Commit ecf43840 authored by jyx's avatar jyx

Merge branch 'dev_kyl' into dev_ad

parents 6fb2b3a3 69c52606
......@@ -269,6 +269,9 @@ dependencies {
// 快手
implementation(name: 'kssdk-ad-3.3.6-publishRelease', ext: 'aar')
// 抖音滑动LayoutManager
implementation(name: 'LayoutManagerGroup', ext: 'aar')
// testImplementation 'junit:junit:4.13'
// androidTestImplementation 'androidx.test.ext:junit:1.1.2'
// androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
......
......@@ -222,6 +222,9 @@
<activity
android:name=".ui.activitys.TaskCpdActivity"
android:screenOrientation="portrait" />
<activity
android:name=".ui.activitys.DrawNativeVideoActivity"
android:screenOrientation="portrait" />
<activity
android:name=".ui.activitys.KylVideoActivity"
android:configChanges="orientation|screenSize|keyboardHidden"
......
......@@ -10,7 +10,6 @@ import com.downloader.PRDownloader
import com.downloader.PRDownloaderConfig
import com.mints.goodmoney.manager.BxmManager.initBxm
import com.mob.MobSDK
import com.tencent.mm.opensdk.openapi.WXAPIFactory
/**
* 子线程初始化SDK
......
package com.mints.goodmoney.ad.draw
import android.app.Activity
import com.bytedance.sdk.openadsdk.AdSlot
import com.bytedance.sdk.openadsdk.TTAdNative
import com.bytedance.sdk.openadsdk.TTNativeExpressAd
import com.bytedance.sdk.openadsdk.TTRewardVideoAd
import com.mints.goodmoney.manager.TTNativeExpressManager
import com.mints.goodmoney.manager.TtCsjAdManager
import com.mints.goodmoney.utils.LogUtil
import com.mints.goodmoney.utils.UIUtils
class CsjDrawAdManager private constructor(activity: Activity) {
companion object {
private var _inst: CsjDrawAdManager? = null
fun getInstance(activity: Activity): CsjDrawAdManager? {
return if (_inst != null) {
_inst
} else {
_inst = CsjDrawAdManager(activity)
_inst
}
}
}
private var activity: Activity? = null
private var ttAdNative: TTAdNative? = null
private var mttRewardVideoAd: TTRewardVideoAd? = null
private var csjDrawAdListener: CsjDrawAdListener? = null
init {
this.activity = activity
val ttNativeExpressManager = TTNativeExpressManager()
ttAdNative = ttNativeExpressManager.initTTAd(false)
}
fun loadDrawNativeAd(activity: Activity, adCount: Int) {
this.activity = activity
//step3:创建广告请求参数AdSlot,具体参数含义参考文档
val expressViewWidth: Float = UIUtils.getScreenWidthDp(activity)
val expressViewHeight: Float = UIUtils.getHeight(activity)
val adSlot = AdSlot.Builder()
.setCodeId(TtCsjAdManager.TT_AD_EXPRESS_DRAW)
.setExpressViewAcceptedSize(expressViewWidth, expressViewHeight)
.setAdCount(adCount) //请求广告数量为1到3条
.build()
mttRewardVideoAd?.setRewardAdInteractionListener(null)
//step4:请求广告,对请求回调的广告作渲染处理
ttAdNative?.loadExpressDrawFeedAd(adSlot, object : TTAdNative.NativeExpressAdListener {
override fun onError(p0: Int, p1: String?) {
// ToastUtil.show(activity, p1)
LogUtil.d(p1)
this@CsjDrawAdManager.csjDrawAdListener?.csjDrawAdFail()
}
override fun onNativeExpressAdLoad(p0: MutableList<TTNativeExpressAd>?) {
if (p0 == null || p0.isEmpty()) {
// ToastUtil.show(activity, "未请求到广告")
this@CsjDrawAdManager.csjDrawAdListener?.csjDrawAdFail()
LogUtil.d("未请求到广告")
return
}
this@CsjDrawAdManager.csjDrawAdListener?.csjDrawAdSuccess(p0)
}
})
}
fun setCsjDrawAdListener(csjDrawAdListener: CsjDrawAdListener?) {
this.csjDrawAdListener = csjDrawAdListener
}
interface CsjDrawAdListener {
fun csjDrawAdFail()
fun csjDrawAdSuccess(data: MutableList<TTNativeExpressAd>?)
}
fun onDestroy() {
this.csjDrawAdListener = null
mttRewardVideoAd?.setRewardAdInteractionListener(null)
activity = null
}
}
\ No newline at end of file
......@@ -108,7 +108,9 @@ object DownloadApkManager {
.build()
.setOnProgressListener { progress ->
if (activity != null && !activity!!.isFinishing) {
downloadProgressDialog?.setProgress(progress)
activity!!.runOnUiThread {
downloadProgressDialog?.setProgress(progress)
}
}
}
.start(object : OnDownloadListener {
......@@ -126,7 +128,7 @@ object DownloadApkManager {
}
override fun onError(error: Error) {
if (activity != null && !activity!!.isFinishing()) {
if (activity != null && !activity!!.isFinishing) {
downloadProgressDialog?.dismiss()
CacheUtil.clearAllCache()
}
......
package com.mints.goodmoney.manager;
import android.content.Context;
import android.text.TextUtils;
import com.bytedance.sdk.openadsdk.TTAdConfig;
import com.bytedance.sdk.openadsdk.TTAdConstant;
import com.bytedance.sdk.openadsdk.TTAdSdk;
import com.mints.goodmoney.BuildConfig;
import com.mints.goodmoney.MintsApplication;
import com.mints.goodmoney.common.AppConfig;
import com.mints.goodmoney.common.Constant;
import com.mints.goodmoney.mvp.model.AdcodeBean;
import com.mints.goodmoney.mvp.model.UserMsgBean;
import com.mints.library.utils.CommonUtils;
/**
......@@ -59,6 +56,9 @@ public class TtCsjAdManager {
public static String TT_AD_INSERT_LOADING_ID_LIEBAO = "945608874";//猎豹游戏加载时
public static String TT_AD_INSERT_LOADING_ID_JULEYUN = "945675533";//聚乐云
/*全屏Draw信息流*/
public static String TT_AD_EXPRESS_DRAW = "945858858";//讯飞信息流
private static boolean sInit;
public static com.bytedance.sdk.openadsdk.TTAdManager get() {
......
package com.mints.goodmoney.mvp.model;
import android.os.Parcel;
import android.os.Parcelable;
import com.bytedance.sdk.openadsdk.TTNativeExpressAd;
public class DrawVideoBean implements Parcelable {
public int type = 0;
public TTNativeExpressAd ad;
public String videoId;
public String videoUrl;
public String ImgId;
public DrawVideoBean(int type, TTNativeExpressAd ad, String videoId, String videoUrl, String imgId) {
this.type = type;
this.ad = ad;
this.videoId = videoId;
this.videoUrl = videoUrl;
ImgId = imgId;
}
protected DrawVideoBean(Parcel in) {
type = in.readInt();
videoId = in.readString();
videoUrl = in.readString();
ImgId = in.readString();
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeInt(type);
dest.writeString(videoId);
dest.writeString(videoUrl);
dest.writeString(ImgId);
}
@Override
public int describeContents() {
return 0;
}
public static final Creator<DrawVideoBean> CREATOR = new Creator<DrawVideoBean>() {
@Override
public DrawVideoBean createFromParcel(Parcel in) {
return new DrawVideoBean(in);
}
@Override
public DrawVideoBean[] newArray(int size) {
return new DrawVideoBean[size];
}
};
}
......@@ -3,6 +3,7 @@ package com.mints.goodmoney.mvp.presenters
import com.google.gson.JsonObject
import com.mints.goodmoney.manager.AppHttpManager
import com.mints.goodmoney.mvp.model.BaseResponse
import com.mints.goodmoney.mvp.model.KylBean
import com.mints.goodmoney.mvp.views.KylVideoView
import com.mints.library.net.neterror.BaseSubscriber
import com.mints.library.net.neterror.Throwable
......@@ -10,6 +11,36 @@ import java.util.*
class KylVideoPresenter : BasePresenter<KylVideoView>() {
fun getXfPageMsg(targetid:String,page: Int,pageCount: Int) {
val vo = HashMap<String, Any>()
vo["targetid"] = targetid
vo["page"] = page
vo["size"] = pageCount
AppHttpManager.getInstance(loanApplication)
.call(loanService.getXfPageMsg(vo),
object : BaseSubscriber<BaseResponse<KylBean>>() {
override fun onCompleted() {
}
override fun onError(e: Throwable) {
if (isLinkView) return
view.getXfPageMsgFail()
}
override fun onNext(baseResponse: BaseResponse<KylBean>) {
if (isLinkView) return
val code = baseResponse.getStatus()
when (code) {
200 -> {
view.getXfPageMsgSuc(baseResponse.data)
}
else -> view.showToast(baseResponse.getMessage())
}
}
})
}
fun addReadSeconds(seconds: Int) {
val vo = HashMap<String, Any>()
vo["seconds"] = seconds
......
package com.mints.goodmoney.mvp.views
import com.mints.goodmoney.mvp.model.KylBean
interface KylVideoView : BaseView {
interface KylVideoView : BaseView {
fun getXfPageMsgSuc(data: KylBean)
fun getXfPageMsgFail()
}
\ No newline at end of file
......@@ -374,9 +374,14 @@ class AwardActivity : BaseActivity(), AwardView, View.OnClickListener {
}
override fun onDestroy() {
super.onDestroy()
AppConfig.isSuperTask = false
if (mReceiverBroadcastReceiver != null) {
mContext.stopService(Intent(context, AppInstallService::class.java))
mContext.unregisterReceiver(mReceiverBroadcastReceiver)
mReceiverBroadcastReceiver = null
}
awardPresenter.setHighTaskType("0")
mTimer?.stop()
......@@ -395,14 +400,9 @@ class AwardActivity : BaseActivity(), AwardView, View.OnClickListener {
videoAdingManager.setVideoAdingListener(null)
videoAdingManager.onDestory()
if (mReceiverBroadcastReceiver != null) {
mContext.stopService(Intent(context, AppInstallService::class.java))
mContext.unregisterReceiver(mReceiverBroadcastReceiver)
mReceiverBroadcastReceiver = null
}
awardPresenter.detachView()
super.onDestroy()
}
override fun onKeyDown(keyCode: Int, event: KeyEvent): Boolean {
......
......@@ -16,6 +16,7 @@ import com.mints.goodmoney.call.permission.PermissionActivity
import com.mints.goodmoney.call.permission.PermissionManager
import com.mints.goodmoney.common.Constant
import com.mints.goodmoney.manager.UserManager
import com.mints.goodmoney.mvp.model.KylBean
import com.mints.goodmoney.mvp.model.VideoAdingBean
import com.mints.goodmoney.mvp.presenters.KylVideoPresenter
import com.mints.goodmoney.mvp.views.KylVideoView
......@@ -133,11 +134,10 @@ class KylVideoActivity : BaseActivity(), View.OnClickListener, KylVideoView {
private fun downloadVedioToCacheFile() {
downloadVedioSucFlag = false
var vedioPath = ""
try {
vedioPath = getExternalFilesDir(null)!!.absolutePath + "/video/"
var vedioPath: String = try {
getExternalFilesDir(null)!!.absolutePath + "/video/"
} catch (e: java.lang.Exception) {
vedioPath = filesDir.absolutePath + "/video/"
filesDir.absolutePath + "/video/"
}
val vedioName = MD5.GetMD5Code(System.currentTimeMillis().toString() + UserManager.getInstance().userID + videoUrl) + ".mp4"
vedioPathName = vedioPath + vedioName
......@@ -225,4 +225,10 @@ class KylVideoActivity : BaseActivity(), View.OnClickListener, KylVideoView {
PermissionActivity.startSelf(this)
}
}
override fun getXfPageMsgSuc(data: KylBean) {
}
override fun getXfPageMsgFail() {
}
}
package com.mints.goodmoney.ui.adapter
import android.content.Context
import android.net.Uri
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.*
import androidx.recyclerview.widget.RecyclerView
import com.mints.goodmoney.R
import com.mints.goodmoney.call.widget.CustomVideoView
import com.mints.goodmoney.mvp.model.DrawVideoBean
import com.mints.goodmoney.ui.activitys.DrawNativeVideoActivity
import com.mints.goodmoney.ui.adapter.listener.OnItemClickListener
import com.mints.library.utils.GlideUtils
class DrawVideoAdapter(context: Context, datas: List<DrawVideoBean>) : RecyclerView.Adapter<RecyclerView.ViewHolder>() {
private var mContext: Context = context
private var mDrawVideoData: List<DrawVideoBean> = datas
private var mOnItemClickListener: OnItemClickListener? = null
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
val view = LayoutInflater.from(mContext).inflate(R.layout.item_view_pager, parent, false)
return ViewHolder(view)
}
override fun getItemViewType(position: Int): Int {
return mDrawVideoData[position].type
}
override fun onBindViewHolder(viewHolder: RecyclerView.ViewHolder, position: Int) {
val holder = viewHolder as ViewHolder
var view: View? = View(mContext)
val item: DrawVideoBean? = mDrawVideoData[position]
if (item?.type == DrawNativeVideoActivity.TYPE_COMMON_ITEM) {
GlideUtils.loadImageView(mContext, item.ImgId, holder.img_thumb)
view = getView()
(view as VideoView).setVideoURI(Uri.parse(mDrawVideoData[position].videoUrl))
} else if (item?.type == DrawNativeVideoActivity.TYPE_AD_ITEM && item.ad != null) {
view = item.ad.expressAdView
}
holder.videoLayout.removeAllViews()
if (view?.parent != null) {
(view.parent as ViewGroup).removeView(view)
}
holder.videoLayout.addView(view)
if (item != null) {
changeUIVisibility(holder, item.type)
}
}
private fun changeUIVisibility(holder: ViewHolder, type: Int) {
var visibilable = true
if (type == DrawNativeVideoActivity.TYPE_AD_ITEM) {
visibilable = false
}
holder.img_play.visibility = if (visibilable) View.VISIBLE else View.GONE
holder.img_thumb.visibility = if (visibilable) View.VISIBLE else View.GONE
}
private fun getView(): View {
val videoView = CustomVideoView(mContext)
val layoutParams = FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT)
videoView.layoutParams = layoutParams
return videoView
}
override fun getItemCount(): Int {
return mDrawVideoData.size
}
inner class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
val img_thumb: ImageView = itemView.findViewById(R.id.img_thumb)
val img_play: ImageView = itemView.findViewById(R.id.img_play)
val rootView: RelativeLayout = itemView.findViewById(R.id.root_view)
val videoLayout: FrameLayout = itemView.findViewById(R.id.video_layout)
}
fun setOnItemClickListener(listener: OnItemClickListener) {
mOnItemClickListener = listener
}
}
\ No newline at end of file
......@@ -168,14 +168,15 @@ class KylPageAdapter(val kylPageList: MutableList<KylBean.Data>) :
private fun bindDislikeCustom(dislike: View, ad: TTFeedAd) {
val ttAdDislike = ad.getDislikeDialog(context as Activity?)
if (ttAdDislike != null) {
ad.getDislikeDialog(context as Activity?).setDislikeInteractionCallback(object : DislikeInteractionCallback {
override fun onSelected(position: Int, value: String) {
}
override fun onCancel() {}
override fun onRefuse() {}
})
}
// if (ttAdDislike != null) {
// ad.getDislikeDialog(context as Activity?).setDislikeInteractionCallback(object : DislikeInteractionCallback {
// override fun onSelected(position: Int, value: String) {
// }
// override fun onCancel() {}
// override fun onRefuse() {}
// })
// }
dislike.setOnClickListener { ttAdDislike!!.showDislikeDialog() }
}
......
......@@ -5,10 +5,11 @@ import androidx.recyclerview.widget.GridLayoutManager
import com.bytedance.sdk.openadsdk.*
import com.mints.goodmoney.R
import com.mints.goodmoney.manager.TtCsjAdManager
import com.mints.goodmoney.mvp.model.DrawVideoBean
import com.mints.goodmoney.mvp.model.KylBean
import com.mints.goodmoney.mvp.presenters.KuYinYuePagePresenter
import com.mints.goodmoney.mvp.views.KuYinYuePageView
import com.mints.goodmoney.ui.activitys.KylVideoActivity
import com.mints.goodmoney.ui.activitys.DrawNativeVideoActivity
import com.mints.goodmoney.ui.adapter.KylPageAdapter
import com.mints.goodmoney.ui.fragment.base.LazyLoadBaseFragment
import com.mints.goodmoney.utils.LogUtil
......@@ -62,11 +63,27 @@ class KuYinYuePageFragment(private val targetid: String) : LazyLoadBaseFragment(
}
override fun onItemClick(position: Int) {
if (kylData != null && kylData.size > 0) {
if (kylData.size > 0) {
// val bundle = Bundle()
// bundle.putString(KylVideoActivity.VIDEO_URL, kylData[position].url)
// bundle.putString(KylVideoActivity.VIDEO_ID, kylData[position].vedioId)
// readyGo(KylVideoActivity::class.java, bundle)
val dataList = arrayListOf<DrawVideoBean>()
val index = position % PAGE_SIZE // 余数
for (i in position until PAGE_SIZE * curPage) {
dataList.add(DrawVideoBean(DrawNativeVideoActivity.TYPE_COMMON_ITEM, null,
kylData[index / PAGE_SIZE + i].vedioId,
kylData[index / PAGE_SIZE + i].url,
kylData[index / PAGE_SIZE + i].pvurl))
}
val bundle = Bundle()
bundle.putString(KylVideoActivity.VIDEO_URL, kylData[position].url)
bundle.putString(KylVideoActivity.VIDEO_ID, kylData[position].vedioId)
readyGo(KylVideoActivity::class.java, bundle)
bundle.putParcelableArrayList(DrawNativeVideoActivity.VIDEO_DATA, dataList)
bundle.putInt(DrawNativeVideoActivity.CURRENT_PAGE, curPage)
bundle.putString(DrawNativeVideoActivity.TARGET_ID, targetid)
readyGo(DrawNativeVideoActivity::class.java, bundle)
}
}
......@@ -156,7 +173,7 @@ class KuYinYuePageFragment(private val targetid: String) : LazyLoadBaseFragment(
}
override fun onFeedAdLoad(ads: List<TTFeedAd>) {
if (ads == null || ads.isEmpty()) {
if (ads.isEmpty()) {
getXfPageMsg()
return
}
......
......@@ -652,7 +652,7 @@ class MainFragment : BaseFragment(), HomeView, View.OnClickListener {
mRedBoxTimer?.setOnCountDownTimerListener(object : OnCountDownTimerListener {
override fun onTick(millisUntilFinished: Long) {
if (isAdded && !requireActivity().isFinishing) {
stopRedbox()
// stopRedbox()
tv_fragment_main_redbox.text = TimeRender.ms2MS(millisUntilFinished.toInt())
}
}
......
......@@ -10,7 +10,6 @@ import android.widget.ImageView
import android.widget.TextView
import com.downloader.PRDownloader
import com.downloader.Progress
import com.mints.goodmoney.MintsApplication
import com.mints.goodmoney.R
import com.mints.goodmoney.utils.CacheUtil
import com.mints.goodmoney.utils.Utils
......
......@@ -26,9 +26,11 @@ import androidx.core.content.ContextCompat;
import android.provider.Settings;
import android.text.TextUtils;
import android.view.DisplayCutout;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowInsets;
import android.view.WindowManager;
import android.view.accessibility.AccessibilityManager;
......
<vector android:alpha="0.61" android:height="24dp"
android:viewportHeight="24.0" android:viewportWidth="24.0"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#99ffffff" android:pathData="M8,5v14l11,-7z"/>
</vector>
<?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/black">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recy_draw_native"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/ivBack"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_marginStart="5dp"
android:layout_marginTop="20dp"
android:padding="12dp"
android:src="@mipmap/ic_left_arrow" />
<TextView
android:id="@+id/ivVedio"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_alignParentBottom="true"
android:layout_marginLeft="50dp"
android:layout_marginRight="50dp"
android:layout_marginBottom="100dp"
android:background="@drawable/shape_tv_gold"
android:gravity="center"
android:text="设为视频彩铃"
android:textColor="@color/white" />
<TextView
android:id="@+id/ivSetting"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_alignParentBottom="true"
android:layout_marginLeft="50dp"
android:layout_marginRight="50dp"
android:layout_marginBottom="40dp"
android:background="@drawable/shape_tv_gold"
android:gravity="center"
android:text="看广告设置来电秀"
android:textColor="@color/white" />
</RelativeLayout>
</RelativeLayout>
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/root_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/black">
<FrameLayout
android:id="@+id/video_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clickable="false"
android:focusable="false" />
<ImageView
android:id="@+id/img_play"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_centerInParent="true"
android:alpha="0"
android:clickable="false"
android:focusable="false"
android:src="@drawable/play_arrow" />
<ImageView
android:id="@+id/img_thumb"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clickable="false"
android:focusable="false"
android:scaleType="fitXY" />
</RelativeLayout>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment