list) {
57 | super(fm);
58 | this.list = list;
59 | }
60 |
61 | @Override
62 | public Fragment getItem(int position) {
63 | return list.get(position);
64 | }
65 |
66 | @Override
67 | public int getCount() {
68 | return list.size();
69 | }
70 |
71 | @Override
72 | public CharSequence getPageTitle(int position) {
73 | return list.get(position).getClass().getSimpleName().replace("Fragment", "");
74 | }
75 | }
76 |
77 | }
78 |
--------------------------------------------------------------------------------
/aslibrary/src/main/java/com/aserbao/alibrary/particle/MyFragmentPagerAdapter.java:
--------------------------------------------------------------------------------
1 | package com.aserbao.alibrary.particle;
2 |
3 | /*
4 | * Copyright (C) 2011 The Android Open Source Project
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | *
18 | */
19 |
20 | import java.util.UUID;
21 |
22 | import android.os.Parcelable;
23 | import android.support.v4.app.Fragment;
24 | import android.support.v4.app.FragmentManager;
25 | import android.support.v4.app.FragmentStatePagerAdapter;
26 | import android.support.v4.app.FragmentTransaction;
27 | import android.support.v4.view.PagerAdapter;
28 | import android.util.Log;
29 | import android.view.View;
30 | import android.view.ViewGroup;
31 |
32 | /**
33 | * Implementation of {@link PagerAdapter} that
34 | * represents each page as a {@link Fragment} that is persistently
35 | * kept in the fragment manager as long as the user can return to the page.
36 | *
37 | * This version of the pager is best for use when there are a handful of
38 | * typically more static fragments to be paged through, such as a set of tabs.
39 | * The fragment of each page the user visits will be kept in memory, though its
40 | * view hierarchy may be destroyed when not visible. This can result in using
41 | * a significant amount of memory since fragment instances can hold on to an
42 | * arbitrary amount of state. For larger sets of pages, consider
43 | * {@link FragmentStatePagerAdapter}.
44 | *
45 | *
When using FragmentPagerAdapter the host ViewPager must have a
46 | * valid ID set.
47 | *
48 | * Subclasses only need to implement {@link #getItem(int)}
49 | * and {@link #getCount()} to have a working adapter.
50 | *
51 | *
Here is an example implementation of a pager containing fragments of
52 | * lists:
53 | *
54 | * {@sample development/samples/Support4Demos/src/com/example/android/supportv4/app/FragmentPagerSupport.java
55 | * complete}
56 | *
57 | *
The R.layout.fragment_pager
resource of the top-level fragment is:
58 | *
59 | * {@sample development/samples/Support4Demos/res/layout/fragment_pager.xml
60 | * complete}
61 | *
62 | *
The R.layout.fragment_pager_list
resource containing each
63 | * individual fragment's layout is:
64 | *
65 | * {@sample development/samples/Support4Demos/res/layout/fragment_pager_list.xml
66 | * complete}
67 | */
68 | public abstract class MyFragmentPagerAdapter extends PagerAdapter {
69 | private static final String TAG = "FragmentPagerAdapter";
70 | private static final boolean DEBUG = false;
71 |
72 | private final FragmentManager mFragmentManager;
73 | private FragmentTransaction mCurTransaction = null;
74 | private Fragment mCurrentPrimaryItem = null;
75 |
76 | public MyFragmentPagerAdapter(FragmentManager fm) {
77 | mFragmentManager = fm;
78 | }
79 |
80 | /**
81 | * Return the Fragment associated with a specified position.
82 | */
83 | public abstract Fragment getItem(int position);
84 |
85 | @Override
86 | public void startUpdate(ViewGroup container) {
87 | }
88 |
89 | @Override
90 | public Object instantiateItem(ViewGroup container, int position) {
91 | if (mCurTransaction == null) {
92 | mCurTransaction = mFragmentManager.beginTransaction();
93 | }
94 |
95 | // Do we already have this fragment?
96 | String name = makeFragmentName(container.getId(), position);
97 | Fragment fragment = mFragmentManager.findFragmentByTag(name);
98 | if (fragment != null) {
99 | if (DEBUG)
100 | Log.v(TAG, "Attaching item #" + position + ": f=" + fragment);
101 | mCurTransaction.attach(fragment);
102 | }
103 | else {
104 | fragment = getItem(position);
105 | if (DEBUG)
106 | Log.v(TAG, "Adding item #" + position + ": f=" + fragment);
107 | mCurTransaction.add(container.getId(), fragment, makeFragmentName(container.getId(), position));
108 | }
109 | if (fragment != mCurrentPrimaryItem) {
110 | fragment.setMenuVisibility(false);
111 | fragment.setUserVisibleHint(false);
112 | }
113 |
114 | return fragment;
115 | }
116 |
117 | @Override
118 | public void destroyItem(ViewGroup container, int position, Object object) {
119 | if (mCurTransaction == null) {
120 | mCurTransaction = mFragmentManager.beginTransaction();
121 | }
122 | if (DEBUG)
123 | Log.v(TAG, "Detaching item #" + position + ": f=" + object + " v=" + ((Fragment) object).getView());
124 | mCurTransaction.detach((Fragment) object);
125 | }
126 |
127 | @Override
128 | public void setPrimaryItem(ViewGroup container, int position, Object object) {
129 | Fragment fragment = (Fragment) object;
130 | if (fragment != mCurrentPrimaryItem) {
131 | if (mCurrentPrimaryItem != null) {
132 | mCurrentPrimaryItem.setMenuVisibility(false);
133 | mCurrentPrimaryItem.setUserVisibleHint(false);
134 | }
135 | if (fragment != null) {
136 | fragment.setMenuVisibility(true);
137 | fragment.setUserVisibleHint(true);
138 | }
139 | mCurrentPrimaryItem = fragment;
140 | }
141 | }
142 |
143 | @Override
144 | public void finishUpdate(ViewGroup container) {
145 | if (mCurTransaction != null) {
146 | mCurTransaction.commitAllowingStateLoss();
147 | mCurTransaction = null;
148 | mFragmentManager.executePendingTransactions();
149 | }
150 | }
151 |
152 | @Override
153 | public boolean isViewFromObject(View view, Object object) {
154 | return ((Fragment) object).getView() == view;
155 | }
156 |
157 | @Override
158 | public Parcelable saveState() {
159 | return null;
160 | }
161 |
162 | @Override
163 | public void restoreState(Parcelable state, ClassLoader loader) {
164 | }
165 | protected String mToken = UUID.randomUUID().toString();
166 | private String makeFragmentName(int viewId, int index) {
167 | return "android:switcher:" + viewId + ":" + index + ":" + mToken;
168 | }
169 |
170 | public Fragment getCurrentFragment(){
171 | return mCurrentPrimaryItem;
172 | }
173 | }
174 |
--------------------------------------------------------------------------------
/aslibrary/src/main/java/com/aserbao/alibrary/particle/TabViewLayout.java:
--------------------------------------------------------------------------------
1 | package com.aserbao.alibrary.particle;
2 |
3 | import android.content.Context;
4 | import android.support.v4.view.PagerAdapter;
5 | import android.support.v4.view.ViewPager;
6 | import android.support.v4.view.ViewPager.OnPageChangeListener;
7 | import android.util.AttributeSet;
8 | import android.view.LayoutInflater;
9 | import android.view.View;
10 | import android.widget.HorizontalScrollView;
11 | import android.widget.LinearLayout;
12 | import android.widget.TextView;
13 |
14 | import com.aserbao.aslibrary.R;
15 |
16 | public class TabViewLayout extends HorizontalScrollView implements OnPageChangeListener {
17 |
18 | private LinearLayout tabContainer;
19 | private ViewPager mViewPager;
20 |
21 | public TabViewLayout(Context context, AttributeSet attrs, int defStyle) {
22 | super(context, attrs, defStyle);
23 | }
24 |
25 | public TabViewLayout(Context context, AttributeSet attrs) {
26 | super(context, attrs);
27 | LayoutInflater.from(getContext()).inflate(R.layout.tab_container, this);
28 | }
29 |
30 | public TabViewLayout(Context context) {
31 | super(context);
32 | LayoutInflater.from(getContext()).inflate(R.layout.tab_container, this);
33 | }
34 |
35 | public void setViewPager(ViewPager viewPager){
36 | mViewPager = viewPager;
37 | mViewPager.setOnPageChangeListener(this);
38 | initTab();
39 | }
40 |
41 | private void initTab(){
42 | tabContainer = (LinearLayout) findViewById(R.id.tab_container);
43 | PagerAdapter adapter = mViewPager.getAdapter();
44 | int childCount = adapter.getCount();
45 | for(int i = 0; i < childCount; i ++){
46 | final int index = i;
47 | TextView view = (TextView) LayoutInflater.from(getContext()).inflate(R.layout.tab_view, null);
48 | view.setText(adapter.getPageTitle(i));
49 | view.setOnClickListener(new OnClickListener() {
50 | public void onClick(View v) {
51 | if(mViewPager != null){
52 | mViewPager.setCurrentItem(index);
53 | }
54 | }
55 | });
56 | tabContainer.addView(view);
57 | }
58 | }
59 |
60 | // @Override
61 | // protected void onFinishInflate() {
62 | // super.onFinishInflate();
63 | // tabContainer = (LinearLayout) findViewById(R.id.tab_container);
64 | //
65 | // int childCount = tabContainer.getChildCount();
66 | // for(int i = 0; i < childCount; i ++){
67 | // final int index = i;
68 | // View view = tabContainer.getChildAt(i);
69 | // view.setOnClickListener(new View.OnClickListener() {
70 | // public void onClick(View v) {
71 | // if(mViewPager != null){
72 | // mViewPager.setCurrentItem(index);
73 | // }
74 | // }
75 | // });
76 | // }
77 | // }
78 |
79 | @Override
80 | public void onPageScrollStateChanged(int arg0) {
81 |
82 | }
83 |
84 | @Override
85 | public void onPageScrolled(int arg0, float arg1, int arg2) {
86 | }
87 |
88 | @Override
89 | public void onPageSelected(int arg0) {
90 |
91 | }
92 |
93 | }
94 |
--------------------------------------------------------------------------------
/aslibrary/src/main/java/com/aserbao/alibrary/particle/effect/base/EffectBase.java:
--------------------------------------------------------------------------------
1 | package com.aserbao.alibrary.particle.effect.base;
2 |
3 | import android.graphics.Canvas;
4 |
5 | /**
6 | * 效果基本功能接口
7 | * @author xianfeng
8 | *
9 | */
10 | public interface EffectBase {
11 | /**
12 | * 绘制效果
13 | * @param canvas
14 | */
15 | public void draw(Canvas canvas);
16 |
17 | /**
18 | * 效果元素变化
19 | */
20 | public void move();
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/aslibrary/src/main/java/com/aserbao/alibrary/particle/effect/base/EffectItem.java:
--------------------------------------------------------------------------------
1 | package com.aserbao.alibrary.particle.effect.base;
2 |
3 | import java.util.Random;
4 |
5 | /**
6 | * 效果基础类
7 | * @author xianfeng
8 | *
9 | */
10 | public abstract class EffectItem implements EffectBase{
11 | /**
12 | * 显示区域的宽度
13 | */
14 | protected int width;
15 | /**
16 | * 显示区域的高度
17 | */
18 | protected int height;
19 | /**
20 | * 效果元素的随机对象
21 | */
22 | protected Random rand;
23 | /**
24 | * item color
25 | */
26 | protected int color;
27 | /**
28 | * rand item color
29 | */
30 | protected boolean randColor;
31 |
32 | public EffectItem(int width, int height){
33 | this.width = width;
34 | this.height = height;
35 | rand =new Random();
36 | }
37 |
38 | public EffectItem(int width, int height, int color){
39 | this.width = width;
40 | this.height = height;
41 | this.color = color;
42 | rand =new Random();
43 | }
44 |
45 | public EffectItem(int width, int height, int color, boolean randColor){
46 | this.width = width;
47 | this.height = height;
48 | this.color = color;
49 | this.randColor = randColor;
50 | rand =new Random();
51 | }
52 |
53 | protected void randomColor(){
54 | if(randColor){
55 | int alpha = 200;
56 | int r = rand.nextInt(255);
57 | int g = rand.nextInt(255);
58 | int b = rand.nextInt(255);
59 | color = alpha << 24 | r << 16 | g << 8 | b;
60 | }
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/aslibrary/src/main/java/com/aserbao/alibrary/particle/effect/base/EffectScence.java:
--------------------------------------------------------------------------------
1 | package com.aserbao.alibrary.particle.effect.base;
2 |
3 | import java.util.ArrayList;
4 |
5 | import android.graphics.Bitmap;
6 | import android.graphics.Canvas;
7 |
8 |
9 | /**
10 | * 效果场景基类
11 | * @author xianfeng
12 | *
13 | */
14 | public abstract class EffectScence {
15 |
16 | protected int itemNum = 0;//效果元素数量
17 | protected int itemColor = 0;//粒子颜色
18 | protected boolean randColor = false;//rand color
19 | //效果场景宽高
20 | protected int width;
21 | protected int height;
22 | //效果容器
23 | protected ArrayList list = new ArrayList();
24 | //如果有图片的需要此属性
25 | protected Bitmap mBitmap;
26 | /**
27 | * 效果场景构造
28 | * @param width 显示区域宽
29 | * @param height 显示区域宽
30 | * @param itemNum 显示区域元素数量
31 | */
32 | public EffectScence(int width, int height, int itemNum){
33 | this.width = width;
34 | this.height = height;
35 | this.itemNum = itemNum;
36 | initScence();
37 | }
38 | /**
39 | * 效果场景构造
40 | * @param width 显示区域宽
41 | * @param height 显示区域宽
42 | * @param itemNum 显示区域元素数量
43 | * @param itemColor 元素color
44 | */
45 | public EffectScence(int width, int height, int itemNum, int itemColor){
46 | this.width = width;
47 | this.height = height;
48 | this.itemNum = itemNum;
49 | this.itemColor = itemColor;
50 | initScence();
51 | }
52 | /**
53 | *
54 | * @param width
55 | * @param height
56 | * @param itemNum
57 | * @param itemColor
58 | * @param randColor if true,itemColor Invalid
59 | */
60 | public EffectScence(int width, int height, int itemNum, int itemColor, boolean randColor){
61 | this.width = width;
62 | this.height = height;
63 | this.itemNum = itemNum;
64 | this.itemColor = itemColor;
65 | this.randColor = randColor;
66 | initScence();
67 | }
68 | /**
69 | * 效果场景构造
70 | * @param width 显示区域宽
71 | * @param height 显示区域宽
72 | * @param itemNum 显示区域元素数量
73 | * @param bitmap 图片
74 | */
75 | public EffectScence(int width, int height, int itemNum, Bitmap bitmap){
76 | this.width = width;
77 | this.height = height;
78 | this.itemNum = itemNum;
79 | mBitmap = bitmap;
80 | initScence();
81 | }
82 |
83 | /**
84 | * 必须要实现的初始场景方法,需要
85 | */
86 | protected abstract void initScence();
87 |
88 | public void draw(Canvas canvas){
89 | if(list.size() == 0){
90 | throw new RuntimeException("请初在initScence的方法中加入效果元素!");
91 | }
92 | for(EffectBase item : list){
93 | item.draw(canvas);
94 | }
95 | }
96 |
97 | public void move(){
98 | if(list.size() == 0){
99 | throw new RuntimeException("请初在initScence的方法中加入效果元素!");
100 | }
101 | for(EffectBase item : list){
102 | item.move();
103 | }
104 | }
105 | }
106 |
--------------------------------------------------------------------------------
/aslibrary/src/main/java/com/aserbao/alibrary/particle/effect/item/MusicPoint.java:
--------------------------------------------------------------------------------
1 | package com.aserbao.alibrary.particle.effect.item;
2 |
3 | import android.graphics.Canvas;
4 | import android.graphics.Paint;
5 |
6 | import com.aserbao.alibrary.particle.effect.base.EffectItem;
7 |
8 |
9 | public class MusicPoint extends EffectItem {
10 |
11 | private Paint paint = new Paint();
12 | private int x;
13 | private int centerY;
14 | private int maxH;
15 | private int distance;
16 | private int itemSize;
17 | private int num;
18 |
19 | public MusicPoint(int x, int width, int height){
20 | this(width, height);
21 | this.x = x;
22 | }
23 |
24 | public MusicPoint(int x, int width, int height, int color){
25 | this(x, width, height);
26 | this.color = color;
27 | paint.setColor(color);
28 | }
29 | public MusicPoint(int x, int width, int height, int color, boolean randColor){
30 | super(width, height, color, randColor);
31 | this.x = x;
32 | centerY = height / 2;
33 | maxH = height / 3;
34 | itemSize = maxH / 15;
35 | distance = itemSize / 2;
36 | randomColor();
37 | paint.setColor(this.color);
38 | }
39 | public MusicPoint(int width, int height) {
40 | super(width, height);
41 |
42 | centerY = height / 2;
43 | maxH = height / 3;
44 | itemSize = maxH / 15;
45 | distance = itemSize / 2;
46 |
47 | paint.setColor(0xffffffff);
48 | }
49 |
50 | @Override
51 | public void draw(Canvas canvas) {
52 | //绘制向上的音符块
53 | paint.setAlpha(100);
54 | for(int i = 0; i < num; i ++){
55 | canvas.drawRect(x + distance, centerY - (i + 1) * itemSize - i * distance, x + itemSize + distance, centerY - i * (itemSize + distance), paint);
56 | }
57 | //绘制向下的镜像音符块
58 | paint.setAlpha(50);
59 | for(int i = 0; i < num; i ++){
60 | canvas.drawRect(x + distance, centerY + i * (itemSize + distance), x + itemSize + distance, centerY + (i + 1) * itemSize + i * distance, paint);
61 | }
62 | }
63 |
64 | int count = 0;
65 | @Override
66 | public void move() {
67 | count ++;
68 | if(count >= 6){
69 | count = 0;
70 | num = 1 + rand.nextInt(10);
71 | }
72 | }
73 |
74 | }
75 |
--------------------------------------------------------------------------------
/aslibrary/src/main/java/com/aserbao/alibrary/particle/effect/item/RainPoint.java:
--------------------------------------------------------------------------------
1 | package com.aserbao.alibrary.particle.effect.item;
2 |
3 | import android.graphics.Canvas;
4 | import android.graphics.Paint;
5 | import android.graphics.Point;
6 | import android.graphics.Rect;
7 | import android.util.Log;
8 |
9 | import com.aserbao.alibrary.particle.effect.base.EffectItem;
10 |
11 |
12 | public class RainPoint extends EffectItem {
13 |
14 | private Paint paint = new Paint();
15 | private final int size = 50; //长度在0-50像素
16 | private Rect point; //雨点
17 | private Point speed; //雨点x,y方向速度
18 |
19 | public RainPoint(int width, int height){
20 | super(width, height);
21 | point = new Rect();
22 | speed = new Point();
23 |
24 | paint.setColor(0xffffffff);
25 | reset();
26 | }
27 |
28 | public RainPoint(int width, int height, int color){
29 | super(width, height, color);
30 | point = new Rect();
31 | speed = new Point();
32 |
33 | paint.setColor(color);
34 | reset();
35 | }
36 |
37 | public RainPoint(int width, int height, int color, boolean randColor){
38 | super(width, height, color, randColor);
39 | point = new Rect();
40 | speed = new Point();
41 | reset();
42 |
43 | }
44 |
45 | public void draw(Canvas canvas){
46 | canvas.drawLine(point.left, point.top, point.right, point.bottom, paint);
47 | }
48 |
49 | public void move(){
50 | point.left += speed.x;
51 | point.top += speed.y;
52 | point.right = point.right + speed.x;
53 | point.bottom = point.bottom + speed.y;
54 |
55 | if(point.left < 0 || point.left > width || point.bottom > height){
56 | reset();
57 | }
58 | speed.y += rand.nextBoolean() ? 1 : 0;
59 | }
60 |
61 | private void reset(){
62 | int x = rand.nextInt(width);
63 | int y = rand.nextInt(height);
64 | int w = rand.nextInt(size / 2);
65 | int h = rand.nextInt(size);
66 |
67 | w = w > h ? h : w;
68 |
69 | point.left = x;
70 | point.top = y;
71 | point.right = x - w;
72 | point.bottom = y + h;
73 |
74 | // int speedX = rand.nextInt(size / 2);
75 | // int speedY = rand.nextInt(size);
76 | int speedX = w;
77 | int speedY = h;
78 |
79 | speedX = speedX == 0 ? 1 : speedX;
80 | speedY = speedY == 0 ? 1 : speedY;
81 | speedX = speedX > speedY ? speedY : speedX;
82 |
83 | speed.x = -speedX;
84 | speed.y = speedY;
85 | randomColor();
86 | paint.setColor(color);
87 | }
88 |
89 | public void printPosition(){
90 | Log.d("rainPoint", "x : " + point.left + " y : " + point.top + " r : " + point.right + " b : " + point.bottom);
91 | }
92 |
93 | }
94 |
--------------------------------------------------------------------------------
/aslibrary/src/main/java/com/aserbao/alibrary/particle/effect/item/SnowPoint.java:
--------------------------------------------------------------------------------
1 | package com.aserbao.alibrary.particle.effect.item;
2 |
3 | import android.graphics.Canvas;
4 | import android.graphics.Paint;
5 | import android.graphics.Point;
6 | import android.graphics.Rect;
7 | import android.util.Log;
8 |
9 | import com.aserbao.alibrary.particle.effect.base.EffectItem;
10 |
11 | public class SnowPoint extends EffectItem{
12 |
13 | private Paint paint = new Paint();
14 | private final int size = 36; // 长度在0-50像素
15 | private Rect point; // 雪点
16 | private Point speed; // 雪点x,y方向速度
17 |
18 | public SnowPoint(int width, int height) {
19 | super(width, height);
20 | point = new Rect();
21 | speed = new Point();
22 | paint.setColor(0xffffffff);
23 | reset();
24 | }
25 | public SnowPoint(int width, int height, int color) {
26 | super(width, height, color);
27 | point = new Rect();
28 | speed = new Point();
29 | paint.setColor(color);
30 | reset();
31 | }
32 | public SnowPoint(int width, int height, int color, boolean randColor) {
33 | super(width, height, color, randColor);
34 | point = new Rect();
35 | speed = new Point();
36 | reset();
37 | }
38 | public void draw(Canvas canvas) {
39 | //变长小于等于8绘制圆形
40 | if(point.width() <= 8){
41 | canvas.drawCircle(point.left, point.top, point.width() / 2, paint);
42 | }
43 | else{
44 | //绘制雪花形状
45 | drawSknow(canvas);
46 | }
47 | }
48 |
49 | int count = 0;
50 |
51 | public void move() {
52 | point.left += speed.x;
53 | point.top += speed.y;
54 | point.right = point.right + speed.x;
55 | point.bottom = point.bottom + speed.y;
56 | count++;
57 | if (count > 5) {
58 | count = 0;
59 | speed.x = rand.nextInt(size);
60 | speed.x = speed.x > speed.y ? speed.y : speed.x;
61 | speed.x = rand.nextBoolean() ? -speed.x : speed.x;
62 | speed.y += rand.nextBoolean() ? 1 : 0;
63 | }
64 |
65 | if (point.left < 0 || point.bottom > height) {
66 | reset();
67 | }
68 | }
69 |
70 | private void reset() {
71 | int x = rand.nextInt(width);
72 | int y = rand.nextInt(height);
73 | int w = rand.nextInt(size);
74 | int h = rand.nextInt(size);
75 |
76 | if(w > 8){
77 | //勾3股4弦5(宽是4的倍数,高是3的倍数)
78 | int mod = w % 4;
79 | w += mod;
80 | int mul = w / 4;//倍数
81 | h = 3 * mul;
82 | point.left = x;
83 | point.top = y;
84 | point.right = x + w;
85 | point.bottom = y + h;
86 |
87 | }
88 | else{
89 | point.left = x;
90 | point.top = y;
91 | point.right = x + w;
92 | point.bottom = y + w;
93 | }
94 |
95 | int speedX = rand.nextInt(size);
96 | int speedY = rand.nextInt(size);
97 | /*
98 | * int speedX = w; int speedY = h;
99 | */
100 |
101 | speedX = speedX == 0 ? 1 : speedX;
102 | speedY = speedY == 0 ? 1 : speedY;
103 | speedX = speedX > speedY ? speedY : speedX;
104 |
105 | speed.x = speedX;
106 | speed.y = speedY;
107 | randomColor();
108 | paint.setColor(color);
109 | }
110 |
111 | private void drawSknow(Canvas canvas){
112 | int w = point.width();
113 | int h = point.height();
114 | int mul = w / 4;//倍数
115 | float xie = 5 * mul / 2;
116 | float centerY = point.top + h / 2;
117 | float centerX =point.left + w / 2;
118 |
119 | canvas.drawLine(point.left, point.top, point.right, point.bottom, paint);
120 | canvas.drawLine(point.left, point.bottom, point.right, point.top, paint);
121 | canvas.drawLine(centerX, centerY - xie, centerX, centerY + xie, paint);
122 |
123 | }
124 |
125 | public void printPosition() {
126 | Log.d("SknowPoint", "x : " + point.left + " y : " + point.top + " r : "
127 | + point.right + " b : " + point.bottom);
128 | }
129 |
130 | }
131 |
--------------------------------------------------------------------------------
/aslibrary/src/main/java/com/aserbao/alibrary/particle/effect/item/SnowPoint2.java:
--------------------------------------------------------------------------------
1 | package com.aserbao.alibrary.particle.effect.item;
2 |
3 | import android.graphics.Canvas;
4 | import android.graphics.Paint;
5 | import android.graphics.Point;
6 |
7 | import com.aserbao.alibrary.particle.effect.base.EffectItem;
8 |
9 | public class SnowPoint2 extends EffectItem{
10 |
11 | private Paint paint = new Paint();
12 | private final int size = 36; // 长度在0-50像素
13 | private int lenSize;// 边长
14 | private int mul;// 倍数
15 | private Point point; // 雪点
16 | private Point speed; // 雪点x,y方向速度
17 |
18 | public SnowPoint2(int width, int height) {
19 | super(width, height);
20 | point = new Point();
21 | speed = new Point();
22 | paint.setColor(0xffffffff);
23 | reset();
24 | }
25 | public SnowPoint2(int width, int height, int color) {
26 | super(width, height, color);
27 | point = new Point();
28 | speed = new Point();
29 | paint.setColor(color);
30 | reset();
31 | }
32 | public SnowPoint2(int width, int height, int color, boolean randColor) {
33 | super(width, height, color, randColor);
34 | point = new Point();
35 | speed = new Point();
36 | reset();
37 | }
38 | public void draw(Canvas canvas) {
39 | // 变长小于等于8绘制圆形
40 | if (lenSize <= 10) {
41 | canvas.drawCircle(point.x, point.y, lenSize / 2, paint);
42 | } else {
43 | // 绘制雪花形状
44 | drawSknow(canvas);
45 | }
46 | }
47 |
48 | int count = 0;
49 |
50 | public void move() {
51 | point.x += speed.x;
52 | point.y += speed.y;
53 | count++;
54 | if (count > 5) {
55 | count = 0;
56 | speed.x = rand.nextInt(size);
57 | speed.x = speed.x > speed.y ? speed.y : speed.x;
58 | speed.x = rand.nextBoolean() ? -speed.x : speed.x;
59 | speed.y += rand.nextBoolean() ? 1 : 0;
60 | }
61 |
62 | if (point.x < 0 || point.x > width || point.y > height) {
63 | reset();
64 | }
65 | }
66 |
67 | private void reset() {
68 | point.x = rand.nextInt(width);
69 | point.y = rand.nextInt(height);
70 | lenSize = rand.nextInt(size);
71 |
72 | lenSize += lenSize % 5;
73 | mul = lenSize / 5;
74 |
75 | int speedX = rand.nextInt(size);
76 | int speedY = rand.nextInt(size);
77 | /*
78 | * int speedX = w; int speedY = h;
79 | */
80 |
81 | speedX = speedX == 0 ? 1 : speedX;
82 | speedY = speedY == 0 ? 1 : speedY;
83 | speedX = speedX > speedY ? speedY : speedX;
84 |
85 | speed.x = speedX;
86 | speed.y = speedY;
87 | randomColor();
88 | paint.setColor(color);
89 | }
90 |
91 | private void drawSknow(Canvas canvas) {
92 | int y = mul * 3;
93 | int x = mul * 4;
94 |
95 | if (speed.x > 0) {
96 | // 竖雪花
97 | canvas.drawLine(point.x, point.y - (float) lenSize / 2, point.x,
98 | point.y + (float) lenSize / 2, paint);
99 | canvas.drawLine(point.x - (float) x / 2, point.y - (float) y / 2,
100 | point.x + (float) x / 2, point.y + (float) y / 2, paint);
101 | canvas.drawLine(point.x - (float) x / 2, point.y + (float) y / 2,
102 | point.x + (float) x / 2, point.y - (float) y / 2, paint);
103 | } else {
104 | // 横雪花
105 | canvas.drawLine(point.x - (float) lenSize / 2, point.y, point.x
106 | + (float) lenSize / 2, point.y, paint);
107 | canvas.drawLine(point.x - (float) y / 2, point.y - (float) x / 2,
108 | point.x + (float) y / 2, point.y + (float) x / 2, paint);
109 | canvas.drawLine(point.x - (float) y / 2, point.y + (float) x / 2,
110 | point.x + (float) y / 2, point.y - (float) x / 2, paint);
111 | }
112 |
113 | }
114 |
115 | }
116 |
--------------------------------------------------------------------------------
/aslibrary/src/main/java/com/aserbao/alibrary/particle/effect/item/Star.java:
--------------------------------------------------------------------------------
1 | package com.aserbao.alibrary.particle.effect.item;
2 |
3 | import android.graphics.Canvas;
4 | import android.graphics.Paint;
5 | import android.graphics.Point;
6 |
7 | import com.aserbao.alibrary.particle.effect.base.EffectItem;
8 |
9 | public class Star extends EffectItem{
10 |
11 | private final int NORMAL = 0;
12 | private final int LIGHT = 1;
13 | private final int METEOR = 2;
14 | private int state = NORMAL;
15 |
16 | private Paint paint = new Paint();
17 | private final int size = 10; // 长度在0-size像素
18 | private int radius;
19 | private Point point; // 星星
20 |
21 | private int light = 100;// 闪烁
22 | private int meteor = 10000;// 流星
23 |
24 | //星星闪烁类型
25 | private final int LIGHT_FULL = 0;
26 | private final int LIGHT_HALF = 1;
27 | private final int LIGHT_HALF_ALPHA = 2;
28 | private int lightState = 0;
29 | private int lightAlpha = 80;
30 |
31 | //流星移动值
32 | private int meteorSpeedX;
33 | private int meteorSpeedY;
34 | private int meteorState = 0;
35 | private int meteorAlpha = 255;
36 | private int meteorStep;
37 |
38 |
39 | public Star(int width, int height) {
40 | super(width, height);
41 | point = new Point();
42 | paint.setColor(0xffffffff);
43 | reset();
44 | }
45 | public Star(int width, int height, int color) {
46 | super(width, height, color);
47 | point = new Point();
48 | paint.setColor(color);
49 | reset();
50 | }
51 | public Star(int width, int height, int color, boolean randColor) {
52 | super(width, height, color, randColor);
53 | point = new Point();
54 | reset();
55 | }
56 | public void draw(Canvas canvas) {
57 | // 变长小于等于8绘制圆形
58 | switch (state) {
59 | case NORMAL:
60 | canvas.drawCircle(point.x, point.y, radius / 2, paint);
61 | break;
62 | case LIGHT:
63 | canvas.drawCircle(point.x, point.y, radius / 2, paint);
64 | drawLightStar(canvas);
65 | break;
66 | case METEOR:
67 | drawMeteor(canvas);
68 | break;
69 | }
70 | }
71 |
72 | public void move() {
73 |
74 | switch (state) {
75 | case NORMAL:
76 | while (point.x < 0 || point.x > width || point.y > height) {
77 | reset();
78 | }
79 | int mod = rand.nextInt(light + 1) % light;
80 | if (mod == 0) {
81 | // 闪烁
82 | state = LIGHT;
83 | lightState = rand.nextInt(10) % 3;
84 | return;
85 | }
86 | mod = rand.nextInt(meteor + 1) % meteor;
87 | if (mod == 0) {
88 | // 流星
89 | state = METEOR;
90 | meteorSpeedY = 1 + rand.nextInt(height / 20);
91 | meteorSpeedX = rand.nextInt(width / 20);
92 | meteorSpeedX *= rand.nextBoolean() ? 1 : -1;
93 | meteorStep = 1;
94 | return;
95 | }
96 | break;
97 | case LIGHT:
98 | lightAlpha -= 20;
99 | if(lightAlpha < 0){
100 | state = NORMAL;
101 | lightAlpha = 80;
102 | }
103 | break;
104 | case METEOR:
105 | meteorAlpha -= 20;
106 | if(meteorAlpha < 0){
107 | state = NORMAL;
108 | meteorAlpha = 255;
109 | meteorStep = 1;
110 | return;
111 | }
112 | meteorState = rand.nextInt(10) % 3;
113 | meteorStep ++;
114 | break;
115 | }
116 |
117 | }
118 |
119 | private void reset() {
120 | point.x = rand.nextInt(width);
121 | point.y = rand.nextInt(height / 2);
122 | radius = rand.nextInt(size);
123 |
124 | randomColor();
125 | paint.setColor(color);
126 | }
127 |
128 | private void drawLightStar(Canvas canvas) {
129 |
130 | switch(lightState){
131 | case LIGHT_HALF:
132 | //左右交叉
133 | canvas.drawLine(point.x - radius, point.y - radius, point.x + radius, point.y + radius, paint);
134 | canvas.drawLine(point.x - radius, point.y + radius, point.x + radius, point.y - radius, paint);
135 | break;
136 | case LIGHT_FULL:
137 | paint.setAlpha(255 - lightAlpha);
138 | //绘制横竖向
139 | canvas.drawLine(point.x - 2 * radius, point.y, point.x + 2 * radius, point.y, paint);
140 | canvas.drawLine(point.x, point.y - 2 * radius, point.x, point.y + 2 * radius, paint);
141 | case LIGHT_HALF_ALPHA:
142 | paint.setAlpha(lightAlpha);
143 | //左右交叉
144 | canvas.drawLine(point.x - radius, point.y - radius, point.x + radius, point.y + radius, paint);
145 | canvas.drawLine(point.x - radius, point.y + radius, point.x + radius, point.y - radius, paint);
146 | paint.setAlpha(255);
147 | break;
148 | }
149 |
150 | }
151 |
152 | private void drawMeteor(Canvas canvas){
153 |
154 | int trimX = meteorStep * meteorSpeedX;
155 | int trimY = meteorStep * meteorSpeedY;
156 | paint.setAlpha(lightAlpha);
157 | //绘制流行轨迹
158 | canvas.drawLine(point.x, point.y, trimX + point.x, trimY + point.y, paint);
159 | paint.setAlpha(255);
160 | canvas.drawCircle(trimX + point.x, trimY + point.y, radius / 2, paint);
161 | switch(meteorState){
162 | case LIGHT_HALF:
163 | //左右交叉
164 | canvas.drawLine(trimX + point.x - radius, trimY + point.y - radius, trimX + point.x + radius, trimY + point.y + radius, paint);
165 | canvas.drawLine(trimX + point.x - radius, trimY + point.y + radius, trimX + point.x + radius, trimY + point.y - radius, paint);
166 | break;
167 | case LIGHT_FULL:
168 | paint.setAlpha(255 - lightAlpha);
169 | //绘制横竖向
170 | canvas.drawLine(trimX + point.x - 2 * radius, trimY + point.y, trimX + point.x + 2 * radius, trimY + point.y, paint);
171 | canvas.drawLine(trimX + point.x, trimY + point.y - 2 * radius, trimX + point.x, trimY + point.y + 2 * radius, paint);
172 | case LIGHT_HALF_ALPHA:
173 | paint.setAlpha(lightAlpha);
174 | //左右交叉
175 | canvas.drawLine(trimX + point.x - radius, trimY + point.y - radius, trimX + point.x + radius, trimY + point.y + radius, paint);
176 | canvas.drawLine(trimX + point.x - radius, trimY + point.y + radius, trimX + point.x + radius, trimY + point.y - radius, paint);
177 | paint.setAlpha(255);
178 | break;
179 | }
180 | }
181 |
182 | }
183 |
--------------------------------------------------------------------------------
/aslibrary/src/main/java/com/aserbao/alibrary/particle/effect/scene/Lightning.java:
--------------------------------------------------------------------------------
1 | package com.aserbao.alibrary.particle.effect.scene;
2 |
3 |
4 | import java.util.ArrayList;
5 |
6 | import com.aserbao.alibrary.particle.effect.base.EffectItem;
7 |
8 | import android.graphics.Canvas;
9 | import android.graphics.Paint;
10 | import android.graphics.Rect;
11 | import android.util.Log;
12 |
13 | /**
14 | * 闪电特殊,没有子元素
15 | * @author xianfeng
16 | *
17 | */
18 | public class Lightning extends EffectItem{
19 |
20 | private final String TAG = "Lightning";
21 |
22 | private Paint paint = new Paint();
23 | private final int minSize = 10;
24 | private final int maxSize = 50; // 长度在0-50像素
25 | private ArrayList lines = new ArrayList();
26 |
27 | private int alpha = 255;
28 |
29 | public Lightning(int width, int height){
30 | super(width, height);
31 | reset();
32 | }
33 |
34 | public synchronized void draw(Canvas canvas){
35 | if(canvas == null){
36 | return;
37 | }
38 | // paint.setAlpha(alpha);
39 | // paint.setColor(0xffffffff);
40 | canvas.drawColor((alpha << 24) | (255 << 16) | (255 << 8) | 255);
41 | paint.setARGB(alpha, 255, 125, 0);
42 | for(Rect rect : lines){
43 | canvas.drawLine(rect.left, rect.top, rect.right, rect.bottom, paint);
44 | }
45 | }
46 |
47 | public synchronized void reset(){
48 | int x = rand.nextInt(width);
49 | int y = rand.nextInt(height / 2);
50 | int w = 0;
51 | int h = 0;
52 | lines.clear();
53 | while(x < width && y < height){
54 | Rect rect = new Rect();
55 |
56 | rect.left = x;
57 | rect.top = y;
58 | w = minSize + rand.nextInt(maxSize);
59 | h = minSize + rand.nextInt(maxSize);
60 | w *= rand.nextBoolean() ? 1 : -1;
61 | x += w;
62 | y += h;
63 |
64 | rect.right = x;
65 | rect.bottom = y;
66 | lines.add(rect);
67 | //加入闪电节点分出的闪电
68 | int len = rand.nextInt(6);
69 | for(int i = 0; i < len; i ++){
70 | Rect r = new Rect();
71 | r.left = x;
72 | r.top = y;
73 | w = rand.nextInt(maxSize);
74 | h = minSize + rand.nextInt(maxSize);
75 | w *= rand.nextBoolean() ? 1 : -1;
76 |
77 | r.right = x + w;
78 | r.bottom = y + h;
79 | lines.add(r);
80 | }
81 |
82 | }
83 | alpha = 255;
84 | Log.w(TAG, "light is reset");
85 | }
86 |
87 | public void move(){
88 | alpha -= 30;
89 | if(alpha < 0){
90 | alpha = 0;
91 | }
92 | }
93 |
94 | }
95 |
--------------------------------------------------------------------------------
/aslibrary/src/main/java/com/aserbao/alibrary/particle/effect/scene/MusicJumpScence.java:
--------------------------------------------------------------------------------
1 | package com.aserbao.alibrary.particle.effect.scene;
2 |
3 |
4 | import com.aserbao.alibrary.particle.effect.base.EffectScence;
5 | import com.aserbao.alibrary.particle.effect.item.MusicPoint;
6 |
7 | public class MusicJumpScence extends EffectScence {
8 | @Deprecated
9 | public MusicJumpScence(int width, int height, int musicNum){
10 | super(width, height, musicNum);
11 | }
12 | @Deprecated
13 | public MusicJumpScence(int width, int height, int musicNum, int itemColor){
14 | super(width, height, musicNum, itemColor);
15 | }
16 |
17 | public MusicJumpScence(int width, int height, int musicNum, int itemColor, boolean randColor){
18 | super(width, height, musicNum, itemColor, randColor);
19 | }
20 |
21 | protected void initScence() {
22 | for(int i = 0; i < itemNum; i ++){
23 | list.add(new MusicPoint(i * width / itemNum, width, height, itemColor, randColor));
24 | }
25 | }
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/aslibrary/src/main/java/com/aserbao/alibrary/particle/effect/scene/RainScence.java:
--------------------------------------------------------------------------------
1 | package com.aserbao.alibrary.particle.effect.scene;
2 |
3 | import com.aserbao.alibrary.particle.effect.base.EffectScence;
4 | import com.aserbao.alibrary.particle.effect.item.RainPoint;
5 |
6 | public class RainScence extends EffectScence{
7 |
8 | /**
9 | * 雨景构造
10 | * @param rainNum 雨点数量
11 | * @param width 雨点显示屏幕宽
12 | * @param height 雨点显示屏幕高
13 | */
14 | @Deprecated
15 | public RainScence(int width, int height, int rainNum){
16 | super(width, height,rainNum);
17 | }
18 | @Deprecated
19 | public RainScence(int width, int height, int rainNum, int itemColor){
20 | super(width, height,rainNum, itemColor);
21 | }
22 |
23 | public RainScence(int width, int height, int rainNum, int itemColor, boolean randColor){
24 | super(width, height,rainNum, itemColor, randColor);
25 | }
26 |
27 | @Override
28 | protected void initScence() {
29 | for(int i = 0; i < itemNum; i ++){
30 | list.add(new RainPoint(width, height, itemColor, randColor));
31 | }
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/aslibrary/src/main/java/com/aserbao/alibrary/particle/effect/scene/Snow2Scence.java:
--------------------------------------------------------------------------------
1 | package com.aserbao.alibrary.particle.effect.scene;
2 |
3 |
4 | import com.aserbao.alibrary.particle.effect.base.EffectScence;
5 | import com.aserbao.alibrary.particle.effect.item.SnowPoint2;
6 |
7 | public class Snow2Scence extends EffectScence {
8 |
9 | @Deprecated
10 | public Snow2Scence(int width, int height, int sknowNum){
11 | super(width, height, sknowNum);
12 | }
13 | public Snow2Scence(int width, int height, int sknowNum, int itemColor){
14 | super(width, height, sknowNum, itemColor);
15 | }
16 | public Snow2Scence(int width, int height, int sknowNum, int itemColor, boolean randColor){
17 | super(width, height, sknowNum, itemColor, randColor);
18 | }
19 | protected void initScence() {
20 | for(int i = 0; i < itemNum; i ++){
21 | list.add(new SnowPoint2(width, height, itemColor, randColor));
22 | }
23 | }
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/aslibrary/src/main/java/com/aserbao/alibrary/particle/effect/scene/SnowScence.java:
--------------------------------------------------------------------------------
1 | package com.aserbao.alibrary.particle.effect.scene;
2 |
3 |
4 | import com.aserbao.alibrary.particle.effect.base.EffectScence;
5 | import com.aserbao.alibrary.particle.effect.item.SnowPoint;
6 |
7 | public class SnowScence extends EffectScence {
8 |
9 | @Deprecated
10 | public SnowScence(int width, int height, int sknowNum){
11 | super(width, height, sknowNum);
12 | }
13 | @Deprecated
14 | public SnowScence(int width, int height, int sknowNum, int itemColor){
15 | super(width, height, sknowNum, itemColor);
16 | }
17 | public SnowScence(int width, int height, int sknowNum, int itemColor, boolean randColor){
18 | super(width, height, sknowNum, itemColor, randColor);
19 | }
20 | protected void initScence() {
21 | for(int i = 0; i < itemNum; i ++){
22 | list.add(new SnowPoint(width, height, itemColor, randColor));
23 | }
24 | }
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/aslibrary/src/main/java/com/aserbao/alibrary/particle/effect/scene/StarSkyScence.java:
--------------------------------------------------------------------------------
1 | package com.aserbao.alibrary.particle.effect.scene;
2 |
3 | import android.graphics.Canvas;
4 |
5 | import com.aserbao.alibrary.particle.effect.base.EffectScence;
6 | import com.aserbao.alibrary.particle.effect.item.Star;
7 |
8 |
9 | public class StarSkyScence extends EffectScence {
10 |
11 | @Deprecated
12 | public StarSkyScence(int width, int height, int sknowNum){
13 | super(width, height, sknowNum);
14 | }
15 | public StarSkyScence(int width, int height, int sknowNum, int itemColor){
16 | super(width, height, sknowNum, itemColor);
17 | }
18 | public StarSkyScence(int width, int height, int sknowNum, int itemColor, boolean randColor){
19 | super(width, height, sknowNum, itemColor, randColor);
20 | }
21 | protected void initScence() {
22 | for(int i = 0; i < itemNum; i ++){
23 | list.add(new Star(width, height, itemColor, randColor));
24 | }
25 | }
26 |
27 | public void draw(Canvas canvas){
28 | canvas.drawColor(0x80000000);
29 | super.draw(canvas);
30 | }
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/aslibrary/src/main/java/com/aserbao/alibrary/particle/fragment/LightFragment.java:
--------------------------------------------------------------------------------
1 | package com.aserbao.alibrary.particle.fragment;
2 |
3 |
4 |
5 | import android.os.Bundle;
6 | import android.support.v4.app.Fragment;
7 | import android.view.LayoutInflater;
8 | import android.view.View;
9 | import android.view.ViewGroup;
10 |
11 | import com.aserbao.aslibrary.R;
12 |
13 | public class LightFragment extends Fragment {
14 |
15 | @Override
16 | public View onCreateView(LayoutInflater inflater, ViewGroup container,
17 | Bundle savedInstanceState) {
18 | View view = inflater.inflate(R.layout.fragment_light, null);
19 | return view;
20 | }
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/aslibrary/src/main/java/com/aserbao/alibrary/particle/fragment/MusicFragment.java:
--------------------------------------------------------------------------------
1 | package com.aserbao.alibrary.particle.fragment;
2 |
3 | //import com.aserbao.aslibrary.R;
4 |
5 | import android.os.Bundle;
6 | import android.support.v4.app.Fragment;
7 | import android.view.LayoutInflater;
8 | import android.view.View;
9 | import android.view.ViewGroup;
10 |
11 | import com.aserbao.aslibrary.R;
12 |
13 | public class MusicFragment extends Fragment {
14 |
15 | @Override
16 | public View onCreateView(LayoutInflater inflater, ViewGroup container,
17 | Bundle savedInstanceState) {
18 | View view = inflater.inflate(R.layout.fragment_music, null);
19 | return view;
20 | }
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/aslibrary/src/main/java/com/aserbao/alibrary/particle/fragment/RainFragment.java:
--------------------------------------------------------------------------------
1 | package com.aserbao.alibrary.particle.fragment;
2 |
3 | import com.aserbao.aslibrary.R;
4 |
5 | import android.os.Bundle;
6 | import android.support.v4.app.Fragment;
7 | import android.view.LayoutInflater;
8 | import android.view.View;
9 | import android.view.ViewGroup;
10 |
11 | public class RainFragment extends Fragment {
12 |
13 | @Override
14 | public View onCreateView(LayoutInflater inflater, ViewGroup container,
15 | Bundle savedInstanceState) {
16 | View view = inflater.inflate(R.layout.fragment_rain, null);
17 | return view;
18 | }
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/aslibrary/src/main/java/com/aserbao/alibrary/particle/fragment/SnowFragment.java:
--------------------------------------------------------------------------------
1 | package com.aserbao.alibrary.particle.fragment;
2 |
3 | import com.aserbao.aslibrary.R;
4 |
5 | import android.os.Bundle;
6 | import android.support.v4.app.Fragment;
7 | import android.view.LayoutInflater;
8 | import android.view.View;
9 | import android.view.ViewGroup;
10 |
11 | public class SnowFragment extends Fragment {
12 |
13 | @Override
14 | public View onCreateView(LayoutInflater inflater, ViewGroup container,
15 | Bundle savedInstanceState) {
16 | View view = inflater.inflate(R.layout.fragment_sknow, null);
17 | return view;
18 | }
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/aslibrary/src/main/java/com/aserbao/alibrary/particle/fragment/StarFragment.java:
--------------------------------------------------------------------------------
1 | package com.aserbao.alibrary.particle.fragment;
2 |
3 | import com.aserbao.aslibrary.R;
4 |
5 | import android.os.Bundle;
6 | import android.support.v4.app.Fragment;
7 | import android.view.LayoutInflater;
8 | import android.view.View;
9 | import android.view.ViewGroup;
10 |
11 | public class StarFragment extends Fragment {
12 |
13 | @Override
14 | public View onCreateView(LayoutInflater inflater, ViewGroup container,
15 | Bundle savedInstanceState) {
16 | View view = inflater.inflate(R.layout.fragment_star, null);
17 |
18 | return view;
19 | }
20 |
21 | }
22 |
--------------------------------------------------------------------------------
/aslibrary/src/main/java/com/aserbao/alibrary/particle/util/LogUtil.java:
--------------------------------------------------------------------------------
1 | package com.aserbao.alibrary.particle.util;
2 |
3 | import android.util.Log;
4 |
5 | public class LogUtil {
6 |
7 | /**
8 | * 输出Log.d
9 | * @param TAG
10 | * @param msg
11 | */
12 | public static void LogD(String TAG, String msg){
13 | Log.d(TAG, msg);
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/aslibrary/src/main/java/com/aserbao/alibrary/particle/widget/EffectAnimation.java:
--------------------------------------------------------------------------------
1 | package com.aserbao.alibrary.particle.widget;
2 |
3 |
4 | import android.annotation.SuppressLint;
5 | import android.content.Context;
6 | import android.content.res.TypedArray;
7 | import android.graphics.Canvas;
8 | import android.graphics.Path;
9 | import android.graphics.Path.Direction;
10 | import android.os.Handler;
11 | import android.util.AttributeSet;
12 | import android.view.View;
13 |
14 | import com.aserbao.alibrary.particle.effect.base.EffectScence;
15 | import com.aserbao.aslibrary.R;
16 |
17 | /**
18 | * 效果动画基类
19 | * @author xianfeng
20 | *
21 | */
22 | @SuppressLint("NewApi") public abstract class EffectAnimation extends View {
23 |
24 | protected final String TAG = "EffectAnimation";
25 |
26 | private Thread spriteThread;
27 | private boolean running = false;
28 | protected EffectScence scence;
29 | //item attribute
30 | private int itemNum;
31 | private int itemColor = 0xffffffff;
32 | private boolean randColor = false;
33 | //clip
34 | private boolean clip_scale = false;
35 | private int clip_radius = 0;
36 | private int clip_step = 0;
37 | private int clip_dur_time = 2000;
38 |
39 | public EffectAnimation(Context context, AttributeSet attrs, int defStyleAttr) {
40 | super(context, attrs, defStyleAttr);
41 | }
42 |
43 | public EffectAnimation(Context context, AttributeSet attrs) {
44 | super(context, attrs);
45 | TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.EffectAnimation);
46 | itemNum = a.getInt(R.styleable.EffectAnimation_itemNum, 0);
47 | itemColor = a.getColor(R.styleable.EffectAnimation_itemColor, 0xffffffff);
48 | randColor = a.getBoolean(R.styleable.EffectAnimation_randColor, false);
49 | clip_scale = a.getBoolean(R.styleable.EffectAnimation_clipScale, false);
50 | a.recycle();
51 | setLayerType(View.LAYER_TYPE_SOFTWARE, null);
52 | }
53 |
54 | public EffectAnimation(Context context) {
55 | super(context);
56 | }
57 |
58 | /**
59 | * 需要初始话的效果场景
60 | * @return
61 | */
62 | protected abstract EffectScence initScence(int itemNum);
63 |
64 | /**
65 | * need init scence
66 | * @param itemNum
67 | * @param itemColor
68 | * @return
69 | */
70 | protected abstract EffectScence initScence(int itemNum, int itemColor);
71 |
72 | /**
73 | * need init scence
74 | * @param itemNum
75 | * @param itemColor
76 | * @param randColor
77 | * @return
78 | */
79 | protected abstract EffectScence initScence(int itemNum, int itemColor, boolean randColor);
80 |
81 | private void init(){
82 | running = false;
83 | if(itemNum == 0){
84 | itemNum = 100;
85 | }
86 |
87 | clip_step = getWidth() < getHeight() ? getHeight() : getWidth();
88 | clip_step /= 2;
89 | clip_radius = 0;
90 |
91 | scence = initScence(itemNum, itemColor, randColor);
92 | spriteThread = new Thread(run);
93 | spriteThread.start();
94 | }
95 |
96 | @Override
97 | protected void onDraw(Canvas canvas) {
98 | super.onDraw(canvas);
99 | if(scence != null){
100 | if(clip_scale){
101 | Path path = new Path();
102 | path.addCircle(getWidth() / 2, getHeight() / 2, clip_radius, Direction.CCW);
103 | canvas.save();
104 | canvas.clipPath(path);
105 | scence.draw(canvas);
106 | canvas.restore();
107 | }else{
108 | scence.draw(canvas);
109 | }
110 | }
111 | else{
112 | init();
113 | }
114 | }
115 |
116 | @Override
117 | protected void onDetachedFromWindow() {
118 | super.onDetachedFromWindow();
119 | running = false;
120 | }
121 |
122 | private Runnable run = new Runnable(){
123 | public void run() {
124 | running = true;
125 | long curTime = 0;
126 | while (running) {
127 | curTime = System.currentTimeMillis();
128 | animLogic();
129 | mHandler.sendEmptyMessage(0);
130 | curTime = System.currentTimeMillis() - curTime;
131 | if(curTime < 30){
132 | try {
133 | Thread.sleep(30 - curTime);
134 | } catch (InterruptedException e) {
135 | break;
136 | }
137 | }
138 | }
139 |
140 | }
141 | };
142 |
143 | private void animLogic(){
144 | if(scence != null){
145 | scence.move();
146 | }
147 |
148 | clip_radius += 30 * clip_step / clip_dur_time ;
149 | if(clip_radius > clip_step){
150 | clip_scale = false;
151 | }
152 | }
153 |
154 | private Handler mHandler = new Handler() {
155 | public void handleMessage(android.os.Message msg) {
156 | invalidate();
157 | };
158 | };
159 |
160 | protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
161 | super.onLayout(changed, left, top, right, bottom);
162 | };
163 | }
164 |
--------------------------------------------------------------------------------
/aslibrary/src/main/java/com/aserbao/alibrary/particle/widget/LightningAnimation.java:
--------------------------------------------------------------------------------
1 | package com.aserbao.alibrary.particle.widget;
2 |
3 | import java.util.Random;
4 |
5 | import com.aserbao.alibrary.particle.effect.scene.Lightning;
6 |
7 | import android.content.Context;
8 | import android.graphics.Canvas;
9 | import android.os.Handler;
10 | import android.util.AttributeSet;
11 | import android.view.View;
12 |
13 | public class LightningAnimation extends View {
14 |
15 | private boolean running = false;
16 | private Lightning lightning;
17 | private Random rand;
18 | private int countTime = 0;
19 | private int during = 3000;
20 |
21 | public LightningAnimation(Context context, AttributeSet attrs,
22 | int defStyleAttr) {
23 | super(context, attrs, defStyleAttr);
24 | }
25 |
26 | public LightningAnimation(Context context, AttributeSet attrs) {
27 | super(context, attrs);
28 | }
29 |
30 | public LightningAnimation(Context context) {
31 | super(context);
32 | }
33 |
34 | @Override
35 | protected void onDraw(Canvas canvas) {
36 | if(lightning == null){
37 | initLightning();
38 | }
39 | else{
40 | lightning.draw(canvas);
41 | }
42 | }
43 |
44 | private void initLightning() {
45 | int width = getWidth();
46 | int height = getHeight();
47 |
48 | rand = new Random();
49 | lightning = new Lightning(width, height);
50 | spriteThread.start();
51 | }
52 |
53 | @Override
54 | protected void onDetachedFromWindow() {
55 | super.onDetachedFromWindow();
56 | running = false;
57 | }
58 |
59 | private Thread spriteThread = new Thread() {
60 | public void run() {
61 | running = true;
62 | while (running) {
63 | lightning.move();
64 |
65 | try {
66 | Thread.sleep(50);
67 | countTime += 50;
68 | if (countTime > during) {
69 | countTime = 0;
70 | during = 3000 + rand.nextInt(6000);
71 | lightning.reset();
72 | }
73 | } catch (InterruptedException e) {
74 | break;
75 | }
76 | mHandler.sendEmptyMessage(0);
77 | }
78 |
79 | }
80 | };
81 |
82 | private Handler mHandler = new Handler() {
83 | public void handleMessage(android.os.Message msg) {
84 |
85 | invalidate();
86 | };
87 | };
88 |
89 | }
90 |
--------------------------------------------------------------------------------
/aslibrary/src/main/java/com/aserbao/alibrary/particle/widget/MusicAnimation.java:
--------------------------------------------------------------------------------
1 | package com.aserbao.alibrary.particle.widget;
2 |
3 | import android.content.Context;
4 | import android.util.AttributeSet;
5 |
6 | //import com.aserbao.alibrary.particle.effect.base.EffectScence;
7 | import com.aserbao.alibrary.particle.effect.base.EffectScence;
8 | import com.aserbao.alibrary.particle.effect.scene.MusicJumpScence;
9 | import com.aserbao.alibrary.particle.effect.scene.RainScence;
10 |
11 | public class MusicAnimation extends EffectAnimation {
12 |
13 | public MusicAnimation(Context context, AttributeSet attrs, int defStyleAttr) {
14 | super(context, attrs, defStyleAttr);
15 | }
16 |
17 | public MusicAnimation(Context context, AttributeSet attrs) {
18 | super(context, attrs);
19 | }
20 |
21 | public MusicAnimation(Context context) {
22 | super(context);
23 | }
24 |
25 | @Override
26 | protected EffectScence initScence(int itemNum) {
27 | int width = getWidth();
28 | int height = getHeight();
29 |
30 | return new MusicJumpScence(width, height, itemNum);
31 | }
32 |
33 | @Override
34 | protected EffectScence initScence(int itemNum, int itemColor) {
35 | int width = getWidth();
36 | int height = getHeight();
37 |
38 | return new MusicJumpScence(width, height, itemNum, itemColor);
39 | }
40 |
41 | @Override
42 | protected EffectScence initScence(int itemNum, int itemColor,
43 | boolean randColor) {
44 | int width = getWidth();
45 | int height = getHeight();
46 |
47 | return new MusicJumpScence(width, height, itemNum, itemColor, randColor);
48 | }
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/aslibrary/src/main/java/com/aserbao/alibrary/particle/widget/RainAnimation.java:
--------------------------------------------------------------------------------
1 | package com.aserbao.alibrary.particle.widget;
2 |
3 | import android.content.Context;
4 | import android.util.AttributeSet;
5 |
6 | import com.aserbao.alibrary.particle.effect.base.EffectScence;
7 | import com.aserbao.alibrary.particle.effect.scene.RainScence;
8 |
9 | public class RainAnimation extends EffectAnimation {
10 |
11 | public RainAnimation(Context context, AttributeSet attrs, int defStyleAttr) {
12 | super(context, attrs, defStyleAttr);
13 | }
14 |
15 | public RainAnimation(Context context, AttributeSet attrs) {
16 | super(context, attrs);
17 | }
18 |
19 | public RainAnimation(Context context) {
20 | super(context);
21 | }
22 |
23 | @Override
24 | protected EffectScence initScence(int itemNum) {
25 | int width = getWidth();
26 | int height = getHeight();
27 |
28 | return new RainScence(width, height, itemNum);
29 | }
30 |
31 | @Override
32 | protected EffectScence initScence(int itemNum, int itemColor) {
33 | int width = getWidth();
34 | int height = getHeight();
35 |
36 | return new RainScence(width, height, itemNum, itemColor);
37 | }
38 |
39 | @Override
40 | protected EffectScence initScence(int itemNum, int itemColor,
41 | boolean randColor) {
42 | int width = getWidth();
43 | int height = getHeight();
44 |
45 | return new RainScence(width, height, itemNum, itemColor, randColor);
46 | }
47 |
48 | }
49 |
--------------------------------------------------------------------------------
/aslibrary/src/main/java/com/aserbao/alibrary/particle/widget/SnowAnimation.java:
--------------------------------------------------------------------------------
1 | package com.aserbao.alibrary.particle.widget;
2 |
3 | import android.content.Context;
4 | import android.util.AttributeSet;
5 |
6 | import com.aserbao.alibrary.particle.effect.base.EffectScence;
7 | import com.aserbao.alibrary.particle.effect.scene.SnowScence;
8 |
9 | /**
10 | * 基本雪花效果
11 | * @author xianfeng
12 | * 2015年4月23日 上午11:37:58
13 | */
14 | public class SnowAnimation extends EffectAnimation {
15 |
16 | public SnowAnimation(Context context, AttributeSet attrs, int defStyleAttr) {
17 | super(context, attrs, defStyleAttr);
18 | }
19 |
20 | public SnowAnimation(Context context, AttributeSet attrs) {
21 | super(context, attrs);
22 | }
23 |
24 | public SnowAnimation(Context context) {
25 | super(context);
26 | }
27 |
28 | @Override
29 | @Deprecated
30 | protected EffectScence initScence(int itemNum) {
31 | int width = getWidth();
32 | int height = getHeight();
33 |
34 | return new SnowScence(width, height, itemNum);
35 | }
36 |
37 | @Override
38 | protected EffectScence initScence(int itemNum, int itemColor) {
39 | int width = getWidth();
40 | int height = getHeight();
41 |
42 | return new SnowScence(width, height, itemNum, itemColor);
43 | }
44 |
45 | @Override
46 | protected EffectScence initScence(int itemNum, int itemColor,
47 | boolean randColor) {
48 | int width = getWidth();
49 | int height = getHeight();
50 |
51 | return new SnowScence(width, height, itemNum, itemColor, randColor);
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/aslibrary/src/main/java/com/aserbao/alibrary/particle/widget/SnowAnimation2.java:
--------------------------------------------------------------------------------
1 | package com.aserbao.alibrary.particle.widget;
2 |
3 | import android.content.Context;
4 | import android.util.AttributeSet;
5 |
6 | import com.aserbao.alibrary.particle.effect.base.EffectScence;
7 | import com.aserbao.alibrary.particle.effect.scene.Snow2Scence;
8 |
9 | public class SnowAnimation2 extends EffectAnimation {
10 |
11 | public SnowAnimation2(Context context, AttributeSet attrs, int defStyleAttr) {
12 | super(context, attrs, defStyleAttr);
13 | }
14 |
15 | public SnowAnimation2(Context context, AttributeSet attrs) {
16 | super(context, attrs);
17 | }
18 |
19 | public SnowAnimation2(Context context) {
20 | super(context);
21 | }
22 |
23 | @Override
24 | protected EffectScence initScence(int itemNum) {
25 | int width = getWidth();
26 | int height = getHeight();
27 |
28 | return new Snow2Scence(width, height, itemNum);
29 | }
30 |
31 | @Override
32 | protected EffectScence initScence(int itemNum, int itemColor) {
33 | int width = getWidth();
34 | int height = getHeight();
35 |
36 | return new Snow2Scence(width, height, itemNum, itemColor);
37 | }
38 |
39 | @Override
40 | protected EffectScence initScence(int itemNum, int itemColor,
41 | boolean randColor) {
42 | int width = getWidth();
43 | int height = getHeight();
44 |
45 | return new Snow2Scence(width, height, itemNum, itemColor, randColor);
46 | }
47 |
48 | }
49 |
--------------------------------------------------------------------------------
/aslibrary/src/main/java/com/aserbao/alibrary/particle/widget/StarSkyAnimation.java:
--------------------------------------------------------------------------------
1 | package com.aserbao.alibrary.particle.widget;
2 | import android.content.Context;
3 | import android.util.AttributeSet;
4 |
5 | import com.aserbao.alibrary.particle.effect.base.EffectScence;
6 | import com.aserbao.alibrary.particle.effect.scene.StarSkyScence;
7 |
8 |
9 | public class StarSkyAnimation extends EffectAnimation {
10 |
11 | public StarSkyAnimation(Context context, AttributeSet attrs, int defStyleAttr) {
12 | super(context, attrs, defStyleAttr);
13 | }
14 |
15 | public StarSkyAnimation(Context context, AttributeSet attrs) {
16 | super(context, attrs);
17 | }
18 |
19 | public StarSkyAnimation(Context context) {
20 | super(context);
21 | }
22 |
23 | @Override
24 | protected EffectScence initScence(int itemNum) {
25 | int width = getWidth();
26 | int height = getHeight();
27 |
28 | return new StarSkyScence(width, height, itemNum);
29 | }
30 |
31 | @Override
32 | protected EffectScence initScence(int itemNum, int itemColor) {
33 | int width = getWidth();
34 | int height = getHeight();
35 |
36 | return new StarSkyScence(width, height, itemNum, itemColor);
37 | }
38 |
39 | @Override
40 | protected EffectScence initScence(int itemNum, int itemColor,
41 | boolean randColor) {
42 | int width = getWidth();
43 | int height = getHeight();
44 |
45 | return new StarSkyScence(width, height, itemNum, itemColor, randColor);
46 | }
47 |
48 | }
49 |
--------------------------------------------------------------------------------
/aslibrary/src/main/res/drawable-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aserbao/HomePager/08f005aa8c2464272e7cb37fa9a2c8d9088852db/aslibrary/src/main/res/drawable-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/aslibrary/src/main/res/drawable-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aserbao/HomePager/08f005aa8c2464272e7cb37fa9a2c8d9088852db/aslibrary/src/main/res/drawable-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/aslibrary/src/main/res/drawable-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aserbao/HomePager/08f005aa8c2464272e7cb37fa9a2c8d9088852db/aslibrary/src/main/res/drawable-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/aslibrary/src/main/res/drawable-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aserbao/HomePager/08f005aa8c2464272e7cb37fa9a2c8d9088852db/aslibrary/src/main/res/drawable-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/aslibrary/src/main/res/drawable/home_item_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/aslibrary/src/main/res/drawable/tab_selector.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | "
4 |
5 |
6 |
--------------------------------------------------------------------------------
/aslibrary/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
9 |
10 |
14 |
15 |
20 |
21 |
--------------------------------------------------------------------------------
/aslibrary/src/main/res/layout/fragment_light.xml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
12 |
13 |
--------------------------------------------------------------------------------
/aslibrary/src/main/res/layout/fragment_music.xml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
14 |
15 |
--------------------------------------------------------------------------------
/aslibrary/src/main/res/layout/fragment_rain.xml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
14 |
15 |
--------------------------------------------------------------------------------
/aslibrary/src/main/res/layout/fragment_rose_down.xml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
14 |
15 |
--------------------------------------------------------------------------------
/aslibrary/src/main/res/layout/fragment_sknow.xml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
16 |
17 |
--------------------------------------------------------------------------------
/aslibrary/src/main/res/layout/fragment_star.xml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
15 |
16 |
--------------------------------------------------------------------------------
/aslibrary/src/main/res/layout/tab_container.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/aslibrary/src/main/res/layout/tab_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/aslibrary/src/main/res/menu/main.xml:
--------------------------------------------------------------------------------
1 |
10 |
--------------------------------------------------------------------------------
/aslibrary/src/main/res/values-sw600dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/aslibrary/src/main/res/values-sw720dp-land/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 | 128dp
8 |
9 |
10 |
--------------------------------------------------------------------------------
/aslibrary/src/main/res/values-v11/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/aslibrary/src/main/res/values-v14/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/aslibrary/src/main/res/values/attrs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/aslibrary/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #5005f6f3
4 | #50fff6f3
5 |
6 |
--------------------------------------------------------------------------------
/aslibrary/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 16dp
5 | 16dp
6 |
7 | 150dp
8 |
9 |
--------------------------------------------------------------------------------
/aslibrary/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Particle
5 | Settings
6 | Hello world!
7 |
8 |
9 |
--------------------------------------------------------------------------------
/aslibrary/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
14 |
15 |
16 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/aslibrary/src/test/java/com/aserbao/aslibrary/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.aserbao.aslibrary;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | jcenter()
6 | }
7 | dependencies {
8 | classpath 'com.android.tools.build:gradle:2.3.3'
9 | classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
10 | // NOTE: Do not place your application dependencies here; they belong
11 | // in the individual module build.gradle files
12 | }
13 | }
14 |
15 | allprojects {
16 | repositories {
17 | jcenter()
18 | }
19 | }
20 |
21 | task clean(type: Delete) {
22 | delete rootProject.buildDir
23 | }
24 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | ## Project-wide Gradle settings.
2 | #
3 | # For more details on how to configure your build environment visit
4 | # http://www.gradle.org/docs/current/userguide/build_environment.html
5 | #
6 | # Specifies the JVM arguments used for the daemon process.
7 | # The setting is particularly useful for tweaking memory settings.
8 | # Default value: -Xmx1024m -XX:MaxPermSize=256m
9 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
10 | #
11 | # When configured, Gradle will run in incubating parallel mode.
12 | # This option should only be used with decoupled projects. More details, visit
13 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
14 | # org.gradle.parallel=true
15 | #Fri Sep 29 11:45:59 CST 2017
16 | systemProp.http.proxyHost=mirrors.neusoft.edu.cn
17 | org.gradle.jvmargs=-Xmx2048m
18 | systemProp.http.proxyPort=80
19 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aserbao/HomePager/08f005aa8c2464272e7cb37fa9a2c8d9088852db/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Mon Jul 10 10:11:47 CST 2017
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------