fix animations

This commit is contained in:
Bnyro 2022-07-21 18:06:09 +02:00
parent 276d611a9f
commit f15a98175c
3 changed files with 17 additions and 22 deletions

View File

@ -21,7 +21,6 @@ class SubscriptionChannelAdapter(private val subscriptions: MutableList<Subscrip
val TAG = "SubChannelAdapter" val TAG = "SubChannelAdapter"
private var subscribed = true private var subscribed = true
private var isLoading = false
override fun getItemCount(): Int { override fun getItemCount(): Int {
return subscriptions.size return subscriptions.size
@ -43,17 +42,16 @@ class SubscriptionChannelAdapter(private val subscriptions: MutableList<Subscrip
NavigationHelper.navigateChannel(root.context, subscription.url) NavigationHelper.navigateChannel(root.context, subscription.url)
} }
subscriptionSubscribe.setOnClickListener { subscriptionSubscribe.setOnClickListener {
if (!isLoading) { val channelId = subscription.url?.replace("/channel/", "")!!
isLoading = true if (subscribed) {
val channelId = subscription.url?.replace("/channel/", "")!! subscriptionSubscribe.text = root.context.getString(R.string.subscribe)
if (subscribed) { unsubscribe(channelId)
unsubscribe(channelId) subscribed = false
subscriptionSubscribe.text = root.context.getString(R.string.unsubscribe) } else {
} else { subscriptionSubscribe.text =
subscribe(channelId) root.context.getString(R.string.unsubscribe)
subscriptionSubscribe.text = subscribe(channelId)
root.context.getString(R.string.subscribe) subscribed = true
}
} }
} }
} }
@ -71,8 +69,6 @@ class SubscriptionChannelAdapter(private val subscriptions: MutableList<Subscrip
} catch (e: Exception) { } catch (e: Exception) {
Log.e(TAG, e.toString()) Log.e(TAG, e.toString())
} }
subscribed = true
isLoading = false
} }
} }
run() run()
@ -90,8 +86,6 @@ class SubscriptionChannelAdapter(private val subscriptions: MutableList<Subscrip
} catch (e: Exception) { } catch (e: Exception) {
Log.e(TAG, e.toString()) Log.e(TAG, e.toString())
} }
subscribed = false
isLoading = false
} }
} }
run() run()

View File

@ -78,11 +78,11 @@ class SubscriptionsFragment : Fragment() {
fetchChannels(binding.subChannels) fetchChannels(binding.subChannels)
loadedSubbedChannels = true loadedSubbedChannels = true
} }
binding.subChannels.visibility = View.VISIBLE binding.subChannelsContainer.visibility = View.VISIBLE
binding.subFeed.visibility = View.GONE binding.subFeedContainer.visibility = View.GONE
} else { } else {
binding.subChannels.visibility = View.GONE binding.subChannelsContainer.visibility = View.GONE
binding.subFeed.visibility = View.VISIBLE binding.subFeedContainer.visibility = View.VISIBLE
} }
} }

View File

@ -95,13 +95,13 @@
</com.google.android.material.card.MaterialCardView> </com.google.android.material.card.MaterialCardView>
<RelativeLayout <RelativeLayout
android:id="@+id/sub_channels_container"
android:visibility="gone"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:descendantFocusability="blocksDescendants"> android:descendantFocusability="blocksDescendants">
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
android:visibility="gone"
android:id="@+id/sub_channels" android:id="@+id/sub_channels"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
@ -110,6 +110,7 @@
</RelativeLayout> </RelativeLayout>
<RelativeLayout <RelativeLayout
android:id="@+id/sub_feed_container"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:descendantFocusability="blocksDescendants"> android:descendantFocusability="blocksDescendants">