-
-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Kyle Corry <kylecorry31@gmail.com>
- Loading branch information
1 parent
6fdf08d
commit 8a62ba1
Showing
4 changed files
with
47 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
app/src/main/java/com/kylecorry/trail_sense/tools/tools/widgets/ChartToolWidgetViewBase.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package com.kylecorry.trail_sense.tools.tools.widgets | ||
|
||
import android.content.Context | ||
import android.view.View | ||
import android.widget.RemoteViews | ||
import androidx.lifecycle.Lifecycle | ||
import com.kylecorry.andromeda.core.system.Resources | ||
import com.kylecorry.andromeda.core.ui.Views | ||
import com.kylecorry.trail_sense.R | ||
import com.kylecorry.trail_sense.tools.tools.ui.widgets.ToolWidgetView | ||
|
||
abstract class ChartToolWidgetViewBase: ToolWidgetView { | ||
protected val LAYOUT = R.layout.widget_chart | ||
protected val ROOT = R.id.widget_frame | ||
protected val TITLE_TEXTVIEW = R.id.widget_title | ||
protected val CHART = R.id.widget_chart | ||
|
||
override fun onInAppEvent(context: Context, event: Lifecycle.Event, triggerUpdate: () -> Unit) { | ||
// Do nothing | ||
} | ||
|
||
protected fun renderChart(context: Context, views: RemoteViews, view: View){ | ||
val width = Resources.dp(context, 400f).toInt() | ||
val height = Resources.dp(context, 200f).toInt() | ||
val bitmap = Views.renderViewAsBitmap(view, width, height) | ||
views.setImageViewBitmap(CHART, bitmap) | ||
} | ||
|
||
override fun getView(context: Context): RemoteViews { | ||
return RemoteViews(context.packageName, LAYOUT) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters