From a26b136430d859e482e7f8a7b2c385c5b279ecb7 Mon Sep 17 00:00:00 2001 From: 18401019693 Date: Wed, 27 Jul 2022 17:52:35 +0800 Subject: [PATCH] 11111 --- .../live/adapter/LivePromotionAdapter.java | 21 +++++---- .../yunbao/live/bean/LivePromotionBean.java | 11 ++++- .../live/dialog/LiveHDDialogFragment.java | 38 +++++++++++++-- live/src/main/res/layout/dialog_live_hd.xml | 47 +++++++++++++++++-- 4 files changed, 100 insertions(+), 17 deletions(-) diff --git a/live/src/main/java/com/yunbao/live/adapter/LivePromotionAdapter.java b/live/src/main/java/com/yunbao/live/adapter/LivePromotionAdapter.java index e4113592b..4bf30fa6c 100644 --- a/live/src/main/java/com/yunbao/live/adapter/LivePromotionAdapter.java +++ b/live/src/main/java/com/yunbao/live/adapter/LivePromotionAdapter.java @@ -2,13 +2,15 @@ package com.yunbao.live.adapter; import android.content.Context; import android.os.Bundle; -import androidx.annotation.NonNull; -import androidx.recyclerview.widget.RecyclerView; +import android.text.TextUtils; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.TextView; +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; + import com.yunbao.common.CommonAppConfig; import com.yunbao.common.adapter.RefreshAdapter; import com.yunbao.common.glide.ImgLoader; @@ -21,11 +23,12 @@ import com.yunbao.live.dialog.LivePromotionDialogFragment; public class LivePromotionAdapter extends RefreshAdapter { - String mLiveUid; + String mLiveUid; LivePromotionDialogFragment fs; + public LivePromotionAdapter(Context context, String mLiveUids, LivePromotionDialogFragment f) { super(context); - mLiveUid=mLiveUids; + mLiveUid = mLiveUids; this.fs = f; } @@ -60,7 +63,7 @@ public class LivePromotionAdapter extends RefreshAdapter { public Vh(@NonNull View itemView) { super(itemView); - text = (TextView)itemView.findViewById(R.id.text); + text = (TextView) itemView.findViewById(R.id.text); img = (ImageView) itemView.findViewById(R.id.img); } @@ -70,11 +73,13 @@ public class LivePromotionAdapter extends RefreshAdapter { itemView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - String url = CommonAppConfig.HOST +"/"+bean.getActive_src()+"?uid="+CommonAppConfig.getInstance().getUid()+"&token="+CommonAppConfig.getInstance().getToken() - +"&anchorUid="+mLiveUid - +"&active_id="+bean.getActive_id(); + String url = CommonAppConfig.HOST + "/" + bean.getActive_src() + "?uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + + "&anchorUid=" + mLiveUid + + "&active_id=" + bean.getActive_id(); Bundle bundle = new Bundle(); bundle.putString("url", url); + int show = TextUtils.isEmpty(bean.getShow_type()) ? 0 : Integer.parseInt(bean.getShow_type()); + bundle.putInt("show_type", show); LiveHDDialogFragment fragment = new LiveHDDialogFragment(); fragment.setArguments(bundle); fragment.show(((LiveAudienceActivity) mContext).getSupportFragmentManager(), "LiveHDDialogFragment"); diff --git a/live/src/main/java/com/yunbao/live/bean/LivePromotionBean.java b/live/src/main/java/com/yunbao/live/bean/LivePromotionBean.java index 232dc29cc..a5077c526 100644 --- a/live/src/main/java/com/yunbao/live/bean/LivePromotionBean.java +++ b/live/src/main/java/com/yunbao/live/bean/LivePromotionBean.java @@ -1,7 +1,7 @@ package com.yunbao.live.bean; public class LivePromotionBean { - String active_name, active_img, active_src,active_id; + String active_name, active_img, active_src, active_id, show_type; public String getActive_id() { return active_id; @@ -34,4 +34,13 @@ public class LivePromotionBean { public void setActive_src(String active_src) { this.active_src = active_src; } + + public String getShow_type() { + return show_type; + } + + public LivePromotionBean setShow_type(String show_type) { + this.show_type = show_type; + return this; + } } diff --git a/live/src/main/java/com/yunbao/live/dialog/LiveHDDialogFragment.java b/live/src/main/java/com/yunbao/live/dialog/LiveHDDialogFragment.java index 56ae4b51c..d968c591f 100644 --- a/live/src/main/java/com/yunbao/live/dialog/LiveHDDialogFragment.java +++ b/live/src/main/java/com/yunbao/live/dialog/LiveHDDialogFragment.java @@ -1,10 +1,15 @@ package com.yunbao.live.dialog; +import android.app.Dialog; +import android.graphics.Color; +import android.graphics.drawable.ColorDrawable; import android.os.Build; import android.os.Bundle; import android.text.TextUtils; +import android.util.DisplayMetrics; import android.util.Log; import android.view.Gravity; +import android.view.View; import android.view.Window; import android.view.WindowManager; import android.webkit.JavascriptInterface; @@ -20,7 +25,6 @@ import com.yunbao.common.Constants; import com.yunbao.common.bean.JsWishBean; import com.yunbao.common.dialog.AbsDialogFragment; import com.yunbao.common.utils.L; -import com.yunbao.common.utils.ToastUtil; import com.yunbao.live.R; import com.yunbao.live.activity.LiveActivity; import com.yunbao.live.activity.LiveAudienceActivity; @@ -33,6 +37,7 @@ import static com.yunbao.common.utils.RouteUtil.PATH_GOOGLE; public class LiveHDDialogFragment extends AbsDialogFragment { private WebView mWebView; + private int showType = 0; @Override protected int getLayoutId() { @@ -60,12 +65,29 @@ public class LiveHDDialogFragment extends AbsDialogFragment { window.setAttributes(params); } + @Override + public void onStart() { + super.onStart(); + Window window = getDialog().getWindow(); + window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); + WindowManager.LayoutParams windowParams = window.getAttributes(); + windowParams.dimAmount = 0.0f; + windowParams.y = 100; + window.setAttributes(windowParams); + Dialog dialog = getDialog(); + if (dialog != null) { + DisplayMetrics dm = new DisplayMetrics(); + getActivity().getWindowManager().getDefaultDisplay().getMetrics(dm); + dialog.getWindow().setLayout((int) (dm.widthPixels), (int) (dm.heightPixels * (showType == 0 ? 0.5 : 1))); + } + } @Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); mWebView = (WebView) findViewById(R.id.rlWebview); + findViewById(R.id.btn_back).setOnClickListener(v -> dismiss()); mWebView.addJavascriptInterface(new JsInteration(), "androidObject"); mWebView.getSettings().setJavaScriptEnabled(true); mWebView.getSettings().setDomStorageEnabled(true); @@ -85,6 +107,12 @@ public class LiveHDDialogFragment extends AbsDialogFragment { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { mWebView.getSettings().setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW); } + showType = bundle.getInt("show_type"); + if (showType==0){ + findViewById(R.id.title_laout).setVisibility(View.GONE); + }else { + findViewById(R.id.title_laout).setVisibility(View.VISIBLE); + } mWebView.loadUrl(bundle.getString("url")); mWebView.setWebViewClient(new WebViewClient() { @Override @@ -172,11 +200,11 @@ public class LiveHDDialogFragment extends AbsDialogFragment { public void onTrickerySendGiftInto(JsWishBean id) { Log.i("tvs", "來了" + id); - if (id!=null){ + if (id != null) { dismiss(); - Log.i("tvs","來了111"+id); - if (mContext instanceof LiveAudienceActivity){ - Log.i("tvs","來了333"+id); + Log.i("tvs", "來了111" + id); + if (mContext instanceof LiveAudienceActivity) { + Log.i("tvs", "來了333" + id); ((LiveAudienceActivity) mContext).openGiftWindow(id.getGiftId(), "1"); } } diff --git a/live/src/main/res/layout/dialog_live_hd.xml b/live/src/main/res/layout/dialog_live_hd.xml index 2f3bcd7ef..498b00292 100644 --- a/live/src/main/res/layout/dialog_live_hd.xml +++ b/live/src/main/res/layout/dialog_live_hd.xml @@ -1,12 +1,53 @@ - + android:background="@color/white" + android:layout_height="50dp"> + + + + + + + + + + \ No newline at end of file