clean Sad's shit
This commit is contained in:
parent
84e300482a
commit
cc5b512441
53 changed files with 652 additions and 466 deletions
|
@ -4,17 +4,16 @@ import android.content.Context
|
|||
import android.content.Intent
|
||||
import android.graphics.Bitmap
|
||||
import android.graphics.BitmapFactory
|
||||
import android.net.Uri
|
||||
import android.widget.RemoteViews
|
||||
import android.widget.RemoteViewsService
|
||||
import androidx.core.net.toUri
|
||||
import ani.dantotsu.R
|
||||
import ani.dantotsu.logger
|
||||
import java.io.InputStream
|
||||
import java.net.HttpURLConnection
|
||||
import java.net.URL
|
||||
|
||||
class CurrentlyAiringRemoteViewsFactory(private val context: Context, intent: Intent) : RemoteViewsService.RemoteViewsFactory {
|
||||
class CurrentlyAiringRemoteViewsFactory(private val context: Context, intent: Intent) :
|
||||
RemoteViewsService.RemoteViewsFactory {
|
||||
private var widgetItems = mutableListOf<WidgetItem>()
|
||||
|
||||
override fun onCreate() {
|
||||
|
@ -22,7 +21,11 @@ class CurrentlyAiringRemoteViewsFactory(private val context: Context, intent: In
|
|||
widgetItems.clear()
|
||||
logger("CurrentlyAiringRemoteViewsFactory onCreate")
|
||||
widgetItems = List(4) {
|
||||
WidgetItem("Show $it", "$it days $it hours $it minutes", "https://s4.anilist.co/file/anilistcdn/media/anime/cover/large/bx14741-alxqoP4yx6WF.jpg")
|
||||
WidgetItem(
|
||||
"Show $it",
|
||||
"$it days $it hours $it minutes",
|
||||
"https://s4.anilist.co/file/anilistcdn/media/anime/cover/large/bx14741-alxqoP4yx6WF.jpg"
|
||||
)
|
||||
}.toMutableList()
|
||||
}
|
||||
|
||||
|
@ -30,11 +33,41 @@ class CurrentlyAiringRemoteViewsFactory(private val context: Context, intent: In
|
|||
// 4 items for testing
|
||||
logger("CurrentlyAiringRemoteViewsFactory onDataSetChanged")
|
||||
widgetItems.clear()
|
||||
widgetItems.add(WidgetItem("Show 1", "1 day 2 hours 3 minutes", "https://s4.anilist.co/file/anilistcdn/media/anime/cover/large/bx14741-alxqoP4yx6WF.jpg"))
|
||||
widgetItems.add(WidgetItem("Show 2", "2 days 3 hours 4 minutes", "https://s4.anilist.co/file/anilistcdn/media/anime/cover/large/bx14741-alxqoP4yx6WF.jpg"))
|
||||
widgetItems.add(WidgetItem("Show 3", "3 days 4 hours 5 minutes", "https://s4.anilist.co/file/anilistcdn/media/anime/cover/large/bx14741-alxqoP4yx6WF.jpg"))
|
||||
widgetItems.add(WidgetItem("Show 4", "4 days 5 hours 6 minutes", "https://s4.anilist.co/file/anilistcdn/media/anime/cover/large/bx14741-alxqoP4yx6WF.jpg"))
|
||||
widgetItems.add(WidgetItem("Show 5", "5 days 6 hours 7 minutes", "https://s4.anilist.co/file/anilistcdn/media/anime/cover/large/bx14741-alxqoP4yx6WF.jpg"))
|
||||
widgetItems.add(
|
||||
WidgetItem(
|
||||
"Show 1",
|
||||
"1 day 2 hours 3 minutes",
|
||||
"https://s4.anilist.co/file/anilistcdn/media/anime/cover/large/bx14741-alxqoP4yx6WF.jpg"
|
||||
)
|
||||
)
|
||||
widgetItems.add(
|
||||
WidgetItem(
|
||||
"Show 2",
|
||||
"2 days 3 hours 4 minutes",
|
||||
"https://s4.anilist.co/file/anilistcdn/media/anime/cover/large/bx14741-alxqoP4yx6WF.jpg"
|
||||
)
|
||||
)
|
||||
widgetItems.add(
|
||||
WidgetItem(
|
||||
"Show 3",
|
||||
"3 days 4 hours 5 minutes",
|
||||
"https://s4.anilist.co/file/anilistcdn/media/anime/cover/large/bx14741-alxqoP4yx6WF.jpg"
|
||||
)
|
||||
)
|
||||
widgetItems.add(
|
||||
WidgetItem(
|
||||
"Show 4",
|
||||
"4 days 5 hours 6 minutes",
|
||||
"https://s4.anilist.co/file/anilistcdn/media/anime/cover/large/bx14741-alxqoP4yx6WF.jpg"
|
||||
)
|
||||
)
|
||||
widgetItems.add(
|
||||
WidgetItem(
|
||||
"Show 5",
|
||||
"5 days 6 hours 7 minutes",
|
||||
"https://s4.anilist.co/file/anilistcdn/media/anime/cover/large/bx14741-alxqoP4yx6WF.jpg"
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
|
|
|
@ -3,6 +3,7 @@ package ani.dantotsu.widgets
|
|||
import android.content.Intent
|
||||
import android.widget.RemoteViewsService
|
||||
import ani.dantotsu.logger
|
||||
|
||||
class CurrentlyAiringRemoteViewsService : RemoteViewsService() {
|
||||
override fun onGetViewFactory(intent: Intent): RemoteViewsFactory {
|
||||
logger("CurrentlyAiringRemoteViewsFactory onGetViewFactory")
|
||||
|
|
|
@ -20,7 +20,11 @@ import ani.dantotsu.R
|
|||
* App Widget Configuration implemented in [CurrentlyAiringWidgetConfigureActivity]
|
||||
*/
|
||||
class CurrentlyAiringWidget : AppWidgetProvider() {
|
||||
override fun onUpdate(context: Context, appWidgetManager: AppWidgetManager, appWidgetIds: IntArray) {
|
||||
override fun onUpdate(
|
||||
context: Context,
|
||||
appWidgetManager: AppWidgetManager,
|
||||
appWidgetIds: IntArray
|
||||
) {
|
||||
appWidgetIds.forEach { appWidgetId ->
|
||||
val intent = Intent(context, CurrentlyAiringRemoteViewsService::class.java).apply {
|
||||
putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId)
|
||||
|
@ -36,6 +40,7 @@ class CurrentlyAiringWidget : AppWidgetProvider() {
|
|||
}
|
||||
super.onUpdate(context, appWidgetManager, appWidgetIds)
|
||||
}
|
||||
|
||||
override fun onDeleted(context: Context, appWidgetIds: IntArray) {
|
||||
// When the user deletes the widget, delete the preference associated with it.
|
||||
for (appWidgetId in appWidgetIds) {
|
||||
|
@ -51,6 +56,7 @@ class CurrentlyAiringWidget : AppWidgetProvider() {
|
|||
override fun onDisabled(context: Context) {
|
||||
super.onDisabled(context)
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun updateAppWidget(
|
||||
context: Context,
|
||||
|
@ -60,10 +66,15 @@ class CurrentlyAiringWidget : AppWidgetProvider() {
|
|||
) {
|
||||
// Create an intent to launch the configuration activity when the widget is clicked
|
||||
val intent = Intent(context, CurrentlyAiringWidgetConfigureActivity::class.java)
|
||||
val pendingIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_IMMUTABLE)
|
||||
val pendingIntent =
|
||||
PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_IMMUTABLE)
|
||||
|
||||
// Get the gradient drawable resource and update its start color with the user-selected color
|
||||
val gradientDrawable = ResourcesCompat.getDrawable(context.resources, R.drawable.gradient_background, null) as GradientDrawable
|
||||
val gradientDrawable = ResourcesCompat.getDrawable(
|
||||
context.resources,
|
||||
R.drawable.gradient_background,
|
||||
null
|
||||
) as GradientDrawable
|
||||
gradientDrawable.colors = intArrayOf(color, Color.GRAY) // End color is gray.
|
||||
|
||||
// Create the RemoteViews object and set the background
|
||||
|
|
|
@ -57,7 +57,7 @@ class CurrentlyAiringWidgetConfigureActivity : Activity() {
|
|||
binding = CurrentlyAiringWidgetConfigureBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
|
||||
appWidgetText = binding.appwidgetText as EditText
|
||||
appWidgetText = binding.appwidgetText
|
||||
binding.addButton.setOnClickListener(onClickListener)
|
||||
|
||||
// Find the widget id from the intent.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue