Example usage for android.app Dialog Dialog

List of usage examples for android.app Dialog Dialog

Introduction

In this page you can find the example usage for android.app Dialog Dialog.

Prototype

public Dialog(@NonNull Context context, @StyleRes int themeResId) 

Source Link

Document

Creates a dialog window that uses a custom dialog style.

Usage

From source file:com.xplink.android.carchecklist.CarCheckListActivity.java

private void SlidePowerLayout() {

    DisplayMetrics metrics = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(metrics);

    float height = metrics.heightPixels;
    float width = metrics.widthPixels;

    int left500 = (int) ((width / 100) * 39);
    int top200 = (int) ((width / 100) * 15.7);

    final SharedPreferences settings = getSharedPreferences("mysettings", 0);
    final SharedPreferences.Editor editor = settings.edit();
    final Dialog powerdialog = new Dialog(CarCheckListActivity.this, R.style.backgrounddialog);
    powerdialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    powerdialog.setContentView(R.layout.powerdialoglayout);
    powerdialog.getWindow().getAttributes().windowAnimations = R.style.PowerDialogAnimation;
    powerdialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
    // make everything around Dialog brightness than default
    WindowManager.LayoutParams lp = powerdialog.getWindow().getAttributes();
    lp.dimAmount = 0f;//  w  w w. j  a va2  s . c  o  m

    final CheckBox chkpower_headLight = (CheckBox) powerdialog.getWindow().findViewById(R.id.power_headLight);
    final CheckBox chkpower_dim = (CheckBox) powerdialog.getWindow().findViewById(R.id.power_dim);
    final CheckBox chkpower_highBeam = (CheckBox) powerdialog.getWindow().findViewById(R.id.power_highBeam);
    final CheckBox chkpower_dashBoardLight = (CheckBox) powerdialog.getWindow()
            .findViewById(R.id.power_dashBoardLight);
    final CheckBox chkpower_cabinSeatLight = (CheckBox) powerdialog.getWindow()
            .findViewById(R.id.power_cabinSeatLight);
    final CheckBox chkpower_sideDoorLight = (CheckBox) powerdialog.getWindow()
            .findViewById(R.id.power_sideDoorLight);
    final CheckBox chkpower_turnSignal = (CheckBox) powerdialog.getWindow().findViewById(R.id.power_turnSignal);
    final CheckBox chkpower_air = (CheckBox) powerdialog.getWindow().findViewById(R.id.power_air);
    final CheckBox chkpower_thermometer = (CheckBox) powerdialog.getWindow()
            .findViewById(R.id.power_thermometer);
    final CheckBox chkpower_horn = (CheckBox) powerdialog.getWindow().findViewById(R.id.power_horn);
    final CheckBox chkpower_wipe = (CheckBox) powerdialog.getWindow().findViewById(R.id.power_wipe);
    final CheckBox chkpower_rainSensor = (CheckBox) powerdialog.getWindow().findViewById(R.id.power_rainSensor);
    final CheckBox chkpower_thirdBrakeLight = (CheckBox) powerdialog.getWindow()
            .findViewById(R.id.power_thirdBrakeLight);
    final CheckBox chkpower_antiFoggyBack = (CheckBox) powerdialog.getWindow()
            .findViewById(R.id.power_antiFoggyBack);
    final CheckBox chkpower_antiFoggySide = (CheckBox) powerdialog.getWindow()
            .findViewById(R.id.power_antiFoggySide);
    final CheckBox chkpower_steeringWheelTest = (CheckBox) powerdialog.getWindow()
            .findViewById(R.id.power_steeringWheelTest);
    final CheckBox chkpower_steeringWheelSet = (CheckBox) powerdialog.getWindow()
            .findViewById(R.id.power_steeringWheelSet);
    final CheckBox chkpower_carStereo = (CheckBox) powerdialog.getWindow().findViewById(R.id.power_carStereo);
    final CheckBox chkpower_electronicWindow = (CheckBox) powerdialog.getWindow()
            .findViewById(R.id.power_electronicWindow);
    final CheckBox chkpower_sideMirror = (CheckBox) powerdialog.getWindow().findViewById(R.id.power_sideMirror);
    final CheckBox chkpower_warnDoor = (CheckBox) powerdialog.getWindow().findViewById(R.id.power_warnDoor);
    final CheckBox chkpower_warnSeatBelt = (CheckBox) powerdialog.getWindow()
            .findViewById(R.id.power_warnSeatBelt);
    final CheckBox chkpower_warnHandBrake = (CheckBox) powerdialog.getWindow()
            .findViewById(R.id.power_warnHandBrake);
    final CheckBox chkpower_clock = (CheckBox) powerdialog.getWindow().findViewById(R.id.power_clock);
    final CheckBox chkpower_remoteKey = (CheckBox) powerdialog.getWindow().findViewById(R.id.power_remoteKey);
    final CheckBox chkpower_centralLock = (CheckBox) powerdialog.getWindow()
            .findViewById(R.id.power_centralLock);
    final CheckBox chkpower_transmissionPosition = (CheckBox) powerdialog.getWindow()
            .findViewById(R.id.power_transmissionPosition);

    // change font
    chkpower_headLight.setTypeface(type);
    chkpower_dim.setTypeface(type);
    chkpower_highBeam.setTypeface(type);
    chkpower_dashBoardLight.setTypeface(type);
    chkpower_cabinSeatLight.setTypeface(type);
    chkpower_sideDoorLight.setTypeface(type);
    chkpower_turnSignal.setTypeface(type);
    chkpower_air.setTypeface(type);
    chkpower_thermometer.setTypeface(type);
    chkpower_horn.setTypeface(type);
    chkpower_wipe.setTypeface(type);
    chkpower_rainSensor.setTypeface(type);
    chkpower_thirdBrakeLight.setTypeface(type);
    chkpower_antiFoggyBack.setTypeface(type);
    chkpower_antiFoggySide.setTypeface(type);
    chkpower_steeringWheelTest.setTypeface(type);
    chkpower_steeringWheelSet.setTypeface(type);
    chkpower_carStereo.setTypeface(type);
    chkpower_electronicWindow.setTypeface(type);
    chkpower_sideMirror.setTypeface(type);
    chkpower_warnDoor.setTypeface(type);
    chkpower_warnSeatBelt.setTypeface(type);
    chkpower_warnHandBrake.setTypeface(type);
    chkpower_clock.setTypeface(type);
    chkpower_remoteKey.setTypeface(type);
    chkpower_centralLock.setTypeface(type);
    chkpower_transmissionPosition.setTypeface(type);

    powerdialog.setCanceledOnTouchOutside(true);
    powerdialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
        @Override
        public void onCancel(DialogInterface dialog) {
            headpower.setVisibility(ImageView.VISIBLE);
            TranslateAnimation slideoutheadpower = new TranslateAnimation(0, 0, 200, 800);
            slideoutheadpower.setDuration(500);
            slideoutheadpower.setFillAfter(true);
            headpower.startAnimation(slideoutheadpower);

            Map<String, Boolean> mp = new HashMap<String, Boolean>();

            mp.put("power_headLight", chkpower_headLight.isChecked());
            mp.put("power_dim", chkpower_dim.isChecked());
            mp.put("power_highBeam", chkpower_highBeam.isChecked());
            mp.put("power_dashBoardLight", chkpower_dashBoardLight.isChecked());
            mp.put("power_cabinSeatLight", chkpower_cabinSeatLight.isChecked());
            mp.put("power_sideDoorLight", chkpower_sideDoorLight.isChecked());
            mp.put("power_turnSignal", chkpower_turnSignal.isChecked());
            mp.put("power_air", chkpower_air.isChecked());
            mp.put("power_thermometer", chkpower_thermometer.isChecked());
            mp.put("power_horn", chkpower_horn.isChecked());
            mp.put("power_wipe", chkpower_wipe.isChecked());
            mp.put("power_rainSensor", chkpower_rainSensor.isChecked());
            mp.put("power_thirdBrakeLight", chkpower_thirdBrakeLight.isChecked());
            mp.put("power_antiFoggyBack", chkpower_antiFoggyBack.isChecked());
            mp.put("power_antiFoggySide", chkpower_antiFoggySide.isChecked());
            mp.put("power_steeringWheelTest", chkpower_steeringWheelTest.isChecked());
            mp.put("power_steeringWheelSet", chkpower_steeringWheelSet.isChecked());
            mp.put("power_carStereo", chkpower_carStereo.isChecked());
            mp.put("power_electronicWindow", chkpower_electronicWindow.isChecked());
            mp.put("power_sideMirror", chkpower_sideMirror.isChecked());
            mp.put("power_warnDoor", chkpower_warnDoor.isChecked());
            mp.put("power_warnSeatBelt", chkpower_warnSeatBelt.isChecked());
            mp.put("power_warnHandBrake", chkpower_warnHandBrake.isChecked());
            mp.put("power_clock", chkpower_clock.isChecked());
            mp.put("power_remoteKey", chkpower_remoteKey.isChecked());
            mp.put("power_centralLock", chkpower_centralLock.isChecked());
            mp.put("power_transmissionPosition", chkpower_transmissionPosition.isChecked());

            filterStore("power", mp);
            save(mp);

        }
    });

    TextView power = (TextView) powerdialog.getWindow().findViewById(R.id.Power);
    power.setTypeface(type);
    Button powerback = (Button) powerdialog.getWindow().findViewById(R.id.Powerback);
    powerback.setTypeface(type);
    powerback.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {

            powerdialog.dismiss();

            headpower.setVisibility(ImageView.VISIBLE);
            TranslateAnimation slideoutheadpower = new TranslateAnimation(0, 0, 200, 800);
            slideoutheadpower.setDuration(500);
            slideoutheadpower.setFillAfter(true);
            headpower.startAnimation(slideoutheadpower);

            Map<String, Boolean> mp = new HashMap<String, Boolean>();

            mp.put("power_headLight", chkpower_headLight.isChecked());
            mp.put("power_dim", chkpower_dim.isChecked());
            mp.put("power_highBeam", chkpower_highBeam.isChecked());
            mp.put("power_dashBoardLight", chkpower_dashBoardLight.isChecked());
            mp.put("power_cabinSeatLight", chkpower_cabinSeatLight.isChecked());
            mp.put("power_sideDoorLight", chkpower_sideDoorLight.isChecked());
            mp.put("power_turnSignal", chkpower_turnSignal.isChecked());
            mp.put("power_air", chkpower_air.isChecked());
            mp.put("power_thermometer", chkpower_thermometer.isChecked());
            mp.put("power_horn", chkpower_horn.isChecked());
            mp.put("power_wipe", chkpower_wipe.isChecked());
            mp.put("power_rainSensor", chkpower_rainSensor.isChecked());
            mp.put("power_thirdBrakeLight", chkpower_thirdBrakeLight.isChecked());
            mp.put("power_antiFoggyBack", chkpower_antiFoggyBack.isChecked());
            mp.put("power_antiFoggySide", chkpower_antiFoggySide.isChecked());
            mp.put("power_steeringWheelTest", chkpower_steeringWheelTest.isChecked());
            mp.put("power_steeringWheelSet", chkpower_steeringWheelSet.isChecked());
            mp.put("power_carStereo", chkpower_carStereo.isChecked());
            mp.put("power_electronicWindow", chkpower_electronicWindow.isChecked());
            mp.put("power_sideMirror", chkpower_sideMirror.isChecked());
            mp.put("power_warnDoor", chkpower_warnDoor.isChecked());
            mp.put("power_warnSeatBelt", chkpower_warnSeatBelt.isChecked());
            mp.put("power_warnHandBrake", chkpower_warnHandBrake.isChecked());
            mp.put("power_clock", chkpower_clock.isChecked());
            mp.put("power_remoteKey", chkpower_remoteKey.isChecked());
            mp.put("power_centralLock", chkpower_centralLock.isChecked());
            mp.put("power_transmissionPosition", chkpower_transmissionPosition.isChecked());

            filterStore("power", mp);
            save(mp);

        }
    });

    chkpower_headLight.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            boolean increment = true;
            if (((CheckBox) v).isChecked()) {
                getTotalPower(increment);
            } else {
                increment = false;
                getTotalPower(increment);
            }
            PowerProgress.setProgress(PercenPower);
            percenpower.setText("" + PercenPower + "%");
            RatioProgress.setProgress(PercenRatio);
            Ratiotext.setText("Rating of the Vehicle.   " + PercenRatio + "  %");
            CheckRatio();
        }
    });

    chkpower_dim.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            boolean increment = true;
            if (((CheckBox) v).isChecked()) {
                getTotalPower(increment);
            } else {
                increment = false;
                getTotalPower(increment);
            }
            PowerProgress.setProgress(PercenPower);
            percenpower.setText("" + PercenPower + "%");
            RatioProgress.setProgress(PercenRatio);
            Ratiotext.setText("Rating of the Vehicle.   " + PercenRatio + "  %");
            CheckRatio();
        }
    });

    chkpower_highBeam.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            boolean increment = true;
            if (((CheckBox) v).isChecked()) {
                getTotalPower(increment);
            } else {
                increment = false;
                getTotalPower(increment);
            }
            PowerProgress.setProgress(PercenPower);
            percenpower.setText("" + PercenPower + "%");
            RatioProgress.setProgress(PercenRatio);
            Ratiotext.setText("Rating of the Vehicle.   " + PercenRatio + "  %");
            CheckRatio();
        }
    });

    chkpower_dashBoardLight.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            boolean increment = true;
            if (((CheckBox) v).isChecked()) {
                getTotalPower(increment);
            } else {
                increment = false;
                getTotalPower(increment);
            }
            PowerProgress.setProgress(PercenPower);
            percenpower.setText("" + PercenPower + "%");
            RatioProgress.setProgress(PercenRatio);
            Ratiotext.setText("Rating of the Vehicle.   " + PercenRatio + "  %");
            CheckRatio();
        }
    });

    chkpower_cabinSeatLight.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            boolean increment = true;
            if (((CheckBox) v).isChecked()) {
                getTotalPower(increment);
            } else {
                increment = false;
                getTotalPower(increment);
            }
            PowerProgress.setProgress(PercenPower);
            percenpower.setText("" + PercenPower + "%");
            RatioProgress.setProgress(PercenRatio);
            Ratiotext.setText("Rating of the Vehicle.   " + PercenRatio + "  %");
            CheckRatio();
        }
    });

    chkpower_sideDoorLight.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            boolean increment = true;
            if (((CheckBox) v).isChecked()) {
                getTotalPower(increment);
            } else {
                increment = false;
                getTotalPower(increment);
            }
            PowerProgress.setProgress(PercenPower);
            percenpower.setText("" + PercenPower + "%");
            RatioProgress.setProgress(PercenRatio);
            Ratiotext.setText("Rating of the Vehicle.   " + PercenRatio + "  %");
            CheckRatio();
        }
    });

    chkpower_turnSignal.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            boolean increment = true;
            if (((CheckBox) v).isChecked()) {
                getTotalPower(increment);
            } else {
                increment = false;
                getTotalPower(increment);
            }
            PowerProgress.setProgress(PercenPower);
            percenpower.setText("" + PercenPower + "%");
            RatioProgress.setProgress(PercenRatio);
            Ratiotext.setText("Rating of the Vehicle.   " + PercenRatio + "  %");
            CheckRatio();
        }
    });

    chkpower_air.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            boolean increment = true;
            if (((CheckBox) v).isChecked()) {
                getTotalPower(increment);
            } else {
                increment = false;
                getTotalPower(increment);
            }
            PowerProgress.setProgress(PercenPower);
            percenpower.setText("" + PercenPower + "%");
            RatioProgress.setProgress(PercenRatio);
            Ratiotext.setText("Rating of the Vehicle.   " + PercenRatio + "  %");
            CheckRatio();
        }
    });

    chkpower_thermometer.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            boolean increment = true;
            if (((CheckBox) v).isChecked()) {
                getTotalPower(increment);
            } else {
                increment = false;
                getTotalPower(increment);
            }
            PowerProgress.setProgress(PercenPower);
            percenpower.setText("" + PercenPower + "%");
            RatioProgress.setProgress(PercenRatio);
            Ratiotext.setText("Rating of the Vehicle.   " + PercenRatio + "  %");
            CheckRatio();
        }
    });

    chkpower_horn.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            boolean increment = true;
            if (((CheckBox) v).isChecked()) {
                getTotalPower(increment);
            } else {
                increment = false;
                getTotalPower(increment);
            }
            PowerProgress.setProgress(PercenPower);
            percenpower.setText("" + PercenPower + "%");
            RatioProgress.setProgress(PercenRatio);
            Ratiotext.setText("Rating of the Vehicle.   " + PercenRatio + "  %");
            CheckRatio();
        }
    });

    chkpower_wipe.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            boolean increment = true;
            if (((CheckBox) v).isChecked()) {
                getTotalPower(increment);
            } else {
                increment = false;
                getTotalPower(increment);
            }
            PowerProgress.setProgress(PercenPower);
            percenpower.setText("" + PercenPower + "%");
            RatioProgress.setProgress(PercenRatio);
            Ratiotext.setText("Rating of the Vehicle.   " + PercenRatio + "  %");
            CheckRatio();
        }
    });

    chkpower_rainSensor.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            boolean increment = true;
            if (((CheckBox) v).isChecked()) {
                getTotalPower(increment);
            } else {
                increment = false;
                getTotalPower(increment);
            }
            PowerProgress.setProgress(PercenPower);
            percenpower.setText("" + PercenPower + "%");
            RatioProgress.setProgress(PercenRatio);
            Ratiotext.setText("Rating of the Vehicle.   " + PercenRatio + "  %");
            CheckRatio();
        }
    });

    chkpower_thirdBrakeLight.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            boolean increment = true;
            if (((CheckBox) v).isChecked()) {
                getTotalPower(increment);
            } else {
                increment = false;
                getTotalPower(increment);
            }
            PowerProgress.setProgress(PercenPower);
            percenpower.setText("" + PercenPower + "%");
            RatioProgress.setProgress(PercenRatio);
            Ratiotext.setText("Rating of the Vehicle.   " + PercenRatio + "  %");
            CheckRatio();
        }
    });

    chkpower_antiFoggyBack.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            boolean increment = true;
            if (((CheckBox) v).isChecked()) {
                getTotalPower(increment);
            } else {
                increment = false;
                getTotalPower(increment);
            }
            PowerProgress.setProgress(PercenPower);
            percenpower.setText("" + PercenPower + "%");
            RatioProgress.setProgress(PercenRatio);
            Ratiotext.setText("Rating of the Vehicle.   " + PercenRatio + "  %");
            CheckRatio();
        }
    });

    chkpower_antiFoggySide.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            boolean increment = true;
            if (((CheckBox) v).isChecked()) {
                getTotalPower(increment);
            } else {
                increment = false;
                getTotalPower(increment);
            }
            PowerProgress.setProgress(PercenPower);
            percenpower.setText("" + PercenPower + "%");
            RatioProgress.setProgress(PercenRatio);
            Ratiotext.setText("Rating of the Vehicle.   " + PercenRatio + "  %");
            CheckRatio();
        }
    });

    chkpower_steeringWheelTest.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            boolean increment = true;
            if (((CheckBox) v).isChecked()) {
                getTotalPower(increment);
            } else {
                increment = false;
                getTotalPower(increment);
            }
            PowerProgress.setProgress(PercenPower);
            percenpower.setText("" + PercenPower + "%");
            RatioProgress.setProgress(PercenRatio);
            Ratiotext.setText("Rating of the Vehicle.   " + PercenRatio + "  %");
            CheckRatio();
        }
    });

    chkpower_steeringWheelSet.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            boolean increment = true;
            if (((CheckBox) v).isChecked()) {
                getTotalPower(increment);
            } else {
                increment = false;
                getTotalPower(increment);
            }
            PowerProgress.setProgress(PercenPower);
            percenpower.setText("" + PercenPower + "%");
            RatioProgress.setProgress(PercenRatio);
            Ratiotext.setText("Rating of the Vehicle.   " + PercenRatio + "  %");
            CheckRatio();
        }
    });

    chkpower_carStereo.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            boolean increment = true;
            if (((CheckBox) v).isChecked()) {
                getTotalPower(increment);
            } else {
                increment = false;
                getTotalPower(increment);
            }
            PowerProgress.setProgress(PercenPower);
            percenpower.setText("" + PercenPower + "%");
            RatioProgress.setProgress(PercenRatio);
            Ratiotext.setText("Rating of the Vehicle.   " + PercenRatio + "  %");
            CheckRatio();
        }
    });

    chkpower_electronicWindow.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            boolean increment = true;
            if (((CheckBox) v).isChecked()) {
                getTotalPower(increment);
            } else {
                increment = false;
                getTotalPower(increment);
            }
            PowerProgress.setProgress(PercenPower);
            percenpower.setText("" + PercenPower + "%");
            RatioProgress.setProgress(PercenRatio);
            Ratiotext.setText("Rating of the Vehicle.   " + PercenRatio + "  %");
            CheckRatio();
        }
    });

    chkpower_sideMirror.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            boolean increment = true;
            if (((CheckBox) v).isChecked()) {
                getTotalPower(increment);
            } else {
                increment = false;
                getTotalPower(increment);
            }
            PowerProgress.setProgress(PercenPower);
            percenpower.setText("" + PercenPower + "%");
            RatioProgress.setProgress(PercenRatio);
            Ratiotext.setText("Rating of the Vehicle.   " + PercenRatio + "  %");
            CheckRatio();
        }
    });

    chkpower_warnDoor.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            boolean increment = true;
            if (((CheckBox) v).isChecked()) {
                getTotalPower(increment);
            } else {
                increment = false;
                getTotalPower(increment);
            }
            PowerProgress.setProgress(PercenPower);
            percenpower.setText("" + PercenPower + "%");
            RatioProgress.setProgress(PercenRatio);
            Ratiotext.setText("Rating of the Vehicle.   " + PercenRatio + "  %");
            CheckRatio();
        }
    });

    chkpower_warnSeatBelt.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            boolean increment = true;
            if (((CheckBox) v).isChecked()) {
                getTotalPower(increment);
            } else {
                increment = false;
                getTotalPower(increment);
            }
            PowerProgress.setProgress(PercenPower);
            percenpower.setText("" + PercenPower + "%");
            RatioProgress.setProgress(PercenRatio);
            Ratiotext.setText("Rating of the Vehicle.   " + PercenRatio + "  %");
            CheckRatio();
        }
    });

    chkpower_warnHandBrake.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            boolean increment = true;
            if (((CheckBox) v).isChecked()) {
                getTotalPower(increment);
            } else {
                increment = false;
                getTotalPower(increment);
            }
            PowerProgress.setProgress(PercenPower);
            percenpower.setText("" + PercenPower + "%");
            RatioProgress.setProgress(PercenRatio);
            Ratiotext.setText("Rating of the Vehicle.   " + PercenRatio + "  %");
            CheckRatio();
        }
    });

    chkpower_clock.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            boolean increment = true;
            if (((CheckBox) v).isChecked()) {
                getTotalPower(increment);
            } else {
                increment = false;
                getTotalPower(increment);
            }
            PowerProgress.setProgress(PercenPower);
            percenpower.setText("" + PercenPower + "%");
            RatioProgress.setProgress(PercenRatio);
            Ratiotext.setText("Rating of the Vehicle.   " + PercenRatio + "  %");
            CheckRatio();
        }
    });

    chkpower_remoteKey.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            boolean increment = true;
            if (((CheckBox) v).isChecked()) {
                getTotalPower(increment);
            } else {
                increment = false;
                getTotalPower(increment);
            }
            PowerProgress.setProgress(PercenPower);
            percenpower.setText("" + PercenPower + "%");
            RatioProgress.setProgress(PercenRatio);
            Ratiotext.setText("Rating of the Vehicle.   " + PercenRatio + "  %");
            CheckRatio();
        }
    });

    chkpower_centralLock.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            boolean increment = true;
            if (((CheckBox) v).isChecked()) {
                getTotalPower(increment);
            } else {
                increment = false;
                getTotalPower(increment);
            }
            PowerProgress.setProgress(PercenPower);
            percenpower.setText("" + PercenPower + "%");
            RatioProgress.setProgress(PercenRatio);
            Ratiotext.setText("Rating of the Vehicle.   " + PercenRatio + "  %");
            CheckRatio();
        }
    });

    chkpower_transmissionPosition.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            boolean increment = true;
            if (((CheckBox) v).isChecked()) {
                getTotalPower(increment);
            } else {
                increment = false;
                getTotalPower(increment);
            }
            PowerProgress.setProgress(PercenPower);
            percenpower.setText("" + PercenPower + "%");
            RatioProgress.setProgress(PercenRatio);
            Ratiotext.setText("Rating of the Vehicle.   " + PercenRatio + "  %");
            CheckRatio();
        }
    });

    headpower.setVisibility(ImageView.VISIBLE);
    TranslateAnimation slideheadpower = new TranslateAnimation(0, 0, 800, 200);
    slideheadpower.setDuration(300);
    slideheadpower.setFillAfter(true);
    headpower.startAnimation(slideheadpower);

    powerdialog.show();
    WindowManager.LayoutParams params = powerdialog.getWindow().getAttributes();
    params.y = top200;
    params.x = left500;
    params.gravity = Gravity.TOP | Gravity.LEFT;
    powerdialog.getWindow().setAttributes(params);

    isSaveCheckBox();

    chkpower_headLight.setChecked(load("power_headLight"));
    chkpower_dim.setChecked(load("power_dim"));
    chkpower_highBeam.setChecked(load("power_highBeam"));
    chkpower_dashBoardLight.setChecked(load("power_dashBoardLight"));
    chkpower_cabinSeatLight.setChecked(load("power_cabinSeatLight"));
    chkpower_sideDoorLight.setChecked(load("power_sideDoorLight"));
    chkpower_turnSignal.setChecked(load("power_turnSignal"));
    chkpower_air.setChecked(load("power_air"));
    chkpower_thermometer.setChecked(load("power_thermometer"));
    chkpower_horn.setChecked(load("power_horn"));
    chkpower_wipe.setChecked(load("power_wipe"));
    chkpower_rainSensor.setChecked(load("power_rainSensor"));
    chkpower_thirdBrakeLight.setChecked(load("power_thirdBrakeLight"));
    chkpower_antiFoggyBack.setChecked(load("power_antiFoggyBack"));
    chkpower_antiFoggySide.setChecked(load("power_antiFoggySide"));
    chkpower_steeringWheelTest.setChecked(load("power_steeringWheelTest"));
    chkpower_steeringWheelSet.setChecked(load("power_steeringWheelSet"));
    chkpower_carStereo.setChecked(load("power_carStereo"));
    chkpower_electronicWindow.setChecked(load("power_electronicWindow"));
    chkpower_sideMirror.setChecked(load("power_sideMirror"));
    chkpower_warnDoor.setChecked(load("power_warnDoor"));
    chkpower_warnSeatBelt.setChecked(load("power_warnSeatBelt"));
    chkpower_warnHandBrake.setChecked(load("power_warnHandBrake"));
    chkpower_clock.setChecked(load("power_clock"));
    chkpower_remoteKey.setChecked(load("power_remoteKey"));
    chkpower_centralLock.setChecked(load("power_centralLock"));
    chkpower_transmissionPosition.setChecked(load("power_transmissionPosition"));

}

