Commit 33897bad authored by divyanshu's avatar divyanshu

Use isVisible Ktx function rather than extension function

parent c736eff3
...@@ -6,6 +6,7 @@ import android.os.Bundle ...@@ -6,6 +6,7 @@ import android.os.Bundle
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import androidx.core.view.isVisible
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import chat.rocket.android.R import chat.rocket.android.R
import chat.rocket.android.analytics.AnalyticsManager import chat.rocket.android.analytics.AnalyticsManager
...@@ -13,7 +14,6 @@ import chat.rocket.android.analytics.event.ScreenViewEvent ...@@ -13,7 +14,6 @@ import chat.rocket.android.analytics.event.ScreenViewEvent
import chat.rocket.android.authentication.registerusername.presentation.RegisterUsernamePresenter import chat.rocket.android.authentication.registerusername.presentation.RegisterUsernamePresenter
import chat.rocket.android.authentication.registerusername.presentation.RegisterUsernameView import chat.rocket.android.authentication.registerusername.presentation.RegisterUsernameView
import chat.rocket.android.util.extensions.inflate import chat.rocket.android.util.extensions.inflate
import chat.rocket.android.util.extensions.setVisible
import chat.rocket.android.util.extensions.shake import chat.rocket.android.util.extensions.shake
import chat.rocket.android.util.extensions.showKeyboard import chat.rocket.android.util.extensions.showKeyboard
import chat.rocket.android.util.extensions.showToast import chat.rocket.android.util.extensions.showToast
...@@ -88,13 +88,13 @@ class RegisterUsernameFragment : Fragment(), RegisterUsernameView { ...@@ -88,13 +88,13 @@ class RegisterUsernameFragment : Fragment(), RegisterUsernameView {
override fun showLoading() { override fun showLoading() {
ui { ui {
disableUserInput() disableUserInput()
view_loading.setVisible(true) view_loading.isVisible = true
} }
} }
override fun hideLoading() { override fun hideLoading() {
ui { ui {
view_loading.setVisible(false) view_loading.isVisible = false
enableUserInput() enableUserInput()
} }
} }
......
...@@ -7,6 +7,7 @@ import android.view.LayoutInflater ...@@ -7,6 +7,7 @@ import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.Toast import android.widget.Toast
import androidx.core.view.isVisible
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import chat.rocket.android.R import chat.rocket.android.R
import chat.rocket.android.analytics.AnalyticsManager import chat.rocket.android.analytics.AnalyticsManager
...@@ -14,7 +15,6 @@ import chat.rocket.android.analytics.event.ScreenViewEvent ...@@ -14,7 +15,6 @@ import chat.rocket.android.analytics.event.ScreenViewEvent
import chat.rocket.android.authentication.resetpassword.presentation.ResetPasswordPresenter import chat.rocket.android.authentication.resetpassword.presentation.ResetPasswordPresenter
import chat.rocket.android.authentication.resetpassword.presentation.ResetPasswordView import chat.rocket.android.authentication.resetpassword.presentation.ResetPasswordView
import chat.rocket.android.util.extensions.inflate import chat.rocket.android.util.extensions.inflate
import chat.rocket.android.util.extensions.setVisible
import chat.rocket.android.util.extensions.shake import chat.rocket.android.util.extensions.shake
import chat.rocket.android.util.extensions.showKeyboard import chat.rocket.android.util.extensions.showKeyboard
import chat.rocket.android.util.extensions.showToast import chat.rocket.android.util.extensions.showToast
...@@ -85,13 +85,13 @@ class ResetPasswordFragment : Fragment(), ResetPasswordView { ...@@ -85,13 +85,13 @@ class ResetPasswordFragment : Fragment(), ResetPasswordView {
override fun showLoading() { override fun showLoading() {
ui { ui {
disableUserInput() disableUserInput()
view_loading.setVisible(true) view_loading.isVisible = true
} }
} }
override fun hideLoading() { override fun hideLoading() {
ui { ui {
view_loading.setVisible(false) view_loading.isVisible = false
enableUserInput() enableUserInput()
} }
} }
......
...@@ -9,6 +9,7 @@ import android.view.ViewGroup ...@@ -9,6 +9,7 @@ import android.view.ViewGroup
import android.view.ViewTreeObserver import android.view.ViewTreeObserver
import android.widget.AdapterView import android.widget.AdapterView
import android.widget.ArrayAdapter import android.widget.ArrayAdapter
import androidx.core.view.isVisible
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import chat.rocket.android.BuildConfig import chat.rocket.android.BuildConfig
import chat.rocket.android.R import chat.rocket.android.R
...@@ -22,7 +23,6 @@ import chat.rocket.android.util.extensions.hintContent ...@@ -22,7 +23,6 @@ import chat.rocket.android.util.extensions.hintContent
import chat.rocket.android.util.extensions.ifEmpty import chat.rocket.android.util.extensions.ifEmpty
import chat.rocket.android.util.extensions.inflate import chat.rocket.android.util.extensions.inflate
import chat.rocket.android.util.extensions.sanitize import chat.rocket.android.util.extensions.sanitize
import chat.rocket.android.util.extensions.setVisible
import chat.rocket.android.util.extensions.showToast import chat.rocket.android.util.extensions.showToast
import chat.rocket.android.util.extensions.textContent import chat.rocket.android.util.extensions.textContent
import chat.rocket.android.util.extensions.ui import chat.rocket.android.util.extensions.ui
...@@ -118,13 +118,13 @@ class ServerFragment : Fragment(), ServerView { ...@@ -118,13 +118,13 @@ class ServerFragment : Fragment(), ServerView {
override fun showLoading() { override fun showLoading() {
ui { ui {
enableUserInput(false) enableUserInput(false)
view_loading.setVisible(true) view_loading.isVisible = true
} }
} }
override fun hideLoading() { override fun hideLoading() {
ui { ui {
view_loading.setVisible(false) view_loading.isVisible = false
enableUserInput(true) enableUserInput(true)
} }
} }
......
...@@ -10,6 +10,7 @@ import android.view.LayoutInflater ...@@ -10,6 +10,7 @@ import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.view.ViewTreeObserver import android.view.ViewTreeObserver
import androidx.core.view.isVisible
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import chat.rocket.android.R import chat.rocket.android.R
import chat.rocket.android.R.string.message_credentials_saved_successfully import chat.rocket.android.R.string.message_credentials_saved_successfully
...@@ -20,7 +21,6 @@ import chat.rocket.android.authentication.signup.presentation.SignupView ...@@ -20,7 +21,6 @@ import chat.rocket.android.authentication.signup.presentation.SignupView
import chat.rocket.android.helper.KeyboardHelper import chat.rocket.android.helper.KeyboardHelper
import chat.rocket.android.helper.TextHelper import chat.rocket.android.helper.TextHelper
import chat.rocket.android.helper.saveCredentials import chat.rocket.android.helper.saveCredentials
import chat.rocket.android.util.extensions.setVisible
import chat.rocket.android.util.extensions.shake import chat.rocket.android.util.extensions.shake
import chat.rocket.android.util.extensions.showToast import chat.rocket.android.util.extensions.showToast
import chat.rocket.android.util.extensions.textContent import chat.rocket.android.util.extensions.textContent
...@@ -40,11 +40,11 @@ class SignupFragment : Fragment(), SignupView { ...@@ -40,11 +40,11 @@ class SignupFragment : Fragment(), SignupView {
lateinit var analyticsManager: AnalyticsManager lateinit var analyticsManager: AnalyticsManager
private val layoutListener = ViewTreeObserver.OnGlobalLayoutListener { private val layoutListener = ViewTreeObserver.OnGlobalLayoutListener {
if (KeyboardHelper.isSoftKeyboardShown(relative_layout.rootView)) { if (KeyboardHelper.isSoftKeyboardShown(relative_layout.rootView)) {
bottom_container.setVisible(false) bottom_container.isVisible = false
} else { } else {
bottom_container.apply { bottom_container.apply {
postDelayed({ postDelayed({
ui { setVisible(true) } ui { isVisible = true }
}, 3) }, 3)
} }
} }
...@@ -134,13 +134,13 @@ class SignupFragment : Fragment(), SignupView { ...@@ -134,13 +134,13 @@ class SignupFragment : Fragment(), SignupView {
override fun showLoading() { override fun showLoading() {
ui { ui {
enableUserInput(false) enableUserInput(false)
view_loading.setVisible(true) view_loading.isVisible = true
} }
} }
override fun hideLoading() { override fun hideLoading() {
ui { ui {
view_loading.setVisible(false) view_loading.isVisible = false
enableUserInput(true) enableUserInput(true)
} }
} }
......
...@@ -8,6 +8,7 @@ import android.view.LayoutInflater ...@@ -8,6 +8,7 @@ import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.view.inputmethod.InputMethodManager import android.view.inputmethod.InputMethodManager
import androidx.core.view.isVisible
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import chat.rocket.android.R import chat.rocket.android.R
import chat.rocket.android.analytics.AnalyticsManager import chat.rocket.android.analytics.AnalyticsManager
...@@ -15,7 +16,6 @@ import chat.rocket.android.analytics.event.ScreenViewEvent ...@@ -15,7 +16,6 @@ import chat.rocket.android.analytics.event.ScreenViewEvent
import chat.rocket.android.authentication.twofactor.presentation.TwoFAPresenter import chat.rocket.android.authentication.twofactor.presentation.TwoFAPresenter
import chat.rocket.android.authentication.twofactor.presentation.TwoFAView import chat.rocket.android.authentication.twofactor.presentation.TwoFAView
import chat.rocket.android.util.extensions.inflate import chat.rocket.android.util.extensions.inflate
import chat.rocket.android.util.extensions.setVisible
import chat.rocket.android.util.extensions.shake import chat.rocket.android.util.extensions.shake
import chat.rocket.android.util.extensions.showToast import chat.rocket.android.util.extensions.showToast
import chat.rocket.android.util.extensions.textContent import chat.rocket.android.util.extensions.textContent
...@@ -82,13 +82,13 @@ class TwoFAFragment : Fragment(), TwoFAView { ...@@ -82,13 +82,13 @@ class TwoFAFragment : Fragment(), TwoFAView {
override fun showLoading() { override fun showLoading() {
ui { ui {
enableUserInput(false) enableUserInput(false)
view_loading.setVisible(true) view_loading.isVisible = true
} }
} }
override fun hideLoading() { override fun hideLoading() {
ui { ui {
view_loading.setVisible(false) view_loading.isVisible = false
enableUserInput(true) enableUserInput(true)
} }
} }
......
...@@ -4,6 +4,7 @@ import android.os.Bundle ...@@ -4,6 +4,7 @@ import android.os.Bundle
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import androidx.core.view.isVisible
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import androidx.recyclerview.widget.DefaultItemAnimator import androidx.recyclerview.widget.DefaultItemAnimator
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
...@@ -15,7 +16,6 @@ import chat.rocket.android.chatinformation.adapter.ReadReceiptAdapter ...@@ -15,7 +16,6 @@ import chat.rocket.android.chatinformation.adapter.ReadReceiptAdapter
import chat.rocket.android.chatinformation.presentation.MessageInfoPresenter import chat.rocket.android.chatinformation.presentation.MessageInfoPresenter
import chat.rocket.android.chatinformation.presentation.MessageInfoView import chat.rocket.android.chatinformation.presentation.MessageInfoView
import chat.rocket.android.chatinformation.viewmodel.ReadReceiptViewModel import chat.rocket.android.chatinformation.viewmodel.ReadReceiptViewModel
import chat.rocket.android.util.extensions.setVisible
import chat.rocket.android.util.extensions.showToast import chat.rocket.android.util.extensions.showToast
import dagger.android.support.AndroidSupportInjection import dagger.android.support.AndroidSupportInjection
import kotlinx.android.synthetic.main.fragment_message_info.* import kotlinx.android.synthetic.main.fragment_message_info.*
...@@ -84,13 +84,13 @@ class MessageInfoFragment : Fragment(), MessageInfoView { ...@@ -84,13 +84,13 @@ class MessageInfoFragment : Fragment(), MessageInfoView {
} }
override fun showLoading() { override fun showLoading() {
view_loading.setVisible(true) view_loading.isVisible = true
view_loading.show() view_loading.show()
} }
override fun hideLoading() { override fun hideLoading() {
view_loading.hide() view_loading.hide()
view_loading.setVisible(false) view_loading.isVisible = false
} }
override fun showReadReceipts(messageReceipts: List<ReadReceiptViewModel>) { override fun showReadReceipts(messageReceipts: List<ReadReceiptViewModel>) {
......
...@@ -7,10 +7,10 @@ import android.view.View ...@@ -7,10 +7,10 @@ import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.ImageView import android.widget.ImageView
import android.widget.TextView import android.widget.TextView
import androidx.core.view.isVisible
import chat.rocket.android.R import chat.rocket.android.R
import chat.rocket.android.chatroom.adapter.PeopleSuggestionsAdapter.PeopleSuggestionViewHolder import chat.rocket.android.chatroom.adapter.PeopleSuggestionsAdapter.PeopleSuggestionViewHolder
import chat.rocket.android.chatroom.uimodel.suggestion.PeopleSuggestionUiModel import chat.rocket.android.chatroom.uimodel.suggestion.PeopleSuggestionUiModel
import chat.rocket.android.util.extensions.setVisible
import chat.rocket.android.suggestions.model.SuggestionModel import chat.rocket.android.suggestions.model.SuggestionModel
import chat.rocket.android.suggestions.ui.BaseSuggestionViewHolder import chat.rocket.android.suggestions.ui.BaseSuggestionViewHolder
import chat.rocket.android.suggestions.ui.SuggestionsAdapter import chat.rocket.android.suggestions.ui.SuggestionsAdapter
...@@ -58,9 +58,9 @@ class PeopleSuggestionsAdapter(context: Context) : SuggestionsAdapter<PeopleSugg ...@@ -58,9 +58,9 @@ class PeopleSuggestionsAdapter(context: Context) : SuggestionsAdapter<PeopleSugg
username.text = item.username username.text = item.username
name.text = item.name name.text = item.name
if (item.imageUri?.isEmpty() != false) { if (item.imageUri?.isEmpty() != false) {
avatar.setVisible(false) avatar.isVisible = false
} else { } else {
avatar.setVisible(true) avatar.isVisible = true
avatar.setImageURI(item.imageUri) avatar.setImageURI(item.imageUri)
} }
val status = item.status val status = item.status
...@@ -68,7 +68,7 @@ class PeopleSuggestionsAdapter(context: Context) : SuggestionsAdapter<PeopleSugg ...@@ -68,7 +68,7 @@ class PeopleSuggestionsAdapter(context: Context) : SuggestionsAdapter<PeopleSugg
val statusDrawable = DrawableHelper.getUserStatusDrawable(status, itemView.context) val statusDrawable = DrawableHelper.getUserStatusDrawable(status, itemView.context)
statusView.setImageDrawable(statusDrawable) statusView.setImageDrawable(statusDrawable)
} else { } else {
statusView.setVisible(false) statusView.isVisible = false
} }
setOnClickListener { setOnClickListener {
itemClickListener?.onClick(item) itemClickListener?.onClick(item)
......
...@@ -12,6 +12,7 @@ import android.view.View ...@@ -12,6 +12,7 @@ import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.ImageView import android.widget.ImageView
import android.widget.TextView import android.widget.TextView
import androidx.core.view.isVisible
import chat.rocket.android.R import chat.rocket.android.R
import chat.rocket.android.infrastructure.LocalRepository import chat.rocket.android.infrastructure.LocalRepository
import chat.rocket.android.infrastructure.checkIfMyself import chat.rocket.android.infrastructure.checkIfMyself
...@@ -53,13 +54,13 @@ class ChatRoomsAdapter( ...@@ -53,13 +54,13 @@ class ChatRoomsAdapter(
bindName(chatRoom, text_chat_name) bindName(chatRoom, text_chat_name)
bindIcon(chatRoom, image_chat_icon) bindIcon(chatRoom, image_chat_icon)
if (settings.showLastMessage()) { if (settings.showLastMessage()) {
text_last_message.setVisible(true) text_last_message.isVisible = true
text_last_message_date_time.setVisible(true) text_last_message_date_time.isVisible = true
bindLastMessageDateTime(chatRoom, text_last_message_date_time) bindLastMessageDateTime(chatRoom, text_last_message_date_time)
bindLastMessage(chatRoom, text_last_message) bindLastMessage(chatRoom, text_last_message)
} else { } else {
text_last_message.setVisible(false) text_last_message.isVisible = false
text_last_message_date_time.setVisible(false) text_last_message_date_time.isVisible = false
} }
bindUnreadMessages(chatRoom, text_total_unread_messages) bindUnreadMessages(chatRoom, text_total_unread_messages)
...@@ -178,13 +179,13 @@ class ChatRoomsAdapter( ...@@ -178,13 +179,13 @@ class ChatRoomsAdapter(
when { when {
totalUnreadMessage in 1..99 -> { totalUnreadMessage in 1..99 -> {
textView.textContent = totalUnreadMessage.toString() textView.textContent = totalUnreadMessage.toString()
textView.setVisible(true) textView.isVisible = true
} }
totalUnreadMessage > 99 -> { totalUnreadMessage > 99 -> {
textView.textContent = context.getString(R.string.msg_more_than_ninety_nine_unread_messages) textView.textContent = context.getString(R.string.msg_more_than_ninety_nine_unread_messages)
textView.setVisible(true) textView.isVisible = true
} }
else -> textView.setVisible(false) else -> textView.isVisible = false
} }
} }
} }
......
...@@ -12,6 +12,7 @@ import android.view.View ...@@ -12,6 +12,7 @@ import android.view.View
import android.view.ViewAnimationUtils import android.view.ViewAnimationUtils
import android.view.animation.AccelerateInterpolator import android.view.animation.AccelerateInterpolator
import android.view.animation.DecelerateInterpolator import android.view.animation.DecelerateInterpolator
import androidx.core.view.isVisible
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
fun View.rotateBy(value: Float, duration: Long = 100) { fun View.rotateBy(value: Float, duration: Long = 100) {
...@@ -23,7 +24,7 @@ fun View.rotateBy(value: Float, duration: Long = 100) { ...@@ -23,7 +24,7 @@ fun View.rotateBy(value: Float, duration: Long = 100) {
fun View.fadeIn(startValue: Float = 0f, finishValue: Float = 1f, duration: Long = 200) { fun View.fadeIn(startValue: Float = 0f, finishValue: Float = 1f, duration: Long = 200) {
if (alpha == finishValue) { if (alpha == finishValue) {
setVisible(true) isVisible = true
return return
} }
...@@ -38,12 +39,12 @@ fun View.fadeIn(startValue: Float = 0f, finishValue: Float = 1f, duration: Long ...@@ -38,12 +39,12 @@ fun View.fadeIn(startValue: Float = 0f, finishValue: Float = 1f, duration: Long
.setInterpolator(AccelerateInterpolator()).start() .setInterpolator(AccelerateInterpolator()).start()
}.start() }.start()
setVisible(true) isVisible = true
} }
fun View.fadeOut(startValue: Float = 1f, finishValue: Float = 0f, duration: Long = 200) { fun View.fadeOut(startValue: Float = 1f, finishValue: Float = 0f, duration: Long = 200) {
if (alpha == finishValue) { if (alpha == finishValue) {
setVisible(false) isVisible = false
return return
} }
...@@ -58,7 +59,7 @@ fun View.fadeOut(startValue: Float = 1f, finishValue: Float = 0f, duration: Long ...@@ -58,7 +59,7 @@ fun View.fadeOut(startValue: Float = 1f, finishValue: Float = 0f, duration: Long
.setInterpolator(AccelerateInterpolator()).start() .setInterpolator(AccelerateInterpolator()).start()
}.start() }.start()
setVisible(false) isVisible = false
} }
fun View.circularRevealOrUnreveal( fun View.circularRevealOrUnreveal(
...@@ -72,11 +73,7 @@ fun View.circularRevealOrUnreveal( ...@@ -72,11 +73,7 @@ fun View.circularRevealOrUnreveal(
ViewAnimationUtils.createCircularReveal(this, centerX, centerY, startRadius, endRadius) ViewAnimationUtils.createCircularReveal(this, centerX, centerY, startRadius, endRadius)
anim.duration = duration anim.duration = duration
if (startRadius < endRadius) { isVisible = startRadius < endRadius
setVisible(true)
} else {
setVisible(false)
}
anim.start() anim.start()
} }
......
...@@ -19,19 +19,6 @@ import androidx.appcompat.view.menu.MenuBuilder ...@@ -19,19 +19,6 @@ import androidx.appcompat.view.menu.MenuBuilder
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import chat.rocket.android.R import chat.rocket.android.R
// TODO: Remove. Use KTX instead.
fun View.setVisible(visible: Boolean) {
visibility = if (visible) {
View.VISIBLE
} else {
View.GONE
}
}
fun View.isVisible(): Boolean {
return visibility == View.VISIBLE
}
fun ViewGroup.inflate(@LayoutRes resource: Int, attachToRoot: Boolean = false): View = fun ViewGroup.inflate(@LayoutRes resource: Int, attachToRoot: Boolean = false): View =
LayoutInflater.from(context).inflate(resource, this, attachToRoot) LayoutInflater.from(context).inflate(resource, this, attachToRoot)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment