Java Code Examples for android.view.InflateException

The following are top voted examples for showing how to use android.view.InflateException. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: Hitalk   File: FloatingSearchView.java   View source code 7 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 2
Project: boohee_v5.6   File: SupportMenuInflater.java   View source code 7 votes vote down vote up
public void inflate(int menuRes, Menu menu) {
    if (menu instanceof SupportMenu) {
        XmlResourceParser parser = null;
        try {
            parser = this.mContext.getResources().getLayout(menuRes);
            parseMenu(parser, Xml.asAttributeSet(parser), menu);
            if (parser != null) {
                parser.close();
            }
        } catch (XmlPullParserException e) {
            throw new InflateException("Error inflating menu XML", e);
        } catch (IOException e2) {
            throw new InflateException("Error inflating menu XML", e2);
        } catch (Throwable th) {
            if (parser != null) {
                parser.close();
            }
        }
    } else {
        super.inflate(menuRes, menu);
    }
}
 
Example 3
Project: AndroidSkinAnimator   File: SkinCompatViewInflater.java   View source code 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 4
Project: grafika   File: WorkDialog.java   View source code 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 5
Project: grafika   File: AboutBox.java   View source code 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 6
Project: Android-skin-support   File: SkinCompatViewInflater.java   View source code 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
Project: Android-skin-support   File: SkinCompatViewInflater.java   View source code 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
Project: ReadMark   File: SkinAppCompatViewInflater.java   View source code 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 9
Project: solved-hacking-problem   File: C0253i.java   View source code 6 votes vote down vote up
public void inflate(int i, Menu menu) {
    if (menu instanceof C0089a) {
        XmlResourceParser xmlResourceParser = null;
        try {
            xmlResourceParser = this.f868e.getResources().getLayout(i);
            m2024a(xmlResourceParser, Xml.asAttributeSet(xmlResourceParser), menu);
            if (xmlResourceParser != null) {
                xmlResourceParser.close();
            }
        } catch (Throwable e) {
            throw new InflateException("Error inflating menu XML", e);
        } catch (Throwable e2) {
            throw new InflateException("Error inflating menu XML", e2);
        } catch (Throwable th) {
            if (xmlResourceParser != null) {
                xmlResourceParser.close();
            }
        }
    } else {
        super.inflate(i, menu);
    }
}
 
Example 10
Project: solved-hacking-problem   File: C0253i.java   View source code 6 votes vote down vote up
public void inflate(int i, Menu menu) {
    if (menu instanceof C0089a) {
        XmlResourceParser xmlResourceParser = null;
        try {
            xmlResourceParser = this.f868e.getResources().getLayout(i);
            m2024a(xmlResourceParser, Xml.asAttributeSet(xmlResourceParser), menu);
            if (xmlResourceParser != null) {
                xmlResourceParser.close();
            }
        } catch (Throwable e) {
            throw new InflateException("Error inflating menu XML", e);
        } catch (Throwable e2) {
            throw new InflateException("Error inflating menu XML", e2);
        } catch (Throwable th) {
            if (xmlResourceParser != null) {
                xmlResourceParser.close();
            }
        }
    } else {
        super.inflate(i, menu);
    }
}
 
Example 11
Project: GSYVideoPlayer   File: GSYVideoView.java   View source code 6 votes vote down vote up
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();
        }
    }
}
 
Example 12
Project: permissionsModule   File: AppCompatViewInflater.java   View source code 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 13
Project: zhizhihuhu   File: NightModelManager.java   View source code 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
Project: GComic   File: FloatingSearchView.java   View source code 6 votes vote down vote up
public void inflateMenu(@MenuRes int menuRes) {
    if (menuRes == 0) 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 15
Project: mediacodec   File: WorkDialog.java   View source code 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 16
Project: mediacodec   File: AboutBox.java   View source code 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 17
Project: FloatingSearchView   File: FloatingSearchView.java   View source code 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 18
Project: cpe-manifest-android-experience   File: ExtraLeftListFragment.java   View source code 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    if (view != null) {
        ViewGroup parent = (ViewGroup) view.getParent();
        if (parent != null)
            parent.removeView(view);
    }
    try {
        view = inflater.inflate(R.layout.next_gen_list_view, container, false);
    } catch (InflateException e) {
    /* map is already there, just return view as it is */
    }
    return view;

}
 
Example 19
Project: cpe-manifest-android-experience   File: AbstractNextGenFragment.java   View source code 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    if (view != null) {
        ViewGroup parent = (ViewGroup) view.getParent();
        if (parent != null)
            parent.removeView(view);
    }
    try {
        view = inflater.inflate(getContentViewId(), container, false);
    } catch (InflateException e) {
        NextGenLogger.e(F.TAG, e.getLocalizedMessage());
    }
    return view;

}
 
