List of usage examples for android.os Bundle keySet
public Set<String> keySet()
From source file:com.cokus.fangdouyu.widget.viewpagerindicator.view.indicator.FragmentListPageAdapter.java
@Override public void restoreState(Parcelable state, ClassLoader loader) { if (state != null) { Bundle bundle = (Bundle) state; bundle.setClassLoader(loader);/*w w w . j a va2s . c om*/ mSavedState.clear(); mFragments.clear(); if (bundle.containsKey("states")) { mSavedState = bundle.getSparseParcelableArray("states"); } Iterable<String> keys = bundle.keySet(); for (String key : keys) { if (key.startsWith("f")) { int index = Integer.parseInt(key.substring(1)); Fragment f = mFragmentManager.getFragment(bundle, key); if (f != null) { f.setMenuVisibility(false); mFragments.put(index, f); } else { // Log.w(TAG, "Bad fragment at key " + key); } } } } }
From source file:edt.com.edt.view.mainpage.indicator.FragmentListPageAdapter.java
@Override public void restoreState(Parcelable state, ClassLoader loader) { if (state != null) { Bundle bundle = (Bundle) state; bundle.setClassLoader(loader);//from ww w.j a v a2s. co m mSavedState.clear(); mFragments.clear(); if (bundle.containsKey("states")) { mSavedState = bundle.getSparseParcelableArray("states"); } Iterable<String> keys = bundle.keySet(); for (String key : keys) { if (key.startsWith("f")) { int index = Integer.parseInt(key.substring(1)); Fragment f = mFragmentManager.getFragment(bundle, key); if (f != null) { f.setMenuVisibility(false); mFragments.put(index, f); } else { // Log.w(TAG, "Bad fragment_home at key " + key); } } } } }
From source file:com.example.li.demo.tab.FragmentListPageAdapter.java
@Override public void restoreState(Parcelable state, ClassLoader loader) { if (state != null) { Bundle bundle = (Bundle) state; bundle.setClassLoader(loader);/*w w w . jav a 2s .c o m*/ mSavedState.clear(); mFragments.clear(); if (bundle.containsKey("states")) { mSavedState = bundle.getSparseParcelableArray("states"); } Iterable<String> keys = bundle.keySet(); for (String key : keys) { if (key.startsWith("f")) { int index = Integer.parseInt(key.substring(1)); Fragment f = mFragmentManager.getFragment(bundle, key); if (f != null) { f.setMenuVisibility(false); mFragments.put(index, f); } else { Log.w("", "Bad fragment at key " + key); } } } } }
From source file:com.chatwing.whitelabel.services.NotificationIntentService.java
@Override public void onMessageReceived(String from, Bundle extras) { if (mUserManager.getCurrentUser() == null) return;//No login no push if (from.startsWith("/topics/")) { // message received from some topic. } else {/*w w w. j a v a 2 s. c om*/ Set<String> keys = extras.keySet(); for (String k : keys) { LogUtils.v("Key in GCM " + k + ":" + extras.get(k)); } if (!supportVersion(extras)) { return; } if (handleBroadCastEvent(extras)) { return; } String params = extras.getString("params"); if (params == null) return; MessageResponse messageResponse = getMessagesFromParams(params); if (messageResponse == null) return; Message[] messages = messageResponse.getMessages(); User targetUser = messageResponse.getChatUser(); if (messages == null || messages.length == 0) { return; } if (!shouldShowNotification(messages[0])) { return; } //Fill chatbox_id or conversation_id to message fillGroupIDToMessage(messages, extras.getString("type"), messageResponse); insertNotificationMessagesToDb(messages); if (extras.getString("type").equals("conversation_notification")) { String conversationId = messageResponse.getConversation().getId(); List<Message> freshConversations = getMessagesByGroup(conversationId); LogUtils.v("Test notification not receive getMessagesByGroup " + freshConversations.size()); mCWNotificationManager.notifyForBox(freshConversations, messageResponse.getConversation().getId(), targetUser, false); // We use GCM notification just as backup plan to update latest message so no need to make sound } else { ChatBox chatbox = messageResponse.getChatbox(); List<Message> freshChatboxes = getMessagesByGroup(chatbox.getId()); mCWNotificationManager.notifyForBox(freshChatboxes, chatbox.getName(), chatbox.getId(), false); // We use GCM notification just as backup plan to update latest message so no need to make sound } } }
From source file:com.facebook.SharedPreferencesTokenCache.java
/** * Persists all supported data types present in the passed in Bundle, to the * cache//from w w w . ja v a 2 s . c om * * @param bundle * The Bundle containing information to be cached */ public void save(Bundle bundle) { Validate.notNull(bundle, "bundle"); SharedPreferences.Editor editor = cache.edit(); for (String key : bundle.keySet()) { try { serializeKey(key, bundle, editor); } catch (JSONException e) { // Error in the bundle. Don't store a partial cache. Logger.log(LoggingBehaviors.CACHE, Log.WARN, TAG, "Error processing value for key: '" + key + "' -- " + e); // Bypass the commit and just return. This cancels the entire edit transaction return; } } boolean successfulCommit = editor.commit(); if (!successfulCommit) { Logger.log(LoggingBehaviors.CACHE, Log.WARN, TAG, "SharedPreferences.Editor.commit() was not successful"); } }
From source file:com.facebook.SharedPreferencesTokenCachingStrategy.java
/** * Persists all supported data types present in the passed in Bundle, to the * cache/*from w w w .j a v a 2s.com*/ * * @param bundle * The Bundle containing information to be cached */ public void save(Bundle bundle) { Validate.notNull(bundle, "bundle"); SharedPreferences.Editor editor = cache.edit(); for (String key : bundle.keySet()) { try { serializeKey(key, bundle, editor); } catch (JSONException e) { // Error in the bundle. Don't store a partial cache. Logger.log(LoggingBehavior.CACHE, Log.WARN, TAG, "Error processing value for key: '" + key + "' -- " + e); // Bypass the commit and just return. This cancels the entire edit transaction return; } } editor.apply(); }
From source file:com.hybris.mobile.lib.location.geofencing.service.GeofencingIntentService.java
/** * Handles incoming intents//from ww w. j av a 2 s .c om * * @param intent The Intent sent by Location Services. This Intent is provided to Location Services (inside a * PendingIntent) when you call addGeofences() */ @Override protected void onHandleIntent(Intent intent) { Log.i(TAG, "Geofencing event received"); GeofencingEvent geofencingEvent = GeofencingEvent.fromIntent(intent); // Check for errors if (geofencingEvent.hasError()) { Log.e(TAG, "Error with geofencing. Error Code: " + geofencingEvent.getErrorCode()); } else { // Get the type of transition (entry or leaving_geofence) int geofenceTransition = geofencingEvent.getGeofenceTransition(); Log.i(TAG, "Geofence transition type: " + geofenceTransition); // Test that a valid transition was reported if (geofenceTransition == Geofence.GEOFENCE_TRANSITION_ENTER || geofenceTransition == Geofence.GEOFENCE_TRANSITION_EXIT) { // Post a notification List<Geofence> geofences = geofencingEvent.getTriggeringGeofences(); if (geofences != null && !geofences.isEmpty()) { for (Geofence geofence : geofences) { Log.d(TAG, "Intent information: "); Bundle intentBundle = intent .getBundleExtra(GeofencingConstants.PREFIX_INTENT_BUNDLE + geofence.getRequestId()); if (intentBundle != null) { Log.d(TAG, "Bundle information: "); for (String key : intentBundle.keySet()) { Log.d(TAG, "Key: " + key + ". Value: " + intentBundle.get(key)); } sendNotification(geofence, (GeofenceObject.Notification) intentBundle.getParcelable( GeofencingConstants.PREFIX_INTENT_NOTIFICATION_TRANSITION + geofenceTransition), geofenceTransition); } else { Log.e(TAG, "No bundle found for geofence id " + geofence.getRequestId()); } } } else { Log.e(TAG, "No associated geofences found for transition " + geofenceTransition); } } else { // Log the error. Log.e(TAG, "Geofence transition not supported by the library. Details: " + geofenceTransition); } } }
From source file:com.trk.aboutme.facebook.SharedPreferencesTokenCachingStrategy.java
/** * Persists all supported data types present in the passed in Bundle, to the * cache/*from w ww. ja va 2s . c o m*/ * * @param bundle * The Bundle containing information to be cached */ public void save(Bundle bundle) { Validate.notNull(bundle, "bundle"); SharedPreferences.Editor editor = cache.edit(); for (String key : bundle.keySet()) { try { serializeKey(key, bundle, editor); } catch (JSONException e) { // Error in the bundle. Don't store a partial cache. Logger.log(LoggingBehavior.CACHE, Log.WARN, TAG, "Error processing value for key: '" + key + "' -- " + e); // Bypass the commit and just return. This cancels the entire edit transaction return; } } boolean successfulCommit = editor.commit(); if (!successfulCommit) { Logger.log(LoggingBehavior.CACHE, Log.WARN, TAG, "SharedPreferences.Editor.commit() was not successful"); } }
From source file:org.hfoss.posit.android.plugin.csv.CsvListFindsFragment.java
/** * Attempts to parse a comma-delimited String as a CsvFind object. * This is a simplified version of the method Ryan McLeod wrote for * Sms Plugin./*from w w w .j a v a 2s. c o m*/ * @param csv The comma delimited string * @return A CsvFind object, or null if it couldn't be parsed. */ private CsvFind parseCsvFind(String csv, String mapstring) { String map[] = mapstring.split(","); String values[] = csv.split(","); Log.i(TAG, csv); // Attempt to construct a Find CsvFind find; FindPlugin plugin = FindPluginManager.mFindPlugin; if (plugin == null) { Log.e(TAG, "Could not retrieve Find Plugin."); return null; } find = new CsvFind(); Log.i(TAG, "Processing " + find.getClass()); // Need to get attributes for the Find Bundle bundle = find.getDbEntries(); List<String> keys = new ArrayList<String>(bundle.keySet()); Log.i(TAG, "mapstring=" + mapstring); Log.i(TAG, "keys=" + keys); Log.i(TAG, "values=" + values); for (int i = 0; i < values.length; i++) { String key = map[i]; // Get type of this entry Class<Object> type = null; if (keys.contains(key)) { try { type = find.getType(key); } catch (NoSuchFieldException e) { Log.e(TAG, "Encountered no such field exception on field: " + key); e.printStackTrace(); continue; } } else { continue; } // See if we can decode this value. If not, then we can't make a Find. Serializable obj; try { obj = (Serializable) ObjectCoder.decode(values[i], type); } catch (IllegalArgumentException e) { Log.e(TAG, "Failed to decode value for attribute \"" + key + "\", string was \"" + values[i] + "\""); return null; } // Decode successful! bundle.putSerializable(key, obj); } // Make Find find.updateObject(bundle); return find; }
From source file:com.google.android.apps.authenticator.dataimport.Importer.java
private void importAccountDbFromBundle(Bundle bundle, AccountDb accountDb) { // Each account is stored in a Bundle whose key is a string representing the ordinal (integer) // position of the account in the database. List<String> sortedAccountBundleKeys = new ArrayList<String>(bundle.keySet()); Collections.sort(sortedAccountBundleKeys, new IntegerStringComparator()); int importedAccountCount = 0; for (String accountBundleKey : sortedAccountBundleKeys) { Bundle accountBundle = bundle.getBundle(accountBundleKey); String name = accountBundle.getString(KEY_NAME); if (name == null) { Log.w(LOG_TAG, "Skipping account #" + accountBundleKey + ": name missing"); continue; }/* www. ja va 2s .c o m*/ if (accountDb.nameExists(name)) { // Don't log account name here and below because it's considered PII Log.w(LOG_TAG, "Skipping account #" + accountBundleKey + ": already configured"); continue; } String encodedSecret = accountBundle.getString(KEY_ENCODED_SECRET); if (encodedSecret == null) { Log.w(LOG_TAG, "Skipping account #" + accountBundleKey + ": secret missing"); continue; } String typeString = accountBundle.getString(KEY_TYPE); AccountDb.OtpType type; if ("totp".equals(typeString)) { type = AccountDb.OtpType.TOTP; } else if ("hotp".equals(typeString)) { type = AccountDb.OtpType.HOTP; } else { Log.w(LOG_TAG, "Skipping account #" + accountBundleKey + ": unsupported type: \"" + typeString + "\""); continue; } Integer counter = accountBundle.containsKey(KEY_COUNTER) ? accountBundle.getInt(KEY_COUNTER) : null; if (counter == null) { if (type == AccountDb.OtpType.HOTP) { Log.w(LOG_TAG, "Skipping account #" + accountBundleKey + ": counter missing"); continue; } else { // TOTP counter = AccountDb.DEFAULT_HOTP_COUNTER; } } accountDb.update(name, encodedSecret, name, type, counter); importedAccountCount++; } Log.i(LOG_TAG, "Imported " + importedAccountCount + " accounts"); }