handle network error

This commit is contained in:
Felix 2017-09-25 04:03:51 +02:00
parent cd7039906e
commit c7f8de64e0

View file

@ -4,6 +4,7 @@ import android.arch.lifecycle.ViewModelProviders;
import android.content.res.Resources;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.Snackbar;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
@ -60,23 +61,20 @@ public class BrowseActivity extends AppCompatActivity implements
if(savedInstanceState == null){
ConferencesTabBrowseFragment browseFragment
= ConferencesTabBrowseFragment.newInstance(getNumColumns());
mViewModel.getConferencesWrapperAsLiveData().observe(browseFragment,conferencesWrapper -> {
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
ft.replace(R.id.fragment_container,browseFragment);
ft.setReorderingAllowed(true);
ft.commit();
});
// mDisposables.add(mViewModel.getConferencesWrapper()
// .observeOn(AndroidSchedulers.mainThread())
// .doOnError(throwable -> Log.d(TAG, String.valueOf(throwable.getCause())))
// .subscribe(conferencesWrapper -> {
// ConferencesTabBrowseFragment browseFragment
// = ConferencesTabBrowseFragment.newInstance(getNumColumns());
// mViewModel.getConferencesWrapperAsLiveData().observe(browseFragment,conferencesWrapper -> {
// FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
// ft.replace(R.id.fragment_container,browseFragment);
// ft.setReorderingAllowed(true);
// ft.commit();
// }));
// });
mDisposables.add(mViewModel.getConferencesWrapper()
.observeOn(AndroidSchedulers.mainThread())
.subscribe(conferencesWrapper -> {
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
ft.replace(R.id.fragment_container,browseFragment);
ft.setReorderingAllowed(true);
ft.commit();
}, throwable -> Snackbar.make(findViewById(R.id.fragment_container),throwable.getMessage(),Snackbar.LENGTH_INDEFINITE).show()));
}
}