Display a notice when the user does not have any notification.

This commit is contained in:
Pierre 2018-04-14 16:50:20 +02:00
parent f9156f8e6a
commit f7fef9905b
3 changed files with 33 additions and 0 deletions

View File

@ -16,6 +16,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.R;
@ -74,6 +75,11 @@ public class NotificationsFragment extends Fragment implements View.OnCreateCont
*/
private ProgressBar mLoadingProgress;
/**
* No notification notice
*/
private TextView mNoNotifNotice;
/**
* User page opener
*/
@ -108,6 +114,10 @@ public class NotificationsFragment extends Fragment implements View.OnCreateCont
//Get loading progress view
mLoadingProgress = view.findViewById(R.id.loading_progress);
//Get the "no notification" notice
mNoNotifNotice = view.findViewById(R.id.no_notification_notification_notice);
mNoNotifNotice.setVisibility(View.GONE);
//Delete all the notifications action
mDeleteNotificationsBtn = view.findViewById(R.id.delete_all_notif_btn);
mDeleteNotificationsBtn.setOnClickListener(new View.OnClickListener() {
@ -272,6 +282,9 @@ public class NotificationsFragment extends Fragment implements View.OnCreateCont
//Set context menu creator
mNotificationsListView.setOnCreateContextMenuListener(this);
mNotificationsListView.setOnItemClickListener(this);
//Check if there is not any notification to display the "no notification" notice
updateNoNotifNotif();
}
@Override
@ -316,6 +329,9 @@ public class NotificationsFragment extends Fragment implements View.OnCreateCont
mNotificationsList.remove(pos);
mNotificationsAdapter.notifyDataSetChanged();
//Check if the "no notification" notice has to be shown
updateNoNotifNotif();
//Delete the notification from the server
new AsyncTask<Integer, Void, Boolean>(){
@ -362,4 +378,11 @@ public class NotificationsFragment extends Fragment implements View.OnCreateCont
}
}
/**
* Update the visibility status of the no notification status
*/
private void updateNoNotifNotif(){
mNoNotifNotice.setVisibility(mNotificationsList.size() == 0 ? View.VISIBLE : View.GONE);
}
}

View File

@ -11,6 +11,15 @@
android:layout_gravity="center"
android:layout_marginTop="10dp"/>
<!-- No notification notice -->
<TextView
android:id="@+id/no_notification_notification_notice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/notice_no_notification"
android:layout_gravity="center"
android:layout_marginTop="10dp"/>
<!-- Notifications list -->
<ListView
android:id="@+id/notificcation_list"

View File

@ -173,4 +173,5 @@
<string name="button_reject_friend_request">Reject request</string>
<string name="err_get_friendship_status">An error occurred while retrieving friendship status!</string>
<string name="err_get_post_info">An error occurred while trying to get post information!</string>
<string name="notice_no_notification">You do not have any notification yet.</string>
</resources>