-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: free46000 <[email protected]>
- Loading branch information
Showing
6 changed files
with
159 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
89 changes: 89 additions & 0 deletions
89
demo/src/main/java/com/freelib/multiitem/demo/AnimationActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
package com.freelib.multiitem.demo; | ||
|
||
import android.content.Context; | ||
import android.support.v7.app.AppCompatActivity; | ||
import android.support.v7.widget.LinearLayoutManager; | ||
import android.support.v7.widget.RecyclerView; | ||
import android.view.View; | ||
import android.widget.CheckBox; | ||
import android.widget.CompoundButton; | ||
import android.widget.RadioGroup; | ||
|
||
import com.freelib.multiitem.adapter.BaseItemAdapter; | ||
import com.freelib.multiitem.animation.AlphaInAnimation; | ||
import com.freelib.multiitem.animation.BaseAnimation; | ||
import com.freelib.multiitem.animation.ScaleInAnimation; | ||
import com.freelib.multiitem.animation.SlideInBottomAnimation; | ||
import com.freelib.multiitem.animation.SlideInLeftAnimation; | ||
import com.freelib.multiitem.animation.SlideInRightAnimation; | ||
import com.freelib.multiitem.demo.bean.ImageBean; | ||
import com.freelib.multiitem.demo.bean.ImageTextBean; | ||
import com.freelib.multiitem.demo.bean.TextBean; | ||
import com.freelib.multiitem.demo.viewholder.ImageAndTextManager; | ||
import com.freelib.multiitem.demo.viewholder.ImageViewManager; | ||
import com.freelib.multiitem.demo.viewholder.TextViewManager; | ||
|
||
import org.androidannotations.annotations.AfterViews; | ||
import org.androidannotations.annotations.CheckedChange; | ||
import org.androidannotations.annotations.EActivity; | ||
import org.androidannotations.annotations.ViewById; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
@EActivity(R.layout.activity_animation) | ||
public class AnimationActivity extends AppCompatActivity { | ||
@ViewById(R.id.recyclerView) | ||
protected RecyclerView recyclerView; | ||
|
||
private BaseItemAdapter adapter; | ||
|
||
public static void startActivity(Context context) { | ||
AnimationActivity_.intent(context).start(); | ||
} | ||
|
||
@AfterViews | ||
protected void initViews() { | ||
setTitle(R.string.animation_title); | ||
|
||
recyclerView.setLayoutManager(new LinearLayoutManager(this)); | ||
//初始化adapter | ||
adapter = new BaseItemAdapter(); | ||
//为XXBean数据源注册XXManager管理类 | ||
adapter.register(ImageTextBean.class, new ImageAndTextManager()); | ||
recyclerView.setAdapter(adapter); | ||
List<Object> list = new ArrayList<>(); | ||
for (int i = 0; i < 20; i++) { | ||
list.add(new ImageTextBean(R.drawable.img2, "BBB" + i)); | ||
} | ||
|
||
adapter.setDataItems(list); | ||
} | ||
|
||
@CheckedChange({R.id.leftCheck, R.id.rightCheck, R.id.bottomCheck, R.id.scaleCheck, R.id.alphaCheck}) | ||
protected void checkedChanged(CompoundButton compoundButton, boolean isChecked) { | ||
if (!isChecked) { | ||
return; | ||
} | ||
BaseAnimation baseAnimation; | ||
switch (compoundButton.getId()) { | ||
case R.id.leftCheck: | ||
baseAnimation = new SlideInLeftAnimation(); | ||
break; | ||
case R.id.rightCheck: | ||
baseAnimation = new SlideInRightAnimation(); | ||
break; | ||
case R.id.bottomCheck: | ||
baseAnimation = new SlideInBottomAnimation(); | ||
break; | ||
case R.id.alphaCheck: | ||
baseAnimation = new AlphaInAnimation(); | ||
break; | ||
default: | ||
baseAnimation = new ScaleInAnimation(); | ||
break; | ||
} | ||
//开启动画,并取消动画只在第一次加载时展示 | ||
adapter.enableAnimation(baseAnimation, false); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?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" | ||
android:background="#eeeeee" | ||
android:orientation="vertical"> | ||
|
||
<RadioGroup android:id="@+id/animationGroup" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:orientation="horizontal"> | ||
|
||
<RadioButton | ||
android:id="@+id/scaleCheck" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:text="scale" | ||
/> | ||
|
||
<RadioButton | ||
android:id="@+id/alphaCheck" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:text="alpha" | ||
/> | ||
|
||
<RadioButton | ||
android:id="@+id/bottomCheck" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:text="bottom" | ||
/> | ||
|
||
<RadioButton | ||
android:id="@+id/leftCheck" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:text="left" | ||
/> | ||
|
||
<RadioButton | ||
android:id="@+id/rightCheck" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:text="right" | ||
/> | ||
|
||
</RadioGroup> | ||
|
||
<android.support.v7.widget.RecyclerView | ||
android:id="@+id/recyclerView" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:clipToPadding="false" | ||
android:padding="8dp"/> | ||
</LinearLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters