private void initSwitchers() { temperatureSwitcher = (TextSwitcher) findViewById(R.id.cs_ts_temperature); temperatureSwitcher.setFactory(new TextViewFactory(R.style.CsTemperatureTextView, true)); temperatureSwitcher.setCurrentText(temperatures[0]); placeSwitcher = (TextSwitcher) findViewById(R.id.cs_ts_place); placeSwitcher.setFactory(new TextViewFactory(R.style.CsPlaceTextView, false)); placeSwitcher.setCurrentText(places[0]); clockSwitcher = (TextSwitcher) findViewById(R.id.cs_ts_clock); clockSwitcher.setFactory(new TextViewFactory(R.style.CsClockTextView, false)); clockSwitcher.setCurrentText(times[0]); descriptionsSwitcher = (TextSwitcher) findViewById(R.id.cs_ts_description); descriptionsSwitcher.setInAnimation(this, android.R.anim.fade_in); descriptionsSwitcher.setOutAnimation(this, android.R.anim.fade_out); descriptionsSwitcher.setFactory(new TextViewFactory(R.style.CsDescriptionTextView, false)); descriptionsSwitcher.setCurrentText(getString(descriptions[0])); mapSwitcher = (ImageSwitcher) findViewById(R.id.cs_ts_map); mapSwitcher.setInAnimation(this, R.anim.cs_fade_in); mapSwitcher.setOutAnimation(this, R.anim.cs_fade_out); mapSwitcher.setFactory(new ImageViewFactory()); mapSwitcher.setImageResource(maps[0]); }
public ViewHolder() { imageSwitch = (ImageSwitcher) findViewById(R.id.play_theme_custom_image_switch); container = findViewById(R.id.play_theme_custom_container); dark = (TextView) findViewById(R.id.play_theme_custom_dark); white = (TextView) findViewById(R.id.play_theme_custom_white); blur = (TextView) findViewById(R.id.play_theme_custom_blur); color = (TextView) findViewById(R.id.play_theme_custom_color); gradient = (TextView) findViewById(R.id.play_theme_custom_gradient); mask = (TextView) findViewById(R.id.play_theme_custom_mask); done = (FloatingActionButton) findViewById(R.id.play_theme_custom_done); texts = new TextView[]{ dark, white, blur, color, gradient, mask }; }
public void initViews() { flRootView = (FrameLayout) activity.findViewById(R.id.play_root); isBg = (ImageSwitcher) activity.findViewById(R.id.play_bg); isBg.setFactory(new ViewSwitcher.ViewFactory() { @Override public View makeView() { ImageView view = new ImageView(activity); view.setLayoutParams(new FrameLayout.LayoutParams( FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT)); view.setScaleType(ImageView.ScaleType.CENTER_CROP); return view; } }); }
private void initViews() { albumView = (ImageSwitcher) view.findViewById(R.id.play_album_is); albumView.setFactory(new ViewSwitcher.ViewFactory() { @Override public View makeView() { ImageView imageView = new ImageView(getActivity()); imageView.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT)); imageView.setScaleType(ImageView.ScaleType.FIT_CENTER); int pad = (int) getActivity().getResources().getDimension(R.dimen.play_album_padding); imageView.setPadding(pad, pad, pad, pad); return imageView; } }); DisplayMetrics metrics = Utils.getMetrics(getActivity()); //专辑图片直径 int size = metrics.widthPixels * 2 / 3; albumPictureController = new AlbumPictureController(getActivity(), albumView, size); }
public AlbumPictureController(Context context, final ImageSwitcher view, int size) { this.view = view; this.size = size; this.context = context; this.cache = new BitmapCache(context, BitmapCache.CACHE_ALBUM_VISUALIZER_IMAGE); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { defaultColor = context.getColor(R.color.default_play_bg_color); defaultTextColor = context.getColor(R.color.default_play_text_color); } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { defaultColor = context.getResources().getColor(R.color.default_play_bg_color, null); defaultTextColor = context.getResources().getColor(R.color.default_play_text_color, null); } else { defaultColor = context.getResources().getColor(R.color.default_play_bg_color); defaultTextColor = context.getResources().getColor(R.color.default_play_text_color); } this.bitmapProducer = new BitmapProducer(context); colors = new int[]{ defaultColor, defaultTextColor, defaultColor, defaultTextColor }; rotateAnim = ObjectAnimator.ofFloat(0, 360); rotateAnim.setDuration(45 * 1000); rotateAnim.setRepeatMode(ValueAnimator.RESTART); rotateAnim.setRepeatCount(ValueAnimator.INFINITE); rotateAnim.setInterpolator(new LinearInterpolator()); rotateAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { float value = (float) animation.getAnimatedValue(); view.getCurrentView().setRotation(value); } }); }
@Override protected void initViews(Bundle savedInstanceState) { setDisplayHomeAsUpEnabled(true); tvVersion = (TextView) findViewById(R.id.tv_app_version); tvVersion.setText("v" + BuildConfig.VERSION_NAME); imageSwitcher = (ImageSwitcher) findViewById(R.id.imageSwitcher); imageSwitcher.setFactory(new ViewSwitcher.ViewFactory() { @Override public View makeView() { ImageView imageView = new ImageView(AboutActivity.this); imageView.setScaleType(ImageView.ScaleType.FIT_XY); return imageView; } }); imageSwitcher.setInAnimation(AnimationUtils.loadAnimation(this, R.anim.zoom_in)); imageSwitcher.setOutAnimation(AnimationUtils.loadAnimation(this, R.anim.zoom_out)); }
private synchronized static void display(String url, View view, DisplayImageOptions displayImageOptions, ImageLoadingListener imageLoadingListener, ImageLoadingProgressListener imageLoadingProgressListener) { try { if (view instanceof ImageView) { mImageLoader.displayImage(url, new ImageViewAware((ImageView) view), displayImageOptions, imageLoadingListener, imageLoadingProgressListener); } else if (view instanceof ImageSwitcher) { mImageLoader.displayImage(url, new ImageSwitcherAware(view), displayImageOptions, imageLoadingListener, imageLoadingProgressListener); } else { mImageLoader.displayImage(url, new SimpleViewAware(view), displayImageOptions, imageLoadingListener, imageLoadingProgressListener); } } catch (OutOfMemoryError e1) { e1.printStackTrace(); } catch (Exception e2) { e2.printStackTrace(); } }
/** * Строим список */ private void buildViews() { llCheckBoxList.removeAllViews(); for (Box box : list) { View v = inflate(getContext(), R.layout.custom_checkbox_filter, null); TextView tvTitle = hs.get(v, R.id.tvTitle); ImageSwitcher isImage = hs.get(v, R.id.isImage); v.setOnClickListener(imageSwitch); isImage.setFactory(factory); setAnimation(isImage); tvTitle.setText(box.title); llCheckBoxList.addView(v); prepareCounts(box); isImage.setImageResource(images[box.status]); } invalidateCount(); }
@Override public void onClick(View v) { ImageSwitcher isImage = hs.get(v, R.id.isImage); int position = llCheckBoxList.indexOfChild(v); Box box = list.get(position); if(!multy) clear(box); box.status++; if(box.status > 2 || (!negativeStatus && box.status > 1)) box.status = 0; upCount(box); invalidateCount(); isImage.setImageResource(images[box.status]); }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.image_switcher_1); mSwitcher = (ImageSwitcher) findViewById(R.id.switcher); mSwitcher.setFactory(this); mSwitcher.setInAnimation(AnimationUtils.loadAnimation(this, android.R.anim.fade_in)); mSwitcher.setOutAnimation(AnimationUtils.loadAnimation(this, android.R.anim.fade_out)); Gallery g = (Gallery) findViewById(R.id.gallery); g.setAdapter(new ImageAdapter(this)); g.setOnItemSelectedListener(this); }
public YiGuideView(Context context, AttributeSet attrs) { super(context, attrs); this.context = context; LayoutInflater.from(getContext()).inflate(R.layout.yi_guide_view,this); mImageSwitcher = (ImageSwitcher) findViewById(R.id.yi_guide_vs); mViewGroup = (LinearLayout) findViewById(R.id.yi_guide_viewgroup); WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); reqWidth = manager.getDefaultDisplay().getWidth(); reqHeight = manager.getDefaultDisplay().getHeight(); Log.i(TAG, "reqWidth = " + reqWidth + ",reqHeight =" + reqHeight); mImageSwitcher.setOnTouchListener(this); // ������ͼ���� mImageSwitcher.setFactory(this); }
public AddReportView(Activity activity) { super(activity); mBtnPicture = (Button) activity.findViewById(R.id.btnPicture); mBtnAddCategory = (Button) activity.findViewById(R.id.add_category); mPickDate = (Button) activity.findViewById(R.id.pick_date); mPickTime = (Button) activity.findViewById(R.id.pick_time); mDeleteReport = (Button) activity.findViewById(R.id.delete_report); mLatitude = (EditText) activity.findViewById(R.id.incident_latitude); mLongitude = (EditText) activity.findViewById(R.id.incident_longitude); gallery = (Gallery) activity.findViewById(R.id.gallery); mIncidentTitle = (EditText) activity.findViewById(R.id.incident_title); mIncidentLocation = (EditText) activity .findViewById(R.id.incident_location); mIncidentDesc = (EditText) activity.findViewById(R.id.incident_desc); mNews = (EditText) activity.findViewById(R.id.report_news); mSwitcher = (ImageSwitcher) activity .findViewById(R.id.sel_image_switcher); mSwitcher.setInAnimation(AnimationUtils.loadAnimation(activity, android.R.anim.fade_in)); mSwitcher.setOutAnimation(AnimationUtils.loadAnimation(activity, android.R.anim.fade_out)); }
/** * Called when the processing is complete and the final bitmap should be set * on the ImageSwitcher. * * @param ImageSwitcher * @param bitmap */ @SuppressWarnings("deprecation") private void setImageBitmap(ImageSwitcher imageSwitcher, Bitmap bitmap) { if (fadeIn) { // Transition drawable with a transparent drwabale and the final // bitmap final TransitionDrawable td = new TransitionDrawable( new Drawable[] { new ColorDrawable(android.R.color.transparent), new BitmapDrawable(context.getResources(), bitmap) }); // Set background to loading bitmap imageSwitcher.setBackgroundDrawable(new BitmapDrawable(context .getResources(), loadingBitmap)); imageSwitcher.setImageDrawable(td); td.startTransition(FADE_IN_TIME); } else { imageSwitcher.setImageDrawable(new BitmapDrawable(context .getResources(), bitmap)); } }
public AddReportView(Activity activity) { super(activity); mBtnPicture = (Button) activity.findViewById(R.id.btnPicture); mBtnAddCategory = (Button) activity.findViewById(R.id.add_category); mPickDate = (Button) activity.findViewById(R.id.pick_date); mPickTime = (Button) activity.findViewById(R.id.pick_time); mDeleteReport = (Button) activity.findViewById(R.id.delete_report); mLatitude = (EditText) activity.findViewById(R.id.incident_latitude); mLongitude = (EditText) activity.findViewById(R.id.incident_longitude); gallery = (Gallery) activity.findViewById(R.id.gallery); mIncidentTitle = (EditText) activity.findViewById(R.id.incident_title); mIncidentLocation = (EditText) activity .findViewById(R.id.incident_location); mIncidentDesc = (EditText) activity.findViewById(R.id.incident_desc); mNews = (EditText) activity.findViewById(R.id.report_news); mSwitcher = (ImageSwitcher) activity .findViewById(R.id.sel_image_switcher); mSwitcher.setInAnimation(AnimationUtils.loadAnimation(activity, android.R.anim.fade_in)); mSwitcher.setOutAnimation(AnimationUtils.loadAnimation(activity, android.R.anim.fade_out)); this.mapView = (MapView) activity.findViewById(R.id.location_map); }
/** * Called when the processing is complete and the final bitmap should be set * on the ImageSwitcher. * * @param ImageSwitcher * @param bitmap */ private void setImageBitmap(ImageSwitcher imageSwitcher, Bitmap bitmap) { if (fadeIn) { // Transition drawable with a transparent drwabale and the final // bitmap final TransitionDrawable td = new TransitionDrawable( new Drawable[] { new ColorDrawable(android.R.color.transparent), new BitmapDrawable(context.getResources(), bitmap) }); // Set background to loading bitmap imageSwitcher.setBackgroundDrawable(new BitmapDrawable(context .getResources(), loadingBitmap)); imageSwitcher.setImageDrawable(td); td.startTransition(FADE_IN_TIME); } else { imageSwitcher.setImageDrawable(new BitmapDrawable(bitmap)); } }
@Override public View makeView() { final ImageView imageView = new ImageView(CardSliderActivity.this); imageView.setScaleType(ImageView.ScaleType.CENTER_CROP); final LayoutParams lp = new ImageSwitcher.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); imageView.setLayoutParams(lp); return imageView; }
private void initSwitchers() { temperatureSwitcher = (TextSwitcher) findViewById(R.id.ts_temperature); temperatureSwitcher.setFactory(new TextViewFactory(R.style.TemperatureTextView, true)); temperatureSwitcher.setCurrentText(temperatures[0]); placeSwitcher = (TextSwitcher) findViewById(R.id.ts_place); placeSwitcher.setFactory(new TextViewFactory(R.style.PlaceTextView, false)); placeSwitcher.setCurrentText(places[0]); clockSwitcher = (TextSwitcher) findViewById(R.id.ts_clock); clockSwitcher.setFactory(new TextViewFactory(R.style.ClockTextView, false)); clockSwitcher.setCurrentText(times[0]); descriptionsSwitcher = (TextSwitcher) findViewById(R.id.ts_description); descriptionsSwitcher.setInAnimation(this, android.R.anim.fade_in); descriptionsSwitcher.setOutAnimation(this, android.R.anim.fade_out); descriptionsSwitcher.setFactory(new TextViewFactory(R.style.DescriptionTextView, false)); descriptionsSwitcher.setCurrentText(getString(descriptions[0])); mapSwitcher = (ImageSwitcher) findViewById(R.id.ts_map); mapSwitcher.setInAnimation(this, R.anim.fade_in); mapSwitcher.setOutAnimation(this, R.anim.fade_out); mapSwitcher.setFactory(new ImageViewFactory()); mapSwitcher.setImageResource(maps[0]); mapLoadListener = new DecodeBitmapTask.Listener() { @Override public void onPostExecuted(Bitmap bitmap) { ((ImageView)mapSwitcher.getNextView()).setImageBitmap(bitmap); mapSwitcher.showNext(); } }; }
@Override public View makeView() { final ImageView imageView = new ImageView(MainActivity.this); imageView.setScaleType(ImageView.ScaleType.CENTER_CROP); final LayoutParams lp = new ImageSwitcher.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); imageView.setLayoutParams(lp); return imageView; }
@Override public View makeView() { final ImageView imageView = new ImageView(this); imageView.setBackgroundColor(0xff000000); // imageView.setScaleType(ImageView.ScaleType.CENTER_CROP); // FIXME:提供外层进行设置,或者是提供设置. // imageView.setScaleType(ImageView.ScaleType.FIT_XY); // imageView.setScaleType(ImageView.ScaleType.CENTER_CROP); // imageView.setLayoutParams(new ImageSwitcher.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); imageView.setLayoutParams(new ImageSwitcher.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); return imageView; }
private void initViews() { mPhoto = (ImageView) findViewById(R.id.id_photo); mGetImage = (ImageButton) findViewById(R.id.id_getImage); mDetect = (TextView) findViewById(R.id.id_detect); // mTip = (TextView) findViewById(R.id.id_tip); mWaitting = findViewById(R.id.id_waiting); gallery = (Gallery) findViewById(R.id.id_gallery); imageSwitcher = (ImageSwitcher) findViewById(R.id.id_imageSwitcher); scrollView = (ScrollView) findViewById(R.id.scrollView1); scrollView.setVerticalScrollBarEnabled(false); }
protected void updateImageSwitcher(final ImageSwitcher view, final Drawable img) { view.post(new Runnable() { public void run() { view.setImageDrawable(img); } }); }
private void clearIcons() { for (ImageSwitcher imageSwitcher : imageSwitcherList) { updateImageSwitcher(imageSwitcher, null); } }
private void updateImageSwitcher(final ImageSwitcher imageSwitcher, final Drawable drawable) { imageSwitcher.post(new Runnable() { public void run() { imageSwitcher.setImageDrawable(drawable); } }); }
@Override public View makeView() { ImageView imageView = new ImageView(this); imageView.setBackgroundColor(0xFF000000); imageView.setScaleType(ImageView.ScaleType.FIT_CENTER); imageView.setLayoutParams(new ImageSwitcher.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); return imageView; }
/** * 得到url对应的硬盘缓存数据(url没有加七牛的信息) * * @param url 原始的url * @param view 原始的url显示的控件,这个控件是用来计算宽高用的 * @return */ public static String getDiskCachePath(String url, View view) { ImageAware aware; if (view instanceof ImageView) { aware = new ImageViewAware((ImageView) view); } else if (view instanceof ImageSwitcher) { aware = new ImageSwitcherAware(view); } else { aware = new SimpleViewAware(view); } return getDiskCachePath(url, aware.getWidth(), aware.getHeight()); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); this.setContentView(R.layout.customize_activity); switcher = (ImageSwitcher) findViewById(R.id.imageSwitcher); accelerationBar = (ProgressBar) findViewById(R.id.progressBar_customize_acceleration); speedBar = (ProgressBar) findViewById(R.id.progressBar_customize_speed); weightBar = (ProgressBar) findViewById(R.id.progressBar_customize_weight); carNameView = (TextView) findViewById(R.id.textViewCarName); switcher.setFactory(new ViewSwitcher.ViewFactory() { @Override public View makeView() { ImageView myView = new ImageView(getApplicationContext()); FrameLayout.LayoutParams params = new FrameLayout.LayoutParams (FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT); myView.setLayoutParams(params); myView.setScaleType(ImageView.ScaleType.FIT_CENTER); return myView; } }); slide_in_left = AnimationUtils.loadAnimation(this, android.R.anim.slide_in_left); slide_out_right = AnimationUtils.loadAnimation(this, android.R.anim.slide_out_right); slide_in_right = AnimationUtils.loadAnimation(this, R.anim.slide_in_right); slide_out_left = AnimationUtils.loadAnimation(this, R.anim.slide_out_left); loadCars(); updateData(); }
public View makeView() { LayoutInflater inflater=(LayoutInflater)getContext(). getSystemService(Context.LAYOUT_INFLATER_SERVICE); View view=inflater.inflate(R.layout.image_tutorial_item,null); view.findViewById(R.id.image).setOnClickListener(this); view.setLayoutParams(new ImageSwitcher.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); return view; }
/** * Анимация смены плюсика на минус и наоборот * @param isImage */ void setAnimation(ImageSwitcher isImage){ if(Build.VERSION.SDK_INT > 10){ Animation in = AnimationUtils.loadAnimation(getContext(), R.anim.checkbox_animation_in); Animation out = AnimationUtils.loadAnimation(getContext(), R.anim.checkbox_animation_out); isImage.setInAnimation(in); isImage.setOutAnimation(out); } }
public View makeView() { ImageView i = new ImageView(this); i.setBackgroundColor(0xFF000000); i.setScaleType(ImageView.ScaleType.FIT_CENTER); i.setLayoutParams(new ImageSwitcher.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); return i; }
@Override public void setImageDrawable(Drawable drawable, boolean animate) { View view = getView(); if (view == null) { return; } ImageSwitcher imageSwitcher = (ImageSwitcher) view; if (animate) { imageSwitcher.setImageDrawable(drawable); } else { ImageView curr = (ImageView) imageSwitcher.getCurrentView(); curr.setImageDrawable(drawable); } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setTheme(R.style.CustomTutorialTheme); setContentView(R.layout.tutorials_card); this.entries = (ArrayList<TutorialEntry>) getIntent().getSerializableExtra("entries"); switcher = (ImageSwitcher) findViewById(R.id.imageSwitcher); next = (Button) findViewById(R.id.nextButton); descriptionText = (TextView) findViewById(R.id.descriptionText); previous = (Button) findViewById(R.id.previousButton); previous.setVisibility(View.INVISIBLE); next.setOnClickListener(this); previous.setOnClickListener(this); switcher.setFactory(new ViewSwitcher.ViewFactory() { @Override public View makeView() { ImageView myView = new ImageView(getApplicationContext()); myView.setScaleType(ImageView.ScaleType.FIT_CENTER); myView.setLayoutParams(new ImageSwitcher.LayoutParams(LayoutParams. FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); myView.setImageResource(entries.get(index).image); return myView; } }); // Gesture detection gestureDetector = new GestureDetector(this, new SwipeGestureDetector()); gestureListener = new View.OnTouchListener() { public boolean onTouch(View v, MotionEvent event) { return gestureDetector.onTouchEvent(event); } }; descriptionText.setText(entries.get(index).description); // Do this for each view added to the grid switcher.setOnTouchListener(gestureListener); }
@Override public View makeView() { ImageView i = new ImageView(this); i.setAdjustViewBounds(true); i.setScaleType(ImageView.ScaleType.FIT_CENTER); i.setLayoutParams(new ImageSwitcher.LayoutParams( android.view.ViewGroup.LayoutParams.WRAP_CONTENT, android.view.ViewGroup.LayoutParams.WRAP_CONTENT)); return i; }
public void loadImage(Object data, ImageSwitcher imageSwitcher, boolean fullScale, int width) { final BitmapWorkerTask task = new BitmapWorkerTask(imageSwitcher); final AsyncDrawable asyncDrawable = new AsyncDrawable( context.getResources(), loadingBitmap, task); imageSwitcher.setImageDrawable(asyncDrawable); task.fullScale = fullScale; task.width = width; task.imageSwitcher = imageSwitcher; task.execute(data); }