Simplify ShowHabitActivity

This commit is contained in:
2017-06-05 18:01:13 -04:00
parent 217516ad59
commit 8d181a6683
17 changed files with 138 additions and 149 deletions

View File

@@ -118,4 +118,11 @@ abstract public class BaseActivity extends AppCompatActivity
{
return new BaseExceptionHandler(this);
}
@Override
protected void onResume()
{
super.onResume();
if(screen != null) screen.reattachDialogs();
}
}

View File

@@ -46,6 +46,9 @@ public abstract class BaseRootView extends FrameLayout
protected boolean shouldDisplayHomeAsUp = false;
@Nullable
private BaseScreen screen;
public BaseRootView(@NonNull Context context)
{
super(context);
@@ -91,4 +94,15 @@ public abstract class BaseRootView extends FrameLayout
if (view != null) view.setVisibility(GONE);
}
}
public void onAttachedToScreen(BaseScreen screen)
{
this.screen = screen;
}
@Nullable
public BaseScreen getScreen()
{
return screen;
}
}

View File

@@ -157,6 +157,15 @@ public class BaseScreen
{
}
/**
* Called after activity has been recreated, and the dialogs should be
* reattached to their controllers.
*/
public void reattachDialogs()
{
}
/**
* Sets the menu to be shown by this screen.
* <p>
@@ -180,7 +189,7 @@ public class BaseScreen
this.rootView = rootView;
activity.setContentView(rootView);
if (rootView == null) return;
rootView.onAttachedToScreen(this);
invalidateToolbar();
}