RecyclerView 适配器
BaseAdapter
QuickAdapter
ViewPager 适配器
PagerAdapter
PagerAdapter2
Activity
BaseActivity
Fragment
BaseFragment
对话框
BaseDialog
BaseBottomSheetDialog
BasePopupWindow
Activity堆栈管理工具类
AppManagerUtils
Assets文件管理工具类
AssetsUtils
Base64工具类
Base64Utils
bitmap图片工具类
BitmapUtils
设备工具信息工具
EquipmentUtils
文件工具类
FileUtils
glide图片加载工具类
GlideUtils
系统http工具类
LoadUrlUtils
log日志工具类
LogsUtils
网络检测工具类
NetUtils
SharedPreferences本地xml储存工具类
SharedPreferencesUtils
时间工具类
TimeUtils
Toast工具类
ToastUtils
Ui相关工具类
UiUtils
- 项目build.gradle导入
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
- app build.gradle导入
dependencies {
implementation 'com.github.pikachu0621:MyUtils:0.0.4'
}
- 在app build.gradle 开启 viewBinding
android {
...
viewBinding {
enabled = true
}
}
public class TestQuickAdapter extends QuickAdapter<ActivityMainBinding, String> {
public TestQuickAdapter(List<String> data) {
super(data);
}
@Override
public void onQuickBindView(ActivityMainBinding binding, String itemData, int position, List<String> data) {
}
}
public class Test2QuickAdapter extends BaseAdapter<String> {
public Test2QuickAdapter(List<String> data) {
super(data);
}
@Override
public Class<? extends ViewBinding> onCreateView(ViewGroup parent, int viewType) {
// 根据 viewType 返回布局 Binding
if (viewType == 1) {
return ActivityMainBinding.class;
} else if (viewType == 10) {
return ActivityMainBinding.class;
}
return ActivityMainBinding.class;
}
@Override
public void onBindView(ViewBinding binding, String itemData, int position, int itemViewType, List<String> data) {
}
@Override
public int getItemViewType(int position, String itemData) {
//根据position 返回 viewType
return 0;
}
}
public class MainActivity extends BaseActivity<ActivityMainBinding> {
@Override
protected void initActivity(Bundle savedInstanceState) {
// 业务逻辑
// binding.getRoot().setVisibility(View.VISIBLE);
}
}
public class MainFragment extends BaseFragment<FragmentMainBinding> {
@Override
protected void onInitView(Bundle savedInstanceState, FragmentMainBinding binding, FragmentActivity activity) {
// 业务逻辑
// binding.getRoot().setVisibility(View.VISIBLE);
}
@Override
protected void lazyLoad() {
// 懒加载 第一次对用户可见时调用
// binding.getRoot().setVisibility(View.VISIBLE);
}
}
public class TestDialog {
private final Context context;
public TestDialog(Context context) {
this.context = context;
}
/**
* 普通对话框
* 背景默认透明
*/
public void testBaseDialog(){
BaseDialog<ActivityMainBinding> dialog = new BaseDialog<ActivityMainBinding>(context) {
@Override
protected void onViewCreate(ActivityMainBinding binding) {
// 业务逻辑
// binding.getRoot().setOnClickListener();
}
};
dialog.show();
}
/**
* 底部弹出对话框
* 背景默认透明
*/
public void testBaseBottomSheetDialog(){
BaseBottomSheetDialog<ActivityMainBinding> dialog = new BaseBottomSheetDialog<ActivityMainBinding>(context) {
@Override
protected void onViewCreate(ActivityMainBinding binding) {
// 业务逻辑
// binding.getRoot().setOnClickListener();
}
};
dialog.show();
}
/**
* 控件悬浮对话框
* 背景默认透明
*/
public void testBasePopupWindow(View view){
BasePopupWindow<ActivityMainBinding> dialog = new BasePopupWindow<ActivityMainBinding>(context) {
@Override
public void onViewCreate(ActivityMainBinding binding) {
// 业务逻辑
// binding.getRoot().setOnClickListener();
}
};
dialog.showAsTop(view);
}
}
-keep class com.pikachu.databinding.* {*;}