From source file:ab.util.AbDialogUtil.java

/**
 * progressDialog//from   ww  w  .  ja  v  a 2s. com
 * 
 * @param context
 * @param msg
 * @return
 */
public static Dialog createLoadingDialog(Context context, String msg) {
    LayoutInflater inflater = LayoutInflater.from(context);
    View v = inflater.inflate(R.layout.herily_alertex_dialog_custom_frame_layout, null);// view
    ProgressWheel spaceshipImage = (ProgressWheel) v.findViewById(R.id.customFrameLoadImg);
    spaceshipImage.stopSpinning();
    spaceshipImage.startSpinning();
    TextView tipTextView = (TextView) v.findViewById(R.id.customFrameMsg);// ??
    tipTextView.setText(msg);// ?
    Dialog loadingDialog = new Dialog(context, R.style.loading_dialog);// ?dialog
    loadingDialog.setCancelable(false);// ????
    loadingDialog.setContentView(v, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT,
            LinearLayout.LayoutParams.FILL_PARENT));// 
    return loadingDialog;
}

From source file:in.shick.diode.mail.InboxListActivity.java

@Override
protected Dialog onCreateDialog(int id) {
    Dialog dialog;//from  www.  ja  v a  2s .c o m
    ProgressDialog pdialog;
    switch (id) {
    case Constants.DIALOG_LOGIN:
        dialog = new LoginDialog(this, mSettings, true) {
            @Override
            public void onLoginChosen(String user, String password) {
                removeDialog(Constants.DIALOG_LOGIN);
                new MyLoginTask(user, password).execute();
            }
        };
        break;

    case Constants.DIALOG_REPLY:
        dialog = new Dialog(this, mSettings.getDialogTheme());
        dialog.setContentView(R.layout.compose_reply_dialog);
        final EditText replyBody = (EditText) dialog.findViewById(R.id.body);
        final Button replySaveButton = (Button) dialog.findViewById(R.id.reply_save_button);
        final Button replyCancelButton = (Button) dialog.findViewById(R.id.reply_cancel_button);
        replySaveButton.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                if (mReplyTargetName != null) {
                    new MessageReplyTask(mReplyTargetName).execute(replyBody.getText().toString());
                    removeDialog(Constants.DIALOG_REPLY);
                } else {
                    Common.showErrorToast("Error replying. Please try again.", Toast.LENGTH_SHORT,
                            InboxListActivity.this);
                }
            }
        });
        replyCancelButton.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                removeDialog(Constants.DIALOG_REPLY);
            }
        });
        break;
    // "Please wait"
    case Constants.DIALOG_LOGGING_IN:
        pdialog = new ProgressDialog(new ContextThemeWrapper(this, mSettings.getDialogTheme()));
        pdialog.setMessage("Logging in...");
        pdialog.setIndeterminate(true);
        pdialog.setCancelable(true);
        dialog = pdialog;
        break;
    case Constants.DIALOG_REPLYING:
        pdialog = new ProgressDialog(new ContextThemeWrapper(this, mSettings.getDialogTheme()));
        pdialog.setMessage("Sending reply...");
        pdialog.setIndeterminate(true);
        pdialog.setCancelable(true);
        dialog = pdialog;
        break;

    default:
        throw new IllegalArgumentException("Unexpected dialog id " + id);
    }
    return dialog;
}

