// Path: HOSMCollect/src/hosm/odk/collect/android/provider/InstanceProviderAPI.java
//     public static final class InstanceColumns implements BaseColumns {
//         // This class cannot be instantiated
//         private InstanceColumns() {}
//         
//         public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/instances");
//         public static final String CONTENT_TYPE = "vnd.android.cursor.dir/vnd.odk.instance";
//         public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/vnd.odk.instance";
// 
//         // These are the only things needed for an insert
//         public static final String DISPLAY_NAME = "displayName";
//         public static final String SUBMISSION_URI = "submissionUri";
//         public static final String INSTANCE_FILE_PATH = "instanceFilePath";
//         public static final String JR_FORM_ID = "jrFormId";
//         public static final String JR_VERSION = "jrVersion";
//         //public static final String FORM_ID = "formId";
//         
//         // these are generated for you (but you can insert something else if you want)
//         public static final String STATUS = "status";
//         public static final String CAN_EDIT_WHEN_COMPLETE = "canEditWhenComplete";
//         public static final String LAST_STATUS_CHANGE_DATE = "date";
//         public static final String DISPLAY_SUBTEXT = "displaySubtext";
//         //public static final String DISPLAY_SUB_SUBTEXT = "displaySubSubtext";
// 
// 
// //        public static final String DEFAULT_SORT_ORDER = "modified DESC";
// //        public static final String TITLE = "title";
// //        public static final String NOTE = "note";
// //        public static final String CREATED_DATE = "created";
// //        public static final String MODIFIED_DATE = "modified";
//     }


import hosm.odk.collect.android.application.Collect;
import hosm.odk.collect.android.listeners.DeleteInstancesListener;
import hosm.odk.collect.android.provider.InstanceProviderAPI.InstanceColumns;
import android.content.ContentResolver;
import android.net.Uri;
import android.os.AsyncTask;
import android.util.Log;
/*
 * Copyright (C) 2012 University of Washington
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
 * in compliance with the License. You may obtain a copy of the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software distributed under the License
 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 * or implied. See the License for the specific language governing permissions and limitations under
 * the License.
 */

package hosm.odk.collect.android.tasks;


/**
 * Task responsible for deleting selected instances.
 * @author norman86@gmail.com
 * @author mitchellsundt@gmail.com
 *
 */
public class DeleteInstancesTask extends AsyncTask<Long, Void, Integer> {
	private static final String t = "DeleteInstancesTask";
	
	private ContentResolver cr;
	private DeleteInstancesListener dl;
	
	private int successCount = 0;
	
	@Override
	protected Integer doInBackground(Long... params) {
		int deleted = 0;

		if (params == null ||cr == null || dl == null) {
			return deleted;
		}
		
		// delete files from database and then from file system
		for (int i = 0; i < params.length; i++) {
			if ( isCancelled() ) {
				break;
			}
// Path: HOSMCollect/src/hosm/odk/collect/android/provider/InstanceProviderAPI.java
//     public static final class InstanceColumns implements BaseColumns {
//         // This class cannot be instantiated
//         private InstanceColumns() {}
//         
//         public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/instances");
//         public static final String CONTENT_TYPE = "vnd.android.cursor.dir/vnd.odk.instance";
//         public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/vnd.odk.instance";
// 
//         // These are the only things needed for an insert
//         public static final String DISPLAY_NAME = "displayName";
//         public static final String SUBMISSION_URI = "submissionUri";
//         public static final String INSTANCE_FILE_PATH = "instanceFilePath";
//         public static final String JR_FORM_ID = "jrFormId";
//         public static final String JR_VERSION = "jrVersion";
//         //public static final String FORM_ID = "formId";
//         
//         // these are generated for you (but you can insert something else if you want)
//         public static final String STATUS = "status";
//         public static final String CAN_EDIT_WHEN_COMPLETE = "canEditWhenComplete";
//         public static final String LAST_STATUS_CHANGE_DATE = "date";
//         public static final String DISPLAY_SUBTEXT = "displaySubtext";
//         //public static final String DISPLAY_SUB_SUBTEXT = "displaySubSubtext";
// 
// 
// //        public static final String DEFAULT_SORT_ORDER = "modified DESC";
// //        public static final String TITLE = "title";
// //        public static final String NOTE = "note";
// //        public static final String CREATED_DATE = "created";
// //        public static final String MODIFIED_DATE = "modified";
//     }


// Path: HOSMCollect/src/hosm/odk/collect/android/tasks/DeleteInstancesTask.java
import hosm.odk.collect.android.application.Collect;
import hosm.odk.collect.android.listeners.DeleteInstancesListener;
import hosm.odk.collect.android.provider.InstanceProviderAPI.InstanceColumns;
import android.content.ContentResolver;
import android.net.Uri;
import android.os.AsyncTask;
import android.util.Log;

/*
 * Copyright (C) 2012 University of Washington
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
 * in compliance with the License. You may obtain a copy of the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software distributed under the License
 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 * or implied. See the License for the specific language governing permissions and limitations under
 * the License.
 */

package hosm.odk.collect.android.tasks;


/**
 * Task responsible for deleting selected instances.
 * @author norman86@gmail.com
 * @author mitchellsundt@gmail.com
 *
 */
public class DeleteInstancesTask extends AsyncTask<Long, Void, Integer> {
	private static final String t = "DeleteInstancesTask";
	
	private ContentResolver cr;
	private DeleteInstancesListener dl;
	
	private int successCount = 0;
	
	@Override
	protected Integer doInBackground(Long... params) {
		int deleted = 0;

		if (params == null ||cr == null || dl == null) {
			return deleted;
		}
		
		// delete files from database and then from file system
		for (int i = 0; i < params.length; i++) {
			if ( isCancelled() ) {
				break;
			}
			try {