Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright 2013 Naver Business Platform Corp. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. /
 
 package com.handmark.pulltorefresh.library;
 
 
 
 
Factory which creates google style view layouts
Google style view layouts must be listed in pulltorefresh.xml as "PullToRefresh/GoogleStyleViewLayouts/layout" nodes

Author(s):
Wonjun Kim
 
 
 	private static final String LOG_TAG = GoogleStyleViewLayoutFactory.class
Create the class token matched by layoutCode

Parameters:
layoutCode Google style view layout code, which must be defined in pulltorefresh.xml
Returns:
Class token which is matched by layoutCode, or the class token of RotateGoogleStyleViewLayout instance if not
 
 	public static Class<? extends GoogleStyleViewLayoutcreateGoogleStyleViewLayoutClazzByLayoutCode(String layoutCode) {
 		String clazzName = PullToRefreshXmlConfiguration.getInstance().getGoogleStyleViewLayoutClazzName(layoutCode);
 		return createGoogleStyleViewLayoutClazz(clazzName);
 	}
Create a GoogleStyleViewLayout instance matched by clazz token

Parameters:
layoutCode Google style view layout code, which must be defined in pulltorefresh.xml
context
Returns:
GoogleStyleViewLayout instance if the class matched by layoutCode exists, or RotateGoogleStyleViewLayout instance if not
 
 	@SuppressWarnings("unchecked")
 			String clazzName) {
 		Class<? extends GoogleStyleViewLayoutgoogleStyleViewLayoutClazz = null;
 		if ( clazzName == null ) {
 			googleStyleViewLayoutClazz = DefaultGoogleStyleViewLayoutFactory.createGoogleStyleViewLayoutClazz(clazzName);
 			return googleStyleViewLayoutClazz;
 		}
 		
 		try {
 			googleStyleViewLayoutClazz = (Class<GoogleStyleViewLayout>) Class.forName(clazzName);
 
 		} catch (ClassNotFoundException e) {
 			Log.e(,"The google style view layout you have chosen class has not been found."e);
 			googleStyleViewLayoutClazz = DefaultGoogleStyleViewLayoutFactory.createGoogleStyleViewLayoutClazz(clazzName);
 		} 
 
 		return googleStyleViewLayoutClazz;
 	}
Create a GoogleStyleViewLayout instance matched by layoutCode

Parameters:
layoutCode Google style view layout code, which must be defined in pulltorefresh.xml
context
Returns:
GoogleStyleViewLayout instance if the class matched by layoutCode exists, or DefaultGoogleStyleViewLayout instance if not
 
 	public static GoogleStyleViewLayout createGoogleStyleViewLayout(String layoutCodeContext contextTypedArray attrs) {
 		Class<? extends GoogleStyleViewLayoutclazz = createGoogleStyleViewLayoutClazz(layoutCode);
 		return createGoogleStyleViewLayout(clazzcontextattrs);
 	}
Create a GoogleStyleViewLayout instance matched by clazz token

Parameters:
layoutCode Google style view layout code, which must be defined in pulltorefresh.xml
context
Returns:
GoogleStyleViewLayout instance if the class matched by layoutCode exists, or DefaultGoogleStyleViewLayout instance if not
 
 			Class<? extends GoogleStyleViewLayoutclazzContext contextTypedArray attrs) {
 		GoogleStyleViewLayout layout = null;
 		// Prevent NullPointerException
 		if ( clazz == null ) {
 			Log.i("The Class token of the GoogleStyleViewLayout is missing. Default google style view layout will be used.");
 			clazz = DefaultGoogleStyleViewLayoutFactory.createGoogleStyleViewLayoutClazz("");
 		}
 		
		layout = tryNewInstance(clazzcontextattrs);
		// If trying to create new instance has failed,
		if (layout == null) {
			layout = DefaultGoogleStyleViewLayoutFactory.createGoogleStyleViewLayout(clazzcontextattrs);
		}
		return layout;
	}
			Class<? extends GoogleStyleViewLayoutclazzContext contextTypedArray attrs) {
		GoogleStyleViewLayout layout = null;
		try {
			Constructor<? extends GoogleStyleViewLayoutconstructor = clazz
			layout = (GoogleStyleViewLayoutconstructor.newInstance(contextattrs);
catch (IllegalArgumentException e) {
			Log.e("The google style view layout has failed to be created. "e);
catch (InvocationTargetException e) {
			Log.e("The google style view layout has failed to be created. "e);
catch (SecurityException e) {
			Log.e("The google style view layout has failed to be created. "e);
catch (NoSuchMethodException e) {
			Log.e("The google style view layout has failed to be created. "e);
catch (InstantiationException e) {
			Log.e("The google style view layout has failed to be created. "e);
catch (IllegalAccessException e) {
			Log.e("The google style view layout has failed to be created. "e);
catch (NullPointerException e) {
			Log.e("The google style view layout has failed to be created. "e);
		}
		return layout;
	}
Factory which creates a default google style view layout instance. This is used when GoogleStyleViewLayoutFactory fails to create a instance

Author(s):
Wonjun Kim
	private static class DefaultGoogleStyleViewLayoutFactory {

Parameters:
clazzName This class name is being ignored
Returns:
Class token of DefaultGoogleStyleViewLayout
				String clazzName) {
		}

Parameters:
clazz Class token is being ignored.
context
Returns:
DefaultGoogleStyleViewLayout instance
				Class<? extends GoogleStyleViewLayoutclazzContext contextTypedArray attrs) {
			return new DefaultGoogleStyleViewLayout(contextattrs);
		}
	}
New to GrepCode? Check out our FAQ X