Search in sources :

Example 11 with ProgressDialog

use of android.app.ProgressDialog in project Anki-Android by Ramblurr.

the class Reviewer method onCreate.

// ----------------------------------------------------------------------------
// ANDROID METHODS
// ----------------------------------------------------------------------------
@Override
protected void onCreate(Bundle savedInstanceState) {
    // Create the extensions as early as possible, so that they can be offered events.
    mExtensions = new ReviewerExtRegistry(getBaseContext());
    Themes.applyTheme(this);
    super.onCreate(savedInstanceState);
    Log.i(AnkiDroidApp.TAG, "Reviewer - onCreate");
    // Remove the status bar and title bar
    if (mPrefFullscreenReview) {
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
        // Do not hide the title bar in Honeycomb, since it contains the action bar.
        if (AnkiDroidApp.SDK_VERSION <= 11) {
            requestWindowFeature(Window.FEATURE_NO_TITLE);
        }
    }
    mChangeBorderStyle = Themes.getTheme() == Themes.THEME_ANDROID_LIGHT || Themes.getTheme() == Themes.THEME_ANDROID_DARK;
    // The hardware buttons should control the music volume while reviewing.
    setVolumeControlStream(AudioManager.STREAM_MUSIC);
    Collection col = AnkiDroidApp.getCol();
    if (col == null) {
        reloadCollection(savedInstanceState);
        return;
    } else {
        mSched = col.getSched();
        mCollectionFilename = col.getPath();
        mBaseUrl = Utils.getBaseUrl(col.getMedia().getDir());
        restorePreferences();
        setFullScreen(mPrefFullscreenReview);
        registerExternalStorageListener();
        if (mNightMode) {
            mCurrentBackgroundColor = Themes.getNightModeCardBackground(this);
        } else {
            mCurrentBackgroundColor = Color.WHITE;
        }
        mUseQuickUpdate = shouldUseQuickUpdate();
        initLayout(R.layout.flashcard);
        try {
            String[] title = mSched.getCol().getDecks().current().getString("name").split("::");
            AnkiDroidApp.getCompat().setTitle(this, title[title.length - 1], mInvertedColors);
        } catch (JSONException e) {
            throw new RuntimeException(e);
        }
        AnkiDroidApp.getCompat().setSubtitle(this, "", mInvertedColors);
        if (mPrefTextSelection) {
            clipboardSetText("");
        }
        // Load the template for the card
        try {
            mCardTemplate = Utils.convertStreamToString(getAssets().open("card_template.html"));
        } catch (IOException e) {
            e.printStackTrace();
        }
        // Initialize text-to-speech. This is an asynchronous operation.
        if (mSpeakText) {
            ReadText.initializeTts(this);
            mTTSProgressDialog = new ProgressDialog(this);
            new AsyncTask<String, Void, Void>() {

                @Override
                protected void onPreExecute() {
                    mTTSProgressDialog.setMessage("Init TTS");
                    mTTSProgressDialog.show();
                }

                @Override
                protected Void doInBackground(String... params) {
                    while (ReadText.mTTSInitDone == false) {
                        try {
                            Thread.sleep(500);
                        } catch (InterruptedException e) {
                            e.printStackTrace();
                        }
                    }
                    return null;
                }

                @Override
                protected void onPostExecute(Void res) {
                    mTTSProgressDialog.dismiss();
                    // Load the first card and start reviewing. Uses the answer card
                    // task to load a card, but since we send null
                    // as the card to answer, no card will be answered.
                    DeckTask.launchDeckTask(DeckTask.TASK_TYPE_ANSWER_CARD, mAnswerCardHandler, new DeckTask.TaskData(mSched, null, 0));
                }
            }.execute();
        }
        // Get last whiteboard state
        if (mPrefWhiteboard && mCurrentCard != null && MetaDB.getWhiteboardState(this, mCurrentCard.getDid()) == 1) {
            mShowWhiteboard = true;
            mWhiteboard.setVisibility(View.VISIBLE);
        }
        // Load the first card and start reviewing. Uses the answer card
        // task to load a card, but since we send null
        // as the card to answer, no card will be answered.
        DeckTask.launchDeckTask(DeckTask.TASK_TYPE_ANSWER_CARD, mAnswerCardHandler, new DeckTask.TaskData(mSched, null, 0));
        // Since we aren't actually answering a card, decrement the rep count
        mSched.setReps(mSched.getReps() - 1);
    }
}
Also used : JSONException(org.json.JSONException) SpannedString(android.text.SpannedString) SpannableString(android.text.SpannableString) IOException(java.io.IOException) ProgressDialog(android.app.ProgressDialog) StyledProgressDialog(com.ichi2.themes.StyledProgressDialog) DeckTask(com.ichi2.async.DeckTask) Collection(com.ichi2.libanki.Collection) ReviewerExtRegistry(com.ichi2.anki.reviewer.ReviewerExtRegistry)

Example 12 with ProgressDialog

use of android.app.ProgressDialog in project SeriesGuide by UweTrottmann.

the class SearchActivity method showProgressDialog.

private void showProgressDialog() {
    if (progressDialog == null) {
        progressDialog = new ProgressDialog(this);
        progressDialog.setCancelable(false);
    }
    progressDialog.show();
}
Also used : ProgressDialog(android.app.ProgressDialog)

Example 13 with ProgressDialog

use of android.app.ProgressDialog in project FileExplorer by MiCode.

