Commit 30e54bd8 authored by Aniket Singh's avatar Aniket Singh

channel creation successful

parent 874ae7e4
package chat.rocket.android.createChannel.presentation package chat.rocket.android.createChannel.presentation
import android.widget.Toast
import chat.rocket.android.core.lifecycle.CancelStrategy import chat.rocket.android.core.lifecycle.CancelStrategy
import chat.rocket.android.server.domain.GetCurrentServerInteractor import chat.rocket.android.server.domain.GetCurrentServerInteractor
import chat.rocket.android.server.infraestructure.RocketChatClientFactory import chat.rocket.android.server.infraestructure.RocketChatClientFactory
import chat.rocket.android.util.extensions.launchUI import chat.rocket.android.util.extensions.launchUI
import chat.rocket.common.RocketChatException import chat.rocket.common.RocketChatException
import chat.rocket.common.model.RoomType import chat.rocket.common.model.RoomType
import chat.rocket.common.util.ifNull
import chat.rocket.core.RocketChatClient import chat.rocket.core.RocketChatClient
import chat.rocket.core.internal.rest.createChannel import chat.rocket.core.internal.rest.createChannel
import chat.rocket.core.model.Room
import javax.inject.Inject import javax.inject.Inject
...@@ -21,11 +24,14 @@ class CreateNewChannelPresenter @Inject constructor(private val view: CreateNewC ...@@ -21,11 +24,14 @@ class CreateNewChannelPresenter @Inject constructor(private val view: CreateNewC
launchUI(strategy) { launchUI(strategy) {
view.showLoading() view.showLoading()
try { try {
client.createChannel(roomType, channelName, usersList, readOnly) val channelCreated:Room? = client.createChannel(roomType, channelName, usersList, readOnly)
view.showMessage("Channel Created successfully") view.showChannelCreatedSuccessfullyMessage()
} catch (ex: RocketChatException) { } catch (exception: RocketChatException) {
//TODO remove this and add Log message instead exception.message?.let {
ex.printStackTrace() view.showMessage(it)
}.ifNull {
view.showGenericErrorMessage()
}
} finally { } finally {
view.hideLoading() view.hideLoading()
} }
......
...@@ -4,6 +4,9 @@ import chat.rocket.android.core.behaviours.LoadingView ...@@ -4,6 +4,9 @@ import chat.rocket.android.core.behaviours.LoadingView
import chat.rocket.android.core.behaviours.MessageView import chat.rocket.android.core.behaviours.MessageView
interface CreateNewChannelView : LoadingView, MessageView { interface CreateNewChannelView : LoadingView, MessageView {
//TODO add functions to be implemented /*
Show a message that a channel was successfully created
*/
fun showChannelCreatedSuccessfullyMessage()
} }
\ No newline at end of file
...@@ -4,11 +4,11 @@ import android.graphics.drawable.GradientDrawable ...@@ -4,11 +4,11 @@ import android.graphics.drawable.GradientDrawable
import android.os.Bundle import android.os.Bundle
import android.support.v7.app.AppCompatActivity import android.support.v7.app.AppCompatActivity
import android.view.MenuItem import android.view.MenuItem
import android.widget.Toast
import chat.rocket.android.R import chat.rocket.android.R
import chat.rocket.android.createChannel.presentation.CreateNewChannelPresenter import chat.rocket.android.createChannel.presentation.CreateNewChannelPresenter
import chat.rocket.android.createChannel.presentation.CreateNewChannelView import chat.rocket.android.createChannel.presentation.CreateNewChannelView
import chat.rocket.android.util.extensions.setVisible import chat.rocket.android.util.extensions.setVisible
import chat.rocket.android.util.extensions.showToast
import chat.rocket.common.model.roomTypeOf import chat.rocket.common.model.roomTypeOf
import com.jakewharton.rxbinding2.widget.RxTextView import com.jakewharton.rxbinding2.widget.RxTextView
import dagger.android.AndroidInjection import dagger.android.AndroidInjection
...@@ -30,16 +30,20 @@ class CreateNewChannelActivity : AppCompatActivity(), CreateNewChannelView { ...@@ -30,16 +30,20 @@ class CreateNewChannelActivity : AppCompatActivity(), CreateNewChannelView {
layout_container.isEnabled = true layout_container.isEnabled = true
} }
override fun showChannelCreatedSuccessfullyMessage() {
showToast(getString(R.string.msg_channel_created_successfully))
}
override fun showMessage(resId: Int) { override fun showMessage(resId: Int) {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates. showToast(getString(resId))
} }
override fun showMessage(message: String) { override fun showMessage(message: String) {
Toast.makeText(this, message, Toast.LENGTH_LONG).show() showToast(message)
} }
override fun showGenericErrorMessage() { override fun showGenericErrorMessage() {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates. showMessage(getString(R.string.msg_generic_error))
} }
@Inject @Inject
...@@ -86,7 +90,7 @@ class CreateNewChannelActivity : AppCompatActivity(), CreateNewChannelView { ...@@ -86,7 +90,7 @@ class CreateNewChannelActivity : AppCompatActivity(), CreateNewChannelView {
channelType = "c" channelType = "c"
channel_type.text = getString(R.string.public_channel_type) channel_type.text = getString(R.string.public_channel_type)
channel_description.text = getString(R.string.private_channel_type_description) channel_description.text = getString(R.string.public_channel_description)
placeholder.setImageDrawable(getDrawable(R.drawable.ic_hashtag_black)) placeholder.setImageDrawable(getDrawable(R.drawable.ic_hashtag_black))
...@@ -104,7 +108,7 @@ class CreateNewChannelActivity : AppCompatActivity(), CreateNewChannelView { ...@@ -104,7 +108,7 @@ class CreateNewChannelActivity : AppCompatActivity(), CreateNewChannelView {
channelType = "p" channelType = "p"
channel_type.text = getString(R.string.private_channel_type) channel_type.text = getString(R.string.private_channel_type)
channel_description.text = getString(R.string.public_channel_description) channel_description.text = getString(R.string.private_channel_type_description)
placeholder.setImageDrawable(getDrawable(R.drawable.ic_room_lock)) placeholder.setImageDrawable(getDrawable(R.drawable.ic_room_lock))
......
...@@ -49,6 +49,7 @@ ...@@ -49,6 +49,7 @@
<string name="msg_generic_error">Sorry, an error has occurred, please try again</string> <string name="msg_generic_error">Sorry, an error has occurred, please try again</string>
<string name="msg_no_data_to_display">No data to display</string> <string name="msg_no_data_to_display">No data to display</string>
<string name="msg_profile_update_successfully">Profile update successfully</string> <string name="msg_profile_update_successfully">Profile update successfully</string>
<string name="msg_channel_created_successfully">"Channel created successfully</string>
<string name="msg_username">username</string> <string name="msg_username">username</string>
<string name="msg_username_or_email">username or email</string> <string name="msg_username_or_email">username or email</string>
<string name="msg_password">password</string> <string name="msg_password">password</string>
......
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