List of usage examples for android.widget ImageView setImageResource
@android.view.RemotableViewMethod(asyncImpl = "setImageResourceAsync") public void setImageResource(@DrawableRes int resId)
From source file:com.cw.litenote.note.AudioUi_note.java
public static void updateAudioPlayState(AppCompatActivity act) { ImageView audio_play_btn = (ImageView) act.findViewById(R.id.pager_btn_audio_play); if (Audio_manager.getAudioPlayMode() != Audio_manager.NOTE_PLAY_MODE) return;/* ww w .j a va2s . c om*/ TextView audioTitle = (TextView) act.findViewById(R.id.pager_audio_title); // update playing state if (Audio_manager.getPlayerState() == Audio_manager.PLAYER_AT_PLAY) { audio_play_btn.setImageResource(R.drawable.ic_media_pause); showAudioName(act); audioTitle.setTextColor(ColorSet.getHighlightColor(act)); audioTitle.setSelected(true); } else if ((Audio_manager.getPlayerState() == Audio_manager.PLAYER_AT_PAUSE) || (Audio_manager.getPlayerState() == Audio_manager.PLAYER_AT_STOP)) { audio_play_btn.setImageResource(R.drawable.ic_media_play); showAudioName(act); audioTitle.setTextColor(ColorSet.getPauseColor(act)); audioTitle.setSelected(false); } }
From source file:com.android.volley.toolbox.ImageLoader.java
/** * The default implementation of ImageListener which handles basic functionality * of showing a default image until the network response is received, at which point * it will switch to either the actual image or the error image. * @param view The imageView that the listener is associated with. * @param defaultImageResId Default image resource ID to use, or 0 if it doesn't exist. * @param errorImageResId Error image resource ID to use, or 0 if it doesn't exist. *///from www .ja v a 2s . c o m public static ImageListener getImageListener(final ImageView view, final int defaultImageResId, final int errorImageResId) { return new ImageListener() { @Override public void onErrorResponse(VolleyError error) { if (errorImageResId != 0) { view.setImageResource(errorImageResId); } } @Override public void onResponse(ImageContainer response, boolean isImmediate) { if (response.getBitmap() != null) { view.setImageBitmap(response.getBitmap()); } else if (defaultImageResId != 0) { view.setImageResource(defaultImageResId); } } }; }
From source file:com.cw.litenote.note.AudioUi_note.java
public static void initAudioProgress(AppCompatActivity act, String audioUriInDB, ViewPager _pager) { SeekBar seekBar = (SeekBar) act.findViewById(R.id.pager_img_audio_seek_bar); ImageView mPager_audio_play_button = (ImageView) act.findViewById(R.id.pager_btn_audio_play); // set audio block listeners setAudioBlockListener(act, audioUriInDB, _pager); mProgress = 0;/*from w w w .j av a 2 s . co m*/ mAudioUriInDB = audioUriInDB; showAudioName(act); TextView audioTitle = (TextView) act.findViewById(R.id.pager_audio_title); audioTitle.setSelected(false); mPager_audio_play_button.setImageResource(R.drawable.ic_media_play); audioTitle.setTextColor(ColorSet.getPauseColor(act)); audioTitle.setSelected(false); // current position int curHour = Math.round((float) (mProgress / 1000 / 60 / 60)); int curMin = Math.round((float) ((mProgress - curHour * 60 * 60 * 1000) / 1000 / 60)); int curSec = Math.round((float) ((mProgress - curHour * 60 * 60 * 1000 - curMin * 60 * 1000) / 1000)); String curr_pos_str = String.format(Locale.ENGLISH, "%2d", curHour) + ":" + String.format(Locale.ENGLISH, "%02d", curMin) + ":" + String.format(Locale.ENGLISH, "%02d", curSec); TextView audio_curr_pos = (TextView) act.findViewById(R.id.pager_audio_current_pos); audio_curr_pos.setText(curr_pos_str); audio_curr_pos.setTextColor(ColorSet.color_white); // audio seek bar seekBar.setProgress(mProgress); // This math construction give a percentage of "was playing"/"song length" seekBar.setMax(99); // It means 100% .0-99 seekBar.setVisibility(View.VISIBLE); // get audio file length try { if (Util.isUriExisted(mAudioUriInDB, act)) { MediaPlayer mp = MediaPlayer.create(act, Uri.parse(mAudioUriInDB)); mediaFileLength = mp.getDuration(); mp.release(); } } catch (Exception e) { System.out.println("AudioUi_note / _initAudioProgress / exception"); } // set audio file length int fileHour = Math.round((float) (mediaFileLength / 1000 / 60 / 60)); int fileMin = Math.round((float) ((mediaFileLength - fileHour * 60 * 60 * 1000) / 1000 / 60)); int fileSec = Math .round((float) ((mediaFileLength - fileHour * 60 * 60 * 1000 - fileMin * 1000 * 60) / 1000)); String strHour = String.format(Locale.ENGLISH, "%2d", fileHour); String strMinute = String.format(Locale.ENGLISH, "%02d", fileMin); String strSecond = String.format(Locale.ENGLISH, "%02d", fileSec); String strLength = strHour + ":" + strMinute + ":" + strSecond; TextView audio_length = (TextView) act.findViewById(R.id.pager_audio_file_length); audio_length.setText(strLength); audio_length.setTextColor(ColorSet.color_white); }
From source file:org.openjira.jira.utils.LoadImageAsync.java
public static void setImageViewAsync(String url, ImageView v, int defaultImage, LoadBitmapListener callback, Activity activity) {/*from w w w .jav a 2 s . c om*/ WeakReference<Bitmap> ref = cachedBitmaps.get(url); // Log.v(LOGTAG, "Cache size: " + cachedBitmaps.size()); Bitmap bitmap = (ref != null) ? ref.get() : null; if (bitmap != null) { callback.bitmapLoaded(bitmap, v); return; } { // Log.v("Utils.setImageViewAsync", "Will load " + url); v.setImageResource(defaultImage); bitmap = getImageFromFile(url); if (bitmap != null) { callback.bitmapLoaded(bitmap, v); } else { if (imageLoader == null) { imageLoader = new ImageDownloader(JiraApp.get()); } if (url != null) imageLoader.loadImageHttp(url, v, callback, activity); } } }
From source file:com.android.volley.cache.plus.ImageLoader.java
/** * The default implementation of ImageListener which handles basic functionality * of showing a default image until the network response is received, at which point * it will switch to either the actual image or the error image. * @param imageView The imageView that the listener is associated with. * @param defaultImageResId Default image resource ID to use, or 0 if it doesn't exist. * @param errorImageResId Error image resource ID to use, or 0 if it doesn't exist. *//*from w ww . j a v a2 s . co m*/ public static ImageListener getImageListener(final ImageView view, final int defaultImageResId, final int errorImageResId) { return new ImageListener() { @Override public void onErrorResponse(VolleyError error) { if (errorImageResId != 0) { view.setImageResource(errorImageResId); } } @Override public void onResponse(ImageContainer response, boolean isImmediate) { if (response.getBitmap() != null) { view.setImageDrawable(response.getBitmap()); } else if (defaultImageResId != 0) { view.setImageResource(defaultImageResId); } } }; }
From source file:SlideFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.fragment_slide, container, false); ImageView imageView = (ImageView) rootView.findViewById(R.id.imageView); imageView.setImageResource(mImageResourceID); return rootView; }
From source file:cn.trinea.android.demo.adapter.ImagePagerAdapter.java
@Override public Object instantiateItem(ViewGroup container, int position) { ImageView imageView = new ImageView(context); imageView.setImageResource(imageIdList.get(position)); ((ViewPager) container).addView(imageView, 0); return imageView; }
From source file:com.commonsware.android.preso.slides.SlidesAdapter.java
@Override public Object instantiateItem(ViewGroup container, int position) { ImageView page = new ImageView(ctxt); page.setImageResource(getPageResource(position)); container.addView(page, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); return (page); }
From source file:com.manning.androidhacks.hack028.adapter.ImageAdapter.java
public View getView(int position, View convertView, ViewGroup parent) { ImageView imageView = new ImageView(mContext); imageView.setImageResource(mImageIds[position]); imageView.setLayoutParams(new Gallery.LayoutParams(150, 100)); imageView.setScaleType(ImageView.ScaleType.FIT_XY); return imageView; }
From source file:com.paras.amazonadvertice.ImageGalleryFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { setRetainInstance(true);/*from w w w.j a v a 2s .c o m*/ final ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.image_fragment, container, false); final ImageView imageView = (ImageView) rootView.findViewById(R.id.image_view); imageView.setImageResource(this.imageResource); return rootView; }