Example usage for android.app Dialog setContentView

List of usage examples for android.app Dialog setContentView

Introduction

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

Prototype

public void setContentView(@NonNull View view) 

Source Link

Document

Set the screen content to an explicit view.

Usage

From source file:com.sentaroh.android.SMBSync2.SyncTaskUtility.java

public void setRemoteDir(final String remurl, final String curdir, final String p_dir,
        final NotifyEvent p_ntfy) {
    final ArrayList<TreeFilelistItem> rows = new ArrayList<TreeFilelistItem>();

    NotifyEvent ntfy = new NotifyEvent(mContext);
    // set thread response 
    ntfy.setListener(new NotifyEventListener() {
        @Override//w  w  w . j av a2 s  .com
        public void positiveResponse(Context c, Object[] o) {
            @SuppressWarnings("unchecked")
            ArrayList<TreeFilelistItem> rfl = (ArrayList<TreeFilelistItem>) o[0];
            for (int i = 0; i < rfl.size(); i++) {
                if (rfl.get(i).isDir() && rfl.get(i).canRead())
                    rows.add(rfl.get(i));
            }
            Collections.sort(rows);
            if (rows.size() < 1)
                rows.add(new TreeFilelistItem(mContext.getString(R.string.msgs_dir_empty)));
            //??
            final Dialog dialog = new Dialog(mContext);
            dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
            dialog.setCanceledOnTouchOutside(false);
            dialog.setContentView(R.layout.item_select_list_dlg);

            LinearLayout ll_dlg_view = (LinearLayout) dialog.findViewById(R.id.item_select_list_dlg_view);
            ll_dlg_view.setBackgroundColor(mGp.themeColorList.dialog_msg_background_color);

            final LinearLayout title_view = (LinearLayout) dialog
                    .findViewById(R.id.item_select_list_dlg_title_view);
            final TextView title = (TextView) dialog.findViewById(R.id.item_select_list_dlg_title);
            final TextView subtitle = (TextView) dialog.findViewById(R.id.item_select_list_dlg_subtitle);
            title_view.setBackgroundColor(mGp.themeColorList.dialog_title_background_color);
            title.setTextColor(mGp.themeColorList.text_color_dialog_title);
            subtitle.setTextColor(mGp.themeColorList.text_color_dialog_title);

            title.setText(mContext.getString(R.string.msgs_select_remote_dir));
            subtitle.setText(mContext.getString(R.string.msgs_current_dir) + "/" + remurl);
            //             if (rows.size()<1) {
            //                TextView dlg_msg=(TextView)dialog.findViewById(R.id.item_select_list_dlg_msg);
            //                dlg_msg.setText(msgs_dir_empty);
            //                dlg_msg.setVisibility(TextView.VISIBLE);
            //             }
            final Button btn_ok = (Button) dialog.findViewById(R.id.item_select_list_dlg_ok_btn);
            //              if (rows.size()<=2) 
            //                 ((TextView)dialog.findViewById(R.id.item_select_list_dlg_spacer))
            //                 .setVisibility(TextView.VISIBLE);

            CommonDialog.setDlgBoxSizeLimit(dialog, true);

            final ListView lv = (ListView) dialog.findViewById(android.R.id.list);
            final TreeFilelistAdapter tfa = new TreeFilelistAdapter(mContext, true, false);
            //            tfa.setNotifyOnChange(true);
            tfa.setDataList(rows);
            lv.setAdapter(tfa);
            lv.setScrollingCacheEnabled(false);
            lv.setScrollbarFadingEnabled(false);
            lv.setFastScrollEnabled(true);

            if (p_dir.length() != 0)
                for (int i = 0; i < tfa.getDataItemCount(); i++) {
                    if (tfa.getDataItem(i).getName().equals(p_dir))
                        lv.setSelection(i);
                }

            lv.setOnItemClickListener(new OnItemClickListener() {
                public void onItemClick(AdapterView<?> items, View view, int idx, long id) {
                    // ????????
                    final int pos = tfa.getItem(idx);
                    final TreeFilelistItem tfi = tfa.getDataItem(pos);
                    if (tfi.getName().startsWith("---"))
                        return;
                    expandHideRemoteDirTree(remurl, pos, tfi, tfa);
                }
            });
            lv.setOnItemLongClickListener(new OnItemLongClickListener() {
                @Override
                public boolean onItemLongClick(AdapterView<?> arg0, View arg1, final int position, long arg3) {
                    final int t_pos = tfa.getItem(position);
                    if (tfa.getDataItem(t_pos).isChecked()) {
                        ccMenu.addMenuItem(mContext.getString(R.string.msgs_file_select_unselect_this_entry)
                                + " " + tfa.getDataItem(t_pos).getPath() + tfa.getDataItem(t_pos).getName())
                                .setOnClickListener(new CustomContextMenuOnClickListener() {
                                    @Override
                                    public void onClick(CharSequence menuTitle) {
                                        final TreeFilelistItem tfi = tfa.getDataItem(t_pos);
                                        if (tfi.getName().startsWith("---"))
                                            return;
                                        tfa.setDataItemIsUnselected(t_pos);
                                        btn_ok.setEnabled(false);
                                    }
                                });
                    } else {
                        ccMenu.addMenuItem(mContext.getString(R.string.msgs_file_select_select_this_entry) + " "
                                + tfa.getDataItem(t_pos).getPath() + tfa.getDataItem(t_pos).getName())
                                .setOnClickListener(new CustomContextMenuOnClickListener() {
                                    @Override
                                    public void onClick(CharSequence menuTitle) {
                                        final TreeFilelistItem tfi = tfa.getDataItem(t_pos);
                                        if (tfi.getName().startsWith("---"))
                                            return;
                                        tfa.setDataItemIsSelected(t_pos);
                                        btn_ok.setEnabled(true);
                                    }
                                });
                    }
                    ccMenu.createMenu();
                    return false;
                }
            });
            NotifyEvent ctv_ntfy = new NotifyEvent(mContext);
            // set file list thread response listener 
            ctv_ntfy.setListener(new NotifyEventListener() {
                @Override
                public void positiveResponse(Context c, Object[] o) {
                    if (o != null) {
                        int pos = (Integer) o[0];
                        if (tfa.getDataItem(pos).isChecked())
                            btn_ok.setEnabled(true);
                    }
                }

                @Override
                public void negativeResponse(Context c, Object[] o) {
                    btn_ok.setEnabled(false);
                    for (int i = 0; i < tfa.getDataItemCount(); i++) {
                        if (tfa.getDataItem(i).isChecked()) {
                            btn_ok.setEnabled(true);
                            break;
                        }
                    }
                }
            });
            tfa.setCbCheckListener(ctv_ntfy);

            //OK?
            btn_ok.setEnabled(false);
            btn_ok.setVisibility(Button.VISIBLE);
            btn_ok.setOnClickListener(new View.OnClickListener() {
                public void onClick(View v) {
                    String sel = "";
                    for (int i = 0; i < tfa.getCount(); i++) {
                        if (tfa.getDataItem(i).isChecked() && !tfa.getDataItem(i).getName()
                                .equals(mContext.getString(R.string.msgs_dir_empty))) {
                            if (tfa.getDataItem(i).getPath().length() == 1)
                                sel = tfa.getDataItem(i).getName();
                            else
                                sel = tfa.getDataItem(i).getPath().substring(1,
                                        tfa.getDataItem(i).getPath().length()) + tfa.getDataItem(i).getName();
                            break;
                        }
                    }
                    dialog.dismiss();
                    p_ntfy.notifyToListener(true, new Object[] { sel });
                }
            });
            //CANCEL?
            final Button btn_cancel = (Button) dialog.findViewById(R.id.item_select_list_dlg_cancel_btn);
            btn_cancel.setOnClickListener(new View.OnClickListener() {
                public void onClick(View v) {
                    dialog.dismiss();
                    p_ntfy.notifyToListener(false, null);
                }
            });
            // Cancel?
            dialog.setOnCancelListener(new Dialog.OnCancelListener() {
                @Override
                public void onCancel(DialogInterface arg0) {
                    btn_cancel.performClick();
                }
            });

            //             dialog.setOnKeyListener(new DialogOnKeyListener(context));
            //             dialog.setCancelable(false);
            dialog.show();
        }

        @Override
        public void negativeResponse(Context c, Object[] o) {
            p_ntfy.notifyToListener(false, o);
        }
    });
    createRemoteFileList(remurl, curdir, ntfy, true);
    return;
}

From source file:com.nttec.everychan.ui.presentation.BoardFragment.java

