[6.0.0]
[taxi driver kotlin]
This commit is contained in:
@@ -1,100 +0,0 @@
|
||||
package com.mogo.och.taxi;
|
||||
|
||||
import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_TAXI;
|
||||
|
||||
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.call.setting.CallerMoGoUiSettingManager;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
import com.mogo.och.taxi.constant.TaxiUnmannedConst;
|
||||
import com.mogo.och.taxi.ui.TaxiFragment;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2021/1/15
|
||||
* <p>
|
||||
* 网约车-出租车
|
||||
*/
|
||||
@Route( path = TaxiUnmannedConst.PATH )
|
||||
class TaxiUnmannedProvider implements IMogoOCH {
|
||||
|
||||
private static final String TAG = "TaxiProvider";
|
||||
private TaxiFragment ochTaxiFragment;
|
||||
private FragmentActivity mActivity;
|
||||
private int mContainerId;
|
||||
@Override
|
||||
public void init( Context context ) {
|
||||
CallerLogger.INSTANCE.d( M_TAXI + TAG, "init" );
|
||||
}
|
||||
|
||||
/**
|
||||
* 进入鹰眼模式,设置手势缩放地图失效
|
||||
*/
|
||||
private void stepIntoVrMode() {
|
||||
CallerLogger.INSTANCE.d( M_TAXI + TAG, "进入vr模式" );
|
||||
CallerMoGoUiSettingManager.INSTANCE.stepInNightMode();//夜间模式 状态栏字体颜色变黑
|
||||
}
|
||||
|
||||
private void showFragment() {
|
||||
FragmentManager supportFragmentManager = mActivity.getSupportFragmentManager();
|
||||
if (ochTaxiFragment == null) {
|
||||
CallerLogger.INSTANCE.d(M_TAXI + TAG, "准备add fragment======");
|
||||
Fragment fragmentByTag = supportFragmentManager.findFragmentByTag(TaxiFragment.TAG);
|
||||
if (fragmentByTag instanceof TaxiFragment){
|
||||
ochTaxiFragment = (TaxiFragment) fragmentByTag;
|
||||
}else {
|
||||
ochTaxiFragment = new TaxiFragment();
|
||||
}
|
||||
|
||||
if (!ochTaxiFragment.isAdded()){
|
||||
supportFragmentManager.beginTransaction().add(mContainerId, ochTaxiFragment
|
||||
,TaxiFragment.TAG).commitAllowingStateLoss();
|
||||
}
|
||||
return;
|
||||
}
|
||||
CallerLogger.INSTANCE.d(M_TAXI + TAG, "准备show fragment");
|
||||
supportFragmentManager.beginTransaction().show(ochTaxiFragment).commitAllowingStateLoss();
|
||||
}
|
||||
|
||||
private void hideFragment(){
|
||||
if (ochTaxiFragment != null){
|
||||
mActivity.getSupportFragmentManager().beginTransaction().hide(ochTaxiFragment).commitAllowingStateLoss();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createCoverage(FragmentActivity activity, int containerId) {
|
||||
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getFunctionName() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Fragment createCoverage(@Nullable FragmentActivity fragmentActivity, @Nullable Integer integer) {
|
||||
this.mActivity = fragmentActivity;
|
||||
this.mContainerId = integer;
|
||||
showFragment();
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
//若不调用finish, 设置中打开关闭UITouch,会造成och fragment 重叠
|
||||
if (mActivity == null) return;
|
||||
mActivity.finish();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
package com.mogo.och.taxi
|
||||
|
||||
import android.content.Context
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.FragmentActivity
|
||||
import com.alibaba.android.arouter.facade.annotation.Route
|
||||
import com.mogo.eagle.core.function.call.setting.CallerMoGoUiSettingManager.stepInNightMode
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.d
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant
|
||||
import com.mogo.och.taxi.constant.TaxiUnmannedConst
|
||||
import com.mogo.och.taxi.ui.TaxiFragment
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2021/1/15
|
||||
*
|
||||
*
|
||||
* 网约车-出租车
|
||||
*/
|
||||
@Route(path = TaxiUnmannedConst.PATH)
|
||||
class TaxiUnmannedProvider : IMogoOCH {
|
||||
private var ochTaxiFragment: TaxiFragment? = null
|
||||
private var mActivity: FragmentActivity? = null
|
||||
private var mContainerId = 0
|
||||
override fun init(context: Context) {
|
||||
d(SceneConstant.M_TAXI + TAG, "init")
|
||||
}
|
||||
|
||||
/**
|
||||
* 进入鹰眼模式,设置手势缩放地图失效
|
||||
*/
|
||||
private fun stepIntoVrMode() {
|
||||
d(SceneConstant.M_TAXI + TAG, "进入vr模式")
|
||||
stepInNightMode() //夜间模式 状态栏字体颜色变黑
|
||||
}
|
||||
|
||||
private fun showFragment() {
|
||||
val supportFragmentManager = mActivity!!.supportFragmentManager
|
||||
if (ochTaxiFragment == null) {
|
||||
d(SceneConstant.M_TAXI + TAG, "准备add fragment======")
|
||||
val fragmentByTag = supportFragmentManager.findFragmentByTag(TaxiFragment.TAG)
|
||||
ochTaxiFragment = if (fragmentByTag is TaxiFragment) {
|
||||
fragmentByTag
|
||||
} else {
|
||||
TaxiFragment()
|
||||
}
|
||||
if (!ochTaxiFragment!!.isAdded) {
|
||||
supportFragmentManager.beginTransaction().add(
|
||||
mContainerId, ochTaxiFragment!!, TaxiFragment.TAG
|
||||
).commitAllowingStateLoss()
|
||||
}
|
||||
return
|
||||
}
|
||||
d(SceneConstant.M_TAXI + TAG, "准备show fragment")
|
||||
supportFragmentManager.beginTransaction().show(ochTaxiFragment!!).commitAllowingStateLoss()
|
||||
}
|
||||
|
||||
private fun hideFragment() {
|
||||
if (ochTaxiFragment != null) {
|
||||
mActivity!!.supportFragmentManager.beginTransaction().hide(ochTaxiFragment!!)
|
||||
.commitAllowingStateLoss()
|
||||
}
|
||||
}
|
||||
|
||||
override fun createCoverage(activity: FragmentActivity, containerId: Int) {}
|
||||
override val functionName: String
|
||||
get() = "TaxiUnmannedProvider"
|
||||
|
||||
override fun createCoverage(fragmentActivity: FragmentActivity?, integer: Int?): Fragment? {
|
||||
mActivity = fragmentActivity
|
||||
mContainerId = integer!!
|
||||
showFragment()
|
||||
return null
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
//若不调用finish, 设置中打开关闭UITouch,会造成och fragment 重叠
|
||||
if (mActivity == null) return
|
||||
mActivity!!.finish()
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val TAG = "TaxiProvider"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user