1
0
mirror of https://github.com/TwidereProject/Twidere-Android synced 2025-02-07 23:38:40 +01:00

bug fixes

This commit is contained in:
Mariotaku Lee 2016-03-20 13:06:31 +08:00
parent 7d83d65724
commit 5a4d2ac87d
7 changed files with 31 additions and 18 deletions

View File

@ -36,6 +36,7 @@ import android.widget.ListView;
import android.widget.Toast;
import org.apache.commons.lang3.ArrayUtils;
import org.mariotaku.sqliteqb.library.Expression;
import org.mariotaku.twidere.R;
import org.mariotaku.twidere.adapter.AccountsAdapter;
import org.mariotaku.twidere.model.ParcelableAccount;
@ -97,8 +98,16 @@ public class AccountSelectorActivity extends BaseActivity implements
@Override
public Loader<Cursor> onCreateLoader(final int id, final Bundle args) {
final String where = isOAuthOnly() ? Accounts.AUTH_TYPE + " = " + ParcelableCredentials.AUTH_TYPE_OAUTH : null;
return new CursorLoader(this, Accounts.CONTENT_URI, Accounts.COLUMNS, where, null, null);
final String where;
final String[] whereArgs;
if (isOAuthOnly()) {
where = Expression.equalsArgs(Accounts.AUTH_TYPE).getSQL();
whereArgs = new String[]{String.valueOf(ParcelableCredentials.AUTH_TYPE_OAUTH)};
} else {
where = null;
whereArgs = null;
}
return new CursorLoader(this, Accounts.CONTENT_URI, Accounts.COLUMNS, where, whereArgs, null);
}
@Override

View File

@ -34,6 +34,7 @@ import org.mariotaku.twidere.model.DraftCursorIndices;
import org.mariotaku.twidere.model.ParcelableMedia;
import org.mariotaku.twidere.model.ParcelableMediaUpdate;
import org.mariotaku.twidere.model.util.ParcelableMediaUtils;
import org.mariotaku.twidere.model.util.UserKeyUtils;
import org.mariotaku.twidere.util.DataStoreUtils;
import org.mariotaku.twidere.util.JsonSerializer;
import org.mariotaku.twidere.util.MediaLoaderWrapper;

View File

@ -10,17 +10,17 @@ import com.bluelinelabs.logansquare.annotation.JsonObject;
public class DeletionEvent {
@JsonField(name = "id")
long id;
String id;
@JsonField(name = "user_id")
long userId;
String userId;
@JsonField(name = "timestamp_ms")
long timestampMs;
public long getId() {
public String getId() {
return id;
}
public long getUserId() {
public String getUserId() {
return userId;
}

View File

@ -849,7 +849,7 @@ public final class TwidereDataProvider extends ContentProvider implements Consta
final Expression usersSelection = Expression.or(
Expression.likeRaw(new Column(CachedUsers.SCREEN_NAME), "?||'%'", "^"),
Expression.likeRaw(new Column(CachedUsers.NAME), "?||'%'", "^"),
Expression.in(new Column(CachedUsers.USER_KEY), new RawItemArray(nicknameKeys)));
Expression.inArgs(new Column(CachedUsers.USER_KEY), nicknameKeys.length));
final String[] selectionArgs = new String[nicknameKeys.length + 2];
selectionArgs[0] = selectionArgs[1] = queryTrimmed;
System.arraycopy(nicknameKeys, 0, selectionArgs, 2, nicknameKeys.length);

View File

@ -226,17 +226,20 @@ public class StreamingService extends Service implements Constants {
@Override
public void onDirectMessageDeleted(final DeletionEvent event) {
final String where = Expression.equals(DirectMessages.MESSAGE_ID, event.getId()).getSQL();
final String where = Expression.equalsArgs(DirectMessages.MESSAGE_ID).getSQL();
final String[] whereArgs = {event.getId()};
for (final Uri uri : MESSAGES_URIS) {
resolver.delete(uri, where, null);
resolver.delete(uri, where, whereArgs);
}
}
@Override
public void onStatusDeleted(final DeletionEvent event) {
final long statusId = event.getId();
resolver.delete(Statuses.CONTENT_URI, Expression.equals(Statuses.STATUS_ID, statusId).getSQL(), null);
resolver.delete(Activities.AboutMe.CONTENT_URI, Expression.equals(Activities.AboutMe.STATUS_ID, statusId).getSQL(), null);
final String statusId = event.getId();
resolver.delete(Statuses.CONTENT_URI, Expression.equalsArgs(Statuses.STATUS_ID).getSQL(),
new String[]{statusId});
resolver.delete(Activities.AboutMe.CONTENT_URI, Expression.equalsArgs(Activities.STATUS_ID).getSQL(),
new String[]{statusId});
}
@Override

View File

@ -1307,8 +1307,8 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
values.put(Statuses.RETWEET_COUNT, status.retweet_count - 1);
}
for (final Uri uri : TwidereDataStore.STATUSES_URIS) {
mResolver.delete(uri, Statuses.STATUS_ID + " = " + mStatusId, null);
mResolver.update(uri, values, Statuses.MY_RETWEET_ID + " = " + mStatusId, null);
mResolver.delete(uri, Expression.equalsArgs(Statuses.STATUS_ID).getSQL(), new String[]{mStatusId});
mResolver.update(uri, values, Expression.equalsArgs(Statuses.MY_RETWEET_ID).getSQL(), new String[]{mStatusId});
}
}
return SingleResponse.getInstance(status, exception);

View File

@ -163,23 +163,23 @@ public class TwidereQueryBuilder {
}
public static Pair<SQLSelectQuery, String[]> byScreenName(final String[] projection, final UserKey accountKey,
final String screen_name, final String selection, final String sortOrder) {
final String screenName, final String selection, final String sortOrder) {
final Selectable select = Utils.getColumnsFromProjection(projection);
final SQLSelectQuery.Builder qb = SQLQueryBuilder.select(select);
qb.select(select);
qb.from(new Tables(DirectMessages.TABLE_NAME));
final Expression accountIdWhere = Expression.equalsArgs(DirectMessages.ACCOUNT_KEY);
final Expression incomingWhere = Expression.and(Expression.notEquals(DirectMessages.IS_OUTGOING, 1),
Expression.equals(new Column(DirectMessages.SENDER_SCREEN_NAME), screen_name));
Expression.equalsArgs(DirectMessages.SENDER_SCREEN_NAME));
final Expression outgoingWhere = Expression.and(Expression.equals(DirectMessages.IS_OUTGOING, 1),
Expression.equals(new Column(DirectMessages.RECIPIENT_SCREEN_NAME), screen_name));
Expression.equalsArgs(DirectMessages.RECIPIENT_SCREEN_NAME));
if (selection != null) {
qb.where(Expression.and(accountIdWhere, incomingWhere, outgoingWhere, new Expression(selection)));
} else {
qb.where(Expression.and(accountIdWhere, incomingWhere, outgoingWhere));
}
qb.orderBy(new OrderBy(sortOrder != null ? sortOrder : Conversation.DEFAULT_SORT_ORDER));
return Pair.create(qb.build(), new String[]{accountKey.toString()});
return Pair.create(qb.build(), new String[]{accountKey.toString(), screenName, screenName});
}
}