don't query DB from the UI thread\!
This commit is contained in:
parent
79b5328ecf
commit
000633f60c
|
@ -517,6 +517,11 @@ public class AudioplayerActivity extends MediaplayerActivity implements NavDrawe
|
|||
return (navDrawerData != null) ? navDrawerData.numDownloadedItems : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getReclaimableItems() {
|
||||
return (navDrawerData != null) ? navDrawerData.reclaimableSpace : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFeedCounter(long feedId) {
|
||||
return navDrawerData != null ? navDrawerData.feedCounters.get(feedId) : 0;
|
||||
|
|
|
@ -643,11 +643,15 @@ public class MainActivity extends AppCompatActivity implements NavDrawerActivity
|
|||
return (navDrawerData != null) ? navDrawerData.numDownloadedItems : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getReclaimableItems() {
|
||||
return (navDrawerData != null) ? navDrawerData.reclaimableSpace : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFeedCounter(long feedId) {
|
||||
return navDrawerData != null ? navDrawerData.feedCounters.get(feedId) : 0;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
private void loadData() {
|
||||
|
|
|
@ -228,9 +228,10 @@ public class NavListAdapter extends BaseAdapter
|
|||
}
|
||||
} else if(tag.equals(DownloadsFragment.TAG) && UserPreferences.isEnableAutodownload()) {
|
||||
int epCacheSize = UserPreferences.getEpisodeCacheSize();
|
||||
// don't count episodes that we could delete when autodownloading
|
||||
// don't count episodes that can be reclaimed
|
||||
int spaceUsed = itemAccess.getNumberOfDownloadedItems() -
|
||||
UserPreferences.getEpisodeCleanupAlgorithm().getAvailableSpace();
|
||||
itemAccess.getReclaimableItems();
|
||||
|
||||
if (spaceUsed >= epCacheSize) {
|
||||
holder.count.setText("{md-disc-full 150%}");
|
||||
Iconify.addIcons(holder.count);
|
||||
|
@ -338,6 +339,7 @@ public class NavListAdapter extends BaseAdapter
|
|||
int getQueueSize();
|
||||
int getNumberOfNewItems();
|
||||
int getNumberOfDownloadedItems();
|
||||
int getReclaimableItems();
|
||||
int getFeedCounter(long feedId);
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ public class APCleanupAlgorithm extends EpisodeCleanupAlgorithm {
|
|||
/**
|
||||
* @return the number of episodes that *could* be cleaned up, if needed
|
||||
*/
|
||||
public int getAvailableSpace()
|
||||
public int getReclaimableItems()
|
||||
{
|
||||
return getCandidates().size();
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ public class APNullCleanupAlgorithm extends EpisodeCleanupAlgorithm {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int getAvailableSpace() {
|
||||
public int getReclaimableItems() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ public class APQueueCleanupAlgorithm extends EpisodeCleanupAlgorithm {
|
|||
/**
|
||||
* @return the number of episodes that *could* be cleaned up, if needed
|
||||
*/
|
||||
public int getAvailableSpace()
|
||||
public int getReclaimableItems()
|
||||
{
|
||||
return getCandidates().size();
|
||||
}
|
||||
|
|
|
@ -1017,7 +1017,8 @@ public final class DBReader {
|
|||
int numNewItems = adapter.getNumberOfNewItems();
|
||||
int numDownloadedItems = adapter.getNumberOfDownloadedEpisodes();
|
||||
|
||||
NavDrawerData result = new NavDrawerData(feeds, queueSize, numNewItems, numDownloadedItems, feedCounters);
|
||||
NavDrawerData result = new NavDrawerData(feeds, queueSize, numNewItems, numDownloadedItems,
|
||||
feedCounters, UserPreferences.getEpisodeCleanupAlgorithm().getReclaimableItems());
|
||||
adapter.close();
|
||||
return result;
|
||||
}
|
||||
|
@ -1028,17 +1029,20 @@ public final class DBReader {
|
|||
public int numNewItems;
|
||||
public int numDownloadedItems;
|
||||
public LongIntMap feedCounters;
|
||||
public int reclaimableSpace;
|
||||
|
||||
public NavDrawerData(List<Feed> feeds,
|
||||
int queueSize,
|
||||
int numNewItems,
|
||||
int numDownloadedItems,
|
||||
LongIntMap feedIndicatorValues) {
|
||||
LongIntMap feedIndicatorValues,
|
||||
int reclaimableSpace) {
|
||||
this.feeds = feeds;
|
||||
this.queueSize = queueSize;
|
||||
this.numNewItems = numNewItems;
|
||||
this.numDownloadedItems = numDownloadedItems;
|
||||
this.feedCounters = feedIndicatorValues;
|
||||
this.reclaimableSpace = reclaimableSpace;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,9 +40,9 @@ public abstract class EpisodeCleanupAlgorithm {
|
|||
}
|
||||
|
||||
/**
|
||||
* @return the number of episodes that *could* be cleaned up, if needed
|
||||
* @return the number of episodes/items that *could* be cleaned up, if needed
|
||||
*/
|
||||
public abstract int getAvailableSpace();
|
||||
public abstract int getReclaimableItems();
|
||||
|
||||
/**
|
||||
* @param amountOfRoomNeeded the number of episodes we want to download
|
||||
|
|
Loading…
Reference in New Issue