Search in sources :

Example 1 with AthleticModel

use of com.cleveroad.testrecycler.models.AthleticModel in project FanLayoutManager by Cleveroad.

the class FullInfoTabFragment method onViewCreated.

@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    toolbar.setTitle(sportCardModel.getSportTitle());
    toolbar.setNavigationIcon(R.drawable.ic_back);
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            getActivity().onBackPressed();
        }
    });
    toolbar.setBackgroundColor(ContextCompat.getColor(getContext(), sportCardModel.getBackgroundColorResId()));
    ivPhoto.setImageResource(sportCardModel.getImageResId());
    List<AthleticModel> items = new ArrayList<>();
    for (int i = 10; i > 0; i--) {
        int points = i * 100;
        items.add(new AthleticModel("Vae, mirabilis tumultumque", Country.ITALY, --points));
        items.add(new AthleticModel("Cobaltums favere", Country.USA, --points));
        items.add(new AthleticModel("Stella de peritus lixa", Country.ROK, --points));
    }
    ScoreAdapter scoreAdapter = new ScoreAdapter();
    scoreAdapter.addItems(items);
    rvAthletics.setAdapter(scoreAdapter);
    rvAthletics.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false));
    rvAthletics.setItemAnimator(new DefaultItemAnimator());
    rvAthletics.addItemDecoration(new DividerItemDecoration(getContext()));
}
Also used : AthleticModel(com.cleveroad.testrecycler.models.AthleticModel) ArrayList(java.util.ArrayList) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) ImageView(android.widget.ImageView) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) DefaultItemAnimator(android.support.v7.widget.DefaultItemAnimator)

Example 2 with AthleticModel

use of com.cleveroad.testrecycler.models.AthleticModel in project FanLayoutManager by Cleveroad.

the class ScoreAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(AthleticHolder holder, int position) {
    AthleticModel item = mItems.get(position);
    holder.tvAthleticName.setText(item.getName());
    holder.tvCountry.setText(item.getCountry().getCountry());
    holder.tvScore.setText(String.valueOf(item.getScore()));
    switch(item.getCountry()) {
        case USA:
            {
                holder.ivAthleticFlag.setImageResource(R.drawable.us_flag);
                break;
            }
        case ROK:
            {
                holder.ivAthleticFlag.setImageResource(R.drawable.flag_korea);
                break;
            }
        case ITALY:
            {
                holder.ivAthleticFlag.setImageResource(R.drawable.italy_flag);
                break;
            }
    }
}
Also used : AthleticModel(com.cleveroad.testrecycler.models.AthleticModel)

Aggregations

AthleticModel (com.cleveroad.testrecycler.models.AthleticModel)2 DefaultItemAnimator (android.support.v7.widget.DefaultItemAnimator)1 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 RecyclerView (android.support.v7.widget.RecyclerView)1 View (android.view.View)1 ImageView (android.widget.ImageView)1 ArrayList (java.util.ArrayList)1