From source file:com.andrewshu.android.reddit.mail.InboxListActivity.java

@Override
protected Dialog onCreateDialog(int id) {
    Dialog dialog;/*from www  . j  a  va  2 s.  c o m*/
    ProgressDialog pdialog;
    AlertDialog.Builder builder;
    LayoutInflater inflater;
    View layout; // used for inflated views for AlertDialog.Builder.setView()

    switch (id) {
    case Constants.DIALOG_LOGIN:
        dialog = new LoginDialog(this, mSettings, true) {
            @Override
            public void onLoginChosen(String user, String password) {
                removeDialog(Constants.DIALOG_LOGIN);
                new MyLoginTask(user, password).execute();
            }
        };
        break;

    case Constants.DIALOG_REPLY:
        dialog = new Dialog(this, mSettings.getDialogTheme());
        dialog.setContentView(R.layout.compose_reply_dialog);
        final EditText replyBody = (EditText) dialog.findViewById(R.id.body);
        final Button replySaveButton = (Button) dialog.findViewById(R.id.reply_save_button);
        final Button replyCancelButton = (Button) dialog.findViewById(R.id.reply_cancel_button);
        replySaveButton.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                if (mReplyTargetName != null) {
                    new MessageReplyTask(mReplyTargetName).execute(replyBody.getText().toString());
                    removeDialog(Constants.DIALOG_REPLY);
                } else {
                    Common.showErrorToast("Error replying. Please try again.", Toast.LENGTH_SHORT,
                            InboxListActivity.this);
                }
            }
        });
        replyCancelButton.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                removeDialog(Constants.DIALOG_REPLY);
            }
        });
        break;
    // "Please wait"
    case Constants.DIALOG_LOGGING_IN:
        pdialog = new ProgressDialog(new ContextThemeWrapper(this, mSettings.getDialogTheme()));
        pdialog.setMessage("Logging in...");
        pdialog.setIndeterminate(true);
        pdialog.setCancelable(true);
        dialog = pdialog;
        break;
    case Constants.DIALOG_REPLYING:
        pdialog = new ProgressDialog(new ContextThemeWrapper(this, mSettings.getDialogTheme()));
        pdialog.setMessage("Sending reply...");
        pdialog.setIndeterminate(true);
        pdialog.setCancelable(true);
        dialog = pdialog;
        break;

    default:
        throw new IllegalArgumentException("Unexpected dialog id " + id);
    }
    return dialog;
}

