update
This commit is contained in:
parent
2e19fd0b28
commit
7a3efa2bee
@ -15,6 +15,7 @@ import com.all.pdfreader.pro.app.ui.fragment.FavoriteFrag
|
|||||||
import com.all.pdfreader.pro.app.ui.fragment.HomeFrag
|
import com.all.pdfreader.pro.app.ui.fragment.HomeFrag
|
||||||
import com.all.pdfreader.pro.app.ui.fragment.RecentlyFrag
|
import com.all.pdfreader.pro.app.ui.fragment.RecentlyFrag
|
||||||
import com.all.pdfreader.pro.app.ui.fragment.ToolsFrag
|
import com.all.pdfreader.pro.app.ui.fragment.ToolsFrag
|
||||||
|
import com.all.pdfreader.pro.app.util.AppUtils.setDebouncedClickWithAnimation
|
||||||
import com.all.pdfreader.pro.app.util.FileChangeObserver
|
import com.all.pdfreader.pro.app.util.FileChangeObserver
|
||||||
import com.all.pdfreader.pro.app.util.FileUtils
|
import com.all.pdfreader.pro.app.util.FileUtils
|
||||||
import com.all.pdfreader.pro.app.util.PdfMetadataExtractor
|
import com.all.pdfreader.pro.app.util.PdfMetadataExtractor
|
||||||
@ -98,6 +99,18 @@ class MainActivity : BaseActivity(), PermissionDialogFragment.PermissionCallback
|
|||||||
//直接跳转到权限设置页面
|
//直接跳转到权限设置页面
|
||||||
requestPermissions()
|
requestPermissions()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
binding.sidebarBtn.setDebouncedClickWithAnimation {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
binding.searchBtn.setDebouncedClickWithAnimation {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
binding.sortingBtn.setDebouncedClickWithAnimation {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun switchFragment(target: Fragment) {
|
private fun switchFragment(target: Fragment) {
|
||||||
|
|||||||
47
app/src/main/java/com/all/pdfreader/pro/app/util/AppUtils.kt
Normal file
47
app/src/main/java/com/all/pdfreader/pro/app/util/AppUtils.kt
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
package com.all.pdfreader.pro.app.util
|
||||||
|
|
||||||
|
import android.view.View
|
||||||
|
|
||||||
|
object AppUtils {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 为 View 点击事件添加防抖点击 + 动画 + 执行逻辑
|
||||||
|
*
|
||||||
|
* @param debounceTime 防抖间隔,默认 500 毫秒
|
||||||
|
* @param onClick 点击后执行的逻辑(动画完成后调用)
|
||||||
|
*/
|
||||||
|
fun View.setDebouncedClickWithAnimation(
|
||||||
|
debounceTime: Long = 500L,
|
||||||
|
onClick: () -> Unit
|
||||||
|
) {
|
||||||
|
var lastClickTime = 0L
|
||||||
|
|
||||||
|
this.setOnClickListener {
|
||||||
|
val currentTime = System.currentTimeMillis()
|
||||||
|
if (currentTime - lastClickTime < debounceTime) {
|
||||||
|
return@setOnClickListener
|
||||||
|
}
|
||||||
|
lastClickTime = currentTime
|
||||||
|
|
||||||
|
// 动画 + 禁用点击
|
||||||
|
this.isEnabled = false
|
||||||
|
this.animate()
|
||||||
|
.scaleX(1.2f)
|
||||||
|
.scaleY(1.2f)
|
||||||
|
.setDuration(150)
|
||||||
|
.withEndAction {
|
||||||
|
this.animate()
|
||||||
|
.scaleX(1f)
|
||||||
|
.scaleY(1f)
|
||||||
|
.setDuration(150)
|
||||||
|
.withEndAction {
|
||||||
|
this.isEnabled = true
|
||||||
|
onClick() // 执行传入的逻辑
|
||||||
|
}
|
||||||
|
.start()
|
||||||
|
}
|
||||||
|
.start()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
18
app/src/main/res/drawable/dr_round_click_effect_bg.xml
Normal file
18
app/src/main/res/drawable/dr_round_click_effect_bg.xml
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
|
<!-- 按下状态 -->
|
||||||
|
<item android:state_pressed="true">
|
||||||
|
<shape android:shape="oval">
|
||||||
|
<solid android:color="#0D000000" /> <!-- 按下颜色:深一点 -->
|
||||||
|
</shape>
|
||||||
|
</item>
|
||||||
|
|
||||||
|
<!-- 默认状态 -->
|
||||||
|
<item>
|
||||||
|
<shape android:shape="oval">
|
||||||
|
<solid android:color="#00000000" /> <!-- 默认颜色 -->
|
||||||
|
</shape>
|
||||||
|
</item>
|
||||||
|
|
||||||
|
</selector>
|
||||||
9
app/src/main/res/drawable/search.xml
Normal file
9
app/src/main/res/drawable/search.xml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="256dp"
|
||||||
|
android:height="256dp"
|
||||||
|
android:viewportWidth="1024"
|
||||||
|
android:viewportHeight="1024">
|
||||||
|
<path
|
||||||
|
android:pathData="M781.3,738.7l105.4,168.1a42.8,42.8 0,0 1,-13.9 59.2,43.4 43.4,0 0,1 -59.6,-13.8l-103.8,-165.4a421,421 0,0 1,-197.9 49.2C279.3,835.9 90.4,648.4 90.4,418S279.3,0 511.6,0c232.3,0 421.2,187.5 421.2,418 0,128.7 -59,243.9 -151.5,320.6zM511.6,85.9C327.1,85.9 177,234.9 177,418s150.1,332.1 334.6,332.1c184.6,0 334.7,-149 334.7,-332.1s-150.1,-332.1 -334.7,-332.1z"
|
||||||
|
android:fillColor="#2c2c2c"/>
|
||||||
|
</vector>
|
||||||
9
app/src/main/res/drawable/sidebar.xml
Normal file
9
app/src/main/res/drawable/sidebar.xml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="256dp"
|
||||||
|
android:height="256dp"
|
||||||
|
android:viewportWidth="1024"
|
||||||
|
android:viewportHeight="1024">
|
||||||
|
<path
|
||||||
|
android:pathData="M46.5,791.3c0,27.9 18.6,46.5 46.5,46.5h418.9c23.3,0 46.5,-18.6 46.5,-46.5s-18.6,-46.5 -46.5,-46.5h-418.9c-27.9,0 -46.5,18.6 -46.5,46.5zM46.5,512c0,27.9 18.6,46.5 46.5,46.5h651.6c27.9,0 46.5,-18.6 46.5,-46.5s-18.6,-46.5 -46.5,-46.5h-651.6c-27.9,0 -46.5,18.6 -46.5,46.5zM46.5,232.7c0,27.9 23.3,46.5 46.5,46.5h837.8c23.3,0 46.5,-18.6 46.5,-46.5s-23.3,-46.5 -46.5,-46.5h-837.8c-27.9,0 -46.5,18.6 -46.5,46.5z"
|
||||||
|
android:fillColor="#2c2c2c"/>
|
||||||
|
</vector>
|
||||||
9
app/src/main/res/drawable/sorting.xml
Normal file
9
app/src/main/res/drawable/sorting.xml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="256dp"
|
||||||
|
android:height="256dp"
|
||||||
|
android:viewportWidth="1024"
|
||||||
|
android:viewportHeight="1024">
|
||||||
|
<path
|
||||||
|
android:pathData="M600.4,60.5v907.6c0,27.9 18.6,46.5 46.5,46.5s46.5,-18.6 46.5,-46.5V158.3l116.4,93.1c18.6,18.6 51.2,14 65.2,-4.7 18.6,-18.6 14,-51.2 -4.7,-65.2L679.6,23.3c-32.6,-27.9 -79.1,-4.7 -79.1,37.2zM377,9.3c-27.9,0 -46.5,18.6 -46.5,46.5v809.9l-116.4,-93.1c-18.6,-18.6 -51.2,-14 -65.2,4.7 -18.6,18.6 -14,51.2 4.7,65.2l190.8,158.3c32.6,23.3 74.5,4.7 74.5,-37.2V55.9c4.7,-23.3 -18.6,-46.5 -41.9,-46.5z"
|
||||||
|
android:fillColor="#2c2c2c"/>
|
||||||
|
</vector>
|
||||||
@ -2,7 +2,7 @@
|
|||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:background="@color/bg_color"
|
android:background="@color/white"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<View
|
<View
|
||||||
@ -10,10 +10,67 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="0dp" />
|
android:layout_height="0dp" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="48dp"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/sidebarBtn"
|
||||||
|
android:layout_width="44dp"
|
||||||
|
android:layout_height="44dp"
|
||||||
|
android:layout_marginStart="6dp"
|
||||||
|
android:layout_marginEnd="6dp"
|
||||||
|
android:gravity="center">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:layout_width="24dp"
|
||||||
|
android:layout_height="24dp"
|
||||||
|
android:src="@drawable/sidebar" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_weight="1" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/searchBtn"
|
||||||
|
android:layout_width="44dp"
|
||||||
|
android:layout_height="44dp"
|
||||||
|
android:layout_marginStart="6dp"
|
||||||
|
android:layout_marginEnd="6dp"
|
||||||
|
android:gravity="center">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:layout_width="24dp"
|
||||||
|
android:layout_height="24dp"
|
||||||
|
android:src="@drawable/search" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/sortingBtn"
|
||||||
|
android:layout_width="44dp"
|
||||||
|
android:layout_height="44dp"
|
||||||
|
android:layout_marginStart="6dp"
|
||||||
|
android:layout_marginEnd="6dp"
|
||||||
|
android:gravity="center">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/sortingImg"
|
||||||
|
android:layout_width="24dp"
|
||||||
|
android:layout_height="24dp"
|
||||||
|
android:src="@drawable/sorting" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
|
android:background="@color/bg_color"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
@ -96,8 +153,7 @@
|
|||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="68dp"
|
android:layout_height="68dp">
|
||||||
android:background="@color/white">
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/home_ll_btn"
|
android:id="@+id/home_ll_btn"
|
||||||
|
|||||||
@ -12,4 +12,5 @@
|
|||||||
<color name="grey">#E6E6E6</color>
|
<color name="grey">#E6E6E6</color>
|
||||||
<color name="bg_color">#F6F6F6</color>
|
<color name="bg_color">#F6F6F6</color>
|
||||||
<color name="line_color">#E0E0E0</color>
|
<color name="line_color">#E0E0E0</color>
|
||||||
|
<color name="black_img_color">#2c2c2c</color>
|
||||||
</resources>
|
</resources>
|
||||||
Loading…
Reference in New Issue
Block a user