android.widget.ImageSwitcher Java Examples

The following examples show how to use android.widget.ImageSwitcher. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PlayBgDrawableController.java    From Musicoco with Apache License 2.0 6 votes vote down vote up
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;
        }
    });
}
 
Example #2
Source File: VisualizerFragment.java    From Musicoco with Apache License 2.0 6 votes vote down vote up
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);

    }
 
Example #3
Source File: PlayThemeCustomActivity.java    From Musicoco with Apache License 2.0 6 votes vote down vote up
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
    };

}
 
Example #4
Source File: ImageSwitcher1.java    From codeexamples-android with Eclipse Public License 1.0 6 votes vote down vote up
@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);
}
 
Example #5
Source File: ZjbImageLoader.java    From Android-Application-ZJB with Apache License 2.0 6 votes vote down vote up
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();
    }

}
 
Example #6
Source File: MainActivity.java    From BlackJack with MIT License 5 votes vote down vote up
public View makeView() {
  ImageView iView = new ImageView(this);
  iView.setScaleType(ImageView.ScaleType.FIT_CENTER);
  iView.setLayoutParams(new ImageSwitcher.LayoutParams(
      LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
  return iView;
}
 
Example #7
Source File: ImageSwitcher1.java    From codeexamples-android with Eclipse Public License 1.0 5 votes vote down vote up
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;
}
 
Example #8
Source File: ViewSwitcherWrapper.java    From Android-Notification with Apache License 2.0 5 votes vote down vote up
@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);
    }
}
 
Example #9
Source File: ImageAutoPlayImageSwitcherActivity.java    From android-project-wo2b with Apache License 2.0 5 votes vote down vote up
@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;
}
 
Example #10
Source File: FaceActivity.java    From Android-HowOld with MIT License 5 votes vote down vote up
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);

}
 
Example #11
Source File: MainActivity.java    From journaldev with MIT License 5 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    mTextSwitcher = (TextSwitcher) findViewById(R.id.textSwitcher);
    mTextSwitcher.setFactory(new ViewSwitcher.ViewFactory() {
        @Override
        public View makeView() {
            TextView textView = new TextView(MainActivity.this);
            textView.setTextSize(18);
            textView.setGravity(Gravity.CENTER);
            return textView;
        }
    });

    mTextSwitcher.setInAnimation(this, android.R.anim.fade_in);
    mTextSwitcher.setOutAnimation(this, android.R.anim.fade_out);

    mImageSwitcher = (ImageSwitcher) findViewById(R.id.imageSwitcher);
    mImageSwitcher.setFactory(new ViewSwitcher.ViewFactory() {
        @Override
        public View makeView() {
            ImageView imageView = new ImageView(MainActivity.this);
            return imageView;
        }
    });
    mImageSwitcher.setInAnimation(this, android.R.anim.slide_in_left);
    mImageSwitcher.setOutAnimation(this, android.R.anim.slide_out_right);

    onSwitch(null);
}
 
