List of usage examples for android.graphics.drawable BitmapDrawable BitmapDrawable
@Deprecated
public BitmapDrawable(java.io.InputStream is)
From source file:de.ub0r.android.websms.connector.o2.ConnectorO2.java
/** * Load captcha and wait for user input to solve it. * /*from ww w.j a v a 2 s .c om*/ * @param context * {@link Context} * @param flow * _flowExecutionKey * @return true if captcha was solved * @throws IOException * IOException */ private boolean solveCaptcha(final Context context, final String flow) throws IOException { HttpResponse response = Utils.getHttpClient(URL_CAPTCHA, null, null, TARGET_AGENT, URL_LOGIN, ENCODING, O2_SSL_FINGERPRINTS); int resp = response.getStatusLine().getStatusCode(); if (resp != HttpURLConnection.HTTP_OK) { throw new WebSMSException(context, R.string.error_http, "" + resp); } BitmapDrawable captcha = new BitmapDrawable(response.getEntity().getContent()); final Intent intent = new Intent(Connector.ACTION_CAPTCHA_REQUEST); intent.putExtra(Connector.EXTRA_CAPTCHA_DRAWABLE, captcha.getBitmap()); captcha = null; this.getSpec(context).setToIntent(intent); context.sendBroadcast(intent); try { synchronized (CAPTCHA_SYNC) { CAPTCHA_SYNC.wait(CAPTCHA_TIMEOUT); } } catch (InterruptedException e) { Log.e(TAG, null, e); return false; } if (captchaSolve == null) { return false; } // got user response, try to solve captcha Log.d(TAG, "got solved captcha: " + captchaSolve); final ArrayList<BasicNameValuePair> postData = // . new ArrayList<BasicNameValuePair>(3); postData.add(new BasicNameValuePair("_flowExecutionKey", flow)); postData.add(new BasicNameValuePair("_eventId", "submit")); postData.add(new BasicNameValuePair("riddleValue", captchaSolve)); response = Utils.getHttpClient(URL_SOLVECAPTCHA, null, postData, TARGET_AGENT, URL_LOGIN, ENCODING, O2_SSL_FINGERPRINTS); Log.d(TAG, postData.toString()); resp = response.getStatusLine().getStatusCode(); if (resp != HttpURLConnection.HTTP_OK) { throw new WebSMSException(context, R.string.error_http, "" + resp); } final String mHtmlText = Utils.stream2str(response.getEntity().getContent()); if (mHtmlText.indexOf(CHECK_WRONGCAPTCHA) > 0) { throw new WebSMSException(context, R.string.error_wrongcaptcha); } return true; }
From source file:kr.co.cashqc.MainActivity.java
@Override public void onItemSelected(View view, String name) { if (toast == null) { toast = Toast.makeText(mContext, "?? !~", Toast.LENGTH_SHORT); // toast.setGravity(Gravity.CENTER, 0, getScreenSize()/4); } else {//from ww w. ja v a 2 s. c o m // toast.setText("ddd"); } toast.show(); mPointText.setText("?? ? ?"); int drawable = 0; switch (view.getId()) { case R.id.wmain_chicken: mIntent.putExtra("TYPE", 1); drawable = R.drawable.bg_chicken; break; case R.id.wmain_pizza: mIntent.putExtra("TYPE", 2); drawable = R.drawable.bg_pizza; break; case R.id.wmain_chinese: mIntent.putExtra("TYPE", 3); drawable = R.drawable.bg_chinese; break; case R.id.wmain_korean: mIntent.putExtra("TYPE", 4); drawable = R.drawable.bg_korean; break; case R.id.wmain_dakbal: mIntent.putExtra("TYPE", 5); drawable = R.drawable.bg_dakbal; break; case R.id.wmain_night: mIntent.putExtra("TYPE", 6); drawable = R.drawable.bg_night; break; case R.id.wmain_bossam: mIntent.putExtra("TYPE", 7); drawable = R.drawable.bg_jokbal; break; case R.id.wmain_japanese: mIntent.putExtra("TYPE", 8); drawable = R.drawable.bg_japanese; break; } String uri = "drawable://" + drawable; ImageLoader.getInstance().loadImage(uri, new SimpleImageLoadingListener() { @Override public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) { Drawable topImage = new BitmapDrawable(loadedImage); mLinearLayout.setBackgroundDrawable(topImage); } }); }
From source file:com.example.android.navigationdrawerexample.Controller.PilihanController.java
@Override public void onResume() { super.onResume(); if (fragment.getArguments().getInt("role") == 1) { /*SharedPreferences sharedPreferences = getSharedPreferences(getString(R.string.profile_pref), MODE_PRIVATE);/*from w w w. jav a 2s .co m*/ String defaultS = ""; String path = sharedPreferences.getString(getString(R.string.path_foto), defaultS);*/ ProfileController profileController = new ProfileController(username); mahasiswa = profileController.getMahasiswa(username); if (mahasiswa.getPath() != null) ((ImageButton) rootView.findViewById(R.id.foto_profil)) .setBackgroundDrawable(new BitmapDrawable(BitmapFactory.decodeFile(mahasiswa.getPath()))); //new GetAllRole().execute(username); } }
From source file:com.aidigame.hisun.imengstar.huanxin.ChatActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_chat_huanxin); other = (MyUser) getIntent().getSerializableExtra("user"); rooLayout = (RelativeLayout) findViewById(R.id.root_layout); BitmapFactory.Options options = new BitmapFactory.Options(); options.inSampleSize = 4;/*from www. jav a 2 s. c om*/ rooLayout.setBackgroundDrawable( new BitmapDrawable(BitmapFactory.decodeResource(getResources(), R.drawable.blur, options))); if (other == null) { toChatUsername = getIntent().getStringExtra("userId"); conversation = EMChatManager.getInstance().getConversation(toChatUsername); if (conversation.getMsgCount() > 0) { EMMessage lastMessage = conversation.getLastMessage(); String nick = ""; String tx = ""; String userid = ""; try { userid = lastMessage.getStringAttribute("id"); nick = lastMessage.getStringAttribute("nickname"); tx = lastMessage.getStringAttribute("tx"); } catch (EaseMobException e) { // TODO Auto-generated catch block e.printStackTrace(); } if (("" + PetApplication.myUser.userId).equals(userid)) { try { nick = lastMessage.getStringAttribute("other_nickname"); tx = lastMessage.getStringAttribute("other_tx"); } catch (EaseMobException e) { // TODO Auto-generated catch block e.printStackTrace(); } } other = new MyUser(); other.u_nick = nick; other.u_iconUrl = tx; other.userId = Integer.parseInt(toChatUsername); } } initView(); setUpView(); if (!DemoHXSDKHelper.getInstance().isLogined()) { Dialog4Activity.listener = new Dialog4Activity.Dialog3ActivityListener() { @Override public void onClose() { // TODO Auto-generated method stub } @Override public void onButtonTwo() { // TODO Auto-generated method stub EMChatManager.getInstance().login("" + PetApplication.myUser.userId, PetApplication.myUser.code, new EMCallBack() { @Override public void onSuccess() { // TODO Auto-generated method stub PetApplication.setUserName("" + PetApplication.myUser.userId); PetApplication.setPassword(PetApplication.myUser.code); runOnUiThread(new Runnable() { @Override public void run() { // TODO Auto-generated method stub conversation = EMChatManager.getInstance() .getConversation(toChatUsername); adapter.conversation = EMChatManager.getInstance() .getConversation(toChatUsername); ; adapter.notifyDataSetChanged(); } }); } @Override public void onProgress(int arg0, String arg1) { // TODO Auto-generated method stub } @Override public void onError(int arg0, String arg1) { // TODO Auto-generated method stub } }); } @Override public void onButtonOne() { // TODO Auto-generated method stub } }; Intent intent = new Intent(this, Dialog4Activity.class); intent.putExtra("mode", 6); startActivity(intent); } }
From source file:com.github.topbottomsnackbar.TBSnackbar.java
@Deprecated private TBSnackbar addIcon(int resource_id, int size) { final TextView tv = mView.getMessageView(); tv.setCompoundDrawablesWithIntrinsicBounds(new BitmapDrawable(Bitmap.createScaledBitmap( ((BitmapDrawable) (mContext.getResources().getDrawable(resource_id))).getBitmap(), size, size, true)), null, null, null);/*w w w . ja va 2s . co m*/ return this; }
From source file:com.example.util.ImageUtils.java
/** * /*from w ww.j av a 2 s . c o m*/ */ public static void downloadHomeTopDrawable(Context context, String url, ImageView imageView) { CacheManager cache = CacheManager.getInstance(); if (cache.existsDrawable(url)) { BitmapDrawable background = new BitmapDrawable(cache.getDrawableFromCache(url)); StateListDrawable foreground = getMaskDrawable(context); imageView.setImageDrawable(foreground); imageView.setBackgroundDrawable(background); return; } Drawable defaultDrawable = context.getResources().getDrawable(R.drawable.banner_loading); if (cancelPotentialBitmapDownload(url, imageView)) { BitmapDownloaderTask task = new BitmapDownloaderTask(imageView); DownloadedDrawable1 downloadedDrawable = new DownloadedDrawable1(defaultDrawable, task); imageView.setImageDrawable(downloadedDrawable); task.execute(context, url, TYPE_TOP); } }
From source file:com.c4mprod.utils.ImageDownloader.java
public void setDefault_img(Bitmap bitmap) { this.default_img = new BitmapDrawable(bitmap); }
From source file:fi.tuukka.weather.utils.Utils.java
public static void showImage(Activity activity, View view, Bitmap bmp) { final Dialog imageDialog = new Dialog(activity); imageDialog.requestWindowFeature(Window.FEATURE_NO_TITLE); imageDialog.setContentView(R.layout.showimage); imageDialog.setCancelable(true);/*from w w w . j av a 2s . co m*/ ImageView imageView = (ImageView) imageDialog.findViewById(R.id.imageView); // Getting width & height of the given image. DisplayMetrics displayMetrics = activity.getResources().getDisplayMetrics(); int wn = displayMetrics.widthPixels; int hn = displayMetrics.heightPixels; int wo = bmp.getWidth(); int ho = bmp.getHeight(); Matrix mtx = new Matrix(); // Setting rotate to 90 mtx.preRotate(90); // Setting resize mtx.postScale(((float) 1.3 * wn) / ho, ((float) 1.3 * hn) / wo); // Rotating Bitmap Bitmap rotatedBMP = Bitmap.createBitmap(bmp, 0, 0, wo, ho, mtx, true); BitmapDrawable bmd = new BitmapDrawable(rotatedBMP); imageView.setImageDrawable(bmd); imageView.setOnClickListener(new View.OnClickListener() { public void onClick(View button) { imageDialog.dismiss(); } }); imageDialog.show(); }
From source file:com.android.mms.rcs.FavoriteDetailAdapter.java
private void initImageMsgView(LinearLayout linearLayout) { String thumbPath = mCursor/*from w ww . jav a2s .com*/ .getString(mCursor.getColumnIndexOrThrow(FavoriteMessageProvider.FavoriteMessage.THUMBNAIL)); String fileName = mCursor .getString(mCursor.getColumnIndexOrThrow(FavoriteMessageProvider.FavoriteMessage.FILE_NAME)); thumbPath = RcsUtils.formatFilePathIfExisted(thumbPath); fileName = RcsUtils.formatFilePathIfExisted(fileName); ImageView imageView = (ImageView) linearLayout.findViewById(R.id.image_view); Bitmap thumbPathBitmap = null; Bitmap filePathBitmap = null; if (!TextUtils.isEmpty(thumbPath)) { thumbPathBitmap = RcsUtils.decodeInSampleSizeBitmap(thumbPath); } else if (!TextUtils.isEmpty(fileName)) { filePathBitmap = RcsUtils.decodeInSampleSizeBitmap(fileName); } if (thumbPathBitmap != null) { imageView.setBackgroundDrawable(new BitmapDrawable(thumbPathBitmap)); } else if (filePathBitmap != null) { imageView.setBackgroundDrawable(new BitmapDrawable(filePathBitmap)); } else { imageView.setBackgroundResource(R.drawable.ic_attach_picture_holo_light); } }
From source file:com.landenlabs.all_UiDemo.frag.ImageScalesFrag.java
private Bitmap setScaledImage(final Drawable bgImage, View view, Bitmap prevScaled) { if (bgImage != null) { if (prevScaled != null) prevScaled.recycle();/*from www . j a v a2 s. c om*/ int screenWidthPx = Resources.getSystem().getDisplayMetrics().widthPixels; int viewHeightPx = view.getMeasuredHeight(); // view.setBackgroundResource(bgImage); if (bgImage instanceof BitmapDrawable) { BitmapDrawable bmDrawable = (BitmapDrawable) bgImage; Bitmap bmImage = bmDrawable.getBitmap(); prevScaled = scaleCenterCrop(bmImage, screenWidthPx, viewHeightPx); view.setBackgroundDrawable(new BitmapDrawable(prevScaled)); } else { // TODO - compute scale factor from screenWidthPx and viewHeightx Drawable scaleDrawable = new ScaleDrawable(bgImage, Gravity.NO_GRAVITY, 1.0f, 0.1f); view.setBackgroundDrawable(scaleDrawable); } } return prevScaled; }