gt: 						getActivity(), ListTypeI.TABLE_NEED, ListTableM.COLUMN_FILTER));
context: package com.sunyata.nourishment.pastAndFuture;
  
  import java.util.ArrayList;
  
  import android.app.ListFragment;
  import android.content.ContentValues;
  import android.content.Context;
  import android.content.Intent;
  import android.database.Cursor;
  import android.database.sqlite.SQLiteDatabase;
  import android.net.Uri;
  import android.provider.CalendarContract.Events;
  import android.util.Log;
  import android.view.ActionMode;
  import android.view.Menu;
  import android.view.MenuItem;
  import android.view.View;
  import android.view.ViewGroup;
  import android.widget.CheckBox;
  import android.widget.CursorAdapter;
  import android.widget.SimpleCursorAdapter;
  import android.widget.SimpleCursorAdapter.ViewBinder;
  import android.widget.TextView;
  
  import com.sunyata.nourishment.R;
  import com.sunyata.nourishment.database.ContentProviderM;
  import com.sunyata.nourishment.database.DatabaseHelperM;
  import com.sunyata.nourishment.database.ListTableM;
  import com.sunyata.nourishment.database.ListTableM.ListTableNameI;
  import com.sunyata.nourishment.database.MomentListRelationTableM;
  import com.sunyata.nourishment.util.DatabaseU;
  import com.sunyata.nourishment.util.DbgU;
  import com.sunyata.nourishment.util.OtherU;
  import com.sunyata.nourishment.util.OtherU.SectionTypeI;
  
  public class FutureListFragmentC extends CabListFragmentAC {
  
  	private static final int FUTURE_LOADER_ID = 21;
  
  	public static CabListFragmentAC newInstance(){
  		CabListFragmentAC retListFragment = new FutureListFragmentC();
  		
  		return retListFragment;
  	}
  	
  	@Override
  	public int getMenu() {
  		return R.menu.future_contextual;
  	}
  
  	@Override
  	public int getLoaderId() {
  		return FUTURE_LOADER_ID;
  	}
  
  	@Override
  	public String getMainQueryString() {
  		return ListTableNameI.TABLE_CATEGORY;
  	}
  
  	@Override
  	public String[] getProjection() {
  		String[] tmpProjection = {
  				ListTableM.COLUMN_ID, ListTableM.COLUMN_NAME, ListTableM.COLUMN_ACTIVE};
  		return tmpProjection;
  	}
  	
  	
  	
  
  	@Override
  	public String getSelection() {
  		return null; //Unused
  	}
  	@Override
  	public String getSortOrder() {
  		return ListTableM.COLUMN_SORT_VALUE + " DESC";
  	}
  	
  
  	
  	
  	@Override
  	public String[] getDatabaseFrom() {
  		String[] tDatabaseFrom = {ListTableM.COLUMN_NAME, ListTableM.COLUMN_ACTIVE};
  		return tDatabaseFrom;
  	}
  
  	@Override
  	public int[] getDatabaseTo() {
  		int[] tDatabaseTo = {R.id.titleTextView, R.id.activeCheckBox};
  		return tDatabaseTo;
  	}
  	
  	
  	
  
  	@Override
  	public int getRowLayout() {
  		return R.layout.row_future;
  	}
  
  	@Override
  	public ViewBinder getViewBinder(Context iContext) {
  		// TODO Auto-generated method stub
  		return new ViewBinderM(iContext);
  	}
  
  	
  
  	/**
  	 * \brief Binder which binds values in the database to parts of the rows
  	 * 
  	 * Some bindings are supported by default, in those cases we can simply return false
  	 * and the adapter will take care of the mapping. The modifications we have made:
  	 * + We do the binding for checkboxes ourselves
  	 * 
  	 * Note: When running with the debug window open in eclipse we can see that many
  	 * binder threads are created, more than we would expect normally, but this is not an
  	 * error according to one info source
  	 */
  	private static class ViewBinderM implements ViewBinder{
  
  		public ViewBinderM(Context iContext){
  			
  		}
  		
  		@Override
  		public boolean setViewValue(View inView, Cursor inCursor, int inColumnIndex) {
  
  			if(inColumnIndex == inCursor.getColumnIndexOrThrow(ListTableM.COLUMN_ACTIVE)){
  				//Setting status of the checkbox (checked / not checked)
  				long tmpActive = Long.parseLong(inCursor.getString(
  						inCursor.getColumnIndexOrThrow(ListTableM.COLUMN_ACTIVE)));
  				CheckBox tmpCheckBox = ((CheckBox)inView.findViewById(R.id.activeCheckBox));
  				if (tmpCheckBox != null){
  					tmpCheckBox.setChecked(tmpActive != ListTableM.FALSE);
  				}
  				return true;
  				//-hilarious if we don't have this, the checkboxes displays the expected state,
  				//but we get a number representation as well to the right of the checkboxes!
  				
  			}
  
  			//Returning false for other values, which means that default mapping will be done
  			return false;
  		}
  	}
  
  
  
  	@Override
  	public SimpleCursorAdapter getMyAdapter() {
  		SimpleCursorAdapter rCursorAdapter = new RelationCursorAdapterM(
  				this, getRowLayout(), null, getDatabaseFrom(),
  				getDatabaseTo(), CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER);
  		return rCursorAdapter;
  	}
  
  	
  	
  	private class RelationCursorAdapterM extends SimpleCursorAdapter{
  
  		private static final String TEXT_SEPARATOR = ", ";
  		
  		private ListFragment mListFragment;
  		
  		private Cursor mRelCr; ///@< It seems we need to have this as a member var (not local var)
  
  		public RelationCursorAdapterM(ListFragment iListFragment, int layout, Cursor c, String[] from, int[] to,
  				int flags) {
  			
  			super(iListFragment.getActivity(), layout, c, from, to, flags);
  			mListFragment = iListFragment;
  		}
  
  		
  		private String getQueryString(long iCurrentCategoryRowId){
  			return "SELECT * FROM moment_need_relation"
  					+ " INNER JOIN need"
  					+ " ON moment_need_relation.need_id=need._id"
  					+ " INNER JOIN moment_category_relation"
  					+ " ON moment_need_relation.moment_id=moment_category_relation.moment_id"
  					+ " WHERE moment_category_relation.category_id=" + iCurrentCategoryRowId
  					+ " GROUP BY need.name";
  		}
  		
  		/**
  		 * \brief
  		 * 
  		 * This implementation is different from the previous implementation in kindmind (which is
  		 * no longer used) and also is different from other examples
  		 */
  		@Override
  		public View getView(int iPos, View iConvertView, ViewGroup iParent){
  			View v = super.getView(iPos, iConvertView, iParent);
  			
  			this.updateTextView(R.id.needsTextView, v, iPos);
  
  			return v;
  		}
  		
  		private void updateTextView(int iResId, View iView, int iPos){
  			long tCurrentMomentRowId = super.getItemId(iPos);
  			
  			mRelCr = DatabaseHelperM.get(mListFragment.getActivity()).rawQuery(
  					getQueryString(tCurrentMomentRowId));
  
  			String tNeedText = DatabaseU.EMPTY_STRING;
  			
  			if(mRelCr.moveToFirst() == true){
  				for(mRelCr.moveToFirst(); mRelCr.isAfterLast() == false; mRelCr.moveToNext()){
  					tNeedText = addTextWithSeparator(
  							tNeedText,
  							mRelCr.getString(mRelCr.getColumnIndexOrThrow(ListTableM.COLUMN_NAME)));
  				}
  			}
  			
  			((TextView)iView.findViewById(iResId)).setText(tNeedText);
  		}
  
  		private String addTextWithSeparator(String iTextBase, String iTextToAdd) {
  			String rText;
  			if(iTextBase == DatabaseU.EMPTY_STRING){
  				rText = iTextToAdd;
  			}else{
  				rText = iTextBase + TEXT_SEPARATOR + iTextToAdd;
  			}
  			return rText;
  		}
  	}
  
  
  	@Override
  	public void handleOnContextActionItemClicked(ActionMode mode, MenuItem item, ArrayList<Uri> iUris) {
  		final String constSeparator = " + ";
  		switch(item.getItemId()){
  		case R.id.action_add_to_calendar:
  			String tName = DatabaseU.EMPTY_STRING;
  			for(Uri u : iUris){
  				if(tName.equals(DatabaseU.EMPTY_STRING) == true){
  					tName = DatabaseU.getStringFromTable(u, getActivity(), ListTableM.COLUMN_NAME);
  				}else{
  					tName = tName + constSeparator
  							+ DatabaseU.getStringFromTable(u, getActivity(), ListTableM.COLUMN_NAME);
  				}
  			}
  			
  			//Updating calendar 
  			launchCalendar(tName);
  		break;
  		default:
  		}
  	}
  	private void launchCalendar(String iTitle) {
  		Intent tCalendarIntent = new Intent(Intent.ACTION_EDIT);
  		tCalendarIntent.setType("vnd.android.cursor.item/event");
  		tCalendarIntent.putExtra(Events.TITLE, iTitle);
  		tCalendarIntent.putExtra(Events.DESCRIPTION, "test event description / needs");
  		getActivity().startActivity(tCalendarIntent);
  	}
  
  	@Override
  	public void handleOnPrepareOptionsMenu(Menu iMenu) {
  		OtherU.setMenuVisibility(iMenu, SectionTypeI.FUTURE);
  	}
  	
  	@Override
  	public boolean handleOnOptionsItemSelected(MenuItem iMenuItem){
  		switch (iMenuItem.getItemId()){
  		case R.id.future_action_sort_by_needs:
  			NeedsDialogFragmentC tNeedsDialogFragment = NeedsDialogFragmentC.newInstance(this, ListTableM.COLUMN_SORT);
  			tNeedsDialogFragment.show(getFragmentManager(), NEEDS_DIALOG);
  			return true;
  		default:
  			return false;
  		}
  	}
  	
  	@Override
  	public void fireOnExitNeedsDialog() {
  		/*
  		mSelection = STATUS_SELECTION + buildSelectionString(ListTypeI.TABLE_NEED,
  				ListTableM.getIdsOfCheckedRows(
  