mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2025-02-23 13:13:59 +01:00
Load comments of comments one more time, just like parent-level comments.
This commit is contained in:
parent
c00aaf04b9
commit
70fcc671d8
@ -9,7 +9,6 @@ import android.support.annotation.NonNull;
|
|||||||
import android.support.customtabs.CustomTabsIntent;
|
import android.support.customtabs.CustomTabsIntent;
|
||||||
import android.support.v4.content.ContextCompat;
|
import android.support.v4.content.ContextCompat;
|
||||||
import android.support.v7.widget.RecyclerView;
|
import android.support.v7.widget.RecyclerView;
|
||||||
import android.util.Log;
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
@ -111,15 +110,11 @@ class CommentMultiLevelRecyclerViewAdapter extends MultiLevelAdapter {
|
|||||||
setExpandButton(((CommentViewHolder) holder).expandButton, commentItem.isExpanded());
|
setExpandButton(((CommentViewHolder) holder).expandButton, commentItem.isExpanded());
|
||||||
} else {
|
} else {
|
||||||
((CommentViewHolder) holder).loadMoreCommentsProgressBar.setVisibility(View.VISIBLE);
|
((CommentViewHolder) holder).loadMoreCommentsProgressBar.setVisibility(View.VISIBLE);
|
||||||
FetchComment.fetchComment(mRetrofit, subredditNamePrefixed, article, commentItem.getId(),
|
FetchComment.fetchAllComment(mRetrofit, subredditNamePrefixed, article, commentItem.getId(),
|
||||||
locale, false, commentItem.getDepth(), new FetchComment.FetchCommentListener() {
|
locale, false, commentItem.getDepth(), new FetchComment.FetchAllCommentListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onFetchCommentSuccess(List<?> commentData,
|
public void onFetchAllCommentSuccess(List<?> commentData) {
|
||||||
String parentId, String commaSeparatedChildren) {
|
|
||||||
commentItem.addChildren((List<RecyclerViewItem>) commentData);
|
commentItem.addChildren((List<RecyclerViewItem>) commentData);
|
||||||
for (RecyclerViewItem r : (List<RecyclerViewItem>) commentData) {
|
|
||||||
Log.i("asdfasdfasd", Integer.toString(r.getLevel()));
|
|
||||||
}
|
|
||||||
((CommentViewHolder) holder).loadMoreCommentsProgressBar
|
((CommentViewHolder) holder).loadMoreCommentsProgressBar
|
||||||
.setVisibility(View.GONE);
|
.setVisibility(View.GONE);
|
||||||
mMultiLevelRecyclerView.toggleItemsGroup(holder.getAdapterPosition());
|
mMultiLevelRecyclerView.toggleItemsGroup(holder.getAdapterPosition());
|
||||||
@ -128,7 +123,7 @@ class CommentMultiLevelRecyclerViewAdapter extends MultiLevelAdapter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFetchCommentFailed() {
|
public void onFetchAllCommentFailed() {
|
||||||
((CommentViewHolder) holder).loadMoreCommentsProgressBar
|
((CommentViewHolder) holder).loadMoreCommentsProgressBar
|
||||||
.setVisibility(View.GONE);
|
.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,11 @@ class FetchComment {
|
|||||||
void onFetchMoreCommentFailed();
|
void onFetchMoreCommentFailed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface FetchAllCommentListener {
|
||||||
|
void onFetchAllCommentSuccess(List<?> commentData);
|
||||||
|
void onFetchAllCommentFailed();
|
||||||
|
}
|
||||||
|
|
||||||
static void fetchComment(Retrofit retrofit, String subredditNamePrefixed, String article,
|
static void fetchComment(Retrofit retrofit, String subredditNamePrefixed, String article,
|
||||||
String comment, Locale locale, boolean isPost, int parentDepth,
|
String comment, Locale locale, boolean isPost, int parentDepth,
|
||||||
final FetchCommentListener fetchCommentListener) {
|
final FetchCommentListener fetchCommentListener) {
|
||||||
@ -126,4 +131,40 @@ class FetchComment {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void fetchAllComment(Retrofit retrofit, String subredditNamePrefixed, String article,
|
||||||
|
String comment, Locale locale, boolean isPost, int parentDepth,
|
||||||
|
FetchAllCommentListener fetchAllCommentListener) {
|
||||||
|
fetchComment(retrofit, subredditNamePrefixed, article, comment, locale, isPost, parentDepth,
|
||||||
|
new FetchCommentListener() {
|
||||||
|
@Override
|
||||||
|
public void onFetchCommentSuccess(List<?> commentData, String parentId, String commaSeparatedChildren) {
|
||||||
|
if(!commaSeparatedChildren.equals("")) {
|
||||||
|
fetchMoreComment(retrofit, subredditNamePrefixed, parentId, commaSeparatedChildren,
|
||||||
|
locale, new FetchMoreCommentListener() {
|
||||||
|
@Override
|
||||||
|
public void onFetchMoreCommentSuccess(List<?> moreCommentData) {
|
||||||
|
((ArrayList<CommentData>)commentData).addAll((ArrayList<CommentData>) moreCommentData);
|
||||||
|
fetchAllCommentListener.onFetchAllCommentSuccess(commentData);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFetchMoreCommentFailed() {
|
||||||
|
Log.i("fetch more comment", "error");
|
||||||
|
fetchAllCommentListener.onFetchAllCommentFailed();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
fetchAllCommentListener.onFetchAllCommentSuccess(commentData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFetchCommentFailed() {
|
||||||
|
Log.i("fetch comment", "error");
|
||||||
|
fetchAllCommentListener.onFetchAllCommentFailed();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user