mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-04-14 19:56:32 +00:00
if there is an error sending a message, put it back into input
This commit is contained in:
parent
38a463b0cb
commit
f79f54c219
5 changed files with 25 additions and 12 deletions
|
|
@ -201,7 +201,7 @@
|
|||
android:layout_marginTop="@dimen/spacing_xlarge"
|
||||
android:layout_height="@dimen/diamond_button_height"
|
||||
android:text="@string/login_btn_fb"
|
||||
android:drawableLeft="@drawable/facebook_icon"
|
||||
android:drawableStart="@drawable/facebook_icon"
|
||||
style="@style/LoginButton"/>
|
||||
|
||||
<Button
|
||||
|
|
@ -210,7 +210,7 @@
|
|||
android:layout_marginTop="@dimen/spacing_large"
|
||||
android:layout_height="@dimen/diamond_button_height"
|
||||
android:text="@string/login_btn_google"
|
||||
android:drawableLeft="@drawable/google_icon"
|
||||
android:drawableStart="@drawable/google_icon"
|
||||
style="@style/LoginButton"/>
|
||||
|
||||
<Button
|
||||
|
|
@ -219,8 +219,9 @@
|
|||
android:layout_marginTop="@dimen/spacing_large"
|
||||
android:layout_height="@dimen/diamond_button_height"
|
||||
android:text="@string/login_btn_apple"
|
||||
android:drawableLeft="@drawable/apple_icon"
|
||||
style="@style/LoginButton"/>
|
||||
android:drawableStart="@drawable/apple_icon"
|
||||
style="@style/LoginButton"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/forgot_password"
|
||||
|
|
@ -231,7 +232,7 @@
|
|||
android:text="@string/forgot_pw_btn"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:textColor="@color/white_75_alpha"
|
||||
android:background="@color/transparent"/>
|
||||
android:background="@color/transparent" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
|
|
|||
|
|
@ -209,8 +209,10 @@ class ChatFragment : BaseFragment() {
|
|||
}
|
||||
|
||||
private fun sendChatMessage(chatText: String) {
|
||||
viewModel?.postGroupChat(chatText) {
|
||||
viewModel?.postGroupChat(chatText, {
|
||||
recyclerView?.scrollToPosition(0)
|
||||
}) {
|
||||
chatBarView.message = chatText
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -123,9 +123,12 @@ class InboxMessageListFragment : BaseMainFragment(), androidx.swiperefreshlayout
|
|||
socialRepository.postPrivateMessage(userID, chatText)
|
||||
.delay(200, TimeUnit.MILLISECONDS)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(Consumer {
|
||||
.subscribe({
|
||||
recyclerView?.scrollToPosition(0)
|
||||
}, RxErrorHandler.handleEmptyError())
|
||||
}, { error ->
|
||||
RxErrorHandler.reportError(error)
|
||||
chatBarView.message = chatText
|
||||
})
|
||||
KeyboardUtil.dismissKeyboard(getActivity())
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -200,11 +200,14 @@ open class GroupViewModel : BaseViewModel() {
|
|||
disposable.add(socialRepository.deleteMessage(chatMessage).subscribe(Consumer { }, RxErrorHandler.handleEmptyError()))
|
||||
}
|
||||
|
||||
fun postGroupChat(chatText: String, onComplete: () -> Unit?) {
|
||||
fun postGroupChat(chatText: String, onComplete: () -> Unit, onError: () -> Unit) {
|
||||
groupIDSubject.value?.value?.let {
|
||||
socialRepository.postGroupChat(it, chatText).subscribe(Consumer {
|
||||
socialRepository.postGroupChat(it, chatText).subscribe({
|
||||
onComplete()
|
||||
}, RxErrorHandler.handleEmptyError())
|
||||
}, { error ->
|
||||
RxErrorHandler.reportError(error)
|
||||
onError()
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -55,6 +55,10 @@ class ChatBarView : LinearLayout {
|
|||
autocompleteAdapter?.groupID = value
|
||||
}
|
||||
|
||||
var message: String?
|
||||
get() = chatEditText.text.toString()
|
||||
set(value) = chatEditText.setText(value)
|
||||
|
||||
constructor(context: Context) : super(context) {
|
||||
setupView(context)
|
||||
}
|
||||
|
|
@ -115,7 +119,7 @@ class ChatBarView : LinearLayout {
|
|||
}
|
||||
|
||||
private fun sendButtonPressed() {
|
||||
val chatText = chatEditText.text.toString()
|
||||
val chatText = message ?: ""
|
||||
if (chatText.isNotEmpty()) {
|
||||
chatEditText.text = null
|
||||
sendAction?.invoke(chatText)
|
||||
|
|
|
|||
Loading…
Reference in a new issue