M66B 5 years ago
parent 9d234aa9a4
commit 0191240a27

@ -153,7 +153,7 @@ abstract class ActivityBilling extends ActivityBase implements PurchasesUpdatedL
private BroadcastReceiver receiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.RESUMED)) {
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) {
if (ACTION_PURCHASE.equals(intent.getAction()))
onPurchase(intent);
else if (ACTION_PURCHASE_CHECK.equals(intent.getAction()))

@ -207,7 +207,7 @@ public class ActivityCompose extends ActivityBilling implements FragmentManager.
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.RESUMED))
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED))
onBackPressed();
return true;
default:
@ -234,7 +234,7 @@ public class ActivityCompose extends ActivityBilling implements FragmentManager.
private BroadcastReceiver receiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.RESUMED)) {
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) {
if (ACTION_SHOW_PRO.equals(intent.getAction()))
onShowPro(intent);
}
@ -242,7 +242,7 @@ public class ActivityCompose extends ActivityBilling implements FragmentManager.
};
private void onShowPro(Intent intent) {
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.RESUMED))
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED))
getSupportFragmentManager().popBackStack("pro", FragmentManager.POP_BACK_STACK_INCLUSIVE);
FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();

@ -349,7 +349,7 @@ public class ActivitySetup extends ActivityBase implements FragmentManager.OnBac
switch (item.getItemId()) {
case android.R.id.home:
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.RESUMED))
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED))
getSupportFragmentManager().popBackStack();
return true;
}
@ -407,7 +407,7 @@ public class ActivitySetup extends ActivityBase implements FragmentManager.OnBac
}
private void onMenuOrder(int title, Class clazz) {
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.RESUMED))
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED))
getSupportFragmentManager().popBackStack("order", FragmentManager.POP_BACK_STACK_INCLUSIVE);
Bundle args = new Bundle();
@ -450,7 +450,7 @@ public class ActivitySetup extends ActivityBase implements FragmentManager.OnBac
}
private void onMenuContacts() {
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.RESUMED))
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED))
getSupportFragmentManager().popBackStack("contacts", FragmentManager.POP_BACK_STACK_INCLUSIVE);
FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
@ -459,7 +459,7 @@ public class ActivitySetup extends ActivityBase implements FragmentManager.OnBac
}
private void onMenuLegend() {
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.RESUMED))
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED))
getSupportFragmentManager().popBackStack("legend", FragmentManager.POP_BACK_STACK_INCLUSIVE);
FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
@ -480,7 +480,7 @@ public class ActivitySetup extends ActivityBase implements FragmentManager.OnBac
}
private void onMenuAbout() {
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.RESUMED))
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED))
getSupportFragmentManager().popBackStack("about", FragmentManager.POP_BACK_STACK_INCLUSIVE);
FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
@ -1091,7 +1091,7 @@ public class ActivitySetup extends ActivityBase implements FragmentManager.OnBac
private BroadcastReceiver receiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.RESUMED)) {
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) {
String action = intent.getAction();
if (ACTION_QUICK_SETUP.equals(action))
onViewQuickSetup(intent);

@ -479,11 +479,11 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
setIntent(intent);
if ("unified".equals(action)) {
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.RESUMED))
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED))
getSupportFragmentManager().popBackStack("unified", 0);
} else if ("why".equals(action)) {
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.RESUMED))
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED))
getSupportFragmentManager().popBackStack("unified", 0);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ActivityView.this);
@ -627,7 +627,7 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
switch (item.getItemId()) {
case android.R.id.home:
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.RESUMED))
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED))
getSupportFragmentManager().popBackStack();
return true;
default:
@ -813,7 +813,7 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
}
private void onMenuFolders(long account) {
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.RESUMED))
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED))
getSupportFragmentManager().popBackStack("unified", 0);
Bundle args = new Bundle();
@ -840,7 +840,7 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
@Override
protected void onExecuted(Bundle args, Long folder) {
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.RESUMED))
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED))
getSupportFragmentManager().popBackStack("unified", 0);
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(ActivityView.this);
@ -858,7 +858,7 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
}
private void onMenuOperations() {
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.RESUMED))
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED))
getSupportFragmentManager().popBackStack("operations", FragmentManager.POP_BACK_STACK_INCLUSIVE);
FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
@ -867,7 +867,7 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
}
private void onMenuAnswers() {
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.RESUMED))
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED))
getSupportFragmentManager().popBackStack("answers", FragmentManager.POP_BACK_STACK_INCLUSIVE);
FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
@ -880,7 +880,7 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
}
private void onMenuLegend() {
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.RESUMED))
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED))
getSupportFragmentManager().popBackStack("legend", FragmentManager.POP_BACK_STACK_INCLUSIVE);
FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
@ -905,7 +905,7 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
}
private void onMenuAbout() {
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.RESUMED))
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED))
getSupportFragmentManager().popBackStack("about", FragmentManager.POP_BACK_STACK_INCLUSIVE);
FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
@ -959,7 +959,7 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
}
private void onShowLog() {
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.RESUMED))
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED))
getSupportFragmentManager().popBackStack("logs", FragmentManager.POP_BACK_STACK_INCLUSIVE);
FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
@ -970,7 +970,7 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
private BroadcastReceiver receiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.RESUMED)) {
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) {
String action = intent.getAction();
if (ACTION_VIEW_FOLDERS.equals(action))
@ -1003,7 +1003,7 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
}
private void onViewMessages(Intent intent) {
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.RESUMED))
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED))
getSupportFragmentManager().popBackStack("messages", FragmentManager.POP_BACK_STACK_INCLUSIVE);
Bundle args = new Bundle();
@ -1030,7 +1030,7 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
private void onViewThread(Intent intent) {
boolean found = intent.getBooleanExtra("found", false);
if (!found && getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.RESUMED))
if (!found && getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED))
getSupportFragmentManager().popBackStack("thread", FragmentManager.POP_BACK_STACK_INCLUSIVE);
Bundle args = new Bundle();
@ -1095,7 +1095,7 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
}
private void onShowPro(Intent intent) {
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.RESUMED))
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED))
getSupportFragmentManager().popBackStack("pro", FragmentManager.POP_BACK_STACK_INCLUSIVE);
FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();

