Remove AccountStats
This commit is contained in:
parent
f0dabcc516
commit
347d33849c
4 changed files with 9 additions and 30 deletions
|
@ -1,14 +0,0 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package com.fsck.k9;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class AccountStats implements Serializable {
|
||||
private static final long serialVersionUID = -5706839923710842234L;
|
||||
public long size = -1;
|
||||
public int unreadMessageCount = 0;
|
||||
public int flaggedMessageCount = 0;
|
||||
public boolean available = true;
|
||||
}
|
|
@ -33,8 +33,7 @@ internal class DefaultUnreadMessageCountProvider(
|
|||
accountSearchConditions.excludeSpecialFolders(account, search)
|
||||
accountSearchConditions.limitToDisplayableFolders(account, search)
|
||||
|
||||
val accountStats = localStore.getAccountStats(search)
|
||||
accountStats.unreadMessageCount
|
||||
localStore.getUnreadMessageCount(search)
|
||||
} catch (e: MessagingException) {
|
||||
Timber.e(e, "Unable to getUnreadMessageCount for account: %s", account)
|
||||
0
|
||||
|
@ -56,8 +55,7 @@ internal class DefaultUnreadMessageCountProvider(
|
|||
private fun getUnreadMessageCountWithLocalSearch(account: Account, search: LocalSearch): Int {
|
||||
return try {
|
||||
val localStore = localStoreProvider.getInstance(account)
|
||||
val accountStats = localStore.getAccountStats(search)
|
||||
accountStats.unreadMessageCount
|
||||
localStore.getUnreadMessageCount(search)
|
||||
} catch (e: MessagingException) {
|
||||
Timber.e(e, "Unable to getUnreadMessageCount for account: %s", account)
|
||||
0
|
||||
|
|
|
@ -28,7 +28,6 @@ import androidx.annotation.Nullable;
|
|||
import android.text.TextUtils;
|
||||
|
||||
import com.fsck.k9.Account;
|
||||
import com.fsck.k9.AccountStats;
|
||||
import com.fsck.k9.Clock;
|
||||
import com.fsck.k9.DI;
|
||||
import com.fsck.k9.K9;
|
||||
|
@ -1293,7 +1292,7 @@ public class LocalStore {
|
|||
return folderMap;
|
||||
}
|
||||
|
||||
public AccountStats getAccountStats(LocalSearch search) throws MessagingException {
|
||||
public int getUnreadMessageCount(LocalSearch search) throws MessagingException {
|
||||
StringBuilder whereBuilder = new StringBuilder();
|
||||
List<String> queryArgs = new ArrayList<>();
|
||||
SqlQueryBuilder.buildWhereClause(account, search.getConditions(), whereBuilder, queryArgs);
|
||||
|
@ -1301,24 +1300,22 @@ public class LocalStore {
|
|||
String where = whereBuilder.toString();
|
||||
final String[] selectionArgs = queryArgs.toArray(new String[queryArgs.size()]);
|
||||
|
||||
final String sqlQuery = "SELECT SUM(read=0), SUM(flagged) " +
|
||||
final String sqlQuery = "SELECT SUM(read=0) " +
|
||||
"FROM messages " +
|
||||
"JOIN folders ON (folders.id = messages.folder_id) " +
|
||||
"WHERE (messages.empty = 0 AND messages.deleted = 0)" +
|
||||
(!TextUtils.isEmpty(where) ? " AND (" + where + ")" : "");
|
||||
|
||||
return database.execute(false, new DbCallback<AccountStats>() {
|
||||
return database.execute(false, new DbCallback<Integer>() {
|
||||
@Override
|
||||
public AccountStats doDbWork(SQLiteDatabase db) throws WrappedException, MessagingException {
|
||||
public Integer doDbWork(SQLiteDatabase db) throws WrappedException, MessagingException {
|
||||
Cursor cursor = db.rawQuery(sqlQuery, selectionArgs);
|
||||
try {
|
||||
AccountStats accountStats = new AccountStats();
|
||||
if (cursor.moveToFirst()) {
|
||||
accountStats.unreadMessageCount = cursor.getInt(0);
|
||||
accountStats.flaggedMessageCount = cursor.getInt(1);
|
||||
return cursor.getInt(0);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return accountStats;
|
||||
} finally {
|
||||
cursor.close();
|
||||
}
|
||||
|
|
|
@ -36,7 +36,6 @@ import android.os.Bundle;
|
|||
import android.provider.BaseColumns;
|
||||
|
||||
import com.fsck.k9.Account;
|
||||
import com.fsck.k9.AccountStats;
|
||||
import com.fsck.k9.BuildConfig;
|
||||
import com.fsck.k9.DI;
|
||||
import com.fsck.k9.Preferences;
|
||||
|
@ -45,7 +44,6 @@ import com.fsck.k9.controller.MessagingController;
|
|||
import com.fsck.k9.controller.SimpleMessagingListener;
|
||||
import com.fsck.k9.mail.Flag;
|
||||
import com.fsck.k9.mail.Message;
|
||||
import com.fsck.k9.mail.MessagingException;
|
||||
import com.fsck.k9.mailstore.LocalMessage;
|
||||
import com.fsck.k9.search.SearchAccount;
|
||||
import timber.log.Timber;
|
||||
|
|
Loading…
Reference in a new issue