Skip to content

提交fancycoverflow基本版本 #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 5, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified fancycoverflow-demo/res/drawable-hdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified fancycoverflow-demo/res/drawable-ldpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added fancycoverflow-demo/res/drawable-mdpi/h10.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added fancycoverflow-demo/res/drawable-mdpi/h5.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added fancycoverflow-demo/res/drawable-mdpi/h8.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added fancycoverflow-demo/res/drawable-mdpi/h8s.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added fancycoverflow-demo/res/drawable-mdpi/h9.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified fancycoverflow-demo/res/drawable-mdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added fancycoverflow-demo/res/drawable-mdpi/tfboys.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
41 changes: 36 additions & 5 deletions fancycoverflow-demo/res/layout/activity_fancycoverflow_layout.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,38 @@
<RelativeLayout
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">

</RelativeLayout>
xmlns:fcf="http://schemas.android.com/apk/res-auto"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal">
<RelativeLayout
android:layout_width="0.0dp"
android:layout_height="fill_parent"
android:layout_weight="3"
android:background="@android:color/white">
<ListView
android:id="@+id/fancyCoverFlowListId"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scrollbarStyle="outsideInset"
/>
</RelativeLayout>

<!-- 使用fcf属性时,一定要在跟布局中引用“xmlns:fcf” -->
<RelativeLayout
android:layout_width="0.0dp"
android:layout_height="match_parent"
android:layout_weight="7">
<at.technikum.mti.fancycoverflow.FancyCoverFlow
android:id="@+id/fancyCoverFlowId"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
fcf:maxRotation="45"
fcf:unselectedAlpha="0.3"
fcf:unselectedSaturation="0.0"
fcf:unselectedScale="0.4"
fcf:scaleDownGravity="0.5"
/>
</RelativeLayout>
</LinearLayout>
12 changes: 12 additions & 0 deletions fancycoverflow-demo/res/layout/adapter_base_layout.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/imageId"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/app_name"
/>
</LinearLayout>
Original file line number Diff line number Diff line change
@@ -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;
}
Original file line number Diff line number Diff line change
@@ -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( );
}
Original file line number Diff line number Diff line change
@@ -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��
* <at.technikum.mti.fancycoverflow.FancyCoverFlow
android:id="@+id/fancyCoverFlowId"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
fcf:maxRotation="45"
fcf:unselectedAlpha="0.3"
fcf:unselectedSaturation="0.0"
fcf:unselectedScale="0.4"
fcf:scaleDownGravity="0.5"
/>
*
*
* 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<String>(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<String> getListData( ){
ArrayList<String> listData = new ArrayList<String>( );

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;
}