From source file:com.trukr.shipper.fragment.RequestStatus.java

public void cancelalertdialog(Context mContext, String Title, String Content, final int Status) {
    final Dialog dialog = new Dialog(mContext, R.style.Dialog);
    dialog.setCancelable(false);/*  w  ww .ja va 2s  . c o m*/
    dialog.setContentView(R.layout.custom_alertdialog);

    // set the custom dialog components - title and content
    TextView alertHead = (TextView) dialog.findViewById(R.id.custom_alertdialog_tv_alerthead);
    alertHead.setText(Title);
    TextView alertContent = (TextView) dialog.findViewById(R.id.custom_alertdialog_tv_alertcontent);
    alertContent.setText(Content);

    View line = (View) dialog.findViewById(R.id.centerLineDialog);
    Button btnDialogCancel = (Button) dialog.findViewById(R.id.custom_alertdialog_btn_cancel);
    /* line.setVisibility(View.GONE);
    btnDialogCancel.setVisibility(View.GONE);*/
    Button btnDialogOk = (Button) dialog.findViewById(R.id.custom_alertdialog_btn_ok);
    /* btnDialogOk.setBackgroundResource(R.drawable.dialogbtnbackground);*/

    // if button is clicked, close the custom dialog
    btnDialogOk.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            dialog.dismiss();
            cancelJob();
        }
    });
    btnDialogCancel.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            dialog.dismiss();
        }
    });
    dialog.show();
}

From source file:com.trukr.shipper.fragment.RequestStatus.java

public void contactalertDialog(final Context ctx, String Title, String Content) {
    final Dialog dialog = new Dialog(ctx, R.style.Dialog);
    dialog.setCancelable(false);//from w ww .  j av a2  s  . c o  m
    dialog.setContentView(R.layout.contactalertdialog);
    TextView alertHead = (TextView) dialog.findViewById(R.id.tv_alerthead);
    alertHead.setText(Title);
    TextView alertContent = (TextView) dialog.findViewById(R.id.tv_alertcontent);
    alertContent.setText(Content);
    Button btnDialogOk = (Button) dialog.findViewById(R.id.btn_text);
    Button btnDialogCancel = (Button) dialog.findViewById(R.id.btn_call);
    // if button is clicked, close the custom dialog
    btnDialogOk.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent smsIntent = new Intent(android.content.Intent.ACTION_VIEW);
            smsIntent.setData(Uri.parse("sms:" + driverContactValue.toString()));
            startActivity(smsIntent);
            dialog.dismiss();
        }

    });

    btnDialogCancel.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Uri phoneCall = Uri.parse("tel:" + driverContactValue.toString());
            Intent caller = new Intent(Intent.ACTION_DIAL, phoneCall);
            startActivity(caller);
        }
    });
    dialog.show();
}

