Example usage for android.os Bundle getSerializable

List of usage examples for android.os Bundle getSerializable

Introduction

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

Prototype

@Override
@Nullable
public Serializable getSerializable(@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.mojtaba.materialdatetimepicker.date.DatePickerDialog.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    Log.d(TAG, "onCreateView: ");
    getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE);

    View view = inflater.inflate(R.layout.mdtp_date_picker_dialog, null);

    mDayOfWeekView = (TextView) view.findViewById(R.id.date_picker_header);
    mMonthAndDayView = (LinearLayout) view.findViewById(R.id.date_picker_month_and_day);
    mMonthAndDayView.setOnClickListener(this);
    mSelectedMonthTextView = (TextView) view.findViewById(R.id.date_picker_month);
    mSelectedDayTextView = (TextView) view.findViewById(R.id.date_picker_day);
    mYearView = (TextView) view.findViewById(R.id.date_picker_year);
    mYearView.setOnClickListener(this);

    int listPosition = -1;
    int listPositionOffset = 0;
    int currentView = MONTH_AND_DAY_VIEW;
    if (savedInstanceState != null) {
        mWeekStart = savedInstanceState.getInt(KEY_WEEK_START);
        mMinYear = savedInstanceState.getInt(KEY_YEAR_START);
        mMaxYear = savedInstanceState.getInt(KEY_YEAR_END);
        currentView = savedInstanceState.getInt(KEY_CURRENT_VIEW);
        listPosition = savedInstanceState.getInt(KEY_LIST_POSITION);
        listPositionOffset = savedInstanceState.getInt(KEY_LIST_POSITION_OFFSET);
        mMinDate = (PersianCalendar) savedInstanceState.getSerializable(KEY_MIN_DATE);
        mMaxDate = (PersianCalendar) savedInstanceState.getSerializable(KEY_MAX_DATE);
        highlightedDays = (PersianCalendar[]) savedInstanceState.getSerializable(KEY_HIGHLIGHTED_DAYS);
        selectableDays = (PersianCalendar[]) savedInstanceState.getSerializable(KEY_SELECTABLE_DAYS);
        mThemeDark = savedInstanceState.getBoolean(KEY_THEME_DARK);
        mThemeDarkChanged = savedInstanceState.getBoolean(KEY_THEME_DARK_CHANGED);
        mAccentColor = savedInstanceState.getInt(KEY_ACCENT);
        mVibrate = savedInstanceState.getBoolean(KEY_VIBRATE);
        mDismissOnPause = savedInstanceState.getBoolean(KEY_DISMISS);
        mAutoDismiss = savedInstanceState.getBoolean(KEY_AUTO_DISMISS);
        mTitle = savedInstanceState.getString(KEY_TITLE);
        mOkResid = savedInstanceState.getInt(KEY_OK_RESID);
        mOkString = savedInstanceState.getString(KEY_OK_STRING);
        mCancelResid = savedInstanceState.getInt(KEY_CANCEL_RESID);
        mCancelString = savedInstanceState.getString(KEY_CANCEL_STRING);
    }/*from w  w  w .  j av  a2  s.c  o  m*/

    final Activity activity = getActivity();
    mDayPickerView = new SimpleDayPickerView(activity, this);
    mYearPickerView = new YearPickerView(activity, this);

    // if theme mode has not been set by java code, check if it is specified in Style.xml
    if (!mThemeDarkChanged) {
        mThemeDark = Utils.isDarkTheme(activity, mThemeDark);
    }

    Resources res = getResources();
    mDayPickerDescription = res.getString(R.string.mdtp_day_picker_description);
    mSelectDay = res.getString(R.string.mdtp_select_day);
    mYearPickerDescription = res.getString(R.string.mdtp_year_picker_description);
    mSelectYear = res.getString(R.string.mdtp_select_year);

    int bgColorResource = mThemeDark ? R.color.mdtp_date_picker_view_animator_dark_theme
            : R.color.mdtp_date_picker_view_animator;
    view.setBackgroundColor(ContextCompat.getColor(activity, bgColorResource));

    mAnimator = (AccessibleDateAnimator) view.findViewById(R.id.animator);
    mAnimator.addView(mDayPickerView);
    mAnimator.addView(mYearPickerView);
    mAnimator.setDateMillis(mPersianCalendar.getTimeInMillis());
    // TODO: Replace with animation decided upon by the design team.
    Animation animation = new AlphaAnimation(0.0f, 1.0f);
    animation.setDuration(ANIMATION_DURATION);
    mAnimator.setInAnimation(animation);
    // TODO: Replace with animation decided upon by the design team.
    Animation animation2 = new AlphaAnimation(1.0f, 0.0f);
    animation2.setDuration(ANIMATION_DURATION);
    mAnimator.setOutAnimation(animation2);

    Button okButton = (Button) view.findViewById(R.id.ok);
    okButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            tryVibrate();
            if (mCallBack != null) {
                mCallBack.onDateSet(DatePickerDialog.this, mPersianCalendar.getPersianYear(),
                        mPersianCalendar.getPersianMonth(), mPersianCalendar.getPersianDay());
            }
            dismiss();
        }
    });
    okButton.setTypeface(TypefaceHelper.get(activity, "Roboto-Medium"));
    if (mOkString != null)
        okButton.setText(mOkString);
    else
        okButton.setText(mOkResid);

    Button cancelButton = (Button) view.findViewById(R.id.cancel);
    cancelButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            tryVibrate();
            if (getDialog() != null)
                getDialog().cancel();
        }
    });
    cancelButton.setTypeface(TypefaceHelper.get(activity, "Roboto-Medium"));
    if (mCancelString != null)
        cancelButton.setText(mCancelString);
    else
        cancelButton.setText(mCancelResid);
    cancelButton.setVisibility(isCancelable() ? View.VISIBLE : View.GONE);

    // If an accent color has not been set manually, get it from the context
    if (mAccentColor == -1) {
        mAccentColor = Utils.getAccentColorFromThemeIfAvailable(getActivity());
    }
    if (mDayOfWeekView != null)
        mDayOfWeekView.setBackgroundColor(Utils.darkenColor(mAccentColor));
    view.findViewById(R.id.day_picker_selected_date_layout).setBackgroundColor(mAccentColor);
    okButton.setTextColor(mAccentColor);
    cancelButton.setTextColor(mAccentColor);

    if (getDialog() == null) {
        view.findViewById(R.id.done_background).setVisibility(View.GONE);
    }

    updateDisplay(false);
    setCurrentView(currentView);

    if (listPosition != -1) {
        if (currentView == MONTH_AND_DAY_VIEW) {
            mDayPickerView.postSetSelection(listPosition);
        } else if (currentView == YEAR_VIEW) {
            mYearPickerView.postSetSelectionFromTop(listPosition, listPositionOffset);
        }
    }

    mHapticFeedbackController = new HapticFeedbackController(activity);
    return view;
}