the class FileViewInteractionHub method showProgress.

private void showProgress(String msg) {
    progressDialog = new ProgressDialog(mContext);
    // dialog.setIcon(R.drawable.icon);
    progressDialog.setMessage(msg);
    progressDialog.setIndeterminate(true);
    progressDialog.setCancelable(false);
    progressDialog.show();
}
Also used : ProgressDialog(android.app.ProgressDialog)

Example 14 with ProgressDialog

use of android.app.ProgressDialog in project 9GAG by Mixiaoxiao.

the class IntentUtil method shareBitmap.

public static void shareBitmap(final Activity context, final Bitmap bitmap, final String chooserDialogTitleString) {
    //		chooserDialogTitleString = "share";
    final Intent intent = new Intent(Intent.ACTION_SEND);
    intent.setType("image/png");
    //		ByteArrayOutputStream bos = new ByteArrayOutputStream();
    if (bitmap != null) {
        //			bitmap.compress(CompressFormat.PNG, 100, bos);
        //			intent.putExtra(Intent.EXTRA_STREAM, bos.toByteArray());
        //			final ProgressDialog dialog = ProgressDialog.show(context, null, MxxTextUtil.getTypefaceSpannableString(context, "Just wait a moment...",  MxxTextUtil.Roboto_Light, false));
        final Dialog dialog = MxxDialogUtil.creatPorgressDialog(context, null, MxxTextUtil.getTypefaceSpannableString(context, "Just wait a moment...", MxxTextUtil.Roboto_Light, false), false, true, null);
        dialog.show();
        new Thread(new Runnable() {

            @Override
            public void run() {
                // TODO Auto-generated method stub
                final String imagePath = MxxFileUtil.getCachePath(context) + "/9gag_image_share.png";
                final boolean saved = BitmapUtil.saveBitmapFile(bitmap, imagePath);
                context.runOnUiThread(new Runnable() {

                    @Override
                    public void run() {
                        dialog.dismiss();
                        if (saved) {
                            File f = new File(imagePath);
                            if (f != null && f.exists() && f.isFile()) {
                                Uri u = Uri.fromFile(f);
                                intent.putExtra(Intent.EXTRA_STREAM, u);
                            }
                            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                            try {
                                context.startActivity(Intent.createChooser(intent, MxxTextUtil.getTypefaceSpannableString(context, chooserDialogTitleString, true)));
                            } catch (ActivityNotFoundException e) {
                                // TODO Auto-generated catch block
                                e.printStackTrace();
                            }
                        }
                    }
                });
            }
        }).start();
    }
}
Also used : ActivityNotFoundException(android.content.ActivityNotFoundException) ProgressDialog(android.app.ProgressDialog) Dialog(android.app.Dialog) Intent(android.content.Intent) File(java.io.File) Uri(android.net.Uri)

Example 15 with ProgressDialog

use of android.app.ProgressDialog in project openkit-android by OpenKit.

the class WebDialog method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setOnCancelListener(new OnCancelListener() {

        @Override
        public void onCancel(DialogInterface dialogInterface) {
            sendCancelToListener();
        }
    });
    spinner = new ProgressDialog(getContext());
    spinner.requestWindowFeature(Window.FEATURE_NO_TITLE);
    spinner.setMessage(getContext().getString(R.string.com_facebook_loading));
    spinner.setOnCancelListener(new OnCancelListener() {

        @Override
        public void onCancel(DialogInterface dialogInterface) {
            sendCancelToListener();
            WebDialog.this.dismiss();
        }
    });
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    contentFrameLayout = new FrameLayout(getContext());
    // First calculate how big the frame layout should be
    calculateSize();
    getWindow().setGravity(Gravity.CENTER);
    // resize the dialog if the soft keyboard comes up
    getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
    /* Create the 'x' image, but don't add to the contentFrameLayout layout yet
         * at this point, we only need to know its drawable width and height
         * to place the webview
         */
    createCrossImage();
    /* Now we know 'x' drawable width and height,
         * layout the webview and add it the contentFrameLayout layout
         */
    int crossWidth = crossImageView.getDrawable().getIntrinsicWidth();
    setUpWebView(crossWidth / 2 + 1);
    /* Finally add the 'x' image to the contentFrameLayout layout and
        * add contentFrameLayout to the Dialog view
        */
    contentFrameLayout.addView(crossImageView, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    setContentView(contentFrameLayout);
}
Also used : DialogInterface(android.content.DialogInterface) FrameLayout(android.widget.FrameLayout) ProgressDialog(android.app.ProgressDialog) SuppressLint(android.annotation.SuppressLint)

Aggregations

ProgressDialog (android.app.ProgressDialog)247 DialogInterface (android.content.DialogInterface)43 Intent (android.content.Intent)20 View (android.view.View)17 File (java.io.File)17 Handler (android.os.Handler)12 FrameLayout (android.widget.FrameLayout)12 TextView (android.widget.TextView)10 IOException (java.io.IOException)10 JSONObject (org.json.JSONObject)10 LinearLayout (android.widget.LinearLayout)9 ArrayList (java.util.ArrayList)9 SuppressLint (android.annotation.SuppressLint)8 Display (android.view.Display)8 Activity (android.app.Activity)7 Uri (android.net.Uri)7 AsyncTask (android.os.AsyncTask)7 Bundle (android.os.Bundle)6 KeyEvent (android.view.KeyEvent)6 ImageView (android.widget.ImageView)6