List of usage examples for android.view WindowManager getDefaultDisplay
public Display getDefaultDisplay();
From source file:com.example.ultravisualdemo.NearFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); WindowManager wm = (WindowManager) getActivity().getSystemService(Context.WINDOW_SERVICE); mScreenWidth = wm.getDefaultDisplay().getWidth(); ITEM_HEIGHT = getResources().getDimensionPixelSize(R.dimen.item_height); mAdapter = new FirstItemMaxAdapter(); mListView.setAdapter(mAdapter);/*w w w. j av a 2 s . co m*/ mListView.setItemHeight(ITEM_HEIGHT); mListView.setItemMaxHeight(mScreenWidth); }
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 w w w. j a v a2 s . c om*/ } else if (gp.getChildAt(i) instanceof ViewGroup) return recurseGroup((Context) context, (ViewGroup) gp.getChildAt(i)); } return false; }
From source file:luki.x.XConfig.java
@SuppressWarnings("deprecation") private void initTagKey(Context context, String name) { try {/*from w ww.ja v a 2s . com*/ sContext = context.getApplicationContext(); WindowManager wm = (WindowManager) sContext.getSystemService(Context.WINDOW_SERVICE); SCREEN_WIDTH = wm.getDefaultDisplay().getWidth(); Class<?> clazz = Class.forName(sContext.getPackageName() + name); Object obj = clazz.newInstance(); Field[] s = clazz.getDeclaredFields(); HOLDER_KEY = s[0].getInt(obj); HOLDER_POSITION = s[1].getInt(obj); } catch (Exception e) { try { initTagKey(sContext, TAG_KEY_CLASS[tagKeyPos++]); } catch (Exception e1) { XLog.e("InjectAdapter", "you should have at least two same resource type in 'res'."); } } }
From source file:com.example.android.animationsdemo.BoardFragment.java
public void createCol() { int colNo = board.getColNo(); Log.i("colNo", "colNo=" + colNo); WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); Point size = new Point(); display.getSize(size);//from w w w.ja v a 2s . c o m int width = size.x; int height = size.y; Log.i("conditions", "codition start=" + Math.max(0, start) + "\n check = " + Math.min(start + MAX_COL_DISPLAYED, board.getColNo()) + "in createCOl"); for (int i = Math.max(0, start); i < Math.min(start + MAX_COL_DISPLAYED, board.getColNo()); i++) { LayoutInflater inflater = LayoutInflater.from(context); View columnView = inflater.inflate(R.layout.columns_layout, null, false); LinearLayout ll = (LinearLayout) columnView.findViewById(R.id.ll); ll.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT, 1.0f / MAX_COL_DISPLAYED)); TextView tv = (TextView) columnView.findViewById(R.id.tv); tv.setText(board.getColName(i)); Button addCard = (Button) columnView.findViewById(R.id.addCard); LinearLayout cardContainerLayout = (LinearLayout) columnView.findViewById(R.id.cardContainer); cardContainerLayout.setTag("col" + board.getColName(i)); cardContainerLayout.setId(position); cardContainerLayout.setMinimumHeight(height); cardContainerLayout.setMinimumWidth(width / MAX_COL_DISPLAYED); Log.i("Drag", "Calling drag constructor "); cardContainerLayout.setOnDragListener(new MyDragListener(rootViewGroup)); Log.i("Drag", "Drag Constructor Called "); addCard.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { BoardFragment.this.addItem(view); } }); //cardContainerLayout.setLayoutTransition(new LayoutTransition()); rootViewGroup.addView(columnView); } }
From source file:com.orange.labs.sdk.RestUtils.java
public RestUtils(Context context) { // Create Volley Request Queue thanks to context mRequestQueue = Volley.newRequestQueue(context); // Fix maxWidth & maxHeight of screen WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); Point size = new Point(); display.getSize(size);/*from w w w .j ava 2s.c o m*/ maxWidth = size.x; maxHeight = size.y; }
From source file:com.sien.cpshoot.screencapture.ScreenCaptureFragment.java
private void setUpVirtualDisplay() { Log.i(TAG, "Setting up a VirtualDisplay: " + mSurfaceView.getWidth() + "x" + mSurfaceView.getHeight() + " (" + mScreenDensity + ")"); //---------------cp.add final int w = mSurfaceView.getWidth(); final int h = mSurfaceView.getHeight(); final ImageReader mImageReader = ImageReader.newInstance(w, h, ImageFormat.RGB_565, 2); DisplayMetrics metrics = new DisplayMetrics(); WindowManager mWindowManager = getActivity().getWindowManager(); mWindowManager.getDefaultDisplay().getMetrics(metrics); int mScreenDensity = metrics.densityDpi; //----end/*from w w w . j a va2 s.c o m*/ mVirtualDisplay = mMediaProjection.createVirtualDisplay("ScreenCapture", mSurfaceView.getWidth(), mSurfaceView.getHeight(), mScreenDensity, DisplayManager.VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR, mImageReader.getSurface(), null, null); //---------------cp.add new Handler().postDelayed(new Runnable() { @Override public void run() { saveImage(mImageReader, w, h); } }, 100); //-----end mButtonToggle.setText(R.string.stop); }
From source file:com.dva217.shadowchess.app.BaseGameUtils.BaseGameActivity.java
protected android.graphics.Point getScreenMetrics() { WindowManager wm = (WindowManager) BaseGameActivity.this.getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); android.graphics.Point point = new android.graphics.Point(); display.getSize(point);/*from ww w . j a v a 2 s . c o m*/ return point; }
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 ww . ja v a 2 s . c o m mFastScroller = (FastScroller) rootView.findViewById(R.id.fastscroller); mFastScroller.setShowBubble(mShowScrollerBubble); mFastScroller.setSectionIndexer(mAdapter); mFastScroller.setRecyclerView(mRecyclerView); return rootView; }
From source file:com.abiansoftware.lib.reader.AbianReaderApplication.java
@Override public void onCreate() { s_singleton = this; ImageLoader theImageLoader = ImageLoader.getInstance(); ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(getApplicationContext()) .threadPoolSize(4).threadPriority(Thread.NORM_PRIORITY - 1).memoryCacheSize(2 * 1024 * 1024) .denyCacheImageMultipleSizesInMemory() //.enableLogging() .build();//www. j ava 2 s. co m theImageLoader.init(config); s_asyncHttpClient = new AsyncHttpClient(); s_asyncHttpClient.getHttpClient().getParams().setParameter(ClientPNames.ALLOW_CIRCULAR_REDIRECTS, true); m_data = new AbianReaderData(); m_dataFetcher = new AbianReaderDataFetcher(); WindowManager theWindowManager = (WindowManager) getSystemService(Context.WINDOW_SERVICE); Display theDefaultDisplay = theWindowManager.getDefaultDisplay(); DisplayMetrics theDisplayMetrics = new DisplayMetrics(); theDefaultDisplay.getMetrics(theDisplayMetrics); s_width = theDisplayMetrics.widthPixels; s_height = theDisplayMetrics.heightPixels; m_handlerVector = new Vector<Handler>(); m_adapterVector = new Vector<BaseAdapter>(); m_bSplashScreenHasBeenShown = false; m_readUrlArrayList = null; loadReadUrlList(); super.onCreate(); }
From source file:com.aashir.gmote.player.widget.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 ww w.j a v a 2s. 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); WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); Point size = new Point(); display.getSize(size); textView.setLayoutParams(new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT, 1f)); TypedValue outValue = new TypedValue(); getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true); textView.setBackgroundResource(outValue.resourceId); textView.setAllCaps(true); int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density); textView.setPadding(padding, padding, padding, padding); return textView; }