List of usage examples for android.app Dialog requestWindowFeature
public final boolean requestWindowFeature(int featureId)
From source file:com.nttec.everychan.ui.presentation.BoardFragment.java
/** * ? ? ?//www. j a v a 2s.co m * @param itemPosition ? ? (?) listView * @param isTablet true, ? (?? ? ??) * @param coordinates ?? */ private void showPostPopupDialog(final int itemPosition, final boolean isTablet, final Point coordinates, final String refererPost) { final int bgShadowResource = ThemeUtils.getThemeResId(activity.getTheme(), R.attr.dialogBackgroundShadow); final int bgColor = ThemeUtils.getThemeColor(activity.getTheme(), R.attr.activityRootBackground, Color.BLACK); final int measuredWidth = isTablet ? adapter.measureViewWidth(itemPosition) : -1; //? ?? ? final View tmpV = new View(activity); final Dialog tmpDlg = new Dialog(activity); tmpDlg.getWindow().setBackgroundDrawableResource(bgShadowResource); tmpDlg.requestWindowFeature(Window.FEATURE_NO_TITLE); tmpDlg.setCanceledOnTouchOutside(true); tmpDlg.setContentView(tmpV); final Rect activityWindowRect; final int dlgWindowWidth; final int dlgWindowHeight; if (isTablet) { activityWindowRect = new Rect(); activity.getWindow().getDecorView().getWindowVisibleDisplayFrame(activityWindowRect); dlgWindowWidth = Math.max(coordinates.x, activityWindowRect.width() - coordinates.x); dlgWindowHeight = Math.max(coordinates.y, activityWindowRect.height() - coordinates.y); tmpDlg.getWindow().setLayout(dlgWindowWidth, dlgWindowHeight); } else { activityWindowRect = null; dlgWindowWidth = -1; dlgWindowHeight = -1; } tmpDlg.show(); Runnable next = new Runnable() { @SuppressLint("RtlHardcoded") @Override public void run() { int dlgWidth = tmpV.getWidth(); int dlgHeight = tmpV.getHeight(); tmpDlg.hide(); tmpDlg.cancel(); int newWidth = isTablet ? Math.min(measuredWidth, dlgWidth) : dlgWidth; View view = adapter.getView(itemPosition, null, null, newWidth, refererPost); view.setBackgroundColor(bgColor); //Logger.d(TAG, "measured: "+view.findViewById(R.id.post_frame_main).getMeasuredWidth()+ // "x"+view.findViewById(R.id.post_frame_main).getMeasuredHeight()); Dialog dialog = new Dialog(activity); dialog.getWindow().setBackgroundDrawableResource(bgShadowResource); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setCanceledOnTouchOutside(true); dialog.setContentView(view); if (isTablet) { view.findViewById(R.id.post_frame_main).measure( MeasureSpec.makeMeasureSpec(newWidth, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED)); int newWindowWidth = dlgWindowWidth - dlgWidth + newWidth; int newWindowHeight = dlgWindowHeight - dlgHeight + Math.min(view.findViewById(R.id.post_frame_main).getMeasuredHeight(), dlgHeight); dialog.getWindow().setLayout(newWindowWidth, newWindowHeight); WindowManager.LayoutParams params = dialog.getWindow().getAttributes(); if (coordinates.x > activityWindowRect.width() - coordinates.x && coordinates.x + newWindowWidth > activityWindowRect.width()) { params.x = activityWindowRect.width() - coordinates.x; params.gravity = Gravity.RIGHT; } else { params.x = coordinates.x; params.gravity = Gravity.LEFT; } if (coordinates.y > activityWindowRect.height() - coordinates.y && coordinates.y + newWindowHeight > activityWindowRect.height()) { params.y = activityWindowRect.height() - coordinates.y; params.gravity |= Gravity.BOTTOM; } else { params.y = coordinates.y; params.gravity |= Gravity.TOP; } dialog.getWindow().setAttributes(params); // if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { CompatibilityImpl.setDimAmount(dialog.getWindow(), 0.1f); } else { dialog.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND); } } dialog.show(); dialogs.add(dialog); } }; if (tmpV.getWidth() != 0) { next.run(); } else { AppearanceUtils.callWhenLoaded(tmpDlg.getWindow().getDecorView(), next); } }
From source file:com.nttec.everychan.ui.presentation.BoardFragment.java
private void showThreadPreviewDialog(final int position) { final List<PresentationItemModel> items = new ArrayList<>(); final int bgShadowResource = ThemeUtils.getThemeResId(activity.getTheme(), R.attr.dialogBackgroundShadow); final int bgColor = ThemeUtils.getThemeColor(activity.getTheme(), R.attr.activityRootBackground, Color.BLACK);// w ww . j av a 2 s . c o m final View tmpV = new View(activity); final Dialog tmpDlg = new Dialog(activity); tmpDlg.getWindow().setBackgroundDrawableResource(bgShadowResource); tmpDlg.requestWindowFeature(Window.FEATURE_NO_TITLE); tmpDlg.setCanceledOnTouchOutside(true); tmpDlg.setContentView(tmpV); tmpDlg.show(); Runnable next = new Runnable() { @Override public void run() { final int dlgWidth = tmpV.getWidth(); tmpDlg.hide(); tmpDlg.cancel(); final Dialog dialog = new Dialog(activity); if (presentationModel.source != null && presentationModel.source.threads != null && presentationModel.source.threads.length > position && presentationModel.source.threads[position].posts != null && presentationModel.source.threads[position].posts.length > 0) { final String threadNumber = presentationModel.source.threads[position].posts[0].number; ClickableURLSpan.URLSpanClickListener spanClickListener = new ClickableURLSpan.URLSpanClickListener() { @Override public void onClick(View v, ClickableURLSpan span, String url, String referer) { if (url.startsWith("#")) { try { UrlPageModel threadPageModel = new UrlPageModel(); threadPageModel.chanName = chan.getChanName(); threadPageModel.type = UrlPageModel.TYPE_THREADPAGE; threadPageModel.boardName = tabModel.pageModel.boardName; threadPageModel.threadNumber = threadNumber; url = chan.buildUrl(threadPageModel) + url; dialog.dismiss(); UrlHandler.open(chan.fixRelativeUrl(url), activity); } catch (Exception e) { Logger.e(TAG, e); } } else { dialog.dismiss(); UrlHandler.open(chan.fixRelativeUrl(url), activity); } } }; AndroidDateFormat.initPattern(); String datePattern = AndroidDateFormat.getPattern(); DateFormat dateFormat = datePattern == null ? DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT) : new SimpleDateFormat(datePattern, Locale.US); dateFormat.setTimeZone(settings.isLocalTime() ? TimeZone.getDefault() : TimeZone.getTimeZone(presentationModel.source.boardModel.timeZoneId)); int postsCount = presentationModel.source.threads[position].postsCount; boolean showIndex = presentationModel.source.threads[position].posts.length <= postsCount; int curPostIndex = postsCount - presentationModel.source.threads[position].posts.length + 1; boolean openSpoilers = settings.openSpoilers(); for (int i = 0; i < presentationModel.source.threads[position].posts.length; ++i) { PresentationItemModel model = new PresentationItemModel( presentationModel.source.threads[position].posts[i], chan.getChanName(), presentationModel.source.pageModel.boardName, presentationModel.source.pageModel.threadNumber, dateFormat, spanClickListener, imageGetter, ThemeUtils.ThemeColors.getInstance(activity.getTheme()), openSpoilers, floatingModels, null); model.buildSpannedHeader(showIndex ? (i == 0 ? 1 : ++curPostIndex) : -1, presentationModel.source.boardModel.bumpLimit, presentationModel.source.boardModel.defaultUserName, null, false); items.add(model); } } else { items.add(presentationModel.presentationList.get(position)); } ListView dlgList = new ListView(activity); dlgList.setAdapter(new ArrayAdapter<PresentationItemModel>(activity, 0, items) { @Override public View getView(int position, View convertView, ViewGroup parent) { View view = adapter.getView(position, convertView, parent, dlgWidth, getItem(position)); view.setBackgroundColor(bgColor); return view; } }); dialog.getWindow().setBackgroundDrawableResource(bgShadowResource); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setCanceledOnTouchOutside(true); dialog.setContentView(dlgList); dialog.show(); dialogs.add(dialog); } }; if (tmpV.getWidth() != 0) { next.run(); } else { AppearanceUtils.callWhenLoaded(tmpDlg.getWindow().getDecorView(), next); } }
From source file:com.sentaroh.android.SMBSync2.SyncTaskUtility.java
private void listDirFilterLocal(SyncTaskItem sti, String prof_master, final ArrayList<String> dir_filter, final AdapterFilterList fla, final NotifyEvent p_ntfy) { final String cdir = sti.getMasterDirectoryName(); String localBaseDir_t = mGp.internalRootDirectory; if (sti.getMasterFolderType().equals(SyncTaskItem.SYNC_FOLDER_TYPE_SDCARD)) localBaseDir_t = mGp.sdcardRootDirectory; final String localBaseDir = localBaseDir_t; //??/*from ww w . j a v a 2 s . c om*/ 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_filter_list_dlg_add_dir_filter)); subtitle.setText(mContext.getString(R.string.msgs_current_dir) + " " + localBaseDir + "/" + cdir); final TextView dlg_msg = (TextView) dialog.findViewById(R.id.item_select_list_dlg_msg); final Button btn_ok = (Button) dialog.findViewById(R.id.item_select_list_dlg_ok_btn); final LinearLayout ll_context = (LinearLayout) dialog.findViewById(R.id.context_view_file_select); ll_context.setVisibility(LinearLayout.VISIBLE); final ImageButton ib_select_all = (ImageButton) ll_context.findViewById(R.id.context_button_select_all); final ImageButton ib_unselect_all = (ImageButton) ll_context.findViewById(R.id.context_button_unselect_all); dlg_msg.setVisibility(TextView.VISIBLE); // 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, false, false); lv.setAdapter(tfa); ArrayList<TreeFilelistItem> tfl = createLocalFilelist(true, localBaseDir, "/" + cdir); if (tfl.size() < 1) tfl.add(new TreeFilelistItem(mContext.getString(R.string.msgs_dir_empty))); tfa.setDataList(tfl); lv.setScrollingCacheEnabled(false); lv.setScrollbarFadingEnabled(false); ib_select_all.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { for (int i = 0; i < tfa.getDataItemCount(); i++) { TreeFilelistItem tfli = tfa.getDataItem(i); if (!tfli.isHideListItem()) tfa.setDataItemIsSelected(i); } tfa.notifyDataSetChanged(); btn_ok.setEnabled(true); } }); ib_unselect_all.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { for (int i = 0; i < tfa.getDataItemCount(); i++) { tfa.setDataItemIsUnselected(i); } tfa.notifyDataSetChanged(); btn_ok.setEnabled(false); } }); 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; expandHideLocalDirTree(true, localBaseDir, 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); final TreeFilelistItem tfi = tfa.getDataItem(t_pos); if (tfi.getName().startsWith("---")) return true; if (!tfa.getDataItem(t_pos).isChecked()) { tfa.setDataItemIsSelected(t_pos); } return true; } }); //OK? btn_ok.setEnabled(false); NotifyEvent ntfy = new NotifyEvent(mContext); //Listen setRemoteShare response ntfy.setListener(new NotifyEventListener() { @Override public void positiveResponse(Context arg0, Object[] arg1) { btn_ok.setEnabled(true); } @Override public void negativeResponse(Context arg0, Object[] arg1) { boolean checked = false; for (int i = 0; i < tfa.getDataItemCount(); i++) { if (tfa.getDataItem(i).isChecked()) { checked = true; break; } } if (checked) btn_ok.setEnabled(true); else btn_ok.setEnabled(false); } }); tfa.setCbCheckListener(ntfy); btn_ok.setText(mContext.getString(R.string.msgs_filter_list_dlg_add)); btn_ok.setVisibility(Button.VISIBLE); btn_ok.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { if (!addDirFilter(true, tfa, fla, "/" + cdir + "/", dlg_msg)) return; addDirFilter(false, tfa, fla, "/" + cdir + "/", dlg_msg); dialog.dismiss(); p_ntfy.notifyToListener(true, null); } }); //CANCEL? final Button btn_cancel = (Button) dialog.findViewById(R.id.item_select_list_dlg_cancel_btn); btn_cancel.setText(mContext.getString(R.string.msgs_filter_list_dlg_close)); btn_cancel.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { dialog.dismiss(); p_ntfy.notifyToListener(true, 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(); return; }
From source file:com.sentaroh.android.SMBSync2.SyncTaskUtility.java
public void selectLocalDirDlg(final String url, final String dir, String p_dir, final NotifyEvent p_ntfy) { //??/* w w w .j a v a2 s. c om*/ 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_local_dir)); subtitle.setText(mContext.getString(R.string.msgs_current_dir) + url + dir); 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); ListView lv = (ListView) dialog.findViewById(android.R.id.list); final TreeFilelistAdapter tfa = new TreeFilelistAdapter(mContext, true, false); lv.setAdapter(tfa); ArrayList<TreeFilelistItem> tfl = createLocalFilelist(true, url, dir); if (tfl.size() < 1) tfl.add(new TreeFilelistItem(mContext.getString(R.string.msgs_dir_empty))); tfa.setDataList(tfl); 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; expandHideLocalDirTree(true, url, 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_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.setDataItemIsUnselected(t_pos); if (tfa.isDataItemIsSelected()) btn_ok.setEnabled(true); else 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); 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; } } if (sel.equals("")) { } 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(); return; }
From source file:com.sentaroh.android.SMBSync2.SyncTaskUtility.java
public void editDirFilterDlg(final SyncTaskItem sti, final String prof_master, final ArrayList<String> dir_filter, final NotifyEvent p_ntfy) { ArrayList<FilterListItem> filterList = new ArrayList<FilterListItem>(); final AdapterFilterList filterAdapter; // ??//from w ww.j a v a 2 s . c o m final Dialog dialog = new Dialog(mContext); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setCanceledOnTouchOutside(false); dialog.setContentView(R.layout.filter_list_dlg); LinearLayout ll_dlg_view = (LinearLayout) dialog.findViewById(R.id.filter_select_edit_view); ll_dlg_view.setBackgroundColor(mGp.themeColorList.dialog_msg_background_color); final LinearLayout title_view = (LinearLayout) dialog.findViewById(R.id.filter_select_edit_title_view); final TextView title = (TextView) dialog.findViewById(R.id.filter_select_edit_title); title_view.setBackgroundColor(mGp.themeColorList.dialog_title_background_color); title.setTextColor(mGp.themeColorList.text_color_dialog_title); filterAdapter = new AdapterFilterList(mContext, R.layout.filter_list_item_view, filterList); final ListView lv = (ListView) dialog.findViewById(R.id.filter_select_edit_listview); for (int i = 0; i < dir_filter.size(); i++) { String inc = dir_filter.get(i).substring(0, 1); String filter = dir_filter.get(i).substring(1, dir_filter.get(i).length()); boolean b_inc = false; if (inc.equals(SMBSYNC_PROF_FILTER_INCLUDE)) b_inc = true; filterAdapter.add(new FilterListItem(filter, b_inc)); } if (filterAdapter.getCount() == 0) filterAdapter.add(new FilterListItem(mContext.getString(R.string.msgs_filter_list_no_filter), false)); lv.setAdapter(filterAdapter); lv.setScrollingCacheEnabled(false); lv.setScrollbarFadingEnabled(false); title.setText(mContext.getString(R.string.msgs_filter_list_dlg_dir_filter)); final TextView dlg_msg = (TextView) dialog.findViewById(R.id.filter_select_edit_msg); final Button dirbtn = (Button) dialog.findViewById(R.id.filter_select_edit_dir_btn); CommonDialog.setDlgBoxSizeLimit(dialog, true); final EditText et_filter = (EditText) dialog.findViewById(R.id.filter_select_edit_new_filter); final Button addbtn = (Button) dialog.findViewById(R.id.filter_select_edit_add_btn); final Button btn_cancel = (Button) dialog.findViewById(R.id.filter_select_edit_cancel_btn); final Button btn_ok = (Button) dialog.findViewById(R.id.filter_select_edit_ok_btn); lv.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> items, View view, int idx, long id) { FilterListItem fli = filterAdapter.getItem(idx); if (fli.getFilter().startsWith("---") || fli.isDeleted()) return; // ???????? editDirFilter(idx, filterAdapter, fli, fli.getFilter()); } }); // Add? et_filter.addTextChangedListener(new TextWatcher() { @Override public void afterTextChanged(Editable s) { if (s.length() != 0) { if (isFilterExists(s.toString().trim(), filterAdapter)) { String mtxt = mContext.getString(R.string.msgs_filter_list_duplicate_filter_specified); dlg_msg.setText(String.format(mtxt, s.toString().trim())); addbtn.setEnabled(false); dirbtn.setEnabled(true); btn_ok.setEnabled(true); } else { dlg_msg.setText(""); addbtn.setEnabled(true); dirbtn.setEnabled(false); btn_ok.setEnabled(false); } } else { addbtn.setEnabled(false); dirbtn.setEnabled(true); btn_ok.setEnabled(true); } // et_filter.setText(s); } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } }); addbtn.setEnabled(false); addbtn.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { dlg_msg.setText(""); String newfilter = et_filter.getText().toString(); if (isFilterExists(newfilter, filterAdapter)) { String mtxt = mContext.getString(R.string.msgs_filter_list_duplicate_filter_specified); dlg_msg.setText(String.format(mtxt, newfilter)); return; } dlg_msg.setText(""); et_filter.setText(""); if (filterAdapter.getItem(0).getFilter().startsWith("---")) filterAdapter.remove(filterAdapter.getItem(0)); filterAdapter.add(new FilterListItem(newfilter, true)); filterAdapter.setNotifyOnChange(true); filterAdapter.sort(new Comparator<FilterListItem>() { @Override public int compare(FilterListItem lhs, FilterListItem rhs) { return lhs.getFilter().compareToIgnoreCase(rhs.getFilter()); }; }); dirbtn.setEnabled(true); btn_ok.setEnabled(true); } }); // Directory? // if (getProfileType(prof_master,prof_dapter).equals("L")) { // if (!mGp.externalStorageIsMounted) dirbtn.setEnabled(false); // } else if (getProfileType(prof_master,prof_dapter).equals("R")) { // if (util.isRemoteDisable()) dirbtn.setEnabled(false); // } else dirbtn.setEnabled(false); dirbtn.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { NotifyEvent ntfy = new NotifyEvent(mContext); //Listen setRemoteShare response ntfy.setListener(new NotifyEventListener() { @Override public void positiveResponse(Context arg0, Object[] arg1) { dlg_msg.setText(""); } @Override public void negativeResponse(Context arg0, Object[] arg1) { if (arg1 != null) dlg_msg.setText((String) arg1[0]); else dlg_msg.setText(""); } }); listDirFilter(sti, prof_master, dir_filter, filterAdapter, ntfy); } }); // CANCEL? btn_cancel.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { dialog.dismiss(); // glblParms.profileListView.setSelectionFromTop(currentViewPosX,currentViewPosY); } }); // Cancel? dialog.setOnCancelListener(new Dialog.OnCancelListener() { @Override public void onCancel(DialogInterface arg0) { btn_cancel.performClick(); } }); // OK? btn_ok.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { dialog.dismiss(); dir_filter.clear(); if (filterAdapter.getCount() > 0) { for (int i = 0; i < filterAdapter.getCount(); i++) { if (!filterAdapter.getItem(i).isDeleted() && !filterAdapter.getItem(i).getFilter().startsWith("---")) { String inc = SMBSYNC_PROF_FILTER_EXCLUDE; if (filterAdapter.getItem(i).getInc()) inc = SMBSYNC_PROF_FILTER_INCLUDE; dir_filter.add(inc + filterAdapter.getItem(i).getFilter()); } } } p_ntfy.notifyToListener(true, null); } }); // dialog.setOnKeyListener(new DialogOnKeyListener(context)); // dialog.setCancelable(false); dialog.show(); }
From source file:com.sentaroh.android.SMBSync2.SyncTaskUtility.java
private void listDirFilterSMB(SyncTaskItem sti, String prof_master, final ArrayList<String> dir_filter, final AdapterFilterList fla, final NotifyEvent p_ntfy) { setSmbUserPass(sti.getMasterRemoteUserID(), sti.getMasterRemotePassword()); String t_remurl = ""; if (sti.getMasterRemoteHostname().equals("")) t_remurl = sti.getMasterRemoteAddr(); else// w w w . ja v a2 s . com t_remurl = sti.getMasterRemoteHostname(); String h_port = ""; if (!sti.getMasterRemotePassword().equals("")) h_port = ":" + sti.getMasterRemotePort(); final String remurl = "smb://" + t_remurl + h_port + "/" + sti.getMasterRemoteSmbShareName(); final String remdir = "/" + sti.getMasterDirectoryName() + "/"; NotifyEvent ntfy = new NotifyEvent(mContext); // set thread response ntfy.setListener(new NotifyEventListener() { @Override public void positiveResponse(Context c, Object[] o) { final ArrayList<TreeFilelistItem> rows = new ArrayList<TreeFilelistItem>(); @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_filter_list_dlg_add_dir_filter)); subtitle.setText(mContext.getString(R.string.msgs_current_dir) + " " + remurl + remdir); final TextView dlg_msg = (TextView) dialog.findViewById(R.id.item_select_list_dlg_msg); final LinearLayout ll_context = (LinearLayout) dialog.findViewById(R.id.context_view_file_select); ll_context.setVisibility(LinearLayout.VISIBLE); final ImageButton ib_select_all = (ImageButton) ll_context .findViewById(R.id.context_button_select_all); final ImageButton ib_unselect_all = (ImageButton) ll_context .findViewById(R.id.context_button_unselect_all); final Button btn_ok = (Button) dialog.findViewById(R.id.item_select_list_dlg_ok_btn); dlg_msg.setVisibility(TextView.VISIBLE); // 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, false, false); tfa.setDataList(rows); lv.setAdapter(tfa); lv.setScrollingCacheEnabled(false); lv.setScrollbarFadingEnabled(false); // lv.setFastScrollEnabled(true); ib_select_all.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { for (int i = 0; i < tfa.getDataItemCount(); i++) { TreeFilelistItem tfli = tfa.getDataItem(i); if (!tfli.isHideListItem()) tfa.setDataItemIsSelected(i); } tfa.notifyDataSetChanged(); btn_ok.setEnabled(true); } }); ib_unselect_all.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { for (int i = 0; i < tfa.getDataItemCount(); i++) { tfa.setDataItemIsUnselected(i); } tfa.notifyDataSetChanged(); btn_ok.setEnabled(false); } }); 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); final TreeFilelistItem tfi = tfa.getDataItem(t_pos); if (tfi.getName().startsWith("---")) return true; if (!tfa.getDataItem(t_pos).isChecked()) { tfa.setDataItemIsSelected(t_pos); } return true; } }); //OK? btn_ok.setEnabled(false); NotifyEvent ntfy = new NotifyEvent(mContext); //Listen setRemoteShare response ntfy.setListener(new NotifyEventListener() { @Override public void positiveResponse(Context arg0, Object[] arg1) { btn_ok.setEnabled(true); } @Override public void negativeResponse(Context arg0, Object[] arg1) { if (tfa.isDataItemIsSelected()) btn_ok.setEnabled(true); else btn_ok.setEnabled(false); } }); tfa.setCbCheckListener(ntfy); btn_ok.setText(mContext.getString(R.string.msgs_filter_list_dlg_add)); btn_ok.setVisibility(Button.VISIBLE); btn_ok.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { if (!addDirFilter(true, tfa, fla, remdir, dlg_msg)) return; addDirFilter(false, tfa, fla, remdir, dlg_msg); dialog.dismiss(); p_ntfy.notifyToListener(true, null); } }); //CANCEL? final Button btn_cancel = (Button) dialog.findViewById(R.id.item_select_list_dlg_cancel_btn); btn_cancel.setText(mContext.getString(R.string.msgs_filter_list_dlg_close)); btn_cancel.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { dialog.dismiss(); p_ntfy.notifyToListener(true, 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, remdir, ntfy, true); }
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/*from ww w .j a v a 2s. c o m*/ 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.sentaroh.android.SMBSync2.SyncTaskUtility.java
private void selectImportProfileItem(final AdapterSyncTask tfl, final NotifyEvent p_ntfy) { final Dialog dialog = new Dialog(mContext); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setContentView(R.layout.export_import_profile_dlg); dialog.setCanceledOnTouchOutside(false); LinearLayout ll_dlg_view = (LinearLayout) dialog.findViewById(R.id.export_import_profile_view); ll_dlg_view.setBackgroundColor(mGp.themeColorList.dialog_msg_background_color); ArrayList<ExportImportProfileListItem> eipl = new ArrayList<ExportImportProfileListItem>(); for (int i = 0; i < tfl.getCount(); i++) { SyncTaskItem pl = tfl.getItem(i); ExportImportProfileListItem eipli = new ExportImportProfileListItem(); eipli.isChecked = true;//from w w w.j a v a 2 s. c o m eipli.item_name = pl.getSyncTaskName(); eipl.add(eipli); } // Collections.sort(eipl, new Comparator<ExportImportProfileListItem>(){ // @Override // public int compare(ExportImportProfileListItem arg0, // ExportImportProfileListItem arg1) { // if (arg0.item_name.equals(arg1.item_name)) return arg0.item_type.compareToIgnoreCase(arg1.item_type); // return arg0.item_name.compareToIgnoreCase(arg1.item_name); // } // }); // ExportImportProfileListItem eipli=new ExportImportProfileListItem(); // eipli.isChecked=true; // eipli.item_type="*"; // eipli.item_name=mContext.getString(R.string.msgs_export_import_profile_setting_parms); // eipl.add(eipli); final AdapterExportImportSyncTask imp_list_adapt = new AdapterExportImportSyncTask(mContext, R.layout.export_import_profile_list_item, eipl); ListView lv = (ListView) dialog.findViewById(R.id.export_import_profile_listview); lv.setAdapter(imp_list_adapt); CommonDialog.setDlgBoxSizeLimit(dialog, true); final LinearLayout title_view = (LinearLayout) dialog.findViewById(R.id.export_import_profile_title_view); final TextView title = (TextView) dialog.findViewById(R.id.export_import_profile_title); title_view.setBackgroundColor(mGp.themeColorList.dialog_title_background_color); title.setTextColor(mGp.themeColorList.text_color_dialog_title); title.setText(mContext.getString(R.string.msgs_export_import_profile_title)); // TextView tv_msgx=(TextView)dialog.findViewById(R.id.export_import_profile_msg); // tv_msgx.setVisibility(LinearLayout.GONE); LinearLayout ll_filelist = (LinearLayout) dialog.findViewById(R.id.export_import_profile_file_list); ll_filelist.setVisibility(LinearLayout.GONE); final Button ok_btn = (Button) dialog.findViewById(R.id.export_import_profile_dlg_btn_ok); Button cancel_btn = (Button) dialog.findViewById(R.id.export_import_profile_dlg_btn_cancel); final Button rb_select_all = (Button) dialog.findViewById(R.id.export_import_profile_list_select_all); final Button rb_unselect_all = (Button) dialog.findViewById(R.id.export_import_profile_list_unselect_all); final CheckedTextView ctv_reset_profile = (CheckedTextView) dialog .findViewById(R.id.export_import_profile_list_ctv_reset_profile); final CheckedTextView ctv_import_settings = (CheckedTextView) dialog .findViewById(R.id.export_import_profile_list_ctv_import_settings); final CheckedTextView ctv_import_schedule = (CheckedTextView) dialog .findViewById(R.id.export_import_profile_list_ctv_import_schedule); ctv_reset_profile.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { ((CheckedTextView) v).toggle(); setImportOkBtnEnabled(ctv_reset_profile, ctv_import_settings, ctv_import_schedule, imp_list_adapt, ok_btn); } }); ctv_import_settings.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { ((CheckedTextView) v).toggle(); setImportOkBtnEnabled(ctv_reset_profile, ctv_import_settings, ctv_import_schedule, imp_list_adapt, ok_btn); } }); ctv_import_schedule.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { ((CheckedTextView) v).toggle(); setImportOkBtnEnabled(ctv_reset_profile, ctv_import_settings, ctv_import_schedule, imp_list_adapt, ok_btn); } }); ctv_import_settings.setChecked(true); ctv_import_schedule.setChecked(true); lv.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View arg1, int pos, long arg3) { // imp_list_adapt.getItem(pos).isChecked=!imp_list_adapt.getItem(pos).isChecked; // imp_list_adapt.notifyDataSetChanged(); // if (imp_list_adapt.isItemSelected()) { // ok_btn.setEnabled(true); // } else { // ok_btn.setEnabled(false); // } setImportOkBtnEnabled(ctv_reset_profile, ctv_import_settings, ctv_import_schedule, imp_list_adapt, ok_btn); } }); // lv.setOnItemLongClickListener(new OnItemLongClickListener(){ // @Override // public boolean onItemLongClick(AdapterView<?> arg0, View arg1, // int pos, long arg3) { // ccMenu.addMenuItem( // mContext.getString(R.string.msgs_export_import_profile_select_all),R.drawable.blank) // .setOnClickListener(new CustomContextMenuOnClickListener() { // @Override // final public void onClick(CharSequence menuTitle) { // for (int i=0;i<imp_list_adapt.getCount();i++) // imp_list_adapt.getItem(i).isChecked=true; // imp_list_adapt.notifyDataSetChanged(); // ok_btn.setEnabled(true); // } // }); // ccMenu.addMenuItem( // mContext.getString(R.string.msgs_export_import_profile_unselect_all),R.drawable.blank) // .setOnClickListener(new CustomContextMenuOnClickListener() { // @Override // final public void onClick(CharSequence menuTitle) { // for (int i=0;i<imp_list_adapt.getCount();i++) // imp_list_adapt.getItem(i).isChecked=false; // imp_list_adapt.notifyDataSetChanged(); // ok_btn.setEnabled(false); // } // }); // ccMenu.createMenu(); // return false; // } // }); rb_select_all.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { for (int i = 0; i < imp_list_adapt.getCount(); i++) imp_list_adapt.getItem(i).isChecked = true; ctv_import_settings.setChecked(true); ctv_import_schedule.setChecked(true); imp_list_adapt.notifyDataSetChanged(); ok_btn.setEnabled(true); } }); rb_unselect_all.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { for (int i = 0; i < imp_list_adapt.getCount(); i++) imp_list_adapt.getItem(i).isChecked = false; ctv_import_settings.setChecked(false); ctv_import_schedule.setChecked(false); imp_list_adapt.notifyDataSetChanged(); ok_btn.setEnabled(false); } }); NotifyEvent ntfy_ctv_listener = new NotifyEvent(mContext); ntfy_ctv_listener.setListener(new NotifyEventListener() { @Override public void positiveResponse(Context c, Object[] o) { // if (imp_list_adapt.isItemSelected()) { // ok_btn.setEnabled(true); // } else { // if (ctv_import_settings.isChecked()) ok_btn.setEnabled(true); // else ok_btn.setEnabled(false); // } setImportOkBtnEnabled(ctv_reset_profile, ctv_import_settings, ctv_import_schedule, imp_list_adapt, ok_btn); } @Override public void negativeResponse(Context c, Object[] o) { } }); imp_list_adapt.setCheckButtonListener(ntfy_ctv_listener); ok_btn.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { if (ctv_reset_profile.isChecked()) mGp.syncTaskAdapter.clear(); importSelectedSyncTaskItem(imp_list_adapt, tfl, ctv_import_settings.isChecked(), ctv_import_schedule.isChecked(), p_ntfy); dialog.dismiss(); } }); cancel_btn.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { dialog.dismiss(); } }); dialog.show(); }
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()]; }// w ww . j a v a 2 s . com @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;//from w ww . j av a 2s . co 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")); }