Example usage for android.os Bundle getLong

List of usage examples for android.os Bundle getLong

Introduction

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

Prototype

public long getLong(String key) 

Source Link

Document

Returns the value associated with the given key, or 0L if no mapping of the desired type exists for the given key.

Usage

From source file:com.nextgis.mobile.fragment.MapFragment.java

@Override
public void onViewStateRestored(@Nullable Bundle savedInstanceState) {
    super.onViewStateRestored(savedInstanceState);
    if (null == savedInstanceState) {
        mMode = MODE_NORMAL;/*from  w  w  w  . j  av  a 2 s .c  om*/
    } else {
        mMode = savedInstanceState.getInt(KEY_MODE);

        int layerId = savedInstanceState.getInt(BUNDLE_KEY_LAYER);
        ILayer layer = mMap.getLayerById(layerId);
        Feature feature = null;

        if (null != layer && layer instanceof VectorLayer) {
            mSelectedLayer = (VectorLayer) layer;

            if (savedInstanceState.containsKey(BUNDLE_KEY_SAVED_FEATURE)) {
                GeoGeometry geometry = null;

                try {
                    geometry = GeoGeometryFactory
                            .fromBlob(savedInstanceState.getByteArray(BUNDLE_KEY_SAVED_FEATURE));
                } catch (IOException | ClassNotFoundException e) {
                    e.printStackTrace();
                }

                feature = new Feature();
                feature.setId(savedInstanceState.getLong(BUNDLE_KEY_FEATURE_ID));
                feature.setGeometry(geometry);
            }
        }

        mEditLayerOverlay.setSelectedLayer(mSelectedLayer);
        mEditLayerOverlay.setSelectedFeature(feature);
    }

    if (WalkEditService.isServiceRunning(getContext())) {
        SharedPreferences preferences = getContext().getSharedPreferences(WalkEditService.TEMP_PREFERENCES,
                Constants.MODE_MULTI_PROCESS);
        int layerId = preferences.getInt(ConstantsUI.KEY_LAYER_ID, NOT_FOUND);
        long featureId = preferences.getLong(ConstantsUI.KEY_FEATURE_ID, NOT_FOUND);
        ILayer layer = mMap.getMap().getLayerById(layerId);
        if (layer != null && layer instanceof VectorLayer) {
            mSelectedLayer = (VectorLayer) layer;
            mEditLayerOverlay.setSelectedLayer(mSelectedLayer);

            if (featureId > NOT_FOUND)
                mEditLayerOverlay.setSelectedFeature(featureId);
            else
                mEditLayerOverlay.newGeometryByWalk();

            GeoGeometry geometry = GeoGeometryFactory.fromWKT(
                    preferences.getString(ConstantsUI.KEY_GEOMETRY, ""), GeoConstants.CRS_WEB_MERCATOR);
            if (geometry != null)
                mEditLayerOverlay.setGeometryFromWalkEdit(geometry);

            mMode = MODE_EDIT_BY_WALK;
        }
    }

    setMode(mMode);

    if (savedInstanceState != null && savedInstanceState.getBoolean(BUNDLE_KEY_IS_MEASURING, false))
        startMeasuring();
}

From source file:com.xandy.calendar.AllInOneActivity.java

