Issue
I am using bottomsheetlayout pop up for social media sharing. now issue is , it is opening more than one time. please help me to solve this.
on my button click I call asynctask for download Images.
@Override
protected void onPostExecute(Void res) {
super.onPostExecute(res);
//prodImageUri1.addAll(prodImageUri);
if(single_rdb.isChecked())
{
createImageBitmap();
}
else if(allimg_rdb.isChecked())
{
temps=new ArrayList<>();
for(int i=0;i<prodImageUri.size();i++)
{
if(i==8)
{
break;
}
temps.add(prodImageUri.get(i));
// System.out.println("SIZE "+temps.size()+"TEST1 "+temps.get(i));
createImageBitmap();
}
}
}
here I call createImageBitmap method. now inside this method I have bottomsheet.show
public void createImageBitmap(){
...................
...................
if(single_rdb.isChecked())
{
header_image.setImageURI(prodImageUri.get(0));
imageview1.setVisibility(View.GONE);
imageview2.setVisibility(View.GONE);
imageview3.setVisibility(View.GONE);
horizontal_image_layout.setVisibility(View.GONE);
}
else if(allimg_rdb.isChecked())
{
arrayListClone = (ArrayList<Uri>) temps.clone();
for(int i=0;i<arrayListClone.size();i++)
{
//System.out.println("FAFA"+arrayListClone);
header_image.setImageURI(arrayListClone.get(i));
// System.out.println("SIZE "+temps.size()+"TEST "+temps.get(i));
}
imageview1.setVisibility(View.GONE);
imageview2.setVisibility(View.GONE);
imageview3.setVisibility(View.GONE);
horizontal_image_layout.setVisibility(View.GONE);
}
for(int i=0;i<arrayListClone.size();i++)
{
if(i==1)
{
break;
}
System.out.println("This is check");
addPhotoBottomDialogFragment = new BottomSheetSharingFragment1();
addPhotoBottomDialogFragment.show(((FragmentActivity)context).getSupportFragmentManager(),
"add_photo_dialog_fragment");
}
What I am trying to achieve is, bottomDailog should open only one time, right now it is opening as per size of arraylist of Image. For Example if arraylist will have 3 images it shows dailog three time and placing on one another.
Solution
Okay remove the bottom sheet dialog call from your for loop and place it outside the for loop it's executing multiple times because of the for loop where until the for loop reaches the end of your array list it will keep executing. So simply remove bottom sheet and place it outside the for loop You're facing problem because of this piece of code:
for(int i=0;i<prodImageUri.size();i++)
{
if(i==8)
{
break;
}
temps.add(prodImageUri.get(i));
// System.out.println("SIZE "+temps.size()+"TEST1 "+temps.get(i));
createImageBitmap();
}
so simply remove bottom sheet dialog from your createImageBitmap(); method and place it outside the method.
Answered By - Mr. Patel
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.