List of usage examples for android.graphics.drawable BitmapDrawable BitmapDrawable
private BitmapDrawable(BitmapState state, Resources res)
From source file:com.andreaszeiser.bob.ImageWorker.java
/** * Called when the processing is complete and the final bitmap should be set * on the ImageView.//from w ww . ja v a 2 s .c om * * @param imageView * @param bitmap */ private void setImageBitmap(ImageView imageView, Bitmap bitmap) { if (mFadeInBitmap) { // Use TransitionDrawable to fade in final TransitionDrawable td = new TransitionDrawable(new Drawable[] { new ColorDrawable(android.R.color.transparent), new BitmapDrawable(mResources, bitmap) }); // noinspection deprecation imageView.setImageDrawable(td); td.startTransition(FADE_IN_TIME); } else { imageView.setImageBitmap(bitmap); } }
From source file:cl.monsoon.s1next.widget.PhotoView.java
/** * Binds a bitmap to the view./*from w w w . java 2 s. co m*/ * * @param photoBitmap the bitmap to bind. */ public void bindPhoto(Bitmap photoBitmap) { boolean currentDrawableIsBitmapDrawable = mDrawable instanceof BitmapDrawable; boolean changed = !(currentDrawableIsBitmapDrawable); if (mDrawable != null && currentDrawableIsBitmapDrawable) { final Bitmap drawableBitmap = ((BitmapDrawable) mDrawable).getBitmap(); if (photoBitmap == drawableBitmap) { // setting the same bitmap; do nothing return; } changed = photoBitmap != null && (mDrawable.getIntrinsicWidth() != photoBitmap.getWidth() || mDrawable.getIntrinsicHeight() != photoBitmap.getHeight()); // Reset mMinScale to ensure the bounds / matrix are recalculated mMinScale = 0f; mDrawable = null; } if (mDrawable == null && photoBitmap != null) { mDrawable = new BitmapDrawable(getResources(), photoBitmap); } configureBounds(changed); invalidate(); }
From source file:com.dvn.vindecoder.ui.user.GetAllVehicalDetails.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); Log.e("Activity sss1", "sds"); if (requestCode == GALLERY_REQUEST) { if (resultCode == RESULT_OK) { if (data != null) { uri = data.getData();/*from ww w . jav a 2 s . c om*/ image_path = uri.getPath(); //addNewVehicalFragment.setImagePath(image_path); BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = true; try { // BitmapFactory.decodeStream(getContentResolver().openInputStream(uri), null, options); options.inSampleSize = calculateInSampleSize(options, 100, 100); options.inJustDecodeBounds = false; Bitmap image = BitmapFactory.decodeStream(getContentResolver().openInputStream(uri), null, options); // car_image.setImageBitmap(image); //car_image1.setImageBitmap(image); /* Bitmap bitmap = ((BitmapDrawable) car_image.getDrawable()).getBitmap(); ByteArrayOutputStream bytes = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.JPEG, 90, bytes); File destination = new File(getCacheDir(), "car.jpg"); FileOutputStream fo; try { fo = new FileOutputStream(destination); fo.write(bytes.toByteArray()); fo.close(); } catch (IOException e) { e.printStackTrace(); } image_path = destination.getAbsolutePath();*/ // car_image.setImageBitmap(bitmap); // addNewVehicalFragment.setImagePath(image_path); } catch (Exception e) { e.printStackTrace(); } } else { Toast.makeText(getApplicationContext(), "Cancelled", Toast.LENGTH_SHORT).show(); } } else if (resultCode == RESULT_CANCELED) { Toast.makeText(getApplicationContext(), "Cancelled", Toast.LENGTH_SHORT).show(); } } else if (requestCode == CAMERA_REQUEST) { if (resultCode == RESULT_OK) { if (data.hasExtra("data")) { Bitmap bitmap = (Bitmap) data.getExtras().get("data"); /* ByteArrayOutputStream bytes = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.JPEG, 90, bytes); File destination = new File(getCacheDir(), "car.jpg"); FileOutputStream fo; try { fo = new FileOutputStream(destination); fo.write(bytes.toByteArray()); fo.close(); } catch (IOException e) { e.printStackTrace(); } image_path = destination.getAbsolutePath();*/ // car_image.setImageBitmap(bitmap); // car_image1.setImageBitmap(bitmap); // addNewVehicalFragment.setImagePath(image_path); } else if (data.getExtras() == null) { Toast.makeText(getApplicationContext(), "No extras to retrieve!", Toast.LENGTH_SHORT).show(); BitmapDrawable thumbnail = new BitmapDrawable(getResources(), data.getData().getPath()); //img_view_drivingLicense.setImageDrawable(thumbnail); // car_image.setImageDrawable(thumbnail); // car_image1.setImageDrawable(thumbnail); } } else if (resultCode == RESULT_CANCELED) { Toast.makeText(getApplicationContext(), "Cancelled", Toast.LENGTH_SHORT).show(); } } }
From source file:com.image.cache.util.ImageWorker.java
/** * Called when the processing is complete and the final drawable should be * set on the ImageView./*ww w . ja va 2 s.c o m*/ * * @param imageView * @param drawable */ private void setImageDrawable(ImageView imageView, Drawable drawable) { if (mFadeInBitmap) { // Transition drawable with a transparent drawable and the final drawable final TransitionDrawable td = new TransitionDrawable( new Drawable[] { new ColorDrawable(android.R.color.transparent), drawable }); // Set background to loading bitmap imageView.setImageDrawable(new BitmapDrawable(mResources, mLoadingBitmap)); imageView.setImageDrawable(td); td.startTransition(FADE_IN_TIME); } else { imageView.setImageDrawable(drawable); } }
From source file:com.linhnv.apps.maxim.utils.ImageWorker.java
private BitmapDrawable roundCornered(BitmapDrawable scaledBitmap, int i) { Bitmap bitmap = scaledBitmap.getBitmap(); Bitmap result = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(result); int color = 0xff424242; Paint paint = new Paint(); Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight()); RectF rectF = new RectF(rect); int roundPx = i; paint.setAntiAlias(true);//from w w w.j av a 2 s. co m canvas.drawARGB(0, 0, 0, 0); // paint.setColor(Color.BLUE); canvas.drawRoundRect(rectF, roundPx, roundPx, paint); paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN)); canvas.drawBitmap(bitmap, rect, rect, paint); BitmapDrawable finalresult = new BitmapDrawable(mResources, result); return finalresult; }
From source file:com.gtx.cooliris.imagecache.ImageWorker.java
/** * Called when the processing is complete and the final drawable should be * set on the ImageView.//from w ww . ja va 2 s .c om * * @param imageView * @param drawable */ private void setImageDrawable(IAsyncImageView imageView, Drawable drawable) { if (mFadeInBitmap) { // Transition drawable with a transparent drawable and the final drawable final TransitionDrawable td = new TransitionDrawable( new Drawable[] { new ColorDrawable(android.R.color.transparent), drawable }); // Set background to loading bitmap if (null != mLoadingBitmap) { imageView.setBackgroundDrawable(new BitmapDrawable(mResources, mLoadingBitmap)); } imageView.setImageDrawable(td); td.startTransition(FADE_IN_TIME); } else { imageView.setImageDrawable(drawable); } }
From source file:com.image.cache.util.ImageWorker.java
private void setImageDrawableFrame(ImageView imageView, Drawable drawable) { if (mFadeInBitmap) { // Transition drawable with a transparent drawable and the final drawable final TransitionDrawable td = new TransitionDrawable( new Drawable[] { new ColorDrawable(android.R.color.transparent), drawable }); // Set background to loading bitmap imageView.setImageDrawable(new BitmapDrawable(mResources, mLoadingBitmap)); imageView.setImageDrawable(td);/* w w w . ja v a 2 s. c o m*/ td.startTransition(FADE_IN_TIME); } else { imageView.setImageDrawable(drawable); } }
From source file:keyboard.ecloga.com.eclogakeyboard.EclogaKeyboard.java
@Override public void onStartInputView(EditorInfo info, boolean restarting) { initializeKeyboard();/*from ww w . j av a 2 s . c o m*/ onRotate(); if (mVoiceRecognitionTrigger != null) { mVoiceRecognitionTrigger.onStartInputView(); } vbListenerPause = false; if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("random")) { Random rand = new Random(); int randInt = rand.nextInt(25); switch (randInt) { case 1: kv.setBackgroundColor(getResources().getColor(R.color.white)); break; case 2: kv.setBackgroundColor(getResources().getColor(R.color.black)); break; case 3: kv.setBackgroundColor(getResources().getColor(R.color.purple)); break; case 4: kv.setBackgroundColor(getResources().getColor(R.color.red)); break; case 5: kv.setBackgroundColor(getResources().getColor(R.color.pink)); break; case 6: kv.setBackgroundColor(getResources().getColor(R.color.blue)); break; case 7: kv.setBackgroundColor(getResources().getColor(R.color.green)); break; case 8: kv.setBackgroundColor(getResources().getColor(R.color.yellow)); break; case 9: kv.setBackgroundColor(getResources().getColor(R.color.orange)); break; case 10: kv.setBackgroundColor(getResources().getColor(R.color.grey)); break; case 11: kv.setBackgroundColor(getResources().getColor(R.color.lightpurple)); break; case 12: kv.setBackgroundColor(getResources().getColor(R.color.lightred)); break; case 13: kv.setBackgroundColor(getResources().getColor(R.color.lightpink)); break; case 14: kv.setBackgroundColor(getResources().getColor(R.color.lightblue)); break; case 15: kv.setBackgroundColor(getResources().getColor(R.color.lightgreen)); break; case 16: kv.setBackgroundColor(getResources().getColor(R.color.lightyellow)); break; case 17: kv.setBackgroundColor(getResources().getColor(R.color.lightgrey)); break; case 18: kv.setBackgroundColor(getResources().getColor(R.color.lightorange)); break; case 19: kv.setBackgroundColor(getResources().getColor(R.color.darkpurple)); break; case 20: kv.setBackgroundColor(getResources().getColor(R.color.darkorange)); break; case 21: kv.setBackgroundColor(getResources().getColor(R.color.darkblue)); break; case 22: kv.setBackgroundColor(getResources().getColor(R.color.darkgreen)); break; case 23: kv.setBackgroundColor(getResources().getColor(R.color.darkred)); break; case 24: kv.setBackgroundColor(getResources().getColor(R.color.darkyellow)); break; case 25: kv.setBackgroundColor(getResources().getColor(R.color.darkpink)); break; } } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("pattern_1")) { kv.setBackgroundResource(R.drawable.pattern_1); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("pattern_2")) { kv.setBackgroundResource(R.drawable.pattern_2); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("pattern_3")) { kv.setBackgroundResource(R.drawable.pattern_3); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("pattern_4")) { kv.setBackgroundResource(R.drawable.pattern_4); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("pattern_5")) { kv.setBackgroundResource(R.drawable.pattern_5); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("pattern_6")) { kv.setBackgroundResource(R.drawable.pattern_6); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("pattern_7")) { kv.setBackgroundResource(R.drawable.pattern_7); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("pattern_8")) { kv.setBackgroundResource(R.drawable.pattern_8); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("pattern_9")) { kv.setBackgroundResource(R.drawable.pattern_9); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("pattern_10")) { kv.setBackgroundResource(R.drawable.pattern_10); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("pattern_11")) { kv.setBackgroundResource(R.drawable.pattern_11); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("pattern_12")) { kv.setBackgroundResource(R.drawable.pattern_12); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("pattern_13")) { kv.setBackgroundResource(R.drawable.pattern_13); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("pattern_14")) { kv.setBackgroundResource(R.drawable.pattern_14); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("pattern_15")) { kv.setBackgroundResource(R.drawable.pattern_15); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("pattern_16")) { kv.setBackgroundResource(R.drawable.pattern_16); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("pattern_17")) { kv.setBackgroundResource(R.drawable.pattern_17); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("nature_1")) { kv.setBackgroundResource(R.drawable.nature_1); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("nature_2")) { kv.setBackgroundResource(R.drawable.nature_2); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("nature_3")) { kv.setBackgroundResource(R.drawable.nature_3); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("nature_4")) { kv.setBackgroundResource(R.drawable.nature_4); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("nature_5")) { kv.setBackgroundResource(R.drawable.nature_5); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("nature_6")) { kv.setBackgroundResource(R.drawable.nature_6); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("nature_7")) { kv.setBackgroundResource(R.drawable.nature_7); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("nature_8")) { kv.setBackgroundResource(R.drawable.nature_8); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("nature_9")) { kv.setBackgroundResource(R.drawable.nature_9); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("nature_10")) { kv.setBackgroundResource(R.drawable.nature_10); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("nature_11")) { kv.setBackgroundResource(R.drawable.nature_11); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("nature_12")) { kv.setBackgroundResource(R.drawable.nature_12); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("nature_13")) { kv.setBackgroundResource(R.drawable.nature_13); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("nature_14")) { kv.setBackgroundResource(R.drawable.nature_14); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("black")) { kv.setBackgroundColor(getResources().getColor(R.color.black)); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("white")) { kv.setBackgroundColor(getResources().getColor(R.color.white)); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("transparent")) { kv.setBackgroundColor(getResources().getColor(R.color.transparent)); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("gradient_1")) { kv.setBackgroundResource(R.drawable.gradient_1); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("gradient_2")) { kv.setBackgroundResource(R.drawable.gradient_2); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("gradient_3")) { kv.setBackgroundResource(R.drawable.gradient_3); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("gradient_4")) { kv.setBackgroundResource(R.drawable.gradient_4); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("gradient_5")) { kv.setBackgroundResource(R.drawable.gradient_5); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("gradient_6")) { kv.setBackgroundResource(R.drawable.gradient_6); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("gradient_7")) { kv.setBackgroundResource(R.drawable.gradient_7); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("gradient_8")) { kv.setBackgroundResource(R.drawable.gradient_8); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("gradient_9")) { kv.setBackgroundResource(R.drawable.gradient_9); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("gradient_10")) { kv.setBackgroundResource(R.drawable.gradient_10); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("red")) { kv.setBackgroundColor(getResources().getColor(R.color.red)); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("pink")) { kv.setBackgroundColor(getResources().getColor(R.color.pink)); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("purple")) { kv.setBackgroundColor(getResources().getColor(R.color.purple)); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("blue")) { kv.setBackgroundColor(getResources().getColor(R.color.blue)); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("green")) { kv.setBackgroundColor(getResources().getColor(R.color.green)); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("yellow")) { kv.setBackgroundColor(getResources().getColor(R.color.yellow)); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("orange")) { kv.setBackgroundColor(getResources().getColor(R.color.orange)); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("grey")) { kv.setBackgroundColor(getResources().getColor(R.color.grey)); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("lightred")) { kv.setBackgroundColor(getResources().getColor(R.color.lightred)); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("lightpink")) { kv.setBackgroundColor(getResources().getColor(R.color.lightpink)); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("lightpurple")) { kv.setBackgroundColor(getResources().getColor(R.color.lightpurple)); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("lightblue")) { kv.setBackgroundColor(getResources().getColor(R.color.lightblue)); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("lightgreen")) { kv.setBackgroundColor(getResources().getColor(R.color.lightgreen)); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("lightyellow")) { kv.setBackgroundColor(getResources().getColor(R.color.lightyellow)); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("lightorange")) { kv.setBackgroundColor(getResources().getColor(R.color.lightorange)); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("lightgrey")) { kv.setBackgroundColor(getResources().getColor(R.color.lightgrey)); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("darkred")) { kv.setBackgroundColor(getResources().getColor(R.color.darkred)); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("darkpink")) { kv.setBackgroundColor(getResources().getColor(R.color.darkpink)); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("darkpurple")) { kv.setBackgroundColor(getResources().getColor(R.color.darkpurple)); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("darkblue")) { kv.setBackgroundColor(getResources().getColor(R.color.darkblue)); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("darkgreen")) { kv.setBackgroundColor(getResources().getColor(R.color.darkgreen)); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("darkyellow")) { kv.setBackgroundColor(getResources().getColor(R.color.darkyellow)); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("darkorange")) { kv.setBackgroundColor(getResources().getColor(R.color.darkorange)); } else if (Preferences.getDefaults("bgcolor", getApplicationContext()).equals("darkgrey")) { kv.setBackgroundColor(getResources().getColor(R.color.darkgrey)); } else { String uploadString = Preferences.getDefaults("bgcolor", getApplicationContext()); byte[] decodedString = Base64.decode(uploadString, Base64.URL_SAFE); Bitmap photo = BitmapFactory.decodeByteArray(decodedString, 0, decodedString.length); BitmapDrawable bdrawable = new BitmapDrawable(getApplication().getResources(), photo); kv.setBackgroundDrawable(bdrawable); } if (Preferences.getDefaults("autocapitalize", getApplicationContext()).equals("true")) { autoCapitalize = true; } else if (Preferences.getDefaults("autocapitalize", getApplicationContext()).equals("false")) { autoCapitalize = false; } if (Preferences.getDefaults("volumebuttons", getApplicationContext()).equals("true")) { volumeButtons = true; } else if (Preferences.getDefaults("volumebuttons", getApplicationContext()).equals("false")) { volumeButtons = false; } if (Preferences.getDefaults("allcaps", getApplicationContext()).equals("true")) { allCaps = true; } else if (Preferences.getDefaults("allcaps", getApplicationContext()).equals("false")) { allCaps = false; } if (Preferences.getDefaults("autospacing", getApplicationContext()).equals("true")) { autoSpacing = true; } else if (Preferences.getDefaults("autospacing", getApplicationContext()).equals("false")) { autoSpacing = false; } if (Preferences.getDefaults("changekeyboard", getApplicationContext()).equals("true")) { changeKeyboard = true; } else if (Preferences.getDefaults("changekeyboard", getApplicationContext()).equals("false")) { changeKeyboard = false; } if (Preferences.getDefaults("shakedelete", getApplicationContext()).equals("true")) { shakeDelete = true; } else if (Preferences.getDefaults("shakedelete", getApplicationContext()).equals("false")) { shakeDelete = false; } if (Preferences.getDefaults("doublespace", getApplicationContext()).equals("true")) { spaceDot = true; } else if (Preferences.getDefaults("doublespace", getApplicationContext()).equals("false")) { spaceDot = false; } if (Preferences.getDefaults("voiceinput", getApplicationContext()).equals("true")) { voiceInput = true; } else if (Preferences.getDefaults("voiceinout", getApplicationContext()).equals("false")) { voiceInput = false; } if (Preferences.getDefaults("popup", getApplicationContext()).equals("true")) { popupKeypress = true; } else if (Preferences.getDefaults("popup", getApplicationContext()).equals("false")) { popupKeypress = false; } if (Preferences.getDefaults("oppositecase", getApplicationContext()).equals("true")) { oppositeCase = true; } else if (Preferences.getDefaults("oppositecase", getApplicationContext()).equals("false")) { oppositeCase = false; } if (changeKeyboard) { MovementDetector.getInstance(getApplicationContext()).start(); MovementDetector.getInstance(getApplicationContext()).addListener(new MovementDetector.Listener() { @Override public void onMotionDetected(SensorEvent event, float acceleration) { if (MovementDetector.direction[1].equals("LEFT")) { playSwipeH(); onSwipeLeft(); } else if (MovementDetector.direction[1].equals("RIGHT")) { playSwipeH(); onSwipeRight(); } if (MovementDetector.direction[0].equals("UP")) { playSwipeV(); onSwipeUp(); } else if (MovementDetector.direction[0].equals("DOWN")) { playSwipeV(); onSwipeDown(); } } }); } keypresscounter1 = Preferences.getDefaults("keypresscounter1", getApplicationContext()); keypresscounter2 = Preferences.getDefaults("keypresscounter2", getApplicationContext()); keypresscounter3 = Preferences.getDefaults("keypresscounter3", getApplicationContext()); keyPressCounter = Integer.parseInt(Preferences.getDefaults("keypresses", getApplicationContext())); time1 = Preferences.getDefaults("time1", getApplicationContext()); time2 = Preferences.getDefaults("time2", getApplicationContext()); time3 = Preferences.getDefaults("time3", getApplicationContext()); time = Integer.parseInt(Preferences.getDefaults("time", getApplicationContext())); tTime = new CountDownTimer(60000, 1000) { @Override public void onTick(long millisUntilFinished) { time = time + 1; if (time > 300 && time <= 960 && time1.equals("false")) { NotificationManager notif = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); Notification notify = new Notification(R.drawable.notify, "Ecloga Keyboard", System.currentTimeMillis()); PendingIntent pending = PendingIntent.getActivity(getApplicationContext(), 0, new Intent(getApplicationContext(), Home.class), 0); notify.setLatestEventInfo(getApplicationContext(), "Warming up!", "Type more than 360 seconds", pending); notif.notify(0, notify); Preferences.setDefaults("time1", "true", getApplicationContext()); } else if (time > 960 && time <= 3600 && time2.equals("false")) { NotificationManager notif = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); Notification notify = new Notification(R.drawable.notify, "Ecloga Keyboard", System.currentTimeMillis()); PendingIntent pending = PendingIntent.getActivity(getApplicationContext(), 0, new Intent(getApplicationContext(), Home.class), 0); notify.setLatestEventInfo(getApplicationContext(), "Keep it up!", "Type more than 960 seconds", pending); notif.notify(0, notify); Preferences.setDefaults("time2", "true", getApplicationContext()); } else if (time > 3600 && time3.equals("false")) { NotificationManager notif = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); Notification notify = new Notification(R.drawable.notify, "Ecloga Keyboard", System.currentTimeMillis()); PendingIntent pending = PendingIntent.getActivity(getApplicationContext(), 0, new Intent(getApplicationContext(), Home.class), 0); notify.setLatestEventInfo(getApplicationContext(), "Typing master!", "Type more than 3600 seconds", pending); notif.notify(0, notify); Preferences.setDefaults("time3", "true", getApplicationContext()); } Preferences.setDefaults("time", String.valueOf(time), getApplicationContext()); } @Override public void onFinish() { tTime.start(); } }.start(); if (popupKeypress) { kv.setPreviewEnabled(true); } else { kv.setPreviewEnabled(false); } if (shakeDelete) { mShaker = new ShakeListener(this); mShaker.setOnShakeListener(new ShakeListener.OnShakeListener() { public void onShake() { InputConnection ic = getCurrentInputConnection(); ic.deleteSurroundingText(500, 500); } }); } super.onStartInputView(info, restarting); }
From source file:com.benefit.buy.library.http.query.callback.BitmapAjaxCallback.java
private static Drawable makeDrawable(ImageView iv, Bitmap bm, float ratio, float anchor) { BitmapDrawable bd = null;//from ww w.j a v a 2 s .c o m if (ratio > 0) { bd = new RatioDrawable(iv.getResources(), bm, iv, ratio, anchor); } else { bd = new BitmapDrawable(iv.getResources(), bm); } return bd; }
From source file:chinanurse.cn.nurse.Fragment_Nurse_job.IdentityFragment_ACTIVITY.java
/** * ????//www .j a va 2 s.co m * * @param data */ private void getImageToView(Intent data) { Bundle extras = data.getExtras(); if (extras != null) { Bitmap photo = extras.getParcelable("data"); Drawable drawable = new BitmapDrawable(this.getResources(), photo); picname = "avatar" + user.getUserid() + String.valueOf(new Date().getTime()); storeImageToSDCARD(photo, picname, filepath); if (HttpConnect.isConnnected(activity)) { new StudyRequest(activity, handler).updateUserImg(head, KEY); } else { Toast.makeText(activity, R.string.net_erroy, Toast.LENGTH_SHORT).show(); } } }