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, long defaultValue) 

Source Link

Document

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

Usage

From source file:com.aimfire.demo.CamcorderActivity.java

@Override
protected void onNewIntent(Intent intent) {
    if (BuildConfig.DEBUG)
        Log.d(TAG, "onNewIntent");

    /*//from w ww .  j a  v  a  2 s .  c o  m
     * we will now set up the synchronization between two cameras
     */
    Bundle extras = intent.getExtras();
    if (extras == null) {
        if (BuildConfig.DEBUG)
            Log.e(TAG, "onNewIntent: wrong parameter");
        FirebaseCrash.report(new Exception("CamcorderActivity onNewIntent: wrong parameter"));
        finish();
        return;
    }

    mSyncTimeUs = extras.getLong(MainConsts.EXTRA_SYNCTIME, -1);

    /*
     * we could get here in two ways: 1) AimfireService completed sync with remote device.
     * 2) a switch from photo to video mode. if it is the latter, EXTRA_MSG is true
     */
    mPvSwitching = extras.getBoolean(MainConsts.EXTRA_MSG, false);

    /*
     * originally we set the initiator to be the left device. now we will set left/right
     * based on user preference
     */
    if (mPvSwitching) {
        mIsLeft = extras.getBoolean(MainConsts.EXTRA_ISLEFT);
    }

    /*
     * send parameters of our camera to remote.
     */
    sendCamParams();

    //      CustomToast.show(getActivity(),
    //          mIsLeft?getActivity().getString(R.string.left_camera_ready):
    //                  getActivity().getString(R.string.right_camera_ready),
    //          Toast.LENGTH_SHORT);
}

From source file:com.lambdasoup.quickfit.ui.WorkoutListActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Timber.d("onCreate before inflate");
    setContentView(R.layout.activity_workout_list);

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);/*from  w ww . ja v a 2  s  . com*/
    //noinspection ConstantConditions
    toolbar.setTitle(getTitle());

    fabAnimationDuration = getResources().getInteger(R.integer.fab_animation_duration);

    fab = (FloatingActionButton) findViewById(R.id.fab);
    //noinspection ConstantConditions
    fab.setOnClickListener(view -> addNewWorkout());

    // need to set statelistdrawable referencing vector drawables programmatically, because
    // support library vector drawable support in 23.3.0 does not allow vector drawable
    // references in xml statelistdrawables
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
        VectorDrawableCompat drawableAdd = VectorDrawableCompat.create(getResources(),
                R.drawable.ic_add_white_fat_24dp, getTheme());
        VectorDrawableCompat drawableExpandLess = VectorDrawableCompat.create(getResources(),
                R.drawable.ic_expand_less_white_fat_24dp, getTheme());

        StateListDrawable stateListDrawable = new StateListDrawable();
        stateListDrawable.addState(new int[] { android.R.attr.state_activated }, drawableExpandLess);
        stateListDrawable.addState(new int[] {}, drawableAdd);

        fab.setImageDrawable(stateListDrawable);
    }

    fabBackgroundToActivated = BackgroundTintListAnimator.create(this, fab, R.color.colorAccent,
            R.color.colorPrimaryMediumLight, fabAnimationDuration);
    fabBackgroundToNotActivated = BackgroundTintListAnimator.create(this, fab, R.color.colorPrimaryMediumLight,
            R.color.colorAccent, fabAnimationDuration);

    masterDetailView = (MasterDetailLayout) findViewById(R.id.two_panes);
    if (masterDetailView != null) {
        // The detail container view will be present only in the
        // large-screen layouts (res/values-w900dp).
        // If this view is present, then the
        // activity should be in two-pane mode.
        isTwoPane = true;

        fabAddSchedule = findViewById(R.id.fab_add_schedule);
        //noinspection ConstantConditions
        fabAddSchedule.setOnClickListener(view -> addNewSchedule());
        fabAddWorkout = findViewById(R.id.fab_add_workout);
        //noinspection ConstantConditions
        fabAddWorkout.setOnClickListener(view -> addNewWorkout());
        setMiniFabOffsets();

        masterDetailView.setAfterCollapse(() -> {
            CoordinatorLayout.LayoutParams fabLayoutParams = (CoordinatorLayout.LayoutParams) fab
                    .getLayoutParams();
            fabLayoutParams.setAnchorId(View.NO_ID);
            fabLayoutParams.gravity = Gravity.BOTTOM | Gravity.END;
            fab.setLayoutParams(fabLayoutParams);

            Fragment schedulesFragment = getSupportFragmentManager().findFragmentById(R.id.schedules_container);
            getSupportFragmentManager().beginTransaction().remove(schedulesFragment).commit();
        });
    }

    workoutsRecyclerView = (EmptyRecyclerView) findViewById(R.id.workout_list);
    workoutsAdapter = new WorkoutItemRecyclerViewAdapter(this, isTwoPane);
    workoutsAdapter.setOnWorkoutInteractionListener(this);

    workoutsRecyclerView.setAdapter(workoutsAdapter);
    workoutsRecyclerView.addItemDecoration(new DividerItemDecoration(this, false));

    readIntentExtras();

    if (savedInstanceState != null) {
        idToSelect = savedInstanceState.getLong(KEY_SHOW_WORKOUT_ID, NO_ID);
        if (idToSelect == NO_ID) {
            idToSelect = savedInstanceState.getLong(KEY_SELECTED_ITEM_ID, NO_ID);
        }
    } else {
        idToSelect = FIRST_ITEM_IF_EXISTS;
    }

    getLoaderManager().initLoader(0, null, this);
    Timber.d("onCreate finished");
}

