Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ android {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}

debug{
debuggable true
}
}
// compileOptions {
// targetCompatibility 1.8
Expand Down
119 changes: 70 additions & 49 deletions app/src/main/java/com/coorchice/supertextview/MainActivity.java
Original file line number Diff line number Diff line change
@@ -1,59 +1,80 @@
package com.coorchice.supertextview;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Toast;

import com.coorchice.library.SuperTextView;
import com.coorchice.supertextview.SuperTextView.Adjuster.BtnAdjuster;
import com.coorchice.supertextview.SuperTextView.Adjuster.MoveEffectAdjuster;
import com.coorchice.supertextview.SuperTextView.Adjuster.OpportunityDemoAdjuster;
import com.coorchice.supertextview.SuperTextView.Adjuster.RippleAdjuster;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;


public class MainActivity extends AppCompatActivity {
//
private SuperTextView stv_17;
private SuperTextView stv_18;
private SuperTextView stv_19;
private SuperTextView stv_20;
private SuperTextView stv_21;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
initView();
}

private void initView() {
findViews();

stv_17.setAdjuster(new MoveEffectAdjuster())
.setAutoAdjust(true)
.startAnim();

stv_18.setAdjuster(new RippleAdjuster(getResources().getColor(R.color.opacity_5_a58fed)));

OpportunityDemoAdjuster opportunityDemoAdjuster1 = new OpportunityDemoAdjuster();
opportunityDemoAdjuster1.setOpportunity(SuperTextView.Adjuster.Opportunity.BEFORE_DRAWABLE);
stv_19.setAdjuster(opportunityDemoAdjuster1);
stv_19.setAutoAdjust(true);

OpportunityDemoAdjuster opportunityDemoAdjuster2 = new OpportunityDemoAdjuster();
opportunityDemoAdjuster2.setOpportunity(SuperTextView.Adjuster.Opportunity.BEFORE_TEXT);
stv_20.setAdjuster(opportunityDemoAdjuster2);
stv_20.setAutoAdjust(true);

OpportunityDemoAdjuster opportunityDemoAdjuster3 = new OpportunityDemoAdjuster();
opportunityDemoAdjuster3.setOpportunity(SuperTextView.Adjuster.Opportunity.AT_LAST);
stv_21.setAdjuster(opportunityDemoAdjuster3);
stv_21.setAutoAdjust(true);
}

private void findViews() {
stv_17 = (SuperTextView) findViewById(R.id.stv_17);
stv_18 = (SuperTextView) findViewById(R.id.stv_18);
stv_19 = (SuperTextView) findViewById(R.id.stv_19);
stv_20 = (SuperTextView) findViewById(R.id.stv_20);
stv_21 = (SuperTextView) findViewById(R.id.stv_21);
}
//
private SuperTextView stv_0;
private SuperTextView stv_17;
private SuperTextView stv_18;
private SuperTextView stv_19;
private SuperTextView stv_20;
private SuperTextView stv_21;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
initView();
}

private void initView() {
findViews();
getWindow().getDecorView().postDelayed(new Runnable() {
@Override
public void run() {
// stv_0.setEnabled(false);
stv_0.setBgColorAttr(R.attr.attr_part_translucent_black1);
stv_0.setStrokeColorAttr(R.attr.attr_part_translucent_black);
}
}, 4000);

stv_0.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(MainActivity.this, "ssssssss", Toast.LENGTH_SHORT).show();
}
});


stv_17.setAdjuster(new MoveEffectAdjuster())
.setAutoAdjust(true)
.startAnim();

stv_18.setAdjuster(new RippleAdjuster(getResources().getColor(R.color.opacity_5_a58fed)));

OpportunityDemoAdjuster opportunityDemoAdjuster1 = new OpportunityDemoAdjuster();
opportunityDemoAdjuster1.setOpportunity(SuperTextView.Adjuster.Opportunity.BEFORE_DRAWABLE);
stv_19.setAdjuster(opportunityDemoAdjuster1);
stv_19.setAutoAdjust(true);

OpportunityDemoAdjuster opportunityDemoAdjuster2 = new OpportunityDemoAdjuster();
opportunityDemoAdjuster2.setOpportunity(SuperTextView.Adjuster.Opportunity.BEFORE_TEXT);
stv_20.setAdjuster(opportunityDemoAdjuster2);
stv_20.setAutoAdjust(true);

OpportunityDemoAdjuster opportunityDemoAdjuster3 = new OpportunityDemoAdjuster();
opportunityDemoAdjuster3.setOpportunity(SuperTextView.Adjuster.Opportunity.AT_LAST);
stv_21.setAdjuster(opportunityDemoAdjuster3);
stv_21.setAutoAdjust(true);
}

