fixed 404 error while upload media

This commit is contained in:
Mariotaku Lee 2015-04-07 12:19:40 +08:00
parent 6f8efb2b66
commit 5288fe34e9
11 changed files with 59 additions and 21 deletions

View File

@ -800,6 +800,8 @@ public interface TwidereDataStore {
IN_REPLY_TO_USER_SCREEN_NAME, SOURCE, LOCATION, RETWEET_COUNT, FAVORITE_COUNT, REPLY_COUNT,
DESCENDENT_REPLY_COUNT, RETWEET_ID, RETWEET_TIMESTAMP, RETWEETED_BY_USER_ID,
RETWEETED_BY_USER_NAME, RETWEETED_BY_USER_SCREEN_NAME, RETWEETED_BY_USER_PROFILE_IMAGE,
// QUOTE_ID, QUOTE_TEXT_HTML, QUOTE_TEXT_PLAIN, QUOTE_TEXT_UNESCAPED, QUOTE_TIMESTAMP,
// QUOTED_BY_USER_ID, QUOTED_BY_USER_NAME, QUOTED_BY_USER_SCREEN_NAME, QUOTED_BY_USER_PROFILE_IMAGE,
MY_RETWEET_ID, IS_RETWEET, IS_FAVORITE, IS_PROTECTED, IS_VERIFIED, IS_FOLLOWING, IS_GAP,
IS_POSSIBLY_SENSITIVE, MEDIA_LIST, MENTIONS_LIST, CARD_NAME, CARD, PLACE_FULL_NAME};

View File

@ -84,6 +84,7 @@ dependencies {
compile 'com.github.mariotaku:DragSortListView:0.6.1'
compile 'com.github.mariotaku:SlidingMenu:1.3'
compile 'com.github.uucky:ColorPicker-Android:0.9.1'
compile 'com.sprylab.android.texturevideoview:texturevideoview:1.0.0'
googleCompile 'com.google.android.gms:play-services-maps:7.0.0'
googleCompile 'com.google.maps.android:android-maps-utils:0.3.4'
fdroidCompile 'org.osmdroid:osmdroid-android:4.3'

View File

@ -41,10 +41,12 @@ import android.view.View.OnLayoutChangeListener;
import android.view.ViewGroup;
import android.webkit.WebView;
import android.widget.Toast;
import android.widget.VideoView;
import com.diegocarloslima.byakugallery.lib.TileBitmapDrawable;
import com.diegocarloslima.byakugallery.lib.TileBitmapDrawable.OnInitializeListener;
import com.pnikosis.materialishprogress.ProgressWheel;
import com.sprylab.android.widget.TextureVideoView;
import org.apache.commons.lang3.ArrayUtils;
import org.mariotaku.twidere.Constants;
@ -193,7 +195,7 @@ public final class MediaViewerActivity extends ThemedActionBarActivity implement
SUPPORTED_VIDEO_TYPES = new String[]{"video/mp4"};
}
private WebView mWebView;
private TextureVideoView mVideoView;
private VideoLoader mVideoLoader;
@Override
@ -224,7 +226,7 @@ public final class MediaViewerActivity extends ThemedActionBarActivity implement
@Override
public void onBaseViewCreated(View view, Bundle savedInstanceState) {
super.onBaseViewCreated(view, savedInstanceState);
mWebView = (WebView) view.findViewById(R.id.web_view);
mVideoView = (TextureVideoView) view.findViewById(R.id.video_view);
}
@Override
@ -235,18 +237,15 @@ public final class MediaViewerActivity extends ThemedActionBarActivity implement
@Override
public void onResume() {
super.onResume();
mWebView.onResume();
}
@Override
public void onDestroyView() {
mWebView.destroy();
super.onDestroyView();
}
@Override
public void onPause() {
mWebView.onPause();
super.onPause();
}
@ -260,7 +259,8 @@ public final class MediaViewerActivity extends ThemedActionBarActivity implement
@Override
public void onVideoLoadingComplete(String uri, VideoLoadingListener listener, File file) {
Toast.makeText(getActivity(), String.format("%s length: %d", file, file.length()), Toast.LENGTH_SHORT).show();
mVideoView.setVideoURI(Uri.fromFile(file));
mVideoView.start();
}
@Override

View File

@ -433,13 +433,8 @@ public abstract class AbsStatusesFragment<Data> extends BaseSupportFragment impl
@Override
public boolean scrollToStart() {
final AsyncTwitterWrapper twitter = getTwitterWrapper();
final int tabPosition = getTabPosition();
if (twitter != null && tabPosition != -1) {
twitter.clearUnreadCountAsync(tabPosition);
}
saveReadPosition();
mRecyclerView.smoothScrollToPosition(0);
// mRecyclerView.scrollToPosition(0);
return true;
}