@ -1067,7 +1067,7 @@ public class FragmentAccount extends FragmentBase {
fragment.setArguments(aargs);
fragment.setTargetFragment(FragmentAccount.this, REQUEST_SAVE);
fragment.show(getFragmentManager(), "account:save");
} else if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.RESUMED))
} else if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED))
getFragmentManager().popBackStack();
}
@ -1316,7 +1316,7 @@ public class FragmentAccount extends FragmentBase {
}
});
onSave(false);
} else if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.RESUMED))
} else if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED))
getFragmentManager().popBackStack();
break;
case REQUEST_DELETE:
@ -1363,7 +1363,7 @@ public class FragmentAccount extends FragmentBase {
@Override
protected void onExecuted(Bundle args, Void data) {
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.RESUMED))
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED))
getFragmentManager().popBackStack();
}

@ -68,7 +68,7 @@ public class FragmentBase extends Fragment {
}
protected void finish() {
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.RESUMED))
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED))
getFragmentManager().popBackStack();
else
finish = true;

@ -749,7 +749,7 @@ public class FragmentCompose extends FragmentBase {
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.RESUMED))
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED))
checkInternet();
}
});
@ -806,7 +806,7 @@ public class FragmentCompose extends FragmentBase {
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.RESUMED))
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED))
onExit();
return true;
case R.id.menu_zoom:
@ -3307,7 +3307,7 @@ public class FragmentCompose extends FragmentBase {
private ActivityBase.IBackPressedListener onBackPressedListener = new ActivityBase.IBackPressedListener() {
@Override
public boolean onBackPressed() {
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.RESUMED))
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED))
onExit();
return true;
}

@ -255,7 +255,7 @@ public class FragmentFolder extends FragmentBase {
}
});
onSave(false);
} else if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.RESUMED))
} else if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED))
getFragmentManager().popBackStack();
break;
@ -478,7 +478,7 @@ public class FragmentFolder extends FragmentBase {
ask.setArguments(aargs);
ask.setTargetFragment(FragmentFolder.this, REQUEST_SAVE_CHANGES);
ask.show(getFragmentManager(), "folder:save");
} else if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.RESUMED))
} else if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED))
getFragmentManager().popBackStack();
}
@ -519,7 +519,7 @@ public class FragmentFolder extends FragmentBase {
@Override
protected void onExecuted(Bundle args, Void data) {
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.RESUMED))
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED))
getFragmentManager().popBackStack();
}

@ -785,7 +785,7 @@ public class FragmentIdentity extends FragmentBase {
fragment.setArguments(aargs);
fragment.setTargetFragment(FragmentIdentity.this, REQUEST_SAVE);
fragment.show(getFragmentManager(), "identity:save");
} else if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.RESUMED))
} else if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED))
getFragmentManager().popBackStack();
}
@ -1058,7 +1058,7 @@ public class FragmentIdentity extends FragmentBase {
}
});
onSave(false);
} else if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.RESUMED))
} else if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED))
getFragmentManager().popBackStack();
break;
case REQUEST_DELETE:
@ -1109,7 +1109,7 @@ public class FragmentIdentity extends FragmentBase {
@Override
protected void onExecuted(Bundle args, Void data) {
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.RESUMED))
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED))
getFragmentManager().popBackStack();
}