From source file:com.android.launcher2.Launcher.java

/**
 * Restores the previous state, if it exists.
 *
 * @param savedState The previous state.
 *///from  w  ww.  j a  va 2 s  .  c  o  m
private void restoreState(Bundle savedState) {
    if (savedState == null) {
        return;
    }

    State state = intToState(savedState.getInt(RUNTIME_STATE, State.WORKSPACE.ordinal()));
    if (state == State.APPS_CUSTOMIZE) {
        mOnResumeState = State.APPS_CUSTOMIZE;
    }

    int currentScreen = savedState.getInt(RUNTIME_STATE_CURRENT_SCREEN, -1);
    if (currentScreen > -1) {
        mWorkspace.setCurrentPage(currentScreen);
    }

    final long pendingAddContainer = savedState.getLong(RUNTIME_STATE_PENDING_ADD_CONTAINER, -1);
    final int pendingAddScreen = savedState.getInt(RUNTIME_STATE_PENDING_ADD_SCREEN, -1);

    if (pendingAddContainer != ItemInfo.NO_ID && pendingAddScreen > -1) {
        mPendingAddInfo.container = pendingAddContainer;
        mPendingAddInfo.screen = pendingAddScreen;
        mPendingAddInfo.cellX = savedState.getInt(RUNTIME_STATE_PENDING_ADD_CELL_X);
        mPendingAddInfo.cellY = savedState.getInt(RUNTIME_STATE_PENDING_ADD_CELL_Y);
        mPendingAddInfo.spanX = savedState.getInt(RUNTIME_STATE_PENDING_ADD_SPAN_X);
        mPendingAddInfo.spanY = savedState.getInt(RUNTIME_STATE_PENDING_ADD_SPAN_Y);
        mPendingAddWidgetInfo = savedState.getParcelable(RUNTIME_STATE_PENDING_ADD_WIDGET_INFO);
        mWaitingForResult = true;
        mRestoring = true;
    }

    boolean renameFolder = savedState.getBoolean(RUNTIME_STATE_PENDING_FOLDER_RENAME, false);
    if (renameFolder) {
        long id = savedState.getLong(RUNTIME_STATE_PENDING_FOLDER_RENAME_ID);
        mFolderInfo = mModel.getFolderById(this, sFolders, id);
        mRestoring = true;
    }

    // Restore the AppsCustomize tab
    if (mAppsCustomizeTabHost != null) {
        String curTab = savedState.getString("apps_customize_currentTab");
        if (curTab != null) {
            mAppsCustomizeTabHost
                    .setContentTypeImmediate(mAppsCustomizeTabHost.getContentTypeForTabTag(curTab));
            mAppsCustomizeContent.loadAssociatedPages(mAppsCustomizeContent.getCurrentPage());
        }

        int currentIndex = savedState.getInt("apps_customize_currentIndex");
        mAppsCustomizeContent.restorePageForIndex(currentIndex);
    }
}

