Example usage for android.os Bundle getBundle

List of usage examples for android.os Bundle getBundle

Introduction

In this page you can find the example usage for android.os Bundle getBundle.

Prototype

@Nullable
public Bundle getBundle(@Nullable String key) 

Source Link

Document

Returns the value associated with the given key, or null if no mapping of the desired type exists for the given key or a null value is explicitly associated with the key.

Usage

From source file:com.facebook.samples.booleanog.LogicActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    uiHelper = new UiLifecycleHelper(this, callback);
    uiHelper.onCreate(savedInstanceState);

    setContentView(R.layout.main);//from   w  w w.j  ava2 s . com

    // Views
    logicButton = (Button) findViewById(R.id.logic_button);
    friendsButton = (Button) findViewById(R.id.friends_button);
    settingsButton = (Button) findViewById(R.id.settings_button);
    contentButton = (Button) findViewById(R.id.content_button);

    logicGroup = (ViewGroup) findViewById(R.id.logic_group);
    leftSpinner = (Spinner) findViewById(R.id.left_spinner);
    rightSpinner = (Spinner) findViewById(R.id.right_spinner);
    andButton = (Button) findViewById(R.id.and_button);
    orButton = (Button) findViewById(R.id.or_button);
    resultText = (TextView) findViewById(R.id.result_text);
    postResultText = (TextView) findViewById(R.id.post_result_text);

    friendsGroup = (ViewGroup) findViewById(R.id.friends_group);
    ListView friendActivityList = (ListView) findViewById(R.id.friend_activity_list);
    String[] mapColumnNames = { "date", "action" };
    int[] mapViewIds = { R.id.friend_action_date, R.id.friend_action_data };
    friendActivityAdapter = new SimpleCursorAdapter(this, R.layout.friend_activity_row, createEmptyCursor(),
            mapColumnNames, mapViewIds);
    friendActivityList.setAdapter(friendActivityAdapter);
    friendActivityProgressBar = (ProgressBar) findViewById(R.id.friend_activity_progress_bar);

    settingsGroup = (ViewGroup) findViewById(R.id.settings_group);

    contentGroup = (ViewGroup) findViewById(R.id.content_group);
    contentImage = (ImageView) findViewById(R.id.content_image);
    contentSpinner = (Spinner) findViewById(R.id.content_spinner);

    // Fragments
    FragmentManager fragmentManager = getSupportFragmentManager();
    FragmentTransaction transaction = fragmentManager.beginTransaction();

    friendPickerFragment = (FriendPickerFragment) fragmentManager.findFragmentById(R.id.friend_picker_fragment);
    if (friendPickerFragment == null) {
        Bundle args = new Bundle();
        args.putBoolean(FriendPickerFragment.SHOW_TITLE_BAR_BUNDLE_KEY, false);
        friendPickerFragment = new FriendPickerFragment(args);
        transaction.add(R.id.friend_picker_fragment, friendPickerFragment);
    }

    userSettingsFragment = (UserSettingsFragment) fragmentManager.findFragmentById(R.id.login_fragment);
    if (userSettingsFragment == null) {
        userSettingsFragment = new UserSettingsFragment();
        transaction.add(R.id.login_fragment, userSettingsFragment);
    }

    transaction.commit();

    // Spinners
    ArrayAdapter<CharSequence> truthAdapter = ArrayAdapter.createFromResource(this, R.array.truth_values,
            android.R.layout.simple_spinner_item);
    truthAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    leftSpinner.setAdapter(truthAdapter);
    rightSpinner.setAdapter(truthAdapter);
    contentSpinner.setAdapter(truthAdapter);
    leftSpinner.setSelection(0);
    rightSpinner.setSelection(0);

    // Navigation
    for (Button button : Arrays.asList(logicButton, friendsButton, settingsButton, contentButton)) {
        initializeNavigationButton(button);
    }

    // Logic
    initializeCalculationButton(andButton);
    initializeCalculationButton(orButton);

    // Friends
    friendPickerFragment.setOnErrorListener(new PickerFragment.OnErrorListener() {
        @Override
        public void onError(PickerFragment<?> fragment, FacebookException error) {
            LogicActivity.this.onError(error);
        }
    });
    friendPickerFragment.setUserId("me");
    friendPickerFragment.setMultiSelect(false);
    friendPickerFragment.setOnSelectionChangedListener(new PickerFragment.OnSelectionChangedListener() {
        @Override
        public void onSelectionChanged(PickerFragment<?> fragment) {
            LogicActivity.this.onFriendSelectionChanged();
        }
    });
    friendPickerFragment.setExtraFields(Arrays.asList(INSTALLED));
    friendPickerFragment.setFilter(new PickerFragment.GraphObjectFilter<GraphUser>() {
        @Override
        public boolean includeItem(GraphUser graphObject) {
            Boolean installed = graphObject.cast(GraphUserWithInstalled.class).getInstalled();
            return (installed != null) && installed.booleanValue();
        }
    });

    // Content
    contentSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
            LogicActivity.this.onContentSelectionChanged();
        }

        @Override
        public void onNothingSelected(AdapterView<?> adapterView) {
            LogicActivity.this.onContentSelectionChanged();
        }
    });

    // Restore saved state
    Button startButton = logicButton;

    if (savedInstanceState != null) {
        leftSpinner.setSelection(savedInstanceState.getInt(SAVE_LEFT_OPERAND_SELECTION));
        rightSpinner.setSelection(savedInstanceState.getInt(SAVE_RIGHT_OPERAND_SELECTION));
        contentSpinner.setSelection(savedInstanceState.getInt(SAVE_CONTENT_SELECTION));
        resultText.setText(savedInstanceState.getString(SAVE_RESULT_TEXT));
        postResultText.setText(savedInstanceState.getString(SAVE_POST_RESULT_TEXT));
        activeTab = savedInstanceState.getString(SAVE_ACTIVE_TAB);
        pendingPost = savedInstanceState.getBundle(SAVE_PENDING);

        friendActionList = savedInstanceState.getParcelableArrayList(SAVE_FRIEND_ACTIONS);
        if ((friendActionList != null) && (friendActionList.size() > 0)) {
            updateCursor(friendActionList);
        }

        if (getString(R.string.navigate_friends).equals(activeTab)) {
            startButton = friendsButton;
        } else if (getString(R.string.navigate_content).equals(activeTab)) {
            startButton = contentButton;
        } else if (getString(R.string.navigate_settings).equals(activeTab)) {
            startButton = settingsButton;
        }
    }

    if (!handleNativeLink()) {
        onNavigateButtonClick(startButton);
    }
}

