Show a full screen slideshow image gallery Android -


i have implemented android image gallery load images android gallery android application. images loads fine application. want show full screen slideshow of images have loaded. able show full screen slideshow, problem is not loading image in current position. example, consider have 3 folders in gallery, first folder, loads first image, second folder, loads second image , on. figured out passing position of gridview(folder), , unable figure out how fix this.

kindly me regarding same. please find attached code below of have tried.

galleryfragment.java

 gv_folder = (gridview)view.findviewbyid(r.id.gv_folder);     gv_folder.setonitemclicklistener(new adapterview.onitemclicklistener() {         @override         public void onitemclick(adapterview<?> adapterview, view view, int i, long l) {             intent intent = new intent(getcontext(), photosactivity.class);             intent.putextra("value",i);             startactivity(intent);         }     }); 

photosactivity.java

gridview = (gridview)findviewbyid(r.id.gv_folder);     int_position = getintent().getintextra("value", 0);     adapter = new gridviewadapter(this, galleryfragment.al_images,int_position);     gridview.setadapter(adapter);  gridview.setonitemclicklistener(new adapterview.onitemclicklistener() {         @override         public void onitemclick(final adapterview<?> parent, view view, final int position, long id) {              charsequence options[] = new charsequence[]{"add memory", "listen short memory?", "listen long memory?", "fullscreen slideshow"};  //                if(position == 0) {                 //options = new charsequence[]{"add memory", "listen short memory?", "listen long memory?", "fullscreen slideshow"}; //                }else{ //                    options = new charsequence[]{"add memory", "listen   short memory?", "listen long memory?"};  //                }              alertdialog.builder builder = new alertdialog.builder(photosactivity.this);             builder.setitems(options, new dialoginterface.onclicklistener() {                 @override                 public void onclick(dialoginterface dialog, int which) {                     else if(which == 3){                         intent intent = new intent(photosactivity.this, fullscreenviewactivity.class);                         intent.putextra("position", int_position);                         startactivity(intent);                     }                 }             });             builder.show();         }     }); 

gridviewadapter.java

package com.project.group.projectga.adapters; public class gridviewadapter extends arrayadapter<model_images> {  context context; viewholder viewholder; arraylist<model_images> al_menu = new arraylist<>(); int int_position;   public gridviewadapter(context context, arraylist<model_images> al_menu,int int_position) {     super(context, r.layout.adapter_photosfolder, al_menu);     this.al_menu = al_menu;     this.context = context;     this.int_position = int_position;  }  @override public int getcount() {      log.e("adapter list size", al_menu.get(int_position).getal_imagepath().size() + "");     return al_menu.get(int_position).getal_imagepath().size(); }  @override public int getitemviewtype(int position) {     return position; }  @override public int getviewtypecount() {     if (al_menu.get(int_position).getal_imagepath().size() > 0) {         return al_menu.get(int_position).getal_imagepath().size();     } else {         return 1;     } }  @override public long getitemid(int position) {     return position; }  @override public view getview(final int position, view convertview, viewgroup parent) {      if (convertview == null) {          viewholder = new viewholder();         convertview = layoutinflater.from(getcontext()).inflate(r.layout.adapter_photosfolder, parent, false);         viewholder.tv_foldern = (textview) convertview.findviewbyid(r.id.tv_folder);         viewholder.tv_foldersize = (textview) convertview.findviewbyid(r.id.tv_folder2);         viewholder.iv_image = (imageview) convertview.findviewbyid(r.id.iv_image);          convertview.settag(viewholder);     } else {         viewholder = (viewholder) convertview.gettag();     }      viewholder.tv_foldern.setvisibility(view.gone);     viewholder.tv_foldersize.setvisibility(view.gone);      glide.with(context).load("file://" + al_menu.get(int_position).getal_imagepath().get(position))             .diskcachestrategy(diskcachestrategy.none)             .skipmemorycache(true)             .into(viewholder.iv_image);      return convertview; }  private static class viewholder {     textview tv_foldern, tv_foldersize;     imageview iv_image; } } 

fullscreenviewactivity.java

@override protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.activity_fullscreen_view);      viewpager = (viewpager) findviewbyid(r.id.pager);     countlabel = (textview) findviewbyid(r.id.countlabel);       intent = getintent();     selectedpostion = i.getintextra("position", 0);      adapter = new fullscreenimageadapter(this, galleryfragment.al_images.get(selectedpostion).getal_imagepath());      viewpager.setadapter(adapter);     viewpager.addonpagechangelistener(pagechangelistener);      // displaying selected image first     //viewpager.         setcurrentitem(selectedpostion); }  private void setcurrentitem(int position) {     viewpager.setcurrentitem(position, false);     displayextras(position); }  //  page change listener viewpager.onpagechangelistener pagechangelistener = new viewpager.onpagechangelistener() {      @override     public void onpageselected(int position) {         displayextras(position);     }      @override     public void onpagescrolled(int arg0, float arg1, int arg2) {      }      @override     public void onpagescrollstatechanged(int arg0) {      } };  private void displayextras(int position) {     countlabel.settext((position + 1) + " of " + galleryfragment.al_images.get(selectedpostion).getal_imagepath().size());  } 

fullscreenimageadapter.java

public class fullscreenimageadapter extends pageradapter {  private activity _activity; private arraylist<string> _imagepaths; private layoutinflater inflater;  // constructor public fullscreenimageadapter(activity activity,                               arraylist<string> imagepaths) {     this._activity = activity;     this._imagepaths = imagepaths; }  @override public int getcount() {     return this._imagepaths.size(); }  @override public boolean isviewfromobject(view view, object object) {     return view == ((relativelayout) object); }  @override public object instantiateitem(viewgroup container, int position) {     imageview imgdisplay;     button btnclose;      inflater = (layoutinflater) _activity             .getsystemservice(context.layout_inflater_service);     view viewlayout = inflater.inflate(r.layout.layout_fullscreen_image, container,             false);      imgdisplay = (imageview) viewlayout.findviewbyid(r.id.imgdisplay);     btnclose = (button) viewlayout.findviewbyid(r.id.btnclose);      bitmapfactory.options options = new bitmapfactory.options();     options.inpreferredconfig = bitmap.config.argb_8888;     bitmap bitmap = bitmapfactory.decodefile(_imagepaths.get(position), options);     imgdisplay.setimagebitmap(bitmap);      // close button click event     btnclose.setonclicklistener(new view.onclicklistener() {         @override         public void onclick(view v) {             _activity.finish();         }     });      ((viewpager) container).addview(viewlayout);      return viewlayout; }  @override public void destroyitem(viewgroup container, int position, object object) {     ((viewpager) container).removeview((relativelayout) object);  } 

just posting necessary code snippets. in case, guys need else, let me know can update question. can see, position of image full screen missing. passing wrong position value. , not able figure out position value pass fullscreenviewactivity. kindly help.


Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -