Merge pull request #2990 from Bnyro/master

Minor downloads fragment improvements
This commit is contained in:
Bnyro 2023-02-07 19:37:25 +01:00 committed by GitHub
commit a2f8f2500a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 21 additions and 28 deletions

View File

@ -8,9 +8,9 @@ import android.os.Binder
import android.os.IBinder
import android.util.SparseBooleanArray
import androidx.core.app.NotificationCompat
import androidx.core.app.ServiceCompat
import androidx.core.util.set
import androidx.core.util.valueIterator
import androidx.core.app.ServiceCompat
import com.github.libretube.R
import com.github.libretube.api.CronetHelper
import com.github.libretube.api.RetrofitInstance

View File

@ -91,13 +91,9 @@ class DownloadsAdapter(
root.setOnLongClickListener {
MaterialAlertDialogBuilder(root.context)
.setItems(
arrayOf(
root.context.getString(R.string.delete)
)
) { _, index ->
when (index) {
0 -> {
.setTitle(R.string.delete)
.setMessage(R.string.irreversible)
.setPositiveButton(R.string.okay) { _, _ ->
items.map { File(it.path) }.forEach { file ->
if (file.exists()) {
try {
@ -113,8 +109,6 @@ class DownloadsAdapter(
notifyItemRemoved(position)
notifyItemRangeChanged(position, itemCount)
}
}
}
.setNegativeButton(R.string.cancel, null)
.show()
true

View File

@ -9,7 +9,6 @@ import android.os.IBinder
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.core.view.size
import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
@ -109,11 +108,11 @@ class DownloadsFragment : BaseFragment() {
binding.downloads.adapter?.registerAdapterDataObserver(
object : RecyclerView.AdapterDataObserver() {
override fun onItemRangeRemoved(positionStart: Int, itemCount: Int) {
if (binding.downloads.size == 0) {
super.onItemRangeRemoved(positionStart, itemCount)
if (binding.downloads.adapter?.itemCount == 0) {
binding.downloads.visibility = View.GONE
binding.downloadsEmpty.visibility = View.VISIBLE
}
super.onItemRangeRemoved(positionStart, itemCount)
}
}
)

View File

@ -19,9 +19,9 @@ import com.github.libretube.extensions.hideKeyboard
import com.github.libretube.helpers.PreferenceHelper
import com.github.libretube.ui.adapters.SearchAdapter
import com.github.libretube.ui.base.BaseFragment
import java.io.IOException
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import java.io.IOException
import retrofit2.HttpException
class SearchResultFragment : BaseFragment() {

View File

@ -11,10 +11,10 @@ import com.github.libretube.helpers.ImportHelper
import com.github.libretube.obj.BackupFile
import com.github.libretube.ui.base.BasePreferenceFragment
import com.github.libretube.ui.dialogs.BackupDialog
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import java.time.LocalDateTime
import java.time.format.DateTimeFormatter
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
class BackupRestoreSettings : BasePreferenceFragment() {
private val backupDateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd-HH:mm:ss")