From source file:com.android.deskclock.timer.TimerFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final View view = inflater.inflate(R.layout.timer_fragment, container, false);

    mAdapter = new TimerPagerAdapter(getChildFragmentManager());
    mViewPager = (ViewPager) view.findViewById(R.id.vertical_view_pager);
    mViewPager.setAdapter(mAdapter);//from  w ww  .j av a 2 s.  c  o  m
    mViewPager.addOnPageChangeListener(mTimerPageChangeListener);

    mTimersView = view.findViewById(R.id.timer_view);
    mCreateTimerView = (TimerSetupView) view.findViewById(R.id.timer_setup);
    mPageIndicators = new ImageView[] { (ImageView) view.findViewById(R.id.page_indicator0),
            (ImageView) view.findViewById(R.id.page_indicator1),
            (ImageView) view.findViewById(R.id.page_indicator2),
            (ImageView) view.findViewById(R.id.page_indicator3) };
    mCancelCreateButton = (ImageButton) view.findViewById(R.id.timer_cancel);
    mCancelCreateButton.setOnClickListener(new CancelCreateListener());

    view.findViewById(R.id.timer_create).setOnClickListener(new CreateListener());

    final Resources resources = getResources();
    mShortAnimationDuration = resources.getInteger(android.R.integer.config_shortAnimTime);
    mMediumAnimationDuration = resources.getInteger(android.R.integer.config_mediumAnimTime);

    DataModel.getDataModel().addTimerListener(mAdapter);
    DataModel.getDataModel().addTimerListener(mTimerWatcher);

    // If timer setup state is present, retrieve it to be later honored.
    if (savedInstanceState != null) {
        mTimerSetupState = savedInstanceState.getSerializable(KEY_TIMER_SETUP_STATE);
    }

    return view;
}

