Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright 2011, 2012 Chris Banes. 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.internal;
 
 
 
 @SuppressLint("ViewConstructor")
 public abstract class LoadingLayout extends FrameLayout implements ILoadingLayout {
 
 	static final String LOG_TAG = "PullToRefresh-LoadingLayout";
 
 
 	protected FrameLayout mInnerLayout;
 
 	protected ImageView mHeaderImage;
 
 	private boolean mUseIntrinsicAnimation;
 
 	protected TextView mHeaderText;
 	protected TextView mSubHeaderText;
 
 	protected final Mode mMode;
 	protected final Orientation mScrollDirection;
 
 
 	private Drawable mImageDrawable;

The constructor to customize layout, not public scope now.

Parameters:
context
mode
scrollDirection
 
 	protected LoadingLayout(Context contextfinal Mode modefinal Orientation scrollDirectionTypedArray attrsint inflateId) {
 		super(context);
 		 = mode;
 		 = scrollDirection;
 
 		initInflate(contextinflateId);
 		initProperties(contextmodeattrs);
 
 		if (null != ) {
 			 = null;
 		}
 
 		reset();	
 		
 	}
 	
 	public LoadingLayout(Context contextfinal Mode modefinal Orientation scrollDirectionTypedArray attrs) {
 		super(context);
 		 = mode;
 		 = scrollDirection;
 
 		switch (scrollDirection) {
				break;
			case :
			default:
				break;
		}
		if (null != ) {
			switch (mode) {
					lp.gravity = scrollDirection == . ? . : .;
					break;
				default:
					lp.gravity = scrollDirection == . ? . : .;
					break;
			}			
		}
		initProperties(contextmodeattrs);
		// If we don't have a user defined drawable, load the default
		if (null == ) {
		}
		// Set Drawable, and save width/height
	}
	protected void initComponents() {
	}
	private void initInflate(Context contextint inflateId) {
		LayoutInflater.from(context).inflate(inflateIdthis);
	}
	protected void initProperties(Context contextfinal Mode mode,
			TypedArray attrs) {
		// Load Loading Layout Labels
		loadLoadingLayoutLabels(contextattrsmode);
			if (null != background) {
				ViewCompat.setBackground(thisbackground);
			}
		}
			TypedValue styleID = new TypedValue();
			setTextAppearance(styleID.data);
		}
			TypedValue styleID = new TypedValue();
			setSubTextAppearance(styleID.data);
		}
		// Text Color attrs need to be set after TextAppearance attrs
			if (null != colors) {
				setTextColor(colors);
			}
		}
			if (null != colors) {
			}
		}
		// Try and get defined drawable from Attrs
		}
		// Check Specific Drawable from Attrs, these overrite the generic
		// drawable attr above
		switch (mode) {
			default:
					Utils.warnDeprecation("ptrDrawableTop""ptrDrawableStart");
				}
				break;
					Utils.warnDeprecation("ptrDrawableBottom""ptrDrawableEnd");
				}
				break;
		}
	}

Load labels of pull, refresh, release, and assign into fields
Convert an each attribute value such as ptrPullLabel, ptrRefreshLabel or ptrReleaseLabel to each label field if each value exists.
Or if not, then the each label is assigned some string as default
NOTE : This method Must be modified if kinds of Mode are increased.

Parameters:
attrs
mode Current mode
	private void loadLoadingLayoutLabels(Context contextTypedArray attrsMode mode) {
		 = loadPullLabel(contextattrsmode);
		 = loadRefreshingLabel(contextattrsmode);
		 = loadReleaseLabel(contextattrsmode);
	}
Load labels of pull
Convert an ptrPullLabel attribute value to mPullLabel field if each value exists.
Or if not, then the pull label is assigned some string as default
If you want to set some custom pull label at sub class, you have to override this method and implement. NOTE : This method Must be modified if kinds of Mode are increased.

Parameters:
context
attrs
mode
Returns:
String to be a pull label
	protected String loadPullLabel(Context contextTypedArray attrsMode mode) {
		// Pull Label
		return context.getString(stringId);
	}	
Load labels of refreshing
Convert an ptrRefreshLabel attribute value to mRefreshingLabel field if each value exists.
Or if not, then the refreshing label is assigned some string as default
If you want to set some custom refreshing label at sub class, you have to override this method and implement. NOTE : This method Must be modified if kinds of Mode are increased.

