android.view.InflateException Java Examples

The following examples show how to use android.view.InflateException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WorkDialog.java    From pause-resume-video-recording with Apache License 2.0 6 votes vote down vote up
/**
  * Prepares an alert dialog builder, using the work_dialog view.
  * <p>
  * The caller should finish populating the builder, then call AlertDialog.Builder#show().
  */
 public static AlertDialog.Builder create(Activity activity, int titleId) {
     View view;
     try {
         view = activity.getLayoutInflater().inflate(R.layout.work_dialog, null);
     } catch (InflateException ie) {
         Log.e(TAG, "Exception while inflating work dialog layout: " + ie.getMessage());
         throw ie;
     }

     String title = activity.getString(titleId);
     AlertDialog.Builder builder = new AlertDialog.Builder(activity);
     builder.setTitle(title);
     builder.setView(view);
     return builder;
}
 
Example #2
Source File: HelpDialog.java    From Focus with GNU General Public License v3.0 6 votes vote down vote up
@SuppressLint("InflateParams")
    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {
        final View customView;
        try {
            customView = LayoutInflater.from(getActivity()).inflate(R.layout.dialog_help_view, null);
        } catch (InflateException e) {
            throw new IllegalStateException("This device does not support Web Views.");
        }
        MaterialDialog dialog =
                new MaterialDialog.Builder(getActivity())
                        .theme(getArguments().getBoolean("dark_theme") ? Theme.DARK : Theme.LIGHT)
                        .title("帮助信息")
                        .customView(customView, false)
                        .positiveText(android.R.string.ok)
                        .build();

        final WebView webView = customView.findViewById(R.id.webview);
//        webView.loadData(this.content, "text/html", "UTF-8");
        WebViewUtil.LoadHtmlIntoWebView(webView,this.content,getActivity(),"");
        return dialog;
    }
 
Example #3
Source File: ViewProducer.java    From NewFastFrame with Apache License 2.0 6 votes vote down vote up
private static View createView(Context context, String name, String prefix)
        throws ClassNotFoundException, InflateException {
    Constructor<? extends View> constructor = sConstructorMap.get(name);

    try {
        if (constructor == null) {
            // Class not found in the cache, see if it's real, and try to add it
            Class<? extends View> clazz = context.getClassLoader().loadClass(
                    prefix != null ? (prefix + name) : name).asSubclass(View.class);

            constructor = clazz.getConstructor(sConstructorSignature);
            sConstructorMap.put(name, constructor);
        }
        constructor.setAccessible(true);
        return constructor.newInstance(mConstructorArgs);
    } catch (Exception e) {
        return null;
    }
}
 
Example #4
Source File: SkinCompatViewInflater.java    From Android-skin-support with MIT License 6 votes vote down vote up
private View createView(Context context, String name, String prefix)
        throws ClassNotFoundException, InflateException {
    Constructor<? extends View> constructor = sConstructorMap.get(name);

    try {
        if (constructor == null) {
            // Class not found in the cache, see if it's real, and try to add it
            Class<? extends View> clazz = context.getClassLoader().loadClass(
                    prefix != null ? (prefix + name) : name).asSubclass(View.class);

            constructor = clazz.getConstructor(sConstructorSignature);
            sConstructorMap.put(name, constructor);
        }
        constructor.setAccessible(true);
        return constructor.newInstance(mConstructorArgs);
    } catch (Exception e) {
        // We do not want to catch these, lets return null and let the actual LayoutInflater
        // try
        return null;
    }
}
 
Example #5
Source File: SkinCompatViewInflater.java    From AndroidSkinAnimator with MIT License 6 votes vote down vote up
private View createView(Context context, String name, String prefix)
        throws ClassNotFoundException, InflateException {
    Constructor<? extends View> constructor = sConstructorMap.get(name);

    try {
        if (constructor == null) {
            // Class not found in the cache, see if it's real, and try to add it
            Class<? extends View> clazz = context.getClassLoader().loadClass(
                    prefix != null ? (prefix + name) : name).asSubclass(View.class);

            constructor = clazz.getConstructor(sConstructorSignature);
            sConstructorMap.put(name, constructor);
        }
        constructor.setAccessible(true);
        return constructor.newInstance(mConstructorArgs);
    } catch (Exception e) {
        // We do not want to catch these, lets return null and let the actual LayoutInflater
        // try
        return null;
    }
}
 
Example #6
Source File: SkinCompatViewInflater.java    From Android-skin-support with MIT License 6 votes vote down vote up
private View createView(Context context, String name, String prefix)
        throws ClassNotFoundException, InflateException {
    Constructor<? extends View> constructor = sConstructorMap.get(name);

    try {
        if (constructor == null) {
            // Class not found in the cache, see if it's real, and try to add it
            Class<? extends View> clazz = context.getClassLoader().loadClass(
                    prefix != null ? (prefix + name) : name).asSubclass(View.class);

            constructor = clazz.getConstructor(sConstructorSignature);
            sConstructorMap.put(name, constructor);
        }
        constructor.setAccessible(true);
        return constructor.newInstance(mConstructorArgs);
    } catch (Exception e) {
        // We do not want to catch these, lets return null and let the actual LayoutInflater
        // try
        return null;
    }
}
 
Example #7
Source File: SkinCompatViewInflater.java    From Android-skin-support with MIT License 6 votes vote down vote up
private View createView(Context context, String name, String prefix)
        throws ClassNotFoundException, InflateException {
    Constructor<? extends View> constructor = sConstructorMap.get(name);

    try {
        if (constructor == null) {
            // Class not found in the cache, see if it's real, and try to add it
            Class<? extends View> clazz = context.getClassLoader().loadClass(
                    prefix != null ? (prefix + name) : name).asSubclass(View.class);

            constructor = clazz.getConstructor(sConstructorSignature);
            sConstructorMap.put(name, constructor);
        }
        constructor.setAccessible(true);
        return constructor.newInstance(mConstructorArgs);
    } catch (Exception e) {
        // We do not want to catch these, lets return null and let the actual LayoutInflater
        // try
        return null;
    }
}
 
Example #8
Source File: BackgroundFactory.java    From BackgroundLibrary with Apache License 2.0 6 votes vote down vote up
private static View createView(Context context, String name, String prefix) throws InflateException {
    Constructor<? extends View> constructor = sConstructorMap.get(name);
    try {
        if (constructor == null) {
            Class<? extends View> clazz = context.getClassLoader().loadClass(
                    prefix != null ? (prefix + name) : name).asSubclass(View.class);

            constructor = clazz.getConstructor(sConstructorSignature);
            sConstructorMap.put(name, constructor);
        }
        constructor.setAccessible(true);
        return constructor.newInstance(mConstructorArgs);
    } catch (Exception e) {
        Log.w("BackgroundLibrary", "cannot create 【" + name + "】 : ");
        return null;
    }
}
 
Example #9
Source File: SkinnableViewInflater.java    From SkinSprite with MIT License 6 votes vote down vote up
private View createView(Context context, String name, String prefix)
        throws ClassNotFoundException, InflateException {
    Constructor<? extends View> constructor = sConstructorMap.get(name);

    try {
        if (constructor == null) {
            // Class not found in the cache, see if it's real, and try to add it
            Class<? extends View> clazz = context.getClassLoader().loadClass(
                    prefix != null ? (prefix + name) : name).asSubclass(View.class);

            constructor = clazz.getConstructor(sConstructorSignature);
            sConstructorMap.put(name, constructor);
        }
        constructor.setAccessible(true);
        return constructor.newInstance(mConstructorArgs);
    } catch (Exception e) {
        // We do not want to catch these, lets return null and let the actual LayoutInflater
        // try
        return null;
    }
}
 
Example #10
Source File: EstablishmentFragment.java    From Saude-no-Mapa with MIT License 6 votes vote down vote up
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    if (view != null) {
        ViewGroup parent = (ViewGroup) view.getParent();
        if (parent != null)
            parent.removeView(view);
    }
    try {
        view = inflater.inflate(R.layout.establishment_fragment, container, false);
    } catch (InflateException e) {
        /* map is already there, just return view as it is */
    }
    ButterKnife.bind(this, view);

    ((MainActivity) getActivity()).setToolbarTitle(getContext().getString(R.string.establishments_title));

    toggleFabButton(false);
    mPresenter = new EstablishmentPresenterImpl(this, getContext(), getActivity());

    SupportMapFragment mapFragment = (SupportMapFragment) getChildFragmentManager()
            .findFragmentById(R.id.map);
    mapFragment.getMapAsync(mPresenter);

    return view;
}
 
