...
This commit is contained in:
parent
75df1bf324
commit
467b0dc720
@ -508,23 +508,10 @@ internal class LauncherHome : Fragment() {
|
|||||||
if (prevUrl!=null && prevUrl.length > TEST_PAG.length && prevUrl.contains("/page/") && listItem.size < (24 * 5) ) {
|
if (prevUrl!=null && prevUrl.length > TEST_PAG.length && prevUrl.contains("/page/") && listItem.size < (24 * 5) ) {
|
||||||
BLog.LOGE("listItem.size >>> ${listItem.size} do next ")
|
BLog.LOGE("listItem.size >>> ${listItem.size} do next ")
|
||||||
webView.postDelayed({webView.loadUrl(prevUrl)}, 5000L)
|
webView.postDelayed({webView.loadUrl(prevUrl)}, 5000L)
|
||||||
if(binding.mainList.adapter is RssTagAdapter) {
|
|
||||||
binding.mainList?.post {
|
|
||||||
(binding.mainList.adapter as RssItemAdapter).apply {
|
|
||||||
updateData(listItem)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
binding.mainList?.post {
|
|
||||||
binding.mainList.adapter = RssItemAdapter(listItem,requireContext()).apply {
|
|
||||||
updateData(listItem)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
listTags.sortByDescending { it.count }
|
listItem.sortByDescending { it.date }
|
||||||
binding.mainList?.post {
|
binding.mainList?.post {
|
||||||
(binding.mainList.adapter as RssItemAdapter).apply {
|
binding.mainList.adapter = RssItemAdapter(listItem,requireContext()).apply {
|
||||||
updateData(listItem)
|
updateData(listItem)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -560,26 +547,7 @@ internal class LauncherHome : Fragment() {
|
|||||||
/* gestures on root view */
|
/* gestures on root view */
|
||||||
@SuppressLint("ClickableViewAccessibility")
|
@SuppressLint("ClickableViewAccessibility")
|
||||||
private fun rootViewGestures() {
|
private fun rootViewGestures() {
|
||||||
|
|
||||||
binding.root.setOnTouchListener(SimpleFingerGestures(context = requireContext(), binding.root , mFingerGestureListener))
|
binding.root.setOnTouchListener(SimpleFingerGestures(context = requireContext(), binding.root , mFingerGestureListener))
|
||||||
// {
|
|
||||||
|
|
||||||
/* open quick access panel on swipe up */
|
|
||||||
// override fun onSwipeUp() {
|
|
||||||
// super.onSwipeUp()
|
|
||||||
// QuickAccess().show(fragManager, BOTTOM_SHEET_TAG)
|
|
||||||
// }
|
|
||||||
// /* expand notification panel on swipe down */
|
|
||||||
// override fun onSwipeDown() {
|
|
||||||
// super.onSwipeDown()
|
|
||||||
// expandNotificationPanel(requireContext())
|
|
||||||
// }
|
|
||||||
// /* lock the screen on double tap (optional) */
|
|
||||||
// override fun onDoubleClick() {
|
|
||||||
// super.onDoubleClick()
|
|
||||||
// lockMethod(settingsPrefs.getInt(KEY_LOCK_METHOD, 0), requireContext(), binding.favAppsGroup)
|
|
||||||
// }
|
|
||||||
// })
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -588,71 +556,12 @@ internal class LauncherHome : Fragment() {
|
|||||||
@SuppressLint("ClickableViewAccessibility")
|
@SuppressLint("ClickableViewAccessibility")
|
||||||
private fun batteryProgressGestures() {
|
private fun batteryProgressGestures() {
|
||||||
binding.batteryProgress.setOnTouchListener(SimpleFingerGestures(context = requireContext(), binding.batteryProgress , mFingerGestureListener))
|
binding.batteryProgress.setOnTouchListener(SimpleFingerGestures(context = requireContext(), binding.batteryProgress , mFingerGestureListener))
|
||||||
// binding.batteryProgress.setOnTouchListener(object : SwipeTouchListener(requireContext()) {
|
|
||||||
// /* open alarms list with default clock app */
|
|
||||||
// override fun onClick() {
|
|
||||||
// super.onClick()
|
|
||||||
// requireContext().startActivity(
|
|
||||||
// Intent(AlarmClock.ACTION_SHOW_ALARMS).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
|
||||||
// )
|
|
||||||
// }
|
|
||||||
// /* open settings activity on long click */
|
|
||||||
// override fun onLongClick() {
|
|
||||||
// super.onLongClick()
|
|
||||||
// lActivity!!.startActivity(Intent(requireContext(), SettingsActivity::class.java))
|
|
||||||
// }
|
|
||||||
// /* expand notification panel on swipe down */
|
|
||||||
// override fun onSwipeDown() {
|
|
||||||
// super.onSwipeDown()
|
|
||||||
// expandNotificationPanel(requireContext())
|
|
||||||
// }
|
|
||||||
// /* lock the screen on double tap (optional) */
|
|
||||||
// override fun onDoubleClick() {
|
|
||||||
// super.onDoubleClick()
|
|
||||||
// lockMethod(settingsPrefs.getInt(KEY_LOCK_METHOD, 0), requireContext(), binding.favAppsGroup)
|
|
||||||
// }
|
|
||||||
// })
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* gestures on to-do area */
|
/* gestures on to-do area */
|
||||||
@SuppressLint("ClickableViewAccessibility")
|
@SuppressLint("ClickableViewAccessibility")
|
||||||
private fun todosGestures() {
|
private fun todosGestures() {
|
||||||
binding.mainList.setOnTouchListener(SimpleFingerGestures(context = requireContext(), binding.mainList , mFingerGestureListener))
|
binding.mainList.setOnTouchListener(SimpleFingerGestures(context = requireContext(), binding.mainList , mFingerGestureListener))
|
||||||
// binding.notes.setOnTouchListener(object : SwipeTouchListener(requireContext()) {
|
|
||||||
// /* open TodoManager on long click */
|
|
||||||
// override fun onLongClick() {
|
|
||||||
// super.onLongClick()
|
|
||||||
// when (settingsPrefs.getBoolean(KEY_TODO_LOCK, false)) {
|
|
||||||
// false -> launchTodoManager()
|
|
||||||
// /* show authentication screen if lock is on */
|
|
||||||
// true -> {
|
|
||||||
// if (canAuthenticate(requireContext())) {
|
|
||||||
// val biometricPrompt = BiometricPrompt(lActivity!!, authenticationCallback)
|
|
||||||
// try {
|
|
||||||
// biometricPrompt.authenticate(biometricPromptInfo(lActivity!!.getString(R.string.todo_manager)))
|
|
||||||
// } catch (exception: Exception) {
|
|
||||||
// exception.printStackTrace()
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// /* open quick access panel on swipe up */
|
|
||||||
// override fun onSwipeUp() {
|
|
||||||
// super.onSwipeUp()
|
|
||||||
// QuickAccess().show(fragManager, BOTTOM_SHEET_TAG)
|
|
||||||
// }
|
|
||||||
// /* expand notification panel on swipe down */
|
|
||||||
// override fun onSwipeDown() {
|
|
||||||
// super.onSwipeDown()
|
|
||||||
// expandNotificationPanel(requireContext())
|
|
||||||
// }
|
|
||||||
// /* lock the screen on double tap (optional) */
|
|
||||||
// override fun onDoubleClick() {
|
|
||||||
// super.onDoubleClick()
|
|
||||||
// lockMethod(settingsPrefs.getInt(KEY_LOCK_METHOD, 0), requireContext(), binding.favAppsGroup)
|
|
||||||
// }
|
|
||||||
// })
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* authentication callback for TodoManager lock */
|
/* authentication callback for TodoManager lock */
|
||||||
|
|||||||
@ -28,9 +28,11 @@ import androidx.core.content.ContextCompat.startActivity
|
|||||||
import androidx.recyclerview.widget.DiffUtil
|
import androidx.recyclerview.widget.DiffUtil
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import com.google.gson.Gson
|
import com.google.gson.Gson
|
||||||
|
import com.squareup.picasso.Picasso
|
||||||
import rasel.lunar.launcher.LauncherActivity.Companion.lActivity
|
import rasel.lunar.launcher.LauncherActivity.Companion.lActivity
|
||||||
import rasel.lunar.launcher.R
|
import rasel.lunar.launcher.R
|
||||||
import rasel.lunar.launcher.databinding.ListItemBinding
|
import rasel.lunar.launcher.databinding.ListItemBinding
|
||||||
|
import rasel.lunar.launcher.databinding.ListItemWithBinding
|
||||||
import rasel.lunar.launcher.home.RssItem
|
import rasel.lunar.launcher.home.RssItem
|
||||||
import rasel.lunar.launcher.home.RssTagItem
|
import rasel.lunar.launcher.home.RssTagItem
|
||||||
import rasel.lunar.launcher.utils.BLog
|
import rasel.lunar.launcher.utils.BLog
|
||||||
@ -43,10 +45,8 @@ internal class RssItemAdapter (
|
|||||||
private val smsList: ArrayList<RssItem>,
|
private val smsList: ArrayList<RssItem>,
|
||||||
private val context: Context) : RecyclerView.Adapter<RssItemAdapter.RssTag>() {
|
private val context: Context) : RecyclerView.Adapter<RssItemAdapter.RssTag>() {
|
||||||
|
|
||||||
private val currentFragment = lActivity!!.supportFragmentManager.findFragmentById(R.id.mainFragmentsContainer)
|
|
||||||
|
|
||||||
override fun onCreateViewHolder(viewGroup: ViewGroup, i: Int): RssTag {
|
override fun onCreateViewHolder(viewGroup: ViewGroup, i: Int): RssTag {
|
||||||
val binding = ListItemBinding.inflate(LayoutInflater.from(viewGroup.context), viewGroup, false)
|
val binding = ListItemWithBinding.inflate(LayoutInflater.from(viewGroup.context), viewGroup, false)
|
||||||
return RssTag(binding)
|
return RssTag(binding)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,64 +57,20 @@ internal class RssItemAdapter (
|
|||||||
@SuppressLint("SetTextI18n")
|
@SuppressLint("SetTextI18n")
|
||||||
override fun onBindViewHolder(holder: RssTag, position: Int) {
|
override fun onBindViewHolder(holder: RssTag, position: Int) {
|
||||||
val todo = smsList[position]
|
val todo = smsList[position]
|
||||||
|
BLog.LOGE("position >>>> ${position}")
|
||||||
holder.view.itemText.text = "\u25CF ${Gson().toJson(todo)}"
|
holder.view.itemText.text = "\u25CF ${Gson().toJson(todo)}"
|
||||||
/* multiline texts are enabled for TodoManager */
|
Picasso.get().load(todo.pageLink).into(holder.view.circlePreview)
|
||||||
// holder.view.itemText.isSingleLine = false
|
|
||||||
/* launch edit or update dialog on item click */
|
|
||||||
// holder.view.itemText.setOnClickListener { updateDialog(position) }
|
|
||||||
/* copy texts on long click */
|
|
||||||
holder.view.itemText.setOnLongClickListener {
|
holder.view.itemText.setOnLongClickListener {
|
||||||
|
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inner class RssTag(var view: ListItemBinding) : RecyclerView.ViewHolder(view.root)
|
inner class RssTag(var view: ListItemWithBinding) : RecyclerView.ViewHolder(view.root)
|
||||||
|
|
||||||
fun updateData(newList: List<RssItem>) {
|
fun updateData(newList: List<RssItem>) {
|
||||||
val diffUtilResult = DiffUtil.calculateDiff(RssItemDiffUtil(smsList, newList))
|
val diffUtilResult = DiffUtil.calculateDiff(RssItemDiffUtil(smsList, newList))
|
||||||
diffUtilResult.dispatchUpdatesTo(this)
|
diffUtilResult.dispatchUpdatesTo(this)
|
||||||
// smsList.clear()
|
|
||||||
// smsList.addAll(newList)
|
|
||||||
}
|
|
||||||
|
|
||||||
/* update dialog */
|
|
||||||
private fun updateDialog(position: Int) {
|
|
||||||
// val bottomSheetDialog = BottomSheetDialog(lActivity!!, R.style.BottomSheetDialog)
|
|
||||||
// val dialogBinding = TodoDialogBinding.inflate(LayoutInflater.from(context))
|
|
||||||
// bottomSheetDialog.setContentView(dialogBinding.root)
|
|
||||||
// bottomSheetDialog.show()
|
|
||||||
// bottomSheetDialog.dismissWithAnimation = true
|
|
||||||
//
|
|
||||||
// val databaseHandler = DatabaseHandler(context)
|
|
||||||
// val todo = databaseHandler.todos[position]
|
|
||||||
//
|
|
||||||
// dialogBinding.apply {
|
|
||||||
// deleteAllConfirmation.visibility = View.GONE
|
|
||||||
// todoInput.setText(todo.name)
|
|
||||||
// todoCancel.text = context.getString(R.string.delete)
|
|
||||||
// todoCancel.setTextColor(ContextCompat.getColor(context, android.R.color.holo_red_light))
|
|
||||||
// todoOk.text = context.getString(R.string.update)
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// /* delete the item */
|
|
||||||
// dialogBinding.todoCancel.setOnClickListener {
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// /* update the item */
|
|
||||||
// dialogBinding.todoOk.setOnClickListener {
|
|
||||||
// val updatedTodoString = Objects.requireNonNull(dialogBinding.todoInput.text).toString().trim { it <= ' ' }
|
|
||||||
// if (updatedTodoString.isNotEmpty()) {
|
|
||||||
// todo.name = updatedTodoString
|
|
||||||
// databaseHandler.updateTodo(todo)
|
|
||||||
// bottomSheetDialog.dismiss()
|
|
||||||
// } else {
|
|
||||||
// dialogBinding.todoInput.error = context.getString(R.string.empty_text_field)
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,6 +4,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||||
|
|
||||||
|
|
||||||
<com.google.android.material.textview.MaterialTextView
|
<com.google.android.material.textview.MaterialTextView
|
||||||
android:id="@+id/itemText"
|
android:id="@+id/itemText"
|
||||||
android:layout_width="@dimen/zero"
|
android:layout_width="@dimen/zero"
|
||||||
|
|||||||
31
app/src/main/res/layout/list_item_with.xml
Normal file
31
app/src/main/res/layout/list_item_with.xml
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
<?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="wrap_content"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||||
|
|
||||||
|
<rasel.lunar.launcher.view.CircleImageView
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
app:layout_constraintLeft_toLeftOf="parent"
|
||||||
|
app:layout_constraintRight_toRightOf="parent"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
android:id="@+id/circle_preview"
|
||||||
|
style="@style/SearchMenuItem"
|
||||||
|
android:adjustViewBounds="true"
|
||||||
|
android:scaleType="fitCenter"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="20dp"/>
|
||||||
|
|
||||||
|
<com.google.android.material.textview.MaterialTextView
|
||||||
|
android:id="@+id/itemText"
|
||||||
|
android:layout_width="@dimen/zero"
|
||||||
|
android:layout_height="40dp"
|
||||||
|
android:padding="@dimen/twelve"
|
||||||
|
android:singleLine="false"
|
||||||
|
android:lines="0"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"/>
|
||||||
|
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
Loading…
x
Reference in New Issue
Block a user