AVIARY API TERMS OF USE
Full Legal Agreement
The following terms and conditions and the terms and conditions at http://www.aviary.com/terms (collectively, the ?Terms??)
govern your use of any and ...
If you think the Android project Aviary-Android-SDK listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code
package com.aviary.android.feather.widget;
//fromwww.java2s.comimport android.content.Context;
import android.content.res.Resources.Theme;
import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.widget.ImageView;
import android.widget.LinearLayout;
import com.aviary.android.feather.R;
publicclass AviaryWorkspaceIndicator extends LinearLayout {
int mResId;
int mSelected;
int mResWidth = -1;
int mResHeight = -1;
public AviaryWorkspaceIndicator ( Context context, AttributeSet attrs ) {
super( context, attrs );
init( context, attrs, 0 );
}
privatevoid init( Context context, AttributeSet attrs, int defStyle ) {
Theme theme = context.getTheme();
TypedArray a = theme.obtainStyledAttributes( attrs, R.styleable.AviaryWorkspaceIndicator, defStyle, 0 );
setOrientation( LinearLayout.HORIZONTAL );
mResId = a.getResourceId( R.styleable.AviaryWorkspaceIndicator_aviary_indicatorId, 0 );
a.recycle();
if ( mResId > 0 ) {
Drawable d = getContext().getResources().getDrawable( mResId );
mResWidth = d.getIntrinsicWidth();
mResHeight = d.getIntrinsicHeight();
}
}
@Override
protectedvoid onLayout( boolean changed, int l, int t, int r, int b ) {
super.onLayout( changed, l, t, r, b );
}
void resetView( int count ) {
removeAllViews();
if ( mResId != 0 && count > 0 ) {
int h = getHeight();
if ( mResWidth > 0 ) {
float ratio = (float) mResHeight / h;
if ( mResHeight > h ) {
mResHeight = h;
mResWidth = (int) ( mResWidth / ratio );
}
} else {
mResWidth = LinearLayout.LayoutParams.WRAP_CONTENT;
mResHeight = LinearLayout.LayoutParams.MATCH_PARENT;
}
for ( int i = 0; i < count; i++ ) {
ImageView v = new ImageView( getContext() );
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams( mResWidth, mResHeight );
v.setImageResource( mResId );
v.setSelected( false );
v.setPadding( 2, 0, 2, 0 );
v.setLayoutParams( params );
addView( v );
}
}
}
publicvoid setLevel( int mCurrentScreen, int mItemCount ) {
if ( getChildCount() != mItemCount ) {
resetView( mItemCount );
mSelected = 0;
}
if ( mCurrentScreen >= 0 && mCurrentScreen < getChildCount() ) {
getChildAt( mSelected ).setSelected( false );
getChildAt( mCurrentScreen ).setSelected( true );
mSelected = mCurrentScreen;
}
}
}