mirror of
https://github.com/nextcloud/android.git
synced 2024-11-26 23:28:42 +03:00
start to implement sticky header behavior
Signed-off-by: alex <alex.plutta@googlemail.com> Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
This commit is contained in:
parent
259e106308
commit
cd3d8dca12
5 changed files with 79 additions and 24 deletions
|
@ -60,7 +60,7 @@ import butterknife.BindView;
|
|||
import butterknife.ButterKnife;
|
||||
import butterknife.Unbinder;
|
||||
|
||||
public class ActivitiesActivity extends FileActivity implements ActivityListInterface, ActivitiesContract.View {
|
||||
public class ActivitiesActivity extends FileActivity implements ActivityListInterface, ActivityListElement, ActivitiesContract.View {
|
||||
private static final String TAG = ActivitiesActivity.class.getSimpleName();
|
||||
|
||||
@BindView(R.id.empty_list_view)
|
||||
|
@ -104,9 +104,9 @@ public class ActivitiesActivity extends FileActivity implements ActivityListInte
|
|||
protected void onCreate(Bundle savedInstanceState) {
|
||||
Log_OC.v(TAG, "onCreate() start");
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
mActionListener = new ActivitiesPresenter(activitiesRepository, filesRepository, this);
|
||||
|
||||
setContentView(R.layout.activity_list_layout);
|
||||
setContentView(R.layout.activity_list_layout);
|
||||
unbinder = ButterKnife.bind(this);
|
||||
|
||||
|
@ -174,6 +174,7 @@ public class ActivitiesActivity extends FileActivity implements ActivityListInte
|
|||
LinearLayoutManager layoutManager = new LinearLayoutManager(this);
|
||||
|
||||
recyclerView.setLayoutManager(layoutManager);
|
||||
recyclerView.addItemDecoration(new ActivityListItemDecoration());
|
||||
recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
|
||||
|
||||
@Override
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
package com.owncloud.android.ui.activities;
|
||||
|
||||
public interface ActivityListElement {
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package com.owncloud.android.ui.activities;
|
||||
|
||||
public class ActivityListHeader implements ActivityListElement {
|
||||
final private String headline;
|
||||
|
||||
public ActivityListHeader(String headline) {
|
||||
this.headline = headline;
|
||||
}
|
||||
|
||||
public String getHeadline() {
|
||||
return headline;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
package com.owncloud.android.ui.activities;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
public class ActivityListItemDecoration extends RecyclerView.ItemDecoration {
|
||||
private final String TAG = this.getClass().getSimpleName();
|
||||
@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" );
|
||||
}
|
||||
}
|
||||
|
||||
private void drawHeader(Canvas c, View header) {
|
||||
c.save();
|
||||
c.translate(0, 0);
|
||||
header.draw(c);
|
||||
c.restore();
|
||||
}
|
||||
}
|
|
@ -65,6 +65,7 @@ import com.owncloud.android.lib.resources.activities.models.PreviewObject;
|
|||
import com.owncloud.android.lib.resources.files.FileUtils;
|
||||
import com.owncloud.android.lib.resources.status.OCCapability;
|
||||
import com.owncloud.android.lib.resources.status.OwnCloudVersion;
|
||||
import com.owncloud.android.ui.activities.ActivityListHeader;
|
||||
import com.owncloud.android.ui.interfaces.ActivityListInterface;
|
||||
import com.owncloud.android.utils.DisplayUtils;
|
||||
import com.owncloud.android.utils.MimeTypeUtil;
|
||||
|
@ -141,7 +142,7 @@ public class ActivityListAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
|||
values.add(activity);
|
||||
} else {
|
||||
sTime = time;
|
||||
values.add(sTime);
|
||||
values.add(new ActivityListHeader(sTime));
|
||||
values.add(activity);
|
||||
}
|
||||
}
|
||||
|
@ -237,7 +238,8 @@ public class ActivityListAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
|||
}
|
||||
} else {
|
||||
ActivityViewHeaderHolder activityViewHeaderHolder = (ActivityViewHeaderHolder) holder;
|
||||
activityViewHeaderHolder.title.setText((String) values.get(position));
|
||||
ActivityListHeader header = (ActivityListHeader) values.get(position);
|
||||
activityViewHeaderHolder.title.setText((String) header.getHeadline());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue