Example usage for android.widget ImageView setVisibility

List of usage examples for android.widget ImageView setVisibility

Introduction

In this page you can find the example usage for android.widget ImageView setVisibility.

Prototype

@RemotableViewMethod
    @Override
    public void setVisibility(int visibility) 

Source Link

Usage

From source file:org.runbuddy.tomahawk.adapters.ViewHolder.java

public void fillView(Query query, String numerationString, boolean showAsPlaying, boolean showAsQueued,
        View.OnClickListener dequeueButtonListener, boolean showResolverIcon) {
    TextView trackNameTextView = (TextView) findViewById(R.id.track_textview);
    trackNameTextView.setText(query.getPrettyName());
    setTextViewEnabled(trackNameTextView, query.isPlayable(), false);

    ImageView resolverImageView = (ImageView) ensureInflation(R.id.resolver_imageview_stub,
            R.id.resolver_imageview);//from  w w  w .j  a va  2s  .co m
    TextView numerationTextView = (TextView) findViewById(R.id.numeration_textview);
    if (showAsQueued) {
        ImageView dequeueImageView = (ImageView) findViewById(R.id.dequeue_imageview);
        if (dequeueButtonListener != null && dequeueImageView != null) {
            ImageUtils.loadDrawableIntoImageView(TomahawkApp.getContext(), dequeueImageView,
                    R.drawable.ic_navigation_close, R.color.tomahawk_red);
            dequeueImageView.setOnClickListener(dequeueButtonListener);
        }
    } else if (showAsPlaying || showResolverIcon) {
        if (numerationTextView != null) {
            numerationTextView.setVisibility(View.GONE);
        }
        if (resolverImageView != null) {
            resolverImageView.setVisibility(View.VISIBLE);
            if (query.getPreferredTrackResult() != null) {
                Resolver resolver = query.getPreferredTrackResult().getResolvedBy();
                resolver.loadIcon(resolverImageView, false);
            }
        }
    } else if (numerationString != null) {
        if (resolverImageView != null) {
            resolverImageView.setVisibility(View.GONE);
        }
        if (numerationTextView != null) {
            numerationTextView.setVisibility(View.VISIBLE);
            numerationTextView.setText(numerationString);
            setTextViewEnabled(numerationTextView, query.isPlayable(), false);
        }
    }
    if (mLayoutId == R.layout.list_item_numeration_track_artist || mLayoutId == R.layout.list_item_track_artist
            || mLayoutId == R.layout.list_item_track_artist_queued) {
        TextView artistNameTextView = (TextView) findViewById(R.id.artist_textview);
        artistNameTextView.setText(query.getArtist().getPrettyName());
        setTextViewEnabled(artistNameTextView, query.isPlayable(), false);
    } else if (mLayoutId == R.layout.list_item_numeration_track_duration) {
        TextView durationTextView = (TextView) findViewById(R.id.duration_textview);
        if (query.getPreferredTrack().getDuration() > 0) {
            durationTextView.setText(ViewUtils.durationToString((query.getPreferredTrack().getDuration())));
        } else {
            durationTextView.setText(PlaybackPanel.COMPLETION_STRING_DEFAULT);
        }
        setTextViewEnabled(durationTextView, query.isPlayable(), false);
    }
}

From source file:com.nnm.smsviet.MessageListActivity.java

/**
 * Show {@link Contact}'s photo./*ww w . j  av  a 2s.  c  o m*/
 * 
 * @param contact
 *            {@link Contact}
 */
