Example usage for android.content Intent putParcelableArrayListExtra

List of usage examples for android.content Intent putParcelableArrayListExtra

Introduction

In this page you can find the example usage for android.content Intent putParcelableArrayListExtra.

Prototype

public @NonNull Intent putParcelableArrayListExtra(String name, ArrayList<? extends Parcelable> value) 

Source Link

Document

Add extended data to the intent.

Usage

From source file:org.strongswan.android.ui.fragment.VpnStateFragment.java

/**
 * dialog//ww w  . ja  v a2 s. c o m
 *
 * @param textid textid
 */
private void showErrorDialog(int textid) {
    final List<RemediationInstruction> instructions = mService.getRemediationInstructions();
    final boolean show_instructions = mService.getImcState() == ImcState.BLOCK && !instructions.isEmpty();
    int text = show_instructions ? R.string.show_remediation_instructions : R.string.show_log;

    mErrorDialog = new AlertDialog.Builder(getActivity())
            .setMessage(getString(R.string.error_introduction) + " " + getString(textid)).setCancelable(false)
            .setNeutralButton(text, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    clearError();
                    dialog.dismiss();
                    Intent intent;
                    if (show_instructions) {
                        intent = new Intent(getActivity(), RemediationInstructionsActivity.class);
                        intent.putParcelableArrayListExtra(
                                RemediationInstructionsFragment.EXTRA_REMEDIATION_INSTRUCTIONS,
                                new ArrayList<>(instructions));
                    } else {
                        intent = new Intent(getActivity(), LogActivity.class);
                    }
                    startActivity(intent);
                }
            }).setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int id) {
                    clearError();
                    dialog.dismiss();
                }
            }).create();
    //?dialog?GC
    mErrorDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
        @Override
        public void onDismiss(DialogInterface dialog) {
            mErrorDialog = null;
        }
    });
    mErrorDialog.show();
}

From source file:com.android.mail.browse.AttachmentActionHandler.java

public void shareAttachments(ArrayList<Parcelable> uris) {
    Intent intent = new Intent(Intent.ACTION_SEND_MULTIPLE);
    intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);

    intent.setType("image/*");
    intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);

    try {//  w  w  w .  j a  v a2  s .c o  m
        mContext.startActivity(intent);
    } catch (ActivityNotFoundException e) {
        // couldn't find activity for SEND_MULTIPLE intent
        LogUtils.e(LOG_TAG, "Couldn't find Activity for intent", e);
    }
}

From source file:org.gnucash.android.ui.budget.BudgetFormFragment.java

@OnClick(R.id.btn_add_budget_amount)
public void onOpenBudgetAmountEditor(View v) {
    Intent intent = new Intent(getActivity(), FormActivity.class);
    intent.putExtra(UxArgument.FORM_TYPE, FormActivity.FormType.BUDGET_AMOUNT_EDITOR.name());
    mBudgetAmounts = extractBudgetAmounts();
    intent.putParcelableArrayListExtra(UxArgument.BUDGET_AMOUNT_LIST, mBudgetAmounts);
    startActivityForResult(intent, REQUEST_EDIT_BUDGET_AMOUNTS);
}

From source file:org.ubicompforall.cityexplorer.gui.PoiDetailsActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    int itemID = item.getItemId();
    int editID = R.id.poiMenuEdit;
    int favID = R.id.poiMenufavorite;
    int dirID = R.id.poiMenuDirections;
    int mapID = R.id.poiMenuMap;

    //1: Edit/* w w  w  .  ja  v a  2  s .co m*/
    if (itemID == editID) {
        debug(0, "Handle Edit-selection here!");
        Intent editIntent = new Intent(this, NewPoiActivity.class);
        editIntent.putExtra(IntentPassable.POI, poi); //setResult( Activity.RESULT_OK, resultIntent );
        startActivity(editIntent);
        finish(); // After editing, the details should be refreshed. This activity should thus be restarted.
    }
    //2: Favorite
    if (itemID == favID) {
        if (poi.isFavorite()) {
            poi = new Poi(poi.modify().favourite(false));
            DBFactory.getInstance(this).editPoi(poi);
            return true;
        }
        poi = poi.modify().favourite(true).build();
        DBFactory.getInstance(this).editPoi(poi);
        return true;
    }
    //3: Directions
    if (itemID == dirID) {
        userLocation = StartActivity.verifyUserLocation(userLocation, this);

        //Latitude and longitude for current position
        double slon = userLocation.getLongitude();
        double slat = userLocation.getLatitude();
        //Latitude and longitude for selected poi
        double dlon = poi.getGeoPoint().getLongitudeE6() / 1E6;
        double dlat = poi.getGeoPoint().getLatitudeE6() / 1E6;

        Intent navigate = new Intent(PoiDetailsActivity.this, NavigateFrom.class);
        navigate.putExtra("slon", slon);
        navigate.putExtra("slat", slat);
        navigate.putExtra("dlon", dlon);
        navigate.putExtra("dlat", dlat);
        startActivity(navigate);

        return true;
    }
    //4: Map
    if (itemID == mapID) {
        Intent showInMap = new Intent(PoiDetailsActivity.this, MapsActivity.class);
        ArrayList<Poi> selectedPois = new ArrayList<Poi>();
        selectedPois.add(poi);
        showInMap.putParcelableArrayListExtra(IntentPassable.POILIST, selectedPois);

        startActivity(showInMap);
        return true;
    }
    return true;
}

