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

Handled Null Safety Cases

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