public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (savedInstanceState == null) { x = 50; } else { x = savedInstanceState.getInt("x"); } y = 50; vw = new MyView(this); vw.setFocusable(true); vw.setFocusableInTouchMode(true); setContentView(vw); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_canvas); myView = (MyView) findViewById(R.id.myView); Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.android); myView.setBitmap(bitmap); Intent intent = getIntent(); if (intent != null) { MyView.DrawMode drawMode = MyView.DrawMode.valueOf(intent.getIntExtra("drawMode", 0)); myView.setDrawMode(drawMode); } }
@Override protected void onDestroy() { super.onDestroy(); if (myView != null) { myView.destroy(); myView = null; } }
@Override public View getView(final int position, View convertView, ViewGroup parent) { final MyView view; if (convertView == null) { view = new MyView(); convertView = mInflater.inflate(R.layout.list_pro_type_item, null); view.icon = (ImageView) convertView.findViewById(R.id.typeicon); view.name = (TextView) convertView.findViewById(R.id.typename); convertView.setTag(view); } else { view = (MyView) convertView.getTag(); } if (list != null && list.size() > 0) { type = list.get(position); if (type != null) { view.name.setText(type.getProduct_name()); imageLoader.displayImage( type.getProduct_pic(), view.icon, UniversityApplication.options, animateFirstListener); } } return convertView; }
@Inject public GraphZoomPresenter( EventBus eventBus, MyView view, MyProxy proxy, Graphs graphs, @Named("zoom") Context context, Provider<NavigationBar> navigationBarProvider) { super(eventBus, view, proxy); this.context = context; this.graphs = graphs; this.navigationBarProvider = navigationBarProvider; view.setUiHandlers(this); }
@Override public boolean onOptionsItemSelected(MenuItem item) { mPaint.setXfermode(null); mPaint.setAlpha(0xFF); switch (item.getItemId()) { case COLOR_MENU_ID: new ColorPickerDialog(this, this, mPaint.getColor()).show(); return true; case EMBOSS_MENU_ID: if (mPaint.getMaskFilter() != mEmboss) { mPaint.setMaskFilter(mEmboss); } else { mPaint.setMaskFilter(null); } return true; case BLUR_MENU_ID: if (mPaint.getMaskFilter() != mBlur) { mPaint.setMaskFilter(mBlur); } else { mPaint.setMaskFilter(null); } return true; case ERASE_MENU_ID: mPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR)); return true; case SRCATOP_MENU_ID: mPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_ATOP)); mPaint.setAlpha(0x80); return true; case SAVE_MENU_ID: Log.v("PaintActivity", "saveButtonPresed"); // Save current as bitmap // String filename = "/sdcard/mypic.png"; String filename = "mypic.png"; FileHelper.saveBitmapWithFilename(myView.getBitmapCopy(), filename); return true; } return super.onOptionsItemSelected(item); }