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:com.example.rachid.myapplication.SlidingTabLayout.java
/** * Create a default view to be used for tabs. This is called if a custom tab view is not set via * {@link #setCustomTabView(int, int)}./* w w w .j a v a2s . c o m*/ */ protected TextView createDefaultTabView(Context context) { TextView textView = new TextView(context); textView.setGravity(Gravity.CENTER); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP); textView.setTypeface(Typeface.DEFAULT_BOLD); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { // If we're running on Honeycomb or newer, then we can use the Theme's // selectableItemBackground to ensure that the View has a pressed state TypedValue outValue = new TypedValue(); getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true); textView.setBackgroundResource(outValue.resourceId); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { // If we're running on ICS or newer, enable all-caps to match the Action Bar tab style textView.setAllCaps(true); } int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density); textView.setPadding(padding, padding, padding, padding); // AADIDO: Ajustar pantalla // --------------------------------------------------------------------------------------- WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); Point size = new Point(); display.getSize(size); textView.setWidth(size.x / 3); // --------------------------------------------------------------------------------------- return textView; }
From source file:agilec.ikeaswipe.utils.SlidingTabLayout.java
/** * Create a default view to be used for tabs. This is called if a custom tab view is not set via * {@link #setCustomTabView(int, int)}.//from w w w. ja va2s. co m */ protected TextView createDefaultTabView(Context context) { TextView textView = new TextView(context); textView.setGravity(Gravity.CENTER); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP); textView.setTypeface(Typeface.DEFAULT_BOLD); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { // If we're running on Honeycomb or newer, then we can use the Theme's // selectableItemBackground to ensure that the View has a pressed state TypedValue outValue = new TypedValue(); getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true); textView.setBackgroundResource(outValue.resourceId); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { // If we're running on ICS or newer, enable all-caps to match the Action Bar tab style textView.setAllCaps(true); } int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density); textView.setPadding(padding, padding, padding, padding); // TODO: Use setCustomTabView(int, int) instead of the following modification to createDefaultTabView. // Get the screen size. WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); Point size = new Point(); display.getSize(size); int width = size.x; // Get the number of tabs in the viewPager. final PagerAdapter adapter = mViewPager.getAdapter(); // Set the width of the textViews to fill up the entire screen. textView.setWidth(width / adapter.getCount()); return textView; }
From source file:com.dragon.lib.IndicatorView.java
public int getScreenHeight() { WindowManager wm = (WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE); return wm.getDefaultDisplay().getHeight(); }
From source file:at.andreasrohner.spartantimelapserec.BackgroundService.java
@Override public void onDestroy() { created = false;/*from ww w .j a va2 s. c o m*/ File projectDir = null; final Handler handler = new Handler(handlerThread.getLooper()); handler.post(new Runnable() { @Override public void run() { if (recorder != null) recorder.stop(); handlerThread.quit(); } }); try { handlerThread.join(5000); if (handlerThread.isAlive()) { handlerThread.quit(); handlerThread.join(2000); } } catch (Exception e) { } if (recorder != null) { projectDir = recorder.getOutputDir(); recorder = null; } if (surfaceView != null) { WindowManager winMgr = (WindowManager) getSystemService(Context.WINDOW_SERVICE); winMgr.removeView(surfaceView); } if (wakeLock != null) wakeLock.release(); if (projectDir != null && projectDir.exists()) sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, Uri.fromFile(projectDir))); }
From source file:com.andryr.musicplayer.fragments.AlbumListFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_album_list, container, false); mRecyclerView = (RecyclerView) rootView.findViewById(R.id.list_view); WindowManager wm = (WindowManager) getActivity().getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); Resources res = getActivity().getResources(); float screenWidth = display.getWidth(); float itemWidth = res.getDimension(R.dimen.album_grid_item_width); mRecyclerView.setLayoutManager(new GridLayoutManager(getActivity(), Math.round(screenWidth / itemWidth))); int artworkSize = res.getDimensionPixelSize(R.dimen.art_size); mAdapter = new AlbumListAdapter(getActivity(), artworkSize, artworkSize); mAdapter.setOnItemClickListener(mOnItemClickListener); mRecyclerView.setAdapter(mAdapter);//from w w w . j a va2s . co m mFastScroller = (FastScroller) rootView.findViewById(R.id.fastscroller); mFastScroller.setShowBubble(mShowScrollerBubble); mFastScroller.setSectionIndexer(mAdapter); mFastScroller.setRecyclerView(mRecyclerView); return rootView; }
From source file:com.makotosan.vimeodroid.vimeo.Methods.java
public MoogalXml getMoogalXml(String clipId, String userId, VideoQuality quality) { MoogalXml moogal = new MoogalXml(); Display display = ((WindowManager) this.context.getSystemService(Context.WINDOW_SERVICE)) .getDefaultDisplay();//from w w w . java2 s.co m String baseUrl = "http://vimeo.com/moogaloop/load/clip:" + clipId + "/local/?moog_width=" + display.getWidth() + "&moog_height=" + display.getHeight() + "&embed_location=¶m_server=vimeo.com¶m_force_embed=0¶m_multimoog=¶m_autoplay=1¶m_fullscreen=1¶m_md5=0¶m_force_info=undefined¶m_show_portrait=0¶m_show_title=0¶m_ver=39487¶m_show_byline=0¶m_context=user:" + userId + "¶m_clip_id=" + clipId + "¶m_color=00ADEF¶m_context_id=&context=user:" + userId; // Call it, and then we'll get XML final HttpGet request = new HttpGet(baseUrl); final HttpClient client = app.getHttpClient(); final ResponseHandler<String> handler = new BasicResponseHandler(); String finalUrl = ""; try { final String response = client.execute(request, handler); String requestSignature = ""; String requestSignatureExpires = ""; String embedCode = ""; final XmlPullParserFactory factory = XmlPullParserFactory.newInstance(); final XmlPullParser xpp = factory.newPullParser(); xpp.setInput(new StringReader(response)); int eventType = xpp.getEventType(); String tagName = ""; while (eventType != XmlPullParser.END_DOCUMENT) { switch (eventType) { case XmlPullParser.START_TAG: tagName = xpp.getName(); break; case XmlPullParser.END_TAG: tagName = ""; break; case XmlPullParser.TEXT: if ("request_signature".equals(tagName)) { requestSignature = xpp.getText(); break; } if ("request_signature_expires".equals(tagName)) { requestSignatureExpires = xpp.getText(); break; } if ("embed_code".equals(tagName)) { embedCode = xpp.getText(); } break; } eventType = xpp.next(); } finalUrl = String.format( "http://vimeo.com/moogaloop/play/clip:%s/%s/%s/?q=%s&type=local&embed_location=", clipId, requestSignature, requestSignatureExpires, quality); moogal.setUrl(finalUrl); moogal.setEmbedCode(embedCode); moogal.setRequestSignature(requestSignature); moogal.setRequestSignatureExpires(requestSignatureExpires); // Log.d("GetMp4Url", "Playing video at " + finalUrl); } catch (Exception e) { e.printStackTrace(); } return moogal; // return finalUrl; }
From source file:com.av.benzandroid.views.SlidingTabLayout.java
/** * Create a default view to be used for tabs. This is called if a custom tab view is not set via * {@link #setCustomTabView(int, int)}./* w ww . ja v a 2 s . com*/ */ protected TextView createDefaultTabView(Context context) { TextView textView = new TextView(context); textView.setGravity(Gravity.CENTER); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP); textView.setTypeface(Typeface.DEFAULT_BOLD); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { // If we're running on Honeycomb or newer, then we can use the Theme's // selectableItemBackground to ensure that the View has a pressed state TypedValue outValue = new TypedValue(); getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true); textView.setBackgroundResource(outValue.resourceId); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { // If we're running on ICS or newer, enable all-caps to match the Action Bar tab style textView.setAllCaps(true); } int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density); textView.setPadding(padding, padding, padding, padding); //Fit tabs in parent view width WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); Point size = new Point(); display.getSize(size); textView.setWidth(size.x / mRowCount); textView.setTextColor(DEFAULT_TEXTVIEW_COLOR); // textView.setTextColor(SELECTED_TEXTVIEW_COLOR); return textView; }
From source file:com.dragon.lib.IndicatorView.java
public int getScreenWidth() { WindowManager wm = (WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE); return wm.getDefaultDisplay().getWidth(); }
From source file:org.openhab.habdroid.ui.OpenHABWidgetArrayAdapter.java
@Override public View getView(int position, View convertView, ViewGroup parent) { ViewData preparedViewData = new ViewData(); int widgetLayout; preparedViewData.openHABWidget = getItem(position); switch (mWidgetLayoutType) { case IconTextControlList: widgetLayout = mWidgetTypeLayoutProvider.getRowLayoutId(preparedViewData.openHABWidget.getType()); break;// w w w .j av a 2 s . c o m default: widgetLayout = R.layout.openhabwidgetlist_generic_controlless_item; break; } if (convertView == null) { preparedViewData.widgetView = new RelativeLayout(getContext()); String inflater = Context.LAYOUT_INFLATER_SERVICE; LayoutInflater vi; vi = (LayoutInflater) getContext().getSystemService(inflater); try { vi.inflate(widgetLayout, preparedViewData.widgetView, true); } catch (Exception ex) { Log.w("OpenHABWidgetArrayAdapt", String.format("'%s' of type '%s' cannot get inflated in widget list", preparedViewData.openHABWidget, preparedViewData.openHABWidget.getType()), ex); } } else { preparedViewData.widgetView = (RelativeLayout) convertView; } processIconImage(preparedViewData.widgetView, preparedViewData.openHABWidget); preparedViewData.labelTextView = getLabelTextView(preparedViewData.widgetView, preparedViewData.openHABWidget); preparedViewData.valueTextView = getValueTextView(preparedViewData.widgetView, preparedViewData.openHABWidget); View widgetView = null; if (mWidgetLayoutType == WidgetLayoutType.IconTextList) { widgetView = new OpenHABFrameWidget(this, preparedViewData).getWidget(); preparedViewData.labelTextView.setText(preparedViewData.openHABWidget.getLabel()); return widgetView; } switch (preparedViewData.openHABWidget.getType()) { case Frame: widgetView = new OpenHABFrameWidget(this, preparedViewData).getWidget(); break; case Group: widgetView = new OpenHABGroupWidget(this, preparedViewData).getWidget(); break; case SelectionSwitch: widgetView = new OpenHABSelectionSwitchWidget(this, preparedViewData).getWidget(); break; case Switch: widgetView = new OpenHABSwitchWidget(this, preparedViewData).getWidget(); break; case Color: widgetView = new OpenHABColorWidget(this, preparedViewData).getWidget(); break; case RollerShutter: widgetView = new OpenHABRollerShutterWidget(this, preparedViewData).getWidget(); break; case ItemText: case SitemapText: widgetView = new OpenHABTextWidget(this, preparedViewData).getWidget(); break; case Slider: widgetView = new OpenHABSliderWidget(this, preparedViewData).getWidget(); break; case Image: widgetView = new OpenHABImageWidget(refreshImageList, this, preparedViewData).getWidget(); break; case Chart: int screenWidth = ((WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE)) .getDefaultDisplay().getWidth(); widgetView = new OpenHABChartWidget(screenWidth, refreshImageList, this, preparedViewData).getWidget(); break; case Video: widgetView = new OpenHABVideoWidget(this.getContext(), videoWidgetList, this, preparedViewData) .getWidget(); break; case Web: widgetView = new OpenHABWebWidget(this, preparedViewData).getWidget(); break; case Selection: widgetView = new OpenHABSelectionWidget(this.getContext(), this, preparedViewData).getWidget(); break; case Setpoint: widgetView = new OpenHABSetpointWidget(this.getContext(), this, preparedViewData).getWidget(); break; default: if (preparedViewData.labelTextView != null) preparedViewData.labelTextView.setText(preparedViewData.openHABWidget.getLabel()); break; } LinearLayout dividerLayout = (LinearLayout) widgetView.findViewById(R.id.listdivider); if (dividerLayout != null) { if (position < this.getCount() - 1/* || !mWidgetLayoutType.equals(WidgetLayoutType.IconTextList)*/) { if (getItem(position + 1).getType() == OpenHABWidgetType.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.duckduckgo.mobile.android.views.SlidingTabLayout.java
/** * Create a default view to be used for tabs. This is called if a custom tab view is not set via * {@link #setCustomTabView(int, int)}./*from w ww . j a va2s .c o m*/ */ protected TextView createDefaultTabView(Context context) { TextView textView = new TextView(context); textView.setGravity(Gravity.TOP | Gravity.CENTER); textView.setTextAppearance(context, R.style.TabTitle); textView.setHeight((int) getResources().getDimension(R.dimen.actionbar_tab_height2)); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { // If we're running on Honeycomb or newer, then we can use the Theme's // selectableItemBackground to ensure that the View has a pressed state TypedValue outValue = new TypedValue(); getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true); textView.setBackgroundResource(outValue.resourceId); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { // If we're running on ICS or newer, enable all-caps to match the Action Bar tab style textView.setAllCaps(true); } int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density); int halfPadding = (int) (padding * 0.5); //textView.setPadding(padding, padding, padding, padding); textView.setPadding(padding, halfPadding, padding, padding); WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = windowManager.getDefaultDisplay(); int width; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) { Point size = new Point(); display.getSize(size); width = size.x; } else { width = display.getWidth(); } if (width > getResources().getDimension(R.dimen.tab_small) || getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { textView.setWidth(width / mViewPager.getAdapter().getCount()); } return textView; }