mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-12 10:49:06 +01:00
Improve handling of HotspotState's field 'consumed'
This commit is contained in:
@@ -60,6 +60,7 @@ public class HotspotActivity extends BriarActivity
|
||||
// to not lose state on configuration changes
|
||||
if (fm.findFragmentByTag(tag) == null) {
|
||||
if (started.wasNotYetConsumed()) {
|
||||
started.consume();
|
||||
showFragment(fm, new HotspotFragment(), tag);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,16 +57,19 @@ abstract class HotspotState {
|
||||
return websiteConfig;
|
||||
}
|
||||
|
||||
@UiThread
|
||||
boolean wasNotYetConsumed() {
|
||||
return !consumed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Mark this state as consumed, i.e. the UI has already done something
|
||||
* as a result of the state changing to this. This can be used in order
|
||||
* to not repeat actions such as showing fragments on rotation changes.
|
||||
*/
|
||||
@UiThread
|
||||
boolean wasNotYetConsumed() {
|
||||
boolean old = consumed;
|
||||
void consume() {
|
||||
consumed = true;
|
||||
return !old;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user