|
@@ -23,7 +23,6 @@ package com.owncloud.android.ui.adapter;
|
|
|
|
|
|
import android.content.Context;
|
|
|
import android.support.annotation.NonNull;
|
|
|
-import android.support.annotation.Nullable;
|
|
|
import android.view.LayoutInflater;
|
|
|
import android.view.View;
|
|
|
import android.view.ViewGroup;
|
|
@@ -52,7 +51,7 @@ import butterknife.ButterKnife;
|
|
|
/**
|
|
|
* Adapter to display all auto-synced folders and/or instant upload media folders.
|
|
|
*/
|
|
|
-public class SyncedFolderAdapter extends SectionedRecyclerViewAdapter<SyncedFolderAdapter.MainViewHolder> {
|
|
|
+public class SyncedFolderAdapter extends SectionedRecyclerViewAdapter<SectionedViewHolder> {
|
|
|
|
|
|
private final Context mContext;
|
|
|
private final int mGridWidth;
|
|
@@ -99,7 +98,9 @@ public class SyncedFolderAdapter extends SectionedRecyclerViewAdapter<SyncedFold
|
|
|
|
|
|
@Override
|
|
|
public int getItemCount(int section) {
|
|
|
- if (mSyncFolderItems.get(section).getFilePaths() != null) {
|
|
|
+ List<String> filePaths = mSyncFolderItems.get(section).getFilePaths();
|
|
|
+
|
|
|
+ if (filePaths != null) {
|
|
|
return mSyncFolderItems.get(section).getFilePaths().size();
|
|
|
} else {
|
|
|
return 1;
|
|
@@ -129,7 +130,9 @@ public class SyncedFolderAdapter extends SectionedRecyclerViewAdapter<SyncedFold
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void onBindHeaderViewHolder(final MainViewHolder holder, final int section, boolean expanded) {
|
|
|
+ public void onBindHeaderViewHolder(SectionedViewHolder commonHolder, final int section, boolean expanded) {
|
|
|
+ HeaderViewHolder holder = (HeaderViewHolder) commonHolder;
|
|
|
+
|
|
|
holder.mainHeaderContainer.setVisibility(View.VISIBLE);
|
|
|
|
|
|
holder.title.setText(mSyncFolderItems.get(section).getFolderName());
|
|
@@ -171,14 +174,17 @@ public class SyncedFolderAdapter extends SectionedRecyclerViewAdapter<SyncedFold
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void onBindFooterViewHolder(MainViewHolder holder, int section) {
|
|
|
+ public void onBindFooterViewHolder(SectionedViewHolder holder, int section) {
|
|
|
// not needed
|
|
|
}
|
|
|
|
|
|
|
|
|
@Override
|
|
|
- public void onBindViewHolder(MainViewHolder holder, int section, int relativePosition, int absolutePosition) {
|
|
|
+ public void onBindViewHolder(SectionedViewHolder commonHolder, int section, int relativePosition,
|
|
|
+ int absolutePosition) {
|
|
|
if (mSyncFolderItems.get(section).getFilePaths() != null) {
|
|
|
+ MainViewHolder holder = (MainViewHolder) commonHolder;
|
|
|
+
|
|
|
File file = new File(mSyncFolderItems.get(section).getFilePaths().get(relativePosition));
|
|
|
|
|
|
ThumbnailsCacheManager.MediaThumbnailGenerationTask task =
|
|
@@ -201,7 +207,7 @@ public class SyncedFolderAdapter extends SectionedRecyclerViewAdapter<SyncedFold
|
|
|
|
|
|
if (mSyncFolderItems.get(section).getNumberOfFiles() > mGridTotal && relativePosition >= mGridTotal - 1) {
|
|
|
holder.counterValue.setText(String.format(Locale.US, "%d",
|
|
|
- mSyncFolderItems.get(section).getNumberOfFiles() - mGridTotal);)
|
|
|
+ mSyncFolderItems.get(section).getNumberOfFiles() - mGridTotal));
|
|
|
holder.counterBar.setVisibility(View.VISIBLE);
|
|
|
holder.thumbnailDarkener.setVisibility(View.VISIBLE);
|
|
|
} else {
|
|
@@ -213,11 +219,14 @@ public class SyncedFolderAdapter extends SectionedRecyclerViewAdapter<SyncedFold
|
|
|
|
|
|
@NonNull
|
|
|
@Override
|
|
|
- public MainViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
|
|
- View v = LayoutInflater.from(parent.getContext()).inflate(
|
|
|
- viewType == VIEW_TYPE_HEADER ?
|
|
|
- R.layout.synced_folders_item_header : R.layout.grid_sync_item, parent, false);
|
|
|
- return new MainViewHolder(v);
|
|
|
+ public SectionedViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
|
|
+ if (viewType == VIEW_TYPE_HEADER) {
|
|
|
+ View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.synced_folders_item_header, parent, false);
|
|
|
+ return new HeaderViewHolder(v);
|
|
|
+ } else {
|
|
|
+ View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.grid_sync_item, parent, false);
|
|
|
+ return new MainViewHolder(v);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
public interface ClickListener {
|
|
@@ -225,43 +234,41 @@ public class SyncedFolderAdapter extends SectionedRecyclerViewAdapter<SyncedFold
|
|
|
void onSyncFolderSettingsClick(int section, SyncedFolderDisplayItem syncedFolderDisplayItem);
|
|
|
}
|
|
|
|
|
|
- static class MainViewHolder extends SectionedViewHolder {
|
|
|
- @Nullable
|
|
|
- @BindView(R.id.thumbnail)
|
|
|
- public ImageView image;
|
|
|
+ static class HeaderViewHolder extends SectionedViewHolder {
|
|
|
+ @BindView(R.id.header_container)
|
|
|
+ public RelativeLayout mainHeaderContainer;
|
|
|
+
|
|
|
+ @BindView(R.id.type)
|
|
|
+ public ImageView type;
|
|
|
|
|
|
- @Nullable
|
|
|
@BindView(R.id.title)
|
|
|
public TextView title;
|
|
|
|
|
|
- @Nullable
|
|
|
- @BindView(R.id.type)
|
|
|
- public ImageView type;
|
|
|
+ @BindView(R.id.syncStatusButton)
|
|
|
+ public ImageButton syncStatusButton;
|
|
|
|
|
|
- @Nullable
|
|
|
@BindView(R.id.settingsButton)
|
|
|
public ImageButton menuButton;
|
|
|
|
|
|
- @Nullable
|
|
|
- @BindView(R.id.syncStatusButton)
|
|
|
- public ImageButton syncStatusButton;
|
|
|
+ private HeaderViewHolder(View itemView) {
|
|
|
+ super(itemView);
|
|
|
+ ButterKnife.bind(this, itemView);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ static class MainViewHolder extends SectionedViewHolder {
|
|
|
+ @BindView(R.id.thumbnail)
|
|
|
+ public ImageView image;
|
|
|
|
|
|
- @Nullable
|
|
|
@BindView(R.id.counterLayout)
|
|
|
public LinearLayout counterBar;
|
|
|
|
|
|
- @Nullable
|
|
|
@BindView(R.id.counter)
|
|
|
public TextView counterValue;
|
|
|
|
|
|
- @Nullable
|
|
|
@BindView(R.id.thumbnailDarkener)
|
|
|
public ImageView thumbnailDarkener;
|
|
|
|
|
|
- @Nullable
|
|
|
- @BindView(R.id.header_container)
|
|
|
- public RelativeLayout mainHeaderContainer;
|
|
|
-
|
|
|
private MainViewHolder(View itemView) {
|
|
|
super(itemView);
|
|
|
ButterKnife.bind(this, itemView);
|