Replace runOnUiThread by main handler

This commit is contained in:
M66B 2020-09-17 16:52:19 +02:00
parent 33581e907f
commit 6752793a6d
3 changed files with 16 additions and 25 deletions

View File

@ -1298,15 +1298,13 @@ public class FragmentCompose extends FragmentBase {
}
private void check() {
Activity activity = getActivity();
if (activity != null)
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED))
checkInternet();
}
});
getMainHandler().post(new Runnable() {
@Override
public void run() {
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED))
checkInternet();
}
});
}
};

View File

@ -3658,16 +3658,14 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
}
private void check() {
Activity activity = getActivity();
if (activity != null)
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED))
if (!rvMessage.isComputingLayout())
adapter.checkInternet();
}
});
getMainHandler().post(new Runnable() {
@Override
public void run() {
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED))
if (!rvMessage.isComputingLayout())
adapter.checkInternet();
}
});
}
};

View File

@ -49,7 +49,6 @@ import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.widget.SwitchCompat;
import androidx.fragment.app.FragmentActivity;
import androidx.lifecycle.Lifecycle;
import androidx.preference.PreferenceManager;
@ -295,11 +294,7 @@ public class FragmentOptionsConnection extends FragmentBase implements SharedPre
};
private void showConnectionType() {
FragmentActivity activity = getActivity();
if (activity == null)
return;
activity.runOnUiThread(new Runnable() {
getMainHandler().post(new Runnable() {
@Override
public void run() {
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) {