mirror of
https://github.com/TwidereProject/Twidere-Android
synced 2025-02-13 18:20:37 +01:00
migrated Void[] to Object[] for AsyncTask
improved status screen removed internet error toast for refreshes
This commit is contained in:
parent
90e7a068e3
commit
bd0198a623
@ -255,9 +255,6 @@ public interface SharedPreferenceConstants {
|
||||
String KEY_CONSUMER_KEY = "consumer_key";
|
||||
@Preference(type = STRING, hasDefault = true, defaultString = TwidereConstants.TWITTER_CONSUMER_SECRET_3)
|
||||
String KEY_CONSUMER_SECRET = "consumer_secret";
|
||||
String KEY_FILTERS_IN_HOME_TIMELINE = "filters_in_home_timeline";
|
||||
String KEY_FILTERS_IN_MENTIONS_TIMELINE = "filters_in_mentions";
|
||||
String KEY_FILTERS_FOR_RTS = "filters_for_rts";
|
||||
String KEY_SETTINGS_WIZARD_COMPLETED = "settings_wizard_completed";
|
||||
@Preference(type = BOOLEAN, hasDefault = true, defaultBoolean = true)
|
||||
String KEY_CARD_ANIMATION = "card_animation";
|
||||
|
@ -23,7 +23,7 @@ import static org.mariotaku.twidere.util.Utils.copyStream;
|
||||
* Created by Denny C. Ng on 2/20/15.
|
||||
*/
|
||||
|
||||
public class SpiceAsyUploadTask extends AsyncTask<Void, Void, Void> {
|
||||
public class SpiceAsyUploadTask extends AsyncTask<Object, Object, Object> {
|
||||
|
||||
private static final String PROFILE_SERVER_URL = "http://twidere-spice.mariotaku.org:18080/spice/usage";
|
||||
|
||||
@ -73,7 +73,7 @@ public class SpiceAsyUploadTask extends AsyncTask<Void, Void, Void> {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Void doInBackground(final Void... params) {
|
||||
protected Object doInBackground(final Object... params) {
|
||||
|
||||
final SharedPreferences prefs = context.getSharedPreferences("spice_data_profiling", Context.MODE_PRIVATE);
|
||||
|
||||
|
@ -19,7 +19,7 @@ import twitter4j.http.HttpResponse;
|
||||
|
||||
import static org.mariotaku.twidere.util.Utils.copyStream;
|
||||
|
||||
public class UploadTask extends AsyncTask<Void, Void, Void> {
|
||||
public class UploadTask extends AsyncTask<Object, Object, Object> {
|
||||
|
||||
private static final String LAST_UPLOAD_DATE = "last_upload_time";
|
||||
private static final double MILLSECS_HALF_DAY = 1000 * 60 * 60 * 12;
|
||||
@ -74,7 +74,7 @@ public class UploadTask extends AsyncTask<Void, Void, Void> {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Void doInBackground(final Void... params) {
|
||||
protected Object doInBackground(final Object... params) {
|
||||
|
||||
final SharedPreferences prefs = context.getSharedPreferences("ucd_data_profiling", Context.MODE_PRIVATE);
|
||||
|
||||
|
@ -95,12 +95,6 @@ public class FiltersActivity extends BaseActionBarActivity implements TabListene
|
||||
|
||||
@Override
|
||||
public boolean onPrepareOptionsMenu(final Menu menu) {
|
||||
final boolean enable_in_home_timeline = mPreferences.getBoolean(KEY_FILTERS_IN_HOME_TIMELINE, true);
|
||||
final boolean enable_in_mentions = mPreferences.getBoolean(KEY_FILTERS_IN_MENTIONS_TIMELINE, true);
|
||||
final boolean enable_for_rts = mPreferences.getBoolean(KEY_FILTERS_FOR_RTS, true);
|
||||
menu.findItem(R.id.enable_in_home_timeline).setChecked(enable_in_home_timeline);
|
||||
menu.findItem(R.id.enable_in_mentions).setChecked(enable_in_mentions);
|
||||
menu.findItem(R.id.enable_for_rts).setChecked(enable_for_rts);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -131,24 +125,6 @@ public class FiltersActivity extends BaseActionBarActivity implements TabListene
|
||||
dialog.show(getSupportFragmentManager(), "add_rule");
|
||||
return true;
|
||||
}
|
||||
case R.id.enable_in_home_timeline: {
|
||||
final SharedPreferences.Editor editor = mPreferences.edit();
|
||||
editor.putBoolean(KEY_FILTERS_IN_HOME_TIMELINE, !item.isChecked());
|
||||
editor.apply();
|
||||
break;
|
||||
}
|
||||
case R.id.enable_in_mentions: {
|
||||
final SharedPreferences.Editor editor = mPreferences.edit();
|
||||
editor.putBoolean(KEY_FILTERS_IN_MENTIONS_TIMELINE, !item.isChecked());
|
||||
editor.apply();
|
||||
break;
|
||||
}
|
||||
case R.id.enable_for_rts: {
|
||||
final SharedPreferences.Editor editor = mPreferences.edit();
|
||||
editor.putBoolean(KEY_FILTERS_FOR_RTS, !item.isChecked());
|
||||
editor.apply();
|
||||
break;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -504,7 +504,7 @@ public class SettingsWizardActivity extends Activity implements Constants {
|
||||
}
|
||||
}
|
||||
|
||||
static abstract class AbsInitialSettingsTask extends AsyncTask<Void, Void, Boolean> {
|
||||
static abstract class AbsInitialSettingsTask extends AsyncTask<Object, Object, Boolean> {
|
||||
|
||||
private static final String FRAGMENT_TAG = "initial_settings_dialog";
|
||||
|
||||
@ -518,7 +518,7 @@ public class SettingsWizardActivity extends Activity implements Constants {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Boolean doInBackground(final Void... params) {
|
||||
protected Boolean doInBackground(final Object... params) {
|
||||
final ContentResolver resolver = mActivity.getContentResolver();
|
||||
final List<SupportTabSpec> tabs = CustomTabUtils.getHomeTabs(mActivity);
|
||||
if (wasConfigured(tabs)) return true;
|
||||
|
@ -215,7 +215,7 @@ public class BrowserSignInActivity extends BaseSupportDialogActivity implements
|
||||
|
||||
}
|
||||
|
||||
static class GetRequestTokenTask extends AsyncTask<Void, Void, RequestToken> {
|
||||
static class GetRequestTokenTask extends AsyncTask<Object, Object, RequestToken> {
|
||||
|
||||
private final String mConsumerKey, mConsumerSecret;
|
||||
private final TwidereApplication mApplication;
|
||||
@ -232,7 +232,7 @@ public class BrowserSignInActivity extends BaseSupportDialogActivity implements
|
||||
}
|
||||
|
||||
@Override
|
||||
protected RequestToken doInBackground(final Void... params) {
|
||||
protected RequestToken doInBackground(final Object... params) {
|
||||
final ConfigurationBuilder cb = new ConfigurationBuilder();
|
||||
final boolean enable_gzip_compressing = mPreferences.getBoolean(KEY_GZIP_COMPRESSING, false);
|
||||
final boolean ignore_ssl_error = mPreferences.getBoolean(KEY_IGNORE_SSL_ERROR, false);
|
||||
|
@ -170,7 +170,7 @@ public class ComposeActivity extends ThemedFragmentActivity implements TextWatch
|
||||
private SharedPreferencesWrapper mPreferences;
|
||||
private ParcelableLocation mRecentLocation;
|
||||
private ContentResolver mResolver;
|
||||
private AsyncTask<Void, Void, ?> mTask;
|
||||
private AsyncTask<Object, Object, ?> mTask;
|
||||
private GridView mMediaPreviewGrid;
|
||||
private ActionMenuView mMenuBar;
|
||||
private StatusComposeEditText mEditText;
|
||||
@ -1333,7 +1333,7 @@ public class ComposeActivity extends ThemedFragmentActivity implements TextWatch
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Boolean doInBackground(Void... params) {
|
||||
protected Boolean doInBackground(Object... params) {
|
||||
if (mBitmap == null || mBitmap.isRecycled()) return false;
|
||||
FileOutputStream os = null;
|
||||
try {
|
||||
@ -1350,7 +1350,7 @@ public class ComposeActivity extends ThemedFragmentActivity implements TextWatch
|
||||
|
||||
}
|
||||
|
||||
private static class AddMediaTask extends AsyncTask<Void, Void, Boolean> {
|
||||
private static class AddMediaTask extends AsyncTask<Object, Object, Boolean> {
|
||||
|
||||
private final ComposeActivity activity;
|
||||
private final int media_type;
|
||||
@ -1367,7 +1367,7 @@ public class ComposeActivity extends ThemedFragmentActivity implements TextWatch
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Boolean doInBackground(final Void... params) {
|
||||
protected Boolean doInBackground(final Object... params) {
|
||||
try {
|
||||
final ContentResolver resolver = activity.getContentResolver();
|
||||
final InputStream is = resolver.openInputStream(src);
|
||||
@ -1408,7 +1408,7 @@ public class ComposeActivity extends ThemedFragmentActivity implements TextWatch
|
||||
}
|
||||
}
|
||||
|
||||
private static class DeleteImageTask extends AsyncTask<Void, Void, Boolean> {
|
||||
private static class DeleteImageTask extends AsyncTask<Object, Object, Boolean> {
|
||||
|
||||
final ComposeActivity mActivity;
|
||||
private final ParcelableMediaUpdate[] mMedia;
|
||||
@ -1419,7 +1419,7 @@ public class ComposeActivity extends ThemedFragmentActivity implements TextWatch
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Boolean doInBackground(final Void... params) {
|
||||
protected Boolean doInBackground(final Object... params) {
|
||||
if (mMedia == null) return false;
|
||||
try {
|
||||
for (final ParcelableMediaUpdate media : mMedia) {
|
||||
@ -1454,7 +1454,7 @@ public class ComposeActivity extends ThemedFragmentActivity implements TextWatch
|
||||
}
|
||||
}
|
||||
|
||||
private static class DiscardTweetTask extends AsyncTask<Void, Void, Void> {
|
||||
private static class DiscardTweetTask extends AsyncTask<Object, Object, Object> {
|
||||
|
||||
final ComposeActivity mActivity;
|
||||
|
||||
@ -1463,7 +1463,7 @@ public class ComposeActivity extends ThemedFragmentActivity implements TextWatch
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Void doInBackground(final Void... params) {
|
||||
protected Object doInBackground(final Object... params) {
|
||||
for (final ParcelableMediaUpdate media : mActivity.getMediaList()) {
|
||||
if (media.uri == null) continue;
|
||||
final Uri uri = Uri.parse(media.uri);
|
||||
@ -1478,7 +1478,7 @@ public class ComposeActivity extends ThemedFragmentActivity implements TextWatch
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(final Void result) {
|
||||
protected void onPostExecute(final Object result) {
|
||||
mActivity.setProgressVisible(false);
|
||||
mActivity.finish();
|
||||
}
|
||||
|
@ -90,7 +90,7 @@ public class DataExportActivity extends BaseActionBarActivity implements FileSel
|
||||
}
|
||||
}
|
||||
|
||||
static class ExportSettingsTask extends AsyncTask<Void, Void, Boolean> {
|
||||
static class ExportSettingsTask extends AsyncTask<Object, Object, Boolean> {
|
||||
private static final String FRAGMENT_TAG = "import_settings_dialog";
|
||||
|
||||
private final DataExportActivity mActivity;
|
||||
@ -104,7 +104,7 @@ public class DataExportActivity extends BaseActionBarActivity implements FileSel
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Boolean doInBackground(final Void... params) {
|
||||
protected Boolean doInBackground(final Object... params) {
|
||||
if (mPath == null) return false;
|
||||
final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss", Locale.US);
|
||||
final String fileName = String.format("Twidere_Settings_%s.zip", sdf.format(new Date()));
|
||||
|
@ -103,7 +103,7 @@ public class DataImportActivity extends BaseActionBarActivity implements FileSel
|
||||
}
|
||||
}
|
||||
|
||||
static class ImportSettingsTask extends AsyncTask<Void, Void, Boolean> {
|
||||
static class ImportSettingsTask extends AsyncTask<Object, Object, Boolean> {
|
||||
private static final String FRAGMENT_TAG = "import_settings_dialog";
|
||||
|
||||
private final DataImportActivity mActivity;
|
||||
@ -117,7 +117,7 @@ public class DataImportActivity extends BaseActionBarActivity implements FileSel
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Boolean doInBackground(final Void... params) {
|
||||
protected Boolean doInBackground(final Object... params) {
|
||||
if (mPath == null) return false;
|
||||
final File file = new File(mPath);
|
||||
if (!file.isFile()) return false;
|
||||
@ -152,7 +152,7 @@ public class DataImportActivity extends BaseActionBarActivity implements FileSel
|
||||
|
||||
}
|
||||
|
||||
static class OpenImportTypeTask extends AsyncTask<Void, Void, Integer> {
|
||||
static class OpenImportTypeTask extends AsyncTask<Object, Object, Integer> {
|
||||
|
||||
private static final String FRAGMENT_TAG = "read_settings_data_dialog";
|
||||
|
||||
@ -165,7 +165,7 @@ public class DataImportActivity extends BaseActionBarActivity implements FileSel
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Integer doInBackground(final Void... params) {
|
||||
protected Integer doInBackground(final Object... params) {
|
||||
if (mPath == null) return 0;
|
||||
final File file = new File(mPath);
|
||||
if (!file.isFile()) return 0;
|
||||
|
@ -290,7 +290,7 @@ public class DraftsActivity extends BaseActionBarActivity implements LoaderCallb
|
||||
|
||||
}
|
||||
|
||||
private static class DeleteDraftsTask extends AsyncTask<Void, Void, Integer> {
|
||||
private static class DeleteDraftsTask extends AsyncTask<Object, Object, Integer> {
|
||||
|
||||
private static final String FRAGMENT_TAG_DELETING_DRAFTS = "deleting_drafts";
|
||||
private final FragmentActivity mActivity;
|
||||
@ -306,7 +306,7 @@ public class DraftsActivity extends BaseActionBarActivity implements LoaderCallb
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Integer doInBackground(final Void... params) {
|
||||
protected Integer doInBackground(final Object... params) {
|
||||
final ContentResolver resolver = mActivity.getContentResolver();
|
||||
final Expression where = Expression.in(new Column(Drafts._ID), new RawItemArray(mIds));
|
||||
final String[] projection = {Drafts.MEDIA};
|
||||
|
@ -943,7 +943,7 @@ public class HomeActivity extends BaseActionBarActivity implements OnClickListen
|
||||
|
||||
}
|
||||
|
||||
private static class UpdateUnreadCountTask extends AsyncTask<Void, Void, Map<SupportTabSpec, Integer>> {
|
||||
private static class UpdateUnreadCountTask extends AsyncTask<Object, Object, Map<SupportTabSpec, Integer>> {
|
||||
private final Context mContext;
|
||||
private final ReadStateManager mReadStateManager;
|
||||
private final TabPagerIndicator mIndicator;
|
||||
@ -957,7 +957,7 @@ public class HomeActivity extends BaseActionBarActivity implements OnClickListen
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Map<SupportTabSpec, Integer> doInBackground(final Void... params) {
|
||||
protected Map<SupportTabSpec, Integer> doInBackground(final Object... params) {
|
||||
final Map<SupportTabSpec, Integer> result = new HashMap<>();
|
||||
for (SupportTabSpec spec : mTabs) {
|
||||
switch (spec.type) {
|
||||
|
@ -186,7 +186,7 @@ public class ImagePickerActivity extends ThemedActionBarActivity {
|
||||
}
|
||||
}
|
||||
|
||||
private static class CopyImageTask extends AsyncTask<Void, Void, SingleResponse<File>> {
|
||||
private static class CopyImageTask extends AsyncTask<Object, Object, SingleResponse<File>> {
|
||||
private final ImagePickerActivity mActivity;
|
||||
private final Uri mUri;
|
||||
|
||||
@ -198,7 +198,7 @@ public class ImagePickerActivity extends ThemedActionBarActivity {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SingleResponse<File> doInBackground(final Void... params) {
|
||||
protected SingleResponse<File> doInBackground(final Object... params) {
|
||||
final ContentResolver cr = mActivity.getContentResolver();
|
||||
InputStream is = null;
|
||||
OutputStream os = null;
|
||||
|
@ -519,7 +519,7 @@ public class SignInActivity extends BaseActionBarActivity implements TwitterCons
|
||||
});
|
||||
}
|
||||
|
||||
public static abstract class AbstractSignInTask extends AsyncTask<Void, Void, SignInResponse> {
|
||||
public static abstract class AbstractSignInTask extends AsyncTask<Object, Object, SignInResponse> {
|
||||
|
||||
protected final Configuration conf;
|
||||
protected final SignInActivity callback;
|
||||
@ -575,7 +575,7 @@ public class SignInActivity extends BaseActionBarActivity implements TwitterCons
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SignInResponse doInBackground(final Void... params) {
|
||||
protected SignInResponse doInBackground(final Object... params) {
|
||||
try {
|
||||
final Twitter twitter = new TwitterFactory(conf).getInstance();
|
||||
final AccessToken access_token = twitter.getOAuthAccessToken(new RequestToken(conf, request_token,
|
||||
@ -634,7 +634,7 @@ public class SignInActivity extends BaseActionBarActivity implements TwitterCons
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SignInResponse doInBackground(final Void... params) {
|
||||
protected SignInResponse doInBackground(final Object... params) {
|
||||
try {
|
||||
switch (auth_type) {
|
||||
case Accounts.AUTH_TYPE_OAUTH:
|
||||
|
@ -230,7 +230,7 @@ public class UserListSelectorActivity extends BaseSupportDialogActivity implemen
|
||||
mCreateUserListContainer.setVisibility(isMyAccount ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
|
||||
private static class GetUserListsTask extends AsyncTask<Void, Void, SingleResponse<List<ParcelableUserList>>> {
|
||||
private static class GetUserListsTask extends AsyncTask<Object, Object, SingleResponse<List<ParcelableUserList>>> {
|
||||
|
||||
private static final String FRAGMENT_TAG_GET_USER_LISTS = "get_user_lists";
|
||||
|
||||
@ -247,7 +247,7 @@ public class UserListSelectorActivity extends BaseSupportDialogActivity implemen
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SingleResponse<List<ParcelableUserList>> doInBackground(final Void... params) {
|
||||
protected SingleResponse<List<ParcelableUserList>> doInBackground(final Object... params) {
|
||||
final Twitter twitter = getTwitterInstance(mActivity, mAccountId, false);
|
||||
if (twitter == null) return SingleResponse.getInstance();
|
||||
try {
|
||||
@ -301,7 +301,7 @@ public class UserListSelectorActivity extends BaseSupportDialogActivity implemen
|
||||
|
||||
}
|
||||
|
||||
private static class SearchUsersTask extends AsyncTask<Void, Void, SingleResponse<List<ParcelableUser>>> {
|
||||
private static class SearchUsersTask extends AsyncTask<Object, Object, SingleResponse<List<ParcelableUser>>> {
|
||||
|
||||
private static final String FRAGMENT_TAG_SEARCH_USERS = "search_users";
|
||||
private final UserListSelectorActivity mActivity;
|
||||
@ -318,7 +318,7 @@ public class UserListSelectorActivity extends BaseSupportDialogActivity implemen
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SingleResponse<List<ParcelableUser>> doInBackground(final Void... params) {
|
||||
protected SingleResponse<List<ParcelableUser>> doInBackground(final Object... params) {
|
||||
final Twitter twitter = getTwitterInstance(mActivity, mAccountId, false);
|
||||
if (twitter == null) return SingleResponse.getInstance();
|
||||
try {
|
||||
|
@ -82,7 +82,7 @@ public class UserProfileEditorActivity extends BaseActionBarActivity implements
|
||||
|
||||
private MediaLoaderWrapper mLazyImageLoader;
|
||||
private AsyncTaskManager mAsyncTaskManager;
|
||||
private AsyncTask<Void, Void, ?> mTask;
|
||||
private AsyncTask<Object, Object, ?> mTask;
|
||||
|
||||
private ImageView mProfileImageView;
|
||||
private ImageView mProfileBannerView;
|
||||
@ -422,7 +422,7 @@ public class UserProfileEditorActivity extends BaseActionBarActivity implements
|
||||
mDoneButton.setEnabled(isProfileChanged());
|
||||
}
|
||||
|
||||
static class UpdateProfileTaskInternal extends AsyncTask<Void, Void, SingleResponse<ParcelableUser>> {
|
||||
static class UpdateProfileTaskInternal extends AsyncTask<Object, Object, SingleResponse<ParcelableUser>> {
|
||||
|
||||
private static final String DIALOG_FRAGMENT_TAG = "updating_user_profile";
|
||||
private final UserProfileEditorActivity mActivity;
|
||||
@ -454,7 +454,7 @@ public class UserProfileEditorActivity extends BaseActionBarActivity implements
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SingleResponse<ParcelableUser> doInBackground(final Void... params) {
|
||||
protected SingleResponse<ParcelableUser> doInBackground(final Object... params) {
|
||||
final Twitter twitter = getTwitterInstance(mActivity, mAccountId, true);
|
||||
try {
|
||||
User user = null;
|
||||
@ -519,7 +519,7 @@ public class UserProfileEditorActivity extends BaseActionBarActivity implements
|
||||
|
||||
}
|
||||
|
||||
class RemoveProfileBannerTaskInternal extends AsyncTask<Void, Void, SingleResponse<Boolean>> {
|
||||
class RemoveProfileBannerTaskInternal extends AsyncTask<Object, Object, SingleResponse<Boolean>> {
|
||||
|
||||
private final long account_id;
|
||||
|
||||
@ -528,7 +528,7 @@ public class UserProfileEditorActivity extends BaseActionBarActivity implements
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SingleResponse<Boolean> doInBackground(final Void... params) {
|
||||
protected SingleResponse<Boolean> doInBackground(final Object... params) {
|
||||
return TwitterWrapper.deleteProfileBannerImage(UserProfileEditorActivity.this, account_id);
|
||||
}
|
||||
|
||||
|
@ -52,7 +52,6 @@ import static org.mariotaku.twidere.util.Utils.buildStatusFilterWhereClause;
|
||||
import static org.mariotaku.twidere.util.Utils.getNewestStatusIdsFromDatabase;
|
||||
import static org.mariotaku.twidere.util.Utils.getOldestStatusIdsFromDatabase;
|
||||
import static org.mariotaku.twidere.util.Utils.getTableNameByUri;
|
||||
import static org.mariotaku.twidere.util.Utils.shouldEnableFiltersForRTs;
|
||||
|
||||
/**
|
||||
* Created by mariotaku on 14/12/3.
|
||||
@ -185,10 +184,10 @@ public abstract class CursorStatusesFragment extends AbsStatusesFragment<Cursor>
|
||||
@Override
|
||||
public void onLoadMoreContents() {
|
||||
super.onLoadMoreContents();
|
||||
AsyncTaskUtils.executeTask(new AsyncTask<Void, Void, long[][]>() {
|
||||
AsyncTaskUtils.executeTask(new AsyncTask<Object, Object, long[][]>() {
|
||||
|
||||
@Override
|
||||
protected long[][] doInBackground(final Void... params) {
|
||||
protected long[][] doInBackground(final Object... params) {
|
||||
final long[][] result = new long[3][];
|
||||
result[0] = getAccountIds();
|
||||
result[1] = getOldestStatusIds(result[0]);
|
||||
@ -205,10 +204,10 @@ public abstract class CursorStatusesFragment extends AbsStatusesFragment<Cursor>
|
||||
|
||||
@Override
|
||||
public boolean triggerRefresh() {
|
||||
AsyncTaskUtils.executeTask(new AsyncTask<Void, Void, long[][]>() {
|
||||
AsyncTaskUtils.executeTask(new AsyncTask<Object, Object, long[][]>() {
|
||||
|
||||
@Override
|
||||
protected long[][] doInBackground(final Void... params) {
|
||||
protected long[][] doInBackground(final Object... params) {
|
||||
final long[][] result = new long[3][];
|
||||
result[0] = getAccountIds();
|
||||
result[2] = getNewestStatusIds(result[0]);
|
||||
@ -226,7 +225,7 @@ public abstract class CursorStatusesFragment extends AbsStatusesFragment<Cursor>
|
||||
|
||||
protected Expression getFiltersWhere(String table) {
|
||||
if (!isFilterEnabled()) return null;
|
||||
return buildStatusFilterWhereClause(table, null, shouldEnableFiltersForRTs(getActivity()));
|
||||
return buildStatusFilterWhereClause(table, null);
|
||||
}
|
||||
|
||||
protected long[] getNewestStatusIds(long[] accountIds) {
|
||||
|
@ -159,10 +159,10 @@ public class DirectMessagesFragment extends BaseSupportFragment implements Loade
|
||||
|
||||
@Override
|
||||
public void onRefresh() {
|
||||
AsyncTaskUtils.executeTask(new AsyncTask<Void, Void, long[][]>() {
|
||||
AsyncTaskUtils.executeTask(new AsyncTask<Object, Object, long[][]>() {
|
||||
|
||||
@Override
|
||||
protected long[][] doInBackground(final Void... params) {
|
||||
protected long[][] doInBackground(final Object... params) {
|
||||
final long[][] result = new long[2][];
|
||||
result[0] = Utils.getActivatedAccountIds(getActivity());
|
||||
result[1] = Utils.getNewestMessageIdsFromDatabase(getActivity(), DirectMessages.Inbox.CONTENT_URI);
|
||||
@ -367,10 +367,10 @@ public class DirectMessagesFragment extends BaseSupportFragment implements Loade
|
||||
if (isRefreshing()) return;
|
||||
mAdapter.setLoadMoreIndicatorVisible(true);
|
||||
mSwipeRefreshLayout.setEnabled(false);
|
||||
AsyncTaskUtils.executeTask(new AsyncTask<Void, Void, long[][]>() {
|
||||
AsyncTaskUtils.executeTask(new AsyncTask<Object, Object, long[][]>() {
|
||||
|
||||
@Override
|
||||
protected long[][] doInBackground(final Void... params) {
|
||||
protected long[][] doInBackground(final Object... params) {
|
||||
final long[][] result = new long[3][];
|
||||
result[0] = Utils.getActivatedAccountIds(getActivity());
|
||||
result[1] = Utils.getOldestMessageIdsFromDatabase(getActivity(), DirectMessages.Inbox.CONTENT_URI);
|
||||
@ -413,7 +413,7 @@ public class DirectMessagesFragment extends BaseSupportFragment implements Loade
|
||||
AsyncTaskUtils.executeTask(mRemoveUnreadCountsTask);
|
||||
}
|
||||
|
||||
static class RemoveUnreadCountsTask extends AsyncTask<Void, Void, Void> {
|
||||
static class RemoveUnreadCountsTask extends AsyncTask<Object, Object, Object> {
|
||||
private final Set<Integer> read_positions;
|
||||
private final MessageEntriesAdapter adapter;
|
||||
private final DirectMessagesFragment fragment;
|
||||
@ -425,7 +425,7 @@ public class DirectMessagesFragment extends BaseSupportFragment implements Loade
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Void doInBackground(final Void... params) {
|
||||
protected Object doInBackground(final Object... params) {
|
||||
for (final int pos : read_positions) {
|
||||
final DirectMessageEntry entry = adapter.getEntry(pos);
|
||||
final long id = entry.conversation_id, account_id = entry.account_id;
|
||||
@ -435,7 +435,7 @@ public class DirectMessagesFragment extends BaseSupportFragment implements Loade
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(final Void result) {
|
||||
protected void onPostExecute(final Object result) {
|
||||
final AsyncTwitterWrapper twitter = fragment.getTwitterWrapper();
|
||||
if (twitter != null) {
|
||||
twitter.removeUnreadCountsAsync(fragment.getTabPosition(), fragment.getUnreadCountsToRemove());
|
||||
|
@ -19,7 +19,6 @@
|
||||
|
||||
package org.mariotaku.twidere.fragment.support;
|
||||
|
||||
import android.content.SharedPreferences;
|
||||
import android.net.Uri;
|
||||
|
||||
import org.mariotaku.twidere.provider.TwidereDataStore.Statuses;
|
||||
@ -42,8 +41,7 @@ public class HomeTimelineFragment extends CursorStatusesFragment {
|
||||
|
||||
@Override
|
||||
protected boolean isFilterEnabled() {
|
||||
final SharedPreferences pref = getSharedPreferences();
|
||||
return pref != null && pref.getBoolean(KEY_FILTERS_IN_HOME_TIMELINE, true);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -20,7 +20,6 @@
|
||||
package org.mariotaku.twidere.fragment.support;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.net.Uri;
|
||||
|
||||
import org.mariotaku.twidere.adapter.CursorStatusesAdapter;
|
||||
@ -57,8 +56,7 @@ public class MentionsTimelineFragment extends CursorStatusesFragment {
|
||||
|
||||
@Override
|
||||
protected boolean isFilterEnabled() {
|
||||
final SharedPreferences pref = getSharedPreferences();
|
||||
return pref != null && pref.getBoolean(KEY_FILTERS_IN_MENTIONS_TIMELINE, true);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -510,10 +510,10 @@ public class MessagesConversationFragment extends BaseSupportFragment implements
|
||||
|
||||
// @Override
|
||||
// public void onRefreshFromEnd() {
|
||||
// new TwidereAsyncTask<Void, Void, long[][]>() {
|
||||
// new TwidereAsyncTask<Object, Object, long[][]>() {
|
||||
//
|
||||
// @Override
|
||||
// protected long[][] doInBackground(final Void... params) {
|
||||
// protected long[][] doInBackground(final Object... params) {
|
||||
// final long[][] result = new long[2][];
|
||||
// result[0] = getActivatedAccountIds(getActivity());
|
||||
// result[1] = getNewestMessageIdsFromDatabase(getActivity(), DirectMessages.Inbox.CONTENT_URI);
|
||||
@ -677,10 +677,10 @@ public class MessagesConversationFragment extends BaseSupportFragment implements
|
||||
|
||||
// private void loadMoreMessages() {
|
||||
// if (isRefreshing()) return;
|
||||
// new TwidereAsyncTask<Void, Void, long[][]>() {
|
||||
// new TwidereAsyncTask<Object, Object, long[][]>() {
|
||||
//
|
||||
// @Override
|
||||
// protected long[][] doInBackground(final Void... params) {
|
||||
// protected long[][] doInBackground(final Object... params) {
|
||||
// final long[][] result = new long[3][];
|
||||
// result[0] = getActivatedAccountIds(getActivity());
|
||||
// result[1] = getOldestMessageIdsFromDatabase(getActivity(), DirectMessages.Inbox.CONTENT_URI);
|
||||
@ -786,7 +786,7 @@ public class MessagesConversationFragment extends BaseSupportFragment implements
|
||||
}
|
||||
}
|
||||
|
||||
private static class SetReadStateTask extends AsyncTask<Void, Void, Cursor> {
|
||||
private static class SetReadStateTask extends AsyncTask<Object, Object, Cursor> {
|
||||
private final Context mContext;
|
||||
private final ReadStateManager mReadStateManager;
|
||||
private final ParcelableAccount mAccount;
|
||||
@ -811,7 +811,7 @@ public class MessagesConversationFragment extends BaseSupportFragment implements
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Cursor doInBackground(Void... params) {
|
||||
protected Cursor doInBackground(Object... params) {
|
||||
final ContentResolver resolver = mContext.getContentResolver();
|
||||
final String[] projection = {ConversationEntries.MESSAGE_ID};
|
||||
final String selection = Expression.and(
|
||||
|
@ -636,6 +636,10 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac
|
||||
final int idx = status.quote_text_unescaped.lastIndexOf(" twitter.com");
|
||||
final Spanned quote_text = Html.fromHtml(status.quote_text_html);
|
||||
quoteTextView.setText(idx > 0 ? quote_text.subSequence(0, idx - 1) : quote_text);
|
||||
final SpannableString originalTweetLink = SpannableString.valueOf("Original tweet");
|
||||
originalTweetLink.setSpan(new URLSpan(LinkCreator.getTwitterStatusLink(status.user_screen_name, status.quote_id).toString()),
|
||||
0, originalTweetLink.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
|
||||
quoteTextView.append(originalTweetLink);
|
||||
linkify.applyAllLinks(quoteTextView, status.account_id, getLayoutPosition(),
|
||||
status.is_possibly_sensitive, adapter.getLinkHighlightingStyle());
|
||||
|
||||
@ -1140,6 +1144,7 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac
|
||||
public void setLoadMoreIndicatorVisible(boolean enabled) {
|
||||
if (mLoadMoreIndicatorVisible == enabled) return;
|
||||
mLoadMoreIndicatorVisible = enabled && mLoadMoreSupported;
|
||||
updateItemDecoration();
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@ -1440,10 +1445,10 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac
|
||||
private void updateItemDecoration() {
|
||||
final DividerItemDecoration decoration = mFragment.getItemDecoration();
|
||||
decoration.setDecorationStart(0);
|
||||
if (mReplies != null) {
|
||||
decoration.setDecorationEndOffset(2);
|
||||
} else {
|
||||
if (isLoadMoreIndicatorVisible()) {
|
||||
decoration.setDecorationEndOffset(3);
|
||||
} else {
|
||||
decoration.setDecorationEndOffset(mReplies != null && mReplies.size() > 0 ? 1 : 2);
|
||||
}
|
||||
mFragment.mRecyclerView.invalidateItemDecorations();
|
||||
}
|
||||
|
@ -131,7 +131,7 @@ public class UserListMembersFragment extends CursorSupportUsersListFragment impl
|
||||
return R.menu.action_user_list_member;
|
||||
}
|
||||
|
||||
private class GetUserListTask extends AsyncTask<Void, Void, ParcelableUserList> {
|
||||
private class GetUserListTask extends AsyncTask<Object, Object, ParcelableUserList> {
|
||||
|
||||
private final long accountId, userId;
|
||||
private final long listId;
|
||||
@ -147,7 +147,7 @@ public class UserListMembersFragment extends CursorSupportUsersListFragment impl
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ParcelableUserList doInBackground(final Void... params) {
|
||||
protected ParcelableUserList doInBackground(final Object... params) {
|
||||
final Twitter twitter = getTwitterInstance(getActivity(), accountId, true);
|
||||
if (twitter == null) return null;
|
||||
try {
|
||||
|
@ -36,7 +36,7 @@ import twitter4j.TwitterException;
|
||||
import static org.mariotaku.twidere.util.Utils.getAccountId;
|
||||
import static org.mariotaku.twidere.util.Utils.isFiltered;
|
||||
|
||||
public class MediaTimelineLoader extends Twitter4JStatusesLoader {
|
||||
public class MediaTimelineLoader extends TwitterAPIStatusesLoader {
|
||||
|
||||
private final long mUserId;
|
||||
private final String mUserScreenName;
|
||||
|
@ -36,7 +36,7 @@ import twitter4j.User;
|
||||
|
||||
import static org.mariotaku.twidere.util.Utils.isFiltered;
|
||||
|
||||
public class RetweetsOfMeLoader extends Twitter4JStatusesLoader {
|
||||
public class RetweetsOfMeLoader extends TwitterAPIStatusesLoader {
|
||||
|
||||
private int mTotalItemsCount;
|
||||
|
||||
|
@ -35,18 +35,15 @@ import twitter4j.TwitterException;
|
||||
|
||||
import static org.mariotaku.twidere.util.Utils.isFiltered;
|
||||
|
||||
public class TweetSearchLoader extends Twitter4JStatusesLoader {
|
||||
public class TweetSearchLoader extends TwitterAPIStatusesLoader {
|
||||
|
||||
private final String mQuery;
|
||||
private final boolean mFiltersForRts;
|
||||
|
||||
public TweetSearchLoader(final Context context, final long accountId, final String query,
|
||||
final long sinceId, final long maxId, final List<ParcelableStatus> data,
|
||||
final String[] savedStatusesArgs, final int tabPosition, boolean fromUser) {
|
||||
super(context, accountId, sinceId, maxId, data, savedStatusesArgs, tabPosition, fromUser);
|
||||
mQuery = query;
|
||||
mFiltersForRts = context.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE).getBoolean(
|
||||
KEY_FILTERS_FOR_RTS, true);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@ -66,7 +63,7 @@ public class TweetSearchLoader extends Twitter4JStatusesLoader {
|
||||
|
||||
@Override
|
||||
protected boolean shouldFilterStatus(final SQLiteDatabase database, final ParcelableStatus status) {
|
||||
return isFiltered(database, status, mFiltersForRts);
|
||||
return isFiltered(database, status, true);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ import twitter4j.TwitterException;
|
||||
import static org.mariotaku.twidere.util.Utils.getTwitterInstance;
|
||||
import static org.mariotaku.twidere.util.Utils.truncateStatuses;
|
||||
|
||||
public abstract class Twitter4JStatusesLoader extends ParcelableStatusesLoader {
|
||||
public abstract class TwitterAPIStatusesLoader extends ParcelableStatusesLoader {
|
||||
|
||||
private final Context mContext;
|
||||
private final long mAccountId;
|
||||
@ -55,12 +55,12 @@ public abstract class Twitter4JStatusesLoader extends ParcelableStatusesLoader {
|
||||
private final Object[] mSavedStatusesFileArgs;
|
||||
private Comparator<ParcelableStatus> mComparator;
|
||||
|
||||
public Twitter4JStatusesLoader(final Context context, final long account_id, final long sinceId, final long maxId,
|
||||
final List<ParcelableStatus> data, final String[] savedStatusesArgs,
|
||||
final int tabPosition, boolean fromUser) {
|
||||
public TwitterAPIStatusesLoader(final Context context, final long accountId, final long sinceId,
|
||||
final long maxId, final List<ParcelableStatus> data,
|
||||
final String[] savedStatusesArgs, final int tabPosition, boolean fromUser) {
|
||||
super(context, data, tabPosition, fromUser);
|
||||
mContext = context;
|
||||
mAccountId = account_id;
|
||||
mAccountId = accountId;
|
||||
mMaxId = maxId;
|
||||
mSinceId = sinceId;
|
||||
mDatabase = TwidereApplication.getInstance(context).getSQLiteDatabase();
|
@ -33,7 +33,7 @@ import twitter4j.Status;
|
||||
import twitter4j.Twitter;
|
||||
import twitter4j.TwitterException;
|
||||
|
||||
public class UserFavoritesLoader extends Twitter4JStatusesLoader {
|
||||
public class UserFavoritesLoader extends TwitterAPIStatusesLoader {
|
||||
|
||||
private final long mUserId;
|
||||
private final String mUserScreenName;
|
||||
|
@ -35,12 +35,11 @@ import twitter4j.TwitterException;
|
||||
|
||||
import static org.mariotaku.twidere.util.Utils.isFiltered;
|
||||
|
||||
public class UserListTimelineLoader extends Twitter4JStatusesLoader {
|
||||
public class UserListTimelineLoader extends TwitterAPIStatusesLoader {
|
||||
|
||||
private final long mUserId;
|
||||
private final String mScreenName, mListName;
|
||||
private final long mListId;
|
||||
private final boolean mFiltersForRts;
|
||||
|
||||
public UserListTimelineLoader(final Context context, final long accountId, final long listId,
|
||||
final long userId, final String screenName, final String listName,
|
||||
@ -51,28 +50,25 @@ public class UserListTimelineLoader extends Twitter4JStatusesLoader {
|
||||
mUserId = userId;
|
||||
mScreenName = screenName;
|
||||
mListName = listName;
|
||||
mFiltersForRts = context.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE).getBoolean(
|
||||
KEY_FILTERS_FOR_RTS, true);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
protected ResponseList<Status> getStatuses(@NonNull final Twitter twitter, final Paging paging) throws TwitterException {
|
||||
if (twitter == null) return null;
|
||||
if (mListId > 0)
|
||||
return twitter.getUserListStatuses(mListId, paging);
|
||||
else if (mListName == null)
|
||||
return null;
|
||||
throw new TwitterException("No list name or id given");
|
||||
else if (mUserId > 0)
|
||||
return twitter.getUserListStatuses(mListName.replace(' ', '-'), mUserId, paging);
|
||||
else if (mScreenName != null)
|
||||
return twitter.getUserListStatuses(mListName.replace(' ', '-'), mScreenName, paging);
|
||||
return null;
|
||||
throw new TwitterException("User id or screen name is required for list name");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean shouldFilterStatus(final SQLiteDatabase database, final ParcelableStatus status) {
|
||||
return isFiltered(database, status, mFiltersForRts);
|
||||
return isFiltered(database, status, true);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ import twitter4j.TwitterException;
|
||||
import static org.mariotaku.twidere.util.Utils.getAccountId;
|
||||
import static org.mariotaku.twidere.util.Utils.isFiltered;
|
||||
|
||||
public class UserTimelineLoader extends Twitter4JStatusesLoader {
|
||||
public class UserTimelineLoader extends TwitterAPIStatusesLoader {
|
||||
|
||||
private final long mUserId;
|
||||
private final String mUserScreenName;
|
||||
|
@ -214,7 +214,7 @@ public abstract class AccountsListPreference extends PreferenceCategory implemen
|
||||
}
|
||||
}
|
||||
|
||||
private static class LoadAccountsTask extends AsyncTask<Void, Void, List<ParcelableAccount>> {
|
||||
private static class LoadAccountsTask extends AsyncTask<Object, Object, List<ParcelableAccount>> {
|
||||
|
||||
private final AccountsListPreference mPreference;
|
||||
|
||||
@ -223,7 +223,7 @@ public abstract class AccountsListPreference extends PreferenceCategory implemen
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<ParcelableAccount> doInBackground(final Void... params) {
|
||||
protected List<ParcelableAccount> doInBackground(final Object... params) {
|
||||
return ParcelableAccount.getAccountsList(mPreference.getContext(), false);
|
||||
}
|
||||
|
||||
|
@ -58,7 +58,7 @@ public abstract class AsyncTaskPreference extends Preference implements Constant
|
||||
|
||||
protected abstract void doInBackground();
|
||||
|
||||
private static class Task extends AsyncTask<Void, Void, Void> {
|
||||
private static class Task extends AsyncTask<Object, Object, Object> {
|
||||
|
||||
private final AsyncTaskPreference mPreference;
|
||||
private final Context mContext;
|
||||
@ -71,13 +71,13 @@ public abstract class AsyncTaskPreference extends Preference implements Constant
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Void doInBackground(final Void... args) {
|
||||
protected Object doInBackground(final Object... args) {
|
||||
mPreference.doInBackground();
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(final Void result) {
|
||||
protected void onPostExecute(final Object result) {
|
||||
if (mProgress == null) return;
|
||||
if (mProgress.isShowing()) {
|
||||
mProgress.dismiss();
|
||||
|
@ -88,9 +88,12 @@ public class CardPreviewPreference extends Preference implements Constants, OnSh
|
||||
|
||||
@Override
|
||||
protected View onCreateView(final ViewGroup parent) {
|
||||
if (mPreferences != null && mPreferences.getBoolean(KEY_COMPACT_CARDS, false))
|
||||
return mInflater.inflate(R.layout.card_item_status_compact, parent, false);
|
||||
final View view = mInflater.inflate(R.layout.card_item_status, parent, false);
|
||||
final View view;
|
||||
if (mPreferences != null && mPreferences.getBoolean(KEY_COMPACT_CARDS, false)) {
|
||||
view = mInflater.inflate(R.layout.card_item_status_compact, parent, false);
|
||||
} else {
|
||||
view = mInflater.inflate(R.layout.card_item_status, parent, false);
|
||||
}
|
||||
mHolder = new StatusViewHolder(mAdapter, view);
|
||||
return view;
|
||||
}
|
||||
|
@ -156,7 +156,7 @@ public class TranslationDestinationPreference extends Preference implements Cons
|
||||
|
||||
}
|
||||
|
||||
class GetLanguagesTask extends AsyncTask<Void, Void, ResponseList<Language>> implements OnCancelListener {
|
||||
class GetLanguagesTask extends AsyncTask<Object, Object, ResponseList<Language>> implements OnCancelListener {
|
||||
|
||||
private final ProgressDialog mProgress;
|
||||
|
||||
@ -170,7 +170,7 @@ public class TranslationDestinationPreference extends Preference implements Cons
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ResponseList<Language> doInBackground(final Void... args) {
|
||||
protected ResponseList<Language> doInBackground(final Object... args) {
|
||||
final Twitter twitter = getDefaultTwitterInstance(getContext(), false);
|
||||
final String pref = mPreferences.getString(KEY_TRANSLATION_DESTINATION, null);
|
||||
if (twitter == null) return null;
|
||||
|
@ -51,165 +51,165 @@ import static org.mariotaku.twidere.util.Utils.getDefaultTwitterInstance;
|
||||
|
||||
public class TrendsLocationPreference extends Preference implements Constants, OnClickListener {
|
||||
|
||||
private SharedPreferences mPreferences;
|
||||
private SharedPreferences mPreferences;
|
||||
|
||||
private int mCheckedWoeId = 1;
|
||||
private int mCheckedWoeId = 1;
|
||||
|
||||
private GetAvailableTrendsTask mGetAvailableTrendsTask;
|
||||
private GetAvailableTrendsTask mGetAvailableTrendsTask;
|
||||
|
||||
private final AvailableTrendsAdapter mAdapter;
|
||||
private final AvailableTrendsAdapter mAdapter;
|
||||
|
||||
private AlertDialog mDialog;
|
||||
private AlertDialog mDialog;
|
||||
|
||||
public TrendsLocationPreference(final Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
public TrendsLocationPreference(final Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
public TrendsLocationPreference(final Context context, final AttributeSet attrs) {
|
||||
this(context, attrs, android.R.attr.preferenceStyle);
|
||||
}
|
||||
public TrendsLocationPreference(final Context context, final AttributeSet attrs) {
|
||||
this(context, attrs, android.R.attr.preferenceStyle);
|
||||
}
|
||||
|
||||
public TrendsLocationPreference(final Context context, final AttributeSet attrs, final int defStyle) {
|
||||
super(context, attrs, defStyle);
|
||||
mAdapter = new AvailableTrendsAdapter(context);
|
||||
}
|
||||
public TrendsLocationPreference(final Context context, final AttributeSet attrs, final int defStyle) {
|
||||
super(context, attrs, defStyle);
|
||||
mAdapter = new AvailableTrendsAdapter(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(final DialogInterface dialog, final int which) {
|
||||
final SharedPreferences.Editor editor = getEditor();
|
||||
if (editor == null) return;
|
||||
final Location item = mAdapter.getItem(which);
|
||||
if (item != null) {
|
||||
editor.putInt(KEY_LOCAL_TRENDS_WOEID, item.getWoeid());
|
||||
editor.apply();
|
||||
}
|
||||
if (mDialog != null && mDialog.isShowing()) {
|
||||
mDialog.dismiss();
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void onClick(final DialogInterface dialog, final int which) {
|
||||
final SharedPreferences.Editor editor = getEditor();
|
||||
if (editor == null) return;
|
||||
final Location item = mAdapter.getItem(which);
|
||||
if (item != null) {
|
||||
editor.putInt(KEY_LOCAL_TRENDS_WOEID, item.getWoeid());
|
||||
editor.apply();
|
||||
}
|
||||
if (mDialog != null && mDialog.isShowing()) {
|
||||
mDialog.dismiss();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onClick() {
|
||||
mPreferences = getSharedPreferences();
|
||||
if (mPreferences == null) return;
|
||||
mCheckedWoeId = mPreferences.getInt(KEY_LOCAL_TRENDS_WOEID, 1);
|
||||
if (mGetAvailableTrendsTask != null) {
|
||||
mGetAvailableTrendsTask.cancel(false);
|
||||
}
|
||||
mGetAvailableTrendsTask = new GetAvailableTrendsTask(getContext());
|
||||
mGetAvailableTrendsTask.execute();
|
||||
}
|
||||
@Override
|
||||
protected void onClick() {
|
||||
mPreferences = getSharedPreferences();
|
||||
if (mPreferences == null) return;
|
||||
mCheckedWoeId = mPreferences.getInt(KEY_LOCAL_TRENDS_WOEID, 1);
|
||||
if (mGetAvailableTrendsTask != null) {
|
||||
mGetAvailableTrendsTask.cancel(false);
|
||||
}
|
||||
mGetAvailableTrendsTask = new GetAvailableTrendsTask(getContext());
|
||||
mGetAvailableTrendsTask.execute();
|
||||
}
|
||||
|
||||
private static class AvailableTrendsAdapter extends ArrayAdapter<Location> {
|
||||
private static class AvailableTrendsAdapter extends ArrayAdapter<Location> {
|
||||
|
||||
private final Context mContext;
|
||||
private final Context mContext;
|
||||
|
||||
public AvailableTrendsAdapter(final Context context) {
|
||||
super(context, android.R.layout.simple_list_item_single_choice);
|
||||
mContext = context;
|
||||
}
|
||||
public AvailableTrendsAdapter(final Context context) {
|
||||
super(context, android.R.layout.simple_list_item_single_choice);
|
||||
mContext = context;
|
||||
}
|
||||
|
||||
public int findItemPosition(final int woeid) {
|
||||
final int count = getCount();
|
||||
for (int i = 0; i < count; i++) {
|
||||
final Location item = getItem(i);
|
||||
if (item.getWoeid() == woeid) return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
public int findItemPosition(final int woeid) {
|
||||
final int count = getCount();
|
||||
for (int i = 0; i < count; i++) {
|
||||
final Location item = getItem(i);
|
||||
if (item.getWoeid() == woeid) return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(final int position, final View convertView, final ViewGroup parent) {
|
||||
final View view = super.getView(position, convertView, parent);
|
||||
final TextView text = (TextView) (view instanceof TextView ? view : view.findViewById(android.R.id.text1));
|
||||
final Location item = getItem(position);
|
||||
if (item != null && text != null) {
|
||||
text.setSingleLine();
|
||||
text.setText(item.getName());
|
||||
}
|
||||
return view;
|
||||
}
|
||||
@Override
|
||||
public View getView(final int position, final View convertView, final ViewGroup parent) {
|
||||
final View view = super.getView(position, convertView, parent);
|
||||
final TextView text = (TextView) (view instanceof TextView ? view : view.findViewById(android.R.id.text1));
|
||||
final Location item = getItem(position);
|
||||
if (item != null && text != null) {
|
||||
text.setSingleLine();
|
||||
text.setText(item.getName());
|
||||
}
|
||||
return view;
|
||||
}
|
||||
|
||||
public void setData(final List<Location> data) {
|
||||
clear();
|
||||
if (data != null) {
|
||||
addAll(data);
|
||||
}
|
||||
sort(new LocationComparator(mContext));
|
||||
}
|
||||
public void setData(final List<Location> data) {
|
||||
clear();
|
||||
if (data != null) {
|
||||
addAll(data);
|
||||
}
|
||||
sort(new LocationComparator(mContext));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private static class LocationComparator implements Comparator<Location> {
|
||||
private final Collator mCollator;
|
||||
private static class LocationComparator implements Comparator<Location> {
|
||||
private final Collator mCollator;
|
||||
|
||||
LocationComparator(final Context context) {
|
||||
mCollator = Collator.getInstance(context.getResources().getConfiguration().locale);
|
||||
}
|
||||
LocationComparator(final Context context) {
|
||||
mCollator = Collator.getInstance(context.getResources().getConfiguration().locale);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compare(final Location object1, final Location object2) {
|
||||
if (object1.getWoeid() == 1) return Integer.MIN_VALUE;
|
||||
if (object2.getWoeid() == 1) return Integer.MAX_VALUE;
|
||||
return mCollator.compare(object1.getName(), object2.getName());
|
||||
}
|
||||
@Override
|
||||
public int compare(final Location object1, final Location object2) {
|
||||
if (object1.getWoeid() == 1) return Integer.MIN_VALUE;
|
||||
if (object2.getWoeid() == 1) return Integer.MAX_VALUE;
|
||||
return mCollator.compare(object1.getName(), object2.getName());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
class GetAvailableTrendsTask extends AsyncTask<Void, Void, ResponseList<Location>> implements OnCancelListener {
|
||||
class GetAvailableTrendsTask extends AsyncTask<Object, Object, ResponseList<Location>> implements OnCancelListener {
|
||||
|
||||
private final ProgressDialog mProgress;
|
||||
private final ProgressDialog mProgress;
|
||||
|
||||
public GetAvailableTrendsTask(final Context context) {
|
||||
mProgress = new ProgressDialog(context);
|
||||
}
|
||||
public GetAvailableTrendsTask(final Context context) {
|
||||
mProgress = new ProgressDialog(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCancel(final DialogInterface dialog) {
|
||||
cancel(true);
|
||||
}
|
||||
@Override
|
||||
public void onCancel(final DialogInterface dialog) {
|
||||
cancel(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ResponseList<Location> doInBackground(final Void... args) {
|
||||
final Twitter twitter = getDefaultTwitterInstance(getContext(), false);
|
||||
if (twitter == null) return null;
|
||||
try {
|
||||
return twitter.getAvailableTrends();
|
||||
} catch (final TwitterException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
protected ResponseList<Location> doInBackground(final Object... args) {
|
||||
final Twitter twitter = getDefaultTwitterInstance(getContext(), false);
|
||||
if (twitter == null) return null;
|
||||
try {
|
||||
return twitter.getAvailableTrends();
|
||||
} catch (final TwitterException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(final ResponseList<Location> result) {
|
||||
if (mProgress != null && mProgress.isShowing()) {
|
||||
mProgress.dismiss();
|
||||
}
|
||||
mAdapter.setData(result);
|
||||
if (result == null) return;
|
||||
final AlertDialog.Builder selectorBuilder = new AlertDialog.Builder(getContext());
|
||||
selectorBuilder.setTitle(getTitle());
|
||||
selectorBuilder.setSingleChoiceItems(mAdapter, mAdapter.findItemPosition(mCheckedWoeId),
|
||||
TrendsLocationPreference.this);
|
||||
selectorBuilder.setNegativeButton(android.R.string.cancel, null);
|
||||
mDialog = selectorBuilder.create();
|
||||
final ListView lv = mDialog.getListView();
|
||||
if (lv != null) {
|
||||
lv.setFastScrollEnabled(true);
|
||||
}
|
||||
mDialog.show();
|
||||
}
|
||||
@Override
|
||||
protected void onPostExecute(final ResponseList<Location> result) {
|
||||
if (mProgress.isShowing()) {
|
||||
mProgress.dismiss();
|
||||
}
|
||||
mAdapter.setData(result);
|
||||
if (result == null) return;
|
||||
final AlertDialog.Builder selectorBuilder = new AlertDialog.Builder(getContext());
|
||||
selectorBuilder.setTitle(getTitle());
|
||||
selectorBuilder.setSingleChoiceItems(mAdapter, mAdapter.findItemPosition(mCheckedWoeId),
|
||||
TrendsLocationPreference.this);
|
||||
selectorBuilder.setNegativeButton(android.R.string.cancel, null);
|
||||
mDialog = selectorBuilder.create();
|
||||
final ListView lv = mDialog.getListView();
|
||||
if (lv != null) {
|
||||
lv.setFastScrollEnabled(true);
|
||||
}
|
||||
mDialog.show();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPreExecute() {
|
||||
if (mProgress != null && mProgress.isShowing()) {
|
||||
mProgress.dismiss();
|
||||
}
|
||||
mProgress.setMessage(getContext().getString(R.string.please_wait));
|
||||
mProgress.setOnCancelListener(this);
|
||||
mProgress.show();
|
||||
}
|
||||
@Override
|
||||
protected void onPreExecute() {
|
||||
if (mProgress.isShowing()) {
|
||||
mProgress.dismiss();
|
||||
}
|
||||
mProgress.setMessage(getContext().getString(R.string.please_wait));
|
||||
mProgress.setOnCancelListener(this);
|
||||
mProgress.show();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -827,7 +827,7 @@ public final class TwidereDataProvider extends ContentProvider implements Consta
|
||||
final Expression selection = Expression.and(Expression.equals(Statuses.ACCOUNT_ID, accountId),
|
||||
Expression.greaterThan(Statuses.STATUS_ID, position));
|
||||
final String filteredSelection = Utils.buildStatusFilterWhereClause(Statuses.TABLE_NAME,
|
||||
selection, true).getSQL();
|
||||
selection).getSQL();
|
||||
final String[] userProjection = {Statuses.USER_ID, Statuses.USER_NAME, Statuses.USER_SCREEN_NAME};
|
||||
final String[] statusProjection = {Statuses.STATUS_ID};
|
||||
final Cursor statusCursor = mDatabaseWrapper.query(Statuses.TABLE_NAME, statusProjection,
|
||||
@ -900,7 +900,7 @@ public final class TwidereDataProvider extends ContentProvider implements Consta
|
||||
Expression.greaterThan(Statuses.STATUS_ID, position));
|
||||
}
|
||||
final String filteredSelection = Utils.buildStatusFilterWhereClause(Mentions.TABLE_NAME,
|
||||
selection, true).getSQL();
|
||||
selection).getSQL();
|
||||
final String[] userProjection = {Statuses.USER_ID, Statuses.USER_NAME, Statuses.USER_SCREEN_NAME};
|
||||
final String[] statusProjection = {Statuses.STATUS_ID, Statuses.USER_ID, Statuses.USER_NAME, Statuses.USER_SCREEN_NAME,
|
||||
Statuses.TEXT_UNESCAPED, Statuses.STATUS_TIMESTAMP};
|
||||
@ -1264,7 +1264,7 @@ public final class TwidereDataProvider extends ContentProvider implements Consta
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private static class GetWritableDatabaseTask extends AsyncTask<Void, Void, SQLiteDatabase> {
|
||||
private static class GetWritableDatabaseTask extends AsyncTask<Object, Object, SQLiteDatabase> {
|
||||
private final Context mContext;
|
||||
private final SQLiteOpenHelper mHelper;
|
||||
private final SQLiteDatabaseWrapper mWrapper;
|
||||
@ -1277,7 +1277,7 @@ public final class TwidereDataProvider extends ContentProvider implements Consta
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SQLiteDatabase doInBackground(final Void... params) {
|
||||
protected SQLiteDatabase doInBackground(final Object... params) {
|
||||
return mHelper.getWritableDatabase();
|
||||
}
|
||||
|
||||
|
@ -41,7 +41,7 @@ import static org.mariotaku.twidere.util.ContentValuesCreator.createCachedUser;
|
||||
import static org.mariotaku.twidere.util.ContentValuesCreator.createStatus;
|
||||
import static org.mariotaku.twidere.util.content.ContentResolverUtils.bulkInsert;
|
||||
|
||||
public class CacheUsersStatusesTask extends AsyncTask<TwitterListResponse<twitter4j.Status>, Void, Void> implements Constants {
|
||||
public class CacheUsersStatusesTask extends AsyncTask<TwitterListResponse<twitter4j.Status>, Object, Object> implements Constants {
|
||||
|
||||
private final Context context;
|
||||
|
||||
@ -51,7 +51,7 @@ public class CacheUsersStatusesTask extends AsyncTask<TwitterListResponse<twitte
|
||||
|
||||
@SafeVarargs
|
||||
@Override
|
||||
protected final Void doInBackground(final TwitterListResponse<twitter4j.Status>... args) {
|
||||
protected final Object doInBackground(final TwitterListResponse<twitter4j.Status>... args) {
|
||||
if (args == null || args.length == 0) return null;
|
||||
final ContentResolver resolver = context.getContentResolver();
|
||||
final Extractor extractor = new Extractor();
|
||||
|
@ -517,7 +517,14 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
return mAsyncTaskManager.add(task, true);
|
||||
}
|
||||
|
||||
static class GetSavedSearchesTask extends ManagedAsyncTask<Long, Void, SingleResponse<Void>> {
|
||||
private static <T extends SingleResponse<?>> Exception getException(List<T> responses) {
|
||||
for (T response : responses) {
|
||||
if (response.hasException()) return response.getException();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
static class GetSavedSearchesTask extends ManagedAsyncTask<Long, Object, SingleResponse<Object>> {
|
||||
|
||||
private final Context mContext;
|
||||
|
||||
@ -527,7 +534,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SingleResponse<Void> doInBackground(Long... params) {
|
||||
protected SingleResponse<Object> doInBackground(Long... params) {
|
||||
final ContentResolver cr = mContext.getContentResolver();
|
||||
for (long accountId : params) {
|
||||
final Twitter twitter = Utils.getTwitterInstance(mContext, accountId, true);
|
||||
@ -545,7 +552,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
}
|
||||
}
|
||||
|
||||
public static class UpdateProfileBannerImageTask extends ManagedAsyncTask<Void, Void, SingleResponse<ParcelableUser>> {
|
||||
public static class UpdateProfileBannerImageTask extends ManagedAsyncTask<Object, Object, SingleResponse<ParcelableUser>> {
|
||||
|
||||
private final long mAccountId;
|
||||
private final Uri mImageUri;
|
||||
@ -562,7 +569,18 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SingleResponse<ParcelableUser> doInBackground(final Void... params) {
|
||||
protected void onPostExecute(final SingleResponse<ParcelableUser> result) {
|
||||
super.onPostExecute(result);
|
||||
if (result.hasData()) {
|
||||
Utils.showOkMessage(mContext, R.string.profile_banner_image_updated, false);
|
||||
final Bus bus = TwidereApplication.getInstance(mContext).getMessageBus();
|
||||
bus.post(new ProfileUpdatedEvent(result.getData()));
|
||||
} else {
|
||||
Utils.showErrorMessage(mContext, R.string.action_updating_profile_banner_image, result.getException(),
|
||||
true);
|
||||
}
|
||||
} @Override
|
||||
protected SingleResponse<ParcelableUser> doInBackground(final Object... params) {
|
||||
try {
|
||||
final Twitter twitter = getTwitterInstance(mContext, mAccountId, true);
|
||||
TwitterWrapper.updateProfileBannerImage(mContext, twitter, mImageUri, mDeleteImage);
|
||||
@ -580,22 +598,11 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(final SingleResponse<ParcelableUser> result) {
|
||||
super.onPostExecute(result);
|
||||
if (result.hasData()) {
|
||||
Utils.showOkMessage(mContext, R.string.profile_banner_image_updated, false);
|
||||
final Bus bus = TwidereApplication.getInstance(mContext).getMessageBus();
|
||||
bus.post(new ProfileUpdatedEvent(result.getData()));
|
||||
} else {
|
||||
Utils.showErrorMessage(mContext, R.string.action_updating_profile_banner_image, result.getException(),
|
||||
true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public static class UpdateProfileImageTask extends ManagedAsyncTask<Void, Void, SingleResponse<ParcelableUser>> {
|
||||
public static class UpdateProfileImageTask extends ManagedAsyncTask<Object, Object, SingleResponse<ParcelableUser>> {
|
||||
|
||||
private final long mAccountId;
|
||||
private final Uri mImageUri;
|
||||
@ -612,7 +619,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SingleResponse<ParcelableUser> doInBackground(final Void... params) {
|
||||
protected SingleResponse<ParcelableUser> doInBackground(final Object... params) {
|
||||
try {
|
||||
final Twitter twitter = getTwitterInstance(mContext, mAccountId, true);
|
||||
TwitterWrapper.updateProfileImage(mContext, twitter, mImageUri, mDeleteImage);
|
||||
@ -644,7 +651,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
|
||||
}
|
||||
|
||||
public static class UpdateProfileTask extends ManagedAsyncTask<Void, Void, SingleResponse<ParcelableUser>> {
|
||||
public static class UpdateProfileTask extends ManagedAsyncTask<Object, Object, SingleResponse<ParcelableUser>> {
|
||||
|
||||
private final long account_id;
|
||||
private final String name, url, location, description;
|
||||
@ -662,7 +669,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SingleResponse<ParcelableUser> doInBackground(final Void... params) {
|
||||
protected SingleResponse<ParcelableUser> doInBackground(final Object... params) {
|
||||
return updateProfile(context, account_id, name, url, location, description);
|
||||
}
|
||||
|
||||
@ -681,7 +688,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
|
||||
}
|
||||
|
||||
class AcceptFriendshipTask extends ManagedAsyncTask<Void, Void, SingleResponse<User>> {
|
||||
class AcceptFriendshipTask extends ManagedAsyncTask<Object, Object, SingleResponse<User>> {
|
||||
|
||||
private final long mAccountId;
|
||||
private final long mUserId;
|
||||
@ -701,7 +708,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SingleResponse<User> doInBackground(final Void... params) {
|
||||
protected SingleResponse<User> doInBackground(final Object... params) {
|
||||
|
||||
final Twitter twitter = getTwitterInstance(mContext, mAccountId, false);
|
||||
if (twitter == null) return SingleResponse.getInstance();
|
||||
@ -732,7 +739,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
|
||||
}
|
||||
|
||||
class AddUserListMembersTask extends ManagedAsyncTask<Void, Void, SingleResponse<ParcelableUserList>> {
|
||||
class AddUserListMembersTask extends ManagedAsyncTask<Object, Object, SingleResponse<ParcelableUserList>> {
|
||||
|
||||
private final long accountId;
|
||||
private final long listId;
|
||||
@ -746,7 +753,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SingleResponse<ParcelableUserList> doInBackground(final Void... params) {
|
||||
protected SingleResponse<ParcelableUserList> doInBackground(final Object... params) {
|
||||
final Twitter twitter = getTwitterInstance(mContext, accountId, false);
|
||||
if (twitter == null || users == null) return SingleResponse.getInstance();
|
||||
try {
|
||||
@ -789,7 +796,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
|
||||
}
|
||||
|
||||
final class ClearNotificationTask extends AsyncTask<Void, Void, Integer> {
|
||||
final class ClearNotificationTask extends AsyncTask<Object, Object, Integer> {
|
||||
private final int notificationType;
|
||||
private final long accountId;
|
||||
|
||||
@ -799,13 +806,13 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Integer doInBackground(final Void... params) {
|
||||
protected Integer doInBackground(final Object... params) {
|
||||
return clearNotification(mContext, notificationType, accountId);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
final class ClearUnreadCountTask extends AsyncTask<Void, Void, Integer> {
|
||||
final class ClearUnreadCountTask extends AsyncTask<Object, Object, Integer> {
|
||||
private final int position;
|
||||
|
||||
ClearUnreadCountTask(final int position) {
|
||||
@ -813,13 +820,13 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Integer doInBackground(final Void... params) {
|
||||
protected Integer doInBackground(final Object... params) {
|
||||
return clearUnreadCount(mContext, position);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class CreateBlockTask extends ManagedAsyncTask<Void, Void, SingleResponse<ParcelableUser>> {
|
||||
class CreateBlockTask extends ManagedAsyncTask<Object, Object, SingleResponse<ParcelableUser>> {
|
||||
|
||||
private final long account_id, user_id;
|
||||
|
||||
@ -830,7 +837,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SingleResponse<ParcelableUser> doInBackground(final Void... params) {
|
||||
protected SingleResponse<ParcelableUser> doInBackground(final Object... params) {
|
||||
final Twitter twitter = getTwitterInstance(mContext, account_id, false);
|
||||
if (twitter == null) return SingleResponse.getInstance();
|
||||
try {
|
||||
@ -868,7 +875,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
|
||||
}
|
||||
|
||||
class CreateFavoriteTask extends ManagedAsyncTask<Void, Void, SingleResponse<ParcelableStatus>> {
|
||||
class CreateFavoriteTask extends ManagedAsyncTask<Object, Object, SingleResponse<ParcelableStatus>> {
|
||||
|
||||
private final long account_id, status_id;
|
||||
|
||||
@ -879,7 +886,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SingleResponse<ParcelableStatus> doInBackground(final Void... params) {
|
||||
protected SingleResponse<ParcelableStatus> doInBackground(final Object... params) {
|
||||
if (account_id < 0) return SingleResponse.getInstance();
|
||||
final Twitter twitter = getTwitterInstance(mContext, account_id, true);
|
||||
if (twitter == null) return SingleResponse.getInstance();
|
||||
@ -925,7 +932,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
|
||||
}
|
||||
|
||||
class CreateFriendshipTask extends ManagedAsyncTask<Void, Void, SingleResponse<ParcelableUser>> {
|
||||
class CreateFriendshipTask extends ManagedAsyncTask<Object, Object, SingleResponse<ParcelableUser>> {
|
||||
|
||||
private final long mAccountId;
|
||||
private final long user_id;
|
||||
@ -945,7 +952,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SingleResponse<ParcelableUser> doInBackground(final Void... params) {
|
||||
protected SingleResponse<ParcelableUser> doInBackground(final Object... params) {
|
||||
|
||||
final Twitter twitter = getTwitterInstance(mContext, mAccountId, false);
|
||||
if (twitter == null) return SingleResponse.getInstance();
|
||||
@ -979,7 +986,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
|
||||
}
|
||||
|
||||
class CreateMultiBlockTask extends ManagedAsyncTask<Void, Void, ListResponse<Long>> {
|
||||
class CreateMultiBlockTask extends ManagedAsyncTask<Object, Object, ListResponse<Long>> {
|
||||
|
||||
private final long account_id;
|
||||
private final long[] user_ids;
|
||||
@ -1000,7 +1007,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ListResponse<Long> doInBackground(final Void... params) {
|
||||
protected ListResponse<Long> doInBackground(final Object... params) {
|
||||
final List<Long> blocked_users = new ArrayList<>();
|
||||
final Twitter twitter = getTwitterInstance(mContext, account_id, false);
|
||||
if (twitter != null) {
|
||||
@ -1037,7 +1044,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
|
||||
}
|
||||
|
||||
class CreateMuteTask extends ManagedAsyncTask<Void, Void, SingleResponse<ParcelableUser>> {
|
||||
class CreateMuteTask extends ManagedAsyncTask<Object, Object, SingleResponse<ParcelableUser>> {
|
||||
|
||||
private final long mAccountId, mUserId;
|
||||
|
||||
@ -1048,7 +1055,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SingleResponse<ParcelableUser> doInBackground(final Void... params) {
|
||||
protected SingleResponse<ParcelableUser> doInBackground(final Object... params) {
|
||||
final Twitter twitter = getTwitterInstance(mContext, mAccountId, false);
|
||||
if (twitter == null) return SingleResponse.getInstance();
|
||||
try {
|
||||
@ -1080,7 +1087,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
|
||||
}
|
||||
|
||||
class CreateSavedSearchTask extends ManagedAsyncTask<Void, Void, SingleResponse<SavedSearch>> {
|
||||
class CreateSavedSearchTask extends ManagedAsyncTask<Object, Object, SingleResponse<SavedSearch>> {
|
||||
|
||||
private final long mAccountId;
|
||||
private final String mQuery;
|
||||
@ -1092,7 +1099,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SingleResponse<SavedSearch> doInBackground(final Void... params) {
|
||||
protected SingleResponse<SavedSearch> doInBackground(final Object... params) {
|
||||
final Twitter twitter = getTwitterInstance(mContext, mAccountId, false);
|
||||
if (twitter == null) return null;
|
||||
try {
|
||||
@ -1115,7 +1122,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
|
||||
}
|
||||
|
||||
class CreateUserListSubscriptionTask extends ManagedAsyncTask<Void, Void, SingleResponse<ParcelableUserList>> {
|
||||
class CreateUserListSubscriptionTask extends ManagedAsyncTask<Object, Object, SingleResponse<ParcelableUserList>> {
|
||||
|
||||
private final long accountId;
|
||||
private final long listId;
|
||||
@ -1127,7 +1134,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SingleResponse<ParcelableUserList> doInBackground(final Void... params) {
|
||||
protected SingleResponse<ParcelableUserList> doInBackground(final Object... params) {
|
||||
final Twitter twitter = getTwitterInstance(mContext, accountId, false);
|
||||
if (twitter == null) return SingleResponse.getInstance();
|
||||
|
||||
@ -1157,7 +1164,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
|
||||
}
|
||||
|
||||
class CreateUserListTask extends ManagedAsyncTask<Void, Void, SingleResponse<UserList>> {
|
||||
class CreateUserListTask extends ManagedAsyncTask<Object, Object, SingleResponse<UserList>> {
|
||||
|
||||
private final long account_id;
|
||||
private final String list_name, description;
|
||||
@ -1173,7 +1180,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SingleResponse<UserList> doInBackground(final Void... params) {
|
||||
protected SingleResponse<UserList> doInBackground(final Object... params) {
|
||||
final Twitter twitter = getTwitterInstance(mContext, account_id, false);
|
||||
if (twitter == null || list_name == null) return SingleResponse.getInstance();
|
||||
try {
|
||||
@ -1201,7 +1208,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
|
||||
}
|
||||
|
||||
class DeleteUserListMembersTask extends ManagedAsyncTask<Void, Void, SingleResponse<ParcelableUserList>> {
|
||||
class DeleteUserListMembersTask extends ManagedAsyncTask<Object, Object, SingleResponse<ParcelableUserList>> {
|
||||
|
||||
private final long mAccountId;
|
||||
private final long mUserListId;
|
||||
@ -1215,7 +1222,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SingleResponse<ParcelableUserList> doInBackground(final Void... params) {
|
||||
protected SingleResponse<ParcelableUserList> doInBackground(final Object... params) {
|
||||
final Twitter twitter = getTwitterInstance(mContext, mAccountId, false);
|
||||
if (twitter == null) return SingleResponse.getInstance();
|
||||
try {
|
||||
@ -1258,7 +1265,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
|
||||
}
|
||||
|
||||
class DenyFriendshipTask extends ManagedAsyncTask<Void, Void, SingleResponse<User>> {
|
||||
class DenyFriendshipTask extends ManagedAsyncTask<Object, Object, SingleResponse<User>> {
|
||||
|
||||
private final long mAccountId;
|
||||
private final long mUserId;
|
||||
@ -1278,7 +1285,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SingleResponse<User> doInBackground(final Void... params) {
|
||||
protected SingleResponse<User> doInBackground(final Object... params) {
|
||||
|
||||
final Twitter twitter = getTwitterInstance(mContext, mAccountId, false);
|
||||
if (twitter == null) return SingleResponse.getInstance();
|
||||
@ -1308,7 +1315,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
|
||||
}
|
||||
|
||||
class DestroyBlockTask extends ManagedAsyncTask<Void, Void, SingleResponse<ParcelableUser>> {
|
||||
class DestroyBlockTask extends ManagedAsyncTask<Object, Object, SingleResponse<ParcelableUser>> {
|
||||
|
||||
private final long mAccountId;
|
||||
private final long mUserId;
|
||||
@ -1320,7 +1327,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SingleResponse<ParcelableUser> doInBackground(final Void... params) {
|
||||
protected SingleResponse<ParcelableUser> doInBackground(final Object... params) {
|
||||
final Twitter twitter = getTwitterInstance(mContext, mAccountId, false);
|
||||
if (twitter == null) return SingleResponse.getInstance();
|
||||
try {
|
||||
@ -1349,7 +1356,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
|
||||
}
|
||||
|
||||
class DestroyDirectMessageTask extends ManagedAsyncTask<Void, Void, SingleResponse<DirectMessage>> {
|
||||
class DestroyDirectMessageTask extends ManagedAsyncTask<Object, Object, SingleResponse<DirectMessage>> {
|
||||
|
||||
private final long message_id;
|
||||
private final long account_id;
|
||||
@ -1367,8 +1374,13 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
mResolver.delete(DirectMessages.Outbox.CONTENT_URI, where, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SingleResponse<DirectMessage> doInBackground(final Void... args) {
|
||||
private boolean isMessageNotFound(final Exception e) {
|
||||
if (!(e instanceof TwitterException)) return false;
|
||||
final TwitterException te = (TwitterException) e;
|
||||
return te.getErrorCode() == StatusCodeMessageUtils.PAGE_NOT_FOUND
|
||||
|| te.getStatusCode() == HttpResponseCode.NOT_FOUND;
|
||||
} @Override
|
||||
protected SingleResponse<DirectMessage> doInBackground(final Object... args) {
|
||||
final Twitter twitter = getTwitterInstance(mContext, account_id, false);
|
||||
if (twitter == null) return SingleResponse.getInstance();
|
||||
try {
|
||||
@ -1383,12 +1395,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isMessageNotFound(final Exception e) {
|
||||
if (!(e instanceof TwitterException)) return false;
|
||||
final TwitterException te = (TwitterException) e;
|
||||
return te.getErrorCode() == StatusCodeMessageUtils.PAGE_NOT_FOUND
|
||||
|| te.getStatusCode() == HttpResponseCode.NOT_FOUND;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(final SingleResponse<DirectMessage> result) {
|
||||
@ -1404,7 +1411,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
|
||||
}
|
||||
|
||||
class DestroyFavoriteTask extends ManagedAsyncTask<Void, Void, SingleResponse<ParcelableStatus>> {
|
||||
class DestroyFavoriteTask extends ManagedAsyncTask<Object, Object, SingleResponse<ParcelableStatus>> {
|
||||
|
||||
private final long account_id;
|
||||
|
||||
@ -1417,7 +1424,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SingleResponse<ParcelableStatus> doInBackground(final Void... params) {
|
||||
protected SingleResponse<ParcelableStatus> doInBackground(final Object... params) {
|
||||
if (account_id < 0) return SingleResponse.getInstance();
|
||||
final Twitter twitter = getTwitterInstance(mContext, account_id, true);
|
||||
if (twitter != null) {
|
||||
@ -1461,7 +1468,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
|
||||
}
|
||||
|
||||
class DestroyFriendshipTask extends ManagedAsyncTask<Void, Void, SingleResponse<ParcelableUser>> {
|
||||
class DestroyFriendshipTask extends ManagedAsyncTask<Object, Object, SingleResponse<ParcelableUser>> {
|
||||
|
||||
private final long mAccountId;
|
||||
private final long user_id;
|
||||
@ -1481,7 +1488,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SingleResponse<ParcelableUser> doInBackground(final Void... params) {
|
||||
protected SingleResponse<ParcelableUser> doInBackground(final Object... params) {
|
||||
|
||||
final Twitter twitter = getTwitterInstance(mContext, mAccountId, false);
|
||||
if (twitter != null) {
|
||||
@ -1517,7 +1524,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
|
||||
}
|
||||
|
||||
class DestroyMuteTask extends ManagedAsyncTask<Void, Void, SingleResponse<ParcelableUser>> {
|
||||
class DestroyMuteTask extends ManagedAsyncTask<Object, Object, SingleResponse<ParcelableUser>> {
|
||||
|
||||
private final long mAccountId;
|
||||
private final long mUserId;
|
||||
@ -1529,7 +1536,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SingleResponse<ParcelableUser> doInBackground(final Void... params) {
|
||||
protected SingleResponse<ParcelableUser> doInBackground(final Object... params) {
|
||||
final Twitter twitter = getTwitterInstance(mContext, mAccountId, false);
|
||||
if (twitter == null) return SingleResponse.getInstance();
|
||||
try {
|
||||
@ -1558,7 +1565,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
|
||||
}
|
||||
|
||||
class DestroySavedSearchTask extends ManagedAsyncTask<Void, Void, SingleResponse<SavedSearch>> {
|
||||
class DestroySavedSearchTask extends ManagedAsyncTask<Object, Object, SingleResponse<SavedSearch>> {
|
||||
|
||||
private final long mAccountId;
|
||||
private final int mSearchId;
|
||||
@ -1570,7 +1577,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SingleResponse<SavedSearch> doInBackground(final Void... params) {
|
||||
protected SingleResponse<SavedSearch> doInBackground(final Object... params) {
|
||||
final Twitter twitter = getTwitterInstance(mContext, mAccountId, false);
|
||||
if (twitter == null) return SingleResponse.getInstance();
|
||||
try {
|
||||
@ -1593,7 +1600,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
|
||||
}
|
||||
|
||||
class DestroyStatusTask extends ManagedAsyncTask<Void, Void, SingleResponse<ParcelableStatus>> {
|
||||
class DestroyStatusTask extends ManagedAsyncTask<Object, Object, SingleResponse<ParcelableStatus>> {
|
||||
|
||||
private final long account_id;
|
||||
|
||||
@ -1606,7 +1613,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SingleResponse<ParcelableStatus> doInBackground(final Void... params) {
|
||||
protected SingleResponse<ParcelableStatus> doInBackground(final Object... params) {
|
||||
final Twitter twitter = getTwitterInstance(mContext, account_id, false);
|
||||
if (twitter == null) return SingleResponse.getInstance();
|
||||
ParcelableStatus status = null;
|
||||
@ -1655,7 +1662,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
|
||||
}
|
||||
|
||||
class DestroyUserListSubscriptionTask extends ManagedAsyncTask<Void, Void, SingleResponse<ParcelableUserList>> {
|
||||
class DestroyUserListSubscriptionTask extends ManagedAsyncTask<Object, Object, SingleResponse<ParcelableUserList>> {
|
||||
|
||||
private final long mAccountId;
|
||||
private final long mListId;
|
||||
@ -1667,7 +1674,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SingleResponse<ParcelableUserList> doInBackground(final Void... params) {
|
||||
protected SingleResponse<ParcelableUserList> doInBackground(final Object... params) {
|
||||
|
||||
final Twitter twitter = getTwitterInstance(mContext, mAccountId, false);
|
||||
if (twitter != null) {
|
||||
@ -1699,7 +1706,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
|
||||
}
|
||||
|
||||
class DestroyUserListTask extends ManagedAsyncTask<Void, Void, SingleResponse<ParcelableUserList>> {
|
||||
class DestroyUserListTask extends ManagedAsyncTask<Object, Object, SingleResponse<ParcelableUserList>> {
|
||||
|
||||
private final long mAccountId;
|
||||
private final long mListId;
|
||||
@ -1711,7 +1718,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SingleResponse<ParcelableUserList> doInBackground(final Void... params) {
|
||||
protected SingleResponse<ParcelableUserList> doInBackground(final Object... params) {
|
||||
|
||||
final Twitter twitter = getTwitterInstance(mContext, mAccountId, false);
|
||||
if (twitter != null) {
|
||||
@ -1745,7 +1752,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
|
||||
}
|
||||
|
||||
abstract class GetDirectMessagesTask extends ManagedAsyncTask<Void, Void, List<MessageListResponse>> {
|
||||
abstract class GetDirectMessagesTask extends ManagedAsyncTask<Object, Object, List<MessageListResponse>> {
|
||||
|
||||
private final long[] account_ids, max_ids, since_ids;
|
||||
|
||||
@ -1760,12 +1767,10 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
public abstract ResponseList<DirectMessage> getDirectMessages(Twitter twitter, Paging paging)
|
||||
throws TwitterException;
|
||||
|
||||
final boolean isMaxIdsValid() {
|
||||
return max_ids != null && max_ids.length == account_ids.length;
|
||||
}
|
||||
protected abstract Uri getDatabaseUri();
|
||||
|
||||
@Override
|
||||
protected List<MessageListResponse> doInBackground(final Void... params) {
|
||||
protected abstract boolean isOutgoing(); @Override
|
||||
protected List<MessageListResponse> doInBackground(final Object... params) {
|
||||
|
||||
final List<MessageListResponse> result = new ArrayList<>();
|
||||
|
||||
@ -1806,7 +1811,13 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
|
||||
}
|
||||
|
||||
protected abstract boolean isOutgoing();
|
||||
final boolean isMaxIdsValid() {
|
||||
return max_ids != null && max_ids.length == account_ids.length;
|
||||
}
|
||||
|
||||
final boolean isSinceIdsValid() {
|
||||
return since_ids != null && since_ids.length == account_ids.length;
|
||||
}
|
||||
|
||||
private boolean storeMessages(long accountId, List<DirectMessage> messages, boolean isOutgoing, boolean notify) {
|
||||
if (messages == null) return true;
|
||||
@ -1831,30 +1842,20 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
return false;
|
||||
}
|
||||
|
||||
protected abstract Uri getDatabaseUri();
|
||||
|
||||
final boolean isSinceIdsValid() {
|
||||
return since_ids != null && since_ids.length == account_ids.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPreExecute() {
|
||||
super.onPreExecute();
|
||||
final Bus bus = TwidereApplication.getInstance(getContext()).getMessageBus();
|
||||
bus.post(new GetMessagesTaskEvent(getDatabaseUri(), true));
|
||||
bus.post(new GetMessagesTaskEvent(getDatabaseUri(), true, null));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(final List<MessageListResponse> result) {
|
||||
super.onPostExecute(result);
|
||||
final Bus bus = TwidereApplication.getInstance(getContext()).getMessageBus();
|
||||
bus.post(new GetMessagesTaskEvent(getDatabaseUri(), false));
|
||||
for (final TwitterListResponse<DirectMessage> response : result) {
|
||||
if (response.list == null) {
|
||||
mMessagesManager.showErrorMessage(R.string.action_refreshing_direct_messages,
|
||||
response.getException(), true);
|
||||
}
|
||||
}
|
||||
bus.post(new GetMessagesTaskEvent(getDatabaseUri(), false, getException(result)));
|
||||
}
|
||||
|
||||
|
||||
@ -1866,28 +1867,22 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
super(account_ids, max_ids, since_ids, TASK_TAG_GET_HOME_TIMELINE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseList<twitter4j.Status> getStatuses(final Twitter twitter, final Paging paging)
|
||||
throws TwitterException {
|
||||
return twitter.getHomeTimeline(paging);
|
||||
} @NonNull
|
||||
@Override
|
||||
protected Uri getDatabaseUri() {
|
||||
return Statuses.CONTENT_URI;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseList<twitter4j.Status> getStatuses(final Twitter twitter, final Paging paging)
|
||||
throws TwitterException {
|
||||
return twitter.getHomeTimeline(paging);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(final List<StatusListResponse> responses) {
|
||||
super.onPostExecute(responses);
|
||||
protected void onPostExecute(final List<StatusListResponse> result) {
|
||||
super.onPostExecute(result);
|
||||
mGetHomeTimelineTaskId = -1;
|
||||
for (final StatusListResponse response : responses) {
|
||||
if (response.list == null) {
|
||||
mMessagesManager.showErrorMessage(R.string.action_refreshing_home_timeline,
|
||||
response.getException(), true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -1939,23 +1934,16 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
return twitter.getMentionsTimeline(paging);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
protected Uri getDatabaseUri() {
|
||||
return Mentions.CONTENT_URI;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(final List<StatusListResponse> responses) {
|
||||
super.onPostExecute(responses);
|
||||
// mAsyncTaskManager.add(new StoreMentionsTask(responses, !isMaxIdsValid()), true);
|
||||
protected void onPostExecute(final List<StatusListResponse> result) {
|
||||
super.onPostExecute(result);
|
||||
mGetMentionsTaskId = -1;
|
||||
for (final StatusListResponse response : responses) {
|
||||
if (response.list == null) {
|
||||
mMessagesManager.showErrorMessage(R.string.action_refreshing_mentions, response.getException(),
|
||||
true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -1975,15 +1963,15 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseList<DirectMessage> getDirectMessages(final Twitter twitter, final Paging paging)
|
||||
throws TwitterException {
|
||||
return twitter.getDirectMessages(paging);
|
||||
} @Override
|
||||
protected Uri getDatabaseUri() {
|
||||
return Inbox.CONTENT_URI;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseList<DirectMessage> getDirectMessages(final Twitter twitter, final Paging paging)
|
||||
throws TwitterException {
|
||||
return twitter.getDirectMessages(paging);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected boolean isOutgoing() {
|
||||
@ -2037,7 +2025,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
|
||||
}
|
||||
|
||||
abstract class GetStatusesTask extends ManagedAsyncTask<Void, TwitterListResponse<twitter4j.Status>, List<StatusListResponse>> {
|
||||
abstract class GetStatusesTask extends ManagedAsyncTask<Object, TwitterListResponse<twitter4j.Status>, List<StatusListResponse>> {
|
||||
|
||||
private final long[] mAccountIds, mMaxIds, mSinceIds;
|
||||
|
||||
@ -2051,16 +2039,21 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
public abstract ResponseList<twitter4j.Status> getStatuses(Twitter twitter, Paging paging)
|
||||
throws TwitterException;
|
||||
|
||||
@NonNull
|
||||
protected abstract Uri getDatabaseUri();
|
||||
|
||||
final boolean isMaxIdsValid() {
|
||||
return mMaxIds != null && mMaxIds.length == mAccountIds.length;
|
||||
}
|
||||
|
||||
@SafeVarargs
|
||||
} @SafeVarargs
|
||||
@Override
|
||||
protected final void onProgressUpdate(TwitterListResponse<twitter4j.Status>... values) {
|
||||
AsyncTaskUtils.executeTask(new CacheUsersStatusesTask(mContext), values);
|
||||
}
|
||||
|
||||
final boolean isSinceIdsValid() {
|
||||
return mSinceIds != null && mSinceIds.length == mAccountIds.length;
|
||||
}
|
||||
|
||||
private void storeStatus(long accountId, List<twitter4j.Status> statuses, long maxId, boolean truncated, boolean notify) {
|
||||
if (statuses == null || statuses.isEmpty() || accountId <= 0) {
|
||||
return;
|
||||
@ -2114,25 +2107,22 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
|
||||
}
|
||||
|
||||
@NonNull
|
||||
protected abstract Uri getDatabaseUri();
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(List<StatusListResponse> statusListResponses) {
|
||||
super.onPostExecute(statusListResponses);
|
||||
protected void onPostExecute(List<StatusListResponse> result) {
|
||||
super.onPostExecute(result);
|
||||
final Bus bus = TwidereApplication.getInstance(mContext).getMessageBus();
|
||||
bus.post(new GetStatusesTaskEvent(getDatabaseUri(), false));
|
||||
bus.post(new GetStatusesTaskEvent(getDatabaseUri(), false, getException(result)));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPreExecute() {
|
||||
super.onPreExecute();
|
||||
final Bus bus = TwidereApplication.getInstance(mContext).getMessageBus();
|
||||
bus.post(new GetStatusesTaskEvent(getDatabaseUri(), true));
|
||||
bus.post(new GetStatusesTaskEvent(getDatabaseUri(), true, null));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<StatusListResponse> doInBackground(final Void... params) {
|
||||
protected List<StatusListResponse> doInBackground(final Object... params) {
|
||||
final List<StatusListResponse> result = new ArrayList<>();
|
||||
if (mAccountIds == null) return result;
|
||||
int idx = 0;
|
||||
@ -2169,14 +2159,9 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
return result;
|
||||
}
|
||||
|
||||
final boolean isSinceIdsValid() {
|
||||
return mSinceIds != null && mSinceIds.length == mAccountIds.length;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
abstract class GetTrendsTask extends ManagedAsyncTask<Void, Void, ListResponse<Trends>> {
|
||||
abstract class GetTrendsTask extends ManagedAsyncTask<Object, Object, ListResponse<Trends>> {
|
||||
|
||||
private final long account_id;
|
||||
|
||||
@ -2188,7 +2173,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
public abstract List<Trends> getTrends(Twitter twitter) throws TwitterException;
|
||||
|
||||
@Override
|
||||
protected ListResponse<Trends> doInBackground(final Void... params) {
|
||||
protected ListResponse<Trends> doInBackground(final Object... params) {
|
||||
final Twitter twitter = getTwitterInstance(mContext, account_id, false);
|
||||
final Bundle extras = new Bundle();
|
||||
extras.putLong(EXTRA_ACCOUNT_ID, account_id);
|
||||
@ -2204,7 +2189,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
|
||||
}
|
||||
|
||||
final class RemoveUnreadCountsTask extends AsyncTask<Void, Void, Integer> {
|
||||
final class RemoveUnreadCountsTask extends AsyncTask<Object, Object, Integer> {
|
||||
private final int position;
|
||||
private final LongSparseArray<Set<Long>> counts;
|
||||
|
||||
@ -2214,13 +2199,13 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Integer doInBackground(final Void... params) {
|
||||
protected Integer doInBackground(final Object... params) {
|
||||
return removeUnreadCounts(mContext, position, counts);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class ReportMultiSpamTask extends ManagedAsyncTask<Void, Void, ListResponse<Long>> {
|
||||
class ReportMultiSpamTask extends ManagedAsyncTask<Object, Object, ListResponse<Long>> {
|
||||
|
||||
private final long account_id;
|
||||
private final long[] user_ids;
|
||||
@ -2232,7 +2217,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ListResponse<Long> doInBackground(final Void... params) {
|
||||
protected ListResponse<Long> doInBackground(final Object... params) {
|
||||
|
||||
final Bundle extras = new Bundle();
|
||||
extras.putLong(EXTRA_ACCOUNT_ID, account_id);
|
||||
@ -2274,7 +2259,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
|
||||
}
|
||||
|
||||
class ReportSpamTask extends ManagedAsyncTask<Void, Void, SingleResponse<ParcelableUser>> {
|
||||
class ReportSpamTask extends ManagedAsyncTask<Object, Object, SingleResponse<ParcelableUser>> {
|
||||
|
||||
private final long mAccountId;
|
||||
private final long user_id;
|
||||
@ -2286,7 +2271,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SingleResponse<ParcelableUser> doInBackground(final Void... params) {
|
||||
protected SingleResponse<ParcelableUser> doInBackground(final Object... params) {
|
||||
final Twitter twitter = getTwitterInstance(mContext, mAccountId, false);
|
||||
if (twitter != null) {
|
||||
try {
|
||||
@ -2318,7 +2303,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
|
||||
}
|
||||
|
||||
class RetweetStatusTask extends ManagedAsyncTask<Void, Void, SingleResponse<ParcelableStatus>> {
|
||||
class RetweetStatusTask extends ManagedAsyncTask<Object, Object, SingleResponse<ParcelableStatus>> {
|
||||
|
||||
private final long account_id;
|
||||
|
||||
@ -2331,7 +2316,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SingleResponse<ParcelableStatus> doInBackground(final Void... params) {
|
||||
protected SingleResponse<ParcelableStatus> doInBackground(final Object... params) {
|
||||
if (account_id < 0) return SingleResponse.getInstance();
|
||||
final Twitter twitter = getTwitterInstance(mContext, account_id, true);
|
||||
if (twitter == null) {
|
||||
@ -2414,7 +2399,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
|
||||
}
|
||||
|
||||
class StoreTrendsTask extends ManagedAsyncTask<Void, Void, SingleResponse<Boolean>> {
|
||||
class StoreTrendsTask extends ManagedAsyncTask<Object, Object, SingleResponse<Boolean>> {
|
||||
|
||||
private final ListResponse<Trends> response;
|
||||
private final Uri uri;
|
||||
@ -2426,7 +2411,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SingleResponse<Boolean> doInBackground(final Void... args) {
|
||||
protected SingleResponse<Boolean> doInBackground(final Object... args) {
|
||||
if (response == null) return SingleResponse.getInstance(false);
|
||||
final List<Trends> messages = response.list;
|
||||
final ArrayList<String> hashtags = new ArrayList<>();
|
||||
@ -2465,7 +2450,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
|
||||
}
|
||||
|
||||
class UpdateUserListDetailsTask extends ManagedAsyncTask<Void, Void, SingleResponse<ParcelableUserList>> {
|
||||
class UpdateUserListDetailsTask extends ManagedAsyncTask<Object, Object, SingleResponse<ParcelableUserList>> {
|
||||
|
||||
private final long accountId;
|
||||
private final long listId;
|
||||
@ -2483,7 +2468,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SingleResponse<ParcelableUserList> doInBackground(final Void... params) {
|
||||
protected SingleResponse<ParcelableUserList> doInBackground(final Object... params) {
|
||||
|
||||
final Twitter twitter = getTwitterInstance(mContext, accountId, false);
|
||||
if (twitter != null) {
|
||||
|
@ -50,17 +50,11 @@ public class MediaLoaderWrapper implements Constants {
|
||||
final DisplayImageOptions.Builder profileOptsBuilder = new DisplayImageOptions.Builder();
|
||||
profileOptsBuilder.cacheInMemory(true);
|
||||
profileOptsBuilder.cacheOnDisk(true);
|
||||
// profileOptsBuilder.showImageForEmptyUri(R.drawable.ic_profile_image_default);
|
||||
// profileOptsBuilder.showImageOnFail(R.drawable.ic_profile_image_default);
|
||||
// profileOptsBuilder.showImageOnLoading(R.drawable.ic_profile_image_default);
|
||||
profileOptsBuilder.bitmapConfig(Bitmap.Config.ARGB_8888);
|
||||
profileOptsBuilder.resetViewBeforeLoading(true);
|
||||
final DisplayImageOptions.Builder ovalProfileOptsBuilder = new DisplayImageOptions.Builder();
|
||||
ovalProfileOptsBuilder.cacheInMemory(true);
|
||||
ovalProfileOptsBuilder.cacheOnDisk(true);
|
||||
// ovalProfileOptsBuilder.showImageForEmptyUri(R.drawable.ic_profile_image_default);
|
||||
// ovalProfileOptsBuilder.showImageOnFail(R.drawable.ic_profile_image_default);
|
||||
// ovalProfileOptsBuilder.showImageOnLoading(R.drawable.ic_profile_image_default);
|
||||
ovalProfileOptsBuilder.bitmapConfig(Bitmap.Config.ARGB_8888);
|
||||
ovalProfileOptsBuilder.displayer(new OvalBitmapDisplayer());
|
||||
ovalProfileOptsBuilder.resetViewBeforeLoading(true);
|
||||
@ -77,7 +71,6 @@ public class MediaLoaderWrapper implements Constants {
|
||||
bannerOptsBuilder.bitmapConfig(Bitmap.Config.RGB_565);
|
||||
bannerOptsBuilder.displayer(new FadeInBitmapDisplayer(200, true, true, true));
|
||||
final DisplayImageOptions.Builder dashboardProfileOptsBuilder = new DisplayImageOptions.Builder();
|
||||
// dashboardProfileOptsBuilder.showImageOnLoading(android.R.color.transparent);
|
||||
dashboardProfileOptsBuilder.cacheInMemory(true);
|
||||
dashboardProfileOptsBuilder.cacheOnDisk(true);
|
||||
dashboardProfileOptsBuilder.bitmapConfig(Bitmap.Config.RGB_565);
|
||||
|
@ -40,7 +40,7 @@ import java.io.IOException;
|
||||
import static android.text.TextUtils.isEmpty;
|
||||
import static org.mariotaku.twidere.util.Utils.getImageMimeType;
|
||||
|
||||
public class SaveImageTask extends AsyncTask<Void, Void, File> implements Constants {
|
||||
public class SaveImageTask extends AsyncTask<Object, Object, File> implements Constants {
|
||||
|
||||
private static final String PROGRESS_FRAGMENT_TAG = "progress";
|
||||
|
||||
@ -53,7 +53,7 @@ public class SaveImageTask extends AsyncTask<Void, Void, File> implements Consta
|
||||
}
|
||||
|
||||
@Override
|
||||
protected File doInBackground(final Void... args) {
|
||||
protected File doInBackground(final Object... args) {
|
||||
if (src == null) return null;
|
||||
return saveImage(activity, src);
|
||||
}
|
||||
|
@ -537,21 +537,17 @@ public final class Utils implements Constants, TwitterConstants {
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
public static Expression buildStatusFilterWhereClause(final String table, final Expression extraSelection,
|
||||
final boolean enableInRts) {
|
||||
public static Expression buildStatusFilterWhereClause(final String table, final Expression extraSelection) {
|
||||
if (table == null) return null;
|
||||
final SQLSelectQuery filteredUsersQuery = SQLQueryBuilder
|
||||
.select(new Column(new Table(Filters.Users.TABLE_NAME), Filters.Users.USER_ID))
|
||||
.from(new Tables(Filters.Users.TABLE_NAME))
|
||||
.build();
|
||||
final Expression filteredUsersWhere;
|
||||
if (enableInRts) {
|
||||
filteredUsersWhere = Expression.or(
|
||||
Expression.in(new Column(new Table(table), Statuses.USER_ID), filteredUsersQuery),
|
||||
Expression.in(new Column(new Table(table), Statuses.RETWEETED_BY_USER_ID), filteredUsersQuery));
|
||||
} else {
|
||||
filteredUsersWhere = Expression.in(new Column(new Table(table), Statuses.USER_ID), filteredUsersQuery);
|
||||
}
|
||||
final Expression filteredUsersWhere = Expression.or(
|
||||
Expression.in(new Column(new Table(table), Statuses.USER_ID), filteredUsersQuery),
|
||||
Expression.in(new Column(new Table(table), Statuses.RETWEETED_BY_USER_ID), filteredUsersQuery),
|
||||
Expression.in(new Column(new Table(table), Statuses.QUOTED_BY_USER_ID), filteredUsersQuery)
|
||||
);
|
||||
final SQLSelectQuery.Builder filteredIdsQueryBuilder = SQLQueryBuilder
|
||||
.select(true, new Column(new Table(table), Statuses._ID))
|
||||
.from(new Tables(table))
|
||||
@ -559,18 +555,30 @@ public final class Utils implements Constants, TwitterConstants {
|
||||
.union()
|
||||
.select(true, new Columns(new Column(new Table(table), Statuses._ID)))
|
||||
.from(new Tables(table, Filters.Sources.TABLE_NAME))
|
||||
.where(Expression.likeRaw(new Column(new Table(table), Statuses.SOURCE),
|
||||
"'%>'||" + Filters.Sources.TABLE_NAME + "." + Filters.Sources.VALUE + "||'</a>%'"))
|
||||
.where(Expression.or(
|
||||
Expression.likeRaw(new Column(new Table(table), Statuses.SOURCE),
|
||||
"'%>'||" + Filters.Sources.TABLE_NAME + "." + Filters.Sources.VALUE + "||'</a>%'"),
|
||||
Expression.likeRaw(new Column(new Table(table), Statuses.QUOTE_SOURCE),
|
||||
"'%>'||" + Filters.Sources.TABLE_NAME + "." + Filters.Sources.VALUE + "||'</a>%'")
|
||||
))
|
||||
.union()
|
||||
.select(true, new Columns(new Column(new Table(table), Statuses._ID)))
|
||||
.from(new Tables(table, Filters.Keywords.TABLE_NAME))
|
||||
.where(Expression.likeRaw(new Column(new Table(table), Statuses.TEXT_PLAIN),
|
||||
"'%'||" + Filters.Keywords.TABLE_NAME + "." + Filters.Keywords.VALUE + "||'%'"))
|
||||
.where(Expression.or(
|
||||
Expression.likeRaw(new Column(new Table(table), Statuses.TEXT_PLAIN),
|
||||
"'%'||" + Filters.Keywords.TABLE_NAME + "." + Filters.Keywords.VALUE + "||'%'"),
|
||||
Expression.likeRaw(new Column(new Table(table), Statuses.QUOTE_TEXT_PLAIN),
|
||||
"'%'||" + Filters.Keywords.TABLE_NAME + "." + Filters.Keywords.VALUE + "||'%'")
|
||||
))
|
||||
.union()
|
||||
.select(true, new Columns(new Column(new Table(table), Statuses._ID)))
|
||||
.from(new Tables(table, Filters.Links.TABLE_NAME))
|
||||
.where(Expression.likeRaw(new Column(new Table(table), Statuses.TEXT_HTML),
|
||||
"'%>%'||" + Filters.Links.TABLE_NAME + "." + Filters.Links.VALUE + "||'%</a>%'"));
|
||||
.where(Expression.or(
|
||||
Expression.likeRaw(new Column(new Table(table), Statuses.TEXT_HTML),
|
||||
"'%>%'||" + Filters.Links.TABLE_NAME + "." + Filters.Links.VALUE + "||'%</a>%'"),
|
||||
Expression.likeRaw(new Column(new Table(table), Statuses.QUOTE_TEXT_HTML),
|
||||
"'%>%'||" + Filters.Links.TABLE_NAME + "." + Filters.Links.VALUE + "||'%</a>%'")
|
||||
));
|
||||
final Expression filterExpression = Expression.or(
|
||||
Expression.notIn(new Column(new Table(table), Statuses._ID), filteredIdsQueryBuilder.build()),
|
||||
Expression.equals(new Column(new Table(table), Statuses.IS_GAP), 1)
|
||||
@ -1455,7 +1463,7 @@ public final class Utils implements Constants, TwitterConstants {
|
||||
if (context == null) return 0;
|
||||
final ContentResolver resolver = context.getContentResolver();
|
||||
final Cursor cur = ContentResolverUtils.query(resolver, uri, new String[]{Statuses.STATUS_ID},
|
||||
buildStatusFilterWhereClause(getTableNameByUri(uri), null, shouldEnableFiltersForRTs(context)).getSQL(),
|
||||
buildStatusFilterWhereClause(getTableNameByUri(uri), null).getSQL(),
|
||||
null, null);
|
||||
if (cur == null) return 0;
|
||||
try {
|
||||
@ -1477,7 +1485,7 @@ public final class Utils implements Constants, TwitterConstants {
|
||||
final Expression selection = Expression.and(
|
||||
Expression.in(new Column(Statuses.ACCOUNT_ID), idsIn),
|
||||
Expression.greaterThan(Statuses.STATUS_ID, sinceId),
|
||||
buildStatusFilterWhereClause(getTableNameByUri(uri), null, shouldEnableFiltersForRTs(context))
|
||||
buildStatusFilterWhereClause(getTableNameByUri(uri), null)
|
||||
);
|
||||
final Cursor cur = ContentResolverUtils.query(resolver, uri, new String[]{SQLFunctions.COUNT()},
|
||||
selection.getSQL(),
|
||||
@ -1497,7 +1505,7 @@ public final class Utils implements Constants, TwitterConstants {
|
||||
if (context == null) return new long[0];
|
||||
final ContentResolver resolver = context.getContentResolver();
|
||||
final Cursor cur = ContentResolverUtils.query(resolver, uri, new String[]{Statuses.STATUS_ID},
|
||||
buildStatusFilterWhereClause(getTableNameByUri(uri), null, shouldEnableFiltersForRTs(context)).getSQL(),
|
||||
buildStatusFilterWhereClause(getTableNameByUri(uri), null).getSQL(),
|
||||
null, null);
|
||||
if (cur == null) return new long[0];
|
||||
final long[] ids = new long[cur.getCount()];
|
||||
@ -3667,12 +3675,6 @@ public final class Utils implements Constants, TwitterConstants {
|
||||
"5.32.0", 3030745, 'r', 692, deviceInfo));
|
||||
}
|
||||
|
||||
public static boolean shouldEnableFiltersForRTs(final Context context) {
|
||||
if (context == null) return false;
|
||||
final SharedPreferences prefs = context.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE);
|
||||
return prefs.getBoolean(KEY_FILTERS_FOR_RTS, true);
|
||||
}
|
||||
|
||||
public static boolean shouldForceUsingPrivateAPIs(final Context context) {
|
||||
if (context == null) return false;
|
||||
final SharedPreferences prefs = context.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE);
|
||||
|
@ -94,7 +94,7 @@ public class VideoLoader {
|
||||
void onVideoLoadingStarted(String uri, VideoLoadingListener listener);
|
||||
}
|
||||
|
||||
private static class PreLoadVideoTask extends ManagedAsyncTask<Void, Integer, SingleResponse<File>> implements IoUtils.CopyListener {
|
||||
private static class PreLoadVideoTask extends ManagedAsyncTask<Object, Integer, SingleResponse<File>> implements IoUtils.CopyListener {
|
||||
|
||||
private final VideoLoader mPreLoader;
|
||||
private final VideoLoadingListener mListener;
|
||||
@ -115,7 +115,7 @@ public class VideoLoader {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SingleResponse<File> doInBackground(Void... params) {
|
||||
protected SingleResponse<File> doInBackground(Object... params) {
|
||||
final File file = mPreLoader.mDiskCache.get(mUri);
|
||||
if (file.isFile() && file.length() > 0) return SingleResponse.getInstance(file);
|
||||
try {
|
||||
|
@ -30,9 +30,11 @@ public class GetMessagesTaskEvent {
|
||||
@NonNull
|
||||
public final Uri uri;
|
||||
public final boolean running;
|
||||
private final Exception exception;
|
||||
|
||||
public GetMessagesTaskEvent(@NonNull Uri uri, boolean running) {
|
||||
public GetMessagesTaskEvent(@NonNull Uri uri, boolean running, Exception exception) {
|
||||
this.uri = uri;
|
||||
this.running = running;
|
||||
this.exception = exception;
|
||||
}
|
||||
}
|
||||
|
@ -30,9 +30,11 @@ public class GetStatusesTaskEvent {
|
||||
@NonNull
|
||||
public final Uri uri;
|
||||
public final boolean running;
|
||||
public final Exception exception;
|
||||
|
||||
public GetStatusesTaskEvent(@NonNull Uri uri, boolean running) {
|
||||
public GetStatusesTaskEvent(@NonNull Uri uri, boolean running, Exception exception) {
|
||||
this.uri = uri;
|
||||
this.running = running;
|
||||
this.exception = exception;
|
||||
}
|
||||
}
|
||||
|
@ -54,7 +54,11 @@ public class ShortTimeView extends ThemedTextView implements Constants, OnShared
|
||||
public ShortTimeView(final Context context, final AttributeSet attrs, final int defStyle) {
|
||||
super(context, attrs, defStyle);
|
||||
mTicker = new TickerRunnable(this);
|
||||
mPreferences = context.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE);
|
||||
if (!isInEditMode()) {
|
||||
mPreferences = context.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE);
|
||||
} else {
|
||||
mPreferences = null;
|
||||
}
|
||||
if (mPreferences != null) {
|
||||
mPreferences.registerOnSharedPreferenceChangeListener(this);
|
||||
}
|
||||
|
@ -126,6 +126,7 @@ public class StatusViewHolder extends RecyclerView.ViewHolder implements Constan
|
||||
timeView.setTime(System.currentTimeMillis());
|
||||
mediaPreview.setVisibility(adapter.isMediaPreviewEnabled() ? View.VISIBLE : View.GONE);
|
||||
mediaPreview.displayMedia(R.drawable.nyan_stars_background);
|
||||
extraTypeView.setImageResource(R.drawable.ic_action_gallery);
|
||||
}
|
||||
|
||||
public void displayStatus(final ParcelableStatus status, final boolean displayInReplyTo) {
|
||||
|
@ -103,8 +103,10 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignTop="@id/profile_image_space"
|
||||
android:layout_marginBottom="@dimen/element_spacing_normal"
|
||||
android:layout_marginLeft="@dimen/element_spacing_normal"
|
||||
android:layout_toRightOf="@id/profile_image_space"
|
||||
android:minHeight="@dimen/icon_size_status_profile_image"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
@ -238,7 +240,6 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/media_preview"
|
||||
android:layout_marginBottom="@dimen/element_spacing_small"
|
||||
android:layout_marginTop="@dimen/element_spacing_small"
|
||||
android:layout_toRightOf="@+id/quote_indicator"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
@ -254,7 +255,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignLeft="@id/status_content"
|
||||
android:layout_below="@+id/status_content"
|
||||
android:layout_marginTop="@dimen/element_spacing_minus_small"
|
||||
android:layout_marginTop="@dimen/element_spacing_minus_normal"
|
||||
android:layout_toLeftOf="@+id/item_menu"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal">
|
||||
@ -311,11 +312,11 @@
|
||||
android:id="@+id/item_menu"
|
||||
style="?cardActionButtonStyle"
|
||||
android:layout_width="@dimen/button_size_content_card"
|
||||
android:layout_height="@dimen/button_size_content_card"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignBottom="@+id/action_buttons"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_alignTop="@+id/action_buttons"
|
||||
android:layout_marginTop="@dimen/element_spacing_minus_small"
|
||||
android:layout_marginTop="@dimen/element_spacing_minus_normal"
|
||||
android:color="?android:textColorTertiary"
|
||||
android:focusable="false"
|
||||
android:src="@drawable/ic_action_more_horizontal"/>
|
||||
|
@ -7,23 +7,5 @@
|
||||
android:icon="@drawable/ic_action_add"
|
||||
app:showAsAction="always"
|
||||
android:title="@string/add_rule"/>
|
||||
<item
|
||||
android:id="@+id/enable_in_home_timeline"
|
||||
android:checkable="true"
|
||||
android:checked="true"
|
||||
android:icon="@drawable/ic_action_home"
|
||||
android:title="@string/enable_in_home_timeline"/>
|
||||
<item
|
||||
android:id="@+id/enable_in_mentions"
|
||||
android:checkable="true"
|
||||
android:checked="true"
|
||||
android:icon="@drawable/ic_action_at"
|
||||
android:title="@string/enable_in_mentions"/>
|
||||
<item
|
||||
android:id="@+id/enable_for_rts"
|
||||
android:checkable="true"
|
||||
android:checked="true"
|
||||
android:icon="@drawable/ic_action_retweet"
|
||||
android:title="@string/enable_for_rts"/>
|
||||
|
||||
</menu>
|
@ -192,6 +192,20 @@
|
||||
<item name="android:dividerVertical">@drawable/divider_compose_vertical_dark</item>
|
||||
<item name="android:windowActionBarOverlay">false</item>
|
||||
<item name="android:windowActionModeOverlay">false</item>
|
||||
|
||||
<!-- Custom view styles -->
|
||||
|
||||
<!-- Card UI styles -->
|
||||
<item name="cardActionButtonStyle">@style/Widget.CardActionButton</item>
|
||||
<item name="profileImageStyle">@style/Widget.ProfileImage</item>
|
||||
<item name="profileImageStyleLarge">@style/Widget.ProfileImage.Large</item>
|
||||
<item name="cardItemBackgroundColor">@color/background_color_card_item_dark</item>
|
||||
|
||||
|
||||
<!-- Twidere specific styles -->
|
||||
<item name="menuIconColor">@color/action_icon_light</item>
|
||||
<item name="menuIconColorActionBar">?menuIconColor</item>
|
||||
<item name="messageBubbleColor">@color/message_bubble_color_dark</item>
|
||||
</style>
|
||||
|
||||
<style name="Theme.Twidere.Light.Compose" parent="Theme.Compat.Base.Light.Dialog">
|
||||
@ -203,6 +217,20 @@
|
||||
<item name="android:dividerVertical">@drawable/divider_compose_vertical_light</item>
|
||||
<item name="android:windowActionBarOverlay">false</item>
|
||||
<item name="android:windowActionModeOverlay">false</item>
|
||||
|
||||
<!-- Custom view styles -->
|
||||
|
||||
<!-- Card UI styles -->
|
||||
<item name="cardActionButtonStyle">@style/Widget.Light.CardActionButton</item>
|
||||
<item name="profileImageStyle">@style/Widget.Light.ProfileImage</item>
|
||||
<item name="profileImageStyleLarge">@style/Widget.Light.ProfileImage.Large</item>
|
||||
<item name="cardItemBackgroundColor">@color/background_color_card_item_light</item>
|
||||
|
||||
|
||||
<!-- Twidere specific styles -->
|
||||
<item name="menuIconColor">@color/action_icon_dark</item>
|
||||
<item name="menuIconColorActionBar">?menuIconColor</item>
|
||||
<item name="messageBubbleColor">@color/message_bubble_color_light</item>
|
||||
</style>
|
||||
|
||||
<style name="Theme.Twidere.Light.QuickSearchBar" parent="Theme.Twidere.Light.Dialog">
|
||||
|
@ -15,24 +15,25 @@
|
||||
android:key="name_first"
|
||||
android:order="22"
|
||||
android:title="@string/name_first"/>
|
||||
|
||||
<org.mariotaku.twidere.preference.AutoFixCheckBoxPreference
|
||||
android:defaultValue="true"
|
||||
android:key="display_profile_image"
|
||||
android:order="23"
|
||||
android:title="@string/profile_image"/>
|
||||
<org.mariotaku.twidere.preference.AutoFixCheckBoxPreference
|
||||
android:defaultValue="false"
|
||||
android:key="media_preview"
|
||||
android:order="24"
|
||||
android:title="@string/media_preview"/>
|
||||
<org.mariotaku.twidere.preference.SummaryListPreference
|
||||
android:defaultValue="@string/default_profile_image_style"
|
||||
android:entries="@array/entries_profile_image_style"
|
||||
android:entryValues="@array/values_profile_image_style"
|
||||
android:key="profile_image_style"
|
||||
android:order="25"
|
||||
android:order="24"
|
||||
android:title="@string/profile_image_style"/>
|
||||
|
||||
<org.mariotaku.twidere.preference.AutoFixCheckBoxPreference
|
||||
android:defaultValue="false"
|
||||
android:key="media_preview"
|
||||
android:order="25"
|
||||
android:title="@string/media_preview"/>
|
||||
<org.mariotaku.twidere.preference.SummaryListPreference
|
||||
android:defaultValue="crop"
|
||||
android:entries="@array/entries_media_preview_style"
|
||||
|
Loading…
x
Reference in New Issue
Block a user