From source file:com.android.email.activity.MessageView.java

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    setContentView(R.layout.message_view);
    mHandler = new MessageViewHandler();
    mControllerCallback = new ControllerResults();

    mSubjectView = (TextView) findViewById(R.id.subject);
    mFromView = (TextView) findViewById(R.id.from);
    mToView = (TextView) findViewById(R.id.to);
    mCcView = (TextView) findViewById(R.id.cc);
    mCcContainerView = findViewById(R.id.cc_container);
    mDateView = (TextView) findViewById(R.id.date);
    mTimeView = (TextView) findViewById(R.id.time);
    mMessageContentView = (WebView) findViewById(R.id.message_content);
    mAttachments = (LinearLayout) findViewById(R.id.attachments);
    mAttachmentIcon = (ImageView) findViewById(R.id.attachment);
    mFavoriteIcon = (ImageView) findViewById(R.id.favorite);
    mShowPicturesSection = findViewById(R.id.show_pictures_section);
    mInviteSection = findViewById(R.id.invite_section);
    mSenderPresenceView = (ImageView) findViewById(R.id.presence);
    mMoveToNewer = findViewById(R.id.moveToNewer);
    mMoveToOlder = findViewById(R.id.moveToOlder);
    mScrollView = findViewById(R.id.scrollview);

    mMoveToNewer.setOnClickListener(this);
    mMoveToOlder.setOnClickListener(this);
    mFromView.setOnClickListener(this);
    mSenderPresenceView.setOnClickListener(this);
    mFavoriteIcon.setOnClickListener(this);
    findViewById(R.id.reply).setOnClickListener(this);
    findViewById(R.id.reply_all).setOnClickListener(this);
    findViewById(R.id.delete).setOnClickListener(this);
    findViewById(R.id.show_pictures).setOnClickListener(this);

    mMeetingYes = (TextView) findViewById(R.id.accept);
    mMeetingMaybe = (TextView) findViewById(R.id.maybe);
    mMeetingNo = (TextView) findViewById(R.id.decline);

    mMeetingYes.setOnClickListener(this);
    mMeetingMaybe.setOnClickListener(this);
    mMeetingNo.setOnClickListener(this);
    findViewById(R.id.invite_link).setOnClickListener(this);

    mMessageContentView.setVerticalScrollBarEnabled(false);
    mMessageContentView.getSettings().setBlockNetworkLoads(true);
    mMessageContentView.getSettings().setSupportZoom(false);
    mMessageContentView.setWebViewClient(new CustomWebViewClient());

    mProgressDialog = new ProgressDialog(this);
    mProgressDialog.setIndeterminate(true);
    mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);

    mDateFormat = android.text.format.DateFormat.getDateFormat(this); // short format
    mTimeFormat = android.text.format.DateFormat.getTimeFormat(this); // 12/24 date format

    mFavoriteIconOn = getResources().getDrawable(R.drawable.btn_star_big_buttonless_on);
    mFavoriteIconOff = getResources().getDrawable(R.drawable.btn_star_big_buttonless_off);

    initFromIntent();/*from w w  w . j  a v  a2s.c o  m*/
    if (icicle != null) {
        mMessageId = icicle.getLong(STATE_MESSAGE_ID, mMessageId);
    }

    mController = Controller.getInstance(getApplication());

    // This observer is used to watch for external changes to the message list
    mCursorObserver = new ContentObserver(mHandler) {
        @Override
        public void onChange(boolean selfChange) {
            // get a new message list cursor, but only if we already had one
            // (otherwise it's "too soon" and other pathways will cause it to be loaded)
            if (mLoadMessageListTask == null && mMessageListCursor != null) {
                mLoadMessageListTask = new LoadMessageListTask(mMailboxId);
                mLoadMessageListTask.execute();
            }
        }
    };

    messageChanged();
}

