Android Open Source - TasksReminder Task Cursor Adapter






From Project

Back to project page TasksReminder.

License

The source code is released under:

MIT License

If you think the Android project TasksReminder 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.sampa.tasksreminder;
/*w w  w  .  j av a2s .com*/
import org.joda.time.LocalDate;
import org.joda.time.LocalTime;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;

import android.content.Context;
import android.database.Cursor;
import android.support.v4.widget.CursorAdapter;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

public class TaskCursorAdapter extends CursorAdapter {

  public TaskCursorAdapter(Context context, Cursor c) {
    super(context, c, FLAG_REGISTER_CONTENT_OBSERVER);
  }

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

    TextView titleView = (TextView) view.findViewById(R.id.title);
    titleView.setText(cursor.getString(cursor.getColumnIndex("title")));

    String dateString = cursor.getString(cursor.getColumnIndex("date"));

    LocalDate date = LocalDate.parse(dateString.substring(0, 10));
    LocalTime time = LocalTime.parse(dateString.substring(11,
        dateString.length() - 1));

    DateTimeFormatter fmt = DateTimeFormat.forPattern("dd/MM/yyyy");
    TextView dateView = (TextView) view.findViewById(R.id.date);
    dateView.setText(date.toString(fmt));

    fmt = DateTimeFormat.forPattern("HH:mm");
    TextView timeView = (TextView) view.findViewById(R.id.time);
    timeView.setText(time.toString(fmt));
  }

  @Override
  public View newView(Context context, Cursor cursor, ViewGroup parent) {
    // when the view will be created for first time,
    // we need to tell the adapters, how each item will look
    LayoutInflater inflater = LayoutInflater.from(parent.getContext());
    return inflater.inflate(R.layout.single_task_item, parent, false);
  }
}




Java Source Code List

com.sampa.tasksreminder.AlarmManagerHelper.java
com.sampa.tasksreminder.AlarmReceiver.java
com.sampa.tasksreminder.AlarmService.java
com.sampa.tasksreminder.DatePickerActivity.java
com.sampa.tasksreminder.DatePickerActivity_.java
com.sampa.tasksreminder.MainActivity.java
com.sampa.tasksreminder.MainActivity_.java
com.sampa.tasksreminder.NewTaskActivity.java
com.sampa.tasksreminder.NewTaskActivity_.java
com.sampa.tasksreminder.ShowTaskActivity.java
com.sampa.tasksreminder.ShowTaskActivity_.java
com.sampa.tasksreminder.TaskCursorAdapter.java
com.sampa.tasksreminder.TaskSQLiteHelper.java
com.sampa.tasksreminder.Task.java
com.sampa.tasksreminder.TimePickerFragment.java
com.sampa.tasksreminder.TimePickerFragment_.java
com.squareup.timessquare.CalendarCellView.java
com.squareup.timessquare.CalendarGridView.java
com.squareup.timessquare.CalendarPickerView.java
com.squareup.timessquare.CalendarRowView.java
com.squareup.timessquare.Logr.java
com.squareup.timessquare.MonthCellDescriptor.java
com.squareup.timessquare.MonthDescriptor.java
com.squareup.timessquare.MonthView.java