From source file:com.cognizant.trumobi.PersonaLauncher.java

@Override
protected void onRestoreInstanceState(Bundle savedInstanceState) {
    // NOTE: Do NOT do this. Ever. This is a terrible and horrifying hack.
    ////ww  w.j  ava 2 s  .c o  m
    // Home loads the content of the workspace on a background thread. This
    // means that
    // a previously focused view will be, after orientation change, added to
    // the view
    // hierarchy at an undeterminate time in the future. If we were to
    // invoke
    // super.onRestoreInstanceState() here, the focus restoration would fail
    // because the
    // view to focus does not exist yet.
    //
    // However, not invoking super.onRestoreInstanceState() is equally bad.
    // In such a case,
    // panels would not be restored properly. For instance, if the menu is
    // open then the
    // user changes the orientation, the menu would not be opened in the new
    // orientation.
    //
    // To solve both issues Home messes up with the internal state of the
    // bundle to remove
    // the properties it does not want to see restored at this moment. After
    // invoking
    // super.onRestoreInstanceState(), it removes the panels state.
    //
    // Later, when the workspace is done loading, Home calls
    // super.onRestoreInstanceState()
    // again to restore focus and other view properties. It will not,
    // however, restore
    // the panels since at this point the panels' state has been removed
    // from the bundle.
    //
    // This is a bad example, do not do this.
    //
    // If you are curious on how this code was put together, take a look at
    // the following
    // in Android's source code:
    // - Activity.onRestoreInstanceState()
    // - PhoneWindow.restoreHierarchyState()
    // - PhoneWindow.DecorView.onAttachedToWindow()
    //
    // The source code of these various methods shows what states should be
    // kept to
    // achieve what we want here.

    Bundle windowState = savedInstanceState.getBundle("android:viewHierarchyState");
    SparseArray<Parcelable> savedStates = null;
    int focusedViewId = View.NO_ID;

    if (windowState != null) {
        savedStates = windowState.getSparseParcelableArray("android:views");
        windowState.remove("android:views");
        focusedViewId = windowState.getInt("android:focusedViewId", View.NO_ID);
        windowState.remove("android:focusedViewId");
    }

    super.onRestoreInstanceState(savedInstanceState);

    if (windowState != null) {
        windowState.putSparseParcelableArray("android:views", savedStates);
        windowState.putInt("android:focusedViewId", focusedViewId);
        windowState.remove("android:Panels");
    }

    mSavedInstanceState = savedInstanceState;
}

