List of usage examples for android.os Bundle getBoolean
public boolean getBoolean(String key)
From source file:com.facebook.internal.LikeActionController.java
private FacebookDialog.Callback getFacebookDialogCallback(final Bundle analyticsParameters) { return new FacebookDialog.Callback() { @Override/*w w w .j a v a2 s .co m*/ public void onComplete(FacebookDialog.PendingCall pendingCall, Bundle data) { if (data == null || !data.containsKey(LIKE_DIALOG_RESPONSE_OBJECT_IS_LIKED_KEY)) { // This is an empty result that we can't handle. return; } boolean isObjectLiked = data.getBoolean(LIKE_DIALOG_RESPONSE_OBJECT_IS_LIKED_KEY); // Default to known/cached state, if properties are missing. String likeCountStringWithLike = LikeActionController.this.likeCountStringWithLike; String likeCountStringWithoutLike = LikeActionController.this.likeCountStringWithoutLike; if (data.containsKey(LIKE_DIALOG_RESPONSE_LIKE_COUNT_STRING_KEY)) { likeCountStringWithLike = data.getString(LIKE_DIALOG_RESPONSE_LIKE_COUNT_STRING_KEY); likeCountStringWithoutLike = likeCountStringWithLike; } String socialSentenceWithLike = LikeActionController.this.socialSentenceWithLike; String socialSentenceWithoutWithoutLike = LikeActionController.this.socialSentenceWithoutLike; if (data.containsKey(LIKE_DIALOG_RESPONSE_SOCIAL_SENTENCE_KEY)) { socialSentenceWithLike = data.getString(LIKE_DIALOG_RESPONSE_SOCIAL_SENTENCE_KEY); socialSentenceWithoutWithoutLike = socialSentenceWithLike; } String unlikeToken = data.containsKey(LIKE_DIALOG_RESPONSE_OBJECT_IS_LIKED_KEY) ? data.getString(LIKE_DIALOG_RESPONSE_UNLIKE_TOKEN_KEY) : LikeActionController.this.unlikeToken; Bundle logParams = (analyticsParameters == null) ? new Bundle() : analyticsParameters; logParams.putString(AnalyticsEvents.PARAMETER_CALL_ID, pendingCall.getCallId().toString()); appEventsLogger.logSdkEvent(AnalyticsEvents.EVENT_LIKE_VIEW_DIALOG_DID_SUCCEED, null, logParams); updateState(isObjectLiked, likeCountStringWithLike, likeCountStringWithoutLike, socialSentenceWithLike, socialSentenceWithoutWithoutLike, unlikeToken); } @Override public void onError(FacebookDialog.PendingCall pendingCall, Exception error, Bundle data) { Logger.log(LoggingBehavior.REQUESTS, TAG, "Like Dialog failed with error : %s", error); Bundle logParams = analyticsParameters == null ? new Bundle() : analyticsParameters; logParams.putString(AnalyticsEvents.PARAMETER_CALL_ID, pendingCall.getCallId().toString()); // Log the error and AppEvent logAppEventForError("present_dialog", logParams); broadcastAction(LikeActionController.this, ACTION_LIKE_ACTION_CONTROLLER_DID_ERROR, data); } }; }
From source file:com.facebook.internal.LikeActionController.java
private void refreshStatusViaService() { LikeStatusClient likeStatusClient = new LikeStatusClient(applicationContext, Settings.getApplicationId(), objectId);//w w w . jav a 2s . c o m if (!likeStatusClient.start()) { return; } LikeStatusClient.CompletedListener callback = new LikeStatusClient.CompletedListener() { @Override public void completed(Bundle result) { // Don't lose old state if the service response is incomplete. if (result == null || !result.containsKey(NativeProtocol.EXTRA_OBJECT_IS_LIKED)) { return; } boolean objectIsLiked = result.getBoolean(NativeProtocol.EXTRA_OBJECT_IS_LIKED); String likeCountWithLike = result.containsKey(NativeProtocol.EXTRA_LIKE_COUNT_STRING_WITH_LIKE) ? result.getString(NativeProtocol.EXTRA_LIKE_COUNT_STRING_WITH_LIKE) : LikeActionController.this.likeCountStringWithLike; String likeCountWithoutLike = result .containsKey(NativeProtocol.EXTRA_LIKE_COUNT_STRING_WITHOUT_LIKE) ? result.getString(NativeProtocol.EXTRA_LIKE_COUNT_STRING_WITHOUT_LIKE) : LikeActionController.this.likeCountStringWithoutLike; String socialSentenceWithLike = result.containsKey(NativeProtocol.EXTRA_SOCIAL_SENTENCE_WITH_LIKE) ? result.getString(NativeProtocol.EXTRA_SOCIAL_SENTENCE_WITH_LIKE) : LikeActionController.this.socialSentenceWithLike; String socialSentenceWithoutLike = result .containsKey(NativeProtocol.EXTRA_SOCIAL_SENTENCE_WITHOUT_LIKE) ? result.getString(NativeProtocol.EXTRA_SOCIAL_SENTENCE_WITHOUT_LIKE) : LikeActionController.this.socialSentenceWithoutLike; String unlikeToken = result.containsKey(NativeProtocol.EXTRA_UNLIKE_TOKEN) ? result.getString(NativeProtocol.EXTRA_UNLIKE_TOKEN) : LikeActionController.this.unlikeToken; updateState(objectIsLiked, likeCountWithLike, likeCountWithoutLike, socialSentenceWithLike, socialSentenceWithoutLike, unlikeToken); } }; likeStatusClient.setCompletedListener(callback); }
From source file:com.facebook.share.internal.LikeActionController.java
private void refreshStatusViaService() { LikeStatusClient likeStatusClient = new LikeStatusClient(FacebookSdk.getApplicationContext(), FacebookSdk.getApplicationId(), objectId); if (!likeStatusClient.start()) { return;/*from w w w . j av a2 s. com*/ } LikeStatusClient.CompletedListener callback = new LikeStatusClient.CompletedListener() { @Override public void completed(Bundle result) { // Don't lose old state if the service response is incomplete. if (result == null || !result.containsKey(ShareConstants.EXTRA_OBJECT_IS_LIKED)) { return; } boolean objectIsLiked = result.getBoolean(ShareConstants.EXTRA_OBJECT_IS_LIKED); String likeCountWithLike = result.containsKey(ShareConstants.EXTRA_LIKE_COUNT_STRING_WITH_LIKE) ? result.getString(ShareConstants.EXTRA_LIKE_COUNT_STRING_WITH_LIKE) : LikeActionController.this.likeCountStringWithLike; String likeCountWithoutLike = result .containsKey(ShareConstants.EXTRA_LIKE_COUNT_STRING_WITHOUT_LIKE) ? result.getString(ShareConstants.EXTRA_LIKE_COUNT_STRING_WITHOUT_LIKE) : LikeActionController.this.likeCountStringWithoutLike; String socialSentenceWithLike = result.containsKey(ShareConstants.EXTRA_SOCIAL_SENTENCE_WITH_LIKE) ? result.getString(ShareConstants.EXTRA_SOCIAL_SENTENCE_WITH_LIKE) : LikeActionController.this.socialSentenceWithLike; String socialSentenceWithoutLike = result .containsKey(ShareConstants.EXTRA_SOCIAL_SENTENCE_WITHOUT_LIKE) ? result.getString(ShareConstants.EXTRA_SOCIAL_SENTENCE_WITHOUT_LIKE) : LikeActionController.this.socialSentenceWithoutLike; String unlikeToken = result.containsKey(ShareConstants.EXTRA_UNLIKE_TOKEN) ? result.getString(ShareConstants.EXTRA_UNLIKE_TOKEN) : LikeActionController.this.unlikeToken; updateState(objectIsLiked, likeCountWithLike, likeCountWithoutLike, socialSentenceWithLike, socialSentenceWithoutLike, unlikeToken); } }; likeStatusClient.setCompletedListener(callback); }
From source file:com.facebook.share.internal.LikeActionController.java
private ResultProcessor getResultProcessor(final Bundle analyticsParameters) { return new ResultProcessor(null) { @Override/* w ww . j a v a 2s .c o m*/ public void onSuccess(AppCall appCall, Bundle data) { if (data == null || !data.containsKey(LIKE_DIALOG_RESPONSE_OBJECT_IS_LIKED_KEY)) { // This is an empty result that we can't handle. return; } boolean isObjectLiked = data.getBoolean(LIKE_DIALOG_RESPONSE_OBJECT_IS_LIKED_KEY); // Default to known/cached state, if properties are missing. String likeCountStringWithLike = LikeActionController.this.likeCountStringWithLike; String likeCountStringWithoutLike = LikeActionController.this.likeCountStringWithoutLike; if (data.containsKey(LIKE_DIALOG_RESPONSE_LIKE_COUNT_STRING_KEY)) { likeCountStringWithLike = data.getString(LIKE_DIALOG_RESPONSE_LIKE_COUNT_STRING_KEY); likeCountStringWithoutLike = likeCountStringWithLike; } String socialSentenceWithLike = LikeActionController.this.socialSentenceWithLike; String socialSentenceWithoutWithoutLike = LikeActionController.this.socialSentenceWithoutLike; if (data.containsKey(LIKE_DIALOG_RESPONSE_SOCIAL_SENTENCE_KEY)) { socialSentenceWithLike = data.getString(LIKE_DIALOG_RESPONSE_SOCIAL_SENTENCE_KEY); socialSentenceWithoutWithoutLike = socialSentenceWithLike; } String unlikeToken = data.containsKey(LIKE_DIALOG_RESPONSE_OBJECT_IS_LIKED_KEY) ? data.getString(LIKE_DIALOG_RESPONSE_UNLIKE_TOKEN_KEY) : LikeActionController.this.unlikeToken; Bundle logParams = (analyticsParameters == null) ? new Bundle() : analyticsParameters; logParams.putString(AnalyticsEvents.PARAMETER_CALL_ID, appCall.getCallId().toString()); getAppEventsLogger().logSdkEvent(AnalyticsEvents.EVENT_LIKE_VIEW_DIALOG_DID_SUCCEED, null, logParams); updateState(isObjectLiked, likeCountStringWithLike, likeCountStringWithoutLike, socialSentenceWithLike, socialSentenceWithoutWithoutLike, unlikeToken); } @Override public void onError(AppCall appCall, FacebookException error) { Logger.log(LoggingBehavior.REQUESTS, TAG, "Like Dialog failed with error : %s", error); Bundle logParams = analyticsParameters == null ? new Bundle() : analyticsParameters; logParams.putString(AnalyticsEvents.PARAMETER_CALL_ID, appCall.getCallId().toString()); // Log the error and AppEvent logAppEventForError("present_dialog", logParams); broadcastAction(LikeActionController.this, ACTION_LIKE_ACTION_CONTROLLER_DID_ERROR, NativeProtocol.createBundleForException(error)); } @Override public void onCancel(AppCall appCall) { onError(appCall, new FacebookOperationCanceledException()); } }; }
From source file:com.android.contacts.common.list.ContactListItemView.java
/** * Shows search snippet.//from w w w .ja va2 s .co m */ public void showSnippet(Cursor cursor, int summarySnippetColumnIndex) { if (cursor.getColumnCount() <= summarySnippetColumnIndex || !SearchSnippets.SNIPPET.equals(cursor.getColumnName(summarySnippetColumnIndex))) { setSnippet(null); return; } String snippet = cursor.getString(summarySnippetColumnIndex); // Do client side snippeting if provider didn't do it final Bundle extras = cursor.getExtras(); if (extras.getBoolean(ContactsContract.DEFERRED_SNIPPETING)) { final String query = extras.getString(ContactsContract.DEFERRED_SNIPPETING_QUERY); String displayName = null; int displayNameIndex = cursor.getColumnIndex(Contacts.DISPLAY_NAME); if (displayNameIndex >= 0) { displayName = cursor.getString(displayNameIndex); } snippet = updateSnippet(snippet, query, displayName); } else { if (snippet != null) { int from = 0; int to = snippet.length(); int start = snippet.indexOf(DefaultContactListAdapter.SNIPPET_START_MATCH); if (start == -1) { snippet = null; } else { int firstNl = snippet.lastIndexOf('\n', start); if (firstNl != -1) { from = firstNl + 1; } int end = snippet.lastIndexOf(DefaultContactListAdapter.SNIPPET_END_MATCH); if (end != -1) { int lastNl = snippet.indexOf('\n', end); if (lastNl != -1) { to = lastNl; } } StringBuilder sb = new StringBuilder(); for (int i = from; i < to; i++) { char c = snippet.charAt(i); if (c != DefaultContactListAdapter.SNIPPET_START_MATCH && c != DefaultContactListAdapter.SNIPPET_END_MATCH) { sb.append(c); } } snippet = sb.toString(); } } } setSnippet(snippet); }
From source file:com.facebook.LegacyTokenCacheTest.java
@Test public void testAllTypes() { Bundle originalBundle = new Bundle(); putBoolean(BOOLEAN_KEY, originalBundle); putBooleanArray(BOOLEAN_ARRAY_KEY, originalBundle); putByte(BYTE_KEY, originalBundle);/* w ww.ja v a 2 s .c o m*/ putByteArray(BYTE_ARRAY_KEY, originalBundle); putShort(SHORT_KEY, originalBundle); putShortArray(SHORT_ARRAY_KEY, originalBundle); putInt(INT_KEY, originalBundle); putIntArray(INT_ARRAY_KEY, originalBundle); putLong(LONG_KEY, originalBundle); putLongArray(LONG_ARRAY_KEY, originalBundle); putFloat(FLOAT_KEY, originalBundle); putFloatArray(FLOAT_ARRAY_KEY, originalBundle); putDouble(DOUBLE_KEY, originalBundle); putDoubleArray(DOUBLE_ARRAY_KEY, originalBundle); putChar(CHAR_KEY, originalBundle); putCharArray(CHAR_ARRAY_KEY, originalBundle); putString(STRING_KEY, originalBundle); putStringList(STRING_LIST_KEY, originalBundle); originalBundle.putSerializable(SERIALIZABLE_KEY, AccessTokenSource.FACEBOOK_APPLICATION_WEB); ensureApplicationContext(); LegacyTokenHelper cache = new LegacyTokenHelper(RuntimeEnvironment.application); cache.save(originalBundle); LegacyTokenHelper cache2 = new LegacyTokenHelper(RuntimeEnvironment.application); Bundle cachedBundle = cache2.load(); assertEquals(originalBundle.getBoolean(BOOLEAN_KEY), cachedBundle.getBoolean(BOOLEAN_KEY)); assertArrayEquals(originalBundle.getBooleanArray(BOOLEAN_ARRAY_KEY), cachedBundle.getBooleanArray(BOOLEAN_ARRAY_KEY)); assertEquals(originalBundle.getByte(BYTE_KEY), cachedBundle.getByte(BYTE_KEY)); assertArrayEquals(originalBundle.getByteArray(BYTE_ARRAY_KEY), cachedBundle.getByteArray(BYTE_ARRAY_KEY)); assertEquals(originalBundle.getShort(SHORT_KEY), cachedBundle.getShort(SHORT_KEY)); assertArrayEquals(originalBundle.getShortArray(SHORT_ARRAY_KEY), cachedBundle.getShortArray(SHORT_ARRAY_KEY)); assertEquals(originalBundle.getInt(INT_KEY), cachedBundle.getInt(INT_KEY)); assertArrayEquals(originalBundle.getIntArray(INT_ARRAY_KEY), cachedBundle.getIntArray(INT_ARRAY_KEY)); assertEquals(originalBundle.getLong(LONG_KEY), cachedBundle.getLong(LONG_KEY)); assertArrayEquals(originalBundle.getLongArray(LONG_ARRAY_KEY), cachedBundle.getLongArray(LONG_ARRAY_KEY)); assertEquals(originalBundle.getFloat(FLOAT_KEY), cachedBundle.getFloat(FLOAT_KEY), TestUtils.DOUBLE_EQUALS_DELTA); assertArrayEquals(originalBundle.getFloatArray(FLOAT_ARRAY_KEY), cachedBundle.getFloatArray(FLOAT_ARRAY_KEY)); assertEquals(originalBundle.getDouble(DOUBLE_KEY), cachedBundle.getDouble(DOUBLE_KEY), TestUtils.DOUBLE_EQUALS_DELTA); assertArrayEquals(originalBundle.getDoubleArray(DOUBLE_ARRAY_KEY), cachedBundle.getDoubleArray(DOUBLE_ARRAY_KEY)); assertEquals(originalBundle.getChar(CHAR_KEY), cachedBundle.getChar(CHAR_KEY)); assertArrayEquals(originalBundle.getCharArray(CHAR_ARRAY_KEY), cachedBundle.getCharArray(CHAR_ARRAY_KEY)); assertEquals(originalBundle.getString(STRING_KEY), cachedBundle.getString(STRING_KEY)); assertListEquals(originalBundle.getStringArrayList(STRING_LIST_KEY), cachedBundle.getStringArrayList(STRING_LIST_KEY)); assertEquals(originalBundle.getSerializable(SERIALIZABLE_KEY), cachedBundle.getSerializable(SERIALIZABLE_KEY)); }
From source file:com.airbnb.rxgroups.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); startStop = (FloatingActionButton) findViewById(R.id.fab); lockUnlock = (FloatingActionButton) findViewById(R.id.fab_pause_resume); alarmOffDrawable = ContextCompat.getDrawable(this, R.drawable.ic_alarm_off_black_24dp); alarmDrawable = ContextCompat.getDrawable(this, R.drawable.ic_alarm_black_24dp); lockDrawable = ContextCompat.getDrawable(this, R.drawable.ic_lock_outline_black_24dp); unlockDrawable = ContextCompat.getDrawable(this, R.drawable.ic_lock_open_black_24dp); output = (TextView) findViewById(R.id.txt_output); setSupportActionBar(toolbar);/*from www . j av a 2 s . c om*/ startStop.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { onClickStartStopTimer(v); } }); lockUnlock.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { onClickLockUnlockGroup(v); } }); SampleApplication application = (SampleApplication) getApplication(); ObservableManager manager = application.observableManager(); groupLifecycleManager = GroupLifecycleManager.onCreate(manager, savedInstanceState, this); timerObservable = application.timerObservable(); observableGroup = groupLifecycleManager.group(); if (savedInstanceState != null && savedInstanceState.getBoolean(IS_RUNNING)) { isRunning = true; startStop.setImageDrawable(alarmOffDrawable); } }
From source file:se.leap.bitmaskclient.ProviderAPI.java
/** * Downloads a provider.json from a given URL, adding a new provider using the given name. * * @param task containing a boolean meaning if the provider is custom or not, another boolean meaning if the user completely trusts this provider, the provider name and its provider.json url. * @return a bundle with a boolean value mapped to a key named RESULT_KEY, and which is true if the update was successful. *///from w w w . jav a2s .c om private Bundle setUpProvider(Bundle task) { int progress = 0; Bundle current_download = new Bundle(); if (task != null && task.containsKey(Provider.MAIN_URL)) { last_provider_main_url = task.containsKey(Provider.MAIN_URL) ? task.getString(Provider.MAIN_URL) : ""; provider_ca_cert_fingerprint = task.containsKey(Provider.CA_CERT_FINGERPRINT) ? task.getString(Provider.CA_CERT_FINGERPRINT) : ""; CA_CERT_DOWNLOADED = PROVIDER_JSON_DOWNLOADED = EIP_SERVICE_JSON_DOWNLOADED = false; go_ahead = true; } if (!PROVIDER_JSON_DOWNLOADED) current_download = getAndSetProviderJson(last_provider_main_url, provider_ca_cert_fingerprint); if (PROVIDER_JSON_DOWNLOADED || (current_download.containsKey(RESULT_KEY) && current_download.getBoolean(RESULT_KEY))) { broadcastProgress(progress++); PROVIDER_JSON_DOWNLOADED = true; if (!CA_CERT_DOWNLOADED) current_download = downloadCACert(); if (CA_CERT_DOWNLOADED || (current_download.containsKey(RESULT_KEY) && current_download.getBoolean(RESULT_KEY))) { broadcastProgress(progress++); CA_CERT_DOWNLOADED = true; current_download = getAndSetEipServiceJson(); if (current_download.containsKey(RESULT_KEY) && current_download.getBoolean(RESULT_KEY)) { broadcastProgress(progress++); EIP_SERVICE_JSON_DOWNLOADED = true; } } } return current_download; }
From source file:fr.bde_eseo.eseomega.lydia.LydiaActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { // Set view / call parent super.onCreate(savedInstanceState); setContentView(R.layout.activity_lydia); context = this; // Init intent flag INTENT_REQUEST intent_request = INTENT_REQUEST.ERROR; // Get intent parameters if (savedInstanceState == null) { Intent intent = getIntent();/*from w ww . j av a2 s .c om*/ Bundle extras = intent.getExtras(); String action = intent.getAction(); if (action != null) { // Check if intent's action is correct (obviously yes, but prevents Manifest modifications) if (action.equals(Intent.ACTION_VIEW)) { // Intent depuis Lydia intent_request = INTENT_REQUEST.FROM_LYDIA; // Get all parameters Uri qUri = intent.getData(); // Order ID String sOrderID = qUri.getQueryParameter("id"); if (sOrderID != null) { orderID = Integer.parseInt(sOrderID); } orderType = qUri.getQueryParameter("cat"); } } else if (extras != null) { // Intent interne intent_request = INTENT_REQUEST.FROM_APP; orderID = extras.getInt(Constants.KEY_LYDIA_ORDER_ID); orderType = extras.getString(Constants.KEY_LYDIA_ORDER_TYPE); // Demande de check ? donc ask dj effectu if (extras.getBoolean(Constants.KEY_LYDIA_ORDER_ASKED)) { intent_request = INTENT_REQUEST.FROM_LYDIA; } } } // No intent received if (intent_request == INTENT_REQUEST.ERROR || orderID == -1) { Toast.makeText(context, "Erreur de l'application (c'est pas normal)", Toast.LENGTH_SHORT).show(); close(); } // Get objects userProfile = new UserProfile(); userProfile.readProfilePromPrefs(context); prefsUser = PreferenceManager.getDefaultSharedPreferences(getBaseContext()); // Init dialog dialogInit(); // Get intent type if (intent_request == INTENT_REQUEST.FROM_APP) { /** * FROM_APP : On doit demander le numro de tlphone du client, puis lorsqu'il clique sur "Payer", effectuer une demande de paiement auprs de Lydia. * Il faut ensuite lancer l'Intent vers Lydia avec le bon numro de requte. * * A afficher : * - InputText tlphone * - Checkbox mmorisation numro * - Texte "lgal" sur le numro de tlphone * - Boutons Annuler / Valider AsyncTask ask.php */ dialogFromApp(); } else { /** * FROM_LYDIA : L'activit vient d'tre ouverte aprs que le client ait cliqu sur "Accepter" depuis l'app Lydia. * Dans 100% des cas, le retour notre activit se fait si il a eu un paiement valid. * Cependant, on vrifiera le statut de la commande auprs de notre serveur malgr tout. * * A afficher : * - Texte "tat de votre commande" titre dialogue * - Texte status : actualis toutes les 3 secondes asyncTask * - Bouton Fermer si status diffrent de "en cours" */ dialogFromLydia(); } }