Avoid non-UI thread view touching on some devices

This commit is contained in:
seven332 committed 2018-12-23 12:20:10 +08:00
1 parent 8f76f50526
commit 95f2d46420
1 file changed
+8
@@ -27,6 +27,7 @@ import android.content.res.Resources;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.os.Looper;
import android.os.Parcelable;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
@@ -505,6 +506,13 @@ public final class GalleryCommentsScene extends ToolbarScene
return;
}
if (Looper.myLooper() != Looper.getMainLooper()) {
// Some devices may run this block in non-UI thread.
// It might be a bug of Android OS.
// Check it here to avoid crash.
return;
}
mEditPanel.setVisibility(View.GONE);
((View) mFab).setVisibility(View.VISIBLE);
int fabStartX = mEditPanel.getLeft() + (mEditPanel.getWidth() / 2) - (mFab.getWidth() / 2);