collapse start chat button
This commit is contained in:
parent
b30a88e7a5
commit
dc0a139392
|
@ -299,6 +299,7 @@ public class ConversationsOverviewFragment extends XmppFragment {
|
|||
});
|
||||
this.binding.list.setAdapter(this.conversationsAdapter);
|
||||
this.binding.list.setLayoutManager(new LinearLayoutManager(getActivity(),LinearLayoutManager.VERTICAL,false));
|
||||
this.binding.list.addOnScrollListener(ExtendedFabSizeChanger.of(binding.fab));
|
||||
this.touchHelper = new ItemTouchHelper(this.callback);
|
||||
this.touchHelper.attachToRecyclerView(this.binding.list);
|
||||
return binding.getRoot();
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
package eu.siacs.conversations.ui;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton;
|
||||
|
||||
public class ExtendedFabSizeChanger extends RecyclerView.OnScrollListener {
|
||||
|
||||
private final ExtendedFloatingActionButton extendedFloatingActionButton;
|
||||
|
||||
private ExtendedFabSizeChanger(
|
||||
final ExtendedFloatingActionButton extendedFloatingActionButton) {
|
||||
this.extendedFloatingActionButton = extendedFloatingActionButton;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
|
||||
super.onScrolled(recyclerView, dx, dy);
|
||||
if (RecyclerViews.findFirstVisibleItemPosition(recyclerView) > 0) {
|
||||
extendedFloatingActionButton.shrink();
|
||||
} else {
|
||||
extendedFloatingActionButton.extend();
|
||||
}
|
||||
}
|
||||
|
||||
public static RecyclerView.OnScrollListener of(final ExtendedFloatingActionButton fab) {
|
||||
return new ExtendedFabSizeChanger(fab);
|
||||
}
|
||||
}
|
29
src/main/java/eu/siacs/conversations/ui/RecyclerViews.java
Normal file
29
src/main/java/eu/siacs/conversations/ui/RecyclerViews.java
Normal file
|
@ -0,0 +1,29 @@
|
|||
package eu.siacs.conversations.ui;
|
||||
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
public final class RecyclerViews {
|
||||
|
||||
private RecyclerViews() {
|
||||
throw new IllegalStateException("Do not instantiate me");
|
||||
}
|
||||
|
||||
public static boolean scrolledToTop(final RecyclerView recyclerView) {
|
||||
final RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager();
|
||||
if (layoutManager instanceof LinearLayoutManager linearLayoutManager) {
|
||||
return linearLayoutManager.findFirstCompletelyVisibleItemPosition() == 0;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static int findFirstVisibleItemPosition(final RecyclerView recyclerView) {
|
||||
final RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager();
|
||||
if (layoutManager instanceof LinearLayoutManager linearLayoutManager) {
|
||||
return linearLayoutManager.findFirstVisibleItemPosition();
|
||||
} else {
|
||||
return RecyclerView.NO_POSITION;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue