Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue/fix lifecycle crash with appcompat 1 1 0 #11292

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package org.wordpress.android.ui.sitecreation.domains

import android.content.Context
import android.os.Bundle
import android.os.Parcelable
import android.view.View
import android.view.ViewGroup
import androidx.annotation.LayoutRes
Expand All @@ -23,8 +22,6 @@ import org.wordpress.android.ui.sitecreation.misc.SearchInputWithHeader
import org.wordpress.android.ui.utils.UiHelpers
import javax.inject.Inject

private const val KEY_LIST_STATE = "list_state"

class SiteCreationDomainsFragment : SiteCreationBaseFormFragment() {
private lateinit var nonNullActivity: FragmentActivity
private lateinit var linearLayoutManager: LinearLayoutManager
Expand Down Expand Up @@ -87,16 +84,8 @@ class SiteCreationDomainsFragment : SiteCreationBaseFormFragment() {
(nonNullActivity.application as WordPress).component().inject(this)
}

override fun onSaveInstanceState(outState: Bundle) {
super.onSaveInstanceState(outState)
outState.putParcelable(KEY_LIST_STATE, linearLayoutManager.onSaveInstanceState())
}

override fun onViewStateRestored(savedInstanceState: Bundle?) {
super.onViewStateRestored(savedInstanceState)
savedInstanceState?.getParcelable<Parcelable>(KEY_LIST_STATE)?.let {
linearLayoutManager.onRestoreInstanceState(it)
}
// we need to set the `onTextChanged` after the viewState has been restored otherwise the viewModel.updateQuery
// is called when the system sets the restored value to the EditText which results in an unnecessary request
searchInputWithHeader.onTextChanged = { viewModel.updateQuery(it) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package org.wordpress.android.ui.sitecreation.segments

import android.content.Context
import android.os.Bundle
import android.os.Parcelable
import android.view.View
import android.view.ViewGroup
import android.widget.Button
Expand All @@ -24,8 +23,6 @@ import org.wordpress.android.ui.utils.UiHelpers
import org.wordpress.android.util.image.ImageManager
import javax.inject.Inject

private const val KEY_LIST_STATE = "list_state"

class SiteCreationSegmentsFragment : SiteCreationBaseFormFragment() {
private lateinit var linearLayoutManager: LinearLayoutManager
private lateinit var recyclerView: RecyclerView
Expand Down Expand Up @@ -133,18 +130,6 @@ class SiteCreationSegmentsFragment : SiteCreationBaseFormFragment() {
(activity!!.application as WordPress).component().inject(this)
}

override fun onSaveInstanceState(outState: Bundle) {
super.onSaveInstanceState(outState)
outState.putParcelable(KEY_LIST_STATE, linearLayoutManager.onSaveInstanceState())
}

override fun onViewStateRestored(savedInstanceState: Bundle?) {
super.onViewStateRestored(savedInstanceState)
savedInstanceState?.getParcelable<Parcelable>(KEY_LIST_STATE)?.let {
linearLayoutManager.onRestoreInstanceState(it)
}
}

private fun updateContentLayout(segments: SegmentsContentUiState) {
(recyclerView.adapter as SiteCreationSegmentsAdapter).update(segments.items)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package org.wordpress.android.ui.sitecreation.verticals

import android.content.Context
import android.os.Bundle
import android.os.Parcelable
import android.view.ViewGroup
import android.widget.Button
import androidx.annotation.LayoutRes
Expand All @@ -28,8 +27,6 @@ import org.wordpress.android.ui.utils.UiHelpers
import javax.inject.Inject
import kotlin.properties.Delegates

private const val KEY_LIST_STATE = "list_state"

class SiteCreationVerticalsFragment : SiteCreationBaseFormFragment() {
private lateinit var nonNullActivity: FragmentActivity
private var segmentId by Delegates.notNull<Long>()
Expand Down Expand Up @@ -99,16 +96,8 @@ class SiteCreationVerticalsFragment : SiteCreationBaseFormFragment() {
}
}

override fun onSaveInstanceState(outState: Bundle) {
super.onSaveInstanceState(outState)
outState.putParcelable(KEY_LIST_STATE, linearLayoutManager.onSaveInstanceState())
}

override fun onViewStateRestored(savedInstanceState: Bundle?) {
super.onViewStateRestored(savedInstanceState)
savedInstanceState?.getParcelable<Parcelable>(KEY_LIST_STATE)?.let {
linearLayoutManager.onRestoreInstanceState(it)
}
// we need to set the `onTextChanged` after the viewState has been restored otherwise the viewModel.updateQuery
// is called when the system sets the restored value to the EditText which results in an unnecessary request
searchInputWithHeader.onTextChanged = { viewModel.updateQuery(it) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ public class LoginMagicLinkRequestFragment extends Fragment {
public static final String TAG = "login_magic_link_request_fragment_tag";

private static final String KEY_IN_PROGRESS = "KEY_IN_PROGRESS";
private static final String KEY_GRAVATAR_IN_PROGRESS = "KEY_GRAVATAR_IN_PROGRESS";
private static final String ARG_EMAIL_ADDRESS = "ARG_EMAIL_ADDRESS";
private static final String ARG_MAGIC_LINK_SCHEME = "ARG_MAGIC_LINK_SCHEME";
private static final String ARG_IS_JETPACK_CONNECT = "ARG_IS_JETPACK_CONNECT";
Expand Down Expand Up @@ -224,9 +223,6 @@ public void onActivityCreated(@Nullable Bundle savedInstanceState) {
if (mInProgress) {
showMagicLinkRequestProgressDialog();
}

boolean gravatarInProgress = savedInstanceState.getBoolean(KEY_GRAVATAR_IN_PROGRESS);
mAvatarProgressBar.setVisibility(gravatarInProgress ? View.VISIBLE : View.GONE);
}
// important for accessibility - talkback
getActivity().setTitle(R.string.magic_link_login_title);
Expand All @@ -243,7 +239,6 @@ public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);

outState.putBoolean(KEY_IN_PROGRESS, mInProgress);
outState.putBoolean(KEY_GRAVATAR_IN_PROGRESS, mAvatarProgressBar.getVisibility() == View.VISIBLE);
}

@Override
Expand Down