Compare commits
1217 Commits
v4.5.2-252
...
v5.1.2-372
| Author | SHA1 | Date | |
|---|---|---|---|
| 7fd7197909 | |||
| 58178d2871 | |||
| 880838c263 | |||
| 17e5c0535d | |||
| 66fee84b49 | |||
| bbe0350f2c | |||
| 1a35b5ded0 | |||
| efd81a4e0c | |||
| 493e08ce2c | |||
| 1906451060 | |||
| f865e95ae1 | |||
| 3e7e98d555 | |||
| 7537963a8e | |||
| bb9fd24068 | |||
| eda1eea2de | |||
| 62e60f4309 | |||
| b1fef73c54 | |||
| c4fc31c963 | |||
| 812eb842e2 | |||
| 783cb95f24 | |||
| 5969fa2ca5 | |||
| 0187608918 | |||
| 98531376d9 | |||
| 86edc8b919 | |||
| 7903751d85 | |||
| 2620a29a2b | |||
| 5cc40c09dc | |||
| 5c02d37852 | |||
| 2e5d445d65 | |||
| c8bae7d89b | |||
| 2c98c38721 | |||
| 4f28c54591 | |||
| 06b5b885e9 | |||
| 612cc2ca9b | |||
| 18f7b695e5 | |||
| f29e2fe1de | |||
| 799c22093f | |||
| 2496c1d96e | |||
| 8ee76af30f | |||
| 2f35442558 | |||
| 81fa6a6233 | |||
| e5778d5b5f | |||
| f69d607ecb | |||
| 79fc2e1f93 | |||
| 6dfdbb9ee8 | |||
| 5d8f7b3f8d | |||
| cd4601a9c9 | |||
| 462a011401 | |||
| 31d55dae14 | |||
| 8dc9731299 | |||
| 66c19c644e | |||
| 2b617e2697 | |||
| 3a60a497e1 | |||
| a9337aee63 | |||
| c80cd47ccc | |||
| d9c2371488 | |||
| 096d19751a | |||
| ef70119090 | |||
| 95dba71bb9 | |||
| ec37c7a6f8 | |||
| dcc9352301 | |||
| c509c6bb38 | |||
| 4784d689f8 | |||
| 8903a075be | |||
| 48d6e91b0e | |||
| 30865239d2 | |||
| 8b7cd92ae8 | |||
| 69f336553e | |||
| ed82f96ae3 | |||
| 8f02016a76 | |||
| c06f397d12 | |||
| 912b7280cd | |||
| 50f7dd2c63 | |||
| 23469543c7 | |||
| 2d3f70dd12 | |||
| f57d19e797 | |||
| 8c529f0724 | |||
| 1583f1957a | |||
| 676ccb133f | |||
| 489b8143a1 | |||
| c4cf3efa21 | |||
| 871cfd638d | |||
| 1f3ae1c687 | |||
| 59eb101a48 | |||
| b3b8b6ba29 | |||
| 42baaa8950 | |||
| 61ad70d3b8 | |||
| 04252e3b91 | |||
| b40543d7b5 | |||
| 903fa49b71 | |||
| 03ae2699c6 | |||
| 8ecc4078bb | |||
| ebaf4f02f0 | |||
| e85437379a | |||
| 5a77522a04 | |||
| e5512604fa | |||
| 146a46f8be | |||
| 91f33f06d3 | |||
| 59da7b6ba6 | |||
| 0a1ad238f8 | |||
| 302e6c145c | |||
| a6bbf0dfc7 | |||
| 9c3d22964c | |||
| ab60ed8473 | |||
| 9a00e70cc4 | |||
| 35954f52c5 | |||
| e13d80d063 | |||
| 73ed15689d | |||
| 65d949bade | |||
| 33d0d01051 | |||
| 9998ed0a14 | |||
| 85a8a17acb | |||
| 4032cb8abe | |||
| fc2e87063e | |||
| a63b809642 | |||
| c30048c268 | |||
| 956d5a39be | |||
| 76fd1ab7e3 | |||
| 2c4c954c64 | |||
| aef4da961d | |||
| 31e00bb681 | |||
| 369fdd24ef | |||
| 2a57994c7f | |||
| 6f84b14277 | |||
| 10ed05c8ef | |||
| 799bd1042f | |||
| 6f9acab2d2 | |||
| 387d8eb5af | |||
| c813c5d5ef | |||
| 1c6df6741f | |||
| b54ab5f824 | |||
| 37fdf6c18e | |||
| 2685de9b3e | |||
| c049100f5f | |||
| 711d1f9d65 | |||
| 5d7453afec | |||
| e4acf466ba | |||
| 2d66cbd29c | |||
| 8786f7d500 | |||
| 3d40d7a819 | |||
| 6f7862a0f2 | |||
| 58c6211d54 | |||
| d10b187a1f | |||
| 1ebf34c83a | |||
| 01e2a3c708 | |||
| c9b97552d4 | |||
| 428f39aa86 | |||
| 5fecb723bc | |||
| 0168b0d93a | |||
| 895fa510fe | |||
| 0aae59a1ba | |||
| 574a2b4dc7 | |||
| acae608966 | |||
| 6ca6c34f92 | |||
| 16724a2d2e | |||
| 8b50cc561a | |||
| 1ec1d482c4 | |||
| 869b9d507b | |||
| 514fe66347 | |||
| 657c91a5ef | |||
| 82354a1156 | |||
| b7619f0c93 | |||
| 598a3ad0b6 | |||
| bf0be93dc9 | |||
| 90a676f778 | |||
| a675e4bbe3 | |||
| 5eee8c6785 | |||
| 3c54e4313c | |||
| 67c4b76de9 | |||
| 34fd08d06a | |||
| d08b95021d | |||
| 8517a2aef1 | |||
| cbe90141f1 | |||
| fd43bc9426 | |||
| 34a143b632 | |||
| d96e02eca0 | |||
| 398b1ae58b | |||
| 0749205bef | |||
| 54ec115fee | |||
| ebe7b84dc8 | |||
| 332abe66f5 | |||
| 9dccbfbd51 | |||
| 23a8c9e6aa | |||
| 1e4408ac6e | |||
| 05ece9c999 | |||
| 216905e455 | |||
| a1bd88dad8 | |||
| 16c66c707f | |||
| 50cdea2b03 | |||
| 95b0fda15a | |||
| 9c99273f81 | |||
| 8d9d36a5df | |||
| b22d168e97 | |||
| 1fee166e3b | |||
| 7c098c29b2 | |||
| ffc9dc46e2 | |||
| c491a4084c | |||
| 0f076a03c5 | |||
| 3345ab2044 | |||
| 5874bdd311 | |||
| 4669211196 | |||
| 4879e7f0aa | |||
| f5283d386b | |||
| 602333f923 | |||
| e9810c129e | |||
| c503f15df9 | |||
| cba1012bbd | |||
| 646493ae61 | |||
| b649089ab0 | |||
| e97fd9023e | |||
| 478dd658ab | |||
| b313feac01 | |||
| c04b82549e | |||
| 842e62f909 | |||
| 51c6de0506 | |||
| d350f65c1f | |||
| aaf8e28abc | |||
| 7cb921e969 | |||
| 3a4b41058d | |||
| 26308d1852 | |||
| af54932309 | |||
| 83799048ed | |||
| ce410ad2a0 | |||
| 933c40458f | |||
| 6ae7578281 | |||
| 72b804e26e | |||
| 7e58cdc59e | |||
| d782ea90b6 | |||
| efffd752f5 | |||
| 47f3f45fe6 | |||
| b4e12e2ec3 | |||
| 2d331f6294 | |||
| feb4137f84 | |||
| 6a2c4a2967 | |||
| 68fc5532ff | |||
| 43ae479271 | |||
| 7a3ea4d939 | |||
| 1bcb343355 | |||
| 1b7a601cee | |||
| 8bc9544dc2 | |||
| e586e65e44 | |||
| 8096da5f50 | |||
| 91868fda15 | |||
| a71e8824ce | |||
| 6cbc354921 | |||
| 79e2077a3d | |||
| 6ea3ed067d | |||
| 84fe33becc | |||
| 276f53fead | |||
| 0789cc6fdf | |||
| 3a563b7bd0 | |||
| 9b8ba0c3e6 | |||
| 258f054161 | |||
| 258c8db0f9 | |||
| 741d0b11af | |||
| 9267896b50 | |||
| 85c0bd69c1 | |||
| 2436507b7b | |||
| 1b68b07e53 | |||
| c4ba28de1a | |||
| 8daa55c16a | |||
| 5e6c6aca13 | |||
| e08ab790ee | |||
| a394901cb4 | |||
| 2aaa7f2795 | |||
| 7b0d2a25c8 | |||
| e3f553a96f | |||
| 809a25e3e2 | |||
| 88041d9b5f | |||
| a11d741f6f | |||
| 1283def6da | |||
| 9c621c31a2 | |||
| 9e3f40723f | |||
| 682bb9a3e7 | |||
| 9f2d164c70 | |||
| bad5130047 | |||
| e3f831e0ca | |||
| a1432452f5 | |||
| b3cc68b7c6 | |||
| cc1f5a269a | |||
| a2892a713a | |||
| c342e22ce4 | |||
| 57dcbab096 | |||
| 5aa4c5bcbc | |||
| 039e1fc957 | |||
| f7b2d10543 | |||
| 38972eca76 | |||
| c2d853d709 | |||
| 239209dbf2 | |||
| ba1f3e20d3 | |||
| 92ac62d949 | |||
| 6499e3b718 | |||
| 5f0d2604ec | |||
| 5f7bb6cb49 | |||
| 7360eef244 | |||
| 52e6feab59 | |||
| 5f44252410 | |||
| 7ae3b1cafb | |||
| 0fb77e79fd | |||
| d4ae878947 | |||
| 37a2e3cc0e | |||
| 30595741cc | |||
| 11f177d572 | |||
| 9e13675ca5 | |||
| 144a0641b6 | |||
| 95266f6f68 | |||
| 9ded647c0d | |||
| f566e4d5c3 | |||
| 5df3efd087 | |||
| 98f4361bf0 | |||
| 000d1e020a | |||
| 93431a7e37 | |||
| d54523cdb6 | |||
| ed468b7c73 | |||
| bad6211bf5 | |||
| 2743d4d0de | |||
| a0f5387917 | |||
| 1abfcfdb51 | |||
| ecc0a75f52 | |||
| c98bf26337 | |||
| 187d07d02d | |||
| c47c23ad21 | |||
| 8d011ae7ef | |||
| 36b58383f7 | |||
| e6ea1738e5 | |||
| 70b7689ac5 | |||
| 40983ecebc | |||
| 47b0a8d1ac | |||
| 1ae63d3010 | |||
| fbe73ce4da | |||
| d46617237f | |||
| 0894957d73 | |||
| 9b9777ae19 | |||
| 7f2145d0ef | |||
| acefbba6bf | |||
| 660a091b7b | |||
| 103078d63e | |||
| 178395f531 | |||
| 8db213d040 | |||
| 5904d3c5c7 | |||
| 1a511ebbad | |||
| ef97e8cc6d | |||
| 814cef6218 | |||
| fd6c4836d4 | |||
| 9df138ed7c | |||
| 7b11b0e99a | |||
| 01034f093a | |||
| 8e28766449 | |||
| d06d0bd15c | |||
| 4fe4a33b80 | |||
| 4a8e91bbff | |||
| b1f6c7d55c | |||
| 727eeac52e | |||
| fb26ec0c13 | |||
| 3e25619bf8 | |||
| e81fa4ff1a | |||
| d7d2bf2667 | |||
| c763a0a9e6 | |||
| 1f34f95e7c | |||
| 2afb99b603 | |||
| 2e09ac033b | |||
| 54747143d1 | |||
| 076c98977d | |||
| b96104fcd9 | |||
| daece9337c | |||
| 3547330e2a | |||
| 4d76fb0159 | |||
| f34a95b36f | |||
| 6e3cb7a196 | |||
| 03f87c46ba | |||
| b052ba1635 | |||
| d1183199cd | |||
| 31fed948f0 | |||
| f1c5b80dc2 | |||
| 86f2aec9ca | |||
| f826dc07c6 | |||
| 34670d08c0 | |||
| 5e5646468e | |||
| a218f13ccb | |||
| 1fc37571df | |||
| 576f06f250 | |||
| 3805cb52f6 | |||
| f8d7377236 | |||
| 354fa13a35 | |||
| 3c533b896b | |||
| 11c6618c0f | |||
| 898bf3e432 | |||
| 0faf408762 | |||
| 1dbabe3cda | |||
| a107a19d95 | |||
| 58ea0bb51d | |||
| 557f22b23b | |||
| f40a192e82 | |||
| 84f3556275 | |||
| cddc2bff2b | |||
| a0b8caa60a | |||
| 22cadc77f0 | |||
| 28fb45f0b8 | |||
| 3d7f8b3f41 | |||
| bba326cfd9 | |||
| f76bb7070a | |||
| a6a3d769bd | |||
| ea5627b3da | |||
| d9807227ec | |||
| 039203408a | |||
| 60b325812e | |||
| 06a43f617b | |||
| 5cc1cfa1a6 | |||
| 35cdd140cc | |||
| 87597dbd1f | |||
| 398f7b6642 | |||
| 85d3412fd8 | |||
| 71b8cbbef3 | |||
| dfc0183a14 | |||
| f0ca0a2ab1 | |||
| c9ffd4e5bd | |||
| d354b07fe2 | |||
| 71a61fdef0 | |||
| 156e52f619 | |||
| 252cb3825b | |||
| 2eded37321 | |||
| 075a7e4e77 | |||
| 0c95f911d1 | |||
| f35baf0e5b | |||
| 49b74c9a37 | |||
| c4240440d1 | |||
| e0205ec060 | |||
| 895024aa09 | |||
| 4d64281c78 | |||
| 95f1692434 | |||
| f1302dd1bb | |||
| fd946703a9 | |||
| 806935a81e | |||
| feb30ff3a4 | |||
| fec34f1efa | |||
| def3b55e51 | |||
| 4549f78ede | |||
| 3054b56f4a | |||
| 4cf5e0f2f4 | |||
| 1a18c82f06 | |||
| b8fbb429f1 | |||
| 005229fe8a | |||
| 3a0bbbf3d0 | |||
| 4b851732c9 | |||
| 3abf29fa75 | |||
| 4bb7d2a043 | |||
| e3d830235e | |||
| 6425f3d50c | |||
| 868e6d31b8 | |||
| a687f8d877 | |||
| e9d2c6573f | |||
| 05e36f11cf | |||
| bc76e6eddb | |||
| 6de543261b | |||
| d9a8fa0a2d | |||
| 51c88e8586 | |||
| 9e930f1b35 | |||
| eb8fb191bb | |||
| 6653467259 | |||
| 9ec29ad367 | |||
| 406ac98616 | |||
| 5832c75909 | |||
| 9d8681c50f | |||
| 9c28bf162e | |||
| 3e86a40215 | |||
| 061d5c19ed | |||
| 1241207dd2 | |||
| 6a68839d0f | |||
| 2140c9eb40 | |||
| 702da08bc4 | |||
| 942af39b2d | |||
| a0331f0437 | |||
| 8c885e38a1 | |||
| acc6935608 | |||
| 63798c94cf | |||
| 62a87d1c71 | |||
| 2ba479d3ca | |||
| 6c2ff6a94f | |||
| 3f5f3bf57c | |||
| 2211f562c7 | |||
| 4d10ca0c6c | |||
| c816fd87f4 | |||
| 547bfd98ac | |||
| 34ba85f099 | |||
| 2d251ef453 | |||
| 7a0165375c | |||
| d7c7fe8740 | |||
| 295e783d4b | |||
| 58dfad4123 | |||
| f31d8b51fa | |||
| 01ea8b9834 | |||
| 5152060515 | |||
| 0a0d805e9d | |||
| 51511c8be8 | |||
| 4bbfa3e16e | |||
| 81c0c6ee09 | |||
| 50b449ca64 | |||
| 8764412492 | |||
| c1e011cae8 | |||
| 018f814a6b | |||
| ef9cb24b61 | |||
| 245a4273de | |||
| 94c1651510 | |||
| 07f55acb3a | |||
| 43ee3b3488 | |||
| 32625f59e0 | |||
| e1e3aa5598 | |||
| c5ff2cb5bd | |||
| acf02c99e7 | |||
| 9a00999d9e | |||
| 4c5b602a3b | |||
| cbde36f3bd | |||
| f4b6193a6b | |||
| 85a596766d | |||
| 785cfecf81 | |||
| 0c8b98084a | |||
| 87a6a3a539 | |||
| 6c50082de5 | |||
| 41195ec9d4 | |||
| e280ea008a | |||
| 223646cf3d | |||
| ab4bb79a32 | |||
| 50b51e2f3c | |||
| 1fef7d51d6 | |||
| 6546961f81 | |||
| 75e4f32840 | |||
| a3f3c95e19 | |||
| 508231d547 | |||
| 8649b98032 | |||
| d35211262f | |||
| 96a5838155 | |||
| fc21799288 | |||
| 3e04d77d50 | |||
| 35f47e363a | |||
| 019724e9c6 | |||
| 70f059b4de | |||
| 34cd63d36d | |||
| 033cf6b566 | |||
| 513fc3be1c | |||
| fd1273a092 | |||
| 27a6f14d18 | |||
| 000c7978fd | |||
| 486c8f691c | |||
| 16450a7f8d | |||
| 438e660449 | |||
| b9bf4311cf | |||
| 75a324747c | |||
| 04b579cda7 | |||
| 5962a8cf08 | |||
| ea388a8e1b | |||
| 8a98d6323a | |||
| 1b67ff5d12 | |||
| 9ee0f65e02 | |||
| 557b6fee21 | |||
| c90d6ec0dc | |||
| 8109aa58c9 | |||
| 213e079e9d | |||
| 40e38e50b9 | |||
| b70e18af96 | |||
| 4c91f06d94 | |||
| 199067cf8a | |||
| fa01260f0b | |||
| f8dac32bd6 | |||
| d5641d437c | |||
| c27f62e726 | |||
| b98d4e6ec6 | |||
| a4e67cda91 | |||
| ab3616f237 | |||
| bd9032c659 | |||
| 4ded8cbfc8 | |||
| 5a14afa71e | |||
| 7736ef37e5 | |||
| 40adf1938e | |||
| 7e1f821d7a | |||
| 4f81996857 | |||
| 328a559ef0 | |||
| ee01512f84 | |||
| a366a87324 | |||
| 3c7a1e2ae3 | |||
| 87c71882f5 | |||
| 7fa912bc0c | |||
| 27dc3f73ae | |||
| be630e39cd | |||
| cded31298c | |||
| 54030fd1df | |||
| 98c1565dfb | |||
| d89c2d4a70 | |||
| 0f11f6344f | |||
| a25f265bd3 | |||
| 68adc0ff23 | |||
| ab5aa01ec5 | |||
| 71e5f798d9 | |||
| 2572c53305 | |||
| 64b5ca8efa | |||
| b5ef73517f | |||
| feb2f68778 | |||
| f0a6e79418 | |||
| 78699cc0e8 | |||
| 96805537f4 | |||
| 13c4be2ab0 | |||
| c2e5e8adbc | |||
| c5c9a3f4d2 | |||
| 8bd2fa9b3a | |||
| 4bd8fc4e51 | |||
| 5b26165aaa | |||
| 1bb4c1cc2c | |||
| d38b347eb8 | |||
| feaf2d0bfc | |||
| 210dcdc698 | |||
| fec291156a | |||
| 62bb23abc9 | |||
| 19be9e1842 | |||
| a5cfd147b4 | |||
| f15d572785 | |||
| 5e99e8b032 | |||
| af39b82da1 | |||
| ba3a4ede11 | |||
| db591d0249 | |||
| 1370261b87 | |||
| 3824de4719 | |||
| 6ee26fb401 | |||
| 865fe2729f | |||
| 85c556c593 | |||
| 86681b8ab1 | |||
| 5f2ce22506 | |||
| dafa85a791 | |||
| 9cc3a29b5a | |||
| d2e8a67971 | |||
| 1bd3168add | |||
| 81d81882e0 | |||
| 3f4e4f1a52 | |||
| 3845e1f3ee | |||
| 6d2ae4dca5 | |||
| e2efa26ac0 | |||
| 70e12ebd08 | |||
| 91fc511fe6 | |||
| c5530ba307 | |||
| 67cbd9b641 | |||
| 6735047e67 | |||
| 9993bca582 | |||
| 07258b08af | |||
| f8bd7787f6 | |||
| b6a3ef5faa | |||
| 730151f6ba | |||
| 532b98e002 | |||
| 202a26b09c | |||
| fe1821884a | |||
| eb1605cc0a | |||
| 08ad5c3455 | |||
| 0774525de6 | |||
| b69ebc8122 | |||
| 49f31da303 | |||
| 66568b09d5 | |||
| 57a944f954 | |||
| 1fb8a60b2b | |||
| 489a57a379 | |||
| 0aa02c186c | |||
| fd463ec1e3 | |||
| 0c16ae5f3f | |||
| 76cca46015 | |||
| 748cacce3f | |||
| b47985d4ff | |||
| 9e41bd2846 | |||
| 0e4b18fc5d | |||
| 5594a03cee | |||
| 59ece3be49 | |||
| a7f77076a5 | |||
| 6526d5b3ce | |||
| 3a2f877d0c | |||
| 0d344e66a1 | |||
| d3de323c06 | |||
| 721d5acc1d | |||
| 7069744191 | |||
| b1f56d5dcd | |||
| 5aaa5bd076 | |||
| 7e74dee0eb | |||
| 45b8f7f82f | |||
| 7c9b8732e2 | |||
| 86ae96253b | |||
| 9dcc0b5587 | |||
| 9ceba793e8 | |||
| 175cc55b75 | |||
| 5486d1803f | |||
| cb885f8b66 | |||
| ab9f5cf7d8 | |||
| 7f4fafc637 | |||
| acccd2330d | |||
| 2745147e73 | |||
| 8fb0e3feaf | |||
| 335fa8ba39 | |||
| c739074057 | |||
| a2569cf876 | |||
| a81b0a1603 | |||
| 76c20e4b82 | |||
| 4144cc2c4f | |||
| 5465ff7731 | |||
| fc6dedb320 | |||
| a76b98f20c | |||
| f05c0324fa | |||
| 606eb30d9f | |||
| aa41da022d | |||
| b62d2c1b9e | |||
| ba21543800 | |||
| 6f5b832a68 | |||
| eb4bbb9efa | |||
| 233f91d2b9 | |||
| 1c51b2fe41 | |||
| 5123d7ff11 | |||
| c20e06f2eb | |||
| df55caa1f8 | |||
| 61bdac3aa2 | |||
| d56dc53b06 | |||
| 18c02ad9c3 | |||
| 8a262532e1 | |||
| 876d920251 | |||
| 1bad70a83f | |||
| c04a1a5802 | |||
| ea8c47a6d6 | |||
| 53f3f48c4d | |||
| 706df0c22f | |||
| 74cee421f9 | |||
| 4b08fa56da | |||
| 522f664f30 | |||
| 87a92055a7 | |||
| f23aa496ae | |||
| 65d7322546 | |||
| d9178f8538 | |||
| 5de471d89a | |||
| 63cc104e9f | |||
| f06ba9bf45 | |||
| 682d5a2cd4 | |||
| 76ce4e2f04 | |||
| 54221cc976 | |||
| 79ae36c51f | |||
| 335d6787a7 | |||
| 2bf9c1e4d7 | |||
| 133635c495 | |||
| 2aaf6d8a9c | |||
| f119f6751a | |||
| 18f964c167 | |||
| 369275225e | |||
| d80daf104f | |||
| 71c697d596 | |||
| 169814d6a9 | |||
| 52cffde739 | |||
| 11f84b69ac | |||
| 2c3e03bd0f | |||
| 264e103395 | |||
| 7f4d3ffe3e | |||
| 79b7a15f7d | |||
| 638dd4ad1d | |||
| 04f58e036b | |||
| 6624868bfe | |||
| 2ff83b8cc5 | |||
| cab412ab70 | |||
| 1a83e64f3a | |||
| be76fb0526 | |||
| 5cc25482a9 | |||
| c683e6786c | |||
| 5f182eeddb | |||
| 3e0979fabb | |||
| 13685ec605 | |||
| 4eac5ff61c | |||
| 98f0cf5fc0 | |||
| cb345f49eb | |||
| ef95be60f1 | |||
| a85cfa47e2 | |||
| 66123b0ae8 | |||
| cdb660b884 | |||
| 026e4f71de | |||
| 01ecde0425 | |||
| f748fcbd48 | |||
| 65464eed3d | |||
| 6a5d8e915c | |||
| 5fde455bcd | |||
| e1e257b1d8 | |||
| 7a87f8dc14 | |||
| 3fe2b8ffcd | |||
| 565b7b2c38 | |||
| b3bf9d862f | |||
| c6f5ef64d5 | |||
| 95b21b5bb5 | |||
| 0da331d109 | |||
| 8c1f8833b1 | |||
| e53cd6dede | |||
| fa27e172e4 | |||
| 544f5102ea | |||
| 5d6134f0dd | |||
| e0b951e043 | |||
| f2476c84c4 | |||
| c186c32d47 | |||
| 194f30650e | |||
| a475b176b4 | |||
| 73cac4d39d | |||
| 93d0f30352 | |||
| 98d30d1183 | |||
| b1d178f8df | |||
| 0550df7039 | |||
| 13c7b8ff1d | |||
| d7b7633ffe | |||
| 5e536db94e | |||
| 55d8b6a866 | |||
| a2a8610083 | |||
| 8d9f0adebe | |||
| e386994e4d | |||
| fc5f1e9830 | |||
| fd17eaea00 | |||
| 8a65d6dd85 | |||
| 8d3c609ad0 | |||
| 2e71e11a09 | |||
| b9c17bcdb8 | |||
| 55bb1a1873 | |||
| 54601bc083 | |||
| df2bb9c020 | |||
| 0bf297d094 | |||
| db8a2a06aa | |||
| 44a9db7294 | |||
| 7db48b6923 | |||
| 0a8f2d51db | |||
| b06d2a479a | |||
| d56bd0078e | |||
| 7b87aadd86 | |||
| 8f2da187f2 | |||
| 8291caa5e3 | |||
| e30ec540bd | |||
| 3c4da21bf6 | |||
| 800260b6a4 | |||
| ddea202f85 | |||
| b3a786ee22 | |||
| 332e24b874 | |||
| 5413ebfba4 | |||
| 7ead1c89f3 | |||
| 03300a41f7 | |||
| 2d8698e070 | |||
| 078b1a18a0 | |||
| de1e3ba7a7 | |||
| a9275c83d2 | |||
| 02894879e3 | |||
| 56a202ae5c | |||
| 013969a73a | |||
| 1a5a4ba149 | |||
| 9bdae33655 | |||
| be1184583b | |||
| 68ee926897 | |||
| 4d0db8cbcc | |||
| 59e4b6e063 | |||
| e74cf92033 | |||
| 811b1bbfce | |||
| 00c25d0d47 | |||
| 66b4b4b9f0 | |||
| 4bab47d2a6 | |||
| 2c9567aa61 | |||
| 97598dc7ec | |||
| 4771c79fa9 | |||
| 3458a5d7f3 | |||
| 5bc7c333d8 | |||
| c7a24555a2 | |||
| e19a678699 | |||
| 795af0528f | |||
| d0b4ea8ec2 | |||
| 45861dff61 | |||
| 5f41463fc3 | |||
| 89cca6dbfd | |||
| e43c0efdcb | |||
| 2dbd635b8e | |||
| 728d4fd8e1 | |||
| 48b5c7efc1 | |||
| 278dcc33be | |||
| 87be3bed61 | |||
| 078b102152 | |||
| 4f6969a70a | |||
| 29140b6c0b | |||
| 11bd9bed95 | |||
| 997b5676dc | |||
| 9b8755e035 | |||
| 85e97bc64d | |||
| 0ea7c81ce9 | |||
| 951ac06948 | |||
| 92cdb6fdbb | |||
| cb0dd1d082 | |||
| 276655a8ec | |||
| df8b612188 | |||
| a550305947 | |||
| 3af4dd5494 | |||
| 4d413eb1f2 | |||
| d496ab0283 | |||
| b519ff6aac | |||
| 8c05d2be8a | |||
| 23dd89198b | |||
| 6569ab2d33 | |||
| 1bead6a756 | |||
| c0df3af298 | |||
| 267363f46d | |||
| 44cf54aee6 | |||
| 322d7117f8 | |||
| c8684f837a | |||
| 9e5ecf1520 | |||
| 2df94dddc5 | |||
| 1731980e88 | |||
| f789f0cb73 | |||
| d043a89f3e | |||
| 4ab0f066df | |||
| 096679029b | |||
| 2634228d21 | |||
| a33784221d | |||
| 2ef7216bda | |||
| 2554fab389 | |||
| a4e3121489 | |||
| 8dfde8ddd0 | |||
| 63403c7c29 | |||
| aa9269aecc | |||
| 489e7105bb | |||
| 8dbc407503 | |||
| 3e032fa540 | |||
| 3df381b255 | |||
| 7c59181bc6 | |||
| 9244a65371 | |||
| a7b8b678f7 | |||
| 9877d4d51e | |||
| 32b4570738 | |||
| af3fdb3cfb | |||
| 5ce992ee63 | |||
| ba17019428 | |||
| f77087907f | |||
| 3080f59ef6 | |||
| 74b1f388e2 | |||
| dcbc2fe352 | |||
| b892c58c52 | |||
| 0a455c7b09 | |||
| 7a254c4609 | |||
| 4f08a4b9d2 | |||
| 75670b7801 | |||
| af386f6bdc | |||
| ff813d8784 | |||
| dba87fe09c | |||
| cf13003c2a | |||
| 7fe337c557 | |||
| 1902ed29c1 | |||
| a67927e9e7 | |||
| 33b6835ae6 | |||
| 1ca6a2c795 | |||
| 372230092a | |||
| 2ee1db1074 | |||
| caabf416bb | |||
| d33d0e98c9 | |||
| a4a029f31e | |||
| 3b8d34f8c3 | |||
| 2368e268bf | |||
| 6390198899 | |||
| 4a6aef4caa | |||
| 91529f51a3 | |||
| 57096b2b08 | |||
| 40f1f57844 | |||
| b9da7fbcb8 | |||
| 7138177df2 | |||
| aa4cf291dc | |||
| 8f4c1651a3 | |||
| 30a6cfd7d9 | |||
| c1abb977bf | |||
| fef633e9d8 | |||
| 5207b5675c | |||
| b7059abcee | |||
| 45a84fc45c | |||
| cf96b00036 | |||
| 49dacc472d | |||
| 72d069ad7e | |||
| 2f49e05891 | |||
| fd2d277470 | |||
| fc52694fdc | |||
| 7123b3d59a | |||
| 7684c247bf | |||
| f2b9d26e8a | |||
| 6d5d407aa8 | |||
| 338de605ec | |||
| 53930b0257 | |||
| 34d5e2cc29 | |||
| 591a694bdf | |||
| 9fd9a4ebcc | |||
| f2712c3db7 | |||
| 61c2c7b218 | |||
| 8a54c47d9e | |||
| 7f60a575a4 | |||
| eb2dd7c6b8 | |||
| ae8433d8bd | |||
| 7ec4ba6582 | |||
| 190434a855 | |||
| 4b82e40eb4 | |||
| d8e858ddb8 | |||
| 9b8c8f328d | |||
| bebdbe64cd | |||
| a0555d6ffc | |||
| d6674efe4a | |||
| 20235c6908 | |||
| bc155d580c | |||
| 9cf852b490 | |||
| f32bc837b4 | |||
| 36efcdb75a | |||
| a232ef9d03 | |||
| 05b90bd5b4 | |||
| bc382e6f31 | |||
| 116d71bb9c | |||
| 2aadb78301 | |||
| 22801846e4 | |||
| f9f6886250 | |||
| 30c8d4db02 | |||
| 08a5ea100e | |||
| db33ed0d0d | |||
| fd424b0204 | |||
| c1bf0a628f | |||
| 086bf75314 | |||
| af31fdc562 | |||
| 99e0a2e0a2 | |||
| 069d0db00e | |||
| 68f1343c93 | |||
| fbe25c9099 | |||
| 9b893bcb42 | |||
| 5182d4cd8d | |||
| cce077de96 | |||
| 03092a0ec1 | |||
| 4906ecc06b | |||
| 7a831ce646 | |||
| 290a26c4e2 | |||
| 571080b1e5 | |||
| d9567138ee | |||
| 4a31f74dcb | |||
| 79cf96b161 | |||
| 7fdd4dbf04 | |||
| 8eeeb5de60 | |||
| 150109cef4 | |||
| 7e7cc38d6d | |||
| b3df30680e | |||
| f73048d3a5 | |||
| c540c14e1c | |||
| f216bf4097 | |||
| a42bcbd160 | |||
| bc6786b21e | |||
| 47e357143c | |||
| 74eb8ad0e8 | |||
| d2fc927ffb | |||
| db4b049591 | |||
| 86db2b5688 | |||
| baa1c9f9e5 | |||
| be3a3e82af | |||
| 120ea26455 | |||
| fc476ca889 | |||
| fc36ce6a03 | |||
| 0a1d330c2f | |||
| e5ec42576c | |||
| b57f74a411 | |||
| cb3884ea2e | |||
| 0cb3184e35 | |||
| 76c5009fbc | |||
| 312ec153f1 | |||
| 1ef79df4c5 | |||
| d7a809f8a6 | |||
| ebadeeb873 | |||
| 55155ee8ae | |||
| be98a6b6d6 | |||
| e2f396f8c7 | |||
| 2a8024368a | |||
| 0cd025b42d | |||
| d6adda78c4 | |||
| 99708d7801 | |||
| 584986a9d5 | |||
| 507da05841 | |||
| 72a8fe4764 | |||
| f9f23f6324 | |||
| e2964f93c7 | |||
| cb2a9a3ca0 | |||
| ea68941bb9 | |||
| b598d331d4 | |||
| d7b876bfed | |||
| 6aca60080a | |||
| 59d76688b9 | |||
| 8e5e677228 | |||
| dd1bfcaddd | |||
| f4c66e1ab7 | |||
| 6ebdf6e42a | |||
| 4c01dd442b | |||
| ac226e3301 | |||
| 569f1b8cf1 | |||
| 46f5da88a6 | |||
| f5b876b018 | |||
| c5df856023 | |||
| 4f775847dc | |||
| f53710fdf5 | |||
| 80c56def08 | |||
| a1d88d999e | |||
| fbc6f6adaa | |||
| e7c55b2467 | |||
| 2c45bb1da9 | |||
| 173825dc74 | |||
| a63e28809b | |||
| 0eb8cb6e66 | |||
| e1514e2b25 | |||
| bef0da821b | |||
| 54741729f3 | |||
| e2640c22f8 | |||
| 2f16d5ba99 | |||
| 1d5301f887 | |||
| cc09c702f7 | |||
| 6b2a88766e | |||
| 0eb629fe67 | |||
| 44c398c9fb | |||
| 96122c5919 | |||
| bd4c438036 | |||
| adc8648f5a | |||
| 8eb3922a33 | |||
| 30743bb015 | |||
| 853f51ad0e | |||
| 763aad99ee | |||
| 2ed2317b02 | |||
| 0663f3eb2b | |||
| 11a2eeae7a | |||
| 8c2619bb22 | |||
| 46320fe07d | |||
| 1ee933b115 | |||
| 1d9152ca1a | |||
| 81ebf21bb9 | |||
| dd4bf98f28 | |||
| ba3a06da43 | |||
| 6fe096383c | |||
| d16f99958f | |||
| 5fa3aa42dc | |||
| f4f28a2daa | |||
| 3c1cd14bdc | |||
| 6dcc251312 | |||
| f692aa4bff | |||
| 7cde55ebe0 | |||
| 94eba08af4 | |||
| 2bf207661c | |||
| 2fff7f60c2 | |||
| 1b3c93ebb5 | |||
| 5b529b044e | |||
| 91f417f479 | |||
| fc0bf595bd | |||
| c0f6499577 | |||
| b9bef384f1 | |||
| 58bfae2fdb | |||
| d2c2fff884 | |||
| ab178c47b5 | |||
| 40be004376 | |||
| 0b501c9ce1 | |||
| cff82379f5 | |||
| 825503bd58 | |||
| 77a715a4bd | |||
| 78b233c506 | |||
| a6e799bb9a | |||
| b65992099a | |||
| 3d1a5f52bf | |||
| 82d0d5745c | |||
| fe7968cb32 | |||
| 94c503af74 | |||
| bdd9815ffc | |||
| 693acceca8 | |||
| 90971bc299 | |||
| e5b3613348 | |||
| 652ca8f69c | |||
| f15e351c1e | |||
| 47c81c3dac | |||
| 7453a61e4f | |||
| 911f6397e8 | |||
| 8d21a4f774 | |||
| 991c54b680 | |||
| 48dcb5089b | |||
| 461efe7101 | |||
| 0735161a20 | |||
| 093c1e2b15 | |||
| 7d0e02c899 | |||
| 8294913f04 | |||
| e811c4f90b | |||
| 69e248b389 | |||
| 43f6bfc4c2 | |||
| c8b81ab56a | |||
| aa41fd98e8 | |||
| ff6c4c2de9 | |||
| 136761d2f7 | |||
| 9374fc5264 | |||
| 324aaa5056 | |||
| f22afbd819 | |||
| e149231cb2 | |||
| 9c8155ddf8 | |||
| dd95419a36 | |||
| 870b10dd13 | |||
| 637b426649 | |||
| ee8ce87e28 | |||
| a944a7f730 | |||
| fdbb16b45f | |||
| 29bc098dcf | |||
| b2433cf13a | |||
| e908e23bb2 | |||
| 1a4dc827b5 | |||
| 9fd5e65fa2 | |||
| 5405dcd30e | |||
| 5c35f7fe5d | |||
| fc907a398f | |||
| 1b8dc6eba0 | |||
| c17a36c866 | |||
| a29cf832f1 | |||
| c9a628a5e9 | |||
| 165ba01afd | |||
| a39a8c2cce | |||
| 4002f138bb | |||
| 48fdb38902 | |||
| 38a3120ea1 | |||
| c0e370dfd2 | |||
| e4765089fa | |||
| 721e73ca1e | |||
| e406c90027 | |||
| e7c4886219 | |||
| 80a2e4f336 | |||
| 9f5940c6f6 | |||
| d01fda44b3 | |||
| 2020033bc0 | |||
| dc2c8e590c | |||
| b115db51e9 | |||
| 7d194c7078 |
1
.gitignore
vendored
1
.gitignore
vendored
@ -7,5 +7,6 @@ local.properties
|
||||
captures/
|
||||
build/
|
||||
release-app/
|
||||
test-app/
|
||||
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.ghzs.com:android/common-library.git
|
||||
url = git@git.ghzs.com:android/common-library.git
|
||||
branch = master
|
||||
|
||||
93
README.md
93
README.md
@ -1,69 +1,68 @@
|
||||
# 光环助手Android客户端
|
||||
|
||||
### APK打包配置
|
||||
### 概述
|
||||
|
||||
* 使用[ApkChannelPackage](https://github.com/ltlovezh/ApkChannelPackage)的方案
|
||||
* 打包命令,视情况使用:
|
||||
光环助手Android客户端目前使用 Kotlin 作为主要开发语言,以 MVVM 作为参考架构模式进行开发
|
||||
|
||||
> 打包Tinker基准包:`./scripts/tinker_release_base.sh`
|
||||
### 约束
|
||||
|
||||
> 以Tinker基准包打渠道包:`./scripts/tinker_release_channel.sh`
|
||||
为编写易读易维护且较健壮的代码,可参考以下约束
|
||||
|
||||
> 以Tinker基准包打补丁包:`./scripts/tinker_release_patch.sh`
|
||||
1. 尽量将逻辑代码放置于 ViewModel 中,View 中只执行 UI 操作
|
||||
2. 尽量使 View 在被销毁之后仍能恢复状态,处理方式可参考 [保存界面状态](https://developer.android.com/topic/libraries/architecture/saving-states)
|
||||
3. 尽量参考原有文件结构及命名规范,即以 大模块 - 小模块 的形式生成包关系
|
||||
4. 遵循最小改动原则,在提交代码前务必先检查变动的代码,尽量以可控的变动规模来构成一个 commit ,以便日后追踪问题
|
||||
5. 代码规范可参考 [AOSP Java 风格](https://source.android.com/setup/contribute/code-style)
|
||||
6. 尽量使用 Kotlin 来写新文件
|
||||
7. RecyclerView 的 ViewHolder 尽量使用 DataBinding 来减少代码以及提高可读性
|
||||
8. Commit 前请确保不带入非项目必须文件,可手动修改 [.gitignore](https://stackoverflow.com/questions/8527597/how-do-i-ignore-files-in-a-directory-in-git) 文件忽略
|
||||
9. 新页面请勿使用 ButterKnife 来进行 View 获取和绑定,请使用 ViewBinding
|
||||
10. No AsyncTask!
|
||||
|
||||
### 混淆配置
|
||||
### 公用部分
|
||||
|
||||
* 配置文件:Android默认配置+proguard-rules.txt等
|
||||
* 参考libraries下每个项目独立的配置文件`proguard-project.txt`
|
||||
本项目使用 LiveData 实现了一个简单通用的基础列表分页功能,具体可见 `ListFragment`, `ListViewModel` 等类,理想情况下只需少量代码即可新建一个简单分页列表
|
||||
|
||||
### apk大小优化
|
||||
### 首次拉取项目代码
|
||||
|
||||
* 限制resConfig资源集
|
||||
* 开启ShrinkResources
|
||||
* 开启混淆,使用minifyEnabled(仅在release开启)
|
||||
* pngquant对png压缩、png/jpg->webp(未尝试)
|
||||
`git clone -b dev git@git.ghzs.com:halo/android/assistant-android.git --recursive`
|
||||
|
||||
### git 版本管理
|
||||
|
||||
本项目使用简化版的 git flow 来管理分支,细节请看 [光环安卓简单 git 规范](https://git.ghzs.com/halo/android/assistant-android/-/wikis/%E5%85%89%E7%8E%AF%E5%AE%89%E5%8D%93%E7%AE%80%E5%8D%95-git-%E8%A7%84%E8%8C%83)
|
||||
|
||||
### API 环境配置
|
||||
|
||||
本项目使用 Build Variants 来切换 API 环境
|
||||
|
||||
* internal 为测试环境
|
||||
* publish 为正式环境
|
||||
|
||||
### 图片资源配置
|
||||
|
||||
* 新增图片资源时,默认只添加最高规格的 xxxhdpi 文件
|
||||
* 新增图片资源时,需要将其转换为 .webp 格式 (包括含透明图层的图片,默认质量为90%) (转换后体积变大的文件除外)
|
||||
|
||||
### 第三方appkey等配置
|
||||
|
||||
* 修改`gradle.properties`文件将各种key填入其中,实现统一管理
|
||||
* 通过gradle文件内的resValue/buildConfigField/manifestPlaceHolder方式实现编译期间修改,具体情况请参考``./build.gradle``和``./app/build.gradle``配置
|
||||
|
||||
### 拉取代码步骤
|
||||
### 混淆配置
|
||||
|
||||
1. 拉取主项目代码: `git clone -b dev git@gitlab.ghzhushou.com:halo/assistant-android.git`
|
||||
2. 初始化公用类库: `bash ./scripts/submodules_init.sh`
|
||||
* 本项目使用了微信的 [AndResGuard](https://github.com/shwenzhang/AndResGuard) 作为资源混淆压缩方案,新增需要使用 `getIdentifier` 获取的资源文件时需要添加至白名单
|
||||
* 本项目默认使用 R8 作为混淆工具,往 proguard-rules.txt 添加 proguard 新配置项时请检查可用性(如语法等)
|
||||
|
||||
### submodule管理方式(只拉取master)
|
||||
### APK打包配置
|
||||
|
||||
* 提交代码,需要cd到submodule文件夹去做修改
|
||||
* 更新远端代码,`bash ./scripts/submodules_update.sh`
|
||||
* 本项目使用了 [VasDolly](https://github.com/Tencent/VasDolly) 作为渠道包实现方案
|
||||
* 打包命令,具体参数请见相应文件:
|
||||
|
||||
> 打内部测试包:`./scripts/test_build.sh`
|
||||
> 打正式发布包:`./scripts/build_with_simple_backup.sh`
|
||||
|
||||
### TODO
|
||||
|
||||
* GSON 序列化用统一的一个, GsonUtil fromJson
|
||||
* CleanApkAdapter 转化字符串size工具函数 比如SpeedUtils
|
||||
* getString 解决 字符串hardcode问题
|
||||
* ~~Adapter 里面clicklistener 用接口传参将点击操作委托给controller~~
|
||||
* ~~Adapter ViewHolder的功能,部分重写到ViewHolder类本身~~
|
||||
|
||||
* ~~activity 统一入口未完成(外部入口相关),去除多余activity使用,统一toolbar~~
|
||||
* ~~release / debug compile不同的类库,不需要再做什么开关~~
|
||||
|
||||
* ~~Toolbar分离,有图形按钮/没有图形按钮~~
|
||||
|
||||
### TODO Since 3.1
|
||||
|
||||
- 解决 Utils 工具类引发的内存泄漏问题
|
||||
- 把原有 EventBus 的消息 Type 统一到一个文件内
|
||||
- 将实现细节从 View(Fragment、Activity) 剥离并以 MVVM 结构改造
|
||||
- ~~将 ListViewModel 所对应的 ListRepository 合并到 ListViewModel 中~~
|
||||
- 依照光环助手界面功能以大模块 - 小模块的方式去修改包结构,包内文件建议以包名摘要作为前缀
|
||||
- ~~使用 RxJava 的 Debounce 和 Map 操作优化搜索触发机制 参考资料:[1](https://proandroiddev.com/building-an-autocompleting-edittext-using-rxjava-f69c5c3f5a40),[2](https://medium.com/@kurtisnusbaum/rxandroid-basics-part-2-6e877af352)~~
|
||||
|
||||
- ~~把 ListViewModel 的数据结构类型转换方式换为抽象方法,让继承的类实现,避免出现无响应的问题~~
|
||||
|
||||
- ~~rxjava2 如果接口返回为空 会发生异常:java.lang.NullPointerException: Null is not a valid element (答案编辑) 解决方法->com.gh.gamecenter.retrofit.Response~~
|
||||
- constraintLayout 1.1.2 导致布局出现异常(问题编辑标签选择弹窗)
|
||||
|
||||
- 搞清楚 GameManager 的用途,看能不能去掉
|
||||
- 重构一下 MainActivity
|
||||
* 把原有 EventBus 的消息 Type 统一到一个文件内
|
||||
* 将实现细节从 View(Fragment、Activity) 剥离并以 MVVM 结构改造
|
||||
* 重构 MainActivity
|
||||
210
app/build.gradle
210
app/build.gradle
@ -2,26 +2,20 @@ apply plugin: 'com.android.application'
|
||||
apply plugin: 'kotlin-android' // kotlin
|
||||
apply plugin: 'kotlin-android-extensions'
|
||||
apply plugin: 'kotlin-kapt'
|
||||
|
||||
// apkChannelPackage
|
||||
apply plugin: 'channel'
|
||||
//apply plugin: 'io.sentry.android.gradle'
|
||||
apply plugin: 'AndResGuard'
|
||||
|
||||
import groovy.xml.XmlUtil
|
||||
|
||||
//apply from: 'tinker-support.gradle'
|
||||
|
||||
android {
|
||||
|
||||
androidExtensions {
|
||||
experimental = true
|
||||
}
|
||||
|
||||
dataBinding {
|
||||
enabled = true
|
||||
}
|
||||
|
||||
viewBinding {
|
||||
enabled = true
|
||||
buildFeatures {
|
||||
viewBinding = true
|
||||
dataBinding = true
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
@ -38,6 +32,10 @@ android {
|
||||
javaMaxHeapSize "4g"
|
||||
}
|
||||
|
||||
aaptOptions {
|
||||
additionalParameters "--no-version-vectors"
|
||||
}
|
||||
|
||||
defaultConfig {
|
||||
|
||||
multiDexEnabled true
|
||||
@ -48,7 +46,9 @@ android {
|
||||
}
|
||||
|
||||
ndk {
|
||||
abiFilters "armeabi-v7a"
|
||||
// 如果不添加 `arm64` 调用系统的 PackageManager 的方法读取安装包信息的时候会出现 native 层闪退,草
|
||||
// 微博 SDK 没有 64位的 SO,添加了 arm64 又会无法使用微博登录,下个版本更新微博 SDK 刻不容缓了!
|
||||
abiFilters "armeabi-v7a", "x86"
|
||||
}
|
||||
|
||||
renderscriptTargetApi 18
|
||||
@ -78,6 +78,8 @@ android {
|
||||
buildConfigField "String", "TTAD_APPID", "\"${TTAD_APPID}\""
|
||||
buildConfigField "String", "DOUYIN_CLIENTKEY", "\"${DOUYIN_CLIENTKEY}\""
|
||||
buildConfigField "String", "DOUYIN_CLIENTSECRET", "\"${DOUYIN_CLIENTSECRET}\""
|
||||
buildConfigField "String", "QUICK_LOGIN_APPID", "\"${QUICK_LOGIN_APPID}\""
|
||||
buildConfigField "String", "QUICK_LOGIN_APPKEY", "\"${QUICK_LOGIN_APPKEY}\""
|
||||
|
||||
buildConfigField "String", "MIPUSH_APPID", "\"${MIPUSH_APPID}\""
|
||||
buildConfigField "String", "MIPUSH_APPKEY", "\"${MIPUSH_APPKEY}\""
|
||||
@ -184,6 +186,8 @@ android {
|
||||
buildConfigField "String", "UMENG_APPKEY", "\"${UMENG_APPKEY}\""
|
||||
buildConfigField "String", "UMENG_MESSAGE_SECRET", "\"${UMENG_MESSAGE_SECRET}\""
|
||||
buildConfigField "String", "BUGLY_APPID", "\"${BUGLY_APPID}\""
|
||||
|
||||
manifestPlaceholders.put("APPLOG_SCHEME", "rangersapplog.byAx6uYt".toLowerCase())
|
||||
}
|
||||
|
||||
gdt {
|
||||
@ -200,23 +204,6 @@ android {
|
||||
}
|
||||
}
|
||||
|
||||
// apkChannelPackage
|
||||
channel {
|
||||
//多渠道包的输出目录,默认为new File(project.buildDir,"channel")
|
||||
baseOutputDir = new File(project.buildDir, "channel")
|
||||
//多渠道包的命名规则,默认为:${appName}-${versionName}-${versionCode}-${flavorName}-${buildType}
|
||||
apkNameFormat = '${appName}-${versionName}-${versionCode}-${flavorName}-${buildType}'
|
||||
}
|
||||
|
||||
rebuildChannel {
|
||||
// baseDebugApk = 已有Debug APK
|
||||
// baseReleaseApk = 已有Release APK
|
||||
// //默认为new File(project.buildDir, "rebuildChannel/debug")
|
||||
// debugOutputDir = Debug渠道包输出目录
|
||||
// //默认为new File(project.buildDir, "rebuildChannel/release")
|
||||
// releaseOutputDir = Release渠道包输出目录
|
||||
}
|
||||
|
||||
repositories {
|
||||
flatDir {
|
||||
dirs 'libs', 'libs/aars'
|
||||
@ -231,14 +218,12 @@ dependencies {
|
||||
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}"
|
||||
debugImplementation "com.gu.android:toolargetool:${toolargetool}"
|
||||
debugImplementation "com.github.nichbar:WhatTheStack:$whatTheStack"
|
||||
debugImplementation "com.github.nichbar:WhatTheStack:${whatTheStack}"
|
||||
|
||||
implementation "androidx.core:core:${core}"
|
||||
implementation "androidx.fragment:fragment:${fragment}"
|
||||
implementation "androidx.core:core-ktx:${core}"
|
||||
implementation "androidx.fragment:fragment-ktx:${fragment}"
|
||||
implementation "androidx.multidex:multidex:${multiDex}"
|
||||
implementation "androidx.appcompat:appcompat:${appCompat}"
|
||||
implementation "androidx.cardview:cardview:${cardView}"
|
||||
@ -259,8 +244,10 @@ dependencies {
|
||||
implementation "com.kyleduo.switchbutton:library:${switchButton}"
|
||||
|
||||
implementation "com.facebook.fresco:fresco:${fresco}"
|
||||
implementation "com.facebook.fresco:animated-gif:${fresco}"
|
||||
implementation "com.facebook.fresco:animated-gif-lite:${fresco}"
|
||||
implementation "com.facebook.fresco:animated-drawable:${fresco}"
|
||||
implementation "com.facebook.fresco:animated-webp:${fresco}"
|
||||
implementation "com.facebook.fresco:webpsupport:${fresco}"
|
||||
|
||||
implementation "com.squareup.okhttp3:okhttp:${okHttp}"
|
||||
|
||||
@ -289,8 +276,6 @@ dependencies {
|
||||
|
||||
implementation "com.daimajia.swipelayout:library:${swipeLayout}"
|
||||
|
||||
implementation "com.sina.weibo.sdk:core:${weiboSDK}"
|
||||
|
||||
// bugly with tinker support
|
||||
// implementation "com.tencent.bugly:crashreport_upgrade:${buglyTinkerSupport}"
|
||||
|
||||
@ -313,11 +298,11 @@ dependencies {
|
||||
implementation "com.squareup.picasso:picasso:${picasso}"
|
||||
|
||||
// for video streaming
|
||||
implementation("com.shuyu:gsyVideoPlayer-java:$gsyVideo", {
|
||||
implementation("com.github.CarGuo.GSYVideoPlayer:gsyVideoPlayer-java:$gsyVideo", {
|
||||
exclude module: "gsyvideoplayer-androidvideocache"
|
||||
exclude group: "tv.danmaku.ijk.media"
|
||||
})
|
||||
implementation "com.shuyu:GSYVideoPlayer-exo2:$gsyVideo"
|
||||
implementation "com.github.CarGuo.GSYVideoPlayer:gsyVideoPlayer-exo_player2:$gsyVideo"
|
||||
|
||||
implementation "android.arch.work:work-runtime:${workManager}"
|
||||
|
||||
@ -328,29 +313,39 @@ dependencies {
|
||||
implementation "com.ethanhua:skeleton:${skeleton}"
|
||||
implementation "io.supercharge:shimmerlayout:${shimmerlayout}"
|
||||
implementation "com.tencent.mm.opensdk:wechat-sdk-android-without-mta:${mta}"
|
||||
implementation "com.walkud.rom.checker:RomChecker:${romChecker}"
|
||||
implementation "com.github.nichbar:AndroidRomChecker:${romChecker}"
|
||||
|
||||
debugImplementation "com.github.nichbar.chucker:library:$chucker"
|
||||
releaseImplementation "com.github.nichbar.chucker:library-no-op:$chucker"
|
||||
teaImplementation "com.bytedance.applog:RangersAppLog-Lite-cn:$bytedanceApplog"
|
||||
debugImplementation "com.github.nichbar.chucker:library:${chucker}"
|
||||
releaseImplementation "com.github.nichbar.chucker:library-no-op:${chucker}"
|
||||
teaImplementation "com.bytedance.applog:RangersAppLog-Lite-cn:${bytedanceApplog}"
|
||||
// implementation "com.bytedance.ies.ugc.aweme:opensdk-china-external:$bytedanceAweme"
|
||||
// implementation "com.bytedance.ies.ugc.aweme:opensdk-common:$bytedanceAweme"
|
||||
|
||||
implementation "com.aliyun.dpa:oss-android-sdk:${oss}"
|
||||
|
||||
implementation "com.airbnb.android:lottie:$lottie"
|
||||
implementation "com.airbnb.android:lottie:${lottie}"
|
||||
|
||||
implementation "net.lingala.zip4j:zip4j:${zip4j}"
|
||||
|
||||
implementation "io.sentry:sentry-android:$sentry"
|
||||
// plugin 需要字符串,故不能用值
|
||||
implementation "io.sentry:sentry-android:3.2.0"
|
||||
|
||||
implementation("com.github.piasy:BigImageViewer:$bigImageViewer", {
|
||||
implementation("com.github.piasy:BigImageViewer:${bigImageViewer}", {
|
||||
exclude group: 'com.squareup.okhttp3'
|
||||
exclude group: 'androidx.swiperefreshlayout'
|
||||
exclude group: 'com.github.bumptech.glide'
|
||||
exclude group: 'com.facebook.fresco'
|
||||
})
|
||||
implementation "com.github.PhilJay:MPAndroidChart:${chart}"
|
||||
|
||||
implementation "com.github.hsiafan:apk-parser:${apkParser}"
|
||||
implementation "org.nanohttpd:nanohttpd:${nanohttpd}"
|
||||
|
||||
implementation "com.aliyun.openservices:aliyun-log-android-sdk:${aliyunLog}"
|
||||
implementation "com.github.princekin-f:EasyFloat:${easyFloat}"
|
||||
|
||||
implementation "io.github.florent37:shapeofview:$shapeOfView"
|
||||
|
||||
implementation project(':libraries:LGLibrary')
|
||||
// implementation project(':libraries:MTA')
|
||||
implementation project(':libraries:QQShare')
|
||||
@ -417,6 +412,77 @@ if (propFile.exists()) {
|
||||
// }.each { t -> t.dependsOn generateMetaJson }
|
||||
//}
|
||||
|
||||
andResGuard {
|
||||
mappingFile = null
|
||||
use7zip = true
|
||||
useSign = true
|
||||
// 打开这个开关,会keep住所有资源的原始路径,只混淆资源的名字
|
||||
keepRoot = false
|
||||
// 设置这个值,会把arsc name列混淆成相同的名字,减少string常量池的大小
|
||||
fixedResName = "arg"
|
||||
// 打开这个开关会合并所有哈希值相同的资源,但请不要过度依赖这个功能去除去冗余资源
|
||||
mergeDuplicatedRes = true
|
||||
whiteList = [
|
||||
"R.drawable.icon",
|
||||
"R.drawable.bg_notification_answer_style_1",
|
||||
"R.drawable.bg_notification_answer_style_2",
|
||||
"R.drawable.bg_notification_article_style_1",
|
||||
"R.drawable.bg_notification_article_style_2",
|
||||
"R.drawable.bg_notification_feedback_style_1",
|
||||
"R.drawable.bg_notification_feedback_style_2",
|
||||
"R.drawable.bg_notification_gift_style_1",
|
||||
"R.drawable.bg_notification_gift_style_2",
|
||||
"R.drawable.bg_notification_login_style_1",
|
||||
"R.drawable.bg_notification_login_style_2",
|
||||
"R.drawable.bg_notification_question_style_1",
|
||||
"R.drawable.bg_notification_question_style_2",
|
||||
"R.drawable.bg_notification_rating_style_1",
|
||||
"R.drawable.bg_notification_rating_style_2",
|
||||
"R.drawable.bg_notification_reserve_game_style_1",
|
||||
"R.drawable.bg_notification_reserve_game_style_2",
|
||||
"R.drawable.bg_notification_video_style_1",
|
||||
"R.drawable.bg_notification_video_style_2",
|
||||
"R.drawable.ic_search_no_1",
|
||||
"R.drawable.ic_search_no_2",
|
||||
"R.drawable.ic_search_no_3",
|
||||
"R.drawable.ic_search_no_4",
|
||||
"R.drawable.ic_search_no_5",
|
||||
"R.drawable.ic_search_no_6",
|
||||
"R.drawable.ic_search_no_7",
|
||||
"R.drawable.ic_search_no_8",
|
||||
"R.drawable.ic_search_no_9",
|
||||
"R.drawable.ic_search_no_10",
|
||||
"R.drawable.ic_search_no_11",
|
||||
"R.drawable.ic_search_no_12",
|
||||
"R.drawable.ic_search_no_13",
|
||||
"R.drawable.ic_search_no_14",
|
||||
"R.drawable.ic_search_no_15",
|
||||
"R.drawable.ic_search_no_16",
|
||||
"R.drawable.ic_search_no_17",
|
||||
"R.drawable.ic_search_no_18",
|
||||
"R.drawable.ic_search_no_19",
|
||||
"R.drawable.ic_search_no_20",
|
||||
"R.drawable.ic_recommend_activity",
|
||||
"R.drawable.ic_recommend_discount",
|
||||
"R.drawable.ic_recommend_function",
|
||||
"R.drawable.ic_recommend_gift",
|
||||
"R.drawable.ic_recommend_role",
|
||||
"R.drawable.login_btn_bg",
|
||||
"R.drawable.ic_quick_login_check",
|
||||
"R.drawable.ic_quick_login_uncheck",
|
||||
"R.anim.anim_auth_in",
|
||||
"R.anim.anim_auth_out",
|
||||
]
|
||||
compressFilePattern = [
|
||||
"*.png",
|
||||
"*.jpg",
|
||||
"*.jpeg",
|
||||
"*.gif",
|
||||
]
|
||||
sevenzip {
|
||||
artifact = 'com.tencent.mm:SevenZip:1.2.20'
|
||||
}
|
||||
}
|
||||
|
||||
project.afterEvaluate {
|
||||
def variants = null
|
||||
@ -448,36 +514,46 @@ project.afterEvaluate {
|
||||
if (manifestFile == null || !manifestFile.exists()) {
|
||||
return
|
||||
}
|
||||
|
||||
String[] configChanges = [
|
||||
"density",
|
||||
"fontScale",
|
||||
"keyboard",
|
||||
"keyboardHidden",
|
||||
"layoutDirection",
|
||||
"locale",
|
||||
"mcc",
|
||||
"mnc",
|
||||
"navigation",
|
||||
"orientation",
|
||||
"screenLayout",
|
||||
"screenSize",
|
||||
"smallestScreenSize",
|
||||
"touchscreen",
|
||||
"uiMode"]
|
||||
|
||||
def parser = new XmlSlurper(false, true)
|
||||
def manifest = parser.parse(manifestFile)
|
||||
def app = manifest.'application'[0]
|
||||
app.'activity'.each { act ->
|
||||
String value = act.attributes()['android:configChanges']
|
||||
if (value == null || value.isEmpty()) {
|
||||
value = "keyboardHidden|orientation|screenSize|screenLayout|density|fontScale|locale"
|
||||
if (value == null) value = ""
|
||||
configChanges.eachWithIndex { config, index ->
|
||||
if (index != configChanges.length - 1) {
|
||||
value += config + "|"
|
||||
} else {
|
||||
value += config
|
||||
}
|
||||
}
|
||||
act.attributes()['androidconfigChanges'] = value
|
||||
} else {
|
||||
String[] valueSplit = value.split("\\|")
|
||||
if (!valueSplit.contains("keyboardHidden")) {
|
||||
value += "|keyboardHidden"
|
||||
}
|
||||
if (!valueSplit.contains("orientation")) {
|
||||
value += "|orientation"
|
||||
}
|
||||
if (!valueSplit.contains("screenSize")) {
|
||||
value += "|screenSize"
|
||||
}
|
||||
if (!valueSplit.contains("screenLayout")) {
|
||||
value += "|screenLayout"
|
||||
}
|
||||
if (!valueSplit.contains("density")) {
|
||||
value += "|density"
|
||||
}
|
||||
if (!valueSplit.contains("fontScale")) {
|
||||
value += "|fontScale"
|
||||
}
|
||||
if (!valueSplit.contains("locale")) {
|
||||
value += "|locale"
|
||||
println configChanges
|
||||
configChanges.eachWithIndex { config, index ->
|
||||
if (!valueSplit.contains(config)) {
|
||||
value += ("|" + config)
|
||||
}
|
||||
}
|
||||
act.attributes()['android:configChanges'] = value
|
||||
}
|
||||
|
||||
Binary file not shown.
BIN
app/libs/quick_login_android_5.8.1.aar
Normal file
BIN
app/libs/quick_login_android_5.8.1.aar
Normal file
Binary file not shown.
BIN
app/libs/sina-weibo-2.0.3.aar
Normal file
BIN
app/libs/sina-weibo-2.0.3.aar
Normal file
Binary file not shown.
271
app/proguard-rules-legacy.txt
Normal file
271
app/proguard-rules-legacy.txt
Normal file
@ -0,0 +1,271 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# By default, the flags in this file are appended to flags specified
|
||||
# in C:\Android\sdk/tools/proguard/proguard-android.txt
|
||||
# You can edit the include path and order by changing the proguardFiles
|
||||
# directive in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# Add any project specific keep options here:
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
|
||||
#--------- remove logs start ----------------
|
||||
-assumenosideeffects class com.lightgame.config.CommonDebug {
|
||||
private static String getLogTag(...);
|
||||
private static String getMethodName();
|
||||
public static void logMethodName(...);
|
||||
public static void logParams(...);
|
||||
public static void logFields(...);
|
||||
public static void logMethodWithParams(...);
|
||||
}
|
||||
#-assumenosideeffects class com.lightgame.config.CommonDebug {*;}
|
||||
|
||||
#-dontoptimize
|
||||
#--------- remove logs end ----------------
|
||||
|
||||
-keepattributes *Annotation*,Signature,InnerClasses,EnclosingMethod
|
||||
-dontwarn InnerClasses
|
||||
|
||||
# OrmLite uses reflection
|
||||
-keep class com.j256.**
|
||||
-keepclassmembers class com.j256.** { *; }
|
||||
-keep enum com.j256.**
|
||||
-keepclassmembers enum com.j256.** { *; }
|
||||
-keep interface com.j256.**
|
||||
-keepclassmembers interface com.j256.** { *; }
|
||||
-dontwarn com.j256.**
|
||||
|
||||
#okhttp3
|
||||
-dontwarn com.squareup.okhttp3.**
|
||||
-dontwarn okio.**
|
||||
-keep class com.squareup.okhttp3.** { *;}
|
||||
|
||||
# stetho
|
||||
-keep class com.facebook.stetho.** { *; }
|
||||
-dontwarn com.facebook.stetho.**
|
||||
|
||||
# Retrofit 2.2
|
||||
# Platform calls Class.forName on types which do not exist on Android to determine platform.
|
||||
-dontnote retrofit2.Platform
|
||||
# Platform used when running on Java 8 VMs. Will not be used at runtime.
|
||||
-dontwarn retrofit2.Platform$Java8
|
||||
# Retain generic type information for use by reflection by converters and adapters.
|
||||
-keepattributes Signature
|
||||
# Retain declared checked exceptions for use by a Proxy instance.
|
||||
-keepattributes Exceptions
|
||||
|
||||
# Retrofit 2.X
|
||||
## https://square.github.io/retrofit/ ##
|
||||
|
||||
-dontwarn retrofit2.**
|
||||
-keep class retrofit2.** { *; }
|
||||
-keepattributes Signature
|
||||
-keepattributes Exceptions
|
||||
|
||||
-keepclasseswithmembers class * {
|
||||
@retrofit2.http.* <methods>;
|
||||
}
|
||||
|
||||
|
||||
# rxjava
|
||||
-keep class rx.schedulers.Schedulers {
|
||||
public static <methods>;
|
||||
}
|
||||
-keep class rx.schedulers.ImmediateScheduler {
|
||||
public <methods>;
|
||||
}
|
||||
-keep class rx.schedulers.TestScheduler {
|
||||
public <methods>;
|
||||
}
|
||||
-keep class rx.schedulers.Schedulers {
|
||||
public static ** test();
|
||||
}
|
||||
-keepclassmembers class rx.internal.util.unsafe.*ArrayQueue*Field* {
|
||||
long producerIndex;
|
||||
long consumerIndex;
|
||||
}
|
||||
-keepclassmembers class rx.internal.util.unsafe.BaseLinkedQueueProducerNodeRef {
|
||||
long producerNode;
|
||||
long consumerNode;
|
||||
}
|
||||
-dontwarn rx.internal.util.**
|
||||
|
||||
## AutoScrollViewPager
|
||||
-keep class cn.trinea.android.** { *; }
|
||||
-keepclassmembers class cn.trinea.android.** { *; }
|
||||
-dontwarn cn.trinea.android.**
|
||||
|
||||
## butterknife
|
||||
# Retain generated class which implement Unbinder.
|
||||
#-keep public class * implements butterknife.Unbinder { public <init>(**, android.view.View); }
|
||||
#
|
||||
## Prevent obfuscation of types which use ButterKnife annotations since the simple name
|
||||
## is used to reflectively look up the generated ViewBinding.
|
||||
#-keep class butterknife.*
|
||||
#-keepclasseswithmembernames class * { @butterknife.* <methods>; }
|
||||
#-keepclasseswithmembernames class * { @butterknife.* <fields>; }
|
||||
|
||||
-dontwarn butterknife.internal.**
|
||||
-keep class **$$ViewInjector { *; }
|
||||
-keepnames class * { @butterknife.InjectView *;}
|
||||
-dontwarn butterknife.Views$InjectViewProcessor
|
||||
-dontwarn com.gc.materialdesign.views.**
|
||||
|
||||
# eventbus
|
||||
-keepattributes *Annotation*
|
||||
-keepclassmembers class ** {
|
||||
@org.greenrobot.eventbus.Subscribe <methods>;
|
||||
}
|
||||
-keep enum org.greenrobot.eventbus.ThreadMode { *; }
|
||||
|
||||
# Only required if you use AsyncExecutor
|
||||
-keepclassmembers class * extends org.greenrobot.eventbus.util.ThrowableFailureEvent {
|
||||
<init>(java.lang.Throwable);
|
||||
}
|
||||
|
||||
# weiboSdk
|
||||
-keep class com.sina.weibo.sdk.** { *; }
|
||||
-dontwarn android.webkit.WebView
|
||||
-dontwarn android.webkit.WebViewClient
|
||||
|
||||
# app models
|
||||
-keep class com.gh.common.view.** {*;}
|
||||
-keep class com.gh.gamecenter.db.info.** {*;}
|
||||
-keep class com.gh.gamecenter.entity.** {*;}
|
||||
-keep class com.gh.gamecenter.qa.entity.** {*;}
|
||||
-keep class com.gh.gamecenter.retrofit.** {*;}
|
||||
-keep class com.gh.gamecenter.eventbus.** {*;}
|
||||
-keep class com.gh.gamecenter.video.detail.** {*;}
|
||||
-keep class * extends rx.Subscriber
|
||||
|
||||
#---------------------------------webview------------------------------------
|
||||
-keepclassmembers class * extends android.webkit.WebViewClient {
|
||||
public void *(android.webkit.WebView, java.lang.String, android.graphics.Bitmap);
|
||||
public boolean *(android.webkit.WebView, java.lang.String);
|
||||
}
|
||||
-keepclassmembers class * extends android.webkit.WebViewClient {
|
||||
public void *(android.webkit.WebView, java.lang.String);
|
||||
}
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
|
||||
##---------------Begin: proguard configuration for Gson ----------
|
||||
# Gson uses generic type information stored in a class file when working with fields. Proguard
|
||||
# removes such information by default, so configure it to keep all of it.
|
||||
-keepattributes Signature
|
||||
|
||||
# For using GSON @Expose annotation
|
||||
-keepattributes *Annotation*
|
||||
|
||||
# Gson specific classes
|
||||
-keep class sun.misc.Unsafe { *; }
|
||||
#-keep class com.google.gson.stream.** { *; }
|
||||
|
||||
# Prevent proguard from stripping interface information from TypeAdapterFactory,
|
||||
# JsonSerializer, JsonDeserializer instances (so they can be used in @JsonAdapter)
|
||||
-keep class * implements com.google.gson.TypeAdapterFactory
|
||||
-keep class * implements com.google.gson.JsonSerializer
|
||||
-keep class * implements com.google.gson.JsonDeserializer
|
||||
|
||||
-keepclassmembers enum * { *; }
|
||||
|
||||
##---------------End: proguard configuration for Gson ----------
|
||||
|
||||
# ------ bugly ---------
|
||||
-dontwarn com.tencent.bugly.**
|
||||
-keep public class com.tencent.bugly.**{*;}
|
||||
|
||||
# easypermission
|
||||
-keepclassmembers class * {
|
||||
@pub.devrel.easypermissions.AfterPermissionGranted <methods>;
|
||||
}
|
||||
|
||||
# 重命名文件为SourceFile,再配合mapping符号表,可以拿到真实的类名
|
||||
-renamesourcefileattribute SourceFile
|
||||
# 保留源文件行号
|
||||
-keepattributes SourceFile,LineNumberTable
|
||||
|
||||
-ignorewarnings
|
||||
|
||||
-keep @androidx.annotation.Keep class *
|
||||
-keepclassmembers class ** {
|
||||
@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 { *; }
|
||||
|
||||
#阿里云上传
|
||||
-keep class com.alibaba.sdk.android.oss.** { *; }
|
||||
-dontwarn okio.**
|
||||
-dontwarn org.apache.commons.codec.binary.**
|
||||
|
||||
#视频相关
|
||||
-keep class com.shuyu.gsyvideoplayer.video.** { *; }
|
||||
-dontwarn com.shuyu.gsyvideoplayer.video.**
|
||||
-keep class com.shuyu.gsyvideoplayer.video.base.** { *; }
|
||||
-dontwarn com.shuyu.gsyvideoplayer.video.base.**
|
||||
-keep class com.shuyu.gsyvideoplayer.utils.** { *; }
|
||||
-dontwarn com.shuyu.gsyvideoplayer.utils.**
|
||||
-keep class tv.danmaku.ijk.** { *; }
|
||||
-dontwarn tv.danmaku.ijk.**
|
||||
-keep public class * extends android.view.View{
|
||||
*** get*();
|
||||
void set*(***);
|
||||
public <init>(android.content.Context);
|
||||
public <init>(android.content.Context, android.util.AttributeSet);
|
||||
public <init>(android.content.Context, android.util.AttributeSet, int);
|
||||
}
|
||||
|
||||
#穿山甲
|
||||
-keep class com.bytedance.sdk.openadsdk.** { *; }
|
||||
-keep public interface com.bytedance.sdk.openadsdk.downloadnew.** {*;}
|
||||
-keep class com.pgl.sys.ces.* {*;}
|
||||
|
||||
-keep class com.gyf.immersionbar.* {*;}
|
||||
-dontwarn com.gyf.immersionbar.**
|
||||
|
||||
-keep class com.taobao.securityjni.**{*;}
|
||||
-keep class com.taobao.wireless.security.**{*;}
|
||||
-keep class com.ut.secbody.**{*;}
|
||||
-keep class com.taobao.dp.**{*;}
|
||||
-keep class com.alibaba.wireless.security.**{*;}
|
||||
|
||||
-keep class com.alibaba.sdk.android.**{*;}
|
||||
-keep class com.ut.**{*;}
|
||||
-keep class com.ta.**{*;}
|
||||
|
||||
-keep class com.gh.gamecenter.GdtHelper { *; }
|
||||
-keep class com.gh.gamecenter.TeaHelper { *; }
|
||||
@ -1,20 +1,3 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# By default, the flags in this file are appended to flags specified
|
||||
# in C:\Android\sdk/tools/proguard/proguard-android.txt
|
||||
# You can edit the include path and order by changing the proguardFiles
|
||||
# directive in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# Add any project specific keep options here:
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
|
||||
#--------- remove logs start ----------------
|
||||
-assumenosideeffects class com.lightgame.config.CommonDebug {
|
||||
@ -26,126 +9,66 @@
|
||||
public static void logMethodWithParams(...);
|
||||
}
|
||||
|
||||
#-assumenosideeffects class com.lightgame.config.CommonDebug {*;}
|
||||
|
||||
#-dontoptimize
|
||||
-assumenosideeffects class com.lightgame.utils.Utils {
|
||||
public static void log(...);
|
||||
}
|
||||
#--------- remove logs end ----------------
|
||||
|
||||
-keepattributes *Annotation*,Signature,InnerClasses,EnclosingMethod
|
||||
-dontwarn InnerClasses
|
||||
# TODO Dicard sourceFile in final release build but remain in internal build.
|
||||
-renamesourcefileattribute SourceFile
|
||||
# Keep Attribute
|
||||
-keepattributes *Annotation*,Signature,InnerClasses,EnclosingMethod,SourceFile,LineNumberTable
|
||||
|
||||
# OrmLite uses reflection
|
||||
-keep class com.j256.**
|
||||
-keepclassmembers class com.j256.** { *; }
|
||||
-keep enum com.j256.**
|
||||
-keepclassmembers enum com.j256.** { *; }
|
||||
-keep interface com.j256.**
|
||||
-keepclassmembers interface com.j256.** { *; }
|
||||
# OrmLite
|
||||
-keep class com.j256.*
|
||||
-keepclassmembers class com.j256.* { *; }
|
||||
-keep enum com.j256.*
|
||||
-keepclassmembers enum com.j256.* { *; }
|
||||
-keep interface com.j256.*
|
||||
-keepclassmembers interface com.j256.* { *; }
|
||||
-dontwarn com.j256.**
|
||||
|
||||
#okhttp3
|
||||
-dontwarn com.squareup.okhttp3.**
|
||||
-dontwarn okio.**
|
||||
-keep class com.squareup.okhttp3.** { *;}
|
||||
|
||||
# stetho
|
||||
-keep class com.facebook.stetho.** { *; }
|
||||
-dontwarn com.facebook.stetho.**
|
||||
|
||||
# Retrofit 2.2
|
||||
# Platform calls Class.forName on types which do not exist on Android to determine platform.
|
||||
-dontnote retrofit2.Platform
|
||||
# Platform used when running on Java 8 VMs. Will not be used at runtime.
|
||||
-dontwarn retrofit2.Platform$Java8
|
||||
# Retain generic type information for use by reflection by converters and adapters.
|
||||
-keepattributes Signature
|
||||
# Retain declared checked exceptions for use by a Proxy instance.
|
||||
-keepattributes Exceptions
|
||||
|
||||
# Retrofit 2.X
|
||||
## https://square.github.io/retrofit/ ##
|
||||
|
||||
-dontwarn retrofit2.**
|
||||
-keep class retrofit2.** { *; }
|
||||
-keepattributes Signature
|
||||
-keepattributes Exceptions
|
||||
|
||||
-keepclasseswithmembers class * {
|
||||
@retrofit2.http.* <methods>;
|
||||
}
|
||||
|
||||
|
||||
# rxjava
|
||||
-keep class rx.schedulers.Schedulers {
|
||||
public static <methods>;
|
||||
}
|
||||
-keep class rx.schedulers.ImmediateScheduler {
|
||||
public <methods>;
|
||||
}
|
||||
-keep class rx.schedulers.TestScheduler {
|
||||
public <methods>;
|
||||
}
|
||||
-keep class rx.schedulers.Schedulers {
|
||||
public static ** test();
|
||||
}
|
||||
-keepclassmembers class rx.internal.util.unsafe.*ArrayQueue*Field* {
|
||||
long producerIndex;
|
||||
long consumerIndex;
|
||||
}
|
||||
-keepclassmembers class rx.internal.util.unsafe.BaseLinkedQueueProducerNodeRef {
|
||||
long producerNode;
|
||||
long consumerNode;
|
||||
}
|
||||
-dontwarn rx.internal.util.**
|
||||
|
||||
## AutoScrollViewPager
|
||||
-keep class cn.trinea.android.** { *; }
|
||||
-keepclassmembers class cn.trinea.android.** { *; }
|
||||
### AutoScrollViewPager
|
||||
-keep class cn.trinea.android.* { *; }
|
||||
-keepclassmembers class cn.trinea.android.* { *; }
|
||||
-dontwarn cn.trinea.android.**
|
||||
|
||||
## butterknife
|
||||
# Retain generated class which implement Unbinder.
|
||||
#-keep public class * implements butterknife.Unbinder { public <init>(**, android.view.View); }
|
||||
#
|
||||
## Prevent obfuscation of types which use ButterKnife annotations since the simple name
|
||||
## is used to reflectively look up the generated ViewBinding.
|
||||
#-keep class butterknife.*
|
||||
#-keepclasseswithmembernames class * { @butterknife.* <methods>; }
|
||||
#-keepclasseswithmembernames class * { @butterknife.* <fields>; }
|
||||
### Butterknife
|
||||
-keep public class * implements butterknife.Unbinder { public <init>(**, android.view.View); }
|
||||
-keep class butterknife.*
|
||||
-keepclasseswithmembernames class * { @butterknife.* <methods>; }
|
||||
-keepclasseswithmembernames class * { @butterknife.* <fields>; }
|
||||
|
||||
-dontwarn butterknife.internal.**
|
||||
-keep class **$$ViewInjector { *; }
|
||||
-keepnames class * { @butterknife.InjectView *;}
|
||||
-dontwarn butterknife.Views$InjectViewProcessor
|
||||
-dontwarn com.gc.materialdesign.views.**
|
||||
|
||||
# eventbus
|
||||
-keepattributes *Annotation*
|
||||
-keepclassmembers class ** {
|
||||
### eventbus
|
||||
-keepclassmembers class * {
|
||||
@org.greenrobot.eventbus.Subscribe <methods>;
|
||||
}
|
||||
-keep enum org.greenrobot.eventbus.ThreadMode { *; }
|
||||
|
||||
# Only required if you use AsyncExecutor
|
||||
### Only required if you use AsyncExecutor
|
||||
-keepclassmembers class * extends org.greenrobot.eventbus.util.ThrowableFailureEvent {
|
||||
<init>(java.lang.Throwable);
|
||||
}
|
||||
|
||||
# weiboSdk
|
||||
-keep class com.sina.weibo.sdk.** { *; }
|
||||
### weiboSdk
|
||||
-keep class com.sina.weibo.sdk.* { *; }
|
||||
-dontwarn android.webkit.WebView
|
||||
-dontwarn android.webkit.WebViewClient
|
||||
|
||||
# app models
|
||||
-keep class com.gh.common.view.** {*;}
|
||||
-keep class com.gh.gamecenter.db.info.** {*;}
|
||||
-keep class com.gh.gamecenter.entity.** {*;}
|
||||
-keep class com.gh.gamecenter.qa.entity.** {*;}
|
||||
-keep class com.gh.gamecenter.retrofit.** {*;}
|
||||
-keep class com.gh.gamecenter.eventbus.** {*;}
|
||||
-keep class * extends rx.Subscriber
|
||||
### wechatSdk
|
||||
### TODO 这里用 com.tencent.*{*;} 不起效?但其它地方可以?
|
||||
-keep class com.tencent.**{*;}
|
||||
|
||||
#---------------------------------webview------------------------------------
|
||||
### app models
|
||||
-keep class com.gh.common.view.* {*;}
|
||||
-keep class com.gh.gamecenter.db.info.* {*;}
|
||||
-keep class com.gh.gamecenter.entity.* {*;}
|
||||
-keep class com.gh.gamecenter.qa.entity.* {*;}
|
||||
-keep class com.gh.gamecenter.retrofit.* {*;}
|
||||
-keep class com.gh.gamecenter.eventbus.* {*;}
|
||||
-keep class com.gh.gamecenter.video.detail.* {*;}
|
||||
|
||||
###
|
||||
-keepclassmembers class * extends android.webkit.WebViewClient {
|
||||
public void *(android.webkit.WebView, java.lang.String, android.graphics.Bitmap);
|
||||
public boolean *(android.webkit.WebView, java.lang.String);
|
||||
@ -153,93 +76,38 @@
|
||||
-keepclassmembers class * extends android.webkit.WebViewClient {
|
||||
public void *(android.webkit.WebView, java.lang.String);
|
||||
}
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
|
||||
##---------------Begin: proguard configuration for Gson ----------
|
||||
# Gson uses generic type information stored in a class file when working with fields. Proguard
|
||||
# removes such information by default, so configure it to keep all of it.
|
||||
-keepattributes Signature
|
||||
|
||||
# For using GSON @Expose annotation
|
||||
-keepattributes *Annotation*
|
||||
|
||||
# Gson specific classes
|
||||
-keep class sun.misc.Unsafe { *; }
|
||||
#-keep class com.google.gson.stream.** { *; }
|
||||
|
||||
# Prevent proguard from stripping interface information from TypeAdapterFactory,
|
||||
# JsonSerializer, JsonDeserializer instances (so they can be used in @JsonAdapter)
|
||||
-keep class * implements com.google.gson.TypeAdapterFactory
|
||||
-keep class * implements com.google.gson.JsonSerializer
|
||||
-keep class * implements com.google.gson.JsonDeserializer
|
||||
|
||||
-keepclassmembers enum * { *; }
|
||||
|
||||
##---------------End: proguard configuration for Gson ----------
|
||||
|
||||
# ------ bugly ---------
|
||||
-dontwarn com.tencent.bugly.**
|
||||
-keep public class com.tencent.bugly.**{*;}
|
||||
|
||||
# easypermission
|
||||
### easypermission
|
||||
-keepclassmembers class * {
|
||||
@pub.devrel.easypermissions.AfterPermissionGranted <methods>;
|
||||
}
|
||||
|
||||
# 重命名文件为SourceFile,再配合mapping符号表,可以拿到真实的类名
|
||||
-renamesourcefileattribute SourceFile
|
||||
# 保留源文件行号
|
||||
-keepattributes SourceFile,LineNumberTable
|
||||
|
||||
# TODO What's this ?
|
||||
-ignorewarnings
|
||||
|
||||
### Keep Annotation
|
||||
-keep @androidx.annotation.Keep class *
|
||||
-keepclassmembers class ** {
|
||||
-keepclassmembers class * {
|
||||
@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.** {*;}
|
||||
-keep class com.qq.gdt.action.* {*;}
|
||||
|
||||
### AndroidX
|
||||
-keep class androidx.core.app.CoreComponentFactory { *; }
|
||||
|
||||
#阿里云上传
|
||||
-keep class com.alibaba.sdk.android.oss.** { *; }
|
||||
### 阿里云上传
|
||||
-keep class com.alibaba.sdk.android.oss.* { *; }
|
||||
-dontwarn okio.**
|
||||
-dontwarn org.apache.commons.codec.binary.**
|
||||
|
||||
#视频相关
|
||||
-keep class com.shuyu.gsyvideoplayer.video.** { *; }
|
||||
### 视频相关
|
||||
-keep class com.shuyu.gsyvideoplayer.video.* { *; }
|
||||
-dontwarn com.shuyu.gsyvideoplayer.video.**
|
||||
-keep class com.shuyu.gsyvideoplayer.video.base.** { *; }
|
||||
-keep class com.shuyu.gsyvideoplayer.video.base.* { *; }
|
||||
-dontwarn com.shuyu.gsyvideoplayer.video.base.**
|
||||
-keep class com.shuyu.gsyvideoplayer.utils.** { *; }
|
||||
-keep class com.shuyu.gsyvideoplayer.utils.* { *; }
|
||||
-dontwarn com.shuyu.gsyvideoplayer.utils.**
|
||||
-keep class tv.danmaku.ijk.** { *; }
|
||||
-keep class tv.danmaku.ijk.* { *; }
|
||||
-dontwarn tv.danmaku.ijk.**
|
||||
-keep public class * extends android.view.View{
|
||||
*** get*();
|
||||
@ -249,23 +117,26 @@
|
||||
public <init>(android.content.Context, android.util.AttributeSet, int);
|
||||
}
|
||||
|
||||
#穿山甲
|
||||
-keep class com.bytedance.sdk.openadsdk.** { *; }
|
||||
-keep public interface com.bytedance.sdk.openadsdk.downloadnew.** {*;}
|
||||
-keep class com.pgl.sys.ces.* {*;}
|
||||
|
||||
-keep class com.gyf.immersionbar.* {*;}
|
||||
-dontwarn com.gyf.immersionbar.**
|
||||
|
||||
-keep class com.taobao.securityjni.**{*;}
|
||||
-keep class com.taobao.wireless.security.**{*;}
|
||||
-keep class com.ut.secbody.**{*;}
|
||||
-keep class com.taobao.dp.**{*;}
|
||||
-keep class com.alibaba.wireless.security.**{*;}
|
||||
|
||||
-keep class com.alibaba.sdk.android.**{*;}
|
||||
-keep class com.ut.**{*;}
|
||||
-keep class com.ta.**{*;}
|
||||
-keep class com.alibaba.sdk.android.*{*;}
|
||||
-keep class com.ut.*{*;}
|
||||
-keep class com.ta.*{*;}
|
||||
|
||||
### GDT & TEA
|
||||
-keep class com.gh.gamecenter.GdtHelper { *; }
|
||||
-keep class com.gh.gamecenter.TeaHelper { *; }
|
||||
-keep class com.gh.gamecenter.TeaHelper { *; }
|
||||
|
||||
### 阿里云日志
|
||||
-keep class com.aliyun.sls.android.producer.* { *; }
|
||||
-keep interface com.aliyun.sls.android.producer.* { *; }
|
||||
|
||||
### 中国移动一键登录
|
||||
-dontwarn com.cmic.sso.sdk.**
|
||||
-keep class com.cmic.sso.sdk.* { *; }
|
||||
|
||||
### EasyFloat
|
||||
-keep class com.lzf.easyfloat.* {*;}
|
||||
|
||||
### 避免 WebChromeClient 被混淆
|
||||
-keepclassmembers class * extends android.webkit.WebChromeClient{
|
||||
public void openFileChooser(...);
|
||||
}
|
||||
@ -2,8 +2,6 @@ package com.gh.gamecenter;
|
||||
|
||||
import android.app.Application;
|
||||
|
||||
import com.facebook.stetho.Stetho;
|
||||
import com.facebook.stetho.okhttp3.StethoInterceptor;
|
||||
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.logging.HttpLoggingInterceptor;
|
||||
@ -17,9 +15,6 @@ import okhttp3.logging.HttpLoggingInterceptor;
|
||||
public class Injection {
|
||||
|
||||
public static boolean appInit(Application application) {
|
||||
// init stetho
|
||||
Stetho.initializeWithDefaults(application);
|
||||
|
||||
// 监控Bundle大小,预防溢出(需要调试的时候再开启吧!)
|
||||
// TooLargeTool.startLogging(application);
|
||||
return true;
|
||||
@ -30,7 +25,6 @@ public class Injection {
|
||||
HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
|
||||
interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
|
||||
builder.addNetworkInterceptor(interceptor);
|
||||
builder.addNetworkInterceptor(new StethoInterceptor());
|
||||
return builder;
|
||||
}
|
||||
|
||||
|
||||
@ -31,6 +31,8 @@ object GdtHelper {
|
||||
GDTAction.init(application, "1111012969", "9d3d9da5b0948a317c03d08f14d445dc")
|
||||
} else if (channel == "GH_729") {
|
||||
GDTAction.init(application, "1111013063", "f53dabf458a356b101d99fc4069eb7f1")
|
||||
} else if (channel == "GH_765") {
|
||||
GDTAction.init(application, "1111327925", "588d503f0990f98f9b2394fbb795c570")
|
||||
} else {
|
||||
GDTAction.init(application, "1110680399", "f5ddaafbf520d7d7385499232a408d0a")
|
||||
}
|
||||
|
||||
@ -21,23 +21,17 @@
|
||||
<uses-permission android:name="android.permission.VIBRATE" />
|
||||
<!-- 允许应用程序改变Wi-Fi连接状态 -->
|
||||
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
|
||||
<!-- 允许应用程序打开系统窗口,显示其他应用程序 -->
|
||||
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
|
||||
<!-- 创建快捷方式的权限 -->
|
||||
<!-- 允许应用程序改变网络连接状态 -->
|
||||
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
|
||||
<!-- 允许应用程序快捷方式 -->
|
||||
<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" />
|
||||
|
||||
<uses-permission
|
||||
android:name="android.permission.PACKAGE_USAGE_STATS"
|
||||
tools:ignore="ProtectedPermissions" />
|
||||
|
||||
<!-- bugly with tinker -->
|
||||
<!-- <uses-permission android:name="android.permission.READ_LOGS" />-->
|
||||
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
|
||||
|
||||
<!--可选,穿山甲提供“获取地理位置权限”和“不给予地理位置权限,开发者传入地理位置参数”两种方式上报用户位置,两种方式均可不选,添加位置权限或参数将帮助投放定位广告-->
|
||||
<!--请注意:无论通过何种方式提供给穿山甲用户地理位置,均需向用户声明地理位置权限将应用于穿山甲广告投放,穿山甲不强制获取地理位置信息-->
|
||||
<!--<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />-->
|
||||
|
||||
<!-- 如果有视频相关的广告且使用textureView播放,请务必添加,否则黑屏 -->
|
||||
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
||||
|
||||
@ -47,9 +41,11 @@
|
||||
com.shuyu.gsyvideoplayer.armv7a,
|
||||
com.shuyu.gsyvideoplayer.x86,
|
||||
com.shuyu.gsy.base,
|
||||
shuyu.com.androidvideocache,
|
||||
com.google.android.exoplayer2,
|
||||
tv.danmaku.ijk.media.exo2,
|
||||
pl.droidsonroids.gif" />
|
||||
pl.droidsonroids.gif,
|
||||
com.lzf.easyfloat"/>
|
||||
|
||||
<!-- 去掉 SDK 一些流氓权限 -->
|
||||
<uses-permission
|
||||
@ -70,6 +66,7 @@
|
||||
android:icon="@mipmap/logo"
|
||||
android:label="@string/app_name"
|
||||
android:largeHeap="true"
|
||||
android:networkSecurityConfig="@xml/network_security_config"
|
||||
android:resizeableActivity="true"
|
||||
android:theme="@style/AppCompatTheme.APP"
|
||||
tools:replace="android:allowBackup"
|
||||
@ -79,7 +76,11 @@
|
||||
android:name="io.sentry.auto-init"
|
||||
android:value="false" />
|
||||
|
||||
<!--android:launchMode = "singleTask"-->
|
||||
<!-- 不让 sentry 读取系统事件 -->
|
||||
<meta-data
|
||||
android:name="io.sentry.breadcrumbs.system-events"
|
||||
android:value="false" />
|
||||
|
||||
<activity
|
||||
android:name="com.gh.gamecenter.SplashScreenActivity"
|
||||
android:configChanges="keyboardHidden|orientation|screenSize"
|
||||
@ -106,7 +107,6 @@
|
||||
android:launchMode="singleTask"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<!--android:theme = "@android:style/Theme.Black.NoTitleBar.Fullscreen" 退出时屏幕抖动 -->
|
||||
<activity
|
||||
android:name="com.gh.gamecenter.ImageViewerActivity"
|
||||
android:theme="@style/Theme.Transparent" />
|
||||
@ -164,6 +164,10 @@
|
||||
android:name="com.gh.gamecenter.WebActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name="com.gh.gamecenter.SingletonWebActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name="com.gh.gamecenter.FullScreenWebActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
@ -469,7 +473,7 @@
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name="com.gh.gamecenter.qa.editor.VideoActivity"
|
||||
android:name="com.gh.gamecenter.qa.editor.LocalMediaActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
@ -507,6 +511,12 @@
|
||||
android:theme="@style/Theme.Transparent"
|
||||
android:windowSoftInputMode="adjustNothing" />
|
||||
|
||||
<activity
|
||||
android:name=".qa.dialog.ChooseForumActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/Theme.Transparent"
|
||||
android:windowSoftInputMode="adjustNothing" />
|
||||
|
||||
<activity
|
||||
android:name="com.gh.gamecenter.video.detail.VideoDetailActivity"
|
||||
android:configChanges="orientation|screenSize|keyboardHidden"
|
||||
@ -546,10 +556,6 @@
|
||||
android:name=".forum.select.ForumSelectActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name=".forum.follow.ForumMyFollowActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name=".forum.detail.ForumDetailActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
@ -558,6 +564,10 @@
|
||||
android:name=".forum.moderator.ModeratorListActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name=".forum.moderator.ApplyModeratorActivity"
|
||||
android:screenOrientation="portrait"/>
|
||||
|
||||
<activity
|
||||
android:name=".video.label.VideoLabelActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
@ -579,10 +589,6 @@
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/TransparentStatusBarAndNavigationBar" />
|
||||
|
||||
<activity
|
||||
android:name=".personalhome.excellentcomments.ExcellentCommentsActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name=".simulatorgame.SimulatorGameActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
@ -603,6 +609,88 @@
|
||||
android:name=".forum.search.ForumOrUserSearchActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name=".energy.EnergyCenterActivity"
|
||||
android:launchMode="singleTask"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name=".energy.EnergyHouseActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name=".personal.NewPersonalActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name=".qa.questions.draft.QuestionDraftActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name=".servers.GameServerTestActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name=".category2.CategoryV2Activity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name=".personal.DeliveryInfoActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name=".qa.editor.PreviewVideoActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name=".qa.video.publish.VideoPublishActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name=".setting.GameDownloadSettingActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name=".setting.VideoSettingActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name=".qa.video.detail.ForumVideoDetailActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name=".video.videomanager.VideoDraftActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name=".qa.questions.newdetail.NewQuestionDetailActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name=".qa.editor.FullScreenVideoActivity"
|
||||
android:screenOrientation="landscape"
|
||||
android:theme="@style/AppFullScreenTheme" />
|
||||
|
||||
<activity
|
||||
android:name=".forum.list.ForumListActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name=".qa.answer.detail.SimpleAnswerDetailActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name="com.cmic.sso.sdk.activity.LoginAuthActivity"
|
||||
android:configChanges="orientation|keyboardHidden|screenSize"
|
||||
android:launchMode="singleTop"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@android:style/Theme.Dialog" />
|
||||
|
||||
|
||||
<activity
|
||||
android:name=".home.skip.PackageSkipActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<!-- <!– 使用小米/华为推送弹窗功能提高推送成功率–>-->
|
||||
<!-- <activity-->
|
||||
<!-- android:name="com.gh.gamecenter.PushProxyActivity"-->
|
||||
@ -654,6 +742,11 @@
|
||||
android:resource="@xml/provider_paths" />
|
||||
</provider>
|
||||
|
||||
<provider
|
||||
android:name="androidx.work.impl.WorkManagerInitializer"
|
||||
android:authorities="${applicationId}.workmanager-init"
|
||||
tools:node="remove" />
|
||||
|
||||
<receiver
|
||||
android:name="com.gh.gamecenter.receiver.DownloadReceiver"
|
||||
android:exported="false">
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,58 @@
|
||||
package androidx.swiperefreshlayout.widget;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.ViewConfiguration;
|
||||
|
||||
public class ViewPagerSwipeRefreshLayout extends SwipeRefreshLayout {
|
||||
|
||||
private float startY;
|
||||
private float startX;
|
||||
// 记录viewPager是否拖拽的标记
|
||||
private boolean mIsVpDragger;
|
||||
private final int mTouchSlop;
|
||||
|
||||
public ViewPagerSwipeRefreshLayout(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onInterceptTouchEvent(MotionEvent ev) {
|
||||
int action = ev.getAction();
|
||||
switch (action) {
|
||||
case MotionEvent.ACTION_DOWN:
|
||||
// 记录手指按下的位置
|
||||
startY = ev.getY();
|
||||
startX = ev.getX();
|
||||
// 初始化标记
|
||||
mIsVpDragger = false;
|
||||
break;
|
||||
case MotionEvent.ACTION_MOVE:
|
||||
// 如果viewpager正在拖拽中,那么不拦截它的事件,直接return false;
|
||||
if(mIsVpDragger) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 获取当前手指位置
|
||||
float endY = ev.getY();
|
||||
float endX = ev.getX();
|
||||
float distanceX = Math.abs(endX - startX);
|
||||
float distanceY = Math.abs(endY - startY);
|
||||
// 如果X轴位移大于Y轴位移,那么将事件交给viewPager处理。
|
||||
if(distanceX > mTouchSlop && distanceX > distanceY) {
|
||||
mIsVpDragger = true;
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case MotionEvent.ACTION_UP:
|
||||
case MotionEvent.ACTION_CANCEL:
|
||||
// 初始化标记
|
||||
mIsVpDragger = false;
|
||||
break;
|
||||
}
|
||||
// 如果是Y轴位移大于X轴,事件交给swipeRefreshLayout处理。
|
||||
return super.onInterceptTouchEvent(ev);
|
||||
}
|
||||
}
|
||||
@ -5,6 +5,7 @@ import android.app.PendingIntent;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Build;
|
||||
import android.os.Looper;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.util.Log;
|
||||
@ -25,8 +26,9 @@ import java.lang.Thread.UncaughtExceptionHandler;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
|
||||
import io.sentry.core.Sentry;
|
||||
import io.sentry.Sentry;
|
||||
|
||||
public class AppUncaughtHandler implements UncaughtExceptionHandler {
|
||||
|
||||
@ -38,22 +40,26 @@ public class AppUncaughtHandler implements UncaughtExceptionHandler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void uncaughtException(Thread thread, Throwable ex) {
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
public void uncaughtException(Thread t, Throwable e) {
|
||||
if (("FinalizerWatchdogDaemon").equals(t.getName())
|
||||
&& e instanceof TimeoutException) {
|
||||
// ignore timeoutException
|
||||
// detail can be found in this didi tech blog post https://mp.weixin.qq.com/s?__biz=MzU1ODEzNjI2NA==&mid=2247487185&idx=2&sn=cf2d9e10053f625bde0f61d246f14870&source=41#wechat_redirect
|
||||
} else {
|
||||
new Thread(() -> {
|
||||
Looper.prepare();
|
||||
Utils.toast(mContext.getApplicationContext(), "\"光环助手\"发生错误");
|
||||
Looper.loop();
|
||||
}
|
||||
});
|
||||
|
||||
saveLocalLog(mContext, ex);
|
||||
Sentry.captureException(ex);
|
||||
restart(mContext);
|
||||
});
|
||||
saveLocalLog(mContext, e);
|
||||
restart(mContext);
|
||||
Sentry.captureException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static void restart(final Context context) {
|
||||
// S450 这机器会无限重启循环 : (
|
||||
if ("S450".equals(Build.MODEL)) return;
|
||||
|
||||
// 防止重复奔溃,导致助手一直重启,20秒内不做处理
|
||||
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
|
||||
@ -8,6 +8,8 @@ import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.os.Parcel;
|
||||
import android.os.TransactionTooLargeException;
|
||||
import android.text.TextUtils;
|
||||
import android.util.TypedValue;
|
||||
import android.view.Gravity;
|
||||
@ -25,12 +27,16 @@ import androidx.lifecycle.Lifecycle;
|
||||
|
||||
import com.gh.base.fragment.BaseFragment;
|
||||
import com.gh.common.constant.Constants;
|
||||
import com.gh.common.tracker.IBusiness;
|
||||
import com.gh.common.util.DialogHelper;
|
||||
import com.gh.common.util.DialogUtils;
|
||||
import com.gh.common.util.DisplayUtils;
|
||||
import com.gh.common.util.EntranceUtils;
|
||||
import com.gh.common.util.ExtensionsKt;
|
||||
import com.gh.common.util.MtaHelper;
|
||||
import com.gh.common.util.NetworkUtils;
|
||||
import com.gh.common.util.PackageInstaller;
|
||||
import com.gh.common.util.QuickLoginHelper;
|
||||
import com.gh.common.util.RunningUtils;
|
||||
import com.gh.common.util.SPUtils;
|
||||
import com.gh.common.util.ShareUtils;
|
||||
@ -56,6 +62,7 @@ import java.lang.ref.WeakReference;
|
||||
import java.util.List;
|
||||
|
||||
import butterknife.ButterKnife;
|
||||
import kotlin.Pair;
|
||||
import pub.devrel.easypermissions.EasyPermissions;
|
||||
|
||||
import static com.gh.common.util.EntranceUtils.KEY_ENTRANCE;
|
||||
@ -66,17 +73,25 @@ import static com.gh.common.util.EntranceUtils.KEY_ENTRANCE;
|
||||
* 需要工具栏的页面请继承{@link ToolBarActivity}
|
||||
*/
|
||||
|
||||
public abstract class BaseActivity extends BaseAppCompatActivity implements EasyPermissions.PermissionCallbacks {
|
||||
public abstract class BaseActivity extends BaseAppCompatActivity implements EasyPermissions.PermissionCallbacks, IBusiness {
|
||||
|
||||
// global dialog key
|
||||
public final static String DOWNLOAD_HIJACK = "hijack";
|
||||
public final static String LOGIN_EXCEPTION = "loginException";
|
||||
public final static String PLUGGABLE = "plugin";
|
||||
public final static String SIGNATURE_CONFLICT = "signature_conflict";
|
||||
public final static int ID_ROOT_INDICATOR = 999;
|
||||
public final int MAX_BUNDLE_SIZE = 300;
|
||||
|
||||
@NonNull
|
||||
protected String mEntrance;
|
||||
|
||||
private boolean mIsExistLogoutDialog;
|
||||
private boolean mHasAddTaskFloat = false;
|
||||
private View mTaskBackView;
|
||||
private WindowManager mWM;
|
||||
private WindowManager.LayoutParams mWmParams;
|
||||
public long startPageTime = 0;
|
||||
|
||||
protected final Handler mBaseHandler = new BaseHandler(this);
|
||||
|
||||
@ -116,6 +131,7 @@ public abstract class BaseActivity extends BaseAppCompatActivity implements Easy
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
if (useEventBus()) EventBus.getDefault().register(this);
|
||||
if (useButterKnife()) ButterKnife.bind(this);
|
||||
mEntrance = getIntent().getStringExtra(KEY_ENTRANCE);
|
||||
@ -127,6 +143,8 @@ public abstract class BaseActivity extends BaseAppCompatActivity implements Easy
|
||||
Utils.log("ACTIVITY_ENTRANCE -> " + mEntrance);
|
||||
}
|
||||
|
||||
disableAutofill();
|
||||
|
||||
if (savedInstanceState != null) {
|
||||
String xapkUnzipActivity = SPUtils.getString(Constants.SP_XAPK_UNZIP_ACTIVITY);
|
||||
String xapkUrl = SPUtils.getString(Constants.SP_XAPK_URL);
|
||||
@ -138,13 +156,21 @@ public abstract class BaseActivity extends BaseAppCompatActivity implements Easy
|
||||
}
|
||||
if (this.getClass().getName().equals(xapkUnzipActivity) && !TextUtils.isEmpty(xapkUrl)) {
|
||||
DownloadEntity downloadEntity = DownloadManager.getInstance(this).getDownloadEntityByUrl(xapkUrl);
|
||||
PackageInstaller.install(this, downloadEntity, false);
|
||||
SPUtils.setString(Constants.SP_XAPK_UNZIP_ACTIVITY, "");
|
||||
SPUtils.setString(Constants.SP_XAPK_URL, "");
|
||||
if (downloadEntity != null) {
|
||||
PackageInstaller.install(this, downloadEntity, false);
|
||||
SPUtils.setString(Constants.SP_XAPK_UNZIP_ACTIVITY, "");
|
||||
SPUtils.setString(Constants.SP_XAPK_URL, "");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
startPageTime = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
@Override
|
||||
public void setContentView(View view) {
|
||||
@ -188,6 +214,15 @@ public abstract class BaseActivity extends BaseAppCompatActivity implements Easy
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭 editText 自动填充帐号 (我们也用不上),开启的时候有小概率出发 TimeoutException
|
||||
*/
|
||||
private void disableAutofill() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
getWindow().getDecorView().setImportantForAutofill(View.IMPORTANT_FOR_AUTOFILL_NO_EXCLUDE_DESCENDANTS);
|
||||
}
|
||||
}
|
||||
|
||||
private View getRootViewWithEnvIndicator(View view) {
|
||||
RelativeLayout screenRootView = new RelativeLayout(this);
|
||||
screenRootView.setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT));
|
||||
@ -206,6 +241,7 @@ public abstract class BaseActivity extends BaseAppCompatActivity implements Easy
|
||||
tv.setTextSize(TypedValue.COMPLEX_UNIT_SP, 13);
|
||||
tv.measure(0, 0);
|
||||
tv.setAlpha(0.15F);
|
||||
tv.setId(ID_ROOT_INDICATOR);
|
||||
int height = tv.getMeasuredHeight();
|
||||
int width = tv.getMeasuredWidth();
|
||||
tv.setPadding(DisplayUtils.dip2px(20), 0, DisplayUtils.dip2px(20), 0);
|
||||
@ -237,12 +273,18 @@ public abstract class BaseActivity extends BaseAppCompatActivity implements Easy
|
||||
if (DOWNLOAD_HIJACK.equals(showDialog.getType())) {
|
||||
DialogUtils.showQqSessionDialog(this);// 建议用户联系客服
|
||||
} else if (PLUGGABLE.equals(showDialog.getType())) {
|
||||
DialogUtils.showPluginDialog(this, () -> {
|
||||
DialogHelper.showPluginDialog(this, () -> {
|
||||
if (FileUtils.isEmptyFile(showDialog.getPath())) {
|
||||
toast(R.string.install_failure_hint);
|
||||
} else {
|
||||
PackageInstaller.uninstall(BaseActivity.this, showDialog.getPath());
|
||||
}
|
||||
return null;
|
||||
});
|
||||
} else if (SIGNATURE_CONFLICT.equals(showDialog.getType())) {
|
||||
DialogHelper.showSignatureConflictDialog(this, () -> {
|
||||
PackageInstaller.uninstall(BaseActivity.this, showDialog.getPath());
|
||||
return null;
|
||||
});
|
||||
} else if (LOGIN_EXCEPTION.equals(showDialog.getType())) {
|
||||
if (mIsExistLogoutDialog) return;
|
||||
@ -255,8 +297,14 @@ public abstract class BaseActivity extends BaseAppCompatActivity implements Easy
|
||||
, StringUtils.buildString("(", model, ")")
|
||||
, "知道了", "重新登录"
|
||||
, null
|
||||
, () -> startActivity(LoginActivity.getIntent(BaseActivity.this,
|
||||
"你的账号已在另外一台设备登录多设备-重新登录"))
|
||||
, () -> {
|
||||
if (SPUtils.getBoolean(Constants.SP_HAS_GET_PHONE_INFO) || NetworkUtils.isOpenMobileData(BaseActivity.this)) {
|
||||
QuickLoginHelper.startLogin(BaseActivity.this, "你的账号已在另外一台设备登录多设备-重新登录");
|
||||
} else {
|
||||
startActivity(LoginActivity.getIntent(BaseActivity.this,
|
||||
"你的账号已在另外一台设备登录多设备-重新登录"));
|
||||
}
|
||||
}
|
||||
);
|
||||
mBaseHandler.postDelayed(() -> mIsExistLogoutDialog = false, 5000);
|
||||
} catch (Exception e) {
|
||||
@ -269,6 +317,7 @@ public abstract class BaseActivity extends BaseAppCompatActivity implements Easy
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
|
||||
if (isFinishing()) {
|
||||
onFinish();
|
||||
for (Fragment fragment : getSupportFragmentManager().getFragments()) {
|
||||
@ -279,11 +328,6 @@ public abstract class BaseActivity extends BaseAppCompatActivity implements Easy
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
}
|
||||
|
||||
/**
|
||||
* 此回调可用于确认当前 activity 已经执行了 finish() 方法并处于 isFinishing 状态
|
||||
*/
|
||||
@ -359,4 +403,54 @@ public abstract class BaseActivity extends BaseAppCompatActivity implements Easy
|
||||
}
|
||||
return resources;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* ActivityThread每次调用onSaveInstanceState时outState大小都会累加,最终会导致{@link TransactionTooLargeException}异常
|
||||
* 解决方案:判断每次获取到的outState大小,当达到300k时手动clear掉
|
||||
*/
|
||||
@Override
|
||||
protected void onSaveInstanceState(@NonNull Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
|
||||
if (preventRecreateFragmentByFragmentManager()) {
|
||||
outState = discardFragmentFromSaveInstanceState(outState);
|
||||
}
|
||||
|
||||
long bundleSize = getBundleSize(outState);
|
||||
if (bundleSize > MAX_BUNDLE_SIZE * 1024) {
|
||||
outState.clear();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否停用 Activity 重建时 FragmentManager 根据 saveState 自动重建保存的 Fragment 的功能
|
||||
*/
|
||||
protected boolean preventRecreateFragmentByFragmentManager() {
|
||||
return false;
|
||||
}
|
||||
|
||||
private Bundle discardFragmentFromSaveInstanceState(Bundle outState) {
|
||||
if (outState != null) {
|
||||
outState.remove("android:support:fragments");
|
||||
}
|
||||
return outState;
|
||||
}
|
||||
|
||||
private long getBundleSize(Bundle bundle) {
|
||||
long dataSize;
|
||||
Parcel obtain = Parcel.obtain();
|
||||
try {
|
||||
obtain.writeBundle(bundle);
|
||||
dataSize = obtain.dataSize();
|
||||
} finally {
|
||||
obtain.recycle();
|
||||
}
|
||||
return dataSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pair<String, String> getBusinessId() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package com.gh.base
|
||||
|
||||
import android.animation.ObjectAnimator
|
||||
import android.annotation.SuppressLint
|
||||
import android.app.Activity
|
||||
import android.content.ClipboardManager
|
||||
@ -9,39 +10,53 @@ import android.os.Bundle
|
||||
import android.text.TextUtils
|
||||
import android.view.View
|
||||
import android.webkit.JavascriptInterface
|
||||
import android.widget.CheckBox
|
||||
import android.widget.FrameLayout
|
||||
import android.widget.TextView
|
||||
import androidx.lifecycle.Observer
|
||||
import butterknife.OnClick
|
||||
import com.gh.common.util.DialogUtils
|
||||
import com.gh.common.util.MtaHelper
|
||||
import com.gh.common.AppExecutor
|
||||
import com.gh.common.runOnIoThread
|
||||
import com.gh.common.util.*
|
||||
import com.gh.common.view.RichEditor
|
||||
import com.gh.gamecenter.CropImageActivity
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.entity.GameEntity
|
||||
import com.gh.gamecenter.entity.MyVideoEntity
|
||||
import com.gh.gamecenter.qa.answer.edit.AnswerEditActivity
|
||||
import com.gh.gamecenter.entity.LocalVideoEntity
|
||||
import com.gh.gamecenter.entity.VideoEntity
|
||||
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.editor.VideoActivity
|
||||
import com.gh.gamecenter.qa.editor.LocalMediaActivity
|
||||
import com.gh.gamecenter.qa.entity.AnswerEntity
|
||||
import com.gh.gamecenter.qa.entity.ArticleEntity
|
||||
import com.gh.gamecenter.qa.entity.EditorInsertEntity
|
||||
import com.gh.gamecenter.video.poster.PosterEditActivity
|
||||
import com.gh.gamecenter.video.upload.UploadManager
|
||||
import com.google.gson.JsonObject
|
||||
import com.halo.assistant.HaloApp
|
||||
import com.lightgame.utils.Util_System_Keyboard
|
||||
import com.lightgame.utils.Utils
|
||||
import com.lightgame.view.CheckableImageView
|
||||
import io.reactivex.disposables.Disposable
|
||||
import kotterknife.bindView
|
||||
import org.json.JSONArray
|
||||
import org.json.JSONObject
|
||||
import java.io.File
|
||||
|
||||
abstract class BaseRichEditorActivity : ToolBarActivity() {
|
||||
abstract class BaseRichEditorActivity<VM : BaseRichEditorViewModel> : ToolBarActivity(),
|
||||
KeyboardHeightObserver, UploadVideoListener {
|
||||
|
||||
val mRichEditor by bindView<RichEditor>(R.id.rich_editor)
|
||||
val mDraftBtn by bindView<TextView>(R.id.draft_btn)
|
||||
|
||||
private val mEditorTextNumTv by bindView<TextView>(R.id.editorTextNumTv)
|
||||
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 mEditorFontUnderline by bindView<CheckableImageView>(R.id.editor_font_underline)
|
||||
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)
|
||||
@ -50,88 +65,199 @@ abstract class BaseRichEditorActivity : ToolBarActivity() {
|
||||
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 val mEditorInsertDetailContainer by bindView<View>(R.id.editor_insert_detail_container)
|
||||
private val mTagsContainer by bindView<FrameLayout>(R.id.tagsContainer)
|
||||
private val mUploadVideoGuideContainer by bindView<View>(R.id.uploadVideoGuideContainer)
|
||||
protected val mOriginalCb by bindView<CheckBox>(R.id.originalCb)
|
||||
private val mOriginalTipsContainer by bindView<View>(R.id.originalTipsContainer)
|
||||
private val mOriginalTipsClose by bindView<TextView>(R.id.originalTipsClose)
|
||||
|
||||
private var mCurrentParagraphStyle = ""
|
||||
|
||||
private var mIsExtendedKeyboardShow = false
|
||||
private var mAgreePostPic: Boolean = false
|
||||
private var mGuideDisposable: Disposable? = null
|
||||
protected lateinit var mViewModel: VM
|
||||
protected var mIsKeyBoardShow = false
|
||||
private var mKeyboardHeightProvider: KeyboardHeightProvider? = null
|
||||
private var mMaxUploadVideoGuideCount = 2
|
||||
val FILE_HOST = "file:///"
|
||||
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
super.onActivityResult(requestCode, resultCode, data)
|
||||
DialogUtils.fixWebViewKeyboardNotWorking(this)
|
||||
if (resultCode != Activity.RESULT_OK) return
|
||||
var insertData: EditorInsertEntity? = null
|
||||
val insertData: EditorInsertEntity?
|
||||
when (requestCode) {
|
||||
INSERT_ANSWER_CODE -> {
|
||||
val answer = data?.getParcelableExtra<AnswerEntity>(AnswerEntity::class.java.simpleName)
|
||||
if (answer != null) insertData = EditorInsertEntity.transform(answer)
|
||||
val answer =
|
||||
data?.getParcelableExtra<AnswerEntity>(AnswerEntity::class.java.simpleName)
|
||||
if (answer != null) {
|
||||
mRichEditor.focusEditor()
|
||||
insertData = EditorInsertEntity.transform(answer)
|
||||
mRichEditor.insertCustomStyleLink(insertData)
|
||||
}
|
||||
}
|
||||
INSERT_ARTICLE_CODE -> {
|
||||
val article = data?.getParcelableExtra<ArticleEntity>(ArticleEntity::class.java.simpleName)
|
||||
if (article != null) insertData = EditorInsertEntity.transform(article)
|
||||
val article =
|
||||
data?.getParcelableExtra<ArticleEntity>(ArticleEntity::class.java.simpleName)
|
||||
if (article != null) {
|
||||
mRichEditor.focusEditor()
|
||||
insertData = EditorInsertEntity.transform(article)
|
||||
mRichEditor.insertCustomStyleLink(insertData)
|
||||
}
|
||||
}
|
||||
INSERT_GAME_CODE -> {
|
||||
val game = data?.getParcelableExtra<GameEntity>(GameEntity::class.java.simpleName)
|
||||
if (game != null) insertData = EditorInsertEntity.transform(game)
|
||||
if (game != null) {
|
||||
mRichEditor.focusEditor()
|
||||
insertData = EditorInsertEntity.transform(game)
|
||||
mRichEditor.insertCustomStyleLink(insertData)
|
||||
}
|
||||
}
|
||||
VideoActivity.INSERT_VIDEO_CODE -> {
|
||||
val video = data?.getParcelableExtra<MyVideoEntity>(MyVideoEntity::class.java.simpleName)
|
||||
if (video != null) mRichEditor.insertCustomVideo(video)
|
||||
return
|
||||
REQUEST_CODE_IMAGE -> {
|
||||
if (data != null) mViewModel.uploadPic(data)
|
||||
}
|
||||
INSERT_VIDEO_CODE -> {
|
||||
val localVideoList =
|
||||
data?.getParcelableArrayListExtra<LocalVideoEntity>(LocalVideoEntity::class.java.name)
|
||||
?: arrayListOf()
|
||||
if (localVideoList.isNotEmpty()) {
|
||||
mRichEditor.focusEditor()
|
||||
uploadVideo(localVideoList)
|
||||
}
|
||||
}
|
||||
REQUEST_CODE_IMAGE_CROP -> {
|
||||
val imagePath = data?.getStringExtra(CropImageActivity.RESULT_CLIP_PATH)
|
||||
if (!imagePath.isNullOrEmpty()) {
|
||||
mViewModel.uploadPoster(imagePath)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mRichEditor.insertCustomStyleLink(insertData)
|
||||
closeExtendedKeyboard()
|
||||
AppExecutor.uiExecutor.executeWithDelay(Runnable {
|
||||
Util_System_Keyboard.showSoftKeyboard(this)
|
||||
}, 100)
|
||||
}
|
||||
|
||||
@SuppressLint("AddJavascriptInterface")
|
||||
private fun uploadVideo(localVideoList: ArrayList<LocalVideoEntity>) {
|
||||
mViewModel.localVideoList.addAll(localVideoList)
|
||||
runOnIoThread {
|
||||
localVideoList.forEach {
|
||||
if (it.poster.startsWith("http")) {
|
||||
runOnUiThread {
|
||||
mRichEditor.focusEditor()
|
||||
mRichEditor.insertPlaceholderVideo(it.id, it.poster)
|
||||
}
|
||||
} else {
|
||||
val videoThumbnail = BitmapUtils.getVideoThumbnail(it.filePath)
|
||||
val filePath = "${cacheDir.absolutePath}${File.separator}${it.id}.webp"
|
||||
BitmapUtils.saveBitmap(videoThumbnail, filePath)
|
||||
it.poster = filePath
|
||||
runOnUiThread {
|
||||
mRichEditor.focusEditor()
|
||||
mRichEditor.insertPlaceholderVideo(it.id, "$FILE_HOST${it.poster}")
|
||||
}
|
||||
}
|
||||
}
|
||||
mViewModel.uploadVideo()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@SuppressLint("AddJavascriptInterface", "ClickableViewAccessibility")
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
mViewModel = provideViewModel()
|
||||
mViewModel.setUploadVideoListener(this)
|
||||
mKeyboardHeightProvider = KeyboardHeightProvider(this)
|
||||
mRichEditor.post { mKeyboardHeightProvider?.start() }
|
||||
mRichEditor.setPadding(20, 15, 20, 15)
|
||||
// 防止个别手机在Js里无法获取粘贴内容
|
||||
mRichEditor.addJavascriptInterface(OnPasteListener(), "onPasteListener")
|
||||
mRichEditor.addJavascriptInterface(OnCursorChangeListener(), "OnCursorChangeListener")
|
||||
mRichEditor.addJavascriptInterface(OnEditorTextChangeListener(), "OnEditorTextChangeListener")
|
||||
mRichEditor.addJavascriptInterface(
|
||||
OnEditorTextChangeListener(),
|
||||
"OnEditorTextChangeListener"
|
||||
)
|
||||
mRichEditor.addJavascriptInterface(OnVideoListener(), "onVideoListener")
|
||||
mRichEditor.addJavascriptInterface(
|
||||
OnQuoteCountChangeListener(),
|
||||
"OnQuoteCountChangeListener"
|
||||
)
|
||||
mRichEditor.setInputEnabled(true)
|
||||
mRichEditor.setPadding(16, 15, 16, 15)
|
||||
|
||||
mDraftBtn.text = if (this is AnswerEditActivity) {
|
||||
"回答草稿"
|
||||
} else "帖子草稿"
|
||||
mRichEditor.setOnTouchListener { _, _ ->
|
||||
if (mIsExtendedKeyboardShow) {
|
||||
closeExtendedKeyboard()
|
||||
Util_System_Keyboard.showSoftKeyboard(this)
|
||||
//是否消费事件根据mRichEditor是否含有焦点决定,mRichEditor没有焦点则不消费事件
|
||||
mRichEditor.hasFocus()
|
||||
} else false
|
||||
}
|
||||
mOriginalCb.setOnCheckedChangeListener { _, isChecked ->
|
||||
if (isChecked) {
|
||||
mOriginalTipsContainer.alpha = 0f
|
||||
mOriginalTipsContainer.visibility = View.VISIBLE
|
||||
ObjectAnimator.ofFloat(mOriginalTipsContainer, "alpha", 0f, 1f).setDuration(200).start()
|
||||
}
|
||||
}
|
||||
observeData()
|
||||
}
|
||||
|
||||
@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, R.id.editor_link_video)
|
||||
private fun observeData() {
|
||||
mViewModel.chooseImagesUpload.observe(this, Observer {
|
||||
mRichEditor.focusEditor()
|
||||
for (key in it.keys) {
|
||||
mRichEditor.insertPlaceholderImage(key)
|
||||
}
|
||||
})
|
||||
mViewModel.chooseImagesUploadSuccess.observe(this, Observer {
|
||||
val jsonArray = JSONArray()
|
||||
for (key in it.keys) {
|
||||
val jsonObject = JSONObject()
|
||||
jsonObject.put("id", key)
|
||||
jsonObject.put("url", it[key])
|
||||
jsonArray.put(jsonObject)
|
||||
}
|
||||
mRichEditor.replacePlaceholderImage(jsonArray.toString())
|
||||
})
|
||||
}
|
||||
|
||||
override fun onKeyboardHeightChanged(height: Int, orientation: Int) {
|
||||
mIsKeyBoardShow = height > 0
|
||||
if (height > 0) {
|
||||
closeExtendedKeyboard()
|
||||
}
|
||||
}
|
||||
|
||||
fun closeExtendedKeyboard() {
|
||||
mEditorInsertDetailContainer.visibility = View.GONE
|
||||
mEditorFont.isChecked = false
|
||||
mEditorLink.isChecked = false
|
||||
mIsExtendedKeyboardShow = false
|
||||
}
|
||||
|
||||
protected fun controlEditorInsertContainerEnabled(isEnabled: Boolean) {
|
||||
mEditorFont.isEnabled = isEnabled
|
||||
}
|
||||
|
||||
@OnClick(
|
||||
R.id.editor_image, R.id.editor_font, R.id.editor_link, R.id.editor_font_underline,
|
||||
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, R.id.editor_link_video, R.id.uploadVideoGuideClose,
|
||||
R.id.originalTipsClose
|
||||
)
|
||||
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
|
||||
controlEditorFontContainer()
|
||||
}
|
||||
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
|
||||
controlEditorLinkContainer()
|
||||
}
|
||||
R.id.editor_font_bold -> {
|
||||
mEditorFontBold.isChecked = !mEditorFontBold.isChecked
|
||||
@ -155,6 +281,14 @@ abstract class BaseRichEditorActivity : ToolBarActivity() {
|
||||
MtaHelper.onEvent(mtaEventName(), "文字样式", "文字样式-删除线")
|
||||
}
|
||||
}
|
||||
R.id.editor_font_underline -> {
|
||||
mEditorFontUnderline.isChecked = !mEditorFontUnderline.isChecked
|
||||
mRichEditor.setUnderline()
|
||||
|
||||
if (mEditorFontUnderline.isChecked) {
|
||||
MtaHelper.onEvent(mtaEventName(), "文字样式", "文字样式-下滑线")
|
||||
}
|
||||
}
|
||||
R.id.editor_paragraph_h1 -> {
|
||||
if (mEditorParagraphH1.isChecked) {
|
||||
mRichEditor.formatBlock()
|
||||
@ -202,20 +336,202 @@ abstract class BaseRichEditorActivity : ToolBarActivity() {
|
||||
}
|
||||
R.id.editor_link_answer -> {
|
||||
MtaHelper.onEvent(mtaEventName(), "插入链接", "插入链接-回答")
|
||||
startActivityForResult(InsertAnswerWrapperActivity.getIntent(this), INSERT_ANSWER_CODE)
|
||||
startActivityForResult(
|
||||
InsertAnswerWrapperActivity.getIntent(this),
|
||||
INSERT_ANSWER_CODE
|
||||
)
|
||||
}
|
||||
R.id.editor_link_article -> {
|
||||
MtaHelper.onEvent(mtaEventName(), "插入链接", "插入链接-文章")
|
||||
startActivityForResult(InsertArticleWrapperActivity.getIntent(this), INSERT_ARTICLE_CODE)
|
||||
startActivityForResult(
|
||||
InsertArticleWrapperActivity.getIntent(this),
|
||||
INSERT_ARTICLE_CODE
|
||||
)
|
||||
}
|
||||
R.id.editor_link_game -> {
|
||||
MtaHelper.onEvent(mtaEventName(), "插入链接", "插入链接-游戏")
|
||||
startActivityForResult(GameActivity.getIntent(this, GameActivity.INSERT_GAME_TITLE), INSERT_GAME_CODE)
|
||||
startActivityForResult(
|
||||
GameActivity.getIntent(this, GameActivity.INSERT_GAME_TITLE),
|
||||
INSERT_GAME_CODE
|
||||
)
|
||||
}
|
||||
R.id.editor_link_video -> {
|
||||
MtaHelper.onEvent(mtaEventName(), "插入链接", "插入链接-视频")
|
||||
startActivityForResult(VideoActivity.getIntent(this), VideoActivity.INSERT_VIDEO_CODE)
|
||||
PermissionHelper.checkStoragePermissionBeforeAction(this,
|
||||
object : EmptyCallback {
|
||||
override fun onCallback() {
|
||||
MtaHelper.onEvent(mtaEventName(), "插入链接", "插入链接-视频")
|
||||
startActivityForResult(
|
||||
LocalMediaActivity.getIntent(
|
||||
this@BaseRichEditorActivity,
|
||||
LocalMediaActivity.ChooseType.VIDEO,
|
||||
3,
|
||||
if (mtaEventName() == "提问帖") "发提问帖" else "发帖子"
|
||||
), INSERT_VIDEO_CODE
|
||||
)
|
||||
NewLogUtils.logChooseMedia(
|
||||
"view_media",
|
||||
if (mtaEventName() == "提问帖") "提问帖" else "帖子",
|
||||
"视频"
|
||||
)
|
||||
}
|
||||
})
|
||||
}
|
||||
R.id.editor_image -> {
|
||||
if (!mAgreePostPic && !NetworkUtils.isWifiOr4GOr3GConnected(this)) {
|
||||
mAgreePostPic = true
|
||||
DialogUtils.showAlertDialog(
|
||||
this,
|
||||
"警告",
|
||||
"当前使用移动网络,上传图片会消耗手机流量",
|
||||
"我知道了", "", { startMediaStore() }, null
|
||||
)
|
||||
return
|
||||
}
|
||||
startMediaStore()
|
||||
NewLogUtils.logChooseMedia(
|
||||
"view_media",
|
||||
if (mtaEventName() == "提问帖") "提问帖" else "帖子",
|
||||
"图片"
|
||||
)
|
||||
}
|
||||
R.id.uploadVideoGuideClose -> {
|
||||
hideUploadVideoGuide()
|
||||
if (mGuideDisposable != null && !mGuideDisposable!!.isDisposed) {
|
||||
mGuideDisposable!!.dispose()
|
||||
mGuideDisposable = null
|
||||
}
|
||||
}
|
||||
R.id.originalTipsClose -> {
|
||||
val animator = ObjectAnimator.ofFloat(mOriginalTipsContainer, "alpha", 1f, 0f).setDuration(200)
|
||||
animator.doOnEnd {
|
||||
mOriginalTipsContainer.visibility = View.GONE
|
||||
}
|
||||
animator.start()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun startMediaStore() {
|
||||
MtaHelper.onEvent(mtaEventName(), "插入图片", "插入图片")
|
||||
if (mViewModel.mapImages.size >= 50) {
|
||||
toast(R.string.answer_edit_max_img_hint)
|
||||
return
|
||||
}
|
||||
try {
|
||||
PermissionHelper.checkStoragePermissionBeforeAction(this, object : EmptyCallback {
|
||||
override fun onCallback() {
|
||||
val intent = LocalMediaActivity.getIntent(
|
||||
this@BaseRichEditorActivity,
|
||||
LocalMediaActivity.ChooseType.IMAGE,
|
||||
10,
|
||||
if (mtaEventName() == "提问帖") "发提问帖" else "发帖子"
|
||||
)
|
||||
startActivityForResult(intent, REQUEST_CODE_IMAGE)
|
||||
}
|
||||
})
|
||||
} catch (e: Exception) {
|
||||
toast(R.string.media_image_hint)
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
private fun controlEditorFontContainer() {
|
||||
mEditorFont.isChecked = !mEditorFont.isChecked
|
||||
mEditorLink.isChecked = false
|
||||
val isShouldDelay = if (mEditorFont.isChecked) {
|
||||
Util_System_Keyboard.hideSoftKeyboard(this)
|
||||
true
|
||||
} else {
|
||||
Util_System_Keyboard.showSoftKeyboard(this)
|
||||
false
|
||||
}
|
||||
mEditorInsertDetailContainer.postDelayed({
|
||||
mEditorInsertDetailContainer.visibility =
|
||||
if (mEditorFont.isChecked) View.VISIBLE else View.GONE
|
||||
mEditorFontContainer.visibility = if (mEditorFont.isChecked) View.VISIBLE else View.GONE
|
||||
mEditorParagraphContainer.visibility =
|
||||
if (mEditorFont.isChecked) View.VISIBLE else View.GONE
|
||||
mEditorLinkContainer.visibility = View.GONE
|
||||
mTagsContainer.visibility = View.GONE
|
||||
mIsExtendedKeyboardShow = mEditorFont.isChecked
|
||||
}, if (isShouldDelay) 200 else 0L)
|
||||
}
|
||||
|
||||
private fun controlEditorLinkContainer() {
|
||||
mEditorLink.isChecked = !mEditorLink.isChecked
|
||||
mEditorFont.isChecked = false
|
||||
val isShouldDelay = if (mEditorLink.isChecked) {
|
||||
Util_System_Keyboard.hideSoftKeyboard(this)
|
||||
true
|
||||
} else {
|
||||
Util_System_Keyboard.showSoftKeyboard(this)
|
||||
false
|
||||
}
|
||||
mEditorInsertDetailContainer.postDelayed({
|
||||
mEditorInsertDetailContainer.visibility =
|
||||
if (mEditorLink.isChecked) View.VISIBLE else View.GONE
|
||||
mEditorLinkContainer.visibility = if (mEditorLink.isChecked) View.VISIBLE else View.GONE
|
||||
mEditorFontContainer.visibility = View.GONE
|
||||
mEditorParagraphContainer.visibility = View.GONE
|
||||
mTagsContainer.visibility = View.GONE
|
||||
mIsExtendedKeyboardShow = mEditorLink.isChecked
|
||||
}, if (isShouldDelay) 200 else 0L)
|
||||
}
|
||||
|
||||
|
||||
override fun handleBackPressed(): Boolean {
|
||||
if (mIsExtendedKeyboardShow) {
|
||||
closeExtendedKeyboard()
|
||||
return true
|
||||
}
|
||||
return super.handleBackPressed()
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
mKeyboardHeightProvider?.setKeyboardHeightObserver(this)
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
mKeyboardHeightProvider?.setKeyboardHeightObserver(null)
|
||||
}
|
||||
|
||||
//视频上传功能引导
|
||||
fun showUploadVideoGuide() {
|
||||
mUploadVideoGuideContainer.postDelayed({
|
||||
val count = SPUtils.getInt(getVideoGuideKey(), 0)
|
||||
if (count >= mMaxUploadVideoGuideCount) return@postDelayed
|
||||
mUploadVideoGuideContainer.alpha = 0f
|
||||
mUploadVideoGuideContainer.visibility = View.VISIBLE
|
||||
mUploadVideoGuideContainer.animate().alpha(1f).setDuration(200).start()
|
||||
mGuideDisposable = countDownTimer(3) { finish, _ ->
|
||||
if (finish) {
|
||||
hideUploadVideoGuide()
|
||||
}
|
||||
}
|
||||
SPUtils.setInt(getVideoGuideKey(), count + 1)
|
||||
}, 1000)
|
||||
}
|
||||
|
||||
fun hideUploadVideoGuide() {
|
||||
val animate = mUploadVideoGuideContainer.animate().alpha(0f).setDuration(200)
|
||||
animate.doOnEnd {
|
||||
mUploadVideoGuideContainer.visibility = View.GONE
|
||||
}
|
||||
animate.start()
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
mKeyboardHeightProvider?.close()
|
||||
val path = mViewModel.currentUploadingVideo?.filePath
|
||||
if (path != null && UploadManager.isUploading(path)) {
|
||||
UploadManager.cancelTask(path)
|
||||
}
|
||||
if (mGuideDisposable != null && !mGuideDisposable!!.isDisposed) {
|
||||
mGuideDisposable!!.dispose()
|
||||
mGuideDisposable = null
|
||||
}
|
||||
}
|
||||
|
||||
@ -237,6 +553,7 @@ abstract class BaseRichEditorActivity : ToolBarActivity() {
|
||||
mEditorFontBold.isChecked = elements.contains(ELEMENT_NAME_BOLD)
|
||||
mEditorFontItalic.isChecked = elements.contains(ELEMENT_NAME_ITALIC)
|
||||
mEditorFontStrikeThrough.isChecked = elements.contains(ELEMENT_NAME_STRIKE)
|
||||
mEditorFontUnderline.isChecked = elements.contains(ELEMENT_NAME_UNDERLINE)
|
||||
mEditorParagraphH1.isChecked = elements.contains(ELEMENT_PARAGRAPH_H1)
|
||||
mEditorParagraphH2.isChecked = elements.contains(ELEMENT_PARAGRAPH_H2)
|
||||
mEditorParagraphH3.isChecked = elements.contains(ELEMENT_PARAGRAPH_H3)
|
||||
@ -250,11 +567,12 @@ abstract class BaseRichEditorActivity : ToolBarActivity() {
|
||||
@JavascriptInterface
|
||||
fun onPaste() {
|
||||
val clipboard =
|
||||
HaloApp.getInstance().application.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
|
||||
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/>")
|
||||
val text = clipText.replace("[ ]".toRegex(), " ")
|
||||
.replace("[\r\n]".toRegex(), "<br/>")
|
||||
mBaseHandler.post { mRichEditor.insertHtml(text) }
|
||||
}
|
||||
}
|
||||
@ -264,16 +582,111 @@ abstract class BaseRichEditorActivity : ToolBarActivity() {
|
||||
@JavascriptInterface
|
||||
fun onTextChange(count: Int) {
|
||||
val num = if (count > MAX_INPUT_TEXT_NUM) MAX_INPUT_TEXT_NUM - count else count
|
||||
mEditorTextNumTv.text = num.toString()
|
||||
mEditorTextNumTv.post {
|
||||
mEditorTextNumTv.text = num.toString()
|
||||
mViewModel.quoteCountEntity.textCount = num
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private inner class OnQuoteCountChangeListener {
|
||||
@JavascriptInterface
|
||||
fun onQuoteCountChange(
|
||||
imageCount: Int,
|
||||
articleCount: Int,
|
||||
answerCount: Int,
|
||||
videoCount: Int,
|
||||
gameCount: Int
|
||||
) {
|
||||
mEditorTextNumTv.post {
|
||||
mViewModel.quoteCountEntity.apply {
|
||||
this.imageCount = imageCount
|
||||
this.articleCount = articleCount
|
||||
this.answerCount = answerCount
|
||||
this.videoCount = videoCount
|
||||
this.gameCount = gameCount
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private inner class OnVideoListener {
|
||||
@JavascriptInterface
|
||||
fun showDeleteDialog(id: String) {
|
||||
DialogHelper.showDialog(this@BaseRichEditorActivity, "提示", "确定删除吗?", "确定", "取消", {
|
||||
runOnUiThread {
|
||||
mRichEditor.delPlaceholderVideo(id)
|
||||
mViewModel.deleteVideo(id)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
fun updatePoster(id: String, videoId: String, url: String) {
|
||||
mViewModel.id = id
|
||||
mViewModel.videoId = videoId
|
||||
val videoEntity = VideoEntity(url = url)
|
||||
val intent =
|
||||
PosterEditActivity.getIntentByVideo(this@BaseRichEditorActivity, videoEntity)
|
||||
startActivityForResult(intent, REQUEST_CODE_IMAGE_CROP)
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
fun deleteUploadingVideo(id: String) {
|
||||
mViewModel.deleteVideo(id)
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
fun reUploadVideo(id: String) {
|
||||
val video = mViewModel.uploadVideoErrorList.find { it.id == id }
|
||||
if (video != null) {
|
||||
mViewModel.localVideoList.add(video)
|
||||
mViewModel.uploadVideoErrorList.remove(video)
|
||||
mViewModel.uploadVideo()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun insertPlaceholderVideo(id: String, poster: String) {
|
||||
mRichEditor.insertPlaceholderVideo(id, poster)
|
||||
}
|
||||
|
||||
override fun updateVideoProgress(id: String, progress: String) {
|
||||
mRichEditor.updateVideoProgress(id, progress)
|
||||
}
|
||||
|
||||
override fun videoUploadFinished(id: String, url: String, msg: JsonObject) {
|
||||
try {
|
||||
val obj = JSONObject()
|
||||
obj.put("poster", msg.get("poster").asString)
|
||||
obj.put("url", msg.get("url").asString)
|
||||
obj.put("duration", RichEditor.formatVideoDuration(msg.get("length").asLong))
|
||||
obj.put("id", msg.get("_id").asString)
|
||||
obj.put("status", "pending")
|
||||
mRichEditor.videoUploadFinished(id, url, obj.toString())
|
||||
} catch (e: java.lang.Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
override fun changePoster(id: String, poster: String) {
|
||||
mRichEditor.changePoster(id, poster)
|
||||
}
|
||||
|
||||
override fun videoUploadFailed(id: String) {
|
||||
mRichEditor.videoUploadFailed(id)
|
||||
}
|
||||
|
||||
open fun getSelectedLabel(): Int = 0
|
||||
abstract fun mtaEventName(): String
|
||||
abstract fun provideViewModel(): VM
|
||||
abstract fun getVideoGuideKey(): String
|
||||
|
||||
companion object {
|
||||
const val ELEMENT_NAME_BOLD = " b "
|
||||
const val ELEMENT_NAME_ITALIC = " i "
|
||||
const val ELEMENT_NAME_STRIKE = " strike "
|
||||
const val ELEMENT_NAME_UNDERLINE = " u "
|
||||
const val ELEMENT_PARAGRAPH_H1 = " h1 "
|
||||
const val ELEMENT_PARAGRAPH_H2 = " h2 "
|
||||
const val ELEMENT_PARAGRAPH_H3 = " h3 "
|
||||
@ -284,5 +697,9 @@ abstract class BaseRichEditorActivity : ToolBarActivity() {
|
||||
const val INSERT_ARTICLE_CODE = 412
|
||||
const val INSERT_GAME_CODE = 413
|
||||
const val MAX_INPUT_TEXT_NUM = 10000
|
||||
|
||||
const val REQUEST_CODE_IMAGE = 120
|
||||
const val INSERT_VIDEO_CODE = 121
|
||||
const val REQUEST_CODE_IMAGE_CROP = 122
|
||||
}
|
||||
}
|
||||
444
app/src/main/java/com/gh/base/BaseRichEditorViewModel.kt
Normal file
444
app/src/main/java/com/gh/base/BaseRichEditorViewModel.kt
Normal file
@ -0,0 +1,444 @@
|
||||
package com.gh.base
|
||||
|
||||
import android.app.Application
|
||||
import android.content.Intent
|
||||
import android.graphics.Bitmap
|
||||
import android.media.ThumbnailUtils
|
||||
import android.provider.MediaStore
|
||||
import android.text.TextUtils
|
||||
import androidx.lifecycle.AndroidViewModel
|
||||
import androidx.lifecycle.MediatorLiveData
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import com.gh.base.fragment.WaitingDialogFragment
|
||||
import com.gh.common.runOnUiThread
|
||||
import com.gh.common.util.*
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.entity.ErrorEntity
|
||||
import com.gh.gamecenter.entity.LocalVideoEntity
|
||||
import com.gh.gamecenter.entity.QuoteCountEntity
|
||||
import com.gh.gamecenter.qa.BbsType
|
||||
import com.gh.gamecenter.retrofit.Response
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager
|
||||
import com.gh.gamecenter.retrofit.service.ApiService
|
||||
import com.gh.gamecenter.video.upload.OnUploadListener
|
||||
import com.gh.gamecenter.video.upload.UploadManager
|
||||
import com.google.gson.JsonObject
|
||||
import com.lightgame.utils.Utils
|
||||
import com.zhihu.matisse.Matisse
|
||||
import com.zhihu.matisse.internal.utils.PathUtils
|
||||
import io.reactivex.disposables.Disposable
|
||||
import okhttp3.ResponseBody
|
||||
import retrofit2.HttpException
|
||||
import java.io.File
|
||||
import java.io.FileOutputStream
|
||||
import java.util.*
|
||||
import kotlin.collections.HashMap
|
||||
import kotlin.collections.LinkedHashMap
|
||||
import kotlin.collections.List
|
||||
import kotlin.collections.Map
|
||||
import kotlin.collections.find
|
||||
import kotlin.collections.forEach
|
||||
import kotlin.collections.set
|
||||
|
||||
abstract class BaseRichEditorViewModel(application: Application) : AndroidViewModel(application) {
|
||||
val mApi: ApiService = RetrofitManager.getInstance(application).api
|
||||
val processDialog = MediatorLiveData<WaitingDialogFragment.WaitingDialogData>()
|
||||
val uploadingImage = ArrayList<LinkedHashMap<String, String>>()
|
||||
val chooseImagesUpload = MutableLiveData<LinkedHashMap<String, String>>()
|
||||
val chooseImagesUploadSuccess = MutableLiveData<LinkedHashMap<String, String>>()
|
||||
var uploadImageSubscription: Disposable? = null
|
||||
val mapImages = HashMap<String, String>()
|
||||
val localVideoList = ArrayList<LocalVideoEntity>()
|
||||
val uploadVideoErrorList = ArrayList<LocalVideoEntity>()
|
||||
var currentUploadingVideo: LocalVideoEntity? = null
|
||||
var type: String = "" //游戏论坛:game_bbs 官方论坛:official_bbs
|
||||
private var mUploadVideoListener: UploadVideoListener? = null
|
||||
val TITLE_MIN_LENGTH = 6
|
||||
val MIN_TEXT_LENGTH = 6
|
||||
val MAX_TEXT_LENGTH = 10000
|
||||
val FILE_HOST = "file:///"
|
||||
var id = ""//视频标记
|
||||
var videoId = ""//更改封面视频id
|
||||
val quoteCountEntity = QuoteCountEntity()//数据上报用
|
||||
|
||||
fun setUploadVideoListener(uploadVideoListener: UploadVideoListener) {
|
||||
this.mUploadVideoListener = uploadVideoListener
|
||||
}
|
||||
|
||||
//检查图片是否符合规则并上传图片
|
||||
fun uploadPic(data: Intent) {
|
||||
val uris = Matisse.obtainResult(data)
|
||||
val pictureList = ArrayList<String>()
|
||||
for (uri in uris) {
|
||||
val picturePath = PathUtils.getPath(getApplication(), uri)
|
||||
if (picturePath != null) {
|
||||
if (File(picturePath).length() > ImageUtils.getUploadFileMaxSize()) {
|
||||
val count = ImageUtils.getUploadFileMaxSize() / 1024 / 1024
|
||||
val application: Application = getApplication()
|
||||
Utils.toast(
|
||||
getApplication(),
|
||||
application.getString(R.string.pic_max_hint, count)
|
||||
)
|
||||
continue
|
||||
}
|
||||
Utils.log("picturePath = $picturePath")
|
||||
pictureList.add(picturePath)
|
||||
} else {
|
||||
Utils.log("picturePath is null")
|
||||
}
|
||||
}
|
||||
if (pictureList.size == 0) return
|
||||
val imageType = when (getRichType()) {
|
||||
RichType.ARTICLE -> UploadImageUtils.UploadType.community_article
|
||||
RichType.QUESTION -> UploadImageUtils.UploadType.question
|
||||
else -> UploadImageUtils.UploadType.poster
|
||||
}
|
||||
uploadImageSubscription = UploadImageUtils.compressAndUploadImageList(
|
||||
imageType,
|
||||
pictureList,
|
||||
false,
|
||||
object : UploadImageUtils.OnUploadImageListListener {
|
||||
override fun onProgress(total: Long, progress: Long) {}
|
||||
|
||||
override fun onCompressSuccess(imageUrls: List<String>) {
|
||||
val chooseImageMd5Map = LinkedHashMap<String, String>()
|
||||
imageUrls.forEach {
|
||||
chooseImageMd5Map[MD5Utils.getUrlMD5(it)] = ""
|
||||
}
|
||||
uploadingImage.add(chooseImageMd5Map)
|
||||
chooseImagesUpload.postValue(chooseImageMd5Map)
|
||||
}
|
||||
|
||||
override fun onSingleSuccess(imageUrl: Map<String, String>) {
|
||||
val map = LinkedHashMap<String, String>()
|
||||
for (key in imageUrl.keys) {
|
||||
map[MD5Utils.getUrlMD5(key)] = FILE_HOST + key.decodeURI()
|
||||
mapImages[TextUtils.htmlEncode(key).decodeURI()] = imageUrl[key] ?: ""
|
||||
}
|
||||
chooseImagesUploadSuccess.postValue(map)
|
||||
}
|
||||
|
||||
override fun onSuccess(
|
||||
imageUrl: LinkedHashMap<String, String>,
|
||||
errorMap: Map<String, Exception>
|
||||
) {
|
||||
val uploadMap = uploadingImage.find {
|
||||
it.containsKey(
|
||||
MD5Utils.getUrlMD5(
|
||||
imageUrl.entries.iterator().next().key
|
||||
)
|
||||
)
|
||||
}
|
||||
uploadMap?.let {
|
||||
uploadingImage.remove(uploadMap)
|
||||
}
|
||||
|
||||
val errorSize = pictureList.size - imageUrl.size
|
||||
if (errorSize > 0) {
|
||||
val map = LinkedHashMap<String, String>()
|
||||
for (key in errorMap.keys) {
|
||||
map[MD5Utils.getUrlMD5(key)] = ""
|
||||
}
|
||||
//value为空会删除PlaceholderImage
|
||||
chooseImagesUploadSuccess.postValue(map)
|
||||
|
||||
for (error in errorMap.values) {
|
||||
if (error is HttpException && error.code() == 403) {
|
||||
Utils.toast(getApplication(), errorSize.toString() + "张违规图片上传失败")
|
||||
return
|
||||
}
|
||||
}
|
||||
Utils.toast(getApplication(), errorSize.toString() + "张图片上传失败")
|
||||
}
|
||||
}
|
||||
|
||||
override fun onError(errorMap: Map<String, Exception>) {
|
||||
val errorSize = pictureList.size
|
||||
if (errorSize > 0) {
|
||||
val map = LinkedHashMap<String, String>()
|
||||
for (key in errorMap.keys) {
|
||||
map[MD5Utils.getUrlMD5(key)] = ""
|
||||
}
|
||||
//value为空会删除PlaceholderImage
|
||||
chooseImagesUploadSuccess.postValue(map)
|
||||
}
|
||||
|
||||
for (error in errorMap.values) {
|
||||
if (error is HttpException && error.code() == 403) {
|
||||
val e = error.response()?.errorBody()?.string()?.toObject<ErrorEntity>()
|
||||
if (e != null && e.code == 403017) {
|
||||
Utils.toast(
|
||||
getApplication(),
|
||||
errorSize.toString() + "张图片的宽或高超过限制,请裁剪后上传"
|
||||
)
|
||||
} else {
|
||||
Utils.toast(getApplication(), errorSize.toString() + "张违规图片上传失败")
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
if (errorSize == 1) {
|
||||
Utils.toast(getApplication(), "图片上传失败")
|
||||
} else {
|
||||
Utils.toast(getApplication(), errorSize.toString() + "张图片上传失败")
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fun uploadPoster(picturePath: String) {
|
||||
processDialog.postValue(WaitingDialogFragment.WaitingDialogData("封面上传中...", true))
|
||||
uploadImageSubscription =
|
||||
UploadImageUtils.compressAndUploadImage(UploadImageUtils.UploadType.poster,
|
||||
picturePath,
|
||||
false,
|
||||
object : UploadImageUtils.OnUploadImageListener {
|
||||
override fun onSuccess(imageUrl: String) {
|
||||
patchVideoPoster(imageUrl)
|
||||
}
|
||||
|
||||
override fun onError(e: Throwable?) {
|
||||
handleUploadPosterResult(true)
|
||||
}
|
||||
|
||||
override fun onProgress(total: Long, progress: Long) {
|
||||
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
private fun patchVideoPoster(poster: String) {
|
||||
if (id.isEmpty() || videoId.isEmpty()) return
|
||||
val map = hashMapOf("poster" to poster, "type" to getVideoType())
|
||||
mApi.patchInsertVideo(videoId, map.toRequestBody())
|
||||
.compose(observableToMain())
|
||||
.subscribe(object : Response<ResponseBody>() {
|
||||
override fun onResponse(response: ResponseBody?) {
|
||||
super.onResponse(response)
|
||||
mUploadVideoListener?.changePoster(id, poster)
|
||||
handleUploadPosterResult(false)
|
||||
}
|
||||
|
||||
override fun onFailure(e: HttpException?) {
|
||||
super.onFailure(e)
|
||||
handleUploadPosterResult(true)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
private fun handleUploadPosterResult(isFailure: Boolean = false) {
|
||||
processDialog.postValue(WaitingDialogFragment.WaitingDialogData("封面上传中...", false))
|
||||
if (isFailure) {
|
||||
ToastUtils.showToast("封面更改失败")
|
||||
}
|
||||
id = ""
|
||||
videoId = ""
|
||||
}
|
||||
|
||||
fun deleteVideo(id: String) {
|
||||
if (localVideoList.isNotEmpty()) {
|
||||
val video = localVideoList.find { it.id == id }
|
||||
if (video != null) {
|
||||
if (UploadManager.isUploading(video.filePath)) {
|
||||
UploadManager.cancelTask(video.filePath)
|
||||
}
|
||||
localVideoList.remove(video)
|
||||
}
|
||||
}
|
||||
if (uploadVideoErrorList.isNotEmpty()) {
|
||||
val video = uploadVideoErrorList.find { it.id == id }
|
||||
if (video != null) {
|
||||
uploadVideoErrorList.remove(video)
|
||||
}
|
||||
}
|
||||
if (currentUploadingVideo?.id == id) {
|
||||
currentUploadingVideo = null
|
||||
uploadVideo()
|
||||
}
|
||||
}
|
||||
|
||||
fun uploadVideo() {
|
||||
if (currentUploadingVideo != null) return
|
||||
if (localVideoList.isEmpty()) return
|
||||
currentUploadingVideo = localVideoList[0]
|
||||
UploadManager.createUploadTask(currentUploadingVideo?.filePath
|
||||
?: "", object : OnUploadListener {
|
||||
override fun onProgressChanged(
|
||||
uploadFilePath: String,
|
||||
currentSize: Long,
|
||||
totalSize: Long,
|
||||
speed: Long
|
||||
) {
|
||||
runOnUiThread {
|
||||
val percent = (currentSize * 100 / totalSize.toFloat()).roundTo(1)
|
||||
currentUploadingVideo?.id?.let {
|
||||
mUploadVideoListener?.updateVideoProgress(it, percent.toString())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onUploadSuccess(uploadFilePath: String, url: String) {
|
||||
if (currentUploadingVideo != null) {
|
||||
postVideoPosterAndInfo(uploadFilePath, url)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onUploadFailure(uploadFilePath: String, errorMsg: String) {
|
||||
uploadVideoFailure()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
private fun postVideoPosterAndInfo(uploadFilePath: String, url: String) {
|
||||
val localVideoPoster =
|
||||
getApplication<Application>().cacheDir.absolutePath + File.separator + System.currentTimeMillis() + ".jpg"
|
||||
try {
|
||||
val bmp = ThumbnailUtils.createVideoThumbnail(
|
||||
uploadFilePath,
|
||||
MediaStore.Images.Thumbnails.MINI_KIND
|
||||
)
|
||||
// bmp 可能为空
|
||||
FileOutputStream(localVideoPoster).use { out ->
|
||||
bmp?.compress(Bitmap.CompressFormat.PNG, 100, out)
|
||||
}
|
||||
} catch (e: java.lang.Exception) {
|
||||
e.printStackTrace()
|
||||
ToastUtils.showToast("视频封面操作失败")
|
||||
uploadVideoFailure()
|
||||
return
|
||||
}
|
||||
uploadImageSubscription =
|
||||
UploadImageUtils.compressAndUploadImage(UploadImageUtils.UploadType.poster,
|
||||
localVideoPoster,
|
||||
false,
|
||||
object : UploadImageUtils.OnUploadImageListener {
|
||||
override fun onSuccess(imageUrl: String) {
|
||||
postVideoInfo(url, imageUrl)
|
||||
}
|
||||
|
||||
override fun onError(e: Throwable?) {
|
||||
uploadVideoFailure()
|
||||
}
|
||||
|
||||
override fun onProgress(total: Long, progress: Long) {
|
||||
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
private fun postVideoInfo(url: String, poster: String) {
|
||||
val map = HashMap<String, Any>().apply {
|
||||
put("poster", poster)
|
||||
put("url", url)
|
||||
put("format", currentUploadingVideo?.format ?: "")
|
||||
put("size", currentUploadingVideo?.size ?: 0)
|
||||
put("length", (currentUploadingVideo?.duration ?: 0) / 1000)
|
||||
put("type", getVideoType())
|
||||
}
|
||||
val requestBody = map.toRequestBody()
|
||||
mApi.insertVideo(requestBody)
|
||||
.compose(observableToMain())
|
||||
.subscribe(object : Response<JsonObject>() {
|
||||
override fun onResponse(response: JsonObject?) {
|
||||
super.onResponse(response)
|
||||
if (response != null) {
|
||||
uploadVideoSuccess(poster, url, response)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onFailure(e: HttpException?) {
|
||||
super.onFailure(e)
|
||||
uploadVideoFailure()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
private fun uploadVideoSuccess(poster: String, url: String, data: JsonObject) {
|
||||
processDialog.postValue(WaitingDialogFragment.WaitingDialogData("封面上传中...", false))
|
||||
currentUploadingVideo?.let {
|
||||
mUploadVideoListener?.changePoster(it.id, poster)
|
||||
mUploadVideoListener?.videoUploadFinished(it.id, url, data)
|
||||
UploadManager.cancelTask(it.filePath)
|
||||
localVideoList.remove(it)
|
||||
}
|
||||
currentUploadingVideo = null
|
||||
uploadVideo()
|
||||
}
|
||||
|
||||
private fun uploadVideoFailure() {
|
||||
processDialog.postValue(WaitingDialogFragment.WaitingDialogData("封面上传中...", false))
|
||||
currentUploadingVideo?.let {
|
||||
runOnUiThread {
|
||||
mUploadVideoListener?.videoUploadFailed(it.id)
|
||||
}
|
||||
uploadVideoErrorList.add(it)
|
||||
localVideoList.remove(it)
|
||||
UploadManager.cancelTask(it.filePath)
|
||||
}
|
||||
currentUploadingVideo = null
|
||||
uploadVideo()
|
||||
}
|
||||
|
||||
fun checkIsAllUploadedAndToast(): Boolean {
|
||||
if (localVideoList.isNotEmpty() || uploadVideoErrorList.isNotEmpty()) {
|
||||
ToastUtils.showToast("视频未上传完成,视频内容保存失败")
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
private fun getVideoType(): String {
|
||||
return when (type) {
|
||||
BbsType.GAME_BBS.value -> {
|
||||
when (getRichType()) {
|
||||
RichType.ARTICLE -> BbsType.GAME_BBS_ARTICLE_INSERT.value
|
||||
RichType.QUESTION -> BbsType.GAME_BBS_QUESTION_INSERT.value
|
||||
else -> ""
|
||||
}
|
||||
}
|
||||
BbsType.OFFICIAL_BBS.value -> {
|
||||
when (getRichType()) {
|
||||
RichType.ARTICLE -> BbsType.OFFICIAL_BBS_ARTICLE_INSERT.value
|
||||
RichType.QUESTION -> BbsType.OFFICIAL_BBS_QUESTION_INSERT.value
|
||||
else -> ""
|
||||
}
|
||||
}
|
||||
else -> ""
|
||||
}
|
||||
}
|
||||
|
||||
abstract fun getRichType(): RichType
|
||||
}
|
||||
|
||||
interface UploadVideoListener {
|
||||
/**
|
||||
* 插入视频占位图
|
||||
*/
|
||||
fun insertPlaceholderVideo(id: String, poster: String)
|
||||
|
||||
/**
|
||||
* 更新视频进度条
|
||||
*/
|
||||
fun updateVideoProgress(id: String, progress: String)
|
||||
|
||||
/**
|
||||
* 上传视频完成
|
||||
*/
|
||||
fun videoUploadFinished(id: String, url: String, msg: JsonObject)
|
||||
|
||||
/**
|
||||
* 更换封面图
|
||||
*/
|
||||
fun changePoster(id: String, poster: String)
|
||||
|
||||
/**
|
||||
* 上传失败
|
||||
*/
|
||||
fun videoUploadFailed(id: String)
|
||||
}
|
||||
|
||||
enum class RichType {
|
||||
ARTICLE,
|
||||
QUESTION,
|
||||
ANSWER
|
||||
}
|
||||
@ -1,77 +0,0 @@
|
||||
package com.gh.base;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Application.ActivityLifecycleCallbacks;
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.gh.common.notifier.Notifier;
|
||||
import com.gh.common.util.DataUtils;
|
||||
import com.gh.download.DownloadManager;
|
||||
import com.halo.assistant.HaloApp;
|
||||
import com.lightgame.utils.AppManager;
|
||||
|
||||
/**
|
||||
* 1、写点针对生命周期的统计代码
|
||||
* 2、写点通用的逻辑
|
||||
* 3、接口解耦
|
||||
*
|
||||
* @author CsHeng
|
||||
* @Date 09/05/2017
|
||||
* @Time 6:22 PM
|
||||
*/
|
||||
public class GHActivityLifecycleCallbacksImpl implements ActivityLifecycleCallbacks {
|
||||
|
||||
@Override
|
||||
public void onActivityCreated(Activity activity, Bundle savedInstanceState) {
|
||||
|
||||
AppManager.getInstance().addActivity(activity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityStarted(Activity activity) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityResumed(Activity activity) {
|
||||
CurrentActivityHolder.getActivitySet().add(activity);
|
||||
|
||||
if (HaloApp.isUserAcceptPrivacyPolicy(activity)) {
|
||||
DataUtils.onResume(activity);
|
||||
//FIXME 这里应该只是部分Activity需要
|
||||
try {
|
||||
// 初始化gameMap
|
||||
DownloadManager.getInstance(activity).initGameMap();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityPaused(Activity activity) {
|
||||
CurrentActivityHolder.getActivitySet().remove(activity);
|
||||
|
||||
if (HaloApp.isUserAcceptPrivacyPolicy(activity)) {
|
||||
DataUtils.onPause(activity);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityStopped(Activity activity) {
|
||||
Notifier.hide();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivitySaveInstanceState(Activity activity, Bundle outState) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityDestroyed(Activity activity) {
|
||||
if (activity.isFinishing()) {
|
||||
AppManager.getInstance().finishActivity(activity);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
17
app/src/main/java/com/gh/base/GHThreadFactory.kt
Normal file
17
app/src/main/java/com/gh/base/GHThreadFactory.kt
Normal file
@ -0,0 +1,17 @@
|
||||
package com.gh.base
|
||||
|
||||
import java.util.concurrent.ThreadFactory
|
||||
import java.util.concurrent.atomic.AtomicInteger
|
||||
|
||||
class GHThreadFactory(threadNamePrefix: String) : ThreadFactory {
|
||||
|
||||
private val THREAD_NAME_STEM = "${threadNamePrefix}_%d"
|
||||
private val mThreadId = AtomicInteger(0)
|
||||
|
||||
override fun newThread(r: Runnable?): Thread {
|
||||
val t = Thread(r)
|
||||
t.name = String.format(THREAD_NAME_STEM, mThreadId.getAndIncrement())
|
||||
return t
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,95 @@
|
||||
package com.gh.base
|
||||
|
||||
import android.app.Activity
|
||||
import android.app.Application
|
||||
import android.os.Bundle
|
||||
import com.gh.common.notifier.Notifier
|
||||
import com.gh.common.util.DataUtils
|
||||
import com.gh.common.util.FloatingBackViewManager
|
||||
import com.gh.download.DownloadManager
|
||||
import com.gh.gamecenter.MainActivity
|
||||
import com.gh.gamecenter.SplashScreenActivity
|
||||
import com.gh.gamecenter.energy.EnergyCenterActivity
|
||||
import com.gh.gamecenter.forum.detail.ForumDetailActivity
|
||||
import com.gh.gamecenter.forum.list.ForumListActivity
|
||||
import com.gh.gamecenter.qa.article.detail.ArticleDetailActivity
|
||||
import com.gh.gamecenter.qa.questions.newdetail.NewQuestionDetailActivity
|
||||
import com.gh.gamecenter.qa.video.detail.ForumVideoDetailActivity
|
||||
import com.halo.assistant.HaloApp
|
||||
import com.lightgame.utils.AppManager
|
||||
|
||||
class GlobalActivityLifecycleObserver : Application.ActivityLifecycleCallbacks {
|
||||
|
||||
override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) {
|
||||
AppManager.getInstance().addActivity(activity)
|
||||
}
|
||||
|
||||
override fun onActivityStarted(activity: Activity) {
|
||||
|
||||
}
|
||||
|
||||
override fun onActivityResumed(activity: Activity) {
|
||||
CurrentActivityHolder.activitySet.add(activity)
|
||||
|
||||
// 判断是否需要显示或隐藏返回小浮窗
|
||||
if (FloatingBackViewManager.getType().isNotEmpty()) {
|
||||
if (activity is EnergyCenterActivity
|
||||
&& FloatingBackViewManager.getType() == FloatingBackViewManager.TYPE_TASK
|
||||
) {
|
||||
FloatingBackViewManager.disableBackView()
|
||||
} else if (!shouldShowActivityBackView(activity)
|
||||
&& FloatingBackViewManager.getType() == FloatingBackViewManager.TYPE_ACTIVITY
|
||||
) {
|
||||
FloatingBackViewManager.disableBackView()
|
||||
} else {
|
||||
FloatingBackViewManager.showBackView(activity)
|
||||
}
|
||||
}
|
||||
|
||||
if (HaloApp.isUserAcceptPrivacyPolicy(activity)) {
|
||||
DataUtils.onResume(activity)
|
||||
// FIXME 这里应该只是部分Activity需要
|
||||
try {
|
||||
// 初始化gameMap
|
||||
if (activity !is SplashScreenActivity) {
|
||||
DownloadManager.getInstance(activity).initGameMap()
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun shouldShowActivityBackView(activity: Activity): Boolean {
|
||||
return (activity is MainActivity
|
||||
|| activity is ArticleDetailActivity
|
||||
|| activity is ForumVideoDetailActivity
|
||||
|| activity is ForumDetailActivity
|
||||
|| activity is ForumListActivity
|
||||
|| activity is NewQuestionDetailActivity)
|
||||
}
|
||||
|
||||
override fun onActivityPaused(activity: Activity) {
|
||||
CurrentActivityHolder.activitySet.remove(activity)
|
||||
FloatingBackViewManager.dismissBackView(activity)
|
||||
|
||||
if (HaloApp.isUserAcceptPrivacyPolicy(activity)) {
|
||||
DataUtils.onPause(activity)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onActivityStopped(activity: Activity) {
|
||||
Notifier.hide()
|
||||
}
|
||||
|
||||
override fun onActivitySaveInstanceState(activity: Activity, outState: Bundle) {
|
||||
|
||||
}
|
||||
|
||||
override fun onActivityDestroyed(activity: Activity) {
|
||||
if (activity.isFinishing) {
|
||||
AppManager.getInstance().finishActivity(activity)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -9,6 +9,8 @@ import com.gh.gamecenter.R;
|
||||
import com.lightgame.utils.RuntimeUtils;
|
||||
import com.lightgame.utils.Utils;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.StringRes;
|
||||
@ -29,7 +31,7 @@ public class BaseDialogFragment extends DialogFragment {
|
||||
@NonNull
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
final Dialog dialog = new Dialog(getActivity(), R.style.DialogWindowTransparent);
|
||||
final Dialog dialog = new Dialog(getActivity(), getThemeRes());
|
||||
dialog.setCanceledOnTouchOutside(false);
|
||||
dialog.setOnKeyListener((dialog1, keyCode, event) -> {
|
||||
if (keyCode == KeyEvent.KEYCODE_BACK && !ClickUtils.isFastDoubleClick()) {
|
||||
@ -41,6 +43,10 @@ public class BaseDialogFragment extends DialogFragment {
|
||||
return dialog;
|
||||
}
|
||||
|
||||
public int getThemeRes() {
|
||||
return R.style.DialogWindowTransparent;
|
||||
}
|
||||
|
||||
public void toast(@StringRes int res) {
|
||||
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED))
|
||||
toast(getString(res));
|
||||
@ -71,7 +77,22 @@ public class BaseDialogFragment extends DialogFragment {
|
||||
transaction.show(fragment);
|
||||
transaction.commit();
|
||||
} else {
|
||||
super.show(manager, tag);
|
||||
try {
|
||||
Class<?> clazz = DialogFragment.class;
|
||||
Field dismissed = clazz.getDeclaredField("mDismissed");
|
||||
dismissed.setAccessible(true);
|
||||
dismissed.set(this, false);
|
||||
|
||||
Field shownByMe = clazz.getDeclaredField("mShownByMe");
|
||||
shownByMe.setAccessible(true);
|
||||
shownByMe.set(this, true);
|
||||
FragmentTransaction transaction = manager.beginTransaction();
|
||||
transaction.add(this, tag);
|
||||
transaction.commitAllowingStateLoss();
|
||||
} catch (Exception e) {
|
||||
super.show(manager, tag);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -61,6 +61,8 @@ public abstract class BaseFragment<T> extends Fragment implements OnRequestCallB
|
||||
@NonNull
|
||||
protected String mEntrance = "";
|
||||
|
||||
public long startPageTime = 0;
|
||||
|
||||
protected final Handler mBaseHandler = new BaseFragment.BaseHandler(this);
|
||||
|
||||
protected static class BaseHandler extends Handler {
|
||||
@ -140,9 +142,8 @@ public abstract class BaseFragment<T> extends Fragment implements OnRequestCallB
|
||||
EventBus.getDefault().register(this);
|
||||
|
||||
// For data binding.
|
||||
if (getInflatedLayout() != null) {
|
||||
mCachedView = getInflatedLayout();
|
||||
} else {
|
||||
mCachedView = getInflatedLayout();
|
||||
if (mCachedView == null) {
|
||||
mCachedView = View.inflate(getContext(), getLayoutId(), null);
|
||||
}
|
||||
|
||||
@ -207,6 +208,10 @@ public abstract class BaseFragment<T> extends Fragment implements OnRequestCallB
|
||||
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
if (container != null) {
|
||||
container.removeView(mCachedView);
|
||||
// TODO 页面重建 (framgent 的重新获取) 有大问题,这里只是修修补补
|
||||
if (mCachedView != null && mCachedView.getParent() instanceof ViewGroup) {
|
||||
((ViewGroup) mCachedView.getParent()).removeView(mCachedView);
|
||||
}
|
||||
}
|
||||
return mCachedView;
|
||||
}
|
||||
@ -222,6 +227,7 @@ public abstract class BaseFragment<T> extends Fragment implements OnRequestCallB
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
isEverPause = false;
|
||||
startPageTime = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -11,12 +11,14 @@ package com.gh.base.fragment;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
|
||||
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;
|
||||
@ -53,19 +55,21 @@ public abstract class BaseFragment_ViewPager extends NormalFragment implements D
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
mFragmentsList = new ArrayList<>();
|
||||
initFragmentList(mFragmentsList);
|
||||
mAdapter = BaseFragmentPagerAdapter.newInstance(getChildFragmentManager(), mFragmentsList);
|
||||
final Bundle args = getArguments();
|
||||
if (args != null) {
|
||||
mCheckedIndex = args.getInt(ARGS_INDEX);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
mViewPager = (ViewPager) view.findViewById(getViewPagerId());
|
||||
mViewPager = view.findViewById(getViewPagerId());
|
||||
mFragmentsList = restoreFragments();
|
||||
if (mFragmentsList.size() == 0) {
|
||||
initFragmentList(mFragmentsList);
|
||||
}
|
||||
mAdapter = BaseFragmentPagerAdapter.newInstance(getChildFragmentManager(), mFragmentsList);
|
||||
final Bundle args = getArguments();
|
||||
if (args != null) {
|
||||
mCheckedIndex = args.getInt(ARGS_INDEX);
|
||||
}
|
||||
mViewPager.setOffscreenPageLimit(mFragmentsList.size());
|
||||
mViewPager.setAdapter(mAdapter);
|
||||
if (mCheckedIndex < mFragmentsList.size()) {
|
||||
@ -116,9 +120,24 @@ public abstract class BaseFragment_ViewPager extends NormalFragment implements D
|
||||
fragment.onActivityResult(requestCode, resultCode, data);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public ArrayList<Fragment> restoreFragments() {
|
||||
String tag = "android:switcher:" + mViewPager.getId() + ":";
|
||||
ArrayList<Fragment> fragments = new ArrayList<>();
|
||||
int childCount = getChildCount();
|
||||
for (int index = 0; index < childCount; index++) {
|
||||
Fragment fragment = getChildFragmentManager().findFragmentByTag(tag + index);
|
||||
if (fragment != null) {
|
||||
fragments.add(fragment);
|
||||
}
|
||||
}
|
||||
|
||||
return fragments;
|
||||
}
|
||||
|
||||
public abstract int getChildCount();
|
||||
|
||||
public int getCurrentItem() {
|
||||
return mViewPager != null ? mViewPager.getCurrentItem() : 0;
|
||||
}
|
||||
|
||||
@ -2,7 +2,6 @@ package com.gh.base.fragment
|
||||
|
||||
import android.os.Bundle
|
||||
import com.gh.gamecenter.normal.NormalFragment
|
||||
import com.lightgame.utils.Utils
|
||||
|
||||
/**
|
||||
* 懒加载(支持多层嵌套)
|
||||
@ -105,15 +104,25 @@ abstract class BaseLazyFragment : NormalFragment() {
|
||||
isSupportVisible = visible
|
||||
|
||||
if (visible) {
|
||||
if (mIsFirstVisible && view != null) {
|
||||
|
||||
// TODO 当 fragment 重建时这里的被调用很奇怪,onActivityCreated 回调触发,但此时的 view 是空的,原因是 createView 还没被调用
|
||||
// TODO 这样就造成了 onFragmentResume 里可能用到 view 的地方出现空指针异常,所以这里遇到 view 为空的时候 return 等下一次被调用才进去
|
||||
if (view == null) {
|
||||
return
|
||||
}
|
||||
|
||||
if (mIsFirstVisible) {
|
||||
mIsFirstVisible = false
|
||||
onFragmentFirstVisible()
|
||||
}
|
||||
onFragmentResume()
|
||||
dispatchChildVisibleState(true)
|
||||
} else {
|
||||
dispatchChildVisibleState(false)
|
||||
onFragmentPause()
|
||||
// 当 fragment 重建时,这个代码块可能在第一次 view 为空的 visible 后调用导致在 onFragmentPause 里可能用到 view 的地方出现空指针异常
|
||||
if (!mIsFirstVisible) {
|
||||
dispatchChildVisibleState(false)
|
||||
onFragmentPause()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
68
app/src/main/java/com/gh/base/fragment/LazyFragment.kt
Normal file
68
app/src/main/java/com/gh/base/fragment/LazyFragment.kt
Normal file
@ -0,0 +1,68 @@
|
||||
package com.gh.base.fragment
|
||||
|
||||
import android.view.View
|
||||
import android.view.ViewStub
|
||||
import com.gh.gamecenter.R
|
||||
|
||||
/**
|
||||
* 这是在 BaseLazyFragment 之上添加了一些通用功能的抽象类
|
||||
*
|
||||
* 怎么将一个已有的 fragment 转化为懒加载 (延迟渲染) 的 fragment 呢?
|
||||
* (继承 ListFragment 的类请改为继承 LazyListFragment)
|
||||
*
|
||||
* 0. 删掉旧的 getInflatedLayout() 的代码,现在由 getLayoutId() 提供 Stub 布局 (默认为 R.layout.fragment_stub,若重写请注意提供 id 为 stub 的 ViewStub)
|
||||
* 1. 重写 getRealLayoutId(),提供实际要延迟渲染的 layout Id
|
||||
* 1. 将原有在 onCreate() 的代码移动到 onFragmentFirstVisible()
|
||||
* 2. 将原有在 onViewCreated() 的代码移动到 initRealView()
|
||||
* (注意,initRealView() 在 onFragmentFirstVisible() 中被调用,如果要初始化 viewModel 等非 UI 对象请在 super.onFragmentVisible() 调用)
|
||||
* 3. 如需使用 ViewBinding ,在 onRealLayoutInflated() 的回调中初始化 ViewBinding 即可
|
||||
* 4. onResume() 的代码移动到 onFragmentResume(),onPause() 的代码移动到 onFragmentPause()
|
||||
* 5. Done!
|
||||
*/
|
||||
abstract class LazyFragment : BaseLazyFragment() {
|
||||
|
||||
// ViewStub + ViewBinding 有莫名的 bug,语法上没问题,但编译时通不过。
|
||||
private var mViewStub: ViewStub? = null
|
||||
|
||||
override fun getLayoutId() = R.layout.fragment_stub
|
||||
|
||||
override fun useButterKnife() = false
|
||||
|
||||
override fun initView(view: View?) {
|
||||
super.initView(view)
|
||||
mViewStub = mCachedView.findViewById(R.id.stub)
|
||||
}
|
||||
|
||||
override fun onFragmentFirstVisible() {
|
||||
super.onFragmentFirstVisible()
|
||||
inflateRealView()
|
||||
initRealView()
|
||||
}
|
||||
|
||||
/**
|
||||
* 真正 inflate View 的地方
|
||||
*/
|
||||
protected open fun inflateRealView() {
|
||||
mViewStub?.layoutResource = getRealLayoutId()
|
||||
mViewStub?.setOnInflateListener { _, inflatedView -> onRealLayoutInflated(inflatedView) }
|
||||
mCachedView = mViewStub?.inflate()
|
||||
}
|
||||
|
||||
/**
|
||||
* 请在这个方法之后获取初始化后的各种 view
|
||||
*
|
||||
* 替换旧 fragment 实现时,等同于 onViewCreated
|
||||
*/
|
||||
protected open fun initRealView() {}
|
||||
|
||||
/**
|
||||
* 提供要 stub inflate 的 layout
|
||||
*/
|
||||
protected abstract fun getRealLayoutId(): Int
|
||||
|
||||
/**
|
||||
* 真实 layout inflate 完成的回调,可用于 viewBinding
|
||||
*/
|
||||
protected open fun onRealLayoutInflated(inflatedView: View) {}
|
||||
|
||||
}
|
||||
@ -10,6 +10,7 @@ import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
|
||||
import com.gh.common.util.ExtensionsKt;
|
||||
import com.gh.gamecenter.R;
|
||||
|
||||
/**
|
||||
@ -87,7 +88,11 @@ public class WaitingDialogFragment extends BaseDialogFragment {
|
||||
@Override
|
||||
public void dismissAllowingStateLoss() {
|
||||
mBackListener = null;
|
||||
super.dismissAllowingStateLoss();
|
||||
try {
|
||||
super.dismissAllowingStateLoss();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static class WaitingDialogData {
|
||||
|
||||
@ -2,12 +2,13 @@ package com.gh.common
|
||||
|
||||
import android.os.Handler
|
||||
import android.os.Looper
|
||||
import com.gh.base.GHThreadFactory
|
||||
import com.gh.common.AppExecutor.ioExecutor
|
||||
import com.gh.common.AppExecutor.lightWeightIoExecutor
|
||||
import com.gh.common.AppExecutor.logExecutor
|
||||
import com.gh.common.AppExecutor.uiExecutor
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
import java.util.concurrent.Executor
|
||||
import java.util.concurrent.Executors
|
||||
import java.util.concurrent.*
|
||||
|
||||
/**
|
||||
* APP 线程池管理类
|
||||
@ -15,16 +16,32 @@ import java.util.concurrent.Executors
|
||||
* [ioExecutor] 是一个最大线程数固定的线程池,较为繁重的 IO 任务可以交给它
|
||||
* [uiExecutor] 是主线程的包裹,需要切换至主线程执行可以用它
|
||||
* [lightWeightIoExecutor] 是一个单线程的线程池,轻量级且需要保证同一线程的 IO 任务可以交给它
|
||||
*
|
||||
* [logExecutor] 只为上传 log 而使用的线程池
|
||||
*/
|
||||
object AppExecutor {
|
||||
|
||||
private val mCoreSize = Runtime.getRuntime().availableProcessors()
|
||||
private val mMinimumPoolSize = 16.coerceAtLeast(mCoreSize * 4)
|
||||
private val mMaximumPoolSize = 64.coerceAtLeast(mCoreSize * 16)
|
||||
|
||||
// TODO 因为 LinkedBlockingQueue 过大导致 MaximumPoolSize 的值几乎无效,下版本改造 [PackageRepository] 启动请求一堆游戏摘要信息的接口?
|
||||
|
||||
@JvmStatic
|
||||
val uiExecutor by lazy { MainThreadExecutor() }
|
||||
|
||||
@JvmStatic
|
||||
val lightWeightIoExecutor by lazy { Executors.newSingleThreadExecutor() }
|
||||
val lightWeightIoExecutor by lazy { Executors.newSingleThreadExecutor(GHThreadFactory("GH_LIGHT_WEIGHT_IO_THREAD")) }
|
||||
|
||||
@JvmStatic
|
||||
val ioExecutor = Executors.newCachedThreadPool() // 用 by lazy 可能影响初始化速度
|
||||
val logExecutor by lazy { Executors.newSingleThreadExecutor(GHThreadFactory("GH_LOG_THREAD")) }
|
||||
|
||||
@JvmStatic
|
||||
val ioExecutor = ThreadPoolExecutor(
|
||||
mMinimumPoolSize,
|
||||
mMaximumPoolSize,
|
||||
20L, TimeUnit.SECONDS,
|
||||
LinkedBlockingQueue<Runnable>(1000),
|
||||
GHThreadFactory("GH_IO_THREAD"))
|
||||
|
||||
val cachedScheduler by lazy { Schedulers.from(ioExecutor) }
|
||||
|
||||
|
||||
@ -3,21 +3,28 @@ package com.gh.common
|
||||
import android.annotation.SuppressLint
|
||||
import android.app.Activity
|
||||
import android.content.Context
|
||||
import android.util.Base64
|
||||
import android.webkit.JavascriptInterface
|
||||
import androidx.annotation.Keep
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import com.gh.base.CurrentActivityHolder
|
||||
import com.gh.common.constant.Constants
|
||||
import com.gh.common.loghub.LoghubUtils
|
||||
import com.gh.common.tracker.Tracker
|
||||
import com.gh.common.util.*
|
||||
import com.gh.common.view.dsbridge.CompletionHandler
|
||||
import com.gh.gamecenter.BuildConfig
|
||||
import com.gh.gamecenter.ImageViewerActivity
|
||||
import com.gh.gamecenter.LoginActivity
|
||||
import com.gh.gamecenter.WebActivity
|
||||
import com.gh.gamecenter.energy.EnergyCenterActivity
|
||||
import com.gh.gamecenter.energy.EnergyHouseActivity
|
||||
import com.gh.gamecenter.entity.Badge
|
||||
import com.gh.gamecenter.entity.MtaEvent
|
||||
import com.gh.gamecenter.entity.NotificationUgc
|
||||
import com.gh.gamecenter.help.QaFeedbackDialogFragment
|
||||
import com.gh.gamecenter.manager.UserManager
|
||||
import com.gh.gamecenter.personalhome.border.AvatarBorderActivity
|
||||
import com.gh.gamecenter.retrofit.BiResponse
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager
|
||||
import com.gh.gamecenter.security.BindPhoneActivity
|
||||
@ -30,11 +37,16 @@ import io.reactivex.schedulers.Schedulers
|
||||
import okhttp3.ResponseBody
|
||||
import org.json.JSONObject
|
||||
import retrofit2.HttpException
|
||||
import java.io.BufferedOutputStream
|
||||
import java.io.File
|
||||
import java.io.FileOutputStream
|
||||
import java.util.*
|
||||
import kotlin.collections.ArrayList
|
||||
|
||||
class DefaultJsApi(var context: Context) {
|
||||
|
||||
private var mLoginHandler: CompletionHandler<Any>? = null
|
||||
|
||||
@JavascriptInterface
|
||||
fun isGhzs(msg: Any): String {
|
||||
return "true"
|
||||
@ -64,8 +76,12 @@ class DefaultJsApi(var context: Context) {
|
||||
|
||||
@JavascriptInterface
|
||||
fun login(msg: Any) {
|
||||
val intent = LoginActivity.getIntent(context, "浏览器")
|
||||
context.startActivity(intent)
|
||||
if (SPUtils.getBoolean(Constants.SP_HAS_GET_PHONE_INFO) || NetworkUtils.isOpenMobileData(context)) {
|
||||
QuickLoginHelper.startLogin(context, "浏览器")
|
||||
} else {
|
||||
val intent = LoginActivity.getIntent(context, "浏览器")
|
||||
context.startActivity(intent)
|
||||
}
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
@ -115,6 +131,7 @@ class DefaultJsApi(var context: Context) {
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(object : BiResponse<ResponseBody>() {
|
||||
override fun onSuccess(data: ResponseBody) {
|
||||
EnergyTaskHelper.postEnergyTask("bind_wechat")
|
||||
handler.complete(true)
|
||||
}
|
||||
|
||||
@ -198,6 +215,7 @@ class DefaultJsApi(var context: Context) {
|
||||
@JavascriptInterface
|
||||
fun updateRegulationTestStatus(msg: Any) {
|
||||
if (msg.toString().toLowerCase(Locale.getDefault()) == "pass") {
|
||||
EnergyTaskHelper.postEnergyTask("finish_etiquette_exam")
|
||||
SPUtils.setString(Constants.SP_REGULATION_TEST_PASS_STATUS, "pass")
|
||||
}
|
||||
}
|
||||
@ -215,7 +233,7 @@ class DefaultJsApi(var context: Context) {
|
||||
|
||||
@JavascriptInterface
|
||||
fun showIncompatibleVersionDialog(msg: Any) {
|
||||
DialogUtils.showLowVersionDialog(context)
|
||||
DialogHelper.showUpgradeDialog(context)
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
@ -228,6 +246,20 @@ class DefaultJsApi(var context: Context) {
|
||||
MessageShareUtils.getInstance(context).shareFromWeb(context, imageShareEvent.type)
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
fun inviteFriends(event: Any) {
|
||||
val inviteEvent = event.toString().toObject() ?: InviteFriendsEvent()
|
||||
val context = CurrentActivityHolder.getCurrentActivity()
|
||||
if ("poster" == inviteEvent.type) {
|
||||
Base64ImageHolder.image = inviteEvent.poster.run {
|
||||
if (this.startsWith("data:image/png;base64")) this.split(",")[1] else this
|
||||
}
|
||||
MessageShareUtils.getInstance(context).shareInviteFriends(context, inviteEvent.way)
|
||||
} else {
|
||||
ShareUtils.getInstance(context).shareInviteFriends(context, inviteEvent.url, inviteEvent.way)
|
||||
}
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
fun bindPhone(msg: Any) {
|
||||
val intent = BindPhoneActivity.getNormalIntent(context, false)
|
||||
@ -257,10 +289,121 @@ class DefaultJsApi(var context: Context) {
|
||||
runOnUiThread { DirectUtils.directToWebView(context, url.toString(), "内部网页") }
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
fun postWearBadgeTask(msg: Any) {
|
||||
EnergyTaskHelper.postEnergyTask("wear_badge")
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
fun startEnergyCenter(msg: Any) {
|
||||
context.startActivity(EnergyCenterActivity.getIntent(context))
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
fun startEnergyHouse(msg: Any) {
|
||||
context.startActivity(EnergyHouseActivity.getIntent(context))
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
fun showQaFeedbackDialog(msg: Any) {
|
||||
QaFeedbackDialogFragment.show(context as AppCompatActivity, msg.toString())
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
fun getMetaObject(msg: Any): String {
|
||||
return LogUtils.getMetaObject().toString()
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
fun getLaunchId(msg: Any): String {
|
||||
return Tracker.launchId
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
fun getSessionId(msg: Any): String {
|
||||
return Tracker.sessionId
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
fun postLogEvent(event: Any) {
|
||||
val logEvent = event.toString().toObject() ?: LogEvent()
|
||||
debugOnly {
|
||||
Utils.log("LogUtils->${logEvent.jsonString}")
|
||||
}
|
||||
LoghubUtils.log(logEvent.jsonString, logEvent.logStore, false)
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
fun startAvatarBorderPage(msg: Any) {
|
||||
context.startActivity(AvatarBorderActivity.getIntent(context, msg.toString()))
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
fun isNetworkConnected(): Boolean {
|
||||
return NetworkUtils.isNetworkConnected(context)
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
fun isWifiConnected(): Boolean {
|
||||
return NetworkUtils.isWifiConnected(context)
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
fun enableBackToActivity(msg: Any) {
|
||||
FloatingBackViewManager.enableBackView(FloatingBackViewManager.TYPE_ACTIVITY, msg.toString())
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
fun startBBSStayTimeCount(msg: Any) {
|
||||
BbsStayTimeHelper.enableStayTimeCount(msg.toString().toInt())
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
fun saveBase64ImageToGallery(msg: Any) {
|
||||
val base64StringData = msg.toString()
|
||||
runOnIoThread {
|
||||
val base64String = base64StringData.replace("data:image/png;base64", "")
|
||||
tryWithDefaultCatch {
|
||||
val imageFile = File(HaloApp.getInstance().cacheDir.absolutePath + File.separator + System.currentTimeMillis() + ".png")
|
||||
val decodedString = Base64.decode(base64String, Base64.DEFAULT)
|
||||
val bos = BufferedOutputStream(FileOutputStream(imageFile))
|
||||
bos.write(decodedString)
|
||||
bos.flush()
|
||||
bos.close()
|
||||
|
||||
ImageUtils.saveImageToFile(imageFile, "", true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
fun loginWithCallback(msg: Any, handler: CompletionHandler<Any>) {
|
||||
mLoginHandler = handler
|
||||
login(msg)
|
||||
}
|
||||
|
||||
fun onLogin() {
|
||||
mLoginHandler?.complete(true)
|
||||
mLoginHandler = null
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
fun openInNewFullWebview(url: Any) {
|
||||
runOnUiThread { DirectUtils.directToFullScreenWebPage(context, url.toString(), true) }
|
||||
}
|
||||
|
||||
@Keep
|
||||
internal data class ImageEvent(var imageList: ArrayList<String> = arrayListOf(), var position: Int = 0)
|
||||
|
||||
@Keep
|
||||
internal data class ImageShareEvent(var image: String = "", var type: String = "")
|
||||
|
||||
@Keep
|
||||
internal data class InviteFriendsEvent(var type: String = "",
|
||||
var way: String = "",
|
||||
var url: String = "",
|
||||
var poster: String = "")
|
||||
|
||||
@Keep
|
||||
internal data class LogEvent(var jsonString: String = "", var logStore: String = "")
|
||||
}
|
||||
|
||||
@ -10,15 +10,16 @@ import com.gh.common.util.DirectUtils.directToFeedback
|
||||
import com.gh.common.util.DirectUtils.directToGameDetailVideoStreaming
|
||||
import com.gh.common.util.DirectUtils.directToGameServerCalendar
|
||||
import com.gh.common.util.DirectUtils.directToGameVideo
|
||||
import com.gh.common.util.DirectUtils.directToLegacyVideoDetail
|
||||
import com.gh.common.util.DirectUtils.directToLinkPage
|
||||
import com.gh.common.util.DirectUtils.directToQa
|
||||
import com.gh.common.util.DirectUtils.directToVideoDetail
|
||||
import com.gh.common.util.GsonUtils.gson
|
||||
import com.gh.gamecenter.LibaoDetailActivity
|
||||
import com.gh.gamecenter.MainActivity
|
||||
import com.gh.gamecenter.NewsDetailActivity
|
||||
import com.gh.gamecenter.WebActivity
|
||||
import com.gh.gamecenter.entity.*
|
||||
import com.gh.gamecenter.qa.BbsType
|
||||
import com.gh.gamecenter.qa.video.publish.VideoPublishActivity
|
||||
import com.gh.gamecenter.subject.SubjectActivity
|
||||
import com.gh.gamecenter.video.detail.VideoDetailContainerViewModel
|
||||
import com.lightgame.utils.Utils
|
||||
@ -63,9 +64,7 @@ object DefaultUrlHandler {
|
||||
}
|
||||
|
||||
"inurl" -> {
|
||||
intent = Intent(context, WebActivity::class.java)
|
||||
intent.putExtra(EntranceUtils.KEY_URL, uri.getQueryParameter("url"))
|
||||
context.startActivity(intent)
|
||||
DirectUtils.directToWebView(context, uri.getQueryParameter("url") ?: "")
|
||||
}
|
||||
|
||||
"outurl" -> {
|
||||
@ -141,7 +140,8 @@ object DefaultUrlHandler {
|
||||
}
|
||||
EntranceUtils.HOST_USERHOME -> {
|
||||
val position = uri.getQueryParameter("position")
|
||||
DirectUtils.directToHomeActivity(context, id, if (position.isNullOrEmpty()) -1 else position.toInt(), entrance, "")
|
||||
val subtype = uri.getQueryParameter("sub_type") ?: ""
|
||||
DirectUtils.directToHomeActivity(context, id, subtype, if (position.isNullOrEmpty()) -1 else position.toInt(), entrance, "")
|
||||
}
|
||||
EntranceUtils.HOST_VIDEO_MORE -> {
|
||||
val referer = uri.getQueryParameter("referer") ?: ""
|
||||
@ -159,11 +159,14 @@ object DefaultUrlHandler {
|
||||
} else {
|
||||
id
|
||||
}
|
||||
directToVideoDetail(context, id, location, false, gameId, entrance, "", referer, type, act, paginationType, fieldId, sectionName)
|
||||
directToLegacyVideoDetail(context, id, location, false, gameId, entrance, "", referer, type, act, paginationType, fieldId, sectionName)
|
||||
}
|
||||
EntranceUtils.HOST_VIDEO_DETAIL -> {
|
||||
DirectUtils.directToVideoDetail(context, id, entrance, path)
|
||||
}
|
||||
EntranceUtils.HOST_VIDEO_SINGLE -> {
|
||||
val referer = uri.getQueryParameter("referer") ?: ""
|
||||
directToVideoDetail(context, id, VideoDetailContainerViewModel.Location.SINGLE_VIDEO.value,
|
||||
DirectUtils.directToVideoDetail(context, id, VideoDetailContainerViewModel.Location.SINGLE_VIDEO.value,
|
||||
false, "", entrance, "", if (TextUtils.isEmpty(referer)) "" else referer)
|
||||
}
|
||||
EntranceUtils.HOST_VIDEO_STREAMING_HOME -> {
|
||||
@ -275,11 +278,39 @@ object DefaultUrlHandler {
|
||||
}
|
||||
|
||||
EntranceUtils.HOST_GAME_RATING_DETAIL -> {
|
||||
DirectUtils.directToGameRatingDetail(context, uri.getQueryParameter(EntranceUtils.KEY_GAME_ID), uri.getQueryParameter(EntranceUtils.KEY_COMMENT_ID), EntranceUtils.ENTRANCE_BROWSER)
|
||||
DirectUtils.directToGameRatingDetail(
|
||||
context,
|
||||
uri.getQueryParameter(EntranceUtils.KEY_GAME_ID),
|
||||
uri.getQueryParameter(EntranceUtils.KEY_COMMENT_ID),
|
||||
EntranceUtils.ENTRANCE_BROWSER)
|
||||
}
|
||||
|
||||
EntranceUtils.HOST_FORUM -> {
|
||||
DirectUtils.directToForum(context)
|
||||
val position = uri.getQueryParameter(EntranceUtils.KEY_POSITION)?.toInt()
|
||||
|
||||
DirectUtils.directToForum(context, position ?: 0)
|
||||
}
|
||||
|
||||
EntranceUtils.HOST_UPLOAD_VIDEO_NEW -> {
|
||||
val activityName = uri.getQueryParameter("activity_name") ?: ""
|
||||
val activityId = uri.getQueryParameter("activity_id") ?: ""
|
||||
val forumName = uri.getQueryParameter("forum_name") ?: ""
|
||||
val forumId = uri.getQueryParameter("forum_id") ?: ""
|
||||
val forumIcon = uri.getQueryParameter("forum_icon") ?: ""
|
||||
val forumType = uri.getQueryParameter("forum_type") ?: BbsType.OFFICIAL_BBS.value
|
||||
|
||||
val activityLabelEntity = ActivityLabelEntity(id = activityId, name = activityName)
|
||||
val communityEntity = CommunityEntity(id = forumId, name = forumName, icon = forumIcon)
|
||||
|
||||
context.startActivity(VideoPublishActivity.getIntent(
|
||||
context,
|
||||
communityEntity,
|
||||
activityLabelEntity,
|
||||
forumType,
|
||||
false,
|
||||
entrance,
|
||||
""
|
||||
))
|
||||
}
|
||||
|
||||
EntranceUtils.HOST_SUGGESTION -> {
|
||||
@ -287,6 +318,7 @@ object DefaultUrlHandler {
|
||||
val platformName = PlatformUtils.getInstance(context).getPlatformName(platform)
|
||||
val gameId = uri.getQueryParameter(EntranceUtils.KEY_GAMEID)
|
||||
val packageMd5 = uri.getQueryParameter(EntranceUtils.KEY_PACKAGE_MD5)
|
||||
val isQaFeedback = uri.getQueryParameter(EntranceUtils.KEY_IS_QA_FEEDBACK) == "true"
|
||||
val content = if (TextUtils.isEmpty(gameId) || TextUtils.isEmpty(packageMd5)) String.format("%s-%s-V%s,",
|
||||
uri.getQueryParameter(EntranceUtils.KEY_GAME_NAME),
|
||||
if (TextUtils.isEmpty(platformName)) platform else platformName,
|
||||
@ -299,7 +331,7 @@ object DefaultUrlHandler {
|
||||
if (!TextUtils.isEmpty(qaId)) {
|
||||
directToQa(context, qaTitle, qaId)
|
||||
} else {
|
||||
directToFeedback(context, content, EntranceUtils.ENTRANCE_BROWSER)
|
||||
directToFeedback(context, content, null, isQaFeedback, EntranceUtils.ENTRANCE_BROWSER)
|
||||
}
|
||||
}
|
||||
|
||||
@ -307,7 +339,7 @@ object DefaultUrlHandler {
|
||||
val position = uri.getQueryParameter("position") ?: ""
|
||||
DirectUtils.directToHelpAndFeedback(context, position.toInt())
|
||||
}
|
||||
else -> DialogUtils.showLowVersionDialog(context)
|
||||
else -> DialogHelper.showUpgradeDialog(context)
|
||||
}
|
||||
return true
|
||||
} else if ("zhiqu" == uri.scheme) {
|
||||
@ -344,6 +376,11 @@ object DefaultUrlHandler {
|
||||
return true
|
||||
}
|
||||
|
||||
// 处理内部页面逻辑
|
||||
if (transformNormalScheme(context, url, entrance)) {
|
||||
return true
|
||||
}
|
||||
|
||||
if ("http" != uri.scheme && "https" != uri.scheme) return true
|
||||
return false
|
||||
}
|
||||
@ -360,7 +397,8 @@ object DefaultUrlHandler {
|
||||
uri.path?.apply {
|
||||
when {
|
||||
contains("game") -> {
|
||||
val gameId = uri.getQueryParameter("gameId") ?: ""
|
||||
val gameId = uri.getQueryParameter("gameId") ?: uri.pathSegments.last()
|
||||
?: ""
|
||||
DirectUtils.directToGameDetail(context, gameId, entrance, autoDownload = false, traceEvent = null)
|
||||
}
|
||||
contains("question") -> {
|
||||
@ -372,11 +410,12 @@ object DefaultUrlHandler {
|
||||
DirectUtils.directToAnswerDetail(context, answerId, entrance, "")
|
||||
}
|
||||
}
|
||||
contains("communities") && contains("article") -> {
|
||||
((contains("bbs")) && contains("article") ||
|
||||
(contains("communities")) && contains("article")) -> {
|
||||
var communityId = ""
|
||||
var type = ""
|
||||
var typeId = ""
|
||||
val split = replace("/communities", "").replace(".html", "").split("/".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()
|
||||
val split = replace("/communities", "").replace("/bbs", "").replace(".html", "").split("/".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()
|
||||
for (text in split) {
|
||||
if (TextUtils.isEmpty(communityId)) {
|
||||
communityId = text
|
||||
@ -390,7 +429,7 @@ object DefaultUrlHandler {
|
||||
typeId = text
|
||||
}
|
||||
}
|
||||
if ("articles" == type) {
|
||||
if ("articles" == type || "article" == type) {
|
||||
DirectUtils.directToCommunityArticle(
|
||||
context, typeId, communityId,
|
||||
entrance, "文章链接")
|
||||
@ -398,7 +437,11 @@ object DefaultUrlHandler {
|
||||
}
|
||||
contains("article") -> {
|
||||
val articleId = split("/")[2].replace(".html", "")
|
||||
DirectUtils.directToArticle(context, articleId, entrance)
|
||||
if (entrance == "隐私政策") {
|
||||
DirectUtils.directToArticle(context, articleId, true, entrance)
|
||||
} else {
|
||||
DirectUtils.directToArticle(context, articleId, entrance)
|
||||
}
|
||||
}
|
||||
contains("columns") -> {
|
||||
val columnsId = split("/")[3]
|
||||
@ -406,10 +449,11 @@ object DefaultUrlHandler {
|
||||
val name = uri.getQueryParameter("communityName") ?: ""
|
||||
DirectUtils.directToCommunityColumn(context, CommunityEntity(id, name), columnsId, entrance, "")
|
||||
}
|
||||
contains("zone") -> {
|
||||
contains("zone") && split("/").size > 2 -> {
|
||||
val gameId = split("/")[2]
|
||||
DirectUtils.directGameZone(context, gameId, url, entrance)
|
||||
}
|
||||
else -> return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
|
||||
@ -11,6 +11,7 @@ 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
|
||||
import kotlin.concurrent.fixedRateTimer
|
||||
|
||||
object FixedRateJobHelper {
|
||||
@ -35,7 +36,7 @@ object FixedRateJobHelper {
|
||||
// 时间校对,10分钟一次
|
||||
if ((mExecuteCount * CHECKER_PERIOD) % TIME_PERIOD == 0L) {
|
||||
RetrofitManager.getInstance(HaloApp.getInstance().application).api.time
|
||||
.subscribeOn(AppExecutor.cachedScheduler)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.subscribe(object : Response<TimeEntity>() {
|
||||
override fun onResponse(response: TimeEntity?) {
|
||||
val serverTime = response?.time
|
||||
|
||||
@ -5,6 +5,7 @@ import android.app.Application
|
||||
import android.os.Bundle
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.FragmentManager
|
||||
import com.gh.base.GHThreadFactory
|
||||
import com.halo.assistant.HaloApp
|
||||
import java.util.concurrent.ExecutorService
|
||||
import java.util.concurrent.Executors
|
||||
@ -29,31 +30,31 @@ class TimeElapsedHelper(val fragment: Fragment?, val activity: Activity?) {
|
||||
|
||||
init {
|
||||
activity?.application?.registerActivityLifecycleCallbacks(object : Application.ActivityLifecycleCallbacks {
|
||||
override fun onActivityStarted(a: Activity?) {
|
||||
override fun onActivityStarted(a: Activity) {
|
||||
}
|
||||
|
||||
override fun onActivitySaveInstanceState(a: Activity?, outState: Bundle?) {
|
||||
override fun onActivitySaveInstanceState(a: Activity, outState: Bundle) {
|
||||
}
|
||||
|
||||
override fun onActivityStopped(a: Activity?) {
|
||||
override fun onActivityStopped(a: Activity) {
|
||||
}
|
||||
|
||||
override fun onActivityCreated(a: Activity?, savedInstanceState: Bundle?) {
|
||||
override fun onActivityCreated(a: Activity, savedInstanceState: Bundle?) {
|
||||
}
|
||||
|
||||
override fun onActivityPaused(a: Activity?) {
|
||||
override fun onActivityPaused(a: Activity) {
|
||||
if (activity == a) {
|
||||
pauseCounting()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onActivityResumed(a: Activity?) {
|
||||
override fun onActivityResumed(a: Activity) {
|
||||
if (activity == a) {
|
||||
resumeCounting()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onActivityDestroyed(a: Activity?) {
|
||||
override fun onActivityDestroyed(a: Activity) {
|
||||
if (activity == a) {
|
||||
HaloApp.getInstance().application.unregisterActivityLifecycleCallbacks(this)
|
||||
}
|
||||
@ -114,7 +115,7 @@ class TimeElapsedHelper(val fragment: Fragment?, val activity: Activity?) {
|
||||
}
|
||||
|
||||
object TimeElapsedThreadHolder {
|
||||
val threadService: ExecutorService by lazy { Executors.newSingleThreadExecutor() }
|
||||
val threadService: ExecutorService by lazy { Executors.newSingleThreadExecutor(GHThreadFactory("TIME_ELAPSED_THREAD")) }
|
||||
}
|
||||
|
||||
interface TimeoutCallback {
|
||||
|
||||
@ -2,6 +2,7 @@ package com.gh.common.constant;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Build;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.text.TextUtils;
|
||||
|
||||
@ -11,9 +12,11 @@ import com.gh.common.util.PackageUtils;
|
||||
import com.gh.common.util.SPUtils;
|
||||
import com.gh.gamecenter.BuildConfig;
|
||||
import com.gh.gamecenter.SuggestionActivity;
|
||||
import com.gh.gamecenter.entity.NewSettingsEntity;
|
||||
import com.gh.gamecenter.entity.NewsEntity;
|
||||
import com.gh.gamecenter.entity.SettingsEntity;
|
||||
import com.gh.gamecenter.eventbus.EBReuse;
|
||||
import com.gh.gamecenter.retrofit.BiResponse;
|
||||
import com.gh.gamecenter.retrofit.Response;
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager;
|
||||
import com.halo.assistant.HaloApp;
|
||||
@ -52,15 +55,19 @@ public class Config {
|
||||
public static final String TTAD_APPID = BuildConfig.TTAD_APPID;
|
||||
public static final String DOUYIN_CLIENTKEY = BuildConfig.DOUYIN_CLIENTKEY;
|
||||
public static final String DOUYIN_CLIENTSECRET = BuildConfig.DOUYIN_CLIENTSECRET;
|
||||
public static final String QUICK_LOGIN_APPID = BuildConfig.QUICK_LOGIN_APPID;
|
||||
public static final String QUICK_LOGIN_APPKEY = BuildConfig.QUICK_LOGIN_APPKEY;
|
||||
// http://www.ghzs666.com/article/${articleId}.html
|
||||
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";
|
||||
public static final String DEFAULT_CHANNEL = "GH_TEST2";
|
||||
public static final String DEFAULT_CHANNEL_FOR_RELEASE = "GH_LOST"; // 正式包的缺省渠道,避免因渠道丢失而回落到测试渠道
|
||||
|
||||
private static String SETTINGS_KEY = "settingsKey";
|
||||
|
||||
private static SettingsEntity mSettingsEntity;
|
||||
private static NewSettingsEntity mNewSettingsEntity;
|
||||
|
||||
public static final String FIX_DOWNLOAD_KEY = "isFixDownload";
|
||||
public static final String FIX_PLUGIN_KEY = "isFixPlugin";
|
||||
@ -203,6 +210,21 @@ public class Config {
|
||||
return mSettingsEntity;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static NewSettingsEntity getNewSettingsEntity() {
|
||||
if (mNewSettingsEntity == null) {
|
||||
try {
|
||||
String json = SPUtils.getString(Constants.SP_NEW_SETTINGS);
|
||||
if (!TextUtils.isEmpty(json)) {
|
||||
mNewSettingsEntity = GsonUtils.fromJson(json, NewSettingsEntity.class);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return mNewSettingsEntity;
|
||||
}
|
||||
|
||||
private static boolean isExistDownloadFilter() {
|
||||
if (getSettings() == null || getSettings().getDownload() == null || getSettings().getDownload().size() == 0) {
|
||||
return false;
|
||||
@ -278,5 +300,17 @@ public class Config {
|
||||
EventBus.getDefault().post(new EBReuse("Refresh"));
|
||||
}
|
||||
});
|
||||
|
||||
RetrofitManager.getInstance(HaloApp.getInstance().getApplication())
|
||||
.getApi().getNewSettings(Build.MANUFACTURER, Build.MODEL, channel, Build.VERSION.SDK_INT, BuildConfig.VERSION_NAME)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new BiResponse<NewSettingsEntity>() {
|
||||
@Override
|
||||
public void onSuccess(NewSettingsEntity data) {
|
||||
mNewSettingsEntity = data;
|
||||
SPUtils.setString(Constants.SP_NEW_SETTINGS, GsonUtils.toJson(data));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package com.gh.common.constant;
|
||||
|
||||
import com.gh.common.util.PackageUtils;
|
||||
import com.gh.common.util.TimeUtils;
|
||||
import com.halo.assistant.HaloApp;
|
||||
|
||||
public class Constants {
|
||||
@ -27,12 +28,16 @@ public class Constants {
|
||||
|
||||
public static final String GAME_DETAIL_COME_IN = "game_detail_come_in"; // 从游戏详情进入
|
||||
|
||||
public static final String SPLASH_AD = "splash_ad"; // 启动广告
|
||||
|
||||
public static final String XPOSED_INSTALLER_PACKAGE_NAME = "de.robv.android.xposed.installer";
|
||||
|
||||
public static final String EB_QUIT_LOGIN = "quit_login";
|
||||
|
||||
// 用于避免历史下载掺和到普通下载状态的 ID 修饰符
|
||||
public static final String GAME_ID_DIVIDER = ":";
|
||||
public static final String EB_SHOW_AD = "show_ad";
|
||||
|
||||
public static final String EB_GAME_DETAIL = "eb_game_detail";
|
||||
|
||||
// 用于避免历史下载影响到部分依赖名字作为数据更新条件的修饰符
|
||||
public static final String GAME_NAME_DECORATOR = " ";
|
||||
|
||||
@ -49,10 +54,19 @@ public class Constants {
|
||||
public static final String RAW_GAME_ICON = "raw_game_icon";
|
||||
public static final String GAME_ICON_SUBSCRIPT = "game_icon_subscript";
|
||||
|
||||
public static final String IS_PLATFORM_RECOMMEND = "isPlatformRecommend";
|
||||
|
||||
// 下载 id,一般来说跟下载文件名一样
|
||||
public static final String DOWNLOAD_ID = "download_id";
|
||||
|
||||
public static final String GHZS_GAME_ID = "5ae4462c2924bc7936438d07";
|
||||
|
||||
public static final String EXTRA_DOWNLOAD_TYPE = "extra_download_type";
|
||||
public static final String SILENT_UPDATE = "静默更新";
|
||||
public static final String SIMULATOR_DOWNLOAD = "下载模拟器";
|
||||
public static final String SIMULATOR_GAME = "simulator_game";
|
||||
public static final String SIMULATOR = "simulator";
|
||||
public static final String GAME_NAME = "game_name";
|
||||
public static final String SIMULATOR_DOWNLOAD_START_TIME = "simulator_download_start_time";
|
||||
public static final String LAST_GHZS_UPDATE_FILE_SIZE = "last_ghzs_update_file_size";
|
||||
|
||||
@ -62,6 +76,8 @@ public class Constants {
|
||||
public static final String SP_IMEI = "imei";
|
||||
public static final String SP_ANDROID_ID = "android_id";
|
||||
|
||||
public static final String LAST_INSTALL_GAME = "last_install_game";
|
||||
|
||||
//引导设置 “通知管理” 引导弹窗
|
||||
public static final String SP_SHOWED_NOTIFICATION_LOGIN = "show_notification_login_hint";
|
||||
public static final String SP_SHOWED_NOTIFICATION_QUESTION = "show_notification_question_hint";
|
||||
@ -106,8 +122,6 @@ public class Constants {
|
||||
public static final String SP_FILTER_TAGS = "filter_tags";
|
||||
//实名认证弹窗分类数据
|
||||
public static final String SP_AUTH_DIALOG = "auth_dialog";
|
||||
//顶部视频进度保存,重启恢复
|
||||
public static final String SP_TOP_VIDEO_SCHEDULE = "top_video_schedule";
|
||||
//我的光环小红点提示
|
||||
public static final String SP_GH_RED_POINT_REMIND = "gh_red_point_remind";
|
||||
//论坛首页引导
|
||||
@ -131,10 +145,79 @@ public class Constants {
|
||||
public static final String SP_BRAND_NEW_USER = "brand_new_user";
|
||||
//包名检测是否点击不再提示
|
||||
public static final String SP_PACKAGE_CHECK = "package_check";
|
||||
//游戏详情预约引导提示
|
||||
public static final String SP_GAME_DETAIL_RESERVE_GUIDE = "game_detail_reserve_guide";
|
||||
|
||||
public static final String SP_XAPK_UNZIP_ACTIVITY = "xapk_unzip_activity";
|
||||
public static final String SP_XAPK_URL = "xapk_url";
|
||||
|
||||
//游戏详情推荐弹窗
|
||||
public static final String SP_RECOMMEND_POPUP = "recommend_popup";
|
||||
|
||||
|
||||
// 使用浏览器安装开关
|
||||
public static final String SP_USE_BROWSER_TO_INSTALL = "use_browser_to_install";
|
||||
// 游戏详情页底部使用浏览器安装提示
|
||||
public static final String SP_SHOULD_SHOW_GAMEDETAIL_USE_BROWSER_TO_INSTALL_HINT = "should_show_gamedetail_use_browser_to_install_hint";
|
||||
// 第一次普通安装推荐使用浏览器安装提示
|
||||
public static final String SP_SHOULD_SHOW_USE_BROWSER_TO_INSTALL_HINT = "should_show_use_browser_to_install_hint";
|
||||
|
||||
//模拟器管理引导
|
||||
public static final String SP_SIMULATOR_GUIDE = "simulator_guide";
|
||||
//模拟器游戏引导
|
||||
public static final String SP_SIMULATOR_GAME_GUIDE = "simulator_game_guide";
|
||||
|
||||
|
||||
//首页视频播放进度
|
||||
public static final String SP_HOME_VIDEO_PLAY_RECORD = "home_video_play_record";
|
||||
|
||||
// 论坛内容视频播放进度
|
||||
public static final String SP_CONTENT_VIDEO_PLAY_RECORD = "content_video_play_record";
|
||||
|
||||
// 用户是否曾经永久拒绝过存储权限
|
||||
public static final String SP_USER_HAS_PERMANENTLY_DENIED_STORAGE_PERMISSION = "user_has_permanently_denied_storage_permission";
|
||||
|
||||
// 是否已经填写邀请码
|
||||
public static final String SP_HAS_COMPLETE_INVITE_CODE = "has_complete_invite_code";
|
||||
|
||||
// 补充配置项
|
||||
public static final String SP_NEW_SETTINGS = "new_settings";
|
||||
|
||||
// 头像挂件ID
|
||||
public static final String SP_CHOOSE_AVATAR_ID = "choose_avatar_id";
|
||||
|
||||
// 是否第一次进入新分类2.0
|
||||
public static final String SP_FIRST_ENTER_CATEGORY_V2 = "first_enter_category_v2";
|
||||
|
||||
// 是否成功取过号
|
||||
public static final String SP_HAS_GET_PHONE_INFO = "has_get_phone_info";
|
||||
|
||||
// 是否点击过更换背景按钮
|
||||
public static final String SP_HAS_CLICK_CHANGE_BG = "has_click_change_bg";
|
||||
// 是否显示更换背景提示
|
||||
public static final String SP_SHOW_CHANGE_BG_TIPS = "show_change_bg_tips" + TimeUtils.getStartTimeOfToday();
|
||||
|
||||
// 新分类2.0引导
|
||||
public static final String SP_SHOW_CATEGORY_GUIDE = "show_category_guide";
|
||||
|
||||
|
||||
// 内容视频播放选项
|
||||
public static final String SP_CONTENT_VIDEO_OPTION = "content_video_option";
|
||||
// 首页/游戏详情页视频播放选项
|
||||
public static final String SP_HOME_OR_DETAIL_VIDEO_OPTION = "home_or_detail_video_option";
|
||||
// 是否默认静音播放视频
|
||||
public static final String SP_VIDEO_PLAY_MUTE = "video_play_mute";
|
||||
//帖子发布页上传视频引导
|
||||
public static final String SP_ARTICLE_VIDEO_GUIDE = "article_video_guide";
|
||||
//问题发布页上传视频引导
|
||||
public static final String SP_QUESTION_VIDEO_GUIDE = "question_video_guide";
|
||||
// 社区首页引导
|
||||
public static final String SP_COMMUNITY_HOME_GUIDE = "community_home_guide";
|
||||
// 社区首页发布按钮引导
|
||||
public static final String SP_COMMUNITY_HOME_VIDEO_GUIDE = "community_home_video_guide";
|
||||
// 论坛详情申请版主引导
|
||||
public static final String SP_FORUM_DETAIL_MODERATOR_GUIDE = "forum_detail_moderator_guide";
|
||||
|
||||
//手机号码匹配规则
|
||||
public static final String REGEX_MOBILE = "^((13[0-9])|(15[^4,\\D])|(18[0,5-9]))\\d{8}$";
|
||||
public static final String REGEX_ACCOUNT = "^[a-zA-Z_]\\w{5,17}$";
|
||||
@ -169,13 +252,80 @@ public class Constants {
|
||||
//版规声明
|
||||
public static final String FORUM_REGULATIONS_NEWS_ID = "5f4db9cc34d44d01b92fd670";
|
||||
|
||||
// 权限使用场景地址
|
||||
public static final String PERMISSION_SCENARIO_ADDRESS = "https://resource.ghzs.com/page/permissions/android.html";
|
||||
|
||||
//帮助内容详情
|
||||
public static final String HELP_ADDRESS_DEV = "https://static-web.ghzs.com/ghzs_help_dev/help.html?content=";
|
||||
public static final String HELP_ADDRESS = "https://static-web.ghzs.com/ghzs_help/help.html?content=";
|
||||
|
||||
// 注销页面
|
||||
public static final String LOGOUT_ADDRESS_DEV = "https://static-web.ghzs.com/ghzs_help_dev/help.html?content=5f6b1f02786564003944a693";
|
||||
public static final String LOGOUT_ADDRESS = "https://static-web.ghzs.com/ghzs_help/help.html?content=5f534111b1f72909fc225672";
|
||||
public static final String LOGOUT_ADDRESS_DEV = "https://static-web.ghzs.com/ghzs_help_dev/help.html?content=5f6b1f02786564003944a693&from=ghzs";
|
||||
public static final String LOGOUT_ADDRESS = "https://static-web.ghzs.com/ghzs_help/help.html?content=5f534111b1f72909fc225672&from=ghzs";
|
||||
|
||||
// 商品详情
|
||||
public static final String COMMODITY_DETAIL_ADDRESS_DEV = "https://static-web.ghzs.com/shop-dev/index.html#/product?from=ghzs";
|
||||
public static final String COMMODITY_DETAIL_ADDRESS = "https://static-web.ghzs.com/shop/index.html#/product?from=ghzs";
|
||||
|
||||
// 光能记录
|
||||
public static final String ENERGY_RECORD_ADDRESS_DEV = "https://static-web.ghzs.com/shop-dev/index.html#/record?from=ghzs";
|
||||
public static final String ENERGY_RECORD_ADDRESS = "https://static-web.ghzs.com/shop/index.html#/record?from=ghzs";
|
||||
|
||||
// 订单中心
|
||||
public static final String ORDER_CENTER_ADDRESS_DEV = "https://static-web.ghzs.com/shop-dev/index.html#/orders?from=ghzs";
|
||||
public static final String ORDER_CENTER_ADDRESS = "https://static-web.ghzs.com/shop/index.html#/orders?from=ghzs";
|
||||
|
||||
// 订单详情
|
||||
public static final String ORDER_DETAIL_ADDRESS_DEV = "https://static-web.ghzs.com/shop-dev/index.html#/order-detail?from=ghzs";
|
||||
public static final String ORDER_DETAIL_ADDRESS = "https://static-web.ghzs.com/shop/index.html#/order-detail?from=ghzs";
|
||||
|
||||
// 邀请好友
|
||||
public static final String INVITE_FRIENDS_ADDRESS_DEV = "https://static-web.ghzs.com/ghzs_activity_dev/inviteFriends.html#/invite";
|
||||
public static final String INVITE_FRIENDS_ADDRESS = "https://static-web.ghzs.com/ghzs_activity_prod/inviteFriends.html#/invite";
|
||||
|
||||
// 等级页面
|
||||
public static final String LEVEL_ADDRESS_DEV = "https://static-web.ghzs.com/ghzs-userhome-dev/index.html#/level";
|
||||
public static final String LEVEL_ADDRESS = "https://static-web.ghzs.com/ghzs-userhome/index.html#/level";
|
||||
|
||||
// 兑换规则
|
||||
public static final String EXCHANGE_RULE_ADDRESS_DEV = "https://static-web.ghzs.com/shop-dev/index.html#/exchange-rule?from=ghzs";
|
||||
public static final String EXCHANGE_RULE_ADDRESS = "https://static-web.ghzs.com/shop/index.html#/exchange-rule?from=ghzs";
|
||||
|
||||
// 光能规则
|
||||
public static final String ENERGY_RULE_ADDRESS_DEV = "https://static-web.ghzs.com/shop-dev/index.html#/energy-rule?from=ghzs";
|
||||
public static final String ENERGY_RULE_ADDRESS = "https://static-web.ghzs.com/shop/index.html#/energy-rule?from=ghzs";
|
||||
|
||||
// 兑换商品
|
||||
public static final String EXCHANGE_COMMODITY_ADDRESS_DEV = "https://static-web.ghzs.com/shop-dev/index.html#/exchange-log?from=ghzs";
|
||||
public static final String EXCHANGE_COMMODITY_ADDRESS = "https://static-web.ghzs.com/shop/index.html#/exchange-log?from=ghzs";
|
||||
|
||||
// 抽奖乐园
|
||||
public static final String LOTTERY_PARADISE_ADDRESS_DEV = "https://static-web.ghzs.com/shop-dev/index.html#/lottery-list?from=ghzs";
|
||||
public static final String LOTTERY_PARADISE_ADDRESS = "https://static-web.ghzs.com/shop/index.html#/lottery-list?from=ghzs";
|
||||
|
||||
// 我的奖品
|
||||
public static final String MY_PRIZE_ADDRESS_DEV = "https://static-web.ghzs.com/shop-dev/index.html#/mywin?from=ghzs";
|
||||
public static final String MY_PRIZE_ADDRESS = "https://static-web.ghzs.com/shop/index.html#/mywin?from=ghzs";
|
||||
|
||||
// 中奖订单详情
|
||||
public static final String WIN_ORDER_DETAIL_ADDRESS_DEV = "https://static-web.ghzs.com/shop-dev/index.html#/win-order-detail?from=ghzs";
|
||||
public static final String WIN_ORDER_DETAIL_ADDRESS = "https://static-web.ghzs.com/shop/index.html#/win-order-detail?from=ghzs";
|
||||
|
||||
// 地址信息
|
||||
public static final String ADDRESS_INFO_ADDRESS_DEV = "https://static-web.ghzs.com/shop-dev/index.html#/address-list?from=ghzs";
|
||||
public static final String ADDRESS_INFO_ADDRESS = "https://static-web.ghzs.com/shop/index.html#/address-list?from=ghzs";
|
||||
|
||||
// 领奖信息
|
||||
public static final String PRIZE_INFO_ADDRESS_DEV = "https://static-web.ghzs.com/shop-dev/index.html#/user-info?from=ghzs";
|
||||
public static final String PRIZE_INFO_ADDRESS = "https://static-web.ghzs.com/shop/index.html#/user-info?from=ghzs";
|
||||
|
||||
// 提现信息
|
||||
public static final String WITHDRAW_INFO_ADDRESS_DEV = "https://static-web.ghzs.com/shop-dev/index.html#/cash?from=ghzs";
|
||||
public static final String WITHDRAW_INFO_ADDRESS = "https://static-web.ghzs.com/shop/index.html#/cash?from=ghzs";
|
||||
|
||||
// 活动详情
|
||||
public static final String ACTIVITY_DETAIL_ADDRESS_DEV = "https://static-web.ghzs.com/ghzs_activity_dev/common.html?from=ghzs";
|
||||
public static final String ACTIVITY_DETAIL_ADDRESS = "https://static-web.ghzs.com/ghzs_activity_prod/common.html?from=ghzs";
|
||||
|
||||
//最少需要多少数据才能上传
|
||||
public static final int DATA_AMOUNT = 20;
|
||||
|
||||
@ -46,12 +46,14 @@ import com.gh.common.util.NumberUtils;
|
||||
import com.gh.common.util.PackageInstaller;
|
||||
import com.gh.common.util.PackageUtils;
|
||||
import com.gh.common.util.PlatformUtils;
|
||||
import com.gh.common.util.RealNameHelper;
|
||||
import com.gh.common.util.ReservationHelper;
|
||||
import com.gh.common.view.DownloadProgressBar;
|
||||
import com.gh.common.view.DrawableView;
|
||||
import com.gh.common.view.GameIconView;
|
||||
import com.gh.download.DownloadManager;
|
||||
import com.gh.download.dialog.DownloadDialog;
|
||||
import com.gh.download.server.BrowserInstallHelper;
|
||||
import com.gh.gamecenter.DownloadManagerActivity;
|
||||
import com.gh.gamecenter.R;
|
||||
import com.gh.gamecenter.WebActivity;
|
||||
@ -66,6 +68,7 @@ import com.gh.gamecenter.entity.ServerCalendarEntity;
|
||||
import com.gh.gamecenter.entity.TagStyleEntity;
|
||||
import com.gh.gamecenter.entity.TestEntity;
|
||||
import com.gh.gamecenter.eventbus.EBReuse;
|
||||
import com.gh.gamecenter.gamedetail.dialog.GamePermissionDialogFragment;
|
||||
import com.gh.gamecenter.manager.PackagesManager;
|
||||
import com.gh.gamecenter.qa.entity.CommunityVideoEntity;
|
||||
import com.lightgame.download.DownloadEntity;
|
||||
@ -333,6 +336,13 @@ public class BindingAdapters {
|
||||
}
|
||||
}
|
||||
|
||||
@BindingAdapter("gameIcon")
|
||||
public static void setGameIcon(View view, GameEntity gameEntity) {
|
||||
if (gameEntity != null && view instanceof GameIconView) {
|
||||
((GameIconView) view).displayGameIcon(gameEntity.getIcon(), gameEntity.getIconSubscript());
|
||||
}
|
||||
}
|
||||
|
||||
@BindingAdapter("articleType")
|
||||
public static void setArticleType(TextView view, String articleType) {
|
||||
NewsUtils.setNewsType(view, articleType, 0, 0);
|
||||
@ -456,27 +466,37 @@ public class BindingAdapters {
|
||||
return;
|
||||
}
|
||||
}
|
||||
PackageCheckDialogFragment.show((AppCompatActivity) v.getContext(), gameEntity.getPackageDialog(), () -> {
|
||||
DownloadDialogHelper.findAvailableDialogAndShow(v.getContext(), gameEntity, apk, () -> {
|
||||
CertificationDialog.showCertificationDialog(v.getContext(), gameEntity, () -> {
|
||||
DialogUtils.showVersionNumberDialog(v.getContext(), gameEntity, () -> {
|
||||
DialogUtils.showOverseaDownloadDialog(v.getContext(), gameEntity, () -> {
|
||||
DialogUtils.checkDownload(v.getContext(), apk.getSize(),
|
||||
isSubscribe -> download(progressBar, gameEntity, traceEvent, isSubscribe, entrance, location));
|
||||
RealNameHelper.checkIfAuth(v.getContext(), gameEntity, () -> {
|
||||
GamePermissionDialogFragment.show((AppCompatActivity) v.getContext(), gameEntity, gameEntity.getInfo(), () -> {
|
||||
BrowserInstallHelper.showBrowserInstallHintDialog(v.getContext(), () -> {
|
||||
PackageCheckDialogFragment.show((AppCompatActivity) v.getContext(), gameEntity, () -> {
|
||||
DownloadDialogHelper.findAvailableDialogAndShow(v.getContext(), gameEntity, apk, () -> {
|
||||
CertificationDialog.showCertificationDialog(v.getContext(), gameEntity, () -> {
|
||||
DialogUtils.showVersionNumberDialog(v.getContext(), gameEntity, () -> {
|
||||
DialogUtils.showOverseaDownloadDialog(v.getContext(), gameEntity, () -> {
|
||||
DialogUtils.checkDownload(v.getContext(), apk.getSize(),
|
||||
isSubscribe -> download(progressBar, gameEntity, traceEvent, isSubscribe, entrance, location));
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
} else {
|
||||
CertificationDialog.showCertificationDialog(v.getContext(), gameEntity, () -> {
|
||||
DialogUtils.showVersionNumberDialog(v.getContext(), gameEntity, () -> {
|
||||
DownloadDialog.showDownloadDialog(
|
||||
v.getContext(),
|
||||
gameEntity,
|
||||
traceEvent,
|
||||
entrance,
|
||||
location + ":" + gameEntity.getName());
|
||||
RealNameHelper.checkIfAuth(v.getContext(), gameEntity, () -> {
|
||||
GamePermissionDialogFragment.show((AppCompatActivity) v.getContext(), gameEntity, gameEntity.getInfo(), () -> {
|
||||
CertificationDialog.showCertificationDialog(v.getContext(), gameEntity, () -> {
|
||||
DialogUtils.showVersionNumberDialog(v.getContext(), gameEntity, () -> {
|
||||
DownloadDialog.showDownloadDialog(
|
||||
v.getContext(),
|
||||
gameEntity,
|
||||
traceEvent,
|
||||
entrance,
|
||||
location + ":" + gameEntity.getName());
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
@ -518,12 +538,16 @@ public class BindingAdapters {
|
||||
}
|
||||
break;
|
||||
case RESERVABLE:
|
||||
CheckLoginUtils.checkLogin(progressBar.getContext(), "", () -> {
|
||||
ReserveDialogFragment dialogFragment = ReserveDialogFragment.getInstance(gameEntity, () -> {
|
||||
LogUtils.logReservation(gameEntity, traceEvent);
|
||||
updateReservation(progressBar, gameEntity);
|
||||
RealNameHelper.checkIfAuth(v.getContext(), gameEntity, () -> {
|
||||
GamePermissionDialogFragment.show((AppCompatActivity) v.getContext(), gameEntity, gameEntity.getInfo(), () -> {
|
||||
CheckLoginUtils.checkLogin(progressBar.getContext(), "", () -> {
|
||||
ReserveDialogFragment dialogFragment = ReserveDialogFragment.getInstance(gameEntity, () -> {
|
||||
LogUtils.logReservation(gameEntity, traceEvent);
|
||||
updateReservation(progressBar, gameEntity);
|
||||
});
|
||||
dialogFragment.show(((AppCompatActivity) progressBar.getContext()).getSupportFragmentManager(), "reserve");
|
||||
});
|
||||
});
|
||||
dialogFragment.show(((AppCompatActivity) progressBar.getContext()).getSupportFragmentManager(), "reserve");
|
||||
});
|
||||
break;
|
||||
case RESERVED:
|
||||
@ -550,8 +574,10 @@ public class BindingAdapters {
|
||||
HistoryHelper.insertGameEntity(gameEntity);
|
||||
}
|
||||
|
||||
Intent i = new Intent(WebActivity.getIntentForWebGame(progressBar.getContext(), linkEntity.getLink(), gameEntity.getName(), isPlay, linkEntity.getCloseButton()));
|
||||
progressBar.getContext().startActivity(i);
|
||||
GamePermissionDialogFragment.show((AppCompatActivity) v.getContext(), gameEntity, gameEntity.getInfo(), () -> {
|
||||
Intent i = new Intent(WebActivity.getIntentForWebGame(progressBar.getContext(), linkEntity.getLink(), gameEntity.getName(), isPlay, linkEntity.getCloseButton()));
|
||||
progressBar.getContext().startActivity(i);
|
||||
});
|
||||
break;
|
||||
case UPDATING:
|
||||
Utils.toast(progressBar.getContext(), "正在加急更新版本,敬请后续留意");
|
||||
@ -731,7 +757,9 @@ public class BindingAdapters {
|
||||
try {
|
||||
ArrayList<TagStyleEntity> tagStyle = new ArrayList<>();
|
||||
TestEntity test = gameEntity.getTest();
|
||||
if (test != null) {
|
||||
if (test != null
|
||||
// 这个判断用于开测表列表
|
||||
&& !"type_tag".equals(test.getGameTag())) {
|
||||
TagStyleEntity typeTag = new TagStyleEntity();
|
||||
typeTag.setName(test.getType() != null ? test.getType() : "");
|
||||
typeTag.setBackground("FFF3E0");
|
||||
@ -752,6 +780,34 @@ public class BindingAdapters {
|
||||
}
|
||||
}
|
||||
|
||||
@BindingAdapter("setVideoDetailGameTags")
|
||||
public static void setVideoDetailGameTags(LinearLayout layout, GameEntity gameEntity) {
|
||||
try {
|
||||
ArrayList<TagStyleEntity> tagStyle = new ArrayList<>();
|
||||
TestEntity test = gameEntity.getTest();
|
||||
if (test != null
|
||||
// 这个判断用于开测表列表
|
||||
&& !"type_tag".equals(test.getGameTag())) {
|
||||
TagStyleEntity typeTag = new TagStyleEntity();
|
||||
typeTag.setName(test.getType() != null ? test.getType() : "");
|
||||
typeTag.setBackground("FFF3E0");
|
||||
typeTag.setColor("FA8500");
|
||||
tagStyle.add(typeTag);
|
||||
|
||||
TagStyleEntity timeTag = new TagStyleEntity();
|
||||
timeTag.setName(GameViewUtils.getGameTestDate(test.getStart()));
|
||||
timeTag.setBackground("E0FFF9");
|
||||
timeTag.setColor("00A887");
|
||||
tagStyle.add(timeTag);
|
||||
} else {
|
||||
tagStyle = gameEntity.getTagStyle();
|
||||
}
|
||||
GameViewUtils.setLabelList(layout.getContext(), layout, tagStyle, 4);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@BindingAdapter("isRefreshing")
|
||||
public static void isRefreshing(SwipeRefreshLayout layout, LoadStatus status) {
|
||||
if (status != LoadStatus.INIT_LOADING && status != LoadStatus.LIST_LOADING) {
|
||||
|
||||
@ -0,0 +1,90 @@
|
||||
package com.gh.common.dialog
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.fragment.app.FragmentTransaction
|
||||
import com.gh.base.fragment.BaseDialogFragment
|
||||
import com.gh.common.util.DirectUtils
|
||||
import com.gh.common.util.SpanBuilder
|
||||
import com.gh.common.util.dip2px
|
||||
import com.gh.common.view.CustomLinkMovementMethod
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.databinding.DialogApplyModeratorBinding
|
||||
|
||||
|
||||
class ApplyModeratorDialogFragment : BaseDialogFragment() {
|
||||
private lateinit var binding: DialogApplyModeratorBinding
|
||||
private var groupNumber = ""
|
||||
private var groupKey = ""
|
||||
private var mCallBack: (() -> Unit)? = null
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View {
|
||||
binding = DialogApplyModeratorBinding.inflate(inflater, container, false)
|
||||
return binding.root
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
val startText = "版主考核群:"
|
||||
val text = "$startText$groupNumber\n感谢你对论坛建设的支持\n请加入版主考核群并联系群主进行版主资格考核"
|
||||
binding.desTv.text = SpanBuilder(text)
|
||||
.click(startText.length, startText.length + groupNumber.length, R.color.theme_font,true) {
|
||||
DirectUtils.directToQqGroup(
|
||||
requireContext(),
|
||||
groupKey
|
||||
)
|
||||
}
|
||||
.build()
|
||||
binding.desTv.movementMethod = CustomLinkMovementMethod.getInstance()
|
||||
binding.confirmTv.setOnClickListener {
|
||||
dismissAllowingStateLoss()
|
||||
mCallBack?.invoke()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
val width = requireContext().resources.displayMetrics.widthPixels - 60F.dip2px()
|
||||
val height = ViewGroup.LayoutParams.WRAP_CONTENT
|
||||
dialog?.window?.setLayout(width, height)
|
||||
}
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun show(
|
||||
activity: AppCompatActivity,
|
||||
number: String,
|
||||
key: String,
|
||||
callBack: (() -> Unit)?
|
||||
) {
|
||||
var dialogFragment =
|
||||
activity.supportFragmentManager.findFragmentByTag(ApplyModeratorDialogFragment::class.java.simpleName) as? ApplyModeratorDialogFragment
|
||||
if (dialogFragment != null) {
|
||||
dialogFragment.groupNumber = number
|
||||
dialogFragment.groupKey = key
|
||||
dialogFragment.mCallBack = callBack
|
||||
val transaction: FragmentTransaction =
|
||||
activity.supportFragmentManager.beginTransaction()
|
||||
transaction.show(dialogFragment)
|
||||
transaction.commit()
|
||||
} else {
|
||||
dialogFragment = ApplyModeratorDialogFragment().apply {
|
||||
groupNumber = number
|
||||
groupKey = key
|
||||
mCallBack = callBack
|
||||
}
|
||||
dialogFragment.show(
|
||||
activity.supportFragmentManager,
|
||||
PrivacyDialogFragment::class.java.simpleName
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,95 @@
|
||||
package com.gh.common.dialog
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.app.Dialog
|
||||
import android.os.Bundle
|
||||
import android.view.*
|
||||
import com.gh.base.fragment.BaseDialogFragment
|
||||
import com.gh.gamecenter.R
|
||||
import com.halo.assistant.HaloApp
|
||||
|
||||
abstract class BaseDraggableDialogFragment : BaseDialogFragment(), View.OnTouchListener {
|
||||
private var mInitPositionY = 0f
|
||||
private lateinit var mGestureDetector: GestureDetector
|
||||
private lateinit var mRootView: View
|
||||
private lateinit var mDragCloseView: View
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
mRootView = getRootView()
|
||||
mDragCloseView = getDragCloseView()
|
||||
mDragCloseView.setOnTouchListener(this)
|
||||
mGestureDetector = GestureDetector(requireContext(), SingleTapConfirm())
|
||||
}
|
||||
|
||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||
val createDialog = super.onCreateDialog(savedInstanceState)
|
||||
createDialog.setCanceledOnTouchOutside(true)
|
||||
|
||||
val window = createDialog.window
|
||||
window?.setGravity(Gravity.BOTTOM)
|
||||
window?.setWindowAnimations(R.style.community_publication_animation)
|
||||
return createDialog
|
||||
}
|
||||
|
||||
// dialog drag animation
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
override fun onTouch(v: View, event: MotionEvent): Boolean {
|
||||
if (mGestureDetector.onTouchEvent(event) && mRootView.y == 0F) {
|
||||
v.performClick()
|
||||
return true
|
||||
}
|
||||
when (event.action) {
|
||||
MotionEvent.ACTION_DOWN -> {
|
||||
mInitPositionY = mRootView.y - event.rawY
|
||||
}
|
||||
MotionEvent.ACTION_MOVE -> {
|
||||
val offsetY = event.rawY + mInitPositionY
|
||||
val dialogY = mRootView.y
|
||||
if (dialogY + offsetY > 0) {
|
||||
mRootView.animate()
|
||||
.y(offsetY)
|
||||
.setDuration(0)
|
||||
.start()
|
||||
} else {
|
||||
resetDialogPosition()
|
||||
}
|
||||
}
|
||||
MotionEvent.ACTION_CANCEL,
|
||||
MotionEvent.ACTION_UP,
|
||||
MotionEvent.ACTION_OUTSIDE -> {
|
||||
if (mRootView.y >= mRootView.height / 2) {
|
||||
dismissAllowingStateLoss()
|
||||
} else {
|
||||
resetDialogPosition(300)
|
||||
}
|
||||
}
|
||||
else -> return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
private fun resetDialogPosition(duration: Long = 0) {
|
||||
mRootView.animate()
|
||||
.y(0F)
|
||||
.setDuration(duration)
|
||||
.start()
|
||||
}
|
||||
|
||||
private class SingleTapConfirm : GestureDetector.SimpleOnGestureListener() {
|
||||
override fun onSingleTapUp(event: MotionEvent): Boolean {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
val width = HaloApp.getInstance().application.resources.displayMetrics.widthPixels
|
||||
val height = dialog?.window?.attributes?.height ?: ViewGroup.LayoutParams.WRAP_CONTENT
|
||||
dialog?.window?.setLayout(width, height)
|
||||
}
|
||||
|
||||
abstract fun getRootView(): View
|
||||
abstract fun getDragCloseView(): View
|
||||
override fun getThemeRes(): Int = R.style.DialogFragmentDimAmount
|
||||
}
|
||||
@ -4,6 +4,8 @@ import android.content.DialogInterface
|
||||
import android.os.Bundle
|
||||
import android.view.KeyEvent
|
||||
import android.view.View
|
||||
import androidx.fragment.app.DialogFragment
|
||||
import androidx.fragment.app.FragmentManager
|
||||
import com.gh.common.util.MtaHelper
|
||||
import com.lightgame.dialog.BaseDialogFragment
|
||||
import java.util.concurrent.atomic.AtomicBoolean
|
||||
@ -63,4 +65,29 @@ abstract class BaseTrackableDialogFragment : BaseDialogFragment() {
|
||||
|
||||
open fun trackWithBasicDeviceInfo() = false
|
||||
|
||||
|
||||
override fun show(manager: FragmentManager, tag: String?) {
|
||||
val fragment = manager.findFragmentByTag(tag)
|
||||
if (fragment != null) {
|
||||
val transaction = manager.beginTransaction()
|
||||
transaction.show(fragment)
|
||||
transaction.commit()
|
||||
} else {
|
||||
try {
|
||||
val clazz: Class<*> = DialogFragment::class.java
|
||||
val dismissed = clazz.getDeclaredField("mDismissed")
|
||||
dismissed.isAccessible = true
|
||||
dismissed[this] = false
|
||||
val shownByMe = clazz.getDeclaredField("mShownByMe")
|
||||
shownByMe.isAccessible = true
|
||||
shownByMe[this] = true
|
||||
val transaction = manager.beginTransaction()
|
||||
transaction.add(this, tag)
|
||||
transaction.commitAllowingStateLoss()
|
||||
} catch (e: Exception) {
|
||||
super.show(manager, tag)
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -17,13 +17,9 @@ import androidx.appcompat.app.AppCompatActivity
|
||||
import com.gh.common.avoidcallback.AvoidOnResultManager
|
||||
import com.gh.common.avoidcallback.Callback
|
||||
import com.gh.common.constant.Constants
|
||||
import com.gh.common.util.CheckLoginUtils
|
||||
import com.gh.common.util.DialogUtils
|
||||
import com.gh.common.util.GsonUtils
|
||||
import com.gh.common.util.SPUtils
|
||||
import com.gh.common.util.*
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.UserInfoEditActivity
|
||||
import com.gh.gamecenter.WebActivity
|
||||
import com.gh.gamecenter.entity.AuthDialogEntity
|
||||
import com.gh.gamecenter.entity.AuthDialogLevel
|
||||
import com.gh.gamecenter.entity.GameEntity
|
||||
@ -56,7 +52,7 @@ class CertificationDialog(context: Context, private val authDialogEntity: AuthDi
|
||||
detailedDesTv.paint.isAntiAlias = true
|
||||
|
||||
detailedDesTv.setOnClickListener {
|
||||
context.startActivity(WebActivity.getIntentByUrl(context, authDialogEntity.link))
|
||||
DirectUtils.directToWebView(context, authDialogEntity.link)
|
||||
}
|
||||
|
||||
when (authDialogEntity.level) {
|
||||
|
||||
@ -26,7 +26,7 @@ import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.entity.DeviceDialogEntity
|
||||
import com.gh.gamecenter.entity.GameEntity
|
||||
import com.google.gson.reflect.TypeToken
|
||||
import com.halo.assistant.fragment.SettingsFragment.AUTO_INSTALL_SP_KEY
|
||||
import com.gh.gamecenter.setting.GameDownloadSettingFragment.Companion.AUTO_INSTALL_SP_KEY
|
||||
import com.lightgame.download.DataWatcher
|
||||
import com.lightgame.download.DownloadEntity
|
||||
import com.lightgame.download.DownloadStatus
|
||||
@ -60,26 +60,36 @@ class DeviceRemindDialog(context: Context, val entity: DeviceDialogEntity, val g
|
||||
|
||||
companion object {
|
||||
fun showDeviceRemindDialog(context: Context, gameEntity: GameEntity) {
|
||||
val datas = SPUtils.getString(Constants.SP_DEVICE_REMIND)
|
||||
if (datas.isNotEmpty()) {
|
||||
val pair = shouldShowDeviceRemindDialog(gameEntity)
|
||||
if (pair.first) {
|
||||
val dialog = DeviceRemindDialog(context, pair.second!!, gameEntity)
|
||||
dialog.show()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun shouldShowDeviceRemindDialog(gameEntity: GameEntity): Pair<Boolean, DeviceDialogEntity?> {
|
||||
val datas = SPUtils.getString(Constants.SP_DEVICE_REMIND)
|
||||
if (datas.isNotEmpty()) {
|
||||
val type = object : TypeToken<List<DeviceDialogEntity>>() {}.type
|
||||
val entitys = GsonUtils.gson.fromJson<List<DeviceDialogEntity>>(datas, type)
|
||||
val entities = GsonUtils.gson.fromJson<List<DeviceDialogEntity>>(datas, type)
|
||||
//1.判断设备是否匹配
|
||||
val entity = entitys.find { it.manufacturer.toLowerCase().startsWith(Build.MANUFACTURER.toLowerCase()) }
|
||||
?: return
|
||||
val entity = entities.find { it.manufacturer.toLowerCase().startsWith(Build.MANUFACTURER.toLowerCase()) }
|
||||
?: return Pair(false, null)
|
||||
//2.判断游戏不含剔除标签
|
||||
gameEntity.tagStyle.forEach {
|
||||
if (entity.excludeTags.contains(it.name)) {
|
||||
return
|
||||
return Pair(false, null)
|
||||
}
|
||||
}
|
||||
//3.不再弹出提示判断
|
||||
val isNoRemindAgain = SPUtils.getBoolean(Constants.SP_NO_REMIND_AGAIN, false)
|
||||
if (isNoRemindAgain) return
|
||||
|
||||
val dialog = DeviceRemindDialog(context, entity, gameEntity)
|
||||
dialog.show()
|
||||
if (isNoRemindAgain) return Pair(false, null)
|
||||
return Pair(true, entity)
|
||||
}
|
||||
return Pair(false, null)
|
||||
}
|
||||
}
|
||||
|
||||
@ -215,7 +225,7 @@ class DeviceRemindDialog(context: Context, val entity: DeviceDialogEntity, val g
|
||||
|
||||
class LooperHandle(val mAdapter: BannerAdapter) : Handler() {
|
||||
private val mWeakReference: WeakReference<BannerAdapter> = WeakReference(mAdapter)
|
||||
override fun handleMessage(msg: Message?) {
|
||||
override fun handleMessage(msg: Message) {
|
||||
val adapter = mWeakReference.get()
|
||||
adapter?.scrollToNextPage()
|
||||
adapter?.startScroll()
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package com.gh.common.dialog
|
||||
|
||||
import android.app.Dialog
|
||||
import android.graphics.Paint
|
||||
import android.os.Bundle
|
||||
import android.util.TypedValue
|
||||
@ -8,54 +9,70 @@ import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.TextView
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.text.HtmlCompat
|
||||
import com.gh.base.fragment.BaseDialogFragment
|
||||
import com.gh.common.util.DirectUtils
|
||||
import com.gh.common.util.DisplayUtils
|
||||
import com.gh.common.util.MtaHelper
|
||||
import com.gh.common.util.dip2px
|
||||
import com.gh.common.util.toColor
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.databinding.DialogGameOffServiceBinding
|
||||
import com.gh.gamecenter.entity.GameEntity
|
||||
import kotlinx.android.synthetic.main.dialog_game_off_service.*
|
||||
|
||||
// 游戏关闭下载弹窗
|
||||
class GameOffServiceDialogFragment
|
||||
// : BaseTrackableDialogFragment()
|
||||
:BaseDialogFragment() {
|
||||
: BaseDialogFragment() {
|
||||
|
||||
private var mDialog: GameEntity.Dialog? = null
|
||||
private var mBinding: DialogGameOffServiceBinding? = null
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||
return inflater.inflate(R.layout.dialog_game_off_service, null)
|
||||
return DialogGameOffServiceBinding
|
||||
.inflate(inflater)
|
||||
.apply { mBinding = this }
|
||||
.root
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
mDialog?.run {
|
||||
titleTv.text = title
|
||||
contentTv.text = HtmlCompat.fromHtml(content, HtmlCompat.FROM_HTML_MODE_LEGACY)
|
||||
|
||||
for (site in sites) {
|
||||
val siteTv = TextView(context)
|
||||
siteTv.layoutParams = LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT).apply {
|
||||
topMargin = DisplayUtils.dip2px(12f)
|
||||
}
|
||||
siteTv.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14f)
|
||||
siteTv.setTextColor(ContextCompat.getColor(requireContext(), R.color.theme_font))
|
||||
siteTv.text = site.text
|
||||
siteTv.paintFlags = siteTv.paintFlags or Paint.UNDERLINE_TEXT_FLAG
|
||||
siteTv.setOnClickListener {
|
||||
// MtaHelper.onEvent("游戏下载状态按钮", getKey(), site.text)
|
||||
DirectUtils.directToWebView(requireContext(), site.url, "(关闭下载弹窗)")
|
||||
mBinding?.run {
|
||||
mDialog?.run {
|
||||
titleTv.text = title
|
||||
contentTv.text = HtmlCompat.fromHtml(content, HtmlCompat.FROM_HTML_MODE_LEGACY)
|
||||
okTv.setOnClickListener {
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
|
||||
container.addView(siteTv)
|
||||
// 过滤内容为空的元素
|
||||
val notEmptySite = sites.filter { it.text.isNotBlank() }
|
||||
|
||||
notEmptySite.forEachIndexed { index, site ->
|
||||
val siteTv = TextView(context)
|
||||
siteTv.layoutParams = LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT).apply {
|
||||
topMargin = 24F.dip2px()
|
||||
if (index == notEmptySite.size - 1) bottomMargin = 8F.dip2px()
|
||||
}
|
||||
siteTv.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14F)
|
||||
siteTv.setTextColor(R.color.theme_font.toColor())
|
||||
siteTv.text = site.text
|
||||
siteTv.paintFlags = siteTv.paintFlags or Paint.UNDERLINE_TEXT_FLAG
|
||||
siteTv.setOnClickListener {
|
||||
// MtaHelper.onEvent("游戏下载状态按钮", getKey(), site.text)
|
||||
DirectUtils.directToWebView(requireContext(), site.url, "(关闭下载弹窗)")
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
|
||||
container.addView(siteTv)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||
return super.onCreateDialog(savedInstanceState).apply { setCanceledOnTouchOutside(true) }
|
||||
}
|
||||
|
||||
// override fun getEvent(): String {
|
||||
// return "游戏下载状态按钮"
|
||||
// }
|
||||
|
||||
@ -67,7 +67,7 @@ class NotificationHintDialogFragment : BaseTrackableDialogFragment() {
|
||||
activateTv.setOnClickListener {
|
||||
MtaHelper.onEventWithBasicDeviceInfo(getEvent(), getKey(), "点击立即开启")
|
||||
MtaHelper.onEventWithBasicDeviceInfo(getEvent(), getKey(), "${styleEntity.scenes}_${styleEntity.styleNo}_点击立即开启")
|
||||
dismiss()
|
||||
dismissAllowingStateLoss()
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
//这种方案适用于 API 26, 即8.0(含8.0)以上可以用
|
||||
val intent = Intent()
|
||||
@ -80,7 +80,7 @@ class NotificationHintDialogFragment : BaseTrackableDialogFragment() {
|
||||
}
|
||||
|
||||
closeIv.setOnClickListener {
|
||||
dismiss()
|
||||
dismissAllowingStateLoss()
|
||||
MtaHelper.onEventWithBasicDeviceInfo(getEvent(), getKey(), "点击关闭")
|
||||
MtaHelper.onEventWithBasicDeviceInfo(getEvent(), getKey(), "${styleEntity.scenes}_${styleEntity.styleNo}_点击关闭")
|
||||
}
|
||||
|
||||
@ -1,30 +1,39 @@
|
||||
package com.gh.common.dialog
|
||||
|
||||
import android.animation.ValueAnimator
|
||||
import android.content.Context
|
||||
import android.content.pm.PackageInfo
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.view.animation.LinearInterpolator
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.RelativeLayout
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.fragment.app.FragmentTransaction
|
||||
import androidx.lifecycle.Lifecycle
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.gh.base.BaseRecyclerViewHolder
|
||||
import com.gh.common.constant.Constants
|
||||
import com.gh.common.util.*
|
||||
import com.gh.common.view.CustomLinkMovementMethod
|
||||
import com.gh.download.DownloadManager
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.databinding.FragmentPackageCheckBinding
|
||||
import com.gh.gamecenter.databinding.PackageCheckItemBinding
|
||||
import com.gh.gamecenter.entity.DetectionObjectEntity
|
||||
import com.gh.gamecenter.entity.GameEntity
|
||||
import com.gh.gamecenter.entity.LinkEntity
|
||||
import com.gh.gamecenter.entity.PackageDialogEntity
|
||||
import com.gh.gamecenter.eventbus.EBPackage
|
||||
import com.halo.assistant.HaloApp
|
||||
import com.lightgame.adapter.BaseRecyclerAdapter
|
||||
import com.lightgame.dialog.BaseDialogFragment
|
||||
import com.lightgame.download.DataWatcher
|
||||
import com.lightgame.download.DownloadEntity
|
||||
import com.lightgame.download.DownloadStatus
|
||||
import io.reactivex.disposables.Disposable
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import org.greenrobot.eventbus.Subscribe
|
||||
@ -33,6 +42,7 @@ import org.greenrobot.eventbus.ThreadMode
|
||||
/**
|
||||
* 包名检测弹窗
|
||||
*/
|
||||
// TODO 将 gameEntity 放到 argument 里再取出,避免重建时为空
|
||||
class PackageCheckDialogFragment : BaseDialogFragment() {
|
||||
|
||||
private lateinit var binding: FragmentPackageCheckBinding
|
||||
@ -40,12 +50,33 @@ class PackageCheckDialogFragment : BaseDialogFragment() {
|
||||
private val mDuration = 3000
|
||||
private var mDisposable: Disposable? = null
|
||||
private var mAdapter: PackageCheckAdapter? = null
|
||||
var packageDialogEntity: PackageDialogEntity? = null
|
||||
private var mAllInstalledPackages = PackageUtils.getInstalledPackages(HaloApp.getInstance().application, 0)
|
||||
var gameEntity: GameEntity? = null
|
||||
var callBack: DialogUtils.ConfirmListener? = null
|
||||
|
||||
private val dataWatcher = object : DataWatcher() {
|
||||
override fun onDataChanged(downloadEntity: DownloadEntity) {
|
||||
val packageName = downloadEntity.packageName
|
||||
val detectionObjects = gameEntity?.packageDialog?.detectionObjects
|
||||
if (DownloadStatus.add == downloadEntity.status || DownloadStatus.done == downloadEntity.status) {
|
||||
detectionObjects?.forEach { detectionObject ->
|
||||
if (detectionObject.packages.contains(packageName)) {
|
||||
val packageLink = gameEntity?.packageDialog?.links?.find { it.buttonLink }
|
||||
LogUtils.uploadPackageCheck("pkg_check_pop_download", if (DownloadStatus.add == downloadEntity.status) "下载开始" else "下载完成",
|
||||
gameEntity, packageLink?.text ?: "", packageLink?.title
|
||||
?: "", downloadEntity.gameId, downloadEntity.getMetaExtra(Constants.GAME_NAME))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
EventBus.getDefault().register(this)
|
||||
gameEntity?.let {
|
||||
LogUtils.uploadPackageCheck("pkg_check_pop_click", "出现弹窗", it, "", "", "", "")
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||
@ -55,7 +86,7 @@ class PackageCheckDialogFragment : BaseDialogFragment() {
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
packageDialogEntity?.let {
|
||||
gameEntity?.packageDialog?.let {
|
||||
changeParams(it.detectionObjects.size)
|
||||
|
||||
binding.packageRv.layoutManager = LinearLayoutManager(requireContext())
|
||||
@ -69,6 +100,7 @@ class PackageCheckDialogFragment : BaseDialogFragment() {
|
||||
it.links.forEachIndexed { index, link ->
|
||||
val linkSpan = SpanBuilder(link.title ?: "").click(0, (link.title
|
||||
?: "").length, R.color.theme_font, true) {
|
||||
LogUtils.uploadPackageCheck("pkg_check_pop_click", "点击链接", gameEntity, link.text, link.title, "", "")
|
||||
DirectUtils.directToLinkPage(requireContext(), link, "包名检测弹窗", "")
|
||||
}.build()
|
||||
spanBuilder.append(linkSpan)
|
||||
@ -88,6 +120,10 @@ class PackageCheckDialogFragment : BaseDialogFragment() {
|
||||
binding.cancelTv.text = "我知道了"
|
||||
binding.noRemindAgainCb.visibility = View.GONE
|
||||
}
|
||||
"OPTIONAL_CURRENT_HINT" -> {
|
||||
binding.cancelTv.text = "我知道了"
|
||||
binding.noRemindAgainCb.visibility = View.VISIBLE
|
||||
}
|
||||
else -> {
|
||||
binding.cancelTv.text = "我知道了"
|
||||
binding.noRemindAgainCb.visibility = View.VISIBLE
|
||||
@ -95,7 +131,9 @@ class PackageCheckDialogFragment : BaseDialogFragment() {
|
||||
}
|
||||
initListener(it)
|
||||
}
|
||||
checkPackage()
|
||||
binding.root.post {
|
||||
checkPackage()
|
||||
}
|
||||
}
|
||||
|
||||
private fun changeParams(size: Int) {
|
||||
@ -107,15 +145,19 @@ class PackageCheckDialogFragment : BaseDialogFragment() {
|
||||
private fun initListener(entity: PackageDialogEntity) {
|
||||
binding.downloadBtn.setOnClickListener {
|
||||
if (binding.noRemindAgainCb.isChecked) {
|
||||
SPUtils.setBoolean(Constants.SP_PACKAGE_CHECK, true)
|
||||
saveRecord(entity)
|
||||
}
|
||||
val isAllPackageInstalled = isAllPackageInstalled(entity)
|
||||
val isAllPackageInstalled = isAllPackageInstalled(mAllInstalledPackages, entity)
|
||||
if (isAllPackageInstalled) {
|
||||
callBack?.onConfirm()
|
||||
dismissAllowingStateLoss()
|
||||
} else {
|
||||
val packageLink = entity.links.find { it.buttonLink }
|
||||
var packageLink = getNotInstalledLink(entity)
|
||||
if (packageLink == null) {
|
||||
packageLink = entity.links.find { it.buttonLink }
|
||||
}
|
||||
if (packageLink != null) {
|
||||
LogUtils.uploadPackageCheck("pkg_check_pop_click", "点击前往下载", gameEntity, packageLink.text, packageLink.title, "", "")
|
||||
DirectUtils.directToLinkPage(requireContext(), packageLink, "包名检测弹窗", "")
|
||||
}
|
||||
}
|
||||
@ -126,22 +168,26 @@ class PackageCheckDialogFragment : BaseDialogFragment() {
|
||||
callBack?.onConfirm()
|
||||
}
|
||||
if (binding.noRemindAgainCb.isChecked) {
|
||||
SPUtils.setBoolean(Constants.SP_PACKAGE_CHECK, true)
|
||||
saveRecord(entity)
|
||||
LogUtils.uploadPackageCheck("pkg_check_pop_click", "不再提示", gameEntity, "", "", "", "")
|
||||
}
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
}
|
||||
|
||||
private fun saveRecord(entity: PackageDialogEntity) {
|
||||
if (entity.level == "OPTIONAL_CURRENT_HINT") {
|
||||
SPUtils.setBoolean("${Constants.SP_PACKAGE_CHECK}:${gameEntity?.id}", true)
|
||||
} else {
|
||||
SPUtils.setBoolean("${Constants.SP_PACKAGE_CHECK}:${gameEntity?.packageDialog?.id}", true)
|
||||
}
|
||||
}
|
||||
|
||||
private fun checkPackage() {
|
||||
var index = 0
|
||||
mTotalWidth = (DisplayUtils.getScreenWidth() - 108f.dip2px()).toFloat()
|
||||
mDisposable = rxTimer(1) {
|
||||
val width = (mTotalWidth / mDuration) * it
|
||||
val params = binding.progressView.layoutParams as RelativeLayout.LayoutParams
|
||||
params.width = width.toInt()
|
||||
binding.progressView.layoutParams = params
|
||||
|
||||
packageDialogEntity?.detectionObjects?.let { objects ->
|
||||
gameEntity?.packageDialog?.detectionObjects?.let { objects ->
|
||||
if (objects.isNotEmpty()) {
|
||||
val averageTime = if (objects.size == 1) {
|
||||
mDuration
|
||||
@ -159,24 +205,49 @@ class PackageCheckDialogFragment : BaseDialogFragment() {
|
||||
if (it >= mDuration) {
|
||||
mDisposable?.dispose()
|
||||
binding.downloadBtn.isEnabled = true
|
||||
binding.progressText.text = "检测完成"
|
||||
binding.progressView.background = ContextCompat.getDrawable(requireContext(), R.drawable.package_check_complete_bg)
|
||||
}
|
||||
}
|
||||
val animator = ValueAnimator.ofInt(0, 100)
|
||||
animator.duration = mDuration.toLong()
|
||||
animator.interpolator = LinearInterpolator()
|
||||
animator.addUpdateListener {
|
||||
binding.progressBar.progress = it.animatedValue as Int
|
||||
}
|
||||
animator.start()
|
||||
}
|
||||
|
||||
private fun getNotInstalledLink(packageDialogEntity: PackageDialogEntity): LinkEntity? {
|
||||
val links = LinkedHashSet<LinkEntity>()
|
||||
packageDialogEntity.detectionObjects.forEach { obj ->
|
||||
if (!checkDetectionsInstalled(mAllInstalledPackages, obj.packages)) {
|
||||
obj.assignDownload.forEach {
|
||||
links.add(packageDialogEntity.links[it])
|
||||
}
|
||||
}
|
||||
}
|
||||
var link: LinkEntity? = null
|
||||
if (links.size > 1) {
|
||||
link = links.find { it.buttonLink } ?: links.toList()[0]
|
||||
} else if (links.size == 1) {
|
||||
link = links.toList()[0]
|
||||
}
|
||||
return link
|
||||
}
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
val width = requireContext().resources.displayMetrics.widthPixels - 60F.dip2px()
|
||||
val height = ViewGroup.LayoutParams.WRAP_CONTENT
|
||||
dialog?.window?.setLayout(width, height)
|
||||
dialog?.setCanceledOnTouchOutside(true)
|
||||
requireDialog().window?.setLayout(width, height)
|
||||
requireDialog().setCanceledOnTouchOutside(true)
|
||||
DownloadManager.getInstance(context).addObserver(dataWatcher)
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
packageDialogEntity?.let {
|
||||
if (isAllPackageInstalled(it)) {
|
||||
mAllInstalledPackages = PackageUtils.getInstalledPackages(HaloApp.getInstance().application, 0)
|
||||
gameEntity?.packageDialog?.let {
|
||||
if (isAllPackageInstalled(mAllInstalledPackages, it)) {
|
||||
callBack?.onConfirm()
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
@ -189,22 +260,25 @@ class PackageCheckDialogFragment : BaseDialogFragment() {
|
||||
if (mDisposable?.isDisposed == false) {
|
||||
mDisposable?.dispose()
|
||||
}
|
||||
LogUtils.uploadPackageCheck("pkg_check_pop_click", "关闭弹窗", gameEntity, "", "", "", "")
|
||||
DownloadManager.getInstance(context).removeObserver(dataWatcher)
|
||||
}
|
||||
|
||||
//安装、卸载事件
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
fun onEventMainThread(busFour: EBPackage) {
|
||||
if ("安装" == busFour.type || "卸载" == busFour.type) {
|
||||
mAllInstalledPackages = PackageUtils.getInstalledPackages(HaloApp.getInstance().application, 0)
|
||||
mAdapter?.notifyDataSetChanged()
|
||||
}
|
||||
}
|
||||
|
||||
class PackageCheckAdapter(val context: Context, val entities: ArrayList<DetectionObjectEntity>) : BaseRecyclerAdapter<RecyclerView.ViewHolder>(context) {
|
||||
inner class PackageCheckAdapter(val context: Context, val entities: ArrayList<DetectionObjectEntity>) : BaseRecyclerAdapter<RecyclerView.ViewHolder>(context) {
|
||||
private var index = -1
|
||||
|
||||
fun notifyPackages() {
|
||||
index++
|
||||
notifyDataSetChanged()
|
||||
notifyItemChanged(index)
|
||||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
|
||||
@ -218,14 +292,7 @@ class PackageCheckDialogFragment : BaseDialogFragment() {
|
||||
val entity = entities[position]
|
||||
holder.binding.entity = entity
|
||||
if (position <= index) {
|
||||
var isAllInstalled = false
|
||||
entity.packages.forEach { packageName ->
|
||||
val isInstalled = PackageUtils.getInstalledPackages(context, 0).find { it.packageName == packageName } != null
|
||||
if (isInstalled) {
|
||||
isAllInstalled = true
|
||||
return@forEach
|
||||
}
|
||||
}
|
||||
val isAllInstalled = checkDetectionsInstalled(mAllInstalledPackages, entity.packages)
|
||||
if (isAllInstalled) {
|
||||
holder.binding.statusTv.text = "已安装"
|
||||
holder.binding.statusTv.setTextColor(ContextCompat.getColor(context, R.color.theme_font))
|
||||
@ -245,56 +312,65 @@ class PackageCheckDialogFragment : BaseDialogFragment() {
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun show(activity: AppCompatActivity, packageDialogEntity: PackageDialogEntity?, callBack: DialogUtils.ConfirmListener) {
|
||||
fun show(activity: AppCompatActivity, gameEntity: GameEntity, callBack: DialogUtils.ConfirmListener) {
|
||||
val packageDialogEntity = gameEntity.packageDialog
|
||||
if (packageDialogEntity == null) {
|
||||
callBack.onConfirm()
|
||||
return
|
||||
}
|
||||
if (isAllPackageInstalled(packageDialogEntity)) {
|
||||
|
||||
val allInstalledPackages = PackageUtils.getInstalledPackages(HaloApp.getInstance().application, 0)
|
||||
if (isAllPackageInstalled(allInstalledPackages, packageDialogEntity)) {
|
||||
callBack.onConfirm()
|
||||
return
|
||||
}
|
||||
val isChoose = SPUtils.getBoolean(Constants.SP_PACKAGE_CHECK, false)
|
||||
|
||||
val isChoose = SPUtils.getBoolean("${Constants.SP_PACKAGE_CHECK}:${packageDialogEntity.id}", false)
|
||||
if (packageDialogEntity.level == "OPTIONAL_HINT" && isChoose) {
|
||||
callBack.onConfirm()
|
||||
return
|
||||
}
|
||||
|
||||
val isCurrentGameChoose = SPUtils.getBoolean("${Constants.SP_PACKAGE_CHECK}:${gameEntity.id}", false)
|
||||
if (packageDialogEntity.level == "OPTIONAL_CURRENT_HINT" && isCurrentGameChoose) {
|
||||
callBack.onConfirm()
|
||||
return
|
||||
}
|
||||
|
||||
if (!activity.lifecycle.currentState.isAtLeast(Lifecycle.State.RESUMED)) return
|
||||
|
||||
var dialogFragment = activity.supportFragmentManager.findFragmentByTag(PackageCheckDialogFragment::class.java.simpleName) as? PackageCheckDialogFragment
|
||||
if (dialogFragment == null) {
|
||||
dialogFragment = PackageCheckDialogFragment()
|
||||
dialogFragment.packageDialogEntity = packageDialogEntity
|
||||
dialogFragment.gameEntity = gameEntity
|
||||
dialogFragment.callBack = callBack
|
||||
|
||||
dialogFragment.show(activity.supportFragmentManager, PackageCheckDialogFragment::class.java.simpleName)
|
||||
} else {
|
||||
dialogFragment.packageDialogEntity = packageDialogEntity
|
||||
dialogFragment.gameEntity = gameEntity
|
||||
dialogFragment.callBack = callBack
|
||||
|
||||
val transaction: FragmentTransaction = activity.supportFragmentManager.beginTransaction()
|
||||
transaction.show(dialogFragment)
|
||||
transaction.commit()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fun isAllPackageInstalled(packageDialogEntity: PackageDialogEntity): Boolean {
|
||||
var isAllInstalled = true
|
||||
|
||||
val isPackagesInstall: (ArrayList<String>) -> Boolean = { packages ->
|
||||
var isPackagesInstalled = false
|
||||
packages.forEach {packageName->
|
||||
val isInstalled = PackageUtils.getInstalledPackages(HaloApp.getInstance().application, 0).find { it.packageName == packageName } != null
|
||||
if (isInstalled) {
|
||||
isPackagesInstalled = true
|
||||
return@forEach
|
||||
}
|
||||
private fun checkDetectionsInstalled(allInstalledPackages: List<PackageInfo>, packages: ArrayList<String>): Boolean {
|
||||
var isPackagesInstalled = false
|
||||
packages.forEach { packageName ->
|
||||
val isInstalled = allInstalledPackages.find { it.packageName == packageName } != null
|
||||
if (isInstalled) {
|
||||
isPackagesInstalled = true
|
||||
return@forEach
|
||||
}
|
||||
isPackagesInstalled
|
||||
}
|
||||
return isPackagesInstalled
|
||||
}
|
||||
|
||||
|
||||
fun isAllPackageInstalled(allInstalledPackages: List<PackageInfo>, packageDialogEntity: PackageDialogEntity): Boolean {
|
||||
var isAllInstalled = true
|
||||
packageDialogEntity.detectionObjects.forEach loop@{ obj ->
|
||||
if (!isPackagesInstall(obj.packages)) {
|
||||
if (!checkDetectionsInstalled(allInstalledPackages, obj.packages)) {
|
||||
isAllInstalled = false
|
||||
return isAllInstalled
|
||||
}
|
||||
|
||||
@ -14,10 +14,10 @@ import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.fragment.app.FragmentTransaction
|
||||
import com.gh.base.fragment.BaseDialogFragment
|
||||
import com.gh.common.util.DirectUtils.directToExternalBrowser
|
||||
import com.gh.common.util.dip2px
|
||||
import com.gh.common.view.CustomLinkMovementMethod
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.WebActivity
|
||||
|
||||
class PrivacyDialogFragment : BaseDialogFragment() {
|
||||
|
||||
@ -53,7 +53,8 @@ class PrivacyDialogFragment : BaseDialogFragment() {
|
||||
}
|
||||
|
||||
override fun onClick(widget: View) {
|
||||
directToExternalBrowser(context!!, context!!.getString(R.string.privacy_policy_url))
|
||||
val intent = WebActivity.getIntent(requireContext(), context!!.getString(R.string.privacy_policy_url), true)
|
||||
context?.startActivity(intent)
|
||||
}
|
||||
}, skipText.length - 9, skipText.length - 5, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
|
||||
|
||||
@ -65,7 +66,8 @@ class PrivacyDialogFragment : BaseDialogFragment() {
|
||||
}
|
||||
|
||||
override fun onClick(widget: View) {
|
||||
directToExternalBrowser(requireContext(), requireContext().getString(R.string.disclaimer_url))
|
||||
val intent = WebActivity.getIntent(requireContext(), context!!.getString(R.string.disclaimer_url), true)
|
||||
context?.startActivity(intent)
|
||||
}
|
||||
}, skipText.length - 4, skipText.length, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
|
||||
descTv?.movementMethod = CustomLinkMovementMethod()
|
||||
|
||||
@ -13,9 +13,17 @@ data class ExposureEntity(
|
||||
val gameName: String? = "",
|
||||
val gameVersion: String? = "",
|
||||
val sequence: Int? = 0,
|
||||
val outerSequence: Int? = 0,
|
||||
val platform: String? = "",
|
||||
var isMirrorData: Boolean = false,
|
||||
@SerializedName("is_web_download")
|
||||
var isWebDownload: Boolean = false,
|
||||
val downloadType: String? = "",
|
||||
val downloadCompleteType: String? = "",
|
||||
@SerializedName("display_type")
|
||||
val displayType: String? = "",
|
||||
@SerializedName("is_platform_recommend")
|
||||
val isPlatformRecommend: Boolean? = false,
|
||||
|
||||
// 下载地址的 host 和 path
|
||||
var host: String? = "",
|
||||
|
||||
@ -9,9 +9,12 @@ import com.gh.common.exposure.meta.Meta
|
||||
import com.gh.common.exposure.meta.MetaUtil
|
||||
import com.gh.common.exposure.time.TimeUtil
|
||||
import com.gh.common.util.getFirstElementDividedByDivider
|
||||
import com.gh.download.server.BrowserInstallHelper
|
||||
import com.gh.gamecenter.entity.GameEntity
|
||||
import com.lightgame.download.DownloadEntity
|
||||
import kotlinx.android.parcel.Parcelize
|
||||
import java.util.*
|
||||
import kotlin.collections.ArrayList
|
||||
|
||||
@Keep
|
||||
@Parcelize
|
||||
@ -29,19 +32,27 @@ data class ExposureEvent(
|
||||
|
||||
// TODO 建一个 exposureEvent 池规避反复生成对象
|
||||
@JvmStatic
|
||||
fun createEvent(gameEntity: GameEntity?, source: List<ExposureSource>, eTrace: List<ExposureEvent>? = null, event: ExposureType = ExposureType.EXPOSURE): ExposureEvent {
|
||||
fun createEvent(gameEntity: GameEntity?,
|
||||
source: List<ExposureSource>,
|
||||
eTrace: List<ExposureEvent>? = null,
|
||||
event: ExposureType = ExposureType.EXPOSURE): ExposureEvent {
|
||||
if (gameEntity?.getApk()?.size == 1) {
|
||||
gameEntity.gameVersion = gameEntity.getApk().elementAtOrNull(0)?.version ?: ""
|
||||
}
|
||||
return ExposureEvent(
|
||||
payload = ExposureEntity(
|
||||
gameId = gameEntity?.id?.getFirstElementDividedByDivider(Constants.GAME_ID_DIVIDER),
|
||||
gameName = gameEntity?.name?.removeSuffix(Constants.GAME_NAME_DECORATOR),
|
||||
gameVersion = gameEntity?.gameVersion,
|
||||
sequence = gameEntity?.sequence,
|
||||
platform = gameEntity?.platform,
|
||||
gameId = gameEntity?.id?.getFirstElementDividedByDivider(DownloadEntity.GAME_ID_DIVIDER),
|
||||
gameName = eTrace?.firstOrNull()?.payload?.gameName ?: gameEntity?.name?.removeSuffix(Constants.GAME_NAME_DECORATOR),
|
||||
gameVersion = eTrace?.firstOrNull()?.payload?.gameVersion ?:gameEntity?.gameVersion,
|
||||
isMirrorData = eTrace?.firstOrNull()?.payload?.isMirrorData ?: gameEntity?.shouldUseMirrorInfo() ?: false,
|
||||
isWebDownload = BrowserInstallHelper.isUseBrowserToInstallEnabled() && BrowserInstallHelper.shouldUseBrowserToInstall(), // 实时的值,不用从 eTrace 里取
|
||||
sequence = eTrace?.firstOrNull()?.payload?.sequence ?: gameEntity?.sequence,
|
||||
outerSequence = eTrace?.firstOrNull()?.payload?.outerSequence ?: gameEntity?.outerSequence,
|
||||
platform = eTrace?.firstOrNull()?.payload?.platform ?:gameEntity?.platform,
|
||||
downloadType = gameEntity?.downloadType,
|
||||
downloadCompleteType = gameEntity?.downloadCompleteType,
|
||||
displayType = eTrace?.firstOrNull()?.payload?.displayType ?:gameEntity?.displayContent,
|
||||
isPlatformRecommend = gameEntity?.isPlatformRecommend ?: false,
|
||||
// ugly
|
||||
welcomeDialogId = gameEntity?.welcomeDialogId ?: eTrace?.firstOrNull()?.payload?.welcomeDialogId,
|
||||
welcomeDialogLinkTitle = gameEntity?.welcomeDialogTitle ?: eTrace?.firstOrNull()?.payload?.welcomeDialogLinkTitle),
|
||||
@ -49,5 +60,19 @@ data class ExposureEvent(
|
||||
eTrace = eTrace,
|
||||
event = event).apply { gameEntity?.exposureEvent = this }
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun createEventWithSourceConcat(gameEntity: GameEntity?,
|
||||
basicSource: List<ExposureSource>,
|
||||
source: List<ExposureSource>,
|
||||
eTrace: List<ExposureEvent>? = null,
|
||||
event: ExposureType = ExposureType.EXPOSURE): ExposureEvent {
|
||||
val concatSourceList = ArrayList<ExposureSource>().apply {
|
||||
addAll(basicSource)
|
||||
addAll(source)
|
||||
}
|
||||
return createEvent(gameEntity, concatSourceList, eTrace, event)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@ -11,20 +11,16 @@ import io.reactivex.functions.Consumer
|
||||
*/
|
||||
class ExposureListener(var fragment: Fragment, var exposable: IExposable) : RecyclerView.OnScrollListener() {
|
||||
|
||||
var throttleBus: ExposureThrottleBus? = null
|
||||
val throttleBus: ExposureThrottleBus by lazy { ExposureThrottleBus(Consumer { commitExposure(it) }, Consumer(Throwable::printStackTrace)) }
|
||||
var layoutManager: LinearLayoutManager? = null
|
||||
var visibleState: ExposureThrottleBus.VisibleState? = null
|
||||
|
||||
init {
|
||||
fragment.fragmentManager?.registerFragmentLifecycleCallbacks(
|
||||
object : FragmentManager.FragmentLifecycleCallbacks() {
|
||||
override fun onFragmentResumed(fm: FragmentManager, f: Fragment) {
|
||||
throttleBus = ExposureThrottleBus(Consumer { commitExposure(it) }, Consumer(Throwable::printStackTrace))
|
||||
}
|
||||
|
||||
override fun onFragmentPaused(fm: FragmentManager, f: Fragment) {
|
||||
visibleState?.let { commitExposure(it) }
|
||||
throttleBus?.clear()
|
||||
throttleBus.clear()
|
||||
}
|
||||
|
||||
override fun onFragmentViewDestroyed(fm: FragmentManager, f: Fragment) {
|
||||
@ -44,7 +40,7 @@ class ExposureListener(var fragment: Fragment, var exposable: IExposable) : Recy
|
||||
|
||||
layoutManager?.run {
|
||||
visibleState = ExposureThrottleBus.VisibleState(findFirstVisibleItemPosition(), findLastVisibleItemPosition())
|
||||
throttleBus?.postVisibleState(visibleState!!)
|
||||
throttleBus.postVisibleState(visibleState!!)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,15 +1,13 @@
|
||||
package com.gh.common.exposure
|
||||
|
||||
import com.aliyun.sls.android.sdk.model.LogGroup
|
||||
import com.gh.common.exposure.time.TimeUtil
|
||||
import com.aliyun.sls.android.producer.Log
|
||||
import com.gh.common.loghub.LoghubHelper
|
||||
import com.gh.common.util.toJson
|
||||
import com.gh.common.util.tryWithDefaultCatch
|
||||
import com.gh.gamecenter.BuildConfig
|
||||
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 java.util.concurrent.ExecutorService
|
||||
|
||||
/**
|
||||
* A handful tool for committing logs to aliyun loghub.
|
||||
@ -22,26 +20,23 @@ import java.util.concurrent.Executors
|
||||
*/
|
||||
object ExposureManager {
|
||||
|
||||
private const val ENDPOINT = "cn-qingdao.log.aliyuncs.com"
|
||||
private const val PROJECT = "ghzs"
|
||||
private const val STORE_SIZE = 100
|
||||
private const val LOG_STORE = BuildConfig.EXPOSURE_REPO
|
||||
|
||||
private val loghubHelper = LoghubHelper.getInstance()
|
||||
|
||||
// exposureCache 用来过滤掉具有相同 id 的曝光事件,避免重复发送事件
|
||||
private val exposureSet by lazy { hashSetOf<ExposureEvent>() }
|
||||
private val exposureExecutor by lazy { Executors.newSingleThreadExecutor() }
|
||||
private var exposureExecutor: ExecutorService? = null
|
||||
private val exposureCache by lazy { FixedSizeLinkedHashSet<String>(300) }
|
||||
private val exposureDao by lazy { ExposureDatabase.buildDatabase(HaloApp.getInstance().application).logHubEventDao() }
|
||||
|
||||
@JvmStatic
|
||||
fun init() {
|
||||
loghubHelper.init(HaloApp.getInstance().application, ENDPOINT, PROJECT, LOG_STORE) { TimeUtil.currentTimeMillis() }
|
||||
|
||||
exposureExecutor.execute {
|
||||
val eventList = exposureDao.getAll()
|
||||
exposureSet.addAll(eventList)
|
||||
fun init(excutor: ExecutorService) {
|
||||
exposureExecutor = excutor
|
||||
exposureExecutor?.execute {
|
||||
tryWithDefaultCatch {
|
||||
val eventList = exposureDao.getAll()
|
||||
exposureSet.addAll(eventList)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -49,7 +44,7 @@ object ExposureManager {
|
||||
* Log a single exposure event.
|
||||
*/
|
||||
fun log(event: ExposureEvent) {
|
||||
exposureExecutor.execute {
|
||||
exposureExecutor?.execute {
|
||||
try {
|
||||
if (!exposureCache.contains(event.id)) {
|
||||
// Catch `android.database.sqlite.SQLiteFullException: database or disk is full` exception.
|
||||
@ -71,7 +66,7 @@ object ExposureManager {
|
||||
* Log a collection of exposure event.
|
||||
*/
|
||||
fun log(eventList: List<ExposureEvent>) {
|
||||
exposureExecutor.execute {
|
||||
exposureExecutor?.execute {
|
||||
for (event in eventList) {
|
||||
try {
|
||||
if (!exposureCache.contains(event.id)) {
|
||||
@ -94,14 +89,13 @@ object ExposureManager {
|
||||
* @param forced Ignore all restrictions.
|
||||
*/
|
||||
fun commitSavedExposureEvents(forced: Boolean = false) {
|
||||
exposureExecutor.execute {
|
||||
exposureExecutor?.execute {
|
||||
tryWithDefaultCatch {
|
||||
// TODO 初始化 loghubHelper 去掉这个 tryCatch 块
|
||||
if (exposureSet.size < STORE_SIZE && !forced || exposureSet.size == 0) return@execute
|
||||
|
||||
val exposureList = exposureSet.toList()
|
||||
// uploadLogGroup 是一个异步方法,LoghubHelper 里面实现了重传功能,所以这里交给它就好了
|
||||
loghubHelper.uploadLogGroup(buildLogGroup(exposureList))
|
||||
uploadExposures(exposureList)
|
||||
|
||||
Utils.log("Exposure", "提交了${exposureList.size}条曝光记录")
|
||||
exposureSet.removeAll(exposureList)
|
||||
@ -114,31 +108,25 @@ object ExposureManager {
|
||||
return jsonWithMultipleBracket.replace("[[", "[").replace("]]", "]")
|
||||
}
|
||||
|
||||
private fun buildLogGroup(eventList: List<ExposureEvent>): LogGroup {
|
||||
val logGroup = LogGroup("sls android", "no ip")
|
||||
|
||||
eventList.forEach { logGroup.PutLog(buildLog(it)) }
|
||||
|
||||
return logGroup
|
||||
private fun uploadExposures(eventList: List<ExposureEvent>) {
|
||||
eventList.forEach {
|
||||
LoghubHelper.uploadLog(buildLog(it), LOG_STORE)
|
||||
}
|
||||
}
|
||||
|
||||
private fun buildLog(event: ExposureEvent): LgLOG {
|
||||
val log = LgLOG(TimeUtil.currentTime())
|
||||
|
||||
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) {
|
||||
private fun buildLog(event: ExposureEvent) = Log().apply {
|
||||
putContent("id", event.id)
|
||||
putContent("payload", event.payload.toJson())
|
||||
putContent("event", event.event.toString())
|
||||
putContent("source", eliminateMultipleBrackets(event.source.toJson()))
|
||||
putContent("meta", event.meta.toJson())
|
||||
putContent("e-traces", if (event.eTrace != null) {
|
||||
eliminateMultipleBrackets(event.eTrace?.toJson() ?: "")
|
||||
} else "")
|
||||
log.PutTime(event.time)
|
||||
|
||||
return log
|
||||
logTime = event.time.toLong()
|
||||
}
|
||||
|
||||
internal class FixedSizeLinkedHashSet<T>(var maxSize: Int) : LinkedHashSet<T>() {
|
||||
class FixedSizeLinkedHashSet<T>(var maxSize: Int) : LinkedHashSet<T>() {
|
||||
override fun add(element: T): Boolean {
|
||||
if (size == maxSize) {
|
||||
pop()
|
||||
|
||||
@ -2,35 +2,39 @@ package com.gh.common.exposure
|
||||
|
||||
import android.text.TextUtils
|
||||
import com.g00fy2.versioncompare.Version
|
||||
import com.gh.common.constant.Constants
|
||||
import com.gh.common.util.PackageUtils
|
||||
import com.gh.common.util.toObject
|
||||
import com.gh.gamecenter.entity.ApkEntity
|
||||
import com.gh.gamecenter.entity.GameEntity
|
||||
import com.halo.assistant.HaloApp
|
||||
import java.util.*
|
||||
import com.lightgame.download.DownloadEntity
|
||||
|
||||
object ExposureUtils {
|
||||
|
||||
private val mDownloadCompleteTraceEventIdSet = ExposureManager.FixedSizeLinkedHashSet<String>(3)
|
||||
|
||||
@JvmStatic
|
||||
fun logADownloadExposureEvent(entity: GameEntity,
|
||||
platform: String?,
|
||||
traceEvent: ExposureEvent?,
|
||||
downloadType: DownloadType): ExposureEvent {
|
||||
val gameEntity = entity.clone()
|
||||
gameEntity.id = if (entity.id.contains(Constants.GAME_ID_DIVIDER)) {
|
||||
entity.id.split(Constants.GAME_ID_DIVIDER).toTypedArray()[0]
|
||||
gameEntity.id = if (entity.id.contains(DownloadEntity.GAME_ID_DIVIDER)) {
|
||||
entity.id.split(DownloadEntity.GAME_ID_DIVIDER).toTypedArray()[0]
|
||||
} else {
|
||||
entity.id
|
||||
}
|
||||
gameEntity.gameVersion = entity.getApk().elementAtOrNull(0)?.version ?: gameEntity.gameVersion
|
||||
gameEntity.gameVersion = entity.getApk().elementAtOrNull(0)?.version
|
||||
?: gameEntity.gameVersion
|
||||
gameEntity.platform = platform
|
||||
gameEntity.downloadType = downloadType.toString()
|
||||
val exposureEvent = ExposureEvent.createEvent(gameEntity = gameEntity,
|
||||
source = traceEvent?.source ?: ArrayList(),
|
||||
eTrace = ExposureTraceUtils.appendTrace(traceEvent),
|
||||
event = ExposureType.DOWNLOAD)
|
||||
ExposureManager.log(exposureEvent)
|
||||
if (!TextUtils.isEmpty(entity.id)) {
|
||||
ExposureManager.log(exposureEvent)
|
||||
}
|
||||
return exposureEvent
|
||||
}
|
||||
|
||||
@ -45,6 +49,16 @@ object ExposureUtils {
|
||||
gameEntity.platform = platform
|
||||
gameEntity.downloadCompleteType = downloadType.toString()
|
||||
val traceEvent = trace?.toObject<ExposureEvent>()
|
||||
|
||||
if (TextUtils.isEmpty(entity.id)) return
|
||||
|
||||
// 避免生成 trace 相同的下载完成事件,根据日志看下载完成的同一秒有可能生成两条
|
||||
if (mDownloadCompleteTraceEventIdSet.contains(traceEvent?.id)) {
|
||||
return
|
||||
}
|
||||
|
||||
traceEvent?.payload?.gameId?.let { mDownloadCompleteTraceEventIdSet.add(it) }
|
||||
|
||||
val exposureEvent = ExposureEvent.createEvent(gameEntity = gameEntity,
|
||||
source = traceEvent?.source ?: ArrayList(),
|
||||
eTrace = ExposureTraceUtils.appendTrace(traceEvent),
|
||||
@ -80,6 +94,15 @@ object ExposureUtils {
|
||||
}
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun updateExposureSequence(gameList: List<GameEntity>?) {
|
||||
gameList?.let {
|
||||
for ((index, game) in it.withIndex()) {
|
||||
game.sequence = index
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
enum class DownloadType {
|
||||
DOWNLOAD,
|
||||
|
||||
|
||||
@ -8,10 +8,10 @@ import kotlinx.android.parcel.Parcelize
|
||||
@Parcelize
|
||||
data class Meta(
|
||||
val mac: String? = "",
|
||||
val imei: String? = "",
|
||||
val jnfj: String? = "",
|
||||
val model: String? = "",
|
||||
val manufacturer: String? = "",
|
||||
val android_id: String? = "",
|
||||
val dia: String? = "",
|
||||
val android_sdk: Int? = -1,
|
||||
val android_version: String? = "",
|
||||
val network: String? = "",
|
||||
|
||||
@ -11,6 +11,7 @@ import android.telephony.TelephonyManager
|
||||
import android.text.TextUtils
|
||||
import com.gh.common.constant.Constants
|
||||
import com.gh.common.util.SPUtils
|
||||
import com.gh.common.util.tryWithDefaultCatch
|
||||
import com.gh.gamecenter.BuildConfig
|
||||
import com.gh.gamecenter.manager.UserManager
|
||||
import com.halo.assistant.HaloApp
|
||||
@ -26,13 +27,25 @@ object MetaUtil {
|
||||
private var imei: String? = null
|
||||
private var base64EncodedImei: String? = null
|
||||
private var androidId: String? = null
|
||||
private var base64EncodedAndroidId: String? = null
|
||||
|
||||
private var romName: String? = null
|
||||
private var romVersion: String? = null
|
||||
|
||||
fun refreshMeta() {
|
||||
|
||||
if (romName == null) {
|
||||
tryWithDefaultCatch {
|
||||
romName = RomIdentifier.getRom().name
|
||||
romVersion = RomIdentifier.getRom().versionName
|
||||
}
|
||||
}
|
||||
|
||||
m = Meta(mac = "",
|
||||
imei = getIMEI(),
|
||||
jnfj = getBase64EncodedIMEI(),
|
||||
model = getModel(),
|
||||
manufacturer = getManufacturer(),
|
||||
android_id = getAndroidId(),
|
||||
dia = getBase64EncodedAndroidId(),
|
||||
android_sdk = getAndroidSDK(),
|
||||
android_version = getAndroidVersion(),
|
||||
network = getNetwork(),
|
||||
@ -43,7 +56,7 @@ object MetaUtil {
|
||||
appVersion = BuildConfig.VERSION_NAME,
|
||||
userId = UserManager.getInstance().userId,
|
||||
exposureVersion = BuildConfig.EXPOSURE_VERSION,
|
||||
rom = RomIdentifier.getRom().name + "" + RomIdentifier.getRom().versionName)
|
||||
rom = romName + "" + romVersion)
|
||||
}
|
||||
|
||||
fun getMeta(): Meta {
|
||||
@ -107,6 +120,10 @@ object MetaUtil {
|
||||
|
||||
@JvmStatic
|
||||
fun getBase64EncodedIMEI(): String {
|
||||
if (imei == null) {
|
||||
getIMEI()
|
||||
}
|
||||
|
||||
if (TextUtils.isEmpty(base64EncodedImei) && imei != null) {
|
||||
try {
|
||||
base64EncodedImei = android.util.Base64.encodeToString(getIMEI().trim().toByteArray(), android.util.Base64.NO_WRAP)
|
||||
@ -119,6 +136,24 @@ object MetaUtil {
|
||||
return base64EncodedImei ?: ""
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getBase64EncodedAndroidId(): String {
|
||||
if (androidId == null) {
|
||||
getAndroidId()
|
||||
}
|
||||
|
||||
if (TextUtils.isEmpty(base64EncodedAndroidId) && androidId != null) {
|
||||
try {
|
||||
base64EncodedAndroidId = android.util.Base64.encodeToString(getAndroidId().trim().toByteArray(), android.util.Base64.NO_WRAP)
|
||||
} catch (e: java.lang.Exception) {
|
||||
e.printStackTrace()
|
||||
return ""
|
||||
}
|
||||
}
|
||||
|
||||
return base64EncodedAndroidId ?: ""
|
||||
}
|
||||
|
||||
fun getModel(): String? {
|
||||
return Build.MODEL
|
||||
}
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
package com.gh.common.filter
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import com.gh.common.AppExecutor
|
||||
import com.gh.common.constant.Constants
|
||||
import com.gh.common.util.SPUtils
|
||||
import com.gh.common.util.debounceActionWithInterval
|
||||
@ -14,6 +13,7 @@ import com.gh.gamecenter.retrofit.RetrofitManager
|
||||
import com.halo.assistant.HaloApp
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.functions.Function
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
|
||||
object RegionSettingHelper {
|
||||
|
||||
@ -67,7 +67,7 @@ object RegionSettingHelper {
|
||||
RetrofitManager.getInstance(HaloApp.getInstance().application)
|
||||
.sensitiveApi
|
||||
.getRegionSetting(HaloApp.getInstance().channel)
|
||||
.subscribeOn(AppExecutor.cachedScheduler)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(object : BiResponse<RegionSetting>() {
|
||||
override fun onSuccess(data: RegionSetting) {
|
||||
@ -76,7 +76,7 @@ object RegionSettingHelper {
|
||||
}
|
||||
|
||||
override fun onFailure(exception: Exception) {
|
||||
SPUtils.getString(SP_SETTING).toObject<RegionSetting>()?.let {
|
||||
SPUtils.getString(SP_SETTING)?.toObject<RegionSetting>()?.let {
|
||||
updateSettingsInMemory(it)
|
||||
}
|
||||
}
|
||||
|
||||
@ -15,7 +15,7 @@ import com.gh.gamecenter.room.converter.*
|
||||
import com.gh.gamecenter.room.dao.*
|
||||
import com.halo.assistant.HaloApp
|
||||
|
||||
@Database(entities = [AnswerEntity::class, ArticleEntity::class, NewsEntity::class, HistoryGameEntity::class, MyVideoEntity::class], version = 7, exportSchema = false)
|
||||
@Database(entities = [AnswerEntity::class, ArticleEntity::class, NewsEntity::class, HistoryGameEntity::class, MyVideoEntity::class], version = 9, exportSchema = false)
|
||||
@TypeConverters(CountConverter::class,
|
||||
CommunityConverter::class,
|
||||
TimeConverter::class,
|
||||
@ -23,8 +23,12 @@ import com.halo.assistant.HaloApp
|
||||
ThumbnailConverter::class,
|
||||
TagStyleListConverter::class,
|
||||
StringArrayListConverter::class,
|
||||
ListStringConverter::class,
|
||||
CommunityVideoConverter::class,
|
||||
UserConverter::class)
|
||||
UserConverter::class,
|
||||
ImageInfoConverter::class,
|
||||
VideoInfoConverter::class,
|
||||
QuestionsConverter::class)
|
||||
|
||||
abstract class HistoryDatabase : RoomDatabase() {
|
||||
|
||||
@ -69,6 +73,34 @@ abstract class HistoryDatabase : RoomDatabase() {
|
||||
}
|
||||
}
|
||||
|
||||
val MIGRATION_7_8: Migration = object : Migration(7, 8) {
|
||||
override fun migrate(database: SupportSQLiteDatabase) {
|
||||
database.execSQL("Alter TABLE ArticleEntity add images TEXT NOT NULL DEFAULT ''")
|
||||
database.execSQL("Alter TABLE ArticleEntity add imagesInfo TEXT NOT NULL DEFAULT ''")
|
||||
database.execSQL("Alter TABLE AnswerEntity add imagesInfo TEXT NOT NULL DEFAULT ''")
|
||||
}
|
||||
}
|
||||
|
||||
val MIGRATION_8_9: Migration = object : Migration(8, 9) {
|
||||
override fun migrate(database: SupportSQLiteDatabase) {
|
||||
database.execSQL("Alter TABLE ArticleEntity add des TEXT NOT NULL DEFAULT ''")
|
||||
database.execSQL("Alter TABLE ArticleEntity add url TEXT NOT NULL DEFAULT ''")
|
||||
database.execSQL("Alter TABLE ArticleEntity add videoInfo TEXT NOT NULL DEFAULT ''")
|
||||
database.execSQL("Alter TABLE ArticleEntity add poster TEXT NOT NULL DEFAULT ''")
|
||||
database.execSQL("Alter TABLE ArticleEntity add length INTEGER NOT NULL DEFAULT 0")
|
||||
database.execSQL("Alter TABLE ArticleEntity add status TEXT NOT NULL DEFAULT ''")
|
||||
database.execSQL("Alter TABLE ArticleEntity add content TEXT NOT NULL DEFAULT ''")
|
||||
database.execSQL("Alter TABLE ArticleEntity add questions TEXT NOT NULL DEFAULT ''")
|
||||
database.execSQL("Alter TABLE AnswerEntity add des TEXT NOT NULL DEFAULT ''")
|
||||
database.execSQL("Alter TABLE AnswerEntity add url TEXT NOT NULL DEFAULT ''")
|
||||
database.execSQL("Alter TABLE AnswerEntity add videoInfo TEXT NOT NULL DEFAULT ''")
|
||||
database.execSQL("Alter TABLE AnswerEntity add poster TEXT NOT NULL DEFAULT ''")
|
||||
database.execSQL("Alter TABLE AnswerEntity add length INTEGER NOT NULL DEFAULT 0")
|
||||
database.execSQL("Alter TABLE AnswerEntity add status TEXT NOT NULL DEFAULT ''")
|
||||
database.execSQL("Alter TABLE AnswerEntity add content TEXT NOT NULL DEFAULT ''")
|
||||
}
|
||||
}
|
||||
|
||||
val instance by lazy {
|
||||
Room.databaseBuilder(HaloApp.getInstance().application, HistoryDatabase::class.java, "USER_TRACK_HISTORY_DATABASE")
|
||||
.addMigrations(MIGRATION_2_3)
|
||||
@ -76,6 +108,8 @@ abstract class HistoryDatabase : RoomDatabase() {
|
||||
.addMigrations(MIGRATION_4_5)
|
||||
.addMigrations(MIGRATION_5_6)
|
||||
.addMigrations(MIGRATION_6_7)
|
||||
.addMigrations(MIGRATION_7_8)
|
||||
.addMigrations(MIGRATION_8_9)
|
||||
.build()
|
||||
}
|
||||
}
|
||||
|
||||
@ -69,48 +69,49 @@ object HistoryHelper {
|
||||
@JvmStatic
|
||||
fun insertNewsEntity(newsEntity: NewsEntity) {
|
||||
newsEntity.orderTag = System.currentTimeMillis()
|
||||
runOnIoThread { HistoryDatabase.instance.newsDao().addNews(newsEntity) }
|
||||
runOnIoThread { tryCatchInRelease { HistoryDatabase.instance.newsDao().addNews(newsEntity) } }
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun deleteNewsEntity(newsId: String) {
|
||||
runOnIoThread { HistoryDatabase.instance.newsDao().deleteNews(NewsEntity().apply { id = newsId }) }
|
||||
runOnIoThread { tryCatchInRelease { HistoryDatabase.instance.newsDao().deleteNews(NewsEntity().apply { id = newsId }) } }
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun deleteGameEntity(gameId: String) {
|
||||
runOnIoThread { HistoryDatabase.instance.gameDao().deleteGame(HistoryGameEntity(id = gameId)) }
|
||||
runOnIoThread { tryCatchInRelease { HistoryDatabase.instance.gameDao().deleteGame(HistoryGameEntity(id = gameId)) } }
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun deleteArticleEntity(articleId: String) {
|
||||
runOnIoThread { HistoryDatabase.instance.articleDao().deleteArticle(ArticleEntity(id = articleId)) }
|
||||
runOnIoThread { tryCatchInRelease { HistoryDatabase.instance.articleDao().deleteArticle(ArticleEntity(id = articleId)) } }
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun deleteAnswerEntity(answerId: String) {
|
||||
runOnIoThread { HistoryDatabase.instance.answerDao().deleteAnswer(AnswerEntity().apply { primaryKey = answerId }) }
|
||||
runOnIoThread { tryCatchInRelease { HistoryDatabase.instance.answerDao().deleteAnswer(AnswerEntity().apply { primaryKey = answerId }) } }
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun deleteVideoEntity(videoId: String) {
|
||||
runOnIoThread { HistoryDatabase.instance.videoHistoryDao().deleteVideo(MyVideoEntity().apply { id = videoId }) }
|
||||
runOnIoThread { tryCatchInRelease { HistoryDatabase.instance.videoHistoryDao().deleteVideo(MyVideoEntity().apply { id = videoId }) } }
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun deleteAttentionVideoRecord() {
|
||||
runOnIoThread { tryCatchInRelease { HistoryDatabase.instance.videoHistoryDao().deleteAttentionVideoRecord() } }
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun emptyDatabase() {
|
||||
runOnIoThread { HistoryDatabase.instance.clearAllTables() }
|
||||
runOnIoThread { tryCatchInRelease { HistoryDatabase.instance.clearAllTables() } }
|
||||
}
|
||||
|
||||
private fun convertArticleDetailToArticle(articleDetailEntity: ArticleDetailEntity): ArticleEntity {
|
||||
val articleEntity = ArticleEntity()
|
||||
|
||||
articleEntity.id = articleDetailEntity.id
|
||||
articleEntity.brief = articleDetailEntity.content.
|
||||
removeVideoContent().
|
||||
removeInsertedContent().
|
||||
clearHtmlFormatCompletely().
|
||||
replace(" +".toRegex()," ")
|
||||
articleEntity.brief = articleDetailEntity.content.removeVideoContent().removeInsertedContent().clearHtmlFormatCompletely().replace(" +".toRegex(), " ")
|
||||
articleEntity.count = articleDetailEntity.count
|
||||
articleDetailEntity.community.id = articleDetailEntity.communityId
|
||||
articleEntity.community = articleDetailEntity.community
|
||||
@ -118,6 +119,9 @@ object HistoryHelper {
|
||||
articleEntity.title = articleDetailEntity.title
|
||||
articleEntity.user = articleDetailEntity.user
|
||||
articleEntity.orderTag = System.currentTimeMillis()
|
||||
articleEntity.images = articleDetailEntity.images
|
||||
articleEntity.imagesInfo = articleDetailEntity.imagesInfo
|
||||
articleEntity.videos = articleDetailEntity.videos
|
||||
|
||||
return articleEntity
|
||||
}
|
||||
@ -132,12 +136,11 @@ object HistoryHelper {
|
||||
answerEntity.vote = answerDetailEntity.vote
|
||||
answerEntity.user = answerDetailEntity.user
|
||||
answerEntity.orderTag = System.currentTimeMillis()
|
||||
answerEntity.brief = answerDetailEntity.content.
|
||||
removeVideoContent().
|
||||
removeInsertedContent().
|
||||
clearHtmlFormatCompletely().
|
||||
replace(" +".toRegex(), " ")
|
||||
answerEntity.brief = answerDetailEntity.content.removeVideoContent().removeInsertedContent().clearHtmlFormatCompletely().replace(" +".toRegex(), " ")
|
||||
answerEntity.time = answerDetailEntity.time
|
||||
answerEntity.images = answerDetailEntity.images
|
||||
answerEntity.imagesInfo = answerDetailEntity.imagesInfo
|
||||
answerEntity.videos = answerDetailEntity.videos
|
||||
|
||||
return answerEntity
|
||||
}
|
||||
|
||||
32
app/src/main/java/com/gh/common/json/JsonBuilder.kt
Normal file
32
app/src/main/java/com/gh/common/json/JsonBuilder.kt
Normal file
@ -0,0 +1,32 @@
|
||||
package com.gh.common.json
|
||||
|
||||
import org.json.JSONArray
|
||||
import org.json.JSONObject
|
||||
import java.util.*
|
||||
|
||||
//Source: https://stackoverflow.com/questions/41861449/kotlin-dsl-for-creating-json-objects-without-creating-garbage
|
||||
|
||||
fun json(build: JsonObjectBuilder.() -> Unit): JSONObject {
|
||||
return JsonObjectBuilder().json(build)
|
||||
}
|
||||
|
||||
class JsonObjectBuilder {
|
||||
private val deque: Deque<JSONObject> = ArrayDeque()
|
||||
|
||||
fun json(build: JsonObjectBuilder.() -> Unit): JSONObject {
|
||||
deque.push(JSONObject())
|
||||
this.build()
|
||||
return deque.pop()
|
||||
}
|
||||
|
||||
infix fun <T> String.to(value: T) {
|
||||
// wrap value into json block if it is a lambda
|
||||
val wrapped = when (value) {
|
||||
is Function0<*> -> json { value.invoke() }
|
||||
is Array<*> -> JSONArray().apply { value.forEach { put(it) } }
|
||||
else -> value
|
||||
}
|
||||
|
||||
deque.peek().put(this, wrapped)
|
||||
}
|
||||
}
|
||||
90
app/src/main/java/com/gh/common/loghub/LoghubHelper.kt
Normal file
90
app/src/main/java/com/gh/common/loghub/LoghubHelper.kt
Normal file
@ -0,0 +1,90 @@
|
||||
package com.gh.common.loghub
|
||||
|
||||
import com.aliyun.sls.android.producer.*
|
||||
import com.gh.common.util.isPublishEnv
|
||||
import com.halo.assistant.HaloApp
|
||||
import com.lightgame.utils.Utils
|
||||
|
||||
/**
|
||||
* 上传阿里云日志辅助类
|
||||
*/
|
||||
object LoghubHelper {
|
||||
|
||||
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 val mClientMaps by lazy { hashMapOf<String, LogProducerClient>() }
|
||||
|
||||
fun uploadLog(log: Log, logStore: String) {
|
||||
getClient(logStore)?.addLog(log)
|
||||
}
|
||||
|
||||
fun uploadLogs(logs: List<Log>, logStore: String) {
|
||||
logs.forEach {
|
||||
uploadLog(it, logStore)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private fun getClient(logStore: String): LogProducerClient? {
|
||||
if (!mClientMaps.containsKey(logStore)) {
|
||||
mClientMaps[logStore] = createClient(logStore)
|
||||
}
|
||||
return mClientMaps[logStore]
|
||||
}
|
||||
|
||||
private fun createClient(logStore: String): LogProducerClient {
|
||||
val config = LogProducerConfig(ENDPOINT, PROJECT, logStore, ACCESS_KEY_ID, ACCESS_KEY_SECRET).apply {
|
||||
// 1 开启断点续传功能, 0 关闭
|
||||
// 每次发送前会把日志保存到本地的binlog文件,只有发送成功才会删除,保证日志上传At Least Once
|
||||
setPersistent(1)
|
||||
// 持久化的文件名,需要保证文件所在的文件夹已创建。配置多个客户端时,不应设置相同文件
|
||||
setPersistentFilePath(HaloApp.getInstance().application.filesDir.absolutePath + "/${logStore}.dat")
|
||||
// 是否每次AddLog强制刷新,高可靠性场景建议打开
|
||||
setPersistentForceFlush(1)
|
||||
// 持久化文件滚动个数,建议设置成10。
|
||||
setPersistentMaxFileCount(10)
|
||||
// 每个持久化文件的大小,建议设置成1-10M
|
||||
setPersistentMaxFileSize(1024 * 1024)
|
||||
// 本地最多缓存的日志数,不建议超过1M,通常设置为65536即可
|
||||
setPersistentMaxLogCount(65536)
|
||||
|
||||
//网络连接超时时间,整数,单位秒,默认为10
|
||||
setConnectTimeoutSec(15)
|
||||
//日志发送超时时间,整数,单位秒,默认为15
|
||||
setSendTimeoutSec(15)
|
||||
//flusher线程销毁最大等待时间,整数,单位秒,默认为1
|
||||
setDestroyFlusherWaitSec(2)
|
||||
//sender线程池销毁最大等待时间,整数,单位秒,默认为1
|
||||
setDestroySenderWaitSec(2)
|
||||
//日志时间与本机时间之差,超过该大小后会根据 `drop_delay_log` 选项进行处理。
|
||||
//一般此种情况只会在设置persistent的情况下出现,即设备下线后,超过几天/数月启动,发送退出前未发出的日志
|
||||
//整数,单位秒,默认为7*24*3600,即7天
|
||||
setMaxLogDelayTime(7 * 24 * 3600)
|
||||
//对于超过 `max_log_delay_time` 日志的处理策略
|
||||
//0 不丢弃,把日志时间修改为当前时间; 1 丢弃,默认为 1 (丢弃)
|
||||
setDropDelayLog(0)
|
||||
//是否丢弃鉴权失败的日志,0 不丢弃,1丢弃
|
||||
//默认为 0,即不丢弃
|
||||
setDropUnauthorizedLog(0)
|
||||
}
|
||||
|
||||
return if (isPublishEnv()) {
|
||||
LogProducerClient(config)
|
||||
} else {
|
||||
return LogProducerClient(config,
|
||||
LogProducerCallback { resultCode, reqId, errorMessage, logBytes, compressedBytes ->
|
||||
|
||||
// resultCode 返回结果代码
|
||||
// reqId 请求id
|
||||
// errorMessage 错误信息,没有为null
|
||||
// logBytes 日志大小
|
||||
// compressedBytes 压缩后日志大小
|
||||
Utils.log("LoghubHelper -> ${String.format("%s %s %s %s %s",
|
||||
LogProducerResult.fromInt(resultCode), reqId, errorMessage, logBytes, compressedBytes)}")
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2,14 +2,12 @@ package com.gh.common.loghub
|
||||
|
||||
import android.app.Application
|
||||
import androidx.annotation.Keep
|
||||
import com.aliyun.sls.android.sdk.model.Log
|
||||
import com.aliyun.sls.android.sdk.model.LogGroup
|
||||
import com.aliyun.sls.android.producer.Log
|
||||
import com.gh.common.exposure.ExposureEntity
|
||||
import com.gh.common.exposure.meta.Meta
|
||||
import com.gh.common.util.tryWithDefaultCatch
|
||||
import com.gh.loghub.LoghubHelper
|
||||
import org.json.JSONObject
|
||||
import java.util.concurrent.Executors
|
||||
import java.util.concurrent.ExecutorService
|
||||
|
||||
object LoghubUtils {
|
||||
|
||||
@ -17,22 +15,25 @@ object LoghubUtils {
|
||||
private lateinit var mApplication: Application
|
||||
|
||||
private val loghubEventSet by lazy { hashSetOf<LoghubEvent>() }
|
||||
private val loghubEventExecutor by lazy { Executors.newSingleThreadExecutor() }
|
||||
private var loghubEventExecutor: ExecutorService? = null
|
||||
private val loghubEventDao by lazy { LoghubDatabase.buildDatabase(mApplication).logHubEventDao() }
|
||||
|
||||
@JvmStatic
|
||||
fun init(application: Application) {
|
||||
fun init(application: Application, executor: ExecutorService) {
|
||||
mApplication = application
|
||||
|
||||
loghubEventExecutor.execute {
|
||||
val eventList = loghubEventDao.getAll()
|
||||
loghubEventSet.addAll(eventList)
|
||||
loghubEventExecutor = executor
|
||||
loghubEventExecutor?.execute {
|
||||
tryWithDefaultCatch {
|
||||
val eventList = loghubEventDao.getAll()
|
||||
loghubEventSet.addAll(eventList)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun log(logJson: JSONObject, logStore: String, forcedUpload: Boolean) {
|
||||
loghubEventExecutor.execute {
|
||||
loghubEventExecutor?.execute {
|
||||
try {
|
||||
val event = LoghubEvent(time = (System.currentTimeMillis() / 1000L).toString(), content = logJson.toString(), logStore = logStore)
|
||||
loghubEventSet.add(event)
|
||||
@ -49,7 +50,7 @@ object LoghubUtils {
|
||||
|
||||
@JvmStatic
|
||||
fun log(jsonString: String, logStore: String, forcedUpload: Boolean) {
|
||||
loghubEventExecutor.execute {
|
||||
loghubEventExecutor?.execute {
|
||||
try {
|
||||
val event = LoghubEvent(time = (System.currentTimeMillis() / 1000L).toString(), content = jsonString, logStore = logStore)
|
||||
loghubEventSet.add(event)
|
||||
@ -64,49 +65,37 @@ object LoghubUtils {
|
||||
}
|
||||
}
|
||||
|
||||
private fun uploadLogGroup(logGroup: LogGroup, logStore: String) {
|
||||
LoghubHelper.getInstance().uploadLogGroup(logGroup, logStore)
|
||||
}
|
||||
|
||||
fun commitSavedLoghubEvents() {
|
||||
loghubEventExecutor.execute {
|
||||
loghubEventExecutor?.execute {
|
||||
// TODO 初始化 loghubHelper 去掉这个 tryCatch 块
|
||||
tryWithDefaultCatch {
|
||||
if (loghubEventSet.isEmpty()) return@execute
|
||||
|
||||
val exposureList = loghubEventSet.toList()
|
||||
|
||||
createLogGroupAndUpload()
|
||||
uploadEvents()
|
||||
loghubEventSet.removeAll(exposureList)
|
||||
loghubEventDao.deleteMany(exposureList)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun createLogGroupAndUpload() {
|
||||
val logGroupHashMap = hashMapOf<String, LogGroup>()
|
||||
|
||||
private fun uploadEvents() {
|
||||
for (event in loghubEventSet) {
|
||||
if (!logGroupHashMap.containsKey(event.logStore)) {
|
||||
logGroupHashMap[event.logStore] = LogGroup("sls android", "no ip")
|
||||
}
|
||||
|
||||
val log = Log()
|
||||
// 特殊处理,以下logStore不需要用content包裹数据
|
||||
if (event.logStore == "collection" || event.logStore == "common" || event.logStore == "halo-api-device-installed") {
|
||||
val contentJson = JSONObject(event.content)
|
||||
for (key in contentJson.keys()) {
|
||||
log.PutContent(key, contentJson.get(key).toString())
|
||||
log.putContent(key, contentJson.get(key).toString())
|
||||
}
|
||||
} else {
|
||||
log.PutContent("current time ", event.time)
|
||||
log.PutContent("content", event.content)
|
||||
log.putContent("current time ", event.time)
|
||||
log.putContent("content", event.content)
|
||||
}
|
||||
logGroupHashMap[event.logStore]?.PutLog(log)
|
||||
}
|
||||
|
||||
for ((logStore, logGroup) in logGroupHashMap) {
|
||||
uploadLogGroup(logGroup, logStore)
|
||||
LoghubHelper.uploadLog(log, event.logStore)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -5,13 +5,14 @@ import android.database.ContentObserver
|
||||
import android.media.AudioManager
|
||||
import android.os.Handler
|
||||
import com.gh.common.util.tryCatchInRelease
|
||||
import com.halo.assistant.HaloApp
|
||||
|
||||
class VolumeObserver(var context: Context, handler: Handler, var callback: MuteCallback? = null)
|
||||
: ContentObserver(handler) {
|
||||
class VolumeObserver(var callback: MuteCallback? = null)
|
||||
: ContentObserver(Handler()) {
|
||||
var previousVolume: Int = 0
|
||||
|
||||
init {
|
||||
val audio = context.getSystemService(Context.AUDIO_SERVICE) as AudioManager
|
||||
val audio = HaloApp.getInstance().application.getSystemService(Context.AUDIO_SERVICE) as AudioManager
|
||||
// 部分设备的 audioManager getStreamVolume 内部会触发空指针 :(
|
||||
tryCatchInRelease { previousVolume = audio.getStreamVolume(AudioManager.STREAM_MUSIC) }
|
||||
}
|
||||
@ -19,8 +20,13 @@ class VolumeObserver(var context: Context, handler: Handler, var callback: MuteC
|
||||
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 audio = HaloApp.getInstance().application.getSystemService(Context.AUDIO_SERVICE) as AudioManager
|
||||
var currentVolume = 0
|
||||
|
||||
tryCatchInRelease {
|
||||
// 部分设备(Meizu 7.1.2 M6 Note)的 audioManager getStreamVolume 内部会触发空指针 :(
|
||||
currentVolume = audio.getStreamVolume(AudioManager.STREAM_MUSIC)
|
||||
}
|
||||
|
||||
val delta = previousVolume - currentVolume
|
||||
|
||||
|
||||
@ -7,6 +7,7 @@ import android.view.View
|
||||
import android.view.Window
|
||||
import android.widget.ProgressBar
|
||||
import android.widget.TextView
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import androidx.core.content.ContextCompat
|
||||
import com.g00fy2.versioncompare.Version
|
||||
@ -14,7 +15,6 @@ import com.gh.common.AppExecutor.uiExecutor
|
||||
import com.gh.common.constant.Constants
|
||||
import com.gh.common.dialog.TrackableDialog
|
||||
import com.gh.common.util.*
|
||||
import com.gh.common.util.PackageInstaller.getDownloadPath
|
||||
import com.gh.download.DownloadManager
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.entity.ApkEntity
|
||||
@ -23,6 +23,7 @@ import com.gh.gamecenter.entity.TrackableEntity
|
||||
import com.halo.assistant.HaloApp
|
||||
import com.lightgame.download.*
|
||||
import com.lightgame.utils.Utils
|
||||
import java.lang.ref.WeakReference
|
||||
import java.text.DecimalFormat
|
||||
|
||||
class SimulatorDownloadManager private constructor() {
|
||||
@ -34,6 +35,7 @@ class SimulatorDownloadManager private constructor() {
|
||||
private var appProgressFilling: View? = null
|
||||
private var appProgressAnchor: View? = null
|
||||
private var downloadDialog: Dialog? = null
|
||||
private var mContextRef: WeakReference<Context>? = null
|
||||
|
||||
private var simulatorLocation: SimulatorLocation? = null
|
||||
private var simulator: SimulatorEntity? = null
|
||||
@ -71,7 +73,10 @@ class SimulatorDownloadManager private constructor() {
|
||||
val startTime = downloadEntity.getMetaExtra(Constants.SIMULATOR_DOWNLOAD_START_TIME)
|
||||
LogUtils.uploadSimulatorDownload("simulator_download_complete", fileName, simulator?.id, downloadEntity.name, gameId, locationStr, downloadType, startTime)
|
||||
DownloadManager.getInstance(HaloApp.getInstance().application).cancel(downloadEntity.url, false, true)
|
||||
downloadDialog?.dismiss()
|
||||
val activity = mContextRef?.get() as? AppCompatActivity
|
||||
if (activity?.isFinishing == false) {
|
||||
downloadDialog?.dismiss()
|
||||
}
|
||||
}
|
||||
DownloadStatus.neterror == downloadEntity.status -> {
|
||||
ToastUtils.showToast("网络不稳定,下载任务已暂停")
|
||||
@ -94,7 +99,9 @@ class SimulatorDownloadManager private constructor() {
|
||||
showDownloadDialog(context, simulator, location, "", "", null)
|
||||
}
|
||||
|
||||
fun showDownloadDialog(context: Context, simulator: SimulatorEntity?, location: SimulatorLocation, gameId: String = "", gameName: String = "", cancelCallback: (() -> Unit)? = null) {
|
||||
fun showDownloadDialog(context: Context?, simulator: SimulatorEntity?, location: SimulatorLocation, gameId: String = "", gameName: String = "", cancelCallback: (() -> Unit)? = null) {
|
||||
if (context == null) return
|
||||
mContextRef = WeakReference(context)
|
||||
this.simulatorLocation = location
|
||||
this.simulator = simulator
|
||||
this.gameId = gameId
|
||||
@ -117,7 +124,7 @@ class SimulatorDownloadManager private constructor() {
|
||||
key = if (shouldShowUpdate && isInstalled) "更新弹窗" else "下载弹窗",
|
||||
logShowEvent = true
|
||||
)
|
||||
DialogUtils.showNewAlertDialog(context, title, message, negativeText, positiveText, trackableEntity, Gravity.LEFT, {
|
||||
DialogUtils.showNewAlertDialog(context, title, message, negativeText, positiveText, trackableEntity, Gravity.LEFT, false, {
|
||||
if (shouldShowUpdate && isInstalled) {
|
||||
cancelCallback?.invoke()
|
||||
MtaHelper.onEvent(trackableEntity.event, trackableEntity.key, "点击下次再说")
|
||||
@ -153,7 +160,10 @@ class SimulatorDownloadManager private constructor() {
|
||||
view.findViewById<View>(R.id.app_tv_cancel).setOnClickListener {
|
||||
DownloadManager.getInstance(context).pause(simulator?.apk?.url)
|
||||
MtaHelper.onEvent("模拟器下载", "下载中弹窗", "点击关闭")
|
||||
downloadDialog?.dismiss()
|
||||
val activity = mContextRef?.get() as? AppCompatActivity
|
||||
if (activity?.isFinishing == false) {
|
||||
downloadDialog?.dismiss()
|
||||
}
|
||||
}
|
||||
|
||||
downloadDialog?.setOnDismissListener {
|
||||
@ -181,9 +191,9 @@ class SimulatorDownloadManager private constructor() {
|
||||
|
||||
private fun download(context: Context, simulator: SimulatorEntity?) {
|
||||
val apkEntity = simulator?.apk ?: return
|
||||
DownloadManager.getInstance(context).pauseAll()
|
||||
|
||||
val entity = DownloadManager.getInstance(context).getDownloadEntityByUrl(apkEntity.url)
|
||||
HaloApp.put(simulator.name, simulator)
|
||||
if (entity != null) {
|
||||
when (entity.status) {
|
||||
DownloadStatus.pause, DownloadStatus.subscribe,
|
||||
@ -203,16 +213,18 @@ class SimulatorDownloadManager private constructor() {
|
||||
|
||||
private fun createDownload(context: Context, apkEntity: ApkEntity, simulator: SimulatorEntity) {
|
||||
DownloadManager.getInstance(context).addObserver(dataWatcher)
|
||||
val downloadId = PackageInstaller.createDownloadId(simulator.name)
|
||||
val downloadEntity = DownloadEntity()
|
||||
downloadEntity.url = apkEntity.url
|
||||
downloadEntity.name = simulator.name
|
||||
downloadEntity.path = getDownloadPath(simulator.name, apkEntity.format)
|
||||
downloadEntity.path = PackageInstaller.getDownloadPathWithId(downloadId, apkEntity.format)
|
||||
downloadEntity.platform = apkEntity.getPlatform()
|
||||
downloadEntity.packageName = apkEntity.packageName
|
||||
downloadEntity.versionName = apkEntity.version
|
||||
|
||||
downloadEntity.addMetaExtra(Constants.EXTRA_DOWNLOAD_TYPE, Constants.SIMULATOR_DOWNLOAD)
|
||||
downloadEntity.addMetaExtra(Constants.SIMULATOR_DOWNLOAD_START_TIME, (System.currentTimeMillis() / 1000).toString())
|
||||
downloadEntity.addMetaExtra(Constants.DOWNLOAD_ID, downloadId)
|
||||
uiExecutor.executeWithDelay(Runnable { DownloadManager.getInstance(context).add(downloadEntity) }, 200)
|
||||
|
||||
val locationStr = if (simulatorLocation == SimulatorLocation.LAUNCH) "${simulatorLocation?.value}《${gameName}》" else simulatorLocation?.value
|
||||
|
||||
@ -3,24 +3,32 @@ package com.gh.common.simulator
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.ActivityNotFoundException
|
||||
import android.content.Intent
|
||||
import android.graphics.Bitmap
|
||||
import android.net.Uri
|
||||
import android.text.TextUtils
|
||||
import com.g00fy2.versioncompare.Version
|
||||
import com.gh.common.json.json
|
||||
import com.gh.common.util.*
|
||||
import com.gh.download.DownloadManager
|
||||
import com.gh.gamecenter.entity.GameEntity
|
||||
import com.gh.gamecenter.entity.SimulatorGameRecordEntity
|
||||
import com.gh.gamecenter.manager.UserManager
|
||||
import com.gh.gamecenter.retrofit.BiResponse
|
||||
import com.gh.gamecenter.retrofit.EmptyResponse
|
||||
import com.gh.gamecenter.retrofit.Response
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager
|
||||
import com.gh.gamecenter.room.AppDatabase
|
||||
import com.halo.assistant.HaloApp
|
||||
import com.lightgame.download.DownloadDao
|
||||
import com.lightgame.download.DownloadEntity
|
||||
import com.lightgame.download.FileUtils
|
||||
import com.lightgame.utils.AppManager
|
||||
import io.reactivex.Single
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
import okhttp3.ResponseBody
|
||||
import org.json.JSONArray
|
||||
import java.io.ByteArrayOutputStream
|
||||
import java.io.File
|
||||
|
||||
|
||||
@ -33,7 +41,7 @@ object SimulatorGameManager {
|
||||
|
||||
@JvmStatic
|
||||
fun deleteLocalGames(names: List<String>) {
|
||||
val downloadEntityList = DownloadDao.getInstance(HaloApp.getInstance().application).all
|
||||
val downloadEntityList = DownloadManager.getInstance(HaloApp.getInstance().application).allDownloadEntity
|
||||
names.forEach { name ->
|
||||
val downloadEntity = downloadEntityList.find { it.name == name }
|
||||
if (downloadEntity != null) {
|
||||
@ -48,7 +56,7 @@ object SimulatorGameManager {
|
||||
|
||||
@JvmStatic
|
||||
fun deleteLocalGame(name: String) {
|
||||
val downloadEntityList = DownloadDao.getInstance(HaloApp.getInstance().application).all
|
||||
val downloadEntityList = DownloadManager.getInstance(HaloApp.getInstance().application).allDownloadEntity
|
||||
val downloadEntity = downloadEntityList.find { it.name == name }
|
||||
if (downloadEntity != null) {
|
||||
val file = File(downloadEntity.path)
|
||||
@ -79,6 +87,8 @@ object SimulatorGameManager {
|
||||
fun launchSimulatorGame(downloadEntity: DownloadEntity, gameEntity: GameEntity) {
|
||||
val versionFromInstalledApp = PackageUtils.getVersionByPackage(gameEntity.simulator?.apk?.packageName)
|
||||
val shouldShowUpdate = Version(gameEntity.simulator?.apk?.version).isHigherThan(versionFromInstalledApp)
|
||||
|
||||
updateSimulatorConfigFile(gameId = gameEntity.id)
|
||||
if (shouldShowUpdate) {
|
||||
SimulatorDownloadManager.getInstance().showDownloadDialog(AppManager.getInstance().recentActiveActivity, gameEntity.simulator,
|
||||
SimulatorDownloadManager.SimulatorLocation.LAUNCH, gameEntity.id, gameEntity.name
|
||||
@ -90,31 +100,62 @@ object SimulatorGameManager {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
private fun jumpToSimulator(downloadEntity: DownloadEntity, gameEntity: GameEntity) {
|
||||
val intent = Intent()
|
||||
intent.data = Uri.fromFile(File(downloadEntity.path))
|
||||
if (gameEntity.simulatorType == "FBA") {
|
||||
val apkEntity = gameEntity.getApk()[0]
|
||||
intent.putExtra("rom_name", apkEntity.packageName)
|
||||
}
|
||||
intent.putExtra("default_path", downloadEntity.path.substring(0, downloadEntity.path.lastIndexOf('/')))
|
||||
intent.putExtra("game_type", gameEntity.simulatorType)
|
||||
intent.putExtra("title", downloadEntity.name)
|
||||
intent.putExtra("icon", gameEntity.icon ?: "")
|
||||
intent.putExtra("meta", LogUtils.getMetaObject().toString())
|
||||
intent.putExtra("simulatorId", gameEntity.simulator?.id)
|
||||
intent.putExtra("simulatorName", gameEntity.simulator?.name)
|
||||
intent.putExtra("gameId", gameEntity.id)
|
||||
Single.just(gameEntity.icon ?: "")
|
||||
.flatMap {
|
||||
getBitmapFormCache(it)
|
||||
}.map {
|
||||
BitmapUtils.compressBitmap(it, 100)
|
||||
}.map {
|
||||
val baos = ByteArrayOutputStream()
|
||||
it.compress(Bitmap.CompressFormat.WEBP, 100, baos)
|
||||
baos.toByteArray()
|
||||
}
|
||||
.compose(singleToMain())
|
||||
.subscribe({
|
||||
val intent = Intent()
|
||||
intent.data = Uri.fromFile(File(downloadEntity.path))
|
||||
if (gameEntity.simulatorType == "FBA" || gameEntity.simulatorType == "FBN") {
|
||||
val apkEntity = gameEntity.getApk()[0]
|
||||
intent.putExtra("rom_name", apkEntity.packageName)
|
||||
}
|
||||
intent.putExtra("default_path", downloadEntity.path.substring(0, downloadEntity.path.lastIndexOf('/')))
|
||||
intent.putExtra("game_type", gameEntity.simulatorType)
|
||||
intent.putExtra("title", downloadEntity.name)
|
||||
intent.putExtra("icon", gameEntity.icon ?: "")
|
||||
intent.putExtra("iconStream", it)
|
||||
intent.putExtra("meta", LogUtils.getMetaObject().toString())
|
||||
intent.putExtra("simulatorId", gameEntity.simulator?.id)
|
||||
intent.putExtra("simulatorName", gameEntity.simulator?.name)
|
||||
intent.putExtra("gameId", gameEntity.id)
|
||||
|
||||
val destActivity = "com.gh.emu.RequestPermissionActivity"
|
||||
intent.setClassName(gameEntity.simulator?.apk?.packageName ?: "", destActivity)
|
||||
try {
|
||||
AppManager.getInstance().recentActiveActivity.startActivity(intent)
|
||||
} catch (e: ActivityNotFoundException) {
|
||||
ToastUtils.showToast("模拟器安装错误")
|
||||
}
|
||||
val destActivity = "com.gh.emu.RequestPermissionActivity"
|
||||
intent.setClassName(gameEntity.simulator?.apk?.packageName ?: "", destActivity)
|
||||
try {
|
||||
AppManager.getInstance().recentActiveActivity?.startActivity(intent)
|
||||
} catch (e: ActivityNotFoundException) {
|
||||
ToastUtils.showToast("模拟器安装错误")
|
||||
}
|
||||
|
||||
recordPlaySimulatorGames(gameEntity.id)
|
||||
recordPlaySimulatorGames(gameEntity.id)
|
||||
}, {
|
||||
ToastUtils.showToast("跳转失败")
|
||||
})
|
||||
}
|
||||
|
||||
private fun getBitmapFormCache(url: String): Single<Bitmap> {
|
||||
return Single.create {
|
||||
ImageUtils.getBitmap(url, object : BiCallback<Bitmap, Boolean> {
|
||||
override fun onFirst(first: Bitmap) {
|
||||
it.onSuccess(first)
|
||||
}
|
||||
|
||||
override fun onSecond(second: Boolean) {
|
||||
it.onError(Throwable("获取bitmap失败"))
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -123,18 +164,69 @@ object SimulatorGameManager {
|
||||
*/
|
||||
@SuppressLint("CheckResult")
|
||||
@JvmStatic
|
||||
fun recordDownloadSimulatorGames(gameId: String) {
|
||||
fun recordDownloadSimulatorGame(gameId: String, type: String) {
|
||||
val requestMap = hashMapOf<String, Any>()
|
||||
requestMap["game_id"] = gameId
|
||||
requestMap["package"] = "-"
|
||||
val body = requestMap.createRequestBodyAny()
|
||||
RetrofitManager.getInstance(HaloApp.getInstance().application).api
|
||||
.downloadSimulatorGames(HaloApp.getInstance().gid, body)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.compose(singleToMain())
|
||||
.subscribe(object : BiResponse<ResponseBody>() {
|
||||
override fun onSuccess(data: ResponseBody) {
|
||||
refreshSimulatorGame(gameId, type)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量记录设备下载的模拟器游戏
|
||||
*/
|
||||
@SuppressLint("CheckResult")
|
||||
@JvmStatic
|
||||
fun recordDownloadSimulatorGames() {
|
||||
val gameArray = JSONArray()
|
||||
val allGameList = AppDatabase.getInstance(HaloApp.getInstance()).simulatorGameDao().getAllSimulatorGame()
|
||||
for (game in allGameList) {
|
||||
if (!game.isDeleted) {
|
||||
gameArray.put(json {
|
||||
"game_id" to game.id
|
||||
"package" to "-"
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
if (gameArray.length() == 0) return
|
||||
|
||||
RetrofitManager.getInstance(HaloApp.getInstance().application).api
|
||||
.putDownloadSimulatorGames(HaloApp.getInstance().gid, gameArray.toRequestBody())
|
||||
.compose(singleToMain())
|
||||
.subscribe(EmptyResponse())
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
private fun refreshSimulatorGame(gameId: String, type: String) {
|
||||
val simulatorGameDao = AppDatabase.getInstance(HaloApp.getInstance()).simulatorGameDao()
|
||||
RetrofitManager.getInstance(HaloApp.getInstance().application).api
|
||||
.getSimulatorGames(HaloApp.getInstance().gid, 1, getFilter(type))
|
||||
.compose(singleToMain())
|
||||
.subscribe(object : BiResponse<List<GameEntity>>() {
|
||||
override fun onSuccess(data: List<GameEntity>) {
|
||||
val simulatorGameRecordList = ArrayList<SimulatorGameRecordEntity>()
|
||||
data.forEach {
|
||||
val entity = it.convertSimulatorGameRecordEntity()
|
||||
entity.isRecentlyPlayed = it.id == gameId
|
||||
simulatorGameRecordList.add(entity)
|
||||
}
|
||||
simulatorGameDao.addSimulatorGameList(simulatorGameRecordList)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
private fun getFilter(type: String): String {
|
||||
return UrlFilterUtils.getFilterQuery("type", type)
|
||||
}
|
||||
|
||||
/**
|
||||
* 标记已玩过
|
||||
*/
|
||||
@ -147,8 +239,7 @@ object SimulatorGameManager {
|
||||
val body = requestMap.toRequestBody()
|
||||
RetrofitManager.getInstance(HaloApp.getInstance().application).api
|
||||
.postPlayedGame(UserManager.getInstance().userId, body)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.compose(singleToMain())
|
||||
.subscribe(EmptyResponse())
|
||||
}
|
||||
}
|
||||
@ -189,6 +280,7 @@ object SimulatorGameManager {
|
||||
/**
|
||||
* 批量删除设备下载模拟器游戏的记录
|
||||
*/
|
||||
@JvmStatic
|
||||
@SuppressLint("CheckResult")
|
||||
fun deleteSimulatorGames(gameIds: List<String>, callback: () -> Unit) {
|
||||
val requestMap = hashMapOf<String, Any>()
|
||||
@ -216,4 +308,22 @@ object SimulatorGameManager {
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(EmptyResponse())
|
||||
}
|
||||
|
||||
private fun updateSimulatorConfigFile(gameId: String) {
|
||||
RetrofitManager.getInstance(HaloApp.getInstance().application)
|
||||
.api
|
||||
.getGameDigest(gameId)
|
||||
.map(ApkActiveUtils.filterMapper)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.subscribe(object : Response<GameEntity>() {
|
||||
override fun onResponse(game: GameEntity?) {
|
||||
game?.let {
|
||||
if (!TextUtils.isEmpty(game.simulatorGameConfig)) {
|
||||
val configFilePath = getPathByType(game.simulatorType + "/cheat/" + game.getApk().firstOrNull()?.packageName + ".ini")
|
||||
FileUtils.downloadAndUpdateFile(game.simulatorGameConfig, configFilePath)
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@ -16,8 +16,12 @@ object SyncFieldConstants {
|
||||
const val ANSWER_COMMENT_COUNT = "ANSWER_COMMENT_COUNT"
|
||||
const val ARTICLE_COMMENT_COUNT = "ARTICLE_COMMENT_COUNT"
|
||||
const val ARTICLE_COMMENT_REPLY_COUNT = "ARTICLE_COMMENT_REPLY_COUNT"
|
||||
const val ANSWER_COMMENT_REPLY_COUNT = "ANSWER_COMMENT_REPLY_COUNT"
|
||||
|
||||
// 回答数量
|
||||
const val ANSWER_COUNT = "ANSWER_COUNT"
|
||||
|
||||
// 是否关注
|
||||
const val IS_FOLLOWER = "IS_FOLLOWER"
|
||||
|
||||
}
|
||||
@ -80,7 +80,7 @@ class ExampleAdapter(context: Context) : ListAdapter<AnswerEntity>(context), ISy
|
||||
ItemViewType.ITEM_FOOTER -> {
|
||||
val footerViewHolder = holder as FooterViewHolder
|
||||
footerViewHolder.initItemPadding()
|
||||
footerViewHolder.initFooterViewHolder(mIsLoading, mIsNetworkError, mIsOver, R.string.ask_loadover_hint)
|
||||
footerViewHolder.initFooterViewHolder(mIsLoading, mIsNetworkError, mIsOver)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,24 @@
|
||||
package com.gh.common.tracker
|
||||
|
||||
import android.app.Activity
|
||||
import android.app.Application
|
||||
import android.os.Bundle
|
||||
|
||||
// FYI 快速启动并且不设置 contentView 马上结束的 SplashActivity 没有 onStart 和 onStop 回调
|
||||
class ActivityLifecycleWatcher(private val mTrack: ITrack) : Application.ActivityLifecycleCallbacks {
|
||||
|
||||
override fun onActivityStarted(activity: Activity) {
|
||||
mTrack.onActivityStarted(activity)
|
||||
}
|
||||
|
||||
override fun onActivityStopped(activity: Activity) {
|
||||
mTrack.onActivityStopped(activity)
|
||||
}
|
||||
|
||||
override fun onActivityDestroyed(activity: Activity) {}
|
||||
override fun onActivitySaveInstanceState(activity: Activity, outState: Bundle) {}
|
||||
override fun onActivityPaused(activity: Activity) {}
|
||||
override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) {}
|
||||
override fun onActivityResumed(activity: Activity) {}
|
||||
|
||||
}
|
||||
@ -0,0 +1,72 @@
|
||||
package com.gh.common.tracker
|
||||
|
||||
import androidx.lifecycle.DefaultLifecycleObserver
|
||||
import androidx.lifecycle.LifecycleOwner
|
||||
import java.util.*
|
||||
import java.util.concurrent.atomic.AtomicBoolean
|
||||
import java.util.concurrent.atomic.AtomicLong
|
||||
import kotlin.concurrent.fixedRateTimer
|
||||
|
||||
/**
|
||||
* 应用生命周期观察者
|
||||
*/
|
||||
class AppLifecycleWatcher(private val mTrack: ITrack) : DefaultLifecycleObserver {
|
||||
|
||||
private var mWatchVisibleCount = 0 // 检查是否满足上传可见的次数
|
||||
|
||||
private val mLastVisibleTime by lazy { AtomicLong(0L) } // 最后可见时间
|
||||
private val mIsVisible by lazy { AtomicBoolean(false) } // 当前是否可见
|
||||
private val mWatchInterval by lazy { AtomicLong(MIN_WATCH_VISIBLE_INTERVAL) } // 与上次上报可见的间隔时间
|
||||
|
||||
init {
|
||||
fixedRateTimer(FIXED_RATE_TIMER_NAME, initialDelay = MIN_WATCH_VISIBLE_INTERVAL, period = MIN_WATCH_VISIBLE_INTERVAL) {
|
||||
if (mIsVisible.get()) {
|
||||
// 单位间隔发送
|
||||
val meetLogVisibleInterval = (mWatchVisibleCount++) * MIN_WATCH_VISIBLE_INTERVAL == mWatchInterval.get()
|
||||
|
||||
val equalToMinVisibleInterval = mWatchInterval.get() == MIN_WATCH_VISIBLE_INTERVAL
|
||||
val equalToMaxVisibleInterval = mWatchInterval.get() == MAX_WATCH_VISIBLE_INTERVAL
|
||||
|
||||
if (meetLogVisibleInterval || equalToMinVisibleInterval) {
|
||||
// 上报完重置计数
|
||||
mWatchVisibleCount = 0
|
||||
mTrack.onAppVisible(mWatchInterval.get() / 1000)
|
||||
if (!equalToMaxVisibleInterval) {
|
||||
mWatchInterval.set(mWatchInterval.get() * 2) // 间隔递增两倍
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onStart(owner: LifecycleOwner) {
|
||||
super.onStart(owner)
|
||||
|
||||
if (mLastVisibleTime.get() == 0L
|
||||
|| (mLastVisibleTime.get() + SESSION_ALIVE_INTERVAL) < System.currentTimeMillis() / 1000) {
|
||||
mTrack.onSessionChanged(UUID.randomUUID().toString())
|
||||
}
|
||||
mIsVisible.set(true)
|
||||
|
||||
mTrack.onAppStarted()
|
||||
}
|
||||
|
||||
override fun onStop(owner: LifecycleOwner) {
|
||||
super.onStop(owner)
|
||||
|
||||
mIsVisible.set(false)
|
||||
mLastVisibleTime.set(System.currentTimeMillis() / 1000)
|
||||
mWatchInterval.set(MIN_WATCH_VISIBLE_INTERVAL)
|
||||
|
||||
mTrack.onAppStopped()
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val FIXED_RATE_TIMER_NAME = "APP_TRACKER_TIMER"
|
||||
|
||||
private const val SESSION_ALIVE_INTERVAL = 30L // 30s
|
||||
private const val MIN_WATCH_VISIBLE_INTERVAL = 5000L // 5s
|
||||
private const val MAX_WATCH_VISIBLE_INTERVAL = 320000L // 320s
|
||||
}
|
||||
|
||||
}
|
||||
8
app/src/main/java/com/gh/common/tracker/IBusiness.kt
Normal file
8
app/src/main/java/com/gh/common/tracker/IBusiness.kt
Normal file
@ -0,0 +1,8 @@
|
||||
package com.gh.common.tracker
|
||||
|
||||
import androidx.annotation.Nullable
|
||||
|
||||
interface IBusiness {
|
||||
@Nullable
|
||||
fun getBusinessId(): Pair<String, String>
|
||||
}
|
||||
14
app/src/main/java/com/gh/common/tracker/ITrack.kt
Normal file
14
app/src/main/java/com/gh/common/tracker/ITrack.kt
Normal file
@ -0,0 +1,14 @@
|
||||
package com.gh.common.tracker
|
||||
|
||||
import android.app.Activity
|
||||
|
||||
interface ITrack {
|
||||
fun onActivityStarted(activity: Activity)
|
||||
fun onActivityStopped(activity: Activity)
|
||||
|
||||
fun onAppStarted()
|
||||
fun onAppVisible(interval: Long)
|
||||
fun onAppStopped()
|
||||
|
||||
fun onSessionChanged(sessionId: String)
|
||||
}
|
||||
70
app/src/main/java/com/gh/common/tracker/Tracker.kt
Normal file
70
app/src/main/java/com/gh/common/tracker/Tracker.kt
Normal file
@ -0,0 +1,70 @@
|
||||
package com.gh.common.tracker
|
||||
|
||||
import android.app.Activity
|
||||
import android.app.Application
|
||||
import androidx.lifecycle.ProcessLifecycleOwner
|
||||
import java.util.*
|
||||
|
||||
/**
|
||||
* launch_id 当前启动的唯一 id (每次应用冷启动或被内存回收时变更)
|
||||
* session_id 当前会话的唯一 id (应用切换至后台超30秒时变更)
|
||||
*/
|
||||
object Tracker : ITrack {
|
||||
|
||||
private var mSessionId: String = ""
|
||||
private val mLaunchId by lazy { UUID.randomUUID().toString() }
|
||||
|
||||
val sessionId: String
|
||||
get() = mSessionId
|
||||
|
||||
val launchId: String
|
||||
get() = mLaunchId
|
||||
|
||||
private var mIsInitialized = false
|
||||
|
||||
@JvmStatic
|
||||
fun init(application: Application) {
|
||||
if (mIsInitialized) {
|
||||
return
|
||||
}
|
||||
|
||||
ProcessLifecycleOwner.get().lifecycle.addObserver(AppLifecycleWatcher(this))
|
||||
application.registerActivityLifecycleCallbacks(ActivityLifecycleWatcher(this))
|
||||
mIsInitialized = true
|
||||
}
|
||||
|
||||
override fun onActivityStarted(activity: Activity) {
|
||||
val businessId = if (activity is IBusiness) activity.getBusinessId() else null
|
||||
|
||||
TrackerLogger.logActivityStart(
|
||||
System.identityHashCode(activity).toString(),
|
||||
activity::class.java.simpleName,
|
||||
businessId)
|
||||
}
|
||||
|
||||
override fun onActivityStopped(activity: Activity) {
|
||||
val businessId = if (activity is IBusiness) activity.getBusinessId() else null
|
||||
|
||||
TrackerLogger.logActivityStop(
|
||||
System.identityHashCode(activity).toString(),
|
||||
activity::class.java.simpleName,
|
||||
businessId)
|
||||
}
|
||||
|
||||
override fun onAppStarted() {
|
||||
TrackerLogger.logAppStart()
|
||||
}
|
||||
|
||||
override fun onAppVisible(interval: Long) {
|
||||
TrackerLogger.logAppVisible(interval)
|
||||
}
|
||||
|
||||
override fun onAppStopped() {
|
||||
TrackerLogger.logAppStop()
|
||||
}
|
||||
|
||||
override fun onSessionChanged(sessionId: String) {
|
||||
mSessionId = sessionId
|
||||
}
|
||||
|
||||
}
|
||||
188
app/src/main/java/com/gh/common/tracker/TrackerLogger.kt
Normal file
188
app/src/main/java/com/gh/common/tracker/TrackerLogger.kt
Normal file
@ -0,0 +1,188 @@
|
||||
package com.gh.common.tracker
|
||||
|
||||
import android.content.Context
|
||||
import com.gh.common.exposure.meta.MetaUtil
|
||||
import com.gh.common.exposure.meta.MetaUtil.getBase64EncodedAndroidId
|
||||
import com.gh.common.exposure.meta.MetaUtil.getBase64EncodedIMEI
|
||||
import com.gh.common.loghub.LoghubUtils
|
||||
import com.gh.common.util.PackageUtils
|
||||
import com.gh.common.util.tryCatchInRelease
|
||||
import com.gh.gamecenter.R
|
||||
import com.lightgame.utils.Utils
|
||||
import org.json.JSONException
|
||||
import org.json.JSONObject
|
||||
|
||||
object TrackerLogger {
|
||||
|
||||
private const val LOG_STORE = "launch_activity"
|
||||
|
||||
fun logAppStart() {
|
||||
logAppVisible(0)
|
||||
}
|
||||
|
||||
fun logAppVisible(interval: Long) {
|
||||
val jsonObject = JSONObject()
|
||||
val payloadObject = JSONObject()
|
||||
tryCatchInRelease {
|
||||
payloadObject.put("launch_id", Tracker.launchId)
|
||||
payloadObject.put("session_id", Tracker.sessionId)
|
||||
payloadObject.put("interval", interval)
|
||||
|
||||
jsonObject.put("event", "app_visible")
|
||||
jsonObject.put("payload", payloadObject)
|
||||
jsonObject.put("meta", getMeta())
|
||||
}
|
||||
uploadToLoghub(jsonObject, true)
|
||||
}
|
||||
|
||||
fun logAppStop() {
|
||||
val jsonObject = JSONObject()
|
||||
val payloadObject = JSONObject()
|
||||
tryCatchInRelease {
|
||||
payloadObject.put("launch_id", Tracker.launchId)
|
||||
payloadObject.put("session_id", Tracker.sessionId)
|
||||
|
||||
jsonObject.put("event", "app_invisible")
|
||||
jsonObject.put("payload", payloadObject)
|
||||
jsonObject.put("meta", getMeta())
|
||||
}
|
||||
uploadToLoghub(jsonObject, true)
|
||||
}
|
||||
|
||||
fun logActivityStart(activityId: String,
|
||||
activityName: String,
|
||||
activityBusinessId: Pair<String, String>? = null) {
|
||||
val jsonObject = JSONObject()
|
||||
val payloadObject = JSONObject()
|
||||
tryCatchInRelease {
|
||||
payloadObject.put("launch_id", Tracker.launchId)
|
||||
payloadObject.put("session_id", Tracker.sessionId)
|
||||
payloadObject.put("activity_id", activityId)
|
||||
payloadObject.put("activity_name", activityName)
|
||||
if (activityBusinessId != null) {
|
||||
payloadObject.put("activity_primary_business_id", activityBusinessId.first)
|
||||
if (activityBusinessId.second.isNotEmpty()) {
|
||||
payloadObject.put("activity_secondary_business_id", activityBusinessId.second)
|
||||
}
|
||||
}
|
||||
|
||||
jsonObject.put("event", "activity_visible")
|
||||
jsonObject.put("payload", payloadObject)
|
||||
jsonObject.put("meta", getMeta())
|
||||
}
|
||||
uploadToLoghub(jsonObject, false)
|
||||
}
|
||||
|
||||
fun logActivityStop(activityId: String,
|
||||
activityName: String,
|
||||
activityBusinessId: Pair<String, String>? = null) {
|
||||
val jsonObject = JSONObject()
|
||||
val payloadObject = JSONObject()
|
||||
tryCatchInRelease {
|
||||
payloadObject.put("launch_id", Tracker.launchId)
|
||||
payloadObject.put("session_id", Tracker.sessionId)
|
||||
payloadObject.put("activity_id", activityId)
|
||||
payloadObject.put("activity_name", activityName)
|
||||
if (activityBusinessId != null) {
|
||||
payloadObject.put("activity_primary_business_id", activityBusinessId.first)
|
||||
if (activityBusinessId.second.isNotEmpty()) {
|
||||
payloadObject.put("activity_secondary_business_id", activityBusinessId.second)
|
||||
}
|
||||
}
|
||||
|
||||
jsonObject.put("event", "activity_invisible")
|
||||
jsonObject.put("payload", payloadObject)
|
||||
jsonObject.put("meta", getMeta())
|
||||
}
|
||||
uploadToLoghub(jsonObject, false)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun logHomeTabSelected(tabPosition: Int,
|
||||
tabContent: String) {
|
||||
val jsonObject = JSONObject()
|
||||
val payloadObject = JSONObject()
|
||||
tryCatchInRelease {
|
||||
payloadObject.put("launch_id", Tracker.launchId)
|
||||
payloadObject.put("session_id", Tracker.sessionId)
|
||||
payloadObject.put("tab_position", tabPosition)
|
||||
payloadObject.put("tab_content", tabContent)
|
||||
|
||||
jsonObject.put("event", "home_tab_select")
|
||||
jsonObject.put("payload", payloadObject)
|
||||
jsonObject.put("meta", getMeta())
|
||||
}
|
||||
uploadToLoghub(jsonObject, false)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun logAppLaunch(context: Context) {
|
||||
val jsonObject = JSONObject()
|
||||
val payloadObject = JSONObject()
|
||||
val signatureHash = PackageUtils.getApkSignatureByPackageName(context, context.packageName)
|
||||
val sideLoadInfo = PackageUtils.getSideLoadedInfo()
|
||||
|
||||
tryCatchInRelease {
|
||||
payloadObject.put("launch_id", Tracker.launchId)
|
||||
payloadObject.put("session_id", Tracker.sessionId)
|
||||
payloadObject.put("signature", signatureHash)
|
||||
payloadObject.put("package_name", context.packageName)
|
||||
payloadObject.put("app_name", context.getString(R.string.app_name))
|
||||
|
||||
sideLoadInfo?.let {
|
||||
payloadObject.put("is_side_loaded", sideLoadInfo["is_side_loaded"])
|
||||
sideLoadInfo["installer_store"]?.let {
|
||||
payloadObject.put("installer_store", it)
|
||||
}
|
||||
}
|
||||
|
||||
jsonObject.put("event", "app_launch")
|
||||
jsonObject.put("payload", payloadObject)
|
||||
jsonObject.put("meta", getMeta())
|
||||
}
|
||||
uploadToLoghub(jsonObject, true)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun logAppLaunchSuccessful() {
|
||||
val jsonObject = JSONObject()
|
||||
val payloadObject = JSONObject()
|
||||
tryCatchInRelease {
|
||||
payloadObject.put("launch_id", Tracker.launchId)
|
||||
payloadObject.put("session_id", Tracker.sessionId)
|
||||
|
||||
jsonObject.put("event", "app_launch_successful")
|
||||
jsonObject.put("payload", payloadObject)
|
||||
jsonObject.put("meta", getMeta())
|
||||
}
|
||||
uploadToLoghub(jsonObject, true)
|
||||
}
|
||||
|
||||
private fun uploadToLoghub(jsonObject: JSONObject, uploadImmediately: Boolean) {
|
||||
jsonObject.put("timestamp", System.currentTimeMillis() / 1000)
|
||||
|
||||
Utils.log("Tracker -> $jsonObject")
|
||||
LoghubUtils.log(jsonObject, LOG_STORE, uploadImmediately)
|
||||
}
|
||||
|
||||
private fun getMeta(): JSONObject {
|
||||
val (_, _, model, manufacturer, _, _, android_version, network, _, gid, _, channel, appVersion, userId) = MetaUtil.getMeta()
|
||||
val metaObject = JSONObject()
|
||||
try {
|
||||
metaObject.put("dia", getBase64EncodedAndroidId())
|
||||
metaObject.put("android_version", android_version)
|
||||
metaObject.put("app_version", appVersion)
|
||||
metaObject.put("channel", channel)
|
||||
metaObject.put("gid", gid)
|
||||
metaObject.put("jnfj", getBase64EncodedIMEI())
|
||||
metaObject.put("manufacturer", manufacturer)
|
||||
metaObject.put("model", model)
|
||||
metaObject.put("network", network)
|
||||
metaObject.put("user_id", userId)
|
||||
} catch (e: JSONException) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
return metaObject
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,7 +1,14 @@
|
||||
package com.gh.common.util
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import com.gh.common.constant.Config
|
||||
import com.gh.gamecenter.entity.SettingsEntity
|
||||
import com.gh.gamecenter.entity.StartupAdEntity
|
||||
import com.gh.gamecenter.retrofit.BiResponse
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager
|
||||
import com.halo.assistant.HaloApp
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
|
||||
object AdHelper {
|
||||
|
||||
@ -12,6 +19,28 @@ object AdHelper {
|
||||
const val LOCATION_DISCOVER = "discover"
|
||||
const val LOCATION_SIMULATOR_GAME = "simulator_game"
|
||||
|
||||
@JvmField
|
||||
var startupAd = MutableLiveData<StartupAdEntity>()
|
||||
|
||||
@JvmStatic
|
||||
@SuppressLint("CheckResult")
|
||||
fun getStartUpAd() {
|
||||
if (!NetworkUtils.isNetworkConnected(HaloApp.getInstance())) {
|
||||
startupAd.postValue(null)
|
||||
return
|
||||
}
|
||||
|
||||
RetrofitManager.getInstance(HaloApp.getInstance())
|
||||
.api
|
||||
.getSplashAd(HaloApp.getInstance().channel)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.subscribe(object : BiResponse<StartupAdEntity>() {
|
||||
override fun onSuccess(data: StartupAdEntity) {
|
||||
startupAd.postValue(data)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fun getAd(location: String): SettingsEntity.AD? {
|
||||
val adList = Config.getSettings()?.adList ?: return null
|
||||
|
||||
|
||||
134
app/src/main/java/com/gh/common/util/BbsReportHelper.kt
Normal file
134
app/src/main/java/com/gh/common/util/BbsReportHelper.kt
Normal file
@ -0,0 +1,134 @@
|
||||
package com.gh.common.util
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.app.Dialog
|
||||
import android.content.Context
|
||||
import android.graphics.Color
|
||||
import android.graphics.drawable.ColorDrawable
|
||||
import android.preference.PreferenceManager
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.Window
|
||||
import android.widget.EditText
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.TextView
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import androidx.core.content.ContextCompat
|
||||
import com.gh.base.CurrentActivityHolder
|
||||
import com.gh.common.json.json
|
||||
import com.gh.common.util.ToastUtils.showToast
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.SuggestionActivity
|
||||
import com.gh.gamecenter.entity.SettingsEntity
|
||||
import com.gh.gamecenter.retrofit.BiResponse
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager
|
||||
import com.halo.assistant.HaloApp
|
||||
import com.lightgame.utils.Util_System_Keyboard
|
||||
import com.lightgame.utils.Utils
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
import okhttp3.ResponseBody
|
||||
import org.json.JSONObject
|
||||
|
||||
object BbsReportHelper {
|
||||
|
||||
fun showReportDialog(contentId: String) {
|
||||
val sp = PreferenceManager.getDefaultSharedPreferences(HaloApp.getInstance())
|
||||
val suggestion: SettingsEntity.Suggestion? = sp.getString(SuggestionActivity.SUGGESTION_HINT_TYPE, null)?.toObject()
|
||||
val reportList = suggestion?.report ?: return
|
||||
|
||||
CurrentActivityHolder.getCurrentActivity()?.apply {
|
||||
if (this.isFinishing) return@apply
|
||||
|
||||
val dialog = Dialog(this)
|
||||
|
||||
val view = LayoutInflater.from(this).inflate(R.layout.dialog_video_complaint, null, false)
|
||||
val complaintContainer = view.findViewById<LinearLayout>(R.id.complaintContainer)
|
||||
val otherComplaintContainer: ConstraintLayout = view.findViewById(R.id.otherComplaintContainer)
|
||||
val complaintCommentEt = view.findViewById<EditText>(R.id.complaintCommentEt)
|
||||
val backTv = view.findViewById<TextView>(R.id.backTv)
|
||||
val commitTv = view.findViewById<TextView>(R.id.commitTv)
|
||||
val finalContext: Context = this
|
||||
//添加透明阴影,实现类似 clipPadding=false 效果
|
||||
complaintCommentEt.setShadowLayer(complaintCommentEt.extendedPaddingBottom.toFloat(), 0f, 0f, Color.TRANSPARENT)
|
||||
|
||||
complaintCommentEt.setTextChangedListener { s: CharSequence, _: Int?, _: Int?, _: Int? ->
|
||||
commitTv.setTextColor(ContextCompat.getColor(finalContext, if (s.toString().trim { it <= ' ' }.isEmpty()) R.color.text_999999 else R.color.theme_font))
|
||||
}
|
||||
|
||||
for (option in reportList) {
|
||||
val reportTv = TextView(this)
|
||||
reportTv.text = option
|
||||
reportTv.textSize = 16F
|
||||
reportTv.setTextColor(R.color.title.toColor())
|
||||
reportTv.setBackgroundResource(R.drawable.textview_white_style)
|
||||
reportTv.layoutParams = LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
|
||||
LinearLayout.LayoutParams.WRAP_CONTENT)
|
||||
reportTv.setPadding(20F.dip2px(), 17F.dip2px(), 20F.dip2px(), 17F.dip2px())
|
||||
if (option.contains("其它")) {
|
||||
val drawable = R.drawable.ic_complaint_arrow_right.toDrawable()
|
||||
drawable!!.setBounds(0, 0, 6F.dip2px(), 10F.dip2px())
|
||||
reportTv.setCompoundDrawables(null, null, drawable, null)
|
||||
}
|
||||
complaintContainer.addView(reportTv)
|
||||
reportTv.setOnClickListener {
|
||||
if (option.contains("其它")) {
|
||||
complaintContainer.visibility = View.GONE
|
||||
otherComplaintContainer.visibility = View.VISIBLE
|
||||
complaintCommentEt.requestFocus()
|
||||
Util_System_Keyboard.showSoftKeyboard(finalContext, complaintCommentEt)
|
||||
} else {
|
||||
postReport(contentId, json {
|
||||
"reason" to reportTv.text.toString()
|
||||
})
|
||||
dialog.cancel()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
backTv.setOnClickListener {
|
||||
Util_System_Keyboard.hideSoftKeyboard(finalContext, complaintCommentEt)
|
||||
complaintContainer.visibility = View.VISIBLE
|
||||
otherComplaintContainer.visibility = View.GONE
|
||||
}
|
||||
commitTv.setOnClickListener {
|
||||
if (complaintCommentEt.text.toString().isEmpty()) {
|
||||
showToast("请先输入说明~")
|
||||
return@setOnClickListener
|
||||
}
|
||||
postReport(contentId, json {
|
||||
"reason" to "其它"
|
||||
"description" to complaintCommentEt.text.toString()
|
||||
})
|
||||
|
||||
dialog.cancel()
|
||||
}
|
||||
|
||||
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE)
|
||||
dialog.setContentView(view)
|
||||
dialog.show()
|
||||
val window = dialog.window
|
||||
if (window != null) {
|
||||
window.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))
|
||||
val params = window.attributes
|
||||
params.width = resources.displayMetrics.widthPixels - 40F.dip2px()
|
||||
window.attributes = params
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
private fun postReport(contentId: String, reportContent: JSONObject) {
|
||||
RetrofitManager.getInstance(HaloApp.getInstance())
|
||||
.api
|
||||
.postBbsReport(contentId, reportContent.toRequestBody())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(object : BiResponse<ResponseBody>() {
|
||||
override fun onSuccess(data: ResponseBody) {
|
||||
Utils.toast(HaloApp.getInstance(), "举报成功")
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
128
app/src/main/java/com/gh/common/util/BbsStayTimeHelper.kt
Normal file
128
app/src/main/java/com/gh/common/util/BbsStayTimeHelper.kt
Normal file
@ -0,0 +1,128 @@
|
||||
package com.gh.common.util
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.app.Activity
|
||||
import android.app.Application
|
||||
import android.os.Bundle
|
||||
import com.gh.base.CurrentActivityHolder
|
||||
import com.gh.base.GHThreadFactory
|
||||
import com.gh.gamecenter.MainActivity
|
||||
import com.gh.gamecenter.forum.detail.ForumDetailActivity
|
||||
import com.gh.gamecenter.qa.article.detail.ArticleDetailActivity
|
||||
import com.gh.gamecenter.qa.comment.CommentActivity
|
||||
import com.gh.gamecenter.qa.questions.newdetail.NewQuestionDetailActivity
|
||||
import com.gh.gamecenter.qa.video.detail.ForumVideoDetailActivity
|
||||
import com.gh.gamecenter.retrofit.BiResponse
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager
|
||||
import com.halo.assistant.HaloApp
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
import okhttp3.ResponseBody
|
||||
import java.util.concurrent.ExecutorService
|
||||
import java.util.concurrent.Executors
|
||||
|
||||
object BbsStayTimeHelper {
|
||||
|
||||
private var mStayTimeCount = 0
|
||||
private var mIsStayTimeCountEnabled = false // 论坛停留时间统计是否开启
|
||||
private var mStayTimeTimeout = 30
|
||||
private var mIsStayTimeCountValid = false // 论坛停留时间统计是否有效
|
||||
|
||||
const val IS_BBS_CONTENT_VISIBLE = "is_bbs_content_visible"
|
||||
|
||||
private val mThreadService: ExecutorService by lazy {
|
||||
Executors.newSingleThreadExecutor(GHThreadFactory("STAY_TIME_THREAD"))
|
||||
}
|
||||
|
||||
private val mActivityLifecycleCallbacks by lazy {
|
||||
object : Application.ActivityLifecycleCallbacks {
|
||||
override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) {}
|
||||
override fun onActivityStopped(activity: Activity) {}
|
||||
override fun onActivitySaveInstanceState(activity: Activity, outState: Bundle) {}
|
||||
override fun onActivityDestroyed(activity: Activity) {}
|
||||
override fun onActivityStarted(activity: Activity) {}
|
||||
|
||||
override fun onActivityResumed(activity: Activity) {
|
||||
if (isTopActivityBbsRelated(activity) && mIsStayTimeCountEnabled) {
|
||||
resumeTimeCount()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onActivityPaused(activity: Activity) {
|
||||
if (isTopActivityBbsRelated(activity) && mIsStayTimeCountEnabled) {
|
||||
pauseTimeCount()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun enableStayTimeCount(timeout: Int) {
|
||||
mIsStayTimeCountEnabled = true
|
||||
mStayTimeTimeout = timeout
|
||||
|
||||
resumeTimeCount()
|
||||
|
||||
HaloApp.getInstance().registerActivityLifecycleCallbacks(mActivityLifecycleCallbacks)
|
||||
}
|
||||
|
||||
fun disableStayTimeCount() {
|
||||
mIsStayTimeCountEnabled = false
|
||||
mStayTimeCount = 0
|
||||
|
||||
HaloApp.getInstance().unregisterActivityLifecycleCallbacks(mActivityLifecycleCallbacks)
|
||||
}
|
||||
|
||||
fun resumeTimeCount() {
|
||||
if (!mIsStayTimeCountEnabled) return
|
||||
|
||||
mIsStayTimeCountValid = true
|
||||
|
||||
mThreadService.execute {
|
||||
while (mIsStayTimeCountEnabled && mIsStayTimeCountValid) {
|
||||
val topActivity = CurrentActivityHolder.getCurrentActivity() ?: continue
|
||||
if (isTopActivityBbsRelated(topActivity)) {
|
||||
tryWithDefaultCatch {
|
||||
mStayTimeCount++
|
||||
if (mStayTimeCount >= mStayTimeTimeout) {
|
||||
postExploreFinish()
|
||||
}
|
||||
}
|
||||
}
|
||||
Thread.sleep(1000)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun pauseTimeCount() {
|
||||
if (!mIsStayTimeCountEnabled) return
|
||||
|
||||
mIsStayTimeCountValid = false
|
||||
}
|
||||
|
||||
private fun isTopActivityBbsRelated(activity: Activity): Boolean {
|
||||
return (activity is MainActivity && activity.intent.extras?.getBoolean(IS_BBS_CONTENT_VISIBLE) == true)
|
||||
|| activity is ForumDetailActivity
|
||||
|| activity is ArticleDetailActivity
|
||||
|| activity is ForumVideoDetailActivity
|
||||
|| activity is CommentActivity
|
||||
|| activity is NewQuestionDetailActivity
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
private fun postExploreFinish() {
|
||||
RetrofitManager.getInstance(HaloApp.getInstance())
|
||||
.api
|
||||
.postExplorerFinish()
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(object : BiResponse<ResponseBody>() {
|
||||
override fun onSuccess(data: ResponseBody) {
|
||||
if (!isPublishEnv()) {
|
||||
ToastUtils.toast("完成了论坛停留任务(仅测试环境有这个 toast 不要慌)")
|
||||
}
|
||||
disableStayTimeCount()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
@ -8,6 +8,7 @@ import android.graphics.Matrix;
|
||||
import android.graphics.PixelFormat;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.media.ExifInterface;
|
||||
import android.media.MediaMetadataRetriever;
|
||||
import android.os.Build;
|
||||
|
||||
import com.halo.assistant.HaloApp;
|
||||
@ -307,6 +308,218 @@ public class BitmapUtils {
|
||||
return outputBitmap;
|
||||
}
|
||||
|
||||
/**
|
||||
* 模糊Bitmap
|
||||
*
|
||||
* @param sentBitmap
|
||||
* @param radius
|
||||
* @return
|
||||
*/
|
||||
public static Bitmap doBlur(Bitmap sentBitmap, int radius) {
|
||||
Bitmap.Config config = sentBitmap.getConfig();
|
||||
if (config == null) {
|
||||
config = Bitmap.Config.ARGB_8888;
|
||||
}
|
||||
Bitmap bitmap = sentBitmap.copy(config, true);
|
||||
|
||||
if (radius < 1) {
|
||||
return (null);
|
||||
}
|
||||
|
||||
int w = bitmap.getWidth();
|
||||
int h = bitmap.getHeight();
|
||||
|
||||
int[] pix = new int[w * h];
|
||||
bitmap.getPixels(pix, 0, w, 0, 0, w, h);
|
||||
|
||||
int wm = w - 1;
|
||||
int hm = h - 1;
|
||||
int wh = w * h;
|
||||
int div = radius + radius + 1;
|
||||
|
||||
int r[] = new int[wh];
|
||||
int g[] = new int[wh];
|
||||
int b[] = new int[wh];
|
||||
int rsum, gsum, bsum, x, y, i, p, yp, yi, yw;
|
||||
int vmin[] = new int[Math.max(w, h)];
|
||||
|
||||
int divsum = (div + 1) >> 1;
|
||||
divsum *= divsum;
|
||||
int dv[] = new int[256 * divsum];
|
||||
for (i = 0; i < 256 * divsum; i++) {
|
||||
dv[i] = (i / divsum);
|
||||
}
|
||||
|
||||
yw = yi = 0;
|
||||
|
||||
int[][] stack = new int[div][3];
|
||||
int stackpointer;
|
||||
int stackstart;
|
||||
int[] sir;
|
||||
int rbs;
|
||||
int r1 = radius + 1;
|
||||
int routsum, goutsum, boutsum;
|
||||
int rinsum, ginsum, binsum;
|
||||
|
||||
for (y = 0; y < h; y++) {
|
||||
rinsum = ginsum = binsum = routsum = goutsum = boutsum = rsum = gsum = bsum = 0;
|
||||
for (i = -radius; i <= radius; i++) {
|
||||
p = pix[yi + Math.min(wm, Math.max(i, 0))];
|
||||
sir = stack[i + radius];
|
||||
sir[0] = (p & 0xff0000) >> 16;
|
||||
sir[1] = (p & 0x00ff00) >> 8;
|
||||
sir[2] = (p & 0x0000ff);
|
||||
rbs = r1 - Math.abs(i);
|
||||
rsum += sir[0] * rbs;
|
||||
gsum += sir[1] * rbs;
|
||||
bsum += sir[2] * rbs;
|
||||
if (i > 0) {
|
||||
rinsum += sir[0];
|
||||
ginsum += sir[1];
|
||||
binsum += sir[2];
|
||||
} else {
|
||||
routsum += sir[0];
|
||||
goutsum += sir[1];
|
||||
boutsum += sir[2];
|
||||
}
|
||||
}
|
||||
stackpointer = radius;
|
||||
|
||||
for (x = 0; x < w; x++) {
|
||||
|
||||
r[yi] = dv[rsum];
|
||||
g[yi] = dv[gsum];
|
||||
b[yi] = dv[bsum];
|
||||
|
||||
rsum -= routsum;
|
||||
gsum -= goutsum;
|
||||
bsum -= boutsum;
|
||||
|
||||
stackstart = stackpointer - radius + div;
|
||||
sir = stack[stackstart % div];
|
||||
|
||||
routsum -= sir[0];
|
||||
goutsum -= sir[1];
|
||||
boutsum -= sir[2];
|
||||
|
||||
if (y == 0) {
|
||||
vmin[x] = Math.min(x + radius + 1, wm);
|
||||
}
|
||||
p = pix[yw + vmin[x]];
|
||||
|
||||
sir[0] = (p & 0xff0000) >> 16;
|
||||
sir[1] = (p & 0x00ff00) >> 8;
|
||||
sir[2] = (p & 0x0000ff);
|
||||
|
||||
rinsum += sir[0];
|
||||
ginsum += sir[1];
|
||||
binsum += sir[2];
|
||||
|
||||
rsum += rinsum;
|
||||
gsum += ginsum;
|
||||
bsum += binsum;
|
||||
|
||||
stackpointer = (stackpointer + 1) % div;
|
||||
sir = stack[(stackpointer) % div];
|
||||
|
||||
routsum += sir[0];
|
||||
goutsum += sir[1];
|
||||
boutsum += sir[2];
|
||||
|
||||
rinsum -= sir[0];
|
||||
ginsum -= sir[1];
|
||||
binsum -= sir[2];
|
||||
|
||||
yi++;
|
||||
}
|
||||
yw += w;
|
||||
}
|
||||
for (x = 0; x < w; x++) {
|
||||
rinsum = ginsum = binsum = routsum = goutsum = boutsum = rsum = gsum = bsum = 0;
|
||||
yp = -radius * w;
|
||||
for (i = -radius; i <= radius; i++) {
|
||||
yi = Math.max(0, yp) + x;
|
||||
|
||||
sir = stack[i + radius];
|
||||
|
||||
sir[0] = r[yi];
|
||||
sir[1] = g[yi];
|
||||
sir[2] = b[yi];
|
||||
|
||||
rbs = r1 - Math.abs(i);
|
||||
|
||||
rsum += r[yi] * rbs;
|
||||
gsum += g[yi] * rbs;
|
||||
bsum += b[yi] * rbs;
|
||||
|
||||
if (i > 0) {
|
||||
rinsum += sir[0];
|
||||
ginsum += sir[1];
|
||||
binsum += sir[2];
|
||||
} else {
|
||||
routsum += sir[0];
|
||||
goutsum += sir[1];
|
||||
boutsum += sir[2];
|
||||
}
|
||||
|
||||
if (i < hm) {
|
||||
yp += w;
|
||||
}
|
||||
}
|
||||
yi = x;
|
||||
stackpointer = radius;
|
||||
for (y = 0; y < h; y++) {
|
||||
// Preserve alpha channel: ( 0xff000000 & pix[yi] )
|
||||
pix[yi] = (0xff000000 & pix[yi]) | (dv[rsum] << 16) | (dv[gsum] << 8) | dv[bsum];
|
||||
|
||||
rsum -= routsum;
|
||||
gsum -= goutsum;
|
||||
bsum -= boutsum;
|
||||
|
||||
stackstart = stackpointer - radius + div;
|
||||
sir = stack[stackstart % div];
|
||||
|
||||
routsum -= sir[0];
|
||||
goutsum -= sir[1];
|
||||
boutsum -= sir[2];
|
||||
|
||||
if (x == 0) {
|
||||
vmin[y] = Math.min(y + r1, hm) * w;
|
||||
}
|
||||
p = x + vmin[y];
|
||||
|
||||
sir[0] = r[p];
|
||||
sir[1] = g[p];
|
||||
sir[2] = b[p];
|
||||
|
||||
rinsum += sir[0];
|
||||
ginsum += sir[1];
|
||||
binsum += sir[2];
|
||||
|
||||
rsum += rinsum;
|
||||
gsum += ginsum;
|
||||
bsum += binsum;
|
||||
|
||||
stackpointer = (stackpointer + 1) % div;
|
||||
sir = stack[stackpointer];
|
||||
|
||||
routsum += sir[0];
|
||||
goutsum += sir[1];
|
||||
boutsum += sir[2];
|
||||
|
||||
rinsum -= sir[0];
|
||||
ginsum -= sir[1];
|
||||
binsum -= sir[2];
|
||||
|
||||
yi += w;
|
||||
}
|
||||
}
|
||||
|
||||
bitmap.setPixels(pix, 0, w, 0, 0, w, h);
|
||||
|
||||
return (bitmap);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存图片
|
||||
*
|
||||
@ -333,14 +546,19 @@ public class BitmapUtils {
|
||||
}
|
||||
|
||||
|
||||
public static Bitmap compressBitmap(Bitmap bitmap) {
|
||||
/**
|
||||
* 压缩图片
|
||||
*
|
||||
* @param bitmap
|
||||
* @param compressSize 压缩大小(单位k)
|
||||
*/
|
||||
public static Bitmap compressBitmap(Bitmap bitmap, int compressSize) {
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||
Matrix matrix = new Matrix();
|
||||
Bitmap result = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true);
|
||||
result.compress(Bitmap.CompressFormat.WEBP, 100, bos);
|
||||
|
||||
while (bos.toByteArray().length > 400 * 1024) {
|
||||
System.out.println(bos.toByteArray().length);
|
||||
while (bos.toByteArray().length > compressSize * 1024) {
|
||||
matrix.setScale(0.9f, 0.9f);
|
||||
result = Bitmap.createBitmap(result, 0, 0, result.getWidth(), result.getHeight(), matrix, true);
|
||||
bos.reset();
|
||||
@ -349,4 +567,25 @@ public class BitmapUtils {
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// 获取视频缩略图(比较耗时,建议在子线程中调用)
|
||||
public static Bitmap getVideoThumbnail(String filePath) {
|
||||
Bitmap bitmap = null;
|
||||
MediaMetadataRetriever retriever = new MediaMetadataRetriever();
|
||||
try {
|
||||
retriever.setDataSource(filePath);
|
||||
bitmap = retriever.getFrameAtTime();
|
||||
} catch (IllegalArgumentException e) {
|
||||
e.printStackTrace();
|
||||
} catch (RuntimeException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
retriever.release();
|
||||
} catch (RuntimeException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return bitmap;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,16 +1,16 @@
|
||||
package com.gh.common.util;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.gh.common.avoidcallback.Callback;
|
||||
import com.gh.base.CurrentActivityHolder;
|
||||
import com.gh.common.constant.Constants;
|
||||
import com.gh.gamecenter.LoginActivity;
|
||||
import com.gh.gamecenter.manager.UserManager;
|
||||
import com.lightgame.utils.Utils;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Created by khy on 28/06/17.
|
||||
@ -18,17 +18,28 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class CheckLoginUtils {
|
||||
|
||||
public static void checkLogin(final Context context, String entrance, OnLoginListener listener) {
|
||||
public static void checkLogin(Context context, String entrance, OnLoginListener listener) {
|
||||
if (!isLogin()) {
|
||||
if (listener != null) Utils.toast(context, "需要登录");
|
||||
LogUtils.login("dialog", null, entrance);
|
||||
LogUtils.login("activity", null, entrance);
|
||||
|
||||
// 有可能App未启动
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString(EntranceUtils.KEY_ENTRANCE, entrance);
|
||||
bundle.putString(EntranceUtils.KEY_TO, LoginActivity.class.getName());
|
||||
EntranceUtils.jumpActivity(context, bundle);
|
||||
if (SPUtils.getBoolean(Constants.SP_HAS_GET_PHONE_INFO) || NetworkUtils.isOpenMobileData(context)) {
|
||||
// 需要确保传入的 context 不为 application
|
||||
if (!(context instanceof Activity)) {
|
||||
context = CurrentActivityHolder.getCurrentActivity();
|
||||
}
|
||||
|
||||
if (context != null) {
|
||||
QuickLoginHelper.startLogin(context, entrance);
|
||||
}
|
||||
} else {
|
||||
// 有可能App未启动
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString(EntranceUtils.KEY_ENTRANCE, entrance);
|
||||
bundle.putString(EntranceUtils.KEY_TO, LoginActivity.class.getName());
|
||||
EntranceUtils.jumpActivity(context, bundle);
|
||||
}
|
||||
} else {
|
||||
if (listener != null) {
|
||||
listener.onLogin();
|
||||
|
||||
@ -21,110 +21,155 @@ import com.lightgame.utils.Utils
|
||||
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(view: View,
|
||||
commentEntity: CommentEntity,
|
||||
showConversation: Boolean,
|
||||
articleId: String,
|
||||
communityId: String,
|
||||
isShowTop: Boolean = false,
|
||||
ignoreModerator: Boolean = false,
|
||||
listener: OnCommentOptionClickListener?) {
|
||||
showCommentOptions(view = view,
|
||||
commentEntity = commentEntity,
|
||||
showConversation = showConversation,
|
||||
articleId = articleId,
|
||||
communityId = communityId,
|
||||
isShowTop = isShowTop,
|
||||
ignoreModerator = ignoreModerator,
|
||||
listener = listener)
|
||||
fun showCommunityArticleCommentOptions(
|
||||
view: View,
|
||||
commentEntity: CommentEntity,
|
||||
showConversation: Boolean,
|
||||
articleId: String,
|
||||
communityId: String,
|
||||
isShowTop: Boolean = false,
|
||||
ignoreModerator: Boolean = false,
|
||||
listener: OnCommentOptionClickListener?
|
||||
) {
|
||||
showCommentOptions(
|
||||
view = view,
|
||||
commentEntity = commentEntity,
|
||||
showConversation = showConversation,
|
||||
articleId = articleId,
|
||||
communityId = communityId,
|
||||
isShowTop = isShowTop,
|
||||
ignoreModerator = ignoreModerator,
|
||||
listener = listener
|
||||
)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun showAnswerCommentOptions(view: View,
|
||||
commentEntity: CommentEntity,
|
||||
showConversation: Boolean,
|
||||
answerId: String,
|
||||
listener: OnCommentOptionClickListener?) {
|
||||
showCommentOptions(view = view,
|
||||
commentEntity = commentEntity,
|
||||
showConversation = showConversation,
|
||||
answerId = answerId,
|
||||
listener = listener)
|
||||
fun showAnswerCommentOptions(
|
||||
view: View,
|
||||
commentEntity: CommentEntity,
|
||||
showConversation: Boolean,
|
||||
answerId: String,
|
||||
listener: OnCommentOptionClickListener?
|
||||
) {
|
||||
showCommentOptions(
|
||||
view = view,
|
||||
commentEntity = commentEntity,
|
||||
showConversation = showConversation,
|
||||
answerId = answerId,
|
||||
listener = listener
|
||||
)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun showVideoCommentOptions(view: View,
|
||||
commentEntity: CommentEntity,
|
||||
showConversation: Boolean,
|
||||
videoId: String,
|
||||
isVideoAuthor: Boolean,
|
||||
listener: OnCommentOptionClickListener?) {
|
||||
showCommentOptions(view = view,
|
||||
commentEntity = commentEntity,
|
||||
showConversation = showConversation,
|
||||
videoId = videoId,
|
||||
isVideoAuthor = isVideoAuthor,
|
||||
listener = listener)
|
||||
fun showVideoCommentOptions(
|
||||
view: View,
|
||||
commentEntity: CommentEntity,
|
||||
showConversation: Boolean,
|
||||
videoId: String,
|
||||
isVideoAuthor: Boolean,
|
||||
isShowTop: Boolean = false,
|
||||
listener: OnCommentOptionClickListener?
|
||||
) {
|
||||
showCommentOptions(
|
||||
view = view,
|
||||
commentEntity = commentEntity,
|
||||
showConversation = showConversation,
|
||||
videoId = videoId,
|
||||
isVideoAuthor = isVideoAuthor,
|
||||
isShowTop = isShowTop,
|
||||
listener = listener
|
||||
)
|
||||
}
|
||||
|
||||
private fun showCommentOptions(view: View,
|
||||
commentEntity: CommentEntity,
|
||||
showConversation: Boolean,
|
||||
articleId: String? = null,
|
||||
communityId: String? = null,
|
||||
answerId: String? = null,
|
||||
videoId: String? = null,
|
||||
isShowTop: Boolean = false,
|
||||
ignoreModerator: Boolean = false,
|
||||
isVideoAuthor: Boolean = false,
|
||||
listener: OnCommentOptionClickListener? = null) {
|
||||
fun showQuestionCommentOption(
|
||||
view: View,
|
||||
commentEntity: CommentEntity,
|
||||
questionId: String,
|
||||
isShowTop: Boolean = false,
|
||||
listener: OnCommentOptionClickListener?
|
||||
) {
|
||||
showCommentOptions(
|
||||
view = view,
|
||||
commentEntity = commentEntity,
|
||||
showConversation = false,
|
||||
questionId = questionId,
|
||||
isShowTop = isShowTop,
|
||||
ignoreModerator = true,
|
||||
listener = listener
|
||||
)
|
||||
}
|
||||
|
||||
private fun showCommentOptions(
|
||||
view: View,
|
||||
commentEntity: CommentEntity,
|
||||
showConversation: Boolean,
|
||||
articleId: String? = null,
|
||||
communityId: String? = null,
|
||||
answerId: String? = null,
|
||||
questionId: String? = null,
|
||||
videoId: String? = null,
|
||||
isShowTop: Boolean = false,
|
||||
ignoreModerator: Boolean = false,
|
||||
isVideoAuthor: Boolean = false,
|
||||
listener: OnCommentOptionClickListener? = null
|
||||
) {
|
||||
val context = view.context
|
||||
val dialogOptions = ArrayList<String>()
|
||||
if (isShowTop && articleId != null && commentEntity.me?.isArticleOrAnswerAuthor == true) {
|
||||
|
||||
if (isShowTop && (articleId != null || questionId != null) && commentEntity.me?.isContentAuthor == true) {
|
||||
dialogOptions.add(if (commentEntity.isTop) "取消置顶" else "置顶")
|
||||
}
|
||||
if (questionId != null && commentEntity.me?.isContentAuthor == true) {
|
||||
if (commentEntity.accept) {
|
||||
dialogOptions.add("取消采纳")
|
||||
} else {
|
||||
dialogOptions.add("采纳")
|
||||
}
|
||||
}
|
||||
|
||||
dialogOptions.add("复制")
|
||||
if (commentEntity.user.id != UserManager.getInstance().userId) {
|
||||
dialogOptions.add("投诉")
|
||||
}
|
||||
if (isVideoAuthor || (videoId != null && commentEntity.user.id == UserManager.getInstance().userId)) {
|
||||
dialogOptions.add("删除评论")
|
||||
} else if (articleId != null && (commentEntity.user.id == UserManager.getInstance().userId ||
|
||||
commentEntity.me?.isModerator == true || commentEntity.me?.isArticleOrAnswerAuthor == true)) {
|
||||
if (questionId != null && commentEntity.me?.isModerator == true && !commentEntity.choiceness) {
|
||||
dialogOptions.add("加精选")
|
||||
}
|
||||
if (commentEntity.user.id == UserManager.getInstance().userId || commentEntity.me?.isModerator == true || commentEntity.me?.isContentAuthor == true) {
|
||||
dialogOptions.add("删除评论")
|
||||
}
|
||||
|
||||
commentEntity.me?.let {
|
||||
/*commentEntity.me?.let {
|
||||
if (ignoreModerator) return@let
|
||||
|
||||
if (it.isModerator || (it.moderatorPermissions.hideAnswerComment > Permissions.GUEST
|
||||
|| it.moderatorPermissions.topAnswerComment > Permissions.GUEST
|
||||
|| it.moderatorPermissions.hideCommunityArticleComment > Permissions.GUEST
|
||||
|| it.moderatorPermissions.topCommunityArticleComment > 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("查看对话")
|
||||
}
|
||||
|
||||
val inflater = LayoutInflater.from(context)
|
||||
val layout = inflater.inflate(R.layout.comment_more_option, null)
|
||||
val popupWindow = BugFixedPopupWindow(layout,
|
||||
LinearLayout.LayoutParams.WRAP_CONTENT,
|
||||
LinearLayout.LayoutParams.WRAP_CONTENT)
|
||||
val layout = inflater.inflate(R.layout.layout_popup_container, null)
|
||||
val popupWindow = BugFixedPopupWindow(
|
||||
layout,
|
||||
LinearLayout.LayoutParams.WRAP_CONTENT,
|
||||
LinearLayout.LayoutParams.WRAP_CONTENT
|
||||
)
|
||||
val container = layout.findViewById<LinearLayout>(R.id.container)
|
||||
for (text in dialogOptions) {
|
||||
val item = inflater.inflate(R.layout.comment_more_option_item, container, false)
|
||||
val item = inflater.inflate(R.layout.layout_popup_option_item, container, false)
|
||||
container.addView(item)
|
||||
|
||||
val hitText = item.findViewById<TextView>(R.id.hint_text)
|
||||
@ -134,34 +179,73 @@ object CommentHelper {
|
||||
popupWindow.dismiss()
|
||||
listener?.onCommentOptionClick(commentEntity, text)
|
||||
when (text) {
|
||||
"管理" -> showControlDialog(context, answerId, articleId, communityId, commentEntity, commentEntity.me!!)
|
||||
"管理" -> showControlDialog(
|
||||
context,
|
||||
answerId,
|
||||
articleId,
|
||||
communityId,
|
||||
commentEntity,
|
||||
commentEntity.me!!
|
||||
)
|
||||
|
||||
"复制" -> copyText(commentEntity.content, context)
|
||||
|
||||
"投诉" -> {
|
||||
context.ifLogin("回答详情-评论-投诉") {
|
||||
showReportTypeDialog(context, !videoId.isNullOrEmpty()) { reportType ->
|
||||
showReportTypeDialog(context) { reportType ->
|
||||
val commentListener =
|
||||
object : PostCommentUtils.PostCommentListener {
|
||||
override fun postSuccess(response: JSONObject?) {
|
||||
Utils.toast(context, "感谢您的投诉")
|
||||
}
|
||||
|
||||
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}")
|
||||
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 if (articleId != null) {
|
||||
PostCommentUtils.reportCommunityArticleComment(context, communityId, articleId, commentEntity.id, reportType, commentListener)
|
||||
} else {
|
||||
PostCommentUtils.reportVideoComment(context, videoId, commentEntity.id, reportType, commentListener)
|
||||
when {
|
||||
answerId != null -> {
|
||||
PostCommentUtils.postAnswerReportData(
|
||||
context,
|
||||
commentEntity.id,
|
||||
answerId,
|
||||
reportType,
|
||||
commentListener
|
||||
)
|
||||
}
|
||||
articleId != null -> {
|
||||
PostCommentUtils.reportCommunityArticleComment(
|
||||
context,
|
||||
communityId,
|
||||
articleId,
|
||||
commentEntity.id,
|
||||
reportType,
|
||||
commentListener
|
||||
)
|
||||
}
|
||||
questionId != null -> {
|
||||
PostCommentUtils.reportQuestionComment(
|
||||
context,
|
||||
questionId,
|
||||
commentEntity.id,
|
||||
reportType,
|
||||
commentListener
|
||||
)
|
||||
}
|
||||
else -> {
|
||||
PostCommentUtils.reportVideoComment(
|
||||
context,
|
||||
videoId,
|
||||
commentEntity.id,
|
||||
reportType,
|
||||
commentListener
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -169,14 +253,37 @@ object CommentHelper {
|
||||
|
||||
"查看对话" -> {
|
||||
if (answerId != null) {
|
||||
context.startActivity(CommentDetailActivity
|
||||
.getAnswerCommentIntent(context, commentEntity.id, answerId, null))
|
||||
context.startActivity(
|
||||
CommentDetailActivity
|
||||
.getAnswerCommentIntent(
|
||||
context,
|
||||
commentEntity.id,
|
||||
answerId,
|
||||
null
|
||||
)
|
||||
)
|
||||
} else if (articleId != null) {
|
||||
context.startActivity(CommentDetailActivity
|
||||
.getCommunityArticleCommentIntent(context, articleId, commentEntity.id, communityId, null))
|
||||
context.startActivity(
|
||||
CommentDetailActivity
|
||||
.getCommunityArticleCommentIntent(
|
||||
context,
|
||||
articleId,
|
||||
commentEntity.id,
|
||||
communityId,
|
||||
null
|
||||
)
|
||||
)
|
||||
} else {
|
||||
context.startActivity(CommentDetailActivity
|
||||
.getVideoCommentIntent(context, commentEntity.id, videoId, isVideoAuthor, null))
|
||||
context.startActivity(
|
||||
CommentDetailActivity
|
||||
.getVideoCommentIntent(
|
||||
context,
|
||||
commentEntity.id,
|
||||
videoId,
|
||||
isVideoAuthor,
|
||||
null
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -188,12 +295,14 @@ object CommentHelper {
|
||||
popupWindow.showAutoOrientation(view)
|
||||
}
|
||||
|
||||
private fun showControlDialog(context: Context,
|
||||
answerId: String? = null,
|
||||
articleId: String? = null,
|
||||
communityId: String? = null,
|
||||
comment: CommentEntity,
|
||||
me: MeEntity) {
|
||||
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 = "隐藏评论"
|
||||
@ -202,19 +311,23 @@ object CommentHelper {
|
||||
var canHideCommentDirectly = false
|
||||
|
||||
if (me.isModerator || me.moderatorPermissions.topAnswerComment > Permissions.GUEST
|
||||
|| me.moderatorPermissions.topCommunityArticleComment > Permissions.GUEST) {
|
||||
|| me.moderatorPermissions.topCommunityArticleComment > Permissions.GUEST
|
||||
) {
|
||||
dialogOptions.add(highlight)
|
||||
if (me.moderatorPermissions.topAnswerComment > Permissions.REPORTER
|
||||
|| me.moderatorPermissions.topCommunityArticleComment > Permissions.REPORTER) {
|
||||
|| me.moderatorPermissions.topCommunityArticleComment > Permissions.REPORTER
|
||||
) {
|
||||
canHighlightCommentDirectly = true
|
||||
}
|
||||
}
|
||||
|
||||
if (me.isModerator || me.moderatorPermissions.hideAnswerComment > Permissions.GUEST
|
||||
|| me.moderatorPermissions.hideCommunityArticleComment > Permissions.GUEST) {
|
||||
|| me.moderatorPermissions.hideCommunityArticleComment > Permissions.GUEST
|
||||
) {
|
||||
dialogOptions.add(hide)
|
||||
if (me.moderatorPermissions.hideAnswerComment > Permissions.REPORTER
|
||||
|| me.moderatorPermissions.hideCommunityArticleComment > Permissions.REPORTER) {
|
||||
|| me.moderatorPermissions.hideCommunityArticleComment > Permissions.REPORTER
|
||||
) {
|
||||
canHideCommentDirectly = true
|
||||
}
|
||||
}
|
||||
@ -275,7 +388,10 @@ object CommentHelper {
|
||||
val errorJson = JSONObject(string)
|
||||
val errorCode = errorJson.getInt("code")
|
||||
if (errorCode == 403059) {
|
||||
Utils.toast(HaloApp.getInstance().application, "权限错误,请刷新后重试")
|
||||
Utils.toast(
|
||||
HaloApp.getInstance().application,
|
||||
"权限错误,请刷新后重试"
|
||||
)
|
||||
return
|
||||
} else {
|
||||
Utils.toast(HaloApp.getInstance().application, e.message())
|
||||
@ -286,23 +402,31 @@ object CommentHelper {
|
||||
}
|
||||
|
||||
if (answerId != null) {
|
||||
DialogUtils.showAlertDialog(context, highlight, highlightDialogHintContent,
|
||||
"确定", "取消", {
|
||||
RetrofitManager.getInstance(context).api
|
||||
DialogUtils.showAlertDialog(
|
||||
context, highlight, highlightDialogHintContent,
|
||||
"确定", "取消", {
|
||||
RetrofitManager.getInstance(context).api
|
||||
.highlightAnswerComment(answerId, comment.id)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.subscribe(highlightObserver)
|
||||
}, null)
|
||||
}, null
|
||||
)
|
||||
} else {
|
||||
DialogUtils.showAlertDialog(context, highlight, highlightDialogHintContent,
|
||||
"确定", "取消", {
|
||||
RetrofitManager.getInstance(context).api
|
||||
.highlightCommunityArticleComment(communityId, articleId, comment.id)
|
||||
DialogUtils.showAlertDialog(
|
||||
context, highlight, highlightDialogHintContent,
|
||||
"确定", "取消", {
|
||||
RetrofitManager.getInstance(context).api
|
||||
.highlightCommunityArticleComment(
|
||||
communityId,
|
||||
articleId,
|
||||
comment.id
|
||||
)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.subscribe(highlightObserver)
|
||||
}, null)
|
||||
}, null
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@ -324,7 +448,10 @@ object CommentHelper {
|
||||
val errorJson = JSONObject(string)
|
||||
val errorCode = errorJson.getInt("code")
|
||||
if (errorCode == 403059) {
|
||||
Utils.toast(HaloApp.getInstance().application, "权限错误,请刷新后重试")
|
||||
Utils.toast(
|
||||
HaloApp.getInstance().application,
|
||||
"权限错误,请刷新后重试"
|
||||
)
|
||||
return
|
||||
} else {
|
||||
Utils.toast(HaloApp.getInstance().application, e.message())
|
||||
@ -335,46 +462,40 @@ object CommentHelper {
|
||||
}
|
||||
|
||||
if (answerId != null) {
|
||||
DialogUtils.showAlertDialog(context, hide, hideDialogHintContent,
|
||||
"确定", "取消", {
|
||||
RetrofitManager.getInstance(context).api
|
||||
DialogUtils.showAlertDialog(
|
||||
context, hide, hideDialogHintContent,
|
||||
"确定", "取消", {
|
||||
RetrofitManager.getInstance(context).api
|
||||
.hideAnswerComment(answerId, comment.id)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.subscribe(hideObserver)
|
||||
}, null)
|
||||
}, null
|
||||
)
|
||||
} else {
|
||||
DialogUtils.showAlertDialog(context, hide, hideDialogHintContent,
|
||||
"确定", "取消", {
|
||||
RetrofitManager.getInstance(context).api
|
||||
DialogUtils.showAlertDialog(
|
||||
context, hide, hideDialogHintContent,
|
||||
"确定", "取消", {
|
||||
RetrofitManager.getInstance(context).api
|
||||
.hideCommunityArticleComment(communityId, articleId, comment.id)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.subscribe(hideObserver)
|
||||
}, null)
|
||||
}, null
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun showReportTypeDialog(context: Context, isVideoComment: Boolean, reportCallback: (reportType: String) -> Unit) {
|
||||
private fun showReportTypeDialog(
|
||||
context: Context,
|
||||
reportCallback: (reportType: String) -> Unit
|
||||
) {
|
||||
val reportTypes = arrayListOf("垃圾广告营销", "恶意攻击谩骂", "淫秽色情信息", "违法有害信息", "其它")
|
||||
|
||||
if (!isVideoComment) {
|
||||
DialogUtils.showListDialog(context, reportTypes, null) { text ->
|
||||
val jsonObject = JSONObject()
|
||||
try {
|
||||
jsonObject.put("reason", text)
|
||||
reportCallback.invoke(jsonObject.toString())
|
||||
} catch (e: JSONException) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
} else {
|
||||
DialogUtils.showVideoComplaintDialog(context, reportTypes, null) { text ->
|
||||
reportCallback.invoke(text)
|
||||
}
|
||||
DialogUtils.showVideoComplaintDialog(context, reportTypes, null) { text ->
|
||||
reportCallback.invoke(text)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -271,6 +271,7 @@ public class CommentUtils {
|
||||
String articleId,
|
||||
String articleCommunityId,
|
||||
String videoId,
|
||||
String questionId,
|
||||
final CommentEntity commentEntity,
|
||||
final TextView commentLikeCountTv,
|
||||
final ImageView commentLikeIv,
|
||||
@ -294,7 +295,7 @@ public class CommentUtils {
|
||||
commentLikeCountTv.setText(NumberUtils.transSimpleCount(commentEntity.getVote()));
|
||||
commentLikeCountTv.setVisibility(View.VISIBLE);
|
||||
|
||||
PostCommentUtils.likeComment(context, answerId, articleId, articleCommunityId, videoId, commentEntity.getId(),
|
||||
PostCommentUtils.likeComment(context, answerId, articleId, articleCommunityId, videoId, questionId, commentEntity.getId(),
|
||||
new PostCommentUtils.PostCommentListener() {
|
||||
@Override
|
||||
public void postSuccess(JSONObject response) {
|
||||
@ -334,20 +335,21 @@ public class CommentUtils {
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
public static void voteVideoComment(final Context context,
|
||||
String answerId,
|
||||
String articleId,
|
||||
String articleCommunityId,
|
||||
String videoId,
|
||||
final CommentEntity commentEntity,
|
||||
final TextView commentLikeCountTv,
|
||||
final ImageView commentLikeIv,
|
||||
final OnVoteListener listener) {
|
||||
String answerId,
|
||||
String articleId,
|
||||
String articleCommunityId,
|
||||
String videoId,
|
||||
final CommentEntity commentEntity,
|
||||
final TextView commentLikeCountTv,
|
||||
final ImageView commentLikeIv,
|
||||
final OnVoteListener listener) {
|
||||
|
||||
String entrance = "视频流-评论-点赞";
|
||||
CheckLoginUtils.checkLogin(context, entrance, () -> {
|
||||
|
||||
PostCommentUtils.likeComment(context, answerId, articleId, articleCommunityId, videoId, commentEntity.getId(),
|
||||
PostCommentUtils.likeComment(context, answerId, articleId, articleCommunityId, videoId, "", commentEntity.getId(),
|
||||
new PostCommentUtils.PostCommentListener() {
|
||||
@Override
|
||||
public void postSuccess(JSONObject response) {
|
||||
@ -389,10 +391,10 @@ public class CommentUtils {
|
||||
}
|
||||
|
||||
public static void unVoteVideoComment(final Context context,
|
||||
String videoId,
|
||||
final CommentEntity commentEntity,
|
||||
final TextView commentLikeCountTv,
|
||||
final ImageView commentLikeIv) {
|
||||
String videoId,
|
||||
final CommentEntity commentEntity,
|
||||
final TextView commentLikeCountTv,
|
||||
final ImageView commentLikeIv) {
|
||||
String entrance = "视频流-评论-取消点赞";
|
||||
CheckLoginUtils.checkLogin(context, entrance, () -> {
|
||||
RetrofitManager.getInstance(context).getApi()
|
||||
@ -434,10 +436,10 @@ public class CommentUtils {
|
||||
holder.commentLikeIv.setImageResource(R.drawable.comment_vote_unselect);
|
||||
|
||||
if (userDataEntity == null || !userDataEntity.isCommentOwner()) {
|
||||
holder.replyLine.setVisibility(View.VISIBLE);
|
||||
if (holder.replyLine != null) holder.replyLine.setVisibility(View.VISIBLE);
|
||||
holder.commentReply.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
holder.replyLine.setVisibility(View.GONE);
|
||||
if (holder.replyLine != null) holder.replyLine.setVisibility(View.GONE);
|
||||
holder.commentReply.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
|
||||
@ -35,7 +35,7 @@ public class DataCollectionUtils {
|
||||
public static void uploadDownload(Context context, DownloadEntity downloadEntity, String status) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("game", StringsKt.removeSuffix(downloadEntity.getName(), Constants.GAME_NAME_DECORATOR));
|
||||
map.put("game_id", downloadEntity.getRealGameId(Constants.GAME_ID_DIVIDER));
|
||||
map.put("game_id", downloadEntity.getGameId());
|
||||
if (downloadEntity.isPluggable()) {
|
||||
map.put("method", "插件化");
|
||||
map.put("btn_status", "插件化");
|
||||
|
||||
@ -52,8 +52,8 @@ public class DataLogUtils {
|
||||
String user = Installation.getUUID(context);
|
||||
String channel = HaloApp.getInstance().getChannel();
|
||||
map.put("version", version);
|
||||
map.put("user", user);
|
||||
map.put("device_id", MetaUtil.getIMEI());
|
||||
map.put("resu", user);
|
||||
map.put("jnfj", MetaUtil.getBase64EncodedIMEI());
|
||||
map.put("channel", channel);
|
||||
|
||||
Map<String, String> params = new HashMap<>();
|
||||
|
||||
@ -7,6 +7,7 @@ import android.os.Build;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.gh.common.AppExecutor;
|
||||
import com.gh.common.constant.Constants;
|
||||
import com.gh.common.exposure.meta.MetaUtil;
|
||||
import com.gh.gamecenter.BuildConfig;
|
||||
@ -19,9 +20,8 @@ import com.lightgame.utils.Utils;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import io.sentry.Sentry;
|
||||
import io.sentry.android.core.SentryAndroid;
|
||||
import io.sentry.core.Sentry;
|
||||
import io.sentry.core.protocol.User;
|
||||
|
||||
/**
|
||||
* Created by LGT on 2016/6/15.
|
||||
@ -40,34 +40,9 @@ public class DataUtils {
|
||||
if (CommonDebug.IS_DEBUG) {
|
||||
return;
|
||||
}
|
||||
|
||||
SentryAndroid.init(context, options -> {
|
||||
options.setDebug(BuildConfig.DEBUG);
|
||||
options.setEnableSessionTracking(true);
|
||||
options.setEnvironment(BuildConfig.FLAVOR);
|
||||
options.setDsn("https://6b1caf0d17c1408e8680f3f73ff80bd0@sentry.ghzs.com/22");
|
||||
|
||||
options.setBeforeSend((event, hint) -> {
|
||||
if (BuildConfig.DEBUG) {
|
||||
return null;
|
||||
} else {
|
||||
return event;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Sentry.configureScope(scope -> {
|
||||
User user = new User();
|
||||
user.setId(HaloApp.getInstance().getGid());
|
||||
scope.setUser(user);
|
||||
|
||||
if (BuildConfig.BUILD_TIME != 0L) {
|
||||
scope.setTag("alias", "内测版" + BuildConfig.VERSION_NAME + "_" + BuildConfig.BUILD_TIME);
|
||||
} else {
|
||||
scope.setTag("alias", "正式版" + BuildConfig.VERSION_NAME);
|
||||
scope.setTag("channel", channel);
|
||||
}
|
||||
});
|
||||
|
||||
// 初始化 Sentry 约占用 90ms,这里切换到子线程初始化
|
||||
AppExecutor.getIoExecutor().execute(() -> initSentry(context, channel));
|
||||
|
||||
//TalkingData
|
||||
// try {
|
||||
@ -137,6 +112,41 @@ public class DataUtils {
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
private static void initSentry(Context context, String channel) {
|
||||
SentryAndroid.init(context, options -> {
|
||||
// Sentry 疯狂报 ANR (很大一部分还是莫名奇妙的 ANR)严重影响到其它闪退日志的收集
|
||||
// 这里将它局限到只有官网渠道的包才统计 ANR
|
||||
if ("GH_206".equals(channel)) {
|
||||
options.setAnrEnabled(true);
|
||||
options.setAnrTimeoutIntervalMillis(6000);
|
||||
} else {
|
||||
options.setAnrEnabled(false);
|
||||
}
|
||||
|
||||
options.setDebug(BuildConfig.DEBUG);
|
||||
options.setEnableSessionTracking(true);
|
||||
options.setEnvironment(BuildConfig.FLAVOR);
|
||||
options.setDsn("https://6b1caf0d17c1408e8680f3f73ff80bd0@sentry.ghzs.com/22");
|
||||
|
||||
options.setBeforeSend((event, hint) -> {
|
||||
if (BuildConfig.DEBUG) {
|
||||
return null;
|
||||
} else {
|
||||
return event;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Sentry.configureScope(scope -> {
|
||||
if (BuildConfig.BUILD_TIME != 0L) {
|
||||
scope.setTag("alias", "内测版" + BuildConfig.VERSION_NAME);
|
||||
} else {
|
||||
scope.setTag("alias", "正式版" + BuildConfig.VERSION_NAME);
|
||||
scope.setTag("channel", channel);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// MTA ->【次数统计】Key-Value参数的事件
|
||||
public static void onMtaEvent(Context context, String eventId, String... kv) {
|
||||
@ -229,7 +239,7 @@ public class DataUtils {
|
||||
|
||||
kv.put("版本", platform);
|
||||
kv.put("用户机型", Build.MODEL);
|
||||
kv.put("设备IMEI", MetaUtil.getIMEI());
|
||||
kv.put("设备JNFJ", MetaUtil.getBase64EncodedIMEI());
|
||||
kv.put("网络状态", DeviceUtils.getNetwork(HaloApp.getInstance().getApplication()));
|
||||
kv.put("光环助手版本", BuildConfig.VERSION_NAME);
|
||||
kv.put("位置", entrance);
|
||||
|
||||
@ -41,11 +41,11 @@ public class DeviceUtils {
|
||||
context = context.getApplicationContext();
|
||||
JSONObject object = new JSONObject();
|
||||
object.put("os", "Android");
|
||||
object.put("imei", MetaUtil.getIMEI());
|
||||
object.put("jnfj", MetaUtil.getBase64EncodedIMEI());
|
||||
object.put("mac", getMac(context));
|
||||
object.put("model", MODEL);
|
||||
object.put("manufacturer", MANUFACTURER);
|
||||
object.put("android_id", MetaUtil.getAndroidId());
|
||||
object.put("dia", MetaUtil.getBase64EncodedAndroidId());
|
||||
object.put("android_sdk", Build.VERSION.SDK_INT);
|
||||
object.put("android_version", android.os.Build.VERSION.RELEASE);
|
||||
object.put("ip", "");
|
||||
@ -57,8 +57,8 @@ public class DeviceUtils {
|
||||
public static JSONObject getUserDevice(Context context) { // 判断新老用户device数据
|
||||
JSONObject object = new JSONObject();
|
||||
try {
|
||||
object.put("IMEI", MetaUtil.getIMEI());
|
||||
object.put("ANDROID_ID", MetaUtil.getAndroidId());
|
||||
object.put("JNFJ", MetaUtil.getBase64EncodedIMEI());
|
||||
object.put("DIA", MetaUtil.getBase64EncodedAndroidId());
|
||||
object.put("MAC", getMac(context));
|
||||
// object.put("MTA_ID", StatConfig.getMid(context));
|
||||
object.put("MANUFACTURER", MANUFACTURER);
|
||||
@ -258,7 +258,7 @@ public class DeviceUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public static long getTotalRamSizeOfDevice(Context context) {
|
||||
public static long getTotalRamSizeOfDevice(Context context) {
|
||||
ActivityManager actManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
|
||||
ActivityManager.MemoryInfo memInfo = new ActivityManager.MemoryInfo();
|
||||
if (actManager != null) {
|
||||
|
||||
@ -1,82 +1,112 @@
|
||||
package com.gh.common.util
|
||||
|
||||
import android.app.Activity
|
||||
import android.app.Dialog
|
||||
import android.content.Context
|
||||
import android.graphics.Color
|
||||
import android.graphics.drawable.ColorDrawable
|
||||
import android.view.Gravity
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.Window
|
||||
import android.widget.TextView
|
||||
import com.gh.common.dialog.TrackableDialog
|
||||
import com.gh.common.util.DialogUtils.checkDialogContext
|
||||
import com.gh.gamecenter.AboutActivity
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.databinding.DialogAlertDefaultBinding
|
||||
|
||||
object DialogHelper {
|
||||
|
||||
/**
|
||||
* Material Design 风格弹窗
|
||||
* 光环常规弹窗
|
||||
*
|
||||
* @param context
|
||||
* @param title 标题
|
||||
* @param content 内容
|
||||
* @param positiveText 确认按钮文本
|
||||
* @param negativeText 取消按钮文本
|
||||
* @param positiveClickCallback 确认按钮监听
|
||||
* @param negativeClickCallback 取消按钮监听
|
||||
* @param trackMtaEvent 是否记录出现、关闭弹窗MTA事件
|
||||
* @param mtaEvent MTA 的事件名
|
||||
* @param mtaKey MTA 的事件 Key
|
||||
* extraConfig,可选标题居中、内容居中、是否显示关闭按钮以及是否显示正文辅助文本等
|
||||
*
|
||||
* uiModificationCallback,可用来手动微调样式的回调,可使用 binding 来修改颜色、文字大小等
|
||||
*/
|
||||
fun showDialog(context: Context,
|
||||
title: String,
|
||||
content: CharSequence,
|
||||
positiveText: String,
|
||||
negativeText: String,
|
||||
positiveClickCallback: (() -> Unit)? = null,
|
||||
negativeClickCallback: (() -> Unit)? = null,
|
||||
trackMtaEvent: Boolean = false,
|
||||
mtaEvent: String = "",
|
||||
mtaKey: String = ""): Dialog {
|
||||
fun showDialog(
|
||||
context: Context,
|
||||
title: String,
|
||||
content: CharSequence,
|
||||
confirmText: String,
|
||||
cancelText: String,
|
||||
confirmClickCallback: (() -> Unit)? = null,
|
||||
cancelClickCallback: (() -> Unit)? = null,
|
||||
extraConfig: Config? = null,
|
||||
uiModificationCallback: ((binding: DialogAlertDefaultBinding) -> Unit)? = null,
|
||||
trackMtaEvent: Boolean = false,
|
||||
mtaEvent: String = "",
|
||||
mtaKey: String = "") {
|
||||
val solidContext = checkDialogContext(context)
|
||||
|
||||
if (solidContext is Activity && solidContext.isFinishing) return
|
||||
|
||||
val dialog = if (trackMtaEvent) {
|
||||
TrackableDialog(solidContext, R.style.GhAlertDialog, mtaEvent, mtaKey)
|
||||
} else {
|
||||
Dialog(solidContext, R.style.GhAlertDialog)
|
||||
}
|
||||
|
||||
val contentView = LayoutInflater.from(solidContext).inflate(R.layout.dialog_alert, null)
|
||||
val contentTv = contentView.findViewById<TextView>(R.id.dialog_content)
|
||||
val titleTv = contentView.findViewById<TextView>(R.id.dialog_title)
|
||||
val negativeTv = contentView.findViewById<TextView>(R.id.dialog_negative)
|
||||
val positiveTv = contentView.findViewById<TextView>(R.id.dialog_positive)
|
||||
contentTv.text = content
|
||||
titleTv.text = title
|
||||
negativeTv.text = negativeText
|
||||
positiveTv.text = positiveText
|
||||
val binding = DialogAlertDefaultBinding.inflate(LayoutInflater.from(solidContext))
|
||||
val contentView = binding.root
|
||||
binding.contentTv.text = content
|
||||
binding.titleTv.text = title
|
||||
|
||||
negativeTv.setOnClickListener {
|
||||
if (trackMtaEvent) MtaHelper.onEvent(mtaEvent, mtaKey, "点击" + negativeText)
|
||||
extraConfig?.let {
|
||||
if (it.hint.isNotEmpty()) {
|
||||
binding.hintTv.visibility = View.VISIBLE
|
||||
binding.hintTv.text = it.hint
|
||||
}
|
||||
|
||||
negativeClickCallback?.invoke()
|
||||
if (it.centerTitle) {
|
||||
binding.titleTv.gravity = Gravity.CENTER
|
||||
}
|
||||
|
||||
if (it.centerContent) {
|
||||
binding.contentTv.gravity = Gravity.CENTER
|
||||
}
|
||||
|
||||
if (it.showCloseIcon) {
|
||||
binding.closeContainer.visibility = View.VISIBLE
|
||||
binding.closeContainer.setOnClickListener { dialog.dismiss() }
|
||||
}
|
||||
}
|
||||
|
||||
if (cancelText.isEmpty()) {
|
||||
binding.cancelTv.visibility = View.GONE
|
||||
binding.centerDivider.visibility = View.GONE
|
||||
}
|
||||
|
||||
binding.cancelTv.text = cancelText
|
||||
binding.confirmTv.text = confirmText
|
||||
|
||||
binding.cancelTv.setOnClickListener {
|
||||
if (trackMtaEvent) MtaHelper.onEvent(mtaEvent, mtaKey, "点击$cancelText")
|
||||
|
||||
cancelClickCallback?.invoke()
|
||||
dialog.dismiss()
|
||||
}
|
||||
|
||||
positiveTv.setOnClickListener {
|
||||
if (trackMtaEvent) MtaHelper.onEvent(mtaEvent, mtaKey, "点击$positiveText")
|
||||
binding.confirmTv.setOnClickListener {
|
||||
if (trackMtaEvent) MtaHelper.onEvent(mtaEvent, mtaKey, "点击$confirmText")
|
||||
|
||||
positiveClickCallback?.invoke()
|
||||
confirmClickCallback?.invoke()
|
||||
dialog.dismiss()
|
||||
}
|
||||
|
||||
uiModificationCallback?.invoke(binding)
|
||||
|
||||
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE)
|
||||
dialog.setContentView(contentView)
|
||||
dialog.window?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))
|
||||
dialog.show()
|
||||
return dialog
|
||||
}
|
||||
|
||||
/**
|
||||
* For legacy java invocation
|
||||
*/
|
||||
@JvmStatic
|
||||
@Deprecated("Kotlin 中请使用其它方法调用")
|
||||
fun showDialog(context: Context,
|
||||
title: String,
|
||||
content: CharSequence,
|
||||
@ -86,8 +116,88 @@ object DialogHelper {
|
||||
negativeClickCallback: EmptyCallback,
|
||||
trackMtaEvent: Boolean = false,
|
||||
mtaEvent: String = "",
|
||||
mtaKey: String = ""): Dialog {
|
||||
return showDialog(context, title, content, positiveText, negativeText, { positiveClickCallback.onCallback() }, { negativeClickCallback.onCallback() }, trackMtaEvent, mtaEvent, mtaKey)
|
||||
mtaKey: String = "") {
|
||||
showDialog(
|
||||
context = context,
|
||||
title = title,
|
||||
content = content,
|
||||
confirmText = positiveText,
|
||||
cancelText = negativeText,
|
||||
confirmClickCallback = { positiveClickCallback.onCallback() },
|
||||
cancelClickCallback = { negativeClickCallback.onCallback() },
|
||||
trackMtaEvent = trackMtaEvent,
|
||||
mtaEvent = mtaEvent,
|
||||
mtaKey = mtaKey)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun showSignatureConflictDialog(context: Context,
|
||||
confirmClickCallback: (() -> Unit)? = null) {
|
||||
showDialog(
|
||||
context,
|
||||
"温馨提示",
|
||||
"检测到安装包与已安装应用的签名不一致,需要卸载后才能安装,是否立即卸载",
|
||||
"卸载",
|
||||
"取消",
|
||||
{ confirmClickCallback?.invoke() },
|
||||
null,
|
||||
Config(hint = "注意:卸载会让游戏数据丢失,请提前做好备份"),
|
||||
{ binding -> binding.hintTv.setTextColor(R.color.theme_font.toColor()) }
|
||||
)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun showPluginDialog(context: Context,
|
||||
confirmClickCallback: (() -> Unit)? = null) {
|
||||
MtaHelper.onEvent("插件化", "插件化安装弹窗", "出现弹窗提示")
|
||||
showDialog(
|
||||
context,
|
||||
"插件化安装",
|
||||
"您将进行插件化安装以实现插件功能,此过程将卸载当前使用的版本并安装插件版本",
|
||||
"确认,开始插件化",
|
||||
"取消",
|
||||
{
|
||||
confirmClickCallback?.invoke()
|
||||
MtaHelper.onEvent("插件化", "插件化安装弹窗", "确认并开始")
|
||||
},
|
||||
{ MtaHelper.onEvent("插件化", "插件化安装弹窗", "取消") },
|
||||
Config(hint = "注意:卸载前请妥善保存游戏账号与密码"),
|
||||
{ binding -> binding.hintTv.setTextColor(R.color.text_FF0000.toColor()) }
|
||||
)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun showUpgradeDialog(context: Context) {
|
||||
showDialog(
|
||||
context,
|
||||
"提示",
|
||||
"当前版本暂不支持该功能,\n建议您升级到最新版本体验哦",
|
||||
"检查升级",
|
||||
"取消",
|
||||
confirmClickCallback = { context.startActivity(AboutActivity.getIntent(context, true)); },
|
||||
uiModificationCallback = {
|
||||
it.titleTv.gravity = Gravity.CENTER
|
||||
it.contentTv.gravity = Gravity.CENTER
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@JvmStatic
|
||||
fun showDowngradeHintDialog(context: Context,
|
||||
confirmClickCallback: (() -> Unit)? = null) {
|
||||
showDialog(
|
||||
context,
|
||||
"温馨提示",
|
||||
"您已安装较高版本,若要安装历史版本需先卸载再安装\n",
|
||||
"我知道了",
|
||||
"",
|
||||
{ confirmClickCallback?.invoke() })
|
||||
}
|
||||
|
||||
data class Config(val hint: String = "",
|
||||
val showCloseIcon: Boolean = false,
|
||||
val centerTitle: Boolean = false,
|
||||
val centerContent: Boolean = false)
|
||||
|
||||
}
|
||||
@ -1,5 +1,6 @@
|
||||
package com.gh.common.util;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
@ -14,12 +15,15 @@ import android.os.CountDownTimer;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.provider.Settings;
|
||||
import android.text.Html;
|
||||
import android.text.Spannable;
|
||||
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.text.style.URLSpan;
|
||||
import android.text.style.UnderlineSpan;
|
||||
import android.view.Gravity;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.LayoutInflater;
|
||||
@ -33,6 +37,7 @@ import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
@ -42,11 +47,15 @@ import androidx.core.content.ContextCompat;
|
||||
import androidx.databinding.DataBindingUtil;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import kotlin.Unit;
|
||||
import kotlin.jvm.functions.Function0;
|
||||
|
||||
import com.facebook.drawee.generic.GenericDraweeHierarchy;
|
||||
import com.facebook.drawee.view.SimpleDraweeView;
|
||||
import com.gh.common.AppExecutor;
|
||||
import com.gh.common.constant.Config;
|
||||
import com.gh.common.dialog.TrackableDialog;
|
||||
import com.gh.common.view.CustomLinkMovementMethod;
|
||||
import com.gh.common.view.DrawableView;
|
||||
import com.gh.common.view.FixLinearLayoutManager;
|
||||
import com.gh.common.view.LimitHeightLinearLayout;
|
||||
@ -55,7 +64,13 @@ import com.gh.gamecenter.AboutActivity;
|
||||
import com.gh.gamecenter.R;
|
||||
import com.gh.gamecenter.SuggestionActivity;
|
||||
import com.gh.gamecenter.adapter.viewholder.PrivacyPolicyItemViewHolder;
|
||||
import com.gh.gamecenter.databinding.DialogBindPhoneBinding;
|
||||
import com.gh.gamecenter.databinding.DialogEnergySignBinding;
|
||||
import com.gh.gamecenter.databinding.DialogOverseaConfirmationBinding;
|
||||
import com.gh.gamecenter.databinding.DialogPackageParseErrorBinding;
|
||||
import com.gh.gamecenter.databinding.DialogQuickLoginPermissionBinding;
|
||||
import com.gh.gamecenter.databinding.DialogReceiveLibaoSuccessBinding;
|
||||
import com.gh.gamecenter.databinding.DialogReportReasonBinding;
|
||||
import com.gh.gamecenter.databinding.ImprintContentItemBinding;
|
||||
import com.gh.gamecenter.databinding.PrivacyItemBinding;
|
||||
import com.gh.gamecenter.entity.ApkEntity;
|
||||
@ -64,7 +79,9 @@ import com.gh.gamecenter.entity.BadgeEntity;
|
||||
import com.gh.gamecenter.entity.GameEntity;
|
||||
import com.gh.gamecenter.entity.PrivacyPolicyEntity;
|
||||
import com.gh.gamecenter.entity.SettingsEntity;
|
||||
import com.gh.gamecenter.entity.SimpleGameEntity;
|
||||
import com.gh.gamecenter.entity.TrackableEntity;
|
||||
import com.gh.gamecenter.setting.GameDownloadSettingFragment;
|
||||
import com.gh.gamecenter.suggest.SuggestType;
|
||||
import com.halo.assistant.HaloApp;
|
||||
import com.halo.assistant.fragment.SettingsFragment;
|
||||
@ -206,7 +223,7 @@ public class DialogUtils {
|
||||
} else if (NetworkUtils.isWifiConnected(context)
|
||||
|| filter4GorSize(context, size)) {
|
||||
callBack.onResponse(false);
|
||||
} else if (!preferences.getBoolean(SettingsFragment.getTrafficDownloadHintKey(), true)) {
|
||||
} else if (!preferences.getBoolean(GameDownloadSettingFragment.getTrafficDownloadHintKey(), true)) {
|
||||
AppExecutor.getUiExecutor().executeWithDelay(() -> Utils.toast(context, "当前使用移动网络下载,请注意流量消耗"), 500);
|
||||
callBack.onResponse(false);
|
||||
} else {
|
||||
@ -281,7 +298,7 @@ public class DialogUtils {
|
||||
PreferenceManager
|
||||
.getDefaultSharedPreferences(finalContext)
|
||||
.edit()
|
||||
.putBoolean(SettingsFragment.getTrafficDownloadHintKey(), false)
|
||||
.putBoolean(GameDownloadSettingFragment.getTrafficDownloadHintKey(), false)
|
||||
.apply();
|
||||
AppExecutor.getUiExecutor().executeWithDelay(() -> {
|
||||
// 显示了弹窗以后,即便下面这个 toast 放在 listener.onConfirm 后调用也是显示 listener.onConfirm 里的 toast
|
||||
@ -311,33 +328,6 @@ public class DialogUtils {
|
||||
showCancelListenerDialog(context, "取消关注", content, "确定取消", "暂不取消", listener, cancelListener);
|
||||
}
|
||||
|
||||
public static void showPluginDialog(Context context, final ConfirmListener listener) {
|
||||
context = checkDialogContext(context);
|
||||
|
||||
MtaHelper.onEvent("插件化", "插件化安装弹窗", "出现弹窗提示");
|
||||
|
||||
final Dialog dialog = new Dialog(context, R.style.GhAlertDialog);
|
||||
|
||||
View contentView = LayoutInflater.from(context).inflate(R.layout.dialog_plugin, null);
|
||||
TextView negativeTv = contentView.findViewById(R.id.dialog_negative);
|
||||
TextView positiveTv = contentView.findViewById(R.id.dialog_positive);
|
||||
negativeTv.setOnClickListener(v -> {
|
||||
dialog.dismiss();
|
||||
MtaHelper.onEvent("插件化", "插件化安装弹窗", "取消");
|
||||
});
|
||||
positiveTv.setOnClickListener(view -> {
|
||||
if (listener != null) {
|
||||
listener.onConfirm();
|
||||
}
|
||||
dialog.dismiss();
|
||||
MtaHelper.onEvent("插件化", "插件化安装弹窗", "确认并开始");
|
||||
});
|
||||
|
||||
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
dialog.setContentView(contentView);
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
/**
|
||||
* ios 风格弹窗
|
||||
*
|
||||
@ -350,7 +340,7 @@ public class DialogUtils {
|
||||
* @param cmListener 确认按钮监听
|
||||
*/
|
||||
public static Dialog showNewAlertDialog(Context context, String title, CharSequence message
|
||||
, String negative, String positive, TrackableEntity trackableEntity, int gravity, final CancelListener clListener, final ConfirmListener cmListener) {
|
||||
, String negative, String positive, TrackableEntity trackableEntity, int gravity, boolean shouldShowCloseBtn, final CancelListener clListener, final ConfirmListener cmListener) {
|
||||
context = checkDialogContext(context);
|
||||
final Dialog dialog;
|
||||
if (trackableEntity != null) {
|
||||
@ -373,6 +363,7 @@ public class DialogUtils {
|
||||
TextView cancelBtn = contentView.findViewById(R.id.cancel);
|
||||
TextView confirmBtn = contentView.findViewById(R.id.confirm);
|
||||
View middleLine = contentView.findViewById(R.id.middle_line);
|
||||
View closeIv = contentView.findViewById(R.id.closeIv);
|
||||
titleTv.setGravity(gravity);
|
||||
contentTv.setGravity(gravity);
|
||||
|
||||
@ -389,6 +380,8 @@ public class DialogUtils {
|
||||
confirmBtn.setVisibility(View.GONE);
|
||||
middleLine.setVisibility(View.GONE);
|
||||
}
|
||||
closeIv.setVisibility(shouldShowCloseBtn ? View.VISIBLE : View.GONE);
|
||||
closeIv.setOnClickListener(v -> dialog.dismiss());
|
||||
|
||||
cancelBtn.setOnClickListener(v -> {
|
||||
if (clListener != null) clListener.onCancel();
|
||||
@ -413,7 +406,12 @@ public class DialogUtils {
|
||||
|
||||
public static Dialog showNewAlertDialog(Context context, String title, CharSequence message
|
||||
, String negative, String positive, final CancelListener clListener, final ConfirmListener cmListener) {
|
||||
return showNewAlertDialog(context, title, message, negative, positive, null, Gravity.LEFT, clListener, cmListener);
|
||||
return showNewAlertDialog(context, title, message, negative, positive, null, Gravity.LEFT, false, clListener, cmListener);
|
||||
}
|
||||
|
||||
public static Dialog showNewAlertDialog(Context context, String title, CharSequence message
|
||||
, String negative, String positive, int gravity, boolean shouldShowCloseBtn, final CancelListener clListener, final ConfirmListener cmListener) {
|
||||
return showNewAlertDialog(context, title, message, negative, positive, null, gravity, shouldShowCloseBtn, clListener, cmListener);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -790,33 +788,6 @@ 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 showLowSystemVersionDialog(Context context) {
|
||||
final Context activityContext = checkDialogContext(context);
|
||||
@ -970,7 +941,7 @@ public class DialogUtils {
|
||||
|
||||
public static void showPrivacyPolicyDialog(Context context,
|
||||
@NonNull PrivacyPolicyEntity entity,
|
||||
EmptyCallback callback) {
|
||||
SimpleCallback<Boolean> callback) {
|
||||
|
||||
final Context activityContext = checkDialogContext(context);
|
||||
|
||||
@ -1086,19 +1057,31 @@ public class DialogUtils {
|
||||
|
||||
title.setText(entity.getTitle());
|
||||
linkContent.setText(skipText);
|
||||
linkContent.setMovementMethod(new LinkMovementMethod());
|
||||
linkContent.setMovementMethod(LinkMovementMethod.getInstance());
|
||||
topContent.setText(entity.getTopContent());
|
||||
bottomContent.setText(entity.getBottomContent());
|
||||
bottomContent.setText(ExtensionsKt.fromHtml(entity.getBottomContent()));
|
||||
bottomContent.setMovementMethod(CustomLinkMovementMethod.getInstance());
|
||||
|
||||
// Remove underline
|
||||
Spannable sa = (Spannable) bottomContent.getText();
|
||||
for (URLSpan u : sa.getSpans(0, sa.length(), URLSpan.class)) {
|
||||
sa.setSpan(new UnderlineSpan() {
|
||||
public void updateDrawState(TextPaint tp) {
|
||||
tp.setUnderlineText(false);
|
||||
}
|
||||
}, sa.getSpanStart(u), sa.getSpanEnd(u), 0);
|
||||
}
|
||||
|
||||
allowButton.setOnClickListener(view -> {
|
||||
dialog.dismiss();
|
||||
callback.onCallback();
|
||||
callback.onCallback(true);
|
||||
// MtaHelper.onEvent("隐私政策弹窗", "隐私政策弹窗", "点击同意");
|
||||
});
|
||||
|
||||
disallowButton.setOnClickListener(v -> {
|
||||
dialog.dismiss();
|
||||
showPrivacyPolicyDisallowDialog(activityContext, entity, callback);
|
||||
callback.onCallback(false);
|
||||
// showPrivacyPolicyDisallowDialog(activityContext, entity, callback);
|
||||
// MtaHelper.onEvent("隐私政策弹窗", "隐私政策弹窗", "不同意并退出App");
|
||||
});
|
||||
|
||||
@ -1902,6 +1885,337 @@ public class DialogUtils {
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
public static Dialog showCancelOrDeleteReservationDialog(Context context, String title, String 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_cancel_reservation, 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(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();
|
||||
Window window = dialog.getWindow();
|
||||
if (window != null) {
|
||||
window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
|
||||
WindowManager.LayoutParams params = window.getAttributes();
|
||||
params.width = context.getResources().getDisplayMetrics().widthPixels - DisplayUtils.dip2px(60f);
|
||||
window.setAttributes(params);
|
||||
}
|
||||
return dialog;
|
||||
}
|
||||
|
||||
public static void showEnergyDialog(Context context, String userName, long energy) {
|
||||
context = checkDialogContext(context);
|
||||
|
||||
final Dialog dialog = new Dialog(context, R.style.DialogWindowTransparent);
|
||||
|
||||
View contentView = LayoutInflater.from(context).inflate(R.layout.dialog_energy, null);
|
||||
((TextView) contentView.findViewById(R.id.userName)).setText("\"" + userName + "\"");
|
||||
((TextView) contentView.findViewById(R.id.energy)).setText(energy + "");
|
||||
|
||||
contentView.findViewById(R.id.dialog_positive).setOnClickListener(v -> {
|
||||
dialog.dismiss();
|
||||
});
|
||||
|
||||
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
dialog.setContentView(contentView);
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
public static void showEnergyTaskNoticeDialog(Context context, String title, String content) {
|
||||
context = checkDialogContext(context);
|
||||
|
||||
final Dialog dialog = new Dialog(context, R.style.DialogWindowTransparent);
|
||||
|
||||
View contentView = LayoutInflater.from(context).inflate(R.layout.dialog_notice, null);
|
||||
TextView titleTv = contentView.findViewById(R.id.dialog_title);
|
||||
TextView contentTv = contentView.findViewById(R.id.dialog_content);
|
||||
TextView okTv = contentView.findViewById(R.id.dialog_ok);
|
||||
|
||||
if (title == null) {
|
||||
titleTv.setVisibility(View.GONE);
|
||||
} else {
|
||||
titleTv.setVisibility(View.VISIBLE);
|
||||
titleTv.setText(title);
|
||||
}
|
||||
contentTv.setText(content);
|
||||
|
||||
okTv.setTextColor(ContextCompat.getColor(context, R.color.theme_font));
|
||||
okTv.setOnClickListener(v -> {
|
||||
dialog.dismiss();
|
||||
});
|
||||
|
||||
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
dialog.setContentView(contentView);
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
public static void showSimulatorParseErrorDialog(Context context, String gameId, String gameName, ConfirmListener confirmListener) {
|
||||
context = checkDialogContext(context);
|
||||
final Dialog dialog = new Dialog(context, R.style.GhAlertDialog);
|
||||
|
||||
DialogPackageParseErrorBinding binding = DialogPackageParseErrorBinding.inflate(LayoutInflater.from(context), null, false);
|
||||
Context finalContext = context;
|
||||
SpannableStringBuilder builder = new SpanBuilder("您也可以点击提交反馈跟我们联系").click(6, 10, R.color.theme_font, true, new Function0<Unit>() {
|
||||
@Override
|
||||
public Unit invoke() {
|
||||
SimpleGameEntity entity = new SimpleGameEntity(gameId, gameName, "");
|
||||
SuggestionActivity.startSuggestionActivity(finalContext, SuggestType.gameQuestion, "notfound", "模拟器安装包解析错误", entity, "-");
|
||||
dialog.dismiss();
|
||||
return null;
|
||||
}
|
||||
}).build();
|
||||
binding.feedbackTv.setText(builder);
|
||||
binding.feedbackTv.setMovementMethod(new LinkMovementMethod());
|
||||
|
||||
binding.cancel.setOnClickListener(v -> {
|
||||
dialog.dismiss();
|
||||
});
|
||||
binding.confirm.setOnClickListener(v -> {
|
||||
confirmListener.onConfirm();
|
||||
dialog.dismiss();
|
||||
});
|
||||
|
||||
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
dialog.setContentView(binding.getRoot());
|
||||
dialog.show();
|
||||
Window window = dialog.getWindow();
|
||||
if (window != null) {
|
||||
window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
|
||||
WindowManager.LayoutParams params = window.getAttributes();
|
||||
params.width = context.getResources().getDisplayMetrics().widthPixels - DisplayUtils.dip2px(60f);
|
||||
window.setAttributes(params);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
public static void showReportReasonDialog(Context context, ReportReasonCallBack callBack) {
|
||||
context = checkDialogContext(context);
|
||||
|
||||
final Dialog dialog = new Dialog(context, R.style.DialogWindowTransparent);
|
||||
DialogReportReasonBinding binding = DialogReportReasonBinding.inflate(LayoutInflater.from(context));
|
||||
|
||||
binding.reasonOne.setOnClickListener(v -> {
|
||||
dialog.dismiss();
|
||||
callBack.onResponse(binding.reasonOne.getText().toString(), "");
|
||||
});
|
||||
|
||||
binding.reasonTwo.setOnClickListener(v -> {
|
||||
dialog.dismiss();
|
||||
callBack.onResponse(binding.reasonTwo.getText().toString(), "");
|
||||
});
|
||||
|
||||
binding.reasonThree.setOnClickListener(v -> {
|
||||
dialog.dismiss();
|
||||
callBack.onResponse(binding.reasonThree.getText().toString(), "");
|
||||
});
|
||||
|
||||
binding.reasonFour.setOnClickListener(v -> {
|
||||
dialog.dismiss();
|
||||
callBack.onResponse(binding.reasonFour.getText().toString(), "");
|
||||
});
|
||||
|
||||
binding.reasonOther.setOnClickListener(v -> {
|
||||
binding.reasonTitle.setText(R.string.report_reason_other_title);
|
||||
binding.normalReasonContainer.setVisibility(View.GONE);
|
||||
binding.otherReasonContainer.setVisibility(View.VISIBLE);
|
||||
});
|
||||
|
||||
binding.negativeBtn.setOnClickListener(v -> {
|
||||
binding.reasonTitle.setText(R.string.report_reason_title);
|
||||
binding.normalReasonContainer.setVisibility(View.VISIBLE);
|
||||
binding.otherReasonContainer.setVisibility(View.GONE);
|
||||
});
|
||||
|
||||
binding.positiveBtn.setOnClickListener(v -> {
|
||||
if (TextUtils.isEmpty(binding.otherReasonEt.getText().toString().trim())) {
|
||||
ToastUtils.INSTANCE.showToast("请填写举报原因");
|
||||
} else {
|
||||
dialog.dismiss();
|
||||
callBack.onResponse("其它", binding.otherReasonEt.getText().toString());
|
||||
}
|
||||
});
|
||||
|
||||
Context finalContext = context;
|
||||
ExtensionsKt.setTextChangedListener(binding.otherReasonEt, (s, start, before, count) -> {
|
||||
int tvCount = s.length();
|
||||
if (tvCount >= 500) {
|
||||
binding.tvCount.setTextColor(ContextCompat.getColor(finalContext, R.color.text_FF4147));
|
||||
}
|
||||
binding.tvCount.setText(tvCount + "/500");
|
||||
return null;
|
||||
});
|
||||
|
||||
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
dialog.setContentView(binding.getRoot());
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
public static void showSignSuccessDialog(Context context, ConfirmListener listener) {
|
||||
context = checkDialogContext(context);
|
||||
|
||||
final Dialog dialog = new Dialog(context, R.style.DialogWindowTransparent);
|
||||
|
||||
View contentView = LayoutInflater.from(context).inflate(R.layout.dialog_sign_success, null);
|
||||
|
||||
ImageView signBg = contentView.findViewById(R.id.signBg);
|
||||
RelativeLayout signContainer = contentView.findViewById(R.id.signContainer);
|
||||
|
||||
Animation animation1 = AnimationUtils.loadAnimation(context, R.anim.anim_badge_light_bg);
|
||||
signBg.startAnimation(animation1);
|
||||
|
||||
Animation animation2 = AnimationUtils.loadAnimation(context, R.anim.anim_sign_dialog_dismiss);
|
||||
signContainer.postDelayed(() -> signContainer.startAnimation(animation2), 2000);
|
||||
|
||||
signContainer.postDelayed(dialog::dismiss, 3000);
|
||||
|
||||
dialog.setOnDismissListener(dialogInterface -> listener.onConfirm());
|
||||
|
||||
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
dialog.setContentView(contentView);
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
public static void showSignRuleDialog(Context context) {
|
||||
context = checkDialogContext(context);
|
||||
|
||||
final Dialog dialog = new Dialog(context, R.style.DialogWindowTransparent);
|
||||
|
||||
View contentView = LayoutInflater.from(context).inflate(R.layout.dialog_sign_rule, null);
|
||||
contentView.findViewById(R.id.dialog_ok).setOnClickListener(v -> dialog.dismiss());
|
||||
|
||||
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
dialog.setContentView(contentView);
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
public static void showBindPhoneDialog(Context context, ConfirmListener listener) {
|
||||
context = checkDialogContext(context);
|
||||
|
||||
final Dialog dialog = new Dialog(context, R.style.DialogWindowTransparent);
|
||||
DialogBindPhoneBinding binding = DialogBindPhoneBinding.inflate(LayoutInflater.from(context));
|
||||
|
||||
binding.positiveTv.setOnClickListener(v -> {
|
||||
dialog.dismiss();
|
||||
listener.onConfirm();
|
||||
});
|
||||
|
||||
binding.closeIv.setOnClickListener(v -> {
|
||||
dialog.dismiss();
|
||||
});
|
||||
|
||||
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
dialog.setContentView(binding.getRoot());
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
public static void showReceiveLibaoSuccessDialog(Context context, String title, String des, String libaoCode, ConfirmListener listener) {
|
||||
context = checkDialogContext(context);
|
||||
|
||||
final Dialog dialog = new Dialog(context, R.style.DialogWindowTransparent);
|
||||
DialogReceiveLibaoSuccessBinding binding = DialogReceiveLibaoSuccessBinding.inflate(LayoutInflater.from(context));
|
||||
binding.title.setText(title);
|
||||
binding.libaoCodeTv.setText(libaoCode);
|
||||
binding.desTv.setText(des);
|
||||
|
||||
binding.confirm.setOnClickListener(v -> {
|
||||
dialog.dismiss();
|
||||
listener.onConfirm();
|
||||
});
|
||||
|
||||
binding.cancel.setOnClickListener(v -> {
|
||||
dialog.dismiss();
|
||||
});
|
||||
|
||||
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
dialog.setContentView(binding.getRoot());
|
||||
dialog.show();
|
||||
Window window = dialog.getWindow();
|
||||
if (window != null) {
|
||||
window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
|
||||
WindowManager.LayoutParams params = window.getAttributes();
|
||||
params.width = context.getResources().getDisplayMetrics().widthPixels - DisplayUtils.dip2px(60f);
|
||||
window.setAttributes(params);
|
||||
}
|
||||
}
|
||||
|
||||
public static void showQuickLoginPermissionDialog(Context context, ConfirmListener confirmListener, CancelListener cancelListener) {
|
||||
context = checkDialogContext(context);
|
||||
|
||||
final Dialog dialog = new Dialog(context, R.style.DialogWindowTransparent);
|
||||
DialogQuickLoginPermissionBinding binding = DialogQuickLoginPermissionBinding.inflate(LayoutInflater.from(context));
|
||||
|
||||
binding.confirmBtn.setOnClickListener(v -> {
|
||||
dialog.dismiss();
|
||||
confirmListener.onConfirm();
|
||||
});
|
||||
|
||||
binding.cancelBtn.setOnClickListener(v -> {
|
||||
dialog.dismiss();
|
||||
cancelListener.onCancel();
|
||||
});
|
||||
|
||||
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
dialog.setContentView(binding.getRoot());
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
public static void showEnergySignDialog(Context context, int sevenDaySerialSign) {
|
||||
context = checkDialogContext(context);
|
||||
|
||||
final Dialog dialog = new Dialog(context, R.style.DialogWindowTransparent);
|
||||
DialogEnergySignBinding binding = DialogEnergySignBinding.inflate(LayoutInflater.from(context));
|
||||
|
||||
if (sevenDaySerialSign > 7) sevenDaySerialSign = 7;
|
||||
|
||||
for (int i = 1; i <= sevenDaySerialSign; i++) {
|
||||
int index = (i - 1) * 2;
|
||||
LinearLayout dayContainer = (LinearLayout) binding.signDaysContainer.getChildAt(index);
|
||||
ImageView dayIv = (ImageView) dayContainer.getChildAt(1);
|
||||
dayIv.setImageResource(R.drawable.ic_energy_center_signed);
|
||||
|
||||
if (i != 7) {
|
||||
int rIndex = (i - 1) * 2 + 1;
|
||||
LinearLayout lineContainer = (LinearLayout) binding.signDaysContainer.getChildAt(rIndex);
|
||||
View straightLine = lineContainer.getChildAt(0);
|
||||
View dottedLine = lineContainer.getChildAt(1);
|
||||
if (i != sevenDaySerialSign) {
|
||||
straightLine.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
dottedLine.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
dialog.setContentView(binding.getRoot());
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param context may be is application context
|
||||
* @return activity context
|
||||
@ -1935,4 +2249,7 @@ public class DialogUtils {
|
||||
void onResponse(boolean isSubscribe);
|
||||
}
|
||||
|
||||
public interface ReportReasonCallBack {
|
||||
void onResponse(String reason, String desc);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package com.gh.common.util
|
||||
|
||||
import android.content.ActivityNotFoundException
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
@ -24,11 +25,12 @@ import com.gh.gamecenter.*
|
||||
import com.gh.gamecenter.amway.AmwayActivity
|
||||
import com.gh.gamecenter.catalog.CatalogActivity
|
||||
import com.gh.gamecenter.category.CategoryDirectoryActivity
|
||||
import com.gh.gamecenter.category2.CategoryV2Activity
|
||||
import com.gh.gamecenter.download.DownloadFragment.Companion.INDEX_UPDATE
|
||||
import com.gh.gamecenter.entity.*
|
||||
import com.gh.gamecenter.eventbus.EBReuse
|
||||
import com.gh.gamecenter.eventbus.EBSkip
|
||||
import com.gh.gamecenter.forum.detail.ForumDetailActivity
|
||||
import com.gh.gamecenter.forum.home.CommunityHomeFragment
|
||||
import com.gh.gamecenter.fragment.MainWrapperFragment
|
||||
import com.gh.gamecenter.game.columncollection.detail.ColumnCollectionDetailActivity
|
||||
import com.gh.gamecenter.game.upload.GameSubmissionActivity
|
||||
@ -39,19 +41,25 @@ import com.gh.gamecenter.gamedetail.rating.RatingReplyActivity
|
||||
import com.gh.gamecenter.manager.UserManager
|
||||
import com.gh.gamecenter.mygame.PlayedGameActivity
|
||||
import com.gh.gamecenter.personalhome.UserHomeActivity
|
||||
import com.gh.gamecenter.qa.CommunityFragment
|
||||
import com.gh.gamecenter.qa.answer.detail.AnswerDetailActivity
|
||||
import com.gh.gamecenter.personalhome.background.PersonalityBackgroundActivity
|
||||
import com.gh.gamecenter.personalhome.border.AvatarBorderActivity
|
||||
import com.gh.gamecenter.personalhome.home.UserHistoryViewModel
|
||||
import com.gh.gamecenter.qa.answer.detail.SimpleAnswerDetailActivity
|
||||
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.qa.questions.newdetail.NewQuestionDetailActivity
|
||||
import com.gh.gamecenter.qa.subject.CommunitySubjectActivity
|
||||
import com.gh.gamecenter.qa.video.detail.ForumVideoDetailActivity
|
||||
import com.gh.gamecenter.retrofit.Response
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager
|
||||
import com.gh.gamecenter.security.BindPhoneActivity
|
||||
import com.gh.gamecenter.servers.GameServerTestActivity
|
||||
import com.gh.gamecenter.servers.GameServersActivity
|
||||
import com.gh.gamecenter.subject.SubjectActivity
|
||||
import com.gh.gamecenter.suggest.SuggestType
|
||||
import com.gh.gamecenter.tag.TagsActivity
|
||||
import com.gh.gamecenter.user.UserViewModel
|
||||
import com.gh.gamecenter.video.data.VideoDataActivity
|
||||
import com.gh.gamecenter.video.detail.VideoDetailActivity
|
||||
import com.gh.gamecenter.video.detail.VideoDetailContainerViewModel
|
||||
@ -204,6 +212,8 @@ object DirectUtils {
|
||||
|
||||
"catalog" -> directCatalog(context, linkEntity.link!!, linkEntity.text!!, entrance, path)
|
||||
|
||||
"category_v2" -> directCategoryV2(context, linkEntity.link!!, linkEntity.text!!, entrance, path)
|
||||
|
||||
"block", "版块" -> {
|
||||
if (linkEntity.link.isNullOrEmpty()) return
|
||||
directToBlock(context,
|
||||
@ -233,7 +243,7 @@ object DirectUtils {
|
||||
|
||||
"libao", "礼包" -> directToGiftDetail(context, linkEntity.link ?: "", entrance)
|
||||
|
||||
"feedback" -> directToFeedback(context, linkEntity.name, linkEntity.text, entrance)
|
||||
"feedback" -> directToFeedback(context, linkEntity.name, linkEntity.text, false, entrance)
|
||||
|
||||
"qa", "Q&A" -> directToQa(context, linkEntity.text ?: "", linkEntity.link ?: "")
|
||||
|
||||
@ -249,6 +259,71 @@ object DirectUtils {
|
||||
|
||||
"bbs_detail" -> directForumDetail(context, linkEntity.link ?: "", entrance)
|
||||
|
||||
"mobile_bind" -> {
|
||||
CheckLoginUtils.checkLogin(context, entrance) {
|
||||
context.startActivity(BindPhoneActivity.getNormalIntent(context, false))
|
||||
}
|
||||
}
|
||||
|
||||
"authentication" -> {
|
||||
CheckLoginUtils.checkLogin(context, entrance) {
|
||||
context.startActivity(UserInfoEditActivity.getIntent(context, UserViewModel.TYPE_ID_CARD))
|
||||
}
|
||||
}
|
||||
|
||||
"user_background" -> {
|
||||
CheckLoginUtils.checkLogin(context, entrance) {
|
||||
context.startActivity(PersonalityBackgroundActivity.getIntent(context))
|
||||
}
|
||||
}
|
||||
|
||||
"avatar_frame" -> {
|
||||
CheckLoginUtils.checkLogin(context, entrance) {
|
||||
context.startActivity(AvatarBorderActivity.getIntent(context))
|
||||
}
|
||||
}
|
||||
|
||||
"badge" -> {
|
||||
CheckLoginUtils.checkLogin(context, entrance) {
|
||||
UserManager.getInstance().userInfoEntity?.run {
|
||||
directToBadgeWall(context, userId, name, icon)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
"etiquette_exam" -> directToRegulationTestPage(context)
|
||||
|
||||
"setting" -> context.startActivity(SettingActivity.getIntent(context, false, entrance))
|
||||
|
||||
"index_page" -> directToHomeTab(context)
|
||||
|
||||
"video_upload" -> context.startActivity(VideoManagerActivity.getIntent(context, "", entrance))
|
||||
|
||||
"bbs" -> directToForum(context)
|
||||
|
||||
"user_page" -> directToHomeActivity(context, UserManager.getInstance().userId, "", entrance)
|
||||
|
||||
"video_tab" -> directToVideoTab(context)
|
||||
|
||||
"toolkit" -> context.startActivity(ToolBoxActivity.getIntent(context, entrance))
|
||||
|
||||
"column_test" -> context.startActivity(GameServerTestActivity.getIntent(context, linkEntity.link
|
||||
?: "", linkEntity.text ?: "", entrance))
|
||||
|
||||
"toolkit_detail" -> {
|
||||
linkEntity.toolkit?.run {
|
||||
if (url != null && url!!.contains(Config.URL_ARTICLE)) {
|
||||
val newsId = url!!.substring(url!!.lastIndexOf("/") + 1, url!!.length - 5) // 5: ".html"
|
||||
val intent = NewsDetailActivity.getIntentById(context, newsId, entrance)
|
||||
context.startActivity(intent)
|
||||
} else {
|
||||
context.startActivity(WebActivity.getWebByCollectionTools(context, this, false))
|
||||
}
|
||||
} ?: ""
|
||||
}
|
||||
|
||||
"halo_tab" -> directToPersonalTab(context)
|
||||
|
||||
//"h5_game_center" -> directLetoGameCenter(context)
|
||||
|
||||
"" -> {
|
||||
@ -258,7 +333,7 @@ object DirectUtils {
|
||||
if (unknownCallback != null) {
|
||||
unknownCallback.invoke()
|
||||
} else {
|
||||
DialogUtils.showLowVersionDialog(context)
|
||||
DialogHelper.showUpgradeDialog(context)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -357,6 +432,20 @@ object DirectUtils {
|
||||
jumpActivity(context, bundle)
|
||||
}
|
||||
|
||||
/**
|
||||
* 跳转到新闻详情
|
||||
*/
|
||||
@JvmStatic
|
||||
fun directToArticle(context: Context, id: String, hideUselessInfo: Boolean, entrance: String? = null) {
|
||||
if (id.isEmpty()) return
|
||||
val bundle = Bundle()
|
||||
bundle.putString(KEY_ENTRANCE, entrance ?: ENTRANCE_BROWSER)
|
||||
bundle.putString(KEY_TO, NewsDetailActivity::class.java.simpleName)
|
||||
bundle.putString(KEY_NEWSID, id)
|
||||
bundle.putBoolean(KEY_HIDE_USELESS_INFO, hideUselessInfo)
|
||||
jumpActivity(context, bundle)
|
||||
}
|
||||
|
||||
/**
|
||||
* 跳转至个人主页
|
||||
*/
|
||||
@ -367,19 +456,42 @@ object DirectUtils {
|
||||
|
||||
/**
|
||||
* 跳转至个人主页
|
||||
* @param position 定位到某个tab 0游戏评论 1问答 2视频
|
||||
* @param position 定位到某个tab 0游戏 1发布
|
||||
*/
|
||||
@JvmStatic
|
||||
fun directToHomeActivity(context: Context, userId: String?, position: Int, entrance: String? = null, path: String? = null) {
|
||||
fun directToHomeActivity(context: Context,
|
||||
userId: String?,
|
||||
position: Int,
|
||||
entrance: String? = null,
|
||||
path: String? = null) {
|
||||
directToHomeActivity(context, userId, "", position, entrance, path)
|
||||
}
|
||||
|
||||
/**
|
||||
* 跳转至个人主页
|
||||
* @param position 定位到某个tab 0游戏 1发布
|
||||
* @param type 类型
|
||||
*/
|
||||
@JvmStatic
|
||||
fun directToHomeActivity(context: Context,
|
||||
userId: String?,
|
||||
type: String = "",
|
||||
position: Int,
|
||||
entrance: String? = null,
|
||||
path: String? = null) {
|
||||
|
||||
IntegralLogHelper.log("view_homepage", "个人主页")
|
||||
val bundle = Bundle()
|
||||
bundle.putString(KEY_USER_ID, userId)
|
||||
bundle.putString(KEY_TO, UserHomeActivity::class.java.name)
|
||||
bundle.putString(KEY_ENTRANCE, BaseActivity.mergeEntranceAndPath(entrance, path))
|
||||
bundle.putString(KEY_PATH, path)
|
||||
bundle.putString(KEY_TYPE, UserHistoryViewModel.TYPE.fromValue(type).value)
|
||||
bundle.putInt(KEY_POSITION, position)
|
||||
jumpActivity(context, bundle)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 回到首页
|
||||
*/
|
||||
@ -472,21 +584,27 @@ object DirectUtils {
|
||||
// 反馈
|
||||
@JvmStatic
|
||||
fun directToFeedback(context: Context, content: String? = null, entrance: String? = null) {
|
||||
directToFeedback(context, content, null, entrance)
|
||||
directToFeedback(context, content, null, false, entrance)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun directToFeedback(context: Context, content: String? = null, hintType: String? = null, entrance: String? = null) {
|
||||
fun directToFeedback(context: Context, content: String? = null, hintType: String? = null, isQaFeedback: Boolean = false, entrance: String? = null) {
|
||||
val bundle = Bundle()
|
||||
bundle.putString(KEY_ENTRANCE, entrance ?: ENTRANCE_BROWSER)
|
||||
bundle.putString(KEY_TO, SuggestionActivity::class.java.simpleName)
|
||||
bundle.putString(KEY_CONTENT, content)
|
||||
if (TextUtils.isEmpty(hintType)) {
|
||||
bundle.putString(KEY_SUGGEST_HINT_TYPE, KEY_PLUGIN)
|
||||
if (isQaFeedback) {
|
||||
bundle.putBoolean(KEY_IS_QA_FEEDBACK, true)
|
||||
bundle.putSerializable(KEY_SUGGESTTYPE, SuggestType.normal)
|
||||
} else {
|
||||
bundle.putString(KEY_SUGGEST_HINT_TYPE, hintType)
|
||||
bundle.putString(KEY_CONTENT, content)
|
||||
bundle.putSerializable(KEY_SUGGESTTYPE, SuggestType.gameQuestion)
|
||||
if (TextUtils.isEmpty(hintType)) {
|
||||
bundle.putString(KEY_SUGGEST_HINT_TYPE, KEY_PLUGIN)
|
||||
} else {
|
||||
bundle.putString(KEY_SUGGEST_HINT_TYPE, hintType)
|
||||
}
|
||||
}
|
||||
bundle.putSerializable(KEY_SUGGESTTYPE, SuggestType.gameQuestion)
|
||||
|
||||
jumpActivity(context, bundle)
|
||||
}
|
||||
|
||||
@ -540,7 +658,7 @@ object DirectUtils {
|
||||
if (id.isEmpty()) return
|
||||
val bundle = Bundle()
|
||||
bundle.putString(KEY_ENTRANCE, entrance ?: ENTRANCE_BROWSER)
|
||||
bundle.putString(KEY_TO, AnswerDetailActivity::class.java.name)
|
||||
bundle.putString(KEY_TO, SimpleAnswerDetailActivity::class.java.name)
|
||||
bundle.putString(KEY_PATH, path)
|
||||
bundle.putString(KEY_ANSWER_ID, id)
|
||||
jumpActivity(context, bundle)
|
||||
@ -551,7 +669,7 @@ object DirectUtils {
|
||||
if (id.isEmpty()) return
|
||||
val bundle = Bundle()
|
||||
bundle.putString(KEY_ENTRANCE, entrance ?: ENTRANCE_BROWSER)
|
||||
bundle.putString(KEY_TO, QuestionsDetailActivity::class.java.name)
|
||||
bundle.putString(KEY_TO, NewQuestionDetailActivity::class.java.name)
|
||||
bundle.putString(KEY_PATH, path)
|
||||
bundle.putString(KEY_QUESTIONS_ID, id)
|
||||
jumpActivity(context, bundle)
|
||||
@ -562,7 +680,11 @@ object DirectUtils {
|
||||
if (url.isEmpty()) return
|
||||
val bundle = Bundle()
|
||||
bundle.putString(KEY_ENTRANCE, entrance ?: ENTRANCE_BROWSER)
|
||||
bundle.putString(KEY_TO, WebActivity::class.java.simpleName)
|
||||
if (url.contains("android_page_type=singleton")) {
|
||||
bundle.putString(KEY_TO, SingletonWebActivity::class.java.simpleName)
|
||||
} else {
|
||||
bundle.putString(KEY_TO, WebActivity::class.java.simpleName)
|
||||
}
|
||||
bundle.putString(EntranceUtils.KEY_URL, url)
|
||||
jumpActivity(context, bundle)
|
||||
}
|
||||
@ -578,12 +700,17 @@ object DirectUtils {
|
||||
|
||||
@JvmStatic
|
||||
fun directToExternalBrowser(context: Context, url: String) {
|
||||
if (url.isEmpty()) return
|
||||
val browserIntent = Intent(Intent.ACTION_VIEW, Uri.parse(Uri.decode(url)))
|
||||
if (context !is AppCompatActivity) {
|
||||
browserIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
try {
|
||||
if (url.isEmpty()) return
|
||||
val browserIntent = Intent(Intent.ACTION_VIEW, Uri.parse(Uri.decode(url)))
|
||||
if (context !is AppCompatActivity) {
|
||||
browserIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
}
|
||||
context.startActivity(browserIntent)
|
||||
} catch (e: ActivityNotFoundException) {
|
||||
e.printStackTrace()
|
||||
Utils.toast(context, "跳转地址无效")
|
||||
}
|
||||
context.startActivity(browserIntent)
|
||||
}
|
||||
|
||||
// 跳转 QQ,qqNumber 为空选择默认客服 QQ
|
||||
@ -653,37 +780,25 @@ object DirectUtils {
|
||||
}
|
||||
|
||||
/**
|
||||
* 切换到社区页面
|
||||
* 切换到社区页面(旧社区页面已经没有了,处理为跳转到论坛详情)
|
||||
*/
|
||||
@JvmStatic
|
||||
fun directToCommunity(context: Context, community: CommunityEntity?) {
|
||||
if (MainActivity::class.java.name != RunningUtils.getTopActivity(context)) {
|
||||
val intent = Intent(context, MainActivity::class.java)
|
||||
intent.flags = Intent.FLAG_ACTIVITY_CLEAR_TOP
|
||||
context.startActivity(intent)
|
||||
}
|
||||
UserManager.getInstance().setCommunityData(community)
|
||||
|
||||
// 这里换个线程操作是为了做一点延时
|
||||
AppExecutor.ioExecutor.execute {
|
||||
EventBus.getDefault().post(EBSkip(MainActivity.EB_SKIP_MAIN, MainWrapperFragment.INDEX_ASK))
|
||||
EventBus.getDefault().post(EBReuse(CommunityFragment.EB_RETRY_PAGE))
|
||||
}
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun directToCommunity(context: Context) {
|
||||
if (MainActivity::class.java.name != RunningUtils.getTopActivity(context)) {
|
||||
val intent = Intent(context, MainActivity::class.java)
|
||||
intent.flags = Intent.FLAG_ACTIVITY_CLEAR_TOP
|
||||
context.startActivity(intent)
|
||||
}
|
||||
|
||||
// 这里换个线程操作是为了做一点延时
|
||||
AppExecutor.ioExecutor.execute {
|
||||
EventBus.getDefault().post(EBSkip(MainActivity.EB_SKIP_MAIN, MainWrapperFragment.INDEX_ASK))
|
||||
EventBus.getDefault().post(EBReuse(CommunityFragment.EB_RETRY_PAGE))
|
||||
}
|
||||
// if (MainActivity::class.java.name != RunningUtils.getTopActivity(context)) {
|
||||
// val intent = Intent(context, MainActivity::class.java)
|
||||
// intent.flags = Intent.FLAG_ACTIVITY_CLEAR_TOP
|
||||
// context.startActivity(intent)
|
||||
//
|
||||
// UserManager.getInstance().setCommunityData(community)
|
||||
//
|
||||
// // 这里换个线程操作是为了做一点延时
|
||||
// AppExecutor.ioExecutor.execute {
|
||||
// EventBus.getDefault().post(EBSkip(MainActivity.EB_SKIP_MAIN, MainWrapperFragment.INDEX_BBS))
|
||||
// EventBus.getDefault().post(EBReuse(CommunityFragment.EB_RETRY_PAGE))
|
||||
// }
|
||||
// } else {
|
||||
directForumDetail(context, community?.id)
|
||||
// }
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
@ -724,16 +839,45 @@ object DirectUtils {
|
||||
jumpActivity(context, bundle)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun directToVideoDetail(context: Context, videoId: String,
|
||||
entrance: String? = null,
|
||||
path: String? = "") {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
||||
val bundle = Bundle()
|
||||
bundle.putString(KEY_ENTRANCE, entrance ?: ENTRANCE_BROWSER)
|
||||
bundle.putString(KEY_TO, ForumVideoDetailActivity::class.java.name)
|
||||
bundle.putString(KEY_VIDEO_ID, videoId);
|
||||
bundle.putString(KEY_PATH, path)
|
||||
jumpActivity(context, bundle)
|
||||
} else {
|
||||
DialogUtils.showLowSystemVersionDialog(context)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 跳转到旧视频页面
|
||||
* @param fromLocation 可见 [VideoDetailContainerViewModel.Location]
|
||||
*/
|
||||
@JvmStatic
|
||||
fun directToVideoDetail(context: Context, videoId: String, fromLocation: String, showComment: Boolean = false, gameId: String = "", entrance: String? = null,
|
||||
path: String? = "", referer: String = "", type: String = "", act: String = "", paginationType: String = "", fieldId: String = "", sectionName: String = "") {
|
||||
fun directToLegacyVideoDetail(context: Context,
|
||||
videoId: String,
|
||||
fromLocation: String,
|
||||
showComment: Boolean = false,
|
||||
gameId: String = "",
|
||||
entrance: String? = null,
|
||||
path: String? = "",
|
||||
referer: String = "",
|
||||
type: String = "",
|
||||
act: String = "",
|
||||
paginationType: String = "",
|
||||
fieldId: String = "",
|
||||
sectionName: String = "") {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
||||
val bundle = Bundle()
|
||||
bundle.putString(KEY_ENTRANCE, entrance ?: ENTRANCE_BROWSER)
|
||||
bundle.putString(KEY_TO, VideoDetailActivity::class.java.name)
|
||||
bundle.putString(KEY_VIDEO_ID, videoId);
|
||||
bundle.putString(KEY_PATH, path)
|
||||
bundle.putString(KEY_ID, videoId)
|
||||
bundle.putString(KEY_GAMEID, gameId)
|
||||
@ -753,7 +897,7 @@ object DirectUtils {
|
||||
|
||||
@JvmStatic
|
||||
fun directToVideoDetail(context: Context, videoId: String, fromLocation: String, showComment: Boolean = false, gameId: String = "", entrance: String? = null, path: String? = "", referer: String = "") {
|
||||
directToVideoDetail(context, videoId, fromLocation, showComment, gameId, entrance, path, referer, "", "")
|
||||
directToVideoDetail(context, videoId, entrance, path)
|
||||
}
|
||||
|
||||
/**
|
||||
@ -906,6 +1050,20 @@ object DirectUtils {
|
||||
jumpActivity(context, bundle)
|
||||
}
|
||||
|
||||
/**
|
||||
* 跳转新分类2.0
|
||||
*/
|
||||
@JvmStatic
|
||||
fun directCategoryV2(context: Context, categoryId: String, categoryTitle: String, entrance: String? = null, path: String? = "") {
|
||||
if (categoryId.isEmpty()) return
|
||||
val bundle = Bundle()
|
||||
bundle.putString(KEY_TO, CategoryV2Activity::class.java.name)
|
||||
bundle.putString(KEY_CATEGORY_ID, categoryId)
|
||||
bundle.putString(KEY_CATEGORY_TITLE, categoryTitle)
|
||||
bundle.putString(KEY_ENTRANCE, BaseActivity.mergeEntranceAndPath(entrance, path))
|
||||
jumpActivity(context, bundle)
|
||||
}
|
||||
|
||||
/**
|
||||
* 跳转到问题标签详情
|
||||
*/
|
||||
@ -1030,10 +1188,10 @@ object DirectUtils {
|
||||
}
|
||||
|
||||
/**
|
||||
* 到首页论坛 tab
|
||||
* 到首页-首页 tab
|
||||
*/
|
||||
@JvmStatic
|
||||
fun directToForum(context: Context) {
|
||||
fun directToHomeTab(context: Context) {
|
||||
if (RunningUtils.isRunning(context)
|
||||
&& MainActivity::class.java.name == RunningUtils.getBaseActivity(context)) {
|
||||
val intent = Intent(context, MainActivity::class.java)
|
||||
@ -1042,10 +1200,76 @@ object DirectUtils {
|
||||
|
||||
// 这里换个线程操作是为了做一点延时
|
||||
AppExecutor.ioExecutor.execute {
|
||||
EventBus.getDefault().post(EBSkip(MainActivity.EB_SKIP_MAIN, MainWrapperFragment.INDEX_ASK))
|
||||
EventBus.getDefault().post(EBSkip(MainActivity.EB_SKIP_MAIN, MainWrapperFragment.INDEX_HOME))
|
||||
}
|
||||
} else {
|
||||
jumpActivity(context, Bundle().apply { putInt(KEY_POSITION, MainWrapperFragment.INDEX_ASK) })
|
||||
jumpActivity(context, Bundle().apply { putInt(KEY_POSITION, MainWrapperFragment.INDEX_HOME) })
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 到首页-论坛 tab
|
||||
* @param position 论坛的子 tab 位置
|
||||
*/
|
||||
@JvmStatic
|
||||
fun directToForum(context: Context, position: Int = 0) {
|
||||
if (RunningUtils.isRunning(context)
|
||||
&& MainActivity::class.java.name == RunningUtils.getBaseActivity(context)) {
|
||||
val intent = Intent(context, MainActivity::class.java)
|
||||
intent.flags = Intent.FLAG_ACTIVITY_CLEAR_TOP
|
||||
context.startActivity(intent)
|
||||
|
||||
// 这里换个线程操作是为了做一点延时
|
||||
AppExecutor.ioExecutor.execute {
|
||||
EventBus.getDefault().post(EBSkip(MainActivity.EB_SKIP_MAIN, MainWrapperFragment.INDEX_BBS))
|
||||
EventBus.getDefault().post(EBSkip(CommunityHomeFragment.EB_TAB, position))
|
||||
}
|
||||
} else {
|
||||
jumpActivity(context, Bundle().apply {
|
||||
putInt(KEY_POSITION, MainWrapperFragment.INDEX_BBS)
|
||||
putInt(KEY_SUB_POSITION, position)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 到首页-视频 tab
|
||||
*/
|
||||
@JvmStatic
|
||||
fun directToVideoTab(context: Context) {
|
||||
if (RunningUtils.isRunning(context)
|
||||
&& MainActivity::class.java.name == RunningUtils.getBaseActivity(context)) {
|
||||
val intent = Intent(context, MainActivity::class.java)
|
||||
intent.flags = Intent.FLAG_ACTIVITY_CLEAR_TOP
|
||||
context.startActivity(intent)
|
||||
|
||||
// 这里换个线程操作是为了做一点延时
|
||||
AppExecutor.ioExecutor.execute {
|
||||
EventBus.getDefault().post(EBSkip(MainActivity.EB_SKIP_MAIN, MainWrapperFragment.INDEX_VIDEO))
|
||||
}
|
||||
} else {
|
||||
jumpActivity(context, Bundle().apply { putInt(KEY_POSITION, MainWrapperFragment.INDEX_VIDEO) })
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 到首页-我的光环 tab
|
||||
*/
|
||||
@JvmStatic
|
||||
fun directToPersonalTab(context: Context) {
|
||||
if (RunningUtils.isRunning(context)
|
||||
&& MainActivity::class.java.name == RunningUtils.getBaseActivity(context)) {
|
||||
val intent = Intent(context, MainActivity::class.java)
|
||||
intent.flags = Intent.FLAG_ACTIVITY_CLEAR_TOP
|
||||
context.startActivity(intent)
|
||||
|
||||
// 这里换个线程操作是为了做一点延时
|
||||
AppExecutor.ioExecutor.execute {
|
||||
EventBus.getDefault().post(EBSkip(MainActivity.EB_SKIP_MAIN, MainWrapperFragment.INDEX_PERSONAL))
|
||||
}
|
||||
} else {
|
||||
jumpActivity(context, Bundle().apply { putInt(KEY_POSITION, MainWrapperFragment.INDEX_PERSONAL) })
|
||||
}
|
||||
}
|
||||
|
||||
@ -1060,4 +1284,245 @@ object DirectUtils {
|
||||
bundle.putInt(BaseActivity_TabLayout.PAGE_INDEX, position)
|
||||
jumpActivity(context, bundle)
|
||||
}
|
||||
|
||||
/**
|
||||
* 跳转至商品详情
|
||||
*/
|
||||
@JvmStatic
|
||||
fun directToCommodityDetail(context: Context, commodityId: String) {
|
||||
var url: String = if ("internal" == BuildConfig.FLAVOR) {
|
||||
Constants.COMMODITY_DETAIL_ADDRESS_DEV
|
||||
} else {
|
||||
Constants.COMMODITY_DETAIL_ADDRESS
|
||||
}
|
||||
|
||||
url = String.format(Locale.CHINA, "%s&shopid=%s×tamp=%d", url, commodityId, (Date().time / 1000 / 1000.toFloat()).roundToInt())
|
||||
directToFullScreenWebPage(context, url, true)
|
||||
}
|
||||
|
||||
/**
|
||||
* 跳转至光能记录(默认跳到光能记录第一个Tab)
|
||||
*/
|
||||
@JvmStatic
|
||||
fun directToEnergyRecord(context: Context) {
|
||||
directToEnergyRecord(context, 0)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun directToEnergyRecord(context: Context, position: Int) {
|
||||
var url: String = if ("internal" == BuildConfig.FLAVOR) {
|
||||
Constants.ENERGY_RECORD_ADDRESS_DEV
|
||||
} else {
|
||||
Constants.ENERGY_RECORD_ADDRESS
|
||||
}
|
||||
|
||||
url = String.format(Locale.CHINA, "%s&position=%s×tamp=%d", url, position, (Date().time / 1000 / 1000.toFloat()).roundToInt())
|
||||
directToFullScreenWebPage(context, url, true)
|
||||
}
|
||||
|
||||
/**
|
||||
* 跳转至订单中心
|
||||
*/
|
||||
@JvmStatic
|
||||
fun directToOrderCenter(context: Context) {
|
||||
var url: String = if ("internal" == BuildConfig.FLAVOR) {
|
||||
Constants.ORDER_CENTER_ADDRESS_DEV
|
||||
} else {
|
||||
Constants.ORDER_CENTER_ADDRESS
|
||||
}
|
||||
directToFullScreenWebPage(context, url, true)
|
||||
}
|
||||
|
||||
/**
|
||||
* 跳转至订单详情
|
||||
*/
|
||||
@JvmStatic
|
||||
fun directToOrderDetail(context: Context, orderId: String) {
|
||||
var url: String = if ("internal" == BuildConfig.FLAVOR) {
|
||||
Constants.ORDER_DETAIL_ADDRESS_DEV
|
||||
} else {
|
||||
Constants.ORDER_DETAIL_ADDRESS
|
||||
}
|
||||
|
||||
url = String.format(Locale.CHINA, "%s&order_id=%s×tamp=%d", url, orderId, (Date().time / 1000 / 1000.toFloat()).roundToInt())
|
||||
directToFullScreenWebPage(context, url, true)
|
||||
}
|
||||
|
||||
/**
|
||||
* 跳转至邀请好友
|
||||
*/
|
||||
@JvmStatic
|
||||
fun directToInviteFriends(context: Context) {
|
||||
var url: String = if ("internal" == BuildConfig.FLAVOR) {
|
||||
Constants.INVITE_FRIENDS_ADDRESS_DEV
|
||||
} else {
|
||||
Constants.INVITE_FRIENDS_ADDRESS
|
||||
}
|
||||
directToFullScreenWebPage(context, url, true)
|
||||
}
|
||||
|
||||
/**
|
||||
* 跳转至等级页面
|
||||
*/
|
||||
@JvmStatic
|
||||
fun directToLevelPage(context: Context) {
|
||||
var url: String = if (isPublishEnv()) {
|
||||
Constants.LEVEL_ADDRESS
|
||||
} else {
|
||||
Constants.LEVEL_ADDRESS_DEV
|
||||
}
|
||||
|
||||
url = String.format(Locale.CHINA, "%s?timestamp=%d", url, (Date().time / 1000 / 1000.toFloat()).roundToInt())
|
||||
directToFullScreenWebPage(context, url, true)
|
||||
}
|
||||
|
||||
/**
|
||||
* 跳转至兑换规则
|
||||
*/
|
||||
@JvmStatic
|
||||
fun directToExchangeRulePage(context: Context) {
|
||||
var url: String = if (isPublishEnv()) {
|
||||
Constants.EXCHANGE_RULE_ADDRESS
|
||||
} else {
|
||||
Constants.EXCHANGE_RULE_ADDRESS_DEV
|
||||
}
|
||||
|
||||
url = String.format(Locale.CHINA, "%s×tamp=%d", url, (Date().time / 1000 / 1000.toFloat()).roundToInt())
|
||||
directToFullScreenWebPage(context, url, true)
|
||||
}
|
||||
|
||||
/**
|
||||
* 跳转至光能规则
|
||||
*/
|
||||
@JvmStatic
|
||||
fun directToEnergyRulePage(context: Context) {
|
||||
var url: String = if (isPublishEnv()) {
|
||||
Constants.ENERGY_RULE_ADDRESS
|
||||
} else {
|
||||
Constants.ENERGY_RULE_ADDRESS_DEV
|
||||
}
|
||||
|
||||
url = String.format(Locale.CHINA, "%s×tamp=%d", url, (Date().time / 1000 / 1000.toFloat()).roundToInt())
|
||||
directToFullScreenWebPage(context, url, true)
|
||||
}
|
||||
|
||||
/**
|
||||
* 跳转至兑换商品
|
||||
*/
|
||||
@JvmStatic
|
||||
fun directToExchangeCommodityPage(context: Context) {
|
||||
var url: String = if (isPublishEnv()) {
|
||||
Constants.EXCHANGE_COMMODITY_ADDRESS
|
||||
} else {
|
||||
Constants.EXCHANGE_COMMODITY_ADDRESS_DEV
|
||||
}
|
||||
|
||||
url = String.format(Locale.CHINA, "%s×tamp=%d", url, (Date().time / 1000 / 1000.toFloat()).roundToInt())
|
||||
directToFullScreenWebPage(context, url, true)
|
||||
}
|
||||
|
||||
/**
|
||||
* 跳转至抽奖乐园
|
||||
*/
|
||||
@JvmStatic
|
||||
fun directToLotteryParadisePage(context: Context) {
|
||||
var url: String = if (isPublishEnv()) {
|
||||
Constants.LOTTERY_PARADISE_ADDRESS
|
||||
} else {
|
||||
Constants.LOTTERY_PARADISE_ADDRESS_DEV
|
||||
}
|
||||
|
||||
url = String.format(Locale.CHINA, "%s×tamp=%d", url, (Date().time / 1000 / 1000.toFloat()).roundToInt())
|
||||
directToFullScreenWebPage(context, url, true)
|
||||
}
|
||||
|
||||
/**
|
||||
* 跳转至我的奖品
|
||||
*/
|
||||
@JvmStatic
|
||||
fun directToMyPrizePage(context: Context) {
|
||||
var url: String = if (isPublishEnv()) {
|
||||
Constants.MY_PRIZE_ADDRESS
|
||||
} else {
|
||||
Constants.MY_PRIZE_ADDRESS_DEV
|
||||
}
|
||||
|
||||
url = String.format(Locale.CHINA, "%s×tamp=%d", url, (Date().time / 1000 / 1000.toFloat()).roundToInt())
|
||||
directToFullScreenWebPage(context, url, true)
|
||||
}
|
||||
|
||||
/**
|
||||
* 跳转至中奖订单详情
|
||||
*/
|
||||
@JvmStatic
|
||||
fun directToWinOrderDetail(context: Context, orderId: String, activityId: String) {
|
||||
var url: String = if (isPublishEnv()) {
|
||||
Constants.WIN_ORDER_DETAIL_ADDRESS
|
||||
} else {
|
||||
Constants.WIN_ORDER_DETAIL_ADDRESS_DEV
|
||||
}
|
||||
|
||||
url = String.format(Locale.CHINA, "%s&order_id=%s&activity_id=%s×tamp=%d", url, orderId, activityId, (Date().time / 1000 / 1000.toFloat()).roundToInt())
|
||||
directToFullScreenWebPage(context, url, true)
|
||||
}
|
||||
|
||||
/**
|
||||
* 跳转至地址信息
|
||||
*/
|
||||
@JvmStatic
|
||||
fun directToAddressInfo(context: Context) {
|
||||
var url: String = if (isPublishEnv()) {
|
||||
Constants.ADDRESS_INFO_ADDRESS
|
||||
} else {
|
||||
Constants.ADDRESS_INFO_ADDRESS_DEV
|
||||
}
|
||||
|
||||
url = String.format(Locale.CHINA, "%s×tamp=%d", url, (Date().time / 1000 / 1000.toFloat()).roundToInt())
|
||||
directToFullScreenWebPage(context, url, true)
|
||||
}
|
||||
|
||||
/**
|
||||
* 跳转至领奖信息
|
||||
*/
|
||||
@JvmStatic
|
||||
fun directToPrizeInfo(context: Context) {
|
||||
var url: String = if (isPublishEnv()) {
|
||||
Constants.PRIZE_INFO_ADDRESS
|
||||
} else {
|
||||
Constants.PRIZE_INFO_ADDRESS_DEV
|
||||
}
|
||||
|
||||
url = String.format(Locale.CHINA, "%s×tamp=%d", url, (Date().time / 1000 / 1000.toFloat()).roundToInt())
|
||||
directToFullScreenWebPage(context, url, true)
|
||||
}
|
||||
|
||||
/**
|
||||
* 跳转至提现信息
|
||||
*/
|
||||
@JvmStatic
|
||||
fun directToWithdrawInfo(context: Context) {
|
||||
var url: String = if (isPublishEnv()) {
|
||||
Constants.WITHDRAW_INFO_ADDRESS
|
||||
} else {
|
||||
Constants.WITHDRAW_INFO_ADDRESS_DEV
|
||||
}
|
||||
|
||||
url = String.format(Locale.CHINA, "%s×tamp=%d", url, (Date().time / 1000 / 1000.toFloat()).roundToInt())
|
||||
directToFullScreenWebPage(context, url, true)
|
||||
}
|
||||
|
||||
/**
|
||||
* 跳转至活动详情
|
||||
*/
|
||||
@JvmStatic
|
||||
fun directToActivityDetail(context: Context, activityId: String, categoryId: String, entrance: String) {
|
||||
var url: String = if (isPublishEnv()) {
|
||||
Constants.ACTIVITY_DETAIL_ADDRESS
|
||||
} else {
|
||||
Constants.ACTIVITY_DETAIL_ADDRESS_DEV
|
||||
}
|
||||
|
||||
url = String.format(Locale.CHINA, "%s&id=%s&category_id=%s×tamp=%d", url, activityId, categoryId, (Date().time / 1000 / 1000.toFloat()).roundToInt())
|
||||
directToWebView(context, url, entrance)
|
||||
}
|
||||
}
|
||||
@ -240,6 +240,18 @@ public class DisplayUtils {
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
public static void hideNavigationBar(Activity activity) {
|
||||
Window window = activity.getWindow();
|
||||
View decorView = window.getDecorView();
|
||||
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN && Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) { // lower api
|
||||
decorView.setSystemUiVisibility(View.GONE);
|
||||
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
||||
int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
|
||||
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY | View.SYSTEM_UI_FLAG_FULLSCREEN;
|
||||
decorView.setSystemUiVisibility(uiOptions);
|
||||
}
|
||||
}
|
||||
|
||||
public static int retrieveNavigationHeight(Context context) {
|
||||
Resources resources = context.getResources();
|
||||
int resourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android");
|
||||
|
||||
@ -21,67 +21,74 @@ object DownloadDialogHelper {
|
||||
}
|
||||
|
||||
private fun retrieveAvailableDialog(gameEntity: GameEntity, apkEntity: ApkEntity): GameEntity.Dialog? {
|
||||
if (gameEntity.downloadDialog.isNullOrEmpty()) return null
|
||||
val downloadDialog = if (gameEntity.shouldUseMirrorInfo()) {
|
||||
gameEntity.mirrorData?.downloadDialog
|
||||
} else {
|
||||
gameEntity.downloadDialog
|
||||
}
|
||||
|
||||
for (dialog in gameEntity.downloadDialog!!) {
|
||||
if (downloadDialog.isNullOrEmpty()) return null
|
||||
for (dialog in downloadDialog) {
|
||||
val versionName = PackageUtils.getVersionName()
|
||||
val noticeVersions = dialog.rule.noticeVersions
|
||||
if (noticeVersions.isEmpty() || noticeVersions.contains(versionName)) {
|
||||
// 共有 8 种可能
|
||||
// 1. 不指定包名、机型和系统版本
|
||||
if (dialog.rule.packageName.isEmpty()
|
||||
&& dialog.rule.models.isEmpty()
|
||||
&& dialog.rule.systemVersions.isEmpty()) {
|
||||
return dialog
|
||||
}
|
||||
|
||||
// 共有 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
|
||||
}
|
||||
|
||||
// 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
|
||||
}
|
||||
|
||||
// 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
|
||||
}
|
||||
|
||||
// 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
|
||||
}
|
||||
|
||||
// 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
|
||||
}
|
||||
|
||||
// 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
|
||||
}
|
||||
// 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
|
||||
}
|
||||
} else return null
|
||||
}
|
||||
|
||||
return null
|
||||
|
||||
@ -28,6 +28,7 @@ import com.gh.common.xapk.XapkInstaller;
|
||||
import com.gh.common.xapk.XapkUnzipStatus;
|
||||
import com.gh.download.DownloadManager;
|
||||
import com.gh.download.dialog.DownloadDialog;
|
||||
import com.gh.download.server.BrowserInstallHelper;
|
||||
import com.gh.gamecenter.DownloadManagerActivity;
|
||||
import com.gh.gamecenter.R;
|
||||
import com.gh.gamecenter.WebActivity;
|
||||
@ -36,6 +37,7 @@ import com.gh.gamecenter.entity.ApkEntity;
|
||||
import com.gh.gamecenter.entity.GameEntity;
|
||||
import com.gh.gamecenter.entity.LinkEntity;
|
||||
import com.gh.gamecenter.entity.PluginLocation;
|
||||
import com.gh.gamecenter.gamedetail.dialog.GamePermissionDialogFragment;
|
||||
import com.gh.gamecenter.manager.PackagesManager;
|
||||
import com.lightgame.download.DownloadConfig;
|
||||
import com.lightgame.download.DownloadEntity;
|
||||
@ -125,16 +127,18 @@ public class DownloadItemUtils {
|
||||
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));
|
||||
// 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));
|
||||
updateItem(holder.gameDes.getContext(), gameEntity, holder, false);
|
||||
} 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);
|
||||
holder.gameDownloadBtn.setTextColor(ContextCompat.getColor(holder.gameDes.getContext(), R.color.aaaaaa));
|
||||
holder.gameDownloadBtn.setBackgroundResource(R.drawable.button_round_f5f5f5);
|
||||
updateItemViewStatus(holder, false, null, null);
|
||||
}
|
||||
}
|
||||
|
||||
@ -167,7 +171,7 @@ public class DownloadItemUtils {
|
||||
|
||||
// 显示预约
|
||||
if (gameEntity.isReservable()) {
|
||||
updateItemViewStatus(holder, false, briefStyle);
|
||||
updateItemViewStatus(holder, false, briefStyle, gameEntity.getColumnRecommend());
|
||||
if (!ReservationRepository.thisGameHasBeenReserved(gameEntity.getId())) {
|
||||
holder.gameDownloadBtn.setText("预约");
|
||||
holder.gameDownloadBtn.setTextColor(Color.WHITE);
|
||||
@ -185,7 +189,7 @@ public class DownloadItemUtils {
|
||||
LinkEntity h5LinkEntity = gameEntity.getH5Link();
|
||||
String offStatus = gameEntity.getDownloadOffStatus();
|
||||
|
||||
updateItemViewStatus(holder, false, briefStyle);
|
||||
updateItemViewStatus(holder, false, briefStyle, gameEntity.getColumnRecommend());
|
||||
|
||||
if (h5LinkEntity != null) {
|
||||
if ("play".equals(h5LinkEntity.getType())) {
|
||||
@ -248,7 +252,7 @@ public class DownloadItemUtils {
|
||||
|
||||
GameUtils.setDownloadBtnStatus(context, gameEntity, holder.gameDownloadBtn, pluginLocation);
|
||||
|
||||
updateItemViewStatus(holder, false, briefStyle);
|
||||
updateItemViewStatus(holder, false, briefStyle, gameEntity.getColumnRecommend());
|
||||
}
|
||||
|
||||
// 更新插件的条目,有多个apk包
|
||||
@ -272,14 +276,14 @@ public class DownloadItemUtils {
|
||||
return;
|
||||
}
|
||||
}
|
||||
updateItemViewStatus(holder, false, briefStyle);
|
||||
updateItemViewStatus(holder, false, briefStyle, gameEntity.getColumnRecommend());
|
||||
}
|
||||
|
||||
// 更改进度条和提示文本的状态
|
||||
public static void changeStatus(Context context, GameViewHolder holder, DownloadEntity downloadEntity,
|
||||
boolean isShowPlatform, boolean isNormal) {
|
||||
|
||||
updateItemViewStatus(holder, true, null);
|
||||
updateItemViewStatus(holder, true, null, null);
|
||||
holder.gameProgressbar.setProgressDrawable(context.getResources().getDrawable(R.drawable.progressbar_bg_style));
|
||||
|
||||
String platform = PlatformUtils.getInstance(context).getPlatformName(downloadEntity.getPlatform());
|
||||
@ -373,22 +377,59 @@ public class DownloadItemUtils {
|
||||
}
|
||||
}
|
||||
|
||||
private static void updateItemViewStatus(GameViewHolder holder, boolean hasDownload, @Nullable String briefStyle) {
|
||||
private static void updateItemViewStatus(GameViewHolder holder,
|
||||
boolean hasDownload,
|
||||
@Nullable String briefStyle,
|
||||
@Nullable LinkEntity recommendStyle) {
|
||||
if (hasDownload) {
|
||||
if (holder.gameRating != null) holder.gameRating.setVisibility(View.GONE);
|
||||
holder.gameDes.setVisibility(View.GONE);
|
||||
holder.gameProgressbar.setVisibility(View.VISIBLE);
|
||||
holder.gameInfo.setVisibility(View.VISIBLE);
|
||||
if (holder.recommendContainer != null) {
|
||||
holder.recommendContainer.setVisibility(View.GONE);
|
||||
}
|
||||
} else {
|
||||
holder.gameProgressbar.setVisibility(View.GONE);
|
||||
holder.gameInfo.setVisibility(View.GONE);
|
||||
|
||||
// 推荐优先,有推荐内容时不执行下面的 star 和 brief 代码块
|
||||
if (briefStyle != null
|
||||
&& recommendStyle != null
|
||||
&& briefStyle.contains("recommend")) {
|
||||
if (holder.recommendContainer != null) {
|
||||
holder.recommendContainer.setVisibility(View.VISIBLE);
|
||||
}
|
||||
if (holder.gameRating != null) holder.gameRating.setVisibility(View.GONE);
|
||||
holder.gameDes.setVisibility(View.GONE);
|
||||
|
||||
holder.recommendTv.setText(recommendStyle.getText());
|
||||
if ("none".equals(recommendStyle.getType())) {
|
||||
holder.recommendIv.setVisibility(View.GONE);
|
||||
} else {
|
||||
Context context = holder.recommendContainer.getContext();
|
||||
int drawableId = context.getResources().getIdentifier(
|
||||
"ic_recommend_" + recommendStyle.getType(),
|
||||
"drawable",
|
||||
context.getPackageName());
|
||||
holder.recommendIv.setVisibility(View.VISIBLE);
|
||||
holder.recommendIv.setImageResource(drawableId);
|
||||
}
|
||||
return;
|
||||
} else {
|
||||
if (holder.recommendContainer != null) {
|
||||
holder.recommendContainer.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
if (briefStyle != null && briefStyle.contains("star")) {
|
||||
if (holder.gameRating != null) holder.gameRating.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
if (holder.gameRating != null) holder.gameRating.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
if (TextUtils.isEmpty(briefStyle) || briefStyle.contains("brief")) {
|
||||
// 缺省情况下回落到游戏简介
|
||||
if (TextUtils.isEmpty(briefStyle) || briefStyle.contains("brief") || briefStyle.contains("recommend")) {
|
||||
holder.gameDes.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
holder.gameDes.setVisibility(View.GONE);
|
||||
@ -432,7 +473,7 @@ public class DownloadItemUtils {
|
||||
final ExposureEvent traceEvent,
|
||||
@Nullable final EmptyCallback clickCallback) {
|
||||
|
||||
setOnClickListener(context, downloadBtn, gameEntity, position, adapter, entrance, location, traceEvent, clickCallback, null);
|
||||
setOnClickListener(context, downloadBtn, gameEntity, position, adapter, entrance, location, traceEvent, clickCallback, null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -447,6 +488,7 @@ public class DownloadItemUtils {
|
||||
final String location,
|
||||
final ExposureEvent traceEvent,
|
||||
@Nullable final EmptyCallback clickCallback,
|
||||
@Nullable final EmptyCallback refreshCallback,
|
||||
@Nullable final EmptyCallback allStateClickCallback) {
|
||||
|
||||
if (gameEntity.isReservable()) {
|
||||
@ -464,7 +506,12 @@ public class DownloadItemUtils {
|
||||
gameEntity,
|
||||
() -> {
|
||||
LogUtils.logReservation(gameEntity, traceEvent);
|
||||
adapter.notifyItemChanged(position);
|
||||
if (adapter != null) {
|
||||
adapter.notifyItemChanged(position);
|
||||
}
|
||||
if (refreshCallback != null) {
|
||||
refreshCallback.onCallback();
|
||||
}
|
||||
}
|
||||
);
|
||||
dialogFragment.show(((AppCompatActivity) context).getSupportFragmentManager(), "reserve");
|
||||
@ -482,13 +529,23 @@ public class DownloadItemUtils {
|
||||
if ("download".equals(gameEntity.getReserveStatus())) {
|
||||
ReservationHelper.showDeleteReservationDialog(context, () -> {
|
||||
ReservationHelper.deleteReservation(gameEntity, () -> {
|
||||
adapter.notifyItemChanged(position);
|
||||
if (adapter != null) {
|
||||
adapter.notifyItemChanged(position);
|
||||
}
|
||||
if (refreshCallback != null) {
|
||||
refreshCallback.onCallback();
|
||||
}
|
||||
});
|
||||
});
|
||||
} else {
|
||||
ReservationHelper.showCancelReservationDialog(context, () -> {
|
||||
ReservationHelper.cancelReservation(gameEntity, () -> {
|
||||
adapter.notifyItemChanged(position);
|
||||
if (adapter != null) {
|
||||
adapter.notifyItemChanged(position);
|
||||
}
|
||||
if (refreshCallback != null) {
|
||||
refreshCallback.onCallback();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
@ -525,7 +582,7 @@ public class DownloadItemUtils {
|
||||
if (clickCallback != null) {
|
||||
clickCallback.onCallback();
|
||||
}
|
||||
onNormalClick(context, downloadBtn, gameEntity, position, adapter, entrance, location, traceEvent);
|
||||
onNormalClick(context, downloadBtn, gameEntity, position, adapter, entrance, location, traceEvent, refreshCallback);
|
||||
};
|
||||
|
||||
// 启动不需要请求存储权限
|
||||
@ -544,15 +601,19 @@ public class DownloadItemUtils {
|
||||
if (clickCallback != null) {
|
||||
clickCallback.onCallback();
|
||||
}
|
||||
PermissionHelper.checkStoragePermissionBeforeAction(context, () -> {
|
||||
CertificationDialog.showCertificationDialog(context, gameEntity, () -> {
|
||||
DialogUtils.showVersionNumberDialog(context, gameEntity, () -> {
|
||||
DownloadDialog.showDownloadDialog(
|
||||
v.getContext(),
|
||||
gameEntity,
|
||||
traceEvent,
|
||||
entrance,
|
||||
location);
|
||||
RealNameHelper.checkIfAuth(v.getContext(), gameEntity, () -> {
|
||||
GamePermissionDialogFragment.show((AppCompatActivity) context, gameEntity, gameEntity.getInfo(), () -> {
|
||||
PermissionHelper.checkStoragePermissionBeforeAction(context, () -> {
|
||||
CertificationDialog.showCertificationDialog(context, gameEntity, () -> {
|
||||
DialogUtils.showVersionNumberDialog(context, gameEntity, () -> {
|
||||
DownloadDialog.showDownloadDialog(
|
||||
v.getContext(),
|
||||
gameEntity,
|
||||
traceEvent,
|
||||
entrance,
|
||||
location);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
@ -567,7 +628,7 @@ public class DownloadItemUtils {
|
||||
final RecyclerView.Adapter<? extends RecyclerView.ViewHolder> adapter,
|
||||
final String entrance,
|
||||
final String location) {
|
||||
onNormalClick(context, downloadBtn, gameEntity, position, adapter, entrance, location, null);
|
||||
onNormalClick(context, downloadBtn, gameEntity, position, adapter, entrance, location, null, null);
|
||||
}
|
||||
|
||||
public static void onNormalClick(final Context context,
|
||||
@ -577,18 +638,27 @@ public class DownloadItemUtils {
|
||||
final RecyclerView.Adapter<? extends RecyclerView.ViewHolder> adapter,
|
||||
final String entrance,
|
||||
final String location,
|
||||
@Nullable final ExposureEvent traceEvent) {
|
||||
@Nullable final ExposureEvent traceEvent,
|
||||
@Nullable final EmptyCallback refreshCallback) {
|
||||
String str = downloadBtn.getText().toString();
|
||||
ApkEntity apk = gameEntity.getApk().get(0);
|
||||
if (gameEntity.getApk().isEmpty()) return;
|
||||
ApkEntity apk = ExtensionsKt.safelyGetInRelease(gameEntity.getApk(), 0);
|
||||
if (apk == null) return;
|
||||
|
||||
if (str.equals(context.getString(R.string.download))) {
|
||||
// 先弹下载弹窗(如果需要的话)
|
||||
PackageCheckDialogFragment.show((AppCompatActivity) context, gameEntity.getPackageDialog(), () -> {
|
||||
DownloadDialogHelper.findAvailableDialogAndShow(context, gameEntity, apk, () -> {
|
||||
CertificationDialog.showCertificationDialog(context, gameEntity, () -> {
|
||||
DialogUtils.showOverseaDownloadDialog(context, gameEntity, () -> {
|
||||
DialogUtils.checkDownload(context, apk.getSize(),
|
||||
isSubscribe -> download(context, gameEntity, downloadBtn, entrance, location, isSubscribe, traceEvent));
|
||||
RealNameHelper.checkIfAuth(context, gameEntity, () -> {
|
||||
GamePermissionDialogFragment.show((AppCompatActivity) context, gameEntity, gameEntity.getInfo(), () -> {
|
||||
BrowserInstallHelper.showBrowserInstallHintDialog(context, () -> {
|
||||
PackageCheckDialogFragment.show((AppCompatActivity) context, gameEntity, () -> {
|
||||
DownloadDialogHelper.findAvailableDialogAndShow(context, gameEntity, apk, () -> {
|
||||
CertificationDialog.showCertificationDialog(context, gameEntity, () -> {
|
||||
DialogUtils.showOverseaDownloadDialog(context, gameEntity, () -> {
|
||||
DialogUtils.checkDownload(context, apk.getSize(),
|
||||
isSubscribe -> download(context, gameEntity, downloadBtn, entrance, location, isSubscribe, traceEvent));
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
@ -596,13 +666,19 @@ public class DownloadItemUtils {
|
||||
|
||||
DataLogUtils.uploadGameLog(context, gameEntity.getId(), gameEntity.getName(), entrance);
|
||||
} else if (str.equals(context.getString(R.string.attempt))) {
|
||||
PackageCheckDialogFragment.show((AppCompatActivity) context, gameEntity.getPackageDialog(), () -> {
|
||||
DownloadDialogHelper.findAvailableDialogAndShow(context, gameEntity, apk, () -> {
|
||||
CertificationDialog.showCertificationDialog(context, gameEntity, () -> {
|
||||
DialogUtils.showVersionNumberDialog(context, gameEntity, () -> {
|
||||
DialogUtils.showOverseaDownloadDialog(context, gameEntity, () -> {
|
||||
DialogUtils.checkDownload(context, apk.getSize(),
|
||||
isSubscribe -> download(context, gameEntity, downloadBtn, entrance, location, isSubscribe, traceEvent));
|
||||
RealNameHelper.checkIfAuth(context, gameEntity, () -> {
|
||||
GamePermissionDialogFragment.show((AppCompatActivity) context, gameEntity, gameEntity.getInfo(), () -> {
|
||||
BrowserInstallHelper.showBrowserInstallHintDialog(context, () -> {
|
||||
PackageCheckDialogFragment.show((AppCompatActivity) context, gameEntity, () -> {
|
||||
DownloadDialogHelper.findAvailableDialogAndShow(context, gameEntity, apk, () -> {
|
||||
CertificationDialog.showCertificationDialog(context, gameEntity, () -> {
|
||||
DialogUtils.showVersionNumberDialog(context, gameEntity, () -> {
|
||||
DialogUtils.showOverseaDownloadDialog(context, gameEntity, () -> {
|
||||
DialogUtils.checkDownload(context, apk.getSize(),
|
||||
isSubscribe -> download(context, gameEntity, downloadBtn, entrance, location, isSubscribe, traceEvent));
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
@ -634,7 +710,7 @@ public class DownloadItemUtils {
|
||||
return;
|
||||
}
|
||||
}
|
||||
install(context, gameEntity, position, adapter);
|
||||
install(context, gameEntity, position, adapter, refreshCallback);
|
||||
} else if (str.equals(context.getString(R.string.launch))) {
|
||||
//启动模拟器游戏
|
||||
if (SimulatorGameManager.isSimulatorGame(gameEntity)) {
|
||||
@ -654,6 +730,8 @@ public class DownloadItemUtils {
|
||||
}
|
||||
DataUtils.onGameLaunchEvent(context, gameEntity.getName(), gameEntity.getApk().get(0).getPlatform(), location);
|
||||
PackageUtils.launchApplicationByPackageName(context, gameEntity.getApk().get(0).getPackageName());
|
||||
|
||||
EnergyTaskHelper.postEnergyTask("play_game", gameEntity.getId(), gameEntity.getApk().get(0).getPackageName());
|
||||
} else if (str.equals(context.getString(R.string.update))) {
|
||||
if (entrance.contains("我的游戏")) {
|
||||
MtaHelper.onEvent("我的游戏_启动", "更新", gameEntity.getName());
|
||||
@ -666,6 +744,7 @@ public class DownloadItemUtils {
|
||||
context.startActivity(DownloadManagerActivity.getDownloadMangerIntent(context,
|
||||
apk.getUrl(), entrance + "+(" + location.split(":")[0] + ")"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//下载
|
||||
@ -712,7 +791,7 @@ public class DownloadItemUtils {
|
||||
|
||||
//安装
|
||||
private static void install(final Context context, GameEntity gameEntity, int position,
|
||||
RecyclerView.Adapter<? extends RecyclerView.ViewHolder> adapter) {
|
||||
RecyclerView.Adapter<? extends RecyclerView.ViewHolder> adapter, @Nullable final EmptyCallback refreshCallback) {
|
||||
ApkEntity apkEntity = gameEntity.getApk().get(0);
|
||||
DownloadEntity downloadEntity = DownloadManager.getInstance(context).getDownloadEntityByUrl(apkEntity.getUrl());
|
||||
if (downloadEntity != null) {
|
||||
@ -723,9 +802,17 @@ public class DownloadItemUtils {
|
||||
if (gameEntity.getEntryMap() != null) {
|
||||
gameEntity.getEntryMap().remove(apkEntity.getPlatform());
|
||||
}
|
||||
adapter.notifyItemChanged(position);
|
||||
if (adapter != null) {
|
||||
adapter.notifyItemChanged(position);
|
||||
}
|
||||
if (refreshCallback != null) {
|
||||
refreshCallback.onCallback();
|
||||
}
|
||||
} else if (PackageUtils.isCanPluggable(apkEntity)) {
|
||||
DialogUtils.showPluginDialog(context, () -> PackageInstaller.uninstall(context, path));
|
||||
DialogHelper.showPluginDialog(context, () -> {
|
||||
PackageInstaller.uninstall(context, path);
|
||||
return null;
|
||||
});
|
||||
} else {
|
||||
PackageInstaller.install(context, downloadEntity);
|
||||
}
|
||||
|
||||
@ -8,6 +8,7 @@ import com.gh.common.exposure.ExposureUtils
|
||||
import com.gh.common.exposure.meta.MetaUtil
|
||||
import com.gh.common.simulator.SimulatorDownloadManager
|
||||
import com.gh.common.simulator.SimulatorGameManager
|
||||
import com.gh.common.util.EnergyTaskHelper.postEnergyTask
|
||||
import com.gh.common.xapk.XapkInstaller
|
||||
import com.gh.download.DownloadDataHelper
|
||||
import com.gh.download.DownloadManager
|
||||
@ -16,13 +17,14 @@ import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.SuggestionActivity
|
||||
import com.gh.gamecenter.entity.GameEntity
|
||||
import com.gh.gamecenter.entity.SimpleGameEntity
|
||||
import com.gh.gamecenter.entity.SimulatorEntity
|
||||
import com.gh.gamecenter.eventbus.EBDownloadStatus
|
||||
import com.gh.gamecenter.eventbus.EBShowDialog
|
||||
import com.gh.gamecenter.retrofit.Response
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager
|
||||
import com.gh.gamecenter.setting.GameDownloadSettingFragment.Companion.AUTO_INSTALL_SP_KEY
|
||||
import com.gh.gamecenter.suggest.SuggestType
|
||||
import com.halo.assistant.HaloApp
|
||||
import com.halo.assistant.fragment.SettingsFragment
|
||||
import com.lightgame.download.DataWatcher
|
||||
import com.lightgame.download.DownloadEntity
|
||||
import com.lightgame.download.DownloadStatus
|
||||
@ -50,7 +52,7 @@ object DownloadObserver {
|
||||
val xapkStatus = downloadEntity.meta[XapkInstaller.XAPK_UNZIP_STATUS]
|
||||
if (!xapkStatus.isNullOrEmpty()) return
|
||||
|
||||
val gameId = downloadEntity.getRealGameId(Constants.GAME_ID_DIVIDER)
|
||||
val gameId = downloadEntity.gameId
|
||||
val downloadManager = DownloadManager.getInstance(HaloApp.getInstance().application)
|
||||
|
||||
tryCatchInRelease {
|
||||
@ -111,6 +113,7 @@ object DownloadObserver {
|
||||
}
|
||||
if (DownloadStatus.done == downloadEntity.status) {
|
||||
if (downloadEntity.name.contains(mApplication.getString(R.string.app_name))) {
|
||||
statDoneEvent(downloadEntity)
|
||||
MtaHelper.onEvent("软件更新", "下载完成")
|
||||
// 会有 ActivityNotFoundException 异常,catch 掉不管了
|
||||
tryWithDefaultCatch {
|
||||
@ -124,10 +127,12 @@ object DownloadObserver {
|
||||
} else {
|
||||
statDoneEvent(downloadEntity)
|
||||
|
||||
postEnergyTask("download_game", downloadEntity.gameId, downloadEntity.packageName)
|
||||
val platform = PlatformUtils.getInstance(mApplication)
|
||||
.getPlatformName(downloadEntity.platform)
|
||||
if (platform != null) {
|
||||
when {
|
||||
// TODO 插件化传 path 从 apk 中获取 packageName 的形式有可能出现拿不到 packageName 的情况
|
||||
downloadEntity.isPluggable -> // 弹出插件化提示框
|
||||
EventBus.getDefault().post(EBShowDialog(BaseActivity.PLUGGABLE, downloadEntity.path))
|
||||
downloadEntity.isPlugin -> Utils.toast(mApplication, downloadEntity.name + " - " + platform + " - 下载完成")
|
||||
@ -138,23 +143,24 @@ object DownloadObserver {
|
||||
}
|
||||
if (!downloadEntity.isPluggable) {
|
||||
if (downloadEntity.isSimulatorGame()) {
|
||||
val gameEntity = HaloApp.get(GameEntity::class.java.simpleName, true) as? GameEntity
|
||||
if (gameEntity?.simulator != null) {
|
||||
val isInstalled = PackageUtils.isInstalledFromAllPackage(HaloApp.getInstance().application, gameEntity.simulator!!.apk!!.packageName)
|
||||
if (!isInstalled) {
|
||||
val currentActivity = AppManager.getInstance().currentActivity() ?: return
|
||||
val simulatorJson = downloadEntity.getMetaExtra(Constants.SIMULATOR)
|
||||
val gameName = downloadEntity.getMetaExtra(Constants.GAME_NAME)
|
||||
if (simulatorJson.isEmpty()) return
|
||||
val simulator = GsonUtils.fromJson(simulatorJson, SimulatorEntity::class.java)
|
||||
val isInstalled = PackageUtils.isInstalledFromAllPackage(HaloApp.getInstance().application, simulator.apk?.packageName)
|
||||
if (!isInstalled) {
|
||||
val currentActivity = AppManager.getInstance().currentActivity()
|
||||
?: return
|
||||
|
||||
SimulatorDownloadManager.getInstance().showDownloadDialog(currentActivity, gameEntity.simulator,
|
||||
SimulatorDownloadManager.SimulatorLocation.LAUNCH, gameEntity.id, gameEntity.name
|
||||
?: "", null)
|
||||
}
|
||||
SimulatorGameManager.recordDownloadSimulatorGames(gameEntity.id)
|
||||
SimulatorGameManager.postPlayedGame(gameEntity.id, downloadEntity.packageName)
|
||||
SimulatorDownloadManager.getInstance().showDownloadDialog(currentActivity, simulator,
|
||||
SimulatorDownloadManager.SimulatorLocation.LAUNCH, downloadEntity.gameId, gameName, null)
|
||||
}
|
||||
SimulatorGameManager.recordDownloadSimulatorGame(downloadEntity.gameId, simulator.type)
|
||||
SimulatorGameManager.postPlayedGame(downloadEntity.gameId, downloadEntity.packageName)
|
||||
} else {
|
||||
val downloadType = downloadEntity.getMetaExtra(Constants.EXTRA_DOWNLOAD_TYPE)
|
||||
// 是否是自动安装
|
||||
val isAutoInstall = PreferenceManager.getDefaultSharedPreferences(mApplication).getBoolean(SettingsFragment.AUTO_INSTALL_SP_KEY, true)
|
||||
val isAutoInstall = PreferenceManager.getDefaultSharedPreferences(mApplication).getBoolean(AUTO_INSTALL_SP_KEY, true)
|
||||
if (downloadType == Constants.SIMULATOR_DOWNLOAD || isAutoInstall) {
|
||||
if (FileUtils.isEmptyFile(downloadEntity.path)) {
|
||||
Utils.toast(mApplication, R.string.install_failure_hint)
|
||||
@ -167,7 +173,11 @@ object DownloadObserver {
|
||||
}
|
||||
} else {
|
||||
// 弹出卸载提示框
|
||||
EventBus.getDefault().post(EBShowDialog(BaseActivity.PLUGGABLE, downloadEntity.path))
|
||||
if (downloadEntity.isPlugin) {
|
||||
EventBus.getDefault().post(EBShowDialog(BaseActivity.PLUGGABLE, downloadEntity.path))
|
||||
} else {
|
||||
EventBus.getDefault().post(EBShowDialog(BaseActivity.SIGNATURE_CONFLICT, downloadEntity.path))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -179,15 +189,33 @@ object DownloadObserver {
|
||||
}
|
||||
|
||||
// 下载过程分析统计
|
||||
// val pm = mApplication.packageManager
|
||||
// val packageInfo = pm.getPackageArchiveInfo(downloadEntity.path, 0)
|
||||
// if (packageInfo == null) {
|
||||
|
||||
// 部分设备 (已知 vivo 5.1.1) 在调用 packageManager.getPackageArchiveInfo 获取比较大的 APK 文件时会出现 ANR
|
||||
// 这里为了让它能用就不判断是否解析包错误了
|
||||
if (PackageUtils.isDeviceUnableToHandleBigApkFile(downloadEntity.path)) {
|
||||
return
|
||||
}
|
||||
|
||||
val pm = mApplication.packageManager
|
||||
val packageInfo = pm.getPackageArchiveInfo(downloadEntity.path, 0)
|
||||
if (packageInfo == null) {
|
||||
// MtaHelper.onEventWithBasicDeviceInfo("解析包错误分析",
|
||||
// "游戏名字", downloadEntity.name + ":" + PlatformUtils.getInstance(mApplication).getPlatformName(downloadEntity.platform))
|
||||
//
|
||||
// MtaHelper.onEventWithBasicDeviceInfo("解析包错误_新",
|
||||
// "游戏", downloadEntity.name + ":" + PlatformUtils.getInstance(mApplication).getPlatformName(downloadEntity.platform))
|
||||
// }
|
||||
val downloadType = downloadEntity.getMetaExtra(Constants.EXTRA_DOWNLOAD_TYPE)
|
||||
if (downloadType == Constants.SIMULATOR_DOWNLOAD) {
|
||||
val currentActivity = AppManager.getInstance().currentActivity()
|
||||
?: return
|
||||
DialogUtils.showSimulatorParseErrorDialog(currentActivity, downloadEntity.gameId, downloadEntity.name) {
|
||||
val simulator = HaloApp.get(downloadEntity.name, true) as? SimulatorEntity
|
||||
?: return@showSimulatorParseErrorDialog
|
||||
DownloadManager.getInstance(currentActivity).cancel(downloadEntity.url, true, true)
|
||||
SimulatorDownloadManager.getInstance().showDownloadDialog(currentActivity, simulator, SimulatorDownloadManager.SimulatorLocation.SIMULATOR_GAME)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (downloadEntity.status == DownloadStatus.done) {
|
||||
@ -219,7 +247,7 @@ object DownloadObserver {
|
||||
kv1["版本"] = platform
|
||||
kv1["状态"] = "下载完成"
|
||||
kv1["用户机型"] = Build.MODEL
|
||||
kv1["设备IMEI"] = MetaUtil.getIMEI()
|
||||
kv1["设备JNFJ"] = MetaUtil.getBase64EncodedIMEI()
|
||||
kv1["网络状态"] = DeviceUtils.getNetwork(HaloApp.getInstance().application)
|
||||
kv1["光环助手版本"] = BuildConfig.VERSION_NAME
|
||||
if (downloadEntity.isUpdate) {
|
||||
@ -255,11 +283,12 @@ object DownloadObserver {
|
||||
// "操作", "下载完成",
|
||||
// "网络状态", DeviceUtils.getNetwork(HaloApp.getInstance().application))
|
||||
}
|
||||
|
||||
val isPlatformRecommend = java.lang.Boolean.parseBoolean(downloadEntity.getMetaExtra(Constants.IS_PLATFORM_RECOMMEND))
|
||||
ExposureUtils.logADownloadCompleteExposureEvent(
|
||||
GameEntity(id = downloadEntity.getRealGameId(Constants.GAME_ID_DIVIDER),
|
||||
GameEntity(id = downloadEntity.gameId,
|
||||
mName = downloadEntity.name.removeSuffix(Constants.GAME_NAME_DECORATOR),
|
||||
gameVersion = downloadEntity.versionName ?: ""),
|
||||
gameVersion = downloadEntity.versionName ?: "",
|
||||
isPlatformRecommend = isPlatformRecommend),
|
||||
downloadEntity.platform,
|
||||
downloadEntity.exposureTrace,
|
||||
downloadEntity.meta[DownloadEntity.DOWNLOAD_HOST_KEY] ?: "unknown",
|
||||
@ -287,7 +316,7 @@ object DownloadObserver {
|
||||
params["game"] = id
|
||||
params["platform"] = platform ?: ""
|
||||
val body = RequestBody.create(MediaType.parse("application/json"),
|
||||
JSONObject(params).toString())
|
||||
JSONObject(params as Map<*, *>).toString())
|
||||
RetrofitManager.getInstance(mApplication).api.postDownload(body)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
|
||||
169
app/src/main/java/com/gh/common/util/EnergyTaskHelper.kt
Normal file
169
app/src/main/java/com/gh/common/util/EnergyTaskHelper.kt
Normal file
@ -0,0 +1,169 @@
|
||||
package com.gh.common.util
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.view.Gravity
|
||||
import android.view.View
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.PopupWindow
|
||||
import android.widget.TextView
|
||||
import com.gh.common.constant.Constants
|
||||
import com.gh.gamecenter.BuildConfig
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.energy.EnergyCenterActivity
|
||||
import com.gh.gamecenter.entity.EnergyTaskCompleteEntity
|
||||
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.AppManager
|
||||
import com.lightgame.utils.Utils
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
import okhttp3.MediaType
|
||||
import okhttp3.RequestBody
|
||||
import org.json.JSONObject
|
||||
|
||||
/**
|
||||
* 上报光能任务辅助类
|
||||
*/
|
||||
object EnergyTaskHelper {
|
||||
|
||||
@JvmStatic
|
||||
fun postEnergyTask(action: String) {
|
||||
postEnergyTask(action, null, null, null)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun postEnergyTask(action: String, id: String) {
|
||||
postEnergyTask(action, id, null, null)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun postEnergyTask(action: String, id: String, packageName: String) {
|
||||
postEnergyTask(action, id, packageName, null)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun postEnergyTaskForWeb(action: String, url: String) {
|
||||
postEnergyTask(action, null, null, url)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun postEnergyTaskForShare(type: String, id: String, url: String) {
|
||||
when (type) {
|
||||
"游戏详情" -> postEnergyTask("share_game_detail", id)
|
||||
|
||||
"视频" -> postEnergyTask("share_video", id)
|
||||
|
||||
"资讯文章" -> postEnergyTask("share_article", id)
|
||||
|
||||
"问题详情" -> postEnergyTask("share_question", id)
|
||||
|
||||
"回答详情" -> postEnergyTask("share_answer", id)
|
||||
|
||||
"文章详情" -> postEnergyTask("share_community_article", id)
|
||||
|
||||
"工具箱" -> postEnergyTask("share_toolkit", id)
|
||||
|
||||
"web链接" -> postEnergyTaskForWeb("share_web", url)
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
@JvmStatic
|
||||
fun postEnergyTask(action: String, id: String? = null, packageName: String? = null, url: String? = null) {
|
||||
if (BuildConfig.DEBUG || BuildConfig.BUILD_TIME != 0L) {
|
||||
val taskParams = JSONObject()
|
||||
taskParams.put("action", action)
|
||||
|
||||
val actionParams = JSONObject()
|
||||
if (id != null) actionParams.put("_id", id)
|
||||
if (packageName != null) actionParams.put("package", packageName)
|
||||
if (url != null) actionParams.put("url", url)
|
||||
taskParams.put("action_param", actionParams)
|
||||
|
||||
debugOnly { Utils.log("EnergyTaskHelper -> $taskParams") }
|
||||
|
||||
val body = RequestBody.create(MediaType.parse("application/json"), taskParams.toString())
|
||||
RetrofitManager.getInstance(HaloApp.getInstance().application)
|
||||
.api.postEnergyTask(UserManager.getInstance().userId, body)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(object : BiResponse<List<EnergyTaskCompleteEntity>>() {
|
||||
override fun onSuccess(data: List<EnergyTaskCompleteEntity>) {
|
||||
data.forEach { showCompletePopup(it) }
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
@JvmStatic
|
||||
fun postInviteCodeTask(code: String, from: String, callback: (() -> Unit)?) {
|
||||
if (BuildConfig.DEBUG || BuildConfig.BUILD_TIME != 0L) {
|
||||
val taskParams = JSONObject()
|
||||
taskParams.put("action", "enter_invite_code")
|
||||
|
||||
val actionParams = JSONObject()
|
||||
actionParams.put("code", code)
|
||||
actionParams.put("type", "new")
|
||||
actionParams.put("from", from)
|
||||
taskParams.put("action_param", actionParams)
|
||||
|
||||
debugOnly { Utils.log("EnergyTaskHelper -> $taskParams") }
|
||||
|
||||
val body = RequestBody.create(MediaType.parse("application/json"), taskParams.toString())
|
||||
RetrofitManager.getInstance(HaloApp.getInstance().application)
|
||||
.api.postEnergyTask(UserManager.getInstance().userId, body)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(object : BiResponse<List<EnergyTaskCompleteEntity>>() {
|
||||
override fun onSuccess(data: List<EnergyTaskCompleteEntity>) {
|
||||
SPUtils.setBoolean(Constants.SP_HAS_COMPLETE_INVITE_CODE, true)
|
||||
callback?.invoke()
|
||||
data.forEach { showCompletePopup(it) }
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// 完成弹窗
|
||||
@JvmStatic
|
||||
fun showCompletePopup(entity: EnergyTaskCompleteEntity) {
|
||||
tryWithDefaultCatch {
|
||||
val currentActivity = AppManager.getInstance().recentActiveActivity
|
||||
val popWindow = PopupWindow(LinearLayout.LayoutParams.MATCH_PARENT, 88F.dip2px())
|
||||
|
||||
currentActivity?.run {
|
||||
val contentView = View.inflate(this, R.layout.popup_energy_task, null)
|
||||
contentView.run {
|
||||
findViewById<TextView>(R.id.taskDesc).text = "恭喜你!完成任务:${entity.name}"
|
||||
findViewById<TextView>(R.id.taskEnergy).text = "+${entity.energy}光能"
|
||||
isFocusable = true
|
||||
isFocusableInTouchMode = true
|
||||
setOnClickListener {
|
||||
if (popWindow != null && popWindow.isShowing) {
|
||||
popWindow.dismiss()
|
||||
}
|
||||
if (currentActivity !is EnergyCenterActivity) {
|
||||
currentActivity.startActivity(EnergyCenterActivity.getIntent(currentActivity))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
popWindow.contentView = contentView
|
||||
currentActivity.window.decorView.post {
|
||||
popWindow.showAtLocation(currentActivity.window.decorView, Gravity.TOP, 0, 0)
|
||||
}
|
||||
|
||||
contentView.postDelayed({
|
||||
tryCatchInRelease {
|
||||
if (popWindow != null && popWindow.isShowing) {
|
||||
popWindow.dismiss()
|
||||
}
|
||||
}
|
||||
}, 3000)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -47,11 +47,13 @@ public class EntranceUtils {
|
||||
public static final String KEY_PACKAGE_MD5 = "package_md5";
|
||||
public static final String HOST_ARTICLE = "article";
|
||||
public static final String HOST_UPLOAD_VIDEO = "upload_video";//上传视频
|
||||
public static final String HOST_UPLOAD_VIDEO_NEW = "upload_video_new"; // 上传视频新(AKA 发视频)
|
||||
public static final String HOST_VIDEO_SINGLE = "video_single";//指定视频-不能划动
|
||||
public static final String HOST_VIDEO_MORE = "video_more";//指定视频-能划动
|
||||
public static final String HOST_VIDEO_STREAMING_HOME = "video_streaming_home";//视频流-首页
|
||||
public static final String HOST_VIDEO_STREAMING_DESC = "video_streaming_desc";//视频流-游戏介绍进入
|
||||
public static final String HOST_VIDEO_COLLECTION = "video_collection";//视频合集
|
||||
public static final String HOST_VIDEO_DETAIL = "video_detail";
|
||||
public static final String HOST_USERHOME = "userhome";//个人主页
|
||||
public static final String HOST_VIDEO = "video";
|
||||
public static final String HOST_FORUM = "forum";
|
||||
@ -98,6 +100,7 @@ public class EntranceUtils {
|
||||
public static final String KEY_LINK = "link";
|
||||
public static final String KEY_NAME = "name";
|
||||
public static final String KEY_POSITION = "position";
|
||||
public static final String KEY_SUB_POSITION = "sub_position";
|
||||
public static final String KEY_ENTRANCE = "entrance";
|
||||
public static final String KEY_ENTRANCE_LINK = "entrance_link";
|
||||
public static final String KEY_TARGET = "target";
|
||||
@ -148,8 +151,10 @@ public class EntranceUtils {
|
||||
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_IS_COLUMN_COLLECTION = "is_column_collection";//是专题合集
|
||||
public static final String KEY_DRAFT_ID = "draft_id";
|
||||
public static final String KEY_KAIFU_LIST = "kaifuList";
|
||||
public static final String KEY_CATEGORY = "category";
|
||||
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";
|
||||
@ -167,6 +172,7 @@ public class EntranceUtils {
|
||||
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_HIDE_USELESS_INFO = "hide_useless_info";
|
||||
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";
|
||||
@ -190,6 +196,7 @@ public class EntranceUtils {
|
||||
public static final String KEY_UUID = "uuid";
|
||||
public static final String KEY_IS_HOME_VIDEO = "isHomeVideo";
|
||||
public static final String KEY_IS_HOME = "isHome";
|
||||
public static final String KEY_TAB_COUNT = "tab_count";
|
||||
public static final String KEY_WEB_SHARE = "webShare";
|
||||
public static final String KEY_ACTIVITY_NAME = "activityName";//活动名称
|
||||
public static final String KEY_PAGINATION_TYPE = "paginationType";//活动分页方式
|
||||
@ -212,6 +219,7 @@ public class EntranceUtils {
|
||||
public static final String KEY_CHANGE_PHONE = "changePhone";
|
||||
public static final String KEY_CONFLICT_PHONE = "conflictPhone";
|
||||
public static final String KEY_CONFLICT_USER = "conflictUser";
|
||||
public static final String KEY_EXPOSURE_SOURCE = "exposure_source";
|
||||
public static final String KEY_BBS_ID = "bbs_id";
|
||||
public static final String KEY_DIAGNOSIS = "diagnosis";
|
||||
public static final String KEY_SIMULATOR = "simulator";
|
||||
@ -221,6 +229,21 @@ public class EntranceUtils {
|
||||
public static final String KEY_PRIMARY_CATALOG_NAME = "primaryCatalogName";
|
||||
public static final String KEY_CATALOG_TITLE = "catalog_title";
|
||||
public static final String KEY_CATALOG_INIT_TITLE = "catalog_init_title";
|
||||
public static final String KEY_CATEGORY_LIST = "categoty_list";
|
||||
public static final String KEY_IS_FREE = "is_free";
|
||||
public static final String KEY_IS_SIGN = "is_sign";
|
||||
public static final String KEY_IS_CHOOSE_APK = "is_choose_apk";
|
||||
public static final String KEY_TAB_INDEX = "tab_index";
|
||||
public static final String KEY_IS_CATEGORY_V2 = "is_category_v2";
|
||||
public static final String KEY_SUB_CATEGORY_ID = "sub_category_id";
|
||||
public static final String KEY_IS_QA_FEEDBACK = "is_qa_feedback";
|
||||
public static final String KEY_IS_CLICK_RECEIVE_BTN = "is_click_receive_btn";
|
||||
public static final String KEY_SHOW_QUICK_LOGIN = "show_quick_login";
|
||||
public static final String KEY_VIDEO_LIST = "video_list";
|
||||
public static final String KEY_CHOOSE_FORUM_TYPE = "choose_forum_type";
|
||||
public static final String KEY_CHOOSE_MAX_COUNT = "choose_max_count";
|
||||
public static final String KEY_COMMENT_COUNT = "comment_count";
|
||||
public static final String KEY_IS_COMMENT_CONVERSATION = "is_comment_conversation";
|
||||
|
||||
public static void jumpActivity(Context context, Bundle bundle) {
|
||||
bundle.putBoolean(KEY_REQUIRE_REDIRECT, true);
|
||||
@ -237,6 +260,10 @@ public class EntranceUtils {
|
||||
} else {
|
||||
Intent intent1 = new Intent(context, clazz);
|
||||
intent1.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
// 如果 activity 名称有 singleton 的就添加 reorder_to_front 标签 (有点粗暴有点蠢,但暂时就先这样吧 :C )
|
||||
if (clazz.getSimpleName().toLowerCase().contains("singleton")) {
|
||||
intent1.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
||||
}
|
||||
intent1.putExtras(bundle);
|
||||
context.startActivity(intent1);
|
||||
}
|
||||
|
||||
@ -6,6 +6,7 @@ import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.WebActivity
|
||||
import com.gh.gamecenter.entity.ErrorEntity
|
||||
import com.lightgame.utils.Utils
|
||||
import retrofit2.HttpException
|
||||
|
||||
/**
|
||||
* 这个类用来管理一些错误,像弹窗、TOAST 什么的
|
||||
@ -17,10 +18,13 @@ object ErrorHelper {
|
||||
* [showHighPriorityHint] 用来标识有同样错误码可以触发两种处理时,为 true 时选择重要的
|
||||
* [customizedHandler] 返回 true 为已处理该错误码,false 则交由 [handleError] 处理
|
||||
*/
|
||||
fun handleErrorWithCustomizedHandler(context: Context,
|
||||
errorString: String?,
|
||||
showHighPriorityHint: Boolean = false,
|
||||
customizedHandler: (code: Int) -> Boolean) {
|
||||
@JvmStatic
|
||||
fun handleErrorWithCustomizedHandler(
|
||||
context: Context,
|
||||
errorString: String?,
|
||||
showHighPriorityHint: Boolean = false,
|
||||
customizedHandler: (code: Int) -> Boolean
|
||||
) {
|
||||
val errorEntity = errorString?.toObject<ErrorEntity>()
|
||||
|
||||
if (customizedHandler(errorEntity?.code ?: 0)) {
|
||||
@ -73,8 +77,15 @@ object ErrorHelper {
|
||||
*403057: 游戏评论
|
||||
*403054: 更新社区文章
|
||||
*403047: 回答点赞
|
||||
*403112: 发布视频贴
|
||||
*403113: 修改视频贴
|
||||
*403114: 点赞视频贴
|
||||
*/
|
||||
private fun handleError(context: Context, showHighPriorityHint: Boolean = false, errorEntity: ErrorEntity) {
|
||||
private fun handleError(
|
||||
context: Context,
|
||||
showHighPriorityHint: Boolean = false,
|
||||
errorEntity: ErrorEntity
|
||||
) {
|
||||
when (errorEntity.code) {
|
||||
403050,
|
||||
403051,
|
||||
@ -87,7 +98,10 @@ object ErrorHelper {
|
||||
403054,
|
||||
403069,
|
||||
403071,
|
||||
403047 -> handleErrorWithCommunityBannedDialog(context, errorEntity)
|
||||
403047,
|
||||
403112,
|
||||
403113,
|
||||
403114 -> handleErrorWithCommunityBannedDialog(context, errorEntity)
|
||||
|
||||
403057,
|
||||
403068 -> handleErrorWithCommentBannedDialog(context, errorEntity)
|
||||
@ -118,12 +132,15 @@ object ErrorHelper {
|
||||
403082 -> Utils.toast(context, "作者已关闭评论")
|
||||
403022 -> Utils.toast(context, "不能回复自己")
|
||||
403056 -> Utils.toast(context, "发布失败,字数已达上限")
|
||||
403111 -> Utils.toast(context, "提交失败,评论违规")
|
||||
|
||||
403020 -> if (showHighPriorityHint) {
|
||||
DialogUtils.showAlertDialog(context,
|
||||
"提醒",
|
||||
"提问过于频繁,请先休息一下哦",
|
||||
"知道了", null, null, null)
|
||||
DialogUtils.showAlertDialog(
|
||||
context,
|
||||
"提醒",
|
||||
"提问过于频繁,请先休息一下哦",
|
||||
"知道了", null, null, null
|
||||
)
|
||||
} else {
|
||||
Utils.toast(context, R.string.comment_failed_toofrequent)
|
||||
}
|
||||
@ -146,12 +163,14 @@ object ErrorHelper {
|
||||
"(非永久)"
|
||||
}
|
||||
val dialogContext = DialogUtils.checkDialogContext(context)
|
||||
DialogUtils.showAlertDialog(dialogContext,
|
||||
"提示",
|
||||
"你因违反《光环助手评论规则》,已被禁言$bannedType,如有疑问,请联系客服(QQ:${Config.getSettings()?.support?.qq})",
|
||||
"去看看", "关闭", {
|
||||
dialogContext.startActivity(WebActivity.getCommentRulesIntent(dialogContext))
|
||||
}, null)
|
||||
DialogUtils.showAlertDialog(
|
||||
dialogContext,
|
||||
"提示",
|
||||
"你因违反《光环助手评论规则》,已被禁言$bannedType,如有疑问,请联系客服(QQ:${Config.getSettings()?.support?.qq})",
|
||||
"去看看", "关闭", {
|
||||
dialogContext.startActivity(WebActivity.getCommentRulesIntent(dialogContext))
|
||||
}, null
|
||||
)
|
||||
}
|
||||
|
||||
private fun handleErrorWithCommunityBannedDialog(context: Context, errorEntity: ErrorEntity) {
|
||||
@ -161,12 +180,34 @@ object ErrorHelper {
|
||||
"(非永久)"
|
||||
}
|
||||
val dialogContext = DialogUtils.checkDialogContext(context)
|
||||
DialogUtils.showAlertDialog(dialogContext,
|
||||
"提示",
|
||||
"你因违反《问答版块规则》,已被禁言$bannedType,如有疑问,请联系客服(QQ:1562479331)",
|
||||
"去看看", "关闭", {
|
||||
dialogContext.startActivity(WebActivity.getCommunityRuleIntent(dialogContext))
|
||||
}, null)
|
||||
DialogUtils.showAlertDialog(
|
||||
dialogContext,
|
||||
"提示",
|
||||
"你因违反《问答版块规则》,已被禁言$bannedType,如有疑问,请联系客服(QQ:1562479331)",
|
||||
"去看看", "关闭", {
|
||||
dialogContext.startActivity(WebActivity.getCommunityRuleIntent(dialogContext))
|
||||
}, null
|
||||
)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun handleLoginError(context: Context, httpException: HttpException?) {
|
||||
try {
|
||||
val errorEntity: ErrorEntity? =
|
||||
httpException?.response()?.errorBody()?.string()?.toObject()
|
||||
when {
|
||||
errorEntity?.code == 403099 -> {
|
||||
Utils.toast(context, "当前账号正在注销,禁止登录")
|
||||
}
|
||||
errorEntity?.toast?.isNotEmpty() == true -> {
|
||||
Utils.toast(context, errorEntity.toast)
|
||||
}
|
||||
else -> Utils.toast(context, R.string.login_failure)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
Utils.toast(context, R.string.login_failure)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -4,15 +4,19 @@ import android.animation.Animator
|
||||
import android.content.ClipData
|
||||
import android.content.ClipboardManager
|
||||
import android.content.Context
|
||||
import android.graphics.Bitmap
|
||||
import android.graphics.Canvas
|
||||
import android.graphics.Rect
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.graphics.drawable.GradientDrawable
|
||||
import android.os.Build
|
||||
import android.text.*
|
||||
import android.text.style.ClickableSpan
|
||||
import android.text.style.ImageSpan
|
||||
import android.text.style.URLSpan
|
||||
import android.util.Log
|
||||
import android.util.TypedValue
|
||||
import android.view.Gravity
|
||||
import android.view.View
|
||||
import android.view.*
|
||||
import android.view.inputmethod.InputMethodManager
|
||||
import android.widget.EditText
|
||||
import android.widget.PopupWindow
|
||||
@ -26,6 +30,7 @@ import androidx.fragment.app.FragmentActivity
|
||||
import androidx.lifecycle.*
|
||||
import androidx.lifecycle.Observer
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import androidx.viewbinding.ViewBinding
|
||||
import androidx.viewpager.widget.ViewPager
|
||||
import com.airbnb.lottie.LottieAnimationView
|
||||
import com.facebook.drawee.view.SimpleDraweeView
|
||||
@ -51,54 +56,69 @@ import io.reactivex.disposables.Disposable
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
import okhttp3.MediaType
|
||||
import okhttp3.RequestBody
|
||||
import org.json.JSONArray
|
||||
import org.json.JSONObject
|
||||
import java.net.URI
|
||||
import java.util.*
|
||||
import java.util.concurrent.TimeUnit
|
||||
import java.util.regex.Pattern
|
||||
import kotlin.math.abs
|
||||
|
||||
/**
|
||||
* 创建以 activity 为观察者上下文的 viewModel
|
||||
*/
|
||||
inline fun <reified VM : ViewModel> FragmentActivity.viewModelProvider(
|
||||
provider: ViewModelProvider.Factory? = null
|
||||
) =
|
||||
ViewModelProviders.of(this, provider).get(VM::class.java)
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 创建以 activity 为观察者上下文的 viewModel
|
||||
*/
|
||||
inline fun <reified VM : ViewModel> Fragment.viewModelProviderFromParent(
|
||||
provider: ViewModelProvider.Factory? = null
|
||||
inline fun <reified VM : ViewModel> FragmentActivity.viewModelProvider(
|
||||
provider: ViewModelProvider.Factory? = null
|
||||
) =
|
||||
ViewModelProviders.of(requireActivity(), provider).get(VM::class.java)
|
||||
ViewModelProviders.of(this, provider).get(VM::class.java)
|
||||
|
||||
/**
|
||||
* 创建以 activity 为观察者上下文的 viewModel
|
||||
* 额外的 key: 用于区分单 activity 多 viewModel 的情况 (如首页tab)
|
||||
*/
|
||||
inline fun <reified VM : ViewModel> Fragment.viewModelProviderFromParent(
|
||||
provider: ViewModelProvider.Factory? = null,
|
||||
key: String = ""
|
||||
) = if (key.isEmpty()) {
|
||||
ViewModelProviders.of(requireActivity(), provider).get(VM::class.java)
|
||||
} else {
|
||||
ViewModelProviders.of(requireActivity(), provider).get(key, VM::class.java)
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建以 activity 为观察者上下文的 viewModel
|
||||
*/
|
||||
inline fun <reified VM : ViewModel> FragmentActivity.viewModelProviderFromParent(
|
||||
provider: ViewModelProvider.Factory? = null
|
||||
provider: ViewModelProvider.Factory? = null
|
||||
) =
|
||||
ViewModelProviders.of(this, provider).get(VM::class.java)
|
||||
ViewModelProviders.of(this, provider).get(VM::class.java)
|
||||
|
||||
/**
|
||||
* 创建以 fragment 为观察者上下文的 viewModel
|
||||
*/
|
||||
inline fun <reified VM : ViewModel> Fragment.viewModelProvider(
|
||||
provider: ViewModelProvider.Factory? = null
|
||||
provider: ViewModelProvider.Factory? = null
|
||||
) =
|
||||
ViewModelProviders.of(this, provider).get(VM::class.java)
|
||||
ViewModelProviders.of(this, provider).get(VM::class.java)
|
||||
|
||||
/**
|
||||
*
|
||||
* ViewPager Extensions
|
||||
*
|
||||
*/
|
||||
fun ViewPager.doOnPageSelected(action: (position: Int) -> Unit) = addOnPageChangeListener(onSelected = action)
|
||||
fun ViewPager.doOnPageSelected(action: (position: Int) -> Unit) =
|
||||
addOnPageChangeListener(onSelected = action)
|
||||
|
||||
fun ViewPager.addOnPageChangeListener(onSelected: ((position: Int) -> Unit)? = null) {
|
||||
val listener = object : ViewPager.OnPageChangeListener {
|
||||
override fun onPageScrolled(position: Int, positionOffset: Float, positionOffsetPixels: Int) {
|
||||
override fun onPageScrolled(
|
||||
position: Int,
|
||||
positionOffset: Float,
|
||||
positionOffsetPixels: Int
|
||||
) {
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
@ -113,12 +133,22 @@ fun ViewPager.addOnPageChangeListener(onSelected: ((position: Int) -> Unit)? = n
|
||||
addOnPageChangeListener(listener)
|
||||
}
|
||||
|
||||
fun ViewPager.addOnScrollStateChanged(onStateChanged: ((state: Int) -> Unit)? = null) {
|
||||
fun ViewPager.doOnScroll(
|
||||
onStateChanged: ((state: Int) -> Unit)? = null,
|
||||
onPageScrolled: ((position: Int, positionOffset: Float, positionOffsetPixels: Int) -> Unit)? = null,
|
||||
onPageSelected: ((position: Int) -> Unit)? = null
|
||||
) {
|
||||
val listener = object : ViewPager.OnPageChangeListener {
|
||||
override fun onPageScrolled(position: Int, positionOffset: Float, positionOffsetPixels: Int) {
|
||||
override fun onPageScrolled(
|
||||
position: Int,
|
||||
positionOffset: Float,
|
||||
positionOffsetPixels: Int
|
||||
) {
|
||||
onPageScrolled?.invoke(position, positionOffset, positionOffsetPixels)
|
||||
}
|
||||
|
||||
override fun onPageSelected(position: Int) {
|
||||
onPageSelected?.invoke(position)
|
||||
}
|
||||
|
||||
override fun onPageScrollStateChanged(state: Int) {
|
||||
@ -133,13 +163,19 @@ fun ViewPager.addOnScrollStateChanged(onStateChanged: ((state: Int) -> Unit)? =
|
||||
* Fragment related
|
||||
*/
|
||||
inline fun <reified T : Fragment> Fragment.fragmentFromActivity() =
|
||||
parentFragmentManager.findFragmentByTag(T::class.java.simpleName) as? T
|
||||
?: parentFragmentManager.fragmentFactory.instantiate(requireContext().classLoader, T::class.java.canonicalName) as T
|
||||
parentFragmentManager.findFragmentByTag(T::class.java.simpleName) as? T
|
||||
?: parentFragmentManager.fragmentFactory.instantiate(
|
||||
requireContext().classLoader,
|
||||
T::class.java.canonicalName
|
||||
) as T
|
||||
|
||||
|
||||
inline fun <reified T : Fragment> Fragment.fragmentFromParentFragment() =
|
||||
childFragmentManager.findFragmentByTag(T::class.java.simpleName) as? T
|
||||
?: childFragmentManager.fragmentFactory.instantiate(requireContext().classLoader, T::class.java.canonicalName) as T
|
||||
childFragmentManager.findFragmentByTag(T::class.java.simpleName) as? T
|
||||
?: childFragmentManager.fragmentFactory.instantiate(
|
||||
requireContext().classLoader,
|
||||
T::class.java.canonicalName
|
||||
) as T
|
||||
|
||||
|
||||
/**
|
||||
@ -147,7 +183,12 @@ inline fun <reified T : Fragment> Fragment.fragmentFromParentFragment() =
|
||||
*/
|
||||
|
||||
// 监听滚动距离
|
||||
fun RecyclerView.doOnScrolledSpecificDistance(distanceX: Int = 0, distanceY: Int = 0, singleTimeEvent: Boolean = false, action: () -> Unit) {
|
||||
fun RecyclerView.doOnScrolledSpecificDistance(
|
||||
distanceX: Int = 0,
|
||||
distanceY: Int = 0,
|
||||
singleTimeEvent: Boolean = false,
|
||||
action: () -> Unit
|
||||
) {
|
||||
val listener = object : RecyclerView.OnScrollListener() {
|
||||
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
|
||||
super.onScrolled(recyclerView, dx, dy)
|
||||
@ -164,6 +205,18 @@ fun RecyclerView.doOnScrolledSpecificDistance(distanceX: Int = 0, distanceY: Int
|
||||
addOnScrollListener(listener)
|
||||
}
|
||||
|
||||
/**
|
||||
* ViewBinding related Extensions
|
||||
*/
|
||||
inline fun <reified T : ViewBinding> ViewGroup.toBinding(): T {
|
||||
return T::class.java.getMethod(
|
||||
"inflate",
|
||||
LayoutInflater::class.java,
|
||||
ViewGroup::class.java,
|
||||
Boolean::class.java
|
||||
).invoke(null, layoutInflater, this, false) as T
|
||||
}
|
||||
|
||||
/**
|
||||
* View Extensions
|
||||
*/
|
||||
@ -204,6 +257,46 @@ fun View.setDebouncedClickListener(action: () -> Unit) {
|
||||
setOnClickListener { debounceActionWithInterval(interval = 300L) { action.invoke() } }
|
||||
}
|
||||
|
||||
val View.layoutInflater: LayoutInflater
|
||||
get() = LayoutInflater.from(this.context)
|
||||
|
||||
fun View.removeFromParent() {
|
||||
postDelayed(object : Runnable {
|
||||
override fun run() {
|
||||
try {
|
||||
if (parent == null) {
|
||||
Utils.log(javaClass.simpleName, "getParent() returning Null")
|
||||
} else {
|
||||
try {
|
||||
(parent as ViewGroup).removeView(this@removeFromParent)
|
||||
} catch (ex: Exception) {
|
||||
Utils.log(javaClass.simpleName, "Cannot remove from parent layout")
|
||||
}
|
||||
}
|
||||
} catch (ex: Exception) {
|
||||
Utils.log(javaClass.simpleName, Log.getStackTraceString(ex))
|
||||
}
|
||||
}
|
||||
}, 100)
|
||||
}
|
||||
|
||||
/**
|
||||
* 扩大 View 的点击区域
|
||||
*/
|
||||
fun View.enlargeTouchArea(enlargedSizeInPx: Int = 4F.dip2px()) {
|
||||
val parent = parent as View
|
||||
|
||||
parent.post {
|
||||
val rect = Rect()
|
||||
getHitRect(rect)
|
||||
rect.top -= enlargedSizeInPx
|
||||
rect.left -= enlargedSizeInPx
|
||||
rect.bottom += enlargedSizeInPx
|
||||
rect.right += enlargedSizeInPx
|
||||
parent.touchDelegate = TouchDelegate(rect, this)
|
||||
}
|
||||
}
|
||||
|
||||
fun isPublishEnv(): Boolean {
|
||||
return BuildConfig.FLAVOR != "internal"
|
||||
}
|
||||
@ -256,11 +349,11 @@ fun String.insert(index: Int, string: String): String {
|
||||
*/
|
||||
fun String.replaceUnsupportedHtmlTag(): String {
|
||||
return this.replace("<ul", "<hul")
|
||||
.replace("</ul>", "</hul>")
|
||||
.replace("<li", "<hli")
|
||||
.replace("</li>", "</hli>")
|
||||
.replace("<ol", "<hol")
|
||||
.replace("</ol>", "</hol>")
|
||||
.replace("</ul>", "</hul>")
|
||||
.replace("<li", "<hli")
|
||||
.replace("</li>", "</hli>")
|
||||
.replace("<ol", "<hol")
|
||||
.replace("</ol>", "</hol>")
|
||||
}
|
||||
|
||||
fun String.containHtmlTag(): Boolean {
|
||||
@ -275,8 +368,8 @@ fun String.containHtmlTag(): Boolean {
|
||||
fun Fragment.showRegulationTestDialogIfNeeded(action: (() -> Unit)) {
|
||||
if (UserManager.getInstance().userShouldTakeRegulationBaseOnLastRemind()) {
|
||||
DialogUtils.showRegulationTestDialog(requireContext(),
|
||||
{ DirectUtils.directToRegulationTestPage(requireContext()) },
|
||||
{ action.invoke() })
|
||||
{ DirectUtils.directToRegulationTestPage(requireContext()) },
|
||||
{ action.invoke() })
|
||||
} else {
|
||||
action()
|
||||
}
|
||||
@ -285,8 +378,8 @@ fun Fragment.showRegulationTestDialogIfNeeded(action: (() -> Unit)) {
|
||||
fun Context.showRegulationTestDialogIfNeeded(action: (() -> Unit)) {
|
||||
if (UserManager.getInstance().userShouldTakeRegulationBaseOnLastRemind()) {
|
||||
DialogUtils.showRegulationTestDialog(this,
|
||||
{ DirectUtils.directToRegulationTestPage(this) },
|
||||
{ action.invoke() })
|
||||
{ DirectUtils.directToRegulationTestPage(this) },
|
||||
{ action.invoke() })
|
||||
} else {
|
||||
action()
|
||||
}
|
||||
@ -385,14 +478,15 @@ fun String.removeInsertedContent(): String {
|
||||
|
||||
// 去除视频相关文本
|
||||
fun String.removeVideoContent(): String {
|
||||
val videoRegex = "(?s)<div class=\"insert-video-container\".*?</div>"
|
||||
val videoRegex =
|
||||
"(?s)<div data-id.*?class=\"placeholder-video-container\".*? class=\"video-poster-btn\".*?</div>"
|
||||
return this.replace(videoRegex.toRegex(), "")
|
||||
}
|
||||
|
||||
// 完全地清除所有 Html 格式
|
||||
fun String.clearHtmlFormatCompletely(): String {
|
||||
return Html.fromHtml(this).toString().replace('\n', 32.toChar())
|
||||
.replace(160.toChar(), 32.toChar()).replace(65532.toChar(), 32.toChar()).trim { it <= ' ' }
|
||||
.replace(160.toChar(), 32.toChar()).replace(65532.toChar(), 32.toChar()).trim { it <= ' ' }
|
||||
}
|
||||
|
||||
// 如果该字符串长度超过固定长度的话,从头开始截取固定长度并返回
|
||||
@ -424,7 +518,7 @@ fun String.copyTextAndToast(toastText: String = "复制成功") {
|
||||
val application = HaloApp.getInstance().application
|
||||
val cmb = application.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
|
||||
val clip = ClipData.newPlainText(null, this)
|
||||
cmb.primaryClip = clip
|
||||
cmb.setPrimaryClip(clip)
|
||||
|
||||
if (!TextUtils.isEmpty(toastText)) {
|
||||
ToastUtils.showToast(toastText)
|
||||
@ -451,6 +545,14 @@ fun Any.toRequestBody(): RequestBody {
|
||||
return RequestBody.create(MediaType.parse("application/json"), json)
|
||||
}
|
||||
|
||||
fun JSONObject.toRequestBody(): RequestBody {
|
||||
return RequestBody.create(MediaType.parse("application/json"), this.toString())
|
||||
}
|
||||
|
||||
fun JSONArray.toRequestBody(): RequestBody {
|
||||
return RequestBody.create(MediaType.parse("application/json"), this.toString())
|
||||
}
|
||||
|
||||
// 对在浏览器(WebView)显示的路径进行转码
|
||||
fun String.decodeURI(): String {
|
||||
return URI(null, null, this, null).rawPath
|
||||
@ -477,6 +579,9 @@ fun Float.sp2px(): Int {
|
||||
return (this * scale + 0.5f).toInt()
|
||||
}
|
||||
|
||||
fun Float.roundTo(n: Int): Float {
|
||||
return "%.${n}f".format(Locale.CHINA, this).toFloat()
|
||||
}
|
||||
|
||||
/**
|
||||
* PopupWindow 自动适配方向
|
||||
@ -511,19 +616,23 @@ fun PopupWindow.showAutoOrientation(anchorView: View, distanceY: Int = 0, distan
|
||||
* 权限相关
|
||||
*/
|
||||
fun Fragment.checkReadPhoneStateAndStoragePermissionBeforeAction(action: (() -> Unit)) {
|
||||
PermissionHelper.checkReadPhoneStateAndStoragePermissionBeforeAction(requireContext(), object : EmptyCallback {
|
||||
override fun onCallback() {
|
||||
action.invoke()
|
||||
}
|
||||
})
|
||||
PermissionHelper.checkReadPhoneStateAndStoragePermissionBeforeAction(
|
||||
requireContext(),
|
||||
object : EmptyCallback {
|
||||
override fun onCallback() {
|
||||
action.invoke()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fun Fragment.checkReadPhoneStatePermissionBeforeAction(action: (() -> Unit)) {
|
||||
PermissionHelper.checkReadPhoneStatePermissionBeforeAction(requireContext(), object : EmptyCallback {
|
||||
override fun onCallback() {
|
||||
action.invoke()
|
||||
}
|
||||
})
|
||||
PermissionHelper.checkReadPhoneStatePermissionBeforeAction(
|
||||
requireContext(),
|
||||
object : EmptyCallback {
|
||||
override fun onCallback() {
|
||||
action.invoke()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fun Fragment.checkStoragePermissionBeforeAction(action: (() -> Unit)) {
|
||||
@ -535,11 +644,13 @@ fun Fragment.checkStoragePermissionBeforeAction(action: (() -> Unit)) {
|
||||
}
|
||||
|
||||
fun FragmentActivity.checkReadPhoneStateAndStoragePermissionBeforeAction(action: (() -> Unit)) {
|
||||
PermissionHelper.checkReadPhoneStateAndStoragePermissionBeforeAction(this, object : EmptyCallback {
|
||||
override fun onCallback() {
|
||||
action.invoke()
|
||||
}
|
||||
})
|
||||
PermissionHelper.checkReadPhoneStateAndStoragePermissionBeforeAction(
|
||||
this,
|
||||
object : EmptyCallback {
|
||||
override fun onCallback() {
|
||||
action.invoke()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fun FragmentActivity.checkReadPhoneStatePermissionBeforeAction(action: (() -> Unit)) {
|
||||
@ -570,20 +681,27 @@ fun <T> List<T>.secondOrNull(): T? {
|
||||
/**
|
||||
* TextView related.
|
||||
*/
|
||||
fun TextView.setTextWithHighlightedTextWrappedInsideWrapper(text: CharSequence,
|
||||
wrapper: String = Constants.DEFAULT_TEXT_WRAPPER,
|
||||
@ColorRes
|
||||
highlightColorId: Int = R.color.theme_font,
|
||||
copyClickedText: Boolean = false,
|
||||
highlightedTextClickListener: (() -> Unit)? = null) {
|
||||
TextHelper.highlightTextThatIsWrappedInsideWrapper(this, text, wrapper, highlightColorId, object : SimpleCallback<String> {
|
||||
override fun onCallback(arg: String) {
|
||||
if (copyClickedText) {
|
||||
arg.copyTextAndToast("已复制:$arg")
|
||||
fun TextView.setTextWithHighlightedTextWrappedInsideWrapper(
|
||||
text: CharSequence,
|
||||
wrapper: String = Constants.DEFAULT_TEXT_WRAPPER,
|
||||
@ColorRes
|
||||
highlightColorId: Int = R.color.theme_font,
|
||||
copyClickedText: Boolean = false,
|
||||
highlightedTextClickListener: (() -> Unit)? = null
|
||||
) {
|
||||
TextHelper.highlightTextThatIsWrappedInsideWrapper(
|
||||
this,
|
||||
text,
|
||||
wrapper,
|
||||
highlightColorId,
|
||||
object : SimpleCallback<String> {
|
||||
override fun onCallback(arg: String) {
|
||||
if (copyClickedText) {
|
||||
arg.copyTextAndToast("已复制:$arg")
|
||||
}
|
||||
highlightedTextClickListener?.invoke()
|
||||
}
|
||||
highlightedTextClickListener?.invoke()
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
fun TextView.setTextChangedListener(action: (s: CharSequence, start: Int, before: Int, count: Int) -> Unit) {
|
||||
@ -602,15 +720,20 @@ fun TextView.setTextChangedListener(action: (s: CharSequence, start: Int, before
|
||||
}
|
||||
|
||||
/**
|
||||
* ArrayList related
|
||||
* List related
|
||||
*/
|
||||
fun <T> ArrayList<T>.safelyGetInRelease(index: Int): T? {
|
||||
fun <T> List<T>.safelyGetInRelease(index: Int): T? {
|
||||
return if (index >= size) {
|
||||
throwExceptionInDebug("这里触发了数组越界,请检查")
|
||||
throwExceptionInDebug("这里触发了数组越界,请检查 (index $index >= size $size)")
|
||||
toastInInternalRelease("这个操作可能触发闪退,请确定复现方式并联系开发处理")
|
||||
null
|
||||
} else {
|
||||
this[index]
|
||||
try {
|
||||
this[index]
|
||||
} catch (e: IndexOutOfBoundsException) {
|
||||
e.printStackTrace()
|
||||
null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -619,7 +742,10 @@ fun <T> ArrayList<T>.safelyGetInRelease(index: Int): T? {
|
||||
* @param shrankText 未展开时的文字
|
||||
* @param expandedText 展开后的文字
|
||||
*/
|
||||
fun ExpandTextView.setTextWithInterceptingInternalUrl(shrankText: CharSequence, expandedText: CharSequence) {
|
||||
fun ExpandTextView.setTextWithInterceptingInternalUrl(
|
||||
shrankText: CharSequence,
|
||||
expandedText: CharSequence
|
||||
) {
|
||||
var shrankSsb = shrankText.interceptUrlSpanAndRoundImageSpan()
|
||||
var expandedSsb = expandedText.interceptUrlSpanAndRoundImageSpan()
|
||||
|
||||
@ -627,23 +753,42 @@ fun ExpandTextView.setTextWithInterceptingInternalUrl(shrankText: CharSequence,
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {
|
||||
while (shrankSsb.contains("\n\n")) {
|
||||
val index = shrankSsb.indexOf("\n\n", 0, true)
|
||||
shrankSsb = SpannableStringBuilder(shrankSsb.subSequence(0, index)).append(shrankSsb.subSequence(index + "\n".length, shrankSsb.length))
|
||||
shrankSsb = SpannableStringBuilder(
|
||||
shrankSsb.subSequence(
|
||||
0,
|
||||
index
|
||||
)
|
||||
).append(shrankSsb.subSequence(index + "\n".length, shrankSsb.length))
|
||||
}
|
||||
while (expandedSsb.contains("\n\n")) {
|
||||
val index = expandedSsb.indexOf("\n\n", 0, true)
|
||||
expandedSsb = SpannableStringBuilder(expandedSsb.subSequence(0, index)).append(expandedSsb.subSequence(index + "\n".length, expandedSsb.length))
|
||||
expandedSsb = SpannableStringBuilder(
|
||||
expandedSsb.subSequence(
|
||||
0,
|
||||
index
|
||||
)
|
||||
).append(expandedSsb.subSequence(index + "\n".length, expandedSsb.length))
|
||||
}
|
||||
}
|
||||
|
||||
// 去掉多余的 P 标签换行
|
||||
if (expandedSsb.endsWith("\n", true)) {
|
||||
expandedSsb = SpannableStringBuilder((expandedSsb.subSequence(0, expandedSsb.length - "\n".length)))
|
||||
expandedSsb =
|
||||
SpannableStringBuilder((expandedSsb.subSequence(0, expandedSsb.length - "\n".length)))
|
||||
}
|
||||
|
||||
movementMethod = CustomLinkMovementMethod.getInstance()
|
||||
|
||||
shrankSsb = TextHelper.updateSpannableStringWithHighlightedSpan(context, shrankSsb, highlightedTextClickListener = null)
|
||||
expandedSsb = TextHelper.updateSpannableStringWithHighlightedSpan(context, expandedSsb, highlightedTextClickListener = null)
|
||||
shrankSsb = TextHelper.updateSpannableStringWithHighlightedSpan(
|
||||
context,
|
||||
shrankSsb,
|
||||
highlightedTextClickListener = null
|
||||
)
|
||||
expandedSsb = TextHelper.updateSpannableStringWithHighlightedSpan(
|
||||
context,
|
||||
expandedSsb,
|
||||
highlightedTextClickListener = null
|
||||
)
|
||||
setShrankTextAndExpandedText(shrankSsb, expandedSsb)
|
||||
}
|
||||
|
||||
@ -651,32 +796,41 @@ fun CharSequence.interceptUrlSpanAndRoundImageSpan(): SpannableStringBuilder {
|
||||
return SpannableStringBuilder.valueOf(this).apply {
|
||||
getSpans(0, length, URLSpan::class.java).forEach {
|
||||
setSpan(
|
||||
object : ClickableSpan() {
|
||||
override fun updateDrawState(ds: TextPaint) {
|
||||
super.updateDrawState(ds)
|
||||
ds.color = ContextCompat.getColor(HaloApp.getInstance().application, R.color.theme_font)
|
||||
ds.isUnderlineText = false
|
||||
}
|
||||
object : ClickableSpan() {
|
||||
override fun updateDrawState(ds: TextPaint) {
|
||||
super.updateDrawState(ds)
|
||||
ds.color = ContextCompat.getColor(
|
||||
HaloApp.getInstance().application,
|
||||
R.color.theme_font
|
||||
)
|
||||
ds.isUnderlineText = false
|
||||
}
|
||||
|
||||
override fun onClick(widget: View) {
|
||||
if (!DefaultUrlHandler.interceptUrl(widget.context, it.url, "")) {
|
||||
widget.context.startActivity(WebActivity.getIntent(widget.context, it.url, true))
|
||||
}
|
||||
override fun onClick(widget: View) {
|
||||
if (!DefaultUrlHandler.interceptUrl(widget.context, it.url, "")) {
|
||||
widget.context.startActivity(
|
||||
WebActivity.getIntent(
|
||||
widget.context,
|
||||
it.url,
|
||||
true
|
||||
)
|
||||
)
|
||||
}
|
||||
},
|
||||
getSpanStart(it),
|
||||
getSpanEnd(it),
|
||||
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE
|
||||
}
|
||||
},
|
||||
getSpanStart(it),
|
||||
getSpanEnd(it),
|
||||
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE
|
||||
)
|
||||
removeSpan(it)
|
||||
}
|
||||
|
||||
getSpans(0, length, ImageSpan::class.java).forEach {
|
||||
setSpan(
|
||||
CenterImageSpan(it.drawable),
|
||||
getSpanStart(it),
|
||||
getSpanEnd(it),
|
||||
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE
|
||||
CenterImageSpan(it.drawable),
|
||||
getSpanStart(it),
|
||||
getSpanEnd(it),
|
||||
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE
|
||||
)
|
||||
removeSpan(it)
|
||||
}
|
||||
@ -687,6 +841,10 @@ fun Int.toColor(): Int {
|
||||
return ContextCompat.getColor(HaloApp.getInstance().application, this)
|
||||
}
|
||||
|
||||
fun Int.toDrawable(): Drawable? {
|
||||
return ContextCompat.getDrawable(HaloApp.getInstance().application, this)
|
||||
}
|
||||
|
||||
fun Int.toResString(): String {
|
||||
return HaloApp.getInstance().application.resources.getString(this)
|
||||
}
|
||||
@ -706,11 +864,16 @@ fun SimpleDraweeView.display(url: String) {
|
||||
* DownloadEntity extension
|
||||
*/
|
||||
fun DownloadEntity.addMetaExtra(key: String, value: String?) {
|
||||
value?.let { meta[key] = value }
|
||||
value?.let {
|
||||
if (meta == null) {
|
||||
meta = hashMapOf()
|
||||
}
|
||||
meta[key] = value
|
||||
}
|
||||
}
|
||||
|
||||
fun DownloadEntity.getMetaExtra(key: String): String {
|
||||
return meta[key] ?: ""
|
||||
return meta?.get(key) ?: ""
|
||||
}
|
||||
|
||||
fun DownloadEntity.isSilentUpdate(): Boolean {
|
||||
@ -732,6 +895,9 @@ fun Context.doOnMainProcessOnly(callback: EmptyCallback) {
|
||||
doOnMainProcessOnly { callback.onCallback() }
|
||||
}
|
||||
|
||||
/**
|
||||
* 虽然现在我们没有了友盟以后只是单进程APP,但在 debug 模式下还有 whatTheStack 这个进程如果不限定主进程会出现奇奇怪怪的问题 (BroadcastReceiver相关)
|
||||
*/
|
||||
inline fun Context.doOnMainProcessOnly(f: () -> Unit) {
|
||||
val processName = PackageUtils.obtainProcessName(this)
|
||||
if (processName == null || BuildConfig.APPLICATION_ID == processName) {
|
||||
@ -773,22 +939,22 @@ inline fun testChannelOnly(f: () -> Unit) {
|
||||
* 倒计时,单位s
|
||||
*/
|
||||
inline fun countDownTimer(
|
||||
timeInSeconds: Long,
|
||||
crossinline block: (finish: Boolean, remainingTime: Long) -> Unit
|
||||
timeInSeconds: Long,
|
||||
crossinline block: (finish: Boolean, remainingTime: Long) -> Unit
|
||||
): Disposable {
|
||||
var subscribe: Disposable? = null
|
||||
subscribe = Observable.interval(0, 1000, TimeUnit.MILLISECONDS)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe {
|
||||
if (it < timeInSeconds) {
|
||||
block.invoke(false, timeInSeconds - it)
|
||||
} else {
|
||||
block.invoke(true, 0)
|
||||
if (subscribe != null && !subscribe!!.isDisposed) {
|
||||
subscribe?.dispose()
|
||||
}
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe {
|
||||
if (it < timeInSeconds) {
|
||||
block.invoke(false, timeInSeconds - it)
|
||||
} else {
|
||||
block.invoke(true, 0)
|
||||
if (subscribe != null && !subscribe!!.isDisposed) {
|
||||
subscribe?.dispose()
|
||||
}
|
||||
}
|
||||
}
|
||||
return subscribe
|
||||
}
|
||||
|
||||
@ -797,17 +963,17 @@ inline fun countDownTimer(
|
||||
* @start 起始时间
|
||||
*/
|
||||
inline fun countUpTimer(
|
||||
start: Long,
|
||||
period: Long = 1000,
|
||||
crossinline block: (millisUntilFinished: Long) -> Unit
|
||||
start: Long,
|
||||
period: Long = 1000,
|
||||
crossinline block: (millisUntilFinished: Long) -> Unit
|
||||
): Disposable {
|
||||
var startTime = start
|
||||
return Observable.interval(0, period, TimeUnit.MILLISECONDS)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe {
|
||||
startTime += period
|
||||
block.invoke(startTime)
|
||||
}
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe {
|
||||
startTime += period
|
||||
block.invoke(startTime)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -815,10 +981,10 @@ inline fun countUpTimer(
|
||||
*/
|
||||
inline fun rxTimer(interval: Long, crossinline block: (times: Long) -> Unit): Disposable {
|
||||
return Observable.interval(0, interval, TimeUnit.MILLISECONDS)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe {
|
||||
block.invoke(it)
|
||||
}
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe {
|
||||
block.invoke(it)
|
||||
}
|
||||
}
|
||||
|
||||
fun LottieAnimationView.doOnAnimationEnd(action: () -> Unit) {
|
||||
@ -884,13 +1050,17 @@ fun List<String>?.checkSameFromStringArray(check2: List<String>?): Boolean {
|
||||
fun EditText.showKeyBoard() {
|
||||
this.postDelayed({
|
||||
this.requestFocus()
|
||||
val inputMethodManager = context.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
|
||||
val inputMethodManager =
|
||||
context.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
|
||||
inputMethodManager.showSoftInput(this, 0)
|
||||
}, 300)
|
||||
}
|
||||
|
||||
|
||||
fun SeekBar.doOnSeekBarChangeListener(progressChange: ((progress: Int) -> Unit)? = null, onStopTrackingTouch: (() -> Unit)? = null) {
|
||||
fun SeekBar.doOnSeekBarChangeListener(
|
||||
progressChange: ((progress: Int) -> Unit)? = null,
|
||||
onStopTrackingTouch: (() -> Unit)? = null
|
||||
) {
|
||||
this.setOnSeekBarChangeListener(object : SeekBar.OnSeekBarChangeListener {
|
||||
override fun onProgressChanged(seekBar: SeekBar?, progress: Int, fromUser: Boolean) {
|
||||
progressChange?.invoke(progress)
|
||||
@ -909,13 +1079,28 @@ fun SeekBar.doOnSeekBarChangeListener(progressChange: ((progress: Int) -> Unit)?
|
||||
fun <T> observableToMain(): ObservableTransformer<T, T> {
|
||||
return ObservableTransformer { upstream ->
|
||||
upstream.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
}
|
||||
}
|
||||
|
||||
fun <T> singleToMain(): SingleTransformer<T, T> {
|
||||
return SingleTransformer { upstream ->
|
||||
upstream.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
}
|
||||
}
|
||||
|
||||
fun clickToastByStatus(status: String, action: () -> Unit) {
|
||||
when (status) {
|
||||
"pending" -> ToastUtils.showToast("内容审核中")
|
||||
"fail" -> ToastUtils.showToast("内容审核不通过")
|
||||
else -> action.invoke()
|
||||
}
|
||||
}
|
||||
|
||||
fun View.getBitmapFromView(): Bitmap? {
|
||||
val bitmap = Bitmap.createBitmap(this.width, this.height, Bitmap.Config.ARGB_8888)
|
||||
val canvas = Canvas(bitmap)
|
||||
this.draw(canvas)
|
||||
return bitmap
|
||||
}
|
||||
130
app/src/main/java/com/gh/common/util/FloatingBackViewManager.kt
Normal file
130
app/src/main/java/com/gh/common/util/FloatingBackViewManager.kt
Normal file
@ -0,0 +1,130 @@
|
||||
package com.gh.common.util
|
||||
|
||||
import android.app.Activity
|
||||
import android.os.Build
|
||||
import android.view.Gravity
|
||||
import android.widget.TextView
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.energy.EnergyCenterActivity
|
||||
import com.lightgame.utils.Util_System_Keyboard
|
||||
import com.lzf.easyfloat.EasyFloat
|
||||
import com.lzf.easyfloat.enums.ShowPattern
|
||||
import com.lzf.easyfloat.enums.SidePattern
|
||||
|
||||
/**
|
||||
* 返回小浮窗管理类
|
||||
* 支持两种类型,网页活动(type_activity) 和 积分任务(type_task)
|
||||
*
|
||||
* 两种浮窗冲突,显示其中一个的时候就会把另一个判定为隐藏
|
||||
*/
|
||||
object FloatingBackViewManager {
|
||||
|
||||
const val TYPE_ACTIVITY = "type_activity"
|
||||
const val TYPE_TASK = "type_task"
|
||||
|
||||
private const val FLOATING_BACK_VIEW = "floating_back_view"
|
||||
|
||||
private var mType = ""
|
||||
private var mActivityUrl = ""
|
||||
private var mLastPositionY = 114F.dip2px()
|
||||
|
||||
/**
|
||||
* 显示返回小浮窗
|
||||
*/
|
||||
fun showBackView(activity: Activity) {
|
||||
// 不支持 Android 4.1 的设备
|
||||
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.JELLY_BEAN) return
|
||||
|
||||
EasyFloat.with(activity)
|
||||
.setLayout(R.layout.layout_task_back)
|
||||
.setTag(FLOATING_BACK_VIEW)
|
||||
.setAnimator(null)
|
||||
.setGravity(Gravity.TOP.xor(Gravity.START), 0, mLastPositionY)
|
||||
.setSidePattern(SidePattern.LEFT)
|
||||
.setShowPattern(ShowPattern.CURRENT_ACTIVITY)
|
||||
.registerCallback {
|
||||
createResult { _, _, view ->
|
||||
val titleView = view?.findViewById<TextView>(R.id.titleTv)
|
||||
|
||||
view?.setOnClickListener {
|
||||
// 先收起键盘
|
||||
Util_System_Keyboard.hideSoftKeyboard(activity)
|
||||
|
||||
if (mType == TYPE_ACTIVITY) {
|
||||
titleView?.text = "返回活动"
|
||||
|
||||
DirectUtils.directToWebView(activity, mActivityUrl, ("返回活动浮窗"))
|
||||
} else if (mType == TYPE_TASK) {
|
||||
titleView?.text = "返回任务"
|
||||
|
||||
activity.startActivity(EnergyCenterActivity.getIntent(activity))
|
||||
}
|
||||
|
||||
disableBackView()
|
||||
}
|
||||
}
|
||||
|
||||
dragEnd { view ->
|
||||
val statusBarHeight = DisplayUtils.getStatusBarHeight(activity.resources)
|
||||
|
||||
// 记录停止拖动的最后位置
|
||||
val outLocation = IntArray(2)
|
||||
view.getLocationInWindow(outLocation)
|
||||
val yOffset = outLocation[1]
|
||||
|
||||
if (yOffset <= statusBarHeight) {
|
||||
// 判断状态栏是否被消费
|
||||
if (yOffset == view.y.toInt()) {
|
||||
view.y = statusBarHeight.toFloat()
|
||||
} else {
|
||||
view.y = 0F
|
||||
}
|
||||
}
|
||||
|
||||
mLastPositionY = yOffset
|
||||
}
|
||||
}
|
||||
.show()
|
||||
}
|
||||
|
||||
/**
|
||||
* 隐藏返回小浮窗
|
||||
*/
|
||||
@JvmStatic
|
||||
fun dismissBackView(activity: Activity) {
|
||||
EasyFloat.dismiss(activity, FLOATING_BACK_VIEW)
|
||||
}
|
||||
|
||||
fun getType(): String {
|
||||
return mType
|
||||
}
|
||||
|
||||
/**
|
||||
* 启用返回小浮窗
|
||||
* @param type 类型
|
||||
* @param activityUrl 类型为活动的时候用的地址
|
||||
*/
|
||||
fun enableBackView(type: String, activityUrl: String = "") {
|
||||
mType = type
|
||||
mActivityUrl = activityUrl
|
||||
}
|
||||
|
||||
/**
|
||||
* 停用返回小浮窗
|
||||
* @param type 类型
|
||||
* @param activityUrl 类型为活动的时候用的地址
|
||||
*/
|
||||
@JvmStatic
|
||||
fun disableBackView() {
|
||||
mType = ""
|
||||
mActivityUrl = ""
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回小浮窗类型是否为活动
|
||||
*/
|
||||
fun isTypeActivity() : Boolean {
|
||||
return mType == TYPE_ACTIVITY
|
||||
}
|
||||
|
||||
}
|
||||
@ -93,6 +93,13 @@ object GameSubstituteRepositoryHelper {
|
||||
val game = collection.data?.find { game -> isThisGameUnique(game, gameIdList) }
|
||||
game?.let {
|
||||
collection.data?.remove(game)
|
||||
|
||||
collection.data?.size?.let { remainingSize ->
|
||||
// 记录被替换游戏的数量,10个以上的时候触发
|
||||
if (remainingSize % 10 == 0) {
|
||||
SentryHelper.onEvent("game_substitute", "substituted_size", "${50 - remainingSize}")
|
||||
}
|
||||
}
|
||||
// 产品说要记录补充专题的曝光数,所以这个游戏附带了所在专题的名字
|
||||
game.subjectName = collection.name
|
||||
return game
|
||||
|
||||
@ -78,6 +78,9 @@ public class GameUtils {
|
||||
int pluginCount = 0; // 可插件化数量
|
||||
int updateCount = 0; // 可更新数量
|
||||
int installCount = 0; // 已安装数量
|
||||
|
||||
boolean isRelatedEmulatorInstalled = false; // 若该游戏是模拟器游戏时其对应的模拟器是否已经安装
|
||||
|
||||
DownloadEntity downloadEntity;
|
||||
Object gh_id;
|
||||
apkFor:
|
||||
@ -113,7 +116,10 @@ public class GameUtils {
|
||||
&& !PackageUtils.isSignedByGh(context, apkEntity.getPackageName())
|
||||
&& apkEntity.isShowPlugin(pluginLocation)) {
|
||||
pluginCount++;
|
||||
} else if (gh_id == null || gh_id.equals(gameEntity.getId())) {
|
||||
} else if (gh_id == null
|
||||
|| gh_id.equals(gameEntity.getId())
|
||||
// 当使用镜像时,可能会存在镜像 gh_id 与当前游戏 id 不一样的情况,这时也让它通过,避免装完还是显示`下载`
|
||||
|| gameEntity.shouldUseMirrorInfo()) {
|
||||
installCount++;
|
||||
}
|
||||
}
|
||||
@ -123,20 +129,26 @@ public class GameUtils {
|
||||
boolean isInstalled = PackageUtils.isInstalledFromAllPackage(context, gameEntity.getSimulator().getApk().getPackageName());
|
||||
if (isInstalled) {
|
||||
installCount++;
|
||||
isRelatedEmulatorInstalled = true;
|
||||
} else {
|
||||
doneCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (installCount != 0) {
|
||||
|
||||
if (isRelatedEmulatorInstalled && doneCount != 0) {
|
||||
return context.getString(R.string.launch);
|
||||
}
|
||||
|
||||
if (doneCount != 0) {
|
||||
return context.getString(R.string.install);
|
||||
} else if (pluginCount != 0 && !SimulatorGameManager.isSimulatorGame(gameEntity)) {
|
||||
return context.getString(R.string.pluggable);
|
||||
} else if (updateCount != 0 && !SimulatorGameManager.isSimulatorGame(gameEntity)) {
|
||||
return context.getString(R.string.update);
|
||||
} else if (doneCount != 0) {
|
||||
return context.getString(R.string.install);
|
||||
} else if (installCount != 0) {
|
||||
return context.getString(R.string.launch);
|
||||
} else if (gameEntity.getVersionNumber().contains("无版号") && Config.isGameDomeSwitchOpen() && !SimulatorGameManager.isSimulatorGame(gameEntity)) {
|
||||
return context.getString(R.string.attempt);
|
||||
} else {
|
||||
|
||||
@ -34,6 +34,10 @@ import java.util.TimeZone;
|
||||
public class GameViewUtils {
|
||||
|
||||
public static void setLabelList(Context context, LinearLayout labelLayout, List<TagStyleEntity> tagStyle) {
|
||||
setLabelList(context, labelLayout, tagStyle, 8);
|
||||
}
|
||||
|
||||
public static void setLabelList(Context context, LinearLayout labelLayout, List<TagStyleEntity> tagStyle, int margin) {
|
||||
labelLayout.removeAllViews();
|
||||
if (tagStyle == null || tagStyle.isEmpty()) {
|
||||
// 没有数据的话默认不显示
|
||||
@ -42,7 +46,7 @@ public class GameViewUtils {
|
||||
// labelLayout.addView(getNewGameTagView(context, tagEntity, 0));
|
||||
} else {
|
||||
for (int i = 0, size = tagStyle.size(); i < size; i++) {
|
||||
View view = getNewGameTagView(context, tagStyle.get(i), i == size - 1 ? 0 : DisplayUtils.dip2px(context, 8));
|
||||
View view = getNewGameTagView(context, tagStyle.get(i), i == size - 1 ? 0 : DisplayUtils.dip2px(context, margin));
|
||||
labelLayout.addView(view);
|
||||
if (labelLayout.getChildCount() == 3) {
|
||||
break;
|
||||
|
||||
@ -24,27 +24,39 @@ object HomePluggableHelper {
|
||||
val apkList = gameEntity.getApk()
|
||||
if (apkList.isNotEmpty()) {
|
||||
val apk = apkList.first()
|
||||
val filterData = mHomePluggableFilterDao.getDataByPkgName(apk.packageName)
|
||||
if (filterData?.active == true) {
|
||||
val filterTag = filterData.tag
|
||||
return filterTag != "never" && apk.version != filterTag
|
||||
tryCatchInRelease {
|
||||
val filterData = mHomePluggableFilterDao.getDataByPkgName(apk.packageName)
|
||||
if (filterData?.active == true) {
|
||||
val filterTag = filterData.tag
|
||||
return filterTag != "never" && apk.version != filterTag
|
||||
}
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getPermanentInactivePluggablePackage() = mHomePluggableFilterDao.getDataByTag("never")
|
||||
fun getPermanentInactivePluggablePackage(): List<HomePluggableFilterEntity>? {
|
||||
tryCatchInRelease {
|
||||
return mHomePluggableFilterDao.getDataByTag("never")
|
||||
}
|
||||
return emptyList()
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun activationFilterData() {
|
||||
val filterList = mHomePluggableFilterDao.getDataByActive(false)
|
||||
try {
|
||||
val filterList = mHomePluggableFilterDao.getDataByActive(false)
|
||||
|
||||
if (filterList != null) {
|
||||
for (entity in filterList) {
|
||||
entity.active = true
|
||||
if (filterList != null) {
|
||||
for (entity in filterList) {
|
||||
entity.active = true
|
||||
}
|
||||
mHomePluggableFilterDao.addData(filterList)
|
||||
}
|
||||
tryCatchInRelease { mHomePluggableFilterDao.addData(filterList) }
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
toastInInternalRelease("数据库/磁盘已满,插件筛选失败")
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -8,6 +8,7 @@ import android.graphics.drawable.Animatable
|
||||
import android.graphics.drawable.ColorDrawable
|
||||
import android.net.Uri
|
||||
import android.os.Build
|
||||
import android.os.Environment
|
||||
import androidx.annotation.DrawableRes
|
||||
import androidx.core.content.ContextCompat
|
||||
import com.facebook.common.executors.CallerThreadExecutor
|
||||
@ -19,20 +20,24 @@ import com.facebook.drawee.controller.ControllerListener
|
||||
import com.facebook.drawee.drawable.ScalingUtils
|
||||
import com.facebook.drawee.generic.GenericDraweeHierarchyBuilder
|
||||
import com.facebook.drawee.view.SimpleDraweeView
|
||||
import com.facebook.imagepipeline.common.ResizeOptions
|
||||
import com.facebook.imagepipeline.datasource.BaseBitmapDataSubscriber
|
||||
import com.facebook.imagepipeline.image.CloseableImage
|
||||
import com.facebook.imagepipeline.image.ImageInfo
|
||||
import com.facebook.imagepipeline.request.ImageRequest
|
||||
import com.facebook.imagepipeline.request.ImageRequestBuilder
|
||||
import com.facebook.imagepipeline.request.Postprocessor
|
||||
import com.gh.common.constant.Config
|
||||
import com.gh.common.runOnUiThread
|
||||
import com.gh.common.structure.FixedSizeLinkedHashSet
|
||||
import com.gh.gamecenter.R
|
||||
import com.halo.assistant.HaloApp
|
||||
import com.lightgame.utils.Utils
|
||||
import com.squareup.picasso.Picasso
|
||||
import io.reactivex.Single
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
import java.io.ByteArrayOutputStream
|
||||
import java.io.*
|
||||
|
||||
object ImageUtils {
|
||||
|
||||
@ -42,6 +47,8 @@ object ImageUtils {
|
||||
private val LARGE_GIF_SIZE = 80F.dip2px()
|
||||
private val STANDARD_GIF_SIZE = 60F.dip2px()
|
||||
|
||||
const val TARGET_WIDTH = R.dimen.width_placeholder
|
||||
|
||||
private val mImageUrlCacheSet by lazy { FixedSizeLinkedHashSet<String>(maxSize = 200) }
|
||||
|
||||
@JvmStatic
|
||||
@ -85,8 +92,14 @@ object ImageUtils {
|
||||
@JvmStatic
|
||||
fun addLimitWidth(imageUrl: String?, width: Int?): String? {
|
||||
val jpegConfig = Config.getSettings()?.image?.oss?.jpeg
|
||||
if (jpegConfig != null) {
|
||||
return "$imageUrl$jpegConfig,w_$width"
|
||||
val webpConfig = Config.getSettings()?.image?.oss?.webp
|
||||
?: Config.getSettings()?.image?.oss?.gif
|
||||
if (imageUrl?.contains("?x-oss-process") == false && jpegConfig != null) {
|
||||
return if (width == 0 || width == null) {
|
||||
"$imageUrl$webpConfig"
|
||||
} else {
|
||||
"$imageUrl$jpegConfig,w_$width"
|
||||
}
|
||||
}
|
||||
return imageUrl
|
||||
}
|
||||
@ -286,15 +299,20 @@ object ImageUtils {
|
||||
|
||||
/**
|
||||
* 规则 width>0 Wifi/4G:x2 traffic:x1
|
||||
* 统一加载 webp 忽略掉第二种方案
|
||||
* 第一种方案:通过LayoutParams获取 可以快速(无延迟)获取宽高,但是无法获取wrap_content和match_parent的View
|
||||
* 第二种方案(备用方案):有延迟,View的宽高需要在Measure过程后才能确定,能够在这里获取到正确的宽高
|
||||
* ~~第二种方案(备用方案):有延迟,View的宽高需要在Measure过程后才能确定,能够在这里获取到正确的宽高~~
|
||||
* @param isAutoPlayGif 是否禁止播放动图
|
||||
*/
|
||||
@JvmStatic
|
||||
fun display(view: SimpleDraweeView?, url: String?, isAutoPlayGif: Boolean = true) {
|
||||
fun display(view: SimpleDraweeView?,
|
||||
url: String?,
|
||||
isAutoPlayGif: Boolean = true,
|
||||
processor: Postprocessor? = null) {
|
||||
if (url == null) return
|
||||
|
||||
val width = view?.layoutParams?.width
|
||||
// 部分自适应宽高图片需要一个 TARGET_WIDTH 来避免加载过小图片
|
||||
val width = (view?.getTag(TARGET_WIDTH) as? Int) ?: view?.width?.coerceAtLeast(view.layoutParams?.width ?: 0)
|
||||
val height = view?.layoutParams?.height
|
||||
|
||||
var lowResUrl = ""
|
||||
@ -310,40 +328,47 @@ object ImageUtils {
|
||||
}
|
||||
|
||||
val loadImageClosure: (autoPlay: Boolean, highResUrl: String, lowResUrl: String) -> Unit = { autoPlay, hUrl, lUrl ->
|
||||
view?.controller = Fresco.newDraweeControllerBuilder()
|
||||
.setImageRequest(ImageRequest.fromUri(hUrl))
|
||||
val imageRequest = ImageRequestBuilder.newBuilderWithSource(Uri.parse(hUrl))
|
||||
.setPostprocessor(processor)
|
||||
.build()
|
||||
val controller = Fresco.newDraweeControllerBuilder()
|
||||
.setImageRequest(imageRequest)
|
||||
.apply {
|
||||
if (lUrl.isNotEmpty()
|
||||
&& lUrl != hUrl
|
||||
&& hUrl != view?.getTag(R.string.highResImageTag)) {
|
||||
lowResImageRequest = ImageRequest.fromUri(lUrl)
|
||||
lowResImageRequest = ImageRequestBuilder.newBuilderWithSource(Uri.parse(lUrl))
|
||||
.setPostprocessor(processor)
|
||||
.build()
|
||||
}
|
||||
autoPlayAnimations = autoPlay
|
||||
}
|
||||
.build()
|
||||
view?.controller = controller
|
||||
|
||||
view?.setTag(R.string.highResImageTag, highResUrl)
|
||||
}
|
||||
|
||||
val shouldLoadAsGif = url.endsWith(".gif") && isAutoPlayGif && view?.getTag(R.id.tag_show_gif) != false
|
||||
// 低于 2G 运行内存的不加载 gif
|
||||
val shouldLoadAsGif = url.endsWith(".gif")
|
||||
&& isAutoPlayGif
|
||||
&& (HaloApp.getInstance().deviceRamSize == 0L || HaloApp.getInstance().deviceRamSize > 2500)
|
||||
&& view?.getTag(R.id.tag_show_gif) != false
|
||||
|
||||
if (shouldLoadAsGif && view?.tag == url) return
|
||||
|
||||
if (width != null && width > 0) {
|
||||
highResUrl = if (shouldLoadAsGif) {
|
||||
resizeGif(url, width, height ?: 0)
|
||||
} else {
|
||||
getTransformLimitUrl(url, width, view.context) ?: ""
|
||||
}
|
||||
if (!shouldLoadAsGif) {
|
||||
highResUrl = getTransformLimitUrl(url, width ?: 0, view?.context) ?: ""
|
||||
loadImageClosure(shouldLoadAsGif, highResUrl, lowResUrl)
|
||||
} else {
|
||||
view?.post {
|
||||
highResUrl = if (shouldLoadAsGif) {
|
||||
resizeGif(url, view.width, height ?: 0)
|
||||
} else {
|
||||
getTransformLimitUrl(url, view.width, view.context) ?: ""
|
||||
}
|
||||
if (width != null && width > 0) {
|
||||
highResUrl = resizeGif(url, view!!.width, height ?: 0)
|
||||
loadImageClosure(shouldLoadAsGif, highResUrl, lowResUrl)
|
||||
} else {
|
||||
view?.post {
|
||||
highResUrl = resizeGif(url, view.width, height ?: 0)
|
||||
loadImageClosure(shouldLoadAsGif, highResUrl, lowResUrl)
|
||||
}
|
||||
}
|
||||
}
|
||||
view?.tag = url
|
||||
@ -352,25 +377,27 @@ object ImageUtils {
|
||||
// Wifi/4G:x2 traffic:x1
|
||||
@JvmStatic
|
||||
fun getTransformLimitUrl(url: String?, width: Int?, context: Context?): String? {
|
||||
var transformUrl: String? = url
|
||||
val transformUrl: String?
|
||||
if (width != null && width > 0) {
|
||||
// 加载大小是实际 ImageView 大小两倍的图片真的有意义吗?
|
||||
val transformUrlX2 = addLimitWidth(url, width * 2)
|
||||
val transformUrlX1 = addLimitWidth(url, width)
|
||||
// 当网络为 WIFI 或 4G, 且系统版本大于 5.0 && 手机内存大于 1G 才用高清图片
|
||||
if (NetworkUtils.isWifiOr4GConnected(context)
|
||||
// 当网络为 WIFI 或 4G, 且系统版本大于 5.0 && 手机内存大于 4G 才用超高清图片 (x2)
|
||||
transformUrl = if (NetworkUtils.isWifiOr4GConnected(context)
|
||||
&& Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP
|
||||
&& HaloApp.getInstance().deviceRamSize > 1024) {
|
||||
transformUrl = transformUrlX2
|
||||
&& HaloApp.getInstance().deviceRamSize > 4500) {
|
||||
transformUrlX2
|
||||
} else {
|
||||
// 检查X2大图是否被缓存
|
||||
if (Fresco.getImagePipeline().isInBitmapMemoryCache(Uri.parse(transformUrlX2)) ||
|
||||
Fresco.getImagePipeline().isInDiskCacheSync(Uri.parse(transformUrlX2))) {
|
||||
transformUrl = transformUrlX2
|
||||
transformUrlX2
|
||||
} else {
|
||||
transformUrl = transformUrlX1
|
||||
transformUrlX1
|
||||
}
|
||||
}
|
||||
} else {
|
||||
transformUrl = addLimitWidth(url, null)
|
||||
}
|
||||
addCachedUrl(transformUrl ?: "")
|
||||
return transformUrl
|
||||
@ -383,9 +410,7 @@ object ImageUtils {
|
||||
if (width != null && width > 0) {
|
||||
view.setImageURI(addLimitWidth(url, width * 2))
|
||||
} else {
|
||||
view?.post {
|
||||
view.setImageURI(addLimitWidth(url, view.width * 2))
|
||||
}
|
||||
view?.setImageURI(addLimitWidth(url, view.width * 2))
|
||||
}
|
||||
}
|
||||
|
||||
@ -395,6 +420,18 @@ object ImageUtils {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取已缓存的图片地址,不区分质量,暂时只供查看大图页面使用
|
||||
*/
|
||||
fun getCachedUrl(url: String): String {
|
||||
for (decoratedUrl in mImageUrlCacheSet) {
|
||||
if (decoratedUrl.contains(url)) {
|
||||
return decoratedUrl
|
||||
}
|
||||
}
|
||||
return url
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun bmpToByteArray(bmp: Bitmap, needRecycle: Boolean): ByteArray {
|
||||
val output = ByteArrayOutputStream()
|
||||
@ -419,6 +456,19 @@ object ImageUtils {
|
||||
draweeView.setImageURI("res:///" + res)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun displayResizeMedia(draweeView: SimpleDraweeView, url: String, resizeWidthDp: Int, resizeHeightDp: Int) {
|
||||
val request = ImageRequestBuilder.newBuilderWithSource(Uri.parse(url))
|
||||
.setResizeOptions(ResizeOptions(resizeWidthDp, resizeHeightDp))
|
||||
.build()
|
||||
val controller = Fresco.newDraweeControllerBuilder()
|
||||
.setImageRequest(request)
|
||||
.setOldController(draweeView.controller)
|
||||
.setControllerListener(BaseControllerListener<ImageInfo>())
|
||||
.build()
|
||||
draweeView.controller = controller
|
||||
}
|
||||
|
||||
//预加载图片
|
||||
@JvmStatic
|
||||
fun prefetchToDiskCache(url: String) {
|
||||
@ -444,11 +494,75 @@ object ImageUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public interface OnImageloadListener {
|
||||
interface OnImageloadListener {
|
||||
fun onLoadFinal(imageInfo: ImageInfo?)
|
||||
}
|
||||
|
||||
fun getVideoSnapshot(videoUrl: String, progress: Long): String {
|
||||
return "$videoUrl?x-oss-process=video/snapshot,t_$progress,f_jpg,w_0,h_0"
|
||||
return "$videoUrl?x-oss-process=video/snapshot,t_$progress,f_jpg,w_0,h_0,ar_auto"
|
||||
}
|
||||
|
||||
/**
|
||||
* 虽然在 Application 里有使用子线程初始化但有可能出现初始化超时(卡住?)的情况,
|
||||
* 这里反射获取 sDraweecontrollerbuildersupplier 根据是否有值确定是否被初始化了
|
||||
*/
|
||||
@JvmStatic
|
||||
fun isFrescoInitialized(): Boolean {
|
||||
val clazz = SimpleDraweeView::class.java
|
||||
return try {
|
||||
val field =
|
||||
clazz.getDeclaredField("sDraweecontrollerbuildersupplier")
|
||||
field.isAccessible = true
|
||||
val obj = field[SimpleDraweeView::class.java]
|
||||
obj != null
|
||||
} catch (ignore: java.lang.Exception) {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 将图片保存到外部存储空间
|
||||
* @param imageFile 内部存储的文件
|
||||
* @param url 图片原地址,用来截取当图片名称用的
|
||||
* @param useRandomName 是否使用随机名称
|
||||
*/
|
||||
fun saveImageToFile(imageFile: File, url: String?, useRandomName: Boolean = false) {
|
||||
var `in`: InputStream? = null
|
||||
var out: OutputStream? = null
|
||||
try {
|
||||
val fileName: String = if (useRandomName) {
|
||||
MD5Utils.getContentMD5(System.currentTimeMillis().toString()) + ".png"
|
||||
} else {
|
||||
Uri.parse(url).lastPathSegment.toString()
|
||||
}
|
||||
val savePath = Environment.getExternalStorageDirectory().absolutePath + "/Pictures/ghzhushou/"
|
||||
val file = File(savePath)
|
||||
if (!file.exists()) {
|
||||
file.mkdirs()
|
||||
}
|
||||
val dst = File(savePath, fileName)
|
||||
if (dst.exists()) {
|
||||
dst.delete()
|
||||
}
|
||||
`in` = FileInputStream(imageFile)
|
||||
out = FileOutputStream(dst)
|
||||
val buf = ByteArray(1024)
|
||||
var len: Int
|
||||
while (`in`.read(buf).also { len = it } > 0) {
|
||||
out.write(buf, 0, len)
|
||||
}
|
||||
|
||||
runOnUiThread {
|
||||
ToastUtils.toast("图片已保存到/Pictures/ghzhushou/")
|
||||
}
|
||||
MessageShareUtils.refreshImage(HaloApp.getInstance(), dst)
|
||||
} catch (e: Exception) {
|
||||
Utils.log("图片保存失败:$e")
|
||||
} finally {
|
||||
tryWithDefaultCatch {
|
||||
out?.close()
|
||||
`in`?.close()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -18,11 +18,11 @@ public class Installation {
|
||||
private static String sID = null;
|
||||
|
||||
public synchronized static String getUUID(Context context) {
|
||||
String imei = MetaUtil.getIMEI();
|
||||
String imei = MetaUtil.getBase64EncodedIMEI();
|
||||
if (!TextUtils.isEmpty(imei)) {
|
||||
return imei;
|
||||
}
|
||||
String android_id = MetaUtil.getAndroidId();
|
||||
String android_id = MetaUtil.getBase64EncodedAndroidId();
|
||||
if (!TextUtils.isEmpty(android_id)) {
|
||||
return android_id;
|
||||
}
|
||||
|
||||
157
app/src/main/java/com/gh/common/util/IntegralLogHelper.kt
Normal file
157
app/src/main/java/com/gh/common/util/IntegralLogHelper.kt
Normal file
@ -0,0 +1,157 @@
|
||||
package com.gh.common.util
|
||||
|
||||
import com.gh.common.loghub.LoghubUtils.log
|
||||
import com.gh.common.tracker.Tracker.launchId
|
||||
import com.gh.common.tracker.Tracker.sessionId
|
||||
import com.lightgame.utils.Utils
|
||||
import org.json.JSONObject
|
||||
|
||||
object IntegralLogHelper {
|
||||
|
||||
fun log(event: String, location: String) = log(event, location, null)
|
||||
|
||||
fun log(event: String, location: String, entrance: String? = null) {
|
||||
val json = JSONObject().apply {
|
||||
tryWithDefaultCatch {
|
||||
put("meta", LogUtils.getMetaObject())
|
||||
put("event", event)
|
||||
put("location", location)
|
||||
put("timestamp", System.currentTimeMillis() / 1000)
|
||||
put("launch_id", launchId)
|
||||
put("session_id", sessionId)
|
||||
entrance?.let {
|
||||
put("entrance", it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
debugOnly {
|
||||
Utils.log("LogUtils->$json")
|
||||
}
|
||||
log(json, "score", false)
|
||||
}
|
||||
|
||||
fun logTask(event: String, location: String, jobId: String, jobName: String, jobType: String) {
|
||||
val json = JSONObject().apply {
|
||||
tryWithDefaultCatch {
|
||||
put("meta", LogUtils.getMetaObject())
|
||||
put("event", event)
|
||||
put("location", location)
|
||||
put("timestamp", System.currentTimeMillis() / 1000)
|
||||
put("launch_id", launchId)
|
||||
put("session_id", sessionId)
|
||||
put("job_id", jobId)
|
||||
put("job_name", jobName)
|
||||
put("job_type", jobType)
|
||||
}
|
||||
}
|
||||
|
||||
debugOnly {
|
||||
Utils.log("LogUtils->$json")
|
||||
}
|
||||
log(json, "score", false)
|
||||
}
|
||||
|
||||
fun logCommodityCategory(event: String, location: String, entrance: String, categoryId: String, categoryName: String) {
|
||||
val json = JSONObject().apply {
|
||||
tryWithDefaultCatch {
|
||||
put("meta", LogUtils.getMetaObject())
|
||||
put("event", event)
|
||||
put("location", location)
|
||||
put("timestamp", System.currentTimeMillis() / 1000)
|
||||
put("launch_id", launchId)
|
||||
put("session_id", sessionId)
|
||||
put("entrance", entrance)
|
||||
put("goods_species_id", categoryId)
|
||||
put("goods_species_name", categoryName)
|
||||
}
|
||||
}
|
||||
|
||||
debugOnly {
|
||||
Utils.log("LogUtils->$json")
|
||||
}
|
||||
log(json, "score", false)
|
||||
}
|
||||
|
||||
fun logCommodity(event: String, location: String, commodityId: String, categoryId: String, categoryName: String) {
|
||||
val json = JSONObject().apply {
|
||||
tryWithDefaultCatch {
|
||||
put("meta", LogUtils.getMetaObject())
|
||||
put("event", event)
|
||||
put("location", location)
|
||||
put("timestamp", System.currentTimeMillis() / 1000)
|
||||
put("launch_id", launchId)
|
||||
put("session_id", sessionId)
|
||||
put("goods_id", commodityId)
|
||||
put("goods_species_id", categoryId)
|
||||
put("goods_species_name", categoryName)
|
||||
}
|
||||
}
|
||||
|
||||
debugOnly {
|
||||
Utils.log("LogUtils->$json")
|
||||
}
|
||||
log(json, "score", false)
|
||||
}
|
||||
|
||||
fun logEnergyRange(event: String, location: String, range: String) {
|
||||
val json = JSONObject().apply {
|
||||
tryWithDefaultCatch {
|
||||
put("meta", LogUtils.getMetaObject())
|
||||
put("event", event)
|
||||
put("location", location)
|
||||
put("timestamp", System.currentTimeMillis() / 1000)
|
||||
put("launch_id", launchId)
|
||||
put("session_id", sessionId)
|
||||
put("energy_range", range)
|
||||
}
|
||||
}
|
||||
|
||||
debugOnly {
|
||||
Utils.log("LogUtils->$json")
|
||||
}
|
||||
log(json, "score", false)
|
||||
}
|
||||
|
||||
fun logPendent(event: String, location: String, pendentId: String, pendentType: String? = null) {
|
||||
val json = JSONObject().apply {
|
||||
tryWithDefaultCatch {
|
||||
put("meta", LogUtils.getMetaObject())
|
||||
put("event", event)
|
||||
put("location", location)
|
||||
put("timestamp", System.currentTimeMillis() / 1000)
|
||||
put("launch_id", launchId)
|
||||
put("session_id", sessionId)
|
||||
put("pendant_id", pendentId)
|
||||
pendentType?.run {
|
||||
put("pendant_type", this)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
debugOnly {
|
||||
Utils.log("LogUtils->$json")
|
||||
}
|
||||
log(json, "score", false)
|
||||
}
|
||||
|
||||
fun logInviteResult(result: String, type: String? = null) {
|
||||
val json = JSONObject().apply {
|
||||
tryWithDefaultCatch {
|
||||
put("meta", LogUtils.getMetaObject())
|
||||
put("event", "invite_result")
|
||||
put("location", "邀请途径面板")
|
||||
put("timestamp", System.currentTimeMillis() / 1000)
|
||||
put("launch_id", launchId)
|
||||
put("session_id", sessionId)
|
||||
put("invitation_result", result)
|
||||
put("invitation_type", type)
|
||||
}
|
||||
}
|
||||
|
||||
debugOnly {
|
||||
Utils.log("LogUtils->$json")
|
||||
}
|
||||
log(json, "score", false)
|
||||
}
|
||||
}
|
||||
@ -4,10 +4,16 @@ import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.gh.gamecenter.NormalActivity;
|
||||
import com.gh.gamecenter.SingletonWebActivity;
|
||||
import com.gh.gamecenter.WebActivity;
|
||||
import com.gh.gamecenter.category.CategoryListActivity;
|
||||
import com.gh.gamecenter.entity.CategoryEntity;
|
||||
import com.halo.assistant.fragment.WebFragment;
|
||||
|
||||
/**
|
||||
* @author CsHeng
|
||||
@ -17,7 +23,6 @@ import com.gh.gamecenter.entity.CategoryEntity;
|
||||
|
||||
public class IntentUtils {
|
||||
|
||||
|
||||
public static Intent getWifiIntent() {
|
||||
return new Intent("android.settings.WIFI_SETTINGS");
|
||||
}
|
||||
@ -61,4 +66,19 @@ public class IntentUtils {
|
||||
DataUtils.onMtaEvent(context, "分类大全", categoryTitle, category.getName());
|
||||
context.startActivity(CategoryListActivity.Companion.getIntent(context, categoryTitle, category, "全部"));
|
||||
}
|
||||
|
||||
public static Intent getWebTargetIntent(Context context, Bundle bundle, String url) {
|
||||
Class<? extends NormalActivity> cls;
|
||||
|
||||
if (url.contains("android_page_type=singleton")) {
|
||||
cls = SingletonWebActivity.class;
|
||||
} else {
|
||||
cls = WebActivity.class;
|
||||
}
|
||||
|
||||
Intent intent = new Intent(context, cls);
|
||||
intent.putExtra(NormalActivity.NORMAL_FRAGMENT_NAME, WebFragment.class.getCanonicalName());
|
||||
intent.putExtra(NormalActivity.NORMAL_FRAGMENT_BUNDLE, bundle);
|
||||
return intent;
|
||||
}
|
||||
}
|
||||
|
||||
@ -91,8 +91,10 @@ public class KeyboardHeightProvider extends PopupWindow {
|
||||
* of the Activity.
|
||||
*/
|
||||
public void start() {
|
||||
|
||||
if (!isShowing() && parentView.getWindowToken() != null) {
|
||||
if (!isShowing()
|
||||
&& parentView.getWindowToken() != null
|
||||
&& activity != null
|
||||
&& !activity.isFinishing()) {
|
||||
setBackgroundDrawable(new ColorDrawable(0));
|
||||
showAtLocation(parentView, Gravity.NO_GRAVITY, 0, 0);
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user