app/src/main/java/fr/neamar/kiss/adapter/RecordAdapter.java
/**
     * When using fast scroll, generate a mapping to know where a given letter starts in the list
     * (can only be used with a sorted result set!)
     */
When using fast scroll, generate a mapping to know where a given letter starts in the list
(can only be used with a sorted result set!)
When using fast scroll generate a mapping to know where a given letter starts in the list ( can only be used with a sorted result set! )
public void buildSections() {
        alphaIndexer.clear();
        int size = results.size();
        for (int x = 0; x < size; x++) {
            String s = results.get(x).getSection();
            if (!alphaIndexer.containsKey(s)) {
                alphaIndexer.put(s, x);
            }
        }
        List<Map.Entry<String, Integer>> entries = new ArrayList<>(alphaIndexer.entrySet());
        Collections.sort(entries, (o1, o2) -> {
            if (o2.getValue().equals(o1.getValue())) {
                return 0;
            }
            return o2.getValue() > o1.getValue() ? -1 : 1;
        });
        sections = new String[entries.size()];
        for (int i = 0; i < entries.size(); i++) {
            sections[i] = entries.get(i).getKey();
        }
    }
public void buildSections ( ) { alphaIndexer . clear ( ) ; int size = results . size ( ) ; for ( int x = 0 ; x < size ; x ++ ) { String s = results . get ( x ) . getSection ( ) ; if ( ! alphaIndexer . containsKey ( s ) ) { alphaIndexer . put ( s , x ) ; } } List < Map . Entry < String , Integer > > entries = new ArrayList < > ( alphaIndexer . entrySet ( ) ) ; Collections . sort ( entries , ( o1 , o2 ) -> { if ( o2 . getValue ( ) . equals ( o1 . getValue ( ) ) ) { return 0 ; } return o2 . getValue ( ) > o1 . getValue ( ) ? - 1 : 1 ; } ) ; sections = new String [ entries . size ( ) ] ; for ( int i = 0 ; i < entries . size ( ) ; i ++ ) { sections [ i ] = entries . get ( i ) . getKey ( ) ; } }
When using fast scroll, generate a mapping to know where a given letter starts in the list
 (can only be used with a sorted result set!)
When using fast scroll generate a mapping to know where a given letter starts in the list ( can only be used with a sorted result set! )
// Generate the mapping letter => number // Put the first one // Generate section list // We're displaying from A to Z, everything needs to be reversed