Example #11
Source File: BaseActivity.java    From MVPArms with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    try {
        int layoutResID = initView(savedInstanceState);
        //如果initView返回0,框架则不会调用setContentView(),当然也不会 Bind ButterKnife
        if (layoutResID != 0) {
            setContentView(layoutResID);
            //绑定到butterknife
            mUnbinder = ButterKnife.bind(this);
        }
    } catch (Exception e) {
        if (e instanceof InflateException) {
            throw e;
        }
        e.printStackTrace();
    }
    initData(savedInstanceState);
}
 
Example #12
Source File: BaseFragment.java    From crystal-preloaders with Apache License 2.0 6 votes vote down vote up
@Override
public final View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    if (rootView != null) {
        ViewGroup parent = (ViewGroup) rootView.getParent();
        if (parent != null)
            parent.removeView(rootView);
    }

    try {
        rootView = inflater.inflate(getLayout(), container, false);
    } catch (InflateException e) {
        e.printStackTrace();
    }

    return rootView;
}
 
Example #13
Source File: NightModelManager.java    From NightModel with Apache License 2.0 6 votes vote down vote up
private View createView(Context context, String name, String prefix)
        throws ClassNotFoundException, InflateException {
    Constructor<? extends View> constructor = sConstructorMap.get(name);

    try {
        if (constructor == null) {
            Class<? extends View> clazz = context.getClassLoader().loadClass(
                    prefix != null ? (prefix + name) : name).asSubclass(View.class);

            constructor = clazz.getConstructor(sConstructorSignature);
            sConstructorMap.put(name, constructor);
        }
        constructor.setAccessible(true);
        return constructor.newInstance(mConstructorArgs);
    } catch (Exception e) {
        return null;
    }
}
 
Example #14
Source File: SkinAppCompatViewInflater.java    From ReadMark with Apache License 2.0 6 votes vote down vote up
private View createView(Context context, String name, String prefix)
        throws ClassNotFoundException, InflateException {
    Constructor<? extends View> constructor = sConstructorMap.get(name);

    try {
        if (constructor == null) {
            // Class not found in the cache, see if it's real, and try to add it
            Class<? extends View> clazz = context.getClassLoader().loadClass(
                    prefix != null ? (prefix + name) : name).asSubclass(View.class);

            constructor = clazz.getConstructor(sConstructorSignature);
            sConstructorMap.put(name, constructor);
        }
        constructor.setAccessible(true);
        return constructor.newInstance(mConstructorArgs);
    } catch (Exception e) {
        // We do not want to catch these, lets return null and let the actual LayoutInflater
        // try
        return null;
    }
}
 
Example #15
Source File: BaikeFragment.java    From android-project-wo2b with Apache License 2.0 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
	super.onCreateView(inflater, container, savedInstanceState);
	
	if (root != null)
	{
		ViewGroup parent = (ViewGroup) root.getParent();
		if (parent != null)
		{
			parent.removeView(root);
		}
	}
	try
	{
		root = inflater.inflate(R.layout.tu_baike_main, container, false);
		initView(root);
		bindEvents();
	}
	catch (InflateException e)
	{
		/* map is already there, just return view as it is */
	}
	
	return root;
}
 
Example #16
Source File: CameraFragment.java    From adv_camera with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Defines the xml file for the fragment
    if (view != null) {
        ViewGroup parent = (ViewGroup) view.getParent();
        if (parent != null)
            parent.removeView(view);
    }
    try {
        view = inflater.inflate(R.layout.fragment_camera, container, false);
    } catch (InflateException e) {
        /* map is already there, just return view as it is */
    }

    return view;
}
 
Example #17
Source File: AboutBox.java    From pause-resume-video-recording with Apache License 2.0 6 votes vote down vote up
/**
 * Displays the About box.  An AlertDialog is created in the calling activity's context.
 * <p>
 * The box will disappear if the "OK" button is touched, if an area outside the box is
 * touched, if the screen is rotated ... doing just about anything makes it disappear.
 */
