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;

View File

@ -64,7 +64,7 @@
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:text="@string/rules"
android:textColor="@color/colorAccent" />
android:textColor="@android:color/white" />
</RelativeLayout>
@ -156,7 +156,9 @@
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toStartOf="@+id/select_from_library_fab_post_image_activity"
app:layout_constraintHorizontal_chainStyle="spread" />
app:layout_constraintHorizontal_chainStyle="spread"
app:backgroundTint="@color/backgroundColorPrimary"
app:tint="@android:color/white" />
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/select_from_library_fab_post_image_activity"
@ -167,7 +169,9 @@
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@+id/capture_fab_post_image_activity"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_chainStyle="spread" />
app:layout_constraintHorizontal_chainStyle="spread"
app:backgroundTint="@color/backgroundColorPrimary"
app:tint="@android:color/white" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -64,7 +64,7 @@
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:text="@string/rules"
android:textColor="@color/colorAccent" />
android:textColor="@android:color/white" />
</RelativeLayout>

View File

@ -64,7 +64,7 @@
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:text="@string/rules"
android:textColor="@color/colorAccent" />
android:textColor="@android:color/white" />
</RelativeLayout>

View File

@ -64,7 +64,7 @@
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:text="@string/rules"
android:textColor="@color/colorAccent" />
android:textColor="@android:color/white" />
</RelativeLayout>
@ -156,7 +156,9 @@
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toStartOf="@+id/select_from_library_fab_post_video_activity"
app:layout_constraintHorizontal_chainStyle="spread" />
app:layout_constraintHorizontal_chainStyle="spread"
app:backgroundTint="@color/backgroundColorPrimary"
app:tint="@android:color/white" />
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/select_from_library_fab_post_video_activity"
@ -167,7 +169,9 @@
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@+id/capture_fab_post_video_activity"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_chainStyle="spread" />
app:layout_constraintHorizontal_chainStyle="spread"
app:backgroundTint="@color/backgroundColorPrimary"
app:tint="@android:color/white" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -125,6 +125,8 @@
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="@dimen/fab_margin"
app:backgroundTint="@color/backgroundColorPrimary"
app:tint="@android:color/white"
app:srcCompat="@drawable/baseline_add_white_24" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>

View File

@ -72,6 +72,8 @@
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="@dimen/fab_margin"
app:backgroundTint="@color/backgroundColorPrimary"
app:tint="@android:color/white"
app:srcCompat="@drawable/baseline_add_white_24" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>

View File

@ -9,12 +9,13 @@
android:layout_width="150dp"
android:layout_height="150dp"
android:layout_gravity="center_horizontal"
android:src="@drawable/load_post_error_indicator"/>
android:src="@drawable/load_post_error_indicator" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="@string/load_comments_failed"/>
android:gravity="center"
android:text="@string/load_comments_failed" />
</LinearLayout>

View File

@ -22,6 +22,8 @@
<color name="backgroundColor">#121212</color>
<color name="backgroundColorPrimary">#1565C0</color>
<color name="backgroundColorPrimaryDark">#1565C0</color>
<color name="roundedBottomSheetPrimaryBackground">#242424</color>

View File

@ -22,6 +22,8 @@
<color name="backgroundColor">#FFFFFF</color>
<color name="backgroundColorPrimary">@color/colorPrimary</color>
<color name="backgroundColorPrimaryDark">@color/colorPrimaryDark</color>
<color name="roundedBottomSheetPrimaryBackground">#FFFFFF</color>

View File

@ -52,7 +52,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_comments_failed">Error loading comments</string>
<string name="load_comments_failed">Error loading comments.\nTap to retry.</string>
<string name="retry">Retry</string>
<string name="comments">Comments</string>
<string name="no_comments_yet">No comments yet. Write a comment?</string>