feat:添加了若干图片资源,并更新了部分代码。

This commit is contained in:
LUX-Timber 2024-04-22 16:07:23 +08:00
parent 4120a620f7
commit 9f5c9e4d17
46 changed files with 735 additions and 84 deletions

View File

@ -3,7 +3,20 @@
<component name="deploymentTargetDropDown"> <component name="deploymentTargetDropDown">
<value> <value>
<entry key="app"> <entry key="app">
<State /> <State>
<runningDeviceTargetSelectedWithDropDown>
<Target>
<type value="RUNNING_DEVICE_TARGET" />
<deviceKey>
<Key>
<type value="SERIAL_NUMBER" />
<value value="ZX1G22HXL8" />
</Key>
</deviceKey>
</Target>
</runningDeviceTargetSelectedWithDropDown>
<timeTargetWasSelectedWithDropDown value="2024-04-22T03:53:07.331156800Z" />
</State>
</entry> </entry>
</value> </value>
</component> </component>

View File

@ -1,6 +1,7 @@
plugins { plugins {
alias(libs.plugins.androidApplication) alias(libs.plugins.androidApplication)
alias(libs.plugins.jetbrainsKotlinAndroid) alias(libs.plugins.jetbrainsKotlinAndroid)
id("kotlin-kapt")
} }
android { android {
@ -33,6 +34,7 @@ android {
buildFeatures { buildFeatures {
viewBinding = true viewBinding = true
buildConfig = true
} }
} }
@ -47,4 +49,29 @@ dependencies {
testImplementation libs.junit testImplementation libs.junit
androidTestImplementation libs.androidx.junit androidTestImplementation libs.androidx.junit
androidTestImplementation libs.androidx.espresso.core androidTestImplementation libs.androidx.espresso.core
implementation 'androidx.appcompat:appcompat:1.0.0' // 1.0.0
implementation 'io.github.scwang90:refresh-layout-kernel:2.1.0' //
implementation 'io.github.scwang90:refresh-header-classics:2.1.0' //
implementation 'io.github.scwang90:refresh-header-radar:2.1.0' //
implementation 'io.github.scwang90:refresh-header-falsify:2.1.0' //
implementation 'io.github.scwang90:refresh-header-material:2.1.0' //
implementation 'io.github.scwang90:refresh-header-two-level:2.1.0' //
implementation 'io.github.scwang90:refresh-footer-ball:2.1.0' //
implementation 'io.github.scwang90:refresh-footer-classics:2.1.0' //
implementation 'com.google.code.gson:gson:2.10.1'
implementation 'com.github.bumptech.glide:glide:4.12.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.12.0'
kapt 'androidx.room:room-compiler:2.6.1'
implementation 'androidx.room:room-runtime:2.6.1'
implementation("androidx.room:room-ktx:2.6.1")
// viewModel
implementation(libs.lifecycle.viewmodel.ktx)
//viewModel初始化用
implementation(libs.activity.ktx)
implementation(libs.fragment.ktx)
} }

View File

@ -6,6 +6,7 @@
<uses-permission android:name="android.permission.SET_WALLPAPER" /> <uses-permission android:name="android.permission.SET_WALLPAPER" />
<application <application
android:name=".tools.MyApplication"
android:allowBackup="true" android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules" android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules" android:fullBackupContent="@xml/backup_rules"
@ -16,7 +17,7 @@
android:theme="@style/Theme.MyLiveWallpaper" android:theme="@style/Theme.MyLiveWallpaper"
tools:targetApi="31"> tools:targetApi="31">
<activity <activity
android:name=".activity.StartActivity" android:name=".ui.activity.StartActivity"
android:exported="true"> android:exported="true">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
@ -24,7 +25,7 @@
<category android:name="android.intent.category.LAUNCHER" /> <category android:name="android.intent.category.LAUNCHER" />
</intent-filter> </intent-filter>
</activity> </activity>
<activity android:name=".activity.MainActivity" /> <activity android:name=".ui.activity.MainActivity" />
</application> </application>
</manifest> </manifest>

View File

@ -1,23 +0,0 @@
package com.timber.soft.mylivewallpaper.activity
import android.os.Bundle
import android.view.View
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import com.timber.soft.mylivewallpaper.R
import com.timber.soft.mylivewallpaper.databinding.ActivityMainBinding
class MainActivity : BaseActivity() {
private lateinit var binding: ActivityMainBinding
override fun getActivityContentView(): View {
binding = ActivityMainBinding.inflate(layoutInflater)
return binding.root
}
override fun initViews() {
super.initViews()
}
}

View File

@ -1,14 +0,0 @@
package com.timber.soft.mylivewallpaper.adapter
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentPagerAdapter
class ViewPagerAdapter : FragmentPagerAdapter() {
override fun getCount(): Int {
TODO("Not yet implemented")
}
override fun getItem(position: Int): Fragment {
TODO("Not yet implemented")
}
}

View File

@ -0,0 +1,19 @@
package com.timber.soft.mylivewallpaper.data
import androidx.room.Entity
import androidx.room.PrimaryKey
import com.timber.soft.mylivewallpaper.tools.AppFinalString
import java.io.Serializable
@Entity(tableName = AppFinalString.TABLE_NAME_WALLPAPER)
data class WallpaperData(
val thumbnail: String,
val preview: String,
val title: String,
@PrimaryKey(autoGenerate = true)
val id: Int = 0,
val classId: String? = null,
var isCollect: Boolean = false,
var downloadUrl: String? = null,
) : Serializable