Parameters:
context
attrs
mode
Returns:
String to be a refreshing label
	protected String loadRefreshingLabel(Context contextTypedArray attrs,
			Mode mode) {
		// Refresh Label
		return context.getString(stringId);
	}	
Load labels of release
Convert an ptrReleaseLabel attribute value to mReleaseLabel field if each value exists.
Or if not, then the release label is assigned some string as default
If you want to set some custom release label at sub class, you have to override this method and implement. NOTE : This method Must be modified if kinds of Mode are increased.

Parameters:
context
attrs
mode
Returns:
String to be a refreshing label
	protected String loadReleaseLabel(Context contextTypedArray attrsMode mode) {
		// Release Label
		return context.getString(stringId);
	}
	public void setHeight(int height) {
		lp.height = height;
	}
	public final void setWidth(int width) {
		lp.width = width;
	}
	public final int getContentSize() {
		switch () {
			case :
			default:
		}
	}
	public final void hideAllViews() {
	}
	private void hideHeaderText() {
		if (null !=  && . == .getVisibility()) {
		}
	}
	private void hideHeaderProgress() {
		}
	}
	private void hideSubHeaderText() {
		if (null !=  && . == .getVisibility()) {
		}
	}
	public final void onPull(float scaleOfLayout) {
			onPullImpl(scaleOfLayout);
		}
	}
	public final void pullToRefresh() {
		if (null != ) {
		}
		// Now call the callback
	}
	public final void refreshing() {
		if (null != ) {
		}
		if (null !=  && ) {
else {
			// Now call the callback
		}
		if (null != ) {
		}
	}
	public final void releaseToRefresh() {
		if (null != ) {
		}
		// Now call the callback
	}
	public final void reset() {
		if (null != ) {
		}
		if (null !=  && ) {
else {
			// Now call the callback
		}		
		if (null != ) {
			if (TextUtils.isEmpty(.getText())) {
else {
			}
		}
	}
	private void showHeaderImage() {
		if (null !=  && . == .getVisibility()) {
		}
	}
	private void hideHeaderImage() {
		if (null !=  && . == .getVisibility() ) {
		}		
	}
	public void setLastUpdatedLabel(CharSequence label) {
	}
	public final void setLoadingDrawable(Drawable imageDrawable) {
		// Set Drawable
		if ( null !=  ) {
		}
		 = (imageDrawable instanceof AnimationDrawable);
		// Now call the callback
		onLoadingDrawableSet(imageDrawable);
	}
	public void setPullLabel(CharSequence pullLabel) {
		 = pullLabel;
	}
	public void setRefreshingLabel(CharSequence refreshingLabel) {
		 = refreshingLabel;
	}
	public void setReleaseLabel(CharSequence releaseLabel) {
		 = releaseLabel;
	}
	public void setTextTypeface(Typeface tf) {
		if (null != ) {
		}
	}
	public final void showInvisibleViews() {
	}
	private void showSubHeaderText() {
		}
	}
	private void showHeaderProgress() {
		}
	}
	private void showHeaderText() {
		if (null !=  && . == .getVisibility()) {
		}
	}

Callbacks for derivative Layouts
	protected abstract int getDefaultDrawableResId();
	protected abstract void onLoadingDrawableSet(Drawable imageDrawable);
	protected abstract void onPullImpl(float scaleOfLayout);
	protected abstract void pullToRefreshImpl();
	protected abstract void refreshingImpl();
	protected abstract void releaseToRefreshImpl();
	protected abstract void resetImpl();
	private void setSubHeaderText(CharSequence label) {
		if (null != ) {
			if (TextUtils.isEmpty(label)) {
else {
				// Only set it to Visible if we're GONE, otherwise VISIBLE will
				// be set soon
				}
			}
		}
	}
	private void setSubTextAppearance(int value) {
		if (null != ) {
		}
	}
	private void setSubTextColor(ColorStateList color) {
		if (null != ) {
		}
	}
	private void setTextAppearance(int value) {
		if (null != ) {
		}
		if (null != ) {
		}
	}
	private void setTextColor(ColorStateList color) {
		if (null != ) {
		}
		if (null != ) {
		}
	}