Example usage for android.content Intent getParcelableArrayListExtra

List of usage examples for android.content Intent getParcelableArrayListExtra

Introduction

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

Prototype

public <T extends Parcelable> ArrayList<T> getParcelableArrayListExtra(String name) 

Source Link

Document

Retrieve extended data from the intent.

Usage

From source file:com.krayzk9s.imgurholo.services.UploadService.java

@Override
protected void onHandleIntent(Intent intent) {
    ids = new ArrayList<String>();
    if (intent.hasExtra("images")) {
        Log.d("recieving", "handling multiple");
        ArrayList<Parcelable> list = intent.getParcelableArrayListExtra("images");
        totalUpload = list.size();//from   ww  w. j a  v a  2 s.co  m
        for (Parcelable parcel : list) {
            Uri uri = (Uri) parcel;
            Log.d("recieving", uri.toString());
            SendImage sendImage = new SendImage(apiCall, FileUtils.getPath(this, uri), getApplicationContext(),
                    getResources(), this);
            Log.d("recieving", "executing");
            sendImage.execute();
        }
    } else {
        totalUpload = -1;
        SendImage sendImage = new SendImage(apiCall,
                FileUtils.getPath(getApplicationContext(), intent.getData()), getApplicationContext(),
                getResources(), this);
        sendImage.execute();
    }
}

From source file:com.odoo.base.ir.Attachment.java

public List<ODataRow> handleMultipleResult(Intent data) {
    List<ODataRow> attachments = new ArrayList<ODataRow>();
    ArrayList<Uri> fileUris = data.getParcelableArrayListExtra(Intent.EXTRA_STREAM);
    for (Uri uri : fileUris) {
        attachments.add(uriToDataRow(uri, null));
    }/*from  w ww. j av a 2 s .  co m*/
    return attachments;
}

From source file:com.bb.hbx.activitiy.InsurancePlanActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (100 == requestCode && 200 == resultCode) {
        if (data == null) {
            return;
        }/*ww w. j a  va2s  .c o  m*/
        customSyxPlan = data.getParcelableArrayListExtra("customSyxPlan");
        customJqxPlan = data.getParcelableArrayListExtra("customJqxPlan");
        customFjxPlan = data.getParcelableArrayListExtra("customFjxPlan");
        customQtxPlan = data.getParcelableArrayListExtra("customQtxPlan");
    }
}

From source file:com.openerp.base.ir.Attachment.java

public List<OEDataRow> handleMultipleResult(Intent data) {
    List<OEDataRow> attachments = new ArrayList<OEDataRow>();
    ArrayList<Uri> fileUris = data.getParcelableArrayListExtra(Intent.EXTRA_STREAM);
    for (Uri uri : fileUris) {
        attachments.add(uriToDataRow(uri, null));
    }//from   ww  w  .j av a2s  .  c o m
    return attachments;
}

From source file:moe.yukinoneko.gcomic.module.gallery.GalleryActivity.java

@Override
public void init() {
    mDecorView = getWindow().getDecorView();

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        CoordinatorLayout.LayoutParams lp = (CoordinatorLayout.LayoutParams) bottomBar.getLayoutParams();
        lp.setMargins(0, 0, 0, Utils.getNavigationBarHeight(this));
    }/*from  www .  j a  va 2  s .  c  o m*/

    mHandler = new Handler();
    mPreviousRunnable = new Runnable() {
        @Override
        public void run() {
            if (mCurChapterPosition < mChapters.size() - 1) {
                mLastChapterPosition = mCurChapterPosition;
                mCurChapterPosition += 1;
                fetchChapterContent(mChapters.get(mCurChapterPosition).chapterId);
            } else {
                galleryPager.setCurrentItem(1);
                galleryPager.setLocked(false);
                seekBar.setEnabled(true);
                showMessageSnackbar(R.string.already_first);
            }
        }
    };
    mNextRunnable = new Runnable() {
        @Override
        public void run() {
            if (mCurChapterPosition > 0) {
                mLastChapterPosition = mCurChapterPosition;
                mCurChapterPosition -= 1;
                fetchChapterContent(mChapters.get(mCurChapterPosition).chapterId);
            } else {
                galleryPager.setCurrentItem(mPagerAdapter.getCount() - 2);
                galleryPager.setLocked(false);
                seekBar.setEnabled(true);
                showMessageSnackbar(R.string.already_last);
            }
        }
    };

    galleryPager.setLocked(true);
    galleryPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

        }

        @Override
        public void onPageSelected(int position) {
            seekBar.setProgress(position - 1);

            intCurPage = position;
            if (intCurPage > mPagerAdapter.getCount() - 2) {
                intCurPage = mPagerAdapter.getCount() - 2;
            } else if (intCurPage < 1) {
                intCurPage = 1;
            }
            curPage.setText(String.valueOf(intCurPage));

            if (position == 0) {
                galleryPager.setLocked(true);
                seekBar.setEnabled(false);
                mHandler.postDelayed(mPreviousRunnable, 1000);
            } else if (position == mPagerAdapter.getCount() - 1) {
                galleryPager.setLocked(true);
                seekBar.setEnabled(false);
                mHandler.postDelayed(mNextRunnable, 1000);
            }
        }

        @Override
        public void onPageScrollStateChanged(int state) {

        }
    });
    mPagerAdapter = new GalleryPagerAdapter(getSupportFragmentManager());
    galleryPager.setAdapter(mPagerAdapter);

    seekBar.setEnabled(false);
    seekBar.setKeyProgressIncrement(1);
    seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {

        int progress = 0;

        @Override
        public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
            progress = i;
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {

        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
            galleryPager.setCurrentItem(progress + 1, false);
        }
    });

    loadErrorLayout.setBackgroundColor(0xFF444444);
    loadErrorTips.setTextColor(0x80FFFFFF);

    Intent intent = getIntent();

    mComicId = intent.getIntExtra(GALLERY_CMOIC_ID, -1);
    firstLetter = intent.getStringExtra(GALLERY_CMOIC_FIRST_LETTER);
    mChapters = intent.getParcelableArrayListExtra(GALLERY_CHAPTER_LIST);
    mCurChapterPosition = intent.getIntExtra(GALLERY_CHAPTER_POSITION, -1);
    mLastChapterPosition = mCurChapterPosition;
    mHistoryBrowsePosition = intent.getIntExtra(GALLERY_BROWSE_POSITION, 1);
    mToolbar.setTitle(mChapters.get(mCurChapterPosition).chapterTitle);

    galleryPager.setCurrentItem(1, false);

    fetchChapterContent(mChapters.get(mCurChapterPosition).chapterId);
}

