From f343b977049e89632c37db20e1ff315b2302fafa Mon Sep 17 00:00:00 2001 From: Danila Fedorin Date: Tue, 12 May 2020 18:49:39 -0700 Subject: [PATCH] Add stimulus activation report counter to UI --- app/build.gradle | 2 ++ .../danilafe/fencelessgrazing/CollarDetailActivity.kt | 3 +++ .../com/danilafe/fencelessgrazing/model/CollarDetails.kt | 2 +- .../danilafe/fencelessgrazing/requests/GsonListener.kt | 1 - app/src/main/res/layout/activity_collar_detail.xml | 9 +++++++++ app/src/main/res/values/strings.xml | 1 + 6 files changed, 16 insertions(+), 2 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index f4622cd..a0aae65 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -25,6 +25,7 @@ android { repositories { mavenCentral() + maven { url 'https://jitpack.io' } } dependencies { @@ -41,4 +42,5 @@ dependencies { implementation 'androidx.recyclerview:recyclerview:1.1.0' implementation 'org.osmdroid:osmdroid-android:6.1.5' implementation "androidx.preference:preference-ktx:1.1.0" + implementation 'com.github.PhilJay:MPAndroidChart:v3.1.0' } diff --git a/app/src/main/java/com/danilafe/fencelessgrazing/CollarDetailActivity.kt b/app/src/main/java/com/danilafe/fencelessgrazing/CollarDetailActivity.kt index c8fa862..7366874 100644 --- a/app/src/main/java/com/danilafe/fencelessgrazing/CollarDetailActivity.kt +++ b/app/src/main/java/com/danilafe/fencelessgrazing/CollarDetailActivity.kt @@ -23,6 +23,7 @@ class CollarDetailActivity : AppCompatActivity() { private lateinit var collarName: TextView private lateinit var collarPos: TextView + private lateinit var collarStimulus: TextView private lateinit var token: String private lateinit var queue: RequestQueue @@ -56,6 +57,7 @@ class CollarDetailActivity : AppCompatActivity() { collarName = findViewById(R.id.collarName) collarPos = findViewById(R.id.collarPos) + collarStimulus = findViewById(R.id.collarStimulus) token = intent.getStringExtra("token")!! collarId = intent.getIntExtra("identifier", -1) @@ -104,6 +106,7 @@ class CollarDetailActivity : AppCompatActivity() { val detailRequest = CollarDetailRequest(getString(R.string.apiUrl), collarId, token, Response.Listener { collarName.text = it.name + collarStimulus.text = getString(R.string.collarSummaryStimulus, it.stimulus) }, Response.ErrorListener { Toast.makeText(this, "Failed to retrieve details of collar", Toast.LENGTH_SHORT).show() diff --git a/app/src/main/java/com/danilafe/fencelessgrazing/model/CollarDetails.kt b/app/src/main/java/com/danilafe/fencelessgrazing/model/CollarDetails.kt index af925fa..384482b 100644 --- a/app/src/main/java/com/danilafe/fencelessgrazing/model/CollarDetails.kt +++ b/app/src/main/java/com/danilafe/fencelessgrazing/model/CollarDetails.kt @@ -1,3 +1,3 @@ package com.danilafe.fencelessgrazing.model -data class CollarDetails(val id: Int, val name: String) \ No newline at end of file +data class CollarDetails(val id: Int, val name: String, val stimulus: Int) \ No newline at end of file diff --git a/app/src/main/java/com/danilafe/fencelessgrazing/requests/GsonListener.kt b/app/src/main/java/com/danilafe/fencelessgrazing/requests/GsonListener.kt index a66dcc9..4e5dc4b 100644 --- a/app/src/main/java/com/danilafe/fencelessgrazing/requests/GsonListener.kt +++ b/app/src/main/java/com/danilafe/fencelessgrazing/requests/GsonListener.kt @@ -10,7 +10,6 @@ class GsonListener(private val targetType : Type, private val stringLis private val gson = Gson() override fun onResponse(response: String?) { - Log.i("Response", response) if(response == null) { return stringListener.onResponse(null) } stringListener.onResponse(gson.fromJson(response, targetType)) } diff --git a/app/src/main/res/layout/activity_collar_detail.xml b/app/src/main/res/layout/activity_collar_detail.xml index 28101a1..cb21952 100644 --- a/app/src/main/res/layout/activity_collar_detail.xml +++ b/app/src/main/res/layout/activity_collar_detail.xml @@ -33,4 +33,13 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@+id/collarName" /> + + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 1e5fbf4..fc2c294 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -5,4 +5,5 @@ Log In http://dev.danilafe.com:8090 Currently at %1f, %2f + Required %1d stimuli in the last 24 hours