@SuppressLint("InlinedApi")
private void openGridGallery() {
    final int tnSize = resources.getDimensionPixelSize(R.dimen.post_thumbnail_size);

    class GridGalleryAdapter extends ArrayAdapter<Triple<AttachmentModel, String, String>>
            implements View.OnClickListener, AbsListView.OnScrollListener {
        private final GridView view;
        private boolean selectingMode = false;
        private boolean[] isSelected = null;
        private volatile boolean isBusy = false;

        public GridGalleryAdapter(GridView view, List<Triple<AttachmentModel, String, String>> list) {
            super(activity, 0, list);
            this.view = view;
            this.isSelected = new boolean[list.size()];
        }/*from   w w  w  .ja va 2 s . c om*/

        @Override
        public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
        }

        @Override
        public void onScrollStateChanged(AbsListView view, int scrollState) {
            if (scrollState == AbsListView.OnScrollListener.SCROLL_STATE_IDLE) {
                if (isBusy)
                    setNonBusy();
                isBusy = false;
            } else
                isBusy = true;
        }

        private void setNonBusy() {
            if (!downloadThumbnails())
                return;
            for (int i = 0; i < view.getChildCount(); ++i) {
                View v = view.getChildAt(i);
                Object tnTag = v.findViewById(R.id.post_thumbnail_image).getTag();
                if (tnTag == null || tnTag == Boolean.FALSE)
                    fill(view.getPositionForView(v), v, false);
            }
        }

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            if (convertView == null) {
                convertView = new FrameLayout(activity);
                convertView.setLayoutParams(new AbsListView.LayoutParams(tnSize, tnSize));
                ImageView tnImage = new ImageView(activity);
                tnImage.setLayoutParams(new FrameLayout.LayoutParams(tnSize, tnSize, Gravity.CENTER));
                tnImage.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
                tnImage.setId(R.id.post_thumbnail_image);
                ((FrameLayout) convertView).addView(tnImage);
            }
            convertView.setTag(getItem(position).getLeft());
            safeRegisterForContextMenu(convertView);
            convertView.setOnClickListener(this);
            fill(position, convertView, isBusy);
            if (isSelected[position]) {
                /*ImageView overlay = new ImageView(activity);
                overlay.setImageResource(android.R.drawable.checkbox_on_background);*/
                FrameLayout overlay = new FrameLayout(activity);
                overlay.setBackgroundColor(Color.argb(128, 0, 255, 0));
                if (((FrameLayout) convertView).getChildCount() < 2)
                    ((FrameLayout) convertView).addView(overlay);

            } else {
                if (((FrameLayout) convertView).getChildCount() > 1)
                    ((FrameLayout) convertView).removeViewAt(1);
            }
            return convertView;
        }

        private void safeRegisterForContextMenu(View view) {
            try {
                view.setOnCreateContextMenuListener(new View.OnCreateContextMenuListener() {
                    @Override
                    public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
                        if (presentationModel == null) {
                            Fragment currentFragment = MainApplication
                                    .getInstance().tabsSwitcher.currentFragment;
                            if (currentFragment instanceof BoardFragment) {
                                currentFragment.onCreateContextMenu(menu, v, menuInfo);
                            }
                        } else {
                            BoardFragment.this.onCreateContextMenu(menu, v, menuInfo);
                        }
                    }
                });
            } catch (Exception e) {
                Logger.e(TAG, e);
            }
        }

        @Override
        public void onClick(View v) {
            if (selectingMode) {
                int position = view.getPositionForView(v);
                isSelected[position] = !isSelected[position];
                notifyDataSetChanged();
            } else {
                BoardFragment fragment = BoardFragment.this;
                if (presentationModel == null) {
                    Fragment currentFragment = MainApplication.getInstance().tabsSwitcher.currentFragment;
                    if (currentFragment instanceof BoardFragment)
                        fragment = (BoardFragment) currentFragment;
                }
                fragment.openAttachment((AttachmentModel) v.getTag());
            }
        }

        private void fill(int position, View view, boolean isBusy) {
            AttachmentModel attachment = getItem(position).getLeft();
            String attachmentHash = getItem(position).getMiddle();
            ImageView tnImage = (ImageView) view.findViewById(R.id.post_thumbnail_image);
            if (attachment.thumbnail == null || attachment.thumbnail.length() == 0) {
                tnImage.setTag(Boolean.TRUE);
                tnImage.setImageResource(Attachments.getDefaultThumbnailResId(attachment.type));
                return;
            }
            tnImage.setTag(Boolean.FALSE);
            CancellableTask imagesDownloadTask = BoardFragment.this.imagesDownloadTask;
            ExecutorService imagesDownloadExecutor = BoardFragment.this.imagesDownloadExecutor;
            if (presentationModel == null) {
                Fragment currentFragment = MainApplication.getInstance().tabsSwitcher.currentFragment;
                if (currentFragment instanceof BoardFragment) {
                    imagesDownloadTask = ((BoardFragment) currentFragment).imagesDownloadTask;
                    imagesDownloadExecutor = ((BoardFragment) currentFragment).imagesDownloadExecutor;
                }
            }
            bitmapCache.asyncGet(attachmentHash, attachment.thumbnail, tnSize, chan, localFile,
                    imagesDownloadTask, tnImage, imagesDownloadExecutor, Async.UI_HANDLER,
                    downloadThumbnails() && !isBusy,
                    downloadThumbnails() ? (isBusy ? 0 : R.drawable.thumbnail_error)
                            : Attachments.getDefaultThumbnailResId(attachment.type));
        }

        public void setSelectingMode(boolean selectingMode) {
            this.selectingMode = selectingMode;
            if (!selectingMode) {
                Arrays.fill(isSelected, false);
                notifyDataSetChanged();
            }
        }

        public void selectAll() {
            if (selectingMode) {
                Arrays.fill(isSelected, true);
                notifyDataSetChanged();
            }
        }

        public void downloadSelected(final Runnable onFinish) {
            final Dialog progressDialog = ProgressDialog.show(activity,
                    resources.getString(R.string.grid_gallery_dlg_title),
                    resources.getString(R.string.grid_gallery_dlg_message), true, false);
            Async.runAsync(new Runnable() {
                @Override
                public void run() {
                    BoardFragment fragment = BoardFragment.this;
                    if (fragment.presentationModel == null) {
                        Fragment currentFragment = MainApplication.getInstance().tabsSwitcher.currentFragment;
                        if (currentFragment instanceof BoardFragment)
                            fragment = (BoardFragment) currentFragment;
                    }
                    boolean flag = false;
                    for (int i = 0; i < isSelected.length; ++i)
                        if (isSelected[i])
                            if (!fragment.downloadFile(getItem(i).getLeft(), true))
                                flag = true;
                    final boolean toast = flag;
                    activity.runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            if (toast)
                                Toast.makeText(activity, R.string.notification_download_exists_or_in_queue,
                                        Toast.LENGTH_LONG).show();
                            progressDialog.dismiss();
                            onFinish.run();
                        }
                    });
                }
            });
        }
    }

    try {
        List<Triple<AttachmentModel, String, String>> list = presentationModel.getAttachments();
        if (list == null) {
            Toast.makeText(activity, R.string.notifacation_updating_now, Toast.LENGTH_LONG).show();
            return;
        }

        GridView grid = new GridView(activity);
        final GridGalleryAdapter gridAdapter = new GridGalleryAdapter(grid, list);
        grid.setNumColumns(GridView.AUTO_FIT);
        grid.setColumnWidth(tnSize);
        int spacing = (int) (resources.getDisplayMetrics().density * 5 + 0.5f);
        grid.setVerticalSpacing(spacing);
        grid.setHorizontalSpacing(spacing);
        grid.setPadding(spacing, spacing, spacing, spacing);
        grid.setAdapter(gridAdapter);
        grid.setOnScrollListener(gridAdapter);
        grid.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 0, 1f));

        final Button btnToSelecting = new Button(activity);
        btnToSelecting.setText(R.string.grid_gallery_select);
        CompatibilityUtils.setTextAppearance(btnToSelecting, android.R.style.TextAppearance_Small);
        btnToSelecting.setSingleLine();
        btnToSelecting.setVisibility(View.VISIBLE);
        btnToSelecting.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
                LinearLayout.LayoutParams.WRAP_CONTENT));

        final LinearLayout layoutSelectingButtons = new LinearLayout(activity);
        layoutSelectingButtons.setOrientation(LinearLayout.HORIZONTAL);
        layoutSelectingButtons.setWeightSum(10f);
        Button btnDownload = new Button(activity);
        btnDownload.setLayoutParams(
                new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.WRAP_CONTENT, 3.25f));
        btnDownload.setText(R.string.grid_gallery_download);
        CompatibilityUtils.setTextAppearance(btnDownload, android.R.style.TextAppearance_Small);
        btnDownload.setSingleLine();
        Button btnSelectAll = new Button(activity);
        btnSelectAll.setLayoutParams(
                new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.WRAP_CONTENT, 3.75f));
        btnSelectAll.setText(android.R.string.selectAll);
        CompatibilityUtils.setTextAppearance(btnSelectAll, android.R.style.TextAppearance_Small);
        btnSelectAll.setSingleLine();
        Button btnCancel = new Button(activity);
        btnCancel.setLayoutParams(new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.WRAP_CONTENT, 3f));
        btnCancel.setText(android.R.string.cancel);
        CompatibilityUtils.setTextAppearance(btnCancel, android.R.style.TextAppearance_Small);
        btnCancel.setSingleLine();
        layoutSelectingButtons.addView(btnDownload);
        layoutSelectingButtons.addView(btnSelectAll);
        layoutSelectingButtons.addView(btnCancel);
        layoutSelectingButtons.setVisibility(View.GONE);
        layoutSelectingButtons.setLayoutParams(new LinearLayout.LayoutParams(
                LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT));

        btnToSelecting.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                btnToSelecting.setVisibility(View.GONE);
                layoutSelectingButtons.setVisibility(View.VISIBLE);
                gridAdapter.setSelectingMode(true);
            }
        });

        btnCancel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                btnToSelecting.setVisibility(View.VISIBLE);
                layoutSelectingButtons.setVisibility(View.GONE);
                gridAdapter.setSelectingMode(false);
            }
        });

        btnSelectAll.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                gridAdapter.selectAll();
            }
        });

        btnDownload.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                gridAdapter.downloadSelected(new Runnable() {
                    @Override
                    public void run() {
                        btnToSelecting.setVisibility(View.VISIBLE);
                        layoutSelectingButtons.setVisibility(View.GONE);
                        gridAdapter.setSelectingMode(false);
                    }
                });
            }
        });

        LinearLayout dlgLayout = new LinearLayout(activity);
        dlgLayout.setOrientation(LinearLayout.VERTICAL);
        dlgLayout.addView(btnToSelecting);
        dlgLayout.addView(layoutSelectingButtons);
        dlgLayout.addView(grid);

        Dialog gridDialog = new Dialog(activity);
        gridDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
        gridDialog.setContentView(dlgLayout);
        gridDialog.getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.WRAP_CONTENT);
        gridDialog.show();
    } catch (OutOfMemoryError oom) {
        MainApplication.freeMemory();
        Logger.e(TAG, oom);
        Toast.makeText(activity, R.string.error_out_of_memory, Toast.LENGTH_LONG).show();
    }
}

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;/*www.  ja v  a2s . 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:org.anurag.file.quest.TaskerActivity.java

/**
 * //from ww  w . jav a 2 s  .  com
 */
