Example usage for android.graphics.drawable AnimationDrawable stop

List of usage examples for android.graphics.drawable AnimationDrawable stop

Introduction

In this page you can find the example usage for android.graphics.drawable AnimationDrawable stop.

Prototype

@Override
public void stop() 

Source Link

Document

Stops the animation at the current frame.

Usage

From source file:Main.java

public static void stopAnimation(ImageView pImageView) {
    AnimationDrawable pAnimation = null;
    if (pImageView != null) {
        pAnimation = (AnimationDrawable) pImageView.getBackground();
    }//from w ww . j  av a2 s  .  co m
    if (pAnimation != null && pAnimation.isRunning()) {
        pAnimation.stop();
    }
}

From source file:org.deviceconnect.android.deviceplugin.sphero.setting.fragment.WakeupFragment.java

@Override
public void onPause() {
    super.onPause();
    View root = getView();/*from   w w w  .  j a  v  a 2  s.  c om*/
    if (root != null) {
        ImageView image = (ImageView) root.findViewById(R.id.animView001);
        AnimationDrawable anim = (AnimationDrawable) image.getBackground();
        anim.stop();
    }
}

From source file:org.deviceconnect.android.deviceplugin.sphero.setting.fragment.PairingFragment.java

@Override
public void onPause() {
    super.onPause();
    View root = getView();//from  w  w w  .j a  va 2  s  .  c o m
    if (root != null) {
        ImageView image = (ImageView) root.findViewById(R.id.animView);
        AnimationDrawable anim = (AnimationDrawable) image.getBackground();
        anim.stop();
    }
}

From source file:com.example.android.uamp.ui.tv.CardViewHolder.java

public void detachView() {
    if (mItemState == MediaItemViewHolder.STATE_PLAYING) {
        AnimationDrawable badgeDrawable = (AnimationDrawable) mCardView.getBadgeImage();
        if (badgeDrawable != null) {
            badgeDrawable.stop();
        }//  w w w  .j a  va 2 s  .  c  om
    }
}

From source file:com.tdispatch.passenger.core.TDFragment.java

protected void lockUI(Boolean lockUI) {
    View v = mFragmentView.findViewById(R.id.tdfragment_busy_overlay_container);

    if (v != null) {

        AnimationDrawable busyAnim = (AnimationDrawable) ((ImageView) mFragmentView
                .findViewById(R.id.tdfragment_busy)).getBackground();

        if (lockUI) {
            //            // hide soft menu
            //            InputMethodManager imm = (InputMethodManager)mContext.getSystemService( Context.INPUT_METHOD_SERVICE);
            //            imm.hideSoftInputFromWindow(v.getWindowToken(), 0);

            if (getOverlayBackgroundResourceId() != null) {
                v.setBackgroundResource(getOverlayBackgroundResourceId());
            }//from  ww  w.  ja  va2s .  c o  m

            busyAnim.start();
            v.setVisibility(View.VISIBLE);
        } else {
            v.setVisibility(View.GONE);
            busyAnim.stop();
        }
    } else {
        WebnetLog.d("No lockUI overlay");
    }
}

From source file:androidx.mediarouter.app.MediaRouteButton.java

/**
 * Sets a drawable to use as the remote route indicator.
 *///from   w w w  . j  a  v  a 2  s.c  o m
public void setRemoteIndicatorDrawable(Drawable d) {
    if (mRemoteIndicatorLoader != null) {
        mRemoteIndicatorLoader.cancel(false);
    }

    if (mRemoteIndicator != null) {
        mRemoteIndicator.setCallback(null);
        unscheduleDrawable(mRemoteIndicator);
    }
    if (d != null) {
        if (mButtonTint != null) {
            d = DrawableCompat.wrap(d.mutate());
            DrawableCompat.setTintList(d, mButtonTint);
        }
        d.setCallback(this);
        d.setState(getDrawableState());
        d.setVisible(getVisibility() == VISIBLE, false);
    }
    mRemoteIndicator = d;

    refreshDrawableState();
    if (mAttachedToWindow && mRemoteIndicator != null
            && mRemoteIndicator.getCurrent() instanceof AnimationDrawable) {
        AnimationDrawable curDrawable = (AnimationDrawable) mRemoteIndicator.getCurrent();
        if (mIsConnecting) {
            if (!curDrawable.isRunning()) {
                curDrawable.start();
            }
        } else if (mRemoteActive) {
            if (curDrawable.isRunning()) {
                curDrawable.stop();
            }
            curDrawable.selectDrawable(curDrawable.getNumberOfFrames() - 1);
        }
    }
}

From source file:androidx.mediarouter.app.MediaRouteButton.java

void refreshRoute() {
    final MediaRouter.RouteInfo route = mRouter.getSelectedRoute();
    final boolean isRemote = !route.isDefaultOrBluetooth() && route.matchesSelector(mSelector);
    final boolean isConnecting = isRemote && route.isConnecting();
    boolean needsRefresh = false;
    if (mRemoteActive != isRemote) {
        mRemoteActive = isRemote;//from   w  w w.  jav a2  s. c  om
        needsRefresh = true;
    }
    if (mIsConnecting != isConnecting) {
        mIsConnecting = isConnecting;
        needsRefresh = true;
    }

    if (needsRefresh) {
        updateContentDescription();
        refreshDrawableState();
    }
    if (mAttachedToWindow) {
        setEnabled(mRouter.isRouteAvailable(mSelector, MediaRouter.AVAILABILITY_FLAG_IGNORE_DEFAULT_ROUTE));
    }
    if (mRemoteIndicator != null && mRemoteIndicator.getCurrent() instanceof AnimationDrawable) {
        AnimationDrawable curDrawable = (AnimationDrawable) mRemoteIndicator.getCurrent();
        if (mAttachedToWindow) {
            if ((needsRefresh || isConnecting) && !curDrawable.isRunning()) {
                curDrawable.start();
            }
        } else if (isRemote && !isConnecting) {
            // When the route is already connected before the view is attached, show the last
            // frame of the connected animation immediately.
            if (curDrawable.isRunning()) {
                curDrawable.stop();
            }
            curDrawable.selectDrawable(curDrawable.getNumberOfFrames() - 1);
        }
    }
}

