Skip to content

Commit

Permalink
v0.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
likaiyuan559 committed Aug 2, 2019
1 parent 7e4e04d commit 62b6c8a
Show file tree
Hide file tree
Showing 29 changed files with 432 additions and 177 deletions.
Binary file added .idea/caches/gradle_models.ser
Binary file not shown.
29 changes: 0 additions & 29 deletions .idea/codeStyles/Project.xml

This file was deleted.

4 changes: 4 additions & 0 deletions .idea/encodings.xml

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

29 changes: 0 additions & 29 deletions .idea/misc.xml

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

4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,13 @@ allprojects {
#### 2.添加依赖

#### 普通版本

```
implementation 'com.github.likaiyuan559:TouchEffects:v0.1.3'
```

#### androidx

```
implementation 'com.github.likaiyuan559:TouchEffects:0.2.0'
```
Expand All @@ -81,6 +84,7 @@ public class MyApplication extends Application {
TouchEffectsManager.build(TouchEffectsWholeType.SCALE)//设置全局使用哪种效果
.addViewType(TouchEffectsViewType.ALL)//添加哪些View支持这个效果
.setListWholeType(TouchEffectsWholeType.RIPPLE);//为父控件为列表的情况下,设置特定效果
                .setAspectRatioType(4f,TouchEffectsWholeType.RIPPLE);//宽高比大于4时启动水波纹
}
...
Expand Down
3 changes: 2 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,12 @@ android {
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
// implementation 'com.android.support:appcompat-v7:26.1.0'
implementation "com.android.support:recyclerview-v7:26.1.0"
// implementation "com.android.support:recyclerview-v7:26.1.0"
implementation 'androidx.appcompat:appcompat:1.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation project(':toucheffectslib')
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'androidx.recyclerview:recyclerview:1.0.0'
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ public class TouchEffectsApplication extends Application {
static {
TouchEffectsManager.build(TouchEffectsWholeType.SCALE)
.addViewType(TouchEffectsViewType.ALL)
.setListWholeType(TouchEffectsWholeType.RIPPLE);
.setListWholeType(TouchEffectsWholeType.RIPPLE)
.setAspectRatioType(4f,TouchEffectsWholeType.RIPPLE);//宽高比大于4时启动水波纹

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.lky.toucheffectsviewdemo.R;
import com.lky.toucheffectsviewdemo.bean.JumpBean;

import java.util.ArrayList;

import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

public class TouchEffectsMainActivity extends TouchEffectsBaseActivity implements View.OnClickListener{

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {

}

@Override
protected void initTouchEffects() {
TouchEffectsFactory.initTouchEffects(this,TouchEffectsWholeType.SCALE);
}
// @Override
// protected void initTouchEffects() {
// TouchEffectsFactory.initTouchEffects(this,TouchEffectsWholeType.SCALE);
// }

@Override
public void onClick(View v) {
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/activity_touch_effects_sample.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
android:gravity="center_horizontal">
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/touch_effects_sample_txt"
android:layout_width="wrap_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="TextView"
android:padding="10dp"/>
Expand Down
39 changes: 37 additions & 2 deletions md/个性化设置.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ tools:ignore="MissingPrefix"
```
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    TouchEffectsFactory.initTouchEffects(this,TouchEffectsWholeType.RIPPLE);
    super.onCreate(savedInstanceState);
TouchEffectsFactory.initTouchEffects(this,TouchEffectsWholeType.RIPPLE);
super.onCreate(savedInstanceState);
}
```

Expand Down Expand Up @@ -80,3 +80,38 @@ protected void initTouchEffects() {
```



### 5.为控件更换新效果

> 使用发现,当使用scale效果的时候,当控件宽高比达到一定程度,效果非常差,会使缩放变得特别严重,所以出现这种情况,可以使用个性化中独立为view设置效果,也可以使用下面这种方式为全局达到条件的view转换效果:


```
TouchEffectsManager.build(TouchEffectsWholeType.SCALE)
.setAspectRatioType(4f,TouchEffectsWholeType.RIPPLE);//宽高比大于4时启动水波纹
```

> //传入宽高比,当宽高比达到条件,会自动转换为指定的效果。
>
> //1f <aspectRatio<10,当小于1时,以高为基准,当大于1时,以宽为基准
>
> setAspectRatioType(float aspectRatio,TouchEffectsWholeType wholeType);
> //传入宽和高,多种模式处理
>
> //width < 1f 且 height < 1f,则使用宽高比模式,大于指定的宽高比则自动转换为指定效果
>
> //width > 1f 或height > 1f,使用宽或高模式,大于指定的其中一个条件,自动转换为指定效果
>
> setAspectRatioType(float width,float height,TouchEffectsWholeType wholeType)
>
> `建议使用宽高比模式`







7 changes: 7 additions & 0 deletions md/更新日志.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# 更新日志

### v0.3.0

1. 更新了宽高比模式转换

2. 修复了bug
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@


import com.lky.toucheffectsmodule.bean.ColorBean;
import com.lky.toucheffectsmodule.bean.ScaleBean;
import com.lky.toucheffectsmodule.bean.extra.BaseExtraBean;
import com.lky.toucheffectsmodule.bean.extra.ExtraAspectRatioBean;
import com.lky.toucheffectsmodule.proxy.TouchEffectsCreateViewSubject;
import com.lky.toucheffectsmodule.proxy.TouchEffectsViewProxy;
import com.lky.toucheffectsmodule.types.TouchEffectsExtraType;
import com.lky.toucheffectsmodule.types.TouchEffectsViewType;
import com.lky.toucheffectsmodule.types.TouchEffectsWholeType;
import com.lky.toucheffectsmodule.utils.TypeUtils;
Expand All @@ -26,7 +30,9 @@ public class TouchEffectsManager {
private static HashMap<String,TouchEffectsWholeType> mViewTypes;
private static TouchEffectsViewProxy mViewSubject;
private static ColorBean mColorBean;
private static ScaleBean mScaleBean;
private static TouchEffectsWholeType mListWholeType;
private static HashMap<TouchEffectsExtraType, BaseExtraBean> mExtraTypeMap = new HashMap<>();


private TouchEffectsManager() {
Expand Down Expand Up @@ -130,6 +136,46 @@ public TouchEffectsManager setListWholeType(TouchEffectsWholeType listWholeType)
return mInstance;
}

/**
* 设置View在某种模式中,宽高比达到什么程度时,使用另外的模式
* @param width 宽度,width < 1f : 使用比例 width > 1 : 不使用比例,当大于这个值的时候触发,与height同时生效
* @param height 宽度,height < 1f : 使用比例 height > 1 : 不使用比例,当大于这个值的时候触发,与width同时生效
* @param wholeType 更换的模式
* !!!注意,优先级大于listType
* @return
*/
public TouchEffectsManager setAspectRatioType(float width,float height,TouchEffectsWholeType wholeType){
ExtraAspectRatioBean extraAspectRatioBean = new ExtraAspectRatioBean(wholeType,width,height);
mExtraTypeMap.put(TouchEffectsExtraType.AspectRatio,extraAspectRatioBean);
return mInstance;
}

/**
* 设置View在某种模式中,宽高比达到什么程度时,使用另外的模式
* @param aspectRatio 宽高比,0 < aspectRatio < 10,如果小于1,则以height为基准,大于等于1,则以width为基准
* @param wholeType 更换的模式
* !!!注意,优先级大于listType
* @return
*/
public TouchEffectsManager setAspectRatioType(float aspectRatio,TouchEffectsWholeType wholeType){
if(aspectRatio > 10 || aspectRatio <= 0){
throw new IllegalArgumentException("宽高比不能大于10或小于等于0");
}
float height = 1f;
float width = aspectRatio;
if(aspectRatio > 1f){
width = aspectRatio / 10f;
height = 1f / 10f;
}
ExtraAspectRatioBean extraAspectRatioBean = new ExtraAspectRatioBean(wholeType,width,height);
mExtraTypeMap.put(TouchEffectsExtraType.AspectRatio,extraAspectRatioBean);
return mInstance;
}

public static HashMap<TouchEffectsExtraType, BaseExtraBean> getExtraTypeMap() {
return mExtraTypeMap;
}

public static TouchEffectsWholeType getListWholeType() {
return mListWholeType;
}
Expand All @@ -152,4 +198,8 @@ public static TouchEffectsViewProxy getViewSubject() {
public static ColorBean getColorBean() {
return mColorBean;
}

public static ScaleBean getScaleBean() {
return mScaleBean;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.lky.toucheffectsmodule.bean.extra;

import com.lky.toucheffectsmodule.types.TouchEffectsWholeType;

public class BaseExtraBean {

protected TouchEffectsWholeType mWholeType;

public void setWholeType(TouchEffectsWholeType wholeType) {
mWholeType = wholeType;
}

public TouchEffectsWholeType getWholeType() {
return mWholeType;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.lky.toucheffectsmodule.bean.extra;

import com.lky.toucheffectsmodule.types.TouchEffectsWholeType;

public class ExtraAspectRatioBean extends BaseExtraBean {

private float mWidth;
private float mHeight;

public ExtraAspectRatioBean(TouchEffectsWholeType wholeType,float width,float height) {
mWholeType = wholeType;
mWidth = width;
mHeight = height;
}

public float getWidth() {
return mWidth;
}

public float getHeight() {
return mHeight;
}
}
Loading

0 comments on commit 62b6c8a

Please sign in to comment.