Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test #18

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

test #18

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions UltimateAndroidGradle/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
/.idea/libraries
.DS_Store
/build
/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ private void findViews() {
}

@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { //RadiozGroup的回调,监听checked change
int id = buttonView.getId();
if(id == R.id.random_anim && isChecked) {
mAnimationType = AnimatedRectLayout.ANIMATION_RANDOM;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ protected void onCreate(Bundle savedInstanceState) {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Techniques technique = (Techniques)view.getTag();
rope = YoYo.with(technique)
rope = YoYo.with(technique) //设置动画
.duration(1200)
.interpolate(new AccelerateDecelerateInterpolator())
.withListener(new Animator.AnimatorListener() {
Expand Down
19 changes: 10 additions & 9 deletions UltimateAndroidGradle/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
# Project-wide Gradle settings.

# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.

## Project-wide Gradle settings.
#
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html

#
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx10248m -XX:MaxPermSize=256m
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8

#
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
# org.gradle.parallel=true
#Mon Dec 14 16:49:30 CST 2015
systemProp.http.proxyPassword=hai123zhi456
systemProp.http.proxyHost=hk.haizhi.me
systemProp.http.proxyUser=haizhi
systemProp.http.proxyPort=8089
Original file line number Diff line number Diff line change
Expand Up @@ -108,24 +108,24 @@ private void prepareGrid() {
int w = getMeasuredWidth();
int h = getMeasuredHeight();

int rectWidth = w/ RECT_COUNT_IN_WIDTH;
int rectWidth = w/ RECT_COUNT_IN_WIDTH; //根基宽度判断 RECT_COUNT_IN_WIDTH范围内的个数
int rectHeight = rectWidth;

mRectCountInWidth = w/rectWidth;
mRectCountInWidth = w/rectWidth; //count个数
mRectCountInHeight = h/rectHeight;

int delta = w%rectWidth;
if(delta>0) {
rectWidth += delta/mRectCountInWidth;
int delta = w%rectWidth; // 取余数
if(delta>0) { //宽度的微调
rectWidth += delta/mRectCountInWidth; //保证 rectWidti * mRectCountInWidth == w
}

delta = h%rectWidth;
if(delta>0) {
rectHeight += delta/mRectCountInHeight;
}

mRects = new Rect[mRectCountInWidth][mRectCountInHeight];
mRectIndexes = new int[mRectCountInWidth * mRectCountInHeight][2];
mRects = new Rect[mRectCountInWidth][mRectCountInHeight]; //初始化数组和数组元素是分开的嘛??
mRectIndexes = new int[mRectCountInWidth * mRectCountInHeight][2]; //每个方块的显示顺序 x y的index

for (int x = 0; x < mRectCountInWidth; x++) {
for (int y = 0; y < mRectCountInHeight; y++) {
Expand All @@ -134,21 +134,21 @@ private void prepareGrid() {
int right = left + rectWidth;
int bottom = top + rectHeight;

if (x + 1 >= mRectCountInWidth) {
if (x + 1 >= mRectCountInWidth) { //如果右边没有空间了
right = w;
}
if (y + 1 >= mRectCountInHeight) {
bottom = h;
}

mRects[x][y] = new Rect(left, top, right, bottom);
mRects[x][y] = new Rect(left, top, right, bottom); //如果不加这个new的操作是不是会报错
}
}

sIndexesBuilder.get(mAnimationType).build(mRectIndexes, mRectCountInWidth, mRectCountInHeight);

if (IS_JBMR2) {
mFullBitmap = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
mFullBitmap = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888); //创建一张整个屏幕大小的Bitmap
Canvas canvas = new Canvas(mFullBitmap);
getChildAt(0).draw(canvas);
}
Expand All @@ -167,19 +167,19 @@ protected void dispatchDraw(Canvas canvas) {
if(i >= threshold) {
return;
}
canvas.save();
canvas.save(); //保存画布的状态 Note:保证画布的其他的东西不受影响

int[] index = mRectIndexes[i];
Rect rect = mRects[index[0]][index[1]];

if(IS_JBMR2) {
canvas.drawBitmap(mFullBitmap, rect, rect, null);
} else {
canvas.clipRect(rect);
canvas.clipRect(rect); //局部绘制 截取画布中的一块区域
super.dispatchDraw(canvas);
}

canvas.restore();
canvas.restore(); //取出画布的状态
}
}

Expand All @@ -198,7 +198,7 @@ public int[][] build(int[][] indexes, int rectCountInWidth, int rectCountInHeigh
index++;
}
}
return shuffle(indexes);
return shuffle(indexes); //random的实现
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,14 @@ public ProgressLayout(Context context, AttributeSet attrs, int defStyle) {
}

private void init(AttributeSet attrs) {
TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.ProgressLayout);
TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.ProgressLayout); // 属性数组
int backgroundColor = a.getColor(R.styleable.ProgressLayout_progressLayoutProgressBackground, Color.TRANSPARENT);
boolean startFromProgress = a.getBoolean(R.styleable.ProgressLayout_progressLayoutProgress, false);
/*
* 在TypedArray后调用recycle主要是为了缓存。
* 当recycle被调用后,这就说明这个对象从现在可以被重用了。
* TypedArray 内部持有部分数组,它们缓存在Resources类中的静态字段中,这样就不用每次使用前都需要分配内存。你可以看看TypedArray.recycle()中的代码:
* */
a.recycle();

LayoutParams layoutParams;
Expand Down