From source file:com.trukr.shipper.fragment.RequestStatus.java

public void cancelAlertDialog(Context mContext, String Title, String Content, final int Status) {
    final Dialog dialog = new Dialog(mContext, R.style.Dialog);
    dialog.setCancelable(false);//  w  w  w .j  a va2 s . c o m
    dialog.setContentView(R.layout.custom_alertdialog);

    // set the custom dialog components - title and content
    TextView alertHead = (TextView) dialog.findViewById(R.id.custom_alertdialog_tv_alerthead);
    alertHead.setText(Title);
    TextView alertContent = (TextView) dialog.findViewById(R.id.custom_alertdialog_tv_alertcontent);
    alertContent.setText(Content);

    View line = (View) dialog.findViewById(R.id.centerLineDialog);
    Button btnDialogCancel = (Button) dialog.findViewById(R.id.custom_alertdialog_btn_cancel);
    line.setVisibility(View.GONE);
    btnDialogCancel.setVisibility(View.GONE);
    Button btnDialogOk = (Button) dialog.findViewById(R.id.custom_alertdialog_btn_ok);
    btnDialogOk.setBackgroundResource(R.drawable.dialogbtnbackground);

    // if button is clicked, close the custom dialog
    btnDialogOk.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (Status == 100) {
                dialog.dismiss();
            } else
                dialog.dismiss();
        }
    });
    dialog.show();
}