private void setContactIcon(final Contact contact) {
    if (contact == null) {
        Log.w(TAG, "setContactIcon(null)");
        this.showContactItem = false;
        return;
    }

    final String name = contact.getName();
    this.showContactItem = this.showPhoto && name != null;

    if (this.contactItem == null) {
        Log.w(TAG, "setContactIcon: contactItem == null");
        return;
    }

    if (!this.needContactUpdate) {
        Log.i(TAG, "skip setContactIcon()");
        return;
    }

    if (this.showPhoto && name != null) {
        // photo
        ImageView ivPhoto = (ImageView) this.findViewById(R.id.photo);
        if (ivPhoto == null) {
            ivPhoto = (ImageView) this.contactItem.getActionView().findViewById(R.id.photo);
        }
        if (ivPhoto == null) {
            Log.w(TAG, "ivPhoto == null");
        } else {
            ivPhoto.setImageDrawable(contact.getAvatar(this, this.defaultContactAvatar));
            ivPhoto.setOnClickListener(WRAPPER.getQuickContact(this, ivPhoto,
                    contact.getLookUpUri(this.getContentResolver()), 2, null));
        }

        // presence
        ImageView ivPresence = (ImageView) this.findViewById(R.id.presence);
        if (ivPresence == null) {
            ivPresence = (ImageView) this.contactItem.getActionView().findViewById(R.id.presence);
        }
        if (ivPresence == null) {
            Log.w(TAG, "ivPresence == null");
        } else {
            if (contact.getPresenceState() > 0) {
                ivPresence.setImageResource(Contact.getPresenceRes(contact.getPresenceState()));
                ivPresence.setVisibility(View.VISIBLE);
            } else {
                ivPresence.setVisibility(View.INVISIBLE);
            }
        }
    }

    this.contactItem.setVisible(this.showContactItem);
    this.needContactUpdate = false;
}

From source file:vn.com.zinza.zinzamessenger.activity.IntroActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);

    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    mPrefManager = new PrefManager(this);
    if (!mPrefManager.isFirstTimeLaunch()) {
        launchHomeScreen();/*  www.  ja  va2 s  . c  om*/
        finish();
    }
    setContentView(R.layout.intro_layout);

    mIcons = new int[] { R.drawable.zinza_icon, R.drawable.chat, R.drawable.search_friend,
            R.drawable.transfer_files };
    mMessages = new int[] { R.string.app_overview_1st_item_text, R.string.app_overview_2nd_item_text,
            R.string.app_overview_3rd_item_text, R.string.app_overview_4th_item_text };
    mViewPager = (ViewPager) findViewById(R.id.intro_view_pager);
    mStartMessagingButton = (TextView) this.findViewById(R.id.start_messaging_button);
    mStartLogin = (TextView) this.findViewById(R.id.startLogin);
    mStartMessagingButton.setText(getString(R.string.StartMessaging));
    if (Build.VERSION.SDK_INT >= 21) {
        StateListAnimator animator = new StateListAnimator();
        animator.addState(new int[] { android.R.attr.state_pressed },
                ObjectAnimator.ofFloat(mStartMessagingButton, "translationZ", AndroidUtilities.dp(2, this),
                        AndroidUtilities.dp(4, this)).setDuration(200));
        animator.addState(new int[] {}, ObjectAnimator.ofFloat(mStartMessagingButton, "translationZ",
                AndroidUtilities.dp(4, this), AndroidUtilities.dp(2, this)).setDuration(200));
        mStartMessagingButton.setStateListAnimator(animator);
    }
    mTopImage1 = (ImageView) findViewById(R.id.icon_image1);
    mTopImage2 = (ImageView) findViewById(R.id.icon_image2);
    mIndicator = (CirclePageIndicator) findViewById(R.id.indicator);

    mTopImage2.setVisibility(View.GONE);
    mViewPager.setAdapter(new IntroAdapter());
    mViewPager.setPageMargin(0);
    mViewPager.setOffscreenPageLimit(1);
    mIndicator.setViewPager(mViewPager);
    mIndicator.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

            if (mViewPager.getCurrentItem() == 3) {
                mStartLogin.setVisibility(View.VISIBLE);
                mStartMessagingButton.setVisibility(View.INVISIBLE);
            } else {
                mStartLogin.setVisibility(View.INVISIBLE);
                mStartMessagingButton.setVisibility(View.VISIBLE);
            }
            if (mLastPage != mViewPager.getCurrentItem()) {
                mLastPage = mViewPager.getCurrentItem();

                final ImageView fadeoutImage;
                final ImageView fadeinImage;
                if (mTopImage1.getVisibility() == View.VISIBLE) {
                    fadeoutImage = mTopImage1;
                    fadeinImage = mTopImage2;

                } else {
                    fadeoutImage = mTopImage2;
                    fadeinImage = mTopImage1;
                }

                fadeinImage.bringToFront();
                fadeinImage.setImageResource(mIcons[mLastPage]);
                fadeinImage.clearAnimation();
                fadeoutImage.clearAnimation();

                Animation outAnimation = AnimationUtils.loadAnimation(IntroActivity.this,
                        R.anim.icon_anim_fade_out);
                outAnimation.setAnimationListener(new Animation.AnimationListener() {
                    @Override
                    public void onAnimationStart(Animation animation) {
                    }

                    @Override
                    public void onAnimationEnd(Animation animation) {
                        fadeoutImage.setVisibility(View.GONE);
                    }

                    @Override
                    public void onAnimationRepeat(Animation animation) {

                    }
                });

                Animation inAnimation = AnimationUtils.loadAnimation(IntroActivity.this,
                        R.anim.icon_anim_fade_in);
                inAnimation.setAnimationListener(new Animation.AnimationListener() {
                    @Override
                    public void onAnimationStart(Animation animation) {
                        fadeinImage.setVisibility(View.VISIBLE);
                    }

                    @Override
                    public void onAnimationEnd(Animation animation) {
                    }

                    @Override
                    public void onAnimationRepeat(Animation animation) {

                    }
                });

                fadeoutImage.startAnimation(outAnimation);
                fadeinImage.startAnimation(inAnimation);
            }
        }

        @Override
        public void onPageSelected(int position) {

        }

        @Override
        public void onPageScrollStateChanged(int state) {

        }
    });

    mStartMessagingButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if (mStartPressed) {
                return;
            }
            mStartPressed = true;
            launchHomeScreen();
        }
    });

    mStartLogin.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            launchHomeScreen();
        }
    });

}

