Search in sources :

Example 1 with BookListAdapter

use of cn.liuyin.manhua.adapter.BookListAdapter in project Manhua by ag2s20150909.

the class ListActivity method showList.

private void showList(final ChaptersBean chapters) {
    if (chapters == null) {
        return;
    }
    if (chapters.code != 0) {
        mHander.obtainMessage(0, chapters.message).sendToTarget();
        return;
    }
    int possion;
    book = BookShelf.getBookById(book.bookid);
    possion = book != null ? book.index : 1;
    if (adapter == null) {
        adapter = new BookListAdapter(ListActivity.this, chapters, possion);
        // lv.setLayoutAnimation(new LayoutAnimationController(AnimationUtils.loadAnimation(this, R.anim.list_animation), 0.5f));
        lv.setAdapter(adapter);
    } else {
        adapter.updateView(chapters, possion);
    }
    lv.setLayoutAnimation(new LayoutAnimationController(AnimationUtils.loadAnimation(this, R.anim.list_animation), 0.5f));
    lv.setSelection(possion - 1);
    lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> p1, View p2, int p3, long p4) {
            try {
                Intent i = new Intent(ListActivity.this, BookContentActivity.class);
                i.putExtra("data", chapters);
                i.putExtra("book", book);
                i.putExtra("index", p3 + 1);
                // Toast.makeText(ListActivity.this,data.get(p3).get("url"),1).show();
                startActivity(i);
            } catch (Exception e) {
                e.printStackTrace();
                mHander.obtainMessage(0, e.getMessage()).sendToTarget();
            }
        }
    });
}
Also used : BookListAdapter(cn.liuyin.manhua.adapter.BookListAdapter) LayoutAnimationController(android.view.animation.LayoutAnimationController) AdapterView(android.widget.AdapterView) Intent(android.content.Intent) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView)

Aggregations

Intent (android.content.Intent)1 View (android.view.View)1 LayoutAnimationController (android.view.animation.LayoutAnimationController)1 AdapterView (android.widget.AdapterView)1 ListView (android.widget.ListView)1 BookListAdapter (cn.liuyin.manhua.adapter.BookListAdapter)1