activity: Remove useless indirection
Signed-off-by: Samuel Holland <samuel@sholland.org>
This commit is contained in:
parent
63efaa2dcc
commit
dbed7155d6
@ -53,7 +53,7 @@ public abstract class BaseActivity extends Activity {
|
|||||||
super.onSaveInstanceState(outState);
|
super.onSaveInstanceState(outState);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract Tunnel onSelectedTunnelChanged(Tunnel oldTunnel, Tunnel newTunnel);
|
protected abstract void onSelectedTunnelChanged(Tunnel oldTunnel, Tunnel newTunnel);
|
||||||
|
|
||||||
public void removeOnSelectedTunnelChangedListener(
|
public void removeOnSelectedTunnelChangedListener(
|
||||||
final OnSelectedTunnelChangedListener listener) {
|
final OnSelectedTunnelChangedListener listener) {
|
||||||
@ -64,11 +64,9 @@ public abstract class BaseActivity extends Activity {
|
|||||||
final Tunnel oldTunnel = selectedTunnel;
|
final Tunnel oldTunnel = selectedTunnel;
|
||||||
if (Objects.equals(oldTunnel, tunnel))
|
if (Objects.equals(oldTunnel, tunnel))
|
||||||
return;
|
return;
|
||||||
// Give the activity a chance to override the tunnel change.
|
selectedTunnel = tunnel;
|
||||||
selectedTunnel = onSelectedTunnelChanged(oldTunnel, tunnel);
|
onSelectedTunnelChanged(oldTunnel, tunnel);
|
||||||
if (Objects.equals(oldTunnel, selectedTunnel))
|
selectionChangeRegistry.notifyCallbacks(oldTunnel, 0, tunnel);
|
||||||
return;
|
|
||||||
selectionChangeRegistry.notifyCallbacks(oldTunnel, 0, selectedTunnel);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface OnSelectedTunnelChangedListener {
|
public interface OnSelectedTunnelChangedListener {
|
||||||
|
@ -120,9 +120,8 @@ public class MainActivity extends BaseActivity {
|
|||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Tunnel onSelectedTunnelChanged(final Tunnel oldTunnel, final Tunnel newTunnel) {
|
protected void onSelectedTunnelChanged(final Tunnel oldTunnel, final Tunnel newTunnel) {
|
||||||
moveToState(newTunnel != null ? State.DETAIL : State.LIST);
|
moveToState(newTunnel != null ? State.DETAIL : State.LIST);
|
||||||
return newTunnel;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private enum State {
|
private enum State {
|
||||||
|
@ -21,8 +21,7 @@ public class TunnelCreatorActivity extends BaseActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Tunnel onSelectedTunnelChanged(final Tunnel oldTunnel, final Tunnel newTunnel) {
|
protected void onSelectedTunnelChanged(final Tunnel oldTunnel, final Tunnel newTunnel) {
|
||||||
finish();
|
finish();
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user