private void initFragments(long timeMillis, int viewType, Bundle icicle) {
    if (DEBUG) {/*from ww  w . ja v a  2s .c om*/
        Log.d(TAG, "Initializing to " + timeMillis + " for view " + viewType);
    }
    //        FragmentTransaction ft = getFragmentManager().beginTransaction();
    FragmentTransaction ft = getSupportFragmentManager().beginTransaction();

    if (mShowCalendarControls) {
        Fragment miniMonthFrag = new MonthByWeekFragment(timeMillis, true);
        ft.replace(R.id.mini_month, miniMonthFrag);
        mController.registerEventHandler(R.id.mini_month, (EventHandler) miniMonthFrag);

        Fragment selectCalendarsFrag = new SelectVisibleCalendarsFragment();
        ft.replace(R.id.calendar_list, selectCalendarsFrag);
        mController.registerEventHandler(R.id.calendar_list, (EventHandler) selectCalendarsFrag);
    }
    if (!mShowCalendarControls || viewType == ViewType.EDIT) {
        mMiniMonth.setVisibility(View.GONE);
        mCalendarsList.setVisibility(View.GONE);
    }

    EventInfo info = null;
    if (viewType == ViewType.EDIT) {
        mPreviousView = GeneralPreferences.getSharedPreferences(this).getInt(GeneralPreferences.KEY_START_VIEW,
                GeneralPreferences.DEFAULT_START_VIEW);

        long eventId = -1;
        Intent intent = getIntent();
        Uri data = intent.getData();
        if (data != null) {
            try {
                eventId = Long.parseLong(data.getLastPathSegment());
            } catch (NumberFormatException e) {
                if (DEBUG) {
                    Log.d(TAG, "Create new event");
                }
            }
        } else if (icicle != null && icicle.containsKey(BUNDLE_KEY_EVENT_ID)) {
            eventId = icicle.getLong(BUNDLE_KEY_EVENT_ID);
        }

        long begin = intent.getLongExtra(EXTRA_EVENT_BEGIN_TIME, -1);
        long end = intent.getLongExtra(EXTRA_EVENT_END_TIME, -1);
        info = new EventInfo();
        if (end != -1) {
            info.endTime = new Time();
            info.endTime.set(end);
        }
        if (begin != -1) {
            info.startTime = new Time();
            info.startTime.set(begin);
        }
        info.id = eventId;
        // We set the viewtype so if the user presses back when they are
        // done editing the controller knows we were in the Edit Event
        // screen. Likewise for eventId
        mController.setViewType(viewType);
        mController.setEventId(eventId);
    } else {
        mPreviousView = viewType;
    }

    setMainPane(ft, R.id.main_pane, viewType, timeMillis, true);
    ft.commit(); // this needs to be after setMainPane()

    Time t = new Time(mTimeZone);
    t.set(timeMillis);
    if (viewType == ViewType.AGENDA && icicle != null) {
        mController.sendEvent(this, EventType.GO_TO, t, null, icicle.getLong(BUNDLE_KEY_EVENT_ID, -1),
                viewType);
    } else if (viewType != ViewType.EDIT) {
        mController.sendEvent(this, EventType.GO_TO, t, null, -1, viewType);
    }
}

From source file:com.android.calendar.AllInOneActivity.java

private void initFragments(long timeMillis, int viewType, Bundle icicle) {
    if (DEBUG) {/*w w w.j  a v a2s  .c  o m*/
        Log.d(TAG, "Initializing to " + timeMillis + " for view " + viewType);
    }
    FragmentTransaction ft = getFragmentManager().beginTransaction();

    if (mShowCalendarControls) {
        Fragment miniMonthFrag = new MonthByWeekFragment(timeMillis, true);
        ft.replace(R.id.mini_month, miniMonthFrag);
        mController.registerEventHandler(R.id.mini_month, (EventHandler) miniMonthFrag);

        Fragment selectCalendarsFrag = new SelectVisibleCalendarsFragment();
        ft.replace(R.id.calendar_list, selectCalendarsFrag);
        mController.registerEventHandler(R.id.calendar_list, (EventHandler) selectCalendarsFrag);
    }
    if (!mShowCalendarControls || viewType == ViewType.EDIT) {
        mMiniMonth.setVisibility(View.GONE);
        mCalendarsList.setVisibility(View.GONE);
    }

    EventInfo info = null;
    if (viewType == ViewType.EDIT) {
        mPreviousView = GeneralPreferences.getSharedPreferences(this).getInt(GeneralPreferences.KEY_START_VIEW,
                GeneralPreferences.DEFAULT_START_VIEW);

        long eventId = -1;
        Intent intent = getIntent();
        Uri data = intent.getData();
        if (data != null) {
            try {
                eventId = Long.parseLong(data.getLastPathSegment());
            } catch (NumberFormatException e) {
                if (DEBUG) {
                    Log.d(TAG, "Create new event");
                }
            }
        } else if (icicle != null && icicle.containsKey(BUNDLE_KEY_EVENT_ID)) {
            eventId = icicle.getLong(BUNDLE_KEY_EVENT_ID);
        }

        long begin = intent.getLongExtra(EXTRA_EVENT_BEGIN_TIME, -1);
        long end = intent.getLongExtra(EXTRA_EVENT_END_TIME, -1);
        info = new EventInfo();
        if (end != -1) {
            info.endTime = new Time();
            info.endTime.set(end);
        }
        if (begin != -1) {
            info.startTime = new Time();
            info.startTime.set(begin);
        }
        info.id = eventId;
        // We set the viewtype so if the user presses back when they are
        // done editing the controller knows we were in the Edit Event
        // screen. Likewise for eventId
        mController.setViewType(viewType);
        mController.setEventId(eventId);
    } else {
        mPreviousView = viewType;
    }

    setMainPane(ft, R.id.main_pane, viewType, timeMillis, true);
    ft.commit(); // this needs to be after setMainPane()

    Time t = new Time(mTimeZone);
    t.set(timeMillis);
    if (viewType == ViewType.AGENDA && icicle != null) {
        mController.sendEvent(this, EventType.GO_TO, t, null, icicle.getLong(BUNDLE_KEY_EVENT_ID, -1),
                viewType);
    } else if (viewType != ViewType.EDIT) {
        mController.sendEvent(this, EventType.GO_TO, t, null, -1, viewType);
    }
}

