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);
|
||||
}
|
||||
|
||||
protected abstract Tunnel onSelectedTunnelChanged(Tunnel oldTunnel, Tunnel newTunnel);
|
||||
protected abstract void onSelectedTunnelChanged(Tunnel oldTunnel, Tunnel newTunnel);
|
||||
|
||||
public void removeOnSelectedTunnelChangedListener(
|
||||
final OnSelectedTunnelChangedListener listener) {
|
||||
@ -64,11 +64,9 @@ public abstract class BaseActivity extends Activity {
|
||||
final Tunnel oldTunnel = selectedTunnel;
|
||||
if (Objects.equals(oldTunnel, tunnel))
|
||||
return;
|
||||
// Give the activity a chance to override the tunnel change.
|
||||
selectedTunnel = onSelectedTunnelChanged(oldTunnel, tunnel);
|
||||
if (Objects.equals(oldTunnel, selectedTunnel))
|
||||
return;
|
||||
selectionChangeRegistry.notifyCallbacks(oldTunnel, 0, selectedTunnel);
|
||||
selectedTunnel = tunnel;
|
||||
onSelectedTunnelChanged(oldTunnel, tunnel);
|
||||
selectionChangeRegistry.notifyCallbacks(oldTunnel, 0, tunnel);
|
||||
}
|
||||
|
||||
public interface OnSelectedTunnelChangedListener {
|
||||
|
@ -120,9 +120,8 @@ public class MainActivity extends BaseActivity {
|
||||
|
||||
|
||||
@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);
|
||||
return newTunnel;
|
||||
}
|
||||
|
||||
private enum State {
|
||||
|
@ -21,8 +21,7 @@ public class TunnelCreatorActivity extends BaseActivity {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Tunnel onSelectedTunnelChanged(final Tunnel oldTunnel, final Tunnel newTunnel) {
|
||||
protected void onSelectedTunnelChanged(final Tunnel oldTunnel, final Tunnel newTunnel) {
|
||||
finish();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user