Commit 4c5df00c by YKai

feat: mdt代码优化

parent 74a9e9ff
...@@ -55,15 +55,15 @@ import kotlinx.android.synthetic.main.activity_main.* ...@@ -55,15 +55,15 @@ import kotlinx.android.synthetic.main.activity_main.*
@Route(path = "/main/main") @Route(path = "/main/main")
class MainActivity : BaseLceActivity<DemoContract.View, DemoContract.Presenter>(), class MainActivity : BaseLceActivity<DemoContract.View, DemoContract.Presenter>(),
DemoContract.View { DemoContract.View {
// private var secretDescriptionDialog: SecretDescriptionDialog? = null // private var secretDescriptionDialog: SecretDescriptionDialog? = null
private var serviceConnection: ServiceConnection? = null private var serviceConnection: ServiceConnection? = null
private var meditationServiceConnection:ServiceConnection? = null private var meditationServiceConnection: ServiceConnection? = null
private var secretDialog: SecretDialog? = null private var secretDialog: SecretDialog? = null
protected var playService: PlayService? = null protected var playService: PlayService? = null
protected var meditationService:MeditationWindowService?=null protected var meditationService: MeditationWindowService? = null
override fun getContentViewId(): Int { override fun getContentViewId(): Int {
return R.id.lce_content_view return R.id.lce_content_view
...@@ -95,10 +95,14 @@ class MainActivity : BaseLceActivity<DemoContract.View, DemoContract.Presenter>( ...@@ -95,10 +95,14 @@ class MainActivity : BaseLceActivity<DemoContract.View, DemoContract.Presenter>(
YdlCommonRouterManager.initYdlCommonRoute(PlatformTempCommonRouteImpl()) YdlCommonRouterManager.initYdlCommonRoute(PlatformTempCommonRouteImpl())
// 初始化一键登录sdk // 初始化一键登录sdk
OneKeyLoginHelp.sdkInit(this, OneKeyLoginHelp.YDL_USER_APP, PhoneNumberAuthHelper.SERVICE_TYPE_LOGIN) OneKeyLoginHelp.sdkInit(
this,
OneKeyLoginHelp.YDL_USER_APP,
PhoneNumberAuthHelper.SERVICE_TYPE_LOGIN
)
bindService() bindService()
bindMeditationService() bindMeditationService()
reLoadData() reLoadData()
requestPermission() requestPermission()
bt_mdt.setOnClickListener { bt_mdt.setOnClickListener {
...@@ -119,7 +123,7 @@ class MainActivity : BaseLceActivity<DemoContract.View, DemoContract.Presenter>( ...@@ -119,7 +123,7 @@ class MainActivity : BaseLceActivity<DemoContract.View, DemoContract.Presenter>(
// .withBoolean("bind_phone", false) // .withBoolean("bind_phone", false)
// .withBoolean("isFromGuide", true) // .withBoolean("isFromGuide", true)
// .navigation() // .navigation()
OneKeyLoginHelp.startLogin(this,false) OneKeyLoginHelp.startLogin(this, false)
} }
bt_to_consultant.setOnClickListener { bt_to_consultant.setOnClickListener {
// ARouter.getInstance() // ARouter.getInstance()
...@@ -164,7 +168,9 @@ class MainActivity : BaseLceActivity<DemoContract.View, DemoContract.Presenter>( ...@@ -164,7 +168,9 @@ class MainActivity : BaseLceActivity<DemoContract.View, DemoContract.Presenter>(
startActivity(Intent(this, CollectSexAndBirthActivity::class.java)) startActivity(Intent(this, CollectSexAndBirthActivity::class.java))
} }
bt_to_confide.setOnClickListener { bt_to_confide.setOnClickListener {
YDLavManager.instances.login(ModularServiceManager.provide(IUserService::class.java).getUserInfo()?.uid) YDLavManager.instances.login(
ModularServiceManager.provide(IUserService::class.java).getUserInfo()?.uid
)
startActivity(Intent(this, ConfideHomeActivity::class.java)) startActivity(Intent(this, ConfideHomeActivity::class.java))
} }
...@@ -243,20 +249,24 @@ class MainActivity : BaseLceActivity<DemoContract.View, DemoContract.Presenter>( ...@@ -243,20 +249,24 @@ class MainActivity : BaseLceActivity<DemoContract.View, DemoContract.Presenter>(
val rxPermissions = RxPermissions(this) val rxPermissions = RxPermissions(this)
rxPermissions.requestEach(Manifest.permission.WRITE_EXTERNAL_STORAGE) rxPermissions.requestEach(Manifest.permission.WRITE_EXTERNAL_STORAGE)
.subscribe { permission -> .subscribe { permission ->
if (permission.granted) { when {
ToastUtil.toastShort("Permission Success") permission.granted -> {
} else if (permission.shouldShowRequestPermissionRationale) { ToastUtil.toastShort("Permission Success")
requestPermission() }
} else { permission.shouldShowRequestPermissionRationale -> {
ToastUtil.toastLong( requestPermission()
this, }
getString(R.string.platform_need_storage_permission_hint) else -> {
) ToastUtil.toastLong(
val intent = Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS) this,
val uri = Uri.fromParts("package", packageName, null) getString(R.string.platform_need_storage_permission_hint)
intent.data = uri )
startActivity(intent) val intent = Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS)
finish() val uri = Uri.fromParts("package", packageName, null)
intent.data = uri
startActivity(intent)
finish()
}
} }
} }
...@@ -269,11 +279,11 @@ class MainActivity : BaseLceActivity<DemoContract.View, DemoContract.Presenter>( ...@@ -269,11 +279,11 @@ class MainActivity : BaseLceActivity<DemoContract.View, DemoContract.Presenter>(
bindService(intent, serviceConnection, Context.BIND_AUTO_CREATE) bindService(intent, serviceConnection, Context.BIND_AUTO_CREATE)
} }
private fun bindMeditationService(){ private fun bindMeditationService() {
val intent = Intent() val intent = Intent()
intent.setClass(this,MeditationWindowService::class.java) intent.setClass(this, MeditationWindowService::class.java)
meditationServiceConnection = MeditationServiceConnection() meditationServiceConnection = MeditationServiceConnection()
bindService(intent,meditationServiceConnection,Context.BIND_AUTO_CREATE) bindService(intent, meditationServiceConnection, Context.BIND_AUTO_CREATE)
} }
override fun onResume() { override fun onResume() {
...@@ -285,7 +295,7 @@ class MainActivity : BaseLceActivity<DemoContract.View, DemoContract.Presenter>( ...@@ -285,7 +295,7 @@ class MainActivity : BaseLceActivity<DemoContract.View, DemoContract.Presenter>(
// (this) // (this)
val trtcCalling = TRTCCalling.sharedInstance(this) val trtcCalling = TRTCCalling.sharedInstance(this)
if (!TextUtils.isEmpty(trtcCalling.mRoomId)&&!TextUtils.isEmpty(trtcCalling.mUserId)){ if (!TextUtils.isEmpty(trtcCalling.mRoomId) && !TextUtils.isEmpty(trtcCalling.mUserId)) {
val intent = Intent(mContext, YDLInvitionActivity::class.java) val intent = Intent(mContext, YDLInvitionActivity::class.java)
intent.putExtra(Constant.ROOM_ID, trtcCalling.mRoomId) intent.putExtra(Constant.ROOM_ID, trtcCalling.mRoomId)
intent.putExtra(Constant.USER_ID, trtcCalling.mUserId) intent.putExtra(Constant.USER_ID, trtcCalling.mUserId)
...@@ -301,8 +311,8 @@ class MainActivity : BaseLceActivity<DemoContract.View, DemoContract.Presenter>( ...@@ -301,8 +311,8 @@ class MainActivity : BaseLceActivity<DemoContract.View, DemoContract.Presenter>(
// ModularServiceManager.provide(IConsultantService::class.java).hideConsultAssistantDialog() // ModularServiceManager.provide(IConsultantService::class.java).hideConsultAssistantDialog()
} }
fun onEvent(event:MeditationFloatEvent){ fun onEvent(event: MeditationFloatEvent) {
} }
@SuppressLint("MissingSuperCall") @SuppressLint("MissingSuperCall")
...@@ -310,12 +320,12 @@ class MainActivity : BaseLceActivity<DemoContract.View, DemoContract.Presenter>( ...@@ -310,12 +320,12 @@ class MainActivity : BaseLceActivity<DemoContract.View, DemoContract.Presenter>(
if (serviceConnection != null) { if (serviceConnection != null) {
unbindService(serviceConnection) unbindService(serviceConnection)
} }
if(meditationServiceConnection!=null){ if (meditationServiceConnection != null) {
EventBus.getDefault().post(MeditationFloatEvent(false)) EventBus.getDefault().post(MeditationFloatEvent(false))
MediaPlayerManager.getInstance(this)?.stop() MediaPlayerManager.getInstance(this)?.stop()
unbindService(meditationServiceConnection) unbindService(meditationServiceConnection)
} }
if(EventBus.getDefault().isRegistered(this)){ if (EventBus.getDefault().isRegistered(this)) {
EventBus.getDefault().unregister(this) EventBus.getDefault().unregister(this)
} }
super.onDestroy() super.onDestroy()
...@@ -331,7 +341,7 @@ class MainActivity : BaseLceActivity<DemoContract.View, DemoContract.Presenter>( ...@@ -331,7 +341,7 @@ class MainActivity : BaseLceActivity<DemoContract.View, DemoContract.Presenter>(
} }
} }
private inner class MeditationServiceConnection:ServiceConnection { private inner class MeditationServiceConnection : ServiceConnection {
override fun onServiceConnected(name: ComponentName?, service: IBinder?) { override fun onServiceConnected(name: ComponentName?, service: IBinder?) {
meditationService = (service as MeditationWindowService.MeditationBinder).service meditationService = (service as MeditationWindowService.MeditationBinder).service
} }
......
...@@ -193,7 +193,7 @@ public class TRTCCalling { ...@@ -193,7 +193,7 @@ public class TRTCCalling {
public MdtCallBack mdtCallBack; public MdtCallBack mdtCallBack;
public interface MdtCallBack{ public interface MdtCallBack {
void onReceiveNewInvitation(String roomId); void onReceiveNewInvitation(String roomId);
void onInviteeAccepted(String roomId); void onInviteeAccepted(String roomId);
...@@ -344,28 +344,26 @@ public class TRTCCalling { ...@@ -344,28 +344,26 @@ public class TRTCCalling {
private V2TIMSignalingListener mTIMSignallingListener = new V2TIMSignalingListener() { private V2TIMSignalingListener mTIMSignallingListener = new V2TIMSignalingListener() {
@Override @Override
public void onReceiveNewInvitation(String inviteID, String inviter, String groupID, List<String> inviteeList, String data) { public void onReceiveNewInvitation(String inviteID, String inviter, String groupID, List<String> inviteeList, String data) {
TRTCLogger.e(TAG, "onReceiveNewInvitation inviteID:" + inviteID + ", inviter:" + inviter TRTCLogger.e(TAG, "onReceiveNewInvitation inviteID:" + inviteID + ", inviter:" + inviter + ", groupID:" + groupID + ", inviteeList:" + inviteeList + " data:" + data);
+ ", groupID:" + groupID + ", inviteeList:" + inviteeList + " data:" + data);
final UserModel userModel = UserModelManager.getInstance().getUserModel(); final UserModel userModel = UserModelManager.getInstance().getUserModel();
for (String s : inviteeList) { if (inviteeList.contains(userModel.userId)) {
if (s.equals(userModel.userId)){ mRoomId = groupID;
mRoomId = groupID; mUserId = userModel.userId;
mUserId = userModel.userId; mInviteId = inviter;
mInviteId = inviter;
Intent intent = new Intent(mContext, YDLInvitionActivity.class);
Intent intent = new Intent(mContext, YDLInvitionActivity.class); intent.putExtra(Constant.ROOM_ID, groupID);
intent.putExtra(Constant.ROOM_ID, groupID); intent.putExtra(Constant.USER_ID, userModel.userId);
intent.putExtra(Constant.USER_ID, userModel.userId); intent.putExtra(Constant.INVITE_ID, inviter);
intent.putExtra(Constant.INVITE_ID, inviter); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); mContext.startActivity(intent);
mContext.startActivity(intent);
if (!mIsInRoom) {
startRing();
} }
mdtCallBack.onReceiveNewInvitation(mRoomId);
} }
if (!mIsInRoom){
startRing();
}
mdtCallBack.onReceiveNewInvitation(mRoomId);
} }
@Override @Override
...@@ -2102,7 +2100,7 @@ public class TRTCCalling { ...@@ -2102,7 +2100,7 @@ public class TRTCCalling {
if (TextUtils.isEmpty(mCallingBellPath)) { if (TextUtils.isEmpty(mCallingBellPath)) {
mMediaPlayHelper.start(R.raw.phone_ringing); mMediaPlayHelper.start(R.raw.phone_ringing);
} else { } else {
if (!mMediaPlayHelper.getMediaPlayer().isPlaying()){ if (!mMediaPlayHelper.getMediaPlayer().isPlaying()) {
mMediaPlayHelper.start(mCallingBellPath); mMediaPlayHelper.start(mCallingBellPath);
} }
} }
......
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