Skip to content

Commit

Permalink
Show local results only after 1s
Browse files Browse the repository at this point in the history
  • Loading branch information
dzlabing committed Apr 25, 2023
1 parent 9794f46 commit cb8ce27
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -873,7 +873,7 @@ fun AppCompatTextView.setDownload(speedDownloadClassification: Classification) {
fun AppCompatTextView.speedDownloadResult(speedDownloadResult: Long, speedDownloadClassificationResult: Classification) {

text = if (speedDownloadResult > 0) {
context.getString(R.string.measurement_download_upload_speed, ((speedDownloadResult.toFloat() / 1000f).format()))
context.getString(R.string.measurement_download_upload_speed, ((speedDownloadResult.toFloat() / 1000f)))//.format()))
} else {
context.getString(R.string.measurement_dash)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package at.rtr.rmbt.android.ui.activity
import android.content.Context
import android.content.Intent
import android.os.Bundle
import android.os.Handler
import android.view.View
import androidx.core.content.ContextCompat
import androidx.recyclerview.widget.DividerItemDecoration
Expand All @@ -21,6 +22,8 @@ import at.rtr.rmbt.android.viewmodel.ResultViewModel
import at.specure.data.NetworkTypeCompat
import at.specure.data.entity.TestResultRecord
import timber.log.Timber
import java.util.Timer
import kotlin.concurrent.timerTask

class ResultsActivity : BaseActivity() {

Expand All @@ -31,6 +34,7 @@ class ResultsActivity : BaseActivity() {
private lateinit var resultChartFragmentPagerAdapter: ResultChartFragmentPagerAdapter

private var mapLoadRequested: Boolean = false
private val timer = Timer()

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
Expand All @@ -55,7 +59,15 @@ class ResultsActivity : BaseActivity() {
viewModel.state.testUUID = testUUID
viewModel.state.returnPoint = returnPoint?.let { ReturnPoint.valueOf(returnPoint) } ?: ReturnPoint.HOME
viewModel.testServerResultLiveData.listen(this) { result ->
viewModel.state.testResult.set(result)

if (result?.isLocalOnly == true) {
timer.schedule(timerTask {
viewModel.state.testResult.set(result)
}, 1000)
} else {
timer.cancel()
viewModel.state.testResult.set(result)
}

result?.testOpenUUID?.let {
resultChartFragmentPagerAdapter = ResultChartFragmentPagerAdapter(supportFragmentManager, testUUID, result.networkType)
Expand Down
7 changes: 4 additions & 3 deletions app/src/main/res/layout/activity_results.xml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="@string/text_failed_to_load_results"
android:visibility="gone"
app:visibleOrGone="@{state.testResult == null}"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
Expand All @@ -110,7 +110,7 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:visibleOrGone="@{false}" />
app:visibleOrGone="@{state.testResult != null && state.testResult.localOnly}" />

<androidx.cardview.widget.CardView
android:id="@+id/mapContainer"
Expand Down Expand Up @@ -334,7 +334,8 @@
android:orientation="vertical"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textDownloadSpeed">
app:layout_constraintTop_toBottomOf="@+id/textDownloadSpeed"
app:visibleOrGone="@{state.testResult != null}">

<androidx.viewpager.widget.ViewPager
android:id="@+id/viewPagerCharts"
Expand Down

0 comments on commit cb8ce27

Please sign in to comment.