Start migrating to Material Design 3. Try optimizing image loading in PostRecyclerViewAdapter.

This commit is contained in:
Alex Ning 2021-10-30 21:20:48 +08:00
parent efd5f61889
commit 4ab8f037f2
17 changed files with 268 additions and 199 deletions

View File

@ -1,7 +1,7 @@
apply plugin: 'com.android.application' apply plugin: 'com.android.application'
android { android {
compileSdkVersion 30 compileSdkVersion 31
defaultConfig { defaultConfig {
applicationId "ml.docilealligator.infinityforreddit" applicationId "ml.docilealligator.infinityforreddit"
minSdkVersion 21 minSdkVersion 21
@ -68,7 +68,7 @@ dependencies {
annotationProcessor "androidx.room:room-compiler:$roomVersion" annotationProcessor "androidx.room:room-compiler:$roomVersion"
implementation 'androidx.viewpager2:viewpager2:1.1.0-beta01' implementation 'androidx.viewpager2:viewpager2:1.1.0-beta01'
implementation 'androidx.work:work-runtime:2.5.0' implementation 'androidx.work:work-runtime:2.5.0'
implementation 'com.google.android.material:material:1.3.0' implementation 'com.google.android.material:material:1.5.0-alpha05'
/** ExoPlayer **/ /** ExoPlayer **/
def exoplayerVersion = "2.10.8" def exoplayerVersion = "2.10.8"

View File

@ -205,7 +205,8 @@
android:label="@string/account_saved_thing_activity_label" android:label="@string/account_saved_thing_activity_label"
android:parentActivityName=".activities.MainActivity" android:parentActivityName=".activities.MainActivity"
android:theme="@style/AppTheme.Slidable" /> android:theme="@style/AppTheme.Slidable" />
<activity android:name=".activities.ShareDataResolverActivity"> <activity android:name=".activities.ShareDataResolverActivity"
android:exported="false">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.SEND" /> <action android:name="android.intent.action.SEND" />
@ -263,7 +264,8 @@
android:label="@string/search_subreddits_activity_label" android:label="@string/search_subreddits_activity_label"
android:parentActivityName=".activities.MainActivity" android:parentActivityName=".activities.MainActivity"
android:theme="@style/AppTheme.Slidable" /> android:theme="@style/AppTheme.Slidable" />
<activity android:name=".activities.LinkResolverActivity"> <activity android:name=".activities.LinkResolverActivity"
android:exported="true">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.VIEW" /> <action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.DEFAULT" />
@ -356,7 +358,8 @@
android:name=".activities.MainActivity" android:name=".activities.MainActivity"
android:label="@string/application_name" android:label="@string/application_name"
android:theme="@style/AppTheme.Launcher" android:theme="@style/AppTheme.Launcher"
android:windowSoftInputMode="adjustPan"> android:windowSoftInputMode="adjustPan"
android:exported="true">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />

View File

@ -1,5 +1,10 @@
package ml.docilealligator.infinityforreddit.activities; package ml.docilealligator.infinityforreddit.activities;
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_AUTO_BATTERY;
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM;
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_NO;
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_YES;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.res.ColorStateList; import android.content.res.ColorStateList;
@ -44,11 +49,6 @@ import ml.docilealligator.infinityforreddit.font.TitleFontStyle;
import ml.docilealligator.infinityforreddit.utils.CustomThemeSharedPreferencesUtils; import ml.docilealligator.infinityforreddit.utils.CustomThemeSharedPreferencesUtils;
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils; import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_AUTO_BATTERY;
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM;
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_NO;
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_YES;
public abstract class BaseActivity extends AppCompatActivity { public abstract class BaseActivity extends AppCompatActivity {
private boolean immersiveInterface; private boolean immersiveInterface;
private boolean changeStatusBarIconColor; private boolean changeStatusBarIconColor;
@ -275,6 +275,15 @@ public abstract class BaseActivity extends AppCompatActivity {
return 0; return 0;
} }
public int getStatusBarHeight() {
int result = 0;
int resourceId = getResources().getIdentifier("status_bar_height", "dimen", "android");
if (resourceId > 0) {
result = getResources().getDimensionPixelSize(resourceId);
}
return result;
}
protected void setTransparentStatusBarAfterToolbarCollapsed() { protected void setTransparentStatusBarAfterToolbarCollapsed() {
this.transparentStatusBarAfterToolbarCollapsed = true; this.transparentStatusBarAfterToolbarCollapsed = true;
} }
@ -288,7 +297,14 @@ public abstract class BaseActivity extends AppCompatActivity {
} }
protected void applyAppBarLayoutAndToolbarTheme(AppBarLayout appBarLayout, Toolbar toolbar) { protected void applyAppBarLayoutAndToolbarTheme(AppBarLayout appBarLayout, Toolbar toolbar) {
applyAppBarLayoutAndToolbarTheme(appBarLayout, toolbar, true);
}
protected void applyAppBarLayoutAndToolbarTheme(AppBarLayout appBarLayout, Toolbar toolbar, boolean setToolbarBackgroundColor) {
appBarLayout.setBackgroundColor(customThemeWrapper.getColorPrimary()); appBarLayout.setBackgroundColor(customThemeWrapper.getColorPrimary());
if (setToolbarBackgroundColor) {
toolbar.setBackgroundColor(customThemeWrapper.getColorPrimary());
}
toolbar.setTitleTextColor(customThemeWrapper.getToolbarPrimaryTextAndIconColor()); toolbar.setTitleTextColor(customThemeWrapper.getToolbarPrimaryTextAndIconColor());
toolbar.setSubtitleTextColor(customThemeWrapper.getToolbarSecondaryTextColor()); toolbar.setSubtitleTextColor(customThemeWrapper.getToolbarSecondaryTextColor());
if (toolbar.getNavigationIcon() != null) { if (toolbar.getNavigationIcon() != null) {

View File

@ -31,7 +31,6 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.appcompat.app.ActionBarDrawerToggle; import androidx.appcompat.app.ActionBarDrawerToggle;
import androidx.appcompat.app.AppCompatDelegate; import androidx.appcompat.app.AppCompatDelegate;
import androidx.appcompat.widget.Toolbar;
import androidx.coordinatorlayout.widget.CoordinatorLayout; import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.core.app.ActivityCompat; import androidx.core.app.ActivityCompat;
import androidx.core.view.GravityCompat; import androidx.core.view.GravityCompat;
@ -52,6 +51,7 @@ import androidx.work.WorkManager;
import com.google.android.material.appbar.AppBarLayout; import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.appbar.CollapsingToolbarLayout; import com.google.android.material.appbar.CollapsingToolbarLayout;
import com.google.android.material.appbar.MaterialToolbar;
import com.google.android.material.bottomappbar.BottomAppBar; import com.google.android.material.bottomappbar.BottomAppBar;
import com.google.android.material.dialog.MaterialAlertDialogBuilder; import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.google.android.material.floatingactionbutton.FloatingActionButton; import com.google.android.material.floatingactionbutton.FloatingActionButton;
@ -160,7 +160,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
@BindView(R.id.collapsing_toolbar_layout_main_activity) @BindView(R.id.collapsing_toolbar_layout_main_activity)
CollapsingToolbarLayout collapsingToolbarLayout; CollapsingToolbarLayout collapsingToolbarLayout;
@BindView(R.id.toolbar) @BindView(R.id.toolbar)
Toolbar toolbar; MaterialToolbar toolbar;
@BindView(R.id.nav_drawer_recycler_view_main_activity) @BindView(R.id.nav_drawer_recycler_view_main_activity)
RecyclerView navDrawerRecyclerView; RecyclerView navDrawerRecyclerView;
@BindView(R.id.tab_layout_main_activity) @BindView(R.id.tab_layout_main_activity)
@ -269,9 +269,10 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
drawer.setStatusBarBackgroundColor(Color.TRANSPARENT); drawer.setStatusBarBackgroundColor(Color.TRANSPARENT);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
drawer.setFitsSystemWindows(false); drawer.setFitsSystemWindows(false);
drawer.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | getWindow().setDecorFitsSystemWindows(false);
/*drawer.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION); View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);*/
} else { } else {
window.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS); window.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
} }
@ -356,6 +357,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
option4BottomAppBar.setColorFilter(bottomAppBarIconColor, android.graphics.PorterDuff.Mode.SRC_IN); option4BottomAppBar.setColorFilter(bottomAppBarIconColor, android.graphics.PorterDuff.Mode.SRC_IN);
navigationView.setBackgroundColor(backgroundColor); navigationView.setBackgroundColor(backgroundColor);
applyAppBarLayoutAndToolbarTheme(appBarLayout, toolbar); applyAppBarLayoutAndToolbarTheme(appBarLayout, toolbar);
collapsingToolbarLayout.setContentScrimColor(mCustomThemeWrapper.getColorPrimary());
applyTabLayoutTheme(tabLayout); applyTabLayoutTheme(tabLayout);
bottomAppBar.setBackgroundTint(ColorStateList.valueOf(mCustomThemeWrapper.getBottomAppBarBackgroundColor())); bottomAppBar.setBackgroundTint(ColorStateList.valueOf(mCustomThemeWrapper.getBottomAppBarBackgroundColor()));
applyFABTheme(fab); applyFABTheme(fab);

View File

@ -16,6 +16,7 @@ import android.view.KeyEvent;
import android.view.Menu; import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.view.ViewTreeObserver;
import android.view.Window; import android.view.Window;
import android.view.WindowManager; import android.view.WindowManager;
import android.view.inputmethod.EditorInfo; import android.view.inputmethod.EditorInfo;
@ -27,7 +28,6 @@ import android.widget.Toast;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.appcompat.widget.Toolbar;
import androidx.coordinatorlayout.widget.CoordinatorLayout; import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity; import androidx.fragment.app.FragmentActivity;
@ -42,6 +42,7 @@ import com.bumptech.glide.RequestManager;
import com.bumptech.glide.request.RequestOptions; import com.bumptech.glide.request.RequestOptions;
import com.google.android.material.appbar.AppBarLayout; import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.appbar.CollapsingToolbarLayout; import com.google.android.material.appbar.CollapsingToolbarLayout;
import com.google.android.material.appbar.MaterialToolbar;
import com.google.android.material.bottomappbar.BottomAppBar; import com.google.android.material.bottomappbar.BottomAppBar;
import com.google.android.material.chip.Chip; import com.google.android.material.chip.Chip;
import com.google.android.material.dialog.MaterialAlertDialogBuilder; import com.google.android.material.dialog.MaterialAlertDialogBuilder;
@ -149,7 +150,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
@BindView(R.id.toolbar_linear_layout_view_subreddit_detail_activity) @BindView(R.id.toolbar_linear_layout_view_subreddit_detail_activity)
LinearLayout linearLayout; LinearLayout linearLayout;
@BindView(R.id.toolbar) @BindView(R.id.toolbar)
Toolbar toolbar; MaterialToolbar toolbar;
@BindView(R.id.tab_layout_view_subreddit_detail_activity) @BindView(R.id.tab_layout_view_subreddit_detail_activity)
TabLayout tabLayout; TabLayout tabLayout;
@BindView(R.id.banner_image_view_view_subreddit_detail_activity) @BindView(R.id.banner_image_view_view_subreddit_detail_activity)
@ -268,9 +269,10 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
if (isImmersiveInterface()) { if (isImmersiveInterface()) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
coordinatorLayout.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | /*coordinatorLayout.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION); View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);*/
getWindow().setDecorFitsSystemWindows(false);
} else { } else {
window.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS); window.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
} }
@ -515,7 +517,14 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
protected void applyCustomTheme() { protected void applyCustomTheme() {
coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor()); coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor());
collapsingToolbarLayout.setContentScrimColor(mCustomThemeWrapper.getColorPrimary()); collapsingToolbarLayout.setContentScrimColor(mCustomThemeWrapper.getColorPrimary());
applyAppBarLayoutAndToolbarTheme(appBarLayout, toolbar); appBarLayout.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
collapsingToolbarLayout.setScrimVisibleHeightTrigger(toolbar.getHeight() + tabLayout.getHeight() + getStatusBarHeight() * 2);
appBarLayout.getViewTreeObserver().removeOnGlobalLayoutListener(this);
}
});
applyAppBarLayoutAndToolbarTheme(appBarLayout, toolbar, false);
expandedTabTextColor = mCustomThemeWrapper.getTabLayoutWithExpandedCollapsingToolbarTextColor(); expandedTabTextColor = mCustomThemeWrapper.getTabLayoutWithExpandedCollapsingToolbarTextColor();
expandedTabIndicatorColor = mCustomThemeWrapper.getTabLayoutWithExpandedCollapsingToolbarTabIndicator(); expandedTabIndicatorColor = mCustomThemeWrapper.getTabLayoutWithExpandedCollapsingToolbarTabIndicator();
expandedTabBackgroundColor = mCustomThemeWrapper.getTabLayoutWithExpandedCollapsingToolbarTabBackground(); expandedTabBackgroundColor = mCustomThemeWrapper.getTabLayoutWithExpandedCollapsingToolbarTabBackground();
@ -793,6 +802,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
option1BottomAppBar.setOnClickListener(view -> { option1BottomAppBar.setOnClickListener(view -> {
bottomAppBarOptionAction(option1); bottomAppBarOptionAction(option1);
//Toast.makeText(this, "s " + collapsingToolbarLayout.getScrimVisibleHeightTrigger(), Toast.LENGTH_SHORT).show();
}); });
option2BottomAppBar.setOnClickListener(view -> { option2BottomAppBar.setOnClickListener(view -> {

View File

@ -6,7 +6,6 @@ import android.content.SharedPreferences;
import android.content.res.ColorStateList; import android.content.res.ColorStateList;
import android.content.res.Resources; import android.content.res.Resources;
import android.net.Uri; import android.net.Uri;
import android.opengl.Visibility;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
@ -18,6 +17,7 @@ import android.view.KeyEvent;
import android.view.Menu; import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.view.ViewTreeObserver;
import android.view.Window; import android.view.Window;
import android.view.WindowManager; import android.view.WindowManager;
import android.view.inputmethod.EditorInfo; import android.view.inputmethod.EditorInfo;
@ -29,7 +29,6 @@ import android.widget.Toast;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.appcompat.widget.Toolbar;
import androidx.coordinatorlayout.widget.CoordinatorLayout; import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity; import androidx.fragment.app.FragmentActivity;
@ -44,6 +43,7 @@ import com.bumptech.glide.RequestManager;
import com.bumptech.glide.request.RequestOptions; import com.bumptech.glide.request.RequestOptions;
import com.google.android.material.appbar.AppBarLayout; import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.appbar.CollapsingToolbarLayout; import com.google.android.material.appbar.CollapsingToolbarLayout;
import com.google.android.material.appbar.MaterialToolbar;
import com.google.android.material.bottomappbar.BottomAppBar; import com.google.android.material.bottomappbar.BottomAppBar;
import com.google.android.material.chip.Chip; import com.google.android.material.chip.Chip;
import com.google.android.material.dialog.MaterialAlertDialogBuilder; import com.google.android.material.dialog.MaterialAlertDialogBuilder;
@ -141,7 +141,7 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
@BindView(R.id.appbar_layout_view_user_detail) @BindView(R.id.appbar_layout_view_user_detail)
AppBarLayout appBarLayout; AppBarLayout appBarLayout;
@BindView(R.id.toolbar_view_user_detail_activity) @BindView(R.id.toolbar_view_user_detail_activity)
Toolbar toolbar; MaterialToolbar toolbar;
@BindView(R.id.toolbar_linear_layout_view_user_detail_activity) @BindView(R.id.toolbar_linear_layout_view_user_detail_activity)
LinearLayout linearLayout; LinearLayout linearLayout;
@BindView(R.id.tab_layout_view_user_detail_activity) @BindView(R.id.tab_layout_view_user_detail_activity)
@ -564,7 +564,14 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
protected void applyCustomTheme() { protected void applyCustomTheme() {
coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor()); coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor());
collapsingToolbarLayout.setContentScrimColor(mCustomThemeWrapper.getColorPrimary()); collapsingToolbarLayout.setContentScrimColor(mCustomThemeWrapper.getColorPrimary());
applyAppBarLayoutAndToolbarTheme(appBarLayout, toolbar); appBarLayout.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
collapsingToolbarLayout.setScrimVisibleHeightTrigger(toolbar.getHeight() + tabLayout.getHeight() + getStatusBarHeight() * 2);
appBarLayout.getViewTreeObserver().removeOnGlobalLayoutListener(this);
}
});
applyAppBarLayoutAndToolbarTheme(appBarLayout, toolbar, false);
expandedTabTextColor = mCustomThemeWrapper.getTabLayoutWithExpandedCollapsingToolbarTextColor(); expandedTabTextColor = mCustomThemeWrapper.getTabLayoutWithExpandedCollapsingToolbarTextColor();
expandedTabIndicatorColor = mCustomThemeWrapper.getTabLayoutWithExpandedCollapsingToolbarTabIndicator(); expandedTabIndicatorColor = mCustomThemeWrapper.getTabLayoutWithExpandedCollapsingToolbarTabIndicator();
expandedTabBackgroundColor = mCustomThemeWrapper.getTabLayoutWithExpandedCollapsingToolbarTabBackground(); expandedTabBackgroundColor = mCustomThemeWrapper.getTabLayoutWithExpandedCollapsingToolbarTabBackground();

View File

@ -680,7 +680,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
} }
((PostDetailVideoAutoplayViewHolder) holder).setVolume(mMuteAutoplayingVideos || (mPost.isNSFW() && mMuteNSFWVideo) ? 0f : 1f); ((PostDetailVideoAutoplayViewHolder) holder).setVolume(mMuteAutoplayingVideos || (mPost.isNSFW() && mMuteNSFWVideo) ? 0f : 1f);
if (mPost.isGfycat() || mPost.isRedgifs() && !mPost.isLoadGfyOrRedgifsVideoSuccess()) { if (mPost.isGfycat() || mPost.isRedgifs() && !mPost.isLoadGfycatOrRedgifsVideoSuccess()) {
((PostDetailVideoAutoplayViewHolder) holder).fetchGfycatOrRedgifsVideoLinks = new FetchGfycatOrRedgifsVideoLinks(new FetchGfycatOrRedgifsVideoLinks.FetchGfycatOrRedgifsVideoLinksListener() { ((PostDetailVideoAutoplayViewHolder) holder).fetchGfycatOrRedgifsVideoLinks = new FetchGfycatOrRedgifsVideoLinks(new FetchGfycatOrRedgifsVideoLinks.FetchGfycatOrRedgifsVideoLinksListener() {
@Override @Override
public void success(String webm, String mp4) { public void success(String webm, String mp4) {
@ -1670,14 +1670,14 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
if (mPost.isGfycat()) { if (mPost.isGfycat()) {
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_GFYCAT); intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_GFYCAT);
intent.putExtra(ViewVideoActivity.EXTRA_GFYCAT_ID, mPost.getGfycatId()); intent.putExtra(ViewVideoActivity.EXTRA_GFYCAT_ID, mPost.getGfycatId());
if (mPost.isLoadGfyOrRedgifsVideoSuccess()) { if (mPost.isLoadGfycatOrRedgifsVideoSuccess()) {
intent.setData(Uri.parse(mPost.getVideoUrl())); intent.setData(Uri.parse(mPost.getVideoUrl()));
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_DOWNLOAD_URL, mPost.getVideoDownloadUrl()); intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_DOWNLOAD_URL, mPost.getVideoDownloadUrl());
} }
} else if (mPost.isRedgifs()) { } else if (mPost.isRedgifs()) {
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_REDGIFS); intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_REDGIFS);
intent.putExtra(ViewVideoActivity.EXTRA_GFYCAT_ID, mPost.getGfycatId()); intent.putExtra(ViewVideoActivity.EXTRA_GFYCAT_ID, mPost.getGfycatId());
if (mPost.isLoadGfyOrRedgifsVideoSuccess()) { if (mPost.isLoadGfycatOrRedgifsVideoSuccess()) {
intent.setData(Uri.parse(mPost.getVideoUrl())); intent.setData(Uri.parse(mPost.getVideoUrl()));
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_DOWNLOAD_URL, mPost.getVideoDownloadUrl()); intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_DOWNLOAD_URL, mPost.getVideoDownloadUrl());
} }

View File

@ -455,6 +455,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
if (holder instanceof PostBaseViewHolder) { if (holder instanceof PostBaseViewHolder) {
Post post = getItem(position); Post post = getItem(position);
if (post != null) { if (post != null) {
((PostBaseViewHolder) holder).post = post;
((PostBaseViewHolder) holder).currentPosition = position; ((PostBaseViewHolder) holder).currentPosition = position;
if (post.isRead()) { if (post.isRead()) {
if (((PostBaseViewHolder) holder).itemViewIsNotCardView) { if (((PostBaseViewHolder) holder).itemViewIsNotCardView) {
@ -689,7 +690,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
((PostVideoAutoplayViewHolder) holder).setVolume(mFragment.getMasterMutingOption() ? 0f : 1f); ((PostVideoAutoplayViewHolder) holder).setVolume(mFragment.getMasterMutingOption() ? 0f : 1f);
} }
if (post.isGfycat() || post.isRedgifs() && !post.isLoadGfyOrRedgifsVideoSuccess()) { if ((post.isGfycat() || post.isRedgifs()) && !post.isLoadGfycatOrRedgifsVideoSuccess()) {
((PostVideoAutoplayViewHolder) holder).fetchGfycatOrRedgifsVideoLinks = new FetchGfycatOrRedgifsVideoLinks(new FetchGfycatOrRedgifsVideoLinks.FetchGfycatOrRedgifsVideoLinksListener() { ((PostVideoAutoplayViewHolder) holder).fetchGfycatOrRedgifsVideoLinks = new FetchGfycatOrRedgifsVideoLinks(new FetchGfycatOrRedgifsVideoLinks.FetchGfycatOrRedgifsVideoLinksListener() {
@Override @Override
public void success(String webm, String mp4) { public void success(String webm, String mp4) {
@ -766,6 +767,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
((PostWithPreviewTypeViewHolder) holder).videoOrGifIndicatorImageView.setVisibility(View.GONE); ((PostWithPreviewTypeViewHolder) holder).videoOrGifIndicatorImageView.setVisibility(View.GONE);
} else { } else {
Post.Preview preview = getSuitablePreview(post.getPreviews()); Post.Preview preview = getSuitablePreview(post.getPreviews());
((PostWithPreviewTypeViewHolder) holder).preview = preview;
if (preview != null) { if (preview != null) {
((PostWithPreviewTypeViewHolder) holder).imageWrapperRelativeLayout.setVisibility(View.VISIBLE); ((PostWithPreviewTypeViewHolder) holder).imageWrapperRelativeLayout.setVisibility(View.VISIBLE);
if (preview.getPreviewWidth() <= 0 || preview.getPreviewHeight() <= 0) { if (preview.getPreviewWidth() <= 0 || preview.getPreviewHeight() <= 0) {
@ -778,7 +780,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
((PostWithPreviewTypeViewHolder) holder).imageView ((PostWithPreviewTypeViewHolder) holder).imageView
.setRatio((float) preview.getPreviewHeight() / preview.getPreviewWidth()); .setRatio((float) preview.getPreviewHeight() / preview.getPreviewWidth());
} }
loadImage(holder, post, preview); loadImage(holder);
} else { } else {
((PostWithPreviewTypeViewHolder) holder).noPreviewLinkImageView.setVisibility(View.VISIBLE); ((PostWithPreviewTypeViewHolder) holder).noPreviewLinkImageView.setVisibility(View.VISIBLE);
if (post.getPostType() == Post.VIDEO_TYPE) { if (post.getPostType() == Post.VIDEO_TYPE) {
@ -821,7 +823,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
((PostCard2VideoAutoplayViewHolder) holder).setVolume(mFragment.getMasterMutingOption() ? 0f : 1f); ((PostCard2VideoAutoplayViewHolder) holder).setVolume(mFragment.getMasterMutingOption() ? 0f : 1f);
} }
if (post.isGfycat() || post.isRedgifs() && !post.isLoadGfyOrRedgifsVideoSuccess()) { if ((post.isGfycat() || post.isRedgifs()) && !post.isLoadGfycatOrRedgifsVideoSuccess()) {
((PostCard2VideoAutoplayViewHolder) holder).fetchGfycatOrRedgifsVideoLinks = new FetchGfycatOrRedgifsVideoLinks(new FetchGfycatOrRedgifsVideoLinks.FetchGfycatOrRedgifsVideoLinksListener() { ((PostCard2VideoAutoplayViewHolder) holder).fetchGfycatOrRedgifsVideoLinks = new FetchGfycatOrRedgifsVideoLinks(new FetchGfycatOrRedgifsVideoLinks.FetchGfycatOrRedgifsVideoLinksListener() {
@Override @Override
public void success(String webm, String mp4) { public void success(String webm, String mp4) {
@ -900,6 +902,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
((PostCard2WithPreviewViewHolder) holder).videoOrGifIndicatorImageView.setVisibility(View.GONE); ((PostCard2WithPreviewViewHolder) holder).videoOrGifIndicatorImageView.setVisibility(View.GONE);
} else { } else {
Post.Preview preview = getSuitablePreview(post.getPreviews()); Post.Preview preview = getSuitablePreview(post.getPreviews());
((PostCard2WithPreviewViewHolder) holder).preview = preview;
if (preview != null) { if (preview != null) {
((PostCard2WithPreviewViewHolder) holder).imageView.setVisibility(View.VISIBLE); ((PostCard2WithPreviewViewHolder) holder).imageView.setVisibility(View.VISIBLE);
if (preview.getPreviewWidth() <= 0 || preview.getPreviewHeight() <= 0) { if (preview.getPreviewWidth() <= 0 || preview.getPreviewHeight() <= 0) {
@ -912,7 +915,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
((PostCard2WithPreviewViewHolder) holder).imageView ((PostCard2WithPreviewViewHolder) holder).imageView
.setRatio((float) preview.getPreviewHeight() / preview.getPreviewWidth()); .setRatio((float) preview.getPreviewHeight() / preview.getPreviewWidth());
} }
loadImage(holder, post, preview); loadImage(holder);
} else { } else {
((PostCard2WithPreviewViewHolder) holder).progressBar.setVisibility(View.GONE); ((PostCard2WithPreviewViewHolder) holder).progressBar.setVisibility(View.GONE);
((PostCard2WithPreviewViewHolder) holder).noPreviewImageView.setVisibility(View.VISIBLE); ((PostCard2WithPreviewViewHolder) holder).noPreviewImageView.setVisibility(View.VISIBLE);
@ -943,6 +946,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
} else if (holder instanceof PostCompactBaseViewHolder) { } else if (holder instanceof PostCompactBaseViewHolder) {
Post post = getItem(position); Post post = getItem(position);
if (post != null) { if (post != null) {
((PostCompactBaseViewHolder) holder).post = post;
((PostCompactBaseViewHolder) holder).currentPosition = position; ((PostCompactBaseViewHolder) holder).currentPosition = position;
if (post.isRead()) { if (post.isRead()) {
holder.itemView.setBackgroundColor(mReadPostCardViewBackgroundColor); holder.itemView.setBackgroundColor(mReadPostCardViewBackgroundColor);
@ -1153,13 +1157,12 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
((PostCompactBaseViewHolder) holder).noPreviewPostImageFrameLayout.setVisibility(View.VISIBLE); ((PostCompactBaseViewHolder) holder).noPreviewPostImageFrameLayout.setVisibility(View.VISIBLE);
((PostCompactBaseViewHolder) holder).noPreviewPostImageView.setImageResource(R.drawable.ic_gallery_24dp); ((PostCompactBaseViewHolder) holder).noPreviewPostImageView.setImageResource(R.drawable.ic_gallery_24dp);
} }
ArrayList<Post.Preview> previews = post.getPreviews(); if (post.getPreviews() != null && !post.getPreviews().isEmpty()) {
if (previews != null && !previews.isEmpty()) {
if (post.getPostType() != Post.GIF_TYPE && post.getPostType() != Post.VIDEO_TYPE) { if (post.getPostType() != Post.GIF_TYPE && post.getPostType() != Post.VIDEO_TYPE) {
((PostCompactBaseViewHolder) holder).imageView.setVisibility(View.VISIBLE); ((PostCompactBaseViewHolder) holder).imageView.setVisibility(View.VISIBLE);
((PostCompactBaseViewHolder) holder).progressBar.setVisibility(View.VISIBLE); ((PostCompactBaseViewHolder) holder).progressBar.setVisibility(View.VISIBLE);
} }
loadImage(holder, post, previews.get(0)); loadImage(holder);
} }
} }
@ -1269,6 +1272,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
} else if (holder instanceof PostGalleryViewHolder) { } else if (holder instanceof PostGalleryViewHolder) {
Post post = getItem(position); Post post = getItem(position);
if (post != null) { if (post != null) {
((PostGalleryViewHolder) holder).post = post;
((PostGalleryViewHolder) holder).currentPosition = position; ((PostGalleryViewHolder) holder).currentPosition = position;
if (post.isRead()) { if (post.isRead()) {
holder.itemView.setBackgroundTintList(ColorStateList.valueOf(mReadPostCardViewBackgroundColor)); holder.itemView.setBackgroundTintList(ColorStateList.valueOf(mReadPostCardViewBackgroundColor));
@ -1281,6 +1285,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
((PostGalleryViewHolder) holder).progressBar.setVisibility(View.VISIBLE); ((PostGalleryViewHolder) holder).progressBar.setVisibility(View.VISIBLE);
Post.Preview preview = getSuitablePreview(post.getPreviews()); Post.Preview preview = getSuitablePreview(post.getPreviews());
((PostGalleryViewHolder) holder).preview = preview;
if (preview != null) { if (preview != null) {
if (preview.getPreviewWidth() <= 0 || preview.getPreviewHeight() <= 0) { if (preview.getPreviewWidth() <= 0 || preview.getPreviewHeight() <= 0) {
int height = (int) (400 * mScale); int height = (int) (400 * mScale);
@ -1292,7 +1297,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
((PostGalleryViewHolder) holder).imageView ((PostGalleryViewHolder) holder).imageView
.setRatio((float) preview.getPreviewHeight() / preview.getPreviewWidth()); .setRatio((float) preview.getPreviewHeight() / preview.getPreviewWidth());
} }
loadImage(holder, post, preview); loadImage(holder);
} else { } else {
((PostGalleryViewHolder) holder).noPreviewImageView.setVisibility(View.VISIBLE); ((PostGalleryViewHolder) holder).noPreviewImageView.setVisibility(View.VISIBLE);
if (post.getPostType() == Post.VIDEO_TYPE) { if (post.getPostType() == Post.VIDEO_TYPE) {
@ -1316,6 +1321,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
((PostGalleryViewHolder) holder).videoOrGifIndicatorImageView.setImageDrawable(ContextCompat.getDrawable(mActivity, R.drawable.ic_play_circle_36dp)); ((PostGalleryViewHolder) holder).videoOrGifIndicatorImageView.setImageDrawable(ContextCompat.getDrawable(mActivity, R.drawable.ic_play_circle_36dp));
Post.Preview preview = getSuitablePreview(post.getPreviews()); Post.Preview preview = getSuitablePreview(post.getPreviews());
((PostGalleryViewHolder) holder).preview = preview;
if (preview != null) { if (preview != null) {
if (preview.getPreviewWidth() <= 0 || preview.getPreviewHeight() <= 0) { if (preview.getPreviewWidth() <= 0 || preview.getPreviewHeight() <= 0) {
int height = (int) (400 * mScale); int height = (int) (400 * mScale);
@ -1327,7 +1333,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
((PostGalleryViewHolder) holder).imageView ((PostGalleryViewHolder) holder).imageView
.setRatio((float) preview.getPreviewHeight() / preview.getPreviewWidth()); .setRatio((float) preview.getPreviewHeight() / preview.getPreviewWidth());
} }
loadImage(holder, post, preview); loadImage(holder);
} else { } else {
((PostGalleryViewHolder) holder).noPreviewImageView.setVisibility(View.VISIBLE); ((PostGalleryViewHolder) holder).noPreviewImageView.setVisibility(View.VISIBLE);
((PostGalleryViewHolder) holder).noPreviewImageView.setImageResource(R.drawable.ic_image_24dp); ((PostGalleryViewHolder) holder).noPreviewImageView.setImageResource(R.drawable.ic_image_24dp);
@ -1341,6 +1347,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
((PostGalleryViewHolder) holder).videoOrGifIndicatorImageView.setImageDrawable(ContextCompat.getDrawable(mActivity, R.drawable.ic_play_circle_36dp)); ((PostGalleryViewHolder) holder).videoOrGifIndicatorImageView.setImageDrawable(ContextCompat.getDrawable(mActivity, R.drawable.ic_play_circle_36dp));
Post.Preview preview = getSuitablePreview(post.getPreviews()); Post.Preview preview = getSuitablePreview(post.getPreviews());
((PostGalleryViewHolder) holder).preview = preview;
if (preview != null) { if (preview != null) {
if (preview.getPreviewWidth() <= 0 || preview.getPreviewHeight() <= 0) { if (preview.getPreviewWidth() <= 0 || preview.getPreviewHeight() <= 0) {
int height = (int) (400 * mScale); int height = (int) (400 * mScale);
@ -1352,7 +1359,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
((PostGalleryViewHolder) holder).imageView ((PostGalleryViewHolder) holder).imageView
.setRatio((float) preview.getPreviewHeight() / preview.getPreviewWidth()); .setRatio((float) preview.getPreviewHeight() / preview.getPreviewWidth());
} }
loadImage(holder, post, preview); loadImage(holder);
} else { } else {
((PostGalleryViewHolder) holder).noPreviewImageView.setVisibility(View.VISIBLE); ((PostGalleryViewHolder) holder).noPreviewImageView.setVisibility(View.VISIBLE);
((PostGalleryViewHolder) holder).noPreviewImageView.setImageResource(R.drawable.ic_outline_video_24dp); ((PostGalleryViewHolder) holder).noPreviewImageView.setImageResource(R.drawable.ic_outline_video_24dp);
@ -1366,6 +1373,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
((PostGalleryViewHolder) holder).videoOrGifIndicatorImageView.setImageDrawable(ContextCompat.getDrawable(mActivity, R.drawable.ic_link_post_type_indicator)); ((PostGalleryViewHolder) holder).videoOrGifIndicatorImageView.setImageDrawable(ContextCompat.getDrawable(mActivity, R.drawable.ic_link_post_type_indicator));
Post.Preview preview = getSuitablePreview(post.getPreviews()); Post.Preview preview = getSuitablePreview(post.getPreviews());
((PostGalleryViewHolder) holder).preview = preview;
if (preview != null) { if (preview != null) {
if (preview.getPreviewWidth() <= 0 || preview.getPreviewHeight() <= 0) { if (preview.getPreviewWidth() <= 0 || preview.getPreviewHeight() <= 0) {
int height = (int) (400 * mScale); int height = (int) (400 * mScale);
@ -1377,7 +1385,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
((PostGalleryViewHolder) holder).imageView ((PostGalleryViewHolder) holder).imageView
.setRatio((float) preview.getPreviewHeight() / preview.getPreviewWidth()); .setRatio((float) preview.getPreviewHeight() / preview.getPreviewWidth());
} }
loadImage(holder, post, preview); loadImage(holder);
} else { } else {
((PostGalleryViewHolder) holder).noPreviewImageView.setVisibility(View.VISIBLE); ((PostGalleryViewHolder) holder).noPreviewImageView.setVisibility(View.VISIBLE);
((PostGalleryViewHolder) holder).noPreviewImageView.setImageResource(R.drawable.ic_link); ((PostGalleryViewHolder) holder).noPreviewImageView.setImageResource(R.drawable.ic_link);
@ -1401,6 +1409,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
((PostGalleryViewHolder) holder).videoOrGifIndicatorImageView.setImageDrawable(ContextCompat.getDrawable(mActivity, R.drawable.ic_gallery_24dp)); ((PostGalleryViewHolder) holder).videoOrGifIndicatorImageView.setImageDrawable(ContextCompat.getDrawable(mActivity, R.drawable.ic_gallery_24dp));
Post.Preview preview = getSuitablePreview(post.getPreviews()); Post.Preview preview = getSuitablePreview(post.getPreviews());
((PostGalleryViewHolder) holder).preview = preview;
if (preview != null) { if (preview != null) {
if (preview.getPreviewWidth() <= 0 || preview.getPreviewHeight() <= 0) { if (preview.getPreviewWidth() <= 0 || preview.getPreviewHeight() <= 0) {
int height = (int) (400 * mScale); int height = (int) (400 * mScale);
@ -1412,7 +1421,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
((PostGalleryViewHolder) holder).imageView ((PostGalleryViewHolder) holder).imageView
.setRatio((float) preview.getPreviewHeight() / preview.getPreviewWidth()); .setRatio((float) preview.getPreviewHeight() / preview.getPreviewWidth());
} }
loadImage(holder, post, preview); loadImage(holder);
} else { } else {
((PostGalleryViewHolder) holder).noPreviewImageView.setVisibility(View.VISIBLE); ((PostGalleryViewHolder) holder).noPreviewImageView.setVisibility(View.VISIBLE);
((PostGalleryViewHolder) holder).noPreviewImageView.setImageResource(R.drawable.ic_gallery_24dp); ((PostGalleryViewHolder) holder).noPreviewImageView.setImageResource(R.drawable.ic_gallery_24dp);
@ -1465,8 +1474,11 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
return null; return null;
} }
private void loadImage(final RecyclerView.ViewHolder holder, final Post post, @NonNull Post.Preview preview) { private void loadImage(final RecyclerView.ViewHolder holder) {
if (holder instanceof PostWithPreviewTypeViewHolder) { if (holder instanceof PostWithPreviewTypeViewHolder) {
Post post = ((PostWithPreviewTypeViewHolder) holder).post;
Post.Preview preview = ((PostWithPreviewTypeViewHolder) holder).preview;
if (preview != null) {
String url; String url;
boolean blurImage = (post.isNSFW() && mNeedBlurNsfw && !(mDoNotBlurNsfwInNsfwSubreddits && mFragment != null && mFragment.getIsNsfwSubreddit()) && !(post.getPostType() == Post.GIF_TYPE && mAutoplayNsfwVideos)) || post.isSpoiler() && mNeedBlurSpoiler; boolean blurImage = (post.isNSFW() && mNeedBlurNsfw && !(mDoNotBlurNsfwInNsfwSubreddits && mFragment != null && mFragment.getIsNsfwSubreddit()) && !(post.getPostType() == Post.GIF_TYPE && mAutoplayNsfwVideos)) || post.isSpoiler() && mNeedBlurSpoiler;
if (post.getPostType() == Post.GIF_TYPE && mAutoplay && !blurImage) { if (post.getPostType() == Post.GIF_TYPE && mAutoplay && !blurImage) {
@ -1474,26 +1486,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
} else { } else {
url = preview.getPreviewUrl(); url = preview.getPreviewUrl();
} }
RequestBuilder<Drawable> imageRequestBuilder = mGlide.load(url).listener(new RequestListener<Drawable>() { RequestBuilder<Drawable> imageRequestBuilder = mGlide.load(url).listener(((PostWithPreviewTypeViewHolder) holder).glideRequestListener);
@Override
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
((PostWithPreviewTypeViewHolder) holder).progressBar.setVisibility(View.GONE);
((PostWithPreviewTypeViewHolder) holder).errorRelativeLayout.setVisibility(View.VISIBLE);
((PostWithPreviewTypeViewHolder) holder).errorRelativeLayout.setOnClickListener(view -> {
((PostWithPreviewTypeViewHolder) holder).progressBar.setVisibility(View.VISIBLE);
((PostWithPreviewTypeViewHolder) holder).errorRelativeLayout.setVisibility(View.GONE);
loadImage(holder, post, preview);
});
return false;
}
@Override
public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
((PostWithPreviewTypeViewHolder) holder).errorRelativeLayout.setVisibility(View.GONE);
((PostWithPreviewTypeViewHolder) holder).progressBar.setVisibility(View.GONE);
return false;
}
});
if (blurImage) { if (blurImage) {
imageRequestBuilder.apply(RequestOptions.bitmapTransform(new BlurTransformation(50, 10))) imageRequestBuilder.apply(RequestOptions.bitmapTransform(new BlurTransformation(50, 10)))
@ -1505,30 +1498,20 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
imageRequestBuilder.into(((PostWithPreviewTypeViewHolder) holder).imageView); imageRequestBuilder.into(((PostWithPreviewTypeViewHolder) holder).imageView);
} }
} }
}
} else if (holder instanceof PostCompactBaseViewHolder) { } else if (holder instanceof PostCompactBaseViewHolder) {
Post post = ((PostCompactBaseViewHolder) holder).post;
String postCompactThumbnailPreviewUrl; String postCompactThumbnailPreviewUrl;
ArrayList<Post.Preview> previews = post.getPreviews(); ArrayList<Post.Preview> previews = post.getPreviews();
if (previews != null && !previews.isEmpty()) { if (previews != null && !previews.isEmpty()) {
if (previews.size() >= 2) { if (previews.size() >= 2) {
postCompactThumbnailPreviewUrl = previews.get(1).getPreviewUrl(); postCompactThumbnailPreviewUrl = previews.get(1).getPreviewUrl();
} else { } else {
postCompactThumbnailPreviewUrl = preview.getPreviewUrl(); postCompactThumbnailPreviewUrl = previews.get(0).getPreviewUrl();
} }
RequestBuilder<Drawable> imageRequestBuilder = mGlide.load(postCompactThumbnailPreviewUrl) RequestBuilder<Drawable> imageRequestBuilder = mGlide.load(postCompactThumbnailPreviewUrl)
.error(R.drawable.ic_error_outline_black_24dp).listener(new RequestListener<Drawable>() { .error(R.drawable.ic_error_outline_black_24dp).listener(((PostCompactBaseViewHolder) holder).requestListener);
@Override
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
((PostCompactBaseViewHolder) holder).progressBar.setVisibility(View.GONE);
return false;
}
@Override
public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
((PostCompactBaseViewHolder) holder).progressBar.setVisibility(View.GONE);
return false;
}
});
if ((post.isNSFW() && mNeedBlurNsfw && !(mDoNotBlurNsfwInNsfwSubreddits && mFragment != null && mFragment.getIsNsfwSubreddit())) || post.isSpoiler() && mNeedBlurSpoiler) { if ((post.isNSFW() && mNeedBlurNsfw && !(mDoNotBlurNsfwInNsfwSubreddits && mFragment != null && mFragment.getIsNsfwSubreddit())) || post.isSpoiler() && mNeedBlurSpoiler) {
imageRequestBuilder imageRequestBuilder
.transform(new BlurTransformation(50, 2)).into(((PostCompactBaseViewHolder) holder).imageView); .transform(new BlurTransformation(50, 2)).into(((PostCompactBaseViewHolder) holder).imageView);
@ -1537,6 +1520,9 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
} }
} }
} else if (holder instanceof PostGalleryViewHolder) { } else if (holder instanceof PostGalleryViewHolder) {
Post post = ((PostGalleryViewHolder) holder).post;
Post.Preview preview = ((PostGalleryViewHolder) holder).preview;
if (preview != null) {
String url; String url;
boolean blurImage = (post.isNSFW() && mNeedBlurNsfw && !(mDoNotBlurNsfwInNsfwSubreddits && mFragment != null && mFragment.getIsNsfwSubreddit()) && !(post.getPostType() == Post.GIF_TYPE && mAutoplayNsfwVideos)) || post.isSpoiler() && mNeedBlurSpoiler; boolean blurImage = (post.isNSFW() && mNeedBlurNsfw && !(mDoNotBlurNsfwInNsfwSubreddits && mFragment != null && mFragment.getIsNsfwSubreddit()) && !(post.getPostType() == Post.GIF_TYPE && mAutoplayNsfwVideos)) || post.isSpoiler() && mNeedBlurSpoiler;
if (post.getPostType() == Post.GIF_TYPE && mAutoplay && !blurImage) { if (post.getPostType() == Post.GIF_TYPE && mAutoplay && !blurImage) {
@ -1544,26 +1530,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
} else { } else {
url = preview.getPreviewUrl(); url = preview.getPreviewUrl();
} }
RequestBuilder<Drawable> imageRequestBuilder = mGlide.load(url).listener(new RequestListener<Drawable>() { RequestBuilder<Drawable> imageRequestBuilder = mGlide.load(url).listener(((PostGalleryViewHolder) holder).requestListener);
@Override
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
((PostGalleryViewHolder) holder).progressBar.setVisibility(View.GONE);
((PostGalleryViewHolder) holder).errorRelativeLayout.setVisibility(View.VISIBLE);
((PostGalleryViewHolder) holder).errorRelativeLayout.setOnClickListener(view -> {
((PostGalleryViewHolder) holder).progressBar.setVisibility(View.VISIBLE);
((PostGalleryViewHolder) holder).errorRelativeLayout.setVisibility(View.GONE);
loadImage(holder, post, preview);
});
return false;
}
@Override
public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
((PostGalleryViewHolder) holder).errorRelativeLayout.setVisibility(View.GONE);
((PostGalleryViewHolder) holder).progressBar.setVisibility(View.GONE);
return false;
}
});
if (blurImage) { if (blurImage) {
imageRequestBuilder.apply(RequestOptions.bitmapTransform(new BlurTransformation(50, 10))) imageRequestBuilder.apply(RequestOptions.bitmapTransform(new BlurTransformation(50, 10)))
@ -1575,7 +1542,11 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
imageRequestBuilder.into(((PostGalleryViewHolder) holder).imageView); imageRequestBuilder.into(((PostGalleryViewHolder) holder).imageView);
} }
} }
}
} else if (holder instanceof PostCard2WithPreviewViewHolder) { } else if (holder instanceof PostCard2WithPreviewViewHolder) {
Post post = ((PostCard2WithPreviewViewHolder) holder).post;
Post.Preview preview = ((PostCard2WithPreviewViewHolder) holder).preview;
if (preview != null) {
String url; String url;
boolean blurImage = (post.isNSFW() && mNeedBlurNsfw && !(mDoNotBlurNsfwInNsfwSubreddits && mFragment != null && mFragment.getIsNsfwSubreddit()) && !(post.getPostType() == Post.GIF_TYPE && mAutoplayNsfwVideos)) || post.isSpoiler() && mNeedBlurSpoiler; boolean blurImage = (post.isNSFW() && mNeedBlurNsfw && !(mDoNotBlurNsfwInNsfwSubreddits && mFragment != null && mFragment.getIsNsfwSubreddit()) && !(post.getPostType() == Post.GIF_TYPE && mAutoplayNsfwVideos)) || post.isSpoiler() && mNeedBlurSpoiler;
if (post.getPostType() == Post.GIF_TYPE && mAutoplay && !blurImage) { if (post.getPostType() == Post.GIF_TYPE && mAutoplay && !blurImage) {
@ -1583,26 +1554,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
} else { } else {
url = preview.getPreviewUrl(); url = preview.getPreviewUrl();
} }
RequestBuilder<Drawable> imageRequestBuilder = mGlide.load(url).listener(new RequestListener<Drawable>() { RequestBuilder<Drawable> imageRequestBuilder = mGlide.load(url).listener(((PostCard2WithPreviewViewHolder) holder).requestListener);
@Override
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
((PostCard2WithPreviewViewHolder) holder).progressBar.setVisibility(View.GONE);
((PostCard2WithPreviewViewHolder) holder).errorRelativeLayout.setVisibility(View.VISIBLE);
((PostCard2WithPreviewViewHolder) holder).errorRelativeLayout.setOnClickListener(view -> {
((PostCard2WithPreviewViewHolder) holder).progressBar.setVisibility(View.VISIBLE);
((PostCard2WithPreviewViewHolder) holder).errorRelativeLayout.setVisibility(View.GONE);
loadImage(holder, post, preview);
});
return false;
}
@Override
public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
((PostCard2WithPreviewViewHolder) holder).errorRelativeLayout.setVisibility(View.GONE);
((PostCard2WithPreviewViewHolder) holder).progressBar.setVisibility(View.GONE);
return false;
}
});
if (blurImage) { if (blurImage) {
imageRequestBuilder.apply(RequestOptions.bitmapTransform(new BlurTransformation(50, 10))) imageRequestBuilder.apply(RequestOptions.bitmapTransform(new BlurTransformation(50, 10)))
@ -1616,6 +1568,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
} }
} }
} }
}
private void shareLink(Post post) { private void shareLink(Post post) {
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
@ -1801,7 +1754,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
} else if (holder instanceof PostWithPreviewTypeViewHolder) { } else if (holder instanceof PostWithPreviewTypeViewHolder) {
mGlide.clear(((PostWithPreviewTypeViewHolder) holder).imageView); mGlide.clear(((PostWithPreviewTypeViewHolder) holder).imageView);
((PostWithPreviewTypeViewHolder) holder).imageWrapperRelativeLayout.setVisibility(View.GONE); ((PostWithPreviewTypeViewHolder) holder).imageWrapperRelativeLayout.setVisibility(View.GONE);
((PostWithPreviewTypeViewHolder) holder).errorRelativeLayout.setVisibility(View.GONE); ((PostWithPreviewTypeViewHolder) holder).errorTextView.setVisibility(View.GONE);
((PostWithPreviewTypeViewHolder) holder).noPreviewLinkImageView.setVisibility(View.GONE); ((PostWithPreviewTypeViewHolder) holder).noPreviewLinkImageView.setVisibility(View.GONE);
((PostWithPreviewTypeViewHolder) holder).progressBar.setVisibility(View.GONE); ((PostWithPreviewTypeViewHolder) holder).progressBar.setVisibility(View.GONE);
((PostWithPreviewTypeViewHolder) holder).videoOrGifIndicatorImageView.setVisibility(View.GONE); ((PostWithPreviewTypeViewHolder) holder).videoOrGifIndicatorImageView.setVisibility(View.GONE);
@ -2045,6 +1998,8 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
TextView commentsCountTextView; TextView commentsCountTextView;
ImageView saveButton; ImageView saveButton;
ImageView shareButton; ImageView shareButton;
Post post;
Post.Preview preview;
boolean itemViewIsNotCardView = false; boolean itemViewIsNotCardView = false;
int currentPosition; int currentPosition;
@ -2706,14 +2661,14 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
if (post.isGfycat()) { if (post.isGfycat()) {
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_GFYCAT); intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_GFYCAT);
intent.putExtra(ViewVideoActivity.EXTRA_GFYCAT_ID, post.getGfycatId()); intent.putExtra(ViewVideoActivity.EXTRA_GFYCAT_ID, post.getGfycatId());
if (post.isLoadGfyOrRedgifsVideoSuccess()) { if (post.isLoadGfycatOrRedgifsVideoSuccess()) {
intent.setData(Uri.parse(post.getVideoUrl())); intent.setData(Uri.parse(post.getVideoUrl()));
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_DOWNLOAD_URL, post.getVideoDownloadUrl()); intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_DOWNLOAD_URL, post.getVideoDownloadUrl());
} }
} else if (post.isRedgifs()) { } else if (post.isRedgifs()) {
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_REDGIFS); intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_REDGIFS);
intent.putExtra(ViewVideoActivity.EXTRA_GFYCAT_ID, post.getGfycatId()); intent.putExtra(ViewVideoActivity.EXTRA_GFYCAT_ID, post.getGfycatId());
if (post.isLoadGfyOrRedgifsVideoSuccess()) { if (post.isLoadGfycatOrRedgifsVideoSuccess()) {
intent.setData(Uri.parse(post.getVideoUrl())); intent.setData(Uri.parse(post.getVideoUrl()));
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_DOWNLOAD_URL, post.getVideoDownloadUrl()); intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_DOWNLOAD_URL, post.getVideoDownloadUrl());
} }
@ -2871,13 +2826,11 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
@BindView(R.id.video_or_gif_indicator_image_view_item_post_with_preview) @BindView(R.id.video_or_gif_indicator_image_view_item_post_with_preview)
ImageView videoOrGifIndicatorImageView; ImageView videoOrGifIndicatorImageView;
@BindView(R.id.image_wrapper_relative_layout_item_post_with_preview) @BindView(R.id.image_wrapper_relative_layout_item_post_with_preview)
RelativeLayout imageWrapperRelativeLayout; FrameLayout imageWrapperRelativeLayout;
@BindView(R.id.progress_bar_item_post_with_preview) @BindView(R.id.progress_bar_item_post_with_preview)
ProgressBar progressBar; ProgressBar progressBar;
@BindView(R.id.image_view_item_post_with_preview) @BindView(R.id.image_view_item_post_with_preview)
AspectRatioGifImageView imageView; AspectRatioGifImageView imageView;
@BindView(R.id.load_image_error_relative_layout_item_post_with_preview)
RelativeLayout errorRelativeLayout;
@BindView(R.id.load_image_error_text_view_item_post_with_preview) @BindView(R.id.load_image_error_text_view_item_post_with_preview)
TextView errorTextView; TextView errorTextView;
@BindView(R.id.image_view_no_preview_gallery_item_post_with_preview) @BindView(R.id.image_view_no_preview_gallery_item_post_with_preview)
@ -2896,6 +2849,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
ImageView saveButton; ImageView saveButton;
@BindView(R.id.share_button_item_post_with_preview) @BindView(R.id.share_button_item_post_with_preview)
ImageView shareButton; ImageView shareButton;
RequestListener<Drawable> glideRequestListener;
PostWithPreviewTypeViewHolder(View itemView) { PostWithPreviewTypeViewHolder(View itemView) {
super(itemView); super(itemView);
@ -2943,9 +2897,31 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
} }
}); });
errorTextView.setOnClickListener(view -> {
progressBar.setVisibility(View.VISIBLE);
errorTextView.setVisibility(View.GONE);
loadImage(this);
});
noPreviewLinkImageView.setOnClickListener(view -> { noPreviewLinkImageView.setOnClickListener(view -> {
imageView.performClick(); imageView.performClick();
}); });
glideRequestListener = new RequestListener<>() {
@Override
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
progressBar.setVisibility(View.GONE);
errorTextView.setVisibility(View.VISIBLE);
return false;
}
@Override
public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
errorTextView.setVisibility(View.GONE);
progressBar.setVisibility(View.GONE);
return false;
}
};
} }
} }
@ -3056,6 +3032,8 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
ImageView saveButton; ImageView saveButton;
ImageView shareButton; ImageView shareButton;
View divider; View divider;
RequestListener<Drawable> requestListener;
Post post;
int currentPosition; int currentPosition;
@ -3552,6 +3530,20 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
shareLink(post); shareLink(post);
} }
}); });
requestListener = new RequestListener<>() {
@Override
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
progressBar.setVisibility(View.GONE);
return false;
}
@Override
public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
progressBar.setVisibility(View.GONE);
return false;
}
};
} }
void markPostRead(Post post, boolean changePostItemColor) { void markPostRead(Post post, boolean changePostItemColor) {
@ -3736,6 +3728,9 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
ImageView noPreviewImageView; ImageView noPreviewImageView;
@BindView(R.id.title_text_view_item_post_gallery) @BindView(R.id.title_text_view_item_post_gallery)
TextView titleTextView; TextView titleTextView;
RequestListener<Drawable> requestListener;
Post post;
Post.Preview preview;
int currentPosition; int currentPosition;
@ -3788,9 +3783,31 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
return true; return true;
}); });
errorRelativeLayout.setOnClickListener(view -> {
progressBar.setVisibility(View.VISIBLE);
errorRelativeLayout.setVisibility(View.GONE);
loadImage(this);
});
noPreviewImageView.setOnClickListener(view -> { noPreviewImageView.setOnClickListener(view -> {
itemView.performClick(); itemView.performClick();
}); });
requestListener = new RequestListener<>() {
@Override
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
progressBar.setVisibility(View.GONE);
errorRelativeLayout.setVisibility(View.VISIBLE);
return false;
}
@Override
public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
errorRelativeLayout.setVisibility(View.GONE);
progressBar.setVisibility(View.GONE);
return false;
}
};
} }
void markPostRead(Post post, boolean changePostItemColor) { void markPostRead(Post post, boolean changePostItemColor) {
@ -3931,14 +3948,14 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
if (post.isGfycat()) { if (post.isGfycat()) {
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_GFYCAT); intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_GFYCAT);
intent.putExtra(ViewVideoActivity.EXTRA_GFYCAT_ID, post.getGfycatId()); intent.putExtra(ViewVideoActivity.EXTRA_GFYCAT_ID, post.getGfycatId());
if (post.isLoadGfyOrRedgifsVideoSuccess()) { if (post.isLoadGfycatOrRedgifsVideoSuccess()) {
intent.setData(Uri.parse(post.getVideoUrl())); intent.setData(Uri.parse(post.getVideoUrl()));
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_DOWNLOAD_URL, post.getVideoDownloadUrl()); intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_DOWNLOAD_URL, post.getVideoDownloadUrl());
} }
} else if (post.isRedgifs()) { } else if (post.isRedgifs()) {
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_REDGIFS); intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_REDGIFS);
intent.putExtra(ViewVideoActivity.EXTRA_GFYCAT_ID, post.getGfycatId()); intent.putExtra(ViewVideoActivity.EXTRA_GFYCAT_ID, post.getGfycatId());
if (post.isLoadGfyOrRedgifsVideoSuccess()) { if (post.isLoadGfycatOrRedgifsVideoSuccess()) {
intent.setData(Uri.parse(post.getVideoUrl())); intent.setData(Uri.parse(post.getVideoUrl()));
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_DOWNLOAD_URL, post.getVideoDownloadUrl()); intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_DOWNLOAD_URL, post.getVideoDownloadUrl());
} }
@ -4121,6 +4138,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
ImageView shareButton; ImageView shareButton;
@BindView(R.id.divider_item_post_card_2_with_preview) @BindView(R.id.divider_item_post_card_2_with_preview)
View divider; View divider;
RequestListener<Drawable> requestListener;
PostCard2WithPreviewViewHolder(@NonNull View itemView) { PostCard2WithPreviewViewHolder(@NonNull View itemView) {
super(itemView); super(itemView);
@ -4170,9 +4188,31 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
} }
}); });
errorRelativeLayout.setOnClickListener(view -> {
progressBar.setVisibility(View.VISIBLE);
errorRelativeLayout.setVisibility(View.GONE);
loadImage(this);
});
noPreviewImageView.setOnClickListener(view -> { noPreviewImageView.setOnClickListener(view -> {
imageView.performClick(); imageView.performClick();
}); });
requestListener = new RequestListener<>() {
@Override
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
progressBar.setVisibility(View.GONE);
errorRelativeLayout.setVisibility(View.VISIBLE);
return false;
}
@Override
public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
errorRelativeLayout.setVisibility(View.GONE);
progressBar.setVisibility(View.GONE);
return false;
}
};
} }
} }

