类android.widget.ImageSwitcher源码实例Demo

下面列出了怎么用android.widget.ImageSwitcher的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: Musicoco   文件: PlayThemeCustomActivity.java
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
    };

}
 
源代码2 项目: Musicoco   文件: PlayBgDrawableController.java
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;
        }
    });
}
 
源代码3 项目: Musicoco   文件: VisualizerFragment.java
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);

    }
 
源代码4 项目: Android-Application-ZJB   文件: ZjbImageLoader.java
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();
    }

}
 
源代码5 项目: codeexamples-android   文件: ImageSwitcher1.java
@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);
}
 
源代码6 项目: Musicoco   文件: AlbumPictureController.java
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);
        }
    });
}
 
源代码7 项目: ssj   文件: Visual.java
protected void updateImageSwitcher(final ImageSwitcher view, final Drawable img)
{
    view.post(new Runnable()
    {
        public void run()
        {
            view.setImageDrawable(img);
        }
    });
}
 
源代码8 项目: ssj   文件: VisualFeedback.java
private void clearIcons()
{
	for (ImageSwitcher imageSwitcher : imageSwitcherList)
	{
		updateImageSwitcher(imageSwitcher, null);
	}
}
 
源代码9 项目: ssj   文件: VisualFeedback.java
private void updateImageSwitcher(final ImageSwitcher imageSwitcher, final Drawable drawable)
{
	imageSwitcher.post(new Runnable()
	{
		public void run()
		{
			imageSwitcher.setImageDrawable(drawable);
		}
	});
}
 
源代码10 项目: Android-Application-ZJB   文件: ZjbImageLoader.java
/**
 * 得到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());
}
 
源代码11 项目: journaldev   文件: MainActivity.java
@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);
}
 
源代码12 项目: Android-HowOld   文件: FaceActivity.java
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);

}
 
@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;
}
 
源代码14 项目: Android-Notification   文件: ViewSwitcherWrapper.java
@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);
    }
}
 
源代码15 项目: codeexamples-android   文件: ImageSwitcher1.java
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;
}
 
源代码16 项目: BlackJack   文件: MainActivity.java
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;
}
 
源代码17 项目: financisto   文件: AmountInput.java
@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);
    }
}
 
源代码18 项目: ssj   文件: Visual.java
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);
        }
    });
}
 
源代码19 项目: ssj   文件: VisualFeedback.java
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);
				}
			}

		}
	});
}
 
protected void setImageDrawableInto(Drawable drawable, View view) {
    ((ImageSwitcher) view).setImageDrawable(drawable);
}
 
protected void setImageBitmapInto(Bitmap bitmap, View view) {
    ((ImageSwitcher) view).setImageDrawable(new BitmapDrawable(view.getResources(), bitmap));
}
 
源代码22 项目: anvil   文件: DSL.java
public static BaseDSL.ViewClassResult imageSwitcher() {
  return BaseDSL.v(ImageSwitcher.class);
}
 
源代码23 项目: anvil   文件: DSL.java
public static Void imageSwitcher(Anvil.Renderable r) {
  return BaseDSL.v(ImageSwitcher.class, r);
}
 
源代码24 项目: anvil   文件: DSL.java
public static BaseDSL.ViewClassResult imageSwitcher() {
  return BaseDSL.v(ImageSwitcher.class);
}
 
源代码25 项目: anvil   文件: DSL.java
public static Void imageSwitcher(Anvil.Renderable r) {
  return BaseDSL.v(ImageSwitcher.class, r);
}
 
源代码26 项目: BlackJack   文件: MainActivity.java
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);

  }
 
 类所在包
 类方法
 同包方法