Commit ace085a8 by konghaorui

补充flutterFragment设置状态栏方法

parent a6fc5e2d
package com.ydl.component package com.ydl.component
//import com.ydl.confide.home.ConfideHomeActivity //import com.ydl.confide.home.ConfideHomeActivity
//import com.yidianling.consultant.ExpertSearchActivity.Companion.HOT_SEARCH_DOCTOR_NAME
import android.Manifest import android.Manifest
import android.annotation.SuppressLint import android.annotation.SuppressLint
import android.content.ComponentName import android.content.ComponentName
...@@ -26,10 +27,8 @@ import com.ydl.ydlcommon.modular.ModularServiceManager ...@@ -26,10 +27,8 @@ import com.ydl.ydlcommon.modular.ModularServiceManager
import com.ydl.ydlcommon.mvp.lce.BaseLceActivity import com.ydl.ydlcommon.mvp.lce.BaseLceActivity
import com.ydl.ydlcommon.router.IYDLRouterConstant import com.ydl.ydlcommon.router.IYDLRouterConstant
import com.yidianling.common.tools.ToastUtil import com.yidianling.common.tools.ToastUtil
//import com.yidianling.consultant.ExpertSearchActivity.Companion.HOT_SEARCH_DOCTOR_NAME
import com.yidianling.consultant.api.IConsultantService import com.yidianling.consultant.api.IConsultantService
import com.yidianling.fm.api.service.IFMService import com.yidianling.fm.api.service.IFMService
import com.yidianling.tests.home.NewTestHomeActivity
import com.yidianling.user.widget.SecretDescriptionDialog import com.yidianling.user.widget.SecretDescriptionDialog
import com.yidianling.user.widget.SecretDialog import com.yidianling.user.widget.SecretDialog
import kotlinx.android.synthetic.main.activity_main.* import kotlinx.android.synthetic.main.activity_main.*
...@@ -106,7 +105,8 @@ class MainActivity : BaseLceActivity<DemoContract.View, DemoContract.Presenter>( ...@@ -106,7 +105,8 @@ class MainActivity : BaseLceActivity<DemoContract.View, DemoContract.Presenter>(
FragmentContainerActivity.start(this, "TrendsHomeFragment") FragmentContainerActivity.start(this, "TrendsHomeFragment")
} }
bt_to_tests.setOnClickListener { bt_to_tests.setOnClickListener {
startActivity(Intent(this, NewTestHomeActivity::class.java)) // startActivity(Intent(this, NewTestHomeActivity::class.java))
FragmentContainerActivity.start(this, "NewTestHomeFragment")
} }
bt_to_confide.setOnClickListener { bt_to_confide.setOnClickListener {
// YDLavManager.instances.login("1193016") // YDLavManager.instances.login("1193016")
......
...@@ -13,6 +13,7 @@ import com.yidianling.home.ui.fragment.YdlHomeFragment ...@@ -13,6 +13,7 @@ import com.yidianling.home.ui.fragment.YdlHomeFragment
//import com.yidianling.dynamic.trendsHome.TrendsHomeFragment //import com.yidianling.dynamic.trendsHome.TrendsHomeFragment
//import com.yidianling.home.ui.fragment.YdlHomeFragment //import com.yidianling.home.ui.fragment.YdlHomeFragment
import com.yidianling.im.ui.page.NewMultiMessageFragment import com.yidianling.im.ui.page.NewMultiMessageFragment
import com.yidianling.tests.home.NewTestHomeFragment
import com.yidianling.user.mine.MineFragment import com.yidianling.user.mine.MineFragment
...@@ -79,6 +80,9 @@ class FragmentContainerActivity : BaseLceActivity<DemoContract.View, DemoContrac ...@@ -79,6 +80,9 @@ class FragmentContainerActivity : BaseLceActivity<DemoContract.View, DemoContrac
if ("MineFragment" == fragmentName) { if ("MineFragment" == fragmentName) {
return MineFragment() return MineFragment()
} }
if ("NewTestHomeFragment" == fragmentName) {
return NewTestHomeFragment()
}
return PlayFragment() return PlayFragment()
} }
} }
...@@ -50,9 +50,9 @@ ext { ...@@ -50,9 +50,9 @@ ext {
"m-im" : "0.0.15.5", "m-im" : "0.0.15.5",
"m-dynamic" : "0.0.7.3", "m-dynamic" : "0.0.7.3",
"m-muse" : "0.0.28.2", "m-muse" : "0.0.28.8",
"m-tests" : "0.0.23.2", "m-tests" : "0.0.23.8",
"m-course" : "0.0.41.8", "m-course" : "0.0.41.9",
//-------------- 业务模块 API 层 -------------- //-------------- 业务模块 API 层 --------------
"m-audioim-api" : "0.0.6", "m-audioim-api" : "0.0.6",
...@@ -69,14 +69,14 @@ ext { ...@@ -69,14 +69,14 @@ ext {
//-------------- 功能组件 -------------- //-------------- 功能组件 --------------
//第一步 //第一步
"ydl-platform" : "0.0.39.3", "ydl-platform" : "0.0.39.4",
//第二步 若干 //第二步 若干
"ydl-webview" : "0.0.38.4", "ydl-webview" : "0.0.38.4",
"ydl-media" : "0.0.21.3", "ydl-media" : "0.0.21.3",
"ydl-pay" : "0.0.18.3", "ydl-pay" : "0.0.18.3",
"m-audioim" : "0.0.48.0", "m-audioim" : "0.0.48.0",
"ydl-flutter-base": "0.0.10.3", "ydl-flutter-base": "0.0.10.8",
//以下 几乎不会动 //以下 几乎不会动
"router" : "0.0.1", "router" : "0.0.1",
...@@ -122,7 +122,7 @@ ext { ...@@ -122,7 +122,7 @@ ext {
"ydl-media" : "0.0.21.3", "ydl-media" : "0.0.21.3",
"ydl-pay" : "0.0.18.3", "ydl-pay" : "0.0.18.3",
"m-audioim" : "0.0.48.0", "m-audioim" : "0.0.48.0",
"ydl-flutter-base": "0.0.10.3", "ydl-flutter-base": "0.0.10.8",
//以下 几乎不会动 //以下 几乎不会动
"router" : "0.0.1", "router" : "0.0.1",
......
...@@ -24,7 +24,7 @@ modular { ...@@ -24,7 +24,7 @@ modular {
groupId = "com.ydl" groupId = "com.ydl"
artifactId = "m-tests-api" artifactId = "m-tests-api"
//开发时注释掉版本号,发布api时打开 //开发时注释掉版本号,发布api时打开
version = rootProject.ext.ydlPublishVersion[childProject.getName()+"-api"] //version = rootProject.ext.ydlPublishVersion[childProject.getName()+"-api"]
// API 层打包时需要引入的依赖 // API 层打包时需要引入的依赖
apiDependencies { apiDependencies {
implementation "com.google.code.gson:gson:2.8.2" implementation "com.google.code.gson:gson:2.8.2"
......
...@@ -16,6 +16,6 @@ class NewTestHomeActivity : BaseFlutterActivity() { ...@@ -16,6 +16,6 @@ class NewTestHomeActivity : BaseFlutterActivity() {
} }
override fun initChannelPlugin(jsonObject: JSONObject) { override fun initChannelPlugin(jsonObject: JSONObject) {
TestPlugin.Companion.rigister(this) TestPlugin.Companion.register(this)
} }
} }
\ No newline at end of file
package com.yidianling.tests.home
import com.alibaba.android.arouter.facade.annotation.Route
import com.channel.ydl_flutter_base.base.BaseFlutterFragment
import com.ydl.ydlcommon.utils.StatusBarUtils
import com.yidianling.tests.home.plugin.TestPlugin
import io.flutter.view.FlutterView
/**
* flutter版测评首页
* Created by xj on 2019/11/19.
*/
@Route(path = "/tests/home")
class NewTestHomeFragment : BaseFlutterFragment() {
override fun initChannelPlugin(flutterView: FlutterView) {
var statusBarHeight = StatusBarUtils.getStatusBarHeight(context);
flutterView.setPadding(0,statusBarHeight,0,0)
TestPlugin.Companion.register(this,flutterView)
}
override fun initialRoute(): String {
return "test/home"
}
}
\ No newline at end of file
package com.yidianling.tests.home.plugin package com.yidianling.tests.home.plugin
import android.app.Activity
import android.net.Uri import android.net.Uri
import com.channel.ydl_flutter_base.base.BaseFlutterFragment
import com.ydl.webview.H5Params import com.ydl.webview.H5Params
import com.ydl.webview.NewH5Activity import com.ydl.webview.NewH5Activity
import com.ydl.ydl_router.manager.YDLRouterManager import com.ydl.ydl_router.manager.YDLRouterManager
...@@ -14,14 +16,15 @@ import com.yidianling.tests.search.TestSearchActivity ...@@ -14,14 +16,15 @@ import com.yidianling.tests.search.TestSearchActivity
import io.flutter.app.FlutterActivity import io.flutter.app.FlutterActivity
import io.flutter.plugin.common.MethodCall import io.flutter.plugin.common.MethodCall
import io.flutter.plugin.common.MethodChannel import io.flutter.plugin.common.MethodChannel
import io.flutter.view.FlutterView
/** /**
* Created by xj on 2019/11/19. * Created by xj on 2019/11/19.
*/ */
class TestPlugin : MethodChannel.MethodCallHandler { class TestPlugin : MethodChannel.MethodCallHandler {
private var mActivity: FlutterActivity? = null private var mActivity: Activity? = null
private constructor(activity: FlutterActivity) { private constructor(activity: Activity) {
mActivity = activity mActivity = activity
} }
companion object { companion object {
...@@ -37,9 +40,13 @@ class TestPlugin : MethodChannel.MethodCallHandler { ...@@ -37,9 +40,13 @@ class TestPlugin : MethodChannel.MethodCallHandler {
const val IS_HIDE_LEFT_BACK = "hideLeftBackLL" // 是否隐藏标题左侧布局 const val IS_HIDE_LEFT_BACK = "hideLeftBackLL" // 是否隐藏标题左侧布局
public var testDelegate:TestPluginDelegate?=null public var testDelegate:TestPluginDelegate?=null
fun rigister(activity: FlutterActivity) { fun register(activity: FlutterActivity) {
MethodChannel(activity.flutterView, CHANNEL).setMethodCallHandler(TestPlugin(activity)) MethodChannel(activity.flutterView, CHANNEL).setMethodCallHandler(TestPlugin(activity))
} }
fun register(fragment: BaseFlutterFragment, flutterView: FlutterView) {
MethodChannel(flutterView, CHANNEL).setMethodCallHandler(TestPlugin(fragment.activity))
}
} }
override fun onMethodCall(methodCall: MethodCall, result: MethodChannel.Result) { override fun onMethodCall(methodCall: MethodCall, result: MethodChannel.Result) {
......
...@@ -2,8 +2,11 @@ package com.channel.ydl_flutter_base.base ...@@ -2,8 +2,11 @@ package com.channel.ydl_flutter_base.base
import android.os.Bundle import android.os.Bundle
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import com.channel.ydl_flutter_base.plugin.YDLCommonPlugin import com.channel.ydl_flutter_base.plugin.YDLCommonPlugin
import com.ydl.ydlcommon.bean.StatusBarOptions
import com.ydl.ydlcommon.utils.StatusBarUtils
import io.flutter.view.FlutterView import io.flutter.view.FlutterView
/** /**
...@@ -14,14 +17,25 @@ import io.flutter.view.FlutterView ...@@ -14,14 +17,25 @@ import io.flutter.view.FlutterView
abstract class BaseFlutterFragment : FlutterFragment() { abstract class BaseFlutterFragment : FlutterFragment() {
private var mFlutterView: FlutterView? = null private var mFlutterView: FlutterView? = null
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): FlutterView { open fun getStatusViewOptions(): StatusBarOptions {
return StatusBarOptions(true, statusBarDarkMode = true)
}
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
mFlutterView= Flutter.createView( mFlutterView= Flutter.createView(
activity!!, activity,
lifecycle, lifecycle,
initialRoute()) initialRoute())
YDLCommonPlugin.fragmentRegister(this, mFlutterView!!) YDLCommonPlugin.fragmentRegister(this, mFlutterView!!)
initChannelPlugin(mFlutterView!!) initChannelPlugin(mFlutterView!!)
return mFlutterView!!
if (getStatusViewOptions().isAddStatusView){
val returnViews = StatusBarUtils.initStatusBarView(activity!!, mFlutterView!!, getStatusViewOptions())
return returnViews[0]
}else{
return mFlutterView!!
}
} }
/** /**
......
...@@ -6,6 +6,7 @@ import android.support.annotation.NonNull; ...@@ -6,6 +6,7 @@ import android.support.annotation.NonNull;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import com.example.fm_plugin.base.Flutter; import com.example.fm_plugin.base.Flutter;
...@@ -36,7 +37,7 @@ public class FlutterFragment extends Fragment { ...@@ -36,7 +37,7 @@ public class FlutterFragment extends Fragment {
} }
@Override @Override
public FlutterView onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
return Flutter.createView(getActivity(), getLifecycle(), mRoute); return Flutter.createView(getActivity(), getLifecycle(), mRoute);
} }
} }
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<corners android:radius="@dimen/platform_dp_14" /> <corners android:radius="@dimen/platform_dp_14" />
<gradient <gradient
android:endColor="@color/platform_color_1EA6FA" android:endColor="@color/platform_main_gradient_end_color"
android:startColor="@color/platform_color_5CC8F7"/> android:startColor="@color/platform_main_gradient_start_color"/>
</shape> </shape>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment