fixed #185
This commit is contained in:
parent
6b02d12ea3
commit
67f7ed52c9
|
@ -1890,7 +1890,7 @@ public final class Utils implements Constants {
|
|||
final long[] messageIds = new long[accountIds.length];
|
||||
int idx = 0;
|
||||
for (final long accountId : accountIds) {
|
||||
final String where = Statuses.ACCOUNT_ID + " = " + accountId;
|
||||
final String where = Expression.equals(DirectMessages.ACCOUNT_ID, accountId).getSQL();
|
||||
final Cursor cur = ContentResolverUtils.query(resolver, uri, cols, where, null,
|
||||
DirectMessages.DEFAULT_SORT_ORDER);
|
||||
if (cur == null) {
|
||||
|
@ -1912,14 +1912,14 @@ public final class Utils implements Constants {
|
|||
return getNewestStatusIdsFromDatabase(context, uri, account_ids);
|
||||
}
|
||||
|
||||
public static long[] getNewestStatusIdsFromDatabase(final Context context, final Uri uri, final long[] account_ids) {
|
||||
if (context == null || uri == null || account_ids == null) return null;
|
||||
public static long[] getNewestStatusIdsFromDatabase(final Context context, final Uri uri, final long[] accountIds) {
|
||||
if (context == null || uri == null || accountIds == null) return null;
|
||||
final String[] cols = new String[]{Statuses.STATUS_ID};
|
||||
final ContentResolver resolver = context.getContentResolver();
|
||||
final long[] status_ids = new long[account_ids.length];
|
||||
final long[] status_ids = new long[accountIds.length];
|
||||
int idx = 0;
|
||||
for (final long account_id : account_ids) {
|
||||
final String where = Statuses.ACCOUNT_ID + " = " + account_id;
|
||||
for (final long accountId : accountIds) {
|
||||
final String where = Expression.equals(Statuses.ACCOUNT_ID, accountId).getSQL();
|
||||
final Cursor cur = ContentResolverUtils
|
||||
.query(resolver, uri, cols, where, null, Statuses.DEFAULT_SORT_ORDER);
|
||||
if (cur == null) {
|
||||
|
@ -1968,14 +1968,14 @@ public final class Utils implements Constants {
|
|||
return getOldestMessageIdsFromDatabase(context, uri, account_ids);
|
||||
}
|
||||
|
||||
public static long[] getOldestMessageIdsFromDatabase(final Context context, final Uri uri, final long[] account_ids) {
|
||||
public static long[] getOldestMessageIdsFromDatabase(final Context context, final Uri uri, final long[] accountIds) {
|
||||
if (context == null || uri == null) return null;
|
||||
final String[] cols = new String[]{DirectMessages.MESSAGE_ID};
|
||||
final ContentResolver resolver = context.getContentResolver();
|
||||
final long[] status_ids = new long[account_ids.length];
|
||||
final long[] status_ids = new long[accountIds.length];
|
||||
int idx = 0;
|
||||
for (final long account_id : account_ids) {
|
||||
final String where = Statuses.ACCOUNT_ID + " = " + account_id;
|
||||
for (final long accountId : accountIds) {
|
||||
final String where = Expression.equals(DirectMessages.ACCOUNT_ID, accountId).getSQL();
|
||||
final Cursor cur = ContentResolverUtils.query(resolver, uri, cols, where, null, DirectMessages.MESSAGE_ID);
|
||||
if (cur == null) {
|
||||
continue;
|
||||
|
@ -1996,14 +1996,14 @@ public final class Utils implements Constants {
|
|||
return getOldestStatusIdsFromDatabase(context, uri, account_ids);
|
||||
}
|
||||
|
||||
public static long[] getOldestStatusIdsFromDatabase(final Context context, final Uri uri, final long[] account_ids) {
|
||||
if (context == null || uri == null || account_ids == null) return null;
|
||||
public static long[] getOldestStatusIdsFromDatabase(final Context context, final Uri uri, final long[] accountIds) {
|
||||
if (context == null || uri == null || accountIds == null) return null;
|
||||
final String[] cols = new String[]{Statuses.STATUS_ID};
|
||||
final ContentResolver resolver = context.getContentResolver();
|
||||
final long[] status_ids = new long[account_ids.length];
|
||||
final long[] status_ids = new long[accountIds.length];
|
||||
int idx = 0;
|
||||
for (final long account_id : account_ids) {
|
||||
final String where = Statuses.ACCOUNT_ID + " = " + account_id;
|
||||
for (final long accountId : accountIds) {
|
||||
final String where = Expression.equals(Statuses.ACCOUNT_ID, accountId).getSQL();
|
||||
final Cursor cur = ContentResolverUtils.query(resolver, uri, cols, where, null, Statuses.STATUS_ID);
|
||||
if (cur == null) {
|
||||
continue;
|
||||
|
@ -2439,10 +2439,10 @@ public final class Utils implements Constants {
|
|||
status.retweeted_by_user_id, filter_rts);
|
||||
}
|
||||
|
||||
public static boolean isMyAccount(final Context context, final long account_id) {
|
||||
public static boolean isMyAccount(final Context context, final long accountId) {
|
||||
if (context == null) return false;
|
||||
final ContentResolver resolver = context.getContentResolver();
|
||||
final String where = Accounts.ACCOUNT_ID + " = " + account_id;
|
||||
final String where = Expression.equals(Accounts.ACCOUNT_ID, accountId).getSQL();
|
||||
final Cursor cur = ContentResolverUtils.query(resolver, Accounts.CONTENT_URI, new String[0], where, null, null);
|
||||
try {
|
||||
return cur != null && cur.getCount() > 0;
|
||||
|
@ -2456,7 +2456,7 @@ public final class Utils implements Constants {
|
|||
public static boolean isMyAccount(final Context context, final String screen_name) {
|
||||
if (context == null) return false;
|
||||
final ContentResolver resolver = context.getContentResolver();
|
||||
final String where = Accounts.SCREEN_NAME + " = ?";
|
||||
final String where = Expression.equalsArgs(Accounts.SCREEN_NAME).getSQL();
|
||||
final Cursor cur = ContentResolverUtils.query(resolver, Accounts.CONTENT_URI, new String[0], where,
|
||||
new String[]{screen_name}, null);
|
||||
try {
|
||||
|
@ -2472,8 +2472,8 @@ public final class Utils implements Constants {
|
|||
return status != null && isMyRetweet(status.account_id, status.retweeted_by_user_id, status.my_retweet_id);
|
||||
}
|
||||
|
||||
public static boolean isMyRetweet(final long account_id, final long retweeted_by_id, final long my_retweet_id) {
|
||||
return retweeted_by_id == account_id || my_retweet_id > 0;
|
||||
public static boolean isMyRetweet(final long accountId, final long retweetedById, final long myRetweetId) {
|
||||
return retweetedById == accountId || myRetweetId > 0;
|
||||
}
|
||||
|
||||
public static boolean isNetworkAvailable(final Context context) {
|
||||
|
@ -3241,7 +3241,7 @@ public final class Utils implements Constants {
|
|||
final boolean isMyRetweet = isMyRetweet(status);
|
||||
final MenuItem delete = menu.findItem(MENU_DELETE);
|
||||
if (delete != null) {
|
||||
delete.setVisible(status.account_id == status.user_id && !isMyRetweet);
|
||||
delete.setVisible(isMyStatus(status));
|
||||
}
|
||||
final MenuItem retweet = menu.findItem(MENU_RETWEET);
|
||||
if (retweet != null) {
|
||||
|
@ -3279,6 +3279,14 @@ public final class Utils implements Constants {
|
|||
|
||||
}
|
||||
|
||||
private static boolean isMyStatus(ParcelableStatus status) {
|
||||
if (isMyRetweet(status)) return true;
|
||||
if (status.is_quote) {
|
||||
return status.account_id == status.quoted_by_user_id;
|
||||
}
|
||||
return status.account_id == status.user_id;
|
||||
}
|
||||
|
||||
public static boolean shouldForceUsingPrivateAPIs(final Context context) {
|
||||
if (context == null) return false;
|
||||
final SharedPreferences prefs = context.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE);
|
||||
|
|
Loading…
Reference in New Issue