View File

@ -49,7 +49,7 @@ public class ViewStatusDialogFragment extends BaseSupportDialogFragment {
if (getShowsDialog()) {
return inflater.inflate(R.layout.dialog_scrollable_status, parent, false);
}
return inflater.inflate(R.layout.card_item_status_common, parent, false);
return inflater.inflate(R.layout.fragment_scrollable_status, parent, false);
}
@Override

View File

@ -888,6 +888,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
Utils.setLastSeen(mContext, status.getUserMentionEntities(), System.currentTimeMillis());
final ContentValues values = new ContentValues();
values.put(Statuses.IS_FAVORITE, true);
values.put(Statuses.FAVORITE_COUNT, status.getFavoriteCount());
final Expression where = Expression.and(Expression.equals(Statuses.ACCOUNT_ID, account_id),
Expression.or(Expression.equals(Statuses.STATUS_ID, status_id),
Expression.equals(Statuses.RETWEET_ID, status_id)));

View File

@ -68,12 +68,12 @@ public class TwitterWrapper implements Constants {
public static SingleResponse<Boolean> deleteProfileBannerImage(final Context context, final long account_id) {
final Twitter twitter = getTwitterInstance(context, account_id, false);
if (twitter == null) return new SingleResponse<Boolean>(false, null);
if (twitter == null) return new SingleResponse<>(false, null);
try {
twitter.removeProfileBannerImage();
return new SingleResponse<Boolean>(true, null);
return new SingleResponse<>(true, null);
} catch (final TwitterException e) {
return new SingleResponse<Boolean>(false, e);
return new SingleResponse<>(false, e);
}
}

View File

@ -1605,11 +1605,12 @@ public final class Utils implements Constants, TwitterConstants {
}
public static String getApiBaseUrl(final String format, final String domain) {
public static String getApiBaseUrl(String format, final String domain) {
if (format == null) return null;
final Matcher matcher = Pattern.compile("\\[(\\.?)DOMAIN(\\.?)\\]").matcher(format);
if (!matcher.find()) {
// For backward compatibility
format = substituteLegacyApiBaseUrl(format, domain);
if (!format.endsWith("/1.1") && !format.endsWith("/1.1/")) {
return format;
}
@ -1622,6 +1623,13 @@ public final class Utils implements Constants, TwitterConstants {
return matcher.replaceAll(String.format("$1%s$2", domain));
}
private static String substituteLegacyApiBaseUrl(@NonNull String format, String domain) {
final int startOfHost = format.indexOf("://") + 3, endOfHost = format.indexOf('/', startOfHost);
final String host = format.substring(startOfHost, endOfHost);
if (!host.equalsIgnoreCase("api.twitter.com")) return format;
return format.substring(0, startOfHost) + domain + ".twitter.com" + format.substring(endOfHost);
}
public static String getApiUrl(final String pattern, final String domain, final String appendPath) {
final String urlBase = getApiBaseUrl(pattern, domain);
if (urlBase == null) return null;

View File

@ -23,11 +23,11 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
<WebView
android:id="@+id/web_view"
<com.sprylab.android.widget.TextureVideoView
android:id="@+id/video_view"
android:layout_width="match_parent"
android:layout_gravity="center"
android:layout_height="match_parent"/>
android:layout_height="wrap_content"/>
<ProgressBar
android:visibility="gone"

View File

@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Twidere - Twitter client for Android
~
~ Copyright (C) 2012-2015 Mariotaku Lee <mariotaku.lee@gmail.com>
~
~ This program is free software: you can redistribute it and/or modify
~ it under the terms of the GNU General Public License as published by
~ the Free Software Foundation, either version 3 of the License, or
~ (at your option) any later version.
~
~ This program is distributed in the hope that it will be useful,
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
~ GNU General Public License for more details.
~
~ You should have received a copy of the GNU General Public License
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<ScrollView
android:id="@+id/status_container"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<include layout="@layout/card_item_status_common"/>
</ScrollView>

View File

@ -22,11 +22,13 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
<org.mariotaku.twidere.view.ForegroundImageView
android:id="@+id/media_preview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:contentDescription="@string/media"
android:foreground="@drawable/ic_action_play_circle"
android:foregroundGravity="center"
android:scaleType="centerCrop"/>
<ProgressBar