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:de.gruenewald.udacity.spotifystreamer.controller.AppController.java

public void handleOnArtistSelected(final int pArtistPosition, final boolean pIsTabletMode)
        throws MissingDependencyException, ParameterException {
    registerArtistListPosition(pArtistPosition);

    if (mArtistListPosition <= -1) {
        throw new ParameterException("Can't execute 'handleOnArtistSelected'. Invalid artist's position.");
    }//from w  w  w. j  a  v a 2 s.  com

    if (mMainActivity == null) {
        throw new MissingDependencyException(
                "Can't execute 'handleOnArtistSelected'. Missing dependency: 'MainActivity'.");
    }

    if (pIsTabletMode && mTrackFragment == null) {
        throw new MissingDependencyException(
                "Can't execute 'handleOnArtistSelected'. Missing dependency: 'TrackFragment'.");
    }

    if (mArtistFragment == null) {
        throw new MissingDependencyException(
                "Can't execute: 'handleOnArtistSelected'. Missing dependency: 'ArtistFragment'.");
    }

    final ArtistListEntry myArtistEntry = mArtistFragment.getArtistListEntries().get(mArtistListPosition);

    //setup the request object for the top-track query
    Map<String, Object> myParameterMap = new HashMap<String, Object>();
    // TODO: Read the country from the settings
    myParameterMap.put("country", "US");

    SPOTIFY_API.getService().getArtistTopTrack(myArtistEntry.getArtistId(), myParameterMap,
            new Callback<Tracks>() {
                @Override
                public void success(Tracks t, Response response) {
                    if (t != null && t.tracks != null && t.tracks.size() > 0) {
                        final ArrayList<TrackListEntry> myTrackListEntries = new ArrayList<TrackListEntry>();
                        for (Track myTrack : t.tracks) {
                            TrackListEntry myCurrentEntry = new TrackListEntry(myTrack.id);
                            myCurrentEntry.setTrackName(myTrack.name);
                            if (myTrack.album != null) {
                                myCurrentEntry.setAlbumName(myTrack.album.name);
                                if (myTrack.album.images != null && myTrack.album.images.size() > 0) {
                                    myCurrentEntry.setAlbumCover(
                                            myTrack.album.images.get(myTrack.album.images.size() - 1).url);
                                    myCurrentEntry.setAlbumCoverLarge(myTrack.album.images.get(0).url);
                                }

                                myCurrentEntry.setPreviewUrl(myTrack.preview_url);
                            }
                            myTrackListEntries.add(myCurrentEntry);
                        }

                        MAIN_THREAD.post(new Runnable() {
                            @Override
                            public void run() {
                                //Check if mTrackFragment is set. If not we're on a smartphone
                                //and start a new TrackActivity as an intent. Else we re-use
                                //the fragment's instance and update the view.
                                if (mTrackFragment == null) {
                                    Intent trackIntent = new Intent(mMainActivity, TrackActivity.class);
                                    trackIntent.putExtra(TrackActivity.EXTRA_ARTISTENTRY, myArtistEntry);
                                    trackIntent.putParcelableArrayListExtra(TrackActivity.EXTRA_TRACKLIST,
                                            myTrackListEntries);
                                    mMainActivity.startActivity(trackIntent);
                                } else {
                                    mTrackFragment.setTitle(myArtistEntry.getArtistName());
                                    mTrackFragment.setNofResults(myTrackListEntries.size());
                                    mTrackFragment.populateListView(myTrackListEntries);
                                }
                            }
                        });
                    } else {
                        MAIN_THREAD.post(new Runnable() {
                            @Override
                            public void run() {
                                Toast.makeText(mMainActivity, R.string.track_search_error_noresults,
                                        Toast.LENGTH_SHORT).show();
                            }
                        });
                    }
                }

                @Override
                public void failure(RetrofitError error) {
                    MAIN_THREAD.post(new Runnable() {
                        @Override
                        public void run() {
                            Toast.makeText(mMainActivity, R.string.track_search_error_default,
                                    Toast.LENGTH_SHORT).show();
                        }
                    });
                }
            });
}

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

