Skip to content

Commit

Permalink
Merge pull request #11292 from wordpress-mobile/issue/fix-lifecycle-c…
Browse files Browse the repository at this point in the history
…rash-with-appcompat-1-1-0

Issue/fix lifecycle crash with appcompat 1 1 0
  • Loading branch information
khaykov authored Feb 23, 2020
2 parents 63da024 + 670c563 commit eca27bd
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 42 deletions.
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

0 comments on commit eca27bd

Please sign in to comment.