Fix the crash that occurs on navigating back to the main fragment.

This commit is contained in:
Isira Seneviratne 2021-01-15 06:45:07 +05:30
parent 8fd48a88be
commit 87568b6590
4 changed files with 33 additions and 25 deletions

View File

@ -117,11 +117,6 @@ public class MainFragment extends BaseFragment implements TabLayout.OnTabSelecte
public void onDestroy() { public void onDestroy() {
super.onDestroy(); super.onDestroy();
tabsManager.unsetSavedTabsListener(); tabsManager.unsetSavedTabsListener();
}
@Override
public void onDestroyView() {
super.onDestroyView();
if (binding != null) { if (binding != null) {
binding.pager.setAdapter(null); binding.pager.setAdapter(null);
binding = null; binding = null;

View File

@ -251,7 +251,7 @@ class FeedFragment : BaseListFragment<FeedState, Unit>() {
} }
feedBinding.loadingProgressBar.isIndeterminate = isIndeterminate || feedBinding.loadingProgressBar.isIndeterminate = isIndeterminate ||
(progressState.maxProgress > 0 && progressState.currentProgress == 0) (progressState.maxProgress > 0 && progressState.currentProgress == 0)
feedBinding.loadingProgressBar.progress = progressState.currentProgress feedBinding.loadingProgressBar.progress = progressState.currentProgress
feedBinding.loadingProgressBar.max = progressState.maxProgress feedBinding.loadingProgressBar.max = progressState.maxProgress
@ -269,8 +269,10 @@ class FeedFragment : BaseListFragment<FeedState, Unit>() {
val loadedCount = loadedState.notLoadedCount > 0 val loadedCount = loadedState.notLoadedCount > 0
feedBinding.refreshSubtitleText.isVisible = loadedCount feedBinding.refreshSubtitleText.isVisible = loadedCount
if (loadedCount) { if (loadedCount) {
feedBinding.refreshSubtitleText.text = getString(R.string.feed_subscription_not_loaded_count, feedBinding.refreshSubtitleText.text = getString(
loadedState.notLoadedCount) R.string.feed_subscription_not_loaded_count,
loadedState.notLoadedCount
)
} }
if (loadedState.itemsErrors.isNotEmpty()) { if (loadedState.itemsErrors.isNotEmpty()) {

View File

@ -311,10 +311,10 @@ class SubscriptionFragment : BaseStateFragment<SubscriptionState>() {
dialogTitleBinding.itemAdditionalDetails.visibility = View.GONE dialogTitleBinding.itemAdditionalDetails.visibility = View.GONE
AlertDialog.Builder(requireContext()) AlertDialog.Builder(requireContext())
.setCustomTitle(dialogTitleBinding.root) .setCustomTitle(dialogTitleBinding.root)
.setItems(commands, actions) .setItems(commands, actions)
.create() .create()
.show() .show()
} }
private fun deleteChannel(selectedItem: ChannelInfoItem) { private fun deleteChannel(selectedItem: ChannelInfoItem) {

View File

@ -368,7 +368,8 @@ class FeedGroupDialog : DialogFragment(), BackPressable {
val selectedCount = this.selectedSubscriptions.size val selectedCount = this.selectedSubscriptions.size
val selectedCountText = resources.getQuantityString( val selectedCountText = resources.getQuantityString(
R.plurals.feed_group_dialog_selection_count, R.plurals.feed_group_dialog_selection_count,
selectedCount, selectedCount) selectedCount, selectedCount
)
feedGroupCreateBinding.selectedSubscriptionCountView.text = selectedCountText feedGroupCreateBinding.selectedSubscriptionCountView.text = selectedCountText
feedGroupCreateBinding.subscriptionsHeaderInfo.text = selectedCountText feedGroupCreateBinding.subscriptionsHeaderInfo.text = selectedCountText
} }
@ -423,10 +424,12 @@ class FeedGroupDialog : DialogFragment(), BackPressable {
feedGroupCreateBinding.separator.onlyVisibleIn(SubscriptionsPickerScreen, IconPickerScreen) feedGroupCreateBinding.separator.onlyVisibleIn(SubscriptionsPickerScreen, IconPickerScreen)
feedGroupCreateBinding.cancelButton.onlyVisibleIn(InitialScreen, DeleteScreen) feedGroupCreateBinding.cancelButton.onlyVisibleIn(InitialScreen, DeleteScreen)
feedGroupCreateBinding.confirmButton.setText(when { feedGroupCreateBinding.confirmButton.setText(
currentScreen == InitialScreen && groupId == NO_GROUP_SELECTED -> R.string.create when {
else -> android.R.string.ok currentScreen == InitialScreen && groupId == NO_GROUP_SELECTED -> R.string.create
}) else -> android.R.string.ok
}
)
feedGroupCreateBinding.deleteButton.isGone = currentScreen != InitialScreen || groupId == NO_GROUP_SELECTED feedGroupCreateBinding.deleteButton.isGone = currentScreen != InitialScreen || groupId == NO_GROUP_SELECTED
@ -471,27 +474,35 @@ class FeedGroupDialog : DialogFragment(), BackPressable {
private fun showKeyboardSearch() { private fun showKeyboardSearch() {
if (searchLayoutBinding.toolbarSearchEditText.requestFocus()) { if (searchLayoutBinding.toolbarSearchEditText.requestFocus()) {
inputMethodManager.showSoftInput(searchLayoutBinding.toolbarSearchEditText, inputMethodManager.showSoftInput(
InputMethodManager.SHOW_IMPLICIT) searchLayoutBinding.toolbarSearchEditText,
InputMethodManager.SHOW_IMPLICIT
)
} }
} }
private fun hideKeyboardSearch() { private fun hideKeyboardSearch() {
inputMethodManager.hideSoftInputFromWindow(searchLayoutBinding.toolbarSearchEditText.windowToken, inputMethodManager.hideSoftInputFromWindow(
InputMethodManager.RESULT_UNCHANGED_SHOWN) searchLayoutBinding.toolbarSearchEditText.windowToken,
InputMethodManager.RESULT_UNCHANGED_SHOWN
)
searchLayoutBinding.toolbarSearchEditText.clearFocus() searchLayoutBinding.toolbarSearchEditText.clearFocus()
} }
private fun showKeyboard() { private fun showKeyboard() {
if (feedGroupCreateBinding.groupNameInput.requestFocus()) { if (feedGroupCreateBinding.groupNameInput.requestFocus()) {
inputMethodManager.showSoftInput(feedGroupCreateBinding.groupNameInput, inputMethodManager.showSoftInput(
InputMethodManager.SHOW_IMPLICIT) feedGroupCreateBinding.groupNameInput,
InputMethodManager.SHOW_IMPLICIT
)
} }
} }
private fun hideKeyboard() { private fun hideKeyboard() {
inputMethodManager.hideSoftInputFromWindow(feedGroupCreateBinding.groupNameInput.windowToken, inputMethodManager.hideSoftInputFromWindow(
InputMethodManager.RESULT_UNCHANGED_SHOWN) feedGroupCreateBinding.groupNameInput.windowToken,
InputMethodManager.RESULT_UNCHANGED_SHOWN
)
feedGroupCreateBinding.groupNameInput.clearFocus() feedGroupCreateBinding.groupNameInput.clearFocus()
} }