From 0b952e12e984fc5fd647ea1423adb42bddcef70f Mon Sep 17 00:00:00 2001 From: Moez Bhatti Date: Fri, 30 Oct 2015 00:14:27 -0400 Subject: [PATCH] Add theme support to empty list indicator --- .../ConversationListFragment.java | 24 +++++++++++++++---- .../res/layout/fragment_conversations.xml | 4 +++- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/QKSMS/src/main/java/com/moez/QKSMS/ui/conversationlist/ConversationListFragment.java b/QKSMS/src/main/java/com/moez/QKSMS/ui/conversationlist/ConversationListFragment.java index 5a93bdc6..7fd229b6 100644 --- a/QKSMS/src/main/java/com/moez/QKSMS/ui/conversationlist/ConversationListFragment.java +++ b/QKSMS/src/main/java/com/moez/QKSMS/ui/conversationlist/ConversationListFragment.java @@ -20,6 +20,8 @@ import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; import android.widget.AdapterView; +import android.widget.ImageView; + import com.melnykov.fab.FloatingActionButton; import com.moez.QKSMS.R; import com.moez.QKSMS.common.BlockedConversationHelper; @@ -60,6 +62,8 @@ public class ConversationListFragment extends QKFragment implements LoaderManage private final int MENU_BLOCK_CONVERSATION = 9; private final int MENU_UNBLOCK_CONVERSATION = 10; + private View mEmptyState; + private ImageView mEmptyStateIcon; private RecyclerView mRecyclerView; private FloatingActionButton mFab; private ConversationListAdapter mAdapter; @@ -69,6 +73,8 @@ public class ConversationListFragment extends QKFragment implements LoaderManage private MenuItem mBlockedItem; private boolean mShowBlocked = false; + private boolean mViewHasLoaded = false; + // This does not hold the current position of the list, rather the position the list is pending being set to private int mPosition; @@ -93,6 +99,10 @@ public class ConversationListFragment extends QKFragment implements LoaderManage public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_conversations, null); + mEmptyState = view.findViewById(R.id.empty_state); + mEmptyStateIcon = (ImageView) view.findViewById(R.id.empty_state_icon); + mEmptyStateIcon.setColorFilter(ThemeManager.getTextOnBackgroundPrimary()); + mRecyclerView = (RecyclerView) view.findViewById(R.id.conversations_list); mRecyclerView.setHasFixedSize(true); mRecyclerView.setLayoutManager(mLayoutManager); @@ -117,6 +127,8 @@ public class ConversationListFragment extends QKFragment implements LoaderManage } }); + mViewHasLoaded = true; + initLoaderManager(); return view; @@ -347,12 +359,16 @@ public class ConversationListFragment extends QKFragment implements LoaderManage @Override public void refresh() { - if (mFab != null) { - mFab.setColorNormal(ThemeManager.getColor()); - mFab.setColorPressed(ColorUtils.lighten(ThemeManager.getColor())); - mFab.getDrawable().setColorFilter(new PorterDuffColorFilter(ThemeManager.getTextOnColorPrimary(), PorterDuff.Mode.MULTIPLY)); + if (!mViewHasLoaded) { + return; } + mFab.setColorNormal(ThemeManager.getColor()); + mFab.setColorPressed(ColorUtils.lighten(ThemeManager.getColor())); + mFab.getDrawable().setColorFilter(new PorterDuffColorFilter(ThemeManager.getTextOnColorPrimary(), PorterDuff.Mode.MULTIPLY)); + + mEmptyStateIcon.setColorFilter(ThemeManager.getTextOnBackgroundPrimary()); + //TODO ListviewHelper.applyCustomScrollbar(mContext, mListView); } diff --git a/QKSMS/src/main/res/layout/fragment_conversations.xml b/QKSMS/src/main/res/layout/fragment_conversations.xml index 249cb289..a8bcb930 100644 --- a/QKSMS/src/main/res/layout/fragment_conversations.xml +++ b/QKSMS/src/main/res/layout/fragment_conversations.xml @@ -9,11 +9,13 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerInParent="true" + android:alpha="0.5" android:gravity="center" android:orientation="vertical" android:paddingBottom="32dp"> -