From source file:com.tct.mail.compose.ComposeActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    //TS: zheng.zou 2015-12-03 EMAIL BUGFIX_1030520 ADD_S
    if (mHasNoPermission) {
        return;/* w  w  w .  ja va  2s. c o  m*/
    }
    //TS: zheng.zou 2015-12-03 EMAIL BUGFIX_1030520 ADD_E
    //AM: peng-zhang 2015-02-27 EMAIL BUGFIX_955421 MOD_S
    if (savedInstanceState != null) {
        bcc_text = savedInstanceState.getString("BCC_SAVE");
        Changed = savedInstanceState.getBoolean("BCC_CHANGED");
        // TS: junwei-xu 2015-06-30 EMAIL BUGFIX-1030195 ADD_S
        mPriorityFlag = savedInstanceState.getInt(KEY_PRIORITY_SAVED_STATE);
        // TS: junwei-xu 2015-06-30 EMAIL BUGFIX-1030195 ADD_E
        // TS: junwei-xu 2015-07-17 EMAIL BUGFIX-1029180 ADD_S
        mTextChanged = savedInstanceState.getBoolean(KEY_SAVED_STATE_TEXT_CHANGED);
        mAttachmentsChanged = savedInstanceState.getBoolean(KEY_SAVED_STATE_ATTACHMENT_CHANGED);
        mReplyFromChanged = savedInstanceState.getBoolean(KEY_SAVED_STATE_REPLY_FROM_CHANGED);
        mProrityChanged = savedInstanceState.getBoolean(KEY_SAVED_STATE_PRIORITY_CHANGED);
        // TS: junwei-xu 2015-07-17 EMAIL BUGFIX-1029180 ADD_E
        //TS: yanhua.chen 2015-7-29 EMAIL BUGFIX_1053132 ADD_S
        attLargeWarning = savedInstanceState.getBoolean(KEY_SAVED_STATE_ATTLARGEWARNING_CHANGED);
        //TS: yanhua.chen 2015-7-29 EMAIL BUGFIX_1053132 ADD_E
        //TS: yanhua.chen 2015-9-1 EMAIL CD_551912 ADD_S
        //mIsClickIcon = savedInstanceState.getBoolean(KEY_SAVED_STATE_ISCLICKICON_CHANGED);//[BUGFIX]-MOD by SCDTABLET.shujing.jin@tcl.com,05/06/2016,2013535
        mChangeAccount = savedInstanceState.getBoolean(KEY_SAVED_STATE_CHANGEACCOUNT_CHANGED);
        mEditDraft = savedInstanceState.getBoolean(KEY_SAVED_STATE_EDITDRAFT_CHANGED);
        //TS: yanhua.chen 2015-9-1 EMAIL CD_551912 ADD_E
    }
    //AM: peng-zhang 2015-02-27 EMAIL BUGFIX_955421 MOD_E
    setContentView(R.layout.compose);
    final ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        // Hide the app icon.
        actionBar.setIcon(null);
        actionBar.setDisplayUseLogoEnabled(false);
    }

    mInnerSavedState = (savedInstanceState != null) ? savedInstanceState.getBundle(KEY_INNER_SAVED_STATE)
            : null;

    //[FEATURE]-Add-BEGIN by TSNJ,Zhenhua.Fan,06/11/2014,FR-622609
    if (EmailApplication.isOrangeImapFeatureOn()) {
        Intent i = getIntent();
        if (i != null && i.getBooleanExtra(EXTRA_FROM_DRAFT_VIEW, false)) {
            isFromView = true;
        }
    }
    //[FEATURE]-Add-END by TSNJ,Zhenhua.Fan
    checkValidAccounts();
    // TS: jian.xu 2015-06-05 EMAIL BUGFIX-1006499 ADD_S
    LinearLayout tmp = (LinearLayout) findViewById(R.id.content);
    tmp.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() {

        @Override
        public void onGlobalLayout() {
            Rect r = new Rect();
            //get the cutrent visibale disrict.
            ComposeActivity.this.getWindow().getDecorView().getWindowVisibleDisplayFrame(r);
            //get the screen height
            int screenHeight = ComposeActivity.this.getWindow().getDecorView().getRootView().getHeight();

            Rect textRect = new Rect();
            int keyboardHeight = screenHeight - r.bottom;
            // the number 100 means that the keyboard is showing.
            if (keyboardHeight > 100) {
                android.os.Message msg = mHandler.obtainMessage(SET_LISTPOPUPWINDOW_HEIGHT);
                mHandler.sendMessage(msg);
            }
        }
    });
    // TS: jian.xu 2015-06-05 EMAIL BUGFIX-1006499 ADD_E
}

