Skip to content

Commit

Permalink
优化
Browse files Browse the repository at this point in the history
  • Loading branch information
gedoor committed Oct 5, 2019
1 parent f19dab7 commit fccb2a7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@
import butterknife.BindView;
import butterknife.ButterKnife;

public class SearchBookActivity extends MBaseActivity<SearchBookContract.Presenter> implements SearchBookContract.View {
public class SearchBookActivity extends MBaseActivity<SearchBookContract.Presenter>
implements SearchBookContract.View, SearchBookshelfAdapter.CallBack {
private final int requestSource = 14;

@BindView(R.id.searchView)
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -542,4 +543,9 @@ public void finish() {
super.finish();
overridePendingTransition(0, android.R.anim.fade_out);
}

@Override
public void openBookInfo(BookInfoBean bookInfoBean) {

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@
public class SearchBookshelfAdapter extends RecyclerView.Adapter<SearchBookshelfAdapter.MyViewHolder> {

private List<BookInfoBean> beans = new ArrayList<>();
private CallBack callBack;

public SearchBookshelfAdapter(CallBack callBack) {
this.callBack = callBack;
}

public void setItems(List<BookInfoBean> beans) {
this.beans.clear();
Expand All @@ -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
Expand All @@ -49,5 +55,8 @@ public MyViewHolder(@NonNull View itemView) {
}
}

public interface CallBack {
void openBookInfo(BookInfoBean bookInfoBean);
}
}

0 comments on commit fccb2a7

Please sign in to comment.