| | |
| | | import android.widget.FrameLayout; |
| | | import android.widget.TextView; |
| | | |
| | | import com.demo.lib.common.util.common.DimenUtils; |
| | | import com.demo.library_ad.AdUtil; |
| | | import com.demo.library_ad.ExpressAdManager; |
| | | import com.demo.library_ad.entity.ExpressAdContainer; |
| | | import com.yeshi.makemoney.video.R; |
| | | import com.demo.lib.common.util.SystemCommon; |
| | | |
| | | import java.util.List; |
| | | |
| | | |
| | | /** |
| | |
| | | return this; |
| | | } |
| | | |
| | | //是否展示过 |
| | | private boolean shown = false; |
| | | |
| | | public ExitDialog create() { |
| | | LayoutInflater inflater = (LayoutInflater) context |
| | | .getSystemService(Context.LAYOUT_INFLATER_SERVICE); |
| | |
| | | }); |
| | | } |
| | | |
| | | dialog.setOnShowListener(new OnShowListener() { |
| | | @Override |
| | | public void onShow(DialogInterface dialog) { |
| | | if (!shown) { |
| | | shown = true; |
| | | return; |
| | | } |
| | | //刷新广告 |
| | | loadAd(context, layout.findViewById(R.id.fl_ad)); |
| | | } |
| | | }); |
| | | |
| | | loadAd(context, layout.findViewById(R.id.fl_ad)); |
| | | |
| | | dialog.setContentView(layout); |
| | | |
| | | android.view.WindowManager.LayoutParams params = dialog.getWindow() |
| | |
| | | dialog.getWindow().setAttributes(params); |
| | | return dialog; |
| | | } |
| | | |
| | | private void loadAd(Activity activity, FrameLayout fl_ad) { |
| | | AdUtil.AD_TYPE adType = AdUtil.getAdType(context, "exitAppAd"); |
| | | if (adType == null) { |
| | | return; |
| | | } |
| | | |
| | | int width = (int) ((SystemCommon.getScreenWidth(context) * 3) / 4); |
| | | width = DimenUtils.px2dip(context, width); |
| | | int height = (int) (width * 0.56); |
| | | |
| | | String pid = (adType == AdUtil.AD_TYPE.csj ? context.getString(R.string.ad_csj_pid_exit) : context.getString(R.string.ad_gdt_pid_exit)); |
| | | |
| | | ExpressAdManager.getInstance(context).loadAd(width, height, pid, 1, adType, context, new ExpressAdManager.IAdLoadListener() { |
| | | |
| | | @Override |
| | | public void onSuccess(List<ExpressAdContainer> adList) { |
| | | if (adList != null && adList.size() > 0) { |
| | | ExpressAdContainer adContainer = adList.get(0); |
| | | ExpressAdManager.renderAndFillAd(activity, adContainer, fl_ad, new ExpressAdManager.IAdEventListener() { |
| | | |
| | | @Override |
| | | public void closeAd(ExpressAdContainer ad) { |
| | | fl_ad.removeAllViews(); |
| | | } |
| | | }); |
| | | } |
| | | } |
| | | }); |
| | | |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | public interface MeasureCallBack { |
| | | void onMeasure(int height); |
| | | } |