mirror of
https://github.com/NiciDieNase/chaosflix
synced 2024-11-23 21:03:12 +00:00
partially solve retention of status on orientation change
This commit is contained in:
parent
65d47fe85a
commit
d34c977abf
3 changed files with 23 additions and 13 deletions
|
@ -32,27 +32,35 @@ public class BrowseActivity extends TouchBaseActivity implements
|
||||||
EventDetailsFragment.OnEventDetailsFragmentInteractionListener{
|
EventDetailsFragment.OnEventDetailsFragmentInteractionListener{
|
||||||
|
|
||||||
private static final String TAG = BrowseActivity.class.getSimpleName();
|
private static final String TAG = BrowseActivity.class.getSimpleName();
|
||||||
|
private static final String TAG_RETAINED_FRAGMENT = "retained_fragment";
|
||||||
CompositeDisposable mDisposables = new CompositeDisposable();
|
CompositeDisposable mDisposables = new CompositeDisposable();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.fragment_container_layout);
|
setContentView(R.layout.fragment_container_layout);
|
||||||
Disposable disposable = getApiServiceObservable()
|
FragmentManager fragmentManager = getSupportFragmentManager();
|
||||||
.subscribe(mediaApiService -> {
|
Fragment fragment = fragmentManager.findFragmentByTag(TAG_RETAINED_FRAGMENT);
|
||||||
mediaApiService.getConferences()
|
if(fragment != null){
|
||||||
|
FragmentTransaction ft = fragmentManager.beginTransaction();
|
||||||
|
ft.replace(R.id.fragment_container,fragment,TAG_RETAINED_FRAGMENT);
|
||||||
|
ft.commit();
|
||||||
|
} else {
|
||||||
|
Disposable disposable = getApiServiceObservable()
|
||||||
|
.subscribe(mediaApiService -> {
|
||||||
|
mediaApiService.getConferences()
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe(conferencesWrapper -> {
|
.subscribe(conferencesWrapper -> {
|
||||||
ConferencesBrowseFragment browseFragment
|
ConferencesTabBrowseFragment browseFragment
|
||||||
= ConferencesBrowseFragment.newInstance(getNumColumns());
|
= ConferencesTabBrowseFragment.newInstance(getNumColumns());
|
||||||
browseFragment.setContent(conferencesWrapper);
|
browseFragment.setContent(conferencesWrapper);
|
||||||
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
|
FragmentTransaction ft = fragmentManager.beginTransaction();
|
||||||
ft.replace(R.id.fragment_container,browseFragment);
|
ft.replace(R.id.fragment_container,browseFragment);
|
||||||
ft.commit();
|
ft.commit();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
mDisposables.add(disposable);
|
mDisposables.add(disposable);
|
||||||
getSupportActionBar().setLogo(R.drawable.icon_notext);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -61,6 +61,7 @@ public class EventDetailsFragment extends Fragment {
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
setRetainInstance(true);
|
||||||
postponeEnterTransition();
|
postponeEnterTransition();
|
||||||
Transition transition = TransitionInflater.from(getContext())
|
Transition transition = TransitionInflater.from(getContext())
|
||||||
.inflateTransition(android.R.transition.move);
|
.inflateTransition(android.R.transition.move);
|
||||||
|
|
|
@ -58,6 +58,7 @@ public class EventsFragment extends Fragment {
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
setRetainInstance(true);
|
||||||
if (getArguments() != null) {
|
if (getArguments() != null) {
|
||||||
mColumnCount = getArguments().getInt(ARG_COLUMN_COUNT);
|
mColumnCount = getArguments().getInt(ARG_COLUMN_COUNT);
|
||||||
mConference = getArguments().getParcelable(ARG_CONFERENCE);
|
mConference = getArguments().getParcelable(ARG_CONFERENCE);
|
||||||
|
|
Loading…
Reference in a new issue