From source file:com.hichinaschool.flashcards.anki.DeckPicker.java

@Override
public void onRestoreInstanceState(Bundle savedInstanceState) {
    super.onRestoreInstanceState(savedInstanceState);
    mCurrentDid = savedInstanceState.getLong("mCurrentDid");
    //      mDeckList = (ArrayList<HashMap<String, String>>) savedInstanceState.getSerializable("mDeckList");
}

From source file:com.synox.android.authentication.AuthenticatorActivity.java

/**
 * {@inheritDoc}//from   w  w w . j  a  va  2  s. com
 * 
 * IMPORTANT ENTRY POINT 1: activity is shown to the user
 */
@Override
protected void onCreate(Bundle savedInstanceState) {
    //Log_OC.wtf(TAG,  "onCreate init");
    super.onCreate(savedInstanceState);

    // Workaround, for fixing a problem with Android Library Suppor v7 19
    //getWindow().requestFeature(Window.FEATURE_NO_TITLE);
    if (getSupportActionBar() != null) {
        getSupportActionBar().hide();

        getSupportActionBar().setDisplayHomeAsUpEnabled(false);
        getSupportActionBar().setDisplayShowHomeEnabled(false);
        getSupportActionBar().setDisplayShowTitleEnabled(false);
    }

    mIsFirstAuthAttempt = true;

    // bind to Operations Service
    mOperationsServiceConnection = new OperationsServiceConnection();
    if (!bindService(new Intent(this, OperationsService.class), mOperationsServiceConnection,
            Context.BIND_AUTO_CREATE)) {
        Toast.makeText(this, R.string.error_cant_bind_to_operations_service, Toast.LENGTH_LONG).show();
        finish();
    }

    /// init activity state
    mAccountMgr = AccountManager.get(this);
    mNewCapturedUriFromOAuth2Redirection = null;

    /// get input values
    mAction = getIntent().getByteExtra(EXTRA_ACTION, ACTION_CREATE);
    mAccount = getIntent().getExtras().getParcelable(EXTRA_ACCOUNT);
    if (savedInstanceState == null) {
        initAuthTokenType();
    } else {
        mAuthTokenType = savedInstanceState.getString(KEY_AUTH_TOKEN_TYPE);
        mWaitingForOpId = savedInstanceState.getLong(KEY_WAITING_FOR_OP_ID);
        mIsFirstAuthAttempt = savedInstanceState.getBoolean(KEY_AUTH_IS_FIRST_ATTEMPT_TAG);
    }

    /// load user interface
    setContentView(R.layout.account_setup);

    /// initialize general UI elements
    initOverallUi();

    mOkButton = findViewById(R.id.buttonOK);
    mOkButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            onOkClick();
        }
    });

    View mCenteredRefreshButton = findViewById(R.id.centeredRefreshButton);
    mCenteredRefreshButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            checkOcServer();
        }
    });

    mOkButton = findViewById(R.id.buttonOK);

    /// initialize block to be moved to single Fragment to check server and get info about it 
    initServerPreFragment(savedInstanceState);

    /// initialize block to be moved to single Fragment to retrieve and validate credentials 
    initAuthorizationPreFragment(savedInstanceState);

    //Log_OC.wtf(TAG,  "onCreate end");
}

From source file:com.cerema.cloud2.authentication.AuthenticatorActivity.java

