diff options
Diffstat (limited to 'app/src')
11 files changed, 34 insertions, 31 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/CommentData.java b/app/src/main/java/ml/docilealligator/infinityforreddit/CommentData.java index e0c697b6..c50e51df 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/CommentData.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/CommentData.java @@ -84,8 +84,8 @@ class CommentData implements Parcelable { hasReply = in.readByte() != 0; scoreHidden = in.readByte() != 0; isExpanded = in.readByte() != 0; - children = in.readArrayList(null); - moreChildrenFullnames = in.readArrayList(null); + children = in.readArrayList(CommentData.class.getClassLoader()); + moreChildrenFullnames = in.readArrayList(CommentData.class.getClassLoader()); moreChildrenStartingIndex = in.readInt(); isPlaceHolder = in.readByte() != 0; isLoadingMoreChildren = in.readByte() != 0; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/MainActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/MainActivity.java index 6e4c6c99..7df67fd1 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/MainActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/MainActivity.java @@ -122,7 +122,7 @@ public class MainActivity extends AppCompatActivity { if (savedInstanceState == null) { mFragment = new PostFragment(); Bundle bundle = new Bundle(); - bundle.putInt(PostFragment.EXTRA_POST_TYPE_KEY, PostDataSource.TYPE_FRONT_PAGE); + bundle.putInt(PostFragment.EXTRA_POST_TYPE, PostDataSource.TYPE_FRONT_PAGE); mFragment.setArguments(bundle); getSupportFragmentManager().beginTransaction().replace(R.id.frame_layout_content_main, mFragment).commit(); } else { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/ParseSubredditData.java b/app/src/main/java/ml/docilealligator/infinityforreddit/ParseSubredditData.java index 2e59e33a..bfdb084d 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/ParseSubredditData.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/ParseSubredditData.java @@ -54,7 +54,7 @@ class ParseSubredditData { JSONObject data = jsonResponse.getJSONObject(JSONUtils.DATA_KEY); mNCurrentOnlineSubscribers = data.getInt(JSONUtils.ACTIVE_USER_COUNT_KEY); subredditData = parseSubredditData(data); - /*String id = data.getString(JSONUtils.EXTRA_SUBREDDIT_NAME_KEY); + /*String id = data.getString(JSONUtils.EXTRA_SUBREDDIT_NAME); String subredditFullName = data.getString(JSONUtils.DISPLAY_NAME); String description = data.getString(JSONUtils.PUBLIC_DESCRIPTION_KEY).trim(); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/PostFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/PostFragment.java index b00bed79..3fde7f58 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/PostFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/PostFragment.java @@ -45,9 +45,9 @@ import retrofit2.Retrofit; */ public class PostFragment extends Fragment implements FragmentCommunicator { - static final String EXTRA_SUBREDDIT_NAME_KEY = "ENK"; - static final String EXTRA_QUERY_KEY = "EQK"; - static final String EXTRA_POST_TYPE_KEY = "EPTK"; + static final String EXTRA_SUBREDDIT_NAME = "EN"; + static final String EXTRA_QUERY = "EQ"; + static final String EXTRA_POST_TYPE = "EPT"; private static final String IS_IN_LAZY_MODE_STATE = "IILMS"; @@ -165,7 +165,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator { return false; }); - int postType = getArguments().getInt(EXTRA_POST_TYPE_KEY); + int postType = getArguments().getInt(EXTRA_POST_TYPE); String accessToken = activity.getSharedPreferences(SharedPreferencesUtils.AUTH_CODE_FILE_KEY, Context.MODE_PRIVATE) .getString(SharedPreferencesUtils.ACCESS_TOKEN_KEY, ""); @@ -173,8 +173,8 @@ public class PostFragment extends Fragment implements FragmentCommunicator { PostViewModel.Factory factory; if(postType == PostDataSource.TYPE_SEARCH) { - String subredditName = getArguments().getString(EXTRA_SUBREDDIT_NAME_KEY); - String query = getArguments().getString(EXTRA_QUERY_KEY); + String subredditName = getArguments().getString(EXTRA_SUBREDDIT_NAME); + String query = getArguments().getString(EXTRA_QUERY); mAdapter = new PostRecyclerViewAdapter(activity, mRetrofit, mSharedPreferences, postType, () -> mPostViewModel.retryLoadingMore()); @@ -195,7 +195,13 @@ public class PostFragment extends Fragment implements FragmentCommunicator { } }); } else if(postType != PostDataSource.TYPE_FRONT_PAGE) { - String subredditName = getArguments().getString(EXTRA_SUBREDDIT_NAME_KEY); + if(postType == PostDataSource.TYPE_USER) { + CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) mFetchPostInfoLinearLayout.getLayoutParams(); + params.height = ViewGroup.LayoutParams.WRAP_CONTENT; + mFetchPostInfoLinearLayout.setLayoutParams(params); + } + + String subredditName = getArguments().getString(EXTRA_SUBREDDIT_NAME); mAdapter = new PostRecyclerViewAdapter(activity, mRetrofit, mSharedPreferences, postType, () -> mPostViewModel.retryLoadingMore()); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/PostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/PostRecyclerViewAdapter.java index 4536c60b..ad6e59e3 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/PostRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/PostRecyclerViewAdapter.java @@ -668,7 +668,7 @@ class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView.ViewHo ErrorViewHolder(View itemView) { super(itemView); ButterKnife.bind(this, itemView); - errorTextView.setText(R.string.load_posts_failed); + errorTextView.setText(R.string.load_posts_error); retryButton.setOnClickListener(view -> retryLoadingMoreCallback.retryLoadingMore()); } } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/SearchResultActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/SearchResultActivity.java index d9421af8..a677b058 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/SearchResultActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/SearchResultActivity.java @@ -101,9 +101,9 @@ public class SearchResultActivity extends AppCompatActivity { case 0: { PostFragment mFragment = new PostFragment(); Bundle bundle = new Bundle(); - bundle.putInt(PostFragment.EXTRA_POST_TYPE_KEY, PostDataSource.TYPE_SEARCH); - bundle.putString(PostFragment.EXTRA_SUBREDDIT_NAME_KEY, mSubredditName); - bundle.putString(PostFragment.EXTRA_QUERY_KEY, mQuery); + bundle.putInt(PostFragment.EXTRA_POST_TYPE, PostDataSource.TYPE_SEARCH); + bundle.putString(PostFragment.EXTRA_SUBREDDIT_NAME, mSubredditName); + bundle.putString(PostFragment.EXTRA_QUERY, mQuery); mFragment.setArguments(bundle); return mFragment; } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/ViewPostDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/ViewPostDetailActivity.java index 8d67cd7c..903786d0 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/ViewPostDetailActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/ViewPostDetailActivity.java @@ -364,7 +364,7 @@ public class ViewPostDetailActivity extends AppCompatActivity { mProgressBar.setVisibility(View.GONE); mFetchPostInfoLinearLayout.setVisibility(View.VISIBLE); mFetchPostInfoLinearLayout.setOnClickListener(view -> fetchPostAndCommentsById(subredditId)); - mFetchPostInfoTextView.setText(R.string.error_loading_post); + mFetchPostInfoTextView.setText(R.string.load_posts_error); mGlide.load(R.drawable.load_post_error_indicator).into(mFetchPostInfoImageView); } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/ViewSubredditDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/ViewSubredditDetailActivity.java index d8f585a5..4c6abc3e 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/ViewSubredditDetailActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/ViewSubredditDetailActivity.java @@ -261,8 +261,8 @@ public class ViewSubredditDetailActivity extends AppCompatActivity { if(savedInstanceState == null) { mFragment = new PostFragment(); Bundle bundle = new Bundle(); - bundle.putString(PostFragment.EXTRA_SUBREDDIT_NAME_KEY, subredditName); - bundle.putInt(PostFragment.EXTRA_POST_TYPE_KEY, PostDataSource.TYPE_SUBREDDIT); + bundle.putString(PostFragment.EXTRA_SUBREDDIT_NAME, subredditName); + bundle.putInt(PostFragment.EXTRA_POST_TYPE, PostDataSource.TYPE_SUBREDDIT); mFragment.setArguments(bundle); getSupportFragmentManager().beginTransaction().replace(R.id.frame_layout_view_subreddit_detail_activity, mFragment).commit(); } else { @@ -270,8 +270,8 @@ public class ViewSubredditDetailActivity extends AppCompatActivity { if(mFragment == null) { mFragment = new PostFragment(); Bundle bundle = new Bundle(); - bundle.putString(PostFragment.EXTRA_SUBREDDIT_NAME_KEY, subredditName); - bundle.putInt(PostFragment.EXTRA_POST_TYPE_KEY, PostDataSource.TYPE_SUBREDDIT); + bundle.putString(PostFragment.EXTRA_SUBREDDIT_NAME, subredditName); + bundle.putInt(PostFragment.EXTRA_POST_TYPE, PostDataSource.TYPE_SUBREDDIT); mFragment.setArguments(bundle); } isInLazyMode = savedInstanceState.getBoolean(IS_IN_LAZY_MODE_STATE); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/ViewUserDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/ViewUserDetailActivity.java index 66e6257f..b0da45da 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/ViewUserDetailActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/ViewUserDetailActivity.java @@ -273,8 +273,8 @@ public class ViewUserDetailActivity extends AppCompatActivity { if(savedInstanceState == null) { /*mFragment = new PostFragment(); Bundle bundle = new Bundle(); - bundle.putString(PostFragment.EXTRA_SUBREDDIT_NAME_KEY, userName); - bundle.putInt(PostFragment.EXTRA_POST_TYPE_KEY, PostDataSource.TYPE_USER); + bundle.putString(PostFragment.EXTRA_SUBREDDIT_NAME, userName); + bundle.putInt(PostFragment.EXTRA_POST_TYPE, PostDataSource.TYPE_USER); mFragment.setArguments(bundle); getSupportFragmentManager().beginTransaction().replace(R.id.frame_layout_view_user_detail_activity, mFragment).commit();*/ } else { @@ -282,8 +282,8 @@ public class ViewUserDetailActivity extends AppCompatActivity { if(mFragment == null) { mFragment = new PostFragment(); Bundle bundle = new Bundle(); - bundle.putString(PostFragment.EXTRA_SUBREDDIT_NAME_KEY, userName); - bundle.putInt(PostFragment.EXTRA_POST_TYPE_KEY, PostDataSource.TYPE_USER); + bundle.putString(PostFragment.EXTRA_SUBREDDIT_NAME, userName); + bundle.putInt(PostFragment.EXTRA_POST_TYPE, PostDataSource.TYPE_USER); mFragment.setArguments(bundle); }*/ isInLazyMode = savedInstanceState.getBoolean(IS_IN_LAZY_MODE_STATE); @@ -430,8 +430,8 @@ public class ViewUserDetailActivity extends AppCompatActivity { if (position == 0) { PostFragment fragment = new PostFragment(); Bundle bundle = new Bundle(); - bundle.putInt(PostFragment.EXTRA_POST_TYPE_KEY, PostDataSource.TYPE_USER); - bundle.putString(PostFragment.EXTRA_SUBREDDIT_NAME_KEY, userName); + bundle.putInt(PostFragment.EXTRA_POST_TYPE, PostDataSource.TYPE_USER); + bundle.putString(PostFragment.EXTRA_SUBREDDIT_NAME, userName); fragment.setArguments(bundle); return fragment; } diff --git a/app/src/main/res/layout/fragment_comments_listing.xml b/app/src/main/res/layout/fragment_comments_listing.xml index bac6f507..a347e7af 100644 --- a/app/src/main/res/layout/fragment_comments_listing.xml +++ b/app/src/main/res/layout/fragment_comments_listing.xml @@ -26,7 +26,7 @@ <LinearLayout android:id="@+id/fetch_comments_info_linear_layout_comments_listing_fragment" android:layout_width="match_parent" - android:layout_height="match_parent" + android:layout_height="wrap_content" android:gravity="center" android:orientation="vertical" android:visibility="gone"> diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 1f7e7d08..c7c521ad 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -32,8 +32,7 @@ <string name="no_users">No users found.</string> <string name="no_storage_permission">No storage permission to save this file</string> - <string name="load_posts_failed">Error loading posts</string> - <string name="load_comments_failed">Error loading comments</string> + <string name="load_comments_failed">Error loading comments.</string> <string name="retry">Retry</string> <string name="comments">Comments</string> <string name="no_comments_yet">No comments yet. Write a comment?</string> @@ -71,8 +70,6 @@ <string name="content_description_banner_imageview">Subreddit Banner Image</string> - <string name="error_loading_posts">Error loading post</string> - <string name="app_label">Infinity</string> <string name="search_hint">Search anything</string> |