@Override
public void onItemClick(QuickAction source, int pos, int actionId) {
    CURRENT_ITEM = mViewPager.getCurrentItem();
    switch (actionId) {

    case -1:
        // THIS CASE DIAPLAYS AN ACTIVITY SHOWING THE
        // DEVELOPMENT STAGE OF THE APP

        break;

    case 1:
        // IF CURRENT ITEM IS 0 AND CATEGORIES ARE DIAPLAYED
        // THEN USER SELECTS FILTER BUTTON,IT SHOWS 7 OPTION
        // FIRST OPTION IS CASE 1
        //SEARCH_FLAG = true;
        load_FIle_Gallery(0);
        search();
        mVFlipper.showNext();
        mVFlipper.setAnimation(nextAnim());
        break;
    case 2:
        // IF CURRENT ITEM IS 0 AND CATEGORIES ARE DIAPLAYED
        // THEN USER SELECTS FILTER BUTTON,IT SHOWS 7 OPTION
        // SECOND OPTION IS CASE 2
        //SEARCH_FLAG = true;
        load_FIle_Gallery(1);
        search();
        mVFlipper.showNext();
        mVFlipper.setAnimation(nextAnim());
        break;
    case 3:
        // IF CURRENT ITEM IS 0 AND CATEGORIES ARE DIAPLAYED
        // THEN USER SELECTS FILTER BUTTON,IT SHOWS 7 OPTION
        // THIRT OPTION IS CASE 3
        //SEARCH_FLAG = true;
        load_FIle_Gallery(2);
        search();
        mVFlipper.showNext();
        mVFlipper.setAnimation(nextAnim());
        break;

    case 4:
        // IF CURRENT ITEM IS 0 AND CATEGORIES ARE DIAPLAYED
        // THEN USER SELECTS FILTER BUTTON,IT SHOWS 7 OPTION
        // Fourth OPTION IS CASE 4
        //SEARCH_FLAG = true;
        load_FIle_Gallery(3);
        search();
        mVFlipper.showNext();
        mVFlipper.setAnimation(nextAnim());
        break;

    case 5:
        // IF CURRENT ITEM IS 0 AND CATEGORIES ARE DIAPLAYED
        // THEN USER SELECTS FILTER BUTTON,IT SHOWS 7 OPTION
        // FIFTH OPTION IS CASE 5
        //SEARCH_FLAG = true;
        load_FIle_Gallery(4);
        search();
        mVFlipper.showNext();
        mVFlipper.setAnimation(nextAnim());
        break;

    case 6:
        // IF CURRENT ITEM IS 0 AND CATEGORIES ARE DIAPLAYED
        // THEN USER SELECTS FILTER BUTTON,IT SHOWS 7 OPTION
        // SIXTH OPTION IS CASE 6
        //SEARCH_FLAG = true;
        load_FIle_Gallery(5);
        search();
        mVFlipper.showNext();
        mVFlipper.setAnimation(nextAnim());
        break;

    case 7:
        // IF CURRENT ITEM IS 0 AND CATEGORIES ARE DIAPLAYED
        // THEN USER SELECTS FILTER BUTTON,IT SHOWS 7 OPTION
        // SEVENTH OPTION IS CASE 7
        //SEARCH_FLAG = true;
        load_FIle_Gallery(6);
        search();
        mVFlipper.showNext();
        mVFlipper.setAnimation(nextAnim());
        break;

    case 8:

        // IF CURRENT ITEM IS 0 AND USER SELECTS JUMP TO BUTTON
        // THEN SEVEN LOCATIONS ARE SHOWN
        // FIRST LOCATION IS CASE 8
        load_FIle_Gallery(0);
        break;

    case 9:
        // IF CURRENT ITEM IS 0 AND USER SELECTS JUMP TO BUTTON
        // THEN SEVEN LOCATIONS ARE SHOWN
        // SECOND LOCATION IS CASE 9
        //loadMediaList(pos=1);
        //elementInFocus = true;
        //media.setAdapter(new MediaElementAdapter(getBaseContext(), R.layout.row_list_1, mediaFileList));
        load_FIle_Gallery(1);
        break;

    case 10:
        // IF CURRENT ITEM IS 0 AND USER SELECTS JUMP TO BUTTON
        // THEN SEVEN LOCATIONS ARE SHOWN
        // THIRD LOCATION IS CASE 10
        load_FIle_Gallery(2);
        break;

    case 11:
        // IF CURRENT ITEM IS 0 AND USER SELECTS JUMP TO BUTTON
        // THEN SEVEN LOCATIONS ARE SHOWN
        // FOURTH LOCATION IS CASE 11
        load_FIle_Gallery(3);
        break;

    case 12:
        // IF CURRENT ITEM IS 0 AND USER SELECTS JUMP TO BUTTON
        // THEN SEVEN LOCATIONS ARE SHOWN
        // FIFTH LOCATION IS CASE 12
        load_FIle_Gallery(4);
        break;

    case 13:
        // IF CURRENT ITEM IS 0 AND USER SELECTS JUMP TO BUTTON
        // THEN SEVEN LOCATIONS ARE SHOWN
        // SIXTH LOCATION IS CASE 13
        load_FIle_Gallery(5);
        break;

    case 14:
        // IF CURRENT ITEM IS 0 AND USER SELECTS JUMP TO BUTTON
        // THEN SEVEN LOCATIONS ARE SHOWN
        // SEVENTH LOCATION IS CASE 14
        load_FIle_Gallery(6);
        break;

    case 80:
        // SHOWING THE OPTIONS AVAILABLE FOR CHANGING APPREANCE
        QuickAction q = new QuickAction(getBaseContext());
        ActionItem q1 = new ActionItem(100, "  Adjust Transparency",
                getResources().getDrawable(R.drawable.ic_launcher_appreance));
        q.addActionItem(q1);
        if (CURRENT_ITEM != 3) {
            q1 = new ActionItem(90, "  Set Folder Icon",
                    getResources().getDrawable(R.drawable.ic_launcher_folder_violet));
            q.addActionItem(q1);
        }
        q.setOnActionItemClickListener(this);
        q.show(indicator);
        break;

    case 90:
        //DIRECTED FROM CASE 80
        // DISPLAYS THE OPTIONS AVAILABLE FOR CHANGING FOLDER ICON TO SHOW
        int FOLDER_TYPE = RootAdapter.FOLDER_TYPE;
        QuickAction ac = new QuickAction(getBaseContext());
        ActionItem it;

        if (FOLDER_TYPE == 0)
            it = new ActionItem(2800, "  Window Style Folder",
                    getResources().getDrawable(R.drawable.ic_launcher_apply));
        else
            it = new ActionItem(2800, "  Window Style Folder",
                    getResources().getDrawable(R.drawable.ic_launcher_folder_orange));
        ac.addActionItem(it);

        if (FOLDER_TYPE == 1)
            it = new ActionItem(2900, "  Oxygen Violet Folder",
                    getResources().getDrawable(R.drawable.ic_launcher_apply));
        else
            it = new ActionItem(2900, "  Oxygen Violet Folder",
                    getResources().getDrawable(R.drawable.ic_launcher_folder_violet));
        ac.addActionItem(it);

        if (FOLDER_TYPE == 2)
            it = new ActionItem(3000, "  Oxygen Orange Folder",
                    getResources().getDrawable(R.drawable.ic_launcher_apply));
        else
            it = new ActionItem(3000, "  Oxygen Orange Folder",
                    getResources().getDrawable(R.drawable.ic_launcher_folder_oxygen));
        ac.addActionItem(it);

        if (FOLDER_TYPE == 3)
            it = new ActionItem(3100, "  Yellow Folder",
                    getResources().getDrawable(R.drawable.ic_launcher_apply));
        else
            it = new ActionItem(3100, "  Yellow Folder",
                    getResources().getDrawable(R.drawable.ic_launcher_folder_yellow));
        ac.addActionItem(it);

        if (FOLDER_TYPE == 4)
            it = new ActionItem(3101, "  Ubuntu Orange Folder",
                    getResources().getDrawable(R.drawable.ic_launcher_apply));
        else
            it = new ActionItem(3101, "  Ubuntu Orange Folder",
                    getResources().getDrawable(R.drawable.ic_launcher_folder_ubuntu));
        ac.addActionItem(it);

        if (FOLDER_TYPE == 5)
            it = new ActionItem(3102, "  Ubuntu Black Folder",
                    getResources().getDrawable(R.drawable.ic_launcher_apply));
        else
            it = new ActionItem(3102, "  Ubuntu Black Folder",
                    getResources().getDrawable(R.drawable.ic_launcher_folder_ubuntu_black));
        ac.addActionItem(it);

        if (FOLDER_TYPE == 6)
            it = new ActionItem(3103, "  Gnome Folder",
                    getResources().getDrawable(R.drawable.ic_launcher_apply));
        else
            it = new ActionItem(3103, "  Gnome Folder",
                    getResources().getDrawable(R.drawable.ic_launcher_folder_gnome));
        ac.addActionItem(it);

        ac.setOnActionItemClickListener(this);
        ac.show(indicator);
        break;
    case 100:
        // DIRECTED FROM CASE 80
        // SHOWING ALL THE TRANSPARENCY LEVEL AVAILABLE
        QuickAction d = new QuickAction(getBaseContext());
        ActionItem l;
        if (TRANS_LEVEL == 0.6f)
            l = new ActionItem(1700, "  60% Opaque", getResources().getDrawable(R.drawable.ic_launcher_apply));
        else
            l = new ActionItem(1700, "  60% Opaque",
                    getResources().getDrawable(R.drawable.ic_launcher_appreance));
        d.addActionItem(l);

        if (TRANS_LEVEL == 0.7f)
            l = new ActionItem(1800, "  70% Opaque", getResources().getDrawable(R.drawable.ic_launcher_apply));
        else
            l = new ActionItem(1800, "  70% Opaque",
                    getResources().getDrawable(R.drawable.ic_launcher_appreance));
        d.addActionItem(l);

        if (TRANS_LEVEL == 0.8f)
            l = new ActionItem(1900, "  80% Opaque", getResources().getDrawable(R.drawable.ic_launcher_apply));
        else
            l = new ActionItem(1900, "  80% Opaque",
                    getResources().getDrawable(R.drawable.ic_launcher_appreance));
        d.addActionItem(l);

        if (TRANS_LEVEL == 0.9f)
            l = new ActionItem(2000, "  90% Opaque", getResources().getDrawable(R.drawable.ic_launcher_apply));
        else
            l = new ActionItem(2000, "  90% Opaque",
                    getResources().getDrawable(R.drawable.ic_launcher_appreance));
        d.addActionItem(l);

        if (TRANS_LEVEL == 1.0f)
            l = new ActionItem(2100, "  100% Opaque", getResources().getDrawable(R.drawable.ic_launcher_apply));
        else
            l = new ActionItem(2100, "  100% Opaque",
                    getResources().getDrawable(R.drawable.ic_launcher_appreance));
        d.addActionItem(l);
        d.setOnActionItemClickListener(this);
        d.show(indicator);
        break;
    case 200:
        // DISPLAYS OPTIONS AVAILABLE IF USER SELECTS FOLDER OPTIONS
        QuickAction a = new QuickAction(getBaseContext());
        ActionItem i = new ActionItem(800, "Set Panel On Startup",
                getResources().getDrawable(R.drawable.ic_launcher_startup));
        a.addActionItem(i);
        if (mViewPager.getCurrentItem() != 3) {
            i = new ActionItem(900, "Set Directory On Startup",
                    getResources().getDrawable(R.drawable.ic_launcher_startup));
            a.addActionItem(i);
        }
        a.setOnActionItemClickListener(this);
        a.show(indicator);
        break;

    case 300:
        QuickAction b = new QuickAction(getBaseContext());
        ActionItem j;
        if (SHOW_HIDDEN_FOLDERS)
            j = new ActionItem(1000, "Show Hidden Folders",
                    getResources().getDrawable(R.drawable.ic_launcher_apply));
        else
            j = new ActionItem(1000, "Show Hidden Folders",
                    getResources().getDrawable(R.drawable.ic_launcher_disabled));
        b.addActionItem(j);
        j = new ActionItem(1100, "Sorting", getResources().getDrawable(R.drawable.ic_launcher_folder_orange));
        b.addActionItem(j);
        b.setOnActionItemClickListener(this);
        b.show(indicator);
        break;

    case 400:
        // LAUNCHES AN INTERFACE FOR SELECTING A DIRECTORY FOR HOME
        // WITH REQUEST CODE 400
        new GetHomeDirectory(mContext, size.x * 4 / 5, preferences);
        break;
    case 500:
        // RESETS APP SETTINGS TO DEFAULT
        edit.clear();
        edit.putString("INTERNAL_PATH_ONE", INTERNAL_PATH_ONE = PATH);
        edit.putString("INTERNAL_PATH_TWO", INTERNAL_PATH_TWO = PATH);
        edit.putInt("SHOW_APP", SHOW_APP = 1);
        edit.putInt("CURRENT_PREF_ITEM", CURRENT_PREF_ITEM = 2);
        edit.putFloat("TRANS_LEVEL", TRANS_LEVEL = 0.8f);
        edit.putBoolean("SHOW_HIDDEN_FOLDERS", SHOW_HIDDEN_FOLDERS = false);
        edit.putInt("SORT_TYPE", SORT_TYPE = 2);
        edit.putInt("FOLDER_TYPE", FOLDER_TYPE = 3);
        edit.putString("HOME_DIRECTORY", HOME_DIRECTORY = null);
        edit.putBoolean("ENABLE_ON_LAUNCH", ENABLE_ON_LAUNCH = false);
        edit.commit();

        // CLEARING THE DEFAULT SELECTED APPS 
        SharedPreferences pr = getSharedPreferences("DEFAULT_APPS", MODE_PRIVATE);
        SharedPreferences.Editor ed = pr.edit();
        ed.clear();
        ed.commit();
        Toast.makeText(getBaseContext(), "Restored To Default", Toast.LENGTH_SHORT).show();
        break;
    case 600:
        CURRENT_ITEM = mViewPager.getCurrentItem();
        setAdapter(CURRENT_ITEM);
        break;
    case 700: {
        Dialog as = new Dialog(mContext, R.style.custom_dialog_theme);
        as.setContentView(R.layout.info_layout);
        as.getWindow().getAttributes().width = size.x * 5 / 6;
        as.setCancelable(true);
        as.show();
    }
        break;
    case 800:
        // DIRECTED FROM CASE 200 
        // IT IS FIRST OPTION AVAILABLE UNDER STARTUP
        QuickAction e = new QuickAction(getBaseContext());
        ActionItem m;
        if (CURRENT_PREF_ITEM == 0)
            m = new ActionItem(2200, "File Gallery", getResources().getDrawable(R.drawable.ic_launcher_apply));
        else
            m = new ActionItem(2200, "File Gallery",
                    getResources().getDrawable(R.drawable.ic_launcher_startup));
        e.addActionItem(m);

        if (CURRENT_PREF_ITEM == 1)
            m = new ActionItem(2300, "/", getResources().getDrawable(R.drawable.ic_launcher_apply));
        else
            m = new ActionItem(2300, "/", getResources().getDrawable(R.drawable.ic_launcher_startup));
        e.addActionItem(m);
        if (CURRENT_PREF_ITEM == 2)
            m = new ActionItem(2400, "SD Card", getResources().getDrawable(R.drawable.ic_launcher_apply));
        else
            m = new ActionItem(2400, "SD Card", getResources().getDrawable(R.drawable.ic_launcher_startup));
        e.addActionItem(m);

        if (CURRENT_PREF_ITEM == 3)
            m = new ActionItem(2500, "Your App Store",
                    getResources().getDrawable(R.drawable.ic_launcher_apply));
        else
            m = new ActionItem(2500, "Your App Store",
                    getResources().getDrawable(R.drawable.ic_launcher_startup));
        e.addActionItem(m);
        e.setOnActionItemClickListener(this);
        e.show(indicator);
        break;
    case 900:
        // DIRECTED FROM CASE 200 
        // IT IS SECOND OPTION AVAILABLE UNDER STARTUP
        QuickAction f = new QuickAction(getBaseContext());
        ActionItem n = new ActionItem(2600, "/", getResources().getDrawable(R.drawable.ic_launcher_startup));
        f.addActionItem(n);
        n = new ActionItem(2700, "SD Card", getResources().getDrawable(R.drawable.ic_launcher_startup));
        f.addActionItem(n);

        if (ENABLE_ON_LAUNCH)
            n = new ActionItem(3600, "Enable On Launch",
                    getResources().getDrawable(R.drawable.ic_launcher_apply));
        else
            n = new ActionItem(3600, "Enable On Launch",
                    getResources().getDrawable(R.drawable.ic_launcher_disabled));
        f.addActionItem(n);

        f.setOnActionItemClickListener(this);
        f.show(indicator);
        break;

    case 1000:
        // CASE 300 DIRECTED QUICKACTION TO CASE 1000 , FIRST OPTION UNDER FOLDER OPTIONS
        // IF HIDDEN FOLDERS ARE VISIBLE HIDE IT OTHER WISE MAKE THEM VISIBLE
        if (SHOW_HIDDEN_FOLDERS) {
            edit.putBoolean("SHOW_HIDDEN_FOLDERS", false);
            SHOW_HIDDEN_FOLDERS = RFileManager.SHOW_HIDDEN_FOLDER = SFileManager.SHOW_HIDDEN_FOLDER = false;
        } else {
            SHOW_HIDDEN_FOLDERS = RFileManager.SHOW_HIDDEN_FOLDER = SFileManager.SHOW_HIDDEN_FOLDER = true;
            edit.putBoolean("SHOW_HIDDEN_FOLDERS", true);
        }
        edit.commit();
        setAdapter(CURRENT_ITEM);
        Toast.makeText(getBaseContext(), "Settings Have Been Applied", Toast.LENGTH_SHORT).show();
        break;
    case 1100:
        // DISPLAYS THE AVAILABLE SORTING METHODS AVAILABLE
        QuickAction c = new QuickAction(getBaseContext());
        ActionItem k;
        if (SORT_TYPE == 1)
            k = new ActionItem(1200, "Alphabetical Order",
                    getResources().getDrawable(R.drawable.ic_launcher_apply));
        else
            k = new ActionItem(1200, "Alphabetical Order",
                    getResources().getDrawable(R.drawable.ic_launcher_folder_orange));
        c.addActionItem(k);

        if (SORT_TYPE == 2)
            k = new ActionItem(1300, "Folder First Then File",
                    getResources().getDrawable(R.drawable.ic_launcher_apply));
        else
            k = new ActionItem(1300, "Folder First Then File",
                    getResources().getDrawable(R.drawable.ic_launcher_folder_orange));
        c.addActionItem(k);

        if (SORT_TYPE == 3)
            k = new ActionItem(1400, "File First Then Folder",
                    getResources().getDrawable(R.drawable.ic_launcher_apply));
        else
            k = new ActionItem(1400, "File First Then Folder",
                    getResources().getDrawable(R.drawable.ic_launcher_folder_orange));
        c.addActionItem(k);

        if (SORT_TYPE == 4)
            k = new ActionItem(1500, "Hidedn Item First",
                    getResources().getDrawable(R.drawable.ic_launcher_apply));
        else
            k = new ActionItem(1500, "Hidden Item First",
                    getResources().getDrawable(R.drawable.ic_launcher_folder_orange));
        c.addActionItem(k);

        if (SORT_TYPE == 5)
            k = new ActionItem(1600, "Non Hidden Item First",
                    getResources().getDrawable(R.drawable.ic_launcher_apply));
        else
            k = new ActionItem(1600, "Non Hidden First",
                    getResources().getDrawable(R.drawable.ic_launcher_folder_orange));
        c.addActionItem(k);
        c.setOnActionItemClickListener(this);
        c.show(indicator);
        break;

    case 1200:
        // DIRECTED FROM CASE 1100
        // SETS SORTING IN ALPHABETICAL ORDER
        SORT_TYPE = RFileManager.SORT_TYPE = SFileManager.SORT_TYPE = 1;
        edit.putInt("SORT_TYPE", 1);
        edit.commit();
        Toast.makeText(getBaseContext(), "Settings Have Been Applied", Toast.LENGTH_SHORT).show();
        setAdapter(CURRENT_ITEM);
        break;

    case 1300:
        // SETS SORTING IN FOLDER FIRST THEN FILE
        // DIRECTED FROM CASE 1100
        SORT_TYPE = RFileManager.SORT_TYPE = SFileManager.SORT_TYPE = 2;
        edit.putInt("SORT_TYPE", 2);
        edit.commit();
        Toast.makeText(getBaseContext(), "Settings Have Been Applied", Toast.LENGTH_SHORT).show();
        setAdapter(CURRENT_ITEM);
        break;

    case 1400:
        // SETS DORTING IN FILE FIRST THE FOLDER
        // DIRECTED FROM CASE 1100
        SORT_TYPE = RFileManager.SORT_TYPE = SFileManager.SORT_TYPE = 3;
        edit.putInt("SORT_TYPE", 3);
        edit.commit();
        Toast.makeText(getBaseContext(), "Settings Have Been Applied", Toast.LENGTH_SHORT).show();
        setAdapter(CURRENT_ITEM);
        break;

    case 1500:
        // SETS SORTING IN SHOW HIDDEN ITEM FIRST
        // DIRECTED FROM CASE 1100
        SORT_TYPE = RFileManager.SORT_TYPE = SFileManager.SORT_TYPE = 4;
        edit.putInt("SORT_TYPE", 4);
        edit.commit();
        Toast.makeText(getBaseContext(), "Settings Have Been Applied", Toast.LENGTH_SHORT).show();
        setAdapter(CURRENT_ITEM);
        break;

    case 1600:
        // SETS SORTING IN SHOW NON HIDDEN ITEMS FIRST
        // DIRECTED FROM CASE 1100
        SORT_TYPE = RFileManager.SORT_TYPE = SFileManager.SORT_TYPE = 5;
        edit.putInt("SORT_TYPE", 5);
        edit.commit();
        Toast.makeText(getBaseContext(), "Settings Have Been Applied", Toast.LENGTH_SHORT).show();
        setAdapter(CURRENT_ITEM);
        break;

    case 1700:
        //DIRECTED FROM CASE 100
        //SETS THE TRANSPARENCY TO 60%
        TRANS_LEVEL = 0.6f;
        edit.putFloat("TRANS_LEVEL", 0.6f);
        edit.commit();
        this.getWindow().getAttributes().alpha = TRANS_LEVEL;
        Toast.makeText(getBaseContext(), "Settings saved,restart app to view change", Toast.LENGTH_SHORT)
                .show();
        break;
    case 1800:
        //DIRECTED FROM CASE 100
        //SETS THE TRANSPARENCY TO 70%
        TRANS_LEVEL = 0.7f;
        edit.putFloat("TRANS_LEVEL", 0.7f);
        edit.commit();
        this.getWindow().getAttributes().alpha = TRANS_LEVEL;
        Toast.makeText(getBaseContext(), "Settings saved,restart app to view change", Toast.LENGTH_SHORT)
                .show();
        break;

    case 1900:
        //DIRECTED FROM CASE 100
        //SETS THE TRANSPARENCY TO 80%
        TRANS_LEVEL = 0.8f;
        edit.putFloat("TRANS_LEVEL", 0.8f);
        edit.commit();
        this.getWindow().getAttributes().alpha = TRANS_LEVEL;
        Toast.makeText(getBaseContext(), "Settings saved,restart app to view change", Toast.LENGTH_SHORT)
                .show();
        break;
    case 2000:
        //DIRECTED FROM CASE 100
        //SETS THE TRANSPARENCY TO 90%
        TRANS_LEVEL = 0.9f;
        edit.putFloat("TRANS_LEVEL", 0.9f);
        edit.commit();
        this.getWindow().getAttributes().alpha = TRANS_LEVEL;
        Toast.makeText(getBaseContext(), "Settings saved,restart app to view change", Toast.LENGTH_SHORT)
                .show();
        break;
    case 2100:
        //DIRECTED FROM CASE 100
        //SETS THE TRANSPARENCY TO 100%
        TRANS_LEVEL = 1.0f;
        edit.putFloat("TRANS_LEVEL", 1.0f);
        edit.commit();
        this.getWindow().getAttributes().alpha = TRANS_LEVEL;
        Toast.makeText(getBaseContext(), "Settings saved,restart app to view change", Toast.LENGTH_SHORT)
                .show();
        break;

    case 2200:
        //DIRECTED FROM CASE 800
        //SETS THE SETTING TO LOAD ALL FILE PANEL TO LOAD FIRST
        CURRENT_PREF_ITEM = 0;
        edit.putInt("CURRENT_PREF_ITEM", 0);
        edit.commit();
        Toast.makeText(getBaseContext(), "Settings Have Been Saved", Toast.LENGTH_SHORT).show();
        break;
    case 2300:
        //DIRECTED FROM CASE 800
        //SETS THE SETTING TO LOAD SD CARD PANEL-1 TO LOAD FIRST
        CURRENT_PREF_ITEM = 1;
        edit.putInt("CURRENT_PREF_ITEM", 1);
        edit.commit();
        Toast.makeText(getBaseContext(), "Settings Have Been Saved", Toast.LENGTH_SHORT).show();
        break;
    case 2400:
        //DIRECTED FROM CASE 800
        //SETS THE SETTING TO LOAD SD CARD PANEL-2 TO LOAD FIRST
        CURRENT_PREF_ITEM = 2;
        edit.putInt("CURRENT_PREF_ITEM", 2);
        edit.commit();
        Toast.makeText(getBaseContext(), "Settings Have Been Saved", Toast.LENGTH_SHORT).show();
        break;
    case 2500:
        //DIRECTED FROM CASE 800
        //SETS THE SETTING TO LOAD ALL FILE PANEL TO LOAD FIRST
        //CURRENT_PREF_ITEM = 3;
        edit.putInt("CURRENT_PREF_ITEM", 3);
        edit.commit();
        Toast.makeText(getBaseContext(), "Settings Have Been Saved", Toast.LENGTH_SHORT).show();
        break;

    case 2600:
        // LAUNCHES AN ACTIVITY TO SELECT THE DIRECTORY FOR INTERNAL STORAGE 1
        // DIRECTED FROM CASE 900
        new SetLaunchDir(mContext, size.x * 4 / 5, preferences, 1);
        break;
    case 2700:
        // LAUNCHES AN ACTIVITY TO SELECT THE DIRECTORY FOR INTERNAL STORAGE 2
        // DIRECTED FROM CASE 900
        new SetLaunchDir(mContext, size.x * 4 / 5, preferences, 2);
        break;

    case 2800:
        // DIRECTED FROM CAE 90
        // SETS THE FOLDER ICON TO DEFAULT FOLDER ICON
        RootAdapter.FOLDER_TYPE = SimpleAdapter.FOLDER_TYPE = 0;
        edit.putInt("FOLDER_TYPE", 0);
        edit.commit();
        Toast.makeText(getBaseContext(), "Settings Have Been Applied", Toast.LENGTH_SHORT).show();
        setAdapter(CURRENT_ITEM);
        break;

    case 2900:
        // DIRECTED FROM CAE 90
        // SETS THE FOLDER ICON TO VIOLET FOLDER ICON
        RootAdapter.FOLDER_TYPE = SimpleAdapter.FOLDER_TYPE = 1;
        edit.putInt("FOLDER_TYPE", 1);
        edit.commit();
        Toast.makeText(getBaseContext(), "Settings Have Been Applied", Toast.LENGTH_SHORT).show();
        setAdapter(CURRENT_ITEM);
        break;

    case 3000:
        // DIRECTED FROM CAE 90
        // SETS THE FOLDER ICON TO OXYGEN FOLDER ICON
        RootAdapter.FOLDER_TYPE = SimpleAdapter.FOLDER_TYPE = 2;
        edit.putInt("FOLDER_TYPE", 2);
        edit.commit();
        Toast.makeText(getBaseContext(), "Settings Have Been Applied", Toast.LENGTH_SHORT).show();
        setAdapter(CURRENT_ITEM);
        break;

    case 3100:
        // DIRECTED FROM CAE 90
        // SETS THE FOLDER ICON TO YELLOW FOLDER ICON
        RootAdapter.FOLDER_TYPE = SimpleAdapter.FOLDER_TYPE = 3;
        edit.putInt("FOLDER_TYPE", 3);
        edit.commit();
        Toast.makeText(getBaseContext(), "Settings Have Been Applied", Toast.LENGTH_SHORT).show();
        setAdapter(CURRENT_ITEM);
        break;

    case 3101:
        // DIRECTED FROM CAE 90
        // SETS THE FOLDER ICON TO YELLOW FOLDER ICON
        RootAdapter.FOLDER_TYPE = SimpleAdapter.FOLDER_TYPE = 4;
        edit.putInt("FOLDER_TYPE", 4);
        edit.commit();
        Toast.makeText(getBaseContext(), "Settings Have Been Applied", Toast.LENGTH_SHORT).show();
        setAdapter(CURRENT_ITEM);
        break;

    case 3102:
        // DIRECTED FROM CAE 90
        // SETS THE FOLDER ICON TO YELLOW FOLDER ICON
        RootAdapter.FOLDER_TYPE = SimpleAdapter.FOLDER_TYPE = 5;
        edit.putInt("FOLDER_TYPE", 5);
        edit.commit();
        Toast.makeText(getBaseContext(), "Settings Have Been Applied", Toast.LENGTH_SHORT).show();
        setAdapter(CURRENT_ITEM);
        break;
    case 3103:
        // DIRECTED FROM CAE 90
        // SETS THE FOLDER ICON TO YELLOW FOLDER ICON
        RootAdapter.FOLDER_TYPE = SimpleAdapter.FOLDER_TYPE = 6;
        edit.putInt("FOLDER_TYPE", 6);
        edit.commit();
        Toast.makeText(getBaseContext(), "Settings Have Been Applied", Toast.LENGTH_SHORT).show();
        setAdapter(CURRENT_ITEM);
        break;
    case 3200:
        //DIRECTED FROM CASE 400 ONLY FOR APP PANEL
        // DISPLAYS OPTION FOR SETTING TO SHOW USER OR SYSTEM OR BOTH TYPES OF APP
        QuickAction s = new QuickAction(getBaseContext());
        ActionItem ti;
        if (SHOW_APP == 1)
            ti = new ActionItem(3300, "Show Downloaded Apps",
                    getResources().getDrawable(R.drawable.ic_launcher_apply));
        else
            ti = new ActionItem(3300, "Show Downloaded Apps",
                    getResources().getDrawable(R.drawable.ic_launcher_user));
        s.addActionItem(ti);

        if (SHOW_APP == 2)
            ti = new ActionItem(3400, "Show System Apps",
                    getResources().getDrawable(R.drawable.ic_launcher_apply));
        else
            ti = new ActionItem(3400, "Show System Apps",
                    getResources().getDrawable(R.drawable.ic_launcher_system));
        s.addActionItem(ti);

        if (SHOW_APP == 3)
            ti = new ActionItem(3500, "Show Both Of Them",
                    getResources().getDrawable(R.drawable.ic_launcher_apply));
        else
            ti = new ActionItem(3500, "Show Both Of Them",
                    getResources().getDrawable(R.drawable.ic_launcher_both));
        s.addActionItem(ti);
        s.setOnActionItemClickListener(this);
        s.show(indicator);
        break;
    case 3300:
        // SETS THE SETTING TO SHOW DOWNLOADED APPS ONLY
        // DIRECTED FROM CASE 3200
        edit.putInt("SHOW_APP", 1);
        edit.commit();
        SHOW_APP = nManager.SHOW_APP = 1;
        Toast.makeText(getBaseContext(), "Settings Have Been Applied", Toast.LENGTH_SHORT).show();
        nList = nManager.giveMeAppList();
        nAppAdapter = new AppAdapter(getBaseContext(), R.layout.row_list_1, nList);
        APP_LIST_VIEW.setAdapter(nAppAdapter);
        break;
    case 3400:
        // SETS THE SETTING TO SHOW SYSTEM APPS ONLY
        // DIRECTED FROM CASE 3200
        edit.putInt("SHOW_APP", 2);
        edit.commit();
        SHOW_APP = nManager.SHOW_APP = 2;
        Toast.makeText(getBaseContext(), "Settings Have Been Applied", Toast.LENGTH_SHORT).show();
        nList = nManager.giveMeAppList();
        nAppAdapter = new AppAdapter(getBaseContext(), R.layout.row_list_1, nList);
        APP_LIST_VIEW.setAdapter(nAppAdapter);
        break;

    case 3500:
        // SETS THE SETTING TO SHOW DOWNLOADED AND SYSTEM APPS
        // DIRECTED FROM CASE 3200
        edit.putInt("SHOW_APP", 3);
        edit.commit();
        SHOW_APP = nManager.SHOW_APP = 3;
        Toast.makeText(getBaseContext(), "Settings Have Been Applied", Toast.LENGTH_SHORT).show();
        nList = nManager.giveMeAppList();
        nAppAdapter = new AppAdapter(getBaseContext(), R.layout.row_list_1, nList);
        APP_LIST_VIEW.setAdapter(nAppAdapter);
        break;

    case 3600:
        // DIRECTED FROM CASE 900
        // ENABLES OR DISABLES TO SHOW PREFFERED DIRECTORY ON LAUNCH
        if (ENABLE_ON_LAUNCH)
            edit.putBoolean("ENABLE_ON_LAUNCH", ENABLE_ON_LAUNCH = false);
        else
            edit.putBoolean("ENABLE_ON_LAUNCH", ENABLE_ON_LAUNCH = true);
        edit.commit();
        Toast.makeText(getBaseContext(), "Settings Have Been Saved", Toast.LENGTH_SHORT).show();
        break;

    }
}

