aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/src/main/AndroidManifest.xml6
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/LinkResolverActivity.java5
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewImageActivity.java5
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewImgurMediaActivity.java22
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewSidebarActivity.java251
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewSubredditDetailActivity.java48
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java18
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java16
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/AppComponent.java3
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/CommentData.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/SidebarFragment.java5
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/ViewImgurImageFragment.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Service/DownloadRedditVideoService.java9
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Utils/GlideImageGetter.java6
-rw-r--r--app/src/main/res/layout/activity_view_image.xml2
-rw-r--r--app/src/main/res/layout/activity_view_sidebar.xml50
-rw-r--r--app/src/main/res/layout/fragment_view_imgur_images.xml6
-rw-r--r--app/src/main/res/menu/view_sidebar_activity.xml10
-rw-r--r--app/src/main/res/menu/view_subreddit_detail_activity.xml8
19 files changed, 85 insertions, 389 deletions
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index ff60bc3f..974c81b6 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -75,10 +75,6 @@
android:theme="@style/AppTheme.NoActionBar"
android:windowSoftInputMode="adjustResize" />
<activity
- android:name=".Activity.ViewSidebarActivity"
- android:parentActivityName=".Activity.MainActivity"
- android:theme="@style/AppTheme.NoActionBar" />
- <activity
android:name=".Activity.ViewMultiRedditDetailActivity"
android:parentActivityName=".Activity.MainActivity"
android:theme="@style/AppTheme.NoActionBar" />
@@ -331,4 +327,4 @@
android:exported="false" />
</application>
-</manifest> \ No newline at end of file
+</manifest>
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/LinkResolverActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/LinkResolverActivity.java
index 0b7cf47f..1ea32f2b 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/LinkResolverActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/LinkResolverActivity.java
@@ -159,8 +159,9 @@ public class LinkResolverActivity extends AppCompatActivity {
intent.putExtra(ViewUserDetailActivity.EXTRA_NEW_ACCOUNT_NAME, newAccountName);
startActivity(intent);
} else if (path.matches(SIDEBAR_PATTERN)) {
- Intent intent = new Intent(this, ViewSidebarActivity.class);
- intent.putExtra(ViewSidebarActivity.EXTRA_SUBREDDIT_NAME, path.substring(3, path.length() - 14));
+ Intent intent = new Intent(this, ViewSubredditDetailActivity.class);
+ intent.putExtra(ViewSubredditDetailActivity.EXTRA_SUBREDDIT_NAME_KEY, path.substring(3, path.length() - 14));
+ intent.putExtra(ViewSubredditDetailActivity.EXTRA_VIEW_SIDEBAR, true);
startActivity(intent);
} else if (path.matches(MULTIREDDIT_PATTERN)) {
Intent intent = new Intent(this, ViewMultiRedditDetailActivity.class);
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewImageActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewImageActivity.java
index 0dacbb43..670a89d9 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewImageActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewImageActivity.java
@@ -90,7 +90,6 @@ public class ViewImageActivity extends AppCompatActivity implements SetAsWallpap
private String mImageUrl;
private String mImageFileName;
private RequestManager glide;
- private String postTitle;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -132,7 +131,7 @@ public class ViewImageActivity extends AppCompatActivity implements SetAsWallpap
Intent intent = getIntent();
mImageUrl = intent.getStringExtra(IMAGE_URL_KEY);
mImageFileName = intent.getStringExtra(FILE_NAME_KEY);
- postTitle = intent.getStringExtra(POST_TITLE_KEY);
+ String postTitle = intent.getStringExtra(POST_TITLE_KEY);
if (postTitle != null) {
setTitle(Html.fromHtml(String.format("<small>%s</small>", postTitle)));
@@ -190,7 +189,7 @@ public class ViewImageActivity extends AppCompatActivity implements SetAsWallpap
mProgressBar.setVisibility(View.GONE);
return false;
}
- }).into(mImageView);
+ }).override(Target.SIZE_ORIGINAL).into(mImageView);
}
@Override
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewImgurMediaActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewImgurMediaActivity.java
index bae1fdf3..e5fba668 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewImgurMediaActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewImgurMediaActivity.java
@@ -292,10 +292,12 @@ public class ViewImgurMediaActivity extends AppCompatActivity implements SetAsWa
}
private void setToolbarTitle(int position) {
- if (images.get(position).getType() == ImgurMedia.TYPE_VIDEO) {
- setTitle(getString(R.string.view_imgur_media_activity_video_label, position + 1, images.size()));
- } else {
- setTitle(getString(R.string.view_imgur_media_activity_image_label, position + 1, images.size()));
+ if (images != null && position >= 0 && position < images.size()) {
+ if (images.get(position).getType() == ImgurMedia.TYPE_VIDEO) {
+ setTitle(getString(R.string.view_imgur_media_activity_video_label, position + 1, images.size()));
+ } else {
+ setTitle(getString(R.string.view_imgur_media_activity_image_label, position + 1, images.size()));
+ }
}
}
@@ -387,17 +389,23 @@ public class ViewImgurMediaActivity extends AppCompatActivity implements SetAsWa
@Override
public void setToHomeScreen(int viewPagerPosition) {
- setAsWallpaper(images.get(viewPagerPosition).getLink(), 0);
+ if (images != null && viewPagerPosition >= 0 && viewPagerPosition < images.size()) {
+ setAsWallpaper(images.get(viewPagerPosition).getLink(), 0);
+ }
}
@Override
public void setToLockScreen(int viewPagerPosition) {
- setAsWallpaper(images.get(viewPagerPosition).getLink(), 1);
+ if (images != null && viewPagerPosition >= 0 && viewPagerPosition < images.size()) {
+ setAsWallpaper(images.get(viewPagerPosition).getLink(), 1);
+ }
}
@Override
public void setToBoth(int viewPagerPosition) {
- setAsWallpaper(images.get(viewPagerPosition).getLink(), 2);
+ if (images != null && viewPagerPosition >= 0 && viewPagerPosition < images.size()) {
+ setAsWallpaper(images.get(viewPagerPosition).getLink(), 2);
+ }
}
public int getCurrentPagePosition() {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewSidebarActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewSidebarActivity.java
deleted file mode 100644
index 826ba33d..00000000
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewSidebarActivity.java
+++ /dev/null
@@ -1,251 +0,0 @@
-package ml.docilealligator.infinityforreddit.Activity;
-
-import android.content.Intent;
-import android.content.SharedPreferences;
-import android.net.Uri;
-import android.os.Build;
-import android.os.Bundle;
-import android.text.Spanned;
-import android.text.style.SuperscriptSpan;
-import android.text.util.Linkify;
-import android.util.TypedValue;
-import android.view.Menu;
-import android.view.MenuItem;
-import android.view.Window;
-import android.view.WindowManager;
-import android.widget.TextView;
-import android.widget.Toast;
-
-import androidx.annotation.NonNull;
-import androidx.appcompat.widget.Toolbar;
-import androidx.coordinatorlayout.widget.CoordinatorLayout;
-import androidx.lifecycle.ViewModelProvider;
-import androidx.recyclerview.widget.LinearLayoutManager;
-import androidx.recyclerview.widget.RecyclerView;
-import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
-
-import com.google.android.material.appbar.AppBarLayout;
-
-import org.commonmark.ext.gfm.tables.TableBlock;
-
-import javax.inject.Inject;
-import javax.inject.Named;
-
-import butterknife.BindView;
-import butterknife.ButterKnife;
-import io.noties.markwon.AbstractMarkwonPlugin;
-import io.noties.markwon.Markwon;
-import io.noties.markwon.MarkwonConfiguration;
-import io.noties.markwon.ext.strikethrough.StrikethroughPlugin;
-import io.noties.markwon.linkify.LinkifyPlugin;
-import io.noties.markwon.recycler.MarkwonAdapter;
-import io.noties.markwon.recycler.table.TableEntry;
-import io.noties.markwon.recycler.table.TableEntryPlugin;
-import io.noties.markwon.simple.ext.SimpleExtPlugin;
-import io.noties.markwon.urlprocessor.UrlProcessorRelativeToAbsolute;
-import ml.docilealligator.infinityforreddit.ActivityToolbarInterface;
-import ml.docilealligator.infinityforreddit.AsyncTask.InsertSubredditDataAsyncTask;
-import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
-import ml.docilealligator.infinityforreddit.FetchSubredditData;
-import ml.docilealligator.infinityforreddit.Infinity;
-import ml.docilealligator.infinityforreddit.R;
-import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
-import ml.docilealligator.infinityforreddit.SubredditDatabase.SubredditData;
-import ml.docilealligator.infinityforreddit.SubredditDatabase.SubredditViewModel;
-import retrofit2.Retrofit;
-
-public class ViewSidebarActivity extends BaseActivity implements ActivityToolbarInterface {
-
- public static final String EXTRA_SUBREDDIT_NAME = "ESN";
- @BindView(R.id.coordinator_layout_view_sidebar_activity)
- CoordinatorLayout coordinatorLayout;
- @BindView(R.id.appbar_layout_view_sidebar_activity)
- AppBarLayout appBarLayout;
- @BindView(R.id.toolbar_view_sidebar_activity)
- Toolbar toolbar;
- @BindView(R.id.swipe_refresh_layout_view_sidebar_activity)
- SwipeRefreshLayout swipeRefreshLayout;
- @BindView(R.id.markdown_recycler_view_view_sidebar_activity)
- RecyclerView markdownRecyclerView;
- @Inject
- @Named("no_oauth")
- Retrofit mRetrofit;
- @Inject
- RedditDataRoomDatabase mRedditDataRoomDatabase;
- @Inject
- @Named("default")
- SharedPreferences mSharedPreferences;
- @Inject
- CustomThemeWrapper mCustomThemeWrapper;
- public SubredditViewModel mSubredditViewModel;
- private LinearLayoutManager mLinearLayoutManager;
- private String subredditName;
- private int markdownColor;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- ((Infinity) getApplication()).getAppComponent().inject(this);
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_view_sidebar);
-
- ButterKnife.bind(this);
-
- applyCustomTheme();
-
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
- Window window = getWindow();
-
- if (isChangeStatusBarIconColor()) {
- addOnOffsetChangedListener(appBarLayout);
- }
-
- if (isImmersiveInterface()) {
- window.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
- adjustToolbar(toolbar);
-
- int navBarHeight = getNavBarHeight();
- if (navBarHeight > 0) {
- int px = (int) TypedValue.applyDimension(
- TypedValue.COMPLEX_UNIT_DIP,
- 16,
- getResources().getDisplayMetrics()
- );
- markdownRecyclerView.setPadding(px, px, px, navBarHeight);
- }
- }
- }
-
- subredditName = getIntent().getStringExtra(EXTRA_SUBREDDIT_NAME);
- if (subredditName == null) {
- Toast.makeText(this, R.string.error_getting_subreddit_name, Toast.LENGTH_SHORT).show();
- finish();
- return;
- }
-
- toolbar.setTitle("r/" + subredditName);
- setSupportActionBar(toolbar);
- getSupportActionBar().setDisplayHomeAsUpEnabled(true);
- setToolbarGoToTop(toolbar);
-
- Markwon markwon = Markwon.builder(this)
- .usePlugin(new AbstractMarkwonPlugin() {
- @Override
- public void beforeSetText(@NonNull TextView textView, @NonNull Spanned markdown) {
- textView.setTextColor(markdownColor);
- }
-
- @Override
- public void configureConfiguration(@NonNull MarkwonConfiguration.Builder builder) {
- builder.linkResolver((view, link) -> {
- Intent intent = new Intent(ViewSidebarActivity.this, LinkResolverActivity.class);
- Uri uri = Uri.parse(link);
- if (uri.getScheme() == null && uri.getHost() == null) {
- intent.setData(LinkResolverActivity.getRedditUriByPath(link));
- } else {
- intent.setData(uri);
- }
- ViewSidebarActivity.this.startActivity(intent);
- }).urlProcessor(new UrlProcessorRelativeToAbsolute("https://www.reddit.com"));
- }
- })
- .usePlugin(StrikethroughPlugin.create())
- .usePlugin(LinkifyPlugin.create(Linkify.WEB_URLS))
- .usePlugin(SimpleExtPlugin.create(plugin ->
- plugin.addExtension(1, '^', (configuration, props) -> {
- return new SuperscriptSpan();
- })
- )
- )
- .usePlugin(TableEntryPlugin.create(this))
- .build();
- MarkwonAdapter markwonAdapter = MarkwonAdapter.builder(R.layout.adapter_default_entry, R.id.text)
- .include(TableBlock.class, TableEntry.create(builder -> builder
- .tableLayout(R.layout.adapter_table_block, R.id.table_layout)
- .textLayoutIsRoot(R.layout.view_table_entry_cell)))
- .build();
-
- mLinearLayoutManager = new LinearLayoutManager(this);
- markdownRecyclerView.setLayoutManager(mLinearLayoutManager);
- markdownRecyclerView.setAdapter(markwonAdapter);
-
- mSubredditViewModel = new ViewModelProvider(this,
- new SubredditViewModel.Factory(getApplication(), mRedditDataRoomDatabase, subredditName))
- .get(SubredditViewModel.class);
- mSubredditViewModel.getSubredditLiveData().observe(this, subredditData -> {
- if (subredditData != null) {
- if (subredditData.getSidebarDescription() != null && !subredditData.getSidebarDescription().equals("")) {
- markwonAdapter.setMarkdown(markwon, subredditData.getSidebarDescription());
- markwonAdapter.notifyDataSetChanged();
- }
- } else {
- fetchSubredditData();
- }
- });
-
- swipeRefreshLayout.setOnRefreshListener(this::fetchSubredditData);
- }
-
- private void fetchSubredditData() {
- swipeRefreshLayout.setRefreshing(true);
- FetchSubredditData.fetchSubredditData(mRetrofit, subredditName, new FetchSubredditData.FetchSubredditDataListener() {
- @Override
- public void onFetchSubredditDataSuccess(SubredditData subredditData, int nCurrentOnlineSubscribers) {
- swipeRefreshLayout.setRefreshing(false);
- new InsertSubredditDataAsyncTask(mRedditDataRoomDatabase, subredditData, () -> swipeRefreshLayout.setRefreshing(false)).execute();
- }
-
- @Override
- public void onFetchSubredditDataFail() {
- swipeRefreshLayout.setRefreshing(false);
- Toast.makeText(ViewSidebarActivity.this, R.string.cannot_fetch_sidebar, Toast.LENGTH_SHORT).show();
- }
- });
- }
-
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- getMenuInflater().inflate(R.menu.view_sidebar_activity, menu);
- applyMenuItemTheme(menu);
- return true;
- }
-
- @Override
- public boolean onOptionsItemSelected(@NonNull MenuItem item) {
- if (item.getItemId() == android.R.id.home) {
- finish();
- return true;
- } else if (item.getItemId() == R.id.action_refresh_view_sidebar_activity) {
- if (!swipeRefreshLayout.isRefreshing()) {
- fetchSubredditData();
- }
- return true;
- }
- return false;
- }
-
- @Override
- public SharedPreferences getSharedPreferences() {
- return mSharedPreferences;
- }
-
- @Override
- protected CustomThemeWrapper getCustomThemeWrapper() {
- return mCustomThemeWrapper;
- }
-
- @Override
- protected void applyCustomTheme() {
- coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor());
- applyAppBarLayoutAndToolbarTheme(appBarLayout, toolbar);
- swipeRefreshLayout.setProgressBackgroundColorSchemeColor(mCustomThemeWrapper.getCircularProgressBarBackground());
- swipeRefreshLayout.setColorSchemeColors(mCustomThemeWrapper.getColorAccent());
- markdownColor = mCustomThemeWrapper.getSecondaryTextColor();
- }
-
- @Override
- public void onLongPress() {
- if (mLinearLayoutManager != null) {
- mLinearLayoutManager.scrollToPositionWithOffset(0, 0);
- }
- }
-}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewSubredditDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewSubredditDetailActivity.java
index 0ec10e46..d1b34c1c 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewSubredditDetailActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewSubredditDetailActivity.java
@@ -90,6 +90,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
public static final String EXTRA_SUBREDDIT_NAME_KEY = "ESN";
public static final String EXTRA_MESSAGE_FULLNAME = "ENF";
public static final String EXTRA_NEW_ACCOUNT_NAME = "ENAN";
+ public static final String EXTRA_VIEW_SIDEBAR = "EVSB";
private static final String FETCH_SUBREDDIT_INFO_STATE = "FSIS";
private static final String CURRENT_ONLINE_SUBSCRIBERS_STATE = "COSS";
@@ -627,6 +628,12 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
viewPager.setOffscreenPageLimit(2);
tabLayout.setupWithViewPager(viewPager);
+
+ boolean viewSidebar = getIntent().getBooleanExtra(EXTRA_VIEW_SIDEBAR, false);
+ if (viewSidebar) {
+ viewPager.setCurrentItem(1, false);
+ }
+
viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
@@ -701,34 +708,31 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
fetchSubredditData();
return true;
case R.id.action_lazy_mode_view_subreddit_detail_activity:
- MenuItem lazyModeItem = mMenu.findItem(R.id.action_lazy_mode_view_subreddit_detail_activity);
- if (isInLazyMode) {
- isInLazyMode = false;
- sectionsPagerAdapter.stopLazyMode();
- lazyModeItem.setTitle(R.string.action_start_lazy_mode);
- params.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL | AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS |
- AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS_COLLAPSED);
- collapsingToolbarLayout.setLayoutParams(params);
- } else {
- isInLazyMode = true;
- if (sectionsPagerAdapter.startLazyMode()) {
- lazyModeItem.setTitle(R.string.action_stop_lazy_mode);
- appBarLayout.setExpanded(false);
- params.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL | AppBarLayout.LayoutParams.SCROLL_FLAG_EXIT_UNTIL_COLLAPSED);
+ if (sectionsPagerAdapter != null) {
+ MenuItem lazyModeItem = mMenu.findItem(R.id.action_lazy_mode_view_subreddit_detail_activity);
+ if (isInLazyMode) {
+ isInLazyMode = false;
+ sectionsPagerAdapter.stopLazyMode();
+ lazyModeItem.setTitle(R.string.action_start_lazy_mode);
+ params.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL | AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS |
+ AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS_COLLAPSED);
collapsingToolbarLayout.setLayoutParams(params);
} else {
- isInLazyMode = false;
+ isInLazyMode = true;
+ if (sectionsPagerAdapter.startLazyMode()) {
+ lazyModeItem.setTitle(R.string.action_stop_lazy_mode);
+ appBarLayout.setExpanded(false);
+ params.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL | AppBarLayout.LayoutParams.SCROLL_FLAG_EXIT_UNTIL_COLLAPSED);
+ collapsingToolbarLayout.setLayoutParams(params);
+ } else {
+ isInLazyMode = false;
+ }
}
}
return true;
case R.id.action_change_post_layout_view_subreddit_detail_activity:
postLayoutBottomSheetFragment.show(getSupportFragmentManager(), postLayoutBottomSheetFragment.getTag());
return true;
- case R.id.action_view_side_bar_view_subreddit_detail_activity:
- Intent sidebarIntent = new Intent(this, ViewSidebarActivity.class);
- sidebarIntent.putExtra(ViewSidebarActivity.EXTRA_SUBREDDIT_NAME, subredditName);
- startActivity(sidebarIntent);
- return true;
case R.id.action_share_view_subreddit_detail_activity:
Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.setType("text/plain");
@@ -777,7 +781,9 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
@Override
public void sortTypeSelected(SortType sortType) {
- sectionsPagerAdapter.changeSortType(sortType);
+ if (sectionsPagerAdapter != null) {
+ sectionsPagerAdapter.changeSortType(sortType);
+ }
}
@Override
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java
index c4d65766..c7984bfb 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java
@@ -1117,7 +1117,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
private void loadImage(PostDetailBaseViewHolder holder) {
if (holder instanceof PostDetailImageAndGifAutoplayViewHolder) {
String url = mAutoplay && mPost.getPostType() == Post.GIF_TYPE ? mPost.getUrl() : mPost.getPreviewUrl();
- RequestBuilder imageRequestBuilder = mGlide.load(url)
+ RequestBuilder<Drawable> imageRequestBuilder = mGlide.load(url)
.listener(new RequestListener<Drawable>() {
@Override
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
@@ -1140,12 +1140,12 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
if ((mPost.isNSFW() && mNeedBlurNsfw) || (mPost.isSpoiler() && mNeedBlurSpoiler)) {
imageRequestBuilder.apply(RequestOptions.bitmapTransform(new BlurTransformation(50, 10)))
- .into(((PostDetailImageAndGifAutoplayViewHolder) holder).mImageView);
+ .override(Target.SIZE_ORIGINAL).into(((PostDetailImageAndGifAutoplayViewHolder) holder).mImageView);
} else {
- imageRequestBuilder.into(((PostDetailImageAndGifAutoplayViewHolder) holder).mImageView);
+ imageRequestBuilder.override(Target.SIZE_ORIGINAL).into(((PostDetailImageAndGifAutoplayViewHolder) holder).mImageView);
}
} else if (holder instanceof PostDetailVideoAndGifPreviewHolder) {
- RequestBuilder imageRequestBuilder = mGlide.load(mPost.getPreviewUrl())
+ RequestBuilder<Drawable> imageRequestBuilder = mGlide.load(mPost.getPreviewUrl())
.listener(new RequestListener<Drawable>() {
@Override
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
@@ -1168,12 +1168,12 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
if ((mPost.isNSFW() && mNeedBlurNsfw) || (mPost.isSpoiler() && mNeedBlurSpoiler)) {
imageRequestBuilder.apply(RequestOptions.bitmapTransform(new BlurTransformation(50, 10)))
- .into(((PostDetailVideoAndGifPreviewHolder) holder).mImageView);
+ .override(Target.SIZE_ORIGINAL).into(((PostDetailVideoAndGifPreviewHolder) holder).mImageView);
} else {
- imageRequestBuilder.into(((PostDetailVideoAndGifPreviewHolder) holder).mImageView);
+ imageRequestBuilder.override(Target.SIZE_ORIGINAL).into(((PostDetailVideoAndGifPreviewHolder) holder).mImageView);
}
} else if(holder instanceof PostDetailLinkViewHolder) {
- RequestBuilder imageRequestBuilder = mGlide.load(mPost.getPreviewUrl())
+ RequestBuilder<Drawable> imageRequestBuilder = mGlide.load(mPost.getPreviewUrl())
.listener(new RequestListener<Drawable>() {
@Override
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
@@ -1196,9 +1196,9 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
if ((mPost.isNSFW() && mNeedBlurNsfw) || (mPost.isSpoiler() && mNeedBlurSpoiler)) {
imageRequestBuilder.apply(RequestOptions.bitmapTransform(new BlurTransformation(50, 10)))
- .into(((PostDetailLinkViewHolder) holder).mImageView);
+ .override(Target.SIZE_ORIGINAL).into(((PostDetailLinkViewHolder) holder).mImageView);
} else {
- imageRequestBuilder.into(((PostDetailLinkViewHolder) holder).mImageView);
+ imageRequestBuilder.override(Target.SIZE_ORIGINAL).into(((PostDetailLinkViewHolder) holder).mImageView);
}
}
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java
index 2b65b05a..e54a0eea 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java
@@ -1145,9 +1145,9 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
if ((post.isNSFW() && mNeedBlurNSFW) || post.isSpoiler() && mNeedBlurSpoiler) {
imageRequestBuilder.apply(RequestOptions.bitmapTransform(new BlurTransformation(50, 10)))
- .into(((PostImageAndGifAutoplayViewHolder) holder).imageView);
+ .override(Target.SIZE_ORIGINAL).into(((PostImageAndGifAutoplayViewHolder) holder).imageView);
} else {
- imageRequestBuilder.into(((PostImageAndGifAutoplayViewHolder) holder).imageView);
+ imageRequestBuilder.override(Target.SIZE_ORIGINAL).into(((PostImageAndGifAutoplayViewHolder) holder).imageView);
}
} else if (holder instanceof PostVideoAndGifPreviewViewHolder) {
RequestBuilder<Drawable> imageRequestBuilder = mGlide.load(post.getPreviewUrl()).listener(new RequestListener<Drawable>() {
@@ -1173,9 +1173,9 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
if ((post.isNSFW() && mNeedBlurNSFW) || post.isSpoiler() && mNeedBlurSpoiler) {
imageRequestBuilder.apply(RequestOptions.bitmapTransform(new BlurTransformation(50, 10)))
- .into(((PostVideoAndGifPreviewViewHolder) holder).imageView);
+ .override(Target.SIZE_ORIGINAL).into(((PostVideoAndGifPreviewViewHolder) holder).imageView);
} else {
- imageRequestBuilder.into(((PostVideoAndGifPreviewViewHolder) holder).imageView);
+ imageRequestBuilder.override(Target.SIZE_ORIGINAL).into(((PostVideoAndGifPreviewViewHolder) holder).imageView);
}
} else if (holder instanceof PostLinkTypeViewHolder) {
RequestBuilder<Drawable> imageRequestBuilder = mGlide.load(post.getPreviewUrl()).listener(new RequestListener<Drawable>() {
@@ -1201,9 +1201,9 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
if ((post.isNSFW() && mNeedBlurNSFW) || post.isSpoiler() && mNeedBlurSpoiler) {
imageRequestBuilder.apply(RequestOptions.bitmapTransform(new BlurTransformation(50, 10)))
- .into(((PostLinkTypeViewHolder) holder).imageView);
+ .override(Target.SIZE_ORIGINAL).into(((PostLinkTypeViewHolder) holder).imageView);
} else {
- imageRequestBuilder.into(((PostLinkTypeViewHolder) holder).imageView);
+ imageRequestBuilder.override(Target.SIZE_ORIGINAL).into(((PostLinkTypeViewHolder) holder).imageView);
}
} else if (holder instanceof PostCompactViewHolder) {
String previewUrl = post.getThumbnailPreviewUrl().equals("") ? post.getPreviewUrl() : post.getThumbnailPreviewUrl();
@@ -1224,9 +1224,9 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
if ((post.isNSFW() && mNeedBlurNSFW) || post.isSpoiler() && mNeedBlurSpoiler) {
imageRequestBuilder
.transform(new BlurTransformation(50, 2))
- .into(((PostCompactViewHolder) holder).imageView);
+ .override(Target.SIZE_ORIGINAL).into(((PostCompactViewHolder) holder).imageView);
} else {
- imageRequestBuilder.into(((PostCompactViewHolder) holder).imageView);
+ imageRequestBuilder.override(Target.SIZE_ORIGINAL).into(((PostCompactViewHolder) holder).imageView);
}
}
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/AppComponent.java b/app/src/main/java/ml/docilealligator/infinityforreddit/AppComponent.java
index 651b09b7..74c850b6 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/AppComponent.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/AppComponent.java
@@ -38,7 +38,6 @@ import ml.docilealligator.infinityforreddit.Activity.ViewImgurMediaActivity;
import ml.docilealligator.infinityforreddit.Activity.ViewMessageActivity;
import ml.docilealligator.infinityforreddit.Activity.ViewMultiRedditDetailActivity;
import ml.docilealligator.infinityforreddit.Activity.ViewPostDetailActivity;
-import ml.docilealligator.infinityforreddit.Activity.ViewSidebarActivity;
import ml.docilealligator.infinityforreddit.Activity.ViewSubredditDetailActivity;
import ml.docilealligator.infinityforreddit.Activity.ViewUserDetailActivity;
import ml.docilealligator.infinityforreddit.Activity.ViewVideoActivity;
@@ -142,8 +141,6 @@ public interface AppComponent {
void inject(ViewMultiRedditDetailActivity viewMultiRedditDetailActivity);
- void inject(ViewSidebarActivity viewSidebarActivity);
-
void inject(ViewVideoActivity viewVideoActivity);
void inject(GesturesAndButtonsPreferenceFragment gesturesAndButtonsPreferenceFragment);
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/CommentData.java b/app/src/main/java/ml/docilealligator/infinityforreddit/CommentData.java
index 5c01f3fe..e38ecd11 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/CommentData.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/CommentData.java
@@ -279,7 +279,7 @@ public class CommentData implements Parcelable {
if (children == null || children.size() == 0) {
setChildren(moreChildren);
} else {
- if (children.get(children.size() - 1).isPlaceHolder) {
+ if (children.size() > 1 && children.get(children.size() - 1).isPlaceHolder) {
children.addAll(children.size() - 2, moreChildren);
} else {
children.addAll(moreChildren);
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/SidebarFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/SidebarFragment.java
index dbafed2d..9d9aa9b7 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/SidebarFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/SidebarFragment.java
@@ -50,9 +50,6 @@ import ml.docilealligator.infinityforreddit.SubredditDatabase.SubredditData;
import ml.docilealligator.infinityforreddit.SubredditDatabase.SubredditViewModel;
import retrofit2.Retrofit;
-/**
- * A simple {@link Fragment} subclass.
- */
public class SidebarFragment extends Fragment {
public static final String EXTRA_SUBREDDIT_NAME = "ESN";
@@ -152,7 +149,7 @@ public class SidebarFragment extends Fragment {
mSubredditViewModel = new ViewModelProvider(this,
new SubredditViewModel.Factory(activity.getApplication(), mRedditDataRoomDatabase, subredditName))
.get(SubredditViewModel.class);
- mSubredditViewModel.getSubredditLiveData().observe(this, subredditData -> {
+ mSubredditViewModel.getSubredditLiveData().observe(getViewLifecycleOwner(), subredditData -> {
if (subredditData != null) {
if (subredditData.getSidebarDescription() != null && !subredditData.getSidebarDescription().equals("")) {
markwonAdapter.setMarkdown(markwon, subredditData.getSidebarDescription());
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/ViewImgurImageFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/ViewImgurImageFragment.java
index 0319c904..99ebd248 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/ViewImgurImageFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/ViewImgurImageFragment.java
@@ -100,7 +100,7 @@ public class ViewImgurImageFragment extends Fragment {
progressBar.setVisibility(View.GONE);
return false;
}
- }).into(imageView);
+ }).override(Target.SIZE_ORIGINAL).into(imageView);
}
@Override
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Service/DownloadRedditVideoService.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Service/DownloadRedditVideoService.java
index 3da24433..b958eba2 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Service/DownloadRedditVideoService.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Service/DownloadRedditVideoService.java
@@ -397,7 +397,7 @@ public class DownloadRedditVideoService extends Service {
int audioTrack = muxer.addTrack(audioFormat);
boolean sawEOS = false;
int offset = 100;
- int sampleSize = 256 * 1024;
+ int sampleSize = 2048 * 1024;
ByteBuffer videoBuf = ByteBuffer.allocate(sampleSize);
ByteBuffer audioBuf = ByteBuffer.allocate(sampleSize);
MediaCodec.BufferInfo videoBufferInfo = new MediaCodec.BufferInfo();
@@ -412,7 +412,6 @@ public class DownloadRedditVideoService extends Service {
videoBufferInfo.offset = offset;
videoBufferInfo.size = videoExtractor.readSampleData(videoBuf, offset);
-
if (videoBufferInfo.size < 0 || audioBufferInfo.size < 0) {
sawEOS = true;
videoBufferInfo.size = 0;
@@ -441,8 +440,10 @@ public class DownloadRedditVideoService extends Service {
}
}
- muxer.stop();
- muxer.release();
+ try {
+ muxer.stop();
+ muxer.release();
+ } catch (IllegalStateException ignore) {}
} catch (IOException e) {
e.printStackTrace();
return false;
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/GlideImageGetter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/GlideImageGetter.java
index 04c16284..fc8cfcf9 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/GlideImageGetter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/GlideImageGetter.java
@@ -56,7 +56,7 @@ public class GlideImageGetter implements Html.ImageGetter {
BitmapDrawablePlaceholder drawable = new BitmapDrawablePlaceholder(textSize);
Context context = container.get().getContext();
- if (!(context instanceof Activity && ((Activity) context).isFinishing())) {
+ if (!(context instanceof Activity && ((Activity) context).isDestroyed())) {
container.get().post(() -> Glide.with(context)
.asBitmap()
.load(source)
@@ -118,7 +118,9 @@ public class GlideImageGetter implements Html.ImageGetter {
@Override
public void onResourceReady(@NonNull Bitmap bitmap, @Nullable Transition<? super Bitmap> transition) {
- setDrawable(new BitmapDrawable(container.get().getResources(), bitmap));
+ if (container != null) {
+ setDrawable(new BitmapDrawable(container.get().getResources(), bitmap));
+ }
}
@Override
diff --git a/app/src/main/res/layout/activity_view_image.xml b/app/src/main/res/layout/activity_view_image.xml
index c094cb47..9a80a732 100644
--- a/app/src/main/res/layout/activity_view_image.xml
+++ b/app/src/main/res/layout/activity_view_image.xml
@@ -28,6 +28,8 @@
android:id="@+id/image_view_view_image_activity"
android:layout_width="match_parent"
android:layout_height="match_parent"
+ android:adjustViewBounds="true"
+ android:scaleType="fitCenter"
app:gest_fillViewport="true" />
<LinearLayout
diff --git a/app/src/main/res/layout/activity_view_sidebar.xml b/app/src/main/res/layout/activity_view_sidebar.xml
deleted file mode 100644
index 94a120ef..00000000
--- a/app/src/main/res/layout/activity_view_sidebar.xml
+++ /dev/null
@@ -1,50 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:app="http://schemas.android.com/apk/res-auto"
- xmlns:tools="http://schemas.android.com/tools"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:id="@+id/coordinator_layout_view_sidebar_activity"
- tools:context=".Activity.ViewSidebarActivity">
-
- <com.google.android.material.appbar.AppBarLayout
- android:id="@+id/appbar_layout_view_sidebar_activity"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:theme="@style/AppTheme.AppBarOverlay">
-
- <com.google.android.material.appbar.CollapsingToolbarLayout
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- app:layout_scrollFlags="scroll|enterAlways"
- app:titleEnabled="false"
- app:toolbarId="@+id/toolbar_view_sidebar_activity">
-
- <androidx.appcompat.widget.Toolbar
- android:id="@+id/toolbar_view_sidebar_activity"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:minHeight="?attr/actionBarSize"
- app:popupTheme="@style/AppTheme.PopupOverlay"
- app:navigationIcon="?attr/homeAsUpIndicator" />
-
- </com.google.android.material.appbar.CollapsingToolbarLayout>
-
- </com.google.android.material.appbar.AppBarLayout>
-
- <androidx.swiperefreshlayout.widget.SwipeRefreshLayout
- android:id="@+id/swipe_refresh_layout_view_sidebar_activity"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- app:layout_behavior="@string/appbar_scrolling_view_behavior">
-
- <androidx.recyclerview.widget.RecyclerView
- android:id="@+id/markdown_recycler_view_view_sidebar_activity"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:padding="16dp"
- android:clipToPadding="false" />
-
- </androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
-
-</androidx.coordinatorlayout.widget.CoordinatorLayout> \ No newline at end of file
diff --git a/app/src/main/res/layout/fragment_view_imgur_images.xml b/app/src/main/res/layout/fragment_view_imgur_images.xml
index a28346dc..63620c08 100644
--- a/app/src/main/res/layout/fragment_view_imgur_images.xml
+++ b/app/src/main/res/layout/fragment_view_imgur_images.xml
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/constraintLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
@@ -15,7 +16,10 @@
<com.alexvasilkov.gestures.views.GestureImageView
android:id="@+id/image_view_view_imgur_image_fragment"
android:layout_width="match_parent"
- android:layout_height="match_parent" />
+ android:layout_height="match_parent"
+ android:adjustViewBounds="true"
+ android:scaleType="fitCenter"
+ app:gest_fillViewport="true" />
<LinearLayout
android:id="@+id/load_image_error_linear_layout_view_imgur_image_fragment"
diff --git a/app/src/main/res/menu/view_sidebar_activity.xml b/app/src/main/res/menu/view_sidebar_activity.xml
deleted file mode 100644
index fa5d9123..00000000
--- a/app/src/main/res/menu/view_sidebar_activity.xml
+++ /dev/null
@@ -1,10 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<menu xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:app="http://schemas.android.com/apk/res-auto">
- <item
- android:id="@+id/action_refresh_view_sidebar_activity"
- android:orderInCategory="1"
- android:title="@string/action_refresh"
- android:icon="@drawable/ic_refresh_toolbar_24dp"
- app:showAsAction="ifRoom" />
-</menu> \ No newline at end of file
diff --git a/app/src/main/res/menu/view_subreddit_detail_activity.xml b/app/src/main/res/menu/view_subreddit_detail_activity.xml
index 9365ed2e..daea0d09 100644
--- a/app/src/main/res/menu/view_subreddit_detail_activity.xml
+++ b/app/src/main/res/menu/view_subreddit_detail_activity.xml
@@ -35,14 +35,8 @@
app:showAsAction="never" />
<item
- android:id="@+id/action_view_side_bar_view_subreddit_detail_activity"
- android:orderInCategory="6"
- android:title="@string/action_view_side_bar"
- app:showAsAction="never" />
-
- <item
android:id="@+id/action_share_view_subreddit_detail_activity"
android:orderInCategory="7"
android:title="@string/action_share"
app:showAsAction="never" />
-</menu> \ No newline at end of file
+</menu>