From source file:io.plaidapp.ui.DesignerNewsStory.java

private void bindDescription() {
    final TextView storyComment = (TextView) header.findViewById(R.id.story_comment);
    if (!TextUtils.isEmpty(story.comment)) {
        HtmlUtils.parseMarkdownAndSetText(storyComment, story.comment, markdown,
                new Bypass.LoadImageCallback() {
                    @Override/*from   w w w  .  jav a 2 s. c o m*/
                    public void loadImage(String src, ImageLoadingSpan loadingSpan) {
                        Glide.with(DesignerNewsStory.this).load(src).asBitmap()
                                .diskCacheStrategy(DiskCacheStrategy.ALL)
                                .into(new ImageSpanTarget(storyComment, loadingSpan));
                    }
                });
    } else {
        storyComment.setVisibility(View.GONE);
    }

    upvoteStory = (TextView) header.findViewById(R.id.story_vote_action);
    upvoteStory.setText(getResources().getQuantityString(R.plurals.upvotes, story.vote_count,
            NumberFormat.getInstance().format(story.vote_count)));
    upvoteStory.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(final View v) {
            upvoteStory();
        }
    });

    final TextView share = (TextView) header.findViewById(R.id.story_share_action);
    share.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            ((AnimatedVectorDrawable) share.getCompoundDrawables()[1]).start();
            startActivity(ShareCompat.IntentBuilder.from(DesignerNewsStory.this).setText(story.url)
                    .setType("text/plain").setSubject(story.title).getIntent());
        }
    });

    TextView storyPosterTime = (TextView) header.findViewById(R.id.story_poster_time);
    SpannableString poster = new SpannableString(story.user_display_name.toLowerCase());
    poster.setSpan(new TextAppearanceSpan(this, R.style.TextAppearance_CommentAuthor), 0, poster.length(),
            Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    CharSequence job = !TextUtils.isEmpty(story.user_job) ? "\n" + story.user_job.toLowerCase() : "";
    CharSequence timeAgo = DateUtils.getRelativeTimeSpanString(story.created_at.getTime(),
            System.currentTimeMillis(), DateUtils.SECOND_IN_MILLIS).toString().toLowerCase();
    storyPosterTime.setText(TextUtils.concat(poster, job, "\n", timeAgo));
    ImageView avatar = (ImageView) header.findViewById(R.id.story_poster_avatar);
    if (!TextUtils.isEmpty(story.user_portrait_url)) {
        Glide.with(this).load(story.user_portrait_url).placeholder(R.drawable.avatar_placeholder)
                .transform(circleTransform).into(avatar);
    } else {
        avatar.setVisibility(View.GONE);
    }
}

