List of usage examples for android.os Bundle containsKey
public boolean containsKey(String key)
From source file:it.sineo.android.tileMapEditor.TileMap.java
public TileMap(Bundle b) { name = b.getString("name"); rows = b.getInt("rows"); columns = b.getInt("columns"); scale = b.getFloat("scale"); xOff = b.getFloat("xOff"); yOff = b.getFloat("yoff"); tilePaths = new String[rows][columns]; tileBitmaps = new Bitmap[rows][columns]; tileAngles = new byte[rows][columns]; tileMatrices = new Matrix[rows][columns]; for (int idxRow = 0; idxRow < rows; idxRow++) { for (int idxCol = 0; idxCol < columns; idxCol++) { if (b.containsKey("paths_" + idxRow + "_" + idxCol)) { tilePaths[idxRow][idxCol] = b.getString("paths_" + idxRow + "_" + idxCol); tileAngles[idxRow][idxCol] = b.getByte("angles_" + idxRow + "_" + idxCol); }//from w w w. j a va 2 s.c o m } } }
From source file:androidx.media.MediaBrowser2.java
/** * Subscribe to a parent id for the change in its children. When there's a change, * {@link BrowserCallback#onChildrenChanged(MediaBrowser2, String, int, Bundle)} will be called * with the bundle that you've specified. You should call * {@link #getChildren(String, int, int, Bundle)} to get the actual contents for the parent. * * @param parentId parent id/*w w w.j av a 2s .c o m*/ * @param extras extra bundle */ public void subscribe(@NonNull String parentId, @Nullable Bundle extras) { if (parentId == null) { throw new IllegalArgumentException("parentId shouldn't be null"); } // TODO: Document this behavior Bundle option; if (extras != null && (extras.containsKey(MediaBrowserCompat.EXTRA_PAGE) || extras.containsKey(MediaBrowserCompat.EXTRA_PAGE_SIZE))) { option = new Bundle(extras); option.remove(MediaBrowserCompat.EXTRA_PAGE); option.remove(MediaBrowserCompat.EXTRA_PAGE_SIZE); } else { option = extras; } SubscribeCallback callback = new SubscribeCallback(); synchronized (mLock) { List<SubscribeCallback> list = mSubscribeCallbacks.get(parentId); if (list == null) { list = new ArrayList<>(); mSubscribeCallbacks.put(parentId, list); } list.add(callback); } // TODO: Revisit using default browser is OK. Here's my concern. // Assume that MediaBrowser2 is connected with the MediaBrowserServiceCompat. // Since MediaBrowserServiceCompat can call MediaBrowserServiceCompat# // getBrowserRootHints(), the service may refuse calls from MediaBrowser2 getBrowserCompat().subscribe(parentId, option, callback); }
From source file:com.android.contacts.list.ContactEntryListAdapter.java
/** * Updates the indexer, which is used to produce section headers. *///from w w w .j a va 2s . com //private void updateIndexer(Cursor cursor) { public void updateIndexer(Cursor cursor) { if (cursor == null) { setIndexer(null); return; } Bundle bundle = cursor.getExtras(); if (bundle.containsKey(ContactCounts.EXTRA_ADDRESS_BOOK_INDEX_TITLES)) { String sections[] = bundle.getStringArray(ContactCounts.EXTRA_ADDRESS_BOOK_INDEX_TITLES); int counts[] = bundle.getIntArray(ContactCounts.EXTRA_ADDRESS_BOOK_INDEX_COUNTS); setIndexer(new ContactsSectionIndexer(sections, counts)); } else { setIndexer(null); } }
From source file:com.openerp.addons.messages.MessageDetail.java
@Override public void onStart() { super.onStart(); Bundle bundle = getArguments(); if (bundle != null) { if (bundle.containsKey("message_id")) { message_id = bundle.getInt("message_id"); LoadMessageDetails messageDetails = new LoadMessageDetails(message_id); messageDetails.execute((Void) null); }/*from w w w . jav a2s .com*/ } }
From source file:za.co.neilson.alarm.preferences.AlarmPreferencesActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // requestWindowFeature(Window.FEATURE_NO_TITLE); ActionBar actionBar = getSupportActionBar(); actionBar.setDisplayHomeAsUpEnabled(true); setContentView(R.layout.alarm_preferences); pref = getSharedPreferences("AppPref", MODE_PRIVATE); email = getIntent().getStringExtra("email"); Log.d("? ???!!! ", "" + email); Bundle bundle = getIntent().getExtras(); if (bundle != null && bundle.containsKey("alarm")) { setMathAlarm((Alarm) bundle.getSerializable("alarm")); } else {/*from w w w. jav a 2 s. c o m*/ setMathAlarm(new Alarm()); } if (bundle != null && bundle.containsKey("adapter")) { setListAdapter((AlarmPreferenceListAdapter) bundle.getSerializable("adapter")); } else { setListAdapter(new AlarmPreferenceListAdapter(this, getMathAlarm())); } getListView().setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> l, View v, int position, long id) { final AlarmPreferenceListAdapter alarmPreferenceListAdapter = (AlarmPreferenceListAdapter) getListAdapter(); final AlarmPreference alarmPreference = (AlarmPreference) alarmPreferenceListAdapter .getItem(position); AlertDialog.Builder alert; v.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY); switch (alarmPreference.getType()) { case BOOLEAN: CheckedTextView checkedTextView = (CheckedTextView) v; boolean checked = !checkedTextView.isChecked(); ((CheckedTextView) v).setChecked(checked); switch (alarmPreference.getKey()) { case ALARM_ACTIVE: alarm.setAlarmActive(checked); break; case ALARM_VIBRATE: alarm.setVibrate(checked); if (checked) { Vibrator vibrator = (Vibrator) getSystemService(VIBRATOR_SERVICE); vibrator.vibrate(1000); } break; } alarmPreference.setValue(checked); break; case STRING: alert = new AlertDialog.Builder(AlarmPreferencesActivity.this); alert.setTitle(alarmPreference.getTitle()); // alert.setMessage(message); // Set an EditText view to get user input final EditText input = new EditText(AlarmPreferencesActivity.this); input.setText(alarmPreference.getValue().toString()); alert.setView(input); alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { alarmPreference.setValue(input.getText().toString()); if (alarmPreference.getKey() == Key.ALARM_NAME) { alarm.setAlarmName(alarmPreference.getValue().toString()); } alarmPreferenceListAdapter.setMathAlarm(getMathAlarm()); alarmPreferenceListAdapter.notifyDataSetChanged(); } }); alert.show(); break; case LIST: alert = new AlertDialog.Builder(AlarmPreferencesActivity.this); alert.setTitle(alarmPreference.getTitle()); // alert.setMessage(message); CharSequence[] items = new CharSequence[alarmPreference.getOptions().length]; for (int i = 0; i < items.length; i++) items[i] = alarmPreference.getOptions()[i]; alert.setItems(items, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { switch (alarmPreference.getKey()) { case ALARM_DIFFICULTY: Alarm.Difficulty d = Alarm.Difficulty.values()[which]; alarm.setDifficulty(d); break; case ALARM_TONE: alarm.setAlarmTonePath(alarmPreferenceListAdapter.getAlarmTonePaths()[which]); if (alarm.getAlarmTonePath() != null) { if (mediaPlayer == null) { mediaPlayer = new MediaPlayer(); } else { if (mediaPlayer.isPlaying()) mediaPlayer.stop(); mediaPlayer.reset(); } try { // mediaPlayer.setVolume(1.0f, 1.0f); mediaPlayer.setVolume(0.2f, 0.2f); mediaPlayer.setDataSource(AlarmPreferencesActivity.this, Uri.parse(alarm.getAlarmTonePath())); mediaPlayer.setAudioStreamType(AudioManager.STREAM_ALARM); mediaPlayer.setLooping(false); mediaPlayer.prepare(); mediaPlayer.start(); // Force the mediaPlayer to stop after 3 // seconds... if (alarmToneTimer != null) alarmToneTimer.cancel(); alarmToneTimer = new CountDownTimer(3000, 3000) { @Override public void onTick(long millisUntilFinished) { } @Override public void onFinish() { try { if (mediaPlayer.isPlaying()) mediaPlayer.stop(); } catch (Exception e) { } } }; alarmToneTimer.start(); } catch (Exception e) { try { if (mediaPlayer.isPlaying()) mediaPlayer.stop(); } catch (Exception e2) { } } } break; default: break; } alarmPreferenceListAdapter.setMathAlarm(getMathAlarm()); alarmPreferenceListAdapter.notifyDataSetChanged(); } }); alert.show(); break; case MULTIPLE_LIST: alert = new AlertDialog.Builder(AlarmPreferencesActivity.this); alert.setTitle(alarmPreference.getTitle()); // alert.setMessage(message); CharSequence[] multiListItems = new CharSequence[alarmPreference.getOptions().length]; for (int i = 0; i < multiListItems.length; i++) multiListItems[i] = alarmPreference.getOptions()[i]; boolean[] checkedItems = new boolean[multiListItems.length]; for (Alarm.Day day : getMathAlarm().getDays()) { checkedItems[day.ordinal()] = true; } alert.setMultiChoiceItems(multiListItems, checkedItems, new OnMultiChoiceClickListener() { @Override public void onClick(final DialogInterface dialog, int which, boolean isChecked) { Alarm.Day thisDay = Alarm.Day.values()[which]; if (isChecked) { alarm.addDay(thisDay); } else { // Only remove the day if there are more than 1 // selected if (alarm.getDays().length > 1) { alarm.removeDay(thisDay); } else { // If the last day was unchecked, re-check // it ((AlertDialog) dialog).getListView().setItemChecked(which, true); } } } }); alert.setOnCancelListener(new OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { alarmPreferenceListAdapter.setMathAlarm(getMathAlarm()); alarmPreferenceListAdapter.notifyDataSetChanged(); } }); alert.show(); break; case TIME: TimePickerDialog timePickerDialog = new TimePickerDialog(AlarmPreferencesActivity.this, new OnTimeSetListener() { @Override public void onTimeSet(TimePicker timePicker, int hours, int minutes) { Calendar newAlarmTime = Calendar.getInstance(); newAlarmTime.set(Calendar.HOUR_OF_DAY, hours); newAlarmTime.set(Calendar.MINUTE, minutes); newAlarmTime.set(Calendar.SECOND, 0); alarm.setAlarmTime(newAlarmTime); alarmPreferenceListAdapter.setMathAlarm(getMathAlarm()); alarmPreferenceListAdapter.notifyDataSetChanged(); } }, alarm.getAlarmTime().get(Calendar.HOUR_OF_DAY), alarm.getAlarmTime().get(Calendar.MINUTE), true); timePickerDialog.setTitle(alarmPreference.getTitle()); timePickerDialog.show(); default: break; } } }); }
From source file:com.fvd.nimbus.MainActivity.java
@Override protected void onRestoreInstanceState(Bundle savedInstanceState) { super.onRestoreInstanceState(savedInstanceState); if (savedInstanceState.containsKey("cameraImageUri")) { outputFileUri = Uri.parse(savedInstanceState.getString("cameraImageUri")); }//w w w . ja va 2s .com }
From source file:ca.mudar.mtlaucasou.BaseMapActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ((AppHelper) getApplicationContext()).updateUiLanguage(); /**// w w w . j ava 2 s. com * By default, show map and hide list. */ isHiddenList = true; if ((savedInstanceState != null) && savedInstanceState.containsKey(Const.KEY_INSTANCE_LIST_IS_HIDDEN)) { /** * For visible/hidden fragments and actionbar icon */ isHiddenList = savedInstanceState.getBoolean(Const.KEY_INSTANCE_LIST_IS_HIDDEN); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { getActionBar().setHomeButtonEnabled(true); } }
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)); }//from w w w . j a v a 2 s . c om 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.handshake.notifications.MyGcmListenerService.java
/** * Called when message is received.//from www. j av a2s . c o m * * @param from SenderID of the sender. * @param data Data bundle containing message data as key/value pairs. * For Set of keys use data.keySet(). */ // [START receive_message] @Override public void onMessageReceived(String from, final Bundle data) { SessionManager session = new SessionManager(this); if (!session.isLoggedIn()) return; /** * Production applications would usually process the message here. * Eg: - Syncing with server. * - Store message in local database. * - Update UI. */ /** * In some cases it may be useful to show a notification indicating to the user * that a message was received. */ try { final JSONArray users = new JSONArray(); if (!data.containsKey("user")) return; final JSONObject user = new JSONObject(data.getString("user")); users.put(user); UserServerSync.cacheUser(getApplicationContext(), users, new UserArraySyncCompleted() { @Override public void syncCompletedListener(final ArrayList<User> users) { if (users.size() == 0) { sendNotification(data, 0, false); return; } final long userId = users.get(0).getUserId(); final boolean isContact = users.get(0).isContact(); FeedItemServerSync.performSync(getApplicationContext(), new SyncCompleted() { @Override public void syncCompletedListener() { ContactSync.performSync(getApplicationContext(), new SyncCompleted() { @Override public void syncCompletedListener() { if (data.containsKey("group_id")) { Realm realm = Realm.getInstance(getApplicationContext()); Group group = realm.where(Group.class) .equalTo("groupId", Long.parseLong(data.getString("group_id"))) .findFirst(); GroupServerSync.loadGroupMembers(group); realm.close(); } sendNotification(data, userId, isContact); } }); } }); } }); } catch (JSONException e) { e.printStackTrace(); } }
From source file:com.ryan.ryanreader.activities.CommentEditActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { PrefsUtility.applyTheme(this); super.onCreate(savedInstanceState); final LinearLayout layout = (LinearLayout) getLayoutInflater().inflate(R.layout.comment_edit); textEdit = (EditText) layout.findViewById(R.id.comment_reply_text); if (getIntent() != null && getIntent().hasExtra("commentIdAndType")) { commentIdAndType = getIntent().getStringExtra("commentIdAndType"); textEdit.setText(getIntent().getStringExtra("commentText")); } else if (savedInstanceState != null && savedInstanceState.containsKey("commentIdAndType")) { textEdit.setText(savedInstanceState.getString("commentText")); commentIdAndType = savedInstanceState.getString("commentIdAndType"); }//from ww w.j a va 2s . c om final ScrollView sv = new ScrollView(this); sv.addView(layout); setContentView(sv); }