public void setCaptImage(Uri ur, int src) { BitMapManipulation bm = new BitMapManipulation(); // String path; switch (imgIdG) { case 0: captView[0].findViewById(R.id.captBtn1).setVisibility(View.GONE); captImg[0].setVisibility(View.VISIBLE); captImg[0].setLongClickable(true); captImg[0].setOnTouchListener(this); if (captImg[0] != null) { captImg[0].destroyDrawingCache(); } System.gc(); Runtime.getRuntime().gc(); bmp[0] = bm.createBMP(src, ur.toString(), captImg[0].getWidth(), captImg[0].getHeight()); resetView(captImg[0]); captImg[0].setImageBitmap(bmp[0]); captImg[0].invalidate(); Toast.makeText(this, "id: " + imgIdG, Toast.LENGTH_SHORT).show(); break; case 1: if (MAX_COL == 1) { captView[1].findViewById(R.id.captBtn1).setVisibility(View.GONE); captImg[1].setVisibility(View.VISIBLE); captImg[1].setOnTouchListener(this); bmp[1] = bm.createBMP(src, ur.toString(), captImg[0].getWidth(), captImg[0].getHeight()); resetView(captImg[1]); captImg[1].setImageBitmap(bmp[1]); } else { captView[0].findViewById(R.id.captBtn2).setVisibility(View.GONE); captImg[1].setVisibility(View.VISIBLE); captImg[1].setOnTouchListener(this); bmp[1] = bm.createBMP(src, ur.toString(), captImg[0].getWidth(), captImg[0].getHeight()); resetView(captImg[1]); captImg[1].setImageBitmap(bmp[1]); } Toast.makeText(this, "id: " + imgIdG, Toast.LENGTH_SHORT).show(); break; case 2: captView[1].findViewById(R.id.captBtn1).setVisibility(View.GONE); captImg[2].setVisibility(View.VISIBLE); captImg[2].setOnTouchListener(this); bmp[2] = bm.createBMP(src, ur.toString(), captImg[2].getWidth(), captImg[2].getHeight()); resetView(captImg[2]); captImg[2].setImageBitmap(bmp[2]); break; case 3: captView[1].findViewById(R.id.captBtn2).setVisibility(View.GONE); captImg[3].setVisibility(View.VISIBLE); captImg[3].setOnTouchListener(this); bmp[3] = bm.createBMP(src, ur.toString(), captImg[0].getWidth(), captImg[0].getHeight()); resetView(captImg[3]); captImg[3].setImageBitmap(bmp[3]); break; } System.gc(); Runtime.getRuntime().gc(); }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // displayWidth and displayHeight will change depending on screen // orientation. To get these dynamically, we should hook // onSizeChanged(). // This simple example uses only landscape mode, so it's ok to get them // once on startup and use those values throughout. mContext = this; Intent intent = getIntent(); if (intent != null) { MAX_COL = intent.getIntExtra("MAX_COL", 1); for (int i = 0; i < 2; i++) { imageSelPath[i] = intent.getStringExtra(Integer.toString(i)); } } Display display = ((WindowManager) getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay(); displayWidth = display.getWidth(); displayHeight = display.getHeight(); setContentView(R.layout.main_capture_screen); // /// home = (ImageView) findViewById(R.id.homeLogoD); text = (TextView) findViewById(R.id.title); showDrawer = (RelativeLayout) findViewById(R.layout.drawer); myLayout = (RelativeLayout) findViewById(R.id.titleBarIn); hiddenInfo = getLayoutInflater().inflate(R.layout.drawer, myLayout, false); home.setVisibility(4); text.setVisibility(4); myLayout.addView(hiddenInfo); // ////// initialize(); BitMapManipulation bm = new BitMapManipulation(); int j = 0; for (int i = 0; i < 2; i++) { if (imageSelPath[i] != null) { captView[j].findViewById(R.id.captBtn1).setVisibility(View.GONE); captImg[j].setVisibility(View.VISIBLE); captImg[j].setLongClickable(true); captImg[j].setOnTouchListener(this); if (captImg[j] != null) { captImg[j].destroyDrawingCache(); } System.gc(); Runtime.getRuntime().gc(); bmp[0] = bm.createBMP(1, imageSelPath[i], displayWidth, displayHeight / 2 - 20); resetView(captImg[0]); captImg[j].setImageBitmap(bmp[0]); j++; } else if (MyGalleryAdapter.imgPath.size() == 0) { if (HomeScreenActivity.selEnabled > 0) { if (HomeScreenActivity.itemsSelected[i] != -999) { captView[j].findViewById(R.id.captBtn1).setVisibility(View.GONE); captImg[j].setVisibility(View.VISIBLE); captImg[j].setLongClickable(true); captImg[j].setOnTouchListener(this); captImg[j].setImageResource( MyGalleryAdapter.SAMPLE_IMAGES[HomeScreenActivity.itemsSelected[i]]); j++; } } } } firstRunPreferences(); if (getFirstRun(0)) { Intent demoIntent = new Intent(CaptureActivity.this, DemoActivity.class); startActivity(demoIntent); setRunned(0); } }