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:com.rubengees.introduction.IntroductionActivity.java

private void handleFinish() {
    clean();/* ww  w  .j ava 2 s.c o m*/
    ArrayList<Option> options = new ArrayList<>();

    for (Slide slide : slides) {
        if (slide.getOption() != null) {
            options.add(slide.getOption());
        }
    }

    Intent result = new Intent();

    result.putParcelableArrayListExtra(OPTION_RESULT, options);
    setResult(RESULT_OK, result);
    finish();
}

From source file:am.roadpolice.roadpolice.MainActivity.java

@Override
public void submissionCompleted(final ArrayList<ViolationInfo> list, final String result) {

    // Hide any showing progress dialog, of submission completed.
    ProgressDialogFragment dialog = (ProgressDialogFragment) getSupportFragmentManager()
            .findFragmentByTag("dialog");
    if (dialog != null)
        dialog.dismissAllowingStateLoss();

    String message = null;/*from  w w w .  j a v  a2s  .  c om*/
    // If no error occurs, result should be null.
    if (TextUtils.isEmpty(result)) {

        // Store Registration Number and Certificate Number for further use.
        SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
        SharedPreferences.Editor ed = sp.edit();
        ed.putString(REG_NUMBER, mRegNum);
        ed.putString(CER_NUMBER, mCerNum);
        ed.putBoolean(AUTO_LOGIN, mAutoLogin);
        ed.apply();

        // Create intent for Violation Info Activity.
        Intent intent = new Intent(MainActivity.this, ViolationInfoActivity.class);
        intent.putParcelableArrayListExtra(ViolationInfoActivity.EXTRA_VIOLATION_INFO_LIST, list);
        intent.putExtra(ViolationInfoActivity.EXTRA_AUTO_LOGIN, mAutoLogin);
        // Do not store user information, just open activity for data view.
        // In this mode user can't set automatic data update alarm.
        if (!mAutoLogin) {
            startActivity(intent);
        }
        // Store user information, next time user will be automatically logged
        // into application and will be allowed to set automatic data update alarm.
        else {
            // Store Data to SQLite Database, if auto login enabled.
            mDbHelper.insertViolationInfoList(list);
            startActivityForResult(intent, 0);
        }
    } else if (result.equalsIgnoreCase(Submitter.ERROR_ON_SERVER_SIDE)
            || result.equalsIgnoreCase(Submitter.ERROR_WHILE_PARSING_DATA)) {
        message = getString(R.string.txtTechnicalIssues);
    } else if (result.equalsIgnoreCase(Submitter.ERROR_WHILE_CREATING_JSOUP)) {
        message = getString(R.string.txtServerIssues);
    } else
        message = result;

    // Show error notification to the user only in the,
    // case if error occurs while processing of url.
    if (!TextUtils.isEmpty(message))
        Toast.makeText(getApplicationContext(), message, Toast.LENGTH_LONG).show();
}

From source file:com.github.jvanhie.discogsscrobbler.ReleaseTracklistFragment.java

public void scrobble() {
    //first a small sanity check
    if (mRelease == null)
        return;//from  w  ww  . j a v a  2 s.  c o m
    final Lastfm lastfm = Lastfm.getInstance(getActivity());
    if (lastfm.isLoggedIn()) {

        //get selected tracks
        final List<Track> tracks = getSelectedTracks();

        AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
        builder.setMessage(
                "Did you just finished listening to " + mRelease.title + " or are you about to listen to it?")
                .setTitle("Scrobble this album?");
        builder.setPositiveButton("About to", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {
                //start now playing service
                Intent i = new Intent(getActivity(), NowPlayingService.class);
                i.putParcelableArrayListExtra(NowPlayingService.TRACK_LIST, new ArrayList<Track>(tracks));
                i.putExtra(NowPlayingService.THUMB_URL, mRelease.thumb);
                i.putExtra(NowPlayingService.RELEASE_ID, mRelease.releaseid);
                if (mRelease.images().size() > 0)
                    i.putExtra(NowPlayingService.ALBUM_ART_URL, mRelease.images().get(0).uri);
                getActivity().startService(i);
                //save to recentlyplayed
                mDiscogs.setRecentlyPlayed(mRelease);
                //go to the now playing activity
                startActivity(new Intent(getActivity(), NowPlayingActivity.class));
            }
        });
        builder.setNeutralButton("Just finished", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialogInterface, int i) {
                //scrobble the tracks now
                lastfm.scrobbleTracks(tracks, new Lastfm.LastfmWaiter() {
                    @Override
                    public void onResult(boolean success) {
                        if (getActivity() != null) {
                            Toast.makeText(getActivity(), "Scrobbled " + tracks.size() + " tracks",
                                    Toast.LENGTH_SHORT).show();
                            clearSelection();
                        }
                    }
                });
                //save to recentlyplayed
                mDiscogs.setRecentlyPlayed(mRelease);
            }
        });
        builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {
                // User cancelled the dialog don't do anything
            }
        });
        AlertDialog dialog = builder.create();
        dialog.show();

    } else {
        //log in first
        lastfm.logIn();
    }
}