Example #12
Source File: ZjbImageLoader.java    From Android-Application-ZJB with Apache License 2.0 5 votes vote down vote up
/**
 * 得到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());
}
 
Example #13
Source File: VisualFeedback.java    From ssj with GNU General Public License v3.0 5 votes vote down vote up
private void updateImageSwitcher(final ImageSwitcher imageSwitcher, final Drawable drawable)
{
	imageSwitcher.post(new Runnable()
	{
		public void run()
		{
			imageSwitcher.setImageDrawable(drawable);
		}
	});
}
 
Example #14
Source File: VisualFeedback.java    From ssj with GNU General Public License v3.0 5 votes vote down vote up
private void clearIcons()
{
	for (ImageSwitcher imageSwitcher : imageSwitcherList)
	{
		updateImageSwitcher(imageSwitcher, null);
	}
}
 
Example #15
Source File: Visual.java    From ssj with GNU General Public License v3.0 5 votes vote down vote up
protected void updateImageSwitcher(final ImageSwitcher view, final Drawable img)
{
    view.post(new Runnable()
    {
        public void run()
        {
            view.setImageDrawable(img);
        }
    });
}
 
Example #16
Source File: AlbumPictureController.java    From Musicoco with Apache License 2.0 5 votes vote down vote up
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);
        }
    });
}
 
Example #17
Source File: ImageSwitcherAware.java    From Android-Application-ZJB with Apache License 2.0 4 votes vote down vote up
protected void setImageDrawableInto(Drawable drawable, View view) {
    ((ImageSwitcher) view).setImageDrawable(drawable);
}
 
Example #18
Source File: ImageSwitcherAware.java    From Android-Application-ZJB with Apache License 2.0 4 votes vote down vote up
protected void setImageBitmapInto(Bitmap bitmap, View view) {
    ((ImageSwitcher) view).setImageDrawable(new BitmapDrawable(view.getResources(), bitmap));
}
 
Example #19
Source File: VisualFeedback.java    From ssj with GNU General Public License v3.0 4 votes vote down vote up
private void buildLayout()
{
	if (options.layout.get() == null)
	{
		Log.e("layout not set, cannot render visual feedback");
		return;
	}

	Handler handler = new Handler(activity.getMainLooper());
	handler.post(new Runnable()
	{
		@Override
		public void run()
		{
			TableLayout table = options.layout.get();
			table.setStretchAllColumns(true);

			if (table.getChildCount() < iconList.size())
			{
				for (int i = table.getChildCount(); i < iconList.size(); ++i)
				{
					table.addView(new TableRow(activity), i);
				}
			}

			for (int i = 0; i < iconList.size(); ++i)
			{
				TableRow tr = (TableRow) table.getChildAt(i);
				tr.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.MATCH_PARENT, 1f));

				//if the image switcher has already been initialized by a class on previous level
				if (tr.getChildAt(options.position.get()) instanceof ImageSwitcher)
				{
					imageSwitcherList.add((ImageSwitcher) tr.getChildAt(options.position.get()));
				}
				else
				{
					ImageSwitcher imageSwitcher = new ImageSwitcher(activity);
					imageSwitcher.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.MATCH_PARENT, 1f));

					Animation in = AnimationUtils.loadAnimation(activity, android.R.anim.fade_in);
					in.setDuration(options.fade.get());
					Animation out = AnimationUtils.loadAnimation(activity, android.R.anim.fade_out);
					out.setDuration(options.fade.get());

					imageSwitcher.setInAnimation(in);
					imageSwitcher.setOutAnimation(out);

					imageSwitcher.setFactory(new ViewSwitcher.ViewFactory()
					{
						@Override
						public View makeView()
						{
							ImageView imageView = new ImageView(activity);
							imageView.setLayoutParams(new ImageSwitcher.LayoutParams(ImageSwitcher.LayoutParams.MATCH_PARENT, ImageSwitcher.LayoutParams.MATCH_PARENT));
							return imageView;
						}
					});

					// Fill with empty views to match position
					for (int columnCount = 0; columnCount <= options.position.get(); columnCount++)
					{
						if (tr.getChildAt(columnCount) == null)
						{
							tr.addView(new View(activity), columnCount);
						}
					}
					tr.removeViewAt(options.position.get());
					tr.addView(imageSwitcher, options.position.get());
					imageSwitcherList.add(imageSwitcher);
				}
			}

		}
	});
}
 
Example #20
Source File: DSL.java    From anvil with MIT License 4 votes vote down vote up
public static BaseDSL.ViewClassResult imageSwitcher() {
  return BaseDSL.v(ImageSwitcher.class);
}
 
Example #21
Source File: DSL.java    From anvil with MIT License 4 votes vote down vote up
public static Void imageSwitcher(Anvil.Renderable r) {
  return BaseDSL.v(ImageSwitcher.class, r);
}
 
Example #22
Source File: DSL.java    From anvil with MIT License 4 votes vote down vote up
public static BaseDSL.ViewClassResult imageSwitcher() {
  return BaseDSL.v(ImageSwitcher.class);
}
 
Example #23
Source File: DSL.java    From anvil with MIT License 4 votes vote down vote up
public static Void imageSwitcher(Anvil.Renderable r) {
  return BaseDSL.v(ImageSwitcher.class, r);
}
 
Example #24
Source File: Visual.java    From ssj with GNU General Public License v3.0 4 votes vote down vote up
private void buildLayout(final Context context, final int fade)
{
    if(options.layout.get() == null)
    {
        Log.e("layout not set, cannot render visual feedback");
        return;
    }

    Handler handler = new Handler(context.getMainLooper());
    handler.post(new Runnable()
    {
        @Override
        public void run()
        {
            TableLayout table = options.layout.get();
            table.setStretchAllColumns(true);

            activity = getActivity(table);
            if(activity == null)
                Log.w("unable to get activity from layout");

            int rows = ((VisualAction) action).icons.length;
            img = new ImageSwitcher[rows];

            //if this is the first visual class, init rows
            if (table.getChildCount() == 0)
                for(int i = 0; i < rows; ++i)
                    table.addView(new TableRow(context), i);

            for(int i = 0; i < rows; ++i)
            {
                TableRow tr = (TableRow) table.getChildAt(i);
                tr.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.MATCH_PARENT, 1f));

                //if the image switcher has already been initialized by a class on previous level
                if(tr.getChildAt(position) != null)
                {
                    img[i] = (ImageSwitcher)tr.getChildAt(position);
                }
                else
                {
                    img[i] = new ImageSwitcher(context);
                    img[i].setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.MATCH_PARENT, 1f));

                    Animation in = AnimationUtils.loadAnimation(context, android.R.anim.fade_in);
                    in.setDuration(fade);
                    Animation out = AnimationUtils.loadAnimation(context, android.R.anim.fade_out);
                    out.setDuration(fade);

                    img[i].setInAnimation(in);
                    img[i].setOutAnimation(out);

                    img[i].setFactory(new ViewSwitcher.ViewFactory() {
                        @Override
                        public View makeView() {
                            ImageView imageView = new ImageView(context);
                            imageView.setLayoutParams(new ImageSwitcher.LayoutParams(ImageSwitcher.LayoutParams.MATCH_PARENT, ImageSwitcher.LayoutParams.MATCH_PARENT));
                            return imageView;
                        }
                    });

                    tr.addView(img[i], position);
                }
            }

            isSetup = true;

            //init view
            updateIcons(new Drawable[]{null, null});
            updateBrightness(defBrightness);
        }
    });
}
 
Example #25
Source File: AmountInput.java    From financisto with GNU General Public License v2.0 4 votes vote down vote up
@AfterViews
protected void initialize() {
    setMinimumHeight(minHeight);
    plusDrawable.mutate().setColorFilter(plusColor, PorterDuff.Mode.SRC_ATOP);
    minusDrawable.mutate().setColorFilter(minusColor, PorterDuff.Mode.SRC_ATOP);
    requestId = EDIT_AMOUNT_REQUEST.incrementAndGet();
    signSwitcher.setFactory(() -> {
        ImageView v = new ImageView(getContext());
        v.setScaleType(ImageView.ScaleType.FIT_CENTER);
        v.setLayoutParams(new ImageSwitcher.LayoutParams(
                LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
        return v;
    });
    signSwitcher.setImageDrawable(minusDrawable);
    primary.setKeyListener(keyListener);
    primary.addTextChangedListener(textWatcher);
    primary.setOnFocusChangeListener(selectAllOnFocusListener);
    secondary.setKeyListener(new DigitsKeyListener(false, false) {

        @Override
        public boolean onKeyDown(View view, Editable content, int keyCode, KeyEvent event) {
            if (keyCode == KeyEvent.KEYCODE_DEL) {
                if (content.length() == 0) {
                    primary.requestFocus();
                    int pos = primary.getText().length();
                    primary.setSelection(pos, pos);
                    return true;
                }
            }
            return super.onKeyDown(view, content, keyCode, event);
        }

        @Override
        public int getInputType() {
            return InputType.TYPE_CLASS_PHONE;
        }

    });
    secondary.addTextChangedListener(textWatcher);
    secondary.setOnFocusChangeListener(selectAllOnFocusListener);

    if (!MyPreferences.isEnterCurrencyDecimalPlaces(getContext())) {
        secondary.setVisibility(GONE);
        delimiter.setVisibility(GONE);
    }
}
 
Example #26
Source File: MainActivity.java    From BlackJack with MIT License 4 votes vote down vote up
private void setupVariables() {

    layout = (LinearLayout) findViewById(R.id.parentLayout);

    tvMoney = (TextView) findViewById(R.id.tvMoney);
    tvHighestScore = (TextView) findViewById(R.id.tvHighest);
    tvDealerScore = (TextView) findViewById(R.id.tvDealer);
    tvYourScore = (TextView) findViewById(R.id.tvYou);
    tvBet = (TextView) findViewById(R.id.tvBet);

    ivDealerCard1 = (ImageSwitcher) findViewById(R.id.ivDealerCard1);
    ivDealerCard2 = (ImageSwitcher) findViewById(R.id.ivDealerCard2);
    ivDealerCard3 = (ImageSwitcher) findViewById(R.id.ivDealerCard3);
    ivDealerCard4 = (ImageSwitcher) findViewById(R.id.ivDealerCard4);
    ivDealerCard5 = (ImageSwitcher) findViewById(R.id.ivDealerCard5);

    ivYourCard1 = (ImageSwitcher) findViewById(R.id.ivYourCard1);
    ivYourCard2 = (ImageSwitcher) findViewById(R.id.ivYourCard2);
    ivYourCard3 = (ImageSwitcher) findViewById(R.id.ivYourCard3);
    ivYourCard4 = (ImageSwitcher) findViewById(R.id.ivYourCard4);
    ivYourCard5 = (ImageSwitcher) findViewById(R.id.ivYourCard5);

    ivSplitCard1 = (ImageSwitcher) findViewById(R.id.ivSplitCard1);
    ivSplitCard2 = (ImageSwitcher) findViewById(R.id.ivSplitCard2);
    ivSplitCard3 = (ImageSwitcher) findViewById(R.id.ivSplitCard3);
    ivSplitCard4 = (ImageSwitcher) findViewById(R.id.ivSplitCard4);
    ivSplitCard5 = (ImageSwitcher) findViewById(R.id.ivSplitCard5);

    btnHit = (Button) findViewById(R.id.btnHit);
    btnStand = (Button) findViewById(R.id.btnStand);
    btnSurrender = (Button) findViewById(R.id.btnSurrender);

    btnHit.setOnClickListener(this);
    btnStand.setOnClickListener(this);
    btnSurrender.setOnClickListener(this);

    btnPlaceBet = (Button) findViewById(R.id.btnPlaceBet);
    btnPlaceBet.setOnClickListener(this);
    Button btnExit = (Button) findViewById(R.id.btnExit);
    btnExit.setOnClickListener(this);
    Button btnHelp = (Button) findViewById(R.id.btnHelp);
    btnHelp.setOnClickListener(this);
    btnChallenge = (Button)findViewById(R.id.btnChallenge);
    btnChallenge.setOnClickListener(this);
    

    sbBetAmount = (SeekBar) findViewById(R.id.sbBetAmount);
    sbBetAmount.setOnSeekBarChangeListener(this);
    
    challengeString[0] = getString(R.string.challengePt1);
    challengeString[1] = getString(R.string.challengePt2);
    challengeString[2] = getString(R.string.challengePt3);

  }