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.vegnab.vegnab.MainVNActivity.java

@Override
public void onExportVisitRequest(Bundle paramsBundle) {
    mVisitIdToExport = paramsBundle.getLong(ARG_VISIT_TO_EXPORT_ID);
    if (LDebug.ON)
        Log.d(LOG_TAG, "mVisitIdToExport received in 'onExportVisitRequest' = " + mVisitIdToExport);
    // ARG_VISIT_TO_EXPORT_NAME); // currently unused
    // get filename, either default or overridden in Confirm dialog
    mExportFileName = paramsBundle.getString(ARG_VISIT_TO_EXPORT_FILENAME);
    if (LDebug.ON)
        Log.d(LOG_TAG, "mExportFileName received in 'onExportVisitRequest': " + mExportFileName);
    mResolvePlaceholders = paramsBundle.getBoolean(ARG_RESOLVE_PLACEHOLDERS, true);
    mConnectionRequested = true;/*from   w w w  . j  a v a 2  s .  co m*/
    buildGoogleApiClient();
    mGoogleApiClient.connect();
    // create new contents resource
    Drive.DriveApi.newDriveContents(getGoogleApiClient()).setResultCallback(driveContentsCallback);
    // file is actually created by a callback, search in this code for:
    // ResultCallback<DriveContentsResult> driveContentsCallback
}

From source file:de.tobiasbielefeld.solitaire.dialogs.DialogWon.java

@Override
@NonNull/* w ww  .j  av  a  2 s . c  o m*/
public Dialog onCreateDialog(Bundle savedState) {
    final GameManager gameManager = (GameManager) getActivity();
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());

    LayoutInflater inflater = getActivity().getLayoutInflater();
    View view = inflater.inflate(R.layout.dialog_won, null);

    builder.setCustomTitle(view).setItems(R.array.won_menu, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            // "which" argument contains index of selected item
            switch (which) {
            case 0:
                gameLogic.newGame();
                break;
            case 1:
                gameLogic.redeal();
                break;
            case 2:
                if (gameManager.hasLoaded) {
                    timer.save();
                    gameLogic.setWonAndReloaded();
                    gameLogic.save();
                }

                gameManager.finish();
                break;
            }
        }
    }).setNegativeButton(R.string.game_cancel, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            //just cancel
        }
    });

    LinearLayout layoutScores = (LinearLayout) view.findViewById(R.id.dialog_won_layout_scores);

    //only show the calculation of the score if bonus is enabled
    if (currentGame.isBonusEnabled()) {
        layoutScores.setVisibility(View.VISIBLE);
        TextView text1 = (TextView) view.findViewById(R.id.dialog_won_text1);
        TextView text2 = (TextView) view.findViewById(R.id.dialog_won_text2);
        TextView text3 = (TextView) view.findViewById(R.id.dialog_won_text3);

        score = (savedState != null && savedState.containsKey(KEY_SCORE)) ? savedState.getLong(KEY_SCORE)
                : scores.getPreBonus();
        bonus = (savedState != null && savedState.containsKey(KEY_BONUS)) ? savedState.getLong(KEY_BONUS)
                : scores.getBonus();
        total = (savedState != null && savedState.containsKey(KEY_TOTAL)) ? savedState.getLong(KEY_TOTAL)
                : scores.getScore();

        text1.setText(
                String.format(Locale.getDefault(), getContext().getString(R.string.dialog_win_score), score));
        text2.setText(
                String.format(Locale.getDefault(), getContext().getString(R.string.dialog_win_bonus), bonus));
        text3.setText(
                String.format(Locale.getDefault(), getContext().getString(R.string.dialog_win_total), total));
    } else {
        layoutScores.setVisibility(View.GONE);
    }

    return applyFlags(builder.create());
}

From source file:com.vegnab.vegnab.MainVNActivity.java

public void onUnHideVisitConfirm(DialogFragment dialog) {
    if (LDebug.ON)
        Log.d(LOG_TAG, "onUnHideVisitConfirm(DialogFragment dialog)");
    Bundle args = dialog.getArguments();
    long recIdToUnhide = args.getLong(UnHideVisitDialog.ARG_VISIT_ID_TO_UNHIDE);
    NewVisitFragment nvFrag = (NewVisitFragment) getSupportFragmentManager().findFragmentByTag(Tags.NEW_VISIT);
    nvFrag.setVisitVisibility(recIdToUnhide, true); // fn refreshes lists
}

From source file:com.heightechllc.breakify.MainActivity.java

