|
|
@@ -4,6 +4,7 @@ import android.view.LayoutInflater;
|
|
|
import android.view.View;
|
|
|
import android.view.ViewGroup;
|
|
|
import android.widget.ImageView;
|
|
|
+import android.widget.LinearLayout;
|
|
|
import android.widget.RelativeLayout;
|
|
|
|
|
|
import androidx.annotation.IntRange;
|
|
|
@@ -97,11 +98,9 @@ class ImagerAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
|
|
ImageDetailsActivity.start(holder.itemView.getContext(), mData, position);
|
|
|
});
|
|
|
} else if (holder instanceof FooterViewHolder) {
|
|
|
- if (position >= mMaxLength) {
|
|
|
- holder.itemView.setVisibility(View.GONE);
|
|
|
- } else {
|
|
|
- holder.itemView.setVisibility(View.VISIBLE);
|
|
|
- }
|
|
|
+ // holder.itemView.setVisibility(View.GONE);
|
|
|
+ // holder.itemView.setVisibility(View.VISIBLE);
|
|
|
+ setVisibility(position < mMaxLength, ((FooterViewHolder) holder).itemRelative);
|
|
|
if (ImageRecycler.mAddRes != null) {
|
|
|
((FooterViewHolder) holder).img.setImageDrawable(ImageRecycler.mAddRes);
|
|
|
}
|
|
|
@@ -113,6 +112,20 @@ class ImagerAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private void setVisibility(boolean isVisible, ViewGroup itemView) {
|
|
|
+ ViewGroup.LayoutParams param = (ViewGroup.LayoutParams) itemView.getLayoutParams();
|
|
|
+ if (isVisible) {
|
|
|
+ param.height = LinearLayout.LayoutParams.MATCH_PARENT;
|
|
|
+ param.width = LinearLayout.LayoutParams.MATCH_PARENT;
|
|
|
+ itemView.setVisibility(View.VISIBLE);
|
|
|
+ } else {
|
|
|
+ itemView.setVisibility(View.GONE);
|
|
|
+ param.height = 0;
|
|
|
+ param.width = 0;
|
|
|
+ }
|
|
|
+ itemView.setLayoutParams(param);
|
|
|
+ }
|
|
|
+
|
|
|
public void setOnAddImgClick(ImageRecycler.OnAddImgClick onAddImgClick) {
|
|
|
this.onAddImgClick = onAddImgClick;
|
|
|
}
|
|
|
@@ -162,6 +175,9 @@ class ImagerAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
|
|
}
|
|
|
|
|
|
public void addData(@IntRange(from = 0L) int position, @NonNull String data) {
|
|
|
+ if (position >= this.mMaxLength) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
this.mData.add(position, data);
|
|
|
this.notifyItemInserted(position);
|
|
|
this.compatibilityDataSizeChanged(1);
|
|
|
@@ -174,6 +190,9 @@ class ImagerAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
|
|
}
|
|
|
|
|
|
public void remove(@IntRange(from = 0L) int position) {
|
|
|
+ if (position >= this.mMaxLength) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
this.mData.remove(position);
|
|
|
this.notifyItemRemoved(position);
|
|
|
this.compatibilityDataSizeChanged(0);
|
|
|
@@ -181,6 +200,9 @@ class ImagerAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
|
|
}
|
|
|
|
|
|
public void setData(@IntRange(from = 0L) int index, @NonNull String data) {
|
|
|
+ if (index >= this.mMaxLength) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
this.mData.set(index, data);
|
|
|
this.notifyItemChanged(index);
|
|
|
}
|
|
|
@@ -202,7 +224,6 @@ class ImagerAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
|
|
this.mData.clear();
|
|
|
this.mData.addAll(data);
|
|
|
}
|
|
|
-
|
|
|
this.notifyDataSetChanged();
|
|
|
}
|
|
|
|
|
|
@@ -211,7 +232,6 @@ class ImagerAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
|
|
if (dataSize == size) {
|
|
|
this.notifyDataSetChanged();
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
@NonNull
|
|
|
@@ -226,7 +246,7 @@ class ImagerAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
|
|
|
|
|
static class ViewHolder extends RecyclerView.ViewHolder {
|
|
|
|
|
|
- private RelativeLayout itemRelative;
|
|
|
+ private SquareRelativeLayout itemRelative;
|
|
|
private ImageView img;
|
|
|
|
|
|
public ViewHolder(@NonNull View itemView) {
|
|
|
@@ -244,7 +264,7 @@ class ImagerAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
|
|
|
|
|
static class FooterViewHolder extends RecyclerView.ViewHolder {
|
|
|
|
|
|
- private RelativeLayout itemRelative;
|
|
|
+ private SquareRelativeLayout itemRelative;
|
|
|
private ImageView img;
|
|
|
|
|
|
public FooterViewHolder(@NonNull View itemView) {
|