activity: Remove useless indirection

Signed-off-by: Samuel Holland <samuel@sholland.org>
This commit is contained in:
Samuel Holland 2018-01-06 04:15:36 -06:00
parent 63efaa2dcc
commit dbed7155d6
3 changed files with 6 additions and 10 deletions

View File

@ -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 {

View File

@ -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 {

View File

@ -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;
}
}