Commit 771dadee authored by Samer Alabi's avatar Samer Alabi

Handled Null Safety Cases

parent cbc5ce94
......@@ -60,8 +60,8 @@ class ChatDetailsFragment: Fragment(), ChatDetailsView {
private var chatRoomId: String? = null
private var chatRoomType: String? = null
private var isSubscribed: Boolean? = null
private var disableMenu: Boolean? = null
private var isSubscribed: Boolean = true
private var disableMenu: Boolean = false
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
......@@ -91,7 +91,7 @@ class ChatDetailsFragment: Fragment(), ChatDetailsView {
override fun displayDetails(room: ChatDetails) {
ui {
val text = " " + room.name
val text = room.name
name.text = text
bindImage(chatRoomType!!)
content_topic.text = if (room.topic.isNullOrEmpty()) getString(R.string.msg_no_topic) else room.topic
......@@ -115,13 +115,13 @@ class ChatDetailsFragment: Fragment(), ChatDetailsView {
}
private fun addOptions(adapter: ChatDetailsAdapter) {
if (!disableMenu!!) {
if (!disableMenu) {
adapter.addOption(getString(R.string.title_files), R.drawable.ic_files_24dp) {
presenter.toFiles(chatRoomId!!)
}
}
if (chatRoomType != RoomType.DIRECT_MESSAGE && !disableMenu!!) {
if (chatRoomType != RoomType.DIRECT_MESSAGE && !disableMenu) {
adapter.addOption(getString(R.string.msg_mentions), R.drawable.ic_at_black_20dp) {
presenter.toMentions(chatRoomId!!)
}
......@@ -158,7 +158,7 @@ class ChatDetailsFragment: Fragment(), ChatDetailsView {
}
private fun getDetails() {
if (isSubscribed!!)
if (isSubscribed)
viewModel.getDetails(chatRoomId!!).observe(viewLifecycleOwner, Observer { details ->
displayDetails(details)
})
......@@ -190,9 +190,9 @@ class ChatDetailsFragment: Fragment(), ChatDetailsView {
}
private fun setupToolbar() {
with(activity as ChatDetailsActivity) {
setNavigationIcon(R.drawable.ic_close_white_24dp)
setToolbarTitle(getString(R.string.title_channel_details))
(activity as ChatDetailsActivity).let {
it.setNavigationIcon(R.drawable.ic_close_white_24dp)
it.setToolbarTitle(getString(R.string.title_channel_details))
}
}
}
\ No newline at end of file
......@@ -296,8 +296,8 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
super.onPrepareOptionsMenu(menu)
}
override fun onOptionsItemSelected(item: MenuItem?): Boolean {
setOnMenuItemClickListener(item!!)
override fun onOptionsItemSelected(item: MenuItem): Boolean {
setOnMenuItemClickListener(item)
return true
}
......
......@@ -116,9 +116,9 @@ class FavoriteMessagesFragment : Fragment(), FavoriteMessagesView {
}
private fun setupToolbar() {
with(activity as ChatDetailsActivity) {
setToolbarTitle(getString(R.string.title_favorite_messages))
setNavigationIcon(R.drawable.ic_arrow_back_white_24dp)
(activity as ChatDetailsActivity).let {
it.setToolbarTitle(getString(R.string.title_favorite_messages))
it.setNavigationIcon(R.drawable.ic_arrow_back_white_24dp)
}
}
}
\ No newline at end of file
......@@ -152,9 +152,9 @@ class FilesFragment : Fragment(), FilesView {
}
private fun setupToolbar(totalFiles: Long) {
with(activity as ChatDetailsActivity) {
setToolbarTitle(getString(R.string.title_files_total, totalFiles))
setNavigationIcon(R.drawable.ic_arrow_back_white_24dp)
(activity as ChatDetailsActivity).let {
it.setToolbarTitle(getString(R.string.title_files_total, totalFiles))
it.setNavigationIcon(R.drawable.ic_arrow_back_white_24dp)
}
}
}
\ No newline at end of file
......@@ -127,13 +127,13 @@ class MembersFragment : Fragment(), MembersView {
}
private fun setupToolbar(totalMembers: Long? = null) {
with (activity as ChatDetailsActivity) {
(activity as ChatDetailsActivity).let {
if (totalMembers != null) {
setToolbarTitle(getString(R.string.title_counted_members, totalMembers))
it.setToolbarTitle(getString(R.string.title_counted_members, totalMembers))
} else {
setToolbarTitle(getString(R.string.title_members))
it.setToolbarTitle(getString(R.string.title_members))
}
setNavigationIcon(R.drawable.ic_arrow_back_white_24dp)
it.setNavigationIcon(R.drawable.ic_arrow_back_white_24dp)
}
}
}
\ No newline at end of file
......@@ -122,9 +122,9 @@ class MentionsFragment : Fragment(), MentionsView {
}
private fun setupToolbar() {
with(activity as ChatDetailsActivity) {
setToolbarTitle(getString(R.string.msg_mentions))
setNavigationIcon(R.drawable.ic_arrow_back_white_24dp)
(activity as ChatDetailsActivity).let {
it.setToolbarTitle(getString(R.string.msg_mentions))
it.setNavigationIcon(R.drawable.ic_arrow_back_white_24dp)
}
}
}
\ No newline at end of file
......@@ -123,9 +123,9 @@ class PinnedMessagesFragment : Fragment(), PinnedMessagesView {
}
private fun setupToolbar() {
with(activity as ChatDetailsActivity) {
setToolbarTitle(getString(R.string.title_pinned_messages))
setNavigationIcon(R.drawable.ic_arrow_back_white_24dp)
(activity as ChatDetailsActivity).let {
it.setToolbarTitle(getString(R.string.title_pinned_messages))
it.setNavigationIcon(R.drawable.ic_arrow_back_white_24dp)
}
}
}
\ No newline at end of file
......@@ -18,6 +18,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/ChatDetails.Title.TextView"
android:drawablePadding="@dimen/text_view_drawable_padding"
tools:text="#important"/>
<TextView
android:id="@+id/title_topic"
......
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