/**
 * Skips to the next timer state//from   ww  w  . j a v  a2 s . c o  m
 */
private void skipToNextState() {
    int oldWorkState = getWorkState();
    // Record the state we're about to skip from, in case the user chooses to undo
    Bundle undoStateBundle = new Bundle();
    undoStateBundle.putLong("totalTime", circleTimer.getTotalTime());
    undoStateBundle.putLong("remainingTime", circleTimer.getRemainingTime());
    undoStateBundle.putInt("workState", oldWorkState);

    String toastMessage = getString(R.string.skip_toast);
    // Get duration from preferences, in minutes
    long duration;
    if (oldWorkState == WORK_STATE_WORKING) {
        // Means we're skipping to break
        duration = sharedPref.getInt(TimerDurationsSettingsFragment.KEY_BREAK_DURATION, 0);
        toastMessage += " break";
    } else {
        // Means we're skipping to work
        duration = sharedPref.getInt(TimerDurationsSettingsFragment.KEY_WORK_DURATION, 0);
        toastMessage += " work";
    }

    // Create and show the undo bar
    showUndoBar(toastMessage, undoStateBundle, new UndoBarController.UndoListener() {
        @Override
        public void onUndo(Parcelable parcelable) {
            if (parcelable == null)
                return;

            // Extract the saved state from the Parcelable
            Bundle undoStateBundle = (Bundle) parcelable;
            long prevTotalTime = undoStateBundle.getLong("totalTime");
            long prevRemainingTime = undoStateBundle.getLong("remainingTime");
            int prevWorkState = undoStateBundle.getInt("workState");

            // Cause startTimer() to treat it like we're resuming (b/c we are)
            timerState = TIMER_STATE_PAUSED;
            setWorkState(prevWorkState);
            // Restore to the previous timer state, similar to how we restore a
            //  running timer from SharedPreferences in onCreate()
            circleTimer.setTotalTime(prevTotalTime);
            circleTimer.updateTimeLbl(prevRemainingTime);
            // Record the total duration, so we can resume if the activity is destroyed
            sharedPref.edit().putLong("schedTotalTime", prevTotalTime).apply();
            startTimer(prevRemainingTime);
            // Analytics
            if (mixpanel != null)
                mixpanel.track("Skip undone", null);
        }
    });

    // Set the new state
    if (oldWorkState == WORK_STATE_WORKING)
        setWorkState(WORK_STATE_BREAKING);
    else
        setWorkState(WORK_STATE_WORKING);

    // We want to start the timer from scratch, not from a paused state
    timerState = TIMER_STATE_STOPPED;
    // Start the timer
    startTimer(duration * 60000); // Multiply into milliseconds

    // Analytics
    if (mixpanel != null) {
        JSONObject props = new JSONObject();
        try {
            props.put("Duration", duration);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        String eventName = getWorkState() == WORK_STATE_WORKING ? "Skipped to work" : "Skipped to break";
        mixpanel.track(eventName, props);
    }
}

From source file:com.vegnab.vegnab.MainVNActivity.java

public void onDeleteVegItemConfirm(DialogFragment dialog) {
    if (LDebug.ON)
        Log.d(LOG_TAG, "onDeleteVegItemConfirm(DialogFragment dialog)");
    Bundle args = dialog.getArguments();
    long recIdToDelete = args.getLong(ConfirmDelVegItemDialog.ARG_VI_REC_ID);
    DataEntryContainerFragment dataEntryFrag = (DataEntryContainerFragment) getSupportFragmentManager()
            .findFragmentByTag(Tags.DATA_SCREENS_CONTAINER);

    int index = dataEntryFrag.mDataScreenPager.getCurrentItem();
    DataEntryContainerFragment.dataPagerAdapter ad = ((DataEntryContainerFragment.dataPagerAdapter) dataEntryFrag.mDataScreenPager
            .getAdapter());/*from w  w  w .  jav  a  2  s  . c o  m*/
    Fragment f = ad.getFragment(index);
    // fix this up when AuxData implemented, to make sure the class of fragment
    try {
        VegSubplotFragment vf = (VegSubplotFragment) f;
        vf.deleteVegItem(recIdToDelete);
    } catch (ClassCastException e) {
        // if not the right class of fragment, fail silently
    }
}

From source file:com.todoroo.astrid.ui.HideUntilControlSet.java

@Nullable
@Override/* w  w w .  j  av  a2  s .  co  m*/
public View onCreateView(final LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = super.onCreateView(inflater, container, savedInstanceState);
    adapter = new HiddenTopArrayAdapter<HideUntilValue>(context, android.R.layout.simple_spinner_item,
            spinnerItems) {
        @NonNull
        @Override
        public View getView(int position, View convertView, @NonNull ViewGroup parent) {
            int selectedItemPosition = position;
            if (parent instanceof AdapterView) {
                selectedItemPosition = ((AdapterView) parent).getSelectedItemPosition();
            }
            TextView tv = (TextView) inflater.inflate(android.R.layout.simple_spinner_item, parent, false);
            tv.setPadding(0, 0, 0, 0);
            HideUntilValue value = getItem(selectedItemPosition);
            if (value.setting == Task.HIDE_UNTIL_NONE) {
                clearButton.setVisibility(View.GONE);
                tv.setText(value.label);
                tv.setTextColor(getColor(context, R.color.text_tertiary));
            } else {
                String display = value.label;
                if (value.setting != Task.HIDE_UNTIL_SPECIFIC_DAY
                        && value.setting != Task.HIDE_UNTIL_SPECIFIC_DAY_TIME) {
                    display = display.toLowerCase();
                }
                tv.setText(getString(R.string.TEA_hideUntil_display, display));
                tv.setTextColor(getColor(context, R.color.text_primary));
            }
            return tv;
        }
    };
    if (savedInstanceState == null) {
        updateSpinnerOptions(initialHideUntil);
    } else {
        updateSpinnerOptions(savedInstanceState.getLong(EXTRA_CUSTOM));
        selection = savedInstanceState.getInt(EXTRA_SELECTION);
    }
    spinner.setAdapter(adapter);
    spinner.setSelection(selection);
    spinner.setOnItemSelectedListener(this);
    refreshDisplayView();
    return view;
}

From source file:cl.ipp.katbag.fragment.Develop.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    mainActivity = (MainActivity) super.getActivity();
    v = inflater.inflate(R.layout.fragment_develop, container, false);

    // rescues parameters
    Bundle bundle = getArguments();
    if (bundle != null) {
        id_app = bundle.getLong("id_app");
    }/*from  w  w  w . j  a  v  a  2 s.c o  m*/

    notRegister = (TextView) v.findViewById(R.id.develop_not_register);
    editMode = false;
    loadListView();

    developListView.setOnItemLongClickListener(new OnItemLongClickListener() {

        @Override
        public boolean onItemLongClick(AdapterView<?> arg0, View view, int position, long id) {
            if (!editMode) {
                dev.clear();
                dev = mainActivity.katbagHandler
                        .selectDevelopForId(Long.parseLong(adapter.items.get(position)));

                dialogIdObjectList.clear();
                dialogHumanStatement.clear();
                dialogHumanStatementRow.clear();

                if (dev.get(0).contentEquals("world")) {
                    showAlertDialog(OBJECT_WORLD, Long.parseLong(adapter.items.get(position)));

                } else if (dev.get(0).contentEquals("drawing")) {
                    showAlertDialog(OBJECT_DRAWING, Long.parseLong(adapter.items.get(position)));

                } else if (dev.get(0).contentEquals("motion")) {
                    dialogIdObjectList = new ArrayList<String>(
                            Arrays.asList(getResources().getStringArray(R.array.motion_id)));
                    dialogHumanStatement = new ArrayList<String>(
                            Arrays.asList(getResources().getStringArray(R.array.motion_name)));
                    dialogHumanStatementRow = new ArrayList<String>(
                            Arrays.asList(getResources().getStringArray(R.array.motion_row)));

                    setMotion(
                            getString(R.string.dialog_title_select) + " "
                                    + getString(R.string.develop_dropdown_menu_add_motion),
                            dialogHumanStatementRow.get(Integer.parseInt(dev.get(2))),
                            Integer.parseInt(dialogIdObjectList.get(Integer.parseInt(dev.get(2)))),
                            Long.parseLong(adapter.items.get(position)));

                } else if (dev.get(0).contentEquals("look")) {
                    dialogIdObjectList = new ArrayList<String>(
                            Arrays.asList(getResources().getStringArray(R.array.look_id)));
                    dialogHumanStatement = new ArrayList<String>(
                            Arrays.asList(getResources().getStringArray(R.array.look_name)));
                    dialogHumanStatementRow = new ArrayList<String>(
                            Arrays.asList(getResources().getStringArray(R.array.look_row)));

                    setLook(getString(R.string.dialog_title_select) + " "
                            + getString(R.string.develop_dropdown_menu_add_look),
                            dialogHumanStatementRow.get(Integer.parseInt(dev.get(2))),
                            Integer.parseInt(dialogIdObjectList.get(Integer.parseInt(dev.get(2)))),
                            Long.parseLong(adapter.items.get(position)));

                } else if (dev.get(0).contentEquals("sound")) {
                    dialogIdObjectList = new ArrayList<String>(
                            Arrays.asList(getResources().getStringArray(R.array.sound_id)));
                    dialogHumanStatement = new ArrayList<String>(
                            Arrays.asList(getResources().getStringArray(R.array.sound_name)));
                    dialogHumanStatementRow = new ArrayList<String>(
                            Arrays.asList(getResources().getStringArray(R.array.sound_row)));

                    setSound(
                            getString(R.string.dialog_title_select) + " "
                                    + getString(R.string.develop_dropdown_menu_add_sound),
                            dialogHumanStatementRow.get(Integer.parseInt(dev.get(2))),
                            Integer.parseInt(dialogIdObjectList.get(Integer.parseInt(dev.get(2)))),
                            Long.parseLong(adapter.items.get(position)));

                } else if (dev.get(0).contentEquals("control")) {
                    dialogIdObjectList = new ArrayList<String>(
                            Arrays.asList(getResources().getStringArray(R.array.control_id)));
                    dialogHumanStatement = new ArrayList<String>(
                            Arrays.asList(getResources().getStringArray(R.array.control_name)));
                    dialogHumanStatementRow = new ArrayList<String>(
                            Arrays.asList(getResources().getStringArray(R.array.control_row)));

                    setControl(
                            getString(R.string.dialog_title_select) + " "
                                    + getString(R.string.develop_dropdown_menu_add_control),
                            dialogHumanStatementRow.get(Integer.parseInt(dev.get(2))),
                            Integer.parseInt(dialogIdObjectList.get(Integer.parseInt(dev.get(2)))),
                            Long.parseLong(adapter.items.get(position)));

                } else if (dev.get(0).contentEquals("sensing")) {
                    dialogIdObjectList = new ArrayList<String>(
                            Arrays.asList(getResources().getStringArray(R.array.sensing_id)));
                    dialogHumanStatement = new ArrayList<String>(
                            Arrays.asList(getResources().getStringArray(R.array.sensing_name)));
                    dialogHumanStatementRow = new ArrayList<String>(
                            Arrays.asList(getResources().getStringArray(R.array.sensing_row)));

                    setSensing(
                            getString(R.string.dialog_title_select) + " "
                                    + getString(R.string.develop_dropdown_menu_add_sensing),
                            dialogHumanStatementRow.get(Integer.parseInt(dev.get(2))),
                            Integer.parseInt(dialogIdObjectList.get(Integer.parseInt(dev.get(2)))),
                            Long.parseLong(adapter.items.get(position)));
                }

                return true;
            } else
                return false;
        }
    });

    developListView.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> arg0, View view, int position, long id) {
            indentCode(position);
            loadListView();
        }
    });

    return v;
}