/**
 * {@inheritDoc}//  w w  w .j  av  a  2  s  . c o m
 * 
 * IMPORTANT ENTRY POINT 1: activity is shown to the user
 */
@Override
protected void onCreate(Bundle savedInstanceState) {
    //Log_OC.wtf(TAG,  "onCreate init");
    super.onCreate(savedInstanceState);

    // Workaround, for fixing a problem with Android Library Suppor v7 19
    //getWindow().requestFeature(Window.FEATURE_NO_TITLE);
    if (getSupportActionBar() != null) {
        getSupportActionBar().hide();

        getSupportActionBar().setDisplayHomeAsUpEnabled(false);
        getSupportActionBar().setDisplayShowHomeEnabled(false);
        getSupportActionBar().setDisplayShowTitleEnabled(false);
    }

    mIsFirstAuthAttempt = true;

    // bind to Operations Service
    mOperationsServiceConnection = new OperationsServiceConnection();
    if (!bindService(new Intent(this, OperationsService.class), mOperationsServiceConnection,
            Context.BIND_AUTO_CREATE)) {
        Toast.makeText(this, R.string.error_cant_bind_to_operations_service, Toast.LENGTH_LONG).show();
        finish();
    }

    /// init activity state
    mAccountMgr = AccountManager.get(this);
    mNewCapturedUriFromOAuth2Redirection = null;

    /// get input values
    mAction = getIntent().getByteExtra(EXTRA_ACTION, ACTION_CREATE);
    mAccount = getIntent().getExtras().getParcelable(EXTRA_ACCOUNT);
    if (savedInstanceState == null) {
        initAuthTokenType();
    } else {
        mAuthTokenType = savedInstanceState.getString(KEY_AUTH_TOKEN_TYPE);
        mWaitingForOpId = savedInstanceState.getLong(KEY_WAITING_FOR_OP_ID);
        mIsFirstAuthAttempt = savedInstanceState.getBoolean(KEY_AUTH_IS_FIRST_ATTEMPT_TAG);
    }

    /// load user interface
    setContentView(R.layout.account_setup);

    /// initialize general UI elements
    initOverallUi();

    mOkButton = findViewById(R.id.buttonOK);
    mOkButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            onOkClick();
        }
    });

    findViewById(R.id.centeredRefreshButton).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            checkOcServer();
        }
    });

    findViewById(R.id.embeddedRefreshButton).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            checkOcServer();
        }
    });

    /// initialize block to be moved to single Fragment to check server and get info about it 
    initServerPreFragment(savedInstanceState);

    /// initialize block to be moved to single Fragment to retrieve and validate credentials 
    initAuthorizationPreFragment(savedInstanceState);

    //Log_OC.wtf(TAG,  "onCreate end");
}

From source file:com.ezeeideas.wordjam.BaseGameActivity.java

/**
 * Restore the instance of the game from the saved Bundle.  This is usually
 * when the device screen was rotated while in the middle of the game.
 * //from  w w  w .ja v a2 s .  c  o  m
 * Note: The game may or may not have been stored in the DB.
 * 
 * @param savedInstanceState The bundle to restore state from
 */