public void openApply(View v) {
    final String[] items = { "Day Pass", "Home Pass" };
    AlertDialog.Builder builder = new AlertDialog.Builder(baseContext);
    builder.setCancelable(true);/*from  w  w  w. j  av a 2s  . co  m*/
    builder.setTitle("Pass type ?");
    builder.setItems(items, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialogList, int item) {
            Intent intent = new Intent(baseContext, PassApplyActivity.class);
            intent.putExtra("pass_type", items[item]);
            if (relays != null && relays.size() > 0 && identifier != null) {
                intent.putParcelableArrayListExtra("relays", relays);
                intent.putExtra("identifier", identifier);
            }
            startActivity(intent);
        }
    });
    AlertDialog alertDialog = builder.create();
    alertDialog.show();
}

From source file:uk.org.crimetalk.fragments.ArticleListFragment.java

/**
 * Private method./*from  w w  w.  j  a  v  a  2 s  . co m*/
 * Starts a new {@link uk.org.crimetalk.SearchActivity}.
 */
private void startSearchActivity() {

    /* SearchActivity searches the articles of the outer Fragment (i.e. LibraryFragment and PressCuttingsFragment)
       so we must know what outer Fragment we are in before starting the Activity */
    switch (((ArticleListHelper) getArguments().getParcelable(ARG_ARTICLE_LIST_HELPER))
            .getFragmentIdentifier()) {

    case ArticleListHelper.LIBRARY_FRAGMENT:

        final ArrayList<ArticleListHelper> libraryArticleListHelperList = new ArrayList<>(
                LibraryFragment.getPages(getActivity()));

        final Intent librarySearchIntent = new Intent(getActivity(), SearchActivity.class);
        librarySearchIntent.putParcelableArrayListExtra(SearchActivity.ARG_ARTICLE_LIST_HELPER_LIST,
                libraryArticleListHelperList);
        librarySearchIntent.putExtra(SearchActivity.ARG_SEARCH_TEXT,
                getResources().getString(R.string.search_library));

        startActivity(librarySearchIntent);

        break;

    case ArticleListHelper.PRESSCUTTINGS_FRAGMENT:

        final ArrayList<ArticleListHelper> pressCuttingsArticleListHelperList = new ArrayList<>(
                PressCuttingsFragment.getPages(getActivity()));

        final Intent pressCuttingsSearchIntent = new Intent(getActivity(), SearchActivity.class);
        pressCuttingsSearchIntent.putParcelableArrayListExtra(SearchActivity.ARG_ARTICLE_LIST_HELPER_LIST,
                pressCuttingsArticleListHelperList);
        pressCuttingsSearchIntent.putExtra(SearchActivity.ARG_SEARCH_TEXT,
                getResources().getString(R.string.search_press_cuttings));

        startActivity(pressCuttingsSearchIntent);

        break;

    }

}

From source file:com.dat255.ht13.grupp23.activites.MapController.java

/**
 * Update method for a markerclick. When a marker is clicked - the method
 * starts a new intent MessageActivity which displays the list of messages
 * held by this marker/*from  w w  w  . j  ava  2s  . c o m*/
 * 
 * @param id
 *            The ID of the marker that was clicked
 * @param eventType
 *            The type of Event passed will always be MarkerClick for this
 *            method
 * 
 */
@Override
public void update(EventType eventType, int id) {
    if (eventType == EventType.MarkerClick) {
        /*if ((mapModel.getMessagePointById(id)).getMessages().size() == 0) {
           mapModel.AddMessageToMessagePoint(id, new Message("Text"));
        }*/

        Intent msgIntent = new Intent(MapController.this, MessageActivity.class);
        ArrayList<ParcelableMessage> parcelableMessages = new ArrayList<ParcelableMessage>();
        Iterator<Message> iterator = mapModel.getMessagePointById(id).getMessages().iterator();
        while (iterator.hasNext()) {
            parcelableMessages.add(new ParcelableMessage(iterator.next()));
        }
        msgIntent.putParcelableArrayListExtra("messages", parcelableMessages);
        msgIntent.putExtra("msgPID", id);
        startActivity(msgIntent);
        System.out.println("Initiating a MessageActivity");
    }
    // finish();
}