From source file:com.android.tv.settings.dialog.DialogFragment.java

public void setIcon(int iconResourceId) {
    mIconResourceId = iconResourceId;//from  w  w w  . j  a  va2s  .co  m
    View v = getView();
    if (v != null) {
        final ImageView iconImageView = (ImageView) v.findViewById(R.id.icon);
        if (iconImageView != null) {
            if (iconResourceId != 0) {
                iconImageView.setImageResource(iconResourceId);
                iconImageView.setVisibility(View.VISIBLE);
                updateViewSize(iconImageView);
            }
        }
    }
}

From source file:jahirfiquitiva.iconshowcase.activities.ViewerActivity.java

@SuppressWarnings("ResourceAsColor")
@Override/*  w  ww  .  j  ava2  s . co m*/
protected void onCreate(Bundle savedInstanceState) {

    ThemeUtils.onActivityCreateSetTheme(this);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        ThemeUtils.onActivityCreateSetNavBar(this);
        Window window = getWindow();
        window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
    }

    super.onCreate(savedInstanceState);

    context = this;

    usePalette = getResources().getBoolean(R.bool.use_palette_api_in_viewer);

    mPrefs = new Preferences(context);

    mPrefs.setActivityVisible(true);

    Intent intent = getIntent();
    String transitionName = intent.getStringExtra("transitionName");

    item = intent.getParcelableExtra("item");

    setContentView(R.layout.wall_viewer_activity);

    toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    if (getSupportActionBar() != null) {
        getSupportActionBar().setTitle("");
        getSupportActionBar().setHomeAsUpIndicator(R.drawable.ic_back);
        getSupportActionBar().setHomeButtonEnabled(true);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        getSupportActionBar().setDisplayShowHomeEnabled(true);
    }

    final int iconsColor = ThemeUtils.darkTheme ? ContextCompat.getColor(context, R.color.toolbar_text_dark)
            : ContextCompat.getColor(context, R.color.toolbar_text_light);

    ToolbarColorizer.colorizeToolbar(toolbar, iconsColor);

    toHide1 = (LinearLayout) findViewById(R.id.iconsA);
    toHide2 = (LinearLayout) findViewById(R.id.iconsB);

    int tintLightLighter = ContextCompat.getColor(context, R.color.drawable_base_tint);
    int tintDark = ContextCompat.getColor(context, R.color.drawable_tint_dark);

    Drawable save = ColorUtils.getTintedIcon(context, R.drawable.ic_save,
            ThemeUtils.darkTheme ? tintDark : tintLightLighter);

    Drawable apply = ColorUtils.getTintedIcon(context, R.drawable.ic_apply_wallpaper,
            ThemeUtils.darkTheme ? tintDark : tintLightLighter);

    Drawable info = ColorUtils.getTintedIcon(context, R.drawable.ic_info,
            ThemeUtils.darkTheme ? tintDark : tintLightLighter);

    ImageView saveIV = (ImageView) findViewById(R.id.download);
    if (item.isDownloadable()) {
        saveIV.setImageDrawable(save);
        saveIV.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (!PermissionUtils.canAccessStorage(context)) {
                    PermissionUtils.setViewerActivityAction("save");
                    PermissionUtils.requestStoragePermission(context);
                } else {
                    showDialogs("save");
                }
            }
        });
    } else {
        saveIV.setVisibility(View.GONE);
    }

    ImageView applyIV = (ImageView) findViewById(R.id.apply);
    applyIV.setImageDrawable(apply);
    applyIV.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            showApplyWallpaperDialog(context, item.getWallURL());
        }
    });

    ImageView infoIV = (ImageView) findViewById(R.id.info);
    infoIV.setImageDrawable(info);
    infoIV.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            ISDialogs.showWallpaperDetailsDialog(context, item.getWallName(), item.getWallAuthor(),
                    item.getWallDimensions(), item.getWallCopyright());
        }
    });

    TouchImageView mPhoto = (TouchImageView) findViewById(R.id.big_wallpaper);
    ViewCompat.setTransitionName(mPhoto, transitionName);

    layout = (RelativeLayout) findViewById(R.id.viewerLayout);

    TextView wallNameText = (TextView) findViewById(R.id.wallName);
    wallNameText.setText(item.getWallName());

    Bitmap bmp = null;
    String filename = getIntent().getStringExtra("image");
    try {
        if (filename != null) {
            FileInputStream is = context.openFileInput(filename);
            bmp = BitmapFactory.decodeStream(is);
            is.close();
        } else {
            bmp = null;
        }
    } catch (Exception e) {
        e.printStackTrace();
    }

    int colorFromCachedPic = 0;

    if (bmp != null) {
        colorFromCachedPic = ColorExtractor.getFinalGeneratedIconsColorFromPalette(bmp, usePalette);
    } else {
        colorFromCachedPic = ThemeUtils.darkTheme ? tintDark : tintLightLighter;
    }

    final ProgressBar spinner = (ProgressBar) findViewById(R.id.progress);
    spinner.getIndeterminateDrawable().setColorFilter(colorFromCachedPic, PorterDuff.Mode.SRC_IN);

    ToolbarColorizer.colorizeToolbar(toolbar, colorFromCachedPic);

    Drawable d;
    if (bmp != null) {
        d = new GlideBitmapDrawable(getResources(), bmp);
    } else {
        d = new ColorDrawable(ContextCompat.getColor(context, android.R.color.transparent));
    }

    if (mPrefs.getAnimationsEnabled()) {
        Glide.with(context).load(item.getWallURL()).placeholder(d).diskCacheStrategy(DiskCacheStrategy.SOURCE)
                .fitCenter().listener(new RequestListener<String, GlideDrawable>() {
                    @Override
                    public boolean onException(Exception e, String model, Target<GlideDrawable> target,
                            boolean isFirstResource) {
                        return false;
                    }

                    @Override
                    public boolean onResourceReady(GlideDrawable resource, String model,
                            Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
                        Bitmap picture = ((GlideBitmapDrawable) resource).getBitmap();
                        ToolbarColorizer.colorizeToolbar(toolbar,
                                ColorExtractor.getFinalGeneratedIconsColorFromPalette(picture, usePalette));
                        spinner.setVisibility(View.GONE);
                        return false;
                    }
                }).into(mPhoto);
    } else {
        Glide.with(context).load(item.getWallURL()).placeholder(d).dontAnimate()
                .diskCacheStrategy(DiskCacheStrategy.SOURCE).fitCenter()
                .listener(new RequestListener<String, GlideDrawable>() {
                    @Override
                    public boolean onException(Exception e, String model, Target<GlideDrawable> target,
                            boolean isFirstResource) {
                        return false;
                    }

                    @Override
                    public boolean onResourceReady(GlideDrawable resource, String model,
                            Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
                        Bitmap picture = ((GlideBitmapDrawable) resource).getBitmap();
                        ToolbarColorizer.colorizeToolbar(toolbar,
                                ColorExtractor.getFinalGeneratedIconsColorFromPalette(picture, usePalette));
                        spinner.setVisibility(View.GONE);
                        return false;
                    }
                }).into(mPhoto);
    }
}

