66import android .content .Intent ;
77import android .net .Uri ;
88import android .os .Bundle ;
9+ import android .support .design .widget .Snackbar ;
910import android .support .v7 .widget .DividerItemDecoration ;
1011import android .support .v7 .widget .LinearLayoutManager ;
1112import android .support .v7 .widget .RecyclerView ;
1516
1617import com .pedrogomez .renderers .RVRendererAdapter ;
1718
19+ import java .lang .ref .WeakReference ;
1820import java .util .Collections ;
1921import java .util .List ;
2022
2527import fr .free .nrw .commons .R ;
2628import fr .free .nrw .commons .Utils ;
2729import fr .free .nrw .commons .theme .NavigationBaseActivity ;
30+ import fr .free .nrw .commons .utils .NetworkUtils ;
2831import fr .free .nrw .commons .utils .ViewUtil ;
2932import io .reactivex .Observable ;
3033import io .reactivex .android .schedulers .AndroidSchedulers ;
@@ -62,9 +65,23 @@ private void initListView() {
6265 recyclerView .setLayoutManager (new LinearLayoutManager (this ));
6366 DividerItemDecoration itemDecor = new DividerItemDecoration (recyclerView .getContext (), DividerItemDecoration .VERTICAL );
6467 recyclerView .addItemDecoration (itemDecor );
65- addNotifications ();
68+ refresh ();
6669 }
6770
71+ private void refresh () {
72+ if (!NetworkUtils .isInternetConnectionEstablished (this )) {
73+ progressBar .setVisibility (View .GONE );
74+ Snackbar .make (relativeLayout , R .string .no_internet , Snackbar .LENGTH_INDEFINITE )
75+ .setAction (R .string .retry , view -> {
76+ refresh ();
77+ }).show ();
78+ }else {
79+ progressBar .setVisibility (View .VISIBLE );
80+ addNotifications ();
81+ }
82+ }
83+
84+
6885 @ SuppressLint ("CheckResult" )
6986 private void addNotifications () {
7087 Timber .d ("Add notifications" );
@@ -124,4 +141,4 @@ private void initializeAndSetNotificationList(List<Notification> notificationLis
124141 .commit ();
125142 mNotificationWorkerFragment .setNotificationList (notificationList );
126143 }
127- }
144+ }
0 commit comments