Android Open Source - HueWatch P H Wizard Alert Dialog






From Project

Back to project page HueWatch.

License

The source code is released under:

Apache License

If you think the Android project HueWatch listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.philips.lighting.quickstart;
/*from  ww  w  . j av  a 2  s . c  o  m*/
import android.app.Activity;
import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.view.WindowManager;

/**
 * Generic class for Alert and Progress dialogs wizard
 * 
 * @author Stephen O'Reilly
 * 
 */

public final class PHWizardAlertDialog {

    private ProgressDialog pdialog;
    private static PHWizardAlertDialog dialogs;

    private PHWizardAlertDialog() {

    }

    public static synchronized PHWizardAlertDialog getInstance() {
        if (dialogs == null) {
            dialogs = new PHWizardAlertDialog();
        }
        return dialogs;
    }

    /**
     * 
     * @param activityContext
     * @param resID
     * @param btnNameResId
     *            String resource id for button name
     */
    public static void showErrorDialog(Context activityContext, String msg,
            int btnNameResId) {
        AlertDialog.Builder builder = new AlertDialog.Builder(activityContext);
        builder.setTitle(R.string.title_error).setMessage(msg)
                .setPositiveButton(btnNameResId, null);
        AlertDialog alert = builder.create();
        alert.getWindow().setSoftInputMode(
                WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
        alert.show();
    }

    /**
     * Stops running progress-bar
     */
    public void closeProgressDialog() {

        if (pdialog != null) {
            pdialog.dismiss();
            pdialog = null;
        }
    }

    /**
     * Shows progress-bar
     * 
     * @param resID
     * @param act
     */
    public void showProgressDialog(int resID, Context ctx) {
        String message = ctx.getString(resID);
        pdialog = ProgressDialog.show(ctx, null, message, true, true);
        pdialog.setCancelable(false);

    }

    /**
     * 
     * @param activityContext
     * @param msg
     * @param btnNameResId
     */
    public static void showAuthenticationErrorDialog(
            final Activity activityContext, String msg, int btnNameResId) {
        AlertDialog.Builder builder = new AlertDialog.Builder(activityContext);
        builder.setTitle(R.string.title_error).setMessage(msg)
                .setPositiveButton(btnNameResId, new OnClickListener() {

                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        activityContext.finish();

                    }
                });
        AlertDialog alert = builder.create();
        alert.getWindow().setSoftInputMode(
                WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
        alert.show();
    }

}




Java Source Code List

com.philips.lighting.data.AccessPointListAdapter.java
com.philips.lighting.data.HueSharedPreferences.java
com.philips.lighting.quickstart.CircularArrayList.java
com.philips.lighting.quickstart.MyApplicationActivity.java
com.philips.lighting.quickstart.PHHomeActivity.java
com.philips.lighting.quickstart.PHPushlinkActivity.java
com.philips.lighting.quickstart.PHWizardAlertDialog.java