From source file:org.gateshipone.odyssey.activities.OdysseyMainActivity.java

@Override
public void setupToolbar(String title, boolean scrollingEnabled, boolean drawerIndicatorEnabled,
        boolean showImage) {
    // set drawer state
    mDrawerToggle.setDrawerIndicatorEnabled(drawerIndicatorEnabled);

    ImageView collapsingImage = (ImageView) findViewById(R.id.collapsing_image);
    View collapsingImageGradientTop = findViewById(R.id.collapsing_image_gradient_top);
    View collapsingImageGradientBottom = findViewById(R.id.collapsing_image_gradient_bottom);
    if (collapsingImage != null && collapsingImageGradientTop != null
            && collapsingImageGradientBottom != null) {
        if (showImage) {
            collapsingImage.setVisibility(View.VISIBLE);
            collapsingImageGradientTop.setVisibility(View.VISIBLE);
            collapsingImageGradientBottom.setVisibility(View.VISIBLE);
        } else {//from   w w  w  . j a  va 2s .  c o  m
            collapsingImage.setVisibility(View.GONE);
            collapsingImage.setImageDrawable(null);
            collapsingImageGradientTop.setVisibility(View.GONE);
            collapsingImageGradientBottom.setVisibility(View.GONE);
        }
    }
    // set scrolling behaviour
    CollapsingToolbarLayout toolbar = (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar);
    AppBarLayout.LayoutParams params = (AppBarLayout.LayoutParams) toolbar.getLayoutParams();

    if (scrollingEnabled && !showImage) {
        toolbar.setTitleEnabled(false);
        toolbar.setPadding(0, getStatusBarHeight(), 0, 0);
        setTitle(title);

        params.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL
                + AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS_COLLAPSED
                + AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS);
    } else if (!scrollingEnabled && showImage && collapsingImage != null) {
        toolbar.setTitleEnabled(true);
        toolbar.setPadding(0, 0, 0, 0);
        toolbar.setTitle(title);

        params.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_EXIT_UNTIL_COLLAPSED
                + AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL);
    } else {
        toolbar.setTitleEnabled(false);
        toolbar.setPadding(0, getStatusBarHeight(), 0, 0);
        setTitle(title);
        params.setScrollFlags(0);
    }
}

