Skip to content

Commit

Permalink
release v1.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
codeestX committed Nov 19, 2016
1 parent 21f5f7f commit e716905
Show file tree
Hide file tree
Showing 10 changed files with 62 additions and 54 deletions.
20 changes: 8 additions & 12 deletions app/src/main/java/moe/codeest/enviewsdemo/ScrollActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,22 @@
public class ScrollActivity extends Activity{

ENScrollView scrollView;
Button btnSelect;
Button btnUnSelect;
Button btnSwitch;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_scroll);
scrollView = (ENScrollView) findViewById(R.id.view_scroll);
btnSelect = (Button) findViewById(R.id.btn_select);
btnUnSelect = (Button) findViewById(R.id.btn_unselect);
btnSelect.setOnClickListener(new View.OnClickListener() {
btnSwitch = (Button) findViewById(R.id.btn_switch);
btnSwitch.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
scrollView.select();
}
});
btnUnSelect.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
scrollView.unSelect();
if (scrollView.isSelected()) {
scrollView.unSelect();
} else {
scrollView.select();
}
}
});
}
Expand Down
8 changes: 4 additions & 4 deletions app/src/main/res/layout/activity_play.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@
app:play_bg_line_width="12"/>

<Button
android:id="@+id/btn_pause"
android:id="@+id/btn_play"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="pause"
android:text="play"
android:layout_marginTop="20dp" />

<Button
android:id="@+id/btn_play"
android:id="@+id/btn_pause"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="play"
android:text="pause"
android:layout_marginTop="20dp" />

</LinearLayout>
15 changes: 5 additions & 10 deletions app/src/main/res/layout/activity_scroll.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,15 @@
app:scroll_line_color="#ffffff"
app:scroll_bg_line_color="#444a4f"
app:scroll_line_width="10"
app:scroll_bg_line_width="10"/>
app:scroll_bg_line_width="10"
app:scroll_is_selected="false"
app:scroll_view_translation_x="16"/>

<Button
android:id="@+id/btn_select"
android:id="@+id/btn_switch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="select"
android:layout_marginTop="20dp" />

<Button
android:id="@+id/btn_unselect"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="unselect"
android:text="switch"
android:layout_marginTop="20dp" />

</LinearLayout>
2 changes: 1 addition & 1 deletion app/src/main/res/layout/activity_volume.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
android:layout_marginTop="20dp"
app:volume_line_color="#ffffff"
app:volume_line_width="10"
app:volume_bg_line_color="#4f5559"
app:volume_bg_line_color="#64696d"
app:volume_bg_line_width="10"/>

