Commit bf18e27e by konghaorui
parents 5d0b11ab 381f2ac1
ext { ext {
kotlin_version = '1.3.21' kotlin_version = '1.3.21'
dev_mode = true dev_mode = false
ydl_app = [ ydl_app = [
appName : "心理咨询壹点灵", appName : "心理咨询壹点灵",
...@@ -180,6 +180,6 @@ ext { ...@@ -180,6 +180,6 @@ ext {
"ydl-m-user-api" : 'com.ydl:m-user-api:0.0.5', "ydl-m-user-api" : 'com.ydl:m-user-api:0.0.5',
"ydl-m-muse-api" : 'com.ydl:m-muse-api:0.0.1', "ydl-m-muse-api" : 'com.ydl:m-muse-api:0.0.1',
"ydl-m-fm-api" : 'com.ydl:m-fm-api:0.0.2', "ydl-m-fm-api" : 'com.ydl:m-fm-api:0.0.2',
"ydl-m-fm-module-ydl" : 'com.ydl:m-fm-module-ydl:0.0.1@aar' "ydl-m-fm-module-ydl" : 'com.ydl:m-fm-module-ydl:0.0.6@aar'
] ]
} }
...@@ -78,7 +78,7 @@ dependencies { ...@@ -78,7 +78,7 @@ dependencies {
implementation project(':ydl-media') implementation project(':ydl-media')
} else { } else {
//发布时使用 //发布时使用
implementation project(':ydl-media') implementation "com.ydl:ydl-media:0.0.4@aar"
implementation rootProject.ext.dependencies["ydl-m-user-api"] implementation rootProject.ext.dependencies["ydl-m-user-api"]
implementation rootProject.ext.dependencies["ydl-platform"] implementation rootProject.ext.dependencies["ydl-platform"]
} }
......
...@@ -15,7 +15,7 @@ modular { ...@@ -15,7 +15,7 @@ modular {
groupId = "com.ydl" groupId = "com.ydl"
artifactId = "m-fm-module-ydl" artifactId = "m-fm-module-ydl"
// 上报的 壹点灵 业务模块 aar 包的版本号 // 上报的 壹点灵 业务模块 aar 包的版本号
version = "0.0.6" version = "0.0.7"
} }
} }
......
...@@ -42,6 +42,7 @@ import com.yidianling.fm.param.FavParam; ...@@ -42,6 +42,7 @@ import com.yidianling.fm.param.FavParam;
import com.yidianling.fm.response.FMDetail; import com.yidianling.fm.response.FMDetail;
import com.yidianling.fm.router.FMIn; import com.yidianling.fm.router.FMIn;
import com.yidianling.fm.widget.FMSurfaceView; import com.yidianling.fm.widget.FMSurfaceView;
import com.yidianling.user.api.event.UserLoginEvent;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.json.JSONException; import org.json.JSONException;
...@@ -52,6 +53,7 @@ import java.util.ArrayList; ...@@ -52,6 +53,7 @@ import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import de.greenrobot.event.EventBus;
import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.android.schedulers.AndroidSchedulers;
/** /**
...@@ -180,8 +182,7 @@ public class FMDetailActivity extends BaseActivity implements View.OnClickListen ...@@ -180,8 +182,7 @@ public class FMDetailActivity extends BaseActivity implements View.OnClickListen
fmIdList.clear(); fmIdList.clear();
// todo 打开 EventBus.getDefault().register(this);
// EventBus.getDefault().register(this);
if (null == getIntent()) { if (null == getIntent()) {
finish(); finish();
...@@ -406,10 +407,10 @@ public class FMDetailActivity extends BaseActivity implements View.OnClickListen ...@@ -406,10 +407,10 @@ public class FMDetailActivity extends BaseActivity implements View.OnClickListen
if (!TextUtils.isEmpty(fmDetail.getFm_url())) { if (!TextUtils.isEmpty(fmDetail.getFm_url())) {
Music music = new Music(); Music music = new Music();
music.setPath(fmDetail.getFm_url()); music.setPath(fmDetail.getFm_url());
music.setAlbum(""); music.setAlbum(fmDetail.getImage_url());
music.setArtist(""); music.setArtist(fmDetail.getAuthor());
music.setCoverPath(""); music.setCoverPath(fmDetail.getImage_url());
music.setTitle(""); music.setTitle(fmDetail.getTitle());
AudioPlayer.Companion.get().prev(); AudioPlayer.Companion.get().prev();
AudioPlayer.Companion.get().singlePlay(music, false); AudioPlayer.Companion.get().singlePlay(music, false);
} }
...@@ -439,13 +440,12 @@ public class FMDetailActivity extends BaseActivity implements View.OnClickListen ...@@ -439,13 +440,12 @@ public class FMDetailActivity extends BaseActivity implements View.OnClickListen
// } // }
// } // }
//todo xujian public void onEvent(UserLoginEvent event) {
// public void onEvent(UserLoginEvent event) { if (isToTrend) {
// if (isToTrend) { isToTrend = false;
// isToTrend = false; toTrend();
// toTrend(); }
// } }
// }
@Override @Override
public void onClick(View v) { public void onClick(View v) {
...@@ -588,8 +588,7 @@ public class FMDetailActivity extends BaseActivity implements View.OnClickListen ...@@ -588,8 +588,7 @@ public class FMDetailActivity extends BaseActivity implements View.OnClickListen
super.onDestroy(); super.onDestroy();
anim.cancel(); anim.cancel();
// todo 打开 EventBus.getDefault().unregister(this);
// EventBus.getDefault().unregister(this);
AudioPlayer.Companion.get().removeOnPlayEventListener(this); AudioPlayer.Companion.get().removeOnPlayEventListener(this);
} }
......
...@@ -69,9 +69,6 @@ dependencies { ...@@ -69,9 +69,6 @@ dependencies {
} else { } else {
//发布时使用 //发布时使用
implementation project(':ydl-media') implementation project(':ydl-media')
api(rootProject.ext.dependencies["ydl-platform"]) { implementation rootProject.ext.dependencies["ydl-platform"]
transitive = true
}
} }
} }
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.yidianling.ydlcommon.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.yidianling.ydlcommon.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.yidianling.ydlcommon.flutter.base
import android.os.Bundle
import android.view.LayoutInflater
import android.view.ViewGroup
import com.ydl.ydlcommon.flutter.io.flutter.facade.Flutter
import com.ydl.ydlcommon.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.ydlcommon.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.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);
}
}
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