From source file:lu.fisch.canze.activities.MainActivity.java

private void setBluetoothState(int btState) {
    if (bluetoothMenutItem != null) {
        final ImageView imageView = (ImageView) bluetoothMenutItem.getActionView()
                .findViewById(R.id.animated_menu_item_action);

        // stop the animation if there is one running
        AnimationDrawable frameAnimation;
        if (imageView.getBackground() instanceof AnimationDrawable) {
            frameAnimation = (AnimationDrawable) imageView.getBackground();
            if (frameAnimation.isRunning())
                frameAnimation.stop();
        }//  ww  w.j  a va  2s  .  co  m

        switch (btState) {
        case BLUETOOTH_DISCONNECTED:
            imageView.setBackgroundResource(R.mipmap.bluetooth_none);
            break;
        case BLUETOOTH_CONNECTED:
            imageView.setBackgroundResource(R.mipmap.bluetooth_3);
            break;
        case BLUETOOTH_SEARCH:
            runOnUiThread(new Runnable() {
                @SuppressLint("NewApi")
                @Override
                public void run() {
                    AnimationDrawable drawable = (AnimationDrawable) ContextCompat
                            .getDrawable(getApplicationContext(), R.anim.animation_bluetooth);
                    // Use setBackgroundDrawable() for API 14 and 15 and setBackground() for API 16+:
                    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
                        imageView.setBackground(drawable);
                    } else {
                        //noinspection deprecation
                        imageView.setBackgroundDrawable(drawable);
                    }
                    AnimationDrawable frameAnimation = (AnimationDrawable) imageView.getBackground();
                    frameAnimation.start();
                }
            });
            break;
        default:
            break;
        }
    }
}

From source file:com.landenlabs.all_devtool.IconBaseFragment.java

/**
 * Show 'AnimationDrawable'  information
 *
 * @param imageView/*from w ww.ja  v  a2  s .  com*/
 * @param animationDrawable
 * @param row1
 * @param row2
 */
private void showAnimationBtns(final ImageView imageView, final AnimationDrawable animationDrawable,
        TableRow row1, TableRow row2) {

    int[] imageResIds = new int[] { android.R.drawable.ic_media_pause, android.R.drawable.ic_media_play
            // , android.R.drawable.ic_media_next
    };

    String[] descBtns = new String[] { "Pause", "Play"
            // , "Next"
    };

    ImageButton btnImage;
    TextView btnDesc;

    for (int idx = 0; idx < imageResIds.length; idx++) {

        btnImage = new ImageButton(imageView.getContext());
        btnImage.setTag(Integer.valueOf(idx));

        btnImage.setImageResource(imageResIds[idx]);
        btnImage.setPadding(10, 10, 10, 10);
        btnImage.setMinimumHeight(8);
        btnImage.setMinimumWidth(8);
        btnImage.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                int n = (Integer) v.getTag();
                switch (n) {
                case 0: // pause
                    animationDrawable.stop();
                    break;
                case 1: // play
                    animationDrawable.stop();
                    animationDrawable.start();
                    break;
                case 2: // next
                    break;
                }

            }
        });

        row1.addView(btnImage);

        btnDesc = new TextView(imageView.getContext());
        btnDesc.setText(descBtns[idx]);
        btnDesc.setTextSize(12);
        btnDesc.setGravity(Gravity.CENTER);
        row2.addView(btnDesc);
    }

    // Can't start now - icon not fully rendered, see onChangeFocus
    // animationDrawable.stop();
    // animationDrawable.start();

}

From source file:com.tdispatch.passenger.fragment.ControlCenterFragment.java

protected void doShowHideBusy(int what, int step) {

    switch (what) {
    case BUSY_GETTING_MAP_ADDRESS: {
        mPickupDropoffBusyCount += step;
    }// ww  w.  j  a v  a2 s .c om
        break;

    case BUSY_GETTING_ROUTE_AND_PRICE: {
        mPickupDropoffBusyCount += step;
        mBookBusyCount += step;
    }
        break;
    }

    View v = mFragmentView.findViewById(R.id.busy_container);
    if (v != null) {
        AnimationDrawable bookBusyAnim = (AnimationDrawable) ((ImageView) mFragmentView.findViewById(R.id.busy))
                .getBackground();

        if ((mBookBusyCount > 0)) {
            bookBusyAnim.start();
            v.setVisibility(View.VISIBLE);
        } else {
            v.setVisibility(View.GONE);
            bookBusyAnim.stop();
        }
    }

    v = mFragmentView.findViewById(R.id.map_aim_point_busy_container);
    if (v != null) {
        AnimationDrawable mapAimBusyAnim = (AnimationDrawable) ((ImageView) mFragmentView
                .findViewById(R.id.map_aim_point_busy)).getBackground();
        if ((mPickupDropoffBusyCount > 0)) {
            mapAimBusyAnim.start();
            v.setVisibility(View.VISIBLE);
        } else {
            v.setVisibility(View.GONE);
            mapAimBusyAnim.stop();
        }
    }

}