Merge pull request #2021 from mfietz/fix-subscriptions

Fix subscription view loading
This commit is contained in:
Martin Fietz 2016-06-19 18:32:37 +02:00 committed by GitHub
commit ca20b1e403
2 changed files with 19 additions and 2 deletions

View File

@ -107,6 +107,10 @@ public class SubscriptionsAdapter extends BaseAdapter implements AdapterView.OnI
holder.count.setPrimaryText(""); holder.count.setPrimaryText("");
// make it go away, we don't need it for add feed // make it go away, we don't need it for add feed
holder.count.setVisibility(View.INVISIBLE); holder.count.setVisibility(View.INVISIBLE);
// when this holder is reused, we could else end up with a cover image
Glide.clear(holder.imageView);
return convertView; return convertView;
} }
@ -135,7 +139,7 @@ public class SubscriptionsAdapter extends BaseAdapter implements AdapterView.OnI
@Override @Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) { public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
if (position == ADD_POSITION) { if (position == getAddTilePosition()) {
mainActivityRef.get().loadChildFragment(new AddFeedFragment()); mainActivityRef.get().loadChildFragment(new AddFeedFragment());
} else { } else {
Fragment fragment = ItemlistFragment.newInstance(getItemId(position)); Fragment fragment = ItemlistFragment.newInstance(getItemId(position));

View File

@ -27,6 +27,7 @@ import de.danoeh.antennapod.core.storage.DBReader;
import de.danoeh.antennapod.core.storage.DBWriter; import de.danoeh.antennapod.core.storage.DBWriter;
import de.danoeh.antennapod.core.util.FeedItemUtil; import de.danoeh.antennapod.core.util.FeedItemUtil;
import rx.Observable; import rx.Observable;
import rx.Subscription;
import rx.android.schedulers.AndroidSchedulers; import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers; import rx.schedulers.Schedulers;
@ -46,6 +47,7 @@ public class SubscriptionFragment extends Fragment {
private int mPosition = -1; private int mPosition = -1;
private Subscription subscription;
public SubscriptionFragment() { public SubscriptionFragment() {
} }
@ -88,8 +90,19 @@ public class SubscriptionFragment extends Fragment {
EventDistributor.getInstance().register(contentUpdate); EventDistributor.getInstance().register(contentUpdate);
} }
@Override
public void onDestroy() {
super.onDestroy();
if(subscription != null) {
subscription.unsubscribe();
}
}
private void loadSubscriptions() { private void loadSubscriptions() {
Observable.fromCallable(() -> DBReader.getNavDrawerData()) if(subscription != null) {
subscription.unsubscribe();
}
subscription = Observable.fromCallable(() -> DBReader.getNavDrawerData())
.subscribeOn(Schedulers.newThread()) .subscribeOn(Schedulers.newThread())
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.subscribe(result -> { .subscribe(result -> {