Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flicker #1948

Closed
audxo112 opened this issue May 20, 2017 · 1 comment
Closed

Flicker #1948

audxo112 opened this issue May 20, 2017 · 1 comment
Labels

Comments

@audxo112
Copy link

Glide Version:3.7.0, 4.0.0

Device/Android Version:G4/6.0

Issue details / Repro steps / Use case background:
I do not want the blinking when I refresh the image
How can I keep the image from blinking?
GIF in G4 causes buffering
However, if you execute the code below, it will blink, but it will run at the desired speed.
Is there any way to eliminate blinking?

Glide load line / GlideModule (if any) / list Adapter code (if any):
public class MainActivity extends AppCompatActivity {

ImageView _Animation;

Bitmap _BeforeImage;
Bitmap _NowImage;

int []_RunId = {
        R.drawable.animation_cheese_and_cream_back_sight_run01,
        R.drawable.animation_cheese_and_cream_back_sight_run02,
        R.drawable.animation_cheese_and_cream_back_sight_run03,
        R.drawable.animation_cheese_and_cream_back_sight_run04,
        R.drawable.animation_cheese_and_cream_back_sight_run05,
        R.drawable.animation_cheese_and_cream_back_sight_run06,
        R.drawable.animation_cheese_and_cream_back_sight_run07,
        R.drawable.animation_cheese_and_cream_back_sight_run08,
        R.drawable.animation_cheese_and_cream_back_sight_run09,
        R.drawable.animation_cheese_and_cream_back_sight_run10,
        R.drawable.animation_cheese_and_cream_back_sight_run11,
        R.drawable.animation_cheese_and_cream_back_sight_run12,
        R.drawable.animation_cheese_and_cream_back_sight_run13,
        R.drawable.animation_cheese_and_cream_back_sight_run14,
        R.drawable.animation_cheese_and_cream_back_sight_run15,
        R.drawable.animation_cheese_and_cream_back_sight_run16,
        R.drawable.animation_cheese_and_cream_back_sight_run17,
        R.drawable.animation_cheese_and_cream_back_sight_run18,
        R.drawable.animation_cheese_and_cream_back_sight_run19,
        R.drawable.animation_cheese_and_cream_back_sight_run20,
        R.drawable.animation_cheese_and_cream_back_sight_run21,
        R.drawable.animation_cheese_and_cream_back_sight_run22,
        R.drawable.animation_cheese_and_cream_back_sight_run23,
        R.drawable.animation_cheese_and_cream_back_sight_run24,
        R.drawable.animation_cheese_and_cream_back_sight_run25,
        R.drawable.animation_cheese_and_cream_back_sight_run26,
        R.drawable.animation_cheese_and_cream_back_sight_run27,
        R.drawable.animation_cheese_and_cream_back_sight_run28,
        R.drawable.animation_cheese_and_cream_back_sight_run29,
        R.drawable.animation_cheese_and_cream_back_sight_run30,
        R.drawable.animation_cheese_and_cream_back_sight_run31,
        R.drawable.animation_cheese_and_cream_back_sight_run32,
        R.drawable.animation_cheese_and_cream_back_sight_run33,
        R.drawable.animation_cheese_and_cream_back_sight_run34,
        R.drawable.animation_cheese_and_cream_back_sight_run35,
        R.drawable.animation_cheese_and_cream_back_sight_run36,
};

Handler _Handler;

int _Index;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    /*Intent intent = new Intent(MainActivity.this, ScreenService.class);
    startService(intent);*/

    _Animation = (ImageView)findViewById(R.id.animation);
    _Handler = new Handler();
    _Index = 0;
}


@Override
protected void onStart() {
    super.onStart();
    
    _Handler.post(new Runnable() {
        @Override
        public void run() {
            if(_BeforeImage != null){
                _BeforeImage.recycle();
            }
            _BeforeImage = _NowImage;

            int frame = nextFrame();

            if(frame == -1){

            }
            else{
                Glide.with(MainActivity.this).load(frame).dontAnimate().into(_Animation);

// new ImageLoader(_Animation).execute(frame);

                _Handler.postDelayed(this, 100);
            }
        }

        public int nextFrame(){
            int frame = _RunId[_Index++];

            if(_Index >= _RunId.length){
                _Index = 0;
            }

            return frame;
        }

    });
}

}

Layout XML:

<ImageView
    android:id="@+id/animation"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />
@TWiStErRob
Copy link
Collaborator

I think you should use an animated drawable or an actual GIF file, and not reinvent the wheel.

If you're serious about this, take a look at #527 (comment), or a gallery like slideshow implementation with Glide at #861 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants