Click here to Skip to main content
15,880,503 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
after select multi images from gallery on specific order selection the code bring the images to the recycle view on random order not as I select on specific order or sort. for example I select B then A then C but the code always bring them with random sort or order like A C B and sometimes C A B. . the order seems undefined at first I thought android sort them based on date and time added to the gallery or what their name i mean alphabet letter but then I realize the order seems undefined. i'm not sure if I need to add listener with array track the user selections. any suggestion

What I have tried:

 <pre lang="Java">ArrayList imagesUriArrayList;
public static final int slect_photo = 100;
Bitmap bitmap1 = null;
RecyclerView rec;
LinearLayoutManager lnm;
Adopter_Browse list;
ArrayList<MyCard> mylist;

 public void Onclick_View(View view) {


    Intent intent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);//
    intent.setType("image/*");
    intent.setAction(Intent.ACTION_GET_CONTENT);

    intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);

    startActivityForResult(intent, slect_photo);
}


  @Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    if (resultCode == RESULT_OK) {


        if (data.getData() != null) {//data.getData() != null) {
   
                imagesUriArrayList = null;
                imagesUriArrayList = new ArrayList();

      try{
                for (int i = 0; i < data.getClipData().getItemCount(); i++) {

                    imagesUriArrayList.add(data.getClipData().getItemAt(i).getUri());

                    
                }


                
                
            } catch (Exception e) {
                Toast.makeText(this, "Something went wrong", Toast.LENGTH_LONG).show();
            }


            try {

                for (int i = 0; i < imagesUriArrayList.size(); i++) {
                     
                     

                    bitmap1 = MediaStore.Images.Media.getBitmap(this.getContentResolver(), (Uri) imagesUriArrayList.get(i));
                    mylist.add(new MyCard(count_s, bitmap1));

                }

            } catch (IOException e) {
                e.printStackTrace();
            }

            
          

            lnm = new LinearLayoutManager(this, RecyclerView.HORIZONTAL, false);

            list = new Adopter_Browse(mylist);

            rec.setLayoutManager(lnm);

            list.notifyDataSetChanged();
            rec.setAdapter(list);
        }
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900