Skip to content

Commit

Permalink
One textview is enough for disabled comments
Browse files Browse the repository at this point in the history
  • Loading branch information
litetex committed Jun 20, 2021
1 parent a0677e6 commit cf8a141
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
public class CommentsFragment extends BaseListInfoFragment<CommentsInfo> {
private final CompositeDisposable disposables = new CompositeDisposable();

private TextView commentsDisabledView;
private TextView emptyStateDesc;

public static CommentsFragment getInstance(final int serviceId, final String url,
final String name) {
Expand All @@ -42,7 +42,7 @@ public CommentsFragment() {
protected void initViews(final View rootView, final Bundle savedInstanceState) {
super.initViews(rootView, savedInstanceState);

commentsDisabledView = rootView.findViewById(R.id.comments_disabled);
emptyStateDesc = rootView.findViewById(R.id.empty_state_desc);
}

/*//////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -84,8 +84,10 @@ protected Single<CommentsInfo> loadResult(final boolean forceLoad) {
public void handleResult(@NonNull final CommentsInfo result) {
super.handleResult(result);

commentsDisabledView.setVisibility(
result.isCommentsDisabled() ? View.VISIBLE : View.GONE);
emptyStateDesc.setText(
result.isCommentsDisabled()
? R.string.comments_are_disabled
: R.string.no_comments);

ViewUtils.slideUp(requireView(), 120, 150, 0.06f);
disposables.clear();
Expand Down
12 changes: 1 addition & 11 deletions app/src/main/res/layout/fragment_comments.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
tools:ignore="HardcodedText,UnusedAttribute" />

<TextView
android:id="@+id/empty_state_desc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
Expand All @@ -49,17 +50,6 @@

</LinearLayout>

<TextView
android:id="@+id/comments_disabled"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/empty_state_view"
android:layout_centerHorizontal="true"
android:text="@string/comments_are_disabled"
android:textSize="20sp"
android:visibility="gone"
tools:visibility="visible" />

<!--ERROR PANEL-->
<include
android:id="@+id/error_panel"
Expand Down

0 comments on commit cf8a141

Please sign in to comment.