show an placeholder message if the widgets event list is empty
This commit is contained in:
parent
c7c972c502
commit
3878217665
|
@ -45,7 +45,8 @@ class MyWidgetListProvider : AppWidgetProvider() {
|
|||
mIntent = Intent(mContext, MyWidgetListProvider::class.java)
|
||||
|
||||
val bgColor = prefs.getInt(WIDGET_BG_COLOR, Color.BLACK)
|
||||
mRemoteViews.setInt(R.id.widget_event_list, "setBackgroundColor", bgColor)
|
||||
mRemoteViews.setInt(R.id.widget_event_list_holder, "setBackgroundColor", bgColor)
|
||||
mRemoteViews.setInt(R.id.widget_event_list_empty, "setTextColor", mTextColor)
|
||||
|
||||
Intent(context, WidgetService::class.java).apply {
|
||||
data = Uri.parse(this.toUri(Intent.URI_INTENT_SCHEME))
|
||||
|
@ -55,6 +56,7 @@ class MyWidgetListProvider : AppWidgetProvider() {
|
|||
val startActivityIntent = Intent(context, EventActivity::class.java)
|
||||
val startActivityPendingIntent = PendingIntent.getActivity(context, 0, startActivityIntent, PendingIntent.FLAG_UPDATE_CURRENT)
|
||||
mRemoteViews.setPendingIntentTemplate(R.id.widget_event_list, startActivityPendingIntent)
|
||||
mRemoteViews.setEmptyView(R.id.widget_event_list, R.id.widget_event_list_empty)
|
||||
|
||||
val appWidgetIds = mWidgetManager.getAppWidgetIds(ComponentName(context, MyWidgetListProvider::class.java))
|
||||
mWidgetManager.updateAppWidget(appWidgetIds, mRemoteViews)
|
||||
|
|
|
@ -1,12 +1,28 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ListView
|
||||
<RelativeLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/widget_event_list"
|
||||
android:id="@+id/widget_event_list_holder"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:clipToPadding="false"
|
||||
android:divider="@null"
|
||||
android:dividerHeight="@dimen/medium_padding"
|
||||
android:paddingBottom="@dimen/activity_margin"
|
||||
android:paddingLeft="@dimen/activity_margin"
|
||||
android:paddingTop="@dimen/medium_padding"/>
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<ListView
|
||||
android:id="@+id/widget_event_list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:clipToPadding="false"
|
||||
android:divider="@null"
|
||||
android:dividerHeight="@dimen/medium_padding"
|
||||
android:paddingBottom="@dimen/activity_margin"
|
||||
android:paddingLeft="@dimen/activity_margin"
|
||||
android:paddingTop="@dimen/medium_padding"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/widget_event_list_empty"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_horizontal"
|
||||
android:padding="@dimen/big_margin"
|
||||
android:text="@string/no_upcoming_events"
|
||||
android:textSize="@dimen/dialog_text_size"/>
|
||||
|
||||
</RelativeLayout>
|
||||
|
|
Loading…
Reference in New Issue