Search in sources :

Example 1 with ModelListAdapter

use of github.chenupt.multiplemodel.ModelListAdapter in project DragTopLayout by chenupt.

the class GridViewFragment method initView.

private void initView() {
    gridView = (GridView) getView().findViewById(R.id.grid_view);
    adapter = new ModelListAdapter(getActivity(), DataService.getInstance().getModelManager());
    gridView.setAdapter(adapter);
    adapter.setList(DataService.getInstance().getList());
    adapter.notifyDataSetChanged();
    // attach top
    gridView.setOnScrollListener(new AbsListView.OnScrollListener() {

        @Override
        public void onScrollStateChanged(AbsListView view, int scrollState) {
        }

        @Override
        public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
            EventBus.getDefault().post(AttachUtil.isAdapterViewAttach(view));
        }
    });
}
Also used : ModelListAdapter(github.chenupt.multiplemodel.ModelListAdapter) AbsListView(android.widget.AbsListView)

Example 2 with ModelListAdapter

use of github.chenupt.multiplemodel.ModelListAdapter in project DragTopLayout by chenupt.

the class ListViewFragment method initView.

private void initView() {
    listView = (ListView) getView().findViewById(R.id.list_view);
    adapter = new ModelListAdapter(getActivity(), DataService.getInstance().getModelManager());
    listView.setAdapter(adapter);
    adapter.setList(DataService.getInstance().getList());
    adapter.notifyDataSetChanged();
    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Toast.makeText(getActivity(), "Clicked " + position, Toast.LENGTH_SHORT).show();
        }
    });
    // attach top
    listView.setOnScrollListener(new AbsListView.OnScrollListener() {

        @Override
        public void onScrollStateChanged(AbsListView view, int scrollState) {
        }

        @Override
        public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
            EventBus.getDefault().post(AttachUtil.isAdapterViewAttach(view));
        }
    });
}
Also used : ModelListAdapter(github.chenupt.multiplemodel.ModelListAdapter) AbsListView(android.widget.AbsListView) AdapterView(android.widget.AdapterView) AbsListView(android.widget.AbsListView) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView)

Example 3 with ModelListAdapter

use of github.chenupt.multiplemodel.ModelListAdapter in project DragTopLayout by chenupt.

the class PullToRefreshActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_pulltorefresh);
    Toolbar toolbar = (Toolbar) findViewById(R.id.tool_bar);
    toolbar.setTitle("PullToRefresh");
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    pullToRefreshTopLayout = (PullToRefreshTopLayout) findViewById(R.id.pull_to_refresh_layout);
    listView = (ListView) findViewById(R.id.list_view);
    ModelListAdapter adapter = new ModelListAdapter(this, DataService.getInstance().getModelManager());
    listView.setAdapter(adapter);
    adapter.setList(DataService.getInstance().getList());
    adapter.notifyDataSetChanged();
    // attach top
    listView.setOnScrollListener(new AbsListView.OnScrollListener() {

        @Override
        public void onScrollStateChanged(AbsListView view, int scrollState) {
        }

        @Override
        public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
            pullToRefreshTopLayout.getRefreshableView().setTouchMode(AttachUtil.isAdapterViewAttach(view));
        }
    });
}
Also used : ModelListAdapter(github.chenupt.multiplemodel.ModelListAdapter) AbsListView(android.widget.AbsListView) Toolbar(android.support.v7.widget.Toolbar)

Aggregations

AbsListView (android.widget.AbsListView)3 ModelListAdapter (github.chenupt.multiplemodel.ModelListAdapter)3 Toolbar (android.support.v7.widget.Toolbar)1 View (android.view.View)1 AdapterView (android.widget.AdapterView)1 ListView (android.widget.ListView)1