From source file:com.cnm.cnmrc.fragment.rc.RcBase.java

/**
 * Loading TapPressAnimation <br>//from w ww.j  av a 2s.  com
 */
protected void startLoadingAni(ImageButton view, final ImageView animView) {
    if (view != null) {
        view.post(new Runnable() {
            @Override
            public void run() {
                try {
                    mTapPressAnimation = new AnimationDrawable();
                    mTapPressAnimation.addFrame(getResources().getDrawable(R.drawable.tappress01), 60);
                    mTapPressAnimation.addFrame(getResources().getDrawable(R.drawable.tappress02), 60);
                    mTapPressAnimation.addFrame(getResources().getDrawable(R.drawable.tappress03), 60);
                    mTapPressAnimation.addFrame(getResources().getDrawable(R.drawable.tappress04), 60);
                    mTapPressAnimation.setOneShot(true);
                    animView.setImageDrawable(mTapPressAnimation);

                    // API 2.3.4?  ?... ???
                    // animView.setBackgroundResource(R.drawable.anim_tappress);
                    // mTapPressAnimation = (AnimationDrawable)
                    // animView.getBackground();

                    mTapPressDuration = 0;
                    for (int i = 0; i < mTapPressAnimation.getNumberOfFrames(); i++) {
                        mTapPressDuration += mTapPressAnimation.getDuration(i);
                    }

                    animView.setVisibility(View.VISIBLE);

                    // Start the animation (looped playback by default).
                    mTapPressAnimation.start();

                    mHandler.postDelayed(new Runnable() {
                        public void run() {
                            mTapPressAnimation.stop();
                            mTapPressAnimation = null;
                            animView.setBackgroundResource(0);
                            animView.setVisibility(View.INVISIBLE);
                            oneClickTapPress = true;
                        }
                    }, mTapPressDuration);
                } catch (Exception e) {
                    e.getStackTrace();
                }

            }
        });
    }

    //view.post(new Starter());
}

From source file:jahirfiquitiva.iconshowcase.activities.WallpaperViewerActivity.java

