How to get Arraylist as output with the help of Glide?How to convert a Drawable to a Bitmap?How to get Bitmap from an Uri?How to get the build/version number of your Android application?How to set view or Activity for dealing with previous listactivity? for example “see full detail page”Get Bitmap attached to ImageViewCan someone show me a simple working implementation of PagerSlidingTabStrip?How to round an image with Glide library?Adding Social Media Share Logic From Firebase in Androidjava.lang.NullPointerException when invoking onLoadFinished()Search Firestore query don't show data in RecycleView

Past participle agreement with the subject in the case of pronominal verbs

Why do guitarists wave their guitars?

How to detach yourself from a character you're going to kill?

How to connect an offset point symbol to its original position in QGIS?

Metal bar on DMM PCB

How could a possessed body begin to rot and decay while it is still alive?

Side by side histograms

Do I include animal companions when calculating difficulty of an encounter?

Personalization conditions switching doesn`t work in Experience Editor (9.1.0, Initial Release)

What are the words for people who cause trouble believing they know better?

How can Iron Man's suit withstand this?

What happens to foam insulation board after you pour concrete slab?

Does any lore text explain why the planes of Acheron, Gehenna, and Carceri are the alignment they are?

What is the purpose of building foundations?

How certain is a caster of when their spell will end?

Accidentally renamed tar.gz file to a non tar.gz file, will my file be messed up

Did thousands of women die every year due to illegal abortions before Roe v. Wade?

Is there any word or phrase for negative bearing?

California: "For quality assurance, this phone call is being recorded"

Building a road to escape Earth's gravity by making a pyramid on Antartica

Can we use the verb "says" for advertisement?

Does resistor placement change power dissipation in simple LED circuit?

Avoiding cliches when writing gods

Credit card offering 0.5 miles for every cent rounded up. Too good to be true?



How to get Arraylist as output with the help of Glide?


How to convert a Drawable to a Bitmap?How to get Bitmap from an Uri?How to get the build/version number of your Android application?How to set view or Activity for dealing with previous listactivity? for example “see full detail page”Get Bitmap attached to ImageViewCan someone show me a simple working implementation of PagerSlidingTabStrip?How to round an image with Glide library?Adding Social Media Share Logic From Firebase in Androidjava.lang.NullPointerException when invoking onLoadFinished()Search Firestore query don't show data in RecycleView






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








1















enter image description here
This image shows current output which is shuffled and duplicate



I have an arraylist mp3 file paths I want to extract thumbnails from them it is working fine with the First Code of Bitmap but extraction speed is too slow.



filterpath==path of MP3 files.



MEDIACOVER==Arraylist to store bitmap images.



Glide version==com.github.bumptech.glide:glide:4.8.0, I think this is the latest version of Glide.



public class Main2Activity extends AppCompatActivity {
private ArrayAdapter<Bitmap> adp;
ListView lv;
ArrayList<String> path;

@Override
protected void onCreate(Bundle savedInstanceState)
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main2);
path=new ArrayList<>();
lv=findViewById(R.id.chckimage);
Intent in=getIntent();
path=in.getStringArrayListExtra("path");
adp = new ArrayAdapter(Main2Activity.this,
android.R.layout.simple_list_item_1);
lv.setAdapter(adp);
loadArrayList(path);
lv.setOnItemClickListener(new AdapterView.OnItemClickListener()
@Override
public void onItemClick(AdapterView<?> parent, View view, int
position, long id)
ImageView iv=findViewById(R.id.getting);
iv.setImageBitmap(adp.getItem(position));
Toast.makeText(Main2Activity.this, ""+adp.getItem(position),
Toast.LENGTH_LONG).show();

);



Now method to Load images.....



 public void loadArrayList(ArrayList<String> Path) 
try
for(String temp:Path)
MediaMetadataRetriever mmr = new MediaMetadataRetriever();
mmr.setDataSource(temp);
byte[] data = mmr.getEmbeddedPicture();
if (data != null)
Glide.with(this)
.asBitmap()
.load(data)
.thumbnail(0.1f)
.apply(RequestOptions.circleCropTransform()) //------getting image in circle
.listener(new RequestListener<Bitmap>()
@Override
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Bitmap> target, boolean isFirstResource)
return false;


@Override
public boolean onResourceReady(Bitmap resource, Object model, Target<Bitmap> target, DataSource dataSource, boolean isFirstResource)
adp.add(resource);
return true;

).submit();
mmr.release();
else

//LOAD FROM DRAWABLE



catch (Exception e)



Here, I used imageview for checking, Now its give another errors like
duplicates values and also shufled from their paths



I want to get total images from total paths in arraylist



I am getting this outputs by running same app...and the size of path arraylist is only 5. But its give me output 10 bitmap images with duplicate of every value










share|improve this question
























  • Comments are not for extended discussion; this conversation has been moved to chat.

    – Samuel Liew
    Jan 22 at 8:50

















1















enter image description here
This image shows current output which is shuffled and duplicate



I have an arraylist mp3 file paths I want to extract thumbnails from them it is working fine with the First Code of Bitmap but extraction speed is too slow.



filterpath==path of MP3 files.



MEDIACOVER==Arraylist to store bitmap images.



Glide version==com.github.bumptech.glide:glide:4.8.0, I think this is the latest version of Glide.



public class Main2Activity extends AppCompatActivity {
private ArrayAdapter<Bitmap> adp;
ListView lv;
ArrayList<String> path;

@Override
protected void onCreate(Bundle savedInstanceState)
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main2);
path=new ArrayList<>();
lv=findViewById(R.id.chckimage);
Intent in=getIntent();
path=in.getStringArrayListExtra("path");
adp = new ArrayAdapter(Main2Activity.this,
android.R.layout.simple_list_item_1);
lv.setAdapter(adp);
loadArrayList(path);
lv.setOnItemClickListener(new AdapterView.OnItemClickListener()
@Override
public void onItemClick(AdapterView<?> parent, View view, int
position, long id)
ImageView iv=findViewById(R.id.getting);
iv.setImageBitmap(adp.getItem(position));
Toast.makeText(Main2Activity.this, ""+adp.getItem(position),
Toast.LENGTH_LONG).show();

);



Now method to Load images.....



 public void loadArrayList(ArrayList<String> Path) 
try
for(String temp:Path)
MediaMetadataRetriever mmr = new MediaMetadataRetriever();
mmr.setDataSource(temp);
byte[] data = mmr.getEmbeddedPicture();
if (data != null)
Glide.with(this)
.asBitmap()
.load(data)
.thumbnail(0.1f)
.apply(RequestOptions.circleCropTransform()) //------getting image in circle
.listener(new RequestListener<Bitmap>()
@Override
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Bitmap> target, boolean isFirstResource)
return false;


@Override
public boolean onResourceReady(Bitmap resource, Object model, Target<Bitmap> target, DataSource dataSource, boolean isFirstResource)
adp.add(resource);
return true;

).submit();
mmr.release();
else

//LOAD FROM DRAWABLE



catch (Exception e)



Here, I used imageview for checking, Now its give another errors like
duplicates values and also shufled from their paths



I want to get total images from total paths in arraylist



I am getting this outputs by running same app...and the size of path arraylist is only 5. But its give me output 10 bitmap images with duplicate of every value










share|improve this question
























  • Comments are not for extended discussion; this conversation has been moved to chat.

    – Samuel Liew
    Jan 22 at 8:50













1












1








1








enter image description here
This image shows current output which is shuffled and duplicate



I have an arraylist mp3 file paths I want to extract thumbnails from them it is working fine with the First Code of Bitmap but extraction speed is too slow.



filterpath==path of MP3 files.



MEDIACOVER==Arraylist to store bitmap images.



Glide version==com.github.bumptech.glide:glide:4.8.0, I think this is the latest version of Glide.



public class Main2Activity extends AppCompatActivity {
private ArrayAdapter<Bitmap> adp;
ListView lv;
ArrayList<String> path;

@Override
protected void onCreate(Bundle savedInstanceState)
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main2);
path=new ArrayList<>();
lv=findViewById(R.id.chckimage);
Intent in=getIntent();
path=in.getStringArrayListExtra("path");
adp = new ArrayAdapter(Main2Activity.this,
android.R.layout.simple_list_item_1);
lv.setAdapter(adp);
loadArrayList(path);
lv.setOnItemClickListener(new AdapterView.OnItemClickListener()
@Override
public void onItemClick(AdapterView<?> parent, View view, int
position, long id)
ImageView iv=findViewById(R.id.getting);
iv.setImageBitmap(adp.getItem(position));
Toast.makeText(Main2Activity.this, ""+adp.getItem(position),
Toast.LENGTH_LONG).show();

);



Now method to Load images.....



 public void loadArrayList(ArrayList<String> Path) 
try
for(String temp:Path)
MediaMetadataRetriever mmr = new MediaMetadataRetriever();
mmr.setDataSource(temp);
byte[] data = mmr.getEmbeddedPicture();
if (data != null)
Glide.with(this)
.asBitmap()
.load(data)
.thumbnail(0.1f)
.apply(RequestOptions.circleCropTransform()) //------getting image in circle
.listener(new RequestListener<Bitmap>()
@Override
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Bitmap> target, boolean isFirstResource)
return false;


@Override
public boolean onResourceReady(Bitmap resource, Object model, Target<Bitmap> target, DataSource dataSource, boolean isFirstResource)
adp.add(resource);
return true;

).submit();
mmr.release();
else

//LOAD FROM DRAWABLE



catch (Exception e)



Here, I used imageview for checking, Now its give another errors like
duplicates values and also shufled from their paths



I want to get total images from total paths in arraylist



I am getting this outputs by running same app...and the size of path arraylist is only 5. But its give me output 10 bitmap images with duplicate of every value










share|improve this question
















enter image description here
This image shows current output which is shuffled and duplicate



I have an arraylist mp3 file paths I want to extract thumbnails from them it is working fine with the First Code of Bitmap but extraction speed is too slow.



filterpath==path of MP3 files.



MEDIACOVER==Arraylist to store bitmap images.



Glide version==com.github.bumptech.glide:glide:4.8.0, I think this is the latest version of Glide.



public class Main2Activity extends AppCompatActivity {
private ArrayAdapter<Bitmap> adp;
ListView lv;
ArrayList<String> path;

@Override
protected void onCreate(Bundle savedInstanceState)
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main2);
path=new ArrayList<>();
lv=findViewById(R.id.chckimage);
Intent in=getIntent();
path=in.getStringArrayListExtra("path");
adp = new ArrayAdapter(Main2Activity.this,
android.R.layout.simple_list_item_1);
lv.setAdapter(adp);
loadArrayList(path);
lv.setOnItemClickListener(new AdapterView.OnItemClickListener()
@Override
public void onItemClick(AdapterView<?> parent, View view, int
position, long id)
ImageView iv=findViewById(R.id.getting);
iv.setImageBitmap(adp.getItem(position));
Toast.makeText(Main2Activity.this, ""+adp.getItem(position),
Toast.LENGTH_LONG).show();

);



Now method to Load images.....



 public void loadArrayList(ArrayList<String> Path) 
try
for(String temp:Path)
MediaMetadataRetriever mmr = new MediaMetadataRetriever();
mmr.setDataSource(temp);
byte[] data = mmr.getEmbeddedPicture();
if (data != null)
Glide.with(this)
.asBitmap()
.load(data)
.thumbnail(0.1f)
.apply(RequestOptions.circleCropTransform()) //------getting image in circle
.listener(new RequestListener<Bitmap>()
@Override
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Bitmap> target, boolean isFirstResource)
return false;


@Override
public boolean onResourceReady(Bitmap resource, Object model, Target<Bitmap> target, DataSource dataSource, boolean isFirstResource)
adp.add(resource);
return true;

).submit();
mmr.release();
else

//LOAD FROM DRAWABLE



catch (Exception e)



Here, I used imageview for checking, Now its give another errors like
duplicates values and also shufled from their paths



I want to get total images from total paths in arraylist



I am getting this outputs by running same app...and the size of path arraylist is only 5. But its give me output 10 bitmap images with duplicate of every value







android thumbnails android-bitmap android-glide






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 24 at 13:27









Zoe

15.1k85789




15.1k85789










asked Jan 20 at 13:00









Vipul ChauhanVipul Chauhan

276115




276115












  • Comments are not for extended discussion; this conversation has been moved to chat.

    – Samuel Liew
    Jan 22 at 8:50

















  • Comments are not for extended discussion; this conversation has been moved to chat.

    – Samuel Liew
    Jan 22 at 8:50
















Comments are not for extended discussion; this conversation has been moved to chat.

– Samuel Liew
Jan 22 at 8:50





Comments are not for extended discussion; this conversation has been moved to chat.

– Samuel Liew
Jan 22 at 8:50












2 Answers
2






active

oldest

votes


















1














Now i found a answer for my question and want to help others to not stuck in this same problem...



public class GlideBitmap extends AppCompatActivity 
MediaMetadataRetriever mmr;
byte[] data;
ArrayList<Bitmap> BMP;
ListView listView;
Bitmap bitmap;

@Override
protected void onCreate(Bundle savedInstanceState)
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_glide_bitmap);
listView=findViewById(R.id.bitmap);
BMP=new ArrayList<>();
try
gettingData();
catch (ExecutionException e)
e.printStackTrace();
Toast.makeText(this, ""+e.toString(), Toast.LENGTH_SHORT).show();
catch (InterruptedException e)
e.printStackTrace();
Toast.makeText(this, ""+e.toString(), Toast.LENGTH_SHORT).show();

//Here Toast is used to check the size of arraylist that
//is it equal to path list or not.
int size=BMP.size();
Toast.makeText(this, ""+size, Toast.LENGTH_SHORT).show();




Now let's see the Main method of this answer...



public ArrayList<Bitmap> gettingData() throws ExecutionException, InterruptedException 
mmr=new MediaMetadataRetriever();
for(String temp:MainActivity.path)
mmr.setDataSource(temp);
data=mmr.getEmbeddedPicture();

if(data!=null)
Glide.with(this)
.asBitmap()
.load(data)
.listener(new RequestListener<Bitmap>()
@Override
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Bitmap> target, boolean isFirstResource)
return false;


@Override
public boolean onResourceReady(Bitmap resource, Object model, Target<Bitmap> target, DataSource dataSource, boolean isFirstResource)
bitmap=resource;
return false;

).submit();
BMP.add(bitmap);
bitmap=null;

else
Glide.with(this)
.asBitmap()
.load(R.drawable.example_picture)
.listener(new RequestListener<Bitmap>()
@Override
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Bitmap> target, boolean isFirstResource)
return false;


@Override
public boolean onResourceReady(Bitmap resource, Object model, Target<Bitmap> target, DataSource dataSource, boolean isFirstResource)
bitmap=resource;
return false;

).submit();
BMP.add(bitmap);
bitmap=null;


return BMP;







share|improve this answer






























    0














    try change the method of glide from asynchronous into synchronous.



    public ArrayList<Bitmap> getArrayList(ArrayList<String> Path) 
    try
    arrayList=new ArrayList<>();
    for(String temp:Path)
    MediaMetadataRetriever mmr = new MediaMetadataRetriever();
    mmr.setDataSource(temp);
    byte[] data = mmr.getEmbeddedPicture();
    if (data != null)
    FutureTarget<Bitmap> submit = Glide.with(this)
    .asBitmap()
    .load(data)
    .thumbnail(0.1f)
    .apply(RequestOptions.circleCropTransform()) //------getting image in circle
    .submit();
    button.setImageBitmap(submit.get());
    arrayList.add(submit.get());
    mmr.release();
    else
    Bitmap bitmap=BitmapFactory.decodeResource(this.getResources(),
    R.drawable.example_picture);
    arrayList.add(bitmap);
    mmr.release();



    catch (Exception e)

    return arrayList;






    share|improve this answer























    • this method is not working buddy it show nothing in both arraylist or imageview

      – Vipul Chauhan
      Jan 22 at 6:45












    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54276708%2fhow-to-get-arraylistbitmap-as-output-with-the-help-of-glide%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    Now i found a answer for my question and want to help others to not stuck in this same problem...



    public class GlideBitmap extends AppCompatActivity 
    MediaMetadataRetriever mmr;
    byte[] data;
    ArrayList<Bitmap> BMP;
    ListView listView;
    Bitmap bitmap;

    @Override
    protected void onCreate(Bundle savedInstanceState)
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_glide_bitmap);
    listView=findViewById(R.id.bitmap);
    BMP=new ArrayList<>();
    try
    gettingData();
    catch (ExecutionException e)
    e.printStackTrace();
    Toast.makeText(this, ""+e.toString(), Toast.LENGTH_SHORT).show();
    catch (InterruptedException e)
    e.printStackTrace();
    Toast.makeText(this, ""+e.toString(), Toast.LENGTH_SHORT).show();

    //Here Toast is used to check the size of arraylist that
    //is it equal to path list or not.
    int size=BMP.size();
    Toast.makeText(this, ""+size, Toast.LENGTH_SHORT).show();




    Now let's see the Main method of this answer...



    public ArrayList<Bitmap> gettingData() throws ExecutionException, InterruptedException 
    mmr=new MediaMetadataRetriever();
    for(String temp:MainActivity.path)
    mmr.setDataSource(temp);
    data=mmr.getEmbeddedPicture();

    if(data!=null)
    Glide.with(this)
    .asBitmap()
    .load(data)
    .listener(new RequestListener<Bitmap>()
    @Override
    public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Bitmap> target, boolean isFirstResource)
    return false;


    @Override
    public boolean onResourceReady(Bitmap resource, Object model, Target<Bitmap> target, DataSource dataSource, boolean isFirstResource)
    bitmap=resource;
    return false;

    ).submit();
    BMP.add(bitmap);
    bitmap=null;

    else
    Glide.with(this)
    .asBitmap()
    .load(R.drawable.example_picture)
    .listener(new RequestListener<Bitmap>()
    @Override
    public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Bitmap> target, boolean isFirstResource)
    return false;


    @Override
    public boolean onResourceReady(Bitmap resource, Object model, Target<Bitmap> target, DataSource dataSource, boolean isFirstResource)
    bitmap=resource;
    return false;

    ).submit();
    BMP.add(bitmap);
    bitmap=null;


    return BMP;







    share|improve this answer



























      1














      Now i found a answer for my question and want to help others to not stuck in this same problem...



      public class GlideBitmap extends AppCompatActivity 
      MediaMetadataRetriever mmr;
      byte[] data;
      ArrayList<Bitmap> BMP;
      ListView listView;
      Bitmap bitmap;

      @Override
      protected void onCreate(Bundle savedInstanceState)
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_glide_bitmap);
      listView=findViewById(R.id.bitmap);
      BMP=new ArrayList<>();
      try
      gettingData();
      catch (ExecutionException e)
      e.printStackTrace();
      Toast.makeText(this, ""+e.toString(), Toast.LENGTH_SHORT).show();
      catch (InterruptedException e)
      e.printStackTrace();
      Toast.makeText(this, ""+e.toString(), Toast.LENGTH_SHORT).show();

      //Here Toast is used to check the size of arraylist that
      //is it equal to path list or not.
      int size=BMP.size();
      Toast.makeText(this, ""+size, Toast.LENGTH_SHORT).show();




      Now let's see the Main method of this answer...



      public ArrayList<Bitmap> gettingData() throws ExecutionException, InterruptedException 
      mmr=new MediaMetadataRetriever();
      for(String temp:MainActivity.path)
      mmr.setDataSource(temp);
      data=mmr.getEmbeddedPicture();

      if(data!=null)
      Glide.with(this)
      .asBitmap()
      .load(data)
      .listener(new RequestListener<Bitmap>()
      @Override
      public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Bitmap> target, boolean isFirstResource)
      return false;


      @Override
      public boolean onResourceReady(Bitmap resource, Object model, Target<Bitmap> target, DataSource dataSource, boolean isFirstResource)
      bitmap=resource;
      return false;

      ).submit();
      BMP.add(bitmap);
      bitmap=null;

      else
      Glide.with(this)
      .asBitmap()
      .load(R.drawable.example_picture)
      .listener(new RequestListener<Bitmap>()
      @Override
      public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Bitmap> target, boolean isFirstResource)
      return false;


      @Override
      public boolean onResourceReady(Bitmap resource, Object model, Target<Bitmap> target, DataSource dataSource, boolean isFirstResource)
      bitmap=resource;
      return false;

      ).submit();
      BMP.add(bitmap);
      bitmap=null;


      return BMP;







      share|improve this answer

























        1












        1








        1







        Now i found a answer for my question and want to help others to not stuck in this same problem...



        public class GlideBitmap extends AppCompatActivity 
        MediaMetadataRetriever mmr;
        byte[] data;
        ArrayList<Bitmap> BMP;
        ListView listView;
        Bitmap bitmap;

        @Override
        protected void onCreate(Bundle savedInstanceState)
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_glide_bitmap);
        listView=findViewById(R.id.bitmap);
        BMP=new ArrayList<>();
        try
        gettingData();
        catch (ExecutionException e)
        e.printStackTrace();
        Toast.makeText(this, ""+e.toString(), Toast.LENGTH_SHORT).show();
        catch (InterruptedException e)
        e.printStackTrace();
        Toast.makeText(this, ""+e.toString(), Toast.LENGTH_SHORT).show();

        //Here Toast is used to check the size of arraylist that
        //is it equal to path list or not.
        int size=BMP.size();
        Toast.makeText(this, ""+size, Toast.LENGTH_SHORT).show();




        Now let's see the Main method of this answer...



        public ArrayList<Bitmap> gettingData() throws ExecutionException, InterruptedException 
        mmr=new MediaMetadataRetriever();
        for(String temp:MainActivity.path)
        mmr.setDataSource(temp);
        data=mmr.getEmbeddedPicture();

        if(data!=null)
        Glide.with(this)
        .asBitmap()
        .load(data)
        .listener(new RequestListener<Bitmap>()
        @Override
        public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Bitmap> target, boolean isFirstResource)
        return false;


        @Override
        public boolean onResourceReady(Bitmap resource, Object model, Target<Bitmap> target, DataSource dataSource, boolean isFirstResource)
        bitmap=resource;
        return false;

        ).submit();
        BMP.add(bitmap);
        bitmap=null;

        else
        Glide.with(this)
        .asBitmap()
        .load(R.drawable.example_picture)
        .listener(new RequestListener<Bitmap>()
        @Override
        public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Bitmap> target, boolean isFirstResource)
        return false;


        @Override
        public boolean onResourceReady(Bitmap resource, Object model, Target<Bitmap> target, DataSource dataSource, boolean isFirstResource)
        bitmap=resource;
        return false;

        ).submit();
        BMP.add(bitmap);
        bitmap=null;


        return BMP;







        share|improve this answer













        Now i found a answer for my question and want to help others to not stuck in this same problem...



        public class GlideBitmap extends AppCompatActivity 
        MediaMetadataRetriever mmr;
        byte[] data;
        ArrayList<Bitmap> BMP;
        ListView listView;
        Bitmap bitmap;

        @Override
        protected void onCreate(Bundle savedInstanceState)
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_glide_bitmap);
        listView=findViewById(R.id.bitmap);
        BMP=new ArrayList<>();
        try
        gettingData();
        catch (ExecutionException e)
        e.printStackTrace();
        Toast.makeText(this, ""+e.toString(), Toast.LENGTH_SHORT).show();
        catch (InterruptedException e)
        e.printStackTrace();
        Toast.makeText(this, ""+e.toString(), Toast.LENGTH_SHORT).show();

        //Here Toast is used to check the size of arraylist that
        //is it equal to path list or not.
        int size=BMP.size();
        Toast.makeText(this, ""+size, Toast.LENGTH_SHORT).show();




        Now let's see the Main method of this answer...



        public ArrayList<Bitmap> gettingData() throws ExecutionException, InterruptedException 
        mmr=new MediaMetadataRetriever();
        for(String temp:MainActivity.path)
        mmr.setDataSource(temp);
        data=mmr.getEmbeddedPicture();

        if(data!=null)
        Glide.with(this)
        .asBitmap()
        .load(data)
        .listener(new RequestListener<Bitmap>()
        @Override
        public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Bitmap> target, boolean isFirstResource)
        return false;


        @Override
        public boolean onResourceReady(Bitmap resource, Object model, Target<Bitmap> target, DataSource dataSource, boolean isFirstResource)
        bitmap=resource;
        return false;

        ).submit();
        BMP.add(bitmap);
        bitmap=null;

        else
        Glide.with(this)
        .asBitmap()
        .load(R.drawable.example_picture)
        .listener(new RequestListener<Bitmap>()
        @Override
        public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Bitmap> target, boolean isFirstResource)
        return false;


        @Override
        public boolean onResourceReady(Bitmap resource, Object model, Target<Bitmap> target, DataSource dataSource, boolean isFirstResource)
        bitmap=resource;
        return false;

        ).submit();
        BMP.add(bitmap);
        bitmap=null;


        return BMP;








        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Jan 26 at 8:34









        Vipul ChauhanVipul Chauhan

        276115




        276115























            0














            try change the method of glide from asynchronous into synchronous.



            public ArrayList<Bitmap> getArrayList(ArrayList<String> Path) 
            try
            arrayList=new ArrayList<>();
            for(String temp:Path)
            MediaMetadataRetriever mmr = new MediaMetadataRetriever();
            mmr.setDataSource(temp);
            byte[] data = mmr.getEmbeddedPicture();
            if (data != null)
            FutureTarget<Bitmap> submit = Glide.with(this)
            .asBitmap()
            .load(data)
            .thumbnail(0.1f)
            .apply(RequestOptions.circleCropTransform()) //------getting image in circle
            .submit();
            button.setImageBitmap(submit.get());
            arrayList.add(submit.get());
            mmr.release();
            else
            Bitmap bitmap=BitmapFactory.decodeResource(this.getResources(),
            R.drawable.example_picture);
            arrayList.add(bitmap);
            mmr.release();



            catch (Exception e)

            return arrayList;






            share|improve this answer























            • this method is not working buddy it show nothing in both arraylist or imageview

              – Vipul Chauhan
              Jan 22 at 6:45
















            0














            try change the method of glide from asynchronous into synchronous.



            public ArrayList<Bitmap> getArrayList(ArrayList<String> Path) 
            try
            arrayList=new ArrayList<>();
            for(String temp:Path)
            MediaMetadataRetriever mmr = new MediaMetadataRetriever();
            mmr.setDataSource(temp);
            byte[] data = mmr.getEmbeddedPicture();
            if (data != null)
            FutureTarget<Bitmap> submit = Glide.with(this)
            .asBitmap()
            .load(data)
            .thumbnail(0.1f)
            .apply(RequestOptions.circleCropTransform()) //------getting image in circle
            .submit();
            button.setImageBitmap(submit.get());
            arrayList.add(submit.get());
            mmr.release();
            else
            Bitmap bitmap=BitmapFactory.decodeResource(this.getResources(),
            R.drawable.example_picture);
            arrayList.add(bitmap);
            mmr.release();



            catch (Exception e)

            return arrayList;






            share|improve this answer























            • this method is not working buddy it show nothing in both arraylist or imageview

              – Vipul Chauhan
              Jan 22 at 6:45














            0












            0








            0







            try change the method of glide from asynchronous into synchronous.



            public ArrayList<Bitmap> getArrayList(ArrayList<String> Path) 
            try
            arrayList=new ArrayList<>();
            for(String temp:Path)
            MediaMetadataRetriever mmr = new MediaMetadataRetriever();
            mmr.setDataSource(temp);
            byte[] data = mmr.getEmbeddedPicture();
            if (data != null)
            FutureTarget<Bitmap> submit = Glide.with(this)
            .asBitmap()
            .load(data)
            .thumbnail(0.1f)
            .apply(RequestOptions.circleCropTransform()) //------getting image in circle
            .submit();
            button.setImageBitmap(submit.get());
            arrayList.add(submit.get());
            mmr.release();
            else
            Bitmap bitmap=BitmapFactory.decodeResource(this.getResources(),
            R.drawable.example_picture);
            arrayList.add(bitmap);
            mmr.release();



            catch (Exception e)

            return arrayList;






            share|improve this answer













            try change the method of glide from asynchronous into synchronous.



            public ArrayList<Bitmap> getArrayList(ArrayList<String> Path) 
            try
            arrayList=new ArrayList<>();
            for(String temp:Path)
            MediaMetadataRetriever mmr = new MediaMetadataRetriever();
            mmr.setDataSource(temp);
            byte[] data = mmr.getEmbeddedPicture();
            if (data != null)
            FutureTarget<Bitmap> submit = Glide.with(this)
            .asBitmap()
            .load(data)
            .thumbnail(0.1f)
            .apply(RequestOptions.circleCropTransform()) //------getting image in circle
            .submit();
            button.setImageBitmap(submit.get());
            arrayList.add(submit.get());
            mmr.release();
            else
            Bitmap bitmap=BitmapFactory.decodeResource(this.getResources(),
            R.drawable.example_picture);
            arrayList.add(bitmap);
            mmr.release();



            catch (Exception e)

            return arrayList;







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Jan 22 at 6:40









            alei longalei long

            697




            697












            • this method is not working buddy it show nothing in both arraylist or imageview

              – Vipul Chauhan
              Jan 22 at 6:45


















            • this method is not working buddy it show nothing in both arraylist or imageview

              – Vipul Chauhan
              Jan 22 at 6:45

















            this method is not working buddy it show nothing in both arraylist or imageview

            – Vipul Chauhan
            Jan 22 at 6:45






            this method is not working buddy it show nothing in both arraylist or imageview

            – Vipul Chauhan
            Jan 22 at 6:45


















            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54276708%2fhow-to-get-arraylistbitmap-as-output-with-the-help-of-glide%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

            Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

            Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript