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

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
add a comment |

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
Comments are not for extended discussion; this conversation has been moved to chat.
– Samuel Liew♦
Jan 22 at 8:50
add a comment |

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

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
edited Jan 24 at 17:22
Vipul Chauhan
asked Jan 20 at 13:00
Vipul ChauhanVipul Chauhan
518
518
Comments are not for extended discussion; this conversation has been moved to chat.
– Samuel Liew♦
Jan 22 at 8:50
add a comment |
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
add a comment |
2 Answers
2
active
oldest
votes
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;
}
this method is not working buddy it show nothing in both arraylist or imageview
– Vipul Chauhan
Jan 22 at 6:45
add a comment |
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;
}
}
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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;
}
this method is not working buddy it show nothing in both arraylist or imageview
– Vipul Chauhan
Jan 22 at 6:45
add a comment |
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;
}
this method is not working buddy it show nothing in both arraylist or imageview
– Vipul Chauhan
Jan 22 at 6:45
add a comment |
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;
}
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;
}
answered Jan 22 at 6:40
alei longalei long
294
294
this method is not working buddy it show nothing in both arraylist or imageview
– Vipul Chauhan
Jan 22 at 6:45
add a comment |
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
add a comment |
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;
}
}
add a comment |
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;
}
}
add a comment |
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;
}
}
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;
}
}
answered Jan 26 at 8:34
Vipul ChauhanVipul Chauhan
518
518
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
Comments are not for extended discussion; this conversation has been moved to chat.
– Samuel Liew♦
Jan 22 at 8:50