Search in sources :

Example 1 with CategorizationFragment

use of fr.free.nrw.commons.category.CategorizationFragment in project apps-android-commons by commons-app.

the class MultipleShareActivity method multipleUploadBegins.

private void multipleUploadBegins() {
    Timber.d("Multiple upload begins");
    final ProgressDialog dialog = new ProgressDialog(this);
    dialog.setIndeterminate(false);
    dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
    dialog.setMax(photosList.size());
    dialog.setTitle(getResources().getQuantityString(R.plurals.starting_multiple_uploads, photosList.size(), photosList.size()));
    dialog.show();
    for (int i = 0; i < photosList.size(); i++) {
        Contribution up = photosList.get(i);
        // Goddamn Java
        final int uploadCount = i + 1;
        uploadController.startUpload(up, new UploadController.ContributionUploadProgress() {

            @Override
            public void onUploadStarted(Contribution contribution) {
                dialog.setProgress(uploadCount);
                if (uploadCount == photosList.size()) {
                    dialog.dismiss();
                    Toast startingToast = Toast.makeText(CommonsApplication.getInstance(), R.string.uploading_started, Toast.LENGTH_LONG);
                    startingToast.show();
                }
            }
        });
    }
    uploadsList.setImageOnlyMode(true);
    categorizationFragment = (CategorizationFragment) getSupportFragmentManager().findFragmentByTag("categorization");
    if (categorizationFragment == null) {
        categorizationFragment = new CategorizationFragment();
    }
    // FIXME: Stops the keyboard from being shown 'stale' while moving out of this fragment into the next
    View target = getCurrentFocus();
    if (target != null) {
        InputMethodManager imm = (InputMethodManager) target.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.hideSoftInputFromWindow(target.getWindowToken(), 0);
    }
    getSupportFragmentManager().beginTransaction().add(R.id.uploadsFragmentContainer, categorizationFragment, "categorization").commitAllowingStateLoss();
//See http://stackoverflow.com/questions/7469082/getting-exception-illegalstateexception-can-not-perform-this-action-after-onsa
}
Also used : Toast(android.widget.Toast) CategorizationFragment(fr.free.nrw.commons.category.CategorizationFragment) InputMethodManager(android.view.inputmethod.InputMethodManager) ProgressDialog(android.app.ProgressDialog) View(android.view.View) AdapterView(android.widget.AdapterView) Contribution(fr.free.nrw.commons.contributions.Contribution)

Aggregations

ProgressDialog (android.app.ProgressDialog)1 View (android.view.View)1 InputMethodManager (android.view.inputmethod.InputMethodManager)1 AdapterView (android.widget.AdapterView)1 Toast (android.widget.Toast)1 CategorizationFragment (fr.free.nrw.commons.category.CategorizationFragment)1 Contribution (fr.free.nrw.commons.contributions.Contribution)1