Skip to content

Commit

Permalink
1.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
LwkCoder committed Apr 29, 2020
1 parent 1d585ef commit 8610aa7
Show file tree
Hide file tree
Showing 8 changed files with 302 additions and 249 deletions.
5 changes: 5 additions & 0 deletions NineGridView/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ android {
minSdkVersion MIN_SDK_VERSION as int
targetSdkVersion TARGET_SDK_VERSION as int
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}

dependencies {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageView;

Expand Down Expand Up @@ -42,13 +41,10 @@ private void init(Context context, AttributeSet attrs)
mImageView = (NineGridImageView) findViewById(R.id.img_ninegrid_imagecontainer_content);
mImgDelete = (ImageView) findViewById(R.id.img_ninegrid_imagecontainer_delete);
mImgDelete.setImageResource(mIcDelete);
mImgDelete.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View view)
mImgDelete.setOnClickListener(view -> {
if (mListener != null)
{
if (mListener != null)
mListener.onClickDelete();
mListener.onClickDelete();
}
});
setIsDeleteMode(mIsDeleteMode);
Expand Down Expand Up @@ -101,7 +97,9 @@ public int getImageHeight()
private void setScanType(ImageView.ScaleType scanType)
{
if (mImageView != null)
{
mImageView.setScaleType(scanType);
}
}

/**
Expand All @@ -111,9 +109,12 @@ public void setIsDeleteMode(boolean b)
{
this.mIsDeleteMode = b;
if (mIsDeleteMode)
{
mImgDelete.setVisibility(VISIBLE);
else
} else
{
mImgDelete.setVisibility(GONE);
}
requestLayout();
}

Expand All @@ -124,7 +125,9 @@ public void setDeleteIcon(int resId)
{
this.mIcDelete = resId;
if (mImgDelete != null)
{
mImgDelete.setImageResource(mIcDelete);
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,34 +1,40 @@
package com.lwkandroid.widget.ninegridview;

import android.os.Build;
import android.os.Parcel;
import android.os.Parcelable;

import java.util.Objects;
import java.util.UUID;

/**
* Data source
*
* @author LWK
*/

public class NineGridBean implements Parcelable
public final class NineGridBean implements Parcelable
{
private String id;
private String thumbUrl;
private String originUrl;
private String transitionName;

public NineGridBean(String originUrl)
{
this.originUrl = originUrl;
this(originUrl, null);
}

public NineGridBean(String originUrl, String thumbUrl)
{
this.thumbUrl = thumbUrl;
this.originUrl = originUrl;
this(originUrl, thumbUrl, null);
}

public NineGridBean(String thumbUrl, String originUrl, String transitionName)
{
this.thumbUrl = thumbUrl;
this.originUrl = originUrl;
this.transitionName = transitionName;
this.id = UUID.randomUUID().toString();
}

public String getThumbUrl()
Expand Down Expand Up @@ -61,16 +67,55 @@ public void setTransitionName(String transitionName)
this.transitionName = transitionName;
}

public String getId()
{
return id;
}

@Override
public String toString()
{
return "NineGridBean{" +
"thumbUrl='" + thumbUrl + '\'' +
"id='" + id + '\'' +
", thumbUrl='" + thumbUrl + '\'' +
", originUrl='" + originUrl + '\'' +
", transitionName='" + transitionName + '\'' +
'}';
}

@Override
public boolean equals(Object o)
{
if (this == o)
{
return true;
}
if (o == null || getClass() != o.getClass())
{
return false;
}
NineGridBean that = (NineGridBean) o;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT)
{
return Objects.equals(id, that.id);
} else
{
return id.equals(that.id);
}
}

@Override
public int hashCode()
{
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT)
{
return Objects.hash(id);
} else
{
return id.hashCode();
}
}

@Override
public int describeContents()
{
Expand All @@ -80,13 +125,15 @@ public int describeContents()
@Override
public void writeToParcel(Parcel dest, int flags)
{
dest.writeString(this.id);
dest.writeString(this.thumbUrl);
dest.writeString(this.originUrl);
dest.writeString(this.transitionName);
}

protected NineGridBean(Parcel in)
{
this.id = in.readString();
this.thumbUrl = in.readString();
this.originUrl = in.readString();
this.transitionName = in.readString();
Expand Down
Loading

0 comments on commit 8610aa7

Please sign in to comment.