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:ir.aarani.bazaar.billing.BillingProcessor.java

private boolean loadPurchasesByType(String type, BillingCache cacheStorage) {
    if (!isInitialized())
        return false;
    try {/*from w w w  .  j av a 2s .  c o  m*/
        Bundle bundle = billingService.getPurchases(Constants.GOOGLE_API_VERSION, contextPackageName, type,
                null);
        if (bundle.getInt(Constants.RESPONSE_CODE) == Constants.BILLING_RESPONSE_RESULT_OK) {
            cacheStorage.clear();
            ArrayList<String> purchaseList = bundle.getStringArrayList(Constants.INAPP_PURCHASE_DATA_LIST);
            ArrayList<String> signatureList = bundle.getStringArrayList(Constants.INAPP_DATA_SIGNATURE_LIST);
            if (purchaseList != null)
                for (int i = 0; i < purchaseList.size(); i++) {
                    String jsonData = purchaseList.get(i);

                    if (!TextUtils.isEmpty(jsonData)) {
                        JSONObject purchase = new JSONObject(jsonData);
                        String signature = signatureList != null && signatureList.size() > i
                                ? signatureList.get(i)
                                : null;
                        cacheStorage.put(purchase.getString(Constants.RESPONSE_PRODUCT_ID), jsonData,
                                signature);
                    }
                }
        }
        return true;
    } catch (Exception e) {
        if (eventHandler != null)
            eventHandler.onBillingError(Constants.BILLING_ERROR_FAILED_LOAD_PURCHASES, e);
        Log.e(LOG_TAG, "Error in loadPurchasesByType", e);
    }
    return false;
}

From source file:com.money.manager.ex.investment.watchlist.WatchlistItemsFragment.java

@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
    MmxCursorLoader result;//from  w ww.  j  a  va2 s .c o m

    //animation
    setListShown(false);

    switch (id) {
    case ID_LOADER:
        // compose selection and sort
        String selection = "";
        if (args != null && args.containsKey(AllDataListFragment.KEY_ARGUMENTS_WHERE)) {
            ArrayList<String> whereClause = args.getStringArrayList(AllDataListFragment.KEY_ARGUMENTS_WHERE);
            if (whereClause != null) {
                for (int i = 0; i < whereClause.size(); i++) {
                    selection += (!TextUtils.isEmpty(selection) ? " AND " : "") + whereClause.get(i);
                }
            }
        }

        // set sort
        String sort = "";
        if (args != null && args.containsKey(AllDataListFragment.KEY_ARGUMENTS_SORT)) {
            sort = args.getString(AllDataListFragment.KEY_ARGUMENTS_SORT);
        }

        Select query = new Select(mStockRepository.getAllColumns()).where(selection).orderBy(sort);

        result = new MmxCursorLoader(getActivity(), mStockRepository.getUri(), query);
        break;
    default:
        result = null;
    }
    return result;
}

From source file:com.appsimobile.appsii.iab.IabInventoryHelper.java

int querySkuDetails(String itemType, Inventory inv, List<String> moreSkus)
        throws RemoteException, JSONException {
    logDebug("Querying SKU details.");
    ArrayList<String> skuList = new ArrayList<>();
    skuList.addAll(inv.getAllOwnedSkus(itemType));
    if (moreSkus != null)
        skuList.addAll(moreSkus);/*from  ww  w . j  a v  a 2s . c om*/

    if (skuList.size() == 0) {
        logDebug("queryPrices: nothing to do because there are no SKUs.");
        return BILLING_RESPONSE_RESULT_OK;
    }

    Bundle querySkus = new Bundle();
    querySkus.putStringArrayList(GET_SKU_DETAILS_ITEM_LIST, skuList);
    Bundle skuDetails = mService.getSkuDetails(3, mContext.getPackageName(), itemType, querySkus);

    if (!skuDetails.containsKey(RESPONSE_GET_SKU_DETAILS_LIST)) {
        int response = getResponseCodeFromBundle(skuDetails);
        if (response != BILLING_RESPONSE_RESULT_OK) {
            logDebug("getSkuDetails() failed: " + getResponseDesc(response));
            return response;
        } else {
            logError("getSkuDetails() returned a bundle with neither an error nor a detail " + "list.");
            return IABHELPER_BAD_RESPONSE;
        }
    }

    ArrayList<String> responseList = skuDetails.getStringArrayList(RESPONSE_GET_SKU_DETAILS_LIST);

    int N = responseList.size();
    for (int i = 0; i < N; i++) {
        String thisResponse = responseList.get(i);
        SkuDetails d = new SkuDetails(itemType, thisResponse);
        logDebug("Got sku details: " + d);
        inv.addSkuDetails(d);
    }
    return BILLING_RESPONSE_RESULT_OK;
}