@SuppressWarnings("ResourceAsColor")
@Override/* ww  w . j  ava2  s .  com*/
protected void onCreate(Bundle savedInstanceState) {

    ThemeUtils.onActivityCreateSetTheme(this);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        ThemeUtils.onActivityCreateSetNavBar(this);
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
    }

    super.onCreate(savedInstanceState);

    makeStatusBarIconsWhite();

    context = this;

    mPrefs = new Preferences(context);

    Intent intent = getIntent();
    String transitionName = intent.getStringExtra("transitionName");

    item = intent.getParcelableExtra("item");

    setContentView(R.layout.wallpaper_viewer_activity);

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    if (getSupportActionBar() != null) {
        getSupportActionBar().setTitle("");
        getSupportActionBar().setHomeAsUpIndicator(R.drawable.ic_back_with_shadow);
        getSupportActionBar().setHomeButtonEnabled(true);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        getSupportActionBar().setDisplayShowHomeEnabled(true);
    }

    ToolbarColorizer.colorizeToolbar(toolbar, ContextCompat.getColor(context, android.R.color.white));

    toHide1 = (LinearLayout) findViewById(R.id.iconsA);
    toHide2 = (LinearLayout) findViewById(R.id.iconsB);

    int tintColor = ThemeUtils.darkOrLight(context, R.color.drawable_tint_dark, R.color.drawable_base_tint);

    Drawable save = IconUtils.getTintedIcon(context, R.drawable.ic_save, tintColor);

    Drawable apply = IconUtils.getTintedIcon(context, R.drawable.ic_apply_wallpaper, tintColor);

    Drawable info = IconUtils.getTintedIcon(context, R.drawable.ic_info, tintColor);

    ImageView saveIV = (ImageView) findViewById(R.id.download);
    if (item.isDownloadable()) {
        saveIV.setImageDrawable(save);
        saveIV.setOnClickListener(new DebouncedClickListener() {
            @Override
            public void onDebouncedClick(View v) {
                if (!PermissionUtils.canAccessStorage(context)) {
                    PermissionUtils.setViewerActivityAction("save");
                    PermissionUtils.requestStoragePermission(context);
                } else {
                    showDialogs("save");
                }
            }
        });
    } else {
        saveIV.setVisibility(View.GONE);
    }

    ImageView applyIV = (ImageView) findViewById(R.id.apply);
    applyIV.setImageDrawable(apply);
    applyIV.setOnClickListener(new DebouncedClickListener() {
        @Override
        public void onDebouncedClick(View v) {
            showApplyWallpaperDialog(item.getWallURL());
        }
    });

    ImageView infoIV = (ImageView) findViewById(R.id.info);
    infoIV.setImageDrawable(info);
    infoIV.setOnClickListener(new DebouncedClickListener() {
        @Override
        public void onDebouncedClick(View v) {
            ISDialogs.showWallpaperDetailsDialog(context, item.getWallName(), item.getWallAuthor(),
                    item.getWallDimensions(), item.getWallCopyright(), new DialogInterface.OnDismissListener() {
                        @Override
                        public void onDismiss(DialogInterface dialogInterface) {
                            //Do nothing
                        }
                    });
        }
    });

    TouchImageView mPhoto = (TouchImageView) findViewById(R.id.big_wallpaper);
    ViewCompat.setTransitionName(mPhoto, transitionName);

    layout = (RelativeLayout) findViewById(R.id.viewerLayout);

    TextView wallNameText = (TextView) findViewById(R.id.wallName);
    wallNameText.setText(item.getWallName());

    Bitmap bmp = null;
    String filename = getIntent().getStringExtra("image");
    try {
        if (filename != null) {
            FileInputStream is = context.openFileInput(filename);
            bmp = BitmapFactory.decodeStream(is);
            is.close();
        } else {
            bmp = null;
        }
    } catch (Exception e) {
        e.printStackTrace();
    }

    int colorFromCachedPic;

    if (bmp != null) {
        colorFromCachedPic = ColorUtils.getPaletteSwatch(bmp).getTitleTextColor();
    } else {
        colorFromCachedPic = tintColor;
    }

    final ProgressBar spinner = (ProgressBar) findViewById(R.id.progress);
    spinner.getIndeterminateDrawable().setColorFilter(colorFromCachedPic, PorterDuff.Mode.SRC_IN);

    Drawable d;
    if (bmp != null) {
        d = new GlideBitmapDrawable(getResources(), bmp);
    } else {
        d = new ColorDrawable(ContextCompat.getColor(context, android.R.color.transparent));
    }

    if (mPrefs.getAnimationsEnabled()) {
        Glide.with(context).load(item.getWallURL()).placeholder(d).diskCacheStrategy(DiskCacheStrategy.SOURCE)
                .fitCenter().listener(new RequestListener<String, GlideDrawable>() {
                    @Override
                    public boolean onException(Exception e, String model, Target<GlideDrawable> target,
                            boolean isFirstResource) {
                        return false;
                    }

                    @Override
                    public boolean onResourceReady(GlideDrawable resource, String model,
                            Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
                        spinner.setVisibility(View.GONE);
                        return false;
                    }
                }).into(mPhoto);
    } else {
        Glide.with(context).load(item.getWallURL()).placeholder(d).dontAnimate()
                .diskCacheStrategy(DiskCacheStrategy.SOURCE).fitCenter()
                .listener(new RequestListener<String, GlideDrawable>() {
                    @Override
                    public boolean onException(Exception e, String model, Target<GlideDrawable> target,
                            boolean isFirstResource) {
                        return false;
                    }

                    @Override
                    public boolean onResourceReady(GlideDrawable resource, String model,
                            Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
                        spinner.setVisibility(View.GONE);
                        return false;
                    }
                }).into(mPhoto);
    }
}

