mirror of
https://github.com/atsunatsu/Look4Sat.git
synced 2026-10-04 19:47:22 +00:00
Changes to LEO sat ViewHolder
This commit is contained in:
1 parent
886a27b016
commit
1c6d22ccf9
10 files changed
+68
-99
No files matched your search
@@ -108,19 +108,15 @@ class PassesAdapter(context: Context, private var shouldUseUTC: Boolean = false)
|
||||
|
||||
fun bind(satPass: SatPass) {
|
||||
binding.apply {
|
||||
if (satPass.active) passLeoImg.setImageResource(R.drawable.ic_pass_active)
|
||||
else passLeoImg.setImageResource(R.drawable.ic_pass_inactive)
|
||||
|
||||
if (shouldUseUTC) simpleDateFormat.timeZone = timeZoneUTC
|
||||
val startTime = simpleDateFormat.format(satPass.pass.startTime)
|
||||
val endTime = simpleDateFormat.format(satPass.pass.endTime)
|
||||
passLeoSatName.text = satPass.tle.name
|
||||
passLeoSatId.text = String.format(satIdFormat, satPass.tle.catnum)
|
||||
passLeoAosAz.text = String.format(aosAzFormat, startTime, satPass.pass.aosAzimuth)
|
||||
passLeoMaxEl.text = String.format(elevFormat, satPass.pass.maxEl)
|
||||
passLeoAosAz.text = String.format(aosAzFormat, satPass.pass.aosAzimuth)
|
||||
passLeoLosAz.text = String.format(losAzFormat, satPass.pass.losAzimuth)
|
||||
passLeoLosAz.text = String.format(losAzFormat, satPass.pass.losAzimuth, endTime)
|
||||
passLeoProgress.progress = satPass.progress
|
||||
|
||||
if (shouldUseUTC) simpleDateFormat.timeZone = timeZoneUTC
|
||||
passLeoAosTime.text = simpleDateFormat.format(satPass.pass.startTime)
|
||||
passLeoLosTime.text = simpleDateFormat.format(satPass.pass.endTime)
|
||||
}
|
||||
|
||||
itemView.setOnClickListener {
|
||||
|
||||
@@ -22,8 +22,10 @@ package com.rtbishop.look4sat.ui.fragments
|
||||
import android.animation.ObjectAnimator
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import androidx.core.content.res.ResourcesCompat
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.activityViewModels
|
||||
import androidx.recyclerview.widget.DividerItemDecoration
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.SimpleItemAnimator
|
||||
import com.rtbishop.look4sat.R
|
||||
@@ -60,14 +62,11 @@ class PassesFragment : Fragment(R.layout.fragment_passes) {
|
||||
|
||||
private fun setupObservers() {
|
||||
viewModel.getPasses().observe(viewLifecycleOwner, { result ->
|
||||
when (result) {
|
||||
is Result.Success -> {
|
||||
animator.cancel()
|
||||
passes = result.data
|
||||
passesAdapter.setList(passes)
|
||||
}
|
||||
is Result.InProgress -> animator.start()
|
||||
}
|
||||
if (result is Result.Success) {
|
||||
animator.cancel()
|
||||
passes = result.data
|
||||
passesAdapter.setList(passes)
|
||||
} else if (result is Result.InProgress) animator.start()
|
||||
})
|
||||
viewModel.getCurrentTimeMillis().observe(viewLifecycleOwner, { currentTime ->
|
||||
tickMainTimer(currentTime)
|
||||
@@ -79,10 +78,16 @@ class PassesFragment : Fragment(R.layout.fragment_passes) {
|
||||
passesAdapter = PassesAdapter(requireContext(), prefsManager.shouldUseUTC())
|
||||
binding.apply {
|
||||
passesRecycler.apply {
|
||||
layoutManager = LinearLayoutManager(requireContext())
|
||||
val linearLayoutMgr = LinearLayoutManager(requireContext())
|
||||
val divider = DividerItemDecoration(requireContext(), linearLayoutMgr.orientation)
|
||||
val drawable = ResourcesCompat
|
||||
.getDrawable(resources, R.drawable.rec_passes_divider, requireActivity().theme)
|
||||
drawable?.let { divider.setDrawable(it) }
|
||||
layoutManager = linearLayoutMgr
|
||||
adapter = passesAdapter
|
||||
isVerticalScrollBarEnabled = false
|
||||
(itemAnimator as SimpleItemAnimator).supportsChangeAnimations = false
|
||||
addItemDecoration(divider)
|
||||
setHasFixedSize(true)
|
||||
}
|
||||
animator = passesFab.getRotationAnimator()
|
||||
|
||||
Reference in new issue
Block a user