mirror of
https://github.com/TwidereProject/Twidere-Android
synced 2025-02-17 04:00:48 +01:00
fixed null pointer problems
This commit is contained in:
parent
fbaf4dd0da
commit
d45a5722b6
@ -78,7 +78,7 @@ public class SavedSearchesAdapter extends BaseAdapter {
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public boolean removeItem(UserKey accountId, long searchId) {
|
||||
public boolean removeItem(UserKey accountKey, long searchId) {
|
||||
if (mData == null) return false;
|
||||
for (int i = 0, mDataSize = mData.size(); i < mDataSize; i++) {
|
||||
SavedSearch search = mData.get(i);
|
||||
|
@ -53,7 +53,7 @@ public class AccountToggleProvider extends ActionProvider implements TwidereCons
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public UserKey[] getActivatedAccountIds() {
|
||||
public UserKey[] getActivatedAccountKeys() {
|
||||
if (mAccounts == null) return new UserKey[0];
|
||||
UserKey[] temp = new UserKey[mAccounts.length];
|
||||
int len = 0;
|
||||
@ -110,10 +110,10 @@ public class AccountToggleProvider extends ActionProvider implements TwidereCons
|
||||
}
|
||||
}
|
||||
|
||||
public void setAccountActivated(UserKey accountId, boolean isChecked) {
|
||||
public void setAccountActivated(@NonNull UserKey accountKey, boolean isChecked) {
|
||||
if (mAccounts == null) return;
|
||||
for (final AccountDetails account : mAccounts) {
|
||||
if (account.key == accountId) {
|
||||
if (accountKey.equals(account.key)) {
|
||||
account.activated = isChecked;
|
||||
}
|
||||
}
|
||||
|
@ -75,8 +75,10 @@ public class FriendshipTaskEvent {
|
||||
return "FriendshipTaskEvent{" +
|
||||
"action=" + action +
|
||||
", finished=" + finished +
|
||||
", mAccountKey=" + accountKey +
|
||||
", userId=" + userKey +
|
||||
", succeeded=" + succeeded +
|
||||
", accountKey=" + accountKey +
|
||||
", userKey=" + userKey +
|
||||
", user=" + user +
|
||||
'}';
|
||||
}
|
||||
|
||||
|
@ -186,7 +186,7 @@ public class CustomTabUtils implements Constants {
|
||||
return TabConfiguration.ofType(Tab.getTypeAlias(tabType)) != null;
|
||||
}
|
||||
|
||||
public static boolean hasAccountId(final Context context, @NonNull final Bundle args,
|
||||
public static boolean hasAccountKey(final Context context, @NonNull final Bundle args,
|
||||
final UserKey[] activatedAccountKeys, UserKey accountKey) {
|
||||
final UserKey[] accountKeys = Utils.getAccountKeys(context, args);
|
||||
if (accountKeys != null) {
|
||||
|
@ -30,7 +30,7 @@ import java.util.List;
|
||||
public class MultiSelectManager {
|
||||
|
||||
private final NoDuplicatesArrayList<String> mSelectedStatusIds = new NoDuplicatesArrayList<>();
|
||||
private final NoDuplicatesArrayList<UserKey> mSelectedUserIds = new NoDuplicatesArrayList<>();
|
||||
private final NoDuplicatesArrayList<UserKey> mSelectedUserKeys = new NoDuplicatesArrayList<>();
|
||||
private final NoDuplicatesArrayList<Callback> mCallbacks = new NoDuplicatesArrayList<>();
|
||||
private final ItemsList mSelectedItems = new ItemsList(this);
|
||||
private UserKey mAccountKey;
|
||||
@ -69,7 +69,7 @@ public class MultiSelectManager {
|
||||
}
|
||||
|
||||
public boolean isUserSelected(final UserKey userKey) {
|
||||
return mSelectedUserIds.contains(userKey);
|
||||
return mSelectedUserKeys.contains(userKey);
|
||||
}
|
||||
|
||||
public void registerCallback(final Callback callback) {
|
||||
@ -124,7 +124,7 @@ public class MultiSelectManager {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static UserKey[] getSelectedUserIds(final List<Object> selectedItems) {
|
||||
public static UserKey[] getSelectedUserKeys(final List<Object> selectedItems) {
|
||||
final ArrayList<UserKey> userKeys = new ArrayList<>();
|
||||
for (final Object item : selectedItems) {
|
||||
if (item instanceof ParcelableUser) {
|
||||
@ -160,7 +160,7 @@ public class MultiSelectManager {
|
||||
if (object instanceof ParcelableStatus) {
|
||||
manager.mSelectedStatusIds.add(((ParcelableStatus) object).id);
|
||||
} else if (object instanceof ParcelableUser) {
|
||||
manager.mSelectedUserIds.add(((ParcelableUser) object).key);
|
||||
manager.mSelectedUserKeys.add(((ParcelableUser) object).key);
|
||||
} else
|
||||
return false;
|
||||
final boolean ret = super.add(object);
|
||||
@ -172,7 +172,7 @@ public class MultiSelectManager {
|
||||
public void clear() {
|
||||
super.clear();
|
||||
manager.mSelectedStatusIds.clear();
|
||||
manager.mSelectedUserIds.clear();
|
||||
manager.mSelectedUserKeys.clear();
|
||||
manager.onItemsCleared();
|
||||
}
|
||||
|
||||
@ -182,7 +182,7 @@ public class MultiSelectManager {
|
||||
if (object instanceof ParcelableStatus) {
|
||||
manager.mSelectedStatusIds.remove(((ParcelableStatus) object).id);
|
||||
} else if (object instanceof ParcelableUser) {
|
||||
manager.mSelectedUserIds.remove(((ParcelableUser) object).key);
|
||||
manager.mSelectedUserKeys.remove(((ParcelableUser) object).key);
|
||||
}
|
||||
if (ret) {
|
||||
if (isEmpty()) {
|
||||
|
@ -51,13 +51,12 @@ public final class StatusShortenerInterface extends AbsServiceInterface<IStatusS
|
||||
}
|
||||
|
||||
public StatusShortenResult shorten(final ParcelableStatusUpdate status,
|
||||
final UserKey currentAccountId,
|
||||
final String overrideStatusText) {
|
||||
final UserKey currentAccountKey, final String overrideStatusText) {
|
||||
final IStatusShortener iface = getInterface();
|
||||
if (iface == null) return StatusShortenResult.error(1, "Shortener not ready");
|
||||
try {
|
||||
final String statusJson = JsonSerializer.serialize(status, ParcelableStatusUpdate.class);
|
||||
final String resultJson = iface.shorten(statusJson, currentAccountId.toString(),
|
||||
final String resultJson = iface.shorten(statusJson, currentAccountKey.toString(),
|
||||
overrideStatusText);
|
||||
return JsonSerializer.parse(resultJson, StatusShortenResult.class);
|
||||
} catch (final Exception e) {
|
||||
|
@ -164,8 +164,8 @@ public final class TwidereLinkify implements Constants {
|
||||
mHighlightOption = style;
|
||||
}
|
||||
|
||||
private boolean addCashtagLinks(final Spannable spannable, final UserKey accountKey, final long extraId,
|
||||
final OnLinkClickListener listener, final int highlightOption) {
|
||||
private boolean addCashtagLinks(final Spannable spannable, final UserKey accountKey,
|
||||
final long extraId, final OnLinkClickListener listener, final int highlightOption) {
|
||||
boolean hasMatches = false;
|
||||
for (final Entity entity : mExtractor.extractCashtagsWithIndices(spannable.toString())) {
|
||||
final int start = entity.getStart();
|
||||
@ -177,13 +177,13 @@ public final class TwidereLinkify implements Constants {
|
||||
return hasMatches;
|
||||
}
|
||||
|
||||
private boolean addHashtagLinks(final Spannable spannable, final UserKey accountId, final long extraId,
|
||||
final OnLinkClickListener listener, final int highlightOption) {
|
||||
private boolean addHashtagLinks(final Spannable spannable, final UserKey accountKey,
|
||||
final long extraId, final OnLinkClickListener listener, final int highlightOption) {
|
||||
boolean hasMatches = false;
|
||||
for (final Entity entity : mExtractor.extractHashtagsWithIndices(spannable.toString())) {
|
||||
final int start = entity.getStart();
|
||||
final int end = entity.getEnd();
|
||||
applyLink(entity.getValue(), null, start, end, spannable, accountId, extraId,
|
||||
applyLink(entity.getValue(), null, start, end, spannable, accountKey, extraId,
|
||||
LINK_TYPE_HASHTAG, false, highlightOption, listener);
|
||||
hasMatches = true;
|
||||
}
|
||||
@ -193,8 +193,9 @@ public final class TwidereLinkify implements Constants {
|
||||
/**
|
||||
* Applies a regex to the text of a TextView turning the matches into links.
|
||||
*/
|
||||
private void addLinks(final Spannable string, @Nullable final UserKey accountKey, final long extraId, final int type,
|
||||
final boolean sensitive, final OnLinkClickListener listener, final int highlightOption) {
|
||||
private void addLinks(final Spannable string, @Nullable final UserKey accountKey,
|
||||
final long extraId, final int type, final boolean sensitive,
|
||||
final OnLinkClickListener listener, final int highlightOption) {
|
||||
switch (type) {
|
||||
case LINK_TYPE_MENTION: {
|
||||
addMentionOrListLinks(string, accountKey, extraId, highlightOption, listener);
|
||||
|
@ -133,9 +133,9 @@ public class UserColorNameManager {
|
||||
return getDisplayName(status.user_key, status.user_name, status.user_screen_name, nameFirst);
|
||||
}
|
||||
|
||||
public String getDisplayName(@NonNull final UserKey userId, final String name,
|
||||
public String getDisplayName(@NonNull final UserKey userKey, final String name,
|
||||
final String screenName, final boolean nameFirst) {
|
||||
return getDisplayName(userId.toString(), name, screenName, nameFirst);
|
||||
return getDisplayName(userKey.toString(), name, screenName, nameFirst);
|
||||
}
|
||||
|
||||
public String getDisplayName(@NonNull final String userId, final String name,
|
||||
@ -144,8 +144,8 @@ public class UserColorNameManager {
|
||||
return decideDisplayName(nick, name, screenName, nameFirst);
|
||||
}
|
||||
|
||||
public int getUserColor(@NonNull final UserKey userId) {
|
||||
return getUserColor(userId.toString());
|
||||
public int getUserColor(@NonNull final UserKey userKey) {
|
||||
return getUserColor(userKey.toString());
|
||||
}
|
||||
|
||||
public int getUserColor(@NonNull final String userId) {
|
||||
@ -163,8 +163,8 @@ public class UserColorNameManager {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getUserNickname(@NonNull final UserKey userId, final String name) {
|
||||
final String nick = getUserNickname(userId);
|
||||
public String getUserNickname(@NonNull final UserKey userKey, final String name) {
|
||||
final String nick = getUserNickname(userKey);
|
||||
return decideNickname(nick, name);
|
||||
}
|
||||
|
||||
@ -192,11 +192,11 @@ public class UserColorNameManager {
|
||||
}
|
||||
|
||||
public interface UserColorChangedListener {
|
||||
void onUserColorChanged(@NonNull UserKey userId, int color);
|
||||
void onUserColorChanged(@NonNull UserKey userKey, int color);
|
||||
}
|
||||
|
||||
public interface UserNicknameChangedListener {
|
||||
void onUserNicknameChanged(@NonNull UserKey userId, String nick);
|
||||
void onUserNicknameChanged(@NonNull UserKey userKey, String nick);
|
||||
}
|
||||
|
||||
private static final class OnColorPreferenceChangeListener implements OnSharedPreferenceChangeListener {
|
||||
@ -209,9 +209,9 @@ public class UserColorNameManager {
|
||||
|
||||
@Override
|
||||
public void onSharedPreferenceChanged(final SharedPreferences preferences, final String key) {
|
||||
final UserKey userId = UserKey.valueOf(key);
|
||||
final UserKey userKey = UserKey.valueOf(key);
|
||||
if (mListener != null) {
|
||||
mListener.onUserColorChanged(userId, preferences.getInt(key, 0));
|
||||
mListener.onUserColorChanged(userKey, preferences.getInt(key, 0));
|
||||
}
|
||||
}
|
||||
|
||||
@ -227,9 +227,9 @@ public class UserColorNameManager {
|
||||
|
||||
@Override
|
||||
public void onSharedPreferenceChanged(final SharedPreferences preferences, final String key) {
|
||||
final UserKey userId = UserKey.valueOf(key);
|
||||
final UserKey userKey = UserKey.valueOf(key);
|
||||
if (mListener != null) {
|
||||
mListener.onUserNicknameChanged(userId, preferences.getString(key, null));
|
||||
mListener.onUserNicknameChanged(userKey, preferences.getString(key, null));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -314,7 +314,7 @@ public final class Utils implements Constants {
|
||||
return result;
|
||||
}
|
||||
|
||||
public static boolean setLastSeen(Context context, UserKey userId, long time) {
|
||||
public static boolean setLastSeen(Context context, UserKey userKey, long time) {
|
||||
final ContentResolver cr = context.getContentResolver();
|
||||
final ContentValues values = new ContentValues();
|
||||
if (time > 0) {
|
||||
@ -324,7 +324,7 @@ public final class Utils implements Constants {
|
||||
values.putNull(CachedUsers.LAST_SEEN);
|
||||
}
|
||||
final String where = Expression.equalsArgs(CachedUsers.USER_KEY).getSQL();
|
||||
final String[] selectionArgs = {userId.toString()};
|
||||
final String[] selectionArgs = {userKey.toString()};
|
||||
return cr.update(CachedUsers.CONTENT_URI, values, where, selectionArgs) > 0;
|
||||
}
|
||||
|
||||
@ -348,7 +348,7 @@ public final class Utils implements Constants {
|
||||
UserKey accountKey = string != null ? UserKey.valueOf(string) : null;
|
||||
final UserKey[] accountKeys = DataStoreUtils.INSTANCE.getAccountKeys(context);
|
||||
int idMatchIdx = -1;
|
||||
for (int i = 0, accountIdsLength = accountKeys.length; i < accountIdsLength; i++) {
|
||||
for (int i = 0, j = accountKeys.length; i < j; i++) {
|
||||
if (accountKeys[i].equals(accountKey)) {
|
||||
idMatchIdx = i;
|
||||
}
|
||||
@ -618,8 +618,8 @@ public final class Utils implements Constants {
|
||||
status.my_retweet_id);
|
||||
}
|
||||
|
||||
public static boolean isMyRetweet(final UserKey accountId, final UserKey retweetedById, final String myRetweetId) {
|
||||
return accountId.equals(retweetedById) || myRetweetId != null;
|
||||
public static boolean isMyRetweet(final UserKey accountKey, final UserKey retweetedByKey, final String myRetweetId) {
|
||||
return accountKey.equals(retweetedByKey) || myRetweetId != null;
|
||||
}
|
||||
|
||||
public static int matchTabCode(@Nullable final Uri uri) {
|
||||
@ -898,9 +898,9 @@ public final class Utils implements Constants {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static int getNotificationId(int baseId, @Nullable UserKey accountId) {
|
||||
public static int getNotificationId(int baseId, @Nullable UserKey accountKey) {
|
||||
int result = baseId;
|
||||
result = 31 * result + (accountId != null ? accountId.hashCode() : 0);
|
||||
result = 31 * result + (accountKey != null ? accountKey.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -61,15 +61,15 @@ public final class CachedUsersQueryBuilder {
|
||||
final UserKey accountKey) {
|
||||
final SQLSelectQuery.Builder qb = new SQLSelectQuery.Builder();
|
||||
qb.select(select).from(new Tables(TwidereDataStore.CachedUsers.TABLE_NAME));
|
||||
final Columns.Column relationshipsUserId = new Columns.Column(new Table(CachedRelationships.TABLE_NAME),
|
||||
final Columns.Column relationshipsUserKey = new Columns.Column(new Table(CachedRelationships.TABLE_NAME),
|
||||
CachedRelationships.USER_KEY);
|
||||
final Columns.Column usersUserId = new Columns.Column(new Table(TwidereDataStore.CachedUsers.TABLE_NAME),
|
||||
final Columns.Column usersUserKey = new Columns.Column(new Table(TwidereDataStore.CachedUsers.TABLE_NAME),
|
||||
CachedRelationships.USER_KEY);
|
||||
final Columns.Column relationshipsAccountId = new Columns.Column(new Table(CachedRelationships.TABLE_NAME),
|
||||
final Columns.Column relationshipsAccountKey = new Columns.Column(new Table(CachedRelationships.TABLE_NAME),
|
||||
CachedRelationships.ACCOUNT_KEY);
|
||||
final Expression on = Expression.and(
|
||||
Expression.equals(relationshipsUserId, usersUserId),
|
||||
Expression.equalsArgs(relationshipsAccountId.getSQL())
|
||||
Expression.equals(relationshipsUserKey, usersUserKey),
|
||||
Expression.equalsArgs(relationshipsAccountKey.getSQL())
|
||||
);
|
||||
qb.join(new Join(false, Join.Operation.LEFT, new Table(CachedRelationships.TABLE_NAME), on));
|
||||
final Expression userTypeExpression;
|
||||
|
@ -26,7 +26,7 @@ import java.util.*
|
||||
*/
|
||||
|
||||
object InternalActivityCreator {
|
||||
fun status(accountId: String, status: Status): Activity {
|
||||
fun status(status: Status, accountId: String): Activity {
|
||||
val activity = Activity()
|
||||
|
||||
activity.minPosition = status.getId()
|
||||
|
@ -197,7 +197,7 @@ class ComposeActivity : BaseActivity(), OnMenuItemClickListener, OnClickListener
|
||||
return
|
||||
}
|
||||
val accountDetails = AccountUtils.getAllAccountDetails(am, accounts, true)
|
||||
val defaultAccountIds = accountDetails.map(AccountDetails::key).toTypedArray()
|
||||
val defaultAccountKeys = accountDetails.map(AccountDetails::key).toTypedArray()
|
||||
menuBar.setOnMenuItemClickListener(this)
|
||||
setupEditText()
|
||||
accountSelectorButton.setOnClickListener(this)
|
||||
@ -226,7 +226,7 @@ class ComposeActivity : BaseActivity(), OnMenuItemClickListener, OnClickListener
|
||||
if (savedInstanceState != null) {
|
||||
// Restore from previous saved state
|
||||
val selected = savedInstanceState.getTypedArray(EXTRA_ACCOUNT_KEYS, UserKey.CREATOR)
|
||||
accountsAdapter.setSelectedAccountIds(*selected)
|
||||
accountsAdapter.setSelectedAccountKeys(*selected)
|
||||
possiblySensitive = savedInstanceState.getBoolean(EXTRA_IS_POSSIBLY_SENSITIVE)
|
||||
val mediaList = savedInstanceState.getParcelableArrayList<ParcelableMediaUpdate>(EXTRA_MEDIA)
|
||||
if (mediaList != null) {
|
||||
@ -251,15 +251,15 @@ class ComposeActivity : BaseActivity(), OnMenuItemClickListener, OnClickListener
|
||||
handleDefaultIntent(intent)
|
||||
}
|
||||
setLabel(intent)
|
||||
val selectedAccountIds = accountsAdapter.selectedAccountKeys
|
||||
if (selectedAccountIds.isNullOrEmpty()) {
|
||||
val selectedAccountKeys = accountsAdapter.selectedAccountKeys
|
||||
if (selectedAccountKeys.isNullOrEmpty()) {
|
||||
val idsInPrefs: Array<UserKey> = kPreferences[composeAccountsKey] ?: emptyArray()
|
||||
val intersection: Array<UserKey> = defaultAccountIds.intersect(listOf(*idsInPrefs)).toTypedArray()
|
||||
val intersection: Array<UserKey> = defaultAccountKeys.intersect(listOf(*idsInPrefs)).toTypedArray()
|
||||
|
||||
if (intersection.isEmpty()) {
|
||||
accountsAdapter.setSelectedAccountIds(*defaultAccountIds)
|
||||
accountsAdapter.setSelectedAccountKeys(*defaultAccountKeys)
|
||||
} else {
|
||||
accountsAdapter.setSelectedAccountIds(*intersection)
|
||||
accountsAdapter.setSelectedAccountKeys(*intersection)
|
||||
}
|
||||
}
|
||||
originalText = ParseUtils.parseString(editText.text)
|
||||
@ -888,17 +888,17 @@ class ComposeActivity : BaseActivity(), OnMenuItemClickListener, OnClickListener
|
||||
private fun handleDefaultIntent(intent: Intent?): Boolean {
|
||||
if (intent == null) return false
|
||||
val action = intent.action
|
||||
val hasAccountIds: Boolean
|
||||
val hasAccountKeys: Boolean
|
||||
if (intent.hasExtra(EXTRA_ACCOUNT_KEYS)) {
|
||||
val accountKeys = intent.getParcelableArrayExtra(EXTRA_ACCOUNT_KEYS).toTypedArray(UserKey.CREATOR)
|
||||
accountsAdapter.setSelectedAccountIds(*accountKeys)
|
||||
hasAccountIds = true
|
||||
accountsAdapter.setSelectedAccountKeys(*accountKeys)
|
||||
hasAccountKeys = true
|
||||
} else if (intent.hasExtra(EXTRA_ACCOUNT_KEY)) {
|
||||
val accountKey = intent.getParcelableExtra<UserKey>(EXTRA_ACCOUNT_KEY)
|
||||
accountsAdapter.setSelectedAccountIds(accountKey)
|
||||
hasAccountIds = true
|
||||
accountsAdapter.setSelectedAccountKeys(accountKey)
|
||||
hasAccountKeys = true
|
||||
} else {
|
||||
hasAccountIds = false
|
||||
hasAccountKeys = false
|
||||
}
|
||||
if (Intent.ACTION_SEND == action) {
|
||||
shouldSaveAccounts = false
|
||||
@ -915,7 +915,7 @@ class ComposeActivity : BaseActivity(), OnMenuItemClickListener, OnClickListener
|
||||
TaskStarter.execute(AddMediaTask(this, src, true, false))
|
||||
}
|
||||
} else {
|
||||
shouldSaveAccounts = !hasAccountIds
|
||||
shouldSaveAccounts = !hasAccountKeys
|
||||
val data = intent.data
|
||||
if (data != null) {
|
||||
val src = arrayOf(data)
|
||||
@ -936,7 +936,7 @@ class ComposeActivity : BaseActivity(), OnMenuItemClickListener, OnClickListener
|
||||
editText.setText(draft.text)
|
||||
val selectionEnd = editText.length()
|
||||
editText.setSelection(selectionEnd)
|
||||
accountsAdapter.setSelectedAccountIds(*draft.account_keys ?: emptyArray())
|
||||
accountsAdapter.setSelectedAccountKeys(*draft.account_keys ?: emptyArray())
|
||||
if (draft.media != null) {
|
||||
addMedia(Arrays.asList(*draft.media))
|
||||
}
|
||||
@ -1048,7 +1048,7 @@ class ComposeActivity : BaseActivity(), OnMenuItemClickListener, OnClickListener
|
||||
editText.setText(String.format("@%s ", user.screen_name))
|
||||
val selection_end = editText.length()
|
||||
editText.setSelection(selection_end)
|
||||
accountsAdapter.setSelectedAccountIds(user.account_key)
|
||||
accountsAdapter.setSelectedAccountKeys(user.account_key)
|
||||
return true
|
||||
}
|
||||
|
||||
@ -1056,7 +1056,7 @@ class ComposeActivity : BaseActivity(), OnMenuItemClickListener, OnClickListener
|
||||
if (status == null) return false
|
||||
editText.setText(Utils.getQuoteStatus(this, status))
|
||||
editText.setSelection(0)
|
||||
accountsAdapter.setSelectedAccountIds(status.account_key)
|
||||
accountsAdapter.setSelectedAccountKeys(status.account_key)
|
||||
showQuoteLabel(status)
|
||||
return true
|
||||
}
|
||||
@ -1138,7 +1138,7 @@ class ComposeActivity : BaseActivity(), OnMenuItemClickListener, OnClickListener
|
||||
|
||||
val selectionEnd = editText.length()
|
||||
editText.setSelection(selectionStart, selectionEnd)
|
||||
accountsAdapter.setSelectedAccountIds(status.account_key)
|
||||
accountsAdapter.setSelectedAccountKeys(status.account_key)
|
||||
showReplyLabel(status)
|
||||
return true
|
||||
}
|
||||
@ -1156,15 +1156,15 @@ class ComposeActivity : BaseActivity(), OnMenuItemClickListener, OnClickListener
|
||||
}
|
||||
}
|
||||
|
||||
private fun handleReplyMultipleIntent(screenNames: Array<String>?, accountId: UserKey?,
|
||||
private fun handleReplyMultipleIntent(screenNames: Array<String>?, accountKey: UserKey?,
|
||||
inReplyToStatus: ParcelableStatus): Boolean {
|
||||
if (screenNames == null || screenNames.isEmpty() || accountId == null) return false
|
||||
val myScreenName = DataStoreUtils.getAccountScreenName(this, accountId)
|
||||
if (screenNames == null || screenNames.isEmpty() || accountKey == null) return false
|
||||
val myScreenName = DataStoreUtils.getAccountScreenName(this, accountKey)
|
||||
if (TextUtils.isEmpty(myScreenName)) return false
|
||||
screenNames.filterNot { it.equals(myScreenName, ignoreCase = true) }
|
||||
.forEach { editText.append("@$it ") }
|
||||
editText.setSelection(editText.length())
|
||||
accountsAdapter.setSelectedAccountIds(accountId)
|
||||
accountsAdapter.setSelectedAccountKeys(accountKey)
|
||||
this.inReplyToStatus = inReplyToStatus
|
||||
return true
|
||||
}
|
||||
@ -1667,7 +1667,7 @@ class ComposeActivity : BaseActivity(), OnMenuItemClickListener, OnClickListener
|
||||
.toTypedArray()
|
||||
}
|
||||
|
||||
fun setSelectedAccountIds(vararg accountKeys: UserKey) {
|
||||
fun setSelectedAccountKeys(vararg accountKeys: UserKey) {
|
||||
selection.clear()
|
||||
for (accountKey in accountKeys) {
|
||||
selection.put(accountKey, true)
|
||||
|
@ -688,7 +688,7 @@ class HomeActivity : BaseActivity(), OnClickListener, OnPageChangeListener, Supp
|
||||
val tab = adapter.get(i)
|
||||
if (tabType == Tab.getTypeAlias(tab.type)) {
|
||||
val args = tab.args
|
||||
if (args != null && CustomTabUtils.hasAccountId(this, args,
|
||||
if (args != null && CustomTabUtils.hasAccountKey(this, args,
|
||||
activatedAccountKeys, accountKey)) {
|
||||
initialTab = i
|
||||
break
|
||||
|
@ -228,11 +228,11 @@ class QuickSearchBarActivity : BaseActivity(), OnClickListener, LoaderCallbacks<
|
||||
}
|
||||
|
||||
override fun onCreateLoader(id: Int, args: Bundle?): Loader<Cursor?> {
|
||||
val accountId = selectedAccountDetails?.key
|
||||
val accountKey = selectedAccountDetails?.key
|
||||
val builder = Suggestions.Search.CONTENT_URI.buildUpon()
|
||||
builder.appendQueryParameter(QUERY_PARAM_QUERY, ParseUtils.parseString(searchQuery.text))
|
||||
if (accountId != null) {
|
||||
builder.appendQueryParameter(QUERY_PARAM_ACCOUNT_KEY, accountId.toString())
|
||||
if (accountKey != null) {
|
||||
builder.appendQueryParameter(QUERY_PARAM_ACCOUNT_KEY, accountKey.toString())
|
||||
}
|
||||
return CursorLoader(this, builder.build(), Suggestions.Search.COLUMNS, null, null, null)
|
||||
}
|
||||
|
@ -612,7 +612,7 @@ class SignInActivity : BaseActivity(), OnClickListener, TextWatcher,
|
||||
val apiUser = twitter.verifyCredentials()
|
||||
var color = analyseUserProfileColor(apiUser)
|
||||
val typeExtras = SignInActivity.detectAccountType(twitter, apiUser, apiConfig.type)
|
||||
val userId = apiUser.id!!
|
||||
val userId = apiUser.id
|
||||
val accountKey = UserKey(userId, UserKeyUtils.getUserHost(apiUser))
|
||||
val user = ParcelableUserUtils.fromUser(apiUser, accountKey, typeExtras.first,
|
||||
profileImageSize = profileImageSize)
|
||||
@ -849,9 +849,8 @@ class SignInActivity : BaseActivity(), OnClickListener, TextWatcher,
|
||||
val authenticator = OAuthPasswordAuthenticator(oauth,
|
||||
verificationCallback, userAgent)
|
||||
val accessToken = authenticator.getOAuthAccessToken(username, password)
|
||||
val userId = accessToken.userId!!
|
||||
return getOAuthSignInResponse(activity, accessToken, userId,
|
||||
Credentials.Type.OAUTH)
|
||||
val userId = accessToken.userId
|
||||
return getOAuthSignInResponse(activity, accessToken, userId, Credentials.Type.OAUTH)
|
||||
}
|
||||
|
||||
@Throws(MicroBlogException::class)
|
||||
@ -864,8 +863,7 @@ class SignInActivity : BaseActivity(), OnClickListener, TextWatcher,
|
||||
val oauth = newMicroBlogInstance(activity, endpoint = endpoint, auth = auth,
|
||||
accountType = apiConfig.type, cls = TwitterOAuth::class.java)
|
||||
val accessToken = oauth.getAccessToken(username, password)
|
||||
var userId: String? = accessToken.userId
|
||||
if (userId == null) {
|
||||
val userId = accessToken.userId ?: run {
|
||||
// Trying to fix up userId if accessToken doesn't contain one.
|
||||
auth = OAuthAuthorization(apiConfig.consumerKey,
|
||||
apiConfig.consumerSecret, accessToken)
|
||||
@ -873,9 +871,9 @@ class SignInActivity : BaseActivity(), OnClickListener, TextWatcher,
|
||||
apiConfig.isNoVersionSuffix)
|
||||
val microBlog = newMicroBlogInstance(activity, endpoint = endpoint, auth = auth,
|
||||
accountType = apiConfig.type, cls = MicroBlog::class.java)
|
||||
userId = microBlog.verifyCredentials().id
|
||||
return@run microBlog.verifyCredentials().id
|
||||
}
|
||||
return getOAuthSignInResponse(activity, accessToken, userId!!, Credentials.Type.XAUTH)
|
||||
return getOAuthSignInResponse(activity, accessToken, userId, Credentials.Type.XAUTH)
|
||||
}
|
||||
|
||||
@Throws(MicroBlogException::class, OAuthPasswordAuthenticator.AuthenticationException::class)
|
||||
|
@ -70,7 +70,7 @@ class ParcelableActivitiesAdapter(
|
||||
private val eventListener: EventListener
|
||||
private var data: List<ParcelableActivity>? = null
|
||||
private var activityAdapterListener: ActivityAdapterListener? = null
|
||||
private var filteredUserIds: Array<UserKey>? = null
|
||||
private var filteredUserKeys: Array<UserKey>? = null
|
||||
private val gapLoadingIds: MutableSet<ObjectId> = HashSet()
|
||||
|
||||
var followingOnly: Boolean = false
|
||||
@ -181,7 +181,7 @@ class ParcelableActivitiesAdapter(
|
||||
|
||||
override fun setData(data: List<ParcelableActivity>?) {
|
||||
if (data is CursorActivitiesFragment.CursorActivitiesLoader.ActivityCursor) {
|
||||
filteredUserIds = data.filteredUserIds
|
||||
filteredUserKeys = data.filteredUserIds
|
||||
}
|
||||
this.data = data
|
||||
gapLoadingIds.clear()
|
||||
@ -293,7 +293,7 @@ class ParcelableActivitiesAdapter(
|
||||
Activity.Action.MEDIA_TAGGED, Activity.Action.RETWEETED_MEDIA_TAGGED,
|
||||
Activity.Action.FAVORITED_MEDIA_TAGGED, Activity.Action.JOINED_TWITTER -> {
|
||||
if (mentionsOnly) return ITEM_VIEW_TYPE_EMPTY
|
||||
filteredUserIds?.let {
|
||||
filteredUserKeys?.let {
|
||||
ParcelableActivityUtils.initAfterFilteredSourceIds(activity, it, followingOnly)
|
||||
if (activity.after_filtered_source_ids.isEmpty()) {
|
||||
return ITEM_VIEW_TYPE_EMPTY
|
||||
|
@ -302,10 +302,10 @@ abstract class AbsActivitiesFragment protected constructor() :
|
||||
return
|
||||
}
|
||||
}
|
||||
val accountIds = arrayOf(activity.account_key)
|
||||
val accountKeys = arrayOf(activity.account_key)
|
||||
val maxIds = arrayOf(activity.min_position)
|
||||
val maxSortIds = longArrayOf(activity.min_sort_position)
|
||||
getActivities(BaseRefreshTaskParam(accountKeys = accountIds, maxIds = maxIds,
|
||||
getActivities(BaseRefreshTaskParam(accountKeys = accountKeys, maxIds = maxIds,
|
||||
sinceIds = null, maxSortIds = maxSortIds, sinceSortIds = null).also {
|
||||
it.extraId = activity._id
|
||||
})
|
||||
|
@ -344,10 +344,10 @@ abstract class AbsStatusesFragment : AbsContentListRecyclerViewFragment<Parcelab
|
||||
val status = adapter.getStatus(position)
|
||||
DebugLog.v(msg = "Load activity gap $status")
|
||||
adapter.addGapLoadingId(ObjectId(status.account_key, status.id))
|
||||
val accountIds = arrayOf(status.account_key)
|
||||
val accountKeys = arrayOf(status.account_key)
|
||||
val maxIds = arrayOf<String?>(status.id)
|
||||
val maxSortIds = longArrayOf(status.sort_id)
|
||||
getStatuses(BaseRefreshTaskParam(accountKeys = accountIds, maxIds = maxIds, sinceIds = null,
|
||||
getStatuses(BaseRefreshTaskParam(accountKeys = accountKeys, maxIds = maxIds, sinceIds = null,
|
||||
maxSortIds = maxSortIds, sinceSortIds = null))
|
||||
}
|
||||
|
||||
|
@ -382,10 +382,10 @@ class AccountsDashboardFragment : BaseFragment(), LoaderCallbacks<AccountsInfo>,
|
||||
menu.setItemAvailability(R.id.public_timeline, hasPublicTimeline)
|
||||
}
|
||||
|
||||
private fun hasAccountInTab(tab: SupportTabSpec, accountId: UserKey, isActivated: Boolean): Boolean {
|
||||
private fun hasAccountInTab(tab: SupportTabSpec, accountKey: UserKey, isActivated: Boolean): Boolean {
|
||||
if (tab.args == null) return false
|
||||
val accountKeys = Utils.getAccountKeys(context, tab.args) ?: return isActivated
|
||||
return accountKeys.contains(accountId)
|
||||
return accountKey in accountKeys
|
||||
}
|
||||
|
||||
private fun closeAccountsDrawer() {
|
||||
|
@ -346,8 +346,8 @@ abstract class CursorActivitiesFragment : AbsActivitiesFragment() {
|
||||
projection, selection, selectionArgs, sortOrder, fromUser) {
|
||||
|
||||
override fun createObjectCursor(cursor: Cursor, indices: ObjectCursor.CursorIndices<ParcelableActivity>): ObjectCursor<ParcelableActivity> {
|
||||
val filteredUserIds = DataStoreUtils.getFilteredUserIds(context)
|
||||
return ActivityCursor(cursor, indices, filteredUserIds)
|
||||
val filteredUserKeys = DataStoreUtils.getFilteredUserKeys(context)
|
||||
return ActivityCursor(cursor, indices, filteredUserKeys)
|
||||
}
|
||||
|
||||
class ActivityCursor(cursor: Cursor, indies: ObjectCursor.CursorIndices<ParcelableActivity>,
|
||||
|
@ -240,8 +240,8 @@ abstract class CursorStatusesFragment : AbsStatusesFragment() {
|
||||
super.setUserVisibleHint(isVisibleToUser)
|
||||
val context = context
|
||||
if (context != null && isVisibleToUser) {
|
||||
for (accountId in accountKeys) {
|
||||
twitterWrapper.clearNotificationAsync(notificationType, accountId)
|
||||
for (accountKey in accountKeys) {
|
||||
twitterWrapper.clearNotificationAsync(notificationType, accountKey)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -135,16 +135,16 @@ class CustomTabsFragment : BaseFragment(), LoaderCallbacks<Cursor?>, MultiChoice
|
||||
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
|
||||
inflater.inflate(R.menu.menu_custom_tabs, menu)
|
||||
val context = this.context
|
||||
val accountIds = DataStoreUtils.getAccountKeys(context)
|
||||
val accountKeys = DataStoreUtils.getAccountKeys(context)
|
||||
val itemAdd = menu.findItem(R.id.add_submenu)
|
||||
val theme = Chameleon.getOverrideTheme(context, context)
|
||||
if (itemAdd != null && itemAdd.hasSubMenu()) {
|
||||
val subMenu = itemAdd.subMenu
|
||||
subMenu.clear()
|
||||
for ((type, conf) in TabConfiguration.all()) {
|
||||
val accountIdRequired = (conf.accountFlags and TabConfiguration.FLAG_ACCOUNT_REQUIRED) != 0
|
||||
val accountRequired = TabConfiguration.FLAG_ACCOUNT_REQUIRED in conf.accountFlags
|
||||
val subItem = subMenu.add(0, 0, conf.sortPosition, conf.name.createString(context))
|
||||
val disabledByNoAccount = accountIdRequired && accountIds.isEmpty()
|
||||
val disabledByNoAccount = accountRequired && accountKeys.isEmpty()
|
||||
val disabledByDuplicateTab = conf.isSingleTab && CustomTabUtils.isTabAdded(context, type)
|
||||
val shouldDisable = disabledByDuplicateTab || disabledByNoAccount
|
||||
subItem.isVisible = !shouldDisable
|
||||
@ -281,13 +281,13 @@ class CustomTabsFragment : BaseFragment(), LoaderCallbacks<Cursor?>, MultiChoice
|
||||
|
||||
val editMode = tag == TAG_EDIT_TAB
|
||||
|
||||
val hasAccount = conf.accountFlags and TabConfiguration.FLAG_HAS_ACCOUNT != 0
|
||||
val accountMutable = conf.accountFlags and TabConfiguration.FLAG_ACCOUNT_MUTABLE != 0
|
||||
val hasAccount = TabConfiguration.FLAG_HAS_ACCOUNT in conf.accountFlags
|
||||
val accountMutable = TabConfiguration.FLAG_ACCOUNT_MUTABLE in conf.accountFlags
|
||||
if (hasAccount && (accountMutable || !editMode)) {
|
||||
accountContainer.visibility = View.VISIBLE
|
||||
val accountIdRequired = conf.accountFlags and TabConfiguration.FLAG_ACCOUNT_REQUIRED != 0
|
||||
val accountRequired = TabConfiguration.FLAG_ACCOUNT_REQUIRED in conf.accountFlags
|
||||
accountsAdapter.clear()
|
||||
if (!accountIdRequired) {
|
||||
if (!accountRequired) {
|
||||
accountsAdapter.add(AccountDetails.dummy())
|
||||
}
|
||||
val officialKeyOnly = arguments.getBoolean(EXTRA_OFFICIAL_KEY_ONLY, false)
|
||||
|
@ -45,12 +45,12 @@ class GroupFragment : AbsToolbarTabPagesFragment(), LoaderCallbacks<SingleRespon
|
||||
}
|
||||
|
||||
override fun onCreateLoader(id: Int, args: Bundle): Loader<SingleResponse<ParcelableGroup>> {
|
||||
val accountKey = args.getParcelable<UserKey>(EXTRA_ACCOUNT_KEY)
|
||||
val accountKey = args.getParcelable<UserKey?>(EXTRA_ACCOUNT_KEY)
|
||||
val groupId = args.getString(EXTRA_GROUP_ID)
|
||||
val groupName = args.getString(EXTRA_GROUP_NAME)
|
||||
val omitIntentExtra = args.getBoolean(EXTRA_OMIT_INTENT_EXTRA, true)
|
||||
return ParcelableGroupLoader(context, omitIntentExtra, arguments, accountKey,
|
||||
groupId, groupName)
|
||||
return ParcelableGroupLoader(context, omitIntentExtra, arguments, accountKey, groupId,
|
||||
groupName)
|
||||
}
|
||||
|
||||
override fun onLoadFinished(loader: Loader<SingleResponse<ParcelableGroup>>, data: SingleResponse<ParcelableGroup>) {
|
||||
@ -94,31 +94,32 @@ class GroupFragment : AbsToolbarTabPagesFragment(), LoaderCallbacks<SingleRespon
|
||||
context: Context,
|
||||
private val omitIntentExtra: Boolean,
|
||||
private val extras: Bundle?,
|
||||
private val accountKey: UserKey,
|
||||
private val accountKey: UserKey?,
|
||||
private val groupId: String?,
|
||||
private val groupName: String?
|
||||
) : FixedAsyncTaskLoader<SingleResponse<ParcelableGroup>>(context) {
|
||||
|
||||
override fun loadInBackground(): SingleResponse<ParcelableGroup> {
|
||||
if (!omitIntentExtra && extras != null) {
|
||||
val cache = extras.getParcelable<ParcelableGroup>(EXTRA_GROUP)
|
||||
if (cache != null) return SingleResponse.getInstance(cache)
|
||||
val cache = extras.getParcelable<ParcelableGroup?>(EXTRA_GROUP)
|
||||
if (cache != null) return SingleResponse(cache)
|
||||
}
|
||||
val twitter = MicroBlogAPIFactory.getInstance(context, accountKey
|
||||
) ?: return SingleResponse.getInstance<ParcelableGroup>()
|
||||
try {
|
||||
if (accountKey == null) throw MicroBlogException("No account")
|
||||
val twitter = MicroBlogAPIFactory.getInstance(context, accountKey) ?:
|
||||
throw MicroBlogException("No account")
|
||||
val group: Group
|
||||
if (groupId != null) {
|
||||
group = twitter.showGroup(groupId)
|
||||
} else if (groupName != null) {
|
||||
group = twitter.showGroupByName(groupName)
|
||||
} else {
|
||||
return SingleResponse.getInstance<ParcelableGroup>()
|
||||
return SingleResponse()
|
||||
}
|
||||
return SingleResponse.getInstance(ParcelableGroupUtils.from(group, accountKey, 0,
|
||||
group.isMember))
|
||||
} catch (e: MicroBlogException) {
|
||||
return SingleResponse.getInstance<ParcelableGroup>(e)
|
||||
return SingleResponse(e)
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -30,11 +30,11 @@ class GroupMembersFragment : CursorUsersListFragment() {
|
||||
|
||||
override fun onCreateUsersLoader(context: Context,
|
||||
args: Bundle, fromUser: Boolean): CursorSupportUsersLoader {
|
||||
val accountId = args.getParcelable<UserKey>(EXTRA_ACCOUNT_KEY)
|
||||
val accountKey = args.getParcelable<UserKey?>(EXTRA_ACCOUNT_KEY)
|
||||
val groupId = args.getString(EXTRA_GROUP_ID)
|
||||
val groupName = args.getString(EXTRA_GROUP_NAME)
|
||||
val loader = GroupMembersLoader(context, accountId, groupId,
|
||||
groupName, adapter.getData(), fromUser)
|
||||
val loader = GroupMembersLoader(context, accountKey, groupId, groupName, adapter.getData(),
|
||||
fromUser)
|
||||
loader.cursor = nextCursor
|
||||
loader.page = nextPage
|
||||
return loader
|
||||
|
@ -63,9 +63,8 @@ class HomeTimelineFragment : CursorStatusesFragment() {
|
||||
super.setUserVisibleHint(isVisibleToUser)
|
||||
val context = context
|
||||
if (isVisibleToUser && context != null) {
|
||||
for (accountId in accountKeys) {
|
||||
val tag = "home_" + accountId
|
||||
notificationManager.cancel(tag, NOTIFICATION_ID_HOME_TIMELINE)
|
||||
accountKeys.forEach { accountKey ->
|
||||
notificationManager.cancel("home_$accountKey", NOTIFICATION_ID_HOME_TIMELINE)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -29,10 +29,9 @@ import org.mariotaku.twidere.model.event.FriendshipTaskEvent
|
||||
|
||||
class MutesUsersListFragment : CursorUsersListFragment() {
|
||||
|
||||
override fun onCreateUsersLoader(context: Context,
|
||||
args: Bundle,
|
||||
fromUser: Boolean): CursorSupportUsersLoader {
|
||||
val accountKey = args.getParcelable<UserKey>(EXTRA_ACCOUNT_KEY)
|
||||
override fun onCreateUsersLoader(context: Context, args: Bundle, fromUser: Boolean):
|
||||
CursorSupportUsersLoader {
|
||||
val accountKey = args.getParcelable<UserKey?>(EXTRA_ACCOUNT_KEY)
|
||||
val loader = MutesUsersLoader(context, accountKey, adapter.getData(), fromUser)
|
||||
loader.cursor = nextCursor
|
||||
loader.page = nextPage
|
||||
|
@ -67,10 +67,7 @@ abstract class ParcelableGroupsFragment : AbsContentListRecyclerViewFragment<Par
|
||||
}
|
||||
|
||||
protected val accountKey: UserKey?
|
||||
get() {
|
||||
val args = arguments
|
||||
return args.getParcelable<UserKey>(EXTRA_ACCOUNT_KEY)
|
||||
}
|
||||
get() = arguments.getParcelable<UserKey?>(EXTRA_ACCOUNT_KEY)
|
||||
|
||||
protected fun hasMoreData(data: List<ParcelableGroup>?): Boolean {
|
||||
return data == null || !data.isEmpty()
|
||||
|
@ -70,10 +70,7 @@ abstract class ParcelableUserListsFragment : AbsContentListRecyclerViewFragment<
|
||||
}
|
||||
|
||||
protected val accountKey: UserKey?
|
||||
get() {
|
||||
val args = arguments
|
||||
return args.getParcelable<UserKey>(EXTRA_ACCOUNT_KEY)
|
||||
}
|
||||
get() = arguments.getParcelable<UserKey?>(EXTRA_ACCOUNT_KEY)
|
||||
|
||||
protected fun hasMoreData(data: List<ParcelableUserList>?): Boolean {
|
||||
return data == null || !data.isEmpty()
|
||||
|
@ -42,7 +42,7 @@ class SearchUsersFragment : ParcelableUsersFragment() {
|
||||
}
|
||||
|
||||
override fun onCreateUsersLoader(context: Context, args: Bundle, fromUser: Boolean): Loader<List<ParcelableUser>?> {
|
||||
val accountKey = args.getParcelable<UserKey>(EXTRA_ACCOUNT_KEY)
|
||||
val accountKey = args.getParcelable<UserKey?>(EXTRA_ACCOUNT_KEY)
|
||||
val query = args.getString(EXTRA_QUERY)
|
||||
val page = args.getInt(EXTRA_PAGE, 1)
|
||||
return UserSearchLoader(context, accountKey, query, page, adapter.getData(), fromUser)
|
||||
|
@ -25,7 +25,6 @@ import android.content.DialogInterface.OnClickListener
|
||||
import android.os.Bundle
|
||||
import android.support.v4.app.FragmentManager
|
||||
import android.support.v7.app.AlertDialog
|
||||
import android.text.TextUtils
|
||||
import android.widget.EditText
|
||||
import org.mariotaku.ktextension.empty
|
||||
import org.mariotaku.twidere.R
|
||||
@ -37,32 +36,30 @@ import org.mariotaku.twidere.model.UserKey
|
||||
class SetUserNicknameDialogFragment : BaseDialogFragment(), OnClickListener {
|
||||
|
||||
override fun onClick(dialog: DialogInterface, which: Int) {
|
||||
val args = arguments!!
|
||||
val editName = (dialog as AlertDialog).findViewById(R.id.editName) as EditText
|
||||
val userId = args.getParcelable<UserKey>(EXTRA_USER_KEY)!!
|
||||
val userKey = arguments.getParcelable<UserKey>(EXTRA_USER_KEY)
|
||||
when (which) {
|
||||
DialogInterface.BUTTON_POSITIVE -> {
|
||||
if (editName.empty) {
|
||||
userColorNameManager.clearUserNickname(userId)
|
||||
userColorNameManager.clearUserNickname(userKey)
|
||||
} else {
|
||||
userColorNameManager.setUserNickname(userId, editName.text.toString())
|
||||
userColorNameManager.setUserNickname(userKey, editName.text.toString())
|
||||
}
|
||||
}
|
||||
DialogInterface.BUTTON_NEUTRAL -> {
|
||||
userColorNameManager.clearUserNickname(userId)
|
||||
userColorNameManager.clearUserNickname(userKey)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||
val args = arguments
|
||||
val nick: String? = args.getString(EXTRA_NAME)
|
||||
val nick = arguments.getString(EXTRA_NAME)
|
||||
val context = activity
|
||||
val builder = AlertDialog.Builder(context)
|
||||
builder.setTitle(R.string.title_set_nickname)
|
||||
builder.setPositiveButton(android.R.string.ok, this)
|
||||
if (!TextUtils.isEmpty(nick)) {
|
||||
if (!nick.isNullOrEmpty()) {
|
||||
builder.setNeutralButton(R.string.action_clear, this)
|
||||
}
|
||||
builder.setNegativeButton(android.R.string.cancel, null)
|
||||
|
@ -32,10 +32,10 @@ class StatusRetweetersListFragment : CursorUsersListFragment() {
|
||||
override fun onCreateUsersLoader(context: Context,
|
||||
args: Bundle,
|
||||
fromUser: Boolean): CursorSupportUsersLoader {
|
||||
val accountKey = args.getParcelable<UserKey>(EXTRA_ACCOUNT_KEY)
|
||||
val accountKey = args.getParcelable<UserKey?>(EXTRA_ACCOUNT_KEY)
|
||||
val statusId = args.getString(EXTRA_STATUS_ID)
|
||||
val loader = StatusRetweetersLoader(context, accountKey, statusId,
|
||||
adapter.getData(), fromUser)
|
||||
val loader = StatusRetweetersLoader(context, accountKey, statusId, adapter.getData(),
|
||||
fromUser)
|
||||
loader.cursor = nextCursor
|
||||
loader.page = nextPage
|
||||
return loader
|
||||
|
@ -32,7 +32,7 @@ class UserBlocksListFragment : CursorUsersListFragment() {
|
||||
override fun onCreateUsersLoader(context: Context,
|
||||
args: Bundle,
|
||||
fromUser: Boolean): CursorSupportUsersLoader {
|
||||
val accountKey = args.getParcelable<UserKey>(EXTRA_ACCOUNT_KEY)
|
||||
val accountKey = args.getParcelable<UserKey?>(EXTRA_ACCOUNT_KEY)
|
||||
val loader = UserBlocksLoader(context, accountKey, adapter.getData(), fromUser)
|
||||
loader.cursor = nextCursor
|
||||
loader.page = nextPage
|
||||
|
@ -29,11 +29,10 @@ import org.mariotaku.twidere.model.event.FriendshipTaskEvent
|
||||
|
||||
class UserFollowersFragment : CursorUsersListFragment() {
|
||||
|
||||
override fun onCreateUsersLoader(context: Context,
|
||||
args: Bundle,
|
||||
fromUser: Boolean): CursorSupportUsersLoader {
|
||||
val accountKey = args.getParcelable<UserKey>(EXTRA_ACCOUNT_KEY)
|
||||
val userKey = args.getParcelable<UserKey>(EXTRA_USER_KEY)
|
||||
override fun onCreateUsersLoader(context: Context, args: Bundle, fromUser: Boolean):
|
||||
CursorSupportUsersLoader {
|
||||
val accountKey = args.getParcelable<UserKey?>(EXTRA_ACCOUNT_KEY)
|
||||
val userKey = args.getParcelable<UserKey?>(EXTRA_USER_KEY)
|
||||
val screenName = args.getString(EXTRA_SCREEN_NAME)
|
||||
val loader = UserFollowersLoader(context, accountKey, userKey, screenName,
|
||||
adapter.getData(), fromUser)
|
||||
|
@ -216,8 +216,8 @@ class UserFragment : BaseFragment(), OnClickListener, OnLinkClickListener,
|
||||
|
||||
override fun onCreateLoader(id: Int, args: Bundle): Loader<SingleResponse<ParcelableUser>> {
|
||||
val omitIntentExtra = args.getBoolean(EXTRA_OMIT_INTENT_EXTRA, true)
|
||||
val accountKey = args.getParcelable<UserKey>(EXTRA_ACCOUNT_KEY)
|
||||
val userId = args.getParcelable<UserKey>(EXTRA_USER_KEY)
|
||||
val accountKey = args.getParcelable<UserKey?>(EXTRA_ACCOUNT_KEY)
|
||||
val userKey = args.getParcelable<UserKey?>(EXTRA_USER_KEY)
|
||||
val screenName = args.getString(EXTRA_SCREEN_NAME)
|
||||
if (user == null && (!omitIntentExtra || !args.containsKey(EXTRA_USER))) {
|
||||
cardContent.visibility = View.GONE
|
||||
@ -227,8 +227,8 @@ class UserFragment : BaseFragment(), OnClickListener, OnLinkClickListener,
|
||||
errorText.visibility = View.GONE
|
||||
}
|
||||
val user = this@UserFragment.user
|
||||
val loadFromCache = user == null || !user.is_cache && user.key.maybeEquals(userId)
|
||||
return ParcelableUserLoader(activity, accountKey, userId, screenName, arguments,
|
||||
val loadFromCache = user == null || !user.is_cache && user.key.maybeEquals(userKey)
|
||||
return ParcelableUserLoader(activity, accountKey, userKey, screenName, arguments,
|
||||
omitIntentExtra, loadFromCache)
|
||||
}
|
||||
|
||||
@ -701,9 +701,12 @@ class UserFragment : BaseFragment(), OnClickListener, OnLinkClickListener,
|
||||
preferences[themeBackgroundOptionKey], preferences[themeBackgroundAlphaKey])
|
||||
actionBarShadowColor = 0xA0000000.toInt()
|
||||
val args = arguments
|
||||
val accountId: UserKey = args.getParcelable<UserKey>(EXTRA_ACCOUNT_KEY)
|
||||
val userId: UserKey? = args.getParcelable<UserKey>(EXTRA_USER_KEY)
|
||||
val screenName: String? = args.getString(EXTRA_SCREEN_NAME)
|
||||
val accountKey = args.getParcelable<UserKey?>(EXTRA_ACCOUNT_KEY) ?: run {
|
||||
activity.finish()
|
||||
return
|
||||
}
|
||||
val userKey = args.getParcelable<UserKey?>(EXTRA_USER_KEY)
|
||||
val screenName = args.getString(EXTRA_SCREEN_NAME)
|
||||
|
||||
Utils.setNdefPushMessageCallback(activity, CreateNdefMessageCallback {
|
||||
val user = user ?: return@CreateNdefMessageCallback null
|
||||
@ -770,7 +773,7 @@ class UserFragment : BaseFragment(), OnClickListener, OnLinkClickListener,
|
||||
setupViewStyle()
|
||||
setupUserPages()
|
||||
|
||||
getUserInfo(accountId, userId, screenName, false)
|
||||
getUserInfo(accountKey, userKey, screenName, false)
|
||||
}
|
||||
|
||||
|
||||
@ -1302,13 +1305,13 @@ class UserFragment : BaseFragment(), OnClickListener, OnLinkClickListener,
|
||||
return false
|
||||
}
|
||||
|
||||
override fun onUserNicknameChanged(userId: UserKey, nick: String) {
|
||||
if (user == null || user!!.key != userId) return
|
||||
override fun onUserNicknameChanged(userKey: UserKey, nick: String) {
|
||||
if (user?.key != userKey) return
|
||||
displayUser(user, account)
|
||||
}
|
||||
|
||||
override fun onUserColorChanged(userId: UserKey, color: Int) {
|
||||
if (user == null || user!!.key != userId) return
|
||||
override fun onUserColorChanged(userKey: UserKey, color: Int) {
|
||||
if (user?.key != userKey) return
|
||||
displayUser(user, account)
|
||||
}
|
||||
|
||||
@ -1442,7 +1445,7 @@ class UserFragment : BaseFragment(), OnClickListener, OnLinkClickListener,
|
||||
tabArgs.putString(EXTRA_SCREEN_NAME, user.screen_name)
|
||||
tabArgs.putString(EXTRA_PROFILE_URL, user.extras?.statusnet_profile_url)
|
||||
} else {
|
||||
userKey = args.getParcelable<UserKey>(EXTRA_ACCOUNT_KEY)
|
||||
userKey = args.getParcelable<UserKey?>(EXTRA_ACCOUNT_KEY)
|
||||
tabArgs.putParcelable(EXTRA_ACCOUNT_KEY, userKey)
|
||||
tabArgs.putParcelable(EXTRA_USER_KEY, args.getParcelable<Parcelable>(EXTRA_USER_KEY))
|
||||
tabArgs.putString(EXTRA_SCREEN_NAME, args.getString(EXTRA_SCREEN_NAME))
|
||||
@ -1689,6 +1692,7 @@ class UserFragment : BaseFragment(), OnClickListener, OnLinkClickListener,
|
||||
}
|
||||
|
||||
class AddRemoveUserListDialogFragment : BaseDialogFragment() {
|
||||
|
||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||
val lists = arguments.getParcelableArray(EXTRA_USER_LISTS).toTypedArray(ParcelableUserList.CREATOR)
|
||||
val userKey = arguments.getParcelable<UserKey>(EXTRA_USER_KEY)
|
||||
|
@ -31,11 +31,11 @@ class UserFriendsFragment : CursorUsersListFragment() {
|
||||
|
||||
override fun onCreateUsersLoader(context: Context,
|
||||
args: Bundle, fromUser: Boolean): CursorSupportUsersLoader {
|
||||
val accountKey = args.getParcelable<UserKey>(EXTRA_ACCOUNT_KEY)
|
||||
val userKey = args.getParcelable<UserKey>(EXTRA_USER_KEY)
|
||||
val accountKey = args.getParcelable<UserKey?>(EXTRA_ACCOUNT_KEY)
|
||||
val userKey = args.getParcelable<UserKey?>(EXTRA_USER_KEY)
|
||||
val screenName = args.getString(EXTRA_SCREEN_NAME)
|
||||
val loader = UserFriendsLoader(context, accountKey, userKey,
|
||||
screenName, adapter.getData(), fromUser)
|
||||
val loader = UserFriendsLoader(context, accountKey, userKey, screenName, adapter.getData(),
|
||||
fromUser)
|
||||
loader.cursor = nextCursor
|
||||
loader.page = nextPage
|
||||
return loader
|
||||
|
@ -289,8 +289,8 @@ class UserListFragment : AbsToolbarTabPagesFragment(), OnClickListener,
|
||||
}
|
||||
|
||||
override fun onCreateLoader(id: Int, args: Bundle): Loader<SingleResponse<ParcelableUserList>> {
|
||||
val accountKey = args.getParcelable<UserKey>(EXTRA_ACCOUNT_KEY)
|
||||
val userKey = args.getParcelable<UserKey>(EXTRA_USER_KEY)
|
||||
val accountKey = args.getParcelable<UserKey?>(EXTRA_ACCOUNT_KEY)
|
||||
val userKey = args.getParcelable<UserKey?>(EXTRA_USER_KEY)
|
||||
val listId = args.getString(EXTRA_LIST_ID)
|
||||
val listName = args.getString(EXTRA_LIST_NAME)
|
||||
val screenName = args.getString(EXTRA_SCREEN_NAME)
|
||||
@ -385,7 +385,7 @@ class UserListFragment : AbsToolbarTabPagesFragment(), OnClickListener,
|
||||
context: Context,
|
||||
private val omitIntentExtra: Boolean,
|
||||
private val extras: Bundle?,
|
||||
private val accountKey: UserKey,
|
||||
private val accountKey: UserKey?,
|
||||
private val listId: String?,
|
||||
private val listName: String?,
|
||||
private val userKey: UserKey?,
|
||||
@ -397,9 +397,10 @@ class UserListFragment : AbsToolbarTabPagesFragment(), OnClickListener,
|
||||
val cache = extras.getParcelable<ParcelableUserList>(EXTRA_USER_LIST)
|
||||
if (cache != null) return SingleResponse(cache)
|
||||
}
|
||||
val twitter = MicroBlogAPIFactory.getInstance(context, accountKey)
|
||||
?: return SingleResponse(MicroBlogException("No account"))
|
||||
try {
|
||||
if (accountKey == null) throw MicroBlogException("No account")
|
||||
val twitter = MicroBlogAPIFactory.getInstance(context, accountKey)
|
||||
?: throw MicroBlogException("No account")
|
||||
val list: UserList
|
||||
when {
|
||||
listId != null -> {
|
||||
|
@ -45,13 +45,13 @@ class UserListMembersFragment : CursorUsersListFragment() {
|
||||
|
||||
override fun onCreateUsersLoader(context: Context,
|
||||
args: Bundle, fromUser: Boolean): CursorSupportUsersLoader {
|
||||
val accountId = args.getParcelable<UserKey>(EXTRA_ACCOUNT_KEY)
|
||||
val accountKey = args.getParcelable<UserKey?>(EXTRA_ACCOUNT_KEY)
|
||||
val listId = args.getString(EXTRA_LIST_ID)
|
||||
val userKey = args.getParcelable<UserKey>(EXTRA_USER_KEY)
|
||||
val userKey = args.getParcelable<UserKey?>(EXTRA_USER_KEY)
|
||||
val screenName = args.getString(EXTRA_SCREEN_NAME)
|
||||
val listName = args.getString(EXTRA_LIST_NAME)
|
||||
val loader = UserListMembersLoader(context, accountId, listId,
|
||||
userKey, screenName, listName, adapter.getData(), fromUser)
|
||||
val loader = UserListMembersLoader(context, accountKey, listId, userKey, screenName,
|
||||
listName, adapter.getData(), fromUser)
|
||||
loader.cursor = nextCursor
|
||||
loader.page = nextPage
|
||||
return loader
|
||||
@ -83,10 +83,9 @@ class UserListMembersFragment : CursorUsersListFragment() {
|
||||
|
||||
override fun onCreateContextMenu(menu: ContextMenu, v: View, menuInfo: ContextMenu.ContextMenuInfo?) {
|
||||
if (!userVisibleHint || menuInfo == null) return
|
||||
val args = arguments
|
||||
val accountId = args.getParcelable<UserKey>(EXTRA_ACCOUNT_KEY)
|
||||
val userKey = args.getParcelable<UserKey>(EXTRA_USER_KEY)
|
||||
if (accountId == null || accountId != userKey) return
|
||||
val accountKey = arguments.getParcelable<UserKey?>(EXTRA_ACCOUNT_KEY)
|
||||
val userKey = arguments.getParcelable<UserKey?>(EXTRA_USER_KEY)
|
||||
if (accountKey == null || accountKey != userKey) return
|
||||
val inflater = MenuInflater(context)
|
||||
val contextMenuInfo = menuInfo as ExtendedRecyclerView.ContextMenuInfo?
|
||||
inflater.inflate(R.menu.action_user_list_member, menu)
|
||||
@ -120,13 +119,12 @@ class UserListMembersFragment : CursorUsersListFragment() {
|
||||
@Subscribe
|
||||
fun onUserListMembersChanged(event: UserListMembersChangedEvent) {
|
||||
val userList = event.userList
|
||||
val args = arguments
|
||||
val accountId = args.getParcelable<UserKey>(EXTRA_ACCOUNT_KEY)
|
||||
val listId = args.getString(EXTRA_LIST_ID)
|
||||
val userKey = args.getParcelable<UserKey>(EXTRA_USER_KEY)
|
||||
val screenName = args.getString(EXTRA_SCREEN_NAME)
|
||||
val listName = args.getString(EXTRA_LIST_NAME)
|
||||
if (!ParcelableUserListUtils.check(userList, accountId, listId, userKey, screenName, listName)) {
|
||||
val accountKey = arguments.getParcelable<UserKey?>(EXTRA_ACCOUNT_KEY) ?: return
|
||||
val listId = arguments.getString(EXTRA_LIST_ID)
|
||||
val userKey = arguments.getParcelable<UserKey?>(EXTRA_USER_KEY)
|
||||
val screenName = arguments.getString(EXTRA_SCREEN_NAME)
|
||||
val listName = arguments.getString(EXTRA_LIST_NAME)
|
||||
if (!ParcelableUserListUtils.check(userList, accountKey, listId, userKey, screenName, listName)) {
|
||||
return
|
||||
}
|
||||
when (event.action) {
|
||||
|
@ -31,8 +31,8 @@ class UserListMembershipsFragment : ParcelableUserListsFragment() {
|
||||
|
||||
override fun onCreateUserListsLoader(context: Context,
|
||||
args: Bundle, fromUser: Boolean): Loader<List<ParcelableUserList>> {
|
||||
val accountKey = args.getParcelable<UserKey>(EXTRA_ACCOUNT_KEY)
|
||||
val userKey = args.getParcelable<UserKey>(EXTRA_USER_KEY)
|
||||
val accountKey = args.getParcelable<UserKey?>(EXTRA_ACCOUNT_KEY)
|
||||
val userKey = args.getParcelable<UserKey?>(EXTRA_USER_KEY)
|
||||
val screenName = args.getString(EXTRA_SCREEN_NAME)
|
||||
val cursor = args.getLong(EXTRA_NEXT_CURSOR, -1)
|
||||
return UserListMembershipsLoader(activity, accountKey, userKey, screenName, cursor, data)
|
||||
|
@ -30,8 +30,8 @@ class UserListSubscribersFragment : CursorUsersListFragment() {
|
||||
|
||||
override fun onCreateUsersLoader(context: Context, args: Bundle, fromUser: Boolean): CursorSupportUsersLoader {
|
||||
val listId = args.getString(EXTRA_LIST_ID)
|
||||
val accountKey = args.getParcelable<UserKey>(EXTRA_ACCOUNT_KEY)
|
||||
val userKey = args.getParcelable<UserKey>(EXTRA_USER_KEY)
|
||||
val accountKey = args.getParcelable<UserKey?>(EXTRA_ACCOUNT_KEY)
|
||||
val userKey = args.getParcelable<UserKey?>(EXTRA_USER_KEY)
|
||||
val screenName = args.getString(EXTRA_SCREEN_NAME)
|
||||
val listName = args.getString(EXTRA_LIST_NAME)
|
||||
val loader = UserListSubscribersLoader(context, accountKey,
|
||||
|
@ -30,8 +30,8 @@ import org.mariotaku.twidere.model.UserKey
|
||||
class UserListSubscriptionsFragment : ParcelableUserListsFragment() {
|
||||
|
||||
override fun onCreateUserListsLoader(context: Context, args: Bundle, fromUser: Boolean): Loader<List<ParcelableUserList>> {
|
||||
val accountKey = args.getParcelable<UserKey>(EXTRA_ACCOUNT_KEY)
|
||||
val userKey = args.getParcelable<UserKey>(EXTRA_USER_KEY)
|
||||
val accountKey = args.getParcelable<UserKey?>(EXTRA_ACCOUNT_KEY)
|
||||
val userKey = args.getParcelable<UserKey?>(EXTRA_USER_KEY)
|
||||
val screenName = args.getString(EXTRA_SCREEN_NAME)
|
||||
val cursor = args.getLong(EXTRA_NEXT_CURSOR, -1)
|
||||
return UserListSubscriptionsLoader(activity, accountKey, userKey, screenName, cursor, data)
|
||||
|
@ -39,7 +39,7 @@ class UserListTimelineFragment : ParcelableStatusesFragment() {
|
||||
get() {
|
||||
val accountKey = Utils.getAccountKey(context, arguments)
|
||||
val listId = arguments.getString(EXTRA_LIST_ID)
|
||||
val userKey = arguments.getParcelable<UserKey>(EXTRA_USER_KEY)
|
||||
val userKey = arguments.getParcelable<UserKey?>(EXTRA_USER_KEY)
|
||||
val screenName = arguments.getString(EXTRA_SCREEN_NAME)
|
||||
val listName = arguments.getString(EXTRA_LIST_NAME)
|
||||
val result = ArrayList<String>()
|
||||
@ -70,7 +70,7 @@ class UserListTimelineFragment : ParcelableStatusesFragment() {
|
||||
if (listId != null) {
|
||||
sb.append(listId)
|
||||
} else if (listName != null) {
|
||||
val userKey = arguments.getParcelable<UserKey>(EXTRA_USER_KEY)
|
||||
val userKey = arguments.getParcelable<UserKey?>(EXTRA_USER_KEY)
|
||||
val screenName = arguments.getString(EXTRA_SCREEN_NAME)
|
||||
if (userKey != null) {
|
||||
sb.append(userKey)
|
||||
@ -90,13 +90,13 @@ class UserListTimelineFragment : ParcelableStatusesFragment() {
|
||||
override fun onCreateStatusesLoader(context: Context, args: Bundle, fromUser: Boolean):
|
||||
Loader<List<ParcelableStatus>?> {
|
||||
refreshing = true
|
||||
val listId = args.getString(EXTRA_LIST_ID)
|
||||
val accountKey = Utils.getAccountKey(context, args)
|
||||
val listId = args.getString(EXTRA_LIST_ID)
|
||||
val userKey = args.getParcelable<UserKey?>(EXTRA_USER_KEY)
|
||||
val listName = args.getString(EXTRA_LIST_NAME)
|
||||
val maxId = args.getString(EXTRA_MAX_ID)
|
||||
val sinceId = args.getString(EXTRA_SINCE_ID)
|
||||
val userKey = args.getParcelable<UserKey>(EXTRA_USER_KEY)
|
||||
val screenName = args.getString(EXTRA_SCREEN_NAME)
|
||||
val listName = args.getString(EXTRA_LIST_NAME)
|
||||
val tabPosition = args.getInt(EXTRA_TAB_POSITION, -1)
|
||||
val loadingMore = args.getBoolean(EXTRA_LOADING_MORE, false)
|
||||
return UserListTimelineLoader(activity, accountKey, listId, userKey, screenName,
|
||||
|
@ -33,7 +33,6 @@ import org.mariotaku.twidere.loader.UserListOwnershipsLoader
|
||||
import org.mariotaku.twidere.model.ParcelableUserList
|
||||
import org.mariotaku.twidere.model.UserKey
|
||||
import org.mariotaku.twidere.model.event.UserListDestroyedEvent
|
||||
import org.mariotaku.twidere.util.MenuUtils
|
||||
import org.mariotaku.twidere.util.Utils
|
||||
|
||||
class UserListsOwnershipsFragment : ParcelableUserListsFragment() {
|
||||
@ -41,12 +40,12 @@ class UserListsOwnershipsFragment : ParcelableUserListsFragment() {
|
||||
private val screenName: String?
|
||||
get() = arguments.getString(EXTRA_SCREEN_NAME)
|
||||
|
||||
private val userId: UserKey?
|
||||
get() = arguments.getParcelable<UserKey>(EXTRA_USER_KEY)
|
||||
private val userKey: UserKey?
|
||||
get() = arguments.getParcelable<UserKey?>(EXTRA_USER_KEY)
|
||||
|
||||
override fun onCreateUserListsLoader(context: Context, args: Bundle, fromUser: Boolean): Loader<List<ParcelableUserList>> {
|
||||
val accountKey = args.getParcelable<UserKey>(EXTRA_ACCOUNT_KEY)
|
||||
val userKey = args.getParcelable<UserKey>(EXTRA_USER_KEY)
|
||||
val accountKey = args.getParcelable<UserKey?>(EXTRA_ACCOUNT_KEY)
|
||||
val userKey = args.getParcelable<UserKey?>(EXTRA_USER_KEY)
|
||||
val screenName = args.getString(EXTRA_SCREEN_NAME)
|
||||
return UserListOwnershipsLoader(activity, accountKey, userKey, screenName, nextCursor, data)
|
||||
}
|
||||
@ -75,13 +74,11 @@ class UserListsOwnershipsFragment : ParcelableUserListsFragment() {
|
||||
}
|
||||
|
||||
override fun onPrepareOptionsMenu(menu: Menu) {
|
||||
val item = menu.findItem(R.id.new_user_list)
|
||||
val accountId = accountKey
|
||||
if (accountId == null || item == null) return
|
||||
if (accountId == userId) {
|
||||
val accountKey = this.accountKey ?: return
|
||||
val screenName = this.screenName
|
||||
if (accountKey == userKey) {
|
||||
menu.setItemAvailability(R.id.new_user_list, true)
|
||||
} else {
|
||||
val screenName = this.screenName
|
||||
menu.setItemAvailability(R.id.new_user_list, screenName != null &&
|
||||
Utils.isMyAccount(activity, screenName))
|
||||
}
|
||||
|
@ -15,10 +15,10 @@ class UserMediaTimelineFragment : AbsMediaStatusesFragment() {
|
||||
|
||||
override fun onCreateStatusesLoader(context: Context, args: Bundle, fromUser: Boolean):
|
||||
Loader<List<ParcelableStatus>?> {
|
||||
val accountKey = args.getParcelable<UserKey>(EXTRA_ACCOUNT_KEY)
|
||||
val accountKey = args.getParcelable<UserKey?>(EXTRA_ACCOUNT_KEY)
|
||||
val userKey = args.getParcelable<UserKey?>(EXTRA_USER_KEY)
|
||||
val maxId = args.getString(EXTRA_MAX_ID)
|
||||
val sinceId = args.getString(EXTRA_SINCE_ID)
|
||||
val userKey = args.getParcelable<UserKey>(EXTRA_USER_KEY)
|
||||
val screenName = args.getString(EXTRA_SCREEN_NAME)
|
||||
val tabPosition = args.getInt(EXTRA_TAB_POSITION, -1)
|
||||
val loadingMore = args.getBoolean(EXTRA_LOADING_MORE, false)
|
||||
|
@ -46,7 +46,7 @@ class UserMentionsFragment : StatusesSearchFragment() {
|
||||
args: Bundle,
|
||||
fromUser: Boolean): Loader<List<ParcelableStatus>?> {
|
||||
val screenName = args.getString(EXTRA_SCREEN_NAME)
|
||||
val accountKey = args.getParcelable<UserKey>(EXTRA_ACCOUNT_KEY)
|
||||
val accountKey = args.getParcelable<UserKey?>(EXTRA_ACCOUNT_KEY)
|
||||
val maxId = args.getString(EXTRA_MAX_ID)
|
||||
val sinceId = args.getString(EXTRA_SINCE_ID)
|
||||
val page = args.getInt(EXTRA_PAGE, -1)
|
||||
|
@ -51,8 +51,8 @@ class UserTimelineFragment : ParcelableStatusesFragment() {
|
||||
|
||||
override val savedStatusesFileArgs: Array<String>?
|
||||
get() {
|
||||
val accountKey = Utils.getAccountKey(context, arguments)!!
|
||||
val userKey = arguments.getParcelable<UserKey>(EXTRA_USER_KEY)
|
||||
val accountKey = Utils.getAccountKey(context, arguments)
|
||||
val userKey = arguments.getParcelable<UserKey?>(EXTRA_USER_KEY)
|
||||
val screenName = arguments.getString(EXTRA_SCREEN_NAME)
|
||||
val result = ArrayList<String>()
|
||||
result.add(AUTHORITY_USER_TIMELINE)
|
||||
|
@ -172,10 +172,10 @@ class FilteredUsersFragment : BaseFiltersFragment() {
|
||||
|
||||
icon.visibility = View.GONE
|
||||
|
||||
val userId = UserKey.valueOf(cursor.getString(indices[Filters.Users.USER_KEY]))
|
||||
val userKey = UserKey.valueOf(cursor.getString(indices[Filters.Users.USER_KEY]))
|
||||
val name = cursor.getString(indices[Filters.Users.NAME])
|
||||
val screenName = cursor.getString(indices[Filters.Users.SCREEN_NAME])
|
||||
val displayName = userColorNameManager.getDisplayName(userId, name, screenName,
|
||||
val displayName = userColorNameManager.getDisplayName(userKey, name, screenName,
|
||||
nameFirst)
|
||||
text1.text = displayName
|
||||
|
||||
@ -189,7 +189,7 @@ class FilteredUsersFragment : BaseFiltersFragment() {
|
||||
ssb.setSpan(EmojiSpan(drawable), start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
|
||||
}
|
||||
text1.text = ssb
|
||||
text2.text = userId.host
|
||||
text2.text = userKey.host
|
||||
}
|
||||
|
||||
override fun swapCursor(c: Cursor?): Cursor? {
|
||||
|
@ -41,8 +41,18 @@ import java.lang.ref.WeakReference
|
||||
|
||||
class ImagePageFragment : SubsampleImageViewerFragment() {
|
||||
|
||||
|
||||
private val media: ParcelableMedia?
|
||||
get() = arguments.getParcelable<ParcelableMedia?>(EXTRA_MEDIA)
|
||||
|
||||
private val accountKey: UserKey?
|
||||
get() = arguments.getParcelable<UserKey?>(EXTRA_ACCOUNT_KEY)
|
||||
|
||||
private val sizedResultCreator: CacheDownloadLoader.ResultCreator by lazy {
|
||||
return@lazy SizedResultCreator(context)
|
||||
}
|
||||
|
||||
private var mediaLoadState: Int = 0
|
||||
private val sizedResultCreator: CacheDownloadLoader.ResultCreator by lazy { SizedResultCreator(context) }
|
||||
|
||||
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
||||
super.onActivityCreated(savedInstanceState)
|
||||
@ -57,13 +67,13 @@ class ImagePageFragment : SubsampleImageViewerFragment() {
|
||||
}
|
||||
|
||||
override fun getDownloadUri(): Uri? {
|
||||
return media.media_url?.let(Uri::parse)
|
||||
return media?.media_url?.let(Uri::parse)
|
||||
}
|
||||
|
||||
override fun getDownloadExtra(): Any? {
|
||||
val mediaExtra = MediaExtra()
|
||||
mediaExtra.accountKey = accountKey
|
||||
mediaExtra.fallbackUrl = media.preview_url
|
||||
mediaExtra.fallbackUrl = media?.preview_url
|
||||
mediaExtra.isSkipUrlReplacing = mediaExtra.fallbackUrl != downloadUri?.toString()
|
||||
return mediaExtra
|
||||
}
|
||||
@ -107,12 +117,6 @@ class ImagePageFragment : SubsampleImageViewerFragment() {
|
||||
return sizedResultCreator
|
||||
}
|
||||
|
||||
private val media: ParcelableMedia
|
||||
get() = arguments.getParcelable<ParcelableMedia>(EXTRA_MEDIA)
|
||||
|
||||
private val accountKey: UserKey
|
||||
get() = arguments.getParcelable<UserKey>(EXTRA_ACCOUNT_KEY)
|
||||
|
||||
internal class SizedResult(cacheUri: Uri, val width: Int, val height: Int) : CacheDownloadLoader.Result(cacheUri, null)
|
||||
|
||||
internal class SizedResultCreator(context: Context) : CacheDownloadLoader.ResultCreator {
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
package org.mariotaku.twidere.loader
|
||||
|
||||
import android.accounts.AccountManager
|
||||
import android.content.Context
|
||||
import android.support.v4.content.FixedAsyncTaskLoader
|
||||
import android.util.Log
|
||||
@ -32,11 +33,12 @@ import org.mariotaku.microblog.library.twitter.model.UserList
|
||||
import org.mariotaku.twidere.R
|
||||
import org.mariotaku.twidere.TwidereConstants.LOGTAG
|
||||
import org.mariotaku.twidere.constant.loadItemLimitKey
|
||||
import org.mariotaku.twidere.extension.model.newMicroBlogInstance
|
||||
import org.mariotaku.twidere.loader.iface.ICursorSupportLoader
|
||||
import org.mariotaku.twidere.model.ParcelableUserList
|
||||
import org.mariotaku.twidere.model.UserKey
|
||||
import org.mariotaku.twidere.model.util.AccountUtils
|
||||
import org.mariotaku.twidere.model.util.ParcelableUserListUtils
|
||||
import org.mariotaku.twidere.util.MicroBlogAPIFactory
|
||||
import org.mariotaku.twidere.util.SharedPreferencesWrapper
|
||||
import org.mariotaku.twidere.util.collection.NoDuplicatesArrayList
|
||||
import org.mariotaku.twidere.util.dagger.GeneralComponentHelper
|
||||
@ -46,7 +48,7 @@ import javax.inject.Inject
|
||||
|
||||
abstract class BaseUserListsLoader(
|
||||
context: Context,
|
||||
protected val accountId: UserKey,
|
||||
protected val accountKey: UserKey?,
|
||||
override val cursor: Long,
|
||||
data: List<ParcelableUserList>?
|
||||
) : FixedAsyncTaskLoader<List<ParcelableUserList>>(context), ICursorSupportLoader {
|
||||
@ -71,9 +73,12 @@ abstract class BaseUserListsLoader(
|
||||
abstract fun getUserLists(twitter: MicroBlog, paging: Paging): List<UserList>
|
||||
|
||||
override fun loadInBackground(): List<ParcelableUserList> {
|
||||
val twitter = MicroBlogAPIFactory.getInstance(context, accountId) ?: return data
|
||||
if (accountKey == null) return emptyList()
|
||||
var listLoaded: List<UserList>? = null
|
||||
try {
|
||||
val am = AccountManager.get(context)
|
||||
val details = AccountUtils.getAccountDetails(am, accountKey, true) ?: return data
|
||||
val twitter = details.newMicroBlogInstance(context, MicroBlog::class.java)
|
||||
val paging = Paging()
|
||||
paging.count(preferences[loadItemLimitKey].coerceIn(0, 100))
|
||||
if (cursor > 0) {
|
||||
@ -92,13 +97,13 @@ abstract class BaseUserListsLoader(
|
||||
val dataSize = data.size
|
||||
for (i in 0..listSize - 1) {
|
||||
val list = listLoaded[i]
|
||||
data.add(ParcelableUserListUtils.from(list, accountId, (dataSize + i).toLong(),
|
||||
data.add(ParcelableUserListUtils.from(list, accountKey, (dataSize + i).toLong(),
|
||||
isFollowing(list), profileImageSize))
|
||||
}
|
||||
} else {
|
||||
for (i in 0..listSize - 1) {
|
||||
val list = listLoaded[i]
|
||||
data.add(ParcelableUserListUtils.from(listLoaded[i], accountId, i.toLong(),
|
||||
data.add(ParcelableUserListUtils.from(listLoaded[i], accountKey, i.toLong(),
|
||||
isFollowing(list), profileImageSize))
|
||||
}
|
||||
}
|
||||
|
@ -108,8 +108,8 @@ class MediaTimelineLoader(
|
||||
@WorkerThread
|
||||
override fun shouldFilterStatus(database: SQLiteDatabase, status: ParcelableStatus): Boolean {
|
||||
if (status.media.isNullOrEmpty()) return false
|
||||
val retweetUserId = if (status.is_retweet) status.user_key else null
|
||||
return !isMyTimeline && InternalTwitterContentUtils.isFiltered(database, retweetUserId,
|
||||
val retweetUserKey = status.user_key.takeIf { status.is_retweet }
|
||||
return !isMyTimeline && InternalTwitterContentUtils.isFiltered(database, retweetUserKey,
|
||||
status.text_plain, status.quoted_text_plain, status.spans, status.quoted_spans,
|
||||
status.source, status.quoted_source, null, status.quoted_user_key)
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ class MutesUsersLoader(
|
||||
}
|
||||
|
||||
override fun onLoadInBackground(): List<ParcelableUser> {
|
||||
filteredUsers = DataStoreUtils.getFilteredUserIds(context)
|
||||
filteredUsers = DataStoreUtils.getFilteredUserKeys(context)
|
||||
return super.onLoadInBackground()
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,7 @@ import org.mariotaku.twidere.util.InternalTwitterContentUtils
|
||||
|
||||
class PublicTimelineLoader(
|
||||
context: Context,
|
||||
accountId: UserKey?,
|
||||
accountKey: UserKey?,
|
||||
sinceId: String?,
|
||||
maxId: String?,
|
||||
adapterData: List<ParcelableStatus>?,
|
||||
@ -42,7 +42,7 @@ class PublicTimelineLoader(
|
||||
tabPosition: Int,
|
||||
fromUser: Boolean,
|
||||
loadingMore: Boolean
|
||||
) : MicroBlogAPIStatusesLoader(context, accountId, sinceId, maxId, -1, adapterData, savedStatusesArgs,
|
||||
) : MicroBlogAPIStatusesLoader(context, accountKey, sinceId, maxId, -1, adapterData, savedStatusesArgs,
|
||||
tabPosition, fromUser, loadingMore) {
|
||||
|
||||
@Throws(MicroBlogException::class)
|
||||
|
@ -30,13 +30,11 @@ import org.mariotaku.twidere.TwidereConstants.LOGTAG
|
||||
import org.mariotaku.twidere.model.UserKey
|
||||
import org.mariotaku.twidere.util.MicroBlogAPIFactory
|
||||
|
||||
class SavedSearchesLoader(
|
||||
context: Context,
|
||||
private val accountId: UserKey
|
||||
) : FixedAsyncTaskLoader<ResponseList<SavedSearch>>(context), Constants {
|
||||
class SavedSearchesLoader(context: Context, private val accountKey: UserKey) :
|
||||
FixedAsyncTaskLoader<ResponseList<SavedSearch>>(context), Constants {
|
||||
|
||||
override fun loadInBackground(): ResponseList<SavedSearch>? {
|
||||
val twitter = MicroBlogAPIFactory.getInstance(context, accountId) ?: return null
|
||||
val twitter = MicroBlogAPIFactory.getInstance(context, accountKey) ?: return null
|
||||
try {
|
||||
return twitter.savedSearches
|
||||
} catch (e: MicroBlogException) {
|
||||
|
@ -30,7 +30,7 @@ import org.mariotaku.twidere.model.UserKey
|
||||
|
||||
class StatusRetweetersLoader(
|
||||
context: Context,
|
||||
accountKey: UserKey,
|
||||
accountKey: UserKey?,
|
||||
private val statusId: String,
|
||||
data: List<ParcelableUser>?,
|
||||
fromUser: Boolean
|
||||
|
@ -30,12 +30,8 @@ import org.mariotaku.twidere.model.ParcelableUser
|
||||
import org.mariotaku.twidere.model.UserKey
|
||||
import org.mariotaku.twidere.util.DataStoreUtils
|
||||
|
||||
class UserBlocksLoader(
|
||||
context: Context,
|
||||
accountKey: UserKey,
|
||||
data: List<ParcelableUser>?,
|
||||
fromUser: Boolean
|
||||
) : CursorSupportUsersLoader(context, accountKey, data, fromUser) {
|
||||
class UserBlocksLoader(context: Context, accountKey: UserKey?, data: List<ParcelableUser>?,
|
||||
fromUser: Boolean) : CursorSupportUsersLoader(context, accountKey, data, fromUser) {
|
||||
|
||||
private var filteredUsers: Array<UserKey>? = null
|
||||
|
||||
@ -52,7 +48,7 @@ class UserBlocksLoader(
|
||||
}
|
||||
|
||||
override fun onLoadInBackground(): List<ParcelableUser> {
|
||||
filteredUsers = DataStoreUtils.getFilteredUserIds(context)
|
||||
filteredUsers = DataStoreUtils.getFilteredUserKeys(context)
|
||||
return super.onLoadInBackground()
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,7 @@ import org.mariotaku.twidere.model.UserKey
|
||||
|
||||
class UserListMembersLoader(
|
||||
context: Context,
|
||||
accountKey: UserKey,
|
||||
accountKey: UserKey?,
|
||||
private val listId: String?,
|
||||
private val userKey: UserKey?,
|
||||
private val screenName: String?,
|
||||
|
@ -31,7 +31,7 @@ import org.mariotaku.twidere.model.UserKey
|
||||
|
||||
class UserListMembershipsLoader(
|
||||
context: Context,
|
||||
accountKey: UserKey,
|
||||
accountKey: UserKey?,
|
||||
private val userKey: UserKey?,
|
||||
private val screenName: String?,
|
||||
cursor: Long,
|
||||
|
@ -29,7 +29,7 @@ import org.mariotaku.twidere.model.UserKey
|
||||
|
||||
class UserListOwnershipsLoader(
|
||||
context: Context,
|
||||
accountKey: UserKey,
|
||||
accountKey: UserKey?,
|
||||
private val userKey: UserKey?,
|
||||
private val screenName: String?,
|
||||
cursor: Long,
|
||||
|
@ -32,7 +32,7 @@ import org.mariotaku.twidere.model.UserKey
|
||||
|
||||
class UserListSubscribersLoader(
|
||||
context: Context,
|
||||
accountKey: UserKey,
|
||||
accountKey: UserKey?,
|
||||
private val listId: String?,
|
||||
private val userKey: UserKey?,
|
||||
private val screenName: String?,
|
||||
|
@ -31,7 +31,7 @@ import org.mariotaku.twidere.model.UserKey
|
||||
|
||||
class UserListSubscriptionsLoader(
|
||||
context: Context,
|
||||
accountKey: UserKey,
|
||||
accountKey: UserKey?,
|
||||
private val userKey: UserKey?,
|
||||
private val screenName: String?,
|
||||
cursor: Long,
|
||||
|
@ -28,7 +28,7 @@ import org.mariotaku.twidere.model.UserKey
|
||||
|
||||
class UserMentionsLoader(
|
||||
context: Context,
|
||||
accountId: UserKey,
|
||||
accountKey: UserKey?,
|
||||
screenName: String,
|
||||
maxId: String?,
|
||||
sinceId: String?,
|
||||
@ -39,7 +39,7 @@ class UserMentionsLoader(
|
||||
fromUser: Boolean,
|
||||
makeGap: Boolean,
|
||||
loadingMore: Boolean
|
||||
) : TweetSearchLoader(context, accountId, screenName, sinceId, maxId, page, data, savedStatusesArgs,
|
||||
) : TweetSearchLoader(context, accountKey, screenName, sinceId, maxId, page, data, savedStatusesArgs,
|
||||
tabPosition, fromUser, makeGap, loadingMore) {
|
||||
|
||||
override fun processQuery(details: AccountDetails, query: String): String {
|
||||
|
@ -31,7 +31,7 @@ import org.mariotaku.twidere.model.UserKey
|
||||
|
||||
open class UserSearchLoader(
|
||||
context: Context,
|
||||
accountKey: UserKey,
|
||||
accountKey: UserKey?,
|
||||
val query: String,
|
||||
val page: Int,
|
||||
data: List<ParcelableUser>?,
|
||||
|
@ -52,7 +52,7 @@ import java.util.concurrent.atomic.AtomicReference
|
||||
|
||||
class UserTimelineLoader(
|
||||
context: Context,
|
||||
accountId: UserKey?,
|
||||
accountKey: UserKey?,
|
||||
private val userKey: UserKey?,
|
||||
private val screenName: String?,
|
||||
private val profileUrl: String?,
|
||||
@ -65,7 +65,7 @@ class UserTimelineLoader(
|
||||
loadingMore: Boolean,
|
||||
val pinnedStatusIds: Array<String>?,
|
||||
val timelineFilter: UserTimelineFilter? = null
|
||||
) : MicroBlogAPIStatusesLoader(context, accountId, sinceId, maxId, -1, data, savedStatusesArgs,
|
||||
) : MicroBlogAPIStatusesLoader(context, accountKey, sinceId, maxId, -1, data, savedStatusesArgs,
|
||||
tabPosition, fromUser, loadingMore) {
|
||||
|
||||
private val pinnedStatusesRef = AtomicReference<List<ParcelableStatus>>()
|
||||
@ -116,11 +116,10 @@ class UserTimelineLoader(
|
||||
|
||||
@WorkerThread
|
||||
override fun shouldFilterStatus(database: SQLiteDatabase, status: ParcelableStatus): Boolean {
|
||||
val accountId = accountKey
|
||||
if (accountId != null && userKey != null && TextUtils.equals(accountId.id, userKey.id))
|
||||
if (accountKey != null && userKey != null && TextUtils.equals(accountKey.id, userKey.id))
|
||||
return false
|
||||
val retweetUserId = if (status.is_retweet) status.user_key else null
|
||||
return InternalTwitterContentUtils.isFiltered(database, retweetUserId, status.text_plain,
|
||||
val retweetUserKey = status.user_key.takeIf { status.is_retweet }
|
||||
return InternalTwitterContentUtils.isFiltered(database, retweetUserKey, status.text_plain,
|
||||
status.quoted_text_plain, status.spans, status.quoted_spans, status.source,
|
||||
status.quoted_source, null, status.quoted_user_key)
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ class AccountActionProvider(
|
||||
var accounts: Array<AccountDetails>? = AccountUtils.getAllAccountDetails(AccountManager.get(context), false)
|
||||
) : ActionProvider(context), TwidereConstants {
|
||||
|
||||
var selectedAccountIds: Array<UserKey>? = null
|
||||
var selectedAccountKeys: Array<UserKey>? = null
|
||||
var isExclusive: Boolean = false
|
||||
|
||||
override fun hasSubMenu(): Boolean {
|
||||
@ -39,7 +39,7 @@ class AccountActionProvider(
|
||||
item.intent = intent
|
||||
}
|
||||
subMenu.setGroupCheckable(MENU_GROUP, true, isExclusive)
|
||||
selectedAccountIds?.let {
|
||||
selectedAccountKeys?.let {
|
||||
for (i in 0 until subMenu.size()) {
|
||||
val item = subMenu.getItem(i)
|
||||
val intent = item.intent
|
||||
|
@ -17,23 +17,23 @@ object ParcelableActivityUtils {
|
||||
/**
|
||||
* @param activity Activity for processing
|
||||
* *
|
||||
* @param filteredUserIds Those ids will be removed from source_ids.
|
||||
* @param filteredUserKeys Those ids will be removed from source_ids.
|
||||
* *
|
||||
* @param followingOnly Limit following users in sources
|
||||
* *
|
||||
* @return true if source ids changed, false otherwise
|
||||
*/
|
||||
fun initAfterFilteredSourceIds(activity: ParcelableActivity, filteredUserIds: Array<UserKey>,
|
||||
fun initAfterFilteredSourceIds(activity: ParcelableActivity, filteredUserKeys: Array<UserKey>,
|
||||
followingOnly: Boolean): Boolean {
|
||||
if (activity.sources == null) return false
|
||||
if (activity.after_filtered_source_ids != null) return false
|
||||
if (followingOnly || filteredUserIds.isNotEmpty()) {
|
||||
if (followingOnly || filteredUserKeys.isNotEmpty()) {
|
||||
val list = activity.sources.filter { user ->
|
||||
if (followingOnly && !user.is_following) {
|
||||
return@filter false
|
||||
}
|
||||
|
||||
if (!filteredUserIds.contains(user.key)) {
|
||||
if (!filteredUserKeys.contains(user.key)) {
|
||||
return@filter true
|
||||
}
|
||||
return@filter false
|
||||
|
@ -124,7 +124,7 @@ object ParcelableStatusUtils {
|
||||
result.in_reply_to_name = getInReplyToName(status)
|
||||
result.in_reply_to_screen_name = status.inReplyToScreenName
|
||||
result.in_reply_to_status_id = status.inReplyToStatusId
|
||||
result.in_reply_to_user_key = getInReplyToUserId(status, accountKey)
|
||||
result.in_reply_to_user_key = getInReplyToUserKey(status, accountKey)
|
||||
|
||||
val user = status.user
|
||||
result.user_key = UserKeyUtils.fromUser(user)
|
||||
@ -188,7 +188,7 @@ object ParcelableStatusUtils {
|
||||
return text.contains("<") && text.contains(">")
|
||||
}
|
||||
|
||||
private fun getInReplyToUserId(status: Status, accountKey: UserKey): UserKey? {
|
||||
private fun getInReplyToUserKey(status: Status, accountKey: UserKey): UserKey? {
|
||||
val inReplyToUserId = status.inReplyToUserId ?: return null
|
||||
val entities = status.userMentionEntities
|
||||
if (entities != null) {
|
||||
|
@ -382,10 +382,11 @@ class TwidereDataProvider : ContentProvider(), LazyLoadCallback {
|
||||
var updated = false
|
||||
if (values != null) {
|
||||
val accountKey = values.getAsString(CachedRelationships.ACCOUNT_KEY)
|
||||
val userId = values.getAsString(CachedRelationships.USER_KEY)
|
||||
val userKey = values.getAsString(CachedRelationships.USER_KEY)
|
||||
val where = Expression.and(Expression.equalsArgs(CachedRelationships.ACCOUNT_KEY),
|
||||
Expression.equalsArgs(CachedRelationships.USER_KEY))
|
||||
if (databaseWrapper.update(table, values, where.sql, arrayOf(accountKey, userId)) > 0) {
|
||||
if (databaseWrapper.update(table, values, where.sql, arrayOf(accountKey,
|
||||
userKey)) > 0) {
|
||||
val projection = arrayOf(CachedRelationships._ID)
|
||||
val c = databaseWrapper.query(table, projection, where.sql, null,
|
||||
null, null, null)
|
||||
|
@ -132,8 +132,8 @@ class CreateFavoriteTask(
|
||||
|
||||
private val creatingFavoriteIds = ArrayIntList()
|
||||
|
||||
fun isCreatingFavorite(accountId: UserKey?, statusId: String?): Boolean {
|
||||
return creatingFavoriteIds.contains(calculateHashCode(accountId, statusId))
|
||||
fun isCreatingFavorite(accountKey: UserKey?, statusId: String?): Boolean {
|
||||
return creatingFavoriteIds.contains(calculateHashCode(accountKey, statusId))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -69,7 +69,7 @@ class GetActivitiesAboutMeTask(context: Context) : GetActivitiesTask(context) {
|
||||
statuses = twitter.getMentionsTimeline(paging)
|
||||
}
|
||||
}
|
||||
statuses.mapTo(activities) { InternalActivityCreator.status(details.key.id, it) }
|
||||
statuses.mapTo(activities) { InternalActivityCreator.status(it, details.key.id) }
|
||||
return activities
|
||||
}
|
||||
|
||||
|
@ -46,7 +46,7 @@ abstract class GetActivitiesTask(
|
||||
|
||||
override fun doLongOperation(param: RefreshTaskParam): List<TwitterListResponse<Activity>> {
|
||||
if (param.shouldAbort) return emptyList()
|
||||
val accountIds = param.accountKeys
|
||||
val accountKeys = param.accountKeys
|
||||
val maxIds = param.maxIds
|
||||
val maxSortIds = param.maxSortIds
|
||||
val sinceIds = param.sinceIds
|
||||
@ -54,8 +54,8 @@ abstract class GetActivitiesTask(
|
||||
val result = ArrayList<TwitterListResponse<Activity>>()
|
||||
val loadItemLimit = preferences[loadItemLimitKey]
|
||||
var saveReadPosition = false
|
||||
for (i in accountIds.indices) {
|
||||
val accountKey = accountIds[i]
|
||||
for (i in accountKeys.indices) {
|
||||
val accountKey = accountKeys[i]
|
||||
val noItemsBefore = DataStoreUtils.getActivitiesCount(context, contentUri, accountKey) <= 0
|
||||
val credentials = AccountUtils.getAccountDetails(AccountManager.get(context), accountKey, true) ?: continue
|
||||
val microBlog = credentials.newMicroBlogInstance(context = context, cls = MicroBlog::class.java)
|
||||
|
@ -231,8 +231,8 @@ class AsyncTwitterWrapper(
|
||||
return true
|
||||
}
|
||||
|
||||
fun getLocalTrendsAsync(accountId: UserKey, woeId: Int) {
|
||||
val task = GetTrendsTask(context, accountId, woeId)
|
||||
fun getLocalTrendsAsync(accountKey: UserKey, woeId: Int) {
|
||||
val task = GetTrendsTask(context, accountKey, woeId)
|
||||
TaskStarter.execute<Any, Unit, Any>(task)
|
||||
}
|
||||
|
||||
@ -252,8 +252,8 @@ class AsyncTwitterWrapper(
|
||||
return sendingDraftIds.toArray()
|
||||
}
|
||||
|
||||
fun isDestroyingStatus(accountId: UserKey?, statusId: String?): Boolean {
|
||||
return destroyingStatusIds.contains(calculateHashCode(accountId, statusId))
|
||||
fun isDestroyingStatus(accountKey: UserKey?, statusId: String?): Boolean {
|
||||
return destroyingStatusIds.contains(calculateHashCode(accountKey, statusId))
|
||||
}
|
||||
|
||||
fun isStatusTimelineRefreshing(uri: Uri): Boolean {
|
||||
@ -376,9 +376,9 @@ class AsyncTwitterWrapper(
|
||||
override val exceptionClass = MicroBlogException::class.java
|
||||
|
||||
override fun onExecute(params: Any?) {
|
||||
for (accountId in accountKeys) {
|
||||
val microBlog = MicroBlogAPIFactory.getInstance(context, accountId) ?: continue
|
||||
if (!Utils.isOfficialCredentials(context, accountId)) continue
|
||||
for (accountKey in accountKeys) {
|
||||
val microBlog = MicroBlogAPIFactory.getInstance(context, accountKey) ?: continue
|
||||
if (!Utils.isOfficialCredentials(context, accountKey)) continue
|
||||
microBlog.setActivitiesAboutMeUnread(cursor)
|
||||
}
|
||||
}
|
||||
@ -386,16 +386,16 @@ class AsyncTwitterWrapper(
|
||||
TaskStarter.execute(task)
|
||||
}
|
||||
|
||||
fun addUpdatingRelationshipId(accountKey: UserKey, userId: UserKey) {
|
||||
updatingRelationshipIds.add(ParcelableUser.calculateHashCode(accountKey, userId))
|
||||
fun addUpdatingRelationshipId(accountKey: UserKey, userKey: UserKey) {
|
||||
updatingRelationshipIds.add(ParcelableUser.calculateHashCode(accountKey, userKey))
|
||||
}
|
||||
|
||||
fun removeUpdatingRelationshipId(accountKey: UserKey, userId: UserKey) {
|
||||
updatingRelationshipIds.removeElement(ParcelableUser.calculateHashCode(accountKey, userId))
|
||||
fun removeUpdatingRelationshipId(accountKey: UserKey, userKey: UserKey) {
|
||||
updatingRelationshipIds.removeElement(ParcelableUser.calculateHashCode(accountKey, userKey))
|
||||
}
|
||||
|
||||
fun isUpdatingRelationship(accountId: UserKey, userId: UserKey): Boolean {
|
||||
return updatingRelationshipIds.contains(ParcelableUser.calculateHashCode(accountId, userId))
|
||||
fun isUpdatingRelationship(accountKey: UserKey, userKey: UserKey): Boolean {
|
||||
return updatingRelationshipIds.contains(ParcelableUser.calculateHashCode(accountKey, userKey))
|
||||
}
|
||||
|
||||
internal inner class CreateMultiBlockTask(
|
||||
@ -553,8 +553,8 @@ class AsyncTwitterWrapper(
|
||||
override fun doInBackground(vararg params: Any): SingleResponse<ParcelableUserList> {
|
||||
val microBlog = MicroBlogAPIFactory.getInstance(context, accountKey) ?: return SingleResponse.getInstance<ParcelableUserList>()
|
||||
try {
|
||||
val userIds = users.map { it.key }.toTypedArray()
|
||||
val userList = microBlog.deleteUserListMembers(userListId, UserKey.getIds(userIds))
|
||||
val userKeys = users.map { it.key }.toTypedArray()
|
||||
val userList = microBlog.deleteUserListMembers(userListId, UserKey.getIds(userKeys))
|
||||
val list = ParcelableUserListUtils.from(userList, accountKey)
|
||||
return SingleResponse.getInstance(list)
|
||||
} catch (e: MicroBlogException) {
|
||||
@ -657,8 +657,8 @@ class AsyncTwitterWrapper(
|
||||
|
||||
companion object {
|
||||
|
||||
fun calculateHashCode(accountId: UserKey?, statusId: String?): Int {
|
||||
return (accountId?.hashCode() ?: 0) xor (statusId?.hashCode() ?: 0)
|
||||
fun calculateHashCode(accountKey: UserKey?, statusId: String?): Int {
|
||||
return (accountKey?.hashCode() ?: 0) xor (statusId?.hashCode() ?: 0)
|
||||
}
|
||||
|
||||
fun <T : Response<*>> getException(responses: List<T>): Exception? {
|
||||
|
@ -191,7 +191,7 @@ class ContentNotificationManager(
|
||||
|
||||
var timestamp = -1L
|
||||
var newMaxPositionKey = -1L
|
||||
val filteredUserIds = DataStoreUtils.getFilteredUserIds(context)
|
||||
val filteredUserKeys = DataStoreUtils.getFilteredUserKeys(context)
|
||||
var consumed = 0
|
||||
val remaining = c.forEachRow(5) { cur, _ ->
|
||||
val activity = ci.newObject(cur)
|
||||
@ -206,7 +206,7 @@ class ContentNotificationManager(
|
||||
if (activity.status_id != null && FilterQueryBuilder.isFiltered(cr, activity)) {
|
||||
return@forEachRow false
|
||||
}
|
||||
ParcelableActivityUtils.initAfterFilteredSourceIds(activity, filteredUserIds,
|
||||
ParcelableActivityUtils.initAfterFilteredSourceIds(activity, filteredUserKeys,
|
||||
pref.isNotificationFollowingOnly)
|
||||
val sources = ParcelableActivityUtils.getAfterFilteredSources(activity)
|
||||
|
||||
|
@ -256,9 +256,9 @@ object DataStoreUtils {
|
||||
}, accountKeys)
|
||||
}
|
||||
|
||||
fun getStatusCount(context: Context, uri: Uri, accountId: UserKey): Int {
|
||||
fun getStatusCount(context: Context, uri: Uri, accountKey: UserKey): Int {
|
||||
val where = Expression.equalsArgs(AccountSupportColumns.ACCOUNT_KEY).sql
|
||||
val whereArgs = arrayOf(accountId.toString())
|
||||
val whereArgs = arrayOf(accountKey.toString())
|
||||
return queryCount(context.contentResolver, uri, where, whereArgs)
|
||||
}
|
||||
|
||||
@ -270,7 +270,7 @@ object DataStoreUtils {
|
||||
|
||||
|
||||
@SuppressLint("Recycle")
|
||||
fun getFilteredUserIds(context: Context?): Array<UserKey> {
|
||||
fun getFilteredUserKeys(context: Context?): Array<UserKey> {
|
||||
if (context == null) return emptyArray()
|
||||
val resolver = context.contentResolver
|
||||
val projection = arrayOf(Filters.Users.USER_KEY)
|
||||
@ -814,8 +814,8 @@ object DataStoreUtils {
|
||||
}
|
||||
}
|
||||
|
||||
fun getInteractionsCount(context: Context, extraArgs: Bundle?,
|
||||
accountIds: Array<UserKey>, since: Long, sinceColumn: String): Int {
|
||||
fun getInteractionsCount(context: Context, extraArgs: Bundle?, accountKeys: Array<UserKey>,
|
||||
since: Long, sinceColumn: String): Int {
|
||||
var extraWhere: Expression? = null
|
||||
var extraWhereArgs: Array<String>? = null
|
||||
var followingOnly = false
|
||||
@ -832,7 +832,7 @@ object DataStoreUtils {
|
||||
}
|
||||
}
|
||||
return getActivitiesCount(context, Activities.AboutMe.CONTENT_URI, extraWhere, extraWhereArgs,
|
||||
sinceColumn, since, followingOnly, accountIds)
|
||||
sinceColumn, since, followingOnly, accountKeys)
|
||||
}
|
||||
|
||||
fun addToFilter(context: Context, users: Collection<ParcelableUser>, filterAnywhere: Boolean) {
|
||||
|
@ -17,7 +17,6 @@ import org.mariotaku.twidere.R
|
||||
import org.mariotaku.twidere.TwidereConstants.*
|
||||
import org.mariotaku.twidere.activity.MediaViewerActivity
|
||||
import org.mariotaku.twidere.annotation.Referral
|
||||
import org.mariotaku.twidere.constant.IntentConstants
|
||||
import org.mariotaku.twidere.fragment.SensitiveContentWarningDialogFragment
|
||||
import org.mariotaku.twidere.model.*
|
||||
import org.mariotaku.twidere.model.util.ParcelableLocationUtils
|
||||
@ -483,20 +482,20 @@ object IntentUtils {
|
||||
}
|
||||
|
||||
fun openUserListDetails(context: Context, accountKey: UserKey?, listId: String?,
|
||||
userId: UserKey?, screenName: String?, listName: String?) {
|
||||
context.startActivity(userListDetails(accountKey, listId, userId, screenName, listName))
|
||||
userKey: UserKey?, screenName: String?, listName: String?) {
|
||||
context.startActivity(userListDetails(accountKey, listId, userKey, screenName, listName))
|
||||
}
|
||||
|
||||
fun userListDetails(accountKey: UserKey?, listId: String?, userId: UserKey?, screenName: String?,
|
||||
listName: String?): Intent {
|
||||
fun userListDetails(accountKey: UserKey?, listId: String?, userKey: UserKey?,
|
||||
screenName: String?, listName: String?): Intent {
|
||||
return Intent(Intent.ACTION_VIEW, getTwidereUserListRelatedLink(AUTHORITY_USER_LIST,
|
||||
accountKey, listId, userId, screenName, listName))
|
||||
accountKey, listId, userKey, screenName, listName))
|
||||
}
|
||||
|
||||
fun userListTimeline(accountKey: UserKey?, listId: String?, userId: UserKey?, screenName: String?,
|
||||
listName: String?): Intent {
|
||||
fun userListTimeline(accountKey: UserKey?, listId: String?, userKey: UserKey?,
|
||||
screenName: String?, listName: String?): Intent {
|
||||
return Intent(Intent.ACTION_VIEW, getTwidereUserListRelatedLink(AUTHORITY_USER_LIST_TIMELINE,
|
||||
accountKey, listId, userId, screenName, listName))
|
||||
accountKey, listId, userKey, screenName, listName))
|
||||
}
|
||||
|
||||
fun openUserListDetails(context: Context, userList: ParcelableUserList) {
|
||||
@ -556,9 +555,7 @@ object IntentUtils {
|
||||
}
|
||||
|
||||
|
||||
fun openUserGroups(context: Context,
|
||||
accountKey: UserKey?,
|
||||
userId: UserKey?,
|
||||
fun openUserGroups(context: Context, accountKey: UserKey?, userKey: UserKey?,
|
||||
screenName: String?) {
|
||||
val builder = Uri.Builder()
|
||||
builder.scheme(SCHEME_TWIDERE)
|
||||
@ -566,8 +563,8 @@ object IntentUtils {
|
||||
if (accountKey != null) {
|
||||
builder.appendQueryParameter(QUERY_PARAM_ACCOUNT_KEY, accountKey.toString())
|
||||
}
|
||||
if (userId != null) {
|
||||
builder.appendQueryParameter(QUERY_PARAM_USER_KEY, userId.toString())
|
||||
if (userKey != null) {
|
||||
builder.appendQueryParameter(QUERY_PARAM_USER_KEY, userKey.toString())
|
||||
}
|
||||
if (screenName != null) {
|
||||
builder.appendQueryParameter(QUERY_PARAM_SCREEN_NAME, screenName)
|
||||
@ -639,13 +636,13 @@ object IntentUtils {
|
||||
return intent
|
||||
}
|
||||
|
||||
fun openProfileEditor(context: Context, accountId: UserKey?) {
|
||||
fun openProfileEditor(context: Context, accountKey: UserKey?) {
|
||||
val intent = Intent()
|
||||
val builder = Uri.Builder()
|
||||
builder.scheme(SCHEME_TWIDERE)
|
||||
builder.authority(AUTHORITY_PROFILE_EDITOR)
|
||||
if (accountId != null) {
|
||||
builder.appendQueryParameter(QUERY_PARAM_ACCOUNT_KEY, accountId.toString())
|
||||
if (accountKey != null) {
|
||||
builder.appendQueryParameter(QUERY_PARAM_ACCOUNT_KEY, accountKey.toString())
|
||||
}
|
||||
intent.data = builder.build()
|
||||
intent.`package` = BuildConfig.APPLICATION_ID
|
||||
|
@ -67,7 +67,7 @@ object LinkCreator {
|
||||
}
|
||||
|
||||
fun getTwidereUserListRelatedLink(authority: String, accountKey: UserKey?, listId: String?,
|
||||
userId: UserKey?, screenName: String?, listName: String?): Uri {
|
||||
userKey: UserKey?, screenName: String?, listName: String?): Uri {
|
||||
val builder = Uri.Builder()
|
||||
builder.scheme(SCHEME_TWIDERE)
|
||||
builder.authority(authority)
|
||||
@ -77,8 +77,8 @@ object LinkCreator {
|
||||
if (listId != null) {
|
||||
builder.appendQueryParameter(QUERY_PARAM_LIST_ID, listId)
|
||||
}
|
||||
if (userId != null) {
|
||||
builder.appendQueryParameter(QUERY_PARAM_USER_KEY, userId.toString())
|
||||
if (userKey != null) {
|
||||
builder.appendQueryParameter(QUERY_PARAM_USER_KEY, userKey.toString())
|
||||
}
|
||||
if (screenName != null) {
|
||||
builder.appendQueryParameter(QUERY_PARAM_SCREEN_NAME, screenName)
|
||||
|
@ -119,25 +119,28 @@ class MultiSelectEventHandler(
|
||||
R.id.mute_user -> {
|
||||
val resolver = activity.contentResolver
|
||||
val valuesList = ArrayList<ContentValues>()
|
||||
val userIds = HashSet<UserKey>()
|
||||
for (`object` in selectedItems) {
|
||||
if (`object` is ParcelableStatus) {
|
||||
userIds.add(`object`.user_key)
|
||||
valuesList.add(ContentValuesCreator.createFilteredUser(`object`))
|
||||
} else if (`object` is ParcelableUser) {
|
||||
userIds.add(`object`.key)
|
||||
valuesList.add(ContentValuesCreator.createFilteredUser(`object`))
|
||||
val userKeys = HashSet<UserKey>()
|
||||
for (selectedItem in selectedItems) {
|
||||
when (selectedItem) {
|
||||
is ParcelableStatus -> {
|
||||
userKeys.add(selectedItem.user_key)
|
||||
valuesList.add(ContentValuesCreator.createFilteredUser(selectedItem))
|
||||
}
|
||||
is ParcelableUser -> {
|
||||
userKeys.add(selectedItem.key)
|
||||
valuesList.add(ContentValuesCreator.createFilteredUser(selectedItem))
|
||||
}
|
||||
}
|
||||
}
|
||||
ContentResolverUtils.bulkDelete(resolver, Filters.Users.CONTENT_URI,
|
||||
Filters.Users.USER_KEY, false, userIds, null, null)
|
||||
Filters.Users.USER_KEY, false, userKeys, null, null)
|
||||
ContentResolverUtils.bulkInsert(resolver, Filters.Users.CONTENT_URI, valuesList)
|
||||
Toast.makeText(activity, R.string.message_toast_users_filters_added, Toast.LENGTH_SHORT).show()
|
||||
mode.finish()
|
||||
}
|
||||
R.id.block -> {
|
||||
val accountKey = multiSelectManager.accountKey
|
||||
val userIds = UserKey.getIds(MultiSelectManager.getSelectedUserIds(selectedItems))
|
||||
val userIds = UserKey.getIds(MultiSelectManager.getSelectedUserKeys(selectedItems))
|
||||
if (accountKey != null && userIds != null) {
|
||||
twitterWrapper.createMultiBlockAsync(accountKey, userIds)
|
||||
}
|
||||
@ -145,7 +148,7 @@ class MultiSelectEventHandler(
|
||||
}
|
||||
R.id.report_spam -> {
|
||||
val accountKey = multiSelectManager.accountKey
|
||||
val userIds = UserKey.getIds(MultiSelectManager.getSelectedUserIds(selectedItems))
|
||||
val userIds = UserKey.getIds(MultiSelectManager.getSelectedUserKeys(selectedItems))
|
||||
if (accountKey != null && userIds != null) {
|
||||
twitterWrapper.reportMultiSpam(accountKey, userIds)
|
||||
}
|
||||
@ -157,7 +160,7 @@ class MultiSelectEventHandler(
|
||||
if (intent == null || !intent.hasExtra(EXTRA_ACCOUNT)) return false
|
||||
val account: AccountDetails = intent.getParcelableExtra(EXTRA_ACCOUNT)
|
||||
multiSelectManager.accountKey = account.key
|
||||
accountActionProvider?.selectedAccountIds = arrayOf(account.key)
|
||||
accountActionProvider?.selectedAccountKeys = arrayOf(account.key)
|
||||
mode.invalidate()
|
||||
}
|
||||
return true
|
||||
@ -166,7 +169,7 @@ class MultiSelectEventHandler(
|
||||
override fun onCreateActionMode(mode: ActionMode, menu: Menu): Boolean {
|
||||
mode.menuInflater.inflate(R.menu.action_multi_select_contents, menu)
|
||||
accountActionProvider = menu.findItem(R.id.select_account).actionProvider as AccountActionProvider
|
||||
accountActionProvider?.selectedAccountIds = arrayOf(multiSelectManager.firstSelectAccountKey)
|
||||
accountActionProvider?.selectedAccountKeys = arrayOf(multiSelectManager.firstSelectAccountKey)
|
||||
return true
|
||||
}
|
||||
|
||||
|
@ -40,7 +40,7 @@ abstract class FanfouTimelineStreamCallback(
|
||||
handled = handled or onHomeTimeline(status)
|
||||
}
|
||||
if (target?.id == accountId) {
|
||||
handled = handled or onActivityAboutMe(InternalActivityCreator.status(accountId, status))
|
||||
handled = handled or onActivityAboutMe(InternalActivityCreator.status(status, accountId))
|
||||
}
|
||||
return handled
|
||||
}
|
||||
|
@ -45,13 +45,13 @@ abstract class TwitterTimelineStreamCallback(val accountId: String) : SimpleUser
|
||||
}
|
||||
if (status.inReplyToUserId == accountId) {
|
||||
// Reply
|
||||
handled = handled or onActivityAboutMe(InternalActivityCreator.status(accountId, status))
|
||||
handled = handled or onActivityAboutMe(InternalActivityCreator.status(status, accountId))
|
||||
} else if (userId != accountId && status.retweetedStatus?.user?.id == accountId) {
|
||||
// Retweet
|
||||
handled = handled or onActivityAboutMe(InternalActivityCreator.retweet(status))
|
||||
} else if (status.userMentionEntities?.find { it.id == accountId } != null) {
|
||||
// Mention
|
||||
handled = handled or onActivityAboutMe(InternalActivityCreator.status(accountId, status))
|
||||
handled = handled or onActivityAboutMe(InternalActivityCreator.status(status, accountId))
|
||||
}
|
||||
onAllStatus(status)
|
||||
return handled
|
||||
|
Loading…
x
Reference in New Issue
Block a user