Example 20
Project: cpe-manifest-android-experience   File: IMEBottomFragment.java   View source code 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    if (view != null) {
        ViewGroup parent = (ViewGroup) view.getParent();
        if (parent != null)
            parent.removeView(view);
    }
    try {
        view = inflater.inflate(R.layout.next_gen_ime_lower_frame, container, false);
    } catch (InflateException e) {
    /* map is already there, just return view as it is */
    }
    return view;

}
 
Example 21
Project: SkinSprite   File: SkinnableViewInflater.java   View source code 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 22
Project: Saude-no-Mapa   File: EstablishmentFragment.java   View source code 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 23
Project: NightModel   File: NightModelManager.java   View source code 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 24
Project: CanAdapter   File: CanErvAdapter.java   View source code 6 votes vote down vote up
public CanErvAdapter(RecyclerView mRecyclerView) {
    super();
    this.mContext = mRecyclerView.getContext();
    this.mRecyclerView = mRecyclerView;
    this.mGroupList = new ArrayList<>();
    this.mChildList = new ArrayList<>();

    RecyclerView.LayoutManager manager = mRecyclerView.getLayoutManager();

    if (manager == null) {
        throw new InflateException("LayoutManager is null");
    }
    if (manager instanceof GridLayoutManager) {

        mSpanCount = ((GridLayoutManager) manager).getSpanCount();
    }


}
 
Example 25
Project: Android-Plugin-Framework   File: PluginViewInflater.java   View source code 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 26
Project: ReadMark   File: SkinAppCompatViewInflater.java   View source code 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 27
Project: android-project-wo2b   File: BaikeFragment.java   View source code 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 28
Project: pause-resume-video-recording   File: WorkDialog.java   View source code 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
Project: pause-resume-video-recording   File: AboutBox.java   View source code 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
Project: FMTech   File: SupportMenuInflater.java   View source code 6 votes vote down vote up
public InflatedOnMenuItemClickListener(Object paramObject, String paramString)
{
  this.mRealOwner = paramObject;
  Class localClass = paramObject.getClass();
  try
  {
    this.mMethod = localClass.getMethod(paramString, PARAM_TYPES);
    return;
  }
  catch (Exception localException)
  {
    InflateException localInflateException = new InflateException("Couldn't resolve menu item onClick handler " + paramString + " in class " + localClass.getName());
    localInflateException.initCause(localException);
    throw localInflateException;
  }
}
 
Example 31
Project: FMTech   File: AppCompatViewInflater.java   View source code 6 votes vote down vote up
private View createView(Context paramContext, String paramString1, String paramString2)
  throws ClassNotFoundException, InflateException
{
  Constructor localConstructor = (Constructor)sConstructorMap.get(paramString1);
  if (localConstructor == null) {}
  try
  {
    ClassLoader localClassLoader = paramContext.getClassLoader();
    if (paramString2 != null) {}
    for (String str = paramString2 + paramString1;; str = paramString1)
    {
      localConstructor = localClassLoader.loadClass(str).asSubclass(View.class).getConstructor(sConstructorSignature);
      sConstructorMap.put(paramString1, localConstructor);
      localConstructor.setAccessible(true);
      View localView = (View)localConstructor.newInstance(this.mConstructorArgs);
      return localView;
    }
    return null;
  }
  catch (Exception localException) {}
}
 
Example 32
Project: Small   File: HealthManager.java   View source code 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 33
Project: FloatingSearchView   File: FloatingSearchView.java   View source code 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 34
Project: ChangeSkin   File: BaseSkinActivity.java   View source code 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 35
Project: mc_backup   File: GeckoMenuInflater.java   View source code 6 votes vote down vote up
@Override
public void inflate(int menuRes, Menu menu) {

    // This does not check for a well-formed XML.

    XmlResourceParser parser = null;
    try {
        parser = mContext.getResources().getXml(menuRes);
        AttributeSet attrs = Xml.asAttributeSet(parser);

        parseMenu(parser, attrs, menu);

    } catch (XmlPullParserException | IOException e) {
        throw new InflateException("Error inflating menu XML", e);
    } finally {
        if (parser != null)
            parser.close();
    }
}
 
Example 36
Project: android-breakout   File: AboutBox.java   View source code 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, 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 37
Project: HardwareEncodingTest   File: WorkDialog.java   View source code 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 38
Project: HardwareEncodingTest   File: AboutBox.java   View source code 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 39
Project: AndroidDemoProjects   File: PTRMapFragment.java   View source code 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 40
Project: ThemeDemo   File: LayoutInflaterFactory2.java   View source code 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;
    }
}