From source file:com.android.deskclock.AlarmClockFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedState) {
    // Inflate the layout for this fragment
    final View v = inflater.inflate(R.layout.alarm_clock, container, false);

    long expandedId = INVALID_ID;
    long[] repeatCheckedIds = null;
    long[] selectedAlarms = null;
    Bundle previousDayMap = null;/*from w  ww .j  av a 2 s  . co  m*/
    if (savedState != null) {
        expandedId = savedState.getLong(KEY_EXPANDED_ID);
        repeatCheckedIds = savedState.getLongArray(KEY_REPEAT_CHECKED_IDS);
        mRingtoneTitleCache = savedState.getBundle(KEY_RINGTONE_TITLE_CACHE);
        mDeletedAlarm = savedState.getParcelable(KEY_DELETED_ALARM);
        mUndoShowing = savedState.getBoolean(KEY_UNDO_SHOWING);
        selectedAlarms = savedState.getLongArray(KEY_SELECTED_ALARMS);
        previousDayMap = savedState.getBundle(KEY_PREVIOUS_DAY_MAP);
        mSelectedAlarm = savedState.getParcelable(KEY_SELECTED_ALARM);
    }

    mExpandInterpolator = new DecelerateInterpolator(EXPAND_DECELERATION);
    mCollapseInterpolator = new DecelerateInterpolator(COLLAPSE_DECELERATION);

    if (USE_TRANSITION_FRAMEWORK) {
        mAddRemoveTransition = new AutoTransition();
        mAddRemoveTransition.setDuration(ANIMATION_DURATION);

        /// M: Scrap the views in ListView and request layout again, then alarm item will be
        /// attached correctly. This is to avoid the case when some items are not correctly
        ///  attached after animation end  @{
        mAddRemoveTransition.addListener(new Transition.TransitionListenerAdapter() {
            @Override
            public void onTransitionEnd(Transition transition) {
                mAlarmsList.clearScrapViewsIfNeeded();
            }
        });
        /// @}

        mRepeatTransition = new AutoTransition();
        mRepeatTransition.setDuration(ANIMATION_DURATION / 2);
        mRepeatTransition.setInterpolator(new AccelerateDecelerateInterpolator());

        mEmptyViewTransition = new TransitionSet().setOrdering(TransitionSet.ORDERING_SEQUENTIAL)
                .addTransition(new Fade(Fade.OUT)).addTransition(new Fade(Fade.IN))
                .setDuration(ANIMATION_DURATION);
    }

    boolean isLandscape = getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE;
    View menuButton = v.findViewById(R.id.menu_button);
    if (menuButton != null) {
        if (isLandscape) {
            menuButton.setVisibility(View.GONE);
        } else {
            menuButton.setVisibility(View.VISIBLE);
            setupFakeOverflowMenuButton(menuButton);
        }
    }

    mEmptyView = v.findViewById(R.id.alarms_empty_view);

    mMainLayout = (FrameLayout) v.findViewById(R.id.main);
    mAlarmsList = (ListView) v.findViewById(R.id.alarms_list);

    mUndoBar = (ActionableToastBar) v.findViewById(R.id.undo_bar);
    mUndoFrame = v.findViewById(R.id.undo_frame);
    mUndoFrame.setOnTouchListener(this);

    mFooterView = v.findViewById(R.id.alarms_footer_view);
    mFooterView.setOnTouchListener(this);

    mAdapter = new AlarmItemAdapter(getActivity(), expandedId, repeatCheckedIds, selectedAlarms, previousDayMap,
            mAlarmsList);
    mAdapter.registerDataSetObserver(new DataSetObserver() {

        private int prevAdapterCount = -1;

        @Override
        public void onChanged() {

            final int count = mAdapter.getCount();
            if (mDeletedAlarm != null && prevAdapterCount > count) {
                showUndoBar();
            }

            if (USE_TRANSITION_FRAMEWORK && ((count == 0 && prevAdapterCount > 0) || /* should fade  in */
            (count > 0 && prevAdapterCount == 0) /* should fade out */)) {
                TransitionManager.beginDelayedTransition(mMainLayout, mEmptyViewTransition);
            }
            mEmptyView.setVisibility(count == 0 ? View.VISIBLE : View.GONE);

            // Cache this adapter's count for when the adapter changes.
            prevAdapterCount = count;
            super.onChanged();
        }
    });

    if (mRingtoneTitleCache == null) {
        mRingtoneTitleCache = new Bundle();
    }

    mAlarmsList.setAdapter(mAdapter);
    mAlarmsList.setVerticalScrollBarEnabled(true);
    mAlarmsList.setOnCreateContextMenuListener(this);

    if (mUndoShowing) {
        showUndoBar();
    }
    return v;
}

