Android Open Source - Alkomer Glass Adapter






From Project

Back to project page Alkomer.

License

The source code is released under:

MIT License

If you think the Android project Alkomer 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 cz.jmx.tomik.alkomer.android.drinks;
//from  w  w w.j av  a  2 s.co  m
import java.text.SimpleDateFormat;
import java.util.ArrayList;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import cz.jmx.tomik.alkomer.android.R;

/**
 * Alkomer - Server App
 * --------------------
 * Adapter for List of All Drunk Drinks
 *
 * @copyright   Copyright (c) 2011 Tomas Vitek
 * @author      Tomas Vitek ~ http://tomik.jmx.cz

 * @package     Alkomer
 * @version     1.0
 */
public class GlassAdapter extends ArrayAdapter<Glass> {

    private Context context;
    private ArrayList<Glass> items;

    public GlassAdapter(Context context, int textViewResourceId, ArrayList<Glass> items) {
        
            super(context, textViewResourceId, items);
            
            this.items = items;
            this.context = context;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
      Drinks drinks = new Drinks();
      
    View v = convertView;
        
        Glass g = items.get(position);
        Drink d = drinks.findDrink(g.getDrinkId());
        
        if (v == null) {
            LayoutInflater vi = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            v = vi.inflate(R.layout.glass_list_row, null);
        }
        
      TextView text = (TextView) v.findViewById(R.id.text);
      text.setText(d.getName());
      
      TextView volume = (TextView) v.findViewById(R.id.volume);
      volume.setText("("+d.getVolumeInText()+")");      

      SimpleDateFormat timeFormatter = new SimpleDateFormat("HH:mm (d.M.)");
      
      TextView time = (TextView) v.findViewById(R.id.time);
      time.setText(timeFormatter.format(g.getTime()));      
      
      ImageView icon = (ImageView) v.findViewById(R.id.img);
      
        Drawable dr = null;
      if (d.getIconType().equals("drink_1")) dr = context.getResources().getDrawable(R.drawable.drink_1);
      if (d.getIconType().equals("drink_2")) dr = context.getResources().getDrawable(R.drawable.drink_2);
      if (d.getIconType().equals("drink_3")) dr = context.getResources().getDrawable(R.drawable.drink_3);
      if (d.getIconType().equals("drink_4")) dr = context.getResources().getDrawable(R.drawable.drink_4);
      if (d.getIconType().equals("drink_5")) dr = context.getResources().getDrawable(R.drawable.drink_5);
      if (d.getIconType().equals("drink_6")) dr = context.getResources().getDrawable(R.drawable.drink_6);
      if (d.getIconType().equals("drink_7")) dr = context.getResources().getDrawable(R.drawable.drink_7);
      if (d.getIconType().equals("drink_8")) dr = context.getResources().getDrawable(R.drawable.drink_8);
      if (d.getIconType().equals("drink_9")) dr = context.getResources().getDrawable(R.drawable.drink_9);
      if (d.getIconType().equals("drink_10")) dr = context.getResources().getDrawable(R.drawable.drink_10);
      if (d.getIconType().equals("drink_11")) dr = context.getResources().getDrawable(R.drawable.drink_11);
      if (d.getIconType().equals("drink_12")) dr = context.getResources().getDrawable(R.drawable.drink_12);
      if (d.getIconType().equals("drink_13")) dr = context.getResources().getDrawable(R.drawable.drink_13);
      if (d.getIconType().equals("drink_14")) dr = context.getResources().getDrawable(R.drawable.drink_14);
      if (d.getIconType().equals("drink_15")) dr = context.getResources().getDrawable(R.drawable.drink_15);
      if (d.getIconType().equals("drink_16")) dr = context.getResources().getDrawable(R.drawable.drink_16);
      icon.setImageDrawable(dr);

        return v;
    }
}




Java Source Code List

cz.jmx.tomik.alkomer.android.BaseActivity.java
cz.jmx.tomik.alkomer.android.DashboardActivity.java
cz.jmx.tomik.alkomer.android.DrinkListActivity.java
cz.jmx.tomik.alkomer.android.ForgottenPasswordActivity.java
cz.jmx.tomik.alkomer.android.GlassListActivity.java
cz.jmx.tomik.alkomer.android.LoginActivity.java
cz.jmx.tomik.alkomer.android.Main.java
cz.jmx.tomik.alkomer.android.RegistrationActivity.java
cz.jmx.tomik.alkomer.android.SettingsActivity.java
cz.jmx.tomik.alkomer.android.StatisticsActivity.java
cz.jmx.tomik.alkomer.android.StatisticsFlowAdapter.java
cz.jmx.tomik.alkomer.android.database.DataHelper.java
cz.jmx.tomik.alkomer.android.drinks.DrinkAdapter.java
cz.jmx.tomik.alkomer.android.drinks.Drink.java
cz.jmx.tomik.alkomer.android.drinks.Drinks.java
cz.jmx.tomik.alkomer.android.drinks.GlassAdapter.java
cz.jmx.tomik.alkomer.android.drinks.Glass.java
cz.jmx.tomik.alkomer.android.models.Gender.java
cz.jmx.tomik.alkomer.android.models.User.java
cz.jmx.tomik.alkomer.android.threads.DeleteDrinkThread.java
cz.jmx.tomik.alkomer.android.threads.DeleteDrinksThread.java
cz.jmx.tomik.alkomer.android.threads.DrinkThread.java
cz.jmx.tomik.alkomer.android.threads.ForgottenPasswordAsyncTask.java
cz.jmx.tomik.alkomer.android.threads.ImageDownloadAsyncTask.java
cz.jmx.tomik.alkomer.android.threads.LoginAsyncTask.java
cz.jmx.tomik.alkomer.android.threads.RegistrationAsyncTask.java
cz.jmx.tomik.alkomer.android.threads.UpdateSettingsThread.java
cz.jmx.tomik.alkomer.android.tools.Calculator.java
cz.jmx.tomik.alkomer.android.tools.DataTime.java
cz.jmx.tomik.alkomer.android.tools.EmailValidator.java
cz.jmx.tomik.alkomer.android.tools.IntEditTextPreference.java