Tap the error view to retry loading comments in ViewPostDetailActivity. Minor UI tweaks.

This commit is contained in:
Alex Ning
2019-08-26 15:55:18 +08:00
parent 5e144c6de9
commit 1da0e08552
13 changed files with 49 additions and 13 deletions

View File

@@ -86,6 +86,7 @@ class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVie
interface CommentRecyclerViewAdapterCallback {
void updatePost(Post post);
void retryFetchingComments();
void retryFetchingMoreComments();
}
@@ -1413,6 +1414,9 @@ class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVie
class LoadCommentsFailedViewHolder extends RecyclerView.ViewHolder {
LoadCommentsFailedViewHolder(@NonNull View itemView) {
super(itemView);
itemView.setOnClickListener(view -> {
mCommentRecyclerViewAdapterCallback.retryFetchingComments();
});
}
}

View File

@@ -6,7 +6,6 @@ import android.content.res.Resources;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
@@ -117,6 +116,13 @@ public class RulesActivity extends AppCompatActivity {
params.topMargin = getResources().getDimensionPixelSize(statusBarResourceId);
toolbar.setLayoutParams(params);
}
if (resources.getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT || resources.getBoolean(R.bool.isTablet)) {
int navBarResourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android");
if (navBarResourceId > 0) {
recyclerView.setPadding(0, 0, 0, resources.getDimensionPixelSize(navBarResourceId));
}
}
}
}
@@ -240,7 +246,6 @@ public class RulesActivity extends AppCompatActivity {
String shortName = rulesArray.getJSONObject(i).getString(JSONUtils.SHORT_NAME_KEY);
String description = null;
if(rulesArray.getJSONObject(i).has(JSONUtils.DESCRIPTION_KEY)) {
Log.i("asdfasdf", "" + rulesArray.getJSONObject(i).getString(JSONUtils.DESCRIPTION_KEY));
description = Utils.addSubredditAndUserLink(rulesArray.getJSONObject(i).getString(JSONUtils.DESCRIPTION_KEY));
}
rules.add(new Rule(shortName, description));

View File

@@ -351,6 +351,11 @@ public class ViewPostDetailActivity extends AppCompatActivity implements FlairBo
EventBus.getDefault().post(new PostUpdateEventToPostList(mPost, postListPosition));
}
@Override
public void retryFetchingComments() {
fetchComments(false);
}
@Override
public void retryFetchingMoreComments() {
isLoadingMoreChildren = false;
@@ -443,6 +448,11 @@ public class ViewPostDetailActivity extends AppCompatActivity implements FlairBo
EventBus.getDefault().post(new PostUpdateEventToPostList(mPost, postListPosition));
}
@Override
public void retryFetchingComments() {
fetchComments(false);
}
@Override
public void retryFetchingMoreComments() {
isLoadingMoreChildren = false;