From source file:com.onyx.deskclock.deskclock.timer.TimerFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final View view = inflater.inflate(R.layout.timer_fragment, container, false);

    mAdapter = new TimerPagerAdapter(getFragmentManager());
    mViewPager = (ViewPager) view.findViewById(R.id.vertical_view_pager);
    mViewPager.setAdapter(mAdapter);//from  w  w  w .  j  a va  2  s  .  com
    mViewPager.addOnPageChangeListener(mTimerPageChangeListener);

    mTimersView = view.findViewById(R.id.timer_view);
    mCreateTimerView = (TimerSetupView) view.findViewById(R.id.timer_setup);
    mPageIndicators = new ImageView[] { (ImageView) view.findViewById(R.id.page_indicator0),
            (ImageView) view.findViewById(R.id.page_indicator1),
            (ImageView) view.findViewById(R.id.page_indicator2),
            (ImageView) view.findViewById(R.id.page_indicator3) };
    mCancelCreateButton = (ImageButton) view.findViewById(R.id.timer_cancel);
    mCancelCreateButton.setOnClickListener(new CancelCreateListener());

    view.findViewById(R.id.timer_create).setOnClickListener(new CreateListener());

    final Resources resources = getResources();
    mShortAnimationDuration = resources.getInteger(android.R.integer.config_shortAnimTime);
    mMediumAnimationDuration = resources.getInteger(android.R.integer.config_mediumAnimTime);

    DataModel.getDataModel().addTimerListener(mAdapter);
    DataModel.getDataModel().addTimerListener(mTimerWatcher);

    // If timer setup state is present, retrieve it to be later honored.
    if (savedInstanceState != null) {
        mTimerSetupState = savedInstanceState.getSerializable(KEY_TIMER_SETUP_STATE);
    }

    return view;
}

From source file:com.codetroopers.betterpickers.radialtimepicker.RadialTimePickerDialogFragment.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (savedInstanceState != null && savedInstanceState.containsKey(KEY_HOUR_OF_DAY)
            && savedInstanceState.containsKey(KEY_MINUTE)
            && savedInstanceState.containsKey(KEY_IS_24_HOUR_VIEW)) {
        mInitialHourOfDay = savedInstanceState.getInt(KEY_HOUR_OF_DAY);
        mInitialMinute = savedInstanceState.getInt(KEY_MINUTE);
        mIs24HourMode = savedInstanceState.getBoolean(KEY_IS_24_HOUR_VIEW);
        mInKbMode = savedInstanceState.getBoolean(KEY_IN_KB_MODE);
        mStyleResId = savedInstanceState.getInt(KEY_STYLE);
        if (savedInstanceState.containsKey(KEY_FUTURE_MINUTES_LIMIT)) {
            mFutureMinutesLimit = savedInstanceState.getInt(KEY_FUTURE_MINUTES_LIMIT);
        }//  w w w.j  a v a2 s .  c o m
        if (savedInstanceState.containsKey(KEY_PAST_MINUTES_LIMIT)) {
            mPastMinutesLimit = savedInstanceState.getInt(KEY_PAST_MINUTES_LIMIT);
        }
        if (savedInstanceState.containsKey(KEY_CURRENT_DATE)) {
            mValidateDateTime = (Calendar) savedInstanceState.getSerializable(KEY_CURRENT_DATE);
        }
        if (savedInstanceState.containsKey(KEY_PICKER_DATE)) {
            mPickerDate = (Calendar) savedInstanceState.getSerializable(KEY_PICKER_DATE);
        }
    } else {
        if (mIs24HourMode == null) {
            mIs24HourMode = DateFormat.is24HourFormat(getContext());
        }
    }
}

