List of usage examples for android.app Dialog getWindow
public @Nullable Window getWindow()
From source file:de.bogutzky.psychophysiocollector.app.MainActivity.java
private void showGraph(String bluetoothDeviceAddress, int requestCode, int which) { int beginAtField = 0; GraphView graphView = null;/* w w w. j a v a2 s . c o m*/ Dialog dialog = null; switch (requestCode) { case REQUEST_MAIN_COMMAND_SHIMMER: beginAtField = 1; switch (which) { case 1: beginAtField = 4; break; } graphView = new GraphView(this, beginAtField); if (this.shimmerImuService != null) { if (!isSessionStarted) this.startStreamingOfAllShimmerImus(false); this.shimmerImuService.startDataVisualization(bluetoothDeviceAddress, graphView); } dialog = new Dialog(this); dialog.setOnDismissListener(new DialogInterface.OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { if (shimmerImuService != null) { shimmerImuService.stopDataVisualization(); } if (!isSessionStarted) { stopAllStreamingOfAllShimmerImus(); } } }); break; case REQUEST_MAIN_COMMAND_BIOHARNESS: graphView = new GraphView(this, beginAtField); if (this.bioHarnessService != null) { this.bioHarnessService.startDataVisualization(graphView); } dialog = new Dialog(this); dialog.setOnDismissListener(new DialogInterface.OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { if (bioHarnessService != null) { bioHarnessService.stopDataVisualization(); } } }); break; } assert dialog != null; dialog.setContentView(graphView); dialog.setTitle(getString(R.string.graph)); dialog.setCancelable(true); WindowManager.LayoutParams lp = new WindowManager.LayoutParams(); lp.copyFrom(dialog.getWindow().getAttributes()); lp.width = WindowManager.LayoutParams.MATCH_PARENT; lp.height = WindowManager.LayoutParams.MATCH_PARENT; dialog.getWindow().setAttributes(lp); dialog.show(); }
From source file:com.mitre.holdshort.MainActivity.java
private void showNotSupportedDialog(String airport) { final Dialog dialog = new Dialog(MainActivity.this); OnCancelListener notSupportedCancelListener = null; notSupportedCancelListener = new OnCancelListener() { @Override//from w w w. j av a2s . co m public void onCancel(DialogInterface dialog) { dialog.dismiss(); finish(); } }; OnClickListener noAirportClickListener = new OnClickListener() { @Override public void onClick(View v) { switch (v.getId()) { case R.id.exit: dialog.dismiss(); finish(); break; case R.id.contactMitre: Log.d(LOG_TAG, "TEST"); contactMITRE("RIPPLE App Support"); case R.id.uploadData: AlertLogger al = new AlertLogger("999", MainActivity.this); default: return; } } }; if (airport == null) { dialog.setOnCancelListener(notSupportedCancelListener); dialog.setContentView(R.layout.no_airport_found_dialog); dialog.setTitle("No Airport Found!"); dialog.getWindow().setLayout(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); Button exit = (Button) dialog.findViewById(R.id.exit); Button contact = (Button) dialog.findViewById(R.id.contactMitre); Button uploadData = (Button) dialog.findViewById(R.id.uploadData); contact.setOnClickListener(noAirportClickListener); exit.setOnClickListener(noAirportClickListener); uploadData.setOnClickListener(noAirportClickListener); dialog.show(); } else { dialog.setOnCancelListener(notSupportedCancelListener); dialog.setContentView(R.layout.airport_not_supported_dialog); dialog.setTitle("Airport " + (airport.split("_"))[0] + " Not Supported"); dialog.getWindow().setLayout(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); Button exit = (Button) dialog.findViewById(R.id.exit); Button contact = (Button) dialog.findViewById(R.id.contactMitre); contact.setOnClickListener(noAirportClickListener); exit.setOnClickListener(noAirportClickListener); dialog.show(); } }
From source file:org.anurag.file.quest.TaskerActivity.java
/** * FUNCTION MAKE 3d LIST VIEW VISIBLE OR GONE AS PER REQUIREMENT * @param mode/*from ww w .ja va 2s .com*/ * @param con */ public static void load_FIle_Gallery(final int mode) { final Dialog pDialog = new Dialog(mContext, R.style.custom_dialog_theme); final Handler handle = new Handler() { @Override public void handleMessage(Message msg) { switch (msg.what) { case 0: try { pDialog.setContentView(R.layout.p_dialog); pDialog.setCancelable(false); pDialog.getWindow().getAttributes().width = size.x * 4 / 5; WebView web = (WebView) pDialog.findViewById(R.id.p_Web_View); web.loadUrl("file:///android_asset/Progress_Bar_HTML/index.html"); web.setEnabled(false); pDialog.show(); } catch (InflateException e) { error = true; Toast.makeText(mContext, "An exception encountered please wait while loading" + " file list", Toast.LENGTH_SHORT).show(); } break; case 1: if (pDialog != null) if (pDialog.isShowing()) pDialog.dismiss(); if (mediaFileList.size() > 0) { FILE_GALLEY.setVisibility(View.GONE); LIST_VIEW_3D.setVisibility(View.VISIBLE); element = new MediaElementAdapter(mContext, R.layout.row_list_1, mediaFileList); //AT THE PLACE OF ELEMENT YOU CAN USE MUSIC ADAPTER.... // AND SEE WHAT HAPPENS if (mediaFileList.size() > 0) { LIST_VIEW_3D.setAdapter(element); LIST_VIEW_3D.setEnabled(true); } else if (mediaFileList.size() == 0) { LIST_VIEW_3D.setAdapter(new EmptyAdapter(mContext, R.layout.row_list_3, EMPTY)); LIST_VIEW_3D.setEnabled(false); } LIST_VIEW_3D.setDynamics(new SimpleDynamics(0.7f, 0.6f)); if (!elementInFocus) { mFlipperBottom.showPrevious(); mFlipperBottom.setAnimation(prevAnim()); elementInFocus = true; } if (SEARCH_FLAG) { mVFlipper.showPrevious(); mVFlipper.setAnimation(nextAnim()); } } else { LIST_VIEW_3D.setVisibility(View.GONE); FILE_GALLEY.setVisibility(View.VISIBLE); Toast.makeText(mContext, R.string.empty, Toast.LENGTH_SHORT).show(); if (elementInFocus) { mFlipperBottom.showNext(); mFlipperBottom.setAnimation(nextAnim()); } elementInFocus = false; } break; } } }; Thread thread = new Thread(new Runnable() { @Override public void run() { // TODO Auto-generated method stub handle.sendEmptyMessage(0); while (!Utils.loaded) { //STOPPING HERE WHILE FILES ARE BEING LOADED IN BACKGROUND.... } if (mode == 0) mediaFileList = Utils.music; else if (mode == 1) mediaFileList = Utils.apps; else if (mode == 2) mediaFileList = Utils.doc; else if (mode == 3) mediaFileList = Utils.img; else if (mode == 4) mediaFileList = Utils.vids; else if (mode == 5) mediaFileList = Utils.zip; else if (mode == 6) mediaFileList = Utils.mis; handle.sendEmptyMessage(1); } }); thread.start(); }
From source file:com.hughes.android.dictionary.DictionaryActivity.java
@Override public boolean onCreateOptionsMenu(final Menu menu) { if (PreferenceManager.getDefaultSharedPreferences(this) .getBoolean(getString(R.string.showPrevNextButtonsKey), true)) { // Next word. nextWordMenuItem = menu.add(getString(R.string.nextWord)).setIcon(R.drawable.arrow_down_float); MenuItemCompat.setShowAsAction(nextWordMenuItem, MenuItem.SHOW_AS_ACTION_IF_ROOM); nextWordMenuItem.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override//from ww w . j ava 2 s. c o m public boolean onMenuItemClick(MenuItem item) { onUpDownButton(false); return true; } }); // Previous word. previousWordMenuItem = menu.add(getString(R.string.previousWord)).setIcon(R.drawable.arrow_up_float); MenuItemCompat.setShowAsAction(previousWordMenuItem, MenuItem.SHOW_AS_ACTION_IF_ROOM); previousWordMenuItem.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { onUpDownButton(true); return true; } }); } randomWordMenuItem = menu.add(getString(R.string.randomWord)); randomWordMenuItem.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { onRandomWordButton(); return true; } }); application.onCreateGlobalOptionsMenu(this, menu); { final MenuItem dictionaryManager = menu.add(getString(R.string.dictionaryManager)); MenuItemCompat.setShowAsAction(dictionaryManager, MenuItem.SHOW_AS_ACTION_NEVER); dictionaryManager.setOnMenuItemClickListener(new OnMenuItemClickListener() { public boolean onMenuItemClick(final MenuItem menuItem) { startActivity(DictionaryManagerActivity.getLaunchIntent(getApplicationContext())); finish(); return false; } }); } { final MenuItem aboutDictionary = menu.add(getString(R.string.aboutDictionary)); MenuItemCompat.setShowAsAction(aboutDictionary, MenuItem.SHOW_AS_ACTION_NEVER); aboutDictionary.setOnMenuItemClickListener(new OnMenuItemClickListener() { public boolean onMenuItemClick(final MenuItem menuItem) { final Context context = getListView().getContext(); final Dialog dialog = new Dialog(context); dialog.setContentView(R.layout.about_dictionary_dialog); final TextView textView = (TextView) dialog.findViewById(R.id.text); final String name = application.getDictionaryName(dictFile.getName()); dialog.setTitle(name); final StringBuilder builder = new StringBuilder(); final DictionaryInfo dictionaryInfo = dictionary.getDictionaryInfo(); dictionaryInfo.uncompressedBytes = dictFile.length(); if (dictionaryInfo != null) { builder.append(dictionaryInfo.dictInfo).append("\n\n"); builder.append(getString(R.string.dictionaryPath, dictFile.getPath())).append("\n"); builder.append(getString(R.string.dictionarySize, dictionaryInfo.uncompressedBytes)) .append("\n"); builder.append(getString(R.string.dictionaryCreationTime, dictionaryInfo.creationMillis)) .append("\n"); for (final IndexInfo indexInfo : dictionaryInfo.indexInfos) { builder.append("\n"); builder.append(getString(R.string.indexName, indexInfo.shortName)).append("\n"); builder.append(getString(R.string.mainTokenCount, indexInfo.mainTokenCount)) .append("\n"); } builder.append("\n"); builder.append(getString(R.string.sources)).append("\n"); for (final EntrySource source : dictionary.sources) { builder.append(getString(R.string.sourceInfo, source.getName(), source.getNumEntries())) .append("\n"); } } textView.setText(builder.toString()); dialog.show(); final WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams(); layoutParams.width = WindowManager.LayoutParams.MATCH_PARENT; layoutParams.height = WindowManager.LayoutParams.MATCH_PARENT; dialog.getWindow().setAttributes(layoutParams); return false; } }); } return true; }
From source file:com.xplink.android.carchecklist.CarCheckListActivity.java
public void getSettingShared() { SharedPreferences mSharedPrefs = getSharedPreferences("mysettings", Context.MODE_PRIVATE); final Dialog settingdialog = new Dialog(CarCheckListActivity.this, R.style.backgrounddialog); settingdialog.requestWindowFeature(Window.FEATURE_NO_TITLE); settingdialog.setContentView(R.layout.settingdialoglayout); final SeekBar powerseekbar = (SeekBar) settingdialog.getWindow().findViewById(R.id.Powerbar); final SeekBar engineseekbar = (SeekBar) settingdialog.getWindow().findViewById(R.id.Enginebar); final SeekBar exteriorseekbar = (SeekBar) settingdialog.getWindow().findViewById(R.id.Exteriorbar); final SeekBar interiorseekbar = (SeekBar) settingdialog.getWindow().findViewById(R.id.Interiorbar); final SeekBar documentseekbar = (SeekBar) settingdialog.getWindow().findViewById(R.id.Documentbar); // seekbar.putInt("Powerbar", powerseekbarValue).commit(); // powerseekbar.setProgress(4); // Log.i("seek", "setProgress(4)"); engineseekbar.setProgress(mSharedPrefs.getInt("Enginebar", 0)); exteriorseekbar.setProgress(mSharedPrefs.getInt("Exteriorbar", 0)); interiorseekbar.setProgress(mSharedPrefs.getInt("Interiorbar", 0)); documentseekbar.setProgress(mSharedPrefs.getInt("Documentbar", 0)); }
From source file:com.xplink.android.carchecklist.CarCheckListActivity.java
public void filterStore(String menuName, Map<String, Boolean> mp) { // progressCheckListMemo(); SharedPreferences sharedPreferences = getSharedPreferences("mysettings", Context.MODE_PRIVATE); SharedPreferences.Editor editor = sharedPreferences.edit(); String tmp = ""; // Log.i("filter", "infileter : " + menuName); for (Map.Entry<String, Boolean> entry : mp.entrySet()) { editor.putBoolean(entry.getKey(), entry.getValue()); editor.commit();// w w w.j a v a 2 s. c om String result = (entry.getValue()) ? "t" : "f"; tmp += entry.getKey() + "-" + result + ","; } final Dialog settingdialog = new Dialog(CarCheckListActivity.this, R.style.backgrounddialog); settingdialog.requestWindowFeature(Window.FEATURE_NO_TITLE); settingdialog.setContentView(R.layout.settingdialoglayout); final SeekBar powerSeekbar = (SeekBar) settingdialog.getWindow().findViewById(R.id.Powerbar); final SeekBar engineSeekbar = (SeekBar) settingdialog.getWindow().findViewById(R.id.Enginebar); final SeekBar exteriorSeekbar = (SeekBar) settingdialog.getWindow().findViewById(R.id.Exteriorbar); final SeekBar interiorSeekbar = (SeekBar) settingdialog.getWindow().findViewById(R.id.Interiorbar); final SeekBar documentSeekbar = (SeekBar) settingdialog.getWindow().findViewById(R.id.Documentbar); tmp = tmp.substring(0, tmp.length() - 1); // Log.i("store", menuName + " : " + tmp); editor.putString(menuName, tmp); Log.i("checknum", "CHECKNUM IN FILTERSTORE : " + Checknum); editor.putInt("checknum", Checknum); editor.putInt("percentRatio", PercenRatio); intent.putExtra(menuName, tmp); editor.commit(); String checklistInMem = sharedPreferences.getString(menuName, ""); Log.i("inmem", "*** " + checklistInMem); editor.putInt("checknum", Checknum); editor.commit(); // CHECK // ------------------------------------------------------------------------------------ // checkBug("ON CANCEL "); editor.putInt("PercenPower", PercenPower); editor.putInt("PercenEngine", PercenEngine); editor.putInt("PercenExterior", PercenExterior); editor.putInt("PercenInterior", PercenInterior); editor.putInt("PercenDocument", PercenDocument); editor.commit(); }
From source file:com.nttec.everychan.ui.presentation.BoardFragment.java
private void openReferencesList(final String from) { final List<Integer> positions = new ArrayList<>(); int position = -1; for (int i = 0; i < presentationModel.presentationList.size(); ++i) { if (presentationModel.presentationList.get(i).sourceModel.number.equals(from)) { position = i;/* www.ja v a 2 s. co m*/ break; } } if (position != -1) { Spanned referencesString = presentationModel.presentationList.get(position).referencesString; if (referencesString == null) { Logger.e(TAG, "null referencesString"); return; } ClickableURLSpan[] spans = referencesString.getSpans(0, referencesString.length(), ClickableURLSpan.class); for (ClickableURLSpan span : spans) { String url = span.getURL(); try { //url , .. ??? PresentationItemModel ( ) UrlPageModel model = UrlHandler.getPageModel(url); for (; position < presentationModel.presentationList.size(); ++position) { if (presentationModel.presentationList.get(position).sourceModel.number .equals(model.postNumber)) { break; } } if (position < presentationModel.presentationList.size()) positions.add(position); } catch (Exception e) { Logger.e(TAG, e); } } } if (positions.size() == 0) { Logger.e(TAG, "no references"); return; } final int bgShadowResource = ThemeUtils.getThemeResId(activity.getTheme(), R.attr.dialogBackgroundShadow); final int bgColor = ThemeUtils.getThemeColor(activity.getTheme(), R.attr.activityRootBackground, Color.BLACK); 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(); ListView dlgList = new ListView(activity); dlgList.setAdapter(new ArrayAdapter<Integer>(activity, 0, positions) { @Override public View getView(int position, View convertView, ViewGroup parent) { try { int adapterPositon = getItem(position); View view = adapter.getView(adapterPositon, convertView, parent, dlgWidth, adapter.getItem(adapterPositon), from); view.setBackgroundColor(bgColor); return view; } catch (Exception e) { Logger.e(TAG, e); Toast.makeText(activity, R.string.error_unknown, Toast.LENGTH_LONG).show(); return new View(activity); } } }); Dialog dialog = new Dialog(activity); 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.nttec.everychan.ui.presentation.BoardFragment.java
/** * ? ? ?//from w w w. ja va 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);//from www .j a v a2s.co 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.xplink.android.carchecklist.CarCheckListActivity.java
private void SlideExteriorLayout() { final SharedPreferences settings = getSharedPreferences("mysettings", 0); final SharedPreferences.Editor editor = settings.edit(); final Dialog exteriordialog = new Dialog(CarCheckListActivity.this, R.style.backgrounddialog); exteriordialog.requestWindowFeature(Window.FEATURE_NO_TITLE); exteriordialog.setContentView(R.layout.exteriordialoglayout); exteriordialog.getWindow().getAttributes().windowAnimations = R.style.ExteriorDialogAnimation; exteriordialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT)); // make everything around Dialog brightness than default WindowManager.LayoutParams lp = exteriordialog.getWindow().getAttributes(); lp.dimAmount = 0f;/*from w w w. j a v a 2s. c o m*/ final CheckBox chkoutside_color = (CheckBox) exteriordialog.getWindow().findViewById(R.id.outside_color); final CheckBox chkoutside_window = (CheckBox) exteriordialog.getWindow().findViewById(R.id.outside_window); final CheckBox chkoutside_doorHood = (CheckBox) exteriordialog.getWindow() .findViewById(R.id.outside_doorHood); final CheckBox chkoutside_jack = (CheckBox) exteriordialog.getWindow().findViewById(R.id.outside_jack); final CheckBox chkoutside_wrench = (CheckBox) exteriordialog.getWindow().findViewById(R.id.outside_wrench); final CheckBox chkoutside_tires = (CheckBox) exteriordialog.getWindow().findViewById(R.id.outside_tires); final CheckBox chkoutside_light = (CheckBox) exteriordialog.getWindow().findViewById(R.id.outside_light); final CheckBox chkoutside_seal = (CheckBox) exteriordialog.getWindow().findViewById(R.id.outside_seal); final CheckBox chkoutside_tirePart = (CheckBox) exteriordialog.getWindow() .findViewById(R.id.outside_tirePart); // Change font chkoutside_color.setTypeface(type); chkoutside_window.setTypeface(type); chkoutside_doorHood.setTypeface(type); chkoutside_jack.setTypeface(type); chkoutside_wrench.setTypeface(type); chkoutside_tires.setTypeface(type); chkoutside_light.setTypeface(type); chkoutside_seal.setTypeface(type); chkoutside_tirePart.setTypeface(type); exteriordialog.setCanceledOnTouchOutside(true); exteriordialog.setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { headexterior.setVisibility(ImageView.VISIBLE); TranslateAnimation slideoutheadexterior = new TranslateAnimation(0, 0, 380, -400); slideoutheadexterior.setDuration(500); slideoutheadexterior.setFillAfter(true); headexterior.startAnimation(slideoutheadexterior); Map<String, Boolean> mp = new HashMap<String, Boolean>(); mp.put("outside_color", chkoutside_color.isChecked()); mp.put("outside_window", chkoutside_window.isChecked()); mp.put("outside_doorHood", chkoutside_doorHood.isChecked()); mp.put("outside_jack", chkoutside_jack.isChecked()); mp.put("outside_wrench", chkoutside_wrench.isChecked()); mp.put("outside_tires", chkoutside_tires.isChecked()); mp.put("outside_light", chkoutside_light.isChecked()); mp.put("outside_seal", chkoutside_seal.isChecked()); mp.put("outside_tirePart", chkoutside_tirePart.isChecked()); filterStore("exterior", mp); save(mp); } }); TextView exterior = (TextView) exteriordialog.getWindow().findViewById(R.id.Exterior); exterior.setTypeface(type); Button exteriorback = (Button) exteriordialog.getWindow().findViewById(R.id.Exteriorback); exteriorback.setTypeface(type); exteriorback.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { exteriordialog.dismiss(); headexterior.setVisibility(ImageView.VISIBLE); TranslateAnimation slideoutheadexterior = new TranslateAnimation(0, 0, 380, -400); slideoutheadexterior.setDuration(500); slideoutheadexterior.setFillAfter(true); headexterior.startAnimation(slideoutheadexterior); Map<String, Boolean> mp = new HashMap<String, Boolean>(); mp.put("outside_color", chkoutside_color.isChecked()); mp.put("outside_window", chkoutside_window.isChecked()); mp.put("outside_doorHood", chkoutside_doorHood.isChecked()); mp.put("outside_jack", chkoutside_jack.isChecked()); mp.put("outside_wrench", chkoutside_wrench.isChecked()); mp.put("outside_tires", chkoutside_tires.isChecked()); mp.put("outside_light", chkoutside_light.isChecked()); mp.put("outside_seal", chkoutside_seal.isChecked()); mp.put("outside_tirePart", chkoutside_tirePart.isChecked()); filterStore("exterior", mp); save(mp); } }); chkoutside_color.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalExterior(increment); } else { increment = false; getTotalExterior(increment); } ExteriorProgress.setProgress(PercenExterior); percenexterior.setText("" + PercenExterior + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); chkoutside_window.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalExterior(increment); } else { increment = false; getTotalExterior(increment); } ExteriorProgress.setProgress(PercenExterior); percenexterior.setText("" + PercenExterior + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); chkoutside_doorHood.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalExterior(increment); } else { increment = false; getTotalExterior(increment); } ExteriorProgress.setProgress(PercenExterior); percenexterior.setText("" + PercenExterior + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); chkoutside_jack.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalExterior(increment); } else { increment = false; getTotalExterior(increment); } ExteriorProgress.setProgress(PercenExterior); percenexterior.setText("" + PercenExterior + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); chkoutside_wrench.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalExterior(increment); } else { increment = false; getTotalExterior(increment); } ExteriorProgress.setProgress(PercenExterior); percenexterior.setText("" + PercenExterior + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); chkoutside_tires.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalExterior(increment); } else { increment = false; getTotalExterior(increment); } ExteriorProgress.setProgress(PercenExterior); percenexterior.setText("" + PercenExterior + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); chkoutside_light.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalExterior(increment); } else { increment = false; getTotalExterior(increment); } ExteriorProgress.setProgress(PercenExterior); percenexterior.setText("" + PercenExterior + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); chkoutside_seal.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalExterior(increment); } else { increment = false; getTotalExterior(increment); } ExteriorProgress.setProgress(PercenExterior); percenexterior.setText("" + PercenExterior + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); chkoutside_tirePart.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalExterior(increment); } else { increment = false; getTotalExterior(increment); } ExteriorProgress.setProgress(PercenExterior); percenexterior.setText("" + PercenExterior + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); headexterior.setVisibility(ImageView.VISIBLE); TranslateAnimation slideheadexterior = new TranslateAnimation(0, 0, 0, 380); slideheadexterior.setDuration(500); slideheadexterior.setFillAfter(true); headexterior.startAnimation(slideheadexterior); exteriordialog.show(); WindowManager.LayoutParams params = exteriordialog.getWindow().getAttributes(); params.y = 0; params.x = 60; params.gravity = Gravity.TOP | Gravity.LEFT; exteriordialog.getWindow().setAttributes(params); chkoutside_color.setChecked(load("outside_color")); chkoutside_window.setChecked(load("outside_window")); chkoutside_doorHood.setChecked(load("outside_doorHood")); chkoutside_jack.setChecked(load("outside_jack")); chkoutside_wrench.setChecked(load("outside_wrench")); chkoutside_tires.setChecked(load("outside_tires")); chkoutside_light.setChecked(load("outside_light")); chkoutside_seal.setChecked(load("outside_seal")); chkoutside_tirePart.setChecked(load("outside_tirePart")); }