Commit 47a5c09d by 徐健

增加冥想模块

parent 878ea97f
/*___Generated_by_IDEA___*/
package com.ydl.component;
/* This stub is only used by the IDE. It is NOT the BuildConfig class actually packed into the APK */
public final class BuildConfig {
public final static boolean DEBUG = Boolean.parseBoolean(null);
}
\ No newline at end of file
/*___Generated_by_IDEA___*/
package com.ydl.component;
/* This stub is only used by the IDE. It is NOT the Manifest class actually packed into the APK */
public final class Manifest {
}
\ No newline at end of file
/*___Generated_by_IDEA___*/
package com.ydl.component;
/* This stub is only used by the IDE. It is NOT the R class actually packed into the APK */
public final class R {
}
\ No newline at end of file
/*___Generated_by_IDEA___*/
package com.yidianling.consultant;
/* This stub is only used by the IDE. It is NOT the BuildConfig class actually packed into the APK */
public final class BuildConfig {
public final static boolean DEBUG = Boolean.parseBoolean(null);
}
\ No newline at end of file
/*___Generated_by_IDEA___*/
package com.yidianling.consultant;
/* This stub is only used by the IDE. It is NOT the Manifest class actually packed into the APK */
public final class Manifest {
}
\ No newline at end of file
/*___Generated_by_IDEA___*/
package com.yidianling.consultant;
/* This stub is only used by the IDE. It is NOT the R class actually packed into the APK */
public final class R {
}
\ No newline at end of file
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
apply plugin: 'kotlin-android-extensions'
kapt {
arguments {
arg("AROUTER_MODULE_NAME", project.getName())
}
}
android {
compileSdkVersion rootProject.ext.compileSdkVersion
defaultConfig {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
flavorDimensions "versionCode"
javaCompileOptions {
annotationProcessorOptions {
arguments = [AROUTER_MODULE_NAME: project.getName(), AROUTER_GENERATE_DOC: "enable"]
}
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility 1.8
targetCompatibility 1.8
}
}
dependencies {
api fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
if (rootProject.ext.dev_mode){
//开发时使用
api project(":ydl-platform")
} else {
//发布时使用
api(rootProject.ext.dependencies["ydl-platform"]) {
transitive = true
}
}
}
modular {
//模块包名
packageName "com.yidianling.muse"
// 模块发布需要的参数
publish {
modules {
xlzx {
groupId = "com.ydl"
artifactId = "m-muse-module-xlzx"
// 上报的 心理咨询 业务模块 aar 包的版本号
version = "0.0.1"
}
ydl{
groupId = "com.ydl"
artifactId = "m-muse-module-ydl"
// 上报的 壹点灵 业务模块 aar 包的版本号
version = "0.0.1"
}
}
api {
// 壹点灵/心理咨询 业务模块 API层 jar包的发布信息
groupId = "com.ydl"
artifactId = "m-muse-api"
//开发时注释掉版本号,发布api时打开
//version = "0.0.1"
// API 层打包时需要引入的依赖
apiDependencies {
implementation "com.google.code.gson:gson:2.8.2"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.alibaba:arouter-api:1.4.1'
}
}
}
}
\ 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
package com.ydl.ydl_muse;
import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() throws Exception {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();
assertEquals("com.ydl.ydl_muse.test", appContext.getPackageName());
}
}
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.yidianling.muse">
<application>
<activity
android:name=".activity.MuseActivity"
android:screenOrientation="portrait"/>
</application>
</manifest>
package com.yidianling.muse.activity
import com.alibaba.android.arouter.facade.annotation.Route
import com.ydl.media.audio.AudioPlayer
import com.ydl.ydlcommon.base.flutter.base.BaseFlutterActivity
import com.ydl.ydlcommon.router.IYDLRouterConstant
import com.yidianling.muse.handler.MusePlugin
import com.yidianling.ydlcommon.flutter.base.BaseFlutterActivity
import org.json.JSONObject
/**
* Created by xj on 2019/9/6.
*/
@Route(path = "/module/muse")
class MuseActivity : BaseFlutterActivity() {
override fun initialRoute(): String {
return "native/muse/home"
}
override fun initChannelPlugin(jsonObject: JSONObject) {
MusePlugin.rigister(this, jsonObject.getString(IYDLRouterConstant.MUSIC_URL), jsonObject.getString(IYDLRouterConstant.DATA_JSON))
/**
* 如果正在播放音乐,则停止播放所有音乐
*/
if (AudioPlayer.get().isPlaying) {
AudioPlayer.get().playMode/**playingType*/ = YDLMusicHelper.PLAY_TYPE_MUSE
YDLMusicHelper.stop()
}
}
override fun onDestroy() {
super.onDestroy()
/**
* 退出冥想模块的时候,关闭音乐播放
*/
YDLMusicHelper.stop()
}
}
package com.yidianling.muse.handler
import android.graphics.drawable.Drawable
import com.google.gson.Gson
import com.ydl.ydlcommon.utils.YDLCacheUtils
import com.ydl.ydlcommon.view.dialog.YDLShareDialog
import com.yidianling.common.tools.ToastUtil
import com.yidianling.muse.api.bean.MuseModuleBean
import io.flutter.app.FlutterActivity
import io.flutter.plugin.common.MethodCall
import io.flutter.plugin.common.MethodChannel
/**
* Created by xj on 2019/9/6.
*/
class MusePlugin : MethodChannel.MethodCallHandler {
companion object {
const val CHANNEL: String = "lib/fm_module/channel"
const val ACTION_GET_APPINFO_INITIAL_DATA = "action_get_initial_app_info_data" //获取主包信息的数据
const val ACTION_GET_MUSIC_INITIAL_DATA = "action_get_initial_music_data" //获取音乐原生的数据
const val ACTION_PLAY_MUSIC = "action_play_music" //播放音乐
const val ACTION_PAUSE_MUSIC = "action_pause_music" //暂停音乐
const val ACTION_STOP_MUSIC = "action_stop_music" //暂停(销毁)音乐
const val ACTION_SET_DEFAULT_TIME = "action_set_default_time" //时间控制页面设置时间
const val ACTION_POP_PAGE = "action_pop_page" //pop当前页面
const val ACTION_SHARE_WX = "action_share_wx" //分享至微信
const val ACTION_SET_BGIMG = "action_set_bgImg"; //设置背景图片
var currentMusicUrl: String = "" //当前正在播放的冥想url
var data: MuseModuleBean? = null //冥想数据
fun rigister(activity: FlutterActivity, currentUrl: String?, dataJson: String) {
currentUrl?.let {
currentMusicUrl = currentUrl
}
data = Gson().fromJson(dataJson, MuseModuleBean::class.java)
MethodChannel(activity.flutterView, CHANNEL).setMethodCallHandler(MusePlugin(activity))
}
}
private var mActivity: FlutterActivity? = null
private constructor(activity: FlutterActivity) {
mActivity = activity
}
override fun onMethodCall(methodCall: MethodCall, result: MethodChannel.Result) {
methodCall?.let {
when (methodCall.method) {
// flutter获取原生的音乐数据
ACTION_GET_MUSIC_INITIAL_DATA -> {
val mMap = mutableMapOf<String, Any>()
mMap["defaultTime"] = getDefaultTime()
mMap["currentMusicUrl"] = currentMusicUrl
mMap["dataJson"] = Gson().toJson(data)
result?.success(mMap)
}
// 播放音乐
ACTION_PLAY_MUSIC -> {
var musicUrl: String? = methodCall.argument<String>("url")
var mContinue: Boolean = methodCall.argument<Boolean>("mContinue")!!
if (mContinue) {
YDLMusicHelper.seekTo(YDLMusicHelper.time)
}else {
YDLMusicHelper.musePlay(musicUrl ?: currentMusicUrl)
}
}
// 暂停音乐
ACTION_PAUSE_MUSIC -> {
YDLMusicHelper.pause()
}
// 暂停(销毁)音乐
ACTION_STOP_MUSIC -> {
YDLMusicHelper.stop()
}
// 设置默认时间
ACTION_SET_DEFAULT_TIME -> {
YDLCacheUtils.saveMuseDefaultTime(methodCall.argument<Int>("time").toString())
}
// 退出flutteractivity
ACTION_POP_PAGE -> {
mActivity?.finish()
}
// 分享
ACTION_SHARE_WX -> {
share(methodCall)
}
//设置背景图片
ACTION_SET_BGIMG -> {
var mDrawable: Drawable?
when (methodCall.arguments) {
"sleeps_icon_default" -> {
mDrawable = mActivity?.resources?.getDrawable(R.drawable.muse_sleeps_icon_default)
}
"sleeps_icon_playing" -> {
mDrawable = mActivity?.resources?.getDrawable(R.drawable.muse_sleeps_icon_playing)
}
"muse_icon_default" -> {
mDrawable = mActivity?.resources?.getDrawable(R.drawable.muse_muse_icon_default)
}
"muse_icon_playing" -> {
mDrawable = mActivity?.resources?.getDrawable(R.drawable.muse_muse_icon_playing)
}
else -> {
mDrawable = mActivity?.resources?.getDrawable(R.drawable.muse_sleeps_icon_default)
}
}
mDrawable?.let {
mActivity?.window?.setBackgroundDrawable(mDrawable)
}
}
else -> {
}
}
}
}
/**
* 分享,跟FM一致
*/
private fun share(methodCall: MethodCall?) {
var shareUrl = methodCall?.argument<String>("shareUrl")?:""
var title = methodCall?.argument<String>("title")?:""
var path = methodCall?.argument<String>("path")?:""
var appId = methodCall?.argument<String>("appId")?:""
if (shareUrl.isEmpty()) {
ToastUtil.toastShort("分享数据获取失败")
}else {
val dialog = YDLShareDialog.style7(mActivity!!, title, shareUrl, null, "https://img.yidianling.com/file/2019/06/10/fm0vovijx0p2br9s.png", path, appId)
dialog.setCallBack(object : YDLShareDialog.ICallBack {
override fun callBack(type: Int) {
}
})
dialog.show(mActivity!!.fragmentManager, "lose")
}
}
/**
* 获取默认时间
*/
private fun getDefaultTime(): Int {
var time = YDLCacheUtils.getMuseDefaultTime()
return try {
time.toInt()
} catch (e: Exception) {
600
}
}
}
\ No newline at end of file
package com.yidianling.muse.api.bean
/**
* Created by xj on 2019/10/31.
*/
open class HomeItemBaseBean(var isRealEmpty: Boolean)
\ No newline at end of file
package com.yidianling.muse.api.bean
/**
* 冥想模块所有数据
* Created by xj on 2019/9/16.
*/
class MuseModuleBean : HomeItemBaseBean {
constructor():super(false)
constructor(isRealEmpty:Boolean):super(isRealEmpty)
/**
* 冥想数据
*/
var muses: ArrayList<MuseDetailBean>? = null
/**
* 助眠数据
*/
var sleeps: ArrayList<SleepsDetailBean>? = null
data class MuseDetailBean(
val id: Int,
val audioUrl: String,
val backgroundUrl: String,
val category: Int,
val createTime: String,
val effectCode: String,
val isDelete: String,
val name: String,
val playCount: Int,
val sort: Int,
val updateTime: String,
val shareUrl: String,
val appId: String,
val path: String)
data class SleepsDetailBean(
val id: Int,
val audioUrl: String,
val backgroundUrl: String,
val category: Int,
val createTime: String,
val effectCode: String,
val isDelete: String,
val name: String,
val playCount: Int,
val sort: Int,
val updateTime: String,
val shareUrl: String,
val appId: String,
val path: String)
}
\ No newline at end of file
<resources>
<string name="app_name">ydl-muse</string>
</resources>
package com.ydl.ydl_muse;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* Example local unit test, which will execute on the development machine (host).
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() throws Exception {
assertEquals(4, 2 + 2);
}
}
\ No newline at end of file
/*___Generated_by_IDEA___*/
package com.yidianling.user;
/* This stub is only used by the IDE. It is NOT the BuildConfig class actually packed into the APK */
public final class BuildConfig {
public final static boolean DEBUG = Boolean.parseBoolean(null);
}
\ No newline at end of file
/*___Generated_by_IDEA___*/
package com.yidianling.user;
/* This stub is only used by the IDE. It is NOT the Manifest class actually packed into the APK */
public final class Manifest {
}
\ No newline at end of file
/*___Generated_by_IDEA___*/
package com.yidianling.user;
/* This stub is only used by the IDE. It is NOT the R class actually packed into the APK */
public final class R {
}
\ No newline at end of file
......@@ -8,6 +8,7 @@ import com.umeng.socialize.UMShareAPI
import com.ydl.ydlcommon.base.delegate.IAppLifecycles
import com.ydl.ydlcommon.modular.ModularServiceManager
import com.yidianling.user.api.event.UserSetEvent
import com.yidianling.user.api.service.IUserService
import com.yidianling.user.modular_service.UserServiceImp
import de.greenrobot.event.EventBus
......@@ -32,11 +33,11 @@ class UserAppLifecycles : IAppLifecycles {
open fun onEvent(event:UserSetEvent){
if (event.userResponse!=null){
ModularServiceManager.provide(UserServiceImp::class.java).setUserResponse(event.userResponse)
ModularServiceManager.provide(IUserService::class.java).setUserResponse(event.userResponse)
} else if (event.userInfo!=null){
ModularServiceManager.provide(UserServiceImp::class.java).updateUserInfoSp(event.userInfo)
ModularServiceManager.provide(IUserService::class.java).updateUserInfoSp(event.userInfo)
}else if (event.userSetting!=null){
ModularServiceManager.provide(UserServiceImp::class.java).updateUserSetingSp(event.userSetting)
ModularServiceManager.provide(IUserService::class.java).updateUserSetingSp(event.userSetting)
}
}
......
/*___Generated_by_IDEA___*/
package com.yidianling.router;
/* This stub is only used by the IDE. It is NOT the BuildConfig class actually packed into the APK */
public final class BuildConfig {
public final static boolean DEBUG = Boolean.parseBoolean(null);
}
\ No newline at end of file
/*___Generated_by_IDEA___*/
package com.yidianling.router;
/* This stub is only used by the IDE. It is NOT the Manifest class actually packed into the APK */
public final class Manifest {
}
\ No newline at end of file
/*___Generated_by_IDEA___*/
package com.yidianling.router;
/* This stub is only used by the IDE. It is NOT the R class actually packed into the APK */
public final class R {
}
\ No newline at end of file
include ':app',":router", ':ydl-net', ':ydl-utils', ':ydl-platform', ':ydl-webview', ':ydl-media',":m-user", ':m-consultant'
include ':app',":router", ':ydl-net', ':ydl-utils', ':ydl-platform', ':ydl-webview', ':ydl-media',":m-user", ':m-consultant', ':m-muse'
//, ':m-tests'
\ No newline at end of file
/*___Generated_by_IDEA___*/
package com.ydl.media;
/* This stub is only used by the IDE. It is NOT the BuildConfig class actually packed into the APK */
public final class BuildConfig {
public final static boolean DEBUG = Boolean.parseBoolean(null);
}
\ No newline at end of file
/*___Generated_by_IDEA___*/
package com.ydl.media;
/* This stub is only used by the IDE. It is NOT the Manifest class actually packed into the APK */
public final class Manifest {
}
\ No newline at end of file
/*___Generated_by_IDEA___*/
package com.ydl.media;
/* This stub is only used by the IDE. It is NOT the R class actually packed into the APK */
public final class R {
}
\ No newline at end of file
/*___Generated_by_IDEA___*/
package com.ydl.ydlnet;
/* This stub is only used by the IDE. It is NOT the BuildConfig class actually packed into the APK */
public final class BuildConfig {
public final static boolean DEBUG = Boolean.parseBoolean(null);
}
\ No newline at end of file
/*___Generated_by_IDEA___*/
package com.ydl.ydlnet;
/* This stub is only used by the IDE. It is NOT the Manifest class actually packed into the APK */
public final class Manifest {
}
\ No newline at end of file
/*___Generated_by_IDEA___*/
package com.ydl.ydlnet;
/* This stub is only used by the IDE. It is NOT the R class actually packed into the APK */
public final class R {
}
\ No newline at end of file
/*___Generated_by_IDEA___*/
package com.ydl.ydlcommon;
/* This stub is only used by the IDE. It is NOT the BuildConfig class actually packed into the APK */
public final class BuildConfig {
public final static boolean DEBUG = Boolean.parseBoolean(null);
}
\ No newline at end of file
/*___Generated_by_IDEA___*/
package com.ydl.ydlcommon;
/* This stub is only used by the IDE. It is NOT the Manifest class actually packed into the APK */
public final class Manifest {
}
\ No newline at end of file
/*___Generated_by_IDEA___*/
package com.ydl.ydlcommon;
/* This stub is only used by the IDE. It is NOT the R class actually packed into the APK */
public final class R {
}
\ No newline at end of file
package com.ydl.ydlcommon.base.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.ydlcommon.base.flutter.base
import io.flutter.app.FlutterActivity
import io.flutter.plugin.common.MethodCall
import io.flutter.plugin.common.MethodChannel
/**
* 公共通道插件类
* Created by xj on 2019/9/30.
*/
class BaseFlutterChannelPlugin: MethodChannel.MethodCallHandler {
companion object {
const val CHANNEL: String = "lib/common/channel"
const val ACTION_GET_APPINFO_INITIAL_DATA = "action_get_initial_app_info_data" //获取主包信息的数据
fun rigister(activity: FlutterActivity) {
MethodChannel(activity.flutterView, CHANNEL).setMethodCallHandler(BaseFlutterChannelPlugin(activity))
}
}
private var mActivity: FlutterActivity? = null
private constructor(activity: FlutterActivity) {
mActivity = activity
}
override fun onMethodCall(methodCall: MethodCall, result: MethodChannel.Result) {
methodCall?.let {
when (methodCall.method) {
// 获取主包信息的数据
//todo xujian
// ACTION_GET_APPINFO_INITIAL_DATA -> {
// val mRequestMap = mutableMapOf(
// "isDevelopment" to (BuildConfig.FLUTTER_API != "prod"),
// "uid" to ,
// "accessToken" to LoginHelper.getInstance().user.accessToken,
// "version" to RxAppTool.getAppVersionName(mActivity?.applicationContext),
// "isFromApp" to "1",
// "osBuild" to RxDeviceTool.getBuildBrandModel() + "," + RxDeviceTool.getSDKVersionName() + "," + RxAppTool.getAppVersionName(mActivity?.applicationContext)
// )
// }
}
}
}
}
\ No newline at end of file
package com.ydl.ydlcommon.base.flutter.base
import android.os.Bundle
import android.view.LayoutInflater
import android.view.ViewGroup
import com.ydl.ydlcommon.base.flutter.io.flutter.facade.Flutter
import io.flutter.embedding.android.FlutterFragment
import io.flutter.view.FlutterView
/**
* flutter fragment 基类
* Created by xj on 2019/9/30.
*/
abstract class BaseFlutterFragment : FlutterFragment() {
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): FlutterView {
return Flutter.createView(
activity!!,
lifecycle,
initialRoute())
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
initChannelPlugin()
}
/**
* 路由,例 "quick_reply"
*/
abstract fun initialRoute(): String
/**
* 初始化flutter channel插件
*/
abstract fun initChannelPlugin()
}
package com.ydl.ydlcommon.base.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.ydlcommon.base.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);
}
}
......@@ -70,5 +70,11 @@ interface IYDLRouterConstant{
const val EXTRA_CATETITLE = "cateTitle"
const val EXTRA_SHOWTYPE = "showType"
const val EXTRA_KEYWORD = "keyword"
/**
* 冥想模块额外参数
*/
const val MUSIC_URL = "musicUrl"
const val DATA_JSON = "dataJson"
}
}
\ No newline at end of file
......@@ -54,7 +54,22 @@ class YDLCacheUtils {
private var CACHE_HOT_SEARCH_DATA = "cache_hot_search_data"
//api
private var CACHE_API = "cache_api"
//冥想模块默认时间缓存
private var CACHE_MUSE_DEFAULT_TIME = "cache_muse_default_time"
/**
* 保存冥想模块默认时间缓存
*/
fun saveMuseDefaultTime(time: String) {
SharedPreferencesEditor.putString(CACHE_MUSE_DEFAULT_TIME, time)
}
/**
* 获取冥想模块默认时间缓存
*/
fun getMuseDefaultTime(): String {
return SharedPreferencesEditor.getString(CACHE_MUSE_DEFAULT_TIME)
}
/**
* 根据sessionId保存提醒专家的时间
......
......@@ -81,7 +81,7 @@ class YDLShareDialog : DialogFragment {
companion object {
var typeStyle: Int = 0
/**
* 1.为显示1排(5个) 2.为显示2排(隐藏动态和举报)3.为显示2排(隐藏动态和删除) 4.为显示1排(4个)隐藏动态按钮 5:生成海报按钮、隐藏动态 6:保存海报按钮、隐藏动态
* 1.为显示1排(5个) 2.为显示2排(隐藏动态和举报)3.为显示2排(隐藏动态和删除) 4.为显示1排(4个)隐藏动态按钮 5:生成海报按钮、隐藏动态 6:保存海报按钮、隐藏动态 7.为显示1排(4个)隐藏动态按钮
*/
const val TYPE1 = 1
const val TYPE2 = 2
......@@ -89,6 +89,7 @@ class YDLShareDialog : DialogFragment {
const val TYPE4 = 4
const val TYPE5 = 5
const val TYPE6 = 6
const val TYPE7 = 7
/**
* 点击事件类型 1.动态 2.删除 3.举报 4.返回首页 5:生成海报 6:保存本地 7:分享纯图片
*/
......@@ -135,6 +136,12 @@ class YDLShareDialog : DialogFragment {
typeStyle = TYPE6
return YDLShareDialog(activity, shareTitle, shareUrl, shareContent, shareHead)
}
//支持分享小程序
fun style7(activity: Activity, shareTitle: String?, shareUrl: String?, shareContent: String?, shareHead: String?, minProgramPath: String? = "", minProgramId: String? = ""): YDLShareDialog {
typeStyle = TYPE7
return YDLShareDialog(activity, shareTitle, shareUrl, shareContent, shareHead, minProgramPath, minProgramId)
}
}
override fun onCreateView(inflater: LayoutInflater?, container: ViewGroup?, savedInstanceState: Bundle?): View {
......@@ -217,6 +224,11 @@ class YDLShareDialog : DialogFragment {
ll_save.visibility = View.VISIBLE
ll_layout2.visibility = View.GONE
}
TYPE7 -> {
//样式7
ll_layout2.visibility = View.GONE
ll_dynamic.visibility = View.GONE
}
}
showPictureView()
......
/*___Generated_by_IDEA___*/
package com.ydl.webview;
/* This stub is only used by the IDE. It is NOT the BuildConfig class actually packed into the APK */
public final class BuildConfig {
public final static boolean DEBUG = Boolean.parseBoolean(null);
}
\ No newline at end of file
/*___Generated_by_IDEA___*/
package com.ydl.webview;
/* This stub is only used by the IDE. It is NOT the Manifest class actually packed into the APK */
public final class Manifest {
}
\ No newline at end of file
/*___Generated_by_IDEA___*/
package com.ydl.webview;
/* This stub is only used by the IDE. It is NOT the R class actually packed into the APK */
public final class R {
}
\ 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