mirror of
https://github.com/M66B/FairEmail.git
synced 2025-01-01 04:35:57 +00:00
Refactoring small improvement
This commit is contained in:
parent
28fe881b46
commit
e08f276996
3 changed files with 9 additions and 7 deletions
|
@ -2568,7 +2568,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
this.name_email = prefs.getBoolean("name_email", !compact);
|
||||
this.zoom = zoom;
|
||||
this.sort = sort;
|
||||
this.internet = (Helper.isMetered(context, false) != null);
|
||||
this.internet = Helper.isConnected(context);
|
||||
this.properties = properties;
|
||||
|
||||
|
||||
|
@ -2648,7 +2648,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
}
|
||||
|
||||
void checkInternet() {
|
||||
boolean internet = (Helper.isMetered(context, false) != null);
|
||||
boolean internet = Helper.isConnected(context);
|
||||
if (this.internet != internet) {
|
||||
this.internet = internet;
|
||||
notifyDataSetChanged();
|
||||
|
|
|
@ -695,7 +695,7 @@ public class FragmentCompose extends FragmentBase {
|
|||
};
|
||||
|
||||
private void checkInternet() {
|
||||
boolean internet = (Helper.isMetered(getContext(), false) != null);
|
||||
boolean internet = Helper.isConnected(getContext());
|
||||
|
||||
Boolean content = (Boolean) tvNoInternet.getTag();
|
||||
tvNoInternet.setVisibility(!internet && content != null && !content ? View.VISIBLE : View.GONE);
|
||||
|
|
|
@ -696,16 +696,18 @@ public class Helper {
|
|||
}
|
||||
|
||||
static boolean isConnected(Context context) {
|
||||
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
NetworkInfo ni = cm.getActiveNetworkInfo();
|
||||
return (ni != null && ni.isConnected());
|
||||
return (isMetered(context, false) != null);
|
||||
}
|
||||
|
||||
static Boolean isMetered(Context context, boolean log) {
|
||||
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
|
||||
if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.M)
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
|
||||
NetworkInfo ani = cm.getActiveNetworkInfo();
|
||||
if (ani == null || !ani.isConnected())
|
||||
return null;
|
||||
return cm.isActiveNetworkMetered();
|
||||
}
|
||||
|
||||
Network active = cm.getActiveNetwork();
|
||||
if (active == null) {
|
||||
|
|
Loading…
Reference in a new issue