Add subscription counter
This commit is contained in:
parent
ab88df91ba
commit
09d22b8ede
|
@ -537,6 +537,18 @@ public class AudioplayerActivity extends MediaplayerActivity implements NavDrawe
|
|||
public int getFeedCounter(long feedId) {
|
||||
return navDrawerData != null ? navDrawerData.feedCounters.get(feedId) : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFeedCounterSum() {
|
||||
if(navDrawerData == null) {
|
||||
return 0;
|
||||
}
|
||||
int sum = 0;
|
||||
for(int counter : navDrawerData.feedCounters.values()) {
|
||||
sum += counter;
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
};
|
||||
|
||||
public interface AudioplayerContentFragment {
|
||||
|
|
|
@ -654,6 +654,18 @@ public class MainActivity extends AppCompatActivity implements NavDrawerActivity
|
|||
return navDrawerData != null ? navDrawerData.feedCounters.get(feedId) : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFeedCounterSum() {
|
||||
if(navDrawerData == null) {
|
||||
return 0;
|
||||
}
|
||||
int sum = 0;
|
||||
for(int counter : navDrawerData.feedCounters.values()) {
|
||||
sum += counter;
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
private void loadData() {
|
||||
|
|
|
@ -19,7 +19,6 @@ import com.bumptech.glide.Glide;
|
|||
import com.joanzapata.iconify.Iconify;
|
||||
import com.joanzapata.iconify.widget.IconTextView;
|
||||
|
||||
import de.danoeh.antennapod.fragment.SubscriptionFragment;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -39,6 +38,7 @@ import de.danoeh.antennapod.fragment.EpisodesFragment;
|
|||
import de.danoeh.antennapod.fragment.NewEpisodesFragment;
|
||||
import de.danoeh.antennapod.fragment.PlaybackHistoryFragment;
|
||||
import de.danoeh.antennapod.fragment.QueueFragment;
|
||||
import de.danoeh.antennapod.fragment.SubscriptionFragment;
|
||||
|
||||
/**
|
||||
* BaseAdapter for the navigation drawer
|
||||
|
@ -253,6 +253,14 @@ public class NavListAdapter extends BaseAdapter
|
|||
} else {
|
||||
holder.count.setVisibility(View.GONE);
|
||||
}
|
||||
} else if (tag.equals(SubscriptionFragment.TAG)) {
|
||||
int sum = itemAccess.getFeedCounterSum();
|
||||
if (sum > 0) {
|
||||
holder.count.setVisibility(View.VISIBLE);
|
||||
holder.count.setText(String.valueOf(sum));
|
||||
} else {
|
||||
holder.count.setVisibility(View.GONE);
|
||||
}
|
||||
} else if(tag.equals(DownloadsFragment.TAG) && UserPreferences.isEnableAutodownload()) {
|
||||
int epCacheSize = UserPreferences.getEpisodeCacheSize();
|
||||
// don't count episodes that can be reclaimed
|
||||
|
@ -372,6 +380,7 @@ public class NavListAdapter extends BaseAdapter
|
|||
int getNumberOfDownloadedItems();
|
||||
int getReclaimableItems();
|
||||
int getFeedCounter(long feedId);
|
||||
int getFeedCounterSum();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package de.danoeh.antennapod.core.util;
|
||||
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* Fast and memory efficient long to long map
|
||||
*/
|
||||
|
@ -197,6 +199,15 @@ public class LongIntMap {
|
|||
size = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a copy of the values contained in this map.
|
||||
*
|
||||
* @return a copy of the values contained in this map
|
||||
*/
|
||||
public int[] values() {
|
||||
return Arrays.copyOf(values, size);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
if (other == this) {
|
||||
|
|
Loading…
Reference in New Issue