android - Animation on notifyDataSetChanged() in FragmentStatePagerAdapter -


by overwriting getitemposition() method can refresh fragmentstatepageradapter, works fine. change of contents not nice see.

is there possibility apply kind of animation refresh fragmentstatepageradapter?

i facing same issue.so, should do. make global variables in adapter want continuous animate.

now when start animation on button click. pass value global variables.

when notifydatasetchanged doesn't effect animation.

i haven't found correct way. so, did thing.it's working perfect.

public class homeadapter extends recyclerview.adapter<recyclerview.viewholder> { private context mcontext; private arraylist<response.databean> feedarraylist = new arraylist<>(); feedclicklistener mlistener;  @inject imageutility mimageutility; @inject apputils mapputils; @inject preferencemanager mpref;  private float prevposition = -1;  private yoyo.yoyostring ropetext,ropeimage; private int temphandleplaypause = 0; private textview temptextview; private imageview tempimageview;  /**  * click listeners  */ interface feedclicklistener {      void onplayaudioclicked( feedresponse.databean feeditem, seekbar audioprogress, int position);      void onpauseaudioclicked(feedresponse.databean feeditem); }   public homeadapter(context context, arraylist<response.databean> mdataarraylist, homeclicklistener mfeedlistener) {     ((baseapplication) context.getapplicationcontext()).getappcomponent().inject(this);     this.mcontext = context;     this.feedarraylist = mdataarraylist;     mlistener = mfeedlistener;  }  @override public recyclerview.viewholder oncreateviewholder(viewgroup parent, int viewtype) {          return new itemviewholder(layoutinflater.from(parent.getcontext()).inflate(r.layout.item_layout, parent, false));   }  @override public void onbindviewholder(recyclerview.viewholder holder, int position) {      switch (holder.getitemviewtype()) {              itemviewholder holderitem = (itemviewholder) holder;             int adapterposition = holder.getadapterposition() - 1;                  holderitem.normalcontainer.setvisibility(view.visible);                 holderitem.bannercontainer.setvisibility(view.gone);                 setupnormalitem(adapterposition, holderitem);      }  }  private void setupnormalitem(int adapterposition, itemviewholder holder) {      feedresponse.databean feeditem = feedarraylist.get(adapterposition);     // set data current view holder items     setupitems(holder, feeditem, adapterposition);  }   private void setupitems(itemviewholder holder, feedresponse.databean feeditem, int position) {       if (feeditem.isstop()) {         holder.playimageview.setvisibility(view.gone);         holder.pauseimageview.setvisibility(view.visible);      } else {         holder.playimageview.setvisibility(view.visible);         holder.pauseimageview.setvisibility(view.gone);         holder.audioprogress.setprogress(0);     }      holder.playimageview.setonclicklistener(v -> {          feeditem.setiscomplete(false);          if (prevposition >= 0) {             feedarraylist.get((int)prevposition).setisstop(false);             feedarraylist.get((int)prevposition).setisprepare(false);         }             feedarraylist.get(position).setisstop(true);             feedarraylist.get(position).setisprepare(true);          mlistener.onplayaudioclicked(feeditem, holder.audioprogress, position);          prevposition = position;          temphandleplaypause = 1;          temptextview = holder.tvplayingblink;         tempimageview = holder.pauseimageview;          notifydatasetchanged();       });     holder.pauseimageview.setonclicklistener(v -> {          feedarraylist.get(position).setisstop(false);          temptextview = holder.tvplayingblink;         tempimageview = holder.pauseimageview;          temphandleplaypause = 0;          mlistener.onpauseaudioclicked(feeditem);           notifydatasetchanged();      });       if (feeditem.isprepare()) {          holder.tvplayingblink.setvisibility(view.visible);          if (temphandleplaypause == 1){             startanimation();         }else {             stopanimation();         }      } else {         holder.tvplayingblink.setvisibility(view.invisible);         if (temphandleplaypause == 1){             startanimation();         }else {             stopanimation();         }     }       // play on complete audio     if (feeditem.iscomplete()) {          holder.playimageview.setvisibility(view.visible);         holder.pauseimageview.setvisibility(view.gone);      }      if ((!feeditem.iscomplete()) && feeditem.gettotallength() > 0) {          holder.audioprogress.setmax(feeditem.gettotallength());         holder.audioprogress.setprogress(0);      } }  private void startanimation(){      if (ropetext != null || ropeimage != null) {         ropetext.stop(true);         ropeimage.stop(true);     }     ropetext = yoyo.with(techniques.pulse)             .duration(800)             .repeat(yoyo.infinite)             .pivot(yoyo.center_pivot, yoyo.center_pivot)             .interpolate(new acceleratedecelerateinterpolator())             .playon(temptextview);      ropeimage = yoyo.with(techniques.pulse)             .duration(800)             .repeat(yoyo.infinite)             .pivot(yoyo.center_pivot, yoyo.center_pivot)             .interpolate(new acceleratedecelerateinterpolator())             .playon(tempimageview); }  private void stopanimation(){      if (ropetext != null || ropeimage != null) {         ropetext.stop(true);         ropeimage.stop(true);     } }  public void updatedata(list<feedresponse.databean> items) {     feedarraylist.clear();     feedarraylist.addall(items);     notifydatasetchanged();  }  public void deleteitem(int position) {     feedarraylist.remove(position);     notifydatasetchanged(); }   @override public int getitemcount() {     return (feedarraylist.size()); }  public static class itemviewholder extends recyclerview.viewholder {      @bindview(r.id.image_view_3)     imageview imageview3;     @bindview(r.id.tvplayingblink)     textview tvplayingblink;        public itemviewholder(view itemview) {         super(itemview);         butterknife.bind(this, itemview);     } } }  

Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -