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
This commit is contained in:
parent
281b9b9b63
commit
9ae42aaeb4
|
@ -0,0 +1,6 @@
|
|||
|
||||
Osquid:S1118":Add a private constructor to hide the implicit public one.(®»–ü
|
||||
ssquid:S1488"YImmediately return this expression instead of assigning it to the temporary variable "s".(”‘€»ûÿÿÿÿ
|
||||
=squid:S1148"#Use a logger to log this exception.(€ÉÔ…ýÿÿÿÿ
|
||||
tsquid:S1149"_Replace the synchronized class "StringBuffer" by an unsynchronized one such as "StringBuilder".(<28>ÿ©–
|
||||
isquid:S00100"NRename this method name to match the regular expression '^[a-z][a-zA-Z0-9]*$'.(¨Ž”íøÿÿÿÿ
|
|
@ -0,0 +1,9 @@
|
|||
|
||||
Lsquid:S1135"2Complete the task associated to this TODO comment.(» æžÿÿÿÿÿ
|
||||
Lsquid:S1135"2Complete the task associated to this TODO comment.(» æžÿÿÿÿÿ
|
||||
csquid:CallToDeprecatedMethod"=Remove this use of "setBackgroundDrawable"; it is deprecated.(Ìý´Ÿ
|
||||
Lsquid:S1135"2Complete the task associated to this TODO comment.(» æžÿÿÿÿÿ
|
||||
Lsquid:S1135"2Complete the task associated to this TODO comment.(» æžÿÿÿÿÿ
|
||||
>squid:S1659"*Declare "backgroundIv" on a separate line.(·«ï
|
||||
bsquid:S1226"HIntroduce a new variable instead of reusing the parameter "convertView".(îªÙ¨ùÿÿÿÿ
|
||||
rsquid:S1450"]Remove the "mDefaultBgPath" field and declare it as a local variable in the relevant methods.(çêè
|
|
@ -0,0 +1,4 @@
|
|||
|
||||
hsquid:ModifiersOrderCheck"EReorder the modifiers to comply with the Java Language Specification.(<28>Þúí
|
||||
Tsquid:S1118":Add a private constructor to hide the implicit public one.(ŽÞëÿùÿÿÿÿ
|
||||
Osquid:S1118":Add a private constructor to hide the implicit public one.(§Ú¦“
|
|
@ -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.(à”£½
|
|
@ -0,0 +1,9 @@
|
|||
|
||||
vsquid:S3008"\Rename this field "BMOB_PICTURE_PATH" to match the regular expression '^[a-z][a-zA-Z0-9]*$'.(²Ó˜Àûÿÿÿÿ
|
||||
Qsquid: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.(š¸°‚
|
||||
Tsquid:S1118":Add a private constructor to hide the implicit public one.(¯¨×¼ýÿÿÿÿ
|
||||
Fsquid:S1444"1Make this "public static MyAvatarDir" field final(š¸°‚
|
||||
Gsquid: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.(²Ó˜Àûÿÿÿÿ
|
||||
ksquid:S3008"VRename this field "MyAvatarDir" to match the regular expression '^[a-z][a-zA-Z0-9]*$'.(š¸°‚
|
|
@ -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.(±Õ»²
|
||||
Tsquid:S1118":Add a private constructor to hide the implicit public one.(<28>“³±ûÿÿÿÿ
|
|
@ -0,0 +1,6 @@
|
|||
|
||||
Isquid:S1066"/Merge this if statement with the enclosing one.(©¶©‡ûÿÿÿÿ
|
||||
Vsquid: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".(ìåÌ–
|
||||
Dsquid:S1066"/Merge this if statement with the enclosing one.(²<><C2B2>¾
|
||||
Osquid:S1118":Add a private constructor to hide the implicit public one.(§Á¡Œ
|
|
@ -0,0 +1,8 @@
|
|||
|
||||
`squid:CommentedOutCodeLine"<This block of commented-out lines of code should be removed.(Žëê·
|
||||
_squid:CommentedOutCodeLine"<This block of commented-out lines of code should be removed.(¡ÅøP
|
||||
`squid:CommentedOutCodeLine"<This block of commented-out lines of code should be removed.(ªÌ¿ú
|
||||
`squid:CommentedOutCodeLine"<This block of commented-out lines of code should be removed.(†äßï
|
||||
esquid:CommentedOutCodeLine"<This block of commented-out lines of code should be removed.(éØ»Úûÿÿÿÿ
|
||||
jsquid:S1206"PThis class overrides "equals()" and should therefore also override "hashCode()".(Ý¢êÍýÿÿÿÿ
|
||||
`squid:CommentedOutCodeLine"<This block of commented-out lines of code should be removed.(Áä–—
|
|
@ -1,3 +1,3 @@
|
|||
|
||||
Tsquid:S1118":Add a private constructor to hide the implicit public one.(㉷눪<E389B7><EB88AA><EFBFBD><EFBFBD>
|
||||
gsquid:S3776"RRefactor this method to reduce its Cognitive Complexity from 20 to the 15 allowed.(±ºÝ¹
|
||||
Tsquid:S1118":Add a private constructor to hide the implicit public one.(㉷눪<E389B7><EB88AA><EFBFBD><EFBFBD>
|
|
@ -1,11 +1,11 @@
|
|||
|
||||
qsquid:S3008"WRename this field "BITMAP_ERROR" to match the regular expression '^[a-z][a-zA-Z0-9]*$'.(•†<E280A2>ÿÿÿÿÿ
|
||||
lsquid:S3008"WRename this field "BITMAP_PRESS" to match the regular expression '^[a-z][a-zA-Z0-9]*$'.(üÉÌÍ
|
||||
[squid:S1126"AReplace this if-then-else statement by a single return statement.(¾ê¹¥üÿÿÿÿ
|
||||
Lsquid:S1444"2Make this "public static BITMAP_ERROR" field final(•†<E280A2>ÿÿÿÿÿ
|
||||
msquid:S3008"XRename this field "BITMAP_NORMAL" to match the regular expression '^[a-z][a-zA-Z0-9]*$'.(û¹ß¶
|
||||
„"squid:ClassVariableVisibilityCheck"XMake BITMAP_PRESS a static final constant or non-public and provide accessors if needed.(üÉÌÍ
|
||||
…"squid:ClassVariableVisibilityCheck"YMake BITMAP_NORMAL a static final constant or non-public and provide accessors if needed.(û¹ß¶
|
||||
‰"squid:ClassVariableVisibilityCheck"XMake BITMAP_ERROR a static final constant or non-public and provide accessors if needed.(•†<E280A2>ÿÿÿÿÿ
|
||||
„"squid:ClassVariableVisibilityCheck"XMake BITMAP_PRESS a static final constant or non-public and provide accessors if needed.(üÉÌÍ
|
||||
Hsquid:S1444"3Make this "public static BITMAP_NORMAL" field final(û¹ß¶
|
||||
Gsquid:S1444"2Make this "public static BITMAP_PRESS" field final(üÉÌÍ
|
||||
[squid:S1126"AReplace this if-then-else statement by a single return statement.(¾ê¹¥üÿÿÿÿ
|
||||
…"squid:ClassVariableVisibilityCheck"YMake BITMAP_NORMAL a static final constant or non-public and provide accessors if needed.(û¹ß¶
|
||||
msquid:S3008"XRename this field "BITMAP_NORMAL" to match the regular expression '^[a-z][a-zA-Z0-9]*$'.(û¹ß¶
|
||||
Lsquid:S1444"2Make this "public static BITMAP_ERROR" field final(•†<E280A2>ÿÿÿÿÿ
|
||||
lsquid:S3008"WRename this field "BITMAP_PRESS" to match the regular expression '^[a-z][a-zA-Z0-9]*$'.(üÉÌÍ
|
|
@ -0,0 +1,10 @@
|
|||
|
||||
;squid:S1452"&Remove usage of generic wildcard type.(õ›Éü
|
||||
Osquid:S1118":Add a private constructor to hide the implicit public one.(؉ ú
|
||||
Zsquid:S2147"ECombine this catch with the one at line 185, which has the same body.(à“˜ƒ
|
||||
Dsquid:S00108")Either remove or fill this block of code.(ÒÌâ–øÿÿÿÿ
|
||||
Dsquid:S00108")Either remove or fill this block of code.(ÒÌâ–øÿÿÿÿ
|
||||
Zsquid:S2147"ECombine this catch with the one at line 185, which has the same body.(“Ç—Ã
|
||||
Dsquid:S00108")Either remove or fill this block of code.(ÒÌâ–øÿÿÿÿ
|
||||
Osquid:S1118":Add a private constructor to hide the implicit public one.(Ÿ¶í÷
|
||||
Dsquid:S00108")Either remove or fill this block of code.(ÒÌâ–øÿÿÿÿ
|
|
@ -0,0 +1,4 @@
|
|||
|
||||
esquid:CommentedOutCodeLine"<This block of commented-out lines of code should be removed.(·Äü‡ýÿÿÿÿ
|
||||
esquid:CommentedOutCodeLine"<This block of commented-out lines of code should be removed.(¬œÐ²ûÿÿÿÿ
|
||||
`squid:CommentedOutCodeLine"<This block of commented-out lines of code should be removed.(‚”’ö
|
|
@ -0,0 +1,5 @@
|
|||
|
||||
ssquid:S00117"QRename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.(Öæ«Ùùÿÿÿÿ8åܽؤ,
|
||||
Vsquid:S1118":Add a private constructor to hide the implicit public one.(±éó<C3A9>8åܽؤ,
|
||||
Asquid:S2068" Remove this hard-coded password.(ñ¤Ïáùÿÿÿÿ8åܽؤ,
|
||||
<squid:S2068" Remove this hard-coded password.(Ø´˜Ù8åܽؤ,
|
|
@ -0,0 +1,3 @@
|
|||
|
||||
tsquid:S1488"_Immediately return this expression instead of assigning it to the temporary variable "options".(çâÛì
|
||||
Osquid:S1118":Add a private constructor to hide the implicit public one.(‘˜Š³
|
|
@ -0,0 +1,10 @@
|
|||
|
||||
gsquid:S00117"QRename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.(Š÷˜Í
|
||||
Vsquid:S2184"ACast one of the operands of this addition operation to a "float".(ÆÞ–’
|
||||
Ysquid:S2184"DCast one of the operands of this subtraction operation to a "float".(ð䘊
|
||||
Vsquid:S2184"ACast one of the operands of this addition operation to a "float".(ƒ‰Á¨
|
||||
Tsquid:S1118":Add a private constructor to hide the implicit public one.(̲<C38C>íùÿÿÿÿ
|
||||
›squid:S1186"€Add a nested comment explaining why this method is empty, throw an UnsupportedOperationException or complete the implementation.(â¡ú—ÿÿÿÿÿ
|
||||
=squid:S1172"(Remove this unused method parameter "X".(Š÷˜Í
|
||||
^squid:S2184"DCast one of the operands of this subtraction operation to a "float".(¨ùã¸ùÿÿÿÿ
|
||||
›squid:S1186"€Add a nested comment explaining why this method is empty, throw an UnsupportedOperationException or complete the implementation.(•€ÕÎùÿÿÿÿ
|
|
@ -0,0 +1,24 @@
|
|||
|
||||
‚squid:S1192"hDefine a constant instead of duplicating this literal "好东西è¦<C3A8>与å°<C3A5>伙伴们一起分享" 3 times.(Á…Ï¿úÿÿÿÿ
|
||||
Gsquid:S1135"2Complete the task associated to this TODO comment.(ÉÚõÎ
|
||||
;squid:S1170"!Make this final field static too.(¯¶±Ÿýÿÿÿÿ
|
||||
_squid:CommentedOutCodeLine"<This block of commented-out lines of code should be removed.(ÿ¨¬j
|
||||
Lsquid:S2589"7Remove this expression which always evaluates to "true"(ÿý†
|
||||
usquid:S1488"[Immediately return this expression instead of assigning it to the temporary variable "pre".(úš ¡ùÿÿÿÿ
|
||||
lsquid:S00116"VRename this field "BG_PIC_PATH" to match the regular expression '^[a-z][a-zA-Z0-9]*$'.(¥òûŸ
|
||||
6squid:S1170"!Make this final field static too.(¥òûŸ
|
||||
=squid:S1148"#Use a logger to log this exception.(€ÉÔ…ýÿÿÿÿ
|
||||
`squid:CommentedOutCodeLine"<This block of commented-out lines of code should be removed.(ÆΰÇ
|
||||
_squid:CommentedOutCodeLine"<This block of commented-out lines of code should be removed.(àˆüz
|
||||
_squid:S1192"JDefine a constant instead of duplicating this literal "share.jpg" 3 times.(ãî<C3A3>Ö
|
||||
Vsquid:S1126"AReplace this if-then-else statement by a single return statement.(ýðÞ¬
|
||||
esquid:CallToDeprecatedMethod":Remove this use of "MODE_MULTI_PROCESS"; it is deprecated.(Žù›‡ûÿÿÿÿ
|
||||
osquid:S00116"TRename this field "PREF_NAME" to match the regular expression '^[a-z][a-zA-Z0-9]*$'.(«ú±ôøÿÿÿÿ
|
||||
`squid:CommentedOutCodeLine"<This block of commented-out lines of code should be removed.(†€éˆ
|
||||
=squid:S1148"#Use a logger to log this exception.(€ÉÔ…ýÿÿÿÿ
|
||||
tsquid:S00116"YRename this field "KEY_NOTE_DRAFT" to match the regular expression '^[a-z][a-zA-Z0-9]*$'.(¯¶±Ÿýÿÿÿÿ
|
||||
esquid:CallToDeprecatedMethod":Remove this use of "MODE_MULTI_PROCESS"; it is deprecated.(Žù›‡ûÿÿÿÿ
|
||||
Lsquid:S1135"2Complete the task associated to this TODO comment.(ÕÌ<C395>®þÿÿÿÿ
|
||||
esquid:CommentedOutCodeLine"<This block of commented-out lines of code should be removed.(¸¯þŸøÿÿÿÿ
|
||||
esquid:CommentedOutCodeLine"<This block of commented-out lines of code should be removed.(<28>Žª´ÿÿÿÿÿ
|
||||
`squid:CommentedOutCodeLine"<This block of commented-out lines of code should be removed.(¯Öýã
|
|
@ -1,3 +1,3 @@
|
|||
|
||||
Tsquid:S1161":Add the "@Override" annotation above this method signature(â¢çÊüÿÿÿÿ
|
||||
hsquid:MaximumInheritanceDepth"<This class has 7 parents which is greater than 5 authorized.(ž<> ¨ýÿÿÿÿ
|
||||
Tsquid:S1161":Add the "@Override" annotation above this method signature(â¢çÊüÿÿÿÿ
|
|
@ -0,0 +1,11 @@
|
|||
|
||||
_squid:CommentedOutCodeLine"<This block of commented-out lines of code should be removed.(ÎÂù
|
||||
esquid:CommentedOutCodeLine"<This block of commented-out lines of code should be removed.(ÜÖè‡ýÿÿÿÿ
|
||||
`squid:CommentedOutCodeLine"<This block of commented-out lines of code should be removed.(´¢‘œ
|
||||
esquid:CommentedOutCodeLine"<This block of commented-out lines of code should be removed.(âÝ‹Œûÿÿÿÿ
|
||||
esquid:CommentedOutCodeLine"<This block of commented-out lines of code should be removed.(†˜é…ûÿÿÿÿ
|
||||
esquid:CommentedOutCodeLine"<This block of commented-out lines of code should be removed.(¦˜Å…üÿÿÿÿ
|
||||
`squid:CommentedOutCodeLine"<This block of commented-out lines of code should be removed.(<28><>³Ÿ
|
||||
_squid:CommentedOutCodeLine"<This block of commented-out lines of code should be removed.(ú÷€
|
||||
1squid:S1220""Move this file to a named package.
|
||||
esquid:CommentedOutCodeLine"<This block of commented-out lines of code should be removed.(žá§•øÿÿÿÿ
|
|
@ -1,22 +1,22 @@
|
|||
|
||||
Lsquid:S2589"7Remove this expression which always evaluates to "true"(¯É©“
|
||||
Ksquid:S2696"6Make the enclosing method "static" or remove this set.(µâ‚Ø
|
||||
hsquid:MaximumInheritanceDepth"<This class has 6 parents which is greater than 5 authorized.(¸–þ§þÿÿÿÿ
|
||||
Ssquid:S1226">Introduce a new variable instead of reusing the parameter "x".(úµÈ™
|
||||
lsquid:S3776"RRefactor this method to reduce its Cognitive Complexity from 17 to the 15 allowed.(Ö¼Ù<C2BC>ýÿÿÿÿ
|
||||
nsquid:S2293"YReplace the type specification in this constructor call with the diamond operator ("<>").(«Ûô‘
|
||||
Isquid:EmptyStatementUsageCheck"Remove this empty statement.(ôŸŽìúÿÿÿÿ
|
||||
nsquid:S1450"TRemove the "moveX" field and declare it as a local variable in the relevant methods.(Í àØþÿÿÿÿ
|
||||
asquid:S2184"GCast one of the operands of this multiplication operation to a "float".(÷æ‰Ðùÿÿÿÿ
|
||||
S"squid:SwitchLastCaseIsDefaultCheck""Add a default case to this switch.(¯·ø‹úÿÿÿÿ
|
||||
Tsquid: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.(ê±Ë<C2B1>úÿÿÿÿ
|
||||
S"squid:SwitchLastCaseIsDefaultCheck""Add a default case to this switch.(¯·ø‹úÿÿÿÿ
|
||||
asquid:S2184"GCast one of the operands of this multiplication operation to a "float".(÷æ‰Ðùÿÿÿÿ
|
||||
gsquid: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.(½<>ì©úÿÿÿÿ
|
||||
psquid: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.(€ÉÔ…ýÿÿÿÿ
|
||||
\squid:S2184"GCast one of the operands of this multiplication operation to a "float".(žì‘Ç
|
||||
nsquid:S1450"TRemove the "moveX" field and declare it as a local variable in the relevant methods.(Í àØþÿÿÿÿ
|
||||
Isquid:EmptyStatementUsageCheck"Remove this empty statement.(ôŸŽìúÿÿÿÿ
|
||||
Lsquid:S2589"7Remove this expression which always evaluates to "true"(¯É©“
|
||||
Ssquid:S1226">Introduce a new variable instead of reusing the parameter "y".(žÅ™õ
|
||||
lsquid:S3776"RRefactor this method to reduce its Cognitive Complexity from 17 to the 15 allowed.(»òíÖÿÿÿÿÿ
|
||||
psquid:S00115"ZRename this constant name to match the regular expression '^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$'.(‡ÚÂÖ
|
||||
hsquid:MaximumInheritanceDepth"<This class has 6 parents which is greater than 5 authorized.(¸–þ§þÿÿÿÿ
|
||||
lsquid:S3776"RRefactor this method to reduce its Cognitive Complexity from 17 to the 15 allowed.(Ö¼Ù<C2BC>ýÿÿÿÿ
|
||||
S"squid:SwitchLastCaseIsDefaultCheck""Add a default case to this switch.(¯·ø‹úÿÿÿÿ
|
||||
nsquid:S2293"YReplace the type specification in this constructor call with the diamond operator ("<>").(«Ûô‘
|
||||
=squid:S1148"#Use a logger to log this exception.(€ÉÔ…ýÿÿÿÿ
|
||||
gsquid: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.(½<>ì©úÿÿÿÿ
|
||||
Ssquid: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".(žì‘Ç
|
||||
Ksquid:S2696"6Make the enclosing method "static" or remove this set.(µâ‚Ø
|
||||
[squid:S1126"AReplace this if-then-else statement by a single return statement.(ê±Ë<C2B1>úÿÿÿÿ
|
||||
Lsquid:S2589"7Remove this expression which always evaluates to "true"(¯É©“
|
|
@ -0,0 +1,2 @@
|
|||
|
||||
isquid:MaximumInheritanceDepth"=This class has 10 parents which is greater than 5 authorized.(‹†½íÿÿÿÿÿ
|
|
@ -0,0 +1,7 @@
|
|||
|
||||
[squid:CallToDeprecatedMethod"0Remove this use of "fromHtml"; it is deprecated.(Ë–ü÷ùÿÿÿÿ
|
||||
ysquid:S1488"_Immediately return this expression instead of assigning it to the temporary variable "builder".(’âÃùÿÿÿÿ
|
||||
Osquid: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.(¸Ø§Î
|
|
@ -0,0 +1,2 @@
|
|||
|
||||
dsquid:MaximumInheritanceDepth"=This class has 10 parents which is greater than 5 authorized.(<28>ªÉç
|
|
@ -0,0 +1,43 @@
|
|||
|
||||
isquid: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.(´¾’Ñÿÿÿÿÿ
|
||||
Dsquid:S2093"*Change this "try" to a try-with-resources.(¡»¢üùÿÿÿÿ
|
||||
Asquid:S1659"'Declare "dst_right" on a separate line.(´¾’Ñÿÿÿÿÿ
|
||||
Tsquid: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.(€ÉÔ…ýÿÿÿÿ
|
||||
lsquid: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"<This block of commented-out lines of code should be removed.(±ËÅž
|
||||
Osquid:S1118":Add a private constructor to hide the implicit public one.(Þô™ê
|
||||
?squid:S1659"%Declare "dst_top" on a separate line.(´¾’Ñÿÿÿÿÿ
|
||||
T
|
||||
squid:S899";Do something with the "boolean" value returned by "delete".(²Œ<C592>ûÿÿÿÿ
|
||||
ysquid:S1488"eImmediately return this expression instead of assigning it to the temporary variable "resizedBitmap".(Ö½Þ|
|
||||
=squid:S1148"#Use a logger to log this exception.(€ÉÔ…ýÿÿÿÿ
|
||||
?squid:S00108")Either remove or fill this block of code.(<28>”ý¾
|
||||
lsquid:S00117"QRename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.(´¾’Ñÿÿÿÿÿ
|
||||
Zsquid:S2184"@Cast one of the operands of this integer division to a "double".(€ºá™øÿÿÿÿ
|
||||
[squid:S2184"ACast one of the operands of this division operation to a "float".(€ºá™øÿÿÿÿ
|
||||
lsquid:S00117"QRename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.(´¾’Ñÿÿÿÿÿ
|
||||
lsquid:S00117"QRename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.(´¾’Ñÿÿÿÿÿ
|
||||
Usquid:S2184"ACast one of the operands of this division operation to a "float".(À¬þ
|
||||
;squid:S1659"!Declare "top" on a separate line.(´¾’Ñÿÿÿÿÿ
|
||||
Bsquid:S1659"(Declare "dst_bottom" on a separate line.(´¾’Ñÿÿÿÿÿ
|
||||
>squid:S1659"$Declare "bottom" on a separate line.(´¾’Ñÿÿÿÿÿ
|
||||
Dsquid:S1066"/Merge this if statement with the enclosing one.(¼ÙØý
|
||||
Lsquid:S1135"2Complete the task associated to this TODO comment.(ÕÌ<C395>®þÿÿÿÿ
|
||||
[squid:S2184"ACast one of the operands of this division operation to a "float".(Õú²”ùÿÿÿÿ
|
||||
=squid:S1148"#Use a logger to log this exception.(€ÉÔ…ýÿÿÿÿ
|
||||
Tsquid:S1854":Remove this useless assignment to local variable "bitmap".(×ý¥Êüÿÿÿÿ
|
||||
[
|
||||
squid:S899"BDo something with the "boolean" value returned by "createNewFile".(Ð<>’Íùÿÿÿÿ
|
||||
Tsquid:S2184"@Cast one of the operands of this integer division to a "double".(À¬þ
|
||||
Lsquid:S1135"2Complete the task associated to this TODO comment.(ÕÌ<C395>®þÿÿÿÿ
|
||||
Zsquid: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.(´¾’Ñÿÿÿÿÿ
|
|
@ -0,0 +1,36 @@
|
|||
|
||||
isquid:S00100"NRename this method name to match the regular expression '^[a-z][a-zA-Z0-9]*$'.(¡¥ÎÏüÿÿÿÿ
|
||||
isquid:S00100"NRename this method name to match the regular expression '^[a-z][a-zA-Z0-9]*$'.(óµÔüúÿÿÿÿ
|
||||
isquid:S00100"NRename this method name to match the regular expression '^[a-z][a-zA-Z0-9]*$'.(òŸŒ<C5B8>þÿÿÿÿ
|
||||
?squid:S00108")Either remove or fill this block of code.(<28>”ý¾
|
||||
Rsquid:CallToDeprecatedMethod",Remove this use of "Time"; it is deprecated.(óÌæ‚
|
||||
msquid:ModifiersOrderCheck"EReorder the modifiers to comply with the Java Language Specification.(ãו‰þÿÿÿÿ
|
||||
Qsquid:S2589"7Remove this expression which always evaluates to "true"(¹ï¤Ÿýÿÿÿÿ
|
||||
ssquid:S1149"_Replace the synchronized class "StringBuffer" by an unsynchronized one such as "StringBuilder".(ÄÍœ
|
||||
|
||||
Rsquid:CallToDeprecatedMethod",Remove this use of "Time"; it is deprecated.(óÌæ‚
|
||||
lsquid: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.(óÌæ‚
|
||||
ysquid:S1488"_Immediately return this expression instead of assigning it to the temporary variable "curDate".(Ó°Ø’úÿÿÿÿ
|
||||
Rsquid:CallToDeprecatedMethod",Remove this use of "Time"; it is deprecated.(óÌæ‚
|
||||
Tsquid: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.(<28>”ý¾
|
||||
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.(<28>”ý¾
|
||||
=squid:S1148"#Use a logger to log this exception.(€ÉÔ…ýÿÿÿÿ
|
||||
Qsquid:S2589"7Remove this expression which always evaluates to "true"(ÜÞ¼<C39E>ûÿÿÿÿ
|
||||
Rsquid:CallToDeprecatedMethod",Remove this use of "Time"; it is deprecated.(óÌæ‚
|
||||
?squid:S00108")Either remove or fill this block of code.(ï£Ä
|
||||
Wsquid:S1226"BIntroduce a new variable instead of reusing the parameter "start".(ÑÉþÔ
|
||||
Tsquid:S1226"?Introduce a new variable instead of reusing the parameter "is".(¥ÁÙ¥
|
||||
Zsquid:S1226"@Introduce a new variable instead of reusing the parameter "num".(ÎÈÖ‡ýÿÿÿÿ
|
|
@ -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.(Ç¡´ôþÿÿÿÿ
|
||||
osquid:S1450"URemove the "startX" field and declare it as a local variable in the relevant methods.(Àœ<C380>£ýÿÿÿÿ
|
||||
<squid:S1659""Declare "endX" on a separate line.(Àœ<C380>£ýÿÿÿÿ
|
||||
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.(Ûû•
|
||||
<squid:S1659""Declare "endX" on a separate line.(Àœ<C380>£ýÿÿÿÿ
|
||||
osquid:S1450"URemove the "startX" field and declare it as a local variable in the relevant methods.(Àœ<C380>£ýÿÿÿÿ
|
||||
hsquid:ModifiersOrderCheck"EReorder the modifiers to comply with the Java Language Specification.(êÅ®Ü
|
|
@ -0,0 +1,2 @@
|
|||
|
||||
isquid:MaximumInheritanceDepth"=This class has 10 parents which is greater than 5 authorized.(´úÈ¢ùÿÿÿÿ
|
|
@ -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"<This block of commented-out lines of code should be removed.(‚„É“øÿÿÿÿ
|
|
@ -0,0 +1,6 @@
|
|||
|
||||
esquid:CommentedOutCodeLine"<This block of commented-out lines of code should be removed.(«·³‰ýÿÿÿÿ
|
||||
ssquid:S2293"YReplace the type specification in this constructor call with the diamond operator ("<>").(ñП’øÿÿÿÿ
|
||||
esquid:CommentedOutCodeLine"<This block of commented-out lines of code should be removed.(®ôˆÍøÿÿÿÿ
|
||||
esquid:CommentedOutCodeLine"<This block of commented-out lines of code should be removed.(ÌÙ·Îøÿÿÿÿ
|
||||
esquid:CommentedOutCodeLine"<This block of commented-out lines of code should be removed.(¯²Ç‚ÿÿÿÿÿ
|
|
@ -0,0 +1,7 @@
|
|||
|
||||
Rsquid:S1226">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'.(üÿ–Ìúÿÿÿÿ
|
||||
ssquid: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".(¹ê˜Áøÿÿÿÿ
|
|
@ -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'.(Æš…Åùÿÿÿÿ
|
||||
Lsquid: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"<This block of commented-out lines of code should be removed.(Ú°à¬
|
||||
`squid:CommentedOutCodeLine"<This block of commented-out lines of code should be removed.(ÒäÕ§
|
||||
–squid:S1186"€Add a nested comment explaining why this method is empty, throw an UnsupportedOperationException or complete the implementation.( µâ²
|
||||
esquid:CommentedOutCodeLine"<This block of commented-out lines of code should be removed.(ßÕù•ýÿÿÿÿ
|
||||
msquid:S2293"YReplace the type specification in this constructor call with the diamond operator ("<>").(Ì¿Íh
|
||||
msquid:ModifiersOrderCheck"EReorder the modifiers to comply with the Java Language Specification.(ÆŸßêùÿÿÿÿ
|
||||
lsquid:S00117"QRename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.(쇯Úþÿÿÿÿ
|
||||
esquid:CommentedOutCodeLine"<This block of commented-out lines of code should be removed.(°þíÈÿÿÿÿÿ
|
||||
hsquid:ModifiersOrderCheck"EReorder the modifiers to comply with the Java Language Specification.(¹¶Á»
|
||||
nsquid:S2293"YReplace the type specification in this constructor call with the diamond operator ("<>").(ÚÒîÊ
|
||||
`squid:CommentedOutCodeLine"<This block of commented-out lines of code should be removed.(<28>ÄŠæ
|
||||
esquid:CommentedOutCodeLine"<This block of commented-out lines of code should be removed.(㑨<E28098>úÿÿÿÿ
|
||||
esquid:CommentedOutCodeLine"<This block of commented-out lines of code should be removed.(™ØÓ¯ûÿÿÿÿ
|
||||
`squid:CommentedOutCodeLine"<This block of commented-out lines of code should be removed.(òü€–
|
||||
esquid:CommentedOutCodeLine"<This block of commented-out lines of code should be removed.(Ò£èÄûÿÿÿÿ
|
||||
~squid:UselessImportCheck"\Remove this unused import 'com.nostra13.universalimageloader.core.ImageLoaderConfiguration'.(좣±
|
||||
[squid:UnusedPrivateMethod"3Remove this unused private "updateUserHead" method.(¤È‚Ìýÿÿÿÿ
|
||||
–squid:S1186"€Add a nested comment explaining why this method is empty, throw an UnsupportedOperationException or complete the implementation.(¹ó¯™
|
||||
–squid:S1186"€Add a nested comment explaining why this method is empty, throw an UnsupportedOperationException or complete the implementation.(“¨ëø
|
||||
`squid:CommentedOutCodeLine"<This block of commented-out lines of code should be removed.(Ôˆ«¿
|
||||
msquid:ModifiersOrderCheck"EReorder the modifiers to comply with the Java Language Specification.(쇯Úþÿÿÿÿ
|
||||
isquid:UselessImportCheck"GRemove this unused import 'com.htq.baidu.coolnote.app.BaseApplication'.(°¤ù‰
|
||||
`squid:CommentedOutCodeLine"<This block of commented-out lines of code should be removed.(Ú°à¬
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
Vsquid:S2184"ACast one of the operands of this division operation to a "float".(ñÌ–à
|
||||
Vsquid:S2184"ACast one of the operands of this addition operation to a "float".(†¬’²
|
||||
Vsquid:S2184"ACast one of the operands of this addition operation to a "float".(†¬’²
|
||||
Vsquid:S2184"ACast one of the operands of this division operation to a "float".(ĵöö
|
||||
Vsquid:S2184"ACast one of the operands of this division operation to a "float".(ĵöö
|
||||
Vsquid:S2184"ACast one of the operands of this division operation to a "float".(ñÌ–à
|
||||
Vsquid:S2184"ACast one of the operands of this division operation to a "float".(ñÌ–à
|
||||
Vsquid:S2184"ACast one of the operands of this addition operation to a "float".(†¬’²
|
||||
Vsquid:S2184"ACast one of the operands of this addition operation to a "float".(†¬’²
|
|
@ -1,27 +1,27 @@
|
|||
|
||||
esquid:CommentedOutCodeLine"<This block of commented-out lines of code should be removed.(îí”Ôþÿÿÿÿ
|
||||
ssquid:S2293"YReplace the type specification in this constructor call with the diamond operator ("<>").(±±´ðþÿÿÿÿ
|
||||
:squid:S2068" Remove this hard-coded password.(Š…÷<E280A6>úÿÿÿÿ
|
||||
Bsquid:S1125"(Remove the literal "true" boolean value.(êØòëÿÿÿÿÿ
|
||||
Xsquid:S1155">Use isEmpty() to check whether the collection is empty or not.(ÃЮùÿÿÿÿ
|
||||
0squid:S1643"Use a StringBuilder instead.(븈2
|
||||
Fsquid:S1068",Remove this unused "mContext" private field.(»úžøÿÿÿÿ
|
||||
esquid:CommentedOutCodeLine"<This block of commented-out lines of code should be removed.(¬ëʳûÿÿÿÿ
|
||||
S"squid:SwitchLastCaseIsDefaultCheck""Add a default case to this switch.(ãÁð™øÿÿÿÿ
|
||||
[squid:CallToDeprecatedMethod"0Remove this use of "getWidth"; it is deprecated.(ð“ñÀþÿÿÿÿ
|
||||
4squid:S2131"Use "Integer.toString" instead.(јòö
|
||||
Dsquid:S1066"/Merge this if statement with the enclosing one.(댯Ú
|
||||
[squid:S2184"ACast one of the operands of this division operation to a "float".(¢é…ˆþÿÿÿÿ
|
||||
Bsquid:S1125"(Remove the literal "true" boolean value.(êØòëÿÿÿÿÿ
|
||||
esquid:CommentedOutCodeLine"<This block of commented-out lines of code should be removed.(îí”Ôþÿÿÿÿ
|
||||
:squid:S2068" Remove this hard-coded password.(ò¤‚›üÿÿÿÿ
|
||||
=squid:S1148"#Use a logger to log this exception.(€ÉÔ…ýÿÿÿÿ
|
||||
Zsquid:S2184"@Cast one of the operands of this integer division to a "double".(¢é…ˆþÿÿÿÿ
|
||||
esquid:CommentedOutCodeLine"<This block of commented-out lines of code should be removed.(±¹ËÌüÿÿÿÿ
|
||||
>squid:S1659"$Declare "mMoveY" on a separate line.(ŸöÁæúÿÿÿÿ
|
||||
osquid:S1450"URemove the "mMoveY" field and declare it as a local variable in the relevant methods.(ŸöÁæúÿÿÿÿ
|
||||
gsquid:S3776"RRefactor this method to reduce its Cognitive Complexity from 35 to the 15 allowed.(ôó§è
|
||||
psquid:S1450"\Remove the "mScreenHeight" field and declare it as a local variable in the relevant methods.(ÎݘZ
|
||||
osquid:S1450"URemove the "mMoveX" field and declare it as a local variable in the relevant methods.(ŸöÁæúÿÿÿÿ
|
||||
4squid:S2131"Use "Integer.toString" instead.(јòö
|
||||
esquid:CommentedOutCodeLine"<This block of commented-out lines of code should be removed.(¬ëʳûÿÿÿÿ
|
||||
[squid:S2142"FEither re-interrupt this method or rethrow the "InterruptedException".(ä ¹€
|
||||
`squid:CommentedOutCodeLine"<This block of commented-out lines of code should be removed.(îˆÝç
|
||||
psquid:S1450"\Remove the "mScreenHeight" field and declare it as a local variable in the relevant methods.(ÎݘZ
|
||||
usquid:S1450"[Remove the "mScreenWidth" field and declare it as a local variable in the relevant methods.(Ò™úªÿÿÿÿÿ
|
||||
>squid:S1659"$Declare "mMoveY" on a separate line.(ŸöÁæúÿÿÿÿ
|
||||
osquid:S1450"URemove the "mMoveY" field and declare it as a local variable in the relevant methods.(ŸöÁæúÿÿÿÿ
|
||||
Fsquid:S1068",Remove this unused "mContext" private field.(»úžøÿÿÿÿ
|
||||
gsquid: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.(ð“ñÀþÿÿÿÿ
|
||||
S"squid:SwitchLastCaseIsDefaultCheck""Add a default case to this switch.(ãÁð™øÿÿÿÿ
|
||||
Zsquid:S2184"@Cast one of the operands of this integer division to a "double".(¢é…ˆþÿÿÿÿ
|
||||
0squid:S1643"Use a StringBuilder instead.(븈2
|
||||
Dsquid:S1066"/Merge this if statement with the enclosing one.(댯Ú
|
||||
osquid:S1450"URemove the "mMoveX" field and declare it as a local variable in the relevant methods.(ŸöÁæúÿÿÿÿ
|
||||
esquid:CommentedOutCodeLine"<This block of commented-out lines of code should be removed.(±¹ËÌüÿÿÿÿ
|
||||
:squid:S2068" Remove this hard-coded password.(Š…÷<E280A6>úÿÿÿÿ
|
||||
[squid:CallToDeprecatedMethod"0Remove this use of "getWidth"; it is deprecated.(ð“ñÀþÿÿÿÿ
|
||||
:squid:S2068" Remove this hard-coded password.(ò¤‚›üÿÿÿÿ
|
|
@ -0,0 +1,2 @@
|
|||
|
||||
Tsquid:S1118":Add a private constructor to hide the implicit public one.(¡¯¦Œýÿÿÿÿ
|
|
@ -1,10 +1,60 @@
|
|||
|
||||
<
|
||||
build.gradle,f\0\f07866736216be0ee2aba49e392191aeae700a35
|
||||
€
|
||||
Papp\src\main\java\com\example\administrator\myapplication\db\DatabaseHelper.java,a\a\aa2f43374bddf98bfc4aea5a398fe877e5337db3
|
||||
~
|
||||
Napp\src\main\java\com\example\administrator\myapplication\ui\SignActivity.java,b\d\bd98ce0af59853dea38d4090583c47ba06bce28d
|
||||
Napp\src\main\java\com\example\administrator\myapplication\db\NoteDatabase.java,b\3\b395e8da890bfdf6daeefc467704d4b30eac2ea4
|
||||
‡
|
||||
Wapp\src\main\java\com\example\administrator\myapplication\adapter\BgPicGridAdapter.java,0\3\037b293928bff3f763d72038512124d16aebd627
|
||||
|
|
||||
Lapp\src\main\java\com\example\administrator\myapplication\entity\Entity.java,8\5\859e5ebe76cd38bc36ca8379efb50fa9654aada0
|
||||
|
|
||||
Lapp\src\main\java\com\example\administrator\myapplication\ui\EditImages.java,9\e\9ea0176c0b7c2596ee3a138d5aafcdb83764d0f4
|
||||
{
|
||||
Kapp\src\main\java\com\example\administrator\myapplication\ui\EditNotes.java,9\2\92cf1c7de3acc98eba6f939165f0bb2683705fcf
|
||||
|
||||
Oapp\src\main\java\com\example\administrator\myapplication\ui\ImagesDisplay.java,a\6\a6e0067cc06ea7f07e5e3c87e060a04c54f022e7
|
||||
‚
|
||||
Rapp\src\main\java\com\example\administrator\myapplication\entity\NotebookData.java,4\8\487d5149cb35c7a7667af03d218f63298d21b1f0
|
||||
<EFBFBD>
|
||||
Qapp\src\main\java\com\example\administrator\myapplication\entity\BgPicEntity.java,1\7\17acf378acdba9698dfb6d704084bcd18706d372
|
||||
ˆ
|
||||
Xapp\src\main\java\com\example\administrator\myapplication\entity\OnResponseListener.java,f\8\f8d5ad2e69267983911206328e3836505144d8db
|
||||
~
|
||||
Napp\src\main\java\com\example\administrator\myapplication\entity\Response.java,5\b\5b0e24b16ee3b9a006718e6880c3eb1eeff4d105
|
||||
<EFBFBD>
|
||||
Qapp\src\main\java\com\example\administrator\myapplication\entity\UpdataEvent.java,d\c\dceb451ef5f82cbe33558978d2a79abc27fb6fe0
|
||||
z
|
||||
Japp\src\main\java\com\example\administrator\myapplication\entity\User.java,c\5\c5ce6afdb0606af7b3aad034a3799dc44d4d4c5c
|
||||
<EFBFBD>
|
||||
]app\src\main\java\com\example\administrator\myapplication\ui\AppCompatPreferenceActivity.java,7\f\7fc1f946c8e0fc0221c21f1cb84787e5b2965d9a
|
||||
<EFBFBD>
|
||||
Qapp\src\main\java\com\example\administrator\myapplication\utils\AccountUtils.java,6\2\623bf4dae8f8d83b8faa2b618d5550b1a37e5683
|
||||
‚
|
||||
Rapp\src\main\java\com\example\administrator\myapplication\utils\BmobConstants.java,3\4\342c9edfd27db16bba3e3455e68c749d04c55cbd
|
||||
~
|
||||
Napp\src\main\java\com\example\administrator\myapplication\utils\Constants.java,3\6\36c3f609a5d93035486e7c295cd723418b0f089e
|
||||
€
|
||||
Papp\src\main\java\com\example\administrator\myapplication\utils\CommonUtils.java,3\7\37269061f6dc97247d4050e30277a569050f1b3d
|
||||
‚
|
||||
Rapp\src\main\java\com\example\administrator\myapplication\utils\HTQAnimations.java,6\5\65764ff37783669e71501692a607a3cea49c4bdc
|
||||
|
|
||||
Lapp\src\main\java\com\example\administrator\myapplication\utils\MD5Util.java,0\0\00ede12c640622790c9816ae6766f38a949ed3bd
|
||||
€
|
||||
Papp\src\main\java\com\example\administrator\myapplication\utils\StringUtils.java,a\0\a02bf92a1675ea96231995a8137b01dd95f322ae
|
||||
|
|
||||
Lapp\src\main\java\com\example\administrator\myapplication\utils\SPUtils.java,5\7\57c831202760b4842bfc3ee5ac2511ebb0122f9e
|
||||
€
|
||||
Papp\src\main\java\com\example\administrator\myapplication\utils\SystemUtils.java,6\7\67ee5a70c0947c6377cf1e29856f6a79659f84e7
|
||||
|
||||
Oapp\src\main\java\com\example\administrator\myapplication\utils\DialogHelp.java,9\5\954e8115c9434902b13d9840c149e0ff3fe59df2
|
||||
ƒ
|
||||
Sapp\src\main\java\com\example\administrator\myapplication\utils\ResourceParser.java,0\e\0eb5e393710f19bb3d38d5884bfea90461e2f527
|
||||
~
|
||||
Napp\src\main\java\com\example\administrator\myapplication\utils\PhotoUtil.java,9\f\9fbe46e342a1ff27349384d89b44b286ccf531a3
|
||||
<EFBFBD>
|
||||
Qapp\src\main\java\com\example\administrator\myapplication\utils\TimeZoneUtil.java,f\d\fd0acbc65b4f2ecc0ae0379155f8cab404805cfb
|
||||
‘
|
||||
aapp\src\main\java\com\example\administrator\myapplication\widget\patternlock\LockPatternView.java,d\5\d55eada2cdd2dd102362d485231d9b377995b0b0
|
||||
‡
|
||||
|
@ -13,13 +63,15 @@ Wapp\src\main\java\com\example\administrator\myapplication\widget\patternlock\Po
|
|||
Uapp\src\main\java\com\example\administrator\myapplication\widget\HTQDragGridView.java,8\e\8e104bc4be91ecea7d96ed093e7eefd2be1a136c
|
||||
…
|
||||
Uapp\src\main\java\com\example\administrator\myapplication\widget\CircleImageView.java,d\2\d2c92a556e47fd0e9a3fa038dbf835129e2f5090
|
||||
…
|
||||
Uapp\src\main\java\com\example\administrator\myapplication\utils\ImageLoadOptions.java,6\5\655e5da5fa53bd4a676fde93415f3962c6841a5c
|
||||
†
|
||||
Vapp\src\main\java\com\example\administrator\myapplication\adapter\NotebookAdapter.java,b\f\bf99366384db0ccf7ec0367c3aa4412c93f2a9bb
|
||||
<EFBFBD>
|
||||
_app\src\main\java\com\example\administrator\myapplication\widget\patternlock\RotateDegrees.java,5\4\5407486fb05ebaf77ee187807ac7fbb8cb42de8a
|
||||
ˆ
|
||||
Xapp\src\main\java\com\example\administrator\myapplication\widget\NoteItemCircleView.java,e\7\e71af57077389976b85ce04fe9c4f9e8bc78f9d2
|
||||
‚
|
||||
Rapp\src\main\java\com\example\administrator\myapplication\widget\ToggleButton.java,a\2\a2cac54ed6169d41dc3d4fe37b5f3594fabd1e9d
|
||||
<EFBFBD>
|
||||
Qapp\src\main\java\com\example\administrator\myapplication\ui\WelcomeActivity.java,f\4\f4db46de912ee15bd8dff2e67791e614cfdc8ae8
|
||||
|
||||
Oapp\src\main\java\com\example\administrator\myapplication\ui\LoginActivity.java,d\9\d9f0b00bd9259256a0cc6a48eb4c59665266c4ea
|
||||
@
|
||||
app\build.gradle,8\3\83d37b2761f0342c28dad5cd3a4bdc7a7b7d55d6
|
|
@ -1,8 +1,10 @@
|
|||
apply plugin: 'com.android.application'
|
||||
apply plugin: 'com.neenbedankt.android-apt'
|
||||
|
||||
android {
|
||||
compileSdkVersion 26
|
||||
buildToolsVersion "26.0.1"
|
||||
useLibrary 'org.apache.http.legacy'
|
||||
defaultConfig {
|
||||
applicationId "com.example.administrator.myapplication"
|
||||
minSdkVersion 15
|
||||
|
@ -18,9 +20,20 @@ android {
|
|||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
aaptOptions {
|
||||
cruncherEnabled = false
|
||||
useNewCruncher = false
|
||||
sourceSets {
|
||||
main() {
|
||||
jniLibs.srcDirs = ['libs']
|
||||
}
|
||||
|
||||
}
|
||||
lintOptions {
|
||||
ignoreWarnings true
|
||||
//lint 遇到 error 时继续 构建
|
||||
abortOnError false
|
||||
//build release 版本 时 开启lint 检测
|
||||
checkReleaseBuilds false
|
||||
// 防止在发布的时候出现因MissingTranslation导致Build Failed!
|
||||
disable 'MissingTranslation'
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -31,8 +44,16 @@ dependencies {
|
|||
})
|
||||
compile 'com.android.support:appcompat-v7:26.+'
|
||||
compile 'com.android.support.constraint:constraint-layout:1.0.2'
|
||||
compile 'com.jakewharton:butterknife:8.2.1'
|
||||
apt 'com.jakewharton:butterknife-compiler:8.2.1'
|
||||
compile 'com.android.support:design:26.+'
|
||||
compile 'com.android.support:support-v4:26.+'
|
||||
compile 'com.android.support:support-vector-drawable:26.+'
|
||||
compile 'com.google.android.gms:play-services-appindexing:8.1.0'
|
||||
compile 'cn.bmob.android:http-legacy:1.0'
|
||||
compile 'cn.bmob.android:bmob-sdk:3.4.7-aar'
|
||||
compile 'org.greenrobot:eventbus:3.0.0'
|
||||
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.2'
|
||||
compile 'com.github.clans:fab:1.6.1'
|
||||
testCompile 'junit:junit:4.12'
|
||||
}
|
||||
|
|
|
@ -0,0 +1,91 @@
|
|||
package com.example.administrator.myapplication.adapter;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import com.example.administrator.myapplication.R;
|
||||
import com.example.administrator.myapplication.entity.BgPicEntity;
|
||||
import com.example.administrator.myapplication.utils.SystemUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class BgPicGridAdapter extends BaseAdapter {
|
||||
|
||||
|
||||
private List<BgPicEntity> bgList;
|
||||
private Resources resources;
|
||||
private Activity mActivity;
|
||||
private String mDefaultBgPath;
|
||||
private SystemUtils systemUtil;
|
||||
public BgPicGridAdapter(Activity mActivity,List<BgPicEntity> 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;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -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<NotebookData> 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<NotebookData> 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<NotebookData> datas) {
|
||||
if (datas == null) {
|
||||
datas = new ArrayList<NotebookData>(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<NotebookData> 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();
|
||||
}
|
||||
}
|
|
@ -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);// 全局初始化此配置
|
||||
}
|
||||
|
||||
}
|
|
@ -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) {}
|
||||
|
||||
}
|
|
@ -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<NotebookData> query() {
|
||||
return query(" ");
|
||||
}
|
||||
|
||||
/**
|
||||
* 查
|
||||
*
|
||||
* @param where
|
||||
* @return
|
||||
*/
|
||||
public List<NotebookData> query(String where) {
|
||||
SQLiteDatabase sqlite = dbHelper.getReadableDatabase();
|
||||
ArrayList<NotebookData> data = null;
|
||||
data = new ArrayList<NotebookData>();
|
||||
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<NotebookData> 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<NotebookData> 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);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
package com.example.administrator.myapplication.entity;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
|
||||
public class BgPicEntity {
|
||||
public Bitmap bitmap;
|
||||
public String path;
|
||||
}
|
|
@ -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;
|
||||
// }
|
||||
//}
|
|
@ -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<NotebookData> {
|
||||
|
||||
|
||||
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<data.size();i++) {
|
||||
save(context, new SaveListener() {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
if (listener != null) {
|
||||
com.example.administrator.myapplication.entity.Response response = new Response();
|
||||
response.setIsSucces(true);
|
||||
listener.onResponse(response);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(int code, String msg) {
|
||||
if (listener != null) {
|
||||
com.example.administrator.myapplication.entity.Response response = new Response();
|
||||
response.setIsSucces(false);
|
||||
response.setMsg(msg);
|
||||
listener.onResponse(response);
|
||||
}
|
||||
}
|
||||
});
|
||||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param context
|
||||
* @param listener
|
||||
*/
|
||||
public void updateNoteInServe(Context context,String objectId,final com.example.administrator.myapplication.entity.OnResponseListener listener)
|
||||
{
|
||||
//objectId,
|
||||
update(context, new UpdateListener() {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
if (listener != null) {
|
||||
com.example.administrator.myapplication.entity.Response response = new Response();
|
||||
response.setIsSucces(true);
|
||||
listener.onResponse(response);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(int code, String msg) {
|
||||
if (listener != null) {
|
||||
com.example.administrator.myapplication.entity.Response response = new Response();
|
||||
response.setIsSucces(false);
|
||||
response.setMsg(msg);
|
||||
listener.onResponse(response);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
public void deleteNoteInServe(Context context,/*int noteId,*/final com.example.administrator.myapplication.entity.OnResponseListener listener)
|
||||
{
|
||||
// String objectId=new NoteDatabase().query();
|
||||
|
||||
delete(context, new DeleteListener() {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
if (listener != null) {
|
||||
com.example.administrator.myapplication.entity.Response response = new Response();
|
||||
response.setIsSucces(true);
|
||||
listener.onResponse(response);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(int code, String msg) {
|
||||
if (listener != null) {
|
||||
com.example.administrator.myapplication.entity.Response response = new Response();
|
||||
response.setIsSucces(false);
|
||||
response.setMsg(msg);
|
||||
listener.onResponse(response);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public int getIid() {
|
||||
return iid;
|
||||
}
|
||||
|
||||
public void setIid(int iid) {
|
||||
this.iid = iid;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public String getDate() {
|
||||
return date;
|
||||
}
|
||||
|
||||
public void setDate(String date) {
|
||||
this.date = date;
|
||||
}
|
||||
|
||||
public String getUnixTime() {
|
||||
return unixTime;
|
||||
}
|
||||
|
||||
public void setUnixTime(String time) {
|
||||
this.unixTime = time;
|
||||
// setServerUpdateTime(time);
|
||||
}
|
||||
|
||||
public String getColorText() {
|
||||
return colorText;
|
||||
}
|
||||
|
||||
public void setColorText(String color) {
|
||||
this.colorText = color;
|
||||
}
|
||||
|
||||
public int getColor() {
|
||||
// 客户端始终以当前手机上的颜色为准
|
||||
if ("blue".equals(colorText)) {
|
||||
this.color = 3;
|
||||
} else if ("red".equals(colorText)) {
|
||||
this.color = 2;
|
||||
} else if ("yellow".equals(colorText)) {
|
||||
this.color = 1;
|
||||
} else if ("purple".equals(colorText)) {
|
||||
this.color = 4;
|
||||
} else if ("green".equals(colorText)) {
|
||||
this.color = 0;
|
||||
}
|
||||
return color;
|
||||
}
|
||||
|
||||
// public String getServerUpdateTime() {
|
||||
// return serverUpdateTime;
|
||||
// }
|
||||
//
|
||||
// public void setServerUpdateTime(String serverUpdateTime) {
|
||||
// this.serverUpdateTime = serverUpdateTime;
|
||||
// }
|
||||
|
||||
public void setColor(int color) {
|
||||
switch (color) {
|
||||
case 0:
|
||||
colorText = "green";
|
||||
break;
|
||||
case 1:
|
||||
colorText = "yellow";
|
||||
break;
|
||||
case 2:
|
||||
colorText = "red";
|
||||
break;
|
||||
case 3:
|
||||
colorText = "blue";
|
||||
break;
|
||||
case 4:
|
||||
colorText = "purple";
|
||||
break;
|
||||
default:
|
||||
this.color = color;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(NotebookData another) {
|
||||
return this.iid - another.getIid();
|
||||
}
|
||||
|
||||
public String getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(String userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
package com.example.administrator.myapplication.entity;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* 服务器回复的回调接口
|
||||
*
|
||||
*/
|
||||
public interface OnResponseListener {
|
||||
|
||||
/**
|
||||
* 成功
|
||||
* @param response 回复的结果
|
||||
*/
|
||||
void onResponse(com.example.administrator.myapplication.entity.Response response);
|
||||
|
||||
}
|
|
@ -0,0 +1,59 @@
|
|||
package com.example.administrator.myapplication.entity;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 服务器响应类
|
||||
*
|
||||
*/
|
||||
public class Response {
|
||||
|
||||
private String msg;
|
||||
private boolean isSucces;
|
||||
|
||||
private List<NotebookData> noteItemList;
|
||||
// private List<DiaryItem> 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<NotebookData> getNoteItemList() {
|
||||
return noteItemList;
|
||||
}
|
||||
|
||||
public void setNoteItemList(List<NotebookData> noteItemList) {
|
||||
this.noteItemList = noteItemList;
|
||||
}
|
||||
|
||||
// public List<DiaryItem> getDiaryItemList() {
|
||||
// return diaryItemList;
|
||||
// }
|
||||
//
|
||||
// public void setDiaryItemList(List<DiaryItem> diaryItemList) {
|
||||
// this.diaryItemList = diaryItemList;
|
||||
// }
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
|
@ -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<NotebookData> list = new ArrayList<NotebookData>();
|
||||
BmobQuery<NotebookData> query = new BmobQuery<NotebookData>();
|
||||
|
||||
query.addWhereEqualTo(NotebookData.NOTE_USER_ID, user_id);
|
||||
//返回50条数据,如果不加上这条语句,默认返回10条数据
|
||||
query.setLimit(50);
|
||||
//按更新日期降序排列
|
||||
query.order("-updatedAt");
|
||||
//执行查询方法
|
||||
query.findObjects(context, new FindListener<NotebookData>() {
|
||||
@Override
|
||||
public void onSuccess(List<NotebookData> 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;
|
||||
// }
|
||||
}
|
|
@ -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();
|
||||
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -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 <EFBFBD><EFBFBD><EFBFBD><EFBFBD>2:48:33
|
||||
*/
|
||||
@SuppressLint("SdCardPath")
|
||||
public class BmobConstants {
|
||||
|
||||
/**
|
||||
* <EFBFBD><EFBFBD>ŷ<EFBFBD><EFBFBD><EFBFBD>ͼƬ<EFBFBD><EFBFBD>Ŀ¼
|
||||
*/
|
||||
public static String BMOB_PICTURE_PATH = Environment.getExternalStorageDirectory() + "/bmobimdemo/image/";
|
||||
|
||||
/**
|
||||
* <EFBFBD>ҵ<EFBFBD>ͷ<EFBFBD><EFBFBD>Ŀ¼
|
||||
*/
|
||||
public static String MyAvatarDir = "/sdcard/beautynote/avatar/";
|
||||
/**
|
||||
* <EFBFBD><EFBFBD><EFBFBD>ջص<EFBFBD>
|
||||
*/
|
||||
public static final int REQUESTCODE_UPLOADAVATAR_CAMERA = 1;//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD><EFBFBD>
|
||||
public static final int REQUESTCODE_UPLOADAVATAR_LOCATION = 2;//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD><EFBFBD>
|
||||
public static final int REQUESTCODE_UPLOADAVATAR_CROP = 3;//ϵͳ<EFBFBD>ü<EFBFBD>ͷ<EFBFBD><EFBFBD>
|
||||
|
||||
public static final int REQUESTCODE_TAKE_CAMERA = 0x000001;//<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
public static final int REQUESTCODE_TAKE_LOCAL = 0x000002;//<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼƬ
|
||||
public static final int REQUESTCODE_TAKE_LOCATION = 0x000003;//λ<EFBFBD><EFBFBD>
|
||||
public static final String EXTRA_STRING = "extra_string";
|
||||
|
||||
|
||||
public static final String ACTION_REGISTER_SUCCESS_FINISH ="register.success.finish";//ע<EFBFBD><EFBFBD>ɹ<EFBFBD>֮<EFBFBD><EFBFBD><EFBFBD>½ҳ<EFBFBD><EFBFBD><EFBFBD>˳<EFBFBD>
|
||||
}
|
|
@ -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 {
|
||||
|
||||
/** <20><><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
public static boolean isNetworkAvailable(Context context) {
|
||||
NetworkInfo info = getNetworkInfo(context);
|
||||
if (info != null) {
|
||||
return info.isAvailable();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/** <20><><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD>WIFI */
|
||||
public static boolean isWifi(Context context) {
|
||||
NetworkInfo info = getNetworkInfo(context);
|
||||
if (info != null) {
|
||||
if (info.getType() == ConnectivityManager.TYPE_WIFI)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/** <20><><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD>ƶ<EFBFBD><C6B6><EFBFBD><EFBFBD><EFBFBD> */
|
||||
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();
|
||||
}
|
||||
|
||||
/** <20><><EFBFBD>SD<53><44><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD> */
|
||||
public static boolean checkSdCard() {
|
||||
if (android.os.Environment.getExternalStorageState().equals(
|
||||
android.os.Environment.MEDIA_MOUNTED))
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
|
@ -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;
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -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()
|
||||
// // <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼƬ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڼ<EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD>ͼƬ
|
||||
// .showImageOnLoading(R.drawable.small_image_holder_listpage)
|
||||
// // <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼƬUriΪ<EFBFBD>ջ<EFBFBD><EFBFBD>Ǵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD>ͼƬ
|
||||
// .showImageForEmptyUri(R.drawable.small_image_holder_listpage)
|
||||
// // <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼƬ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>/<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD>ͼƬ
|
||||
// .showImageOnFail(R.drawable.small_image_holder_listpage)
|
||||
.cacheInMemory(true)
|
||||
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ص<EFBFBD>ͼƬ<EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD><EFBFBD><EFBFBD>
|
||||
.cacheOnDisc(true)
|
||||
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ص<EFBFBD>ͼƬ<EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD>SD<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
.considerExifParams(true)
|
||||
.imageScaleType(ImageScaleType.EXACTLY)// <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼƬ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>εı<EFBFBD><EFBFBD>뷽ʽ<EFBFBD><EFBFBD>ʾ
|
||||
.bitmapConfig(Bitmap.Config.RGB_565)// <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼƬ<EFBFBD>Ľ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
// .decodingOptions(android.graphics.BitmapFactory.Options
|
||||
// decodingOptions)//<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼƬ<EFBFBD>Ľ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
.considerExifParams(true)
|
||||
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼƬ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD><EFBFBD><EFBFBD>ӳ<EFBFBD>
|
||||
// .delayBeforeLoading(int delayInMillis)//int
|
||||
// delayInMillisΪ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD><EFBFBD>ӳ<EFBFBD>ʱ<EFBFBD><EFBFBD>
|
||||
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼƬ<EFBFBD><EFBFBD><EFBFBD>뻺<EFBFBD><EFBFBD>ǰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>bitmap<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
// <EFBFBD><EFBFBD>preProcessor(BitmapProcessor preProcessor)
|
||||
.resetViewBeforeLoading(true)// <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼƬ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ã<EFBFBD><EFBFBD><EFBFBD>λ
|
||||
// .displayer(new RoundedBitmapDisplayer(20))//<EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ΪԲ<EFBFBD>ǣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
.displayer(new FadeInBitmapDisplayer(100))// <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
.build();
|
||||
|
||||
return options;
|
||||
}
|
||||
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -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 {
|
||||
|
||||
/**
|
||||
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> recycle
|
||||
*
|
||||
* @throws
|
||||
*/
|
||||
public static void recycle(Bitmap bitmap) {
|
||||
// <EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD><EFBFBD>Ƿ<EFBFBD><EFBFBD>Ѿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
if (bitmap != null && !bitmap.isRecycled()) {
|
||||
// <EFBFBD><EFBFBD><EFBFBD>ղ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊnull
|
||||
bitmap.recycle();
|
||||
bitmap = null;
|
||||
}
|
||||
System.gc();
|
||||
}
|
||||
|
||||
/**
|
||||
* <EFBFBD><EFBFBD>ȡָ<EFBFBD><EFBFBD>·<EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD>ͼƬ<EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>С<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ 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;
|
||||
// <EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD>ͼƬ<EFBFBD>Ŀ<EFBFBD>ߣ<EFBFBD>ע<EFBFBD><EFBFBD>˴<EFBFBD><EFBFBD><EFBFBD>bitmapΪnull
|
||||
bitmap = BitmapFactory.decodeFile(imagePath, options);
|
||||
options.inJustDecodeBounds = false; // <EFBFBD><EFBFBD>Ϊ false
|
||||
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ű<EFBFBD>
|
||||
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;
|
||||
// <EFBFBD><EFBFBD><EFBFBD>¶<EFBFBD><EFBFBD><EFBFBD>ͼƬ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD>ź<EFBFBD><EFBFBD>bitmap<EFBFBD><EFBFBD>ע<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD>options.inJustDecodeBounds <EFBFBD><EFBFBD>Ϊ false
|
||||
bitmap = BitmapFactory.decodeFile(imagePath, options);
|
||||
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ThumbnailUtils<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫָ<EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĸ<EFBFBD>Bitmap<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
bitmap = ThumbnailUtils.extractThumbnail(bitmap, width, height,
|
||||
ThumbnailUtils.OPTIONS_RECYCLE_INPUT);
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
/**
|
||||
* saveBitmap
|
||||
*
|
||||
* @param @param filename---<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ-<EFBFBD><EFBFBD>Ŀ¼<EFBFBD>Լ<EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>
|
||||
* @param @param bitmap
|
||||
* @param @param isDelete --<EFBFBD>Ƿ<EFBFBD>ֻ<EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD>
|
||||
* @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);
|
||||
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڼ<EFBFBD>ɾ<EFBFBD><EFBFBD>-Ĭ<EFBFBD><EFBFBD>ֻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD>
|
||||
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) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* <EFBFBD><EFBFBD>ȡͼƬ<EFBFBD><EFBFBD><EFBFBD>ԣ<EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD>ĽǶ<EFBFBD>
|
||||
* @param path ͼƬ<EFBFBD><EFBFBD><EFBFBD>·<EFBFBD><EFBFBD>
|
||||
* @return degree<EFBFBD><EFBFBD>ת<EFBFBD>ĽǶ<EFBFBD>
|
||||
*/
|
||||
|
||||
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;
|
||||
|
||||
}
|
||||
|
||||
/** <EFBFBD><EFBFBD>תͼƬһ<EFBFBD><EFBFBD><EFBFBD>Ƕ<EFBFBD>
|
||||
* rotaingImageView
|
||||
* @return Bitmap
|
||||
* @throws
|
||||
*/
|
||||
public static Bitmap rotaingImageView(int angle, Bitmap bitmap) {
|
||||
// <EFBFBD><EFBFBD>תͼƬ <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
Matrix matrix = new Matrix();
|
||||
matrix.postRotate(angle);
|
||||
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD>ͼƬ
|
||||
Bitmap resizedBitmap = Bitmap.createBitmap(bitmap, 0, 0,
|
||||
bitmap.getWidth(), bitmap.getHeight(), matrix, true);
|
||||
return resizedBitmap;
|
||||
}
|
||||
|
||||
/**
|
||||
* <EFBFBD><EFBFBD>ͼƬ<EFBFBD><EFBFBD>ΪԲ<EFBFBD><EFBFBD>
|
||||
*
|
||||
* @param bitmap
|
||||
* ԭBitmapͼƬ
|
||||
* @param pixels
|
||||
* ͼƬԲ<EFBFBD>ǵĻ<EFBFBD><EFBFBD><EFBFBD>(<EFBFBD><EFBFBD>λ:<EFBFBD><EFBFBD><EFBFBD><EFBFBD>(px))
|
||||
* @return <EFBFBD><EFBFBD><EFBFBD><EFBFBD>Բ<EFBFBD>ǵ<EFBFBD>ͼƬ(Bitmap <EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* <EFBFBD><EFBFBD>ͼƬת<EFBFBD><EFBFBD>ΪԲ<EFBFBD><EFBFBD>ͷ<EFBFBD><EFBFBD>
|
||||
*
|
||||
* @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);// <EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
canvas.drawARGB(0, 0, 0, 0); // <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Canvas
|
||||
|
||||
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Բ,drawRounRect<EFBFBD><EFBFBD>drawCircle
|
||||
canvas.drawRoundRect(rectF, roundPx, roundPx, paint);// <EFBFBD><EFBFBD>Բ<EFBFBD>Ǿ<EFBFBD><EFBFBD>Σ<EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊͼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD>ڶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>͵<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֱ<EFBFBD><EFBFBD><EFBFBD>ˮƽԲ<EFBFBD>ǰ뾶<EFBFBD>ʹ<EFBFBD>ֱԲ<EFBFBD>ǰ뾶<EFBFBD><EFBFBD>
|
||||
// canvas.drawCircle(roundPx, roundPx, roundPx, paint);
|
||||
|
||||
paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN));// <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼƬ<EFBFBD>ཻʱ<EFBFBD><EFBFBD>ģʽ,<EFBFBD>ο<EFBFBD>http://trylovecatch.iteye.com/blog/1189452
|
||||
canvas.drawBitmap(bitmap, src, dst, paint); // <EFBFBD><EFBFBD>Mode.SRC_INģʽ<EFBFBD>ϲ<EFBFBD>bitmap<EFBFBD><EFBFBD><EFBFBD>Ѿ<EFBFBD>draw<EFBFBD>˵<EFBFBD>Circle
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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<String, ?> 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();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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<SimpleDateFormat> dateFormater = new ThreadLocal<SimpleDateFormat>() {
|
||||
@Override
|
||||
protected SimpleDateFormat initialValue() {
|
||||
return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
}
|
||||
};
|
||||
|
||||
private final static ThreadLocal<SimpleDateFormat> dateFormater2 = new ThreadLocal<SimpleDateFormat>() {
|
||||
@Override
|
||||
protected SimpleDateFormat initialValue() {
|
||||
return new SimpleDateFormat("yyyy-MM-dd");
|
||||
}
|
||||
};
|
||||
|
||||
private final static ThreadLocal<SimpleDateFormat> dateFormat3 = new ThreadLocal<SimpleDateFormat>() {
|
||||
@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);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前日期是星期几<br>
|
||||
*
|
||||
* @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 + "<br>");
|
||||
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());
|
||||
}
|
||||
|
||||
}
|
|
@ -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,"好东西要与小伙伴们一起分享"));
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue