类android.view.InflateException源码实例Demo

下面列出了怎么用android.view.InflateException的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: Focus   文件: HelpDialog.java
@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;
    }
 
源代码2 项目: adv_camera   文件: CameraFragment.java
@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;
}
 
源代码3 项目: BackgroundLibrary   文件: BackgroundFactory.java
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;
    }
}
 
源代码4 项目: BackgroundLibrary   文件: BackgroundFactory.java
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;
    }
}
 
源代码5 项目: Focus   文件: HelpDialog.java
@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;
    }
 
源代码6 项目: NewFastFrame   文件: ViewProducer.java
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;
    }
}
 
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;
    }
}
 
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;
    }
}
 
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;
    }
}
 
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;
    }
}
 
源代码11 项目: ReadMark   文件: SkinAppCompatViewInflater.java
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;
    }
}
 
源代码12 项目: GSYVideoPlayer   文件: GSYVideoView.java
protected void initInflate(Context context) {
    try {
        View.inflate(context, getLayoutId(), this);
    } catch (InflateException e) {
        if (e.toString().contains("GSYImageCover")) {
            Debuger.printfError("********************\n" +
                    "*****   注意   *****" +
                    "********************\n" +
                    "*该版本需要清除布局文件中的GSYImageCover\n" +
                    "****  Attention  ***\n" +
                    "*Please remove GSYImageCover from Layout in this Version\n" +
                    "********************\n");
            e.printStackTrace();
            throw new InflateException("该版本需要清除布局文件中的GSYImageCover,please remove GSYImageCover from your layout");
        } else {
            e.printStackTrace();
        }
    }
}
 
源代码13 项目: FloatingSearchView   文件: FloatingSearchView.java
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();
    }
}
 
源代码14 项目: SkinSprite   文件: SkinnableViewInflater.java
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;
    }
}
 
源代码15 项目: Saude-no-Mapa   文件: EstablishmentFragment.java
@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;
}
 
源代码16 项目: MVPArms   文件: BaseActivity.java
@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);
}
 
源代码17 项目: crystal-preloaders   文件: BaseFragment.java
@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;
}
 
源代码18 项目: NightModel   文件: NightModelManager.java
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;
    }
}
 
源代码19 项目: ReadMark   文件: SkinAppCompatViewInflater.java
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;
    }
}
 
源代码20 项目: android-project-wo2b   文件: BaikeFragment.java
@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;
}
 
源代码21 项目: pause-resume-video-recording   文件: WorkDialog.java
/**
  * 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;
}
 
源代码22 项目: pause-resume-video-recording   文件: AboutBox.java
/**
 * 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();
}
 
源代码23 项目: Small   文件: HealthManager.java
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;
}
 
源代码24 项目: FloatingSearchView   文件: FloatingSearchView.java
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();
    }
}
 
源代码25 项目: ChangeSkin   文件: BaseSkinActivity.java
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;
    }
}
 
@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);
    }
}
 
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;
    }
}
 
源代码28 项目: ThemeDemo   文件: LayoutInflaterFactory2.java
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;
    }
}
 
源代码29 项目: q-municate-android   文件: MaskedImageView.java
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);
}
 
源代码30 项目: odm   文件: CameraCapture.java
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);
}
 
 类所在包
 类方法
 同包方法