From source file:com.borax12.materialdaterangepicker.single.date.DatePickerDialog.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    Log.d(TAG, "onCreateView: ");

    View view = inflater.inflate(R.layout.mdtp_date_picker_dialog_single, container, false);

    mDayOfWeekView = (TextView) view.findViewById(R.id.date_picker_header);
    mMonthAndDayView = (LinearLayout) view.findViewById(R.id.date_picker_month_and_day);
    mMonthAndDayView.setOnClickListener(this);
    mSelectedMonthTextView = (TextView) view.findViewById(R.id.date_picker_month);
    mSelectedDayTextView = (TextView) view.findViewById(R.id.date_picker_day);
    mYearView = (TextView) view.findViewById(R.id.date_picker_year);
    mYearView.setOnClickListener(this);

    int listPosition = -1;
    int listPositionOffset = 0;
    int currentView = mDefaultView;
    if (savedInstanceState != null) {
        mWeekStart = savedInstanceState.getInt(KEY_WEEK_START);
        mMinYear = savedInstanceState.getInt(KEY_YEAR_START);
        mMaxYear = savedInstanceState.getInt(KEY_YEAR_END);
        currentView = savedInstanceState.getInt(KEY_CURRENT_VIEW);
        listPosition = savedInstanceState.getInt(KEY_LIST_POSITION);
        listPositionOffset = savedInstanceState.getInt(KEY_LIST_POSITION_OFFSET);
        mMinDate = (Calendar) savedInstanceState.getSerializable(KEY_MIN_DATE);
        mMaxDate = (Calendar) savedInstanceState.getSerializable(KEY_MAX_DATE);
        highlightedDays = (Calendar[]) savedInstanceState.getSerializable(KEY_HIGHLIGHTED_DAYS);
        selectableDays = (Calendar[]) savedInstanceState.getSerializable(KEY_SELECTABLE_DAYS);
        mThemeDark = savedInstanceState.getBoolean(KEY_THEME_DARK);
        mThemeDarkChanged = savedInstanceState.getBoolean(KEY_THEME_DARK_CHANGED);
        mAccentColor = savedInstanceState.getInt(KEY_ACCENT);
        mVibrate = savedInstanceState.getBoolean(KEY_VIBRATE);
        mDismissOnPause = savedInstanceState.getBoolean(KEY_DISMISS);
        mAutoDismiss = savedInstanceState.getBoolean(KEY_AUTO_DISMISS);
        mTitle = savedInstanceState.getString(KEY_TITLE);
        mOkResid = savedInstanceState.getInt(KEY_OK_RESID);
        mOkString = savedInstanceState.getString(KEY_OK_STRING);
        mCancelResid = savedInstanceState.getInt(KEY_CANCEL_RESID);
        mCancelString = savedInstanceState.getString(KEY_CANCEL_STRING);
    }/*from   w w w . jav a  2s. c  o m*/

    final Activity activity = getActivity();
    mDayPickerView = new SimpleDayPickerView(activity, this);
    mYearPickerView = new YearPickerView(activity, this);

    // if theme mode has not been set by java code, check if it is specified in Style.xml
    if (!mThemeDarkChanged) {
        mThemeDark = Utils.isDarkTheme(activity, mThemeDark);
    }

    Resources res = getResources();
    mDayPickerDescription = res.getString(R.string.mdtp_day_picker_description);
    mSelectDay = res.getString(R.string.mdtp_select_day);
    mYearPickerDescription = res.getString(R.string.mdtp_year_picker_description);
    mSelectYear = res.getString(R.string.mdtp_select_year);

    int bgColorResource = mThemeDark ? R.color.mdtp_date_picker_view_animator_dark_theme
            : R.color.mdtp_date_picker_view_animator;
    view.setBackgroundColor(ContextCompat.getColor(activity, bgColorResource));

    mAnimator = (com.borax12.materialdaterangepicker.single.date.AccessibleDateAnimator) view
            .findViewById(R.id.animator);
    mAnimator.addView(mDayPickerView);
    mAnimator.addView(mYearPickerView);
    mAnimator.setDateMillis(mCalendar.getTimeInMillis());
    // TODO: Replace with animation decided upon by the design team.
    Animation animation = new AlphaAnimation(0.0f, 1.0f);
    animation.setDuration(ANIMATION_DURATION);
    mAnimator.setInAnimation(animation);
    // TODO: Replace with animation decided upon by the design team.
    Animation animation2 = new AlphaAnimation(1.0f, 0.0f);
    animation2.setDuration(ANIMATION_DURATION);
    mAnimator.setOutAnimation(animation2);

    Button okButton = (Button) view.findViewById(R.id.ok);
    okButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            tryVibrate();
            notifyOnDateListener();
            dismiss();
        }
    });
    okButton.setTypeface(TypefaceHelper.get(activity, "Roboto-Medium"));
    if (mOkString != null)
        okButton.setText(mOkString);
    else
        okButton.setText(mOkResid);

    Button cancelButton = (Button) view.findViewById(R.id.cancel);
    cancelButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            tryVibrate();
            if (getDialog() != null)
                getDialog().cancel();
        }
    });
    cancelButton.setTypeface(TypefaceHelper.get(activity, "Roboto-Medium"));
    if (mCancelString != null)
        cancelButton.setText(mCancelString);
    else
        cancelButton.setText(mCancelResid);
    cancelButton.setVisibility(isCancelable() ? View.VISIBLE : View.GONE);

    // If an accent color has not been set manually, get it from the context
    if (mAccentColor == -1) {
        mAccentColor = Utils.getAccentColorFromThemeIfAvailable(getActivity());
    }
    if (mDayOfWeekView != null)
        mDayOfWeekView.setBackgroundColor(Utils.darkenColor(mAccentColor));
    view.findViewById(R.id.day_picker_selected_date_layout).setBackgroundColor(mAccentColor);
    okButton.setTextColor(mAccentColor);
    cancelButton.setTextColor(mAccentColor);

    if (getDialog() == null) {
        view.findViewById(R.id.done_background).setVisibility(View.GONE);
    }

    updateDisplay(false);
    setCurrentView(currentView);

    if (listPosition != -1) {
        if (currentView == MONTH_AND_DAY_VIEW) {
            mDayPickerView.postSetSelection(listPosition);
        } else if (currentView == YEAR_VIEW) {
            mYearPickerView.postSetSelectionFromTop(listPosition, listPositionOffset);
        }
    }

    mHapticFeedbackController = new HapticFeedbackController(activity);
    return view;
}