From source file:pl.mrwojtek.sensrec.app.Records.java

@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setRetainInstance(true);//from   ww  w  .j ava  2 s. c o  m

    Set<String> activated = null;
    if (savedInstanceState != null) {
        activated = new HashSet<>(savedInstanceState.getStringArrayList(PARAM_ACTIVATED));
    }

    // TODO: Add option to select storage directory
    //File[] directories = ContextCompat.getExternalFilesDirs(context, null);

    uiHandler = new Handler(getActivity().getMainLooper());

    recorder = RecordingService.getRecorder(getContext());
    recordReader = new RecordReader(recorder);

    recordsDirectory = getActivity().getExternalFilesDir(null);
    recordsObserver = new RecordsObserver(recordsDirectory.getPath());
    recordsObserver.startWatching();

    fileListener = new FileListener();
    recorder.getOutput().getFileOutput().addOnFileListener(fileListener);

    // TODO: Move this listing to the initialization task
    for (File d : recordsDirectory.listFiles()) {
        RecordEntry recordEntry = new RecordEntry(d, true);
        if (activated != null && activated.contains(recordEntry.getFile().getPath())) {
            recordEntry.toggleActivated();
        }
        records.add(recordEntry);
        recordByName.put(recordEntry.getName(), recordEntry);
    }

    updateRecordsOrder();

    initializationTask = new RecordsInitializationTask(recorder, new ArrayList<>(records));
    initializationTask.execute();
}

From source file:com.hippo.scene.StageActivity.java

@Override
protected final void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if (savedInstanceState != null) {
        mStageId = savedInstanceState.getInt(KEY_STAGE_ID, IntIdGenerator.INVALID_ID);
        ArrayList<String> list = savedInstanceState.getStringArrayList(KEY_SCENE_TAG_LIST);
        mSceneTagList.addAll(list);//ww  w  . java 2s .  c om
        mDelaySceneTagList.addAll(list);
        mIdGenerator.lazySet(savedInstanceState.getInt(KEY_NEXT_ID));
    }

    if (mStageId == IntIdGenerator.INVALID_ID) {
        ((SceneApplication) getApplicationContext()).registerStageActivity(this);
    } else {
        ((SceneApplication) getApplicationContext()).registerStageActivity(this, mStageId);
    }

    // Create layout
    onCreate2(savedInstanceState);

    Intent intent = getIntent();
    if (savedInstanceState == null) {
        if (intent != null) {
            String action = intent.getAction();
            if (Intent.ACTION_MAIN.equals(action)) {
                Announcer announcer = getLaunchAnnouncer();
                if (announcer != null) {
                    startScene(announcer);
                    return;
                }
            } else if (ACTION_START_SCENE.equals(action)) {
                if (startSceneFromIntent(intent)) {
                    return;
                }
            }
        }

        // Can't recognize intent
        onUnrecognizedIntent(intent);
    }
}

From source file:com.cettco.buycar.activity.BargainActivity.java

protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (data == null)
        return;/*from   w ww . jav a2s . c  o m*/
    //System.out.println("resultcode :" + resultCode + " requestcode:"
    //+ requestCode);
    Bundle b = data.getExtras();
    switch (resultCode) { // resultCodeBRESULT_OK
    case RESULT_OK:
        // dataBIntent
        // int position = b.getInt("result");
        if (requestCode == RESULT_COLOR) {
            colors = b.getStringArrayList("colors");
        } else if (requestCode == RESULT_TIME) {
            getcarTimeSelection = b.getInt("result");
        } else if (requestCode == RESULT_LOAN) {
            loanSelection = b.getInt("result");
        } else if (requestCode == RESULT_LOCATION) {
            locationSelection = b.getInt("result");
        } else if (requestCode == RESULT_PLATE) {
            plateSelection = b.getInt("result");
        } else if (requestCode == RESULT_SHOP) {
            dealers = b.getStringArrayList("dealers");
            //System.out.println("dealer size:" + dealers.size());
        }
        break;
    default:
        break;
    }
}

