1
0
Fork 0
mirror of https://github.com/M66B/FairEmail.git synced 2024-12-28 02:37:16 +00:00

Added view ID

This commit is contained in:
M66B 2021-12-11 15:45:58 +01:00
parent 4ea8c3b112
commit 9e33838a00
3 changed files with 28 additions and 2 deletions

View file

@ -46,7 +46,7 @@ public class FixedImageButton extends AppCompatImageButton {
try {
super.onDraw(canvas);
} catch (RuntimeException ex) {
Log.e(ex);
Log.e(new Throwable(Helper.getViewName(this), ex));
Context context = getContext();
Drawable d = context.getDrawable(R.drawable.twotone_broken_image_24);
d.setBounds(getDrawable().getBounds());

View file

@ -23,6 +23,7 @@ import android.content.Context;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.View;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
@ -46,7 +47,7 @@ public class FixedImageView extends androidx.appcompat.widget.AppCompatImageView
try {
super.onDraw(canvas);
} catch (RuntimeException ex) {
Log.e(ex);
Log.e(new Throwable(Helper.getViewName(this), ex));
Context context = getContext();
Drawable d = context.getDrawable(R.drawable.twotone_broken_image_24);
d.setBounds(getDrawable().getBounds());

View file

@ -68,6 +68,7 @@ import android.view.Menu;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewParent;
import android.view.ViewTreeObserver;
import android.view.WindowManager;
import android.view.accessibility.AccessibilityManager;
@ -1293,6 +1294,30 @@ public class Helper {
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
}
static String getViewName(View view) {
StringBuilder sb = new StringBuilder(_getViewName(view));
ViewParent parent = view.getParent();
while (parent != null) {
if (parent instanceof View)
sb.insert(0, '/').insert(0, _getViewName((View) parent));
parent = parent.getParent();
}
return sb.toString();
}
private static String _getViewName(View view) {
if (view == null)
return "<null>";
int id = view.getId();
if (id == View.NO_ID)
return "";
try {
return view.getContext().getResources().getResourceEntryName(id);
} catch (Throwable ex) {
return ex.toString();
}
}
// Formatting
private static final DecimalFormat df = new DecimalFormat("@@");