View File

@ -337,7 +337,7 @@ public class Post implements Parcelable {
this.isRedgifs = isRedgifs; this.isRedgifs = isRedgifs;
} }
public boolean isLoadGfyOrRedgifsVideoSuccess() { public boolean isLoadGfycatOrRedgifsVideoSuccess() {
return loadGfyOrRedgifsVideoSuccess; return loadGfyOrRedgifsVideoSuccess;
} }

View File

@ -140,7 +140,7 @@
</RelativeLayout> </RelativeLayout>
<androidx.appcompat.widget.Toolbar <com.google.android.material.appbar.MaterialToolbar
android:id="@+id/toolbar" android:id="@+id/toolbar"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"

View File

@ -107,7 +107,7 @@
</RelativeLayout> </RelativeLayout>
<androidx.appcompat.widget.Toolbar <com.google.android.material.appbar.MaterialToolbar
android:id="@+id/toolbar_view_user_detail_activity" android:id="@+id/toolbar_view_user_detail_activity"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"

View File

@ -6,6 +6,7 @@
android:id="@+id/hauler_view_view_video_activity" android:id="@+id/hauler_view_view_video_activity"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="#000000"
android:keepScreenOn="true" android:keepScreenOn="true"
app:dragUpEnabled="true" app:dragUpEnabled="true"
tools:application="ml.docilealligator.infinityforreddit.activities.ViewVideoActivity"> tools:application="ml.docilealligator.infinityforreddit.activities.ViewVideoActivity">

