Example usage for android.os Bundle getBoolean

List of usage examples for android.os Bundle getBoolean

Introduction

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

Prototype

public boolean getBoolean(String key) 

Source Link

Document

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

Usage

From source file:de.j4velin.mapsmeasure.Map.java

@Override
protected void onRestoreInstanceState(final Bundle savedInstanceState) {
    super.onRestoreInstanceState(savedInstanceState);
    try {//from w  w w.  j  ava 2s  . c o  m
        metric = savedInstanceState.getBoolean("metric");
        @SuppressWarnings("unchecked")
        // Casting to Stack<LatLng> apparently results in
        // "java.lang.ClassCastException: java.util.ArrayList cannot be cast to java.util.Stack"
        // on some devices
        List<LatLng> tmp = (List<LatLng>) savedInstanceState.getSerializable("trace");
        Iterator<LatLng> it = tmp.iterator();
        while (it.hasNext()) {
            addPoint(it.next());
        }
        mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(
                new LatLng(savedInstanceState.getDouble("position-lat"),
                        savedInstanceState.getDouble("position-lon")),
                savedInstanceState.getFloat("position-zoom")));
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:at.alladin.rmbt.android.map.RMBTMapFragment.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    geoLocation = new MyGeoLocation(getActivity());

    final Bundle bundle = getArguments();

    if (bundle != null) {
        if (bundle.containsKey(OPTION_ENABLE_ALL_GESTURES)) {
            options.setEnableAllGestures(bundle.getBoolean(OPTION_ENABLE_ALL_GESTURES));
        }/*w w  w  .ja  v a 2 s.c  o m*/
        if (bundle.containsKey(OPTION_SHOW_INFO_TOAST)) {
            options.setShowInfoToast(bundle.getBoolean(OPTION_SHOW_INFO_TOAST));
        }
        if (bundle.containsKey(OPTION_ENABLE_CONTROL_BUTTONS)) {
            options.setEnableControlButtons(bundle.getBoolean(OPTION_ENABLE_CONTROL_BUTTONS));
        }
        if (bundle.containsKey(OPTION_ENABLE_OVERLAY)) {
            options.setEnableOverlay(bundle.getBoolean(OPTION_ENABLE_OVERLAY));
        }
    }
}

From source file:com.appeaser.sublimepicker.Sampler.java

void dealWithSavedInstanceState(Bundle savedInstanceState) {
    if (savedInstanceState == null) { // Default
        cbDatePicker.setChecked(true);//  w  w  w. ja v a2 s  .co  m
        cbTimePicker.setChecked(true);
        cbRecurrencePicker.setChecked(true);
        cbAllowDateRangeSelection.setChecked(false);

        rbDatePicker.setChecked(true);
    } else { // Restore
        cbDatePicker.setChecked(savedInstanceState.getBoolean(SS_DATE_PICKER_CHECKED));
        cbTimePicker.setChecked(savedInstanceState.getBoolean(SS_TIME_PICKER_CHECKED));
        cbRecurrencePicker.setChecked(savedInstanceState.getBoolean(SS_RECURRENCE_PICKER_CHECKED));
        cbAllowDateRangeSelection.setChecked(savedInstanceState.getBoolean(SS_ALLOW_DATE_RANGE_SELECTION));

        rbDatePicker.setVisibility(cbDatePicker.isChecked() ? View.VISIBLE : View.GONE);
        rbTimePicker.setVisibility(cbTimePicker.isChecked() ? View.VISIBLE : View.GONE);
        rbRecurrencePicker.setVisibility(cbRecurrencePicker.isChecked() ? View.VISIBLE : View.GONE);

        onActivatedPickersChanged();

        if (savedInstanceState.getBoolean(SS_INFO_VIEW_VISIBILITY)) {
            int startYear = savedInstanceState.getInt(SS_START_YEAR);

            if (startYear != INVALID_VAL) {
                Calendar startCal = Calendar.getInstance();
                startCal.set(startYear, savedInstanceState.getInt(SS_START_MONTH),
                        savedInstanceState.getInt(SS_START_DAY));

                Calendar endCal = Calendar.getInstance();
                endCal.set(savedInstanceState.getInt(SS_END_YEAR), savedInstanceState.getInt(SS_END_MONTH),
                        savedInstanceState.getInt(SS_END_DAY));
                mSelectedDate = new SelectedDate(startCal, endCal);
            }

            mHour = savedInstanceState.getInt(SS_HOUR);
            mMinute = savedInstanceState.getInt(SS_MINUTE);
            mRecurrenceOption = savedInstanceState.getString(SS_RECURRENCE_OPTION);
            mRecurrenceRule = savedInstanceState.getString(SS_RECURRENCE_RULE);

            updateInfoView();
        }

        final int scrollY = savedInstanceState.getInt(SS_SCROLL_Y);

        if (scrollY != 0) {
            svMainContainer.post(new Runnable() {
                @Override
                public void run() {
                    svMainContainer.scrollTo(svMainContainer.getScrollX(), scrollY);
                }
            });
        }

        // Set callback
        SublimePickerFragment restoredFragment = (SublimePickerFragment) getSupportFragmentManager()
                .findFragmentByTag("SUBLIME_PICKER");
        if (restoredFragment != null) {
            restoredFragment.setCallback(mFragmentCallback);
        }
    }
}

