* Make image in BackgroundMessageView adapt to the height, fix #1618 * Hide filters panel when showing status view in notifications
This commit is contained in:
parent
d9c802982e
commit
656644b7cb
6 changed files with 29 additions and 7 deletions
|
@ -167,6 +167,7 @@ public class NotificationsFragment extends SFragment implements
|
|||
private boolean alwaysShowSensitiveMedia;
|
||||
private boolean alwaysOpenSpoiler;
|
||||
private boolean showNotificationsFilter;
|
||||
private boolean showingError;
|
||||
|
||||
// Each element is either a Notification for loading data or a Placeholder
|
||||
private final PairedList<Either<Placeholder, Notification>, NotificationViewData> notifications
|
||||
|
@ -280,7 +281,7 @@ public class NotificationsFragment extends SFragment implements
|
|||
private void updateFilterVisibility() {
|
||||
CoordinatorLayout.LayoutParams params =
|
||||
(CoordinatorLayout.LayoutParams) swipeRefreshLayout.getLayoutParams();
|
||||
if (showNotificationsFilter) {
|
||||
if (showNotificationsFilter && !showingError && !notifications.isEmpty()) {
|
||||
appBarOptions.setExpanded(true, false);
|
||||
appBarOptions.setVisibility(View.VISIBLE);
|
||||
//Set content behaviour to hide filter on scroll
|
||||
|
@ -392,6 +393,7 @@ public class NotificationsFragment extends SFragment implements
|
|||
@Override
|
||||
public void onRefresh() {
|
||||
this.statusView.setVisibility(View.GONE);
|
||||
this.showingError = false;
|
||||
Either<Placeholder, Notification> first = CollectionsKt.firstOrNull(this.notifications);
|
||||
String topId;
|
||||
if (first != null && first.isRight()) {
|
||||
|
@ -669,6 +671,7 @@ public class NotificationsFragment extends SFragment implements
|
|||
//Show friend elephant
|
||||
this.statusView.setVisibility(View.VISIBLE);
|
||||
this.statusView.setup(R.drawable.elephant_friend_empty, R.string.message_empty, null);
|
||||
updateFilterVisibility();
|
||||
|
||||
//Update adapter
|
||||
updateAdapter();
|
||||
|
@ -994,6 +997,7 @@ public class NotificationsFragment extends SFragment implements
|
|||
} else {
|
||||
swipeRefreshLayout.setEnabled(true);
|
||||
}
|
||||
updateFilterVisibility();
|
||||
swipeRefreshLayout.setRefreshing(false);
|
||||
progressBar.setVisibility(View.GONE);
|
||||
}
|
||||
|
@ -1009,6 +1013,7 @@ public class NotificationsFragment extends SFragment implements
|
|||
} else if (this.notifications.isEmpty()) {
|
||||
this.statusView.setVisibility(View.VISIBLE);
|
||||
swipeRefreshLayout.setEnabled(false);
|
||||
this.showingError = true;
|
||||
if (exception instanceof IOException) {
|
||||
this.statusView.setup(R.drawable.elephant_offline, R.string.error_network, __ -> {
|
||||
this.progressBar.setVisibility(View.VISIBLE);
|
||||
|
@ -1022,6 +1027,7 @@ public class NotificationsFragment extends SFragment implements
|
|||
return Unit.INSTANCE;
|
||||
});
|
||||
}
|
||||
updateFilterVisibility();
|
||||
}
|
||||
Log.e(TAG, "Fetch failure: " + exception.getMessage());
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ class BackgroundMessageView @JvmOverloads constructor(
|
|||
fun setup(@DrawableRes imageRes: Int, @StringRes messageRes: Int,
|
||||
clickListener: ((v: View) -> Unit)? = null) {
|
||||
messageTextView.setText(messageRes)
|
||||
messageTextView.setCompoundDrawablesWithIntrinsicBounds(0, imageRes, 0, 0)
|
||||
imageView.setImageResource(imageRes)
|
||||
button.setOnClickListener(clickListener)
|
||||
button.visible(clickListener != null)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue