Compare commits

...

12 Commits

25 changed files with 114 additions and 78 deletions

View File

@ -51,7 +51,7 @@ class DefaultJsApi(var context: Context) {
@JavascriptInterface
fun getUserInfo(msg: Any): String {
return UserManager.getInstance().userInfoEntity.toJson()
return UserManager.getInstance().userInfoEntity?.toJson() ?: ""
}
@JavascriptInterface
@ -70,9 +70,9 @@ class DefaultJsApi(var context: Context) {
val userInfoEntity = UserManager.getInstance().userInfoEntity
if (msg.toString().isNotEmpty()) {
val badge = msg.toString().toObject() ?: Badge()
userInfoEntity.badge = badge
userInfoEntity?.badge = badge
} else {
userInfoEntity.badge = null
userInfoEntity?.badge = null
}
UserManager.getInstance().userInfoEntity = userInfoEntity
}

View File

@ -48,7 +48,7 @@ class NotificationHintDialogFragment : BaseTrackableDialogFragment() {
val index = Random.nextInt(2)
val jsonArray = JSONArray(jsonString)
val jsonObj = jsonArray.getJSONObject(index)
if (!jsonObj.has(mNotificationUgc!!.value)) {
if (!jsonObj.has(mNotificationUgc?.value)) {
Utils.log("ugc type error")
return
}

View File

@ -170,7 +170,7 @@ class ReserveDialogFragment
}
private fun setMobileIndexHint(reserveMobile: String?) {
var userMobile = UserManager.getInstance().userInfoEntity.mobile
var userMobile = UserManager.getInstance().userInfoEntity?.mobile
if (reserveMobile == userMobile) userMobile = null
if (!reserveMobile.isNullOrEmpty()) {

View File

@ -45,7 +45,7 @@ object ImManager {
HaloApp.getInstance().application,
ImReceiver.UNIQUE_BROADCAST_ACTION,
IM_KEY,
UserManager.getInstance().userInfoEntity.name + "(" + UserManager.getInstance().userId + ")",
UserManager.getInstance().userInfoEntity?.name + "(" + UserManager.getInstance().userId + ")",
UserManager.getInstance().userId)
shouldShowFloatingWindow = SPUtils.getBoolean(SP_FLOATING_WINDOW_KEY + UserManager.getInstance().userId)
@ -75,11 +75,11 @@ object ImManager {
try {
SPUtils.setBoolean(SP_FLOATING_WINDOW_DOT_KEY + UserManager.getInstance().userId, false)
shouldShowFloatingWindowDot = false
val chatHelper = KfStartHelper(activity, UserManager.getInstance().userInfoEntity.icon, inputContent, requestCode)
val chatHelper = KfStartHelper(activity, UserManager.getInstance().userInfoEntity?.icon, inputContent, requestCode)
chatHelper.initSdkChat(
ImReceiver.UNIQUE_BROADCAST_ACTION,
IM_KEY,
UserManager.getInstance().userInfoEntity.name + "(" + UserManager.getInstance().userId + ")"
UserManager.getInstance().userInfoEntity?.name + "(" + UserManager.getInstance().userId + ")"
+ "[" + BuildConfig.VERSION_NAME + "]",
UserManager.getInstance().userId)
} catch (e: Exception) {

View File

@ -21,9 +21,7 @@ object ActivationHelper {
*/
@JvmStatic
fun sendActivationInfo() {
// 能获取到 IMEI 并且之前没发送过激活信息才发
if (!mHasSentActivatedInfo
&& Util_System_Phone_State.canGetImei(HaloApp.getInstance().application)) {
if (!mHasSentActivatedInfo) {
RetrofitManager.getInstance(HaloApp.getInstance().application)
.api.postActivationInfo()
.subscribeOn(Schedulers.io())

View File

@ -139,32 +139,35 @@ object DownloadNotificationHelper {
}
private fun updateNotificationGroup() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
val notificationManager = getNotificationManager()
val activeNotifications = notificationManager.activeNotifications
var downloadNotificationSize = 0
var downloadGroupNotificationSize = 0
for (activeNotification in activeNotifications) {
if (activeNotification.id == DOWNLOAD_NOTIFICATION_ID) {
downloadNotificationSize++
// 部分华为设备调用 getActiveNotifications() 方法时会触发方法内的空指针,这里整体包裹处理了
tryCatchInRelease {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
val notificationManager = getNotificationManager()
val activeNotifications = notificationManager.activeNotifications
var downloadNotificationSize = 0
var downloadGroupNotificationSize = 0
for (activeNotification in activeNotifications) {
if (activeNotification.id == DOWNLOAD_NOTIFICATION_ID) {
downloadNotificationSize++
}
if (activeNotification.id == DOWNLOAD_NOTIFICATION_FOLD_ID) {
downloadGroupNotificationSize++
}
}
if (activeNotification.id == DOWNLOAD_NOTIFICATION_FOLD_ID) {
downloadGroupNotificationSize++
}
}
if (downloadNotificationSize == 0 && downloadGroupNotificationSize != 0) {
// 删除组可能会把组内所有通知一并删除
notificationManager.cancel(DOWNLOAD_NOTIFICATION_FOLD_ID)
} else if (downloadNotificationSize != 0 && downloadGroupNotificationSize == 0) {
val groupBuilder = NotificationCompat.Builder(HaloApp.getInstance().application, DOWNLOAD_CHANNEL_ID)
.setSmallIcon(R.mipmap.logo)
.setGroup(DOWNLOAD_GROUP_KEY)
.setGroupSummary(true)
.setStyle(NotificationCompat.BigTextStyle().bigText("下载任务"))
val groupNotification = groupBuilder.build()
groupNotification.flags = groupNotification.flags or Notification.FLAG_NO_CLEAR
notificationManager.notify(DOWNLOAD_NOTIFICATION_FOLD_ID, groupNotification)
if (downloadNotificationSize == 0 && downloadGroupNotificationSize != 0) {
// 删除组可能会把组内所有通知一并删除
notificationManager.cancel(DOWNLOAD_NOTIFICATION_FOLD_ID)
} else if (downloadNotificationSize != 0 && downloadGroupNotificationSize == 0) {
val groupBuilder = NotificationCompat.Builder(HaloApp.getInstance().application, DOWNLOAD_CHANNEL_ID)
.setSmallIcon(R.mipmap.logo)
.setGroup(DOWNLOAD_GROUP_KEY)
.setGroupSummary(true)
.setStyle(NotificationCompat.BigTextStyle().bigText("下载任务"))
val groupNotification = groupBuilder.build()
groupNotification.flags = groupNotification.flags or Notification.FLAG_NO_CLEAR
notificationManager.notify(DOWNLOAD_NOTIFICATION_FOLD_ID, groupNotification)
}
}
}
}

View File

@ -407,7 +407,17 @@ public class DWebView extends WebView {
private void _evaluateJavascript(String script) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
DWebView.super.evaluateJavascript(script, null);
try {
DWebView.super.evaluateJavascript(script, null);
} catch (Exception e) {
// 部分机型把自己伪装成 Android 4.4 然后没 evaluateJavascript 方法!
e.printStackTrace();
try {
super.loadUrl("javascript:" + script);
} catch (Exception ignored){
}
}
} else {
super.loadUrl("javascript:" + script);
}

View File

@ -20,4 +20,8 @@ class SnappingLinearLayoutManager(val context: Context) : LinearLayoutManager(co
startSmoothScroll(smoothScroller)
}
}
override fun onLayoutChildren(recycler: RecyclerView.Recycler?, state: RecyclerView.State?) {
tryWithDefaultCatch { super.onLayoutChildren(recycler, state) }
}
}

View File

@ -179,14 +179,14 @@ public class MainActivity extends BaseActivity {
isNewFirstLaunch = mSp.getBoolean("isNewFirstLaunchV" + PackageUtils.getVersionName(), true);
if (isNewFirstLaunch) {
final LunchType lunchType = DeviceTokenUtils.getLaunchType();
// 延时两秒提交 APP 启动日志的,避免提交时还没获取到 GID
// 延时两秒提交,避免提交时还没获取到 GID/OAID
AppExecutor.getUiExecutor().executeWithDelay(() -> {
if (!this.isFinishing()) {
LogUtils.uploadDevice(lunchType);
ActivationHelper.sendActivationInfo();
}
}, 2000L);
getPluginUpdate();
ActivationHelper.sendActivationInfo();
mSp.edit().putBoolean("isNewFirstLaunchV" + PackageUtils.getVersionName(), false).apply();
checkDevice(); // 根据设备信息判断用户是否是新用户

View File

@ -356,8 +356,8 @@ data class GameEntity(
}
fun setWelcomeDialogInfoIfAvailable() {
welcomeDialogId = HaloApp.get(Constants.WELCOME_DIALOG_ID, false) as String
welcomeDialogTitle = HaloApp.get(Constants.WELCOME_DIALOG_LINK_TITLE, false) as String
welcomeDialogId = HaloApp.get(Constants.WELCOME_DIALOG_ID, false) as? String
welcomeDialogTitle = HaloApp.get(Constants.WELCOME_DIALOG_LINK_TITLE, false) as? String
}
fun getTag(): ArrayList<String> {

View File

@ -25,6 +25,7 @@ import butterknife.BindView;
/**
* @author CsHeng
*/
// TODO 延迟加载,并确保后台配置了动态游戏库 tab 可用
public class SearchToolWrapperFragment extends BaseLazyFragment {
@BindView(R.id.wrapperLl)
LinearLayout wrapperLl;
@ -35,8 +36,8 @@ public class SearchToolWrapperFragment extends BaseLazyFragment {
private Fragment mContentFragment;
@Override
public void onFragmentFirstVisible() {
super.onFragmentFirstVisible();
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mSearchToolbarFragment = new SearchToolbarFragment();
try {
Bundle arguments = getArguments();
@ -95,7 +96,4 @@ public class SearchToolWrapperFragment extends BaseLazyFragment {
DisplayUtils.setLightStatusBar(requireActivity(), true);
}
}
}

View File

@ -149,7 +149,8 @@ class GameFragment : NormalFragment() {
}
fun initPage(blockData: SubjectRecommendEntity) {
if (mViewModel.blockData?.toJson() != blockData.toJson()) {
if (::mViewModel.isInitialized
&& mViewModel.blockData?.toJson() != blockData.toJson()) {
mViewModel.blockData = blockData
mViewModel.initData()
}

View File

@ -94,7 +94,9 @@ class DescFragment : BaseFragment<Any>(), IScrollable {
mViewModel = viewModelProvider(factory)
gameDetailViewModel.gameDetailLiveData.observeNonNull(this) { gameDetail ->
mAdapter.updateDescItemList(mViewModel.decorateList(gameDetail.data!!.detailEntity))
if (gameDetail.data == null) return@observeNonNull
mAdapter.updateDescItemList(mViewModel.decorateList(gameDetail.data.detailEntity))
// 镜像游戏去掉大家都在玩
if (mGameEntity?.shouldUseMirrorInfo() == false) {
mViewModel.generateRecommendedGamesItem(gameDetail.data.detailEntity)

View File

@ -57,6 +57,7 @@ public class UserManager {
private ApiService mApiService;
@Nullable
private UserInfoEntity mUserInfoEntity;
private LoginTokenEntity mLoginTokenEntity;
private CommunityEntity mCommunityData;
@ -88,6 +89,7 @@ public class UserManager {
mLoginTokenEntity = loginTokenEntity;
}
@Nullable
public UserInfoEntity getUserInfoEntity() {
return mUserInfoEntity;
}

View File

@ -178,7 +178,8 @@ class UserHistoryFragment : ListFragment<PersonalHistoryEntity, UserHistoryViewM
super.onActivityResult(requestCode, resultCode, data)
if (data != null && resultCode == Activity.RESULT_OK) {
val dataPosition = data.getIntExtra("DATA_POSITION_TAG", -1)
val historyEntity = mAdapter?.getEntityList()?.get(dataPosition)
if (mAdapter?.entityList?.isEmpty() == true) return
val historyEntity = mAdapter?.entityList?.get(dataPosition)
when (requestCode) {
100 -> {
val resultData = data.getParcelableExtra<RatingComment>(RatingComment::class.java.simpleName)
@ -197,6 +198,7 @@ class UserHistoryFragment : ListFragment<PersonalHistoryEntity, UserHistoryViewM
count.comment = resultData?.count?.comment ?: 0
title = resultData?.title ?: ""
brief = HtmlUtils.stripHtmlCode(resultData?.content ?: "")
me.isCommunityArticleVote = resultData.me.isCommunityArticleVote
}
}
102 -> {

View File

@ -483,6 +483,7 @@ class ArticleDetailFragment : BaseArticleDetailCommentFragment<CommentItemData,
private fun updateLikeView(alreadyLiked: Boolean, likeCount: Int) {
mAdapter?.articleDetailVH?.updateLikeView(alreadyLiked, likeCount)
bottomLikeTv.text = mViewModel.getLikeText(likeCount)
mViewModel.detailEntity?.me?.isCommunityArticleVote = alreadyLiked
if (alreadyLiked) {
bottomLikeIv.setImageResource(R.drawable.ic_article_detail_liked)
} else {

View File

@ -99,6 +99,7 @@ class OkHttpCacheInterceptor implements Interceptor {
.addHeader("IMEI", Util_System_Phone_State.getImei(HaloApp.getInstance().getApplication()))
.addHeader("CHANNEL", HaloApp.getInstance().getChannel())
.addHeader("VERSION", PackageUtils.getVersionName())
.addHeader("OAID", HaloApp.getInstance().getOAID())
.removeHeader("User-Agent")
.addHeader("User-Agent", HaloApp.getInstance().getUserAgent())
.build();

View File

@ -46,7 +46,7 @@ class BindPhoneConflictFragment : NormalFragment() {
mBindPhoneConflictDesc.text = "手机号${mConflictPhone}已经绑定在另一个冲突号上,"
UserManager.getInstance().userInfoEntity.run {
UserManager.getInstance().userInfoEntity?.run {
mCurrentDesc.text = "注册方式:${getRegisterType(registerType)}"
mCurrentName.text = name
ImageUtils.display(mCurrentIcon, icon)

View File

@ -71,7 +71,7 @@ class BindPhoneFragment : NormalFragment() {
mBindPhoneTitle.text = if (mChangePhone) requireContext().resources.getString(R.string.bind_phone_title2)
else requireContext().resources.getString(R.string.bind_phone_title1)
mBindPhoneDesc.text = if (mChangePhone) {
val phoneNum = UserManager.getInstance().userInfoEntity.loginMobile!!
val phoneNum = UserManager.getInstance().userInfoEntity?.loginMobile ?: ""
"当前手机号:" + phoneNum.substring(0, 3) + "******" + phoneNum.substring(9, 11)
} else {
requireContext().resources.getString(R.string.bind_phone_desc)
@ -194,7 +194,7 @@ class BindPhoneFragment : NormalFragment() {
R.id.bind_phone_captcha -> {
val phoneNum: String = mBindPhoneEt.text.toString().trim { it <= ' ' }.replace(" ".toRegex(), "")
if (mChangePhone) {
val oldPhoneNum = UserManager.getInstance().userInfoEntity.loginMobile!!
val oldPhoneNum = UserManager.getInstance().userInfoEntity?.loginMobile ?: ""
mViewModel.reBindPhoneOne(oldPhoneNum, phoneNum, requireContext())
} else {
mViewModel.bindPhoneOne(phoneNum, requireContext())
@ -202,7 +202,7 @@ class BindPhoneFragment : NormalFragment() {
}
R.id.bind_phone_btn -> {
val oldPhoneNum = UserManager.getInstance().userInfoEntity.loginMobile ?: ""
val oldPhoneNum = UserManager.getInstance().userInfoEntity?.loginMobile ?: ""
val phoneNum: String = mBindPhoneEt.text.toString().trim { it <= ' ' }.replace(" ".toRegex(), "")
// 更换手机号,当输入手机号和当前手机号相同则弹出提示
if (mChangePhone && phoneNum == oldPhoneNum) {

View File

@ -23,7 +23,7 @@ class SecurityFragment : NormalFragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
UserManager.getInstance().userInfoEntity.run {
UserManager.getInstance().userInfoEntity?.run {
mSecurityRegisterWay.text = when (registerType) {
"qq" -> "QQ"
"wechat" -> "微信"
@ -40,10 +40,10 @@ class SecurityFragment : NormalFragment() {
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
if (requestCode == INSERT_MOBILE_CODE) {
mSecurityBindPhone.text = if (UserManager.getInstance().userInfoEntity.loginMobile.isNullOrEmpty()) {
mSecurityBindPhone.text = if (UserManager.getInstance().userInfoEntity?.loginMobile.isNullOrEmpty()) {
"立即绑定"
} else {
UserManager.getInstance().userInfoEntity.loginMobile
UserManager.getInstance().userInfoEntity?.loginMobile
}
}
}
@ -52,7 +52,7 @@ class SecurityFragment : NormalFragment() {
override fun onClick(v : View) {
when (v.id) {
R.id.bind_phone_container -> {
if (UserManager.getInstance().userInfoEntity.loginMobile.isNullOrEmpty()) {
if (UserManager.getInstance().userInfoEntity?.loginMobile.isNullOrEmpty()) {
startActivityForResult(BindPhoneActivity.getNormalIntent(requireContext(), false), INSERT_MOBILE_CODE)
} else {
startActivityForResult(BindPhoneActivity.getNormalIntent(requireContext(), true), INSERT_MOBILE_CODE)

View File

@ -174,6 +174,10 @@ public class WebFragment extends NormalFragment implements IScrollable {
mToolBoxEntity.getDes(),
ShareUtils.ShareEntrance.tools, mToolBoxEntity.getId());
} else {
if (mShareEntity == null) {
toast("分享实体为空");
return;
}
curActivity.showShare(TextUtils.isEmpty(mShareEntity.getUrl()) ? getArguments().getString(EntranceUtils.KEY_URL) : mShareEntity.getUrl(),
mShareEntity.getIcon(),
mShareEntity.getTitle(),

View File

@ -1,14 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<com.gh.common.view.FixedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="none">
android:layout_height="match_parent">
<ImageView
<com.gh.common.view.FixedScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:scaleType="fitXY"
android:src="@drawable/skeleton_article_detail_comment" />
android:layout_height="match_parent"
android:scrollbars="none">
</com.gh.common.view.FixedScrollView>
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:scaleType="fitXY"
android:src="@drawable/skeleton_article_detail_comment" />
</com.gh.common.view.FixedScrollView>
</FrameLayout>

View File

@ -1,14 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<com.gh.common.view.FixedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="none">
android:layout_height="match_parent">
<ImageView
<com.gh.common.view.FixedScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:scaleType="fitXY"
android:src="@drawable/skeleton_article_detail" />
android:layout_height="match_parent"
android:scrollbars="none">
</com.gh.common.view.FixedScrollView>
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:scaleType="fitXY"
android:src="@drawable/skeleton_article_detail" />
</com.gh.common.view.FixedScrollView>
</FrameLayout>

View File

@ -7,7 +7,7 @@ ext {
targetSdkVersion = 26
// application info
versionCode = 200
versionCode = 202
versionName = "4.2.0"
applicationId = "com.gh.gamecenter"

View File

@ -53,8 +53,8 @@ SENSITIVE_API_HOST=https\://and-core-api.ghzs.com/v4d2d0/
# 请不要手动改动下面的值除非你明确需要以某个apk作为基准包需要打包请以scripts/tinker*.sh为准
TINKER_ENABLE=
TINKER_ID=547e6da
TINKER_BASE_APK_DIR=app-0904-18-15-15_547e6da
TINKER_ID=f29b8da
TINKER_BASE_APK_DIR=app-0908-14-28-07_f29b8da
android.useAndroidX=true
android.enableJetifier=true