Compare commits
1087 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f5b1fff4ed | |||
| 0c00164113 | |||
| c1a910e2cb | |||
| 4578984a75 | |||
| c8714c0c16 | |||
| 28b1a3b7de | |||
| f35cf6fa99 | |||
| 265b9b7ec1 | |||
| 561d5026c9 | |||
| 932b39ea09 | |||
| bfb7e6aa71 | |||
| 13e2694dc0 | |||
| 325dd07b4d | |||
| ca197ae2ab | |||
| 8542f3aec6 | |||
| 7b23d7a1a3 | |||
| 55901c219a | |||
| 973f6d2f20 | |||
| 42b05160d8 | |||
| 729c48b8ad | |||
| 4a2d201ac2 | |||
| 22051ab626 | |||
| 8188d8495b | |||
| 6d3e613214 | |||
| b8c2b73874 | |||
| de14cc95ef | |||
| a56814a3aa | |||
| 689f1e3b68 | |||
| 1d280ed079 | |||
| 4a4118958d | |||
| c0010e7bdb | |||
| b03ba1df9d | |||
| 5b28be29ac | |||
| 3ca7b7c9bd | |||
| 40e5a42212 | |||
| 481e2d7925 | |||
| 6c46d4b090 | |||
| 9e5b8b5f29 | |||
| 27f0354db5 | |||
| eb68fe86e6 | |||
| cf4514614a | |||
| f26bc062e1 | |||
| 9f848594a1 | |||
| 4cb92f5d8c | |||
| 692fec5518 | |||
| 1f978c3039 | |||
| 72ca4958c1 | |||
| 7ef693c6d8 | |||
| 32319affb7 | |||
| 04458270d3 | |||
| a4e2f4b90f | |||
| bd390decf4 | |||
| 548430e4a8 | |||
| b29f80942f | |||
| 5be275f8b0 | |||
| 1f84195cc9 | |||
| 8204faef7d | |||
| 0a889f4549 | |||
| c9edf04a45 | |||
| 5fc5d1f68f | |||
| b7ae9d82ff | |||
| 498c626227 | |||
| 24be8be4b2 | |||
| 7700d3af79 | |||
| 95dd96f7f9 | |||
| 2f89ba9707 | |||
| 1460e8cad3 | |||
| 9e68a37205 | |||
| d9591a826a | |||
| 843ae23911 | |||
| bf1559f3bd | |||
| 9baf63ded5 | |||
| 5a5a4eccf0 | |||
| d82270d8e9 | |||
| 39fd038fde | |||
| 0e6192487e | |||
| dee19c5961 | |||
| e18a66dd68 | |||
| 8c7efc7bb4 | |||
| 5c88db4bc4 | |||
| ccce9759d6 | |||
| 857541665a | |||
| 1737f4ffdc | |||
| 85c839ffc8 | |||
| 37168298ff | |||
| 65c004e8cc | |||
| a87f642473 | |||
| 69a8f94607 | |||
| 52438c682b | |||
| c9ea7e3b79 | |||
| d4289efbc6 | |||
| d9b65705ad | |||
| 5b35524f8d | |||
| 540274d8f5 | |||
| e4794c60f8 | |||
| 95676ee4bd | |||
| 42b8a9d5f9 | |||
| a027cb16af | |||
| 5b75bd4c61 | |||
| 3d90f9ee34 | |||
| 52543c828e | |||
| ed9c780e2d | |||
| 904b74be5b | |||
| 629fa23237 | |||
| 9f6d441ad1 | |||
| b0a99ced20 | |||
| 101874fd29 | |||
| 3bae1a1af7 | |||
| b6f1138922 | |||
| c90cc405b5 | |||
| c73690e546 | |||
| 5b4ddcae1f | |||
| 1244d838ec | |||
| 6c5da2d787 | |||
| 9f2225de3d | |||
| 69c809a2c0 | |||
| ba27bd8a4c | |||
| 1da1c6f86d | |||
| 012eb42c8a | |||
| 186a5f8d08 | |||
| 522dac5c6b | |||
| 32c2ab67fb | |||
| 54e0cdee75 | |||
| d5a23f5239 | |||
| bbd035d7b1 | |||
| 140c048b71 | |||
| d0306f311a | |||
| 0c918bd826 | |||
| b2064c3758 | |||
| 11e276a977 | |||
| 14ee8921cf | |||
| 2dcc4e974d | |||
| 5b639d78cf | |||
| 35c4fa1209 | |||
| 8a13d6a60b | |||
| b94c742100 | |||
| 967f281210 | |||
| 1dba6f438f | |||
| fb464aefaa | |||
| 35b6db66b3 | |||
| 396862fc0a | |||
| b6ab058cb4 | |||
| fb4d1df210 | |||
| ffaa32be29 | |||
| 18af7c51c8 | |||
| e45b46e8a5 | |||
| 4419463c01 | |||
| 51115e070b | |||
| 783889f050 | |||
| 547229d017 | |||
| ad05198be1 | |||
| f93f31784e | |||
| 05d4109f0b | |||
| 9ea377b72b | |||
| a4eec37467 | |||
| 14d6c9d6f4 | |||
| 4707112837 | |||
| d4f78631d9 | |||
| dc5c2971c8 | |||
| 07f1180ccd | |||
| e483540d3d | |||
| 362518959b | |||
| 7b1ac0f70c | |||
| fc18da47da | |||
| 6d14af968f | |||
| 2cff450fa4 | |||
| 069b82518d | |||
| 91663c4733 | |||
| d7cf91ec5c | |||
| 4854c15f8c | |||
| 248e63ba04 | |||
| fc19ce037e | |||
| 020b67764b | |||
| 32d25e5490 | |||
| d8cd68025e | |||
| 38a8b190fe | |||
| 3788e8ce20 | |||
| b02a6377ab | |||
| ac550094df | |||
| 2ea75c1664 | |||
| cf07f12cad | |||
| fb00833d3f | |||
| 91046c350c | |||
| 3b2c294323 | |||
| 4507c7e581 | |||
| 6d02fb22a2 | |||
| e926f2ca77 | |||
| 77267add3b | |||
| 460a4eed57 | |||
| 84ea2cd1af | |||
| 68e1b9b700 | |||
| 361d260964 | |||
| 3a66d778ed | |||
| dbf5fcda58 | |||
| a5309f2c9e | |||
| 13b81fa3e8 | |||
| 8c60267997 | |||
| 839efd6e32 | |||
| 54c2788e0a | |||
| 1439e598fc | |||
| 7a9e6bdb97 | |||
| 3b58aead33 | |||
| 69d379d07b | |||
| cc9d5765d5 | |||
| aa9cf8b193 | |||
| b8afc028de | |||
| e7a594003f | |||
| 5605df96dc | |||
| c499c19e5b | |||
| 106f3e932e | |||
| 04b5005218 | |||
| 32442985c5 | |||
| 1ce6946507 | |||
| a1a3481939 | |||
| 2db5b5665c | |||
| a184d018da | |||
| 233c3f728a | |||
| 1102d22919 | |||
| 6c903ea25e | |||
| 602bc61b89 | |||
| 42201b3d28 | |||
| a8889c16eb | |||
| edaab18894 | |||
| d300e74fbd | |||
| 1a804b2096 | |||
| 8c7f1ad596 | |||
| b59548d339 | |||
| 181caf6dfa | |||
| 2eafb6b31f | |||
| 742f497833 | |||
| 5119bdf545 | |||
| ce44d3b2a7 | |||
| bf7ed2cd7d | |||
| 1e287c61fb | |||
| d3e42aa876 | |||
| 58e3629c32 | |||
| 990f395b4d | |||
| b8500b4345 | |||
| b52960c47f | |||
| 50ad63735f | |||
| 89bc3d37f8 | |||
| 9cfb820036 | |||
| 365abc3c1e | |||
| 7a1555e8c0 | |||
| 6345bb55d2 | |||
| b48a274707 | |||
| 55e9bd681e | |||
| aec9ec8294 | |||
| 4229888cc9 | |||
| 103b8d32f5 | |||
| 303c98be96 | |||
| c84da4c061 | |||
| 3a4d466907 | |||
| e7143d8da4 | |||
| 99fc35e632 | |||
| 95cc8a1484 | |||
| c139d6bb8a | |||
| 3d0b5bb8b6 | |||
| 552ab8e8c4 | |||
| 596e2e9673 | |||
| 66c7dc6539 | |||
| 2585098c20 | |||
| 1f5f51da68 | |||
| 25e119202a | |||
| 7b421d0b3a | |||
| 0066135f12 | |||
| b930d3fa54 | |||
| 129a549110 | |||
| 22883dc195 | |||
| 516299ee55 | |||
| a9835ba032 | |||
| dda154a927 | |||
| cd5856778c | |||
| d7db950878 | |||
| 62f184f6ea | |||
| ab0d341bca | |||
| 1b27f481ba | |||
| b68f9be8dd | |||
| e9b0dbdfb6 | |||
| 0b21dca0a4 | |||
| 5e5d84cb65 | |||
| c2661d0586 | |||
| 032348e3fd | |||
| 840a682665 | |||
| 04807a5653 | |||
| 5ebea3f3dd | |||
| 49ca3835c0 | |||
| 566307105e | |||
| e8e75408cc | |||
| b52aa38552 | |||
| 8d55b251c3 | |||
| 386c7b19c1 | |||
| eaaa168ee1 | |||
| d9f5811d86 | |||
| 27d3470abc | |||
| 36f7427613 | |||
| 929c117ddb | |||
| 7d6d77fae5 | |||
| 2297461d91 | |||
| a26a3bebad | |||
| 4a673de424 | |||
| a837c2ccd4 | |||
| 10ee3132fd | |||
| 783fbecb00 | |||
| de1b5ba2f3 | |||
| 9a9e288c44 | |||
| 424b48f631 | |||
| 86d1cd4e12 | |||
| e700ff4744 | |||
| 34729c8c28 | |||
| 5a08611fdd | |||
| a73da1d6e4 | |||
| 28b8c20756 | |||
| 6941821b71 | |||
| 3c2244701c | |||
| 38dc873e2e | |||
| c24ffb2489 | |||
| 929864be30 | |||
| bd87163a9b | |||
| 785c740668 | |||
| 25aa16f774 | |||
| 9ec89c0dc1 | |||
| 3e5bd2b087 | |||
| 9de6cff13b | |||
| 6b98bc9fca | |||
| cdf9b0a071 | |||
| ff57e9c759 | |||
| b253113843 | |||
| b7305337bf | |||
| 455e2ad723 | |||
| 8cf87b991b | |||
| ae0b289c3e | |||
| 9404c3349a | |||
| 28afbb8d35 | |||
| 5b24443121 | |||
| 1f9aacbbbd | |||
| d194b33a5d | |||
| 55010f0ef7 | |||
| 49fab9ed04 | |||
| 1cd1b578ec | |||
| 184c56aac5 | |||
| 7c39037472 | |||
| 786a803793 | |||
| 273f0e185d | |||
| eebc2c3940 | |||
| 3a964d629e | |||
| ff041f705e | |||
| af62fc9a68 | |||
| 6ff415cc0d | |||
| 41de94e6f5 | |||
| 60d91ca04e | |||
| 19004b2073 | |||
| 70b536e6bd | |||
| 5009678587 | |||
| a7a01bbe16 | |||
| 9b2ce51c87 | |||
| c735d4e717 | |||
| 6fb4dac45d | |||
| 3d49258b84 | |||
| c23aa12d09 | |||
| 6f6ddf9fbd | |||
| 63837b5c31 | |||
| 27e245c241 | |||
| 7775494ade | |||
| a3ce139b86 | |||
| ad470f10f4 | |||
| 302d12083b | |||
| d40dd15af4 | |||
| 440eb8a07b | |||
| 361b861d5f | |||
| b518b2961a | |||
| bfae4e1501 | |||
| d3e13dd8c6 | |||
| 073c35ca08 | |||
| 99b4373561 | |||
| 52dcea477e | |||
| 6abb8d715b | |||
| 51016b0704 | |||
| d14c150070 | |||
| f59f8a3e5b | |||
| 965be0b5cd | |||
| 716900fc5d | |||
| 14280d802e | |||
| 39924857e5 | |||
| c88bda6615 | |||
| ecb80ca70d | |||
| 51b03b78ce | |||
| a7fd029ed2 | |||
| 5beb29ad09 | |||
| e7dc2ca810 | |||
| b5ce0db1ff | |||
| c8b52902e9 | |||
| dbc4e0ac26 | |||
| a0d2860970 | |||
| 77c1a05a4a | |||
| aeee2e049d | |||
| 525b184ad4 | |||
| 76e0fe9f9a | |||
| 06ddef114c | |||
| 32cdcc1304 | |||
| 4a2b414b59 | |||
| 937497aec9 | |||
| 38d2c189e8 | |||
| 57aeacf3f5 | |||
| fe4036b768 | |||
| 5dd479c492 | |||
| 5f1ff1fc6f | |||
| b08fb1f170 | |||
| e2f6180d6d | |||
| 90d19ea381 | |||
| 13738f08eb | |||
| 1b76184946 | |||
| 711431f7c9 | |||
| 4ea3f7ccf0 | |||
| 80cd86ea29 | |||
| f87bb6cd06 | |||
| ea726a22bd | |||
| 7e3afe7d70 | |||
| 8131c58fbf | |||
| 674e32a096 | |||
| f5d42a3e01 | |||
| a079a03adc | |||
| 8485f94133 | |||
| 5d60a8f03b | |||
| ec4319b74a | |||
| 41c3f9d073 | |||
| c27990b395 | |||
| 2e9a823ee1 | |||
| 590afccae7 | |||
| 7a82780826 | |||
| c75e363a06 | |||
| 573b7b61cf | |||
| 9f9e1bc9fd | |||
| 34e11b1569 | |||
| cc7b77a8ad | |||
| ed3a75ddc0 | |||
| 983c01df57 | |||
| 9d95b7aa6b | |||
| 5319cb8679 | |||
| b4b1a63c22 | |||
| 2dfd57de80 | |||
| cbc8876656 | |||
| 4e6b8bf6b3 | |||
| da92826f6a | |||
| f1a4e429f3 | |||
| 3cd248a2c5 | |||
| 7f5dd97359 | |||
| c0ee431d1f | |||
| f56de73eb6 | |||
| a0b5cd00d5 | |||
| 66b5f3d896 | |||
| a4346a6f34 | |||
| 83894f6530 | |||
| 9b776bb029 | |||
| ea72fb09e0 | |||
| b2b390cf8b | |||
| 926abe248f | |||
| 95468cf83e | |||
| 259b93eb25 | |||
| f59646643f | |||
| 7130417e60 | |||
| 458a9f2a63 | |||
| 0f85497f75 | |||
| 3c0c6afd43 | |||
| 345cdb41bc | |||
| b78fa40eff | |||
| 193831ae7e | |||
| bcb9dc3ba8 | |||
| 7903cdc44a | |||
| a66c1ea50b | |||
| 978e8f160b | |||
| a49351a146 | |||
| 07d9b416a3 | |||
| f9edb69370 | |||
| deac313ba3 | |||
| b149f9acf2 | |||
| 7c96ba090e | |||
| 11ab908848 | |||
| 3d2978b2e5 | |||
| 7ad3a7ae92 | |||
| 9042488a65 | |||
| b08e13f05a | |||
| 6271fd4998 | |||
| 4d747a3df3 | |||
| 5ce057d40e | |||
| 1e2e8f932f | |||
| 5accb9c1f1 | |||
| 5b102d65c7 | |||
| c609ddd721 | |||
| 0c3783d127 | |||
| f702ab6115 | |||
| 7dd760e0fb | |||
| c6f3b5998c | |||
| 28440d97de | |||
| 2b2b71fe01 | |||
| f5a9e7b487 | |||
| d43842a0e6 | |||
| a557962f17 | |||
| 560c682157 | |||
| a0ae36f511 | |||
| bdee17ffc4 | |||
| 5829f09f8c | |||
| bc6fa5e7db | |||
| 1607cea9ce | |||
| 426019ea7c | |||
| 1b878a50c4 | |||
| 97525189b7 | |||
| 999947751a | |||
| 2def61ab43 | |||
| 5e07ef488c | |||
| 7af47c0caf | |||
| 1a5ed3c05f | |||
| 9cc9b09861 | |||
| cef4432d97 | |||
| 18be6acc34 | |||
| 27d0dd40d0 | |||
| b05fa626f6 | |||
| f1fc84ea5f | |||
| 3942154c05 | |||
| ff182ee3c7 | |||
| 10cc275970 | |||
| 21821d584e | |||
| 6b8716eff8 | |||
| 47434e2943 | |||
| 4c3b327cff | |||
| 3454d13e48 | |||
| 0aad7c59ee | |||
| ee8e4e0338 | |||
| a430c51c97 | |||
| b59508e9e5 | |||
| 08deac1dea | |||
| a2dc3f3d5b | |||
| 679cfab088 | |||
| 9144595aaf | |||
| 8a545180a2 | |||
| 17c5793558 | |||
| 8afc346a2c | |||
| 026bb7f67b | |||
| b971e7dbf6 | |||
| ec39ef16e4 | |||
| ae07bacbb7 | |||
| 0f0d8da6cd | |||
| 2a1c99efac | |||
| caa89d3f4c | |||
| 1602816d08 | |||
| 1062cf5924 | |||
| f6e5cd3fd7 | |||
| c675196cb2 | |||
| 8b9c2668d1 | |||
| c1a927ed88 | |||
| 4d4416c1df | |||
| f4833983c0 | |||
| 89eb99d813 | |||
| 683a68d179 | |||
| 598af67338 | |||
| d9d0ffc3b9 | |||
| 4d8e04580e | |||
| cfaddf2f22 | |||
| c72b194107 | |||
| d7f33ff8b1 | |||
| 91e491b66a | |||
| 31b7e40ab0 | |||
| f2b094fff0 | |||
| 185ee7f0f4 | |||
| f446b15f7a | |||
| 52a833f18b | |||
| 37fc68977c | |||
| 96ee71a594 | |||
| 1c2dda9353 | |||
| 96a9fd0ad7 | |||
| c53c27e350 | |||
| fd4f32bb3c | |||
| cbd2d8ed6c | |||
| 3dd06bc620 | |||
| 3a829e1cfd | |||
| 183e1a85c3 | |||
| 6b696234ab | |||
| 21ac1d1f17 | |||
| 4163b81f70 | |||
| 6c3268ce72 | |||
| 4d87f86fcd | |||
| 4a37401dc2 | |||
| 8cf90193fc | |||
| 9942a51cad | |||
| 4980d96c8c | |||
| f32c8748ed | |||
| 7b886679e1 | |||
| 2620c04b09 | |||
| c22157f2f5 | |||
| 09f02bc225 | |||
| 9fc9549a28 | |||
| 0099afad09 | |||
| 3e512634c6 | |||
| 7045354808 | |||
| dbcc97a250 | |||
| 050081b7b1 | |||
| 993d1e7635 | |||
| a86a3c1f71 | |||
| b0a192ad9a | |||
| ea7b478c6b | |||
| b673383f59 | |||
| 06ae366b74 | |||
| 6b9cf7094e | |||
| 5ae22bd2bc | |||
| e951551531 | |||
| 272e5fb6cc | |||
| 7dc17d09c1 | |||
| cfacbe739d | |||
| 0a72226ba5 | |||
| 5f22a14643 | |||
| 5562e38c2f | |||
| f9027f7a61 | |||
| 6d0e437ad4 | |||
| 3abc53d3b3 | |||
| d0e4c2c3ab | |||
| 5be50c1638 | |||
| 7c525aec79 | |||
| 63d5edf892 | |||
| c9f2cf178a | |||
| fc98de3bc0 | |||
| dd8360f5e8 | |||
| bc9b815b47 | |||
| 2a93995221 | |||
| 0e93f6521c | |||
| b3a6d0ce94 | |||
| de60d05190 | |||
| 2a2ce9a490 | |||
| 639644e3c3 | |||
| 2378e6e94e | |||
| 87d9feae70 | |||
| 4a93d129bb | |||
| 39e5e2e9f9 | |||
| 8a5f777c65 | |||
| 22c693e042 | |||
| 36d04f5841 | |||
| 409123337d | |||
| b180a210cb | |||
| 32dfdc4d08 | |||
| 4d46888995 | |||
| 69db836231 | |||
| f82b9ad308 | |||
| 3ac91b1216 | |||
| 8d4b3e0851 | |||
| 67d8f46217 | |||
| f357136936 | |||
| 9d622d2be9 | |||
| 800525227d | |||
| c9dec9a31e | |||
| 2ae4fda6e8 | |||
| 609702715f | |||
| ec7e138208 | |||
| bfd64a8bce | |||
| 5571b6481f | |||
| 6d6574988c | |||
| af8d075bf2 | |||
| b7db66e90b | |||
| 13ac4658d9 | |||
| 8ad3420822 | |||
| f842ced67e | |||
| e0081e56df | |||
| 3202764f22 | |||
| f477876359 | |||
| 86ffcb92f8 | |||
| a2088e5cd9 | |||
| 6e1247f393 | |||
| c33faa4918 | |||
| d0aeb1c411 | |||
| 485924527e | |||
| ca1bfda326 | |||
| c7c786d662 | |||
| acf9fe308c | |||
| 3b32231709 | |||
| 9dae198af2 | |||
| 29bfd5bb93 | |||
| 8da51d7f5a | |||
| 91964a0ffc | |||
| 479ef20859 | |||
| f458b7dcb8 | |||
| 2d25ff7836 | |||
| 57dd5d0584 | |||
| 757efec05e | |||
| 4979045be2 | |||
| f59af60f70 | |||
| 60bc2a02f4 | |||
| 996be3906e | |||
| 14a054bdbc | |||
| 07a9fd6273 | |||
| a067f7bc43 | |||
| a5eefbb6f4 | |||
| 8d9f83c432 | |||
| ae0df36a89 | |||
| 72539671a1 | |||
| 94277a4aeb | |||
| e276d148cf | |||
| a7152034e8 | |||
| 4a5e9da34a | |||
| 1422365cc5 | |||
| 7f55ff6340 | |||
| 4722626fb7 | |||
| 39d87ad98d | |||
| 85333b9eed | |||
| c99ae6db3e | |||
| c5be98adc2 | |||
| 5321aa2e9f | |||
| 345707ef42 | |||
| 6a9d05d916 | |||
| faf2a89706 | |||
| ada51f90f1 | |||
| 53962116d5 | |||
| 3ea52745b3 | |||
| a8f2289b27 | |||
| 6dd56b5d16 | |||
| eb739cf6cb | |||
| 4853cd9047 | |||
| 4e0f14aeed | |||
| 5e37dac0f6 | |||
| 22bfa9051a | |||
| 0a1dca3aa3 | |||
| 0b20896330 | |||
| 3b934578dd | |||
| c42e1a76bf | |||
| d3f2395d9c | |||
| b5ba1e877f | |||
| eba27d8969 | |||
| fe1d4d3406 | |||
| 28418b0d49 | |||
| f35396c0e3 | |||
| 67cc464607 | |||
| b0fa0392b7 | |||
| 0fc4fddfe7 | |||
| f092966c88 | |||
| 0e1cb515ab | |||
| 35115d0581 | |||
| b1d1fc0e36 | |||
| 91f84cdd5c | |||
| ad2c155e54 | |||
| fc4b383292 | |||
| 1a868d3f12 | |||
| e4dd96e21a | |||
| 8705f8d2e2 | |||
| 65fab5e990 | |||
| 1d92b070eb | |||
| d72102784e | |||
| d7351bf93e | |||
| 6bf40ca237 | |||
| 4be93781b2 | |||
| 13fc6b8453 | |||
| 34cbbdffb9 | |||
| e45eadb6e3 | |||
| 7bf2ef1007 | |||
| 23c46cc4b2 | |||
| 259adbf145 | |||
| 95acc64e42 | |||
| 974d4fcefa | |||
| 298733b192 | |||
| 2ec4c75049 | |||
| bfac5398fc | |||
| d029b1692a | |||
| d7006f25f7 | |||
| ef56910da0 | |||
| dbf73a0385 | |||
| 41b8cae6bd | |||
| 0bea685ce1 | |||
| acd39aa969 | |||
| fd59e71714 | |||
| 47c37a1a7e | |||
| 774f9bac80 | |||
| 316eb738ec | |||
| af493d9dfb | |||
| 3d626abbc2 | |||
| a392f7f8d8 | |||
| 8f8f4c645a | |||
| 1cae62fb99 | |||
| 6db72fa7e7 | |||
| 6ee300c70e | |||
| 0f16790535 | |||
| 524742b8ea | |||
| 8c08bbea6a | |||
| d6c2bd6634 | |||
| 4aeb42dee9 | |||
| 0de7f40958 | |||
| 07fd8d986e | |||
| c821923cd0 | |||
| 6ce247d8d1 | |||
| 473d8c43df | |||
| e082b321eb | |||
| fd236857d4 | |||
| 9290934ec3 | |||
| b6d9118d05 | |||
| 544d21613a | |||
| 68a7720ea9 | |||
| 01a537c0f6 | |||
| 11bd2a5831 | |||
| d615a07f27 | |||
| ef941a7651 | |||
| 928ed40dd4 | |||
| 03f3f174c3 | |||
| 6a1a38fb5e | |||
| 9f4ca9a3bb | |||
| 670786cc2d | |||
| cc3b4ba7e9 | |||
| b8d5246230 | |||
| 37665acd3c | |||
| 5aef4d649a | |||
| 90c050590a | |||
| 3115152f32 | |||
| 923562ad8e | |||
| 1b2b9b3b91 | |||
| 8412044b88 | |||
| ceb2384eb8 | |||
| 1244efd015 | |||
| 1cc572f774 | |||
| f43c9e5d67 | |||
| 22387e8e60 | |||
| 9284af351a | |||
| 07cbd3c031 | |||
| 1d03d171e0 | |||
| 1abb783f4c | |||
| d37c809973 | |||
| 0feffda7f3 | |||
| b5bfbfaff6 | |||
| 25a4171631 | |||
| 8622aa787a | |||
| dd44a34e18 | |||
| da91e7de1d | |||
| c32798cbb0 | |||
| a03754d02b | |||
| a9351b29ab | |||
| 84a27b504d | |||
| 91e2432b48 | |||
| 505da678f0 | |||
| e0b44bf41c | |||
| f856ff5957 | |||
| 65fdb90ccb | |||
| 82372dc33b | |||
| 14fb79b90c | |||
| 050c7f9d86 | |||
| 6efd3a3239 | |||
| f1c0888309 | |||
| 1e9ade68f7 | |||
| 58a0fd8fdb | |||
| cd523bd552 | |||
| 22f68d098c | |||
| 5d3657938d | |||
| f2002ff1ce | |||
| 49600213b7 | |||
| 4d87edb1fd | |||
| b536f263f2 | |||
| 65c1300c63 | |||
| f1cc12eea3 | |||
| 0c5dd84c27 | |||
| df8753e1c4 | |||
| eb9dba3bc7 | |||
| 86247e4a61 | |||
| fc46584735 | |||
| dab87d46fa | |||
| 1968f4b7f3 | |||
| 3b1556f931 | |||
| 249332848c | |||
| 26058934cd | |||
| 11298d26e7 | |||
| 394d558707 | |||
| 058d55ea82 | |||
| 903109f8d5 | |||
| 4876abb0ed | |||
| f75490aec2 | |||
| b2e3ae684d | |||
| 5b4f5e0ef8 | |||
| 5fb6f7dbb2 | |||
| c8e32fd968 | |||
| 15f4f58164 | |||
| 291410cc1c | |||
| dd9d6cc452 | |||
| 8866d7f71e | |||
| 83bcd89c0c | |||
| 0a2160e18a | |||
| acab1d89aa | |||
| 42176d334e | |||
| 5db3563400 | |||
| 50f26101cb | |||
| 20915963f8 | |||
| e0fce2c2bf | |||
| 069340ecd1 | |||
| ca5a34e09d | |||
| 08fe5e8f83 | |||
| 12623fd383 | |||
| d52bd00ab9 | |||
| 11963ef040 | |||
| 03ce6f80a1 | |||
| 42ea33612d | |||
| 1cc0c51390 | |||
| 62740ffcb6 | |||
| 727616c764 | |||
| 1b6fd03ba3 | |||
| 53bb1dee01 | |||
| 467950ae2c | |||
| 5248ad3b6a | |||
| 3e41af7f41 | |||
| c01a9c1140 | |||
| 36def0a511 | |||
| 077f768d09 | |||
| c2eafeb9a4 | |||
| 526538a2a4 | |||
| f84b3a6be1 | |||
| 78f3b286ad | |||
| 83246b49dc | |||
| bb2ac7753f | |||
| 8120b06403 | |||
| 03575b169c | |||
| 5932c7b0a7 | |||
| aac03abf14 | |||
| e1e51131fb | |||
| cb5747a2fb | |||
| d5c8df3d1b | |||
| dad84e1d5a | |||
| 4ad03c196c | |||
| 7168f5391d | |||
| 2c5a21ec2a | |||
| e80af77b8d | |||
| 2ef43e821c | |||
| 42e6b88220 | |||
| a4a280ed34 | |||
| 94c3f0e4aa | |||
| 52783ccefc | |||
| 1926236d0b | |||
| 446ee1d145 | |||
| 5fb5f10d9a | |||
| 6da8d873d3 | |||
| db23aecad9 | |||
| 31bd279b4b | |||
| 8b2d249ea6 | |||
| ab817169e8 | |||
| 408e44636e | |||
| 6145092086 | |||
| a038fae17c | |||
| 779b844138 | |||
| 3fe52c36ef | |||
| fa0c843126 | |||
| 6e0047c632 | |||
| 66d2ae99a6 | |||
| b636bed83b | |||
| 16fc9c0b09 | |||
| ee3b06d4aa | |||
| ccc367a376 | |||
| 054d0c74fc | |||
| 5d9554a46d | |||
| 47a77a5085 | |||
| ef3854ae8d | |||
| 9b0a95aa54 | |||
| 26bc1299ff | |||
| 74c9cfc5b6 | |||
| a930a795db | |||
| 0a5e201936 | |||
| 0989a27fdb | |||
| e9a8b80476 | |||
| 36b0676bfc | |||
| 8702440474 | |||
| 3413100602 | |||
| 882f5bc28e | |||
| 1ffb36e1a3 | |||
| b02ded094f | |||
| 36d9f9100c | |||
| 83d695ee94 | |||
| 4d76cf46f9 | |||
| fa5a1daf68 | |||
| 4563261c52 | |||
| ab5f323159 | |||
| 17aed59317 | |||
| 788817f485 | |||
| 8dfe0cd068 | |||
| 2674ba9d99 | |||
| c7c74de382 | |||
| 60c5b9cb9d | |||
| 5c309142f3 | |||
| 098c4f7f3c | |||
| ac5deca5ae | |||
| 82d4c1c94a | |||
| 9118119901 | |||
| 02d61989fd | |||
| eb826dc612 | |||
| d5dd930932 | |||
| 04ebf421a1 | |||
| 93d9a2ebc1 | |||
| b7697742c6 | |||
| a21543ff79 | |||
| 218f234a18 | |||
| 815d895729 | |||
| 6c4bdef80d | |||
| 6cd801287c | |||
| dd7b93615d | |||
| 682b57597a | |||
| 2de0b6311f | |||
| d3195411bb | |||
| e0527b00d5 | |||
| 9d27c3cac4 | |||
| 8e681a9639 | |||
| 48ade5861a | |||
| 28e55fa01a | |||
| 64288af285 | |||
| 27f9f88c37 | |||
| 32da86ec5c | |||
| da440cdea8 | |||
| 6c651cff01 | |||
| a153e18059 | |||
| 48275aff5f | |||
| b5747cab84 | |||
| 5d22031a32 | |||
| 340123aec2 | |||
| e1827395b5 | |||
| bfb6940402 | |||
| f7c096cd9d | |||
| aa15ce42ce | |||
| cebdc97b83 | |||
| 3cfdbca8f5 | |||
| 0645c32a45 | |||
| 2a985eb6aa | |||
| 647bc29ef1 | |||
| b9a074aceb | |||
| 8207e510dd | |||
| 1348a58175 | |||
| 4b5b2fd3bd | |||
| 8bb852e2ff | |||
| 51b3c0d789 | |||
| 5e7a5a4a38 | |||
| 65a4de0e33 | |||
| b5d8e1cd2e | |||
| c11aede298 | |||
| 0db8171898 | |||
| a24482d9b3 | |||
| 7662fe3645 | |||
| 0950fe64cc | |||
| b25e85ddb1 | |||
| deedd0d413 | |||
| 07a7908486 | |||
| 1eea91a6d0 | |||
| 3fbba5d164 | |||
| 30295699b6 | |||
| 37ca59a1e5 | |||
| 6b0e854f26 | |||
| 7ad972dd23 | |||
| c2168eaf02 | |||
| 60625a7bff | |||
| 43ee952763 | |||
| 8720c63f63 | |||
| 6778142d62 | |||
| e6b6e00bf2 | |||
| a91cee40ba | |||
| c03b6521d5 | |||
| c33ff5fa20 | |||
| 281d98edcd | |||
| 7b84e36387 | |||
| 71a122b671 | |||
| f113328619 | |||
| ad9d8259e6 | |||
| 75834b7668 | |||
| 6ac86c9ce6 | |||
| 8e3b5ae664 | |||
| f22d8b5a47 | |||
| 2260a72c1d | |||
| 4ead5238bc | |||
| 851f6f1940 | |||
| 63f69a6bd5 | |||
| 01800715f8 | |||
| 157b1b8d8b | |||
| ffcd191135 | |||
| 769097544e | |||
| adc93021e7 | |||
| a3f5b5c2c0 | |||
| c08a312111 | |||
| 3c71d9ae93 | |||
| fe8205adae | |||
| 75c332ade1 | |||
| e0202ccda5 | |||
| 275da32584 | |||
| 2f6f508a56 | |||
| 9b7e8841c4 | |||
| 48653665b3 | |||
| 5e1a68de63 | |||
| caa9dd4db4 | |||
| cb891bc063 | |||
| 2ee3adef14 | |||
| 53618e0117 | |||
| 7c6a2e9767 | |||
| c44aa52f5f | |||
| 7f6efad8c8 | |||
| f9d82d163f | |||
| 42d0f3cf74 |
3
.gitignore
vendored
3
.gitignore
vendored
@ -7,4 +7,5 @@ local.properties
|
||||
captures/
|
||||
build/
|
||||
release-app/
|
||||
scripts/apk-channel/
|
||||
scripts/apk-channel/
|
||||
app/src/test/java/com/gh/gamecenter
|
||||
2
.gitmodules
vendored
2
.gitmodules
vendored
@ -1,4 +1,4 @@
|
||||
[submodule "libraries/LGLibrary"]
|
||||
path = libraries/LGLibrary
|
||||
url = git@gitlab.ghzhushou.com:client/client-common.git
|
||||
url = git@gitlab.ghzs.com:android/common-library.git
|
||||
branch = master
|
||||
|
||||
82
CHANGELOG.md
82
CHANGELOG.md
@ -1,4 +1,10 @@
|
||||
### Ver 3.1
|
||||
# 版本升级备忘
|
||||
|
||||
### Ver 2.5
|
||||
* 此处写本次更新所做的业务和代码修改
|
||||
|
||||
### Ver 2.6
|
||||
* xx
|
||||
|
||||
### Ver 3.0
|
||||
* 升级账号系统(登录流程/用户信息相关/用户账号相关操作(评论,礼包...))
|
||||
@ -10,8 +16,74 @@
|
||||
* 游戏下载平台面板修改(加快弹出速度,不再读取本地平台图片)
|
||||
* 接入bugly(tinker)
|
||||
|
||||
### Ver 2.6
|
||||
* xx
|
||||
### VER 3.1
|
||||
### VER 3.2
|
||||
### VER 3.3
|
||||
### VER 3.4
|
||||
### VER 3.5
|
||||
|
||||
### Ver 2.5
|
||||
* 此处写本次更新所做的业务和代码修改
|
||||
### Ver 3.6
|
||||
* 首页游戏增加预览骨架,游戏ITEM样式微调和开服标签
|
||||
* 首页问答增加关注页面
|
||||
* 重构游戏更新管理(游戏更新/插件化/已安装的游戏),具体细节参考PackageRepository & PackageViewModel
|
||||
* 重构APP更新管理(已VersionVode为更新基准,小版本更新改为光环后台控制)
|
||||
- 删除TINKER_VERISON_NAME
|
||||
- tinker打包方式变更(以小版本作为Base包,防止与数据后台小版本更新发生冲突)
|
||||
* 社区增加版主功能(版主可以对存在的相关内容进行修改/隐藏操作,内容包括问题/回答/回答评论)
|
||||
* 社区互动引导优化(问答推荐增加`推荐关注`,回答详情增加一些交互动效)
|
||||
|
||||
### Ver 3.6.1
|
||||
* 可以后台控制关闭资讯功能
|
||||
* 版块、分类、专题详情、游戏详情、礼包详情增加预览骨架
|
||||
* 下载按钮状态可以通过接口屏蔽相应的包
|
||||
|
||||
### Ver 3.6.2
|
||||
* 资讯/问答入口和插件功能线上控制(不可逆)
|
||||
* 首页不显示已安装的游戏
|
||||
* 插件求版本功能增加内部跳转
|
||||
* 下载面板增加公告和版本说明功能
|
||||
* 接入腾讯`广点通`(广告)
|
||||
|
||||
### ver 3.6.3
|
||||
* 社区搜索修改
|
||||
- 增加 `文章/用户` 模块
|
||||
- 增加 `搜索置顶` 功能
|
||||
* 回答详情/社区文章详情修改
|
||||
- 支持文案样式(加粗/斜体/删除线)和段落样式(引用/标题)
|
||||
- 支持关闭评论功能
|
||||
- 回答详情新增上下切换回答
|
||||
* 社区编辑框(回答/文章)修改
|
||||
- 支持批量插入图片(使用知乎Matisse实现)
|
||||
- 新增插入特殊样式,文案样式(加粗/斜体/删除线)和段落样式(引用/标题)
|
||||
* 编辑框部分 JS/CSS 使用远程文件
|
||||
|
||||
### ver 3.6.4
|
||||
* 增加浏览记录(回答/文章/资讯/游戏)
|
||||
* 回答/社区文章 增加反对功能
|
||||
* 社区编辑框增加插入文章/回答/游戏
|
||||
- 低版本兼容方案: 插入的样式默认隐藏,只有在3.6.4及以上才会显示
|
||||
* 游戏详情评分模块增加`小编评论`区域以及样式修改
|
||||
* 游戏评分增加回复功能
|
||||
|
||||
### var 3.6.5
|
||||
* 以补丁方式向外推出,并没有增加需求,只是单纯的修BUG
|
||||
|
||||
### var 3.6.6
|
||||
* 游戏详情:
|
||||
- 支持修改评分
|
||||
- 评分列表增加排序/过滤功能
|
||||
- 增加弹出系统
|
||||
* 社区相关:
|
||||
- 选择社区页面重做
|
||||
- 首页社区推荐增加推荐入口
|
||||
- 首页社区问题模块改版,名称改为全部,去除问题分类(统一为问题列表),增加社区文章列表
|
||||
* 游戏搜索默认页面改版
|
||||
* 权限系统更改,不授权也可以进去App,申请权限细分到功能(用到某个功能时才需要强制授予权限)
|
||||
* 增加隐私系统
|
||||
* 增加游戏预约功能
|
||||
* 增加标签详情模块
|
||||
* 进入今日头条广告SDK
|
||||
* 图片上传压缩机制优化
|
||||
- 支持从后台修改上传配置(本该在早些版本实现,由于代码问题无法引用后台配置)
|
||||
- 对压缩失败是进行catch(由于后台对宽高配置放宽,很容易发生OOM),失败后直接上传原图(这步可能会出现问题)
|
||||
* 游戏相关UI修改
|
||||
@ -63,4 +63,7 @@
|
||||
- ~~把 ListViewModel 的数据结构类型转换方式换为抽象方法,让继承的类实现,避免出现无响应的问题~~
|
||||
|
||||
- ~~rxjava2 如果接口返回为空 会发生异常:java.lang.NullPointerException: Null is not a valid element (答案编辑) 解决方法->com.gh.gamecenter.retrofit.Response~~
|
||||
- constraintLayout 1.1.2 导致布局出现异常(问题编辑标签选择弹窗)
|
||||
- constraintLayout 1.1.2 导致布局出现异常(问题编辑标签选择弹窗)
|
||||
|
||||
- 搞清楚 GameManager 的用途,看能不能去掉
|
||||
- 重构一下 MainActivity
|
||||
106
app/build.gradle
106
app/build.gradle
@ -1,7 +1,6 @@
|
||||
apply plugin: 'com.android.application'
|
||||
|
||||
apply plugin: 'org.jetbrains.kotlin.android.extensions'
|
||||
apply plugin: 'kotlin-android' // kotlin
|
||||
apply plugin: 'kotlin-android-extensions'
|
||||
apply plugin: 'kotlin-kapt'
|
||||
|
||||
// apkChannelPackage
|
||||
@ -38,14 +37,8 @@ android {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 只支持两种架构,减少apk大小,有疑问请参考:
|
||||
* https://developer.android.com/ndk/guides/abis.html
|
||||
* http://allenfeng.com/2016/11/06/what-you-should-know-about-android-abi-and-so/
|
||||
* (为了性能考虑,armeabi可以考虑替换成armeabi-v7a[需要先收集用户设备情况])
|
||||
*/
|
||||
ndk {
|
||||
abiFilters "armeabi", "x86"
|
||||
abiFilters "armeabi-v7a", "x86"
|
||||
}
|
||||
|
||||
// 由于app只针对中文用户,所以仅保留zh资源,其他删掉
|
||||
@ -68,7 +61,11 @@ android {
|
||||
buildConfigField "String", "WEIBO_APPKEY", "\"${WEIBO_APPKEY}\""
|
||||
buildConfigField "String", "MTA_APPKEY", "\"${MTA_APPKEY}\""
|
||||
buildConfigField "String", "TD_APPID", "\"${TD_APPID}\""
|
||||
buildConfigField "String", "PATCH_VERSION_NAME", "\"${PATCH_VERSION_NAME}\""
|
||||
|
||||
/**
|
||||
* Build Time 供区分 jenkins 打包时间用
|
||||
*/
|
||||
buildConfigField "long", "BUILD_TIME", "0"
|
||||
|
||||
}
|
||||
|
||||
@ -92,7 +89,7 @@ android {
|
||||
signingConfig signingConfigs.debug
|
||||
|
||||
buildConfigField "String", "EXPOSURE_REPO", "\"test\""
|
||||
buildConfigField "String", "EXPOSURE_VERSION", "\"E1\""
|
||||
buildConfigField "String", "EXPOSURE_VERSION", "\"E3\""
|
||||
}
|
||||
release {
|
||||
debuggable false
|
||||
@ -102,7 +99,7 @@ android {
|
||||
signingConfig signingConfigs.release
|
||||
|
||||
buildConfigField "String", "EXPOSURE_REPO", "\"exposure\""
|
||||
buildConfigField "String", "EXPOSURE_VERSION", "\"E1\""
|
||||
buildConfigField "String", "EXPOSURE_VERSION", "\"E3\""
|
||||
}
|
||||
}
|
||||
|
||||
@ -116,10 +113,7 @@ android {
|
||||
publish {
|
||||
dimension "nonsense"
|
||||
buildConfigField "String", "API_HOST", "\"${API_HOST}\""
|
||||
buildConfigField "String", "USER_HOST", "\"${USER_HOST}\""
|
||||
buildConfigField "String", "COMMENT_HOST", "\"${COMMENT_HOST}\""
|
||||
buildConfigField "String", "LIBAO_HOST", "\"${LIBAO_HOST}\""
|
||||
buildConfigField "String", "MESSAGE_HOST", "\"${MESSAGE_HOST}\""
|
||||
buildConfigField "String", "DATA_HOST", "\"${DATA_HOST}\""
|
||||
|
||||
buildConfigField "String", "UMENG_APPKEY", "\"${UMENG_APPKEY}\""
|
||||
@ -130,7 +124,6 @@ android {
|
||||
buildConfigField "String", "MEIZUPUSH_APPKEY", "\"${MEIZUPUSH_APPKEY}\""
|
||||
|
||||
buildConfigField "String", "BUGLY_APPID", "\"${BUGLY_APPID}\""
|
||||
|
||||
}
|
||||
// internal test dev host
|
||||
internal {
|
||||
@ -138,10 +131,7 @@ android {
|
||||
versionNameSuffix "-debug"
|
||||
|
||||
buildConfigField "String", "API_HOST", "\"${DEV_API_HOST}\""
|
||||
buildConfigField "String", "USER_HOST", "\"${DEV_USER_HOST}\""
|
||||
buildConfigField "String", "COMMENT_HOST", "\"${DEV_COMMENT_HOST}\""
|
||||
buildConfigField "String", "LIBAO_HOST", "\"${DEV_LIBAO_HOST}\""
|
||||
buildConfigField "String", "MESSAGE_HOST", "\"${DEV_MESSAGE_HOST}\""
|
||||
buildConfigField "String", "DATA_HOST", "\"${DEV_DATA_HOST}\""
|
||||
|
||||
buildConfigField "String", "UMENG_APPKEY", "\"${DEBUG_UMENG_APPKEY}\""
|
||||
@ -154,11 +144,6 @@ android {
|
||||
buildConfigField "String", "BUGLY_APPID", "\"${DEBUG_BUGLY_APPID}\""
|
||||
}
|
||||
}
|
||||
|
||||
// productFlavors.all { flavor ->
|
||||
// flavor.manifestPlaceholders = [CHANNEL_VALUE: name]//命令 gradlew assembleRelease
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
// apkChannelPackage
|
||||
@ -178,23 +163,41 @@ rebuildChannel {
|
||||
// releaseOutputDir = Release渠道包输出目录
|
||||
}
|
||||
|
||||
repositories {
|
||||
flatDir {
|
||||
dirs 'libs/aars'
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
||||
implementation fileTree(include: '*.jar', dir: 'libs')
|
||||
implementation fileTree(include: ['*.jar', '*.aar'], dir: 'libs')
|
||||
|
||||
testImplementation 'junit:junit:4.12'
|
||||
|
||||
debugImplementation "com.squareup.leakcanary:leakcanary-android:${leakcanary}"
|
||||
debugImplementation "com.facebook.stetho:stetho:${stetho}"
|
||||
debugImplementation "com.facebook.stetho:stetho-okhttp3:${stetho}"
|
||||
debugImplementation "com.squareup.okhttp3:logging-interceptor:${okHttp}"
|
||||
|
||||
implementation "com.android.support:multidex:${multidex}"
|
||||
implementation "com.android.support:design:${androidSupport}"
|
||||
implementation "com.android.support:support-v4:${androidSupport}"
|
||||
implementation "com.android.support:appcompat-v7:${androidSupport}"
|
||||
implementation "com.android.support:cardview-v7:${androidSupport}"
|
||||
implementation "com.android.support:support-annotations:${androidSupport}"
|
||||
implementation "com.android.support:percent:${androidSupport}"
|
||||
implementation "com.android.support.constraint:constraint-layout:${constraintLayout}"
|
||||
implementation "androidx.core:core:${core}"
|
||||
implementation "androidx.fragment:fragment:${fragment}"
|
||||
implementation "androidx.multidex:multidex:${multiDex}"
|
||||
implementation "androidx.appcompat:appcompat:${appCompat}"
|
||||
implementation "androidx.cardview:cardview:${cardView}"
|
||||
implementation "androidx.annotation:annotation:${annotation}"
|
||||
implementation "androidx.constraintlayout:constraintlayout:${constraintLayout}"
|
||||
implementation "androidx.recyclerview:recyclerview:${recyclerView}"
|
||||
implementation "androidx.lifecycle:lifecycle-runtime:${lifeCycle}"
|
||||
implementation "androidx.lifecycle:lifecycle-extensions:${lifeCycle}"
|
||||
kapt "androidx.lifecycle:lifecycle-compiler:${lifeCycle}"
|
||||
implementation "androidx.room:room-runtime:${room}"
|
||||
implementation "androidx.room:room-rxjava2:${room}"
|
||||
kapt "androidx.room:room-compiler:${room}"
|
||||
kapt "androidx.databinding:databinding-compiler:${databinding}"
|
||||
|
||||
implementation "com.google.android.material:material:${material}"
|
||||
|
||||
implementation "com.kyleduo.switchbutton:library:${switchButton}"
|
||||
|
||||
implementation "com.facebook.fresco:fresco:${fresco}"
|
||||
@ -212,12 +215,11 @@ dependencies {
|
||||
implementation "com.j256.ormlite:ormlite-core:${ormlite}"
|
||||
|
||||
implementation "com.jakewharton:butterknife:${butterKnife}"
|
||||
annotationProcessor "com.jakewharton:butterknife-compiler:${butterKnife}"
|
||||
kapt "com.jakewharton:butterknife-compiler:${butterKnife}"
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib:${kotlin_version}"
|
||||
|
||||
implementation "org.greenrobot:eventbus:${eventbus}"
|
||||
annotationProcessor "org.greenrobot:eventbus-annotation-processor:${eventbusApt}"
|
||||
kapt "org.greenrobot:eventbus-annotation-processor:${eventbusApt}"
|
||||
|
||||
implementation "io.reactivex.rxjava2:rxjava:${rxJava2}"
|
||||
implementation "io.reactivex.rxjava2:rxandroid:${rxAndroid2}"
|
||||
@ -227,9 +229,6 @@ dependencies {
|
||||
implementation "com.google.zxing:android-core:${zxing}"
|
||||
|
||||
implementation "com.daimajia.swipelayout:library:${swipeLayout}"
|
||||
implementation("cn.trinea.android.view.autoscrollviewpager:android-auto-scroll-view-pager:${autoScrollViewPager}") {
|
||||
exclude module: 'support-v4'
|
||||
}
|
||||
|
||||
implementation "com.sina.weibo.sdk:core:${weiboSDK}"
|
||||
|
||||
@ -237,34 +236,45 @@ dependencies {
|
||||
implementation "com.tencent.bugly:crashreport_upgrade:${buglyTinkerSupport}"
|
||||
|
||||
implementation "pub.devrel:easypermissions:${easypermissions}"
|
||||
// mvvm
|
||||
implementation "android.arch.lifecycle:runtime:${archLifecycleVersion}"
|
||||
kapt "android.arch.lifecycle:compiler:${archLifecycleVersion}"
|
||||
implementation "android.arch.lifecycle:extensions:${archLifecycleVersion}"
|
||||
implementation "android.arch.persistence.room:runtime:${archRoomVersion}"
|
||||
kapt "android.arch.persistence.room:compiler:${archRoomVersion}"
|
||||
|
||||
implementation 'com.google.android:flexbox:0.2.2'
|
||||
implementation 'com.google.android:flexbox:1.1.0'
|
||||
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
||||
kapt 'com.android.databinding:compiler:3.1.3'
|
||||
|
||||
implementation 'com.contrarywind:Android-PickerView:4.1.3'
|
||||
|
||||
implementation "com.scwang.smartrefresh:SmartRefreshLayout:${smartRefreshLayout}"
|
||||
implementation "net.cachapa.expandablelayout:expandablelayout:${expandableLayout}"
|
||||
|
||||
// 用于比较 versionName 是大于小于或等于
|
||||
implementation "com.g00fy2:versioncompare:${versioncompare}"
|
||||
|
||||
implementation "top.zibin:Luban:${luban}"
|
||||
|
||||
// for video streaming
|
||||
implementation "cn.jzvd:jiaozivideoplayer:${jiaoziVideoView}"
|
||||
implementation "com.danikula:videocache:${videoCache}"
|
||||
|
||||
implementation "android.arch.work:work-runtime:${workManager}"
|
||||
|
||||
implementation "com.llew.huawei:verifier:1.0.6"
|
||||
|
||||
implementation "com.github.tbruyelle:rxpermissions:${rxPermissions}"
|
||||
|
||||
implementation 'com.ethanhua:skeleton:1.1.1'
|
||||
implementation 'io.supercharge:shimmerlayout:2.1.0'
|
||||
implementation "com.tencent.mm.opensdk:wechat-sdk-android-without-mta:5.3.1"
|
||||
implementation 'com.walkud.rom.checker:RomChecker:1.0.0'
|
||||
|
||||
implementation project(':libraries:LGLibrary')
|
||||
implementation project(':libraries:MTA')
|
||||
implementation project(':libraries:QQShare')
|
||||
implementation project(':libraries:TalkingData')
|
||||
implementation project(':libraries:UmengPush')
|
||||
implementation project(':libraries:WechatShare')
|
||||
implementation project(':libraries:iosched')
|
||||
// implementation project(':libraries:WechatShare')
|
||||
implementation project(':libraries:LogHub')
|
||||
implementation project(':libraries:im')
|
||||
implementation project(':libraries:Matisse')
|
||||
}
|
||||
File propFile = file('sign.properties')
|
||||
if (propFile.exists()) {
|
||||
|
||||
BIN
app/libs/GDTActionSDK.min.1.4.2.jar
Normal file
BIN
app/libs/GDTActionSDK.min.1.4.2.jar
Normal file
Binary file not shown.
BIN
app/libs/applog-release.aar
Normal file
BIN
app/libs/applog-release.aar
Normal file
Binary file not shown.
BIN
app/libs/gid-1.0.jar
Normal file
BIN
app/libs/gid-1.0.jar
Normal file
Binary file not shown.
@ -194,7 +194,35 @@
|
||||
|
||||
-ignorewarnings
|
||||
|
||||
-keep @android.support.annotation.Keep class *
|
||||
-keep @androidx.annotation.Keep class *
|
||||
-keepclassmembers class ** {
|
||||
@android.support.annotation.Keep *;
|
||||
}
|
||||
@androidx.annotation.Keep *;
|
||||
}
|
||||
|
||||
-keep class com.gh.loghub.** { *; }
|
||||
|
||||
### greenDAO 3
|
||||
-keepclassmembers class * extends org.greenrobot.greendao.AbstractDao {
|
||||
public static java.lang.String TABLENAME;
|
||||
}
|
||||
-keep class **$Properties
|
||||
-keep class org.greenrobot.greendao.** { *; }
|
||||
# If you do not use SQLCipher:
|
||||
-dontwarn org.greenrobot.greendao.database.**
|
||||
# If you do not use RxJava:
|
||||
-dontwarn rx.**
|
||||
-dontwarn org.greenrobot.greendao.rx.**
|
||||
-dontwarn org.greenrobot.greendao.**
|
||||
|
||||
### fastJson
|
||||
-dontwarn com.alibaba.fastjson.**
|
||||
-keep class com.alibaba.fastjson.** { *; }
|
||||
-keepattributes Signature
|
||||
-keepattributes Annotation
|
||||
|
||||
### 广点通
|
||||
-dontwarn com.qq.gdt.action.**
|
||||
-keep class com.qq.gdt.action.** {*;}
|
||||
|
||||
### AndroidX
|
||||
-keep class androidx.core.app.CoreComponentFactory { *; }
|
||||
@ -21,32 +21,19 @@
|
||||
<uses-permission android:name = "android.permission.GET_TASKS" />
|
||||
<!-- 允许访问振动设备 -->
|
||||
<uses-permission android:name = "android.permission.VIBRATE" />
|
||||
<!-- 允许应用程序通过WiFi或移动基站获取粗略的位置信息 -->
|
||||
<uses-permission android:name = "android.permission.ACCESS_COARSE_LOCATION" />
|
||||
<!-- 允许应用程序通过GPS获取精确的位置信息 -->
|
||||
<uses-permission android:name = "android.permission.ACCESS_FINE_LOCATION" />
|
||||
<!-- 允许应用程序改变Wi-Fi连接状态 -->
|
||||
<uses-permission android:name = "android.permission.CHANGE_WIFI_STATE" />
|
||||
<!-- 允许应用程序管理AccountManager中的账户列表 -->
|
||||
<uses-permission android:name = "android.permission.MANAGE_ACCOUNTS" />
|
||||
<!-- 允许应用程序访问GMail账户列表 -->
|
||||
<uses-permission android:name = "android.permission.GET_ACCOUNTS" />
|
||||
<!-- 允许应用程序连接配对过的蓝牙设备 -->
|
||||
<uses-permission android:name = "android.permission.BLUETOOTH" />
|
||||
<!-- 允许应用程序管理蓝牙,搜索和配对新的蓝牙设备 -->
|
||||
<uses-permission android:name = "android.permission.BLUETOOTH_ADMIN" />
|
||||
<!-- 允许应用程序打开系统窗口,显示其他应用程序 -->
|
||||
<uses-permission android:name = "android.permission.SYSTEM_ALERT_WINDOW" />
|
||||
<!-- 修改系统设置的权限 -->
|
||||
<uses-permission android:name = "android.permission.WRITE_SETTINGS" />
|
||||
|
||||
<!-- bugly with tinker -->
|
||||
<uses-permission android:name = "android.permission.READ_PHONE_STATE" />
|
||||
<uses-permission android:name = "android.permission.INTERNET" />
|
||||
<uses-permission android:name = "android.permission.ACCESS_NETWORK_STATE" />
|
||||
<uses-permission android:name = "android.permission.ACCESS_WIFI_STATE" />
|
||||
<uses-permission android:name = "android.permission.READ_LOGS" />
|
||||
<uses-permission android:name = "android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name = "android.permission.REQUEST_INSTALL_PACKAGES" />
|
||||
|
||||
<!-- 去掉 SDK 一些流氓权限 -->
|
||||
<uses-permission android:name = "android.permission.READ_CONTACTS" tools:node = "remove"/>
|
||||
|
||||
<supports-screens
|
||||
android:anyDensity = "true"
|
||||
@ -59,7 +46,7 @@
|
||||
<application
|
||||
android:name = "com.halo.assistant.TinkerApp"
|
||||
android:allowBackup = "true"
|
||||
android:icon = "@drawable/logo"
|
||||
android:icon = "@mipmap/logo"
|
||||
android:label = "@string/app_name"
|
||||
android:resizeableActivity = "true"
|
||||
android:theme = "@style/AppCompatTheme.APP"
|
||||
@ -69,7 +56,6 @@
|
||||
<activity
|
||||
android:name = "com.gh.gamecenter.SplashScreenActivity"
|
||||
android:configChanges = "keyboardHidden|orientation|screenSize"
|
||||
android:noHistory = "true"
|
||||
android:screenOrientation = "portrait"
|
||||
android:theme = "@style/AppGuideTheme" >
|
||||
<intent-filter >
|
||||
@ -107,10 +93,7 @@
|
||||
android:name = "com.gh.gamecenter.ConcernActivity"
|
||||
android:screenOrientation = "portrait" />
|
||||
<activity
|
||||
android:name = "com.gh.gamecenter.subject.refactor.SubjectActivity"
|
||||
android:screenOrientation = "portrait" />
|
||||
<activity
|
||||
android:name = "com.gh.gamecenter.PluginActivity"
|
||||
android:name = "com.gh.gamecenter.subject.SubjectActivity"
|
||||
android:screenOrientation = "portrait" />
|
||||
<activity
|
||||
android:name = "com.gh.gamecenter.NewsSearchActivity"
|
||||
@ -151,19 +134,19 @@
|
||||
android:name = "com.gh.gamecenter.CleanApkActivity"
|
||||
android:screenOrientation = "portrait" />
|
||||
<activity
|
||||
android:name = "com.gh.gamecenter.KcSelectGameActivity"
|
||||
android:name = "com.gh.gamecenter.kuaichuan.view.KcSelectGameActivity"
|
||||
android:screenOrientation = "portrait" />
|
||||
<activity
|
||||
android:name = "com.gh.gamecenter.ChooseReceiverActivity"
|
||||
android:name = "com.gh.gamecenter.kuaichuan.view.ChooseReceiverActivity"
|
||||
android:screenOrientation = "portrait" />
|
||||
<activity
|
||||
android:name = "com.gh.gamecenter.ReceiverWaitingActivity"
|
||||
android:name = "com.gh.gamecenter.kuaichuan.view.ReceiverWaitingActivity"
|
||||
android:screenOrientation = "portrait" />
|
||||
<activity
|
||||
android:name = "com.gh.gamecenter.FileSenderActivity"
|
||||
android:name = "com.gh.gamecenter.kuaichuan.view.FileSenderActivity"
|
||||
android:screenOrientation = "portrait" />
|
||||
<activity
|
||||
android:name = "com.gh.gamecenter.FileReceiverActivity"
|
||||
android:name = "com.gh.gamecenter.kuaichuan.view.FileReceiverActivity"
|
||||
android:screenOrientation = "portrait" />
|
||||
<activity
|
||||
android:name = "com.gh.gamecenter.SelectUserIconActivity"
|
||||
@ -174,8 +157,12 @@
|
||||
<activity
|
||||
android:name = "com.gh.gamecenter.CommentDetailActivity"
|
||||
android:screenOrientation = "portrait" />
|
||||
<activity
|
||||
android:name = "com.gh.gamecenter.mygame.MyGameActivity"
|
||||
android:screenOrientation = "portrait" />
|
||||
<activity
|
||||
android:name = "com.gh.gamecenter.GameDetailActivity"
|
||||
android:configChanges = "orientation|screenSize|keyboardHidden"
|
||||
android:screenOrientation = "portrait" />
|
||||
<activity
|
||||
android:name = "com.gh.gamecenter.SuggestSelectActivity"
|
||||
@ -197,10 +184,6 @@
|
||||
android:screenOrientation = "portrait"
|
||||
android:windowSoftInputMode = "stateHidden" />
|
||||
|
||||
<activity
|
||||
android:name = "com.gh.gamecenter.InstallActivity"
|
||||
android:screenOrientation = "portrait" />
|
||||
|
||||
<activity
|
||||
android:name = ".category.CategoryDirectoryActivity"
|
||||
android:screenOrientation = "portrait" />
|
||||
@ -328,7 +311,7 @@
|
||||
android:screenOrientation = "portrait" />
|
||||
|
||||
<activity
|
||||
android:name = "com.gh.gamecenter.personalhome.fans.FollowersActivity"
|
||||
android:name = "com.gh.gamecenter.personalhome.followers.FollowersActivity"
|
||||
android:screenOrientation = "portrait" />
|
||||
|
||||
<activity
|
||||
@ -343,6 +326,83 @@
|
||||
android:name = "com.gh.gamecenter.personalhome.question.PersonalQuestionActivity"
|
||||
android:screenOrientation = "portrait" />
|
||||
|
||||
<activity
|
||||
android:name = "com.gh.gamecenter.qa.article.edit.ArticleEditActivity"
|
||||
android:screenOrientation = "portrait" />
|
||||
|
||||
<activity
|
||||
android:name = "com.gh.gamecenter.qa.article.MyArticleActivity"
|
||||
android:screenOrientation = "portrait" />
|
||||
|
||||
<activity
|
||||
android:name = "com.gh.gamecenter.qa.article.draft.ArticleDraftActivity"
|
||||
android:screenOrientation = "portrait" />
|
||||
|
||||
<activity
|
||||
android:name = "com.gh.gamecenter.qa.article.detail.ArticleDetailActivity"
|
||||
android:screenOrientation = "portrait" />
|
||||
|
||||
<activity
|
||||
android:name = "com.gh.gamecenter.qa.draft.CommunityDraftWrapperActivity"
|
||||
android:screenOrientation = "portrait" />
|
||||
|
||||
<activity
|
||||
android:name = "com.gh.gamecenter.gamedetail.rating.edit.RatingEditActivity"
|
||||
android:screenOrientation = "portrait"
|
||||
android:windowSoftInputMode = "stateVisible" />
|
||||
|
||||
<activity
|
||||
android:name = "com.gh.gamecenter.qa.questions.edit.manager.HistoryDetailActivity"
|
||||
android:screenOrientation = "portrait" />
|
||||
|
||||
<activity
|
||||
android:name = "com.gh.gamecenter.qa.questions.edit.manager.HistoryActivity"
|
||||
android:screenOrientation = "portrait" />
|
||||
|
||||
<activity
|
||||
android:name = "com.gh.gamecenter.qa.editor.InsertAnswerWrapperActivity"
|
||||
android:screenOrientation = "portrait" />
|
||||
|
||||
<activity
|
||||
android:name = "com.gh.gamecenter.qa.editor.GameActivity"
|
||||
android:screenOrientation = "portrait" />
|
||||
|
||||
<activity
|
||||
android:name = "com.gh.gamecenter.qa.editor.InsertArticleWrapperActivity"
|
||||
android:screenOrientation = "portrait" />
|
||||
|
||||
<activity
|
||||
android:name = "com.gh.gamecenter.gamedetail.rating.RatingReplyActivity"
|
||||
android:screenOrientation = "portrait" />
|
||||
|
||||
<activity
|
||||
android:name = "com.gh.gamecenter.history.HistoryActivity"
|
||||
android:screenOrientation = "portrait" />
|
||||
|
||||
<activity
|
||||
android:name = "com.gh.gamecenter.kuaichuan.view.FileShareActivity"
|
||||
android:screenOrientation = "portrait" />
|
||||
|
||||
<activity
|
||||
android:name = "com.gh.gamecenter.personalhome.rating.RatingActivity"
|
||||
android:screenOrientation = "portrait" />
|
||||
|
||||
<activity
|
||||
android:name = "com.gh.gamecenter.gamedetail.rating.logs.CommentLogsActivity"
|
||||
android:screenOrientation = "portrait" />
|
||||
|
||||
<activity
|
||||
android:name = "com.gh.gamecenter.tag.TagsActivity"
|
||||
android:screenOrientation = "portrait" />
|
||||
|
||||
<activity android:name = "com.gh.gamecenter.qa.article.SimpleArticleListActivity"
|
||||
android:screenOrientation = "portrait" />
|
||||
|
||||
<activity
|
||||
android:name = "com.gh.gamecenter.qa.comment.CommentActivity"
|
||||
android:screenOrientation = "portrait"
|
||||
android:theme = "@style/Theme.Transparent"
|
||||
android:windowSoftInputMode = "adjustNothing" />
|
||||
|
||||
<!-- 使用小米/华为推送弹窗功能提高推送成功率-->
|
||||
<activity
|
||||
@ -363,18 +423,22 @@
|
||||
</activity >
|
||||
|
||||
<activity
|
||||
android:name = ".CommonActivity"
|
||||
android:screenOrientation = "portrait" />
|
||||
android:name = "${applicationId}.wxapi.WXEntryActivity"
|
||||
android:exported = "true"
|
||||
android:label = "@string/app_name"
|
||||
android:launchMode = "singleTop"
|
||||
android:screenOrientation = "portrait"
|
||||
android:theme = "@android:style/Theme.Translucent.NoTitleBar" ></activity >
|
||||
|
||||
<receiver android:name = "com.gh.gamecenter.receiver.InstallAndUninstallReceiver" >
|
||||
<intent-filter >
|
||||
<action android:name = "android.intent.action.PACKAGE_ADDED" />
|
||||
<action android:name = "android.intent.action.PACKAGE_REMOVED" />
|
||||
<action android:name = "android.intent.action.PACKAGE_REPLACED" />
|
||||
|
||||
<data android:scheme = "package" />
|
||||
</intent-filter >
|
||||
</receiver >
|
||||
<provider
|
||||
android:name = "androidx.core.content.FileProvider"
|
||||
android:authorities = "${applicationId}"
|
||||
android:exported = "false"
|
||||
android:grantUriPermissions = "true" >
|
||||
<meta-data
|
||||
android:name = "android.support.FILE_PROVIDER_PATHS"
|
||||
android:resource = "@xml/provider_paths" />
|
||||
</provider >
|
||||
|
||||
<receiver
|
||||
android:name = "com.gh.gamecenter.receiver.DownloadReceiver"
|
||||
@ -390,11 +454,6 @@
|
||||
<action android:name = "com.gh.gamecenter.INSTALL" />
|
||||
</intent-filter >
|
||||
</receiver >
|
||||
<receiver android:name = "com.gh.gamecenter.receiver.NetworkStateReceiver" >
|
||||
<intent-filter >
|
||||
<action android:name = "android.net.conn.CONNECTIVITY_CHANGE" />
|
||||
</intent-filter >
|
||||
</receiver >
|
||||
|
||||
<receiver
|
||||
android:name = "com.gh.gamecenter.receiver.ActivitySkipReceiver"
|
||||
@ -411,30 +470,30 @@
|
||||
</receiver >
|
||||
|
||||
<!--魅族push应用定义消息receiver声明 -->
|
||||
<receiver android:name="com.gh.gamecenter.receiver.MeizuPushReceiver">
|
||||
<intent-filter>
|
||||
<receiver android:name = "com.gh.gamecenter.receiver.MeizuPushReceiver" >
|
||||
<intent-filter >
|
||||
<!-- 接收push消息 -->
|
||||
<action android:name="com.meizu.flyme.push.intent.MESSAGE" />
|
||||
<action android:name = "com.meizu.flyme.push.intent.MESSAGE" />
|
||||
<!-- 接收register消息 -->
|
||||
<action android:name="com.meizu.flyme.push.intent.REGISTER.FEEDBACK" />
|
||||
<action android:name = "com.meizu.flyme.push.intent.REGISTER.FEEDBACK" />
|
||||
<!-- 接收unregister消息-->
|
||||
<action android:name="com.meizu.flyme.push.intent.UNREGISTER.FEEDBACK" />
|
||||
<action android:name = "com.meizu.flyme.push.intent.UNREGISTER.FEEDBACK" />
|
||||
<!-- 兼容低版本Flyme3推送服务配置 -->
|
||||
<action android:name="com.meizu.c2dm.intent.REGISTRATION" />
|
||||
<action android:name="com.meizu.c2dm.intent.RECEIVE" />
|
||||
<action android:name = "com.meizu.c2dm.intent.REGISTRATION" />
|
||||
<action android:name = "com.meizu.c2dm.intent.RECEIVE" />
|
||||
|
||||
<category android:name="${applicationId}"/>
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
<category android:name = "${applicationId}" />
|
||||
</intent-filter >
|
||||
</receiver >
|
||||
|
||||
<receiver
|
||||
android:name="com.gh.common.im.ImReceiver"
|
||||
android:enabled="true">
|
||||
<intent-filter android:priority="2147483647">
|
||||
<action android:name="com.gh.im"/>
|
||||
<action android:name="action_finish"/>
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
android:name = "com.gh.common.im.ImReceiver"
|
||||
android:enabled = "true" >
|
||||
<intent-filter android:priority = "2147483647" >
|
||||
<action android:name = "com.gh.im" />
|
||||
<action android:name = "action_finish" />
|
||||
</intent-filter >
|
||||
</receiver >
|
||||
|
||||
<service android:name = "com.gh.base.GHUmengNotificationService" />
|
||||
|
||||
|
||||
@ -1,28 +1,163 @@
|
||||
function requestContentFocus() {
|
||||
$('#editor').focus();
|
||||
$("#editor").focus();
|
||||
}
|
||||
|
||||
function setupWhenContentEditable() {
|
||||
var editor = $('#editor');
|
||||
if (!editor[0].hasAttribute('contenteditable')) {
|
||||
return;
|
||||
var editor = $("#editor");
|
||||
if (!editor[0].hasAttribute("contenteditable")) {
|
||||
return;
|
||||
}
|
||||
|
||||
// paste
|
||||
editor.on("paste", function(e) {
|
||||
e.preventDefault();
|
||||
var text = (e.originalEvent || e).clipboardData.getData("text/plain");
|
||||
text = text.replace(/\n/g, "<br>");
|
||||
if ("" != text) {
|
||||
document.execCommand("insertHTML", false, text);
|
||||
} else {
|
||||
window.onPasteListener.onPaste();
|
||||
}
|
||||
});
|
||||
|
||||
// paste 回调只会获取粘贴之前的光标位置,需要自己手动加上粘贴文本的长度,并保证粘贴的是纯文本
|
||||
editor.on('paste', function(e) {
|
||||
e.preventDefault();
|
||||
var text = (e.originalEvent || e).clipboardData.getData('text/plain');
|
||||
text = text.replace(/\n/g, '<br>');
|
||||
if("" != text) {
|
||||
document.execCommand("insertHTML", false, text);
|
||||
} else {
|
||||
window.onPasteListener.onPaste();
|
||||
}
|
||||
});
|
||||
|
||||
requestContentFocus();
|
||||
requestContentFocus();
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
setupWhenContentEditable();
|
||||
function getStyle(dom, name) {
|
||||
return window.getComputedStyle(dom)[name];
|
||||
}
|
||||
|
||||
function customLinkgo(self) {
|
||||
var datas = self.dataset.datas;
|
||||
console.log(datas)
|
||||
window.OnLinkClickListener.onClick(datas);
|
||||
}
|
||||
|
||||
var typeClassList = [
|
||||
"community_article-container",
|
||||
"answer-container",
|
||||
"game-container"
|
||||
];
|
||||
|
||||
function removeDomByParent(curDom) {
|
||||
if (curDom.parentElement) {
|
||||
curDom.parentElement.removeChild(curDom);
|
||||
}
|
||||
}
|
||||
|
||||
window.addEventListener("load", function() {
|
||||
var EditorDom = document.querySelector("#editor");
|
||||
setupWhenContentEditable();
|
||||
|
||||
document.addEventListener("keydown", function(e) {
|
||||
var event = e || window.event;
|
||||
|
||||
if (event.keyCode === 8) {
|
||||
var s = document.getSelection();
|
||||
var r = s.getRangeAt(0);
|
||||
|
||||
if (r.startOffset === r.endOffset && r.endOffset === 0) {
|
||||
var preDOM = s.focusNode.previousElementSibling;
|
||||
|
||||
if (
|
||||
preDOM &&
|
||||
preDOM instanceof Element &&
|
||||
preDOM.nodeName === "IMG" &&
|
||||
getStyle(preDOM, "display") === "block"
|
||||
) {
|
||||
preDOM.parentElement.removeChild(preDOM);
|
||||
}
|
||||
}
|
||||
|
||||
var customDom = s.focusNode;
|
||||
if (customDom) {
|
||||
if (
|
||||
r.startContainer.nodeName.toLowerCase() === "blockquote" &&
|
||||
r.startOffset === 0
|
||||
) {
|
||||
RE.formatBlock();
|
||||
e.preventDefault();
|
||||
} else if (
|
||||
customDom.nodeName === "#text" &&
|
||||
customDom.previousElementSibling &&
|
||||
typeClassList.indexOf(customDom.previousElementSibling.className) >
|
||||
-1 &&
|
||||
r.startOffset === 1
|
||||
) {
|
||||
var needDeleteDom = customDom.previousElementSibling;
|
||||
needDeleteDom.insertAdjacentElement(
|
||||
"afterend",
|
||||
document.createElement("br")
|
||||
);
|
||||
} else if (
|
||||
customDom instanceof Element &&
|
||||
customDom.childNodes[s.focusOffset] &&
|
||||
customDom.childNodes[s.focusOffset].previousElementSibling &&
|
||||
typeClassList.indexOf(
|
||||
customDom.childNodes[s.focusOffset].previousElementSibling.className
|
||||
) > -1
|
||||
) {
|
||||
customDom =
|
||||
customDom.childNodes[s.focusOffset].previousElementSibling;
|
||||
customDom.parentElement.removeChild(customDom);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
document.addEventListener("keyup", function(e) {
|
||||
var event = e || window.event;
|
||||
if (event.keyCode === 13) {
|
||||
var s = document.getSelection();
|
||||
var curDom = s.focusNode;
|
||||
var preDom = curDom.previousElementSibling;
|
||||
|
||||
if (
|
||||
curDom.nodeName.toLowerCase() === "blockquote" &&
|
||||
preDom.nodeName.toLowerCase() === "blockquote"
|
||||
) {
|
||||
if (
|
||||
preDom.childNodes.length > 1 ||
|
||||
(preDom.childNodes.length === 1 &&
|
||||
preDom.childNodes[0].tagName !== "BR")
|
||||
) {
|
||||
curDom.style.marginTop = 0;
|
||||
preDom.style.marginBottom = 0;
|
||||
} else if (
|
||||
(curDom.childNodes.length === 0 ||
|
||||
(curDom.childNodes.length === 1 &&
|
||||
curDom.childNodes[0].tagName === "BR")) &&
|
||||
(preDom.childNodes.length === 0 ||
|
||||
(preDom.childNodes.length === 1 &&
|
||||
preDom.childNodes[0].tagName === "BR"))
|
||||
) {
|
||||
|
||||
removeDomByParent(curDom);
|
||||
|
||||
var startQuoteDom = preDom.previousElementSibling;
|
||||
startQuoteDom && startQuoteDom.nodeName.toLowerCase() === "blockquote"
|
||||
? (startQuoteDom.style.marginBottom = "10px")
|
||||
: null;
|
||||
|
||||
var range = document.createRange();
|
||||
range.selectNode(preDom);
|
||||
s.removeAllRanges();
|
||||
s.addRange(range);
|
||||
|
||||
RE.formatBlock();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
document.addEventListener("selectionchange", function(e) {
|
||||
var event = e || window.event;
|
||||
var targetDom = event.target.activeElement;
|
||||
if (targetDom.id === "editor" && targetDom.lastElementChild) {
|
||||
if (typeClassList.indexOf(targetDom.lastElementChild.className) > -1) {
|
||||
var brDom = document.createElement("br");
|
||||
EditorDom.appendChild(brDom);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
@ -1,16 +1,16 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta name="viewport" content="user-scalable=no">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<link rel="stylesheet" type="text/css" href="normalize.css">
|
||||
<link rel="stylesheet" type="text/css" href="style.css">
|
||||
<!--<link rel="stylesheet" type="text/css" href="https://resource.ghzs.com/css/halo_app.css">-->
|
||||
</head>
|
||||
<body>
|
||||
<div id="editor" contenteditable="true"></div>
|
||||
<div id="editor" contenteditable="false"></div>
|
||||
<script type="text/javascript" src="zepto.min.js"></script>
|
||||
<script type="text/javascript" src="rich_editor.js"></script>
|
||||
<script type="text/javascript" src="content.js"></script>
|
||||
<!--<script src="https://cdnjs.cloudflare.com/ajax/libs/vanilla-lazyload/10.15.0/lazyload.min.js"></script>-->
|
||||
<!--<script type="text/javascript" src="content.js"></script>-->
|
||||
<!--<script type="text/javascript" src="https://resource.ghzs.com/js/halo_app.js"></script>-->
|
||||
</body>
|
||||
</html>
|
||||
|
||||
BIN
app/src/main/assets/like.gif
Normal file
BIN
app/src/main/assets/like.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 15 KiB |
@ -14,6 +14,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
// alert("")
|
||||
|
||||
var RE = {};
|
||||
|
||||
RE.currentSelection = {
|
||||
@ -22,13 +24,39 @@ RE.currentSelection = {
|
||||
"endContainer": 0,
|
||||
"endOffset": 0};
|
||||
|
||||
var isDebug = false;
|
||||
try {
|
||||
isDebug = window.NativeCallBack.isNativeBuildDebug()
|
||||
} catch(error) {
|
||||
}
|
||||
|
||||
// 引用远端的JS 和 CSS
|
||||
var script = document.createElement("script")
|
||||
document.body.appendChild(script)
|
||||
if (isDebug) {
|
||||
script.src = "https://resource.ghzs.com/js/halo_app_test.js" + "?timestamp=" + Math.round(new Date().getTime() / 1000)
|
||||
} else {
|
||||
script.src = "https://resource.ghzs.com/js/halo.js" + "?timestamp=" + Math.round(new Date().getTime() / 1000 / 1000)
|
||||
}
|
||||
|
||||
var style = document.createElement("link")
|
||||
style.rel = "stylesheet"
|
||||
style.type = "text/css"
|
||||
if (isDebug) {
|
||||
style.href = "https://resource.ghzs.com/css/halo_app_test.css" + "?timestamp=" + Math.round(new Date().getTime() / 1000)
|
||||
} else {
|
||||
style.href = "https://resource.ghzs.com/css/halo.css" + "?timestamp=" + Math.round(new Date().getTime() / 1000 / 1000)
|
||||
}
|
||||
|
||||
document.head.appendChild(style)
|
||||
|
||||
RE.editor = document.getElementById('editor');
|
||||
|
||||
document.addEventListener("selectionchange", function() { RE.backuprange(); });
|
||||
|
||||
// Initializations
|
||||
RE.callback = function() {
|
||||
window.location.href = "re-callback://" + encodeURI(RE.getHtml());
|
||||
window.location.href = "re-callback://" + encodeURIComponent(RE.getHtml());
|
||||
}
|
||||
|
||||
RE.setHtml = function(contents) {
|
||||
@ -94,16 +122,8 @@ RE.setInputEnabled = function(inputEnabled) {
|
||||
RE.editor.contentEditable = String(inputEnabled);
|
||||
}
|
||||
|
||||
RE.setFocusByEnd = function() {
|
||||
//alert("111111")
|
||||
// var txt =RE.editor.createTextRange();
|
||||
// ("22222")
|
||||
// txt.moveStart('character',-1);
|
||||
// ("333333")
|
||||
// txt.collapse(true);
|
||||
// ("444444")
|
||||
// txt.select();
|
||||
// alert("ddddddd")
|
||||
RE.formatBlock = function() {
|
||||
document.execCommand('formatBlock', false, 'p');
|
||||
}
|
||||
|
||||
RE.undo = function() {
|
||||
@ -166,6 +186,7 @@ RE.setFontSize = function(fontSize){
|
||||
|
||||
RE.setHeading = function(heading) {
|
||||
document.execCommand('formatBlock', false, '<h'+heading+'>');
|
||||
RE.sendElementNameToNative()
|
||||
}
|
||||
|
||||
RE.setIndent = function() {
|
||||
@ -190,6 +211,9 @@ RE.setJustifyRight = function() {
|
||||
|
||||
RE.setBlockquote = function() {
|
||||
document.execCommand('formatBlock', false, '<blockquote>');
|
||||
// var blockId = window.getSelection().focusNode.parentNode;
|
||||
// $(blockId).addClass("haloBlock")
|
||||
RE.sendElementNameToNative()
|
||||
}
|
||||
|
||||
RE.insertImage = function(url) {
|
||||
@ -197,19 +221,17 @@ RE.insertImage = function(url) {
|
||||
RE.insertHTML(html);
|
||||
}
|
||||
|
||||
//RE.lazyLoad = function() {
|
||||
// var myLazyLoad = new LazyLoad({
|
||||
// elements_selector: ".lazy"
|
||||
// })
|
||||
//}
|
||||
|
||||
// 替换成缩略图
|
||||
RE.replaceTbImage = function(imgRuleFlag, gifRuleFlag) {
|
||||
var imgs = document.getElementsByTagName("img");
|
||||
var index = 0
|
||||
for (var i = 0; i < imgs.length; i++) {
|
||||
var img = imgs[i];
|
||||
var imageClassName = img.className;
|
||||
// console.log(imageClassName)
|
||||
if (imageClassName == "image-link") continue;
|
||||
if(img.src.indexOf("?") > 0) continue;
|
||||
|
||||
// console.log(i)
|
||||
var tbImg
|
||||
if(img.src.indexOf(".gif") > 0) {
|
||||
tbImg = img.src + gifRuleFlag
|
||||
@ -220,13 +242,23 @@ RE.replaceTbImage = function(imgRuleFlag, gifRuleFlag) {
|
||||
img.style.cssText = "max-width: 60%; display:block; margin:15px auto; height: auto;"
|
||||
img.src = tbImg;
|
||||
|
||||
if (i == 0) {
|
||||
if (index == 0) {
|
||||
var bigImg = document.createElement('img');
|
||||
bigImg.src = "file:///android_asset/web_load_dfimg_icon.png";
|
||||
bigImg.style.cssText = "max-width: 20%; margin:15px 0 0 0; height: auto;"
|
||||
img.parentNode.insertBefore(bigImg, img.parentNode.childNodes[0]);
|
||||
i++;
|
||||
|
||||
if(img.parentNode != null) {
|
||||
img.parentNode.style.cssText += "text-align: left;"
|
||||
}
|
||||
|
||||
if(img.parentNode != null && img.parentNode.parentNode != null) {
|
||||
img.parentNode.parentNode.style.cssText += "text-align: left;"
|
||||
}
|
||||
|
||||
}
|
||||
index ++;
|
||||
}
|
||||
}
|
||||
|
||||
@ -235,6 +267,8 @@ RE.replaceAllDfImage = function(imgRuleFlag, gifRuleFlag) {
|
||||
var imgs = document.getElementsByTagName("img");
|
||||
for (var i = 0; i < imgs.length; i++) {
|
||||
var img = imgs[i];
|
||||
var imageClassName = img.className;
|
||||
if (imageClassName == "image-link") continue;
|
||||
if(img.src.indexOf("web_load_dfimg_icon") > 0) {
|
||||
img.parentNode.removeChild(img.parentNode.childNodes[0]);
|
||||
i--;
|
||||
@ -259,6 +293,8 @@ RE.hideShowBigPic = function() {
|
||||
var j = 0;
|
||||
for (var i = 0; i < imgs.length; i++) {
|
||||
var img = imgs[i];
|
||||
var imageClassName = img.className;
|
||||
if (imageClassName == "image-link") continue;
|
||||
if(img.src.indexOf(",thumbnail") > 0 && img.src.indexOf(".gif") == -1) {
|
||||
j++;
|
||||
}
|
||||
@ -268,6 +304,8 @@ RE.hideShowBigPic = function() {
|
||||
var imgs = document.getElementsByTagName("img");
|
||||
for (var i = 0; i < imgs.length; i++) {
|
||||
var img = imgs[i];
|
||||
var imageClassName = img.className;
|
||||
if (imageClassName == "image-link") continue;
|
||||
if(img.src.indexOf("web_load_dfimg_icon") > 0) {
|
||||
img.parentNode.removeChild(img.parentNode.childNodes[0]);
|
||||
break;
|
||||
@ -280,6 +318,8 @@ RE.replaceDfImageByUrl = function(imgUrl, imgRuleFlag, gifRuleFlag) {
|
||||
var imgs = document.getElementsByTagName("img");
|
||||
for (var i = 0; i < imgs.length; i++) {
|
||||
var img = imgs[i];
|
||||
var imageClassName = img.className;
|
||||
if (imageClassName == "image-link") continue;
|
||||
if (img.src.indexOf(imgUrl) != -1) {
|
||||
img.style.cssText = "max-width: 100%; display:block; margin:8px auto; height: auto;"
|
||||
if(img.src.indexOf(".gif") > 0) {
|
||||
@ -296,6 +336,8 @@ RE.ImageClickListener = function() {
|
||||
var imgs = document.getElementsByTagName("img");
|
||||
for (var i = 0; i < imgs.length; i++) {
|
||||
var img = imgs[i];
|
||||
var imageClassName = img.className;
|
||||
if (imageClassName == "image-link") continue;
|
||||
window.imagelistener.imageArr(img.src);
|
||||
img.onclick = function() {
|
||||
window.imagelistener.imageClick(this.src);
|
||||
@ -348,12 +390,16 @@ RE.backuprange = function(){
|
||||
}
|
||||
|
||||
RE.restorerange = function(){
|
||||
var selection = window.getSelection();
|
||||
selection.removeAllRanges();
|
||||
var range = document.createRange();
|
||||
range.setStart(RE.currentSelection.startContainer, RE.currentSelection.startOffset);
|
||||
range.setEnd(RE.currentSelection.endContainer, RE.currentSelection.endOffset);
|
||||
selection.addRange(range);
|
||||
try {
|
||||
var selection = window.getSelection();
|
||||
selection.removeAllRanges();
|
||||
var range = document.createRange();
|
||||
range.setStart(RE.currentSelection.startContainer, RE.currentSelection.startOffset);
|
||||
range.setEnd(RE.currentSelection.endContainer, RE.currentSelection.endOffset);
|
||||
selection.addRange(range);
|
||||
} catch(error) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
RE.enabledEditingItems = function(e) {
|
||||
@ -423,12 +469,145 @@ RE.removeFormat = function() {
|
||||
document.execCommand('removeFormat', false, null);
|
||||
}
|
||||
|
||||
RE.insertCustomStyleLink = function(data) {
|
||||
var entity = JSON.parse(data)
|
||||
var html = "<br/><div class='"+ entity.type +"-container'>\n" +
|
||||
" <a class='"+ entity.type +"' href=\"javascript:void(0);\" contenteditable=\"false\" onclick=\"customLinkgo(this)\" data-datas='"+ data +"'>\n" +
|
||||
" <div class='flex-container'>\n" +
|
||||
" <div class='gh-internal-content img-left'>\n" +
|
||||
" <img class = \"image-link\" src='"+ entity.icon +"' />\n" +
|
||||
" </div>\n" +
|
||||
" <div class='gh-internal-content content-right'>\n" +
|
||||
" <p class='content-title'>"+ entity.title +"</p>\n" +
|
||||
" <p class='contents'>"+ entity.brief +"</p>\n" +
|
||||
" </div>\n" +
|
||||
" </div>\n" +
|
||||
" </a>\n" +
|
||||
" </div><br/>"
|
||||
var tags = "", gameHtml = ""
|
||||
if (entity.tags != null) {
|
||||
for (var i = 0; i < entity.tags.length; i++) {
|
||||
tags += "<label>"+ entity.tags[i]+"</label>"
|
||||
}
|
||||
|
||||
gameHtml = "<br/><div class='"+ entity.type +"-container'>\n" +
|
||||
" <a class='"+ entity.type +"' href=\"javascript:void(0);\" contenteditable=\"false\" onclick=\"customLinkgo(this)\" data-datas='"+ data +"'>\n" +
|
||||
" <div class='flex-container'>\n" +
|
||||
" <div class='gh-internal-content img-left'>\n" +
|
||||
" <img class='image-link' src='"+ entity.icon +"' />\n" +
|
||||
" </div>\n" +
|
||||
" <div class='gh-internal-content content-right'>\n" +
|
||||
" <p class='content-title'>"+ entity.title +"</p>\n" +
|
||||
" <p class='tags'>"+ tags +"</p>\n" +
|
||||
" </div>\n" +
|
||||
" </div>\n" +
|
||||
" </a></div><br/>"
|
||||
}
|
||||
|
||||
switch(entity.type) {
|
||||
case "answer":
|
||||
document.execCommand("insertHTML",false, html);
|
||||
break
|
||||
case "community_article":
|
||||
document.execCommand("insertHTML",false, html);
|
||||
break
|
||||
case "game":
|
||||
document.execCommand("insertHTML",false, gameHtml);
|
||||
break
|
||||
}
|
||||
RE.callback();
|
||||
}
|
||||
|
||||
RE.showLinkStyle = function() {
|
||||
var answerElement = document.getElementsByClassName("answer-container");
|
||||
for (var i=0;i<answerElement.length;i+=1){
|
||||
answerElement[i].style.display = 'inline';
|
||||
}
|
||||
var articleElement = document.getElementsByClassName("community_article-container");
|
||||
for (var i=0;i<articleElement.length;i+=1){
|
||||
articleElement[i].style.display = 'inline';
|
||||
}
|
||||
var gameElement = document.getElementsByClassName("game-container");
|
||||
for (var i=0;i<gameElement.length;i+=1){
|
||||
gameElement[i].style.display = 'inline';
|
||||
}
|
||||
}
|
||||
|
||||
RE.hideLinkStyle = function() {
|
||||
var answerElement = document.getElementsByClassName("answer-container");
|
||||
for (var i=0;i<answerElement.length;i+=1){
|
||||
answerElement[i].style.display = 'none';
|
||||
}
|
||||
var articleElement = document.getElementsByClassName("community_article-container");
|
||||
for (var i=0;i<articleElement.length;i+=1){
|
||||
articleElement[i].style.display = 'none';
|
||||
}
|
||||
var gameElement = document.getElementsByClassName("game-container");
|
||||
for (var i=0;i<gameElement.length;i+=1){
|
||||
gameElement[i].style.display = 'none';
|
||||
}
|
||||
}
|
||||
|
||||
// Event Listeners
|
||||
RE.editor.addEventListener("input", RE.callback);
|
||||
|
||||
RE.editor.addEventListener("keyup", function(e) {
|
||||
var KEY_LEFT = 37, KEY_RIGHT = 39;
|
||||
if (e.which == KEY_LEFT || e.which == KEY_RIGHT) {
|
||||
RE.enabledEditingItems(e);
|
||||
}
|
||||
RE.sendElementNameToNative()
|
||||
});
|
||||
RE.editor.addEventListener("click", RE.enabledEditingItems);
|
||||
|
||||
RE.editor.addEventListener("click", function(e) {
|
||||
RE.enabledEditingItems
|
||||
RE.sendElementNameToNative()
|
||||
var s = document.getSelection()
|
||||
var isNeedRemoveR = RE.recursion(e.target)
|
||||
if (isNeedRemoveR && s.rangeCount) {
|
||||
s.removeAllRanges()
|
||||
}
|
||||
});
|
||||
|
||||
document.addEventListener("selectionchange", function(e) {
|
||||
RE.sendElementNameToNative()
|
||||
});
|
||||
|
||||
RE.recursion = function(dom) {
|
||||
var parenDom = dom.parentElement
|
||||
if (parenDom && parenDom instanceof Element &&
|
||||
typeClassList.indexOf(parenDom.className) > -1) {
|
||||
return parenDom
|
||||
} else if(parenDom && parenDom instanceof Element &&
|
||||
typeClassList.indexOf(parenDom.className) === -1 && parenDom.nodeName !== 'BODY') {
|
||||
return RE.recursion(parenDom)
|
||||
} else {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
// 返回组件标签 多个标签以"空格"划分
|
||||
RE.sendElementNameToNative = function() {
|
||||
if (window.getSelection) {
|
||||
var selection = window.getSelection()
|
||||
if (selection.rangeCount > 0) {
|
||||
var range = selection.getRangeAt(0);
|
||||
var container = range.startContainer;
|
||||
var elements = " " + container.localName + " ";
|
||||
var parentElement;
|
||||
while(true) {
|
||||
if(parentElement != null) {
|
||||
parentElement = parentElement.parentElement
|
||||
} else {
|
||||
parentElement = container.parentElement
|
||||
}
|
||||
if (parentElement == null || parentElement.localName == null) {
|
||||
break;
|
||||
}
|
||||
elements = elements + " " + parentElement.localName + " "
|
||||
}
|
||||
// console.log(elements)
|
||||
window.OnCursorChangeListener.onElements(elements);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,53 +0,0 @@
|
||||
package com.gc.materialdesign.views;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.RelativeLayout;
|
||||
|
||||
public class CustomView extends RelativeLayout {
|
||||
|
||||
|
||||
final static String MATERIALDESIGNXML = "http://schemas.android.com/apk/res-auto";
|
||||
final static String ANDROIDXML = "http://schemas.android.com/apk/res/android";
|
||||
|
||||
final int disabledBackgroundColor = Color.parseColor("#E2E2E2");
|
||||
// Indicate if user touched this view the last time
|
||||
public boolean isLastTouch = false;
|
||||
int beforeBackground;
|
||||
boolean animation = false;
|
||||
|
||||
public CustomView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEnabled(boolean enabled) {
|
||||
super.setEnabled(enabled);
|
||||
if (enabled)
|
||||
setBackgroundColor(beforeBackground);
|
||||
else
|
||||
setBackgroundColor(disabledBackgroundColor);
|
||||
invalidate();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDraw(Canvas canvas) {
|
||||
super.onDraw(canvas);
|
||||
if (animation)
|
||||
invalidate();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onAnimationStart() {
|
||||
super.onAnimationStart();
|
||||
animation = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onAnimationEnd() {
|
||||
super.onAnimationEnd();
|
||||
animation = false;
|
||||
}
|
||||
}
|
||||
@ -1,174 +0,0 @@
|
||||
package com.gc.materialdesign.views;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.PorterDuffXfermode;
|
||||
import android.graphics.RectF;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.util.AttributeSet;
|
||||
|
||||
public class ProgressBarCircularIndeterminate extends CustomView {
|
||||
|
||||
final static String ANDROIDXML = "http://schemas.android.com/apk/res/android";
|
||||
|
||||
int backgroundColor = Color.parseColor("#1E88E5");
|
||||
float radius1 = 0;
|
||||
float radius2 = 0;
|
||||
int cont = 0;
|
||||
boolean firstAnimationOver = false;
|
||||
int arcD = 1;
|
||||
int arcO = 0;
|
||||
float rotateAngle = 0;
|
||||
int limite = 0;
|
||||
|
||||
public ProgressBarCircularIndeterminate(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
setAttributes(attrs);
|
||||
}
|
||||
|
||||
// Set atributtes of XML to View
|
||||
protected void setAttributes(AttributeSet attrs) {
|
||||
|
||||
setMinimumHeight(Utils.dpToPx(32, getResources()));
|
||||
setMinimumWidth(Utils.dpToPx(32, getResources()));
|
||||
|
||||
// Set background Color
|
||||
// Color by resource
|
||||
int bacgroundColor = attrs.getAttributeResourceValue(ANDROIDXML, "background", -1);
|
||||
if (bacgroundColor != -1) {
|
||||
setBackgroundColor(ContextCompat.getColor(getContext(), bacgroundColor));
|
||||
} else {
|
||||
// Color by hexadecimal
|
||||
int background = attrs.getAttributeIntValue(ANDROIDXML, "background", -1);
|
||||
if (background != -1) {
|
||||
setBackgroundColor(background);
|
||||
} else {
|
||||
setBackgroundColor(Color.parseColor("#1E88E5"));
|
||||
}
|
||||
}
|
||||
|
||||
setMinimumHeight(Utils.dpToPx(3, getResources()));
|
||||
|
||||
}
|
||||
|
||||
// Set color of background
|
||||
public void setBackgroundColor(int color) {
|
||||
super.setBackgroundColor(ContextCompat.getColor(getContext(), android.R.color.transparent));
|
||||
if (isEnabled()) {
|
||||
beforeBackground = backgroundColor;
|
||||
}
|
||||
this.backgroundColor = color;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDraw(Canvas canvas) {
|
||||
super.onDraw(canvas);
|
||||
if (!firstAnimationOver) {
|
||||
drawFirstAnimation(canvas);
|
||||
}
|
||||
if (cont > 0) {
|
||||
drawSecondAnimation(canvas);
|
||||
}
|
||||
invalidate();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw first animation of view
|
||||
*
|
||||
* @param canvas
|
||||
*/
|
||||
private void drawFirstAnimation(Canvas canvas) {
|
||||
if (radius1 < getWidth() / 2) {
|
||||
Paint paint = new Paint();
|
||||
paint.setAntiAlias(true);
|
||||
paint.setColor(makePressColor());
|
||||
radius1 = (radius1 >= getWidth() / 2) ? (float) getWidth() / 2 : radius1 + 1;
|
||||
canvas.drawCircle(getWidth() / 2, getHeight() / 2, radius1, paint);
|
||||
} else {
|
||||
Bitmap bitmap = Bitmap.createBitmap(canvas.getWidth(), canvas.getHeight(), Bitmap.Config.ARGB_8888);
|
||||
Canvas temp = new Canvas(bitmap);
|
||||
Paint paint = new Paint();
|
||||
paint.setAntiAlias(true);
|
||||
paint.setColor(makePressColor());
|
||||
temp.drawCircle(getWidth() / 2, getHeight() / 2, getHeight() / 2, paint);
|
||||
Paint transparentPaint = new Paint();
|
||||
transparentPaint.setAntiAlias(true);
|
||||
transparentPaint.setColor(ContextCompat.getColor(getContext(), android.R.color.transparent));
|
||||
transparentPaint.setXfermode(new PorterDuffXfermode(
|
||||
PorterDuff.Mode.CLEAR));
|
||||
if (cont >= 50) {
|
||||
radius2 = (radius2 >= getWidth() / 2) ? (float) getWidth() / 2 : radius2 + 1;
|
||||
} else {
|
||||
radius2 = (radius2 >= getWidth() / 2 - Utils.dpToPx(4, getResources())) ?
|
||||
(float) getWidth() / 2 - Utils.dpToPx(4, getResources()) : radius2 + 1;
|
||||
}
|
||||
temp.drawCircle(getWidth() / 2, getHeight() / 2, radius2, transparentPaint);
|
||||
canvas.drawBitmap(bitmap, 0, 0, new Paint());
|
||||
if (radius2 >= getWidth() / 2 - Utils.dpToPx(4, getResources())) {
|
||||
cont++;
|
||||
}
|
||||
if (radius2 >= getWidth() / 2) {
|
||||
firstAnimationOver = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw second animation of view
|
||||
*
|
||||
* @param canvas
|
||||
*/
|
||||
private void drawSecondAnimation(Canvas canvas) {
|
||||
if (arcO == limite) {
|
||||
arcD += 6;
|
||||
}
|
||||
if (arcD >= 290 || arcO > limite) {
|
||||
arcO += 6;
|
||||
arcD -= 6;
|
||||
}
|
||||
if (arcO > limite + 290) {
|
||||
limite = arcO;
|
||||
arcO = limite;
|
||||
arcD = 1;
|
||||
}
|
||||
rotateAngle += 4;
|
||||
canvas.rotate(rotateAngle, getWidth() / 2, getHeight() / 2);
|
||||
|
||||
Bitmap bitmap = Bitmap.createBitmap(canvas.getWidth(), canvas.getHeight(), Bitmap.Config.ARGB_8888);
|
||||
Canvas temp = new Canvas(bitmap);
|
||||
Paint paint = new Paint();
|
||||
paint.setAntiAlias(true);
|
||||
paint.setColor(backgroundColor);
|
||||
// temp.drawARGB(0, 0, 0, 255);
|
||||
temp.drawArc(new RectF(0, 0, getWidth(), getHeight()), arcO, arcD, true, paint);
|
||||
Paint transparentPaint = new Paint();
|
||||
transparentPaint.setAntiAlias(true);
|
||||
transparentPaint.setColor(ContextCompat.getColor(getContext(), android.R.color.transparent));
|
||||
transparentPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR));
|
||||
temp.drawCircle(getWidth() / 2, getHeight() / 2, (getWidth() / 2)
|
||||
- Utils.dpToPx(4, getResources()), transparentPaint);
|
||||
|
||||
canvas.drawBitmap(bitmap, 0, 0, new Paint());
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a dark color to ripple effect
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
protected int makePressColor() {
|
||||
int r = (this.backgroundColor >> 16) & 0xFF;
|
||||
int g = (this.backgroundColor >> 8) & 0xFF;
|
||||
int b = (this.backgroundColor >> 0) & 0xFF;
|
||||
// r = (r+90 > 245) ? 245 : r+90;
|
||||
// g = (g+90 > 245) ? 245 : g+90;
|
||||
// b = (b+90 > 245) ? 245 : b+90;
|
||||
return Color.argb(128, r, g, b);
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,34 +0,0 @@
|
||||
package com.gc.materialdesign.views;
|
||||
|
||||
import android.content.res.Resources;
|
||||
import android.util.TypedValue;
|
||||
import android.view.View;
|
||||
|
||||
public class Utils {
|
||||
|
||||
|
||||
/**
|
||||
* Convert Dp to Pixel
|
||||
*/
|
||||
public static int dpToPx(float dp, Resources resources) {
|
||||
float px = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, resources.getDisplayMetrics());
|
||||
return (int) px;
|
||||
}
|
||||
|
||||
public static int getRelativeTop(View myView) {
|
||||
// if (myView.getParent() == myView.getRootView())
|
||||
if (myView.getId() == android.R.id.content)
|
||||
return myView.getTop();
|
||||
else
|
||||
return myView.getTop() + getRelativeTop((View) myView.getParent());
|
||||
}
|
||||
|
||||
public static int getRelativeLeft(View myView) {
|
||||
// if (myView.getParent() == myView.getRootView())
|
||||
if (myView.getId() == android.R.id.content)
|
||||
return myView.getLeft();
|
||||
else
|
||||
return myView.getLeft() + getRelativeLeft((View) myView.getParent());
|
||||
}
|
||||
|
||||
}
|
||||
@ -75,7 +75,7 @@ public class AppUncaughtHandler implements UncaughtExceptionHandler {
|
||||
// 保存log到本地
|
||||
public static void saveLocalLog(Context context, Throwable ex) {
|
||||
String errorMsg = Log.getStackTraceString(ex);
|
||||
Config.setExceptionMsg(context, errorMsg);
|
||||
Config.setExceptionMsg(errorMsg);
|
||||
|
||||
// 保存到本地
|
||||
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss", Locale.getDefault());
|
||||
|
||||
@ -1,20 +1,24 @@
|
||||
package com.gh.base;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.arch.lifecycle.Lifecycle;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.text.TextUtils;
|
||||
import android.view.Window;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.lifecycle.Lifecycle;
|
||||
|
||||
import com.gh.common.constant.Constants;
|
||||
import com.gh.common.util.DataUtils;
|
||||
import com.gh.common.util.DialogUtils;
|
||||
import com.gh.common.util.PackageUtils;
|
||||
import com.gh.common.util.RunningUtils;
|
||||
import com.gh.common.util.ShareUtils;
|
||||
import com.gh.common.util.StringUtils;
|
||||
import com.gh.gamecenter.BuildConfig;
|
||||
import com.gh.gamecenter.LoginActivity;
|
||||
import com.gh.gamecenter.R;
|
||||
import com.gh.gamecenter.SuggestionActivity;
|
||||
@ -42,6 +46,7 @@ import static com.gh.common.util.EntranceUtils.KEY_ENTRANCE;
|
||||
|
||||
public abstract class BaseActivity extends BaseToolBarActivity implements EasyPermissions.PermissionCallbacks {
|
||||
|
||||
@NonNull
|
||||
protected String mEntrance;
|
||||
|
||||
private boolean mIsPause;
|
||||
@ -100,6 +105,13 @@ public abstract class BaseActivity extends BaseToolBarActivity implements EasyPe
|
||||
EventBus.getDefault().register(this);
|
||||
ButterKnife.bind(this);
|
||||
mEntrance = getIntent().getStringExtra(KEY_ENTRANCE);
|
||||
if (TextUtils.isEmpty(mEntrance)) {
|
||||
mEntrance = Constants.ENTRANCE_UNKNOWN;
|
||||
}
|
||||
|
||||
if (BuildConfig.DEBUG) {
|
||||
Utils.log("ACTIVITY_ENTRANCE -> " + mEntrance);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -158,13 +170,13 @@ public abstract class BaseActivity extends BaseToolBarActivity implements EasyPe
|
||||
try {
|
||||
JSONObject object = new JSONObject(showDialog.getPath());
|
||||
JSONObject device = object.getJSONObject("device");
|
||||
String manufacturer = device.getString("manufacturer");
|
||||
String model = device.getString("model");
|
||||
DialogUtils.showAlertDialog(this, "你的账号已在另外一台设备登录"
|
||||
, StringUtils.buildString("(", manufacturer, " - ", model, ")")
|
||||
, StringUtils.buildString("(", model, ")")
|
||||
, "知道了", "重新登录"
|
||||
, null
|
||||
, () -> startActivity(LoginActivity.getIntent(BaseActivity.this))
|
||||
, () -> startActivity(LoginActivity.getIntent(BaseActivity.this,
|
||||
"你的账号已在另外一台设备登录多设备-重新登录"))
|
||||
);
|
||||
mBaseHandler.postDelayed(() -> mIsExistLogoutDialog = false, 5000);
|
||||
} catch (JSONException e) {
|
||||
@ -208,4 +220,16 @@ public abstract class BaseActivity extends BaseToolBarActivity implements EasyPe
|
||||
public void onPermissionsGranted(int requestCode, List<String> perms) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static String mergeEntranceAndPath(String entrance, String path) {
|
||||
if (TextUtils.isEmpty(entrance) && TextUtils.isEmpty(path)) return "";
|
||||
if (TextUtils.isEmpty(entrance) && !TextUtils.isEmpty(path)) {
|
||||
return StringUtils.buildString("(", path, ")");
|
||||
}
|
||||
if (!TextUtils.isEmpty(entrance) && TextUtils.isEmpty(path)) {
|
||||
return entrance;
|
||||
}
|
||||
return StringUtils.buildString(entrance, "+(", path, ")");
|
||||
}
|
||||
}
|
||||
|
||||
112
app/src/main/java/com/gh/base/BaseActivity_TabLayout.java
Normal file
112
app/src/main/java/com/gh/base/BaseActivity_TabLayout.java
Normal file
@ -0,0 +1,112 @@
|
||||
package com.gh.base;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import androidx.annotation.Nullable;
|
||||
import com.google.android.material.tabs.TabLayout;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
import android.view.View;
|
||||
|
||||
import com.gh.base.adapter.FragmentAdapter;
|
||||
import com.gh.common.view.TabIndicatorView;
|
||||
import com.gh.gamecenter.R;
|
||||
import com.lightgame.view.NoScrollableViewPager;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import butterknife.BindView;
|
||||
|
||||
/**
|
||||
* Created by khy on 15/03/18.
|
||||
*/
|
||||
|
||||
public abstract class BaseActivity_TabLayout extends BaseActivity implements ViewPager.OnPageChangeListener {
|
||||
|
||||
public static final String PAGE_INDEX = "PAGE_INDEX";
|
||||
|
||||
@BindView(R.id.activity_tab_layout)
|
||||
protected TabLayout mTabLayout;
|
||||
@BindView(R.id.activity_view_pager)
|
||||
protected NoScrollableViewPager mViewPager;
|
||||
@BindView(R.id.activity_tab_indicator)
|
||||
protected TabIndicatorView mTabIndicatorView;
|
||||
|
||||
protected List<Fragment> mFragmentsList;
|
||||
|
||||
protected List<String> mTabTitleList;
|
||||
|
||||
protected int mCheckedIndex = 0;
|
||||
|
||||
protected abstract void initFragmentList(List<Fragment> fragments);
|
||||
|
||||
protected abstract void initTabTitleList(List<String> tabTitleList);
|
||||
|
||||
protected int provideIndicatorWidth() {
|
||||
return 65;
|
||||
}
|
||||
|
||||
protected View provideTabView(int position, String tabTitle) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_tablayout_viewpager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
List<Fragment> fragments = getSupportFragmentManager().getFragments();
|
||||
if (fragments != null) {
|
||||
for (Fragment fragment : fragments) {
|
||||
fragment.onActivityResult(requestCode, resultCode, data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
if (getIntent() != null) mCheckedIndex = getIntent().getIntExtra(PAGE_INDEX, 0);
|
||||
mFragmentsList = new ArrayList<>();
|
||||
initFragmentList(mFragmentsList);
|
||||
mTabTitleList = new ArrayList<>();
|
||||
initTabTitleList(mTabTitleList);
|
||||
|
||||
mViewPager.setOffscreenPageLimit(mFragmentsList.size());
|
||||
mViewPager.addOnPageChangeListener(this);
|
||||
mViewPager.setAdapter(new FragmentAdapter(getSupportFragmentManager(), mFragmentsList, mTabTitleList));
|
||||
mViewPager.setCurrentItem(mCheckedIndex);
|
||||
mTabLayout.setupWithViewPager(mViewPager);
|
||||
mTabIndicatorView.setupWithTabLayout(mTabLayout);
|
||||
mTabIndicatorView.setupWithViewPager(mViewPager);
|
||||
mTabIndicatorView.setIndicatorWidth(provideIndicatorWidth());
|
||||
|
||||
for (int i = 0; i < mTabLayout.getTabCount(); i++) {
|
||||
TabLayout.Tab tab = mTabLayout.getTabAt(i);
|
||||
if (tab == null) continue;
|
||||
View tabView = provideTabView(i, tab.getText() != null ? tab.getText().toString() : "");
|
||||
if (tabView == null) continue;
|
||||
tab.setCustomView(tabView);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageSelected(int position) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageScrollStateChanged(int state) {
|
||||
|
||||
}
|
||||
}
|
||||
@ -1,6 +1,6 @@
|
||||
package com.gh.base;
|
||||
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import android.view.View;
|
||||
|
||||
import butterknife.ButterKnife;
|
||||
|
||||
236
app/src/main/java/com/gh/base/BaseRichEditorActivity.kt
Normal file
236
app/src/main/java/com/gh/base/BaseRichEditorActivity.kt
Normal file
@ -0,0 +1,236 @@
|
||||
package com.gh.base
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.app.Activity
|
||||
import android.content.ClipboardManager
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.text.TextUtils
|
||||
import android.view.View
|
||||
import android.webkit.JavascriptInterface
|
||||
import butterknife.OnClick
|
||||
import com.gh.common.view.RichEditor
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.entity.GameEntity
|
||||
import com.gh.gamecenter.qa.editor.GameActivity
|
||||
import com.gh.gamecenter.qa.editor.InsertAnswerWrapperActivity
|
||||
import com.gh.gamecenter.qa.editor.InsertArticleWrapperActivity
|
||||
import com.gh.gamecenter.qa.entity.AnswerEntity
|
||||
import com.gh.gamecenter.qa.entity.ArticleEntity
|
||||
import com.gh.gamecenter.qa.entity.EditorInsertEntity
|
||||
import com.halo.assistant.HaloApp
|
||||
import com.lightgame.utils.Utils
|
||||
import com.lightgame.view.CheckableImageView
|
||||
import kotterknife.bindView
|
||||
|
||||
abstract class BaseRichEditorActivity : BaseActivity() {
|
||||
|
||||
val mRichEditor by bindView<RichEditor>(R.id.rich_editor)
|
||||
|
||||
private val mEditorFont by bindView<CheckableImageView>(R.id.editor_font)
|
||||
private val mEditorLink by bindView<CheckableImageView>(R.id.editor_link)
|
||||
private val mEditorParagraph by bindView<CheckableImageView>(R.id.editor_paragraph)
|
||||
private val mEditorFontBold by bindView<CheckableImageView>(R.id.editor_font_bold)
|
||||
private val mEditorFontItalic by bindView<CheckableImageView>(R.id.editor_font_italic)
|
||||
private val mEditorFontStrikeThrough by bindView<CheckableImageView>(R.id.editor_font_strikethrough)
|
||||
private val mEditorParagraphH1 by bindView<CheckableImageView>(R.id.editor_paragraph_h1)
|
||||
private val mEditorParagraphH2 by bindView<CheckableImageView>(R.id.editor_paragraph_h2)
|
||||
private val mEditorParagraphH3 by bindView<CheckableImageView>(R.id.editor_paragraph_h3)
|
||||
private val mEditorParagraphH4 by bindView<CheckableImageView>(R.id.editor_paragraph_h4)
|
||||
private val mEditorParagraphQuote by bindView<CheckableImageView>(R.id.editor_paragraph_quote)
|
||||
private val mEditorFontContainer by bindView<View>(R.id.editor_font_container)
|
||||
private val mEditorParagraphContainer by bindView<View>(R.id.editor_paragraph_container)
|
||||
private val mEditorLinkContainer by bindView<View>(R.id.editor_link_container)
|
||||
private val mEditorInsertDetail by bindView<View>(R.id.editor_insert_detail)
|
||||
|
||||
private var mCurrentParagraphStyle = ""
|
||||
|
||||
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
super.onActivityResult(requestCode, resultCode, data)
|
||||
if (resultCode != Activity.RESULT_OK) return
|
||||
var insertData: EditorInsertEntity? = null
|
||||
when (requestCode) {
|
||||
INSERT_ANSWER_CODE -> {
|
||||
val answer = data?.getParcelableExtra<AnswerEntity>(AnswerEntity::class.java.simpleName)
|
||||
if (answer != null) insertData = EditorInsertEntity.transform(answer)
|
||||
}
|
||||
INSERT_ARTICLE_CODE -> {
|
||||
val article = data?.getParcelableExtra<ArticleEntity>(ArticleEntity::class.java.simpleName)
|
||||
if (article != null) insertData = EditorInsertEntity.transform(article)
|
||||
}
|
||||
INSERT_GAME_CODE -> {
|
||||
val game = data?.getParcelableExtra<GameEntity>(GameEntity::class.java.simpleName)
|
||||
if (game != null) insertData = EditorInsertEntity.transform(game)
|
||||
}
|
||||
}
|
||||
|
||||
mRichEditor.insertCustomStyleLink(insertData)
|
||||
}
|
||||
|
||||
@SuppressLint("AddJavascriptInterface")
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
mRichEditor.setPadding(20, 15, 20, 15)
|
||||
// 防止个别手机在Js里无法获取粘贴内容
|
||||
mRichEditor.addJavascriptInterface(OnPasteListener(), "onPasteListener")
|
||||
mRichEditor.addJavascriptInterface(OnCursorChangeListener(), "OnCursorChangeListener")
|
||||
mRichEditor.setInputEnabled(true)
|
||||
}
|
||||
|
||||
@OnClick(R.id.editor_image, R.id.editor_font, R.id.editor_link, R.id.editor_paragraph,
|
||||
R.id.editor_font_bold, R.id.editor_font_italic, R.id.editor_font_strikethrough,
|
||||
R.id.editor_paragraph_h1, R.id.editor_paragraph_h2, R.id.editor_paragraph_h3,
|
||||
R.id.editor_paragraph_h4, R.id.editor_font_container, R.id.editor_paragraph_container,
|
||||
R.id.editor_paragraph_quote, R.id.editor_link_answer, R.id.editor_link_article,
|
||||
R.id.editor_link_game)
|
||||
fun onRichClick(view: View) {
|
||||
when (view.id) {
|
||||
R.id.editor_font -> {
|
||||
mEditorFont.isChecked = !mEditorFont.isChecked
|
||||
mEditorParagraph.isChecked = false
|
||||
mEditorLink.isChecked = false
|
||||
mEditorFontContainer.visibility = if (mEditorFont.isChecked) View.VISIBLE else View.GONE
|
||||
mEditorParagraphContainer.visibility = if (!mEditorFont.isChecked) View.VISIBLE else View.GONE
|
||||
mEditorLinkContainer.visibility = if (!mEditorFont.isChecked) View.VISIBLE else View.GONE
|
||||
mEditorInsertDetail.visibility = mEditorFontContainer.visibility
|
||||
}
|
||||
R.id.editor_paragraph -> {
|
||||
mEditorParagraph.isChecked = !mEditorParagraph.isChecked
|
||||
mEditorFont.isChecked = false
|
||||
mEditorLink.isChecked = false
|
||||
mEditorParagraphContainer.visibility = if (mEditorParagraph.isChecked) View.VISIBLE else View.GONE
|
||||
mEditorFontContainer.visibility = if (!mEditorParagraph.isChecked) View.VISIBLE else View.GONE
|
||||
mEditorLinkContainer.visibility = if (!mEditorParagraph.isChecked) View.VISIBLE else View.GONE
|
||||
mEditorInsertDetail.visibility = mEditorParagraphContainer.visibility
|
||||
}
|
||||
R.id.editor_link -> {
|
||||
mEditorLink.isChecked = !mEditorLink.isChecked
|
||||
mEditorFont.isChecked = false
|
||||
mEditorParagraph.isChecked = false
|
||||
mEditorLinkContainer.visibility = if (mEditorLink.isChecked) View.VISIBLE else View.GONE
|
||||
mEditorParagraphContainer.visibility = if (!mEditorLink.isChecked) View.VISIBLE else View.GONE
|
||||
mEditorFontContainer.visibility = if (!mEditorLink.isChecked) View.VISIBLE else View.GONE
|
||||
mEditorInsertDetail.visibility = mEditorLinkContainer.visibility
|
||||
}
|
||||
R.id.editor_font_bold -> {
|
||||
mEditorFontBold.isChecked = !mEditorFontBold.isChecked
|
||||
mRichEditor.setBold()
|
||||
}
|
||||
R.id.editor_font_italic -> {
|
||||
mEditorFontItalic.isChecked = !mEditorFontItalic.isChecked
|
||||
mRichEditor.setItalic()
|
||||
}
|
||||
R.id.editor_font_strikethrough -> {
|
||||
mEditorFontStrikeThrough.isChecked = !mEditorFontStrikeThrough.isChecked
|
||||
mRichEditor.setStrikeThrough()
|
||||
}
|
||||
R.id.editor_paragraph_h1 -> {
|
||||
if (mEditorParagraphH1.isChecked) {
|
||||
mRichEditor.formatBlock()
|
||||
} else {
|
||||
mRichEditor.setHeading(1)
|
||||
}
|
||||
mEditorParagraphH1.isChecked = !mEditorParagraphH1.isChecked
|
||||
}
|
||||
R.id.editor_paragraph_h2 -> {
|
||||
if (mEditorParagraphH2.isChecked) {
|
||||
mRichEditor.formatBlock()
|
||||
} else {
|
||||
mRichEditor.setHeading(2)
|
||||
}
|
||||
mEditorParagraphH2.isChecked = !mEditorParagraphH2.isChecked
|
||||
}
|
||||
R.id.editor_paragraph_h3 -> {
|
||||
if (mEditorParagraphH3.isChecked) {
|
||||
mRichEditor.formatBlock()
|
||||
} else {
|
||||
mRichEditor.setHeading(3)
|
||||
}
|
||||
mEditorParagraphH3.isChecked = !mEditorParagraphH3.isChecked
|
||||
}
|
||||
R.id.editor_paragraph_h4 -> {
|
||||
if (mEditorParagraphH4.isChecked) {
|
||||
mRichEditor.formatBlock()
|
||||
} else {
|
||||
mRichEditor.setHeading(4)
|
||||
}
|
||||
mEditorParagraphH4.isChecked = !mEditorParagraphH4.isChecked
|
||||
}
|
||||
R.id.editor_paragraph_quote -> {
|
||||
if (mEditorParagraphQuote.isChecked) {
|
||||
mRichEditor.formatBlock()
|
||||
} else {
|
||||
mRichEditor.setBlockquote()
|
||||
}
|
||||
mEditorParagraphQuote.isChecked = !mEditorParagraphQuote.isChecked
|
||||
}
|
||||
R.id.editor_link_answer -> {
|
||||
startActivityForResult(InsertAnswerWrapperActivity.getIntent(this), INSERT_ANSWER_CODE)
|
||||
}
|
||||
R.id.editor_link_article -> {
|
||||
startActivityForResult(InsertArticleWrapperActivity.getIntent(this), INSERT_ARTICLE_CODE)
|
||||
}
|
||||
R.id.editor_link_game -> {
|
||||
startActivityForResult(GameActivity.getIntent(this), INSERT_GAME_CODE)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private inner class OnCursorChangeListener {
|
||||
@JavascriptInterface
|
||||
fun onElements(elements: String) {
|
||||
Utils.log("-----------------------")
|
||||
Utils.log(elements)
|
||||
Utils.log(mRichEditor.html)
|
||||
Utils.log("-----------------------")
|
||||
|
||||
mCurrentParagraphStyle = when {
|
||||
elements.contains(ELEMENT_PARAGRAPH_QUOTE) -> ELEMENT_PARAGRAPH_QUOTE
|
||||
elements.contains(ELEMENT_PARAGRAPH_P) -> ELEMENT_PARAGRAPH_P
|
||||
else -> ""
|
||||
}
|
||||
|
||||
mBaseHandler.post {
|
||||
mEditorFontBold.isChecked = elements.contains(ELEMENT_NAME_BOLD)
|
||||
mEditorFontItalic.isChecked = elements.contains(ELEMENT_NAME_ITALIC)
|
||||
mEditorFontStrikeThrough.isChecked = elements.contains(ELEMENT_NAME_STRIKE)
|
||||
mEditorParagraphH1.isChecked = elements.contains(ELEMENT_PARAGRAPH_H1)
|
||||
mEditorParagraphH2.isChecked = elements.contains(ELEMENT_PARAGRAPH_H2)
|
||||
mEditorParagraphH3.isChecked = elements.contains(ELEMENT_PARAGRAPH_H3)
|
||||
mEditorParagraphH4.isChecked = elements.contains(ELEMENT_PARAGRAPH_H4)
|
||||
mEditorParagraphQuote.isChecked = elements.contains(ELEMENT_PARAGRAPH_QUOTE)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private inner class OnPasteListener {
|
||||
@JavascriptInterface
|
||||
fun onPaste() {
|
||||
val clipboard =
|
||||
HaloApp.getInstance().application.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
|
||||
val clipText = clipboard.text.toString()
|
||||
if (!TextUtils.isEmpty(clipText)) {
|
||||
// 替换换行符号否则 插入失败
|
||||
val text = clipText.replace("[ ]".toRegex(), " ").replace("[\r\n]".toRegex(), "<br/>")
|
||||
mBaseHandler.post { mRichEditor.insertHtml(text) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val ELEMENT_NAME_BOLD = " b "
|
||||
const val ELEMENT_NAME_ITALIC = " i "
|
||||
const val ELEMENT_NAME_STRIKE = " strike "
|
||||
const val ELEMENT_PARAGRAPH_H1 = " h1 "
|
||||
const val ELEMENT_PARAGRAPH_H2 = " h2 "
|
||||
const val ELEMENT_PARAGRAPH_H3 = " h3 "
|
||||
const val ELEMENT_PARAGRAPH_H4 = " h4 "
|
||||
const val ELEMENT_PARAGRAPH_P = " p "
|
||||
const val ELEMENT_PARAGRAPH_QUOTE = " blockquote "
|
||||
const val INSERT_ANSWER_CODE = 411
|
||||
const val INSERT_ARTICLE_CODE = 412
|
||||
const val INSERT_GAME_CODE = 413
|
||||
}
|
||||
}
|
||||
@ -1,16 +1,17 @@
|
||||
package com.gh.base;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.DrawableRes;
|
||||
import android.support.annotation.StringRes;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.DrawableRes;
|
||||
import androidx.annotation.StringRes;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import com.gh.common.util.DisplayUtils;
|
||||
import com.gh.gamecenter.R;
|
||||
import com.gh.gamecenter.normal.ToolbarController;
|
||||
@ -67,6 +68,13 @@ public abstract class BaseToolBarActivity extends BaseAppCompatActivity implemen
|
||||
setNavigationTitle(getString(res));
|
||||
}
|
||||
|
||||
/**
|
||||
* 重写此方法以将标题靠左显示
|
||||
*/
|
||||
public boolean showToolbarAtLeft() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setToolbarMenu(int res) {
|
||||
if (mToolbar == null) return;
|
||||
@ -89,9 +97,25 @@ public abstract class BaseToolBarActivity extends BaseAppCompatActivity implemen
|
||||
ViewGroup.LayoutParams layoutParams = mTitleTv.getLayoutParams();
|
||||
if (layoutParams instanceof RelativeLayout.LayoutParams) {
|
||||
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) layoutParams;
|
||||
params.setMargins(DisplayUtils.dip2px(90), 0, DisplayUtils.dip2px(90), 0);
|
||||
if (showToolbarAtLeft()) {
|
||||
params.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
|
||||
params.addRule(RelativeLayout.CENTER_VERTICAL);
|
||||
params.setMargins(DisplayUtils.dip2px(55), 0, DisplayUtils.dip2px(48 * menu.size()), 0);
|
||||
} else {
|
||||
params.setMargins(DisplayUtils.dip2px(90), 0, DisplayUtils.dip2px(90), 0);
|
||||
}
|
||||
mTitleTv.setLayoutParams(params);
|
||||
}
|
||||
} else {
|
||||
if (showToolbarAtLeft()) {
|
||||
ViewGroup.LayoutParams layoutParams = mTitleTv.getLayoutParams();
|
||||
if (layoutParams instanceof RelativeLayout.LayoutParams) {
|
||||
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) layoutParams;
|
||||
params.addRule(RelativeLayout.CENTER_VERTICAL);
|
||||
params.setMargins(DisplayUtils.dip2px(55), 0, DisplayUtils.dip2px(48 * menu.size()), 0);
|
||||
mTitleTv.setLayoutParams(params);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -101,6 +125,12 @@ public abstract class BaseToolBarActivity extends BaseAppCompatActivity implemen
|
||||
return mToolbar.getMenu().findItem(res);
|
||||
}
|
||||
|
||||
public void clearMenu() {
|
||||
if (mToolbar != null) {
|
||||
mToolbar.getMenu().clear();
|
||||
}
|
||||
}
|
||||
|
||||
public Menu getMenu() {
|
||||
return mToolbar.getMenu();
|
||||
}
|
||||
|
||||
@ -7,7 +7,7 @@ import com.gh.common.util.EntranceUtils;
|
||||
import com.gh.gamecenter.GameDetailActivity;
|
||||
import com.gh.gamecenter.NewsDetailActivity;
|
||||
import com.gh.gamecenter.WebActivity;
|
||||
import com.gh.gamecenter.subject.refactor.SubjectActivity;
|
||||
import com.gh.gamecenter.subject.SubjectActivity;
|
||||
import com.umeng.message.UmengNotificationClickHandler;
|
||||
import com.umeng.message.entity.UMessage;
|
||||
|
||||
|
||||
@ -9,51 +9,54 @@ import android.content.Intent
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.preference.PreferenceManager
|
||||
import android.support.v4.app.NotificationCompat
|
||||
import android.text.TextUtils
|
||||
import android.view.View
|
||||
import androidx.core.app.NotificationCompat
|
||||
import com.gh.common.notifier.Notifier
|
||||
import com.gh.common.util.DataUtils
|
||||
import com.gh.common.util.EntranceUtils
|
||||
import com.gh.common.util.PackageUtils
|
||||
import com.gh.common.util.MtaHelper
|
||||
import com.gh.common.util.StringUtils
|
||||
import com.gh.gamecenter.BuildConfig
|
||||
import com.gh.common.util.toObject
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.entity.PushEntity
|
||||
import com.gh.gamecenter.entity.PushMessageEntity
|
||||
import com.gh.gamecenter.entity.PushMessageUnreadEntity
|
||||
import com.gh.gamecenter.entity.PushNotificationEntity
|
||||
import com.gh.gamecenter.manager.UserManager
|
||||
import com.gh.gamecenter.message.MessageUnreadRepository
|
||||
import com.gh.gamecenter.qa.answer.detail.AnswerDetailActivity
|
||||
import com.gh.gamecenter.receiver.UmengMessageReceiver
|
||||
import com.gh.gamecenter.receiver.UmengMessageReceiver.Companion.TYPE_CLICK
|
||||
import com.gh.gamecenter.receiver.UmengMessageReceiver.Companion.TYPE_REMOVE
|
||||
import com.gh.gamecenter.retrofit.Response
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager
|
||||
import com.google.gson.Gson
|
||||
import com.halo.assistant.HaloApp
|
||||
import com.umeng.message.UmengMessageService
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
import okhttp3.MediaType
|
||||
import okhttp3.RequestBody
|
||||
import okhttp3.ResponseBody
|
||||
import org.android.agoo.common.AgooConstants
|
||||
import org.json.JSONObject
|
||||
import retrofit2.HttpException
|
||||
import java.util.*
|
||||
|
||||
class GHUmengNotificationService : UmengMessageService() {
|
||||
|
||||
companion object {
|
||||
const val ACTION_UMENG = "com.gh.gamecenter.UMENG"
|
||||
|
||||
const val MESSAGE_FROM_SYSTEM = "message_from_system"
|
||||
|
||||
const val HALO_MESSAGE_DIALOG = "HALO_MESSAGE_DIALOG"
|
||||
|
||||
const val HALO_MESSAGE_CENTER = "HALO_MESSAGE_CENTER"
|
||||
|
||||
const val ANSWER = "answer"
|
||||
|
||||
const val FOLLOW_QUESTION = "follow_question"
|
||||
|
||||
const val NOTIFICATION_ID = 2015
|
||||
|
||||
const val DISPLAY_TYPE_NOTIFICATION = "notification"
|
||||
|
||||
const val DISPLAY_TYPE_CUSTOM = "custom"
|
||||
const val MESSAGE_ID = "message_id"
|
||||
const val NOTIFICATION_MESSAGE_ID = "notification_message_id" // 通知中心消息 ID
|
||||
const val PUSH_ID = "push_id"
|
||||
}
|
||||
|
||||
val notificationTags = arrayOf("GH_UMENG_TAG_1", "GH_UMENG_TAG_2", "GH_UMENG_TAG_3")
|
||||
@ -64,7 +67,7 @@ class GHUmengNotificationService : UmengMessageService() {
|
||||
val isMessageFromSystem = intent.getBooleanExtra(MESSAGE_FROM_SYSTEM, false)
|
||||
|
||||
try {
|
||||
val pushData = gson.fromJson(message, PushEntity::class.java)
|
||||
val pushData = message.toObject<PushEntity>()
|
||||
pushData?.let { handlePushData(context, it, message, isMessageFromSystem) }
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
@ -77,59 +80,68 @@ class GHUmengNotificationService : UmengMessageService() {
|
||||
if (pushData.displayType == DISPLAY_TYPE_NOTIFICATION) {
|
||||
// 其它类型的透传信息
|
||||
// 显示到通知栏
|
||||
val msg = gson.fromJson(message, PushNotificationEntity::class.java)
|
||||
val msg = message.toObject<PushNotificationEntity>()
|
||||
val data = msg?.extra?.data
|
||||
|
||||
// 系统推送,直接处理跳转
|
||||
// 系统推送(非自定义信息),直接处理跳转
|
||||
if (isMessageFromSystem) {
|
||||
val intent = Intent()
|
||||
intent.setClass(context, UmengMessageReceiver::class.java)
|
||||
intent.putExtra(EntranceUtils.KEY_DATA, data?.link)
|
||||
intent.putExtra(EntranceUtils.KEY_TYPE, UmengMessageReceiver.DIRECT_ONLY)
|
||||
intent.putExtra(EntranceUtils.KEY_MESSAGE, message)
|
||||
intent.putExtra(NOTIFICATION_MESSAGE_ID, data?.messageId)
|
||||
context.sendBroadcast(intent)
|
||||
return
|
||||
}
|
||||
|
||||
// 判断是否过滤该消息
|
||||
if (validatePush(data?.condition)) {
|
||||
val clickIntent = Intent()
|
||||
val removeIntent = Intent()
|
||||
|
||||
clickIntent.setClass(context, UmengMessageReceiver::class.java)
|
||||
clickIntent.putExtra(EntranceUtils.KEY_DATA, data?.link)
|
||||
clickIntent.putExtra(EntranceUtils.KEY_MESSAGE, message)
|
||||
clickIntent.putExtra(EntranceUtils.KEY_TYPE, TYPE_CLICK)
|
||||
|
||||
removeIntent.setClass(context, UmengMessageReceiver::class.java)
|
||||
removeIntent.putExtra(EntranceUtils.KEY_TYPE, TYPE_REMOVE)
|
||||
removeIntent.putExtra(EntranceUtils.KEY_MESSAGE, message)
|
||||
|
||||
val clickPendingIntent = PendingIntent.getBroadcast(context, System.currentTimeMillis().toInt(),
|
||||
clickIntent, PendingIntent.FLAG_UPDATE_CURRENT)
|
||||
|
||||
val deletePendingIntent = PendingIntent.getBroadcast(context, System.currentTimeMillis().toInt() + 1,
|
||||
removeIntent, PendingIntent.FLAG_UPDATE_CURRENT)
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
val channel = NotificationChannel("Halo_Push", "Halo_Push", NotificationManager.IMPORTANCE_DEFAULT)
|
||||
notificationManager.createNotificationChannel(channel)
|
||||
}
|
||||
|
||||
val notification = NotificationCompat.Builder(context, "Halo_Push")
|
||||
.setSmallIcon(R.drawable.ic_notification)
|
||||
.setTicker(pushData.body?.ticker)
|
||||
.setContentTitle(pushData.body?.title)
|
||||
.setContentText(pushData.body?.text)
|
||||
.setContentIntent(clickPendingIntent)
|
||||
.setDeleteIntent(deletePendingIntent)
|
||||
.build()
|
||||
notification.flags = notification.flags or Notification.FLAG_AUTO_CANCEL
|
||||
|
||||
notificationManager.notify(getNotificationTag(context), NOTIFICATION_ID, notification)
|
||||
// 用户未登录的情况下不生成消息中心通知,避免用户掉登录了还收到跳转至消息中心的通知
|
||||
if (data != null
|
||||
&& data.link?.target == "system"
|
||||
&& !UserManager.getInstance().isLoggedIn) {
|
||||
return
|
||||
}
|
||||
|
||||
val clickIntent = Intent()
|
||||
val removeIntent = Intent()
|
||||
|
||||
clickIntent.setClass(context, UmengMessageReceiver::class.java)
|
||||
clickIntent.putExtra(EntranceUtils.KEY_DATA, data?.link)
|
||||
clickIntent.putExtra(EntranceUtils.KEY_MESSAGE, message)
|
||||
clickIntent.putExtra(MESSAGE_ID, msg?.msgId)
|
||||
clickIntent.putExtra(PUSH_ID, data?.pushId)
|
||||
clickIntent.putExtra(NOTIFICATION_MESSAGE_ID, data?.messageId)
|
||||
clickIntent.putExtra(EntranceUtils.KEY_TYPE, TYPE_CLICK)
|
||||
|
||||
removeIntent.setClass(context, UmengMessageReceiver::class.java)
|
||||
removeIntent.putExtra(EntranceUtils.KEY_TYPE, TYPE_REMOVE)
|
||||
removeIntent.putExtra(EntranceUtils.KEY_MESSAGE, message)
|
||||
|
||||
val clickPendingIntent = PendingIntent.getBroadcast(context, System.currentTimeMillis().toInt(),
|
||||
clickIntent, PendingIntent.FLAG_UPDATE_CURRENT)
|
||||
|
||||
val deletePendingIntent = PendingIntent.getBroadcast(context, System.currentTimeMillis().toInt() + 1,
|
||||
removeIntent, PendingIntent.FLAG_UPDATE_CURRENT)
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
val channel = NotificationChannel("Halo_Push", "Halo_Push", NotificationManager.IMPORTANCE_DEFAULT)
|
||||
notificationManager.createNotificationChannel(channel)
|
||||
}
|
||||
|
||||
val notification = NotificationCompat.Builder(context, "Halo_Push")
|
||||
.setSmallIcon(R.drawable.ic_notification)
|
||||
.setTicker(pushData.body?.ticker)
|
||||
.setContentTitle(pushData.body?.title)
|
||||
.setContentText(pushData.body?.text)
|
||||
.setContentIntent(clickPendingIntent)
|
||||
.setDeleteIntent(deletePendingIntent)
|
||||
.build()
|
||||
notification.flags = notification.flags or Notification.FLAG_AUTO_CANCEL
|
||||
|
||||
notificationManager.notify(getNotificationTag(context), NOTIFICATION_ID, notification)
|
||||
} else {
|
||||
if (HALO_MESSAGE_DIALOG == pushData.body?.custom) {
|
||||
if (UserManager.getInstance().isLoggedIn
|
||||
&& HALO_MESSAGE_DIALOG == pushData.body?.custom) {
|
||||
// 回答了问题或者关注了问题的消息
|
||||
val msg = gson.fromJson(message, PushMessageEntity::class.java)
|
||||
val data = msg?.extra?.data
|
||||
@ -149,16 +161,33 @@ class GHUmengNotificationService : UmengMessageService() {
|
||||
.setText(displayText)
|
||||
.setDuration(5000)
|
||||
.setIcon(data?.userEntity?.icon)
|
||||
.setOnClickListener(View.OnClickListener { _ ->
|
||||
.setOnClickListener(View.OnClickListener {
|
||||
val bundle = Bundle()
|
||||
bundle.putString(EntranceUtils.KEY_ANSWER_ID, data?.answer?.id)
|
||||
bundle.putString(EntranceUtils.KEY_ENTRANCE, EntranceUtils.ENTRANCE_UMENG)
|
||||
bundle.putString(EntranceUtils.KEY_TO, AnswerDetailActivity::class.java.name)
|
||||
EntranceUtils.jumpActivity(context, bundle)
|
||||
|
||||
DataUtils.onMtaEvent(context, "消息弹窗",
|
||||
type, "")
|
||||
MtaHelper.onEvent("消息弹窗", type, "Does not contains any parameter.")
|
||||
|
||||
// 标记已读
|
||||
val jsonObject = JSONObject()
|
||||
jsonObject.put("type", type)
|
||||
val body = RequestBody.create(MediaType.parse("application/json"), jsonObject.toString())
|
||||
|
||||
RetrofitManager.getInstance(application).api.postMessageRead(UserManager.getInstance().userId, data?.id, body)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(object : Response<ResponseBody>() {
|
||||
override fun onResponse(response: ResponseBody?) {
|
||||
super.onResponse(response)
|
||||
MessageUnreadRepository.loadMessageUnreadData()
|
||||
}
|
||||
|
||||
override fun onFailure(e: HttpException?) {
|
||||
e?.printStackTrace()
|
||||
}
|
||||
})
|
||||
Notifier.hide()
|
||||
})
|
||||
.show(false)
|
||||
@ -173,37 +202,6 @@ class GHUmengNotificationService : UmengMessageService() {
|
||||
}
|
||||
}
|
||||
|
||||
private fun validatePush(condition: PushNotificationEntity.Data.Condition?): Boolean {
|
||||
if (condition == null) return true
|
||||
|
||||
// 校验渠道是否匹配
|
||||
condition.ghzs?.channel?.let {
|
||||
if (it.isNotEmpty() && it != HaloApp.getInstance().channel) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// 校验光环版本版本是否匹配
|
||||
condition.ghzs?.version?.let {
|
||||
if (it.isNotEmpty() && !BuildConfig.VERSION_NAME.contains(it)) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// 校验已安装的应用里是否存在条件的包名
|
||||
if (condition.packageName.isNotEmpty()) {
|
||||
val installedPackageList = PackageUtils.getAllPackageName(HaloApp.getInstance().application)
|
||||
for (packageName in installedPackageList) {
|
||||
if (condition.packageName == packageName) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
/**
|
||||
* 规则:最多三条消息,以旧换新
|
||||
*
|
||||
|
||||
@ -2,7 +2,11 @@ package com.gh.base;
|
||||
|
||||
/**
|
||||
* Created by Administrator on 2016/9/8.
|
||||
*
|
||||
* 逐步移除
|
||||
*/
|
||||
|
||||
@Deprecated
|
||||
public interface OnRequestCallBackListener<T> {
|
||||
|
||||
void loadDone();
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
package com.gh.base.adapter;
|
||||
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.support.v4.app.FragmentPagerAdapter;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.fragment.app.FragmentPagerAdapter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
package com.gh.base.adapter;
|
||||
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.support.v4.app.FragmentStatePagerAdapter;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.fragment.app.FragmentStatePagerAdapter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
package com.gh.base.fragment;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.arch.lifecycle.Lifecycle;
|
||||
import androidx.lifecycle.Lifecycle;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.StringRes;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.StringRes;
|
||||
import androidx.fragment.app.DialogFragment;
|
||||
import android.view.KeyEvent;
|
||||
|
||||
import com.gh.common.util.ClickUtils;
|
||||
|
||||
@ -2,9 +2,9 @@ package com.gh.base.fragment;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.Fragment;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
|
||||
@ -1,22 +1,26 @@
|
||||
package com.gh.base.fragment;
|
||||
|
||||
import android.arch.lifecycle.Lifecycle;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.support.annotation.LayoutRes;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.annotation.StringRes;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.FragmentTransaction;
|
||||
import android.text.TextUtils;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.LayoutRes;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.StringRes;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentTransaction;
|
||||
import androidx.lifecycle.Lifecycle;
|
||||
|
||||
import com.gh.base.OnListClickListener;
|
||||
import com.gh.base.OnRequestCallBackListener;
|
||||
import com.gh.common.constant.Constants;
|
||||
import com.gh.gamecenter.BuildConfig;
|
||||
import com.gh.gamecenter.eventbus.EBMiPush;
|
||||
import com.lightgame.OnTitleClickListener;
|
||||
import com.lightgame.utils.RuntimeUtils;
|
||||
@ -43,10 +47,13 @@ import static com.gh.common.util.EntranceUtils.KEY_ENTRANCE;
|
||||
public abstract class BaseFragment<T> extends Fragment implements OnRequestCallBackListener<T>,
|
||||
View.OnClickListener, OnListClickListener, OnTitleClickListener {
|
||||
|
||||
public static final int RESULT_REFRESH = 9528;
|
||||
|
||||
protected View mCachedView;
|
||||
|
||||
protected boolean isEverPause;
|
||||
|
||||
@NonNull
|
||||
protected String mEntrance;
|
||||
|
||||
protected final Handler mBaseHandler = new BaseFragment.BaseHandler(this);
|
||||
@ -116,6 +123,14 @@ public abstract class BaseFragment<T> extends Fragment implements OnRequestCallB
|
||||
mEntrance = getArguments().getString(KEY_ENTRANCE);
|
||||
}
|
||||
|
||||
if (TextUtils.isEmpty(mEntrance)) {
|
||||
mEntrance = Constants.ENTRANCE_UNKNOWN;
|
||||
}
|
||||
|
||||
if (BuildConfig.DEBUG) {
|
||||
Utils.log("FRAGMENT_ENTRANCE -> " + mEntrance);
|
||||
}
|
||||
|
||||
isEverPause = false;
|
||||
EventBus.getDefault().register(this);
|
||||
|
||||
@ -130,10 +145,10 @@ public abstract class BaseFragment<T> extends Fragment implements OnRequestCallB
|
||||
initView(mCachedView);
|
||||
}
|
||||
|
||||
//TODO 尴尬,必须的有subscribe才能register
|
||||
// 必须的有subscribe才能register
|
||||
@Subscribe(threadMode = ThreadMode.BACKGROUND)
|
||||
public void onDummyEvent(EBMiPush push) {
|
||||
//
|
||||
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@ -234,4 +249,10 @@ public abstract class BaseFragment<T> extends Fragment implements OnRequestCallB
|
||||
}
|
||||
}
|
||||
|
||||
// 为 fragment 附加 bundle (setArgument())
|
||||
public BaseFragment with(Bundle bundle) {
|
||||
this.setArguments(bundle);
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -2,11 +2,11 @@ package com.gh.base.fragment;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.design.widget.TabLayout;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.view.ViewPager;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import com.google.android.material.tabs.TabLayout;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
import android.view.View;
|
||||
|
||||
import com.gh.base.adapter.FragmentAdapter;
|
||||
@ -55,7 +55,7 @@ public abstract class BaseFragment_TabLayout extends NormalFragment implements V
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.fragment_taglyout_viewpager;
|
||||
return R.layout.fragment_tablayout_viewpager;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -11,12 +11,12 @@ package com.gh.base.fragment;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.IdRes;
|
||||
import android.support.annotation.LayoutRes;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.view.PagerAdapter;
|
||||
import android.support.v4.view.ViewPager;
|
||||
import androidx.annotation.IdRes;
|
||||
import androidx.annotation.LayoutRes;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.viewpager.widget.PagerAdapter;
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
import android.view.View;
|
||||
|
||||
import com.gh.gamecenter.normal.NormalFragment;
|
||||
|
||||
@ -10,9 +10,9 @@
|
||||
package com.gh.base.fragment;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.IdRes;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.view.ViewPager;
|
||||
import androidx.annotation.IdRes;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Checkable;
|
||||
|
||||
@ -1,13 +1,15 @@
|
||||
package com.gh.base.fragment;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
|
||||
import com.gh.gamecenter.R;
|
||||
|
||||
/**
|
||||
@ -43,9 +45,9 @@ public class WaitingDialogFragment extends BaseDialogFragment {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
final View view = inflater.inflate(R.layout.set_wait_dialog, null);
|
||||
message = (TextView) view.findViewById(R.id.set_wait_message);
|
||||
message = view.findViewById(R.id.set_wait_message);
|
||||
message.setText(getArguments().getString(KEY_MSG));
|
||||
return view;
|
||||
}
|
||||
@ -77,6 +79,12 @@ public class WaitingDialogFragment extends BaseDialogFragment {
|
||||
return super.onBack();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dismiss() {
|
||||
mBackListener = null;
|
||||
super.dismiss();
|
||||
}
|
||||
|
||||
public static class WaitingDialogData {
|
||||
private String msg;
|
||||
|
||||
|
||||
@ -17,5 +17,17 @@ object AppExecutor {
|
||||
override fun execute(command: Runnable) {
|
||||
mainThreadHandler.post(command)
|
||||
}
|
||||
|
||||
fun executeWithDelay(command: Runnable, delay: Long) {
|
||||
mainThreadHandler.postDelayed(command, delay)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun runOnIoThread(f: () -> Unit) {
|
||||
AppExecutor.ioExecutor.execute(f)
|
||||
}
|
||||
|
||||
fun runOnUiThread(f: () -> Unit) {
|
||||
AppExecutor.uiExecutor.execute(f)
|
||||
}
|
||||
@ -1,14 +1,16 @@
|
||||
package com.gh.common
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.preference.PreferenceManager
|
||||
import com.gh.base.GHUmengNotificationService
|
||||
import com.gh.common.constant.Config
|
||||
import com.gh.common.exposure.meta.MetaUtil
|
||||
import com.gh.common.util.edit
|
||||
import com.gh.common.util.toJson
|
||||
import com.gh.common.util.toObject
|
||||
import com.gh.gamecenter.BuildConfig
|
||||
import com.gh.gamecenter.entity.AliasEntity
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager
|
||||
import com.google.gson.Gson
|
||||
import com.halo.assistant.HaloApp
|
||||
import com.lightgame.utils.Utils
|
||||
import com.umeng.commonsdk.UMConfigure
|
||||
@ -24,7 +26,6 @@ import org.json.JSONObject
|
||||
|
||||
object PushManager {
|
||||
|
||||
var gson = Gson()
|
||||
var deviceToken: String? = ""
|
||||
var previousAlias: AliasEntity? = null
|
||||
var application = HaloApp.getInstance().application
|
||||
@ -52,7 +53,7 @@ object PushManager {
|
||||
registerDevice()
|
||||
|
||||
val aliasInSp = PreferenceManager.getDefaultSharedPreferences(application).getString(SP_PUSH_ALIAS, "")
|
||||
previousAlias = gson.fromJson(aliasInSp, AliasEntity::class.java)
|
||||
previousAlias = aliasInSp?.toObject()
|
||||
|
||||
if (previousAlias == null) {
|
||||
getAndSetAlias()
|
||||
@ -77,6 +78,7 @@ object PushManager {
|
||||
})
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
@JvmStatic
|
||||
fun getAndSetAlias() {
|
||||
if (deviceToken.isNullOrEmpty()) {
|
||||
@ -112,7 +114,7 @@ object PushManager {
|
||||
|
||||
previousAlias = alias
|
||||
PreferenceManager.getDefaultSharedPreferences(application).edit {
|
||||
putString(SP_PUSH_ALIAS, gson.toJson(previousAlias))
|
||||
putString(SP_PUSH_ALIAS, previousAlias?.toJson())
|
||||
}
|
||||
|
||||
pushAgent.setAlias(alias.alias, alias.aliasType) { b, s ->
|
||||
|
||||
@ -1,34 +1,79 @@
|
||||
package com.gh.common
|
||||
|
||||
import android.support.v4.app.Fragment
|
||||
import android.support.v4.app.FragmentManager
|
||||
import android.app.Activity
|
||||
import android.app.Application
|
||||
import android.os.Bundle
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.FragmentManager
|
||||
import com.halo.assistant.HaloApp
|
||||
import java.util.concurrent.Executors
|
||||
|
||||
/**
|
||||
* 统计用户在当前 Fragment 的停留时间,在 onViewDestroy 或 onDestroy 里获取 elapsedTime 即可,单位为秒
|
||||
*/
|
||||
class TimeElapsedHelper(var fragment: Fragment) {
|
||||
class TimeElapsedHelper(val fragment: Fragment?, val activity: Activity?) {
|
||||
|
||||
constructor() : this(null, null)
|
||||
|
||||
constructor(fragment: Fragment) : this(fragment, null)
|
||||
|
||||
constructor(activity: Activity) : this(null, activity)
|
||||
|
||||
private var isWorking = false
|
||||
|
||||
var elapsedTime: Int = 0
|
||||
|
||||
var timeout: Int = 0
|
||||
var timeoutCallback: TimeoutCallback? = null
|
||||
|
||||
init {
|
||||
fragment.fragmentManager?.registerFragmentLifecycleCallbacks(
|
||||
activity?.application?.registerActivityLifecycleCallbacks(object : Application.ActivityLifecycleCallbacks {
|
||||
override fun onActivityStarted(a: Activity?) {
|
||||
}
|
||||
|
||||
override fun onActivitySaveInstanceState(a: Activity?, outState: Bundle?) {
|
||||
}
|
||||
|
||||
override fun onActivityStopped(a: Activity?) {
|
||||
}
|
||||
|
||||
override fun onActivityCreated(a: Activity?, savedInstanceState: Bundle?) {
|
||||
}
|
||||
|
||||
override fun onActivityPaused(a: Activity?) {
|
||||
if (activity == a) {
|
||||
pauseCounting()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onActivityResumed(a: Activity?) {
|
||||
if (activity == a) {
|
||||
resumeCounting()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onActivityDestroyed(a: Activity?) {
|
||||
if (activity == a) {
|
||||
HaloApp.getInstance().application.unregisterActivityLifecycleCallbacks(this)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
fragment?.fragmentManager?.registerFragmentLifecycleCallbacks(
|
||||
object : FragmentManager.FragmentLifecycleCallbacks() {
|
||||
override fun onFragmentResumed(fm: FragmentManager?, f: Fragment?) {
|
||||
override fun onFragmentResumed(fm: FragmentManager, f: Fragment) {
|
||||
if (f === fragment) {
|
||||
resumeCounting()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onFragmentPaused(fm: FragmentManager?, f: Fragment?) {
|
||||
override fun onFragmentPaused(fm: FragmentManager, f: Fragment) {
|
||||
if (f === fragment) {
|
||||
pauseCounting()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onFragmentViewDestroyed(fm: FragmentManager?, f: Fragment?) {
|
||||
override fun onFragmentViewDestroyed(fm: FragmentManager, f: Fragment) {
|
||||
if (f === fragment) {
|
||||
fragment.fragmentManager?.unregisterFragmentLifecycleCallbacks(this)
|
||||
}
|
||||
@ -36,12 +81,19 @@ class TimeElapsedHelper(var fragment: Fragment) {
|
||||
}, false)
|
||||
}
|
||||
|
||||
private fun resumeCounting() {
|
||||
fun resumeCounting() {
|
||||
isWorking = true
|
||||
TimeElapsedThreadHolder.threadService.execute {
|
||||
while (isWorking) {
|
||||
try {
|
||||
elapsedTime++
|
||||
if (timeout != 0 && timeout == elapsedTime) {
|
||||
timeoutCallback?.run {
|
||||
AppExecutor.uiExecutor.execute {
|
||||
onTimeout()
|
||||
}
|
||||
}
|
||||
}
|
||||
Thread.sleep(1000)
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
@ -50,7 +102,11 @@ class TimeElapsedHelper(var fragment: Fragment) {
|
||||
}
|
||||
}
|
||||
|
||||
private fun pauseCounting() {
|
||||
fun resetCounting() {
|
||||
elapsedTime = 0
|
||||
}
|
||||
|
||||
fun pauseCounting() {
|
||||
isWorking = false
|
||||
}
|
||||
|
||||
@ -58,4 +114,8 @@ class TimeElapsedHelper(var fragment: Fragment) {
|
||||
|
||||
object TimeElapsedThreadHolder {
|
||||
val threadService = Executors.newSingleThreadExecutor()
|
||||
}
|
||||
|
||||
interface TimeoutCallback {
|
||||
fun onTimeout()
|
||||
}
|
||||
11
app/src/main/java/com/gh/common/annotation/Synchronize.java
Normal file
11
app/src/main/java/com/gh/common/annotation/Synchronize.java
Normal file
@ -0,0 +1,11 @@
|
||||
package com.gh.common.annotation;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@Target(ElementType.FIELD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface Synchronize {
|
||||
}
|
||||
@ -1,12 +1,14 @@
|
||||
package com.gh.common.constant;
|
||||
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.preference.PreferenceManager;
|
||||
import androidx.annotation.Nullable;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.gh.common.util.GsonUtils;
|
||||
import com.gh.common.util.PackageHelper;
|
||||
import com.gh.common.util.SPUtils;
|
||||
import com.gh.gamecenter.BuildConfig;
|
||||
import com.gh.gamecenter.entity.NewsEntity;
|
||||
import com.gh.gamecenter.entity.SettingsEntity;
|
||||
@ -18,17 +20,12 @@ import java.util.List;
|
||||
public class Config {
|
||||
|
||||
public static final String API_HOST = BuildConfig.API_HOST;
|
||||
public static final String USER_HOST = BuildConfig.USER_HOST;
|
||||
public static final String COMMENT_HOST = BuildConfig.COMMENT_HOST;
|
||||
public static final String DATA_HOST = BuildConfig.DATA_HOST;
|
||||
public static final String LIBAO_HOST = BuildConfig.LIBAO_HOST;
|
||||
public static final String MESSAGE_HOST = BuildConfig.MESSAGE_HOST;
|
||||
|
||||
/**
|
||||
* 需要配置的请使用{@link PreferenceManager#getDefaultSharedPreferences(Context)}
|
||||
*/
|
||||
// @Deprecated
|
||||
// public static final String PREFERENCE = "ghzhushou";
|
||||
|
||||
// Third-Party confs
|
||||
public static final String WECHAT_APPID = BuildConfig.WECHAT_APPID;
|
||||
@ -42,45 +39,48 @@ public class Config {
|
||||
public static final String UMENG_APPKEY = BuildConfig.UMENG_APPKEY;
|
||||
public static final String UMENG_MESSAGE_SECRET = BuildConfig.UMENG_MESSAGE_SECRET;
|
||||
public static final String BUGLY_APPID = BuildConfig.BUGLY_APPID;
|
||||
public static final String PATCH_VERSION_NAME = BuildConfig.PATCH_VERSION_NAME; // 补丁包版本 对应关于->版本号
|
||||
// http://www.ghzs666.com/article/${articleId}.html
|
||||
public static final String URL_ARTICLE = "http://www.ghzs666.com/article/"; // TODO ghzs/ghzs666 统一
|
||||
public static final String URL_ARTICLE = "http://www.ghzs666.com/article/"; // ghzs/ghzs666 统一
|
||||
public static final String PATCHES = "patches";
|
||||
|
||||
public static final String DEFAULT_CHANNEL = "GH_TEST";
|
||||
|
||||
private static String SETTINGS_KEY = "settingsKey";
|
||||
|
||||
private static SettingsEntity mSettingsEntity;
|
||||
|
||||
public static final String FIX_DOWNLOAD_KEY = "isFixDownload";
|
||||
public static final String FIX_PLUGIN_KEY = "isFixPlugin";
|
||||
public static final String FIX_ARTICLE_KEY = "isFixArticle";
|
||||
public static final String FIX_COMMUNITY_KEY = "isFixCommunity";
|
||||
|
||||
|
||||
public static boolean isShow() {
|
||||
if (PreferenceManager.getDefaultSharedPreferences(HaloApp.getInstance().getApplication())
|
||||
.getBoolean("isFixDownload", false)) return true;
|
||||
if (getPreferences().getBoolean(FIX_DOWNLOAD_KEY, false)) return true;
|
||||
|
||||
if (!isExistDownloadFilter()) return false;
|
||||
|
||||
for (SettingsEntity.Download entity : getSettings().getDownload()) {
|
||||
if ("all".equals(entity.getGame())) {
|
||||
if (entity.isPluginfy() && "normal".equals(entity.getPolicy()) && filterTime(entity.getTime())) {
|
||||
if (entity.getPluginfy() && "normal".equals(entity.getPolicy()) && filterTime(entity.getTime())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static String getExceptionMsg(Context context) {
|
||||
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
return sp.getString("errMsg", null);
|
||||
public static String getExceptionMsg() {
|
||||
return getPreferences().getString("errMsg", null);
|
||||
}
|
||||
|
||||
public static void setExceptionMsg(Context context, String errMsg) {
|
||||
PreferenceManager.getDefaultSharedPreferences(context).edit().putString("errMsg", errMsg).apply();
|
||||
public static void setExceptionMsg(String errMsg) {
|
||||
SPUtils.setString(getPreferences(), "errMsg", errMsg); //先用apply(),保存不了再用commit() 9.0机型保存不了信息
|
||||
}
|
||||
|
||||
public static boolean isShowDownload(String gameId) {
|
||||
|
||||
if (PreferenceManager.getDefaultSharedPreferences(HaloApp.getInstance().getApplication())
|
||||
.getBoolean("isFixDownload", false)) return true;
|
||||
if (getPreferences().getBoolean(FIX_DOWNLOAD_KEY, false)) return true;
|
||||
|
||||
if (TextUtils.isEmpty(gameId) || !isExistDownloadFilter())
|
||||
return false;
|
||||
@ -104,18 +104,25 @@ public class Config {
|
||||
|
||||
|
||||
public static boolean isShowPlugin(String gameId) {
|
||||
SharedPreferences preferences = getPreferences();
|
||||
boolean isFixPlugin = preferences.getBoolean(FIX_PLUGIN_KEY, false);
|
||||
if (isFixPlugin) return true;
|
||||
|
||||
if (TextUtils.isEmpty(gameId) || !isExistDownloadFilter())
|
||||
return false;
|
||||
|
||||
for (SettingsEntity.Download entity : getSettings().getDownload()) {
|
||||
if (gameId.equals(entity.getGame())) {
|
||||
if (entity.isPluginfy() && filterTime(entity.getTime())) {
|
||||
if (entity.getPluginfy() && filterTime(entity.getTime())) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else if ("all".equals(entity.getGame())) {
|
||||
if (entity.isPluginfy() && filterTime(entity.getTime())) {
|
||||
}
|
||||
|
||||
if ("all".equals(entity.getGame())) {
|
||||
if (entity.getPluginfy() && filterTime(entity.getTime())) {
|
||||
preferences.edit().putBoolean(FIX_PLUGIN_KEY, true).apply();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -125,12 +132,17 @@ public class Config {
|
||||
}
|
||||
|
||||
public static boolean isShowPlugin() {
|
||||
SharedPreferences preferences = getPreferences();
|
||||
boolean isFixPlugin = preferences.getBoolean(FIX_PLUGIN_KEY, false);
|
||||
if (isFixPlugin) return true;
|
||||
|
||||
if (!isExistDownloadFilter())
|
||||
return false;
|
||||
|
||||
for (SettingsEntity.Download entity : getSettings().getDownload()) {
|
||||
if ("all".equals(entity.getGame())) {
|
||||
if (entity.isPluginfy() && filterTime(entity.getTime())) {
|
||||
if (entity.getPluginfy() && filterTime(entity.getTime())) {
|
||||
preferences.edit().putBoolean(FIX_PLUGIN_KEY, true).apply();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -152,19 +164,20 @@ public class Config {
|
||||
}
|
||||
|
||||
public static void setSettings(SettingsEntity settingsEntity) {
|
||||
SharedPreferences.Editor edit = PreferenceManager.getDefaultSharedPreferences(HaloApp.getInstance().getApplication()).edit();
|
||||
edit.putString(SETTINGS_KEY, GsonUtils.getInstance().toJson(settingsEntity)).apply();
|
||||
|
||||
getPreferences().edit().putString(SETTINGS_KEY, GsonUtils.toJson(settingsEntity)).apply();
|
||||
mSettingsEntity = settingsEntity;
|
||||
|
||||
// 加载完设置后刷新下
|
||||
PackageHelper.initList();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static SettingsEntity getSettings() {
|
||||
if (mSettingsEntity == null) {
|
||||
try {
|
||||
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(HaloApp.getInstance().getApplication());
|
||||
String json = sp.getString(SETTINGS_KEY, null);
|
||||
String json = getPreferences().getString(SETTINGS_KEY, null);
|
||||
if (!TextUtils.isEmpty(json)) {
|
||||
mSettingsEntity = GsonUtils.getInstance().fromJsonBean(json, SettingsEntity.class);
|
||||
mSettingsEntity = GsonUtils.fromJson(json, SettingsEntity.class);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@ -194,4 +207,27 @@ public class Config {
|
||||
}
|
||||
}
|
||||
|
||||
public static SharedPreferences getPreferences() {
|
||||
return PreferenceManager.getDefaultSharedPreferences(HaloApp.getInstance().getApplication());
|
||||
}
|
||||
|
||||
public static boolean isExistHideFunction() {
|
||||
SharedPreferences preferences = getPreferences();
|
||||
if (!preferences.getBoolean(FIX_DOWNLOAD_KEY, false)) return true;
|
||||
if (!preferences.getBoolean(FIX_PLUGIN_KEY, false)) return true;
|
||||
if (!preferences.getBoolean(FIX_COMMUNITY_KEY, false)) return true;
|
||||
if (!preferences.getBoolean(FIX_ARTICLE_KEY, false)) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void fixHideFunction() {
|
||||
SharedPreferences preferences = PreferenceManager.
|
||||
getDefaultSharedPreferences(HaloApp.getInstance().getApplication());
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
editor.putBoolean(Config.FIX_DOWNLOAD_KEY, true);
|
||||
editor.putBoolean(Config.FIX_ARTICLE_KEY, true);
|
||||
editor.putBoolean(Config.FIX_COMMUNITY_KEY, true);
|
||||
editor.putBoolean(Config.FIX_PLUGIN_KEY, true);
|
||||
editor.apply();
|
||||
}
|
||||
}
|
||||
|
||||
@ -15,6 +15,10 @@ public class Constants {
|
||||
public static final String USER_TOKEN_KEY = "userTokenKey";
|
||||
public static final String USER_INFO_KEY = "userInfoKey";
|
||||
|
||||
public static final String DEVICE_KEY = "deviceKey";
|
||||
|
||||
public static final String XPOSED_INSTALLER_PACKAGE_NAME = "de.robv.android.xposed.installer";
|
||||
|
||||
// 最近显示的弹窗信息
|
||||
public static final String SP_LAST_OPENING_ID = "last_opening_dialog_id";
|
||||
public static final String SP_LAST_OPENING_TIME = "last_opening_dialog_time";
|
||||
@ -43,4 +47,7 @@ public class Constants {
|
||||
//评论 cd间隔
|
||||
public static final int COMMENT_CD = 60 * 1000;
|
||||
|
||||
public static final String[] REPORT_LIST = new String[]{"垃圾广告营销", "恶意攻击谩骂", "淫秽色情信息", "违法有害信息", "其它"};
|
||||
|
||||
public static final String ENTRANCE_UNKNOWN = "(unknown)";
|
||||
}
|
||||
|
||||
@ -26,13 +26,14 @@ public class ItemViewType {
|
||||
public static final int GAME_PLUGIN = 18; // 游戏插件模块
|
||||
public static final int ASK_REFRESH = 19; // 问答精选 刷新
|
||||
public static final int ITEM_EMPTY = 20;
|
||||
public static final int ASK_CONCERN = 21; // 问答精选 关注
|
||||
public static final int RATING_ITEM = 22; // 问答精选 关注
|
||||
|
||||
/**
|
||||
* 普通列表
|
||||
*/
|
||||
public static final int ITEM_BODY = 100;
|
||||
public static final int ITEM_FOOTER = 101;
|
||||
public static final int ITEM_TOP = 102;
|
||||
|
||||
public static final int ITEM_HEADER = 102;
|
||||
|
||||
}
|
||||
|
||||
@ -1,9 +1,6 @@
|
||||
package com.gh.common.databind;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.databinding.BindingAdapter;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v4.widget.SwipeRefreshLayout;
|
||||
import android.text.TextUtils;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MotionEvent;
|
||||
@ -12,6 +9,10 @@ import android.widget.EditText;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.databinding.BindingAdapter;
|
||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
||||
|
||||
import com.facebook.drawee.view.SimpleDraweeView;
|
||||
import com.gh.base.OnViewClickListener;
|
||||
import com.gh.common.constant.Config;
|
||||
@ -20,14 +21,14 @@ import com.gh.common.exposure.ExposureUtils;
|
||||
import com.gh.common.util.DataUtils;
|
||||
import com.gh.common.util.DialogUtils;
|
||||
import com.gh.common.util.DisplayUtils;
|
||||
import com.gh.common.util.DownloadDialogHelper;
|
||||
import com.gh.common.util.GameUtils;
|
||||
import com.gh.common.util.GameViewUtils;
|
||||
import com.gh.common.util.ImageUtils;
|
||||
import com.gh.common.util.KaiFuUtils;
|
||||
import com.gh.common.util.NetworkUtils;
|
||||
import com.gh.common.util.NewsUtils;
|
||||
import com.gh.common.util.NumberUtils;
|
||||
import com.gh.common.util.PackageUtils;
|
||||
import com.gh.common.util.PlatformUtils;
|
||||
import com.gh.common.util.StringUtils;
|
||||
import com.gh.common.view.DownloadDialog;
|
||||
import com.gh.common.view.DownloadProgressBar;
|
||||
@ -40,15 +41,15 @@ import com.gh.gamecenter.databinding.KaifuDetailItemRowBinding;
|
||||
import com.gh.gamecenter.entity.ApkEntity;
|
||||
import com.gh.gamecenter.entity.GameEntity;
|
||||
import com.gh.gamecenter.entity.KaiFuCalendarEntity;
|
||||
import com.gh.gamecenter.entity.PluginLocation;
|
||||
import com.gh.gamecenter.eventbus.EBReuse;
|
||||
import com.gh.gamecenter.manager.PackageManager;
|
||||
import com.gh.gamecenter.manager.PackagesManager;
|
||||
import com.lightgame.download.DownloadEntity;
|
||||
import com.lightgame.download.FileUtils;
|
||||
import com.lightgame.utils.Utils;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
@ -64,12 +65,16 @@ public class BindingAdapters {
|
||||
ImageUtils.displayIcon(view, imageUrl);
|
||||
}
|
||||
|
||||
|
||||
@BindingAdapter("imageUrl")
|
||||
public static void loadImage(SimpleDraweeView view, String imageUrl) {
|
||||
ImageUtils.display(view, imageUrl);
|
||||
}
|
||||
|
||||
@BindingAdapter("setTextSize")
|
||||
public static void setTextSize(TextView view, int number) {
|
||||
view.setTextSize(number);
|
||||
}
|
||||
|
||||
@BindingAdapter({"addDetailKaiFuView", "addDetailKaiFuViewListener", "isReadyPatch"})
|
||||
public static void addDetailKaiFuView(LinearLayout view, List<KaiFuCalendarEntity> list
|
||||
, OnViewClickListener listener, Boolean isReadyPatch) {
|
||||
@ -300,6 +305,7 @@ public class BindingAdapters {
|
||||
}
|
||||
}
|
||||
|
||||
// 大图下的进度条
|
||||
@BindingAdapter({"downloadButton", "traceEvent"})
|
||||
public static void setDownloadButton(DownloadProgressBar progressBar, GameEntity gameEntity, ExposureEvent traceEvent) {
|
||||
// 判断是否显示按钮
|
||||
@ -317,15 +323,13 @@ public class BindingAdapters {
|
||||
progressBar.setText("暂无下载");
|
||||
progressBar.setDownloadType(DownloadProgressBar.DownloadType.NONE);
|
||||
} else {
|
||||
String status = GameUtils.getDownloadBtnText(progressBar.getContext(), gameEntity);
|
||||
String status = GameUtils.getDownloadBtnText(progressBar.getContext(), gameEntity, PluginLocation.only_game);
|
||||
switch (status) {
|
||||
case "插件化":
|
||||
progressBar.setDownloadType(DownloadProgressBar.DownloadType.PLUGIN);
|
||||
break;
|
||||
case "打开":
|
||||
if (gameEntity.getApk().size() == 1) {
|
||||
status = "启动";
|
||||
}
|
||||
case "启动":
|
||||
progressBar.setDownloadType(DownloadProgressBar.DownloadType.LAUNCH_OR_OPEN);
|
||||
break;
|
||||
default:
|
||||
@ -347,7 +351,7 @@ public class BindingAdapters {
|
||||
case neterror:
|
||||
case waiting:
|
||||
progressBar.setText(R.string.downloading);
|
||||
if (downloadEntity.isPluggable() && PackageManager.INSTANCE.isInstalled(downloadEntity.getPackageName())) {
|
||||
if (downloadEntity.isPluggable() && PackagesManager.INSTANCE.isInstalled(downloadEntity.getPackageName())) {
|
||||
progressBar.setDownloadType(DownloadProgressBar.DownloadType.DOWNLOADING_PLUGIN);
|
||||
} else {
|
||||
progressBar.setDownloadType(DownloadProgressBar.DownloadType.DOWNLOADING_NORMAL);
|
||||
@ -356,7 +360,7 @@ public class BindingAdapters {
|
||||
case done:
|
||||
progressBar.setText(R.string.install);
|
||||
if (downloadEntity.isPluggable()
|
||||
&& PackageManager.INSTANCE.isInstalled(downloadEntity.getPackageName())) {
|
||||
&& PackagesManager.INSTANCE.isInstalled(downloadEntity.getPackageName())) {
|
||||
progressBar.setDownloadType(DownloadProgressBar.DownloadType.INSTALL_PLUGIN);
|
||||
} else {
|
||||
progressBar.setDownloadType(DownloadProgressBar.DownloadType.INSTALL_NORMAL);
|
||||
@ -387,13 +391,15 @@ public class BindingAdapters {
|
||||
case NORMAL:
|
||||
case PLUGIN:
|
||||
if (gameEntity.getApk().size() == 1) {
|
||||
if (NetworkUtils.isWifiConnected(v.getContext())) {
|
||||
download(progressBar, gameEntity, traceEvent);
|
||||
} else {
|
||||
DialogUtils.showDownloadDialog(v.getContext(), () -> {
|
||||
download(progressBar, gameEntity, traceEvent);
|
||||
});
|
||||
}
|
||||
ApkEntity apk = gameEntity.getApk().get(0);
|
||||
DownloadDialogHelper.findAvailableDialogAndShow(
|
||||
v.getContext(),
|
||||
gameEntity,
|
||||
apk,
|
||||
() -> {
|
||||
DialogUtils.checkDownload(v.getContext(), apk.getSize(),
|
||||
isSubscribe -> download(progressBar, gameEntity, traceEvent, isSubscribe));
|
||||
});
|
||||
} else {
|
||||
DownloadDialog.getInstance(v.getContext()).showPopupWindow(v, gameEntity,
|
||||
"(我的光环:我的游戏)", "我的光环-我的游戏:" + gameEntity.getName(), traceEvent);
|
||||
@ -416,13 +422,14 @@ public class BindingAdapters {
|
||||
PackageUtils.launchSetup(v.getContext(), downloadEntity.getPath());
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 开始下载
|
||||
private static void download(DownloadProgressBar progressBar, GameEntity
|
||||
gameEntity, ExposureEvent traceEvent) {
|
||||
gameEntity, ExposureEvent traceEvent, boolean isSubscribe) {
|
||||
String str = progressBar.getText();
|
||||
String method;
|
||||
if (str.contains("更新")) {
|
||||
@ -444,6 +451,7 @@ public class BindingAdapters {
|
||||
gameEntity,
|
||||
method,
|
||||
StringUtils.buildString("(我的光环:我的游戏)"), "我的光环-我的游戏:" + gameEntity.getName(),
|
||||
isSubscribe,
|
||||
downloadExposureEvent);
|
||||
|
||||
progressBar.setProgress(0);
|
||||
@ -462,8 +470,8 @@ public class BindingAdapters {
|
||||
View testView = LayoutInflater.from(layout.getContext()).inflate(R.layout.game_test_label, null);
|
||||
TextView testType = testView.findViewById(R.id.test_type);
|
||||
TextView testTime = testView.findViewById(R.id.test_time);
|
||||
String type = gameEntity.getTest().getType();
|
||||
KaiFuUtils.setKaiFuType(testType, type);
|
||||
testType.setText(gameEntity.getTest().getType());
|
||||
testType.setBackgroundColor(ContextCompat.getColor(layout.getContext(), R.color.tag_yellow));
|
||||
|
||||
if (gameEntity.getTest().getStart() == 0) {
|
||||
testTime.setVisibility(View.GONE);
|
||||
@ -485,4 +493,16 @@ public class BindingAdapters {
|
||||
layout.setRefreshing(false);
|
||||
}
|
||||
}
|
||||
|
||||
@BindingAdapter({"setGameName", "isShowPlatform"})
|
||||
public static void setGameName(TextView view, GameEntity game, boolean isShowPlatform) {
|
||||
if (isShowPlatform && game.getApk().size() > 0) {
|
||||
view.setText(String.format("%s - %s", game.getName(),
|
||||
PlatformUtils.getInstance(view.getContext()).getPlatformName(
|
||||
game.getApk().get(0).getPlatform())));
|
||||
} else {
|
||||
view.setText(game.getName());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
181
app/src/main/java/com/gh/common/dialog/ReserveDialogFragment.kt
Normal file
181
app/src/main/java/com/gh/common/dialog/ReserveDialogFragment.kt
Normal file
@ -0,0 +1,181 @@
|
||||
package com.gh.common.dialog
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.app.Application
|
||||
import android.os.Bundle
|
||||
import android.text.Html
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.EditText
|
||||
import android.widget.TextView
|
||||
import androidx.lifecycle.AndroidViewModel
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import butterknife.BindView
|
||||
import butterknife.ButterKnife
|
||||
import butterknife.OnClick
|
||||
import com.gh.common.constant.Config
|
||||
import com.gh.common.repository.ReservationRepository
|
||||
import com.gh.common.util.*
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.entity.GameEntity
|
||||
import com.gh.gamecenter.manager.UserManager
|
||||
import com.gh.gamecenter.retrofit.BiResponse
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager
|
||||
import com.lightgame.dialog.BaseDialogFragment
|
||||
import com.lightgame.utils.Utils
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
import okhttp3.ResponseBody
|
||||
|
||||
class ReserveDialogFragment : BaseDialogFragment() {
|
||||
|
||||
@BindView(R.id.reserve_hint_tv)
|
||||
lateinit var reserveHintTv: TextView
|
||||
@BindView(R.id.reserve_content_tv)
|
||||
lateinit var reserveContentTv: TextView
|
||||
@BindView(R.id.reserve_completed_content_tv)
|
||||
lateinit var reserveCompletedContentTv: TextView
|
||||
@BindView(R.id.mobile_et)
|
||||
lateinit var mobileEt: EditText
|
||||
@BindView(R.id.reserve_container)
|
||||
lateinit var reserveContainer: View
|
||||
@BindView(R.id.reserve_completed_container)
|
||||
lateinit var reserveCompletedContainer: View
|
||||
@BindView(R.id.customizable_btn)
|
||||
lateinit var customizableBtn: TextView
|
||||
|
||||
private lateinit var mViewModel: ReserveViewModel
|
||||
|
||||
private var mSuccessCallback: SuccessCallback? = null
|
||||
|
||||
private var mGameId: String = ""
|
||||
private var mGameName: String = ""
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
mViewModel = viewModelProvider()
|
||||
}
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||
return inflater.inflate(R.layout.dialog_reserve_game, null)
|
||||
}
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
@SuppressLint("SetTextI18n")
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
ButterKnife.bind(this, view)
|
||||
|
||||
val reserveContent = "游戏上线,您将<font color='#ff4147'>免费</font>收到短信提醒"
|
||||
|
||||
reserveContentTv.text = Html.fromHtml(reserveContent)
|
||||
mobileEt.setText(UserManager.getInstance().userInfoEntity.mobile)
|
||||
mobileEt.setSelection(mobileEt.text.length)
|
||||
|
||||
mViewModel.reservation.observeNonNull(this) {
|
||||
if (it.success) {
|
||||
showSuccessDialog(it.withMobile)
|
||||
mSuccessCallback?.onSuccess()
|
||||
}
|
||||
}
|
||||
dialog.setCanceledOnTouchOutside(true)
|
||||
}
|
||||
|
||||
private fun showSuccessDialog(withMobile: Boolean) {
|
||||
reserveHintTv.text = "游戏预约成功"
|
||||
reserveContainer.visibility = View.GONE
|
||||
reserveCompletedContainer.visibility = View.VISIBLE
|
||||
|
||||
val reservation = Config.getSettings()?.appointment
|
||||
val dialogConfig = if (withMobile) reservation?.withMobile else reservation?.withoutMobile
|
||||
|
||||
reserveCompletedContentTv.text = Html.fromHtml(dialogConfig?.htmlContent)
|
||||
if (dialogConfig?.text.isNullOrEmpty()
|
||||
|| dialogConfig?.toLinkEntity()?.link.isNullOrEmpty()) {
|
||||
customizableBtn.visibility = View.GONE
|
||||
} else {
|
||||
customizableBtn.text = dialogConfig?.text
|
||||
customizableBtn.setOnClickListener {
|
||||
DirectUtils.directToLinkPage(
|
||||
requireContext(),
|
||||
dialogConfig!!.toLinkEntity(),
|
||||
"(游戏预约)",
|
||||
"")
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@OnClick(R.id.reserve_with_mobile_btn,
|
||||
R.id.reserve_without_mobile_btn,
|
||||
R.id.close_btn,
|
||||
R.id.customizable_btn)
|
||||
fun onClick(view: View) {
|
||||
when (view.id) {
|
||||
R.id.reserve_without_mobile_btn -> {
|
||||
mViewModel.reserve(gameId = mGameId, gameName = mGameName)
|
||||
}
|
||||
|
||||
R.id.reserve_with_mobile_btn -> {
|
||||
val mobile = mobileEt.text.toString()
|
||||
if (mobile.length < 11 || !mobile.startsWith("1")) {
|
||||
Utils.toast(context, "手机号格式错误,请检查并重新输入")
|
||||
return
|
||||
}
|
||||
|
||||
mViewModel.reserve(gameId = mGameId, gameName = mGameName, mobile = mobile)
|
||||
}
|
||||
|
||||
R.id.close_btn -> {
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun getInstance(gameEntity: GameEntity, successCallback: SuccessCallback) = ReserveDialogFragment().apply {
|
||||
this.mGameId = gameEntity.id
|
||||
this.mGameName = gameEntity.name ?: ""
|
||||
this.mSuccessCallback = successCallback
|
||||
}
|
||||
}
|
||||
|
||||
interface SuccessCallback {
|
||||
fun onSuccess()
|
||||
}
|
||||
}
|
||||
|
||||
class ReserveViewModel(application: Application) : AndroidViewModel(application) {
|
||||
val reservation = MutableLiveData<Reservation>()
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
fun reserve(gameId: String, gameName: String, mobile: String = "") {
|
||||
|
||||
val requestMap = hashMapOf<String, String>()
|
||||
requestMap["game_id"] = gameId
|
||||
if (mobile.isNotEmpty()) {
|
||||
requestMap["mobile"] = mobile
|
||||
}
|
||||
|
||||
RetrofitManager.getInstance(getApplication()).api
|
||||
.createNewGameReservation(requestMap.createRequestBody())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.subscribe(object : BiResponse<ResponseBody>() {
|
||||
override fun onSuccess(data: ResponseBody) {
|
||||
reservation.postValue(Reservation(success = true, withMobile = mobile.isNotEmpty()))
|
||||
ReservationRepository.addReservationToMemoryAndRefresh(gameId)
|
||||
|
||||
MtaHelper.onEvent("预约游戏", "预约", gameName)
|
||||
}
|
||||
|
||||
override fun onFailure(exception: Exception) {
|
||||
Utils.toast(getApplication(), exception.message)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
class Reservation(var success: Boolean = false, var withMobile: Boolean = false)
|
||||
|
||||
}
|
||||
@ -1,8 +1,8 @@
|
||||
package com.gh.common.exposure
|
||||
|
||||
import android.arch.persistence.room.TypeConverter
|
||||
import androidx.room.TypeConverter
|
||||
import com.gh.common.exposure.meta.Meta
|
||||
import com.google.gson.Gson
|
||||
import com.gh.common.util.GsonUtils
|
||||
import java.util.*
|
||||
import kotlin.collections.ArrayList
|
||||
|
||||
@ -10,32 +10,32 @@ class ExposureConverters {
|
||||
|
||||
@TypeConverter
|
||||
fun convertPayload2String(any: ExposureEntity): String {
|
||||
return Gson().toJson(any)
|
||||
return GsonUtils.toJson(any)
|
||||
}
|
||||
|
||||
@TypeConverter
|
||||
fun convertString2Payload(string: String): ExposureEntity {
|
||||
return Gson().fromJson(string, ExposureEntity::class.java)
|
||||
return GsonUtils.fromJson(string, ExposureEntity::class.java)
|
||||
}
|
||||
|
||||
@TypeConverter
|
||||
fun convertSource2String(sourceList: List<ExposureSource>): String {
|
||||
return Gson().toJson(sourceList)
|
||||
return GsonUtils.toJson(sourceList)
|
||||
}
|
||||
|
||||
@TypeConverter
|
||||
fun convertString2Source(sourceList: String): List<ExposureSource> {
|
||||
return ArrayList(Arrays.asList(Gson().fromJson(sourceList, Array<ExposureSource>::class.java))) as List<ExposureSource>
|
||||
return ArrayList(Arrays.asList(GsonUtils.fromJson(sourceList, Array<ExposureSource>::class.java))) as List<ExposureSource>
|
||||
}
|
||||
|
||||
@TypeConverter
|
||||
fun convertETrace2String(sourceList: List<ExposureEvent>?): String {
|
||||
return Gson().toJson(sourceList)
|
||||
return GsonUtils.toJson(sourceList)
|
||||
}
|
||||
|
||||
@TypeConverter
|
||||
fun convertStringToETrace(sourceList: String): List<ExposureEvent> {
|
||||
return ArrayList(Arrays.asList(Gson().fromJson(sourceList, Array<ExposureEvent>::class.java))) as List<ExposureEvent>
|
||||
return ArrayList(Arrays.asList(GsonUtils.fromJson(sourceList, Array<ExposureEvent>::class.java))) as List<ExposureEvent>
|
||||
}
|
||||
|
||||
@TypeConverter
|
||||
@ -50,12 +50,12 @@ class ExposureConverters {
|
||||
|
||||
@TypeConverter
|
||||
fun convertMeta2String(any: Meta): String {
|
||||
return Gson().toJson(any)
|
||||
return GsonUtils.toJson(any)
|
||||
}
|
||||
|
||||
@TypeConverter
|
||||
fun convertString2Meta(string: String): Meta {
|
||||
return Gson().fromJson(string, Meta::class.java)
|
||||
return GsonUtils.fromJson(string, Meta::class.java)
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,9 +1,9 @@
|
||||
package com.gh.common.exposure
|
||||
|
||||
import android.arch.persistence.room.Database
|
||||
import android.arch.persistence.room.Room
|
||||
import android.arch.persistence.room.RoomDatabase
|
||||
import android.arch.persistence.room.TypeConverters
|
||||
import androidx.room.Database
|
||||
import androidx.room.Room
|
||||
import androidx.room.RoomDatabase
|
||||
import androidx.room.TypeConverters
|
||||
import android.content.Context
|
||||
|
||||
@TypeConverters(ExposureConverters::class)
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
package com.gh.common.exposure
|
||||
|
||||
import android.os.Parcelable
|
||||
import android.support.annotation.Keep
|
||||
import androidx.annotation.Keep
|
||||
import com.google.gson.annotations.SerializedName
|
||||
import kotlinx.android.parcel.Parcelize
|
||||
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
package com.gh.common.exposure
|
||||
|
||||
import android.arch.persistence.room.Entity
|
||||
import android.arch.persistence.room.PrimaryKey
|
||||
import androidx.room.Entity
|
||||
import androidx.room.PrimaryKey
|
||||
import android.os.Parcelable
|
||||
import android.support.annotation.Keep
|
||||
import androidx.annotation.Keep
|
||||
import com.gh.common.exposure.meta.Meta
|
||||
import com.gh.common.exposure.meta.MetaUtil
|
||||
import com.gh.common.exposure.time.TimeUtil
|
||||
@ -15,7 +15,7 @@ import java.util.*
|
||||
@Parcelize
|
||||
@Entity(tableName = "exposureEvent")
|
||||
data class ExposureEvent(
|
||||
val payload: ExposureEntity,
|
||||
var payload: ExposureEntity,
|
||||
val source: List<ExposureSource>,
|
||||
var eTrace: List<ExposureEvent>? = arrayListOf(),
|
||||
val event: ExposureType,
|
||||
@ -26,7 +26,7 @@ data class ExposureEvent(
|
||||
companion object {
|
||||
fun createEvent(gameEntity: GameEntity?, source: List<ExposureSource>, eTrace: List<ExposureEvent>?, event: ExposureType): ExposureEvent {
|
||||
return ExposureEvent(
|
||||
ExposureEntity(gameId = gameEntity?.id,
|
||||
payload = ExposureEntity(gameId = gameEntity?.id,
|
||||
gameName = gameEntity?.name,
|
||||
sequence = gameEntity?.sequence,
|
||||
platform = gameEntity?.platform,
|
||||
|
||||
@ -1,10 +1,9 @@
|
||||
package com.gh.common.exposure
|
||||
|
||||
import android.arch.persistence.room.*
|
||||
import androidx.room.*
|
||||
|
||||
@Dao
|
||||
interface ExposureEventDao {
|
||||
|
||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||
fun insertMany(eventList: List<ExposureEvent>)
|
||||
|
||||
|
||||
@ -1,16 +1,13 @@
|
||||
package com.gh.common.exposure
|
||||
|
||||
import android.support.v4.app.Fragment
|
||||
import android.support.v4.app.FragmentManager
|
||||
import android.support.v7.widget.LinearLayoutManager
|
||||
import android.support.v7.widget.RecyclerView
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.FragmentManager
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import io.reactivex.functions.Consumer
|
||||
|
||||
/**
|
||||
* Exposure Event Listener for RecyclerView
|
||||
*
|
||||
* TODO 1. Pull down refresh change in first page without scroll down action
|
||||
* TODO 2. Item change not triggered by user scroll action (vm data change etc.)
|
||||
*/
|
||||
class ExposureListener(var fragment: Fragment, var exposable: IExposable) : RecyclerView.OnScrollListener() {
|
||||
|
||||
@ -21,11 +18,11 @@ class ExposureListener(var fragment: Fragment, var exposable: IExposable) : Recy
|
||||
init {
|
||||
fragment.fragmentManager?.registerFragmentLifecycleCallbacks(
|
||||
object : FragmentManager.FragmentLifecycleCallbacks() {
|
||||
override fun onFragmentResumed(fm: FragmentManager?, f: Fragment?) {
|
||||
override fun onFragmentResumed(fm: FragmentManager, f: Fragment) {
|
||||
throttleBus = ExposureThrottleBus(Consumer { commitExposure(it) }, Consumer(Throwable::printStackTrace))
|
||||
}
|
||||
|
||||
override fun onFragmentPaused(fm: FragmentManager?, f: Fragment?) {
|
||||
override fun onFragmentPaused(fm: FragmentManager, f: Fragment) {
|
||||
visibleState?.let { commitExposure(it) }
|
||||
throttleBus?.clear()
|
||||
}
|
||||
@ -48,8 +45,7 @@ class ExposureListener(var fragment: Fragment, var exposable: IExposable) : Recy
|
||||
}
|
||||
|
||||
/**
|
||||
* Check disappearMap items together with according data in displayMap,
|
||||
* log any items displayed long enough to be called a EXPOSURE
|
||||
* Just commit the exposureEvent that is stored in listItem.
|
||||
*/
|
||||
private fun commitExposure(visibleState: ExposureThrottleBus.VisibleState) {
|
||||
|
||||
@ -59,8 +55,8 @@ class ExposureListener(var fragment: Fragment, var exposable: IExposable) : Recy
|
||||
try {
|
||||
exposable.getEventByPosition(pos)?.let { eventList.add(it) }
|
||||
exposable.getEventListByPosition(pos)?.let { eventList.addAll(it) }
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
} catch (ignore: Exception) {
|
||||
// Just ignore the error.
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,185 +1,140 @@
|
||||
package com.gh.common.exposure
|
||||
|
||||
import android.app.Application
|
||||
import com.aliyun.sls.android.sdk.LogException
|
||||
import com.aliyun.sls.android.sdk.model.LogGroup
|
||||
import com.gh.common.exposure.aliyun.LGLOG
|
||||
import com.gh.common.exposure.aliyun.LGLOGClient
|
||||
import com.gh.common.exposure.meta.MetaUtil
|
||||
import com.gh.common.exposure.time.TimeUtil
|
||||
import com.gh.common.util.toJson
|
||||
import com.gh.gamecenter.BuildConfig
|
||||
import com.google.gson.Gson
|
||||
import com.gh.loghub.LgLOG
|
||||
import com.gh.loghub.LoghubHelper
|
||||
import com.halo.assistant.HaloApp
|
||||
import com.lightgame.utils.Utils
|
||||
import java.util.concurrent.Executors
|
||||
import kotlin.concurrent.fixedRateTimer
|
||||
|
||||
/**
|
||||
* ExposureManager tool to commit logs to aliyun loghub
|
||||
* TODO handle logs that failed to be committed multiple times
|
||||
* A handful tool for committing logs to aliyun loghub.
|
||||
*
|
||||
* 如何简单地统计列表中每个 item 的曝光事件?
|
||||
*
|
||||
* 1. Adapter 实现 IExposable 接口,在 BindView 阶段更新 ExposureEvent,ExposureEvent 供 getEventByPosition(pos) 方法获取用
|
||||
* 2. 构建一个 ExposureListener 并作为入参添加至 recyclerview 的 Scroll 回调中
|
||||
* 3. 没了
|
||||
*/
|
||||
object ExposureManager {
|
||||
|
||||
private var TAG: String = ExposureManager::class.java.simpleName
|
||||
|
||||
private const val ACCESS_KEY_ID = "LTAIV3i0sNc4TPK1"
|
||||
private const val ACCESS_KEY_SECRET = "8dKtTPeE5WYA6ZCeuIBcIVp7eB0ir4"
|
||||
private const val ENDPOINT = "cn-qingdao.log.aliyuncs.com"
|
||||
private const val PROJECT = "ghzs"
|
||||
private const val STORE_SIZE = 100
|
||||
private const val STORE_FORCE_UPLOAD_PERIOD = 300 * 1000L
|
||||
private const val LOG_STORE = BuildConfig.EXPOSURE_REPO
|
||||
|
||||
private var LOG_STORE = BuildConfig.EXPOSURE_REPO
|
||||
private val loghubHelper = LoghubHelper.getInstance()
|
||||
|
||||
private lateinit var client: LGLOGClient
|
||||
private lateinit var db: ExposureEventDao
|
||||
private val storeSet = hashSetOf<ExposureEvent>()
|
||||
private val storeOpThread = Executors.newSingleThreadExecutor()
|
||||
private val gson = Gson()
|
||||
// exposureCache 用来过滤掉具有相同 id 的曝光事件,避免重复发送事件
|
||||
private val exposureCache = FixedSizeLinkedHashSet<String>(100)
|
||||
private val exposureSet = hashSetOf<ExposureEvent>()
|
||||
private val exposureDao by lazy { ExposureDatabase.buildDatabase(HaloApp.getInstance().application).logHubEventDao() }
|
||||
private val exposureExecutor = Executors.newSingleThreadExecutor()
|
||||
|
||||
private val exposureCache = FixedSizeLinkedHashSet<String>(20)
|
||||
@JvmStatic
|
||||
fun init() {
|
||||
TimeUtil.init()
|
||||
|
||||
/**
|
||||
* Must be called early to init object then real use (for example in Application)
|
||||
*/
|
||||
fun init(application: Application) {
|
||||
loghubHelper.init(HaloApp.getInstance().application, ENDPOINT, PROJECT, LOG_STORE) { TimeUtil.currentTimeMillis() }
|
||||
|
||||
client = LGLOGClient(ENDPOINT, ACCESS_KEY_ID, ACCESS_KEY_SECRET, PROJECT)
|
||||
db = ExposureDatabase.buildDatabase(application).logHubEventDao()
|
||||
|
||||
storeOpThread.execute {
|
||||
val eventList = db.getAll()
|
||||
storeSet.addAll(eventList)
|
||||
exposureExecutor.execute {
|
||||
val eventList = exposureDao.getAll()
|
||||
exposureSet.addAll(eventList)
|
||||
}
|
||||
|
||||
fixedRateTimer(name = "ExposureManager-Store-Checker", initialDelay = 500, period = STORE_FORCE_UPLOAD_PERIOD) {
|
||||
checkAndUploadFromDatabase(true)
|
||||
}
|
||||
|
||||
MetaUtil.init(application)
|
||||
TimeUtil.init()
|
||||
}
|
||||
|
||||
/**
|
||||
* Log an Event
|
||||
*/
|
||||
fun log(event: ExposureEvent, uploadImmediately: Boolean = false) {
|
||||
when (uploadImmediately) {
|
||||
false -> store(event)
|
||||
true -> upload(event)
|
||||
commitSavedExposureEvent(true)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Log Many Events
|
||||
* Log a single exposure event.
|
||||
*/
|
||||
fun log(eventList: List<ExposureEvent>, uploadImmediately: Boolean = false) {
|
||||
when (uploadImmediately) {
|
||||
false -> store(eventList)
|
||||
true -> upload(eventList)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Store an Event to storeSet, upload when storeSet size exceeds STORE_SIZE
|
||||
*/
|
||||
private fun store(event: ExposureEvent) {
|
||||
storeOpThread.execute {
|
||||
fun log(event: ExposureEvent) {
|
||||
exposureExecutor.execute {
|
||||
if (!exposureCache.contains(event.id)) {
|
||||
storeSet.add(event)
|
||||
db.insert(event)
|
||||
exposureCache.add(event.id)
|
||||
// Catch `android.database.sqlite.SQLiteFullException: database or disk is full` exception.
|
||||
try {
|
||||
exposureSet.add(event)
|
||||
exposureDao.insert(event)
|
||||
exposureCache.add(event.id)
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
} else {
|
||||
Utils.log("Exposure", "遇到重复曝光事件,自动过滤 (${event.id} - ${event.payload.gameName})")
|
||||
}
|
||||
checkAndUploadFromDatabase()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Store Many Events to storeSet, upload when storeSet size exceeds STORE_SIZE
|
||||
* Log a collection of exposure event.
|
||||
*/
|
||||
private fun store(eventList: List<ExposureEvent>) {
|
||||
storeOpThread.execute {
|
||||
fun log(eventList: List<ExposureEvent>) {
|
||||
exposureExecutor.execute {
|
||||
for (event in eventList) {
|
||||
if (!exposureCache.contains(event.id)) {
|
||||
storeSet.add(event)
|
||||
db.insert(event)
|
||||
exposureCache.add(event.id)
|
||||
// Catch `android.database.sqlite.SQLiteFullException: database or disk is full` exception.
|
||||
try {
|
||||
exposureSet.add(event)
|
||||
exposureDao.insert(event)
|
||||
exposureCache.add(event.id)
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
} else {
|
||||
Utils.log("Exposure", "遇到重复曝光事件,自动过滤 (${event.id} - ${event.payload.gameName})")
|
||||
}
|
||||
}
|
||||
|
||||
commitSavedExposureEvent()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Upload an Event
|
||||
*/
|
||||
private fun upload(event: ExposureEvent) {
|
||||
storeOpThread.execute {
|
||||
client.PostLog(buildLogGroup(event), LOG_STORE)
|
||||
fun commitSavedExposureEvent(forced: Boolean = false) {
|
||||
exposureExecutor.execute {
|
||||
if (exposureSet.size < STORE_SIZE && !forced || exposureSet.size == 0) return@execute
|
||||
|
||||
val exposureList = exposureSet.toList()
|
||||
// uploadLogGroup 是一个异步方法,LoghubHelper 里面实现了重传功能,所以这里交给它就好了
|
||||
loghubHelper.uploadLogGroup(buildLogGroup(exposureList))
|
||||
|
||||
Utils.log("Exposure", "提交了${exposureList.size}条曝光记录")
|
||||
exposureSet.removeAll(exposureList)
|
||||
exposureDao.deleteMany(exposureList)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Upload Many Events
|
||||
*/
|
||||
private fun upload(eventList: List<ExposureEvent>) {
|
||||
storeOpThread.execute {
|
||||
client.PostLog(buildLogGroup(eventList), LOG_STORE)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Upload Events From Store, and removed them
|
||||
*/
|
||||
private fun checkAndUploadFromDatabase(isForceUpload: Boolean = false) {
|
||||
storeOpThread.execute {
|
||||
if (storeSet.size < STORE_SIZE && !isForceUpload || storeSet.size == 0) return@execute
|
||||
val uploaded = storeSet.toList()
|
||||
try {
|
||||
client.PostLog(buildLogGroup(uploaded), LOG_STORE)
|
||||
} catch (exception: LogException) {
|
||||
// Return to insure no logs lost because of online commit failure
|
||||
return@execute
|
||||
}
|
||||
storeSet.removeAll(uploaded)
|
||||
db.deleteMany(uploaded)
|
||||
}
|
||||
}
|
||||
|
||||
private fun buildLog(event: ExposureEvent): LGLOG {
|
||||
val log = LGLOG()
|
||||
|
||||
log.PutContent("id", event.id)
|
||||
log.PutContent("payload", gson.toJson(event.payload))
|
||||
log.PutContent("event", event.event.toString())
|
||||
log.PutContent("source", eliminateMultipleBrackets(gson.toJson(event.source)))
|
||||
log.PutContent("meta", gson.toJson(event.meta))
|
||||
log.PutContent("e-traces", if (event.eTrace != null) eliminateMultipleBrackets(gson.toJson(event.eTrace)) else "")
|
||||
log.PutTime(event.time)
|
||||
|
||||
return log
|
||||
}
|
||||
|
||||
private fun eliminateMultipleBrackets(jsonWithMultipleBracket: String): String {
|
||||
return jsonWithMultipleBracket.replace("[[", "[").replace("]]", "]")
|
||||
}
|
||||
|
||||
private fun buildLogGroup(event: ExposureEvent): LogGroup {
|
||||
|
||||
private fun buildLogGroup(eventList: List<ExposureEvent>): LogGroup {
|
||||
val logGroup = LogGroup("sls android", "no ip")
|
||||
|
||||
logGroup.PutLog(buildLog(event))
|
||||
eventList.forEach { logGroup.PutLog(buildLog(it)) }
|
||||
|
||||
return logGroup
|
||||
}
|
||||
|
||||
private fun buildLogGroup(eventList: List<ExposureEvent>): LogGroup {
|
||||
private fun buildLog(event: ExposureEvent): LgLOG {
|
||||
val log = LgLOG(TimeUtil.currentTime())
|
||||
|
||||
val logGroup = LogGroup("sls android", "no ip")
|
||||
log.PutContent("id", event.id)
|
||||
log.PutContent("payload", event.payload.toJson())
|
||||
log.PutContent("event", event.event.toString())
|
||||
log.PutContent("source", eliminateMultipleBrackets(event.source.toJson()))
|
||||
log.PutContent("meta", event.meta.toJson())
|
||||
log.PutContent("e-traces", if (event.eTrace != null) {
|
||||
eliminateMultipleBrackets(event.eTrace?.toJson() ?: "")
|
||||
} else "")
|
||||
log.PutTime(event.time)
|
||||
|
||||
eventList.forEach { event ->
|
||||
logGroup.PutLog(buildLog(event))
|
||||
}
|
||||
|
||||
return logGroup
|
||||
return log
|
||||
}
|
||||
|
||||
internal class FixedSizeLinkedHashSet<T>(var maxSize: Int) : LinkedHashSet<T>() {
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
package com.gh.common.exposure
|
||||
|
||||
import android.os.Parcelable
|
||||
import android.support.annotation.Keep
|
||||
import androidx.annotation.Keep
|
||||
import kotlinx.android.parcel.Parcelize
|
||||
|
||||
@Keep
|
||||
|
||||
@ -1,15 +1,16 @@
|
||||
package com.gh.common.exposure
|
||||
|
||||
import com.gh.common.util.toObject
|
||||
import com.gh.gamecenter.entity.GameEntity
|
||||
import com.google.gson.Gson
|
||||
import java.util.*
|
||||
|
||||
object ExposureUtils {
|
||||
|
||||
val gson = Gson()
|
||||
|
||||
@JvmStatic
|
||||
fun logADownloadExposureEvent(entity: GameEntity, platform: String?, traceEvent: ExposureEvent?, downloadType: DownloadType): ExposureEvent {
|
||||
fun logADownloadExposureEvent(entity: GameEntity,
|
||||
platform: String?,
|
||||
traceEvent: ExposureEvent?,
|
||||
downloadType: DownloadType): ExposureEvent {
|
||||
val gameEntity = entity.clone()
|
||||
gameEntity.platform = platform
|
||||
gameEntity.downloadType = downloadType.toString()
|
||||
@ -17,21 +18,25 @@ object ExposureUtils {
|
||||
source = traceEvent?.source ?: ArrayList(),
|
||||
eTrace = ExposureTraceUtils.appendTrace(traceEvent),
|
||||
event = ExposureType.DOWNLOAD)
|
||||
ExposureManager.log(exposureEvent, false)
|
||||
ExposureManager.log(exposureEvent)
|
||||
return exposureEvent
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun logADownloadCompleteExposureEvent(entity: GameEntity, platform: String?, trace: String?, downloadType: DownloadType) {
|
||||
fun logADownloadCompleteExposureEvent(entity: GameEntity,
|
||||
platform: String?,
|
||||
trace: String?,
|
||||
downloadType: DownloadType) {
|
||||
val gameEntity = entity.clone()
|
||||
gameEntity.platform = platform
|
||||
gameEntity.downloadCompleteType = downloadType.toString()
|
||||
val traceEvent = gson.fromJson(trace, ExposureEvent::class.java)
|
||||
val traceEvent = trace?.toObject<ExposureEvent>()
|
||||
val exposureEvent = ExposureEvent.createEvent(gameEntity = gameEntity,
|
||||
source = traceEvent?.source ?: ArrayList(),
|
||||
eTrace = ExposureTraceUtils.appendTrace(traceEvent),
|
||||
event = ExposureType.DOWNLOAD_COMPLETE)
|
||||
ExposureManager.log(exposureEvent, false)
|
||||
ExposureManager.log(exposureEvent)
|
||||
ExposureManager.commitSavedExposureEvent(forced = true)
|
||||
}
|
||||
|
||||
enum class DownloadType {
|
||||
|
||||
@ -1,7 +1,11 @@
|
||||
package com.gh.common.exposure
|
||||
|
||||
/**
|
||||
* 统计曝光的列表的 adapter 需要实现这个接口
|
||||
*/
|
||||
interface IExposable {
|
||||
fun getEventByPosition(pos: Int): ExposureEvent?
|
||||
|
||||
// 部分列表的 item 内嵌套了 recyclerview 这里获取这个 item 所携带的所有事件
|
||||
fun getEventListByPosition(pos: Int): List<ExposureEvent>?
|
||||
}
|
||||
@ -1,42 +0,0 @@
|
||||
package com.gh.common.exposure.aliyun;
|
||||
|
||||
import com.aliyun.sls.android.sdk.model.Log;
|
||||
import com.gh.common.exposure.time.TimeUtil;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Extend to change __time__ field in mContent to use the correct time from TimeUtil
|
||||
*/
|
||||
public class LGLOG extends Log {
|
||||
|
||||
private Map<String, Object> mContent = new HashMap<String, Object>();
|
||||
|
||||
public LGLOG() {
|
||||
mContent.put("__time__", TimeUtil.INSTANCE.currentTime());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void PutTime(int time) {
|
||||
mContent.put("__time__", time);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void PutContent(String key, String value) {
|
||||
if (key == null || key.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
if (value == null) {
|
||||
mContent.put(key, "");
|
||||
} else {
|
||||
mContent.put(key, value);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> GetContent() {
|
||||
return mContent;
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,67 +0,0 @@
|
||||
package com.gh.common.exposure.aliyun;
|
||||
|
||||
import com.aliyun.sls.android.sdk.LOGClient;
|
||||
import com.aliyun.sls.android.sdk.LogException;
|
||||
import com.gh.common.exposure.time.TimeUtil;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.TimeZone;
|
||||
|
||||
/**
|
||||
* Extend to override GetHttpHeadersFrom, so we can change "Date" header attribute using
|
||||
* correct time from TimeUtil.
|
||||
* And accordingly, the value of "Authorization" attribute should also be re-calculate
|
||||
* since the sign became different as before.
|
||||
*/
|
||||
public class LGLOGClient extends LOGClient {
|
||||
|
||||
private String mAccessKeyID;
|
||||
private String mAccessKeySecret;
|
||||
private String mAccessToken;
|
||||
|
||||
public LGLOGClient(String endPoint, String accessKeyID, String accessKeySecret, String projectName) {
|
||||
super(endPoint, accessKeyID, accessKeySecret, projectName);
|
||||
this.mAccessKeyID = accessKeyID;
|
||||
this.mAccessKeySecret = accessKeySecret;
|
||||
this.mAccessToken = "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> GetHttpHeadersFrom(String logStoreName, byte[] body, byte[] bodyZipped) throws LogException {
|
||||
|
||||
Map<String, String> headers = super.GetHttpHeadersFrom(logStoreName, body, bodyZipped);
|
||||
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z", Locale.US);
|
||||
sdf.setTimeZone(TimeZone.getTimeZone("GMT")); // 设置时区为GMT
|
||||
String str = sdf.format(new Date(TimeUtil.INSTANCE.currentTimeMillis()));
|
||||
headers.put("Date", str);
|
||||
|
||||
StringBuilder signStringBuf = new StringBuilder("POST" + "\n").
|
||||
append(headers.get("Content-MD5") + "\n").
|
||||
append(headers.get("Content-Type") + "\n").
|
||||
append(headers.get("Date") + "\n");
|
||||
String token = mAccessToken;
|
||||
if (token != null && token != "") {
|
||||
headers.put("x-acs-security-token", token);
|
||||
signStringBuf.append("x-acs-security-token:" + headers.get("x-acs-security-token") + "\n");
|
||||
}
|
||||
signStringBuf.append("x-log-apiversion:0.6.0\n").
|
||||
append("x-log-bodyrawsize:" + headers.get("x-log-bodyrawsize") + "\n").
|
||||
append("x-log-compresstype:deflate\n").
|
||||
append("x-log-signaturemethod:hmac-sha1\n").
|
||||
append("/logstores/" + logStoreName + "/shards/lb");
|
||||
String signString = signStringBuf.toString();
|
||||
try {
|
||||
String sign = hmac_sha1(signString, mAccessKeySecret);
|
||||
headers.put("Authorization", "LOG " + mAccessKeyID + ":" + sign);
|
||||
} catch (Exception e) {
|
||||
throw new LogException("LogClientError", "fail to get encode signature", e, "");
|
||||
}
|
||||
|
||||
return headers;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -1,7 +1,7 @@
|
||||
package com.gh.common.exposure.meta
|
||||
|
||||
import android.os.Parcelable
|
||||
import android.support.annotation.Keep
|
||||
import androidx.annotation.Keep
|
||||
import kotlinx.android.parcel.Parcelize
|
||||
|
||||
@Keep
|
||||
@ -15,10 +15,11 @@ data class Meta(
|
||||
val android_sdk: Int? = -1,
|
||||
val android_version: String? = "",
|
||||
val network: String? = "",
|
||||
val ip: String? = "",
|
||||
val os: String? = "",
|
||||
val gid: String? = "",
|
||||
val channel: String? = "",
|
||||
val appVersion: String? = "",
|
||||
val userId: String? = "",
|
||||
val exposureVersion: String? = ""
|
||||
val exposureVersion: String? = "",
|
||||
val rom: String? = ""
|
||||
) : Parcelable
|
||||
@ -12,23 +12,34 @@ import android.telephony.TelephonyManager
|
||||
import android.text.TextUtils
|
||||
import com.gh.gamecenter.BuildConfig
|
||||
import com.gh.gamecenter.manager.UserManager
|
||||
import com.halo.assistant.HaloApp
|
||||
import com.leon.channel.helper.ChannelReaderUtil
|
||||
import com.walkud.rom.checker.RomIdentifier
|
||||
import java.io.File
|
||||
|
||||
object MetaUtil {
|
||||
|
||||
private lateinit var application: Application
|
||||
private val application: Application = HaloApp.getInstance().application
|
||||
private var channel = ""
|
||||
|
||||
private var m: Meta? = null
|
||||
|
||||
fun init(application: Application) {
|
||||
MetaUtil.application = application
|
||||
}
|
||||
|
||||
fun refreshMeta() {
|
||||
m = Meta(getMac(), getIMEI(), getModel(), getManufacturer(), getAndroidId(), getAndroidSDK(),
|
||||
getAndroidVersion(), getNetwork(), getIP(), getOS(), getChannel(), BuildConfig.VERSION_NAME, UserManager.getInstance().userId, BuildConfig.EXPOSURE_VERSION)
|
||||
m = Meta(mac = getMac(),
|
||||
imei = getIMEI(),
|
||||
model = getModel(),
|
||||
manufacturer = getManufacturer(),
|
||||
android_id = getAndroidId(),
|
||||
android_sdk = getAndroidSDK(),
|
||||
android_version = getAndroidVersion(),
|
||||
network = getNetwork(),
|
||||
os = getOS(),
|
||||
gid = HaloApp.getInstance().gid,
|
||||
channel = getChannel(),
|
||||
appVersion = BuildConfig.VERSION_NAME,
|
||||
userId = UserManager.getInstance().userId,
|
||||
exposureVersion = BuildConfig.EXPOSURE_VERSION,
|
||||
rom = RomIdentifier.getRom().name + "" + RomIdentifier.getRom().versionName)
|
||||
}
|
||||
|
||||
fun getMeta(): Meta {
|
||||
@ -140,16 +151,16 @@ object MetaUtil {
|
||||
val telephonyManager = application.getSystemService(Context.TELEPHONY_SERVICE) as TelephonyManager
|
||||
if (telephonyManager.simState != TelephonyManager.SIM_STATE_READY) return "unknown"
|
||||
when (telephonyManager.networkType) {
|
||||
// Unknown
|
||||
// Unknown
|
||||
TelephonyManager.NETWORK_TYPE_UNKNOWN -> "Cellular - Unknown"
|
||||
// Cellular Data–2G
|
||||
// Cellular Data–2G
|
||||
TelephonyManager.NETWORK_TYPE_EDGE, TelephonyManager.NETWORK_TYPE_GPRS, TelephonyManager.NETWORK_TYPE_CDMA,
|
||||
TelephonyManager.NETWORK_TYPE_IDEN, TelephonyManager.NETWORK_TYPE_1xRTT -> "Cellular - 2G"
|
||||
// Cellular Data–3G
|
||||
// Cellular Data–3G
|
||||
TelephonyManager.NETWORK_TYPE_UMTS, TelephonyManager.NETWORK_TYPE_HSDPA, TelephonyManager.NETWORK_TYPE_HSPA,
|
||||
TelephonyManager.NETWORK_TYPE_HSPAP, TelephonyManager.NETWORK_TYPE_HSUPA, TelephonyManager.NETWORK_TYPE_EVDO_0,
|
||||
TelephonyManager.NETWORK_TYPE_EVDO_A, TelephonyManager.NETWORK_TYPE_EVDO_B -> "Cellular - 3G"
|
||||
// Cellular Data–4G
|
||||
// Cellular Data–4G
|
||||
TelephonyManager.NETWORK_TYPE_LTE -> "Cellular - 4G"
|
||||
else -> "Cellular - Unknown Generation"
|
||||
}
|
||||
@ -160,10 +171,6 @@ object MetaUtil {
|
||||
|
||||
}
|
||||
|
||||
fun getIP(): String {
|
||||
return "unknown"
|
||||
}
|
||||
|
||||
fun getOS(): String {
|
||||
return "android"
|
||||
}
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
package com.gh.common.exposure.time
|
||||
|
||||
import com.gh.gamecenter.entity.TimeEntity
|
||||
import com.gh.gamecenter.retrofit.Response
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager
|
||||
import com.halo.assistant.HaloApp
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
@ -17,11 +19,12 @@ class Corrector {
|
||||
fixedRateTimer("TimeUtil-Corrector-Checker", initialDelay = 0, period = TIME_CORRECTOR_ADJUST_PERIOD) {
|
||||
RetrofitManager.getInstance(HaloApp.getInstance().application).api.time
|
||||
.subscribeOn(Schedulers.io())
|
||||
.subscribe({
|
||||
val serverTime = java.lang.Long.parseLong(it.string())
|
||||
delta = serverTime * 1000 - System.currentTimeMillis()
|
||||
}, Throwable::printStackTrace)
|
||||
.subscribe(object : Response<TimeEntity>() {
|
||||
override fun onResponse(response: TimeEntity?) {
|
||||
val serverTime = response?.time
|
||||
serverTime?.let { delta = it * 1000 - System.currentTimeMillis() }
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -4,19 +4,20 @@ object TimeUtil {
|
||||
|
||||
private lateinit var corrector: Corrector
|
||||
|
||||
fun init() {
|
||||
corrector = Corrector()
|
||||
}
|
||||
|
||||
fun currentTimeMillis(): Long {
|
||||
return corrector.delta + System.currentTimeMillis()
|
||||
}
|
||||
|
||||
fun currentTime(): Int {
|
||||
return ( ( corrector.delta + System.currentTimeMillis() ) / 1000 ).toInt()
|
||||
}
|
||||
|
||||
/**
|
||||
* Must be called early then real use (for example in Application)
|
||||
*/
|
||||
fun init() {
|
||||
corrector = Corrector()
|
||||
return if (::corrector.isInitialized) {
|
||||
((corrector.delta + System.currentTimeMillis()) / 1000).toInt()
|
||||
} else {
|
||||
(System.currentTimeMillis() / 1000).toInt()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
52
app/src/main/java/com/gh/common/history/HistoryDatabase.kt
Normal file
52
app/src/main/java/com/gh/common/history/HistoryDatabase.kt
Normal file
@ -0,0 +1,52 @@
|
||||
package com.gh.common.history
|
||||
|
||||
import androidx.room.Database
|
||||
import androidx.room.Room
|
||||
import androidx.room.RoomDatabase
|
||||
import androidx.room.TypeConverters
|
||||
import androidx.room.migration.Migration
|
||||
import androidx.sqlite.db.SupportSQLiteDatabase
|
||||
import com.gh.gamecenter.entity.HistoryGameEntity
|
||||
import com.gh.gamecenter.entity.NewsEntity
|
||||
import com.gh.gamecenter.qa.entity.AnswerEntity
|
||||
import com.gh.gamecenter.qa.entity.ArticleEntity
|
||||
import com.gh.gamecenter.room.converter.*
|
||||
import com.gh.gamecenter.room.dao.AnswerHistoryDao
|
||||
import com.gh.gamecenter.room.dao.ArticleHistoryDao
|
||||
import com.gh.gamecenter.room.dao.GameDao
|
||||
import com.gh.gamecenter.room.dao.NewsHistoryDao
|
||||
import com.halo.assistant.HaloApp
|
||||
|
||||
@Database(entities = [AnswerEntity::class, ArticleEntity::class, NewsEntity::class, HistoryGameEntity::class], version = 3, exportSchema = false)
|
||||
@TypeConverters(*[
|
||||
CountConverter::class,
|
||||
CommunityConverter::class,
|
||||
TimeConverter::class,
|
||||
AnswerUserConverter::class,
|
||||
ThumbnailConverter::class,
|
||||
TagStyleListConverter::class,
|
||||
StringArrayListConverter::class])
|
||||
|
||||
abstract class HistoryDatabase : RoomDatabase() {
|
||||
|
||||
abstract fun answerDao(): AnswerHistoryDao
|
||||
abstract fun articleDao(): ArticleHistoryDao
|
||||
abstract fun newsDao(): NewsHistoryDao
|
||||
abstract fun gameDao(): GameDao
|
||||
|
||||
companion object {
|
||||
|
||||
val MIGRATION_2_3: Migration = object : Migration(2, 3) {
|
||||
override fun migrate(database: SupportSQLiteDatabase) {
|
||||
database.execSQL("Alter TABLE HistoryGameEntity add isLibaoExist INTEGER NOT NULL DEFAULT 0")
|
||||
}
|
||||
}
|
||||
|
||||
val instance by lazy {
|
||||
Room.databaseBuilder(HaloApp.getInstance().application, HistoryDatabase::class.java, "USER_TRACK_HISTORY_DATABASE")
|
||||
.addMigrations(MIGRATION_2_3)
|
||||
.build()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
108
app/src/main/java/com/gh/common/history/HistoryHelper.kt
Normal file
108
app/src/main/java/com/gh/common/history/HistoryHelper.kt
Normal file
@ -0,0 +1,108 @@
|
||||
package com.gh.common.history
|
||||
|
||||
import com.gh.common.runOnIoThread
|
||||
import com.gh.common.util.clearHtmlFormatCompletely
|
||||
import com.gh.common.util.removeInsertedContent
|
||||
import com.gh.gamecenter.entity.GameEntity
|
||||
import com.gh.gamecenter.entity.HistoryGameEntity
|
||||
import com.gh.gamecenter.entity.NewsEntity
|
||||
import com.gh.gamecenter.qa.entity.AnswerDetailEntity
|
||||
import com.gh.gamecenter.qa.entity.AnswerEntity
|
||||
import com.gh.gamecenter.qa.entity.ArticleDetailEntity
|
||||
import com.gh.gamecenter.qa.entity.ArticleEntity
|
||||
|
||||
object HistoryHelper {
|
||||
|
||||
fun insertAnswerEntity(answerDetailEntity: AnswerDetailEntity) {
|
||||
val answerEntity = convertAnswerDetailToAnswer(answerDetailEntity)
|
||||
runOnIoThread { HistoryDatabase.instance.answerDao().addAnswer(answerEntity) }
|
||||
}
|
||||
|
||||
fun insertArticleEntity(articleDetailEntity: ArticleDetailEntity) {
|
||||
val articleEntity = convertArticleDetailToArticle(articleDetailEntity)
|
||||
runOnIoThread { HistoryDatabase.instance.articleDao().addArticle(articleEntity) }
|
||||
}
|
||||
|
||||
fun insertGameEntity(gameEntity: GameEntity) {
|
||||
val historyGameEntity = convertGameEntityToHistoryGameEntity(gameEntity)
|
||||
runOnIoThread { HistoryDatabase.instance.gameDao().addGame(historyGameEntity) }
|
||||
}
|
||||
|
||||
private fun convertGameEntityToHistoryGameEntity(gameEntity: GameEntity): HistoryGameEntity {
|
||||
val historyGame = HistoryGameEntity()
|
||||
|
||||
historyGame.orderTag = System.currentTimeMillis()
|
||||
historyGame.id = gameEntity.id
|
||||
historyGame.brief = gameEntity.brief
|
||||
historyGame.des = gameEntity.des
|
||||
historyGame.icon = gameEntity.icon
|
||||
historyGame.name = gameEntity.name
|
||||
historyGame.tagStyle = gameEntity.tagStyle
|
||||
historyGame.tag = gameEntity.getTag()
|
||||
historyGame.isLibaoExist = gameEntity.isLibaoExists
|
||||
return historyGame
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun insertNewsEntity(newsEntity: NewsEntity) {
|
||||
newsEntity.orderTag = System.currentTimeMillis()
|
||||
runOnIoThread { HistoryDatabase.instance.newsDao().addNews(newsEntity) }
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun deleteNewsEntity(newsId: String) {
|
||||
runOnIoThread { HistoryDatabase.instance.newsDao().deleteNews(NewsEntity().apply { id = newsId }) }
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun deleteGameEntity(gameId: String) {
|
||||
runOnIoThread { HistoryDatabase.instance.gameDao().deleteGame(HistoryGameEntity(id = gameId)) }
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun deleteArticleEntity(articleId: String) {
|
||||
runOnIoThread { HistoryDatabase.instance.articleDao().deleteArticle(ArticleEntity(id = articleId)) }
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun deleteAnswerEntity(answerId: String) {
|
||||
runOnIoThread { HistoryDatabase.instance.answerDao().deleteAnswer(AnswerEntity().apply { primaryKey = answerId }) }
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun emptyDatabase() {
|
||||
runOnIoThread { HistoryDatabase.instance.clearAllTables() }
|
||||
}
|
||||
|
||||
private fun convertArticleDetailToArticle(articleDetailEntity: ArticleDetailEntity): ArticleEntity {
|
||||
val articleEntity = ArticleEntity()
|
||||
|
||||
articleEntity.id = articleDetailEntity.id
|
||||
articleEntity.brief = articleDetailEntity.content.removeInsertedContent().clearHtmlFormatCompletely().replace(" +".toRegex()," ")
|
||||
articleEntity.count = articleDetailEntity.count
|
||||
articleEntity.community = articleDetailEntity.community
|
||||
articleEntity.time = articleDetailEntity.time
|
||||
articleEntity.title = articleDetailEntity.title
|
||||
articleEntity.user = articleDetailEntity.user
|
||||
articleEntity.orderTag = System.currentTimeMillis()
|
||||
|
||||
return articleEntity
|
||||
}
|
||||
|
||||
private fun convertAnswerDetailToAnswer(answerDetailEntity: AnswerDetailEntity): AnswerEntity {
|
||||
val answerEntity = AnswerEntity()
|
||||
|
||||
answerEntity.id = answerDetailEntity.id
|
||||
answerEntity.primaryKey = answerDetailEntity.id
|
||||
answerEntity.commentCount = answerDetailEntity.commentCount
|
||||
answerEntity.questions = answerDetailEntity.question
|
||||
answerEntity.vote = answerDetailEntity.vote
|
||||
answerEntity.user = answerDetailEntity.user
|
||||
answerEntity.orderTag = System.currentTimeMillis()
|
||||
answerEntity.brief = answerDetailEntity.content.removeInsertedContent().clearHtmlFormatCompletely().replace(" +".toRegex(), " ")
|
||||
answerEntity.time = answerDetailEntity.time
|
||||
|
||||
return answerEntity
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,7 +1,7 @@
|
||||
package com.gh.common.im
|
||||
|
||||
import android.app.Activity
|
||||
import android.support.v4.view.ViewCompat
|
||||
import androidx.core.view.ViewCompat
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@ package com.gh.common.im
|
||||
import android.app.Activity
|
||||
import android.content.Context
|
||||
import android.os.Build
|
||||
import android.support.v4.view.ViewCompat
|
||||
import androidx.core.view.ViewCompat
|
||||
import android.util.AttributeSet
|
||||
import android.util.DisplayMetrics
|
||||
import android.util.TypedValue
|
||||
|
||||
@ -5,16 +5,20 @@ import android.app.NotificationManager
|
||||
import android.content.Context
|
||||
import com.gh.base.CurrentActivityHolder
|
||||
import com.gh.common.util.SPUtils
|
||||
import com.gh.common.util.tryWithDefaultCatch
|
||||
import com.gh.gamecenter.BuildConfig
|
||||
import com.gh.gamecenter.MainActivity
|
||||
import com.gh.gamecenter.MessageActivity
|
||||
import com.gh.gamecenter.SuggestSelectActivity
|
||||
import com.gh.gamecenter.manager.UserManager
|
||||
import com.halo.assistant.HaloApp
|
||||
import com.m7.imkfsdk.KfStartHelper
|
||||
import com.m7.imkfsdk.utils.Utils
|
||||
import com.moor.imkf.ChatListener
|
||||
import com.moor.imkf.IMChat
|
||||
import com.moor.imkf.IMChatManager
|
||||
import com.moor.imkf.IMMessage
|
||||
import com.moor.imkf.utils.MoorUtils
|
||||
|
||||
object ImManager {
|
||||
|
||||
@ -25,10 +29,17 @@ object ImManager {
|
||||
var shouldShowFloatingWindow = false
|
||||
var shouldShowFloatingWindowDot = false
|
||||
|
||||
// 记录当前用户 ID 避免重复初始化
|
||||
var currentUserId = ""
|
||||
|
||||
@JvmStatic
|
||||
fun attachIm() {
|
||||
try {
|
||||
if (UserManager.getInstance().userInfoEntity != null) {
|
||||
if (UserManager.getInstance().userInfoEntity != null &&
|
||||
currentUserId != UserManager.getInstance().userId) {
|
||||
currentUserId = UserManager.getInstance().userId
|
||||
MoorUtils.init(HaloApp.getInstance().application)
|
||||
Utils.init(HaloApp.getInstance().application)
|
||||
IMChatManager.getInstance().init(
|
||||
HaloApp.getInstance().application,
|
||||
ImReceiver.UNIQUE_BROADCAST_ACTION,
|
||||
@ -67,7 +78,8 @@ object ImManager {
|
||||
chatHelper.initSdkChat(
|
||||
ImReceiver.UNIQUE_BROADCAST_ACTION,
|
||||
IM_KEY,
|
||||
UserManager.getInstance().userInfoEntity.name + "(" + UserManager.getInstance().userId + ")",
|
||||
UserManager.getInstance().userInfoEntity.name + "(" + UserManager.getInstance().userId + ")"
|
||||
+ "[" + BuildConfig.VERSION_NAME + "]",
|
||||
UserManager.getInstance().userId)
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
@ -117,11 +129,13 @@ object ImManager {
|
||||
fun sendFeedbackMessage(message: String) {
|
||||
val fromToMessage = IMMessage.createTxtMessage(message)
|
||||
HaloApp.getInstance().mainExecutor.execute {
|
||||
IMChat.getInstance().sendMessage(fromToMessage, object : ChatListener {
|
||||
override fun onProgress(p0: Int) {}
|
||||
override fun onSuccess() {}
|
||||
override fun onFailed() {}
|
||||
})
|
||||
tryWithDefaultCatch {
|
||||
IMChat.getInstance().sendMessage(fromToMessage, object : ChatListener {
|
||||
override fun onProgress(p0: Int) {}
|
||||
override fun onSuccess() {}
|
||||
override fun onFailed() {}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -8,12 +8,12 @@ import android.content.BroadcastReceiver
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Build
|
||||
import android.support.v4.app.NotificationCompat
|
||||
import androidx.core.app.NotificationCompat
|
||||
import com.gh.base.CurrentActivityHolder
|
||||
import com.gh.gamecenter.R
|
||||
import com.m7.imkfsdk.chat.ChatActivity
|
||||
import com.m7.imkfsdk.utils.Utils
|
||||
import com.moor.imkf.IMChatManager
|
||||
import com.moor.imkf.utils.Utils
|
||||
|
||||
class ImReceiver : BroadcastReceiver() {
|
||||
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
package com.gh.common.notifier
|
||||
|
||||
import android.app.Activity
|
||||
import android.support.v4.view.ViewCompat
|
||||
import androidx.core.view.ViewCompat
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import com.gh.common.util.SPUtils
|
||||
@ -32,7 +32,7 @@ class Notifier private constructor() {
|
||||
@JvmStatic
|
||||
fun tagNotifierAsShowed(content: String) {
|
||||
val viewedNotifierCollection = SPUtils.getString(SP_VIEWED_NOTIFIER)
|
||||
if (viewedNotifierCollection.length > 1000) {
|
||||
if (viewedNotifierCollection.length > 3000) {
|
||||
SPUtils.setString(SP_VIEWED_NOTIFIER, content)
|
||||
} else {
|
||||
SPUtils.setString(SP_VIEWED_NOTIFIER, viewedNotifierCollection + content)
|
||||
|
||||
@ -5,7 +5,6 @@ import android.app.Activity
|
||||
import android.content.Context
|
||||
import android.graphics.Path
|
||||
import android.os.Build
|
||||
import android.support.v4.view.ViewCompat
|
||||
import android.text.TextUtils
|
||||
import android.util.AttributeSet
|
||||
import android.util.DisplayMetrics
|
||||
@ -13,6 +12,7 @@ import android.util.Log
|
||||
import android.util.TypedValue
|
||||
import android.view.*
|
||||
import android.widget.FrameLayout
|
||||
import androidx.core.view.ViewCompat
|
||||
import com.gh.common.util.ImageUtils
|
||||
import com.gh.common.util.doOnEnd
|
||||
import com.gh.common.util.doOnStart
|
||||
@ -201,12 +201,16 @@ class NotifierView @JvmOverloads constructor(context: Context, attrs: AttributeS
|
||||
showAnimatorSet.cancel()
|
||||
hideAnimatorSet.cancel()
|
||||
|
||||
removeAllListeners(expandAnimator,
|
||||
shrinkAnimator,
|
||||
translateUpAnimator,
|
||||
translateDownAnimator,
|
||||
translateToLeftAnimator,
|
||||
translateToRightAnimator)
|
||||
try {
|
||||
removeAllListeners(expandAnimator,
|
||||
shrinkAnimator,
|
||||
translateUpAnimator,
|
||||
translateDownAnimator,
|
||||
translateToLeftAnimator,
|
||||
translateToRightAnimator)
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
private fun removeAllListeners(vararg ts: Animator) {
|
||||
@ -227,7 +231,7 @@ class NotifierView @JvmOverloads constructor(context: Context, attrs: AttributeS
|
||||
postDelayed({ shrink() }, duration)
|
||||
}
|
||||
|
||||
fun shrink() {
|
||||
private fun shrink() {
|
||||
shrinkAnimator.doOnEnd { hide() }
|
||||
shrinkAnimator.start()
|
||||
}
|
||||
|
||||
@ -22,7 +22,7 @@ import android.animation.Animator
|
||||
import android.animation.AnimatorListenerAdapter
|
||||
import android.animation.ValueAnimator
|
||||
import android.os.Build
|
||||
import android.support.annotation.RequiresApi
|
||||
import androidx.annotation.RequiresApi
|
||||
import android.view.MotionEvent
|
||||
import android.view.VelocityTracker
|
||||
import android.view.View
|
||||
|
||||
43
app/src/main/java/com/gh/common/observer/VolumeObserver.kt
Normal file
43
app/src/main/java/com/gh/common/observer/VolumeObserver.kt
Normal file
@ -0,0 +1,43 @@
|
||||
package com.gh.common.observer
|
||||
|
||||
import android.content.Context
|
||||
import android.database.ContentObserver
|
||||
import android.media.AudioManager
|
||||
import android.os.Handler
|
||||
|
||||
class VolumeObserver(var context: Context, handler: Handler, var callback: MuteCallback? = null)
|
||||
: ContentObserver(handler) {
|
||||
var previousVolume: Int = 0
|
||||
|
||||
init {
|
||||
val audio = context.getSystemService(Context.AUDIO_SERVICE) as AudioManager
|
||||
previousVolume = audio.getStreamVolume(AudioManager.STREAM_MUSIC)
|
||||
}
|
||||
|
||||
override fun onChange(selfChange: Boolean) {
|
||||
super.onChange(selfChange)
|
||||
|
||||
val audio = context.getSystemService(Context.AUDIO_SERVICE) as AudioManager
|
||||
val currentVolume = audio.getStreamVolume(AudioManager.STREAM_MUSIC)
|
||||
|
||||
val delta = previousVolume - currentVolume
|
||||
|
||||
if (delta != 0) {
|
||||
if (currentVolume == 0) {
|
||||
callback?.onMute(true)
|
||||
} else {
|
||||
callback?.onMute(false)
|
||||
}
|
||||
}
|
||||
|
||||
if (delta > 0) {
|
||||
previousVolume = currentVolume
|
||||
} else if (delta < 0) {
|
||||
previousVolume = currentVolume
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
interface MuteCallback {
|
||||
fun onMute(isMute: Boolean)
|
||||
}
|
||||
@ -0,0 +1,56 @@
|
||||
package com.gh.common.repository
|
||||
|
||||
import com.gh.common.util.ApkActiveUtils
|
||||
import com.gh.common.util.RandomUtils
|
||||
import com.gh.gamecenter.entity.GameEntity
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager
|
||||
import com.tencent.bugly.beta.tinker.TinkerManager.getApplication
|
||||
import io.reactivex.Observable
|
||||
|
||||
// 热门卡牌的仓库
|
||||
object RemenkapaiRepository {
|
||||
|
||||
var remenkapaiList = arrayListOf<GameEntity>()
|
||||
|
||||
@JvmStatic
|
||||
fun getRemenkapai(size: Int): Observable<List<GameEntity>> {
|
||||
return if (remenkapaiList.isEmpty()) {
|
||||
RetrofitManager.getInstance(getApplication()).api.remenkapai
|
||||
.map { gameList -> filterEntityWithoutApk(gameList) }
|
||||
.map { pickRandomSizeEntity(size) }
|
||||
.map(ApkActiveUtils.filterMapperList)
|
||||
} else {
|
||||
Observable.create { emitter -> emitter.onNext(pickRandomSizeEntity(size)) }
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 选择随机数量的热门卡牌
|
||||
*/
|
||||
private fun pickRandomSizeEntity(size: Int): List<GameEntity> {
|
||||
if (size > remenkapaiList.size) return remenkapaiList
|
||||
|
||||
val randomGameList = arrayListOf<GameEntity>()
|
||||
val randomArray = RandomUtils.getRandomArray(size, remenkapaiList.size)
|
||||
for (i in randomArray) {
|
||||
randomGameList.add(remenkapaiList[i])
|
||||
}
|
||||
return randomGameList
|
||||
}
|
||||
|
||||
/**
|
||||
* 过滤没有 Apk 的实体
|
||||
*/
|
||||
private fun filterEntityWithoutApk(gameList: List<GameEntity>): List<GameEntity> {
|
||||
val realGameList = arrayListOf<GameEntity>()
|
||||
for (gameEntity in gameList) {
|
||||
val apk = gameEntity.getApk()
|
||||
if (apk.size != 0) {
|
||||
realGameList.add(gameEntity)
|
||||
}
|
||||
}
|
||||
remenkapaiList = realGameList
|
||||
return remenkapaiList
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,72 @@
|
||||
package com.gh.common.repository
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import com.gh.common.util.CheckLoginUtils
|
||||
import com.gh.gamecenter.manager.UserManager
|
||||
import com.gh.gamecenter.retrofit.BiResponse
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager
|
||||
import com.halo.assistant.HaloApp
|
||||
import com.lightgame.utils.Utils
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
|
||||
/**
|
||||
* 预约游戏仓库,存储了用户已预约的游戏列表
|
||||
*/
|
||||
object ReservationRepository {
|
||||
|
||||
private var mReservationSet = hashSetOf<String>()
|
||||
|
||||
@JvmStatic
|
||||
fun refreshReservationsIfNeeded() {
|
||||
if (mReservationSet.isEmpty()) {
|
||||
refreshReservations()
|
||||
}
|
||||
}
|
||||
|
||||
fun addReservationToMemoryAndRefresh(gameId: String) {
|
||||
mReservationSet.add(gameId)
|
||||
refreshReservations()
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun removeReservationFromMemoryAndRefresh(gamedId: String) {
|
||||
mReservationSet.remove(gamedId)
|
||||
refreshReservations()
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
@JvmStatic
|
||||
fun refreshReservations() {
|
||||
if (CheckLoginUtils.isLogin()) {
|
||||
RetrofitManager.getInstance(HaloApp.getInstance().application).api
|
||||
.getAllTheGameReservations(UserManager.getInstance().userId, Utils.getTime(HaloApp.getInstance().application))
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(object : BiResponse<List<String>>() {
|
||||
|
||||
override fun onSuccess(data: List<String>) {
|
||||
mReservationSet = HashSet(data)
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun clearReservations() {
|
||||
mReservationSet.clear()
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun thisGameHasBeenReserved(gameId: String): Boolean {
|
||||
return if (!CheckLoginUtils.isLogin()) false else {
|
||||
if (mReservationSet.isEmpty()) {
|
||||
false
|
||||
} else {
|
||||
mReservationSet.contains(gameId)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
41
app/src/main/java/com/gh/common/util/ActivationHelper.kt
Normal file
41
app/src/main/java/com/gh/common/util/ActivationHelper.kt
Normal file
@ -0,0 +1,41 @@
|
||||
package com.gh.common.util
|
||||
|
||||
import com.gh.gamecenter.retrofit.Response
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager
|
||||
import com.halo.assistant.HaloApp
|
||||
import com.lightgame.utils.Util_System_Phone_State
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
import okhttp3.ResponseBody
|
||||
|
||||
/**
|
||||
* 激活信息辅助类
|
||||
*/
|
||||
object ActivationHelper {
|
||||
|
||||
private const val HAS_SENT_ACTIVATED_INFO = "has_sent_activated_info"
|
||||
|
||||
var mHasSentActivatedInfo = SPUtils.getBoolean(HAS_SENT_ACTIVATED_INFO, false)
|
||||
|
||||
/**
|
||||
* 发送激活信息 (用于推广)
|
||||
*/
|
||||
@JvmStatic
|
||||
fun sendActivationInfo() {
|
||||
// 能获取到 IMEI 并且之前没发送过激活信息才发
|
||||
if (mHasSentActivatedInfo
|
||||
&& Util_System_Phone_State.canGetImei(HaloApp.getInstance().application)) {
|
||||
RetrofitManager.getInstance(HaloApp.getInstance().application)
|
||||
.api.postActivationInfo()
|
||||
.subscribeOn(Schedulers.io())
|
||||
.subscribe(object : Response<ResponseBody>() {
|
||||
override fun onResponse(response: ResponseBody?) {
|
||||
super.onResponse(response)
|
||||
|
||||
mHasSentActivatedInfo = true
|
||||
SPUtils.setBoolean(HAS_SENT_ACTIVATED_INFO, true)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
37
app/src/main/java/com/gh/common/util/AdHelper.kt
Normal file
37
app/src/main/java/com/gh/common/util/AdHelper.kt
Normal file
@ -0,0 +1,37 @@
|
||||
package com.gh.common.util
|
||||
|
||||
import com.gh.common.constant.Config
|
||||
import com.gh.gamecenter.entity.SettingsEntity
|
||||
|
||||
object AdHelper {
|
||||
|
||||
// 搜索为空/求版本/意见反馈-功能收录/发现
|
||||
const val LOCATION_SEARCH_EMPTY = "search_empty"
|
||||
const val LOCATION_GAME_REQUEST_VERSION = "game_request_version"
|
||||
const val LOCATION_SUGGESTION_FUNCTION = "suggestion_function"
|
||||
const val LOCATION_DISCOVER = "discover"
|
||||
|
||||
fun getAd(location: String): SettingsEntity.AD? {
|
||||
val adList = Config.getSettings()?.adList ?: return null
|
||||
|
||||
for (ad in adList) {
|
||||
if (ad.location == location) return ad
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
fun getDiscoverAds(): List<SettingsEntity.AD> {
|
||||
val adList = Config.getSettings()?.adList ?: return listOf()
|
||||
|
||||
val discoverAdList = arrayListOf<SettingsEntity.AD>()
|
||||
|
||||
for (ad in adList) {
|
||||
if (ad.location == LOCATION_DISCOVER) {
|
||||
discoverAdList.add(ad)
|
||||
}
|
||||
}
|
||||
|
||||
return discoverAdList
|
||||
}
|
||||
|
||||
}
|
||||
@ -17,7 +17,8 @@
|
||||
package com.gh.common.util
|
||||
|
||||
import android.animation.Animator
|
||||
import android.support.annotation.RequiresApi
|
||||
import androidx.annotation.RequiresApi
|
||||
import android.view.ViewPropertyAnimator
|
||||
|
||||
/**
|
||||
* Since [Android KTX] has not release a stable build yet,
|
||||
@ -125,4 +126,26 @@ fun Animator.addPauseListener(
|
||||
}
|
||||
addPauseListener(listener)
|
||||
return listener
|
||||
}
|
||||
|
||||
fun ViewPropertyAnimator.doOnEnd(onEnd: ((animator: Animator?) -> Unit)? = null): ViewPropertyAnimator {
|
||||
val listener = object : Animator.AnimatorListener {
|
||||
override fun onAnimationRepeat(animation: Animator?) {
|
||||
|
||||
}
|
||||
|
||||
override fun onAnimationEnd(animation: Animator?) {
|
||||
onEnd?.invoke(animation)
|
||||
}
|
||||
|
||||
override fun onAnimationCancel(animation: Animator?) {
|
||||
|
||||
}
|
||||
|
||||
override fun onAnimationStart(animation: Animator?) {
|
||||
|
||||
}
|
||||
}
|
||||
this.setListener(listener)
|
||||
return this
|
||||
}
|
||||
@ -1,31 +1,52 @@
|
||||
package com.gh.common.util;
|
||||
|
||||
import com.gh.gamecenter.BuildConfig;
|
||||
import com.gh.gamecenter.entity.ApkEntity;
|
||||
import com.gh.gamecenter.entity.GameEntity;
|
||||
import com.gh.gamecenter.manager.PackageManager;
|
||||
import com.gh.gamecenter.manager.PackagesManager;
|
||||
import com.lightgame.utils.Utils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.functions.Function;
|
||||
|
||||
/**
|
||||
* Created by khy on 10/05/17.
|
||||
*/
|
||||
|
||||
public class ApkActiveUtils {
|
||||
|
||||
// 过滤隐藏apk包
|
||||
public static void filterHideApk(GameEntity gameEntity) {
|
||||
if (gameEntity == null || gameEntity.getApk() == null
|
||||
|| gameEntity.getApk().size() == 0) return;
|
||||
|
||||
List<ApkEntity> apkList = gameEntity.getApk();
|
||||
for (int i = 0; i < apkList.size(); i++) {
|
||||
ApkEntity apkEntity = apkList.get(i);
|
||||
String packageName = apkEntity.getPackageName();
|
||||
String id = gameEntity.getId();
|
||||
if (!apkEntity.isActive() && !PackageManager.INSTANCE.isCanPluggable(id, packageName)) {
|
||||
apkList.remove(i);
|
||||
i--;
|
||||
try {
|
||||
if (gameEntity == null || gameEntity.getOriginalApk().size() == 0) return;
|
||||
List<ApkEntity> apkList = gameEntity.getOriginalApk();
|
||||
for (int i = 0; i < apkList.size(); i++) {
|
||||
ApkEntity apkEntity = apkList.get(i);
|
||||
String packageName = apkEntity.getPackageName();
|
||||
String id = gameEntity.getId();
|
||||
if (!apkEntity.isActive() && !PackagesManager.INSTANCE.isCanPluggable(id, packageName)) {
|
||||
apkList.remove(i);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
if (BuildConfig.DEBUG) {
|
||||
Utils.log("filter hide game apk throws exception:" + e.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 过滤隐藏apk包
|
||||
public static Function<List<GameEntity>, List<GameEntity>> filterMapperList = list -> {
|
||||
for (GameEntity gameEntity : list) {
|
||||
ApkActiveUtils.filterHideApk(gameEntity);
|
||||
}
|
||||
return list;
|
||||
};
|
||||
|
||||
// 过滤隐藏apk包
|
||||
public static Function<GameEntity, GameEntity> filterMapper = list -> {
|
||||
ApkActiveUtils.filterHideApk(list);
|
||||
return list;
|
||||
};
|
||||
}
|
||||
|
||||
@ -1,90 +0,0 @@
|
||||
package com.gh.common.util;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.lightgame.utils.Utils;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
import retrofit2.HttpException;
|
||||
|
||||
/**
|
||||
* Created by khy on 28/12/17.
|
||||
*/
|
||||
|
||||
public class AskErrorResponseUtils {
|
||||
|
||||
public static void errorResponseControl(Context context, HttpException e) {
|
||||
if (e == null) return;
|
||||
int code = e.code();
|
||||
try {
|
||||
if (code == 403) {
|
||||
JSONObject object = new JSONObject(e.response().errorBody().string());
|
||||
int errorCode = object.getInt("code");
|
||||
switch (errorCode) {
|
||||
case 403001:
|
||||
Utils.toast(context, "标签名称太长了");
|
||||
break;
|
||||
case 403002:
|
||||
Utils.toast(context, "已经被邀请了");
|
||||
break;
|
||||
case 403003:
|
||||
Utils.toast(context, "每天最多只能邀请10次");
|
||||
break;
|
||||
case 403004:
|
||||
Utils.toast(context, "客户端提供的ID无效(空/无效ID)");
|
||||
break;
|
||||
case 403005:
|
||||
Utils.toast(context, "已经回答过了(限制频率)");
|
||||
break;
|
||||
case 403006:
|
||||
Utils.toast(context, "图片数量达到限制点");
|
||||
break;
|
||||
case 403007:
|
||||
Utils.toast(context, "不合法的用户");
|
||||
break;
|
||||
case 403008:
|
||||
Utils.toast(context, "已投票");
|
||||
break;
|
||||
case 403009:
|
||||
Utils.toast(context, "已经收藏过了");
|
||||
break;
|
||||
case 403010:
|
||||
Utils.toast(context, "无效的标签栏");
|
||||
break;
|
||||
case 403011:
|
||||
Utils.toast(context, "标题内容过长");
|
||||
break;
|
||||
case 403012:
|
||||
Utils.toast(context, "描述内容过长");
|
||||
break;
|
||||
case 403013:
|
||||
Utils.toast(context, "无效的标签");
|
||||
break;
|
||||
case 403014:
|
||||
Utils.toast(context, "标签数量太多了");
|
||||
break;
|
||||
case 403015:
|
||||
Utils.toast(context, "已经关注过了");
|
||||
break;
|
||||
default:
|
||||
Utils.toast(context, "网络错误");
|
||||
break;
|
||||
}
|
||||
} else if (code == 401) {
|
||||
JSONObject object = new JSONObject(e.response().errorBody().string());
|
||||
int errorCode = object.getInt("code");
|
||||
if (errorCode == 404001) {
|
||||
Utils.toast(context, "请求的资源不存在");
|
||||
}
|
||||
} else {
|
||||
Utils.toast(context, "网络错误");
|
||||
}
|
||||
|
||||
} catch (Exception e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@ -7,6 +7,9 @@ import android.graphics.Matrix;
|
||||
import android.graphics.PixelFormat;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.media.ExifInterface;
|
||||
import android.os.Build;
|
||||
|
||||
import com.halo.assistant.HaloApp;
|
||||
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
@ -186,15 +189,30 @@ public class BitmapUtils {
|
||||
|
||||
/**
|
||||
* Drawable转Bitmap
|
||||
* @param isSquare 是否是正方形
|
||||
*/
|
||||
public static Bitmap drawableToBitmap(Drawable drawable) {
|
||||
public static Bitmap drawableToBitmap(Drawable drawable, boolean isSquare) {
|
||||
if (drawable == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
int w,h;
|
||||
|
||||
// 取 drawable 的长宽
|
||||
int w = drawable.getIntrinsicWidth();
|
||||
int h = drawable.getIntrinsicHeight();
|
||||
w = drawable.getIntrinsicWidth();
|
||||
h = drawable.getIntrinsicHeight();
|
||||
|
||||
// 在低于 5.1 和运行内存小于 2G 的设备上减小图片大小,避免 OOM,128 * 128 又不是不能看
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP
|
||||
|| DeviceUtils.getTotalRamSizeOfDevice(HaloApp.getInstance().getApplication()) < 2000) {
|
||||
if (isSquare) {
|
||||
w = w > 128 ? 128 : w;
|
||||
h = h > 128 ? 128 : h;
|
||||
} else {
|
||||
w = w > 128 ? w / 2 : w;
|
||||
h = h > 128 ? h / 2 : h;
|
||||
}
|
||||
}
|
||||
// 取 drawable 的颜色格式
|
||||
Bitmap.Config config = drawable.getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888
|
||||
: Bitmap.Config.RGB_565;
|
||||
|
||||
@ -14,15 +14,17 @@ import com.lightgame.utils.Utils;
|
||||
|
||||
public class CheckLoginUtils {
|
||||
|
||||
public static void checkLogin(final Context context, OnLoginListener listener) {
|
||||
if (TextUtils.isEmpty(UserManager.getInstance().getToken())) {
|
||||
Utils.toast(context, "需要登录");
|
||||
LogUtils.login(context, "dialog", null);
|
||||
LogUtils.login(context, "activity", null);
|
||||
Intent intent = LoginActivity.getIntent(context);
|
||||
public static void checkLogin(final Context context, String entrance, OnLoginListener listener) {
|
||||
if (!isLogin()) {
|
||||
if (listener != null) Utils.toast(context, "需要登录");
|
||||
LogUtils.login("dialog", null, entrance);
|
||||
LogUtils.login("activity", null, entrance);
|
||||
Intent intent = LoginActivity.getIntent(context, entrance);
|
||||
context.startActivity(intent);
|
||||
} else {
|
||||
listener.onLogin();
|
||||
if (listener != null) {
|
||||
listener.onLogin();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -19,7 +19,7 @@ import retrofit2.HttpException
|
||||
object CollectionUtils {
|
||||
|
||||
enum class CollectionType {
|
||||
toolkit, article, answer
|
||||
toolkit, article, answer, communityArticle
|
||||
}
|
||||
|
||||
fun postCollection(context: Context, content: String, type: CollectionType, listener: OnCollectionListener) {
|
||||
@ -28,6 +28,7 @@ object CollectionUtils {
|
||||
CollectionType.article -> RetrofitManager.getInstance(context).getApi().postCollectionArticle(UserManager.getInstance().userId, content)
|
||||
CollectionType.toolkit -> RetrofitManager.getInstance(context).getApi().postCollectionTools(UserManager.getInstance().userId, content)
|
||||
CollectionType.answer -> RetrofitManager.getInstance(context).getApi().postCollectionAnswer(UserManager.getInstance().userId, content)
|
||||
else -> return
|
||||
}
|
||||
postCollection
|
||||
.subscribeOn(Schedulers.io())
|
||||
@ -36,7 +37,6 @@ object CollectionUtils {
|
||||
override fun onResponse(response: ResponseBody?) {
|
||||
super.onResponse(response)
|
||||
listener.onSuccess()
|
||||
if(type != CollectionType.answer)
|
||||
EventBus.getDefault().post(EBCollectionChanged(content, true, type))
|
||||
}
|
||||
|
||||
@ -46,7 +46,7 @@ object CollectionUtils {
|
||||
try {
|
||||
val string = e.response()?.errorBody()?.string()
|
||||
val errorBody = JSONObject(string)
|
||||
if (errorBody.getInt("detail") == 403009) {
|
||||
if (errorBody.getInt("code") == 403009) {
|
||||
listener.onSuccess()
|
||||
return
|
||||
}
|
||||
@ -66,6 +66,7 @@ object CollectionUtils {
|
||||
CollectionType.article -> postCollection = RetrofitManager.getInstance(context).getApi().deletaCollectionArticle(UserManager.getInstance().userId, id)
|
||||
CollectionType.toolkit -> postCollection = RetrofitManager.getInstance(context).getApi().deleteCollectionTools(UserManager.getInstance().userId, id)
|
||||
CollectionType.answer -> postCollection = RetrofitManager.getInstance(context).getApi().deleteCollectionAnswer(UserManager.getInstance().userId, id)
|
||||
else -> return
|
||||
}
|
||||
postCollection
|
||||
.subscribeOn(Schedulers.io())
|
||||
@ -74,7 +75,6 @@ object CollectionUtils {
|
||||
override fun onResponse(response: ResponseBody?) {
|
||||
super.onResponse(response)
|
||||
listener.onSuccess()
|
||||
if(type != CollectionType.answer)
|
||||
EventBus.getDefault().post(EBCollectionChanged(id, false, type))
|
||||
}
|
||||
|
||||
|
||||
324
app/src/main/java/com/gh/common/util/CommentHelper.kt
Normal file
324
app/src/main/java/com/gh/common/util/CommentHelper.kt
Normal file
@ -0,0 +1,324 @@
|
||||
package com.gh.common.util
|
||||
|
||||
import android.content.Context
|
||||
import android.text.TextUtils
|
||||
import com.gh.common.util.CommentUtils.copyText
|
||||
import com.gh.gamecenter.CommentDetailActivity
|
||||
import com.gh.gamecenter.MessageDetailActivity
|
||||
import com.gh.gamecenter.adapter.OnCommentCallBackListener
|
||||
import com.gh.gamecenter.entity.CommentEntity
|
||||
import com.gh.gamecenter.entity.MeEntity
|
||||
import com.gh.gamecenter.entity.Permissions
|
||||
import com.gh.gamecenter.retrofit.Response
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager
|
||||
import com.lightgame.utils.Utils
|
||||
import com.tencent.bugly.beta.tinker.TinkerManager.getApplication
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
import okhttp3.ResponseBody
|
||||
import org.json.JSONException
|
||||
import org.json.JSONObject
|
||||
import retrofit2.HttpException
|
||||
|
||||
object CommentHelper {
|
||||
|
||||
@JvmStatic
|
||||
fun showCommunityArticleCommentOptions(context: Context,
|
||||
commentEntity: CommentEntity,
|
||||
showConversation: Boolean,
|
||||
articleId: String,
|
||||
communityId: String,
|
||||
listener: OnCommentCallBackListener?) {
|
||||
showCommentOptions(context = context,
|
||||
commentEntity = commentEntity,
|
||||
showConversation = showConversation,
|
||||
articleId = articleId,
|
||||
communityId = communityId,
|
||||
listener = listener)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun showAnswerCommentOptions(context: Context,
|
||||
commentEntity: CommentEntity,
|
||||
showConversation: Boolean,
|
||||
answerId: String,
|
||||
listener: OnCommentCallBackListener?) {
|
||||
showCommentOptions(context = context,
|
||||
commentEntity = commentEntity,
|
||||
showConversation = showConversation,
|
||||
answerId = answerId,
|
||||
listener = listener)
|
||||
}
|
||||
|
||||
private fun showCommentOptions(context: Context,
|
||||
commentEntity: CommentEntity,
|
||||
showConversation: Boolean,
|
||||
articleId: String? = null,
|
||||
communityId: String? = null,
|
||||
answerId: String? = null,
|
||||
listener: OnCommentCallBackListener? = null) {
|
||||
val dialogOptions = ArrayList<String>()
|
||||
|
||||
if (commentEntity.me == null || !commentEntity.me?.isAnswerCommented!!) {
|
||||
dialogOptions.add("回复")
|
||||
}
|
||||
|
||||
dialogOptions.add("复制")
|
||||
dialogOptions.add("投诉")
|
||||
|
||||
commentEntity.me?.let {
|
||||
if (it.isModerator || (it.moderatorPermissions.hideAnswerComment > Permissions.GUEST
|
||||
|| it.moderatorPermissions.topAnswerComment > Permissions.GUEST
|
||||
|| it.moderatorPermissions.hideCommunityArticleComment > Permissions.GUEST
|
||||
|| it.moderatorPermissions.topCommunityArticleComment > Permissions.GUEST)) {
|
||||
dialogOptions.add("管理")
|
||||
}
|
||||
}
|
||||
|
||||
if (commentEntity.parentUser != null && showConversation) {
|
||||
dialogOptions.add("查看对话")
|
||||
}
|
||||
|
||||
DialogUtils.showListDialog(context, dialogOptions, null) {
|
||||
when (it) {
|
||||
"管理" -> showControlDialog(context, answerId, articleId, communityId, commentEntity, commentEntity.me!!)
|
||||
|
||||
"回复" -> {
|
||||
context.ifLogin("回答详情-评论-回复") {
|
||||
if (listener != null) {
|
||||
listener.onCommentCallback(commentEntity)
|
||||
} else if (!TextUtils.isEmpty(commentEntity.id)) {
|
||||
context.startActivity(MessageDetailActivity.getMessageDetailIntent(context, commentEntity, commentEntity.id))
|
||||
} else {
|
||||
Utils.toast(context, "缺少关键属性")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
"复制" -> copyText(commentEntity.content, context)
|
||||
|
||||
"投诉" -> {
|
||||
context.ifLogin("回答详情-评论-投诉") {
|
||||
showReportTypeDialog(context) { reportType ->
|
||||
|
||||
val commentListener = object : PostCommentUtils.PostCommentListener {
|
||||
override fun postSuccess(response: JSONObject?) {
|
||||
Utils.toast(context, "感谢您的投诉")
|
||||
}
|
||||
|
||||
override fun postFailed(error: Throwable?) {
|
||||
if (error == null) {
|
||||
Utils.toast(context, "投诉失败,请稍后重试")
|
||||
} else {
|
||||
Utils.toast(context, "投诉失败,${error.message}")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (answerId != null) {
|
||||
PostCommentUtils.postAnswerReportData(context, commentEntity.id, answerId, reportType, commentListener)
|
||||
} else {
|
||||
PostCommentUtils.reportCommunityArticleComment(context, communityId, articleId, commentEntity.id, reportType, commentListener)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
"查看对话" -> {
|
||||
if (answerId != null) {
|
||||
context.startActivity(CommentDetailActivity
|
||||
.getAnswerCommentIntent(context, commentEntity.id, answerId, null))
|
||||
} else {
|
||||
context.startActivity(CommentDetailActivity
|
||||
.getCommunityArticleCommentIntent(context, articleId, commentEntity.id, communityId, null))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun showControlDialog(context: Context,
|
||||
answerId: String? = null,
|
||||
articleId: String? = null,
|
||||
communityId: String? = null,
|
||||
comment: CommentEntity,
|
||||
me: MeEntity) {
|
||||
val dialogOptions = arrayListOf<String>()
|
||||
val highlight = "置顶评论"
|
||||
val hide = "隐藏评论"
|
||||
|
||||
var canHighlightCommentDirectly = false
|
||||
var canHideCommentDirectly = false
|
||||
|
||||
if (me.moderatorPermissions.topAnswerComment > Permissions.GUEST
|
||||
|| me.moderatorPermissions.topCommunityArticleComment > Permissions.GUEST) {
|
||||
dialogOptions.add(highlight)
|
||||
if (me.moderatorPermissions.topAnswerComment > Permissions.REPORTER
|
||||
|| me.moderatorPermissions.topCommunityArticleComment > Permissions.REPORTER ) {
|
||||
canHighlightCommentDirectly = true
|
||||
}
|
||||
}
|
||||
|
||||
if (me.moderatorPermissions.hideAnswerComment > Permissions.GUEST
|
||||
|| me.moderatorPermissions.hideCommunityArticleComment > Permissions.GUEST) {
|
||||
dialogOptions.add(hide)
|
||||
if (me.moderatorPermissions.hideAnswerComment > Permissions.REPORTER
|
||||
|| me.moderatorPermissions.hideCommunityArticleComment > Permissions.REPORTER ) {
|
||||
canHideCommentDirectly = true
|
||||
}
|
||||
}
|
||||
|
||||
val highlightDialogHintContent = if (canHighlightCommentDirectly) {
|
||||
"你的操作将立即生效,确定提交吗?(你的管理权限为:高级)"
|
||||
} else {
|
||||
"你的操作将提交给小编审核,确定提交吗?"
|
||||
}
|
||||
|
||||
val hideDialogHintContent = if (canHideCommentDirectly) {
|
||||
"你的操作将立即生效,确定提交吗?(你的管理权限为:高级)"
|
||||
} else {
|
||||
"你的操作将提交给小编审核,确定提交吗?"
|
||||
}
|
||||
|
||||
val disabledOptions = arrayListOf<String>()
|
||||
|
||||
if (comment.priority != 0) {
|
||||
disabledOptions.add(highlight)
|
||||
}
|
||||
|
||||
comment.me?.let {
|
||||
if (it.isAnswerCommented) {
|
||||
disabledOptions.add(highlight)
|
||||
}
|
||||
}
|
||||
|
||||
DialogUtils.showListDialog(context, dialogOptions, disabledOptions) {
|
||||
when (it) {
|
||||
highlight -> {
|
||||
if (comment.priority != 0) {
|
||||
Utils.toast(context, "评论已经置顶")
|
||||
return@showListDialog
|
||||
}
|
||||
|
||||
comment.me?.let { me ->
|
||||
if (me.isAnswerCommented) {
|
||||
Utils.toast(context, "不能置顶自己的评论")
|
||||
return@showListDialog
|
||||
}
|
||||
}
|
||||
|
||||
val highlightObserver = object : Response<ResponseBody>() {
|
||||
override fun onResponse(response: ResponseBody?) {
|
||||
if (canHighlightCommentDirectly) {
|
||||
Utils.toast(context, "置顶成功,请刷新列表")
|
||||
} else {
|
||||
Utils.toast(context, "提交成功")
|
||||
}
|
||||
}
|
||||
|
||||
override fun onFailure(e: HttpException?) {
|
||||
super.onFailure(e)
|
||||
e?.let { httpException ->
|
||||
if (httpException.code() == 403) {
|
||||
val string = e.response().errorBody()?.string()
|
||||
val errorJson = JSONObject(string)
|
||||
val errorCode = errorJson.getInt("code")
|
||||
if (errorCode == 403059) {
|
||||
Utils.toast(getApplication(), "权限错误,请刷新后重试")
|
||||
return
|
||||
} else {
|
||||
Utils.toast(getApplication(), e.message())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (answerId != null) {
|
||||
DialogUtils.showAlertDialog(context, highlight, highlightDialogHintContent,
|
||||
"确定", "取消", {
|
||||
RetrofitManager.getInstance(context).api
|
||||
.highlightAnswerComment(answerId, comment.id)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.subscribe(highlightObserver)
|
||||
}, null)
|
||||
} else {
|
||||
DialogUtils.showAlertDialog(context, highlight, highlightDialogHintContent,
|
||||
"确定", "取消", {
|
||||
RetrofitManager.getInstance(context).api
|
||||
.highlightCommunityArticleComment(communityId, articleId, comment.id)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.subscribe(highlightObserver)
|
||||
}, null)
|
||||
}
|
||||
}
|
||||
|
||||
hide -> {
|
||||
val hideObserver = object : Response<ResponseBody>() {
|
||||
override fun onResponse(response: ResponseBody?) {
|
||||
if (canHideCommentDirectly) {
|
||||
Utils.toast(context, "隐藏成功,请刷新列表")
|
||||
} else {
|
||||
Utils.toast(context, "提交成功")
|
||||
}
|
||||
}
|
||||
|
||||
override fun onFailure(e: HttpException?) {
|
||||
super.onFailure(e)
|
||||
e?.let { httpException ->
|
||||
if (httpException.code() == 403) {
|
||||
val string = e.response().errorBody()?.string()
|
||||
val errorJson = JSONObject(string)
|
||||
val errorCode = errorJson.getInt("code")
|
||||
if (errorCode == 403059) {
|
||||
Utils.toast(getApplication(), "权限错误,请刷新后重试")
|
||||
return
|
||||
} else {
|
||||
Utils.toast(getApplication(), e.message())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (answerId != null) {
|
||||
DialogUtils.showAlertDialog(context, hide, hideDialogHintContent,
|
||||
"确定", "取消", {
|
||||
RetrofitManager.getInstance(context).api
|
||||
.hideAnswerComment(answerId, comment.id)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.subscribe(hideObserver)
|
||||
}, null)
|
||||
} else {
|
||||
DialogUtils.showAlertDialog(context, hide, hideDialogHintContent,
|
||||
"确定", "取消", {
|
||||
RetrofitManager.getInstance(context).api
|
||||
.hideCommunityArticleComment(communityId, articleId, comment.id)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.subscribe(hideObserver)
|
||||
}, null)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun showReportTypeDialog(context: Context, reportCallback: (reportType: String) -> Unit) {
|
||||
val reportTypes = arrayListOf("垃圾广告营销", "恶意攻击谩骂", "淫秽色情信息", "违法有害信息", "其它")
|
||||
|
||||
DialogUtils.showListDialog(context, reportTypes, null) { text ->
|
||||
val jsonObject = JSONObject()
|
||||
try {
|
||||
jsonObject.put("reason", text)
|
||||
reportCallback.invoke(jsonObject.toString())
|
||||
} catch (e: JSONException) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -4,7 +4,7 @@ import android.app.Dialog;
|
||||
import android.content.ClipboardManager;
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
@ -71,9 +71,13 @@ public class CommentUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public static void showReportDialog(final CommentEntity commentEntity, final Context context, final boolean showConversation,
|
||||
final OnCommentCallBackListener listener, final String newsId) {
|
||||
|
||||
public static void showReportDialog(final CommentEntity commentEntity,
|
||||
final Context context,
|
||||
final boolean showConversation,
|
||||
final OnCommentCallBackListener listener,
|
||||
final String newsId,
|
||||
final String patch) {
|
||||
final Dialog dialog = new Dialog(context);
|
||||
|
||||
LinearLayout container = new LinearLayout(context);
|
||||
@ -88,7 +92,7 @@ public class CommentUtils {
|
||||
}
|
||||
|
||||
dialogType.add("复制");
|
||||
dialogType.add("举报");
|
||||
dialogType.add("投诉");
|
||||
|
||||
if (commentEntity.getParent() != null && showConversation) {
|
||||
dialogType.add("查看对话");
|
||||
@ -113,7 +117,7 @@ public class CommentUtils {
|
||||
dialog.cancel();
|
||||
switch (reportTv.getText().toString()) {
|
||||
case "回复":
|
||||
CheckLoginUtils.checkLogin(context, () -> {
|
||||
CheckLoginUtils.checkLogin(context, patch + "-回复", () -> {
|
||||
if (listener != null) {
|
||||
listener.onCommentCallback(commentEntity);
|
||||
} else if (!TextUtils.isEmpty(newsId)) {
|
||||
@ -126,8 +130,9 @@ public class CommentUtils {
|
||||
case "复制":
|
||||
copyText(commentEntity.getContent(), context);
|
||||
break;
|
||||
case "举报":
|
||||
CheckLoginUtils.checkLogin(context, () -> showReportTypeDialog(commentEntity, context));
|
||||
case "投诉":
|
||||
CheckLoginUtils.checkLogin(context, patch + "-投诉",
|
||||
() -> showReportTypeDialog(commentEntity, context));
|
||||
|
||||
break;
|
||||
case "查看对话":
|
||||
@ -144,126 +149,6 @@ public class CommentUtils {
|
||||
|
||||
}
|
||||
|
||||
public static void showAnswerCommentOptions(final CommentEntity commentEntity, final Context context,
|
||||
final OnCommentCallBackListener listener, final String id, boolean showConversation, String answerId) {
|
||||
|
||||
final Dialog dialog = new Dialog(context);
|
||||
|
||||
LinearLayout container = new LinearLayout(context);
|
||||
container.setOrientation(LinearLayout.VERTICAL);
|
||||
container.setBackgroundColor(Color.WHITE);
|
||||
container.setPadding(0, DisplayUtils.dip2px(context, 12), 0, DisplayUtils.dip2px(context, 12));
|
||||
|
||||
List<String> dialogType = new ArrayList<>();
|
||||
|
||||
if (commentEntity.getMe() == null || !commentEntity.getMe().isAnswerCommented()) {
|
||||
dialogType.add("回复");
|
||||
}
|
||||
|
||||
dialogType.add("复制");
|
||||
dialogType.add("举报");
|
||||
|
||||
if (commentEntity.getParentUser() != null && showConversation) {
|
||||
dialogType.add("查看对话");
|
||||
}
|
||||
|
||||
for (String s : dialogType) {
|
||||
final TextView reportTv = new TextView(context);
|
||||
reportTv.setText(s);
|
||||
reportTv.setTextSize(17);
|
||||
reportTv.setTextColor(ContextCompat.getColor(context, R.color.title));
|
||||
reportTv.setBackgroundResource(R.drawable.textview_white_style);
|
||||
int widthPixels = context.getResources().getDisplayMetrics().widthPixels;
|
||||
reportTv.setLayoutParams(new LinearLayout.LayoutParams((widthPixels * 9) / 10,
|
||||
LinearLayout.LayoutParams.WRAP_CONTENT));
|
||||
reportTv.setPadding(DisplayUtils.dip2px(context, 20), DisplayUtils.dip2px(context, 12),
|
||||
0, DisplayUtils.dip2px(context, 12));
|
||||
container.addView(reportTv);
|
||||
|
||||
reportTv.setOnClickListener(v -> {
|
||||
dialog.cancel();
|
||||
switch (reportTv.getText().toString()) {
|
||||
case "回复":
|
||||
CheckLoginUtils.checkLogin(context, () -> {
|
||||
if (listener != null) {
|
||||
listener.onCommentCallback(commentEntity);
|
||||
} else if (!TextUtils.isEmpty(id)) {
|
||||
context.startActivity(MessageDetailActivity.getMessageDetailIntent(context, commentEntity, id));
|
||||
} else {
|
||||
Utils.toast(context, "缺少关键属性");
|
||||
}
|
||||
});
|
||||
break;
|
||||
case "复制":
|
||||
copyText(commentEntity.getContent(), context);
|
||||
break;
|
||||
case "举报":
|
||||
CheckLoginUtils.checkLogin(context, () -> showAnswerReportDialog(answerId, commentEntity, context));
|
||||
break;
|
||||
case "查看对话":
|
||||
context.startActivity(CommentDetailActivity.getAnswerCommentIntent(context, commentEntity.getId(), answerId));
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
dialog.setContentView(container);
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
private static void showAnswerReportDialog(final String answerId, final CommentEntity commentEntity, final Context context) {
|
||||
final String[] arrReportType = new String[]{"垃圾广告营销", "恶意攻击谩骂", "淫秽色情信息",
|
||||
"违法有害信息", "其它"};
|
||||
int widthPixels = context.getResources().getDisplayMetrics().widthPixels;
|
||||
|
||||
final Dialog reportTypeDialog = new Dialog(context);
|
||||
LinearLayout container = new LinearLayout(context);
|
||||
container.setOrientation(LinearLayout.VERTICAL);
|
||||
container.setPadding(0, DisplayUtils.dip2px(context, 12), 0, DisplayUtils.dip2px(context, 12));
|
||||
container.setBackgroundColor(Color.WHITE);
|
||||
|
||||
for (final String s : arrReportType) {
|
||||
TextView reportTypeTv = new TextView(context);
|
||||
reportTypeTv.setText(s);
|
||||
reportTypeTv.setTextSize(17);
|
||||
reportTypeTv.setTextColor(ContextCompat.getColor(context, R.color.title));
|
||||
reportTypeTv.setBackgroundResource(R.drawable.textview_white_style);
|
||||
reportTypeTv.setLayoutParams(new LinearLayout.LayoutParams((widthPixels * 9) / 10,
|
||||
LinearLayout.LayoutParams.WRAP_CONTENT));
|
||||
reportTypeTv.setPadding(DisplayUtils.dip2px(context, 20), DisplayUtils.dip2px(context, 12),
|
||||
0, DisplayUtils.dip2px(context, 12));
|
||||
container.addView(reportTypeTv);
|
||||
|
||||
reportTypeTv.setOnClickListener(v -> {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
try {
|
||||
jsonObject.put("reason", s);
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
PostCommentUtils.postAnswerReportData(context, commentEntity.getId(), answerId, jsonObject.toString(),
|
||||
new PostCommentUtils.PostCommentListener() {
|
||||
@Override
|
||||
public void postSuccess(JSONObject response) {
|
||||
Utils.toast(context, "感谢您的举报");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postFailed(Throwable error) {
|
||||
Utils.toast(context, error.toString());
|
||||
}
|
||||
});
|
||||
reportTypeDialog.cancel();
|
||||
});
|
||||
}
|
||||
|
||||
reportTypeDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
reportTypeDialog.setContentView(container);
|
||||
reportTypeDialog.show();
|
||||
}
|
||||
|
||||
private static void showReportTypeDialog(final CommentEntity commentEntity, final Context context) {
|
||||
final String[] arrReportType = new String[]{"垃圾广告营销", "恶意攻击谩骂", "淫秽色情信息",
|
||||
"违法有害信息", "其它"};
|
||||
@ -302,12 +187,12 @@ public class CommentUtils {
|
||||
new PostCommentUtils.PostCommentListener() {
|
||||
@Override
|
||||
public void postSuccess(JSONObject response) {
|
||||
Utils.toast(context, "感谢您的举报");
|
||||
Utils.toast(context, "感谢您的投诉");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postFailed(Throwable error) {
|
||||
Utils.toast(context, "举报失败,请检查网络设置");
|
||||
Utils.toast(context, "投诉失败,请检查网络设置");
|
||||
}
|
||||
});
|
||||
reportTypeDialog.cancel();
|
||||
@ -321,74 +206,79 @@ public class CommentUtils {
|
||||
}
|
||||
|
||||
public static void postVote(final Context context, final CommentEntity commentEntity,
|
||||
final TextView commentLikeCountTv, final ImageView commentLikeIv, final OnVoteListener listener) {
|
||||
CheckLoginUtils.checkLogin(context, () -> {
|
||||
if (commentLikeCountTv.getCurrentTextColor() == ContextCompat.getColor(context, R.color.theme)) {
|
||||
Utils.toast(context, "已经点过赞啦!");
|
||||
return;
|
||||
}
|
||||
commentEntity.setVote(commentEntity.getVote() + 1);
|
||||
commentLikeCountTv.setTextColor(ContextCompat.getColor(context, R.color.theme));
|
||||
commentLikeIv.setImageResource(R.drawable.ic_like_select);
|
||||
commentLikeCountTv.setText(String.valueOf(commentEntity.getVote()));
|
||||
commentLikeCountTv.setVisibility(View.VISIBLE);
|
||||
final TextView commentLikeCountTv, final ImageView commentLikeIv,
|
||||
final OnVoteListener listener) {
|
||||
if (commentLikeCountTv.getCurrentTextColor() == ContextCompat.getColor(context, R.color.theme)) {
|
||||
Utils.toast(context, "已经点过赞啦!");
|
||||
return;
|
||||
}
|
||||
commentEntity.setVote(commentEntity.getVote() + 1);
|
||||
commentLikeCountTv.setTextColor(ContextCompat.getColor(context, R.color.theme));
|
||||
commentLikeIv.setImageResource(R.drawable.vote_icon_select);
|
||||
commentLikeCountTv.setText(NumberUtils.transSimpleCount(commentEntity.getVote()));
|
||||
commentLikeCountTv.setVisibility(View.VISIBLE);
|
||||
|
||||
PostCommentUtils.addCommentVoto(context, commentEntity.getId(),
|
||||
new PostCommentUtils.PostCommentListener() {
|
||||
@Override
|
||||
public void postSuccess(JSONObject response) {
|
||||
if (listener != null) {
|
||||
listener.onVote();
|
||||
}
|
||||
PostCommentUtils.addCommentVote(context, commentEntity.getId(),
|
||||
new PostCommentUtils.PostCommentListener() {
|
||||
@Override
|
||||
public void postSuccess(JSONObject response) {
|
||||
if (listener != null) {
|
||||
listener.onVote();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postFailed(Throwable e) {
|
||||
|
||||
commentEntity.setVote(commentEntity.getVote() - 1);
|
||||
commentLikeCountTv.setTextColor(ContextCompat.getColor(context, R.color.hint));
|
||||
commentLikeIv.setImageResource(R.drawable.vote_icon_unselect);
|
||||
commentLikeCountTv.setText(NumberUtils.transSimpleCount(commentEntity.getVote()));
|
||||
if (commentEntity.getVote() == 0) {
|
||||
commentLikeCountTv.setVisibility(View.GONE);
|
||||
} else {
|
||||
commentLikeCountTv.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postFailed(Throwable e) {
|
||||
|
||||
commentEntity.setVote(commentEntity.getVote() - 1);
|
||||
commentLikeCountTv.setTextColor(ContextCompat.getColor(context, R.color.hint));
|
||||
commentLikeIv.setImageResource(R.drawable.ic_like_unselect);
|
||||
commentLikeCountTv.setText(String.valueOf(commentEntity.getVote()));
|
||||
if (commentEntity.getVote() == 0) {
|
||||
commentLikeCountTv.setVisibility(View.GONE);
|
||||
} else {
|
||||
commentLikeCountTv.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
if (e instanceof HttpException) {
|
||||
HttpException exception = (HttpException) e;
|
||||
if (exception.code() == 403) {
|
||||
try {
|
||||
String detail = new JSONObject(exception.response().errorBody().string()).getString("detail");
|
||||
if ("voted".equals(detail)) {
|
||||
Utils.toast(context, "已经点过赞啦!");
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
if (e instanceof HttpException) {
|
||||
HttpException exception = (HttpException) e;
|
||||
if (exception.code() == 403) {
|
||||
try {
|
||||
String detail = new JSONObject(exception.response().errorBody().string()).getString("detail");
|
||||
if ("voted".equals(detail)) {
|
||||
Utils.toast(context, "已经点过赞啦!");
|
||||
}
|
||||
return;
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return;
|
||||
}
|
||||
Utils.toast(context, "网络异常,点赞失败");
|
||||
}
|
||||
});
|
||||
});
|
||||
Utils.toast(context, "网络异常,点赞失败");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void postVoteToAnswerComment(final Context context, String answerId, final CommentEntity commentEntity,
|
||||
public static void postVoteToAnswerComment(final Context context, String answerId, String articleId,
|
||||
String articleCommunityId, final CommentEntity commentEntity,
|
||||
final TextView commentLikeCountTv, final ImageView commentLikeIv, final OnVoteListener listener) {
|
||||
CheckLoginUtils.checkLogin(context, () -> {
|
||||
|
||||
String entrance = "回答详情-评论-点赞";
|
||||
if (TextUtils.isEmpty(articleId)) {
|
||||
entrance = "社区文章详情-评论-点赞";
|
||||
}
|
||||
CheckLoginUtils.checkLogin(context, entrance, () -> {
|
||||
if (commentLikeCountTv.getCurrentTextColor() == ContextCompat.getColor(context, R.color.theme)) {
|
||||
Utils.toast(context, "已经点过赞啦!");
|
||||
return;
|
||||
}
|
||||
commentEntity.setVote(commentEntity.getVote() + 1);
|
||||
commentLikeCountTv.setTextColor(ContextCompat.getColor(context, R.color.theme));
|
||||
commentLikeIv.setImageResource(R.drawable.ic_like_select);
|
||||
commentLikeCountTv.setText(String.valueOf(commentEntity.getVote()));
|
||||
commentLikeIv.setImageResource(R.drawable.vote_icon_select);
|
||||
commentLikeCountTv.setText(NumberUtils.transSimpleCount(commentEntity.getVote()));
|
||||
commentLikeCountTv.setVisibility(View.VISIBLE);
|
||||
|
||||
PostCommentUtils.voteAnswerComment(context, answerId, commentEntity.getId(),
|
||||
PostCommentUtils.voteAnswerComment(context, answerId, articleId, articleCommunityId, commentEntity.getId(),
|
||||
new PostCommentUtils.PostCommentListener() {
|
||||
@Override
|
||||
public void postSuccess(JSONObject response) {
|
||||
@ -402,8 +292,8 @@ public class CommentUtils {
|
||||
|
||||
commentEntity.setVote(commentEntity.getVote() - 1);
|
||||
commentLikeCountTv.setTextColor(ContextCompat.getColor(context, R.color.hint));
|
||||
commentLikeIv.setImageResource(R.drawable.ic_like_unselect);
|
||||
commentLikeCountTv.setText(String.valueOf(commentEntity.getVote()));
|
||||
commentLikeIv.setImageResource(R.drawable.vote_icon_unselect);
|
||||
commentLikeCountTv.setText(NumberUtils.transSimpleCount(commentEntity.getVote()));
|
||||
if (commentEntity.getVote() == 0) {
|
||||
commentLikeCountTv.setVisibility(View.GONE);
|
||||
} else {
|
||||
@ -435,14 +325,14 @@ public class CommentUtils {
|
||||
public static void setCommentUserView(Context mContext, CommentViewHolder holder, CommentEntity entity) {
|
||||
MeEntity userDataEntity = entity.getMe();
|
||||
holder.commentLikeCountTv.setTextColor(ContextCompat.getColor(mContext, R.color.hint));
|
||||
holder.commentLikeIv.setImageResource(R.drawable.ic_like_unselect);
|
||||
holder.commentLikeIv.setImageResource(R.drawable.vote_icon_unselect);
|
||||
|
||||
if (entity.getVote() == 0) {
|
||||
holder.commentLikeCountTv.setVisibility(View.GONE);
|
||||
} else { // 检查是否已点赞
|
||||
if (userDataEntity != null && (userDataEntity.isCommentVoted() || userDataEntity.isAnswerCommentVoted())) {
|
||||
holder.commentLikeCountTv.setTextColor(ContextCompat.getColor(mContext, R.color.theme));
|
||||
holder.commentLikeIv.setImageResource(R.drawable.ic_like_select);
|
||||
holder.commentLikeIv.setImageResource(R.drawable.vote_icon_select);
|
||||
}
|
||||
holder.commentLikeCountTv.setVisibility(View.VISIBLE);
|
||||
holder.commentLikeCountTv.setText(NumberUtils.transSimpleCount(entity.getVote()));
|
||||
|
||||
47
app/src/main/java/com/gh/common/util/CommunityHelper.kt
Normal file
47
app/src/main/java/com/gh/common/util/CommunityHelper.kt
Normal file
@ -0,0 +1,47 @@
|
||||
package com.gh.common.util
|
||||
|
||||
import com.gh.gamecenter.packagehelper.PackageRepository
|
||||
import com.gh.gamecenter.qa.entity.CommunitySelectEntity
|
||||
|
||||
object CommunityHelper {
|
||||
|
||||
/**
|
||||
* 为已开通的社区排序
|
||||
* 排序规则为将本地存在已安装游戏或已关联游戏的社区置顶
|
||||
*/
|
||||
fun sortOpenedCommunity(rawList: List<CommunitySelectEntity>?): ArrayList<CommunitySelectEntity> {
|
||||
val sortedList = ArrayList<CommunitySelectEntity>()
|
||||
rawList?.let {
|
||||
for (game in rawList) {
|
||||
var thisGameIsInstalled = false
|
||||
for (installGame in PackageRepository.gameInstalled) {
|
||||
if (PackageHelper.downloadPackageNameBlackList.contains(installGame.packageName)) {
|
||||
continue
|
||||
}
|
||||
|
||||
// 判断是否已安装
|
||||
if (installGame.id == game.game.id) {
|
||||
thisGameIsInstalled = true
|
||||
break
|
||||
}
|
||||
|
||||
// 判断是否关联了别游戏
|
||||
for (relatedGameId in game.game.relation) {
|
||||
if (installGame.id == relatedGameId) {
|
||||
thisGameIsInstalled = true
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 将已安装的置顶
|
||||
if (thisGameIsInstalled) {
|
||||
sortedList.add(0, game)
|
||||
} else {
|
||||
sortedList.add(game)
|
||||
}
|
||||
}
|
||||
}
|
||||
return sortedList
|
||||
}
|
||||
}
|
||||
@ -29,12 +29,12 @@ object CompressImageUtils {
|
||||
*/
|
||||
@Throws(Exception::class)
|
||||
fun compressImageAndSaveToFile(imageFile: File, compressGif: Boolean): File {
|
||||
// 小于300K直接返回原图
|
||||
// 小于某一个设定的值时,直接返回原图
|
||||
if (imageFile.length() < getImageSetting().processLimitSize) {
|
||||
return imageFile
|
||||
}
|
||||
|
||||
val cacheDir = getImageCacheDir()
|
||||
val cacheDir = getImageCachePatch()
|
||||
val parentFile = cacheDir.parentFile
|
||||
if (!parentFile.exists()) parentFile.mkdirs()
|
||||
var fileOutputStream: FileOutputStream? = null
|
||||
@ -55,6 +55,10 @@ object CompressImageUtils {
|
||||
fileOutputStream = FileOutputStream(cacheDir)
|
||||
// write the compressed bitmap at the destination specified by destinationPath.
|
||||
decodeSampledBitmapFromFile(imageFile).compress(formatType, getImageSetting().quality, fileOutputStream)
|
||||
|
||||
if (cacheDir.length() == 0L) {
|
||||
return imageFile //预防压缩失败
|
||||
}
|
||||
return cacheDir
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
@ -70,7 +74,7 @@ object CompressImageUtils {
|
||||
return imageFile
|
||||
}
|
||||
|
||||
private fun getImageCacheDir(): File {
|
||||
private fun getImageCachePatch(): File {
|
||||
// return File(Environment.getExternalStorageDirectory().absolutePath + "/Pictures/test/" + System.currentTimeMillis() + ".jpg")
|
||||
// 统一用jpg保存应该没有影响吧
|
||||
return File(HaloApp.getInstance().application.cacheDir.absolutePath + File.separator + System.currentTimeMillis() + ".jpg")
|
||||
@ -103,7 +107,6 @@ object CompressImageUtils {
|
||||
} else {
|
||||
inSampleSize = if (longSide / compressLimit == 0) 1 else longSide / compressLimit
|
||||
compressType = CompressType.LIMIT_LONG // 纵向长方形
|
||||
|
||||
}
|
||||
} else if (longSide > compressLimit && shortSide < compressLimit) {
|
||||
if (scale <= getImageSetting().ratio) {
|
||||
@ -136,18 +139,21 @@ object CompressImageUtils {
|
||||
}
|
||||
}
|
||||
matrix.setScale(targetMatrixScale, targetMatrixScale)
|
||||
scaledBitmap = Bitmap.createBitmap(scaledBitmap, 0, 0, scaledBitmap.width, scaledBitmap.height, matrix, true)
|
||||
try {
|
||||
scaledBitmap = Bitmap.createBitmap(scaledBitmap, 0, 0, scaledBitmap.width, scaledBitmap.height, matrix, true)
|
||||
} catch (ignore: OutOfMemoryError) {
|
||||
|
||||
}
|
||||
}
|
||||
return scaledBitmap
|
||||
}
|
||||
|
||||
fun getImageSetting(): SettingsEntity.Image {
|
||||
var settings = Config.getSettings()
|
||||
if (settings == null && settings?.image != null) {
|
||||
return settings.image
|
||||
private fun getImageSetting(): SettingsEntity.Image {
|
||||
val settings = Config.getSettings()
|
||||
if (settings?.image != null) {
|
||||
return settings.image!!
|
||||
}
|
||||
settings = SettingsEntity()
|
||||
val image = settings.Image()
|
||||
val image = SettingsEntity.Image()
|
||||
image.processLimitSize = compressLimitSize
|
||||
image.size = defaultCompressBorder
|
||||
image.ratio = defaultRatio
|
||||
|
||||
@ -2,7 +2,6 @@ package com.gh.common.util;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.view.View;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import com.facebook.drawee.drawable.ScalingUtils;
|
||||
@ -93,12 +92,9 @@ public class ConcernContentUtils {
|
||||
ScalingUtils.ScaleType.CENTER_CROP, list.get(position));
|
||||
break;
|
||||
}
|
||||
imageView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent checkIntent = ViewImageActivity.getViewImageIntent(context, (ArrayList<String>) list, position, entrance);
|
||||
context.startActivity(checkIntent);
|
||||
}
|
||||
imageView.setOnClickListener(v -> {
|
||||
Intent checkIntent = ViewImageActivity.getViewImageIntent(context, (ArrayList<String>) list, position, entrance);
|
||||
context.startActivity(checkIntent);
|
||||
});
|
||||
return imageView;
|
||||
}
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package com.gh.common.util
|
||||
|
||||
import android.content.Context
|
||||
import android.text.TextUtils
|
||||
import com.gh.gamecenter.eventbus.EBConcernChanged
|
||||
import com.gh.gamecenter.manager.UserManager
|
||||
import com.gh.gamecenter.retrofit.Response
|
||||
@ -20,12 +21,17 @@ import retrofit2.HttpException
|
||||
*/
|
||||
object ConcernUtils {
|
||||
|
||||
fun postConcernGameId(context: Context, gameId: String, listener: onConcernListener?) {
|
||||
// val params = JSONArray()
|
||||
// params.put(gameId)
|
||||
// val body = RequestBody.create(MediaType.parse("application/json"), params.toString())
|
||||
RetrofitManager.getInstance(context).getApi()
|
||||
.postConcern(UserManager.getInstance().userId, gameId)
|
||||
/**
|
||||
* autoConcern:是否自动关注'关联关注'
|
||||
*/
|
||||
fun postConcernGameId(context: Context, gameId: String, listener: onConcernListener?, autoConcern: Boolean = false) {
|
||||
val mode = if (autoConcern) "auto" else "manual"
|
||||
|
||||
val userId = UserManager.getInstance().userId
|
||||
if (TextUtils.isEmpty(userId)) return
|
||||
|
||||
RetrofitManager.getInstance(context).api
|
||||
.postConcern(UserManager.getInstance().userId, gameId, mode)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(object : Response<ResponseBody>() {
|
||||
@ -43,7 +49,7 @@ object ConcernUtils {
|
||||
}
|
||||
|
||||
fun deleteConcernData(context: Context, gameId: String, listener: onConcernListener?) {
|
||||
RetrofitManager.getInstance(context).getApi()
|
||||
RetrofitManager.getInstance(context).api
|
||||
.deleteConcern(UserManager.getInstance().userId, gameId)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
@ -64,7 +70,7 @@ object ConcernUtils {
|
||||
fun updateConcernData(context: Context, data: JSONArray) {
|
||||
val body = RequestBody.create(MediaType.parse("application/json"),
|
||||
data.toString())
|
||||
RetrofitManager.getInstance(context).getApi()
|
||||
RetrofitManager.getInstance(context).api
|
||||
.putConcern(UserManager.getInstance().userId, body)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(Schedulers.io())
|
||||
@ -76,7 +82,7 @@ object ConcernUtils {
|
||||
}
|
||||
|
||||
fun deleteConcernQuestions(context: Context, questionsId: String, listener: onConcernListener?) {
|
||||
RetrofitManager.getInstance(context).getApi()
|
||||
RetrofitManager.getInstance(context).api
|
||||
.deleteConcernQuestions(UserManager.getInstance().userId, questionsId)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
@ -89,13 +95,19 @@ object ConcernUtils {
|
||||
override fun onFailure(e: HttpException?) {
|
||||
super.onFailure(e)
|
||||
listener?.onError()
|
||||
AskErrorResponseUtils.errorResponseControl(context, e)
|
||||
var errorString: String? = null
|
||||
try {
|
||||
errorString = e?.response()?.errorBody()?.string()
|
||||
} catch (e1: Exception) {
|
||||
e1.printStackTrace()
|
||||
}
|
||||
ErrorHelper.handleError(context, errorString, false)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fun postConcernQuestions(context: Context, questionsId: String, listener: onConcernListener?) {
|
||||
RetrofitManager.getInstance(context).getApi()
|
||||
RetrofitManager.getInstance(context).api
|
||||
.postConcernQuestions(UserManager.getInstance().userId, questionsId)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
@ -108,7 +120,13 @@ object ConcernUtils {
|
||||
override fun onFailure(e: HttpException?) {
|
||||
super.onFailure(e)
|
||||
listener?.onError()
|
||||
AskErrorResponseUtils.errorResponseControl(context, e)
|
||||
var errorString: String? = null
|
||||
try {
|
||||
errorString = e?.response()?.errorBody()?.string()
|
||||
} catch (e1: Exception) {
|
||||
e1.printStackTrace()
|
||||
}
|
||||
ErrorHelper.handleError(context, errorString, false)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@ -6,7 +6,7 @@ import android.os.Build;
|
||||
import com.gh.gamecenter.entity.GameEntity;
|
||||
import com.gh.gamecenter.entity.NewsDetailEntity;
|
||||
import com.gh.gamecenter.manager.DataCollectionManager;
|
||||
import com.gh.gamecenter.manager.PackageManager;
|
||||
import com.gh.gamecenter.manager.PackagesManager;
|
||||
import com.lightgame.download.DownloadEntity;
|
||||
|
||||
import org.json.JSONArray;
|
||||
@ -118,7 +118,7 @@ public class DataCollectionUtils {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("type", Build.MODEL);
|
||||
map.put("system", Build.VERSION.SDK_INT + "=" + Build.VERSION.RELEASE);
|
||||
map.put("install", PackageManager.INSTANCE.getInstalledList());
|
||||
map.put("install", PackagesManager.INSTANCE.getInstalledList());
|
||||
DataCollectionManager.upsert(context, "user", map);
|
||||
}
|
||||
|
||||
|
||||
@ -27,18 +27,34 @@ import okhttp3.ResponseBody;
|
||||
public class DataLogUtils {
|
||||
|
||||
// 轮播图
|
||||
public static void uploadLunbotuLog(Context context, String type, String title, String location) {
|
||||
public static void uploadLunbotuLog(Context context, String type, String text, String index, String source) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("location", location);
|
||||
map.put("index", index);
|
||||
map.put("type", type);
|
||||
map.put("title", title);
|
||||
map.put("form", "click");
|
||||
uploadLog(context, "lunbotu", map);
|
||||
map.put("text", text);
|
||||
map.put("source", source);
|
||||
uploadLog(context, "slide", map);
|
||||
}
|
||||
|
||||
// 搜索热门标签
|
||||
public static void uploadHotTagLog(Context context, String tag) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("tag", tag);
|
||||
uploadLog(context, "search-hot-tag", map);
|
||||
}
|
||||
|
||||
// 点击下载按钮或进入游戏详情
|
||||
public static void uploadGameLog(Context context, String gameId, String gameName, String entrance) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("game_id", gameId);
|
||||
map.put("game_name", gameName);
|
||||
map.put("entrance", entrance);
|
||||
uploadLog(context, "game", map);
|
||||
}
|
||||
|
||||
// 上传日志
|
||||
public static void uploadLog(Context context, String topic, Map<String, Object> map) {
|
||||
String version = PackageUtils.getPatchVersionName();
|
||||
String version = PackageUtils.getVersionName();
|
||||
String user = Installation.getUUID(context);
|
||||
String channel = HaloApp.getInstance().getChannel();
|
||||
map.put("version", version);
|
||||
|
||||
@ -4,13 +4,19 @@ import android.app.Activity;
|
||||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.gh.common.constant.Config;
|
||||
import com.gh.common.constant.Constants;
|
||||
import com.gh.common.exposure.meta.MetaUtil;
|
||||
import com.gh.gamecenter.BuildConfig;
|
||||
import com.gh.gid.GidCallback;
|
||||
import com.gh.gid.GidHelper;
|
||||
import com.halo.assistant.HaloApp;
|
||||
import com.lightgame.config.CommonDebug;
|
||||
import com.lightgame.utils.Util_System_Phone_State;
|
||||
import com.lightgame.utils.Utils;
|
||||
import com.tencent.bugly.crashreport.CrashReport;
|
||||
import com.tencent.stat.MtaSDkException;
|
||||
import com.tencent.stat.StatConfig;
|
||||
@ -69,7 +75,7 @@ public class DataUtils {
|
||||
|
||||
// 设置数据上报策略
|
||||
// 测试渠道的时候即时上传,方便查看日志
|
||||
if ("GH_TEST".equals(HaloApp.getInstance().getChannel())) {
|
||||
if (Config.DEFAULT_CHANNEL.equals(HaloApp.getInstance().getChannel())) {
|
||||
StatConfig.setStatSendStrategy(StatReportStrategy.INSTANT);
|
||||
} else {
|
||||
StatConfig.setStatSendStrategy(StatReportStrategy.PERIOD);
|
||||
@ -82,25 +88,24 @@ public class DataUtils {
|
||||
StatConfig.init(context);
|
||||
StatConfig.setInstallChannel(channel);
|
||||
StatConfig.setAntoActivityLifecycleStat(true);
|
||||
StatConfig.setAppVersion(PackageUtils.getPatchVersionName());
|
||||
StatConfig.setAppVersion(PackageUtils.getVersionName());
|
||||
|
||||
// 开启收集服务
|
||||
StatService.startStatService(context, Config.MTA_APPKEY, com.tencent.stat.common.StatConstants.VERSION);
|
||||
StatService.registerActivityLifecycleCallbacks(context);
|
||||
|
||||
} catch (MtaSDkException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
// init bugly
|
||||
try {
|
||||
CrashReport.setIsDevelopmentDevice(context, "GH_TEST".equals(channel));
|
||||
CrashReport.setIsDevelopmentDevice(context, Config.DEFAULT_CHANNEL.equals(channel));
|
||||
|
||||
CrashReport.UserStrategy strategy = new CrashReport.UserStrategy(context);
|
||||
strategy.setEnableANRCrashMonitor(false);
|
||||
strategy.setEnableNativeCrashMonitor(false);
|
||||
strategy.setAppChannel(channel);
|
||||
strategy.setAppVersion(PackageUtils.getPatchVersionName());
|
||||
strategy.setAppVersion(PackageUtils.getVersionName());
|
||||
|
||||
CrashReport.initCrashReport(context, Config.BUGLY_APPID, false, strategy);
|
||||
|
||||
@ -115,17 +120,26 @@ public class DataUtils {
|
||||
// if (CommonDebug.IS_DEBUG && (kv == null || kv.length % 2 != 0)) {
|
||||
// throw new IllegalStateException("onEvent kv 必须不为空且数量为偶数");
|
||||
// }
|
||||
Properties prop = new Properties();
|
||||
for (int i = 0; i < kv.length; i++) {
|
||||
if (i % 2 != 0 && i != 0) {
|
||||
String key = kv[i - 1];
|
||||
String value = kv[i];
|
||||
if (!TextUtils.isEmpty(key) && !TextUtils.isEmpty(value)) {
|
||||
prop.setProperty(key, value);
|
||||
}
|
||||
MtaHelper.onEvent(eventId, kv);
|
||||
}
|
||||
|
||||
public static void getGid() {
|
||||
GidHelper.getInstance().registerDevice(new GidCallback() {
|
||||
@Override
|
||||
public void onSuccess(String s) {
|
||||
Utils.log("Gid", s);
|
||||
PreferenceManager.getDefaultSharedPreferences(HaloApp.getInstance().getApplication()).edit().putString(Constants.DEVICE_KEY, s).apply();
|
||||
|
||||
HaloApp.getInstance().setGid(s);
|
||||
// 避免初始化顺序问题导致 MetaUtil 一直持有空的 gid
|
||||
MetaUtil.INSTANCE.refreshMeta();
|
||||
}
|
||||
}
|
||||
StatService.trackCustomKVEvent(context, eventId, prop);
|
||||
|
||||
@Override
|
||||
public void onFailure(String s) {
|
||||
Utils.log(s);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void onEvent(Context var0, String var1, String var2) {
|
||||
@ -199,11 +213,19 @@ public class DataUtils {
|
||||
onEvent(context, "游戏下载", gameName, kv);
|
||||
|
||||
Map<String, Object> kv2 = new HashMap<>();
|
||||
kv2.put("版本", platform);
|
||||
kv2.put("状态", status);
|
||||
kv2.put("位置", entrance);
|
||||
kv2.put("游戏分平台", gameName + "-" + platform);
|
||||
kv2.put("光环助手版本", BuildConfig.VERSION_NAME);
|
||||
|
||||
if (status.equals("开始")) {
|
||||
kv2.put("版本", entrance + "-开始");
|
||||
kv2.put("游戏分平台", gameName + "-" + platform + "-开始");
|
||||
kv2.put("光环助手版本", BuildConfig.VERSION_NAME + "-开始");
|
||||
} else {
|
||||
kv2.put("版本", platform);
|
||||
kv2.put("游戏分平台", gameName + "-" + platform);
|
||||
kv2.put("光环助手版本", BuildConfig.VERSION_NAME);
|
||||
}
|
||||
|
||||
onEvent(context, "游戏下载位置", gameName, kv2);
|
||||
}
|
||||
|
||||
|
||||
@ -4,11 +4,13 @@ import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
|
||||
import com.gh.common.constant.Config;
|
||||
import com.gh.common.repository.ReservationRepository;
|
||||
import com.gh.common.view.DownloadProgressBar;
|
||||
import com.gh.download.DownloadManager;
|
||||
import com.gh.gamecenter.R;
|
||||
import com.gh.gamecenter.adapter.viewholder.DetailViewHolder;
|
||||
import com.gh.gamecenter.manager.PackageManager;
|
||||
import com.gh.gamecenter.entity.PluginLocation;
|
||||
import com.gh.gamecenter.manager.PackagesManager;
|
||||
import com.lightgame.download.DownloadEntity;
|
||||
|
||||
/**
|
||||
@ -29,19 +31,28 @@ public class DetailDownloadUtils {
|
||||
return;
|
||||
}
|
||||
|
||||
if (viewHolder.gameEntity.isReservable()) {
|
||||
if (!ReservationRepository.thisGameHasBeenReserved(viewHolder.gameEntity.getId())) {
|
||||
viewHolder.mDownloadPb.setText("预约《" + viewHolder.gameEntity.getName() + "》");
|
||||
viewHolder.mDownloadPb.setDownloadType(DownloadProgressBar.DownloadType.RESERVABLE);
|
||||
} else {
|
||||
viewHolder.mDownloadPb.setText("已预约《" + viewHolder.gameEntity.getName() + "》");
|
||||
viewHolder.mDownloadPb.setDownloadType(DownloadProgressBar.DownloadType.RESERVED);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (viewHolder.gameEntity.getApk().isEmpty()) {
|
||||
viewHolder.mDownloadPb.setText(TextUtils.isEmpty(viewHolder.downloadOffText) ? "暂无下载" : viewHolder.downloadOffText);
|
||||
viewHolder.mDownloadPb.setDownloadType(DownloadProgressBar.DownloadType.NONE);
|
||||
} else {
|
||||
String status = GameUtils.getDownloadBtnText(viewHolder.context, viewHolder.gameEntity);
|
||||
String status = GameUtils.getDownloadBtnText(viewHolder.context, viewHolder.gameEntity, PluginLocation.only_game);
|
||||
switch (status) {
|
||||
case "插件化":
|
||||
viewHolder.mDownloadPb.setDownloadType(DownloadProgressBar.DownloadType.PLUGIN);
|
||||
break;
|
||||
case "打开":
|
||||
if (viewHolder.gameEntity.getApk().size() == 1) {
|
||||
status = "启动";
|
||||
}
|
||||
case "启动":
|
||||
viewHolder.mDownloadPb.setDownloadType(DownloadProgressBar.DownloadType.LAUNCH_OR_OPEN);
|
||||
break;
|
||||
default:
|
||||
@ -73,11 +84,20 @@ public class DetailDownloadUtils {
|
||||
switch (downloadEntity.getStatus()) {
|
||||
case downloading:
|
||||
case pause:
|
||||
case overflow:
|
||||
viewHolder.mDownloadPb.setText(R.string.downloading);
|
||||
if (downloadEntity.isPluggable() && PackagesManager.INSTANCE.isInstalled(downloadEntity.getPackageName())) {
|
||||
viewHolder.mDownloadPb.setDownloadType(DownloadProgressBar.DownloadType.DOWNLOADING_PLUGIN);
|
||||
} else {
|
||||
viewHolder.mDownloadPb.setDownloadType(DownloadProgressBar.DownloadType.DOWNLOADING_NORMAL);
|
||||
}
|
||||
break;
|
||||
case timeout:
|
||||
case neterror:
|
||||
case waiting:
|
||||
viewHolder.mDownloadPb.setText(R.string.downloading);
|
||||
if (downloadEntity.isPluggable() && PackageManager.INSTANCE.isInstalled(downloadEntity.getPackageName())) {
|
||||
case subscribe:
|
||||
viewHolder.mDownloadPb.setText(R.string.waiting);
|
||||
if (downloadEntity.isPluggable() && PackagesManager.INSTANCE.isInstalled(downloadEntity.getPackageName())) {
|
||||
viewHolder.mDownloadPb.setDownloadType(DownloadProgressBar.DownloadType.DOWNLOADING_PLUGIN);
|
||||
} else {
|
||||
viewHolder.mDownloadPb.setDownloadType(DownloadProgressBar.DownloadType.DOWNLOADING_NORMAL);
|
||||
@ -86,7 +106,7 @@ public class DetailDownloadUtils {
|
||||
case done:
|
||||
viewHolder.mDownloadPb.setText(R.string.install);
|
||||
if (downloadEntity.isPluggable()
|
||||
&& PackageManager.INSTANCE.isInstalled(downloadEntity.getPackageName())) {
|
||||
&& PackagesManager.INSTANCE.isInstalled(downloadEntity.getPackageName())) {
|
||||
viewHolder.mDownloadPb.setDownloadType(DownloadProgressBar.DownloadType.INSTALL_PLUGIN);
|
||||
} else {
|
||||
viewHolder.mDownloadPb.setDownloadType(DownloadProgressBar.DownloadType.INSTALL_NORMAL);
|
||||
|
||||
@ -4,8 +4,9 @@ import android.content.Context
|
||||
import android.os.Environment
|
||||
import android.preference.PreferenceManager
|
||||
import com.gh.gamecenter.BuildConfig
|
||||
import com.gh.gamecenter.entity.TimeEntity
|
||||
import com.gh.gamecenter.retrofit.Response
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager
|
||||
import com.gh.gamecenter.retrofit.StringResponse
|
||||
import com.halo.assistant.HaloApp
|
||||
import com.lightgame.utils.Util_System_Phone_State
|
||||
import com.lightgame.utils.Utils
|
||||
@ -13,7 +14,6 @@ import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
import java.io.File
|
||||
|
||||
|
||||
object DeviceTokenUtils {
|
||||
|
||||
const val DEVICE_ID = "uuid"
|
||||
@ -26,18 +26,13 @@ object DeviceTokenUtils {
|
||||
RetrofitManager.getInstance(context).api.time
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(object : StringResponse() {
|
||||
override fun onResponse(response: String) {
|
||||
if (response.matches("^[0-9]{10}$".toRegex())) {
|
||||
try {
|
||||
val editor = sp.edit()
|
||||
editor.putLong("server_time", java.lang.Long.parseLong(response))
|
||||
editor.putLong("client_time", System.currentTimeMillis() / 1000)
|
||||
editor.apply()
|
||||
} catch (e: NumberFormatException) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
|
||||
.subscribe(object : Response<TimeEntity>() {
|
||||
override fun onResponse(response: TimeEntity?) {
|
||||
val editor = sp.edit()
|
||||
response?.time?.let {
|
||||
editor.putLong("server_time", it)
|
||||
editor.putLong("client_time", System.currentTimeMillis() / 1000)
|
||||
editor.apply()
|
||||
}
|
||||
}
|
||||
})
|
||||
@ -51,18 +46,18 @@ object DeviceTokenUtils {
|
||||
if (values.isNotEmpty()) {
|
||||
for (value in values) {
|
||||
if (value.key.contains("isNewFirstLaunchV")) {
|
||||
lunchType = LunchType.update
|
||||
lunchType = LunchType.UPDATE
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
// 再次重装
|
||||
if (lunchType == null && !getDeviceId().isNullOrEmpty()) {
|
||||
lunchType = LunchType.again
|
||||
lunchType = LunchType.AGAIN
|
||||
}
|
||||
// 首次安装
|
||||
if (lunchType == null) {
|
||||
lunchType = LunchType.first
|
||||
lunchType = LunchType.FIRST
|
||||
}
|
||||
// 保存deviceId
|
||||
var deviceId = Util_System_Phone_State.getDeviceId(HaloApp.getInstance().application)
|
||||
@ -133,7 +128,7 @@ object DeviceTokenUtils {
|
||||
}
|
||||
|
||||
enum class LunchType {
|
||||
first,
|
||||
update,
|
||||
again
|
||||
FIRST,
|
||||
UPDATE,
|
||||
AGAIN
|
||||
}
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package com.gh.common.util;
|
||||
|
||||
import android.app.ActivityManager;
|
||||
import android.content.Context;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
@ -128,6 +129,20 @@ public class DeviceUtils {
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
public static String getUserAgent() {
|
||||
String userAgent = "";
|
||||
userAgent = System.getProperty("http.agent");
|
||||
StringBuffer sb = new StringBuffer();
|
||||
for (int i = 0, length = userAgent.length(); i < length; i++) {
|
||||
char c = userAgent.charAt(i);
|
||||
if (c <= '\u001f' || c >= '\u007f') {
|
||||
sb.append(String.format("\\u%04x", (int) c));
|
||||
} else {
|
||||
sb.append(c);
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public static String getIPAddress(Context context) {
|
||||
NetworkInfo info = ((ConnectivityManager) context
|
||||
@ -201,7 +216,7 @@ public class DeviceUtils {
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
return "无网络";
|
||||
}
|
||||
|
||||
|
||||
@ -224,7 +239,6 @@ public class DeviceUtils {
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
// ping domain
|
||||
public static String ping(String domain) {
|
||||
try {
|
||||
@ -243,5 +257,13 @@ public class DeviceUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public static long getTotalRamSizeOfDevice(Context context) {
|
||||
ActivityManager actManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
|
||||
ActivityManager.MemoryInfo memInfo = new ActivityManager.MemoryInfo();
|
||||
if (actManager != null) {
|
||||
actManager.getMemoryInfo(memInfo);
|
||||
}
|
||||
return memInfo.totalMem / (1024 * 1024);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,91 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2015 Baidu, Inc. All Rights Reserved.
|
||||
*/
|
||||
package com.gh.common.util;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
|
||||
/**
|
||||
* Created by sunpengfei on 15/11/4.
|
||||
*/
|
||||
public class DexUtils {
|
||||
|
||||
private static final int BUF_SIZE = 2048;
|
||||
|
||||
public static boolean prepareAssetsDex(Context context, File dexInternalStoragePath, String dex_file) {
|
||||
BufferedInputStream bis = null;
|
||||
OutputStream dexWriter = null;
|
||||
|
||||
try {
|
||||
bis = new BufferedInputStream(context.getAssets().open(dex_file));
|
||||
dexWriter = new BufferedOutputStream(new FileOutputStream(dexInternalStoragePath));
|
||||
byte[] buf = new byte[BUF_SIZE];
|
||||
int len;
|
||||
while ((len = bis.read(buf, 0, BUF_SIZE)) > 0) {
|
||||
dexWriter.write(buf, 0, len);
|
||||
}
|
||||
dexWriter.close();
|
||||
bis.close();
|
||||
return true;
|
||||
} catch (IOException e) {
|
||||
if (dexWriter != null) {
|
||||
try {
|
||||
dexWriter.close();
|
||||
} catch (IOException ioe) {
|
||||
ioe.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (bis != null) {
|
||||
try {
|
||||
bis.close();
|
||||
} catch (IOException ioe) {
|
||||
ioe.printStackTrace();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean prepareDex(File dexInternalStoragePath, File dex_file) {
|
||||
BufferedInputStream bis = null;
|
||||
OutputStream dexWriter = null;
|
||||
|
||||
try {
|
||||
bis = new BufferedInputStream(new FileInputStream(dex_file));
|
||||
dexWriter = new BufferedOutputStream(new FileOutputStream(dexInternalStoragePath));
|
||||
byte[] buf = new byte[BUF_SIZE];
|
||||
int len;
|
||||
while ((len = bis.read(buf, 0, BUF_SIZE)) > 0) {
|
||||
dexWriter.write(buf, 0, len);
|
||||
}
|
||||
dexWriter.close();
|
||||
bis.close();
|
||||
return true;
|
||||
} catch (IOException e) {
|
||||
if (dexWriter != null) {
|
||||
try {
|
||||
dexWriter.close();
|
||||
} catch (IOException ioe) {
|
||||
ioe.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (bis != null) {
|
||||
try {
|
||||
bis.close();
|
||||
} catch (IOException ioe) {
|
||||
ioe.printStackTrace();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -4,15 +4,19 @@ import android.app.Activity;
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Color;
|
||||
import android.os.Handler;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.text.Html;
|
||||
import android.text.SpannableStringBuilder;
|
||||
import android.text.Spanned;
|
||||
import android.text.TextPaint;
|
||||
import android.text.TextUtils;
|
||||
import android.text.method.LinkMovementMethod;
|
||||
import android.text.style.ClickableSpan;
|
||||
import android.view.Display;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
@ -24,10 +28,18 @@ import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.gh.gamecenter.KcSelectGameActivity;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import com.gh.gamecenter.AboutActivity;
|
||||
import com.gh.gamecenter.R;
|
||||
import com.gh.gamecenter.WebActivity;
|
||||
import com.gh.gamecenter.kuaichuan.WifiMgr;
|
||||
import com.gh.gamecenter.kuaichuan.view.KcSelectGameActivity;
|
||||
import com.halo.assistant.HaloApp;
|
||||
import com.lightgame.utils.AppManager;
|
||||
import com.lightgame.utils.Utils;
|
||||
|
||||
import java.io.File;
|
||||
import java.text.DecimalFormat;
|
||||
@ -39,12 +51,12 @@ import java.util.Map;
|
||||
|
||||
public class DialogUtils {
|
||||
|
||||
private static boolean isShow = false;
|
||||
|
||||
public static Dialog showWaitDialog(Context context, String msg) {
|
||||
context = checkDialogContext(context);
|
||||
|
||||
Dialog dialog = new Dialog(context);
|
||||
View view = View.inflate(context, R.layout.set_wait_dialog, null);
|
||||
TextView message = (TextView) view.findViewById(R.id.set_wait_message);
|
||||
TextView message = view.findViewById(R.id.set_wait_message);
|
||||
message.setText(msg);
|
||||
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
dialog.setContentView(view);
|
||||
@ -63,27 +75,23 @@ public class DialogUtils {
|
||||
|
||||
WifiMgr.getInstance(activity).disconnectCurrentNetwork(); // 断开当前WiFi
|
||||
|
||||
// int heightPixels = getContext().getResources().getDisplayMetrics().heightPixels;
|
||||
// int widthPixels = getContext().getResources().getDisplayMetrics().widthPixels;
|
||||
|
||||
int filesCount = mapList.size();
|
||||
int filesSize = 0;
|
||||
int sendTime = 0;
|
||||
|
||||
View view = View.inflate(activity, R.layout.dialog_kuaichuan, null);
|
||||
final LinearLayout mShareLl = (LinearLayout) view.findViewById(R.id.kuaichuan_dialog_ll);
|
||||
final LinearLayout mShareBottomLl = (LinearLayout) view.findViewById(R.id.kuaichuan_dialog_share_rl);
|
||||
LinearLayout shareIconLl = (LinearLayout) view.findViewById(R.id.kuaichuan_icon_ll);
|
||||
ImageView qrCode = (ImageView) view.findViewById(R.id.kuaichuan_qrcode);
|
||||
TextView dateTv = (TextView) view.findViewById(R.id.kuaichuan_dialog_date);
|
||||
TextView countTv = (TextView) view.findViewById(R.id.kuaichuan_send_count);
|
||||
TextView sizeTv = (TextView) view.findViewById(R.id.kuaichuan_send_size);
|
||||
TextView speedTv = (TextView) view.findViewById(R.id.kuaichuan_send_speed);
|
||||
TextView timeCount = (TextView) view.findViewById(R.id.kuaichuan_time_count);
|
||||
TextView timeTv = (TextView) view.findViewById(R.id.kuaichuan_time_tv);
|
||||
TextView sendCountTv = (TextView) view.findViewById(R.id.dialog_send_tv);
|
||||
ImageView closeIv = (ImageView) view.findViewById(R.id.kuaichuan_dialog_colse);
|
||||
// content.setLayoutParams(new LinearLayout.LayoutParams((int)(((float)heightPixels)*0.85), (int)((float)widthPixels*0.81)));
|
||||
final LinearLayout mShareLl = view.findViewById(R.id.kuaichuan_dialog_ll);
|
||||
final LinearLayout mShareBottomLl = view.findViewById(R.id.kuaichuan_dialog_share_rl);
|
||||
LinearLayout shareIconLl = view.findViewById(R.id.kuaichuan_icon_ll);
|
||||
ImageView qrCode = view.findViewById(R.id.kuaichuan_qrcode);
|
||||
TextView dateTv = view.findViewById(R.id.kuaichuan_dialog_date);
|
||||
TextView countTv = view.findViewById(R.id.kuaichuan_send_count);
|
||||
TextView sizeTv = view.findViewById(R.id.kuaichuan_send_size);
|
||||
TextView speedTv = view.findViewById(R.id.kuaichuan_send_speed);
|
||||
TextView timeCount = view.findViewById(R.id.kuaichuan_time_count);
|
||||
TextView timeTv = view.findViewById(R.id.kuaichuan_time_tv);
|
||||
TextView sendCountTv = view.findViewById(R.id.dialog_send_tv);
|
||||
ImageView closeIv = view.findViewById(R.id.kuaichuan_dialog_colse);
|
||||
|
||||
final Dialog dialog = new Dialog(activity);
|
||||
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
@ -126,7 +134,7 @@ public class DialogUtils {
|
||||
ApplicationInfo appInfo = info.applicationInfo;
|
||||
appInfo.sourceDir = apkPath;
|
||||
appInfo.publicSourceDir = apkPath;
|
||||
Bitmap bitmap = BitmapUtils.drawableToBitmap(appInfo.loadIcon(pm));
|
||||
Bitmap bitmap = BitmapUtils.drawableToBitmap(appInfo.loadIcon(pm), true);
|
||||
|
||||
ImageView imageView = new ImageView(activity);
|
||||
imageView.setLayoutParams(new LinearLayout.LayoutParams(DisplayUtils.dip2px(activity, 25)
|
||||
@ -185,24 +193,16 @@ public class DialogUtils {
|
||||
countTv.setText(filesCount + "个");
|
||||
|
||||
// 延迟操作,等待截图部分绘制完成
|
||||
handler.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
mShareLl.setDrawingCacheEnabled(true);
|
||||
mShareLl.buildDrawingCache();
|
||||
Bitmap drawingCache = mShareLl.getDrawingCache();
|
||||
saveBitmap(drawingCache, activity, picName);
|
||||
MessageShareUtils.getInstance(activity).showShareWindows(activity, mShareBottomLl, drawingCache, picName, 2);
|
||||
mShareBottomLl.setVisibility(View.VISIBLE);
|
||||
}
|
||||
handler.postDelayed(() -> {
|
||||
mShareLl.setDrawingCacheEnabled(true);
|
||||
mShareLl.buildDrawingCache();
|
||||
Bitmap drawingCache = mShareLl.getDrawingCache();
|
||||
saveBitmap(drawingCache, activity, picName);
|
||||
MessageShareUtils.getInstance(activity).showShareWindows(activity, mShareBottomLl, drawingCache, picName, 2);
|
||||
mShareBottomLl.setVisibility(View.VISIBLE);
|
||||
}, 200);
|
||||
|
||||
closeIv.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
dialog.cancel();
|
||||
}
|
||||
});
|
||||
closeIv.setOnClickListener(v -> dialog.cancel());
|
||||
}
|
||||
|
||||
public static void saveBitmap(Bitmap bm, Activity activity, String picName) {
|
||||
@ -222,110 +222,82 @@ public class DialogUtils {
|
||||
}
|
||||
|
||||
public static void showInstallHintDialog(Context context, final ConfirmListener cmListener) {
|
||||
|
||||
context = checkDialogContext(context);
|
||||
|
||||
final Dialog dialog = new Dialog(context);
|
||||
|
||||
View view = View.inflate(context, R.layout.dialog_install_hint, null);
|
||||
|
||||
// 标题
|
||||
TextView alertdialog_title = (TextView) view.findViewById(R.id.installhint_title);
|
||||
TextView alertdialog_title = view.findViewById(R.id.installhint_title);
|
||||
alertdialog_title.setText("重要提示");
|
||||
Spanned content = Html.fromHtml("如果您使用的是" + "<font color=\"#ff0000\">华为</font>" + "或" +
|
||||
"<font color=\"#ff0000\">OPPO</font>" + "手机,安装游戏时请选择“" +
|
||||
"<font color=\"#ff0000\">继续安装</font>" +
|
||||
"”(记住不要选择“官方推荐”或“软件商店安装”)");
|
||||
// 内容
|
||||
TextView alertdialog_content = (TextView) view.findViewById(R.id.installhint_content);
|
||||
TextView alertdialog_content = view.findViewById(R.id.installhint_content);
|
||||
alertdialog_content.setText(content);
|
||||
|
||||
// 确定按钮
|
||||
TextView installhint_confirm = (TextView) view.findViewById(R.id.installhint_confirm);
|
||||
TextView installhint_confirm = view.findViewById(R.id.installhint_confirm);
|
||||
installhint_confirm.setText("知道了");
|
||||
|
||||
final ImageView installhint_unselect = (ImageView) view.findViewById(R.id.installhint_unselect);
|
||||
final ImageView installhint_select = (ImageView) view.findViewById(R.id.installhint_select);
|
||||
final ImageView installhint_unselect = view.findViewById(R.id.installhint_unselect);
|
||||
final ImageView installhint_select = view.findViewById(R.id.installhint_select);
|
||||
|
||||
LinearLayout installhint_unselect_ll = (LinearLayout) view.findViewById(R.id.installhint_unselect_ll);
|
||||
LinearLayout installhint_unselect_ll = view.findViewById(R.id.installhint_unselect_ll);
|
||||
|
||||
installhint_unselect_ll.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (installhint_unselect.getVisibility() == View.GONE) {
|
||||
installhint_unselect.setVisibility(View.VISIBLE);
|
||||
installhint_select.setVisibility(View.GONE);
|
||||
} else {
|
||||
installhint_unselect.setVisibility(View.GONE);
|
||||
installhint_select.setVisibility(View.VISIBLE);
|
||||
}
|
||||
installhint_unselect_ll.setOnClickListener(v -> {
|
||||
if (installhint_unselect.getVisibility() == View.GONE) {
|
||||
installhint_unselect.setVisibility(View.VISIBLE);
|
||||
installhint_select.setVisibility(View.GONE);
|
||||
} else {
|
||||
installhint_unselect.setVisibility(View.GONE);
|
||||
installhint_select.setVisibility(View.VISIBLE);
|
||||
}
|
||||
});
|
||||
|
||||
installhint_confirm.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
dialog.dismiss();
|
||||
if (installhint_select.getVisibility() == View.VISIBLE) {
|
||||
if (cmListener != null) {
|
||||
cmListener.onConfirm();
|
||||
}
|
||||
installhint_confirm.setOnClickListener(v -> {
|
||||
dialog.dismiss();
|
||||
if (installhint_select.getVisibility() == View.VISIBLE) {
|
||||
if (cmListener != null) {
|
||||
cmListener.onConfirm();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
dialog.setOnDismissListener(new Dialog.OnDismissListener() {
|
||||
@Override
|
||||
public void onDismiss(DialogInterface dialog) {
|
||||
isShow = false;
|
||||
}
|
||||
});
|
||||
|
||||
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
dialog.setContentView(view);
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
public static void showHintDialog(Context context, String title, CharSequence msg, String confirm) {
|
||||
context = checkDialogContext(context);
|
||||
|
||||
final Dialog dialog = new Dialog(context);
|
||||
|
||||
View view = View.inflate(context, R.layout.common_hintdialog, null);
|
||||
|
||||
TextView hintdialog_title = (TextView) view.findViewById(R.id.tv_dialog_hint_title);
|
||||
TextView hintdialog_title = view.findViewById(R.id.tv_dialog_hint_title);
|
||||
hintdialog_title.setText(title);
|
||||
|
||||
// 内容
|
||||
TextView hintdialog_content = (TextView) view.findViewById(R.id.tv_dialog_hint_content);
|
||||
TextView hintdialog_content = view.findViewById(R.id.tv_dialog_hint_content);
|
||||
hintdialog_content.setText(msg);
|
||||
|
||||
TextView hintdialog_confirm = (TextView) view.findViewById(R.id.tv_dialog_hint_confirm);
|
||||
TextView hintdialog_confirm = view.findViewById(R.id.tv_dialog_hint_confirm);
|
||||
|
||||
hintdialog_confirm.setText(confirm);
|
||||
|
||||
hintdialog_confirm.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
dialog.cancel();
|
||||
}
|
||||
});
|
||||
hintdialog_confirm.setOnClickListener(v -> dialog.cancel());
|
||||
|
||||
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
dialog.setContentView(view);
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
public static void showHijackDialog(final Context context) {
|
||||
showWarningDialog(context, "警告", "您当前网络环境异常,下载地址已被替换(网络劫持),请更换网络环境进行下载。",
|
||||
new ConfirmListener() {
|
||||
@Override
|
||||
public void onConfirm() {
|
||||
// 跳转wifi管理界面
|
||||
context.startActivity(IntentUtils.getWifiIntent());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void showWarningDialog(Context context, String title, CharSequence msg, final ConfirmListener listener) {
|
||||
//TODO fix this
|
||||
if (!(context instanceof Activity)) {
|
||||
return;
|
||||
}
|
||||
@ -342,18 +314,73 @@ public class DialogUtils {
|
||||
public static void showQqSessionDialog(final Context context, final String qq) {
|
||||
showWarningDialog(context, "警告", "您当前网络环境异常,下载地址可能被运营商恶意替换(网络劫持)" +
|
||||
",如多次下载失败,请联系客服获取正确的下载地址(客服QQ:" + qq + ")"
|
||||
, "取消", "前往QQ", new ConfirmListener() {
|
||||
@Override
|
||||
public void onConfirm() {
|
||||
DirectUtils.directToQqConversation(context, qq);
|
||||
}
|
||||
}, null);
|
||||
, "取消", "前往QQ", () -> DirectUtils.directToQqConversation(context, qq), null);
|
||||
}
|
||||
|
||||
public static void checkDownload(Context context, String size, CheckDownloadCallBack callBack) {
|
||||
if (!NetworkUtils.isNetworkConnected(context)) {
|
||||
showNoConnectionDownloadDialog(context, null,
|
||||
() -> callBack.onResponse(true));
|
||||
} else if (NetworkUtils.isWifiConnected(context) || filter4GorSize(context, size)) {
|
||||
callBack.onResponse(false);
|
||||
} else {
|
||||
MtaHelper.onEvent("移动网络下载", NetworkUtils.getMobileNetworkType(context), "出现弹窗提示");
|
||||
showDownloadDialog(context,
|
||||
() -> {
|
||||
callBack.onResponse(false);
|
||||
MtaHelper.onEvent("移动网络下载", NetworkUtils.getMobileNetworkType(context), "立即下载");
|
||||
},
|
||||
() -> {
|
||||
callBack.onResponse(true);
|
||||
MtaHelper.onEvent("移动网络下载", NetworkUtils.getMobileNetworkType(context), "连上WiFi后自动下载");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean filter4GorSize(Context context, String size) {
|
||||
try {
|
||||
if (TextUtils.isEmpty(size)) {
|
||||
return false;
|
||||
}
|
||||
String mb = size.toUpperCase().replaceAll("MB", "").trim();
|
||||
Float i = Float.valueOf(mb);
|
||||
if (NetworkUtils.isWifiOr4GConnected(context) && i <= 50) {
|
||||
Utils.toast(context, "当前使用移动流量下载");
|
||||
return true;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void checkResumeDownload(Context context, CheckDownloadCallBack callBack) {
|
||||
if (!NetworkUtils.isNetworkConnected(context)) {
|
||||
showNoConnectionDownloadDialog(context, null, () -> callBack.onResponse(true));
|
||||
} else if (NetworkUtils.isWifiConnected(context)) {
|
||||
callBack.onResponse(false);
|
||||
} else {
|
||||
showResumeDownloadDialog(context, () -> {
|
||||
callBack.onResponse(false);
|
||||
}, () -> {
|
||||
callBack.onResponse(true);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public static void showNoConnectionDownloadDialog(Context context, ConfirmListener listener, CancelListener cancelListener) {
|
||||
showWarningDialog(context, "下载提示", "网络异常,请检查手机网络状态", "连上WiFi后自动下载", "关闭", listener, cancelListener);
|
||||
}
|
||||
|
||||
public static void showDownloadDialog(Context context, ConfirmListener listener, CancelListener cancelListener) {
|
||||
showWarningDialog(context, "下载提示", "您当前使用的网络为2G/3G/4G,开始下载将会消耗移动流量,确定下载?", "取消", "确定", listener, cancelListener);
|
||||
showWarningDialog(context, "下载提示", "当前正在使用移动网络,立即下载会消耗手机流量", "连上WiFi后自动下载", "立即下载", listener, cancelListener);
|
||||
}
|
||||
|
||||
public static void showResumeDownloadDialog(Context context, ConfirmListener listener, CancelListener cancelListener) {
|
||||
showWarningDialog(context, "下载提示", "当前正在使用移动网络,继续下载会消耗手机流量", "连上WiFi后自动下载", "继续下载", listener, cancelListener);
|
||||
}
|
||||
|
||||
|
||||
public static void showDownloadDialog(Context context, ConfirmListener listener) {
|
||||
showWarningDialog(context, "下载提示", "您当前使用的网络为2G/3G/4G,开始下载将会消耗移动流量,确定下载?", listener);
|
||||
}
|
||||
@ -383,6 +410,7 @@ public class DialogUtils {
|
||||
*/
|
||||
public static Dialog showAlertDialog(Context context, String title, CharSequence message
|
||||
, String positive, String negative, final ConfirmListener cmListener, final CancelListener clListener) {
|
||||
context = checkDialogContext(context);
|
||||
|
||||
final Dialog dialog = new Dialog(context, R.style.GhAlertDialog);
|
||||
|
||||
@ -391,30 +419,100 @@ public class DialogUtils {
|
||||
TextView titleTv = contentView.findViewById(R.id.dialog_title);
|
||||
TextView negativeTv = contentView.findViewById(R.id.dialog_negative);
|
||||
TextView positiveTv = contentView.findViewById(R.id.dialog_positive);
|
||||
if (message.toString().contains("红包奖励")) {//将红包奖励四个字标红
|
||||
String str = message.toString().substring(0, message.toString().indexOf("红包奖励")) + "<font color='#FF0000'>红包奖励</font>";
|
||||
contentTv.setText(Html.fromHtml(str));
|
||||
} else {
|
||||
contentTv.setText(message);
|
||||
}
|
||||
titleTv.setText(title);
|
||||
negativeTv.setText(negative);
|
||||
positiveTv.setText(positive);
|
||||
|
||||
negativeTv.setOnClickListener(view -> {
|
||||
if (clListener != null) {
|
||||
clListener.onCancel();
|
||||
}
|
||||
dialog.dismiss();
|
||||
});
|
||||
|
||||
positiveTv.setOnClickListener(view -> {
|
||||
if (cmListener != null) {
|
||||
cmListener.onConfirm();
|
||||
}
|
||||
dialog.dismiss();
|
||||
});
|
||||
|
||||
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
dialog.setContentView(contentView);
|
||||
dialog.show();
|
||||
return dialog;
|
||||
}
|
||||
|
||||
public static Dialog showAlertDialog(Context context, String title, Spanned message
|
||||
, String positive, String negative, final ConfirmListener cmListener, final CancelListener clListener) {
|
||||
context = checkDialogContext(context);
|
||||
|
||||
final Dialog dialog = new Dialog(context, R.style.GhAlertDialog);
|
||||
|
||||
View contentView = LayoutInflater.from(context).inflate(R.layout.dialog_alert, null);
|
||||
TextView contentTv = contentView.findViewById(R.id.dialog_content);
|
||||
TextView titleTv = contentView.findViewById(R.id.dialog_title);
|
||||
TextView negativeTv = contentView.findViewById(R.id.dialog_negative);
|
||||
TextView positiveTv = contentView.findViewById(R.id.dialog_positive);
|
||||
contentTv.setText(message);
|
||||
titleTv.setText(title);
|
||||
negativeTv.setText(negative);
|
||||
positiveTv.setText(positive);
|
||||
|
||||
negativeTv.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (clListener != null) {
|
||||
clListener.onCancel();
|
||||
}
|
||||
dialog.dismiss();
|
||||
negativeTv.setOnClickListener(view -> {
|
||||
if (clListener != null) {
|
||||
clListener.onCancel();
|
||||
}
|
||||
dialog.dismiss();
|
||||
});
|
||||
|
||||
positiveTv.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (cmListener != null) {
|
||||
cmListener.onConfirm();
|
||||
}
|
||||
dialog.dismiss();
|
||||
positiveTv.setOnClickListener(view -> {
|
||||
if (cmListener != null) {
|
||||
cmListener.onConfirm();
|
||||
}
|
||||
dialog.dismiss();
|
||||
});
|
||||
|
||||
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
dialog.setContentView(contentView);
|
||||
dialog.show();
|
||||
return dialog;
|
||||
}
|
||||
|
||||
public static Dialog showDialogWithHtmlContent(Context context, String title, String content
|
||||
, String positive, String negative, final ConfirmListener cmListener, final CancelListener clListener) {
|
||||
context = checkDialogContext(context);
|
||||
|
||||
final Dialog dialog = new Dialog(context, R.style.GhAlertDialog);
|
||||
|
||||
View contentView = LayoutInflater.from(context).inflate(R.layout.dialog_alert, null);
|
||||
TextView contentTv = contentView.findViewById(R.id.dialog_content);
|
||||
TextView titleTv = contentView.findViewById(R.id.dialog_title);
|
||||
TextView negativeTv = contentView.findViewById(R.id.dialog_negative);
|
||||
TextView positiveTv = contentView.findViewById(R.id.dialog_positive);
|
||||
contentTv.setText(Html.fromHtml(content));
|
||||
titleTv.setText(title);
|
||||
negativeTv.setText(negative);
|
||||
positiveTv.setText(positive);
|
||||
|
||||
negativeTv.setOnClickListener(view -> {
|
||||
if (clListener != null) {
|
||||
clListener.onCancel();
|
||||
}
|
||||
dialog.dismiss();
|
||||
});
|
||||
|
||||
positiveTv.setOnClickListener(view -> {
|
||||
if (cmListener != null) {
|
||||
cmListener.onConfirm();
|
||||
}
|
||||
dialog.dismiss();
|
||||
});
|
||||
|
||||
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
@ -436,6 +534,7 @@ public class DialogUtils {
|
||||
|
||||
public static void showCancelAlertDialog(Context context, String title, CharSequence message
|
||||
, String positive, String negative, final ConfirmListener cmListener, final CancelListener clListener) {
|
||||
context = checkDialogContext(context);
|
||||
|
||||
final Dialog dialog = new Dialog(context, R.style.GhAlertDialog);
|
||||
|
||||
@ -451,24 +550,18 @@ public class DialogUtils {
|
||||
negativeTv.setTextColor(ContextCompat.getColor(context, R.color.hint));
|
||||
positiveTv.setText(positive);
|
||||
|
||||
negativeTv.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (clListener != null) {
|
||||
clListener.onCancel();
|
||||
}
|
||||
dialog.dismiss();
|
||||
negativeTv.setOnClickListener(view -> {
|
||||
if (clListener != null) {
|
||||
clListener.onCancel();
|
||||
}
|
||||
dialog.dismiss();
|
||||
});
|
||||
|
||||
positiveTv.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (cmListener != null) {
|
||||
cmListener.onConfirm();
|
||||
}
|
||||
dialog.dismiss();
|
||||
positiveTv.setOnClickListener(view -> {
|
||||
if (cmListener != null) {
|
||||
cmListener.onConfirm();
|
||||
}
|
||||
dialog.dismiss();
|
||||
});
|
||||
|
||||
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
@ -483,7 +576,7 @@ public class DialogUtils {
|
||||
*/
|
||||
public static void showCancelListenerDialog(Context context, String title, CharSequence message
|
||||
, String positive, String negative, final ConfirmListener cmListener, final CancelListener clListener) {
|
||||
|
||||
context = checkDialogContext(context);
|
||||
|
||||
final Dialog dialog = new Dialog(context, R.style.GhAlertDialog);
|
||||
|
||||
@ -509,24 +602,18 @@ public class DialogUtils {
|
||||
}
|
||||
});
|
||||
|
||||
positiveTv.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (cmListener != null) {
|
||||
cmListener.onConfirm();
|
||||
}
|
||||
dialog.dismiss();
|
||||
positiveTv.setOnClickListener(view -> {
|
||||
if (cmListener != null) {
|
||||
cmListener.onConfirm();
|
||||
}
|
||||
dialog.dismiss();
|
||||
});
|
||||
|
||||
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
dialog.setContentView(contentView);
|
||||
dialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
|
||||
@Override
|
||||
public void onCancel(DialogInterface dialogInterface) {
|
||||
if (clListener != null)
|
||||
clListener.onCancel();
|
||||
}
|
||||
dialog.setOnCancelListener(dialogInterface -> {
|
||||
if (clListener != null)
|
||||
clListener.onCancel();
|
||||
});
|
||||
dialog.show();
|
||||
|
||||
@ -540,6 +627,7 @@ public class DialogUtils {
|
||||
*/
|
||||
public static void showPermissionDialog(Context context, String title, CharSequence message
|
||||
, String positive, String negative, final ConfirmListener cmListener, final CancelListener clListener) {
|
||||
context = checkDialogContext(context);
|
||||
|
||||
final Dialog dialog = new Dialog(context, R.style.GhAlertDialog);
|
||||
|
||||
@ -555,24 +643,18 @@ public class DialogUtils {
|
||||
negativeTv.setTextColor(ContextCompat.getColor(context, R.color.hint));
|
||||
positiveTv.setText(positive);
|
||||
|
||||
negativeTv.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (clListener != null) {
|
||||
clListener.onCancel();
|
||||
}
|
||||
dialog.dismiss();
|
||||
negativeTv.setOnClickListener(view -> {
|
||||
if (clListener != null) {
|
||||
clListener.onCancel();
|
||||
}
|
||||
dialog.dismiss();
|
||||
});
|
||||
|
||||
positiveTv.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (cmListener != null) {
|
||||
cmListener.onConfirm();
|
||||
}
|
||||
dialog.dismiss();
|
||||
positiveTv.setOnClickListener(view -> {
|
||||
if (cmListener != null) {
|
||||
cmListener.onConfirm();
|
||||
}
|
||||
dialog.dismiss();
|
||||
});
|
||||
|
||||
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
@ -587,6 +669,7 @@ public class DialogUtils {
|
||||
*/
|
||||
public static void showForceDialog(Context context, String title, CharSequence message
|
||||
, String positive, String negative, final ConfirmListener cmListener, final CancelListener clListener) {
|
||||
context = checkDialogContext(context);
|
||||
|
||||
final Dialog dialog = new Dialog(context, R.style.GhAlertDialog);
|
||||
|
||||
@ -601,24 +684,18 @@ public class DialogUtils {
|
||||
negativeTv.setText(negative);
|
||||
positiveTv.setText(positive);
|
||||
|
||||
negativeTv.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (clListener != null) {
|
||||
clListener.onCancel();
|
||||
}
|
||||
dialog.dismiss();
|
||||
negativeTv.setOnClickListener(view -> {
|
||||
if (clListener != null) {
|
||||
clListener.onCancel();
|
||||
}
|
||||
dialog.dismiss();
|
||||
});
|
||||
|
||||
positiveTv.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (cmListener != null) {
|
||||
cmListener.onConfirm();
|
||||
}
|
||||
dialog.dismiss();
|
||||
positiveTv.setOnClickListener(view -> {
|
||||
if (cmListener != null) {
|
||||
cmListener.onConfirm();
|
||||
}
|
||||
dialog.dismiss();
|
||||
});
|
||||
|
||||
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
@ -641,12 +718,9 @@ public class DialogUtils {
|
||||
AlertDialog alertDialog = new AlertDialog.Builder(context, R.style.GhAlertDialog)
|
||||
.setTitle("请确定手机号:")
|
||||
.setMessage(phoneNum)
|
||||
.setPositiveButton("确认", new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
if (cmListener != null) {
|
||||
cmListener.onConfirm();
|
||||
}
|
||||
.setPositiveButton("确认", (dialog, which) -> {
|
||||
if (cmListener != null) {
|
||||
cmListener.onConfirm();
|
||||
}
|
||||
})
|
||||
.setNegativeButton("取消", null)
|
||||
@ -673,6 +747,8 @@ public class DialogUtils {
|
||||
|
||||
public static void showSignDialog(Context context, String title, CharSequence message, CharSequence message2
|
||||
, String positive, final ConfirmListener cmListener) {
|
||||
context = checkDialogContext(context);
|
||||
|
||||
final Dialog dialog = new Dialog(context);
|
||||
|
||||
View contentView = LayoutInflater.from(context).inflate(R.layout.dialog_sign, null);
|
||||
@ -701,6 +777,242 @@ public class DialogUtils {
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
public static void showLowVersionDialog(Context context) {
|
||||
final Context activityContext = checkDialogContext(context);
|
||||
|
||||
final Dialog dialog = new Dialog(activityContext, R.style.GhAlertDialog);
|
||||
|
||||
View contentView = LayoutInflater.from(activityContext).inflate(R.layout.dialog_alert, null);
|
||||
TextView contentTv = contentView.findViewById(R.id.dialog_content);
|
||||
TextView titleTv = contentView.findViewById(R.id.dialog_title);
|
||||
TextView negativeTv = contentView.findViewById(R.id.dialog_negative);
|
||||
TextView positiveTv = contentView.findViewById(R.id.dialog_positive);
|
||||
|
||||
contentTv.setText("链接超出范围,请检查升级至最新版本的光环助手");
|
||||
titleTv.setText("提示");
|
||||
negativeTv.setText("关闭");
|
||||
positiveTv.setText("检查升级");
|
||||
|
||||
negativeTv.setOnClickListener(view -> dialog.dismiss());
|
||||
|
||||
positiveTv.setOnClickListener(view -> {
|
||||
activityContext.startActivity(AboutActivity.getIntent(activityContext, true));
|
||||
dialog.dismiss();
|
||||
});
|
||||
|
||||
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
dialog.setContentView(contentView);
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
public static void showListDialog(Context context,
|
||||
List<String> selectionList,
|
||||
DialogInterface.OnClickListener onClickListener) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
||||
|
||||
String[] selectionArray = new String[selectionList.size()];
|
||||
selectionArray = selectionList.toArray(selectionArray);
|
||||
builder.setItems(selectionArray, onClickListener);
|
||||
AlertDialog dialog = builder.create();
|
||||
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param options 供以显示的选项
|
||||
* @param disabledOptions 显示为灰色的选项(是 options 的子集)
|
||||
*/
|
||||
public static void showListDialog(Context context,
|
||||
List<String> options,
|
||||
List<String> disabledOptions,
|
||||
OptionCallback callback) {
|
||||
context = checkDialogContext(context);
|
||||
|
||||
Dialog dialog = new Dialog(context);
|
||||
|
||||
LinearLayout container = new LinearLayout(context);
|
||||
container.setOrientation(LinearLayout.VERTICAL);
|
||||
container.setBackgroundColor(Color.WHITE);
|
||||
container.setPadding(0, DisplayUtils.dip2px(context, 12f), 0, DisplayUtils.dip2px(context, 12f));
|
||||
|
||||
for (String option : options) {
|
||||
TextView reportTv = new TextView(context);
|
||||
reportTv.setText(option);
|
||||
reportTv.setTextSize(17f);
|
||||
if (disabledOptions != null && disabledOptions.contains(option)) {
|
||||
reportTv.setTextColor(ContextCompat.getColor(context, R.color.btn_gray));
|
||||
} else {
|
||||
reportTv.setTextColor(ContextCompat.getColor(context, R.color.title));
|
||||
reportTv.setBackgroundResource(R.drawable.textview_white_style);
|
||||
}
|
||||
int widthPixels = context.getResources().getDisplayMetrics().widthPixels;
|
||||
reportTv.setLayoutParams(new LinearLayout.LayoutParams(widthPixels * 9 / 10,
|
||||
LinearLayout.LayoutParams.WRAP_CONTENT));
|
||||
reportTv.setPadding(DisplayUtils.dip2px(context, 20f), DisplayUtils.dip2px(context, 12f),
|
||||
0, DisplayUtils.dip2px(context, 12f));
|
||||
container.addView(reportTv);
|
||||
|
||||
reportTv.setOnClickListener(v -> {
|
||||
dialog.cancel();
|
||||
callback.onClicked(reportTv.getText().toString());
|
||||
});
|
||||
}
|
||||
|
||||
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
dialog.setContentView(container);
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 特殊:目前只在提交问题错误返回时弹出
|
||||
*/
|
||||
public static Dialog showCommunityDialog(Context context,
|
||||
String title,
|
||||
String contentTitle,
|
||||
String contentDes,
|
||||
String negative,
|
||||
String positive,
|
||||
final CancelListener clListener,
|
||||
final ConfirmListener cmListener) {
|
||||
context = checkDialogContext(context);
|
||||
|
||||
final Dialog dialog = new Dialog(context, R.style.GhAlertDialog);
|
||||
|
||||
View contentView = LayoutInflater.from(context).inflate(R.layout.dialog_community, null);
|
||||
View contentContainer = contentView.findViewById(R.id.content_container);
|
||||
TextView titleTv = contentView.findViewById(R.id.title);
|
||||
TextView contentTitleTv = contentView.findViewById(R.id.content_title);
|
||||
TextView contentDesTv = contentView.findViewById(R.id.content_des);
|
||||
TextView negativeTv = contentView.findViewById(R.id.negative);
|
||||
TextView positiveTv = contentView.findViewById(R.id.positive);
|
||||
|
||||
titleTv.setText(title);
|
||||
contentTitleTv.setText(contentTitle);
|
||||
contentDesTv.setText(contentDes);
|
||||
|
||||
if (TextUtils.isEmpty(negative)) {
|
||||
negativeTv.setVisibility(View.GONE);
|
||||
} else {
|
||||
negativeTv.setVisibility(View.VISIBLE);
|
||||
negativeTv.setText(negative);
|
||||
}
|
||||
|
||||
if (TextUtils.isEmpty(positive)) {
|
||||
positiveTv.setVisibility(View.GONE);
|
||||
} else {
|
||||
positiveTv.setText(positive);
|
||||
positiveTv.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
negativeTv.setOnClickListener(view -> {
|
||||
if (clListener != null) {
|
||||
clListener.onCancel();
|
||||
}
|
||||
dialog.dismiss();
|
||||
});
|
||||
|
||||
positiveTv.setOnClickListener(view -> {
|
||||
if (cmListener != null) {
|
||||
cmListener.onConfirm();
|
||||
}
|
||||
dialog.dismiss();
|
||||
});
|
||||
|
||||
contentContainer.setOnClickListener(v -> {
|
||||
if (cmListener != null) {
|
||||
cmListener.onConfirm();
|
||||
}
|
||||
dialog.dismiss();
|
||||
});
|
||||
|
||||
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
dialog.setContentView(contentView);
|
||||
dialog.show();
|
||||
return dialog;
|
||||
}
|
||||
|
||||
public static void showPrivacyPolicyDialog(Context context, String title, String content, EmptyCallback callback) {
|
||||
final Context activityContext = checkDialogContext(context);
|
||||
|
||||
String privacyPolicyContent;
|
||||
String privacyPolicyTitle = (TextUtils.isEmpty(title)) ? "个人信息保护指引" : title;
|
||||
if (TextUtils.isEmpty(content)) {
|
||||
privacyPolicyContent = "你的个人信息安全对我们来说至关重要。一直以来,光环助手都致力于为每位用户提供更安全的互联网环境" +
|
||||
"。我们将依据《中华人民共和国网络安全法》、《信息安全技术个人信息安全规范》(GB/T 35273-2017)" +
|
||||
"以及其他相关法律法规和技术规范来收集和使用你的个人信息,以帮助我们向你提供更优质的产品和服务。" +
|
||||
"<br/>1.为帮助你浏览内容、互动交流、注册认证等,我们会收集部分必要的信息" +
|
||||
"<br/>2.为提供上述服务,我们可能需要获取 IMEI号码、IMSI号码 等信息的读取权限" +
|
||||
"<br/>3.以上获取个人信息的权限均不会默认开启,只有在运行相关功能或服务时才会明确提示授权,光环助手不会在未经你同意的情况下收集相关信息";
|
||||
} else {
|
||||
privacyPolicyContent = content;
|
||||
}
|
||||
|
||||
final Dialog dialog = new Dialog(activityContext, R.style.GhAlertDialog);
|
||||
|
||||
View contentView = LayoutInflater.from(activityContext).inflate(R.layout.dialog_privacy_policy, null);
|
||||
TextView contentTv = contentView.findViewById(R.id.dialog_content);
|
||||
TextView titleTv = contentView.findViewById(R.id.dialog_title);
|
||||
TextView positiveTv = contentView.findViewById(R.id.dialog_positive);
|
||||
TextView skipTv = contentView.findViewById(R.id.dialog_skip);
|
||||
|
||||
SpannableStringBuilder skipText = new SpannableStringBuilder("查看完整版的 隐私政策");
|
||||
skipText.setSpan(new ClickableSpan() {
|
||||
|
||||
@Override
|
||||
public void updateDrawState(@NonNull TextPaint ds) {
|
||||
super.updateDrawState(ds);
|
||||
ds.setColor(ContextCompat.getColor(activityContext, R.color.theme));
|
||||
ds.setUnderlineText(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(@NonNull View widget) {
|
||||
MtaHelper.onEvent("隐私政策弹窗", "隐私政策弹窗", "点击隐私政策");
|
||||
Intent intent = WebActivity.getPrivacyPolicyIntent(activityContext);
|
||||
activityContext.startActivity(intent);
|
||||
}
|
||||
}, skipText.length() - 4, skipText.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
|
||||
|
||||
skipTv.setText(skipText);
|
||||
skipTv.setMovementMethod(new LinkMovementMethod());
|
||||
contentTv.setText(Html.fromHtml(privacyPolicyContent));
|
||||
titleTv.setText(privacyPolicyTitle);
|
||||
positiveTv.setText("我知道了");
|
||||
|
||||
positiveTv.setOnClickListener(view -> {
|
||||
dialog.dismiss();
|
||||
MtaHelper.onEvent("隐私政策弹窗", "隐私政策弹窗", "点击我知道了");
|
||||
});
|
||||
|
||||
dialog.setOnDismissListener(d -> {
|
||||
callback.onCallback();
|
||||
});
|
||||
|
||||
MtaHelper.onEvent("隐私政策弹窗", "隐私政策弹窗", "出现弹窗");
|
||||
|
||||
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
dialog.setContentView(contentView);
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param context may be is application context
|
||||
* @return activity context
|
||||
*/
|
||||
public static Context checkDialogContext(Context context) {
|
||||
if (context == null) {
|
||||
throw new NullPointerException("dialog context is null");
|
||||
}
|
||||
|
||||
if (context instanceof Activity) {
|
||||
return context;
|
||||
}
|
||||
|
||||
return AppManager.getInstance().currentActivity();
|
||||
}
|
||||
|
||||
public interface ConfirmListener {
|
||||
void onConfirm();
|
||||
}
|
||||
@ -709,4 +1021,12 @@ public class DialogUtils {
|
||||
void onCancel();
|
||||
}
|
||||
|
||||
public interface OptionCallback {
|
||||
void onClicked(String text);
|
||||
}
|
||||
|
||||
public interface CheckDownloadCallBack {
|
||||
void onResponse(boolean isSubscribe);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -5,20 +5,27 @@ import android.content.Intent
|
||||
import android.net.Uri
|
||||
import android.os.Bundle
|
||||
import android.text.TextUtils
|
||||
import com.gh.base.BaseActivity
|
||||
import com.gh.base.fragment.BaseFragment_TabLayout
|
||||
import com.gh.common.AppExecutor
|
||||
import com.gh.common.util.EntranceUtils.*
|
||||
import com.gh.gamecenter.*
|
||||
import com.gh.gamecenter.category.CategoryDirectoryActivity
|
||||
import com.gh.gamecenter.download.DownloadFragment.Companion.INDEX_UPDATE
|
||||
import com.gh.gamecenter.entity.CommunityEntity
|
||||
import com.gh.gamecenter.entity.SubjectData
|
||||
import com.gh.gamecenter.entity.*
|
||||
import com.gh.gamecenter.eventbus.EBReuse
|
||||
import com.gh.gamecenter.eventbus.EBSkip
|
||||
import com.gh.gamecenter.manager.UserManager
|
||||
import com.gh.gamecenter.qa.AskFragment
|
||||
import com.gh.gamecenter.qa.answer.detail.AnswerDetailActivity
|
||||
import com.gh.gamecenter.qa.article.SimpleArticleListActivity
|
||||
import com.gh.gamecenter.qa.article.detail.ArticleDetailActivity
|
||||
import com.gh.gamecenter.qa.column.detail.AskColumnDetailActivity
|
||||
import com.gh.gamecenter.qa.questions.detail.QuestionsDetailActivity
|
||||
import com.gh.gamecenter.subject.refactor.SubjectActivity
|
||||
import com.gh.gamecenter.qa.subject.CommunitySubjectActivity
|
||||
import com.gh.gamecenter.subject.SubjectActivity
|
||||
import com.gh.gamecenter.suggest.SuggestType
|
||||
import com.gh.gamecenter.tag.TagsActivity
|
||||
import com.lightgame.utils.Util_System_ClipboardManager
|
||||
import com.lightgame.utils.Utils
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
@ -59,7 +66,68 @@ object DirectUtils {
|
||||
}
|
||||
|
||||
/**
|
||||
* 跳转到文章详情
|
||||
* 跳转到特定页面,只支持App内部跳转
|
||||
*/
|
||||
@JvmStatic
|
||||
fun directToLinkPage(context: Context, linkEntity: LinkEntity, entrance: String, path: String) {
|
||||
when (linkEntity.type) {
|
||||
"article", "news" -> {
|
||||
NewsUtils.statNewsViews(context, linkEntity.link) // 统计阅读量
|
||||
context.startActivity(NewsDetailActivity.getIntentById(context, linkEntity.link, BaseActivity.mergeEntranceAndPath(entrance, path)))
|
||||
}
|
||||
|
||||
"game" -> GameDetailActivity.startGameDetailActivity(context, linkEntity.link, BaseActivity.mergeEntranceAndPath(entrance, path))
|
||||
|
||||
"column" -> SubjectActivity.startSubjectActivity(context, linkEntity.link, linkEntity.text, false, BaseActivity.mergeEntranceAndPath(entrance, path))
|
||||
|
||||
"question" -> context.startActivity(QuestionsDetailActivity.getIntent(context, linkEntity.link, entrance, path))
|
||||
|
||||
"answer" -> context.startActivity(AnswerDetailActivity.getIntent(context, linkEntity.link, entrance, path))
|
||||
|
||||
"community" -> directToCommunity(context, CommunityEntity(linkEntity.link!!, linkEntity.text!!))
|
||||
|
||||
"community_article" -> context.startActivity(ArticleDetailActivity.getIntent(context, linkEntity.community!!, linkEntity.link!!, entrance, path))
|
||||
|
||||
"community_column" -> directToCommunityColumn(context, linkEntity.community, linkEntity.link!!, entrance, path)
|
||||
|
||||
"community_special_column" -> context.startActivity(AskColumnDetailActivity.getIntentByColumnId(context, linkEntity.link, linkEntity.community!!, entrance, path))
|
||||
|
||||
"web", "inurl" -> directToWebView(context, url = linkEntity.link!!, entrance = BaseActivity.mergeEntranceAndPath(entrance, path))
|
||||
|
||||
"qq" -> directToQqConversation(context, linkEntity.link)
|
||||
|
||||
"outurl" -> directToExternalBrowser(context, linkEntity.link!!)
|
||||
|
||||
"qqqun" -> directToQqGroup(context, linkEntity.link!!)
|
||||
|
||||
"tag" -> context.startActivity(TagsActivity.getIntent(context, linkEntity.text!!, entrance, path))
|
||||
|
||||
"all_community_article" -> {
|
||||
context.startActivity(SimpleArticleListActivity.getIntent(
|
||||
context,
|
||||
linkEntity.link ?: "",
|
||||
entrance,
|
||||
path))
|
||||
}
|
||||
|
||||
"category" -> {
|
||||
context.startActivity(CategoryDirectoryActivity.getIntent(context, linkEntity.link!!, linkEntity.text!!))
|
||||
}
|
||||
|
||||
"block" -> {
|
||||
context.startActivity(BlockActivity.getIntent(context, SubjectRecommendEntity(
|
||||
link = linkEntity.link,
|
||||
text = linkEntity.text,
|
||||
name = linkEntity.name,
|
||||
display = linkEntity.display ?: Display())))
|
||||
}
|
||||
|
||||
else -> DialogUtils.showLowVersionDialog(context)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 跳转到新闻详情
|
||||
*/
|
||||
@JvmStatic
|
||||
fun directToArticle(context: Context, id: String, entrance: String? = null) {
|
||||
@ -87,9 +155,10 @@ object DirectUtils {
|
||||
@JvmStatic
|
||||
fun directToSubject(context: Context, id: String, subjectName: String? = "", entrance: String? = null) {
|
||||
val bundle = Bundle()
|
||||
val subjectData = SubjectData(subjectId = id, subjectName = subjectName, isOrder = false)
|
||||
bundle.putString(KEY_ENTRANCE, entrance ?: ENTRANCE_BROWSER)
|
||||
bundle.putString(KEY_TO, SubjectActivity::class.java.name)
|
||||
bundle.putParcelable(EntranceUtils.KEY_SUBJECT_DATA, SubjectData(id, subjectName, false, null, null, null, null))
|
||||
bundle.putParcelable(EntranceUtils.KEY_SUBJECT_DATA, subjectData)
|
||||
EntranceUtils.jumpActivity(context, bundle)
|
||||
}
|
||||
|
||||
@ -137,7 +206,6 @@ object DirectUtils {
|
||||
bundle.putString(KEY_GAMEID, gameId)
|
||||
bundle.putString(KEY_PACKAGENAME, packageName)
|
||||
bundle.putInt(BaseFragment_TabLayout.PAGE_INDEX, INDEX_UPDATE)
|
||||
bundle.putBoolean(KEY_AUTO_UPDATE, true)
|
||||
EntranceUtils.jumpActivity(context, bundle)
|
||||
}
|
||||
|
||||
@ -165,7 +233,7 @@ object DirectUtils {
|
||||
fun directToWebView(context: Context, url: String, entrance: String? = null) {
|
||||
val bundle = Bundle()
|
||||
bundle.putString(KEY_ENTRANCE, entrance ?: ENTRANCE_BROWSER)
|
||||
bundle.putString(EntranceUtils.KEY_TO, WebActivity::class.java.simpleName)
|
||||
bundle.putString(KEY_TO, WebActivity::class.java.simpleName)
|
||||
bundle.putString(EntranceUtils.KEY_URL, url)
|
||||
EntranceUtils.jumpActivity(context, bundle)
|
||||
}
|
||||
@ -174,11 +242,17 @@ object DirectUtils {
|
||||
@JvmStatic
|
||||
fun directToOfficialNotification(context: Context, entrance: String? = null) {
|
||||
val bundle = Bundle()
|
||||
bundle.putString(EntranceUtils.KEY_ENTRANCE, entrance ?: ENTRANCE_BROWSER)
|
||||
bundle.putString(EntranceUtils.KEY_TO, MessageKeFuActivity::class.java.simpleName)
|
||||
bundle.putString(KEY_ENTRANCE, entrance ?: ENTRANCE_BROWSER)
|
||||
bundle.putString(KEY_TO, MessageKeFuActivity::class.java.simpleName)
|
||||
EntranceUtils.jumpActivity(context, bundle)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun directToExternalBrowser(context: Context, url: String) {
|
||||
val browserIntent = Intent(Intent.ACTION_VIEW, Uri.parse(url))
|
||||
context.startActivity(browserIntent)
|
||||
}
|
||||
|
||||
// 跳转 QQ
|
||||
@JvmStatic
|
||||
fun directToQqConversation(context: Context, qqNumber: String? = null) {
|
||||
@ -226,7 +300,7 @@ object DirectUtils {
|
||||
fun directToGiftDetail(context: Context, giftId: String, entrance: String? = null) {
|
||||
val bundle = Bundle()
|
||||
bundle.putString(KEY_ENTRANCE, entrance ?: ENTRANCE_BROWSER)
|
||||
bundle.putString(EntranceUtils.KEY_TO, LibaoDetailActivity::class.java.simpleName)
|
||||
bundle.putString(KEY_TO, LibaoDetailActivity::class.java.simpleName)
|
||||
bundle.putString(EntranceUtils.KEY_ID, giftId)
|
||||
EntranceUtils.jumpActivity(context, bundle)
|
||||
}
|
||||
@ -242,7 +316,36 @@ object DirectUtils {
|
||||
context.startActivity(intent)
|
||||
}
|
||||
UserManager.getInstance().setCommunityData(community)
|
||||
EventBus.getDefault().post(EBSkip(MainActivity.EB_SKIP_GAMEFRAGMENT, 1))
|
||||
EventBus.getDefault().post(EBReuse(AskFragment.EB_RETRY_PAGE))
|
||||
|
||||
// 这里换个线程操作是为了做一点延时
|
||||
AppExecutor.ioExecutor.execute {
|
||||
EventBus.getDefault().post(EBSkip(MainActivity.EB_SKIP_GAMEFRAGMENT, 1))
|
||||
EventBus.getDefault().post(EBReuse(AskFragment.EB_RETRY_PAGE))
|
||||
}
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun directToCommunityArticle(context: Context, articleId: String?, communityId: String?, entrance: String?, path: String?) {
|
||||
val bundle = Bundle()
|
||||
bundle.putString(KEY_ENTRANCE, entrance ?: ENTRANCE_BROWSER)
|
||||
bundle.putString(KEY_PATH, path)
|
||||
bundle.putString(KEY_TO, ArticleDetailActivity::class.java.name)
|
||||
bundle.putString(KEY_COMMUNITY_ARTICLE_ID, articleId)
|
||||
bundle.putParcelable(KEY_COMMUNITY_DATA, CommunityEntity(id = communityId!!))
|
||||
jumpActivity(context, bundle)
|
||||
}
|
||||
|
||||
/**
|
||||
* 跳转到社区专题
|
||||
*/
|
||||
@JvmStatic
|
||||
fun directToCommunityColumn(context: Context, community: CommunityEntity?, subjectId: String, entrance: String?, path: String?) {
|
||||
val bundle = Bundle()
|
||||
bundle.putString(KEY_PATH, path)
|
||||
bundle.putString(KEY_TO, CommunitySubjectActivity::class.java.name)
|
||||
bundle.putString(KEY_ENTRANCE, BaseActivity.mergeEntranceAndPath(entrance, path))
|
||||
bundle.putString(KEY_COLUMN_ID, subjectId)
|
||||
bundle.putParcelable(KEY_COMMUNITY_DATA, community)
|
||||
jumpActivity(context, bundle)
|
||||
}
|
||||
}
|
||||
101
app/src/main/java/com/gh/common/util/DownloadDialogHelper.kt
Normal file
101
app/src/main/java/com/gh/common/util/DownloadDialogHelper.kt
Normal file
@ -0,0 +1,101 @@
|
||||
package com.gh.common.util
|
||||
|
||||
import android.content.Context
|
||||
import android.os.Build
|
||||
import com.gh.gamecenter.entity.ApkEntity
|
||||
import com.gh.gamecenter.entity.GameEntity
|
||||
|
||||
object DownloadDialogHelper {
|
||||
|
||||
/**
|
||||
* [callback] 执行点击关闭以后会执行的代码块,没有弹窗也会执行这个代码块
|
||||
*/
|
||||
@JvmStatic
|
||||
fun findAvailableDialogAndShow(context: Context, gameEntity: GameEntity, apkEntity: ApkEntity, callback: EmptyCallback) {
|
||||
val dialog = retrieveAvailableDialog(gameEntity, apkEntity)
|
||||
if (dialog != null) {
|
||||
showDownloadDialog(context, dialog, callback)
|
||||
} else {
|
||||
callback.onCallback()
|
||||
}
|
||||
}
|
||||
|
||||
private fun retrieveAvailableDialog(gameEntity: GameEntity, apkEntity: ApkEntity): GameEntity.Dialog? {
|
||||
if (gameEntity.downloadDialog.isNullOrEmpty()) return null
|
||||
|
||||
for (dialog in gameEntity.downloadDialog!!) {
|
||||
|
||||
// 共有 8 种可能
|
||||
// 1. 不指定包名、机型和系统版本
|
||||
if (dialog.rule.packageName.isEmpty()
|
||||
&& dialog.rule.models.isEmpty()
|
||||
&& dialog.rule.systemVersions.isEmpty()) {
|
||||
return dialog
|
||||
}
|
||||
|
||||
// 2. 指定包名不管机型和系统
|
||||
if (dialog.rule.packageName == apkEntity.packageName
|
||||
&& dialog.rule.models.isEmpty()
|
||||
&& dialog.rule.systemVersions.isEmpty()) {
|
||||
return dialog
|
||||
}
|
||||
|
||||
// 3. 指定机型不管包名和系统
|
||||
if (dialog.rule.models.contains(Build.MODEL)
|
||||
&& dialog.rule.packageName.isEmpty()
|
||||
&& dialog.rule.systemVersions.isEmpty()) {
|
||||
return dialog
|
||||
}
|
||||
|
||||
// 4. 指定系统不管包名和机型
|
||||
if (dialog.rule.systemVersions.contains(Build.VERSION.RELEASE)
|
||||
&& dialog.rule.packageName.isEmpty()
|
||||
&& dialog.rule.models.isEmpty()) {
|
||||
return dialog
|
||||
}
|
||||
|
||||
// 5. 指定包名和机型不管系统
|
||||
if (dialog.rule.packageName == apkEntity.packageName
|
||||
&& dialog.rule.models.contains(Build.MODEL)
|
||||
&& dialog.rule.systemVersions.isEmpty()) {
|
||||
return dialog
|
||||
}
|
||||
|
||||
// 6. 指定包名和系统不管机型
|
||||
if (dialog.rule.packageName == apkEntity.packageName
|
||||
&& dialog.rule.systemVersions.contains(Build.VERSION.RELEASE)
|
||||
&& dialog.rule.models.isEmpty()) {
|
||||
return dialog
|
||||
}
|
||||
|
||||
// 7. 指定机型和系统不管包名
|
||||
if (dialog.rule.systemVersions.contains(Build.VERSION.RELEASE)
|
||||
&& dialog.rule.models.contains(Build.MODEL)
|
||||
&& dialog.rule.packageName.isEmpty()) {
|
||||
return dialog
|
||||
}
|
||||
|
||||
// 8.指定包名、机型和系统版本
|
||||
if (dialog.rule.packageName == apkEntity.packageName
|
||||
&& dialog.rule.models.contains(Build.MODEL)
|
||||
&& dialog.rule.systemVersions.contains(Build.VERSION.RELEASE)) {
|
||||
return dialog
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
private fun showDownloadDialog(context: Context, dialog: GameEntity.Dialog, callback: EmptyCallback) {
|
||||
DialogUtils.showDialogWithHtmlContent(
|
||||
context,
|
||||
dialog.title,
|
||||
dialog.content,
|
||||
"继续下载",
|
||||
"取消",
|
||||
{ callback.onCallback() },
|
||||
null)
|
||||
}
|
||||
|
||||
}
|
||||
@ -21,6 +21,7 @@ object DownloadHelper {
|
||||
RetrofitManager.getInstance(HaloApp.getInstance().application)
|
||||
.api
|
||||
.getGameDigest(gameId)
|
||||
.map(ApkActiveUtils.filterMapper)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.subscribe(object : Response<GameEntity>() {
|
||||
override fun onResponse(response: GameEntity?) {
|
||||
@ -29,13 +30,13 @@ object DownloadHelper {
|
||||
for (apk in response.getApk()) {
|
||||
if (packageName == apk.packageName) {
|
||||
DownloadManager.createDownload(HaloApp.getInstance().application,
|
||||
apk, response, "", EntranceUtils.ENTRANCE_RECOMMEND, "", null)
|
||||
apk, response, "", EntranceUtils.ENTRANCE_RECOMMEND, "", false, null)
|
||||
block.invoke()
|
||||
}
|
||||
}
|
||||
} else if (response.getApk().size == 1) {
|
||||
DownloadManager.createDownload(HaloApp.getInstance().application,
|
||||
response, "", EntranceUtils.ENTRANCE_RECOMMEND, "", null)
|
||||
response, "", EntranceUtils.ENTRANCE_RECOMMEND, "", false, null)
|
||||
block.invoke()
|
||||
}
|
||||
}
|
||||
|
||||
@ -3,17 +3,21 @@ package com.gh.common.util;
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.os.Message;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v4.util.ArrayMap;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.collection.ArrayMap;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.gh.common.constant.Config;
|
||||
import com.gh.common.dialog.ReserveDialogFragment;
|
||||
import com.gh.common.exposure.ExposureEvent;
|
||||
import com.gh.common.exposure.ExposureUtils;
|
||||
import com.gh.common.repository.ReservationRepository;
|
||||
import com.gh.common.view.DownloadDialog;
|
||||
import com.gh.download.DownloadManager;
|
||||
import com.gh.gamecenter.DownloadManagerActivity;
|
||||
@ -21,7 +25,8 @@ import com.gh.gamecenter.R;
|
||||
import com.gh.gamecenter.adapter.viewholder.GameViewHolder;
|
||||
import com.gh.gamecenter.entity.ApkEntity;
|
||||
import com.gh.gamecenter.entity.GameEntity;
|
||||
import com.gh.gamecenter.manager.PackageManager;
|
||||
import com.gh.gamecenter.entity.PluginLocation;
|
||||
import com.gh.gamecenter.manager.PackagesManager;
|
||||
import com.lightgame.download.DownloadConfig;
|
||||
import com.lightgame.download.DownloadEntity;
|
||||
import com.lightgame.download.DownloadStatus;
|
||||
@ -68,7 +73,7 @@ public class DownloadItemUtils {
|
||||
// adapter.notifyItemChanged(index);
|
||||
// }
|
||||
} else {
|
||||
if (!queue.contains(platform)) {
|
||||
if (!queue.contains(platform) && !TextUtils.isEmpty(platform)) {
|
||||
queue.offer(platform);
|
||||
if (AppDebugConfig.IS_DEBUG) {
|
||||
AppDebugConfig.logMethodWithParams(DownloadItemUtils.class, queue.size(), gameEntity.getBrief(), downloadEntity.getPlatform(), index);
|
||||
@ -82,7 +87,7 @@ public class DownloadItemUtils {
|
||||
DownloadManager.getInstance(context).sendMessageDelayed(msg, 3000);
|
||||
}
|
||||
}
|
||||
if (platform.equals(queue.peek())) {
|
||||
if (platform != null && platform.equals(queue.peek())) {
|
||||
if (entryMap == null) {
|
||||
entryMap = new ArrayMap<>();
|
||||
gameEntity.setEntryMap(entryMap);
|
||||
@ -95,7 +100,42 @@ public class DownloadItemUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public static void updateItem(Context context, GameEntity gameEntity, GameViewHolder holder, boolean isShowPlatform) {
|
||||
// 下载按钮显示为查看,并且不提供下载功能
|
||||
public static void updateItemWithViewOnlyStyle(GameViewHolder holder) {
|
||||
holder.gameDownloadBtn.setVisibility(View.VISIBLE);
|
||||
holder.gameDownloadBtn.setText("查看");
|
||||
holder.gameDownloadBtn.setClickable(false);
|
||||
}
|
||||
|
||||
// 根据预约状态更新下载按钮
|
||||
public static void updateItemWithReserveStatus(GameViewHolder holder, GameEntity gameEntity) {
|
||||
if ("download".equals(gameEntity.getReserveStatus())) {
|
||||
// 已上线
|
||||
holder.gameDownloadBtn.setVisibility(View.VISIBLE);
|
||||
holder.gameDownloadBtn.setText("已上线");
|
||||
holder.gameDownloadBtn.setTextColor(Color.WHITE);
|
||||
holder.gameDownloadBtn.setBackground(ContextCompat.getDrawable(holder.gameDes.getContext(), R.drawable.game_item_btn_pause_dn));
|
||||
} else if ("appointment".equals(gameEntity.getReserveStatus())) {
|
||||
// 已预约
|
||||
holder.gameDownloadBtn.setVisibility(View.VISIBLE);
|
||||
holder.gameDownloadBtn.setText("已预约");
|
||||
holder.gameDownloadBtn.setTextColor(Color.WHITE);
|
||||
holder.gameDownloadBtn.setBackgroundResource(R.drawable.game_item_btn_pause_dn);
|
||||
}
|
||||
if (gameEntity.isLibaoExists()) {
|
||||
holder.gameLibaoIcon.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
holder.gameLibaoIcon.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
public static void updateItem(Context context, GameEntity gameEntity, GameViewHolder holder,
|
||||
boolean isShowPlatform) {
|
||||
updateItem(context, gameEntity, holder, isShowPlatform, PluginLocation.only_game);
|
||||
}
|
||||
|
||||
public static void updateItem(Context context, GameEntity gameEntity, GameViewHolder holder,
|
||||
boolean isShowPlatform, PluginLocation pluginLocation) {
|
||||
|
||||
// 控制是否显示下载按钮
|
||||
if (!Config.isShowDownload(gameEntity.getId()) || context.getString(R.string.app_name).equals(gameEntity.getName())) {
|
||||
@ -110,6 +150,23 @@ public class DownloadItemUtils {
|
||||
holder.gameLibaoIcon.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
// 显示预约
|
||||
if (gameEntity.isReservable()) {
|
||||
holder.gameDes.setVisibility(View.VISIBLE);
|
||||
holder.gameProgressbar.setVisibility(View.GONE);
|
||||
holder.gameInfo.setVisibility(View.GONE);
|
||||
if (!ReservationRepository.thisGameHasBeenReserved(gameEntity.getId())) {
|
||||
holder.gameDownloadBtn.setText("预约");
|
||||
holder.gameDownloadBtn.setTextColor(Color.WHITE);
|
||||
holder.gameDownloadBtn.setBackgroundResource(R.drawable.button_reserve);
|
||||
} else {
|
||||
holder.gameDownloadBtn.setText("已预约");
|
||||
holder.gameDownloadBtn.setTextColor(Color.WHITE);
|
||||
holder.gameDownloadBtn.setBackgroundResource(R.drawable.game_item_btn_pause_dn);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (gameEntity.getApk() == null || gameEntity.getApk().isEmpty()) {
|
||||
holder.gameDes.setVisibility(View.VISIBLE);
|
||||
holder.gameProgressbar.setVisibility(View.GONE);
|
||||
@ -119,17 +176,16 @@ public class DownloadItemUtils {
|
||||
holder.gameDownloadBtn.setTextColor(ContextCompat.getColor(context, R.color.button_gray));
|
||||
holder.gameDownloadBtn.setClickable(false);
|
||||
} else if (gameEntity.getApk().size() == 1) {
|
||||
updateNormalItem(context, holder, gameEntity, isShowPlatform);
|
||||
updateNormalItem(context, holder, gameEntity, isShowPlatform, pluginLocation);
|
||||
} else {
|
||||
// updateNormalItem(context, holder, gameEntity, isShowPlatform);
|
||||
updatePluginItem(context, holder, gameEntity, isShowPlatform);
|
||||
updatePluginItem(context, holder, gameEntity, isShowPlatform, pluginLocation);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 更新正常的条目,只有一个apk包
|
||||
static void updateNormalItem(Context context, GameViewHolder holder, GameEntity gameEntity,
|
||||
boolean isShowPlatform) {
|
||||
boolean isShowPlatform, PluginLocation pluginLocation) {
|
||||
|
||||
final ArrayMap<String, DownloadEntity> entryMap = gameEntity.getEntryMap();
|
||||
final ApkEntity apkEntity = gameEntity.getApk().get(0);
|
||||
@ -143,74 +199,22 @@ public class DownloadItemUtils {
|
||||
}
|
||||
}
|
||||
|
||||
GameUtils.setDownloadBtnStatus(context, gameEntity, holder.gameDownloadBtn, pluginLocation);
|
||||
|
||||
holder.gameDes.setVisibility(View.VISIBLE);
|
||||
holder.gameProgressbar.setVisibility(View.GONE);
|
||||
holder.gameInfo.setVisibility(View.GONE);
|
||||
|
||||
holder.gameDownloadBtn.setTextColor(Color.WHITE);
|
||||
|
||||
final String packageName = apkEntity.getPackageName();
|
||||
|
||||
if (gameEntity.isPluggable()) {
|
||||
holder.gameDownloadBtn.setText(R.string.pluggable);
|
||||
setwhat(context, holder, apkEntity, packageName);
|
||||
} else if (PackageManager.INSTANCE.isInstalled(packageName)) {
|
||||
if (PackageManager.INSTANCE.isCanUpdate(gameEntity.getId(), packageName)) {
|
||||
holder.gameDownloadBtn.setText(R.string.update);
|
||||
holder.gameDownloadBtn.setBackgroundResource(R.drawable.game_item_btn_download_style);
|
||||
} else {
|
||||
Object gh_id = PackageUtils.getMetaData(context, packageName, "gh_id");
|
||||
if (gameEntity.getTag() != null && gameEntity.getTag().size() != 0
|
||||
&& !TextUtils.isEmpty(apkEntity.getGhVersion())
|
||||
&& !PackageUtils.isSignature(context, packageName)) {
|
||||
holder.gameDownloadBtn.setText(R.string.pluggable);
|
||||
setwhat(context, holder, apkEntity, packageName);
|
||||
} else if (gh_id == null || gh_id.equals(gameEntity.getId())) {
|
||||
holder.gameDownloadBtn.setText(R.string.launch);
|
||||
holder.gameDownloadBtn.setTextColor(ContextCompat.getColor(context, R.color.theme));
|
||||
holder.gameDownloadBtn.setBackgroundResource(R.drawable.detail_download_open_style);
|
||||
} else {
|
||||
holder.gameDownloadBtn.setText(R.string.download);
|
||||
holder.gameDownloadBtn.setBackgroundResource(R.drawable.game_item_btn_download_style);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
holder.gameDownloadBtn.setText(R.string.download);
|
||||
holder.gameDownloadBtn.setBackgroundResource(R.drawable.game_item_btn_download_style);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 这个干什么鬼?
|
||||
*
|
||||
* @param context
|
||||
* @param holder
|
||||
* @param apkEntity
|
||||
* @param packageName
|
||||
*/
|
||||
public static void setwhat(Context context, GameViewHolder holder, ApkEntity apkEntity, String packageName) {
|
||||
DownloadEntity downloadEntity = DownloadManager.getInstance(context).getDownloadEntityByPackageName(packageName);
|
||||
if (downloadEntity == null || downloadEntity.getUrl().equals(apkEntity.getUrl())) {
|
||||
holder.gameDownloadBtn.setClickable(true);
|
||||
holder.gameDownloadBtn.setBackgroundResource(R.drawable.game_item_btn_plugin_style);
|
||||
} else {
|
||||
holder.gameDownloadBtn.setClickable(false);
|
||||
holder.gameDownloadBtn.setBackgroundResource(R.drawable.game_item_btn_pause_up);
|
||||
}
|
||||
}
|
||||
|
||||
// 更新插件的条目,有多个apk包
|
||||
static void updatePluginItem(Context context, GameViewHolder holder, GameEntity gameEntity,
|
||||
boolean isShowPlatform) {
|
||||
|
||||
GameUtils.setDownloadBtnStatus(context, gameEntity, holder.gameDownloadBtn);
|
||||
private static void updatePluginItem(Context context, GameViewHolder holder, GameEntity gameEntity,
|
||||
boolean isShowPlatform, PluginLocation pluginLocation) {
|
||||
GameUtils.setDownloadBtnStatus(context, gameEntity, holder.gameDownloadBtn, pluginLocation);
|
||||
|
||||
ArrayMap<String, DownloadEntity> entryMap = gameEntity.getEntryMap();
|
||||
if (entryMap != null && !entryMap.isEmpty()) {
|
||||
|
||||
DownloadEntity downloadEntity;
|
||||
|
||||
LinkedBlockingQueue<String> queue = DownloadManager.getInstance(context).getQueue(gameEntity.getName());
|
||||
DownloadEntity downloadEntity;
|
||||
if (queue != null && !queue.isEmpty()) {
|
||||
downloadEntity = entryMap.get(queue.peek());
|
||||
} else {
|
||||
@ -274,7 +278,9 @@ public class DownloadItemUtils {
|
||||
}
|
||||
} else if (status.equals(DownloadStatus.pause)
|
||||
|| status.equals(DownloadStatus.timeout)
|
||||
|| status.equals(DownloadStatus.neterror)) {
|
||||
|| status.equals(DownloadStatus.neterror)
|
||||
|| status.equals(DownloadStatus.subscribe)
|
||||
|| status.equals(DownloadStatus.overflow)) {
|
||||
holder.gameProgressbar.setProgress((int) (downloadEntity.getPercent() * 10));
|
||||
if (isShowPlatform && platform != null) {
|
||||
holder.gameDownloadSpeed.setText(String.format("%s - 暂停", platform));
|
||||
@ -284,7 +290,11 @@ public class DownloadItemUtils {
|
||||
holder.gameDownloadPercentage.setText(downloadEntity.getPercent() + "%");
|
||||
|
||||
if (isNormal) {
|
||||
holder.gameDownloadBtn.setText(R.string.downloading);
|
||||
if (status.equals(DownloadStatus.waiting)) {
|
||||
holder.gameDownloadBtn.setText(R.string.waiting);
|
||||
} else {
|
||||
holder.gameDownloadBtn.setText(R.string.downloading);
|
||||
}
|
||||
holder.gameDownloadBtn.setBackgroundResource(R.drawable.game_item_btn_downloading_style);
|
||||
holder.gameDownloadBtn.setTextColor(ContextCompat.getColorStateList(context, R.color.text_downloading_style));
|
||||
}
|
||||
@ -298,10 +308,10 @@ public class DownloadItemUtils {
|
||||
holder.gameDownloadPercentage.setText(R.string.hundred_percent);
|
||||
|
||||
if (isNormal) {
|
||||
holder.gameDownloadBtn.setText("安装");
|
||||
holder.gameDownloadBtn.setText(R.string.install);
|
||||
holder.gameDownloadBtn.setTextColor(Color.WHITE);
|
||||
if (downloadEntity.isPluggable()
|
||||
&& PackageManager.INSTANCE.isInstalled(downloadEntity.getPackageName())) {
|
||||
&& PackagesManager.INSTANCE.isInstalled(downloadEntity.getPackageName())) {
|
||||
holder.gameDownloadBtn.setBackgroundResource(R.drawable.game_item_btn_plugin_style);
|
||||
} else {
|
||||
holder.gameDownloadBtn.setBackgroundResource(R.drawable.game_item_btn_download_style);
|
||||
@ -330,10 +340,83 @@ public class DownloadItemUtils {
|
||||
final String location,
|
||||
final ExposureEvent traceEvent) {
|
||||
|
||||
setOnClickListener(context, downloadBtn, gameEntity, position, adapter, entrance, location, traceEvent, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param clickCallback 供那些需要知道点击回调的地方使用
|
||||
*/
|
||||
public static void setOnClickListener(final Context context,
|
||||
final TextView downloadBtn,
|
||||
final GameEntity gameEntity,
|
||||
final int position,
|
||||
final RecyclerView.Adapter<? extends RecyclerView.ViewHolder> adapter,
|
||||
final String entrance,
|
||||
final String location,
|
||||
final ExposureEvent traceEvent,
|
||||
@Nullable final EmptyCallback clickCallback) {
|
||||
|
||||
if (gameEntity.isReservable()) {
|
||||
if (!ReservationRepository.thisGameHasBeenReserved(gameEntity.getId())) {
|
||||
downloadBtn.setOnClickListener(v -> {
|
||||
CheckLoginUtils.checkLogin(context, entrance, () -> {
|
||||
PermissionHelper.checkReadPhoneStatePermissionBeforeAction(context, () -> {
|
||||
ReserveDialogFragment dialogFragment = ReserveDialogFragment.getInstance(
|
||||
gameEntity,
|
||||
() -> adapter.notifyItemChanged(position)
|
||||
);
|
||||
dialogFragment.show(((AppCompatActivity) context).getSupportFragmentManager(), "reserve");
|
||||
});
|
||||
if (clickCallback != null) {
|
||||
clickCallback.onCallback();
|
||||
}
|
||||
});
|
||||
});
|
||||
} else {
|
||||
downloadBtn.setOnClickListener(v -> {
|
||||
if ("download".equals(gameEntity.getReserveStatus())) {
|
||||
ReservationHelper.showDeleteReservationDialog(context, () -> {
|
||||
ReservationHelper.deleteReservation(gameEntity, () -> {
|
||||
adapter.notifyItemChanged(position);
|
||||
});
|
||||
});
|
||||
} else {
|
||||
ReservationHelper.showCancelReservationDialog(context, () -> {
|
||||
ReservationHelper.cancelReservation(gameEntity, () -> {
|
||||
adapter.notifyItemChanged(position);
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (gameEntity.getApk().size() == 1) {
|
||||
downloadBtn.setOnClickListener(v -> onNormalClick(context, downloadBtn, gameEntity, position, adapter, entrance, location, traceEvent));
|
||||
downloadBtn.setOnClickListener(v -> {
|
||||
EmptyCallback clickRunnable = () -> {
|
||||
onNormalClick(context, downloadBtn, gameEntity, position, adapter, entrance, location, traceEvent);
|
||||
if (clickCallback != null) {
|
||||
clickCallback.onCallback();
|
||||
}
|
||||
};
|
||||
|
||||
// 启动不需要请求存储权限
|
||||
if (downloadBtn.getText().toString().equals(context.getString(R.string.launch))) {
|
||||
clickRunnable.onCallback();
|
||||
} else {
|
||||
PermissionHelper.checkStoragePermissionBeforeAction(context, clickRunnable);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
downloadBtn.setOnClickListener(v -> DownloadDialog.getInstance(context).showPopupWindow(v, gameEntity, entrance, location, traceEvent));
|
||||
downloadBtn.setOnClickListener(v -> {
|
||||
PermissionHelper.checkStoragePermissionBeforeAction(context, () -> {
|
||||
DownloadDialog.getInstance(context).showPopupWindow(v, gameEntity, entrance, location, traceEvent);
|
||||
if (clickCallback != null) {
|
||||
clickCallback.onCallback();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@ -356,51 +439,45 @@ public class DownloadItemUtils {
|
||||
final String entrance,
|
||||
final String location,
|
||||
@Nullable final ExposureEvent traceEvent) {
|
||||
|
||||
String str = downloadBtn.getText().toString();
|
||||
switch (str) {
|
||||
case "下载":
|
||||
if (NetworkUtils.isWifiConnected(context)) {
|
||||
download(context, gameEntity, downloadBtn, entrance, location, traceEvent);
|
||||
} else {
|
||||
DialogUtils.showDownloadDialog(context, () -> download(context, gameEntity, downloadBtn, entrance, location, traceEvent));
|
||||
}
|
||||
break;
|
||||
case "插件化":
|
||||
if (entrance.contains("我的游戏")) {
|
||||
DataUtils.onMtaEvent(context, "我的游戏_启动", "插件化", gameEntity.getName());
|
||||
}
|
||||
if (NetworkUtils.isWifiConnected(context)) {
|
||||
plugin(context, gameEntity, downloadBtn, entrance, location, traceEvent);
|
||||
} else {
|
||||
DialogUtils.showDownloadDialog(context, () -> plugin(context, gameEntity, downloadBtn, entrance, location, traceEvent));
|
||||
}
|
||||
break;
|
||||
case "安装":
|
||||
install(context, gameEntity, position, adapter);
|
||||
break;
|
||||
case "启动":
|
||||
if (entrance.contains("我的游戏")) {
|
||||
DataUtils.onMtaEvent(context, "我的游戏_启动", "启动", gameEntity.getName());
|
||||
}
|
||||
DataUtils.onGameLaunchEvent(context, gameEntity.getName(), gameEntity.getApk().get(0).getPlatform(), location);
|
||||
ApkEntity apk = gameEntity.getApk().get(0);
|
||||
|
||||
PackageUtils.launchApplicationByPackageName(context, gameEntity.getApk().get(0).getPackageName());
|
||||
break;
|
||||
case "下载中":
|
||||
context.startActivity(
|
||||
DownloadManagerActivity.getDownloadMangerIntent(context, gameEntity.getApk().get(0).getUrl(), entrance + "+(" + location.split(":")[0] + ")"));
|
||||
break;
|
||||
case "更新":
|
||||
if (entrance.contains("我的游戏")) {
|
||||
DataUtils.onMtaEvent(context, "我的游戏_启动", "更新", gameEntity.getName());
|
||||
}
|
||||
if (NetworkUtils.isWifiConnected(context)) {
|
||||
update(context, gameEntity, entrance, location, traceEvent);
|
||||
} else {
|
||||
DialogUtils.showDownloadDialog(context, () -> update(context, gameEntity, entrance, location, traceEvent));
|
||||
}
|
||||
break;
|
||||
if (str.equals(context.getString(R.string.download))) {
|
||||
// 先弹下载弹窗(如果需要的话)
|
||||
DownloadDialogHelper.findAvailableDialogAndShow(context, gameEntity, apk, () -> {
|
||||
DialogUtils.checkDownload(context, apk.getSize(),
|
||||
isSubscribe -> download(context, gameEntity, downloadBtn, entrance, location, isSubscribe, traceEvent));
|
||||
});
|
||||
|
||||
DataLogUtils.uploadGameLog(context, gameEntity.getId(), gameEntity.getName(), entrance);
|
||||
} else if (str.equals(context.getString(R.string.pluggable))) {
|
||||
if (entrance.contains("我的游戏")) {
|
||||
MtaHelper.onEvent("我的游戏_启动", "插件化", gameEntity.getName());
|
||||
}
|
||||
DownloadDialogHelper.findAvailableDialogAndShow(context, gameEntity, apk, () -> {
|
||||
DialogUtils.checkDownload(context, apk.getSize(),
|
||||
isSubscribe -> plugin(context, gameEntity, downloadBtn, entrance, location, isSubscribe, traceEvent));
|
||||
});
|
||||
} else if (str.equals(context.getString(R.string.install))) {
|
||||
install(context, gameEntity, position, adapter);
|
||||
} else if (str.equals(context.getString(R.string.launch))) {
|
||||
if (entrance.contains("我的游戏")) {
|
||||
MtaHelper.onEvent("我的游戏_启动", "启动", gameEntity.getName());
|
||||
}
|
||||
DataUtils.onGameLaunchEvent(context, gameEntity.getName(), gameEntity.getApk().get(0).getPlatform(), location);
|
||||
PackageUtils.launchApplicationByPackageName(context, gameEntity.getApk().get(0).getPackageName());
|
||||
} else if (str.equals(context.getString(R.string.waiting))
|
||||
|| str.equals(context.getString(R.string.downloading))) {
|
||||
context.startActivity(DownloadManagerActivity.getDownloadMangerIntent(context,
|
||||
apk.getUrl(), entrance + "+(" + location.split(":")[0] + ")"));
|
||||
} else if (str.equals(context.getString(R.string.update))) {
|
||||
if (entrance.contains("我的游戏")) {
|
||||
MtaHelper.onEvent("我的游戏_启动", "更新", gameEntity.getName());
|
||||
}
|
||||
DownloadDialogHelper.findAvailableDialogAndShow(context, gameEntity, apk, () -> {
|
||||
DialogUtils.checkDownload(context, apk.getSize(),
|
||||
isSubscribe -> update(context, gameEntity, entrance, location, isSubscribe, traceEvent));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -410,6 +487,7 @@ public class DownloadItemUtils {
|
||||
TextView downloadBtn,
|
||||
String entrance,
|
||||
String location,
|
||||
boolean isSubscribe,
|
||||
@Nullable ExposureEvent traceEvent) {
|
||||
String msg = FileUtils.isCanDownload(context, gameEntity.getApk().get(0).getSize());
|
||||
if (TextUtils.isEmpty(msg)) {
|
||||
@ -417,7 +495,7 @@ public class DownloadItemUtils {
|
||||
|
||||
ExposureEvent downloadExposureEvent = ExposureUtils.logADownloadExposureEvent(gameEntity, gameEntity.getApk().get(0).getPlatform(), traceEvent, ExposureUtils.DownloadType.DOWNLOAD);
|
||||
|
||||
DownloadManager.createDownload(context, gameEntity, context.getString(R.string.download), entrance, location, downloadExposureEvent);
|
||||
DownloadManager.createDownload(context, gameEntity, context.getString(R.string.download), entrance, location, isSubscribe, downloadExposureEvent);
|
||||
Utils.toast(context, gameEntity.getName() + "已加入下载队列");
|
||||
|
||||
downloadBtn.setText(R.string.downloading);
|
||||
@ -432,14 +510,14 @@ public class DownloadItemUtils {
|
||||
|
||||
//插件化
|
||||
private static void plugin(Context context, GameEntity gameEntity, TextView downloadBtn, String entrance,
|
||||
String location, @Nullable ExposureEvent traceEvent) {
|
||||
String location, boolean isSubscribe, @Nullable ExposureEvent traceEvent) {
|
||||
String msg = FileUtils.isCanDownload(context, gameEntity.getApk().get(0).getSize());
|
||||
if (TextUtils.isEmpty(msg)) {
|
||||
DataUtils.onGameDownloadEvent(context, gameEntity.getName(), gameEntity.getApk().get(0).getPlatform(), entrance, "下载开始", "插件化");
|
||||
|
||||
ExposureEvent downloadExposureEvent = ExposureUtils.logADownloadExposureEvent(gameEntity, gameEntity.getApk().get(0).getPlatform(), traceEvent, ExposureUtils.DownloadType.PLUGIN_DOWNLOAD);
|
||||
|
||||
DownloadManager.createDownload(context, gameEntity, "插件化", entrance, location, downloadExposureEvent);
|
||||
DownloadManager.createDownload(context, gameEntity, "插件化", entrance, location, isSubscribe, downloadExposureEvent);
|
||||
Utils.toast(context, gameEntity.getName() + "已加入下载队列");
|
||||
|
||||
downloadBtn.setText(R.string.downloading);
|
||||
@ -473,10 +551,11 @@ public class DownloadItemUtils {
|
||||
}
|
||||
|
||||
//更新
|
||||
private static void update(Context context, GameEntity gameEntity, String entrance, String location, @Nullable ExposureEvent traceEvent) {
|
||||
private static void update(Context context, GameEntity gameEntity, String entrance, String location,
|
||||
boolean isSubscribe, @Nullable ExposureEvent traceEvent) {
|
||||
DataUtils.onGameUpdateEvent(context, gameEntity.getName(), gameEntity.getApk().get(0).getPlatform(), "下载开始");
|
||||
ExposureEvent downloadExposureEvent = ExposureUtils.logADownloadExposureEvent(gameEntity, gameEntity.getApk().get(0).getPlatform(), traceEvent, ExposureUtils.DownloadType.UPDATE);
|
||||
DownloadManager.createDownload(context, gameEntity, "更新", entrance, location, downloadExposureEvent);
|
||||
DownloadManager.createDownload(context, gameEntity, "更新", entrance, location, isSubscribe, downloadExposureEvent);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
5
app/src/main/java/com/gh/common/util/EmptyCallback.kt
Normal file
5
app/src/main/java/com/gh/common/util/EmptyCallback.kt
Normal file
@ -0,0 +1,5 @@
|
||||
package com.gh.common.util
|
||||
|
||||
interface EmptyCallback {
|
||||
fun onCallback()
|
||||
}
|
||||
@ -1,132 +1,143 @@
|
||||
package com.gh.common.util;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.gh.gamecenter.MainActivity;
|
||||
import com.gh.gamecenter.NormalActivity;
|
||||
import com.gh.gamecenter.SplashScreenActivity;
|
||||
import com.gh.gamecenter.normal.NormalFragment;
|
||||
|
||||
/**
|
||||
* @author CsHeng
|
||||
* @Date 2017/4/25
|
||||
* @Time 16:39
|
||||
*/
|
||||
|
||||
public class EntranceUtils {
|
||||
|
||||
public static final String KEY_TO = "to";
|
||||
public static final String KEY_NEWSID = "newsId";
|
||||
public static final String KEY_GAMEID = "gameId";
|
||||
public static final String KEY_ID = "id";
|
||||
public static final String KEY_URL = "url";
|
||||
public static final String KEY_GAMENAME = "gameName";
|
||||
public static final String HOST_ARTICLE = "article";
|
||||
public static final String HOST_GAME = "game";
|
||||
public static final String HOST_GAME_DOWNLOAD = "game_download";
|
||||
public static final String HOST_COLUMN = "column";
|
||||
public static final String HOST_WEB = "web";
|
||||
public static final String HOST_QQ = "qq";
|
||||
public static final String HOST_DOWNLOAD = "download";
|
||||
public static final String HOST_UPDATE = "update";
|
||||
public static final String HOST_LIBAO = "libao";
|
||||
public static final String HOST_COMMUNITY = "community";
|
||||
public static final String HOST_SUGGESTION = "suggestion";
|
||||
public static final String HOST_ANSWER = "answer";
|
||||
public static final String HOST_QUESTION = "question";
|
||||
public static final String KEY_DATA = "data";
|
||||
public static final String KEY_MESSAGE = "message";
|
||||
public static final String KEY_TYPE = "type";
|
||||
public static final String KEY_NAME = "name";
|
||||
public static final String KEY_ENTRANCE = "entrance";
|
||||
public static final String KEY_TARGET = "target";
|
||||
public static final String ENTRANCE_BROWSER = "(浏览器)";
|
||||
public static final String ENTRANCE_WELCOME = "(启动弹窗)";
|
||||
public static final String ENTRANCE_UMENG = "(友盟推送)";
|
||||
public static final String ENTRANCE_MIPUSH = "(小米推送)";
|
||||
public static final String ENTRANCE_DOWNLOAD = "(下载跳转)";
|
||||
public static final String ENTRANCE_RECOMMEND = "(落地页)";
|
||||
public static final String ENTRANCE_BLOCK_RECOMMEND = "(推荐入口)";
|
||||
public static final String KEY_SUGGEST_HINT_TYPE = "suggestHintType";
|
||||
public static final String KEY_PACKAGENAME = "packageName";
|
||||
public static final String KEY_PLATFORM = "platform";
|
||||
public static final String KEY_GAME_NAME = "game_name";
|
||||
public static final String KEY_VERSION = "version";
|
||||
public static final String KEY_CONTENT = "content";
|
||||
public static final String KEY_PLUGIN = "plugin";
|
||||
public static final String KEY_CURRENTITEM = "currentItem";
|
||||
public static final String KEY_COMMENTID = "commentId";
|
||||
public static final String KEY_PATH = "path";
|
||||
public static final String KEY_OLDERUSER = "isOldUser";
|
||||
public static final String KEY_SEARCHKEY = "searchKey";
|
||||
public static final String KEY_HINT = "hint";
|
||||
public static final String KEY_GAME_ICON_URL = "gameIconUrl";
|
||||
public static final String KEY_SHARECONTENT = "shareContent";
|
||||
public static final String KEY_SUGGESTTYPE = "suggestType";
|
||||
public static final String KEY_PROLIST = "provinceList";
|
||||
public static final String KEY_ORDER = "order";
|
||||
public static final String KEY_TAGTYPE = "tagType";
|
||||
public static final String KEY_ANSWER_ID = "answerId";
|
||||
public static final String KEY_ANSWER_CONTENT = "answerContent";
|
||||
public static final String KEY_QUESTIONS_ID = "questionsId";
|
||||
public static final String KEY_QUESTIONS_TITLE = "questionsTitle";
|
||||
public static final String KEY_ANSWER_OPEN_IN_NEW_PAGE = "openInNewPage";
|
||||
public static final String KEY_QUESTIONS_PATCH = "questionsPatch";
|
||||
public static final String KEY_INVITE_SEARCH_KEY = "inviteSearchKey";
|
||||
public static final String KEY_MESSAGE_TYPE = "messageType";
|
||||
public static final String KEY_QUESTIONS_SEARCH_KEY = "questionsSearchKey";
|
||||
public static final String KEY_SHOW_ANSWER_COMMENT = "showAnswerComment";
|
||||
public static final String KEY_RECOMMENDS_ANSWER = "isRecommendsAnswer";
|
||||
public static final String KEY_VERSION_UPDATE = "versionUpdate";
|
||||
public static final String KEY_CHECK_QUESTION_CONCERN = "check_question_concern";
|
||||
public static final String KEY_DRAFT_ID = "draft_id";
|
||||
public static final String KEY_KAIFU_LIST = "kaifuList";
|
||||
public static final String KEY_CATEGORY_ID = "category_id";
|
||||
public static final String KEY_CATEGORY_TITLE = "category_title";
|
||||
public static final String KEY_CATEGORY_INIT_TITLE = "category_init_title";
|
||||
public static final String KEY_BLOCK_DATA = "blockData";
|
||||
public static final String KEY_ASK_TAG = "askTag";
|
||||
public static final String KEY_ASK_COLUMN_TAG = "askColumnTag";
|
||||
public static final String KEY_COMMUNITY_ID = "community_id";
|
||||
public static final String KEY_COMMUNITY_NAME = "community_name";
|
||||
public static final String KEY_COMMUNITY_DATA = "communityData";
|
||||
public static final String KEY_TRACE_EVENT = "trace_event";
|
||||
public static final String KEY_SUBJECT_DATA = "subjectData";
|
||||
public static final String KEY_SHOW_SELECT_COMMUNITY = "show_select_community";
|
||||
public static final String KEY_USER_ID = "user_id";
|
||||
public static final String KEY_QUESTION_TAG = "question_tag";
|
||||
public static final String KEY_COLUMN_ID = "column_id";
|
||||
public static final String KEY_AUTO_DOWNLOAD = "auto_download";
|
||||
public static final String KEY_AUTO_UPDATE = "auto_update";
|
||||
public static final String KEY_SEARCH_SUGGEST_HINT = "search_suggest_hint";
|
||||
|
||||
public static void jumpActivity(Context context, Bundle bundle) {
|
||||
|
||||
//TODO 把其他类似的跳转启动逻辑也处理掉
|
||||
if (RunningUtils.isRunning(context)
|
||||
&& MainActivity.class.getName().equals(RunningUtils.getBaseActivity(context))) {
|
||||
// 应用正在运行,前台或后台
|
||||
String to = bundle.getString(KEY_TO);
|
||||
if (!TextUtils.isEmpty(to)) {
|
||||
Class<?> clazz = ClassUtils.forName(to);
|
||||
if (clazz != null) {
|
||||
if (NormalFragment.class.isAssignableFrom(clazz)) { // 兼容NormalFragment
|
||||
NormalActivity.startFragmentNewTask(context, (Class<? extends NormalFragment>) clazz, bundle);
|
||||
} else {
|
||||
Intent intent1 = new Intent(context, clazz);
|
||||
intent1.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
intent1.putExtras(bundle);
|
||||
context.startActivity(intent1);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// 应用未在运行
|
||||
context.startActivity(SplashScreenActivity.getSplashScreenIntent(context, bundle));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
package com.gh.common.util;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.gh.gamecenter.MainActivity;
|
||||
import com.gh.gamecenter.NormalActivity;
|
||||
import com.gh.gamecenter.SplashScreenActivity;
|
||||
import com.gh.gamecenter.normal.NormalFragment;
|
||||
|
||||
/**
|
||||
* @author CsHeng
|
||||
* @Date 2017/4/25
|
||||
* @Time 16:39
|
||||
*/
|
||||
|
||||
public class EntranceUtils {
|
||||
|
||||
public static final String KEY_TO = "to";
|
||||
public static final String KEY_NEWSID = "newsId";
|
||||
public static final String KEY_GAMEID = "gameId";
|
||||
public static final String KEY_ID = "id";
|
||||
public static final String KEY_URL = "url";
|
||||
public static final String KEY_GAMENAME = "gameName";
|
||||
public static final String HOST_ARTICLE = "article";
|
||||
public static final String HOST_COMMUNITY_ARTICLE = "community_article";
|
||||
public static final String HOST_COMMUNITY_COLUMN = "community_column";
|
||||
public static final String HOST_GAME = "game";
|
||||
public static final String HOST_GAME_DOWNLOAD = "game_download";
|
||||
public static final String HOST_COLUMN = "column";
|
||||
public static final String HOST_WEB = "web";
|
||||
public static final String HOST_QQ = "qq";
|
||||
public static final String HOST_DOWNLOAD = "download";
|
||||
public static final String HOST_UPDATE = "update";
|
||||
public static final String HOST_LIBAO = "libao";
|
||||
public static final String HOST_COMMUNITY = "community";
|
||||
public static final String HOST_SUGGESTION = "suggestion";
|
||||
public static final String HOST_ANSWER = "answer";
|
||||
public static final String HOST_QUESTION = "question";
|
||||
public static final String KEY_DATA = "data";
|
||||
public static final String KEY_MESSAGE = "message";
|
||||
public static final String KEY_MESSAGE_ID = "message_id";
|
||||
public static final String KEY_TYPE = "type";
|
||||
public static final String KEY_LINK = "link";
|
||||
public static final String KEY_NAME = "name";
|
||||
public static final String KEY_ENTRANCE = "entrance";
|
||||
public static final String KEY_TARGET = "target";
|
||||
public static final String ENTRANCE_BROWSER = "(浏览器)";
|
||||
public static final String ENTRANCE_WELCOME = "(启动弹窗)";
|
||||
public static final String ENTRANCE_UMENG = "(友盟推送)";
|
||||
public static final String ENTRANCE_MIPUSH = "(小米推送)";
|
||||
public static final String ENTRANCE_DOWNLOAD = "(下载跳转)";
|
||||
public static final String ENTRANCE_RECOMMEND = "(落地页)";
|
||||
public static final String ENTRANCE_BLOCK_RECOMMEND = "(推荐入口)";
|
||||
public static final String KEY_SUGGEST_HINT_TYPE = "suggestHintType";
|
||||
public static final String KEY_PACKAGENAME = "packageName";
|
||||
public static final String KEY_PLATFORM = "platform";
|
||||
public static final String KEY_GAME_NAME = "game_name";
|
||||
public static final String KEY_VERSION = "version";
|
||||
public static final String KEY_CONTENT = "content";
|
||||
public static final String KEY_PLUGIN = "plugin";
|
||||
public static final String KEY_CURRENTITEM = "currentItem";
|
||||
public static final String KEY_COMMENTID = "commentId";
|
||||
public static final String KEY_PATH = "path";
|
||||
public static final String KEY_OUTER_INFO = "outerInfo";
|
||||
public static final String KEY_OLDERUSER = "isOldUser";
|
||||
public static final String KEY_SEARCHKEY = "searchKey";
|
||||
public static final String KEY_HINT = "hint";
|
||||
public static final String KEY_GAME_ICON_URL = "gameIconUrl";
|
||||
public static final String KEY_SHARECONTENT = "shareContent";
|
||||
public static final String KEY_SUGGESTTYPE = "suggestType";
|
||||
public static final String KEY_PROLIST = "provinceList";
|
||||
public static final String KEY_ORDER = "order";
|
||||
public static final String KEY_TAGTYPE = "tagType";
|
||||
public static final String KEY_ANSWER_ID = "answerId";
|
||||
public static final String KEY_ANSWER_CONTENT = "answerContent";
|
||||
public static final String KEY_QUESTIONS_ID = "questionsId";
|
||||
public static final String KEY_QUESTIONS_TITLE = "questionsTitle";
|
||||
public static final String KEY_ANSWER_OPEN_IN_NEW_PAGE = "openInNewPage";
|
||||
public static final String KEY_QUESTIONS_PATCH = "questionsPatch";
|
||||
public static final String KEY_INVITE_SEARCH_KEY = "inviteSearchKey";
|
||||
public static final String KEY_MESSAGE_TYPE = "messageType";
|
||||
public static final String KEY_QUESTIONS_SEARCH_KEY = "questionsSearchKey";
|
||||
public static final String KEY_SHOW_ANSWER_COMMENT = "showAnswerComment";
|
||||
public static final String KEY_RECOMMENDS_CONTENTS = "isRecommendsContents";
|
||||
public static final String KEY_VERSION_UPDATE = "versionUpdate";
|
||||
public static final String KEY_CHECK_QUESTION_CONCERN = "check_question_concern";
|
||||
public static final String KEY_DRAFT_ID = "draft_id";
|
||||
public static final String KEY_KAIFU_LIST = "kaifuList";
|
||||
public static final String KEY_CATEGORY_ID = "category_id";
|
||||
public static final String KEY_CATEGORY_TITLE = "category_title";
|
||||
public static final String KEY_CATEGORY_INIT_TITLE = "category_init_title";
|
||||
public static final String KEY_BLOCK_DATA = "blockData";
|
||||
public static final String KEY_ASK_TAG = "askTag";
|
||||
public static final String KEY_ASK_COLUMN_TAG = "askColumnTag";
|
||||
public static final String KEY_COMMUNITY_ID = "community_id";
|
||||
public static final String KEY_COMMUNITY_NAME = "community_name";
|
||||
public static final String KEY_COMMUNITY_DATA = "communityData";
|
||||
public static final String KEY_TRACE_EVENT = "trace_event";
|
||||
public static final String KEY_SUBJECT_DATA = "subjectData";
|
||||
public static final String KEY_USER_ID = "user_id";
|
||||
public static final String KEY_QUESTION_TAG = "question_tag";
|
||||
public static final String KEY_COLUMN_ID = "column_id";
|
||||
public static final String KEY_AUTO_DOWNLOAD = "auto_download";
|
||||
public static final String KEY_HIDE_SUGGEST_HINT = "hide_suggest_hint";
|
||||
public static final String KEY_COMMUNITY_ARTICLE_ID = "communityArticleId";
|
||||
public static final String KEY_ARTICLE_COMMENT_ID = "articleCommentId";
|
||||
public static final String KEY_SHOW_ARTICLE_COMMENT = "showArticleComment";
|
||||
public static final String KEY_RATING_STAR_COUNT = "ratingStarCount";
|
||||
public static final String KEY_QUESTION_MODERATOR_PATCH = "questionModeratorPatch";
|
||||
public static final String KEY_SKIP_GAME_COMMENT = "skipGameComment";
|
||||
public static final String KEY_OPEN_PLATFORM_WINDOW = "openPlatformWindow";
|
||||
public static final String KEY_OPEN_KEYBOARD = "openKeyboard";
|
||||
|
||||
public static void jumpActivity(Context context, Bundle bundle) {
|
||||
|
||||
//TODO 把其他类似的跳转启动逻辑也处理掉
|
||||
if (RunningUtils.isRunning(context)
|
||||
&& MainActivity.class.getName().equals(RunningUtils.getBaseActivity(context))) {
|
||||
// 应用正在运行,前台或后台
|
||||
String to = bundle.getString(KEY_TO);
|
||||
if (!TextUtils.isEmpty(to)) {
|
||||
Class<?> clazz = ClassUtils.forName(to);
|
||||
if (clazz != null) {
|
||||
if (NormalFragment.class.isAssignableFrom(clazz)) { // 兼容NormalFragment
|
||||
NormalActivity.startFragmentNewTask(context, (Class<? extends NormalFragment>) clazz, bundle);
|
||||
} else {
|
||||
Intent intent1 = new Intent(context, clazz);
|
||||
intent1.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
intent1.putExtras(bundle);
|
||||
context.startActivity(intent1);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// 应用未在运行
|
||||
context.startActivity(SplashScreenActivity.getSplashScreenIntent(context, bundle));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user