Handling update events in feed subscriptions, removed updated time in subscription view

This commit is contained in:
Raghul 2015-07-08 11:11:52 +08:00
parent 9e09ad247b
commit b4a363cece
3 changed files with 35 additions and 14 deletions

View File

@ -550,7 +550,7 @@ public class MainActivity extends ActionBarActivity implements NavDrawerActivity
String lastFragment = getLastNavFragment();
if(!ArrayUtils.contains(NAV_DRAWER_TAGS, lastFragment)) {
long feedId = Long.valueOf(lastFragment);
//loadFeedFragmentById(feedId);
loadFeedFragmentById(feedId);
saveLastNavFragment(null);
}

View File

@ -15,6 +15,7 @@ import de.danoeh.antennapod.R;
import de.danoeh.antennapod.activity.MainActivity;
import de.danoeh.antennapod.adapter.NavListAdapter;
import de.danoeh.antennapod.adapter.SubscriptionsAdapter;
import de.danoeh.antennapod.core.feed.EventDistributor;
import de.danoeh.antennapod.core.feed.Feed;
import de.danoeh.antennapod.core.storage.DBReader;
import de.greenrobot.event.EventBus;
@ -64,17 +65,7 @@ public class SubscriptionFragment extends Fragment {
mSubscriptionAdapter = new SubscriptionsAdapter(getActivity(), mItemAccess);
mSubscriptionGridLayout.setAdapter(mSubscriptionAdapter);
Observable.just(loadData()).subscribe(new Action1<DBReader.NavDrawerData>() {
@Override
public void call(DBReader.NavDrawerData navDrawerData) {
mDrawerData = navDrawerData;
mSubscriptionList = mDrawerData.feeds;
mSubscriptionAdapter.setItemAccess(mItemAccess);
mSubscriptionAdapter.notifyDataSetChanged();
}
});
refreshSubscriptionList();
mSubscriptionGridLayout.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
@ -88,9 +79,38 @@ public class SubscriptionFragment extends Fragment {
}
private void refreshSubscriptionList() {
Observable.just(loadData()).subscribe(new Action1<DBReader.NavDrawerData>() {
@Override
public void call(DBReader.NavDrawerData navDrawerData) {
mDrawerData = navDrawerData;
mSubscriptionList = mDrawerData.feeds;
mSubscriptionAdapter.setItemAccess(mItemAccess);
mSubscriptionAdapter.notifyDataSetChanged();
}
});
}
EventDistributor.EventListener updateListener = new EventDistributor.EventListener() {
@Override
public void update(EventDistributor eventDistributor, Integer arg) {
if ((arg & EventDistributor.FEED_LIST_UPDATE) != 0) {
refreshSubscriptionList();
}
}
};
@Override
public void onStop() {
super.onStop();
EventDistributor.getInstance().unregister(updateListener);
}
@Override
public void onResume() {
super.onResume();
EventDistributor.getInstance().register(updateListener);
}
public class SubscriptionEvent {

View File

@ -13,7 +13,6 @@ import com.squareup.picasso.Picasso;
import de.danoeh.antennapod.R;
import de.danoeh.antennapod.core.feed.Feed;
import de.danoeh.antennapod.utils.TimeUtils;
/**
* Custom view for handling feed item.
@ -72,7 +71,9 @@ public class SubscriptionViewItem extends RelativeLayout {
}
});
mUnreadCountText.setText(unreadCount + "");
mTextTime.setText(TimeUtils.getTimeAgo(feed.getLastUpdate().getTime(), mContext));
// Removing the updated time. It could be the latest podcast updated time in the future.
//mTextTime.setText(TimeUtils.getTimeAgo(feed.getLastUpdate().getTime(), mContext));
mTextTime.setVisibility(GONE);
}
}