Search in sources :

Example 1 with Person

use of com.jude.dome.entites.Person in project EasyRecyclerView by Jude95.

the class InsertActivity method onOptionsItemSelected.

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    Random random = new Random();
    int len = adapter.getCount();
    if (len > 0) {
        int pos = random.nextInt(len);
        // int pos = 0;
        List<Person> persons = DataProvider.getPersonList(0);
        Person data = persons.get(random.nextInt(persons.size()));
        switch(item.getItemId()) {
            case R.id.ic_add:
                adapter.insert(data, pos);
                break;
            case R.id.ic_remove:
                adapter.remove(pos);
                break;
            case R.id.ic_refresh:
                adapter.update(data, pos);
                break;
        }
    }
    return true;
}
Also used : Random(java.util.Random) Person(com.jude.dome.entites.Person)

Example 2 with Person

use of com.jude.dome.entites.Person in project EasyRecyclerView by Jude95.

the class DataProvider method getPersonWithAds.

public static List<Object> getPersonWithAds(int page) {
    ArrayList<Object> arrAll = new ArrayList<>();
    List<Ad> arrAd = getAdList();
    int index = 0;
    for (Person person : getPersonList(page)) {
        arrAll.add(person);
        // 按比例混合广告
        if (Math.random() < 0.2) {
            arrAll.add(arrAd.get(index % arrAd.size()));
            index++;
        }
    }
    return arrAll;
}
Also used : Ad(com.jude.dome.entites.Ad) ArrayList(java.util.ArrayList) Person(com.jude.dome.entites.Person)

Example 3 with Person

use of com.jude.dome.entites.Person in project EasyRecyclerView by Jude95.

the class InsertActivity method onCreate.

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_recyclerview);
    recyclerView = (EasyRecyclerView) findViewById(R.id.recyclerView);
    recyclerView.setLayoutManager(new LinearLayoutManager(this));
    DividerDecoration itemDecoration = new DividerDecoration(Color.GRAY, Util.dip2px(this, 0.5f), Util.dip2px(this, 72), 0);
    itemDecoration.setDrawLastItem(false);
    recyclerView.addItemDecoration(itemDecoration);
    recyclerView.setAdapterWithProgress(adapter = new PersonAdapter(this));
    List<Person> persons = DataProvider.getPersonList(0);
    adapter.addAll(persons.subList(0, 3));
    recyclerView.setItemAnimator(new DefaultItemAnimator());
}
Also used : DividerDecoration(com.jude.easyrecyclerview.decoration.DividerDecoration) PersonAdapter(com.jude.dome.loadmore.PersonAdapter) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) Person(com.jude.dome.entites.Person) DefaultItemAnimator(android.support.v7.widget.DefaultItemAnimator)

Example 4 with Person

use of com.jude.dome.entites.Person in project EasyRecyclerView by Jude95.

the class DataProvider method getPersonList.

public static List<Person> getPersonList(int page) {
    ArrayList<Person> arr = new ArrayList<>();
    if (page >= 4)
        return arr;
    arr.add(new Person("http://i2.hdslb.com/52_52/user/61175/6117592/myface.jpg", "月の星く雪" + "————————第" + page + "页", "完结来补"));
    arr.add(new Person("http://i1.hdslb.com/52_52/user/6738/673856/myface.jpg", "影·蓝玉", "一看评论被***了一脸,伐开心。"));
    arr.add(new Person("http://i1.hdslb.com/account/face/1467772/e1afaf4a/myface.png", "i琳夏i", "(`・ω・´)"));
    arr.add(new Person("http://i0.hdslb.com/52_52/user/18494/1849483/myface.jpg", "Minerva。", "为啥下载不能了?π_π"));
    arr.add(new Person("http://i0.hdslb.com/52_52/account/face/4613528/303f4f5a/myface.png", "如歌行极", "求生肉(/TДT)/"));
    arr.add(new Person("http://i0.hdslb.com/52_52/account/face/611203/76c02248/myface.png", "GERM", "第一次看 看弹幕那些说什么影帝模式啥的 感觉日了狗了 让我怎么往后看啊 艹"));
    arr.add(new Person("http://i2.hdslb.com/52_52/user/46230/4623018/myface.jpg", "じ★ve↘魅惑", "开头吾王裙子被撩起来怎么回事!→_→"));
    arr.add(new Person("http://i2.hdslb.com/52_52/user/66723/6672394/myface.jpg", "道尘一梦", "@伪 · 卫宫士郎"));
    arr.add(new Person("http://i1.hdslb.com/user/3039/303946/myface.jpg", "潘多哥斯拉", "朋友,听说过某R吗……..我呸,听说过虫群吗?(`・ω・´)"));
    arr.add(new Person("http://i2.hdslb.com/account/face/9034989/aabbc52a/myface.png", "一只红发的猫", "道理我都懂,我就问,几楼开车←_←"));
    arr.add(new Person("http://i0.hdslb.com/account/face/1557783/8733bd7b/myface.png", "Mikuの草莓胖次", "扶..扶我起来,喝了最后这一瓶营养快线,让我撸死up"));
    arr.add(new Person("http://i2.hdslb.com/user/3716/371679/myface.jpg", "Absolute Field", "朋也,看过里番吗?"));
    arr.add(new Person("http://i1.hdslb.com/account/face/9045165/4b11d894/myface.png", "琪雅之约", "摩西摩西.警察局么?"));
    return arr;
}
Also used : ArrayList(java.util.ArrayList) Person(com.jude.dome.entites.Person)

Aggregations

Person (com.jude.dome.entites.Person)4 ArrayList (java.util.ArrayList)2 DefaultItemAnimator (android.support.v7.widget.DefaultItemAnimator)1 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 Ad (com.jude.dome.entites.Ad)1 PersonAdapter (com.jude.dome.loadmore.PersonAdapter)1 DividerDecoration (com.jude.easyrecyclerview.decoration.DividerDecoration)1 Random (java.util.Random)1