View File

@ -0,0 +1,65 @@
package com.timber.soft.mylivewallpaper.data
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import com.timber.soft.mylivewallpaper.tools.AppTools
import com.timber.soft.mylivewallpaper.tools.AppTools.parseJsonFile
import com.timber.soft.mylivewallpaper.tools.MyApplication
import java.util.concurrent.atomic.AtomicBoolean
class WallpaperViewModel : ViewModel() {
private var wallpaperDataListLiveData: MutableLiveData<MutableList<WallpaperData>> =
MutableLiveData()
private var wallpaperDataList: MutableList<WallpaperData> = mutableListOf()
private var wallpaperPoolsList: MutableList<WallpaperData> = mutableListOf()
var isLoading = AtomicBoolean(false)
fun getData(): MutableLiveData<MutableList<WallpaperData>> {
return wallpaperDataListLiveData
}
fun updateWallpaper() {
if (isLoading.get()) {
return
}
try {
isLoading.set(true)
wallpaperDataList.clear()
wallpaperPoolsList.clear()
wallpaperPoolsList.addAll(getDataList())
val list = wallpaperPoolsList.subList(0, 40)
wallpaperDataList.addAll(list)
wallpaperPoolsList.removeAll(list)
} catch (e: Exception) {
e.printStackTrace()
} finally {
wallpaperDataListLiveData.postValue(wallpaperDataList)
isLoading.set(false)
}
}
fun loadWallpaper() {
if (isLoading.get()) {
return
}
try {
isLoading.set(true)
val list = wallpaperPoolsList.subList(0, 20)
wallpaperDataList.addAll(list)
wallpaperPoolsList.removeAll(list)
} catch (e: Exception) {
e.printStackTrace()
} finally {
wallpaperDataListLiveData.postValue(wallpaperDataList)
isLoading.set(false)
}
}
private fun getDataList(): List<WallpaperData> {
return parseJsonFile(MyApplication.appContext.assets.open("live.json")).shuffled()
}
override fun onCleared() {
super.onCleared()
}
}

View File

@ -1,9 +0,0 @@
package com.timber.soft.mylivewallpaper.fragment
import android.view.View
class CollectFragment :BaseFragment(){
override fun getFragmentContentView(): View {
TODO("Not yet implemented")
}
}

View File

@ -1,4 +0,0 @@
package com.timber.soft.mylivewallpaper.fragment
class HomeFragment {
}

View File

@ -1,9 +0,0 @@
package com.timber.soft.mylivewallpaper.fragment
import android.view.View
class SettingFragment :BaseFragment(){
override fun getFragmentContentView(): View {
TODO("Not yet implemented")
}
}

View File

@ -0,0 +1,5 @@
package com.timber.soft.mylivewallpaper.tools
object AppFinalString {
const val TABLE_NAME_WALLPAPER = "wallpaper"
}

View File

@ -0,0 +1,17 @@
package com.timber.soft.mylivewallpaper.tools
import android.os.Handler
import android.os.Looper
import com.google.gson.Gson
import com.timber.soft.mylivewallpaper.data.WallpaperData
import java.io.InputStream
import java.io.InputStreamReader
object AppTools {
fun onMain(operation: () -> Unit) = Handler(Looper.getMainLooper()).post(operation)
fun parseJsonFile(jsonInputStream: InputStream): List<WallpaperData> {
val reader = InputStreamReader(jsonInputStream)
val jsonString = reader.readText()
return Gson().fromJson(jsonString, Array<WallpaperData>::class.java).toMutableList()
}
}

View File

@ -0,0 +1,16 @@
package com.timber.soft.mylivewallpaper.tools
import android.app.Application
import android.content.Context
class MyApplication : Application() {
companion object {
lateinit var appContext: Context
}
override fun onCreate() {
super.onCreate()
appContext = this
}
}

View File

@ -1,4 +1,4 @@
package com.timber.soft.mylivewallpaper.activity package com.timber.soft.mylivewallpaper.ui.activity
import android.graphics.Color import android.graphics.Color
import android.os.Build import android.os.Build
@ -14,12 +14,22 @@ abstract class BaseActivity : AppCompatActivity() {
} }
open fun initViews() { open fun initViews() {
initStatusBar()
}
abstract fun getActivityContentView(): View
private fun initStatusBar() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
window.decorView.systemUiVisibility = window.decorView.systemUiVisibility =
(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or View.SYSTEM_UI_FLAG_LAYOUT_STABLE) or View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR (View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or View.SYSTEM_UI_FLAG_LAYOUT_STABLE) or View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
window.statusBarColor = Color.TRANSPARENT window.statusBarColor = Color.TRANSPARENT
} }
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
// window.decorView.systemUiVisibility =
// (View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or View.SYSTEM_UI_FLAG_LAYOUT_STABLE)
// window.statusBarColor = Color.TRANSPARENT
// }
} }
}
abstract fun getActivityContentView(): View
}

View File