From source file:com.monkey.entonado.MainActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();
    if (id == R.id.action_settings) {
        Intent intent = new Intent(this, MiLista.class);
        intent.putParcelableArrayListExtra(EXTRA_LISTA, milista);
        startActivityForResult(intent, 999);
        intentoEnviarLista = false;//from w ww  . j  a v  a2 s  .  c o m
        return true;

    }
    return super.onOptionsItemSelected(item);
}

From source file:com.cerema.cloud2.ui.activity.LogHistoryActivity.java

/**
 * Start activity for sending email with logs attached
 *///from   w ww.j a  va2s. c o  m
private void sendMail() {

    // For the moment we need to consider the possibility that setup.xml
    // does not include the "mail_logger" entry. This block prevents that
    // compilation fails in this case.
    String emailAddress;
    try {
        Class<?> stringClass = R.string.class;
        Field mailLoggerField = stringClass.getField("mail_logger");
        int emailAddressId = (Integer) mailLoggerField.get(null);
        emailAddress = getString(emailAddressId);
    } catch (Exception e) {
        emailAddress = "";
    }

    ArrayList<Uri> uris = new ArrayList<Uri>();

    // Convert from paths to Android friendly Parcelable Uri's
    for (String file : Log_OC.getLogFileNames()) {
        File logFile = new File(mLogPath, file);
        if (logFile.exists()) {
            uris.add(Uri.fromFile(logFile));
        }
    }

    Intent intent = new Intent(Intent.ACTION_SEND_MULTIPLE);

    intent.putExtra(Intent.EXTRA_EMAIL, emailAddress);
    String subject = String.format(getString(R.string.log_send_mail_subject), getString(R.string.app_name));
    intent.putExtra(Intent.EXTRA_SUBJECT, subject);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.setType(MAIL_ATTACHMENT_TYPE);
    intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);
    try {
        startActivity(intent);
    } catch (ActivityNotFoundException e) {
        Toast.makeText(this, getString(R.string.log_send_no_mail_app), Toast.LENGTH_LONG).show();
        Log_OC.i(TAG, "Could not find app for sending log history.");
    }

}

From source file:com.synox.android.ui.activity.LogHistoryActivity.java

/**
 * Start activity for sending email with logs attached
 *///from  ww  w.  ja  v  a2  s . c o m
private void sendMail() {

    // For the moment we need to consider the possibility that setup.xml
    // does not include the "mail_logger" entry. This block prevents that
    // compilation fails in this case.
    String emailAddress;
    try {
        Class<?> stringClass = R.string.class;
        Field mailLoggerField = stringClass.getField("mail_logger");
        int emailAddressId = (Integer) mailLoggerField.get(null);
        emailAddress = getString(emailAddressId);
    } catch (Exception e) {
        emailAddress = "";
    }

    ArrayList<Uri> uris = new ArrayList<>();

    // Convert from paths to Android friendly Parcelable Uri's
    for (String file : Log_OC.getLogFileNames()) {
        File logFile = new File(mLogPath, file);
        if (logFile.exists()) {
            uris.add(Uri.fromFile(logFile));
        }
    }

    Intent intent = new Intent(Intent.ACTION_SEND_MULTIPLE);

    intent.putExtra(Intent.EXTRA_EMAIL, emailAddress);
    String subject = String.format(getString(R.string.log_send_mail_subject), getString(R.string.app_name));
    intent.putExtra(Intent.EXTRA_SUBJECT, subject);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.setType(MAIL_ATTACHMENT_TYPE);
    intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);
    try {
        startActivity(intent);
    } catch (ActivityNotFoundException e) {
        Toast.makeText(this, getString(R.string.log_send_no_mail_app), Toast.LENGTH_LONG).show();
        Log_OC.i(TAG, "Could not find app for sending log history.");
    }

}