From source file:com.amaze.filemanager.services.CopyService.java

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    Bundle b = new Bundle();
    ArrayList<BaseFile> files = intent.getParcelableArrayListExtra("FILE_PATHS");
    String FILE2 = intent.getStringExtra("COPY_DIRECTORY");
    int mode = intent.getIntExtra("MODE", 0);
    mNotifyManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    b.putInt("id", startId);
    Intent notificationIntent = new Intent(this, MainActivity.class);
    notificationIntent.setAction(Intent.ACTION_MAIN);
    notificationIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    notificationIntent.putExtra("openprocesses", true);
    PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
    mBuilder = new NotificationCompat.Builder(c);
    mBuilder.setContentIntent(pendingIntent);
    mBuilder.setContentTitle(getResources().getString(R.string.copying))

            .setSmallIcon(R.drawable.ic_content_copy_white_36dp);
    if (foreground) {
        startForeground(Integer.parseInt("456" + startId), mBuilder.build());
        foreground = false;// ww  w .  ja va 2  s .  c o  m
    }
    b.putBoolean("move", intent.getBooleanExtra("move", false));
    b.putString("FILE2", FILE2);
    b.putInt("MODE", mode);
    b.putParcelableArrayList("files", files);
    hash.put(startId, true);
    DataPackage intent1 = new DataPackage();
    intent1.setName(files.get(0).getName());
    intent1.setTotal(0);
    intent1.setDone(0);
    intent1.setId(startId);
    intent1.setP1(0);
    intent1.setP2(0);
    intent1.setMove(intent.getBooleanExtra("move", false));
    intent1.setCompleted(false);
    hash1.put(startId, intent1);
    //going async
    new DoInBackground().execute(b);

    // If we get killed, after returning from here, restart
    return START_STICKY;
}

From source file:com.somexapps.wyre.services.MediaService.java

private void handleIntent(Intent intent) {
    if (intent != null) {
        int songToPlay = -1;
        if (intent.getExtras() != null) {
            // Get list of songs
            songsList = intent.getParcelableArrayListExtra(EXTRA_SONG_LIST);

            // See if song to play was passed
            songToPlay = intent.getExtras().getInt(EXTRA_SONG_TO_PLAY, -1);
        }/*from w ww  .j a  v  a 2s  .  co  m*/

        switch (intent.getAction()) {
        case ACTION_PLAY:
            // Play the song
            playSong(songToPlay);

            // Notify transport controls
            mediaController.getTransportControls().play();

            break;
        case ACTION_STOP:
            // Notify transport controls
            mediaController.getTransportControls().stop();

            break;
        case ACTION_PAUSE:
            if (mediaPlayer != null && mediaPlayer.isPlaying()) {
                mediaPlayer.pause();
                isPaused = true;
            }

            // Notify transport controls
            mediaController.getTransportControls().pause();

            break;
        case ACTION_NEXT:
            // Switch to next song if one exists
            if (playingSongIndex + 1 < songsList.size()) {
                // Go to next song in list
                playingSongIndex++;

                // Play the song
                playSong(playingSongIndex);
            }

            // Notify transport controls
            mediaController.getTransportControls().skipToNext();

            break;
        case ACTION_PREVIOUS:
            // Switch to previous song if one exists
            if (playingSongIndex - 1 >= 0) {
                // Go to previous song in list
                playingSongIndex--;

                // Play the song
                playSong(playingSongIndex);
            }

            // Notify transport controls
            mediaController.getTransportControls().skipToPrevious();

            break;
        }
    }
}

