diff --git a/app/src/main/java/com/kunfei/bookshelf/view/activity/SearchBookActivity.java b/app/src/main/java/com/kunfei/bookshelf/view/activity/SearchBookActivity.java index fe2e08f73d..3b4f21fd09 100644 --- a/app/src/main/java/com/kunfei/bookshelf/view/activity/SearchBookActivity.java +++ b/app/src/main/java/com/kunfei/bookshelf/view/activity/SearchBookActivity.java @@ -56,7 +56,8 @@ import butterknife.BindView; import butterknife.ButterKnife; -public class SearchBookActivity extends MBaseActivity implements SearchBookContract.View { +public class SearchBookActivity extends MBaseActivity + implements SearchBookContract.View, SearchBookshelfAdapter.CallBack { private final int requestSource = 14; @BindView(R.id.searchView) @@ -116,7 +117,7 @@ protected void onCreateActivity() { protected void initData() { mExplosionField = ExplosionField.attach2Window(this); searchBookAdapter = new SearchBookAdapter(this); - searchBookshelfAdapter = new SearchBookshelfAdapter(); + searchBookshelfAdapter = new SearchBookshelfAdapter(this); } @SuppressLint("InflateParams") @@ -542,4 +543,9 @@ public void finish() { super.finish(); overridePendingTransition(0, android.R.anim.fade_out); } + + @Override + public void openBookInfo(BookInfoBean bookInfoBean) { + + } } diff --git a/app/src/main/java/com/kunfei/bookshelf/view/adapter/SearchBookshelfAdapter.java b/app/src/main/java/com/kunfei/bookshelf/view/adapter/SearchBookshelfAdapter.java index 348b9f4390..20ed3e1fd0 100644 --- a/app/src/main/java/com/kunfei/bookshelf/view/adapter/SearchBookshelfAdapter.java +++ b/app/src/main/java/com/kunfei/bookshelf/view/adapter/SearchBookshelfAdapter.java @@ -17,6 +17,11 @@ public class SearchBookshelfAdapter extends RecyclerView.Adapter { private List beans = new ArrayList<>(); + private CallBack callBack; + + public SearchBookshelfAdapter(CallBack callBack) { + this.callBack = callBack; + } public void setItems(List beans) { this.beans.clear(); @@ -33,6 +38,7 @@ public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) @Override public void onBindViewHolder(@NonNull MyViewHolder holder, int position) { holder.textView.setText(beans.get(position).getName()); + holder.itemView.setOnClickListener(v -> callBack.openBookInfo(beans.get(position))); } @Override @@ -49,5 +55,8 @@ public MyViewHolder(@NonNull View itemView) { } } + public interface CallBack { + void openBookInfo(BookInfoBean bookInfoBean); + } }