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