From source file:edu.pdx.its.portal.routelandia.DatePickUp.java

@Override
public void onApiResult(APIResultWrapper resWrap) {
    trafficStatList = resWrap.getListResponse();

    loadingDialog.dismiss();/*from ww  w .j a va2s. co m*/
    activeAsyncs--;

    if (resWrap.getExceptions().size() > 0) {
        String errStr = "";
        Iterator eItr = resWrap.getExceptions().iterator();
        while (eItr.hasNext()) {
            // TODO: Handle specific exception differently?
            Exception tEx = (Exception) eItr.next();
            errStr += tEx.getMessage() + "\n\n";
        }

        new ErrorPopup("Error fetching statistics...", errStr).givePopup(this).show();
    } else {
        if (trafficStatList == null) {
            // This actually shouldn't happen because if no results returned an error SHOULD be,
            // and so the above block should have caught it... But we like to cover everything.
            Log.e(TAG, "No results returned from statistics query.");
            new ErrorPopup("Error", "Server returned no results").givePopup(this).show();
        } else {
            Intent intent = new Intent(getApplicationContext(), ListStat.class);
            intent.putParcelableArrayListExtra("travel info", trafficStatList);
            startActivity(intent);
        }
    }
}

From source file:com.poepoemyintswe.popularmovies.ui.MainFragment.java

private void initUI() {
    if (mTwoPane) {
        mLayoutManager = new GridLayoutManager(getActivity(), 2);
    } else {// w  w  w. j  a v a  2s . co m
        mLayoutManager = new GridLayoutManager(getActivity(), 3);
    }

    mRecyclerView.setLayoutManager(mLayoutManager);
    mRecyclerView.setHasFixedSize(true);
    int spacingInPixels = getResources().getDimensionPixelSize(R.dimen.spacing_nano);
    mRecyclerView.addItemDecoration(new SpacesItemDecoration(spacingInPixels));
    movieAdapter = new MovieAdapter(calculateWidth());
    mRecyclerView.setAdapter(movieAdapter);
    mRecyclerView.setVisibility(View.GONE);
    mRecyclerView.addOnScrollListener(new ScrollListener());

    movieAdapter.setOnItemClickListener(new MovieAdapter.ClickListener() {
        @Override
        public void onItemClick(View view, int position) {
            if (mTwoPane) {

            } else {
                Intent intent = new Intent(getActivity(), MovieDetailActivity.class);
                intent.putParcelableArrayListExtra(MOVIE, movieAdapter.getResults());
                intent.putExtra(POSITION, position);
                startActivity(intent);
            }

        }
    });
}

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

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.imc_state_fragment, container, false);

    mButton = (LinearLayout) view.findViewById(R.id.imc_state_button);
    mButton.setOnClickListener(new OnClickListener() {
        @Override/* w ww.  j  a  v a 2  s .c o  m*/
        public void onClick(View v) {
            Intent intent;
            if (mService != null && !mService.getRemediationInstructions().isEmpty()) {
                intent = new Intent(getActivity(), RemediationInstructionsActivity.class);
                intent.putParcelableArrayListExtra(
                        RemediationInstructionsFragment.EXTRA_REMEDIATION_INSTRUCTIONS,
                        new ArrayList<RemediationInstruction>(mService.getRemediationInstructions()));
            } else {
                intent = new Intent(getActivity(), LogActivity.class);
            }
            startActivity(intent);
        }
    });
    final GestureDetector gestures = new GestureDetector(getActivity(),
            new GestureDetector.SimpleOnGestureListener() {
                /* a better value would be getScaledTouchExplorationTapSlop() but that is hidden */
                private final int mMinDistance = ViewConfiguration.get(getActivity()).getScaledTouchSlop() * 4;

                @Override
                public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
                    if (Math.abs(e1.getX() - e2
                            .getX()) >= mMinDistance) { /* only if the user swiped a minimum horizontal distance */
                        if (mService != null) {
                            mService.setImcState(ImcState.UNKNOWN);
                        }
                        return true;
                    }
                    return false;
                }
            });
    mButton.setOnTouchListener(new OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            return gestures.onTouchEvent(event);
        }
    });

    mStateView = (TextView) view.findViewById(R.id.imc_state);
    mAction = (TextView) view.findViewById(R.id.action);

    return view;
}

