Commit 1d2d7d9b authored by wangchangqin's avatar wangchangqin

梳理公共module,抽取file-picker文件选择器

parents
*.iml
.gradle
/local.properties
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
.idea
.DS_Store
/build
/captures
.externalNativeBuild
/build
\ No newline at end of file
apply plugin: 'com.android.library'
apply plugin: "maven-publish"
apply plugin: 'maven' //发布到maven 库中的插件
android {
compileSdkVersion rootProject.ext.compileSdkVersion
defaultConfig {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "1.0"
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
def common = rootProject.ext.common
implementation common.appcompat
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
}
//设置动态属性
ext {
//发布到仓库用户名
publishUserName = "face-dev"
//发布到仓库地址
publishUserPassword = "Face-dev@2019"
//仓库地址
publishURL = "https://nexus.infra.miyatech.com/repository/shualianzhifu/"
publishVersion = 0.01
publishArtifactId = "common-dialog"
}
uploadArchives {
repositories.mavenDeployer {
repository(url: publishURL) {//RELEASE
authentication(userName: publishUserName, password: publishUserPassword)
}
pom.project {
version '0.01'
artifactId 'common-dialog'
groupId 'com.miya.iot'
packaging 'jar'
description 'common-dialog'
}
}
}
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
\ No newline at end of file
package com.changqin.study.component;
import android.content.Context;
import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
assertEquals("com.changqin.study.androidxdemo", appContext.getPackageName());
}
}
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.sdy.miya.moblie.component.dialog">
</manifest>
\ No newline at end of file
package com.sdy.miya.moblie.component.dialog.avi;
import android.animation.ValueAnimator;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.ColorFilter;
import android.graphics.Paint;
import android.graphics.PixelFormat;
import android.graphics.Rect;
import android.graphics.drawable.Animatable;
import android.graphics.drawable.Drawable;
import java.util.ArrayList;
import java.util.HashMap;
/**
* Created by Jack Wang on 2016/8/5.
*/
public abstract class Indicator extends Drawable implements Animatable {
private HashMap<ValueAnimator,ValueAnimator.AnimatorUpdateListener> mUpdateListeners=new HashMap<>();
private ArrayList<ValueAnimator> mAnimators;
private int alpha = 255;
private static final Rect ZERO_BOUNDS_RECT = new Rect();
protected Rect drawBounds = ZERO_BOUNDS_RECT;
private boolean mHasAnimators;
private Paint mPaint=new Paint();
public Indicator(){
mPaint.setColor(Color.WHITE);
mPaint.setStyle(Paint.Style.FILL);
mPaint.setAntiAlias(true);
}
public int getColor() {
return mPaint.getColor();
}
public void setColor(int color) {
mPaint.setColor(color);
}
@Override
public void setAlpha(int alpha) {
this.alpha = alpha;
}
@Override
public int getAlpha() {
return alpha;
}
@Override
public int getOpacity() {
return PixelFormat.OPAQUE;
}
@Override
public void setColorFilter(ColorFilter colorFilter) {
}
@Override
public void draw(Canvas canvas) {
draw(canvas,mPaint);
}
public abstract void draw(Canvas canvas, Paint paint);
public abstract ArrayList<ValueAnimator> onCreateAnimators();
@Override
public void start() {
ensureAnimators();
if (mAnimators == null) {
return;
}
// If the animators has not ended, do nothing.
if (isStarted()) {
return;
}
startAnimators();
invalidateSelf();
}
private void startAnimators() {
for (int i = 0; i < mAnimators.size(); i++) {
ValueAnimator animator = mAnimators.get(i);
//when the animator restart , add the updateListener again because they
// was removed by animator stop .
ValueAnimator.AnimatorUpdateListener updateListener=mUpdateListeners.get(animator);
if (updateListener!=null){
animator.addUpdateListener(updateListener);
}
animator.start();
}
}
private void stopAnimators() {
if (mAnimators!=null){
for (ValueAnimator animator : mAnimators) {
if (animator != null && animator.isStarted()) {
animator.removeAllUpdateListeners();
animator.end();
}
}
}
}
private void ensureAnimators() {
if (!mHasAnimators) {
mAnimators = onCreateAnimators();
mHasAnimators = true;
}
}
@Override
public void stop() {
stopAnimators();
}
private boolean isStarted() {
for (ValueAnimator animator : mAnimators) {
return animator.isStarted();
}
return false;
}
@Override
public boolean isRunning() {
for (ValueAnimator animator : mAnimators) {
return animator.isRunning();
}
return false;
}
/**
* Your should use this to add AnimatorUpdateListener when
* create animator , otherwise , animator doesn't work when
* the animation restart .
* @param updateListener
*/
public void addUpdateListener(ValueAnimator animator, ValueAnimator.AnimatorUpdateListener updateListener){
mUpdateListeners.put(animator,updateListener);
}
@Override
protected void onBoundsChange(Rect bounds) {
super.onBoundsChange(bounds);
setDrawBounds(bounds);
}
public void setDrawBounds(Rect drawBounds) {
setDrawBounds(drawBounds.left, drawBounds.top, drawBounds.right, drawBounds.bottom);
}
public void setDrawBounds(int left, int top, int right, int bottom) {
this.drawBounds = new Rect(left, top, right, bottom);
}
public void postInvalidate(){
invalidateSelf();
}
public Rect getDrawBounds() {
return drawBounds;
}
public int getWidth(){
return drawBounds.width();
}
public int getHeight(){
return drawBounds.height();
}
public int centerX(){
return drawBounds.centerX();
}
public int centerY(){
return drawBounds.centerY();
}
public float exactCenterX(){
return drawBounds.exactCenterX();
}
public float exactCenterY(){
return drawBounds.exactCenterY();
}
}
package com.sdy.miya.moblie.component.dialog.avi.indicators;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.animation.ValueAnimator;
import com.sdy.miya.moblie.component.dialog.avi.Indicator;
import java.util.ArrayList;
/**
* Created by Jack on 2015/10/19.
*/
public class BallBeatIndicator extends Indicator {
public static final float SCALE=1.0f;
public static final int ALPHA=255;
private float[] scaleFloats=new float[]{SCALE,
SCALE,
SCALE};
int[] alphas=new int[]{ALPHA,
ALPHA,
ALPHA,};
@Override
public void draw(Canvas canvas, Paint paint) {
float circleSpacing=4;
float radius=(getWidth()-circleSpacing*2)/6;
float x = getWidth()/ 2-(radius*2+circleSpacing);
float y=getHeight() / 2;
for (int i = 0; i < 3; i++) {
canvas.save();
float translateX=x+(radius*2)*i+circleSpacing*i;
canvas.translate(translateX, y);
canvas.scale(scaleFloats[i], scaleFloats[i]);
paint.setAlpha(alphas[i]);
canvas.drawCircle(0, 0, radius, paint);
canvas.restore();
}
}
@Override
public ArrayList<ValueAnimator> onCreateAnimators() {
ArrayList<ValueAnimator> animators=new ArrayList<>();
int[] delays=new int[]{350,0,350};
for (int i = 0; i < 3; i++) {
final int index=i;
ValueAnimator scaleAnim=ValueAnimator.ofFloat(1,0.75f,1);
scaleAnim.setDuration(700);
scaleAnim.setRepeatCount(-1);
scaleAnim.setStartDelay(delays[i]);
addUpdateListener(scaleAnim,new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
scaleFloats[index] = (float) animation.getAnimatedValue();
postInvalidate();
}
});
ValueAnimator alphaAnim=ValueAnimator.ofInt(255,51,255);
alphaAnim.setDuration(700);
alphaAnim.setRepeatCount(-1);
alphaAnim.setStartDelay(delays[i]);
addUpdateListener(alphaAnim,new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
alphas[index] = (int) animation.getAnimatedValue();
postInvalidate();
}
});
animators.add(scaleAnim);
animators.add(alphaAnim);
}
return animators;
}
}
package com.sdy.miya.moblie.component.dialog.avi.indicators;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.RectF;
import android.animation.ValueAnimator;
import com.sdy.miya.moblie.component.dialog.avi.Indicator;
import java.util.ArrayList;
/**
* Created by Jack on 2015/10/16.
*/
public class BallClipRotateIndicator extends Indicator {
float scaleFloat=1,degrees;
@Override
public void draw(Canvas canvas, Paint paint) {
paint.setStyle(Paint.Style.STROKE);
paint.setStrokeWidth(3);
float circleSpacing=12;
float x = (getWidth()) / 2;
float y=(getHeight()) / 2;
canvas.translate(x, y);
canvas.scale(scaleFloat, scaleFloat);
canvas.rotate(degrees);
RectF rectF=new RectF(-x+circleSpacing,-y+circleSpacing,0+x-circleSpacing,0+y-circleSpacing);
canvas.drawArc(rectF, -45, 270, false, paint);
}
@Override
public ArrayList<ValueAnimator> onCreateAnimators() {
ArrayList<ValueAnimator> animators=new ArrayList<>();
ValueAnimator scaleAnim=ValueAnimator.ofFloat(1,0.6f,0.5f,1);
scaleAnim.setDuration(750);
scaleAnim.setRepeatCount(-1);
addUpdateListener(scaleAnim,new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
scaleFloat = (float) animation.getAnimatedValue();
postInvalidate();
}
});
ValueAnimator rotateAnim=ValueAnimator.ofFloat(0,180,360);
rotateAnim.setDuration(750);
rotateAnim.setRepeatCount(-1);
addUpdateListener(rotateAnim,new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
degrees = (float) animation.getAnimatedValue();
postInvalidate();
}
});
animators.add(scaleAnim);
animators.add(rotateAnim);
return animators;
}
}
package com.sdy.miya.moblie.component.dialog.avi.indicators;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.RectF;
import android.animation.ValueAnimator;
import com.sdy.miya.moblie.component.dialog.avi.Indicator;
import java.util.ArrayList;
/**
* Created by Jack on 2015/10/17.
*/
public class BallClipRotateMultipleIndicator extends Indicator {
float scaleFloat=1,degrees;
@Override
public void draw(Canvas canvas, Paint paint) {
paint.setStrokeWidth(3);
paint.setStyle(Paint.Style.STROKE);
float circleSpacing=12;
float x=getWidth()/2;
float y=getHeight()/2;
canvas.save();
canvas.translate(x, y);
canvas.scale(scaleFloat, scaleFloat);
canvas.rotate(degrees);
//draw two big arc
float[] bStartAngles=new float[]{135,-45};
for (int i = 0; i < 2; i++) {
RectF rectF=new RectF(-x+circleSpacing,-y+circleSpacing,x-circleSpacing,y-circleSpacing);
canvas.drawArc(rectF, bStartAngles[i], 90, false, paint);
}
canvas.restore();
canvas.translate(x, y);
canvas.scale(scaleFloat, scaleFloat);
canvas.rotate(-degrees);
//draw two small arc
float[] sStartAngles=new float[]{225,45};
for (int i = 0; i < 2; i++) {
RectF rectF=new RectF(-x/1.8f+circleSpacing,-y/1.8f+circleSpacing,x/1.8f-circleSpacing,y/1.8f-circleSpacing);
canvas.drawArc(rectF, sStartAngles[i], 90, false, paint);
}
}
@Override
public ArrayList<ValueAnimator> onCreateAnimators() {
ArrayList<ValueAnimator> animators=new ArrayList<>();
ValueAnimator scaleAnim=ValueAnimator.ofFloat(1,0.6f,1);
scaleAnim.setDuration(1000);
scaleAnim.setRepeatCount(-1);
addUpdateListener(scaleAnim,new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
scaleFloat = (float) animation.getAnimatedValue();
postInvalidate();
}
});
ValueAnimator rotateAnim=ValueAnimator.ofFloat(0, 180,360);
rotateAnim.setDuration(1000);
rotateAnim.setRepeatCount(-1);
addUpdateListener(rotateAnim,new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
degrees = (float) animation.getAnimatedValue();
postInvalidate();
}
});
animators.add(scaleAnim);
animators.add(rotateAnim);
return animators;
}
}
package com.sdy.miya.moblie.component.dialog.avi.indicators;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.RectF;
import android.animation.ValueAnimator;
import com.sdy.miya.moblie.component.dialog.avi.Indicator;
import java.util.ArrayList;
/**
* Created by Jack on 2015/10/16.
*/
public class BallClipRotatePulseIndicator extends Indicator {
float scaleFloat1,scaleFloat2,degrees;
@Override
public void draw(Canvas canvas, Paint paint) {
float circleSpacing=12;
float x=getWidth()/2;
float y=getHeight()/2;
//draw fill circle
canvas.save();
canvas.translate(x, y);
canvas.scale(scaleFloat1, scaleFloat1);
paint.setStyle(Paint.Style.FILL);
canvas.drawCircle(0, 0, x / 2.5f, paint);
canvas.restore();
canvas.translate(x, y);
canvas.scale(scaleFloat2, scaleFloat2);
canvas.rotate(degrees);
paint.setStrokeWidth(3);
paint.setStyle(Paint.Style.STROKE);
//draw two arc
float[] startAngles=new float[]{225,45};
for (int i = 0; i < 2; i++) {
RectF rectF=new RectF(-x+circleSpacing,-y+circleSpacing,x-circleSpacing,y-circleSpacing);
canvas.drawArc(rectF, startAngles[i], 90, false, paint);
}
}
@Override
public ArrayList<ValueAnimator> onCreateAnimators() {
ValueAnimator scaleAnim=ValueAnimator.ofFloat(1,0.3f,1);
scaleAnim.setDuration(1000);
scaleAnim.setRepeatCount(-1);
addUpdateListener(scaleAnim,new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
scaleFloat1 = (float) animation.getAnimatedValue();
postInvalidate();
}
});
ValueAnimator scaleAnim2=ValueAnimator.ofFloat(1,0.6f,1);
scaleAnim2.setDuration(1000);
scaleAnim2.setRepeatCount(-1);
addUpdateListener(scaleAnim2,new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
scaleFloat2 = (float) animation.getAnimatedValue();
postInvalidate();
}
});
ValueAnimator rotateAnim=ValueAnimator.ofFloat(0, 180,360);
rotateAnim.setDuration(1000);
rotateAnim.setRepeatCount(-1);
addUpdateListener(rotateAnim,new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
degrees = (float) animation.getAnimatedValue();
postInvalidate();
}
});
ArrayList<ValueAnimator> animators=new ArrayList<>();
animators.add(scaleAnim);
animators.add(scaleAnim2);
animators.add(rotateAnim);
return animators;
}
}
package com.sdy.miya.moblie.component.dialog.avi.indicators;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.animation.ValueAnimator;
import com.sdy.miya.moblie.component.dialog.avi.Indicator;
import java.util.ArrayList;
/**
* Created by Jack on 2015/10/20.
*/
public class BallGridBeatIndicator extends Indicator {
public static final int ALPHA=255;
int[] alphas=new int[]{ALPHA,
ALPHA,
ALPHA,
ALPHA,
ALPHA,
ALPHA,
ALPHA,
ALPHA,
ALPHA};
@Override
public void draw(Canvas canvas, Paint paint) {
float circleSpacing=4;
float radius=(getWidth()-circleSpacing*4)/6;
float x = getWidth()/ 2-(radius*2+circleSpacing);
float y = getWidth()/ 2-(radius*2+circleSpacing);
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
canvas.save();
float translateX=x+(radius*2)*j+circleSpacing*j;
float translateY=y+(radius*2)*i+circleSpacing*i;
canvas.translate(translateX, translateY);
paint.setAlpha(alphas[3 * i + j]);
canvas.drawCircle(0, 0, radius, paint);
canvas.restore();
}
}
}
@Override
public ArrayList<ValueAnimator> onCreateAnimators() {
ArrayList<ValueAnimator> animators=new ArrayList<>();
int[] durations={960, 930, 1190, 1130, 1340, 940, 1200, 820, 1190};
int[] delays= {360, 400, 680, 410, 710, -150, -120, 10, 320};
for (int i = 0; i < 9; i++) {
final int index=i;
ValueAnimator alphaAnim=ValueAnimator.ofInt(255, 168,255);
alphaAnim.setDuration(durations[i]);
alphaAnim.setRepeatCount(-1);
alphaAnim.setStartDelay(delays[i]);
addUpdateListener(alphaAnim,new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
alphas[index] = (int) animation.getAnimatedValue();
postInvalidate();
}
});
animators.add(alphaAnim);
}
return animators;
}
}
package com.sdy.miya.moblie.component.dialog.avi.indicators;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.animation.ValueAnimator;
import com.sdy.miya.moblie.component.dialog.avi.Indicator;
import java.util.ArrayList;
/**
* Created by Jack on 2015/10/16.
*/
public class BallGridPulseIndicator extends Indicator {
public static final int ALPHA=255;
public static final float SCALE=1.0f;
int[] alphas=new int[]{ALPHA,
ALPHA,
ALPHA,
ALPHA,
ALPHA,
ALPHA,
ALPHA,
ALPHA,
ALPHA};
float[] scaleFloats=new float[]{SCALE,
SCALE,
SCALE,
SCALE,
SCALE,
SCALE,
SCALE,
SCALE,
SCALE};
@Override
public void draw(Canvas canvas, Paint paint) {
float circleSpacing=4;
float radius=(getWidth()-circleSpacing*4)/6;
float x = getWidth()/ 2-(radius*2+circleSpacing);
float y = getWidth()/ 2-(radius*2+circleSpacing);
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
canvas.save();
float translateX=x+(radius*2)*j+circleSpacing*j;
float translateY=y+(radius*2)*i+circleSpacing*i;
canvas.translate(translateX, translateY);
canvas.scale(scaleFloats[3 * i + j], scaleFloats[3 * i + j]);
paint.setAlpha(alphas[3 * i + j]);
canvas.drawCircle(0, 0, radius, paint);
canvas.restore();
}
}
}
@Override
public ArrayList<ValueAnimator> onCreateAnimators() {
ArrayList<ValueAnimator> animators=new ArrayList<>();
int[] durations={720, 1020, 1280, 1420, 1450, 1180, 870, 1450, 1060};
int[] delays= {-60, 250, -170, 480, 310, 30, 460, 780, 450};
for (int i = 0; i < 9; i++) {
final int index=i;
ValueAnimator scaleAnim=ValueAnimator.ofFloat(1,0.5f,1);
scaleAnim.setDuration(durations[i]);
scaleAnim.setRepeatCount(-1);
scaleAnim.setStartDelay(delays[i]);
addUpdateListener(scaleAnim,new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
scaleFloats[index] = (float) animation.getAnimatedValue();
postInvalidate();
}
});
ValueAnimator alphaAnim=ValueAnimator.ofInt(255, 210, 122, 255);
alphaAnim.setDuration(durations[i]);
alphaAnim.setRepeatCount(-1);
alphaAnim.setStartDelay(delays[i]);
addUpdateListener(alphaAnim,new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
alphas[index] = (int) animation.getAnimatedValue();
postInvalidate();
}
});
animators.add(scaleAnim);
animators.add(alphaAnim);
}
return animators;
}
}
package com.sdy.miya.moblie.component.dialog.avi.indicators;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.animation.ValueAnimator;
import com.sdy.miya.moblie.component.dialog.avi.Indicator;
import java.util.ArrayList;
/**
* Created by Jack on 2015/10/16.
*/
public class BallPulseIndicator extends Indicator {
public static final float SCALE=1.0f;
//scale x ,y
private float[] scaleFloats=new float[]{SCALE,
SCALE,
SCALE};
@Override
public void draw(Canvas canvas, Paint paint) {
float circleSpacing=4;
float radius=(Math.min(getWidth(),getHeight())-circleSpacing*2)/6;
float x = getWidth()/ 2-(radius*2+circleSpacing);
float y=getHeight() / 2;
for (int i = 0; i < 3; i++) {
canvas.save();
float translateX=x+(radius*2)*i+circleSpacing*i;
canvas.translate(translateX, y);
canvas.scale(scaleFloats[i], scaleFloats[i]);
canvas.drawCircle(0, 0, radius, paint);
canvas.restore();
}
}
@Override
public ArrayList<ValueAnimator> onCreateAnimators() {
ArrayList<ValueAnimator> animators=new ArrayList<>();
int[] delays=new int[]{120,240,360};
for (int i = 0; i < 3; i++) {
final int index=i;
ValueAnimator scaleAnim=ValueAnimator.ofFloat(1,0.3f,1);
scaleAnim.setDuration(750);
scaleAnim.setRepeatCount(-1);
scaleAnim.setStartDelay(delays[i]);
addUpdateListener(scaleAnim,new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
scaleFloats[index] = (float) animation.getAnimatedValue();
postInvalidate();
}
});
animators.add(scaleAnim);
}
return animators;
}
}
package com.sdy.miya.moblie.component.dialog.avi.indicators;
import android.animation.ValueAnimator;
import android.graphics.Camera;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.view.animation.LinearInterpolator;
import com.sdy.miya.moblie.component.dialog.avi.Indicator;
import java.util.ArrayList;
/**
* Created by Jack on 2015/10/17.
*/
public class BallPulseRiseIndicator extends Indicator {
private Camera mCamera;
private Matrix mMatrix;
private float degress;
public BallPulseRiseIndicator(){
mCamera=new Camera();
mMatrix=new Matrix();
}
@Override
public void draw(Canvas canvas, Paint paint) {
mMatrix.reset();
mCamera.save();
mCamera.rotateX(degress);
mCamera.getMatrix(mMatrix);
mCamera.restore();
mMatrix.preTranslate(-centerX(), -centerY());
mMatrix.postTranslate(centerX(), centerY());
canvas.concat(mMatrix);
float radius=getWidth()/10;
canvas.drawCircle(getWidth()/4,radius*2,radius,paint);
canvas.drawCircle(getWidth()*3/4,radius*2,radius,paint);
canvas.drawCircle(radius,getHeight()-2*radius,radius,paint);
canvas.drawCircle(getWidth()/2,getHeight()-2*radius,radius,paint);
canvas.drawCircle(getWidth()-radius,getHeight()-2*radius,radius,paint);
}
@Override
public ArrayList<ValueAnimator> onCreateAnimators() {
ArrayList<ValueAnimator> animators=new ArrayList<>();
ValueAnimator animator=ValueAnimator.ofFloat(0,360);
addUpdateListener(animator,new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
degress = (float) animation.getAnimatedValue();
postInvalidate();
}
});
animator.setInterpolator(new LinearInterpolator());
animator.setRepeatCount(-1);
animator.setDuration(1500);
animators.add(animator);
return animators;
}
}
package com.sdy.miya.moblie.component.dialog.avi.indicators;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.animation.ValueAnimator;
import com.sdy.miya.moblie.component.dialog.avi.Indicator;
import java.util.ArrayList;
/**
* Created by Jack on 2015/10/19.
*/
public class BallPulseSyncIndicator extends Indicator {
float[] translateYFloats=new float[3];
@Override
public void draw(Canvas canvas, Paint paint) {
float circleSpacing=4;
float radius=(getWidth()-circleSpacing*2)/6;
float x = getWidth()/ 2-(radius*2+circleSpacing);
for (int i = 0; i < 3; i++) {
canvas.save();
float translateX=x+(radius*2)*i+circleSpacing*i;
canvas.translate(translateX, translateYFloats[i]);
canvas.drawCircle(0, 0, radius, paint);
canvas.restore();
}
}
@Override
public ArrayList<ValueAnimator> onCreateAnimators() {
ArrayList<ValueAnimator> animators=new ArrayList<>();
float circleSpacing=4;
float radius=(getWidth()-circleSpacing*2)/6;
int[] delays=new int[]{70,140,210};
for (int i = 0; i < 3; i++) {
final int index=i;
ValueAnimator scaleAnim=ValueAnimator.ofFloat(getHeight()/2,getHeight()/2-radius*2,getHeight()/2);
scaleAnim.setDuration(600);
scaleAnim.setRepeatCount(-1);
scaleAnim.setStartDelay(delays[i]);
addUpdateListener(scaleAnim,new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
translateYFloats[index] = (float) animation.getAnimatedValue();
postInvalidate();
}
});
animators.add(scaleAnim);
}
return animators;
}
}
package com.sdy.miya.moblie.component.dialog.avi.indicators;
import android.animation.ValueAnimator;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.Paint;
import com.sdy.miya.moblie.component.dialog.avi.Indicator;
import java.util.ArrayList;
/**
* Created by Jack on 2015/10/17.
*/
public class BallRotateIndicator extends Indicator {
float scaleFloat=0.5f;
float degress;
private Matrix mMatrix;
public BallRotateIndicator(){
mMatrix=new Matrix();
}
@Override
public void draw(Canvas canvas, Paint paint) {
float radius=getWidth()/10;
float x = getWidth()/ 2;
float y=getHeight()/2;
/*mMatrix.preTranslate(-centerX(), -centerY());
mMatrix.preRotate(degress,centerX(),centerY());
mMatrix.postTranslate(centerX(), centerY());
canvas.concat(mMatrix);*/
canvas.rotate(degress,centerX(),centerY());
canvas.save();
canvas.translate(x - radius * 2 - radius, y);
canvas.scale(scaleFloat, scaleFloat);
canvas.drawCircle(0, 0, radius, paint);
canvas.restore();
canvas.save();
canvas.translate(x, y);
canvas.scale(scaleFloat, scaleFloat);
canvas.drawCircle(0, 0, radius, paint);
canvas.restore();
canvas.save();
canvas.translate(x + radius * 2 + radius, y);
canvas.scale(scaleFloat, scaleFloat);
canvas.drawCircle(0,0,radius, paint);
canvas.restore();
}
@Override
public ArrayList<ValueAnimator> onCreateAnimators() {
ArrayList<ValueAnimator> animators=new ArrayList<>();
ValueAnimator scaleAnim=ValueAnimator.ofFloat(0.5f,1,0.5f);
scaleAnim.setDuration(1000);
scaleAnim.setRepeatCount(-1);
addUpdateListener(scaleAnim,new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
scaleFloat = (float) animation.getAnimatedValue();
postInvalidate();
}
});
ValueAnimator rotateAnim=ValueAnimator.ofFloat(0,180,360);
addUpdateListener(rotateAnim,new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
degress = (float) animation.getAnimatedValue();
postInvalidate();
}
});
rotateAnim.setDuration(1000);
rotateAnim.setRepeatCount(-1);
animators.add(scaleAnim);
animators.add(rotateAnim);
return animators;
}
}
package com.sdy.miya.moblie.component.dialog.avi.indicators;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.view.animation.LinearInterpolator;
import android.animation.ValueAnimator;
import com.sdy.miya.moblie.component.dialog.avi.Indicator;
import java.util.ArrayList;
/**
* Created by Jack on 2015/10/19.
*/
public class BallScaleIndicator extends Indicator {
float scale=1;
int alpha=255;
@Override
public void draw(Canvas canvas, Paint paint) {
float circleSpacing=4;
paint.setAlpha(alpha);
canvas.scale(scale,scale,getWidth()/2,getHeight()/2);
paint.setAlpha(alpha);
canvas.drawCircle(getWidth()/2,getHeight()/2,getWidth()/2-circleSpacing,paint);
}
@Override
public ArrayList<ValueAnimator> onCreateAnimators() {
ArrayList<ValueAnimator> animators=new ArrayList<>();
ValueAnimator scaleAnim=ValueAnimator.ofFloat(0,1);
scaleAnim.setInterpolator(new LinearInterpolator());
scaleAnim.setDuration(1000);
scaleAnim.setRepeatCount(-1);
addUpdateListener(scaleAnim,new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
scale = (float) animation.getAnimatedValue();
postInvalidate();
}
});
ValueAnimator alphaAnim=ValueAnimator.ofInt(255, 0);
alphaAnim.setInterpolator(new LinearInterpolator());
alphaAnim.setDuration(1000);
alphaAnim.setRepeatCount(-1);
addUpdateListener(alphaAnim,new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
alpha = (int) animation.getAnimatedValue();
postInvalidate();
}
});
animators.add(scaleAnim);
animators.add(alphaAnim);
return animators;
}
}
package com.sdy.miya.moblie.component.dialog.avi.indicators;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.view.animation.LinearInterpolator;
import android.animation.ValueAnimator;
import com.sdy.miya.moblie.component.dialog.avi.Indicator;
import java.util.ArrayList;
/**
* Created by Jack on 2015/10/19.
*/
public class BallScaleMultipleIndicator extends Indicator {
float[] scaleFloats=new float[]{1,1,1};
int[] alphaInts=new int[]{255,255,255};
@Override
public void draw(Canvas canvas, Paint paint) {
float circleSpacing=4;
for (int i = 0; i < 3; i++) {
paint.setAlpha(alphaInts[i]);
canvas.scale(scaleFloats[i],scaleFloats[i],getWidth()/2,getHeight()/2);
canvas.drawCircle(getWidth()/2,getHeight()/2,getWidth()/2-circleSpacing,paint);
}
}
@Override
public ArrayList<ValueAnimator> onCreateAnimators() {
ArrayList<ValueAnimator> animators=new ArrayList<>();
long[] delays=new long[]{0, 200, 400};
for (int i = 0; i < 3; i++) {
final int index=i;
ValueAnimator scaleAnim=ValueAnimator.ofFloat(0,1);
scaleAnim.setInterpolator(new LinearInterpolator());
scaleAnim.setDuration(1000);
scaleAnim.setRepeatCount(-1);
addUpdateListener(scaleAnim,new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
scaleFloats[index] = (float) animation.getAnimatedValue();
postInvalidate();
}
});
scaleAnim.setStartDelay(delays[i]);
ValueAnimator alphaAnim=ValueAnimator.ofInt(255,0);
alphaAnim.setInterpolator(new LinearInterpolator());
alphaAnim.setDuration(1000);
alphaAnim.setRepeatCount(-1);
addUpdateListener(alphaAnim,new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
alphaInts[index] = (int) animation.getAnimatedValue();
postInvalidate();
}
});
scaleAnim.setStartDelay(delays[i]);
animators.add(scaleAnim);
animators.add(alphaAnim);
}
return animators;
}
}
package com.sdy.miya.moblie.component.dialog.avi.indicators;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.view.animation.LinearInterpolator;
import android.animation.ValueAnimator;
import java.util.ArrayList;
/**
* Created by Jack on 2015/10/19.
*/
public class BallScaleRippleIndicator extends BallScaleIndicator {
@Override
public void draw(Canvas canvas, Paint paint) {
paint.setStyle(Paint.Style.STROKE);
paint.setStrokeWidth(3);
super.draw(canvas, paint);
}
@Override
public ArrayList<ValueAnimator> onCreateAnimators() {
ArrayList<ValueAnimator> animators=new ArrayList<>();
ValueAnimator scaleAnim=ValueAnimator.ofFloat(0,1);
scaleAnim.setInterpolator(new LinearInterpolator());
scaleAnim.setDuration(1000);
scaleAnim.setRepeatCount(-1);
addUpdateListener(scaleAnim,new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
scale = (float) animation.getAnimatedValue();
postInvalidate();
}
});
ValueAnimator alphaAnim=ValueAnimator.ofInt(0, 255);
alphaAnim.setInterpolator(new LinearInterpolator());
alphaAnim.setDuration(1000);
alphaAnim.setRepeatCount(-1);
addUpdateListener(alphaAnim,new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
alpha = (int) animation.getAnimatedValue();
postInvalidate();
}
});
animators.add(scaleAnim);
animators.add(alphaAnim);
return animators;
}
}
package com.sdy.miya.moblie.component.dialog.avi.indicators;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.view.animation.LinearInterpolator;
import android.animation.ValueAnimator;
import java.util.ArrayList;
/**
* Created by Jack on 2015/10/19.
*/
public class BallScaleRippleMultipleIndicator extends BallScaleMultipleIndicator {
@Override
public void draw(Canvas canvas, Paint paint) {
paint.setStyle(Paint.Style.STROKE);
paint.setStrokeWidth(3);
super.draw(canvas, paint);
}
@Override
public ArrayList<ValueAnimator> onCreateAnimators() {
ArrayList<ValueAnimator> animators=new ArrayList<>();
long[] delays=new long[]{0, 200, 400};
for (int i = 0; i < 3; i++) {
final int index=i;
ValueAnimator scaleAnim=ValueAnimator.ofFloat(0,1);
scaleAnim.setInterpolator(new LinearInterpolator());
scaleAnim.setDuration(1000);
scaleAnim.setRepeatCount(-1);
addUpdateListener(scaleAnim,new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
scaleFloats[index] = (float) animation.getAnimatedValue();
postInvalidate();
}
});
scaleAnim.setStartDelay(delays[i]);
ValueAnimator alphaAnim=ValueAnimator.ofInt(0,255);
scaleAnim.setInterpolator(new LinearInterpolator());
alphaAnim.setDuration(1000);
alphaAnim.setRepeatCount(-1);
addUpdateListener(alphaAnim,new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
alphaInts[index] = (int) animation.getAnimatedValue();
postInvalidate();
}
});
scaleAnim.setStartDelay(delays[i]);
animators.add(scaleAnim);
animators.add(alphaAnim);
}
return animators;
}
}
package com.sdy.miya.moblie.component.dialog.avi.indicators;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.animation.ValueAnimator;
import com.sdy.miya.moblie.component.dialog.avi.Indicator;
import java.util.ArrayList;
/**
* Created by Jack on 2015/10/20.
*/
public class BallSpinFadeLoaderIndicator extends Indicator {
public static final float SCALE=1.0f;
public static final int ALPHA=255;
float[] scaleFloats=new float[]{SCALE,
SCALE,
SCALE,
SCALE,
SCALE,
SCALE,
SCALE,
SCALE};
int[] alphas=new int[]{ALPHA,
ALPHA,
ALPHA,
ALPHA,
ALPHA,
ALPHA,
ALPHA,
ALPHA};
@Override
public void draw(Canvas canvas, Paint paint) {
float radius=getWidth()/10;
for (int i = 0; i < 8; i++) {
canvas.save();
Point point=circleAt(getWidth(),getHeight(),getWidth()/2-radius,i*(Math.PI/4));
canvas.translate(point.x,point.y);
canvas.scale(scaleFloats[i],scaleFloats[i]);
paint.setAlpha(alphas[i]);
canvas.drawCircle(0,0,radius,paint);
canvas.restore();
}
}
@Override
public ArrayList<ValueAnimator> onCreateAnimators() {
ArrayList<ValueAnimator> animators=new ArrayList<>();
int[] delays= {0, 120, 240, 360, 480, 600, 720, 780, 840};
for (int i = 0; i < 8; i++) {
final int index=i;
ValueAnimator scaleAnim=ValueAnimator.ofFloat(1,0.4f,1);
scaleAnim.setDuration(1000);
scaleAnim.setRepeatCount(-1);
scaleAnim.setStartDelay(delays[i]);
addUpdateListener(scaleAnim,new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
scaleFloats[index] = (float) animation.getAnimatedValue();
postInvalidate();
}
});
ValueAnimator alphaAnim=ValueAnimator.ofInt(255, 77, 255);
alphaAnim.setDuration(1000);
alphaAnim.setRepeatCount(-1);
alphaAnim.setStartDelay(delays[i]);
addUpdateListener(alphaAnim,new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
alphas[index] = (int) animation.getAnimatedValue();
postInvalidate();
}
});
animators.add(scaleAnim);
animators.add(alphaAnim);
}
return animators;
}
/**
* 圆O的圆心为(a,b),半径为R,点A与到X轴的为角α.
*则点A的坐标为(a+R*cosα,b+R*sinα)
* @param width
* @param height
* @param radius
* @param angle
* @return
*/
Point circleAt(int width,int height,float radius,double angle){
float x= (float) (width/2+radius*(Math.cos(angle)));
float y= (float) (height/2+radius*(Math.sin(angle)));
return new Point(x,y);
}
final class Point{
public float x;
public float y;
public Point(float x, float y){
this.x=x;
this.y=y;
}
}
}
package com.sdy.miya.moblie.component.dialog.avi.indicators;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.view.animation.LinearInterpolator;
import android.animation.ValueAnimator;
import com.sdy.miya.moblie.component.dialog.avi.Indicator;
import java.util.ArrayList;
/**
* Created by Jack on 2015/10/19.
*/
public class BallTrianglePathIndicator extends Indicator {
float[] translateX=new float[3],translateY=new float[3];
@Override
public void draw(Canvas canvas, Paint paint) {
paint.setStrokeWidth(3);
paint.setStyle(Paint.Style.STROKE);
for (int i = 0; i < 3; i++) {
canvas.save();
canvas.translate(translateX[i], translateY[i]);
canvas.drawCircle(0, 0, getWidth() / 10, paint);
canvas.restore();
}
}
@Override
public ArrayList<ValueAnimator> onCreateAnimators() {
ArrayList<ValueAnimator> animators=new ArrayList<>();
float startX=getWidth()/5;
float startY=getWidth()/5;
for (int i = 0; i < 3; i++) {
final int index=i;
ValueAnimator translateXAnim=ValueAnimator.ofFloat(getWidth()/2,getWidth()-startX,startX,getWidth()/2);
if (i==1){
translateXAnim=ValueAnimator.ofFloat(getWidth()-startX,startX,getWidth()/2,getWidth()-startX);
}else if (i==2){
translateXAnim=ValueAnimator.ofFloat(startX,getWidth()/2,getWidth()-startX,startX);
}
ValueAnimator translateYAnim=ValueAnimator.ofFloat(startY,getHeight()-startY,getHeight()-startY,startY);
if (i==1){
translateYAnim=ValueAnimator.ofFloat(getHeight()-startY,getHeight()-startY,startY,getHeight()-startY);
}else if (i==2){
translateYAnim=ValueAnimator.ofFloat(getHeight()-startY,startY,getHeight()-startY,getHeight()-startY);
}
translateXAnim.setDuration(2000);
translateXAnim.setInterpolator(new LinearInterpolator());
translateXAnim.setRepeatCount(-1);
addUpdateListener(translateXAnim,new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
translateX [index]= (float) animation.getAnimatedValue();
postInvalidate();
}
});
translateYAnim.setDuration(2000);
translateYAnim.setInterpolator(new LinearInterpolator());
translateYAnim.setRepeatCount(-1);
addUpdateListener(translateYAnim,new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
translateY [index]= (float) animation.getAnimatedValue();
postInvalidate();
}
});
animators.add(translateXAnim);
animators.add(translateYAnim);
}
return animators;
}
}
package com.sdy.miya.moblie.component.dialog.avi.indicators;
import android.view.animation.LinearInterpolator;
import android.animation.ValueAnimator;
import java.util.ArrayList;
/**
* Created by Jack on 2015/10/19.
*/
public class BallZigZagDeflectIndicator extends BallZigZagIndicator {
@Override
public ArrayList<ValueAnimator> onCreateAnimators() {
ArrayList<ValueAnimator> animators=new ArrayList<>();
float startX=getWidth()/6;
float startY=getWidth()/6;
for (int i = 0; i < 2; i++) {
final int index=i;
ValueAnimator translateXAnim=ValueAnimator.ofFloat(startX,getWidth()-startX,startX,getWidth()-startX,startX);
if (i==1){
translateXAnim=ValueAnimator.ofFloat(getWidth()-startX,startX,getWidth()-startX,startX,getWidth()-startX);
}
ValueAnimator translateYAnim=ValueAnimator.ofFloat(startY,startY,getHeight()-startY,getHeight()-startY,startY);
if (i==1){
translateYAnim=ValueAnimator.ofFloat(getHeight()-startY,getHeight()-startY,startY,startY,getHeight()-startY);
}
translateXAnim.setDuration(2000);
translateXAnim.setInterpolator(new LinearInterpolator());
translateXAnim.setRepeatCount(-1);
addUpdateListener(translateXAnim,new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
translateX [index]= (float) animation.getAnimatedValue();
postInvalidate();
}
});
translateYAnim.setDuration(2000);
translateYAnim.setInterpolator(new LinearInterpolator());
translateYAnim.setRepeatCount(-1);
addUpdateListener(translateYAnim,new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
translateY [index]= (float) animation.getAnimatedValue();
postInvalidate();
}
});
animators.add(translateXAnim);
animators.add(translateYAnim);
}
return animators;
}
}
package com.sdy.miya.moblie.component.dialog.avi.indicators;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.view.animation.LinearInterpolator;
import android.animation.ValueAnimator;
import com.sdy.miya.moblie.component.dialog.avi.Indicator;
import java.util.ArrayList;
/**
* Created by Jack on 2015/10/19.
*/
public class BallZigZagIndicator extends Indicator {
float[] translateX=new float[2],translateY=new float[2];
@Override
public void draw(Canvas canvas, Paint paint) {
for (int i = 0; i < 2; i++) {
canvas.save();
canvas.translate(translateX[i], translateY[i]);
canvas.drawCircle(0, 0, getWidth() / 10, paint);
canvas.restore();
}
}
@Override
public ArrayList<ValueAnimator> onCreateAnimators() {
ArrayList<ValueAnimator> animators=new ArrayList<>();
float startX=getWidth()/6;
float startY=getWidth()/6;
for (int i = 0; i < 2; i++) {
final int index=i;
ValueAnimator translateXAnim=ValueAnimator.ofFloat(startX,getWidth()-startX,getWidth()/2,startX);
if (i==1){
translateXAnim=ValueAnimator.ofFloat(getWidth()-startX,startX,getWidth()/2,getWidth()-startX);
}
ValueAnimator translateYAnim=ValueAnimator.ofFloat(startY,startY,getHeight()/2,startY);
if (i==1){
translateYAnim=ValueAnimator.ofFloat(getHeight()-startY,getHeight()-startY,getHeight()/2,getHeight()-startY);
}
translateXAnim.setDuration(1000);
translateXAnim.setInterpolator(new LinearInterpolator());
translateXAnim.setRepeatCount(-1);
addUpdateListener(translateXAnim,new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
translateX[index] = (float) animation.getAnimatedValue();
postInvalidate();
}
});
translateYAnim.setDuration(1000);
translateYAnim.setInterpolator(new LinearInterpolator());
translateYAnim.setRepeatCount(-1);
addUpdateListener(translateYAnim,new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
translateY[index] = (float) animation.getAnimatedValue();
postInvalidate();
}
});
animators.add(translateXAnim);
animators.add(translateYAnim);
}
return animators;
}
}
package com.sdy.miya.moblie.component.dialog.avi.indicators;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.RectF;
import android.view.animation.LinearInterpolator;
import android.animation.ValueAnimator;
import com.sdy.miya.moblie.component.dialog.avi.Indicator;
import java.util.ArrayList;
/**
* Created by Jack on 2015/10/18.
*/
public class CubeTransitionIndicator extends Indicator {
float[] translateX=new float[2],translateY=new float[2];
float degrees,scaleFloat=1.0f;
@Override
public void draw(Canvas canvas, Paint paint) {
float rWidth=getWidth()/5;
float rHeight=getHeight()/5;
for (int i = 0; i < 2; i++) {
canvas.save();
canvas.translate(translateX[i], translateY[i]);
canvas.rotate(degrees);
canvas.scale(scaleFloat,scaleFloat);
RectF rectF=new RectF(-rWidth/2,-rHeight/2,rWidth/2,rHeight/2);
canvas.drawRect(rectF,paint);
canvas.restore();
}
}
@Override
public ArrayList<ValueAnimator> onCreateAnimators() {
ArrayList<ValueAnimator> animators=new ArrayList<>();
float startX=getWidth()/5;
float startY=getHeight()/5;
for (int i = 0; i < 2; i++) {
final int index=i;
translateX[index]=startX;
ValueAnimator translationXAnim=ValueAnimator.ofFloat(startX,getWidth()-startX,getWidth()-startX, startX,startX);
if (i==1){
translationXAnim=ValueAnimator.ofFloat(getWidth()-startX,startX,startX, getWidth()-startX,getWidth()-startX);
}
translationXAnim.setInterpolator(new LinearInterpolator());
translationXAnim.setDuration(1600);
translationXAnim.setRepeatCount(-1);
translationXAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
translateX[index] = (float) animation.getAnimatedValue();
postInvalidate();
}
});
translateY[index]=startY;
ValueAnimator translationYAnim=ValueAnimator.ofFloat(startY,startY,getHeight()-startY,getHeight()- startY,startY);
if (i==1){
translationYAnim=ValueAnimator.ofFloat(getHeight()-startY,getHeight()-startY,startY,startY,getHeight()-startY);
}
translationYAnim.setDuration(1600);
translationYAnim.setInterpolator(new LinearInterpolator());
translationYAnim.setRepeatCount(-1);
addUpdateListener(translationYAnim,new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
translateY[index] = (float) animation.getAnimatedValue();
postInvalidate();
}
});
animators.add(translationXAnim);
animators.add(translationYAnim);
}
ValueAnimator scaleAnim=ValueAnimator.ofFloat(1,0.5f,1,0.5f,1);
scaleAnim.setDuration(1600);
scaleAnim.setInterpolator(new LinearInterpolator());
scaleAnim.setRepeatCount(-1);
addUpdateListener(scaleAnim,new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
scaleFloat = (float) animation.getAnimatedValue();
postInvalidate();
}
});
ValueAnimator rotateAnim=ValueAnimator.ofFloat(0,180,360,1.5f*360,2*360);
rotateAnim.setDuration(1600);
rotateAnim.setInterpolator(new LinearInterpolator());
rotateAnim.setRepeatCount(-1);
addUpdateListener(rotateAnim,new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
degrees = (float) animation.getAnimatedValue();
postInvalidate();
}
});
animators.add(scaleAnim);
animators.add(rotateAnim);
return animators;
}
}
package com.sdy.miya.moblie.component.dialog.avi.indicators;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.RectF;
import android.animation.ValueAnimator;
import com.sdy.miya.moblie.component.dialog.avi.Indicator;
import java.util.ArrayList;
/**
* Created by Jack on 2015/10/19.
*/
public class LineScaleIndicator extends Indicator {
public static final float SCALE=1.0f;
float[] scaleYFloats=new float[]{SCALE,
SCALE,
SCALE,
SCALE,
SCALE,};
@Override
public void draw(Canvas canvas, Paint paint) {
float translateX=getWidth()/11;
float translateY=getHeight()/2;
for (int i = 0; i < 5; i++) {
canvas.save();
canvas.translate((2 + i * 2) * translateX - translateX / 2, translateY);
canvas.scale(SCALE, scaleYFloats[i]);
RectF rectF=new RectF(-translateX/2,-getHeight()/2.5f,translateX/2,getHeight()/2.5f);
canvas.drawRoundRect(rectF, 5, 5, paint);
canvas.restore();
}
}
@Override
public ArrayList<ValueAnimator> onCreateAnimators() {
ArrayList<ValueAnimator> animators=new ArrayList<>();
long[] delays=new long[]{100,200,300,400,500};
for (int i = 0; i < 5; i++) {
final int index=i;
ValueAnimator scaleAnim=ValueAnimator.ofFloat(1, 0.4f, 1);
scaleAnim.setDuration(1000);
scaleAnim.setRepeatCount(-1);
scaleAnim.setStartDelay(delays[i]);
addUpdateListener(scaleAnim,new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
scaleYFloats[index] = (float) animation.getAnimatedValue();
postInvalidate();
}
});
animators.add(scaleAnim);
}
return animators;
}
}
package com.sdy.miya.moblie.component.dialog.avi.indicators;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.RectF;
import android.animation.ValueAnimator;
import com.sdy.miya.moblie.component.dialog.avi.Indicator;
import java.util.ArrayList;
/**
* Created by Jack on 2015/10/19.
*/
public class LineScalePartyIndicator extends Indicator {
public static final float SCALE=1.0f;
float[] scaleFloats=new float[]{SCALE,
SCALE,
SCALE,
SCALE,
SCALE,};
@Override
public void draw(Canvas canvas, Paint paint) {
float translateX=getWidth()/9;
float translateY=getHeight()/2;
for (int i = 0; i < 4; i++) {
canvas.save();
canvas.translate((2 + i * 2) * translateX - translateX / 2, translateY);
canvas.scale(scaleFloats[i], scaleFloats[i]);
RectF rectF=new RectF(-translateX/2,-getHeight()/2.5f,translateX/2,getHeight()/2.5f);
canvas.drawRoundRect(rectF,5,5,paint);
canvas.restore();
}
}
@Override
public ArrayList<ValueAnimator> onCreateAnimators() {
ArrayList<ValueAnimator> animators=new ArrayList<>();
long[] durations=new long[]{1260, 430, 1010, 730};
long[] delays=new long[]{770, 290, 280, 740};
for (int i = 0; i < 4; i++) {
final int index=i;
ValueAnimator scaleAnim=ValueAnimator.ofFloat(1,0.4f,1);
scaleAnim.setDuration(durations[i]);
scaleAnim.setRepeatCount(-1);
scaleAnim.setStartDelay(delays[i]);
addUpdateListener(scaleAnim,new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
scaleFloats[index] = (float) animation.getAnimatedValue();
postInvalidate();
}
});
animators.add(scaleAnim);
}
return animators;
}
}
package com.sdy.miya.moblie.component.dialog.avi.indicators;
import android.animation.ValueAnimator;
import java.util.ArrayList;
/**
* Created by Jack on 2015/10/19.
*/
public class LineScalePulseOutIndicator extends LineScaleIndicator {
@Override
public ArrayList<ValueAnimator> onCreateAnimators() {
ArrayList<ValueAnimator> animators=new ArrayList<>();
long[] delays=new long[]{500,250,0,250,500};
for (int i = 0; i < 5; i++) {
final int index=i;
ValueAnimator scaleAnim=ValueAnimator.ofFloat(1,0.3f,1);
scaleAnim.setDuration(900);
scaleAnim.setRepeatCount(-1);
scaleAnim.setStartDelay(delays[i]);
addUpdateListener(scaleAnim,new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
scaleYFloats[index] = (float) animation.getAnimatedValue();
postInvalidate();
}
});
animators.add(scaleAnim);
}
return animators;
}
}
package com.sdy.miya.moblie.component.dialog.avi.indicators;
import android.animation.ValueAnimator;
import java.util.ArrayList;
/**
* Created by Jack on 2015/10/19.
*/
public class LineScalePulseOutRapidIndicator extends LineScaleIndicator {
@Override
public ArrayList<ValueAnimator> onCreateAnimators() {
ArrayList<ValueAnimator> animators=new ArrayList<>();
long[] delays=new long[]{400,200,0,200,400};
for (int i = 0; i < 5; i++) {
final int index=i;
ValueAnimator scaleAnim=ValueAnimator.ofFloat(1,0.4f,1);
scaleAnim.setDuration(1000);
scaleAnim.setRepeatCount(-1);
scaleAnim.setStartDelay(delays[i]);
addUpdateListener(scaleAnim,new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
scaleYFloats[index] = (float) animation.getAnimatedValue();
postInvalidate();
}
});
animators.add(scaleAnim);
}
return animators;
}
}
package com.sdy.miya.moblie.component.dialog.avi.indicators;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.RectF;
/**
* Created by Jack on 2015/10/24.
* Email:81813780@qq.com
*/
public class LineSpinFadeLoaderIndicator extends BallSpinFadeLoaderIndicator {
@Override
public void draw(Canvas canvas, Paint paint) {
float radius=getWidth()/10;
for (int i = 0; i < 8; i++) {
canvas.save();
Point point=circleAt(getWidth(),getHeight(),getWidth()/2.5f-radius,i*(Math.PI/4));
canvas.translate(point.x, point.y);
canvas.scale(scaleFloats[i], scaleFloats[i]);
canvas.rotate(i*45);
paint.setAlpha(alphas[i]);
RectF rectF=new RectF(-radius,-radius/1.5f,1.5f*radius,radius/1.5f);
canvas.drawRoundRect(rectF,5,5,paint);
canvas.restore();
}
}
}
package com.sdy.miya.moblie.component.dialog.avi.indicators;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.RectF;
import android.view.animation.LinearInterpolator;
import android.animation.ValueAnimator;
import com.sdy.miya.moblie.component.dialog.avi.Indicator;
import java.util.ArrayList;
/**
* Created by Jack on 2015/10/16.
*/
public class PacmanIndicator extends Indicator {
private float translateX;
private int alpha;
private float degrees1,degrees2;
@Override
public void draw(Canvas canvas, Paint paint) {
drawPacman(canvas,paint);
drawCircle(canvas,paint);
}
private void drawPacman(Canvas canvas,Paint paint){
float x=getWidth()/2;
float y=getHeight()/2;
canvas.save();
canvas.translate(x, y);
canvas.rotate(degrees1);
paint.setAlpha(255);
RectF rectF1=new RectF(-x/1.7f,-y/1.7f,x/1.7f,y/1.7f);
canvas.drawArc(rectF1, 0, 270, true, paint);
canvas.restore();
canvas.save();
canvas.translate(x, y);
canvas.rotate(degrees2);
paint.setAlpha(255);
RectF rectF2=new RectF(-x/1.7f,-y/1.7f,x/1.7f,y/1.7f);
canvas.drawArc(rectF2,90,270,true,paint);
canvas.restore();
}
private void drawCircle(Canvas canvas, Paint paint) {
float radius=getWidth()/11;
paint.setAlpha(alpha);
canvas.drawCircle(translateX, getHeight() / 2, radius, paint);
}
@Override
public ArrayList<ValueAnimator> onCreateAnimators() {
ArrayList<ValueAnimator> animators=new ArrayList<>();
float startT=getWidth()/11;
ValueAnimator translationAnim=ValueAnimator.ofFloat(getWidth()-startT,getWidth()/2);
translationAnim.setDuration(650);
translationAnim.setInterpolator(new LinearInterpolator());
translationAnim.setRepeatCount(-1);
addUpdateListener(translationAnim,new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
translateX = (float) animation.getAnimatedValue();
postInvalidate();
}
});
ValueAnimator alphaAnim=ValueAnimator.ofInt(255,122);
alphaAnim.setDuration(650);
alphaAnim.setRepeatCount(-1);
addUpdateListener(alphaAnim,new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
alpha = (int) animation.getAnimatedValue();
postInvalidate();
}
});
ValueAnimator rotateAnim1=ValueAnimator.ofFloat(0, 45, 0);
rotateAnim1.setDuration(650);
rotateAnim1.setRepeatCount(-1);
addUpdateListener(rotateAnim1,new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
degrees1 = (float) animation.getAnimatedValue();
postInvalidate();
}
});
ValueAnimator rotateAnim2=ValueAnimator.ofFloat(0,-45,0);
rotateAnim2.setDuration(650);
rotateAnim2.setRepeatCount(-1);
addUpdateListener(rotateAnim2,new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
degrees2 = (float) animation.getAnimatedValue();
postInvalidate();
}
});
animators.add(translationAnim);
animators.add(alphaAnim);
animators.add(rotateAnim1);
animators.add(rotateAnim2);
return animators;
}
}
package com.sdy.miya.moblie.component.dialog.avi.indicators;
import android.animation.ValueAnimator;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.RectF;
import com.sdy.miya.moblie.component.dialog.avi.Indicator;
import java.util.ArrayList;
/**
* Created by Jack on 2015/10/20.
*/
public class SemiCircleSpinIndicator extends Indicator {
private float degress;
@Override
public void draw(Canvas canvas, Paint paint) {
canvas.rotate(degress,centerX(),centerY());
RectF rectF=new RectF(0,0,getWidth(),getHeight());
canvas.drawArc(rectF,-60,120,false,paint);
}
@Override
public ArrayList<ValueAnimator> onCreateAnimators() {
ArrayList<ValueAnimator> animators=new ArrayList<>();
ValueAnimator rotateAnim=ValueAnimator.ofFloat(0,180,360);
addUpdateListener(rotateAnim,new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
degress= (float) animation.getAnimatedValue();
postInvalidate();
}
});
rotateAnim.setDuration(600);
rotateAnim.setRepeatCount(-1);
animators.add(rotateAnim);
return animators;
}
}
package com.sdy.miya.moblie.component.dialog.avi.indicators;
import android.animation.ValueAnimator;
import android.graphics.Camera;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.RectF;
import android.view.animation.LinearInterpolator;
import com.sdy.miya.moblie.component.dialog.avi.Indicator;
import java.util.ArrayList;
/**
* Created by Jack on 2015/10/16.
*/
public class SquareSpinIndicator extends Indicator {
private float rotateX;
private float rotateY;
private Camera mCamera;
private Matrix mMatrix;
public SquareSpinIndicator(){
mCamera=new Camera();
mMatrix=new Matrix();
}
@Override
public void draw(Canvas canvas, Paint paint) {
mMatrix.reset();
mCamera.save();
mCamera.rotateX(rotateX);
mCamera.rotateY(rotateY);
mCamera.getMatrix(mMatrix);
mCamera.restore();
mMatrix.preTranslate(-centerX(), -centerY());
mMatrix.postTranslate(centerX(), centerY());
canvas.concat(mMatrix);
canvas.drawRect(new RectF(getWidth()/5,getHeight()/5,getWidth()*4/5,getHeight()*4/5),paint);
}
@Override
public ArrayList<ValueAnimator> onCreateAnimators() {
ArrayList<ValueAnimator> animators=new ArrayList<>();
ValueAnimator animator=ValueAnimator.ofFloat(0,180,180,0,0);
addUpdateListener(animator,new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
rotateX= (float) animation.getAnimatedValue();
postInvalidate();
}
});
animator.setInterpolator(new LinearInterpolator());
animator.setRepeatCount(-1);
animator.setDuration(2500);
ValueAnimator animator1=ValueAnimator.ofFloat(0,0,180,180,0);
addUpdateListener(animator1,new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
rotateY= (float) animation.getAnimatedValue();
postInvalidate();
}
});
animator1.setInterpolator(new LinearInterpolator());
animator1.setRepeatCount(-1);
animator1.setDuration(2500);
animators.add(animator);
animators.add(animator1);
return animators;
}
}
package com.sdy.miya.moblie.component.dialog.avi.indicators;
import android.animation.ValueAnimator;
import android.graphics.Camera;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.Path;
import android.view.animation.LinearInterpolator;
import com.sdy.miya.moblie.component.dialog.avi.Indicator;
import java.util.ArrayList;
/**
* Created by Jack on 2015/10/20.
*/
public class TriangleSkewSpinIndicator extends Indicator {
private float rotateX;
private float rotateY;
private Camera mCamera;
private Matrix mMatrix;
public TriangleSkewSpinIndicator(){
mCamera=new Camera();
mMatrix=new Matrix();
}
@Override
public void draw(Canvas canvas, Paint paint) {
mMatrix.reset();
mCamera.save();
mCamera.rotateX(rotateX);
mCamera.rotateY(rotateY);
mCamera.getMatrix(mMatrix);
mCamera.restore();
mMatrix.preTranslate(-centerX(), -centerY());
mMatrix.postTranslate(centerX(), centerY());
canvas.concat(mMatrix);
Path path=new Path();
path.moveTo(getWidth()/5,getHeight()*4/5);
path.lineTo(getWidth()*4/5, getHeight()*4/5);
path.lineTo(getWidth()/2,getHeight()/5);
path.close();
canvas.drawPath(path, paint);
}
@Override
public ArrayList<ValueAnimator> onCreateAnimators() {
ArrayList<ValueAnimator> animators=new ArrayList<>();
ValueAnimator animator=ValueAnimator.ofFloat(0,180,180,0,0);
addUpdateListener(animator,new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
rotateX= (float) animation.getAnimatedValue();
postInvalidate();
}
});
animator.setInterpolator(new LinearInterpolator());
animator.setRepeatCount(-1);
animator.setDuration(2500);
ValueAnimator animator1=ValueAnimator.ofFloat(0,0,180,180,0);
addUpdateListener(animator1,new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
rotateY= (float) animation.getAnimatedValue();
postInvalidate();
}
});
animator1.setInterpolator(new LinearInterpolator());
animator1.setRepeatCount(-1);
animator1.setDuration(2500);
animators.add(animator);
animators.add(animator1);
return animators;
}
}
<vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt"
android:width="108dp"
android:height="108dp"
android:viewportWidth="108"
android:viewportHeight="108">
<path android:pathData="M31,63.928c0,0 6.4,-11 12.1,-13.1c7.2,-2.6 26,-1.4 26,-1.4l38.1,38.1L107,108.928l-32,-1L31,63.928z">
<aapt:attr name="android:fillColor">
<gradient
android:endX="85.84757"
android:endY="92.4963"
android:startX="42.9492"
android:startY="49.59793"
android:type="linear">
<item
android:color="#44000000"
android:offset="0.0" />
<item
android:color="#00000000"
android:offset="1.0" />
</gradient>
</aapt:attr>
</path>
<path
android:fillColor="#FFFFFF"
android:fillType="nonZero"
android:pathData="M65.3,45.828l3.8,-6.6c0.2,-0.4 0.1,-0.9 -0.3,-1.1c-0.4,-0.2 -0.9,-0.1 -1.1,0.3l-3.9,6.7c-6.3,-2.8 -13.4,-2.8 -19.7,0l-3.9,-6.7c-0.2,-0.4 -0.7,-0.5 -1.1,-0.3C38.8,38.328 38.7,38.828 38.9,39.228l3.8,6.6C36.2,49.428 31.7,56.028 31,63.928h46C76.3,56.028 71.8,49.428 65.3,45.828zM43.4,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2c-0.3,-0.7 -0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C45.3,56.528 44.5,57.328 43.4,57.328L43.4,57.328zM64.6,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2s-0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C66.5,56.528 65.6,57.328 64.6,57.328L64.6,57.328z"
android:strokeWidth="1"
android:strokeColor="#00000000" />
</vector>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp"
android:height="108dp"
android:viewportWidth="108"
android:viewportHeight="108">
<path
android:fillColor="#3DDC84"
android:pathData="M0,0h108v108h-108z" />
<path
android:fillColor="#00000000"
android:pathData="M9,0L9,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,0L19,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M29,0L29,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M39,0L39,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M49,0L49,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M59,0L59,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M69,0L69,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M79,0L79,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M89,0L89,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M99,0L99,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,9L108,9"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,19L108,19"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,29L108,29"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,39L108,39"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,49L108,49"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,59L108,59"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,69L108,69"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,79L108,79"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,89L108,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,99L108,99"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,29L89,29"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,39L89,39"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,49L89,49"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,59L89,59"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,69L89,69"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,79L89,79"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M29,19L29,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M39,19L39,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M49,19L49,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M59,19L59,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M69,19L69,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M79,19L79,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
</vector>
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon>
\ No newline at end of file
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
<style name="Theme.Selfcashierterminalcomponentcommonwidget" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Primary brand color. -->
<item name="colorPrimary">@color/purple_200</item>
<item name="colorPrimaryDark">@color/purple_700</item>
<item name="colorAccent">@color/teal_200</item>
<!-- Customize your theme here. -->
</style>
</resources>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<resources>
<declare-styleable name="AVLoadingIndicatorView">
<attr name="minWidth" format="dimension" />
<attr name="maxWidth" format="dimension"/>
<attr name="minHeight" format="dimension" />
<attr name="maxHeight" format="dimension"/>
<attr name="indicatorName" format="string"/>
<attr name="indicatorColor" format="color"/>
</declare-styleable>
</resources>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="AVLoadingIndicatorView">
<item name="minWidth">48dip</item>
<item name="maxWidth">48dip</item>
<item name="minHeight">48dip</item>
<item name="maxHeight">48dip</item>
<item name="indicatorName">BallPulseIndicator</item>
</style>
<style name="AVLoadingIndicatorView.Large">
<item name="minWidth">76dip</item>
<item name="maxWidth">76dip</item>
<item name="minHeight">76dip</item>
<item name="maxHeight">76dip</item>
<item name="indicatorName">BallPulseIndicator</item>
</style>
<style name="AVLoadingIndicatorView.Small">
<item name="minWidth">24dip</item>
<item name="maxWidth">24dip</item>
<item name="minHeight">24dip</item>
<item name="maxHeight">24dip</item>
<item name="indicatorName">BallPulseIndicator</item>
</style>
</resources>
\ No newline at end of file
package com.changqin.study.component;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* Example local unit test, which will execute on the development machine (host).
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() {
assertEquals(4, 2 + 2);
}
}
\ No newline at end of file
*.iml
.gradle
/local.properties
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
.DS_Store
*/build
/build
/captures
.externalNativeBuild
/.idea/*
*/build/
apply plugin: 'com.android.library'
apply plugin: "maven-publish"
apply plugin: 'maven' //发布到maven 库中的插件
android {
compileSdkVersion rootProject.ext.compileSdkVersion
defaultConfig {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "1.0"
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
def common = rootProject.ext.common
implementation common.appcompat
implementation common.fragment
implementation common.recyclerview
implementation common.common_dialog
}
//}
//设置动态属性
ext {
//发布到仓库用户名
publishUserName = "face-dev"
//发布到仓库地址
publishUserPassword = "Face-dev@2019"
//仓库地址
publishURL = "https://nexus.infra.miyatech.com/repository/shualianzhifu/"
publishVersion = 0.03
publishArtifactId = "common-file-picker"
}
uploadArchives {
repositories.mavenDeployer {
repository(url: publishURL) {//RELEASE
authentication(userName: publishUserName, password: publishUserPassword)
}
pom.project {
version '0.03'
artifactId 'common-file-picker'
groupId 'com.miya.iot'
packaging 'jar'
description 'file-picker'
}
}
}
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
################common###############
-keep class **$Properties
-dontwarn java.beans.**
## ----------Apache Commons-----------##
-keep class org.apache.commons.** { *; }
-dontwarn org.apache.commons.**
## ----------Apache Commons-----------##
-dontwarn org.apache.log4j.**
-dontwarn org.apache.commons.logging.**
-keep class org.** { *; }
-keepclasseswithmembernames class * {
native <methods>;
}
-keepclasseswithmembernames class * {
public <init>(android.updateLog.Context, android.util.AttributeSet);
}
-keepclasseswithmembernames class * {
public <init>(android.updateLog.Context, android.util.AttributeSet, int);
}
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}
-keep class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator *;
}
-keepclassmembers class **.R$* {
public static <fields>;
}
# 保护注解
-keepattributes *Annotation*
-keep class * extends java.lang.annotation.Annotation {*;}
-keepclassmembers class ** {
@com.hwangjr.rxbus.annotation.Subscribe <methods>;
}
-keepclassmembers class ** {
@com.hwangjr.rxbus.annotation.Tag <methods>;
}
################Gson#######################
-keepattributes Signature
-keepattributes EnclosingMethod
# 不混淆内部类
-keepattributes InnerClasses
# Gson specific classes
-keep class sun.misc.Unsafe { *; }
# Application classes that will be serialized/deserialized over Gson
-keep class com.google.gson.** { *; }
-keep class com.google.gson.stream.** { *; }
# OkHttp
-keep class com.squareup.okhttp.** { *; }
-keep interface com.squareup.okhttp.** { *; }
-dontwarn com.squareup.okhttp.**
-keep class okhttp3.** { *; }
-dontwarn okhttp3.**
-keep class okhttp3.internal.**{*;}
-keep class okio.** { *; }
# fastjson
-dontwarn com.alibaba.fastjson.**
# Okio
-keep class sun.misc.Unsafe{ *; }
-dontwarn java.nio.file.*
-dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
-dontwarn okio.**
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}
-keep class org.apache.commons.lang3.**{*;}
# retrofit2
# Platform calls Class.forName on types which do not exist on Android to determine platform.
-dontnote retrofit.Platform
# Platform used when running on RoboVM on iOS. Will not be used at runtime.
# Platform used when running on Java 8 VMs. Will not be used at runtime.
-dontwarn retrofit.Platform$Java8
-dontwarn org.w3c.dom.Node
# Retain declared checked exceptions for use by a Proxy instance.
-keepattributes Exceptions
-dontwarn retrofit2.**
-dontwarn retrofit.appengine.UrlFetchClient
-keep class retrofit2.** { *; }
-keepclasseswithmembers class * {
@retrofit.http.* <methods>;
}
#xml解析
-libraryjars <java.home>/lib/rt.jar
-keepattributes ElementList, Root
-keep public class org.simpleframework.** { *; }
-dontwarn com.bea.xml.stream.**
-dontwarn org.simpleframework.xml.stream.**
-keep class org.simpleframework.xml.**{ *; }
-keepclassmembers,allowobfuscation class * {
@org.simpleframework.xml.* <fields>;
@org.simpleframework.xml.* <init>(...);
}
-dontwarn javax.xml.stream.events.**
-dontwarn javax.xml.**
-keepclassmembers class * {
@org.simpleframework.xml.* *;
}
-keep interface org.simpleframework.xml.core.Label {
public *;
}
-keep class * implements org.simpleframework.xml.core.Label {
public *;
}
-keep interface org.simpleframework.xml.core.Parameter {
public *;
}
-keep class * implements org.simpleframework.xml.core.Parameter {
public *;
}
-keep interface org.simpleframework.xml.core.Extractor {
public *;
}
-keep class * implements org.simpleframework.xml.core.Extractor {
public *;
}
-keep class java.beans.** { *; }
-keep class test.org.tap.security.positiontable.** { *; }
-keep class org.tap.** { *; }
-keep class org.apache.log4j.** { *; }
-keep class com.tap.operation.** { *; }
-dontwarn org.tap.security.**
-keep class rx.** { *; }
-keep class javax.** { *; }
-keep class com.miya.** { *; }
-keep class miyaapay.** { *; }
-keep class com.google.** { *; }
-keep class org.simpleframework.** { *; }
-keep class com.sdy.miya.moblie.component.pay.core.** { *; }
-keep class com.sdy.miya.moblie.component.pay.midhub.bean.** { *; }
-keep class com.sdy.miya.moblie.component.pay.midhub.sign.** { *; }
-keep class com.sdy.miya.moblie.component.pay.platform.bean.** { *; }
-keep class com.miya.** { *; }
-keep class com.sdy.miya.moblie.component.pay.platform.MiYaPlatformPayService{
public *;
}
-keep class com.sdy.miya.moblie.component.pay.midhub.MiYaMidHubPayService{
public *;
}
-keep class com.sdy.miya.moblie.component.pay.jar.MiYaJarPayService{
public *;
}
-keep class MiYaPayMobileApiClient{
public *;
}
-keep class com.alibaba.fastjson.** { *; }
-keep class com.squareup.** { *; }
-dontwarn javax.**
-dontwarn rx.**
-dontwarn org.simpleframework.xml.**
-dontwarn com.google.gson.JsonParseException
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.sdy.miya.moblie.component.filepicker">
<application>
<activity android:name=".LFilePickerActivity"/>
</application>
</manifest>
\ No newline at end of file
package com.sdy.miya.moblie.component.filepicker;
import java.util.ArrayList;
public interface IFilePickerCallback {
void onChoseFile(ArrayList<String> choseFiles, String path, IFilePickerHandle handle);
}
\ No newline at end of file
package com.sdy.miya.moblie.component.filepicker;
public interface IFilePickerHandle {
void CloseFilePicker();
void showLoading();
void hideLoading();
}
package com.sdy.miya.moblie.component.filepicker;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.annotation.StyleRes;
import androidx.fragment.app.Fragment;
import com.sdy.miya.moblie.component.filepicker.model.ParamEntity;
/**
* 作者:Leon
* 时间:2017/3/20 16:57
*/
public class LFilePicker {
private Activity mActivity;
private Fragment mFragment;
private android.app.Fragment mSupportFragment;
private String mTitle;
private String mTitleColor;
private int theme = R.style.LFileTheme;
private int mTitleStyle = R.style.LFileToolbarTextStyle;
private String mBackgroundColor;
private int mBackStyle;
private int mRequestCode;
private boolean mMutilyMode = true;
private boolean mChooseMode = true;
private String mAddText;
private int mIconStyle;
private String[] mFileTypes;
private String mNotFoundFiles;
private int mMaxNum;
private String mStartPath;
private boolean mIsGreater = true;//是否大于
private long mFileSize;
private String mFileName;
public static IFilePickerCallback sIFilePickerCallback;
public static final String RESULT_PATHS = "paths";
public static final String RESULT_PATH = "path";
/**
* 绑定Activity
*
* @param activity
* @return
*/
public LFilePicker withActivity(Activity activity) {
this.mActivity = activity;
return this;
}
/**
* 绑定Fragment
*
* @param fragment
* @return
*/
public LFilePicker withFragment(Fragment fragment) {
this.mFragment = fragment;
return this;
}
/**
* 绑定v4包Fragment
*
* @param supportFragment
* @return
*/
public LFilePicker withSupportFragment(android.app.Fragment supportFragment) {
this.mSupportFragment = supportFragment;
return this;
}
/**
* 设置主标题
*
* @param title
* @return
*/
public LFilePicker withTitle(String title) {
this.mTitle = title;
return this;
}
/**
* 设置辩题颜色
*
* @param color
* @return
*/
@Deprecated
public LFilePicker withTitleColor(String color) {
this.mTitleColor = color;
return this;
}
/**
* 设置主题
*
* @param theme
* @return
*/
public LFilePicker withTheme(@StyleRes int theme) {
this.theme = theme;
return this;
}
/**
* 设置标题的颜色和字体大小
*
* @param style
* @return
*/
public LFilePicker withTitleStyle(@StyleRes int style) {
this.mTitleStyle = style;
return this;
}
/**
* 设置背景色
*
* @param color
* @return
*/
public LFilePicker withBackgroundColor(String color) {
this.mBackgroundColor = color;
return this;
}
/**
* 请求码
*
* @param requestCode
* @return
*/
public LFilePicker withRequestCode(int requestCode) {
this.mRequestCode = requestCode;
return this;
}
/**
* 设置返回图标
*
* @param backStyle
* @return
*/
public LFilePicker withBackIcon(int backStyle) {
this.mBackStyle = 0;//默认样式
this.mBackStyle = backStyle;
return this;
}
/**
* 设置选择模式,默认为true,多选;false为单选
*
* @param isMutily
* @return
*/
public LFilePicker withMutilyMode(boolean isMutily) {
this.mMutilyMode = isMutily;
return this;
}
/**
* 设置多选时按钮文字
*
* @param text
* @return
*/
public LFilePicker withAddText(String text) {
this.mAddText = text;
return this;
}
/**
* 设置文件夹图标风格
*
* @param style
* @return
*/
public LFilePicker withIconStyle(int style) {
this.mIconStyle = style;
return this;
}
public LFilePicker withFileFilter(String[] arrs) {
this.mFileTypes = arrs;
return this;
}
/**
* 没有选中文件时的提示信息
*
* @param notFoundFiles
* @return
*/
public LFilePicker withNotFoundBooks(String notFoundFiles) {
this.mNotFoundFiles = notFoundFiles;
return this;
}
/**
* 设置最大选中数量
*
* @param num
* @return
*/
public LFilePicker withMaxNum(int num) {
this.mMaxNum = num;
return this;
}
/**
* 设置选择上传的文件
* @param fileName
* @return
*/
public LFilePicker withFileName(String fileName) {
this.mFileName = fileName;
return this;
}
/**
* 设置初始显示路径
*
* @param path
* @return
*/
public LFilePicker withStartPath(String path) {
this.mStartPath = path;
return this;
}
/**
* 设置选择模式,true为文件选择模式,false为文件夹选择模式,默认为true
*
* @param chooseMode
* @return
*/
public LFilePicker withChooseMode(boolean chooseMode) {
this.mChooseMode = chooseMode;
return this;
}
/**
* 设置文件大小过滤方式:大于指定大小或者小于指定大小
*
* @param isGreater true:大于 ;false:小于,同时包含指定大小在内
* @return
*/
public LFilePicker withIsGreater(boolean isGreater) {
this.mIsGreater = isGreater;
return this;
}
/**
* 设置过滤文件大小
*
* @param fileSize
* @return
*/
public LFilePicker withFileSize(long fileSize) {
this.mFileSize = fileSize;
return this;
}
public LFilePicker registerCallBack(IFilePickerCallback callback){
sIFilePickerCallback = callback;
return this;
}
public void start() {
if (mActivity == null && mFragment == null && mSupportFragment == null) {
throw new RuntimeException("You must pass Activity or Fragment by withActivity or withFragment or withSupportFragment method");
}
Intent intent = initIntent();
Bundle bundle = getBundle();
intent.putExtras(bundle);
if (mActivity != null) {
mActivity.startActivityForResult(intent, mRequestCode);
} else if (mFragment != null) {
mFragment.startActivityForResult(intent, mRequestCode);
} else {
mSupportFragment.startActivityForResult(intent, mRequestCode);
}
}
private Intent initIntent() {
Intent intent;
if (mActivity != null) {
intent = new Intent(mActivity, LFilePickerActivity.class);
} else if (mFragment != null) {
intent = new Intent(mFragment.getActivity(), LFilePickerActivity.class);
} else {
intent = new Intent(mSupportFragment.getActivity(), LFilePickerActivity.class);
}
return intent;
}
@NonNull
private Bundle getBundle() {
ParamEntity paramEntity = new ParamEntity();
paramEntity.setTitle(mTitle);
paramEntity.setTheme(theme);
paramEntity.setTitleColor(mTitleColor);
paramEntity.setTitleStyle(mTitleStyle);
paramEntity.setBackgroundColor(mBackgroundColor);
paramEntity.setBackIcon(mBackStyle);
paramEntity.setMutilyMode(mMutilyMode);
paramEntity.setAddText(mAddText);
paramEntity.setIconStyle(mIconStyle);
paramEntity.setFileTypes(mFileTypes);
paramEntity.setNotFoundFiles(mNotFoundFiles);
paramEntity.setMaxNum(mMaxNum);
paramEntity.setChooseMode(mChooseMode);
paramEntity.setPath(mStartPath);
paramEntity.setFileSize(mFileSize);
paramEntity.setFileName(mFileName);
paramEntity.setGreater(mIsGreater);
Bundle bundle = new Bundle();
bundle.putSerializable("param", paramEntity);
return bundle;
}
}
package com.sdy.miya.moblie.component.filepicker.adapter;
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import androidx.recyclerview.widget.RecyclerView;
import com.sdy.miya.moblie.component.filepicker.R;
import com.sdy.miya.moblie.component.filepicker.utils.Constant;
import com.sdy.miya.moblie.component.filepicker.utils.FileUtils;
import java.io.File;
import java.io.FileFilter;
import java.util.List;
/**
* 作者:Leon
* 时间:2017/3/15 15:47
*/
public class PathAdapter extends RecyclerView.Adapter<PathAdapter.PathViewHolder> {
public interface OnItemClickListener {
void click(int position);
}
public interface OnCancelChoosedListener {
void cancelChoosed(CheckBox checkBox);
}
private final String TAG = "FilePickerLeon";
private List<File> mListData;
private Context mContext;
public OnItemClickListener onItemClickListener;
private FileFilter mFileFilter;
private boolean[] mCheckedFlags;
private boolean mMutilyMode;
private int mIconStyle;
private boolean mIsGreater;
private long mFileSize;
public PathAdapter(List<File> mListData, Context mContext, FileFilter mFileFilter, boolean mMutilyMode, boolean mIsGreater, long mFileSize) {
this.mListData = mListData;
this.mContext = mContext;
this.mFileFilter = mFileFilter;
this.mMutilyMode = mMutilyMode;
this.mIsGreater = mIsGreater;
this.mFileSize = mFileSize;
mCheckedFlags = new boolean[mListData.size()];
}
@Override
public PathViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = View.inflate(mContext, R.layout.lfile_listitem, null);
PathViewHolder pathViewHolder = new PathViewHolder(view);
return pathViewHolder;
}
@Override
public int getItemCount() {
return mListData.size();
}
@Override
public void onBindViewHolder(final PathViewHolder holder, final int position) {
final File file = mListData.get(position);
if (file.isFile()) {
updateFileIconStyle(holder.ivType);
holder.tvName.setText(file.getName());
holder.tvDetail.setText(mContext.getString(R.string.lfile_FileSize) + " " + FileUtils.getReadableFileSize(file.length()));
holder.cbChoose.setVisibility(View.VISIBLE);
} else {
updateFloaderIconStyle(holder.ivType);
holder.tvName.setText(file.getName());
//文件大小过滤
List files = FileUtils.getFileList(file.getAbsolutePath(), mFileFilter, mIsGreater, mFileSize);
if (files == null) {
holder.tvDetail.setText("0 " + mContext.getString(R.string.lfile_LItem));
} else {
holder.tvDetail.setText(files.size() + " " + mContext.getString(R.string.lfile_LItem));
}
holder.cbChoose.setVisibility(View.GONE);
}
if (!mMutilyMode) {
holder.cbChoose.setVisibility(View.GONE);
}
holder.layoutRoot.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (file.isFile()) {
holder.cbChoose.setChecked(!holder.cbChoose.isChecked());
}
onItemClickListener.click(position);
}
});
holder.cbChoose.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//同步复选框和外部布局点击的处理
onItemClickListener.click(position);
}
});
holder.cbChoose.setOnCheckedChangeListener(null);//先设置一次CheckBox的选中监听器,传入参数null
holder.cbChoose.setChecked(mCheckedFlags[position]);//用数组中的值设置CheckBox的选中状态
//再设置一次CheckBox的选中监听器,当CheckBox的选中状态发生改变时,把改变后的状态储存在数组中
holder.cbChoose.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
mCheckedFlags[position] = b;
}
});
}
private void updateFloaderIconStyle(ImageView imageView) {
switch (mIconStyle) {
case Constant.ICON_STYLE_BLUE:
imageView.setBackgroundResource(R.mipmap.lfile_folder_style_blue);
break;
case Constant.ICON_STYLE_GREEN:
imageView.setBackgroundResource(R.mipmap.lfile_folder_style_green);
break;
case Constant.ICON_STYLE_YELLOW:
imageView.setBackgroundResource(R.mipmap.lfile_folder_style_yellow);
break;
}
}
private void updateFileIconStyle(ImageView imageView) {
switch (mIconStyle) {
case Constant.ICON_STYLE_BLUE:
imageView.setBackgroundResource(R.mipmap.lfile_file_style_blue);
break;
case Constant.ICON_STYLE_GREEN:
imageView.setBackgroundResource(R.mipmap.lfile_file_style_green);
break;
case Constant.ICON_STYLE_YELLOW:
imageView.setBackgroundResource(R.mipmap.lfile_file_style_yellow);
break;
}
}
/**
* 设置监听器
*
* @param onItemClickListener
*/
public void setOnItemClickListener(OnItemClickListener onItemClickListener) {
this.onItemClickListener = onItemClickListener;
}
/**
* 设置数据源
*
* @param mListData
*/
public void setmListData(List<File> mListData) {
this.mListData = mListData;
mCheckedFlags = new boolean[mListData.size()];
}
public void setmIconStyle(int mIconStyle) {
this.mIconStyle = mIconStyle;
}
/**
* 设置是否全选
*
* @param isAllSelected
*/
public void updateAllSelelcted(boolean isAllSelected) {
for (int i = 0; i < mCheckedFlags.length; i++) {
mCheckedFlags[i] = isAllSelected;
}
notifyDataSetChanged();
}
class PathViewHolder extends RecyclerView.ViewHolder {
private RelativeLayout layoutRoot;
private ImageView ivType;
private TextView tvName;
private TextView tvDetail;
private CheckBox cbChoose;
public PathViewHolder(View itemView) {
super(itemView);
ivType = (ImageView) itemView.findViewById(R.id.iv_type);
layoutRoot = (RelativeLayout) itemView.findViewById(R.id.layout_item_root);
tvName = (TextView) itemView.findViewById(R.id.tv_name);
tvDetail = (TextView) itemView.findViewById(R.id.tv_detail);
cbChoose = (CheckBox) itemView.findViewById(R.id.cb_choose);
}
}
}
package com.sdy.miya.moblie.component.filepicker.filter;
import java.io.File;
import java.io.FileFilter;
/**
* 作者:Leon
* 时间:2017/3/24 13:43
*/
public class LFileFilter implements FileFilter {
private String[] mTypes;
public LFileFilter(String[] types) {
this.mTypes = types;
}
@Override
public boolean accept(File file) {
if (file.isDirectory()) {
return true;
}
if (mTypes != null && mTypes.length > 0) {
for (int i = 0; i < mTypes.length; i++) {
if (file.getName().endsWith(mTypes[i].toLowerCase()) || file.getName().endsWith(mTypes[i].toUpperCase())) {
return true;
}
}
}else {
return true;
}
return false;
}
}
package com.sdy.miya.moblie.component.filepicker.model;
import java.io.Serializable;
/**
* 作者:Leon
* 时间:2017/3/21 14:50
*/
public class ParamEntity implements Serializable {
private String title;
private String titleColor;
private int titleStyle ;
private int theme ;
private String backgroundColor;
private int backIcon;
private boolean mutilyMode;
private String addText;
private int iconStyle;
private String[] fileTypes;
private String notFoundFiles;
private int maxNum;
private boolean chooseMode = true;
private String path;
private long fileSize;
private boolean isGreater;
private String fileName;
public String getFileName() {
return fileName;
}
public void setFileName(String fileName) {
this.fileName = fileName;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
@Deprecated
public String getTitleColor() {
return titleColor;
}
@Deprecated
public void setTitleColor(String titleColor) {
this.titleColor = titleColor;
}
public int getTheme() {
return theme;
}
public void setTheme(int theme) {
this.theme = theme;
}
public int getTitleStyle() {
return titleStyle;
}
public void setTitleStyle(int titleStyle) {
this.titleStyle = titleStyle;
}
public String getBackgroundColor() {
return backgroundColor;
}
public void setBackgroundColor(String backgroundColor) {
this.backgroundColor = backgroundColor;
}
public boolean isMutilyMode() {
return mutilyMode;
}
public void setMutilyMode(boolean mutilyMode) {
this.mutilyMode = mutilyMode;
}
public int getBackIcon() {
return backIcon;
}
public void setBackIcon(int backIcon) {
this.backIcon = backIcon;
}
public String getAddText() {
return addText;
}
public void setAddText(String addText) {
this.addText = addText;
}
public int getIconStyle() {
return iconStyle;
}
public void setIconStyle(int iconStyle) {
this.iconStyle = iconStyle;
}
public String[] getFileTypes() {
return fileTypes;
}
public void setFileTypes(String[] fileTypes) {
this.fileTypes = fileTypes;
}
public String getNotFoundFiles() {
return notFoundFiles;
}
public void setNotFoundFiles(String notFoundFiles) {
this.notFoundFiles = notFoundFiles;
}
public int getMaxNum() {
return maxNum;
}
public void setMaxNum(int maxNum) {
this.maxNum = maxNum;
}
public boolean isChooseMode() {
return chooseMode;
}
public void setChooseMode(boolean chooseMode) {
this.chooseMode = chooseMode;
}
public String getPath() {
return path;
}
public void setPath(String path) {
this.path = path;
}
public long getFileSize() {
return fileSize;
}
public void setFileSize(long fileSize) {
this.fileSize = fileSize;
}
public boolean isGreater() {
return isGreater;
}
public void setGreater(boolean greater) {
isGreater = greater;
}
}
package com.sdy.miya.moblie.component.filepicker.utils;
import java.io.Closeable;
import java.io.IOException;
/**
* <pre>
* author: Blankj
* blog : http://blankj.com
* time : 2016/10/9
* desc : 关闭相关工具类
* </pre>
*/
public class CloseUtils {
private CloseUtils() {
throw new UnsupportedOperationException("u can't instantiate me...");
}
/**
* 关闭IO
*
* @param closeables closeables
*/
public static void closeIO(Closeable... closeables) {
if (closeables == null) return;
for (Closeable closeable : closeables) {
if (closeable != null) {
try {
closeable.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
/**
* 安静关闭IO
*
* @param closeables closeables
*/
public static void closeIOQuietly(Closeable... closeables) {
if (closeables == null) return;
for (Closeable closeable : closeables) {
if (closeable != null) {
try {
closeable.close();
} catch (IOException ignored) {
}
}
}
}
}
\ No newline at end of file
package com.sdy.miya.moblie.component.filepicker.utils;
import java.io.File;
import java.io.FileFilter;
import java.io.Serializable;
import java.util.ArrayList;
/**
* Created by Dimorinny on 31.05.16.
*/
public class CompositeFilter implements FileFilter, Serializable {
private ArrayList<FileFilter> mFilters;
public CompositeFilter(ArrayList<FileFilter> filters) {
mFilters = filters;
}
@Override
public boolean accept(File f) {
for (FileFilter filter : mFilters) {
if (!filter.accept(f)) {
return false;
}
}
return true;
}
}
package com.sdy.miya.moblie.component.filepicker.utils;
/**
* 作者:Leon
* 时间:2017/3/21 15:06
*
*/
public interface Constant {
//返回图标风格
int BACKICON_STYLEONE = 0;
int BACKICON_STYLETWO = 1;
int BACKICON_STYLETHREE = 2;
//图标风格
int ICON_STYLE_YELLOW = 0;
int ICON_STYLE_BLUE = 1;
int ICON_STYLE_GREEN = 2;
}
package com.sdy.miya.moblie.component.filepicker.utils;
import java.io.File;
import java.util.Comparator;
/**
* Created by Dimorinny on 24.10.15.
*/
public class FileComparator implements Comparator<File> {
@Override
public int compare(File f1, File f2) {
if(f1 == f2) {
return 0;
}
if(f1.isDirectory() && f2.isFile()) {
// Show directories above files
return -1;
}
if(f1.isFile() && f2.isDirectory()) {
// Show files below directories
return 1;
}
// Sort the directories alphabetically
return f1.getName().compareToIgnoreCase(f2.getName());
}
}
package com.sdy.miya.moblie.component.filepicker.utils;
import java.io.File;
import java.io.FileFilter;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
/**
* Created by Dimorinny on 24.10.15.
*/
public class FileUtils {
public static List<File> getFileListByDirPath(String path, FileFilter filter) {
File directory = new File(path);
File[] files = directory.listFiles(filter);
List<File> result = new ArrayList<>();
if (files == null) {
return new ArrayList<>();
}
for (int i = 0; i < files.length; i++) {
result.add(files[i]);
}
Collections.sort(result, new FileComparator());
return result;
}
public static String cutLastSegmentOfPath(String path) {
return path.substring(0, path.lastIndexOf("/"));
}
public static String getReadableFileSize(long size) {
if (size <= 0) return "0";
final String[] units = new String[]{"B", "KB", "MB", "GB", "TB"};
int digitGroups = (int) (Math.log10(size) / Math.log10(1024));
return new DecimalFormat("#").format(size / Math.pow(1024, digitGroups)) + " " + units[digitGroups];
}
/**
* 获取文件长度
*
* @param file 文件
* @return 文件长度
*/
public static long getFileLength(final File file) {
if (!isFile(file)) return -1;
return file.length();
}
/**
* 判断是否是文件
*
* @param file 文件
* @return {@code true}: 是<br>{@code false}: 否
*/
public static boolean isFile(final File file) {
return file != null && file.exists() && file.isFile();
}
/**
* 根据地址获取当前地址下的所有目录和文件,并且排序,同时过滤掉不符合大小要求的文件
*
* @param path
* @return List<File>
*/
public static List<File> getFileList(String path, FileFilter filter, boolean isGreater, long targetSize) {
List<File> list = FileUtils.getFileListByDirPath(path, filter);
//进行过滤文件大小
Iterator iterator = list.iterator();
// for(File file:list){
// D.i("wangyu",file.toString());
// }
while (iterator.hasNext()) {
File f = (File) iterator.next();
if (f.isFile()) {
//获取当前文件大小
long size = FileUtils.getFileLength(f);
if (isGreater) {
//当前想要留下大于指定大小的文件,所以过滤掉小于指定大小的文件
if (size < targetSize) {
iterator.remove();
}
} else {
//当前想要留下小于指定大小的文件,所以过滤掉大于指定大小的文件
if (size > targetSize) {
iterator.remove();
}
}
}
}
return list;
}
}
package com.sdy.miya.moblie.component.filepicker.utils;
import androidx.annotation.IntDef;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
/**
* <pre>
* author: Blankj
* blog : http://blankj.com
* time : 2017/03/13
* desc : 存储相关常量
* </pre>
*/
public class MemoryConstant {
/**
* Byte与Byte的倍数
*/
public static final int BYTE = 1;
/**
* KB与Byte的倍数
*/
public static final int KB = 1024;
/**
* MB与Byte的倍数
*/
public static final int MB = 1048576;
/**
* GB与Byte的倍数
*/
public static final int GB = 1073741824;
@IntDef({BYTE, KB, MB, GB})
@Retention(RetentionPolicy.SOURCE)
public @interface Unit {
}
}
\ No newline at end of file
package com.sdy.miya.moblie.component.filepicker.widget;
import android.content.Context;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.RecyclerView;
import android.util.AttributeSet;
import android.view.View;
/**
* 作者:Leon
* 时间:2017/3/17 13:44
*/
public class EmptyRecyclerView extends RecyclerView {
private View mEmptyView;
public EmptyRecyclerView(Context context) {
super(context);
}
public EmptyRecyclerView(Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
}
public EmptyRecyclerView(Context context, @Nullable AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
/**
* 根据数据源判断是否显示空白view
*/
private void checkIfEmpty() {
if (mEmptyView != null || getAdapter() != null) {
mEmptyView.setVisibility(getAdapter().getItemCount() > 0 ? GONE : VISIBLE);
}
}
public void setmEmptyView(View mEmptyView) {
this.mEmptyView = mEmptyView;
checkIfEmpty();
}
@Override
public void setAdapter(Adapter adapter) {
Adapter adapterOld = getAdapter();
if (adapterOld != null) {
adapterOld.unregisterAdapterDataObserver(observer);
}
super.setAdapter(adapter);
if (adapter != null) {
adapter.registerAdapterDataObserver(observer);
}
}
AdapterDataObserver observer = new AdapterDataObserver() {
@Override
public void onChanged() {
super.onChanged();
checkIfEmpty();
}
};
}
package com.sdy.miya.moblie.component.filepicker.widget;
import android.app.Dialog;
import android.content.Context;
import android.view.Gravity;
import android.view.WindowManager;
import com.sdy.miya.moblie.component.filepicker.R;
/**
* 等待对话框
* Created by fys on 2016/3/21.
*/
public class FWaitingProgressDialog extends Dialog {
public FWaitingProgressDialog(Context context) {
super(context, R.style.FWaitingProgressDialog);
this.setContentView(R.layout.views_waitting_progress_bar);
this.setTitle("");
// this.setCancelable(false);
this.setCanceledOnTouchOutside(false);
this.getWindow().getAttributes().gravity = Gravity.CENTER;
WindowManager.LayoutParams lp = this.getWindow()
.getAttributes();
lp.dimAmount = 0.2f;
this.getWindow().setAttributes(lp);
}
public FWaitingProgressDialog(Context context, int theme) {
super(context, theme);
}
/**
*
*/
public void onWindowFocusChanged(boolean hasFocus) {
}
}
<?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="@color/lfile_gray">
<item
android:drawable="@color/lfile_lightgray"
android:state_pressed="false"/>
</ripple>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="@color/lfile_lightgray">
<item
android:drawable="@color/lfile_defaultColor"
android:state_pressed="false"/>
</ripple>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@color/lfile_lightgray" android:state_pressed="true" />
<item android:drawable="@color/lfile_lightgray" android:state_selected="true" />
<item android:drawable="@color/lfile_white" />
</selector>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@color/lfile_gray" android:state_pressed="true"/>
<item android:drawable="@color/lfile_gray" android:state_selected="true"/>
<item android:drawable="@color/lfile_lightgray"/>
</selector>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@color/lfile_defaultColor" android:state_pressed="true"/>
<item android:drawable="@color/lfile_defaultColor" android:state_selected="true"/>
<item android:drawable="@color/lfile_defaultColor"/>
</selector>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#AA000000" />
<corners
android:bottomLeftRadius="8dp"
android:bottomRightRadius="8dp"
android:topLeftRadius="8dp"
android:topRightRadius="8dp" />
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/lfile_white"
tools:context=".LFilePickerActivity">
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?android:attr/actionBarSize"
android:background="?attr/colorPrimary"
android:minHeight="?android:attr/actionBarSize"
app:navigationIcon="?attr/navigationIcon" />
<LinearLayout
android:id="@+id/layout_path"
android:layout_width="match_parent"
android:layout_height="44dp"
android:layout_below="@id/toolbar"
android:background="#dddddd"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:id="@+id/tv_path"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginLeft="8dp"
android:layout_weight="1"
android:ellipsize="middle"
android:gravity="left|center"
android:singleLine="true"
android:textSize="14sp" />
<TextView
android:visibility="gone"
android:id="@+id/tv_back"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:background="@drawable/lfile_back_bg"
android:clickable="true"
android:drawableLeft="@mipmap/lfile_up"
android:drawablePadding="4dp"
android:gravity="center"
android:paddingLeft="8dp"
android:paddingRight="8dp"
android:text="@string/lfile_UpOneLevel" />
</LinearLayout>
<Button
android:id="@+id/btn_addbook"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="@drawable/lfile_btn_bg"
android:text="@string/lfile_Selected"
android:textColor="@color/lfile_white"
android:textSize="18sp" />
<com.sdy.miya.moblie.component.filepicker.widget.EmptyRecyclerView
android:id="@+id/recylerview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@id/btn_addbook"
android:layout_below="@id/layout_path" />
<include
android:id="@+id/empty_view"
layout="@layout/lfile_emptyview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/layout_path" />
</RelativeLayout>
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/lfile_white">
<TextView
android:id="@+id/tv_empty"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:gravity="center"
android:padding="12dp"
android:text="暂无数据"
android:textColor="@color/lfile_gray"
android:textSize="18sp"/>
<ImageView
android:layout_centerHorizontal="true"
android:layout_width="120dp"
android:layout_height="120dp"
android:layout_above="@id/tv_empty"
android:background="@mipmap/lfile_emptyimg"/>
</RelativeLayout>
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment