content: package com.yalantis.phoenix.sample;
  
  import android.content.Context;
  import android.os.Bundle;
  import android.support.annotation.NonNull;
  import android.support.v7.app.ActionBarActivity;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  import android.widget.ArrayAdapter;
  import android.widget.ImageView;
  import android.widget.ListView;
  
  import com.yalantis.phoenix.PullToRefreshView;
  
  import java.util.ArrayList;
  import java.util.HashMap;
  import java.util.List;
  import java.util.Map;
  
  public class PhoenixPullToRefreshActivity extends ActionBarActivity {
  
      public static final int REFRESH_DELAY = 2000;
  
      private PullToRefreshView mPullToRefreshView;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(com.jinlin.yalantis.R.layout.activity_pull_to_refresh);
  
          Map<String, Integer> map;
          List<Map<String, Integer>> sampleList = new ArrayList<>();
  
          int[] icons = {
                  com.jinlin.yalantis.R.mipmap.icon_1,
                  com.jinlin.yalantis.R.mipmap.icon_2,
                  com.jinlin.yalantis.R.mipmap.icon_3};
  
          int[] colors = {
                  com.jinlin.yalantis.R.color.saffron,
                  com.jinlin.yalantis.R.color.eggplant,
                  com.jinlin.yalantis.R.color.sienna};
  
          for (int i = 0; i < icons.length; i++) {
              map = new HashMap<>();
              map.put(SampleAdapter.KEY_ICON, icons[i]);
              map.put(SampleAdapter.KEY_COLOR, colors[i]);
              sampleList.add(map);
          }
  
          ListView listView = (ListView) findViewById(com.jinlin.yalantis.R.id.list_view);
          listView.setAdapter(new SampleAdapter(this, com.jinlin.yalantis.R.layout.list_item1, sampleList));
  
          mPullToRefreshView = (PullToRefreshView) findViewById(com.jinlin.yalantis.R.id.pull_to_refresh);
          mPullToRefreshView.setOnRefreshListener(new PullToRefreshView.OnRefreshListener() {
              @Override
              public void onRefresh() {
                  mPullToRefreshView.postDelayed(new Runnable() {
                      @Override
                      public void run() {
                          mPullToRefreshView.setRefreshing(false);
                      }
                  }, REFRESH_DELAY);
              }
          });
      }
  
      class SampleAdapter extends ArrayAdapter<Map<String, Integer>> {
  
          public static final String KEY_ICON = "icon";
          public static final String KEY_COLOR = "color";
  
          private final LayoutInflater mInflater;
          private final List<Map<String, Integer>> mData;
  
          public SampleAdapter(Context context, int layoutResourceId, List<Map<String, Integer>> data) {
              super(context, layoutResourceId, data);
              mData = data;
              mInflater = LayoutInflater.from(context);
          }
  
          @Override
          public View getView(final int position, View convertView, @NonNull ViewGroup parent) {
              final ViewHolder viewHolder;
              if (convertView == null) {
                  viewHolder = new ViewHolder();
                  convertView = mInflater.inflate(com.jinlin.yalantis.R.layout.list_item1, parent, false);
                  viewHolder.imageViewIcon = (ImageView) convertView.findViewById(com.jinlin.yalantis.R.id.image_view_icon);
                  convertView.setTag(viewHolder);
              } else {
                  viewHolder = (ViewHolder) convertView.getTag();
              }
  
              viewHolder.imageViewIcon.setImageResource(mData.get(position).get(KEY_ICON));
              convertView.setBackgroundResource(mData.get(position).get(KEY_COLOR));
  
              return convertView;
          }
  
          class ViewHolder {
              ImageView imageViewIcon;
          }
  
      }
  
  }
  