修复RecyclerView Bug
This commit is contained in:
parent
54d99a9fbb
commit
24c02a6d41
13
README.md
13
README.md
@ -1,11 +1,13 @@
|
||||
|
||||
### 1.0.2版本
|
||||
|
||||
#### 2022年03月18日
|
||||
|
||||
```
|
||||
1.添加取消疑难事件,标记疑难事件添加说明、疑难等级
|
||||
```
|
||||
|
||||
### 2022-7-25
|
||||
|
||||
```
|
||||
1.修复百度定位Key Bug
|
||||
2.融合通信添加Https端口配置
|
||||
@ -16,13 +18,20 @@
|
||||
```
|
||||
|
||||
### 2022-8-22
|
||||
|
||||
```
|
||||
1.修改融合通信登录时机
|
||||
2.添加单设备登录
|
||||
```
|
||||
|
||||
|
||||
### 2022-10-26
|
||||
|
||||
```
|
||||
1.添加日志浏览功能
|
||||
```
|
||||
|
||||
### 2023-5-8
|
||||
|
||||
```
|
||||
1.修复Bug RecyclerView Inconsistency detected
|
||||
```
|
@ -3,6 +3,8 @@ package com.tenlionsoft.baselib.core.widget.base;
|
||||
import android.content.Context;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.bumptech.glide.request.RequestOptions;
|
||||
import com.tenlionsoft.baselib.R;
|
||||
import com.tenlionsoft.baselib.utils.ConvertUtils;
|
||||
@ -10,8 +12,6 @@ import com.tenlionsoft.baselib.utils.ConvertUtils;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
/**
|
||||
* 作者 : Adam on 2018/6/15.
|
||||
* 邮箱 : itgaojian@163.com
|
||||
@ -31,10 +31,10 @@ public abstract class BaseRecyclerAdapter<T, H extends RecyclerView.ViewHolder>
|
||||
RoundedCornersTransform roundedCornersTransform = new RoundedCornersTransform(mContext, ConvertUtils.dp2px(5));
|
||||
roundedCornersTransform.setNeedCorner(true, true, true, true);
|
||||
options = new RequestOptions()
|
||||
.override(500, 500)
|
||||
.error(R.drawable.ic_img_load_err)
|
||||
.placeholder(R.drawable.ic_img_loading)
|
||||
.transform(new GlideRoundTransform(mContext, 5));
|
||||
.override(500, 500)
|
||||
.error(R.drawable.ic_img_load_err)
|
||||
.placeholder(R.drawable.ic_img_loading)
|
||||
.transform(new GlideRoundTransform(mContext, 5));
|
||||
for (int i = 0; i < mData.size(); i++) {
|
||||
mChoose.add(i, false);
|
||||
}
|
||||
@ -75,10 +75,6 @@ public abstract class BaseRecyclerAdapter<T, H extends RecyclerView.ViewHolder>
|
||||
*/
|
||||
public void setData(List<T> list) {
|
||||
this.mData = list;
|
||||
// mChoose.clear();
|
||||
// for (int i = 0; i < mData.size(); i++) {
|
||||
// mChoose.add(i, false);
|
||||
// }
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,32 @@
|
||||
package com.tenlionsoft.baselib.core.widget.base;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.tenlionsoft.baselib.utils.LogUtils;
|
||||
|
||||
public class WrapContentLinearLayoutManager extends LinearLayoutManager {
|
||||
public WrapContentLinearLayoutManager(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public WrapContentLinearLayoutManager(Context context, int orientation, boolean reverseLayout) {
|
||||
super(context, orientation, reverseLayout);
|
||||
}
|
||||
|
||||
public WrapContentLinearLayoutManager(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
||||
super(context, attrs, defStyleAttr, defStyleRes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLayoutChildren(RecyclerView.Recycler recycler, RecyclerView.State state) {
|
||||
try {
|
||||
super.onLayoutChildren(recycler, state);
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
LogUtils.e("RecyclerView IndexOUtOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
@ -7,6 +7,10 @@ import android.graphics.Color;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.viewpager2.widget.ViewPager2;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.github.promeg.pinyinhelper.Pinyin;
|
||||
@ -37,9 +41,6 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.viewpager2.widget.ViewPager2;
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.Unbinder;
|
||||
@ -82,10 +83,10 @@ public class AddressListActivity extends BaseActivity {
|
||||
mBind = ButterKnife.bind(this);
|
||||
|
||||
ImmersionBar.with(mActivity)
|
||||
.statusBarColor("#FFFFFF")
|
||||
.statusBarDarkFont(true)
|
||||
.titleBar(mRlTitleBar)
|
||||
.init();
|
||||
.statusBarColor("#FFFFFF")
|
||||
.statusBarDarkFont(true)
|
||||
.titleBar(mRlTitleBar)
|
||||
.init();
|
||||
mTvBaseTitle.setTextColor(Color.BLACK);
|
||||
mRlTitleBar.setBackgroundColor(getResources().getColor(R.color.white));
|
||||
mTvAppBack.setBackgroundResource(R.drawable.ic_back_black);
|
||||
@ -108,17 +109,17 @@ public class AddressListActivity extends BaseActivity {
|
||||
Pinyin.init(Pinyin.newConfig());
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(mActivity);
|
||||
builder.setTitle("提示")
|
||||
.setMessage("您还未同步通讯录,现在要同步吗?")
|
||||
.setPositiveButton("确定", (dialog, which) -> {
|
||||
dialog.dismiss();
|
||||
doSyncContact();
|
||||
})
|
||||
.setNegativeButton("取消", (dialog, which) -> {
|
||||
refreshView(STATE_LOAD_EMPTY);
|
||||
dialog.dismiss();
|
||||
})
|
||||
.create()
|
||||
.show();
|
||||
.setMessage("您还未同步通讯录,现在要同步吗?")
|
||||
.setPositiveButton("确定", (dialog, which) -> {
|
||||
dialog.dismiss();
|
||||
doSyncContact();
|
||||
})
|
||||
.setNegativeButton("取消", (dialog, which) -> {
|
||||
refreshView(STATE_LOAD_EMPTY);
|
||||
dialog.dismiss();
|
||||
})
|
||||
.create()
|
||||
.show();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -140,45 +141,45 @@ public class AddressListActivity extends BaseActivity {
|
||||
*/
|
||||
private void doSyncUser() {
|
||||
RetrofitManager.getInstance()
|
||||
.create(GridApis.class)
|
||||
.getAllUserList(UserLgUtils.getToken())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Observer<List<UserDatabaseBean>>() {
|
||||
@Override
|
||||
public void onSubscribe(@androidx.annotation.NonNull Disposable d) {
|
||||
.create(GridApis.class)
|
||||
.getAllUserList(UserLgUtils.getToken())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Observer<List<UserDatabaseBean>>() {
|
||||
@Override
|
||||
public void onSubscribe(@androidx.annotation.NonNull Disposable d) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@androidx.annotation.NonNull List<UserDatabaseBean> userDatabaseBeans) {
|
||||
mUserDatabaseBeanList = userDatabaseBeans;
|
||||
for (UserDatabaseBean next : mUserDatabaseBeanList) {
|
||||
if (!TextUtils.isEmpty(next.getUserName())) {
|
||||
next.setPinYin(Pinyin.toPinyin(next.getUserName(), ","));
|
||||
} else {
|
||||
next.setPinYin("#");
|
||||
@Override
|
||||
public void onNext(@androidx.annotation.NonNull List<UserDatabaseBean> userDatabaseBeans) {
|
||||
mUserDatabaseBeanList = userDatabaseBeans;
|
||||
for (UserDatabaseBean next : mUserDatabaseBeanList) {
|
||||
if (!TextUtils.isEmpty(next.getUserName())) {
|
||||
next.setPinYin(Pinyin.toPinyin(next.getUserName(), ","));
|
||||
} else {
|
||||
next.setPinYin("#");
|
||||
}
|
||||
}
|
||||
++mCount;
|
||||
if (mCount == 2) {
|
||||
insertAll();
|
||||
}
|
||||
}
|
||||
++mCount;
|
||||
if (mCount == 2) {
|
||||
insertAll();
|
||||
|
||||
@Override
|
||||
public void onError(@androidx.annotation.NonNull Throwable e) {
|
||||
mCount = 0;
|
||||
mDialog.dismiss();
|
||||
refreshView(STATE_LOAD_ERROR);
|
||||
ToastUtils.show("同步失败,请稍后重试");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@androidx.annotation.NonNull Throwable e) {
|
||||
mCount = 0;
|
||||
mDialog.dismiss();
|
||||
refreshView(STATE_LOAD_ERROR);
|
||||
ToastUtils.show("同步失败,请稍后重试");
|
||||
}
|
||||
@Override
|
||||
public void onComplete() {
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@ -186,38 +187,38 @@ public class AddressListActivity extends BaseActivity {
|
||||
*/
|
||||
private void doSyncDept() {
|
||||
RetrofitManager.getInstance()
|
||||
.create(GridApis.class)
|
||||
.getAllDeptList(UserLgUtils.getToken())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Observer<List<DeptDatabaseBean>>() {
|
||||
@Override
|
||||
public void onSubscribe(@androidx.annotation.NonNull Disposable d) {
|
||||
.create(GridApis.class)
|
||||
.getAllDeptList(UserLgUtils.getToken())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Observer<List<DeptDatabaseBean>>() {
|
||||
@Override
|
||||
public void onSubscribe(@androidx.annotation.NonNull Disposable d) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@androidx.annotation.NonNull List<DeptDatabaseBean> deptDatabaseBeans) {
|
||||
++mCount;
|
||||
mDatabaseBeanList = deptDatabaseBeans;
|
||||
if (mCount == 2) {
|
||||
insertAll();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
mCount = 0;
|
||||
refreshView(STATE_LOAD_ERROR);
|
||||
mDialog.dismiss();
|
||||
ToastUtils.show("同步失败,请稍后重试");
|
||||
}
|
||||
@Override
|
||||
public void onNext(@androidx.annotation.NonNull List<DeptDatabaseBean> deptDatabaseBeans) {
|
||||
++mCount;
|
||||
mDatabaseBeanList = deptDatabaseBeans;
|
||||
if (mCount == 2) {
|
||||
insertAll();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
mCount = 0;
|
||||
refreshView(STATE_LOAD_ERROR);
|
||||
mDialog.dismiss();
|
||||
ToastUtils.show("同步失败,请稍后重试");
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public void onComplete() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@ -264,6 +265,7 @@ public class AddressListActivity extends BaseActivity {
|
||||
commonNavigator.setAdapter(new ViewPageNavigatorAdapter(this, mTitles, mVpContent));
|
||||
commonNavigator.setAdjustMode(true);
|
||||
mMiTabs.setNavigator(commonNavigator);
|
||||
mVpContent.setUserInputEnabled(false);
|
||||
UIUtil.bindViewPager2(mMiTabs, mVpContent, null);
|
||||
}
|
||||
|
||||
@ -285,8 +287,8 @@ public class AddressListActivity extends BaseActivity {
|
||||
@Override
|
||||
protected void listenerSearch() {
|
||||
ARouter.getInstance()
|
||||
.build(PathConfig.PATH_MODULE_CHAT_ADDRESSLIST_SEARCH)
|
||||
.navigation();
|
||||
.build(PathConfig.PATH_MODULE_CHAT_ADDRESSLIST_SEARCH)
|
||||
.navigation();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -5,6 +5,9 @@ import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ProgressBar;
|
||||
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.tengshisoft.chatmodule.R;
|
||||
@ -18,13 +21,13 @@ import com.tenlionsoft.baselib.core.db.AppDatabase;
|
||||
import com.tenlionsoft.baselib.core.db.DeptDao;
|
||||
import com.tenlionsoft.baselib.core.db.UserDao;
|
||||
import com.tenlionsoft.baselib.core.widget.base.BaseFragment;
|
||||
import com.tenlionsoft.baselib.core.widget.base.WrapContentLinearLayoutManager;
|
||||
import com.tenlionsoft.baselib.core.widget.views.TypeFaceTextView;
|
||||
import com.tenlionsoft.baselib.utils.LogUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.Unbinder;
|
||||
@ -82,7 +85,7 @@ public class DeptContactFragment extends BaseFragment {
|
||||
mSelDatas = new ArrayList<>();
|
||||
mSelDatas.add(bean1);
|
||||
mSelAdapter = new DeptChooseAdapter(mActivity, mSelDatas);
|
||||
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(mActivity);
|
||||
WrapContentLinearLayoutManager linearLayoutManager = new WrapContentLinearLayoutManager(mActivity);
|
||||
linearLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
|
||||
mRlvSelDept.setLayoutManager(linearLayoutManager);
|
||||
mRlvSelDept.setAdapter(mSelAdapter);
|
||||
@ -95,10 +98,10 @@ public class DeptContactFragment extends BaseFragment {
|
||||
UserDatabaseBean bean = (UserDatabaseBean) o;
|
||||
//跳转用户详情
|
||||
ARouter.getInstance()
|
||||
.build(PathConfig.PATH_MODULE_CHAT_ADDRESSLIST_USER_DETAIL)
|
||||
.withString("id", bean.getUserId())
|
||||
.withString("deptId", bean.getDepartmentId())
|
||||
.navigation();
|
||||
.build(PathConfig.PATH_MODULE_CHAT_ADDRESSLIST_USER_DETAIL)
|
||||
.withString("id", bean.getUserId())
|
||||
.withString("deptId", bean.getDepartmentId())
|
||||
.navigation();
|
||||
} else {
|
||||
//部门
|
||||
DeptDatabaseBean bean = (DeptDatabaseBean) o;
|
||||
@ -111,9 +114,9 @@ public class DeptContactFragment extends BaseFragment {
|
||||
queryDept();
|
||||
}
|
||||
});
|
||||
|
||||
mSelAdapter.setOnItemChoose((bean12, pos) -> {
|
||||
mSelDatas = mSelDatas.subList(0, pos + 1);
|
||||
LogUtils.e("选择部门==" + (pos + 1));
|
||||
mSelAdapter.setData(mSelDatas);
|
||||
mRlvSelDept.scrollToPosition(mSelDatas.size() - 1);
|
||||
mSelDeptId = bean12.getDepartmentId();
|
||||
@ -130,56 +133,56 @@ public class DeptContactFragment extends BaseFragment {
|
||||
mDatas.clear();
|
||||
refreshStateView(STATE_LOAD);
|
||||
Observable.create((ObservableOnSubscribe<Integer>) emitter -> {
|
||||
try {
|
||||
if (mDataBase == null) {
|
||||
mDataBase = AppDatabase.getInstance(mActivity.getApplication());
|
||||
mDeptDao = mDataBase.getDeptDao();
|
||||
mUserDao = mDataBase.getUserDao();
|
||||
}
|
||||
List<DeptDatabaseBean> beans = mDeptDao.queryByPid(mSelDeptId);
|
||||
List<UserDatabaseBean> deptId = mUserDao.getUsersByDeptId(mSelDeptId);
|
||||
if (beans.size() > 0 || deptId.size() > 0) {
|
||||
mDatas.addAll(beans);
|
||||
mDatas.addAll(deptId);
|
||||
emitter.onNext(1);
|
||||
} else {
|
||||
emitter.onNext(2);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
emitter.onError(new Exception("加载失败"));
|
||||
}
|
||||
})
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Observer<Integer>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull Integer o) {
|
||||
if (o == 1) {
|
||||
//有数据
|
||||
mAdapter.setData(mDatas);
|
||||
refreshStateView(STATE_SUCCESS);
|
||||
} else {
|
||||
//没有数据
|
||||
refreshStateView(STATE_EMPTY);
|
||||
try {
|
||||
if (mDataBase == null) {
|
||||
mDataBase = AppDatabase.getInstance(mActivity.getApplication());
|
||||
mDeptDao = mDataBase.getDeptDao();
|
||||
mUserDao = mDataBase.getUserDao();
|
||||
}
|
||||
List<DeptDatabaseBean> beans = mDeptDao.queryByPid(mSelDeptId);
|
||||
List<UserDatabaseBean> deptId = mUserDao.getUsersByDeptId(mSelDeptId);
|
||||
if (beans.size() > 0 || deptId.size() > 0) {
|
||||
mDatas.addAll(beans);
|
||||
mDatas.addAll(deptId);
|
||||
emitter.onNext(1);
|
||||
} else {
|
||||
emitter.onNext(2);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
emitter.onError(new Exception("加载失败"));
|
||||
}
|
||||
}
|
||||
})
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Observer<Integer>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
//加载失败
|
||||
refreshStateView(STATE_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
@Override
|
||||
public void onNext(@NonNull Integer o) {
|
||||
mAdapter.setData(mDatas);
|
||||
if (o == 1) {
|
||||
//有数据
|
||||
refreshStateView(STATE_SUCCESS);
|
||||
} else {
|
||||
//没有数据
|
||||
refreshStateView(STATE_EMPTY);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
//加载失败
|
||||
refreshStateView(STATE_ERROR);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user