/*
 * Copyright (c) 2012 Google Inc.
 * 
 * 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 dacer.google.task;

import java.io.IOException;
import java.util.List;

import android.util.Log;

import dacer.settinghelper.SettingUtility;
import dacer.utils.GlobalContext;

/**
 * Asynchronously load the tasks.
 * 
 * @author Yaniv Inbar
 * modified by Dacer
 */
class SyncDBTasks extends CommonAsyncTask {
  String TAG = "AsyncLoadTask--->";
  private TaskLocalUtils tLocalUtils;
  
  SyncDBTasks(TaskListFragment listFragment) {
    super(listFragment);
    tLocalUtils = new TaskLocalUtils(GlobalContext.getInstance());
  }

  @Override
  protected void doInBackground() throws IOException {
	  Log.e(TAG, "Running");
    TaskUtils.updateDB(SettingUtility.getTaskListId(),GlobalContext.getInstance(),client);
    List<String> result = tLocalUtils.getTasksTitleFromDB();
    mFragment.tasksList = result;
  }

  static void run(TaskListFragment listFragment) {
    new SyncDBTasks(listFragment).execute();
  }
  
  
  

}