From source file:com.android.contacts.activities.PhotoSelectionActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.photoselection_activity);
    if (savedInstanceState != null) {
        mCurrentPhotoUri = savedInstanceState.getParcelable(KEY_CURRENT_PHOTO_URI);
        mSubActivityInProgress = savedInstanceState.getBoolean(KEY_SUB_ACTIVITY_IN_PROGRESS);
    }//from   w  w  w  .java 2s  .  com

    // Pull data out of the intent.
    final Intent intent = getIntent();
    mPhotoUri = intent.getParcelableExtra(PHOTO_URI);
    mState = (RawContactDeltaList) intent.getParcelableExtra(ENTITY_DELTA_LIST);
    mIsProfile = intent.getBooleanExtra(IS_PROFILE, false);
    mIsDirectoryContact = intent.getBooleanExtra(IS_DIRECTORY_CONTACT, false);
    mExpandPhoto = intent.getBooleanExtra(EXPAND_PHOTO, false);

    // Pull out photo expansion properties from resources
    mExpandedPhotoSize = getResources().getDimensionPixelSize(R.dimen.detail_contact_photo_expanded_size);
    mHeightOffset = getResources().getDimensionPixelOffset(R.dimen.expanded_photo_height_offset);

    mBackdrop = findViewById(R.id.backdrop);
    mPhotoView = (ImageView) findViewById(R.id.photo);
    mSourceBounds = intent.getSourceBounds();

    // Fade in the background.
    animateInBackground();

    // Dismiss the dialog on clicking the backdrop.
    mBackdrop.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            finish();
        }
    });

    // Wait until the layout pass to show the photo, so that the source bounds will match up.
    SchedulingUtils.doAfterLayout(mBackdrop, new Runnable() {
        @Override
        public void run() {
            displayPhoto();
        }
    });
}

From source file:com.nextgis.firereporter.GetFiresService.java

