List of usage examples for android.os Bundle containsKey
public boolean containsKey(String key)
From source file:com.facebook.internal.LikeActionController.java
private FacebookDialog.Callback getFacebookDialogCallback(final Bundle analyticsParameters) { return new FacebookDialog.Callback() { @Override/*from w w w . j a v a2 s. c o 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.irccloud.android.activity.PastebinsActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (Build.VERSION.SDK_INT >= 21) { Bitmap cloud = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher); setTaskDescription(new ActivityManager.TaskDescription(getResources().getString(R.string.app_name), cloud, 0xFFF2F7FC));/* w ww .ja v a2s . c o m*/ cloud.recycle(); } setContentView(R.layout.ignorelist); if (getSupportActionBar() != null) { getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setHomeAsUpIndicator(R.drawable.abc_ic_ab_back_mtrl_am_alpha); getSupportActionBar().setBackgroundDrawable(getResources().getDrawable(R.drawable.actionbar)); getSupportActionBar().setElevation(0); } if (savedInstanceState != null && savedInstanceState.containsKey("adapter")) { try { page = savedInstanceState.getInt("page"); Pastebin[] pastebins = (Pastebin[]) savedInstanceState.getSerializable("adapter"); for (Pastebin p : pastebins) { adapter.addPastebin(p); } adapter.notifyDataSetChanged(); } catch (Exception e) { page = 0; adapter.clear(); } } footer = getLayoutInflater().inflate(R.layout.messageview_header, null); ListView listView = (ListView) findViewById(android.R.id.list); listView.setAdapter(adapter); listView.addFooterView(footer); listView.setOnScrollListener(new AbsListView.OnScrollListener() { @Override public void onScrollStateChanged(AbsListView absListView, int i) { } @Override public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { if (canLoadMore && firstVisibleItem + visibleItemCount > totalItemCount - 4) { canLoadMore = false; new FetchPastebinsTask().execute((Void) null); } } }); listView.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) { } @Override public void onNothingSelected(AdapterView<?> adapterView) { } }); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { final Pastebin p = (Pastebin) adapter.getItem(i); Intent intent = new Intent(PastebinsActivity.this, PastebinViewerActivity.class); intent.setData(Uri.parse(p.url + "?id=" + p.id + "&own_paste=" + (p.own_paste ? "1" : "0"))); startActivity(intent); } }); Toast.makeText(this, "Tap a pastebin to view full text with syntax highlighting", Toast.LENGTH_LONG).show(); }
From source file:ca.rmen.android.palidamuerte.app.poem.list.PoemListFragment.java
@Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); ListView listView = getListView(); ViewGroup parent = (ViewGroup) listView.getParent(); final View emptyListView; String searchTerms = getActivity().getIntent().getStringExtra(SearchManager.QUERY); if (!TextUtils.isEmpty(searchTerms)) { emptyListView = getActivity().getLayoutInflater().inflate(R.layout.empty_search_list, parent, false); String[] keyWords = Search.getSearchTerms(searchTerms); ((TextView) emptyListView.findViewById(R.id.empty_search_list_description)).setText(getResources() .getQuantityString(R.plurals.empty_search_list_description, keyWords.length, searchTerms)); } else {//from www .j a v a2 s . c o m emptyListView = getActivity().getLayoutInflater().inflate(R.layout.empty_favorite_list, parent, false); } TextView emptyTitle = (TextView) emptyListView.findViewById(R.id.title); emptyTitle.setTypeface(Font.getTypeface(getActivity())); parent.addView(emptyListView); listView.setEmptyView(emptyListView); // Restore the previously serialized activated item position. if (savedInstanceState != null && savedInstanceState.containsKey(STATE_ACTIVATED_POSITION)) { setActivatedPosition(savedInstanceState.getInt(STATE_ACTIVATED_POSITION)); } }
From source file:jp.mixi.android.sdk.MixiContainerImpl.java
/** * ?//from w ww . ja va2s . c om * * @throws RemoteException * @throws ApiException */ private synchronized void refreshToken() throws RemoteException, ApiException { Log.v(TAG, "refreshToken start"); Bundle bundle = new Bundle(); bundle.putString(REFRESH_TOKEN, getRefreshToken()); bundle.putString(CLIENT_ID, mClientId); // ????? if (mRemoteAuth == null) { Log.v(TAG, "RemoteAuthenticator is not bind"); throw new ApiException(ErrorInfo.OFFICIAL_APP_NOT_FOUND, "RemoteAuthenticator is not bind"); } Bundle response = mRemoteAuth.tokenRefresh(bundle); if (response.containsKey(ERROR_STR)) { Log.w(TAG, response.getString(ERROR_STR)); throw new ApiException(response.getInt(ERROR_CODE_STR), response.getString(ERROR_MESSAGE_STR)); } String accessToken = response.getString(ACCESS_TOKEN); String refreshToken = response.getString(REFRESH_TOKEN); String expire = response.getString(EXPIRES); setAccessToken(accessToken); setRefreshToken(refreshToken); setAccessExpiresIn(expire); if (mContextWrapper != null) { saveSession(mContextWrapper); } }
From source file:com.smartmobilesoftware.util.IabHelper.java
int queryPurchases(Inventory inv, String itemType) throws JSONException, RemoteException, NullPointerException { // Query purchases logDebug("Querying owned items, item type: " + itemType); logDebug("Package name: " + mContext.getPackageName()); boolean verificationFailed = false; String continueToken = null;/*from w w w.j av a2 s . c o m*/ do { logDebug("Calling getPurchases with continuation token: " + continueToken); Bundle ownedItems = mService.getPurchases(3, mContext.getPackageName(), itemType, continueToken); int response = getResponseCodeFromBundle(ownedItems); logDebug("Owned items response: " + String.valueOf(response)); if (response != BILLING_RESPONSE_RESULT_OK) { logDebug("getPurchases() failed: " + getResponseDesc(response)); return response; } if (!ownedItems.containsKey(RESPONSE_INAPP_ITEM_LIST) || !ownedItems.containsKey(RESPONSE_INAPP_PURCHASE_DATA_LIST) || !ownedItems.containsKey(RESPONSE_INAPP_SIGNATURE_LIST)) { logError("Bundle returned from getPurchases() doesn't contain required fields."); return ERR_BAD_RESPONSE; } ArrayList<String> ownedSkus = ownedItems.getStringArrayList(RESPONSE_INAPP_ITEM_LIST); ArrayList<String> purchaseDataList = ownedItems.getStringArrayList(RESPONSE_INAPP_PURCHASE_DATA_LIST); ArrayList<String> signatureList = ownedItems.getStringArrayList(RESPONSE_INAPP_SIGNATURE_LIST); for (int i = 0; i < purchaseDataList.size(); ++i) { String purchaseData = purchaseDataList.get(i); String signature = signatureList.get(i); String sku = ownedSkus.get(i); if (Security.verifyPurchase(mSignatureBase64, purchaseData, signature)) { logDebug("Sku is owned: " + sku); Purchase purchase = new Purchase(itemType, purchaseData, signature); if (TextUtils.isEmpty(purchase.getToken())) { logWarn("BUG: empty/null token!"); logDebug("Purchase data: " + purchaseData); } // Record ownership and token inv.addPurchase(purchase); } else { logWarn("Purchase signature verification **FAILED**. Not adding item."); logDebug(" Purchase data: " + purchaseData); logDebug(" Signature: " + signature); verificationFailed = true; } } continueToken = ownedItems.getString(INAPP_CONTINUATION_TOKEN); logDebug("Continuation token: " + continueToken); } while (!TextUtils.isEmpty(continueToken)); return verificationFailed ? ERR_VERIFICATION_FAILED : BILLING_RESPONSE_RESULT_OK; }
From source file:in.blogspot.anselmbros.torchie.donate.IabHelper.java
int queryPurchases(Inventory inv, String itemType) throws JSONException, RemoteException { // Query purchases logDebug("Querying owned items, item type: " + itemType); try {// w w w.j a v a 2 s. co m logDebug("Package name: " + mContext.getPackageName());// Sometimes Null pointer Exception arises as mContext becomes 'null' } catch (Exception e) { } boolean verificationFailed = false; String continueToken = null; do { logDebug("Calling getPurchases with continuation token: " + continueToken); Bundle ownedItems = mService.getPurchases(3, mContext.getPackageName(), itemType, continueToken); int response = getResponseCodeFromBundle(ownedItems); logDebug("Owned items response: " + String.valueOf(response)); if (response != BILLING_RESPONSE_RESULT_OK) { logDebug("getPurchases() failed: " + getResponseDesc(response)); return response; } if (!ownedItems.containsKey(RESPONSE_INAPP_ITEM_LIST) || !ownedItems.containsKey(RESPONSE_INAPP_PURCHASE_DATA_LIST) || !ownedItems.containsKey(RESPONSE_INAPP_SIGNATURE_LIST)) { logError("Bundle returned from getPurchases() doesn't contain required fields."); return IABHELPER_BAD_RESPONSE; } ArrayList<String> ownedSkus = ownedItems.getStringArrayList(RESPONSE_INAPP_ITEM_LIST); ArrayList<String> purchaseDataList = ownedItems.getStringArrayList(RESPONSE_INAPP_PURCHASE_DATA_LIST); ArrayList<String> signatureList = ownedItems.getStringArrayList(RESPONSE_INAPP_SIGNATURE_LIST); for (int i = 0; i < purchaseDataList.size(); ++i) { String purchaseData = purchaseDataList.get(i); String signature = signatureList.get(i); String sku = ownedSkus.get(i); if (Security.verifyPurchase(mSignatureBase64, purchaseData, signature)) { logDebug("Sku is owned: " + sku); Purchase purchase = new Purchase(itemType, purchaseData, signature); if (TextUtils.isEmpty(purchase.getToken())) { logWarn("BUG: empty/null token!"); logDebug("Purchase data: " + purchaseData); } // Record ownership and token inv.addPurchase(purchase); } else { logWarn("Purchase signature verification **FAILED**. Not adding item."); logDebug(" Purchase data: " + purchaseData); logDebug(" Signature: " + signature); verificationFailed = true; } } continueToken = ownedItems.getString(INAPP_CONTINUATION_TOKEN); logDebug("Continuation token: " + continueToken); } while (!TextUtils.isEmpty(continueToken)); return verificationFailed ? IABHELPER_VERIFICATION_FAILED : BILLING_RESPONSE_RESULT_OK; }
From source file:cc.mintcoin.wallet.ui.SendCoinsFragment.java
private void restoreInstanceState(final Bundle savedInstanceState) { paymentIntent = (PaymentIntent) savedInstanceState.getParcelable("payment_intent"); state = (State) savedInstanceState.getSerializable("state"); validatedAddress = savedInstanceState.getParcelable("validated_address"); if (savedInstanceState.containsKey("sent_transaction_hash")) { sentTransaction = wallet// www . java 2 s . co m .getTransaction((Sha256Hash) savedInstanceState.getSerializable("sent_transaction_hash")); sentTransaction.getConfidence().addEventListener(sentTransactionConfidenceListener); } if (savedInstanceState.containsKey("direct_payment_ack")) directPaymentAck = savedInstanceState.getBoolean("direct_payment_ack"); }
From source file:com.zdf.test_magiccam_iap.util.IabHelper.java
int queryPurchases(Inventory inv, String itemType) throws JSONException, RemoteException { // Query purchases logDebug("Querying owned items, item type: " + itemType); logDebug("Package name: " + mContext.getPackageName()); boolean verificationFailed = false; String continueToken = null;/* w w w. ja v a2 s .co m*/ do { logDebug("Calling getPurchases with continuation token: " + continueToken); Bundle ownedItems = mService.getPurchases(3, mContext.getPackageName(), itemType, continueToken); logDebug("Owned items: " + ownedItems); int response = getResponseCodeFromBundle(ownedItems); logDebug("Owned items response: " + String.valueOf(response)); if (response != BILLING_RESPONSE_RESULT_OK) { logDebug("getPurchases() failed: " + getResponseDesc(response)); return response; } if (!ownedItems.containsKey(RESPONSE_INAPP_ITEM_LIST) || !ownedItems.containsKey(RESPONSE_INAPP_PURCHASE_DATA_LIST) || !ownedItems.containsKey(RESPONSE_INAPP_SIGNATURE_LIST)) { logError("Bundle returned from getPurchases() doesn't contain required fields."); return IABHELPER_BAD_RESPONSE; } logDebug("Owned items 2: " + ownedItems); ArrayList<String> ownedSkus = ownedItems.getStringArrayList(RESPONSE_INAPP_ITEM_LIST); ArrayList<String> purchaseDataList = ownedItems.getStringArrayList(RESPONSE_INAPP_PURCHASE_DATA_LIST); ArrayList<String> signatureList = ownedItems.getStringArrayList(RESPONSE_INAPP_SIGNATURE_LIST); for (int i = 0; i < purchaseDataList.size(); ++i) { String purchaseData = purchaseDataList.get(i); String signature = signatureList.get(i); String sku = ownedSkus.get(i); if (Security.verifyPurchase(mSignatureBase64, purchaseData, signature)) { logDebug("Sku is owned: " + sku); Purchase purchase = new Purchase(itemType, purchaseData, signature); if (TextUtils.isEmpty(purchase.getToken())) { logWarn("BUG: empty/null token!"); logDebug("Purchase data: " + purchaseData); } // Record ownership and token inv.addPurchase(purchase); } else { logWarn("Purchase signature verification **FAILED**. Not adding item."); logDebug(" Purchase data: " + purchaseData); logDebug(" Signature: " + signature); verificationFailed = true; } } continueToken = ownedItems.getString(INAPP_CONTINUATION_TOKEN); logDebug("Continuation token: " + continueToken); } while (!TextUtils.isEmpty(continueToken)); return verificationFailed ? IABHELPER_VERIFICATION_FAILED : BILLING_RESPONSE_RESULT_OK; }
From source file:com.tafayor.selfcamerashot.taflib.iab.util.IabHelper.java
int queryPurchases(Inventory inv, String itemType) throws JSONException, RemoteException { if (mDisposed) return -1; // Query purchases logDebug("Querying owned items, item type: " + itemType); logDebug("Package name: " + mContext.getPackageName()); boolean verificationFailed = false; String continueToken = null;// w ww . ja v a 2 s . co m do { logDebug("Calling getPurchases with continuation token: " + continueToken); Bundle ownedItems = mService.getPurchases(3, mContext.getPackageName(), itemType, continueToken); int response = getResponseCodeFromBundle(ownedItems); logDebug("Owned items response: " + String.valueOf(response)); if (response != BILLING_RESPONSE_RESULT_OK) { logDebug("getPurchases() failed: " + getResponseDesc(response)); return response; } if (!ownedItems.containsKey(RESPONSE_INAPP_ITEM_LIST) || !ownedItems.containsKey(RESPONSE_INAPP_PURCHASE_DATA_LIST) || !ownedItems.containsKey(RESPONSE_INAPP_SIGNATURE_LIST)) { logError("Bundle returned from getPurchases() doesn't contain required fields."); return IABHELPER_BAD_RESPONSE; } ArrayList<String> ownedSkus = ownedItems.getStringArrayList(RESPONSE_INAPP_ITEM_LIST); ArrayList<String> purchaseDataList = ownedItems.getStringArrayList(RESPONSE_INAPP_PURCHASE_DATA_LIST); ArrayList<String> signatureList = ownedItems.getStringArrayList(RESPONSE_INAPP_SIGNATURE_LIST); for (int i = 0; i < purchaseDataList.size(); ++i) { String purchaseData = purchaseDataList.get(i); String signature = signatureList.get(i); String sku = ownedSkus.get(i); if (Security.verifyPurchase(mSignatureBase64, purchaseData, signature)) { logDebug("Sku is owned: " + sku); Purchase purchase = new Purchase(itemType, purchaseData, signature); if (TextUtils.isEmpty(purchase.getToken())) { logWarn("BUG: empty/null token!"); logDebug("Purchase data: " + purchaseData); } // Record ownership and token inv.addPurchase(purchase); } else { logWarn("Purchase signature verification **FAILED**. Not adding item."); logDebug(" Purchase data: " + purchaseData); logDebug(" Signature: " + signature); verificationFailed = true; } } continueToken = ownedItems.getString(INAPP_CONTINUATION_TOKEN); logDebug("Continuation token: " + continueToken); } while (!TextUtils.isEmpty(continueToken)); return verificationFailed ? IABHELPER_VERIFICATION_FAILED : BILLING_RESPONSE_RESULT_OK; }
From source file:com.facebook.share.internal.LikeActionController.java
private ResultProcessor getResultProcessor(final Bundle analyticsParameters) { return new ResultProcessor(null) { @Override/*from w ww. java 2 s.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()); } }; }