mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-22 20:24:03 -04:00
Android Another network error fix #261
This commit is contained in:
parent
334a9871c8
commit
d341536387
@ -111,4 +111,5 @@
|
|||||||
<string name="zim_simple">Simple</string>
|
<string name="zim_simple">Simple</string>
|
||||||
<string name="zim_nopic">No Pictures</string>
|
<string name="zim_nopic">No Pictures</string>
|
||||||
<string name="open_partial_zim">This file could be incomplete. Do you wish to attempt to open it?</string>
|
<string name="open_partial_zim">This file could be incomplete. Do you wish to attempt to open it?</string>
|
||||||
|
<string name="no_network_connection">No network connection</string>
|
||||||
</resources>
|
</resources>
|
@ -64,8 +64,9 @@ import static org.kiwix.kiwixmobile.utils.ShortcutUtils.stringsGetter;
|
|||||||
public class LibraryFragment extends Fragment implements AdapterView.OnItemClickListener {
|
public class LibraryFragment extends Fragment implements AdapterView.OnItemClickListener {
|
||||||
|
|
||||||
@BindView(R.id.library_list) ListView libraryList;
|
@BindView(R.id.library_list) ListView libraryList;
|
||||||
@BindView(R.id.progressbar_layout) RelativeLayout progressBar;
|
@BindView(R.id.progressBar) ProgressBar progressBar;
|
||||||
@BindView(R.id.progressbar_message) TextView progressBarMessage;
|
@BindView(R.id.progressbar_message) TextView progressBarMessage;
|
||||||
|
@BindView(R.id.progressbar_layout) RelativeLayout progressBarLayout;
|
||||||
|
|
||||||
|
|
||||||
private KiwixService kiwixService;
|
private KiwixService kiwixService;
|
||||||
@ -100,6 +101,11 @@ public class LibraryFragment extends Fragment implements AdapterView.OnItemClick
|
|||||||
// Don't use this method, it's handled by inflater.inflate() above :
|
// Don't use this method, it's handled by inflater.inflate() above :
|
||||||
// setContentView(R.layout.activity_layout);
|
// setContentView(R.layout.activity_layout);
|
||||||
ButterKnife.bind(this, llLayout);
|
ButterKnife.bind(this, llLayout);
|
||||||
|
|
||||||
|
progressBar.setVisibility(View.VISIBLE);
|
||||||
|
progressBarMessage.setVisibility(View.VISIBLE);
|
||||||
|
progressBarLayout.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
kiwixService = ((KiwixApplication) super.getActivity().getApplication()).getKiwixService();
|
kiwixService = ((KiwixApplication) super.getActivity().getApplication()).getKiwixService();
|
||||||
conMan = (ConnectivityManager) super.getActivity().getSystemService(Context.CONNECTIVITY_SERVICE);
|
conMan = (ConnectivityManager) super.getActivity().getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||||
NetworkInfo network = conMan.getActiveNetworkInfo();
|
NetworkInfo network = conMan.getActiveNetworkInfo();
|
||||||
@ -125,8 +131,10 @@ public class LibraryFragment extends Fragment implements AdapterView.OnItemClick
|
|||||||
books = booksCopy;
|
books = booksCopy;
|
||||||
libraryAdapter = new LibraryAdapter(super.getActivity(), books);
|
libraryAdapter = new LibraryAdapter(super.getActivity(), books);
|
||||||
libraryList.setAdapter(libraryAdapter);
|
libraryList.setAdapter(libraryAdapter);
|
||||||
progressBar.setVisibility(View.GONE);
|
progressBarLayout.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
},error -> {
|
||||||
|
noNetworkConnection();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@ -134,8 +142,7 @@ public class LibraryFragment extends Fragment implements AdapterView.OnItemClick
|
|||||||
|
|
||||||
active = true;
|
active = true;
|
||||||
} else {
|
} else {
|
||||||
progressBar.setVisibility(View.INVISIBLE);
|
noNetworkConnection();
|
||||||
progressBarMessage.setText("No network connection");
|
|
||||||
}
|
}
|
||||||
// The FragmentActivity doesn't contain the layout directly so we must use our instance of LinearLayout :
|
// The FragmentActivity doesn't contain the layout directly so we must use our instance of LinearLayout :
|
||||||
//llLayout.findViewById(R.id.someGuiElement);
|
//llLayout.findViewById(R.id.someGuiElement);
|
||||||
@ -144,11 +151,11 @@ public class LibraryFragment extends Fragment implements AdapterView.OnItemClick
|
|||||||
return llLayout; // We must return the loaded Layout
|
return llLayout; // We must return the loaded Layout
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public void noNetworkConnection() {
|
||||||
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
|
progressBar.setVisibility(View.INVISIBLE);
|
||||||
super.onViewCreated(view, savedInstanceState);
|
progressBarLayout.setVisibility(View.VISIBLE);
|
||||||
progressBar.setVisibility(View.VISIBLE);
|
progressBarMessage.setVisibility(View.VISIBLE);
|
||||||
|
progressBarMessage.setText("No network connection");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
x
Reference in New Issue
Block a user