use of com.mxt.anitrend.model.entity.anilist.MediaList in project anitrend-app by AniTrend.
the class MediaListAdapter method getFilter.
@Override
public Filter getFilter() {
return new Filter() {
@Override
protected FilterResults performFiltering(CharSequence constraint) {
String filter = constraint.toString();
if (filter.isEmpty()) {
data = clone;
} else {
data = new ArrayList<>();
for (MediaList model : clone) {
if (model.getMedia().getTitle().getEnglish().toLowerCase(Locale.getDefault()).contains(filter) || model.getMedia().getTitle().getRomaji().toLowerCase(Locale.getDefault()).contains(filter) || model.getMedia().getTitle().getOriginal().toLowerCase(Locale.getDefault()).contains(filter)) {
data.add(model);
}
}
}
FilterResults results = new FilterResults();
results.values = data;
return results;
}
@Override
@SuppressWarnings("unchecked")
protected void publishResults(CharSequence constraint, FilterResults results) {
data = new ArrayList<>((List<MediaList>) results.values);
notifyDataSetChanged();
}
};
}
use of com.mxt.anitrend.model.entity.anilist.MediaList in project anitrend-app by AniTrend.
the class AutoIncrementWidget method onResponse.
@Override
public void onResponse(@NonNull Call<MediaList> call, @NonNull Response<MediaList> response) {
try {
MediaList mediaList;
if (response.isSuccessful() && (mediaList = response.body()) != null) {
boolean isModelCategoryChanged = !mediaList.getStatus().equals(model.getStatus());
model = mediaList;
binding.seriesProgressIncrement.setSeriesModel(model, presenter.isCurrentUser(currentUser));
presenter.getDatabase().getBoxStore(MediaList.class).put(model);
resetFlipperState();
if (isModelCategoryChanged) {
NotifyUtil.makeText(getContext(), R.string.text_changes_saved, R.drawable.ic_check_circle_white_24dp, Toast.LENGTH_SHORT).show();
presenter.notifyAllListeners(new BaseConsumer<>(requestType, model), false);
}
} else {
resetFlipperState();
Log.e(this.toString(), ErrorUtil.getError(response));
NotifyUtil.makeText(getContext(), R.string.text_error_request, Toast.LENGTH_SHORT).show();
}
} catch (Exception e) {
e.printStackTrace();
}
}
Aggregations