nums = new ArrayList<>();
55 | Pattern pattern = Pattern.compile("\\D+"); //非数字
56 | Matcher matcher = pattern.matcher(string);
57 | while (matcher.find()) {
58 | nums.add(matcher.group(0));
59 | }
60 | return nums;
61 |
62 | }
63 |
64 | }
65 |
--------------------------------------------------------------------------------
/baselib/src/main/java/com/brioal/baselib/util/EncodeUtil.java:
--------------------------------------------------------------------------------
1 | package com.brioal.baselib.util;
2 |
3 | import java.math.BigInteger;
4 | import java.security.MessageDigest;
5 |
6 | /**
7 | * 加密工具类
8 | *
9 | * 1.MD5加密
10 | * 2.SHA加密
11 | * Created by Brioal on 2016/8/1.
12 | */
13 |
14 | public class EncodeUtil {
15 |
16 |
17 | //MD5加密
18 | public static String encryptMD5(String data) throws Exception {
19 | MessageDigest md5 = MessageDigest.getInstance("MD5");
20 | return new BigInteger(md5.digest(data.getBytes())).toString(16);
21 | }
22 |
23 | //SHA加密
24 | public static String encryptSHA(String data) throws Exception {
25 | MessageDigest sha = MessageDigest.getInstance("SHA");
26 | return new BigInteger(sha.digest(data.getBytes())).toString(32);
27 | }
28 |
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/baselib/src/main/java/com/brioal/baselib/util/FontManager.java:
--------------------------------------------------------------------------------
1 | package com.brioal.baselib.util;
2 |
3 | import android.content.Context;
4 | import android.graphics.Typeface;
5 | import android.view.View;
6 | import android.view.ViewGroup;
7 | import android.widget.Button;
8 | import android.widget.EditText;
9 | import android.widget.TextView;
10 |
11 | /**字体管理类
12 | * Created by Brioal on 2016/6/3.
13 | */
14 |
15 | public class FontManager {
16 | //设置指定ViewGroup下的所有字体
17 | public static void changeFonts(ViewGroup root, Context context) {
18 | Typeface tf = Typeface.createFromAsset(context.getAssets(), "font.ttf");
19 | for (int i = 0; i < root.getChildCount(); i++) {
20 | View v = root.getChildAt(i);
21 | if (v instanceof TextView) {
22 | ((TextView) v).setTypeface(tf);
23 | } else if (v instanceof Button) {
24 | ((Button) v).setTypeface(tf);
25 | } else if (v instanceof EditText) {
26 | ((EditText) v).setTypeface(tf);
27 | } else if (v instanceof ViewGroup) {
28 | changeFonts((ViewGroup) v, context);
29 | }
30 | }
31 | }
32 | //设置指定View的字体
33 | public static void changeFonts(View root, Context context) {
34 | Typeface tf = Typeface.createFromAsset(context.getAssets(), "font.ttf");
35 | if (root instanceof TextView) {
36 | ((TextView) root).setTypeface(tf);
37 | } else if (root instanceof Button) {
38 | ((Button) root).setTypeface(tf);
39 | } else if (root instanceof EditText) {
40 | ((EditText) root).setTypeface(tf);
41 | } else if (root instanceof ViewGroup) {
42 | changeFonts((ViewGroup) root, context);
43 | }
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/baselib/src/main/java/com/brioal/baselib/util/NetWorkUtil.java:
--------------------------------------------------------------------------------
1 | package com.brioal.baselib.util;
2 |
3 | import android.app.Activity;
4 | import android.content.ComponentName;
5 | import android.content.Context;
6 | import android.content.Intent;
7 | import android.net.ConnectivityManager;
8 | import android.net.NetworkInfo;
9 |
10 | /**
11 | * 网络状态判断类
12 | */
13 | public class NetWorkUtil {
14 | //判断网络是否可用
15 | public static boolean isNetworkConnected(Context context) {
16 | ConnectivityManager connectivityManager
17 | = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
18 | NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
19 | return activeNetworkInfo != null && activeNetworkInfo.isConnected();
20 | }
21 |
22 | //判断是否是wifi
23 | public static boolean isWifi(Context context) {
24 | ConnectivityManager cm = (ConnectivityManager) context
25 | .getSystemService(Context.CONNECTIVITY_SERVICE);
26 | if (cm == null)
27 | return false;
28 | return cm.getActiveNetworkInfo().getType() == ConnectivityManager.TYPE_WIFI;
29 |
30 | }
31 | //打开网络设置界面
32 | public static void openSetting(Activity activity) {
33 | Intent intent = new Intent("/");
34 | ComponentName cm = new ComponentName("com.android.settings",
35 | "com.android.settings.WirelessSettings");
36 | intent.setComponent(cm);
37 | intent.setAction("android.intent.action.VIEW");
38 | activity.startActivityForResult(intent, 0);
39 | }
40 | }
--------------------------------------------------------------------------------
/baselib/src/main/java/com/brioal/baselib/util/RegularUtils.java:
--------------------------------------------------------------------------------
1 | package com.brioal.baselib.util;
2 |
3 | import android.text.TextUtils;
4 |
5 | import java.util.regex.Pattern;
6 |
7 | /**
8 | * 正则表达式工具类
9 | * Created by Brioal on 2016/8/1.
10 | */
11 |
12 | public class RegularUtils {
13 | //验证手机号
14 | private static final String REGEX_MOBILE = "^(13[0-9]|14[5|7]|15[0|1|2|3|5|6|7|8|9]|18[0|1|2|3|5|6|7|8|9])\\d{8}$";
15 | //验证座机号,正确格式:xxx/xxxx-xxxxxxx/xxxxxxxx
16 | private static final String REGEX_TEL = "^0\\d{2,3}[- ]?\\d{7,8}";
17 | //验证邮箱
18 | private static final String REGEX_EMAIL = "^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$";
19 | //验证url
20 | private static final String REGEX_URL = "http(s)?://([\\w-]+\\.)+[\\w-]+(/[\\w-./?%&=]*)?";
21 | //验证汉字
22 | private static final String REGEX_CHZ = "^[\\u4e00-\\u9fa5]+$";
23 | //验证用户名,取值范围为a-z,A-Z,0-9,"_",汉字,不能以"_"结尾,用户名必须是6-20位
24 | private static final String REGEX_USERNAME = "^[\\w\\u4e00-\\u9fa5]{6,20}(? 0) {
76 | result = context.getResources().getDimensionPixelSize(resourceId);
77 | }
78 | return result;
79 | }
80 |
81 | //获取状态栏高度+标题栏(ActionBar)高度
82 | public static int getTopBarHeight(Activity activity) {
83 | return activity.getWindow().findViewById(Window.ID_ANDROID_CONTENT).getTop();
84 | }
85 |
86 |
87 | }
88 |
--------------------------------------------------------------------------------
/baselib/src/main/java/com/brioal/baselib/util/SoftInputUtil.java:
--------------------------------------------------------------------------------
1 | package com.brioal.baselib.util;
2 |
3 | import android.app.Activity;
4 | import android.content.Context;
5 | import android.view.View;
6 | import android.view.inputmethod.InputMethodManager;
7 | import android.widget.EditText;
8 |
9 | import static android.content.Context.INPUT_METHOD_SERVICE;
10 |
11 | /**
12 | * 软键盘管理类
13 | *
14 | *
15 | * 1.避免输入法面板遮挡
16 | * 2.动态隐藏软键盘
17 | * 3.改变软键盘的状态,弹出时隐藏,隐藏时弹出
18 | * 4.动态隐藏软键盘
19 | * 5.动态显示软键盘
20 | * Created by Brioal on 2016/6/6.
21 | */
22 | public class SoftInputUtil {
23 | // 在manifest.xml中activity中设置
24 | //android:windowSoftInputMode="stateVisible|adjustResize"
25 |
26 | //改变软键盘的状态,弹出时隐藏,隐藏时弹出
27 | public static void judgeSoftInut(Context context) {
28 | InputMethodManager imm = (InputMethodManager) context.getSystemService(INPUT_METHOD_SERVICE);
29 | imm.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS);
30 | }
31 |
32 | //动态隐藏软键盘
33 | public static void hideSoftInput(Activity activity) {
34 | View view = activity.getWindow().peekDecorView();
35 | if (view != null) {
36 | InputMethodManager inputmanger = (InputMethodManager) activity
37 | .getSystemService(INPUT_METHOD_SERVICE);
38 | inputmanger.hideSoftInputFromWindow(view.getWindowToken(), 0);
39 | }
40 | }
41 |
42 | //动态隐藏软键盘
43 | public static void hideSoftInput(Context context, EditText edit) {
44 | edit.clearFocus();
45 | InputMethodManager inputmanger = (InputMethodManager) context
46 | .getSystemService(INPUT_METHOD_SERVICE);
47 | inputmanger.hideSoftInputFromWindow(edit.getWindowToken(), 0);
48 | }
49 | //动态显示软键盘
50 | public static void showSoftInput(Context context, EditText edit) {
51 | edit.setFocusable(true);
52 | edit.setFocusableInTouchMode(true);
53 | edit.requestFocus();
54 | InputMethodManager inputManager = (InputMethodManager) context
55 | .getSystemService(Context.INPUT_METHOD_SERVICE);
56 | inputManager.showSoftInput(edit, 0);
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/baselib/src/main/java/com/brioal/baselib/util/ThemeUtil.java:
--------------------------------------------------------------------------------
1 | package com.brioal.baselib.util;
2 |
3 | import android.content.Context;
4 | import android.content.SharedPreferences;
5 |
6 | /**
7 | * 从本地读取颜色属性
8 | * Created by Brioal on 2016/5/20.
9 | */
10 |
11 | public class ThemeUtil {
12 | //保存颜色属性到本地
13 | public static void saveThemeColor(Context context, String color) {
14 | SharedPreferences preferences = context.getSharedPreferences("Brioal", Context.MODE_PRIVATE);
15 | SharedPreferences.Editor editor = preferences.edit();
16 | editor.putString("ThemeColor", color);
17 | editor.commit();
18 | }
19 |
20 | //从本地读取颜色属性
21 | public static String readThemeColor(Context context) {
22 | SharedPreferences preferences = context.getSharedPreferences("Brioal", Context.MODE_PRIVATE);
23 | return preferences.getString("ThemeColor", "#3eb6d1");
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/baselib/src/main/java/com/brioal/baselib/util/ToastUtils.java:
--------------------------------------------------------------------------------
1 | package com.brioal.baselib.util;
2 |
3 | import android.content.Context;
4 |
5 | import static android.R.id.message;
6 |
7 | /**
8 | * 吐司显示类.
9 | */
10 | public class ToastUtils {
11 | public static ExtraToast mToast;
12 |
13 |
14 | public static void showToast(Context context, String message) {
15 | showToast(context, message, ExtraToast.LENGTH_SHORT);
16 | }
17 |
18 | //显示字符串
19 | public static void showToast(final Context context, final String message, int duration) {
20 | if (mToast == null) {
21 | mToast = ExtraToast.makeText(context, message, duration);
22 | } else {
23 | mToast.setText(message);
24 | }
25 | mToast.show();
26 | }
27 |
28 | //显示资源文件
29 | public static void showToast(final Context context, final int messageResId, int duration) {
30 | if (mToast == null) {
31 | mToast = ExtraToast.makeText(context, messageResId, duration);
32 | } else {
33 | mToast.setText(message);
34 | }
35 | mToast.show();
36 | }
37 |
38 | //隐藏吐司
39 | public static void hideToast() {
40 | if (mToast == null) {
41 | return;
42 | }
43 | mToast.hide();
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/baselib/src/main/java/com/brioal/baselib/util/klog/BaseLog.java:
--------------------------------------------------------------------------------
1 | package com.brioal.baselib.util.klog;
2 |
3 | import android.util.Log;
4 |
5 | /**
6 | * Created by zhaokaiqiang on 15/11/18.
7 | */
8 | public class BaseLog {
9 |
10 | public static void printDefault(int type, String tag, String msg) {
11 |
12 | int index = 0;
13 | int maxLength = 4000;
14 | int countOfSub = msg.length() / maxLength;
15 |
16 | if (countOfSub > 0) {
17 | for (int i = 0; i < countOfSub; i++) {
18 | String sub = msg.substring(index, index + maxLength);
19 | printSub(type, tag, sub);
20 | index += maxLength;
21 | }
22 | printSub(type, tag, msg.substring(index, msg.length()));
23 | } else {
24 | printSub(type, tag, msg);
25 | }
26 | }
27 |
28 | private static void printSub(int type, String tag, String sub) {
29 | switch (type) {
30 | case KLog.V:
31 | Log.v(tag, sub);
32 | break;
33 | case KLog.D:
34 | Log.d(tag, sub);
35 | break;
36 | case KLog.I:
37 | Log.i(tag, sub);
38 | break;
39 | case KLog.W:
40 | Log.w(tag, sub);
41 | break;
42 | case KLog.E:
43 | Log.e(tag, sub);
44 | break;
45 | case KLog.A:
46 | Log.wtf(tag, sub);
47 | break;
48 | }
49 | }
50 |
51 | }
52 |
--------------------------------------------------------------------------------
/baselib/src/main/java/com/brioal/baselib/util/klog/FileLog.java:
--------------------------------------------------------------------------------
1 | package com.brioal.baselib.util.klog;
2 |
3 | import android.util.Log;
4 |
5 | import java.io.BufferedWriter;
6 | import java.io.File;
7 | import java.io.FileNotFoundException;
8 | import java.io.FileWriter;
9 | import java.io.IOException;
10 | import java.io.UnsupportedEncodingException;
11 | import java.util.Random;
12 |
13 | /**写入日志文件
14 | * Created by zhaokaiqiang on 15/11/18.
15 | */
16 | public class FileLog {
17 |
18 | public static void printFile(String tag, File targetDirectory, String fileName, String headString, String msg) {
19 |
20 | fileName = (fileName == null) ? getFileName() : fileName;
21 | if (save(targetDirectory, fileName, msg)) {
22 | Log.d(tag, headString + " save log success ! location is >>>" + targetDirectory.getAbsolutePath() + "/" + fileName);
23 | } else {
24 | Log.e(tag, headString + "save log fails !");
25 | }
26 | }
27 |
28 | private static boolean save(File dic, String fileName, String msg) {
29 | File file = new File(dic, fileName);
30 | try {
31 | FileWriter fr = new FileWriter(file, true);
32 | BufferedWriter writer = new BufferedWriter(fr);
33 | writer.append(msg + "\n");
34 | writer.flush();
35 | writer.close();
36 | } catch (FileNotFoundException e) {
37 | e.printStackTrace();
38 | return false;
39 | } catch (UnsupportedEncodingException e) {
40 | e.printStackTrace();
41 | return false;
42 | } catch (IOException e) {
43 | e.printStackTrace();
44 | return false;
45 | } catch (Exception e) {
46 | e.printStackTrace();
47 | return false;
48 | }
49 |
50 | return true;
51 | }
52 |
53 | private static String getFileName() {
54 | Random random = new Random();
55 | return "KLog_" + Long.toString(System.currentTimeMillis() + random.nextInt(10000)).substring(4) + ".txt";
56 | }
57 |
58 | }
59 |
--------------------------------------------------------------------------------
/baselib/src/main/java/com/brioal/baselib/util/klog/JsonLog.java:
--------------------------------------------------------------------------------
1 | package com.brioal.baselib.util.klog;
2 |
3 | import android.util.Log;
4 |
5 | import org.json.JSONArray;
6 | import org.json.JSONException;
7 | import org.json.JSONObject;
8 |
9 | /**
10 | * Created by zhaokaiqiang on 15/11/18.
11 | */
12 | public class JsonLog {
13 |
14 | public static void printJson(String tag, String msg, String headString) {
15 |
16 | String message;
17 |
18 | try {
19 | if (msg.startsWith("{")) {
20 | JSONObject jsonObject = new JSONObject(msg);
21 | message = jsonObject.toString(KLog.JSON_INDENT);
22 | } else if (msg.startsWith("[")) {
23 | JSONArray jsonArray = new JSONArray(msg);
24 | message = jsonArray.toString(KLog.JSON_INDENT);
25 | } else {
26 | message = msg;
27 | }
28 | } catch (JSONException e) {
29 | message = msg;
30 | }
31 |
32 | Util.printLine(tag, true);
33 | message = headString + KLog.LINE_SEPARATOR + message;
34 | String[] lines = message.split(KLog.LINE_SEPARATOR);
35 | for (String line : lines) {
36 | Log.d(tag, "║ " + line);
37 | }
38 | Util.printLine(tag, false);
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/baselib/src/main/java/com/brioal/baselib/util/klog/Util.java:
--------------------------------------------------------------------------------
1 | package com.brioal.baselib.util.klog;
2 |
3 | import android.text.TextUtils;
4 | import android.util.Log;
5 |
6 | /**
7 | * Created by zhaokaiqiang on 15/12/11.
8 | */
9 | public class Util {
10 |
11 | public static boolean isEmpty(String line) {
12 | return TextUtils.isEmpty(line) || line.equals("\n") || line.equals("\t") || TextUtils.isEmpty(line.trim());
13 | }
14 |
15 | public static void printLine(String tag, boolean isTop) {
16 | if (isTop) {
17 | Log.d(tag, "╔═══════════════════════════════════════════════════════════════════════════════════════");
18 | } else {
19 | Log.d(tag, "╚═══════════════════════════════════════════════════════════════════════════════════════");
20 | }
21 | }
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/baselib/src/main/java/com/brioal/baselib/util/klog/XmlLog.java:
--------------------------------------------------------------------------------
1 | package com.brioal.baselib.util.klog;
2 |
3 | import android.util.Log;
4 |
5 | import java.io.StringReader;
6 | import java.io.StringWriter;
7 |
8 | import javax.xml.transform.OutputKeys;
9 | import javax.xml.transform.Source;
10 | import javax.xml.transform.Transformer;
11 | import javax.xml.transform.TransformerFactory;
12 | import javax.xml.transform.stream.StreamResult;
13 | import javax.xml.transform.stream.StreamSource;
14 |
15 | /**
16 | * Created by zhaokaiqiang on 15/11/18.
17 | */
18 | public class XmlLog {
19 |
20 | public static void printXml(String tag, String xml, String headString) {
21 |
22 | if (xml != null) {
23 | xml = XmlLog.formatXML(xml);
24 | xml = headString + "\n" + xml;
25 | } else {
26 | xml = headString + KLog.NULL_TIPS;
27 | }
28 |
29 | Util.printLine(tag, true);
30 | String[] lines = xml.split(KLog.LINE_SEPARATOR);
31 | for (String line : lines) {
32 | if (!Util.isEmpty(line)) {
33 | Log.d(tag, "║ " + line);
34 | }
35 | }
36 | Util.printLine(tag, false);
37 | }
38 |
39 | public static String formatXML(String inputXML) {
40 | try {
41 | Source xmlInput = new StreamSource(new StringReader(inputXML));
42 | StreamResult xmlOutput = new StreamResult(new StringWriter());
43 | Transformer transformer = TransformerFactory.newInstance().newTransformer();
44 | transformer.setOutputProperty(OutputKeys.INDENT, "yes");
45 | transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
46 | transformer.transform(xmlInput, xmlOutput);
47 | return xmlOutput.getWriter().toString().replaceFirst(">", ">\n");
48 | } catch (Exception e) {
49 | e.printStackTrace();
50 | return inputXML;
51 | }
52 | }
53 |
54 | }
55 |
--------------------------------------------------------------------------------
/baselib/src/main/res/drawable/item_conver_white_bg.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/baselib/src/main/res/layout/swipeback_layout.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
--------------------------------------------------------------------------------
/baselib/src/main/res/mipmap/shadow_bottom.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Brioal/LibManager/e8a295a76bc3008ea8887597a7602c3014f6d263/baselib/src/main/res/mipmap/shadow_bottom.png
--------------------------------------------------------------------------------
/baselib/src/main/res/mipmap/shadow_left.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Brioal/LibManager/e8a295a76bc3008ea8887597a7602c3014f6d263/baselib/src/main/res/mipmap/shadow_left.png
--------------------------------------------------------------------------------
/baselib/src/main/res/mipmap/shadow_right.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Brioal/LibManager/e8a295a76bc3008ea8887597a7602c3014f6d263/baselib/src/main/res/mipmap/shadow_right.png
--------------------------------------------------------------------------------
/baselib/src/main/res/values/attrs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/baselib/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3eb6d1
4 | #3eb6d1
5 | #FF4081
6 | #ffffff
7 | #000000
8 | #3eb6d1
9 | #f4f4f4
10 | #303030
11 | #ffdedede
12 | #ff0099cc
13 | #ff00719b
14 | #ffff4444
15 | #ffcd3a3a
16 | #ff99cc00
17 | #ff6d9b00
18 | @android:color/white
19 |
20 |
--------------------------------------------------------------------------------
/baselib/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | BaseLib
3 |
4 |
--------------------------------------------------------------------------------
/baselib/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
16 |
17 |
21 |
22 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/baselib/src/test/java/com/brioal/baselib/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.brioal.baselib;
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.2.0-alpha6'
9 | // NOTE: Do not place your application dependencies here; they belong
10 | // in the individual module build.gradle files
11 | }
12 | }
13 |
14 | allprojects {
15 | repositories {
16 | jcenter()
17 | }
18 | }
19 |
20 | task clean(type: Delete) {
21 | delete rootProject.buildDir
22 | }
23 |
--------------------------------------------------------------------------------
/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 | org.gradle.jvmargs=-Xmx1536m
13 |
14 | # When configured, Gradle will run in incubating parallel mode.
15 | # This option should only be used with decoupled projects. More details, visit
16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
17 | # org.gradle.parallel=true
18 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Brioal/LibManager/e8a295a76bc3008ea8887597a7602c3014f6d263/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Mon Dec 28 10:00:20 PST 2015
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.10-all.zip
7 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/netlib/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/netlib/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | //网络请求类
3 | //Bmob后台操作类
4 | //Glide操作类
5 | android {
6 | compileSdkVersion 24
7 | buildToolsVersion "24.0.1"
8 | sourceSets {
9 | main.jniLibs.srcDirs = ['libs']
10 | }
11 | defaultConfig {
12 | minSdkVersion 21
13 | targetSdkVersion 24
14 | versionCode 1
15 | versionName "1.0"
16 |
17 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
18 |
19 | }
20 | buildTypes {
21 | release {
22 | minifyEnabled false
23 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
24 | }
25 | }
26 | }
27 |
28 | dependencies {
29 | compile fileTree(include: ['*.jar'], dir: 'libs')
30 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
31 | exclude group: 'com.android.support', module: 'support-annotations'
32 | })
33 | compile 'com.android.support:appcompat-v7:24.1.1'
34 | testCompile 'junit:junit:4.12'
35 | compile files('libs/Bmob_Push_V0.9beta_20160520.jar')
36 | compile files('libs/BmobSDK_V3.4.7_0527.jar')
37 | compile files('libs/glide-3.5.1.jar')
38 | compile files('libs/jsoup-1.9.1.jar')
39 | compile files('libs/okhttp-3.2.0.jar')
40 | compile files('libs/okio-1.7.0.jar')
41 | compile files('libs/umeng_social_sdk.jar')
42 | compile 'com.squareup.retrofit2:retrofit:2.1.0'
43 | }
44 |
--------------------------------------------------------------------------------
/netlib/libs/BmobSDK_V3.4.7_0527.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Brioal/LibManager/e8a295a76bc3008ea8887597a7602c3014f6d263/netlib/libs/BmobSDK_V3.4.7_0527.jar
--------------------------------------------------------------------------------
/netlib/libs/Bmob_Push_V0.9beta_20160520.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Brioal/LibManager/e8a295a76bc3008ea8887597a7602c3014f6d263/netlib/libs/Bmob_Push_V0.9beta_20160520.jar
--------------------------------------------------------------------------------
/netlib/libs/arm64-v8a/libbmob.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Brioal/LibManager/e8a295a76bc3008ea8887597a7602c3014f6d263/netlib/libs/arm64-v8a/libbmob.so
--------------------------------------------------------------------------------
/netlib/libs/armeabi-v7a/libbmob.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Brioal/LibManager/e8a295a76bc3008ea8887597a7602c3014f6d263/netlib/libs/armeabi-v7a/libbmob.so
--------------------------------------------------------------------------------
/netlib/libs/armeabi/libbmob.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Brioal/LibManager/e8a295a76bc3008ea8887597a7602c3014f6d263/netlib/libs/armeabi/libbmob.so
--------------------------------------------------------------------------------
/netlib/libs/glide-3.5.1.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Brioal/LibManager/e8a295a76bc3008ea8887597a7602c3014f6d263/netlib/libs/glide-3.5.1.jar
--------------------------------------------------------------------------------
/netlib/libs/jsoup-1.9.1.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Brioal/LibManager/e8a295a76bc3008ea8887597a7602c3014f6d263/netlib/libs/jsoup-1.9.1.jar
--------------------------------------------------------------------------------
/netlib/libs/mips/libbmob.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Brioal/LibManager/e8a295a76bc3008ea8887597a7602c3014f6d263/netlib/libs/mips/libbmob.so
--------------------------------------------------------------------------------
/netlib/libs/mips64/libbmob.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Brioal/LibManager/e8a295a76bc3008ea8887597a7602c3014f6d263/netlib/libs/mips64/libbmob.so
--------------------------------------------------------------------------------
/netlib/libs/okhttp-3.2.0.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Brioal/LibManager/e8a295a76bc3008ea8887597a7602c3014f6d263/netlib/libs/okhttp-3.2.0.jar
--------------------------------------------------------------------------------
/netlib/libs/okio-1.7.0.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Brioal/LibManager/e8a295a76bc3008ea8887597a7602c3014f6d263/netlib/libs/okio-1.7.0.jar
--------------------------------------------------------------------------------
/netlib/libs/umeng_social_sdk.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Brioal/LibManager/e8a295a76bc3008ea8887597a7602c3014f6d263/netlib/libs/umeng_social_sdk.jar
--------------------------------------------------------------------------------
/netlib/libs/x86/libbmob.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Brioal/LibManager/e8a295a76bc3008ea8887597a7602c3014f6d263/netlib/libs/x86/libbmob.so
--------------------------------------------------------------------------------
/netlib/libs/x86_64/libbmob.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Brioal/LibManager/e8a295a76bc3008ea8887597a7602c3014f6d263/netlib/libs/x86_64/libbmob.so
--------------------------------------------------------------------------------
/netlib/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 A:\Android\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 |
--------------------------------------------------------------------------------
/netlib/src/androidTest/java/com/example/netlib/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.example.netlib;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumentation test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.example.netlib.test", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/netlib/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/netlib/src/main/java/com/brioal/netlib/DataQuery.java:
--------------------------------------------------------------------------------
1 | package com.brioal.netlib;
2 |
3 | import android.content.Context;
4 |
5 | import java.util.ArrayList;
6 | import java.util.List;
7 |
8 | import cn.bmob.v3.BmobQuery;
9 | import cn.bmob.v3.listener.FindListener;
10 | import cn.bmob.v3.listener.GetListener;
11 |
12 |
13 | /**数据查询类
14 | * Created by Brioal on 2016/6/4.
15 | */
16 |
17 | public class DataQuery {
18 | private final int TYPE_EQUAL = 0; //query.addWhereEqualTo()
19 | private final int TYPE_CONTAIN = 1; //query.addWhereContains()
20 | private final String TAG = "DataQueryInfo";
21 |
22 | /*
23 | 查询多个数据
24 |
25 | 条目限制 ,
26 | 跳过的数量,
27 | 排序规则 ,
28 | 添加条件的类别 ,
29 | 条件的键,
30 | 条件的值,
31 | 监听器
32 | * */
33 | public void getDatas(Context context, int queryLimit, int skipCount, String order, int conditionType, String conditionKey, Object conditionValue, FindListener listener) {
34 | List t = new ArrayList<>();
35 | BmobQuery query = new BmobQuery<>();
36 | query.setLimit(queryLimit); //设置查询的数据条目
37 | query.setSkip(skipCount); //跳过的条目
38 | query.order(order); //设置排序方式
39 | if (conditionType != -1) {
40 | switch (conditionType) { //设置查询条件
41 | case 0:
42 | query.addWhereEqualTo(conditionKey, conditionValue);
43 | break;
44 | case 1:
45 | query.addWhereContains(conditionKey, (String) conditionValue);
46 | break;
47 | // TODO: 2016/6/4 其他用到再添加
48 | }
49 | }
50 |
51 | query.findObjects(context, listener);
52 | }
53 |
54 | /*
55 | 根据Onjectid查询单个数据
56 | context
57 | objectId
58 | 监听器
59 | */
60 | public void getData(Context context, String onjectId, GetListener listener) {
61 | BmobQuery query = new BmobQuery<>();
62 | query.getObject(context, onjectId, listener);
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/netlib/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | NetLib
3 |
4 |
--------------------------------------------------------------------------------
/netlib/src/test/java/com/example/netlib/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.example.netlib;
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 | }
--------------------------------------------------------------------------------
/rxlearnapp/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/rxlearnapp/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 24
5 | buildToolsVersion "24.0.1"
6 |
7 | defaultConfig {
8 | applicationId "com.brioal.rxlearnapp"
9 | minSdkVersion 21
10 | targetSdkVersion 24
11 | versionCode 1
12 | versionName "1.0"
13 |
14 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
15 |
16 | }
17 | buildTypes {
18 | release {
19 | minifyEnabled false
20 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
21 | }
22 | }
23 | }
24 |
25 | dependencies {
26 | compile fileTree(include: ['*.jar'], dir: 'libs')
27 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
28 | exclude group: 'com.android.support', module: 'support-annotations'
29 | })
30 | compile 'com.android.support:appcompat-v7:24.1.1'
31 | compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha4'
32 | testCompile 'junit:junit:4.12'
33 | compile project(':baselib')
34 | }
35 |
--------------------------------------------------------------------------------
/rxlearnapp/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 A:\Android\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 |
--------------------------------------------------------------------------------
/rxlearnapp/src/androidTest/java/com/brioal/rxlearnapp/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.brioal.rxlearnapp;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumentation test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.brioal.rxlearnapp", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/rxlearnapp/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
11 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/rxlearnapp/src/main/java/com/brioal/rxlearnapp/LauncherActivity.java:
--------------------------------------------------------------------------------
1 | package com.brioal.rxlearnapp;
2 |
3 | import android.os.Bundle;
4 |
5 | import com.brioal.baselib.base.BaseActivity;
6 | import com.brioal.rxlearnapp.activity.MainActivity;
7 |
8 | import java.util.concurrent.TimeUnit;
9 |
10 | import rx.Observable;
11 | import rx.functions.Action1;
12 |
13 | public class LauncherActivity extends BaseActivity {
14 |
15 | @Override
16 | public void initData() {
17 | setTheme(R.style.AppTheme_NoActionbar);
18 | super.initData();
19 | }
20 |
21 | @Override
22 | public void initView(Bundle savedInstanceState) {
23 | super.initView(savedInstanceState);
24 | setContentView(R.layout.act_launcher);
25 | //2秒后进入MainActivity
26 | Observable.timer(1, TimeUnit.SECONDS).subscribe(new Action1() {
27 | @Override
28 | public void call(Long aLong) {
29 | MainActivity.startActivity(mContext, MainActivity.class);
30 | }
31 | });
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/rxlearnapp/src/main/java/com/brioal/rxlearnapp/activity/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.brioal.rxlearnapp.activity;
2 |
3 | import android.os.Bundle;
4 |
5 | import com.brioal.baselib.base.BaseActivity;
6 | import com.brioal.rxlearnapp.R;
7 |
8 | public class MainActivity extends BaseActivity {
9 |
10 | @Override
11 | protected void onCreate(Bundle savedInstanceState) {
12 | super.onCreate(savedInstanceState);
13 | setContentView(R.layout.act_main);
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/rxlearnapp/src/main/res/layout/act_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/rxlearnapp/src/main/res/layout/act_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/rxlearnapp/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Brioal/LibManager/e8a295a76bc3008ea8887597a7602c3014f6d263/rxlearnapp/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/rxlearnapp/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Brioal/LibManager/e8a295a76bc3008ea8887597a7602c3014f6d263/rxlearnapp/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/rxlearnapp/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Brioal/LibManager/e8a295a76bc3008ea8887597a7602c3014f6d263/rxlearnapp/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/rxlearnapp/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Brioal/LibManager/e8a295a76bc3008ea8887597a7602c3014f6d263/rxlearnapp/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/rxlearnapp/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Brioal/LibManager/e8a295a76bc3008ea8887597a7602c3014f6d263/rxlearnapp/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/rxlearnapp/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/rxlearnapp/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #b46122
4 | #b46122
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/rxlearnapp/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 | 22sp
6 |
7 |
--------------------------------------------------------------------------------
/rxlearnapp/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | RxLearnApp
3 |
4 |
--------------------------------------------------------------------------------
/rxlearnapp/src/test/java/com/brioal/rxlearnapp/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.brioal.rxlearnapp;
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 | }
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':rxlearnapp', ':baselib', ':netlib', ':uilib'
2 |
--------------------------------------------------------------------------------
/uilib/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/uilib/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | //界面Lib
3 |
4 | android {
5 | compileSdkVersion 24
6 | buildToolsVersion "24.0.1"
7 |
8 | defaultConfig {
9 | minSdkVersion 21
10 | targetSdkVersion 24
11 | versionCode 1
12 | versionName "1.0"
13 |
14 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
15 |
16 | }
17 | buildTypes {
18 | release {
19 | minifyEnabled false
20 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
21 | }
22 | }
23 | }
24 |
25 | dependencies {
26 | compile fileTree(dir: 'libs', include: ['*.jar'])
27 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
28 | exclude group: 'com.android.support', module: 'support-annotations'
29 | })
30 | compile 'com.android.support:appcompat-v7:24.1.1'
31 | testCompile 'junit:junit:4.12'
32 | compile project(':baselib')
33 | compile 'com.android.support:design:24.1.1'
34 | compile 'com.nineoldandroids:library:2.4.0'
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/uilib/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 A:\Android\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 |
--------------------------------------------------------------------------------
/uilib/src/androidTest/java/com/brioal/uilib/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.brioal.uilib;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumentation test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.brioal.uilib.test", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/uilib/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/uilib/src/main/java/com/brioal/uilib/bgabanner/BGAViewPager.java:
--------------------------------------------------------------------------------
1 | package com.brioal.uilib.bgabanner;
2 |
3 | import android.content.Context;
4 | import android.support.v4.view.ViewPager;
5 | import android.util.AttributeSet;
6 | import android.view.MotionEvent;
7 |
8 | import java.lang.reflect.Field;
9 | import java.lang.reflect.Method;
10 |
11 | /**
12 | * 作者:王浩 邮件:bingoogolapple@gmail.com
13 | * 创建时间:15/6/19 11:23
14 | * 描述:继承ViewPager,通过反射方式实现支持低版本上切换动画
15 | */
16 | public class BGAViewPager extends ViewPager {
17 | private boolean mScrollable = true;
18 |
19 | public BGAViewPager(Context context) {
20 | super(context);
21 | }
22 |
23 | public BGAViewPager(Context context, AttributeSet attrs) {
24 | super(context, attrs);
25 | }
26 |
27 | public void setPageTransformer(boolean reverseDrawingOrder, PageTransformer transformer) {
28 | /**
29 | 继承ViewPager,重写setPageTransformer方法,移除版本限制,通过反射设置参数和方法
30 |
31 | getDeclaredMethod*()获取的是【类自身】声明的所有方法,包含public、protected和private方法。
32 | getMethod*()获取的是类的所有共有方法,这就包括自身的所有【public方法】,和从基类继承的、从接口实现的所有【public方法】。
33 |
34 | getDeclaredField获取的是【类自身】声明的所有字段,包含public、protected和private字段。
35 | getField获取的是类的所有共有字段,这就包括自身的所有【public字段】,和从基类继承的、从接口实现的所有【public字段】。
36 | */
37 | Class viewpagerClass = ViewPager.class;
38 |
39 | try {
40 | boolean hasTransformer = transformer != null;
41 |
42 | Field pageTransformerField = viewpagerClass.getDeclaredField("mPageTransformer");
43 | pageTransformerField.setAccessible(true);
44 | PageTransformer mPageTransformer = (PageTransformer) pageTransformerField.get(this);
45 |
46 | boolean needsPopulate = hasTransformer != (mPageTransformer != null);
47 | pageTransformerField.set(this, transformer);
48 |
49 | Method setChildrenDrawingOrderEnabledCompatMethod = viewpagerClass.getDeclaredMethod("setChildrenDrawingOrderEnabledCompat", boolean.class);
50 | setChildrenDrawingOrderEnabledCompatMethod.setAccessible(true);
51 | setChildrenDrawingOrderEnabledCompatMethod.invoke(this, hasTransformer);
52 |
53 | Field drawingOrderField = viewpagerClass.getDeclaredField("mDrawingOrder");
54 | drawingOrderField.setAccessible(true);
55 | if (hasTransformer) {
56 | drawingOrderField.setInt(this, reverseDrawingOrder ? 2 : 1);
57 | } else {
58 | drawingOrderField.setInt(this, 0);
59 | }
60 |
61 | if (needsPopulate) {
62 | Method populateMethod = viewpagerClass.getDeclaredMethod("populate");
63 | populateMethod.setAccessible(true);
64 | populateMethod.invoke(this);
65 | }
66 | } catch (Exception e) {
67 | e.printStackTrace();
68 | }
69 | }
70 |
71 | /**
72 | * 设置调用setCurrentItem(int item, boolean smoothScroll)方法时,page切换的时间长度
73 | *
74 | * @param duration page切换的时间长度
75 | */
76 | public void setPageChangeDuration(int duration) {
77 | try {
78 | Field scrollerField = ViewPager.class.getDeclaredField("mScroller");
79 | scrollerField.setAccessible(true);
80 | scrollerField.set(this, new PageChangeDurationScroller(getContext(), duration));
81 | } catch (Exception e) {
82 | e.printStackTrace();
83 | }
84 | }
85 |
86 | /**
87 | * 设置是否允许用户手指滑动
88 | *
89 | * @param scrollable true表示允许跟随用户触摸滑动,false反之
90 | */
91 | public void setAllowUserScrollable(boolean scrollable) {
92 | mScrollable = scrollable;
93 | }
94 |
95 | @Override
96 | public boolean onInterceptTouchEvent(MotionEvent ev) {
97 | if (mScrollable) {
98 | return super.onInterceptTouchEvent(ev);
99 | } else {
100 | return false;
101 | }
102 | }
103 |
104 | @Override
105 | public boolean onTouchEvent(MotionEvent ev) {
106 | if (mScrollable) {
107 | return super.onTouchEvent(ev);
108 | } else {
109 | return false;
110 | }
111 | }
112 | }
--------------------------------------------------------------------------------
/uilib/src/main/java/com/brioal/uilib/bgabanner/PageChangeDurationScroller.java:
--------------------------------------------------------------------------------
1 | package com.brioal.uilib.bgabanner;
2 |
3 | import android.content.Context;
4 | import android.widget.Scroller;
5 |
6 | /**
7 | * 作者:王浩 邮件:bingoogolapple@gmail.com
8 | * 创建时间:15/6/19 下午11:59
9 | * 描述:
10 | */
11 | public class PageChangeDurationScroller extends Scroller {
12 | private int mDuration = 1000;
13 |
14 | public PageChangeDurationScroller(Context context) {
15 | super(context);
16 | }
17 |
18 | public PageChangeDurationScroller(Context context, int duration) {
19 | super(context);
20 | mDuration = duration;
21 | }
22 |
23 | @Override
24 | public void startScroll(int startX, int startY, int dx, int dy, int duration) {
25 | super.startScroll(startX, startY, dx, dy, mDuration);
26 | }
27 | }
--------------------------------------------------------------------------------
/uilib/src/main/java/com/brioal/uilib/bgabanner/transformer/AccordionPageTransformer.java:
--------------------------------------------------------------------------------
1 | package com.brioal.uilib.bgabanner.transformer;
2 |
3 | import android.view.View;
4 |
5 | import com.nineoldandroids.view.ViewHelper;
6 |
7 |
8 | /**
9 | * 作者:王浩 邮件:bingoogolapple@gmail.com
10 | * 创建时间:15/6/19 上午8:41
11 | * 描述:
12 | */
13 | public class AccordionPageTransformer extends BGAPageTransformer {
14 |
15 | @Override
16 | public void handleInvisiblePage(View view, float position) {
17 | }
18 |
19 | @Override
20 | public void handleLeftPage(View view, float position) {
21 | ViewHelper.setPivotX(view, view.getWidth());
22 | ViewHelper.setScaleX(view, 1.0f + position);
23 | }
24 |
25 | @Override
26 | public void handleRightPage(View view, float position) {
27 | ViewHelper.setPivotX(view, 0);
28 | ViewHelper.setScaleX(view, 1.0f - position);
29 | }
30 |
31 | }
--------------------------------------------------------------------------------
/uilib/src/main/java/com/brioal/uilib/bgabanner/transformer/AlphaPageTransformer.java:
--------------------------------------------------------------------------------
1 | package com.brioal.uilib.bgabanner.transformer;
2 |
3 | import android.view.View;
4 |
5 | import com.nineoldandroids.view.ViewHelper;
6 |
7 | /**
8 | * 作者:王浩 邮件:bingoogolapple@gmail.com
9 | * 创建时间:15/6/19 上午8:41
10 | * 描述:
11 | */
12 | public class AlphaPageTransformer extends BGAPageTransformer {
13 | private float mMinScale = 0.4f;
14 |
15 | public AlphaPageTransformer() {
16 | }
17 |
18 | public AlphaPageTransformer(float minScale) {
19 | setMinScale(minScale);
20 | }
21 |
22 | @Override
23 | public void handleInvisiblePage(View view, float position) {
24 | ViewHelper.setAlpha(view, 0);
25 | }
26 |
27 | @Override
28 | public void handleLeftPage(View view, float position) {
29 | ViewHelper.setAlpha(view, mMinScale + (1 - mMinScale) * (1 + position));
30 | }
31 |
32 | @Override
33 | public void handleRightPage(View view, float position) {
34 | ViewHelper.setAlpha(view, mMinScale + (1 - mMinScale) * (1 - position));
35 | }
36 |
37 | public void setMinScale(float minScale) {
38 | if (minScale >= 0.0f && minScale <= 1.0f) {
39 | mMinScale = minScale;
40 | }
41 | }
42 | }
--------------------------------------------------------------------------------
/uilib/src/main/java/com/brioal/uilib/bgabanner/transformer/BGAPageTransformer.java:
--------------------------------------------------------------------------------
1 | package com.brioal.uilib.bgabanner.transformer;
2 |
3 | import android.support.v4.view.ViewPager;
4 | import android.view.View;
5 |
6 | /**
7 | * 作者:王浩 邮件:bingoogolapple@gmail.com
8 | * 创建时间:15/6/19 14:35
9 | * 描述:
10 | */
11 | public abstract class BGAPageTransformer implements ViewPager.PageTransformer {
12 |
13 | public void transformPage(View view, float position) {
14 | if (position < -1.0f) {
15 | // [-Infinity,-1)
16 | // This page is way off-screen to the left.
17 | handleInvisiblePage(view, position);
18 | } else if (position <= 0.0f) {
19 | // [-1,0]
20 | // Use the default slide transition when moving to the left page
21 | handleLeftPage(view, position);
22 | } else if (position <= 1.0f) {
23 | // (0,1]
24 | handleRightPage(view, position);
25 | } else {
26 | // (1,+Infinity]
27 | // This page is way off-screen to the right.
28 | handleInvisiblePage(view, position);
29 | }
30 | }
31 |
32 | public abstract void handleInvisiblePage(View view, float position);
33 |
34 | public abstract void handleLeftPage(View view, float position);
35 |
36 | public abstract void handleRightPage(View view, float position);
37 |
38 | }
--------------------------------------------------------------------------------
/uilib/src/main/java/com/brioal/uilib/bgabanner/transformer/CubePageTransformer.java:
--------------------------------------------------------------------------------
1 | package com.brioal.uilib.bgabanner.transformer;
2 |
3 | import android.view.View;
4 |
5 | import com.nineoldandroids.view.ViewHelper;
6 |
7 | /**
8 | * 作者:王浩 邮件:bingoogolapple@gmail.com
9 | * 创建时间:15/6/19 17:39
10 | * 描述:
11 | */
12 | public class CubePageTransformer extends BGAPageTransformer {
13 | private float mMaxRotation = 90.0f;
14 |
15 | public CubePageTransformer() {
16 | }
17 |
18 | public CubePageTransformer(float maxRotation) {
19 | setMaxRotation(maxRotation);
20 | }
21 |
22 | @Override
23 | public void handleInvisiblePage(View view, float position) {
24 | ViewHelper.setPivotX(view, view.getMeasuredWidth());
25 | ViewHelper.setPivotY(view, view.getMeasuredHeight() * 0.5f);
26 | ViewHelper.setRotationY(view, 0);
27 | }
28 |
29 | @Override
30 | public void handleLeftPage(View view, float position) {
31 | ViewHelper.setPivotX(view, view.getMeasuredWidth());
32 | ViewHelper.setPivotY(view, view.getMeasuredHeight() * 0.5f);
33 | ViewHelper.setRotationY(view, mMaxRotation * position);
34 | }
35 |
36 | @Override
37 | public void handleRightPage(View view, float position) {
38 | ViewHelper.setPivotX(view, 0);
39 | ViewHelper.setPivotY(view, view.getMeasuredHeight() * 0.5f);
40 | ViewHelper.setRotationY(view, mMaxRotation * position);
41 | }
42 |
43 | public void setMaxRotation(float maxRotation) {
44 | if (maxRotation >= 0.0f && maxRotation <= 90.0f) {
45 | mMaxRotation = maxRotation;
46 | }
47 | }
48 |
49 | }
50 |
--------------------------------------------------------------------------------
/uilib/src/main/java/com/brioal/uilib/bgabanner/transformer/DefaultPageTransformer.java:
--------------------------------------------------------------------------------
1 | package com.brioal.uilib.bgabanner.transformer;
2 |
3 | import android.view.View;
4 |
5 | /**
6 | * 作者:王浩 邮件:bingoogolapple@gmail.com
7 | * 创建时间:15/6/19 上午8:41
8 | * 描述:
9 | */
10 | public class DefaultPageTransformer extends BGAPageTransformer {
11 |
12 | @Override
13 | public void handleInvisiblePage(View view, float position) {
14 | }
15 |
16 | @Override
17 | public void handleLeftPage(View view, float position) {
18 | }
19 |
20 | @Override
21 | public void handleRightPage(View view, float position) {
22 | }
23 |
24 | }
--------------------------------------------------------------------------------
/uilib/src/main/java/com/brioal/uilib/bgabanner/transformer/DepthPageTransformer.java:
--------------------------------------------------------------------------------
1 | package com.brioal.uilib.bgabanner.transformer;
2 |
3 | import android.view.View;
4 |
5 | import com.nineoldandroids.view.ViewHelper;
6 |
7 | /**
8 | * 作者:王浩 邮件:bingoogolapple@gmail.com
9 | * 创建时间:15/6/19 上午8:41
10 | * 描述:
11 | */
12 | public class DepthPageTransformer extends BGAPageTransformer {
13 | private float mMinScale = 0.8f;
14 |
15 | public DepthPageTransformer() {
16 | }
17 |
18 | public DepthPageTransformer(float minScale) {
19 | setMinScale(minScale);
20 | }
21 |
22 | @Override
23 | public void handleInvisiblePage(View view, float position) {
24 | ViewHelper.setAlpha(view, 0);
25 | }
26 |
27 | @Override
28 | public void handleLeftPage(View view, float position) {
29 | ViewHelper.setAlpha(view, 1);
30 | ViewHelper.setTranslationX(view, 0);
31 | ViewHelper.setScaleX(view, 1);
32 | ViewHelper.setScaleY(view, 1);
33 | }
34 |
35 | @Override
36 | public void handleRightPage(View view, float position) {
37 | ViewHelper.setAlpha(view, 1 - position);
38 | ViewHelper.setTranslationX(view, -view.getWidth() * position);
39 | float scale = mMinScale + (1 - mMinScale) * (1 - position);
40 | ViewHelper.setScaleX(view, scale);
41 | ViewHelper.setScaleY(view, scale);
42 | }
43 |
44 | public void setMinScale(float minScale) {
45 | if (minScale >= 0.6f && minScale <= 1.0f) {
46 | mMinScale = minScale;
47 | }
48 | }
49 |
50 | }
--------------------------------------------------------------------------------
/uilib/src/main/java/com/brioal/uilib/bgabanner/transformer/FadePageTransformer.java:
--------------------------------------------------------------------------------
1 | package com.brioal.uilib.bgabanner.transformer;
2 |
3 | import android.view.View;
4 |
5 | import com.nineoldandroids.view.ViewHelper;
6 |
7 | /**
8 | * 作者:王浩 邮件:bingoogolapple@gmail.com
9 | * 创建时间:15/6/19 上午8:41
10 | * 描述:
11 | */
12 | public class FadePageTransformer extends BGAPageTransformer {
13 |
14 | @Override
15 | public void handleInvisiblePage(View view, float position) {
16 | }
17 |
18 | @Override
19 | public void handleLeftPage(View view, float position) {
20 | ViewHelper.setTranslationX(view, -view.getWidth() * position);
21 | ViewHelper.setAlpha(view, 1 + position);
22 | }
23 |
24 | @Override
25 | public void handleRightPage(View view, float position) {
26 | ViewHelper.setTranslationX(view, -view.getWidth() * position);
27 | ViewHelper.setAlpha(view, 1 - position);
28 | }
29 |
30 | }
--------------------------------------------------------------------------------
/uilib/src/main/java/com/brioal/uilib/bgabanner/transformer/FlipPageTransformer.java:
--------------------------------------------------------------------------------
1 | package com.brioal.uilib.bgabanner.transformer;
2 |
3 | import android.view.View;
4 |
5 | import com.nineoldandroids.view.ViewHelper;
6 |
7 | /**
8 | * 作者:王浩 邮件:bingoogolapple@gmail.com
9 | * 创建时间:15/6/19 上午8:41
10 | * 描述:
11 | */
12 | public class FlipPageTransformer extends BGAPageTransformer {
13 | private static final float ROTATION = 180.0f;
14 |
15 | @Override
16 | public void handleInvisiblePage(View view, float position) {
17 | }
18 |
19 | @Override
20 | public void handleLeftPage(View view, float position) {
21 | ViewHelper.setTranslationX(view, -view.getWidth() * position);
22 | float rotation = (ROTATION * position);
23 | ViewHelper.setRotationY(view, rotation);
24 |
25 | if (position > -0.5) {
26 | view.setVisibility(View.VISIBLE);
27 | } else {
28 | view.setVisibility(View.INVISIBLE);
29 | }
30 | }
31 |
32 | @Override
33 | public void handleRightPage(View view, float position) {
34 | ViewHelper.setTranslationX(view, -view.getWidth() * position);
35 | float rotation = (ROTATION * position);
36 | ViewHelper.setRotationY(view, rotation);
37 |
38 | if (position < 0.5) {
39 | view.setVisibility(View.VISIBLE);
40 | } else {
41 | view.setVisibility(View.INVISIBLE);
42 | }
43 | }
44 |
45 | }
--------------------------------------------------------------------------------
/uilib/src/main/java/com/brioal/uilib/bgabanner/transformer/RotatePageTransformer.java:
--------------------------------------------------------------------------------
1 | package com.brioal.uilib.bgabanner.transformer;
2 |
3 | import android.view.View;
4 |
5 | import com.nineoldandroids.view.ViewHelper;
6 |
7 | /**
8 | * 作者:王浩 邮件:bingoogolapple@gmail.com
9 | * 创建时间:15/6/19 上午8:41
10 | * 描述:
11 | */
12 | public class RotatePageTransformer extends BGAPageTransformer {
13 | private float mMaxRotation = 15.0f;
14 |
15 | public RotatePageTransformer() {
16 | }
17 |
18 | public RotatePageTransformer(float maxRotation) {
19 | setMaxRotation(maxRotation);
20 | }
21 |
22 | @Override
23 | public void handleInvisiblePage(View view, float position) {
24 | ViewHelper.setPivotX(view, view.getMeasuredWidth() * 0.5f);
25 | ViewHelper.setPivotY(view, view.getMeasuredHeight());
26 | ViewHelper.setRotation(view, 0);
27 | }
28 |
29 | @Override
30 | public void handleLeftPage(View view, float position) {
31 | float rotation = (mMaxRotation * position);
32 | ViewHelper.setPivotX(view, view.getMeasuredWidth() * 0.5f);
33 | ViewHelper.setPivotY(view, view.getMeasuredHeight());
34 | ViewHelper.setRotation(view, rotation);
35 | }
36 |
37 | @Override
38 | public void handleRightPage(View view, float position) {
39 | handleLeftPage(view, position);
40 | }
41 |
42 | public void setMaxRotation(float maxRotation) {
43 | if (maxRotation >= 0.0f && maxRotation <= 40.0f) {
44 | mMaxRotation = maxRotation;
45 | }
46 | }
47 | }
--------------------------------------------------------------------------------
/uilib/src/main/java/com/brioal/uilib/bgabanner/transformer/StackPageTransformer.java:
--------------------------------------------------------------------------------
1 | package com.brioal.uilib.bgabanner.transformer;
2 |
3 | import android.view.View;
4 |
5 | import com.nineoldandroids.view.ViewHelper;
6 |
7 | /**
8 | * 作者:王浩 邮件:bingoogolapple@gmail.com
9 | * 创建时间:15/6/19 上午8:41
10 | * 描述:
11 | */
12 | public class StackPageTransformer extends BGAPageTransformer {
13 |
14 | @Override
15 | public void handleInvisiblePage(View view, float position) {
16 | }
17 |
18 | @Override
19 | public void handleLeftPage(View view, float position) {
20 | }
21 |
22 | @Override
23 | public void handleRightPage(View view, float position) {
24 | ViewHelper.setTranslationX(view, -view.getWidth() * position);
25 | }
26 |
27 | }
--------------------------------------------------------------------------------
/uilib/src/main/java/com/brioal/uilib/bgabanner/transformer/ZoomCenterPageTransformer.java:
--------------------------------------------------------------------------------
1 | package com.brioal.uilib.bgabanner.transformer;
2 |
3 | import android.view.View;
4 |
5 | import com.nineoldandroids.view.ViewHelper;
6 |
7 | /**
8 | * 作者:王浩 邮件:bingoogolapple@gmail.com
9 | * 创建时间:15/6/19 上午8:41
10 | * 描述:
11 | */
12 | public class ZoomCenterPageTransformer extends BGAPageTransformer {
13 |
14 | @Override
15 | public void handleInvisiblePage(View view, float position) {
16 | }
17 |
18 | @Override
19 | public void handleLeftPage(View view, float position) {
20 | ViewHelper.setTranslationX(view, -view.getWidth() * position);
21 |
22 | ViewHelper.setPivotX(view, view.getWidth() * 0.5f);
23 | ViewHelper.setPivotY(view, view.getHeight() * 0.5f);
24 | ViewHelper.setScaleX(view, 1 + position);
25 | ViewHelper.setScaleY(view, 1 + position);
26 |
27 | if (position < -0.95f) {
28 | ViewHelper.setAlpha(view, 0);
29 | } else {
30 | ViewHelper.setAlpha(view, 1);
31 | }
32 | }
33 |
34 | @Override
35 | public void handleRightPage(View view, float position) {
36 | ViewHelper.setTranslationX(view, -view.getWidth() * position);
37 |
38 | ViewHelper.setPivotX(view, view.getWidth() * 0.5f);
39 | ViewHelper.setPivotY(view, view.getHeight() * 0.5f);
40 | ViewHelper.setScaleX(view, 1 - position);
41 | ViewHelper.setScaleY(view, 1 - position);
42 |
43 | if (position > 0.95f) {
44 | ViewHelper.setAlpha(view, 0);
45 | } else {
46 | ViewHelper.setAlpha(view, 1);
47 | }
48 | }
49 |
50 | }
--------------------------------------------------------------------------------
/uilib/src/main/java/com/brioal/uilib/bgabanner/transformer/ZoomFadePageTransformer.java:
--------------------------------------------------------------------------------
1 | package com.brioal.uilib.bgabanner.transformer;
2 |
3 | import android.view.View;
4 |
5 | import com.nineoldandroids.view.ViewHelper;
6 |
7 | /**
8 | * 作者:王浩 邮件:bingoogolapple@gmail.com
9 | * 创建时间:15/6/19 上午8:41
10 | * 描述:
11 | */
12 | public class ZoomFadePageTransformer extends BGAPageTransformer {
13 |
14 | @Override
15 | public void handleInvisiblePage(View view, float position) {
16 | }
17 |
18 | @Override
19 | public void handleLeftPage(View view, float position) {
20 | ViewHelper.setTranslationX(view, -view.getWidth() * position);
21 |
22 | ViewHelper.setPivotX(view,view.getWidth() * 0.5f);
23 | ViewHelper.setPivotY(view, view.getHeight() * 0.5f);
24 | ViewHelper.setScaleX(view, 1 + position);
25 | ViewHelper.setScaleY(view, 1 + position);
26 |
27 | ViewHelper.setAlpha(view, 1 + position);
28 | }
29 |
30 | @Override
31 | public void handleRightPage(View view, float position) {
32 | ViewHelper.setTranslationX(view, -view.getWidth() * position);
33 |
34 | ViewHelper.setPivotX(view,view.getWidth() * 0.5f);
35 | ViewHelper.setPivotY(view, view.getHeight() * 0.5f);
36 | ViewHelper.setScaleX(view, 1 - position);
37 | ViewHelper.setScaleY(view, 1 - position);
38 | ViewHelper.setAlpha(view, 1 - position);
39 | }
40 |
41 | }
--------------------------------------------------------------------------------
/uilib/src/main/java/com/brioal/uilib/bgabanner/transformer/ZoomPageTransformer.java:
--------------------------------------------------------------------------------
1 | package com.brioal.uilib.bgabanner.transformer;
2 |
3 | import android.view.View;
4 |
5 | import com.nineoldandroids.view.ViewHelper;
6 |
7 | /**
8 | * 作者:王浩 邮件:bingoogolapple@gmail.com
9 | * 创建时间:15/6/19 上午8:41
10 | * 描述:
11 | */
12 | public class ZoomPageTransformer extends BGAPageTransformer {
13 | private float mMinScale = 0.85f;
14 | private float mMinAlpha = 0.65f;
15 |
16 | public ZoomPageTransformer() {
17 | }
18 |
19 | public ZoomPageTransformer(float minAlpha, float minScale) {
20 | setMinAlpha(minAlpha);
21 | setMinScale(minScale);
22 | }
23 |
24 | @Override
25 | public void handleInvisiblePage(View view, float position) {
26 | ViewHelper.setAlpha(view, 0);
27 | }
28 |
29 | @Override
30 | public void handleLeftPage(View view, float position) {
31 | float scale = Math.max(mMinScale, 1 + position);
32 | float vertMargin = view.getHeight() * (1 - scale) / 2;
33 | float horzMargin = view.getWidth() * (1 - scale) / 2;
34 | ViewHelper.setTranslationX(view, horzMargin - vertMargin / 2);
35 | ViewHelper.setScaleX(view, scale);
36 | ViewHelper.setScaleY(view, scale);
37 | ViewHelper.setAlpha(view, mMinAlpha + (scale - mMinScale) / (1 - mMinScale) * (1 - mMinAlpha));
38 | }
39 |
40 | @Override
41 | public void handleRightPage(View view, float position) {
42 | float scale = Math.max(mMinScale, 1 - position);
43 | float vertMargin = view.getHeight() * (1 - scale) / 2;
44 | float horzMargin = view.getWidth() * (1 - scale) / 2;
45 | ViewHelper.setTranslationX(view, -horzMargin + vertMargin / 2);
46 | ViewHelper.setScaleX(view, scale);
47 | ViewHelper.setScaleY(view, scale);
48 | ViewHelper.setAlpha(view, mMinAlpha + (scale - mMinScale) / (1 - mMinScale) * (1 - mMinAlpha));
49 | }
50 |
51 | public void setMinAlpha(float minAlpha) {
52 | if (minAlpha >= 0.6f && minAlpha <= 1.0f) {
53 | mMinAlpha = minAlpha;
54 | }
55 | }
56 |
57 | public void setMinScale(float minScale) {
58 | if (minScale >= 0.6f && minScale <= 1.0f) {
59 | mMinScale = minScale;
60 | }
61 | }
62 | }
--------------------------------------------------------------------------------
/uilib/src/main/java/com/brioal/uilib/bgabanner/transformer/ZoomStackPageTransformer.java:
--------------------------------------------------------------------------------
1 | package com.brioal.uilib.bgabanner.transformer;
2 |
3 | import android.view.View;
4 |
5 | import com.nineoldandroids.view.ViewHelper;
6 |
7 | /**
8 | * 作者:王浩 邮件:bingoogolapple@gmail.com
9 | * 创建时间:15/6/19 上午8:41
10 | * 描述:
11 | */
12 | public class ZoomStackPageTransformer extends BGAPageTransformer {
13 |
14 | @Override
15 | public void handleInvisiblePage(View view, float position) {
16 | }
17 |
18 | @Override
19 | public void handleLeftPage(View view, float position) {
20 | ViewHelper.setTranslationX(view, -view.getWidth() * position);
21 |
22 | ViewHelper.setPivotX(view, view.getWidth() * 0.5f);
23 | ViewHelper.setPivotY(view, view.getHeight() * 0.5f);
24 | ViewHelper.setScaleX(view, 1 + position);
25 | ViewHelper.setScaleY(view, 1 + position);
26 |
27 | if (position < -0.95f) {
28 | ViewHelper.setAlpha(view, 0);
29 | } else {
30 | ViewHelper.setAlpha(view, 1);
31 | }
32 | }
33 |
34 | @Override
35 | public void handleRightPage(View view, float position) {
36 | ViewHelper.setTranslationX(view, -view.getWidth() * position);
37 |
38 | ViewHelper.setPivotX(view, view.getWidth() * 0.5f);
39 | ViewHelper.setPivotY(view, view.getHeight() * 0.5f);
40 | ViewHelper.setScaleX(view, 1 + position);
41 | ViewHelper.setScaleY(view, 1 + position);
42 |
43 | if (position > 0.95f) {
44 | ViewHelper.setAlpha(view, 0);
45 | } else {
46 | ViewHelper.setAlpha(view, 1);
47 | }
48 | }
49 |
50 | }
--------------------------------------------------------------------------------
/uilib/src/main/java/com/brioal/uilib/circlehead/CircleHead.java:
--------------------------------------------------------------------------------
1 | package com.brioal.uilib.circlehead;
2 |
3 | import android.content.Context;
4 | import android.content.res.TypedArray;
5 | import android.graphics.Canvas;
6 | import android.graphics.Color;
7 | import android.graphics.Paint;
8 | import android.util.AttributeSet;
9 | import android.view.View;
10 |
11 | import com.brioal.uilib.R;
12 |
13 | import java.util.Random;
14 |
15 | /**
16 | * 显示文字的圆点
17 | */
18 | public class CircleHead extends View {
19 | private int mHeight; //高度
20 | private int mWidth; //宽度
21 | private int mRadius; //半径
22 | private String mText = "A"; //文字
23 | private Paint mPaintBack; //背景画笔
24 | private Paint mPaintText; //文字画笔
25 | private int mBackColor = Color.GRAY; //背景色
26 | private int mTextColor = Color.WHITE; //文字颜色
27 | private boolean isRandom = false; //是否开启随机颜色
28 | private Random random;
29 |
30 | public CircleHead(Context context) {
31 | this(context, null);
32 | }
33 |
34 | public CircleHead(Context context, AttributeSet attrs) {
35 | super(context, attrs);
36 | random = new Random();
37 | TypedArray array = getContext().obtainStyledAttributes(attrs, R.styleable.CircleHead);
38 | mText = array.getString(R.styleable.CircleHead_circle_head_text);
39 | mBackColor = array.getColor(R.styleable.CircleHead_circlr_head_back, getResources().getColor(R.color.colorPrimary));
40 | mTextColor = array.getColor(R.styleable.CircleHead_circlr_head_text_color, Color.WHITE);
41 | isRandom = array.getBoolean(R.styleable.CircleHead_circlr_head_israndom, false);
42 | array.recycle();
43 | init();
44 | }
45 |
46 | private void init() {
47 | mPaintBack = new Paint();
48 | mPaintBack.setAntiAlias(true);
49 | mPaintBack.setDither(true);
50 | mPaintBack.setStyle(Paint.Style.FILL);
51 | if (isRandom) {
52 | mBackColor = getRandomColor(); //产生随机颜色
53 | }
54 | mPaintBack.setColor(mBackColor);
55 |
56 | mPaintText = new Paint();
57 | mPaintText.setAntiAlias(true);
58 | mPaintText.setDither(true);
59 | mPaintText.setColor(mTextColor);
60 |
61 | }
62 |
63 | //设置文字
64 | public void setmText(String mText) {
65 | this.mText = mText;
66 | invalidate();
67 | }
68 |
69 | //设置背景颜色
70 | public void setBackColor(int backColor) {
71 | mBackColor = backColor;
72 | }
73 |
74 | //设置文字颜色
75 | public void setTextColor(int textColor) {
76 | mTextColor = textColor;
77 | }
78 |
79 | //设置是否开启随机颜色
80 | public void setRandom(boolean isRandom) {
81 | this.isRandom = isRandom;
82 | }
83 |
84 | public int getRandomColor() {
85 | int r = random.nextInt(255);
86 | int g = random.nextInt(255);
87 | int b = random.nextInt(255);
88 | return Color.rgb(r, g, b);
89 | }
90 |
91 | @Override
92 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
93 | super.onMeasure(widthMeasureSpec, heightMeasureSpec);
94 | mWidth = MeasureSpec.getSize(widthMeasureSpec);
95 | mHeight = MeasureSpec.getSize(heightMeasureSpec);
96 | mRadius = (Math.min(mWidth, mHeight) - 10) / 2; //获取半径
97 | }
98 |
99 | @Override
100 | protected void onDraw(Canvas canvas) {
101 | super.onDraw(canvas);
102 | canvas.drawCircle(mWidth / 2, mHeight / 2, mRadius, mPaintBack); //绘制外圆
103 | mPaintText.setTextSize(mRadius - 20); //自动设置字体大小
104 | Paint.FontMetrics metrics = mPaintText.getFontMetrics();
105 | float textWidth = mPaintText.measureText(mText); //获取字体的宽度
106 | float textHeight = metrics.bottom - metrics.top; //获取字体的高度
107 | float offsetWidth = (textWidth) / 2; //计算快递便宜
108 | float offsetHeight = mWidth / 2 - (metrics.bottom - (textHeight - mWidth) / 2); //计算高度偏移
109 | canvas.drawText(mText, mWidth / 2 - offsetWidth, mHeight / 2 + offsetHeight, mPaintText); //绘制文字
110 | }
111 | }
112 |
--------------------------------------------------------------------------------
/uilib/src/main/java/com/brioal/uilib/circlepoint/CirclePoint.java:
--------------------------------------------------------------------------------
1 | package com.brioal.uilib.circlepoint;
2 |
3 | import android.content.Context;
4 | import android.content.res.TypedArray;
5 | import android.graphics.Canvas;
6 | import android.graphics.Color;
7 | import android.graphics.Paint;
8 | import android.util.AttributeSet;
9 | import android.view.View;
10 |
11 | import com.brioal.uilib.R;
12 |
13 | import java.util.Random;
14 |
15 | /**
16 | * 圆点
17 | * Created by Brioal on 2016/5/18.
18 | */
19 | public class CirclePoint extends View {
20 | private int mColor;
21 | private Paint mPaint;
22 | private int radicus;
23 | private int mWidth;
24 | private int mHeight;
25 |
26 | private Random mRandom;
27 | private boolean isRandom = false; //是否随机颜色
28 |
29 | public CirclePoint(Context context) {
30 | this(context, null);
31 | init();
32 | }
33 |
34 | public CirclePoint(Context context, AttributeSet attrs) {
35 | super(context, attrs);
36 | TypedArray array = getContext().obtainStyledAttributes(attrs, R.styleable.CirclePoint);
37 | int color = array.getColor(R.styleable.CirclePoint_pointcolor, getResources().getColor(R.color.colorPrimary));
38 | boolean israndom = array.getBoolean(R.styleable.CirclePoint_israndom, false);
39 | mColor = color;
40 | isRandom = israndom;
41 | init();
42 | }
43 |
44 | public void randomColor() {
45 | int r = mRandom.nextInt(255);
46 | int g = mRandom.nextInt(255);
47 | int b = mRandom.nextInt(255);
48 | mColor = Color.rgb(r, g, b);
49 | }
50 |
51 | @Override
52 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
53 | super.onMeasure(widthMeasureSpec, heightMeasureSpec);
54 | int widthSize = MeasureSpec.getSize(widthMeasureSpec);
55 | int heightSize = MeasureSpec.getSize(heightMeasureSpec);
56 | mWidth = widthSize;
57 | mHeight = heightSize;
58 | radicus = Math.min(widthSize, heightSize) / 2;
59 | }
60 |
61 |
62 | private void init() {
63 | mRandom = new Random();
64 | mPaint = new Paint();
65 | mPaint.setAntiAlias(true);
66 | mPaint.setDither(true);
67 | mPaint.setStyle(Paint.Style.FILL);
68 | if (isRandom) {
69 | randomColor(); //产生随机颜色
70 | }
71 | mPaint.setColor(mColor);
72 | }
73 |
74 | public void setColor(int mColor) {
75 | this.mColor = mColor;
76 | mPaint.setColor(mColor);
77 | invalidate();
78 | }
79 |
80 | public void setRandom(boolean isRandom) {
81 | this.isRandom = isRandom;
82 | randomColor();
83 | invalidate();
84 | }
85 |
86 | @Override
87 | protected void onDraw(Canvas canvas) {
88 | super.onDraw(canvas);
89 | canvas.drawCircle(mWidth / 2, mHeight / 2, radicus - 10, mPaint);
90 | }
91 | }
92 |
--------------------------------------------------------------------------------
/uilib/src/main/java/com/brioal/uilib/entity/AdEntity.java:
--------------------------------------------------------------------------------
1 | package com.brioal.uilib.entity;
2 |
3 | public class AdEntity {
4 | private String mFront; //前面的文字
5 | private String mBack; //后面的文字
6 | private String mUrl;//包含的链接
7 |
8 | public AdEntity(String mFront, String mBack, String mUrl) {
9 | this.mFront = mFront;
10 | this.mBack = mBack;
11 | this.mUrl = mUrl;
12 | }
13 |
14 | public String getmUrl() {
15 | return mUrl;
16 | }
17 |
18 | public void setmUrl(String mUrl) {
19 | this.mUrl = mUrl;
20 | }
21 |
22 | public String getmFront() {
23 | return mFront;
24 | }
25 |
26 | public void setmFront(String mFront) {
27 | this.mFront = mFront;
28 | }
29 |
30 | public String getmBack() {
31 | return mBack;
32 | }
33 |
34 | public void setmBack(String mBack) {
35 | this.mBack = mBack;
36 | }
37 | }
--------------------------------------------------------------------------------
/uilib/src/main/java/com/brioal/uilib/largeimagedisplay/BaseGestureDector.java:
--------------------------------------------------------------------------------
1 | package com.brioal.uilib.largeimagedisplay;
2 |
3 | import android.content.Context;
4 | import android.view.MotionEvent;
5 |
6 | /**
7 | * 基本手势检测类
8 | * Created by brioal on 16-7-26.
9 | */
10 |
11 | public abstract class BaseGestureDector {
12 |
13 | protected boolean mGestureInProgress;
14 | protected MotionEvent mPreMotionEvent;
15 | protected MotionEvent mCurrentMotionEvent;
16 |
17 | protected Context mContext;
18 |
19 | public BaseGestureDector(Context context) {
20 | mContext = context;
21 | }
22 |
23 | public boolean onToucEvent(MotionEvent event) {
24 |
25 | if (!mGestureInProgress) {
26 | handleStartProgressEvent(event);
27 | } else {
28 | handleInProgressEvent(event);
29 | }
30 |
31 | return true;
32 |
33 | }
34 |
35 | protected abstract void handleInProgressEvent(MotionEvent event);
36 |
37 | protected abstract void handleStartProgressEvent(MotionEvent event);
38 |
39 | protected abstract void updateStateByEvent(MotionEvent event);
40 |
41 | protected void resetState() {
42 | if (mPreMotionEvent != null) {
43 | mPreMotionEvent.recycle();
44 | mPreMotionEvent = null;
45 | }
46 | if (mCurrentMotionEvent != null) {
47 | mCurrentMotionEvent.recycle();
48 | mCurrentMotionEvent = null;
49 | }
50 | mGestureInProgress = false;
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/uilib/src/main/java/com/brioal/uilib/largeimagedisplay/MoveGestureDetector.java:
--------------------------------------------------------------------------------
1 | package com.brioal.uilib.largeimagedisplay;
2 |
3 | import android.content.Context;
4 | import android.graphics.PointF;
5 | import android.view.MotionEvent;
6 |
7 | /**
8 | * 手势移动检测类
9 | * Created by brioal on 16-7-26.
10 | */
11 |
12 | public class MoveGestureDetector extends BaseGestureDector {
13 |
14 | private PointF mCurrentPointF;
15 | private PointF mPrePointF;
16 |
17 | //仅仅为了减少创建内存
18 | private PointF mDeltaPointer = new PointF();
19 |
20 | //用于记录最终结果,并返回
21 | private PointF mExtenalPointer = new PointF();
22 |
23 | private onMoveGestureListener mListener;
24 |
25 |
26 | public MoveGestureDetector(Context context, onMoveGestureListener listener) {
27 | super(context);
28 | mListener = listener;
29 | }
30 |
31 |
32 | @Override
33 | protected void handleInProgressEvent(MotionEvent event) {
34 |
35 | int actionCode = event.getAction() & MotionEvent.ACTION_MASK;
36 | switch (actionCode) {
37 | case MotionEvent.ACTION_CANCEL:
38 | case MotionEvent.ACTION_UP:
39 | mListener.onMoveEnd(this);
40 | resetState();
41 | break;
42 | case MotionEvent.ACTION_MOVE:
43 | updateStateByEvent(event);
44 | boolean update = mListener.onMove(this);
45 | if (update) {
46 | mPreMotionEvent.recycle();
47 | mPreMotionEvent = MotionEvent.obtain(event);
48 | }
49 | break;
50 | }
51 | }
52 |
53 | @Override
54 | protected void handleStartProgressEvent(MotionEvent event) {
55 |
56 | int actionCode = event.getAction() & MotionEvent.ACTION_MASK;
57 | switch (actionCode) {
58 | case MotionEvent.ACTION_DOWN:
59 | resetState(); //防止没有接收到cancel或者up
60 | mPreMotionEvent = MotionEvent.obtain(event);
61 | updateStateByEvent(event);
62 | break;
63 | case MotionEvent.ACTION_MOVE:
64 | mGestureInProgress = mListener.onMoveBegin(this);
65 | break;
66 | }
67 | }
68 |
69 | @Override
70 | protected void updateStateByEvent(MotionEvent event) {
71 |
72 |
73 | final MotionEvent prev = mPreMotionEvent;
74 |
75 | mPrePointF = caculateFocalPointer(prev);
76 | mCurrentPointF = caculateFocalPointer(event);
77 |
78 | //Log.e("TAG", mPrePointer.toString() + " , " + mCurrentPointer);
79 |
80 | boolean mSkipThisMoveEvent = prev.getPointerCount() != event.getPointerCount();
81 |
82 | //Log.e("TAG", "mSkipThisMoveEvent = " + mSkipThisMoveEvent);
83 | mExtenalPointer.x = mSkipThisMoveEvent ? 0 : mCurrentPointF.x - mPrePointF.x;
84 | mExtenalPointer.y = mSkipThisMoveEvent ? 0 : mCurrentPointF.y - mPrePointF.y;
85 |
86 | }
87 |
88 | private PointF caculateFocalPointer(MotionEvent event) {
89 | final int count = event.getPointerCount();
90 | float x = 0, y = 0;
91 | for (int i = 0; i < count; i++) {
92 | x += event.getX(i);
93 | y += event.getY(i);
94 | }
95 |
96 | x /= count;
97 | y /= count;
98 |
99 | return new PointF(x, y);
100 | }
101 |
102 |
103 | public float getMoveX() {
104 | return mExtenalPointer.x;
105 |
106 | }
107 |
108 | public float getMoveY() {
109 | return mExtenalPointer.y;
110 | }
111 |
112 | public static class SimpleMoveGestureDetector implements onMoveGestureListener {
113 |
114 | @Override
115 | public boolean onMoveBegin(MoveGestureDetector detector) {
116 | return true;
117 | }
118 |
119 | @Override
120 | public boolean onMove(MoveGestureDetector detector) {
121 | return false;
122 | }
123 |
124 | @Override
125 | public void onMoveEnd(MoveGestureDetector detector) {
126 | }
127 | }
128 |
129 | }
130 |
--------------------------------------------------------------------------------
/uilib/src/main/java/com/brioal/uilib/largeimagedisplay/onMoveGestureListener.java:
--------------------------------------------------------------------------------
1 | package com.brioal.uilib.largeimagedisplay;
2 |
3 | /**
4 | * 手势移动监听器
5 | * Created by brioal on 16-7-26.
6 | */
7 |
8 | public interface onMoveGestureListener {
9 | boolean onMoveBegin(MoveGestureDetector detector);
10 |
11 | boolean onMove(MoveGestureDetector detector);
12 |
13 | void onMoveEnd(MoveGestureDetector detector);
14 | }
15 |
--------------------------------------------------------------------------------
/uilib/src/main/java/com/brioal/uilib/paintboard/PaintBoard.java:
--------------------------------------------------------------------------------
1 | package com.brioal.uilib.paintboard;
2 |
3 | import android.content.Context;
4 | import android.content.res.TypedArray;
5 | import android.graphics.Canvas;
6 | import android.graphics.Paint;
7 | import android.graphics.Path;
8 | import android.util.AttributeSet;
9 | import android.view.MotionEvent;
10 | import android.view.View;
11 |
12 | import com.brioal.baselib.util.SizeUtil;
13 | import com.brioal.uilib.R;
14 |
15 | /**
16 | * 画板
17 | * Created by brioal on 16-7-28.
18 | */
19 |
20 | public class PaintBoard extends View {
21 | private int mBoardColor; //画板颜色
22 | private int mPaintColor; //画笔颜色
23 | private int mPaintStrike; //画笔宽度
24 |
25 | private Paint mPaint;
26 | private Path mPath;
27 |
28 |
29 | public PaintBoard(Context context) {
30 | this(context, null);
31 | }
32 |
33 | public PaintBoard(Context context, AttributeSet attrs) {
34 | super(context, attrs);
35 | obtainStyledAttr(attrs);
36 | init();
37 | }
38 |
39 | private void init() {
40 | mPaint = new Paint();
41 | mPaint.setAntiAlias(true);
42 | mPaint.setDither(true);
43 | mPaint.setColor(mPaintColor);
44 | mPaint.setStrokeWidth(mPaintStrike);
45 | mPaint.setStyle(Paint.Style.STROKE);
46 |
47 | mPath = new Path();
48 |
49 | setBackgroundColor(mBoardColor);
50 | }
51 |
52 | private void obtainStyledAttr(AttributeSet attrs) {
53 | TypedArray array = null;
54 | try {
55 | array = getContext().obtainStyledAttributes(attrs, R.styleable.PaintBoard);
56 | mBoardColor = array.getColor(R.styleable.PaintBoard_paintBoardColor, getResources().getColor(R.color.colorWhite));
57 | mPaintColor = array.getColor(R.styleable.PaintBoard_paintPaintColor, getResources().getColor(R.color.colorLightBlack));
58 | mPaintStrike = (int) array.getDimension(R.styleable.PaintBoard_paintPaintStrike, SizeUtil.Sp2Px(getContext(), 2));
59 | } catch (Exception e) {
60 | e.printStackTrace();
61 | } finally {
62 | if (array != null) {
63 | array.recycle();
64 | }
65 | }
66 | }
67 |
68 | @Override
69 | public boolean onTouchEvent(MotionEvent event) {
70 | int action = event.getAction();
71 | float x = event.getX();
72 | float y = event.getY();
73 | switch (action) {
74 | case MotionEvent.ACTION_DOWN:
75 | mPath.moveTo(x, y);
76 | break;
77 | case MotionEvent.ACTION_MOVE:
78 | mPath.lineTo(x, y);
79 | break;
80 | }
81 | invalidate();
82 | return true;
83 | }
84 |
85 | @Override
86 | protected void onDraw(Canvas canvas) {
87 | super.onDraw(canvas);
88 | canvas.drawPath(mPath, mPaint);
89 | }
90 | }
91 |
--------------------------------------------------------------------------------
/uilib/src/main/java/com/brioal/uilib/tagview/TagView.java:
--------------------------------------------------------------------------------
1 | package com.brioal.uilib.tagview;
2 |
3 | import android.content.Context;
4 | import android.graphics.Canvas;
5 | import android.graphics.Color;
6 | import android.graphics.Paint;
7 | import android.graphics.RectF;
8 | import android.util.AttributeSet;
9 | import android.widget.TextView;
10 |
11 | import com.brioal.uilib.R;
12 |
13 |
14 | /**
15 | * 一个带边框的TextView
16 | * Created by Brioal on 2016/5/19.
17 | */
18 |
19 | public class TagView extends TextView {
20 | private Paint mPaint;
21 | private int mWidth;
22 | private int mHeight;
23 | private int mStrikeWidth;
24 | private int mColor;
25 | private boolean isChecked = false;
26 |
27 | public TagView(Context context) {
28 | this(context, null);
29 | }
30 |
31 | public TagView(Context context, AttributeSet attrs) {
32 | super(context, attrs);
33 | }
34 |
35 | @Override
36 | protected void onSizeChanged(int w, int h, int oldw, int oldh) {
37 | super.onSizeChanged(w, h, oldw, oldh);
38 | mWidth = w;
39 | mHeight = h;
40 | mStrikeWidth = 2;
41 | mColor = getContext().getResources().getColor(R.color.colorPrimary);
42 |
43 | mPaint = new Paint();
44 | mPaint.setAntiAlias(true);
45 | mPaint.setDither(true);
46 | mPaint.setColor(mColor);
47 | mPaint.setStyle(Paint.Style.STROKE);
48 | mPaint.setStrokeWidth(mStrikeWidth);
49 |
50 | }
51 |
52 | public void setChecked(boolean checked) {
53 | isChecked = checked;
54 | if (checked) {
55 | setTextColor(Color.WHITE);
56 | setBackgroundColor(getContext().getResources().getColor(R.color.colorPrimary));
57 | } else {
58 | setTextColor(Color.BLACK);
59 | setBackgroundColor(Color.WHITE);
60 | }
61 | }
62 |
63 | public boolean isChecked() {
64 | return isChecked;
65 | }
66 |
67 | @Override
68 | protected void onDraw(Canvas canvas) {
69 |
70 | super.onDraw(canvas);
71 | canvas.drawRoundRect(new RectF(mStrikeWidth, mStrikeWidth, mWidth - mStrikeWidth, mHeight - mStrikeWidth), 5, 5, mPaint);
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/uilib/src/main/res/drawable/selector_bgabanner_point.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | -
4 |
5 |
6 |
7 |
8 |
9 | -
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/uilib/src/main/res/layout/ui_test.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
12 |
--------------------------------------------------------------------------------
/uilib/src/main/res/values/ids.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/uilib/src/main/res/values/paint_board_attr.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/uilib/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | UILib
3 |
4 |
--------------------------------------------------------------------------------
/uilib/src/main/res/values/watch_board_attrs.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 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/uilib/src/test/java/com/brioal/uilib/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.brioal.uilib;
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 | }
--------------------------------------------------------------------------------