短剧优化
This commit is contained in:
parent
004a5b2a53
commit
aa62dda844
@ -410,6 +410,8 @@ public class WebViewActivity extends AbsActivity {
|
||||
} else if (TextUtils.equals(event.getMethod(), "androidMethodLookToLive")) {
|
||||
//看直播
|
||||
gotoLive(event.getLiveId());
|
||||
}else if (TextUtils.equals(event.getMethod(), "androidtoCommunityVideo")) {
|
||||
RouteUtil.forwardCommunityActivity();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -95,6 +95,16 @@ public class DialogUitl {
|
||||
showSimpleTipDialog(context, null, content);
|
||||
}
|
||||
|
||||
public static void showBackDialog(Context context, String content, String cancel, String sure, SimpleCallback callback) {
|
||||
if (context instanceof Activity) {
|
||||
if (((Activity) context).isDestroyed() || ((Activity) context).isFinishing()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
new Builder(context).setTitle(content).setCancelable(true).isShowContent(false).setCancelString(cancel).setConfirmString(sure).setClickCallback(callback).build().show();
|
||||
}
|
||||
|
||||
|
||||
public static void showSimpleTipDialog(Context context, String title, String content) {
|
||||
if (context instanceof Activity) {
|
||||
if (((Activity) context).isDestroyed() || ((Activity) context).isFinishing()) {
|
||||
@ -351,6 +361,7 @@ public class DialogUitl {
|
||||
private String mHint;
|
||||
private int mInputType;
|
||||
private int mLength;
|
||||
boolean isShowContent;
|
||||
private SimpleCallback mClickCallback;
|
||||
private SimpleCallback3 mClickCallback3;
|
||||
private SimpleCallbackView mSimpleCallbackView;
|
||||
@ -393,6 +404,11 @@ public class DialogUitl {
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder isShowContent(boolean isShow) {
|
||||
isShowContent = isShow;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setCancelable(boolean cancelable) {
|
||||
mCancelable = cancelable;
|
||||
return this;
|
||||
@ -471,6 +487,9 @@ public class DialogUitl {
|
||||
if (mLength > 0 && content instanceof EditText) {
|
||||
content.setFilters(new InputFilter[]{new InputFilter.LengthFilter(mLength)});
|
||||
}
|
||||
if (!isShowContent) {
|
||||
content.setVisibility(View.GONE);
|
||||
}
|
||||
TextView btnConfirm = (TextView) dialog.findViewById(R.id.btn_confirm);
|
||||
if (!TextUtils.isEmpty(mConfirmString)) {
|
||||
btnConfirm.setText(mConfirmString);
|
||||
|
@ -683,4 +683,9 @@ public class JavascriptInterfaceUtils {
|
||||
ToastUtil.showDebug("网页跳客服页面");
|
||||
RouteUtil.forwardCustomerService(url);
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public void androidtoCommunityVideo() {
|
||||
RouteUtil.forwardCommunityActivity();
|
||||
}
|
||||
}
|
||||
|
@ -49,7 +49,13 @@ public class RouteUtil {
|
||||
public static final String PATH_SELECT_AVATAR="/main/UserAvatarSelectActivity";
|
||||
public static final String PATH_BattlePassActivity="/main/BattlePassActivity";
|
||||
public static final String PATH_SudGameActivity="/live/SudGameActivity";
|
||||
public static final String PATH_COMMUNITY_Activity="/main/MainHomeCommunityActivity";
|
||||
|
||||
|
||||
public static void forwardCommunityActivity() {
|
||||
ARouter.getInstance().build(PATH_COMMUNITY_Activity)
|
||||
.navigation();
|
||||
}
|
||||
public static void forwardFansActivity(String uid) {
|
||||
ARouter.getInstance().build(PATH_FANSACTIVITY)
|
||||
.withString(Constants.TO_UID, uid)
|
||||
|
@ -628,7 +628,7 @@
|
||||
<string name="accept">accept</string>
|
||||
<string name="all">whole</string>
|
||||
<string name="alumb">Album</string>
|
||||
<string name="cancel">cancel</string>
|
||||
<string name="cancel">Cancel</string>
|
||||
<string name="camera">camera</string>
|
||||
<string name="pic_choose_look">Picture selection/Preview</string>
|
||||
<string name="preview">Preview</string>
|
||||
@ -1447,4 +1447,7 @@ Limited ride And limited avatar frame</string>
|
||||
<string name="game_review_view_sound_off">Mute</string>
|
||||
|
||||
<string name="sys_msg_cancel">Cancel</string>
|
||||
<string name="community_back">Are you sure to return?</string>
|
||||
|
||||
<string name="back_community_sure">Sure</string>
|
||||
</resources>
|
||||
|
@ -1445,4 +1445,8 @@
|
||||
<string name="main_suspension_war_order">直播通行證</string>
|
||||
|
||||
<string name="sys_msg_cancel">取消</string>
|
||||
|
||||
<string name="community_back">是否確認返回?</string>
|
||||
|
||||
<string name="back_community_sure">確定</string>
|
||||
</resources>
|
||||
|
@ -1445,4 +1445,8 @@
|
||||
|
||||
<string name="sys_msg_cancel">取消</string>
|
||||
|
||||
<string name="community_back">是否確認返回?</string>
|
||||
|
||||
<string name="back_community_sure">確定</string>
|
||||
|
||||
</resources>
|
||||
|
@ -1442,4 +1442,8 @@
|
||||
|
||||
<string name="sys_msg_cancel">取消</string>
|
||||
|
||||
<string name="community_back">是否確認返回?</string>
|
||||
|
||||
<string name="back_community_sure">確定</string>
|
||||
|
||||
</resources>
|
||||
|
@ -1451,4 +1451,8 @@ Limited ride And limited avatar frame</string>
|
||||
|
||||
<string name="sys_msg_cancel">Cancel</string>
|
||||
|
||||
<string name="community_back">Are you sure to return?</string>
|
||||
|
||||
<string name="back_community_sure">Sure</string>
|
||||
|
||||
</resources>
|
||||
|
@ -860,6 +860,8 @@ public class LiveAudienceActivity extends LiveActivity {
|
||||
if (!TextUtils.isEmpty(event.getMethod())) {
|
||||
if (TextUtils.equals(event.getMethod(), "closeLiveRoom")) {
|
||||
onBackPressed();
|
||||
}else if (TextUtils.equals(event.getMethod(), "androidtoCommunityVideo")) {
|
||||
RouteUtil.forwardCommunityActivity();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -161,6 +161,13 @@ public class LiveGameDialogFragment extends AbsDialogFragment {
|
||||
.setLiveZhuangBana(true).
|
||||
setDialogClose(true).
|
||||
setPageClose(false), "androidObject");
|
||||
|
||||
|
||||
/* mWebView.addJavascriptInterface(JavascriptInterfaceUtils.getInstance().setmContext(getActivity(), mWebView)
|
||||
.setLiveZhuangBana(true).
|
||||
setDialogClose(true).
|
||||
setPageClose(false), "androidObject");*/
|
||||
|
||||
mWebView.getSettings().setJavaScriptEnabled(true);
|
||||
mWebView.getSettings().setDomStorageEnabled(true);
|
||||
String appCachePath = mContext.getCacheDir().getAbsolutePath();
|
||||
@ -417,6 +424,8 @@ public class LiveGameDialogFragment extends AbsDialogFragment {
|
||||
);
|
||||
|
||||
}
|
||||
}else if (TextUtils.equals(event.getMethod(), "androidtoCommunityVideo")) {
|
||||
RouteUtil.forwardCommunityActivity();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -159,6 +159,9 @@
|
||||
<activity android:name=".activity.UserAvatarSelectActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity android:name=".activity.BattlePassActivity" />
|
||||
|
||||
<activity android:name=".activity.MainHomeCommunityActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
</application>
|
||||
|
||||
</manifest>
|
@ -0,0 +1,43 @@
|
||||
package com.yunbao.main.activity;
|
||||
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.fragment.app.FragmentTransaction;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.yunbao.common.activity.AbsActivity;
|
||||
import com.yunbao.common.utils.L;
|
||||
import com.yunbao.common.utils.RouteUtil;
|
||||
import com.yunbao.main.R;
|
||||
import com.yunbao.main.fragment.MainHomeCommunityVideoFragment;
|
||||
|
||||
/**
|
||||
* 短剧
|
||||
*/
|
||||
@Route(path = RouteUtil.PATH_COMMUNITY_Activity)
|
||||
public class MainHomeCommunityActivity extends AbsActivity {
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_main_home_community;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void main() {
|
||||
MainHomeCommunityVideoFragment communityVideoFragment = new MainHomeCommunityVideoFragment();
|
||||
|
||||
FragmentManager FM = getSupportFragmentManager();//获取管理器
|
||||
FragmentTransaction FT = FM.beginTransaction();//获取启动器
|
||||
FT.replace(R.id.fragment, communityVideoFragment);//替换碎片
|
||||
FT.addToBackStack(null);//是否启动回退栈
|
||||
FT.commit();//提交
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
}
|
@ -10,8 +10,10 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Message;
|
||||
import android.text.TextUtils;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.webkit.CookieManager;
|
||||
@ -19,6 +21,10 @@ import android.webkit.ValueCallback;
|
||||
import android.webkit.WebSettings;
|
||||
import android.webkit.WebView;
|
||||
import android.webkit.WebViewClient;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import androidx.activity.OnBackPressedCallback;
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.lxj.xpopup.XPopup;
|
||||
@ -48,10 +54,17 @@ import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
public class MainHomeCommunityVideoFragment extends BaseFragment {
|
||||
WebView mWebView;
|
||||
private Context mContext;
|
||||
LinearLayout back;
|
||||
|
||||
boolean isShow = true;
|
||||
|
||||
Timer timer;
|
||||
|
||||
@Override
|
||||
public View createView(LayoutInflater inflater, ViewGroup container) {
|
||||
@ -118,6 +131,80 @@ public class MainHomeCommunityVideoFragment extends BaseFragment {
|
||||
}
|
||||
}
|
||||
});
|
||||
back = findViewById(R.id.back);
|
||||
back.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
showBackDialog();
|
||||
}
|
||||
});
|
||||
mWebView.setOnTouchListener(new View.OnTouchListener() {
|
||||
@Override
|
||||
public boolean onTouch(View v, MotionEvent event) {
|
||||
back.setVisibility(View.VISIBLE);
|
||||
if (timer != null) {
|
||||
timer.cancel();
|
||||
timer = null;
|
||||
}
|
||||
updateKnowledge();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
mWebView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
back.setVisibility(View.VISIBLE);
|
||||
if (timer != null) {
|
||||
timer.cancel();
|
||||
timer = null;
|
||||
}
|
||||
updateKnowledge();
|
||||
}
|
||||
});
|
||||
updateKnowledge();
|
||||
}
|
||||
|
||||
public void showBackDialog() {
|
||||
DialogUitl.showBackDialog(mContext, getString(R.string.community_back), getString(R.string.cancel), getString(R.string.back_community_sure), new DialogUitl.SimpleCallback() {
|
||||
@Override
|
||||
public void onConfirmClick(Dialog dialog, String content) {
|
||||
onDestroy();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttach(@NonNull Context context) {
|
||||
super.onAttach(context);
|
||||
requireActivity().getOnBackPressedDispatcher().addCallback(this, new OnBackPressedCallback(true) {
|
||||
@Override
|
||||
public void handleOnBackPressed() {
|
||||
showBackDialog();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void updateKnowledge() {
|
||||
timer = new Timer();
|
||||
timer.schedule(new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
getActivity().runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
back.setVisibility(View.GONE);
|
||||
isShow = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
}, 5 * 1000);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
getActivity().finish();
|
||||
}
|
||||
|
||||
private void copy(String content) {
|
||||
@ -143,20 +230,14 @@ public class MainHomeCommunityVideoFragment extends BaseFragment {
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onJavascriptInterfaceEvent2(JavascriptInterfaceEvent event) {
|
||||
if (TextUtils.equals(event.getMethod(), "postWeakBalance")) {
|
||||
LiveNetManager.get(mContext).
|
||||
getCoolConfig(new com.yunbao.common.http.base.HttpCallback<CoolConfig>() {
|
||||
LiveNetManager.get(mContext).getCoolConfig(new com.yunbao.common.http.base.HttpCallback<CoolConfig>() {
|
||||
@Override
|
||||
public void onSuccess(CoolConfig data) {
|
||||
new XPopup.Builder(mContext)
|
||||
.enableDrag(false)
|
||||
.autoOpenSoftInput(false)
|
||||
.maxWidth(DeviceUtils.getScreenHeight((Activity) mContext) - DpUtil.dp2px(34))
|
||||
.asCustom(new CinemaTicketPopupWindow(mContext, data.setTicketCount(event.getCoolConfig().getTicketCount()), new CinemaTicketPopupWindow.CinemaTicketPopupWindowCallBack() {
|
||||
new XPopup.Builder(mContext).enableDrag(false).autoOpenSoftInput(false).maxWidth(DeviceUtils.getScreenHeight((Activity) mContext) - DpUtil.dp2px(34)).asCustom(new CinemaTicketPopupWindow(mContext, data.setTicketCount(event.getCoolConfig().getTicketCount()), new CinemaTicketPopupWindow.CinemaTicketPopupWindowCallBack() {
|
||||
@Override
|
||||
public void onCallBack(String data) {
|
||||
if (TextUtils.equals(data, "2")) {
|
||||
DialogUitl.showSimpleDialog(mContext, mContext.getString(com.yunbao.live.R.string.live_coin_not_enough), false,
|
||||
new DialogUitl.SimpleCallback2() {
|
||||
DialogUitl.showSimpleDialog(mContext, mContext.getString(com.yunbao.live.R.string.live_coin_not_enough), false, new DialogUitl.SimpleCallback2() {
|
||||
@Override
|
||||
public void onConfirmClick(Dialog dialog, String content) {
|
||||
mContext.startActivity(new Intent(mContext, MyWalletActivity.class).putExtra("p", 1));
|
||||
@ -197,10 +278,12 @@ public class MainHomeCommunityVideoFragment extends BaseFragment {
|
||||
});
|
||||
}
|
||||
}
|
||||
public void onPausePlay(){
|
||||
|
||||
public void onPausePlay() {
|
||||
mWebView.onPause();
|
||||
}
|
||||
public void onResumePlay(){
|
||||
|
||||
public void onResumePlay() {
|
||||
mWebView.onResume();
|
||||
}
|
||||
}
|
||||
|
@ -120,7 +120,6 @@ public class MainHomeCommunityViewHolder extends AbsMainHomeChildViewHolder impl
|
||||
ViewPager2 viewPager;
|
||||
private MagicIndicator mIndicator;
|
||||
|
||||
|
||||
public MainHomeCommunityViewHolder(Context context, ViewGroup parentView, MainActivity mainActivity) {
|
||||
super(context, parentView);
|
||||
mContext = context;
|
||||
@ -198,9 +197,13 @@ public class MainHomeCommunityViewHolder extends AbsMainHomeChildViewHolder impl
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (viewPager != null) {
|
||||
if (index == 1) {
|
||||
RouteUtil.forwardCommunityActivity();
|
||||
} else {
|
||||
viewPager.setCurrentItem(index);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
return simplePagerTitleView;
|
||||
}
|
||||
@ -225,29 +228,30 @@ public class MainHomeCommunityViewHolder extends AbsMainHomeChildViewHolder impl
|
||||
}
|
||||
|
||||
public void onPauseVideo() {
|
||||
if(fragments==null || fragments.isEmpty()){
|
||||
if (fragments == null || fragments.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
BaseFragment fragment = fragments.get(viewPager.getCurrentItem());
|
||||
if(fragment==null){
|
||||
if (fragment == null) {
|
||||
return;
|
||||
}
|
||||
if (fragment instanceof MainHomeCommunityVideoFragment) {
|
||||
// viewPager.setCurrentItem(0, false);
|
||||
((MainHomeCommunityVideoFragment)fragment).onPausePlay();
|
||||
((MainHomeCommunityVideoFragment) fragment).onPausePlay();
|
||||
}
|
||||
}
|
||||
|
||||
public void onResumePlay() {
|
||||
if(fragments==null || fragments.isEmpty()){
|
||||
if (fragments == null || fragments.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
BaseFragment fragment = fragments.get(viewPager.getCurrentItem());
|
||||
if(fragment==null){
|
||||
if (fragment == null) {
|
||||
return;
|
||||
}
|
||||
if (fragment instanceof MainHomeCommunityVideoFragment) {
|
||||
// viewPager.setCurrentItem(0, false);
|
||||
((MainHomeCommunityVideoFragment)fragment).onResumePlay();
|
||||
((MainHomeCommunityVideoFragment) fragment).onResumePlay();
|
||||
}
|
||||
}
|
||||
|
||||
|
14
main/src/main/res/drawable/background_community_video.xml
Normal file
14
main/src/main/res/drawable/background_community_video.xml
Normal file
@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item>
|
||||
<shape android:shape="rectangle">
|
||||
<corners android:topLeftRadius="90dp"
|
||||
android:bottomLeftRadius="90dp" />
|
||||
<gradient
|
||||
android:startColor="#f0eff2"
|
||||
android:endColor="#f0eff2"
|
||||
android:angle="90"
|
||||
/>
|
||||
</shape>
|
||||
</item>
|
||||
</selector>
|
13
main/src/main/res/layout/activity_main_home_community.xml
Normal file
13
main/src/main/res/layout/activity_main_home_community.xml
Normal file
@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/color_white"
|
||||
android:orientation="vertical">
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/fragment"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
</RelativeLayout>
|
@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
@ -8,9 +8,32 @@
|
||||
android:id="@+id/webView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginBottom="68dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/back"
|
||||
android:layout_width="80dp"
|
||||
android:layout_height="30dp"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_marginTop="50dp"
|
||||
android:background="@drawable/background_community_video"
|
||||
android:gravity="center">
|
||||
|
||||
<ImageView
|
||||
android:src="@mipmap/icon_back_community"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<TextView
|
||||
android:layout_marginLeft="10dp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="@color/black1"
|
||||
android:text="@string/back" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</RelativeLayout>
|
BIN
main/src/main/res/mipmap-xxhdpi/icon_back_community.png
Normal file
BIN
main/src/main/res/mipmap-xxhdpi/icon_back_community.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.7 KiB |
Loading…
Reference in New Issue
Block a user