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

channel creation successful

parent 874ae7e4
package chat.rocket.android.createChannel.presentation
import android.widget.Toast
import chat.rocket.android.core.lifecycle.CancelStrategy
import chat.rocket.android.server.domain.GetCurrentServerInteractor
import chat.rocket.android.server.infraestructure.RocketChatClientFactory
import chat.rocket.android.util.extensions.launchUI
import chat.rocket.common.RocketChatException
import chat.rocket.common.model.RoomType
import chat.rocket.common.util.ifNull
import chat.rocket.core.RocketChatClient
import chat.rocket.core.internal.rest.createChannel
import chat.rocket.core.model.Room
import javax.inject.Inject
......@@ -21,11 +24,14 @@ class CreateNewChannelPresenter @Inject constructor(private val view: CreateNewC
launchUI(strategy) {
view.showLoading()
try {
client.createChannel(roomType, channelName, usersList, readOnly)
view.showMessage("Channel Created successfully")
} catch (ex: RocketChatException) {
//TODO remove this and add Log message instead
ex.printStackTrace()
val channelCreated:Room? = client.createChannel(roomType, channelName, usersList, readOnly)
view.showChannelCreatedSuccessfullyMessage()
} catch (exception: RocketChatException) {
exception.message?.let {
view.showMessage(it)
}.ifNull {
view.showGenericErrorMessage()
}
} finally {
view.hideLoading()
}
......
......@@ -4,6 +4,9 @@ import chat.rocket.android.core.behaviours.LoadingView
import chat.rocket.android.core.behaviours.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
import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import android.view.MenuItem
import android.widget.Toast
import chat.rocket.android.R
import chat.rocket.android.createChannel.presentation.CreateNewChannelPresenter
import chat.rocket.android.createChannel.presentation.CreateNewChannelView
import chat.rocket.android.util.extensions.setVisible
import chat.rocket.android.util.extensions.showToast
import chat.rocket.common.model.roomTypeOf
import com.jakewharton.rxbinding2.widget.RxTextView
import dagger.android.AndroidInjection
......@@ -30,16 +30,20 @@ class CreateNewChannelActivity : AppCompatActivity(), CreateNewChannelView {
layout_container.isEnabled = true
}
override fun showChannelCreatedSuccessfullyMessage() {
showToast(getString(R.string.msg_channel_created_successfully))
}
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) {
Toast.makeText(this, message, Toast.LENGTH_LONG).show()
showToast(message)
}
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
......@@ -86,7 +90,7 @@ class CreateNewChannelActivity : AppCompatActivity(), CreateNewChannelView {
channelType = "c"
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))
......@@ -104,7 +108,7 @@ class CreateNewChannelActivity : AppCompatActivity(), CreateNewChannelView {
channelType = "p"
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))
......
......@@ -49,6 +49,7 @@
<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_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_or_email">username or email</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