mirror of
https://gitee.com/zhangsken/AndroidIDE.git
synced 2026-10-16 07:49:44 +08:00
Show different message for views that are not supported
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* This file is part of AndroidIDE.
|
||||
*
|
||||
* AndroidIDE is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* AndroidIDE is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.itsaky.inflater;
|
||||
|
||||
/**
|
||||
* Exception thrown by inflaters and drawable parsers to
|
||||
* indicate that the a specific view or tag is not
|
||||
* supported.
|
||||
*
|
||||
* @author Akash Yadav
|
||||
*/
|
||||
public class NotSupportedException extends UnsupportedOperationException {
|
||||
|
||||
public NotSupportedException () {
|
||||
}
|
||||
|
||||
public NotSupportedException (String message) {
|
||||
super (message);
|
||||
}
|
||||
|
||||
public NotSupportedException (String message, Throwable cause) {
|
||||
super (message, cause);
|
||||
}
|
||||
|
||||
public NotSupportedException (Throwable cause) {
|
||||
super (cause);
|
||||
}
|
||||
}
|
||||
@@ -284,7 +284,7 @@ class XMLLayoutInflater extends BaseLayoutInflater {
|
||||
final var androidView = this.widgetInfo.getWidget (name);
|
||||
if (androidView == null) {
|
||||
// If this is not an Android view, do not bother to create one
|
||||
throw new InflateException (String.format ("%s is not supported yet.", name));
|
||||
throw new NotSupportedException ();
|
||||
}
|
||||
|
||||
final View created = createAndroidViewForName (name);
|
||||
@@ -294,6 +294,11 @@ class XMLLayoutInflater extends BaseLayoutInflater {
|
||||
: new UiView (name, created);
|
||||
return applyLayoutParams (view, parent);
|
||||
} catch (Throwable th) {
|
||||
|
||||
if (th instanceof NotSupportedException) {
|
||||
return onCreateErrorView (name, getString (R.string.msg_view_not_supported, name), parent);
|
||||
}
|
||||
|
||||
final var msg = getString (R.string.msg_cannot_create_view, name);
|
||||
LOG.error (msg, th);
|
||||
return onCreateErrorView (name, msg, parent);
|
||||
|
||||
@@ -2,4 +2,5 @@
|
||||
<string name="msg_cannot_create_view">Cannot create view for tag: %s</string>
|
||||
<string name="err_cannot_read_values">Unable to read values</string>
|
||||
<string name="err_no_attr_adapter">No attribute adapter implementation found for %s</string>
|
||||
<string name="msg_view_not_supported">View %s is not supported currently.</string>
|
||||
</resources>
|
||||
|
||||
Reference in New Issue
Block a user