private void restoreSavedInstance(Bundle savedInstanceState) {
    if (savedInstanceState != null && !savedInstanceState.isEmpty()) {
        mIsPlay = savedInstanceState.getBoolean(Constants.KEY_IS_PLAY);
        mPlayType = savedInstanceState.getInt(Constants.KEY_PLAY_TYPE);
        mGameNumber = savedInstanceState.getInt(Constants.KEY_GAME_NUM);
        mIsNewGame = savedInstanceState.getBoolean(Constants.KEY_IS_NEW_GAME);

        if (mIsPlay) {
            mLevel = savedInstanceState.getInt(Constants.KEY_LEVEL);
            mNumGamesInLevel = savedInstanceState.getInt(Constants.KEY_LEVEL_NUM_GAMES);

            mLevelPoints = savedInstanceState.getInt(Constants.KEY_LEVEL_POINTS);
            mLevelState = savedInstanceState.getInt(Constants.KEY_LEVEL_STATE);
            mLevelGamesRemaining = savedInstanceState.getInt(Constants.KEY_LEVEL_GAMES_REMAINING);
            mLevelHintsRemaining = savedInstanceState.getInt(Constants.KEY_LEVEL_HINTS_REMAINING);
            mLevelHintsEarned = savedInstanceState.getInt(Constants.KEY_LEVEL_HINTS_EARNED);
        } else {
            mPracticeType = savedInstanceState.getInt(Constants.KEY_PRACTICE_TYPE);
            mPracticeGamesCompleted = savedInstanceState.getInt(Constants.PRACTICE_GAMES_COMPLETED);
            mPracticeTimeSpent = savedInstanceState.getInt(Constants.PRACTICE_TIME_SPENT);
            mPracticeHintsUsed = savedInstanceState.getInt(Constants.PRACTICE_HINTS_USED);
            mPracticePointsEarned = savedInstanceState.getInt(Constants.PRACTICE_POINTS_EARNED);
        }

        mGameState = savedInstanceState.getInt(Constants.KEY_GAME_STATE);
        mGameHintsRemaining = savedInstanceState.getInt(Constants.KEY_GAME_HINTS_REMAINING);
        mGameHintsUsed = GameUtils.getPointChart(mPlayType, mIsPlay, mLevel,
                mPracticeType)[GameUtils.GAME_HINTS_TOTAL][mGameType] - mGameHintsRemaining;
        mGamePoints = savedInstanceState.getInt(Constants.KEY_GAME_POINTS);
        mGameTime = savedInstanceState.getLong(Constants.KEY_GAME_DURATION);
        mGameData = savedInstanceState.getString(Constants.KEY_GAME_DATA);
    }
}

From source file:de.vanita5.twittnuker.activity.support.ComposeActivity.java