From source file:com.tct.mail.ui.AbstractActivityController.java

/**
 * Restore the state from the previous bundle. Subclasses should call this
 * method from the parent class, since it performs important UI
 * initialization.//from w  w w  . j a  v  a2 s  .  com
 *
 * @param savedState previous state
 */
@Override
public void onRestoreInstanceState(Bundle savedState) {
    mDetachedConvUri = savedState.getParcelable(SAVED_DETACHED_CONV_URI);
    if (savedState.containsKey(SAVED_CONVERSATION)) {
        // Open the conversation.
        final Conversation conversation = savedState.getParcelable(SAVED_CONVERSATION);
        if (conversation != null && conversation.position < 0) {
            // Set the position to 0 on this conversation, as we don't know where it is
            // in the list
            conversation.position = 0;
        }
        showConversation(conversation);
    }

    if (savedState.containsKey(SAVED_TOAST_BAR_OP)) {
        ToastBarOperation op = savedState.getParcelable(SAVED_TOAST_BAR_OP);
        if (op != null) {
            //TS: qing.liang 2015-03-10 EMAIL BUGFIX_-941849 ADD_S
            if (mConversationListCursor != null && mConversationListCursor.getUndoCallback() != null) {
                mUndoConversation = savedState.getParcelable(SAVED_UNDO_CONVERSATION);
                mUndoAction = savedState.getInt(SAVED_UNDO_ACTION);

                final UndoCallback undoCallback = new UndoCallback() {
                    @Override
                    public void performUndoCallback() {
                        showConversation(mUndoConversation);
                    }
                };
                mConversationListCursor.updateCallback(undoCallback);
            }
            //TS: qing.liang 2015-03-10 EMAIL BUGFIX_-941849 ADD_E
            if (op.getType() == ToastBarOperation.UNDO) {
                onUndoAvailable(op);
            } else if (op.getType() == ToastBarOperation.ERROR) {
                onError(mFolder, true);
            } else if (op.getType() == ToastBarOperation.DISCARD) { // TS: zheng.zou 2015-09-01 EMAIL BUGFIX-552138 ADD_S
                mSavedDraftMsgId = savedState.getLong(SAVED_DRAFT_MSG_ID);
                showDiscardDraftToast(mSavedDraftMsgId);
            } else if (op.getType() == ToastBarOperation.DISCARDED) {
                showDiscardedToast();
            }
            // TS: zheng.zou 2015-09-01 EMAIL BUGFIX-552138 ADD_E
        }
    }
    mFolderListFolder = savedState.getParcelable(SAVED_HIERARCHICAL_FOLDER);
    final ConversationListFragment convListFragment = getConversationListFragment();
    if (convListFragment != null) {
        convListFragment.getAnimatedAdapter().onRestoreInstanceState(savedState);
    }
    /*
     * Restore the state of selected conversations. This needs to be done after the correct mode
     * is set and the action bar is fully initialized. If not, several key pieces of state
     * information will be missing, and the split views may not be initialized correctly.
     */
    restoreSelectedConversations(savedState);
    // Order is important!!!
    // The dialog listener needs to happen *after* the selected set is restored.

    // If there has been an orientation change, and we need to recreate the listener for the
    // confirm dialog fragment (delete/archive/...), then do it here.
    if (mDialogAction != -1) {
        makeDialogListener(mDialogAction, mDialogFromSelectedSet,
                getUndoCallbackForDestructiveActionsWithAutoAdvance(mDialogAction, mCurrentConversation));
    }

    mInbox = savedState.getParcelable(SAVED_INBOX_KEY);

    mConversationListScrollPositions.clear();
    mConversationListScrollPositions.putAll(savedState.getBundle(SAVED_CONVERSATION_LIST_SCROLL_POSITIONS));
}

