List of usage examples for android.content Context WINDOW_SERVICE
String WINDOW_SERVICE
To view the source code for android.content Context WINDOW_SERVICE.
Click Source Link
From source file:jp.co.ipublishing.esnavi.views.MarqueeView.java
/** * ??//from w ww . java2s .co m * * @param measureSpec * @return */ private int measureWidth(int measureSpec) { final int result; final int specMode = MeasureSpec.getMode(measureSpec); final int specSize = MeasureSpec.getSize(measureSpec); if (specMode == MeasureSpec.EXACTLY) { // We were told how big to be result = specSize; } else { final WindowManager wm = (WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE); final Display display = wm.getDefaultDisplay(); result = display.getWidth(); } return result; }
From source file:com.autoparts.buyers.activity.InquiryModelActivity.java
private void initOverlay() { letterListView = (MyLetterListView) findViewById(R.id.MyLetterListView); letterListView.setOnTouchingLetterChangedListener(new LetterListViewListener()); overlayThread = new OverlayThread(); handler = new Handler(); LayoutInflater inflater = LayoutInflater.from(this); overlayView = inflater.inflate(R.layout.contact_overlay, null); overlay = (TextView) overlayView.findViewById(R.id.mTextView); overlayView.setVisibility(View.INVISIBLE); WindowManager.LayoutParams lp = new WindowManager.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.TYPE_APPLICATION, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE, PixelFormat.TRANSLUCENT);/*from w w w .j a v a 2 s .c om*/ WindowManager windowManager = (WindowManager) this.getSystemService(Context.WINDOW_SERVICE); windowManager.addView(overlayView, lp); }
From source file:org.openhab.habdroid.ui.OpenHABWidgetSettingsAdapter.java
@Override public View getView(int position, View convertView, ViewGroup parent) { /* TODO: This definitely needs some huge refactoring *///from w w w . j a v a2 s . c o m final int pos = position; RelativeLayout widgetView; TextView labelTextView; ImageView roomEditView; int widgetLayout = 0; OpenHABWidget openHABWidget = getItem(position); switch (this.getItemViewType(position)) { case TYPE_FRAME: widgetLayout = R.layout.openhabwidgetlist_frameitem; break; case TYPE_GROUP: widgetLayout = R.layout.openhabwidget_settings_item; break; case TYPE_IMAGE: widgetLayout = R.layout.openhabwidgetlist_imageitem; break; case TYPE_CHART: widgetLayout = R.layout.openhabwidgetlist_chartitem; break; case TYPE_VIDEO: widgetLayout = R.layout.openhabwidgetlist_videoitem; break; case TYPE_WEB: widgetLayout = R.layout.openhabwidgetlist_webitem; break; default: widgetLayout = R.layout.openhabwidget_settings_item; break; } if (convertView == null) { widgetView = new RelativeLayout(getContext()); String inflater = Context.LAYOUT_INFLATER_SERVICE; LayoutInflater vi; vi = (LayoutInflater) getContext().getSystemService(inflater); vi.inflate(widgetLayout, widgetView, true); } else { widgetView = (RelativeLayout) convertView; } switch (getItemViewType(position)) { case TYPE_FRAME: labelTextView = (TextView) widgetView.findViewById(R.id.framelabel); if (labelTextView != null) labelTextView.setText(openHABWidget.getLabel()); widgetView.setClickable(false); if (openHABWidget.getLabel().length() > 0) { // hide empty frames widgetView.setVisibility(View.VISIBLE); labelTextView.setVisibility(View.VISIBLE); } else { widgetView.setVisibility(View.GONE); labelTextView.setVisibility(View.GONE); } break; case TYPE_IMAGE: MySmartImageView imageImage = (MySmartImageView) widgetView.findViewById(R.id.imageimage); imageImage.setImageUrl(ensureAbsoluteURL(openHABBaseUrl, openHABWidget.getUrl()), false); if (openHABWidget.getRefresh() > 0) { imageImage.setRefreshRate(openHABWidget.getRefresh()); refreshImageList.add(imageImage); } break; case TYPE_CHART: MySmartImageView chartImage = (MySmartImageView) widgetView.findViewById(R.id.chartimage); OpenHABItem chartItem = openHABWidget.getItem(); Random random = new Random(); String chartUrl = ""; if (chartItem.getType().equals("GroupItem")) { chartUrl = openHABBaseUrl + "rrdchart.png?groups=" + chartItem.getName() + "&period=" + openHABWidget.getPeriod() + "&random=" + String.valueOf(random.nextInt()); } Log.i("OpenHABWidgetAdapter", "Chart url = " + chartUrl); chartImage.setImageUrl(chartUrl, false); // TODO: This is quite dirty fix to make charts look full screen width on all displays ViewGroup.LayoutParams chartLayoutParams = chartImage.getLayoutParams(); int screenWidth = ((WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE)) .getDefaultDisplay().getWidth(); chartLayoutParams.height = (int) (screenWidth / 1.88); chartImage.setLayoutParams(chartLayoutParams); if (openHABWidget.getRefresh() > 0) { chartImage.setRefreshRate(openHABWidget.getRefresh()); refreshImageList.add(chartImage); } Log.i("OpenHABWidgetAdapter", "chart size = " + chartLayoutParams.width + " " + chartLayoutParams.height); break; case TYPE_VIDEO: VideoView videoVideo = (VideoView) widgetView.findViewById(R.id.videovideo); Log.i("OpenHABWidgetAdapter", "Opening video at " + openHABWidget.getUrl()); // TODO: This is quite dirty fix to make video look maximum available size on all screens WindowManager wm = (WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE); ViewGroup.LayoutParams videoLayoutParams = videoVideo.getLayoutParams(); videoLayoutParams.height = (int) (wm.getDefaultDisplay().getWidth() / 1.77); videoVideo.setLayoutParams(videoLayoutParams); // We don't have any event handler to know if the VideoView is on the screen // so we manage an array of all videos to stop them when user leaves the page if (!videoWidgetList.contains(videoVideo)) videoWidgetList.add(videoVideo); // Start video if (!videoVideo.isPlaying()) { videoVideo.setVideoURI(Uri.parse(openHABWidget.getUrl())); videoVideo.start(); } Log.i("OpenHABWidgetAdapter", "Video height is " + videoVideo.getHeight()); break; case TYPE_WEB: WebView webWeb = (WebView) widgetView.findViewById(R.id.webweb); if (openHABWidget.getHeight() > 0) { ViewGroup.LayoutParams webLayoutParams = webWeb.getLayoutParams(); webLayoutParams.height = openHABWidget.getHeight() * 80; webWeb.setLayoutParams(webLayoutParams); } webWeb.setWebViewClient(new WebViewClient()); webWeb.loadUrl(openHABWidget.getUrl()); break; default: labelTextView = (TextView) widgetView.findViewById(R.id.itemlabel); roomEditView = (ImageView) widgetView.findViewById(R.id.editimg); if (null != roomEditView) { roomEditView.setVisibility(View.VISIBLE); roomEditView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub if (null != listItemListener) listItemListener.onEditClickListener(pos); } }); } if (labelTextView != null) labelTextView.setText(openHABWidget.getLabel()); MySmartImageView sliderImage = (MySmartImageView) widgetView.findViewById(R.id.itemimage); sliderImage.setImageUrl(openHABBaseUrl + "images/" + openHABWidget.getIcon() + ".png"); break; } LinearLayout dividerLayout = (LinearLayout) widgetView.findViewById(R.id.listdivider); if (dividerLayout != null) { if (position < this.getCount() - 1) { if (this.getItemViewType(position + 1) == TYPE_FRAME) { dividerLayout.setVisibility(View.GONE); // hide dividers before frame widgets } else { dividerLayout.setVisibility(View.VISIBLE); // show dividers for all others } } else { // last widget in the list, hide divider dividerLayout.setVisibility(View.GONE); } } return widgetView; }
From source file:com.wpi.assistments.HomeTabbedActivity.java
private int getScale() { Display display = ((WindowManager) getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay(); int width = display.getWidth(); Double val = new Double(width) / 800d; val = val * 100d; Log.i("test", Integer.toString(val.intValue())); return val.intValue(); }
From source file:fr.cph.chicago.util.Util.java
public static int[] getScreenSize(@NonNull final Context context) { final WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); final Display display = wm.getDefaultDisplay(); final Point size = new Point(); display.getSize(size);//from www .java 2 s . c om return new int[] { size.x, size.y }; }
From source file:com.byteshaft.medicosperuanos.utils.Helper.EmojiconsPopup.java
private int getUsableScreenHeight() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { DisplayMetrics metrics = new DisplayMetrics(); WindowManager windowManager = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE); windowManager.getDefaultDisplay().getMetrics(metrics); return metrics.heightPixels; } else {/*from w ww . jav a2s .co m*/ return rootView.getRootView().getHeight(); } }
From source file:com.example.appdetail_optimization.PagerSlidingTabStrip.java
@SuppressWarnings("deprecation") private void addTextTab(final int position, String title) { TextView tab = new TextView(getContext()); tab.setText(title);//from w w w . j a v a 2 s . co m tab.setGravity(Gravity.CENTER); tab.setPadding(0, 0, 0, 0); WindowManager wm = (WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE); int width = wm.getDefaultDisplay().getWidth(); tab.setMaxWidth(width / tabCount - tabPadding * 2); tab.setEllipsize(TruncateAt.END); tab.setSingleLine(); addTab(position, tab); }
From source file:jp.co.ipublishing.esnavi.views.MarqueeView.java
/** * ???X?//from ww w .ja v a 2 s . c o m * * @return */ private int getMarqueeStartX() { final WindowManager wm = (WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE); final Display display = wm.getDefaultDisplay(); final Point size = new Point(); display.getSize(size); final int measureText = (int) mTextPaint.measureText(mText); final int measureWidth = getMeasuredWidth(); if (size.x == measureWidth) { return measureWidth; } else if (measureText > size.x) { // ???? return size.x; } else if (measureWidth > measureText) { return measureWidth; } else { return measureText; } }
From source file:com.freshplanet.nativeExtensions.C2DMBroadcastReceiver.java
private boolean recurseGroup(Context context, ViewGroup gp) { final int count = gp.getChildCount(); for (int i = 0; i < count; ++i) { if (gp.getChildAt(i) instanceof TextView) { final TextView text = (TextView) gp.getChildAt(i); final String szText = text.getText().toString(); if (COLOR_SEARCH_RECURSE_TIP.equals(szText)) { notification_text_color = text.getTextColors().getDefaultColor(); notification_text_size = text.getTextSize(); DisplayMetrics metrics = new DisplayMetrics(); WindowManager systemWM = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); systemWM.getDefaultDisplay().getMetrics(metrics); notification_text_size /= metrics.scaledDensity; return true; }/*from ww w .j a va2 s .co m*/ } else if (gp.getChildAt(i) instanceof ViewGroup) return recurseGroup((Context) context, (ViewGroup) gp.getChildAt(i)); } return false; }
From source file:com.android.systemui.statusbar.phone.NavigationBarView.java
public NavigationBarView(Context context, AttributeSet attrs) { super(context, attrs); mContext = context;/* w w w. j a v a 2 s . c o m*/ mHidden = false; mDisplay = ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay(); mBarService = IStatusBarService.Stub.asInterface(ServiceManager.getService(Context.STATUS_BAR_SERVICE)); final Resources res = mContext.getResources(); mBarSize = res.getDimensionPixelSize(R.dimen.navigation_bar_size); mVertical = false; mShowMenu = false; mDelegateHelper = new DelegateViewHelper(this); mBackIcon = res.getDrawable(R.drawable.ic_sysbar_back); mBackLandIcon = res.getDrawable(R.drawable.ic_sysbar_back_land); mBackAltIcon = res.getDrawable(R.drawable.ic_sysbar_back_ime); mBackAltLandIcon = res.getDrawable(R.drawable.ic_sysbar_back_ime); mContext.getContentResolver().registerContentObserver( Settings.System.getUriFor(Settings.System.NAV_BAR_COLOR), false, new ContentObserver(new Handler()) { @Override public void onChange(boolean selfChange) { updateColor(false); } }); }