From source file:com.jiandanbaoxian.fragment.DialogFragmentCreater.java

/**
 * Dialog ???/*from  w w w  . j  a v  a 2 s  . c o m*/
 * @param mContext
 * @return
 */
private Dialog showLicenseChoiceDialog(final Context mContext) {
    View convertView = LayoutInflater.from(mContext).inflate(R.layout.dialog_license_choice, null);
    final Dialog dialog = new Dialog(mContext, R.style.mystyle);

    View.OnClickListener listener = new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            switch (v.getId()) {
            case R.id.layout_rule:
                if (isAgree) {
                    isAgree = false;
                    ImageView imageView = (ImageView) v.findViewById(R.id.iv_choose);
                    //                            TextView textView = (TextView)v.findViewById(R.id.tv_rule);
                    imageView.setImageResource(R.drawable.icon_choose);
                    //                            textView.setBackgroundColor(getResources().getColor(R.color.bg_gray_color_level_0));
                    //                            textView.setTextColor(getResources().getColor(R.color.tv_gray_color_level_3));
                } else {
                    isAgree = true;
                    ImageView imageView = (ImageView) v.findViewById(R.id.iv_choose);
                    //                            TextView textView = (TextView)v.findViewById(R.id.tv_rule);
                    imageView.setImageResource(R.drawable.icon_choose_selected);
                    //                            textView.setBackgroundResource(R.drawable.btn_select_base_shape_0);
                    //                            textView.setTextColor(getResources().getColor(R.color.white_color));
                }
                break;
            }
            if (onLicenseDialogClickListener != null) {
                onLicenseDialogClickListener.onClick(v, isAgree);
            }
        }
    };

    TitleBar titleBar;
    SwipeRefreshLayout swipeLayout;
    final WebView webView;
    ProgressBar progressBar;
    LinearLayout layoutRule;
    LinearLayout layoutConfirm;

    titleBar = (TitleBar) convertView.findViewById(R.id.title_bar);
    swipeLayout = (SwipeRefreshLayout) convertView.findViewById(R.id.swipe_layout);
    webView = (WebView) convertView.findViewById(R.id.webView);
    progressBar = (ProgressBar) convertView.findViewById(R.id.progress_bar);
    layoutRule = (LinearLayout) convertView.findViewById(R.id.layout_rule);
    layoutConfirm = (LinearLayout) convertView.findViewById(R.id.layout_confirm);

    WebChromeClient client = new AppChromeWebClient(titleBar, progressBar, swipeLayout);
    webView.setWebChromeClient(client);
    webView.setWebViewClient(new AppWebClient());
    webView.getSettings().setJavaScriptEnabled(true);
    webView.loadUrl(webViewURL);
    webView.setOnKeyListener(new View.OnKeyListener() {
        @Override
        public boolean onKey(View v, int keyCode, KeyEvent event) {
            if (event.getAction() == KeyEvent.ACTION_DOWN) {
                if (keyCode == KeyEvent.KEYCODE_BACK && webView.canGoBack()) {
                    webView.goBack(); //?
                    return true; //?
                }
            }
            return false;
        }
    });

    titleBar.initTitleBarInfo("", R.drawable.arrow_left, -1, "", "");
    titleBar.setOnTitleBarClickListener(new TitleBar.OnTitleBarClickListener() {
        @Override
        public void onLeftButtonClick(View v) {
            if (webView.canGoBack()) {
                webView.goBack(); //?
                return; //?
            }

            if (onLicenseDialogClickListener != null) {
                onLicenseDialogClickListener.onClick(v, isAgree);
                dismiss();
            }
        }

        @Override
        public void onRightButtonClick(View v) {

        }
    });
    UIUtils.initSwipeRefreshLayout(swipeLayout);
    swipeLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            webView.reload();
        }
    });

    layoutConfirm.setOnClickListener(listener);
    layoutRule.setOnClickListener(listener);

    dialog.setContentView(convertView);
    dialog.getWindow().setWindowAnimations(R.style.dialog_right_control_style);
    return dialog;
}