From source file:com.aimfire.demo.CameraActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    if (BuildConfig.DEBUG)
        Log.d(TAG, "create CameraActivity");

    checkPreferences();// w  w  w . ja v a2  s  .c  om

    /*
     *  keep the screen on until we turn off the flag 
     */
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_camera);

    /*
     * Obtain the FirebaseAnalytics instance.
     */
    mFirebaseAnalytics = FirebaseAnalytics.getInstance(this);

    /*
     * disable nfc push
     */
    NfcAdapter nfcAdapter = NfcAdapter.getDefaultAdapter(this);
    if (nfcAdapter != null)
        nfcAdapter.setNdefPushMessage(null, this);

    /*
     * get the natural orientation of this device. need to be called before
     * we fix the display orientation
     */
    mNaturalOrientation = getDeviceDefaultOrientation();

    /*
     * force CameraActivity in landscape because it is the natural 
     * orientation of the camera sensor
     */
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);

    mLandscapeOrientation = getDeviceLandscapeOrientation();

    Bundle extras = getIntent().getExtras();
    if (extras == null) {
        if (BuildConfig.DEBUG)
            Log.e(TAG, "onCreate: error create CameraActivity, wrong parameter");
        finish();
        return;
    }

    /*
     *  make sure we have camera
     */
    if (!checkCameraHardware(this)) {
        if (BuildConfig.DEBUG)
            Log.e(TAG, "onCreate: error create CameraActivity, cannot find camera!!!");
        finish();
        return;
    }

    mIsLeft = extras.getBoolean(MainConsts.EXTRA_ISLEFT);

    mView3DButton = (ImageButton) findViewById(R.id.view3D_button);
    mExitButton = (ImageButton) findViewById(R.id.exit_button);
    mCaptureButton = (ImageButton) findViewById(R.id.capture_button);
    mPvButton = (ImageButton) findViewById(R.id.switch_photo_video_button);
    mFbButton = (ImageButton) findViewById(R.id.switch_front_back_button);
    mLevelButton = (Button) findViewById(R.id.level_button);
    mModeButton = (ImageButton) findViewById(R.id.mode_button);

    if (mIsLeft) {
        mCaptureButton.setImageResource(R.drawable.ic_photo_camera_black_24dp);
    } else {
        mCaptureButton.setVisibility(View.INVISIBLE);

        mPvButton.setVisibility(View.INVISIBLE);
        mFbButton.setVisibility(View.INVISIBLE);
    }

    mView3DButton.setOnClickListener(oclView3D);
    mExitButton.setOnClickListener(oclExit);
    mPvButton.setOnClickListener(oclPV);
    mFbButton.setOnClickListener(oclFB);
    mCaptureButton.setOnClickListener(oclCapture);

    /*
     * we could get here in two ways: 1) directly after MainActivity ->
     * AimfireService sync with remote device. 2) we could get here 
     * because of a switch from video to photo mode. 
     * 
     * mSyncTimeUs is determined by AudioContext. each device 
     * calculates it, and they correspond to the same absolute moment 
     * in time
     */
    mSyncTimeUs = extras.getLong(MainConsts.EXTRA_SYNCTIME, -1);

    /*
     * start camera client object in a dedicated thread
     */
    mCameraClient = new CameraClient(Camera.CameraInfo.CAMERA_FACING_BACK, PHOTO_DIMENSION[0],
            PHOTO_DIMENSION[1]);

    /*
     * create our SurfaceView for preview 
     */
    mPreview = new CameraPreview(this);
    mPreviewLayout = (AspectFrameLayout) findViewById(R.id.cameraPreview_frame);
    mPreviewLayout.addView(mPreview);
    mPreviewLayout.setOnTouchListener(otl);
    if (BuildConfig.DEBUG)
        Log.d(TAG, "add camera preview view");

    mShutterSoundPlayer = MediaPlayer.create(this, Uri.parse("file:///system/media/audio/ui/camera_click.ogg"));

    /*
     * place UI controls at their initial, default orientation
     */
    adjustUIControls(0);

    /*
     * load the latest thumbnail to the view3D button
     */
    loadCurrThumbnail();

    /*
     * initializes AimfireService, and bind to it
     */
    mAimfireServiceConn = new AimfireServiceConn(this);

    /*
     * binding doesn't happen until later. wait for it to happen in another 
     * thread and connect to p2p peer if necessary
     */
    (new Thread(mAimfireServiceInitTask)).start();

    if (ADD_LOGO) {
        /*
         * init our logo that will be embedded in processed photos
         */
        AssetManager assetManager = getAssets();
        p.getInstance().a(assetManager, MainConsts.MEDIA_3D_RAW_PATH, "logo.png");
    }

    /*
     * register for AimfireService message broadcast
     */
    LocalBroadcastManager.getInstance(this).registerReceiver(mAimfireServiceMsgReceiver,
            new IntentFilter(MainConsts.AIMFIRE_SERVICE_MESSAGE));

    /*
     * register for intents sent by the media processor service
     */
    LocalBroadcastManager.getInstance(this).registerReceiver(mPhotoProcessorMsgReceiver,
            new IntentFilter(MainConsts.PHOTO_PROCESSOR_MESSAGE));
}

From source file:com.klinker.android.launcher.launcher3.Launcher.java

/**
 * Restores the previous state, if it exists.
 *
 * @param savedState The previous state.
 *//* w ww . j a  va 2 s.co  m*/