protected void Prepare() {
    mLocManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
    mnCurrentExec = 0;/*from  w  w w . j  ava 2 s  .  c o  m*/
    mmoFires = new HashMap<Long, FireItem>();

    mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    nUserCount = 0;
    nNasaCount = 0;
    nScanexCount = 0;
    TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
    stackBuilder.addParentStack(MainActivity.class);
    stackBuilder.addNextIntent(new Intent(this, MainActivity.class));
    //stackBuilder.addNextIntent(new Intent(this, ScanexNotificationsActivity.class));
    PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);

    mBuilder = new NotificationCompat.Builder(this).setSmallIcon(R.drawable.ic_fire_small)
            .setContentTitle(getString(R.string.stNewFireNotifications));
    mBuilder.setContentIntent(resultPendingIntent);

    Intent delIntent = new Intent(this, GetFiresService.class);
    delIntent.putExtra(COMMAND, SERVICE_NOTIFY_DISMISSED);
    PendingIntent deletePendingIntent = PendingIntent.getService(this, 0, delIntent,
            PendingIntent.FLAG_UPDATE_CURRENT);
    mBuilder.setDeleteIntent(deletePendingIntent);

    mInboxStyle = new NotificationCompat.InboxStyle();
    mInboxStyle.setBigContentTitle(getString(R.string.stNewFireNotificationDetailes));

    LoadScanexData();

    mSanextCookieTime = new Time();
    mSanextCookieTime.setToNow();
    msScanexLoginCookie = new String("not_set");

    mFillDataHandler = new Handler() {
        public void handleMessage(Message msg) {

            mnCurrentExec--;

            Bundle resultData = msg.getData();
            boolean bHaveErr = resultData.getBoolean(ERROR);
            if (bHaveErr) {
                SendError(resultData.getString(ERR_MSG));
            } else {
                int nType = resultData.getInt(SOURCE);
                String sData = resultData.getString(JSON);
                switch (nType) {
                case 3:
                    FillScanexData(nType, sData);
                    break;
                case 4:
                    msScanexLoginCookie = sData;
                    mSanextCookieTime.setToNow();
                    GetScanexData(false);
                    break;
                default:
                    FillData(nType, sData);
                    break;
                }
            }
            GetDataStoped();
        };
    };
}

From source file:at.wada811.android.dialogfragments.AlertDialogFragment.java

private void setAdapter(AlertDialog.Builder builder) {
    final Bundle args = getArguments();
    boolean useAdapter = args.getBoolean(ADAPTER);
    if (!useAdapter) {
        return;//  w ww. jav a 2s  .  c o  m
    }
    DialogFragmentCallback listener = getDialogFragmentCallback();
    if (listener == null) {
        throw new RuntimeException("DialogEventListenerPovider has not implemented.");
    }
    ListAdapter adapter = listener.getAdapter(this);
    if (adapter == null) {
        throw new NullPointerException("DialogEventListener#getListAdapter returns null.");
    }
    builder.setAdapter(adapter, new OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            bindItemClickListener(which);
        }
    });
}

From source file:at.alladin.rmbt.android.terms.RMBTCheckFragment.java

@Override
public View onCreateView(final LayoutInflater inflater, final ViewGroup container,
        final Bundle savedInstanceState) {
    if (!(getActivity() instanceof RMBTMainActivity))
        firstTime = false;/*  w  ww .  j  a v  a2 s . co m*/

    final View v = inflater.inflate(R.layout.ndt_check, container, false);

    if (!firstTime)
        v.findViewById(R.id.termsNdtButtonBack).setVisibility(View.GONE);

    final TextView textTitle = (TextView) v.findViewById(R.id.check_fragment_title);
    textTitle.setText(checkType.getTitleId());

    checkBox = (CheckBox) v.findViewById(R.id.ndtCheckBox);
    checkBox.setText(checkType.getTextId());

    if (savedInstanceState != null) {
        checkBox.setChecked(savedInstanceState.getBoolean("isChecked"));
    } else {
        checkBox.setChecked(checkType.isDefaultIsChecked());
    }

    final Button buttonAccept = (Button) v.findViewById(R.id.termsNdtAcceptButton);

    if (!firstTime) {
        checkBox.setOnCheckedChangeListener(new OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                buttonAccept.setEnabled(isChecked);
            }
        });
    }

    final WebView wv = (WebView) v.findViewById(R.id.ndtInfoWebView);
    wv.loadUrl(checkType.getTemplateFile());

    buttonAccept.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(final View v) {
            final FragmentActivity activity = getActivity();

            switch (checkType) {
            case NDT:
                ConfigHelper.setNDT(activity, checkBox.isChecked());
                ConfigHelper.setNDTDecisionMade(activity, true);
                break;
            case LOOP_MODE:
                ConfigHelper.setLoopMode(activity, checkBox.isChecked());
                break;
            }

            activity.getSupportFragmentManager().popBackStack(checkType.getFragmentTag(),
                    FragmentManager.POP_BACK_STACK_INCLUSIVE);

            if (firstTime && CheckType.NDT.equals(checkType)) {
                ((RMBTMainActivity) activity).initApp(false);
            } else {
                getActivity().setResult(checkBox.isChecked() ? Activity.RESULT_OK : Activity.RESULT_CANCELED);
                getActivity().finish();
            }
        }
    });

    new Handler().postDelayed(new Runnable() {
        @Override
        public void run() {
            buttonAccept.setEnabled(firstTime || checkBox.isChecked());
        }
    }, 500);

    final Button buttonBack = (Button) v.findViewById(R.id.termsNdtBackButton);
    buttonBack.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(final View v) {
            getActivity().getSupportFragmentManager().popBackStack();
        }
    });

    return v;
}