From source file:com.ebridgevas.android.ebridgeapp.messaging.mqttservice.MqttAndroidClient.java

/**
 * Process trace action - pass trace data back to the callback
 * //w  ww  . j av a2s.  c o m
 * @param data
 */
private void traceAction(Bundle data) {

    if (traceCallback != null) {
        String severity = data.getString(MqttServiceConstants.CALLBACK_TRACE_SEVERITY);
        String message = data.getString(MqttServiceConstants.CALLBACK_ERROR_MESSAGE);
        String tag = data.getString(MqttServiceConstants.CALLBACK_TRACE_TAG);
        if (MqttServiceConstants.TRACE_DEBUG.equals(severity))
            traceCallback.traceDebug(tag, message);
        else if (MqttServiceConstants.TRACE_ERROR.equals(severity))
            traceCallback.traceError(tag, message);
        else {
            Exception e = (Exception) data.getSerializable(MqttServiceConstants.CALLBACK_EXCEPTION);
            traceCallback.traceException(tag, message, e);
        }
    }
}

From source file:org.elasticdroid.SshConnectorView.java

/**
 * Restore instance state when the activity is reconstructed after a destroy
 * //from   ww w . j  a  v a2 s .  co m
 * This method restores:
 * <ul>
 * <li></li>
 * </ul>
 */
