fixed crashes
This commit is contained in:
parent
7319655443
commit
c76e4421b0
|
@ -705,19 +705,23 @@ public class DataStoreUtils implements Constants {
|
||||||
return filterExpression;
|
return filterExpression;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int[] getAccountColors(final Context context, final UserKey[] accountKeys) {
|
@NonNull
|
||||||
if (context == null || accountKeys == null) return new int[0];
|
public static int[] getAccountColors(@NonNull final Context context, @NonNull final UserKey[] accountKeys) {
|
||||||
final String[] cols = new String[]{Accounts.ACCOUNT_KEY, Accounts.COLOR};
|
final String[] cols = new String[]{Accounts.ACCOUNT_KEY, Accounts.COLOR};
|
||||||
final String where = Expression.inArgs(new Column(Accounts.ACCOUNT_KEY), accountKeys.length).getSQL();
|
final String where = Expression.inArgs(new Column(Accounts.ACCOUNT_KEY), accountKeys.length).getSQL();
|
||||||
final String[] whereArgs = TwidereArrayUtils.toStringArray(accountKeys);
|
final String[] whereArgs = TwidereArrayUtils.toStringArray(accountKeys);
|
||||||
|
final int[] colors = new int[accountKeys.length];
|
||||||
final Cursor cur = context.getContentResolver().query(Accounts.CONTENT_URI, cols, where,
|
final Cursor cur = context.getContentResolver().query(Accounts.CONTENT_URI, cols, where,
|
||||||
whereArgs, null);
|
whereArgs, null);
|
||||||
if (cur == null) return new int[0];
|
if (cur == null) return colors;
|
||||||
try {
|
try {
|
||||||
final int[] colors = new int[cur.getCount()];
|
cur.moveToFirst();
|
||||||
for (int i = 0, j = cur.getCount(); i < j; i++) {
|
while (!cur.isAfterLast()) {
|
||||||
cur.moveToPosition(i);
|
final int idx = ArrayUtils.indexOf(accountKeys, UserKey.valueOf(cur.getString(0)));
|
||||||
colors[ArrayUtils.indexOf(accountKeys, cur.getLong(0))] = cur.getInt(1);
|
if (idx >= 0) {
|
||||||
|
colors[idx] = cur.getInt(1);
|
||||||
|
}
|
||||||
|
cur.moveToNext();
|
||||||
}
|
}
|
||||||
return colors;
|
return colors;
|
||||||
} finally {
|
} finally {
|
||||||
|
|
|
@ -77,7 +77,11 @@ class DraftsAdapter(context: Context) : SimpleCursorAdapter(context, R.layout.li
|
||||||
holder.media_preview_container.visibility = View.GONE
|
holder.media_preview_container.visibility = View.GONE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
holder.content.drawEnd(*DataStoreUtils.getAccountColors(context, accountKeys))
|
if (accountKeys != null) {
|
||||||
|
holder.content.drawEnd(*DataStoreUtils.getAccountColors(context, accountKeys))
|
||||||
|
} else {
|
||||||
|
holder.content.drawEnd()
|
||||||
|
}
|
||||||
holder.setTextSize(mTextSize)
|
holder.setTextSize(mTextSize)
|
||||||
val emptyContent = TextUtils.isEmpty(text)
|
val emptyContent = TextUtils.isEmpty(text)
|
||||||
if (emptyContent) {
|
if (emptyContent) {
|
||||||
|
|
Loading…
Reference in New Issue