// Display overlay dialog with a view to prevent home button click public void lock(Activity activity) { if (mOverlayDialog == null) { mOverlayDialog = new OverlayDialog(activity); mOverlayDialog.show(); mLockStatusChangedListener = (OnLockStatusChangedListener) activity; } }
// Unlock the home button and give callback to unlock the screen public void unlock() { if (mOverlayDialog != null) { mOverlayDialog.dismiss(); mOverlayDialog = null; if (mLockStatusChangedListener != null) { mLockStatusChangedListener.onLockStatusChanged(false); } } }
/** * Show a centered fullscreen dialog with given title and information text. Doesn't do anything if * already shown. Hide before show a new one. * * @param title Dialog title text * @param info Dialog info text */ private void showCenteredFullScreenDialog(String title, String info) { if (centeredFullScreenDialog != null) { return; } FragmentManager fragmentManager = getFragmentManager(); centeredFullScreenDialog = OverlayDialog.newInstance(title, info); fragmentManager .beginTransaction() .add(R.id.fullDialogFrameLayout, centeredFullScreenDialog) .commit(); }
@Override public void onClick(Fragment f) { if (f == null) { return; } if (f == centeredFullScreenDialog) { String title = centeredFullScreenDialog.getTitle(); if (title.equals(getString(R.string.paused_game_title))) { startGame(); } hideCenteredFullScreenDialog(); } }
public void unlock() { if (mOverlayDialog != null) { mOverlayDialog.dismiss(); mOverlayDialog = null; } }
public void lock(Activity activity) { if (mOverlayDialog == null) { mOverlayDialog = new OverlayDialog(activity); mOverlayDialog.show(); } }
// Reset variables public void reset() { if (mOverlayDialog != null) { mOverlayDialog.dismiss(); mOverlayDialog = null; } }