import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter; import java.lang.reflect.Array;
import java.util.ArrayList; import cn.loaderman.holder.BaseHolder;
import cn.loaderman.holder.HomeHolder;
import cn.loaderman.utils.ItemAnimationUtils; import static android.icu.lang.UCharacter.GraphemeClusterBreak.T; /**
*
* 封装的思想:
* 抽取基类:
* 在基类中做的一般都是通用的事情
* 不通用的事情
* 1、父类不知道如何完成的事情,通过抽象方法来交给子类实现
* 2、父类不知道的数据类型,通过泛型来解决,泛型是自定义的一种不存在的类型,这种类型究竟是啥,在定义子类的时候确定
* 尖括号的位置
* 如果在自己的类名后面,代表定义了一个泛型
* 如果跟在父类的名称后面,代表确定父类所定义的泛型类型
*
*/ public abstract class MyBaseAdapter<T> extends BaseAdapter { private ArrayList<T> dataList; public MyBaseAdapter(ArrayList<T> dataList) {
this.dataList = dataList;
} @Override
public int getCount() {
return dataList.size();
} @Override
public Object getItem(int position) {
return dataList.get(position);
} @Override
public long getItemId(int position) {
return position;
} @Override
public View getView(int position, View convertView, ViewGroup parent) {
BaseHolder holder = null;
if(convertView == null) {
holder = getHolder(position);
} else {
holder = (BaseHolder) convertView.getTag();
} holder.setData(dataList.get(position)); ItemAnimationUtils.startAnim(holder.convertView); return holder.convertView;
} public abstract BaseHolder getHolder(int position);
}

BaseHolder.java

import android.view.View;
/**
* 1、加载布局文件 convertView,布局文件的id
* 2、初始化控件 TextView、convertView、Holder
* 3、存储holder Holder、convertView
* 4、刷新控件的数据 TextView、数据
*/ public abstract class BaseHolder<T> {
public View convertView;
public T data;
public BaseHolder() {
convertView = initView();
convertView.setTag(this);
}
public void setData(T data) {
if(data != null) {
this.data = data;
}
refreshView();
}
public abstract View initView() ;
public abstract void refreshView();\
}

ItemAnimationUtils.java

public class ItemAnimationUtils {

    public static void startAnim(View view) {

        ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(view,"alpha",0.0f,1.0f);
objectAnimator.setDuration(500);
objectAnimator.start(); /*AlphaAnimation alphaAnimation = new AlphaAnimation(0.0f, 1.0f);
alphaAnimation.setDuration(500);
alphaAnimation.setFillAfter(true);*/ //view.setScaleX(); /*view.setPivotX(0);
view.setPivotY(0);*/
ObjectAnimator objectAnimatorX = ObjectAnimator.ofFloat(view,"scaleX",0.5f,1.0f);
objectAnimatorX.setDuration(500);
objectAnimatorX.start();
ObjectAnimator objectAnimatorY = ObjectAnimator.ofFloat(view,"scaleY",0.5f,1.0f);
objectAnimatorY.setDuration(500);
objectAnimatorY.start(); /* ScaleAnimation scaleAnimation = new ScaleAnimation(0.5f,1.0f,0.5f,1.0f); scaleAnimation.setDuration(500);
scaleAnimation.setFillAfter(true); AnimationSet animationSet = new AnimationSet(true);
//设置动画的插入器
animationSet.setInterpolator(new OvershootInterpolator(2)); animationSet.addAnimation(alphaAnimation);
animationSet.addAnimation(scaleAnimation); view.startAnimation(animationSet);*/ }
}

最新文章

  1. HTML5 div+css导航菜单
  2. 大叔也说Xamarin~Android篇~ListView里的Click事件并获取本行的其它元素
  3. 全球第一本基于Bootstrap V3.x的图书《深入理解Bootstrap》终于上市了,再次免费送书15本【活动结束】
  4. SQL Server 跨数据库查询
  5. 《BI项目笔记》报到信息分析Cube
  6. java非静态变量初始化
  7. Linq--扩展方法
  8. php的表单安全处理
  9. 通过WMI获取机器信息
  10. AI CV 会议2018
  11. 仿爱奇艺视频,腾讯视频,搜狐视频首页推荐位轮播图(二)之SuperIndicator源码分析
  12. Windows系统封装教程
  13. linux下 编译安装Mysql
  14. C#基于wpf编写的串口调试助手
  15. 【Linux】使用Google Authenticator 实现ssh登录双因素认证
  16. 【1】AQS详解
  17. 基于SVM的python简单实现验证码识别
  18. Python自动化开发 - 常用模块(二)
  19. Linux&#160;awk命令常见使用方法介绍
  20. ArrayDeque源代码分析

热门文章

  1. 如何使用sqlalchemy根据数据库里面的表反推出模型,然后进行查询
  2. c++ 用模板类实现顺序储存的线性表
  3. 代码报错--------EOFError: Compressed file ended before the end-of-stream marker was reached
  4. 使用go语言开发一个后端gin框架的web项目
  5. HTML5日期时间输入类型注意事项(time,date)
  6. Head First设计模式 装饰者模式
  7. 求两个数的最大公约数和最小公倍数Java(cvte考题)
  8. Java多线程和并发(九),ReentrantLock(公平锁)
  9. Confluence 6 Office 和 PDF 文件
  10. linux下简单好用的端口映射转发工具rinetd