@Override protected void initialize(Bundle savedInstanceState) { super.initialize(savedInstanceState); mOverlay = (ViewGroup) findViewById(R.id.overlay); mTray = findViewById(R.id.tray); mFab = (FloatingActionButton) findViewById(R.id.fab); mFab.getViewTreeObserver() .addOnGlobalLayoutListener( new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { if (android.os.Build.VERSION.SDK_INT >= 16) { mFab.getViewTreeObserver().removeOnGlobalLayoutListener(this); } else { mFab.getViewTreeObserver().removeGlobalOnLayoutListener(this); } initializeLayout(); } }); mFab.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { showTray(); hideFab(); } }); setupTray(savedInstanceState); if (findViewById(R.id.pad_pager) == null) { showFab(); } }
@Override protected void onSaveInstanceState(@NonNull Bundle outState) { super.onSaveInstanceState(outState); final View advancedPad = findViewById(R.id.pad_advanced); final View hexPad = findViewById(R.id.pad_hex); final View matrixPad = findViewById(R.id.pad_matrix); Panel panel = null; if (advancedPad.getVisibility() == View.VISIBLE) { panel = Panel.Advanced; } else if (hexPad.getVisibility() == View.VISIBLE) { panel = Panel.Hex; } else if (matrixPad.getVisibility() == View.VISIBLE) { panel = Panel.Matrix; } outState.putSerializable(KEY_PANEL, panel); }