From source file:group.pals.android.lib.ui.filechooser.FragmentFiles.java

/**
 * Show a dialog for sorting options and resort file list after user
 * selected an option./*ww w.  j av  a 2s .co m*/
 */
private void resortViewFiles() {
    final Dialog dialog = new Dialog(getActivity(),
            Ui.resolveAttribute(getActivity(), R.attr.afc_theme_dialog));
    dialog.setCanceledOnTouchOutside(true);

    // get the index of button of current sort type
    int btnCurrentSortTypeIdx = 0;
    switch (DisplayPrefs.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 (!DisplayPrefs.isSortAscending(getActivity()))
        btnCurrentSortTypeIdx++;

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

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

            if (v.getId() == R.id.afc_button_sort_by_name_asc) {
                DisplayPrefs.setSortType(getActivity(), BaseFile.SORT_BY_NAME);
                DisplayPrefs.setSortAscending(getActivity(), true);
            } else if (v.getId() == R.id.afc_button_sort_by_name_desc) {
                DisplayPrefs.setSortType(getActivity(), BaseFile.SORT_BY_NAME);
                DisplayPrefs.setSortAscending(getActivity(), false);
            } else if (v.getId() == R.id.afc_button_sort_by_size_asc) {
                DisplayPrefs.setSortType(getActivity(), BaseFile.SORT_BY_SIZE);
                DisplayPrefs.setSortAscending(getActivity(), true);
            } else if (v.getId() == R.id.afc_button_sort_by_size_desc) {
                DisplayPrefs.setSortType(getActivity(), BaseFile.SORT_BY_SIZE);
                DisplayPrefs.setSortAscending(getActivity(), false);
            } else if (v.getId() == R.id.afc_button_sort_by_date_asc) {
                DisplayPrefs.setSortType(getActivity(), BaseFile.SORT_BY_MODIFICATION_TIME);
                DisplayPrefs.setSortAscending(getActivity(), true);
            } else if (v.getId() == R.id.afc_button_sort_by_date_desc) {
                DisplayPrefs.setSortType(getActivity(), BaseFile.SORT_BY_MODIFICATION_TIME);
                DisplayPrefs.setSortAscending(getActivity(), false);
            }

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

    View view = getLayoutInflater(null).inflate(R.layout.afc_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.afc_bullet);
        }
    }

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