@Override
protected void onCreate(final Bundle savedInstanceState) {
    // requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
    super.onCreate(savedInstanceState);
    mLocationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
    mPreferences = SharedPreferencesWrapper.getInstance(this, SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE);
    mBottomSendButton = mPreferences.getBoolean(KEY_BOTTOM_SEND_BUTTON, false);
    mTwitterWrapper = getTwittnukerApplication().getTwitterWrapper();
    mResolver = getContentResolver();/*w  w w . ja  va 2 s  . c o  m*/
    mValidator = new TwidereValidator(this);
    setContentView(getLayoutInflater().inflate(R.layout.activity_compose, null));
    setProgressBarIndeterminateVisibility(false);
    setFinishOnTouchOutside(false);
    mAccountIds = getAccountIds(this);
    if (mAccountIds.length <= 0) {
        final Intent intent = new Intent(INTENT_ACTION_TWITTER_LOGIN);
        intent.setClass(this, SignInActivity.class);
        startActivity(intent);
        finish();
        return;
    }
    mBottomMenuBar.setIsBottomBar(true);
    mBottomMenuBar.setOnMenuItemClickListener(this);
    mActionMenuBar.setOnMenuItemClickListener(this);
    mEditText.setOnEditorActionListener(mPreferences.getBoolean(KEY_QUICK_SEND, false) ? this : null);
    mEditText.addTextChangedListener(this);
    mAccountSelectorAdapter = new AccountSelectorAdapter(this);
    mAccountSelector.setAdapter(mAccountSelectorAdapter);
    mAccountSelector.setOnItemClickListener(this);
    mAccountSelector.setOnItemLongClickListener(this);
    mAccountSelector.setScrollAfterItemClickEnabled(false);
    mAccountSelector.setScrollRightSpacingEnabled(false);

    mMediaPreviewAdapter = new MediaPreviewAdapter(this);
    mMediasPreviewGrid.setAdapter(mMediaPreviewAdapter);

    final Intent intent = getIntent();

    if (savedInstanceState != null) {
        // Restore from previous saved state
        mSendAccountIds = savedInstanceState.getLongArray(EXTRA_ACCOUNT_IDS);
        mIsPossiblySensitive = savedInstanceState.getBoolean(EXTRA_IS_POSSIBLY_SENSITIVE);
        final ArrayList<ParcelableMediaUpdate> mediasList = savedInstanceState
                .getParcelableArrayList(EXTRA_MEDIAS);
        if (mediasList != null) {
            addMedias(mediasList);
        }
        mInReplyToStatus = savedInstanceState.getParcelable(EXTRA_STATUS);
        mInReplyToStatusId = savedInstanceState.getLong(EXTRA_STATUS_ID);
        mMentionUser = savedInstanceState.getParcelable(EXTRA_USER);
        mDraftItem = savedInstanceState.getParcelable(EXTRA_DRAFT);
        mShouldSaveAccounts = savedInstanceState.getBoolean(EXTRA_SHOULD_SAVE_ACCOUNTS);
        mOriginalText = savedInstanceState.getString(EXTRA_ORIGINAL_TEXT);
        mTempPhotoUri = savedInstanceState.getParcelable(EXTRA_TEMP_URI);
    } else {
        // The activity was first created
        final int notificationId = intent.getIntExtra(EXTRA_NOTIFICATION_ID, -1);
        final long notificationAccount = intent.getLongExtra(EXTRA_NOTIFICATION_ACCOUNT, -1);
        if (notificationId != -1) {
            mTwitterWrapper.clearNotificationAsync(notificationId, notificationAccount);
        }
        if (!handleIntent(intent)) {
            handleDefaultIntent(intent);
        }
        if (mSendAccountIds == null || mSendAccountIds.length == 0) {
            final long[] ids_in_prefs = ArrayUtils
                    .parseLongArray(mPreferences.getString(KEY_COMPOSE_ACCOUNTS, null), ',');
            final long[] intersection = ArrayUtils.intersection(ids_in_prefs, mAccountIds);
            mSendAccountIds = intersection.length > 0 ? intersection : mAccountIds;
        }
        mOriginalText = ParseUtils.parseString(mEditText.getText());
    }
    if (!setComposeTitle(intent)) {
        setTitle(R.string.compose);
    }

    final boolean useBottomMenu = isSingleAccount() || !mBottomSendButton;
    if (useBottomMenu) {
        mBottomMenuBar.inflate(R.menu.menu_compose);
    } else {
        mActionMenuBar.inflate(R.menu.menu_compose);
    }
    mBottomMenuBar.setVisibility(useBottomMenu ? View.VISIBLE : View.GONE);
    mActionMenuBar.setVisibility(useBottomMenu ? View.GONE : View.VISIBLE);
    mSendView.setVisibility(mBottomSendButton ? View.GONE : View.VISIBLE);
    mBottomSendDivider.setVisibility(mBottomSendButton ? View.VISIBLE : View.GONE);
    mBottomSendView.setVisibility(mBottomSendButton ? View.VISIBLE : View.GONE);
    mSendView.setOnClickListener(this);
    mBottomSendView.setOnClickListener(this);
    mSendView.setOnLongClickListener(this);
    mBottomSendView.setOnLongClickListener(this);
    final LinearLayout.LayoutParams bottomMenuContainerParams = (LinearLayout.LayoutParams) mBottomMenuContainer
            .getLayoutParams();
    final LinearLayout.LayoutParams accountSelectorParams = (LinearLayout.LayoutParams) mAccountSelector
            .getLayoutParams();
    final int maxItemsShown;
    final Resources res = getResources();
    if (isSingleAccount()) {
        accountSelectorParams.weight = 0;
        accountSelectorParams.width = ViewGroup.LayoutParams.WRAP_CONTENT;
        bottomMenuContainerParams.weight = 1;
        bottomMenuContainerParams.width = ViewGroup.LayoutParams.MATCH_PARENT;
        maxItemsShown = res.getInteger(R.integer.max_compose_menu_buttons_bottom_singleaccount);
        mAccountSelectorDivider.setVisibility(View.VISIBLE);
    } else {
        accountSelectorParams.weight = 1;
        accountSelectorParams.width = ViewGroup.LayoutParams.MATCH_PARENT;
        bottomMenuContainerParams.weight = 0;
        bottomMenuContainerParams.width = ViewGroup.LayoutParams.WRAP_CONTENT;
        maxItemsShown = res.getInteger(R.integer.max_compose_menu_buttons_bottom);
        mAccountSelectorDivider.setVisibility(mBottomSendButton ? View.GONE : View.VISIBLE);
    }
    mBottomMenuContainer.setLayoutParams(bottomMenuContainerParams);
    mBottomMenuBar.setMaxItemsShown(maxItemsShown);
    setMenu();
    updateAccountSelection();
    updateMediasPreview();
}

