Merge pull request #1857 from mfietz/issue/1850-subscriptions-counter
Subscription counter
This commit is contained in:
commit
9b563c1c87
|
@ -537,6 +537,18 @@ public class AudioplayerActivity extends MediaplayerActivity implements NavDrawe
|
||||||
public int getFeedCounter(long feedId) {
|
public int getFeedCounter(long feedId) {
|
||||||
return navDrawerData != null ? navDrawerData.feedCounters.get(feedId) : 0;
|
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 {
|
public interface AudioplayerContentFragment {
|
||||||
|
|
|
@ -654,6 +654,18 @@ public class MainActivity extends AppCompatActivity implements NavDrawerActivity
|
||||||
return navDrawerData != null ? navDrawerData.feedCounters.get(feedId) : 0;
|
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() {
|
private void loadData() {
|
||||||
|
|
|
@ -19,7 +19,6 @@ import com.bumptech.glide.Glide;
|
||||||
import com.joanzapata.iconify.Iconify;
|
import com.joanzapata.iconify.Iconify;
|
||||||
import com.joanzapata.iconify.widget.IconTextView;
|
import com.joanzapata.iconify.widget.IconTextView;
|
||||||
|
|
||||||
import de.danoeh.antennapod.fragment.SubscriptionFragment;
|
|
||||||
import org.apache.commons.lang3.ArrayUtils;
|
import org.apache.commons.lang3.ArrayUtils;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
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.NewEpisodesFragment;
|
||||||
import de.danoeh.antennapod.fragment.PlaybackHistoryFragment;
|
import de.danoeh.antennapod.fragment.PlaybackHistoryFragment;
|
||||||
import de.danoeh.antennapod.fragment.QueueFragment;
|
import de.danoeh.antennapod.fragment.QueueFragment;
|
||||||
|
import de.danoeh.antennapod.fragment.SubscriptionFragment;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* BaseAdapter for the navigation drawer
|
* BaseAdapter for the navigation drawer
|
||||||
|
@ -253,6 +253,14 @@ public class NavListAdapter extends BaseAdapter
|
||||||
} else {
|
} else {
|
||||||
holder.count.setVisibility(View.GONE);
|
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()) {
|
} else if(tag.equals(DownloadsFragment.TAG) && UserPreferences.isEnableAutodownload()) {
|
||||||
int epCacheSize = UserPreferences.getEpisodeCacheSize();
|
int epCacheSize = UserPreferences.getEpisodeCacheSize();
|
||||||
// don't count episodes that can be reclaimed
|
// don't count episodes that can be reclaimed
|
||||||
|
@ -372,6 +380,7 @@ public class NavListAdapter extends BaseAdapter
|
||||||
int getNumberOfDownloadedItems();
|
int getNumberOfDownloadedItems();
|
||||||
int getReclaimableItems();
|
int getReclaimableItems();
|
||||||
int getFeedCounter(long feedId);
|
int getFeedCounter(long feedId);
|
||||||
|
int getFeedCounterSum();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package de.danoeh.antennapod.core.util;
|
package de.danoeh.antennapod.core.util;
|
||||||
|
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fast and memory efficient long to long map
|
* Fast and memory efficient long to long map
|
||||||
*/
|
*/
|
||||||
|
@ -197,6 +199,15 @@ public class LongIntMap {
|
||||||
size = 0;
|
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
|
@Override
|
||||||
public boolean equals(Object other) {
|
public boolean equals(Object other) {
|
||||||
if (other == this) {
|
if (other == this) {
|
||||||
|
|
Loading…
Reference in New Issue