mirror of
https://github.com/TwidereProject/Twidere-Android
synced 2025-02-01 17:26:46 +01:00
removed some broadcasts
This commit is contained in:
parent
2b28a177c0
commit
ebf3deb1d8
@ -73,13 +73,9 @@ public interface IntentConstants {
|
||||
String INTENT_ACTION_PEBBLE_NOTIFICATION = "com.getpebble.action.SEND_NOTIFICATION";
|
||||
|
||||
String BROADCAST_NOTIFICATION_DELETED = INTENT_PACKAGE_PREFIX + "NOTIFICATION_DELETED";
|
||||
String BROADCAST_USER_LIST_DETAILS_UPDATED = INTENT_PACKAGE_PREFIX
|
||||
+ "USER_LIST_DETAILS_UPDATED";
|
||||
|
||||
String BROADCAST_USER_LIST_MEMBERS_DELETED = INTENT_PACKAGE_PREFIX + "USER_LIST_MEMBER_DELETED";
|
||||
String BROADCAST_USER_LIST_MEMBERS_ADDED = INTENT_PACKAGE_PREFIX + "USER_LIST_MEMBER_ADDED";
|
||||
String BROADCAST_USER_LIST_SUBSCRIBED = INTENT_PACKAGE_PREFIX + "USER_LIST_SUBSRCIBED";
|
||||
String BROADCAST_USER_LIST_UNSUBSCRIBED = INTENT_PACKAGE_PREFIX + "USER_LIST_UNSUBSCRIBED";
|
||||
String BROADCAST_REFRESH_HOME_TIMELINE = INTENT_PACKAGE_PREFIX + "REFRESH_HOME_TIMELINE";
|
||||
String BROADCAST_REFRESH_NOTIFICATIONS = INTENT_PACKAGE_PREFIX + "REFRESH_NOTIFICATIONS";
|
||||
String BROADCAST_REFRESH_DIRECT_MESSAGES = INTENT_PACKAGE_PREFIX + "REFRESH_DIRECT_MESSAGES";
|
||||
|
@ -87,6 +87,7 @@ import android.view.View.OnClickListener;
|
||||
import android.view.View.OnLongClickListener;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.Window;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
@ -367,6 +368,11 @@ public class ComposeActivity extends BaseActivity implements OnMenuItemClickList
|
||||
setAccountSelectorVisible(!isAccountSelectorVisible());
|
||||
break;
|
||||
}
|
||||
case R.id.reply_label: {
|
||||
if (mReplyLabel.getVisibility() != View.VISIBLE) return;
|
||||
mReplyLabel.setSingleLine(mReplyLabel.getLineCount() > 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -641,6 +647,7 @@ public class ComposeActivity extends BaseActivity implements OnMenuItemClickList
|
||||
setupEditText();
|
||||
mAccountSelectorContainer.setOnClickListener(this);
|
||||
mAccountSelectorButton.setOnClickListener(this);
|
||||
mReplyLabel.setOnClickListener(this);
|
||||
final boolean attachLocation = mPreferences.getBoolean(KEY_ATTACH_LOCATION);
|
||||
final boolean attachPreciseLocation = mPreferences.getBoolean(KEY_ATTACH_PRECISE_LOCATION);
|
||||
if (attachLocation) {
|
||||
|
@ -31,6 +31,7 @@ import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.database.sqlite.SQLiteOpenHelper;
|
||||
import android.graphics.Color;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Handler;
|
||||
import android.support.annotation.NonNull;
|
||||
@ -169,12 +170,15 @@ public class TwidereApplication extends Application implements Constants,
|
||||
.primaryColor(themeColor)
|
||||
.accentColor(themeColor)
|
||||
.coloredActionBar(true)
|
||||
.coloredStatusBar(true)
|
||||
.commit();
|
||||
}
|
||||
if (!ATE.config(this, VALUE_THEME_NAME_DARK).isConfigured()) {
|
||||
ATE.config(this, VALUE_THEME_NAME_DARK)
|
||||
.accentColor(themeColor)
|
||||
.coloredActionBar(false)
|
||||
.coloredStatusBar(true)
|
||||
.statusBarColor(Color.BLACK)
|
||||
.commit();
|
||||
}
|
||||
if (!ATE.config(this, null).isConfigured()) {
|
||||
@ -352,7 +356,8 @@ public class TwidereApplication extends Application implements Constants,
|
||||
ATE.config(this, VALUE_THEME_NAME_DARK)
|
||||
.accentColor(themeColor)
|
||||
.coloredActionBar(false)
|
||||
.coloredStatusBar(false)
|
||||
.coloredStatusBar(true)
|
||||
.statusBarColor(Color.BLACK)
|
||||
.commit();
|
||||
ATE.config(this, null)
|
||||
.accentColor(themeColor)
|
||||
|
@ -22,11 +22,9 @@ package org.mariotaku.twidere.fragment;
|
||||
import android.app.Activity;
|
||||
import android.app.Dialog;
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.nfc.NdefMessage;
|
||||
import android.nfc.NdefRecord;
|
||||
import android.nfc.NfcAdapter.CreateNdefMessageCallback;
|
||||
@ -50,6 +48,7 @@ import android.view.View.OnClickListener;
|
||||
import android.widget.CheckBox;
|
||||
|
||||
import com.rengwuxian.materialedittext.MaterialEditText;
|
||||
import com.squareup.otto.Subscribe;
|
||||
|
||||
import org.mariotaku.twidere.R;
|
||||
import org.mariotaku.twidere.activity.AccountSelectorActivity;
|
||||
@ -65,6 +64,8 @@ import org.mariotaku.twidere.model.ParcelableUser;
|
||||
import org.mariotaku.twidere.model.ParcelableUserList;
|
||||
import org.mariotaku.twidere.model.SingleResponse;
|
||||
import org.mariotaku.twidere.model.UserKey;
|
||||
import org.mariotaku.twidere.model.message.UserListSubscriptionEvent;
|
||||
import org.mariotaku.twidere.model.message.UserListUpdatedEvent;
|
||||
import org.mariotaku.twidere.model.util.ParcelableUserListUtils;
|
||||
import org.mariotaku.twidere.text.validator.UserListNameValidator;
|
||||
import org.mariotaku.twidere.util.AsyncTwitterWrapper;
|
||||
@ -82,26 +83,6 @@ public class UserListFragment extends AbsToolbarTabPagesFragment implements OnCl
|
||||
private boolean mUserListLoaderInitialized;
|
||||
|
||||
private ParcelableUserList mUserList;
|
||||
private final BroadcastReceiver mStatusReceiver = new BroadcastReceiver() {
|
||||
|
||||
@Override
|
||||
public void onReceive(final Context context, final Intent intent) {
|
||||
if (getActivity() == null || !isAdded() || isDetached()) return;
|
||||
final String action = intent.getAction();
|
||||
final ParcelableUserList userList = intent.getParcelableExtra(EXTRA_USER_LIST);
|
||||
if (userList == null || mUserList == null)
|
||||
return;
|
||||
if (BROADCAST_USER_LIST_DETAILS_UPDATED.equals(action)) {
|
||||
if (userList.id == mUserList.id) {
|
||||
getUserListInfo(true);
|
||||
}
|
||||
} else if (BROADCAST_USER_LIST_SUBSCRIBED.equals(action) || BROADCAST_USER_LIST_UNSUBSCRIBED.equals(action)) {
|
||||
if (userList.id == mUserList.id) {
|
||||
getUserListInfo(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public void displayUserList(final ParcelableUserList userList) {
|
||||
final FragmentActivity activity = getActivity();
|
||||
@ -207,15 +188,12 @@ public class UserListFragment extends AbsToolbarTabPagesFragment implements OnCl
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
final IntentFilter filter = new IntentFilter(BROADCAST_USER_LIST_DETAILS_UPDATED);
|
||||
filter.addAction(BROADCAST_USER_LIST_SUBSCRIBED);
|
||||
filter.addAction(BROADCAST_USER_LIST_UNSUBSCRIBED);
|
||||
registerReceiver(mStatusReceiver, filter);
|
||||
mBus.register(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStop() {
|
||||
unregisterReceiver(mStatusReceiver);
|
||||
mBus.unregister(this);
|
||||
super.onStop();
|
||||
}
|
||||
|
||||
@ -372,6 +350,22 @@ public class UserListFragment extends AbsToolbarTabPagesFragment implements OnCl
|
||||
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onUserListUpdated(UserListUpdatedEvent event) {
|
||||
if (mUserList == null) return;
|
||||
if (event.getUserList().id == mUserList.id) {
|
||||
getUserListInfo(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onUserListSubscriptionChanged(UserListSubscriptionEvent event) {
|
||||
if (mUserList == null) return;
|
||||
if (event.getUserList().id == mUserList.id) {
|
||||
getUserListInfo(true);
|
||||
}
|
||||
}
|
||||
|
||||
public static class EditUserListDialogFragment extends BaseSupportDialogFragment implements
|
||||
DialogInterface.OnClickListener {
|
||||
|
||||
@ -388,6 +382,7 @@ public class UserListFragment extends AbsToolbarTabPagesFragment implements OnCl
|
||||
final MaterialEditText editName = (MaterialEditText) alertDialog.findViewById(R.id.name);
|
||||
final MaterialEditText editDescription = (MaterialEditText) alertDialog.findViewById(R.id.description);
|
||||
final CheckBox editIsPublic = (CheckBox) alertDialog.findViewById(R.id.is_public);
|
||||
assert editName != null && editDescription != null && editIsPublic != null;
|
||||
final String name = ParseUtils.parseString(editName.getText());
|
||||
final String description = ParseUtils.parseString(editDescription.getText());
|
||||
final boolean isPublic = editIsPublic.isChecked();
|
||||
|
@ -0,0 +1,37 @@
|
||||
package org.mariotaku.twidere.model.message;
|
||||
|
||||
import android.support.annotation.IntDef;
|
||||
import android.support.annotation.NonNull;
|
||||
|
||||
import org.mariotaku.twidere.model.ParcelableUserList;
|
||||
|
||||
/**
|
||||
* Created by mariotaku on 16/3/28.
|
||||
*/
|
||||
public class UserListSubscriptionEvent {
|
||||
@Action
|
||||
private final int action;
|
||||
@NonNull
|
||||
private final ParcelableUserList userList;
|
||||
|
||||
public UserListSubscriptionEvent(@Action int action, @NonNull ParcelableUserList userList) {
|
||||
this.action = action;
|
||||
this.userList = userList;
|
||||
}
|
||||
|
||||
@Action
|
||||
public int getAction() {
|
||||
return action;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public ParcelableUserList getUserList() {
|
||||
return userList;
|
||||
}
|
||||
|
||||
@IntDef({Action.SUBSCRIBE, Action.UNSUBSCRIBE})
|
||||
public @interface Action {
|
||||
int SUBSCRIBE = 1;
|
||||
int UNSUBSCRIBE = 2;
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package org.mariotaku.twidere.model.message;
|
||||
|
||||
import android.support.annotation.NonNull;
|
||||
|
||||
import org.mariotaku.twidere.model.ParcelableUserList;
|
||||
|
||||
/**
|
||||
* Created by mariotaku on 16/3/28.
|
||||
*/
|
||||
public class UserListUpdatedEvent {
|
||||
private final ParcelableUserList userList;
|
||||
|
||||
public UserListUpdatedEvent(@NonNull ParcelableUserList userList) {
|
||||
this.userList = userList;
|
||||
}
|
||||
|
||||
public ParcelableUserList getUserList() {
|
||||
return userList;
|
||||
}
|
||||
}
|
@ -64,9 +64,10 @@ public class ParcelableMediaUtils {
|
||||
|
||||
private static ParcelableMedia fromMediaEntity(MediaEntity entity) {
|
||||
final ParcelableMedia media = new ParcelableMedia();
|
||||
media.url = InternalTwitterContentUtils.getMediaUrl(entity);
|
||||
media.media_url = InternalTwitterContentUtils.getMediaUrl(entity);
|
||||
media.preview_url = InternalTwitterContentUtils.getMediaUrl(entity);
|
||||
final String mediaUrl = InternalTwitterContentUtils.getMediaUrl(entity);
|
||||
media.url = mediaUrl;
|
||||
media.media_url = mediaUrl;
|
||||
media.preview_url = mediaUrl;
|
||||
media.start = entity.getStart();
|
||||
media.end = entity.getEnd();
|
||||
media.type = ParcelableMediaUtils.getTypeInt(entity.getType());
|
||||
|
@ -79,17 +79,25 @@ public class RefreshService extends Service implements Constants {
|
||||
if (BuildConfig.DEBUG) {
|
||||
Log.d(LOGTAG, String.format("Refresh service received action %s", action));
|
||||
}
|
||||
if (BROADCAST_RESCHEDULE_HOME_TIMELINE_REFRESHING.equals(action)) {
|
||||
rescheduleHomeTimelineRefreshing();
|
||||
} else if (BROADCAST_RESCHEDULE_MENTIONS_REFRESHING.equals(action)) {
|
||||
rescheduleMentionsRefreshing();
|
||||
} else if (BROADCAST_RESCHEDULE_DIRECT_MESSAGES_REFRESHING.equals(action)) {
|
||||
rescheduleDirectMessagesRefreshing();
|
||||
} else if (BROADCAST_RESCHEDULE_TRENDS_REFRESHING.equals(action)) {
|
||||
rescheduleTrendsRefreshing();
|
||||
} else if (isAutoRefreshAllowed()) {
|
||||
if (BROADCAST_REFRESH_HOME_TIMELINE.equals(action)) {
|
||||
if (!isHomeTimelineRefreshing()) {
|
||||
switch (action) {
|
||||
case BROADCAST_RESCHEDULE_HOME_TIMELINE_REFRESHING: {
|
||||
rescheduleHomeTimelineRefreshing();
|
||||
break;
|
||||
}
|
||||
case BROADCAST_RESCHEDULE_MENTIONS_REFRESHING: {
|
||||
rescheduleMentionsRefreshing();
|
||||
break;
|
||||
}
|
||||
case BROADCAST_RESCHEDULE_DIRECT_MESSAGES_REFRESHING: {
|
||||
rescheduleDirectMessagesRefreshing();
|
||||
break;
|
||||
}
|
||||
case BROADCAST_RESCHEDULE_TRENDS_REFRESHING: {
|
||||
rescheduleTrendsRefreshing();
|
||||
break;
|
||||
}
|
||||
case BROADCAST_REFRESH_HOME_TIMELINE: {
|
||||
if (isAutoRefreshAllowed() && !isHomeTimelineRefreshing()) {
|
||||
mTwitterWrapper.getHomeTimelineAsync(new SimpleRefreshTaskParam() {
|
||||
private UserKey[] accountIds;
|
||||
|
||||
@ -110,28 +118,34 @@ public class RefreshService extends Service implements Constants {
|
||||
}
|
||||
});
|
||||
}
|
||||
} else if (BROADCAST_REFRESH_NOTIFICATIONS.equals(action)) {
|
||||
mTwitterWrapper.getActivitiesAboutMeAsync(new SimpleRefreshTaskParam() {
|
||||
private UserKey[] accountIds;
|
||||
break;
|
||||
}
|
||||
case BROADCAST_REFRESH_NOTIFICATIONS: {
|
||||
if (isAutoRefreshAllowed()) {
|
||||
mTwitterWrapper.getActivitiesAboutMeAsync(new SimpleRefreshTaskParam() {
|
||||
private UserKey[] accountIds;
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public UserKey[] getAccountKeysWorker() {
|
||||
if (accountIds != null) return accountIds;
|
||||
final AccountPreferences[] prefs = AccountPreferences.getAccountPreferences(context,
|
||||
DataStoreUtils.getAccountKeys(context));
|
||||
return accountIds = getRefreshableIds(prefs, MentionsRefreshableFilter.INSTANCE);
|
||||
}
|
||||
@NonNull
|
||||
@Override
|
||||
public UserKey[] getAccountKeysWorker() {
|
||||
if (accountIds != null) return accountIds;
|
||||
final AccountPreferences[] prefs = AccountPreferences.getAccountPreferences(context,
|
||||
DataStoreUtils.getAccountKeys(context));
|
||||
return accountIds = getRefreshableIds(prefs, MentionsRefreshableFilter.INSTANCE);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String[] getSinceIds() {
|
||||
return DataStoreUtils.getNewestActivityMaxPositions(context,
|
||||
Activities.AboutMe.CONTENT_URI, getAccountKeys());
|
||||
}
|
||||
});
|
||||
} else if (BROADCAST_REFRESH_DIRECT_MESSAGES.equals(action)) {
|
||||
if (!isReceivedDirectMessagesRefreshing()) {
|
||||
@Nullable
|
||||
@Override
|
||||
public String[] getSinceIds() {
|
||||
return DataStoreUtils.getNewestActivityMaxPositions(context,
|
||||
Activities.AboutMe.CONTENT_URI, getAccountKeys());
|
||||
}
|
||||
});
|
||||
}
|
||||
break;
|
||||
}
|
||||
case BROADCAST_REFRESH_DIRECT_MESSAGES: {
|
||||
if (isAutoRefreshAllowed() && !isReceivedDirectMessagesRefreshing()) {
|
||||
mTwitterWrapper.getReceivedDirectMessagesAsync(new SimpleRefreshTaskParam() {
|
||||
private UserKey[] accountIds;
|
||||
|
||||
@ -152,15 +166,20 @@ public class RefreshService extends Service implements Constants {
|
||||
}
|
||||
});
|
||||
}
|
||||
} else if (BROADCAST_REFRESH_TRENDS.equals(action)) {
|
||||
final AccountPreferences[] prefs = AccountPreferences.getAccountPreferences(context,
|
||||
DataStoreUtils.getAccountKeys(context));
|
||||
final UserKey[] refreshIds = getRefreshableIds(prefs, TrendsRefreshableFilter.INSTANCE);
|
||||
if (BuildConfig.DEBUG) {
|
||||
Log.d(LOGTAG, String.format("Auto refreshing trends for %s", Arrays.toString(refreshIds)));
|
||||
}
|
||||
if (!isLocalTrendsRefreshing()) {
|
||||
getLocalTrends(refreshIds);
|
||||
break;
|
||||
}
|
||||
case BROADCAST_REFRESH_TRENDS: {
|
||||
if (isAutoRefreshAllowed()) {
|
||||
final AccountPreferences[] prefs = AccountPreferences.getAccountPreferences(context,
|
||||
DataStoreUtils.getAccountKeys(context));
|
||||
final UserKey[] refreshIds = getRefreshableIds(prefs, TrendsRefreshableFilter.INSTANCE);
|
||||
if (BuildConfig.DEBUG) {
|
||||
Log.d(LOGTAG, String.format("Auto refreshing trends for %s", Arrays.toString(refreshIds)));
|
||||
}
|
||||
if (!isLocalTrendsRefreshing()) {
|
||||
getLocalTrends(refreshIds);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -37,6 +37,8 @@ import org.apache.commons.collections.primitives.ArrayIntList;
|
||||
import org.apache.commons.collections.primitives.ArrayLongList;
|
||||
import org.apache.commons.collections.primitives.IntList;
|
||||
import org.apache.commons.collections.primitives.LongList;
|
||||
import org.mariotaku.abstask.library.AbstractTask;
|
||||
import org.mariotaku.abstask.library.TaskStarter;
|
||||
import org.mariotaku.sqliteqb.library.Expression;
|
||||
import org.mariotaku.twidere.BuildConfig;
|
||||
import org.mariotaku.twidere.R;
|
||||
@ -73,6 +75,8 @@ import org.mariotaku.twidere.model.message.StatusListChangedEvent;
|
||||
import org.mariotaku.twidere.model.message.StatusRetweetedEvent;
|
||||
import org.mariotaku.twidere.model.message.UserListCreatedEvent;
|
||||
import org.mariotaku.twidere.model.message.UserListDestroyedEvent;
|
||||
import org.mariotaku.twidere.model.message.UserListSubscriptionEvent;
|
||||
import org.mariotaku.twidere.model.message.UserListUpdatedEvent;
|
||||
import org.mariotaku.twidere.model.message.UsersBlockedEvent;
|
||||
import org.mariotaku.twidere.model.util.ParcelableAccountUtils;
|
||||
import org.mariotaku.twidere.model.util.ParcelableCredentialsUtils;
|
||||
@ -89,7 +93,6 @@ import org.mariotaku.twidere.provider.TwidereDataStore.DirectMessages.Outbox;
|
||||
import org.mariotaku.twidere.provider.TwidereDataStore.Drafts;
|
||||
import org.mariotaku.twidere.provider.TwidereDataStore.Statuses;
|
||||
import org.mariotaku.twidere.service.BackgroundOperationService;
|
||||
import org.mariotaku.abstask.library.AbstractTask;
|
||||
import org.mariotaku.twidere.task.AcceptFriendshipTask;
|
||||
import org.mariotaku.twidere.task.CreateFriendshipTask;
|
||||
import org.mariotaku.twidere.task.CreateUserBlockTask;
|
||||
@ -106,7 +109,6 @@ import org.mariotaku.twidere.task.GetSavedSearchesTask;
|
||||
import org.mariotaku.twidere.task.ManagedAsyncTask;
|
||||
import org.mariotaku.twidere.task.ReportSpamAndBlockTask;
|
||||
import org.mariotaku.twidere.task.twitter.GetActivitiesTask;
|
||||
import org.mariotaku.abstask.library.TaskStarter;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.util.ArrayList;
|
||||
@ -917,9 +919,8 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
if (succeed) {
|
||||
final String message = mContext.getString(R.string.subscribed_to_list, result.getData().name);
|
||||
Utils.showOkMessage(mContext, message, false);
|
||||
final Intent intent = new Intent(BROADCAST_USER_LIST_SUBSCRIBED);
|
||||
intent.putExtra(EXTRA_USER_LIST, result.getData());
|
||||
mContext.sendBroadcast(intent);
|
||||
bus.post(new UserListSubscriptionEvent(UserListSubscriptionEvent.Action.SUBSCRIBE,
|
||||
result.getData()));
|
||||
} else {
|
||||
Utils.showErrorMessage(mContext, R.string.action_subscribing_to_list, result.getException(), true);
|
||||
}
|
||||
@ -1374,9 +1375,8 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
if (succeed) {
|
||||
final String message = mContext.getString(R.string.unsubscribed_from_list, result.getData().name);
|
||||
Utils.showOkMessage(mContext, message, false);
|
||||
final Intent intent = new Intent(BROADCAST_USER_LIST_UNSUBSCRIBED);
|
||||
intent.putExtra(EXTRA_USER_LIST, result.getData());
|
||||
mContext.sendBroadcast(intent);
|
||||
bus.post(new UserListSubscriptionEvent(UserListSubscriptionEvent.Action.UNSUBSCRIBE,
|
||||
result.getData()));
|
||||
} else {
|
||||
Utils.showErrorMessage(mContext, R.string.action_unsubscribing_from_list, result.getException(), true);
|
||||
}
|
||||
@ -1605,12 +1605,10 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(final SingleResponse<ParcelableUserList> result) {
|
||||
if (result.hasData() && result.getData().id > 0) {
|
||||
if (result.hasData()) {
|
||||
final String message = mContext.getString(R.string.updated_list_details, result.getData().name);
|
||||
Utils.showOkMessage(mContext, message, false);
|
||||
final Intent intent = new Intent(BROADCAST_USER_LIST_DETAILS_UPDATED);
|
||||
intent.putExtra(EXTRA_LIST_ID, listId);
|
||||
mContext.sendBroadcast(intent);
|
||||
bus.post(new UserListUpdatedEvent(result.getData()));
|
||||
} else {
|
||||
Utils.showErrorMessage(mContext, R.string.action_updating_details, result.getException(), true);
|
||||
}
|
||||
|
@ -7,8 +7,6 @@ import org.mariotaku.restfu.http.RestHttpClient;
|
||||
import org.mariotaku.twidere.model.ParcelableMedia;
|
||||
import org.mariotaku.twidere.util.UriUtils;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* Created by darkwhite on 1/16/16.
|
||||
*/
|
||||
@ -27,8 +25,8 @@ public class TwitterMediaProvider implements Provider {
|
||||
media.url = link;
|
||||
if (path.startsWith("/media/")) {
|
||||
media.type = ParcelableMedia.Type.IMAGE;
|
||||
media.preview_url = String.format(Locale.ROOT, "%s:medium", link);
|
||||
media.media_url = String.format(Locale.ROOT, "%s:orig", link);
|
||||
media.preview_url = getMediaForSize(link, "medium");
|
||||
media.media_url = getMediaForSize(link, "orig");
|
||||
} else if (path.startsWith("/tweet_video/")) {
|
||||
// Video is not supported yet
|
||||
return null;
|
||||
@ -46,6 +44,10 @@ public class TwitterMediaProvider implements Provider {
|
||||
return from(link);
|
||||
}
|
||||
|
||||
public static String getMediaForSize(@NonNull String link, @NonNull String size) {
|
||||
return link + ":" + size;
|
||||
}
|
||||
|
||||
public static boolean isSupported(@NonNull String link) {
|
||||
final String authority = UriUtils.getAuthority(link);
|
||||
if (authority == null || !authority.endsWith(".twimg.com")) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user