mirror of
https://github.com/NiciDieNase/chaosflix
synced 2024-11-23 12:53:08 +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{
|
||||
|
||||
private static final String TAG = BrowseActivity.class.getSimpleName();
|
||||
private static final String TAG_RETAINED_FRAGMENT = "retained_fragment";
|
||||
CompositeDisposable mDisposables = new CompositeDisposable();
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.fragment_container_layout);
|
||||
Disposable disposable = getApiServiceObservable()
|
||||
.subscribe(mediaApiService -> {
|
||||
mediaApiService.getConferences()
|
||||
FragmentManager fragmentManager = getSupportFragmentManager();
|
||||
Fragment fragment = fragmentManager.findFragmentByTag(TAG_RETAINED_FRAGMENT);
|
||||
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())
|
||||
.subscribe(conferencesWrapper -> {
|
||||
ConferencesBrowseFragment browseFragment
|
||||
= ConferencesBrowseFragment.newInstance(getNumColumns());
|
||||
browseFragment.setContent(conferencesWrapper);
|
||||
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
|
||||
ft.replace(R.id.fragment_container,browseFragment);
|
||||
ft.commit();
|
||||
});
|
||||
});
|
||||
mDisposables.add(disposable);
|
||||
getSupportActionBar().setLogo(R.drawable.icon_notext);
|
||||
ConferencesTabBrowseFragment browseFragment
|
||||
= ConferencesTabBrowseFragment.newInstance(getNumColumns());
|
||||
browseFragment.setContent(conferencesWrapper);
|
||||
FragmentTransaction ft = fragmentManager.beginTransaction();
|
||||
ft.replace(R.id.fragment_container,browseFragment);
|
||||
ft.commit();
|
||||
});
|
||||
});
|
||||
mDisposables.add(disposable);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -61,6 +61,7 @@ public class EventDetailsFragment extends Fragment {
|
|||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setRetainInstance(true);
|
||||
postponeEnterTransition();
|
||||
Transition transition = TransitionInflater.from(getContext())
|
||||
.inflateTransition(android.R.transition.move);
|
||||
|
|
|
@ -58,6 +58,7 @@ public class EventsFragment extends Fragment {
|
|||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setRetainInstance(true);
|
||||
if (getArguments() != null) {
|
||||
mColumnCount = getArguments().getInt(ARG_COLUMN_COUNT);
|
||||
mConference = getArguments().getParcelable(ARG_CONFERENCE);
|
||||
|
|
Loading…
Reference in a new issue