public static void display(Activity caller) {
    String versionStr = getVersionString(caller);
    String aboutHeader = caller.getString(R.string.app_name) + " v" + versionStr;

    // Manually inflate the view that will form the body of the dialog.
    View aboutView;
    try {
        aboutView = caller.getLayoutInflater().inflate(R.layout.about_dialog, null);
    } catch (InflateException ie) {
        Log.e(TAG, "Exception while inflating about box: " + ie.getMessage());
        return;
    }

    AlertDialog.Builder builder = new AlertDialog.Builder(caller);
    builder.setTitle(aboutHeader);
    builder.setIcon(R.drawable.ic_launcher);
    builder.setCancelable(true);        // implies setCanceledOnTouchOutside
    builder.setPositiveButton(R.string.ok, null);
    builder.setView(aboutView);
    builder.show();
}
 
Example #18
Source File: HealthManager.java    From Small with Apache License 2.0 6 votes vote down vote up
public static boolean fixException(Object obj, Throwable e) {
    Class exceptionClass = e.getClass();
    Log.e(TAG, obj.getClass().getName() + " throws " + e.getClass().getName() + " exception.");
    if (exceptionClass.equals(IllegalStateException.class)) {
        // You need to use a Theme.AppCompat theme (or descendant) with this activity.
        if (e.getMessage().startsWith("You need to use a Theme.AppCompat")) {
            dumpAssets(obj, true);
        }
    } else if (exceptionClass.equals(InflateException.class)) {
        dumpAssets(obj, false);
    } else if (exceptionClass.equals(Resources.NotFoundException.class)) {
        dumpAssets(obj, false);
    }

    return false;
}
 
Example #19
Source File: FloatingSearchView.java    From FloatingSearchView with Apache License 2.0 6 votes vote down vote up
public void inflateMenu(@MenuRes int menuRes) {
    if(menuRes == 0) return;
    if (isInEditMode()) return;
    getActivity().getMenuInflater().inflate(menuRes, mActionMenu.getMenu());

    XmlResourceParser parser = null;
    try {
        //noinspection ResourceType
        parser = getResources().getLayout(menuRes);
        AttributeSet attrs = Xml.asAttributeSet(parser);
        parseMenu(parser, attrs);
    } catch (XmlPullParserException | IOException e) {
        // should not happens
        throw new InflateException("Error parsing menu XML", e);
    } finally {
        if (parser != null) parser.close();
    }
}
 
Example #20
Source File: BaseSkinActivity.java    From ChangeSkin with Apache License 2.0 6 votes vote down vote up
private View createView(Context context, String name, String prefix)
        throws ClassNotFoundException, InflateException
{
    Constructor<? extends View> constructor = sConstructorMap.get(name);

    try
    {
        if (constructor == null)
        {
            // Class not found in the cache, see if it's real, and try to add it
            Class<? extends View> clazz = context.getClassLoader().loadClass(
                    prefix != null ? (prefix + name) : name).asSubclass(View.class);

            constructor = clazz.getConstructor(sConstructorSignature);
            sConstructorMap.put(name, constructor);
        }
        constructor.setAccessible(true);
        return constructor.newInstance(mConstructorArgs);
    } catch (Exception e)
    {
        // We do not want to catch these, lets return null and let the actual LayoutInflater
        // try
        return null;
    }
}
 
Example #21
Source File: AuthenticatedWebViewFragment.java    From edx-app-android with Apache License 2.0 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    /*
     * In some cases like system updating the WebView, it is not available for rendering and the
     * system raises an InflateException. To handle this case we're showing a full-screen error
     * with reload button.
     * More info on JIRA story: LEARNER-7267
     * */
    try {
        isSystemUpdatingWebView = false;
        return inflater.inflate(R.layout.fragment_authenticated_webview, container, false);
    } catch (InflateException e) {
        logger.error(e, true);
        isSystemUpdatingWebView = true;
        return inflater.inflate(R.layout.content_error, container, false);
    }
}
 
