diff --git a/app/src/main/kotlin/rasel/lunar/launcher/home/LauncherHome.kt b/app/src/main/kotlin/rasel/lunar/launcher/home/LauncherHome.kt index f413aba1..7cde855c 100644 --- a/app/src/main/kotlin/rasel/lunar/launcher/home/LauncherHome.kt +++ b/app/src/main/kotlin/rasel/lunar/launcher/home/LauncherHome.kt @@ -508,23 +508,10 @@ internal class LauncherHome : Fragment() { if (prevUrl!=null && prevUrl.length > TEST_PAG.length && prevUrl.contains("/page/") && listItem.size < (24 * 5) ) { BLog.LOGE("listItem.size >>> ${listItem.size} do next ") 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 { - listTags.sortByDescending { it.count } + listItem.sortByDescending { it.date } binding.mainList?.post { - (binding.mainList.adapter as RssItemAdapter).apply { + binding.mainList.adapter = RssItemAdapter(listItem,requireContext()).apply { updateData(listItem) } } @@ -560,26 +547,7 @@ internal class LauncherHome : Fragment() { /* gestures on root view */ @SuppressLint("ClickableViewAccessibility") private fun rootViewGestures() { - 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") private fun batteryProgressGestures() { 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 */ @SuppressLint("ClickableViewAccessibility") private fun todosGestures() { 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 */ diff --git a/app/src/main/kotlin/rasel/lunar/launcher/todos/RssItemAdapter.kt b/app/src/main/kotlin/rasel/lunar/launcher/todos/RssItemAdapter.kt index bf32211c..633d9b18 100644 --- a/app/src/main/kotlin/rasel/lunar/launcher/todos/RssItemAdapter.kt +++ b/app/src/main/kotlin/rasel/lunar/launcher/todos/RssItemAdapter.kt @@ -28,9 +28,11 @@ import androidx.core.content.ContextCompat.startActivity import androidx.recyclerview.widget.DiffUtil import androidx.recyclerview.widget.RecyclerView import com.google.gson.Gson +import com.squareup.picasso.Picasso import rasel.lunar.launcher.LauncherActivity.Companion.lActivity import rasel.lunar.launcher.R import rasel.lunar.launcher.databinding.ListItemBinding +import rasel.lunar.launcher.databinding.ListItemWithBinding import rasel.lunar.launcher.home.RssItem import rasel.lunar.launcher.home.RssTagItem import rasel.lunar.launcher.utils.BLog @@ -43,10 +45,8 @@ internal class RssItemAdapter ( private val smsList: ArrayList, private val context: Context) : RecyclerView.Adapter() { - private val currentFragment = lActivity!!.supportFragmentManager.findFragmentById(R.id.mainFragmentsContainer) - 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) } @@ -57,64 +57,20 @@ internal class RssItemAdapter ( @SuppressLint("SetTextI18n") override fun onBindViewHolder(holder: RssTag, position: Int) { val todo = smsList[position] - + BLog.LOGE("position >>>> ${position}") holder.view.itemText.text = "\u25CF ${Gson().toJson(todo)}" - /* multiline texts are enabled for TodoManager */ -// holder.view.itemText.isSingleLine = false - /* launch edit or update dialog on item click */ -// holder.view.itemText.setOnClickListener { updateDialog(position) } - /* copy texts on long click */ + Picasso.get().load(todo.pageLink).into(holder.view.circlePreview) holder.view.itemText.setOnLongClickListener { - 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) { val diffUtilResult = DiffUtil.calculateDiff(RssItemDiffUtil(smsList, newList)) 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) -// } -// } } } diff --git a/app/src/main/res/layout/list_item.xml b/app/src/main/res/layout/list_item.xml index e8e97118..bd2c11eb 100644 --- a/app/src/main/res/layout/list_item.xml +++ b/app/src/main/res/layout/list_item.xml @@ -4,6 +4,7 @@ android:layout_height="wrap_content" xmlns:app="http://schemas.android.com/apk/res-auto"> + + + + + + + + \ No newline at end of file