Directory:
Some of Recyclerview's personal understanding and use (i) Simple encapsulation of adapter
Some personal understanding and use of Recyclerview (ii) Implementation of a simple list interface
Some personal understanding and use of Recyclerview (iii) Timers in the list
Some personal understanding and use of Recyclerview (iv) Implementing sidebar effects in the interface
Some personal understanding and use of Recyclerview (v) The linkage of Recyclerview and the realization of time choice
Some of Recyclerview's personal understanding and use (vi) Recyclerview fragment loading
Some personal understanding and use of Recyclerview (vii) Recyclerview nesting and increasing deletion
Recent projects in the integration of IM, with the cloud, due to the particularity of the need to achieve a more troublesome, spent a time, almost finished, nearly two days also just idle down, I want to relax, but also to everyone also bring a very easy to achieve the function, As usual, attach the previous web site to achieve recyclerview linkage blog:
http://blog.csdn.net/ljwztn/article/details/71209543
This function is mainly to solve some complex recyclerview overall drawing too slow problem, imagine if an interface takes a long time to draw to load out, is undoubtedly affecting the user experience, through the recyclerview of the segmented loading, We have the item drawn and presented to the user, so that the interaction is better. Because this is just a demo, I did not create a complex interface to let it load, just simple implementation of this function, you can according to the actual needs of their projects to see if the need to use. First the picture
The code is also very simple, use the Timmer class to start the task, update the UI in handler, because adapter directly with the beginning of the simplest adapter, do not paste, activity code as follows;
/** * Created by ztn on 2017/6/8 * Segmented load Recyclerview */public class Subsectionrecyclerviewactivity extends Baseactivit
y {list<string> time;
Mainrecyclerviewadapter Mainrecyclerviewadapter;
SimpleDateFormat formatter;
Timer timer;
Subsectionrecyclerviewactivityholder Subsectionrecyclerviewactivityholder; public static Intent Newintent (context context) {return new Intent (context, Subsectionrecyclerviewactivity.class)
;
} @Override protected void OnCreate (Bundle savedinstancestate) {super.oncreate (savedinstancestate);
Setcontentview (R.layout.activity_main);
Subsectionrecyclerviewactivityholder = new Subsectionrecyclerviewactivityholder (this);
Formatter = new SimpleDateFormat ("yyyy mm month DD Day HH:mm:ss", Locale.china);
Time = new arraylist<> ();
Time.add (Formatter.format (System.currenttimemillis ())); Mainrecyclerviewadapter = new Mainrecyclerviewadapter (GetContext (), time);
SubsectionRecyclerViewActivityHolder.recyclerView.setAdapter (Mainrecyclerviewadapter);
Timer = new timer ();
After 0.5 seconds to perform the task, according to the actual needs in the appropriate location, such as the loaded data is network data, should be placed after the network data load successfully executed Timer.schedule (new TimerTask () {@Override
public void Run () {handler.sendemptymessage (1);
}}, 500, 500); } Handler Handler = new Handler (new Handler.callback () {@Override public boolean handlemessage (Messa
GE msg) {switch (msg.what) {Case 1://Load 20 data, actually based on data size
if (Time.size () <) {Time.add (Formatter.format (System.currenttimemillis ()));
Mainrecyclerviewadapter.notifyitemchanged (Time.size ());
} else {//Stop timer.purge ();
} break; Case 2:tImer.purge ();
Break
} return false;
}
}); }
Here is the size of the time used in handler, not the number of times the task is executed, because some interfaces may draw in less than 0.5 seconds, possibly resulting in a null pointer, without the problem of using the size of the window directly.
Project Address:
Https://github.com/Liveinadream/RecyclerViewDemo#recyclerviewdemo
If there is doubt you can add 121606151 this QQ group @crazy (ie i) can, welcome everyone to come to exchange.