From source file:org.anhonesteffort.flock.SubscriptionGoogleFragment.java

private void handleRefreshDaysTillCharge() {
    if (recurringTask != null)
        return;/*from w ww .j a va  2s  .  c o  m*/

    recurringTask = new AsyncTask<Void, Void, Bundle>() {

        @Override
        protected void onPreExecute() {
            Log.d(TAG, "handleRefreshDaysTillCharge");
            subscriptionActivity.setProgressBarIndeterminateVisibility(true);
            subscriptionActivity.setProgressBarVisibility(true);
        }

        @Override
        protected Bundle doInBackground(Void... params) {
            Bundle result = new Bundle();

            if (subscriptionActivity.billingService == null) {
                Log.e(TAG, "billing service is null");
                result.putInt(ErrorToaster.KEY_STATUS_CODE, ErrorToaster.CODE_GOOGLE_PLAY_ERROR);
                return result;
            }

            try {

                Bundle ownedItems = subscriptionActivity.billingService.getPurchases(3,
                        SubscriptionGoogleFragment.class.getPackage().getName(), PRODUCT_TYPE_SUBSCRIPTION,
                        null);

                ArrayList<String> purchaseDataList = ownedItems.getStringArrayList("INAPP_PURCHASE_DATA_LIST");

                for (int i = 0; i < purchaseDataList.size(); ++i) {
                    JSONObject productObject = new JSONObject(purchaseDataList.get(i));
                    if (productObject.getString("productId").equals(SKU_YEARLY_SUBSCRIPTION)) {
                        long purchaseTime = productObject.getLong("purchaseTime");
                        long msSincePurchase = new Date().getTime() - purchaseTime;
                        if (msSincePurchase < 0)
                            msSincePurchase = 0;

                        daysTillNextCharge = 365 - (msSincePurchase / 1000 / 60 / 60 / 24);
                        if (daysTillNextCharge < 0)
                            daysTillNextCharge = 0;
                    }
                }

                result.putInt(ErrorToaster.KEY_STATUS_CODE, ErrorToaster.CODE_SUCCESS);

            } catch (RemoteException e) {
                Log.e(TAG, "error while getting owned items", e);
                result.putInt(ErrorToaster.KEY_STATUS_CODE, ErrorToaster.CODE_GOOGLE_PLAY_ERROR);
            } catch (JSONException e) {
                Log.e(TAG, "error while getting owned items", e);
                result.putInt(ErrorToaster.KEY_STATUS_CODE, ErrorToaster.CODE_GOOGLE_PLAY_ERROR);
            }

            return result;
        }

        @Override
        protected void onPostExecute(Bundle result) {
            recurringTask = null;
            subscriptionActivity.setProgressBarIndeterminateVisibility(false);
            subscriptionActivity.setProgressBarVisibility(false);

            if (result.getInt(ErrorToaster.KEY_STATUS_CODE) == ErrorToaster.CODE_SUCCESS)
                handleUpdateUi();
            else
                ErrorToaster.handleDisplayToastBundledError(subscriptionActivity, result);
        }
    }.execute();
}

From source file:es.glasspixel.wlanaudit.activities.KeyListActivity.java

