Android Open Source - OMGDrums Saved Data Adapter






From Project

Back to project page OMGDrums.

License

The source code is released under:

The OMG License This license is not enforcable.

If you think the Android project OMGDrums 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.monadpad.omgdrums;
/*from  w  w w  .  jav a  2 s.com*/
import android.content.Context;
import android.database.Cursor;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.SimpleCursorAdapter;
import android.widget.TextView;

import java.text.SimpleDateFormat;
import java.util.Date;

public class SavedDataAdapter extends SimpleCursorAdapter {
    private final Context context;
    private final Cursor mCursor;
    private final SimpleDateFormat dateFormat = new SimpleDateFormat("MM/dd HH:mm");

    public SavedDataAdapter(Context context, int layout, Cursor c, String[] from, int[] to){
        super(context, layout, c, from, to);
        this.context = context;
        this.mCursor = c;
    }

    @Override
    public View getView(final int position, View convertView, ViewGroup parent){
        final View rowView;
        final ViewHolder holder;
        if (convertView == null){
            LayoutInflater inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            rowView = inflater.inflate(R.layout.saved_row, parent, false);
            holder = new ViewHolder();

            holder.tags = (TextView)rowView.findViewById(R.id.saved_data_tags);
            holder.date = (TextView)rowView.findViewById(R.id.saved_data_date);
            rowView.setTag(holder);

       }
        else {
            rowView = convertView;
            holder = (ViewHolder)convertView.getTag();
        }

        mCursor.moveToPosition(position);
        String tags = mCursor.getString(mCursor.getColumnIndex("tags"));
        if (tags.length() == 0) {
            tags = "(no tags)";
        }
        holder.tags.setText(tags);

        Date date = new Date();
        date.setTime(mCursor.getLong(mCursor.getColumnIndex("time")) * 1000);
        holder.date.setText(dateFormat.format(date));

        //String date = mCursor.getString(mCursor.getColumnIndex("artist"));
        //holder.date.setText(date);
        final String json = mCursor.getString(mCursor.getColumnIndex("data"));

        return rowView;
    }

    static class ViewHolder {
        TextView tags;
        TextView date;
    }

}




Java Source Code List

com.monadpad.omgdrums.AnimatorHelper.java
com.monadpad.omgdrums.DrumMachineView.java
com.monadpad.omgdrums.GetDrawMusicActivity.java
com.monadpad.omgdrums.GetSketchaTuneActivity.java
com.monadpad.omgdrums.HeadBob.java
com.monadpad.omgdrums.Libeniz.java
com.monadpad.omgdrums.Main.java
com.monadpad.omgdrums.MonadJam.java
com.monadpad.omgdrums.OMGHelper.java
com.monadpad.omgdrums.SaveToOMG.java
com.monadpad.omgdrums.SavedDataAdapter.java
com.monadpad.omgdrums.SavedDataOpenHelper.java
com.monadpad.omgdrums.SavedListActivity.java