List of usage examples for android.view Window ID_ANDROID_CONTENT
int ID_ANDROID_CONTENT
To view the source code for android.view Window ID_ANDROID_CONTENT.
Click Source Link
From source file:com.bobomee.android.common.util.ScreenUtil.java
/** * get the height of title */* www .j av a2 s . c om*/ */ public static int getTitleH(Activity ctx) { int contentTop = ctx.getWindow().findViewById(Window.ID_ANDROID_CONTENT).getTop(); return contentTop - getStatusH(ctx); }
From source file:de.stkl.gbgvertretungsplan.fragments.SubstitutionDetailDialog.java
@Override public void onStart() { super.onStart(); // safety check if (getActivity() == null || getDialog() == null) return;//from w w w. j a va 2 s . c o m int width = getActivity().getWindow().findViewById(Window.ID_ANDROID_CONTENT).getRight(); if (width == 0) return; int newWidth = getResources().getDimensionPixelSize(R.dimen.dialog_detail_width); // set dialog to width specified in dimen resource getDialog().getWindow().setLayout(newWidth >= width ? width : newWidth, getDialog().getWindow().getAttributes().height); activityWidth = width; }
From source file:com.tomeokin.lspush.biz.home.CollectionListAdapter.java
public CollectionListAdapter(Activity activity, @Nullable List<Collection> colList, @Nullable Callback callback) { final Resources resources = activity.getResources(); mMaxHeight = resources.getDimension(R.dimen.list_item_max_content) - resources.getDimension(R.dimen.row_vertical_padding); final View content = activity.getWindow().findViewById(Window.ID_ANDROID_CONTENT); mMaxWidth = content.getWidth() - 2 * resources.getDimension(R.dimen.page_vertical_margin); if (colList != null) { setColList(colList);/*from w ww . ja v a 2 s. c o m*/ } setCallback(callback); }
From source file:com.brucetoo.imagebrowse.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); imgList.add(0, "http://cdn.at.cn/upload/146336617940.jpg"); imgList.add(1, "http://cdn.at.cn/upload/146540079128.jpg"); imgList.add(2, "http://cdn.at.cn/upload/146528287960.jpg"); imgList.add(3, "http://cdn.at.cn/upload/146271377052.jpg"); imgList.add(4, "http://cdn.at.cn/upload/146502027460.jpg"); imgList.add(5, "http://cdn.at.cn/upload/146296005117.jpg"); imgList.add(6, "http://cdn.at.cn/upload/146386101517.jpg"); imgList.add(7, "http://cdn.at.cn/upload/146289180072.jpg"); imgList.add(8, "http://cdn.at.cn/upload/146378563799.jpg"); // imgList.add(0, "http://img6.cache.netease.com/3g/2015/9/30/20150930091938133ad.jpg"); // imgList.add(1, "http://img2.cache.netease.com/3g/2015/9/30/2015093000515435aff.jpg"); // imgList.add(2, "http://img5.cache.netease.com/3g/2015/9/30/20150930075225737e5.jpg"); // imgList.add(3, "http://img5.cache.netease.com/3g/2015/9/29/20150929213007cd8cd.jpg"); // imgList.add(4, "http://img3.cache.netease.com/3g/2015/9/29/20150929162747a8bfa.jpg"); // imgList.add(5, "http://img2.cache.netease.com/3g/2015/9/30/20150930091208cf03c.jpg"); // imgList.add(6, "http://img2.cache.netease.com/3g/2015/9/30/2015093000515435aff.jpg"); // imgList.add(7, "http://img5.cache.netease.com/3g/2015/9/29/20150929213007cd8cd.jpg"); // imgList.add(8, "http://img3.cache.netease.com/3g/2015/9/29/20150929162747a8bfa.jpg"); gridView = (GridView) findViewById(R.id.gridview); root = findViewById(R.id.layout_root); final ImageAdapter adapter = new ImageAdapter(); gridView.setAdapter(adapter);/*from ww w .j a va 2s . co m*/ gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(final AdapterView<?> parent, final View view, final int position, long id) { if (view.isEnabled()) { //Use of ImageBrowseFragment Bundle bundle = new Bundle(); bundle.putStringArrayList(ImageInfo.INTENT_IMAGE_URLS, imgList); bundle.putParcelable(ImageInfo.INTENT_CLICK_IMAGE_INFO, ((PhotoView) view).getInfo()); bundle.putInt(ImageInfo.INTENT_CLICK_IMAGE_POSITION, position); imgImageInfos.clear(); //NOTE:if imgList.size >= the visible count in single screen,i will cause NullPointException //because item out of screen have been replaced/reused for (int i = 0; i < imgList.size(); i++) { imgImageInfos.add(((PhotoView) parent.getChildAt(i)).getInfo()); } parent.getChildAt(position); bundle.putParcelableArrayList(ImageInfo.INTENT_IMAGE_INFOS, imgImageInfos); getSupportFragmentManager() .beginTransaction().replace(Window.ID_ANDROID_CONTENT, ImageBrowseFragment.newInstance(bundle), "ViewPagerFragment") .addToBackStack(null).commit(); //Use of ImageBrowseDialogFragment // root.post(new Runnable() { // in case root view not inflate complete // @Override // public void run() { // Bundle bundle = new Bundle(); // bundle.putStringArrayList(ImageInfo.INTENT_IMAGE_URLS, imgList); // final ImageInfo preImgInfo = ((PhotoView) view).getInfo(); // bundle.putParcelable(ImageInfo.INTENT_CLICK_IMAGE_INFO, preImgInfo); // bundle.putInt(ImageInfo.INTENT_CLICK_IMAGE_POSITION, position); // imgImageInfos.clear(); // for (int i = 0; i < imgList.size(); i++) { // imgImageInfos.add(((PhotoView) parent.getChildAt(i)).getInfo()); // } // bundle.putParcelableArrayList(ImageInfo.INTENT_IMAGE_INFOS, imgImageInfos); // int[] position = new int[2]; // root.getLocationOnScreen(position); // //Must correct the ImageInfo in DialogFragment // preImgInfo.correct(position, getStatusBarHeight()); // for (ImageInfo item : imgImageInfos) { // item.correct(position,getStatusBarHeight()); // } // ImageBrowseDialogFragment.newInstance(bundle).show(getSupportFragmentManager(), ImageBrowseDialogFragment.class.getSimpleName()); // } // }); } } }); }
From source file:com.me.harris.listviewitemanimations._01_activityAnim.ActivityAnimations.java
private void handleStatusBar() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT && Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { ViewGroup mContentView = (ViewGroup) findViewById(Window.ID_ANDROID_CONTENT); /* int statusBarHeight = getStatusBarHeight(); /*from w w w .j a v a 2 s . c o m*/ View mChildView = mContentView.getChildAt(0); if (mChildView != null) { FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) mChildView.getLayoutParams(); //? ChildView marginTop, ? if (lp != null && lp.topMargin < statusBarHeight && lp.height != statusBarHeight) { //? ViewCompat.setFitsSystemWindows(mChildView, false); lp.topMargin += statusBarHeight; mChildView.setLayoutParams(lp); } } View statusBarView = mContentView.getChildAt(0); if (statusBarView != null && statusBarView.getLayoutParams() != null && statusBarView.getLayoutParams().height == statusBarHeight) { //???? View statusBarView.setBackgroundColor(ContextCompat.getColor(this,R.color.colorPrimaryDark)); return; }*/ int statusBarHeight = getStatusBarHeight(); View statusBarView = new View(this); ViewGroup.LayoutParams lp = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, statusBarHeight); statusBarView.setBackgroundColor(ContextCompat.getColor(this, R.color.colorPrimaryDark)); //? ContentView ? View mContentView.addView(statusBarView, 0, lp); } }
From source file:org.de.jmg.learn.SettingsActivity.java
public void init(boolean blnRestart) throws Exception { if (_Intent == null || _main == null || SettingsView == null || _blnInitialized) { return;/*www.j a v a 2 s .c o m*/ } try { //lib.ShowToast(_main, "Settings Start"); RelativeLayout layout = (RelativeLayout) findViewById(R.id.layoutSettings); // id fetch from xml ShapeDrawable rectShapeDrawable = new ShapeDrawable(); // pre defined class int pxPadding = lib.dpToPx(10); rectShapeDrawable.setPadding(pxPadding, pxPadding, pxPadding, pxPadding * ((lib.NookSimpleTouch()) ? 2 : 1)); Paint paint = rectShapeDrawable.getPaint(); paint.setColor(Color.BLACK); paint.setStyle(Style.STROKE); paint.setStrokeWidth(5); // you can change the value of 5 lib.setBg(layout, rectShapeDrawable); mainView = _main.findViewById(Window.ID_ANDROID_CONTENT); //Thread.setDefaultUncaughtExceptionHandler(ErrorHandler); prefs = _main.getPreferences(Context.MODE_PRIVATE); TextView txtSettings = (TextView) findViewById(R.id.txtSettings); SpannableString Settings = new SpannableString(txtSettings.getText()); Settings.setSpan(new UnderlineSpan(), 0, Settings.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); txtSettings.setText(Settings); initCheckBoxes(); initSpinners(blnRestart); initButtons(); initHelp(); edDataDir = (EditText) findViewById(R.id.edDataDir); edDataDir.setSingleLine(true); edDataDir.setText(_main.JMGDataDirectory); edDataDir.setImeOptions(EditorInfo.IME_ACTION_DONE); edDataDir.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_DONE) { String strDataDir = edDataDir.getText().toString(); File fileSelected = new File(strDataDir); if (fileSelected.isDirectory() && fileSelected.exists()) { _main.setJMGDataDirectory(fileSelected.getPath()); edDataDir.setText(_main.JMGDataDirectory); Editor editor = prefs.edit(); editor.putString("JMGDataDirectory", fileSelected.getPath()); editor.commit(); } } return true; } }); edDataDir.setOnLongClickListener(new OnLongClickListener() { @Override public boolean onLongClick(View v) { ShowDataDirDialog(); return true; } }); if (!(lib.NookSimpleTouch()) && !_main.isSmallDevice) { SettingsView.getViewTreeObserver() .addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { // Ensure you call it only once : lib.removeLayoutListener(SettingsView.getViewTreeObserver(), this); // Here you can get the size :) resize(0); //lib.ShowToast(_main, "Resize End"); } }); } else { //resize(1.8f); mScale = 1.0f; } _blnInitialized = true; } catch (Exception ex) { lib.ShowException(_main, ex); } }
From source file:org.de.jmg.learn.MainActivity.java
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); blnTextToSpeech = false;// w w w. jav a 2 s .c o m lib.main = this; //getting the kind of userinterface: television or watch or else int UIMode = lib.getUIMode(this); switch (UIMode) { case Configuration.UI_MODE_TYPE_TELEVISION: isTV = true; break; case Configuration.UI_MODE_TYPE_WATCH: isWatch = true; break; } if (savedInstanceState != null) { JMGDataDirectory = savedInstanceState.getString("JMGDataDirectory"); } setContentView(R.layout.activity_main_viewpager); /** Getting a reference to ViewPager from the layout */ View pager = this.findViewById(R.id.pager); Layout = (ViewGroup) pager; mPager = (ViewPager) pager; /** Getting a reference to FragmentManager */ FragmentManager fm = getSupportFragmentManager(); setPageChangedListener(); /** Creating an instance of FragmentPagerAdapter */ if (fPA == null) { fPA = new MyFragmentPagerAdapter(fm, this, savedInstanceState != null); } /** Setting the FragmentPagerAdapter object to the viewPager object */ mPager.setAdapter(fPA); //mPager.setCurrentItem(0); libLearn.gStatus = "onCreate getEink"; try { _blnEink = getWindowManager().getDefaultDisplay().getRefreshRate() < 5.0; if (_blnEink) lib.ShowToast(this, "This is an Eink diplay!"); } catch (Exception ex) { lib.ShowException(this, ex); } try { libLearn.gStatus = "onCreate setContentView"; mainView = findViewById(Window.ID_ANDROID_CONTENT); defaultErrorHandler = Thread.getDefaultUncaughtExceptionHandler(); Thread.setDefaultUncaughtExceptionHandler(ErrorHandler); // View LayoutMain = findViewById(R.id.layoutMain); processPreferences(savedInstanceState != null); libLearn.gStatus = "onCreate Copy Assets"; CopyAssets(); try { processBundle(savedInstanceState); } catch (Exception e) { e.printStackTrace(); lib.ShowException(this, e); } //InitSettings(); Intent intent = getIntent(); if (Intent.ACTION_VIEW.equals(intent.getAction())) { Uri uri = intent.getData(); if (uri.toString().startsWith("loginquizlet:/")) { loginQuizlet = new LoginQuizletActivity(); this.onNewIntent(intent); } //finish(); } } catch (Exception ex) { lib.ShowException(this, ex); } }
From source file:com.example.alyshia.customsimplelauncher.MainActivity.java
private void handlepicker() { View content = getWindow().findViewById(Window.ID_ANDROID_CONTENT); Log.d("DISPLAY", content.getWidth() + " x " + content.getHeight()); Display display = getWindowManager().getDefaultDisplay(); int aspect_x = content.getWidth(); int aspect_y = content.getHeight(); //enable gallary if disabled edm = (EnterpriseDeviceManager) getSystemService(EnterpriseDeviceManager.ENTERPRISE_POLICY_SERVICE); ApplicationPolicy appPolicy = edm.getApplicationPolicy(); boolean success = appPolicy.removePackagesFromPreventStartBlackList(gallery); if (success) { Log.d(TAG, "enabling back gallery successful"); Intent photoPickerIntent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI); photoPickerIntent.setType("image/*"); photoPickerIntent.putExtra("crop", "true"); photoPickerIntent.putExtra("aspectX", aspect_x); photoPickerIntent.putExtra("aspectY", aspect_y); photoPickerIntent.putExtra("outputX", aspect_x); photoPickerIntent.putExtra("outputY", aspect_y); photoPickerIntent.putExtra(MediaStore.EXTRA_OUTPUT, getTempUri()); photoPickerIntent.putExtra("return-data", true); photoPickerIntent.putExtra("outputFormat", Bitmap.CompressFormat.JPEG.toString()); startActivityForResult(photoPickerIntent, REQ_CODE_PICK_IMAGE); } else {//ww w . ja va 2 s. c o m Log.d(TAG, "enabling back gallery UNsuccessful"); } }
From source file:app.newbee.lib.swipeback.SwipeBackLayout.java
public void attachToActivity(Activity activity) { mActivity = activity;// ww w . j a va 2s .co m TypedArray a = activity.getTheme().obtainStyledAttributes(new int[] { android.R.attr.windowBackground }); int background = a.getResourceId(0, 0); a.recycle(); ViewGroup decor = (ViewGroup) activity.getWindow().getDecorView().findViewById(Window.ID_ANDROID_CONTENT); ViewGroup decorChild = (ViewGroup) decor.getChildAt(0); decorChild.setBackgroundResource(background); decor.removeView(decorChild); addView(decorChild); setContentView(decorChild); decor.addView(this); }
From source file:cz.metaverse.android.bilingualreader.helper.BookPanelOnTouchListener.java
/** * The entry method for any touch-related event. * @param view The WebView where the swipe took place * @param event The MotionEvent of the swipe *//*from ww w. ja v a2s .c o m*/ @Override public boolean onTouch(View view, MotionEvent event) { // Provide data to the GestureDetector. gestureDetector.onTouchEvent(event); /* * Handle Double Tap Swipe in real time. * This handling isn't in onDoubleTapEvent() because that method has a limit how many times * it gets called after which it isn't called at all until the user lifts the finger in which * case it gets called one last time. That is not workable for on-the-fly resizing of panels. */ if (isDoubleTapSwipe) { float absDiffX = Math.abs(doubleTapOriginX - event.getX()); float absDiffY = Math.abs(doubleTapOriginY - event.getY()); // If the swipe was over predefined threshold value high and it was higher than wider, // or if the swipe was over predefined threshold value wide and it was wider than higher. if (doubleTapSwipeEscapedBounds || // Bounds for PORTRAIT orientation. (absDiffY > threshold_swipe_up_or_down_change_panel_size_px && absDiffY > absDiffX && doubleTapSwipe_orientation == Configuration.ORIENTATION_PORTRAIT) || // Bounds for LANDSCAPE orientation. (absDiffX > threshold_swipe_left_right_change_panel_size_px && absDiffX > absDiffY && doubleTapSwipe_orientation != Configuration.ORIENTATION_PORTRAIT)) { if (!doubleTapSwipeEscapedBounds) { // This is the first time doubleTapSwipe escaped it's bounds // - we're officially in the set-panels-size mode. doubleTapSwipeEscapedBounds = true; // Find out and save the relevant dimensions of our view/display Window window = activity.getWindow(); if (doubleTapSwipe_orientation == Configuration.ORIENTATION_PORTRAIT) { doubleTapSwipe_contentStartsAtHeight = window.findViewById(Window.ID_ANDROID_CONTENT) .getTop(); doubleTapSwipe_viewHeight = window.getDecorView().getHeight(); } else { doubleTapSwipe_contentStartsAtHeight = window.findViewById(Window.ID_ANDROID_CONTENT) .getLeft(); doubleTapSwipe_viewHeight = window.getDecorView().getWidth(); } } // Compute the panels weight float useCoordinate = (doubleTapSwipe_orientation == Configuration.ORIENTATION_PORTRAIT) ? event.getRawY() : event.getRawX(); newPanelsWeight = (useCoordinate - doubleTapSwipe_contentStartsAtHeight) / (doubleTapSwipe_viewHeight - doubleTapSwipe_contentStartsAtHeight); // If the weight is close to 0.5, let it stick to it. if (Math.abs(0.5 - newPanelsWeight) < PANEL_RESIZE_SNAP_WEIGHT_AROUND_HALF) { newPanelsWeight = 0.5f; } // Assure that the weight is between the allowed minimum and maximum. newPanelsWeight = Func.minMaxRange(Func.PANEL_WEIGHT_MIN, newPanelsWeight, Func.PANEL_WEIGHT_MAX); // Change relative panel size on the fly. governor.changePanelsWeight(newPanelsWeight); //Log.v(LOG, "[" + panelPosition + "] doubleTapSwipe " + newPanelsWeight); //+ " = (" + event.getRawY() + " - " + contentViewTop + ") / " + (height - contentViewTop)); } } /* * Handle ACTION_UP event for scrolling, because onScroll (almost?) never gets * called with the last MotionEvent.ACTION_UP. * Don't forget to mirror any changes made here in the onScroll() method as well, to be safe. */ if (MotionEventCompat.getActionMasked(event) == MotionEvent.ACTION_UP) { Log.d(LOG, "[" + panelPosition + "] OnTouchListener --> onTouch ACTION_UP - scrollY: " + webView.getScrollY()); // Only if it's not DoubleTapSwipe, that is handled separately. if (!isDoubleTapSwipe) { // Evaluate if the scroll that has just ended constitutes some gesture. handleScrollEnd(event); } } // Modify the event so that it is passed on in a state where the X coordinate hasn't changed at all. // This prevents the "over scroll glow effect" on pages that have some (hidden) horizontal scroll. // -- Disabled because it causes the wrong scroll position to be loaded after opening a page // sometimes (but not every time), for some unknown reason. //event.setLocation(touchOriginX, event.getY()); view.performClick(); // Android system mandates we pass the baton to the onClick listener now. return view.onTouchEvent(event); }