Android Open Source - aReminder Category Adapter






From Project

Back to project page aReminder.

License

The source code is released under:

GNU General Public License

If you think the Android project aReminder 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

/**
 aReminder - an Android + Google wear application test for I/O 2014
//from w w w.  ja  v a 2 s  . co  m
 Copyright (C) 2014  Toni Martinez / Adam Doan Kim

 This program is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation, either version 3 of the License, or
 (at your option) any later version.

 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with this program.  If not, see <http://www.gnu.org/licenses/>.

 */
package com.hodor.company.areminder.ui;

import android.content.Context;
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 com.hodor.company.areminder.R;
import com.hodor.company.areminder.model.CategoryModel;
import com.hodor.company.areminder.util.ImagesUtil;

import java.util.List;

/**
 * Created by toni on 5/07/14.
 */
public class CategoryAdapter extends ArrayAdapter<CategoryModel> {

    private List<CategoryModel> mCategories;

    public CategoryAdapter(Context context, List<CategoryModel> values) {
        super(context, R.layout.category_item, values);
        this.mCategories = values;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View rowView = convertView;
        if(convertView==null) {
            LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            rowView = inflater.inflate(R.layout.category_item, parent, false);
        }

        ((TextView)rowView.findViewById(R.id.text)).setText(this.mCategories.get(position).getName());
        ((ImageView)rowView.findViewById(R.id.picture)).setImageResource(this.mCategories.get(position).getIcon());
        if (position>0) {
            ((ImageView) rowView.findViewById(R.id.picture)).setColorFilter(ImagesUtil.getGrayScaleFilter());
            rowView.setAlpha(0.4f);
        }

        return rowView;
    }

    @Override
    public long getItemId(int position) {
        return this.mCategories.get(position).getIcon();
    }
}




Java Source Code List

com.hodor.company.areminder.model.CategoryModel.java
com.hodor.company.areminder.service.TimerService.java
com.hodor.company.areminder.timer.CountDown.java
com.hodor.company.areminder.ui.CategoryAdapter.java
com.hodor.company.areminder.ui.MainActivity.java
com.hodor.company.areminder.ui.NotificationCenter.java
com.hodor.company.areminder.util.ImagesUtil.java
com.hodor.company.areminder.util.SimpleSharedPreferences.java
com.hodor.company.areminder.util.TimeUtil.java