Commit 199e898c authored by mengcuiguang's avatar mengcuiguang

代码优化

parent 2cae5664
......@@ -10,8 +10,8 @@ android {
applicationId "com.duben.loveplayletu"
minSdkVersion rootProject.ext.androidMinSdkVersion
targetSdkVersion rootProject.ext.androidTargetSdkVersion
versionCode 723
versionName "7.2.3"
versionCode 725
versionName "7.2.5"
flavorDimensions "default"
// dex突破65535的限制
......
......@@ -188,6 +188,12 @@
android:hardwareAccelerated="true"
android:screenOrientation="portrait" />
<activity
android:name=".ui.activities.AlipayTimeActivity"
android:exported="false"
android:screenOrientation="portrait"
android:theme="@style/TransparentTheme" />
<activity
android:name=".video.tx.newrecommend.NewTxVideoActivity"
android:exported="false"
......
package com.duben.loveplayletu.ui.activitys
import android.view.KeyEvent
import android.view.View
import com.duben.library.utils.nodoubleclick.AntiShake
import com.duben.loveplayletu.R
import com.duben.loveplayletu.ui.activitys.base.BaseActivity
import com.duben.loveplayletu.ui.widgets.SimpleCountDownTimer
import kotlinx.android.synthetic.main.activity_alipaytime.*
/**
* 描述:支付倒计时
* 作者:孟崔广
*/
class AlipayTimeActivity : BaseActivity(), View.OnClickListener {
private var countDownTimer: SimpleCountDownTimer? = null
override fun getContentViewLayoutID() = R.layout.activity_alipaytime
override fun isApplyKitKatTranslucency() = false
override fun toggleOverridePendingTransition() = true
override fun getOverridePendingTransitionMode() = TransitionMode.SCALE
override fun initViewsAndEvents() {
countDownTimer= SimpleCountDownTimer(5000, tv_alipaytime).setOnFinishListener {
showToast("11111")
}.start() as SimpleCountDownTimer?
}
override fun finish() {
super.finish()
overridePendingTransition(0, R.anim.scale_out)
}
override fun onDestroy() {
super.onDestroy()
countDownTimer?.cancel()
}
override fun onKeyDown(keyCode: Int, event: KeyEvent): Boolean {
return if (keyCode == KeyEvent.KEYCODE_BACK) {
true
} else super.onKeyDown(keyCode, event)
}
override fun onClick(v: View) {
if (AntiShake.check(v.id)) return
// when (v.id) {
// R.id.ivAwardBack -> {
// finish()
// }
// }
}
}
\ No newline at end of file
......@@ -89,21 +89,6 @@ class MainFragment : LazyLoadBaseFragment(), HomeView, View.OnClickListener, OnR
* 跳转到主页面
*/
private fun goToMainActivity() {
// if (UserManager.getInstance().newFlag && !UserManager.getInstance().vipFlag) {
// homePresenter.getRecommendVedio()
//
// val bundle = Bundle()
// bundle.putBoolean(VipActivity.IS_MAIN, true)
// readyGo(VipActivity::class.java, bundle)
// } else {
// homePresenter.getSoltVedio()
// }
// if (UserManager.getInstance().newFlag && !UserManager.getInstance().vipFlag) {
// val bundle = Bundle()
// bundle.putBoolean(VipActivity.IS_MAIN, true)
// readyGo(VipActivity::class.java, bundle)
// }
homePresenter.getSoltVedio()
}
......@@ -116,9 +101,6 @@ class MainFragment : LazyLoadBaseFragment(), HomeView, View.OnClickListener, OnR
if (AppConfig.fragmentClickFlag == Constant.FRAGMENT_CLICK_ONE) {
if (AntiShake.check(banner?.id)) return
// if (!UserManager.getInstance().vipFlag) {
// BannerManager.loadAd(requireActivity(), fl_main_banner)
// }
BannerManager.loadAd(requireActivity(), fl_main_banner)
if (AppConfig.exitLoginMainRefresh) {
......@@ -167,7 +149,8 @@ class MainFragment : LazyLoadBaseFragment(), HomeView, View.OnClickListener, OnR
if (AntiShake.check(v?.id)) return
when (v?.id) {
R.id.iv_kefu_main -> {
(requireActivity() as MainActivity).backPhoneDialog()
// (requireActivity() as MainActivity).backPhoneDialog()
readyGo(AlipayTimeActivity::class.java)
}
R.id.iv_main_watching_close -> {
LocalVedioManager.closeCacheVedio()
......
package com.duben.loveplayletu.ui.widgets;
import android.os.CountDownTimer;
import android.widget.TextView;
/**
* 简单 时,分,秒,毫秒倒计时
*
* @author Luo Guowen Email:<a href="#">luoguowen123@qq.com</a>
* <p>
* 精确到毫秒
*/
public class SimpleCountDownTimer extends CountDownTimer {
// 默认倒计时间隔
private static final long DEFAULT_INTERVAL = 100L;
/**
* 秒,分,时对应的毫秒数
*/
private int sec = 1000, min = sec * 60, hr = min * 60;
/**
* 显示时间的视图
*/
private TextView tvDisplay;
/**
* 结束监听
*/
private static OnFinishListener onFinishListener;
/**
* @param millisInFuture 倒计时总时间 单位:毫秒
* The number of millis in the future from the call
* to {@link #start()} until the countdown is done and {@link #onFinish()}
* is called.
* @param countDownInterval 倒计时间隔 单位:毫秒
* The interval along the way to receive
* {@link #onTick(long)} callbacks.
* @param tvDisplay 显示时间的视图
*/
public SimpleCountDownTimer(long millisInFuture, long countDownInterval, TextView tvDisplay) {
super(millisInFuture, countDownInterval);
this.tvDisplay = tvDisplay;
}
/**
* @param millisInFuture 倒计时总时间 单位:毫秒
* The number of millis in the future from the call
* to {@link #start()} until the countdown is done and {@link #onFinish()}
* is called.
* @param tvDisplay 显示时间的视图
*/
public SimpleCountDownTimer(long millisInFuture, TextView tvDisplay) {
super(millisInFuture, DEFAULT_INTERVAL);
this.tvDisplay = tvDisplay;
}
/**
* 每一次间隔时间到后调用
*
* @param millisUntilFinished 剩余总时间 单位:毫秒
*/
@Override
public void onTick(long millisUntilFinished) {
// 剩余的小时,分钟,秒,毫秒
long lHr = millisUntilFinished / hr;
long lMin = (millisUntilFinished - lHr * hr) / min;
long lSec = (millisUntilFinished - lHr * hr - lMin * min) / sec;
long lMs = millisUntilFinished - lHr * hr - lMin * min - lSec * sec;
String strLHr = getTime(lHr);
String strLMin = getTime(lMin);
String strLSec = getTime(lSec);
String strLMs = getMs(lMs);
// 依次拼接时间 时:分:秒:毫秒
tvDisplay.setText(strLHr + ":" + strLMin + ":" + strLSec + ":" + strLMs);
}
/**
* 根据毫秒换算成相应单位后是否大于10来返回相应时间
*/
private String getTime(long time) {
return time > 10 ? String.valueOf(time) : "0" + time;
}
/**
* 获取毫秒
*/
private String getMs(long time) {
String strMs = String.valueOf(time);
return time > 100 ? strMs.substring(0, strMs.length() - 1) : "00";
}
/**
* 结束监听,可以在倒计时结束时做一些事
*/
public interface OnFinishListener {
void onFinish();
}
/**
* 设置结束监听
*
* @param onFinishListener 结束监听对象
*/
public SimpleCountDownTimer setOnFinishListener(OnFinishListener onFinishListener) {
SimpleCountDownTimer.onFinishListener = onFinishListener;
return this;
}
/**
* 倒计时结束时调用
*/
@Override
public void onFinish() {
tvDisplay.setText("00:00:00");
if (onFinishListener != null)
onFinishListener.onFinish();
}
}
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/full_transparent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:layout_width="200dp"
android:layout_height="200dp"
android:layout_gravity="center"
android:src="@mipmap/ic_my_new"></ImageView>
<TextView
android:id="@+id/tv_alipaytime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/red"></TextView>
</LinearLayout>
</ScrollView>
\ 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