From source file:com.dsdar.thosearoundme.TeamViewActivity.java

@Override
public boolean onMarkerClick(final Marker theMarker) {
    if (theMarker.equals(MyAppConstants.myMarker)) {
        return false;
    }//from  ww w  .java2s. com

    // Normal Marker
    if (!theMarker.equals(MyAppConstants.myMarker) && (theMarker.getTitle() != null)) {

        final Dialog aMemberDialog = new Dialog(TeamViewActivity.this, R.style.DialogSlideAnim);
        aMemberDialog.setContentView(R.layout.member_dialog);

        TextView aMemberTextName = (TextView) aMemberDialog.findViewById(R.id.tvMemberName);
        Button aTextButton = (Button) aMemberDialog.findViewById(R.id.bMemberText);
        Button aPushButton = (Button) aMemberDialog.findViewById(R.id.bMemberPush);
        Button aCallButton = (Button) aMemberDialog.findViewById(R.id.bMemberCall);
        Button aRemoveButton = (Button) aMemberDialog.findViewById(R.id.bMemberRemove);

        String[] res = theMarker.getTitle().split("~");
        String title = res[0];
        final String phone = res[1];

        aMemberTextName.setText("Say hello to " + title + "!");
        aMemberDialog.getWindow().setBackgroundDrawable(new ColorDrawable(0));
        aMemberDialog.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
        aMemberDialog.getWindow().setGravity(Gravity.BOTTOM);
        aMemberDialog.getWindow().setLayout(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
        aMemberDialog.show();
        ImageView aCancelButton = (ImageView) aMemberDialog.findViewById(R.id.bCancelMemberDialog);
        aCancelButton.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                aMemberDialog.dismiss();
            }
        });

        aTextButton.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                Uri sms_uri = Uri.parse("smsto:" + phone);
                Intent sms_intent = new Intent(Intent.ACTION_SENDTO, sms_uri);
                startActivity(sms_intent);
            }
        });

        // aPushButton.setOnClickListener(new OnClickListener() {
        // public void onClick(View v) {
        // // startActivity(new Intent(Intent.ACTION_VIEW,
        // // Uri.parse("sms:"
        // // + theMarker.getSnippet())));
        // }
        // });

        aCallButton.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                Intent callIntent = new Intent(Intent.ACTION_DIAL);
                callIntent.setData(Uri.parse("tel:" + phone));
                startActivity(callIntent);
            }
        });

        // aRemoveButton.setOnClickListener(new OnClickListener() {
        // public void onClick(View v) {
        // }
        // });
    } else {

        StickyMarkerBehaviorDialog dialog = new StickyMarkerBehaviorDialog(this);
        dialog.show();
    }

    return true;
}

