Search in sources :

Example 1 with OnListItemListener

use of com.khmelenko.lab.varis.adapter.OnListItemListener in project Varis-Android by dkhmelenko.

the class JobsFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_jobs, container, false);
    ButterKnife.bind(this, view);
    mJobsRecyclerView.setNestedScrollingEnabled(false);
    mJobsRecyclerView.setHasFixedSize(true);
    LinearLayoutManager layoutManager = new LinearLayoutManager(getContext());
    mJobsRecyclerView.setLayoutManager(layoutManager);
    mJobsListAdapter = new JobsListAdapter(getContext(), mJobs, new OnListItemListener() {

        @Override
        public void onItemSelected(int position) {
            if (mJobs != null && !mJobs.isEmpty()) {
                Job job = mJobs.get(position);
                mListener.onJobSelected(job);
            }
        }
    });
    mJobsRecyclerView.setAdapter(mJobsListAdapter);
    DisplayMetrics metrics = getResources().getDisplayMetrics();
    int itemHeight = (int) ((mJobsListAdapter.getItemHeight() * metrics.density) + 0.5);
    mJobsRecyclerView.getLayoutParams().height = itemHeight * mJobsListAdapter.getItemCount();
    return view;
}
Also used : JobsListAdapter(com.khmelenko.lab.varis.adapter.JobsListAdapter) OnListItemListener(com.khmelenko.lab.varis.adapter.OnListItemListener) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) Job(com.khmelenko.lab.varis.network.response.Job) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) DisplayMetrics(android.util.DisplayMetrics)

Example 2 with OnListItemListener

use of com.khmelenko.lab.varis.adapter.OnListItemListener in project Varis-Android by dkhmelenko.

the class ReposFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_repos, container, false);
    ButterKnife.bind(this, view);
    mReposRecyclerView.setHasFixedSize(true);
    LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity());
    mReposRecyclerView.setLayoutManager(layoutManager);
    mRepoListAdapter = new RepoListAdapter(mRepos, new OnListItemListener() {

        @Override
        public void onItemSelected(int position) {
            if (mListener != null) {
                mListener.onRepositorySelected(mRepos.get(position));
            }
        }
    });
    mReposRecyclerView.setAdapter(mRepoListAdapter);
    mSwipeRefreshLayout.setColorSchemeResources(R.color.swipe_refresh_progress);
    mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {

        @Override
        public void onRefresh() {
            if (mListener != null) {
                mListener.onRefreshData();
            }
        }
    });
    return view;
}
Also used : OnListItemListener(com.khmelenko.lab.varis.adapter.OnListItemListener) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) View(android.view.View) RepoListAdapter(com.khmelenko.lab.varis.adapter.RepoListAdapter) SwipeRefreshLayout(android.support.v4.widget.SwipeRefreshLayout)

Aggregations

LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)2 RecyclerView (android.support.v7.widget.RecyclerView)2 View (android.view.View)2 OnListItemListener (com.khmelenko.lab.varis.adapter.OnListItemListener)2 SwipeRefreshLayout (android.support.v4.widget.SwipeRefreshLayout)1 DisplayMetrics (android.util.DisplayMetrics)1 TextView (android.widget.TextView)1 JobsListAdapter (com.khmelenko.lab.varis.adapter.JobsListAdapter)1 RepoListAdapter (com.khmelenko.lab.varis.adapter.RepoListAdapter)1 Job (com.khmelenko.lab.varis.network.response.Job)1