diff options
author | Docile-Alligator <25734209+Docile-Alligator@users.noreply.github.com> | 2024-01-10 04:21:16 +0000 |
---|---|---|
committer | Docile-Alligator <25734209+Docile-Alligator@users.noreply.github.com> | 2024-01-10 04:21:16 +0000 |
commit | 48624cc34aa6c57bfb809cca873e3ec0eb68380a (patch) | |
tree | 80af8d04022fe5357a219ef562d70728a8359c38 /app/src/main/java/ml | |
parent | 2b3405f368b35bd678b467da2828e289ce73831a (diff) | |
download | infinity-for-reddit-48624cc34aa6c57bfb809cca873e3ec0eb68380a.tar infinity-for-reddit-48624cc34aa6c57bfb809cca873e3ec0eb68380a.tar.gz infinity-for-reddit-48624cc34aa6c57bfb809cca873e3ec0eb68380a.tar.bz2 infinity-for-reddit-48624cc34aa6c57bfb809cca873e3ec0eb68380a.tar.lz infinity-for-reddit-48624cc34aa6c57bfb809cca873e3ec0eb68380a.tar.xz infinity-for-reddit-48624cc34aa6c57bfb809cca873e3ec0eb68380a.tar.zst infinity-for-reddit-48624cc34aa6c57bfb809cca873e3ec0eb68380a.zip |
Remove Gfycat.
Diffstat (limited to 'app/src/main/java/ml')
23 files changed, 371 insertions, 644 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/FetchGfycatOrRedgifsVideoLinks.java b/app/src/main/java/ml/docilealligator/infinityforreddit/FetchGfycatOrRedgifsVideoLinks.java deleted file mode 100644 index 1f55fb7f..00000000 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/FetchGfycatOrRedgifsVideoLinks.java +++ /dev/null @@ -1,135 +0,0 @@ -package ml.docilealligator.infinityforreddit; - -import android.content.Context; -import android.content.SharedPreferences; -import android.os.Handler; - -import org.json.JSONException; -import org.json.JSONObject; - -import java.io.IOException; -import java.util.concurrent.Executor; - -import ml.docilealligator.infinityforreddit.apis.GfycatAPI; -import ml.docilealligator.infinityforreddit.apis.RedgifsAPI; -import ml.docilealligator.infinityforreddit.utils.APIUtils; -import ml.docilealligator.infinityforreddit.utils.JSONUtils; -import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils; -import retrofit2.Call; -import retrofit2.Response; -import retrofit2.Retrofit; - -public class FetchGfycatOrRedgifsVideoLinks { - - public interface FetchGfycatOrRedgifsVideoLinksListener { - void success(String webm, String mp4); - void failed(int errorCode); - } - - public static void fetchGfycatVideoLinks(Executor executor, Handler handler, Retrofit gfycatRetrofit, - String gfycatId, - FetchGfycatOrRedgifsVideoLinksListener fetchGfycatOrRedgifsVideoLinksListener) { - executor.execute(() -> { - try { - Response<String> response = gfycatRetrofit.create(GfycatAPI.class).getGfycatData(gfycatId).execute(); - if (response.isSuccessful()) { - parseGfycatVideoLinks(handler, response.body(), fetchGfycatOrRedgifsVideoLinksListener); - } else { - handler.post(() -> fetchGfycatOrRedgifsVideoLinksListener.failed(response.code())); - } - } catch (IOException e) { - e.printStackTrace(); - handler.post(() -> fetchGfycatOrRedgifsVideoLinksListener.failed(-1)); - } - }); - } - - public static void fetchRedgifsVideoLinks(Context context, Executor executor, Handler handler, Retrofit redgifsRetrofit, - SharedPreferences currentAccountSharedPreferences, - String gfycatId, - FetchGfycatOrRedgifsVideoLinksListener fetchGfycatOrRedgifsVideoLinksListener) { - executor.execute(() -> { - try { - Response<String> response = redgifsRetrofit.create(RedgifsAPI.class).getRedgifsData(APIUtils.getRedgifsOAuthHeader(currentAccountSharedPreferences.getString(SharedPreferencesUtils.REDGIFS_ACCESS_TOKEN, "")), - gfycatId, APIUtils.USER_AGENT).execute(); - if (response.isSuccessful()) { - parseRedgifsVideoLinks(handler, response.body(), fetchGfycatOrRedgifsVideoLinksListener); - } else { - handler.post(() -> fetchGfycatOrRedgifsVideoLinksListener.failed(response.code())); - } - } catch (IOException e) { - e.printStackTrace(); - handler.post(() -> fetchGfycatOrRedgifsVideoLinksListener.failed(-1)); - } - }); - } - - public static void fetchGfycatOrRedgifsVideoLinksInRecyclerViewAdapter(Executor executor, Handler handler, - Call<String> gfycatCall, - boolean isGfycatVideo, - boolean automaticallyTryRedgifs, - FetchGfycatOrRedgifsVideoLinksListener fetchGfycatOrRedgifsVideoLinksListener) { - executor.execute(() -> { - try { - Response<String> response = gfycatCall.execute(); - if (response.isSuccessful()) { - if (isGfycatVideo) { - parseGfycatVideoLinks(handler, response.body(), fetchGfycatOrRedgifsVideoLinksListener); - } else { - parseRedgifsVideoLinks(handler, response.body(), fetchGfycatOrRedgifsVideoLinksListener); - } - } else { - if (response.code() == 404 && isGfycatVideo && automaticallyTryRedgifs) { - fetchGfycatOrRedgifsVideoLinksInRecyclerViewAdapter(executor, handler, gfycatCall.clone(), - false, false, fetchGfycatOrRedgifsVideoLinksListener); - } else { - handler.post(() -> fetchGfycatOrRedgifsVideoLinksListener.failed(response.code())); - } - } - } catch (IOException e) { - e.printStackTrace(); - handler.post(() -> fetchGfycatOrRedgifsVideoLinksListener.failed(-1)); - } - }); - } - - private static void parseGfycatVideoLinks(Handler handler, String response, - FetchGfycatOrRedgifsVideoLinksListener fetchGfycatOrRedgifsVideoLinksListener) { - try { - JSONObject jsonObject = new JSONObject(response); - String mp4 = jsonObject.getJSONObject(JSONUtils.GFY_ITEM_KEY).has(JSONUtils.MP4_URL_KEY) ? - jsonObject.getJSONObject(JSONUtils.GFY_ITEM_KEY).getString(JSONUtils.MP4_URL_KEY) - : jsonObject.getJSONObject(JSONUtils.GFY_ITEM_KEY) - .getJSONObject(JSONUtils.CONTENT_URLS_KEY) - .getJSONObject(JSONUtils.MP4_KEY) - .getString(JSONUtils.URL_KEY); - String webm; - if (jsonObject.getJSONObject(JSONUtils.GFY_ITEM_KEY).has(JSONUtils.WEBM_URL_KEY)) { - webm = jsonObject.getJSONObject(JSONUtils.GFY_ITEM_KEY).getString(JSONUtils.WEBM_URL_KEY); - } else if (jsonObject.getJSONObject(JSONUtils.GFY_ITEM_KEY).getJSONObject(JSONUtils.CONTENT_URLS_KEY).has(JSONUtils.WEBM_KEY)) { - webm = jsonObject.getJSONObject(JSONUtils.GFY_ITEM_KEY) - .getJSONObject(JSONUtils.CONTENT_URLS_KEY) - .getJSONObject(JSONUtils.WEBM_KEY) - .getString(JSONUtils.URL_KEY); - } else { - webm = mp4; - } - handler.post(() -> fetchGfycatOrRedgifsVideoLinksListener.success(webm, mp4)); - } catch (JSONException e) { - e.printStackTrace(); - handler.post(() -> fetchGfycatOrRedgifsVideoLinksListener.failed(-1)); - } - } - - private static void parseRedgifsVideoLinks(Handler handler, String response, - FetchGfycatOrRedgifsVideoLinksListener fetchGfycatOrRedgifsVideoLinksListener) { - try { - String mp4 = new JSONObject(response).getJSONObject(JSONUtils.GIF_KEY).getJSONObject(JSONUtils.URLS_KEY) - .getString(JSONUtils.HD_KEY); - handler.post(() -> fetchGfycatOrRedgifsVideoLinksListener.success(mp4, mp4)); - } catch (JSONException e) { - e.printStackTrace(); - handler.post(() -> fetchGfycatOrRedgifsVideoLinksListener.failed(-1)); - } - } -} diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/FetchRedgifsVideoLinks.java b/app/src/main/java/ml/docilealligator/infinityforreddit/FetchRedgifsVideoLinks.java new file mode 100644 index 00000000..8435f3ea --- /dev/null +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/FetchRedgifsVideoLinks.java @@ -0,0 +1,76 @@ +package ml.docilealligator.infinityforreddit; + +import android.content.SharedPreferences; +import android.os.Handler; + +import org.json.JSONException; +import org.json.JSONObject; + +import java.io.IOException; +import java.util.concurrent.Executor; + +import ml.docilealligator.infinityforreddit.apis.RedgifsAPI; +import ml.docilealligator.infinityforreddit.utils.APIUtils; +import ml.docilealligator.infinityforreddit.utils.JSONUtils; +import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils; +import retrofit2.Call; +import retrofit2.Response; +import retrofit2.Retrofit; + +public class FetchRedgifsVideoLinks { + + public interface FetchRedgifsVideoLinksListener { + void success(String webm, String mp4); + void failed(int errorCode); + } + + public static void fetchRedgifsVideoLinks(Executor executor, Handler handler, Retrofit redgifsRetrofit, + SharedPreferences currentAccountSharedPreferences, + String redgifsId, + FetchRedgifsVideoLinksListener fetchRedgifsVideoLinksListener) { + executor.execute(() -> { + try { + Response<String> response = redgifsRetrofit.create(RedgifsAPI.class).getRedgifsData(APIUtils.getRedgifsOAuthHeader(currentAccountSharedPreferences.getString(SharedPreferencesUtils.REDGIFS_ACCESS_TOKEN, "")), + redgifsId, APIUtils.USER_AGENT).execute(); + if (response.isSuccessful()) { + parseRedgifsVideoLinks(handler, response.body(), fetchRedgifsVideoLinksListener); + } else { + handler.post(() -> fetchRedgifsVideoLinksListener.failed(response.code())); + } + } catch (IOException e) { + e.printStackTrace(); + handler.post(() -> fetchRedgifsVideoLinksListener.failed(-1)); + } + }); + } + + public static void fetchRedgifsVideoLinksInRecyclerViewAdapter(Executor executor, Handler handler, + Call<String> redgifsCall, + FetchRedgifsVideoLinksListener fetchRedgifsVideoLinksListener) { + executor.execute(() -> { + try { + Response<String> response = redgifsCall.execute(); + if (response.isSuccessful()) { + parseRedgifsVideoLinks(handler, response.body(), fetchRedgifsVideoLinksListener); + } else { + handler.post(() -> fetchRedgifsVideoLinksListener.failed(response.code())); + } + } catch (IOException e) { + e.printStackTrace(); + handler.post(() -> fetchRedgifsVideoLinksListener.failed(-1)); + } + }); + } + + private static void parseRedgifsVideoLinks(Handler handler, String response, + FetchRedgifsVideoLinksListener fetchRedgifsVideoLinksListener) { + try { + String mp4 = new JSONObject(response).getJSONObject(JSONUtils.GIF_KEY).getJSONObject(JSONUtils.URLS_KEY) + .getString(JSONUtils.HD_KEY); + handler.post(() -> fetchRedgifsVideoLinksListener.success(mp4, mp4)); + } catch (JSONException e) { + e.printStackTrace(); + handler.post(() -> fetchRedgifsVideoLinksListener.failed(-1)); + } + } +} diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/NetworkModule.java b/app/src/main/java/ml/docilealligator/infinityforreddit/NetworkModule.java index 5aff6fc1..ffd4dcb6 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/NetworkModule.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/NetworkModule.java @@ -148,15 +148,6 @@ abstract class NetworkModule { } @Provides - @Named("gfycat") - @Singleton - static Retrofit provideGfycatRetrofit(@Named("base") Retrofit retrofit) { - return retrofit.newBuilder() - .baseUrl(APIUtils.GFYCAT_API_BASE_URI) - .build(); - } - - @Provides @Named("RedgifsAccessTokenAuthenticator") static Interceptor redgifsAccessTokenAuthenticator(@Named("current_account") SharedPreferences currentAccountSharedPreferences) { return new RedgifsAccessTokenAuthenticator(currentAccountSharedPreferences); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/LinkResolverActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/LinkResolverActivity.java index 7b535685..e5346178 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/LinkResolverActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/LinkResolverActivity.java @@ -44,7 +44,6 @@ public class LinkResolverActivity extends AppCompatActivity { private static final String MULTIREDDIT_PATTERN = "/user/[\\w-]+/m/\\w+/?"; private static final String MULTIREDDIT_PATTERN_2 = "/[rR]/(\\w+\\+?)+/?"; private static final String REDD_IT_POST_PATTERN = "/\\w+/?"; - private static final String GFYCAT_PATTERN = "(/i?fr)?/[\\w-]+$"; private static final String REDGIFS_PATTERN = "/watch/[\\w-]+$"; private static final String IMGUR_GALLERY_PATTERN = "/gallery/\\w+/?"; private static final String IMGUR_ALBUM_PATTERN = "/(album|a)/\\w+/?"; @@ -258,20 +257,10 @@ public class LinkResolverActivity extends AppCompatActivity { if (path.startsWith("/CL0/")) { handleUri(Uri.parse(path.substring("/CL0/".length()))); } - } else if (authority.contains("gfycat.com")) { - if (path.matches(GFYCAT_PATTERN)) { - Intent intent = new Intent(this, ViewVideoActivity.class); - intent.putExtra(ViewVideoActivity.EXTRA_GFYCAT_ID, path.substring(path.lastIndexOf("/") + 1)); - intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_GFYCAT); - intent.putExtra(ViewVideoActivity.EXTRA_IS_NSFW, getIntent().getBooleanExtra(EXTRA_IS_NSFW, false)); - startActivity(intent); - } else { - deepLinkError(uri); - } } else if (authority.contains("redgifs.com")) { if (path.matches(REDGIFS_PATTERN)) { Intent intent = new Intent(this, ViewVideoActivity.class); - intent.putExtra(ViewVideoActivity.EXTRA_GFYCAT_ID, path.substring(path.lastIndexOf("/") + 1)); + intent.putExtra(ViewVideoActivity.EXTRA_REDGIFS_ID, path.substring(path.lastIndexOf("/") + 1)); intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_REDGIFS); intent.putExtra(ViewVideoActivity.EXTRA_IS_NSFW, true); startActivity(intent); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/LoginActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/LoginActivity.java index 11a11fa7..fb39c4e2 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/LoginActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/LoginActivity.java @@ -203,6 +203,7 @@ public class LoginActivity extends BaseActivity { mCurrentAccountSharedPreferences.edit().putString(SharedPreferencesUtils.ACCESS_TOKEN, accessToken) .putString(SharedPreferencesUtils.ACCOUNT_NAME, name) .putString(SharedPreferencesUtils.ACCOUNT_IMAGE_URL, profileImageUrl).apply(); + mCurrentAccountSharedPreferences.edit().remove(SharedPreferencesUtils.SUBSCRIBED_THINGS_SYNC_TIME).apply(); ParseAndInsertNewAccount.parseAndInsertNewAccount(mExecutor, new Handler(), name, accessToken, refreshToken, profileImageUrl, bannerImageUrl, karma, authCode, mRedditDataRoomDatabase.accountDao(), () -> { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java index 0748fb33..270694b4 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java @@ -1003,6 +1003,10 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb } private void loadSubscriptions() { + if (System.currentTimeMillis() - mCurrentAccountSharedPreferences.getLong(SharedPreferencesUtils.SUBSCRIBED_THINGS_SYNC_TIME, 0L) < 24 * 60 * 60 * 1000) { + return; + } + if (!mAccountName.equals(Account.ANONYMOUS_ACCOUNT) && !mFetchSubscriptionsSuccess) { FetchSubscribedThing.fetchSubscribedThing(mOauthRetrofit, mAccessToken, mAccountName, null, new ArrayList<>(), new ArrayList<>(), @@ -1012,6 +1016,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb public void onFetchSubscribedThingSuccess(ArrayList<SubscribedSubredditData> subscribedSubredditData, ArrayList<SubscribedUserData> subscribedUserData, ArrayList<SubredditData> subredditData) { + mCurrentAccountSharedPreferences.edit().putLong(SharedPreferencesUtils.SUBSCRIBED_THINGS_SYNC_TIME, System.currentTimeMillis()).apply(); InsertSubscribedThings.insertSubscribedThings( mExecutor, new Handler(), diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubscribedThingListingActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubscribedThingListingActivity.java index def20919..d3eca700 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubscribedThingListingActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubscribedThingListingActivity.java @@ -107,9 +107,6 @@ public class SubscribedThingListingActivity extends BaseActivity implements Acti @Named("current_account") SharedPreferences mCurrentAccountSharedPreferences; @Inject - @Named("internal") - SharedPreferences mInternalSharedPreferences; - @Inject CustomThemeWrapper mCustomThemeWrapper; @Inject Executor mExecutor; @@ -318,7 +315,7 @@ public class SubscribedThingListingActivity extends BaseActivity implements Acti } public void loadSubscriptions(boolean forceLoad) { - if (!forceLoad && System.currentTimeMillis() - mInternalSharedPreferences.getLong(SharedPreferencesUtils.SUBSCRIBED_THINGS_SYNC_TIME, 0L) < 24 * 60 * 60 * 1000) { + if (!forceLoad && System.currentTimeMillis() - mCurrentAccountSharedPreferences.getLong(SharedPreferencesUtils.SUBSCRIBED_THINGS_SYNC_TIME, 0L) < 24 * 60 * 60 * 1000) { return; } @@ -331,7 +328,7 @@ public class SubscribedThingListingActivity extends BaseActivity implements Acti public void onFetchSubscribedThingSuccess(ArrayList<SubscribedSubredditData> subscribedSubredditData, ArrayList<SubscribedUserData> subscribedUserData, ArrayList<SubredditData> subredditData) { - mInternalSharedPreferences.edit().putLong(SharedPreferencesUtils.SUBSCRIBED_THINGS_SYNC_TIME, System.currentTimeMillis()).apply(); + mCurrentAccountSharedPreferences.edit().putLong(SharedPreferencesUtils.SUBSCRIBED_THINGS_SYNC_TIME, System.currentTimeMillis()).apply(); InsertSubscribedThings.insertSubscribedThings( mExecutor, new Handler(), diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewVideoActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewVideoActivity.java index 69fd01e4..38ca2f2f 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewVideoActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewVideoActivity.java @@ -68,7 +68,6 @@ import com.google.android.exoplayer2.util.MimeTypes; import com.google.android.exoplayer2.video.VideoSize; import com.google.android.material.bottomappbar.BottomAppBar; import com.google.android.material.button.MaterialButton; -import com.google.android.material.snackbar.Snackbar; import com.google.common.collect.ImmutableList; import com.otaliastudios.zoom.ZoomEngine; import com.otaliastudios.zoom.ZoomSurfaceView; @@ -88,7 +87,7 @@ import app.futured.hauler.LockableNestedScrollView; import butterknife.BindView; import butterknife.ButterKnife; import ml.docilealligator.infinityforreddit.CustomFontReceiver; -import ml.docilealligator.infinityforreddit.FetchGfycatOrRedgifsVideoLinks; +import ml.docilealligator.infinityforreddit.FetchRedgifsVideoLinks; import ml.docilealligator.infinityforreddit.FetchStreamableVideo; import ml.docilealligator.infinityforreddit.Infinity; import ml.docilealligator.infinityforreddit.R; @@ -131,7 +130,7 @@ public class ViewVideoActivity extends AppCompatActivity implements CustomFontRe public static final String EXTRA_POST = "EP"; public static final String EXTRA_PROGRESS_SECONDS = "EPS"; public static final String EXTRA_VIDEO_TYPE = "EVT"; - public static final String EXTRA_GFYCAT_ID = "EGI"; + public static final String EXTRA_REDGIFS_ID = "EGI"; public static final String EXTRA_V_REDD_IT_URL = "EVRIU"; public static final String EXTRA_STREAMABLE_SHORT_CODE = "ESSC"; public static final String EXTRA_IS_NSFW = "EIN"; @@ -140,7 +139,6 @@ public class ViewVideoActivity extends AppCompatActivity implements CustomFontRe public static final int VIDEO_TYPE_V_REDD_IT = 4; public static final int VIDEO_TYPE_DIRECT = 3; public static final int VIDEO_TYPE_REDGIFS = 2; - public static final int VIDEO_TYPE_GFYCAT = 1; private static final int VIDEO_TYPE_NORMAL = 0; private static final int PERMISSION_REQUEST_WRITE_EXTERNAL_STORAGE = 0; @@ -203,10 +201,6 @@ public class ViewVideoActivity extends AppCompatActivity implements CustomFontRe Retrofit applicationOnlyOauthRetrofit; @Inject - @Named("gfycat") - Retrofit gfycatRetrofit; - - @Inject @Named("redgifs") Retrofit redgifsRetrofit; @@ -546,29 +540,21 @@ public class ViewVideoActivity extends AppCompatActivity implements CustomFontRe } } else if (videoType == VIDEO_TYPE_V_REDD_IT) { loadVReddItVideo(savedInstanceState); - } else if (videoType == VIDEO_TYPE_GFYCAT || videoType == VIDEO_TYPE_REDGIFS) { + } else if (videoType == VIDEO_TYPE_REDGIFS) { if (savedInstanceState != null) { videoDownloadUrl = savedInstanceState.getString(VIDEO_DOWNLOAD_URL_STATE); } else { videoDownloadUrl = intent.getStringExtra(EXTRA_VIDEO_DOWNLOAD_URL); } - String gfycatId = intent.getStringExtra(EXTRA_GFYCAT_ID); - if (gfycatId != null && gfycatId.contains("-")) { - gfycatId = gfycatId.substring(0, gfycatId.indexOf('-')); - } - if (videoType == VIDEO_TYPE_GFYCAT) { - videoFileName = "Gfycat-" + gfycatId + ".mp4"; - } else { - videoFileName = "Redgifs-" + gfycatId + ".mp4"; + String redgifsId = intent.getStringExtra(EXTRA_REDGIFS_ID); + if (redgifsId != null && redgifsId.contains("-")) { + redgifsId = redgifsId.substring(0, redgifsId.indexOf('-')); } + videoFileName = "Redgifs-" + redgifsId + ".mp4"; if (mVideoUri == null) { - if (videoType == VIDEO_TYPE_GFYCAT) { - loadGfycatOrRedgifsVideo(gfycatRetrofit, gfycatId, true, savedInstanceState, true); - } else { - loadGfycatOrRedgifsVideo(redgifsRetrofit, gfycatId, false, savedInstanceState, false); - } + loadRedgifsVideo(redgifsId, savedInstanceState); } else { dataSourceFactory = new CacheDataSource.Factory().setCache(mSimpleCache) .setUpstreamDataSourceFactory(new DefaultHttpDataSource.Factory().setAllowCrossProtocolRedirects(true).setUserAgent(APIUtils.USER_AGENT)); @@ -723,61 +709,28 @@ public class ViewVideoActivity extends AppCompatActivity implements CustomFontRe return C.TRACK_TYPE_UNKNOWN; } - private void loadGfycatOrRedgifsVideo(Retrofit retrofit, String gfycatId, boolean isGfycatVideo, - Bundle savedInstanceState, boolean needErrorHandling) { + private void loadRedgifsVideo(String redgifsId, Bundle savedInstanceState) { progressBar.setVisibility(View.VISIBLE); - if (isGfycatVideo) { - FetchGfycatOrRedgifsVideoLinks.fetchGfycatVideoLinks(mExecutor, new Handler(), retrofit, gfycatId, - new FetchGfycatOrRedgifsVideoLinks.FetchGfycatOrRedgifsVideoLinksListener() { - @Override - public void success(String webm, String mp4) { - progressBar.setVisibility(View.GONE); - mVideoUri = Uri.parse(webm); - videoDownloadUrl = mp4; - dataSourceFactory = new CacheDataSource.Factory().setCache(mSimpleCache) - .setUpstreamDataSourceFactory(new DefaultHttpDataSource.Factory().setAllowCrossProtocolRedirects(true).setUserAgent(APIUtils.USER_AGENT)); - preparePlayer(savedInstanceState); - player.prepare(); - player.setMediaSource(new ProgressiveMediaSource.Factory(dataSourceFactory).createMediaSource(MediaItem.fromUri(mVideoUri))); - } - - @Override - public void failed(int errorCode) { - if (errorCode == 404 && needErrorHandling) { - if (mSharedPreferences.getBoolean(SharedPreferencesUtils.AUTOMATICALLY_TRY_REDGIFS, true)) { - loadGfycatOrRedgifsVideo(redgifsRetrofit, gfycatId, false, savedInstanceState, false); - } else { - Snackbar.make(coordinatorLayout, R.string.load_video_in_redgifs, Snackbar.LENGTH_INDEFINITE).setAction(R.string.yes, - view -> loadGfycatOrRedgifsVideo(redgifsRetrofit, gfycatId, false, savedInstanceState, false)).show(); - } - } else { - progressBar.setVisibility(View.GONE); - Toast.makeText(ViewVideoActivity.this, R.string.fetch_gfycat_video_failed, Toast.LENGTH_SHORT).show(); - } - } - }); - } else { - FetchGfycatOrRedgifsVideoLinks.fetchRedgifsVideoLinks(this, mExecutor, new Handler(), redgifsRetrofit, - mCurrentAccountSharedPreferences, gfycatId, new FetchGfycatOrRedgifsVideoLinks.FetchGfycatOrRedgifsVideoLinksListener() { - @Override - public void success(String webm, String mp4) { - progressBar.setVisibility(View.GONE); - mVideoUri = Uri.parse(webm); - videoDownloadUrl = mp4; - dataSourceFactory = new CacheDataSource.Factory().setCache(mSimpleCache) - .setUpstreamDataSourceFactory(new DefaultHttpDataSource.Factory().setAllowCrossProtocolRedirects(true).setUserAgent(APIUtils.USER_AGENT)); - preparePlayer(savedInstanceState); - player.prepare(); - player.setMediaSource(new ProgressiveMediaSource.Factory(dataSourceFactory).createMediaSource(MediaItem.fromUri(mVideoUri))); - } + FetchRedgifsVideoLinks.fetchRedgifsVideoLinks(mExecutor, new Handler(), redgifsRetrofit, + mCurrentAccountSharedPreferences, redgifsId, new FetchRedgifsVideoLinks.FetchRedgifsVideoLinksListener() { + @Override + public void success(String webm, String mp4) { + progressBar.setVisibility(View.GONE); + mVideoUri = Uri.parse(webm); + videoDownloadUrl = mp4; + dataSourceFactory = new CacheDataSource.Factory().setCache(mSimpleCache) + .setUpstreamDataSourceFactory(new DefaultHttpDataSource.Factory().setAllowCrossProtocolRedirects(true).setUserAgent(APIUtils.USER_AGENT)); + preparePlayer(savedInstanceState); + player.prepare(); + player.setMediaSource(new ProgressiveMediaSource.Factory(dataSourceFactory).createMediaSource(MediaItem.fromUri(mVideoUri))); + } - @Override - public void failed(int errorCode) { - progressBar.setVisibility(View.GONE); - Toast.makeText(ViewVideoActivity.this, R.string.fetch_redgifs_video_failed, Toast.LENGTH_SHORT).show(); - } - }); - } + @Override + public void failed(int errorCode) { + progressBar.setVisibility(View.GONE); + Toast.makeText(ViewVideoActivity.this, R.string.fetch_redgifs_video_failed, Toast.LENGTH_SHORT).show(); + } + }); } private void loadVReddItVideo(Bundle savedInstanceState) { @@ -795,30 +748,14 @@ public class ViewVideoActivity extends AppCompatActivity implements CustomFontRe new FetchPost.FetchPostListener() { @Override public void fetchPostSuccess(Post post) { - if (post.isGfycat()) { - videoType = VIDEO_TYPE_GFYCAT; - String gfycatId = post.getGfycatId(); - if (gfycatId != null && gfycatId.contains("-")) { - gfycatId = gfycatId.substring(0, gfycatId.indexOf('-')); - } - if (videoType == VIDEO_TYPE_GFYCAT) { - videoFileName = "Gfycat-" + gfycatId + ".mp4"; - } else { - videoFileName = "Redgifs-" + gfycatId + ".mp4"; - } - loadGfycatOrRedgifsVideo(gfycatRetrofit, gfycatId, true, savedInstanceState, true); - } else if (post.isRedgifs()) { + if (post.isRedgifs()) { videoType = VIDEO_TYPE_REDGIFS; - String gfycatId = post.getGfycatId(); - if (gfycatId != null && gfycatId.contains("-")) { - gfycatId = gfycatId.substring(0, gfycatId.indexOf('-')); - } - if (videoType == VIDEO_TYPE_GFYCAT) { - videoFileName = "Gfycat-" + gfycatId + ".mp4"; - } else { - videoFileName = "Redgifs-" + gfycatId + ".mp4"; + String redgifsId = post.getRedgifsId(); + if (redgifsId != null && redgifsId.contains("-")) { + redgifsId = redgifsId.substring(0, redgifsId.indexOf('-')); } - loadGfycatOrRedgifsVideo(redgifsRetrofit, gfycatId, false, savedInstanceState, false); + videoFileName = "Redgifs-" + redgifsId + ".mp4"; + loadRedgifsVideo(redgifsId, savedInstanceState); } else if (post.isStreamable()) { videoType = VIDEO_TYPE_STREAMABLE; String shortCode = post.getStreamableShortCode(); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/HistoryPostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/HistoryPostRecyclerViewAdapter.java index b5b9d1e5..da1078b2 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/HistoryPostRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/HistoryPostRecyclerViewAdapter.java @@ -65,7 +65,7 @@ import butterknife.BindView; import butterknife.ButterKnife; import jp.wasabeef.glide.transformations.BlurTransformation; import jp.wasabeef.glide.transformations.RoundedCornersTransformation; -import ml.docilealligator.infinityforreddit.FetchGfycatOrRedgifsVideoLinks; +import ml.docilealligator.infinityforreddit.FetchRedgifsVideoLinks; import ml.docilealligator.infinityforreddit.FetchStreamableVideo; import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.SaveMemoryCenterInisdeDownsampleStrategy; @@ -82,7 +82,6 @@ import ml.docilealligator.infinityforreddit.activities.ViewRedditGalleryActivity import ml.docilealligator.infinityforreddit.activities.ViewSubredditDetailActivity; import ml.docilealligator.infinityforreddit.activities.ViewUserDetailActivity; import ml.docilealligator.infinityforreddit.activities.ViewVideoActivity; -import ml.docilealligator.infinityforreddit.apis.GfycatAPI; import ml.docilealligator.infinityforreddit.apis.RedgifsAPI; import ml.docilealligator.infinityforreddit.apis.StreamableAPI; import ml.docilealligator.infinityforreddit.bottomsheetfragments.ShareLinkBottomSheetFragment; @@ -161,7 +160,6 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy private SharedPreferences mCurrentAccountSharedPreferences; private Executor mExecutor; private Retrofit mOauthRetrofit; - private Retrofit mGfycatRetrofit; private Retrofit mRedgifsRetrofit; private Provider<StreamableAPI> mStreamableApiProvider; private String mAccessToken; @@ -220,7 +218,6 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy private boolean mShowThumbnailOnTheRightInCompactLayout; private double mStartAutoplayVisibleAreaOffset; private boolean mMuteNSFWVideo; - private boolean mAutomaticallyTryRedgifs; private boolean mLongPressToHideToolbarInCompactLayout; private boolean mCompactLayoutToolbarHiddenByDefault; private boolean mDataSavingMode = false; @@ -242,7 +239,7 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy private RecyclerView.RecycledViewPool mGalleryRecycledViewPool; public HistoryPostRecyclerViewAdapter(BaseActivity activity, HistoryPostFragment fragment, Executor executor, Retrofit oauthRetrofit, - Retrofit gfycatRetrofit, Retrofit redgifsRetrofit, Provider<StreamableAPI> streambleApiProvider, + Retrofit redgifsRetrofit, Provider<StreamableAPI> streambleApiProvider, CustomThemeWrapper customThemeWrapper, Locale locale, @Nullable String accessToken, @NonNull String accountName, int postType, int postLayout, boolean displaySubredditName, SharedPreferences sharedPreferences, SharedPreferences currentAccountSharedPreferences, @@ -256,7 +253,6 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy mCurrentAccountSharedPreferences = currentAccountSharedPreferences; mExecutor = executor; mOauthRetrofit = oauthRetrofit; - mGfycatRetrofit = gfycatRetrofit; mRedgifsRetrofit = redgifsRetrofit; mStreamableApiProvider = streambleApiProvider; mAccessToken = accessToken; @@ -288,7 +284,6 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy sharedPreferences.getInt(SharedPreferencesUtils.START_AUTOPLAY_VISIBLE_AREA_OFFSET_LANDSCAPE, 50) / 100.0; mMuteNSFWVideo = sharedPreferences.getBoolean(SharedPreferencesUtils.MUTE_NSFW_VIDEO, false); - mAutomaticallyTryRedgifs = sharedPreferences.getBoolean(SharedPreferencesUtils.AUTOMATICALLY_TRY_REDGIFS, true); mLongPressToHideToolbarInCompactLayout = sharedPreferences.getBoolean(SharedPreferencesUtils.LONG_PRESS_TO_HIDE_TOOLBAR_IN_COMPACT_LAYOUT, false); mCompactLayoutToolbarHiddenByDefault = sharedPreferences.getBoolean(SharedPreferencesUtils.POST_COMPACT_LAYOUT_TOOLBAR_HIDDEN_BY_DEFAULT, false); @@ -785,19 +780,17 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy } } - if ((post.isGfycat() || post.isRedgifs()) && !post.isLoadGfycatOrStreamableVideoSuccess()) { - ((PostBaseVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall = - post.isGfycat() ? mGfycatRetrofit.create(GfycatAPI.class).getGfycatData(post.getGfycatId()) : - mRedgifsRetrofit.create(RedgifsAPI.class).getRedgifsData(APIUtils.getRedgifsOAuthHeader(mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.REDGIFS_ACCESS_TOKEN, "")), post.getGfycatId(), APIUtils.USER_AGENT); - FetchGfycatOrRedgifsVideoLinks.fetchGfycatOrRedgifsVideoLinksInRecyclerViewAdapter(mExecutor, new Handler(), - ((PostBaseVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall, - post.isGfycat(), mAutomaticallyTryRedgifs, - new FetchGfycatOrRedgifsVideoLinks.FetchGfycatOrRedgifsVideoLinksListener() { + if (post.isRedgifs() && !post.isLoadRedgifsOrStreamableVideoSuccess()) { + ((PostBaseVideoAutoplayViewHolder) holder).fetchRedgifsOrStreamableVideoCall = + mRedgifsRetrofit.create(RedgifsAPI.class).getRedgifsData(APIUtils.getRedgifsOAuthHeader(mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.REDGIFS_ACCESS_TOKEN, "")), post.getRedgifsId(), APIUtils.USER_AGENT); + FetchRedgifsVideoLinks.fetchRedgifsVideoLinksInRecyclerViewAdapter(mExecutor, new Handler(), + ((PostBaseVideoAutoplayViewHolder) holder).fetchRedgifsOrStreamableVideoCall, + new FetchRedgifsVideoLinks.FetchRedgifsVideoLinksListener() { @Override public void success(String webm, String mp4) { post.setVideoDownloadUrl(mp4); post.setVideoUrl(mp4); - post.setLoadGfyOrStreamableVideoSuccess(true); + post.setLoadRedgifsOrStreamableVideoSuccess(true); if (position == holder.getBindingAdapterPosition()) { ((PostBaseVideoAutoplayViewHolder) holder).bindVideoUri(Uri.parse(post.getVideoUrl())); } @@ -806,22 +799,22 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy @Override public void failed(int errorCode) { if (position == holder.getBindingAdapterPosition()) { - ((PostBaseVideoAutoplayViewHolder) holder).errorLoadingGfycatImageView.setVisibility(View.VISIBLE); + ((PostBaseVideoAutoplayViewHolder) holder).errorLoadingVideoImageView.setVisibility(View.VISIBLE); } } }); - } else if(post.isStreamable() && !post.isLoadGfycatOrStreamableVideoSuccess()) { - ((PostBaseVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall = + } else if(post.isStreamable() && !post.isLoadRedgifsOrStreamableVideoSuccess()) { + ((PostBaseVideoAutoplayViewHolder) holder).fetchRedgifsOrStreamableVideoCall = mStreamableApiProvider.get().getStreamableData(post.getStreamableShortCode()); FetchStreamableVideo.fetchStreamableVideoInRecyclerViewAdapter(mExecutor, new Handler(), - ((PostBaseVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall, + ((PostBaseVideoAutoplayViewHolder) holder).fetchRedgifsOrStreamableVideoCall, new FetchStreamableVideo.FetchStreamableVideoListener() { @Override public void success(StreamableVideo streamableVideo) { StreamableVideo.Media media = streamableVideo.mp4 == null ? streamableVideo.mp4Mobile : streamableVideo.mp4; post.setVideoDownloadUrl(media.url); post.setVideoUrl(media.url); - post.setLoadGfyOrStreamableVideoSuccess(true); + post.setLoadRedgifsOrStreamableVideoSuccess(true); if (position == holder.getBindingAdapterPosition()) { ((PostBaseVideoAutoplayViewHolder) holder).bindVideoUri(Uri.parse(post.getVideoUrl())); } @@ -830,7 +823,7 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy @Override public void failed() { if (position == holder.getBindingAdapterPosition()) { - ((PostBaseVideoAutoplayViewHolder) holder).errorLoadingGfycatImageView.setVisibility(View.VISIBLE); + ((PostBaseVideoAutoplayViewHolder) holder).errorLoadingVideoImageView.setVisibility(View.VISIBLE); } } }); @@ -965,19 +958,20 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy } } - if ((post.isGfycat() || post.isRedgifs()) && !post.isLoadGfycatOrStreamableVideoSuccess()) { - ((PostCard2BaseVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall = - post.isGfycat() ? mGfycatRetrofit.create(GfycatAPI.class).getGfycatData(post.getGfycatId()) : - mRedgifsRetrofit.create(RedgifsAPI.class).getRedgifsData(APIUtils.getRedgifsOAuthHeader(mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.REDGIFS_ACCESS_TOKEN, "")), post.getGfycatId(), APIUtils.USER_AGENT); - FetchGfycatOrRedgifsVideoLinks.fetchGfycatOrRedgifsVideoLinksInRecyclerViewAdapter(mExecutor, new Handler(), - ((PostCard2BaseVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall, - post.isGfycat(), mAutomaticallyTryRedgifs, - new FetchGfycatOrRedgifsVideoLinks.FetchGfycatOrRedgifsVideoLinksListener() { + if (post.isRedgifs() && !post.isLoadRedgifsOrStreamableVideoSuccess()) { + ((PostCard2BaseVideoAutoplayViewHolder) holder).fetchRedgifsOrStreamableVideoCall = + mRedgifsRetrofit.create(RedgifsAPI.class).getRedgifsData( + APIUtils.getRedgifsOAuthHeader( + mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.REDGIFS_ACCESS_TOKEN, "")), + post.getRedgifsId(), APIUtils.USER_AGENT); + FetchRedgifsVideoLinks.fetchRedgifsVideoLinksInRecyclerViewAdapter(mExecutor, new Handler(), + ((PostCard2BaseVideoAutoplayViewHolder) holder).fetchRedgifsOrStreamableVideoCall, + new FetchRedgifsVideoLinks.FetchRedgifsVideoLinksListener() { @Override public void success(String webm, String mp4) { post.setVideoDownloadUrl(mp4); post.setVideoUrl(mp4); - post.setLoadGfyOrStreamableVideoSuccess(true); + post.setLoadRedgifsOrStreamableVideoSuccess(true); if (position == holder.getBindingAdapterPosition()) { ((PostCard2BaseVideoAutoplayViewHolder) holder).bindVideoUri(Uri.parse(post.getVideoUrl())); } @@ -986,22 +980,22 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy @Override public void failed(int errorCode) { if (position == holder.getBindingAdapterPosition()) { - ((PostCard2BaseVideoAutoplayViewHolder) holder).errorLoadingGfycatImageView.setVisibility(View.VISIBLE); + ((PostCard2BaseVideoAutoplayViewHolder) holder).errorLoadingRedgifsImageView.setVisibility(View.VISIBLE); } } }); - } else if(post.isStreamable() && !post.isLoadGfycatOrStreamableVideoSuccess()) { - ((PostCard2BaseVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall = + } else if(post.isStreamable() && !post.isLoadRedgifsOrStreamableVideoSuccess()) { + ((PostCard2BaseVideoAutoplayViewHolder) holder).fetchRedgifsOrStreamableVideoCall = mStreamableApiProvider.get().getStreamableData(post.getStreamableShortCode()); FetchStreamableVideo.fetchStreamableVideoInRecyclerViewAdapter(mExecutor, new Handler(), - ((PostCard2BaseVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall, + ((PostCard2BaseVideoAutoplayViewHolder) holder).fetchRedgifsOrStreamableVideoCall, new FetchStreamableVideo.FetchStreamableVideoListener() { @Override public void success(StreamableVideo streamableVideo) { StreamableVideo.Media media = streamableVideo.mp4 == null ? streamableVideo.mp4Mobile : streamableVideo.mp4; post.setVideoDownloadUrl(media.url); post.setVideoUrl(media.url); - post.setLoadGfyOrStreamableVideoSuccess(true); + post.setLoadRedgifsOrStreamableVideoSuccess(true); if (position == holder.getBindingAdapterPosition()) { ((PostCard2BaseVideoAutoplayViewHolder) holder).bindVideoUri(Uri.parse(post.getVideoUrl())); } @@ -1010,7 +1004,7 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy @Override public void failed() { if (position == holder.getBindingAdapterPosition()) { - ((PostCard2BaseVideoAutoplayViewHolder) holder).errorLoadingGfycatImageView.setVisibility(View.VISIBLE); + ((PostCard2BaseVideoAutoplayViewHolder) holder).errorLoadingRedgifsImageView.setVisibility(View.VISIBLE); } } }); @@ -1787,19 +1781,20 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy } } - if ((post.isGfycat() || post.isRedgifs()) && !post.isLoadGfycatOrStreamableVideoSuccess()) { - ((PostMaterial3CardBaseVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall = - post.isGfycat() ? mGfycatRetrofit.create(GfycatAPI.class).getGfycatData(post.getGfycatId()) : - mRedgifsRetrofit.create(RedgifsAPI.class).getRedgifsData(APIUtils.getRedgifsOAuthHeader(mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.REDGIFS_ACCESS_TOKEN, "")), post.getGfycatId(), APIUtils.USER_AGENT); - FetchGfycatOrRedgifsVideoLinks.fetchGfycatOrRedgifsVideoLinksInRecyclerViewAdapter(mExecutor, new Handler(), - ((PostMaterial3CardBaseVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall, - post.isGfycat(), mAutomaticallyTryRedgifs, - new FetchGfycatOrRedgifsVideoLinks.FetchGfycatOrRedgifsVideoLinksListener() { + if (post.isRedgifs() && !post.isLoadRedgifsOrStreamableVideoSuccess()) { + ((PostMaterial3CardBaseVideoAutoplayViewHolder) holder).fetchRedgifsOrStreamableVideoCall = + mRedgifsRetrofit.create(RedgifsAPI.class).getRedgifsData( + APIUtils.getRedgifsOAuthHeader(mCurrentAccountSharedPreferences + .getString(SharedPreferencesUtils.REDGIFS_ACCESS_TOKEN, "")), + post.getRedgifsId(), APIUtils.USER_AGENT); + FetchRedgifsVideoLinks.fetchRedgifsVideoLinksInRecyclerViewAdapter(mExecutor, new Handler(), + ((PostMaterial3CardBaseVideoAutoplayViewHolder) holder).fetchRedgifsOrStreamableVideoCall, + new FetchRedgifsVideoLinks.FetchRedgifsVideoLinksListener() { @Override public void success(String webm, String mp4) { post.setVideoDownloadUrl(mp4); post.setVideoUrl(mp4); - post.setLoadGfyOrStreamableVideoSuccess(true); + post.setLoadRedgifsOrStreamableVideoSuccess(true); if (position == holder.getBindingAdapterPosition()) { ((PostMaterial3CardBaseVideoAutoplayViewHolder) holder).bindVideoUri(Uri.parse(post.getVideoUrl())); } @@ -1808,22 +1803,22 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy @Override public void failed(int errorCode) { if (position == holder.getBindingAdapterPosition()) { - ((PostMaterial3CardBaseVideoAutoplayViewHolder) holder).errorLoadingGfycatImageView.setVisibility(View.VISIBLE); + ((PostMaterial3CardBaseVideoAutoplayViewHolder) holder).errorLoadingRedgifsImageView.setVisibility(View.VISIBLE); } } }); - } else if(post.isStreamable() && !post.isLoadGfycatOrStreamableVideoSuccess()) { - ((PostMaterial3CardBaseVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall = + } else if(post.isStreamable() && !post.isLoadRedgifsOrStreamableVideoSuccess()) { + ((PostMaterial3CardBaseVideoAutoplayViewHolder) holder).fetchRedgifsOrStreamableVideoCall = mStreamableApiProvider.get().getStreamableData(post.getStreamableShortCode()); FetchStreamableVideo.fetchStreamableVideoInRecyclerViewAdapter(mExecutor, new Handler(), - ((PostMaterial3CardBaseVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall, + ((PostMaterial3CardBaseVideoAutoplayViewHolder) holder).fetchRedgifsOrStreamableVideoCall, new FetchStreamableVideo.FetchStreamableVideoListener() { @Override public void success(StreamableVideo streamableVideo) { StreamableVideo.Media media = streamableVideo.mp4 == null ? streamableVideo.mp4Mobile : streamableVideo.mp4; post.setVideoDownloadUrl(media.url); post.setVideoUrl(media.url); - post.setLoadGfyOrStreamableVideoSuccess(true); + post.setLoadRedgifsOrStreamableVideoSuccess(true); if (position == holder.getBindingAdapterPosition()) { ((PostMaterial3CardBaseVideoAutoplayViewHolder) holder).bindVideoUri(Uri.parse(post.getVideoUrl())); } @@ -1832,7 +1827,7 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy @Override public void failed() { if (position == holder.getBindingAdapterPosition()) { - ((PostMaterial3CardBaseVideoAutoplayViewHolder) holder).errorLoadingGfycatImageView.setVisibility(View.VISIBLE); + ((PostMaterial3CardBaseVideoAutoplayViewHolder) holder).errorLoadingRedgifsImageView.setVisibility(View.VISIBLE); } } }); @@ -2245,11 +2240,11 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy ((PostBaseViewHolder) holder).titleTextView.setTextColor(mPostTitleColor); if (holder instanceof PostBaseVideoAutoplayViewHolder) { ((PostBaseVideoAutoplayViewHolder) holder).mediaUri = null; - if (((PostBaseVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall != null && !((PostBaseVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall.isCanceled()) { - ((PostBaseVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall.cancel(); - ((PostBaseVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall = null; + if (((PostBaseVideoAutoplayViewHolder) holder).fetchRedgifsOrStreamableVideoCall != null && !((PostBaseVideoAutoplayViewHolder) holder).fetchRedgifsOrStreamableVideoCall.isCanceled()) { + ((PostBaseVideoAutoplayViewHolder) holder).fetchRedgifsOrStreamableVideoCall.cancel(); + ((PostBaseVideoAutoplayViewHolder) holder).fetchRedgifsOrStreamableVideoCall = null; } - ((PostBaseVideoAutoplayViewHolder) holder).errorLoadingGfycatImageView.setVisibility(View.GONE); + ((PostBaseVideoAutoplayViewHolder) holder).errorLoadingVideoImageView.setVisibility(View.GONE); ((PostBaseVideoAutoplayViewHolder) holder).muteButton.setVisibility(View.GONE); if (!((PostBaseVideoAutoplayViewHolder) holder).isManuallyPaused) { ((PostBaseVideoAutoplayViewHolder) holder).resetVolume(); @@ -2275,11 +2270,11 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy ((PostTextTypeViewHolder) holder).binding.contentTextViewItemPostTextType.setVisibility(View.GONE); } else if (holder instanceof PostCard2BaseVideoAutoplayViewHolder) { ((PostCard2BaseVideoAutoplayViewHolder) holder).mediaUri = null; - if (((PostCard2BaseVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall != null && !((PostCard2BaseVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall.isCanceled()) { - ((PostCard2BaseVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall.cancel(); - ((PostCard2BaseVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall = null; + if (((PostCard2BaseVideoAutoplayViewHolder) holder).fetchRedgifsOrStreamableVideoCall != null && !((PostCard2BaseVideoAutoplayViewHolder) holder).fetchRedgifsOrStreamableVideoCall.isCanceled()) { + ((PostCard2BaseVideoAutoplayViewHolder) holder).fetchRedgifsOrStreamableVideoCall.cancel(); + ((PostCard2BaseVideoAutoplayViewHolder) holder).fetchRedgifsOrStreamableVideoCall = null; } - ((PostCard2BaseVideoAutoplayViewHolder) holder).errorLoadingGfycatImageView.setVisibility(View.GONE); + ((PostCard2BaseVideoAutoplayViewHolder) holder).errorLoadingRedgifsImageView.setVisibility(View.GONE); ((PostCard2BaseVideoAutoplayViewHolder) holder).muteButton.setVisibility(View.GONE); ((PostCard2BaseVideoAutoplayViewHolder) holder).resetVolume(); mGlide.clear(((PostCard2BaseVideoAutoplayViewHolder) holder).previewImageView); @@ -2357,11 +2352,11 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy ((PostMaterial3CardBaseViewHolder) holder).titleTextView.setTextColor(mPostTitleColor); if (holder instanceof PostMaterial3CardBaseVideoAutoplayViewHolder) { ((PostMaterial3CardBaseVideoAutoplayViewHolder) holder).mediaUri = null; - if (((PostMaterial3CardBaseVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall != null && !((PostMaterial3CardBaseVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall.isCanceled()) { - ((PostMaterial3CardBaseVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall.cancel(); - ((PostMaterial3CardBaseVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall = null; + if (((PostMaterial3CardBaseVideoAutoplayViewHolder) holder).fetchRedgifsOrStreamableVideoCall != null && !((PostMaterial3CardBaseVideoAutoplayViewHolder) holder).fetchRedgifsOrStreamableVideoCall.isCanceled()) { + ((PostMaterial3CardBaseVideoAutoplayViewHolder) holder).fetchRedgifsOrStreamableVideoCall.cancel(); + ((PostMaterial3CardBaseVideoAutoplayViewHolder) holder).fetchRedgifsOrStreamableVideoCall = null; } - ((PostMaterial3CardBaseVideoAutoplayViewHolder) holder).errorLoadingGfycatImageView.setVisibility(View.GONE); + ((PostMaterial3CardBaseVideoAutoplayViewHolder) holder).errorLoadingRedgifsImageView.setVisibility(View.GONE); ((PostMaterial3CardBaseVideoAutoplayViewHolder) holder).muteButton.setVisibility(View.GONE); if (!((PostMaterial3CardBaseVideoAutoplayViewHolder) holder).isManuallyPaused) { ((PostMaterial3CardBaseVideoAutoplayViewHolder) holder).resetVolume(); @@ -2483,12 +2478,9 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy if (post.isImgur()) { intent.setData(Uri.parse(post.getVideoUrl())); intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_IMGUR); - } else if (post.isGfycat()) { - intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_GFYCAT); - intent.putExtra(ViewVideoActivity.EXTRA_GFYCAT_ID, post.getGfycatId()); } else if (post.isRedgifs()) { intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_REDGIFS); - intent.putExtra(ViewVideoActivity.EXTRA_GFYCAT_ID, post.getGfycatId()); + intent.putExtra(ViewVideoActivity.EXTRA_REDGIFS_ID, post.getRedgifsId()); } else if (post.isStreamable()) { intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_STREAMABLE); intent.putExtra(ViewVideoActivity.EXTRA_STREAMABLE_SHORT_CODE, post.getStreamableShortCode()); @@ -3120,7 +3112,7 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy class PostBaseVideoAutoplayViewHolder extends PostBaseViewHolder implements ToroPlayer { AspectRatioFrameLayout aspectRatioFrameLayout; GifImageView previewImageView; - ImageView errorLoadingGfycatImageView; + ImageView errorLoadingVideoImageView; PlayerView videoPlayer; ImageView muteButton; ImageView fullscreenButton; @@ -3133,7 +3125,7 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy ExoPlayerViewHelper helper; private Uri mediaUri; private float volume; - public Call<String> fetchGfycatOrStreamableVideoCall; + public Call<String> fetchRedgifsOrStreamableVideoCall; private boolean isManuallyPaused; PostBaseVideoAutoplayViewHolder(View rootView, @@ -3152,7 +3144,7 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy CustomTextView flairTextView, AspectRatioFrameLayout aspectRatioFrameLayout, GifImageView previewImageView, - ImageView errorLoadingGfycatImageView, + ImageView errorLoadingVideoImageView, PlayerView videoPlayer, ImageView muteButton, ImageView fullscreenButton, @@ -3191,7 +3183,7 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy this.aspectRatioFrameLayout = aspectRatioFrameLayout; this.previewImageView = previewImageView; - this.errorLoadingGfycatImageView = errorLoadingGfycatImageView; + this.errorLoadingVideoImageView = errorLoadingVideoImageView; this.videoPlayer = videoPlayer; this.muteButton = muteButton; this.fullscreenButton = fullscreenButton; @@ -3230,17 +3222,10 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy if (post.isImgur()) { intent.setData(Uri.parse(post.getVideoUrl())); intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_IMGUR); - } else if (post.isGfycat()) { - intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_GFYCAT); - intent.putExtra(ViewVideoActivity.EXTRA_GFYCAT_ID, post.getGfycatId()); - if (post.isLoadGfycatOrStreamableVideoSuccess()) { - intent.setData(Uri.parse(post.getVideoUrl())); - intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_DOWNLOAD_URL, post.getVideoDownloadUrl()); - } } else if (post.isRedgifs()) { intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_REDGIFS); - intent.putExtra(ViewVideoActivity.EXTRA_GFYCAT_ID, post.getGfycatId()); - if (post.isLoadGfycatOrStreamableVideoSuccess()) { + intent.putExtra(ViewVideoActivity.EXTRA_REDGIFS_ID, post.getRedgifsId()); + if (post.isLoadRedgifsOrStreamableVideoSuccess()) { intent.setData(Uri.parse(post.getVideoUrl())); intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_DOWNLOAD_URL, post.getVideoDownloadUrl()); } @@ -3438,7 +3423,7 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy binding.flairCustomTextViewItemPostVideoTypeAutoplay, binding.aspectRatioFrameLayoutItemPostVideoTypeAutoplay, binding.previewImageViewItemPostVideoTypeAutoplay, - binding.errorLoadingGfycatImageViewItemPostVideoTypeAutoplay, + binding.errorLoadingVideoImageViewItemPostVideoTypeAutoplay, binding.playerViewItemPostVideoTypeAutoplay, binding.getRoot().findViewById(R.id.mute_exo_playback_control_view), binding.getRoot().findViewById(R.id.fullscreen_exo_playback_control_view), @@ -3473,7 +3458,7 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy binding.flairCustomTextViewItemPostVideoTypeAutoplay, binding.aspectRatioFrameLayoutItemPostVideoTypeAutoplay, binding.previewImageViewItemPostVideoTypeAutoplay, - binding.errorLoadingGfycatImageViewItemPostVideoTypeAutoplay, + binding.errorLoadingVideoImageViewItemPostVideoTypeAutoplay, binding.playerViewItemPostVideoTypeAutoplay, binding.getRoot().findViewById(R.id.mute_exo_playback_control_view), binding.getRoot().findViewById(R.id.fullscreen_exo_playback_control_view), @@ -4755,7 +4740,7 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy class PostCard2BaseVideoAutoplayViewHolder extends PostBaseViewHolder implements ToroPlayer { AspectRatioFrameLayout aspectRatioFrameLayout; GifImageView previewImageView; - ImageView errorLoadingGfycatImageView; + ImageView errorLoadingRedgifsImageView; PlayerView videoPlayer; ImageView muteButton; ImageView fullscreenButton; @@ -4770,7 +4755,7 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy ExoPlayerViewHelper helper; private Uri mediaUri; private float volume; - public Call<String> fetchGfycatOrStreamableVideoCall; + public Call<String> fetchRedgifsOrStreamableVideoCall; private boolean isManuallyPaused; PostCard2BaseVideoAutoplayViewHolder(View itemView, @@ -4789,7 +4774,7 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy CustomTextView flairTextView, AspectRatioFrameLayout aspectRatioFrameLayout, GifImageView previewImageView, - ImageView errorLoadingGfycatImageView, + ImageView errorLoadingRedgifsImageView, PlayerView videoPlayer, ImageView muteButton, ImageView fullscreenButton, @@ -4830,7 +4815,7 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy this.aspectRatioFrameLayout = aspectRatioFrameLayout; this.previewImageView = previewImageView; - this.errorLoadingGfycatImageView = errorLoadingGfycatImageView; + this.errorLoadingRedgifsImageView = errorLoadingRedgifsImageView; this.videoPlayer = videoPlayer; this.muteButton = muteButton; this.fullscreenButton = fullscreenButton; @@ -4900,17 +4885,10 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy if (post.isImgur()) { intent.setData(Uri.parse(post.getVideoUrl())); intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_IMGUR); - } else if (post.isGfycat()) { - intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_GFYCAT); - intent.putExtra(ViewVideoActivity.EXTRA_GFYCAT_ID, post.getGfycatId()); - if (post.isLoadGfycatOrStreamableVideoSuccess()) { - intent.setData(Uri.parse(post.getVideoUrl())); - intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_DOWNLOAD_URL, post.getVideoDownloadUrl()); - } } else if (post.isRedgifs()) { intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_REDGIFS); - intent.putExtra(ViewVideoActivity.EXTRA_GFYCAT_ID, post.getGfycatId()); - if (post.isLoadGfycatOrStreamableVideoSuccess()) { + intent.putExtra(ViewVideoActivity.EXTRA_REDGIFS_ID, post.getRedgifsId()); + if (post.isLoadRedgifsOrStreamableVideoSuccess()) { intent.setData(Uri.parse(post.getVideoUrl())); intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_DOWNLOAD_URL, post.getVideoDownloadUrl()); } @@ -5077,7 +5055,7 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy binding.flairCustomTextViewItemPostCard2VideoAutoplay, binding.aspectRatioFrameLayoutItemPostCard2VideoAutoplay, binding.previewImageViewItemPostCard2VideoAutoplay, - binding.errorLoadingGfycatImageViewItemPostCard2VideoAutoplay, + binding.errorLoadingVideoImageViewItemPostCard2VideoAutoplay, binding.playerViewItemPostCard2VideoAutoplay, binding.getRoot().findViewById(R.id.mute_exo_playback_control_view), binding.getRoot().findViewById(R.id.fullscreen_exo_playback_control_view), @@ -5113,7 +5091,7 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy binding.flairCustomTextViewItemPostCard2VideoAutoplay, binding.aspectRatioFrameLayoutItemPostCard2VideoAutoplay, binding.previewImageViewItemPostCard2VideoAutoplay, - binding.errorLoadingGfycatImageViewItemPostCard2VideoAutoplay, + binding.errorLoadingVideoImageViewItemPostCard2VideoAutoplay, binding.playerViewItemPostCard2VideoAutoplay, binding.getRoot().findViewById(R.id.mute_exo_playback_control_view), binding.getRoot().findViewById(R.id.fullscreen_exo_playback_control_view), @@ -5754,7 +5732,7 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy class PostMaterial3CardBaseVideoAutoplayViewHolder extends PostMaterial3CardBaseViewHolder implements ToroPlayer { AspectRatioFrameLayout aspectRatioFrameLayout; GifImageView previewImageView; - ImageView errorLoadingGfycatImageView; + ImageView errorLoadingRedgifsImageView; PlayerView videoPlayer; ImageView muteButton; ImageView fullscreenButton; @@ -5767,7 +5745,7 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy ExoPlayerViewHelper helper; private Uri mediaUri; private float volume; - public Call<String> fetchGfycatOrStreamableVideoCall; + public Call<String> fetchRedgifsOrStreamableVideoCall; private boolean isManuallyPaused; PostMaterial3CardBaseVideoAutoplayViewHolder(View rootView, @@ -5779,7 +5757,7 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy TextView titleTextView, AspectRatioFrameLayout aspectRatioFrameLayout, GifImageView previewImageView, - ImageView errorLoadingGfycatImageView, + ImageView errorLoadingRedgifsImageView, PlayerView videoPlayer, ImageView muteButton, ImageView fullscreenButton, @@ -5811,7 +5789,7 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy this.aspectRatioFrameLayout = aspectRatioFrameLayout; this.previewImageView = previewImageView; - this.errorLoadingGfycatImageView = errorLoadingGfycatImageView; + this.errorLoadingRedgifsImageView = errorLoadingRedgifsImageView; this.videoPlayer = videoPlayer; this.muteButton = muteButton; this.fullscreenButton = fullscreenButton; @@ -5878,17 +5856,10 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy if (post.isImgur()) { intent.setData(Uri.parse(post.getVideoUrl())); intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_IMGUR); - } else if (post.isGfycat()) { - intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_GFYCAT); - intent.putExtra(ViewVideoActivity.EXTRA_GFYCAT_ID, post.getGfycatId()); - if (post.isLoadGfycatOrStreamableVideoSuccess()) { - intent.setData(Uri.parse(post.getVideoUrl())); - intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_DOWNLOAD_URL, post.getVideoDownloadUrl()); - } } else if (post.isRedgifs()) { intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_REDGIFS); - intent.putExtra(ViewVideoActivity.EXTRA_GFYCAT_ID, post.getGfycatId()); - if (post.isLoadGfycatOrStreamableVideoSuccess()) { + intent.putExtra(ViewVideoActivity.EXTRA_REDGIFS_ID, post.getRedgifsId()); + if (post.isLoadRedgifsOrStreamableVideoSuccess()) { intent.setData(Uri.parse(post.getVideoUrl())); intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_DOWNLOAD_URL, post.getVideoDownloadUrl()); } @@ -6048,7 +6019,7 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy binding.titleTextViewItemPostCard3VideoTypeAutoplay, binding.aspectRatioFrameLayoutItemPostCard3VideoTypeAutoplay, binding.previewImageViewItemPostCard3VideoTypeAutoplay, - binding.errorLoadingGfycatImageViewItemPostCard3VideoTypeAutoplay, + binding.errorLoadingVideoImageViewItemPostCard3VideoTypeAutoplay, binding.playerViewItemPostCard3VideoTypeAutoplay, binding.getRoot().findViewById(R.id.mute_exo_playback_control_view), binding.getRoot().findViewById(R.id.fullscreen_exo_playback_control_view), @@ -6076,7 +6047,7 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy binding.titleTextViewItemPostCard3VideoTypeAutoplay, binding.aspectRatioFrameLayoutItemPostCard3VideoTypeAutoplay, binding.previewImageViewItemPostCard3VideoTypeAutoplay, - binding.errorLoadingGfycatImageViewItemPostCard3VideoTypeAutoplay, + binding.errorLoadingVideoImageViewItemPostCard3VideoTypeAutoplay, binding.playerViewItemPostCard3VideoTypeAutoplay, binding.getRoot().findViewById(R.id.mute_exo_playback_control_view), binding.getRoot().findViewById(R.id.fullscreen_exo_playback_control_view), diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java index a8148722..39ac232a 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java @@ -61,7 +61,7 @@ import io.noties.markwon.MarkwonPlugin; import io.noties.markwon.core.MarkwonTheme; import jp.wasabeef.glide.transformations.BlurTransformation; import jp.wasabeef.glide.transformations.RoundedCornersTransformation; -import ml.docilealligator.infinityforreddit.FetchGfycatOrRedgifsVideoLinks; +import ml.docilealligator.infinityforreddit.FetchRedgifsVideoLinks; import ml.docilealligator.infinityforreddit.FetchStreamableVideo; import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; @@ -80,7 +80,6 @@ import ml.docilealligator.infinityforreddit.activities.ViewRedditGalleryActivity import ml.docilealligator.infinityforreddit.activities.ViewSubredditDetailActivity; import ml.docilealligator.infinityforreddit.activities.ViewUserDetailActivity; import ml.docilealligator.infinityforreddit.activities.ViewVideoActivity; -import ml.docilealligator.infinityforreddit.apis.GfycatAPI; import ml.docilealligator.infinityforreddit.apis.RedgifsAPI; import ml.docilealligator.infinityforreddit.apis.StreamableAPI; import ml.docilealligator.infinityforreddit.asynctasks.LoadSubredditIcon; @@ -140,7 +139,6 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler private final Executor mExecutor; private final Retrofit mOauthRetrofit; private final Retrofit mApplicationOnlyRetrofit; - private final Retrofit mGfycatRetrofit; private final Retrofit mRedgifsRetrofit; private final Provider<StreamableAPI> mStreamableApiProvider; private final RedditDataRoomDatabase mRedditDataRoomDatabase; @@ -170,7 +168,6 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler private final boolean mMuteAutoplayingVideos; private final double mStartAutoplayVisibleAreaOffset; private final boolean mMuteNSFWVideo; - private final boolean mAutomaticallyTryRedgifs; private boolean mDataSavingMode; private final boolean mDisableImagePreview; private final boolean mOnlyDisablePreviewInVideoAndGifPosts; @@ -224,7 +221,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler public PostDetailRecyclerViewAdapter(@NonNull BaseActivity activity, ViewPostDetailFragment fragment, Executor executor, CustomThemeWrapper customThemeWrapper, - Retrofit oauthRetrofit, Retrofit applicationOnlyRetrofit, Retrofit gfycatRetrofit, + Retrofit oauthRetrofit, Retrofit applicationOnlyRetrofit, Retrofit redgifsRetrofit, Provider<StreamableAPI> streamableApiProvider, RedditDataRoomDatabase redditDataRoomDatabase, RequestManager glide, boolean separatePostAndComments, @Nullable String accessToken, @@ -240,7 +237,6 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler mExecutor = executor; mOauthRetrofit = oauthRetrofit; mApplicationOnlyRetrofit = applicationOnlyRetrofit; - mGfycatRetrofit = gfycatRetrofit; mRedgifsRetrofit = redgifsRetrofit; mStreamableApiProvider = streamableApiProvider; mRedditDataRoomDatabase = redditDataRoomDatabase; @@ -285,7 +281,6 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler sharedPreferences.getInt(SharedPreferencesUtils.START_AUTOPLAY_VISIBLE_AREA_OFFSET_LANDSCAPE, 50) / 100.0; mMuteNSFWVideo = sharedPreferences.getBoolean(SharedPreferencesUtils.MUTE_NSFW_VIDEO, false); - mAutomaticallyTryRedgifs = sharedPreferences.getBoolean(SharedPreferencesUtils.AUTOMATICALLY_TRY_REDGIFS, true); String dataSavingModeString = sharedPreferences.getString(SharedPreferencesUtils.DATA_SAVING_MODE, SharedPreferencesUtils.DATA_SAVING_MODE_OFF); if (dataSavingModeString.equals(SharedPreferencesUtils.DATA_SAVING_MODE_ALWAYS)) { @@ -714,45 +709,46 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler ((PostDetailBaseVideoAutoplayViewHolder) holder).setVolume((mMuteAutoplayingVideos || (mPost.isNSFW() && mMuteNSFWVideo)) ? 0f : 1f); } - if (mPost.isGfycat() || mPost.isRedgifs() && !mPost.isLoadGfycatOrStreamableVideoSuccess()) { - ((PostDetailBaseVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall = - mPost.isGfycat() ? mGfycatRetrofit.create(GfycatAPI.class).getGfycatData(mPost.getGfycatId()) : - mRedgifsRetrofit.create(RedgifsAPI.class).getRedgifsData(APIUtils.getRedgifsOAuthHeader(mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.REDGIFS_ACCESS_TOKEN, "")), mPost.getGfycatId(), APIUtils.USER_AGENT); - FetchGfycatOrRedgifsVideoLinks.fetchGfycatOrRedgifsVideoLinksInRecyclerViewAdapter(mExecutor, new Handler(), - ((PostDetailBaseVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall, - mPost.isGfycat(), mAutomaticallyTryRedgifs, - new FetchGfycatOrRedgifsVideoLinks.FetchGfycatOrRedgifsVideoLinksListener() { + if (mPost.isRedgifs() && !mPost.isLoadRedgifsOrStreamableVideoSuccess()) { + ((PostDetailBaseVideoAutoplayViewHolder) holder).fetchRedgifsOrStreamableVideoCall = + mRedgifsRetrofit.create(RedgifsAPI.class) + .getRedgifsData(APIUtils.getRedgifsOAuthHeader( + mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.REDGIFS_ACCESS_TOKEN, "")), + mPost.getRedgifsId(), APIUtils.USER_AGENT); + FetchRedgifsVideoLinks.fetchRedgifsVideoLinksInRecyclerViewAdapter(mExecutor, new Handler(), + ((PostDetailBaseVideoAutoplayViewHolder) holder).fetchRedgifsOrStreamableVideoCall, + new FetchRedgifsVideoLinks.FetchRedgifsVideoLinksListener() { @Override public void success(String webm, String mp4) { mPost.setVideoDownloadUrl(mp4); mPost.setVideoUrl(mp4); - mPost.setLoadGfyOrStreamableVideoSuccess(true); + mPost.setLoadRedgifsOrStreamableVideoSuccess(true); ((PostDetailBaseVideoAutoplayViewHolder) holder).bindVideoUri(Uri.parse(mPost.getVideoUrl())); } @Override public void failed(int errorCode) { - ((PostDetailBaseVideoAutoplayViewHolder) holder).mErrorLoadingGfycatImageView.setVisibility(View.VISIBLE); + ((PostDetailBaseVideoAutoplayViewHolder) holder).mErrorLoadingRedgifsImageView.setVisibility(View.VISIBLE); } }); - } else if(mPost.isStreamable() && !mPost.isLoadGfycatOrStreamableVideoSuccess()) { - ((PostDetailBaseVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall = + } else if(mPost.isStreamable() && !mPost.isLoadRedgifsOrStreamableVideoSuccess()) { + ((PostDetailBaseVideoAutoplayViewHolder) holder).fetchRedgifsOrStreamableVideoCall = mStreamableApiProvider.get().getStreamableData(mPost.getStreamableShortCode()); FetchStreamableVideo.fetchStreamableVideoInRecyclerViewAdapter(mExecutor, new Handler(), - ((PostDetailBaseVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall, + ((PostDetailBaseVideoAutoplayViewHolder) holder).fetchRedgifsOrStreamableVideoCall, new FetchStreamableVideo.FetchStreamableVideoListener() { @Override public void success(StreamableVideo streamableVideo) { StreamableVideo.Media media = streamableVideo.mp4 == null ? streamableVideo.mp4Mobile : streamableVideo.mp4; mPost.setVideoDownloadUrl(media.url); mPost.setVideoUrl(media.url); - mPost.setLoadGfyOrStreamableVideoSuccess(true); + mPost.setLoadRedgifsOrStreamableVideoSuccess(true); ((PostDetailBaseVideoAutoplayViewHolder) holder).bindVideoUri(Uri.parse(mPost.getVideoUrl())); } @Override public void failed() { - ((PostDetailBaseVideoAutoplayViewHolder) holder).mErrorLoadingGfycatImageView.setVisibility(View.VISIBLE); + ((PostDetailBaseVideoAutoplayViewHolder) holder).mErrorLoadingRedgifsImageView.setVisibility(View.VISIBLE); } }); } else { @@ -1040,11 +1036,11 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler ((PostDetailBaseViewHolder) holder).contentMarkdownView.setVisibility(View.GONE); if (holder instanceof PostDetailBaseVideoAutoplayViewHolder) { - if (((PostDetailBaseVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall != null && !((PostDetailBaseVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall.isCanceled()) { - ((PostDetailBaseVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall.cancel(); - ((PostDetailBaseVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall = null; + if (((PostDetailBaseVideoAutoplayViewHolder) holder).fetchRedgifsOrStreamableVideoCall != null && !((PostDetailBaseVideoAutoplayViewHolder) holder).fetchRedgifsOrStreamableVideoCall.isCanceled()) { + ((PostDetailBaseVideoAutoplayViewHolder) holder).fetchRedgifsOrStreamableVideoCall.cancel(); + ((PostDetailBaseVideoAutoplayViewHolder) holder).fetchRedgifsOrStreamableVideoCall = null; } - ((PostDetailBaseVideoAutoplayViewHolder) holder).mErrorLoadingGfycatImageView.setVisibility(View.GONE); + ((PostDetailBaseVideoAutoplayViewHolder) holder).mErrorLoadingRedgifsImageView.setVisibility(View.GONE); ((PostDetailBaseVideoAutoplayViewHolder) holder).muteButton.setVisibility(View.GONE); if (!((PostDetailBaseVideoAutoplayViewHolder) holder).isManuallyPaused) { ((PostDetailBaseVideoAutoplayViewHolder) holder).resetVolume(); @@ -1603,11 +1599,11 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler } class PostDetailBaseVideoAutoplayViewHolder extends PostDetailBaseViewHolder implements ToroPlayer { - public Call<String> fetchGfycatOrStreamableVideoCall; + public Call<String> fetchRedgifsOrStreamableVideoCall; AspectRatioFrameLayout aspectRatioFrameLayout; PlayerView playerView; GifImageView previewImageView; - ImageView mErrorLoadingGfycatImageView; + ImageView mErrorLoadingRedgifsImageView; ImageView muteButton; ImageView fullscreenButton; ImageView pauseButton; @@ -1639,7 +1635,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler AspectRatioFrameLayout aspectRatioFrameLayout, PlayerView playerView, GifImageView previewImageView, - ImageView errorLoadingGfycatImageView, + ImageView errorLoadingRedgifsImageView, ImageView muteButton, ImageView fullscreenButton, ImageView pauseButton, @@ -1679,7 +1675,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler this.aspectRatioFrameLayout = aspectRatioFrameLayout; this.previewImageView = previewImageView; - this.mErrorLoadingGfycatImageView = errorLoadingGfycatImageView; + this.mErrorLoadingRedgifsImageView = errorLoadingRedgifsImageView; this.playerView = playerView; this.muteButton = muteButton; this.fullscreenButton = fullscreenButton; @@ -1710,17 +1706,10 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler if (mPost.isImgur()) { intent.setData(Uri.parse(mPost.getVideoUrl())); intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_IMGUR); - } else if (mPost.isGfycat()) { - intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_GFYCAT); - intent.putExtra(ViewVideoActivity.EXTRA_GFYCAT_ID, mPost.getGfycatId()); - if (mPost.isLoadGfycatOrStreamableVideoSuccess()) { - intent.setData(Uri.parse(mPost.getVideoUrl())); - intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_DOWNLOAD_URL, mPost.getVideoDownloadUrl()); - } } else if (mPost.isRedgifs()) { intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_REDGIFS); - intent.putExtra(ViewVideoActivity.EXTRA_GFYCAT_ID, mPost.getGfycatId()); - if (mPost.isLoadGfycatOrStreamableVideoSuccess()) { + intent.putExtra(ViewVideoActivity.EXTRA_REDGIFS_ID, mPost.getRedgifsId()); + if (mPost.isLoadRedgifsOrStreamableVideoSuccess()) { intent.setData(Uri.parse(mPost.getVideoUrl())); intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_DOWNLOAD_URL, mPost.getVideoDownloadUrl()); } @@ -1914,7 +1903,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler binding.aspectRatioFrameLayoutItemPostDetailVideoAutoplay, binding.playerViewItemPostDetailVideoAutoplay, binding.previewImageViewItemPostDetailVideoAutoplay, - binding.errorLoadingGfycatImageViewItemPostDetailVideoAutoplay, + binding.errorLoadingVideoImageViewItemPostDetailVideoAutoplay, binding.getRoot().findViewById(R.id.mute_exo_playback_control_view), binding.getRoot().findViewById(R.id.fullscreen_exo_playback_control_view), binding.getRoot().findViewById(R.id.exo_pause), @@ -1951,7 +1940,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler binding.aspectRatioFrameLayoutItemPostDetailVideoAutoplay, binding.playerViewItemPostDetailVideoAutoplay, binding.previewImageViewItemPostDetailVideoAutoplay, - binding.errorLoadingGfycatImageViewItemPostDetailVideoAutoplay, + binding.errorLoadingVideoImageViewItemPostDetailVideoAutoplay, binding.getRoot().findViewById(R.id.mute_exo_playback_control_view), binding.getRoot().findViewById(R.id.fullscreen_exo_playback_control_view), binding.getRoot().findViewById(R.id.exo_pause), @@ -2010,12 +1999,9 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler if (mPost.isImgur()) { intent.setData(Uri.parse(mPost.getVideoUrl())); intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_IMGUR); - } else if (mPost.isGfycat()) { - intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_GFYCAT); - intent.putExtra(ViewVideoActivity.EXTRA_GFYCAT_ID, mPost.getGfycatId()); } else if (mPost.isRedgifs()) { intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_REDGIFS); - intent.putExtra(ViewVideoActivity.EXTRA_GFYCAT_ID, mPost.getGfycatId()); + intent.putExtra(ViewVideoActivity.EXTRA_REDGIFS_ID, mPost.getRedgifsId()); } else if (mPost.isStreamable()) { intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_STREAMABLE); intent.putExtra(ViewVideoActivity.EXTRA_STREAMABLE_SHORT_CODE, mPost.getStreamableShortCode()); @@ -2185,12 +2171,9 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler if (mPost != null) { if (mPost.getPostType() == Post.VIDEO_TYPE) { Intent intent = new Intent(mActivity, ViewVideoActivity.class); - if (mPost.isGfycat()) { - intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_GFYCAT); - intent.putExtra(ViewVideoActivity.EXTRA_GFYCAT_ID, mPost.getGfycatId()); - } else if (mPost.isRedgifs()) { + if (mPost.isRedgifs()) { intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_REDGIFS); - intent.putExtra(ViewVideoActivity.EXTRA_GFYCAT_ID, mPost.getGfycatId()); + intent.putExtra(ViewVideoActivity.EXTRA_REDGIFS_ID, mPost.getRedgifsId()); } else if (mPost.isStreamable()) { intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_STREAMABLE); intent.putExtra(ViewVideoActivity.EXTRA_STREAMABLE_SHORT_CODE, mPost.getStreamableShortCode()); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java index 520a4496..5f8ff0d5 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java @@ -65,7 +65,7 @@ import butterknife.BindView; import butterknife.ButterKnife; import jp.wasabeef.glide.transformations.BlurTransformation; import jp.wasabeef.glide.transformations.RoundedCornersTransformation; -import ml.docilealligator.infinityforreddit.FetchGfycatOrRedgifsVideoLinks; +import ml.docilealligator.infinityforreddit.FetchRedgifsVideoLinks; import ml.docilealligator.infinityforreddit.FetchStreamableVideo; import ml.docilealligator.infinityforreddit.MarkPostAsReadInterface; import ml.docilealligator.infinityforreddit.R; @@ -83,7 +83,6 @@ import ml.docilealligator.infinityforreddit.activities.ViewRedditGalleryActivity import ml.docilealligator.infinityforreddit.activities.ViewSubredditDetailActivity; import ml.docilealligator.infinityforreddit.activities.ViewUserDetailActivity; import ml.docilealligator.infinityforreddit.activities.ViewVideoActivity; -import ml.docilealligator.infinityforreddit.apis.GfycatAPI; import ml.docilealligator.infinityforreddit.apis.RedgifsAPI; import ml.docilealligator.infinityforreddit.apis.StreamableAPI; import ml.docilealligator.infinityforreddit.bottomsheetfragments.ShareLinkBottomSheetFragment; @@ -166,7 +165,6 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie private SharedPreferences mCurrentAccountSharedPreferences; private Executor mExecutor; private Retrofit mOauthRetrofit; - private Retrofit mGfycatRetrofit; private Retrofit mRedgifsRetrofit; private Provider<StreamableAPI> mStreamableApiProvider; private String mAccessToken; @@ -230,7 +228,6 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie private boolean mShowThumbnailOnTheRightInCompactLayout; private double mStartAutoplayVisibleAreaOffset; private boolean mMuteNSFWVideo; - private boolean mAutomaticallyTryRedgifs; private boolean mLongPressToHideToolbarInCompactLayout; private boolean mCompactLayoutToolbarHiddenByDefault; private boolean mDataSavingMode = false; @@ -255,7 +252,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie private RecyclerView.RecycledViewPool mGalleryRecycledViewPool; public PostRecyclerViewAdapter(BaseActivity activity, PostFragment fragment, Executor executor, Retrofit oauthRetrofit, - Retrofit gfycatRetrofit, Retrofit redgifsRetrofit, Provider<StreamableAPI> streamableApiProvider, + Retrofit redgifsRetrofit, Provider<StreamableAPI> streamableApiProvider, CustomThemeWrapper customThemeWrapper, Locale locale, @Nullable String accessToken, @NonNull String accountName, int postType, int postLayout, boolean displaySubredditName, SharedPreferences sharedPreferences, SharedPreferences currentAccountSharedPreferences, @@ -270,7 +267,6 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie mCurrentAccountSharedPreferences = currentAccountSharedPreferences; mExecutor = executor; mOauthRetrofit = oauthRetrofit; - mGfycatRetrofit = gfycatRetrofit; mRedgifsRetrofit = redgifsRetrofit; mStreamableApiProvider = streamableApiProvider; mAccessToken = accessToken; @@ -303,7 +299,6 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie sharedPreferences.getInt(SharedPreferencesUtils.START_AUTOPLAY_VISIBLE_AREA_OFFSET_LANDSCAPE, 50) / 100.0; mMuteNSFWVideo = sharedPreferences.getBoolean(SharedPreferencesUtils.MUTE_NSFW_VIDEO, false); - mAutomaticallyTryRedgifs = sharedPreferences.getBoolean(SharedPreferencesUtils.AUTOMATICALLY_TRY_REDGIFS, true); mLongPressToHideToolbarInCompactLayout = sharedPreferences.getBoolean(SharedPreferencesUtils.LONG_PRESS_TO_HIDE_TOOLBAR_IN_COMPACT_LAYOUT, false); mCompactLayoutToolbarHiddenByDefault = sharedPreferences.getBoolean(SharedPreferencesUtils.POST_COMPACT_LAYOUT_TOOLBAR_HIDDEN_BY_DEFAULT, false); @@ -827,19 +822,20 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie } } - if ((post.isGfycat() || post.isRedgifs()) && !post.isLoadGfycatOrStreamableVideoSuccess()) { - ((PostBaseVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall = - post.isGfycat() ? mGfycatRetrofit.create(GfycatAPI.class).getGfycatData(post.getGfycatId()) : - mRedgifsRetrofit.create(RedgifsAPI.class).getRedgifsData(APIUtils.getRedgifsOAuthHeader(mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.REDGIFS_ACCESS_TOKEN, "")), post.getGfycatId(), APIUtils.USER_AGENT); - FetchGfycatOrRedgifsVideoLinks.fetchGfycatOrRedgifsVideoLinksInRecyclerViewAdapter(mExecutor, new Handler(), - ((PostBaseVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall, - post.isGfycat(), mAutomaticallyTryRedgifs, - new FetchGfycatOrRedgifsVideoLinks.FetchGfycatOrRedgifsVideoLinksListener() { + if (post.isRedgifs() && !post.isLoadRedgifsOrStreamableVideoSuccess()) { + ((PostBaseVideoAutoplayViewHolder) holder).fetchRedgifsOrStreamableVideoCall = + mRedgifsRetrofit.create(RedgifsAPI.class) + .getRedgifsData(APIUtils.getRedgifsOAuthHeader( + mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.REDGIFS_ACCESS_TOKEN, "")), + post.getRedgifsId(), APIUtils.USER_AGENT); + FetchRedgifsVideoLinks.fetchRedgifsVideoLinksInRecyclerViewAdapter(mExecutor, new Handler(), + ((PostBaseVideoAutoplayViewHolder) holder).fetchRedgifsOrStreamableVideoCall, + new FetchRedgifsVideoLinks.FetchRedgifsVideoLinksListener() { @Override public void success(String webm, String mp4) { post.setVideoDownloadUrl(mp4); post.setVideoUrl(mp4); - post.setLoadGfyOrStreamableVideoSuccess(true); + post.setLoadRedgifsOrStreamableVideoSuccess(true); if (position == holder.getBindingAdapterPosition()) { ((PostBaseVideoAutoplayViewHolder) holder).bindVideoUri(Uri.parse(post.getVideoUrl())); } @@ -848,22 +844,22 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie @Override public void failed(int errorCode) { if (position == holder.getBindingAdapterPosition()) { - ((PostBaseVideoAutoplayViewHolder) holder).errorLoadingGfycatImageView.setVisibility(View.VISIBLE); + ((PostBaseVideoAutoplayViewHolder) holder).errorLoadingRedgifsImageView.setVisibility(View.VISIBLE); } } }); - } else if(post.isStreamable() && !post.isLoadGfycatOrStreamableVideoSuccess()) { - ((PostBaseVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall = + } else if(post.isStreamable() && !post.isLoadRedgifsOrStreamableVideoSuccess()) { + ((PostBaseVideoAutoplayViewHolder) holder).fetchRedgifsOrStreamableVideoCall = mStreamableApiProvider.get().getStreamableData(post.getStreamableShortCode()); FetchStreamableVideo.fetchStreamableVideoInRecyclerViewAdapter(mExecutor, new Handler(), - ((PostBaseVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall, + ((PostBaseVideoAutoplayViewHolder) holder).fetchRedgifsOrStreamableVideoCall, new FetchStreamableVideo.FetchStreamableVideoListener() { @Override public void success(StreamableVideo streamableVideo) { StreamableVideo.Media media = streamableVideo.mp4 == null ? streamableVideo.mp4Mobile : streamableVideo.mp4; post.setVideoDownloadUrl(media.url); post.setVideoUrl(media.url); - post.setLoadGfyOrStreamableVideoSuccess(true); + post.setLoadRedgifsOrStreamableVideoSuccess(true); if (position == holder.getBindingAdapterPosition()) { ((PostBaseVideoAutoplayViewHolder) holder).bindVideoUri(Uri.parse(post.getVideoUrl())); } @@ -872,7 +868,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie @Override public void failed() { if (position == holder.getBindingAdapterPosition()) { - ((PostBaseVideoAutoplayViewHolder) holder).errorLoadingGfycatImageView.setVisibility(View.VISIBLE); + ((PostBaseVideoAutoplayViewHolder) holder).errorLoadingRedgifsImageView.setVisibility(View.VISIBLE); } } }); @@ -1010,19 +1006,20 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie } } - if ((post.isGfycat() || post.isRedgifs()) && !post.isLoadGfycatOrStreamableVideoSuccess()) { - ((PostCard2BaseVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall = - post.isGfycat() ? mGfycatRetrofit.create(GfycatAPI.class).getGfycatData(post.getGfycatId()) : - mRedgifsRetrofit.create(RedgifsAPI.class).getRedgifsData(APIUtils.getRedgifsOAuthHeader(mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.REDGIFS_ACCESS_TOKEN, "")), post.getGfycatId(), APIUtils.USER_AGENT); - FetchGfycatOrRedgifsVideoLinks.fetchGfycatOrRedgifsVideoLinksInRecyclerViewAdapter(mExecutor, new Handler(), - ((PostCard2BaseVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall, - post.isGfycat(), mAutomaticallyTryRedgifs, - new FetchGfycatOrRedgifsVideoLinks.FetchGfycatOrRedgifsVideoLinksListener() { + if (post.isRedgifs() && !post.isLoadRedgifsOrStreamableVideoSuccess()) { + ((PostCard2BaseVideoAutoplayViewHolder) holder).fetchRedgifsOrStreamableVideoCall = + mRedgifsRetrofit.create(RedgifsAPI.class).getRedgifsData( + APIUtils.getRedgifsOAuthHeader(mCurrentAccountSharedPreferences + .getString(SharedPreferencesUtils.REDGIFS_ACCESS_TOKEN, "")), + post.getRedgifsId(), APIUtils.USER_AGENT); + FetchRedgifsVideoLinks.fetchRedgifsVideoLinksInRecyclerViewAdapter(mExecutor, new Handler(), + ((PostCard2BaseVideoAutoplayViewHolder) holder).fetchRedgifsOrStreamableVideoCall, + new FetchRedgifsVideoLinks.FetchRedgifsVideoLinksListener() { @Override public void success(String webm, String mp4) { post.setVideoDownloadUrl(mp4); post.setVideoUrl(mp4); - post.setLoadGfyOrStreamableVideoSuccess(true); + post.setLoadRedgifsOrStreamableVideoSuccess(true); if (position == holder.getBindingAdapterPosition()) { ((PostCard2BaseVideoAutoplayViewHolder) holder).bindVideoUri(Uri.parse(post.getVideoUrl())); } @@ -1031,22 +1028,22 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie @Override public void failed(int errorCode) { if (position == holder.getBindingAdapterPosition()) { - ((PostCard2BaseVideoAutoplayViewHolder) holder).errorLoadingGfycatImageView.setVisibility(View.VISIBLE); + ((PostCard2BaseVideoAutoplayViewHolder) holder).errorLoadingRedgifsImageView.setVisibility(View.VISIBLE); } } }); - } else if(post.isStreamable() && !post.isLoadGfycatOrStreamableVideoSuccess()) { - ((PostCard2BaseVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall = + } else if(post.isStreamable() && !post.isLoadRedgifsOrStreamableVideoSuccess()) { + ((PostCard2BaseVideoAutoplayViewHolder) holder).fetchRedgifsOrStreamableVideoCall = mStreamableApiProvider.get().getStreamableData(post.getStreamableShortCode()); FetchStreamableVideo.fetchStreamableVideoInRecyclerViewAdapter(mExecutor, new Handler(), - ((PostCard2BaseVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall, + ((PostCard2BaseVideoAutoplayViewHolder) holder).fetchRedgifsOrStreamableVideoCall, new FetchStreamableVideo.FetchStreamableVideoListener() { @Override public void success(StreamableVideo streamableVideo) { StreamableVideo.Media media = streamableVideo.mp4 == null ? streamableVideo.mp4Mobile : streamableVideo.mp4; post.setVideoDownloadUrl(media.url); post.setVideoUrl(media.url); - post.setLoadGfyOrStreamableVideoSuccess(true); + post.setLoadRedgifsOrStreamableVideoSuccess(true); if (position == holder.getBindingAdapterPosition()) { ((PostCard2BaseVideoAutoplayViewHolder) holder).bindVideoUri(Uri.parse(post.getVideoUrl())); } @@ -1055,7 +1052,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie @Override public void failed() { if (position == holder.getBindingAdapterPosition()) { - ((PostCard2BaseVideoAutoplayViewHolder) holder).errorLoadingGfycatImageView.setVisibility(View.VISIBLE); + ((PostCard2BaseVideoAutoplayViewHolder) holder).errorLoadingRedgifsImageView.setVisibility(View.VISIBLE); } } }); @@ -1871,19 +1868,20 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie } } - if ((post.isGfycat() || post.isRedgifs()) && !post.isLoadGfycatOrStreamableVideoSuccess()) { - ((PostMaterial3CardBaseVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall = - post.isGfycat() ? mGfycatRetrofit.create(GfycatAPI.class).getGfycatData(post.getGfycatId()) : - mRedgifsRetrofit.create(RedgifsAPI.class).getRedgifsData(APIUtils.getRedgifsOAuthHeader(mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.REDGIFS_ACCESS_TOKEN, "")), post.getGfycatId(), APIUtils.USER_AGENT); - FetchGfycatOrRedgifsVideoLinks.fetchGfycatOrRedgifsVideoLinksInRecyclerViewAdapter(mExecutor, new Handler(), - ((PostMaterial3CardBaseVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall, - post.isGfycat(), mAutomaticallyTryRedgifs, - new FetchGfycatOrRedgifsVideoLinks.FetchGfycatOrRedgifsVideoLinksListener() { + if (post.isRedgifs() && !post.isLoadRedgifsOrStreamableVideoSuccess()) { + ((PostMaterial3CardBaseVideoAutoplayViewHolder) holder).fetchRedgifsOrStreamableVideoCall = + mRedgifsRetrofit.create(RedgifsAPI.class).getRedgifsData( + APIUtils.getRedgifsOAuthHeader(mCurrentAccountSharedPreferences + .getString(SharedPreferencesUtils.REDGIFS_ACCESS_TOKEN, "")), + post.getRedgifsId(), APIUtils.USER_AGENT); + FetchRedgifsVideoLinks.fetchRedgifsVideoLinksInRecyclerViewAdapter(mExecutor, new Handler(), + ((PostMaterial3CardBaseVideoAutoplayViewHolder) holder).fetchRedgifsOrStreamableVideoCall, + new FetchRedgifsVideoLinks.FetchRedgifsVideoLinksListener() { @Override public void success(String webm, String mp4) { post.setVideoDownloadUrl(mp4); post.setVideoUrl(mp4); - post.setLoadGfyOrStreamableVideoSuccess(true); + post.setLoadRedgifsOrStreamableVideoSuccess(true); if (position == holder.getBindingAdapterPosition()) { ((PostMaterial3CardBaseVideoAutoplayViewHolder) holder).bindVideoUri(Uri.parse(post.getVideoUrl())); } @@ -1892,22 +1890,22 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie @Override public void failed(int errorCode) { if (position == holder.getBindingAdapterPosition()) { - ((PostMaterial3CardBaseVideoAutoplayViewHolder) holder).errorLoadingGfycatImageView.setVisibility(View.VISIBLE); + ((PostMaterial3CardBaseVideoAutoplayViewHolder) holder).errorLoadingRedgifsImageView.setVisibility(View.VISIBLE); } } }); - } else if(post.isStreamable() && !post.isLoadGfycatOrStreamableVideoSuccess()) { - ((PostMaterial3CardBaseVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall = + } else if(post.isStreamable() && !post.isLoadRedgifsOrStreamableVideoSuccess()) { + ((PostMaterial3CardBaseVideoAutoplayViewHolder) holder).fetchRedgifsOrStreamableVideoCall = mStreamableApiProvider.get().getStreamableData(post.getStreamableShortCode()); FetchStreamableVideo.fetchStreamableVideoInRecyclerViewAdapter(mExecutor, new Handler(), - ((PostMaterial3CardBaseVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall, + ((PostMaterial3CardBaseVideoAutoplayViewHolder) holder).fetchRedgifsOrStreamableVideoCall, new FetchStreamableVideo.FetchStreamableVideoListener() { @Override public void success(StreamableVideo streamableVideo) { StreamableVideo.Media media = streamableVideo.mp4 == null ? streamableVideo.mp4Mobile : streamableVideo.mp4; post.setVideoDownloadUrl(media.url); post.setVideoUrl(media.url); - post.setLoadGfyOrStreamableVideoSuccess(true); + post.setLoadRedgifsOrStreamableVideoSuccess(true); if (position == holder.getBindingAdapterPosition()) { ((PostMaterial3CardBaseVideoAutoplayViewHolder) holder).bindVideoUri(Uri.parse(post.getVideoUrl())); } @@ -1916,7 +1914,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie @Override public void failed() { if (position == holder.getBindingAdapterPosition()) { - ((PostMaterial3CardBaseVideoAutoplayViewHolder) holder).errorLoadingGfycatImageView.setVisibility(View.VISIBLE); + ((PostMaterial3CardBaseVideoAutoplayViewHolder) holder).errorLoadingRedgifsImageView.setVisibility(View.VISIBLE); } } }); @@ -2340,11 +2338,11 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie ((PostBaseViewHolder) holder).titleTextView.setTextColor(mPostTitleColor); if (holder instanceof PostBaseVideoAutoplayViewHolder) { ((PostBaseVideoAutoplayViewHolder) holder).mediaUri = null; - if (((PostBaseVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall != null && !((PostBaseVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall.isCanceled()) { - ((PostBaseVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall.cancel(); - ((PostBaseVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall = null; + if (((PostBaseVideoAutoplayViewHolder) holder).fetchRedgifsOrStreamableVideoCall != null && !((PostBaseVideoAutoplayViewHolder) holder).fetchRedgifsOrStreamableVideoCall.isCanceled()) { + ((PostBaseVideoAutoplayViewHolder) holder).fetchRedgifsOrStreamableVideoCall.cancel(); + ((PostBaseVideoAutoplayViewHolder) holder).fetchRedgifsOrStreamableVideoCall = null; } - ((PostBaseVideoAutoplayViewHolder) holder).errorLoadingGfycatImageView.setVisibility(View.GONE); + ((PostBaseVideoAutoplayViewHolder) holder).errorLoadingRedgifsImageView.setVisibility(View.GONE); ((PostBaseVideoAutoplayViewHolder) holder).muteButton.setVisibility(View.GONE); if (!((PostBaseVideoAutoplayViewHolder) holder).isManuallyPaused) { ((PostBaseVideoAutoplayViewHolder) holder).resetVolume(); @@ -2370,11 +2368,11 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie ((PostTextTypeViewHolder) holder).binding.contentTextViewItemPostTextType.setVisibility(View.GONE); } else if (holder instanceof PostCard2BaseVideoAutoplayViewHolder) { ((PostCard2BaseVideoAutoplayViewHolder) holder).mediaUri = null; - if (((PostCard2BaseVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall != null && !((PostCard2BaseVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall.isCanceled()) { - ((PostCard2BaseVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall.cancel(); - ((PostCard2BaseVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall = null; + if (((PostCard2BaseVideoAutoplayViewHolder) holder).fetchRedgifsOrStreamableVideoCall != null && !((PostCard2BaseVideoAutoplayViewHolder) holder).fetchRedgifsOrStreamableVideoCall.isCanceled()) { + ((PostCard2BaseVideoAutoplayViewHolder) holder).fetchRedgifsOrStreamableVideoCall.cancel(); + ((PostCard2BaseVideoAutoplayViewHolder) holder).fetchRedgifsOrStreamableVideoCall = null; } - ((PostCard2BaseVideoAutoplayViewHolder) holder).errorLoadingGfycatImageView.setVisibility(View.GONE); + ((PostCard2BaseVideoAutoplayViewHolder) holder).errorLoadingRedgifsImageView.setVisibility(View.GONE); ((PostCard2BaseVideoAutoplayViewHolder) holder).muteButton.setVisibility(View.GONE); ((PostCard2BaseVideoAutoplayViewHolder) holder).resetVolume(); mGlide.clear(((PostCard2BaseVideoAutoplayViewHolder) holder).previewImageView); @@ -2480,11 +2478,11 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie ((PostMaterial3CardBaseViewHolder) holder).titleTextView.setTextColor(mPostTitleColor); if (holder instanceof PostMaterial3CardBaseVideoAutoplayViewHolder) { ((PostMaterial3CardBaseVideoAutoplayViewHolder) holder).mediaUri = null; - if (((PostMaterial3CardBaseVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall != null && !((PostMaterial3CardBaseVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall.isCanceled()) { - ((PostMaterial3CardBaseVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall.cancel(); - ((PostMaterial3CardBaseVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall = null; + if (((PostMaterial3CardBaseVideoAutoplayViewHolder) holder).fetchRedgifsOrStreamableVideoCall != null && !((PostMaterial3CardBaseVideoAutoplayViewHolder) holder).fetchRedgifsOrStreamableVideoCall.isCanceled()) { + ((PostMaterial3CardBaseVideoAutoplayViewHolder) holder).fetchRedgifsOrStreamableVideoCall.cancel(); + ((PostMaterial3CardBaseVideoAutoplayViewHolder) holder).fetchRedgifsOrStreamableVideoCall = null; } - ((PostMaterial3CardBaseVideoAutoplayViewHolder) holder).errorLoadingGfycatImageView.setVisibility(View.GONE); + ((PostMaterial3CardBaseVideoAutoplayViewHolder) holder).errorLoadingRedgifsImageView.setVisibility(View.GONE); ((PostMaterial3CardBaseVideoAutoplayViewHolder) holder).muteButton.setVisibility(View.GONE); if (!((PostMaterial3CardBaseVideoAutoplayViewHolder) holder).isManuallyPaused) { ((PostMaterial3CardBaseVideoAutoplayViewHolder) holder).resetVolume(); @@ -2607,12 +2605,9 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie if (post.isImgur()) { intent.setData(Uri.parse(post.getVideoUrl())); intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_IMGUR); - } else if (post.isGfycat()) { - intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_GFYCAT); - intent.putExtra(ViewVideoActivity.EXTRA_GFYCAT_ID, post.getGfycatId()); } else if (post.isRedgifs()) { intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_REDGIFS); - intent.putExtra(ViewVideoActivity.EXTRA_GFYCAT_ID, post.getGfycatId()); + intent.putExtra(ViewVideoActivity.EXTRA_REDGIFS_ID, post.getRedgifsId()); } else if (post.isStreamable()) { intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_STREAMABLE); intent.putExtra(ViewVideoActivity.EXTRA_STREAMABLE_SHORT_CODE, post.getStreamableShortCode()); @@ -3279,7 +3274,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie class PostBaseVideoAutoplayViewHolder extends PostBaseViewHolder implements ToroPlayer { AspectRatioFrameLayout aspectRatioFrameLayout; GifImageView previewImageView; - ImageView errorLoadingGfycatImageView; + ImageView errorLoadingRedgifsImageView; PlayerView videoPlayer; ImageView muteButton; ImageView fullscreenButton; @@ -3292,7 +3287,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie ExoPlayerViewHelper helper; private Uri mediaUri; private float volume; - public Call<String> fetchGfycatOrStreamableVideoCall; + public Call<String> fetchRedgifsOrStreamableVideoCall; private boolean isManuallyPaused; PostBaseVideoAutoplayViewHolder(View rootView, @@ -3311,7 +3306,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie CustomTextView flairTextView, AspectRatioFrameLayout aspectRatioFrameLayout, GifImageView previewImageView, - ImageView errorLoadingGfycatImageView, + ImageView errorLoadingRedgifsImageView, PlayerView videoPlayer, ImageView muteButton, ImageView fullscreenButton, @@ -3350,7 +3345,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie this.aspectRatioFrameLayout = aspectRatioFrameLayout; this.previewImageView = previewImageView; - this.errorLoadingGfycatImageView = errorLoadingGfycatImageView; + this.errorLoadingRedgifsImageView = errorLoadingRedgifsImageView; this.videoPlayer = videoPlayer; this.muteButton = muteButton; this.fullscreenButton = fullscreenButton; @@ -3390,17 +3385,10 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie if (post.isImgur()) { intent.setData(Uri.parse(post.getVideoUrl())); intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_IMGUR); - } else if (post.isGfycat()) { - intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_GFYCAT); - intent.putExtra(ViewVideoActivity.EXTRA_GFYCAT_ID, post.getGfycatId()); - if (post.isLoadGfycatOrStreamableVideoSuccess()) { - intent.setData(Uri.parse(post.getVideoUrl())); - intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_DOWNLOAD_URL, post.getVideoDownloadUrl()); - } } else if (post.isRedgifs()) { intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_REDGIFS); - intent.putExtra(ViewVideoActivity.EXTRA_GFYCAT_ID, post.getGfycatId()); - if (post.isLoadGfycatOrStreamableVideoSuccess()) { + intent.putExtra(ViewVideoActivity.EXTRA_REDGIFS_ID, post.getRedgifsId()); + if (post.isLoadRedgifsOrStreamableVideoSuccess()) { intent.setData(Uri.parse(post.getVideoUrl())); intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_DOWNLOAD_URL, post.getVideoDownloadUrl()); } @@ -3598,7 +3586,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie binding.flairCustomTextViewItemPostVideoTypeAutoplay, binding.aspectRatioFrameLayoutItemPostVideoTypeAutoplay, binding.previewImageViewItemPostVideoTypeAutoplay, - binding.errorLoadingGfycatImageViewItemPostVideoTypeAutoplay, + binding.errorLoadingVideoImageViewItemPostVideoTypeAutoplay, binding.playerViewItemPostVideoTypeAutoplay, binding.getRoot().findViewById(R.id.mute_exo_playback_control_view), binding.getRoot().findViewById(R.id.fullscreen_exo_playback_control_view), @@ -3633,7 +3621,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie binding.flairCustomTextViewItemPostVideoTypeAutoplay, binding.aspectRatioFrameLayoutItemPostVideoTypeAutoplay, binding.previewImageViewItemPostVideoTypeAutoplay, - binding.errorLoadingGfycatImageViewItemPostVideoTypeAutoplay, + binding.errorLoadingVideoImageViewItemPostVideoTypeAutoplay, binding.playerViewItemPostVideoTypeAutoplay, binding.getRoot().findViewById(R.id.mute_exo_playback_control_view), binding.getRoot().findViewById(R.id.fullscreen_exo_playback_control_view), @@ -4983,7 +4971,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie class PostCard2BaseVideoAutoplayViewHolder extends PostBaseViewHolder implements ToroPlayer { AspectRatioFrameLayout aspectRatioFrameLayout; GifImageView previewImageView; - ImageView errorLoadingGfycatImageView; + ImageView errorLoadingRedgifsImageView; PlayerView videoPlayer; ImageView muteButton; ImageView fullscreenButton; @@ -4997,7 +4985,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie ExoPlayerViewHelper helper; private Uri mediaUri; private float volume; - public Call<String> fetchGfycatOrStreamableVideoCall; + public Call<String> fetchRedgifsOrStreamableVideoCall; private boolean isManuallyPaused; PostCard2BaseVideoAutoplayViewHolder(View itemView, @@ -5016,7 +5004,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie CustomTextView flairTextView, AspectRatioFrameLayout aspectRatioFrameLayout, GifImageView previewImageView, - ImageView errorLoadingGfycatImageView, + ImageView errorLoadingRedgifsImageView, PlayerView videoPlayer, ImageView muteButton, ImageView fullscreenButton, @@ -5057,7 +5045,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie this.aspectRatioFrameLayout = aspectRatioFrameLayout; this.previewImageView = previewImageView; - this.errorLoadingGfycatImageView = errorLoadingGfycatImageView; + this.errorLoadingRedgifsImageView = errorLoadingRedgifsImageView; this.videoPlayer = videoPlayer; this.muteButton = muteButton; this.fullscreenButton = fullscreenButton; @@ -5098,17 +5086,10 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie if (post.isImgur()) { intent.setData(Uri.parse(post.getVideoUrl())); intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_IMGUR); - } else if (post.isGfycat()) { - intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_GFYCAT); - intent.putExtra(ViewVideoActivity.EXTRA_GFYCAT_ID, post.getGfycatId()); - if (post.isLoadGfycatOrStreamableVideoSuccess()) { - intent.setData(Uri.parse(post.getVideoUrl())); - intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_DOWNLOAD_URL, post.getVideoDownloadUrl()); - } } else if (post.isRedgifs()) { intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_REDGIFS); - intent.putExtra(ViewVideoActivity.EXTRA_GFYCAT_ID, post.getGfycatId()); - if (post.isLoadGfycatOrStreamableVideoSuccess()) { + intent.putExtra(ViewVideoActivity.EXTRA_REDGIFS_ID, post.getRedgifsId()); + if (post.isLoadRedgifsOrStreamableVideoSuccess()) { intent.setData(Uri.parse(post.getVideoUrl())); intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_DOWNLOAD_URL, post.getVideoDownloadUrl()); } @@ -5305,7 +5286,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie binding.flairCustomTextViewItemPostCard2VideoAutoplay, binding.aspectRatioFrameLayoutItemPostCard2VideoAutoplay, binding.previewImageViewItemPostCard2VideoAutoplay, - binding.errorLoadingGfycatImageViewItemPostCard2VideoAutoplay, + binding.errorLoadingVideoImageViewItemPostCard2VideoAutoplay, binding.playerViewItemPostCard2VideoAutoplay, binding.getRoot().findViewById(R.id.mute_exo_playback_control_view), binding.getRoot().findViewById(R.id.fullscreen_exo_playback_control_view), @@ -5341,7 +5322,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie binding.flairCustomTextViewItemPostCard2VideoAutoplay, binding.aspectRatioFrameLayoutItemPostCard2VideoAutoplay, binding.previewImageViewItemPostCard2VideoAutoplay, - binding.errorLoadingGfycatImageViewItemPostCard2VideoAutoplay, + binding.errorLoadingVideoImageViewItemPostCard2VideoAutoplay, binding.playerViewItemPostCard2VideoAutoplay, binding.getRoot().findViewById(R.id.mute_exo_playback_control_view), binding.getRoot().findViewById(R.id.fullscreen_exo_playback_control_view), @@ -6014,7 +5995,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie class PostMaterial3CardBaseVideoAutoplayViewHolder extends PostMaterial3CardBaseViewHolder implements ToroPlayer { AspectRatioFrameLayout aspectRatioFrameLayout; GifImageView previewImageView; - ImageView errorLoadingGfycatImageView; + ImageView errorLoadingRedgifsImageView; PlayerView videoPlayer; ImageView muteButton; ImageView fullscreenButton; @@ -6027,7 +6008,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie ExoPlayerViewHelper helper; private Uri mediaUri; private float volume; - public Call<String> fetchGfycatOrStreamableVideoCall; + public Call<String> fetchRedgifsOrStreamableVideoCall; private boolean isManuallyPaused; PostMaterial3CardBaseVideoAutoplayViewHolder(View rootView, @@ -6039,7 +6020,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie TextView titleTextView, AspectRatioFrameLayout aspectRatioFrameLayout, GifImageView previewImageView, - ImageView errorLoadingGfycatImageView, + ImageView errorLoadingRedgifsImageView, PlayerView videoPlayer, ImageView muteButton, ImageView fullscreenButton, @@ -6071,7 +6052,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie this.aspectRatioFrameLayout = aspectRatioFrameLayout; this.previewImageView = previewImageView; - this.errorLoadingGfycatImageView = errorLoadingGfycatImageView; + this.errorLoadingRedgifsImageView = errorLoadingRedgifsImageView; this.videoPlayer = videoPlayer; this.muteButton = muteButton; this.fullscreenButton = fullscreenButton; @@ -6111,17 +6092,10 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie if (post.isImgur()) { intent.setData(Uri.parse(post.getVideoUrl())); intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_IMGUR); - } else if (post.isGfycat()) { - intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_GFYCAT); - intent.putExtra(ViewVideoActivity.EXTRA_GFYCAT_ID, post.getGfycatId()); - if (post.isLoadGfycatOrStreamableVideoSuccess()) { - intent.setData(Uri.parse(post.getVideoUrl())); - intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_DOWNLOAD_URL, post.getVideoDownloadUrl()); - } } else if (post.isRedgifs()) { intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_REDGIFS); - intent.putExtra(ViewVideoActivity.EXTRA_GFYCAT_ID, post.getGfycatId()); - if (post.isLoadGfycatOrStreamableVideoSuccess()) { + intent.putExtra(ViewVideoActivity.EXTRA_REDGIFS_ID, post.getRedgifsId()); + if (post.isLoadRedgifsOrStreamableVideoSuccess()) { intent.setData(Uri.parse(post.getVideoUrl())); intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_DOWNLOAD_URL, post.getVideoDownloadUrl()); } @@ -6312,7 +6286,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie binding.titleTextViewItemPostCard3VideoTypeAutoplay, binding.aspectRatioFrameLayoutItemPostCard3VideoTypeAutoplay, binding.previewImageViewItemPostCard3VideoTypeAutoplay, - binding.errorLoadingGfycatImageViewItemPostCard3VideoTypeAutoplay, + binding.errorLoadingVideoImageViewItemPostCard3VideoTypeAutoplay, binding.playerViewItemPostCard3VideoTypeAutoplay, binding.getRoot().findViewById(R.id.mute_exo_playback_control_view), binding.getRoot().findViewById(R.id.fullscreen_exo_playback_control_view), @@ -6340,7 +6314,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie binding.titleTextViewItemPostCard3VideoTypeAutoplay, binding.aspectRatioFrameLayoutItemPostCard3VideoTypeAutoplay, binding.previewImageViewItemPostCard3VideoTypeAutoplay, - binding.errorLoadingGfycatImageViewItemPostCard3VideoTypeAutoplay, + binding.errorLoadingVideoImageViewItemPostCard3VideoTypeAutoplay, binding.playerViewItemPostCard3VideoTypeAutoplay, binding.getRoot().findViewById(R.id.mute_exo_playback_control_view), binding.getRoot().findViewById(R.id.fullscreen_exo_playback_control_view), diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/apis/GfycatAPI.java b/app/src/main/java/ml/docilealligator/infinityforreddit/apis/GfycatAPI.java deleted file mode 100644 index 14028182..00000000 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/apis/GfycatAPI.java +++ /dev/null @@ -1,10 +0,0 @@ -package ml.docilealligator.infinityforreddit.apis; - -import retrofit2.Call; -import retrofit2.http.GET; -import retrofit2.http.Path; - -public interface GfycatAPI { - @GET("{gfyid}") - Call<String> getGfycatData(@Path("gfyid") String gfyId); -} diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/apis/RedditAPI.java b/app/src/main/java/ml/docilealligator/infinityforreddit/apis/RedditAPI.java index 44ba63b6..32948ff7 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/apis/RedditAPI.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/apis/RedditAPI.java @@ -237,10 +237,6 @@ public interface RedditAPI { @GET("/api/trending_searches_v1.json?withAds=0&raw_json=1&gilding_detail=1") Call<String> getTrendingSearchesOauth(@HeaderMap Map<String, String> headers); - default Call<String> getWiki(@Path("subredditName") String subredditName) { - return getWikiPage(subredditName, "index"); - } - @GET("/r/{subredditName}/wiki/{wikiPage}.json?raw_json=1") Call<String> getWikiPage(@Path("subredditName") String subredditName, @Path("wikiPage") String wikiPage); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/asynctasks/SwitchAccount.java b/app/src/main/java/ml/docilealligator/infinityforreddit/asynctasks/SwitchAccount.java index f5443973..bb49824b 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/asynctasks/SwitchAccount.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/asynctasks/SwitchAccount.java @@ -22,6 +22,7 @@ public class SwitchAccount { .putString(SharedPreferencesUtils.ACCESS_TOKEN, account.getAccessToken()) .putString(SharedPreferencesUtils.ACCOUNT_NAME, account.getAccountName()) .putString(SharedPreferencesUtils.ACCOUNT_IMAGE_URL, account.getProfileImageUrl()).apply(); + currentAccountSharedPreferences.edit().remove(SharedPreferencesUtils.SUBSCRIBED_THINGS_SYNC_TIME).apply(); handler.post(() -> switchAccountListener.switched(account)); }); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/HistoryPostFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/HistoryPostFragment.java index 752fe396..988c9b8f 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/HistoryPostFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/HistoryPostFragment.java @@ -163,9 +163,6 @@ public class HistoryPostFragment extends Fragment implements FragmentCommunicato @Named("application_only_oauth") Retrofit mApplicationOnlyRetrofit; @Inject - @Named("gfycat") - Retrofit mGfycatRetrofit; - @Inject @Named("redgifs") Retrofit mRedgifsRetrofit; @Inject @@ -378,7 +375,7 @@ public class HistoryPostFragment extends Fragment implements FragmentCommunicato if (historyType == HISTORY_TYPE_READ_POSTS) { postLayout = mPostLayoutSharedPreferences.getInt(SharedPreferencesUtils.HISTORY_POST_LAYOUT_READ_POST, defaultPostLayout); - mAdapter = new HistoryPostRecyclerViewAdapter(activity, this, mExecutor, mOauthRetrofit, mGfycatRetrofit, + mAdapter = new HistoryPostRecyclerViewAdapter(activity, this, mExecutor, mOauthRetrofit, mRedgifsRetrofit, mStreamableApiProvider, mCustomThemeWrapper, locale, accessToken, accountName, postType, postLayout, true, mSharedPreferences, mCurrentAccountSharedPreferences, mNsfwAndSpoilerSharedPreferences, diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java index e49ff234..e1949175 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java @@ -185,9 +185,6 @@ public class PostFragment extends Fragment implements FragmentCommunicator { @Named("application_only_oauth") Retrofit mApplicationOnlyRetrofit; @Inject - @Named("gfycat") - Retrofit mGfycatRetrofit; - @Inject @Named("redgifs") Retrofit mRedgifsRetrofit; @Inject @@ -462,7 +459,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator { sortType = new SortType(SortType.Type.valueOf(sort), SortType.Time.valueOf(sortTime)); postLayout = mPostLayoutSharedPreferences.getInt(SharedPreferencesUtils.POST_LAYOUT_SEARCH_POST, defaultPostLayout); - mAdapter = new PostRecyclerViewAdapter(activity, this, mExecutor, mOauthRetrofit, mGfycatRetrofit, + mAdapter = new PostRecyclerViewAdapter(activity, this, mExecutor, mOauthRetrofit, mRedgifsRetrofit, mStreamableApiProvider, mCustomThemeWrapper, locale, accessToken, accountName, postType, postLayout, true, mSharedPreferences, mCurrentAccountSharedPreferences, mNsfwAndSpoilerSharedPreferences, mPostHistorySharedPreferences, @@ -539,7 +536,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator { sortType = new SortType(SortType.Type.valueOf(sort)); } - mAdapter = new PostRecyclerViewAdapter(activity, this, mExecutor, mOauthRetrofit, mGfycatRetrofit, + mAdapter = new PostRecyclerViewAdapter(activity, this, mExecutor, mOauthRetrofit, mRedgifsRetrofit, mStreamableApiProvider, mCustomThemeWrapper, locale, accessToken, accountName, postType, postLayout, displaySubredditName, mSharedPreferences, mCurrentAccountSharedPreferences, mNsfwAndSpoilerSharedPreferences, mPostHistorySharedPreferences, @@ -610,7 +607,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator { sortType = new SortType(SortType.Type.valueOf(sort)); } - mAdapter = new PostRecyclerViewAdapter(activity, this, mExecutor, mOauthRetrofit, mGfycatRetrofit, + mAdapter = new PostRecyclerViewAdapter(activity, this, mExecutor, mOauthRetrofit, mRedgifsRetrofit, mStreamableApiProvider, mCustomThemeWrapper, locale, accessToken, accountName, postType, postLayout, true, mSharedPreferences, mCurrentAccountSharedPreferences, mNsfwAndSpoilerSharedPreferences, mPostHistorySharedPreferences, @@ -675,7 +672,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator { } postLayout = mPostLayoutSharedPreferences.getInt(SharedPreferencesUtils.POST_LAYOUT_USER_POST_BASE + username, defaultPostLayout); - mAdapter = new PostRecyclerViewAdapter(activity, this, mExecutor, mOauthRetrofit, mGfycatRetrofit, + mAdapter = new PostRecyclerViewAdapter(activity, this, mExecutor, mOauthRetrofit, mRedgifsRetrofit, mStreamableApiProvider, mCustomThemeWrapper, locale, accessToken, accountName, postType, postLayout, true, mSharedPreferences, mCurrentAccountSharedPreferences, mNsfwAndSpoilerSharedPreferences, mPostHistorySharedPreferences, @@ -736,7 +733,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator { postLayout = mPostLayoutSharedPreferences.getInt(SharedPreferencesUtils.POST_LAYOUT_FRONT_PAGE_POST, defaultPostLayout); - mAdapter = new PostRecyclerViewAdapter(activity, this, mExecutor, mOauthRetrofit, mGfycatRetrofit, + mAdapter = new PostRecyclerViewAdapter(activity, this, mExecutor, mOauthRetrofit, mRedgifsRetrofit, mStreamableApiProvider, mCustomThemeWrapper, locale, accessToken, accountName, postType, postLayout, true, mSharedPreferences, mCurrentAccountSharedPreferences, mNsfwAndSpoilerSharedPreferences, mPostHistorySharedPreferences, @@ -796,7 +793,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator { postLayout = mPostLayoutSharedPreferences.getInt(SharedPreferencesUtils.POST_LAYOUT_MULTI_REDDIT_POST_BASE + multiRedditPath, defaultPostLayout); - mAdapter = new PostRecyclerViewAdapter(activity, this, mExecutor, mOauthRetrofit, mGfycatRetrofit, + mAdapter = new PostRecyclerViewAdapter(activity, this, mExecutor, mOauthRetrofit, mRedgifsRetrofit, mStreamableApiProvider, mCustomThemeWrapper, locale, accessToken, accountName, postType, postLayout, true, mSharedPreferences, mCurrentAccountSharedPreferences, mNsfwAndSpoilerSharedPreferences, mPostHistorySharedPreferences, @@ -853,7 +850,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator { } postLayout = mPostLayoutSharedPreferences.getInt(SharedPreferencesUtils.POST_LAYOUT_FRONT_PAGE_POST, defaultPostLayout); - mAdapter = new PostRecyclerViewAdapter(activity, this, mExecutor, mOauthRetrofit, mGfycatRetrofit, + mAdapter = new PostRecyclerViewAdapter(activity, this, mExecutor, mOauthRetrofit, mRedgifsRetrofit, mStreamableApiProvider, mCustomThemeWrapper, locale, accessToken, accountName, postType, postLayout, true, mSharedPreferences, mCurrentAccountSharedPreferences, mNsfwAndSpoilerSharedPreferences, mPostHistorySharedPreferences, diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragment.java index eb68bbc1..249364f0 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragment.java @@ -160,9 +160,6 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic @Named("application_only_oauth") Retrofit mApplicationOnlyRetrofit; @Inject - @Named("gfycat") - Retrofit mGfycatRetrofit; - @Inject @Named("redgifs") Retrofit mRedgifsRetrofit; @Inject @@ -601,7 +598,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic mPostAdapter = new PostDetailRecyclerViewAdapter(activity, this, mExecutor, mCustomThemeWrapper, mOauthRetrofit, mApplicationOnlyRetrofit, - mGfycatRetrofit, mRedgifsRetrofit, mStreamableApiProvider, mRedditDataRoomDatabase, mGlide, + mRedgifsRetrofit, mStreamableApiProvider, mRedditDataRoomDatabase, mGlide, mSeparatePostAndComments, mAccessToken, mAccountName, mPost, mLocale, mSharedPreferences, mCurrentAccountSharedPreferences, mNsfwAndSpoilerSharedPreferences, mPostDetailsSharedPreferences, mExoCreator, post -> EventBus.getDefault().post(new PostUpdateEventToPostList(mPost, postListPosition))); @@ -1293,7 +1290,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic mPostAdapter = new PostDetailRecyclerViewAdapter(activity, ViewPostDetailFragment.this, mExecutor, mCustomThemeWrapper, - mOauthRetrofit, mApplicationOnlyRetrofit, mGfycatRetrofit, mRedgifsRetrofit, + mOauthRetrofit, mApplicationOnlyRetrofit, mRedgifsRetrofit, mStreamableApiProvider, mRedditDataRoomDatabase, mGlide, mSeparatePostAndComments, mAccessToken, mAccountName, mPost, mLocale, mSharedPreferences, mCurrentAccountSharedPreferences, mNsfwAndSpoilerSharedPreferences, diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/post/FetchRemovedPost.java b/app/src/main/java/ml/docilealligator/infinityforreddit/post/FetchRemovedPost.java index 719e412d..5d815e83 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/post/FetchRemovedPost.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/post/FetchRemovedPost.java @@ -77,7 +77,7 @@ public class FetchRemovedPost { try { Uri uri = Uri.parse(url); String authority = uri.getAuthority(); - if (authority != null && (authority.contains("gfycat.com") || authority.contains("redgifs.com"))) { + if (authority != null && authority.contains("redgifs.com")) { post.setPostType(Post.LINK_TYPE); post.setUrl(url); } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/post/ParsePost.java b/app/src/main/java/ml/docilealligator/infinityforreddit/post/ParsePost.java index f7a4a03e..9389c87e 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/post/ParsePost.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/post/ParsePost.java @@ -312,18 +312,12 @@ public class ParsePost { String authority = uri.getAuthority(); if (authority != null) { - if (authority.contains("gfycat.com")) { - String gfycatId = url.substring(url.lastIndexOf("/") + 1).toLowerCase(); - post.setPostType(Post.VIDEO_TYPE); - post.setIsGfycat(true); - post.setVideoUrl(url); - post.setGfycatId(gfycatId); - } else if (authority.contains("redgifs.com")) { - String gfycatId = url.substring(url.lastIndexOf("/") + 1).toLowerCase(); + if (authority.contains("redgifs.com")) { + String redgifsId = url.substring(url.lastIndexOf("/") + 1).toLowerCase(); post.setPostType(Post.VIDEO_TYPE); post.setIsRedgifs(true); post.setVideoUrl(url); - post.setGfycatId(gfycatId); + post.setRedgifsId(redgifsId); } else if (authority.equals("streamable.com")) { String shortCode = url.substring(url.lastIndexOf("/") + 1); post.setPostType(Post.VIDEO_TYPE); @@ -500,18 +494,12 @@ public class ParsePost { String authority = uri.getAuthority(); if (authority != null) { - if (authority.contains("gfycat.com")) { - String gfycatId = url.substring(url.lastIndexOf("/") + 1).toLowerCase(); - post.setPostType(Post.VIDEO_TYPE); - post.setIsGfycat(true); - post.setVideoUrl(url); - post.setGfycatId(gfycatId); - } else if (authority.contains("redgifs.com")) { - String gfycatId = url.substring(url.lastIndexOf("/") + 1).toLowerCase(); + if (authority.contains("redgifs.com")) { + String redgifsId = url.substring(url.lastIndexOf("/") + 1).toLowerCase(); post.setPostType(Post.VIDEO_TYPE); post.setIsRedgifs(true); post.setVideoUrl(url); - post.setGfycatId(gfycatId); + post.setRedgifsId(redgifsId); } else if (authority.equals("streamable.com")) { String shortCode = url.substring(url.lastIndexOf("/") + 1); post.setPostType(Post.VIDEO_TYPE); @@ -573,18 +561,12 @@ public class ParsePost { String authority = uri.getAuthority(); if (authority != null) { - if (authority.contains("gfycat.com")) { - String gfycatId = url.substring(url.lastIndexOf("/") + 1).toLowerCase(); - post.setPostType(Post.VIDEO_TYPE); - post.setIsGfycat(true); - post.setVideoUrl(url); - post.setGfycatId(gfycatId); - } else if (authority.contains("redgifs.com")) { - String gfycatId = url.substring(url.lastIndexOf("/") + 1).toLowerCase(); + if (authority.contains("redgifs.com")) { + String redgifsId = url.substring(url.lastIndexOf("/") + 1).toLowerCase(); post.setPostType(Post.VIDEO_TYPE); post.setIsRedgifs(true); post.setVideoUrl(url); - post.setGfycatId(gfycatId); + post.setRedgifsId(redgifsId); } else if (authority.equals("streamable.com")) { String shortCode = url.substring(url.lastIndexOf("/") + 1); post.setPostType(Post.VIDEO_TYPE); @@ -601,22 +583,14 @@ public class ParsePost { try { String authority = uri.getAuthority(); if (authority != null) { - if (authority.contains("gfycat.com")) { - post.setIsGfycat(true); - post.setVideoUrl(url); - String gfycatId = url.substring(url.lastIndexOf("/") + 1); - if (gfycatId.contains("-")) { - gfycatId = gfycatId.substring(0, gfycatId.indexOf('-')); - } - post.setGfycatId(gfycatId.toLowerCase()); - } else if (authority.contains("redgifs.com")) { - String gfycatId = url.substring(url.lastIndexOf("/") + 1); - if (gfycatId.contains("-")) { - gfycatId = gfycatId.substring(0, gfycatId.indexOf('-')); + if (authority.contains("redgifs.com")) { + String redgifsId = url.substring(url.lastIndexOf("/") + 1); + if (redgifsId.contains("-")) { + redgifsId = redgifsId.substring(0, redgifsId.indexOf('-')); } post.setIsRedgifs(true); post.setVideoUrl(url); - post.setGfycatId(gfycatId.toLowerCase()); + post.setRedgifsId(redgifsId.toLowerCase()); } else if (authority.equals("streamable.com")) { String shortCode = url.substring(url.lastIndexOf("/") + 1); post.setPostType(Post.VIDEO_TYPE); @@ -684,18 +658,12 @@ public class ParsePost { String authority = uri.getAuthority(); if (authority != null) { - if (authority.contains("gfycat.com")) { - String gfycatId = url.substring(url.lastIndexOf("/") + 1).toLowerCase(); - post.setPostType(Post.VIDEO_TYPE); - post.setIsGfycat(true); - post.setVideoUrl(url); - post.setGfycatId(gfycatId); - } else if (authority.contains("redgifs.com")) { - String gfycatId = url.substring(url.lastIndexOf("/") + 1).toLowerCase(); + if (authority.contains("redgifs.com")) { + String redgifsId = url.substring(url.lastIndexOf("/") + 1).toLowerCase(); post.setPostType(Post.VIDEO_TYPE); post.setIsRedgifs(true); post.setVideoUrl(url); - post.setGfycatId(gfycatId); + post.setRedgifsId(redgifsId); } else if (authority.equals("streamable.com")) { String shortCode = url.substring(url.lastIndexOf("/") + 1); post.setPostType(Post.VIDEO_TYPE); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/post/Post.java b/app/src/main/java/ml/docilealligator/infinityforreddit/post/Post.java index 5985de46..f03a666c 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/post/Post.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/post/Post.java @@ -43,13 +43,12 @@ public class Post implements Parcelable { private String url; private String videoUrl; private String videoDownloadUrl; - private String gfycatId; + private String redgifsId; private String streamableShortCode; private boolean isImgur; - private boolean isGfycat; private boolean isRedgifs; private boolean isStreamable; - private boolean loadGfyOrStreamableVideoSuccess; + private boolean loadRedgifsOrStreamableVideoSuccess; private final String permalink; private String flair; private final long postTimeMillis; @@ -167,13 +166,12 @@ public class Post implements Parcelable { url = in.readString(); videoUrl = in.readString(); videoDownloadUrl = in.readString(); - gfycatId = in.readString(); + redgifsId = in.readString(); streamableShortCode = in.readString(); isImgur = in.readByte() != 0; - isGfycat = in.readByte() != 0; isRedgifs = in.readByte() != 0; isStreamable = in.readByte() != 0; - loadGfyOrStreamableVideoSuccess = in.readByte() != 0; + loadRedgifsOrStreamableVideoSuccess = in.readByte() != 0; permalink = in.readString(); flair = in.readString(); postTimeMillis = in.readLong(); @@ -328,12 +326,12 @@ public class Post implements Parcelable { this.videoDownloadUrl = videoDownloadUrl; } - public String getGfycatId() { - return gfycatId; + public String getRedgifsId() { + return redgifsId; } - public void setGfycatId(String gfycatId) { - this.gfycatId = gfycatId; + public void setRedgifsId(String redgifsId) { + this.redgifsId = redgifsId; } public String getStreamableShortCode() { @@ -352,14 +350,6 @@ public class Post implements Parcelable { return isImgur; } - public boolean isGfycat() { - return isGfycat; - } - - public void setIsGfycat(boolean isGfycat) { - this.isGfycat = isGfycat; - } - public boolean isRedgifs() { return isRedgifs; } @@ -376,12 +366,12 @@ public class Post implements Parcelable { this.isStreamable = isStreamable; } - public boolean isLoadGfycatOrStreamableVideoSuccess() { - return loadGfyOrStreamableVideoSuccess; + public boolean isLoadRedgifsOrStreamableVideoSuccess() { + return loadRedgifsOrStreamableVideoSuccess; } - public void setLoadGfyOrStreamableVideoSuccess(boolean loadGfyOrStreamableVideoSuccess) { - this.loadGfyOrStreamableVideoSuccess = loadGfyOrStreamableVideoSuccess; + public void setLoadRedgifsOrStreamableVideoSuccess(boolean loadRedgifsOrStreamableVideoSuccess) { + this.loadRedgifsOrStreamableVideoSuccess = loadRedgifsOrStreamableVideoSuccess; } public String getPermalink() { @@ -496,13 +486,12 @@ public class Post implements Parcelable { dest.writeString(url); dest.writeString(videoUrl); dest.writeString(videoDownloadUrl); - dest.writeString(gfycatId); + dest.writeString(redgifsId); dest.writeString(streamableShortCode); dest.writeByte((byte) (isImgur ? 1 : 0)); - dest.writeByte((byte) (isGfycat ? 1 : 0)); dest.writeByte((byte) (isRedgifs ? 1 : 0)); dest.writeByte((byte) (isStreamable ? 1 : 0)); - dest.writeByte((byte) (loadGfyOrStreamableVideoSuccess ? 1 : 0)); + dest.writeByte((byte) (loadRedgifsOrStreamableVideoSuccess ? 1 : 0)); dest.writeString(permalink); dest.writeString(flair); dest.writeLong(postTimeMillis); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/settings/AdvancedPreferenceFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/settings/AdvancedPreferenceFragment.java index 9f9534fb..25a3bd82 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/settings/AdvancedPreferenceFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/settings/AdvancedPreferenceFragment.java @@ -227,6 +227,10 @@ public class AdvancedPreferenceFragment extends CustomFontPreferenceFragmentComp editor.remove(SharedPreferencesUtils.BLUR_SPOILER_KEY_LEGACY); editor.remove(SharedPreferencesUtils.CONFIRM_TO_EXIT_LEGACY); editor.remove(SharedPreferencesUtils.OPEN_LINK_IN_APP_LEGACY); + editor.remove(SharedPreferencesUtils.AUTOMATICALLY_TRY_REDGIFS_LEGACY); + editor.remove(SharedPreferencesUtils.DO_NOT_SHOW_REDDIT_API_INFO_AGAIN_LEGACY); + editor.remove(SharedPreferencesUtils.HIDE_THE_NUMBER_OF_AWARDS_LEGACY); + editor.remove(SharedPreferencesUtils.HIDE_COMMENT_AWARDS_LEGACY); SharedPreferences.Editor sortTypeEditor = mSortTypeSharedPreferences.edit(); sortTypeEditor.remove(SharedPreferencesUtils.SORT_TYPE_ALL_POST_LEGACY); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/APIUtils.java b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/APIUtils.java index 10104f5a..5953285f 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/APIUtils.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/APIUtils.java @@ -18,7 +18,6 @@ public class APIUtils { public static final String API_BASE_URI = "https://www.reddit.com"; public static final String API_UPLOAD_MEDIA_URI = "https://reddit-uploaded-media.s3-accelerate.amazonaws.com"; public static final String API_UPLOAD_VIDEO_URI = "https://reddit-uploaded-video.s3-accelerate.amazonaws.com"; - public static final String GFYCAT_API_BASE_URI = "https://api.gfycat.com/v1/gfycats/"; public static final String REDGIFS_API_BASE_URI = "https://api.redgifs.com"; public static final String IMGUR_API_BASE_URI = "https://api.imgur.com/3/"; public static final String PUSHSHIFT_API_BASE_URI = "https://api.pushshift.io/"; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java index 863a49a6..15564ce7 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java @@ -106,7 +106,6 @@ public class SharedPreferencesUtils { public static final String VIDEO_AUTOPLAY_VALUE_NEVER = "0"; public static final String MUTE_AUTOPLAYING_VIDEOS = "mute_autoplaying_videos"; public static final String AUTOPLAY_NSFW_VIDEOS = "autoplay_nsfw_videos"; - public static final String AUTOMATICALLY_TRY_REDGIFS = "automatically_try_redgifs"; public static final String LOCK_JUMP_TO_NEXT_TOP_LEVEL_COMMENT_BUTTON = "lock_jump_to_next_top_level_comment_button"; public static final String SWAP_TAP_AND_LONG_COMMENTS = "swap_tap_and_long_in_comments"; public static final String SWIPE_UP_TO_HIDE_JUMP_TO_NEXT_TOP_LEVEL_COMMENT_BUTTON = "swipe_up_to_hide_jump_to_next_top_level_comments_button"; @@ -392,6 +391,7 @@ public class SharedPreferencesUtils { public static final String BLUR_SPOILER_KEY_LEGACY = "blur_spoiler"; public static final String CONFIRM_TO_EXIT_LEGACY = "confirm_to_exit"; public static final String OPEN_LINK_IN_APP_LEGACY = "open_link_in_app"; + public static final String AUTOMATICALLY_TRY_REDGIFS_LEGACY = "automatically_try_redgifs"; public static final String DO_NOT_SHOW_REDDIT_API_INFO_AGAIN_LEGACY = "do_not_show_reddit_api_info_again"; public static final String HIDE_THE_NUMBER_OF_AWARDS_LEGACY = "hide_the_number_of_awards"; |