supports save gif
This commit is contained in:
parent
c10d3adbed
commit
b001619524
|
@ -88,7 +88,7 @@ import org.mariotaku.twidere.model.ParcelableStatus;
|
|||
import org.mariotaku.twidere.model.UserKey;
|
||||
import org.mariotaku.twidere.provider.CacheProvider;
|
||||
import org.mariotaku.twidere.task.SaveFileTask;
|
||||
import org.mariotaku.twidere.task.SaveImageToGalleryTask;
|
||||
import org.mariotaku.twidere.task.SaveMediaToGalleryTask;
|
||||
import org.mariotaku.twidere.util.AsyncTaskUtils;
|
||||
import org.mariotaku.twidere.util.IntentUtils;
|
||||
import org.mariotaku.twidere.util.MenuUtils;
|
||||
|
@ -527,9 +527,11 @@ public final class MediaViewerActivity extends AbsMediaViewerActivity implements
|
|||
final boolean hasMedia = cacheUri != null;
|
||||
if (!hasMedia) return;
|
||||
if (f instanceof ImagePageFragment) {
|
||||
mSaveFileTask = SaveImageToGalleryTask.create(this, cacheUri, CacheProvider.Type.IMAGE);
|
||||
mSaveFileTask = SaveMediaToGalleryTask.create(this, cacheUri, CacheProvider.Type.IMAGE);
|
||||
} else if (f instanceof VideoPageFragment) {
|
||||
mSaveFileTask = SaveImageToGalleryTask.create(this, cacheUri, CacheProvider.Type.VIDEO);
|
||||
mSaveFileTask = SaveMediaToGalleryTask.create(this, cacheUri, CacheProvider.Type.VIDEO);
|
||||
} else if (f instanceof GifPageFragment) {
|
||||
mSaveFileTask = SaveMediaToGalleryTask.create(this, cacheUri, CacheProvider.Type.IMAGE);
|
||||
} else {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
|
|
@ -25,7 +25,6 @@ import android.net.Uri;
|
|||
import android.os.AsyncTask;
|
||||
import android.os.AsyncTask.Status;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.support.v4.app.Fragment;
|
||||
|
@ -36,6 +35,7 @@ import android.support.v4.app.LoaderManager.LoaderCallbacks;
|
|||
import android.support.v4.content.Loader;
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
import android.util.Pair;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
|
@ -58,11 +58,16 @@ import org.mariotaku.twidere.api.twitter.model.ProfileUpdate;
|
|||
import org.mariotaku.twidere.api.twitter.model.User;
|
||||
import org.mariotaku.twidere.fragment.iface.IBaseFragment;
|
||||
import org.mariotaku.twidere.loader.ParcelableUserLoader;
|
||||
import org.mariotaku.twidere.model.ParcelableAccount;
|
||||
import org.mariotaku.twidere.model.ParcelableCredentials;
|
||||
import org.mariotaku.twidere.model.ParcelableUser;
|
||||
import org.mariotaku.twidere.model.SingleResponse;
|
||||
import org.mariotaku.twidere.model.UserKey;
|
||||
import org.mariotaku.twidere.model.util.ParcelableCredentialsUtils;
|
||||
import org.mariotaku.twidere.model.util.ParcelableUserUtils;
|
||||
import org.mariotaku.twidere.task.UpdateAccountInfoTask;
|
||||
import org.mariotaku.twidere.task.UpdateProfileBannerImageTask;
|
||||
import org.mariotaku.twidere.task.util.TaskStarter;
|
||||
import org.mariotaku.twidere.util.AsyncTaskUtils;
|
||||
import org.mariotaku.twidere.util.AsyncTwitterWrapper.UpdateProfileImageTask;
|
||||
import org.mariotaku.twidere.util.HtmlEscapeHelper;
|
||||
|
@ -415,7 +420,6 @@ public class UserProfileEditorFragment extends BaseSupportFragment implements On
|
|||
private static final String DIALOG_FRAGMENT_TAG = "updating_user_profile";
|
||||
private final UserProfileEditorFragment mFragment;
|
||||
private final FragmentActivity mActivity;
|
||||
private final Handler mHandler;
|
||||
|
||||
// Data fields
|
||||
private final UserKey mAccountKey;
|
||||
|
@ -434,7 +438,6 @@ public class UserProfileEditorFragment extends BaseSupportFragment implements On
|
|||
final int backgroundColor) {
|
||||
mFragment = fragment;
|
||||
mActivity = fragment.getActivity();
|
||||
mHandler = new Handler(mActivity.getMainLooper());
|
||||
mAccountKey = accountKey;
|
||||
mOriginal = original;
|
||||
mName = name;
|
||||
|
@ -447,7 +450,11 @@ public class UserProfileEditorFragment extends BaseSupportFragment implements On
|
|||
|
||||
@Override
|
||||
protected SingleResponse<ParcelableUser> doInBackground(final Object... params) {
|
||||
final Twitter twitter = TwitterAPIFactory.getTwitterInstance(mActivity, mAccountKey, true);
|
||||
final ParcelableCredentials credentials = ParcelableCredentialsUtils.getCredentials(mActivity, mAccountKey);
|
||||
if (credentials == null) return SingleResponse.getInstance();
|
||||
final Twitter twitter = TwitterAPIFactory.getTwitterInstance(mActivity, credentials,
|
||||
true, true);
|
||||
if (twitter == null) return SingleResponse.getInstance();
|
||||
try {
|
||||
User user = null;
|
||||
if (isProfileChanged()) {
|
||||
|
@ -464,7 +471,10 @@ public class UserProfileEditorFragment extends BaseSupportFragment implements On
|
|||
// User profile unchanged
|
||||
return SingleResponse.getInstance();
|
||||
}
|
||||
return SingleResponse.getInstance(ParcelableUserUtils.fromUser(user, mAccountKey));
|
||||
final SingleResponse<ParcelableUser> response = SingleResponse.getInstance(
|
||||
ParcelableUserUtils.fromUser(user, mAccountKey));
|
||||
response.getExtras().putParcelable(EXTRA_ACCOUNT, credentials);
|
||||
return response;
|
||||
} catch (TwitterException e) {
|
||||
return SingleResponse.getInstance(e);
|
||||
}
|
||||
|
@ -487,18 +497,31 @@ public class UserProfileEditorFragment extends BaseSupportFragment implements On
|
|||
@Override
|
||||
protected void onPostExecute(final SingleResponse<ParcelableUser> result) {
|
||||
super.onPostExecute(result);
|
||||
final Fragment f = mFragment.getFragmentManager().findFragmentByTag(DIALOG_FRAGMENT_TAG);
|
||||
if (f instanceof DialogFragment) {
|
||||
((DialogFragment) f).dismissAllowingStateLoss();
|
||||
if (result.hasData()) {
|
||||
final ParcelableAccount account = result.getExtras().getParcelable(EXTRA_ACCOUNT);
|
||||
if (account != null) {
|
||||
final UpdateAccountInfoTask task = new UpdateAccountInfoTask(mActivity);
|
||||
task.setParams(Pair.create(account, result.getData()));
|
||||
TaskStarter.execute(task);
|
||||
}
|
||||
}
|
||||
mFragment.getActivity().finish();
|
||||
mFragment.executeAfterFragmentResumed(new Action() {
|
||||
@Override
|
||||
public void execute(IBaseFragment fragment) {
|
||||
final Fragment f = mFragment.getFragmentManager().findFragmentByTag(DIALOG_FRAGMENT_TAG);
|
||||
if (f instanceof DialogFragment) {
|
||||
((DialogFragment) f).dismissAllowingStateLoss();
|
||||
}
|
||||
mFragment.getActivity().finish();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPreExecute() {
|
||||
mHandler.post(new Runnable() {
|
||||
mFragment.executeAfterFragmentResumed(new Action() {
|
||||
@Override
|
||||
public void run() {
|
||||
public void execute(IBaseFragment fragment) {
|
||||
final DialogFragment df = SupportProgressDialogFragment.show(mFragment.getActivity(), DIALOG_FRAGMENT_TAG);
|
||||
df.setCancelable(false);
|
||||
}
|
||||
|
|
|
@ -36,9 +36,9 @@ import java.io.File;
|
|||
/**
|
||||
* Created by mariotaku on 15/12/28.
|
||||
*/
|
||||
public class SaveImageToGalleryTask extends ProgressSaveFileTask {
|
||||
public class SaveMediaToGalleryTask extends ProgressSaveFileTask {
|
||||
|
||||
public SaveImageToGalleryTask(@NonNull Activity activity, @NonNull Uri source, @NonNull File destination, String type) {
|
||||
public SaveMediaToGalleryTask(@NonNull Activity activity, @NonNull Uri source, @NonNull File destination, String type) {
|
||||
super(activity, source, destination, new CacheProvider.CacheFileTypeCallback(activity, type));
|
||||
}
|
||||
|
||||
|
@ -60,7 +60,7 @@ public class SaveImageToGalleryTask extends ProgressSaveFileTask {
|
|||
}
|
||||
}
|
||||
final File saveDir = new File(pubDir, "Twidere");
|
||||
return new SaveImageToGalleryTask(activity, source, saveDir, type);
|
||||
return new SaveMediaToGalleryTask(activity, source, saveDir, type);
|
||||
}
|
||||
|
||||
@Override
|
|
@ -64,12 +64,15 @@ public class UpdateAccountInfoTask extends AbstractTask<Pair<ParcelableAccount,
|
|||
|
||||
final ContentValues accountKeyValues = new ContentValues();
|
||||
accountKeyValues.put(AccountSupportColumns.ACCOUNT_KEY, String.valueOf(user.key));
|
||||
final String accountKeyWhere = Expression.equalsArgs(AccountSupportColumns.ACCOUNT_KEY).getSQL();
|
||||
final String[] accountKeyWhereArgs = {account.account_key.toString()};
|
||||
|
||||
resolver.update(Statuses.CONTENT_URI, accountKeyValues, accountWhere, accountWhereArgs);
|
||||
resolver.update(Activities.AboutMe.CONTENT_URI, accountKeyValues, accountWhere, accountWhereArgs);
|
||||
resolver.update(DirectMessages.Inbox.CONTENT_URI, accountKeyValues, accountWhere, accountWhereArgs);
|
||||
resolver.update(DirectMessages.Outbox.CONTENT_URI, accountKeyValues, accountWhere, accountWhereArgs);
|
||||
resolver.update(CachedRelationships.CONTENT_URI, accountKeyValues, accountWhere, accountWhereArgs);
|
||||
|
||||
resolver.update(Statuses.CONTENT_URI, accountKeyValues, accountKeyWhere, accountKeyWhereArgs);
|
||||
resolver.update(Activities.AboutMe.CONTENT_URI, accountKeyValues, accountKeyWhere, accountKeyWhereArgs);
|
||||
resolver.update(DirectMessages.Inbox.CONTENT_URI, accountKeyValues, accountKeyWhere, accountKeyWhereArgs);
|
||||
resolver.update(DirectMessages.Outbox.CONTENT_URI, accountKeyValues, accountKeyWhere, accountKeyWhereArgs);
|
||||
resolver.update(CachedRelationships.CONTENT_URI, accountKeyValues, accountKeyWhere, accountKeyWhereArgs);
|
||||
|
||||
updateTabs(context, resolver, user.key);
|
||||
|
||||
|
|
Loading…
Reference in New Issue