Skip to content

Commit

Permalink
Merge pull request #5417 from Isira-Seneviratne/Fix_crash_on_back_nav…
Browse files Browse the repository at this point in the history
…igation

Fix the crash that occurs on navigating back to the main fragment.
  • Loading branch information
Stypox authored Jan 15, 2021
2 parents 8fd48a8 + 87568b6 commit 302fde6
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,6 @@ public void onResume() {
public void onDestroy() {
super.onDestroy();
tabsManager.unsetSavedTabsListener();
}

@Override
public void onDestroyView() {
super.onDestroyView();
if (binding != null) {
binding.pager.setAdapter(null);
binding = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ class FeedFragment : BaseListFragment<FeedState, Unit>() {
}

feedBinding.loadingProgressBar.isIndeterminate = isIndeterminate ||
(progressState.maxProgress > 0 && progressState.currentProgress == 0)
(progressState.maxProgress > 0 && progressState.currentProgress == 0)
feedBinding.loadingProgressBar.progress = progressState.currentProgress

feedBinding.loadingProgressBar.max = progressState.maxProgress
Expand All @@ -269,8 +269,10 @@ class FeedFragment : BaseListFragment<FeedState, Unit>() {
val loadedCount = loadedState.notLoadedCount > 0
feedBinding.refreshSubtitleText.isVisible = loadedCount
if (loadedCount) {
feedBinding.refreshSubtitleText.text = getString(R.string.feed_subscription_not_loaded_count,
loadedState.notLoadedCount)
feedBinding.refreshSubtitleText.text = getString(
R.string.feed_subscription_not_loaded_count,
loadedState.notLoadedCount
)
}

if (loadedState.itemsErrors.isNotEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,10 +311,10 @@ class SubscriptionFragment : BaseStateFragment<SubscriptionState>() {
dialogTitleBinding.itemAdditionalDetails.visibility = View.GONE

AlertDialog.Builder(requireContext())
.setCustomTitle(dialogTitleBinding.root)
.setItems(commands, actions)
.create()
.show()
.setCustomTitle(dialogTitleBinding.root)
.setItems(commands, actions)
.create()
.show()
}

private fun deleteChannel(selectedItem: ChannelInfoItem) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,8 @@ class FeedGroupDialog : DialogFragment(), BackPressable {
val selectedCount = this.selectedSubscriptions.size
val selectedCountText = resources.getQuantityString(
R.plurals.feed_group_dialog_selection_count,
selectedCount, selectedCount)
selectedCount, selectedCount
)
feedGroupCreateBinding.selectedSubscriptionCountView.text = selectedCountText
feedGroupCreateBinding.subscriptionsHeaderInfo.text = selectedCountText
}
Expand Down Expand Up @@ -423,10 +424,12 @@ class FeedGroupDialog : DialogFragment(), BackPressable {
feedGroupCreateBinding.separator.onlyVisibleIn(SubscriptionsPickerScreen, IconPickerScreen)
feedGroupCreateBinding.cancelButton.onlyVisibleIn(InitialScreen, DeleteScreen)

feedGroupCreateBinding.confirmButton.setText(when {
currentScreen == InitialScreen && groupId == NO_GROUP_SELECTED -> R.string.create
else -> android.R.string.ok
})
feedGroupCreateBinding.confirmButton.setText(
when {
currentScreen == InitialScreen && groupId == NO_GROUP_SELECTED -> R.string.create
else -> android.R.string.ok
}
)

feedGroupCreateBinding.deleteButton.isGone = currentScreen != InitialScreen || groupId == NO_GROUP_SELECTED

Expand Down Expand Up @@ -471,27 +474,35 @@ class FeedGroupDialog : DialogFragment(), BackPressable {

private fun showKeyboardSearch() {
if (searchLayoutBinding.toolbarSearchEditText.requestFocus()) {
inputMethodManager.showSoftInput(searchLayoutBinding.toolbarSearchEditText,
InputMethodManager.SHOW_IMPLICIT)
inputMethodManager.showSoftInput(
searchLayoutBinding.toolbarSearchEditText,
InputMethodManager.SHOW_IMPLICIT
)
}
}

private fun hideKeyboardSearch() {
inputMethodManager.hideSoftInputFromWindow(searchLayoutBinding.toolbarSearchEditText.windowToken,
InputMethodManager.RESULT_UNCHANGED_SHOWN)
inputMethodManager.hideSoftInputFromWindow(
searchLayoutBinding.toolbarSearchEditText.windowToken,
InputMethodManager.RESULT_UNCHANGED_SHOWN
)
searchLayoutBinding.toolbarSearchEditText.clearFocus()
}

private fun showKeyboard() {
if (feedGroupCreateBinding.groupNameInput.requestFocus()) {
inputMethodManager.showSoftInput(feedGroupCreateBinding.groupNameInput,
InputMethodManager.SHOW_IMPLICIT)
inputMethodManager.showSoftInput(
feedGroupCreateBinding.groupNameInput,
InputMethodManager.SHOW_IMPLICIT
)
}
}

private fun hideKeyboard() {
inputMethodManager.hideSoftInputFromWindow(feedGroupCreateBinding.groupNameInput.windowToken,
InputMethodManager.RESULT_UNCHANGED_SHOWN)
inputMethodManager.hideSoftInputFromWindow(
feedGroupCreateBinding.groupNameInput.windowToken,
InputMethodManager.RESULT_UNCHANGED_SHOWN
)
feedGroupCreateBinding.groupNameInput.clearFocus()
}

Expand Down

0 comments on commit 302fde6

Please sign in to comment.