Android Open Source - RadioRake Scheduled Recordings Cursor Adaptor






From Project

Back to project page RadioRake.

License

The source code is released under:

GNU General Public License

If you think the Android project RadioRake 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.asp.radiorake;
//from w  ww  . j  a  v  a  2  s  . c  o  m
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 com.asp.radiorake.utils.StringUtils;
import com.aspillai.R;

public class ScheduledRecordingsCursorAdaptor extends SimpleCursorAdapter {

    private int layout;

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

    @Override
    public View newView(Context context, Cursor cursor, ViewGroup parent) {

        Cursor c = getCursor();

        final LayoutInflater inflater = LayoutInflater.from(context);
        View v = inflater.inflate(layout, parent, false);

        int stationColumn = c.getColumnIndex(DatabaseHelper.STATIONS_NAME);
        int typeColumn = c.getColumnIndex(DatabaseHelper.RECORDING_TYPES_TYPE);
        int startTimeColumn = c.getColumnIndex(DatabaseHelper.SCHEDULED_RECORDINGS_START_TIME);
        int endTimeColumn = c.getColumnIndex(DatabaseHelper.SCHEDULED_RECORDINGS_END_TIME);

        String station = c.getString(stationColumn);
        String type = c.getString(typeColumn);
        long start = c.getLong(startTimeColumn);
        long end = c.getLong(endTimeColumn);

        TextView station_text = (TextView) v.findViewById(R.id.station_entry);
        if (station_text != null) {
            station_text.setText(station);
        }

        TextView type_text = (TextView) v.findViewById(R.id.type_entry);
        if (type_text != null) {
            type_text.setText(type);
        }

        TextView start_time_text = (TextView) v.findViewById(R.id.start_time_entry);
        if (start_time_text != null) {
            start_time_text.setText(StringUtils.convertDateTimeToString(start));
        }

        TextView end_time_text = (TextView) v.findViewById(R.id.end_time_entry);
        if (end_time_text != null) {
            end_time_text.setText(StringUtils.convertDateTimeToString(end));
        }

        return v;

    }

    @Override
    public void bindView(View view, Context context, Cursor cursor) {

        int stationColumn = cursor.getColumnIndex(DatabaseHelper.STATIONS_NAME);
        int typeColumn = cursor.getColumnIndex(DatabaseHelper.RECORDING_TYPES_TYPE);
        int startTimeColumn = cursor.getColumnIndex(DatabaseHelper.SCHEDULED_RECORDINGS_START_TIME);
        int endTimeColumn = cursor.getColumnIndex(DatabaseHelper.SCHEDULED_RECORDINGS_END_TIME);

        String station = cursor.getString(stationColumn);
        String type = cursor.getString(typeColumn);
        long start = cursor.getLong(startTimeColumn);
        long end = cursor.getLong(endTimeColumn);

        TextView station_text = (TextView) view.findViewById(R.id.station_entry);
        if (station_text != null) {
            station_text.setText(station);
        }

        TextView type_text = (TextView) view.findViewById(R.id.type_entry);
        if (type_text != null) {
            type_text.setText(type);
        }

        TextView start_time_text = (TextView) view.findViewById(R.id.start_time_entry);
        if (start_time_text != null) {
            start_time_text.setText(StringUtils.convertDateTimeToString(start));
        }

        TextView end_time_text = (TextView) view.findViewById(R.id.end_time_entry);
        if (end_time_text != null) {
            end_time_text.setText(StringUtils.convertDateTimeToString(end));
        }
    }
}




Java Source Code List

com.asp.radiorake.AddNewScheduledRecordingActivity.java
com.asp.radiorake.AlarmHelper.java
com.asp.radiorake.CallReceiver.java
com.asp.radiorake.ConfirmDetailsActivity.java
com.asp.radiorake.DatabaseHelper.java
com.asp.radiorake.DatePickerFragment.java
com.asp.radiorake.LastPlayedFile.java
com.asp.radiorake.ListScheduledRecordingsActivity.java
com.asp.radiorake.NotificationHelper.java
com.asp.radiorake.PlayerService.java
com.asp.radiorake.PlayingFile.java
com.asp.radiorake.RadioActivity.java
com.asp.radiorake.RadioApplication.java
com.asp.radiorake.RadioDetails.java
com.asp.radiorake.RebootBroadcastReceiver.java
com.asp.radiorake.RecordingsActivity.java
com.asp.radiorake.RecordioBaseActivity.java
com.asp.radiorake.RemoteControlReceiver.java
com.asp.radiorake.ScheduledRecordingsCursorAdaptor.java
com.asp.radiorake.TimePickerFragment.java
com.asp.radiorake.filehandling.FileHandler.java
com.asp.radiorake.filehandling.M3uHandler.java
com.asp.radiorake.filehandling.PlsHandler.java
com.asp.radiorake.recording.RecorderService.java
com.asp.radiorake.recording.RecordingBroadcastReceiver.java
com.asp.radiorake.utils.DateUtils.java
com.asp.radiorake.utils.StringUtils.java