fix subscriptions

This commit is contained in:
Bnyro 2022-08-06 11:55:17 +02:00
parent 61f1bf6fee
commit a975ba212f
2 changed files with 44 additions and 42 deletions

View File

@ -15,8 +15,6 @@ class SubscriptionChannelAdapter(private val subscriptions: MutableList<Subscrip
RecyclerView.Adapter<SubscriptionChannelViewHolder>() {
val TAG = "SubChannelAdapter"
private var subscribed = true
override fun getItemCount(): Int {
return subscriptions.size
}
@ -30,6 +28,8 @@ class SubscriptionChannelAdapter(private val subscriptions: MutableList<Subscrip
override fun onBindViewHolder(holder: SubscriptionChannelViewHolder, position: Int) {
val subscription = subscriptions[position]
var subscribed = true
holder.binding.apply {
subscriptionChannelName.text = subscription.name
ConnectionHelper.loadImage(subscription.avatar, subscriptionChannelImage)

View File

@ -22,7 +22,7 @@ class ImportHelper(
private val TAG = "ImportHelper"
fun importSubscriptions(uri: Uri?) {
if (uri != null) {
if (uri == null) return
try {
val type = activity.contentResolver.getType(uri)
@ -45,9 +45,6 @@ class ImportHelper(
break
}
entry = zis.nextEntry
}
}
inputStream?.bufferedReader()?.readLines()?.forEach {
if (it.isNotBlank()) {
val channelId = it.substringBefore(",")
@ -57,10 +54,16 @@ class ImportHelper(
}
}
inputStream?.close()
}
} else {
throw IllegalArgumentException("unsupported type")
}
CoroutineScope(Dispatchers.IO).launch {
SubscriptionHelper.importSubscriptions(channels)
}
Toast.makeText(activity, R.string.importsuccess, Toast.LENGTH_SHORT).show()
} catch (e: Exception) {
Log.e(TAG, e.toString())
Toast.makeText(
@ -70,7 +73,6 @@ class ImportHelper(
).show()
}
}
}
private fun readTextFromUri(uri: Uri): String {
val stringBuilder = StringBuilder()