From source file:com.odt.kandani.View.IntroActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    setTheme(R.style.Theme_TMessages);//from w  ww  . j a v a  2 s  . co m
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);

    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    setContentView(R.layout.activity_layout);

    icons = new int[] { R.drawable.intro1, R.drawable.intro2, R.drawable.intro3, R.drawable.intro4 };
    titles = new int[] { R.string.Page1Title, R.string.Page2Title, R.string.Page3Title, R.string.Page4Title };
    messages = new int[] { R.string.Page1Message, R.string.Page2Message, R.string.Page3Message,
            R.string.Page4Message };

    viewPager = (ViewPager) findViewById(R.id.intro_view_pager);
    TextView startMessagingButton = (TextView) findViewById(R.id.start_messaging_button);
    topImage1 = (ImageView) findViewById(R.id.icon_image1);
    topImage2 = (ImageView) findViewById(R.id.icon_image2);
    bottomPages = (ViewGroup) findViewById(R.id.bottom_pages);
    topImage2.setVisibility(View.GONE);
    viewPager.setAdapter(new IntroAdapter());
    viewPager.setPageMargin(0);
    viewPager.setOffscreenPageLimit(1);
    viewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

        }

        @Override
        public void onPageSelected(int i) {

        }

        @Override
        public void onPageScrollStateChanged(int i) {
            if (i == ViewPager.SCROLL_STATE_IDLE || i == ViewPager.SCROLL_STATE_SETTLING) {
                if (lastPage != viewPager.getCurrentItem()) {
                    lastPage = viewPager.getCurrentItem();

                    final ImageView fadeoutImage;
                    final ImageView fadeinImage;
                    if (topImage1.getVisibility() == View.VISIBLE) {
                        fadeoutImage = topImage1;
                        fadeinImage = topImage2;

                    } else {
                        fadeoutImage = topImage2;
                        fadeinImage = topImage1;
                    }

                    fadeinImage.bringToFront();
                    fadeinImage.setImageResource(icons[lastPage]);
                    fadeinImage.clearAnimation();
                    fadeoutImage.clearAnimation();

                    Animation outAnimation = AnimationUtils.loadAnimation(IntroActivity.this,
                            R.anim.icon_anim_fade_out);
                    outAnimation.setAnimationListener(new Animation.AnimationListener() {
                        @Override
                        public void onAnimationStart(Animation animation) {
                        }

                        @Override
                        public void onAnimationEnd(Animation animation) {
                            fadeoutImage.setVisibility(View.GONE);
                        }

                        @Override
                        public void onAnimationRepeat(Animation animation) {

                        }
                    });

                    Animation inAnimation = AnimationUtils.loadAnimation(IntroActivity.this,
                            R.anim.icon_anim_fade_in);
                    inAnimation.setAnimationListener(new Animation.AnimationListener() {
                        @Override
                        public void onAnimationStart(Animation animation) {
                            fadeinImage.setVisibility(View.VISIBLE);
                        }

                        @Override
                        public void onAnimationEnd(Animation animation) {
                        }

                        @Override
                        public void onAnimationRepeat(Animation animation) {

                        }
                    });

                    fadeoutImage.startAnimation(outAnimation);
                    fadeinImage.startAnimation(inAnimation);
                }
            }
        }
    });

    startMessagingButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Intent intent = new Intent(IntroActivity.this, MainActivity.class);
            IntroActivity.this.startActivity(intent);
            overridePendingTransition(R.anim.pull_in_right, R.anim.push_out_left);
            IntroActivity.this.finish();
        }
    });

    justCreated = true;
}