@ -51,44 +51,44 @@ public class IconFragment extends BaseFragment {
@@ -51,44 +51,44 @@ public class IconFragment extends BaseFragment {
@Override
public void init ( ) {
initSpinner ( ) ;
// initSpinner();
initRecyclerView ( ) ;
}
private void initSpinner ( ) {
Set < String > keySet = IconRecycleAdapter . ICON_MAP . keySet ( ) ;
ArrayList < String > keys = new ArrayList < > ( keySet ) ;
Collections . sort ( keys ) ;
binding . iconsSelect . setAdapter ( new ArrayAdapter < String > ( getContext ( ) , com . necer . R . layout . support_simple_spinner_dropdown_item , keys ) ) ;
binding . iconsSelect . setSelection ( 0 ) ;
binding . iconsSelect . setOnItemSelectedListener ( new AdapterView . OnItemSelectedListener ( ) {
/ * *
* @param parent The AdapterView where the selection happened
* @param view The view within the AdapterView that was clicked
* @param position The position of the view in the adapter
* @param id The row id of the item that is selected
* /
@Override
public void onItemSelected ( AdapterView < ? > parent , View view , int position , long id ) {
String key = keys . get ( position ) ;
String str = binding . iconsSearch . getText ( ) . toString ( ) ;
Predicate < SavedIcon > filter = item - > true ;
if ( null ! = str & & str . length ( ) > 0 ) {
filter = item - > item . getIcon ( ) . contains ( str ) ;
}
iconRecycleAdapter . change ( key , filter ) ;
}
/ * *
* @param parent The AdapterView that now contains no selected item .
* /
@Override
public void onNothingSelected ( AdapterView < ? > parent ) {
}
} ) ;
}
// private void initSpinner() {
// Set<String> keySet = IconRecycleAdapter.ICON_MAP.keySet();
// ArrayList<String> keys = new ArrayList<>(keySet);
// Collections.sort(keys);
// binding.iconsSelect.setAdapter(new ArrayAdapter<String>(getContext(), com.necer.R.layout.support_simple_spinner_dropdown_item, keys));
// binding.iconsSelect.setSelection(0);
//
// binding.iconsSelect.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
// /**
// * @param parent The AdapterView where the selection happened
// * @param view The view within the AdapterView that was clicked
// * @param position The position of the view in the adapter
// * @param id The row id of the item that is selected
// */
// @Override
// public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
// String key = keys.get(position);
// String str = binding.iconsSearch.getText().toString();
// Predicate<SavedIcon> filter = item -> true;
// if (null != str && str.length() > 0) {
// filter = item -> item.getIcon().contains(str);
// }
// iconRecycleAdapter.change(key, filter);
// }
//
// /**
// * @param parent The AdapterView that now contains no selected item.
// */
// @Override
// public void onNothingSelected(AdapterView<?> parent) {
//
// }
// });
// }
private void initRecyclerView ( ) {
binding . iconsRecyclerView . addItemDecoration ( new DividerItemDecoration ( this . getActivity ( ) , DividerItemDecoration . VERTICAL ) ) ;
@ -100,7 +100,7 @@ public class IconFragment extends BaseFragment {
@@ -100,7 +100,7 @@ public class IconFragment extends BaseFragment {
LinearLayoutManager layoutManager = new LinearLayoutManager ( getActivity ( ) ) ;
binding . iconsRecyclerView . setLayoutManager ( layoutManager ) ;
iconRecycleAdapter = new IconRecycleAdapter ( getActivity ( ) , CommunityMaterial . Icon . class ) ;
iconRecycleAdapter = new IconRecycleAdapter ( getActivity ( ) ) ;
binding . iconsRecyclerView . setAdapter ( iconRecycleAdapter ) ;
}
@ -129,7 +129,7 @@ public class IconFragment extends BaseFragment {
@@ -129,7 +129,7 @@ public class IconFragment extends BaseFragment {
@Override
public void afterTextChanged ( Editable s ) {
iconRecycleAdapter . change ( null , item - > item . getIcon ( ) . contains ( s . toString ( ) ) ) ;
iconRecycleAdapter . change ( item - > item . getIcon ( ) . contains ( s . toString ( ) ) ) ;
}
} ) ;
}