@ -2254,7 +2254,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.RESUMED))
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED))
adapter.checkInternet();
}
});
@ -2525,7 +2525,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
}
private void onMenuFolders(long account) {
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.RESUMED))
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED))
getFragmentManager().popBackStack("unified", 0);
Bundle args = new Bundle();
@ -2773,7 +2773,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
@Override
public void onException(@NonNull Throwable ex) {
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.RESUMED))
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED))
if (ex instanceof IllegalStateException) {
Snackbar snackbar = Snackbar.make(view, ex.getMessage(), Snackbar.LENGTH_LONG);
snackbar.setAction(R.string.title_fix, new View.OnClickListener() {
@ -3075,7 +3075,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
}
private void navigate(long id, final boolean left) {
if (!getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.RESUMED))
if (!getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED))
return;
Bundle args = new Bundle();
@ -3094,7 +3094,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
return;
}
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.RESUMED))
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED))
getFragmentManager().popBackStack("thread", FragmentManager.POP_BACK_STACK_INCLUSIVE);
getArguments().putBoolean("fade", true);
@ -3337,7 +3337,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
private BroadcastReceiver receiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.RESUMED)) {
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) {
String action = intent.getAction();
if (ACTION_STORE_RAW.equals(action))
@ -4376,7 +4376,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
return;
}
if (owner.getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.RESUMED))
if (owner.getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED))
manager.popBackStack("search", FragmentManager.POP_BACK_STACK_INCLUSIVE);
Bundle args = new Bundle();

@ -254,7 +254,7 @@ public class FragmentOptionsConnection extends FragmentBase implements SharedPre
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.RESUMED)) {
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) {
ConnectionHelper.NetworkState networkState = ConnectionHelper.getNetworkState(getContext());
tvConnectionType.setText(networkState.isUnmetered() ? R.string.title_legend_unmetered : R.string.title_legend_metered);

@ -122,17 +122,17 @@ public abstract class SimpleTask<T> implements LifecycleObserver {
if (state.equals(Lifecycle.State.DESTROYED)) {
// No delivery
cleanup(context);
} else if (state.isAtLeast(Lifecycle.State.RESUMED)) {
} else if (state.isAtLeast(Lifecycle.State.STARTED)) {
// Inline delivery
Log.i("Deliver task " + name);
deliver();
cleanup(context);
} else
owner.getLifecycle().addObserver(new LifecycleObserver() {
@OnLifecycleEvent(Lifecycle.Event.ON_RESUME)
public void onResume() {
@OnLifecycleEvent(Lifecycle.Event.ON_START)
public void onStart() {
// Deferred delivery
Log.i("Resume task " + name);
Log.i("Deferred delivery task " + name);
owner.getLifecycle().removeObserver(this);
deliver();
cleanup(context);
@ -141,7 +141,7 @@ public abstract class SimpleTask<T> implements LifecycleObserver {
@OnLifecycleEvent(Lifecycle.Event.ON_DESTROY)
public void onDestroyed() {
// No delivery
Log.i("Destroy task " + name);
Log.i("Destroyed task " + name);
owner.getLifecycle().removeObserver(this);
cleanup(context);
}

@ -26,6 +26,8 @@ import androidx.lifecycle.LifecycleOwner;
import androidx.lifecycle.LifecycleRegistry;
import androidx.lifecycle.OnLifecycleEvent;
// This class can be used as an externally controlled standalone or child life cycle owner
public class TwoStateOwner implements LifecycleOwner {
private String name;
private LifecycleRegistry registry;
@ -66,15 +68,13 @@ public class TwoStateOwner implements LifecycleOwner {
}
void start() {
registry.setCurrentState(Lifecycle.State.STARTED);
}
void resume() {
registry.setCurrentState(Lifecycle.State.RESUMED);
if (!registry.getCurrentState().equals(Lifecycle.State.DESTROYED))
registry.setCurrentState(Lifecycle.State.STARTED);
}
void stop() {
registry.setCurrentState(Lifecycle.State.CREATED);
if (!registry.getCurrentState().equals(Lifecycle.State.DESTROYED))
registry.setCurrentState(Lifecycle.State.CREATED);
}
void restart() {

Loading…
Cancel
Save