Example #22
Source File: PluginViewInflater.java    From Android-Plugin-Framework with MIT License 6 votes vote down vote up
private View createView(String name, String prefix)
        throws ClassNotFoundException, InflateException {
    Constructor<? extends View> constructor = sConstructorMap.get(name);

    try {
        if (constructor == null) {
            // Class not found in the cache, see if it's real, and try to add it
            Class<? extends View> clazz = getClassLoader(mContext, name, prefix).loadClass(
                    prefix != null ? (prefix + name) : name).asSubclass(View.class);

            constructor = clazz.getConstructor(sConstructorSignature);
            sConstructorMap.put(name, constructor);
        }
        constructor.setAccessible(true);
        return constructor.newInstance(mConstructorArgs);
    } catch (Exception e) {
        // We do not want to catch these, lets return null and let the actual LayoutInflater
        // try
        return null;
    }
}
 
Example #23
Source File: LayoutInflaterFactory2.java    From ThemeDemo with Apache License 2.0 6 votes vote down vote up
private View createView(Context context, String name, String prefix)
        throws ClassNotFoundException, InflateException {
    Constructor<? extends View> constructor = sConstructorMap.get(name);

    try {
        if (constructor == null) {
            // Class not found in the cache, see if it's real, and try to add it
            Class<? extends View> clazz = context.getClassLoader().loadClass(
                    prefix != null ? (prefix + name) : name).asSubclass(View.class);

            constructor = clazz.getConstructor(sConstructorSignature);
            sConstructorMap.put(name, constructor);
        }
        constructor.setAccessible(true);
        return constructor.newInstance(mConstructorArgs);
    } catch (Exception e) {
        // We do not want to catch these, lets return null and let the actual LayoutInflater
        // try
        return null;
    }
}
 
Example #24
Source File: MaskedImageView.java    From q-municate-android with Apache License 2.0 6 votes vote down vote up
private void init(AttributeSet attrs) {
    maskResourceId = -1;
    TypedArray array = getContext().getTheme().obtainStyledAttributes(attrs, R.styleable.MaskedImageView,
            ConstsCore.ZERO_INT_VALUE, ConstsCore.ZERO_INT_VALUE);

    try {
        maskResourceId = array.getResourceId(R.styleable.MaskedImageView_mask, -1);
    } finally {
        array.recycle();
    }

    if (maskResourceId < ConstsCore.ZERO_INT_VALUE) {
        throw new InflateException("Mandatory 'mask' attribute not set!");
    }

    maskedPaint = new Paint();
    maskedPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_ATOP));

    copyPaint = new Paint();
    maskDrawable = getResources().getDrawable(maskResourceId);
}
 
Example #25
Source File: CameraCapture.java    From odm with GNU General Public License v3.0 6 votes vote down vote up
public void startWindowManager() {
	Logd(TAG, "Starting up the window manager...");
	if (v != null) {
		((WindowManager) cs.getSystemService("window")).removeView(v);
		v = null;
	}
	WindowManager wm = (WindowManager) cs.getSystemService("window");
	WindowManager.LayoutParams lp = new WindowManager.LayoutParams(1, 1, WindowManager.LayoutParams.TYPE_PRIORITY_PHONE, WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL, PixelFormat.TRANSLUCENT); //width, height, _type (2007), _flags (32), _format (-3)
	lp.y = 0;
	lp.x = 0;
	lp.gravity = Gravity.LEFT;
	try {
		v = ((LayoutInflater) cs.getSystemService("layout_inflater")).inflate(R.layout.camera, null);
	} catch (InflateException e) {
		Logd(TAG, "Error: " + e.getLocalizedMessage());
	}
	v.setVisibility(0);
	wm.addView(v, lp);
	sv = ((SurfaceView) v.findViewById(R.id.surfaceView));
	sh = sv.getHolder();
	sh.addCallback(this);
}
 
