mirror of https://github.com/M66B/FairEmail.git
Check connectivity on browse
This commit is contained in:
parent
794e05df64
commit
39b4715915
|
@ -1948,6 +1948,9 @@ public class FragmentMessages extends FragmentBase {
|
|||
@Override
|
||||
public void onError(Throwable ex) {
|
||||
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.RESUMED))
|
||||
if (ex instanceof IllegalArgumentException)
|
||||
Snackbar.make(view, ex.getMessage(), Snackbar.LENGTH_LONG).show();
|
||||
else
|
||||
new DialogBuilderLifecycle(getContext(), getViewLifecycleOwner())
|
||||
.setMessage(Helper.formatThrowable(ex))
|
||||
.setPositiveButton(android.R.string.cancel, null)
|
||||
|
|
|
@ -20,6 +20,8 @@ package eu.faircode.email;
|
|||
*/
|
||||
|
||||
import android.content.Context;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
|
||||
import com.sun.mail.iap.Argument;
|
||||
import com.sun.mail.iap.Response;
|
||||
|
@ -154,6 +156,13 @@ public class ViewModelBrowse extends ViewModel {
|
|||
EntityAccount account = db.account().getAccount(folder.account);
|
||||
|
||||
try {
|
||||
// Check connectivity
|
||||
ConnectivityManager cm = (ConnectivityManager) state.context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
NetworkInfo ni = cm.getActiveNetworkInfo();
|
||||
boolean internet = (ni != null && ni.isConnected());
|
||||
if (!internet)
|
||||
throw new IllegalArgumentException(state.context.getString(R.string.title_no_internet));
|
||||
|
||||
Properties props = MessageHelper.getSessionProperties(account.auth_type, account.realm, account.insecure);
|
||||
Session isession = Session.getInstance(props, null);
|
||||
isession.setDebug(true);
|
||||
|
|
Loading…
Reference in New Issue