Анимация не слушает функцию onRepeatAnimation - PullRequest
0 голосов
/ 08 февраля 2019

Как сказано в документации Android,

setAnimationListener listener Уведомляет о повторении анимации.

, что означает, что он должен выполнять операторы в onAnimationRepeatфункция каждый раз, когда анимация повторяется (5 раз в моем случае).Но onAnimationRepeat не слушает слушателя, хотя моя анимация повторялась 5 раз.

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:shareInterpolator="false">

    <rotate
        android:duration="500"
        android:pivotX="50%"
        android:pivotY="50%"
        android:toDegrees="3000"
        android:repeatCount="5"

        />

</set>
Animation animation = AnimationUtils.loadAnimation(this, R.anim.rotate_around_center_point);
imgLogo.startAnimation(animation);

animation.setAnimationListener(new Animation.AnimationListener() {
    @Override
    public void onAnimationStart(Animation animation) {
        sharedPreferences = MainActivity.this.getSharedPreferences("Login", MODE_PRIVATE);
        Log.d(TAG, "sharedpreferences: "+sharedPreferences.getString("Unm",null));

        if(sharedPreferences.contains("Unm")){
            FirebaseDatabase.getInstance()
                            .getReference("users")
                            .addListenerForSingleValueEvent(new ValueEventListener() {
                @Override
                public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
                    Log.d(TAG, "sharedpreferences: "+sharedPreferences.getString("Unm",null));
                    User.currentUser = dataSnapshot.child(sharedPreferences.getString("Unm",null))
                                                   .getValue(userModel.class);
                    imgLogo.clearAnimation();
                    Intent intent = new Intent(MainActivity.this, food_menu.class);
                    startActivity(intent);
                    finish();

                }

                @Override
                public void onCancelled(@NonNull DatabaseError databaseError) {
                }
            });
        }
    }


    @Override
    public void onAnimationEnd(Animation animation) {
    }

    @Override
    public void onAnimationRepeat(Animation animation) {
        Log.d(TAG, "onAnimationRepeat: ");
        if(sharedPreferences.contains("Unm")){
            return;
        } else{
            animation.cancel();
            imgLogo.clearAnimation();
            btnset.setVisibility(View.VISIBLE);
        }
    }
});
...