Skip to content

Commit

Permalink
😍😍😍为祖国母亲庆生,添加国庆主题
Browse files Browse the repository at this point in the history
  • Loading branch information
hegj committed Sep 28, 2019
1 parent 40db404 commit 81071b9
Show file tree
Hide file tree
Showing 14 changed files with 147 additions and 402 deletions.
394 changes: 68 additions & 326 deletions app/priguardMapping.txt

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion app/release/output.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":4,"versionName":"1.0.3","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release"},"path":"app-release.apk","properties":{}}]
[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":6,"versionName":"1.0.5","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release"},"path":"app-release.apk","properties":{}}]
22 changes: 1 addition & 21 deletions app/src/main/java/me/hegj/wandroid/app/AppLifecyclesImpl.kt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import com.tencent.bugly.Bugly
import com.tencent.bugly.crashreport.CrashReport.UserStrategy
import com.tencent.mmkv.MMKV
import me.hegj.wandroid.BuildConfig
import me.hegj.wandroid.R
import me.hegj.wandroid.app.utils.HttpUtils
import me.hegj.wandroid.app.weight.loadCallBack.EmptyCallback
import me.hegj.wandroid.app.weight.loadCallBack.ErrorCallback
Expand All @@ -55,25 +54,6 @@ class AppLifecyclesImpl : AppLifecycles {
}

override fun onCreate(application: Application) {
//初始化 SmartSwipeBack
/* SmartSwipeBack.activityBack(application, { activity ->
MyActivitySlidingBackConsumer(activity)
.setRelativeMoveFactor(0.5f)
.setScrimColor(-0x80000000)
.setShadowColor(-0x80000000)
.setShadowSize(SmartSwipe.dp2px(20, application))
.setEdgeSize(SmartSwipe.dp2px(20, application))
.enableDirection(DIRECTION_LEFT)
.addListener(object : SimpleSwipeListener() {
override fun onSwipeOpened(wrapper: SmartSwipeWrapper?, consumer: SwipeConsumer?, direction: Int) {
activity.finish()
activity.overridePendingTransition(R.anim.anim_none, R.anim.anim_none)
}
})
}, {
it !is MainActivity || it is SplashActivity//禁止主Activity滑动返回
})*/

//初始化MMKV
MMKV.initialize(application.filesDir.absolutePath + "/mmkv")

Expand Down Expand Up @@ -101,7 +81,7 @@ class AppLifecyclesImpl : AppLifecycles {
val strategy = UserStrategy(context)
strategy.isUploadProcess = processName == null || processName == packageName
// 初始化Bugly
Bugly.init(context, "xxxx", BuildConfig.DEBUG)
Bugly.init(context, "xxx", BuildConfig.DEBUG)

CaocConfig.Builder.create()
.backgroundMode(CaocConfig.BACKGROUND_MODE_SILENT) //default: CaocConfig.BACKGROUND_MODE_SHOW_CUSTOM
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/me/hegj/wandroid/app/utils/ColorUtil.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ object ColorUtil {
Color.parseColor("#78909C"))

val PRIMARY_COLORS_SUB = arrayOf(
intArrayOf(Color.parseColor("#EF5350"), Color.parseColor("#F44336"), Color.parseColor("#E53935"), Color.parseColor("#D32F2F"), Color.parseColor("#C62828"), Color.parseColor("#B71C1C")),
intArrayOf(Color.parseColor("#EF5350"), Color.parseColor("#F44336"), Color.parseColor("#E53935"),Color.parseColor("#e10015"), Color.parseColor("#D32F2F"), Color.parseColor("#C62828"), Color.parseColor("#B71C1C")),
intArrayOf(Color.parseColor("#EC407A"), Color.parseColor("#E91E63"), Color.parseColor("#D81B60"), Color.parseColor("#C2185B"), Color.parseColor("#AD1457"), Color.parseColor("#880E4F")),
intArrayOf(Color.parseColor("#AB47BC"), Color.parseColor("#9C27B0"), Color.parseColor("#8E24AA"), Color.parseColor("#7B1FA2"), Color.parseColor("#6A1B9A"), Color.parseColor("#4A148C")),
intArrayOf(Color.parseColor("#7E57C2"), Color.parseColor("#673AB7"), Color.parseColor("#5E35B1"), Color.parseColor("#512DA8"), Color.parseColor("#4527A0"), Color.parseColor("#311B92")),
Expand Down
29 changes: 26 additions & 3 deletions app/src/main/java/me/hegj/wandroid/app/utils/DatetimeUtil.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,18 @@ object DatetimeUtil {
val nows: Date
get() = formatDate(DATE_PATTERN, now)



/**
* Date to Strin
*/
@SuppressLint("SimpleDateFormat")
fun formatDate(date: Date?, formatStyle: String): String {
if (date != null) {
return if (date != null) {
val sdf = SimpleDateFormat(formatStyle)
return sdf.format(date)
sdf.format(date)
} else {
return ""
""
}

}
Expand All @@ -48,6 +51,20 @@ object DatetimeUtil {
return sdf.format(Date(date))

}

fun formatDate(formatStyle: String, formatStr: String): Date {
val format = SimpleDateFormat(formatStyle, Locale.CHINA)
return try {
val date = Date()
date.time = format.parse(formatStr).time
date
} catch (e: Exception) {
println(e.message)
nows
}

}

/**
* Date to Date
*/
Expand Down Expand Up @@ -76,5 +93,11 @@ object DatetimeUtil {
return Date(lt)
}

/**
* 获得指定时间的日期
*/
fun getCustomTime(dateStr: String):Date{
return formatDate(DATE_PATTERN,dateStr)
}

}
32 changes: 21 additions & 11 deletions app/src/main/java/me/hegj/wandroid/app/utils/SettingUtil.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ import android.graphics.drawable.GradientDrawable
import android.graphics.drawable.StateListDrawable
import android.os.Build
import android.preference.PreferenceManager
import android.util.TypedValue
import android.view.View
import android.widget.ProgressBar
import com.jess.arms.utils.ArmsUtils
import com.kingja.loadsir.core.LoadService
import me.hegj.wandroid.R
import me.hegj.wandroid.app.weight.loadCallBack.LoadingCallback
import java.lang.reflect.InvocationTargetException
import kotlin.math.roundToInt


object SettingUtil {
Expand All @@ -24,12 +24,16 @@ object SettingUtil {
* 获取主题颜色
*/
fun getColor(context: Context): Int {
val setting = PreferenceManager.getDefaultSharedPreferences(context)
val defaultColor = ArmsUtils.getColor(context, R.color.colorPrimary)
val color = setting.getInt("color", defaultColor)
return if (color != 0 && Color.alpha(color) != 255) {
defaultColor
} else color
return if(isHoliDay()){
ArmsUtils.getColor(context, R.color.chinaHoliDay)
}else{
val setting = PreferenceManager.getDefaultSharedPreferences(context)
val defaultColor = ArmsUtils.getColor(context, R.color.colorPrimary)
val color = setting.getInt("color", defaultColor)
if (color != 0 && Color.alpha(color) != 255) {
defaultColor
} else color
}
}

/**
Expand Down Expand Up @@ -87,7 +91,7 @@ object SettingUtil {
return ColorStateList(states, colors)
}

fun getOneColorStateList(color:Int): ColorStateList {
fun getOneColorStateList(color: Int): ColorStateList {
val colors = intArrayOf(color)
val states = arrayOfNulls<IntArray>(1)
states[0] = intArrayOf()
Expand All @@ -108,11 +112,12 @@ object SettingUtil {
/**
* 设置shap的渐变颜色
*/
fun setShapColor(view:View,color:IntArray,orientation: GradientDrawable.Orientation){
fun setShapColor(view: View, color: IntArray, orientation: GradientDrawable.Orientation) {
val drawable = view.background as GradientDrawable
drawable.orientation = orientation//渐变方向
drawable.colors = color//渐变颜色数组
}

/**
* 设置selector文件的颜色
*
Expand Down Expand Up @@ -157,7 +162,7 @@ object SettingUtil {
*/
fun translucentColor(color: Int): Int {
val factor = 0.5f
val alpha = Math.round(Color.alpha(color) * factor)
val alpha = (Color.alpha(color) * factor).roundToInt()
val red = Color.red(color)
val green = Color.green(color)
val blue = Color.blue(color)
Expand All @@ -176,7 +181,12 @@ object SettingUtil {
}
}


/**
* 判断是否过了国庆节了
*/
fun isHoliDay(): Boolean {
return DatetimeUtil.nows <= DatetimeUtil.getCustomTime("2019-10-7")
}


}
6 changes: 3 additions & 3 deletions app/src/main/java/me/hegj/wandroid/app/utils/ShowUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,10 @@ object ShowUtils {
/**
* 在屏幕底部吐司 默认
*/
fun showToast(context: Context, arg: String) {
if (!TextUtils.isEmpty(arg)) {
fun showToast(context: Context, msg: String) {
if (!TextUtils.isEmpty(msg)) {
toast?.cancel()
toast = Toast.makeText(context.applicationContext, arg, Toast.LENGTH_SHORT).apply {
toast = Toast.makeText(context.applicationContext, msg, Toast.LENGTH_SHORT).apply {
show()
}
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
package me.hegj.wandroid.mvp.presenter.main.home

import android.app.Application
import android.content.Intent
import android.util.Log
import androidx.lifecycle.LifecycleOwner

import com.jess.arms.integration.AppManager
import com.jess.arms.di.scope.FragmentScope
import com.jess.arms.mvp.BasePresenter
import com.jess.arms.http.imageloader.ImageLoader
import com.jess.arms.integration.AppManager
import com.jess.arms.mvp.BasePresenter
import com.jess.arms.utils.RxLifecycleUtils
import com.trello.rxlifecycle2.android.FragmentEvent
import io.reactivex.Observable
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.functions.BiFunction
import io.reactivex.functions.Consumer
import io.reactivex.schedulers.Schedulers
import me.hegj.wandroid.app.utils.HttpUtils
import me.hegj.wandroid.app.utils.SettingUtil
import me.jessyan.rxerrorhandler.core.RxErrorHandler
import javax.inject.Inject

import me.hegj.wandroid.mvp.contract.main.home.HomeContract
import me.hegj.wandroid.mvp.model.entity.*
import me.hegj.wandroid.mvp.ui.activity.web.WebviewActivity
import me.hegj.wandroid.mvp.model.entity.ApiPagerResponse
import me.hegj.wandroid.mvp.model.entity.ApiResponse
import me.hegj.wandroid.mvp.model.entity.AriticleResponse
import me.hegj.wandroid.mvp.model.entity.BannerResponse
import me.hegj.wandroid.mvp.ui.adapter.AriticleAdapter
import me.jessyan.rxerrorhandler.core.RxErrorHandler
import me.jessyan.rxerrorhandler.handler.ErrorHandleSubscriber
import me.jessyan.rxerrorhandler.handler.RetryWithDelay
import javax.inject.Inject


/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import me.hegj.wandroid.app.event.LoginFreshEvent
import me.hegj.wandroid.app.event.SettingChangeEvent
import me.hegj.wandroid.app.utils.RecyclerViewUtils
import me.hegj.wandroid.app.utils.SettingUtil
import me.hegj.wandroid.app.utils.ShowUtils
import me.hegj.wandroid.app.weight.CollectView
import me.hegj.wandroid.app.weight.DefineLoadMoreView
import me.hegj.wandroid.app.weight.loadCallBack.EmptyCallback
Expand Down Expand Up @@ -106,7 +107,14 @@ class HomeFragment : BaseFragment<HomePresenter>(), HomeContract.View {
super.initData(savedInstanceState)
toolbar.run {
setBackgroundColor(SettingUtil.getColor(_mActivity))
title = "首页"
//当前时间时间没有超过10月7号,使用国庆主题
if(SettingUtil.isHoliDay()){
title = "为祖国母亲庆生"
setNavigationIcon(R.drawable.china_day)
setNavigationOnClickListener { this@HomeFragment.showMessage("祝老哥国庆节快乐,感谢老哥的支持,没有卸载这个APP,哈哈") }
}else{
title = "首页"
}
inflateMenu(R.menu.home_menu)
setOnMenuItemClickListener {
when (it.itemId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ class GeneralPreferenceFragment : PreferenceFragmentCompat(), SharedPreferences.
SettingUtil.setColor(parentActivity, color)
//通知其他界面立马修改配置
SettingChangeEvent().post()
if(SettingUtil.isHoliDay()){
parentActivity.showMessage("大家一起给祖国母亲庆生,固定大红色走起,10月8号自动恢复正常")
}
}
positiveButton(R.string.done)
negativeButton(R.string.cancel)
Expand Down
Binary file added app/src/main/res/drawable-xxxhdpi/china_day.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions app/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@
<color name="texttipColor">#a0a0a0</color>
<color name="diverColoe">#cecece</color>
<color name="accent">#E91E63</color>
<color name="chinaHoliDay">#e10015</color>
</resources>
6 changes: 2 additions & 4 deletions config.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ ext {
buildToolsVersion: "28.0.3",
minSdkVersion : 21,
targetSdkVersion : 28,
versionCode : 5,
versionName : "1.0.4"
versionCode : 6,
versionName : "1.0.5"
]

version = [
Expand Down Expand Up @@ -150,8 +150,6 @@ ext {
"flow-layout" : 'com.hyman:flowlayout-lib:1.1.2',
//高性能通用 key-value 组件
"mmkv" : 'com.tencent:mmkv:1.0.22',
//侧滑返回
"swipe" : 'com.billy.android:smart-swipe:1.0.7',
//阻止app崩溃
"customactivityoncrash" : 'cat.ereza:customactivityoncrash:2.2.0',

Expand Down

0 comments on commit 81071b9

Please sign in to comment.