mirror of
https://github.com/TeamNewPipe/NewPipe
synced 2025-01-10 17:30:31 +00:00
Use isVisible and isGone extensions for View.
This commit is contained in:
parent
55d242fa08
commit
293e2ff5e3
@ -30,6 +30,7 @@ import android.view.View
|
|||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.appcompat.app.AlertDialog
|
import androidx.appcompat.app.AlertDialog
|
||||||
import androidx.core.os.bundleOf
|
import androidx.core.os.bundleOf
|
||||||
|
import androidx.core.view.isVisible
|
||||||
import androidx.lifecycle.Observer
|
import androidx.lifecycle.Observer
|
||||||
import androidx.lifecycle.ViewModelProvider
|
import androidx.lifecycle.ViewModelProvider
|
||||||
import androidx.preference.PreferenceManager
|
import androidx.preference.PreferenceManager
|
||||||
@ -254,11 +255,9 @@ class FeedFragment : BaseListFragment<FeedState, Unit>() {
|
|||||||
|
|
||||||
oldestSubscriptionUpdate = loadedState.oldestUpdate
|
oldestSubscriptionUpdate = loadedState.oldestUpdate
|
||||||
|
|
||||||
|
refresh_subtitle_text.isVisible = loadedState.notLoadedCount > 0
|
||||||
if (loadedState.notLoadedCount > 0) {
|
if (loadedState.notLoadedCount > 0) {
|
||||||
refresh_subtitle_text.visibility = View.VISIBLE
|
|
||||||
refresh_subtitle_text.text = getString(R.string.feed_subscription_not_loaded_count, loadedState.notLoadedCount)
|
refresh_subtitle_text.text = getString(R.string.feed_subscription_not_loaded_count, loadedState.notLoadedCount)
|
||||||
} else {
|
|
||||||
refresh_subtitle_text.visibility = View.GONE
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (loadedState.itemsErrors.isNotEmpty()) {
|
if (loadedState.itemsErrors.isNotEmpty()) {
|
||||||
|
@ -13,6 +13,8 @@ import android.view.inputmethod.InputMethodManager
|
|||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.core.content.getSystemService
|
import androidx.core.content.getSystemService
|
||||||
import androidx.core.os.bundleOf
|
import androidx.core.os.bundleOf
|
||||||
|
import androidx.core.view.isGone
|
||||||
|
import androidx.core.view.isVisible
|
||||||
import androidx.fragment.app.DialogFragment
|
import androidx.fragment.app.DialogFragment
|
||||||
import androidx.lifecycle.Observer
|
import androidx.lifecycle.Observer
|
||||||
import androidx.lifecycle.ViewModelProvider
|
import androidx.lifecycle.ViewModelProvider
|
||||||
@ -415,21 +417,14 @@ class FeedGroupDialog : DialogFragment(), BackPressable {
|
|||||||
else -> android.R.string.ok
|
else -> android.R.string.ok
|
||||||
})
|
})
|
||||||
|
|
||||||
delete_button.visibility = when {
|
delete_button.isGone = currentScreen != InitialScreen || groupId == NO_GROUP_SELECTED
|
||||||
currentScreen != InitialScreen -> View.GONE
|
|
||||||
groupId == NO_GROUP_SELECTED -> View.GONE
|
|
||||||
else -> View.VISIBLE
|
|
||||||
}
|
|
||||||
|
|
||||||
hideKeyboard()
|
hideKeyboard()
|
||||||
hideSearch()
|
hideSearch()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun View.onlyVisibleIn(vararg screens: ScreenState) {
|
private fun View.onlyVisibleIn(vararg screens: ScreenState) {
|
||||||
visibility = when (currentScreen) {
|
isVisible = currentScreen in screens
|
||||||
in screens -> View.VISIBLE
|
|
||||||
else -> View.GONE
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*///////////////////////////////////////////////////////////////////////////
|
/*///////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
package org.schabi.newpipe.local.subscription.item
|
package org.schabi.newpipe.local.subscription.item
|
||||||
|
|
||||||
import android.view.View.GONE
|
|
||||||
import android.view.View.OnClickListener
|
import android.view.View.OnClickListener
|
||||||
import android.view.View.VISIBLE
|
|
||||||
import androidx.annotation.DrawableRes
|
import androidx.annotation.DrawableRes
|
||||||
|
import androidx.core.view.isVisible
|
||||||
import com.xwray.groupie.kotlinandroidextensions.GroupieViewHolder
|
import com.xwray.groupie.kotlinandroidextensions.GroupieViewHolder
|
||||||
import com.xwray.groupie.kotlinandroidextensions.Item
|
import com.xwray.groupie.kotlinandroidextensions.Item
|
||||||
import kotlinx.android.synthetic.main.header_with_menu_item.header_menu_item
|
import kotlinx.android.synthetic.main.header_with_menu_item.header_menu_item
|
||||||
@ -47,6 +46,6 @@ class HeaderWithMenuItem(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun updateMenuItemVisibility(viewHolder: GroupieViewHolder) {
|
private fun updateMenuItemVisibility(viewHolder: GroupieViewHolder) {
|
||||||
viewHolder.header_menu_item.visibility = if (showMenuItem) VISIBLE else GONE
|
viewHolder.header_menu_item.isVisible = showMenuItem
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package org.schabi.newpipe.local.subscription.item
|
package org.schabi.newpipe.local.subscription.item
|
||||||
|
|
||||||
import android.view.View
|
import android.view.View
|
||||||
|
import androidx.core.view.isVisible
|
||||||
import com.nostra13.universalimageloader.core.ImageLoader
|
import com.nostra13.universalimageloader.core.ImageLoader
|
||||||
import com.xwray.groupie.kotlinandroidextensions.GroupieViewHolder
|
import com.xwray.groupie.kotlinandroidextensions.GroupieViewHolder
|
||||||
import com.xwray.groupie.kotlinandroidextensions.Item
|
import com.xwray.groupie.kotlinandroidextensions.Item
|
||||||
@ -25,7 +26,7 @@ data class PickerSubscriptionItem(
|
|||||||
viewHolder.thumbnail_view, ImageDisplayConstants.DISPLAY_AVATAR_OPTIONS)
|
viewHolder.thumbnail_view, ImageDisplayConstants.DISPLAY_AVATAR_OPTIONS)
|
||||||
|
|
||||||
viewHolder.title_view.text = subscriptionEntity.name
|
viewHolder.title_view.text = subscriptionEntity.name
|
||||||
viewHolder.selected_highlight.visibility = if (isSelected) View.VISIBLE else View.GONE
|
viewHolder.selected_highlight.isVisible = isSelected
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun unbind(viewHolder: GroupieViewHolder) {
|
override fun unbind(viewHolder: GroupieViewHolder) {
|
||||||
|
Loading…
Reference in New Issue
Block a user