diff --git a/app/src/main/java/com/gh/base/BaseActivity.java b/app/src/main/java/com/gh/base/BaseActivity.java index bb64e1f69a..7421f30299 100644 --- a/app/src/main/java/com/gh/base/BaseActivity.java +++ b/app/src/main/java/com/gh/base/BaseActivity.java @@ -143,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); @@ -212,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)); diff --git a/app/src/main/java/com/gh/common/util/KeyboardHeightProvider.java b/app/src/main/java/com/gh/common/util/KeyboardHeightProvider.java index fb8d8e4f49..f1c0f55e70 100644 --- a/app/src/main/java/com/gh/common/util/KeyboardHeightProvider.java +++ b/app/src/main/java/com/gh/common/util/KeyboardHeightProvider.java @@ -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); } diff --git a/app/src/main/java/com/gh/common/util/PackageUtils.java b/app/src/main/java/com/gh/common/util/PackageUtils.java index d5b688132b..abfb48be5d 100644 --- a/app/src/main/java/com/gh/common/util/PackageUtils.java +++ b/app/src/main/java/com/gh/common/util/PackageUtils.java @@ -706,29 +706,34 @@ public class PackageUtils { * 应用是否在前台运行 */ public static boolean isAppOnForeground(Context context) { - ActivityManager activityManager = (ActivityManager) context.getApplicationContext() - .getSystemService(Context.ACTIVITY_SERVICE); - if (activityManager == null) return false; + try { + ActivityManager activityManager = (ActivityManager) context.getApplicationContext() + .getSystemService(Context.ACTIVITY_SERVICE); + if (activityManager == null) return false; - List appProcesses = - activityManager.getRunningAppProcesses(); - if (appProcesses == null) return false; + List appProcesses = + activityManager.getRunningAppProcesses(); + if (appProcesses == null) return false; - PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE); - if (pm == null) return false; - if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT) { - if (!pm.isInteractive()) return false; - } else { - if (!pm.isScreenOn()) return false; - } - - String packageName = context.getApplicationContext().getPackageName(); - for (ActivityManager.RunningAppProcessInfo appProcess : appProcesses) { - // The name of the process that this object is associated with. - if (appProcess.processName.equals(packageName) && appProcess.importance - == ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND) { - return true; + PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE); + if (pm == null) return false; + if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT) { + if (!pm.isInteractive()) return false; + } else { + if (!pm.isScreenOn()) return false; } + + String packageName = context.getApplicationContext().getPackageName(); + for (ActivityManager.RunningAppProcessInfo appProcess : appProcesses) { + // The name of the process that this object is associated with. + if (appProcess.processName.equals(packageName) && appProcess.importance + == ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND) { + return true; + } + } + } catch (NullPointerException e) { + e.printStackTrace(); + return false; } return false; } diff --git a/app/src/main/java/com/gh/gamecenter/entity/PersonalHistoryEntity.kt b/app/src/main/java/com/gh/gamecenter/entity/PersonalHistoryEntity.kt index dd2ca0f30c..5317abc599 100644 --- a/app/src/main/java/com/gh/gamecenter/entity/PersonalHistoryEntity.kt +++ b/app/src/main/java/com/gh/gamecenter/entity/PersonalHistoryEntity.kt @@ -8,7 +8,10 @@ import com.gh.common.syncpage.SyncFieldConstants import com.gh.common.util.SPUtils import com.gh.common.util.TimeUtils import com.gh.gamecenter.manager.UserManager -import com.gh.gamecenter.qa.entity.* +import com.gh.gamecenter.qa.entity.AnswerEntity +import com.gh.gamecenter.qa.entity.CommunityVideoEntity +import com.gh.gamecenter.qa.entity.ImageInfo +import com.gh.gamecenter.qa.entity.Questions import com.google.gson.annotations.SerializedName import kotlinx.android.parcel.IgnoredOnParcel import kotlinx.android.parcel.Parceler @@ -23,7 +26,7 @@ data class PersonalHistoryEntity( var brief: String = "", var des: String = "", var url: String = "", - var status: String = "", + var status: String? = "", @SerializedName("video_info") var videoInfo: VideoInfo = VideoInfo(), var poster: String = "", @@ -166,7 +169,7 @@ data class PersonalHistoryEntity( answer.communityId = community.id answer.communityName = community.name answer.type = type - answer.status = status + answer.status = status ?: "pending" return answer } @@ -187,7 +190,7 @@ data class PersonalHistoryEntity( forumVideoEntity.title = title forumVideoEntity.des = des forumVideoEntity.url = url - forumVideoEntity.status = status + forumVideoEntity.status = status ?: "pending" forumVideoEntity.poster = poster forumVideoEntity.length = length forumVideoEntity.duration = TimeUtils.formatVideoDuration(length) @@ -202,7 +205,7 @@ data class PersonalHistoryEntity( forumVideoEntity.id = newVideos[0].id forumVideoEntity.url = newVideos[0].url forumVideoEntity.poster = newVideos[0].poster - forumVideoEntity.status = status + forumVideoEntity.status = status ?: "pending" forumVideoEntity.duration = newVideos[0].duration forumVideoEntity.videoInfo = VideoInfo(width = newVideos[0].width, height = newVideos[0].height) } diff --git a/app/src/main/java/com/gh/gamecenter/personalhome/home/UserHistoryAdapter.kt b/app/src/main/java/com/gh/gamecenter/personalhome/home/UserHistoryAdapter.kt index 4aaf858790..61d414f45e 100644 --- a/app/src/main/java/com/gh/gamecenter/personalhome/home/UserHistoryAdapter.kt +++ b/app/src/main/java/com/gh/gamecenter/personalhome/home/UserHistoryAdapter.kt @@ -85,7 +85,7 @@ class UserHistoryAdapter(context: Context, answer.id = historyEntity.id answer.communityId = historyEntity.community.id answer.communityName = historyEntity.community.name - answer.status = historyEntity.status + answer.status = historyEntity.status ?: "pending" holder.binding.imageContainer.bindData(answer, mEntrance) bindVideoData(holder.binding, historyEntity.transformForumVideoEntity()) diff --git a/app/src/main/java/com/gh/gamecenter/qa/video/detail/desc/VideoDescTopViewHolder.kt b/app/src/main/java/com/gh/gamecenter/qa/video/detail/desc/VideoDescTopViewHolder.kt index 171ec60fc7..282c4ad8d7 100644 --- a/app/src/main/java/com/gh/gamecenter/qa/video/detail/desc/VideoDescTopViewHolder.kt +++ b/app/src/main/java/com/gh/gamecenter/qa/video/detail/desc/VideoDescTopViewHolder.kt @@ -209,7 +209,7 @@ class VideoDescTopViewHolder( private fun getTextViewHeight(view: TextView, lineCount: Int = 0): Int { if (view.visibility == View.GONE) return 0 - val layout: Layout = view.layout + val layout: Layout = view.layout ?: return 0 val desired: Int = layout.getLineTop(if (lineCount > 0) lineCount else view.lineCount) val padding = view.compoundPaddingTop + view.compoundPaddingBottom return desired + padding diff --git a/app/src/main/java/com/halo/assistant/fragment/WebFragment.java b/app/src/main/java/com/halo/assistant/fragment/WebFragment.java index 29cdbedfca..388098ad08 100644 --- a/app/src/main/java/com/halo/assistant/fragment/WebFragment.java +++ b/app/src/main/java/com/halo/assistant/fragment/WebFragment.java @@ -583,7 +583,9 @@ public class WebFragment extends LazyFragment implements IScrollable { @Override public boolean onBackPressed() { - if (mIsBackpressRequireConfirmation) { + if (mWebView == null) { + return false; + } else if (mIsBackpressRequireConfirmation) { return false; } else if (!TextUtils.isEmpty(mGameName)) { return false;