Search in sources :

Example 1 with InstanceSyncTask

use of org.odk.collect.android.tasks.InstanceSyncTask in project collect by opendatakit.

the class DataManagerList method onViewCreated.

@Override
public void onViewCreated(View rootView, Bundle savedInstanceState) {
    deleteButton.setOnClickListener(this);
    toggleButton.setOnClickListener(this);
    setupAdapter();
    instanceSyncTask = new InstanceSyncTask();
    instanceSyncTask.setDiskSyncListener(this);
    instanceSyncTask.execute();
    super.onViewCreated(rootView, savedInstanceState);
}
Also used : InstanceSyncTask(org.odk.collect.android.tasks.InstanceSyncTask)

Example 2 with InstanceSyncTask

use of org.odk.collect.android.tasks.InstanceSyncTask in project collect by opendatakit.

the class InstanceChooserList method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    // must be at the beginning of any activity that can be called from an external intent
    try {
        Collect.createODKDirs();
    } catch (RuntimeException e) {
        createErrorDialog(e.getMessage(), EXIT);
        return;
    }
    setContentView(R.layout.chooser_list_layout);
    super.onCreate(savedInstanceState);
    String formMode = getIntent().getStringExtra(ApplicationConstants.BundleKeys.FORM_MODE);
    if (formMode == null || ApplicationConstants.FormModes.EDIT_SAVED.equalsIgnoreCase(formMode)) {
        setTitle(getString(R.string.review_data));
        editMode = true;
        sortingOptions = new String[] { getString(R.string.sort_by_name_asc), getString(R.string.sort_by_name_desc), getString(R.string.sort_by_date_asc), getString(R.string.sort_by_date_desc), getString(R.string.sort_by_status_asc), getString(R.string.sort_by_status_desc) };
    } else {
        setTitle(getString(R.string.view_sent_forms));
        sortingOptions = new String[] { getString(R.string.sort_by_name_asc), getString(R.string.sort_by_name_desc), getString(R.string.sort_by_date_asc), getString(R.string.sort_by_date_desc) };
        ((TextView) findViewById(android.R.id.empty)).setText(R.string.no_items_display_sent_forms);
    }
    setupAdapter();
    instanceSyncTask = new InstanceSyncTask();
    instanceSyncTask.setDiskSyncListener(this);
    instanceSyncTask.execute();
}
Also used : TextView(android.widget.TextView) InstanceSyncTask(org.odk.collect.android.tasks.InstanceSyncTask)

Example 3 with InstanceSyncTask

use of org.odk.collect.android.tasks.InstanceSyncTask in project collect by opendatakit.

the class InstanceUploaderList method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    Timber.i("onCreate");
    setContentView(R.layout.instance_uploader_list);
    super.onCreate(savedInstanceState);
    if (savedInstanceState != null) {
        showAllMode = savedInstanceState.getBoolean(SHOW_ALL_MODE);
    }
    instancesDao = new InstancesDao();
    uploadButton = findViewById(R.id.upload_button);
    uploadButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            ConnectivityManager connectivityManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
            NetworkInfo ni = connectivityManager.getActiveNetworkInfo();
            if (NetworkReceiver.running) {
                ToastUtils.showShortToast(R.string.send_in_progress);
            } else if (ni == null || !ni.isConnected()) {
                logger.logAction(this, "uploadButton", "noConnection");
                ToastUtils.showShortToast(R.string.no_connection);
            } else {
                int checkedItemCount = getCheckedCount();
                logger.logAction(this, "uploadButton", Integer.toString(checkedItemCount));
                if (checkedItemCount > 0) {
                    // items selected
                    uploadSelectedFiles();
                    setAllToCheckedState(listView, false);
                    toggleButtonLabel(findViewById(R.id.toggle_button), listView);
                    uploadButton.setEnabled(false);
                } else {
                    // no items selected
                    ToastUtils.showLongToast(R.string.noselect_error);
                }
            }
        }
    });
    final Button toggleSelsButton = findViewById(R.id.toggle_button);
    toggleSelsButton.setLongClickable(true);
    toggleSelsButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            ListView lv = listView;
            boolean allChecked = toggleChecked(lv);
            toggleButtonLabel(toggleSelsButton, lv);
            uploadButton.setEnabled(allChecked);
            if (!allChecked) {
                selectedInstances.clear();
            }
        }
    });
    toggleSelsButton.setOnLongClickListener(this);
    setupAdapter();
    listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
    listView.setItemsCanFocus(false);
    listView.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {

        @Override
        public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
            uploadButton.setEnabled(areCheckedItems());
        }
    });
    // set title
    setTitle(getString(R.string.send_data));
    instanceSyncTask = new InstanceSyncTask();
    instanceSyncTask.setDiskSyncListener(this);
    instanceSyncTask.execute();
    sortingOptions = new String[] { getString(R.string.sort_by_name_asc), getString(R.string.sort_by_name_desc), getString(R.string.sort_by_date_asc), getString(R.string.sort_by_date_desc) };
}
Also used : ListView(android.widget.ListView) InstancesDao(org.odk.collect.android.dao.InstancesDao) NetworkInfo(android.net.NetworkInfo) Button(android.widget.Button) ConnectivityManager(android.net.ConnectivityManager) OnClickListener(android.view.View.OnClickListener) InstanceSyncTask(org.odk.collect.android.tasks.InstanceSyncTask) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ListView(android.widget.ListView)

Aggregations

InstanceSyncTask (org.odk.collect.android.tasks.InstanceSyncTask)3 TextView (android.widget.TextView)2 ConnectivityManager (android.net.ConnectivityManager)1 NetworkInfo (android.net.NetworkInfo)1 View (android.view.View)1 OnClickListener (android.view.View.OnClickListener)1 AdapterView (android.widget.AdapterView)1 Button (android.widget.Button)1 ListView (android.widget.ListView)1 InstancesDao (org.odk.collect.android.dao.InstancesDao)1