@ -0,0 +1,97 @@
package com.timber.soft.mylivewallpaper.ui.activity
import android.view.View
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentPagerAdapter
import androidx.viewpager.widget.ViewPager.OnPageChangeListener
import com.timber.soft.mylivewallpaper.databinding.ActivityMainBinding
import com.timber.soft.mylivewallpaper.ui.adapter.MainViewPagerAdapter
import com.timber.soft.mylivewallpaper.ui.fragment.CollectFragment
import com.timber.soft.mylivewallpaper.ui.fragment.HomeFragment
import com.timber.soft.mylivewallpaper.ui.fragment.SettingFragment
class MainActivity :
BaseActivity(),
OnPageChangeListener,
View.OnClickListener {
private lateinit var binding: ActivityMainBinding
private var viewPagerFragments = mutableListOf<Fragment>()
override fun getActivityContentView(): View {
binding = ActivityMainBinding.inflate(layoutInflater)
return binding.root
}
override fun initViews() {
super.initViews()
initViewPager()
initTab()
}
private fun initViewPager() {
viewPagerFragments.add(HomeFragment())
viewPagerFragments.add(CollectFragment())
viewPagerFragments.add(SettingFragment())
binding.mainViewpager.run {
adapter = MainViewPagerAdapter(viewPagerFragments, supportFragmentManager)
addOnPageChangeListener(this@MainActivity)
}
setTabSelect(0)
}
override fun onPageScrolled(position: Int, positionOffset: Float, positionOffsetPixels: Int) {
}
override fun onPageSelected(position: Int) {
setTabSelect(position)
}
override fun onPageScrollStateChanged(state: Int) {
}
override fun onClick(v: View?) {
when (v) {
binding.mainTabHome -> {
setTabSelect(0)
}
binding.mainTabCollect -> {
setTabSelect(1)
}
binding.mainTabSet -> {
setTabSelect(2)
}
}
}
private fun setTabSelect(position: Int) {
when (position) {
0 -> {
binding.mainTabHome.isSelected = true
binding.mainTabCollect.isSelected = false
binding.mainTabSet.isSelected = false
binding.mainViewpager.currentItem = 0
}
1 -> {
binding.mainTabHome.isSelected = false
binding.mainTabCollect.isSelected = true
binding.mainTabSet.isSelected = false
binding.mainViewpager.currentItem = 1
}
2 -> {
binding.mainTabHome.isSelected = false
binding.mainTabCollect.isSelected = false
binding.mainTabSet.isSelected = true
binding.mainViewpager.currentItem = 2
}
}
}
private fun initTab() {
binding.mainTabHome.setOnClickListener(this)
binding.mainTabCollect.setOnClickListener(this)
binding.mainTabSet.setOnClickListener(this)
}
}

View File

@ -1,4 +1,4 @@
package com.timber.soft.mylivewallpaper.activity package com.timber.soft.mylivewallpaper.ui.activity
import android.content.Intent import android.content.Intent
import android.view.View import android.view.View

View File

@ -0,0 +1,55 @@
package com.timber.soft.mylivewallpaper.ui.adapter
import android.content.Context
import android.graphics.drawable.Drawable
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import androidx.cardview.widget.CardView
import androidx.recyclerview.widget.RecyclerView
import com.bumptech.glide.Glide
import com.bumptech.glide.load.engine.DiskCacheStrategy
import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions
import com.bumptech.glide.request.RequestOptions
import com.timber.soft.mylivewallpaper.R
import com.timber.soft.mylivewallpaper.data.WallpaperData
import com.timber.soft.mylivewallpaper.ui.listener.OnHomeItemClickListener
class HomeItemAdapter(
private val context: Context,
private val wallpaperDataList: MutableList<WallpaperData>,
private val listener: OnHomeItemClickListener
) : RecyclerView.Adapter<HomeItemAdapter.ItemViewHolder>() {
inner class ItemViewHolder(view: View) : RecyclerView.ViewHolder(view) {
val wallpaperItem = itemView.findViewById<ImageView>(R.id.item_home_img)
val rootView = itemView.findViewById<CardView>(R.id.item_home_root)
}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ItemViewHolder {
val view = LayoutInflater.from(context).inflate(R.layout.item_home_wallpaper, parent, false)
return ItemViewHolder(view)
}
override fun getItemCount(): Int {
return wallpaperDataList.size
}
override fun onBindViewHolder(holder: ItemViewHolder, position: Int) {
val wallpaperData = wallpaperDataList[position]
try {
Glide.with(context).load(wallpaperData.thumbnail)
.diskCacheStrategy(DiskCacheStrategy.ALL)
.transition(DrawableTransitionOptions.withCrossFade()).apply(
RequestOptions().placeholder(R.drawable.img_loading)
).error(R.drawable.img_loading_err).into(holder.wallpaperItem)
} catch (e: Exception) {
e.printStackTrace()
}
holder.rootView.setOnClickListener() {
listener.onItemClick(position, wallpaperData)
}
}
}

View File

@ -0,0 +1,18 @@
package com.timber.soft.mylivewallpaper.ui.adapter
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
import androidx.fragment.app.FragmentPagerAdapter
class MainViewPagerAdapter(
private val pagerData: List<Fragment>,
private val fragmentManager: FragmentManager
) : FragmentPagerAdapter(fragmentManager) {
override fun getCount(): Int {
return pagerData.size
}
override fun getItem(position: Int): Fragment {
return pagerData[position]
}
}

View File