From source file:com.speedtong.example.ui.account.LoginActivity.java

private void doLoginReuqest(String user_name, String user_pwd) {
    CCPParameters ccpParameters = new CCPParameters();
    ccpParameters.setParamerTagKey("Request");
    ccpParameters.add("secret_key", "a04daaca96294836bef207594a0a4df8");
    ccpParameters.add("user_name", user_name);
    ccpParameters.add("user_pwd", user_pwd);
    AsyncECRequestRunner.requestAsyncForEncrypt(
            "https://sandboxapp.cloopen.com:8883/2013-12-26/General/GetDemoAccounts", ccpParameters, "POST",
            true, new InnerRequestListener() {

                @Override//from w w w.j  a v  a2s. co m
                public void onECRequestException(CCPException arg0) {
                    ECLog4Util.e("TAG", "onECRequestException " + arg0.getMessage());
                    ToastUtil.showMessage(arg0.getMessage());
                    dismissPostingDialog();
                }

                @Override
                public void onComplete(String arg0) {
                    ECLog4Util.e("TAG", "onComplete " + arg0);
                    String json = OrgJosnUtils.xml2json(arg0);
                    if (json != null) {
                        try {
                            JSONObject mJSONObject = (JSONObject) (new JSONObject(json)).get("Response");
                            if ("000000".equals(mJSONObject.get("statusCode"))) {
                                ECLog4Util.e("TAG", "statusCode " + mJSONObject.get("statusCode"));
                                JSONObject app = (JSONObject) mJSONObject.get("Application");
                                JSONArray jarray = new JSONArray(app.get("SubAccount") + "");
                                int length = jarray.length();
                                ArrayList<ECContacts> arraylist = new ArrayList<ECContacts>();
                                for (int i = 0; i < length; i++) {
                                    JSONObject object = (JSONObject) jarray.get(i);
                                    ECContacts bean = new ECContacts(object.getString("voip_account"));
                                    bean.setToken(object.getString("voip_token"));
                                    bean.setSubAccount(object.getString("sub_account"));
                                    bean.setSubToken(object.getString("sub_token"));
                                    arraylist.add((bean));
                                }
                                saveAutoLogin();
                                Intent intent = new Intent(LoginActivity.this, AccountChooseActivity.class);
                                intent.putParcelableArrayListExtra("arraylist", arraylist);
                                intent.putParcelableArrayListExtra("arraylist", arraylist);
                                startActivityForResult(intent, 0xa);
                            } else {
                                ECLog4Util.e("TAG", "statusCode " + mJSONObject.get("statusCode"));
                                String errorMsg = mJSONObject.get("statusCode").toString();
                                if (mJSONObject.has("statusMsg")) {
                                    errorMsg = mJSONObject.get("statusMsg").toString();
                                }
                                ToastUtil.showMessage(errorMsg);
                            }
                        } catch (JSONException e) {
                            e.printStackTrace();
                            ToastUtil.showMessage(e.getMessage());
                        }
                    }

                    dismissPostingDialog();
                }

            });
}

From source file:com.xbm.android.matisse.ui.MatisseActivity.java

@Override
public void onClick(View v) {
    if (v.getId() == R.id.button_preview) {
        Intent intent = new Intent(this, SelectedPreviewActivity.class);
        intent.putExtra(BasePreviewActivity.EXTRA_DEFAULT_BUNDLE, mSelectedCollection.getDataWithBundle());
        startActivityForResult(intent, REQUEST_CODE_PREVIEW);
    } else if (v.getId() == R.id.button_apply) {
        Intent result = new Intent();
        ArrayList<Uri> selectedUris = (ArrayList<Uri>) mSelectedCollection.asListOfUri();
        result.putParcelableArrayListExtra(EXTRA_RESULT_SELECTION, selectedUris);
        ArrayList<String> selectedPaths = (ArrayList<String>) mSelectedCollection.asListOfString();
        result.putStringArrayListExtra(EXTRA_RESULT_SELECTION_PATH, selectedPaths);
        setResult(RESULT_OK, result);/*from   w w w  .ja  v  a2 s  .  c om*/
        finish();
    }
}

