Skip to content
This repository was archived by the owner on Jun 7, 2020. It is now read-only.

Commit b342f3c

Browse files
authored
Merge pull request #2122 from RocketChat/revert-2093-refactor/app-module
Revert "[REFACTOR] Handle nullable on arguments extra"
2 parents ca4056e + 6a6a254 commit b342f3c

43 files changed

Lines changed: 318 additions & 292 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

app/src/main/java/chat/rocket/android/authentication/login/ui/LoginFragment.kt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,10 @@ class LoginFragment : Fragment(), LoginView {
5858
override fun onCreate(savedInstanceState: Bundle?) {
5959
super.onCreate(savedInstanceState)
6060
AndroidSupportInjection.inject(this)
61-
arguments?.run {
62-
serverName = getString(SERVER_NAME)
61+
62+
val bundle = arguments
63+
if (bundle != null) {
64+
serverName = bundle.getString(SERVER_NAME)
6365
}
6466
}
6567

@@ -148,7 +150,7 @@ class LoginFragment : Fragment(), LoginView {
148150
override fun showGenericErrorMessage() = showMessage(R.string.msg_generic_error)
149151

150152
private fun setupOnClickListener() =
151-
ui {
153+
ui { _ ->
152154
button_log_in.setOnClickListener {
153155
presenter.authenticateWithUserAndPassword(
154156
text_username_or_email.textContent,
@@ -158,7 +160,7 @@ class LoginFragment : Fragment(), LoginView {
158160
}
159161

160162
override fun showForgotPasswordView() {
161-
ui {
163+
ui { _ ->
162164
button_forgot_your_password.isVisible = true
163165
button_forgot_your_password.setOnClickListener { presenter.forgotPassword() }
164166

app/src/main/java/chat/rocket/android/authentication/loginoptions/ui/LoginOptionsFragment.kt

Lines changed: 31 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -157,33 +157,34 @@ class LoginOptionsFragment : Fragment(), LoginOptionsView {
157157
super.onCreate(savedInstanceState)
158158
AndroidSupportInjection.inject(this)
159159

160-
arguments?.run {
161-
serverName = getString(SERVER_NAME)
162-
state = getString(STATE)
163-
facebookOauthUrl = getString(FACEBOOK_OAUTH_URL)
164-
githubOauthUrl = getString(GITHUB_OAUTH_URL)
165-
googleOauthUrl = getString(GOOGLE_OAUTH_URL)
166-
linkedinOauthUrl = getString(LINKEDIN_OAUTH_URL)
167-
gitlabOauthUrl = getString(GITLAB_OAUTH_URL)
168-
wordpressOauthUrl = getString(WORDPRESS_OAUTH_URL)
169-
casLoginUrl = getString(CAS_LOGIN_URL)
170-
casToken = getString(CAS_TOKEN)
171-
casServiceName = getString(CAS_SERVICE_NAME)
172-
casServiceNameTextColor = getInt(CAS_SERVICE_NAME_TEXT_COLOR)
173-
casServiceButtonColor = getInt(CAS_SERVICE_BUTTON_COLOR)
174-
customOauthUrl = getString(CUSTOM_OAUTH_URL)
175-
customOauthServiceName = getString(CUSTOM_OAUTH_SERVICE_NAME)
176-
customOauthServiceTextColor = getInt(CUSTOM_OAUTH_SERVICE_NAME_TEXT_COLOR)
177-
customOauthServiceButtonColor = getInt(CUSTOM_OAUTH_SERVICE_BUTTON_COLOR)
178-
samlUrl = getString(SAML_URL)
179-
samlToken = getString(SAML_TOKEN)
180-
samlServiceName = getString(SAML_SERVICE_NAME)
181-
samlServiceTextColor = getInt(SAML_SERVICE_NAME_TEXT_COLOR)
182-
samlServiceButtonColor = getInt(SAML_SERVICE_BUTTON_COLOR)
183-
totalSocialAccountsEnabled = getInt(TOTAL_SOCIAL_ACCOUNTS)
184-
isLoginFormEnabled = getBoolean(IS_LOGIN_FORM_ENABLED)
185-
isNewAccountCreationEnabled = getBoolean(IS_NEW_ACCOUNT_CREATION_ENABLED)
186-
deepLinkInfo = getParcelable(DEEP_LINK_INFO)
160+
val bundle = arguments
161+
if (bundle != null) {
162+
serverName = bundle.getString(SERVER_NAME)
163+
state = bundle.getString(STATE)
164+
facebookOauthUrl = bundle.getString(FACEBOOK_OAUTH_URL)
165+
githubOauthUrl = bundle.getString(GITHUB_OAUTH_URL)
166+
googleOauthUrl = bundle.getString(GOOGLE_OAUTH_URL)
167+
linkedinOauthUrl = bundle.getString(LINKEDIN_OAUTH_URL)
168+
gitlabOauthUrl = bundle.getString(GITLAB_OAUTH_URL)
169+
wordpressOauthUrl = bundle.getString(WORDPRESS_OAUTH_URL)
170+
casLoginUrl = bundle.getString(CAS_LOGIN_URL)
171+
casToken = bundle.getString(CAS_TOKEN)
172+
casServiceName = bundle.getString(CAS_SERVICE_NAME)
173+
casServiceNameTextColor = bundle.getInt(CAS_SERVICE_NAME_TEXT_COLOR)
174+
casServiceButtonColor = bundle.getInt(CAS_SERVICE_BUTTON_COLOR)
175+
customOauthUrl = bundle.getString(CUSTOM_OAUTH_URL)
176+
customOauthServiceName = bundle.getString(CUSTOM_OAUTH_SERVICE_NAME)
177+
customOauthServiceTextColor = bundle.getInt(CUSTOM_OAUTH_SERVICE_NAME_TEXT_COLOR)
178+
customOauthServiceButtonColor = bundle.getInt(CUSTOM_OAUTH_SERVICE_BUTTON_COLOR)
179+
samlUrl = bundle.getString(SAML_URL)
180+
samlToken = bundle.getString(SAML_TOKEN)
181+
samlServiceName = bundle.getString(SAML_SERVICE_NAME)
182+
samlServiceTextColor = bundle.getInt(SAML_SERVICE_NAME_TEXT_COLOR)
183+
samlServiceButtonColor = bundle.getInt(SAML_SERVICE_BUTTON_COLOR)
184+
totalSocialAccountsEnabled = bundle.getInt(TOTAL_SOCIAL_ACCOUNTS)
185+
isLoginFormEnabled = bundle.getBoolean(IS_LOGIN_FORM_ENABLED)
186+
isNewAccountCreationEnabled = bundle.getBoolean(IS_NEW_ACCOUNT_CREATION_ENABLED)
187+
deepLinkInfo = bundle.getParcelable(DEEP_LINK_INFO)
187188
}
188189
}
189190

@@ -387,7 +388,7 @@ class LoginOptionsFragment : Fragment(), LoginOptionsView {
387388
}
388389

389390
override fun setupExpandAccountsView() {
390-
ui {
391+
ui { _ ->
391392
expand_more_accounts_container.isVisible = true
392393
var isAccountsCollapsed = true
393394
button_expand_collapse_accounts.setOnClickListener {
@@ -405,14 +406,14 @@ class LoginOptionsFragment : Fragment(), LoginOptionsView {
405406
}
406407

407408
override fun showLoginWithEmailButton() {
408-
ui {
409+
ui { _ ->
409410
button_login_with_email.setOnClickListener { presenter.toLoginWithEmail() }
410411
button_login_with_email.isVisible = true
411412
}
412413
}
413414

414415
override fun showCreateNewAccountButton() {
415-
ui {
416+
ui { _ ->
416417
button_create_an_account.setOnClickListener { presenter.toCreateAccount() }
417418
button_create_an_account.isVisible = true
418419
}

app/src/main/java/chat/rocket/android/authentication/registerusername/ui/RegisterUsernameFragment.kt

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,14 @@ class RegisterUsernameFragment : Fragment(), RegisterUsernameView {
5252
override fun onCreate(savedInstanceState: Bundle?) {
5353
super.onCreate(savedInstanceState)
5454
AndroidSupportInjection.inject(this)
55-
arguments?.run {
56-
userId = getString(BUNDLE_USER_ID, "")
57-
authToken = getString(BUNDLE_AUTH_TOKEN, "")
58-
} ?: requireNotNull(arguments) { "no arguments supplied when the fragment was instantiated" }
55+
56+
val bundle = arguments
57+
if (bundle != null) {
58+
userId = bundle.getString(BUNDLE_USER_ID)
59+
authToken = bundle.getString(BUNDLE_AUTH_TOKEN)
60+
} else {
61+
requireNotNull(bundle) { "no arguments supplied when the fragment was instantiated" }
62+
}
5963
}
6064

6165
override fun onCreateView(

app/src/main/java/chat/rocket/android/authentication/signup/ui/SignupFragment.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ class SignupFragment : Fragment(), SignupView {
7575
}
7676

7777
private fun setupOnClickListener() =
78-
ui {
78+
ui { _ ->
7979
button_register.setOnClickListener {
8080
presenter.signup(
8181
text_username.textContent,

app/src/main/java/chat/rocket/android/authentication/twofactor/ui/TwoFAFragment.kt

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,14 @@ class TwoFAFragment : Fragment(), TwoFAView {
4949
override fun onCreate(savedInstanceState: Bundle?) {
5050
super.onCreate(savedInstanceState)
5151
AndroidSupportInjection.inject(this)
52-
arguments?.run {
53-
username = getString(BUNDLE_USERNAME, "")
54-
password = getString(BUNDLE_PASSWORD, "")
55-
} ?: requireNotNull(arguments) { "no arguments supplied when the fragment was instantiated" }
52+
53+
val bundle = arguments
54+
if (bundle != null) {
55+
username = bundle.getString(BUNDLE_USERNAME)
56+
password = bundle.getString(BUNDLE_PASSWORD)
57+
} else {
58+
requireNotNull(bundle) { "no arguments supplied when the fragment was instantiated" }
59+
}
5660
}
5761

5862
override fun onCreateView(

app/src/main/java/chat/rocket/android/chatdetails/ui/ChatDetailsFragment.kt

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,15 @@ class ChatDetailsFragment : Fragment(), ChatDetailsView {
6666
override fun onCreate(savedInstanceState: Bundle?) {
6767
super.onCreate(savedInstanceState)
6868
AndroidSupportInjection.inject(this)
69-
arguments?.run {
70-
chatRoomId = getString(BUNDLE_CHAT_ROOM_ID)
71-
chatRoomType = getString(BUNDLE_CHAT_ROOM_TYPE)
72-
isSubscribed = getBoolean(BUNDLE_IS_SUBSCRIBED)
73-
disableMenu = getBoolean(BUNDLE_DISABLE_MENU)
74-
} ?: requireNotNull(arguments) { "no arguments supplied when the fragment was instantiated" }
69+
val bundle = arguments
70+
if (bundle != null) {
71+
chatRoomId = bundle.getString(BUNDLE_CHAT_ROOM_ID)
72+
chatRoomType = bundle.getString(BUNDLE_CHAT_ROOM_TYPE)
73+
isSubscribed = bundle.getBoolean(BUNDLE_IS_SUBSCRIBED)
74+
disableMenu = bundle.getBoolean(BUNDLE_DISABLE_MENU)
75+
} else {
76+
requireNotNull(bundle) { "no arguments supplied when the fragment was instantiated" }
77+
}
7578
}
7679

7780
override fun onCreateView(

app/src/main/java/chat/rocket/android/chatinformation/ui/MessageInfoFragment.kt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,12 @@ class MessageInfoFragment : Fragment(), MessageInfoView {
4646
AndroidSupportInjection.inject(this)
4747
setHasOptionsMenu(true)
4848

49-
arguments?.run {
50-
messageId = getString(BUNDLE_MESSAGE_ID, "")
51-
} ?: requireNotNull(arguments) { "no arguments supplied when the fragment was instantiated" }
49+
val bundle = arguments
50+
if (bundle != null) {
51+
messageId = bundle.getString(BUNDLE_MESSAGE_ID)
52+
} else {
53+
requireNotNull(bundle) { "no arguments supplied when the fragment was instantiated" }
54+
}
5255
}
5356

5457
override fun onCreateView(

app/src/main/java/chat/rocket/android/chatroom/adapter/ActionsListAdapter.kt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,7 @@ import com.facebook.drawee.backends.pipeline.Fresco
1212
import kotlinx.android.synthetic.main.item_action_button.view.*
1313
import timber.log.Timber
1414

15-
class ActionsListAdapter(
16-
actions: List<Action>,
17-
var actionAttachmentOnClickListener: ActionAttachmentOnClickListener
18-
) : RecyclerView.Adapter<ActionsListAdapter.ViewHolder>() {
15+
class ActionsListAdapter(actions: List<Action>, var actionAttachmentOnClickListener: ActionAttachmentOnClickListener) : RecyclerView.Adapter<ActionsListAdapter.ViewHolder>() {
1916

2017
var actions: List<Action> = actions
2118

app/src/main/java/chat/rocket/android/chatroom/adapter/ChatRoomAdapter.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,12 +174,12 @@ class ChatRoomAdapter(
174174
Timber.d("index: $index")
175175
if (index > -1) {
176176
dataSet[index] = message
177-
dataSet.forEachIndexed { ind, viewModel ->
177+
dataSet.forEachIndexed { index, viewModel ->
178178
if (viewModel.messageId == message.messageId) {
179179
if (viewModel.nextDownStreamMessage == null) {
180180
viewModel.reactions = message.reactions
181181
}
182-
notifyItemChanged(ind)
182+
notifyItemChanged(index)
183183
}
184184
}
185185
// Delete message only if current is a system message update, i.e.: Message Removed

app/src/main/java/chat/rocket/android/chatroom/adapter/RoomSuggestionsAdapter.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ class RoomSuggestionsAdapter : SuggestionsAdapter<RoomSuggestionsViewHolder>("#"
2424
override fun bind(item: SuggestionModel, itemClickListener: SuggestionsAdapter.ItemClickListener?) {
2525
item as ChatRoomSuggestionUiModel
2626
with(itemView) {
27-
val fullname = findViewById<TextView>(R.id.text_fullname)
28-
val name = findViewById<TextView>(R.id.text_name)
27+
val fullname = itemView.findViewById<TextView>(R.id.text_fullname)
28+
val name = itemView.findViewById<TextView>(R.id.text_name)
2929
name.text = item.name
3030
fullname.text = item.fullName
3131
setOnClickListener {

0 commit comments

Comments
 (0)