From source file:com.heightechllc.breakify.MainActivity.java

/**
 * Resets the CircleTimerView and reverts the Activity's UI to its initial state
 * @param isTimerComplete Whether the timer is complete
 *//*from w  w w.  j a  va2s .com*/
private void resetTimerUI(boolean isTimerComplete) {
    timerState = TIMER_STATE_STOPPED;

    // Reset the UI
    timeLbl.clearAnimation();
    stateLbl.clearAnimation();
    resetBtn.setVisibility(View.GONE);
    skipBtn.setVisibility(View.GONE);
    timeLbl.setText("");

    // Record the state we're about to reset from, in case the user chooses to undo
    Bundle undoStateBundle = new Bundle();
    if (isTimerComplete) {
        undoStateBundle.putLong("totalTime", 0);
        undoStateBundle.putLong("remainingTime", 0);
    } else {
        undoStateBundle.putLong("totalTime", circleTimer.getTotalTime());
        undoStateBundle.putLong("remainingTime", circleTimer.getRemainingTime());
    }
    undoStateBundle.putInt("workState", getWorkState());

    // Back to initial state
    setWorkState(WORK_STATE_WORKING);

    // Update the start / stop label
    startStopLbl.setText(R.string.start);
    startStopLbl.setVisibility(View.VISIBLE);

    circleTimer.stopIntervalAnimation();
    circleTimer.invalidate();

    // Remove record of total timer duration and the time remaining for the paused timer
    sharedPref.edit().remove("schedTotalTime").remove("pausedTimeRemaining").apply();

    // Create and show the undo bar
    showUndoBar(getString(R.string.reset_toast), undoStateBundle, new UndoBarController.UndoListener() {
        @Override
        public void onUndo(Parcelable parcelable) {
            if (parcelable == null)
                return;

            // Extract the saved state from the Parcelable
            Bundle undoStateBundle = (Bundle) parcelable;
            long prevTotalTime = undoStateBundle.getLong("totalTime");
            long prevRemainingTime = undoStateBundle.getLong("remainingTime");
            int prevWorkState = undoStateBundle.getInt("workState");
            if (prevTotalTime > 0 && prevRemainingTime > 0) {
                // Cause startTimer() to treat it like we're resuming (b/c we are)
                timerState = TIMER_STATE_PAUSED;
                setWorkState(prevWorkState);
                // Restore to the previous timer state, similar to how we restore a
                //  running timer from SharedPreferences in onCreate()
                circleTimer.setTotalTime(prevTotalTime);
                circleTimer.updateTimeLbl(prevRemainingTime);
                // Record the total duration, so we can resume if the activity is destroyed
                sharedPref.edit().putLong("schedTotalTime", prevTotalTime).apply();
                startTimer(prevRemainingTime);
            } else {
                // Means the timer was complete when resetTimerUI() was called, so we
                //  need to start the timer from the beginning of the next state
                if (prevWorkState == WORK_STATE_WORKING)
                    setWorkState(WORK_STATE_BREAKING);
                else
                    setWorkState(WORK_STATE_WORKING);
                startTimer();
            }
            // Analytics
            if (mixpanel != null)
                mixpanel.track("Timer reset undone", null);
        }
    });
}