@SuppressWarnings("unchecked")
@Override
public void onRestoreInstanceState(Bundle stateToRestore) {
    //restore alertDialogDisplayed boolean
    alertDialogDisplayed = stateToRestore.getBoolean("alertDialogDisplayed");
    Log.v(this.getClass().getName(), "alertDialogDisplayed = " + alertDialogDisplayed);
    alertDialogMessage = stateToRestore.getString("alertDialogMessage");

    //was a progress dialog being displayed? Restore the answer to this question.
    progressDialogDisplayed = stateToRestore.getBoolean("progressDialogDisplayed");
    Log.v(this.getClass().getName() + ".onRestoreInstanceState",
            "progressDialogDisplayed:" + progressDialogDisplayed);

    /*get the model data back, so that you can inform the model that the activity
     * has come back up. */
    Object retained = getLastNonConfigurationInstance();
    //if there was a model executing when the object was destroyed, retained will be an 
    //instance of SecurityGroupsModel
    if (retained instanceof SecurityGroupsModel) {
        Log.i(TAG + ".onRestoreInstanceState()", "Reclaiming previous " + "background task");
        securityGroupsModel = (SecurityGroupsModel) retained;
        securityGroupsModel.setActivity(this);//tell the model of the new activity created
    } else {
        securityGroupsModel = null;

        Log.v(TAG, "No model object, or model finished before activity " + "was recreated.");

        //now if there is no model anymore, and progressDialogDisplayed is set to true,
        //reset it to false, because the model finished executing before the restart
        if (progressDialogDisplayed) {
            progressDialogDisplayed = false;
        }
    }

    Log.d(TAG, "Restoring open ports data if any");

    try {
        openPorts = (ArrayList<String>) stateToRestore.getSerializable("openPorts");
    } catch (Exception exception) {
        openPorts = null;
    }

    //if we have openPorts data, populate the spinner
    if (openPorts != null) {
        populateSpinner();
        //populate spinner will have set the spinner to port 22
        //or to the first index
        //reposition the selected index
        ((Spinner) findViewById(R.id.sshConnectorPortSpinner))
                .setSelection(stateToRestore.getInt("selectedPortPos"));
    }

    //if the user has entered new username, set that into EditText
    if (stateToRestore.getString("sshUsername") != null) {
        ((EditText) findViewById(R.id.sshConnectorUsernameEditTextView))
                .setText(stateToRestore.getString("sshUsername"));
    }

    //set the pubkey auth checkbox
    ((CheckBox) findViewById(R.id.sshConnectorUsePublicKeyAuth))
            .setChecked(stateToRestore.getBoolean("usePubkeyAuth"));
}

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

@Override
public void onRestoreInstanceState(Bundle savedInstanceState) {
    super.onRestoreInstanceState(savedInstanceState);
    if (LDebug.ON)
        Log.d(LOG_TAG, "In 'onRestoreInstanceState'");
    mSubplotTypeId = savedInstanceState.getLong(ARG_SUBPLOT_TYPE_ID);
    mVisitId = savedInstanceState.getLong(ARG_VISIT_ID);
    mConnectionRequested = savedInstanceState.getBoolean(ARG_CONNECTION_REQUESTED);
    mExistingPhCodes = (HashMap<String, Long>) savedInstanceState.getSerializable(ARG_PH_EXISTING_SET);
    mNewPurcRecId = savedInstanceState.getLong(ARG_PURCH_REC_ID);

}

From source file:com.taw.gotothere.GoToThereActivity.java

