Android Open Source - PomodoroTimer Pomodoro List






From Project

Back to project page PomodoroTimer.

License

The source code is released under:

GNU General Public License

If you think the Android project PomodoroTimer 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.example.pomodorotimer;
//from   ww  w.j  a  va2  s  . c  om
import android.app.Activity;
import android.content.CursorLoader;
import android.content.Intent;
import android.database.Cursor;
import android.os.Bundle;
import android.app.LoaderManager;
import android.content.Loader;
import android.widget.SimpleCursorAdapter;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;

/**
 * The Class PomodoroList. Shows list of all pomodoros from databases. 
 */
public class PomodoroList extends Activity implements OnItemClickListener, LoaderManager.LoaderCallbacks<Cursor>
{
  
  /** The Constant NO_FLAGS. */
  private static final int NO_FLAGS = 0;
  
  /** The pomodoro list. */
  private ListView pomodoroListLV;
  
  /** The adapter. */
  private SimpleCursorAdapter adapter;
  
  /** The projection. */
  String[] projection = new String[] {
      PomodoroTimerDBContract.PomodorosTable.COLUMN_NAME_START_DATE,
      PomodoroTimerDBContract.PomodorosTable.COLUMN_NAME_STOP_DATE,
      PomodoroTimerDBContract.PomodorosTable.COLUMN_NAME_START_HOUR,
      PomodoroTimerDBContract.PomodorosTable.COLUMN_NAME_STOP_HOUR,
      PomodoroTimerDBContract.COLUMN_ID
  };

  /* (non-Javadoc)
   * @see android.app.Activity#onCreate(android.os.Bundle)
   */
  @Override
  protected void onCreate(Bundle savedInstanceState)
  {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_pomodoro_list);
    
    pomodoroListLV = (ListView) findViewById(R.id.pomodoroList);
    
    pomodoroListLV.setOnItemClickListener(this);
    
    getLoaderManager().initLoader(1, null, this);
  }

  /* (non-Javadoc)
   * @see android.widget.AdapterView.OnItemClickListener#onItemClick(android.widget.AdapterView, android.view.View, int, long)
   */
  @Override
  public void onItemClick(AdapterView<?> parent, View view, int position,
      long id)
  {
    Intent intent = new Intent(this, PomodoroDetails.class);
    intent.putExtra("dbID", id);
    startActivity(intent);    
  }

  /* (non-Javadoc)
   * @see android.app.LoaderManager.LoaderCallbacks#onCreateLoader(int, android.os.Bundle)
   */
  @Override
  public Loader<Cursor> onCreateLoader(int arg0, Bundle arg1)
  {
    CursorLoader cursorLoader = new CursorLoader(this, PomodoroContentProvider.CONTENT_URI_POMODOROS, projection, null, null, PomodoroTimerDBContract.PomodorosTable._ID + " ASC");
    return cursorLoader;
  }

  /* (non-Javadoc)
   * @see android.app.LoaderManager.LoaderCallbacks#onLoadFinished(android.content.Loader, java.lang.Object)
   */
  @Override
  public void onLoadFinished(Loader<Cursor> loader, Cursor data)
  {
    if(adapter == null) 
    {
      //TODO: rebuild listlayout.xml - it's ugly
      adapter = new SimpleCursorAdapter(this, R.layout.pomodoro_list_layout, data, projection, new int[] { R.id.TextView1, R.id.TextView3, R.id.TextView2, R.id.TextView4}, NO_FLAGS);
    } 
    else
    {
      adapter.swapCursor(data);
    }
    pomodoroListLV.setAdapter(adapter);
  }

  /* (non-Javadoc)
   * @see android.app.LoaderManager.LoaderCallbacks#onLoaderReset(android.content.Loader)
   */
  @Override
  public void onLoaderReset(Loader<Cursor> loader)
  {
    if(adapter != null)
    {
      adapter.swapCursor(null);
    }
    
  }

  /* (non-Javadoc)
   * @see android.app.Activity#onResume()
   */
  @Override
  protected void onResume()
  {
    super.onResume();
    getLoaderManager().restartLoader(1, null, this);
  
  }
  
  //TODO: if list is empty show any statement
  
  
}




Java Source Code List

com.example.pomodorotimer.About.java
com.example.pomodorotimer.DropboxLink.java
com.example.pomodorotimer.MainActivity.java
com.example.pomodorotimer.PomodoroClass.java
com.example.pomodorotimer.PomodoroContentProvider.java
com.example.pomodorotimer.PomodoroDetails.java
com.example.pomodorotimer.PomodoroEdit.java
com.example.pomodorotimer.PomodoroList.java
com.example.pomodorotimer.PomodoroTimerDBContract.java
com.example.pomodorotimer.PomodoroTimerDBHelper.java
com.example.pomodorotimer.PomodorosTagClass.java
com.example.pomodorotimer.SettingsActivity.java
com.example.pomodorotimer.TagClass.java
com.example.pomodorotimer.TagDetails.java
com.example.pomodorotimer.TagEdit.java
com.example.pomodorotimer.TagList.java