2020-02-27 22:59:31 +08:00
|
|
|
package com.finogeeks.mop.service;
|
|
|
|
|
|
|
|
import android.app.Activity;
|
|
|
|
import android.content.Context;
|
|
|
|
|
|
|
|
import com.finogeeks.mop.MopEventStream;
|
|
|
|
import com.finogeeks.mop.api.ApisManager;
|
|
|
|
|
2020-04-26 14:57:08 +08:00
|
|
|
import io.flutter.plugin.common.MethodChannel;
|
|
|
|
|
2020-02-27 22:59:31 +08:00
|
|
|
public class MopPluginService {
|
|
|
|
private final static String TAG = MopPluginService.class.getSimpleName();
|
|
|
|
private static volatile MopPluginService _instance = null;
|
|
|
|
|
|
|
|
private ApisManager apisManager;
|
|
|
|
private MopEventStream mopEventStream;
|
|
|
|
|
|
|
|
|
|
|
|
private Context mContext;
|
|
|
|
private Activity mActivity;
|
2020-04-26 14:57:08 +08:00
|
|
|
private MethodChannel mMethodChannel;
|
2020-02-27 22:59:31 +08:00
|
|
|
|
|
|
|
MopPluginService() {
|
|
|
|
}
|
|
|
|
|
|
|
|
public static MopPluginService getInstance() {
|
|
|
|
if (_instance == null) {
|
|
|
|
synchronized (MopPluginService.class) {
|
|
|
|
if (_instance == null) {
|
|
|
|
_instance = new MopPluginService();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return _instance;
|
|
|
|
}
|
|
|
|
|
2020-04-26 14:57:08 +08:00
|
|
|
public ApisManager getApisManager() {
|
|
|
|
return this.apisManager;
|
|
|
|
}
|
|
|
|
|
|
|
|
public MopEventStream getMopEventStream() {
|
|
|
|
return this.mopEventStream;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void initialize(Activity activity, MopEventStream mopEventStream, MethodChannel methodChannel) {
|
2020-02-27 22:59:31 +08:00
|
|
|
this.mopEventStream = mopEventStream;
|
|
|
|
this.mContext = activity.getApplicationContext();
|
|
|
|
this.apisManager = new ApisManager(activity);
|
|
|
|
this.mActivity = activity;
|
2020-04-26 14:57:08 +08:00
|
|
|
this.mMethodChannel = methodChannel;
|
2020-02-27 22:59:31 +08:00
|
|
|
|
|
|
|
|
|
|
|
}
|
2020-04-26 14:57:08 +08:00
|
|
|
|
2020-02-27 22:59:31 +08:00
|
|
|
public Context getContext() {
|
|
|
|
return mContext;
|
|
|
|
}
|
2020-04-26 14:57:08 +08:00
|
|
|
|
2020-02-27 22:59:31 +08:00
|
|
|
public Activity getActivity() {
|
|
|
|
return mActivity;
|
|
|
|
}
|
2020-04-26 14:57:08 +08:00
|
|
|
|
|
|
|
public MethodChannel getMethodChannel() {
|
|
|
|
return mMethodChannel;
|
|
|
|
}
|
2020-02-27 22:59:31 +08:00
|
|
|
}
|