From source file:com.haibison.android.anhuu.FragmentFiles.java

/**
 * Show a dialog for sorting options and resort file list after user
 * selected an option./*from w  w  w  . ja  v  a 2  s.c o m*/
 */
private void resortViewFiles() {
    final Dialog dialog = new Dialog(getActivity(),
            UI.resolveAttribute(getActivity(), R.attr.anhuu_f5be488d_theme_dialog));
    dialog.setCanceledOnTouchOutside(true);

    // get the index of button of current sort type
    int btnCurrentSortTypeIdx = 0;
    switch (Display.getSortType(getActivity())) {
    case BaseFile.SORT_BY_NAME:
        btnCurrentSortTypeIdx = 0;
        break;
    case BaseFile.SORT_BY_SIZE:
        btnCurrentSortTypeIdx = 2;
        break;
    case BaseFile.SORT_BY_MODIFICATION_TIME:
        btnCurrentSortTypeIdx = 4;
        break;
    }
    if (!Display.isSortAscending(getActivity()))
        btnCurrentSortTypeIdx++;

    View.OnClickListener listener = new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            dialog.dismiss();

            if (v.getId() == R.id.anhuu_f5be488d_button_sort_by_name_asc) {
                Display.setSortType(getActivity(), BaseFile.SORT_BY_NAME);
                Display.setSortAscending(getActivity(), true);
            } else if (v.getId() == R.id.anhuu_f5be488d_button_sort_by_name_desc) {
                Display.setSortType(getActivity(), BaseFile.SORT_BY_NAME);
                Display.setSortAscending(getActivity(), false);
            } else if (v.getId() == R.id.anhuu_f5be488d_button_sort_by_size_asc) {
                Display.setSortType(getActivity(), BaseFile.SORT_BY_SIZE);
                Display.setSortAscending(getActivity(), true);
            } else if (v.getId() == R.id.anhuu_f5be488d_button_sort_by_size_desc) {
                Display.setSortType(getActivity(), BaseFile.SORT_BY_SIZE);
                Display.setSortAscending(getActivity(), false);
            } else if (v.getId() == R.id.anhuu_f5be488d_button_sort_by_date_asc) {
                Display.setSortType(getActivity(), BaseFile.SORT_BY_MODIFICATION_TIME);
                Display.setSortAscending(getActivity(), true);
            } else if (v.getId() == R.id.anhuu_f5be488d_button_sort_by_date_desc) {
                Display.setSortType(getActivity(), BaseFile.SORT_BY_MODIFICATION_TIME);
                Display.setSortAscending(getActivity(), false);
            }

            /*
             * Reload current location.
             */
            goTo(getCurrentLocation());
            getActivity().supportInvalidateOptionsMenu();
        }// onClick()
    };// listener

    View view = getLayoutInflater(null).inflate(R.layout.anhuu_f5be488d_settings_sort_view, null);
    for (int i = 0; i < BUTTON_SORT_IDS.length; i++) {
        View v = view.findViewById(BUTTON_SORT_IDS[i]);
        v.setOnClickListener(listener);
        if (i == btnCurrentSortTypeIdx) {
            v.setEnabled(false);
            if (v instanceof Button)
                ((Button) v).setText(R.string.anhuu_f5be488d_bullet);
        }
    }

    dialog.setTitle(R.string.anhuu_f5be488d_title_sort_by);
    dialog.setContentView(view);
    dialog.show();
}

From source file:com.instiwork.RegistrationFacebookActivity.java

public void dialogTermsUse() {
    View view = LayoutInflater.from(getApplicationContext()).inflate(R.layout.dialog_terms_use, null);
    mBottomSheetDialogTermsUse = new Dialog(RegistrationFacebookActivity.this, R.style.MaterialDialogSheet);
    mBottomSheetDialogTermsUse.setContentView(view);
    mBottomSheetDialogTermsUse.setCancelable(false);
    mBottomSheetDialogTermsUse.getWindow().setLayout(LinearLayout.LayoutParams.MATCH_PARENT,
            LinearLayout.LayoutParams.MATCH_PARENT);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        mBottomSheetDialogTermsUse.getWindow()
                .addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        mBottomSheetDialogTermsUse.getWindow().setStatusBarColor(Color.parseColor("#536942"));
    }/*from www  .j  a  v  a  2 s .com*/
    mBottomSheetDialogTermsUse.getWindow().setGravity(Gravity.BOTTOM);
    mBottomSheetDialogTermsUse.show();

    view.findViewById(R.id.back_me_dlog_payment).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            mBottomSheetDialogTermsUse.dismiss();
        }
    });

    pBarTermsUse = (ProgressBar) view.findViewById(R.id.pbar_terms_use);
    //        txtTermsUse = (RobotoLight) view.findViewById(R.id.txt_terms_use);

    webViewTermsUse = (WebView) view.findViewById(R.id.webv);
    webViewTermsUse.getSettings().setJavaScriptEnabled(true);
    webViewTermsUse.setVisibility(View.GONE);

    getTermsUse(InstiworkConstants.URL_DOMAIN + "Privacy_control");

    mBottomSheetDialogTermsUse.setOnKeyListener(new DialogInterface.OnKeyListener() {

        @Override
        public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
            if (event.getAction() == KeyEvent.ACTION_DOWN)
                if ((keyCode == KeyEvent.KEYCODE_BACK)) {
                    mBottomSheetDialogTermsUse.dismiss();
                    return true;
                }
            return false;
        }
    });
}