Commit 06c876ac authored by mengcuiguang2's avatar mengcuiguang2

代码优化

parent b9a0e053
Pipeline #198 canceled with stages
......@@ -198,16 +198,6 @@
<activity
android:name="com.mints.goodnews.ui.activitys.TaskCpdActivity"
android:screenOrientation="portrait" />
<activity
android:name="com.mints.goodnews.ui.activitys.KylVideoActivity"
android:configChanges="orientation|screenSize|keyboardHidden"
android:screenOrientation="portrait" />
<activity
android:name="com.mints.goodnews.call.permission.PermissionActivity"
android:screenOrientation="portrait" />
<activity
android:name="com.mints.goodnews.call.detail.DetailApplyActivity"
android:screenOrientation="portrait" />
<!-- OneWay激励视频 -->
<activity
......@@ -357,23 +347,6 @@
android:resource="@xml/ow_file_paths" />
</provider>
<!-- 来电秀 -->
<service
android:name="com.mints.goodnews.call.service.PhoneListenService"
android:enabled="true"
android:exported="false"
android:permission="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE">
<intent-filter>
<action android:name="android.intent.action.PHONE_STATE" />
<action android:name="android.service.notification.NotificationListenerService" />
</intent-filter>
</service>
<provider
android:name="com.mints.goodnews.call.provider.CallProvider"
android:authorities="com.mints.goodnews.provider"
android:exported="true"
android:permission="com.mints.goodnews.permission" />
</application>
......
......@@ -8,7 +8,6 @@ import cn.jpush.android.api.BasicPushNotificationBuilder
import cn.jpush.android.api.JPushInterface
import com.downloader.PRDownloader
import com.downloader.PRDownloaderConfig
import com.mints.goodnews.manager.BxmManager.initBxm
import com.mob.MobSDK
/**
......@@ -60,7 +59,6 @@ class InitAppService : IntentService("InitializeService") {
initJpush()
// 变现猫
initBxm(this.application)
// PR下载附件
initPRDownloader()
......
package com.mints.goodnews.manager
import android.app.Activity
import android.app.Application
import android.view.ViewGroup
import com.dhcw.sdk.BDAdvanceButtonAd
import com.dhcw.sdk.BDAdvanceButtonListener
import com.dhcw.sdk.BDAppNativeOnClickListener
import com.dhcw.sdk.manager.BDAdvanceConfig
import com.dhcw.sdk.manager.BDManager
import com.mints.goodnews.BuildConfig
import com.mints.goodnews.MintsApplication
import com.mints.goodnews.common.Constant
/**
* 描述:变现猫
* 作者:孟崔广
*/
object BxmManager {
private const val APP_ID = "85f06dc1a84a4c2abe503d13f7f88721"
private const val BUTTON_AD_SPOT_ID = "807020003001"
private var bdAdvanceButtonAd: BDAdvanceButtonAd? = null
/**
* 初始化
*/
fun initBxm(application: Application) {
BDAdvanceConfig.getInstance()
.setAppName(Constant.MINTS_APP_NAME)
.setDebug(BuildConfig.DEBUG)
.enableAudit(false)
BDManager.getStance()
.init(application, APP_ID)
}
/**
* 获取Button广告
*/
fun loadButtonAd(activity: Activity?, viewGroup: ViewGroup) {
if (activity == null) return
try {
if (bdAdvanceButtonAd != null) {
bdAdvanceButtonAd!!.setBdAdvanceButtonListener(null)
bdAdvanceButtonAd!!.setBdAppNativeOnClickListener(null)
bdAdvanceButtonAd = null
}
bdAdvanceButtonAd = BDAdvanceButtonAd(activity, viewGroup, BUTTON_AD_SPOT_ID)
bdAdvanceButtonAd?.setBdAdvanceButtonListener(object : BDAdvanceButtonListener {
override fun onActivityClosed() {
// Toast.makeText(activity, "活动页关闭 ", Toast.LENGTH_LONG).show()
}
override fun onAdShow() {
// Toast.makeText(activity, "广告展示 ", Toast.LENGTH_LONG).show()
}
override fun onAdFailed() {
// Toast.makeText(activity, "广告加载失败 ", Toast.LENGTH_LONG).show()
}
override fun onAdClicked() {
// Toast.makeText(activity, "广告点击 ", Toast.LENGTH_LONG).show()
}
})
bdAdvanceButtonAd?.setBdAppNativeOnClickListener(object : BDAppNativeOnClickListener {
override fun onActivityClosed() {
// Toast.makeText(activity, "float onActivityClosed ", Toast.LENGTH_SHORT).show()
}
override fun onClick(type: Int, adid: String) {
// Toast.makeText(activity, "float onClick:$type", Toast.LENGTH_SHORT).show()
//type=1 加载视频 type=2 播放视频
if (type == 1) {
//bdAdvanceFloatIconAd 绑定激励视频回调
BxmPlayVideo.getInstance().load(bdAdvanceButtonAd)
} else if (type == 2) {
BxmPlayVideo.getInstance().play(activity)
}
}
})
bdAdvanceButtonAd?.loadAd()
} catch (e: Exception) {
e.printStackTrace()
}
}
/**
* 登录后绑定用户信息
*/
fun bindUserData() {
try {
BDManager.getStance().bindUserData(MintsApplication.getContext(), APP_ID, "cuid=${UserManager.getInstance().userID}")
} catch (e: Exception) {
e.printStackTrace()
}
}
fun onDestory() {
bdAdvanceButtonAd = null
}
}
\ No newline at end of file
package com.mints.goodnews.manager;
import android.app.Activity;
import com.bytedance.sdk.openadsdk.AdSlot;
import com.bytedance.sdk.openadsdk.TTAdConstant;
import com.bytedance.sdk.openadsdk.TTAdNative;
import com.bytedance.sdk.openadsdk.TTRewardVideoAd;
import com.dhcw.sdk.BDAdvanceBaseAppNative;
public class BxmPlayVideo {
static BxmPlayVideo instance = new BxmPlayVideo();
public static BxmPlayVideo getInstance() {
return instance;
}
//一、加载穿山甲激励视频
//BDAdvanceBaseAppNative 绑定激励视频回调
public void load(final BDAdvanceBaseAppNative appNative) {
try {
TTNativeExpressManager ttNativeExpressManager = null;
TTAdNative adNative = null;
if (ttNativeExpressManager == null) {
ttNativeExpressManager = new TTNativeExpressManager();
adNative = ttNativeExpressManager.initTTAd(false);
}
//模版渲染请求AdSlot
AdSlot adSlot = new AdSlot.Builder()
.setCodeId(TtCsjAdManager.TT_AD_VEDIO_BIANXIANMAO)
.setSupportDeepLink(true)
.setAdCount(1)
.setExpressViewAcceptedSize(500, 500)//个性化模板广告需要设置期望个性化模板广告的大小,单位dp,激励视频场景,只要设置的值大于0即可。仅模板广告需要设置此参数
.setImageAcceptedSize(1080, 1920)
.setOrientation(TTAdConstant.VERTICAL)
.setMediaExtra("media_extra")
.setUserID(UserManager.getInstance().getUserID())
.build();
//加载激励视频广告
adNative.loadRewardVideoAd(adSlot, new TTAdNative.RewardVideoAdListener() {
@Override
public void onError(int i, String s) {
appNative.onError(i);
}
@Override
public void onRewardVideoAdLoad(TTRewardVideoAd ttRewardVideoAd) {
if (ttRewardVideoAd == null) {
appNative.onError(0);
} else {
bindRewardListener(ttRewardVideoAd, appNative);
appNative.onADLoad();
}
}
@Override
public void onRewardVideoCached() {
}
});
} catch (Throwable e) {
appNative.onError(0);
}
}
//二、绑定穿山甲激励视频回调
//BDAdvanceBaseAppNative 绑定激励视频回调
TTRewardVideoAd mttRewardVideoAd;
private void bindRewardListener(TTRewardVideoAd ttRewardVideoAd, final BDAdvanceBaseAppNative appNative) {
mttRewardVideoAd = ttRewardVideoAd;
mttRewardVideoAd.setRewardAdInteractionListener(new TTRewardVideoAd.RewardAdInteractionListener() {
@Override
public void onAdShow() {
appNative.onADShow();
}
@Override
public void onAdVideoBarClick() {
appNative.onADClick();
}
@Override
public void onAdClose() {
appNative.onADClose();
}
@Override
public void onVideoComplete() {
appNative.onVideoComplete();
}
@Override
public void onVideoError() {
appNative.onError(0);
}
@Override
public void onRewardVerify(boolean b, int i, String s, int i1, String s1) {
appNative.onReward();
}
@Override
public void onSkippedVideo() {
appNative.onSkipped();
}
});
}
//三、播放穿山甲激励视频
public void play(Activity activity) {
if (mttRewardVideoAd != null) {
mttRewardVideoAd.showRewardVideoAd(activity);
}
}
}
package com.mints.goodnews.mvp.model;
import java.io.Serializable;
import java.util.List;
/**
* @author jyx
* @date 2021/3/22
* @des
*/
public class CashoutChallengeBean implements Serializable {
/**
* canRewardCoin : 0
* list : [{"needCount":10,"cash":0.1,"status":0,"coin":1000},{"needCount":50,"cash":0.5,"status":0,"coin":5000},{"needCount":100,"cash":1,"status":0,"coin":10000},{"needCount":500,"cash":5,"status":0,"coin":50000},{"needCount":1000,"cash":10,"status":0,"coin":100000}]
* complete : 0
*/
private Integer canRewardCoin;
private List<ListDTO> list;
private Integer complete;
public Integer getCanRewardCoin() {
return canRewardCoin;
}
public void setCanRewardCoin(Integer canRewardCoin) {
this.canRewardCoin = canRewardCoin;
}
public List<ListDTO> getList() {
return list;
}
public void setList(List<ListDTO> list) {
this.list = list;
}
public Integer getComplete() {
return complete;
}
public void setComplete(Integer complete) {
this.complete = complete;
}
public class ListDTO implements Serializable{
public Integer getNeedCount() {
return needCount;
}
public void setNeedCount(Integer needCount) {
this.needCount = needCount;
}
public Double getCash() {
return cash;
}
public void setCash(Double cash) {
this.cash = cash;
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
public Integer getCoin() {
return coin;
}
public void setCoin(Integer coin) {
this.coin = coin;
}
/**
* needCount : 10
* cash : 0.1
* status : 0
* coin : 1000
*/
private Integer needCount;
private Double cash;
private Integer status;
private Integer coin;
}
}
......@@ -308,5 +308,30 @@ open class MyPresenter : BasePresenter<MyView>() {
}
})
}
fun addContributionByCompeteCoinTarget() {
AppHttpManager.getInstance(loanApplication)
.call(loanService.addContributionByCompeteCoinTarget(),
object : BaseSubscriber<BaseResponse<UserTaskMsgBean>>() {
override fun onCompleted() {
if (isLinkView) return
view.hideLoading()
}
override fun onError(e:Throwable) {
if (isLinkView) return
view.hideLoading()
}
override fun onNext(baseResponse: BaseResponse<UserTaskMsgBean>) {
if (isLinkView) return
val code = baseResponse.getStatus()
when (code) {
200 -> {
view.showToast("领取成功!")
getAutoUserHallBaseMsg()
}
}
}
})
}
}
\ No newline at end of file
package com.mints.goodnews.mvp.views
import com.mints.goodnews.mvp.model.CashoutChallengeBean
import com.mints.goodnews.mvp.model.FriendHallMsgBean
interface FriendsView : BaseView {
// fun getWorldRankSuc(data: FriendsTaskBean.FriendsBean)
//
// fun getFriendsRankSuc(data: FriendsTaskBean)
fun getContributionBigLeadersSuc(data: FriendHallMsgBean)
fun getFriendsHallMsgSuc(data: FriendHallMsgBean)
......@@ -18,4 +15,8 @@ interface FriendsView : BaseView {
fun getContributionOutToCashSuc()
fun getSonCashoutChallengeMsgSuc(data: CashoutChallengeBean)
fun getSonCashoutChallengeMsgFail()
}
......@@ -7,6 +7,7 @@ import com.mints.goodnews.BuildConfig;
import com.mints.goodnews.mvp.model.AccountMsgBean;
import com.mints.goodnews.mvp.model.BannerBean;
import com.mints.goodnews.mvp.model.BaseResponse;
import com.mints.goodnews.mvp.model.CashoutChallengeBean;
import com.mints.goodnews.mvp.model.ClickTurnBean;
import com.mints.goodnews.mvp.model.CommonParamBean;
import com.mints.goodnews.mvp.model.DrawcashBean;
......@@ -291,6 +292,15 @@ public interface LoanService {
@POST("api/getHallBaseMsg")
Observable<BaseResponse<UserTaskMsgBean>> getHallBaseMsg();
/**
* 完成任务增加贡献值接口
*
* @return
*/
@POST("api//addContributionByCompeteCoinTarget")
Observable<BaseResponse<JsonObject>> addContributionByCompeteCoinTarget();
/**
* 视频信息
*
......@@ -395,6 +405,14 @@ public interface LoanService {
@POST("api/contributionOutToCash")
Observable<BaseResponse<JsonObject>> contributionOutToCash();
/**
* 新版分红逻辑
*
* @return
*/
@POST("api/sonCashoutChallengeMsg")
Observable<BaseResponse<CashoutChallengeBean>> sonCashoutChallengeMsg();
/**
* 新版 我的界面信息
*
......
......@@ -6,7 +6,6 @@ import android.view.View
import androidx.core.content.ContextCompat
import com.mints.goodnews.R
import com.mints.goodnews.common.Constant
import com.mints.goodnews.manager.BxmManager
import com.mints.goodnews.manager.RsNewsManager
import com.mints.goodnews.mvp.model.AccountMsgBean
import com.mints.goodnews.mvp.presenters.AccountMergePresenter
......@@ -147,7 +146,6 @@ class AccountMergeActivity : BaseActivity(), View.OnClickListener, AccountMergeV
// SceneManager.signIn(this)
RsNewsManager.init(baseApplication)
BxmManager.bindUserData()
readyGoThenKill(MainActivity::class.java)
......
package com.mints.goodnews.ui.activitys
import android.Manifest
import android.media.MediaPlayer
import android.os.Bundle
import android.text.TextUtils
import android.view.View
import com.downloader.Error
import com.downloader.OnDownloadListener
import com.downloader.PRDownloader
import com.mints.goodnews.R
import com.mints.goodnews.ad.video.VideoAdingManager
import com.mints.goodnews.call.business.VideoDBHelper
import com.mints.goodnews.call.detail.DetailApplyActivity
import com.mints.goodnews.call.permission.PermissionActivity
import com.mints.goodnews.call.permission.PermissionManager
import com.mints.goodnews.common.AppConfig
import com.mints.goodnews.common.Constant
import com.mints.goodnews.manager.UserManager
import com.mints.goodnews.mvp.model.VideoAdingBean
import com.mints.goodnews.mvp.presenters.KylVideoPresenter
import com.mints.goodnews.mvp.views.KylVideoView
import com.mints.goodnews.ui.activitys.base.BaseActivity
import com.mints.goodnews.utils.MD5
import com.tbruyelle.rxpermissions.RxPermissions
import kotlinx.android.synthetic.main.activity_kyl_video.*
/**
* 描述:酷音乐视频
* 作者:孟崔广
* 时间:2021/1/4 15:09
*/
class KylVideoActivity : BaseActivity(), View.OnClickListener, KylVideoView {
companion object {
const val VIDEO_URL = "video_url"
const val VIDEO_ID = "video_id"
}
private val WEB_VEDIO_URL = "https://vring.kuyin123.com/friend/94aa83142f7f5c98?videoId="
private lateinit var videoUrl: String
private lateinit var videoId: String
private val kylVideoPresenter by lazy { KylVideoPresenter() }
private lateinit var videoAdingManager: VideoAdingManager
private var loadVideoFailCount = 0
private var downloadId: Int = -1//vedio下载id
private var downloadVedioSucFlag = false// 下载视频成功
private var vedioPathName = ""
override fun getContentViewLayoutID() = R.layout.activity_kyl_video
override fun isApplyKitKatTranslucency() = false
override fun getBundleExtras(extras: Bundle?) {
super.getBundleExtras(extras)
extras?.let {
videoUrl = it.getString(VIDEO_URL, "")
videoId = it.getString(VIDEO_ID, "")
}
}
override fun initViewsAndEvents() {
if (TextUtils.isEmpty(videoUrl)) {
showToast("加载失败,请稍后重试.")
finish()
return
}
videoAdingManager = VideoAdingManager.getInstance(this)
initListener()
loadVedio(videoUrl)
}
private fun loadVedio(vedioUrl: String) {
cvvVedio.setOnPreparedListener { mp: MediaPlayer ->
mp.start()
mp.isLooping = true
}
cvvVedio?.setVideoPath(vedioUrl)
cvvVedio?.start()
}
override fun onResume() {
super.onResume()
cvvVedio.resume()
}
override fun onPause() {
super.onPause()
cvvVedio.pause()
}
override fun onDestroy() {
super.onDestroy()
if (downloadId != -1) {
PRDownloader.cancel(downloadId)
}
videoAdingManager.setVideoAdingListener(null)
videoAdingManager.onDestroy()
kylVideoPresenter.detachView()
}
override fun onClick(v: View?) {
when (v?.id) {
R.id.ivBack -> finish()
R.id.ivVedio -> {
val bundle = Bundle()
bundle.putString(WebActivity.WEB_TITLE, "视频彩铃")
bundle.putString(WebActivity.WEB_URL, WEB_VEDIO_URL + videoId)
readyGo(WebActivity::class.java, bundle)
}
R.id.ivSetting -> {
if (downloadVedioSucFlag) {
readyGo()
return
}
RxPermissions(this)
.request(Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE)
.subscribe { granted: Boolean ->
if (granted) {
downloadVedioToCacheFile()
awardVideo()
} else {
showMissingPermissionDialog("存储")
}
}
}
}
}
private fun downloadVedioToCacheFile() {
downloadVedioSucFlag = false
var vedioPath = ""
try {
vedioPath = getExternalFilesDir(null)!!.absolutePath + "/video/"
} catch (e: java.lang.Exception) {
vedioPath = filesDir.absolutePath + "/video/"
}
val vedioName = MD5.GetMD5Code(System.currentTimeMillis().toString() + UserManager.getInstance().userID + videoUrl) + ".mp4"
vedioPathName = vedioPath + vedioName
downloadId = PRDownloader.download(videoUrl, vedioPath, vedioName)
.build()
.start(object : OnDownloadListener {
override fun onDownloadComplete() {
downloadVedioSucFlag = true
}
override fun onError(error: Error) {
}
})
}
private fun initListener() {
ivBack.setOnClickListener(this)
ivSetting.setOnClickListener(this)
ivVedio.setOnClickListener(this)
}
/**
* 获取激励视频
*/
private fun awardVideo() {
if (AppConfig.isVideoSleep) {
showToast("加载失败,请稍后重试。")
return
} else if (videoAdingManager.videoFinishFlag) {
showToast("今日视频已看完,请明天再来吧")
return
}
loadVideoFailCount = 0
showLoading("加载中...")
val bean = VideoAdingBean()
bean.carrierType = Constant.CARRIER_KUYINYUE_VEDIO
loadVideo(videoAdingManager, bean, true)
}
/**
* 加载激励视频
*/
private fun loadVideo(videoAdingManager: VideoAdingManager, bean: VideoAdingBean, isFirstLoad: Boolean) {
videoAdingManager.setVideoAdingListener(object : VideoAdingManager.VideoAdingListener {
override fun videoAdingListenerError(adType: String) {
showToast("加载超时,请休息一下")
hideLoading()
}
override fun videoAdingListenerFail(adType: String) {
loadVideoFailCount++
if (loadVideoFailCount >= 3) {
hideLoading()
showToast("加载失败,请稍后重试!")
} else {
loadVideo(videoAdingManager, bean, false)
}
}
override fun videoAdingListenerSuccess(adType: String) {
hideLoading()
vedioAdingSuccess(adType)
}
})
if (isFirstLoad) {
// 首页按权重加载
videoAdingManager.loadAding(this, bean)
} else {
// 失败按优先级加载
videoAdingManager.loadFailAding(this, bean)
}
}
private fun vedioAdingSuccess(adType: String) {
if (!downloadVedioSucFlag || TextUtils.isEmpty(vedioPathName)) {
showToast("视频处理中,请稍候")
return
}
readyGo()
}
private fun readyGo() {
if (PermissionManager.getInstance().checkEssential(this)) {
VideoDBHelper.getInstance().setSelectVideo(this, VideoDBHelper.UNKNOWN_NUMBER, vedioPathName)
DetailApplyActivity.startSelf(this, vedioPathName, true)
} else {
PermissionActivity.startSelf(this)
}
}
}
......@@ -101,7 +101,6 @@ class MobileLoginActivity : BaseActivity(), LoginView, View.OnClickListener {
// SceneManager.signIn(this)
RsNewsManager.init(baseApplication)
BxmManager.bindUserData()
// false-登录 true-绑定手机号
showToast("登录成功")
......
......@@ -59,10 +59,6 @@ class WrapperActivity : BaseActivity(), View.OnClickListener {
tv_title.text = "瓜分百万现金福利"
currentFragment = FriendsFragment(true)
}
Constant.WRAPPER_TYPE_KYL -> {
tv_title.text = "来电秀"
currentFragment = KuYinYueFragment()
}
Constant.WRAPPER_TYPE_WZ -> {
layoutWrapper.visibility = View.GONE
currentFragment = WzFragment(true)
......
......@@ -14,7 +14,6 @@ import com.mints.goodnews.R
import com.mints.goodnews.common.Constant
import com.mints.goodnews.login.LoginApi
import com.mints.goodnews.login.OnLoginListener
import com.mints.goodnews.manager.BxmManager
import com.mints.goodnews.manager.RsNewsManager
import com.mints.goodnews.manager.TrackManager
import com.mints.goodnews.manager.YwhzManager
......@@ -127,7 +126,6 @@ class WxLoginActivity : BaseActivity()
// SceneManager.signIn(this)
RsNewsManager.init(baseApplication)
BxmManager.bindUserData()
showToast("登录成功")
progressDialog?.dismiss()
......
......@@ -14,7 +14,6 @@ import android.widget.TextView;
import com.mints.goodnews.R;
import com.mints.goodnews.common.Constant;
import com.mints.goodnews.manager.BxmManager;
import com.mints.goodnews.manager.UserManager;
import com.mints.goodnews.mvp.model.BannerBean;
import com.mints.library.utils.GlideUtils;
......@@ -91,9 +90,6 @@ public class GvMyAdapter extends BaseAdapter {
GlideUtils.loadImageView(activity, data.getImgUrl(), viewHolder.ic_my_icon);
viewHolder.tv_my_title.setText(data.getTitle());
if (TextUtils.equals(data.getToUrl(), Constant.HOT_ACTIVITY_BXM) && UserManager.getInstance().userIsLogin()) {
BxmManager.INSTANCE.loadButtonAd(activity, viewHolder.fl_my_icon);
}
}
return convertView;
}
......
......@@ -60,6 +60,9 @@ class MainMyAdapter(context: Context, taskData: MutableList<MyInfo.AutoListBean>
// 其他下载应用
const val TO_DOWNLOADS = "TO_DOWNLOADS"
// 完成任务增加贡献值
const val TO_ADDCONTRIBUTION = "TO_ADDCONTRIBUTION"
}
private var mContext: Context = context
......
//package com.mints.goodmoney.ui.fragment
//
//import android.annotation.SuppressLint
//import android.content.Intent
//import android.content.pm.ApplicationInfo
//import android.net.Uri
//import android.os.Build
//import android.view.View
//import android.view.ViewGroup
//import android.webkit.WebSettings
//import android.webkit.WebViewClient
//import com.mints.goodmoney.R
//import com.mints.goodmoney.manager.UserManager
//import com.mints.goodmoney.ui.fragment.base.LazyLoadBaseFragment
//import com.mints.goodmoney.utils.LogUtil
//import com.mints.goodmoney.utils.MD5
//import com.mints.goodmoney.utils.URIEncoder
//import kotlinx.android.synthetic.main.fragment_main_dh.*
//
///**
// * 描述:电魂游戏
// * 作者:孟崔广
// * 时间:2020/11/17 13:48
// */
//class DhGameFragment : LazyLoadBaseFragment(), View.OnClickListener {
//
// companion object {
// const val CHANNEL = "14533"
// const val KEY = "4932d9037fd94f6ba24fa09605203cd6"
// const val AUTH_URL = "http://www.shandw.com/auth/"
// }
//
// private val TAG = DhGameFragment::class.java.simpleName
//
// override fun getContentViewLayoutID() = R.layout.fragment_main_dh
//
// override fun initViewsAndEvents() {
// }
//
// override fun onFragmentFirstVisible() {
// loadH5Game()
// initListener()
// }
//
// override fun onFragmentResume() {
// super.onFragmentResume()
//// LogUtil.d(TAG, "onFragmentResume")
// }
//
// override fun onFragmentPause() {
//// LogUtil.d(TAG, "onFragmentPause")
// if (UserManager.getInstance().userIsLogin()) {
// loadH5Game()
// }
// }
//
// override fun onDestroy() {
// super.onDestroy()
//
// dh_webview?.let {
// it.destroyDrawingCache()
// val parent = it.getParent() as ViewGroup
// parent.removeView(it)
// it.removeAllViews()
// it.destroy()
// }
//
// }
//
// override fun onClick(v: View) {
// when (v.id) {
// R.id.ivDhBack -> {
// dh_webview.goBack()
// }
// R.id.tvDhRefresh -> {
// loadH5Game()
// }
// }
// }
//
// /**
// * 加载H5Game
// */
// @SuppressLint("SetJavaScriptEnabled")
// private fun loadH5Game() {
// dh_webview?.let {
// val loadUrl = getLoadUrl()
// LogUtil.d(TAG, "url-->${loadUrl}")
// val settings = it.settings
// // 本地 DOM 存储(解决加载某些网页出现白板现象)
// settings.domStorageEnabled = true
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
// // 解决 Android 5.0 上 WebView 默认不允许加载 Http 与 Https 混合内容
// settings.mixedContentMode = WebSettings.MIXED_CONTENT_ALWAYS_ALLOW
// }
// settings.javaScriptEnabled = true
// settings.javaScriptCanOpenWindowsAutomatically = true
// it.setWebViewClient(object : WebViewClient() {
// override fun shouldOverrideUrlLoading(
// view: android.webkit.WebView,
// url: String
// ): Boolean {
// if (url.startsWith("weixin://wap/pay?") || url.startsWith("alipay")) {
// val hasApp: Boolean
// hasApp = if (url.startsWith("weixin://wap/pay?")) {
// isAppExist("com.tencent.mm")
// } else {
// (isAppExist("com.eg.android.AlipayGphone") || isAppExist("com.alipay.android.app"))
// }
// if (hasApp) {
// val intent = Intent()
// intent.action = Intent.ACTION_VIEW
// intent.data = Uri.parse(url)
// activity?.startActivity(intent)
// } else {
// showToast("客官,请先安装支付App哦~")
// }
// return true
// }
//
// if (url.startsWith("https")) {
// val map = HashMap<String, String>()
// map["Referer"] = "http://www.shandw.com"
// it.loadUrl(url, map)
// }
// return super.shouldOverrideUrlLoading(view, url)
// }
// })
// it.loadUrl(loadUrl)
// }
// }
//
// /**
// * 获取拼接url
// */
// fun getLoadUrl(): String {
// val currentTimeMillis = System.currentTimeMillis() / 1000
// val loadUrl = "${AUTH_URL}?" +
// "channel=${CHANNEL}&" +
// "openid=${URIEncoder.encodeURIComponent(UserManager.getInstance().userID)}&" +
// "time=${currentTimeMillis}&" +
// "nick=${URIEncoder.encodeURIComponent(UserManager.getInstance().userID)}&" +
// "avatar=${URIEncoder.encodeURIComponent("https://mints-pkg.oss-cn-beijing.aliyuncs.com/pkg_goodmoney/img/ic_my.png")}&" +
// "sex=${0}&" +
// "phone=${UserManager.getInstance().mobile}&" +
// "sdw_simple=${2}&" +
// "sign=${getSignStr(currentTimeMillis)}"
// return loadUrl
// }
//
// /**
// * 获取签名
// */
// fun getSignStr(currentTimeMillis: Long): String {
// val signStr = "channel=${CHANNEL}&" +
// "openid=${URIEncoder.encodeURIComponent(UserManager.getInstance().userID)}&" +
// "time=${currentTimeMillis}&" +
// "nick=${UserManager.getInstance().userID}&" +
// "avatar=https://mints-pkg.oss-cn-beijing.aliyuncs.com/pkg_goodmoney/img/ic_my.png&" +
// "sex=${0}&" +
// "phone=${UserManager.getInstance().mobile}${KEY}"
// return MD5.GetMD5Code(signStr).toLowerCase()
// }
//
// fun isAppExist(pkgName: String): Boolean {
// var info: ApplicationInfo? = null
// try {
// info = context?.getPackageManager()!!.getApplicationInfo(pkgName, 0)
// context!!.startActivity(context!!.packageManager.getLaunchIntentForPackage(pkgName))
// } catch (e: Exception) {
// }
// return if (info != null) true else false
// }
//
// private fun initListener() {
// ivDhBack.setOnClickListener(this)
// tvDhRefresh.setOnClickListener(this)
// }
//}
\ No newline at end of file
package com.mints.goodnews.ui.fragment
import android.view.View
import androidx.fragment.app.Fragment
import androidx.viewpager.widget.ViewPager
import com.mints.goodnews.R
import com.mints.goodnews.manager.AppHttpManager
import com.mints.goodnews.mvp.model.BaseResponse
import com.mints.goodnews.mvp.model.KylTabBean
import com.mints.goodnews.ui.adapter.MessageFragAdapter
import com.mints.goodnews.ui.fragment.base.LazyLoadBaseFragment
import com.mints.library.net.neterror.BaseSubscriber
import com.mints.library.net.neterror.Throwable
import kotlinx.android.synthetic.main.fragment_main_kyl.*
import java.util.*
import kotlin.collections.ArrayList
import kotlin.concurrent.schedule
/**
* 描述:酷音乐视频(讯飞)
* 作者:孟崔广
*/
class KuYinYueFragment : LazyLoadBaseFragment() {
override fun getContentViewLayoutID() = R.layout.fragment_main_kyl
override fun initViewsAndEvents() {
}
override fun onFragmentFirstVisible() {
super.onFragmentFirstVisible()
getData()
}
private fun getData() {
showLoading("加载中...")
AppHttpManager.getInstance(baseApplication)
.call(baseApplication.loanService.getXfBRTRoot(), object : BaseSubscriber<BaseResponse<KylTabBean>>() {
override fun onError(e: Throwable) {
hideLoading()
}
override fun onNext(t: BaseResponse<KylTabBean>) {
hideLoading()
initViewAndData(t.data)
}
})
}
private fun initViewAndData(tabBean: KylTabBean) {
val tabs: MutableList<String> = ArrayList()
val fragments: MutableList<Fragment> = ArrayList()
for (i in 0 until tabBean.rootArr.size) {
tabs.add(tabBean.rootArr[i].name)
fragments.add(KuYinYuePageFragment(tabBean.rootArr[i].targetid))
}
Timer().schedule(500) {
activity?.runOnUiThread {
hideLoading()
xtFragmentKyl.visibility = View.VISIBLE
}
}
xtFragmentKyl.overScrollMode = ViewPager.OVER_SCROLL_NEVER
vpFragmentKyl.offscreenPageLimit = tabs.size + 3
val adapter = MessageFragAdapter(childFragmentManager, fragments, tabs)
vpFragmentKyl.adapter = adapter
xtFragmentKyl.setxTabDisplayNum(tabs.size)
xtFragmentKyl.setupWithViewPager(vpFragmentKyl)
}
}
\ No newline at end of file
package com.mints.goodnews.ui.fragment
import android.os.Bundle
import androidx.recyclerview.widget.GridLayoutManager
import com.bytedance.sdk.openadsdk.*
import com.mints.goodnews.R
import com.mints.goodnews.manager.TtCsjAdManager
import com.mints.goodnews.mvp.model.KylBean
import com.mints.goodnews.mvp.presenters.KuYinYuePagePresenter
import com.mints.goodnews.mvp.views.KuYinYuePageView
import com.mints.goodnews.ui.activitys.KylVideoActivity
import com.mints.goodnews.ui.adapter.KylPageAdapter
import com.mints.goodnews.ui.fragment.base.LazyLoadBaseFragment
import com.mints.goodnews.utils.LogUtil
import com.scwang.smartrefresh.layout.api.RefreshLayout
import com.scwang.smartrefresh.layout.listener.OnLoadMoreListener
import com.scwang.smartrefresh.layout.listener.OnRefreshListener
import kotlinx.android.synthetic.main.fragment_main_kyl_page.*
/**
* 描述:首页列表详情
* 作者:孟崔广
*/
class KuYinYuePageFragment(private val targetid: String) : LazyLoadBaseFragment(),
KuYinYuePageView,
OnRefreshListener,
OnLoadMoreListener,
KylPageAdapter.OnItemClickListener {
private var mTTAdNative: TTAdNative? = null
private val kuYinYuePagePresenter by lazy { KuYinYuePagePresenter() }
private lateinit var kylPageAdapter: KylPageAdapter
private var kylData: MutableList<KylBean.Data> = mutableListOf()
private var curPage = 1 // 分页
private val PAGE_SIZE = 6
private var feedAd: TTFeedAd? = null
override fun getContentViewLayoutID() = R.layout.fragment_main_kyl_page
override fun initViewsAndEvents() {
}
override fun onFragmentFirstVisible() {
super.onFragmentFirstVisible()
kuYinYuePagePresenter.attachView(this)
mTTAdNative = TTAdSdk.getAdManager().createAdNative(context)
initRvView()
initListener()
// loadListAd()
getXfPageMsg()
}
override fun onDestroy() {
super.onDestroy()
kuYinYuePagePresenter.detachView()
}
override fun onItemClick(position: Int) {
if (kylData != null && 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)
}
}
override fun onRefresh(refreshLayout: RefreshLayout) {
curPage = 1
kylData.clear()
srl_kyl.resetNoMoreData()
// loadListAd()
getXfPageMsg()
}
override fun onLoadMore(refreshLayout: RefreshLayout) {
curPage = ++curPage
// loadListAd()
getXfPageMsg()
}
override fun getXfPageMsgSuc(data: KylBean) {
if (::kylPageAdapter.isInitialized) {
// if (feedAd != null) {
// for (i in 0..data.data.size - 1) {
// if (i == 4) {
// val data1 = KylBean.Data()
// data1.adBean = feedAd
// kylData.add(data1)
// continue
// }
// kylData.add(data.data[i])
// }
// } else {
// kylData.addAll(data.data)
// }
kylData.addAll(data.data)
if (curPage == 1) {
srl_kyl.finishRefresh(true)
kylPageAdapter.notifyDataSetChanged()
} else {
if (data.data.size < PAGE_SIZE) {
srl_kyl.finishLoadMoreWithNoMoreData()
} else {
srl_kyl.finishLoadMore()
}
kylPageAdapter.notifyItemChanged(data.data.size)
}
}
}
override fun getXfPageMsgFail() {
srl_kyl.finishRefresh(false)
srl_kyl.finishLoadMore(false)
curPage = if (curPage == 1) 1 else curPage - 1
}
private fun initRvView() {
val gridLayoutManager = GridLayoutManager(context, 2)
rvPageKyl.layoutManager = gridLayoutManager
kylPageAdapter = KylPageAdapter(kylData)
rvPageKyl.adapter = kylPageAdapter
kylPageAdapter.setOnItemClickListener(this)
}
private fun initListener() {
srl_kyl.setOnRefreshListener(this)
srl_kyl.setOnLoadMoreListener(this)
}
/**
* 加载feed广告
*/
private fun loadListAd() {
feedAd = null
val adSlot = AdSlot.Builder()
.setCodeId(TtCsjAdManager.TT_AD_NATIVEEXPRESS_AWARD)
.setImageAcceptedSize(640, 320)
//[start支持模板样式]:需要支持模板广告和原生广告样式的切换,需要调用supportRenderControl和setExpressViewAcceptedSize
.supportRenderControl()
.setExpressViewAcceptedSize(500f, 500f)//设置模板宽高(dp)
.setAdCount(1) //请求广告数量为1到3条
.build()
mTTAdNative?.loadFeedAd(adSlot, object : TTAdNative.FeedAdListener {
override fun onError(code: Int, message: String) {
LogUtil.d("KuYinYuePageFragment", "code:${code} message:${message}")
getXfPageMsg()
}
override fun onFeedAdLoad(ads: List<TTFeedAd>) {
if (ads == null || ads.isEmpty()) {
getXfPageMsg()
return
}
for (ad in ads) {
if (ad.imageMode == TTAdConstant.IMAGE_MODE_LARGE_IMG) {
feedAd = ad
}
}
getXfPageMsg()
}
})
}
private fun getXfPageMsg() {
kuYinYuePagePresenter.getXfPageMsg(targetid, curPage, PAGE_SIZE)
}
}
\ No newline at end of file
......@@ -185,7 +185,6 @@ class MyFragment : BaseFragment(),
override fun onDestroy() {
super.onDestroy()
fl_my_banner?.removeAllViews()
BxmManager.onDestory()
BannerManager.onDestroy()
myPresenter.detachView()
......@@ -774,6 +773,18 @@ class MyFragment : BaseFragment(),
}
}
// 完成分红任务增加贡献值
MainMyAdapter.TO_ADDCONTRIBUTION -> {
if (!UserManager.getInstance().userIsLogin()) {
readyGo(WxLoginActivity::class.java)
return
}
if (taskBean.otherConfig != null && taskBean.otherConfig.status == 1) {
myPresenter.addContributionByCompeteCoinTarget()
} else {
showToast("请先完成任务")
}
}
MainMyAdapter.TO_DOWNLOADS -> {
if (taskBean.otherConfig != null) {
when (taskBean.otherConfig.status) {
......
//package com.mints.goldspace.ui.fragment
//
//import android.os.Bundle
//import android.view.View
//import androidx.fragment.app.Fragment
//import androidx.fragment.app.FragmentTransaction
//import com.ireader.ireadersdk.IreaderApi
//import com.mints.goldspace.R
//import com.mints.goldspace.common.AppConfig
//import com.mints.goldspace.common.Constant
//import com.mints.goldspace.mvp.presenters.BookPresenter
//import com.mints.goldspace.mvp.views.BookView
//import com.mints.goldspace.ui.activitys.AwardActivity
//import com.mints.goldspace.ui.fragment.base.LazyLoadBaseFragment
//import com.mints.goldspace.utils.SpanUtils
//import kotlinx.android.synthetic.main.fragment_main_zy.*
//
///**
// * 描述:我的-掌阅书城
// * 作者:孟崔广
// */
//class MyZhangyueFragment : LazyLoadBaseFragment(), BookView, IreaderApi.OnReadChangeListener {
//
// private val bookPresenter by lazy { BookPresenter() }
// private var bookFragment: Fragment? = null
//
// override fun getContentViewLayoutID() = R.layout.fragment_main_zy
//
// override fun initViewsAndEvents() {
// bookPresenter.attachView(this)
//
// val transaction: FragmentTransaction = supportFragmentManager.beginTransaction()
// if (bookFragment == null) {
//// bookFragment = IreaderApi.getNovelBookStoreFragment()
// bookFragment = IreaderApi.getNovelChannelFragment()
// transaction.add(R.id.fragment, bookFragment!!, bookFragment!!::class.java.simpleName)
// IreaderApi.setReadChangeListener(this)
// } else {
// transaction.show(bookFragment!!)
// }
// transaction.commitAllowingStateLoss()
// }
//
// override fun onFragmentFirstVisible() {
//
// }
//
// override fun onFragmentResume() {
// super.onFragmentResume()
// if (AppConfig.fragmentClickFlag == Constant.FRAGMENT_CLICK_ONE) {
// bookPresenter.getReadInfo()
// }
// }
//
// override fun onDestroy() {
// super.onDestroy()
//
// IreaderApi.setReadChangeListener(null)
// bookPresenter.detachView()
// }
//
// override fun onReadStart() {
// }
//
// override fun onReadEnd(time: Long) {
//// LogUtil.d(TAG, "onReadEnd time:" + time)
//// LogUtil.d(TAG, "onReadEnd time(Int):" + (time/1000).toInt())
//
// val seconds = (time / 1000).toInt()
// // 阅读5秒以上 保存时长
// if (seconds > 5) {
// bookPresenter.addReadSeconds(seconds)
// }
// }
//
// override fun onReadPage(time: Long) {
// }
//
// override fun readSecondsSuc(coin: Int) {
// if (coin > 0) {
// val bundle = Bundle()
// bundle.putString(Constant.MAIN_CARRIER_TYPE, Constant.CARRIER_ZHANGYUE)
// bundle.putInt(Constant.MAIN_CUR_COIN, coin)
// readyGo(AwardActivity::class.java, bundle)
// }
// }
//
// override fun readInfo(sumTime: Int, sumCoin: Int, readTime: Int) {
// //阅读{10}分钟,奖励{xx}金币,已读{x}分钟
// tvZhangContent.visibility = View.VISIBLE
// if (readTime >= sumTime) {
// tvZhangContent.text = "今日阅读任务已完成"
// } else {
// tvZhangContent.text = SpanUtils()
// .append("阅读").append("${sumTime / 60}").setForegroundColor(mContext.resources.getColor(R.color.color_FF9837)).append("分钟, ")
// .append("奖励").append("$sumCoin").setForegroundColor(mContext.resources.getColor(R.color.color_cb4a39)).append("金币, ")
// .append("已读").append("${readTime / 60}").setForegroundColor(mContext.resources.getColor(R.color.color_FF9837)).append("分钟")
// .create()
// }
// }
//}
\ No newline at end of file
//package com.mints.goldspace.ui.fragment
//
//import android.os.Bundle
//import android.view.View
//import androidx.fragment.app.Fragment
//import androidx.fragment.app.FragmentTransaction
//import com.mints.goldspace.R
//import com.mints.goldspace.common.AppConfig
//import com.mints.goldspace.common.Constant
//import com.mints.goldspace.mvp.presenters.BookPresenter
//import com.mints.goldspace.mvp.views.BookView
//import com.mints.goldspace.ui.activitys.AwardActivity
//import com.mints.goldspace.ui.fragment.base.LazyLoadBaseFragment
//import com.mints.goldspace.utils.SpanUtils
//import kotlinx.android.synthetic.main.fragment_main_zy.*
//
///**
// * 描述:掌阅书城
// * 作者:孟崔广
// */
//class ZhangyueFragment : LazyLoadBaseFragment(), BookView, IreaderApi.OnReadChangeListener {
//
// private val bookPresenter by lazy { BookPresenter() }
// private var bookFragment: Fragment? = null
//
// override fun getContentViewLayoutID() = R.layout.fragment_main_zy
//
// override fun initViewsAndEvents() {
//
// }
//
// override fun onFragmentFirstVisible() {
// bookPresenter.attachView(this)
//
// val transaction: FragmentTransaction = supportFragmentManager.beginTransaction()
// if (bookFragment == null) {
// bookFragment = IreaderApi.getNovelBookStoreFragment()
// transaction.add(R.id.fragment, bookFragment!!, bookFragment!!::class.java.simpleName)
// IreaderApi.setReadChangeListener(this)
// } else {
// transaction.show(bookFragment!!)
// }
// transaction.commitAllowingStateLoss()
// }
//
// override fun onFragmentResume() {
// super.onFragmentResume()
// if (AppConfig.fragmentClickFlag == Constant.FRAGMENT_CLICK_ONE) {
// bookPresenter.getReadInfo()
// }
// }
//
// override fun onDestroy() {
// super.onDestroy()
//
// IreaderApi.setReadChangeListener(null)
// bookPresenter.detachView()
// }
//
// override fun onReadStart() {
// }
//
// override fun onReadEnd(time: Long) {
//// LogUtil.d(TAG, "onReadEnd time:" + time)
//// LogUtil.d(TAG, "onReadEnd time(Int):" + (time/1000).toInt())
//
// val seconds = (time / 1000).toInt()
// // 阅读5秒以上 保存时长
// if (seconds > 5) {
// bookPresenter.addReadSeconds(seconds)
// }
// }
//
// override fun onReadPage(time: Long) {
// }
//
// override fun readSecondsSuc(coin: Int) {
// if (coin > 0) {
// val bundle = Bundle()
// bundle.putString(Constant.MAIN_CARRIER_TYPE, Constant.CARRIER_ZHANGYUE)
// bundle.putInt(Constant.MAIN_CUR_COIN, coin)
// readyGo(AwardActivity::class.java, bundle)
// }
// }
//
// override fun readInfo(sumTime: Int, sumCoin: Int, readTime: Int) {
// //阅读{10}分钟,奖励{xx}金币,已读{x}分钟
// tvZhangContent.visibility = View.VISIBLE
// if (readTime >= sumTime) {
// tvZhangContent.text = "今日阅读任务已完成"
// } else {
// tvZhangContent.text = SpanUtils()
// .append("阅读").append("${sumTime / 60}").setForegroundColor(mContext.resources.getColor(R.color.color_FF9837)).append("分钟, ")
// .append("奖励").append("$sumCoin").setForegroundColor(mContext.resources.getColor(R.color.color_cb4a39)).append("金币, ")
// .append("已读").append("${readTime / 60}").setForegroundColor(mContext.resources.getColor(R.color.color_FF9837)).append("分钟")
// .create()
// }
// }
//}
\ No newline at end of file
......@@ -7,6 +7,7 @@ import android.view.KeyEvent
import android.view.View
import android.view.WindowManager
import android.widget.Button
import android.widget.ImageView
import android.widget.TextView
import com.mints.goodnews.R
......@@ -19,6 +20,7 @@ class BonusDialog(context: Context, private val listener: DialogListener) :
private val tv_dialogper_title: TextView
private val tv_dialogper_content: TextView
private val btn_dialogper_submit: Button
private val iv_dialoger_close: ImageView
fun setTitle(title: String) {
tv_dialogper_title.visibility = View.VISIBLE
......@@ -33,6 +35,14 @@ class BonusDialog(context: Context, private val listener: DialogListener) :
btn_dialogper_submit.text = btnStr
}
fun canClose(flag: Boolean) {
if (flag) {
iv_dialoger_close.visibility = View.VISIBLE
} else {
iv_dialoger_close.visibility = View.GONE
}
}
init {
setContentView(R.layout.dialog_friends)
// 设置window属性
......@@ -56,8 +66,12 @@ class BonusDialog(context: Context, private val listener: DialogListener) :
findViewById<View>(R.id.tv_content) as TextView
btn_dialogper_submit =
findViewById<View>(R.id.btn_submit) as Button
iv_dialoger_close =
findViewById<View>(R.id.iv_close) as ImageView
tv_dialogper_content.setOnClickListener(listener)
tv_dialogper_title.setOnClickListener(listener)
btn_dialogper_submit.setOnClickListener(listener)
iv_dialoger_close.setOnClickListener { this@BonusDialog.dismiss() }
}
}
\ No newline at end of file
package com.mints.goodnews.ui.widgets
import android.content.Context
import android.util.AttributeSet
import android.view.View
import android.widget.FrameLayout
import android.widget.TextView
import androidx.core.content.ContextCompat
import com.mints.goodnews.R
import com.mints.goodnews.mvp.model.CashoutChallengeBean
import com.mints.library.utils.nodoubleclick.AntiShake
/**
*
* @author jyx
* @date 2021/3/22
* @des
*/
class ProgressLayout : FrameLayout, View.OnClickListener {
constructor(ctx: Context) : this(ctx, null)
constructor(ctx: Context, attrs: AttributeSet?) : this(ctx, attrs, 0)
constructor(ctx: Context, attrs: AttributeSet?, defStyleAttr: Int) : super(
ctx,
attrs,
defStyleAttr
)
private var titleView1: TextView
private var titleView2: TextView
private var titleView3: TextView
private var titleView4: TextView
private var titleView5: TextView
private var tickProgress: TickProgress
private var mBoxListener: BoxListener? = null
init {
val rootView = inflate(context, R.layout.layout_progress, this)
titleView1 = rootView.findViewById(R.id.tv_box1)
titleView2 = rootView.findViewById(R.id.tv_box2)
titleView3 = rootView.findViewById(R.id.tv_box3)
titleView4 = rootView.findViewById(R.id.tv_box4)
titleView5 = rootView.findViewById(R.id.tv_box5)
tickProgress = rootView.findViewById(R.id.tick_progress)
initListener()
}
private fun initListener() {
titleView1.setOnClickListener(this)
titleView2.setOnClickListener(this)
titleView3.setOnClickListener(this)
titleView4.setOnClickListener(this)
titleView5.setOnClickListener(this)
}
fun setStatus(dataList: List<CashoutChallengeBean.ListDTO>) {
for (i in dataList.indices) {
setSingleStatus(i, dataList[i].status, dataList[i].needCount)
}
}
fun setSingleStatus(position: Int, status: Int, needCount: Int) {
val boxView = getBoxView(position)
boxView?.text = needCount.toString() + "人"
boxView?.tag = status
when (status) {
0 -> {
boxView?.setCompoundDrawablesWithIntrinsicBounds(
null,
null,
null,
ContextCompat.getDrawable(context, R.mipmap.ic_box_gray)
)
}
1 -> {
boxView?.setCompoundDrawablesWithIntrinsicBounds(
null,
null,
null,
ContextCompat.getDrawable(context, R.mipmap.ic_box_close)
)
}
2 -> {
boxView?.setCompoundDrawablesWithIntrinsicBounds(
null,
null,
null,
ContextCompat.getDrawable(context, R.mipmap.ic_box_open)
)
}
}
}
private fun getBoxView(position: Int): TextView? {
when (position) {
0 -> {
return titleView1
}
1 -> {
return titleView2
}
2 -> {
return titleView3
}
3 -> {
return titleView4
}
4 -> {
return titleView5
}
else -> {
return null
}
}
}
/**
* @param complete 0-1000人
*/
fun setProgress(complete: Int) {
val progress: Float = when (complete) {
in 0..10 -> 0.1f * (complete / 10f)
in 11..50 -> 0.1f + 0.1f * ((complete - 10) / 50f)
in 51..100 -> 0.2f + 0.1f * ((complete - 50) / 50f)
in 101..500 -> 0.3f + 0.3f * ((complete - 100) / 400f)
in 501..1000 -> 0.6f + 0.4f * ((complete - 500) / 500f)
else -> 0f
}
tickProgress.setProgress(progress)
}
fun setBoxListener(boxListener: BoxListener) {
mBoxListener = boxListener
}
interface BoxListener {
/**
* 点击宝箱
*
* @param position 下标
* @param status 状态
*/
fun clickBox(position: Int, status: Int)
}
override fun onClick(v: View?) {
if (AntiShake.check(v)) return
when (v?.id) {
R.id.tv_box1 -> {
mBoxListener?.clickBox(0, v.tag.toString().toInt())
}
R.id.tv_box2 -> {
mBoxListener?.clickBox(1, v.tag.toString().toInt())
}
R.id.tv_box3 -> {
mBoxListener?.clickBox(2, v.tag.toString().toInt())
}
R.id.tv_box4 -> {
mBoxListener?.clickBox(3, v.tag.toString().toInt())
}
R.id.tv_box5 -> {
mBoxListener?.clickBox(4, v.tag.toString().toInt())
}
}
}
}
\ No newline at end of file
package com.mints.goodnews.ui.widgets;
import android.animation.ValueAnimator;
import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.LinearGradient;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.PathMeasure;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffXfermode;
import android.graphics.RectF;
import android.graphics.Shader;
import android.util.AttributeSet;
import android.view.View;
import com.mints.goodnews.ui.widgets.seekbar.BubbleUtils;
import com.mints.goodnews.utils.LogUtil;
@SuppressLint("DrawAllocation")
public class TickProgress extends View {
private static final long DURATION = 200;
private int mViewWidth;
private int mViewHeight;
private int mStrokeWidth;
private int mProgressWidth;
private Paint mBgPaint;
private Paint mProgressPaint;
private Paint mMackTickPaint;
private int mStrokeColor = Color.parseColor("#FB7C27");
private ValueAnimator.AnimatorUpdateListener mUpdateListener;
private ValueAnimator mAnimator;
// 动画数值(用于控制动画状态,因为同一时间内只允许有一种状态出现,具体数值处理取决于当前状态)
private float mAnimatorValue;
public TickProgress(Context context) {
this(context, null);
}
public TickProgress(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
private Paint mStrokePaint;
private int mHeight;
public TickProgress(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
mHeight = BubbleUtils.dp2px(15);
mStrokeWidth = BubbleUtils.dp2px(1);
mBgPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mBgPaint.setStyle(Paint.Style.FILL);
mBgPaint.setStrokeWidth(mHeight);
mBgPaint.setColor(Color.parseColor("#D8D8D8"));
mStrokePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mStrokePaint.setStyle(Paint.Style.STROKE);
mStrokePaint.setStrokeWidth(mStrokeWidth);
mStrokePaint.setColor(mStrokeColor);
mProgressPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mProgressPaint.setStrokeWidth(mHeight);
mProgressPaint.setStyle(Paint.Style.FILL);
mMackTickPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mMackTickPaint.setStyle(Paint.Style.STROKE);
mMackTickPaint.setStrokeWidth(mStrokeWidth);
mMackTickPaint.setColor(mStrokeColor);
setLayerType(LAYER_TYPE_HARDWARE, null);
}
private int mMackTickWidth;
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
mViewHeight = h;
mViewWidth = w;
mMackTickWidth = w / 5;
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
setMeasuredDimension(widthMeasureSpec, mHeight);
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
RectF rectF2 = new RectF(mStrokeWidth, mStrokeWidth, mViewWidth - mStrokeWidth, mHeight - mStrokeWidth);
canvas.drawRoundRect(rectF2, mHeight / 2, mHeight / 2, mBgPaint);
// canvas.drawRoundRect(rectF2, mHeight / 2, mHeight / 2, mStrokePaint);
RectF rectF1 = new RectF(mStrokeWidth / 2, mStrokeWidth / 2, mProgressWidth - mStrokeWidth / 2, mViewHeight - mStrokeWidth / 2);
Path path = new Path();
Path dstPath = new Path();
PathMeasure pathMeasure = new PathMeasure();
path.moveTo(0, 0);
path.lineTo(mViewWidth, 0);
pathMeasure.setPath(path, false);
pathMeasure.getSegment(0, pathMeasure.getLength() * mAnimatorValue, dstPath, true);
//渐变
Shader mShader = new LinearGradient(mStrokeWidth / 2, mStrokeWidth / 2, mProgressWidth, mHeight - mStrokeWidth / 2, Color.parseColor("#FBB643"), Color.parseColor("#FC802B"), Shader.TileMode.REPEAT);
//遮罩
mProgressPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
mProgressPaint.setShader(mShader);
canvas.drawRect(rectF1, mProgressPaint);
mProgressPaint.setXfermode(null);
//刻度
// for (int i = 0; i < 4; i++) {
// canvas.drawLine((i + 1) * mMackTickWidth, mStrokeWidth / 2, (i + 1) * mMackTickWidth, mViewHeight - mStrokeWidth / 2, mMackTickPaint);
// }
}
/**
* 0--1
*/
public void setProgress(float progress) {
if (progress < 0) {
progress = 0;
} else if (progress > 1) {
progress = 1;
}
int delta = (int) (progress / 0.1);
LogUtil.d("delta:" + delta);
delta = delta == 0 ? 1 : delta;
mProgressWidth = (int) (progress * mViewWidth);
mAnimator = ValueAnimator.ofFloat(0, progress).setDuration(delta * DURATION);
mUpdateListener = new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
mAnimatorValue = (float) animation.getAnimatedValue();
mProgressWidth = (int) (mAnimatorValue * mViewWidth);
invalidate();
}
};
mAnimator.addUpdateListener(mUpdateListener);
mAnimator.start();
}
}
\ No newline at end of file
......@@ -5,32 +5,48 @@
android:layout_marginStart="30dp"
android:layout_marginEnd="30dp"
android:background="@drawable/shape_dialog_friends"
android:gravity="center_horizontal"
android:orientation="vertical"
android:padding="20dp">
<TextView
android:id="@+id/tv_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/black"
android:textSize="20sp"
android:textStyle="bold"
android:visibility="gone" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/tv_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:textColor="@color/black"
android:textSize="20sp"
android:textStyle="bold"
android:visibility="gone" />
<ImageView
android:id="@+id/iv_close"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:src="@mipmap/ic_close" />
</RelativeLayout>
<TextView
android:id="@+id/tv_content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_marginLeft="4dp"
android:layout_marginTop="10dp"
android:layout_marginRight="4dp"
android:layout_marginBottom="10dp"
android:textColor="@color/gray"
android:textSize="16sp" />
android:textSize="14sp" />
<Button
android:id="@+id/btn_submit"
android:layout_width="200dp"
android:layout_height="42dp"
android:layout_marginTop="20dp"
android:layout_gravity="center_horizontal"
android:background="@drawable/shape_btn_friends"
android:gravity="center"
android:textColor="@color/white"
......
......@@ -8,7 +8,7 @@
<include
android:id="@+id/friendsLayout"
layout="@layout/header_layout"
android:visibility="gone"/>
android:visibility="gone" />
<com.scwang.smartrefresh.layout.SmartRefreshLayout
android:id="@+id/srl_my"
......@@ -28,9 +28,9 @@
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:stateListAnimator="@animator/appbar_elevation"
android:background="@color/color_F8F8F8"
app:layout_behavior=".ui.widgets.FlingBehavior">
android:stateListAnimator="@animator/appbar_elevation"
app:layout_behavior="com.mints.goodnews.ui.widgets.FlingBehavior">
<LinearLayout
android:layout_width="match_parent"
......@@ -174,7 +174,7 @@
android:gravity="center"
android:paddingEnd="10dp"
android:text="@string/dot"
android:textSize="18sp"
android:textSize="22sp"
app:layout_constraintBottom_toTopOf="@id/tv_today_bonus"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_weight="1"
......@@ -189,7 +189,7 @@
android:gravity="center"
android:paddingEnd="10dp"
android:text="@string/dot"
android:textSize="18sp"
android:textSize="22sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_weight="1"
......@@ -227,7 +227,7 @@
android:layout_marginStart="6dp"
android:layout_marginTop="40dp"
android:text="@string/dot"
android:textSize="18sp" />
android:textSize="22sp" />
<Button
android:id="@+id/btn_get_bonus"
......@@ -245,7 +245,9 @@
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/inviteLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="15dp"
......@@ -253,14 +255,15 @@
android:layout_marginBottom="10dp"
android:background="@drawable/shape_gold_card"
android:elevation="2dip"
android:padding="15dp">
android:padding="15dp"
android:visibility="visible">
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:text="亲友团成员"
android:text="邀请好友 奖励现金"
android:textColor="@color/black"
android:textSize="18sp"
app:layout_constraintBottom_toTopOf="@+id/line"
......@@ -280,83 +283,30 @@
android:id="@+id/line"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginTop="15dp"
android:layout_marginTop="10dp"
android:background="@color/color_F8F8F8"
app:layout_constraintTop_toBottomOf="@id/textView" />
<TextView
android:id="@+id/friends_sum"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:gravity="center"
android:text="@string/dot"
android:textColor="@color/black"
android:textSize="20sp"
app:layout_constraintEnd_toStartOf="@id/friends_directly_sum"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/line" />
<TextView
android:id="@+id/friends_tv"
android:id="@+id/tv_invited_info"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="6dp"
android:text="总人数"
app:layout_constraintEnd_toEndOf="@+id/friends_sum"
app:layout_constraintStart_toStartOf="@+id/friends_sum"
app:layout_constraintTop_toBottomOf="@id/friends_sum" />
<TextView
android:id="@+id/friends_directly_sum"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:gravity="center"
android:text="@string/dot"
android:textColor="@color/black"
android:textSize="20sp"
app:layout_constraintEnd_toStartOf="@id/friends_indirect_sum"
app:layout_constraintStart_toEndOf="@id/friends_sum"
app:layout_constraintTop_toBottomOf="@id/line" />
<TextView
android:id="@+id/tv_friends_directly"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="6dp"
android:drawableEnd="@mipmap/ic_question"
android:drawablePadding="6dp"
android:text="直接亲友"
app:layout_constraintEnd_toEndOf="@+id/friends_directly_sum"
app:layout_constraintStart_toStartOf="@+id/friends_directly_sum"
app:layout_constraintTop_toBottomOf="@id/friends_directly_sum" />
<TextView
android:id="@+id/friends_indirect_sum"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:gravity="center"
android:text="@string/dot"
android:text="您已邀请-人"
android:textColor="@color/black"
android:textSize="20sp"
app:drawableEndCompat="@mipmap/ic_question"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/friends_directly_sum"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/line" />
<TextView
android:id="@+id/tv_friends_indirect"
android:layout_width="wrap_content"
<com.mints.goodnews.ui.widgets.ProgressLayout
android:id="@+id/progress_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="6dp"
android:drawablePadding="6dp"
android:text="间接亲友"
app:drawableEndCompat="@mipmap/ic_question"
app:layout_constraintEnd_toEndOf="@+id/friends_indirect_sum"
app:layout_constraintStart_toStartOf="@+id/friends_indirect_sum"
app:layout_constraintTop_toBottomOf="@id/friends_indirect_sum" />
android:layout_marginTop="10dp"
android:visibility="gone"
app:layout_constraintTop_toBottomOf="@id/tv_invited_info" />
<Button
android:id="@+id/btn_invite"
......@@ -371,7 +321,7 @@
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_friends_directly" />
app:layout_constraintTop_toBottomOf="@id/progress_layout" />
</androidx.constraintlayout.widget.ConstraintLayout>
......
<?xml version="1.0" encoding="utf-8"?>
<merge xmlns:android="http://schemas.android.com/apk/res/android">
<androidx.appcompat.widget.LinearLayoutCompat
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="100">
<TextView
android:id="@+id/tv_box1"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="15"
android:drawablePadding="20dp"
android:gravity="center_horizontal"
android:text="10人"
android:textColor="@color/black" />
<TextView
android:textColor="@color/black"
android:id="@+id/tv_box2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="15"
android:drawablePadding="20dp"
android:gravity="center_horizontal"
android:text="50人" />
<TextView
android:textColor="@color/black"
android:id="@+id/tv_box3"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="20"
android:drawablePadding="20dp"
android:gravity="center_horizontal"
android:text="100人" />
<TextView
android:textColor="@color/black"
android:id="@+id/tv_box4"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="30"
android:drawablePadding="20dp"
android:gravity="center_horizontal"
android:text="500人" />
<TextView
android:textColor="@color/black"
android:id="@+id/tv_box5"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="20"
android:drawablePadding="20dp"
android:gravity="center_horizontal"
android:text="1000人" />
</androidx.appcompat.widget.LinearLayoutCompat>
<com.mints.goodnews.ui.widgets.TickProgress
android:id="@+id/tick_progress"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp" />
</merge>
\ 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