1
0
mirror of https://github.com/TwidereProject/Twidere-Android synced 2025-02-17 04:00:48 +01:00

updated task library

This commit is contained in:
Mariotaku Lee 2016-06-14 10:25:59 +08:00
parent da62d40487
commit e7edf60a96
12 changed files with 49 additions and 47 deletions

View File

@ -167,7 +167,7 @@ dependencies {
compile 'com.github.mariotaku.SQLiteQB:library:0.9.6'
compile 'com.github.mariotaku.ObjectCursor:core:0.9.9'
compile 'com.github.mariotaku:MultiValueSwitch:0.9.4'
compile 'com.github.mariotaku:AbstractTask:0.9.1'
compile 'com.github.mariotaku:AbstractTask:0.9.2'
compile 'com.github.mariotaku.CommonsLibrary:parcel:0.9.8'
compile 'com.github.mariotaku.CommonsLibrary:io:0.9.8'
}

View File

@ -391,7 +391,7 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
mFollowButton.setCompoundDrawablePadding(Math.round(mFollowButton.getTextSize() * 0.25f));
mFollowingYouIndicator.setVisibility(userRelationship.followed_by ? View.VISIBLE : View.GONE);
final CacheUserInfoRunnable task = new CacheUserInfoRunnable(getContext().getApplicationContext());
final CacheUserInfoTask task = new CacheUserInfoTask(getContext().getApplicationContext());
task.setParams(Pair.create(user, userRelationship));
TaskStarter.execute(task);
mFollowButton.setVisibility(View.VISIBLE);
@ -1849,11 +1849,11 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
}
private static class CacheUserInfoRunnable extends AbstractTask<Pair<ParcelableUser,
private static class CacheUserInfoTask extends AbstractTask<Pair<ParcelableUser,
? extends CachedRelationship>, Object, Object> {
private final Context context;
public CacheUserInfoRunnable(Context context) {
public CacheUserInfoTask(Context context) {
this.context = context;
}

View File

@ -447,7 +447,6 @@ public class UserProfileEditorFragment extends BaseSupportFragment implements On
UserProfileEditorFragment> {
private static final String DIALOG_FRAGMENT_TAG = "updating_user_profile";
private final UserProfileEditorFragment mFragment;
private final FragmentActivity mActivity;
// Data fields
@ -465,7 +464,6 @@ public class UserProfileEditorFragment extends BaseSupportFragment implements On
final String name, final String url, final String location,
final String description, final int linkColor,
final int backgroundColor) {
mFragment = fragment;
mActivity = fragment.getActivity();
mAccountKey = accountKey;
mOriginal = original;
@ -524,8 +522,8 @@ public class UserProfileEditorFragment extends BaseSupportFragment implements On
}
@Override
protected void afterExecute(SingleResponse<ParcelableUser> result) {
super.afterExecute(result);
protected void afterExecute(UserProfileEditorFragment callback, SingleResponse<ParcelableUser> result) {
super.afterExecute(callback, result);
if (result.hasData()) {
final ParcelableAccount account = result.getExtras().getParcelable(EXTRA_ACCOUNT);
if (account != null) {
@ -534,14 +532,14 @@ public class UserProfileEditorFragment extends BaseSupportFragment implements On
TaskStarter.execute(task);
}
}
mFragment.executeAfterFragmentResumed(new Action() {
callback.executeAfterFragmentResumed(new Action() {
@Override
public void execute(IBaseFragment fragment) {
final Fragment f = mFragment.getFragmentManager().findFragmentByTag(DIALOG_FRAGMENT_TAG);
final Fragment f = ((UserProfileEditorFragment) fragment).getFragmentManager().findFragmentByTag(DIALOG_FRAGMENT_TAG);
if (f instanceof DialogFragment) {
((DialogFragment) f).dismissAllowingStateLoss();
}
mFragment.getActivity().finish();
f.getActivity().finish();
}
});
}
@ -549,13 +547,16 @@ public class UserProfileEditorFragment extends BaseSupportFragment implements On
@Override
protected void beforeExecute() {
super.beforeExecute();
mFragment.executeAfterFragmentResumed(new Action() {
@Override
public void execute(IBaseFragment fragment) {
final DialogFragment df = ProgressDialogFragment.show(mFragment.getActivity(), DIALOG_FRAGMENT_TAG);
df.setCancelable(false);
}
});
final UserProfileEditorFragment callback = getCallback();
if (callback != null) {
callback.executeAfterFragmentResumed(new Action() {
@Override
public void execute(IBaseFragment fragment) {
final DialogFragment df = ProgressDialogFragment.show(((UserProfileEditorFragment) fragment).getActivity(), DIALOG_FRAGMENT_TAG);
df.setCancelable(false);
}
});
}
}
}
@ -574,8 +575,8 @@ public class UserProfileEditorFragment extends BaseSupportFragment implements On
}
@Override
protected void afterExecute(final SingleResponse<Boolean> result) {
super.afterExecute(result);
protected void afterExecute(UserProfileEditorFragment callback, final SingleResponse<Boolean> result) {
super.afterExecute(callback, result);
if (result.getData() != null && result.getData()) {
getUserInfo();
Toast.makeText(getActivity(), R.string.profile_banner_image_updated, Toast.LENGTH_SHORT).show();
@ -602,8 +603,8 @@ public class UserProfileEditorFragment extends BaseSupportFragment implements On
}
@Override
protected void afterExecute(final SingleResponse<ParcelableUser> result) {
super.afterExecute(result);
protected void afterExecute(UserProfileEditorFragment callback, final SingleResponse<ParcelableUser> result) {
super.afterExecute(callback, result);
setUpdateState(false);
getUserInfo();
}
@ -625,8 +626,8 @@ public class UserProfileEditorFragment extends BaseSupportFragment implements On
}
@Override
protected void afterExecute(final SingleResponse<ParcelableUser> result) {
super.afterExecute(result);
protected void afterExecute(UserProfileEditorFragment callback, final SingleResponse<ParcelableUser> result) {
super.afterExecute(callback, result);
setUpdateState(false);
getUserInfo();
}
@ -647,8 +648,8 @@ public class UserProfileEditorFragment extends BaseSupportFragment implements On
}
@Override
protected void afterExecute(SingleResponse<ParcelableUser> result) {
super.afterExecute(result);
protected void afterExecute(UserProfileEditorFragment callback, SingleResponse<ParcelableUser> result) {
super.afterExecute(callback, result);
if (result != null && result.getData() != null) {
displayUser(result.getData());
}

View File

@ -24,7 +24,6 @@ import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.mariotaku.twidere.TwidereConstants;
import org.mariotaku.twidere.annotation.CustomTabType;
@ -79,15 +78,15 @@ public class SupportTabSpec implements Comparable<SupportTabSpec>, TwidereConsta
@Override
public String toString() {
return new ToStringBuilder(this)
.append("name", name)
.append("icon", icon)
.append("type", type)
.append("cls", cls)
.append("args", args)
.append("position", position)
.append("tag", tag)
.toString();
return "SupportTabSpec{" +
"name=" + name +
", icon=" + icon +
", type='" + type + '\'' +
", cls=" + cls +
", args=" + args +
", position=" + position +
", tag='" + tag + '\'' +
'}';
}
}

View File

@ -61,7 +61,7 @@ public abstract class AbsFriendshipOperationTask extends AbstractTask<AbsFriends
}
@Override
protected final void afterExecute(SingleResponse<ParcelableUser> result) {
protected final void afterExecute(Object callback, SingleResponse<ParcelableUser> result) {
final Arguments params = getParams();
twitter.removeUpdatingRelationshipId(params.accountKey, params.userKey);
final FriendshipTaskEvent event = new FriendshipTaskEvent(action, params.accountKey,

View File

@ -145,7 +145,7 @@ public abstract class GetDirectMessagesTask extends AbstractTask<RefreshTaskPara
}
@Override
protected void afterExecute(List<TwitterWrapper.MessageListResponse> result) {
protected void afterExecute(Object callback, List<TwitterWrapper.MessageListResponse> result) {
bus.post(new GetMessagesTaskEvent(getDatabaseUri(), false, AsyncTwitterWrapper.getException(result)));
}
}

View File

@ -58,7 +58,7 @@ public abstract class GetTrendsTask extends AbstractTask<Object, Object, Object>
}
@Override
protected void afterExecute(Object o) {
protected void afterExecute(Object callback, Object result) {
mBus.post(new TrendsRefreshedEvent());
}

View File

@ -54,8 +54,8 @@ public class UpdateProfileBackgroundImageTask<ResultHandler> extends AbstractTas
}
@Override
protected void afterExecute(SingleResponse<ParcelableUser> result) {
super.afterExecute(result);
protected void afterExecute(ResultHandler callback, SingleResponse<ParcelableUser> result) {
super.afterExecute(callback, result);
if (result.hasData()) {
Utils.showOkMessage(mContext, R.string.profile_banner_image_updated, false);
mBus.post(new ProfileUpdatedEvent(result.getData()));

View File

@ -51,8 +51,8 @@ public class UpdateProfileBannerImageTask<ResultHandler> extends AbstractTask<Ob
}
@Override
protected void afterExecute(final SingleResponse<ParcelableUser> result) {
super.afterExecute(result);
protected void afterExecute(ResultHandler callback, final SingleResponse<ParcelableUser> result) {
super.afterExecute(callback, result);
if (result.hasData()) {
Utils.showOkMessage(mContext, R.string.profile_banner_image_updated, false);
mBus.post(new ProfileUpdatedEvent(result.getData()));

View File

@ -224,7 +224,7 @@ public abstract class GetActivitiesTask extends AbstractTask<RefreshTaskParam, O
throws MicroBlogException;
@Override
public void afterExecute(Object result) {
public void afterExecute(Object handler, Object result) {
context.getContentResolver().notifyChange(getContentUri(), null);
bus.post(new GetActivitiesTaskEvent(getContentUri(), false, null));
}

View File

@ -69,6 +69,8 @@ public abstract class GetStatusesTask extends AbstractTask<RefreshTaskParam,
protected ErrorInfoStore errorInfoStore;
@Inject
protected UserColorNameManager manager;
@Inject
protected AsyncTwitterWrapper wrapper;
public GetStatusesTask(Context context) {
this.context = context;
@ -86,7 +88,7 @@ public abstract class GetStatusesTask extends AbstractTask<RefreshTaskParam,
protected abstract String getTimelineType();
@Override
public void afterExecute(List<TwitterWrapper.StatusListResponse> result) {
public void afterExecute(Object handler, List<TwitterWrapper.StatusListResponse> result) {
context.getContentResolver().notifyChange(getContentUri(), null);
bus.post(new GetStatusesTaskEvent(getContentUri(), false, AsyncTwitterWrapper.getException(result)));
}

View File

@ -603,8 +603,8 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
}
@Override
protected void afterExecute(SingleResponse<ParcelableUser> result) {
super.afterExecute(result);
protected void afterExecute(ResultHandler handler, SingleResponse<ParcelableUser> result) {
super.afterExecute(handler, result);
if (result.hasData()) {
Utils.showOkMessage(mContext, R.string.profile_image_updated, false);
mBus.post(new ProfileUpdatedEvent(result.getData()));