Commit 12022142 by 严久程

课程\fm

parents 2fa9d499 4d43b18f
...@@ -80,6 +80,17 @@ android { ...@@ -80,6 +80,17 @@ android {
keyPassword "123456" keyPassword "123456"
} }
} }
dexOptions {
//使用增量模式构建
// incremental true//最大堆内存
javaMaxHeapSize "4g"//是否支持大工程模式
jumboMode = true//预编译
preDexLibraries = true//线程数
threadCount = 8
//禁止打了运行时注解的类全部打到主dex中
keepRuntimeAnnotatedClasses = false
// additionalParameters = ["--minimal-main-dex"]
}
//多维度 //多维度
//flavorDimensions "APP", "SERVER" //flavorDimensions "APP", "SERVER"
......
ext { ext {
kotlin_version = "1.3.21" kotlin_version = "1.3.21"
dev_mode = true dev_mode = false
ydl_app = [ ydl_app = [
appName : "心理咨询壹点灵", appName : "心理咨询壹点灵",
...@@ -43,12 +43,13 @@ ext { ...@@ -43,12 +43,13 @@ ext {
// -------------- 业务模块 -------------- // -------------- 业务模块 --------------
//第三步 若干 //第三步 若干
"m-confide" : "0.0.18", "m-confide" : "0.0.18",
"m-consultant" : "0.0.25", "m-consultant" : "0.0.26",
"m-course" : "0.0.13", "m-course" : "0.0.16",
"m-fm" : "0.0.14", "m-fm" : "0.0.14",
"m-muse" : "0.0.10", "m-muse" : "0.0.11",
"m-tests" : "0.0.7", "m-tests" : "0.0.9",
"m-user" : "0.0.28", "m-user" : "0.0.30",
//-------------- 业务模块 API 层 -------------- //-------------- 业务模块 API 层 --------------
"m-audioim-api" : "0.0.1", "m-audioim-api" : "0.0.1",
"m-confide-api" : "0.0.1", "m-confide-api" : "0.0.1",
...@@ -59,6 +60,7 @@ ext { ...@@ -59,6 +60,7 @@ ext {
"m-tests-api" : "0.0.1", "m-tests-api" : "0.0.1",
"m-user-api" : "0.0.7", "m-user-api" : "0.0.7",
//-------------- 功能组件 -------------- //-------------- 功能组件 --------------
//第一步 //第一步
"ydl-platform" : "0.0.24", "ydl-platform" : "0.0.24",
//第二步 若干 //第二步 若干
...@@ -67,6 +69,7 @@ ext { ...@@ -67,6 +69,7 @@ ext {
"ydl-pay" : "0.0.9", "ydl-pay" : "0.0.9",
"m-audioim" : "0.0.15", "m-audioim" : "0.0.15",
//以下 几乎不会动 //以下 几乎不会动
"router" : "0.0.1", "router" : "0.0.1",
"ydl-net" : "0.0.2", "ydl-net" : "0.0.2",
"ydl-utils" : "0.0.2", "ydl-utils" : "0.0.2",
...@@ -77,8 +80,8 @@ ext { ...@@ -77,8 +80,8 @@ ext {
// -------------- 业务模块 -------------- // -------------- 业务模块 --------------
//第三步 若干 //第三步 若干
"m-confide" : "0.0.15", "m-confide" : "0.0.15",
"m-consultant" : "0.0.22", "m-consultant" : "0.0.26",
"m-course" : "0.0.8", "m-course" : "0.0.16",
"m-fm" : "0.0.11", "m-fm" : "0.0.11",
"m-muse" : "0.0.7", "m-muse" : "0.0.7",
"m-tests" : "0.0.4", "m-tests" : "0.0.4",
...@@ -93,6 +96,7 @@ ext { ...@@ -93,6 +96,7 @@ ext {
"m-tests-api" : "0.0.1", "m-tests-api" : "0.0.1",
"m-user-api" : "0.0.7", "m-user-api" : "0.0.7",
//-------------- 功能组件 -------------- //-------------- 功能组件 --------------
//第一步 //第一步
"ydl-platform" : "0.0.24", "ydl-platform" : "0.0.24",
//第二步 若干 //第二步 若干
...@@ -101,6 +105,7 @@ ext { ...@@ -101,6 +105,7 @@ ext {
"ydl-pay" : "0.0.9", "ydl-pay" : "0.0.9",
"m-audioim" : "0.0.15", "m-audioim" : "0.0.15",
//以下 几乎不会动 //以下 几乎不会动
"router" : "0.0.1", "router" : "0.0.1",
"ydl-net" : "0.0.2", "ydl-net" : "0.0.2",
"ydl-utils" : "0.0.2", "ydl-utils" : "0.0.2",
...@@ -240,9 +245,8 @@ ext { ...@@ -240,9 +245,8 @@ ext {
"ydl-net" : "com.ydl:ydl-net:${ydlCompileVersion["ydl-net"]}", "ydl-net" : "com.ydl:ydl-net:${ydlCompileVersion["ydl-net"]}",
"ydl-utils" : "com.ydl:ydl-utils:${ydlCompileVersion["ydl-utils"]}", "ydl-utils" : "com.ydl:ydl-utils:${ydlCompileVersion["ydl-utils"]}",
//flutter功能组件升级===>发布ydl-flutter-base组件===>引用flutter相关的业务模块 //flutter功能组件升级===>发布ydl-flutter组件===>引用flutter相关的业务模块
"ydl-flutter" : "com.ydl:ydl-flutter:0.0.7@aar", "ydl-flutter" : "com.ydl:ydl-flutter:0.0.13@aar",
"ydl-flutter-base" : "com.ydl:ydl-flutter-base:${ydlCompileVersion["ydl-flutter-base"]}@aar",
//基础组件 <<--- 先发这个,发完改这里的版本号 //基础组件 <<--- 先发这个,发完改这里的版本号
"ydl-platform" : "com.ydl:ydl-platform:${ydlCompileVersion["ydl-platform"]}@aar", "ydl-platform" : "com.ydl:ydl-platform:${ydlCompileVersion["ydl-platform"]}@aar",
......
...@@ -4,6 +4,7 @@ import android.annotation.SuppressLint ...@@ -4,6 +4,7 @@ import android.annotation.SuppressLint
import android.text.TextUtils import android.text.TextUtils
import com.google.gson.Gson import com.google.gson.Gson
import com.ydl.ydlcommon.base.BaseApp import com.ydl.ydlcommon.base.BaseApp
import com.ydl.ydlcommon.base.lifecycle.IActivityLifecycleable
import com.ydl.ydlcommon.data.http.RxUtils import com.ydl.ydlcommon.data.http.RxUtils
import com.ydl.ydlcommon.data.http.ThrowableConsumer import com.ydl.ydlcommon.data.http.ThrowableConsumer
import com.ydl.ydlcommon.mvp.base.SimplePresenter import com.ydl.ydlcommon.mvp.base.SimplePresenter
...@@ -22,7 +23,6 @@ import io.reactivex.schedulers.Schedulers ...@@ -22,7 +23,6 @@ import io.reactivex.schedulers.Schedulers
/** /**
* 专家搜索页Presenter * 专家搜索页Presenter
* Created by zqk on 17-9-19.
*/ */
class ExpertSearchPresenter : SimplePresenter<IExpertSearchView>() { class ExpertSearchPresenter : SimplePresenter<IExpertSearchView>() {
...@@ -43,10 +43,12 @@ class ExpertSearchPresenter : SimplePresenter<IExpertSearchView>() { ...@@ -43,10 +43,12 @@ class ExpertSearchPresenter : SimplePresenter<IExpertSearchView>() {
} }
@SuppressLint("CheckResult")
fun fetchBannerList() { fun fetchBannerList() {
ExpertSearchDataManager.getHttp().getBannerList() ExpertSearchDataManager.getHttp().getBannerList()
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
.compose(RxLifecycleUtils.bindToLifecycle(mView!!)).compose(RxUtils.resultJavaData()) .compose(RxLifecycleUtils.bindToLifecycle(mView!!))
.compose(RxUtils.resultJavaData())
.map { it } .map { it }
.filter { it != null } .filter { it != null }
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
...@@ -121,6 +123,7 @@ class ExpertSearchPresenter : SimplePresenter<IExpertSearchView>() { ...@@ -121,6 +123,7 @@ class ExpertSearchPresenter : SimplePresenter<IExpertSearchView>() {
} }
} }
@SuppressLint("CheckResult")
fun fetchListData(allFilter: AllFilter, page: Int) { fun fetchListData(allFilter: AllFilter, page: Int) {
var showType = 0 var showType = 0
...@@ -164,7 +167,8 @@ class ExpertSearchPresenter : SimplePresenter<IExpertSearchView>() { ...@@ -164,7 +167,8 @@ class ExpertSearchPresenter : SimplePresenter<IExpertSearchView>() {
} }
sb.append("&page=").append(page) sb.append("&page=").append(page)
ExpertSearchDataManager.getHttp().searchDoctor(sb.toString()) ExpertSearchDataManager.getHttp().searchDoctor(sb.toString())
.compose(RxLifecycleUtils.bindToLifecycle(mView!!)).compose(RxUtils.resultJavaData()) .compose(RxLifecycleUtils.bindToLifecycle(mView!!))
.compose(RxUtils.resultJavaData())
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.subscribe(Consumer { .subscribe(Consumer {
......
...@@ -55,7 +55,7 @@ android { ...@@ -55,7 +55,7 @@ android {
} }
dependencies { dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar']) implementation fileTree(dir: 'libs', include: ['*.jar','*.aar'])
implementation 'com.android.support:appcompat-v7:28.0.0' implementation 'com.android.support:appcompat-v7:28.0.0'
testImplementation 'junit:junit:4.12' testImplementation 'junit:junit:4.12'
...@@ -73,7 +73,7 @@ dependencies { ...@@ -73,7 +73,7 @@ dependencies {
api project(":ydl-platform") api project(":ydl-platform")
api project(":ydl-media") api project(":ydl-media")
api project(":ydl-pay") api project(":ydl-pay")
api project(":ydl-flutter-base")
} else { } else {
//发布时使用 //发布时使用
compileOnly rootProject.ext.dependencies["ydl-m-user-api"] compileOnly rootProject.ext.dependencies["ydl-m-user-api"]
...@@ -82,11 +82,10 @@ dependencies { ...@@ -82,11 +82,10 @@ dependencies {
transitive = true transitive = true
} }
api rootProject.ext.dependencies["ydl-pay"] api rootProject.ext.dependencies["ydl-pay"]
api (rootProject.ext.dependencies["ydl-flutter-base"]){
transitive = true
}
api(rootProject.ext.dependencies["ydl-platform"]) { api(rootProject.ext.dependencies["ydl-platform"]) {
transitive = true transitive = true
} }
} }
api rootProject.ext.dependencies["ydl-flutter"]
} }
package com.yidianling.course; package com.yidianling.course;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import com.alibaba.android.arouter.facade.annotation.Route; import com.alibaba.android.arouter.facade.annotation.Route;
import com.ydl.ydlcommon.base.BaseActivity; import com.ydl.ydlcommon.base.BaseActivity;
...@@ -11,7 +10,6 @@ import com.ydl.ydlcommon.base.BaseActivity; ...@@ -11,7 +10,6 @@ import com.ydl.ydlcommon.base.BaseActivity;
@Route(path = "/course/home") @Route(path = "/course/home")
public class CourseActivity extends BaseActivity { public class CourseActivity extends BaseActivity {
@Override @Override
protected int layoutResId() { protected int layoutResId() {
return R.layout.activity_course; return R.layout.activity_course;
......
...@@ -2,11 +2,13 @@ package com.yidianling.course ...@@ -2,11 +2,13 @@ package com.yidianling.course
import CoursePlugin import CoursePlugin
import android.annotation.SuppressLint import android.annotation.SuppressLint
import android.os.Bundle
import android.os.Handler import android.os.Handler
import android.text.TextUtils import android.text.TextUtils
import android.view.View
import com.alibaba.android.arouter.launcher.ARouter import com.alibaba.android.arouter.launcher.ARouter
import com.example.fm_plugin.base.BaseFlutterFragment
import com.google.gson.Gson import com.google.gson.Gson
import com.ydl.ydl_flutter.flutter.base.BaseFlutterFragment
import com.ydl.ydl_router.manager.YDLRouterManager import com.ydl.ydl_router.manager.YDLRouterManager
import com.ydl.ydlcommon.data.http.BaseResponse import com.ydl.ydlcommon.data.http.BaseResponse
import com.ydl.ydlcommon.data.http.RxUtils import com.ydl.ydlcommon.data.http.RxUtils
...@@ -40,10 +42,12 @@ class FlutterCourseHomeFragment : BaseFlutterFragment() { ...@@ -40,10 +42,12 @@ class FlutterCourseHomeFragment : BaseFlutterFragment() {
private var hasRequestCoupon = false private var hasRequestCoupon = false
private var dialog: CourseCouponDialog? = null private var dialog: CourseCouponDialog? = null
override fun initChannelPlugin(flutterView: FlutterView) { override fun initChannelPlugin(flutterView: FlutterView) {
CoursePlugin.register(this, flutterView) CoursePlugin.register(this, flutterView)
CourseSendPlugin.initContext(this, flutterView) CourseSendPlugin.initContext(this, flutterView)
} }
override fun initialRoute(): String { override fun initialRoute(): String {
......
...@@ -3,6 +3,7 @@ import android.content.Intent ...@@ -3,6 +3,7 @@ import android.content.Intent
import android.net.Uri import android.net.Uri
import android.os.Handler import android.os.Handler
import android.text.TextUtils import android.text.TextUtils
import com.example.fm_plugin.base.BaseFlutterFragment
import com.lzf.easyfloat.permission.PermissionUtils import com.lzf.easyfloat.permission.PermissionUtils
import com.ydl.media.audio.AudioPlayer import com.ydl.media.audio.AudioPlayer
import com.ydl.media.audio.model.Music import com.ydl.media.audio.model.Music
...@@ -11,7 +12,6 @@ import com.ydl.media.view.PlayerFloatHelper ...@@ -11,7 +12,6 @@ import com.ydl.media.view.PlayerFloatHelper
import com.ydl.media.view.PlayerFloatView import com.ydl.media.view.PlayerFloatView
import com.ydl.webview.H5Params import com.ydl.webview.H5Params
import com.ydl.webview.NewH5Activity import com.ydl.webview.NewH5Activity
import com.ydl.ydl_flutter.flutter.base.BaseFlutterFragment
import com.ydl.ydl_router.manager.YDLRouterManager import com.ydl.ydl_router.manager.YDLRouterManager
import com.ydl.ydlcommon.base.BaseApp import com.ydl.ydlcommon.base.BaseApp
import com.ydl.ydlcommon.data.PlatformDataManager import com.ydl.ydlcommon.data.PlatformDataManager
......
package com.yidianling.course.flutterPlugin package com.yidianling.course.flutterPlugin
import com.ydl.ydl_flutter.flutter.io.flutter.facade.FlutterFragment import android.util.Log
import com.example.fm_plugin.base.FlutterFragment
import io.flutter.plugin.common.EventChannel import io.flutter.plugin.common.EventChannel
import io.flutter.view.FlutterView import io.flutter.view.FlutterView
...@@ -45,4 +46,5 @@ object CourseSendPlugin { ...@@ -45,4 +46,5 @@ object CourseSendPlugin {
fun sendLoginSuccess(){ fun sendLoginSuccess(){
eventSink!!.success("loginSuccess") eventSink!!.success("loginSuccess")
} }
} }
\ No newline at end of file
...@@ -66,15 +66,13 @@ dependencies { ...@@ -66,15 +66,13 @@ dependencies {
//开发时使用 //开发时使用
api project(":ydl-platform") api project(":ydl-platform")
implementation project(':ydl-media') implementation project(':ydl-media')
api project(":ydl-flutter-base")
} else { } else {
//发布时使用 //发布时使用
api rootProject.ext.dependencies["ydl-media"] api rootProject.ext.dependencies["ydl-media"]
api (rootProject.ext.dependencies["ydl-flutter-base"]){
transitive = true
}
api (rootProject.ext.dependencies["ydl-platform"]) { api (rootProject.ext.dependencies["ydl-platform"]) {
transitive = true transitive = true
} }
} }
api rootProject.ext.dependencies["ydl-flutter"]
} }
package com.yidianling.muse.activity package com.yidianling.muse.activity
import com.alibaba.android.arouter.facade.annotation.Route import com.alibaba.android.arouter.facade.annotation.Route
import com.example.fm_plugin.base.BaseFlutterActivity
import com.ydl.media.audio.AudioPlayer import com.ydl.media.audio.AudioPlayer
import com.ydl.ydl_flutter.flutter.base.BaseFlutterActivity
import com.ydl.ydlcommon.router.IYDLRouterConstant import com.ydl.ydlcommon.router.IYDLRouterConstant
import com.yidianling.muse.handler.MusePlugin import com.yidianling.muse.handler.MusePlugin
import org.json.JSONObject import org.json.JSONObject
......
...@@ -132,7 +132,7 @@ class TestSearchActivity : BaseMvpActivity<TestSearchView, TestSearchPresenter>( ...@@ -132,7 +132,7 @@ class TestSearchActivity : BaseMvpActivity<TestSearchView, TestSearchPresenter>(
} }
rv_hot_list.addOnScrollListener(object : RecyclerView.OnScrollListener() { rv_hot_list.addOnScrollListener(object : RecyclerView.OnScrollListener() {
override fun onScrolled(recyclerView: RecyclerView?, dx: Int, dy: Int) { override fun onScrolled(recyclerView: RecyclerView?, dx: Int, dy: Int) {
if (!isFirstLoad) { if (!isFirstLoad && dx!=0 && dx!=0) {
hideSoftInput() hideSoftInput()
} }
} }
......
...@@ -32,7 +32,7 @@ object LoginUtils { ...@@ -32,7 +32,7 @@ object LoginUtils {
//设置异常用户ID //设置异常用户ID
CrashReport.setUserId(userInfo?.uid) CrashReport.setUserId(userInfo?.uid)
//登录IM聊天 //登录IM聊天
// loginIm(userInfo) loginIm(userInfo)
//设置极光注册id //设置极光注册id
LoginHelper.setChannelId() LoginHelper.setChannelId()
val loginEvent = UserLoginEvent("login", userInfo?.uid!!) val loginEvent = UserLoginEvent("login", userInfo?.uid!!)
......
...@@ -61,11 +61,7 @@ object UserHelper { ...@@ -61,11 +61,7 @@ object UserHelper {
fun getUserInfoStr(): String? { fun getUserInfoStr(): String? {
if (userTemp != null) return gson.toJson(userTemp) if (userTemp != null) return gson.toJson(userTemp)
try { return SharedPreferencesEditor.getFileString(user_info_name_sp, user_info_key_sp)
return SharedPreferencesEditor.getFileString(user_info_name_sp, user_info_key_sp)
} catch (e: Exception) {
return ""
}
} }
fun updateUserinfo(userInfo: UserResponseBean.UserInfo?) { fun updateUserinfo(userInfo: UserResponseBean.UserInfo?) {
...@@ -135,10 +131,6 @@ object UserHelper { ...@@ -135,10 +131,6 @@ object UserHelper {
fun getUserSettingStr(): String? { fun getUserSettingStr(): String? {
if (userSetting != null) return gson.toJson(userSetting) if (userSetting != null) return gson.toJson(userSetting)
try { return SharedPreferencesEditor.getFileString(user_setting_name_sp, user_setting_key_sp)
return SharedPreferencesEditor.getFileString(user_setting_name_sp, user_setting_key_sp)
} catch (e: Exception) {
return ""
}
} }
} }
\ No newline at end of file
include ':app', ':ydl-flutter-base',":router", ':ydl-net', ':ydl-utils', ':ydl-platform', ':ydl-webview', include ':app',":router", ':ydl-net', ':ydl-utils', ':ydl-platform', ':ydl-webview',
':m-confide', ':m-audioim',':ydl-media',":m-user", ':m-consultant', ':m-muse', ':m-confide', ':m-audioim',':ydl-media',":m-user", ':m-consultant', ':m-muse',
':m-fm', ':m-tests',":m-course", ':ydl-pay' ':m-fm', ':m-tests',":m-course", ':ydl-pay'
......
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply from: "../maven_push.gradle"
android {
compileSdkVersion 28
defaultConfig {
minSdkVersion 17
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
consumerProguardFiles 'consumer-rules.pro'
flavorDimensions "versionCode"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:28.0.0'
api rootProject.ext.dependencies["ydl-flutter"]
}
IS_PUBLISH=true
VERSION_NAME=0.0.3
\ No newline at end of file
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.ydl.ydl_flutter" />
package com.ydl.ydl_flutter.flutter.base
import android.content.Context
import android.content.Intent
import android.graphics.PixelFormat
import android.os.Bundle
import android.util.AttributeSet
import android.view.WindowManager
import io.flutter.app.FlutterActivity
import io.flutter.plugins.GeneratedPluginRegistrant
import io.flutter.view.FlutterView
import org.json.JSONObject
/**
* flutter 页面基类
* Created by xj on 2019/9/30.
*/
abstract class BaseFlutterActivity : FlutterActivity() {
companion object {
const val ROUTE_PAGE = "route" //路由
/**
* 路由传递过来的参数
*/
const val ROUTER_PARAMS = "routerParam"
}
override fun createFlutterView(context: Context?): FlutterView {
val matchParent = WindowManager.LayoutParams(-1, -1)
val nativeView = this.createFlutterNativeView()
val flutterView = FlutterView(this, null as AttributeSet?, nativeView)
flutterView.layoutParams = matchParent
this.setContentView(flutterView)
//这个action必加,不然无法在flutter端获取route参数值
intent.action = Intent.ACTION_RUN
/**
* 在这边初始化route
*/
intent.putExtra(ROUTE_PAGE, initialRoute())
//渲染优化(优化一丢丢几乎看不出来)
flutterView.setZOrderOnTop(true)
flutterView.holder.setFormat(PixelFormat.TRANSLUCENT)
return flutterView
}
public override fun onCreate( savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
GeneratedPluginRegistrant.registerWith(this)
/**
* 获取统一路由传递过来的参数并初始化交互通道
*/
val json = intent.getStringExtra(ROUTER_PARAMS)
initChannelPlugin(JSONObject(json))
}
/**
* 路由,例 "/native/muse/home"
*/
abstract fun initialRoute(): String
/**
* 初始化flutter channel插件
*/
abstract fun initChannelPlugin(jsonObject: JSONObject)
}
\ No newline at end of file
package com.ydl.ydl_flutter.flutter.base
import android.os.Bundle
import android.view.LayoutInflater
import android.view.ViewGroup
import com.ydl.ydl_flutter.flutter.io.flutter.facade.Flutter
import com.ydl.ydl_flutter.flutter.io.flutter.facade.FlutterFragment
import io.flutter.view.FlutterView
/**
* flutter fragment 基类
* Created by xj on 2019/9/30.
*/
abstract class BaseFlutterFragment : FlutterFragment() {
private var mFlutterView: FlutterView? = null
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): FlutterView {
mFlutterView= Flutter.createView(
activity!!,
lifecycle,
initialRoute())
initChannelPlugin(mFlutterView!!)
return mFlutterView!!
}
/**
* 路由,例 "quick_reply"
*/
abstract fun initialRoute(): String
/**
* 初始化flutter channel插件
*/
abstract fun initChannelPlugin(flutterView: FlutterView)
}
package com.ydl.ydl_flutter.flutter.io.flutter.facade;
import android.app.Activity;
import android.arch.lifecycle.Lifecycle;
import android.arch.lifecycle.LifecycleObserver;
import android.arch.lifecycle.OnLifecycleEvent;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.NonNull;
import io.flutter.plugin.common.BasicMessageChannel;
import io.flutter.plugin.common.StringCodec;
import io.flutter.plugins.GeneratedPluginRegistrant;
import io.flutter.view.FlutterMain;
import io.flutter.view.FlutterNativeView;
import io.flutter.view.FlutterRunArguments;
import io.flutter.view.FlutterView;
/**
* Main entry point for using Flutter in Android applications.
*
* <p><strong>Warning:</strong> This file is auto-generated by Flutter tooling.
* DO NOT EDIT.</p>
*/
public final class Flutter {
private Flutter() {
// to prevent instantiation
}
/**
* Initiates the Dart VM. Calling this method at an early point may help decreasing time to first
* frame for a subsequently created {@link FlutterView}.
*
* @param applicationContext the application's {@link Context}
*/
public static void startInitialization(@NonNull Context applicationContext) {
FlutterMain.startInitialization(applicationContext);
}
/**
* Creates a {@link FlutterFragment} managing a {@link FlutterView}. The optional
* initial route string will be made available to the Dart code
* (via {@code window.defaultRouteName}) and may be used to determine which widget
* should be displayed in the view. The default initialRoute is "/".
*
* @param initialRoute an initial route {@link String}, or null
* @return a {@link FlutterFragment}
*/
@NonNull
public static FlutterFragment createFragment(String initialRoute) {
final FlutterFragment fragment = new FlutterFragment();
final Bundle args = new Bundle();
args.putString(FlutterFragment.ARG_ROUTE, initialRoute);
fragment.setArguments(args);
return fragment;
}
/**
* Creates a {@link FlutterView} linked to the specified {@link Activity} and {@link Lifecycle}.
* The optional initial route string will be made available to the Dart code (via
* {@code window.defaultRouteName}) and may be used to determine which widget should be displayed
* in the view. The default initialRoute is "/".
*
* @param activity an {@link Activity}
* @param lifecycle a {@link Lifecycle}
* @param initialRoute an initial route {@link String}, or null
* @return a {@link FlutterView}
*/
@NonNull
public static FlutterView createView(@NonNull final Activity activity, @NonNull final Lifecycle lifecycle, final String initialRoute) {
FlutterMain.startInitialization(activity.getApplicationContext());
FlutterMain.ensureInitializationComplete(activity.getApplicationContext(), null);
final FlutterNativeView nativeView = new FlutterNativeView(activity);
final FlutterView flutterView = new FlutterView(activity, null, nativeView) {
private final BasicMessageChannel<String> lifecycleMessages = new BasicMessageChannel<>(this, "flutter/lifecycle", StringCodec.INSTANCE);
@Override
public void onFirstFrame() {
super.onFirstFrame();
setAlpha(1.0f);
}
@Override
public void onPostResume() {
// Overriding default behavior to avoid dictating system UI via PlatformPlugin.
lifecycleMessages.send("AppLifecycleState.resumed");
}
};
if (initialRoute != null) {
flutterView.setInitialRoute(initialRoute);
}
lifecycle.addObserver(new LifecycleObserver() {
@OnLifecycleEvent(Lifecycle.Event.ON_CREATE)
public void onCreate() {
final FlutterRunArguments arguments = new FlutterRunArguments();
arguments.bundlePath = FlutterMain.findAppBundlePath(activity.getApplicationContext());
arguments.entrypoint = "main";
flutterView.runFromBundle(arguments);
GeneratedPluginRegistrant.registerWith(flutterView.getPluginRegistry());
}
@OnLifecycleEvent(Lifecycle.Event.ON_START)
public void onStart() {
flutterView.onStart();
}
@OnLifecycleEvent(Lifecycle.Event.ON_RESUME)
public void onResume() {
flutterView.onPostResume();
}
@OnLifecycleEvent(Lifecycle.Event.ON_PAUSE)
public void onPause() {
flutterView.onPause();
}
@OnLifecycleEvent(Lifecycle.Event.ON_STOP)
public void onStop() {
flutterView.onStop();
}
@OnLifecycleEvent(Lifecycle.Event.ON_DESTROY)
public void onDestroy() {
flutterView.destroy();
}
});
flutterView.setAlpha(0.0f);
return flutterView;
}
}
package com.ydl.ydl_flutter.flutter.io.flutter.facade;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.Fragment;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.ViewGroup;
import io.flutter.view.FlutterView;
/**
* A {@link Fragment} managing a {@link FlutterView}.
*
* <p><strong>Warning:</strong> This file is auto-generated by Flutter tooling.
* DO NOT EDIT.</p>
*/
public class FlutterFragment extends Fragment {
public static final String ARG_ROUTE = "route";
private String mRoute = "/";
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (getArguments() != null) {
mRoute = getArguments().getString(ARG_ROUTE);
}
}
@Override
public void onInflate(Context context, AttributeSet attrs, Bundle savedInstanceState) {
super.onInflate(context, attrs, savedInstanceState);
}
@Override
public FlutterView onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
return Flutter.createView(getActivity(), getLifecycle(), mRoute);
}
}
<resources>
<string name="app_name">ydl_flutter</string>
</resources>
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