|
|
|
@ -11,7 +11,6 @@ import android.view.LayoutInflater
|
|
|
|
|
import android.view.View
|
|
|
|
|
import android.view.ViewGroup
|
|
|
|
|
import android.widget.Toast
|
|
|
|
|
import androidx.core.view.size
|
|
|
|
|
import androidx.fragment.app.Fragment
|
|
|
|
|
import androidx.fragment.app.activityViewModels
|
|
|
|
|
import androidx.lifecycle.asLiveData
|
|
|
|
@ -40,6 +39,7 @@ import com.example.rehabilitation.SportUserTrue
|
|
|
|
|
import com.example.rehabilitation.User.fragmentUser.QuestionnaireFragment.QAfterFragment
|
|
|
|
|
import com.example.rehabilitation.User.fragmentUser.QuestionnaireFragment.QBeforeFragment
|
|
|
|
|
import com.example.rehabilitation.databinding.FragmentSceduleBinding
|
|
|
|
|
import com.example.rehabilitation.listImageSport
|
|
|
|
|
import com.example.rehabilitation.model_adapter.DataModel
|
|
|
|
|
import com.example.rehabilitation.model_adapter.Day.DayAdapter
|
|
|
|
|
import com.example.rehabilitation.model_adapter.Day.DayListModel
|
|
|
|
@ -82,7 +82,6 @@ class SceduleFragment(/*var taskItem: TaskItem?*/) : Fragment()/*, MonthAdapter.
|
|
|
|
|
lateinit var adapterDay: DayAdapter
|
|
|
|
|
lateinit var adapterImage: ImageSportAdapter
|
|
|
|
|
|
|
|
|
|
private lateinit var scrollListener: RecyclerView.OnScrollListener
|
|
|
|
|
|
|
|
|
|
//Количество выполненных тренировок
|
|
|
|
|
|
|
|
|
@ -108,6 +107,8 @@ class SceduleFragment(/*var taskItem: TaskItem?*/) : Fragment()/*, MonthAdapter.
|
|
|
|
|
//Таймер для открытия упражнения
|
|
|
|
|
var time: Long = 0
|
|
|
|
|
var times = 0
|
|
|
|
|
private lateinit var scrollListener: RecyclerView.OnScrollListener
|
|
|
|
|
private val lastVisibleItemPosition: Int get() = binding.rcViewImage.layoutManager.hashCode()//По вертикали будет выводить по умолчанию)
|
|
|
|
|
override fun onCreateView(
|
|
|
|
|
inflater: LayoutInflater, container: ViewGroup?,
|
|
|
|
|
savedInstanceState: Bundle?
|
|
|
|
@ -201,6 +202,8 @@ class SceduleFragment(/*var taskItem: TaskItem?*/) : Fragment()/*, MonthAdapter.
|
|
|
|
|
model.liveImageList.observe(viewLifecycleOwner) {//viewLifecycleOwner - следит за циклом жизни fragment
|
|
|
|
|
adapterImage.submitList(it)//Напрямую переадем созданный список в adapter(ProductAdapter)
|
|
|
|
|
binding.LoadImage.visibility = View.GONE
|
|
|
|
|
listImageSport = it
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//Drk.xtybt vtnhjyjvf
|
|
|
|
@ -247,7 +250,54 @@ class SceduleFragment(/*var taskItem: TaskItem?*/) : Fragment()/*, MonthAdapter.
|
|
|
|
|
Log.i("Sport15DayAll","${Sport15DayAll}")
|
|
|
|
|
Log.i("SportCursDayNumber","${SportCursDayNumber}")
|
|
|
|
|
|
|
|
|
|
binding.rcViewImage.addOnScrollListener(object : RecyclerView.OnScrollListener() {
|
|
|
|
|
override fun onScrollStateChanged(recyclerView: RecyclerView, newState: Int) {
|
|
|
|
|
super.onScrollStateChanged(recyclerView, newState)
|
|
|
|
|
if (newState == RecyclerView.SCROLL_STATE_IDLE) {
|
|
|
|
|
Log.i("listImageSport","${listImageSport}")
|
|
|
|
|
initRcViewImage()
|
|
|
|
|
adapterImage.submitList(listImageSport)
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
// var loading = true
|
|
|
|
|
// var pastItemsVisible: Int
|
|
|
|
|
// var visibleItemCount: Int
|
|
|
|
|
// var totalItemCount: Int
|
|
|
|
|
//
|
|
|
|
|
// binding.rcViewImage.addOnScrollListener(object : RecyclerView.OnScrollListener() {
|
|
|
|
|
// override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
|
|
|
|
|
// if (dy > 0) { //check for scroll down
|
|
|
|
|
// visibleItemCount = binding.rcViewImage.layoutManager!!.getChildCount()
|
|
|
|
|
// totalItemCount = binding.rcViewImage.layoutManager!!.getItemCount()
|
|
|
|
|
// pastItemsVisible = binding.rcViewImage.layoutManager!!.findFirstVisibleItemPosition()
|
|
|
|
|
// if (loading) {
|
|
|
|
|
// if (visibleItemCount + pastItemsVisible >= totalItemCount) {
|
|
|
|
|
// loading = false
|
|
|
|
|
// Log.v("...", "Last Item !")
|
|
|
|
|
//
|
|
|
|
|
// // Do pagination.. i.e. fetch new data
|
|
|
|
|
// loading = true
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// })
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// binding.rcViewImage.addOnScrollListener(object : RecyclerView.OnScrollListener() {
|
|
|
|
|
// override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
|
|
|
|
|
// val layoutManager = LinearLayoutManager::class.java.cast(recyclerView.layoutManager)
|
|
|
|
|
// val totalItemCount = layoutManager.itemCount
|
|
|
|
|
// val lastVisible = layoutManager.findLastVisibleItemPosition()
|
|
|
|
|
// val endHasBeenReached: Boolean = lastVisible + VISIBLE_ITEMS_COUNT >= totalItemCount
|
|
|
|
|
// if (totalItemCount > 0 && endHasBeenReached) {
|
|
|
|
|
// //logic
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// })
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -544,6 +594,7 @@ class SceduleFragment(/*var taskItem: TaskItem?*/) : Fragment()/*, MonthAdapter.
|
|
|
|
|
// }
|
|
|
|
|
// timer.start()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -812,6 +863,37 @@ class SceduleFragment(/*var taskItem: TaskItem?*/) : Fragment()/*, MonthAdapter.
|
|
|
|
|
adapterImage = ImageSportAdapter(requireContext())
|
|
|
|
|
rcViewImage.adapter = adapterImage
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// val mLayoutManager: LinearLayoutManager
|
|
|
|
|
// mLayoutManager = LinearLayoutManager(requireContext(),LinearLayoutManager.HORIZONTAL, false)
|
|
|
|
|
// binding.rcViewImage.setLayoutManager(mLayoutManager)
|
|
|
|
|
// adapterImage = ImageSportAdapter(requireContext())
|
|
|
|
|
// rcViewImage.adapter = adapterImage
|
|
|
|
|
//
|
|
|
|
|
// var loading = true
|
|
|
|
|
// var pastVisiblesItems: Int
|
|
|
|
|
// var visibleItemCount: Int
|
|
|
|
|
// var totalItemCount: Int
|
|
|
|
|
//
|
|
|
|
|
// binding.rcViewImage.addOnScrollListener(object : RecyclerView.OnScrollListener() {
|
|
|
|
|
// override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
|
|
|
|
|
// if (dy > 0) //check for scroll down
|
|
|
|
|
// {
|
|
|
|
|
// visibleItemCount = mLayoutManager.getChildCount()
|
|
|
|
|
// totalItemCount = mLayoutManager.getItemCount()
|
|
|
|
|
// pastVisiblesItems = mLayoutManager.findFirstVisibleItemPosition()
|
|
|
|
|
// if (loading) {
|
|
|
|
|
// if (visibleItemCount + pastVisiblesItems >= totalItemCount) {
|
|
|
|
|
// loading = false
|
|
|
|
|
// Log.i("terertert", "Last Item Wow !")
|
|
|
|
|
// //Do pagination.. i.e. fetch new data
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// })
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
// Log.i("123112213","${binding.rcViewImage.size.toInt()}")
|
|
|
|
|