mirror of
https://github.com/nextcloud/android.git
synced 2024-11-26 15:15:51 +03:00
first implementation of sticky header logic.
Signed-off-by: alex <alex.plutta@googlemail.com> Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
This commit is contained in:
parent
cd3d8dca12
commit
a184345c1a
2 changed files with 22 additions and 7 deletions
|
@ -1,28 +1,38 @@
|
|||
package com.owncloud.android.ui.activities;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
|
||||
import com.owncloud.android.ui.adapter.ActivityListAdapter;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
public class ActivityListItemDecoration extends RecyclerView.ItemDecoration {
|
||||
private final String TAG = this.getClass().getSimpleName();
|
||||
private View currentHeader;
|
||||
|
||||
@Override
|
||||
public void onDrawOver(@NonNull Canvas c, @NonNull RecyclerView parent, @NonNull RecyclerView.State state) {
|
||||
super.onDrawOver(c, parent, state);
|
||||
|
||||
|
||||
View topChild = parent.getChildAt(0);
|
||||
View currentHeader = topChild;
|
||||
|
||||
|
||||
|
||||
if (currentHeader != null) {
|
||||
drawHeader(c, currentHeader);
|
||||
Log.d(TAG,"Attach new Header" );
|
||||
int topChildPosition = parent.getChildAdapterPosition(topChild);
|
||||
if (topChildPosition == -1) {
|
||||
return;
|
||||
}
|
||||
ActivityListAdapter adapter = (ActivityListAdapter) parent.getAdapter();
|
||||
|
||||
Object topElement = adapter.getActivityAtByPosition(topChildPosition);
|
||||
|
||||
if (topElement instanceof ActivityListHeader) {
|
||||
currentHeader = parent.getChildAt(0);
|
||||
}
|
||||
drawHeader(c, currentHeader);
|
||||
}
|
||||
|
||||
private void drawHeader(Canvas c, View header) {
|
||||
|
|
|
@ -243,6 +243,11 @@ public class ActivityListAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
|||
}
|
||||
}
|
||||
|
||||
public Object getActivityAtByPosition(int pos) {
|
||||
return values.get(pos);
|
||||
|
||||
}
|
||||
|
||||
private ImageView createThumbnailNew(PreviewObject previewObject) {
|
||||
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(px, px);
|
||||
params.setMargins(10, 10, 10, 10);
|
||||
|
|
Loading…
Reference in a new issue