From source file:com.android.mail.ui.OnePaneController.java

@Override
public void onRestoreInstanceState(Bundle inState) {
    super.onRestoreInstanceState(inState);
    if (inState == null) {
        return;//  w  ww .  j  a v a2  s  .  com
    }
    mLastConversationListTransactionId = inState.getInt(CONVERSATION_LIST_TRANSACTION_KEY, INVALID_ID);
    mLastConversationTransactionId = inState.getInt(CONVERSATION_TRANSACTION_KEY, INVALID_ID);
    mConversationListVisible = inState.getBoolean(CONVERSATION_LIST_VISIBLE_KEY);
    mConversationListNeverShown = inState.getBoolean(CONVERSATION_LIST_NEVER_SHOWN_KEY);
}

From source file:ro.tudorluca.gpstracks.android.MainActivity.java

/**
 * Updates fields based on data stored in the bundle.
 *
 * @param savedInstanceState The activity state saved in the Bundle.
 *///from w w w  . j  a  va  2s .  c  o m
private void updateValuesFromBundle(Bundle savedInstanceState) {
    Log.i(TAG, "Updating values from bundle");
    if (savedInstanceState != null) {
        // Update the value of mRequestingLocationUpdates from the Bundle, and make sure that
        // the Start Updates and Stop Updates buttons are correctly enabled or disabled.
        if (savedInstanceState.keySet().contains(REQUESTING_LOCATION_UPDATES_KEY)) {
            mRequestingLocationUpdates = savedInstanceState.getBoolean(REQUESTING_LOCATION_UPDATES_KEY);
            setButtonsEnabledState();
        }

        // Update the value of mCurrentLocation from the Bundle and update the UI to show the
        // correct latitude and longitude.
        if (savedInstanceState.keySet().contains(LOCATION_KEY)) {
            // Since LOCATION_KEY was found in the Bundle, we can be sure that mCurrentLocation
            // is not null.
            mCurrentLocation = savedInstanceState.getParcelable(LOCATION_KEY);
        }

        // Update the value of mLastUpdateTime from the Bundle and update the UI.
        if (savedInstanceState.keySet().contains(LAST_UPDATED_TIME_STRING_KEY)) {
            mLastUpdateTime = savedInstanceState.getString(LAST_UPDATED_TIME_STRING_KEY);
        }
        updateUI();
    }
}

From source file:cm.aptoide.com.actionbarsherlock.widget.SuggestionsAdapter.java

private void updateSpinnerState(Cursor cursor) {
    Bundle extras = cursor != null ? cursor.getExtras() : null;
    if (DBG) {//from  w  w  w .j  av a2 s .c  om
        Log.d(LOG_TAG, "updateSpinnerState - extra = "
                + (extras != null ? extras.getBoolean(SearchManager.CURSOR_EXTRA_KEY_IN_PROGRESS) : null));
    }
    // Check if the Cursor indicates that the query is not complete and show the spinner
    if (extras != null && extras.getBoolean(SearchManager.CURSOR_EXTRA_KEY_IN_PROGRESS)) {
        // mSearchView.getWindow().getDecorView().post(mStartSpinnerRunnable); // TODO:
        return;
    }
    // If cursor is null or is done, stop the spinner
    // mSearchView.getWindow().getDecorView().post(mStopSpinnerRunnable); // TODO:
}