View File

@ -21,7 +21,7 @@
app:titleEnabled="false" app:titleEnabled="false"
app:toolbarId="@+id/toolbar"> app:toolbarId="@+id/toolbar">
<androidx.appcompat.widget.Toolbar <com.google.android.material.appbar.MaterialToolbar
android:id="@+id/toolbar" android:id="@+id/toolbar"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"

View File

@ -206,7 +206,7 @@
android:fontFamily="?attr/font_family" android:fontFamily="?attr/font_family"
android:visibility="gone" /> android:visibility="gone" />
<RelativeLayout <FrameLayout
android:id="@+id/image_wrapper_relative_layout_item_post_with_preview" android:id="@+id/image_wrapper_relative_layout_item_post_with_preview"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
@ -224,7 +224,6 @@
android:layout_width="36dp" android:layout_width="36dp"
android:layout_height="36dp" android:layout_height="36dp"
android:layout_margin="16dp" android:layout_margin="16dp"
android:layout_gravity="start"
android:scaleType="center" android:scaleType="center"
android:background="@drawable/play_button_round_background" android:background="@drawable/play_button_round_background"
android:visibility="gone" /> android:visibility="gone" />
@ -233,14 +232,7 @@
android:id="@+id/progress_bar_item_post_with_preview" android:id="@+id/progress_bar_item_post_with_preview"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_centerInParent="true" /> android:layout_gravity="center" />
<RelativeLayout
android:id="@+id/load_image_error_relative_layout_item_post_with_preview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:visibility="gone">
<TextView <TextView
android:id="@+id/load_image_error_text_view_item_post_with_preview" android:id="@+id/load_image_error_text_view_item_post_with_preview"
@ -253,9 +245,7 @@
android:textSize="?attr/font_default" android:textSize="?attr/font_default"
android:fontFamily="?attr/font_family" /> android:fontFamily="?attr/font_family" />
</RelativeLayout> </FrameLayout>
</RelativeLayout>
<ImageView <ImageView
android:id="@+id/image_view_no_preview_gallery_item_post_with_preview" android:id="@+id/image_view_no_preview_gallery_item_post_with_preview"

