Commit 0505771a authored by jyx's avatar jyx

首页布局

parent 08ce734b
...@@ -3,15 +3,15 @@ ...@@ -3,15 +3,15 @@
package="com.mints.cleaner"> package="com.mints.cleaner">
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.INTERNET" />
<application <application
android:name=".App" android:name=".App"
android:allowBackup="true" android:allowBackup="true"
android:icon="@mipmap/ic_launcher" android:icon="@mipmap/ic_launcher"
android:label="@string/app_name" android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:networkSecurityConfig="@xml/network_security_config" android:networkSecurityConfig="@xml/network_security_config"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true" android:supportsRtl="true"
android:theme="@style/AppTheme"> android:theme="@style/AppTheme">
...@@ -20,8 +20,8 @@ ...@@ -20,8 +20,8 @@
android:name="android.max_aspect" android:name="android.max_aspect"
android:value="2.4" /> android:value="2.4" />
<activity android:name=".ui.login.LoginActivity"/> <activity android:name=".ui.login.LoginActivity" />
<activity android:name=".ui.SplashActivity" /> <activity android:name=".ui.splash.SplashActivity" />
<activity android:name=".ui.NavigationActivity"> <activity android:name=".ui.NavigationActivity">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
......
...@@ -3,11 +3,11 @@ package com.mints.cleaner ...@@ -3,11 +3,11 @@ package com.mints.cleaner
import android.app.Application import android.app.Application
import android.content.Context import android.content.Context
import com.mints.cleaner.di.appModule import com.mints.cleaner.di.appModule
import com.mints.cleaner.util.SystemUtils
import com.mints.cleaner.util.lifecycle.LifeManager import com.mints.cleaner.util.lifecycle.LifeManager
import com.orhanobut.logger.AndroidLogAdapter import com.mints.core.design_width
import com.orhanobut.logger.FormatStrategy import com.mints.core.util.RudenessScreenHelperKt
import com.orhanobut.logger.Logger import com.mints.core.util.SmartBarUtils
import com.orhanobut.logger.PrettyFormatStrategy
import org.koin.android.ext.koin.androidContext import org.koin.android.ext.koin.androidContext
import org.koin.core.context.startKoin import org.koin.core.context.startKoin
import kotlin.properties.Delegates import kotlin.properties.Delegates
...@@ -22,23 +22,37 @@ class App : Application() { ...@@ -22,23 +22,37 @@ class App : Application() {
super.onCreate() super.onCreate()
CONTEXT = applicationContext CONTEXT = applicationContext
initThridConfig() // 初始化koin model
initStartKoin()
// 生命周期
LifeManager().install(this)
initThirdConfig()
} }
/** /**
* 加载第三方配置 * 加载第三方配置
*/ */
private fun initThridConfig() { private fun initThirdConfig() {
// 初始化koin model // 屏幕适配
initStartKoin() initRudenessScreen()
// 自定义logger
initLogger()
// 生命周期 // 生命周期
LifeManager().install(this) LifeManager().install(this)
// 子线程初始化三方SDK
val processName = SystemUtils.getProcessName(this, android.os.Process.myPid())
if (processName != null) {
// 判断onCreate方法执行是否在当前应用的application上
val defaultProcess: Boolean = processName == "com.mints.cleaner"
if (defaultProcess) {
InitAppService.start(this) //初始化数据
}
}
} }
/** /**
...@@ -52,15 +66,12 @@ class App : Application() { ...@@ -52,15 +66,12 @@ class App : Application() {
} }
/** /**
* 自定义logger * 机型适配
*/ */
private fun initLogger() { private fun initRudenessScreen() {
val formatStrategy: FormatStrategy = PrettyFormatStrategy.newBuilder() val hasSmartBar: Boolean = SmartBarUtils.hasSmartBar(this)
.showThreadInfo(false) //是否选择显示线程信息,默认为true design_width = if (hasSmartBar) 800F else 750F
.methodCount(0) //方法数显示多少行,默认2行 RudenessScreenHelperKt(this, design_width).activate()
.methodOffset(7) //隐藏方法内部调用到偏移量,默认5
.tag("mints---network") //自定义TAG全部标签,默认PRETTY_LOGGER
.build()
Logger.addLogAdapter(AndroidLogAdapter(formatStrategy))
} }
} }
\ No newline at end of file
package com.mints.cleaner
object Constant {
// 圆形进度配置
const val ANTI_ALIAS = true
const val DEFAULT_SIZE = 150
const val DEFAULT_START_ANGLE = 270
const val DEFAULT_SWEEP_ANGLE = 360
const val DEFAULT_ANIM_TIME = 1000
const val DEFAULT_MAX_VALUE = 100
const val DEFAULT_VALUE = 50
const val DEFAULT_HINT_SIZE = 15
const val DEFAULT_UNIT_SIZE = 30
const val DEFAULT_VALUE_SIZE = 15
const val DEFAULT_ARC_WIDTH = 15
const val DEFAULT_WAVE_HEIGHT = 40
}
\ No newline at end of file
package com.mints.cleaner
import android.app.IntentService
import android.content.Context
import android.content.Intent
import android.util.Log
import com.orhanobut.logger.AndroidLogAdapter
import com.orhanobut.logger.FormatStrategy
import com.orhanobut.logger.Logger
import com.orhanobut.logger.PrettyFormatStrategy
class InitAppService : IntentService("InitializeService") {
companion object {
const val ACTION_INIT = "initApplication"
const val TAG = "InitAppService"
var IS_DEBUG = BuildConfig.LOG_DEBUG
/**
* 开启intentService
*/
fun start(context: Context) {
val intent = Intent(context, InitAppService::class.java)
intent.action = ACTION_INIT
context.startService(intent)
}
}
var isInit: Boolean = false
override fun onHandleIntent(intent: Intent?) {
if (isInit) return
intent?.let {
val action = intent.action
if (ACTION_INIT == action) {
Log.d(TAG, "onHandleIntent")
initApplication()
isInit = false
}
}
}
/**
* 子线程进行初始化SDK操作
*/
private fun initApplication() {
// 自定义logger
initLogger()
}
/**
* 自定义logger
*/
private fun initLogger() {
if (IS_DEBUG) {
val formatStrategy: FormatStrategy = PrettyFormatStrategy.newBuilder()
.showThreadInfo(false) //是否选择显示线程信息,默认为true
.methodCount(0) //方法数显示多少行,默认2行
.methodOffset(7) //隐藏方法内部调用到偏移量,默认5
.tag("mints---network") //自定义TAG全部标签,默认PRETTY_LOGGER
.build()
Logger.addLogAdapter(AndroidLogAdapter(formatStrategy))
}
}
}
\ No newline at end of file
package com.mints.cleaner.adapter.clean
import android.widget.GridView
import android.widget.SimpleAdapter
import com.chad.library.adapter.base.BaseMultiItemQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.mints.cleaner.R
class CleanAdapter : BaseMultiItemQuickAdapter<CleanMultiItem, BaseViewHolder> {
private val names = arrayOf("手机加速", "微信清理", "QQ清理", "软件管理", "相册清理", "视频清理")
constructor(data: List<CleanMultiItem>) : super(data) {
addItemType(CleanMultiItem.ITEM_TOP, R.layout.item_clean_top)
addItemType(CleanMultiItem.ITEM_MID, R.layout.item_clean_mid)
addItemType(CleanMultiItem.ITEM_BOTTOM, R.layout.item_clean_bottom)
}
override fun convert(helper: BaseViewHolder, item: CleanMultiItem?) {
when (helper.itemViewType) {
CleanMultiItem.ITEM_TOP -> {
helper.addOnClickListener(R.id.btn_clean)
}
CleanMultiItem.ITEM_MID -> {
val listitem: MutableList<Map<String, Any>> =
ArrayList()
for (i in names.indices) {
val item: MutableMap<String, Any> = HashMap()
item["item_gv_text"] = names[i]
listitem.add(item)
}
val gridView = helper.getView<GridView>(R.id.gv_clean)
val simpleAdapter = SimpleAdapter(
gridView.context,
listitem,
R.layout.item_gv_clean,
arrayOf("item_gv_text"),
intArrayOf(R.id.item_gv_text)
)
gridView.adapter = simpleAdapter
gridView.setOnItemClickListener { _, _, position, _ ->
onGridViewItemClickListener?.let {
it.onGridViewItemClick(position)
}
}
}
CleanMultiItem.ITEM_BOTTOM -> {
}
}
}
private var onGridViewItemClickListener: OnGridViewItemClickListener? = null
fun setOnGridViewItemClickListener(listener: OnGridViewItemClickListener?) {
onGridViewItemClickListener = listener
}
interface OnGridViewItemClickListener {
fun onGridViewItemClick(position: Int)
}
}
\ No newline at end of file
package com.mints.cleaner.adapter.clean
import com.chad.library.adapter.base.entity.MultiItemEntity
class CleanMultiItem : MultiItemEntity {
private var itemType: Int = 0
private var itemIndex: Int = 0
constructor(itemType: Int) {
this.itemType = itemType
}
constructor(itemType: Int, itemIndex: Int) {
this.itemType = itemType
this.itemIndex = itemIndex
}
companion object {
// 头布局
const val ITEM_TOP = 0x00000001
// 中间布局
const val ITEM_MID = 0x00000002
// 尾布局
const val ITEM_BOTTOM = 0x00000003
}
override fun getItemType(): Int {
return itemType
}
}
\ No newline at end of file
...@@ -3,7 +3,9 @@ package com.mints.cleaner.di ...@@ -3,7 +3,9 @@ package com.mints.cleaner.di
import com.mints.cleaner.model.api.ApiService import com.mints.cleaner.model.api.ApiService
import com.mints.cleaner.model.api.client.RetrofitClient import com.mints.cleaner.model.api.client.RetrofitClient
import com.mints.cleaner.model.repository.LoginRepository import com.mints.cleaner.model.repository.LoginRepository
import com.mints.cleaner.model.repository.MainRepository
import com.mints.cleaner.ui.login.LoginViewModel import com.mints.cleaner.ui.login.LoginViewModel
import com.mints.cleaner.ui.main.MainViewModel
import org.koin.androidx.viewmodel.dsl.viewModel import org.koin.androidx.viewmodel.dsl.viewModel
import org.koin.dsl.module import org.koin.dsl.module
...@@ -11,12 +13,14 @@ import org.koin.dsl.module ...@@ -11,12 +13,14 @@ import org.koin.dsl.module
val viewModelModule = module { val viewModelModule = module {
viewModel { LoginViewModel(get()) } viewModel { LoginViewModel(get()) }
viewModel { MainViewModel(get()) }
} }
val repositoryModule = module { val repositoryModule = module {
single { RetrofitClient.getService( single { RetrofitClient.getService(
ApiService::class.java) } ApiService::class.java) }
single { LoginRepository(get()) } single { LoginRepository(get()) }
single { MainRepository(get()) }
} }
val appModule = listOf(viewModelModule, repositoryModule) val appModule = listOf(viewModelModule, repositoryModule)
\ No newline at end of file
...@@ -22,6 +22,7 @@ import java.nio.charset.Charset ...@@ -22,6 +22,7 @@ import java.nio.charset.Charset
class OkHttpInterceptor(aesKey: String) : Interceptor { class OkHttpInterceptor(aesKey: String) : Interceptor {
private var aesKey = "" private var aesKey = ""
init { init {
this.aesKey = aesKey this.aesKey = aesKey
} }
......
package com.mints.cleaner.model.bean
data class HeaderTitle(
// 标题内容
val title: Int,
// 返回箭头是否显示
val backArrowVisible: Int,
// 右边图标
val rightIcon: Int,
// 背景颜色
val background: Int
)
\ No newline at end of file
package com.mints.cleaner.model.bean
class Title(val title: Int, val icon: Int, val action: () -> Unit)
\ No newline at end of file
package com.mints.cleaner.model.repository
import com.mints.cleaner.model.api.ApiService
import com.mints.cleaner.model.api.client.BaseRepository
class MainRepository(val service: ApiService) : BaseRepository() {
}
\ No newline at end of file
...@@ -5,7 +5,6 @@ import androidx.viewpager2.adapter.FragmentStateAdapter ...@@ -5,7 +5,6 @@ import androidx.viewpager2.adapter.FragmentStateAdapter
import com.google.android.material.bottomnavigation.BottomNavigationView import com.google.android.material.bottomnavigation.BottomNavigationView
import com.mints.cleaner.R import com.mints.cleaner.R
import com.mints.cleaner.ui.home.HomeFragment import com.mints.cleaner.ui.home.HomeFragment
import com.mints.cleaner.ui.my.MyFragment
import com.mints.cleaner.ui.news.NewsFragment import com.mints.cleaner.ui.news.NewsFragment
import com.mints.core.base.BaseFragment import com.mints.core.base.BaseFragment
import kotlinx.android.synthetic.main.activity_bottom_navigation.* import kotlinx.android.synthetic.main.activity_bottom_navigation.*
...@@ -13,18 +12,16 @@ import kotlinx.android.synthetic.main.activity_bottom_navigation.* ...@@ -13,18 +12,16 @@ import kotlinx.android.synthetic.main.activity_bottom_navigation.*
/** /**
* 这是首页 Tab * 这是首页 Tab
*/ */
class MainFragment: BaseFragment() { class MainFragment : BaseFragment() {
private val fragmentList = arrayListOf<Fragment>() private val fragmentList = arrayListOf<Fragment>()
private val homeFragment by lazy { HomeFragment() }//首页 private val homeFragment by lazy { HomeFragment() }//首页
private val newsFragment by lazy { NewsFragment() }//新闻 private val newsFragment by lazy { NewsFragment() }//新闻
private val myFragment by lazy { MyFragment() }//我的
init { init {
fragmentList.run { fragmentList.run {
add(homeFragment) add(homeFragment)
add(newsFragment) add(newsFragment)
add(myFragment)
} }
} }
...@@ -46,9 +43,6 @@ class MainFragment: BaseFragment() { ...@@ -46,9 +43,6 @@ class MainFragment: BaseFragment() {
R.id.wifi -> { R.id.wifi -> {
switchFragment(1) switchFragment(1)
} }
R.id.my -> {
switchFragment(2)
}
} }
true true
} }
......
package com.mints.cleaner.ui.home package com.mints.cleaner.ui.home
import android.graphics.Color
import android.view.LayoutInflater
import android.view.View
import android.widget.Toast
import com.mints.cleaner.R import com.mints.cleaner.R
import com.mints.cleaner.util.LogUtil import com.mints.cleaner.adapter.clean.CleanAdapter
import com.mints.core.base.BaseFragment import com.mints.cleaner.adapter.clean.CleanMultiItem
import com.mints.cleaner.databinding.FragmentCleanBinding
import com.mints.cleaner.model.bean.HeaderTitle
import com.mints.cleaner.ui.main.MainViewModel
import com.mints.core.base.BaseVMFragment
import com.mints.ktx.ext.toast
import org.koin.androidx.viewmodel.ext.android.viewModel
/** /**
* 主页面 * 主页面
*/ */
class HomeFragment :BaseFragment(){ class HomeFragment : BaseVMFragment<FragmentCleanBinding>(R.layout.fragment_clean) {
override fun getLayoutResId()= R.layout.fragment_home private val mainViewModel by viewModel<MainViewModel>()
private val cleanAdapter by lazy { CleanAdapter(multiItemList) }
private val multiItemList =
arrayListOf(
CleanMultiItem(CleanMultiItem.ITEM_TOP),
CleanMultiItem(CleanMultiItem.ITEM_MID),
CleanMultiItem(CleanMultiItem.ITEM_BOTTOM, 0),
CleanMultiItem(CleanMultiItem.ITEM_BOTTOM, 1),
CleanMultiItem(CleanMultiItem.ITEM_BOTTOM, 2),
CleanMultiItem(CleanMultiItem.ITEM_BOTTOM, 3)
)
override fun initView() { override fun initView() {
LogUtil.e("HomeFragment","initView") binding.run {
viewModel = mainViewModel
adapter = cleanAdapter
title = HeaderTitle(
R.string.app_name,
View.GONE,
R.mipmap.ic_activity_arrow,
R.color.theme
)
}
initRecyclerView()
}
private fun initRecyclerView() {
cleanAdapter.run {
addFooterView(LayoutInflater.from(activity).inflate(R.layout.home_footer, null))
// 一键清理
setOnItemChildClickListener { adapter, view, position ->
// 一键清理
activity?.let { toast(it, "一键清理", Toast.LENGTH_SHORT) }
}
// 竖向功能点击事件
setOnItemClickListener { _, _, position ->
when (position) {
2 -> {
// 文件清理
activity?.let { toast(it, "文件清理", Toast.LENGTH_SHORT) }
}
3 -> {
// 音乐清理
activity?.let { toast(it, "音乐清理", Toast.LENGTH_SHORT) }
}
4 -> {
// 安装包清理
activity?.let { toast(it, "安装包清理", Toast.LENGTH_SHORT) }
}
5 -> {
// 压缩包清理
activity?.let { toast(it, "压缩包清理", Toast.LENGTH_SHORT) }
}
}
}
// 网格布局功能点击事件
setOnGridViewItemClickListener(object : CleanAdapter.OnGridViewItemClickListener {
override fun onGridViewItemClick(position: Int) {
when (position) {
0 -> {
activity?.let { toast(it, "0", Toast.LENGTH_SHORT) }
}
1 -> {
activity?.let { toast(it, "1", Toast.LENGTH_SHORT) }
}
2 -> {
activity?.let { toast(it, "2", Toast.LENGTH_SHORT) }
}
3 -> {
activity?.let { toast(it, "3", Toast.LENGTH_SHORT) }
}
4 -> {
activity?.let { toast(it, "4", Toast.LENGTH_SHORT) }
}
5 -> {
activity?.let { toast(it, "5", Toast.LENGTH_SHORT) }
}
}
}
})
}
} }
override fun initData() { override fun initData() {
} }
override fun onResume() { override fun startObserve() {
super.onResume()
LogUtil.e("HomeFragment","onResume")
} }
} }
\ No newline at end of file
package com.mints.cleaner.ui.main
import com.mints.cleaner.R
import com.mints.cleaner.databinding.ActivityMainBinding
import com.mints.core.base.BaseVMActivity
import org.koin.androidx.viewmodel.ext.android.viewModel
class MainActivity : BaseVMActivity() {
private val mainViewModel by viewModel<MainViewModel>()
private val binding by binding<ActivityMainBinding>(R.layout.activity_main)
override fun initView() {
binding.run {
viewModel = mainViewModel
}
}
override fun initData() {
}
override fun startObserve() {
}
}
\ No newline at end of file
package com.mints.cleaner.ui.main
import com.mints.cleaner.model.repository.MainRepository
import com.mints.core.base.BaseViewModel
class MainViewModel(val repository: MainRepository) : BaseViewModel() {
}
\ No newline at end of file
package com.mints.cleaner.ui.my
import com.mints.cleaner.R
import com.mints.cleaner.util.LogUtil
import com.mints.core.base.BaseFragment
/**
* 我的页面
*/
class MyFragment :BaseFragment(){
override fun getLayoutResId()= R.layout.fragment_my
override fun initView() {
LogUtil.e("MyFragment","initView")
}
override fun initData() {
}
override fun onResume() {
super.onResume()
LogUtil.e("MyFragment","onResume")
}
}
\ No newline at end of file
package com.mints.cleaner.ui package com.mints.cleaner.ui.splash
import com.mints.cleaner.R import com.mints.cleaner.R
import com.mints.core.base.BaseActivity import com.mints.core.base.BaseActivity
......
package com.mints.cleaner.util;
import android.content.Context;
import android.graphics.Paint;
import android.view.View;
/**
* Created by littlejie on 2017/2/22.
*/
public class MiscUtil {
/**
* 测量 View
*
* @param measureSpec
* @param defaultSize View 的默认大小
* @return
*/
public static int measure(int measureSpec, int defaultSize) {
int result = defaultSize;
int specMode = View.MeasureSpec.getMode(measureSpec);
int specSize = View.MeasureSpec.getSize(measureSpec);
if (specMode == View.MeasureSpec.EXACTLY) {
result = specSize;
} else if (specMode == View.MeasureSpec.AT_MOST) {
result = Math.min(result, specSize);
}
return result;
}
/**
* dip 转换成px
*
* @param dip
* @return
*/
public static int dipToPx(Context context, float dip) {
float density = context.getResources().getDisplayMetrics().density;
return (int) (dip * density + 0.5f * (dip >= 0 ? 1 : -1));
}
/**
* 获取数值精度格式化字符串
*
* @param precision
* @return
*/
public static String getPrecisionFormat(int precision) {
return "%." + precision + "f";
}
/**
* 反转数组
*
* @param arrays
* @param <T>
* @return
*/
public static <T> T[] reverse(T[] arrays) {
if (arrays == null) {
return null;
}
int length = arrays.length;
for (int i = 0; i < length / 2; i++) {
T t = arrays[i];
arrays[i] = arrays[length - i - 1];
arrays[length - i - 1] = t;
}
return arrays;
}
/**
* 测量文字高度
* @param paint
* @return
*/
public static float measureTextHeight(Paint paint) {
Paint.FontMetrics fontMetrics = paint.getFontMetrics();
return (Math.abs(fontMetrics.ascent) - fontMetrics.descent);
}
}
\ No newline at end of file
package com.mints.cleaner.util
import android.app.ActivityManager
import android.content.Context
object SystemUtils {
/**
* 该方法必须在Activity或Service类内调用,一般情况下,可以在Activity的onCreate()方法中调用。
* 由于应用每启动一个新的进程,就会调用一次Application的onCreate()方法,而个推SDK是一个独立的进程
* ,因此如果在Application的onCreate()中调用intialize接口,会导致SDK初始化在一个应用中多次调用,
* 所以不建议在Application继承类中调用个推SDK初始化接口。
* 解释一下,每个[Android](http://lib.csdn.net/base/android "Android知识库")应用都要运行在一个虚拟机上,
* ”个推“采用Service和后台服务器通信进行通信,于是和原本的Activity就形成了多进程。
* 一个前台的应用进程,一个service后台进程,每个进程对应一个application对象,所以当应用配置了多个进程的时候,
* application对象的onCreate方法就会执行多次,所以为了保证只初始化一次,
* 就必须做出区分的处理的(“个推”中提到的在Activity或Service中初始,这种做法个人认为也是存在多次初始化的风险的);
* 进程名是通过Manifest.xml中的"android:process"属性设置的,因此可以在application的onCreate方法中通过pid获取processName,
* 再做进一步的判断(跟android:process的值进行判断)使得相关初始化代码仅执行一次。
*/
fun getProcessName(cxt: Context, pid: Int): String? {
val am: ActivityManager = cxt.getSystemService(Context.ACTIVITY_SERVICE) as ActivityManager
val runningApps: List<ActivityManager.RunningAppProcessInfo> =
am.runningAppProcesses
?: return null
for (procInfo in runningApps) {
if (procInfo.pid === pid) {
return procInfo.processName
}
}
return null
}
}
\ No newline at end of file
package com.mints.cleaner.widget
import android.content.Context
import android.util.AttributeSet
import android.widget.GridView
class AutoHeightGv : GridView {
constructor(context: Context, attrs: AttributeSet,defStyle:Int) : super(context, attrs,defStyle)
constructor(context: Context, attrs: AttributeSet) : super(context, attrs)
constructor(context: Context): super(context)
override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
val expandSpec = MeasureSpec.makeMeasureSpec(Int.MAX_VALUE shr 2, MeasureSpec.AT_MOST)
super.onMeasure(widthMeasureSpec, expandSpec)
}
}
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:radius="1000dp" />
<solid android:color="@color/white"/>
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android" <layout xmlns:android="http://schemas.android.com/apk/res/android">
xmlns:binding="http://schemas.android.com/tools"
xmlns:tools="http://schemas.android.com/tools">
<data> <data>
...@@ -17,10 +15,10 @@ ...@@ -17,10 +15,10 @@
<Button <Button
android:id="@+id/btn_getdata" android:id="@+id/btn_getdata"
android:layout_width="match_parent" android:layout_width="match_parent"
android:text="getData" android:layout_height="wrap_content"
android:layout_centerInParent="true" android:layout_centerInParent="true"
android:onClick="@{()->viewModel.getRotationChart()}" android:onClick="@{()->viewModel.getRotationChart()}"
android:layout_height="wrap_content"/> android:text="getData" />
</RelativeLayout> </RelativeLayout>
......
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android">
<data>
<variable
name="viewModel"
type="com.mints.cleaner.ui.main.MainViewModel" />
</data>
<FrameLayout
android:id="@+id/fragment_container"
android:layout_width="match_parent"
android:layout_height="match_parent">
</FrameLayout>
</layout>
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" <androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="@color/colorPrimary" android:background="@color/colorPrimary"
tools:context="com.mints.cleaner.ui.SplashActivity"> tools:context="com.mints.cleaner.ui.splash.SplashActivity">
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.coordinatorlayout.widget.CoordinatorLayout>
\ No newline at end of file \ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<data>
<variable
name="viewModel"
type="com.mints.cleaner.ui.main.MainViewModel" />
<variable
name="adapter"
type="androidx.recyclerview.widget.RecyclerView.Adapter" />
<variable
name="title"
type="com.mints.cleaner.model.bean.HeaderTitle" />
</data>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include
layout="@layout/header_bar"
app:title="@{title}" />
<androidx.recyclerview.widget.RecyclerView
adapter="@{adapter}"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />
</LinearLayout>
</layout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/tv_home_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="fragment_home"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"></TextView>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/tv_home_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="fragment_my"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"></TextView>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android">
<data>
<variable
name="title"
type="com.mints.cleaner.model.bean.HeaderTitle" />
</data>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="80dp"
android:background="@{title.background}">
<ImageView
android:id="@+id/iv_header_left"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginTop="40dp"
android:scaleType="center"
android:src="@mipmap/ic_activity_arrow"
android:visibility="@{title.backArrowVisible}" />
<TextView
android:id="@+id/tv_activity_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginTop="40dp"
android:layout_toEndOf="@id/iv_header_left"
android:text="@{title.title}"
android:textColor="@color/product_net_text"
android:textSize="18sp" />
<ImageView
android:id="@+id/iv_header_right"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_marginTop="40dp"
android:layout_marginEnd="20dp"
android:scaleType="center"
android:src="@{title.rightIcon}" />
<View
style="@style/line_3"
android:layout_alignParentBottom="true" />
</RelativeLayout>
</layout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:paddingTop="50dp"
android:paddingBottom="50dp"
android:text="@string/file_clean_info"
android:textSize="20sp" />
\ No newline at end of file
<?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="wrap_content"
android:paddingStart="20dp"
android:paddingTop="20dp"
android:paddingEnd="20dp">
<ImageView
android:id="@+id/iv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="10dp"
android:src="@mipmap/ic_launcher" />
<TextView
android:id="@+id/tv_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toEndOf="@id/iv"
android:text="@string/file_clean"
android:textColor="@color/black"
android:textSize="18sp"
android:textStyle="bold" />
<TextView
android:id="@+id/tv_info"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/tv_title"
android:layout_toEndOf="@id/iv"
android:text="@string/file_clean_info"
android:textColor="@color/black"
android:textSize="18sp" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_below="@id/iv"
android:layout_marginTop="20dp"
android:background="@color/gray_01" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:text=">"
android:textSize="30sp" />
</RelativeLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<com.mints.cleaner.widget.AutoHeightGv
android:id="@+id/gv_clean"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:columnWidth="90dp"
android:numColumns="3"
android:scrollbars="none"
android:stretchMode="columnWidth" />
<View
style="@style/line_2"
android:layout_marginTop="20dp" />
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorAccent"
android:paddingTop="20dp"
android:paddingBottom="20dp">
<com.mints.cleaner.widget.CircleProgress
android:id="@+id/cp_wifi"
android:layout_width="200dp"
android:layout_height="200dp"
android:layout_centerHorizontal="true"
app:antiAlias="true"
app:arcWidth="14dp"
app:bgArcColor="#E8E8E8"
app:bgArcWidth="14dp"
app:maxValue="16"
app:startAngle="135"
app:sweepAngle="270"
app:value="0" />
<Button
android:id="@+id/btn_clean"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/cp_wifi"
android:layout_centerHorizontal="true"
android:background="@drawable/btn_circle"
android:paddingStart="30dp"
android:paddingEnd="30dp"
android:text="@string/boost_with_one_click"
android:textSize="18sp" />
<TextView
android:id="@+id/tv_wifi_intensity"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_below="@id/btn_clean"
android:layout_marginTop="10dp"
android:layout_toStartOf="@id/line"
android:gravity="center"
android:text="@string/wifi_intensity_normal"
android:textColor="@color/white" />
<TextView
android:id="@+id/tv_wifi_intensity_field"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_below="@id/tv_wifi_intensity"
android:layout_marginTop="10dp"
android:layout_toStartOf="@id/line"
android:gravity="center"
android:text="@string/wifi_intensity_field"
android:textColor="@color/white" />
<View
android:id="@+id/line"
android:layout_width="1dp"
android:layout_height="20dp"
android:layout_below="@id/btn_clean"
android:layout_centerHorizontal="true"
android:layout_marginStart="50dp"
android:layout_marginTop="26dp"
android:layout_marginEnd="50dp"
android:background="@color/white" />
<TextView
android:id="@+id/tv_wifi_speed"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_below="@id/btn_clean"
android:layout_marginTop="10dp"
android:layout_toEndOf="@id/line"
android:gravity="center"
android:text="@string/wifi_intensity_normal"
android:textColor="@color/white" />
<TextView
android:id="@+id/tv_wifi_speed_field"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_below="@id/tv_wifi_intensity"
android:layout_marginTop="10dp"
android:layout_toEndOf="@id/line"
android:gravity="center"
android:text="@string/wifi_speed_field"
android:textColor="@color/white" />
</RelativeLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:id="@+id/item_gv_img"
android:layout_width="100dp"
android:layout_height="100dp"
android:src="@mipmap/ic_launcher" />
<TextView
android:id="@+id/item_gv_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="手机加速" />
</LinearLayout>
\ No newline at end of file
<?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="wrap_content"
android:background="@color/status_bg"
android:orientation="vertical">
<RelativeLayout
android:id="@+id/header"
android:layout_width="fill_parent"
android:layout_height="38dp"
android:gravity="center_vertical">
<ImageView
android:id="@+id/left_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:background="@null"
android:paddingBottom="10dp"
android:paddingLeft="15dp"
android:paddingRight="15dp"
android:paddingTop="10dp"
android:src="@mipmap/ic_left_arrow" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:gravity="center"
android:orientation="horizontal">
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLength="10"
android:textColor="@color/white"
android:textSize="16sp" />
<ImageView
android:id="@+id/arrow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dip"
android:visibility="gone" />
</LinearLayout>
<ImageView
android:id="@+id/right_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="8dp"
android:background="@null" />
<TextView
android:id="@+id/new_message"
android:layout_width="20dip"
android:layout_height="20dip"
android:layout_alignParentRight="true"
android:gravity="center"
android:textColor="#ffffff"
android:visibility="gone" />
</RelativeLayout>
</RelativeLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<data>
<variable
name="title"
type="com.mints.cleaner.model.bean.Title" />
</data>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:paddingTop="20dp">
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/mToolbar"
icon="@{title.icon}"
navigationClick="@{title.action}"
title="@{title.title}"
android:layout_width="match_parent"
android:layout_height="?actionBarSize"
android:theme="@style/ThemeOverlay.MaterialComponents.ActionBar"
app:popupTheme="@style/ThemeOverlay.MaterialComponents.Light"
app:titleTextColor="@color/white" />
</FrameLayout>
</layout>
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" <menu xmlns:android="http://schemas.android.com/apk/res/android">
xmlns:app="http://schemas.android.com/apk/res-auto">
<item <item
android:id="@+id/home" android:id="@+id/home"
...@@ -11,9 +10,4 @@ ...@@ -11,9 +10,4 @@
android:id="@+id/wifi" android:id="@+id/wifi"
android:icon="@mipmap/ic_launcher" android:icon="@mipmap/ic_launcher"
android:title="@string/wifi" /> android:title="@string/wifi" />
<item
android:id="@+id/my"
android:icon="@mipmap/ic_launcher"
android:title="@string/my" />
</menu> </menu>
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- 圆形进度条 -->
<declare-styleable name="CircleProgressBar">
<attr name="antiAlias" format="boolean" />
<attr name="startAngle" format="integer" />
<attr name="sweepAngle" format="integer" />
<attr name="animTime" format="integer" />
<attr name="maxValue" format="integer" />
<attr name="value" format="integer" />
<attr name="precision" format="dimension" />
<attr name="valueSize" format="dimension" />
<attr name="valueColor" format="color" />
<attr name="textOffsetPercentInRadius" format="dimension" />
<!-- 绘制内容相应的提示语 -->
<attr name="hint" format="string" />
<attr name="hintSize" format="dimension" />
<attr name="hintColor" format="color" />
<!-- 绘制内容的单位 -->
<attr name="unit" format="dimension" />
<attr name="unitSize" format="dimension" />
<attr name="unitColor" format="color" />
<!-- 圆弧宽度 -->
<attr name="arcWidth" format="dimension" />
<attr name="arcColors" format="color" />
<!-- 背景圆弧颜色 -->
<attr name="bgArcColor" format="color" />
<!-- 背景圆弧宽度 -->
<attr name="bgArcWidth" format="dimension" />
</declare-styleable>
</resources>
\ No newline at end of file
...@@ -4,7 +4,20 @@ ...@@ -4,7 +4,20 @@
<color name="colorPrimaryDark">#3700B3</color> <color name="colorPrimaryDark">#3700B3</color>
<color name="colorAccent">#03DAC5</color> <color name="colorAccent">#03DAC5</color>
<color name="white">#FFFFFF</color>
<color name="water_color">#7EE2FF</color>
<color name="theme">#6200EE</color> <color name="theme">#6200EE</color>
<color name="white">#ffffff</color>
<color name="black">#000000</color> <color name="black">#000000</color>
<color name="gray">#999999</color>
<color name="gray_01">#F5F5F5</color>
<color name="gray_02">#E8E8F0</color>
<color name="status_bg">#002444</color>
<color name="product_net_text">#121B32</color>
<color name="product_text">#172B54</color>
</resources> </resources>
\ No newline at end of file
...@@ -10,7 +10,22 @@ ...@@ -10,7 +10,22 @@
<string name="brvah_load_failed">加载失败,请点我重试</string> <string name="brvah_load_failed">加载失败,请点我重试</string>
<string name="brvah_loading">正在加载中...</string> <string name="brvah_loading">正在加载中...</string>
<string name="wifi_intensity_normal">一般</string>
<string name="wifi_intensity_field">信号强度</string>
<string name="wifi_speed_field">网络速度</string>
<string name="boost_with_one_click">一键加速</string>
<string name="home">首页</string> <string name="home">首页</string>
<string name="wifi">wifi</string> <string name="wifi">wifi</string>
<string name="my">我的</string> <string name="my">我的</string>
<string name="file_clean">文件清理</string>
<string name="music_clean">音乐清理</string>
<string name="zip_clean">压缩包清理</string>
<string name="file_clean_info">释放更多空间</string>
<string name="music_clean_info">清理不喜欢的音乐</string>
<string name="zip_clean_info">清理无用的压缩包</string>
</resources> </resources>
\ No newline at end of file
...@@ -12,4 +12,16 @@ ...@@ -12,4 +12,16 @@
<item name="color">@color/white</item> <item name="color">@color/white</item>
</style> </style>
<style name="line_2">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">20px</item>
<item name="android:background">@color/gray_02</item>
</style>
<style name="line_3">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">1px</item>
<item name="android:background">@color/gray_02</item>
</style>
</resources> </resources>
\ No newline at end of file
...@@ -91,7 +91,6 @@ abstract class BaseAppCompatActivity : TransitionActivity() { ...@@ -91,7 +91,6 @@ abstract class BaseAppCompatActivity : TransitionActivity() {
mScreenWidth = widthPixels mScreenWidth = widthPixels
} }
} }
override fun onOptionsItemSelected(item: MenuItem): Boolean { override fun onOptionsItemSelected(item: MenuItem): Boolean {
......
...@@ -46,4 +46,6 @@ abstract class BaseVMFragment<T : ViewDataBinding>(@LayoutRes val layoutId: Int) ...@@ -46,4 +46,6 @@ abstract class BaseVMFragment<T : ViewDataBinding>(@LayoutRes val layoutId: Int)
abstract fun initView() abstract fun initView()
abstract fun initData() abstract fun initData()
abstract fun startObserve() abstract fun startObserve()
override fun toggleIsBack2Left() = false
} }
\ No newline at end of file
package com.mints.core.binding
import androidx.appcompat.widget.Toolbar
import androidx.databinding.BindingAdapter
@BindingAdapter("title", "icon", "navigationClick", requireAll = false)
fun Toolbar.init(titleResId: Int, iconResId: Int, action: () -> Unit) {
setTitle(titleResId)
setNavigationIcon(iconResId)
setNavigationOnClickListener { action() }
}
\ 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