java - Descending Order for SortCursor Class -


so i've been using great resource class found online sort 2 cursors based on column:

https://android.googlesource.com/platform/frameworks/base.git/+/android-4.4.4_r1/core/java/com/android/internal/database/sortcursor.java

the onmove function of cursor seems doing sorting between 2 cursors:

@override     public boolean onmove(int oldposition, int newposition)     {         if (oldposition == newposition)             return true;         /*          * find right cursor          * because client of cursor (the listadapter/view) tends          * jump around in cursor somewhat, simple cache strategy          * used avoid having search cursors start.          * todo: investigate strategies optimizing random access ,          * reverse-order access.          */         int cache_entry = newposition % rowcachesize;         if (mrownumcache[cache_entry] == newposition) {             int = mcursorcache[cache_entry];             mcursor = mcursors[which];             if (mcursor == null) {                 log.w(tag, "onmove: cache results in null cursor.");                 return false;             }             mcursor.movetoposition(mcurrownumcache[cache_entry][which]);             mlastcachehit = cache_entry;             return true;         }         mcursor = null;         int length = mcursors.length;         if (mlastcachehit >= 0) {             (int = 0; < length; i++) {                 if (mcursors[i] == null)                     continue;                 mcursors[i].movetoposition(mcurrownumcache[mlastcachehit][i]);             }         }         if (newposition < oldposition || oldposition == -1) {             (int = 0; < length; i++) {                 if (mcursors[i] == null)                     continue;                 mcursors[i].movetofirst();             }             oldposition = 0;         }         if (oldposition < 0) {             oldposition = 0;         }         // search forward new position         int smallestidx = -1;         (int = oldposition; <= newposition; i++) {             string smallest = "";             smallestidx = -1;             (int j = 0; j < length; j++) {                 if (mcursors[j] == null || mcursors[j].isafterlast()) {                     continue;                 }                 string current = mcursors[j].getstring(msortcolumns[j]);                 if (smallestidx < 0 || current.comparetoignorecase(smallest) < 0) {                     smallest = current;                     smallestidx = j;                 }             }             if (i == newposition)                 break;             if (mcursors[smallestidx] != null) {                 mcursors[smallestidx].movetonext();             }         }         mcursor = mcursors[smallestidx];         mrownumcache[cache_entry] = newposition;         mcursorcache[cache_entry] = smallestidx;         (int = 0; < length; i++) {             if (mcursors[i] != null) {                 mcurrownumcache[cache_entry][i] = mcursors[i].getposition();             }         }         mlastcachehit = -1;         return true;     } 

i'm not familiar how cursors work wondering how modify onmove function such sorting of 2 cursors sorted in desceding order rather default ascending order?

any ideas help! thanks!


Comments

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

[C++][SFML 2.2] Strange Performance Issues - Moving Mouse Lowers CPU Usage -

ios - Possible to get UIButton sizeThatFits to work? -