Example usage for android.os Bundle getStringArrayList

List of usage examples for android.os Bundle getStringArrayList

Introduction

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

Prototype

@Override
@Nullable
public ArrayList<String> getStringArrayList(@Nullable String key) 

Source Link

Document

Returns the value associated with the given key, or null if no mapping of the desired type exists for the given key or a null value is explicitly associated with the key.

Usage

From source file:org.botlibre.sdk.activity.ChatActivity.java

@Override
public void onResults(Bundle results) {
    debug("onResults:");
    muteMicBeep(false);//from  w w  w  .  j a  v  a 2s . c om
    List<String> text = results.getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION);
    this.textView.setText(text.get(0));
    submitChat();
}

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;//from  w w  w. j a  v  a2  s . c o  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:de.geithonline.abattlwp.billinghelper.IabHelper.java

int queryPurchases(final Inventory inv, final 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  ww  .  j  a  v a 2  s. c om*/

    do {
        logDebug("Calling getPurchases with continuation token: " + continueToken);
        final Bundle ownedItems = mService.getPurchases(3, mContext.getPackageName(), itemType, continueToken);

        final 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;
        }

        final ArrayList<String> ownedSkus = ownedItems.getStringArrayList(RESPONSE_INAPP_ITEM_LIST);
        final ArrayList<String> purchaseDataList = ownedItems
                .getStringArrayList(RESPONSE_INAPP_PURCHASE_DATA_LIST);
        final ArrayList<String> signatureList = ownedItems.getStringArrayList(RESPONSE_INAPP_SIGNATURE_LIST);

        for (int i = 0; i < purchaseDataList.size(); ++i) {
            final String purchaseData = purchaseDataList.get(i);
            final String signature = signatureList.get(i);
            final String sku = ownedSkus.get(i);
            if (Security.verifyPurchase(mSignatureBase64, purchaseData, signature)) {
                logDebug("Sku is owned: " + sku);
                final 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.kyleshaver.minuteofangle.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;

        do {//from   www.j  ava2  s.  co m
            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.dreamfarmgames.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  .j  a v  a2  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.vPurchase(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.skubit.android.billing.BillingServiceBinder.java

@Override
public Bundle getSkuDetails(int apiVersion, String userId, String packageName, String type, Bundle skusBundle)
        throws RemoteException {
    Bundle bundle = new Bundle();
    if (TextUtils.isEmpty(packageName) || TextUtils.isEmpty(type)) {
        bundle.putInt("RESPONSE_CODE", BillingResponseCodes.RESULT_DEVELOPER_ERROR);
        return bundle;
    }//from   www.j  ava2 s.c  o  m

    if (apiVersion != 1) {
        bundle.putInt("RESPONSE_CODE", BillingResponseCodes.RESULT_BILLING_UNAVAILABLE);
        return bundle;
    }

    if (skusBundle == null || !skusBundle.containsKey("ITEM_ID_LIST")) {
        bundle.putInt("RESPONSE_CODE", BillingResponseCodes.RESULT_DEVELOPER_ERROR);
        return bundle;
    }

    if (!isValidType(type)) {
        bundle.putInt("RESPONSE_CODE", BillingResponseCodes.RESULT_BILLING_UNAVAILABLE);
        return bundle;
    }

    int packValidate = validatePackageIsOwnedByCaller(packageName);
    if (packValidate != BillingResponseCodes.RESULT_OK) {
        bundle.putInt("RESPONSE_CODE", packValidate);
        return bundle;
    }

    String account = userId;
    if (!hasAccess(userId, packageName)) {
        Log.d(TAG, "User account not configured");
        bundle.putInt("RESPONSE_CODE", BillingResponseCodes.RESULT_USER_ACCESS);
        return bundle;
    }
    Utils.changeAccount(mContext, userId);

    InventoryRestService service = new InventoryService(account, mContext).getRestService();

    ArrayList<String> itemIds = skusBundle.getStringArrayList("ITEM_ID_LIST");
    SkuDetailsListDto skuDetailsListDto = null;

    try {
        skuDetailsListDto = service.getSkuDetailsByIds(packageName, Joiner.on(",").join(itemIds));
    } catch (Exception e1) {
        e1.printStackTrace();
        bundle.putInt("RESPONSE_CODE", BillingResponseCodes.RESULT_ERROR);
    }

    ArrayList<String> details = new ArrayList<String>();
    for (SkuDetailsDto skuDetailsDto : skuDetailsListDto.getItems()) {
        JSONObject jo = new JSONObject();
        try {
            jo.put("productId", skuDetailsDto.getProductId());
            jo.put("type", skuDetailsDto.getType().name());
            jo.put("price", String.valueOf(skuDetailsDto.getSatoshi()));
            jo.put("title", skuDetailsDto.getTitle());
            jo.put("description", skuDetailsDto.getDescription());
        } catch (JSONException e) {
            e.printStackTrace();
        }
        details.add(jo.toString());
    }

    bundle.putStringArrayList("DETAILS_LIST", details);
    bundle.putInt("RESPONSE_CODE", BillingResponseCodes.RESULT_OK);

    return bundle;
}

From source file:org.planetmono.dcuploader.ActivityUploader.java

@SuppressWarnings("unchecked")
@Override//  w  w w  . j  a va  2 s.c  o m
public void onCreate(Bundle savedState) {
    super.onCreate(savedState);

    initViews();
    if (formLocation)
        queryLocation(true);

    if (savedState != null) {
        if (savedState.containsKey("tempfile"))
            tempFile = new File(savedState.getString("tempfile"));
        if (savedState.containsKey("target"))
            resolveTarget(savedState.getString("target"));
        if (savedState.containsKey("tempfiles"))
            tempFiles = savedState.getStringArrayList("tempfiles");
        if (savedState.containsKey("contents")) {
            contents = new ArrayList<Uri>();
            String[] carr = savedState.getStringArray("contents");
            for (String s : carr)
                contents.add(Uri.parse(s));
        }
    }

    postfix = "from <a href=\"http://palladium.planetmono.org/dcuploader\">DCUploader</a>";

    Button uploadVisit = (Button) findViewById(R.id.upload_visit);
    if (passThrough || target == null)
        uploadVisit.setEnabled(false);
    else
        uploadVisit.setEnabled(true);

    /* populate data by getting STREAM parameter */
    Intent i = getIntent();
    Bundle b = i.getExtras();
    String action = i.getAction();

    if (action.equals(Intent.ACTION_SEND) || action.equals(Intent.ACTION_SEND_MULTIPLE)) {
        called = true;

        if (i.hasExtra(Intent.EXTRA_STREAM)) {
            Object o = b.get(Intent.EXTRA_STREAM);

            /* quick and dirty. any better idea? */
            try {
                contents.add((Uri) o);
            } catch (Exception e1) {
                try {
                    contents = (ArrayList<Uri>) ((ArrayList<Uri>) o).clone();
                } catch (Exception e2) {
                }
            }

            boolean exceeded = false;
            if (contents.size() > 5) {
                exceeded = true;

                do {
                    contents.remove(5);
                } while (contents.size() > 5);
            }

            galleryChanged = true;

            updateImageButtons();
            resetThumbnails();
            updateGallery();

            if (exceeded)
                Toast.makeText(this,
                        " 5  . 5 ??? ? ?.",
                        Toast.LENGTH_LONG).show();
        }
        if (i.hasExtra(Intent.EXTRA_TEXT)) {
            ((EditText) findViewById(R.id.upload_text)).setText(b.getString(Intent.EXTRA_TEXT));
        }
    } else if (action.equals("share")) {
        called = true;
        /* HTC web browser uses non-standard intent */

        ((EditText) findViewById(R.id.upload_text)).setText(b.getString(Intent.EXTRA_TITLE));
    } else if (action.equals(Intent.ACTION_VIEW)) {
        Uri uri = i.getData();

        if (i.getCategories().contains(Intent.CATEGORY_BROWSABLE)) {
            passThrough = true;

            Pattern p = Pattern.compile("id=([\\-a-zA-Z0-9_]+)");
            Matcher m = p.matcher(uri.toString());

            if (m.find()) {
                resolveTarget(m.group(1));
            } else {
                passThrough = false;
            }

            if (uri.getHost().equals(Application.HOST_DCMYS)) {
                destination = Application.DESTINATION_DCMYS;
                postfix = "from dc.m.dcmys.kr w/ <a href=\"http://palladium.planetmono.org/dcuploader\">DCUploader</a>";
            } else if (uri.getHost().equals(Application.HOST_MOOLZO)) {
                destination = Application.DESTINATION_MOOLZO;
                postfix = "- From m.oolzo.com w/ <a href=\"http://palladium.planetmono.org/dcuploader\">DCUploader</a>";
            } else if (uri.getHost().equals(Application.HOST_DCINSIDE)) {
                destination = Application.DESTINATION_DCINSIDE;
            }

            setDefaultImage();
        }
    }

    reloadConfigurations();
}

From source file:bulat.diet.helper_sport.utils.IabHelper.java

public 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;//from   w w w.  j  av a 2s.com

    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);
        inv.setSkuArray(ownedSkus);
        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);
                }
                Date currDate = new Date();
                if (sku != null && currDate.getTime() > SaveUtils.getEndPDate(mContext)) {
                    // 0 (purchased), 1 (canceled), or 2 (refunded).
                    if (purchase.getPurchaseState() == 0 || purchase.getPurchaseState() == 2) {
                        if (sku.equals(PaymentsListActivity.SKU_YEAR)) {
                            SaveUtils.setEndPDate(currDate.getTime() + 367 * DateUtils.DAY_IN_MILLIS, mContext);
                        } else if (sku.equals(PaymentsListActivity.SKU_MUNTH)) {
                            SaveUtils.setEndPDate(currDate.getTime() + 32 * DateUtils.DAY_IN_MILLIS, mContext);
                        } else if (sku.equals(PaymentsListActivity.SKU_MUNTH_OLD)) {
                            SaveUtils.setEndPDate(currDate.getTime() + 32 * DateUtils.DAY_IN_MILLIS, mContext);
                        } else if (sku.equals(PaymentsListActivity.SKU_YEAR_OLD)) {
                            SaveUtils.setEndPDate(currDate.getTime() + 367 * DateUtils.DAY_IN_MILLIS, mContext);
                        } else if (sku.equals(PaymentsListActivity.SKU_YEAR_NEW)) {
                            SaveUtils.setEndPDate(currDate.getTime() + 367 * DateUtils.DAY_IN_MILLIS, mContext);
                        } else if (sku.equals(PaymentsListActivity.SKU_YEAR_VIP)) {
                            SaveUtils.setEndPDate(currDate.getTime() + 367 * DateUtils.DAY_IN_MILLIS, mContext);
                        } else if (sku.equals(PaymentsListActivity.SKU_HALFYEAR)) {
                            SaveUtils.setEndPDate(currDate.getTime() + 190 * DateUtils.DAY_IN_MILLIS, mContext);
                        } else if (sku.equals(PaymentsListActivity.SKU_MUUNTH_NEW)) {
                            SaveUtils.setEndPDate(currDate.getTime() + 32 * DateUtils.DAY_IN_MILLIS, mContext);
                        } else if (sku.equals(PaymentsListActivity.SKU_YEAR_2017)) {
                            SaveUtils.setEndPDate(currDate.getTime() + 367 * DateUtils.DAY_IN_MILLIS, mContext);
                        } else if (sku.equals(PaymentsListActivity.SKU_HALFYEAR_2017)) {
                            SaveUtils.setEndPDate(currDate.getTime() + 190 * DateUtils.DAY_IN_MILLIS, mContext);
                        } else if (sku.equals(PaymentsListActivity.SKU_MUUNTH_2017)) {
                            SaveUtils.setEndPDate(currDate.getTime() + 32 * DateUtils.DAY_IN_MILLIS, mContext);
                        }
                    }
                }

                // 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:bulat.diet.helper_sport.utils.IabHelper.java

public int isSubscribed() throws JSONException, RemoteException {
    // Query purchases
    if (subscriptionsSupported()) {
        logDebug("Querying owned items, item type: " + "subs");
        logDebug("Package name: " + mContext.getPackageName());
        boolean verificationFailed = false;
        String continueToken = null;

        do {/* w w w . j a  v  a 2 s  . com*/
            logDebug("Calling getPurchases with continuation token: " + continueToken);
            Bundle ownedItems = mService.getPurchases(3, mContext.getPackageName(), "subs", 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("subs", purchaseData, signature);
                Date currDate = new Date();
                if (sku != null && currDate.getTime() > SaveUtils.getEndPDate(mContext)) {
                    if (sku.equals(PaymentsListActivity.SKU_YEAR)) {
                        SaveUtils.setEndPDate(purchase.getPurchaseTime() + 367 * DateUtils.DAY_IN_MILLIS,
                                mContext);
                    } else if (sku.equals(PaymentsListActivity.SKU_MUNTH)) {
                        SaveUtils.setEndPDate(purchase.getPurchaseTime() + 32 * DateUtils.DAY_IN_MILLIS,
                                mContext);
                    } else if (sku.equals(PaymentsListActivity.SKU_MUNTH_OLD)) {
                        SaveUtils.setEndPDate(purchase.getPurchaseTime() + 32 * DateUtils.DAY_IN_MILLIS,
                                mContext);
                    } else if (sku.equals(PaymentsListActivity.SKU_YEAR_OLD)) {
                        SaveUtils.setEndPDate(purchase.getPurchaseTime() + 367 * DateUtils.DAY_IN_MILLIS,
                                mContext);
                    } else if (sku.equals(PaymentsListActivity.SKU_YEAR_NEW)) {
                        SaveUtils.setEndPDate(purchase.getPurchaseTime() + 367 * DateUtils.DAY_IN_MILLIS,
                                mContext);
                    } else if (sku.equals(PaymentsListActivity.SKU_YEAR_VIP)) {
                        SaveUtils.setEndPDate(purchase.getPurchaseTime() + 367 * DateUtils.DAY_IN_MILLIS,
                                mContext);
                    } else if (sku.equals(PaymentsListActivity.SKU_HALFYEAR)) {
                        SaveUtils.setEndPDate(purchase.getPurchaseTime() + 190 * DateUtils.DAY_IN_MILLIS,
                                mContext);
                    } else if (sku.equals(PaymentsListActivity.SKU_MUUNTH_NEW)) {
                        SaveUtils.setEndPDate(purchase.getPurchaseTime() + 32 * DateUtils.DAY_IN_MILLIS,
                                mContext);
                    } else if (sku.equals(PaymentsListActivity.SKU_HALFYEAR_2017)) {
                        SaveUtils.setEndPDate(purchase.getPurchaseTime() + 190 * DateUtils.DAY_IN_MILLIS,
                                mContext);
                    } else if (sku.equals(PaymentsListActivity.SKU_MUUNTH_2017)) {
                        SaveUtils.setEndPDate(purchase.getPurchaseTime() + 32 * DateUtils.DAY_IN_MILLIS,
                                mContext);
                    } else if (sku.equals(PaymentsListActivity.SKU_YEAR_2017)) {
                        SaveUtils.setEndPDate(purchase.getPurchaseTime() + 367 * DateUtils.DAY_IN_MILLIS,
                                mContext);
                    }
                }

                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;
    } else {
        return IABHELPER_UNKNOWN_ERROR;
    }
}

From source file:de.sourcestream.movieDB.controller.CastDetails.java

/**
 * Fired when are restoring from backState or orientation has changed.
 *
 * @param args our bundle with saved state.
 *//*from  ww w  .j a v  a  2  s . c om*/
private void onOrientationChange(Bundle args) {
    // Home page
    homeIconCheck = args.getInt("homeIconCheck");
    if (homeIconCheck == 0)
        homeIconUrl = args.getString("homepage");

    // Gallery
    galleryIconCheck = args.getInt("galleryIconCheck");
    if (galleryIconCheck == 0) {
        galleryList = new ArrayList<>();
        galleryList = args.getStringArrayList("galleryList");
        if (galleryList.size() == 0)
            activity.hideView(galleryIcon);
    }

    // More icon
    moreIconCheck = args.getInt("moreIconCheck");

    if (homeIconCheck == 1 && galleryIconCheck == 1) {
        moreIconCheck = 1;
        moreIcon.setVisibility(View.GONE);
    } else
        moreIconCheck = 0;

    mSlidingTabLayout.setOnPageChangeListener(onPageChangeSelected);
    activity.setCastDetailsInfoBundle(save);
    activity.setCastDetailsCreditsBundle(save);
    activity.setCastDetailsBiographyBundle(save);

    moviesList = save.getParcelableArrayList("moviesList");
    if (moviesList != null && moviesList.size() == 0) {
        noCredits = true;
        mSlidingTabLayout.disableTabClickListener(1);
    }

    new Handler().post(new Runnable() {
        @Override
        public void run() {
            castDetailsInfo = (CastDetailsInfo) castDetailsSlideAdapter.getRegisteredFragment(0);
            castDetailsCredits = (CastDetailsCredits) castDetailsSlideAdapter.getRegisteredFragment(1);
            if (currPos == 0) {
                moreIcon.setVisibility(View.INVISIBLE);
            } else if (moreIconCheck == 0) {
                castDetailsInfo.getMoreIcon().setVisibility(View.INVISIBLE);
                updateDownPos();
            }
            if (moreIconCheck == 1)
                castDetailsInfo.getMoreIcon().setVisibility(View.GONE);
            else {
                // set listener on backdrop click to open gallery
                if (galleryIconCheck == 0 && galleryList.size() > 0)
                    castDetailsInfo.getProfilePath().setOnClickListener(onGalleryIconClick);
                adjustIconsPos(homeIcon, galleryIcon);
                adjustIconsPos(castDetailsInfo.getHomeIcon(), castDetailsInfo.getGalleryIcon());
            }

            // disable orientation changing, enable nav drawer sliding, show toolbar
            if (galleryIconCheck == 0 && galleryList.size() == 1) {
                activity.getWindow().getDecorView().setBackgroundColor(
                        ContextCompat.getColor(activity, R.color.background_material_light));
                if (activity.getSupportActionBar() != null)
                    activity.getSupportActionBar().show();
                activity.getMDrawerLayout().setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED);
                activity.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);
                if (Build.VERSION.SDK_INT >= 19)
                    activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS
                            | WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
                // Check orientation and lock to portrait if we are on phone
                if (getResources().getBoolean(R.bool.portrait_only))
                    activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
            }

            if (castDetailsCredits.getMoviesList().size() < 7)
                activity.hideView(castDetailsInfo.getShowMoreButton());

        }
    });

}