From source file:org.cafemember.ui.LaunchActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    Date now = new Date();
    /*int year = now.getYear();
    int month = now.getMonth();// w  w w . j a  v a2s.  c  om
    int day = now.getDay();
    now.getDate();
    long curr = 147083220000l;
    if(System.currentTimeMillis() > curr ){
    Toast.makeText(this,"    . ?      ",Toast.LENGTH_LONG).show();
    finish();
    }*/

    ApplicationLoader.postInitApplication();
    NativeCrashManager.handleDumpFiles(this);

    if (!UserConfig.isClientActivated()) {
        Intent intent = getIntent();
        if (intent != null && intent.getAction() != null && (Intent.ACTION_SEND.equals(intent.getAction())
                || intent.getAction().equals(Intent.ACTION_SEND_MULTIPLE))) {
            super.onCreate(savedInstanceState);
            finish();
            return;
        }
        if (intent != null && !intent.getBooleanExtra("fromIntro", false)) {
            SharedPreferences preferences = ApplicationLoader.applicationContext
                    .getSharedPreferences("logininfo2", MODE_PRIVATE);
            Map<String, ?> state = preferences.getAll();
            if (state.isEmpty()) {
                Intent intent2 = new Intent(this, IntroActivity.class);
                startActivity(intent2);
                super.onCreate(savedInstanceState);
                finish();
                return;
            }
        }
    }

    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setTheme(R.style.Theme_TMessages);
    getWindow().setBackgroundDrawableResource(R.drawable.transparent);

    super.onCreate(savedInstanceState);
    Theme.loadRecources(this);

    if (UserConfig.passcodeHash.length() != 0 && UserConfig.appLocked) {
        UserConfig.lastPauseTime = ConnectionsManager.getInstance().getCurrentTime();
    }

    int resourceId = getResources().getIdentifier("status_bar_height", "dimen", "android");
    if (resourceId > 0) {
        AndroidUtilities.statusBarHeight = getResources().getDimensionPixelSize(resourceId);
    }

    actionBarLayout = new ActionBarLayout(this);

    drawerLayoutContainer = new DrawerLayoutContainer(this);
    setContentView(drawerLayoutContainer, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    if (AndroidUtilities.isTablet()) {
        getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);

        RelativeLayout launchLayout = new RelativeLayout(this);
        drawerLayoutContainer.addView(launchLayout);
        FrameLayout.LayoutParams layoutParams1 = (FrameLayout.LayoutParams) launchLayout.getLayoutParams();
        layoutParams1.width = LayoutHelper.MATCH_PARENT;
        layoutParams1.height = LayoutHelper.MATCH_PARENT;
        launchLayout.setLayoutParams(layoutParams1);

        backgroundTablet = new ImageView(this);
        backgroundTablet.setScaleType(ImageView.ScaleType.CENTER_CROP);
        backgroundTablet.setImageResource(R.drawable.cats);
        launchLayout.addView(backgroundTablet);
        RelativeLayout.LayoutParams relativeLayoutParams = (RelativeLayout.LayoutParams) backgroundTablet
                .getLayoutParams();
        relativeLayoutParams.width = LayoutHelper.MATCH_PARENT;
        relativeLayoutParams.height = LayoutHelper.MATCH_PARENT;
        backgroundTablet.setLayoutParams(relativeLayoutParams);

        launchLayout.addView(actionBarLayout);
        relativeLayoutParams = (RelativeLayout.LayoutParams) actionBarLayout.getLayoutParams();
        relativeLayoutParams.width = LayoutHelper.MATCH_PARENT;
        relativeLayoutParams.height = LayoutHelper.MATCH_PARENT;
        actionBarLayout.setLayoutParams(relativeLayoutParams);

        rightActionBarLayout = new ActionBarLayout(this);
        launchLayout.addView(rightActionBarLayout);
        relativeLayoutParams = (RelativeLayout.LayoutParams) rightActionBarLayout.getLayoutParams();
        relativeLayoutParams.width = AndroidUtilities.dp(320);
        relativeLayoutParams.height = LayoutHelper.MATCH_PARENT;
        rightActionBarLayout.setLayoutParams(relativeLayoutParams);
        rightActionBarLayout.init(rightFragmentsStack);
        rightActionBarLayout.setDelegate(this);

        shadowTabletSide = new FrameLayout(this);
        shadowTabletSide.setBackgroundColor(0x40295274);
        launchLayout.addView(shadowTabletSide);
        relativeLayoutParams = (RelativeLayout.LayoutParams) shadowTabletSide.getLayoutParams();
        relativeLayoutParams.width = AndroidUtilities.dp(1);
        relativeLayoutParams.height = LayoutHelper.MATCH_PARENT;
        shadowTabletSide.setLayoutParams(relativeLayoutParams);

        shadowTablet = new FrameLayout(this);
        shadowTablet.setVisibility(View.GONE);
        shadowTablet.setBackgroundColor(0x7F000000);
        launchLayout.addView(shadowTablet);
        relativeLayoutParams = (RelativeLayout.LayoutParams) shadowTablet.getLayoutParams();
        relativeLayoutParams.width = LayoutHelper.MATCH_PARENT;
        relativeLayoutParams.height = LayoutHelper.MATCH_PARENT;
        shadowTablet.setLayoutParams(relativeLayoutParams);
        shadowTablet.setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                if (!actionBarLayout.fragmentsStack.isEmpty() && event.getAction() == MotionEvent.ACTION_UP) {
                    float x = event.getX();
                    float y = event.getY();
                    int location[] = new int[2];
                    layersActionBarLayout.getLocationOnScreen(location);
                    int viewX = location[0];
                    int viewY = location[1];

                    if (layersActionBarLayout.checkTransitionAnimation()
                            || x > viewX && x < viewX + layersActionBarLayout.getWidth() && y > viewY
                                    && y < viewY + layersActionBarLayout.getHeight()) {
                        return false;
                    } else {
                        if (!layersActionBarLayout.fragmentsStack.isEmpty()) {
                            for (int a = 0; a < layersActionBarLayout.fragmentsStack.size() - 1; a++) {
                                layersActionBarLayout
                                        .removeFragmentFromStack(layersActionBarLayout.fragmentsStack.get(0));
                                a--;
                            }
                            layersActionBarLayout.closeLastFragment(true);
                        }
                        return true;
                    }
                }
                return false;
            }
        });

        shadowTablet.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

            }
        });

        layersActionBarLayout = new ActionBarLayout(this);
        layersActionBarLayout.setRemoveActionBarExtraHeight(true);
        layersActionBarLayout.setBackgroundView(shadowTablet);
        layersActionBarLayout.setUseAlphaAnimations(true);
        layersActionBarLayout.setBackgroundResource(R.drawable.boxshadow);
        launchLayout.addView(layersActionBarLayout);
        relativeLayoutParams = (RelativeLayout.LayoutParams) layersActionBarLayout.getLayoutParams();
        relativeLayoutParams.width = AndroidUtilities.dp(530);
        relativeLayoutParams.height = AndroidUtilities.dp(528);
        layersActionBarLayout.setLayoutParams(relativeLayoutParams);
        layersActionBarLayout.init(layerFragmentsStack);
        layersActionBarLayout.setDelegate(this);
        layersActionBarLayout.setDrawerLayoutContainer(drawerLayoutContainer);
        layersActionBarLayout.setVisibility(View.GONE);
    } else {
        drawerLayoutContainer.addView(actionBarLayout, new ViewGroup.LayoutParams(
                ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
    }

    ListView listView = new ListView(this) {
        @Override
        public boolean hasOverlappingRendering() {
            return false;
        }
    };
    listView.setBackgroundColor(0xffffffff);
    listView.setAdapter(drawerLayoutAdapter = new DrawerLayoutAdapter(this));
    listView.setChoiceMode(AbsListView.CHOICE_MODE_SINGLE);
    listView.setDivider(null);
    listView.setDividerHeight(0);
    listView.setVerticalScrollBarEnabled(false);
    drawerLayoutContainer.setDrawerLayout(listView);
    FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) listView.getLayoutParams();
    Point screenSize = AndroidUtilities.getRealScreenSize();
    layoutParams.width = AndroidUtilities.isTablet() ? AndroidUtilities.dp(320)
            : Math.min(screenSize.x, screenSize.y) - AndroidUtilities.dp(56);
    layoutParams.height = LayoutHelper.MATCH_PARENT;
    listView.setLayoutParams(layoutParams);

    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            //
            if (position == 12) {
                presentFragment(new SettingsActivity());
                drawerLayoutContainer.closeDrawer(false);
            } else if (position == 11) {

                try {
                    RulesActivity his = new RulesActivity();
                    presentFragment(his);
                } catch (Exception e) {
                    FileLog.e("tmessages", e);
                }
                drawerLayoutContainer.closeDrawer(false);
            } else if (position == 2) {

                Defaults def = Defaults.getInstance();
                boolean open = def.openOnJoin();
                def.setOpenOnJoin(!open);
                if (view instanceof TextCheckCell) {
                    ((TextCheckCell) view).setChecked(!open);
                }
            } else if (position == 4) {
                try {
                    HistoryActivity his = new HistoryActivity();
                    presentFragment(his);
                } catch (Exception e) {
                    FileLog.e("tmessages", e);
                }
                drawerLayoutContainer.closeDrawer(false);
            }

            else if (position == 3) {
                Intent telegram = new Intent(Intent.ACTION_VIEW, Uri.parse("https://telegram.me/cafemember"));
                startActivity(telegram);

                drawerLayoutContainer.closeDrawer(false);
            } else if (position == 5) {
                try {
                    FAQActivity his = new FAQActivity();
                    presentFragment(his);
                } catch (Exception e) {
                    FileLog.e("tmessages", e);
                }
                drawerLayoutContainer.closeDrawer(false);
            } else if (position == 6) {
                Intent telegram = new Intent(Intent.ACTION_VIEW,
                        Uri.parse("https://telegram.me/" + Defaults.getInstance().getSupport()));
                startActivity(telegram);

                drawerLayoutContainer.closeDrawer(false);
            } else if (position == 7) {
                try {
                    HelpActivity his = new HelpActivity();
                    presentFragment(his);
                } catch (Exception e) {
                    FileLog.e("tmessages", e);
                }
                drawerLayoutContainer.closeDrawer(false);
            } else if (position == 8) {
                try {
                    AddRefActivity his = new AddRefActivity();
                    presentFragment(his);
                } catch (Exception e) {
                    FileLog.e("tmessages", e);
                }
                drawerLayoutContainer.closeDrawer(false);
            } else if (position == 9) {

                try {
                    Log.d("TAB", "Triggering");
                    ShareActivity his = new ShareActivity();
                    Log.d("TAB", "Triggered");
                    presentFragment(his);
                } catch (Exception e) {
                    FileLog.e("tmessages", e);
                }
                drawerLayoutContainer.closeDrawer(false);
            } else if (position == 10) {
                try {
                    //                        TransfareActivity his = new TransfareActivity();
                    //                        presentFragment(his);
                } catch (Exception e) {
                    FileLog.e("tmessages", e);
                }
                drawerLayoutContainer.closeDrawer(false);
            }
        }
    });

    drawerLayoutContainer.setParentActionBarLayout(actionBarLayout);
    actionBarLayout.setDrawerLayoutContainer(drawerLayoutContainer);
    actionBarLayout.init(mainFragmentsStack);
    actionBarLayout.setDelegate(this);

    ApplicationLoader.loadWallpaper();

    passcodeView = new PasscodeView(this);
    drawerLayoutContainer.addView(passcodeView);
    FrameLayout.LayoutParams layoutParams1 = (FrameLayout.LayoutParams) passcodeView.getLayoutParams();
    layoutParams1.width = LayoutHelper.MATCH_PARENT;
    layoutParams1.height = LayoutHelper.MATCH_PARENT;
    passcodeView.setLayoutParams(layoutParams1);

    NotificationCenter.getInstance().postNotificationName(NotificationCenter.closeOtherAppActivities, this);
    currentConnectionState = ConnectionsManager.getInstance().getConnectionState();

    NotificationCenter.getInstance().addObserver(this, NotificationCenter.appDidLogout);
    NotificationCenter.getInstance().addObserver(this, NotificationCenter.mainUserInfoChanged);
    NotificationCenter.getInstance().addObserver(this, NotificationCenter.closeOtherAppActivities);
    NotificationCenter.getInstance().addObserver(this, NotificationCenter.didUpdatedConnectionState);
    NotificationCenter.getInstance().addObserver(this, NotificationCenter.needShowAlert);
    NotificationCenter.getInstance().addObserver(this, NotificationCenter.wasUnableToFindCurrentLocation);
    if (Build.VERSION.SDK_INT < 14) {
        NotificationCenter.getInstance().addObserver(this, NotificationCenter.screenStateChanged);
    }

    if (actionBarLayout.fragmentsStack.isEmpty()) {
        if (!UserConfig.isClientActivated()) {
            actionBarLayout.addFragmentToStack(new LoginActivity());
            drawerLayoutContainer.setAllowOpenDrawer(false, false);
        } else {
            dialogsFragment = new DialogsActivity(null);
            actionBarLayout.addFragmentToStack(dialogsFragment);
            drawerLayoutContainer.setAllowOpenDrawer(true, false);
        }

        try {
            if (savedInstanceState != null) {
                String fragmentName = savedInstanceState.getString("fragment");
                if (fragmentName != null) {
                    Bundle args = savedInstanceState.getBundle("args");
                    switch (fragmentName) {
                    case "chat":
                        if (args != null) {
                            ChatActivity chat = new ChatActivity(args);
                            if (actionBarLayout.addFragmentToStack(chat)) {
                                chat.restoreSelfArgs(savedInstanceState);
                            }
                        }
                        break;
                    case "settings": {
                        SettingsActivity settings = new SettingsActivity();
                        actionBarLayout.addFragmentToStack(settings);
                        settings.restoreSelfArgs(savedInstanceState);
                        break;
                    }
                    case "group":
                        if (args != null) {
                            GroupCreateFinalActivity group = new GroupCreateFinalActivity(args);
                            if (actionBarLayout.addFragmentToStack(group)) {
                                group.restoreSelfArgs(savedInstanceState);
                            }
                        }
                        break;
                    case "channel":
                        if (args != null) {
                            ChannelCreateActivity channel = new ChannelCreateActivity(args);
                            if (actionBarLayout.addFragmentToStack(channel)) {
                                channel.restoreSelfArgs(savedInstanceState);
                            }
                        }
                        break;
                    case "edit":
                        if (args != null) {
                            ChannelEditActivity channel = new ChannelEditActivity(args);
                            if (actionBarLayout.addFragmentToStack(channel)) {
                                channel.restoreSelfArgs(savedInstanceState);
                            }
                        }
                        break;
                    case "chat_profile":
                        if (args != null) {
                            ProfileActivity profile = new ProfileActivity(args);
                            if (actionBarLayout.addFragmentToStack(profile)) {
                                profile.restoreSelfArgs(savedInstanceState);
                            }
                        }
                        break;
                    case "wallpapers": {
                        WallpapersActivity settings = new WallpapersActivity();
                        actionBarLayout.addFragmentToStack(settings);
                        settings.restoreSelfArgs(savedInstanceState);
                        break;
                    }
                    }
                }
            }
        } catch (Exception e) {
            FileLog.e("tmessages", e);
        }
    } else {
        boolean allowOpen = true;
        if (AndroidUtilities.isTablet()) {
            allowOpen = actionBarLayout.fragmentsStack.size() <= 1
                    && layersActionBarLayout.fragmentsStack.isEmpty();
            if (layersActionBarLayout.fragmentsStack.size() == 1
                    && layersActionBarLayout.fragmentsStack.get(0) instanceof LoginActivity) {
                allowOpen = false;
            }
        }
        if (actionBarLayout.fragmentsStack.size() == 1
                && actionBarLayout.fragmentsStack.get(0) instanceof LoginActivity) {
            allowOpen = false;
        }
        drawerLayoutContainer.setAllowOpenDrawer(allowOpen, false);
    }

    handleIntent(getIntent(), false, savedInstanceState != null, false);
    needLayout();

    final View view = getWindow().getDecorView().getRootView();
    view.getViewTreeObserver()
            .addOnGlobalLayoutListener(onGlobalLayoutListener = new ViewTreeObserver.OnGlobalLayoutListener() {
                @Override
                public void onGlobalLayout() {
                    int height = view.getMeasuredHeight();
                    if (height > AndroidUtilities.dp(100) && height < AndroidUtilities.displaySize.y
                            && height + AndroidUtilities.dp(100) > AndroidUtilities.displaySize.y) {
                        AndroidUtilities.displaySize.y = height;
                        FileLog.e("tmessages", "fix display size y to " + AndroidUtilities.displaySize.y);
                    }
                }
            });
}