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:
alexp 2019-08-14 17:24:25 +02:00 committed by Andy Scherzinger
parent cd3d8dca12
commit a184345c1a
No known key found for this signature in database
GPG key ID: 6CADC7E3523C308B
2 changed files with 22 additions and 7 deletions

View file

@ -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) {

View file

@ -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);