Closed coderloveryan closed 2 years ago
The device model is Galaxy s9+,be thanks for your response.
Could you attach affected GIF and/or code which reproduces this issue?
public class UplusRefreshHeader extends LinearLayout implements RefreshHeader {
private GifImageView gifImageView;
private GifDrawable gifDrawable;
private TextView tvRefresh;
protected Context context;
private boolean isSuccess = true;
private RefreshType refreshType = RefreshType.NORMAL;
public UplusRefreshHeader(Context context) {
super(context);
initView(context);
}
public UplusRefreshHeader(Context context, AttributeSet attrs) {
super(context, attrs);
this.initView(context);
}
public UplusRefreshHeader(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
this.initView(context);
}
public void setRefreshType(RefreshType refreshType) {
this.refreshType = refreshType;
}
private void initView(Context context) {
this.context = context;
setOrientation(VERTICAL);
setGravity(Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM);
setPadding(0,0,0, DensityUtil.dp2px(14));
gifImageView = new GifImageView(context);
try {
gifDrawable = new GifDrawable(getResources(), com.haier.uhome.uplus.phone.R.drawable.loading);
gifDrawable.setSpeed(4.0f);
gifImageView.setImageDrawable(gifDrawable);
} catch (IOException e) {
Log.logger().warn("init gifdrawable error so cannot play the animation");
gifImageView.setImageResource(com.haier.uhome.uplus.phone.R.drawable.loading);
}
tvRefresh = new TextView(context);
tvRefresh.setTextColor(Color.parseColor("#999999"));
tvRefresh.setTextSize(COMPLEX_UNIT_SP,10);
addView(gifImageView, DensityUtil.dp2px(35), DensityUtil.dp2px(18));
addView(new View(context), LayoutParams.MATCH_PARENT, DensityUtil.dp2px(6));
addView(tvRefresh, LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
setRefreshHeight();
}
protected void setRefreshHeight() {
setMinimumHeight(DensityUtil.dp2px(60));
}
@NonNull
@Override
public View getView() {
return this;
}
@NonNull
@Override
public SpinnerStyle getSpinnerStyle() {
return SpinnerStyle.Translate;
}
@Override
public void onStartAnimator(RefreshLayout layout, int headHeight, int maxDragHeight) {
if (null != gifDrawable) {
Log.logger().info("onStartAnimator");
gifDrawable.start();
}
}
@Override
public int onFinish(RefreshLayout layout, boolean success) {
if (null != gifImageView) {
gifDrawable.seekToFrame(0);
gifDrawable.stop();
}
isSuccess = success;
refreshType = RefreshType.NORMAL;
return 500;
}
@Override
public void onStateChanged(RefreshLayout refreshLayout, RefreshState oldState, RefreshState
newState) {
switch (newState) {
case None:
case PullDownToRefresh:
if (null != gifDrawable && gifDrawable.isPlaying()) {
gifDrawable.seekToFrame(0);
gifDrawable.stop();
}
changeRefreshText(RefreshState.PullDownToRefresh);
break;
case Refreshing:
changeRefreshText(RefreshState.Refreshing);
break;
case RefreshFinish:
changeRefreshText(RefreshState.RefreshFinish);
isSuccess = true;
break;
case ReleaseToRefresh:
changeRefreshText(RefreshState.ReleaseToRefresh);
break;
default:
break;
}
}
private void changeRefreshText(RefreshState state) {
switch (state) {
case None:
case PullDownToRefresh:
if (refreshType == RefreshType.NORMAL) {
tvRefresh.setText("loading");
} else {
tvRefresh.setText("pull to refresh");
}
break;
case Refreshing:
tvRefresh.setText("loading");
break;
case RefreshFinish:
if (isSuccess) {
tvRefresh.setText("loading complete");
} else {
tvRefresh.setText("timeout!");
}
break;
case ReleaseToRefresh:
if (refreshType == RefreshType.NORMAL) {
tvRefresh.setText("release to refresh");
} else {
tvRefresh.setText("loading");
}
break;
default:
break;
}
}
}
I custom a refresh footer use https://github.com/scwang90/SmartRefreshLayout and then in one search page of app, it's no data and wait a few minutes, the device crash. here is the code of activity
class SearchModelActivity : Activity(), SearchModelContract.View, SearchModelContract.AdapterClickListener {
private var refreshLayout: SmartRefreshLayout? = null private var uplusRefreshFooter: UplusRefreshFooter? = null
...
override fun initView() {
manual_edit_search?.requestFocus()
list = findViewById(R.id.manual_brand_items)
refreshLayout = findViewById(R.id.search_model_view)
linearLayoutManager = object : LinearLayoutManager(this) {
override fun canScrollVertically(): Boolean {
return true
}
}
mAdapter = SearchModelAdapter(adapterDatas, this, this)
list.apply {
this.adapter = mAdapter
this.layoutManager = linearLayoutManager
}
}
...
refreshLayout?.apply {
isEnableLoadmore = true
isEnableRefresh = false
isEnableAutoLoadmore = false
setEnableLoadmoreWhenContentNotFull(true)
refreshFooter = uplusRefreshFooter
setOnLoadmoreListener {
if (adapterDatas.size % 20 != 0) {
uplusRefreshFooter?.setLoadmoreFinished(true)
finishLoadmore(UplusRefreshUtils.UPLOAD_MORE_DELAY_DURATION,true)
} else {
presenter?.loadNextPageData(false, "", manual_edit_search?.text.toString())
}
}
}
...
}
Thanks, I'll investigate it.
Sorry for the long delay. It seems to be a bug in Skia, fixed in https://android.googlesource.com/platform/external/skia/+/bf999383abd128f8db32fc2f24606679280a5b7d