@ -1,4 +1,4 @@
package com.timber.soft.mylivewallpaper.fragment package com.timber.soft.mylivewallpaper.ui.fragment
import android.os.Bundle import android.os.Bundle
@ -21,7 +21,6 @@ abstract class BaseFragment : Fragment() {
} }
open fun initViews() { open fun initViews() {
} }
abstract fun getFragmentContentView(): View abstract fun getFragmentContentView(): View

View File

@ -0,0 +1,12 @@
package com.timber.soft.mylivewallpaper.ui.fragment
import android.view.View
import com.timber.soft.mylivewallpaper.databinding.FragmentCollectBinding
class CollectFragment : BaseFragment() {
private lateinit var binding: FragmentCollectBinding
override fun getFragmentContentView(): View {
binding = FragmentCollectBinding.inflate(layoutInflater)
return binding.root
}
}

View File

@ -0,0 +1,77 @@
package com.timber.soft.mylivewallpaper.ui.fragment
import android.util.Log
import android.view.View
import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.StaggeredGridLayoutManager
import com.timber.soft.mylivewallpaper.data.WallpaperData
import com.timber.soft.mylivewallpaper.data.WallpaperViewModel
import com.timber.soft.mylivewallpaper.databinding.FragmentHomeBinding
import com.timber.soft.mylivewallpaper.ui.adapter.HomeItemAdapter
import com.timber.soft.mylivewallpaper.ui.listener.OnHomeItemClickListener
import kotlinx.coroutines.Dispatchers
import androidx.fragment.app.viewModels
import com.timber.soft.mylivewallpaper.tools.AppTools.onMain
import kotlinx.coroutines.launch
class HomeFragment : BaseFragment() {
private lateinit var binding: FragmentHomeBinding
private val wallpaperViewModel: WallpaperViewModel by viewModels()
private var wallpaperDataList: MutableList<WallpaperData> = mutableListOf()
private lateinit var homeItemAdapter: HomeItemAdapter
override fun getFragmentContentView(): View {
binding = FragmentHomeBinding.inflate(layoutInflater)
return binding.root
}
override fun initViews() {
super.initViews()
initRecyclerView()
initRefreshLayout()
}
private fun initRefreshLayout() {
binding.homeRefreshLayout.setOnRefreshListener {
if (wallpaperViewModel.isLoading.get()) {
return@setOnRefreshListener
}
lifecycleScope.launch(Dispatchers.IO) {
wallpaperViewModel.updateWallpaper()
}
}
binding.homeRefreshLayout.setOnLoadMoreListener {
if (wallpaperViewModel.isLoading.get()) {
return@setOnLoadMoreListener
}
wallpaperViewModel.loadWallpaper()
}
wallpaperViewModel.getData().observe(this) { list ->
wallpaperDataList.clear()
wallpaperDataList.addAll(list)
onMain {
binding.homeRefreshLayout.finishRefresh()
binding.homeRefreshLayout.finishLoadMore()
homeItemAdapter.notifyDataSetChanged()
}
}
}
private fun initRecyclerView() {
homeItemAdapter =
HomeItemAdapter(requireContext(), wallpaperDataList, object : OnHomeItemClickListener {
override fun onItemClick(position: Int, wallpaperData: WallpaperData) {
// val intent = Intent(requireContext())
Log.d("home_item_root", "item has been click!")
}
})
binding.homeRecyclerview.run {
layoutManager = StaggeredGridLayoutManager(2, LinearLayoutManager.VERTICAL)
adapter = homeItemAdapter
}
}
}

View File

@ -0,0 +1,12 @@
package com.timber.soft.mylivewallpaper.ui.fragment
import android.view.View
import com.timber.soft.mylivewallpaper.databinding.FragmentSettingBinding
class SettingFragment : BaseFragment() {
private lateinit var binding: FragmentSettingBinding
override fun getFragmentContentView(): View {
binding = FragmentSettingBinding.inflate(layoutInflater)
return binding.root
}
}

View File

