From 226404a2c46d77e9c8ed8a1e483d77118bc28edd Mon Sep 17 00:00:00 2001 From: Pierre Date: Sat, 14 Apr 2018 17:29:42 +0200 Subject: [PATCH] Display a notice if the user does not have any conversation --- .../fragments/ConversationsListFragment.java | 28 ++++++++++++++++++- .../client/ui/fragments/UserPageFragment.java | 16 +++++------ .../res/layout/fragment_conversationslist.xml | 10 +++++++ app/src/main/res/values/strings.xml | 1 + 4 files changed, 46 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/org/communiquons/android/comunic/client/ui/fragments/ConversationsListFragment.java b/app/src/main/java/org/communiquons/android/comunic/client/ui/fragments/ConversationsListFragment.java index 0689421..7eb530f 100644 --- a/app/src/main/java/org/communiquons/android/comunic/client/ui/fragments/ConversationsListFragment.java +++ b/app/src/main/java/org/communiquons/android/comunic/client/ui/fragments/ConversationsListFragment.java @@ -17,6 +17,7 @@ import android.view.ViewGroup; import android.widget.AdapterView; import android.widget.ListView; import android.widget.ProgressBar; +import android.widget.TextView; import android.widget.Toast; import org.communiquons.android.comunic.client.ui.activities.MainActivity; @@ -64,6 +65,11 @@ public class ConversationsListFragment extends Fragment implements AdapterView.O */ private ConversationsListHelper conversationsListHelper; + /** + * No conversation notice + */ + private TextView mNoConversationNotice; + /** * Conversations ListView */ @@ -114,6 +120,10 @@ public class ConversationsListFragment extends Fragment implements AdapterView.O //Get progress bar wheel progressBar = view.findViewById(R.id.fragment_conversationslist_progressbar); + //Get no conversation notice + mNoConversationNotice = view.findViewById(R.id.no_conversation_notice); + mNoConversationNotice.setVisibility(View.GONE); + //Refresh conversations list refresh_conversations_list(); @@ -307,6 +317,9 @@ public class ConversationsListFragment extends Fragment implements AdapterView.O //Remove progress bar display_progress_bar(false); + + //Update the visibility of the no conversation notice + updateNoConversationNotice(); } @Override @@ -329,7 +342,7 @@ public class ConversationsListFragment extends Fragment implements AdapterView.O confirmDeleteConversation(convID); return true; - //To udpate the conversation + //To update the conversation case R.id.menu_fragment_conversationslist_item_update: updateConversationListener.updateConversation(convID); return true; @@ -403,6 +416,11 @@ public class ConversationsListFragment extends Fragment implements AdapterView.O @Override protected void onPostExecute(Boolean result) { + + //Check if the activity has been destroyed + if(getActivity() == null) + return; + refresh_conversations_list(); //Display a toast if an error occurred @@ -413,4 +431,12 @@ public class ConversationsListFragment extends Fragment implements AdapterView.O } }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } + + /** + * Update the visibility of the "no conversation" notice message + */ + private void updateNoConversationNotice(){ + if(convList != null) + mNoConversationNotice.setVisibility(convList.size() == 0 ? View.VISIBLE : View.GONE); + } } diff --git a/app/src/main/java/org/communiquons/android/comunic/client/ui/fragments/UserPageFragment.java b/app/src/main/java/org/communiquons/android/comunic/client/ui/fragments/UserPageFragment.java index 328c27b..584f2da 100644 --- a/app/src/main/java/org/communiquons/android/comunic/client/ui/fragments/UserPageFragment.java +++ b/app/src/main/java/org/communiquons/android/comunic/client/ui/fragments/UserPageFragment.java @@ -15,17 +15,17 @@ import android.widget.TextView; import android.widget.Toast; import org.communiquons.android.comunic.client.R; -import org.communiquons.android.comunic.client.data.helpers.DatabaseHelper; -import org.communiquons.android.comunic.client.data.helpers.ImageLoadHelper; -import org.communiquons.android.comunic.client.data.models.AdvancedUserInfo; -import org.communiquons.android.comunic.client.data.helpers.GetUsersHelper; -import org.communiquons.android.comunic.client.data.models.UserInfo; -import org.communiquons.android.comunic.client.data.models.Post; -import org.communiquons.android.comunic.client.data.helpers.PostsHelper; import org.communiquons.android.comunic.client.data.arrays.PostsList; +import org.communiquons.android.comunic.client.data.helpers.DatabaseHelper; +import org.communiquons.android.comunic.client.data.helpers.GetUsersHelper; +import org.communiquons.android.comunic.client.data.helpers.ImageLoadHelper; +import org.communiquons.android.comunic.client.data.helpers.PostsHelper; +import org.communiquons.android.comunic.client.data.models.AdvancedUserInfo; +import org.communiquons.android.comunic.client.data.models.Post; +import org.communiquons.android.comunic.client.data.models.UserInfo; +import org.communiquons.android.comunic.client.ui.activities.MainActivity; import org.communiquons.android.comunic.client.ui.listeners.onOpenUsersPageListener; import org.communiquons.android.comunic.client.ui.utils.UiUtils; -import org.communiquons.android.comunic.client.ui.activities.MainActivity; /** * User page fragment diff --git a/app/src/main/res/layout/fragment_conversationslist.xml b/app/src/main/res/layout/fragment_conversationslist.xml index e14df51..6ef12dd 100644 --- a/app/src/main/res/layout/fragment_conversationslist.xml +++ b/app/src/main/res/layout/fragment_conversationslist.xml @@ -11,6 +11,16 @@ android:layout_height="wrap_content" android:layout_gravity="center"/> + + + + An error occurred while trying to get post information! You do not have any notification yet. There is not any post on this page yet. + You do not have any conversation yet.