diff --git a/common/src/main/java/com/yunbao/common/activity/WebViewActivity.java b/common/src/main/java/com/yunbao/common/activity/WebViewActivity.java index dcafa85a8..aeec0100e 100644 --- a/common/src/main/java/com/yunbao/common/activity/WebViewActivity.java +++ b/common/src/main/java/com/yunbao/common/activity/WebViewActivity.java @@ -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(); } } diff --git a/common/src/main/java/com/yunbao/common/utils/DialogUitl.java b/common/src/main/java/com/yunbao/common/utils/DialogUitl.java index a297704d7..e2d3f7056 100644 --- a/common/src/main/java/com/yunbao/common/utils/DialogUitl.java +++ b/common/src/main/java/com/yunbao/common/utils/DialogUitl.java @@ -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); diff --git a/common/src/main/java/com/yunbao/common/utils/JavascriptInterfaceUtils.java b/common/src/main/java/com/yunbao/common/utils/JavascriptInterfaceUtils.java index 33048d9ce..781507ddd 100644 --- a/common/src/main/java/com/yunbao/common/utils/JavascriptInterfaceUtils.java +++ b/common/src/main/java/com/yunbao/common/utils/JavascriptInterfaceUtils.java @@ -683,4 +683,9 @@ public class JavascriptInterfaceUtils { ToastUtil.showDebug("网页跳客服页面"); RouteUtil.forwardCustomerService(url); } + + @JavascriptInterface + public void androidtoCommunityVideo() { + RouteUtil.forwardCommunityActivity(); + } } diff --git a/common/src/main/java/com/yunbao/common/utils/RouteUtil.java b/common/src/main/java/com/yunbao/common/utils/RouteUtil.java index b81b0855f..281357214 100644 --- a/common/src/main/java/com/yunbao/common/utils/RouteUtil.java +++ b/common/src/main/java/com/yunbao/common/utils/RouteUtil.java @@ -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) diff --git a/common/src/main/res/values-en-rUS/string.xml b/common/src/main/res/values-en-rUS/string.xml index 1a4af54ee..b98e1dc22 100644 --- a/common/src/main/res/values-en-rUS/string.xml +++ b/common/src/main/res/values-en-rUS/string.xml @@ -628,7 +628,7 @@ accept whole Album - cancel + Cancel camera Picture selection/Preview Preview @@ -1447,4 +1447,7 @@ Limited ride And limited avatar frame Mute Cancel + Are you sure to return? + + Sure diff --git a/common/src/main/res/values-zh-rHK/strings.xml b/common/src/main/res/values-zh-rHK/strings.xml index d10050f16..2c04fb7e0 100644 --- a/common/src/main/res/values-zh-rHK/strings.xml +++ b/common/src/main/res/values-zh-rHK/strings.xml @@ -1445,4 +1445,8 @@ 直播通行證 取消 + + 是否確認返回? + + 確定 diff --git a/common/src/main/res/values-zh-rTW/strings.xml b/common/src/main/res/values-zh-rTW/strings.xml index 1018b7ee1..6698c9652 100644 --- a/common/src/main/res/values-zh-rTW/strings.xml +++ b/common/src/main/res/values-zh-rTW/strings.xml @@ -1445,4 +1445,8 @@ 取消 + 是否確認返回? + + 確定 + diff --git a/common/src/main/res/values-zh/strings.xml b/common/src/main/res/values-zh/strings.xml index 7649f4799..894b5492a 100644 --- a/common/src/main/res/values-zh/strings.xml +++ b/common/src/main/res/values-zh/strings.xml @@ -1442,4 +1442,8 @@ 取消 + 是否確認返回? + + 確定 + diff --git a/common/src/main/res/values/strings.xml b/common/src/main/res/values/strings.xml index e40c4c050..015c07bf9 100644 --- a/common/src/main/res/values/strings.xml +++ b/common/src/main/res/values/strings.xml @@ -1451,4 +1451,8 @@ Limited ride And limited avatar frame Cancel + Are you sure to return? + + Sure + diff --git a/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java b/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java index e36ded9ed..934bcb316 100644 --- a/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java +++ b/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java @@ -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(); } } } diff --git a/live/src/main/java/com/yunbao/live/dialog/LiveGameDialogFragment.java b/live/src/main/java/com/yunbao/live/dialog/LiveGameDialogFragment.java index ea5cc7968..6bda7e903 100644 --- a/live/src/main/java/com/yunbao/live/dialog/LiveGameDialogFragment.java +++ b/live/src/main/java/com/yunbao/live/dialog/LiveGameDialogFragment.java @@ -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(); } } } diff --git a/main/src/main/AndroidManifest.xml b/main/src/main/AndroidManifest.xml index f5524761c..eff290185 100644 --- a/main/src/main/AndroidManifest.xml +++ b/main/src/main/AndroidManifest.xml @@ -159,6 +159,9 @@ + + \ No newline at end of file diff --git a/main/src/main/java/com/yunbao/main/activity/MainHomeCommunityActivity.java b/main/src/main/java/com/yunbao/main/activity/MainHomeCommunityActivity.java new file mode 100644 index 000000000..084ac2870 --- /dev/null +++ b/main/src/main/java/com/yunbao/main/activity/MainHomeCommunityActivity.java @@ -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(); + } + +} diff --git a/main/src/main/java/com/yunbao/main/fragment/MainHomeCommunityVideoFragment.java b/main/src/main/java/com/yunbao/main/fragment/MainHomeCommunityVideoFragment.java index 0727bf0ca..f2db90261 100644 --- a/main/src/main/java/com/yunbao/main/fragment/MainHomeCommunityVideoFragment.java +++ b/main/src/main/java/com/yunbao/main/fragment/MainHomeCommunityVideoFragment.java @@ -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,64 +230,60 @@ 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() { + LiveNetManager.get(mContext).getCoolConfig(new com.yunbao.common.http.base.HttpCallback() { + @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() { @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() { - @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() { - @Override - public void onConfirmClick(Dialog dialog, String content) { - mContext.startActivity(new Intent(mContext, MyWalletActivity.class).putExtra("p", 1)); - } + 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() { + @Override + public void onConfirmClick(Dialog dialog, String content) { + mContext.startActivity(new Intent(mContext, MyWalletActivity.class).putExtra("p", 1)); + } - @Override - public void onCancelClick() { + @Override + public void onCancelClick() { - } - }); - } else if (TextUtils.equals(data, "1")) { - ToastUtil.show(WordUtil.isNewZh() ? "兑换成功" : "Successful exchange"); - mWebView.post(new Runnable() { - @Override - public void run() { + } + }); + } else if (TextUtils.equals(data, "1")) { + ToastUtil.show(WordUtil.isNewZh() ? "兑换成功" : "Successful exchange"); + mWebView.post(new Runnable() { + @Override + public void run() { - NativeCallbackModel model = new NativeCallbackModel(); - model.setUid(String.valueOf(IMLoginManager.get(mContext).getUserInfo().getId())); - String nativeJson = new JsonUtil().toJson(model); - mWebView.evaluateJavascript("javascript:nativeCallback('" + nativeJson + "')", new ValueCallback() { - @Override - public void onReceiveValue(String value) { - } - }); - - } - }); + NativeCallbackModel model = new NativeCallbackModel(); + model.setUid(String.valueOf(IMLoginManager.get(mContext).getUserInfo().getId())); + String nativeJson = new JsonUtil().toJson(model); + mWebView.evaluateJavascript("javascript:nativeCallback('" + nativeJson + "')", new ValueCallback() { + @Override + public void onReceiveValue(String value) { } + }); - } - })).show(); - } + } + }); + } - @Override - public void onError(String error) { - ToastUtil.show(error); } - }); + })).show(); + } + + @Override + public void onError(String error) { + ToastUtil.show(error); + } + }); } } - public void onPausePlay(){ + + public void onPausePlay() { mWebView.onPause(); } - public void onResumePlay(){ + + public void onResumePlay() { mWebView.onResume(); } } diff --git a/main/src/main/java/com/yunbao/main/views/MainHomeCommunityViewHolder.java b/main/src/main/java/com/yunbao/main/views/MainHomeCommunityViewHolder.java index 6145f2eab..d1f7c1869 100644 --- a/main/src/main/java/com/yunbao/main/views/MainHomeCommunityViewHolder.java +++ b/main/src/main/java/com/yunbao/main/views/MainHomeCommunityViewHolder.java @@ -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,7 +197,11 @@ public class MainHomeCommunityViewHolder extends AbsMainHomeChildViewHolder impl @Override public void onClick(View v) { if (viewPager != null) { - viewPager.setCurrentItem(index); + if (index == 1) { + RouteUtil.forwardCommunityActivity(); + } else { + viewPager.setCurrentItem(index); + } } } }); @@ -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){ - return; - } - if (fragment instanceof MainHomeCommunityVideoFragment) { - // viewPager.setCurrentItem(0, false); - ((MainHomeCommunityVideoFragment)fragment).onPausePlay(); - } - } - public void onResumePlay() { - 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).onPausePlay(); + } + } + + public void onResumePlay() { + if (fragments == null || fragments.isEmpty()) { + return; + } + BaseFragment fragment = fragments.get(viewPager.getCurrentItem()); + if (fragment == null) { + return; + } + if (fragment instanceof MainHomeCommunityVideoFragment) { + // viewPager.setCurrentItem(0, false); + ((MainHomeCommunityVideoFragment) fragment).onResumePlay(); } } diff --git a/main/src/main/res/drawable/background_community_video.xml b/main/src/main/res/drawable/background_community_video.xml new file mode 100644 index 000000000..bd4dede01 --- /dev/null +++ b/main/src/main/res/drawable/background_community_video.xml @@ -0,0 +1,14 @@ + + + + + + + + + \ No newline at end of file diff --git a/main/src/main/res/layout/activity_main_home_community.xml b/main/src/main/res/layout/activity_main_home_community.xml new file mode 100644 index 000000000..d985944f4 --- /dev/null +++ b/main/src/main/res/layout/activity_main_home_community.xml @@ -0,0 +1,13 @@ + + + + + + \ No newline at end of file diff --git a/main/src/main/res/layout/view_main_community_video.xml b/main/src/main/res/layout/view_main_community_video.xml index 4c0f7fb70..489591c49 100644 --- a/main/src/main/res/layout/view_main_community_video.xml +++ b/main/src/main/res/layout/view_main_community_video.xml @@ -1,5 +1,5 @@ - @@ -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" /> - \ No newline at end of file + + + + + + + + + + \ No newline at end of file diff --git a/main/src/main/res/mipmap-xxhdpi/icon_back_community.png b/main/src/main/res/mipmap-xxhdpi/icon_back_community.png new file mode 100644 index 000000000..936cad37b Binary files /dev/null and b/main/src/main/res/mipmap-xxhdpi/icon_back_community.png differ