68 1
This commit is contained in:
@@ -11,6 +11,7 @@ import androidx.annotation.Nullable;
|
|||||||
import androidx.databinding.ViewDataBinding;
|
import androidx.databinding.ViewDataBinding;
|
||||||
import androidx.fragment.app.FragmentActivity;
|
import androidx.fragment.app.FragmentActivity;
|
||||||
|
|
||||||
|
import com.blankj.utilcode.util.LogUtils;
|
||||||
import com.xscm.moduleutil.activity.IPresenter;
|
import com.xscm.moduleutil.activity.IPresenter;
|
||||||
import com.xscm.moduleutil.activity.IView;
|
import com.xscm.moduleutil.activity.IView;
|
||||||
|
|
||||||
@@ -20,6 +21,8 @@ public abstract class BaseMvpFragment<P extends IPresenter, VDB extends ViewData
|
|||||||
|
|
||||||
protected abstract P bindPresenter();
|
protected abstract P bindPresenter();
|
||||||
|
|
||||||
|
protected boolean isShowSuccess = false;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FragmentActivity getSelfActivity() {
|
public FragmentActivity getSelfActivity() {
|
||||||
return getActivity();
|
return getActivity();
|
||||||
@@ -37,6 +40,23 @@ public abstract class BaseMvpFragment<P extends IPresenter, VDB extends ViewData
|
|||||||
super.onViewCreated(view, savedInstanceState);
|
super.onViewCreated(view, savedInstanceState);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResume() {
|
||||||
|
super.onResume();
|
||||||
|
isShowSuccess = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onHiddenChanged(boolean hidden) {
|
||||||
|
super.onHiddenChanged(hidden);
|
||||||
|
LogUtils.e("BaseMvpFragmentAAA","onHiddenChanged==="+hidden+"====="+this.getClass().getSimpleName()+"===="+isShowSuccess);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStop() {
|
||||||
|
super.onStop();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDestroyView() {
|
public void onDestroyView() {
|
||||||
if (MvpPre != null) {
|
if (MvpPre != null) {
|
||||||
|
|||||||
@@ -161,7 +161,7 @@ public class CommonAppContext extends MultiDexApplication implements Applicatio
|
|||||||
//设置mqtt环境 false 测试环境 true 正式环境
|
//设置mqtt环境 false 测试环境 true 正式环境
|
||||||
// ExternalResConstants.INSTANCE.setIS_MQTT_RELEASE(false);
|
// ExternalResConstants.INSTANCE.setIS_MQTT_RELEASE(false);
|
||||||
//设置http环境 false 测试环境 true 正式环境
|
//设置http环境 false 测试环境 true 正式环境
|
||||||
ExternalResConstants.INSTANCE.setIS_HTTP_RELEASE(false);
|
ExternalResConstants.INSTANCE.setIS_HTTP_RELEASE(true);
|
||||||
currentEnvironment = ExternalResConstants.INSTANCE.HTTP_PATH();
|
currentEnvironment = ExternalResConstants.INSTANCE.HTTP_PATH();
|
||||||
|
|
||||||
initialization();
|
initialization();
|
||||||
|
|||||||
@@ -1685,8 +1685,9 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
|||||||
} else {
|
} else {
|
||||||
clFirstCharge(false)
|
clFirstCharge(false)
|
||||||
}
|
}
|
||||||
|
mRoomInfoResp?.room_info?.let { roomInfo ->
|
||||||
EventBus.getDefault().post(mRoomInfoResp?.room_info)
|
EventBus.getDefault().post(roomInfo)
|
||||||
|
}
|
||||||
|
|
||||||
EventBus.getDefault().post(roomSettingEvent)
|
EventBus.getDefault().post(roomSettingEvent)
|
||||||
}
|
}
|
||||||
@@ -1926,7 +1927,11 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
|||||||
roomFragment!!.upRoomInfoData(mRoomInfoResp)
|
roomFragment!!.upRoomInfoData(mRoomInfoResp)
|
||||||
roomFragment?.handleRoomMessage(messageEvent)
|
roomFragment?.handleRoomMessage(messageEvent)
|
||||||
}
|
}
|
||||||
|
RoomType.SIGN_CONTRACT ->{
|
||||||
|
mRoomInfoResp?.room_info?.pit_list!![pitNumber.toInt() - 1] = RoomPitBean(pitNumber)
|
||||||
|
roomFragment!!.upRoomInfoData(mRoomInfoResp)
|
||||||
|
roomFragment?.handleRoomMessage(messageEvent)
|
||||||
|
}
|
||||||
else -> {
|
else -> {
|
||||||
roomFragment!!.updateSeatViewExchangedWithPitArray(mRoomInfoResp)
|
roomFragment!!.updateSeatViewExchangedWithPitArray(mRoomInfoResp)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.xscm.modulemain.activity.room.fragment;
|
package com.xscm.modulemain.activity.room.fragment;
|
||||||
|
|
||||||
import android.Manifest;
|
import android.Manifest;
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.CountDownTimer;
|
import android.os.CountDownTimer;
|
||||||
@@ -59,6 +60,10 @@ import java.nio.charset.StandardCharsets;
|
|||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import io.reactivex.Observable;
|
||||||
|
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author qx
|
* @author qx
|
||||||
@@ -110,6 +115,7 @@ public class RoomFragment extends BaseMvpFragment<RoomPresenter, FragmentRoomBin
|
|||||||
|
|
||||||
FragmentManager fragmentManager = null;
|
FragmentManager fragmentManager = null;
|
||||||
FragmentTransaction fragmentTransaction = null;
|
FragmentTransaction fragmentTransaction = null;
|
||||||
|
|
||||||
private void setRoomSeatViewType() {
|
private void setRoomSeatViewType() {
|
||||||
if (mRoomInfoResp == null || mRoomInfoResp.getRoom_info() == null) {
|
if (mRoomInfoResp == null || mRoomInfoResp.getRoom_info() == null) {
|
||||||
return;
|
return;
|
||||||
@@ -402,7 +408,8 @@ public class RoomFragment extends BaseMvpFragment<RoomPresenter, FragmentRoomBin
|
|||||||
} else if (roomType == RoomType.DATING) {
|
} else if (roomType == RoomType.DATING) {
|
||||||
newFragment = switch (labelId) {
|
newFragment = switch (labelId) {
|
||||||
case "2" -> {
|
case "2" -> {
|
||||||
if (ktvFragment == null) ktvFragment = RoomKtvFragment.newInstance(mRoomInfoResp);
|
if (ktvFragment == null)
|
||||||
|
ktvFragment = RoomKtvFragment.newInstance(mRoomInfoResp);
|
||||||
else ktvFragment.roomInfoUpdate(mRoomInfoResp);
|
else ktvFragment.roomInfoUpdate(mRoomInfoResp);
|
||||||
yield ktvFragment;
|
yield ktvFragment;
|
||||||
}
|
}
|
||||||
@@ -436,7 +443,7 @@ public class RoomFragment extends BaseMvpFragment<RoomPresenter, FragmentRoomBin
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (newFragment != null) {
|
if (newFragment != null) {
|
||||||
switchFragment(newFragment, mBinding.roomItem.getId());
|
switchFragment(newFragment, mBinding.roomItem.getId(), false);
|
||||||
} else {
|
} else {
|
||||||
LogUtils.e("newFragment==null");
|
LogUtils.e("newFragment==null");
|
||||||
}
|
}
|
||||||
@@ -464,7 +471,11 @@ public class RoomFragment extends BaseMvpFragment<RoomPresenter, FragmentRoomBin
|
|||||||
private Fragment currentFragment = null;
|
private Fragment currentFragment = null;
|
||||||
private boolean isReplacing = false;
|
private boolean isReplacing = false;
|
||||||
|
|
||||||
private void switchFragment(Fragment newFragment, int containerId) {
|
private int MAX_COUNT = 3;
|
||||||
|
private int retryCount = 0;
|
||||||
|
|
||||||
|
@SuppressLint("CheckResult")
|
||||||
|
private void switchFragment(Fragment newFragment, int containerId, boolean isAddFail) {
|
||||||
if (!isAdded() || newFragment == null) return;
|
if (!isAdded() || newFragment == null) return;
|
||||||
LogUtils.e("switchFragment attachA");
|
LogUtils.e("switchFragment attachA");
|
||||||
FragmentTransaction ft = getChildFragmentManager().beginTransaction();
|
FragmentTransaction ft = getChildFragmentManager().beginTransaction();
|
||||||
@@ -489,6 +500,43 @@ public class RoomFragment extends BaseMvpFragment<RoomPresenter, FragmentRoomBin
|
|||||||
|
|
||||||
currentFragment = newFragment;
|
currentFragment = newFragment;
|
||||||
|
|
||||||
|
// 校验2:事务执行后,验证Fragment的核心状态
|
||||||
|
// ① 是否真的附加到FragmentManager
|
||||||
|
boolean isLoadSuccess = true;
|
||||||
|
String errorMsg = null;
|
||||||
|
// 更全面的检查
|
||||||
|
if (!newFragment.isAdded()) {
|
||||||
|
isLoadSuccess = false;
|
||||||
|
errorMsg = "Fragment未附加到FragmentManager";
|
||||||
|
} else if (newFragment.getView() == null) {
|
||||||
|
isLoadSuccess = false;
|
||||||
|
errorMsg = "Fragment View创建失败";
|
||||||
|
} else if (!newFragment.isResumed()) {
|
||||||
|
// 可选:检查是否至少执行到onResume
|
||||||
|
// 注意:某些场景可能不需要这么严格的检查
|
||||||
|
isLoadSuccess = false;
|
||||||
|
errorMsg = "Fragment未进入Resumed状态";
|
||||||
|
}
|
||||||
|
LogUtils.e("switchFragment :"+errorMsg +",isLoadSuccess:"+isLoadSuccess);
|
||||||
|
// 处理失败情况
|
||||||
|
if (!isLoadSuccess) {
|
||||||
|
Log.e("FragmentCheck", errorMsg);
|
||||||
|
|
||||||
|
if (retryCount == MAX_COUNT){
|
||||||
|
LogUtils.e("switchFragment retryCount == MAX_COUNT");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 可以考虑自动恢复或通知用户
|
||||||
|
Observable.timer(1000, TimeUnit.MILLISECONDS).observeOn(AndroidSchedulers.mainThread()).subscribe(
|
||||||
|
aLong ->{
|
||||||
|
retryCount++;
|
||||||
|
LogUtils.e("switchFragment retry");
|
||||||
|
switchFragment(newFragment, containerId, true);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
startActivity(new Intent(ActivityUtils.getTopActivity(), TransparentActivity.class));
|
startActivity(new Intent(ActivityUtils.getTopActivity(), TransparentActivity.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,8 +28,8 @@ isBuildModule=false
|
|||||||
#org.gradle.deamon=false
|
#org.gradle.deamon=false
|
||||||
android.injected.testOnly=false
|
android.injected.testOnly=false
|
||||||
|
|
||||||
APP_VERSION_NAME=1.0.7.6
|
APP_VERSION_NAME=1.0.7.8
|
||||||
APP_VERSION_CODE=66
|
APP_VERSION_CODE=68
|
||||||
|
|
||||||
org.gradle.jvm.toolchain.useLegacyAdapters=false
|
org.gradle.jvm.toolchain.useLegacyAdapters=false
|
||||||
#org.gradle.java.home=C\:\\Users\\qx\\.jdks\\ms-17.0.15
|
#org.gradle.java.home=C\:\\Users\\qx\\.jdks\\ms-17.0.15
|
||||||
|
|||||||
Reference in New Issue
Block a user