From source file:com.njlabs.amrita.aid.gpms.ui.GpmsActivity.java

public void openPassStatus(View v) {
    Intent pendingPassActivityIntent = new Intent(baseContext, PendingPassActivity.class);
    if (relays != null && relays.size() > 0 && identifier != null) {
        pendingPassActivityIntent.putParcelableArrayListExtra("relays", relays);
        pendingPassActivityIntent.putExtra("identifier", identifier);
    }/*from  ww  w .  jav  a 2s .  c  o  m*/
    startActivity(pendingPassActivityIntent);
}

From source file:com.njlabs.amrita.aid.gpms.ui.GpmsActivity.java

public void openPassesHistory(View v) {

    Intent passHistoryActivityIntent = new Intent(baseContext, PassHistoryActivity.class);
    if (relays != null && relays.size() > 0 && identifier != null) {
        passHistoryActivityIntent.putParcelableArrayListExtra("relays", relays);
        passHistoryActivityIntent.putExtra("identifier", identifier);
    }//from  www  . jav a2 s . co  m
    startActivity(passHistoryActivityIntent);
}

From source file:com.laevatein.SelectionSpecBuilder.java

/**
 * Start to select photo./*from   ww w  .ja va2  s  .c o  m*/
 * @param requestCode identity of the requester activity.
 */
public void forResult(int requestCode) {
    Activity activity = mLaevatein.getActivity();
    if (activity == null) {
        return; // cannot continue;
    }

    mSelectionSpec.setMimeTypeSet(mMimeType);

    ViewResourceSpec viewSpec = new ViewResourceSpec.Builder().setActionViewResources(mActionViewResources)
            .setAlbumViewResources(mAlbumViewResources).setCountViewResources(mCountViewResources)
            .setItemViewResources(mItemViewResources).setEnableCapture(mEnableCapture)
            .setEnableSelectedView(mEnableSelectedView).setActivityOrientation(mActivityOrientation).create();
    ErrorViewSpec errorSpec = new ErrorViewSpec.Builder().setCountSpec(mCountErrorSpec)
            .setOverQualitySpec(mOverQualityErrorSpec).setUnderQualitySpec(mUnderQualityErrorSpec)
            .setTypeSpec(mTypeErrorSpec).create();

    if (mPhotoSelectionActivityClass == null) {
        mPhotoSelectionActivityClass = PhotoSelectionActivity.class;
    }

    Intent intent = new Intent(activity, mPhotoSelectionActivityClass);
    intent.putExtra(PhotoSelectionActivity.EXTRA_VIEW_SPEC, viewSpec);
    intent.putExtra(PhotoSelectionActivity.EXTRA_ERROR_SPEC, errorSpec);
    intent.putExtra(PhotoSelectionActivity.EXTRA_SELECTION_SPEC, mSelectionSpec);
    intent.putParcelableArrayListExtra(PhotoSelectionActivity.EXTRA_RESUME_LIST,
            (ArrayList<? extends android.os.Parcelable>) mResumeList);

    Fragment fragment = mLaevatein.getFragment();
    if (fragment != null) {
        fragment.startActivityForResult(intent, requestCode);
    } else {
        activity.startActivityForResult(intent, requestCode);
    }
}

From source file:com.grarak.kerneladiutor.fragments.tools.customcontrols.CustomControlsFragment.java

