Change empty view icon
This commit is contained in:
parent
b08ef0c30d
commit
708edc042e
@ -124,6 +124,11 @@ public class AlarmsFragment extends RecyclerViewFragment<Alarm, BaseAlarmViewHol
|
||||
return R.string.empty_alarms_container;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int emptyIcon() {
|
||||
return R.drawable.ic_alarm_96dp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onListItemClick(Alarm item, int position) {
|
||||
boolean expanded = getAdapter().expand(position);
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
package com.philliphsu.clock2.list;
|
||||
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.DrawableRes;
|
||||
import android.support.annotation.Nullable;
|
||||
@ -16,7 +15,6 @@ import android.widget.TextView;
|
||||
|
||||
import com.philliphsu.clock2.BaseFragment;
|
||||
import com.philliphsu.clock2.R;
|
||||
import com.philliphsu.clock2.timepickers.Utils;
|
||||
import com.philliphsu.clock2.data.BaseItemCursor;
|
||||
import com.philliphsu.clock2.data.ObjectWithId;
|
||||
|
||||
@ -79,10 +77,10 @@ public abstract class RecyclerViewFragment<
|
||||
* @return a resource to a Drawable that will be displayed when the list is empty
|
||||
*/
|
||||
@DrawableRes
|
||||
protected int emptyMessageIcon() {
|
||||
// TODO: If this is the same for all RecyclerViewFragments, then why not just specify
|
||||
// the compound drawable in XML?
|
||||
return R.drawable.ic_empty_list_96dp;
|
||||
protected int emptyIcon() {
|
||||
// The reason this isn't abstract is so we don't require subclasses that
|
||||
// don't have an empty view to implement this.
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -117,9 +115,7 @@ public abstract class RecyclerViewFragment<
|
||||
if (hasEmptyView() && mEmptyView != null) {
|
||||
// Configure the empty view, even if there currently are items.
|
||||
mEmptyView.setText(emptyMessage());
|
||||
int iconColor = Utils.getTextColorFromThemeAttr(getActivity(), R.attr.themedIconTint);
|
||||
Drawable emptyMessageIcon = Utils.getTintedDrawable(getActivity(), emptyMessageIcon(), iconColor);
|
||||
mEmptyView.setCompoundDrawablesRelativeWithIntrinsicBounds(null, emptyMessageIcon, null, null);
|
||||
mEmptyView.setCompoundDrawablesRelativeWithIntrinsicBounds(0, emptyIcon(), 0, 0);
|
||||
}
|
||||
return view;
|
||||
}
|
||||
|
||||
@ -109,6 +109,11 @@ public class TimersFragment extends RecyclerViewFragment<Timer, TimerViewHolder,
|
||||
return R.string.empty_timers_container;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int emptyIcon() {
|
||||
return R.drawable.ic_timer_96dp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Loader<TimerCursor> onCreateLoader(int id, Bundle args) {
|
||||
return new TimersListCursorLoader(getActivity());
|
||||
|
||||
10
app/src/main/res/drawable/ic_alarm_96dp.xml
Normal file
10
app/src/main/res/drawable/ic_alarm_96dp.xml
Normal file
@ -0,0 +1,10 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="96dp"
|
||||
android:height="96dp"
|
||||
android:viewportWidth="24.0"
|
||||
android:viewportHeight="24.0">
|
||||
<path
|
||||
android:fillColor="#FFFFFF"
|
||||
android:fillAlpha="0.3"
|
||||
android:pathData="M22,5.72l-4.6,-3.86 -1.29,1.53 4.6,3.86L22,5.72zM7.88,3.39L6.6,1.86 2,5.71l1.29,1.53 4.59,-3.85zM12.5,8H11v6l4.75,2.85 0.75,-1.23 -4,-2.37V8zM12,4c-4.97,0 -9,4.03 -9,9s4.02,9 9,9c4.97,0 9,-4.03 9,-9s-4.03,-9 -9,-9zm0,16c-3.87,0 -7,-3.13 -7,-7s3.13,-7 7,-7 7,3.13 7,7 -3.13,7 -7,7z"/>
|
||||
</vector>
|
||||
@ -1,6 +0,0 @@
|
||||
<vector android:height="96dp" android:viewportHeight="24.0"
|
||||
android:viewportWidth="24.0" android:width="96dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="#FFFFFF"
|
||||
android:fillAlpha="0.3"
|
||||
android:pathData="M14.59,8L12,10.59 9.41,8 8,9.41 10.59,12 8,14.59 9.41,16 12,13.41 14.59,16 16,14.59 13.41,12 16,9.41 14.59,8zM12,2C6.47,2 2,6.47 2,12s4.47,10 10,10 10,-4.47 10,-10S17.53,2 12,2zM12,20c-4.41,0 -8,-3.59 -8,-8s3.59,-8 8,-8 8,3.59 8,8 -3.59,8 -8,8z"/>
|
||||
</vector>
|
||||
10
app/src/main/res/drawable/ic_timer_96dp.xml
Normal file
10
app/src/main/res/drawable/ic_timer_96dp.xml
Normal file
@ -0,0 +1,10 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="96dp"
|
||||
android:height="96dp"
|
||||
android:viewportWidth="24.0"
|
||||
android:viewportHeight="24.0">
|
||||
<path
|
||||
android:fillColor="#FFFFFF"
|
||||
android:fillAlpha="0.3"
|
||||
android:pathData="M11,17c0,0.55 0.45,1 1,1s1,-0.45 1,-1 -0.45,-1 -1,-1 -1,0.45 -1,1zm0,-14v4h2V5.08c3.39,0.49 6,3.39 6,6.92 0,3.87 -3.13,7 -7,7s-7,-3.13 -7,-7c0,-1.68 0.59,-3.22 1.58,-4.42L12,13l1.41,-1.41 -6.8,-6.8v0.02C4.42,6.45 3,9.05 3,12c0,4.97 4.02,9 9,9 4.97,0 9,-4.03 9,-9s-4.03,-9 -9,-9h-1zm7,9c0,-0.55 -0.45,-1 -1,-1s-1,0.45 -1,1 0.45,1 1,1 1,-0.45 1,-1zM6,12c0,0.55 0.45,1 1,1s1,-0.45 1,-1 -0.45,-1 -1,-1 -1,0.45 -1,1z"/>
|
||||
</vector>
|
||||
Loading…
Reference in New Issue
Block a user