-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update and bugs fixed🛠🛠🛠✔
- Loading branch information
1 parent
53d864b
commit 7a0355b
Showing
48 changed files
with
2,431 additions
and
1,148 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
app/src/main/java/com/example/HealthyMode/Adapter/Adapter_todo.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
85 changes: 59 additions & 26 deletions
85
app/src/main/java/com/example/HealthyMode/Adapter/FoodAdapter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,69 @@ | ||
package com.example.HealthyMode.Adapter | ||
|
||
import android.annotation.SuppressLint | ||
import android.content.Context | ||
import android.os.Build | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import android.widget.TextView | ||
import android.widget.Toast | ||
import androidx.annotation.RequiresApi | ||
import androidx.recyclerview.widget.ItemTouchHelper | ||
import androidx.recyclerview.widget.RecyclerView | ||
import com.example.HealthyMode.data_Model.Food | ||
import com.example.HealthyMode.R | ||
|
||
class FoodAdapter(private val foodd:ArrayList<Food>, private val context: Context):RecyclerView.Adapter<FoodAdapter.MyVIewHolder> (){ | ||
|
||
inner class MyVIewHolder(itemView: View): RecyclerView.ViewHolder(itemView){ | ||
private val date: TextView =itemView.findViewById(R.id.fdate) | ||
private val foods: TextView =itemView.findViewById(R.id.food_item) | ||
@SuppressLint("UseCompatLoadingForDrawables") | ||
fun initialize(item: Food){ | ||
date.text=item.date | ||
foods.text=item.foods.toString() | ||
} | ||
|
||
} | ||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MyVIewHolder { | ||
val itemView= | ||
LayoutInflater.from(parent.context).inflate(R.layout.food_trck,parent,false) | ||
return MyVIewHolder(itemView) | ||
import com.example.HealthyMode.data_Model.Nutrient | ||
import com.example.HealthyMode.databinding.FoodListBinding | ||
import com.firebase.ui.firestore.FirestoreRecyclerAdapter | ||
import com.firebase.ui.firestore.FirestoreRecyclerOptions | ||
import com.google.firebase.auth.FirebaseAuth | ||
import com.google.firebase.firestore.DocumentReference | ||
import com.google.firebase.firestore.ktx.firestore | ||
import com.google.firebase.ktx.Firebase | ||
import java.time.LocalDate | ||
class FoodAdapter(val context:Context,val time:String,options: FirestoreRecyclerOptions<Nutrient>): FirestoreRecyclerAdapter<Nutrient, FoodAdapter.ViewHolder>(options) { | ||
private var userDitails: DocumentReference = Firebase.firestore.collection("user").document( | ||
FirebaseAuth.getInstance().currentUser!!.uid | ||
) | ||
class ViewHolder(val binding: FoodListBinding):RecyclerView.ViewHolder(binding.root) | ||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { | ||
val binding= FoodListBinding.inflate(LayoutInflater.from(parent.context),parent,false) | ||
return ViewHolder(binding) | ||
} | ||
@RequiresApi(Build.VERSION_CODES.O) | ||
override fun onBindViewHolder(holder: ViewHolder, position: Int, model: Nutrient) { | ||
holder.binding.itemName.text=model.foodName | ||
holder.binding.amount.text=model.quantity | ||
holder.binding.unit.text=model.unit | ||
holder.binding.calo.text=model.calories | ||
} | ||
private val touchHelper=object :ItemTouchHelper.SimpleCallback( | ||
0,ItemTouchHelper.RIGHT or ItemTouchHelper.LEFT | ||
){ | ||
override fun onMove( | ||
recyclerView: RecyclerView, | ||
viewHolder: RecyclerView.ViewHolder, | ||
target: RecyclerView.ViewHolder | ||
): Boolean { | ||
return false | ||
} | ||
override fun getItemCount(): Int { | ||
return foodd.size | ||
|
||
@RequiresApi(Build.VERSION_CODES.O) | ||
override fun onSwiped(viewHolder: RecyclerView.ViewHolder, direction: Int) { | ||
val position = viewHolder.adapterPosition | ||
val item = getItem(position) | ||
// Delete item from Firestore | ||
userDitails.collection("Meals").document(LocalDate.now().toString()).collection(time) | ||
.document(item.foodName!!) | ||
.delete() | ||
.addOnSuccessListener { | ||
Toast.makeText(context, "$time ${item.foodName} deleted successfully", Toast.LENGTH_SHORT).show() | ||
} | ||
.addOnFailureListener { | ||
// Show error message here | ||
} | ||
} | ||
override fun onBindViewHolder(holder: MyVIewHolder, position: Int) { | ||
holder.initialize(foodd[position]) | ||
} | ||
fun attachswipetoDelete(rec_v:RecyclerView) | ||
{ | ||
val itemtouchHelper=ItemTouchHelper(touchHelper) | ||
itemtouchHelper.attachToRecyclerView(rec_v) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
app/src/main/java/com/example/HealthyMode/ChartRender/CustomMarkerView.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package com.example.HealthyMode.ChartRender | ||
|
||
import android.annotation.SuppressLint | ||
import android.content.Context | ||
import android.widget.TextView | ||
import android.widget.Toast | ||
import com.example.HealthyMode.R | ||
import com.example.HealthyMode.Utils.Constant.convertMillisecondsToDate | ||
import com.github.mikephil.charting.components.MarkerView | ||
import com.github.mikephil.charting.data.Entry | ||
import com.github.mikephil.charting.highlight.Highlight | ||
import com.github.mikephil.charting.utils.MPPointF | ||
|
||
class CustomMarkerView(context: Context, layoutResource: Int, private val check:Long) : MarkerView(context, layoutResource) { | ||
private val tvContent: TextView = findViewById(R.id.chartContent) | ||
private val date: TextView = findViewById(R.id.date) | ||
|
||
@SuppressLint("SetTextI18n") | ||
override fun refreshContent(e: Entry?, highlight: Highlight?) { | ||
if (e == null) { | ||
Toast.makeText(context, " null value", Toast.LENGTH_SHORT).show() | ||
return | ||
} | ||
tvContent.text = "${e.y}" | ||
if(check==0L) | ||
date.text=convertMillisecondsToDate(e.x.toLong() ,"dd-MM-yyyy") | ||
super.refreshContent(e, highlight) | ||
} | ||
override fun getOffset(): MPPointF { | ||
return MPPointF((-(width / 2)).toFloat(), (-height).toFloat()) | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
app/src/main/java/com/example/HealthyMode/FireStore/Repository/Repository.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,19 @@ | ||
package com.example.HealthyMode.FireStore.Repository | ||
|
||
import android.content.Context | ||
import androidx.lifecycle.LiveData | ||
import com.example.HealthyMode.Utils.UIstate | ||
import com.example.HealthyMode.data_Model.Nutrient | ||
import com.example.HealthyMode.data_Model.weight | ||
import com.github.mikephil.charting.data.Entry | ||
|
||
interface Repository { | ||
fun getWeight(result: (UIstate<ArrayList<Entry>>) -> Unit) | ||
fun changedWeight(weight: weight, result: (UIstate<String>) -> Unit) | ||
fun addFood(nutrient: Nutrient, result: (UIstate<Nutrient>) -> Unit) | ||
fun getNutrients(mealTimes: List<String>): LiveData<ArrayList<Float>> | ||
fun getcalories(mealTimes: List<String>): LiveData<ArrayList<Float>> | ||
fun changeHeight(height: String,context:Context) | ||
fun getheight(result: (UIstate<String>) -> Unit) | ||
|
||
} |
Oops, something went wrong.