From source file:de.appplant.cordova.plugin.emailcomposer.EmailComposer.java

/**
 * Fgt die Anhnde zur Mail hinzu./*  w  w w  .ja  v  a 2 s .  c om*/
 */
private void setAttachments(JSONArray attachments, Intent draft) throws JSONException {
    ArrayList<Uri> attachmentUris = new ArrayList<Uri>();

    for (int i = 0; i < attachments.length(); i++) {
        Uri attachmentUri = getUriForPath(attachments.getString(i));

        attachmentUris.add(attachmentUri);
    }

    draft.putParcelableArrayListExtra(Intent.EXTRA_STREAM, attachmentUris);
}

From source file:com.nbplus.vbroadlauncher.fragment.LoadIoTDevicesDialogFragmentStatus.java

public void showSyncAlertDialog() {
    new AlertDialog.Builder(getActivity()).setMessage(R.string.iot_devices_send_alert)
            //.setTitle(R.string.alert_network_title)
            .setCancelable(false)/*from  ww  w  . ja va  2 s  .c o m*/
            .setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {
                    dialog.dismiss();
                }
            }).setPositiveButton(R.string.alert_ok, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {
                    Intent sendIntent = new Intent();
                    sendIntent.setAction(Constants.ACTION_IOT_DEVICE_LIST);
                    sendIntent.putExtra(Constants.EXTRA_IOT_DEVICE_CANCELED, false);
                    sendIntent.putParcelableArrayListExtra(Constants.EXTRA_DATA, mIoTDevicesList);
                    LocalBroadcastManager.getInstance(getActivity()).sendBroadcast(sendIntent);

                    dialog.dismiss();
                    dismissDialogFragment();
                }
            }).show();
}

From source file:com.monkey.entonado.MainActivity.java

/**
 * Recibe la informacion del servidor con las canciones
 * o cualcquier informacion   `//from ww w. j  a va2  s.  c o  m
 * @return Mensaje
 */
public String recibir() {
    String mensajeRecibir = "";
    try {
        System.out.println("recibiendo canciones metodo recibir");
        String linea = in.readLine();
        if (linea == null) {
            mensajeConexion = "desconectado";
            mensajeRecibir = mensajeConexion;
        }
        System.out.println("-----" + linea + "-----");

        int i = 0;
        while (linea != null && !linea.equals("TERMINO")) {
            i++;
            System.out.println(linea);

            if (linea.split(";").length > 1) {
                String[] lineaSp = linea.split(";");

                if (lineaSp[0].equals(AGREGAR_CANCION)) {
                    String[] infoCancion = lineaSp[1].split(" : ");
                    Cancion cancion = new Cancion(infoCancion[0], infoCancion[1], infoCancion[2]);
                    System.out.println("agrega cancion : " + cancion);
                    canciones.add(cancion);
                } else {
                    mensajeRecibir = lineaSp[1];
                    System.out.println("mensaje no == AGREGAR_CANCION");
                }
            }

            System.out.println("No entro AGREGAR");
            linea = in.readLine();
        }
        System.out.println("linae al final es: " + linea);

        Intent intent = new Intent(this, Resultados.class);
        intent.putParcelableArrayListExtra(EXTRA_CANCIONES, canciones);
        intent.putParcelableArrayListExtra(EXTRA_LISTA, milista);
        startActivityForResult(intent, 999);
    } catch (SocketException e) {
        mensajeRecibir = e.getMessage();
        e.printStackTrace();
    } catch (IOException e) {
        mensajeRecibir = e.getMessage();
        e.printStackTrace();
    } catch (Exception e) {
        mensajeRecibir = e.getMessage();
        e.printStackTrace();
    }
    return mensajeRecibir;
}