diff --git a/app/build.gradle b/app/build.gradle index a96671678..ec335e9d6 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -123,7 +123,6 @@ dependencies { compile 'com.github.bumptech.glide:glide:3.6.1' compile 'com.jakewharton:butterknife:7.0.1' compile 'com.jakewharton.timber:timber:4.1.0' - compile 'uk.co.ribot:easyadapter:1.5.0@aar' compile 'ch.acra:acra:4.8.1' compile "frankiesardo:icepick:$ICEPICK_VERSION" provided "frankiesardo:icepick-processor:$ICEPICK_VERSION" diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/myanimelist/MyAnimeListDialogFragment.java b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/myanimelist/MyAnimeListDialogFragment.java index fd2527f89..6d4d9f3bc 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/myanimelist/MyAnimeListDialogFragment.java +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/myanimelist/MyAnimeListDialogFragment.java @@ -11,7 +11,6 @@ import android.view.View; import android.widget.EditText; import android.widget.ListView; import android.widget.ProgressBar; -import android.widget.TextView; import com.afollestad.materialdialogs.MaterialDialog; @@ -25,11 +24,6 @@ import eu.kanade.tachiyomi.data.database.models.MangaSync; import rx.Subscription; import rx.android.schedulers.AndroidSchedulers; import rx.subjects.PublishSubject; -import uk.co.ribot.easyadapter.EasyAdapter; -import uk.co.ribot.easyadapter.ItemViewHolder; -import uk.co.ribot.easyadapter.PositionInfo; -import uk.co.ribot.easyadapter.annotations.LayoutId; -import uk.co.ribot.easyadapter.annotations.ViewId; public class MyAnimeListDialogFragment extends DialogFragment { @@ -37,7 +31,7 @@ public class MyAnimeListDialogFragment extends DialogFragment { @Bind(R.id.myanimelist_search_results) ListView searchResults; @Bind(R.id.progress) ProgressBar progressBar; - private EasyAdapter adapter; + private MyAnimeListSearchAdapter adapter; private MangaSync selectedItem; private Subscription searchSubscription; @@ -59,7 +53,7 @@ public class MyAnimeListDialogFragment extends DialogFragment { ButterKnife.bind(this, dialog.getView()); // Create adapter - adapter = new EasyAdapter<>(getActivity(), ResultViewHolder.class); + adapter = new MyAnimeListSearchAdapter(getActivity()); searchResults.setAdapter(adapter); // Set listeners @@ -125,7 +119,7 @@ public class MyAnimeListDialogFragment extends DialogFragment { public void onSearchResultsError() { progressBar.setVisibility(View.GONE); searchResults.setVisibility(View.VISIBLE); - adapter.getItems().clear(); + adapter.clear(); } public MyAnimeListFragment getMALFragment() { @@ -136,21 +130,6 @@ public class MyAnimeListDialogFragment extends DialogFragment { return getMALFragment().getPresenter(); } - @LayoutId(R.layout.dialog_myanimelist_search_item) - public static class ResultViewHolder extends ItemViewHolder { - - @ViewId(R.id.myanimelist_result_title) TextView title; - - public ResultViewHolder(View view) { - super(view); - } - - @Override - public void onSetValues(MangaSync chapter, PositionInfo positionInfo) { - title.setText(chapter.title); - } - } - private static class SimpleTextChangeListener implements TextWatcher { @Override diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/myanimelist/MyAnimeListSearchAdapter.java b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/myanimelist/MyAnimeListSearchAdapter.java new file mode 100644 index 000000000..9eed6d269 --- /dev/null +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/myanimelist/MyAnimeListSearchAdapter.java @@ -0,0 +1,61 @@ +package eu.kanade.tachiyomi.ui.manga.myanimelist; + +import android.content.Context; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ArrayAdapter; +import android.widget.TextView; + +import java.util.ArrayList; +import java.util.List; + +import butterknife.Bind; +import butterknife.ButterKnife; +import eu.kanade.tachiyomi.R; +import eu.kanade.tachiyomi.data.database.models.MangaSync; + +public class MyAnimeListSearchAdapter extends ArrayAdapter { + + public MyAnimeListSearchAdapter(Context context) { + super(context, R.layout.dialog_myanimelist_search_item, new ArrayList<>()); + } + + @Override + public View getView(int position, View view, ViewGroup parent) { + // Get the data item for this position + MangaSync sync = getItem(position); + // Check if an existing view is being reused, otherwise inflate the view + SearchViewHolder holder; // view lookup cache stored in tag + if (view == null) { + LayoutInflater inflater = LayoutInflater.from(getContext()); + view = inflater.inflate(R.layout.dialog_myanimelist_search_item, parent, false); + holder = new SearchViewHolder(view); + view.setTag(holder); + } else { + holder = (SearchViewHolder) view.getTag(); + } + holder.onSetValues(sync); + return view; + } + + public void setItems(List syncs) { + setNotifyOnChange(false); + clear(); + addAll(syncs); + notifyDataSetChanged(); + } + + public static class SearchViewHolder { + + @Bind(R.id.myanimelist_result_title) TextView title; + + public SearchViewHolder(View view) { + ButterKnife.bind(this, view); + } + + public void onSetValues(MangaSync sync) { + title.setText(sync.title); + } + } +}