diff --git a/fancycoverflow-demo/res/drawable-hdpi/ic_launcher.png b/fancycoverflow-demo/res/drawable-hdpi/ic_launcher.png index 0e79b18..dee7659 100644 Binary files a/fancycoverflow-demo/res/drawable-hdpi/ic_launcher.png and b/fancycoverflow-demo/res/drawable-hdpi/ic_launcher.png differ diff --git a/fancycoverflow-demo/res/drawable-ldpi/ic_launcher.png b/fancycoverflow-demo/res/drawable-ldpi/ic_launcher.png index ebfac7d..dee7659 100644 Binary files a/fancycoverflow-demo/res/drawable-ldpi/ic_launcher.png and b/fancycoverflow-demo/res/drawable-ldpi/ic_launcher.png differ diff --git a/fancycoverflow-demo/res/drawable-mdpi/h10.jpg b/fancycoverflow-demo/res/drawable-mdpi/h10.jpg new file mode 100644 index 0000000..2ba7a0e Binary files /dev/null and b/fancycoverflow-demo/res/drawable-mdpi/h10.jpg differ diff --git a/fancycoverflow-demo/res/drawable-mdpi/h5.jpg b/fancycoverflow-demo/res/drawable-mdpi/h5.jpg new file mode 100644 index 0000000..6fd11a9 Binary files /dev/null and b/fancycoverflow-demo/res/drawable-mdpi/h5.jpg differ diff --git a/fancycoverflow-demo/res/drawable-mdpi/h8.jpg b/fancycoverflow-demo/res/drawable-mdpi/h8.jpg new file mode 100644 index 0000000..b54027a Binary files /dev/null and b/fancycoverflow-demo/res/drawable-mdpi/h8.jpg differ diff --git a/fancycoverflow-demo/res/drawable-mdpi/h8s.jpg b/fancycoverflow-demo/res/drawable-mdpi/h8s.jpg new file mode 100644 index 0000000..bfff77a Binary files /dev/null and b/fancycoverflow-demo/res/drawable-mdpi/h8s.jpg differ diff --git a/fancycoverflow-demo/res/drawable-mdpi/h9.jpg b/fancycoverflow-demo/res/drawable-mdpi/h9.jpg new file mode 100644 index 0000000..c3818dd Binary files /dev/null and b/fancycoverflow-demo/res/drawable-mdpi/h9.jpg differ diff --git a/fancycoverflow-demo/res/drawable-mdpi/ic_launcher.png b/fancycoverflow-demo/res/drawable-mdpi/ic_launcher.png index 1183441..dee7659 100644 Binary files a/fancycoverflow-demo/res/drawable-mdpi/ic_launcher.png and b/fancycoverflow-demo/res/drawable-mdpi/ic_launcher.png differ diff --git a/fancycoverflow-demo/res/drawable-mdpi/tfboys.jpg b/fancycoverflow-demo/res/drawable-mdpi/tfboys.jpg new file mode 100644 index 0000000..eb09297 Binary files /dev/null and b/fancycoverflow-demo/res/drawable-mdpi/tfboys.jpg differ diff --git a/fancycoverflow-demo/res/drawable-xhdpi/ic_launcher.png b/fancycoverflow-demo/res/drawable-xhdpi/ic_launcher.png deleted file mode 100644 index c8ab2a1..0000000 Binary files a/fancycoverflow-demo/res/drawable-xhdpi/ic_launcher.png and /dev/null differ diff --git a/fancycoverflow-demo/res/layout/activity_fancycoverflow_layout.xml b/fancycoverflow-demo/res/layout/activity_fancycoverflow_layout.xml index 3bdb9fb..b25a3ce 100644 --- a/fancycoverflow-demo/res/layout/activity_fancycoverflow_layout.xml +++ b/fancycoverflow-demo/res/layout/activity_fancycoverflow_layout.xml @@ -1,7 +1,38 @@ - - - \ No newline at end of file + xmlns:fcf="http://schemas.android.com/apk/res-auto" + android:layout_width="fill_parent" + android:layout_height="fill_parent" + android:orientation="horizontal"> + + + + + + + + + \ No newline at end of file diff --git a/fancycoverflow-demo/res/layout/adapter_base_layout.xml b/fancycoverflow-demo/res/layout/adapter_base_layout.xml new file mode 100644 index 0000000..e8afeef --- /dev/null +++ b/fancycoverflow-demo/res/layout/adapter_base_layout.xml @@ -0,0 +1,12 @@ + + + + \ No newline at end of file diff --git a/fancycoverflow-demo/src/com/mingy/fancycoverflow/base/FancyCoverFlowBaseAdapter.java b/fancycoverflow-demo/src/com/mingy/fancycoverflow/base/FancyCoverFlowBaseAdapter.java new file mode 100644 index 0000000..139fe88 --- /dev/null +++ b/fancycoverflow-demo/src/com/mingy/fancycoverflow/base/FancyCoverFlowBaseAdapter.java @@ -0,0 +1,48 @@ +package com.mingy.fancycoverflow.base; + +import android.content.Context; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ImageView; +import at.technikum.mti.fancycoverflow.FancyCoverFlow; +import at.technikum.mti.fancycoverflow.FancyCoverFlow.LayoutParams; +import at.technikum.mti.fancycoverflow.FancyCoverFlowAdapter; + +public class FancyCoverFlowBaseAdapter extends FancyCoverFlowAdapter { + public FancyCoverFlowBaseAdapter( Context context, Integer[] dataList ){ + mDataList = dataList; + } + + @Override + public int getCount() { + return mDataList.length; + } + + @Override + public Object getItem(int position) { + return mDataList[ position ]; + } + + @Override + public long getItemId(int position) { + return position; + } + + @Override + public View getCoverFlowItem(int position, View reusableView, ViewGroup parent) { + ImageView imageView = null; + + if (reusableView != null) { + imageView = (ImageView) reusableView; + } else { + imageView = new ImageView(parent.getContext()); + imageView.setLayoutParams(new FancyCoverFlow.LayoutParams(LayoutParams.WRAP_CONTENT,256)); + } + + imageView.setBackgroundResource( mDataList[ position ] ); + + return imageView; + } + + private Integer[] mDataList = null; +} diff --git a/fancycoverflow-demo/src/com/mingy/fancycoverflow/demo/BaseActivity.java b/fancycoverflow-demo/src/com/mingy/fancycoverflow/demo/BaseActivity.java new file mode 100644 index 0000000..d16c993 --- /dev/null +++ b/fancycoverflow-demo/src/com/mingy/fancycoverflow/demo/BaseActivity.java @@ -0,0 +1,23 @@ +package com.mingy.fancycoverflow.demo; + +import android.app.Activity; +import android.os.Bundle; + +public abstract class BaseActivity extends Activity { + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + init( ); + } + + public void init( ){ + findViews( ); + getData( ); + showContent( ); + } + + public abstract void findViews( ); + public abstract void getData( ); + public abstract void showContent( ); +} diff --git a/fancycoverflow-demo/src/com/mingy/fancycoverflow/demo/FancyCoverFlowMainActivity.java b/fancycoverflow-demo/src/com/mingy/fancycoverflow/demo/FancyCoverFlowMainActivity.java index 0aaf5b6..6b6e84f 100644 --- a/fancycoverflow-demo/src/com/mingy/fancycoverflow/demo/FancyCoverFlowMainActivity.java +++ b/fancycoverflow-demo/src/com/mingy/fancycoverflow/demo/FancyCoverFlowMainActivity.java @@ -1,13 +1,152 @@ package com.mingy.fancycoverflow.demo; -import android.app.Activity; +import java.util.ArrayList; + import android.os.Bundle; +import android.view.View; +import android.widget.AdapterView; +import android.widget.AdapterView.OnItemClickListener; +import android.widget.ArrayAdapter; +import android.widget.ListView; +import at.technikum.mti.fancycoverflow.FancyCoverFlow; + +import com.mingy.fancycoverflow.base.FancyCoverFlowBaseAdapter; -public class FancyCoverFlowMainActivity extends Activity { + +/** + * һ��FancyCoverFlowʹ�ò��裺 + * 1����activity�IJ����ļ�������FancyCoverFlow��eg�� + * + * + * + * 2���Զ���Adapter��Adapter�̳���FancyCoverFlowBaseAdapter,eg�� + * public class FancyCoverFlowBaseAdapter extends FancyCoverFlowAdapter { + public FancyCoverFlowBaseAdapter( Context context, Integer[] dataList ){ + mDataList = dataList; + } + + @Override + public int getCount() { + return mDataList.length; + } + + @Override + public Object getItem(int position) { + return mDataList[ position ]; + } + + @Override + public long getItemId(int position) { + return position; + } + + @Override + public View getCoverFlowItem(int position, View reusableView, ViewGroup parent) { + ImageView imageView = null; + + if (reusableView != null) { + imageView = (ImageView) reusableView; + } else { + imageView = new ImageView(parent.getContext()); + imageView.setLayoutParams(new FancyCoverFlow.LayoutParams(LayoutParams.WRAP_CONTENT,256)); + } + + imageView.setBackgroundResource( mDataList[ position ] ); + + return imageView; + } + + private Integer[] mDataList = null; + } + * + * + * 3��ʵ����FancyCoverFlow��Ϊ������Adapter��eg + * FancyCoverFlowBaseAdapter fancyCoverFlowBaseAdapter = new FancyCoverFlowBaseAdapter( this, getBaseDataList( ) ); + mFancyCoverFlow.setAdapter( fancyCoverFlowBaseAdapter ); + * + * + * ����ע����� + * 1���ڲ����ļ�������FancyCoverFlowʱ�������Ҫʹ���Զ������ԣ�����Ҫ�ڸ������ļ��ж����Զ������Ե������ռ䡰xmlns:fcf="http://schemas.android.com/apk/res-auto"���� + * 2��FancyCoverFlow��Ч���ǻ��ڻ���Gallery�ģ��������Զ���Adapterʱ������getCoverFlowItem������һ��Ҫע���Զ���view�����ԣ�����μ���demo�е�FancyCoverFlowBaseAdapter�ࣻ + * */ +public class FancyCoverFlowMainActivity extends BaseActivity { @Override protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); setContentView(R.layout.activity_fancycoverflow_layout); + super.onCreate(savedInstanceState); + } + + @Override + public void findViews() { + mFancyCoverFlowList = ( ListView )findViewById( R.id.fancyCoverFlowListId ); + mFancyCoverFlow = ( FancyCoverFlow )findViewById( R.id.fancyCoverFlowId ); + } + + @Override + public void getData() { + + } + + @Override + public void showContent() { + initFancyCoverFlowList( ); + showFancyCoverFlow( 0 ); + } + + private void initFancyCoverFlowList( ){ + mFancyCoverFlowList.setOnItemClickListener( new OnItemClickListener() { + @Override + public void onItemClick(AdapterView arg0, View arg1, int arg2, long arg3) { + showFancyCoverFlow( arg2 ); + } + }); + + mFancyCoverFlowList.setAdapter(new ArrayAdapter(this, android.R.layout.simple_expandable_list_item_1,getListData())); + } + + private void showFancyCoverFlow( int position ){ + switch( position ){ + case 0:{ + showBaseCoverFlow( ); + } + break; + default:{ + + } + break; + } + } + + private void showBaseCoverFlow( ){ + FancyCoverFlowBaseAdapter fancyCoverFlowBaseAdapter = new FancyCoverFlowBaseAdapter( this, getBaseDataList( ) ); + mFancyCoverFlow.setAdapter( fancyCoverFlowBaseAdapter ); + } + + private ArrayList getListData( ){ + ArrayList listData = new ArrayList( ); + + listData.add( "Base FancyCoverFlow" ); + + return listData; + } + + private Integer[] getBaseDataList( ){ + Integer[] baseData = new Integer[]{R.drawable.h5, R.drawable.h8, R.drawable.h8s, R.drawable.h9, R.drawable.h10 }; + + return baseData; } + + private ListView mFancyCoverFlowList = null; + private FancyCoverFlow mFancyCoverFlow = null; }