Java Code Examples for pl.droidsonroids.gif.GifDrawable#isPlaying()

The following examples show how to use pl.droidsonroids.gif.GifDrawable#isPlaying() . 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: GifItem.java    From iGap-Android with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public void onPlayPauseGIF(ViewHolder holder, String localPath) throws ClassCastException {
    super.onPlayPauseGIF(holder, localPath);

    MessageProgress progress = (MessageProgress) holder.itemView.findViewById(R.id.progress);
    AppUtils.setProgresColor(progress.progressBar);

    progress.withDrawable(R.drawable.photogif, true);

    GifDrawable gifDrawable = (GifDrawable) holder.image.getDrawable();
    if (gifDrawable != null) {
        if (gifDrawable.isPlaying()) {
            gifDrawable.pause();
            holder.itemView.findViewById(R.id.progress).setVisibility(View.VISIBLE);
        } else {
            gifDrawable.start();
            holder.itemView.findViewById(R.id.progress).setVisibility(View.GONE);
        }
    }
}
 
Example 2
Source File: GifWithTextItem.java    From iGap-Android with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public void onPlayPauseGIF(ViewHolder holder, String localPath) throws ClassCastException {
    super.onPlayPauseGIF(holder, localPath);

    MessageProgress progress = (MessageProgress) holder.itemView.findViewById(R.id.progress);
    AppUtils.setProgresColor(progress.progressBar);

    progress.withDrawable(R.mipmap.photogif, true);

    GifDrawable gifDrawable = (GifDrawable) holder.image.getDrawable();
    if (gifDrawable != null) {
        if (gifDrawable.isPlaying()) {
            gifDrawable.pause();
            holder.itemView.findViewById(R.id.progress).setVisibility(View.VISIBLE);
        } else {
            gifDrawable.start();
            holder.itemView.findViewById(R.id.progress).setVisibility(View.GONE);
        }
    }
}
 
Example 3
Source File: GifAwareAsyncDrawable.java    From Markwon with Apache License 2.0 5 votes vote down vote up
@Override
public void draw(@NonNull Canvas canvas) {
    super.draw(canvas);

    if (isGif) {
        final GifDrawable drawable = (GifDrawable) getResult();
        if (!drawable.isPlaying()) {
            gifPlaceholder.setBounds(drawable.getBounds());
            gifPlaceholder.draw(canvas);
        }
    }
}
 
Example 4
Source File: FragmentShearedMedia.java    From iGap-Android with GNU Affero General Public License v3.0 5 votes vote down vote up
private void playAndPusGif(int position, RecyclerView.ViewHolder holder) {

            final GifAdapter.ViewHolder vh = (GifAdapter.ViewHolder) holder;

            GifDrawable gifDrawable = vh.gifDrawable;
            if (gifDrawable != null) {
                if (gifDrawable.isPlaying()) {
                    gifDrawable.pause();
                    vh.messageProgress.setVisibility(View.VISIBLE);
                } else {
                    gifDrawable.start();
                    vh.messageProgress.setVisibility(View.GONE);
                }
            } else {
                File file = new File(vh.filePath);
                if (file.exists()) {
                    vh.gifView.setImageURI(Uri.fromFile(file));
                    vh.gifDrawable = (GifDrawable) vh.gifView.getDrawable();
                    vh.messageProgress.withDrawable(R.drawable.ic_play, true);

                    vh.messageProgress.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View view) {
                            if (vh.gifDrawable != null) {
                                vh.gifDrawable.start();
                                vh.messageProgress.setVisibility(View.GONE);
                            }
                        }
                    });

                    vh.gifDrawable.start();
                    vh.messageProgress.setVisibility(View.GONE);
                }
            }
        }
 
Example 5
Source File: FeedbackFragment.java    From ifican with Apache License 2.0 5 votes vote down vote up
@Override
public void onClick(View v) {
    GifDrawable drawable = (GifDrawable) ((GifImageView) v).getDrawable();
    if (drawable.isPlaying())
        drawable.stop();
    else
        drawable.start();
}
 
Example 6
Source File: TransitionsExampleFragment.java    From ifican with Apache License 2.0 5 votes vote down vote up
@OnClick({R.id.gif1, R.id.gif2})
public void onGifClick(GifImageView view) {
    GifDrawable drawable = (GifDrawable) view.getDrawable();
    if (drawable.isPlaying())
        drawable.stop();
    else
        drawable.start();
}
 
Example 7
Source File: AtentionFragment.java    From ifican with Apache License 2.0 5 votes vote down vote up
@OnClick({R.id.gif1, R.id.gif2, R.id.gif3})
public void onGifClick(GifImageView view) {
    GifDrawable drawable = (GifDrawable) view.getDrawable();
    if (drawable.isPlaying())
        drawable.stop();
    else
        drawable.start();
}
 
Example 8
Source File: ContextFragment.java    From ifican with Apache License 2.0 5 votes vote down vote up
@OnClick(R.id.gif1)
public void onGifClick(GifImageView view) {
    GifDrawable drawable = (GifDrawable) view.getDrawable();
    if (drawable.isPlaying())
        drawable.stop();
    else
        drawable.start();
}
 
Example 9
Source File: Utils.java    From ifican with Apache License 2.0 5 votes vote down vote up
public static void startGif(GifImageView view) {
    GifDrawable drawable = (GifDrawable) view.getDrawable();
    if (!drawable.isPlaying()) {
        drawable.reset();
        drawable.start();
    }
}
 
Example 10
Source File: Utils.java    From ifican with Apache License 2.0 4 votes vote down vote up
public static void stopGif(GifImageView view) {
    GifDrawable drawable = (GifDrawable) view.getDrawable();
    if (drawable.isPlaying())
        drawable.stop();
}