update
This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
package com.shayu.onetoone.dialog;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.lxj.xpopup.XPopup;
|
||||
import com.shayu.onetoone.R;
|
||||
import com.shayu.onetoone.adapter.BottomListDialogAdapter;
|
||||
import com.yunbao.common.dialog.AbsDialogPopupWindow;
|
||||
import com.yunbao.common.interfaces.OnItemClickListener;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class BottomListDialog extends AbsDialogPopupWindow {
|
||||
List<String> strings;
|
||||
OnItemClickListener<String> select;
|
||||
RecyclerView recyclerView;
|
||||
BottomListDialogAdapter adapter;
|
||||
View cancel;
|
||||
|
||||
public BottomListDialog(@NonNull Context context) {
|
||||
super(context);
|
||||
strings = new ArrayList<>();
|
||||
}
|
||||
|
||||
public BottomListDialog setStrings(List<String> strings) {
|
||||
this.strings = strings;
|
||||
return this;
|
||||
}
|
||||
|
||||
public BottomListDialog setSelect(OnItemClickListener<String> select) {
|
||||
this.select = select;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildDialog(XPopup.Builder builder) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int bindLayoutId() {
|
||||
return R.layout.dialog_bottom_list;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate() {
|
||||
super.onCreate();
|
||||
recyclerView = findViewById(R.id.recyclerView);
|
||||
cancel = findViewById(R.id.cancel);
|
||||
cancel.setOnClickListener(v -> dismiss());
|
||||
adapter = new BottomListDialogAdapter(getContext());
|
||||
adapter.setList(strings);
|
||||
adapter.setOnItemClickListener(new OnItemClickListener<String>() {
|
||||
@Override
|
||||
public void onItemClick(String bean, int position) {
|
||||
select.onItemClick(bean, position);
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
recyclerView.setAdapter(adapter);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user