List of usage examples for android.view View setDrawingCacheEnabled
@Deprecated public void setDrawingCacheEnabled(boolean enabled)
Enables or disables the drawing cache.
From source file:org.telegram.ui.GroupCreateActivity.java
public Emoji.XImageSpan createAndPutChipForUser(TLRPC.User user) { LayoutInflater lf = (LayoutInflater) parentActivity.getSystemService(Activity.LAYOUT_INFLATER_SERVICE); View textView = lf.inflate(R.layout.group_create_bubble, null); TextView text = (TextView) textView.findViewById(R.id.bubble_text_view); text.setText(Utilities.formatName(user.first_name, user.last_name)); int spec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED); textView.measure(spec, spec);/* ww w.j a v a 2 s . c o m*/ textView.layout(0, 0, textView.getMeasuredWidth(), textView.getMeasuredHeight()); Bitmap b = Bitmap.createBitmap(textView.getWidth(), textView.getHeight(), Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(b); canvas.translate(-textView.getScrollX(), -textView.getScrollY()); textView.draw(canvas); textView.setDrawingCacheEnabled(true); Bitmap cacheBmp = textView.getDrawingCache(); Bitmap viewBmp = cacheBmp.copy(Bitmap.Config.ARGB_8888, true); textView.destroyDrawingCache(); final BitmapDrawable bmpDrawable = new BitmapDrawable(b); bmpDrawable.setBounds(0, 0, b.getWidth(), b.getHeight()); SpannableStringBuilder ssb = new SpannableStringBuilder(""); Emoji.XImageSpan span = new Emoji.XImageSpan(bmpDrawable, ImageSpan.ALIGN_BASELINE); allSpans.add(span); selectedContacts.put(user.id, span); for (ImageSpan sp : allSpans) { ssb.append("<<"); ssb.setSpan(sp, ssb.length() - 2, ssb.length(), SpannableStringBuilder.SPAN_EXCLUSIVE_EXCLUSIVE); } userSelectEditText.setText(ssb); userSelectEditText.setSelection(ssb.length()); return span; }
From source file:co.vn.e_alarm.customwiget.SlidingLayer.java
@Override public void setDrawingCacheEnabled(boolean enabled) { super.setDrawingCacheEnabled(false); if (mDrawingCacheEnabled != enabled) { super.setDrawingCacheEnabled(enabled); mDrawingCacheEnabled = enabled;//from w w w. ja v a 2s . co m final int l = getChildCount(); for (int i = 0; i < l; i++) { final View child = getChildAt(i); if (child.getVisibility() != GONE) { child.setDrawingCacheEnabled(enabled); } } } }
From source file:com.androidquery.simplefeed.activity.ImageActivity.java
private void initView() { photos = new ArrayList<FeedItem>(); pv = (PagedView) findViewById(R.id.paged); pi = (PageIndicator) findViewById(R.id.page_indicator); pv.setOnPageChangeListener(new OnPagedViewChangeListener() { @Override//from ww w. j a v a2s . com public void onStopTracking(PagedView pagedView) { } @Override public void onStartTracking(PagedView pagedView) { } @Override public void onPageChanged(PagedView pagedView, int previousPage, int newPage) { pi.setActiveDot(newPage); } }); adapter = new PagedAdapter() { @Override public View getView(int position, View convertView, ViewGroup parent) { if (position >= photos.size()) return PageAdapter.getEmptyView(parent); FeedItem item = photos.get(position); String url = item.getSource(); if (url == null) return PageAdapter.getEmptyView(parent); String name = item.getItemName(); View cached = photoViews.get(url); if (cached == null) { convertView = aq.inflate(null, R.layout.item_photo, parent); photoViews.put(url, convertView); } else { convertView = cached; return convertView; } PQuery aq = aq2.recycle(convertView); aq.id(R.id.web).progress(R.id.progress).invisible(); AQUtility.debug("image load url", url); aq.webImage(url, true, false, 0xFF000000); aq.id(R.id.text).text(name, BufferType.NORMAL, true); convertView.setDrawingCacheEnabled(true); return convertView; } @Override public long getItemId(int position) { return position; } @Override public Object getItem(int position) { return photos.get(position); } @Override public int getCount() { return photos.size(); } }; pv.setAdapter(adapter); }
From source file:cn.org.eshow.framwork.view.slidingmenu.CustomViewAbove.java
/** * Sets the scrolling cache enabled./* w ww . j a va 2 s .co m*/ * * @param enabled the new scrolling cache enabled */ private void setScrollingCacheEnabled(boolean enabled) { if (mScrollingCacheEnabled != enabled) { mScrollingCacheEnabled = enabled; if (USE_CACHE) { final int size = getChildCount(); for (int i = 0; i < size; ++i) { final View child = getChildAt(i); if (child.getVisibility() != GONE) { child.setDrawingCacheEnabled(enabled); } } } } }
From source file:bk.vinhdo.taxiads.utils.view.SlidingLayer.java
@Override public void setDrawingCacheEnabled(boolean enabled) { if (mDrawingCacheEnabled != enabled) { super.setDrawingCacheEnabled(enabled); mDrawingCacheEnabled = enabled;// w ww .j a v a 2s .com final int l = getChildCount(); for (int i = 0; i < l; i++) { final View child = getChildAt(i); if (child.getVisibility() != GONE) { child.setDrawingCacheEnabled(enabled); } } } }
From source file:cn.com.zzwfang.view.directionalviewpager.DirectionalViewPager.java
@Override public void addView(View child, int index, ViewGroup.LayoutParams params) { if (mInLayout) { addViewInLayout(child, index, params); child.measure(mChildWidthMeasureSpec, mChildHeightMeasureSpec); } else {/*from w w w.ja va2 s . co m*/ super.addView(child, index, params); } if (USE_CACHE) { if (child.getVisibility() != GONE) { child.setDrawingCacheEnabled(mScrollingCacheEnabled); } else { child.setDrawingCacheEnabled(false); } } }
From source file:org.appcelerator.titanium.util.TiUIHelper.java
/** * Draw the view into a bitmap.// w ww. j a v a2 s. c o m */ public static Bitmap getViewBitmap(final View v) { v.clearFocus(); v.setPressed(false); boolean willNotCache = v.willNotCacheDrawing(); // Reset the drawing cache background color to fully transparent // for the duration of this operation int color = v.getDrawingCacheBackgroundColor(); if (willNotCache || color != 0) { v.setWillNotCacheDrawing(false); v.setDrawingCacheBackgroundColor(0); v.destroyDrawingCache(); } boolean isDrawinCacheEnabled = v.isDrawingCacheEnabled(); Bitmap bitmap = null; try { v.setDrawingCacheEnabled(true); v.buildDrawingCache(true); bitmap = Bitmap.createBitmap(v.getDrawingCache(true)); } catch (Exception e) { bitmap = null; } v.setDrawingCacheEnabled(isDrawinCacheEnabled); // Restore the view if (willNotCache || color != 0) { v.destroyDrawingCache(); v.setDrawingCacheBackgroundColor(color); v.setWillNotCacheDrawing(willNotCache); } return bitmap; }
From source file:com.open.ui.viewpager.view.TabViewPager.java
@Override public void addView(View child, int index, LayoutParams params) { //Log.i(TAG, "addView mInLayout: " + mInLayout + " index: " + index + " child: " + child) ; if (mInLayout) { addViewInLayout(child, index, params); child.measure(mChildWidthMeasureSpec, mChildHeightMeasureSpec); } else {/*from w w w.j a va 2s .co m*/ super.addView(child, index, params); } if (USE_CACHE) { if (child.getVisibility() != GONE) { child.setDrawingCacheEnabled(mScrollingCacheEnabled); } else { child.setDrawingCacheEnabled(false); } } }
From source file:com.yahala.ui.GroupCreateActivity.java
public XImageSpan createAndPutChipForUser(TLRPC.User user) { LayoutInflater lf = (LayoutInflater) parentActivity.getSystemService(Activity.LAYOUT_INFLATER_SERVICE); View textView = lf.inflate(R.layout.group_create_bubble, null); TextView text = (TextView) textView.findViewById(R.id.bubble_text_view); String name = Utilities.formatName(user.first_name, user.last_name); if (name.length() == 0 && user.phone != null && user.phone.length() != 0) { name = PhoneFormat.getInstance().format("+" + user.phone); }/* w w w . j a v a 2s . c o m*/ text.setText(name + ", "); int spec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED); textView.measure(spec, spec); textView.layout(0, 0, textView.getMeasuredWidth(), textView.getMeasuredHeight()); Bitmap b = Bitmap.createBitmap(textView.getWidth(), textView.getHeight(), Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(b); canvas.translate(-textView.getScrollX(), -textView.getScrollY()); textView.draw(canvas); textView.setDrawingCacheEnabled(true); Bitmap cacheBmp = textView.getDrawingCache(); Bitmap viewBmp = cacheBmp.copy(Bitmap.Config.ARGB_8888, true); textView.destroyDrawingCache(); final BitmapDrawable bmpDrawable = new BitmapDrawable(b); bmpDrawable.setBounds(0, 0, b.getWidth(), b.getHeight()); SpannableStringBuilder ssb = new SpannableStringBuilder(""); XImageSpan span = new XImageSpan(bmpDrawable, ImageSpan.ALIGN_BASELINE); allSpans.add(span); selectedContacts.put(user.jid, span); for (ImageSpan sp : allSpans) { ssb.append("<<"); ssb.setSpan(sp, ssb.length() - 2, ssb.length(), SpannableStringBuilder.SPAN_EXCLUSIVE_EXCLUSIVE); } userSelectEditText.setText(ssb); userSelectEditText.setSelection(ssb.length()); return span; }
From source file:org.drrickorang.loopback.LoopbackActivity.java
/** Save a screenshot of the main activity. */ void saveScreenShot(Uri uri) { ParcelFileDescriptor parcelFileDescriptor = null; FileOutputStream outputStream; try {//www . jav a 2s .c om parcelFileDescriptor = getApplicationContext().getContentResolver().openFileDescriptor(uri, "w"); FileDescriptor fileDescriptor = parcelFileDescriptor.getFileDescriptor(); outputStream = new FileOutputStream(fileDescriptor); log("Done creating output stream"); LinearLayout LL = (LinearLayout) findViewById(R.id.linearLayoutMain); View v = LL.getRootView(); v.setDrawingCacheEnabled(true); Bitmap b = v.getDrawingCache(); //save b.compress(Bitmap.CompressFormat.PNG, 100, outputStream); parcelFileDescriptor.close(); v.setDrawingCacheEnabled(false); } catch (Exception e) { log("Failed to open png file " + e); } finally { try { if (parcelFileDescriptor != null) { parcelFileDescriptor.close(); } } catch (Exception e) { e.printStackTrace(); log("Error closing ParcelFile Descriptor"); } } }