List of usage examples for android.view Display getWidth
@Deprecated public int getWidth()
From source file:org.gots.allotment.adapter.ListAllotmentAdapter.java
@SuppressWarnings("deprecation") @Override/* w ww .jav a2s . com*/ public View getView(final int position, View convertView, ViewGroup parent) { LinearLayout ll = (LinearLayout) convertView; Holder holder; if (ll == null) { holder = new Holder(); ll = (LinearLayout) LayoutInflater.from(mContext).inflate(R.layout.list_allotments, parent, false); if (GotsPreferences.DEBUG) { TextView textView = new TextView(mContext); textView.setText("(" + getItem(position).getId() + ")" + getItem(position).getUUID()); ll.addView(textView); } holder.listSeeds = (GridView) ll.findViewById(R.id.IdGrowingSeedList); holder.titlebar = (LinearLayout) ll.findViewById(R.id.idAllotmentTitlebar); holder.allotmentName = (TextView) ll.findViewById(R.id.textAllotmentName); holder.menu = (LinearLayout) ll.findViewById(R.id.idAllotmentMenu); holder.allotment = getItem(position); ll.setTag(holder); ll.setDescendantFocusability(LinearLayout.FOCUS_BLOCK_DESCENDANTS); // ll.setOnClickListener(this); } else holder = (Holder) ll.getTag(); WindowManager wm = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); int width; int sdk = android.os.Build.VERSION.SDK_INT; if (sdk < android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH) { width = display.getWidth(); } else { Point size = new Point(); display.getSize(size); width = size.x; } int layoutsize = 150; if (width <= 480) layoutsize = 50; int nbcolumn = (width - 200) / layoutsize; if (nbcolumn < 1) nbcolumn = 1; holder.listSeeds.setNumColumns(nbcolumn); listGrowingSeedAdapter = new ListGrowingSeedAdapter(mContext, getItem(position).getSeeds()); holder.listSeeds.setAdapter(listGrowingSeedAdapter); holder.listSeeds.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, layoutsize)); if (listGrowingSeedAdapter.getCount() > 0) { holder.listSeeds.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, (holder.listSeeds.getCount() / nbcolumn + 1) * layoutsize + layoutsize)); // holder.listSeeds.setLayoutParams(new // LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, // LayoutParams.WRAP_CONTENT)); } // else // holder.listSeeds.setLayoutParams(new // LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, // ((holder.listSeeds.getCount() / nbcolumn) + 1) * layoutsize)); holder.allotmentName.setText(getItem(position).getName()); // holder.titlebar.removeAllViews(); holder.menu.setTag(holder); holder.menu.setOnClickListener(this); // SowingAction sow = new SowingAction(mContext); // ActionWidget widget = new ActionWidget(mContext, sow); // widget.setTag(position); if (isSelectable) { holder.menu.setBackgroundResource(R.anim.rotate_alerte); // Animation myFadeInAnimation = // AnimationUtils.loadAnimation(mContext, R.anim.rotate_alerte); // menu.startAnimation(myFadeInAnimation); AnimationDrawable frameAnimation = (AnimationDrawable) holder.menu.getBackground(); frameAnimation.start(); holder.menu.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { new AsyncTask<Void, Integer, GrowingSeedInterface>() { @Override protected GrowingSeedInterface doInBackground(Void... params) { GotsGrowingSeedManager growingSeedManager = GotsGrowingSeedManager.getInstance() .initIfNew(mContext); GotsSeedManager seedManager = GotsSeedManager.getInstance().initIfNew(mContext); // NuxeoGrowingSeedProvider provider = new // NuxeoGrowingSeedProvider(mContext); GrowingSeedInterface growingSeed = (GrowingSeedInterface) seedManager .getSeedById(currentSeedId); growingSeed.setDateSowing(Calendar.getInstance().getTime()); return growingSeedManager.plantingSeed(growingSeed, getItem(position)); } @Override protected void onPostExecute(GrowingSeedInterface seed) { // notifyDataSetChanged(); Toast.makeText(mContext, "Sowing" + " " + SeedUtil.translateSpecie(mContext, seed), Toast.LENGTH_LONG).show(); mContext.sendBroadcast(new Intent(BroadCastMessages.SEED_DISPLAYLIST)); ((Activity) mContext).finish(); } }.execute(); } }); } // widget.setPadding(4, 4, 4, 8); // holder.menu.addView(widget); // // SowingAction sow = new SowingAction(mContext); // ImageView widgetSensor = new ImageView(mContext); // widgetSensor.setImageDrawable(mContext.getResources().getDrawable(R.drawable.ic_sensor)); // widgetSensor.setBackgroundDrawable(mContext.getResources().getDrawable(R.drawable.action_selector)); // widgetSensor.setTag(position); // widgetSensor.setOnClickListener(new View.OnClickListener() { // // @Override // public void onClick(View v) { // // GotsPurchaseItem purchaseItem = new GotsPurchaseItem(mContext); // // // if (!purchaseItem.getFeatureParrot() ? true : // purchaseItem.isPremium()) { // if (!purchaseItem.getFeatureParrot() || purchaseItem.isPremium()) { // FragmentManager fm = mContext.getSupportFragmentManager(); // GotsBillingDialog editNameDialog = new // GotsBillingDialog(GotsPurchaseItem.SKU_FEATURE_PARROT); // editNameDialog.setStyle(DialogFragment.STYLE_NORMAL, // R.style.CustomDialog); // editNameDialog.show(fm, "fragment_edit_name"); // } else { // Intent sensorIntent = new Intent(mContext, SensorActivity.class); // mContext.startActivity(sensorIntent); // }// new AsyncTask<Void, Void, List<ParrotLocation>>() { // // private LocationListAdapter sensorListAdapter; // // // // List<ParrotSampleFertilizer> samplesFertilizer = null; // // // // List<ParrotSampleTemperature> samplesTemp = null; // // // // @Override // // protected List<ParrotLocation> doInBackground(Void... params) { // // ParrotSensorProvider sensorProvider = new // ParrotSensorProvider(mContext); // // List<ParrotLocation> locations = sensorProvider.getLocations(); // // sensorProvider.getStatus(); // // samplesFertilizer = // sensorProvider.getSamples(locations.get(0).getLocation_identifier()); // // samplesTemp = // sensorProvider.getSamples2(locations.get(0).getLocation_identifier()); // // // // return locations; // // } // // // // protected void onPostExecute(List<ParrotLocation> result) { // // // sensorListAdapter = new SensorListAdapter(mContext, result); // // sensorListAdapter = new LocationListAdapter(mContext, result); // // // new AlertDialog.Builder(mContext).setAdapter(sensorListAdapter, // // // new DialogInterface.OnClickListener() { // // // // // // @Override // // // public void onClick(DialogInterface dialog, int which) { // // // Toast.makeText(mContext, // sensorListAdapter.getItem(which).getSensor_serial(), // // // Toast.LENGTH_SHORT).show(); // // // ; // // // } // // // }).show(); // // // // Intent sensorIntent = new Intent(mContext, SensorActivity.class); // // mContext.startActivity(sensorIntent); // // // // if (samplesFertilizer != null) { // // WebView webView = new WebView(mContext); // // String chd = new String(); // // for (ParrotSampleFertilizer fertilizer : samplesFertilizer) { // // chd = chd.concat(String.valueOf(fertilizer.getFertilizer_level() * // 100)); // // chd = chd.concat(","); // // } // // chd = chd.substring(0, chd.length() - 1); // // String url = // "http://chart.apis.google.com/chart?cht=ls&chs=250x100&chd=t:" + chd; // // webView.loadUrl(url); // // Log.d(ListAllotmentAdapter.class.getName(), url); // // AlertDialog.Builder alert = new AlertDialog.Builder(mContext); // // alert.setView(webView); // // alert.show(); // // } // // if (samplesTemp != null) { // // WebView webView = new WebView(mContext); // // String chd = new String(); // // int i = 0; // // for (ParrotSampleTemperature sampleTemp : samplesTemp) { // // chd = // chd.concat(String.valueOf(sampleTemp.getAir_temperature_celsius())); // // chd = chd.concat(","); // // if (i++ >= 50) // // break; // // } // // chd = chd.substring(0, chd.length() - 1); // // String url = // "http://chart.apis.google.com/chart?cht=ls&chs=250x100&chd=t:" + chd; // // webView.loadUrl(url); // // Log.d(ListAllotmentAdapter.class.getName(), url); // // AlertDialog.Builder alert = new AlertDialog.Builder(mContext); // // alert.setView(webView); // // alert.show(); // // } // // }; // // }.execute(); // } // }); // // widgetSensor.setPadding(4, 4, 4, 8); // holder.menu.addView(widgetSensor); return ll; }
From source file:com.pictureperfect.FaceTrackerActivity.java
/** * Creates and starts the camera. Note that this uses a higher resolution in comparison * to other detection examples to enable the barcode detector to detect small barcodes * at long distances./*from www. ja v a 2 s . c o m*/ */ private void createCameraSource(int facing) { Context context = getApplicationContext(); FaceDetector detector = new FaceDetector.Builder(context) .setClassificationType(FaceDetector.ALL_CLASSIFICATIONS).setMode(FaceDetector.FAST_MODE).build(); detector.setProcessor(new MultiProcessor.Builder<>(new GraphicFaceTrackerFactory()).build()); if (!detector.isOperational()) { // Note: The first time that an app using face API is installed on a device, GMS will // download a native library to the device in order to do detection. Usually this // completes before the app is run for the first time. But if that download has not yet // completed, then the above call will not detect any faces. // // isOperational() can be used to check if the required native library is currently // available. The detector will automatically become operational once the library // download completes on device. Log.w(TAG, "Face detector dependencies are not yet available."); } Display display = getWindowManager().getDefaultDisplay(); int width = display.getWidth(); // deprecated int height = display.getHeight(); mCameraSource = new CameraSource.Builder(context, detector).setRequestedPreviewSize(width, height) .setFacing(facing).setRequestedFps(32.0f).build(); }
From source file:com.mirasense.scanditsdk.plugin.ScanditSDK.java
private void resize(JSONArray data) { if (mBarcodePicker != null) { final Bundle bundle = new Bundle(); try {//from ww w .j a va 2 s . c o m if (data.length() < 1) { Log.e("ScanditSDK", "The resize call received too few arguments and has to return without starting."); return; } setOptionsOnBundle(data.getJSONObject(0), bundle); } catch (JSONException e) { e.printStackTrace(); } cordova.getActivity().runOnUiThread(new Runnable() { public void run() { Display display = cordova.getActivity().getWindowManager().getDefaultDisplay(); ScanditSDKParameterParser.updatePickerUIFromBundle(mBarcodePicker, bundle, display.getWidth(), display.getHeight()); double animationDuration = 0; if (bundle.containsKey(ScanditSDKParameterParser.paramAnimationDuration)) { animationDuration = bundle.getDouble(ScanditSDKParameterParser.paramAnimationDuration); } adjustLayout(bundle, animationDuration); } }); } }
From source file:org.videolan.vlc.gui.MainActivity.java
private void changeMenuOffset() { WindowManager wm = (WindowManager) getSystemService(WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); @SuppressWarnings("deprecation") int behindOffset_dp = Util.convertPxToDp(display.getWidth()) - 208; mMenu.setBehindOffset(Util.convertDpToPx(behindOffset_dp)); }
From source file:a.dev.mobile.thread.MainActivity.java
public int calculateDrawerWidth() { // Calculate ActionBar height TypedValue tv = new TypedValue(); int actionBarHeight = 0; if (getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true)) { actionBarHeight = TypedValue.complexToDimensionPixelSize(tv.data, getResources().getDisplayMetrics()); }/*from w w w.ja v a 2s .co m*/ Display display = getWindowManager().getDefaultDisplay(); int width; if (android.os.Build.VERSION.SDK_INT >= 13) { Point size = new Point(); display.getSize(size); width = size.x; } else { width = display.getWidth(); // deprecated } return width - actionBarHeight; }
From source file:com.taobao.luaview.view.widget.SuperSwipeRefreshLayout.java
@SuppressWarnings("deprecation") public SuperSwipeRefreshLayout(Context context, AttributeSet attrs) { super(context, attrs); /**// w w w . j a v a 2s . c o m * getScaledTouchSlop???????? */ mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop(); mMediumAnimationDuration = getResources().getInteger(android.R.integer.config_mediumAnimTime); setWillNotDraw(false); mDecelerateInterpolator = new DecelerateInterpolator(DECELERATE_INTERPOLATION_FACTOR); final TypedArray a = context.obtainStyledAttributes(attrs, LAYOUT_ATTRS); setEnabled(a.getBoolean(0, true)); a.recycle(); WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); final DisplayMetrics metrics = getResources().getDisplayMetrics(); mHeaderViewWidth = (int) display.getWidth(); mHeaderViewHeight = (int) (HEADER_VIEW_HEIGHT * metrics.density); createHeaderViewContainer(); ViewCompat.setChildrenDrawingOrderEnabled(this, true); mSpinnerFinalOffset = DEFAULT_CIRCLE_TARGET * metrics.density; density = metrics.density; mTotalDragDistance = mSpinnerFinalOffset; }
From source file:com.andybotting.tubechaser.activity.StationDetail.java
/** * Display station//from w w w . j a va 2s.c o m */ private void displayStation() { setContentView(R.layout.activity_station_detail); // Home button findViewById(R.id.btn_title_home).setOnClickListener(new View.OnClickListener() { public void onClick(View v) { UIUtils.goHome(StationDetail.this); } }); // Refresh button findViewById(R.id.btn_title_refresh).setOnClickListener(new View.OnClickListener() { public void onClick(View v) { new GetDepartures().execute(); } }); // Map button findViewById(R.id.btn_title_map).setOnClickListener(new View.OnClickListener() { public void onClick(View v) { final Intent intent = new Intent(StationDetail.this, StationMap.class); intent.putExtra(StationMap.EXTRA_STATION, mStation.getUri()); startActivityForResult(intent, 1); } }); // Set up our list mListAdapter = new DepartureListAdapter(); mListView = getExpandableListView(); Display display = getWindowManager().getDefaultDisplay(); mListView.setIndicatorBounds(display.getWidth() - 50, display.getWidth() - 10); // Get our line, if we haven't already if (mLine == null) mLine = mProvider.getLine(mContext, mLineUri); // Set the title bar text ((TextView) findViewById(R.id.title_text)).setText(mLine.getLineName()); // Set the title bar colour String lineColour = mLine.getColour(); int colour = Color.parseColor("#" + lineColour); UIUtils.setTitleBarColor(findViewById(R.id.title_container), colour); // Set the station text ((TextView) findViewById(R.id.station_name)).setText(mStation.getName()); ((TextView) findViewById(R.id.station_lines)).setText(mLine.getLineName()); // Get Favourite mStarred = mPreferenceHelper.isStarred(mStation.getId(), mLine.getId()); // Star button mStarredButton = (CompoundButton) findViewById(R.id.star_button); mStarredButton.setChecked(mStarred); // Star button OnClick mStarredButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { toggleStarred(); } }); new GetDepartures().execute(); }
From source file:com.mirasense.scanditsdk.plugin.ScanditSDK.java
private void scan(JSONArray data) { if (mPendingOperation) { return;//from www. j av a2 s. co m } mPendingOperation = true; mHandler.start(); final Bundle bundle = new Bundle(); try { bundle.putString(ScanditSDKParameterParser.paramAppKey, data.getString(0)); } catch (JSONException e) { Log.e("ScanditSDK", "Function called through Java Script contained illegal objects."); e.printStackTrace(); return; } if (data.length() > 1) { // We extract all options and add them to the intent extra bundle. try { setOptionsOnBundle(data.getJSONObject(1), bundle); } catch (JSONException e) { e.printStackTrace(); } } if (bundle.containsKey(ScanditSDKParameterParser.paramContinuousMode)) { mContinuousMode = bundle.getBoolean(ScanditSDKParameterParser.paramContinuousMode); } ScanditLicense.setAppKey(bundle.getString(ScanditSDKParameterParser.paramAppKey)); ScanditSDKGlobals.usedFramework = "phonegap"; if (bundle.containsKey(ScanditSDKParameterParser.paramPortraitMargins) || bundle.containsKey(ScanditSDKParameterParser.paramLandscapeMargins)) { cordova.getActivity().runOnUiThread(new Runnable() { public void run() { ScanSettings settings = ScanditSDKParameterParser.settingsForBundle(bundle); mBarcodePicker = new SearchBarBarcodePicker(cordova.getActivity(), settings); mBarcodePicker.setOnScanListener(ScanditSDK.this); mBarcodePicker.setOnSearchBarListener(ScanditSDK.this); mLayout = new RelativeLayout(cordova.getActivity()); ViewGroup viewGroup = getViewGroupToAddTo(); if (viewGroup != null) { viewGroup.addView(mLayout); } Display display = cordova.getActivity().getWindowManager().getDefaultDisplay(); ScanditSDKParameterParser.updatePickerUIFromBundle(mBarcodePicker, bundle, display.getWidth(), display.getHeight()); RelativeLayout.LayoutParams rLayoutParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT); mLayout.addView(mBarcodePicker, rLayoutParams); adjustLayout(bundle, 0); if (bundle.containsKey(ScanditSDKParameterParser.paramPaused) && bundle.getBoolean(ScanditSDKParameterParser.paramPaused)) { mBarcodePicker.startScanning(true); } else { mBarcodePicker.startScanning(); } } }); } else { ScanditSDKResultRelay.setCallback(this); Intent intent = new Intent(cordova.getActivity(), ScanditSDKActivity.class); intent.putExtras(bundle); cordova.startActivityForResult(this, intent, 1); } }
From source file:org.rapidandroid.activity.chart.ChartBroker.java
protected void loadGraphFinish() { Display display = this.mParentActivity.getWindowManager().getDefaultDisplay(); //Get the screen orientation int width = display.getWidth(); int height = display.getHeight(); Log.d("ChartBroker", "getWidth: " + width); Log.d("ChartBroker", "getHeight: " + height); height = height - 50;//from www .java 2 s . c o m mAppView.loadUrl("javascript:SetGraph(\"" + width + "px\", \"" + height + "px\")"); Log.d("ChartBroker", "javascript:SetGraph(\"" + width + "px\", \"" + height + "px\")"); mAppView.loadUrl("javascript:GotGraph(" + mGraphData.toString() + "," + mGraphOptions.toString() + ")"); Log.d("ChartBroker", "javascript:GotGraph(" + mGraphData.toString() + "," + mGraphOptions.toString() + ")"); }
From source file:de.madvertise.android.sdk.MadView.java
/** * Constructor/* w ww .j av a 2s. c o m*/ * * @param context * @param attrs */ public MadView(Context context, AttributeSet attrs) { super(context, attrs); MadUtil.logMessage(null, Log.DEBUG, "** Constructor for mad view called **"); setVisibility(INVISIBLE); if (context.checkCallingOrSelfPermission( android.Manifest.permission.INTERNET) == PackageManager.PERMISSION_DENIED) { MadUtil.logMessage(null, Log.DEBUG, " *** ----------------------------- *** "); MadUtil.logMessage(null, Log.DEBUG, " *** Missing internet permissions! *** "); MadUtil.logMessage(null, Log.DEBUG, " *** ----------------------------- *** "); throw new IllegalArgumentException(); } initParameters(attrs); Display display = ((WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE)) .getDefaultDisplay(); MadUtil.logMessage(null, Log.DEBUG, "Display values: Width = " + display.getWidth() + " ; Height = " + display.getHeight()); setGravity(Gravity.CENTER); initialBackground = this.getBackground(); Rect r = new Rect(0, 0, display.getWidth(), display.getHeight()); textBannerBackground = generateBackgroundDrawable(r, backgroundColor, 0xffffff); setClickable(true); setFocusable(true); setDescendantFocusability(ViewGroup.FOCUS_BEFORE_DESCENDANTS); }