Android Open Source - tasktracker-android Sticky Adapter






From Project

Back to project page tasktracker-android.

License

The source code is released under:

Copyright (c) 2012 Remo Mueller https://github.com/remomueller This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License. To view a copy of this lice...

If you think the Android project tasktracker-android 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 com.github.remomueller.tasktracker.android;
//  w  ww.  ja  v a2s. co m
import android.app.Activity;
import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.RelativeLayout;
import android.widget.TextView;

import android.graphics.Paint;

import java.util.ArrayList;

import android.util.Log;

public class StickyAdapter extends BaseAdapter {

    private static final String TAG = "TaskTrackerAndroid";

    private Activity activity;
    private ArrayList<Sticky> data;
    private static LayoutInflater inflater = null;

    public StickyAdapter(Activity activity, ArrayList<Sticky> data) {
        this.activity = activity;
        this.data = data;
        this.inflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    }

    public int getCount() {
        return data.size();
    }

    public Object getItem(int position) {
        return data.get(position);
    }

    public long getItemId(int position) {
        return position;
    }

    public View getView(int position, View convertView, ViewGroup parent) {
        View vi = convertView;
        if(convertView == null) {
            vi = inflater.inflate(R.layout.stickies_index_item, null);
        }

        TextView sticky_id = (TextView) vi.findViewById(R.id.sticky_id);
        TextView description = (TextView) vi.findViewById(R.id.description);
        TextView due_date = (TextView) vi.findViewById(R.id.due_date);
        // RelativeLayout tags_container = (RelativeLayout) vi.findViewById(R.id.tags_container);

        TextView single_tag = (TextView) vi.findViewById(R.id.single_tag);

        Sticky sticky = new Sticky();
        sticky = data.get(position);

        sticky_id.setText(Integer.toString(sticky.id));
        if(sticky.completed) {
            sticky_id.setPaintFlags(sticky_id.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
        }else{
            sticky_id.setPaintFlags(sticky_id.getPaintFlags() & (~ Paint.STRIKE_THRU_TEXT_FLAG));
        }

        description.setText(sticky.full_description());
        due_date.setText(sticky.short_due_date());

        // final TextView tagtext = new TextView(vi);

        if(sticky.tags.length != 0) {
            for(int i = 0; i < sticky.tags.length; i++) {
                // final TextView tagtext = new TextView(vi);
                if(i == 0) {
                    single_tag.setText(sticky.tags[i].name);
                    single_tag.setBackgroundColor(Color.parseColor(sticky.tags[i].color));
                    single_tag.setVisibility(View.VISIBLE);
                }
                // tagtext.setText("This is: " + sticky.tags[i].name);
                // tags_container.addView(tagtext);
            }
        }else{
            single_tag.setText("");
            single_tag.setVisibility(View.GONE);
        }

        return vi;
    }
}




Java Source Code List

com.github.remomueller.tasktracker.android.AboutActivity.java
com.github.remomueller.tasktracker.android.DashboardActivity.java
com.github.remomueller.tasktracker.android.LoginActivity.java
com.github.remomueller.tasktracker.android.MainActivity.java
com.github.remomueller.tasktracker.android.ProjectAdapter.java
com.github.remomueller.tasktracker.android.Project.java
com.github.remomueller.tasktracker.android.ProjectsIndex.java
com.github.remomueller.tasktracker.android.ProjectsNew.java
com.github.remomueller.tasktracker.android.StickiesFragment.java
com.github.remomueller.tasktracker.android.StickiesIndex.java
com.github.remomueller.tasktracker.android.StickiesNew.java
com.github.remomueller.tasktracker.android.StickiesShow.java
com.github.remomueller.tasktracker.android.StickyAdapter.java
com.github.remomueller.tasktracker.android.Sticky.java
com.github.remomueller.tasktracker.android.Tag.java
com.github.remomueller.tasktracker.android.TaskTracker.java
com.github.remomueller.tasktracker.android.User.java
com.github.remomueller.tasktracker.android.util.AsyncRequest.java
com.github.remomueller.tasktracker.android.util.Base64.java
com.github.remomueller.tasktracker.android.util.DatabaseHandler.java
com.github.remomueller.tasktracker.android.util.ProjectsRequest.java
com.github.remomueller.tasktracker.android.util.StickiesRequest.java
com.github.remomueller.tasktracker.android.util.WebRequest.java