From source file:com.github.jvanhie.discogsscrobbler.ReleaseDetailFragment.java

public void scrobble() {
    //first a small sanity check
    if (mRelease == null)
        return;/*from   ww w.  j a  v a 2 s. c o m*/
    final Lastfm lastfm = Lastfm.getInstance(getActivity());
    if (lastfm.isLoggedIn()) {
        //we're in detailview, just scrobble everything
        if (mRelease != null) {
            AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
            builder.setMessage("Did you just finished listening to " + mRelease.title
                    + " or are you about to listen to it?").setTitle("Scrobble this album?");
            builder.setPositiveButton("About to", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    //start now playing service
                    Intent i = new Intent(getActivity(), NowPlayingService.class);
                    i.putParcelableArrayListExtra(NowPlayingService.TRACK_LIST,
                            new ArrayList<Track>(mRelease.tracklist()));
                    i.putExtra(NowPlayingService.THUMB_URL, mRelease.thumb);
                    i.putExtra(NowPlayingService.RELEASE_ID, mRelease.releaseid);
                    if (mRelease.images().size() > 0)
                        i.putExtra(NowPlayingService.ALBUM_ART_URL, mRelease.images().get(0).uri);
                    getActivity().startService(i);
                    //save to recentlyplayed
                    mDiscogs.setRecentlyPlayed(mRelease);
                    //go to the now playing activity
                    startActivity(new Intent(getActivity(), NowPlayingActivity.class));
                }
            });
            builder.setNeutralButton("Just finished", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                    //scrobble the tracks now
                    lastfm.scrobbleTracks(mRelease.tracklist(), new Lastfm.LastfmWaiter() {
                        @Override
                        public void onResult(boolean success) {
                            if (getActivity() != null) {
                                Toast.makeText(getActivity(),
                                        "Scrobbled " + mRelease.tracklist().size() + " tracks",
                                        Toast.LENGTH_SHORT).show();
                            }
                        }
                    });
                    //save to recentlyplayed
                    mDiscogs.setRecentlyPlayed(mRelease);
                }
            });
            builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    // User cancelled the dialog don't do anything
                }
            });
            AlertDialog dialog = builder.create();
            dialog.show();

        }
    } else {
        //log in first
        lastfm.logIn();
    }
}

From source file:com.dycode.jepretstory.mediachooser.fragment.BucketVideoFragment.java

private void init() {
    final String orderBy = MediaStore.Video.Media.DATE_TAKEN;
    mCursor = getActivity().getContentResolver().query(MediaStore.Video.Media.EXTERNAL_CONTENT_URI,
            PROJECTION_BUCKET, null, null, orderBy + " DESC");
    ArrayList<BucketEntry> buffer = new ArrayList<BucketEntry>();
    try {//from   w  w  w.  j  a  v  a2s.co  m
        while (mCursor.moveToNext()) {
            BucketEntry entry = new BucketEntry(mCursor.getInt(INDEX_BUCKET_ID),
                    mCursor.getString(INDEX_BUCKET_NAME), mCursor.getString(INDEX_BUCKET_URL));

            if (!buffer.contains(entry)) {
                buffer.add(entry);
            }
        }
        if (mCursor.getCount() > 0) {
            mBucketAdapter = new BucketGridAdapter(getActivity(), 0, buffer, true);
            mBucketAdapter.bucketVideoFragment = this;
            mGridView.setAdapter(mBucketAdapter);
        } else {
            Toast.makeText(getActivity(), getActivity().getString(R.string.no_media_file_available),
                    Toast.LENGTH_SHORT).show();
        }
        mGridView.setOnItemClickListener(new OnItemClickListener() {

            @Override
            public void onItemClick(AdapterView<?> adapter, View view, int position, long id) {

                BucketEntry bucketEntry = (BucketEntry) adapter.getItemAtPosition(position);
                Intent selectImageIntent = new Intent(getActivity(), HomeFragmentActivity.class);
                selectImageIntent.putExtra("name", bucketEntry.bucketName);
                selectImageIntent.putExtra("isFromBucket", true);
                if (mCurrentSelectedVideos != null) {
                    selectImageIntent.putParcelableArrayListExtra("selectedVideos", mCurrentSelectedVideos);
                }
                getActivity().startActivityForResult(selectImageIntent,
                        MediaChooserConstants.BUCKET_SELECT_VIDEO_CODE);

            }
        });

    } finally {
        mCursor.close();
    }
}