@SuppressWarnings("unchecked")
private void restoreState(Bundle savedState) {
    if (savedState == null) {
        return;
    }

    State state = intToState(savedState.getInt(RUNTIME_STATE, State.WORKSPACE.ordinal()));
    if (state == State.APPS || state == State.WIDGETS) {
        mOnResumeState = state;
    }

    int currentScreen = savedState.getInt(RUNTIME_STATE_CURRENT_SCREEN, PagedView.INVALID_RESTORE_PAGE);
    if (currentScreen != PagedView.INVALID_RESTORE_PAGE) {
        mWorkspace.setRestorePage(currentScreen);
    }

    final long pendingAddContainer = savedState.getLong(RUNTIME_STATE_PENDING_ADD_CONTAINER, -1);
    final long pendingAddScreen = savedState.getLong(RUNTIME_STATE_PENDING_ADD_SCREEN, -1);

    if (pendingAddContainer != ItemInfo.NO_ID && pendingAddScreen > -1) {
        mPendingAddInfo.container = pendingAddContainer;
        mPendingAddInfo.screenId = pendingAddScreen;
        mPendingAddInfo.cellX = savedState.getInt(RUNTIME_STATE_PENDING_ADD_CELL_X);
        mPendingAddInfo.cellY = savedState.getInt(RUNTIME_STATE_PENDING_ADD_CELL_Y);
        mPendingAddInfo.spanX = savedState.getInt(RUNTIME_STATE_PENDING_ADD_SPAN_X);
        mPendingAddInfo.spanY = savedState.getInt(RUNTIME_STATE_PENDING_ADD_SPAN_Y);
        AppWidgetProviderInfo info = savedState.getParcelable(RUNTIME_STATE_PENDING_ADD_WIDGET_INFO);
        mPendingAddWidgetInfo = info == null ? null
                : LauncherAppWidgetProviderInfo.fromProviderInfo(this, info);

        mPendingAddWidgetId = savedState.getInt(RUNTIME_STATE_PENDING_ADD_WIDGET_ID);
        setWaitingForResult(true);
        mRestoring = true;
    }

    mItemIdToViewId = (HashMap<Integer, Integer>) savedState.getSerializable(RUNTIME_STATE_VIEW_IDS);
}

From source file:com.android.soma.Launcher.java

/**
 * Restores the previous state, if it exists.
 *
 * @param savedState The previous state.
 *///from  ww w  . ja  va2 s  .c  o m
private void restoreState(Bundle savedState) {
    if (savedState == null) {
        return;
    }

    State state = intToState(savedState.getInt(RUNTIME_STATE, State.WORKSPACE.ordinal()));
    if (state == State.APPS_CUSTOMIZE) {
        mOnResumeState = State.APPS_CUSTOMIZE;
    }

    int currentScreen = savedState.getInt(RUNTIME_STATE_CURRENT_SCREEN, PagedView.INVALID_RESTORE_PAGE);
    if (currentScreen != PagedView.INVALID_RESTORE_PAGE) {
        mWorkspace.setRestorePage(currentScreen);
    }

    final long pendingAddContainer = savedState.getLong(RUNTIME_STATE_PENDING_ADD_CONTAINER, -1);
    final long pendingAddScreen = savedState.getLong(RUNTIME_STATE_PENDING_ADD_SCREEN, -1);

    if (pendingAddContainer != ItemInfo.NO_ID && pendingAddScreen > -1) {
        mPendingAddInfo.container = pendingAddContainer;
        mPendingAddInfo.screenId = pendingAddScreen;
        mPendingAddInfo.cellX = savedState.getInt(RUNTIME_STATE_PENDING_ADD_CELL_X);
        mPendingAddInfo.cellY = savedState.getInt(RUNTIME_STATE_PENDING_ADD_CELL_Y);
        mPendingAddInfo.spanX = savedState.getInt(RUNTIME_STATE_PENDING_ADD_SPAN_X);
        mPendingAddInfo.spanY = savedState.getInt(RUNTIME_STATE_PENDING_ADD_SPAN_Y);
        mPendingAddWidgetInfo = savedState.getParcelable(RUNTIME_STATE_PENDING_ADD_WIDGET_INFO);
        mWaitingForResult = true;
        mRestoring = true;
    }

    boolean renameFolder = savedState.getBoolean(RUNTIME_STATE_PENDING_FOLDER_RENAME, false);
    if (renameFolder) {
        long id = savedState.getLong(RUNTIME_STATE_PENDING_FOLDER_RENAME_ID);
        mFolderInfo = mModel.getFolderById(this, sFolders, id);
        mRestoring = true;
    }

    // Restore the AppsCustomize tab
    if (mAppsCustomizeTabHost != null) {
        String curTab = savedState.getString("apps_customize_currentTab");
        if (curTab != null) {
            mAppsCustomizeTabHost
                    .setContentTypeImmediate(mAppsCustomizeTabHost.getContentTypeForTabTag(curTab));
            mAppsCustomizeContent.loadAssociatedPages(mAppsCustomizeContent.getCurrentPage());
        }

        int currentIndex = savedState.getInt("apps_customize_currentIndex");
        mAppsCustomizeContent.restorePageForIndex(currentIndex);
    }
}