修复一些闪退问题

This commit is contained in:
kehaoyuan@ghzhushou.com
2020-03-23 13:35:46 +08:00
parent 4f68f30576
commit 79ff887375
5 changed files with 22 additions and 13 deletions

View File

@ -92,7 +92,7 @@ class HomeSlideListViewHolder(val binding: HomeSlideListBinding) : BaseRecyclerV
// 缩放控制
fun updateZoomAnimation() {
val childCount = binding.recyclerView.childCount
val width = binding.recyclerView.getChildAt(0).width
val width = binding.recyclerView.getChildAt(0)?.width ?: return
val padding = (binding.recyclerView.width - width) / 2
for (j in 0 until childCount) {

View File

@ -189,7 +189,10 @@ class MyPlayedGameAdapter(context: Context, private val mViewModel: PlayedGameVi
playedGameRemoveView.findViewById<View>(R.id.remove_container).setOnClickListener {
popupWindow.dismiss()
mViewModel.deletePlayedGame(mEntityList[holder.adapterPosition])
val adapterPosition = holder.adapterPosition
if (adapterPosition != RecyclerView.NO_POSITION) {
mViewModel.deletePlayedGame(mEntityList[adapterPosition])
}
}
popupWindow.isTouchable = true

View File

@ -788,7 +788,9 @@ public class NewsDetailAdapter extends BaseRecyclerAdapter<ViewHolder> {
}
public void setFontSize(int fontsize) {
mWebSettings.setTextZoom(defaultTextZoom + 15 * fontsize);
if (mWebSettings != null) {
mWebSettings.setTextZoom(defaultTextZoom + 15 * fontsize);
}
}
public class JsInterface {

View File

@ -1,11 +1,12 @@
package com.gh.gamecenter.qa.search;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import android.text.TextUtils;
import android.view.View;
import com.gh.base.fragment.BaseFragment_TabLayout;
import com.gh.common.util.EntranceUtils;
@ -88,7 +89,7 @@ public class AskSearchFragment extends BaseFragment_TabLayout {
void updateSearch(String key) {
for (Fragment fragment : mFragmentsList) {
if (fragment instanceof BaseAskSearchFragment) {
if (fragment instanceof BaseAskSearchFragment && isAdded()) {
((BaseAskSearchFragment) fragment).search(key);
Bundle arguments = fragment.getArguments();
// 处于 state saved 状态的 fragment 不可 setArguments

View File

@ -8,6 +8,13 @@ import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.DefaultItemAnimator;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.viewpager.widget.ViewPager;
import com.gh.base.fragment.BaseFragment;
import com.gh.common.exposure.ExposureListener;
import com.gh.common.util.DownloadItemUtils;
@ -29,12 +36,6 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.DefaultItemAnimator;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.viewpager.widget.ViewPager;
import butterknife.BindView;
import butterknife.OnClick;
@ -136,6 +137,8 @@ public class GameServersContentFragment extends BaseFragment {
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
int position = mLayoutManager.findFirstVisibleItemPosition();
if (RecyclerView.NO_POSITION == position) return;
List<GameEntity> dataList = mAdapter.getDataList();
GameEntity gameEntity = dataList.get(position + 1);
Long kaifuTimeHint = gameEntity.getKaifuTimeHint();
@ -271,7 +274,7 @@ public class GameServersContentFragment extends BaseFragment {
@Override
public void loadError() {
if (!isAdded()) return;
super.loadError();
toast(R.string.loading_failed_hint);
mKaiFuTimeLl.setVisibility(View.GONE);