@ -0,0 +1,7 @@
package com.timber.soft.mylivewallpaper.ui.listener
import com.timber.soft.mylivewallpaper.data.WallpaperData
interface OnHomeItemClickListener {
fun onItemClick(position: Int, wallpaperData: WallpaperData)
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/svg_collection_enable" android:state_selected="true" />
<item android:drawable="@drawable/svg_collection" android:state_selected="false" />
</selector>

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/svg_home_enable" android:state_selected="true" />
<item android:drawable="@drawable/svg_home" android:state_selected="false" />
</selector>

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/svg_setting_enable" android:state_selected="true" />
<item android:drawable="@drawable/svg_setting" android:state_selected="false" />
</selector>

View File

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="200dp"
android:height="200dp"
android:viewportWidth="1024"
android:viewportHeight="1024">
<path
android:pathData="M877.6,456.8c15,-14.7 20.4,-33 14.8,-50 -5.5,-17 -20.6,-28.5 -41.3,-31.6l-190.2,-27.8c-7,-1 -18.5,-9.5 -21.6,-15.9l-85.1,-173.7c-9.3,-18.9 -24.9,-29.8 -42.9,-29.8 -18,0 -33.6,10.8 -42.8,29.8l-85.1,173.7c-3.1,6.4 -14.6,14.8 -21.6,15.9l-190.2,27.8c-20.7,3 -35.8,14.6 -41.3,31.6 -5.6,17 -0.2,35.2 14.8,50l137.7,135.2c5.1,5 9.5,18.8 8.3,25.9l-32.5,190.9c-3.6,20.8 2.8,38.8 17.3,49.3 7.5,5.4 16.2,8.2 25.5,8.2 8.6,0 17.6,-2.3 26.6,-7l170.2,-90.2c6,-3.2 20.4,-3.2 26.5,0l170.1,90.1c18.5,9.9 37.5,9.4 52.1,-1.1 14.6,-10.5 20.9,-28.5 17.3,-49.3l-32.5,-191c-1.3,-7.1 3.2,-20.9 8.3,-25.9l137.7,-135.2z"
android:fillColor="#2c2c2c"/>
</vector>

View File

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="200dp"
android:height="200dp"
android:viewportWidth="1024"
android:viewportHeight="1024">
<path
android:fillColor="@color/theme_color_dark"
android:pathData="M877.6,456.8c15,-14.7 20.4,-33 14.8,-50 -5.5,-17 -20.6,-28.5 -41.3,-31.6l-190.2,-27.8c-7,-1 -18.5,-9.5 -21.6,-15.9l-85.1,-173.7c-9.3,-18.9 -24.9,-29.8 -42.9,-29.8 -18,0 -33.6,10.8 -42.8,29.8l-85.1,173.7c-3.1,6.4 -14.6,14.8 -21.6,15.9l-190.2,27.8c-20.7,3 -35.8,14.6 -41.3,31.6 -5.6,17 -0.2,35.2 14.8,50l137.7,135.2c5.1,5 9.5,18.8 8.3,25.9l-32.5,190.9c-3.6,20.8 2.8,38.8 17.3,49.3 7.5,5.4 16.2,8.2 25.5,8.2 8.6,0 17.6,-2.3 26.6,-7l170.2,-90.2c6,-3.2 20.4,-3.2 26.5,0l170.1,90.1c18.5,9.9 37.5,9.4 52.1,-1.1 14.6,-10.5 20.9,-28.5 17.3,-49.3l-32.5,-191c-1.3,-7.1 3.2,-20.9 8.3,-25.9l137.7,-135.2z" />
</vector>

View File

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="200dp"
android:height="200dp"
android:viewportWidth="1024"
android:viewportHeight="1024">
<path
android:pathData="M837.8,389.8V104.7H674.9v122.2L512,64 64,512h81.5v448h244.4V593.5h244.4V960h244.4V512H960L837.8,389.8z"
android:fillColor="#2c2c2c"/>
</vector>

View File

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="200dp"
android:height="200dp"
android:viewportWidth="1024"
android:viewportHeight="1024">
<path
android:pathData="M837.8,389.8V104.7H674.9v122.2L512,64 64,512h81.5v448h244.4V593.5h244.4V960h244.4V512H960L837.8,389.8z"
android:fillColor="@color/theme_color_dark"/>
</vector>

View File

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="200dp"
android:height="200dp"
android:viewportWidth="1024"
android:viewportHeight="1024">
<path
android:pathData="M512,249.5c-22.5,0 -37.5,-15 -37.5,-37.5L474.5,99.5c0,-22.5 15,-37.5 37.5,-37.5s37.5,15 37.5,37.5L549.5,212c0,22.5 -15,37.5 -37.5,37.5zM512,962c-22.5,0 -37.5,-15 -37.5,-37.5L474.5,812c0,-22.5 15,-37.5 37.5,-37.5s37.5,15 37.5,37.5v112.5c0,22.5 -15,37.5 -37.5,37.5zM212,549.5L99.5,549.5C77,549.5 62,534.5 62,512s15,-37.5 37.5,-37.5L212,474.5c22.5,0 37.5,15 37.5,37.5s-15,37.5 -37.5,37.5zM924.5,549.5L812,549.5c-22.5,0 -37.5,-15 -37.5,-37.5s15,-37.5 37.5,-37.5h112.5c22.5,0 37.5,15 37.5,37.5s-15,37.5 -37.5,37.5zM770.8,399.5c-11.3,0 -26.3,-7.5 -33.8,-18.8 -11.3,-18.8 -3.8,-41.3 15,-52.5L849.5,272c18.8,-11.3 41.3,-3.8 52.5,15s3.8,41.3 -15,52.5l-97.5,56.3c-3.8,3.8 -11.3,3.8 -18.8,3.8zM155.8,755.8c-11.3,0 -26.3,-7.5 -33.8,-18.8 -11.3,-18.8 -3.8,-41.3 15,-52.5l97.5,-56.3c18.8,-11.3 41.3,-3.8 52.5,15s3.8,41.3 -15,52.5L174.5,752c-7.5,3.8 -15,3.8 -18.8,3.8zM662,290.8c-7.5,0 -11.3,0 -18.8,-3.8 -18.8,-11.3 -22.5,-33.8 -15,-52.5L684.5,137c11.3,-18.8 33.8,-22.5 52.5,-15 18.8,11.3 22.5,33.8 15,52.5L695.8,272c-7.5,11.3 -22.5,18.8 -33.8,18.8zM305.8,905.8c-7.5,0 -11.3,0 -18.8,-3.8 -18.8,-11.3 -22.5,-33.8 -15,-52.5l56.3,-97.5c11.3,-15 33.8,-22.5 52.5,-11.3s22.5,33.8 15,52.5L339.5,887c-7.5,11.3 -22.5,18.8 -33.8,18.8zM253.3,399.5c-7.5,0 -15,0 -18.8,-3.8L137,339.5c-18.8,-11.3 -26.3,-33.8 -15,-52.5s33.8,-22.5 52.5,-15l97.5,56.3c18.8,11.3 22.5,33.8 11.3,52.5 -3.8,11.3 -18.8,18.8 -30,18.8zM868.3,755.8c-7.5,0 -11.3,0 -18.8,-3.8L752,695.8c-18.8,-11.3 -22.5,-33.8 -15,-52.5 11.3,-18.8 33.8,-22.5 52.5,-15L887,684.5c18.8,11.3 22.5,33.8 15,52.5 -7.5,11.3 -18.8,18.8 -33.8,18.8zM362,290.8c-11.3,0 -26.3,-7.5 -33.8,-18.8L272,174.5c-7.5,-18.8 -3.8,-41.3 15,-52.5s41.3,-3.8 52.5,15l56.3,97.5c7.5,18.8 3.8,41.3 -15,48.8 -7.5,3.8 -11.3,7.5 -18.8,7.5zM718.3,905.8c-11.3,0 -26.3,-7.5 -33.8,-18.8l-56.3,-97.5c-11.3,-18.8 -3.8,-41.3 15,-52.5s41.3,-3.8 52.5,15L752,849.5c11.3,18.8 3.8,41.3 -15,52.5 -7.5,3.8 -11.3,3.8 -18.8,3.8z"
android:fillColor="#3095DE"/>
</vector>

View File

@ -0,0 +1,12 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="200dp"
android:height="200dp"
android:viewportWidth="1024"
android:viewportHeight="1024">
<path
android:pathData="M537.5,611.3L323.1,338.8 71.5,764.6V155.1h773.8v282.2c24.2,4.2 47.3,11.4 68.9,21.4V121.1c0,-19.3 -15.6,-34.9 -34.9,-34.9H34.9C15.6,86.2 0,101.8 0,121.1v739C0,879.4 15.6,895 34.9,895h552.7c-42.7,-48.5 -68.8,-112.6 -68.8,-182.8v-0.4c0,-35.5 6.6,-69.3 18.7,-100.5z"
android:fillColor="#3095DE"/>
<path
android:pathData="M839.8,630.1v0.3l-0.1,0.2v0.2l-0.1,0.2S812,759.3 812,759.6c0,0 1.9,-9.6 0,0 -1.9,9.7 -6.7,15 -15,15s-12.6,-6.1 -15.2,-16.1c-2.6,-10 -26.9,-124.7 -26.9,-124.8v-0.2l-0.1,-0.2v-0.7l-0.1,-0.1v-0.3l-0.1,-0.2v-0.4l-0.1,-0.2v-0.8l-0.1,-0.2v-0.4c-0.6,-2.7 -0.9,-5.7 -0.9,-8.9 0,-24.1 19.6,-43.7 43.7,-43.7s43.7,19.6 43.7,43.7c0,3.1 -0.3,6.2 -1,9.2l-0.1,-0.2zM797,872.9c-18.1,0 -32.7,-14.6 -32.7,-32.6s14.6,-32.6 32.6,-32.6 32.6,14.6 32.6,32.6c0.1,18 -14.5,32.6 -32.5,32.6zM797.7,485.7c-125,0 -226.2,101.2 -226.3,226.1 0.1,124.9 101.3,226.1 226.2,226.1h0.2c124.9,0 226.1,-101.2 226.2,-226.1 -0.1,-124.9 -101.3,-226.1 -226.3,-226.1 0.1,0 0,0 0,0z"
android:fillColor="#3095DE"/>
</vector>

View File

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="200dp"
android:height="200dp"
android:viewportWidth="1024"
android:viewportHeight="1024">
<path
android:pathData="M925.6,443.1h-41.4c-19,0 -39.1,-14.8 -44.7,-32.9l-23.7,-57.7c-9,-16.7 -5.3,-41.3 8,-54.7l29.4,-29.3c13.4,-13.5 13.4,-35.4 0,-48.8L804.4,171c-13.4,-13.4 -35.3,-13.4 -48.8,0l-29.3,29.3c-13.4,13.4 -38,17.1 -54.8,8.1l-57.6,-23.7C595.8,179.1 581,159 581,140V98.5c0,-18.9 -15.6,-34.5 -34.4,-34.5h-68.9c-19,0 -34.5,15.6 -34.5,34.5v41.4c0,19 -14.8,39.1 -32.9,44.7l-57.7,23.7c-16.7,9 -41.3,5.3 -54.7,-8.1l-29.4,-29.3c-13.4,-13.4 -35.3,-13.4 -48.7,0l-48.7,48.7c-13.4,13.4 -13.4,35.4 0,48.8l29.3,29.3c13.5,13.4 17.1,38 8.1,54.7l-23.7,57.7c-5.6,18.1 -25.7,32.9 -44.7,32.9H98.8c-19,0 -34.5,15.5 -34.5,34.5v68.9c0,19 15.5,34.5 34.5,34.5h41.3c19,0 39,14.9 44.6,32.9l23.8,57.7c8.9,16.7 5.3,41.4 -8.1,54.8l-29.3,29.3c-13.3,13.4 -13.3,35.3 0,48.8l48.8,48.8c13.4,13.4 35.3,13.4 48.7,0l29.4,-29.3c13.3,-13.4 38,-17 54.6,-8l57.8,23.7c18.1,5.6 32.9,25.7 32.9,44.7v41.2c0,18.9 15.5,34.5 34.5,34.5h68.9c18.9,0 34.4,-15.5 34.4,-34.5v-41.2c0,-19 14.9,-39.1 32.9,-44.7l57.7,-23.7c16.7,-9 41.4,-5.4 54.8,8l29.2,29.3c13.4,13.4 35.4,13.4 48.8,0l48.8,-48.8c13.4,-13.4 13.4,-35.4 0,-48.8l-29.4,-29.3c-13.3,-13.3 -17,-38 -8,-54.8l23.7,-57.7c5.7,-18.1 25.8,-32.9 44.7,-32.9h41.4c18.9,0 34.4,-15.5 34.4,-34.5v-69c-0.1,-18.8 -15.6,-34.3 -34.5,-34.3m-241.2,68.8c0,95.2 -77.1,172.3 -172.3,172.3 -95.2,0 -172.3,-77.1 -172.3,-172.3 0,-95.1 77.1,-172.3 172.3,-172.3 95.2,0.1 172.3,77.2 172.3,172.3"
android:fillColor="#2c2c2c"/>
</vector>

View File

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="200dp"
android:height="200dp"
android:viewportWidth="1024"
android:viewportHeight="1024">
<path
android:pathData="M925.6,443.1h-41.4c-19,0 -39.1,-14.8 -44.7,-32.9l-23.7,-57.7c-9,-16.7 -5.3,-41.3 8,-54.7l29.4,-29.3c13.4,-13.5 13.4,-35.4 0,-48.8L804.4,171c-13.4,-13.4 -35.3,-13.4 -48.8,0l-29.3,29.3c-13.4,13.4 -38,17.1 -54.8,8.1l-57.6,-23.7C595.8,179.1 581,159 581,140V98.5c0,-18.9 -15.6,-34.5 -34.4,-34.5h-68.9c-19,0 -34.5,15.6 -34.5,34.5v41.4c0,19 -14.8,39.1 -32.9,44.7l-57.7,23.7c-16.7,9 -41.3,5.3 -54.7,-8.1l-29.4,-29.3c-13.4,-13.4 -35.3,-13.4 -48.7,0l-48.7,48.7c-13.4,13.4 -13.4,35.4 0,48.8l29.3,29.3c13.5,13.4 17.1,38 8.1,54.7l-23.7,57.7c-5.6,18.1 -25.7,32.9 -44.7,32.9H98.8c-19,0 -34.5,15.5 -34.5,34.5v68.9c0,19 15.5,34.5 34.5,34.5h41.3c19,0 39,14.9 44.6,32.9l23.8,57.7c8.9,16.7 5.3,41.4 -8.1,54.8l-29.3,29.3c-13.3,13.4 -13.3,35.3 0,48.8l48.8,48.8c13.4,13.4 35.3,13.4 48.7,0l29.4,-29.3c13.3,-13.4 38,-17 54.6,-8l57.8,23.7c18.1,5.6 32.9,25.7 32.9,44.7v41.2c0,18.9 15.5,34.5 34.5,34.5h68.9c18.9,0 34.4,-15.5 34.4,-34.5v-41.2c0,-19 14.9,-39.1 32.9,-44.7l57.7,-23.7c16.7,-9 41.4,-5.4 54.8,8l29.2,29.3c13.4,13.4 35.4,13.4 48.8,0l48.8,-48.8c13.4,-13.4 13.4,-35.4 0,-48.8l-29.4,-29.3c-13.3,-13.3 -17,-38 -8,-54.8l23.7,-57.7c5.7,-18.1 25.8,-32.9 44.7,-32.9h41.4c18.9,0 34.4,-15.5 34.4,-34.5v-69c-0.1,-18.8 -15.6,-34.3 -34.5,-34.3m-241.2,68.8c0,95.2 -77.1,172.3 -172.3,172.3 -95.2,0 -172.3,-77.1 -172.3,-172.3 0,-95.1 77.1,-172.3 172.3,-172.3 95.2,0.1 172.3,77.2 172.3,172.3"
android:fillColor="@color/theme_color_dark"/>
</vector>

View File

@ -1,24 +1,112 @@
<?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" <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main_root" android:id="@+id/main_root"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
tools:context=".activity.MainActivity"> android:orientation="vertical"
tools:context=".ui.activity.MainActivity">
<androidx.viewpager.widget.ViewPager <androidx.viewpager.widget.ViewPager
android:id="@+id/main_viewpager" android:id="@+id/main_viewpager"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="0dp" android:layout_height="match_parent" />
app:layout_constraintBottom_toTopOf="@id/main_tabLayout"
app:layout_constraintTop_toTopOf="parent" />
<com.google.android.material.tabs.TabLayout <androidx.cardview.widget.CardView
android:id="@+id/main_tabLayout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="60dp" android:layout_height="56dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout> android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginStart="40dp"
android:layout_marginEnd="40dp"
android:layout_marginBottom="44dp"
android:backgroundTint="@color/white"
android:gravity="center"
app:cardCornerRadius="28dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginStart="22dp"
android:layout_marginEnd="22dp"
android:orientation="horizontal">
<LinearLayout
android:id="@+id/main_tab_home"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical">
<ImageView
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_gravity="center"
android:layout_marginTop="4dp"
android:padding="2dp"
android:src="@drawable/selector_home" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="@string/main_home"
android:textColor="@color/black"
android:textSize="12sp" />
</LinearLayout>
<LinearLayout
android:id="@+id/main_tab_collect"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical">
<ImageView
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_gravity="center"
android:layout_marginTop="4dp"
android:src="@drawable/selector_collection" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="@string/main_collect"
android:textColor="@color/black"
android:textSize="12sp" />
</LinearLayout>
<LinearLayout
android:id="@+id/main_tab_set"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical">
<ImageView
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_gravity="center"
android:layout_marginTop="4dp"
android:padding="2dp"
android:src="@drawable/selector_setting" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="@string/main_setting"
android:textColor="@color/black"
android:textSize="12sp" />
</LinearLayout>
</LinearLayout>
</androidx.cardview.widget.CardView>
</RelativeLayout>

View File

@ -5,7 +5,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="@color/white" android:background="@color/white"
tools:context=".activity.StartActivity"> tools:context=".ui.activity.StartActivity">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -0,0 +1,34 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout 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"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/theme_color_light"
tools:context=".ui.fragment.HomeFragment">
<com.scwang.smart.refresh.layout.SmartRefreshLayout
android:id="@+id/home_refreshLayout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.scwang.smart.refresh.header.MaterialHeader
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/home_recyclerview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="40dp"
android:paddingEnd="14dp" />
<com.scwang.smart.refresh.footer.ClassicsFooter
android:layout_width="match_parent"
android:layout_height="40dp"
app:srlAccentColor="@color/theme_color_dark" />
</com.scwang.smart.refresh.layout.SmartRefreshLayout>
</FrameLayout>

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView 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"
android:id="@+id/item_home_root"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="14dp"
android:layout_marginBottom="14dp"
android:background="@color/white"
app:cardCornerRadius="12dp"
tools:ignore="MissingDefaultResource">
<ImageView
android:id="@+id/item_home_img"
android:layout_width="match_parent"
android:layout_height="320dp"
android:scaleType="fitXY"
android:src="@mipmap/ic_launcher" />
</androidx.cardview.widget.CardView>

View File

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<color name="black">#FF000000</color> <color name="black">#FF2C2C2C</color>
<color name="white">#FFFFFFFF</color> <color name="white">#FFFFFFFF</color>
<color name="theme_color_dark">#3095DE</color> <color name="theme_color_dark">#3095DE</color>
<color name="theme_color_light">#CFEBFF</color> <color name="theme_color_light">#80BFEFFF</color>
<color name="theme_color_mid">#B4DEFE</color> <color name="theme_color_mid">#B4DEFE</color>
</resources> </resources>

View File

@ -1,5 +1,7 @@
<resources> <resources>
<string name="app_name">MyLiveWallpaper</string> <string name="app_name">MyLiveWallpaper</string>
<string name="main_home">Home</string>
<string name="main_collect">Collect</string>
<string name="main_setting">Set</string>
</resources> </resources>

View File

@ -20,4 +20,6 @@ kotlin.code.style=official
# Enables namespacing of each library's R class so that its R class includes only the # Enables namespacing of each library's R class so that its R class includes only the
# resources declared in the library itself and none from the library's dependencies, # resources declared in the library itself and none from the library's dependencies,
# thereby reducing the size of the R class for that library # thereby reducing the size of the R class for that library
android.nonTransitiveRClass=true android.nonTransitiveRClass=true
android.enableJetifier=true

View File

@ -8,7 +8,10 @@ espressoCore = "3.5.1"
appcompat = "1.6.1" appcompat = "1.6.1"
material = "1.11.0" material = "1.11.0"
activity = "1.8.0" activity = "1.8.0"
activity-ktx = "1.9.0"
fragment-ktx = "1.6.2"
constraintlayout = "2.1.4" constraintlayout = "2.1.4"
lifecycle = "2.7.0"
[libraries] [libraries]
androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" } androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
@ -18,6 +21,9 @@ androidx-espresso-core = { group = "androidx.test.espresso", name = "espresso-co
androidx-appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "appcompat" } androidx-appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "appcompat" }
material = { group = "com.google.android.material", name = "material", version.ref = "material" } material = { group = "com.google.android.material", name = "material", version.ref = "material" }
androidx-activity = { group = "androidx.activity", name = "activity", version.ref = "activity" } androidx-activity = { group = "androidx.activity", name = "activity", version.ref = "activity" }
lifecycle-viewmodel-ktx = { module = "androidx.lifecycle:lifecycle-viewmodel-ktx", version.ref = "lifecycle" }
activity-ktx = { module = "androidx.activity:activity-ktx", version.ref = "activity-ktx" }
fragment-ktx = { module = "androidx.fragment:fragment-ktx", version.ref = "fragment-ktx" }
androidx-constraintlayout = { group = "androidx.constraintlayout", name = "constraintlayout", version.ref = "constraintlayout" } androidx-constraintlayout = { group = "androidx.constraintlayout", name = "constraintlayout", version.ref = "constraintlayout" }
[plugins] [plugins]