Android Open Source - beers-todrink Beer Adapter






From Project

Back to project page beers-todrink.

License

The source code is released under:

MIT License

If you think the Android project beers-todrink listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package br.com.androidzin.brunomateus.beerstodrink.adapter;
//from   w w w .j av a 2 s.  c om
import android.content.Context;
import android.content.res.Resources;
import android.database.Cursor;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import br.com.androidzin.brunomateus.beerstodrink.R;
import br.com.androidzin.brunomateus.beerstodrink.model.Beer;

import static br.com.androidzin.brunomateus.beerstodrink.provider.BeerContract.BeerColumns;

/**
 * Created by bruno on 11/12/14.
 */
public class BeerAdapter extends CursorRecyclerViewAdapter<BeerViewHolder>{

    private LayoutInflater mLayoutInflater;
    private OnBeerCardClickListener mBeerListener;
    private Beer.Drinkable mDrinkableListener;
    private Context mContext;

    public BeerAdapter(Context context, Cursor cursor) {
        super(context, cursor);
        setLayoutInflater(context);
        mContext = context;
    }

    public void setOnBeerCardListener(OnBeerCardClickListener listener){
        this.mBeerListener = listener;
    }

    public void setDrinkableListener(Beer.Drinkable drinkableCallbacks) {
        this.mDrinkableListener = drinkableCallbacks;
    }

    public interface OnBeerCardClickListener {

        public void onBeerSeleteced(String beerId);
    }

    private void setLayoutInflater(Context context) {
        mLayoutInflater = LayoutInflater.from(context);
    }

    @Override
    public BeerViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View cardView = mLayoutInflater.inflate(R.layout.beer_list_item, parent, false);
        BeerViewHolder holder = new BeerViewHolder(mContext, cardView, mBeerListener, mDrinkableListener);
        return holder;
    }

    @Override
    public void onBindViewHolder(BeerViewHolder viewHolder, Cursor cursor) {
        viewHolder.bindBeer(cursor);
    }

}




Java Source Code List

br.com.androidzin.brunomateus.beerstodrink.ApplicationTest.java
br.com.androidzin.brunomateus.beerstodrink.BeerDetailActivity.java
br.com.androidzin.brunomateus.beerstodrink.BeerDetailFragment.java
br.com.androidzin.brunomateus.beerstodrink.BeerDialogConfirmation.java
br.com.androidzin.brunomateus.beerstodrink.BeerDrinkingActivity.java
br.com.androidzin.brunomateus.beerstodrink.BeerFilterCountryDialog.java
br.com.androidzin.brunomateus.beerstodrink.BeerFilterTest.java
br.com.androidzin.brunomateus.beerstodrink.BeerListActivity.java
br.com.androidzin.brunomateus.beerstodrink.BeerListFragment.java
br.com.androidzin.brunomateus.beerstodrink.BeerProviderSimple.java
br.com.androidzin.brunomateus.beerstodrink.BeerProviderTest.java
br.com.androidzin.brunomateus.beerstodrink.adapter.BeerAdapter.java
br.com.androidzin.brunomateus.beerstodrink.adapter.BeerViewHolder.java
br.com.androidzin.brunomateus.beerstodrink.adapter.CursorRecyclerViewAdapter.java
br.com.androidzin.brunomateus.beerstodrink.model.Beer.java
br.com.androidzin.brunomateus.beerstodrink.provider.BeerContract.java
br.com.androidzin.brunomateus.beerstodrink.provider.BeerProvider.java
br.com.androidzin.brunomateus.beerstodrink.util.FilterBuilder.java