mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-18 13:49:53 +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
|
// to not lose state on configuration changes
|
||||||
if (fm.findFragmentByTag(tag) == null) {
|
if (fm.findFragmentByTag(tag) == null) {
|
||||||
if (started.wasNotYetConsumed()) {
|
if (started.wasNotYetConsumed()) {
|
||||||
|
started.consume();
|
||||||
showFragment(fm, new HotspotFragment(), tag);
|
showFragment(fm, new HotspotFragment(), tag);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,16 +57,19 @@ abstract class HotspotState {
|
|||||||
return websiteConfig;
|
return websiteConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@UiThread
|
||||||
|
boolean wasNotYetConsumed() {
|
||||||
|
return !consumed;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mark this state as consumed, i.e. the UI has already done something
|
* 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
|
* 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.
|
* to not repeat actions such as showing fragments on rotation changes.
|
||||||
*/
|
*/
|
||||||
@UiThread
|
@UiThread
|
||||||
boolean wasNotYetConsumed() {
|
void consume() {
|
||||||
boolean old = consumed;
|
|
||||||
consumed = true;
|
consumed = true;
|
||||||
return !old;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user