From 0f1c4d1e11a3b072d2bb1a60c52f858c79c6e0ae Mon Sep 17 00:00:00 2001 From: Sergei Kozelko Date: Fri, 11 Nov 2022 12:32:58 +0700 Subject: Switch loading more comments to /morechildren endpoint (#1186) * Load more comments from /morechildren endpoint Previous implementation requested comments from /api/info which returned the comments themselves but did not include any information about their children. Also /api/info does not allow to specify sort type. On the other hand /morechildren supports sort type and it will be added in a later commit. I am not proud of this implementation, but I had to fight with both Reddit api response and existing code. The problem with api response is that it is a flat list of comments, not a tree structure. So the tree has to be rebuilt on our end. And the problem with existing code is that it merges "more children" node into its parent but then adds a placeholder anyways. The code relies on the fact that parent comment will be located before any of its children in the response. The code sequentially processes comments, tries to find their parents and either adds them to the tree or puts in a "top-level" array which will be handled by outside code. One possible problem is the removal of `depth` argument from parsing as I couldn't find a way to fit it in the new logic. However I also didn't experience any problems with it during my testing and the response seems to always contain depth key. Moreover current depth handling logic in ParseComment#parseCommentRecursion is broken because it does not increment depth when making a recursive call. * Store moreChildren ids instead of fullnames /morechildren endpoint accepts ids instead of fullnames so there is no point in converting ids to fullnames and back * Send all comment ids to Reddit so it can select what to display itself Sending all ids allows Reddit to sort them properly. Since the number of comments can be very bing, it requires using POST request instead of GET. This commit changes the meaning of Comment#moreChildrenIds field, now it stores only ids of comments that are not yet loaded. This simplifies the code and removes the need for Comment#moreChildrenStartingIndex * Fetch more comments with current sort type --- .../adapters/CommentsRecyclerViewAdapter.java | 21 ++-- .../infinityforreddit/apis/RedditAPI.java | 9 ++ .../infinityforreddit/comment/Comment.java | 36 ++---- .../infinityforreddit/comment/FetchComment.java | 35 +++--- .../infinityforreddit/comment/ParseComment.java | 121 ++++++++++++++++++--- .../fragments/ViewPostDetailFragment.java | 28 +++-- 6 files changed, 167 insertions(+), 83 deletions(-) (limited to 'app/src/main') diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsRecyclerViewAdapter.java index 1271cfc2..29c3f828 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsRecyclerViewAdapter.java @@ -607,18 +607,17 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter expandedComments, - int childrenStartingIndex) { + public void onFetchMoreCommentSuccess(ArrayList expandedComments, ArrayList moreChildrenIds) { if (mVisibleComments.size() > parentPosition && parentComment.getFullName().equals(mVisibleComments.get(parentPosition).getFullName())) { if (mVisibleComments.get(parentPosition).isExpanded()) { - if (mVisibleComments.get(parentPosition).getChildren().size() > childrenStartingIndex) { - mVisibleComments.get(parentPosition).setMoreChildrenStartingIndex(childrenStartingIndex); + if (!moreChildrenIds.isEmpty()) { + mVisibleComments.get(parentPosition).setMoreChildrenIds(moreChildrenIds); mVisibleComments.get(parentPosition).getChildren().get(mVisibleComments.get(parentPosition).getChildren().size() - 1) .setLoadingMoreChildren(false); mVisibleComments.get(parentPosition).getChildren().get(mVisibleComments.get(parentPosition).getChildren().size() - 1) @@ -647,7 +646,7 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter postSiteAdmin(@HeaderMap Map headers, @FieldMap Map params); + + @FormUrlEncoded + @POST("/api/morechildren.json?raw_json=1&api_type=json") + Call moreChildren(@Field("link_id") String linkId, @Field("children") String children, @Field("sort") String sort); + + @FormUrlEncoded + @POST("/api/morechildren.json?raw_json=1&api_type=json") + Call moreChildrenOauth(@Field("link_id") String linkId, @Field("children") String children, @Field("sort") String sort, @HeaderMap Map headers); } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/comment/Comment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/comment/Comment.java index 15b1b68d..d6a6f173 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/comment/Comment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/comment/Comment.java @@ -53,8 +53,7 @@ public class Comment implements Parcelable { private boolean isExpanded; private boolean hasExpandedBefore; private ArrayList children; - private ArrayList moreChildrenFullnames; - private int moreChildrenStartingIndex; + private ArrayList moreChildrenIds; private int placeholderType; private boolean isLoadingMoreChildren; private boolean loadMoreChildrenFailed; @@ -91,7 +90,6 @@ public class Comment implements Parcelable { this.saved = saved; this.isExpanded = false; this.hasExpandedBefore = false; - moreChildrenStartingIndex = 0; placeholderType = NOT_PLACEHOLDER; } @@ -141,9 +139,8 @@ public class Comment implements Parcelable { hasExpandedBefore = in.readByte() != 0; children = new ArrayList<>(); in.readTypedList(children, Comment.CREATOR); - moreChildrenFullnames = new ArrayList<>(); - in.readStringList(moreChildrenFullnames); - moreChildrenStartingIndex = in.readInt(); + moreChildrenIds = new ArrayList<>(); + in.readStringList(moreChildrenIds); placeholderType = in.readInt(); isLoadingMoreChildren = in.readByte() != 0; loadMoreChildrenFailed = in.readByte() != 0; @@ -345,28 +342,20 @@ public class Comment implements Parcelable { children.add(position, comment); } - public ArrayList getMoreChildrenFullnames() { - return moreChildrenFullnames; + public ArrayList getMoreChildrenIds() { + return moreChildrenIds; } - public void setMoreChildrenFullnames(ArrayList moreChildrenFullnames) { - this.moreChildrenFullnames = moreChildrenFullnames; + public void setMoreChildrenIds(ArrayList moreChildrenIds) { + this.moreChildrenIds = moreChildrenIds; } - public boolean hasMoreChildrenFullnames() { - return moreChildrenFullnames != null; + public boolean hasMoreChildrenIds() { + return moreChildrenIds != null; } - public void removeMoreChildrenFullnames() { - moreChildrenFullnames.clear(); - } - - public int getMoreChildrenStartingIndex() { - return moreChildrenStartingIndex; - } - - public void setMoreChildrenStartingIndex(int moreChildrenStartingIndex) { - this.moreChildrenStartingIndex = moreChildrenStartingIndex; + public void removeMoreChildrenIds() { + moreChildrenIds.clear(); } public int getPlaceholderType() { @@ -423,8 +412,7 @@ public class Comment implements Parcelable { parcel.writeByte((byte) (isExpanded ? 1 : 0)); parcel.writeByte((byte) (hasExpandedBefore ? 1 : 0)); parcel.writeTypedList(children); - parcel.writeStringList(moreChildrenFullnames); - parcel.writeInt(moreChildrenStartingIndex); + parcel.writeStringList(moreChildrenIds); parcel.writeInt(placeholderType); parcel.writeByte((byte) (isLoadingMoreChildren ? 1 : 0)); parcel.writeByte((byte) (loadMoreChildrenFailed ? 1 : 0)); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/comment/FetchComment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/comment/FetchComment.java index 6162865b..a0d62086 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/comment/FetchComment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/comment/FetchComment.java @@ -46,9 +46,9 @@ public class FetchComment { expandChildren, new ParseComment.ParseCommentListener() { @Override public void onParseCommentSuccess(ArrayList expandedComments, - String parentId, ArrayList moreChildrenFullnames) { + String parentId, ArrayList moreChildrenIds) { fetchCommentListener.onFetchCommentSuccess(expandedComments, parentId, - moreChildrenFullnames); + moreChildrenIds); } @Override @@ -70,33 +70,27 @@ public class FetchComment { public static void fetchMoreComment(Executor executor, Handler handler, Retrofit retrofit, @Nullable String accessToken, - ArrayList allChildren, int startingIndex, - int depth, boolean expandChildren, + ArrayList allChildren, + boolean expandChildren, String postFullName, + String sortType, FetchMoreCommentListener fetchMoreCommentListener) { if (allChildren == null) { return; } - StringBuilder stringBuilder = new StringBuilder(); - for (int i = 0; i < 100; i++) { - if (allChildren.size() <= startingIndex + i) { - break; - } - stringBuilder.append(allChildren.get(startingIndex + i)).append(","); - } + String childrenIds = String.join(",", allChildren); - if (stringBuilder.length() == 0) { + if (childrenIds.isEmpty()) { return; } - stringBuilder.deleteCharAt(stringBuilder.length() - 1); - RedditAPI api = retrofit.create(RedditAPI.class); Call moreComments; if (accessToken == null) { - moreComments = api.getInfo(stringBuilder.toString()); + moreComments = api.moreChildren(postFullName, childrenIds, sortType); } else { - moreComments = api.getInfoOauth(stringBuilder.toString(), APIUtils.getOAuthHeader(accessToken)); + moreComments = api.moreChildrenOauth(postFullName, childrenIds, + sortType, APIUtils.getOAuthHeader(accessToken)); } moreComments.enqueue(new Callback() { @@ -104,12 +98,11 @@ public class FetchComment { public void onResponse(@NonNull Call call, @NonNull Response response) { if (response.isSuccessful()) { ParseComment.parseMoreComment(executor, handler, response.body(), new ArrayList<>(), - depth, expandChildren, new ParseComment.ParseCommentListener() { + expandChildren, new ParseComment.ParseCommentListener() { @Override public void onParseCommentSuccess(ArrayList expandedComments, - String parentId, ArrayList moreChildrenFullnames) { - fetchMoreCommentListener.onFetchMoreCommentSuccess(expandedComments, - startingIndex + 100); + String parentId, ArrayList moreChildrenIds) { + fetchMoreCommentListener.onFetchMoreCommentSuccess(expandedComments, moreChildrenIds); } @Override @@ -136,7 +129,7 @@ public class FetchComment { } public interface FetchMoreCommentListener { - void onFetchMoreCommentSuccess(ArrayList expandedComments, int childrenStartingIndex); + void onFetchMoreCommentSuccess(ArrayList expandedComments, ArrayList moreChildrenIds); void onFetchMoreCommentFailed(); } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/comment/ParseComment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/comment/ParseComment.java index 0a341ff3..62b87a1f 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/comment/ParseComment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/comment/ParseComment.java @@ -6,7 +6,9 @@ import static ml.docilealligator.infinityforreddit.comment.Comment.VOTE_TYPE_UPV import android.os.Handler; import android.text.Html; +import android.util.Log; +import androidx.annotation.NonNull; import androidx.annotation.Nullable; import org.json.JSONArray; @@ -14,6 +16,7 @@ import org.json.JSONException; import org.json.JSONObject; import java.util.ArrayList; +import java.util.List; import java.util.concurrent.Executor; import ml.docilealligator.infinityforreddit.utils.JSONUtils; @@ -31,10 +34,10 @@ public class ParseComment { childrenArray = childrenArray.getJSONObject(1).getJSONObject(JSONUtils.DATA_KEY).getJSONArray(JSONUtils.CHILDREN_KEY); ArrayList expandedNewComments = new ArrayList<>(); - ArrayList moreChildrenFullnames = new ArrayList<>(); + ArrayList moreChildrenIds = new ArrayList<>(); ArrayList newComments = new ArrayList<>(); - parseCommentRecursion(childrenArray, newComments, moreChildrenFullnames, 0); + parseCommentRecursion(childrenArray, newComments, moreChildrenIds, 0); expandChildren(newComments, expandedNewComments, expandChildren); if (expandChildren) { @@ -43,7 +46,7 @@ public class ParseComment { commentData.addAll(newComments); } - handler.post(() -> parseCommentListener.onParseCommentSuccess(commentData, parentId, moreChildrenFullnames)); + handler.post(() -> parseCommentListener.onParseCommentSuccess(commentData, parentId, moreChildrenIds)); } catch (JSONException e) { e.printStackTrace(); handler.post(parseCommentListener::onParseCommentFailed); @@ -52,17 +55,75 @@ public class ParseComment { } static void parseMoreComment(Executor executor, Handler handler, String response, - ArrayList commentData, int depth, boolean expandChildren, + ArrayList commentData, boolean expandChildren, ParseCommentListener parseCommentListener) { executor.execute(() -> { try { - JSONArray childrenArray = new JSONObject(response).getJSONObject(JSONUtils.DATA_KEY).getJSONArray(JSONUtils.CHILDREN_KEY); + JSONArray childrenArray = new JSONObject(response).getJSONObject(JSONUtils.JSON_KEY) + .getJSONObject(JSONUtils.DATA_KEY).getJSONArray(JSONUtils.THINGS_KEY); ArrayList newComments = new ArrayList<>(); ArrayList expandedNewComments = new ArrayList<>(); - ArrayList moreChildrenFullnames = new ArrayList<>(); + ArrayList moreChildrenIds = new ArrayList<>(); + + // api response is a flat list of comments tree + // process it in order and rebuild the tree + for (int i = 0; i < childrenArray.length(); i++) { + JSONObject child = childrenArray.getJSONObject(i); + JSONObject childData = child.getJSONObject(JSONUtils.DATA_KEY); + if (child.getString(JSONUtils.KIND_KEY).equals(JSONUtils.KIND_VALUE_MORE)) { + String parentFullName = childData.getString(JSONUtils.PARENT_ID_KEY); + JSONArray childrenIds = childData.getJSONArray(JSONUtils.CHILDREN_KEY); + + if (childrenIds.length() != 0) { + ArrayList localMoreChildrenIds = new ArrayList<>(childrenIds.length()); + for (int j = 0; j < childrenIds.length(); j++) { + localMoreChildrenIds.add(childrenIds.getString(j)); + } + + Comment parentComment = findCommentByFullName(newComments, parentFullName); + if (parentComment != null) { + parentComment.setHasReply(true); + parentComment.setMoreChildrenIds(localMoreChildrenIds); + parentComment.addChildren(new ArrayList<>()); // ensure children list is not null + } else { + // assume that it is parent of this call + moreChildrenIds.addAll(localMoreChildrenIds); + } + } else { + Comment continueThreadPlaceholder = new Comment( + parentFullName, + childData.getInt(JSONUtils.DEPTH_KEY), + Comment.PLACEHOLDER_CONTINUE_THREAD + ); + + Comment parentComment = findCommentByFullName(newComments, parentFullName); + if (parentComment != null) { + parentComment.setHasReply(true); + parentComment.addChild(continueThreadPlaceholder, parentComment.getChildCount()); + parentComment.setChildCount(parentComment.getChildCount() + 1); + } else { + // assume that it is parent of this call + newComments.add(continueThreadPlaceholder); + } + } + } else { + Comment comment = parseSingleComment(childData, 0); + String parentFullName = comment.getParentId(); + + Comment parentComment = findCommentByFullName(newComments, parentFullName); + if (parentComment != null) { + parentComment.setHasReply(true); + parentComment.addChild(comment, parentComment.getChildCount()); + parentComment.setChildCount(parentComment.getChildCount() + 1); + } else { + // assume that it is parent of this call + newComments.add(comment); + } + } + } - parseCommentRecursion(childrenArray, newComments, moreChildrenFullnames, depth); + updateChildrenCount(newComments); expandChildren(newComments, expandedNewComments, expandChildren); if (expandChildren) { @@ -71,7 +132,7 @@ public class ParseComment { commentData.addAll(newComments); } - handler.post(() -> parseCommentListener.onParseCommentSuccess(commentData, null, moreChildrenFullnames)); + handler.post(() -> parseCommentListener.onParseCommentSuccess(commentData, null, moreChildrenIds)); } catch (JSONException e) { e.printStackTrace(); handler.post(parseCommentListener::onParseCommentFailed); @@ -96,7 +157,7 @@ public class ParseComment { } private static void parseCommentRecursion(JSONArray comments, ArrayList newCommentData, - ArrayList moreChildrenFullnames, int depth) throws JSONException { + ArrayList moreChildrenIds, int depth) throws JSONException { int actualCommentLength; if (comments.length() == 0) { @@ -105,17 +166,17 @@ public class ParseComment { JSONObject more = comments.getJSONObject(comments.length() - 1).getJSONObject(JSONUtils.DATA_KEY); - //Maybe moreChildrenFullnames contain only commentsJSONArray and no more info + //Maybe moreChildrenIds contain only commentsJSONArray and no more info if (more.has(JSONUtils.COUNT_KEY)) { JSONArray childrenArray = more.getJSONArray(JSONUtils.CHILDREN_KEY); for (int i = 0; i < childrenArray.length(); i++) { - moreChildrenFullnames.add("t1_" + childrenArray.getString(i)); + moreChildrenIds.add(childrenArray.getString(i)); } actualCommentLength = comments.length() - 1; - if (moreChildrenFullnames.isEmpty() && comments.getJSONObject(comments.length() - 1).getString(JSONUtils.KIND_KEY).equals(JSONUtils.KIND_VALUE_MORE)) { + if (moreChildrenIds.isEmpty() && comments.getJSONObject(comments.length() - 1).getString(JSONUtils.KIND_KEY).equals(JSONUtils.KIND_VALUE_MORE)) { newCommentData.add(new Comment(more.getString(JSONUtils.PARENT_ID_KEY), more.getInt(JSONUtils.DEPTH_KEY), Comment.PLACEHOLDER_CONTINUE_THREAD)); return; } @@ -131,10 +192,10 @@ public class ParseComment { JSONArray childrenArray = data.getJSONObject(JSONUtils.REPLIES_KEY) .getJSONObject(JSONUtils.DATA_KEY).getJSONArray(JSONUtils.CHILDREN_KEY); ArrayList children = new ArrayList<>(); - ArrayList nextMoreChildrenFullnames = new ArrayList<>(); - parseCommentRecursion(childrenArray, children, nextMoreChildrenFullnames, singleComment.getDepth()); + ArrayList nextMoreChildrenIds = new ArrayList<>(); + parseCommentRecursion(childrenArray, children, nextMoreChildrenIds, singleComment.getDepth()); singleComment.addChildren(children); - singleComment.setMoreChildrenFullnames(nextMoreChildrenFullnames); + singleComment.setMoreChildrenIds(nextMoreChildrenIds); singleComment.setChildCount(getChildCount(singleComment)); } @@ -165,7 +226,7 @@ public class ParseComment { } else { c.setExpanded(true); } - if (c.hasMoreChildrenFullnames() && c.getMoreChildrenFullnames().size() > c.getMoreChildrenStartingIndex()) { + if (c.hasMoreChildrenIds() && !c.getMoreChildrenIds().isEmpty()) { //Add a load more placeholder Comment placeholder = new Comment(c.getFullName(), c.getDepth() + 1, Comment.PLACEHOLDER_LOAD_MORE_COMMENTS); visibleComments.add(placeholder); @@ -277,9 +338,35 @@ public class ParseComment { return null; } + @Nullable + private static Comment findCommentByFullName(@NonNull List comments, @NonNull String fullName) { + for (Comment comment: comments) { + if (comment.getFullName().equals(fullName) && + comment.getPlaceholderType() == Comment.NOT_PLACEHOLDER) { + return comment; + } + if (comment.getChildren() != null) { + Comment result = findCommentByFullName(comment.getChildren(), fullName); + if (result != null) { + return result; + } + } + } + return null; + } + + private static void updateChildrenCount(@NonNull List comments) { + for (Comment comment: comments) { + comment.setChildCount(getChildCount(comment)); + if (comment.getChildren() != null) { + updateChildrenCount(comment.getChildren()); + } + } + } + public interface ParseCommentListener { void onParseCommentSuccess(ArrayList expandedComments, String parentId, - ArrayList moreChildrenFullnames); + ArrayList moreChildrenIds); void onParseCommentFailed(); } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragment.java index 87f42698..1f1e2b6f 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragment.java @@ -202,8 +202,6 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic @State ArrayList children; @State - int mChildrenStartingIndex = 0; - @State boolean loadMoreChildrenSuccess = true; @State boolean hasMoreChildren; @@ -621,6 +619,11 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic fetchMoreComments(); } + + @Override + public String getSortType() { + return sortType; + } }); if (mCommentsRecyclerView != null) { mRecyclerView.setAdapter(mPostAdapter); @@ -810,7 +813,6 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic public void changeSortType(SortType sortType) { mFetchPostInfoLinearLayout.setVisibility(View.GONE); mGlide.clear(mFetchPostInfoImageView); - mChildrenStartingIndex = 0; if (children != null) { children.clear(); } @@ -1328,6 +1330,11 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic fetchMoreComments(); } + + @Override + public String getSortType() { + return sortType; + } }); if (mCommentsRecyclerView != null) { mRecyclerView.setAdapter(mPostAdapter); @@ -1343,8 +1350,8 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic ParseComment.parseComment(mExecutor, new Handler(), response.body(), new ArrayList<>(), mExpandChildren, new ParseComment.ParseCommentListener() { @Override - public void onParseCommentSuccess(ArrayList expandedComments, String parentId, ArrayList moreChildrenFullnames) { - ViewPostDetailFragment.this.children = moreChildrenFullnames; + public void onParseCommentSuccess(ArrayList expandedComments, String parentId, ArrayList moreChildrenIds) { + ViewPostDetailFragment.this.children = moreChildrenIds; hasMoreChildren = children.size() != 0; mCommentsAdapter.addComments(expandedComments, hasMoreChildren); @@ -1567,13 +1574,13 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic isLoadingMoreChildren = true; Retrofit retrofit = mAccessToken == null ? mRetrofit : mOauthRetrofit; - FetchComment.fetchMoreComment(mExecutor, new Handler(), retrofit, mAccessToken, children, mChildrenStartingIndex, - 0, mExpandChildren, new FetchComment.FetchMoreCommentListener() { + FetchComment.fetchMoreComment(mExecutor, new Handler(), retrofit, mAccessToken, children, + mExpandChildren, mPost.getFullName(), sortType, new FetchComment.FetchMoreCommentListener() { @Override - public void onFetchMoreCommentSuccess(ArrayList expandedComments, int childrenStartingIndex) { - hasMoreChildren = childrenStartingIndex < children.size(); + public void onFetchMoreCommentSuccess(ArrayList expandedComments, ArrayList moreChildrenIds) { + children = moreChildrenIds; + hasMoreChildren = !children.isEmpty(); mCommentsAdapter.addComments(expandedComments, hasMoreChildren); - mChildrenStartingIndex = childrenStartingIndex; isLoadingMoreChildren = false; loadMoreChildrenSuccess = true; } @@ -1590,7 +1597,6 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic public void refresh(boolean fetchPost, boolean fetchComments) { if (mPostAdapter != null && !isRefreshing) { isRefreshing = true; - mChildrenStartingIndex = 0; mFetchPostInfoLinearLayout.setVisibility(View.GONE); mGlide.clear(mFetchPostInfoImageView); -- cgit v1.2.3