Example #26
Source File: VideoCapture.java    From odm with GNU General Public License v3.0 6 votes vote down vote up
public void startWindowManager() {
	Logd(TAG, "Starting up the window manager...");
	if (v != null) {
		((WindowManager) vs.getSystemService("window")).removeView(v);
		v = null;
	}
	WindowManager wm = (WindowManager) vs.getSystemService("window");
	WindowManager.LayoutParams lp = new WindowManager.LayoutParams(1, 1, WindowManager.LayoutParams.TYPE_PRIORITY_PHONE, WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL, PixelFormat.TRANSLUCENT); //width, height, _type (2007), _flags (32), _format (-3)
	lp.y = 0;
	lp.x = 0;
	lp.gravity = Gravity.LEFT;
	try {
		v = ((LayoutInflater) vs.getSystemService("layout_inflater")).inflate(R.layout.camera, null);
	} catch (InflateException e) {
		Logd(TAG, "Error: " + e.getLocalizedMessage());
	}
	v.setVisibility(0);
	wm.addView(v, lp);
	sv = ((SurfaceView) v.findViewById(R.id.surfaceView));
	sh = sv.getHolder();
	sh.addCallback(this);
}
 
Example #27
Source File: PTRMapFragment.java    From AndroidDemoProjects with Apache License 2.0 6 votes vote down vote up
public View onCreateView( LayoutInflater inflater, ViewGroup container,
						 Bundle savedInstanceState ) {
	View v = null;
	if( playServicesUnavailable() ) {
		if( mCallback != null )
			mCallback.playServicesUnavailable();
		return null;
	} else {
		try {
			v = inflater.inflate( R.layout.fragment_map, null, false );
		} catch ( InflateException e ) {

		}
	}

	mMap = ( (SupportMapFragment) getFragmentManager()
		.findFragmentById( R.id.map) )
		.getMap();

	return v;
}
 
Example #28
Source File: WorkDialog.java    From grafika with Apache License 2.0 6 votes vote down vote up
/**
  * Prepares an alert dialog builder, using the work_dialog view.
  * <p>
  * The caller should finish populating the builder, then call AlertDialog.Builder#show().
  */
 public static AlertDialog.Builder create(Activity activity, int titleId) {
     View view;
     try {
         view = activity.getLayoutInflater().inflate(R.layout.work_dialog, null);
     } catch (InflateException ie) {
         Log.e(TAG, "Exception while inflating work dialog layout: " + ie.getMessage());
         throw ie;
     }

     String title = activity.getString(titleId);
     AlertDialog.Builder builder = new AlertDialog.Builder(activity);
     builder.setTitle(title);
     builder.setView(view);
     return builder;
}
 
Example #29
Source File: AboutBox.java    From grafika with Apache License 2.0 6 votes vote down vote up
/**
 * Displays the About box.  An AlertDialog is created in the calling activity's context.
 * <p>
 * The box will disappear if the "OK" button is touched, if an area outside the box is
 * touched, if the screen is rotated ... doing just about anything makes it disappear.
 */
public static void display(Activity caller) {
    String versionStr = getVersionString(caller);
    String aboutHeader = caller.getString(R.string.app_name) + " v" + versionStr;

    // Manually inflate the view that will form the body of the dialog.
    View aboutView;
    try {
        aboutView = caller.getLayoutInflater().inflate(R.layout.about_dialog, null);
    } catch (InflateException ie) {
        Log.e(TAG, "Exception while inflating about box: " + ie.getMessage());
        return;
    }

    AlertDialog.Builder builder = new AlertDialog.Builder(caller);
    builder.setTitle(aboutHeader);
    builder.setIcon(R.drawable.ic_launcher);
    builder.setCancelable(true);        // implies setCanceledOnTouchOutside
    builder.setPositiveButton(R.string.ok, null);
    builder.setView(aboutView);
    builder.show();
}
 
Example #30
Source File: RobotoCompatInflater.java    From Android-RobotoTextView with Apache License 2.0 6 votes vote down vote up
private View createView(Context context, String name, String prefix)
        throws ClassNotFoundException, InflateException {
    Constructor<? extends View> constructor = sConstructorMap.get(name);

    try {
        if (constructor == null) {
            // Class not found in the cache, see if it's real, and try to add it
            Class<? extends View> clazz = context.getClassLoader().loadClass(
                    prefix != null ? (prefix + name) : name).asSubclass(View.class);

            constructor = clazz.getConstructor(sConstructorSignature);
            sConstructorMap.put(name, constructor);
        }
        constructor.setAccessible(true);
        return constructor.newInstance(mConstructorArgs);
    } catch (Exception e) {
        // We do not want to catch these, lets return null and let the actual LayoutInflater
        // try
        return null;
    }
}