aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java/ml/docilealligator/infinityforreddit
diff options
context:
space:
mode:
authorAlex Ning <chineseperson5@gmail.com>2021-12-03 13:04:19 +0000
committerAlex Ning <chineseperson5@gmail.com>2021-12-03 13:04:19 +0000
commitc809de6350872de2b376892bf10bf48a8931d321 (patch)
treec9e2de32520d238c7e743471ca7d61e46955cd0b /app/src/main/java/ml/docilealligator/infinityforreddit
parentb0d9a15dfd648d27052d1785b4ab808b58ffc2bb (diff)
downloadinfinity-for-reddit-c809de6350872de2b376892bf10bf48a8931d321.tar
infinity-for-reddit-c809de6350872de2b376892bf10bf48a8931d321.tar.gz
infinity-for-reddit-c809de6350872de2b376892bf10bf48a8931d321.tar.bz2
infinity-for-reddit-c809de6350872de2b376892bf10bf48a8931d321.tar.lz
infinity-for-reddit-c809de6350872de2b376892bf10bf48a8931d321.tar.xz
infinity-for-reddit-c809de6350872de2b376892bf10bf48a8931d321.tar.zst
infinity-for-reddit-c809de6350872de2b376892bf10bf48a8931d321.zip
Minor bugs fixed in ParsePost.
Diffstat (limited to 'app/src/main/java/ml/docilealligator/infinityforreddit')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/LinkResolverActivity.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewUserDetailActivity.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/asynctasks/DeleteAllPostLayouts.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/asynctasks/DeleteAllSortTypes.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/SortTimeBottomSheetFragment.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/fragments/CommentsListingFragment.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java3
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewRedditGalleryImageOrGifFragment.java4
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/post/ParsePost.java10
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/post/PostPagingSource.java4
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/settings/ThemePreferenceFragment.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/user/ParseUserData.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/utils/GlideImageGetter.java4
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/utils/Utils.java7
15 files changed, 25 insertions, 25 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/LinkResolverActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/LinkResolverActivity.java
index 2c337c63..b16348c8 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/LinkResolverActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/LinkResolverActivity.java
@@ -269,7 +269,7 @@ public class LinkResolverActivity extends AppCompatActivity {
} else {
deepLinkError(uri);
}
- } else if (authority.contains("google.com") ){
+ } else if (authority.contains("google.com")) {
if ( path.matches(GOOGLE_AMP_PATTERN) ) {
String url = path.substring(11, path.length()); // skipping past amp straight to reddit
handleUri(Uri.parse("https://" + url));
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewUserDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewUserDetailActivity.java
index 583be59d..f733b122 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewUserDetailActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewUserDetailActivity.java
@@ -1175,7 +1175,7 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
.setNegativeButton(R.string.no, null)
.show();
return true;
- } else if(itemId == R.id.action_edit_profile_view_user_detail_activity){
+ } else if (itemId == R.id.action_edit_profile_view_user_detail_activity) {
startActivity(new Intent(this, EditProfileActivity.class));
return true;
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java
index b7d18ac8..d821ddb8 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java
@@ -1908,7 +1908,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
intent.putExtra(ViewImageOrGifActivity.EXTRA_POST_TITLE_KEY, post.getTitle());
intent.putExtra(ViewImageOrGifActivity.EXTRA_SUBREDDIT_OR_USERNAME_KEY, post.getSubredditName());
mActivity.startActivity(intent);
- } else if (post.getPostType() == Post.GIF_TYPE){
+ } else if (post.getPostType() == Post.GIF_TYPE) {
Intent intent = new Intent(mActivity, ViewImageOrGifActivity.class);
intent.putExtra(ViewImageOrGifActivity.EXTRA_FILE_NAME_KEY, post.getSubredditName()
+ "-" + post.getId() + ".gif");
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/asynctasks/DeleteAllPostLayouts.java b/app/src/main/java/ml/docilealligator/infinityforreddit/asynctasks/DeleteAllPostLayouts.java
index ca20a20d..c1ac3d8c 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/asynctasks/DeleteAllPostLayouts.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/asynctasks/DeleteAllPostLayouts.java
@@ -17,7 +17,7 @@ public class DeleteAllPostLayouts {
Map<String,?> keys = defaultSharedPreferences.getAll();
SharedPreferences.Editor editor = defaultSharedPreferences.edit();
- for(Map.Entry<String,?> entry : keys.entrySet()){
+ for (Map.Entry<String,?> entry : keys.entrySet()) {
String key = entry.getKey();
if (key.startsWith(SharedPreferencesUtils.POST_LAYOUT_SHARED_PREFERENCES_FILE)
|| key.startsWith(SharedPreferencesUtils.POST_LAYOUT_FRONT_PAGE_POST)
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/asynctasks/DeleteAllSortTypes.java b/app/src/main/java/ml/docilealligator/infinityforreddit/asynctasks/DeleteAllSortTypes.java
index e077871d..f6a77118 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/asynctasks/DeleteAllSortTypes.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/asynctasks/DeleteAllSortTypes.java
@@ -17,7 +17,7 @@ public class DeleteAllSortTypes {
Map<String,?> keys = defaultSharedPreferences.getAll();
SharedPreferences.Editor editor = defaultSharedPreferences.edit();
- for(Map.Entry<String,?> entry : keys.entrySet()){
+ for (Map.Entry<String,?> entry : keys.entrySet()) {
String key = entry.getKey();
if (key.contains(SharedPreferencesUtils.SORT_TYPE_BEST_POST) || key.contains(SharedPreferencesUtils.SORT_TIME_BEST_POST)
|| key.contains(SharedPreferencesUtils.SORT_TYPE_ALL_POST_LEGACY) || key.contains(SharedPreferencesUtils.SORT_TIME_ALL_POST_LEGACY)
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/SortTimeBottomSheetFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/SortTimeBottomSheetFragment.java
index 38761791..5f184ea8 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/SortTimeBottomSheetFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/SortTimeBottomSheetFragment.java
@@ -59,7 +59,7 @@ public class SortTimeBottomSheetFragment extends LandscapeExpandedRoundedBottomS
}
String sortType = getArguments() != null ? getArguments().getString(EXTRA_SORT_TYPE) : null;
- if(sortType == null) {
+ if (sortType == null) {
dismiss();
return rootView;
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/CommentsListingFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/CommentsListingFragment.java
index 34c67ecd..177c1777 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/CommentsListingFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/CommentsListingFragment.java
@@ -265,7 +265,7 @@ public class CommentsListingFragment extends Fragment implements FragmentCommuni
String username = getArguments().getString(EXTRA_USERNAME);
String sort = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TYPE_USER_COMMENT, SortType.Type.NEW.name());
- if(sort.equals(SortType.Type.CONTROVERSIAL.name()) || sort.equals(SortType.Type.TOP.name())) {
+ if (sort.equals(SortType.Type.CONTROVERSIAL.name()) || sort.equals(SortType.Type.TOP.name())) {
String sortTime = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TIME_USER_COMMENT, SortType.Time.ALL.name());
sortType = new SortType(SortType.Type.valueOf(sort.toUpperCase()), SortType.Time.valueOf(sortTime.toUpperCase()));
} else {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java
index c7a8e7da..b60a86db 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java
@@ -1260,8 +1260,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
mFetchPostInfoLinearLayout.setOnClickListener(view -> refresh());
showErrorView(R.string.load_posts_error);
}
- if (!(refreshLoadState instanceof LoadState.Loading) // #563
- && appendLoadState instanceof LoadState.NotLoading) {
+ if (!(refreshLoadState instanceof LoadState.Loading) && appendLoadState instanceof LoadState.NotLoading) {
if (appendLoadState.getEndOfPaginationReached() && mAdapter.getItemCount() < 1) {
noPostFound();
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewRedditGalleryImageOrGifFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewRedditGalleryImageOrGifFragment.java
index 2d8526bc..6265cf79 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewRedditGalleryImageOrGifFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewRedditGalleryImageOrGifFragment.java
@@ -292,7 +292,7 @@ public class ViewRedditGalleryImageOrGifFragment extends Fragment {
if (!captionUrlIsEmpty) {
String scheme = Uri.parse(captionUrl).getScheme();
String urlWithoutScheme = "";
- if(!TextUtils.isEmpty(scheme)){
+ if (!TextUtils.isEmpty(scheme)) {
urlWithoutScheme = captionUrl.substring(scheme.length() + 3);
}
@@ -330,7 +330,7 @@ public class ViewRedditGalleryImageOrGifFragment extends Fragment {
}
private void loadImage() {
- if(isFallback) {
+ if (isFallback) {
imageView.showImage(Uri.parse(media.fallbackUrl));
}
else{
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/post/ParsePost.java b/app/src/main/java/ml/docilealligator/infinityforreddit/post/ParsePost.java
index cf070e4e..0685170a 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/post/ParsePost.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/post/ParsePost.java
@@ -401,7 +401,7 @@ public class ParsePost {
previews.add(new Post.Preview(url, 0, 0, "", ""));
}
post.setPreviews(previews);
- } else if (url.endsWith("gif")){
+ } else if (url.endsWith("gif")) {
//Gif post
int postType = Post.GIF_TYPE;
post = new Post(id, fullName, subredditName, subredditNamePrefixed, author,
@@ -564,15 +564,15 @@ public class ParsePost {
JSONObject galleryItem = galleryIdsArray.getJSONObject(i);
String galleryItemCaption = "";
String galleryItemCaptionUrl = "";
- if(galleryItem.has(JSONUtils.CAPTION_KEY)){
+ if (galleryItem.has(JSONUtils.CAPTION_KEY)) {
galleryItemCaption = galleryItem.getString(JSONUtils.CAPTION_KEY).trim();
}
- if(galleryItem.has(JSONUtils.CAPTION_URL_KEY)){
+ if (galleryItem.has(JSONUtils.CAPTION_URL_KEY)) {
galleryItemCaptionUrl = galleryItem.getString(JSONUtils.CAPTION_URL_KEY).trim();
}
- if ((previews.isEmpty()) && mimeType.contains("jpg") || mimeType.contains("png")) {
+ if (previews.isEmpty() && (mimeType.contains("jpg") || mimeType.contains("png"))) {
previews.add(new Post.Preview(galleryItemUrl, singleGalleryObject.getJSONObject(JSONUtils.S_KEY).getInt(JSONUtils.X_KEY),
singleGalleryObject.getJSONObject(JSONUtils.S_KEY).getInt(JSONUtils.Y_KEY), galleryItemCaption, galleryItemCaptionUrl));
}
@@ -581,7 +581,7 @@ public class ParsePost {
// For issue #558
// Construct a fallback image url
- if(!TextUtils.isEmpty(galleryItemUrl) && !TextUtils.isEmpty(mimeType) && (mimeType.contains("jpg") || mimeType.contains("png"))) {
+ if (!TextUtils.isEmpty(galleryItemUrl) && !TextUtils.isEmpty(mimeType) && (mimeType.contains("jpg") || mimeType.contains("png"))) {
postGalleryItem.setFallbackUrl("https://i.redd.it/" + galleryId + "." + mimeType.substring(mimeType.lastIndexOf("/") + 1));
postGalleryItem.setHasFallback(true);
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/post/PostPagingSource.java b/app/src/main/java/ml/docilealligator/infinityforreddit/post/PostPagingSource.java
index fe5b1d3e..0bf7eefc 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/post/PostPagingSource.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/post/PostPagingSource.java
@@ -214,7 +214,7 @@ public class PostPagingSource extends ListenableFuturePagingSource<String, Post>
} else {
afterKey = loadParams.getKey();
}
- if(sortType.getTime() != null) {
+ if (sortType.getTime() != null) {
bestPost = api.getBestPostsListenableFuture(sortType.getType().value, sortType.getTime().value, afterKey,
APIUtils.getOAuthHeader(accessToken));
} else {
@@ -299,7 +299,7 @@ public class PostPagingSource extends ListenableFuturePagingSource<String, Post>
searchPosts = api.searchPostsListenableFuture(query, loadParams.getKey(), sortType.getType().value, trendingSource);
}
} else {
- if(sortType.getTime() != null) {
+ if (sortType.getTime() != null) {
searchPosts = api.searchPostsOauthListenableFuture(query, loadParams.getKey(), sortType.getType().value,
sortType.getTime().value, trendingSource, APIUtils.getOAuthHeader(accessToken));
} else {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/settings/ThemePreferenceFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/settings/ThemePreferenceFragment.java
index 0e0a8c7d..0f613cc0 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/settings/ThemePreferenceFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/settings/ThemePreferenceFragment.java
@@ -114,7 +114,7 @@ public class ThemePreferenceFragment extends PreferenceFragmentCompat {
AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_AUTO_BATTERY);
}
- if((getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK) == Configuration.UI_MODE_NIGHT_NO) {
+ if ((getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK) == Configuration.UI_MODE_NIGHT_NO) {
customThemeWrapper.setThemeType(CustomThemeSharedPreferencesUtils.LIGHT);
} else {
if (amoledDarkSwitch.isChecked()) {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/user/ParseUserData.java b/app/src/main/java/ml/docilealligator/infinityforreddit/user/ParseUserData.java
index a57a98ed..c77d0985 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/user/ParseUserData.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/user/ParseUserData.java
@@ -22,7 +22,7 @@ public class ParseUserData {
}
private static UserData parseUserDataBase(JSONObject userDataJson, boolean parseFullKarma) throws JSONException {
- if(userDataJson == null) {
+ if (userDataJson == null) {
return null;
}
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 215e991c..e00737cc 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/GlideImageGetter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/GlideImageGetter.java
@@ -99,7 +99,7 @@ public class GlideImageGetter implements Html.ImageGetter {
@Override
public void onLoadStarted(@Nullable Drawable placeholderDrawable) {
- if(placeholderDrawable != null) {
+ if (placeholderDrawable != null) {
setDrawable(placeholderDrawable);
}
}
@@ -126,7 +126,7 @@ public class GlideImageGetter implements Html.ImageGetter {
@Override
public void onLoadCleared(@Nullable Drawable placeholderDrawable) {
- if(placeholderDrawable != null) {
+ if (placeholderDrawable != null) {
setDrawable(placeholderDrawable);
}
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/Utils.java b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/Utils.java
index f292088d..e7ee8d6a 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/Utils.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/Utils.java
@@ -150,8 +150,9 @@ public class Utils {
public static CharSequence trimTrailingWhitespace(CharSequence source) {
- if(source == null)
+ if (source == null) {
return "";
+ }
int i = source.length();
@@ -329,7 +330,7 @@ public class Utils {
}
}
- public static float convertDpToPixel(float dp, Context context){
+ public static float convertDpToPixel(float dp, Context context) {
return dp * ((float) context.getResources().getDisplayMetrics().densityDpi / DisplayMetrics.DENSITY_DEFAULT);
}
@@ -392,7 +393,7 @@ public class Utils {
int nameIndex = cursor.getColumnIndex(OpenableColumns.DISPLAY_NAME);
cursor.moveToFirst();
String fileName = cursor.getString(nameIndex);
- if(fileName != null && fileName.contains(".")) {
+ if (fileName != null && fileName.contains(".")) {
fileName = fileName.substring(0, fileName.lastIndexOf('.'));
}
return fileName;