Exemplo n.º 1
0
  @Override
  protected void onResume() {
    mDiskSyncTask.setDiskSyncListener(this);
    super.onResume();

    if (mDiskSyncTask.getStatus() == AsyncTask.Status.FINISHED) {
      SyncComplete(mDiskSyncTask.getStatusMessage());
    }

    // connect to cache word to get
    ((MyStatus) getApplicationContext()).connectCacheWord();
  }
Exemplo n.º 2
0
 @Override
 protected void onPause() {
   mDiskSyncTask.setDiskSyncListener(null);
   super.onPause();
   // disconnect to cache word to get
   ((MyStatus) getApplicationContext()).disconnectCacheWord();
 }
Exemplo n.º 3
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // must be at the beginning of any activity that can be called from an external intent
    try {
      MyStatus.createODKDirs();
    } catch (RuntimeException e) {
      createErrorDialog(e.getMessage(), EXIT);
      return;
    }

    setContentView(R.layout.chooser_list_layout);
    setTitle(getString(R.string.app_name) + " > " + getString(R.string.enter_data));

    String sortOrder = FormsColumns.DISPLAY_NAME + " ASC, " + FormsColumns.JR_VERSION + " DESC";
    Cursor c = managedQuery(FormsColumns.CONTENT_URI, null, null, null, sortOrder);

    String[] data =
        new String[] {
          FormsColumns.DISPLAY_NAME, FormsColumns.DISPLAY_SUBTEXT, FormsColumns.JR_VERSION
        };
    int[] view = new int[] {R.id.text1, R.id.text2, R.id.text3};

    // render total instance view
    SimpleCursorAdapter instances =
        new VersionHidingCursorAdapter(
            FormsColumns.JR_VERSION, this, R.layout.two_item, c, data, view);
    setListAdapter(instances);

    if (savedInstanceState != null && savedInstanceState.containsKey(syncMsgKey)) {
      TextView tv = (TextView) findViewById(R.id.status_text);
      tv.setText(savedInstanceState.getString(syncMsgKey));
    }

    // DiskSyncTask checks the disk for any forms not already in the content provider
    // that is, put here by dragging and dropping onto the SDCard
    mDiskSyncTask = (DiskSyncTask) getLastNonConfigurationInstance();
    if (mDiskSyncTask == null) {
      Log.i(t, "Starting new disk sync task");
      mDiskSyncTask = new DiskSyncTask();
      mDiskSyncTask.setDiskSyncListener(this);
      mDiskSyncTask.execute((Void[]) null);
    }
  }