View File

@ -1,6 +1,6 @@
<resources> <resources>
<style name="AppTheme" parent="Theme.MaterialComponents.DayNight"> <style name="AppTheme" parent="Theme.Material3.DayNight">
<item name="colorPrimary">@color/colorPrimary</item> <item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item> <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item> <item name="colorAccent">@color/colorAccent</item>

View File

@ -1,7 +1,7 @@
<resources> <resources>
<!-- Base application theme. --> <!-- Base application theme. -->
<style name="AppTheme" parent="Theme.MaterialComponents.DayNight"> <style name="AppTheme" parent="Theme.Material3.DayNight">
<item name="colorPrimary">@color/colorPrimary</item> <item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item> <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item> <item name="colorAccent">@color/colorAccent</item>

View File

@ -1,7 +1,7 @@
<resources xmlns:tools="http://schemas.android.com/tools"> <resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. --> <!-- Base application theme. -->
<style name="AppTheme" parent="Theme.MaterialComponents.DayNight"> <style name="AppTheme" parent="Theme.Material3.DayNight">
<item name="colorPrimary">?attr/colorPrimary</item> <item name="colorPrimary">?attr/colorPrimary</item>
<item name="colorPrimaryDark">?attr/colorPrimaryDark</item> <item name="colorPrimaryDark">?attr/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item> <item name="colorAccent">@color/colorAccent</item>
@ -58,7 +58,7 @@
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.DayNight" /> <style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.DayNight" />
<style name="MaterialAlertDialogTheme" parent="ThemeOverlay.MaterialComponents.MaterialAlertDialog"> <style name="MaterialAlertDialogTheme" parent="ThemeOverlay.Material3.MaterialAlertDialog">
<item name="android:textSize">?attr/font_default</item> <item name="android:textSize">?attr/font_default</item>
<item name="android:background">?attr/cardViewBackgroundColor</item> <item name="android:background">?attr/cardViewBackgroundColor</item>
<item name="materialAlertDialogTitleTextStyle">@style/MaterialAlertDialogTitleTextStyle <item name="materialAlertDialogTitleTextStyle">@style/MaterialAlertDialogTitleTextStyle
@ -78,15 +78,15 @@
</item> </item>
</style> </style>
<style name="MaterialAlertDialogPositiveButtonStyle" parent="Widget.MaterialComponents.Button.TextButton.Dialog"> <style name="MaterialAlertDialogPositiveButtonStyle" parent="Widget.Material3.Button.TextButton.Dialog">
<item name="android:textColor">@color/colorAccent</item> <item name="android:textColor">@color/colorAccent</item>
</style> </style>
<style name="MaterialAlertDialogNegativeButtonStyle" parent="Widget.MaterialComponents.Button.TextButton.Dialog"> <style name="MaterialAlertDialogNegativeButtonStyle" parent="Widget.Material3.Button.TextButton.Dialog">
<item name="android:textColor">?attr/primaryTextColor</item> <item name="android:textColor">?attr/primaryTextColor</item>
</style> </style>
<style name="MaterialAlertDialogTitleTextStyle" parent="MaterialAlertDialog.MaterialComponents.Title.Text"> <style name="MaterialAlertDialogTitleTextStyle" parent="MaterialAlertDialog.Material3.Title.Text">
<item name="android:textSize">?attr/font_20</item> <item name="android:textSize">?attr/font_20</item>
</style> </style>