private void edit(Controls.ControlItem controlItem) {
    ArrayList<Items.Setting> settings = new ArrayList<>();
    settings.add(new Items.Setting("id", controlItem.getUniqueId(), 0, 0, controlItem.getId(), null, null,
            false, false, Items.Setting.Unit.ID));
    settings.add(new Items.Setting("title", R.string.title, controlItem.getTitle(), true,
            Items.Setting.Unit.STRING));
    settings.add(new Items.Setting("description", R.string.description, controlItem.getDescription(), false,
            Items.Setting.Unit.STRING));

    if (controlItem.getControl() == Items.Control.SWITCH) {
        settings.add(new Items.Setting("enable", R.string.enabled, R.string.switch_enabled_summary,
                controlItem.getString("enable"), true, true, Items.Setting.Unit.BOOLEAN));
        settings.add(new Items.Setting("apply", R.string.applying, R.string.switch_apply_summary,
                controlItem.getApply(), true, true, Items.Setting.Unit.APPLY));
    } else if (controlItem.getControl() == Items.Control.SEEKBAR) {
        settings.add(new Items.Setting("min", R.string.seekbar_min, String.valueOf(controlItem.getInt("min")),
                true, Items.Setting.Unit.INTEGER));
        settings.add(new Items.Setting("max", R.string.seekbar_max, String.valueOf(controlItem.getInt("max")),
                true, Items.Setting.Unit.INTEGER));
        settings.add(new Items.Setting("progress", R.string.seekbar_progress, R.string.seekbar_progress_summary,
                controlItem.getString("progress"), true, true, Items.Setting.Unit.INTEGER));
        settings.add(new Items.Setting("apply", R.string.applying, R.string.seekbar_apply_summary,
                controlItem.getApply(), true, true, Items.Setting.Unit.APPLY));
    } else if (controlItem.getControl() == Items.Control.GENERIC) {
        settings.add(new Items.Setting("value", R.string.generic_value, R.string.generic_value_summary,
                controlItem.getString("value"), true, true, Items.Setting.Unit.STRING));
        settings.add(new Items.Setting("apply", R.string.applying, R.string.generic_apply_summary,
                controlItem.getApply(), true, true, Items.Setting.Unit.APPLY));
    }/*from   w w  w . j  a  v  a 2 s.c om*/

    Intent i = new Intent(getActivity(), CustomControlsActivity.class);
    i.putParcelableArrayListExtra(CustomControlsActivity.SETTINGS_INTENT, settings);
    startActivityForResult(i, 0);
}

From source file:com.doplgangr.secrecy.views.FileViewer.java

void sendMultiple(final ArrayList<FilesListFragment.DecryptArgHolder> args) {
    new Thread(new Runnable() {
        @Override//from  ww  w  . jav  a 2s  . c  om
        public void run() {
            ArrayList<Uri> uris = new ArrayList<Uri>();
            Set<String> mimes = new HashSet<String>();
            MimeTypeMap myMime = MimeTypeMap.getSingleton();
            for (FilesListFragment.DecryptArgHolder arg : args) {
                File tempFile = getFile(arg.encryptedFile, arg.onFinish);
                //File specified is not invalid
                if (tempFile != null) {
                    if (tempFile.getParentFile().equals(Storage.getTempFolder()))
                        tempFile = new java.io.File(Storage.getTempFolder(), tempFile.getName());
                    uris.add(OurFileProvider.getUriForFile(context, OurFileProvider.FILE_PROVIDER_AUTHORITY,
                            tempFile));
                    mimes.add(myMime.getMimeTypeFromExtension(arg.encryptedFile.getType()));

                }
            }
            if (uris.size() == 0 || mimes.size() == 0)
                return;
            Intent newIntent;
            if (uris.size() == 1) {
                newIntent = new Intent(Intent.ACTION_SEND);
                newIntent.putExtra(Intent.EXTRA_STREAM, uris.get(0));
            } else {
                newIntent = new Intent(Intent.ACTION_SEND_MULTIPLE);
                newIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);
            }
            if (mimes.size() > 1)
                newIntent.setType("text/plain"); //Mixed filetypes
            else
                newIntent.setType(new ArrayList<String>(mimes).get(0));
            newIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);

            Intent chooserIntent = generateCustomChooserIntent(newIntent, uris);
            try {
                startActivity(Intent.createChooser(chooserIntent,
                        CustomApp.context.getString(R.string.Dialog__send_file)));
                FilesActivity.onPauseDecision.startActivity();
            } catch (android.content.ActivityNotFoundException e) {
                Util.toast(context, CustomApp.context.getString(R.string.Error__no_activity_view),
                        Toast.LENGTH_LONG);
                FilesActivity.onPauseDecision.finishActivity();
            }
        }
    }).start();
}

From source file:com.grarak.kerneladiutor.fragments.tools.customcontrols.CustomControlsFragment.java

private void showControls() {
    mItemsDialog = new Dialog(getActivity())
            .setItems(getResources().getStringArray(R.array.custom_controls_items),
                    new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            Intent i = new Intent(getActivity(), CustomControlsActivity.class);
                            i.putParcelableArrayListExtra(CustomControlsActivity.SETTINGS_INTENT,
                                    Items.getSettings(which));
                            startActivityForResult(i, 0);
                        }//from   w ww . j a  v a 2  s. c  om
                    })
            .setOnDismissListener(new DialogInterface.OnDismissListener() {
                @Override
                public void onDismiss(DialogInterface dialog) {
                    mItemsDialog = null;
                }
            });
    mItemsDialog.show();
}