<SeekBar
Expand Down
8 changes: 4 additions & 4 deletions library/src/main/java/moe/codeest/enviews/ENDownloadView.java
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ protected void onSizeChanged(int w, int h, int oldw, int oldh) {
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
switch (mCurrentState) {
case STATE_PRE:
case STATE_PRE: //嗷~ 开始阶段:线弹起小球
if (mFraction <= 0.4) {
canvas.drawCircle(mCenterX, mCenterY ,mCircleRadius, mBgPaint);
canvas.drawLine(mCenterX - mBaseLength, mCenterY, mCenterX, mCenterY + mBaseLength, mPaint);
Expand All @@ -172,7 +172,7 @@ protected void onDraw(Canvas canvas) {
canvas.drawLine(mCenterX - mBaseLength * 2.2f , mCenterY , mCenterX + mBaseLength * 2.2f, mCenterY, mPaint);
}
break;
case STATE_DOWNLOADING:
case STATE_DOWNLOADING: //嗷~ 下载阶段:波浪线与文字
if (mFraction <= 0.2) {
mTextPaint.setTextSize(mTextSize / 0.2f * mFraction);
}
Expand All @@ -195,7 +195,7 @@ protected void onDraw(Canvas canvas) {
canvas.drawText(String.format("%.2f", mCurrentSize) + getUnitStr(mUnit), mCenterX , mCenterY + 1.4f * mBaseLength , mTextPaint);
}
break;
case STATE_END:
case STATE_END: //嗷~ 结束阶段:线变勾
canvas.drawCircle(mCenterX, mCenterY ,mCircleRadius, mPaint);
if (mFraction <= 0.5) {
mTextPaint.setTextSize(mTextSize - mTextSize / 0.2f * mFraction);
Expand All @@ -210,7 +210,7 @@ protected void onDraw(Canvas canvas) {
canvas.drawLine(mCenterX - mBaseLength * 0.5f, mCenterY + mBaseLength * 0.5f * mFraction * 1.3f,
mCenterX + mBaseLength * 2.2f - mBaseLength * mFraction, mCenterY - mBaseLength * mFraction * 1.3f, mPaint);
break;
case STATE_RESET:
case STATE_RESET: //嗷~ 复位阶段:勾变箭头
canvas.drawCircle(mCenterX, mCenterY ,mCircleRadius, mBgPaint);
canvas.drawLine(mCenterX - mBaseLength, mCenterY,
mCenterX - mBaseLength * 0.5f + mBaseLength * 0.5f * mFraction, mCenterY + mBaseLength * 0.65f + mBaseLength * 0.35f * mFraction, mPaint);
Expand Down
7 changes: 4 additions & 3 deletions library/src/main/java/moe/codeest/enviews/ENLoadingView.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ public ENLoadingView(Context context, AttributeSet attrs) {
mPaint = new Paint[4];
mBeerPaint = new Paint[4];
mBubblePaint = new Paint[4];
mPath = new Path();
mBgPath = new Path();
isItemReady = new boolean[4];

for (int i = 0; i< 4 ; i++) {
Expand Down Expand Up @@ -110,7 +112,8 @@ protected void onSizeChanged(int w, int h, int oldw, int oldh) {
for (int i = 0; i < 4 ;i++) {
mCurrentRippleX[i] = - 2 * mBgBaseLength;
}
mPath = new Path();

mPath.reset();
mPath.moveTo(0, mCenterY + 2 * mBaseLength);
mPath.lineTo(0, mCenterY);
mPath.lineTo(mBaseLength / 4, mCenterY - mBaseLength);
Expand All @@ -121,8 +124,6 @@ protected void onSizeChanged(int w, int h, int oldw, int oldh) {
mPath.lineTo(mBaseLength, mCenterY + 2 * mBaseLength);
mPath.close();

mBgPath = new Path();

setAlpha(0);
}

Expand Down
26 changes: 20 additions & 6 deletions library/src/main/java/moe/codeest/enviews/ENScrollView.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ public class ENScrollView extends View {

private static final int DEFAULT_DURATION = 700;

private static final int DEFAULT_VIEW_TRANSLATION_X = 16;

private static final boolean DEFAULT_STATE = false;

private int mCurrentState = STATE_UNSELECT;

private int mCurrentColor = DEFAULT_LINE_COLOR;
Expand All @@ -58,7 +62,7 @@ public class ENScrollView extends View {

private float mPathLength;

private int mLineColor, mBgLineColor, mDuration;
private int mLineColor, mBgLineColor, mDuration, mViewTranslationX;

public ENScrollView(Context context) {
super(context);
Expand All @@ -72,6 +76,8 @@ public ENScrollView(Context context, AttributeSet attrs) {
int lineWidth = ta.getInteger(R.styleable.scroll_scroll_line_width, DEFAULT_LINE_WIDTH);
int bgLineColor = ta.getInteger(R.styleable.scroll_scroll_bg_line_color, DEFAULT_BG_LINE_COLOR);
int bgLineWidth = ta.getInteger(R.styleable.scroll_scroll_bg_line_width, DEFAULT_BG_LINE_WIDTH);
boolean isSelected = ta.getBoolean(R.styleable.scroll_scroll_is_selected, DEFAULT_STATE);
int viewTranslationX = ta.getInteger(R.styleable.scroll_scroll_view_translation_x, DEFAULT_VIEW_TRANSLATION_X);
ta.recycle();

mLineColor = lineColor;
Expand Down Expand Up @@ -99,6 +105,14 @@ public ENScrollView(Context context, AttributeSet attrs) {
mPathMeasure = new PathMeasure();

mDuration = DEFAULT_DURATION;
mViewTranslationX = viewTranslationX;
if (isSelected) {
mFraction = 1;
mCurrentState = STATE_SELECT;
} else {
mFraction = 0;
mCurrentState = STATE_UNSELECT;
}
}

@Override
Expand All @@ -120,16 +134,16 @@ protected void onSizeChanged(int w, int h, int oldw, int oldh) {
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
canvas.save();
canvas.translate(mFraction * mCircleRadius / 2, 0);
canvas.drawRoundRect(mRectF, mCircleRadius, mCircleRadius, mBgPaint);
canvas.translate(mFraction * mViewTranslationX, 0);
canvas.drawRoundRect(mRectF, mCircleRadius, mCircleRadius, mBgPaint); //嗷~ 在这画背景线
mDstPath.reset();
mPathMeasure.getSegment(0 ,mPathLength / 2 * mFraction, mDstPath, true);
canvas.drawPath(mDstPath, mPaint);
canvas.drawPath(mDstPath, mPaint); //嗷~ 在这画上半圈
mDstPath.reset();
mPathMeasure.getSegment(mPathLength - mPathLength / 2 * mFraction ,mPathLength, mDstPath, true);
canvas.drawPath(mDstPath, mPaint);
canvas.drawPath(mDstPath, mPaint); //嗷~ 在这画下半圈
mColorPaint.setColor(mCurrentColor);
if (mFraction <= 0.8 && mFraction > 0.2) {
if (mFraction <= 0.8 && mFraction > 0.2) { //嗷~ 在这画球
canvas.drawCircle(mCenterX - mCircleRadius + 2 * mCircleRadius * mFraction , mCenterY , mCircleRadius / 6 / 0.6f * (mFraction - 0.2f) , mColorPaint);
} else if (mFraction > 0.8) {
canvas.drawCircle(mCenterX - mCircleRadius + 2 * mCircleRadius * mFraction , mCenterY , mCircleRadius / 6 , mColorPaint);
Expand Down
10 changes: 5 additions & 5 deletions library/src/main/java/moe/codeest/enviews/ENSearchView.java
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ protected void onSizeChanged(int w, int h, int oldw, int oldh) {
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
if (mFraction <= 0.2) {
if (mFraction <= 0.2) { //嗷~ 放大镜手柄收缩
canvas.drawCircle(mCenterX , mCenterY ,mCircleRadius - mCircleRadius * mFraction, mPaint);
canvas.drawLine(mCenterX + mCircleRadius / (float) Math.sqrt(2) + 1.2f * mCircleRadius / (float) Math.sqrt(2) / 0.2f * mFraction,
mCenterY + mCircleRadius / (float) Math.sqrt(2) + 1.2f * mCircleRadius / (float) Math.sqrt(2) / 0.2f * mFraction,
Expand All @@ -132,13 +132,13 @@ protected void onDraw(Canvas canvas) {
if (isDotShowing) {
isDotShowing = false;
} else {
canvas.drawCircle(mCurrentPos[0], mCurrentPos[1], mDotSize, mPaint);
canvas.drawCircle(mCurrentPos[0], mCurrentPos[1], mDotSize, mPaint); //嗷~ 轨迹中的小球
isDotShowing = true;
}
} else {
canvas.drawCircle(mCurrentPos[0], mCurrentPos[1], mDotSize, mPaint);
}
if (mFraction <= 0.3) {
if (mFraction <= 0.3) { //嗷~ 内圈粘性部分
canvas.drawCircle(mCenterX , mCenterY ,0.8f * mCircleRadius + mCircleRadius * 2 * (mFraction - 0.2f), mPaint);
} else {
canvas.drawCircle(mCenterX , mCenterY ,mCircleRadius , mPaint);
Expand All @@ -150,7 +150,7 @@ protected void onDraw(Canvas canvas) {
canvas.drawArc(mRectF, 45 - 55 / 0.05f * (0.4f - mFraction), 110 / 0.05f * (0.4f - mFraction), false, mArcPaint);
}

if (mFraction <= 0.75 && mFraction > 0.7) {
if (mFraction <= 0.75 && mFraction > 0.7) { //嗷~ 外圈粘性部分
mArcPath.reset();
mArcPath.moveTo(mCenterX + mCircleRadius, mCenterY);
mArcPath.cubicTo(mCenterX + mCircleRadius + 8 / 0.05f * (mFraction - 0.7f), mCenterY + mCircleRadius / 2 + 8 / 0.05f * (mFraction - 0.7f),
Expand All @@ -165,7 +165,7 @@ protected void onDraw(Canvas canvas) {
mCenterX, mCenterY + mCircleRadius);
canvas.drawPath(mArcPath, mPaint);
}
} else {
} else { //嗷~ 放大镜手柄伸长
canvas.drawCircle(mCenterX , mCenterY ,mCircleRadius , mPaint);
canvas.drawLine(mCenterX + 2.2f *mCircleRadius / (float) Math.sqrt(2) - 1.2f * mCircleRadius / (float) Math.sqrt(2) / 0.2f * (mFraction - 0.8f),
mCenterY + 2.2f * mCircleRadius / (float) Math.sqrt(2) - 1.2f * mCircleRadius / (float) Math.sqrt(2) / 0.2f * (mFraction - 0.8f),
Expand Down
18 changes: 9 additions & 9 deletions library/src/main/java/moe/codeest/enviews/ENVolumeView.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class ENVolumeView extends View{

private static final int DEFAULT_LINE_COLOR = Color.WHITE;

private static final int DEFAULT_BG_LINE_COLOR = 0xff4f5559;
private static final int DEFAULT_BG_LINE_COLOR = 0xff64696d;

private static final int DEFAULT_LINE_WIDTH = 10;

Expand Down Expand Up @@ -129,22 +129,22 @@ protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
if (mCurrentState != STATE_VIBRATE) {
if (mFraction <= 0.5) {
mDstPath.reset();
mDstPath.reset(); //嗷~ 在这画喇叭
mPathMeasure.getSegment(0, mPathLength * 0.38f - mPathLength * 0.13f * mFraction, mDstPath, true);
canvas.drawPath(mDstPath, mBgPaint);
mDstPath.reset();
mPathMeasure.getSegment(mPathLength * 0.62f + mPathLength * 0.13f * mFraction, mPathLength, mDstPath, true);
canvas.drawPath(mDstPath, mBgPaint);

canvas.save();
canvas.save(); //嗷~ 在这画X
canvas.translate(- mFraction * mBaseLength * 2, 0);
canvas.drawLine(mCenterX - mBaseLength * (0.5f - mFraction) , mCenterY - mBaseLength * (0.5f - mFraction)
,mCenterX + mBaseLength * (0.5f - mFraction), mCenterY + mBaseLength * (0.5f - mFraction), mBgPaint);
canvas.drawLine(mCenterX - mBaseLength * (0.5f - mFraction), mCenterY + mBaseLength * (0.5f - mFraction)
,mCenterX + mBaseLength * (0.5f - mFraction), mCenterY - mBaseLength * (0.5f - mFraction), mBgPaint);
canvas.restore();
} else {
mDstPath.reset();
mDstPath.reset(); //嗷~ 在这画喇叭
mPathMeasure.getSegment(0, mPathLength * 0.25f + mPathLength * 0.13f * (mFraction - 0.5f), mDstPath, true);
canvas.drawPath(mDstPath, mBgPaint);
mDstPath.reset();
Expand All @@ -157,7 +157,7 @@ protected void onDraw(Canvas canvas) {
mPathMeasure.getSegment(mPathLength - mPathLength * 0.38f / 0.5f * (mFraction - 0.5f), mPathLength, mDstPath, true);
canvas.drawPath(mDstPath, mPaint);

canvas.save();
canvas.save(); //嗷~ 在这画小声波
canvas.translate( - (1 - mFraction) * mBaseLength * 2, 0);
canvas.drawArc(mCenterX - 0.5f * mBaseLength - mBaseLength / 0.5f * (mFraction - 0.5f),
mCenterY - mBaseLength / 0.5f * (mFraction - 0.5f),
Expand All @@ -172,7 +172,7 @@ protected void onDraw(Canvas canvas) {
mCenterY + mBaseLength / 0.5f * (mFraction - 0.5f), -55 / 50 * sVolume, 110 / 50 * sVolume ,false, mPaint);
canvas.restore();

canvas.save();
canvas.save(); //嗷~ 在这画大声波
canvas.translate( - (1 - mFraction) * mBaseLength * 3, 0);
canvas.drawArc(mCenterX - 1.6f * mBaseLength / 0.5f * (mFraction - 0.5f),
mCenterY - 1.6f * mBaseLength / 0.5f * (mFraction - 0.5f),
Expand All @@ -188,14 +188,14 @@ protected void onDraw(Canvas canvas) {
canvas.restore();
}
} else {
mDstPath.reset();
mDstPath.reset(); //嗷~ 在这画喇叭
mPathMeasure.getSegment(0, mPathLength * 0.38f, mDstPath, true);
canvas.drawPath(mDstPath, mPaint);
mDstPath.reset();
mPathMeasure.getSegment(mPathLength - mPathLength * 0.38f, mPathLength, mDstPath, true);
canvas.drawPath(mDstPath, mPaint);

canvas.save();
canvas.save(); //嗷~ 在这画小声波
canvas.translate( - (1 - mFraction) * mBaseLength / 3, 0);
canvas.drawArc(mCenterX - 1.5f * mBaseLength,
mCenterY - mBaseLength,
Expand All @@ -210,7 +210,7 @@ protected void onDraw(Canvas canvas) {
mCenterY + mBaseLength, -55 / 50 * sVolume, 110 / 50 * sVolume ,false, mPaint);
canvas.restore();

canvas.save();
canvas.save(); //嗷~ 在这画大声波
canvas.translate( - (1 - mFraction) * mBaseLength / 3, 0);
canvas.drawArc(mCenterX - 1.6f * mBaseLength,
mCenterY - 1.6f * mBaseLength,
Expand Down
2 changes: 2 additions & 0 deletions library/src/main/res/values/attrs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
<attr name="scroll_line_width" format="integer" />
<attr name="scroll_bg_line_color" format="color" />
<attr name="scroll_bg_line_width" format="integer" />
<attr name="scroll_is_selected" format="boolean" />
<attr name="scroll_view_translation_x" format="integer" />
</declare-styleable>

<declare-styleable name="search">
Expand Down

0 comments on commit e716905

Please # to comment.