├── .gitignore
├── .idea
├── .name
├── compiler.xml
├── copyright
│ └── profiles_settings.xml
├── encodings.xml
├── gradle.xml
├── misc.xml
├── modules.xml
└── vcs.xml
├── GoldDemo.iml
├── README.md
├── app
├── .gitignore
├── app.iml
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── lengyue
│ │ └── apkdv
│ │ └── golddemo
│ │ └── ApplicationTest.java
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── lengyue
│ │ └── apkdv
│ │ └── golddemo
│ │ ├── DvAppUtil.java
│ │ ├── MainActivity.java
│ │ └── flake
│ │ ├── Flake.java
│ │ └── FlakeView.java
│ └── res
│ ├── drawable-hdpi
│ ├── ic_launcher.png
│ ├── reward_care.png
│ └── reward_money.png
│ ├── drawable-mdpi
│ └── ic_launcher.png
│ ├── drawable-xhdpi
│ ├── ic_launcher.png
│ ├── reward.png
│ ├── reward_care.png
│ └── reward_money.png
│ ├── drawable-xxhdpi
│ ├── ic_launcher.png
│ └── reward.png
│ ├── drawable
│ ├── b.png
│ └── shape_white_no_stroke.xml
│ ├── layout
│ ├── activity_main.xml
│ └── view_login_reward.xml
│ ├── menu
│ └── menu_main.xml
│ ├── raw
│ └── shake.mp3
│ ├── values-w820dp
│ └── dimens.xml
│ └── values
│ ├── color.xml
│ ├── dimens.xml
│ ├── strings.xml
│ └── styles.xml
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── screenshot
└── 1429682514132.gif
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | .gradle
2 | /local.properties
3 | /.idea/workspace.xml
4 | /.idea/libraries
5 | .DS_Store
6 | /build
7 | /captures
8 |
--------------------------------------------------------------------------------
/.idea/.name:
--------------------------------------------------------------------------------
1 | GoldDemo
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
18 |
19 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 | Android API 22 Platform
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/GoldDemo.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # 仿淘宝金币掉落动画
2 | 
3 |
4 | 手机截图不是很流畅实际使用会流畅很多
5 |
6 | 声音文件保存在/res/raw 中,可以自己替换
7 |
8 | # 使用方法
9 | 使用PopupWindow来弹出 主题布局和文字都可以很方便的修改
10 | 直接调用
11 |
12 | showPopWindows(View, 现实的金币数);
13 | ```Java
14 | showPopWindows(btnAll, "20");
15 | ```
16 |
17 |
18 | ## 的blog:http://www.apkdv.com/
19 |
20 |
21 |
22 | #License
23 | ---
24 |
25 | Copyright (C) 2014 MarkMjw
26 |
27 | Licensed under the Apache License, Version 2.0 (the "License");
28 | you may not use this file except in compliance with the License.
29 | You may obtain a copy of the License at
30 |
31 | http://www.apache.org/licenses/LICENSE-2.0
32 |
33 | Unless required by applicable law or agreed to in writing, software
34 | distributed under the License is distributed on an "AS IS" BASIS,
35 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
36 | See the License for the specific language governing permissions and
37 | limitations under the License.
38 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/app.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 22
5 | buildToolsVersion "22.0.1"
6 |
7 | defaultConfig {
8 | applicationId "lengyue.apkdv.golddemo"
9 | minSdkVersion 11
10 | targetSdkVersion 22
11 | versionCode 1
12 | versionName "1.0"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 |
22 | dependencies {
23 | compile fileTree(dir: 'libs', include: ['*.jar'])
24 | compile 'com.android.support:appcompat-v7:22.1.0'
25 | }
26 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in D:\android-sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/lengyue/apkdv/golddemo/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package lengyue.apkdv.golddemo;
2 |
3 | import android.app.Application;
4 | import android.test.ApplicationTestCase;
5 |
6 | /**
7 | * Testing Fundamentals
8 | */
9 | public class ApplicationTest extends ApplicationTestCase {
10 | public ApplicationTest() {
11 | super(Application.class);
12 | }
13 | }
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
10 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/app/src/main/java/lengyue/apkdv/golddemo/DvAppUtil.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2012 www.apkdv.com
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package lengyue.apkdv.golddemo;
17 |
18 | import android.app.Activity;
19 | import android.app.ActivityManager;
20 | import android.app.ActivityManager.RunningServiceInfo;
21 | import android.content.Context;
22 | import android.content.Intent;
23 | import android.content.pm.PackageInfo;
24 | import android.content.res.Resources;
25 | import android.location.LocationManager;
26 | import android.net.ConnectivityManager;
27 | import android.net.NetworkInfo;
28 | import android.net.Uri;
29 | import android.telephony.TelephonyManager;
30 | import android.util.DisplayMetrics;
31 | import android.view.inputmethod.InputMethodManager;
32 |
33 | import java.io.File;
34 | import java.io.FileFilter;
35 | import java.io.FileOutputStream;
36 | import java.io.InputStream;
37 | import java.util.Iterator;
38 | import java.util.List;
39 | import java.util.regex.Pattern;
40 |
41 | // TODO: Auto-generated Javadoc
42 |
43 | /**
44 | * © 2012 apkdv.com
45 | * 名称:AbAppUtil.java
46 | * 描述:应用工具类.
47 | *
48 | * @author LengYue
49 | * @version v1.0
50 | * @date:2013-11-10 下午11:52:13
51 | */
52 | public class DvAppUtil {
53 |
54 |
55 | /**
56 | * 描述:打开并安装文件.
57 | *
58 | * @param context the context
59 | * @param file apk文件路径
60 | */
61 | public static void installApk(Context context, File file) {
62 | Intent intent = new Intent();
63 | intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
64 | intent.setAction(Intent.ACTION_VIEW);
65 | intent.setDataAndType(Uri.fromFile(file),
66 | "application/vnd.android.package-archive");
67 | context.startActivity(intent);
68 | }
69 |
70 | /**
71 | * 描述:卸载程序.
72 | *
73 | * @param context the context
74 | * @param packageName 包名
75 | */
76 | public static void uninstallApk(Context context, String packageName) {
77 | Intent intent = new Intent(Intent.ACTION_DELETE);
78 | Uri packageURI = Uri.parse("package:" + packageName);
79 | intent.setData(packageURI);
80 | context.startActivity(intent);
81 | }
82 |
83 |
84 | /**
85 | * 用来判断服务是否运行.
86 | *
87 | * @param ctx the ctx
88 | * @param className 判断的服务名字 "com.xxx.xx..XXXService"
89 | * @return true 在运行 false 不在运行
90 | */
91 | public static boolean isServiceRunning(Context ctx, String className) {
92 | boolean isRunning = false;
93 | ActivityManager activityManager = (ActivityManager) ctx.getSystemService(Context.ACTIVITY_SERVICE);
94 | List servicesList = activityManager.getRunningServices(Integer.MAX_VALUE);
95 | Iterator l = servicesList.iterator();
96 | while (l.hasNext()) {
97 | RunningServiceInfo si = (RunningServiceInfo) l.next();
98 | if (className.equals(si.service.getClassName())) {
99 | isRunning = true;
100 | }
101 | }
102 | return isRunning;
103 | }
104 |
105 | /**
106 | * 停止服务.
107 | *
108 | * @param ctx the ctx
109 | * @param className the class name
110 | * @return true, if successful
111 | */
112 | public static boolean stopRunningService(Context ctx, String className) {
113 | Intent intent_service = null;
114 | boolean ret = false;
115 | try {
116 | intent_service = new Intent(ctx, Class.forName(className));
117 | } catch (Exception e) {
118 | e.printStackTrace();
119 | }
120 | if (intent_service != null) {
121 | ret = ctx.stopService(intent_service);
122 | }
123 | return ret;
124 | }
125 |
126 |
127 | /**
128 | * Gets the number of cores available in this device, across all processors.
129 | * Requires: Ability to peruse the filesystem at "/sys/devices/system/cpu"
130 | *
131 | * @return The number of cores, or 1 if failed to get result
132 | */
133 | public static int getNumCores() {
134 | try {
135 | //Get directory containing CPU info
136 | File dir = new File("/sys/devices/system/cpu/");
137 | //Filter to only list the devices we care about
138 | File[] files = dir.listFiles(new FileFilter() {
139 |
140 | @Override
141 | public boolean accept(File pathname) {
142 | //Check if filename is "cpu", followed by a single digit number
143 | if (Pattern.matches("cpu[0-9]", pathname.getName())) {
144 | return true;
145 | }
146 | return false;
147 | }
148 |
149 | });
150 | //Return the number of cores (virtual CPU devices)
151 | return files.length;
152 | } catch (Exception e) {
153 | //Default to return 1 core
154 | return 1;
155 | }
156 | }
157 |
158 |
159 | /**
160 | * 描述:判断网络是否有效.
161 | *
162 | * @param context the context
163 | * @return true, if is network available
164 | */
165 | public static boolean isNetworkAvailable(Context context) {
166 | try {
167 | ConnectivityManager connectivity = (ConnectivityManager) context
168 | .getSystemService(Context.CONNECTIVITY_SERVICE);
169 | if (connectivity != null) {
170 | NetworkInfo info = connectivity.getActiveNetworkInfo();
171 | if (info != null && info.isConnected()) {
172 | if (info.getState() == NetworkInfo.State.CONNECTED) {
173 | return true;
174 | }
175 | }
176 | }
177 | } catch (Exception e) {
178 | return false;
179 | }
180 | return false;
181 | }
182 |
183 | /**
184 | * Gps是否打开
185 | * 需要权限
186 | *
187 | * @param context the context
188 | * @return true, if is gps enabled
189 | */
190 | public static boolean isGpsEnabled(Context context) {
191 | LocationManager lm = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
192 | return lm.isProviderEnabled(LocationManager.GPS_PROVIDER);
193 | }
194 |
195 | /**
196 | * wifi是否打开.
197 | *
198 | * @param context the context
199 | * @return true, if is wifi enabled
200 | */
201 | public static boolean isWifiEnabled(Context context) {
202 | ConnectivityManager mgrConn = (ConnectivityManager) context
203 | .getSystemService(Context.CONNECTIVITY_SERVICE);
204 | TelephonyManager mgrTel = (TelephonyManager) context
205 | .getSystemService(Context.TELEPHONY_SERVICE);
206 | return ((mgrConn.getActiveNetworkInfo() != null && mgrConn
207 | .getActiveNetworkInfo().getState() == NetworkInfo.State.CONNECTED) || mgrTel
208 | .getNetworkType() == TelephonyManager.NETWORK_TYPE_UMTS);
209 | }
210 |
211 | /**
212 | * 判断当前网络是否是wifi网络.
213 | *
214 | * @param context the context
215 | * @return boolean
216 | */
217 | public static boolean isWifi(Context context) {
218 | ConnectivityManager connectivityManager = (ConnectivityManager) context
219 | .getSystemService(Context.CONNECTIVITY_SERVICE);
220 | NetworkInfo activeNetInfo = connectivityManager.getActiveNetworkInfo();
221 | if (activeNetInfo != null
222 | && activeNetInfo.getType() == ConnectivityManager.TYPE_WIFI) {
223 | return true;
224 | }
225 | return false;
226 | }
227 |
228 | /**
229 | * 判断当前网络是否是移动数据网络.
230 | *
231 | * @param context the context
232 | * @return boolean
233 | */
234 | public static boolean isMobile(Context context) {
235 | ConnectivityManager connectivityManager = (ConnectivityManager) context
236 | .getSystemService(Context.CONNECTIVITY_SERVICE);
237 | NetworkInfo activeNetInfo = connectivityManager.getActiveNetworkInfo();
238 | if (activeNetInfo != null
239 | && activeNetInfo.getType() == ConnectivityManager.TYPE_MOBILE) {
240 | return true;
241 | }
242 | return false;
243 | }
244 |
245 | /**
246 | * 导入数据库.
247 | *
248 | * @param context the context
249 | * @param dbName the db name
250 | * @param rawRes the raw res
251 | * @return true, if successful
252 | */
253 | public static boolean importDatabase(Context context, String dbName, int rawRes) {
254 | int buffer_size = 1024;
255 | InputStream is = null;
256 | FileOutputStream fos = null;
257 | boolean flag = false;
258 |
259 | try {
260 | String dbPath = "/data/data/" + context.getPackageName() + "/databases/" + dbName;
261 | File dbfile = new File(dbPath);
262 | //判断数据库文件是否存在,若不存在则执行导入,否则直接打开数据库
263 | if (!dbfile.exists()) {
264 | //欲导入的数据库
265 | if (!dbfile.getParentFile().exists()) {
266 | dbfile.getParentFile().mkdirs();
267 | }
268 | dbfile.createNewFile();
269 | is = context.getResources().openRawResource(rawRes);
270 | fos = new FileOutputStream(dbfile);
271 | byte[] buffer = new byte[buffer_size];
272 | int count = 0;
273 | while ((count = is.read(buffer)) > 0) {
274 | fos.write(buffer, 0, count);
275 | }
276 | fos.flush();
277 | }
278 | flag = true;
279 | } catch (Exception e) {
280 | e.printStackTrace();
281 | } finally {
282 | if (fos != null) {
283 | try {
284 | fos.close();
285 | } catch (Exception e) {
286 | }
287 | }
288 | if (is != null) {
289 | try {
290 | is.close();
291 | } catch (Exception e) {
292 | }
293 | }
294 | }
295 | return flag;
296 | }
297 |
298 | /**
299 | * 获取屏幕尺寸与密度.
300 | *
301 | * @param context the context
302 | * @return mDisplayMetrics
303 | */
304 | public static DisplayMetrics getDisplayMetrics(Context context) {
305 | Resources mResources;
306 | if (context == null) {
307 | mResources = Resources.getSystem();
308 |
309 | } else {
310 | mResources = context.getResources();
311 | }
312 | //DisplayMetrics{density=1.5, width=480, height=854, scaledDensity=1.5, xdpi=160.421, ydpi=159.497}
313 | //DisplayMetrics{density=2.0, width=720, height=1280, scaledDensity=2.0, xdpi=160.42105, ydpi=160.15764}
314 | DisplayMetrics mDisplayMetrics = mResources.getDisplayMetrics();
315 | return mDisplayMetrics;
316 | }
317 |
318 | /**
319 | * 打开键盘.
320 | *
321 | * @param context the context
322 | */
323 | public static void showSoftInput(Context context) {
324 | InputMethodManager inputMethodManager = (InputMethodManager) context
325 | .getSystemService(Context.INPUT_METHOD_SERVICE);
326 | inputMethodManager.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS);
327 | }
328 |
329 | /**
330 | * 关闭键盘事件.
331 | *
332 | * @param context the context
333 | */
334 | public static void closeSoftInput(Context context) {
335 | InputMethodManager inputMethodManager = (InputMethodManager) context
336 | .getSystemService(Context.INPUT_METHOD_SERVICE);
337 | if (inputMethodManager != null && ((Activity) context).getCurrentFocus() != null) {
338 | inputMethodManager.hideSoftInputFromWindow(((Activity) context).getCurrentFocus()
339 | .getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
340 | }
341 | }
342 |
343 | /**
344 | * 获取包信息.
345 | *
346 | * @param context the context
347 | */
348 | public static PackageInfo getPackageInfo(Context context) {
349 | PackageInfo info = null;
350 | try {
351 | String packageName = context.getPackageName();
352 | info = context.getPackageManager().getPackageInfo(packageName, 0);
353 | } catch (Exception e) {
354 | e.printStackTrace();
355 | }
356 | return info;
357 | }
358 |
359 |
360 | }
361 |
--------------------------------------------------------------------------------
/app/src/main/java/lengyue/apkdv/golddemo/MainActivity.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2012 www.apkdv.com
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package lengyue.apkdv.golddemo;
17 |
18 | import android.app.Activity;
19 | import android.graphics.Color;
20 | import android.graphics.drawable.ColorDrawable;
21 | import android.media.MediaPlayer;
22 | import android.os.Bundle;
23 | import android.view.Gravity;
24 | import android.view.Menu;
25 | import android.view.MenuItem;
26 | import android.view.View;
27 | import android.widget.Button;
28 | import android.widget.FrameLayout;
29 | import android.widget.LinearLayout;
30 | import android.widget.PopupWindow;
31 | import android.widget.TextView;
32 |
33 | import lengyue.apkdv.golddemo.flake.FlakeView;
34 |
35 |
36 | public class MainActivity extends Activity {
37 | //金币掉落动画的主体动画
38 | private FlakeView flakeView;
39 | private Button btnAll, btnthree;
40 |
41 | @Override
42 | protected void onCreate(Bundle savedInstanceState) {
43 | super.onCreate(savedInstanceState);
44 | setContentView(R.layout.activity_main);
45 | flakeView = new FlakeView(this);
46 | btnAll = (Button) findViewById(R.id.btn_all_time);
47 | btnthree = (Button) findViewById(R.id.btn_amin);
48 | btnAll.setOnClickListener(new View.OnClickListener() {
49 | @Override
50 | public void onClick(View v) {
51 | showPopWindows(btnAll, "20", true);
52 | }
53 | });
54 | btnthree.setOnClickListener(new View.OnClickListener() {
55 | @Override
56 | public void onClick(View v) {
57 | showPopWindows(btnAll, "20", false);
58 | }
59 | });
60 |
61 | }
62 |
63 |
64 | @Override
65 | protected void onResume() {
66 | super.onResume();
67 | flakeView.resume();
68 | }
69 |
70 | @Override
71 | protected void onPause() {
72 | super.onPause();
73 | flakeView.pause();
74 | }
75 |
76 | @Override
77 | public boolean onCreateOptionsMenu(Menu menu) {
78 | // Inflate the menu; this adds items to the action bar if it is present.
79 | getMenuInflater().inflate(R.menu.menu_main, menu);
80 | return true;
81 | }
82 |
83 | @Override
84 | public boolean onOptionsItemSelected(MenuItem item) {
85 | // Handle action bar item clicks here. The action bar will
86 | // automatically handle clicks on the Home/Up button, so long
87 | // as you specify a parent activity in AndroidManifest.xml.
88 | int id = item.getItemId();
89 |
90 | //noinspection SimplifiableIfStatement
91 | if (id == R.id.action_settings) {
92 | return true;
93 | }
94 |
95 | return super.onOptionsItemSelected(item);
96 | }
97 |
98 | private PopupWindow pop;
99 |
100 | private PopupWindow showPopWindows(View v, String moneyStr, boolean show) {
101 | View view = this.getLayoutInflater().inflate(R.layout.view_login_reward, null);
102 | TextView tvTips = (TextView) view.findViewById(R.id.tv_tip);
103 | TextView money = (TextView) view.findViewById(R.id.tv_money);
104 | tvTips.setText("连续登陆3天,送您" + moneyStr + "个爱心币");
105 | money.setText(moneyStr);
106 | final LinearLayout container = (LinearLayout) view.findViewById(R.id.container);
107 | //将flakeView 添加到布局中
108 | container.addView(flakeView);
109 | //设置背景
110 | this.getWindow().setBackgroundDrawable(new ColorDrawable(Color.BLACK));
111 | //设置同时出现在屏幕上的金币数量 建议64以内 过多会引起卡顿
112 | flakeView.addFlakes(8);
113 | /**
114 | * 绘制的类型
115 | * @see View.LAYER_TYPE_HARDWARE
116 | * @see View.LAYER_TYPE_SOFTWARE
117 | * @see View.LAYER_TYPE_NONE
118 | */
119 | flakeView.setLayerType(View.LAYER_TYPE_NONE, null);
120 | view.findViewById(R.id.btn_ikow).setOnClickListener(new View.OnClickListener() {
121 | @Override
122 | public void onClick(View v) {
123 | if (container!=null){
124 | container.removeAllViews();
125 | }
126 | pop.dismiss();
127 | }
128 | });
129 | pop = new PopupWindow(view, FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT);
130 | ColorDrawable dw = new ColorDrawable(getResources().getColor(R.color.half_color));
131 | pop.setBackgroundDrawable(dw);
132 | pop.setOutsideTouchable(true);
133 | pop.setFocusable(true);
134 | pop.showAtLocation(v, Gravity.CENTER, 0, 0);
135 |
136 | /**
137 | * 移除动画
138 | */
139 | final Thread thread = new Thread(new Runnable() {
140 | @Override
141 | public void run() {
142 | try {
143 | //设置2秒后
144 | Thread.sleep(2000);
145 | runOnUiThread(new Runnable() {
146 | @Override
147 | public void run() {
148 | container.removeAllViews();
149 | }
150 | });
151 | } catch (InterruptedException e) {
152 | e.printStackTrace();
153 | }
154 |
155 | }
156 | });
157 | if (!show)
158 | thread.start();
159 | MediaPlayer player = MediaPlayer.create(this, R.raw.shake);
160 | player.start();
161 | return pop;
162 | }
163 | }
164 |
--------------------------------------------------------------------------------
/app/src/main/java/lengyue/apkdv/golddemo/flake/Flake.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2012 www.apkdv.com
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package lengyue.apkdv.golddemo.flake;
17 |
18 | import android.content.Context;
19 | import android.graphics.Bitmap;
20 | import android.util.DisplayMetrics;
21 |
22 | import java.util.HashMap;
23 |
24 | import lengyue.apkdv.golddemo.DvAppUtil;
25 |
26 | /**
27 | * This class represents a single Droidflake, with properties representing its
28 | * size, rotation, location, and speed.
29 | */
30 | public class Flake {
31 |
32 | // These are the unique properties of any flake: its size, rotation, speed,
33 | // location, and its underlying Bitmap object
34 | float x, y;
35 | float rotation;
36 | float speed;
37 | float rotationSpeed;
38 | int width, height;
39 | Bitmap bitmap;
40 |
41 | // This map stores pre-scaled bitmaps according to the width. No reason to create
42 | // new bitmaps for sizes we've already seen.
43 | static HashMap bitmapMap = new HashMap();
44 |
45 | /**
46 | * Creates a new droidflake in the given xRange and with the given bitmap. Parameters of
47 | * location, size, rotation, and speed are randomly determined.
48 | */
49 | static Flake createFlake(float xRange, Bitmap originalBitmap,Context Context) {
50 | Flake flake = new Flake();
51 | // Size each flake with a width between 5 and 55 and a proportional height
52 | DisplayMetrics metrics = DvAppUtil.getDisplayMetrics(Context);
53 | if (metrics.widthPixels >= 1080) {
54 | flake.width = (int) (5 + (float) Math.random() * 80);
55 | float hwRatio = originalBitmap.getHeight() / originalBitmap.getWidth();
56 | flake.height = (int) (flake.width * hwRatio + 60);
57 | } else {
58 | flake.width = (int) (5 + (float) Math.random() * 50);
59 | float hwRatio = originalBitmap.getHeight() / originalBitmap.getWidth();
60 | flake.height = (int) (flake.width * hwRatio + 40);
61 |
62 | }
63 | // Position the flake horizontally between the left and right of the range
64 | flake.x = (float) Math.random() * (xRange - flake.width);
65 | // Position the flake vertically slightly off the top of the display
66 | flake.y = 0 - (flake.height + (float) Math.random() * flake.height);
67 |
68 | // Each flake travels at 50-200 pixels per second
69 | flake.speed = 50 + (float) Math.random() * 150;
70 |
71 | // Flakes start at -90 to 90 degrees rotation, and rotate between -45 and 45
72 | // degrees per second
73 | flake.rotation = (float) Math.random() * 180 - 90;
74 | flake.rotationSpeed = (float) Math.random() * 90 - 45;
75 |
76 | // Get the cached bitmap for this size if it exists, otherwise create and cache one
77 | flake.bitmap = bitmapMap.get(flake.width);
78 | if (flake.bitmap == null) {
79 | flake.bitmap = Bitmap.createScaledBitmap(originalBitmap,
80 | (int) flake.width, (int) flake.height, true);
81 | bitmapMap.put(flake.width, flake.bitmap);
82 | }
83 | return flake;
84 | }
85 | }
86 |
--------------------------------------------------------------------------------
/app/src/main/java/lengyue/apkdv/golddemo/flake/FlakeView.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2012 www.apkdv.com
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package lengyue.apkdv.golddemo.flake;
17 |
18 | import android.animation.ValueAnimator;
19 | import android.content.Context;
20 | import android.graphics.Bitmap;
21 | import android.graphics.BitmapFactory;
22 | import android.graphics.Canvas;
23 | import android.graphics.Color;
24 | import android.graphics.Matrix;
25 | import android.graphics.Paint;
26 | import android.view.View;
27 |
28 | import java.util.ArrayList;
29 |
30 | import lengyue.apkdv.golddemo.R;
31 |
32 | /**
33 | * This class is the custom view where all of the Droidflakes are drawn. This class has
34 | * all of the logic for adding, subtracting, and rendering Droidflakes.
35 | */
36 | public class FlakeView extends View {
37 |
38 | Bitmap droid; // The bitmap that all flakes use
39 | int numFlakes = 0; // Current number of flakes
40 | ArrayList flakes = new ArrayList(); // List of current flakes
41 |
42 | // Animator used to drive all separate flake animations. Rather than have potentially
43 | // hundreds of separate animators, we just use one and then update all flakes for each
44 | // frame of that single animation.
45 | public ValueAnimator animator = ValueAnimator.ofFloat(0, 1);
46 | long startTime, prevTime; // Used to track elapsed time for animations and fps
47 | int frames = 0; // Used to track frames per second
48 | Paint textPaint; // Used for rendering fps text
49 | float fps = 0; // frames per second
50 | Matrix m = new Matrix(); // Matrix used to translate/rotate each flake during rendering
51 | String fpsString = "";
52 | String numFlakesString = "";
53 | /**
54 | * Constructor. Create objects used throughout the life of the View: the Paint and
55 | * the animator
56 | */
57 | public FlakeView(Context context) {
58 | super(context);
59 | droid = BitmapFactory.decodeResource(getResources(), R.drawable.b);
60 | textPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
61 | textPaint.setColor(Color.WHITE);
62 | textPaint.setTextSize(24);
63 |
64 | // This listener is where the action is for the flak animations. Every frame of the
65 | // animation, we calculate the elapsed time and update every flake's position and rotation
66 | // according to its speed.
67 | animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
68 | @Override
69 | public void onAnimationUpdate(ValueAnimator arg0) {
70 | long nowTime = System.currentTimeMillis();
71 | float secs = (float) (nowTime - prevTime) / 100f;
72 | prevTime = nowTime;
73 | for (int i = 0; i < numFlakes; ++i) {
74 | Flake flake = flakes.get(i);
75 | flake.y += (flake.speed * secs);
76 | if (flake.y > getHeight()) {
77 | // If a flake falls off the bottom, send it back to the top
78 | flake.y = 0 - flake.height;
79 | }
80 | flake.rotation = flake.rotation + (flake.rotationSpeed * secs);
81 | }
82 | // Force a redraw to see the flakes in their new positions and orientations
83 | invalidate();
84 | }
85 | });
86 | animator.setRepeatCount(ValueAnimator.INFINITE);
87 | animator.setDuration(3000);
88 | }
89 |
90 | int getNumFlakes() {
91 | return numFlakes;
92 | }
93 |
94 | private void setNumFlakes(int quantity) {
95 | numFlakes = quantity;
96 | numFlakesString = "numFlakes: " + numFlakes;
97 | }
98 |
99 | /**
100 | * Add the specified number of droidflakes.
101 | */
102 | public void addFlakes(int quantity) {
103 | for (int i = 0; i < quantity; ++i) {
104 | flakes.add(Flake.createFlake(getWidth(), droid,getContext()));
105 | }
106 | setNumFlakes(numFlakes + quantity);
107 | }
108 |
109 | /**
110 | * Subtract the specified number of droidflakes. We just take them off the end of the
111 | * list, leaving the others unchanged.
112 | */
113 | void subtractFlakes(int quantity) {
114 | for (int i = 0; i < quantity; ++i) {
115 | int index = numFlakes - i - 1;
116 | flakes.remove(index);
117 | }
118 | setNumFlakes(numFlakes - quantity);
119 | }
120 |
121 | @Override
122 | protected void onSizeChanged(int w, int h, int oldw, int oldh) {
123 | super.onSizeChanged(w, h, oldw, oldh);
124 | // Reset list of droidflakes, then restart it with 8 flakes
125 | flakes.clear();
126 | numFlakes = 0;
127 | addFlakes(16);
128 | // Cancel animator in case it was already running
129 | animator.cancel();
130 | // Set up fps tracking and start the animation
131 | startTime = System.currentTimeMillis();
132 | prevTime = startTime;
133 | frames = 0;
134 | animator.start();
135 | }
136 |
137 | @Override
138 | protected void onDraw(Canvas canvas) {
139 | super.onDraw(canvas);
140 |
141 | // For each flake: back-translate by half its size (this allows it to rotate around its center),
142 | // rotate by its current rotation, translate by its location, then draw its bitmap
143 | for (int i = 0; i < numFlakes; ++i) {
144 | Flake flake = flakes.get(i);
145 | m.setTranslate(-flake.width / 2, -flake.height / 2);
146 | m.postRotate(flake.rotation);
147 | m.postTranslate(flake.width / 2 + flake.x, flake.height / 2 + flake.y);
148 | canvas.drawBitmap(flake.bitmap, m, null);
149 | }
150 | // fps counter: count how many frames we draw and once a second calculate the
151 | // frames per second
152 | ++frames;
153 | long nowTime = System.currentTimeMillis();
154 | long deltaTime = nowTime - startTime;
155 | if (deltaTime > 1000) {
156 | float secs = (float) deltaTime / 1000f;
157 | fps = (float) frames / secs;
158 | // fpsString = "fps: " + fps;
159 | startTime = nowTime;
160 | frames = 0;
161 | }
162 | // canvas.drawText(numFlakesString, getWidth() - 200, getHeight() - 50, textPaint);
163 | // canvas.drawText(fpsString, getWidth() - 200, getHeight() - 80, textPaint);
164 | }
165 |
166 | public void pause() {
167 | // Make sure the animator's not spinning in the background when the activity is paused.
168 | animator.cancel();
169 | }
170 |
171 | public void resume() {
172 | animator.start();
173 | }
174 |
175 | }
176 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/appdev/GoldDemo/52708086f3387a5afd1de42edb98e2dfe3fecb5d/app/src/main/res/drawable-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/reward_care.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/appdev/GoldDemo/52708086f3387a5afd1de42edb98e2dfe3fecb5d/app/src/main/res/drawable-hdpi/reward_care.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/reward_money.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/appdev/GoldDemo/52708086f3387a5afd1de42edb98e2dfe3fecb5d/app/src/main/res/drawable-hdpi/reward_money.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/appdev/GoldDemo/52708086f3387a5afd1de42edb98e2dfe3fecb5d/app/src/main/res/drawable-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/appdev/GoldDemo/52708086f3387a5afd1de42edb98e2dfe3fecb5d/app/src/main/res/drawable-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/reward.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/appdev/GoldDemo/52708086f3387a5afd1de42edb98e2dfe3fecb5d/app/src/main/res/drawable-xhdpi/reward.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/reward_care.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/appdev/GoldDemo/52708086f3387a5afd1de42edb98e2dfe3fecb5d/app/src/main/res/drawable-xhdpi/reward_care.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/reward_money.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/appdev/GoldDemo/52708086f3387a5afd1de42edb98e2dfe3fecb5d/app/src/main/res/drawable-xhdpi/reward_money.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/appdev/GoldDemo/52708086f3387a5afd1de42edb98e2dfe3fecb5d/app/src/main/res/drawable-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/reward.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/appdev/GoldDemo/52708086f3387a5afd1de42edb98e2dfe3fecb5d/app/src/main/res/drawable-xxhdpi/reward.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/b.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/appdev/GoldDemo/52708086f3387a5afd1de42edb98e2dfe3fecb5d/app/src/main/res/drawable/b.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/shape_white_no_stroke.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
19 |
20 |
21 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/view_login_reward.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
16 |
17 |
22 |
23 |
30 |
31 |
41 |
42 |
48 |
49 |
55 |
56 |
66 |
67 |
68 |
80 |
81 |
82 |
83 |
88 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/menu_main.xml:
--------------------------------------------------------------------------------
1 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/raw/shake.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/appdev/GoldDemo/52708086f3387a5afd1de42edb98e2dfe3fecb5d/app/src/main/res/raw/shake.mp3
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/color.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #30000000
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | GoldDemo
3 |
4 | Hello world!
5 | Settings
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/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:1.1.0'
9 |
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 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m
13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
14 |
15 | # When configured, Gradle will run in incubating parallel mode.
16 | # This option should only be used with decoupled projects. More details, visit
17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18 | # org.gradle.parallel=true
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/appdev/GoldDemo/52708086f3387a5afd1de42edb98e2dfe3fecb5d/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Wed Apr 10 15:27:10 PDT 2013
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-2.2.1-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 | # For Cygwin, ensure paths are in UNIX format before anything is touched.
46 | if $cygwin ; then
47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
48 | fi
49 |
50 | # Attempt to set APP_HOME
51 | # Resolve links: $0 may be a link
52 | PRG="$0"
53 | # Need this for relative symlinks.
54 | while [ -h "$PRG" ] ; do
55 | ls=`ls -ld "$PRG"`
56 | link=`expr "$ls" : '.*-> \(.*\)$'`
57 | if expr "$link" : '/.*' > /dev/null; then
58 | PRG="$link"
59 | else
60 | PRG=`dirname "$PRG"`"/$link"
61 | fi
62 | done
63 | SAVED="`pwd`"
64 | cd "`dirname \"$PRG\"`/" >&-
65 | APP_HOME="`pwd -P`"
66 | cd "$SAVED" >&-
67 |
68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
69 |
70 | # Determine the Java command to use to start the JVM.
71 | if [ -n "$JAVA_HOME" ] ; then
72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
73 | # IBM's JDK on AIX uses strange locations for the executables
74 | JAVACMD="$JAVA_HOME/jre/sh/java"
75 | else
76 | JAVACMD="$JAVA_HOME/bin/java"
77 | fi
78 | if [ ! -x "$JAVACMD" ] ; then
79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
80 |
81 | Please set the JAVA_HOME variable in your environment to match the
82 | location of your Java installation."
83 | fi
84 | else
85 | JAVACMD="java"
86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
87 |
88 | Please set the JAVA_HOME variable in your environment to match the
89 | location of your Java installation."
90 | fi
91 |
92 | # Increase the maximum file descriptors if we can.
93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
94 | MAX_FD_LIMIT=`ulimit -H -n`
95 | if [ $? -eq 0 ] ; then
96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
97 | MAX_FD="$MAX_FD_LIMIT"
98 | fi
99 | ulimit -n $MAX_FD
100 | if [ $? -ne 0 ] ; then
101 | warn "Could not set maximum file descriptor limit: $MAX_FD"
102 | fi
103 | else
104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
105 | fi
106 | fi
107 |
108 | # For Darwin, add options to specify how the application appears in the dock
109 | if $darwin; then
110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
111 | fi
112 |
113 | # For Cygwin, switch paths to Windows format before running java
114 | if $cygwin ; then
115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
158 | function splitJvmOpts() {
159 | JVM_OPTS=("$@")
160 | }
161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
163 |
164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
165 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/screenshot/1429682514132.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/appdev/GoldDemo/52708086f3387a5afd1de42edb98e2dfe3fecb5d/screenshot/1429682514132.gif
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------