From source file:com.saulcintero.moveon.fragments.Main.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    act = getActivity();//from   ww w.  j  a  v  a 2  s  .  c o m
    mContext = act.getApplicationContext();
    res = mContext.getResources();

    prefs = PreferenceManager.getDefaultSharedPreferences(mContext);

    mDistance = mContext.getString(R.string.zero_with_two_decimal_places_value);
    launchPractice = false;
    paintedPath = new ArrayList<GeoPoint>();
    centerPoint = null;

    if (savedInstanceState != null) {
        chronoBaseValue = savedInstanceState.getLong("chronoBase");
        stopStatus = savedInstanceState.getInt("stopStatus");
        pauseOrResumeStatus = savedInstanceState.getInt("pauseOrResumeStatus");
        activity = savedInstanceState.getInt("activity");
        ACTIVITY_CAMERA = savedInstanceState.getInt("activityCamera");
        pictureCounter = savedInstanceState.getInt("pictureCounter");
        zoom = savedInstanceState.getInt("zoom");
        gpsStatus = savedInstanceState.getString("gpsStatus");
        gpsAccuracy = savedInstanceState.getString("gpsAccuracy");
        mDistance = savedInstanceState.getString("distance");
        mSpeed = savedInstanceState.getString("speed");
        mMaxSpeed = savedInstanceState.getString("maxSpeed");
        mLatitude = savedInstanceState.getString("latitude");
        mLongitude = savedInstanceState.getString("longitude");
        mAltitude = savedInstanceState.getString("altitude");
        mSteps = savedInstanceState.getString("steps");
        mHeartRate = savedInstanceState.getString("hr");
        mCadence = savedInstanceState.getString("cadence");
        path = savedInstanceState.getString("path");
        file = savedInstanceState.getString("file");
        pathOverlayChangeColor = savedInstanceState.getBoolean("pathOverlayChangeColor");
        launchPractice = savedInstanceState.getBoolean("launchPractice");
        isExpanded = savedInstanceState.getBoolean("isExpanded");
        followLocation = savedInstanceState.getBoolean("followLocation");
        hasBeenResumed = savedInstanceState.getBoolean("hasBeenResumed");
        isMetric = savedInstanceState.getBoolean("isMetric");
        latCenterPoint = savedInstanceState.getDouble("latCenterPoint");
        lonCenterPoint = savedInstanceState.getDouble("lonCenterPoint");

        centerPoint = new GeoPoint(latCenterPoint, lonCenterPoint);
    }
}