Search in sources :

Example 6 with MediaList

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();
        }
    };
}
Also used : MediaList(com.mxt.anitrend.model.entity.anilist.MediaList) Filter(android.widget.Filter) MediaList(com.mxt.anitrend.model.entity.anilist.MediaList) ArrayList(java.util.ArrayList) List(java.util.List)

Example 7 with MediaList

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();
    }
}
Also used : MediaList(com.mxt.anitrend.model.entity.anilist.MediaList)

Aggregations

MediaList (com.mxt.anitrend.model.entity.anilist.MediaList)7 Filter (android.widget.Filter)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 ProgressDialog (android.app.ProgressDialog)1 BaseConsumer (com.mxt.anitrend.base.custom.consumer.BaseConsumer)1 MediaBase (com.mxt.anitrend.model.entity.base.MediaBase)1 EntityGroup (com.mxt.anitrend.model.entity.group.EntityGroup)1 WidgetPresenter (com.mxt.anitrend.presenter.widget.WidgetPresenter)1