diff --git a/common/src/main/java/com/yunbao/common/dialog/AbsDialogFragment.java b/common/src/main/java/com/yunbao/common/dialog/AbsDialogFragment.java index b6480a53a..e5e3e600d 100644 --- a/common/src/main/java/com/yunbao/common/dialog/AbsDialogFragment.java +++ b/common/src/main/java/com/yunbao/common/dialog/AbsDialogFragment.java @@ -4,11 +4,13 @@ import android.app.Dialog; import android.content.Context; import android.content.DialogInterface; import android.os.Bundle; -import androidx.annotation.NonNull; -import androidx.fragment.app.DialogFragment; import android.view.LayoutInflater; import android.view.View; import android.view.Window; +import android.view.WindowManager; + +import androidx.annotation.NonNull; +import androidx.fragment.app.DialogFragment; import com.yunbao.common.utils.ClickUtil; @@ -32,7 +34,11 @@ public abstract class AbsDialogFragment extends DialogFragment { dialog.setContentView(mRootView); dialog.setCancelable(canCancel()); dialog.setCanceledOnTouchOutside(canCancel()); - setWindowAttributes(dialog.getWindow()); + Window window = dialog.getWindow(); + if (window != null) { + window.setType(WindowManager.LayoutParams.TYPE_APPLICATION); + } + setWindowAttributes(window); return dialog; } diff --git a/main/src/main/java/com/yunbao/main/activity/MainActivity.java b/main/src/main/java/com/yunbao/main/activity/MainActivity.java index 34f2e3b6e..abfdb9f74 100644 --- a/main/src/main/java/com/yunbao/main/activity/MainActivity.java +++ b/main/src/main/java/com/yunbao/main/activity/MainActivity.java @@ -12,13 +12,11 @@ import android.content.Intent; import android.net.Uri; import android.os.Build; import android.os.Bundle; -import android.os.Message; import android.text.TextUtils; import android.util.Log; import android.view.Display; import android.view.View; import android.view.ViewGroup; -import android.view.inputmethod.InputMethodManager; import android.widget.FrameLayout; import android.widget.RelativeLayout; import android.widget.TextView; @@ -38,12 +36,10 @@ import com.tencent.imsdk.v2.V2TIMManager; import com.tencent.imsdk.v2.V2TIMSDKConfig; import com.tencent.imsdk.v2.V2TIMSDKListener; import com.tencent.imsdk.v2.V2TIMUserFullInfo; - import com.yunbao.common.CommonAppConfig; import com.yunbao.common.Constants; import com.yunbao.common.activity.AbsActivity; import com.yunbao.common.adapter.ViewPagerAdapter; -import com.yunbao.common.bean.BaseModel; import com.yunbao.common.bean.ChatRemarksBean; import com.yunbao.common.bean.ConfigBean; import com.yunbao.common.bean.LiveSvgGiftBean; @@ -73,12 +69,10 @@ import com.yunbao.common.views.AbsMainViewHolder; import com.yunbao.live.LiveConfig; import com.yunbao.live.activity.LiveAnchorActivity; import com.yunbao.live.activity.LiveRyAnchorActivity; -import com.yunbao.live.activity.PDLIiveChatActivity; import com.yunbao.live.bean.LiveBean; import com.yunbao.live.bean.LiveKsyConfigBean; import com.yunbao.live.http.LiveHttpConsts; import com.yunbao.live.http.LiveHttpUtil; -import com.yunbao.live.socket.SocketRyClient; import com.yunbao.live.utils.LiveStorge; import com.yunbao.live.views.ChatListViewHolder; import com.yunbao.main.R; @@ -116,7 +110,6 @@ import java.util.Map; import cn.rongcloud.rtc.api.RCRTCConfig; import cn.rongcloud.rtc.api.RCRTCEngine; import io.rong.imlib.RongIMClient; -import io.rong.message.TextMessage; import static com.yunbao.common.CommonAppContext.isReady; @@ -481,7 +474,7 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene private void showStartDialog() { if (isReady == true) { MainStartDialogFragment dialogFragment = new MainStartDialogFragment(); - dialogFragment.setMainStartChooseCallback(mMainStartChooseCallback); + dialogFragment.setMainStartChooseCallback(true,this); dialogFragment.show(getSupportFragmentManager(), "MainStartDialogFragment"); } else { ToastUtil.show("正在初始化,請稍等...."); @@ -489,87 +482,9 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene } - private MainStartChooseCallback mMainStartChooseCallback = new MainStartChooseCallback() { - @Override - public void onLiveClick() { - mProcessResultUtil.requestPermissions(new String[]{ - Manifest.permission.READ_EXTERNAL_STORAGE, - Manifest.permission.WRITE_EXTERNAL_STORAGE, - Manifest.permission.CAMERA, - Manifest.permission.RECORD_AUDIO - }, mStartLiveRunnable); - } - - @Override - public void onVideoClick() { - if (Constants.isAnchor) { - mProcessResultUtil.requestPermissions(new String[]{ - Manifest.permission.READ_EXTERNAL_STORAGE, - Manifest.permission.WRITE_EXTERNAL_STORAGE, - Manifest.permission.CAMERA, - Manifest.permission.RECORD_AUDIO - }, mStartVideoRunnable); - } else { - ToastUtil.show(getString(R.string.only_open_anchor)); - } - } - }; - - private Runnable mStartLiveRunnable = new Runnable() { - @Override - public void run() { -// MainActivity.this.startActivity(new Intent(MainActivity.this, LiveTRTCAnchorActivity.class)); - if (CommonAppConfig.LIVE_SDK_CHANGED) { - if (mGetLiveSdkCallback == null) { - mGetLiveSdkCallback = new HttpCallback() { - @Override - public void onSuccess(int code, String msg, final String[] info) { - if (code == 0 && info.length > 0) { - LiveHttpUtil.getisRong(new HttpCallback() { - @Override - public void onSuccess(int code, String msg, String[] info1) { - try { - JSONObject obj = JSON.parseObject(info[0]); - JSONObject obj1 = JSON.parseObject(info1[0]); - if (obj1.getString("is_rong").equals("1")) { - LiveRyAnchorActivity.forward(mContext, obj.getIntValue("live_sdk"), JSON.parseObject(obj.getString("android"), LiveKsyConfigBean.class)); - } else { - LiveAnchorActivity.forward(mContext, obj.getIntValue("live_sdk"), JSON.parseObject(obj.getString("android"), LiveKsyConfigBean.class)); - } - } catch (Exception e) { - - } - } - }); - } - } - }; - } - LiveHttpUtil.getLiveSdk(mGetLiveSdkCallback); - } else { - LiveAnchorActivity.forward(mContext, CommonAppConfig.LIVE_SDK_USED, LiveConfig.getDefaultKsyConfig()); - } - } - }; - private Runnable mStartVideoRunnable = new Runnable() { - @Override - public void run() { - String mBeautySdkType = CommonAppConfig.getInstance().getBeautySdkType(); - if ("2".equals(mBeautySdkType)) { - Constants.myIntoIndex = 2; - Intent intent = new Intent(mContext, MyWebViewActivity.class); - intent.putExtra(Constants.URL, CommonAppConfig.HOST + "/h5/shequ/index.html#/h5/shequ/release" + "?token=" + CommonAppConfig.getInstance().getToken() + "&uid=" + CommonAppConfig.getInstance().getUid() + "&isRelease=1"); - startActivity(intent); - } else { - Constants.myIntoIndex = 2; - Intent intent = new Intent(mContext, MyWebViewActivity.class); - intent.putExtra(Constants.URL, CommonAppConfig.HOST + "/h5/shequ/index.html#/h5/shequ/release" + "?token=" + CommonAppConfig.getInstance().getToken() + "&uid=" + CommonAppConfig.getInstance().getUid() + "&isRelease=1"); - startActivity(intent); - } - } - }; + /** * 检查版本更新 @@ -1043,6 +958,8 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene public void onPDLiveConversationListEvent(PDLiveConversationListEvent event) { if (event.getPage() == 11) { finish(); + } else if (event.getPage() == 17) { + showStartDialog(); } else { mViewPager.setCurrentItem(event.getPage()); mTabButtonGroup.setCurPosition(event.getPage()); diff --git a/main/src/main/java/com/yunbao/main/activity/PDLiveConversationListActivity.java b/main/src/main/java/com/yunbao/main/activity/PDLiveConversationListActivity.java index 2ad6b00fd..7d5295eb8 100644 --- a/main/src/main/java/com/yunbao/main/activity/PDLiveConversationListActivity.java +++ b/main/src/main/java/com/yunbao/main/activity/PDLiveConversationListActivity.java @@ -21,11 +21,13 @@ import com.yunbao.common.event.MessageIMEvent; import com.yunbao.common.event.UpdateTablePointMe; import com.yunbao.common.http.HttpCallback; import com.yunbao.common.manager.imrongcloud.MessageIMManager; +import com.yunbao.common.utils.ProcessResultUtil; import com.yunbao.common.utils.ToastUtil; import com.yunbao.live.bean.ImUserBean; import com.yunbao.live.http.ImHttpUtil; import com.yunbao.main.R; import com.yunbao.main.adapter.SystemMessageAdapter; +import com.yunbao.main.dialog.MainStartDialogFragment; import com.yunbao.main.event.PDLiveConversationListEvent; import com.yunbao.main.manager.imrongcloud.ConversationIMListManager; @@ -39,6 +41,8 @@ import java.util.List; import io.rong.imkit.conversationlist.ConversationListFragment; +import static com.yunbao.common.CommonAppContext.isReady; + /** * pdlive消息中心 */ @@ -53,6 +57,7 @@ public class PDLiveConversationListActivity extends AbsActivity { private TextView redPoint; private View redpointMe; private SystemMessageAdapter messageAdapter; + private ProcessResultUtil mProcessResultUtil; @Override protected int getLayoutId() { @@ -79,7 +84,10 @@ public class PDLiveConversationListActivity extends AbsActivity { redpointMe = findViewById(R.id.v_table_redpoint_me); mTabButtonGroup.setCurPosition(2); - + findViewById(R.id.btn_start).setOnClickListener(v -> { + //防止重新加载多个 + showStartDialog(); + }); //选中监听 mTabButtonGroup.addTabButtonGroupChangeListener((view, index) -> { Log.e(CLASSNAME, "onPageSelected:" + index); @@ -92,11 +100,21 @@ public class PDLiveConversationListActivity extends AbsActivity { }); } + private void showStartDialog() { + if (isReady == true) { + MainStartDialogFragment dialogFragment = new MainStartDialogFragment(); + dialogFragment.setMainStartChooseCallback(true,this); + dialogFragment.show(getSupportFragmentManager(), "MainStartDialogFragment"); + } else { + ToastUtil.show("正在初始化,請稍等...."); + } + } /** * 初始化数据 */ private void initData() { + mProcessResultUtil = new ProcessResultUtil(this); //获取系统消息列表 ImHttpUtil.getImUserInfo("", new HttpCallback() { @Override diff --git a/main/src/main/java/com/yunbao/main/dialog/MainStartDialogFragment.java b/main/src/main/java/com/yunbao/main/dialog/MainStartDialogFragment.java index 68876bc4c..714a02b83 100644 --- a/main/src/main/java/com/yunbao/main/dialog/MainStartDialogFragment.java +++ b/main/src/main/java/com/yunbao/main/dialog/MainStartDialogFragment.java @@ -1,8 +1,11 @@ package com.yunbao.main.dialog; +import android.Manifest; import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.ObjectAnimator; +import android.app.Activity; +import android.content.Intent; import android.os.Bundle; import android.os.Handler; import android.view.Gravity; @@ -12,8 +15,24 @@ import android.view.WindowManager; import android.widget.ImageView; import android.widget.LinearLayout; +import androidx.fragment.app.FragmentActivity; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.yunbao.common.CommonAppConfig; +import com.yunbao.common.Constants; +import com.yunbao.common.activity.AbsActivity; import com.yunbao.common.dialog.AbsDialogFragment; +import com.yunbao.common.http.HttpCallback; +import com.yunbao.common.utils.ProcessResultUtil; +import com.yunbao.common.utils.ToastUtil; +import com.yunbao.live.LiveConfig; +import com.yunbao.live.activity.LiveAnchorActivity; +import com.yunbao.live.activity.LiveRyAnchorActivity; +import com.yunbao.live.bean.LiveKsyConfigBean; +import com.yunbao.live.http.LiveHttpUtil; import com.yunbao.main.R; +import com.yunbao.main.activity.MyWebViewActivity; import com.yunbao.main.interfaces.MainStartChooseCallback; /** @@ -62,7 +81,6 @@ public class MainStartDialogFragment extends AbsDialogFragment implements View.O window.setWindowAnimations(R.style.bottomToTopAnim); WindowManager.LayoutParams params = window.getAttributes(); params.width = WindowManager.LayoutParams.MATCH_PARENT; -// params.height = WindowManager.LayoutParams.WRAP_CONTENT; params.gravity = Gravity.BOTTOM; window.setAttributes(params); @@ -124,11 +142,94 @@ public class MainStartDialogFragment extends AbsDialogFragment implements View.O mRootView.findViewById(R.id.btn_video).setOnClickListener(this); mRootView.findViewById(R.id.btn_close).setOnClickListener(this); } - - public void setMainStartChooseCallback(MainStartChooseCallback callback) { - mCallback = callback; + private HttpCallback mGetLiveSdkCallback; + private ProcessResultUtil mProcessResultUtil; + public void setMainStartChooseCallback(boolean isCallback, AbsActivity activity) { + mProcessResultUtil = new ProcessResultUtil(activity); + if (isCallback) { + mCallback = mMainStartChooseCallback; + } } + private MainStartChooseCallback mMainStartChooseCallback = new MainStartChooseCallback() { + @Override + public void onLiveClick() { + mProcessResultUtil.requestPermissions(new String[]{ + Manifest.permission.READ_EXTERNAL_STORAGE, + Manifest.permission.WRITE_EXTERNAL_STORAGE, + Manifest.permission.CAMERA, + Manifest.permission.RECORD_AUDIO + }, mStartLiveRunnable); + } + + @Override + public void onVideoClick() { + if (Constants.isAnchor) { + mProcessResultUtil.requestPermissions(new String[]{ + Manifest.permission.READ_EXTERNAL_STORAGE, + Manifest.permission.WRITE_EXTERNAL_STORAGE, + Manifest.permission.CAMERA, + Manifest.permission.RECORD_AUDIO + }, mStartVideoRunnable); + } else { + ToastUtil.show(getString(R.string.only_open_anchor)); + } + } + }; + private Runnable mStartLiveRunnable = new Runnable() { + @Override + public void run() { + if (CommonAppConfig.LIVE_SDK_CHANGED) { + if (mGetLiveSdkCallback == null) { + mGetLiveSdkCallback = new HttpCallback() { + @Override + public void onSuccess(int code, String msg, final String[] info) { + if (code == 0 && info.length > 0) { + LiveHttpUtil.getisRong(new HttpCallback() { + @Override + public void onSuccess(int code, String msg, String[] info1) { + try { + JSONObject obj = JSON.parseObject(info[0]); + JSONObject obj1 = JSON.parseObject(info1[0]); + if (obj1.getString("is_rong").equals("1")) { + LiveRyAnchorActivity.forward(mContext, obj.getIntValue("live_sdk"), JSON.parseObject(obj.getString("android"), LiveKsyConfigBean.class)); + } else { + LiveAnchorActivity.forward(mContext, obj.getIntValue("live_sdk"), JSON.parseObject(obj.getString("android"), LiveKsyConfigBean.class)); + } + } catch (Exception e) { + + } + } + }); + } + } + }; + } + LiveHttpUtil.getLiveSdk(mGetLiveSdkCallback); + } else { + LiveAnchorActivity.forward(mContext, CommonAppConfig.LIVE_SDK_USED, LiveConfig.getDefaultKsyConfig()); + } + } + }; + + + private Runnable mStartVideoRunnable = new Runnable() { + @Override + public void run() { + String mBeautySdkType = CommonAppConfig.getInstance().getBeautySdkType(); + if ("2".equals(mBeautySdkType)) { + Constants.myIntoIndex = 2; + Intent intent = new Intent(mContext, MyWebViewActivity.class); + intent.putExtra(Constants.URL, CommonAppConfig.HOST + "/h5/shequ/index.html#/h5/shequ/release" + "?token=" + CommonAppConfig.getInstance().getToken() + "&uid=" + CommonAppConfig.getInstance().getUid() + "&isRelease=1"); + startActivity(intent); + } else { + Constants.myIntoIndex = 2; + Intent intent = new Intent(mContext, MyWebViewActivity.class); + intent.putExtra(Constants.URL, CommonAppConfig.HOST + "/h5/shequ/index.html#/h5/shequ/release" + "?token=" + CommonAppConfig.getInstance().getToken() + "&uid=" + CommonAppConfig.getInstance().getUid() + "&isRelease=1"); + startActivity(intent); + } + } + }; @Override public void onClick(View v) { if (!canClick()) { @@ -140,8 +241,6 @@ public class MainStartDialogFragment extends AbsDialogFragment implements View.O } else if (i == R.id.btn_live) { if (mCallback != null) { mCallback.onLiveClick(); -// Intent intent = new Intent(mContext, Beauty360Activity3.class); -// mContext.startActivity(intent); } } else if (i == R.id.btn_video) { if (mCallback != null) {