From source file:com.xmobileapp.rockplayer.RockPlayer.java

/**********************************************
 * /*w  w  w.ja  v  a  2 s  .com*/
 *  Called when the activity is first created
 *  
 **********************************************/
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    context = this;
    System.gc();

    //Log.i("PRFMC", "1");
    /*
    * Window Properties
    */
    //requestWindowFeature(Window.FEATURE_PROGRESS);
    //requestWindowFeature(Window.PROGRESS_VISIBILITY_ON);
    requestWindowFeature(Window.FEATURE_NO_TITLE);

    /*
     * Blur&Dim the BG
     */
    // Have the system blur any windows behind this one.
    //        getWindow().setFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND,
    //                WindowManager.LayoutParams.FLAG_BLUR_BEHIND);
    ////        getWindow().setFlags(WindowManager.LayoutParams.FLAG_DITHER, 
    ////              WindowManager.LayoutParams.FLAG_DITHER);
    //        getWindow().setFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND, 
    //              WindowManager.LayoutParams.FLAG_DIM_BEHIND);
    //        WindowManager.LayoutParams params = getWindow().getAttributes();
    //        params.dimAmount = 0.625f;
    //        getWindow().setAttributes(params);

    //        Resources.Theme theme = getTheme();
    //        theme.dump(arg0, arg1, arg2)

    //setContentView(R.layout.songfest_main);
    //Log.i("PRFMC", "2");

    /*
     * Initialize Display
     */
    WindowManager windowManager = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
    this.display = windowManager.getDefaultDisplay();
    //Log.i("PRFMC", "3");

    /*
     * Set Bug Report Handler
     */
    fdHandler = new FilexDefaultExceptionHandler(this);

    /*
     * Check if Album Art Directory exists
     */
    checkAlbumArtDirectory();
    checkConcertDirectory();
    checkPreferencesDirectory();
    checkBackgroundDirectory();
    //Log.i("PRFMC", "7");

    /*
     * Get Preferences
     */
    readPreferences();

    /*
     * Force landscape or auto-rotate orientation if user requested
     */
    if (alwaysLandscape)
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    else if (autoRotate)
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR);

    /*
      * Create UI and initialize UI vars
      */
    setContentView(R.layout.songfest_main);

    //getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
    //if (true) return;

    //if(true)
    //   return;
    //Log.i("PRFMC", "4");
    initializeAnimations();
    //Log.i("PRFMC", "5");
    initializeUiVariables();
    //Log.i("PRFMC", "6");

    /*
     * Set Background
     */
    setBackground();

    /*
     * Set Current View
     */
    switch (VIEW_STATE) {
    case LIST_EXPANDED_VIEW:
        setListExpandedView();
        break;
    case FULLSCREEN_VIEW:
        setFullScreenView();
        break;
    default:
        setNormalView();
        break;
    }

    //        AlphaAnimation aAnim = new AlphaAnimation(0.0f, 0.92f);
    //        aAnim.setFillAfter(true);
    //        aAnim.setDuration(200);
    //        mainUIContainer.startAnimation(aAnim);

    /*
     * Check for SD Card
     */
    if (!android.os.Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED)) {
        Dialog noSDDialog = new Dialog(this);
        noSDDialog.setTitle("SD Card Error!");
        noSDDialog.setContentView(R.layout.no_sd_alert_layout);
        noSDDialog.show();
        return;
    }

    /*
     * Get a Content Resolver to browse
     * the phone audio database
     */
    contentResolver = getContentResolver();

    /*
     * Get Preferences
     */
    //SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);
    RockOnPreferenceManager settings = new RockOnPreferenceManager(FILEX_PREFERENCES_PATH);
    settings = new RockOnPreferenceManager(this.FILEX_PREFERENCES_PATH);
    // Shuffle
    boolean shuffle = settings.getBoolean("Shuffle", false);
    this.SHUFFLE = shuffle;
    //Playlist
    if (playlist == constants.PLAYLIST_NONE)
        playlist = settings.getLong(constants.PREF_KEY_PLAYLIST, constants.PLAYLIST_ALL);
    Log.i("PLAYLIST PREF", constants.PREF_KEY_PLAYLIST + " " + constants.PLAYLIST_ALL + " " + playlist);

    /*
     * Check if the MediaScanner is scanning
     */
    //        ProgressDialog pD = null;
    //        while(isMediaScannerScanning(this, contentResolver) == true){
    //           if(pD == null){
    //              pD = new ProgressDialog(this);
    //              pD.setTitle("Scanning Media");
    //              pD.setMessage("Wait please...");
    //              pD.show();
    //           }
    //           try {
    //            wait(2000);
    //         } catch (InterruptedException e) {
    //            e.printStackTrace();
    //         }
    //        }
    //        if(pD != null)
    //           pD.dismiss();

    /*
     * Initialize mediaPlayer
     */
    //this.mediaPlayer = new MediaPlayer();
    //this.mediaPlayer.setOnCompletionListener(songCompletedListener);

    /*
     * Initialize (or connect to) BG Service
     *  - when connected it will call the method getCurrentPlaying()
     *     and will cause the Service to reset its albumCursor
     */
    initializeService();
    //Log.i("PRFMC", "8");
    musicChangedIntentReceiver = new MusicChangedIntentReceiver();
    albumChangedIntentReceiver = new AlbumChangedIntentReceiver();
    mediaButtonPauseIntentReceiver = new MediaButtonPauseIntentReceiver();
    mediaButtonPlayIntentReceiver = new MediaButtonPlayIntentReceiver();
    registerReceiver(musicChangedIntentReceiver, musicChangedIntentFilter);
    //Log.i("PRFMC", "9");
    registerReceiver(albumChangedIntentReceiver, albumChangedIntentFilter);
    //Log.i("PRFMC", "10");
    registerReceiver(mediaButtonPauseIntentReceiver, mediaButtonPauseIntentFilter);
    registerReceiver(mediaButtonPlayIntentReceiver, mediaButtonPlayIntentFilter);
    // calls also getCurrentPlaying() upon connection

    /*
     * Register Media Button Receiver
     */
    //        mediaButtonIntentReceiver = new MediaButtonIntentReceiver();
    //        registerReceiver(mediaButtonIntentReceiver, new IntentFilter("android.intent.action.MEDIA_BUTTON"));

    /*
      * Get album information on a new
      * thread
      */
    //new Thread(){
    //   public void run(){
    getAlbums(false);
    //Log.i("PRFMC", "11");
    //   }
    //}.start();

    /*
     * Check for first time run ----------
     * 
     * Save Software Version
     *    &
     * Show Help Screen
     */
    //            if(!settings.contains("Version")){
    //               Editor settingsEditor = settings.edit();
    //               settingsEditor.putLong("Version", VERSION);
    //               settingsEditor.commit();
    //               this.hideMainUI();
    //               this.showHelpUI();
    //            }
    Log.i("DBG", "Version - " + (new RockOnPreferenceManager(this.FILEX_PREFERENCES_PATH)).getLong("Version", 0)
            + " - " + VERSION);
    if (!(new RockOnPreferenceManager(this.FILEX_PREFERENCES_PATH)).contains("Version")
            || (new RockOnPreferenceManager(this.FILEX_PREFERENCES_PATH)).getLong("Version", 0) < VERSION) {

        (new RockOnPreferenceManager(this.FILEX_PREFERENCES_PATH)).putLong("Version", VERSION);

        /*
        * Clear previous Album Art
        */
        Builder aD = new AlertDialog.Builder(context);
        aD.setTitle("New Version");
        aD.setMessage(
                "The new version of RockOn supports album art download from higher quality sources. Do you want to download art now? "
                        + "Every 10 albums will take aproximately 1 minute to download. "
                        + "(You can always do this later by choosing the 'Get Art' menu option)");
        aD.setPositiveButton("Yes", new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                //(new RockOnPreferenceManager(FILEX_PREFERENCES_PATH)).putLong("artImportDate", 0);
                try {
                    File albumArtDir = new File(FILEX_ALBUM_ART_PATH);
                    String[] fileList = albumArtDir.list();
                    File albumArtFile;
                    for (int i = 0; i < fileList.length; i++) {
                        albumArtFile = new File(albumArtDir.getAbsolutePath() + "/" + fileList[i]);
                        albumArtFile.delete();
                    }
                    checkAlbumArtDirectory();
                    triggerAlbumArtFetching();
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }

        });
        aD.setNegativeButton("No", new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {

            }

        });
        aD.show();

        /*
        * Version 2 specific default preference changes
        */
        // version 2 specific
        if (albumCursor.getCount() > 100)
            (new RockOnPreferenceManager(this.FILEX_PREFERENCES_PATH))
                    .putBoolean(PREFS_SHOW_ART_WHILE_SCROLLING, false);
        else
            (new RockOnPreferenceManager(this.FILEX_PREFERENCES_PATH))
                    .putBoolean(PREFS_SHOW_ART_WHILE_SCROLLING, true);

        readPreferences();
        albumAdapter.showArtWhileScrolling = showArtWhileScrolling;
        albumAdapter.showFrame = showFrame;
        //

        /*
        * Show help screen
        */
        this.hideMainUI();
        this.showHelpUI();
    } else {
        /*
         * Run albumArt getter in background
         */
        long lastAlbumArtImportDate = settings.getLong("artImportDate", 0);
        Log.i("SYNCTIME",
                lastAlbumArtImportDate + " + " + this.ART_IMPORT_INTVL + " < " + System.currentTimeMillis());
        if (lastAlbumArtImportDate + this.ART_IMPORT_INTVL < System.currentTimeMillis()) {
            triggerAlbumArtFetching();
        }
        //Log.i("PRFMC", "13");
    }
}

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  . jav a2 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.sentaroh.android.SMBExplorer.SMBExplorerMain.java

