List of usage examples for android.widget ImageView setImageBitmap
@android.view.RemotableViewMethod public void setImageBitmap(Bitmap bm)
From source file:com.luke.lukef.lukeapp.fragments.NewSubmissionFragment.java
/** * Handles updating the categories on the submission screen, based on user selection *//*from ww w .j a v a2s . co m*/ private void updateCategoryThumbnails() { this.categoriesLinearLayout.removeAllViews(); for (Category c : this.confirmedCategories) { ImageView categoryImg = new ImageView(this.getMainActivity()); categoryImg.setImageBitmap(c.getImage()); LinearLayout.LayoutParams make = new LinearLayout.LayoutParams(new LinearLayout.LayoutParams( this.categoriesLinearLayout.getHeight(), this.categoriesLinearLayout.getHeight())); categoryImg.setLayoutParams(make); this.categoriesLinearLayout.addView(categoryImg); } }
From source file:com.twotoasters.android.horizontalimagescroller.io.ImageCacheManager.java
private void bindFromMap(ImageUrlRequestCacheKey key, ImageView imageView) { imageView.setImageBitmap(memoryCache.get(key)); }
From source file:hongik.android.project.best.StoreActivity.java
public void drawPage() throws Exception { String query = "func=storereview" + "&license=" + license; DBConnector conn = new DBConnector(query); conn.start();//from w w w. j a va 2s .co m conn.join(); JSONObject jsonResult = conn.getResult(); boolean result = jsonResult.getBoolean("result"); if (!result) return; final JSONObject store = jsonResult.getJSONArray("store").getJSONObject(0); JSONArray menu = null; if (!jsonResult.isNull("menu")) menu = jsonResult.getJSONArray("menu"); JSONArray review = null; if (!jsonResult.isNull("review")) review = jsonResult.getJSONArray("review"); //Draw Store Information Lat = Double.parseDouble(store.getString("LAT")); Lng = Double.parseDouble(store.getString("LNG")); sname = store.getString("SNAME"); ((TextViewPlus) findViewById(R.id.store_storename)).setText(sname); ((TextViewPlus) findViewById(R.id.store_address)).setText(store.getString("ADDR")); ImageLoader imgLoader = new ImageLoader(store.getString("IMG")); imgLoader.start(); try { imgLoader.join(); Bitmap storeImg = imgLoader.getBitmap(); ((ImageView) findViewById(R.id.store_image)).setImageBitmap(storeImg); } catch (InterruptedException e) { Toast.makeText(this, "Can not bring " + license + "store's image", Toast.LENGTH_SHORT).show(); Log.e("StoreInfo", "Can not bring " + license + "store's image"); } //Draw Menu Table if (menu != null) { TableRow motive = (TableRow) menuTable.getChildAt(1); for (int i = 0; i < menu.length(); i++) { JSONObject json = menu.getJSONObject(i); TableRow tbRow = new TableRow(this); TextViewPlus[] tbCols = new TextViewPlus[3]; final String[] elements = new String[2]; elements[0] = json.getString("ITEM#"); elements[1] = json.getString("PRICE"); imgLoader = new ImageLoader(json.getString("IMG")); imgLoader.start(); imgLoader.join(); ImageView img = new ImageView(this); Bitmap bitmap = imgLoader.getBitmap(); img.setImageBitmap(bitmap); img.setLayoutParams(motive.getChildAt(0).getLayoutParams()); img.setScaleType(ImageView.ScaleType.FIT_XY); img.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent storeIntent = new Intent(originActivity, MenuActivity.class); storeIntent.putExtra("LICENSE", license); storeIntent.putExtra("MENU", elements[0]); startActivity(storeIntent); } }); tbRow.addView(img); for (int j = 0; j < 2; j++) { tbCols[j] = new TextViewPlus(this); tbCols[j].setText(elements[j]); tbCols[j].setLayoutParams(motive.getChildAt(j + 1).getLayoutParams()); tbCols[j].setGravity(Gravity.CENTER); tbCols[j].setTypeface(Typeface.createFromAsset(tbCols[j].getContext().getAssets(), "InterparkGothicBold.ttf")); tbCols[j].setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent storeIntent = new Intent(originActivity, MenuActivity.class); storeIntent.putExtra("LICENSE", license); storeIntent.putExtra("MENU", elements[0]); startActivity(storeIntent); } }); Log.i("StoreMenu", "COL" + j + ":" + elements[j]); tbRow.addView(tbCols[j]); } menuTable.addView(tbRow); } } menuTable.removeViewAt(1); //Draw Review Table if (review != null) { TableRow motive = (TableRow) reviewTable.getChildAt(1); int rowCnt = 5; if (review.length() < 5) rowCnt = review.length(); for (int i = 0; i < rowCnt; i++) { JSONObject json = review.getJSONObject(i); final String[] elements = new String[4]; elements[0] = Double.parseDouble(json.getString("GRADE")) + ""; elements[1] = json.getString("NOTE"); elements[2] = json.getString("CID#"); elements[3] = json.getString("DAY"); TableRow tbRow = new TableRow(this); TextViewPlus[] tbCols = new TextViewPlus[4]; if (elements[1].length() > 14) elements[1] = elements[1].substring(0, 14) + "..."; for (int j = 0; j < 4; j++) { tbCols[j] = new TextViewPlus(this); tbCols[j].setText(elements[j]); tbCols[j].setLayoutParams(motive.getChildAt(j).getLayoutParams()); tbCols[j].setGravity(Gravity.CENTER); tbCols[j].setTypeface(Typeface.createFromAsset(tbCols[j].getContext().getAssets(), "InterparkGothicBold.ttf")); tbCols[j].setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent reviewIntent = new Intent(originActivity, ReviewDetailActivity.class); reviewIntent.putExtra("ACCESS", "STORE"); reviewIntent.putExtra("CID", elements[2]); reviewIntent.putExtra("LICENSE", license); Log.i("StoreReview", "StartActivity"); startActivity(reviewIntent); } }); Log.i("StoreMenu", "COL" + j + ":" + elements[j]); tbRow.addView(tbCols[j]); } reviewTable.addView(tbRow); } } reviewTable.removeViewAt(1); SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager() .findFragmentById(R.id.store_map); mapFragment.getMapAsync(this); }
From source file:com.eyekabob.ArtistInfo.java
private void handleImageResponse(Bitmap img) { DisplayMetrics metrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(metrics); float metWidth = metrics.widthPixels; float imgWidth = img.getWidth(); float ratio = metWidth / imgWidth; // Add a little buffer room int newWidth = (int) Math.floor(img.getWidth() * ratio) - 50; int newHeight = (int) Math.floor(img.getHeight() * ratio) - 50; ImageView iv = (ImageView) findViewById(R.id.infoImageView); Bitmap rescaledImg = Bitmap.createScaledBitmap(img, newWidth, newHeight, false); iv.setImageBitmap(rescaledImg); imageInfoReturned = true;/*from w ww . ja va 2 s. com*/ dismissDialogIfReady(); }
From source file:com.friedran.appengine.dashboard.gui.DashboardLoadFragment.java
private void updateChartImage(View chartView, Bitmap image, boolean animate) { ImageView chartImageView = (ImageView) chartView.findViewById(R.id.load_chart_image); if (image != null) { chartImageView.setImageBitmap(image); } else {/*from w w w. j ava2s.c om*/ chartImageView.setImageResource(android.R.color.transparent); Toast.makeText(mActivity, "Failed downloading charts, please make sure you have Internet connectivity and try refreshing", 2000).show(); } ViewSwitcher viewSwitcher = (ViewSwitcher) chartView.findViewById(R.id.load_chart_switcher); if (viewSwitcher.getDisplayedChild() != 1) { if (animate) { viewSwitcher.setAnimation(AnimationUtils.loadAnimation(mActivity, R.anim.fadein)); } else viewSwitcher.setAnimation(null); viewSwitcher.showNext(); } // Mark the refresh UI as complete once anyone of the charts has been loaded. mPullToRefreshAttacher.setRefreshComplete(); }
From source file:com.luke.lukef.lukeapp.popups.SubmissionPopup.java
/** * Adds imageviews to the categories section of the popup, with the thumbnails of the categories. * Dimensions of the parent view can only be retreived once they are drawn, so a * GlobalLayoutListener is needed.//from ww w . j ava 2s . com * * @param categories list of categories whose images are to be added to the category list */ private void setCategories(List<Category> categories) { for (Category c : categories) { final ImageView categoryImg = new ImageView(this.mainActivity); categoryImg.setImageBitmap(c.getImage()); final LinearLayout.LayoutParams[] layoutParams = new LinearLayout.LayoutParams[1]; this.submissionCategoriesLinear.getViewTreeObserver() .addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { layoutParams[0] = new LinearLayout.LayoutParams(new LinearLayout.LayoutParams( SubmissionPopup.this.submissionCategoriesLinear.getHeight(), SubmissionPopup.this.submissionCategoriesLinear.getHeight())); categoryImg.setLayoutParams(layoutParams[0]); if (categoryImg.getParent() != null) { ((ViewGroup) categoryImg.getParent()).removeView(categoryImg); } SubmissionPopup.this.submissionCategoriesLinear.addView(categoryImg); } }); } }
From source file:com.p2c.thelife.SettingsFragment.java
@Override public void notifyServerResponseAvailable(String indicator, int httpCode, JSONObject jsonObject, String errorString) {/*from www. jav a 2 s .c o m*/ try { if (indicator.equals("queryUserProfile")) { // Update the UI with the result of the query. // But if the query failed, use the local information. // use the existing app user record UserModel user = TheLifeConfiguration.getOwnerDS().getOwner(); // update app user record with latest from server if (Utilities.isSuccessfulHttpCode(httpCode) && jsonObject != null) { user.setFromPartialJSON(jsonObject); TheLifeConfiguration.getOwnerDS().setOwner(user); } // update the UI TextView textView = null; textView = (TextView) getActivity().findViewById(R.id.settings_first_name); textView.setText(user.firstName); textView = (TextView) getActivity().findViewById(R.id.settings_last_name); textView.setText(user.lastName); textView = (TextView) getActivity().findViewById(R.id.settings_email); textView.setText(user.email); textView = (TextView) getActivity().findViewById(R.id.settings_phone); textView.setText(user.mobile); // show the update photo prompt if there's no bitmap in the cache int ownerId = TheLifeConfiguration.getOwnerDS().getId(); showUpdatePhotoPrompt(!UserModel.isInCache(ownerId)); Bitmap bitmap = UserModel.getImage(ownerId); ImageView imageView = (ImageView) getActivity().findViewById(R.id.settings_image); imageView.setImageBitmap(bitmap); closeProgressBar(); } else if (indicator.equals("updateUserProfile")) { if (Utilities.isSuccessfulHttpCode(httpCode)) { // update the app user TheLifeConfiguration.getOwnerDS().setOwner(m_updatedUser); // have updated the user profile, so now update the user profile image if necessary if (m_updatedBitmap != null) { updateImageOnServer(m_updatedBitmap); } else { closeProgressBar(); getActivity().getSupportFragmentManager().popBackStack(); Utilities.showInfoToast(getActivity(), getResources().getString(R.string.user_profile_updated), Toast.LENGTH_SHORT); } } else { closeProgressBar(); } } else if (indicator.equals("updateImage")) { if (Utilities.isSuccessfulHttpCode(httpCode)) { TheLifeConfiguration.getOwnerDS().notifyDSChangedListeners(); m_updatedBitmap = null; Utilities.showInfoToast(getActivity(), getResources().getString(R.string.user_profile_updated), Toast.LENGTH_SHORT); } closeProgressBar(); } } catch (Exception e) { Log.e(TAG, "notifyServerResponseAvailable() " + indicator, e); } }
From source file:android.com.example.contactslist.util.ImageLoader.java
/** * Load an image specified by the data parameter into an ImageView (override * {@link ImageLoader#processBitmap(Object)} to define the processing logic). If the image is * found in the memory cache, it is set immediately, otherwise an {@link AsyncTask} will be * created to asynchronously load the bitmap. * * @param data The URL of the image to download. * @param imageView The ImageView to bind the downloaded image to. *//*from w ww. j a v a 2s. co m*/ public void loadImage(Object data, ImageView imageView) { if (data == null) { imageView.setImageBitmap(mLoadingBitmap); return; } Bitmap bitmap = null; if (mImageCache != null) { bitmap = mImageCache.getBitmapFromMemCache(String.valueOf(data)); } if (bitmap != null) { // Bitmap found in memory cache imageView.setImageBitmap(bitmap); } else if (cancelPotentialWork(data, imageView)) { final BitmapWorkerTask task = new BitmapWorkerTask(imageView); final AsyncDrawable asyncDrawable = new AsyncDrawable(mResources, mLoadingBitmap, task); imageView.setImageDrawable(asyncDrawable); task.execute(data); } }
From source file:org.exoplatform.utils.image.SocialImageLoader.java
public void displayImage(String url, ImageView imageView, boolean isLink) { url = SocialActivityUtil.convertToThumbnail(url); imageViews.put(imageView, url);//from www .ja v a 2s . co m Bitmap bitmap = memoryCache.get(url); if (bitmap != null) imageView.setImageBitmap(bitmap); else { queuePhoto(url, imageView, isLink); imageView.setImageResource(DOWNLOAD_PROGRESS_IMAGE); } }
From source file:com.binroot.fatpita.BitmapManager.java
public void fetchBitmapOnThread(final String urlString, final ImageView imageView, final ProgressBar indeterminateProgressBar, final Activity act, final boolean saveToHistory) { SoftReference<Bitmap> ref = mCache.get(urlString); if (ref != null && ref.get() != null) { imageView.setImageBitmap(ref.get()); return;// w w w. j a v a 2 s. c o m } final Runnable progressBarShow = new Runnable() { public void run() { if (indeterminateProgressBar != null) { imageView.setVisibility(View.GONE); indeterminateProgressBar.setVisibility(View.VISIBLE); } } }; final Runnable progressBarHide = new Runnable() { public void run() { if (indeterminateProgressBar != null) { indeterminateProgressBar.setVisibility(View.GONE); imageView.setVisibility(View.VISIBLE); } } }; final Handler handler = new Handler() { @Override public void handleMessage(Message message) { if (indeterminateProgressBar != null && act != null) act.runOnUiThread(progressBarHide); imageView.setImageBitmap((Bitmap) message.obj); } }; Thread thread = new Thread() { @Override public void run() { if (indeterminateProgressBar != null && act != null) act.runOnUiThread(progressBarShow); Bitmap bitmap = fetchBitmap(urlString, saveToHistory); Message message = handler.obtainMessage(1, bitmap); handler.sendMessage(message); } }; thread.start(); }