private void findViews() {
stv_0 = (SuperTextView) findViewById(R.id.stv_0);
stv_17 = (SuperTextView) findViewById(R.id.stv_17);
stv_18 = (SuperTextView) findViewById(R.id.stv_18);
stv_19 = (SuperTextView) findViewById(R.id.stv_19);
stv_20 = (SuperTextView) findViewById(R.id.stv_20);
stv_21 = (SuperTextView) findViewById(R.id.stv_21);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
/*
* Copyright (C) 2017 CoorChice <[email protected]>
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
* <p>
* Last modified 17-5-23 上午9:41
*/

package com.coorchice.supertextview.SuperTextView.Adjuster;

import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffXfermode;
import android.graphics.RectF;
import android.view.MotionEvent;

import com.coorchice.library.SuperTextView;
import com.coorchice.supertextview.Utils.LogUtils;

/**
* Project Name:SuperTextView
* Author:CoorChice
* Date:2017/4/17
* Notes:
*/

public class BtnAdjuster extends SuperTextView.Adjuster {
private static final float DEFAULT_RADIUS = 50;

private PorterDuffXfermode xfermode = new PorterDuffXfermode(PorterDuff.Mode.SRC_ATOP);
private int rippleColor = Color.parseColor("#ce938d");
private float x = -1;
private float y = -1;
private Paint paint;
private float density;
private float radius = DEFAULT_RADIUS;
private RectF rectF = new RectF();
private float velocity = 2f;



public BtnAdjuster(int rippleColor) {
this.rippleColor = rippleColor;
initPaint();
}

private void initPaint() {
paint = new Paint();
paint.setAntiAlias(true);
paint.setColor(rippleColor);
}


@Override
protected void adjust(SuperTextView v, Canvas canvas) {
int width = v.getWidth();
int height = v.getHeight();

if (density == 0) {
density = v.getResources().getDisplayMetrics().density;
}
if (x == -1) {
x = width / 2;
}
if (y == -1) {
x = height / 2;

}
if (radius < ((float) width) * 1.1) {
radius = (radius + velocity);
}
rectF.setEmpty();
rectF.set(0, 0, width, height);
// 创建一个图层,在图层上演示图形混合后的效果
int sc = canvas.saveLayer(0, 0, width, height, null, Canvas.MATRIX_SAVE_FLAG |
Canvas.CLIP_SAVE_FLAG |
Canvas.HAS_ALPHA_LAYER_SAVE_FLAG |
Canvas.FULL_COLOR_LAYER_SAVE_FLAG |
Canvas.CLIP_TO_LAYER_SAVE_FLAG);
paint.setColor(v.getSolid());
canvas.drawRoundRect(rectF, height / 2, height / 2, paint);
paint.setXfermode(xfermode);
paint.setColor(rippleColor);
canvas.drawCircle(x, y, radius * density, paint);
paint.setXfermode(null);
canvas.restoreToCount(sc);
}

@Override
public boolean onTouch(SuperTextView v, MotionEvent event) {
int action = event.getAction();
LogUtils.e("action = " + action);
switch (action) {
case MotionEvent.ACTION_DOWN:
x = event.getX();
y = event.getY();
radius = DEFAULT_RADIUS;
v.setAutoAdjust(true);
v.startAnim();
break;
case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_CANCEL:
v.stopAnim();
v.setAutoAdjust(false);
LogUtils.e("stopAnim()");
break;
}
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
*/

public class RippleAdjuster extends SuperTextView.Adjuster {
private static final float DEFAULT_RADIUS = 50;
private static final float DEFAULT_RADIUS = 10;

private PorterDuffXfermode xfermode = new PorterDuffXfermode(PorterDuff.Mode.SRC_ATOP);
private int rippleColor = Color.parseColor("#ce938d");
Expand Down
25 changes: 25 additions & 0 deletions app/src/main/res/color/button_color_sel.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2017 CoorChice <[email protected]>
~ <p>
~ Licensed under the Apache License, Version 2.0 (the "License");you may not use this file except
~ in compliance with the License. You may obtain a copy of the License at
~ <p>
~ http://www.apache.org/licenses/LICENSE-2.0
~ <p>
~ Unless required by applicable law or agreed to in writing, software distributed under the License
~ is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
~ or implied. See the License for the specific language governing permissions and limitations under
~ the License.
~ <p>
~ Last modified 17-5-23 下午3:37
-->

<selector
xmlns:android="http://schemas.android.com/apk/res/android">

<item android:state_pressed="true" android:color="@color/opacity_8_green" />
<item android:state_enabled="false" android:color="@color/opacity_5_red" />
<item android:color="@color/red" />

</selector>
25 changes: 25 additions & 0 deletions app/src/main/res/color/button_yellow_color_sel.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2017 CoorChice <[email protected]>
~ <p>
~ Licensed under the Apache License, Version 2.0 (the "License");you may not use this file except
~ in compliance with the License. You may obtain a copy of the License at
~ <p>
~ http://www.apache.org/licenses/LICENSE-2.0
~ <p>
~ Unless required by applicable law or agreed to in writing, software distributed under the License
~ is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
~ or implied. See the License for the specific language governing permissions and limitations under
~ the License.
~ <p>
~ Last modified 17-6-2 上午9:03
-->

<selector
xmlns:android="http://schemas.android.com/apk/res/android">

<item android:state_pressed="true" android:color="@color/blue" />
<item android:state_enabled="false" android:color="@color/opacity_1_yellow" />
<item android:color="@color/yellow" />

</selector>
Loading