private void createItem(final FileListAdapter fla, final String item_optyp, final String base_dir) {
    sendDebugLogMsg(1, "I", "createItem entered.");

    // ??/*from  w ww.java  2 s .  c  o  m*/
    final Dialog dialog = new Dialog(this);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setCanceledOnTouchOutside(false);
    dialog.setContentView(R.layout.file_rename_create_dlg);
    final EditText newName = (EditText) dialog.findViewById(R.id.file_rename_create_dlg_newname);
    final Button btnOk = (Button) dialog.findViewById(R.id.file_rename_create_dlg_ok_btn);
    final Button btnCancel = (Button) dialog.findViewById(R.id.file_rename_create_dlg_cancel_btn);

    CommonDialog.setDlgBoxSizeCompact(dialog);

    ((TextView) dialog.findViewById(R.id.file_rename_create_dlg_title)).setText("Create directory");
    ((TextView) dialog.findViewById(R.id.file_rename_create_dlg_subtitle)).setText("Enter new name");

    // newName.setText(item_name);

    btnOk.setEnabled(false);
    // btnCancel.setEnabled(false);
    newName.addTextChangedListener(new TextWatcher() {
        @Override
        public void afterTextChanged(Editable s) {
            if (s.toString().length() < 1)
                btnOk.setEnabled(false);
            else
                btnOk.setEnabled(true);
        }

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
        }
    });

    // OK?
    btnOk.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            dialog.dismiss();
            if (!checkDuplicateDir(fla, newName.getText().toString())) {
                commonDlg.showCommonDialog(false, "E", "Create", "Duplicate directory name specified", null);
            } else {
                int cmd = 0;
                if (currentTabName.equals(SMBEXPLORER_TAB_LOCAL)) {
                    fileioLinkParm = buildFileioLinkParm(fileioLinkParm, base_dir, "",
                            newName.getText().toString(), "", smbUser, smbPass, true);
                    cmd = FILEIO_PARM_LOCAL_CREATE;
                } else {
                    cmd = FILEIO_PARM_REMOTE_CREATE;
                    fileioLinkParm = buildFileioLinkParm(fileioLinkParm, base_dir, "",
                            newName.getText().toString(), "", smbUser, smbPass, true);
                }
                sendDebugLogMsg(1, "I", "createItem FILEIO task invoked.");
                startFileioTask(fla, cmd, fileioLinkParm, newName.getText().toString(), null, null);
            }
        }
    });
    // CANCEL?
    btnCancel.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            dialog.dismiss();
            sendDebugLogMsg(1, "W", "createItem cancelled.");
        }
    });
    // Cancel?
    dialog.setOnCancelListener(new Dialog.OnCancelListener() {
        @Override
        public void onCancel(DialogInterface arg0) {
            btnCancel.performClick();
        }
    });
    //      dialog.setOnKeyListener(new DialogOnKeyListener(currentContext));
    //      setFixedOrientation(true);
    //      dialog.setCancelable(false);
    dialog.show();
}

