[6.4.0]
[temp]
This commit is contained in:
@@ -1,86 +0,0 @@
|
||||
|
||||
package com.mogo.och.bus;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.mogo.eagle.core.function.api.base.IMoGoFunctionProvider;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
import com.mogo.och.bus.constant.BusConst;
|
||||
import com.mogo.och.bus.fragment.ShuttleFragment;
|
||||
import com.mogo.och.common.module.biz.constant.OchCommonConst;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* 网约车小巴业务实现入口
|
||||
*
|
||||
* @author tongchenfei
|
||||
*/
|
||||
@Route(path = OchCommonConst.SHUTTLE_DRIVER)
|
||||
public class BusProvider implements IMoGoFunctionProvider {
|
||||
|
||||
private static final String TAG = "BusProvider";
|
||||
|
||||
private ShuttleFragment busFragment;
|
||||
private int containerId;
|
||||
private FragmentActivity activity;
|
||||
|
||||
@Override
|
||||
public void init(Context context) {
|
||||
}
|
||||
|
||||
private void showFragment() {
|
||||
FragmentManager supportFragmentManager = activity.getSupportFragmentManager();
|
||||
if (busFragment == null) {
|
||||
CallerLogger.d(TAG, "准备add fragment======");
|
||||
Fragment fragmentByTag = supportFragmentManager.findFragmentByTag(ShuttleFragment.TAG);
|
||||
if (fragmentByTag instanceof ShuttleFragment) {
|
||||
busFragment = (ShuttleFragment) fragmentByTag;
|
||||
} else {
|
||||
busFragment = new ShuttleFragment();
|
||||
}
|
||||
if(!busFragment.isAdded()) {
|
||||
supportFragmentManager.beginTransaction().add(containerId, busFragment, ShuttleFragment.TAG).commitAllowingStateLoss();
|
||||
}
|
||||
return;
|
||||
}
|
||||
CallerLogger.d(TAG, "准备show fragment");
|
||||
supportFragmentManager.beginTransaction().show(busFragment).commitAllowingStateLoss();
|
||||
}
|
||||
|
||||
private void hideFragment() {
|
||||
if (busFragment != null) {
|
||||
CallerLogger.d(TAG, "准备hide fragment");
|
||||
activity.getSupportFragmentManager().beginTransaction().hide(busFragment).commitAllowingStateLoss();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getFunctionName() {
|
||||
return TAG;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Fragment createCoverage(@Nullable FragmentActivity fragmentActivity, @Nullable Integer integer) {
|
||||
this.containerId = integer;
|
||||
this.activity = fragmentActivity;
|
||||
showFragment();
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
//若不调用finish, 设置中打开关闭UITouch,会造成och fragment 重叠
|
||||
if (activity == null) return;
|
||||
activity.finish();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.mogo.och.bus
|
||||
|
||||
import android.content.Context
|
||||
import androidx.fragment.app.Fragment
|
||||
import com.alibaba.android.arouter.facade.annotation.Route
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.d
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant
|
||||
import com.mogo.och.bus.fragment.ShuttleFragment
|
||||
import com.mogo.och.common.module.biz.constant.OchCommonConst
|
||||
import com.mogo.och.common.module.biz.provider.CommonService
|
||||
|
||||
/**
|
||||
* 网约车小巴业务实现入口
|
||||
*
|
||||
* @author tongchenfei
|
||||
*/
|
||||
@Route(path = OchCommonConst.SHUTTLE_DRIVER)
|
||||
class BusProvider : CommonService {
|
||||
private var busFragment: ShuttleFragment? = null
|
||||
override fun init(context: Context) {
|
||||
d(SceneConstant.M_TAXI + TAG, "init")
|
||||
busFragment = ShuttleFragment()
|
||||
}
|
||||
|
||||
override fun getFragment(): Fragment {
|
||||
return busFragment!!
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val TAG = "BusProvider"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user