From source file:com.filemanager.free.services.CopyService.java

@Override
public int onStartCommand(Intent intent, int flags, int startId) throws NullPointerException {
    Bundle b = new Bundle();
    ArrayList<BaseFile> files = intent.getParcelableArrayListExtra("FILE_PATHS");
    String FILE2 = intent.getStringExtra("COPY_DIRECTORY");
    int mode = intent.getIntExtra("MODE", 0);
    mNotifyManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    b.putInt("id", startId);
    Intent notificationIntent = new Intent(this, MainActivity.class);
    notificationIntent.setAction(Intent.ACTION_MAIN);
    notificationIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    notificationIntent.putExtra("openprocesses", true);
    PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
    mBuilder = new NotificationCompat.Builder(c);
    mBuilder.setContentIntent(pendingIntent);
    mBuilder.setContentTitle(getResources().getString(R.string.copying))

            .setSmallIcon(R.drawable.ic_content_copy_white_36dp);
    if (foreground) {
        startForeground(Integer.parseInt("456" + startId), mBuilder.build());
        foreground = false;//from www  .  j  av  a  2 s.c om
    }
    b.putBoolean("move", intent.getBooleanExtra("move", false));
    b.putString("FILE2", FILE2);
    b.putInt("MODE", mode);
    b.putParcelableArrayList("files", files);
    hash.put(startId, true);
    DataPackage intent1 = new DataPackage();
    intent1.setName(files.get(0).getName());
    intent1.setTotal(0);
    intent1.setDone(0);
    intent1.setId(startId);
    intent1.setP1(0);
    intent1.setP2(0);
    intent1.setMove(intent.getBooleanExtra("move", false));
    intent1.setCompleted(false);
    hash1.put(startId, intent1);
    //going async
    new DoInBackground().execute(b);

    // If we get killed, after returning from here, restart
    return START_STICKY;
}

From source file:com.thelastcrusade.soundstream.components.NetworkFragment.java

/**
 * Called to handle a find finished method.  This may be to pop up a dialog
 * or notify the user that no guests were found
 * //from   w  ww .  j  a v a 2  s.  c o  m
 * @param intent
 */
private void onFindFinished(Intent intent) {
    //first thing...reenable the add members button
    setButtonToDefaultState(addMembersButton);
    isSearchingAdd = false;

    //locally initiated device discovery...pop up a dialog for the user
    List<FoundGuest> guests = intent.getParcelableArrayListExtra(ConnectionService.EXTRA_GUESTS);

    //deduplicate and pull out the known items, so we can preselect them
    //NOTE: retained is the list of deduplicated found guests, known
    // is the list of guests that were previously paired.
    Set<FoundGuest> unique = new HashSet<FoundGuest>(guests);
    List<FoundGuest> retained = new ArrayList<FoundGuest>();
    List<FoundGuest> known = new ArrayList<FoundGuest>();
    for (FoundGuest guest : guests) {
        if (unique.contains(guest)) {
            retained.add(guest);
            unique.remove(guest);
        }
        if (guest.isKnown()) {
            known.add(guest);
        }
    }

    if (guests.isEmpty()) {
        Toaster.iToast(this.getActivity(), R.string.no_guests_found);
    } else {
        new MultiSelectListDialog<FoundGuest>(this.getActivity(), R.string.select_guests, R.string.connect)
                .setItems(retained).setSelected(known)
                .setOnClickListener(new IOnDialogMultiItemClickListener<FoundGuest>() {

                    @Override
                    public void onItemsClick(List<FoundGuest> foundGuests) {
                        tracker.trackFoundGuestsEvent(foundGuests.size());
                        getConnectionService().connectToGuests(foundGuests);
                    }
                }).show();
    }
}

From source file:org.sufficientlysecure.keychain.ui.EncryptFilesActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setFullScreenDialogClose(Activity.RESULT_OK, false);

    Intent intent = getIntent();
    String action = intent.getAction();
    String type = intent.getType();
    ArrayList<Uri> uris = new ArrayList<>();

    if (intent.getData() != null) {
        uris.add(intent.getData());/*from  ww  w.  j  a  v a 2  s .  c  o m*/
    }

    // When sending to OpenKeychain Encrypt via share menu
    if (Intent.ACTION_SEND.equals(action) && type != null) {
        // Files via content provider, override uri and action
        uris.clear();
        uris.add(intent.<Uri>getParcelableExtra(Intent.EXTRA_STREAM));
    }

    if (Intent.ACTION_SEND_MULTIPLE.equals(action) && type != null) {
        uris = intent.getParcelableArrayListExtra(Intent.EXTRA_STREAM);
    }

    if (savedInstanceState == null) {
        FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();

        EncryptFilesFragment encryptFragment = EncryptFilesFragment.newInstance(uris);
        transaction.replace(R.id.encrypt_file_container, encryptFragment);
        transaction.commit();
    }

}