/**
 * @see android.app.Activity#onCreate(Bundle)
 *///  w  ww.  j  a  v  a 2 s .  c o m
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.key_list_layout);
    ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);

    // create our manager instance after the content view is set
    SystemBarTintManager tintManager = new SystemBarTintManager(this);
    // enable status bar tint
    tintManager.setStatusBarTintEnabled(true);
    tintManager.setStatusBarTintResource(R.color.wlanaudit_material);

    // If a previous instance state was saved
    if (savedInstanceState != null && savedInstanceState.get(KEY_LIST_KEY) != null) {
        // Load the state
        mKeyList = savedInstanceState.getStringArrayList(KEY_LIST_KEY);
    } else {
        // Read the network from the intent extra passed to this activity
        mKeyList = (List<String>) getIntent().getExtras().getStringArrayList(KEY_LIST_KEY);
    }

    // Ads Initialization
    setupAds((LinearLayout) findViewById(R.id.keyListAdLayout));

    // List display
    setListAdapter(new ArrayAdapter<String>(this, R.layout.key_list_element_layout, R.id.keyString, mKeyList));
}

From source file:org.anhonesteffort.flock.SubscriptionGoogleFragment.java

private void handleLoadSkuList(final String productType) {
    if (asyncTask != null)
        return;//from w  ww  . j ava 2  s .c  om

    asyncTask = new AsyncTask<Void, Void, Bundle>() {

        @Override
        protected void onPreExecute() {
            Log.d(TAG, "handleLoadSkuList");
            subscriptionActivity.setProgressBarIndeterminateVisibility(true);
            subscriptionActivity.setProgressBarVisibility(true);
        }

        private ArrayList<String> getSkuDetails(ArrayList<String> skuList, Bundle result)
                throws RemoteException {
            Bundle skuBundle = new Bundle();
            skuBundle.putStringArrayList("ITEM_ID_LIST", skuList);

            Bundle skuDetails = subscriptionActivity.billingService.getSkuDetails(3,
                    SubscriptionGoogleFragment.class.getPackage().getName(), productType, skuBundle);

            if (skuDetails.getInt("RESPONSE_CODE") == 0)
                return skuDetails.getStringArrayList("DETAILS_LIST");
            else {
                Log.e(TAG, "sku details response code is != 0");
                result.putInt(ErrorToaster.KEY_STATUS_CODE, ErrorToaster.CODE_GOOGLE_PLAY_ERROR);
                return new ArrayList<String>(0);
            }
        }

        @Override
        protected Bundle doInBackground(Void... params) {
            Bundle result = new Bundle();

            if (subscriptionActivity.billingService == null) {
                Log.e(TAG, "billing service is null");
                result.putInt(ErrorToaster.KEY_STATUS_CODE, ErrorToaster.CODE_GOOGLE_PLAY_ERROR);
                return result;
            }

            ArrayList<String> skuQueryList = new ArrayList<String>(2);
            skuQueryList.add(SKU_YEARLY_SUBSCRIPTION);

            try {

                List<String> skuDetails = getSkuDetails(skuQueryList, result);
                ArrayList<String> skuList = new ArrayList<String>();

                if (result.getInt(ErrorToaster.KEY_STATUS_CODE, -1) != -1)
                    return result;

                for (String thisResponse : skuDetails) {
                    JSONObject productObject = new JSONObject(thisResponse);
                    skuList.add(productObject.getString("productId"));
                }

                result.putStringArrayList("SKU_LIST", skuList);
                result.putInt(ErrorToaster.KEY_STATUS_CODE, ErrorToaster.CODE_SUCCESS);

            } catch (JSONException e) {
                Log.e(TAG, "error parsing sku details", e);
                result.putInt(ErrorToaster.KEY_STATUS_CODE, ErrorToaster.CODE_GOOGLE_PLAY_ERROR);
            } catch (RemoteException e) {
                Log.e(TAG, "error parsing sku details", e);
                result.putInt(ErrorToaster.KEY_STATUS_CODE, ErrorToaster.CODE_GOOGLE_PLAY_ERROR);
            }

            return result;
        }

        @Override
        protected void onPostExecute(Bundle result) {
            asyncTask = null;
            subscriptionActivity.setProgressBarIndeterminateVisibility(false);
            subscriptionActivity.setProgressBarVisibility(false);

            if (result.getInt(ErrorToaster.KEY_STATUS_CODE) == ErrorToaster.CODE_SUCCESS)
                handleSkuListLoaded(result.getStringArrayList("SKU_LIST"));
            else
                ErrorToaster.handleDisplayToastBundledError(subscriptionActivity, result);
        }
    }.execute();
}