From 9ae42aaeb44e428f1209269bab4543247777305c Mon Sep 17 00:00:00 2001 From: Mr_Worldwide <1905563644@qq.com> Date: Thu, 22 Mar 2018 09:18:11 +0800 Subject: [PATCH] src\MyApplication\.idea\sonarlint\issuestore\5\4\5407486fb05ebaf77ee187807ac7fbb8cb42de8a src\MyApplication\.idea\sonarlint\issuestore\5\5\55a10cdfd1735580de467639a7fadbfa2db674ba src\MyApplication\.idea\sonarlint\issuestore\7\f\7fc1f946c8e0fc0221c21f1cb84787e5b2965d9a src\MyApplication\.idea\sonarlint\issuestore\8\e\8e104bc4be91ecea7d96ed093e7eefd2be1a136c src\MyApplication\.idea\sonarlint\issuestore\a\2\a2cac54ed6169d41dc3d4fe37b5f3594fabd1e9d src\MyApplication\.idea\sonarlint\issuestore\d\2\d2c92a556e47fd0e9a3fa038dbf835129e2f5090 src\MyApplication\.idea\sonarlint\issuestore\d\5\d55eada2cdd2dd102362d485231d9b377995b0b0 src\MyApplication\.idea\sonarlint\issuestore\index.pb src\MyApplication\app\build.gradle src\MyApplication\app\src\main\java\com\example\administrator\myapplication\ui\WelcomeActivity.java src\MyApplication\build.gradle src\MyApplication\.idea\sonarlint\issuestore\0\0\00ede12c640622790c9816ae6766f38a949ed3bd src\MyApplication\.idea\sonarlint\issuestore\0\3\037b293928bff3f763d72038512124d16aebd627 src\MyApplication\.idea\sonarlint\issuestore\0\e\0eb5e393710f19bb3d38d5884bfea90461e2f527 src\MyApplication\.idea\sonarlint\issuestore\1\7\17acf378acdba9698dfb6d704084bcd18706d372 src\MyApplication\.idea\sonarlint\issuestore\3\4\342c9edfd27db16bba3e3455e68c749d04c55cbd src\MyApplication\.idea\sonarlint\issuestore\3\6\36c3f609a5d93035486e7c295cd723418b0f089e src\MyApplication\.idea\sonarlint\issuestore\3\7\37269061f6dc97247d4050e30277a569050f1b3d src\MyApplication\.idea\sonarlint\issuestore\4\8\487d5149cb35c7a7667af03d218f63298d21b1f0 src\MyApplication\.idea\sonarlint\issuestore\5\7\57c831202760b4842bfc3ee5ac2511ebb0122f9e src\MyApplication\.idea\sonarlint\issuestore\5\b\5b0e24b16ee3b9a006718e6880c3eb1eeff4d105 src\MyApplication\.idea\sonarlint\issuestore\6\2\623bf4dae8f8d83b8faa2b618d5550b1a37e5683 src\MyApplication\.idea\sonarlint\issuestore\6\5\655e5da5fa53bd4a676fde93415f3962c6841a5c src\MyApplication\.idea\sonarlint\issuestore\6\5\65764ff37783669e71501692a607a3cea49c4bdc src\MyApplication\.idea\sonarlint\issuestore\6\7\67ee5a70c0947c6377cf1e29856f6a79659f84e7 src\MyApplication\.idea\sonarlint\issuestore\8\5\859e5ebe76cd38bc36ca8379efb50fa9654aada0 src\MyApplication\.idea\sonarlint\issuestore\9\2\92cf1c7de3acc98eba6f939165f0bb2683705fcf src\MyApplication\.idea\sonarlint\issuestore\9\5\954e8115c9434902b13d9840c149e0ff3fe59df2 src\MyApplication\.idea\sonarlint\issuestore\9\e\9ea0176c0b7c2596ee3a138d5aafcdb83764d0f4 src\MyApplication\.idea\sonarlint\issuestore\9\f\9fbe46e342a1ff27349384d89b44b286ccf531a3 src\MyApplication\.idea\sonarlint\issuestore\a\0\a02bf92a1675ea96231995a8137b01dd95f322ae src\MyApplication\.idea\sonarlint\issuestore\a\6\a6e0067cc06ea7f07e5e3c87e060a04c54f022e7 src\MyApplication\.idea\sonarlint\issuestore\a\a\aa2f43374bddf98bfc4aea5a398fe877e5337db3 src\MyApplication\.idea\sonarlint\issuestore\b\3\b395e8da890bfdf6daeefc467704d4b30eac2ea4 src\MyApplication\.idea\sonarlint\issuestore\b\f\bf99366384db0ccf7ec0367c3aa4412c93f2a9bb src\MyApplication\.idea\sonarlint\issuestore\c\5\c5ce6afdb0606af7b3aad034a3799dc44d4d4c5c src\MyApplication\.idea\sonarlint\issuestore\d\c\dceb451ef5f82cbe33558978d2a79abc27fb6fe0 src\MyApplication\.idea\sonarlint\issuestore\f\8\f8d5ad2e69267983911206328e3836505144d8db src\MyApplication\.idea\sonarlint\issuestore\f\d\fd0acbc65b4f2ecc0ae0379155f8cab404805cfb src\MyApplication\app\src\main\java\com\example\administrator\myapplication\adapter\BgPicGridAdapter.java src\MyApplication\app\src\main\java\com\example\administrator\myapplication\adapter\NotebookAdapter.java src\MyApplication\app\src\main\java\com\example\administrator\myapplication\app\BaseApplication.java src\MyApplication\app\src\main\java\com\example\administrator\myapplication\db\DatabaseHelper.java src\MyApplication\app\src\main\java\com\example\administrator\myapplication\db\NoteDatabase.java src\MyApplication\app\src\main\java\com\example\administrator\myapplication\entity\BgPicEntity.java src\MyApplication\app\src\main\java\com\example\administrator\myapplication\entity\Entity.java src\MyApplication\app\src\main\java\com\example\administrator\myapplication\entity\NotebookData.java src\MyApplication\app\src\main\java\com\example\administrator\myapplication\entity\OnResponseListener.java src\MyApplication\app\src\main\java\com\example\administrator\myapplication\entity\Response.java src\MyApplication\app\src\main\java\com\example\administrator\myapplication\entity\UpdataEvent.java src\MyApplication\app\src\main\java\com\example\administrator\myapplication\entity\User.java src\MyApplication\app\src\main\java\com\example\administrator\myapplication\utils\AccountUtils.java src\MyApplication\app\src\main\java\com\example\administrator\myapplication\utils\BmobConstants.java src\MyApplication\app\src\main\java\com\example\administrator\myapplication\utils\CommonUtils.java src\MyApplication\app\src\main\java\com\example\administrator\myapplication\utils\Constants.java src\MyApplication\app\src\main\java\com\example\administrator\myapplication\utils\DialogHelp.java src\MyApplication\app\src\main\java\com\example\administrator\myapplication\utils\HTQAnimations.java src\MyApplication\app\src\main\java\com\example\administrator\myapplication\utils\ImageLoadOptions.java src\MyApplication\app\src\main\java\com\example\administrator\myapplication\utils\MD5Util.java src\MyApplication\app\src\main\java\com\example\administrator\myapplication\utils\PhotoUtil.java src\MyApplication\app\src\main\java\com\example\administrator\myapplication\utils\ResourceParser.java src\MyApplication\app\src\main\java\com\example\administrator\myapplication\utils\SPUtils.java src\MyApplication\app\src\main\java\com\example\administrator\myapplication\utils\StringUtils.java src\MyApplication\app\src\main\java\com\example\administrator\myapplication\utils\SystemUtils.java src\MyApplication\app\src\main\java\com\example\administrator\myapplication\utils\TimeZoneUtil.java --- .../00ede12c640622790c9816ae6766f38a949ed3bd | 6 + .../037b293928bff3f763d72038512124d16aebd627 | 9 + .../0eb5e393710f19bb3d38d5884bfea90461e2f527 | 4 + .../17acf378acdba9698dfb6d704084bcd18706d372 | 3 + .../342c9edfd27db16bba3e3455e68c749d04c55cbd | 9 + .../36c3f609a5d93035486e7c295cd723418b0f089e | 4 + .../37269061f6dc97247d4050e30277a569050f1b3d | 6 + .../487d5149cb35c7a7667af03d218f63298d21b1f0 | 8 + .../5407486fb05ebaf77ee187807ac7fbb8cb42de8a | 4 +- .../55a10cdfd1735580de467639a7fadbfa2db674ba | 14 +- .../57c831202760b4842bfc3ee5ac2511ebb0122f9e | 10 + .../5b0e24b16ee3b9a006718e6880c3eb1eeff4d105 | 4 + .../623bf4dae8f8d83b8faa2b618d5550b1a37e5683 | 5 + .../655e5da5fa53bd4a676fde93415f3962c6841a5c | 3 + .../65764ff37783669e71501692a607a3cea49c4bdc | 10 + .../67ee5a70c0947c6377cf1e29856f6a79659f84e7 | 24 + .../7fc1f946c8e0fc0221c21f1cb84787e5b2965d9a | 4 +- .../859e5ebe76cd38bc36ca8379efb50fa9654aada0 | 11 + .../8e104bc4be91ecea7d96ed093e7eefd2be1a136c | 28 +- .../92cf1c7de3acc98eba6f939165f0bb2683705fcf | 2 + .../954e8115c9434902b13d9840c149e0ff3fe59df2 | 7 + .../9ea0176c0b7c2596ee3a138d5aafcdb83764d0f4 | 2 + .../9fbe46e342a1ff27349384d89b44b286ccf531a3 | 43 ++ .../a02bf92a1675ea96231995a8137b01dd95f322ae | 36 ++ .../a2cac54ed6169d41dc3d4fe37b5f3594fabd1e9d | 8 +- .../a6e0067cc06ea7f07e5e3c87e060a04c54f022e7 | 2 + .../aa2f43374bddf98bfc4aea5a398fe877e5337db3 | 3 + .../b395e8da890bfdf6daeefc467704d4b30eac2ea4 | 6 + .../bf99366384db0ccf7ec0367c3aa4412c93f2a9bb | 7 + .../c5ce6afdb0606af7b3aad034a3799dc44d4d4c5c | 32 + .../d2c92a556e47fd0e9a3fa038dbf835129e2f5090 | 8 +- .../d55eada2cdd2dd102362d485231d9b377995b0b0 | 36 +- .../dceb451ef5f82cbe33558978d2a79abc27fb6fe0 | 0 .../f8d5ad2e69267983911206328e3836505144d8db | 0 .../fd0acbc65b4f2ecc0ae0379155f8cab404805cfb | 2 + .../.idea/sonarlint/issuestore/index.pb | 62 +- src/MyApplication/app/build.gradle | 27 +- .../adapter/BgPicGridAdapter.java | 91 +++ .../adapter/NotebookAdapter.java | 160 +++++ .../myapplication/app/BaseApplication.java | 59 ++ .../myapplication/db/DatabaseHelper.java | 37 ++ .../myapplication/db/NoteDatabase.java | 180 ++++++ .../myapplication/entity/BgPicEntity.java | 8 + .../myapplication/entity/Entity.java | 32 + .../myapplication/entity/NotebookData.java | 245 +++++++ .../entity/OnResponseListener.java | 17 + .../myapplication/entity/Response.java | 59 ++ .../myapplication/entity/UpdataEvent.java | 29 + .../myapplication/entity/User.java | 298 +++++++++ .../myapplication/ui/WelcomeActivity.java | 81 ++- .../myapplication/utils/AccountUtils.java | 110 ++++ .../myapplication/utils/BmobConstants.java | 39 ++ .../myapplication/utils/CommonUtils.java | 54 ++ .../myapplication/utils/Constants.java | 15 + .../myapplication/utils/DialogHelp.java | 124 ++++ .../myapplication/utils/HTQAnimations.java | 189 ++++++ .../myapplication/utils/ImageLoadOptions.java | 42 ++ .../myapplication/utils/MD5Util.java | 46 ++ .../myapplication/utils/PhotoUtil.java | 300 +++++++++ .../myapplication/utils/ResourceParser.java | 40 ++ .../myapplication/utils/SPUtils.java | 195 ++++++ .../myapplication/utils/StringUtils.java | 598 ++++++++++++++++++ .../myapplication/utils/SystemUtils.java | 225 +++++++ .../myapplication/utils/TimeZoneUtil.java | 40 ++ src/MyApplication/build.gradle | 2 +- 65 files changed, 3702 insertions(+), 62 deletions(-) create mode 100644 src/MyApplication/.idea/sonarlint/issuestore/0/0/00ede12c640622790c9816ae6766f38a949ed3bd create mode 100644 src/MyApplication/.idea/sonarlint/issuestore/0/3/037b293928bff3f763d72038512124d16aebd627 create mode 100644 src/MyApplication/.idea/sonarlint/issuestore/0/e/0eb5e393710f19bb3d38d5884bfea90461e2f527 create mode 100644 src/MyApplication/.idea/sonarlint/issuestore/1/7/17acf378acdba9698dfb6d704084bcd18706d372 create mode 100644 src/MyApplication/.idea/sonarlint/issuestore/3/4/342c9edfd27db16bba3e3455e68c749d04c55cbd create mode 100644 src/MyApplication/.idea/sonarlint/issuestore/3/6/36c3f609a5d93035486e7c295cd723418b0f089e create mode 100644 src/MyApplication/.idea/sonarlint/issuestore/3/7/37269061f6dc97247d4050e30277a569050f1b3d create mode 100644 src/MyApplication/.idea/sonarlint/issuestore/4/8/487d5149cb35c7a7667af03d218f63298d21b1f0 create mode 100644 src/MyApplication/.idea/sonarlint/issuestore/5/7/57c831202760b4842bfc3ee5ac2511ebb0122f9e create mode 100644 src/MyApplication/.idea/sonarlint/issuestore/5/b/5b0e24b16ee3b9a006718e6880c3eb1eeff4d105 create mode 100644 src/MyApplication/.idea/sonarlint/issuestore/6/2/623bf4dae8f8d83b8faa2b618d5550b1a37e5683 create mode 100644 src/MyApplication/.idea/sonarlint/issuestore/6/5/655e5da5fa53bd4a676fde93415f3962c6841a5c create mode 100644 src/MyApplication/.idea/sonarlint/issuestore/6/5/65764ff37783669e71501692a607a3cea49c4bdc create mode 100644 src/MyApplication/.idea/sonarlint/issuestore/6/7/67ee5a70c0947c6377cf1e29856f6a79659f84e7 create mode 100644 src/MyApplication/.idea/sonarlint/issuestore/8/5/859e5ebe76cd38bc36ca8379efb50fa9654aada0 create mode 100644 src/MyApplication/.idea/sonarlint/issuestore/9/2/92cf1c7de3acc98eba6f939165f0bb2683705fcf create mode 100644 src/MyApplication/.idea/sonarlint/issuestore/9/5/954e8115c9434902b13d9840c149e0ff3fe59df2 create mode 100644 src/MyApplication/.idea/sonarlint/issuestore/9/e/9ea0176c0b7c2596ee3a138d5aafcdb83764d0f4 create mode 100644 src/MyApplication/.idea/sonarlint/issuestore/9/f/9fbe46e342a1ff27349384d89b44b286ccf531a3 create mode 100644 src/MyApplication/.idea/sonarlint/issuestore/a/0/a02bf92a1675ea96231995a8137b01dd95f322ae create mode 100644 src/MyApplication/.idea/sonarlint/issuestore/a/6/a6e0067cc06ea7f07e5e3c87e060a04c54f022e7 create mode 100644 src/MyApplication/.idea/sonarlint/issuestore/a/a/aa2f43374bddf98bfc4aea5a398fe877e5337db3 create mode 100644 src/MyApplication/.idea/sonarlint/issuestore/b/3/b395e8da890bfdf6daeefc467704d4b30eac2ea4 create mode 100644 src/MyApplication/.idea/sonarlint/issuestore/b/f/bf99366384db0ccf7ec0367c3aa4412c93f2a9bb create mode 100644 src/MyApplication/.idea/sonarlint/issuestore/c/5/c5ce6afdb0606af7b3aad034a3799dc44d4d4c5c create mode 100644 src/MyApplication/.idea/sonarlint/issuestore/d/c/dceb451ef5f82cbe33558978d2a79abc27fb6fe0 create mode 100644 src/MyApplication/.idea/sonarlint/issuestore/f/8/f8d5ad2e69267983911206328e3836505144d8db create mode 100644 src/MyApplication/.idea/sonarlint/issuestore/f/d/fd0acbc65b4f2ecc0ae0379155f8cab404805cfb create mode 100644 src/MyApplication/app/src/main/java/com/example/administrator/myapplication/adapter/BgPicGridAdapter.java create mode 100644 src/MyApplication/app/src/main/java/com/example/administrator/myapplication/adapter/NotebookAdapter.java create mode 100644 src/MyApplication/app/src/main/java/com/example/administrator/myapplication/app/BaseApplication.java create mode 100644 src/MyApplication/app/src/main/java/com/example/administrator/myapplication/db/DatabaseHelper.java create mode 100644 src/MyApplication/app/src/main/java/com/example/administrator/myapplication/db/NoteDatabase.java create mode 100644 src/MyApplication/app/src/main/java/com/example/administrator/myapplication/entity/BgPicEntity.java create mode 100644 src/MyApplication/app/src/main/java/com/example/administrator/myapplication/entity/Entity.java create mode 100644 src/MyApplication/app/src/main/java/com/example/administrator/myapplication/entity/NotebookData.java create mode 100644 src/MyApplication/app/src/main/java/com/example/administrator/myapplication/entity/OnResponseListener.java create mode 100644 src/MyApplication/app/src/main/java/com/example/administrator/myapplication/entity/Response.java create mode 100644 src/MyApplication/app/src/main/java/com/example/administrator/myapplication/entity/UpdataEvent.java create mode 100644 src/MyApplication/app/src/main/java/com/example/administrator/myapplication/entity/User.java create mode 100644 src/MyApplication/app/src/main/java/com/example/administrator/myapplication/utils/AccountUtils.java create mode 100644 src/MyApplication/app/src/main/java/com/example/administrator/myapplication/utils/BmobConstants.java create mode 100644 src/MyApplication/app/src/main/java/com/example/administrator/myapplication/utils/CommonUtils.java create mode 100644 src/MyApplication/app/src/main/java/com/example/administrator/myapplication/utils/Constants.java create mode 100644 src/MyApplication/app/src/main/java/com/example/administrator/myapplication/utils/DialogHelp.java create mode 100644 src/MyApplication/app/src/main/java/com/example/administrator/myapplication/utils/HTQAnimations.java create mode 100644 src/MyApplication/app/src/main/java/com/example/administrator/myapplication/utils/ImageLoadOptions.java create mode 100644 src/MyApplication/app/src/main/java/com/example/administrator/myapplication/utils/MD5Util.java create mode 100644 src/MyApplication/app/src/main/java/com/example/administrator/myapplication/utils/PhotoUtil.java create mode 100644 src/MyApplication/app/src/main/java/com/example/administrator/myapplication/utils/ResourceParser.java create mode 100644 src/MyApplication/app/src/main/java/com/example/administrator/myapplication/utils/SPUtils.java create mode 100644 src/MyApplication/app/src/main/java/com/example/administrator/myapplication/utils/StringUtils.java create mode 100644 src/MyApplication/app/src/main/java/com/example/administrator/myapplication/utils/SystemUtils.java create mode 100644 src/MyApplication/app/src/main/java/com/example/administrator/myapplication/utils/TimeZoneUtil.java diff --git a/src/MyApplication/.idea/sonarlint/issuestore/0/0/00ede12c640622790c9816ae6766f38a949ed3bd b/src/MyApplication/.idea/sonarlint/issuestore/0/0/00ede12c640622790c9816ae6766f38a949ed3bd new file mode 100644 index 0000000..f02f68f --- /dev/null +++ b/src/MyApplication/.idea/sonarlint/issuestore/0/0/00ede12c640622790c9816ae6766f38a949ed3bd @@ -0,0 +1,6 @@ + +O squid:S1118":Add a private constructor to hide the implicit public one.( +s squid:S1488"YImmediately return this expression instead of assigning it to the temporary variable "s".( += squid:S1148"#Use a logger to log this exception.(ԅ +t squid:S1149"_Replace the synchronized class "StringBuffer" by an unsynchronized one such as "StringBuilder".( +i squid:S00100"NRename this method name to match the regular expression '^[a-z][a-zA-Z0-9]*$'.( \ No newline at end of file diff --git a/src/MyApplication/.idea/sonarlint/issuestore/0/3/037b293928bff3f763d72038512124d16aebd627 b/src/MyApplication/.idea/sonarlint/issuestore/0/3/037b293928bff3f763d72038512124d16aebd627 new file mode 100644 index 0000000..931004c --- /dev/null +++ b/src/MyApplication/.idea/sonarlint/issuestore/0/3/037b293928bff3f763d72038512124d16aebd627 @@ -0,0 +1,9 @@ + +L squid:S1135"2Complete the task associated to this TODO comment.( +L squid:S1135"2Complete the task associated to this TODO comment.( +csquid:CallToDeprecatedMethod"=Remove this use of "setBackgroundDrawable"; it is deprecated.( +L squid:S1135"2Complete the task associated to this TODO comment.( +L squid:S1135"2Complete the task associated to this TODO comment.( +> squid:S1659"*Declare "backgroundIv" on a separate line.( +b squid:S1226"HIntroduce a new variable instead of reusing the parameter "convertView".(٨ +r squid:S1450"]Remove the "mDefaultBgPath" field and declare it as a local variable in the relevant methods.( \ No newline at end of file diff --git a/src/MyApplication/.idea/sonarlint/issuestore/0/e/0eb5e393710f19bb3d38d5884bfea90461e2f527 b/src/MyApplication/.idea/sonarlint/issuestore/0/e/0eb5e393710f19bb3d38d5884bfea90461e2f527 new file mode 100644 index 0000000..6e846fd --- /dev/null +++ b/src/MyApplication/.idea/sonarlint/issuestore/0/e/0eb5e393710f19bb3d38d5884bfea90461e2f527 @@ -0,0 +1,4 @@ + +hsquid:ModifiersOrderCheck"EReorder the modifiers to comply with the Java Language Specification.( +T squid:S1118":Add a private constructor to hide the implicit public one.( +O squid:S1118":Add a private constructor to hide the implicit public one.(ڦ \ No newline at end of file diff --git a/src/MyApplication/.idea/sonarlint/issuestore/1/7/17acf378acdba9698dfb6d704084bcd18706d372 b/src/MyApplication/.idea/sonarlint/issuestore/1/7/17acf378acdba9698dfb6d704084bcd18706d372 new file mode 100644 index 0000000..8d67c1d --- /dev/null +++ b/src/MyApplication/.idea/sonarlint/issuestore/1/7/17acf378acdba9698dfb6d704084bcd18706d372 @@ -0,0 +1,3 @@ + +{"squid:ClassVariableVisibilityCheck"PMake path a static final constant or non-public and provide accessors if needed.(? +~"squid:ClassVariableVisibilityCheck"RMake bitmap a static final constant or non-public and provide accessors if needed.( \ No newline at end of file diff --git a/src/MyApplication/.idea/sonarlint/issuestore/3/4/342c9edfd27db16bba3e3455e68c749d04c55cbd b/src/MyApplication/.idea/sonarlint/issuestore/3/4/342c9edfd27db16bba3e3455e68c749d04c55cbd new file mode 100644 index 0000000..fb6d4a9 --- /dev/null +++ b/src/MyApplication/.idea/sonarlint/issuestore/3/4/342c9edfd27db16bba3e3455e68c749d04c55cbd @@ -0,0 +1,9 @@ + +v squid:S3008"\Rename this field "BMOB_PICTURE_PATH" to match the regular expression '^[a-z][a-zA-Z0-9]*$'.(Ә +Q squid:S1444"7Make this "public static BMOB_PICTURE_PATH" field final(Ә +"squid:ClassVariableVisibilityCheck"WMake MyAvatarDir a static final constant or non-public and provide accessors if needed.( +T squid:S1118":Add a private constructor to hide the implicit public one.(׼ +F squid:S1444"1Make this "public static MyAvatarDir" field final( +G squid:S1135"2Complete the task associated to this TODO comment.( +"squid:ClassVariableVisibilityCheck"]Make BMOB_PICTURE_PATH a static final constant or non-public and provide accessors if needed.(Ә +k squid:S3008"VRename this field "MyAvatarDir" to match the regular expression '^[a-z][a-zA-Z0-9]*$'.( \ No newline at end of file diff --git a/src/MyApplication/.idea/sonarlint/issuestore/3/6/36c3f609a5d93035486e7c295cd723418b0f089e b/src/MyApplication/.idea/sonarlint/issuestore/3/6/36c3f609a5d93035486e7c295cd723418b0f089e new file mode 100644 index 0000000..338313b --- /dev/null +++ b/src/MyApplication/.idea/sonarlint/issuestore/3/6/36c3f609a5d93035486e7c295cd723418b0f089e @@ -0,0 +1,4 @@ + +msquid:ModifiersOrderCheck"EReorder the modifiers to comply with the Java Language Specification.( +hsquid:ModifiersOrderCheck"EReorder the modifiers to comply with the Java Language Specification.(ջ +T squid:S1118":Add a private constructor to hide the implicit public one.( \ No newline at end of file diff --git a/src/MyApplication/.idea/sonarlint/issuestore/3/7/37269061f6dc97247d4050e30277a569050f1b3d b/src/MyApplication/.idea/sonarlint/issuestore/3/7/37269061f6dc97247d4050e30277a569050f1b3d new file mode 100644 index 0000000..516a4f1 --- /dev/null +++ b/src/MyApplication/.idea/sonarlint/issuestore/3/7/37269061f6dc97247d4050e30277a569050f1b3d @@ -0,0 +1,6 @@ + +I squid:S1066"/Merge this if statement with the enclosing one.( +V squid:S1126"AReplace this if-then-else statement by a single return statement.(׭ + squid:S1598"This file "CommonUtils.java" should be located in "com\htq\baidu\coolnote\utils" directory, not in "Y:\ProjectFile\MyApplication\app\src\main\java\com\example\administrator\myapplication\utils".(̖ +D squid:S1066"/Merge this if statement with the enclosing one.( +O squid:S1118":Add a private constructor to hide the implicit public one.( \ No newline at end of file diff --git a/src/MyApplication/.idea/sonarlint/issuestore/4/8/487d5149cb35c7a7667af03d218f63298d21b1f0 b/src/MyApplication/.idea/sonarlint/issuestore/4/8/487d5149cb35c7a7667af03d218f63298d21b1f0 new file mode 100644 index 0000000..b4d5e05 --- /dev/null +++ b/src/MyApplication/.idea/sonarlint/issuestore/4/8/487d5149cb35c7a7667af03d218f63298d21b1f0 @@ -0,0 +1,8 @@ + +`squid:CommentedOutCodeLine"Introduce a new variable instead of reusing the parameter "x".(ș -l squid:S3776"RRefactor this method to reduce its Cognitive Complexity from 17 to the 15 allowed.(ּف -n squid:S2293"YReplace the type specification in this constructor call with the diamond operator ("<>").( +Isquid:EmptyStatementUsageCheck"Remove this empty statement.( +n squid:S1450"TRemove the "moveX" field and declare it as a local variable in the relevant methods.(͠ +a squid:S2184"GCast one of the operands of this multiplication operation to a "float".( S"squid:SwitchLastCaseIsDefaultCheck""Add a default case to this switch.( T squid:S3398"?Move this method into the anonymous class declared at line 157.(ə -[ squid:S1126"AReplace this if-then-else statement by a single return statement.(ː +S squid:S1226">Introduce a new variable instead of reusing the parameter "y".(ř +l squid:S3776"RRefactor this method to reduce its Cognitive Complexity from 17 to the 15 allowed.( +p squid:S00115"ZRename this constant name to match the regular expression '^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$'.( +hsquid:MaximumInheritanceDepth"").( += squid:S1148"#Use a logger to log this exception.(ԅ g squid:S3776"RRefactor this method to reduce its Cognitive Complexity from 16 to the 15 allowed.(Ǩ Zsquid:CallToDeprecatedMethod"/Remove this use of "vibrate"; it is deprecated.( -p squid:S00115"ZRename this constant name to match the regular expression '^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$'.( -= squid:S1148"#Use a logger to log this exception.(ԅ +S squid:S1226">Introduce a new variable instead of reusing the parameter "x".(ș \ squid:S2184"GCast one of the operands of this multiplication operation to a "float".( -n squid:S1450"TRemove the "moveX" field and declare it as a local variable in the relevant methods.(͠ -Isquid:EmptyStatementUsageCheck"Remove this empty statement.( -L squid:S2589"7Remove this expression which always evaluates to "true"(ɩ -S squid:S1226">Introduce a new variable instead of reusing the parameter "y".(ř -l squid:S3776"RRefactor this method to reduce its Cognitive Complexity from 17 to the 15 allowed.( \ No newline at end of file +K squid:S2696"6Make the enclosing method "static" or remove this set.( +[ squid:S1126"AReplace this if-then-else statement by a single return statement.(ː +L squid:S2589"7Remove this expression which always evaluates to "true"(ɩ \ No newline at end of file diff --git a/src/MyApplication/.idea/sonarlint/issuestore/9/2/92cf1c7de3acc98eba6f939165f0bb2683705fcf b/src/MyApplication/.idea/sonarlint/issuestore/9/2/92cf1c7de3acc98eba6f939165f0bb2683705fcf new file mode 100644 index 0000000..6e144e9 --- /dev/null +++ b/src/MyApplication/.idea/sonarlint/issuestore/9/2/92cf1c7de3acc98eba6f939165f0bb2683705fcf @@ -0,0 +1,2 @@ + +isquid:MaximumInheritanceDepth"=This class has 10 parents which is greater than 5 authorized.( \ No newline at end of file diff --git a/src/MyApplication/.idea/sonarlint/issuestore/9/5/954e8115c9434902b13d9840c149e0ff3fe59df2 b/src/MyApplication/.idea/sonarlint/issuestore/9/5/954e8115c9434902b13d9840c149e0ff3fe59df2 new file mode 100644 index 0000000..3ebfc42 --- /dev/null +++ b/src/MyApplication/.idea/sonarlint/issuestore/9/5/954e8115c9434902b13d9840c149e0ff3fe59df2 @@ -0,0 +1,7 @@ + +[squid:CallToDeprecatedMethod"0Remove this use of "fromHtml"; it is deprecated.(˖ +y squid:S1488"_Immediately return this expression instead of assigning it to the temporary variable "builder".(à +O squid:S1118":Add a private constructor to hide the implicit public one.(բ +asquid:CallToDeprecatedMethod"6Remove this use of "ProgressDialog"; it is deprecated.( +\squid:CallToDeprecatedMethod"6Remove this use of "ProgressDialog"; it is deprecated.(ا +\squid:CallToDeprecatedMethod"6Remove this use of "ProgressDialog"; it is deprecated.(ا \ No newline at end of file diff --git a/src/MyApplication/.idea/sonarlint/issuestore/9/e/9ea0176c0b7c2596ee3a138d5aafcdb83764d0f4 b/src/MyApplication/.idea/sonarlint/issuestore/9/e/9ea0176c0b7c2596ee3a138d5aafcdb83764d0f4 new file mode 100644 index 0000000..6e5456a --- /dev/null +++ b/src/MyApplication/.idea/sonarlint/issuestore/9/e/9ea0176c0b7c2596ee3a138d5aafcdb83764d0f4 @@ -0,0 +1,2 @@ + +dsquid:MaximumInheritanceDepth"=This class has 10 parents which is greater than 5 authorized.( \ No newline at end of file diff --git a/src/MyApplication/.idea/sonarlint/issuestore/9/f/9fbe46e342a1ff27349384d89b44b286ccf531a3 b/src/MyApplication/.idea/sonarlint/issuestore/9/f/9fbe46e342a1ff27349384d89b44b286ccf531a3 new file mode 100644 index 0000000..5f6588e --- /dev/null +++ b/src/MyApplication/.idea/sonarlint/issuestore/9/f/9fbe46e342a1ff27349384d89b44b286ccf531a3 @@ -0,0 +1,43 @@ + +i squid:S1215"TDon't try to be smarter than the JVM, remove this call to run the garbage collector.(̰ += squid:S1659"#Declare "right" on a separate line.( +D squid:S2093"*Change this "try" to a try-with-resources.( +A squid:S1659"'Declare "dst_right" on a separate line.( +T squid:S1854":Remove this useless assignment to local variable "bitmap".(İ += squid:S1148"#Use a logger to log this exception.(ԅ += squid:S1148"#Use a logger to log this exception.(ԅ += squid:S1148"#Use a logger to log this exception.(ԅ +l squid:S00117"QRename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.( +] squid:S1226"CIntroduce a new variable instead of reusing the parameter "bitmap".( +[ +squid:S899"BDo something with the "boolean" value returned by "createNewFile".(А +`squid:CommentedOutCodeLine" squid:S1659"$Declare "bottom" on a separate line.( +D squid:S1066"/Merge this if statement with the enclosing one.( +L squid:S1135"2Complete the task associated to this TODO comment.(̐ +[ squid:S2184"ACast one of the operands of this division operation to a "float".( += squid:S1148"#Use a logger to log this exception.(ԅ +T squid:S1854":Remove this useless assignment to local variable "bitmap".( +[ +squid:S899"BDo something with the "boolean" value returned by "createNewFile".(А +T squid:S2184"@Cast one of the operands of this integer division to a "double".( +L squid:S1135"2Complete the task associated to this TODO comment.(̐ +Z squid:S2147"ECombine this catch with the one at line 113, which has the same body.(ﭣ +S"squid:SwitchLastCaseIsDefaultCheck""Add a default case to this switch.( += squid:S1148"#Use a logger to log this exception.(ԅ +@ squid:S1659"&Declare "dst_left" on a separate line.( \ No newline at end of file diff --git a/src/MyApplication/.idea/sonarlint/issuestore/a/0/a02bf92a1675ea96231995a8137b01dd95f322ae b/src/MyApplication/.idea/sonarlint/issuestore/a/0/a02bf92a1675ea96231995a8137b01dd95f322ae new file mode 100644 index 0000000..09af13b --- /dev/null +++ b/src/MyApplication/.idea/sonarlint/issuestore/a/0/a02bf92a1675ea96231995a8137b01dd95f322ae @@ -0,0 +1,36 @@ + +i squid:S00100"NRename this method name to match the regular expression '^[a-z][a-zA-Z0-9]*$'.( +i squid:S00100"NRename this method name to match the regular expression '^[a-z][a-zA-Z0-9]*$'.( +i squid:S00100"NRename this method name to match the regular expression '^[a-z][a-zA-Z0-9]*$'.(򟌝 +? squid:S00108")Either remove or fill this block of code.( +Rsquid:CallToDeprecatedMethod",Remove this use of "Time"; it is deprecated.( +msquid:ModifiersOrderCheck"EReorder the modifiers to comply with the Java Language Specification.(ו +Q squid:S2589"7Remove this expression which always evaluates to "true"(蘭 +s squid:S1149"_Replace the synchronized class "StringBuffer" by an unsynchronized one such as "StringBuilder".(͜ + +Rsquid:CallToDeprecatedMethod",Remove this use of "Time"; it is deprecated.( +l squid:S3776"RRefactor this method to reduce its Cognitive Complexity from 22 to the 15 allowed.( +Rsquid:CallToDeprecatedMethod",Remove this use of "Time"; it is deprecated.( +Wsquid:CallToDeprecatedMethod",Remove this use of "Date"; it is deprecated.( +Rsquid:CallToDeprecatedMethod",Remove this use of "Time"; it is deprecated.( +y squid:S1488"_Immediately return this expression instead of assigning it to the temporary variable "curDate".(Ӱؒ +Rsquid:CallToDeprecatedMethod",Remove this use of "Time"; it is deprecated.( +T squid:S1118":Add a private constructor to hide the implicit public one.(빒 +\ squid:S1226"BIntroduce a new variable instead of reusing the parameter "start".(¶ +Rsquid:CallToDeprecatedMethod",Remove this use of "Time"; it is deprecated.( +msquid:ModifiersOrderCheck"EReorder the modifiers to comply with the Java Language Specification.(Ԓ +Rsquid:CallToDeprecatedMethod",Remove this use of "Time"; it is deprecated.( +msquid:ModifiersOrderCheck"EReorder the modifiers to comply with the Java Language Specification.( +? squid:S00108")Either remove or fill this block of code.( +gsquid:ModifiersOrderCheck"EReorder the modifiers to comply with the Java Language Specification.(S += squid:S1148"#Use a logger to log this exception.(ԅ +msquid:ModifiersOrderCheck"EReorder the modifiers to comply with the Java Language Specification.(ʂ +hsquid:ModifiersOrderCheck"EReorder the modifiers to comply with the Java Language Specification.( +? squid:S00108")Either remove or fill this block of code.( += squid:S1148"#Use a logger to log this exception.(ԅ +Q squid:S2589"7Remove this expression which always evaluates to "true"(޼ +Rsquid:CallToDeprecatedMethod",Remove this use of "Time"; it is deprecated.( +? squid:S00108")Either remove or fill this block of code.(ﭣ +W squid:S1226"BIntroduce a new variable instead of reusing the parameter "start".( +T squid:S1226"?Introduce a new variable instead of reusing the parameter "is".(٥ +Z squid:S1226"@Introduce a new variable instead of reusing the parameter "num".(և \ No newline at end of file diff --git a/src/MyApplication/.idea/sonarlint/issuestore/a/2/a2cac54ed6169d41dc3d4fe37b5f3594fabd1e9d b/src/MyApplication/.idea/sonarlint/issuestore/a/2/a2cac54ed6169d41dc3d4fe37b5f3594fabd1e9d index ff6e8fb..abe01fb 100644 --- a/src/MyApplication/.idea/sonarlint/issuestore/a/2/a2cac54ed6169d41dc3d4fe37b5f3594fabd1e9d +++ b/src/MyApplication/.idea/sonarlint/issuestore/a/2/a2cac54ed6169d41dc3d4fe37b5f3594fabd1e9d @@ -1,8 +1,8 @@ +Ysquid:UnusedPrivateMethod"6Remove this unused private "ToggleButton" constructor.( msquid:ModifiersOrderCheck"EReorder the modifiers to comply with the Java Language Specification.(« @ squid:S1659"&Declare "spotMaxX" on a separate line.(ǡ -o squid:S1450"URemove the "startX" field and declare it as a local variable in the relevant methods.( +gsquid:ModifiersOrderCheck"EReorder the modifiers to comply with the Java Language Specification.( < squid:S1659""Declare "endX" on a separate line.( -Ysquid:UnusedPrivateMethod"6Remove this unused private "ToggleButton" constructor.( -hsquid:ModifiersOrderCheck"EReorder the modifiers to comply with the Java Language Specification.(Ů -gsquid:ModifiersOrderCheck"EReorder the modifiers to comply with the Java Language Specification.( \ No newline at end of file +o squid:S1450"URemove the "startX" field and declare it as a local variable in the relevant methods.( +hsquid:ModifiersOrderCheck"EReorder the modifiers to comply with the Java Language Specification.(Ů \ No newline at end of file diff --git a/src/MyApplication/.idea/sonarlint/issuestore/a/6/a6e0067cc06ea7f07e5e3c87e060a04c54f022e7 b/src/MyApplication/.idea/sonarlint/issuestore/a/6/a6e0067cc06ea7f07e5e3c87e060a04c54f022e7 new file mode 100644 index 0000000..3d8153f --- /dev/null +++ b/src/MyApplication/.idea/sonarlint/issuestore/a/6/a6e0067cc06ea7f07e5e3c87e060a04c54f022e7 @@ -0,0 +1,2 @@ + +isquid:MaximumInheritanceDepth"=This class has 10 parents which is greater than 5 authorized.(Ȣ \ No newline at end of file diff --git a/src/MyApplication/.idea/sonarlint/issuestore/a/a/aa2f43374bddf98bfc4aea5a398fe877e5337db3 b/src/MyApplication/.idea/sonarlint/issuestore/a/a/aa2f43374bddf98bfc4aea5a398fe877e5337db3 new file mode 100644 index 0000000..2e0bfef --- /dev/null +++ b/src/MyApplication/.idea/sonarlint/issuestore/a/a/aa2f43374bddf98bfc4aea5a398fe877e5337db3 @@ -0,0 +1,3 @@ + + squid:S1186"Add a nested comment explaining why this method is empty, throw an UnsupportedOperationException or complete the implementation.( +esquid:CommentedOutCodeLine"").(П +esquid:CommentedOutCodeLine"Introduce a new variable instead of reusing the parameter "v".(įY +Zsquid:UselessImportCheck"3Remove this unused import 'android.graphics.Color'.( +ksquid:UselessImportCheck"DRemove this unused import 'android.graphics.drawable.ColorDrawable'.(֟« +esquid:UselessImportCheck">Remove this unused import 'android.provider.CalendarContract'.( +s squid:S2293"YReplace the type specification in this constructor call with the diamond operator ("<>").( +\ squid:S1226"BIntroduce a new variable instead of reusing the parameter "datas".( \ No newline at end of file diff --git a/src/MyApplication/.idea/sonarlint/issuestore/c/5/c5ce6afdb0606af7b3aad034a3799dc44d4d4c5c b/src/MyApplication/.idea/sonarlint/issuestore/c/5/c5ce6afdb0606af7b3aad034a3799dc44d4d4c5c new file mode 100644 index 0000000..4095dfb --- /dev/null +++ b/src/MyApplication/.idea/sonarlint/issuestore/c/5/c5ce6afdb0606af7b3aad034a3799dc44d4d4c5c @@ -0,0 +1,32 @@ + += squid:S1481")Remove this unused "list" local variable.(̿h +`squid:UselessImportCheck">Remove this unused import 'cn.bmob.v3.listener.LogInListener'.( +msquid:ModifiersOrderCheck"EReorder the modifiers to comply with the Java Language Specification.( +hsquid:ModifiersOrderCheck"EReorder the modifiers to comply with the Java Language Specification.(χ +fsquid:UselessImportCheck"?Remove this unused import 'cn.bmob.v3.exception.BmobException'.(ƚ +L squid:S1854"8Remove this useless assignment to local variable "list".(̿h +msquid:ModifiersOrderCheck"EReorder the modifiers to comply with the Java Language Specification.( +msquid:ModifiersOrderCheck"EReorder the modifiers to comply with the Java Language Specification.( +`squid:CommentedOutCodeLine"").(̿h +msquid:ModifiersOrderCheck"EReorder the modifiers to comply with the Java Language Specification.(Ɵ +l squid:S00117"QRename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.(쇯 +esquid:CommentedOutCodeLine"").( +`squid:CommentedOutCodeLine"").( -: squid:S2068" Remove this hard-coded password.( -B squid:S1125"(Remove the literal "true" boolean value.( X squid:S1155">Use isEmpty() to check whether the collection is empty or not.(Ю -0 squid:S1643"Use a StringBuilder instead.(븈2 -F squid:S1068",Remove this unused "mContext" private field.(ž -esquid:CommentedOutCodeLine" squid:S1659"$Declare "mMoveY" on a separate line.( -o squid:S1450"URemove the "mMoveY" field and declare it as a local variable in the relevant methods.( -g squid:S3776"RRefactor this method to reduce its Cognitive Complexity from 35 to the 15 allowed.( -p squid:S1450"\Remove the "mScreenHeight" field and declare it as a local variable in the relevant methods.(ݘZ -o squid:S1450"URemove the "mMoveX" field and declare it as a local variable in the relevant methods.( +4 squid:S2131"Use "Integer.toString" instead.(ј +esquid:CommentedOutCodeLine" squid:S1659"$Declare "mMoveY" on a separate line.( +o squid:S1450"URemove the "mMoveY" field and declare it as a local variable in the relevant methods.( +F squid:S1068",Remove this unused "mContext" private field.(ž +g squid:S3776"RRefactor this method to reduce its Cognitive Complexity from 35 to the 15 allowed.( [squid:CallToDeprecatedMethod"0Remove this use of "getWidth"; it is deprecated.( -: squid:S2068" Remove this hard-coded password.(򤂛 \ No newline at end of file +S"squid:SwitchLastCaseIsDefaultCheck""Add a default case to this switch.( +Z squid:S2184"@Cast one of the operands of this integer division to a "double".(酈 +0 squid:S1643"Use a StringBuilder instead.(븈2 +D squid:S1066"/Merge this if statement with the enclosing one.(댯 +o squid:S1450"URemove the "mMoveX" field and declare it as a local variable in the relevant methods.( +esquid:CommentedOutCodeLine" bgList; + private Resources resources; + private Activity mActivity; + private String mDefaultBgPath; + private SystemUtils systemUtil; + public BgPicGridAdapter(Activity mActivity,List list) + { + this.bgList = list; + this.mActivity=mActivity; + this.resources = mActivity.getResources(); + systemUtil=new SystemUtils(mActivity); + + } + + @Override + public int getCount() { + // TODO Auto-generated method stub + return bgList.size(); + } + + @Override + public Object getItem(int position) { + // TODO Auto-generated method stub + return bgList.get(position); + } + + @Override + public long getItemId(int position) { + // TODO Auto-generated method stub + return position; + } + + + @Override + public View getView(int position, View convertView, ViewGroup parent) { + // TODO Auto-generated method stub + ViewHolder viewHolder; + if (convertView == null) { + viewHolder = new ViewHolder(); + convertView = LayoutInflater.from(mActivity).inflate( + R.layout.bg_pic_grid_item, null); + viewHolder.backgroundIv = (ImageView) convertView + .findViewById(R.id.gridview_item_iv); + viewHolder.checkedIv = (ImageView) convertView + .findViewById(R.id.gridview_item_checked_iv); + convertView.setTag(viewHolder); + } else { + viewHolder = (ViewHolder) convertView.getTag(); + } + + viewHolder.backgroundIv.setBackgroundDrawable(new BitmapDrawable( + resources, ((BgPicEntity)getItem(position)).bitmap)); + + mDefaultBgPath=systemUtil.getPath(); + if (((BgPicEntity)getItem(position)).path.equals(mDefaultBgPath)) { + viewHolder.checkedIv.setVisibility(View.VISIBLE); + } else { + viewHolder.checkedIv.setVisibility(View.GONE); + } + + return convertView; + + + } + private class ViewHolder { + ImageView checkedIv, backgroundIv; + } + + +} diff --git a/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/adapter/NotebookAdapter.java b/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/adapter/NotebookAdapter.java new file mode 100644 index 0000000..55aa5f1 --- /dev/null +++ b/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/adapter/NotebookAdapter.java @@ -0,0 +1,160 @@ +package com.example.administrator.myapplication.adapter; + +import android.app.Activity; +import android.graphics.Color; +import android.graphics.drawable.ColorDrawable; +import android.provider.CalendarContract; +import android.text.Html; +import android.view.View; +import android.view.ViewGroup; +import android.widget.BaseAdapter; +import android.widget.ImageView; +import android.widget.RelativeLayout.LayoutParams; +import android.widget.TextView; + + +import com.example.administrator.myapplication.R; +import com.example.administrator.myapplication.entity.NotebookData; +import com.example.administrator.myapplication.ui.NoteEditFragment; +import com.example.administrator.myapplication.utils.SystemUtils; +import com.example.administrator.myapplication.widget.HTQDragGridView; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + + +public class NotebookAdapter extends BaseAdapter implements HTQDragGridView.DragGridBaseAdapter { + private List datas; + private final Activity aty; + private int currentHidePosition = -1; + private final int width; + private final int height; + private boolean dataChange = false; + + public NotebookAdapter(Activity aty, List datas) { + super(); + Collections.sort(datas); + this.datas = datas; + this.aty = aty; + width = new SystemUtils(aty).getScreenW(aty) / 2; + height = (int) aty.getResources().getDimension(R.dimen.space_35); + } + + public void refurbishData(List datas) { + if (datas == null) { + datas = new ArrayList(1); + } + Collections.sort(datas); + this.datas = datas; + notifyDataSetChanged(); + } + + @Override + public int getCount() { + return datas.size(); + } + + @Override + public Object getItem(int position) { + return datas.get(position); + } + + @Override + public long getItemId(int position) { + return 0; + } + + public List getDatas() { + return datas; + } + + /** + * 数据是否发生了改变 + * + * @return + */ + public boolean getDataChange() { + return dataChange; + } + + static class ViewHolder { + TextView date; + ImageView state; + ImageView thumbtack; + View titleBar; + TextView content; + } + + @Override + public View getView(int position, View v, ViewGroup parent) { + datas.get(position).setIid(position); + NotebookData data = datas.get(position); + + ViewHolder holder = null; + if (v == null) { + holder = new ViewHolder(); + v = View.inflate(aty, R.layout.item_notebook, null); + holder.titleBar = v.findViewById(R.id.item_note_titlebar); + holder.date = (TextView) v.findViewById(R.id.item_note_tv_date); + holder.state = (ImageView) v.findViewById(R.id.item_note_img_state); + holder.thumbtack = (ImageView) v + .findViewById(R.id.item_note_img_thumbtack); + holder.content = (TextView) v.findViewById(R.id.item_note_content); + v.setTag(holder); + } else { + holder = (ViewHolder) v.getTag(); + } + LayoutParams params = (LayoutParams) holder.content + .getLayoutParams(); + params.width = width; + params.height = (params.width - height); + holder.content.setLayoutParams(params); + + holder.titleBar + .setBackgroundColor(NoteEditFragment.sTitleBackGrounds[data + .getColor()]); + holder.date.setText(data.getDate()); + if (data.getId() > 0) { + holder.state.setVisibility(View.GONE); + } else { + holder.state.setVisibility(View.VISIBLE); + } + holder.thumbtack.setImageResource(NoteEditFragment.sThumbtackImgs[data + .getColor()]); + holder.content.setText(Html.fromHtml(data.getContent())); + holder.content.setBackgroundColor(NoteEditFragment.sBackGrounds[data + .getColor()]); + if (position == currentHidePosition) { + v.setVisibility(View.GONE); + } else { + v.setVisibility(View.VISIBLE); + } + return v; + } + + @Override + public void reorderItems(int oldPosition, int newPosition) { + dataChange = true; + if (oldPosition >= datas.size() || oldPosition < 0) { + return; + } + NotebookData temp = datas.get(oldPosition); + if (oldPosition < newPosition) { + for (int i = oldPosition; i < newPosition; i++) { + Collections.swap(datas, i, i + 1); + } + } else if (oldPosition > newPosition) { + for (int i = oldPosition; i > newPosition; i--) { + Collections.swap(datas, i, i - 1); + } + } + datas.set(newPosition, temp); + } + + @Override + public void setHideItem(int hidePosition) { + this.currentHidePosition = hidePosition; + notifyDataSetChanged(); + } +} diff --git a/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/app/BaseApplication.java b/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/app/BaseApplication.java new file mode 100644 index 0000000..c36f503 --- /dev/null +++ b/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/app/BaseApplication.java @@ -0,0 +1,59 @@ +package com.example.administrator.myapplication.app; + +import android.app.Application; +import android.content.Context; + +import com.example.administrator.myapplication.utils.AccountUtils; +import com.example.administrator.myapplication.utils.BmobConstants; +import com.nostra13.universalimageloader.cache.disc.impl.UnlimitedDiscCache; +import com.nostra13.universalimageloader.cache.disc.naming.Md5FileNameGenerator; +import com.nostra13.universalimageloader.cache.memory.impl.WeakMemoryCache; +import com.nostra13.universalimageloader.core.ImageLoader; +import com.nostra13.universalimageloader.core.ImageLoaderConfiguration; +import com.nostra13.universalimageloader.core.assist.QueueProcessingType; +import com.nostra13.universalimageloader.utils.StorageUtils; + +import java.io.File; + +import cn.bmob.v3.Bmob; + +/** + * Created by htq on 2016/9/5. + */ +public class BaseApplication extends Application { + + + private String ApplicationId="d1ee9b58531115c8f6d57b1efe8b24bf"; + static public String avatarPath= BmobConstants.MyAvatarDir+"avatarIcon.png"; + @Override + public void onCreate() { + super.onCreate(); + initImageLoader(this); + Bmob.initialize(this, ApplicationId); + + } + + /** 初始化ImageLoader */ + public static void initImageLoader(Context context) { + File cacheDir = StorageUtils.getOwnCacheDirectory(context, + "beautynote/cache");// 获取到缓存的目录地址 + // 创建配置ImageLoader(所有的选项都是可选的,只使用那些你真的想定制),这个可以设定在APPLACATION里面,设置为全局的配置参数 + ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder( + context) + + // 线程池内加载的数量 + .threadPoolSize(3).threadPriority(Thread.NORM_PRIORITY - 2) + .memoryCache(new WeakMemoryCache()) + .denyCacheImageMultipleSizesInMemory() + .discCacheFileNameGenerator(new Md5FileNameGenerator()) + // 将保存的时候的URI名称用MD5 加密 + .tasksProcessingOrder(QueueProcessingType.LIFO) + .discCache(new UnlimitedDiscCache(cacheDir))// 自定义缓存路径 + // .defaultDisplayImageOptions(DisplayImageOptions.createSimple()) + .writeDebugLogs() // Remove for release app + .build(); + // Initialize ImageLoader with configuration. + ImageLoader.getInstance().init(config);// 全局初始化此配置 + } + +} diff --git a/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/db/DatabaseHelper.java b/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/db/DatabaseHelper.java new file mode 100644 index 0000000..00d5227 --- /dev/null +++ b/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/db/DatabaseHelper.java @@ -0,0 +1,37 @@ +package com.example.administrator.myapplication.db; + +import android.content.Context; +import android.database.sqlite.SQLiteDatabase; +import android.database.sqlite.SQLiteOpenHelper; + +public class DatabaseHelper extends SQLiteOpenHelper { + + public static final String COOLNOTE_DATABASE_NAME = "coolnote"; + + public static final String NOTE_TABLE_NAME = "htq_Notebook"; + + public static final String CREATE_NOTE_TABLE = "create table " + + NOTE_TABLE_NAME + + " (_id integer primary key autoincrement, objectid text, iid integer," + + " time varchar(10), date varchar(10), content text, color integer)"; + + public static final String NEWS_LIST = "osc_news_list"; + + public static final String CREATE_NEWS_LIST_TABLE = "create table " + + NOTE_TABLE_NAME + "(" + "_id integer primary key autoincrement, " + + "news_id interger, title varchar(10), " + ")"; + + public DatabaseHelper(Context context) { + super(context, COOLNOTE_DATABASE_NAME, null, 1); + } + + @Override + public void onCreate(SQLiteDatabase db) { + db.execSQL(CREATE_NOTE_TABLE); + // db.execSQL(CREATE_NEWS_LIST_TABLE); + } + + @Override + public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {} + +} \ No newline at end of file diff --git a/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/db/NoteDatabase.java b/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/db/NoteDatabase.java new file mode 100644 index 0000000..c872e61 --- /dev/null +++ b/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/db/NoteDatabase.java @@ -0,0 +1,180 @@ +package com.example.administrator.myapplication.db; + +import android.content.Context; +import android.database.Cursor; +import android.database.sqlite.SQLiteDatabase; + + +import com.htq.baidu.coolnote.entity.NotebookData; +import com.htq.baidu.coolnote.utils.AccountUtils; +import com.htq.baidu.coolnote.utils.StringUtils; + +import java.util.ArrayList; +import java.util.List; + +public class NoteDatabase { + private final DatabaseHelper dbHelper; + + public NoteDatabase(Context context) { + super(); + dbHelper = new DatabaseHelper(context); + } + + /** + * 增 + * + * @param data + */ + public void insert(NotebookData data) { + String sql = "insert into " + DatabaseHelper.NOTE_TABLE_NAME; + + sql += "(_id, objectid, iid, time, date, content, color) values(?, ?, ?, ?, ?, ?, ?)"; + + SQLiteDatabase sqlite = dbHelper.getWritableDatabase(); + sqlite.execSQL(sql, new String[] { data.getId() + "", + data.getIid() + "", data.getObjectId(), data.getUnixTime() + "", data.getDate(), + data.getContent(), data.getColor() + "" }); + sqlite.close(); + } + + /** + * 删 + * + * @param id + */ + public void delete(int id) { + SQLiteDatabase sqlite = dbHelper.getWritableDatabase(); + String sql = ("delete from " + DatabaseHelper.NOTE_TABLE_NAME + " where _id=?"); + sqlite.execSQL(sql, new Integer[] { id }); + sqlite.close(); + } + + /** + * 改 + * + * @param data + */ + public void update(NotebookData data) { + SQLiteDatabase sqlite = dbHelper.getWritableDatabase(); + String sql = ("update " + DatabaseHelper.NOTE_TABLE_NAME + " set iid=?, objectid=?, time=?, date=?, content=?, color=? where _id=?"); + sqlite.execSQL(sql, + new String[] { data.getIid() + "", data.getObjectId() + "", data.getUnixTime() + "", + data.getDate(), data.getContent(), + data.getColor() + "", data.getId() + "" }); + sqlite.close(); + } + + public List query() { + return query(" "); + } + + /** + * 查 + * + * @param where + * @return + */ + public List query(String where) { + SQLiteDatabase sqlite = dbHelper.getReadableDatabase(); + ArrayList data = null; + data = new ArrayList(); + Cursor cursor = sqlite.rawQuery("select * from " + + DatabaseHelper.NOTE_TABLE_NAME + where, null); + for (cursor.moveToFirst(); !cursor.isAfterLast(); cursor.moveToNext()) { + NotebookData notebookData = new NotebookData(); + notebookData.setId(cursor.getInt(0)); + notebookData.setObjectId(cursor.getString(1)); + notebookData.setIid(cursor.getInt(2)); + notebookData.setUnixTime(cursor.getString(3)); + notebookData.setDate(cursor.getString(4)); + notebookData.setContent(cursor.getString(5)); + notebookData.setColor(cursor.getInt(6)); + data.add(notebookData); + } + if (!cursor.isClosed()) { + cursor.close(); + } + sqlite.close(); + + return data; + } + + /** + * 重置 + * + * @param datas + */ + public void reset(List datas) { + if (datas != null) { + SQLiteDatabase sqlite = dbHelper.getWritableDatabase(); + // 删除全部 + sqlite.execSQL("delete from " + DatabaseHelper.NOTE_TABLE_NAME); + // 重新添加 + for (NotebookData data : datas) { + insert(data); + } + sqlite.close(); + } + } + + /** + * 保存一条数据到本地(若已存在则直接覆盖) + * + * @param data + */ + public void save(NotebookData data) { + List datas = query(" where _id=" + data.getId()); + if (datas != null && !datas.isEmpty()) { + update(data); + } else { + insert(data); + } + } + + // + // /** + // * 合并一条数据到本地(通过更新时间判断仅保留最新) + // * + // * @param data + // * @return 数据是否被合并了 + // */ + // public boolean merge(NotebookData data) { + // Cursor cursor = sqlite.rawQuery( + // "select * from " + DatabaseHelper.NOTE_TABLE_NAME + // + " where _id=" + data.getId(), null); + // NotebookData localData = new NotebookData(); + // // 本循环其实只执行一次 + // for (cursor.moveToFirst(); !cursor.isAfterLast(); cursor.moveToNext()) { + // localData.setId(cursor.getInt(0)); + // localData.setIid(cursor.getInt(1)); + // localData.setUnixTime(cursor.getString(2)); + // localData.setDate(cursor.getString(3)); + // localData.setContent(cursor.getString(4)); + // localData.setColor(cursor.getInt(5)); + // } + // // 是否需要合这条数据 + // boolean isMerge = localData.getUnixTime() < data.getUnixTime(); + // if (isMerge) { + // save(data); + // } + // return isMerge; + // } + + public void destroy() { + dbHelper.close(); + } + + public void insertIntroduce(Context context) + { + NotebookData editData=new NotebookData(); + if (editData.getId() == 0) { + editData.setId(-1 + * StringUtils.toInt( + StringUtils.getDataTime("dddHHmmss"), 0)); + } + editData.setUnixTime(StringUtils.getDataTime("yyyy-MM-dd HH:mm:ss")); + editData.setContent("欢迎使用颖火虫记事本,赶快记下你此刻的灵感吧!"); + editData.setUserId(AccountUtils.getUserId(context)); + save(editData); + } +} \ No newline at end of file diff --git a/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/entity/BgPicEntity.java b/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/entity/BgPicEntity.java new file mode 100644 index 0000000..147fdd4 --- /dev/null +++ b/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/entity/BgPicEntity.java @@ -0,0 +1,8 @@ +package com.example.administrator.myapplication.entity; + +import android.graphics.Bitmap; + +public class BgPicEntity { + public Bitmap bitmap; + public String path; +} diff --git a/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/entity/Entity.java b/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/entity/Entity.java new file mode 100644 index 0000000..c40e9c3 --- /dev/null +++ b/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/entity/Entity.java @@ -0,0 +1,32 @@ +//package com.htq.baidu.coolnote.entity; +// +// +//import java.io.Serializable; +// +//import cn.bmob.v3.BmobObject; +// +// +//@SuppressWarnings("serial") +//public abstract class Entity extends BmobObject implements Serializable { +// +// +// protected int id; +// +// protected String cacheKey; +// +// public int getId() { +// return id; +// } +// +// public void setId(int id) { +// this.id = id; +// } +// +// public String getCacheKey() { +// return cacheKey; +// } +// +// public void setCacheKey(String cacheKey) { +// this.cacheKey = cacheKey; +// } +//} diff --git a/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/entity/NotebookData.java b/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/entity/NotebookData.java new file mode 100644 index 0000000..c8ce8fa --- /dev/null +++ b/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/entity/NotebookData.java @@ -0,0 +1,245 @@ +package com.example.administrator.myapplication.entity; + + +import android.content.Context; + +import cn.bmob.v3.BmobObject; +import cn.bmob.v3.listener.DeleteListener; +import cn.bmob.v3.listener.SaveListener; +import cn.bmob.v3.listener.UpdateListener; + + +public class NotebookData extends BmobObject implements /*Serializable,*/ + Comparable { + + + private int id; + private int iid; + + private String userId;//用于服务器端存储需要 + + private String unixTime; + + private String date; + + private String content; + + private String colorText; + + private int color; + public static final String NOTE_USER_ID = "userId"; + + @Override + public boolean equals(Object o) { + if (super.equals(o)) { + return true; + } else { + if (o instanceof NotebookData) { + NotebookData data = (NotebookData) o; + try { + return (this.id == data.getId()) + && (this.iid == data.getIid()) + && (this.unixTime == data.getUnixTime()) + && (this.date.equals(data.getDate())) + && (this.content == data.getContent()) + && (this.color == data.getColor()); + } catch (NullPointerException e) { + return false; + } + } else { + return false; + } + } + } + +public void postNoteToServer(Context context,final com.example.administrator.myapplication.entity.OnResponseListener listener) +{ + // for(int i=0;i noteItemList; + // private List diaryItemList; + private Bitmap bitmap; + + public Bitmap getBitmap() { + return bitmap; + } + + public void setBitmap(Bitmap bitmap) { + this.bitmap = bitmap; + } + + public String getMsg() { + return msg; + } + + public void setMsg(String msg) { + this.msg = msg; + } + + public boolean isSucces() { + return isSucces; + } + + public void setIsSucces(boolean isSucces) { + this.isSucces = isSucces; + } + + public List getNoteItemList() { + return noteItemList; + } + + public void setNoteItemList(List noteItemList) { + this.noteItemList = noteItemList; + } + +// public List getDiaryItemList() { +// return diaryItemList; +// } +// +// public void setDiaryItemList(List diaryItemList) { +// this.diaryItemList = diaryItemList; +// } +} diff --git a/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/entity/UpdataEvent.java b/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/entity/UpdataEvent.java new file mode 100644 index 0000000..f158688 --- /dev/null +++ b/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/entity/UpdataEvent.java @@ -0,0 +1,29 @@ +package com.example.administrator.myapplication.entity; + +/** + * 配合EvetnBus使用 + */ +public class UpdataEvent { + public static final int UPDATE_NOTES = 0; + public static final int UPDATE_DIARIES = 1; + public static final int UPDATE_USER_INFOS = 2; + private int type; + private String content; + + public void setType(int type) { + this.type = type; + } + + public int getType() { + return type; + } + public void setString(String str) + { + this.content=str; + } + public String getString() + { + return content; + } + +} diff --git a/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/entity/User.java b/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/entity/User.java new file mode 100644 index 0000000..55577c2 --- /dev/null +++ b/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/entity/User.java @@ -0,0 +1,298 @@ +package com.example.administrator.myapplication.entity; +import android.content.Context; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import android.text.TextUtils; +import android.util.Log; +import android.widget.ImageView; +import android.widget.Toast; + +import com.htq.baidu.coolnote.R; +import com.htq.baidu.coolnote.app.BaseApplication; +import com.htq.baidu.coolnote.utils.AccountUtils; +import com.htq.baidu.coolnote.utils.BmobConstants; +import com.htq.baidu.coolnote.utils.ImageLoadOptions; +import com.htq.baidu.coolnote.utils.SPUtils; +import com.nostra13.universalimageloader.core.ImageLoader; +import com.nostra13.universalimageloader.core.ImageLoaderConfiguration; + +import java.io.File; +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +import cn.bmob.v3.Bmob; +import cn.bmob.v3.BmobQuery; +import cn.bmob.v3.BmobUser; +import cn.bmob.v3.datatype.BmobFile; +import cn.bmob.v3.exception.BmobException; +import cn.bmob.v3.listener.DeleteListener; +import cn.bmob.v3.listener.FindListener; +import cn.bmob.v3.listener.LogInListener; +import cn.bmob.v3.listener.SaveListener; +import cn.bmob.v3.listener.UpdateListener; + + +public class User extends BmobUser implements Serializable{ + + private String nickname; + private String sex; + private String notePwd; + private String headUrl; + + public String getUserNickname() { + if (!TextUtils.isEmpty(nickname)) + return nickname; + else + return ""; + } + + public void setUserNickname(String nickname) { + this.nickname = nickname; + } + + public String getUserSex() { + if (!TextUtils.isEmpty(sex)) + return sex; + else + return ""; + } + + public void setUserSex(String sex) { + this.sex = sex; + } + + public String getUserNotePwd() { + if (!TextUtils.isEmpty(notePwd)) + return notePwd; + else + return ""; + } + + public void setUserNotePwd(String notePwd) { + this.notePwd = notePwd; + } + + public String getUserHeadUrl() { + if (!TextUtils.isEmpty(headUrl)) + return headUrl; + else + return ""; + } + + public void setUserHeadUrl(String headUrl) { + this.headUrl = headUrl; + } + + public void Login(String account ,String pwd ,final Context context) + { + + + } + static public void setUserHeadFromCache(Context context, ImageView img){ + String mSavePath=context.getCacheDir().getAbsolutePath(); + File saveFile = new File(mSavePath, "userHead"); + Bitmap bitmap = BitmapFactory.decodeFile(saveFile.getAbsolutePath()); + img.setImageBitmap(bitmap); + + } + + /** + * 更新头像 refreshAvatar + * + * @return void + * @throws + */ + static public void refreshAvatarFromServe(String avatar,ImageView headIcon) { + if (avatar != null && !avatar.equals("")) { + ImageLoader.getInstance().displayImage(avatar,headIcon, + ImageLoadOptions.getOptions()); + } else { + headIcon.setImageResource(R.mipmap.mine_avatar); + } + + } + static public void refreshAvatarFromLoca(Context context,ImageView headIcon) { + // if (avatar != null && !avatar.equals("")) { + //imageLoader.init(); + File saveFile = new File(BmobConstants.MyAvatarDir, "avatarIcon.png"); + if(saveFile.exists())//先从本地获取 + { + Bitmap bitmap = BitmapFactory.decodeFile(saveFile.getAbsolutePath()); + headIcon.setImageBitmap(bitmap); + }else//从网络上获取,如果失败显示默认图片 + { + initDefaultAvatar(context, headIcon); + } +// Bitmap bitmap = BitmapFactory.decodeFile(saveFile.getAbsolutePath()); +// headIcon.setImageBitmap(bitmap); +// ImageLoader.getInstance().displayImage(/*"file://"+*/avatar,headIcon, +// ImageLoadOptions.getOptions()); +// } else { +// headIcon.setImageResource(R.drawable.default_head); +// } + } + + static public void initDefaultAvatar(Context context,ImageView headIcon) + { + // String defaultPath= BmobConstants.MyAvatarDir+"avatarIcon.png"; + if(!setUserHeadFromServer(context, headIcon)) + { + headIcon.setImageResource(R.drawable.default_head); + } +// boolean isSetAvatar= (boolean) SPUtils.get(context,"isSetAvatar",false); +// if(!isSetAvatar) +// +// else +// { +// Log.i("head","get user icon form srver"); +// setUserHeadFromServer(context, headIcon); +//// ImageLoader.getInstance().displayImage("file://"+defaultPath,headIcon, +//// ImageLoadOptions.getOptions()); +// } + + } + + static public void autoLogin(Context context, final OnResponseListener listener) + { + if(SPUtils.contains(context,"user_name")) + { + String name=(String)SPUtils.get(context,"user_name",""); + String pwd=(String)SPUtils.get(context,"pwd",""); + BmobUser user = new BmobUser(); + user.setUsername(name); + user.setPassword(pwd); + user.login(context, new SaveListener() { + @Override + public void onSuccess() { + if(listener!=null) + { + Response response = new Response(); + response.setIsSucces(true); + listener.onResponse(response); + } + // Snackbar.make(loginBtn,"登录成功!",Snackbar.LENGTH_SHORT).show(); + + } + @Override + public void onFailure(int code, String msg) { + if(listener!=null) + { + Response response = new Response(); + response.setIsSucces(false); + response.setMsg(msg); + listener.onResponse(response); + } + } + }); + } + } + + static public void getUserNotes(Context context, String user_id,final OnResponseListener listener){ + // Bmob.initialize(context, Constants.APPLICATION_ID); + final List list = new ArrayList(); + BmobQuery query = new BmobQuery(); + + query.addWhereEqualTo(NotebookData.NOTE_USER_ID, user_id); + //返回50条数据,如果不加上这条语句,默认返回10条数据 + query.setLimit(50); + //按更新日期降序排列 + query.order("-updatedAt"); + //执行查询方法 + query.findObjects(context, new FindListener() { + @Override + public void onSuccess(List object) { + if (listener != null) { + Response response = new Response(); + response.setIsSucces(true); + response.setNoteItemList(object); + listener.onResponse(response); + } + } + + @Override + public void onError(int code, String msg) { + Response response = new Response(); + response.setIsSucces(false); + response.setMsg(msg); + listener.onResponse(response); + + } + }); + } + /** + * 更新用户表单中的头像列 + * + * @param picUrl 图片的url + */ + private void updateUserHead(Context context, String picUrl, final OnResponseListener listener) { + String oldUrl = AccountUtils.getUserHeadUrl(context); + if (!TextUtils.isEmpty(oldUrl) && !oldUrl.equals("")) { + //删除服务器上的旧头像 + deleteUserOldHead(context, oldUrl); + } + AccountUtils.saveUserHeadUrl(context, picUrl); + User user = new User(); + user.setUserHeadUrl(picUrl); + user.update(context, AccountUtils.getUserId(context), new UpdateListener() { + @Override + public void onSuccess() { + if (listener != null) { + Response response = new Response(); + response.setIsSucces(true); + listener.onResponse(response); + } + } + + @Override + public void onFailure(int code, String msg) { + if (listener != null) { + Response response = new Response(); + response.setIsSucces(false); + response.setMsg(msg); + listener.onResponse(response); + } + } + }); + } + + /** + * 删除服务器上的旧头像 + * + * @param oldUrl 旧头像的url + */ + private void deleteUserOldHead(Context context, String oldUrl) { + BmobFile file = new BmobFile(); + file.setUrl(oldUrl);//此url是上传文件成功之后通过bmobFile.getUrl()方法获取的。 + file.delete(context, new DeleteListener() { + @Override + public void onSuccess() { + } + + @Override + public void onFailure(int code, String msg) { + } + }); + } + + + + static public boolean setUserHeadFromServer(Context context, ImageView headIcon) { + + String photoUrl = AccountUtils.getUserHeadUrl(context).trim(); + + // Toast.makeText(context,photoUrl,Toast.LENGTH_LONG).show(); + if (!TextUtils.isEmpty(photoUrl) && !photoUrl.equals("")) { + ImageLoader.getInstance().displayImage(photoUrl,headIcon, + ImageLoadOptions.getOptions()); + return true; + } + return false;//说明用户第一次使用该App或者未修改head + } + +// static public String getUserHeadPath() +// { +// String path=null; +// return path; +// } +} diff --git a/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/ui/WelcomeActivity.java b/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/ui/WelcomeActivity.java index 4ccb307..984ee8f 100644 --- a/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/ui/WelcomeActivity.java +++ b/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/ui/WelcomeActivity.java @@ -1,15 +1,92 @@ package com.example.administrator.myapplication.ui; -import android.support.v7.app.AppCompatActivity; +import android.content.Intent; import android.os.Bundle; +import android.os.Handler; +import android.support.v7.app.AppCompatActivity; +import android.view.Window; +import android.view.WindowManager; +import android.widget.Toast; import com.example.administrator.myapplication.R; public class WelcomeActivity extends AppCompatActivity { + private boolean isSetLock; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); + /*set it to be no title*/ + requestWindowFeature(Window.FEATURE_NO_TITLE); + /*set it to be full screen*/ + getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, + WindowManager.LayoutParams.FLAG_FULLSCREEN); setContentView(R.layout.activity_welcome); + //初始化bmob + // String libName = "bmob"; + // System.loadLibrary(libName ); + + isSetLock = new com.htq.baidu.coolnote.utils.SystemUtils(WelcomeActivity.this).getBoolean("isSetLock"); + new Handler().postDelayed(new Runnable() { + @Override + public void run() { + + Intent intent; + if (isSetLock) { + + intent = new Intent(WelcomeActivity.this, UnLockActivity.class); + startActivity(intent); + WelcomeActivity.this.finish(); + } else { + autoLogin(); + //intent = new Intent(WelcomeActivity.this, LoginActivity.class); + } + + } + }, 2000); } -} + private void autoLogin() + { + if(com.htq.baidu.coolnote.utils.SPUtils.contains(this,"user_name")) + { + String name=(String) com.htq.baidu.coolnote.utils.SPUtils.get(this,"user_name",""); + String pwd=(String) com.htq.baidu.coolnote.utils.SPUtils.get(this,"pwd",""); + User user = new User(); + user.setUsername(name); + user.setPassword(pwd); + user.login(this, new SaveListener() { + @Override + public void onSuccess() { + // Snackbar.make(loginBtn,"登录成功!",Snackbar.LENGTH_SHORT).show(); + goToHomeActivity(); + + } + + @Override + public void onFailure(int code, String msg) { + //Snackbar.make(loginBtn,"登录失败!",Snackbar.LENGTH_SHORT).show(); + Toast.makeText(WelcomeActivity.this,msg, Toast.LENGTH_SHORT).show(); + goToLoginActivity();//自动登陆失败,用户手动登陆 + } + }); + } + else + { + goToLoginActivity(); + } + } + private void goToHomeActivity() + { + Intent intent=new Intent(WelcomeActivity.this,MainActivity.class); + startActivity(intent); + WelcomeActivity.this.finish(); + + } + private void goToLoginActivity() + { + Intent intent=new Intent(WelcomeActivity.this,LoginActivity.class); + startActivity(intent); + WelcomeActivity.this.finish(); + + } +} \ No newline at end of file diff --git a/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/utils/AccountUtils.java b/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/utils/AccountUtils.java new file mode 100644 index 0000000..52379cb --- /dev/null +++ b/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/utils/AccountUtils.java @@ -0,0 +1,110 @@ +package com.example.administrator.myapplication.utils; + +import android.content.Context; +import android.text.TextUtils; + +import com.example.administrator.myapplication.entity.User; + + +/** + * 用户信息管理类 + */ +public class AccountUtils { + + private static final String USER_NAME = "user_name"; + private static final String USER_PWD = "user_pwd"; + private static final String USER_ID = "user_id"; + private static final String USER_EMAIL = "user_email"; + private static final String USER_NICK_NAME = "user_nickname"; + private static final String USER_NOTE_PWD = "user_note_pwd"; + private static final String USER_SEX = "user_sex"; + private static final String USER_HEAD_URL = "user_head_url"; + + /** + * 保存用户的所有信息 + * @param context + * @param user + * @param user_pwd 用户的登录密码 + */ + public static void saveUserInfos(Context context, User user, String user_pwd) { + saveUserName(context, user.getUsername()); + saveUserPwd(context, user_pwd); + saveUserId(context, user.getObjectId()); + saveUserNickName(context, user.getUserNickname()); + saveUserEmail(context, user.getEmail()); + saveUserDiaryPwd(context, user.getUserNotePwd()); + saveUserSex(context, user.getUserSex()); + saveUserHeadUrl(context, user.getUserHeadUrl()); + } + + + public static String getUserName(Context context) { + return (String) com.example.administrator.myapplication.utils.SPUtils.get(context, USER_NAME, ""); + } + + public static void saveUserName(Context context, String str) { + com.example.administrator.myapplication.utils.SPUtils.put(context, USER_NAME, str); + } + + public static String getUserPwd(Context context) { + return (String) com.example.administrator.myapplication.utils.SPUtils.get(context, USER_PWD, ""); + } + + public static void saveUserPwd(Context context, String str) { + com.example.administrator.myapplication.utils.SPUtils.put(context, USER_PWD, str); + } + + public static String getUserId(Context context) { + return (String) com.example.administrator.myapplication.utils.SPUtils.get(context, USER_ID, ""); + } + + public static void saveUserId(Context context, String str) { + com.example.administrator.myapplication.utils.SPUtils.put(context, USER_ID, str); + } + + public static String getUserEmail(Context context) { + return (String) com.example.administrator.myapplication.utils.SPUtils.get(context, USER_EMAIL, ""); + } + + public static void saveUserEmail(Context context, String str) { + if (!TextUtils.isEmpty(str)) { + com.example.administrator.myapplication.utils.SPUtils.put(context, USER_EMAIL, str); + } + } + + public static String getUserNickName(Context context) { + return (String) com.example.administrator.myapplication.utils.SPUtils.get(context, USER_NICK_NAME, ""); + } + + public static void saveUserNickName(Context context, String str) { + com.example.administrator.myapplication.utils.SPUtils.put(context, USER_NICK_NAME, str); + } + + public static String getUserDiaryPwd(Context context) { + return (String) com.example.administrator.myapplication.utils.SPUtils.get(context, USER_NOTE_PWD, ""); + } + + public static void saveUserDiaryPwd(Context context, String str) { + com.example.administrator.myapplication.utils.SPUtils.put(context, USER_NOTE_PWD, str); + } + + public static String getUserSex(Context context) { + return (String) com.example.administrator.myapplication.utils.SPUtils.get(context, USER_SEX, ""); + } + + public static void saveUserSex(Context context, String str) { + com.example.administrator.myapplication.utils.SPUtils.put(context, USER_SEX, str); + } + + public static String getUserHeadUrl(Context context){ + return (String) com.example.administrator.myapplication.utils.SPUtils.get(context, USER_HEAD_URL, ""); + } + + + public static void saveUserHeadUrl(Context context, String str) { + com.example.administrator.myapplication.utils.SPUtils.put(context, USER_HEAD_URL, str); + } + public static void clearAllInfos(Context context){ + com.example.administrator.myapplication.utils.SPUtils.clear(context); + } +} diff --git a/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/utils/BmobConstants.java b/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/utils/BmobConstants.java new file mode 100644 index 0000000..99bdafe --- /dev/null +++ b/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/utils/BmobConstants.java @@ -0,0 +1,39 @@ +package com.example.administrator.myapplication.utils; + +import android.annotation.SuppressLint; +import android.os.Environment; + + +/** + * @ClassName: BmobConstants + * @Description: TODO + * @author smile + * @date 2014-6-19 ����2:48:33 + */ +@SuppressLint("SdCardPath") +public class BmobConstants { + + /** + * ��ŷ���ͼƬ��Ŀ¼ + */ + public static String BMOB_PICTURE_PATH = Environment.getExternalStorageDirectory() + "/bmobimdemo/image/"; + + /** + * �ҵ�ͷ�񱣴�Ŀ¼ + */ + public static String MyAvatarDir = "/sdcard/beautynote/avatar/"; + /** + * ���ջص� + */ + public static final int REQUESTCODE_UPLOADAVATAR_CAMERA = 1;//�����޸�ͷ�� + public static final int REQUESTCODE_UPLOADAVATAR_LOCATION = 2;//��������޸�ͷ�� + public static final int REQUESTCODE_UPLOADAVATAR_CROP = 3;//ϵͳ�ü�ͷ�� + + public static final int REQUESTCODE_TAKE_CAMERA = 0x000001;//���� + public static final int REQUESTCODE_TAKE_LOCAL = 0x000002;//����ͼƬ + public static final int REQUESTCODE_TAKE_LOCATION = 0x000003;//λ�� + public static final String EXTRA_STRING = "extra_string"; + + + public static final String ACTION_REGISTER_SUCCESS_FINISH ="register.success.finish";//ע��ɹ�֮���½ҳ���˳� +} diff --git a/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/utils/CommonUtils.java b/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/utils/CommonUtils.java new file mode 100644 index 0000000..02b1101 --- /dev/null +++ b/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/utils/CommonUtils.java @@ -0,0 +1,54 @@ +package com.htq.baidu.coolnote.utils; + +import android.content.Context; +import android.net.ConnectivityManager; +import android.net.NetworkInfo; + +public class CommonUtils { + + /** ����Ƿ������� */ + public static boolean isNetworkAvailable(Context context) { + NetworkInfo info = getNetworkInfo(context); + if (info != null) { + return info.isAvailable(); + } + return false; + } + + /** ����Ƿ���WIFI */ + public static boolean isWifi(Context context) { + NetworkInfo info = getNetworkInfo(context); + if (info != null) { + if (info.getType() == ConnectivityManager.TYPE_WIFI) + return true; + } + return false; + } + + /** ����Ƿ����ƶ����� */ + public static boolean isMobile(Context context) { + NetworkInfo info = getNetworkInfo(context); + if (info != null) { + if (info.getType() == ConnectivityManager.TYPE_MOBILE) + return true; + } + return false; + } + + private static NetworkInfo getNetworkInfo(Context context) { + + ConnectivityManager cm = (ConnectivityManager) context + .getSystemService(Context.CONNECTIVITY_SERVICE); + return cm.getActiveNetworkInfo(); + } + + /** ���SD���Ƿ���� */ + public static boolean checkSdCard() { + if (android.os.Environment.getExternalStorageState().equals( + android.os.Environment.MEDIA_MOUNTED)) + return true; + else + return false; + } + +} diff --git a/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/utils/Constants.java b/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/utils/Constants.java new file mode 100644 index 0000000..b5baf42 --- /dev/null +++ b/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/utils/Constants.java @@ -0,0 +1,15 @@ +package com.example.administrator.myapplication.utils; + +/** + * Created by htq on 2016/8/10. + */ +public class Constants { + public final static String BUNDLE_KEY_PAGE = "BUNDLE_KEY_PAGE"; + public final static String BUNDLE_KEY_ARGS = "BUNDLE_KEY_ARGS"; + public static final String ALART_CONTENT="alart_content"; + public static final String TEXT_SIZE="text_size"; + public static final int TEXT_SMALL = 0; + public static final int TEXT_MEDIUM = 1; + public static final int TEXT_LARGE = 2; + public static final int TEXT_SUPER = 3; +} diff --git a/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/utils/DialogHelp.java b/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/utils/DialogHelp.java new file mode 100644 index 0000000..0a673fb --- /dev/null +++ b/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/utils/DialogHelp.java @@ -0,0 +1,124 @@ +package com.example.administrator.myapplication.utils; + +import android.app.ProgressDialog; +import android.content.Context; +import android.content.DialogInterface; +import android.support.v7.app.AlertDialog; +import android.text.Html; +import android.text.TextUtils; + + +public class DialogHelp { + + /*** + * 获取一个dialog + * @param context + * @return + */ + public static AlertDialog.Builder getDialog(Context context) { + AlertDialog.Builder builder = new AlertDialog.Builder(context); + return builder; + } + + /*** + * 获取一个耗时等待对话框 + * @param context + * @param message + * @return + */ + public static ProgressDialog getWaitDialog(Context context, String message) { + ProgressDialog waitDialog = new ProgressDialog(context); + if (!TextUtils.isEmpty(message)) { + waitDialog.setMessage(message); + } + return waitDialog; + } + + /*** + * 获取一个信息对话框,注意需要自己手动调用show方法显示 + * @param context + * @param message + * @param onClickListener + * @return + */ + public static AlertDialog.Builder getMessageDialog(Context context, String message, DialogInterface.OnClickListener onClickListener) { + AlertDialog.Builder builder = getDialog(context); + builder.setMessage(message); + builder.setPositiveButton("确定", onClickListener); + return builder; + } + + public static AlertDialog.Builder getMessageDialog(Context context, String message) { + return getMessageDialog(context, message, null); + } + + public static AlertDialog.Builder getConfirmDialog(Context context, String message, DialogInterface.OnClickListener onClickListener) { + AlertDialog.Builder builder = getDialog(context); + builder.setMessage(Html.fromHtml(message)); + builder.setPositiveButton("确定", onClickListener); + builder.setNegativeButton("取消", null); + return builder; + } + + public static AlertDialog.Builder getConfirmDialog(Context context, String message, DialogInterface.OnClickListener onOkClickListener, DialogInterface.OnClickListener onCancleClickListener) { + AlertDialog.Builder builder = getDialog(context); + builder.setMessage(message); + builder.setPositiveButton("确定", onOkClickListener); + builder.setNegativeButton("取消", onCancleClickListener); + return builder; + } + + public static AlertDialog.Builder getConfirmDialog(Context context, + String message, + String okString, + String cancleString, + DialogInterface.OnClickListener onOkClickListener, + DialogInterface.OnClickListener onCancleClickListener) { + return getConfirmDialog(context, "", message, okString, cancleString, onOkClickListener, onCancleClickListener); + } + + public static AlertDialog.Builder getConfirmDialog(Context context, + String title, + String message, + String okString, + String cancleString, + DialogInterface.OnClickListener onOkClickListener, + DialogInterface.OnClickListener onCancleClickListener) { + AlertDialog.Builder builder = getDialog(context); + if (!TextUtils.isEmpty(title)) { + builder.setTitle(title); + } + builder.setMessage(message); + builder.setPositiveButton(okString, onOkClickListener); + builder.setNegativeButton(cancleString, onCancleClickListener); + return builder; + } + + public static AlertDialog.Builder getSelectDialog(Context context, String title, String[] arrays, DialogInterface.OnClickListener onClickListener) { + AlertDialog.Builder builder = getDialog(context); + builder.setItems(arrays, onClickListener); + if (!TextUtils.isEmpty(title)) { + builder.setTitle(title); + } + builder.setPositiveButton("取消", null); + return builder; + } + + public static AlertDialog.Builder getSelectDialog(Context context, String[] arrays, DialogInterface.OnClickListener onClickListener) { + return getSelectDialog(context, "", arrays, onClickListener); + } + + public static AlertDialog.Builder getSingleChoiceDialog(Context context, String title, String[] arrays, int selectIndex, DialogInterface.OnClickListener onClickListener) { + AlertDialog.Builder builder = getDialog(context); + builder.setSingleChoiceItems(arrays, selectIndex, onClickListener); + if (!TextUtils.isEmpty(title)) { + builder.setTitle(title); + } + builder.setNegativeButton("取消", null); + return builder; + } + + public static AlertDialog.Builder getSingleChoiceDialog(Context context, String[] arrays, int selectIndex, DialogInterface.OnClickListener onClickListener) { + return getSingleChoiceDialog(context, "", arrays, selectIndex, onClickListener); + } +} diff --git a/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/utils/HTQAnimations.java b/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/utils/HTQAnimations.java new file mode 100644 index 0000000..84c48c2 --- /dev/null +++ b/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/utils/HTQAnimations.java @@ -0,0 +1,189 @@ +package com.example.administrator.myapplication.utils; + +import android.view.View; +import android.view.animation.AlphaAnimation; +import android.view.animation.Animation; +import android.view.animation.AnimationSet; +import android.view.animation.AnticipateInterpolator; +import android.view.animation.OvershootInterpolator; +import android.view.animation.RotateAnimation; +import android.view.animation.ScaleAnimation; +import android.view.animation.TranslateAnimation; +import android.widget.ImageView; +import android.widget.RelativeLayout; + +/** + * 录音动画类 + */ +public class HTQAnimations { + + /** + * 旋转 Rotate + */ + public static Animation getRotateAnimation(float fromDegrees, + float toDegrees, long durationMillis) { + RotateAnimation rotate = new RotateAnimation(fromDegrees, toDegrees, + Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, + 0.5f); + rotate.setDuration(durationMillis); + rotate.setFillAfter(true); + return rotate; + } + + /** + * 透明度 Alpha + */ + public static Animation getAlphaAnimation(float fromAlpha, float toAlpha, + long durationMillis) { + AlphaAnimation alpha = new AlphaAnimation(fromAlpha, toAlpha); + alpha.setDuration(durationMillis); + alpha.setFillAfter(true); + return alpha; + } + + /** + * 缩放 Scale + */ + public static Animation getScaleAnimation(float scaleXY, long durationMillis) { + ScaleAnimation scale = new ScaleAnimation(1.0f, scaleXY, 1.0f, scaleXY, + Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, + 0.5f); + scale.setDuration(durationMillis); + return scale; + } + + /** + * 位移 Translate + */ + public static Animation getTranslateAnimation(float fromXDelta, + float toXDelta, float fromYDelta, float toYDelta, + long durationMillis) { + TranslateAnimation translate = new TranslateAnimation(fromXDelta, + toXDelta, fromYDelta, toYDelta); + translate.setDuration(durationMillis); + translate.setFillAfter(true); + return translate; + } + + public static Animation clickAnimation(float scaleXY, long durationMillis) { + AnimationSet set = new AnimationSet(true); + set.addAnimation(getScaleAnimation(scaleXY, durationMillis)); + set.setDuration(durationMillis); + return set; + } + + public static Animation shakeAnimation(int X) { + AnimationSet set = new AnimationSet(true); + Animation anim1 = getTranslateAnimation(0, -200, 0, 0, 100); + anim1.setStartOffset(100); + set.addAnimation(anim1); + Animation anim2 = getTranslateAnimation(-200, 400, 0, 0, 200); + anim2.setStartOffset(300); + set.addAnimation(anim2); + Animation anim3 = getTranslateAnimation(400, -200, 0, 0, 200); + anim3.setStartOffset(500); + set.addAnimation(anim3); + Animation anim4 = getTranslateAnimation(-200, 0, 0, 0, 100); + anim4.setStartOffset(600); + set.addAnimation(anim4); + set.setFillAfter(true); + set.setDuration(640); + return set; + } + + /** + * 打开的动画 + * + * @param relativeLayout + * 子菜单容器 + * @param background + * 子菜单背景 + * @param menu + * 菜单按钮 + * @param durationMillis + * 动画时间 + */ + public static void openAnimation(RelativeLayout relativeLayout, + ImageView menu, long durationMillis) { + relativeLayout.setVisibility(View.VISIBLE); + for (int i = 1; i < relativeLayout.getChildCount(); i++) { + ImageView imageView = null; + if (relativeLayout.getChildAt(i) instanceof ImageView) { + imageView = (ImageView) relativeLayout.getChildAt(i); + } else { + continue; + + } + + int top = imageView.getTop(); + int left = imageView.getLeft(); + if (top == 0) { + top = (menu.getHeight() + 50) * i; + } + if (left == 0) { + left = menu.getLeft(); + } + AnimationSet set = new AnimationSet(true); + set.addAnimation(getRotateAnimation(-360, 0, durationMillis)); + set.addAnimation(getAlphaAnimation(0.5f, 1.0f, durationMillis)); + set.addAnimation(getTranslateAnimation(menu.getLeft() - left, 0, + menu.getTop() - top + 30, 0, durationMillis));// 加30是由于图片上部有一些透明高度 + set.setFillAfter(true); + set.setDuration(durationMillis); + set.setStartOffset((i * 100) + / (-1 + relativeLayout.getChildCount())); + set.setInterpolator(new OvershootInterpolator(1f)); + imageView.startAnimation(set); + } + } + + /** + * 关闭的动画 + * + * @param relativeLayout + * 子菜单容器 + * @param background + * 子菜单背景 + * @param menu + * 菜单按钮 + * @param durationMillis + * 动画时间 + */ + public static void closeAnimation(final RelativeLayout relativeLayout, + final ImageView menu, long durationMillis) { + for (int i = 1; i < relativeLayout.getChildCount(); i++) { + ImageView imageView = null; + if (relativeLayout.getChildAt(i) instanceof ImageView) { + imageView = (ImageView) relativeLayout.getChildAt(i); + } else { + continue; + } + + AnimationSet set = new AnimationSet(true); + set.addAnimation(getRotateAnimation(0, -360, durationMillis)); + set.addAnimation(getAlphaAnimation(1.0f, 0.5f, durationMillis)); + set.addAnimation(getTranslateAnimation(0, menu.getLeft() + - imageView.getLeft(), 0, + menu.getTop() - imageView.getTop() + 30, durationMillis));// 加30是由于图片上部有一些透明高度 + set.setFillAfter(true); + set.setDuration(durationMillis); + set.setStartOffset(((relativeLayout.getChildCount() - i) * 100) + / (-1 + relativeLayout.getChildCount())); + set.setInterpolator(new AnticipateInterpolator(1f)); + set.setAnimationListener(new Animation.AnimationListener() { + @Override + public void onAnimationStart(Animation arg0) {} + + @Override + public void onAnimationRepeat(Animation arg0) {} + + @Override + public void onAnimationEnd(Animation arg0) { + relativeLayout.setVisibility(View.GONE); + } + }); + imageView.startAnimation(set); + } + } + +} diff --git a/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/utils/ImageLoadOptions.java b/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/utils/ImageLoadOptions.java new file mode 100644 index 0000000..33c0990 --- /dev/null +++ b/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/utils/ImageLoadOptions.java @@ -0,0 +1,42 @@ +package com.example.administrator.myapplication.utils; + +import android.graphics.Bitmap; + +import com.nostra13.universalimageloader.core.DisplayImageOptions; +import com.nostra13.universalimageloader.core.assist.ImageScaleType; +import com.nostra13.universalimageloader.core.display.FadeInBitmapDisplayer; + +public class ImageLoadOptions { + + public static DisplayImageOptions getOptions() { + DisplayImageOptions options = new DisplayImageOptions.Builder() + // // ����ͼƬ�������ڼ���ʾ��ͼƬ + // .showImageOnLoading(R.drawable.small_image_holder_listpage) + // // ����ͼƬUriΪ�ջ��Ǵ����ʱ����ʾ��ͼƬ + // .showImageForEmptyUri(R.drawable.small_image_holder_listpage) + // // ����ͼƬ����/�������д���ʱ����ʾ��ͼƬ + // .showImageOnFail(R.drawable.small_image_holder_listpage) + .cacheInMemory(true) + // �������ص�ͼƬ�Ƿ񻺴����ڴ��� + .cacheOnDisc(true) + // �������ص�ͼƬ�Ƿ񻺴���SD���� + .considerExifParams(true) + .imageScaleType(ImageScaleType.EXACTLY)// ����ͼƬ����εı��뷽ʽ��ʾ + .bitmapConfig(Bitmap.Config.RGB_565)// ����ͼƬ�Ľ������� + // .decodingOptions(android.graphics.BitmapFactory.Options + // decodingOptions)//����ͼƬ�Ľ������� + .considerExifParams(true) + // ����ͼƬ����ǰ���ӳ� + // .delayBeforeLoading(int delayInMillis)//int + // delayInMillisΪ�����õ��ӳ�ʱ�� + // ����ͼƬ���뻺��ǰ����bitmap�������� + // ��preProcessor(BitmapProcessor preProcessor) + .resetViewBeforeLoading(true)// ����ͼƬ������ǰ�Ƿ����ã���λ + // .displayer(new RoundedBitmapDisplayer(20))//�Ƿ�����ΪԲ�ǣ�����Ϊ���� + .displayer(new FadeInBitmapDisplayer(100))// ���� + .build(); + + return options; + } + +} diff --git a/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/utils/MD5Util.java b/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/utils/MD5Util.java new file mode 100644 index 0000000..36ee79b --- /dev/null +++ b/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/utils/MD5Util.java @@ -0,0 +1,46 @@ +package com.example.administrator.myapplication.utils; + +import java.security.MessageDigest; + + +public class MD5Util { + public static String MD5(String str) { + MessageDigest md5 = null; + try { + md5 = MessageDigest.getInstance("MD5"); + } catch (Exception e) { + e.printStackTrace(); + return ""; + } + + char[] charArray = str.toCharArray(); + byte[] byteArray = new byte[charArray.length]; + + for (int i = 0; i < charArray.length; i++) { + byteArray[i] = (byte) charArray[i]; + } + byte[] md5Bytes = md5.digest(byteArray); + + StringBuffer hexValue = new StringBuffer(); + for (int i = 0; i < md5Bytes.length; i++) { + int val = ((int) md5Bytes[i]) & 0xff; + if (val < 16) { + hexValue.append("0"); + } + hexValue.append(Integer.toHexString(val)); + } + return hexValue.toString(); + } + + // 可逆的加密算法 + public static String encryptmd5(String str) { + char[] a = str.toCharArray(); + for (int i = 0; i < a.length; i++) { + a[i] = (char) (a[i] ^ 'l'); + } + String s = new String(a); + return s; + } + +} + diff --git a/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/utils/PhotoUtil.java b/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/utils/PhotoUtil.java new file mode 100644 index 0000000..e332e27 --- /dev/null +++ b/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/utils/PhotoUtil.java @@ -0,0 +1,300 @@ +package com.example.administrator.myapplication.utils; + +import android.graphics.Bitmap; +import android.graphics.Bitmap.Config; +import android.graphics.BitmapFactory; +import android.graphics.Canvas; +import android.graphics.Matrix; +import android.graphics.Paint; +import android.graphics.PorterDuff.Mode; +import android.graphics.PorterDuffXfermode; +import android.graphics.Rect; +import android.graphics.RectF; +import android.media.ExifInterface; +import android.media.ThumbnailUtils; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; + +public class PhotoUtil { + + /** + * �������� recycle + * + * @throws + */ + public static void recycle(Bitmap bitmap) { + // ���ж��Ƿ��Ѿ����� + if (bitmap != null && !bitmap.isRecycled()) { + // ���ղ�����Ϊnull + bitmap.recycle(); + bitmap = null; + } + System.gc(); + } + + /** + * ��ȡָ��·���µ�ͼƬ��ָ����С������ͼ getImageThumbnail + * + * @return Bitmap + * @throws + */ + public static Bitmap getImageThumbnail(String imagePath, int width, + int height) { + Bitmap bitmap = null; + BitmapFactory.Options options = new BitmapFactory.Options(); + options.inJustDecodeBounds = true; + // ��ȡ���ͼƬ�Ŀ�͸ߣ�ע��˴���bitmapΪnull + bitmap = BitmapFactory.decodeFile(imagePath, options); + options.inJustDecodeBounds = false; // ��Ϊ false + // �������ű� + int h = options.outHeight; + int w = options.outWidth; + int beWidth = w / width; + int beHeight = h / height; + int be = 1; + if (beWidth < beHeight) { + be = beWidth; + } else { + be = beHeight; + } + if (be <= 0) { + be = 1; + } + options.inSampleSize = be; + // ���¶���ͼƬ����ȡ���ź��bitmap��ע�����Ҫ��options.inJustDecodeBounds ��Ϊ false + bitmap = BitmapFactory.decodeFile(imagePath, options); + // ����ThumbnailUtils����������ͼ������Ҫָ��Ҫ�����ĸ�Bitmap���� + bitmap = ThumbnailUtils.extractThumbnail(bitmap, width, height, + ThumbnailUtils.OPTIONS_RECYCLE_INPUT); + return bitmap; + } + + /** + * saveBitmap + * + * @param @param filename---�����·����ʽ-��Ŀ¼�Լ��ļ��� + * @param @param bitmap + * @param @param isDelete --�Ƿ�ֻ��һ�� + * @return void + * @throws + */ + public static void saveBitmap(String dirpath, String filename, + Bitmap bitmap, boolean isDelete) { + File dir = new File(dirpath); + if (!dir.exists()) { + dir.mkdirs(); + } + + File file = new File(dirpath, filename); + // �����ڼ�ɾ��-Ĭ��ֻ����һ�� + if (isDelete) { + if (file.exists()) { + file.delete(); + } + } + + if (!file.exists()) { + try { + file.createNewFile(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + FileOutputStream out = null; + try { + out = new FileOutputStream(file); + if (bitmap.compress(Bitmap.CompressFormat.PNG, 100, out)) { + out.flush(); + } + } catch (FileNotFoundException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } finally { + if (out != null) { + try { + out.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + } + + public static File getFilePath(String filePath, String fileName) { + File file = null; + makeRootDirectory(filePath); + try { + file = new File(filePath + fileName); + if (!file.exists()) { + file.createNewFile(); + } + + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return file; + } + + public static void makeRootDirectory(String filePath) { + File file = null; + try { + file = new File(filePath); + if (!file.exists()) { + file.mkdirs(); + } + } catch (Exception e) { + + } + } + + /** + * + * ��ȡͼƬ���ԣ���ת�ĽǶ� + * @param path ͼƬ���·�� + * @return degree��ת�ĽǶ� + */ + + public static int readPictureDegree(String path) { + int degree = 0; + try { + ExifInterface exifInterface = new ExifInterface(path); + int orientation = exifInterface.getAttributeInt( + ExifInterface.TAG_ORIENTATION, + ExifInterface.ORIENTATION_NORMAL); + switch (orientation) { + case ExifInterface.ORIENTATION_ROTATE_90: + degree = 90; + break; + case ExifInterface.ORIENTATION_ROTATE_180: + degree = 180; + break; + case ExifInterface.ORIENTATION_ROTATE_270: + degree = 270; + break; + } + } catch (IOException e) { + e.printStackTrace(); + } + return degree; + + } + + /** ��תͼƬһ���Ƕ� + * rotaingImageView + * @return Bitmap + * @throws + */ + public static Bitmap rotaingImageView(int angle, Bitmap bitmap) { + // ��תͼƬ ���� + Matrix matrix = new Matrix(); + matrix.postRotate(angle); + // �����µ�ͼƬ + Bitmap resizedBitmap = Bitmap.createBitmap(bitmap, 0, 0, + bitmap.getWidth(), bitmap.getHeight(), matrix, true); + return resizedBitmap; + } + + /** + * ��ͼƬ��ΪԲ�� + * + * @param bitmap + * ԭBitmapͼƬ + * @param pixels + * ͼƬԲ�ǵĻ���(��λ:����(px)) + * @return ����Բ�ǵ�ͼƬ(Bitmap ����) + */ + public static Bitmap toRoundCorner(Bitmap bitmap, int pixels) { + Bitmap output = Bitmap.createBitmap(bitmap.getWidth(), + bitmap.getHeight(), Config.ARGB_8888); + Canvas canvas = new Canvas(output); + + final int color = 0xff424242; + final Paint paint = new Paint(); + final Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight()); + final RectF rectF = new RectF(rect); + final float roundPx = pixels; + + paint.setAntiAlias(true); + canvas.drawARGB(0, 0, 0, 0); + paint.setColor(color); + canvas.drawRoundRect(rectF, roundPx, roundPx, paint); + + paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN)); + canvas.drawBitmap(bitmap, rect, rect, paint); + + return output; + } + + /** + * ��ͼƬת��ΪԲ��ͷ�� + * + * @Title: toRoundBitmap + * @throws + */ + public static Bitmap toRoundBitmap(Bitmap bitmap) { + int width = bitmap.getWidth(); + int height = bitmap.getHeight(); + float roundPx; + float left, top, right, bottom, dst_left, dst_top, dst_right, dst_bottom; + if (width <= height) { + roundPx = width / 2; + + left = 0; + top = 0; + right = width; + bottom = width; + + height = width; + + dst_left = 0; + dst_top = 0; + dst_right = width; + dst_bottom = width; + } else { + roundPx = height / 2; + + float clip = (width - height) / 2; + + left = clip; + right = width - clip; + top = 0; + bottom = height; + width = height; + + dst_left = 0; + dst_top = 0; + dst_right = height; + dst_bottom = height; + } + + Bitmap output = Bitmap.createBitmap(width, height, Config.ARGB_8888); + Canvas canvas = new Canvas(output); + + final Paint paint = new Paint(); + final Rect src = new Rect((int) left, (int) top, (int) right, + (int) bottom); + final Rect dst = new Rect((int) dst_left, (int) dst_top, + (int) dst_right, (int) dst_bottom); + final RectF rectF = new RectF(dst); + + paint.setAntiAlias(true);// ���û����޾�� + + canvas.drawARGB(0, 0, 0, 0); // ������Canvas + + // ���������ַ�����Բ,drawRounRect��drawCircle + canvas.drawRoundRect(rectF, roundPx, roundPx, paint);// ��Բ�Ǿ��Σ���һ������Ϊͼ����ʾ���򣬵ڶ�������͵��������ֱ���ˮƽԲ�ǰ뾶�ʹ�ֱԲ�ǰ뾶�� + // canvas.drawCircle(roundPx, roundPx, roundPx, paint); + + paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN));// ��������ͼƬ�ཻʱ��ģʽ,�ο�http://trylovecatch.iteye.com/blog/1189452 + canvas.drawBitmap(bitmap, src, dst, paint); // ��Mode.SRC_INģʽ�ϲ�bitmap���Ѿ�draw�˵�Circle + + return output; + } + +} diff --git a/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/utils/ResourceParser.java b/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/utils/ResourceParser.java new file mode 100644 index 0000000..0529542 --- /dev/null +++ b/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/utils/ResourceParser.java @@ -0,0 +1,40 @@ +package com.example.administrator.myapplication.utils; + +import com.example.administrator.myapplication.R; + +/** + * Created by htq on 2016/9/15. + */ +public class ResourceParser { + public static final int TEXT_SMALL = 0; + public static final int TEXT_MEDIUM = 1; + public static final int TEXT_LARGE = 2; + public static final int TEXT_SUPER = 3; + + public static final int BG_DEFAULT_FONT_SIZE = TEXT_MEDIUM; + + public static class TextAppearanceResources { + private final static int [] TEXTAPPEARANCE_RESOURCES = new int [] { + R.style.TextAppearanceNormal, + R.style.TextAppearanceMedium, + R.style.TextAppearanceLarge, + R.style.TextAppearanceSuper + }; + + public static int getTexAppearanceResource(int id) { + /** + * HACKME: Fix bug of store the resource id in shared preference. + * The id may larger than the length of resources, in this case, + * return the {@link ResourceParser#BG_DEFAULT_FONT_SIZE} + */ + if (id >= TEXTAPPEARANCE_RESOURCES.length) { + return BG_DEFAULT_FONT_SIZE; + } + return TEXTAPPEARANCE_RESOURCES[id]; + } + + public static int getResourcesSize() { + return TEXTAPPEARANCE_RESOURCES.length; + } + } +} diff --git a/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/utils/SPUtils.java b/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/utils/SPUtils.java new file mode 100644 index 0000000..7f84d80 --- /dev/null +++ b/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/utils/SPUtils.java @@ -0,0 +1,195 @@ +package com.example.administrator.myapplication.utils; + +import android.content.Context; +import android.content.SharedPreferences; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.Map; + +/** + * Created by Wentong WANG on 2016/6/6. + */ +public class SPUtils { + /** + * 保存在手机里面的文件名 + */ + public static final String FILE_NAME = "user_data"; + + /** + * 保存数据的方法,我们需要拿到保存数据的具体类型,然后根据类型调用不同的保存方法 + * + * @param context + * @param key + * @param object + */ + public static void put(Context context, String key, Object object) + { + + SharedPreferences sp = context.getSharedPreferences(FILE_NAME, + Context.MODE_PRIVATE); + SharedPreferences.Editor editor = sp.edit(); + + if (object instanceof String) + { + editor.putString(key, (String) object); + } else if (object instanceof Integer) + { + editor.putInt(key, (Integer) object); + } else if (object instanceof Boolean) + { + editor.putBoolean(key, (Boolean) object); + } else if (object instanceof Float) + { + editor.putFloat(key, (Float) object); + } else if (object instanceof Long) + { + editor.putLong(key, (Long) object); + } else + { + editor.putString(key, object.toString()); + } + + SharedPreferencesCompat.apply(editor); + } + + /** + * 得到保存数据的方法,我们根据默认值得到保存的数据的具体类型,然后调用相对于的方法获取值 + * + * @param context + * @param key + * @param defaultObject + * @return + */ + public static Object get(Context context, String key, Object defaultObject) + { + SharedPreferences sp = context.getSharedPreferences(FILE_NAME, + Context.MODE_PRIVATE); + + if (defaultObject instanceof String) + { + return sp.getString(key, (String) defaultObject); + } else if (defaultObject instanceof Integer) + { + return sp.getInt(key, (Integer) defaultObject); + } else if (defaultObject instanceof Boolean) + { + return sp.getBoolean(key, (Boolean) defaultObject); + } else if (defaultObject instanceof Float) + { + return sp.getFloat(key, (Float) defaultObject); + } else if (defaultObject instanceof Long) + { + return sp.getLong(key, (Long) defaultObject); + } + + return null; + } + + /** + * 移除某个key值已经对应的值 + * @param context + * @param key + */ + public static void remove(Context context, String key) + { + SharedPreferences sp = context.getSharedPreferences(FILE_NAME, + Context.MODE_PRIVATE); + SharedPreferences.Editor editor = sp.edit(); + editor.remove(key); + SharedPreferencesCompat.apply(editor); + } + + /** + * 清除所有数据 + * @param context + */ + public static void clear(Context context) + { + SharedPreferences sp = context.getSharedPreferences(FILE_NAME, + Context.MODE_PRIVATE); + SharedPreferences.Editor editor = sp.edit(); + editor.clear(); + SharedPreferencesCompat.apply(editor); + } + + /** + * 查询某个key是否已经存在 + * @param context + * @param key + * @return + */ + public static boolean contains(Context context, String key) + { + SharedPreferences sp = context.getSharedPreferences(FILE_NAME, + Context.MODE_PRIVATE); + return sp.contains(key); + } + + /** + * 返回所有的键值对 + * + * @param context + * @return + */ + public static Map getAll(Context context) + { + SharedPreferences sp = context.getSharedPreferences(FILE_NAME, + Context.MODE_PRIVATE); + return sp.getAll(); + } + + /** + * 创建一个解决SharedPreferencesCompat.apply方法的一个兼容类 + * + * @author zhy + * + */ + private static class SharedPreferencesCompat + { + private static final Method sApplyMethod = findApplyMethod(); + + /** + * 反射查找apply的方法 + * + * @return + */ + @SuppressWarnings({ "unchecked", "rawtypes" }) + private static Method findApplyMethod() + { + try + { + Class clz = SharedPreferences.Editor.class; + return clz.getMethod("apply"); + } catch (NoSuchMethodException e) + { + } + + return null; + } + + /** + * 如果找到则使用apply执行,否则使用commit + * + * @param editor + */ + public static void apply(SharedPreferences.Editor editor) + { + try + { + if (sApplyMethod != null) + { + sApplyMethod.invoke(editor); + return; + } + } catch (IllegalArgumentException e) + { + } catch (IllegalAccessException e) + { + } catch (InvocationTargetException e) + { + } + editor.commit(); + } + } +} diff --git a/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/utils/StringUtils.java b/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/utils/StringUtils.java new file mode 100644 index 0000000..c69a60d --- /dev/null +++ b/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/utils/StringUtils.java @@ -0,0 +1,598 @@ +package com.example.administrator.myapplication.utils; + +import android.text.TextUtils; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.Date; +import java.util.TimeZone; +import java.util.regex.Pattern; + +/** + * 字符串操作工具包 + * + * @author liux (http://my.oschina.net/liux) + * @version 1.0 + * @created 2012-3-21 + */ +public class StringUtils { + private final static Pattern emailer = Pattern + .compile("\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*"); + + private final static Pattern IMG_URL = Pattern + .compile(".*?(gif|jpeg|png|jpg|bmp)"); + + private final static Pattern URL = Pattern + .compile("^(https|http)://.*?$(net|com|.com.cn|org|me|)"); + + private final static ThreadLocal dateFormater = new ThreadLocal() { + @Override + protected SimpleDateFormat initialValue() { + return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + } + }; + + private final static ThreadLocal dateFormater2 = new ThreadLocal() { + @Override + protected SimpleDateFormat initialValue() { + return new SimpleDateFormat("yyyy-MM-dd"); + } + }; + + private final static ThreadLocal dateFormat3 = new ThreadLocal() { + @Override + protected SimpleDateFormat initialValue() { + return new SimpleDateFormat("yyyy-MM-dd HH:mm"); + } + }; + + /** + * 将字符串转位日期类型 + * + * @param sdate + * @return + */ + public static Date toDate(String sdate) { + return toDate(sdate, dateFormater.get()); + } + + public static Date toDate(String sdate, SimpleDateFormat dateFormater) { + try { + return dateFormater.parse(sdate); + } catch (Exception e) { + return null; + } + } + + public static String getDateString(Date date) { + return dateFormater.get().format(date); + } + + public static String getDateString(String sdate) { + return dateFormat3.get().format(toDate(sdate)); + } + + /** + * 以友好的方式显示时间 + * + * @param sdate + * @return + */ + public static String friendly_time(String sdate) { + Date time = null; + + if (TimeZoneUtil.isInEasternEightZones()) + time = toDate(sdate); + else + time = TimeZoneUtil.transformTime(toDate(sdate), + TimeZone.getTimeZone("GMT+08"), TimeZone.getDefault()); + + if (time == null) { + return "Unknown"; + } + String ftime = ""; + Calendar cal = Calendar.getInstance(); + + // 判断是否是同一天 + String curDate = dateFormater2.get().format(cal.getTime()); + String paramDate = dateFormater2.get().format(time); + if (curDate.equals(paramDate)) { + int hour = (int) ((cal.getTimeInMillis() - time.getTime()) / 3600000); + if (hour == 0) + ftime = Math.max( + (cal.getTimeInMillis() - time.getTime()) / 60000, 1) + + "分钟前"; + else + ftime = hour + "小时前"; + return ftime; + } + + long lt = time.getTime() / 86400000; + long ct = cal.getTimeInMillis() / 86400000; + int days = (int) (ct - lt); + if (days == 0) { + int hour = (int) ((cal.getTimeInMillis() - time.getTime()) / 3600000); + if (hour == 0) + ftime = Math.max( + (cal.getTimeInMillis() - time.getTime()) / 60000, 1) + + "分钟前"; + else + ftime = hour + "小时前"; + } else if (days == 1) { + ftime = "昨天"; + } else if (days == 2) { + ftime = "前天 "; + } else if (days > 2 && days < 31) { + ftime = days + "天前"; + } else if (days >= 31 && days <= 2 * 31) { + ftime = "一个月前"; + } else if (days > 2 * 31 && days <= 3 * 31) { + ftime = "2个月前"; + } else if (days > 3 * 31 && days <= 4 * 31) { + ftime = "3个月前"; + } else { + ftime = dateFormater2.get().format(time); + } + return ftime; + } + + public static String friendly_time2(String sdate) { + String res = ""; + if (isEmpty(sdate)) + return ""; + + String[] weekDays = {"星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"}; + String currentData = StringUtils.getDataTime("MM-dd"); + int currentDay = toInt(currentData.substring(3)); + int currentMoth = toInt(currentData.substring(0, 2)); + + int sMoth = toInt(sdate.substring(5, 7)); + int sDay = toInt(sdate.substring(8, 10)); + int sYear = toInt(sdate.substring(0, 4)); + Date dt = new Date(sYear, sMoth - 1, sDay - 1); + + if (sDay == currentDay && sMoth == currentMoth) { + res = "今天 / " + weekDays[getWeekOfDate(new Date())]; + } else if (sDay == currentDay + 1 && sMoth == currentMoth) { + res = "昨天 / " + weekDays[(getWeekOfDate(new Date()) + 6) % 7]; + } else { + if (sMoth < 10) { + res = "0"; + } + res += sMoth + "/"; + if (sDay < 10) { + res += "0"; + } + res += sDay + " / " + weekDays[getWeekOfDate(dt)]; + } + + return res; + } + + + /** + * 智能格式化 + */ + public static String friendly_time3(String sdate) { + String res = ""; + if (isEmpty(sdate)) + return ""; + + Date date = StringUtils.toDate(sdate); + if (date == null) + return sdate; + + SimpleDateFormat format = dateFormater2.get(); + + if (isToday(date.getTime())) { + format.applyPattern(isMorning(date.getTime()) ? "上午 hh:mm" : "下午 hh:mm"); + res = format.format(date); + } else if (isYesterday(date.getTime())) { + format.applyPattern(isMorning(date.getTime()) ? "昨天 上午 hh:mm" : "昨天 下午 hh:mm"); + res = format.format(date); + } else if (isCurrentYear(date.getTime())) { + format.applyPattern(isMorning(date.getTime()) ? "MM-dd 上午 hh:mm" : "MM-dd 下午 hh:mm"); + res = format.format(date); + } else { + format.applyPattern(isMorning(date.getTime()) ? "yyyy-MM-dd 上午 hh:mm" : "yyyy-MM-dd 下午 hh:mm"); + res = format.format(date); + } + return res; + } + + /** + * @return 判断一个时间是不是上午 + */ + public static boolean isMorning(long when) { + android.text.format.Time time = new android.text.format.Time(); + time.set(when); + + int hour = time.hour; + return (hour >= 0) && (hour < 12); + } + + /** + * @return 判断一个时间是不是今天 + */ + public static boolean isToday(long when) { + android.text.format.Time time = new android.text.format.Time(); + time.set(when); + + int thenYear = time.year; + int thenMonth = time.month; + int thenMonthDay = time.monthDay; + + time.set(System.currentTimeMillis()); + return (thenYear == time.year) + && (thenMonth == time.month) + && (thenMonthDay == time.monthDay); + } + + /** + * @return 判断一个时间是不是昨天 + */ + public static boolean isYesterday(long when) { + android.text.format.Time time = new android.text.format.Time(); + time.set(when); + + int thenYear = time.year; + int thenMonth = time.month; + int thenMonthDay = time.monthDay; + + time.set(System.currentTimeMillis()); + return (thenYear == time.year) + && (thenMonth == time.month) + && (time.monthDay - thenMonthDay == 1); + } + + /** + * @return 判断一个时间是不是今年 + */ + public static boolean isCurrentYear(long when) { + android.text.format.Time time = new android.text.format.Time(); + time.set(when); + + int thenYear = time.year; + + time.set(System.currentTimeMillis()); + return (thenYear == time.year); + } + + /** + * 获取当前日期是星期几
+ * + * @param dt + * @return 当前日期是星期几 + */ + public static int getWeekOfDate(Date dt) { + Calendar cal = Calendar.getInstance(); + cal.setTime(dt); + int w = cal.get(Calendar.DAY_OF_WEEK) - 1; + if (w < 0) + w = 0; + return w; + } + + /** + * 判断给定字符串时间是否为今日 + * + * @param sdate + * @return boolean + */ + public static boolean isToday(String sdate) { + boolean b = false; + Date time = toDate(sdate); + Date today = new Date(); + if (time != null) { + String nowDate = dateFormater2.get().format(today); + String timeDate = dateFormater2.get().format(time); + if (nowDate.equals(timeDate)) { + b = true; + } + } + return b; + } + + /** + * 是否是相同的一天 + * @param sDate1 sDate1 + * @param sDate2 sDate2 + * @return + */ + public static boolean isSameDay(String sDate1,String sDate2){ + if(TextUtils.isEmpty(sDate1) || TextUtils.isEmpty(sDate2)){ + return false; + } + boolean b = false; + Date date1 = toDate(sDate1); + Date date2 = toDate(sDate2); + if(date1!= null && date2 != null){ + String d1 = dateFormater2.get().format(date1); + String d2 = dateFormater2.get().format(date2); + if (d1.equals(d2)) { + b = true; + } + } + return b; + } + + /** + * 返回long类型的今天的日期 + * + * @return + */ + public static long getToday() { + Calendar cal = Calendar.getInstance(); + String curDate = dateFormater2.get().format(cal.getTime()); + curDate = curDate.replace("-", ""); + return Long.parseLong(curDate); + } + + public static String getCurTimeStr() { + Calendar cal = Calendar.getInstance(); + String curDate = dateFormater.get().format(cal.getTime()); + return curDate; + } + + /*** + * 计算两个时间差,返回的是的秒s + * + * @param dete1 + * @param date2 + * @return + * @author 火蚁 2015-2-9 下午4:50:06 + */ + public static long calDateDifferent(String dete1, String date2) { + + long diff = 0; + + Date d1 = null; + Date d2 = null; + + try { + d1 = dateFormater.get().parse(dete1); + d2 = dateFormater.get().parse(date2); + + // 毫秒ms + diff = d2.getTime() - d1.getTime(); + + } catch (Exception e) { + e.printStackTrace(); + } + + return diff / 1000; + } + + /** + * 判断给定字符串是否空白串。 空白串是指由空格、制表符、回车符、换行符组成的字符串 若输入字符串为null或空字符串,返回true + * + * @param input + * @return boolean + */ + public static boolean isEmpty(String input) { + if (input == null || "".equals(input)) + return true; + + for (int i = 0; i < input.length(); i++) { + char c = input.charAt(i); + if (c != ' ' && c != '\t' && c != '\r' && c != '\n') { + return false; + } + } + return true; + } + + /** + * 判断是不是一个合法的电子邮件地址 + * + * @param email + * @return + */ + public static boolean isEmail(String email) { + if (email == null || email.trim().length() == 0) + return false; + return emailer.matcher(email).matches(); + } + + /** + * 判断一个url是否为图片url + * + * @param url + * @return + */ + public static boolean isImgUrl(String url) { + if (url == null || url.trim().length() == 0) + return false; + return IMG_URL.matcher(url).matches(); + } + + /** + * 判断是否为一个合法的url地址 + * + * @param str + * @return + */ + public static boolean isUrl(String str) { + if (str == null || str.trim().length() == 0) + return false; + return URL.matcher(str).matches(); + } + + /** + * 字符串转整数 + * + * @param str + * @param defValue + * @return + */ + public static int toInt(String str, int defValue) { + try { + return Integer.parseInt(str); + } catch (Exception e) { + } + return defValue; + } + + /** + * 对象转整数 + * + * @param obj + * @return 转换异常返回 0 + */ + public static int toInt(Object obj) { + if (obj == null) + return 0; + return toInt(obj.toString(), 0); + } + + /** + * 对象转整数 + * + * @param obj + * @return 转换异常返回 0 + */ + public static long toLong(String obj) { + try { + return Long.parseLong(obj); + } catch (Exception e) { + } + return 0; + } + + /** + * 字符串转布尔值 + * + * @param b + * @return 转换异常返回 false + */ + public static boolean toBool(String b) { + try { + return Boolean.parseBoolean(b); + } catch (Exception e) { + } + return false; + } + + public static String getString(String s) { + return s == null ? "" : s; + } + + /** + * 将一个InputStream流转换成字符串 + * + * @param is + * @return + */ + public static String toConvertString(InputStream is) { + StringBuffer res = new StringBuffer(); + InputStreamReader isr = new InputStreamReader(is); + BufferedReader read = new BufferedReader(isr); + try { + String line; + line = read.readLine(); + while (line != null) { + res.append(line + "
"); + line = read.readLine(); + } + } catch (IOException e) { + e.printStackTrace(); + } finally { + try { + if (null != isr) { + isr.close(); + isr.close(); + } + if (null != read) { + read.close(); + read = null; + } + if (null != is) { + is.close(); + is = null; + } + } catch (IOException e) { + } + } + return res.toString(); + } + + /*** + * 截取字符串 + * + * @param start 从那里开始,0算起 + * @param num 截取多少个 + * @param str 截取的字符串 + * @return + */ + public static String getSubString(int start, int num, String str) { + if (str == null) { + return ""; + } + int leng = str.length(); + if (start < 0) { + start = 0; + } + if (start > leng) { + start = leng; + } + if (num < 0) { + num = 1; + } + int end = start + num; + if (end > leng) { + end = leng; + } + return str.substring(start, end); + } + + /** + * 获取当前时间为每年第几周 + * + * @return + */ + public static int getWeekOfYear() { + return getWeekOfYear(new Date()); + } + + /** + * 获取当前时间为每年第几周 + * + * @param date + * @return + */ + public static int getWeekOfYear(Date date) { + Calendar c = Calendar.getInstance(); + c.setFirstDayOfWeek(Calendar.MONDAY); + c.setTime(date); + int week = c.get(Calendar.WEEK_OF_YEAR) - 1; + week = week == 0 ? 52 : week; + return week > 0 ? week : 1; + } + + public static int[] getCurrentDate() { + int[] dateBundle = new int[3]; + String[] temp = getDataTime("yyyy-MM-dd").split("-"); + + for (int i = 0; i < 3; i++) { + try { + dateBundle[i] = Integer.parseInt(temp[i]); + } catch (Exception e) { + dateBundle[i] = 0; + } + } + return dateBundle; + } + + /** + * 返回当前系统时间 + */ + public static String getDataTime(String format) { + SimpleDateFormat df = new SimpleDateFormat(format); + return df.format(new Date()); + } + +} diff --git a/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/utils/SystemUtils.java b/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/utils/SystemUtils.java new file mode 100644 index 0000000..3bee5ce --- /dev/null +++ b/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/utils/SystemUtils.java @@ -0,0 +1,225 @@ +package com.example.administrator.myapplication.utils; + +import android.annotation.TargetApi; +import android.app.Activity; +import android.content.Context; +import android.content.Intent; +import android.content.SharedPreferences; +import android.content.res.AssetManager; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import android.net.Uri; +import android.os.Build; +import android.util.DisplayMetrics; + +import com.example.administrator.myapplication.R; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; + +/** + * Created by htq on 2016/8/10. + */ +public class SystemUtils { + + private Context context; + private String PREF_NAME = "creativelocker.pref"; + public final String KEY_NOTE_DRAFT = "KEY_NOTE_DRAFT"; + private final String BG_PIC_PATH ="bg_pic_path"; + + public SystemUtils(Context context) + { + this.context=context; + } + + public String getNoteDraft() { + return getPreferences().getString( + KEY_NOTE_DRAFT , ""); + } + + + public void setNoteDraft(String draft) { + set(KEY_NOTE_DRAFT , draft); + } + + public void set(String key, String value) { + SharedPreferences.Editor editor = getPreferences().edit(); + editor.putString(key, value); + editor.commit(); + } + + public SharedPreferences getPreferences() { + SharedPreferences pre =context.getSharedPreferences(PREF_NAME, + Context.MODE_MULTI_PROCESS); + return pre; + } + + public boolean isFirstUse() + { + if(getString("isFirstUse")==null) + { + return true; + } + return false; + } +public boolean isTarn() +{ + return getBoolean("isTran"); +} + public String getString(String str) + { + SharedPreferences share= getPreferences(); + return share.getString(str,null); + } + public boolean getBoolean(String str) + { + SharedPreferences share= getPreferences(); + return share.getBoolean(str,false); + } + public void setBoolean(String str,boolean bool) + { + SharedPreferences.Editor editor = getPreferences().edit(); + editor.putBoolean(str,bool); + editor.commit(); + } + @TargetApi(Build.VERSION_CODES.HONEYCOMB) + public SharedPreferences getPreferences(String prefName) { + return context.getSharedPreferences(prefName, + Context.MODE_MULTI_PROCESS); + } + + /** + * 获取屏幕宽度 + */ + public static int getScreenW(Context aty) { + DisplayMetrics dm = aty.getResources().getDisplayMetrics(); + return dm.widthPixels; + } + + /** + * 获取屏幕高度 + */ + public static int getScreenH(Context aty) { + DisplayMetrics dm = aty.getResources().getDisplayMetrics(); + return dm.heightPixels; + } + + /** + * 保存背景皮肤图片的地址 + * @author: htq + */ + public void saveBgPicPath(String path) + { + set(BG_PIC_PATH,path); + + } + + public String getPath() { + return getString(BG_PIC_PATH); + } + + public Bitmap getBitmapByPath(Activity aty, String path) { + AssetManager am = aty.getAssets(); + Bitmap bitmap = null; + InputStream is =null; + try { + is = am.open("bkgs/" + path); + bitmap = BitmapFactory.decodeStream(is); + is.close(); + } catch (IOException e) { + e.printStackTrace(); + } + return bitmap; + } + + /** + * @author htq_ + * @param mActivity + * bolg:bolg.csdn.net/htq__ + */ + public static void shareApp(Activity mActivity) + { + String shareAppContent="各位亲爱的小伙伴们,我发现了一款非常好用且颜值爆表的记事本App,分享给大家,记得关注作者的博客http://blog.csdn.net/htq__,福利多多哦!"; + + new File(mActivity.getFilesDir(), "share.jpg").deleteOnExit(); + FileOutputStream fileOutputStream=null; + try { + fileOutputStream = mActivity.openFileOutput( + "share.jpg", 1); + } catch (FileNotFoundException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + Bitmap pic=BitmapFactory.decodeResource(mActivity.getResources(),R.mipmap.app_icon); + pic.compress(Bitmap.CompressFormat.JPEG, 100,fileOutputStream); + + + Intent intent = new Intent("android.intent.action.SEND"); + intent.setType("image/*"); + intent.putExtra("sms_body", shareAppContent); + intent.putExtra("android.intent.extra.TEXT",shareAppContent); + intent.putExtra("android.intent.extra.STREAM", + Uri.fromFile(new File(mActivity.getFilesDir(), "share.jpg"))); + intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); + mActivity.startActivity(Intent.createChooser(intent,"好东西要与小伙伴们一起分享")); + } + + public static void shareNote(Activity mActivity,String noteContent) + { + +// new File(mActivity.getFilesDir(), "share.jpg").deleteOnExit(); +// FileOutputStream fileOutputStream=null; +// try { +// fileOutputStream = mActivity.openFileOutput( +// "share.jpg", 1); +// } catch (FileNotFoundException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// +// Bitmap pic=BitmapFactory.decodeResource(mActivity.getResources(),R.mipmap.app_icon); +// pic.compress(Bitmap.CompressFormat.JPEG, 100,fileOutputStream); + + + Intent intent = new Intent("android.intent.action.SEND"); + // intent.setType("image/*"); + intent.setType("text/plain"); + // intent.putExtra("sms_body", noteContent); + intent.putExtra("android.intent.extra.TEXT",noteContent); +// intent.putExtra("android.intent.extra.STREAM", +// Uri.fromFile(new File(mActivity.getFilesDir(), "share.jpg"))); + intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); + mActivity.startActivity(Intent.createChooser(intent,"好东西要与小伙伴们一起分享")); + } + /** + * 分享功能 + * @param msgTitle + * 消息标题 + * @param msgText + * 消息内容 + * @param imgPath + * 图片路径,不分享图片则传null + */ + public static void shareMsg(Activity mActivity, String msgTitle, String msgText, + String imgPath) { + Intent intent = new Intent(Intent.ACTION_SEND); + if (imgPath == null || imgPath.equals("")) { + intent.setType("text/plain"); // 纯文本 + } else { + File f = new File(imgPath); + if (f != null && f.exists() && f.isFile()) { + intent.setType("image/jpg"); + Uri u = Uri.fromFile(f); + intent.putExtra(Intent.EXTRA_STREAM, u); + } + } + intent.putExtra(Intent.EXTRA_SUBJECT, msgTitle); + intent.putExtra(Intent.EXTRA_TEXT, msgText); + intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + mActivity.startActivity(Intent.createChooser(intent,"好东西要与小伙伴们一起分享")); + } +} diff --git a/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/utils/TimeZoneUtil.java b/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/utils/TimeZoneUtil.java new file mode 100644 index 0000000..9c1fbe0 --- /dev/null +++ b/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/utils/TimeZoneUtil.java @@ -0,0 +1,40 @@ +package com.example.administrator.myapplication.utils; + +import java.util.Date; +import java.util.TimeZone; + +/** + * @author HuangWenwei + * + * @date 2014年10月9日 + */ +public class TimeZoneUtil { + + /** + * 判断用户的设备时区是否为东八区(中国) 2014年7月31日 + * @return + */ + public static boolean isInEasternEightZones() { + boolean defaultVaule = true; + if (TimeZone.getDefault() == TimeZone.getTimeZone("GMT+08")) + defaultVaule = true; + else + defaultVaule = false; + return defaultVaule; + } + + /** + * 根据不同时区,转换时间 2014年7月31日 + * @param time + * @return + */ + public static Date transformTime(Date date, TimeZone oldZone, TimeZone newZone) { + Date finalDate = null; + if (date != null) { + int timeOffset = oldZone.getOffset(date.getTime()) + - newZone.getOffset(date.getTime()); + finalDate = new Date(date.getTime() - timeOffset); + } + return finalDate; + } +} diff --git a/src/MyApplication/build.gradle b/src/MyApplication/build.gradle index c2eea8e..407a12f 100644 --- a/src/MyApplication/build.gradle +++ b/src/MyApplication/build.gradle @@ -6,7 +6,7 @@ buildscript { } dependencies { classpath 'com.android.tools.build:gradle:2.3.3' - + classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files }