Skip to content

Commit

Permalink
Refine code
Browse files Browse the repository at this point in the history
  • Loading branch information
Super12138 committed Jun 9, 2024
1 parent ef58186 commit dc4ffe0
Show file tree
Hide file tree
Showing 8 changed files with 6 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ import android.view.View
import cn.super12138.todo.constant.GlobalValues

object VibrationUtils {
fun performHapticFeedback(view: View, hapticFeedbackConstants: Int=HapticFeedbackConstants.CONTEXT_CLICK) {
fun performHapticFeedback(
view: View,
hapticFeedbackConstants: Int = HapticFeedbackConstants.CONTEXT_CLICK
) {
if (GlobalValues.hapticFeedback) {
view.performHapticFeedback(hapticFeedbackConstants)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ package cn.super12138.todo.views.about
import android.content.Intent
import android.net.Uri
import android.os.Bundle
import android.view.HapticFeedbackConstants
import cn.super12138.todo.constant.Constants
import cn.super12138.todo.constant.GlobalValues
import cn.super12138.todo.databinding.ActivityAboutBinding
import cn.super12138.todo.utils.VersionUtils
import cn.super12138.todo.utils.VibrationUtils
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package cn.super12138.todo.views.all

import android.os.Bundle
import android.view.HapticFeedbackConstants
import android.view.View
import android.view.WindowManager
import androidx.activity.viewModels
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
package cn.super12138.todo.views.all

import android.view.HapticFeedbackConstants
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.fragment.app.FragmentManager
import androidx.recyclerview.widget.RecyclerView
import cn.super12138.todo.R
import cn.super12138.todo.constant.GlobalValues
import cn.super12138.todo.logic.model.ToDo
import cn.super12138.todo.utils.VibrationUtils

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,10 @@ package cn.super12138.todo.views.crash

import android.os.Build
import android.os.Bundle
import android.view.HapticFeedbackConstants
import android.view.ViewGroup
import androidx.activity.enableEdgeToEdge
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import androidx.core.view.updateLayoutParams
import cn.super12138.todo.constant.GlobalValues
import cn.super12138.todo.databinding.ActivityCrashBinding
import cn.super12138.todo.utils.VersionUtils
import cn.super12138.todo.utils.VibrationUtils
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package cn.super12138.todo.views.main
// 2023.11.18立项
import android.content.Intent
import android.os.Bundle
import android.view.HapticFeedbackConstants
import android.view.WindowManager
import cn.super12138.todo.R
import cn.super12138.todo.ToDoApp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import cn.super12138.todo.databinding.DialogBackupBinding
import cn.super12138.todo.databinding.DialogRestoreBinding
import cn.super12138.todo.logic.Repository
import cn.super12138.todo.logic.dao.ToDoRoom
import cn.super12138.todo.utils.showToast
import cn.super12138.todo.views.about.AboutActivity
import cn.super12138.todo.views.all.AllTasksActivity
import cn.super12138.todo.views.main.MainActivity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,8 @@ class ToDoAdapter(
ViewModelProvider(viewModelStoreOwner)[ToDoFragmentViewModel::class.java]

holder.checkToDoBtn.setOnClickListener {
if (GlobalValues.hapticFeedback) {
it.performHapticFeedback(HapticFeedbackConstants.CONTEXT_CLICK)
}
VibrationUtils.performHapticFeedback(it)

if (position < 0 || position >= todoList.size) {
return@setOnClickListener
}
Expand Down

0 comments on commit dc4ffe0

Please sign in to comment.