@Override
protected void onRestoreInstanceState(Bundle savedInstanceState) {
    // Let superclass handle map type/centre point and zoom level
    super.onRestoreInstanceState(savedInstanceState);

    Log.d(TAG, "onRestoreInstanceState()");

    int latitude = savedInstanceState.getInt(END_LAT_KEY, -1);
    int longitude = savedInstanceState.getInt(END_LONG_KEY, -1);

    placingMarker = savedInstanceState.getBoolean(PLACING_MARKER_KEY);
    if (placingMarker) {
        startMarkerPlacement();/*from   ww  w .  jav  a2s . co  m*/

        // May have tapped an endpoint already
        if (latitude != -1 && longitude != -1) {
            navigationOverlay.setSelectedLocation(new GeoPoint(latitude, longitude));
            directionsImageView.setEnabled(true);
        } else {
            directionsImageView.setEnabled(false);
        }
    }

    navigating = savedInstanceState.getBoolean(NAVIGATING_KEY);
    if (navigating) {

        navigationOverlay.startNavigating();

        if (latitude != -1 && longitude != -1) {
            navigationOverlay.setSelectedLocation(new GeoPoint(latitude, longitude));
        }

        latitude = savedInstanceState.getInt(START_LAT_KEY, -1);
        longitude = savedInstanceState.getInt(START_LONG_KEY, -1);

        if (latitude != -1 && longitude != -1) {
            navigationOverlay.setStartLocation(new GeoPoint(latitude, longitude));
        }

        navigationOverlay.setDirections((MapDirections) savedInstanceState.getSerializable(DIRECTIONS_KEY));

        directionsImageView.setSelected(true);
        directionsImageView.setEnabled(true);

        markerImageView.setEnabled(false);
    }

    // Save the previousQuery flag as a preference: if the screen is re-oriented
    // then the activity is killed + restarted, meaning we lose the 
    // savedInstanceState bundle. This is an easy way to keep track of this flag.
    SharedPreferences prefs = getPreferences(Activity.MODE_PRIVATE);
    searchTextView.setText(prefs.getString(PREVIOUS_QUERY, null));
}

