Skip to content

Commit

Permalink
Merge pull request #1 from GcsSloop/master
Browse files Browse the repository at this point in the history
同步源
  • Loading branch information
xiandanin authored Apr 14, 2018
2 parents 9447fd6 + 43ebcfa commit 3d4234d
Show file tree
Hide file tree
Showing 22 changed files with 144 additions and 78 deletions.
Binary file added RCLayout/.idea/caches/build_file_checksums.ser
Binary file not shown.
29 changes: 29 additions & 0 deletions RCLayout/.idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

This file was deleted.

3 changes: 1 addition & 2 deletions RCLayout/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".ExampleActivity">
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified RCLayout/app/src/main/res/drawable/test.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

This file was deleted.

23 changes: 2 additions & 21 deletions RCLayout/rclayout/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,37 +27,18 @@ android {
buildToolsVersion "26.0.1"

defaultConfig {
minSdkVersion 14
minSdkVersion 7
targetSdkVersion 26
versionCode 1
versionName "1.0"

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:26.+'
testCompile 'junit:junit:4.12'
}


// 上传信息
ext {
GROUP_ID = "com.gcssloop.widget"
ARTIFACT_ID = "rclayout"
VERSION = "1.5.2"
VERSION = "1.5.4"
}

apply from: "/Applications/nexus/pack/pack-upload.gradle"
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Last modified 2018-03-20 16:36:45
* Last modified 2018-04-13 23:16:56
*
* GitHub: https://github.com/GcsSloop
* WeiBo: http://weibo.com/GcsSloop
Expand All @@ -25,7 +25,6 @@
import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.Canvas;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.widget.ImageView;
Expand All @@ -45,11 +44,11 @@ public RCImageView(Context context) {
this(context, null);
}

public RCImageView(Context context, @Nullable AttributeSet attrs) {
public RCImageView(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}

public RCImageView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
public RCImageView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
mRCHelper = new RCHelper();
mRCHelper.initAttrs(context, attrs);
Expand Down Expand Up @@ -88,4 +87,91 @@ public boolean dispatchTouchEvent(MotionEvent ev) {
}
return super.dispatchTouchEvent(ev);
}


//--- 公开接口 ----------------------------------------------------------------------------------

public void setClipBackground(boolean clipBackground) {
mRCHelper.mClipBackground = clipBackground;
invalidate();
}

public void setRoundAsCircle(boolean roundAsCircle) {
mRCHelper.mRoundAsCircle = roundAsCircle;
invalidate();
}

public void setRadius(int radius) {
for (int i = 0; i < mRCHelper.radii.length; i++) {
mRCHelper.radii[i] = radius;
}
invalidate();
}

public void setTopLeftRadius(int topLeftRadius) {
mRCHelper.radii[0] = topLeftRadius;
mRCHelper.radii[1] = topLeftRadius;
invalidate();
}

public void setTopRightRadius(int topRightRadius) {
mRCHelper.radii[2] = topRightRadius;
mRCHelper.radii[3] = topRightRadius;
invalidate();
}

public void setBottomLeftRadius(int bottomLeftRadius) {
mRCHelper.radii[4] = bottomLeftRadius;
mRCHelper.radii[5] = bottomLeftRadius;
invalidate();
}

public void setBottomRightRadius(int bottomRightRadius) {
mRCHelper.radii[6] = bottomRightRadius;
mRCHelper.radii[7] = bottomRightRadius;
invalidate();
}

public void setStrokeWidth(int strokeWidth) {
mRCHelper.mStrokeWidth = strokeWidth;
invalidate();
}

public void setStrokeColor(int strokeColor) {
mRCHelper.mStrokeColor = strokeColor;
invalidate();
}

public boolean isClipBackground() {
return mRCHelper.mClipBackground;
}

public boolean isRoundAsCircle() {
return mRCHelper.mRoundAsCircle;
}

public float getTopLeftRadius() {
return mRCHelper.radii[0];
}

public float getTopRightRadius() {
return mRCHelper.radii[2];
}

public float getBottomLeftRadius() {
return mRCHelper.radii[4];
}

public float getBottomRightRadius() {
return mRCHelper.radii[6];
}

public int getStrokeWidth() {
return mRCHelper.mStrokeWidth;
}

public int getStrokeColor() {
return mRCHelper.mStrokeColor;
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2017 GcsSloop
* Copyright 2018 GcsSloop
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Last modified 2017-09-11 15:29:05
* Last modified 2018-04-13 23:18:56
*
* GitHub: https://github.com/GcsSloop
* WeiBo: http://weibo.com/GcsSloop
Expand Down Expand Up @@ -58,7 +58,6 @@ protected void onSizeChanged(int w, int h, int oldw, int oldh) {
mRCHelper.onSizeChanged(this, w, h);
}


@Override
protected void dispatchDraw(Canvas canvas) {
canvas.saveLayer(mRCHelper.mLayer, null, Canvas.ALL_SAVE_FLAG);
Expand Down Expand Up @@ -88,6 +87,8 @@ public boolean dispatchTouchEvent(MotionEvent ev) {
return super.dispatchTouchEvent(ev);
}

//--- 公开接口 ----------------------------------------------------------------------------------

public void setClipBackground(boolean clipBackground) {
mRCHelper.mClipBackground = clipBackground;
invalidate();
Expand Down Expand Up @@ -171,5 +172,4 @@ public int getStrokeColor() {
return mRCHelper.mStrokeColor;
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Last modified 2018-03-20 17:09:03
* Last modified 2018-04-13 23:18:02
*
* GitHub: https://github.com/GcsSloop
* WeiBo: http://weibo.com/GcsSloop
Expand All @@ -39,6 +39,10 @@

import com.gcssloop.rclayout.R;

/**
* 作用:圆角辅助工具
* 作者:GcsSloop
*/
public class RCHelper {
public float[] radii = new float[8]; // top-left, top-right, bottom-right, bottom-left
public Path mClipPath; // 剪裁区域路径
Expand Down Expand Up @@ -80,6 +84,7 @@ public void initAttrs(Context context, AttributeSet attrs) {
radii[6] = roundCornerBottomLeft;
radii[7] = roundCornerBottomLeft;

mLayer = new RectF();
mClipPath = new Path();
mAreaRegion = new Region();
mPaint = new Paint();
Expand All @@ -88,7 +93,7 @@ public void initAttrs(Context context, AttributeSet attrs) {
}

public void onSizeChanged(View view, int w, int h) {
mLayer = new RectF(0, 0, w, h);
mLayer.set(0, 0, w, h);
refreshRegion(view);
}

Expand Down
13 changes: 11 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Android 通用圆角布局,快速实现圆角需求。

## 效果预览

<img src="https://ww4.sinaimg.cn/large/006tKfTcly1fk7twywj5oj30u01fewka.jpg" width="300"/>
<img src="http://ww1.sinaimg.cn/large/005Xtdi2gy1fqbgk8pmevg309u0ghwz9.gif" width="300"/> <img src="https://ww4.sinaimg.cn/large/006tKfTcly1fk7twywj5oj30u01fewka.jpg" width="294"/>

## 支持的特性

Expand Down Expand Up @@ -117,7 +117,7 @@ allprojects {
在需要添加依赖的 Module 下添加以下信息,使用方式和普通的远程仓库一样。

```groovy
implementation 'com.gcssloop.widget:rclayout:1.5.2'
implementation 'com.gcssloop.widget:rclayout:1.5.4'
```


Expand All @@ -131,6 +131,15 @@ implementation 'com.gcssloop.widget:rclayout:1.5.2'

## 更新日志

#### v1.5.4

提供在 Java 中动态设置属性的方法。

#### v1.5.3

降低兼容最低版本。
精简项目结构。

#### v1.5.2

默认不剪裁背景,即 clip-background 默认为 false。
Expand Down

0 comments on commit 3d4234d

Please sign in to comment.