This commit is contained in:
18401019693 2022-07-27 17:52:35 +08:00
parent 966e8bbddb
commit a26b136430
4 changed files with 100 additions and 17 deletions

View File

@ -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;
@ -23,6 +25,7 @@ public class LivePromotionAdapter extends RefreshAdapter<LivePromotionBean> {
String mLiveUid;
LivePromotionDialogFragment fs;
public LivePromotionAdapter(Context context, String mLiveUids, LivePromotionDialogFragment f) {
super(context);
mLiveUid = mLiveUids;
@ -75,6 +78,8 @@ public class LivePromotionAdapter extends RefreshAdapter<LivePromotionBean> {
+ "&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");

View File

@ -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;
}
}

View File

@ -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

View File

@ -1,12 +1,53 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical">
<WebView android:id="@+id/rlWebview"
<RelativeLayout
android:id="@+id/title_laout"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
android:background="@color/white"
android:layout_height="50dp">
<TextView
android:id="@+id/titleView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerHorizontal="true"
android:gravity="center"
android:textColor="@color/textColor"
android:textSize="18sp"
android:textStyle="bold" />
<ImageView
android:id="@+id/btn_back"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_centerVertical="true"
android:onClick="backClick"
android:padding="9dp"
android:src="@mipmap/icon_back"
android:tint="@color/textColor" />
<ImageView
android:id="@+id/img_more"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:padding="9dp"
android:src="@mipmap/btn_more_black"
android:tint="@color/textColor"
android:visibility="gone" />
</RelativeLayout>
<WebView
android:id="@+id/rlWebview"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"/>
</LinearLayout>