From source file:com.sentaroh.android.SMBExplorer.SMBExplorerMain.java

private void renameItem(final FileListAdapter fla, final String item_optyp, final String item_name,
        final boolean item_isdir, final int item_num) {

    sendDebugLogMsg(1, "I", "renameItem entered.");
    // ??/*from   w  w  w . j a  v  a 2s  .c  om*/
    final Dialog dialog = new Dialog(this);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setCanceledOnTouchOutside(false);
    dialog.setContentView(R.layout.file_rename_create_dlg);
    final EditText newName = (EditText) dialog.findViewById(R.id.file_rename_create_dlg_newname);
    final Button btnOk = (Button) dialog.findViewById(R.id.file_rename_create_dlg_ok_btn);
    final Button btnCancel = (Button) dialog.findViewById(R.id.file_rename_create_dlg_cancel_btn);

    CommonDialog.setDlgBoxSizeCompact(dialog);

    ((TextView) dialog.findViewById(R.id.file_rename_create_dlg_title)).setText("Rename");
    ((TextView) dialog.findViewById(R.id.file_rename_create_dlg_subtitle)).setText("Enter new name");

    newName.setText(item_name);

    btnOk.setEnabled(false);
    newName.addTextChangedListener(new TextWatcher() {
        @Override
        public void afterTextChanged(Editable s) {
            if (s.toString().length() < 1 || item_name.equals(s.toString()))
                btnOk.setEnabled(false);
            else
                btnOk.setEnabled(true);
        }

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
        }
    });

    // OK?
    btnOk.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            dialog.dismiss();
            //            setFixedOrientation(false);
            if (item_name.equals(newName.getText().toString())) {
                commonDlg.showCommonDialog(false, "E", "Rename", "Duplicate file name specified", null);
            } else {
                int cmd = 0;
                if (currentTabName.equals(SMBEXPLORER_TAB_LOCAL)) {
                    fileioLinkParm = buildFileioLinkParm(fileioLinkParm, fla.getItem(item_num).getPath(),
                            fla.getItem(item_num).getPath(), item_name, newName.getText().toString(), "", "",
                            true);
                    cmd = FILEIO_PARM_LOCAL_RENAME;
                } else {
                    cmd = FILEIO_PARM_REMOTE_RENAME;
                    if (item_isdir)
                        fileioLinkParm = buildFileioLinkParm(fileioLinkParm, fla.getItem(item_num).getPath(),
                                fla.getItem(item_num).getPath(), item_name, newName.getText().toString(),
                                smbUser, smbPass, true);
                    else
                        fileioLinkParm = buildFileioLinkParm(fileioLinkParm, fla.getItem(item_num).getPath(),
                                fla.getItem(item_num).getPath(), item_name, newName.getText().toString(),
                                smbUser, smbPass, true);
                }
                sendDebugLogMsg(1, "I", "renameItem FILEIO task invoked.");
                startFileioTask(fla, cmd, fileioLinkParm, item_name, null, null);
            }
        }
    });
    // CANCEL?
    btnCancel.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            dialog.dismiss();
            //            setFixedOrientation(false);
            sendDebugLogMsg(1, "W", "renameItem cancelled.");
        }
    });
    // Cancel?
    dialog.setOnCancelListener(new Dialog.OnCancelListener() {
        @Override
        public void onCancel(DialogInterface arg0) {
            btnCancel.performClick();
        }
    });
    //      dialog.setOnKeyListener(new DialogOnKeyListener(currentContext));
    //      setFixedOrientation(true);
    //      dialog.setCancelable(false);
    dialog.show();
}