List of usage examples for android.view View draw
@CallSuper public void draw(Canvas canvas)
From source file:cn.lanmei.com.dingdong_2.ItemDecoration.StickyHeaderDecoration.java
/** * {@inheritDoc}//from w ww . ja va 2 s . co m */ @Override public void onDrawOver(Canvas c, RecyclerView parent, RecyclerView.State state) { // final int count = parent.getChildCount(); LRecyclerViewAdapter adapter = (LRecyclerViewAdapter) parent.getAdapter(); RecyclerView.Adapter ra = adapter.getInnerAdapter(); final int count = ra.getItemCount(); for (int layoutPos = 0; layoutPos < count; layoutPos++) { final View child = parent.getChildAt(layoutPos); final int adapterPos = parent.getChildAdapterPosition(child); // L.MyLog("sticky","onDrawOver:"+adapterPos+"getItemCount"+count); if (adapterPos != RecyclerView.NO_POSITION && (layoutPos == 0 || hasHeader(adapterPos))) { View header = getHeader(parent, adapterPos).itemView; c.save(); final int left = child.getLeft(); final int top = getHeaderTop(parent, child, header, adapterPos, layoutPos); c.translate(left, top); header.setTranslationX(left); header.setTranslationY(top); header.draw(c); c.restore(); } } }
From source file:com.harmazing.aixiumama.activity.ActivityGallery.java
private Bitmap GetandSaveCurrentImage() { //Bitmap/*from w w w . j a v a 2s. c o m*/ WindowManager windowManager = getWindowManager(); Display display = windowManager.getDefaultDisplay(); int w = display.getWidth(); int h = display.getHeight(); Bitmap Bmp = Bitmap.createBitmap(w, h, Bitmap.Config.RGB_565); //?? View decorview = this.getWindow().getDecorView(); // decorview.setDrawingCacheEnabled(true); // decorview.buildDrawingCache(); // Bmp = decorview.getDrawingCache(); Canvas c = new Canvas(Bmp); decorview.draw(c); // Bmp = Bitmap.createBitmap(Bmp, 0, BitmapUtil.dip2px(getApplicationContext(), 50) + getTopViewHeight(), w, CuteApplication.getScreenHW(getApplicationContext())[0] - BitmapUtil.dip2px(getApplicationContext(), 10)); decorview.destroyDrawingCache(); decorview.setDrawingCacheEnabled(false); return Bmp; }
From source file:com.chartiq.chartiqsample.ui.StickyHeaderDecoration.java
/** * {@inheritDoc}// w ww .ja va2 s. c o m */ @Override public void onDrawOver(Canvas canvas, RecyclerView parent, RecyclerView.State state) { final int count = parent.getChildCount(); long previousHeaderId = -1; for (int layoutPos = 0; layoutPos < count; layoutPos++) { final View child = parent.getChildAt(layoutPos); final int adapterPos = parent.getChildAdapterPosition(child); if (child.getVisibility() == View.GONE) { continue; } if (adapterPos != RecyclerView.NO_POSITION && hasHeader(adapterPos)) { long headerId = mAdapter.getHeaderId(adapterPos); if (headerId != previousHeaderId) { previousHeaderId = headerId; View header = getHeader(parent, adapterPos).itemView; canvas.save(); final int left = child.getLeft(); final int top = getHeaderTop(parent, child, header, adapterPos, layoutPos); canvas.translate(left, top); header.setTranslationX(left); header.setTranslationY(top); header.draw(canvas); canvas.restore(); } } } }
From source file:ca.barrenechea.widget.recyclerview.decoration.StickyHeaderDecoration.java
/** * {@inheritDoc}//from w w w .j a v a 2 s . c o m */ @Override public void onDrawOver(Canvas canvas, RecyclerView parent, RecyclerView.State state) { final int count = parent.getChildCount(); long previousHeaderId = -1; for (int layoutPos = 0; layoutPos < count; layoutPos++) { final View child = parent.getChildAt(layoutPos); final int adapterPos = parent.getChildAdapterPosition(child); if (adapterPos != RecyclerView.NO_POSITION && hasHeader(adapterPos)) { long headerId = mAdapter.getHeaderId(adapterPos); if (headerId != previousHeaderId) { previousHeaderId = headerId; View header = getHeader(parent, adapterPos).itemView; canvas.save(); final int left = child.getLeft(); final int top = getHeaderTop(parent, child, header, adapterPos, layoutPos); canvas.translate(left, top); header.setTranslationX(left); header.setTranslationY(top); header.draw(canvas); canvas.restore(); } } } }
From source file:com.dat.complexrecyclerviewdemo.recyclerviewinsidecardviewdemo.StickyHeaderDecoration.java
/** * {@inheritDoc}/*w ww. j a va 2s. c o m*/ */ @Override public void onDrawOver(Canvas canvas, RecyclerView parent, RecyclerView.State state) { final int count = parent.getChildCount(); long previousHeaderId = -1; for (int layoutPos = 0; layoutPos < count; layoutPos++) { final View child = parent.getChildAt(layoutPos); final int adapterPos = parent.getChildAdapterPosition(child); if (adapterPos != RecyclerView.NO_POSITION && hasHeader(adapterPos)) { long headerId = mAdapter.getHeaderId(adapterPos); if (headerId != previousHeaderId) { previousHeaderId = headerId; View header = getHeader(parent, adapterPos).itemView; canvas.save(); final int left = child.getLeft(); final int top = getHeaderTop(parent, child, header, adapterPos, layoutPos); canvas.translate(left, top - 4); header.setTranslationX(left); header.setTranslationY(top); header.draw(canvas); canvas.restore(); } } } }
From source file:com.fada21.android.hydralist.expandable.ExpandingListViewDelegate.java
/** * By overriding dispatchDraw, we can draw the cells that disappear during the expansion process. When the cell expands, some items below or above the * expanding cell may be moved off screen and are thus no longer children of the ListView's layout. By storing a reference to these views prior to the * layout, and guaranteeing that these cells do not get recycled, the cells can be drawn directly onto the canvas during the animation process. After the * animation completes, the references to the extra views can then be discarded. */// w w w .j a va 2 s. co m public void dispatchDraw(Canvas canvas) { if (mViewsToDraw.size() == 0) { return; } for (View v : mViewsToDraw) { canvas.translate(0, v.getTop()); v.draw(canvas); canvas.translate(0, -v.getTop()); } }
From source file:org.rm3l.ddwrt.tiles.status.wireless.WirelessIfaceQrCodeActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.tile_wireless_iface_qr_code_options, menu); this.optionsMenu = menu; /* Getting the actionprovider associated with the menu item whose id is share */ final MenuItem shareMenuItem = menu.findItem(R.id.tile_status_wireless_iface_qrcode_share); shareMenuItem.setEnabled(mException == null); mShareActionProvider = (ShareActionProvider) shareMenuItem.getActionProvider(); final View viewToShare = findViewById(R.id.tile_status_wireless_iface_qrcode_view_to_share); //Construct Bitmap and share it final Bitmap bitmapToExport = Bitmap.createBitmap(viewToShare.getWidth(), viewToShare.getHeight(), Bitmap.Config.ARGB_8888);//from w ww. jav a 2s . c o m final Canvas canvas = new Canvas(bitmapToExport); viewToShare.draw(canvas); mFileToShare = new File(getCacheDir(), String.format("QR-Code_for_Wireless_Network__%s__on_router_%s.png", nullToEmpty(mSsid), nullToEmpty(mRouterUuid))); OutputStream outputStream = null; try { outputStream = new BufferedOutputStream(new FileOutputStream(mFileToShare, false)); bitmapToExport.compress(Bitmap.CompressFormat.PNG, COMPRESSION_QUALITY, outputStream); outputStream.flush(); } catch (IOException e) { e.printStackTrace(); Crouton.makeText(this, getString(R.string.internal_error_please_try_again), Style.ALERT).show(); } finally { try { if (outputStream != null) { outputStream.close(); } } catch (IOException e) { e.printStackTrace(); //No Worries } } setShareFile(mFileToShare); return super.onCreateOptionsMenu(menu); }
From source file:com.example.mylibrary.utils.decoration.StickyHeaderDecoration.java
/** * {@inheritDoc}//w w w . java 2s . co m */ @Override public void onDrawOver(Canvas canvas, RecyclerView parent, RecyclerView.State state) { final int count = parent.getChildCount(); long previousHeaderId = -1; for (int layoutPos = 0; layoutPos < count; layoutPos++) { final View child = parent.getChildAt(layoutPos); int adapterPos = parent.getChildAdapterPosition(child); if (!mIncludeHeader) { if (parent.getAdapter() instanceof RecyclerArrayAdapter) { int headerCount = ((RecyclerArrayAdapter) parent.getAdapter()).getHeaderCount(); int footerCount = ((RecyclerArrayAdapter) parent.getAdapter()).getFooterCount(); int dataCount = ((RecyclerArrayAdapter) parent.getAdapter()).getCount(); if (adapterPos < headerCount) { continue; } if (adapterPos >= headerCount + dataCount) { continue; } if (adapterPos >= headerCount) { adapterPos -= headerCount; } } } if (adapterPos != RecyclerView.NO_POSITION && hasHeader(adapterPos)) { long headerId = mAdapter.getHeaderId(adapterPos); if (headerId != previousHeaderId) { previousHeaderId = headerId; View header = getHeader(parent, adapterPos).itemView; canvas.save(); final int left = child.getLeft(); final int top = getHeaderTop(parent, child, header, adapterPos, layoutPos); canvas.translate(left, top); header.setTranslationX(left); header.setTranslationY(top); header.draw(canvas); canvas.restore(); } } } }
From source file:com.jude.easyrecyclerview.decoration.StickyHeaderDecoration.java
/** * {@inheritDoc}// w ww .jav a 2s. com */ @Override public void onDrawOver(Canvas canvas, RecyclerView parent, RecyclerView.State state) { if (parent.getAdapter() == null) { return; } final int count = parent.getChildCount(); long previousHeaderId = -1; for (int layoutPos = 0; layoutPos < count; layoutPos++) { final View child = parent.getChildAt(layoutPos); int adapterPos = parent.getChildAdapterPosition(child); if (!mIncludeHeader) { if (parent.getAdapter() instanceof RecyclerArrayAdapter) { int headerCount = ((RecyclerArrayAdapter) parent.getAdapter()).getHeaderCount(); int footerCount = ((RecyclerArrayAdapter) parent.getAdapter()).getFooterCount(); int dataCount = ((RecyclerArrayAdapter) parent.getAdapter()).getCount(); if (adapterPos < headerCount) { continue; } if (adapterPos >= headerCount + dataCount) { continue; } if (adapterPos >= headerCount) { adapterPos -= headerCount; } } } if (adapterPos != RecyclerView.NO_POSITION && hasHeader(adapterPos)) { long headerId = mAdapter.getHeaderId(adapterPos); if (headerId != previousHeaderId) { previousHeaderId = headerId; View header = getHeader(parent, adapterPos).itemView; canvas.save(); final int left = child.getLeft(); final int top = getHeaderTop(parent, child, header, adapterPos, layoutPos); canvas.translate(left, top); header.setTranslationX(left); header.setTranslationY(top); header.draw(canvas); canvas.restore(); } } } }
From source file:com.sanjie.zy.adpter.decoration.StickyHeaderDecoration.java
/** * {@inheritDoc}//from w ww .j a v a2 s . c o m */ @Override public void onDrawOver(Canvas canvas, RecyclerView parent, RecyclerView.State state) { if (parent.getAdapter() == null) { return; } final int count = parent.getChildCount(); long previousHeaderId = -1; for (int layoutPos = 0; layoutPos < count; layoutPos++) { final View child = parent.getChildAt(layoutPos); int adapterPos = parent.getChildAdapterPosition(child); if (!mIncludeHeader) { if (parent.getAdapter() instanceof ZYRecyclerViewAdapter) { int headerCount = ((ZYRecyclerViewAdapter) parent.getAdapter()).getHeaderCount(); int footerCount = ((ZYRecyclerViewAdapter) parent.getAdapter()).getFooterCount(); int dataCount = ((ZYRecyclerViewAdapter) parent.getAdapter()).getDataCount(); if (adapterPos < headerCount) { continue; } if (adapterPos >= headerCount + dataCount) { continue; } if (adapterPos >= headerCount) { adapterPos -= headerCount; } } } if (adapterPos != RecyclerView.NO_POSITION && hasHeader(adapterPos)) { long headerId = mAdapter.getHeaderId(adapterPos); if (headerId != previousHeaderId) { previousHeaderId = headerId; View header = getHeader(parent, adapterPos).itemView; canvas.save(); final int left = child.getLeft(); final int top = getHeaderTop(parent, child, header, adapterPos, layoutPos); canvas.translate(left, top); header.setTranslationX(left); header.setTranslationY(top); header.draw(canvas); canvas.restore(); } } } }