From source file:com.tweetlanes.android.core.view.TweetFeedFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);

    mProfileImageLoader = getApp().getProfileImageLoader();
    mPreviewImageLoader = getApp().getPreviewImageLoader();

    mContentHandle = TwitterManager.get().getContentHandle(getContentHandleBase(), getScreenName(),
            getLaneIdentifier(), getApp().getCurrentAccountKey());

    View resultView = inflater.inflate(R.layout.lane, null);
    configureLaneWidth(resultView);/*from   w ww  .  jav  a  2 s .  c om*/

    mViewSwitcher = (ViewSwitcher) resultView.findViewById(R.id.profileSwitcher);
    mListHeadingTextView = (TextView) resultView.findViewById(R.id.list_heading);
    mListHeadingHideImage = (ImageView) resultView.findViewById(R.id.list_hide);
    mListHeadingHideImage.setOnClickListener(mListHeadingHideImageOnClickListener);
    mMultipleTweetSelectionCallback = new MultipleTweetSelectionCallback();
    mTweetFeedListAdapter = new TweetFeedListAdapter(inflater);

    mTweetFeedListView = (PullToRefreshListView) resultView.findViewById(R.id.pull_to_refresh_listview);
    mTweetFeedListView.getRefreshableView().setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL);
    mTweetFeedListView.getRefreshableView().setMultiChoiceModeListener(mMultipleTweetSelectionCallback);
    mTweetFeedListView.getRefreshableView().setOnScrollListener(mTweetFeedOnScrollListener);
    mTweetFeedListView.getRefreshableView().setAdapter(mTweetFeedListAdapter);
    mTweetFeedListView.setOnRefreshListener(mTweetFeedOnRefreshListener);
    mTweetFeedListView.setOnLastItemVisibleListener(mTweetFeedOnLastItemVisibleListener);

    mRefreshTimestampsHandler.removeCallbacks(mRefreshTimestampsTask);
    mRefreshTimestampsHandler.postDelayed(mRefreshTimestampsTask, REFRESH_TIMESTAMPS_INTERVAL);

    LocalBroadcastManager.getInstance(getActivity()).registerReceiver(mVolumeUpKeyDownReceiver,
            new IntentFilter("" + SystemEvent.VOLUME_UP_KEY_DOWN));
    LocalBroadcastManager.getInstance(getActivity()).registerReceiver(mVolumeDownKeyDownReceiver,
            new IntentFilter("" + SystemEvent.VOLUME_DOWN_KEY_DOWN));

    if (savedInstanceState != null) {
        mTwitterStatusIdWhenRefreshed = savedInstanceState.containsKey("TwitterStatusIdWhenRefreshed")
                ? savedInstanceState.getLong("TwitterStatusIdWhenRefreshed")
                : 0L;
        mLastTwitterStatusIdSeen = savedInstanceState.containsKey("LastTwitterStatusIdSeen")
                ? savedInstanceState.getLong("LastTwitterStatusIdSeen")
                : 0L;
        mNewStatuses = savedInstanceState.getInt("NewStatuses", 0);
        mHidingListHeading = savedInstanceState.getBoolean("HidingListHeading", false);
    }

    configureInitialStatuses();

    return resultView;
}

From source file:com.tortel.deploytrack.CreateActivity.java

