选择礼物转到指定为止

This commit is contained in:
ningwenqiang 2024-09-27 12:05:00 +08:00
parent b6d715d81c
commit cdf9e75ebd

View File

@ -1036,12 +1036,17 @@ public class LiveGiftPopup2 extends AbsDialogFragment {
}
giftTitleAdapter.addAllData(name);
if (!TextUtils.isEmpty(mWishGiftId) && liveGiftList.size() > 0) {
Log.i("LiveGiftPopup2", "有礼物设置");
int postion =-1;
for (int i = 0; i < liveGiftList.size(); i++) {
JSONObject data = liveGiftList.getJSONObject(i);
String giftJson = data.getString("giftlist");
List<LiveGiftBean> liveGiftBeans = JSONArray.parseArray(giftJson, LiveGiftBean.class);
for (LiveGiftBean model : liveGiftBeans) {
for (int j = 0; j < liveGiftBeans.size(); j++) {
LiveGiftBean model = liveGiftBeans.get(j);
if (TextUtils.equals(model.getId() + "", mWishGiftId)) {
model.setChecked(true);
postion= j;
mFrameGiftNewAdapter = new FrameGiftNewAdapter(liveGiftBeans, mStream, mLiveUid, mWishGiftId);
giftRecyclerView.setAdapter(mFrameGiftNewAdapter);
giftTitleAdapter.setTitleIndex(i);
@ -1049,6 +1054,18 @@ public class LiveGiftPopup2 extends AbsDialogFragment {
}
}
}
if (postion>-1){
final int p = postion;
giftRecyclerView.scrollToPosition(postion);
// Log.i("LiveGiftPopup2", "进行位置滚动"+p);
// giftRecyclerView.postDelayed(new Runnable() {
// @Override
// public void run() {
// Log.i("LiveGiftPopup2", "进行位置滚动"+p);
// giftRecyclerView.scrollToPosition(p);
// }
// },200);
}
} else {
JSONObject obj2 = liveGiftList.getJSONObject(0);
String giftJson = obj2.getString("giftlist");