From source file:com.bw.luzz.monkeyapplication.View.DateTimePicker.date.DatePickerDialog.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    Log.d(TAG, "onCreateView: ");

    // All options have been set at this point: round the initial selection if necessary
    setToNearestDate(mCalendar);/*from  w w  w.  j  a  v a  2 s  .c o m*/

    View view = inflater.inflate(R.layout.mdtp_date_picker_dialog, container, false);

    mDayOfWeekView = (TextView) view.findViewById(R.id.date_picker_header);
    mMonthAndDayView = (LinearLayout) view.findViewById(R.id.date_picker_month_and_day);
    mMonthAndDayView.setOnClickListener(this);
    mSelectedMonthTextView = (TextView) view.findViewById(R.id.date_picker_month);
    mSelectedDayTextView = (TextView) view.findViewById(R.id.date_picker_day);
    mYearView = (TextView) view.findViewById(R.id.date_picker_year);
    mYearView.setOnClickListener(this);

    int listPosition = -1;
    int listPositionOffset = 0;
    int currentView = mDefaultView;
    if (savedInstanceState != null) {
        mWeekStart = savedInstanceState.getInt(KEY_WEEK_START);
        mMinYear = savedInstanceState.getInt(KEY_YEAR_START);
        mMaxYear = savedInstanceState.getInt(KEY_YEAR_END);
        currentView = savedInstanceState.getInt(KEY_CURRENT_VIEW);
        listPosition = savedInstanceState.getInt(KEY_LIST_POSITION);
        listPositionOffset = savedInstanceState.getInt(KEY_LIST_POSITION_OFFSET);
        mMinDate = (Calendar) savedInstanceState.getSerializable(KEY_MIN_DATE);
        mMaxDate = (Calendar) savedInstanceState.getSerializable(KEY_MAX_DATE);
        highlightedDays = (Calendar[]) savedInstanceState.getSerializable(KEY_HIGHLIGHTED_DAYS);
        selectableDays = (Calendar[]) savedInstanceState.getSerializable(KEY_SELECTABLE_DAYS);
        mThemeDark = savedInstanceState.getBoolean(KEY_THEME_DARK);
        mThemeDarkChanged = savedInstanceState.getBoolean(KEY_THEME_DARK_CHANGED);
        mAccentColor = savedInstanceState.getInt(KEY_ACCENT);
        mVibrate = savedInstanceState.getBoolean(KEY_VIBRATE);
        mDismissOnPause = savedInstanceState.getBoolean(KEY_DISMISS);
        mAutoDismiss = savedInstanceState.getBoolean(KEY_AUTO_DISMISS);
        mTitle = savedInstanceState.getString(KEY_TITLE);
        mOkResid = savedInstanceState.getInt(KEY_OK_RESID);
        mOkString = savedInstanceState.getString(KEY_OK_STRING);
        mCancelResid = savedInstanceState.getInt(KEY_CANCEL_RESID);
        mCancelString = savedInstanceState.getString(KEY_CANCEL_STRING);
    }

    final Activity activity = getActivity();
    mDayPickerView = new SimpleDayPickerView(activity, this);
    mYearPickerView = new YearPickerView(activity, this);

    // if theme mode has not been set by java code, check if it is specified in Style.xml
    if (!mThemeDarkChanged) {
        mThemeDark = Utils.isDarkTheme(activity, mThemeDark);
    }

    Resources res = getResources();
    mDayPickerDescription = res.getString(R.string.mdtp_day_picker_description);
    mSelectDay = res.getString(R.string.mdtp_select_day);
    mYearPickerDescription = res.getString(R.string.mdtp_year_picker_description);
    mSelectYear = res.getString(R.string.mdtp_select_year);

    int bgColorResource = mThemeDark ? R.color.mdtp_date_picker_view_animator_dark_theme
            : R.color.mdtp_date_picker_view_animator;
    view.setBackgroundColor(ContextCompat.getColor(activity, bgColorResource));

    mAnimator = (AccessibleDateAnimator) view.findViewById(R.id.animator);
    mAnimator.addView(mDayPickerView);
    mAnimator.addView(mYearPickerView);
    mAnimator.setDateMillis(mCalendar.getTimeInMillis());
    // TODO: Replace with animation decided upon by the design team.
    Animation animation = new AlphaAnimation(0.0f, 1.0f);
    animation.setDuration(ANIMATION_DURATION);
    mAnimator.setInAnimation(animation);
    // TODO: Replace with animation decided upon by the design team.
    Animation animation2 = new AlphaAnimation(1.0f, 0.0f);
    animation2.setDuration(ANIMATION_DURATION);
    mAnimator.setOutAnimation(animation2);

    Button okButton = (Button) view.findViewById(R.id.ok);
    okButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            tryVibrate();
            notifyOnDateListener();
            dismiss();
        }
    });
    okButton.setTypeface(TypefaceHelper.get(activity, "Roboto-Medium"));
    if (mOkString != null)
        okButton.setText(mOkString);
    else
        okButton.setText(mOkResid);

    Button cancelButton = (Button) view.findViewById(R.id.cancel);
    cancelButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            tryVibrate();
            if (getDialog() != null)
                getDialog().cancel();
        }
    });
    cancelButton.setTypeface(TypefaceHelper.get(activity, "Roboto-Medium"));
    if (mCancelString != null)
        cancelButton.setText(mCancelString);
    else
        cancelButton.setText(mCancelResid);
    cancelButton.setVisibility(isCancelable() ? View.VISIBLE : View.GONE);

    // If an accent color has not been set manually, get it from the context
    if (mAccentColor == -1) {
        mAccentColor = Utils.getAccentColorFromThemeIfAvailable(getActivity());
    }
    if (mDayOfWeekView != null)
        mDayOfWeekView.setBackgroundColor(Utils.darkenColor(mAccentColor));
    view.findViewById(R.id.day_picker_selected_date_layout).setBackgroundColor(mAccentColor);
    okButton.setTextColor(mAccentColor);
    cancelButton.setTextColor(mAccentColor);

    if (getDialog() == null) {
        view.findViewById(R.id.done_background).setVisibility(View.GONE);
    }

    updateDisplay(false);
    setCurrentView(currentView);

    if (listPosition != -1) {
        if (currentView == MONTH_AND_DAY_VIEW) {
            mDayPickerView.postSetSelection(listPosition);
        } else if (currentView == YEAR_VIEW) {
            mYearPickerView.postSetSelectionFromTop(listPosition, listPositionOffset);
        }
    }

    mHapticFeedbackController = new HapticFeedbackController(activity);
    return view;
}