@SuppressLint("SimpleDateFormat")
@Override/* ww w .j  a  v  a  2  s  . com*/
public void onCreate(Bundle savedInstanceState) {
    // Check for light theme
    Prefs.load(this);
    if (Prefs.useLightTheme()) {
        setTheme(R.style.Theme_DeployThemeLight);
    }

    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_create);
    if (getSupportActionBar() != null) {
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    }

    mFirebaseAnalytics = FirebaseAnalytics.getInstance(this);

    mDateFormat = new SimpleDateFormat("MMM dd, yyyy");

    mNameEdit = (EditText) findViewById(R.id.name);
    mNameEdit.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence charSequence, int start, int count, int after) {
            // Do nothing
        }

        @Override
        public void onTextChanged(CharSequence charSequence, int start, int before, int count) {
            // Clear errors on text change
            try {
                mNameWrapper.setErrorEnabled(false);
            } catch (Exception e) {
                // Ignore
            }
        }

        @Override
        public void afterTextChanged(Editable editable) {
            // Do nothing
        }
    });
    mNameWrapper = (TextInputLayout) findViewById(R.id.name_wraper);

    mStartInput = (EditText) findViewById(R.id.button_start);
    mStartInput.setOnClickListener(this);
    mStartInput.setOnFocusChangeListener(this);
    mStartWrapper = (TextInputLayout) findViewById(R.id.start_wrapper);

    mEndInput = (EditText) findViewById(R.id.button_end);
    mEndInput.setOnClickListener(this);
    mEndInput.setOnFocusChangeListener(this);
    mEndWrapper = (TextInputLayout) findViewById(R.id.end_wrapper);

    mBarButton = (RadioButton) findViewById(R.id.layout_bar);
    RadioButton circleButton = (RadioButton) findViewById(R.id.layout_circle);

    //Color pickers
    ColorPicker completedPicker = (ColorPicker) findViewById(R.id.picker_completed);
    ColorPicker remainingPicker = (ColorPicker) findViewById(R.id.picker_remain);

    SVBar completedBar = (SVBar) findViewById(R.id.sv_completed);
    SVBar remainingBar = (SVBar) findViewById(R.id.sv_remain);

    String id = getIntent().getStringExtra("id");
    if (id != null) {
        //Starting in edit mode, load the old data
        mDeployment = DatabaseManager.getInstance(this).getDeployment(id);

        //Set the colors
        mCompletedColor = mDeployment.getCompletedColor();
        mRemainingColor = mDeployment.getRemainingColor();

        //Set the dates
        mStartDate = Calendar.getInstance();
        mEndDate = Calendar.getInstance();

        mStartDate.setTimeInMillis(mDeployment.getStartDate().getTime());
        mEndDate.setTimeInMillis(mDeployment.getEndDate().getTime());

        //Set the buttons
        mStartInput.setText(mDateFormat.format(mStartDate.getTime()));
        mEndInput.setText(mDateFormat.format(mEndDate.getTime()));

        // Set circle/bar selected
        if (mDeployment.getDisplayType() == Deployment.DISPLAY_BAR) {
            mBarButton.setChecked(true);
        } else {
            circleButton.setChecked(true);
        }

        //Set the name
        mNameEdit.setText(mDeployment.getName());

        getSupportActionBar().setTitle(R.string.edit);
    } else {
        mDeployment = new Deployment();

        mStartDate = Calendar.getInstance();
        mEndDate = (Calendar) mStartDate.clone();

        mCompletedColor = Color.GREEN;
        mRemainingColor = Color.RED;

        getSupportActionBar().setTitle(R.string.add_new);
    }

    //If restore from rotation
    if (savedInstanceState != null) {
        mStartDate.setTimeInMillis(savedInstanceState.getLong(KEY_TIME_START));
        mEndDate.setTimeInMillis(savedInstanceState.getLong(KEY_TIME_END));

        mNameEdit.setText(savedInstanceState.getString(KEY_NAME));

        mCompletedColor = savedInstanceState.getInt(KEY_COLOR_COMPLETED);
        mRemainingColor = savedInstanceState.getInt(KEY_COLOR_REMAINING);

        //Set the date buttons, if set
        if (mStartDate != null) {
            mStartInput.setText(mDateFormat.format(mStartDate.getTime()));
        }

        if (mStartDate != null && mEndDate != null && mEndDate.after(mStartDate)) {
            mEndInput.setText(mDateFormat.format(mEndDate.getTime()));
        }

        int viewType = savedInstanceState.getInt(KEY_DISPLAY_TYPE, Deployment.DISPLAY_CIRCLE);
        if (viewType == Deployment.DISPLAY_BAR) {
            mBarButton.setChecked(true);
        } else {
            circleButton.setChecked(true);
        }
    }

    remainingPicker.setOldCenterColor(mRemainingColor);
    remainingPicker.setNewCenterColor(mRemainingColor);
    remainingPicker.addSVBar(remainingBar);
    remainingPicker.setColor(mRemainingColor);
    remainingPicker.setShowOldCenterColor(false);
    remainingPicker.setOnColorChangedListener(new RemainingColorChangeListener());

    completedPicker.setOldCenterColor(mCompletedColor);
    completedPicker.setNewCenterColor(mCompletedColor);
    completedPicker.addSVBar(completedBar);
    completedPicker.setColor(mCompletedColor);
    completedPicker.setShowOldCenterColor(false);
    completedPicker.setOnColorChangedListener(new CompletedColorChangeListener());

    // Register for date changes
    LocalBroadcastManager.getInstance(this).registerReceiver(mDateChangeReceiver,
            new IntentFilter(SingleDatePickerDialog.ACTION_DATE_SELECTED));
}