kopia lustrzana https://github.com/rt-bishop/Look4Sat
Further refactoring. Changed the look of a satellite pass recycler item.
rodzic
eee5c725fd
commit
75996057eb
|
@ -31,5 +31,6 @@ data class SatPass(
|
|||
val tle: TLE,
|
||||
val predictor: @RawValue PassPredictor,
|
||||
val pass: @RawValue SatPassTime,
|
||||
var progress: Int = 0
|
||||
var progress: Int = 0,
|
||||
var active: Boolean = false
|
||||
) : Parcelable
|
|
@ -23,6 +23,7 @@ import android.content.Context
|
|||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.ImageView
|
||||
import android.widget.ProgressBar
|
||||
import android.widget.TextView
|
||||
import androidx.navigation.findNavController
|
||||
|
@ -51,6 +52,7 @@ class SatPassAdapter : RecyclerView.Adapter<SatPassAdapter.SatPassHolder>() {
|
|||
val timeStart = satPass.pass.startTime
|
||||
val timeEnd = satPass.pass.endTime
|
||||
if (timeNow.after(timeStart)) {
|
||||
satPass.active = true
|
||||
val index = satPassList.indexOf(satPass)
|
||||
val deltaTotal = timeEnd.time.minus(timeStart.time)
|
||||
val deltaNow = timeNow.time.minus(timeStart.time)
|
||||
|
@ -83,36 +85,36 @@ class SatPassAdapter : RecyclerView.Adapter<SatPassAdapter.SatPassHolder>() {
|
|||
inner class SatPassHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
|
||||
|
||||
private val context: Context = itemView.context
|
||||
private val passImg = itemView.findViewById<ImageView>(R.id.pass_img)
|
||||
private val satName = itemView.findViewById<TextView>(R.id.pass_satName)
|
||||
private val satId = itemView.findViewById<TextView>(R.id.pass_satId)
|
||||
private val maxEl = itemView.findViewById<TextView>(R.id.pass_maxEl)
|
||||
private val azimuth = itemView.findViewById<TextView>(R.id.pass_azimuth)
|
||||
private val aosAz = itemView.findViewById<TextView>(R.id.pass_aosAz)
|
||||
private val losAz = itemView.findViewById<TextView>(R.id.pass_losAz)
|
||||
private val aosTime = itemView.findViewById<TextView>(R.id.pass_aosTime)
|
||||
private val losTime = itemView.findViewById<TextView>(R.id.pass_losTime)
|
||||
private var progressBar = itemView.findViewById<ProgressBar>(R.id.pass_progress)
|
||||
|
||||
fun bind(satPass: SatPass) {
|
||||
val aos = SimpleDateFormat(
|
||||
context.getString(R.string.pat_time),
|
||||
Locale.getDefault()
|
||||
).format(satPass.pass.startTime)
|
||||
val los = SimpleDateFormat(
|
||||
context.getString(R.string.pat_time),
|
||||
Locale.getDefault()
|
||||
).format(satPass.pass.endTime)
|
||||
|
||||
if (satPass.active) passImg.setImageResource(R.drawable.ic_pass_active)
|
||||
else passImg.setImageResource(R.drawable.ic_pass_inactive)
|
||||
|
||||
satName.text = satPass.tle.name
|
||||
satId.text =
|
||||
String.format(context.getString(R.string.pass_satId), satPass.tle.catnum)
|
||||
maxEl.text =
|
||||
String.format(context.getString(R.string.pass_maxEl), satPass.pass.maxEl)
|
||||
azimuth.text = String.format(
|
||||
context.getString(R.string.pass_azimuth),
|
||||
satPass.pass.aosAzimuth,
|
||||
satPass.pass.losAzimuth
|
||||
)
|
||||
aosTime.text = String.format(context.getString(R.string.pass_aos), aos)
|
||||
losTime.text = String.format(context.getString(R.string.pass_los), los)
|
||||
aosAz.text =
|
||||
String.format(context.getString(R.string.pass_aos_az), satPass.pass.aosAzimuth)
|
||||
losAz.text =
|
||||
String.format(context.getString(R.string.pass_los_az), satPass.pass.losAzimuth)
|
||||
aosTime.text =
|
||||
SimpleDateFormat(context.getString(R.string.pass_dateTime), Locale.getDefault())
|
||||
.format(satPass.pass.startTime)
|
||||
losTime.text =
|
||||
SimpleDateFormat(context.getString(R.string.pass_dateTime), Locale.getDefault())
|
||||
.format(satPass.pass.endTime)
|
||||
progressBar.progress = satPass.progress
|
||||
|
||||
itemView.setOnClickListener {
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24.0"
|
||||
android:viewportHeight="24.0">
|
||||
<path
|
||||
android:fillColor="#FFE082"
|
||||
android:pathData="M12,7c-2.76,0 -5,2.24 -5,5s2.24,5 5,5 5,-2.24 5,-5 -2.24,-5 -5,-5zM12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM12,20c-4.42,0 -8,-3.58 -8,-8s3.58,-8 8,-8 8,3.58 8,8 -3.58,8 -8,8z" />
|
||||
</vector>
|
|
@ -0,0 +1,9 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24.0"
|
||||
android:viewportHeight="24.0">
|
||||
<path
|
||||
android:fillColor="#FFE082"
|
||||
android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM12,20c-4.42,0 -8,-3.58 -8,-8s3.58,-8 8,-8 8,3.58 8,8 -3.58,8 -8,8z" />
|
||||
</vector>
|
|
@ -14,44 +14,68 @@
|
|||
android:layout_height="match_parent"
|
||||
android:background="@drawable/card_pass_background">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/pass_img"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:contentDescription="@string/placeholder"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/pass_satName"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@+id/pass_satName"
|
||||
app:srcCompat="@drawable/ic_pass_inactive" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/pass_satName"
|
||||
style="@style/CardPassName"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginTop="4dp"
|
||||
android:layout_marginStart="4dp"
|
||||
android:text="@string/pass_satName"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
app:layout_constraintBaseline_toBaselineOf="@+id/pass_satId"
|
||||
app:layout_constraintStart_toEndOf="@+id/pass_img" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/pass_satId"
|
||||
style="@style/CardPassText"
|
||||
style="@style/CardPassName"
|
||||
android:layout_marginTop="6dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:text="@string/pass_satId"
|
||||
app:layout_constraintBaseline_toBaselineOf="@+id/pass_satName"
|
||||
app:layout_constraintEnd_toEndOf="parent" />
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/pass_azimuth"
|
||||
android:id="@+id/pass_aosAz"
|
||||
style="@style/CardPassText"
|
||||
android:text="@string/pass_azimuth"
|
||||
app:layout_constraintStart_toStartOf="@+id/pass_satName"
|
||||
app:layout_constraintTop_toBottomOf="@+id/pass_satName" />
|
||||
android:layout_marginEnd="16dp"
|
||||
android:text="@string/pass_aos_az"
|
||||
app:layout_constraintBaseline_toBaselineOf="@+id/pass_maxEl"
|
||||
app:layout_constraintEnd_toStartOf="@+id/pass_maxEl" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/pass_losAz"
|
||||
style="@style/CardPassText"
|
||||
android:layout_marginStart="16dp"
|
||||
android:text="@string/pass_los_az"
|
||||
app:layout_constraintBaseline_toBaselineOf="@+id/pass_maxEl"
|
||||
app:layout_constraintStart_toEndOf="@+id/pass_maxEl" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/pass_maxEl"
|
||||
style="@style/CardPassText"
|
||||
android:layout_marginTop="2dp"
|
||||
android:text="@string/pass_maxEl"
|
||||
app:layout_constraintBaseline_toBaselineOf="@+id/pass_azimuth"
|
||||
app:layout_constraintEnd_toEndOf="@+id/pass_satId" />
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toEndOf="@+id/pass_aosAz"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/pass_satId" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/pass_aosTime"
|
||||
style="@style/CardPassText"
|
||||
android:layout_marginBottom="4dp"
|
||||
android:text="@string/pass_aos"
|
||||
android:layout_marginBottom="6dp"
|
||||
android:text="@string/pass_dateTime"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="@+id/pass_progress"
|
||||
app:layout_constraintTop_toBottomOf="@+id/pass_progress" />
|
||||
|
@ -59,7 +83,7 @@
|
|||
<TextView
|
||||
android:id="@+id/pass_losTime"
|
||||
style="@style/CardPassText"
|
||||
android:text="@string/pass_los"
|
||||
android:text="@string/pass_dateTime"
|
||||
app:layout_constraintBaseline_toBaselineOf="@+id/pass_aosTime"
|
||||
app:layout_constraintEnd_toEndOf="@+id/pass_progress" />
|
||||
|
||||
|
@ -68,9 +92,9 @@
|
|||
style="?android:attr/progressBarStyleHorizontal"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintEnd_toEndOf="@+id/pass_maxEl"
|
||||
app:layout_constraintStart_toStartOf="@+id/pass_azimuth"
|
||||
app:layout_constraintTop_toBottomOf="@+id/pass_azimuth" />
|
||||
app:layout_constraintEnd_toEndOf="@+id/pass_satId"
|
||||
app:layout_constraintStart_toStartOf="@+id/pass_img"
|
||||
app:layout_constraintTop_toBottomOf="@+id/pass_maxEl" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</com.google.android.material.card.MaterialCardView>
|
|
@ -17,9 +17,9 @@
|
|||
android:id="@+id/trans_description"
|
||||
style="@style/CardTransText"
|
||||
android:text="@string/trans_description"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/imageView"
|
||||
app:layout_constraintStart_toEndOf="@+id/imageView"
|
||||
app:layout_constraintTop_toTopOf="@+id/imageView" />
|
||||
app:layout_constraintBottom_toBottomOf="@+id/trans_img"
|
||||
app:layout_constraintStart_toEndOf="@+id/trans_img"
|
||||
app:layout_constraintTop_toTopOf="@+id/trans_img" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/trans_downlink"
|
||||
|
@ -60,7 +60,7 @@
|
|||
app:layout_constraintEnd_toEndOf="parent" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/imageView"
|
||||
android:id="@+id/trans_img"
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="20dp"
|
||||
android:layout_marginStart="4dp"
|
||||
|
@ -72,7 +72,7 @@
|
|||
app:srcCompat="@drawable/ic_trans" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/imageView2"
|
||||
android:id="@+id/trans_img_downlink"
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="20dp"
|
||||
android:contentDescription="@string/placeholder"
|
||||
|
@ -83,7 +83,7 @@
|
|||
app:srcCompat="@drawable/ic_arrow" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/imageView3"
|
||||
android:id="@+id/trans_img_uplink"
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="20dp"
|
||||
android:contentDescription="@string/placeholder"
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
android:id="@+id/pass_list_recycler"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:paddingBottom="4dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
|
|
|
@ -66,14 +66,13 @@
|
|||
<string name="err_no_selection_file">Selection file was not found</string>
|
||||
|
||||
<string name="pass_satName">%s</string>
|
||||
<string name="pass_aos">AOS - %s</string>
|
||||
<string name="pass_los">LOS - %s</string>
|
||||
<string name="pass_satId">Id: %d</string>
|
||||
<string name="pass_aos_az">AOS — %2d°</string>
|
||||
<string name="pass_maxEl">MaxEl: %.1f°</string>
|
||||
<string name="pass_azimuth">Az: %2d° -> %2d°</string>
|
||||
<string name="pass_los_az">LOS — %2d°</string>
|
||||
<string name="pass_dateTime">MMM dd @ HH:mm:ss</string>
|
||||
|
||||
<string name="pat_location">%.4f</string>
|
||||
<string name="pat_time">HH:mm:ss</string>
|
||||
<string name="pat_azimuth">Azimuth: %.1f°</string>
|
||||
<string name="pat_elevation">Elevation: %.1f°</string>
|
||||
<string name="pat_latitude">Latitude: %.1f°</string>
|
||||
|
|
|
@ -69,13 +69,13 @@
|
|||
<style name="CardPassText">
|
||||
<item name="android:layout_width">wrap_content</item>
|
||||
<item name="android:layout_height">wrap_content</item>
|
||||
<item name="android:textSize">18sp</item>
|
||||
<item name="android:textSize">17sp</item>
|
||||
</style>
|
||||
|
||||
<style name="CardPassName">
|
||||
<item name="android:layout_width">wrap_content</item>
|
||||
<item name="android:layout_height">wrap_content</item>
|
||||
<item name="android:textSize">21sp</item>
|
||||
<item name="android:textSize">19sp</item>
|
||||
<item name="android:textColor">@color/themeAccent</item>
|
||||
</style>
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue