Show animation if carbs are required

This commit is contained in:
Tim Gunn 2020-05-10 21:24:46 +12:00
parent 68d0e33a9b
commit a501b37159
No known key found for this signature in database
GPG key ID: C9BC1E9D0D0AED8C

View file

@ -7,6 +7,7 @@ import android.content.Context
import android.content.Intent import android.content.Intent
import android.graphics.Color import android.graphics.Color
import android.graphics.Paint import android.graphics.Paint
import android.graphics.drawable.AnimationDrawable
import android.os.Bundle import android.os.Bundle
import android.os.Handler import android.os.Handler
import android.util.DisplayMetrics import android.util.DisplayMetrics
@ -155,6 +156,8 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
private val secondaryGraphs = ArrayList<GraphView>() private val secondaryGraphs = ArrayList<GraphView>()
private val secondaryGraphsLabel = ArrayList<TextView>() private val secondaryGraphsLabel = ArrayList<TextView>()
private lateinit var carbAnimation: AnimationDrawable
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?): View? { savedInstanceState: Bundle?): View? {
@ -184,6 +187,11 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
overview_bggraph?.gridLabelRenderer?.reloadStyles() overview_bggraph?.gridLabelRenderer?.reloadStyles()
overview_bggraph?.gridLabelRenderer?.labelVerticalWidth = axisWidth overview_bggraph?.gridLabelRenderer?.labelVerticalWidth = axisWidth
val carbicon = overview_carbs_icon;
carbAnimation = carbicon.background as AnimationDrawable
carbAnimation.setEnterFadeDuration(1200);
carbAnimation.setExitFadeDuration(1200);
rangeToDisplay = sp.getInt(R.string.key_rangetodisplay, 6) rangeToDisplay = sp.getInt(R.string.key_rangetodisplay, 6)
overview_bggraph?.setOnLongClickListener { overview_bggraph?.setOnLongClickListener {
@ -733,17 +741,18 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
cobText = resourceHelper.gs(R.string.format_carbs, cobInfo.displayCob.toInt()) cobText = resourceHelper.gs(R.string.format_carbs, cobInfo.displayCob.toInt())
if (cobInfo.futureCarbs > 0) cobText += "(" + DecimalFormatter.to0Decimal(cobInfo.futureCarbs) + ")" if (cobInfo.futureCarbs > 0) cobText += "(" + DecimalFormatter.to0Decimal(cobInfo.futureCarbs) + ")"
} }
overview_cob?.text = cobText
val lastRun = loopPlugin.lastRun val lastRun = loopPlugin.lastRun
if (config.APS && lastRun?.constraintsProcessed != null && lastRun?.constraintsProcessed.carbsReq > 0) {
// if (config.APS && lastRun?.constraintsProcessed != null && lastRun?.constraintsProcessed.carbsReq > 0) { overview_cob?.text = cobText + " ("+lastRun?.constraintsProcessed.carbsReq + " req)"
// overview_cob_required.visibility = View.VISIBLE if(!carbAnimation.isRunning)
// var carbsRequiredString: String = String.format(resourceHelper.gs(R.string.overview_carbs_required), lastRun?.constraintsProcessed?.carbsReq, lastRun?.constraintsProcessed?.carbsReqWithin) carbAnimation.start()
// overview_cob_required.text = carbsRequiredString }else{
// } else { overview_cob?.text = cobText
// overview_cob_required.visibility = View.GONE if(carbAnimation.isRunning)
// } carbAnimation.stop()
carbAnimation.selectDrawable(0);
}
val predictionsAvailable = if (config.APS) lastRun?.request?.hasPredictions == true else config.NSCLIENT val predictionsAvailable = if (config.APS) lastRun?.request?.hasPredictions == true else config.NSCLIENT