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

The following examples show how to use pl.droidsonroids.gif.GifDrawable#pause() . 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: 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);
                }
            }
        }