Change empty view icon

This commit is contained in:
Phillip Hsu
2016-09-28 14:38:13 -07:00
parent b08ef0c30d
commit 708edc042e
6 changed files with 35 additions and 15 deletions
@@ -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());