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:com.stikyhive.stikyhive.ChattingActivity.java

public void clickHoldAndTalk(View v) {
    v.setOnTouchListener(new View.OnTouchListener() {
        @Override/*  w w  w  .  j  a v a  2s . c  om*/
        public boolean onTouch(View v, MotionEvent event) {

            v.setBackgroundResource(R.drawable.spin_animation);
            // Get the background, which has been compiled to an AnimationDrawable object.
            AnimationDrawable frameAnimation = (AnimationDrawable) v.getBackground();

            if (event.getAction() == event.ACTION_DOWN) {
                onRecord(true);

                // Start the animation (looped playback by default).
                frameAnimation.start();
                Toast.makeText(getBaseContext(), "Action Down", Toast.LENGTH_SHORT).show();
            } else if (event.getAction() == event.ACTION_UP) {
                calcualteTodayDate();
                adapter.add(new StikyChat("", "<img", false, timeSend, "voiceSend", 0, 0, "", "",
                        audiofile.getAbsolutePath(), null, ""));
                adapter.notifyDataSetChanged();
                lv.smoothScrollToPosition(adapter.getCount() - 1);
                Toast.makeText(getBaseContext(), "Action Up", Toast.LENGTH_SHORT).show();
                onRecord(false);
                frameAnimation.stop();
                v.setBackgroundResource(R.drawable.chat_micro);
                upLoadServerUri = getApplicationContext().getResources().getString(R.string.url)
                        + "/androidstikyhive/voicetransfer.php?fromStikyBee=" + pref.getString("stkid", "")
                        + "&toStikyBee=" + recipientStkid + "&message=voice" + "&dateTime="
                        + URLEncoder.encode(timeSendServer) + "&url="
                        + URLEncoder.encode(getResources().getString(R.string.url));
                new Thread(new Runnable() {

                    @Override
                    public void run() {
                        // TODO Auto-generated method stub
                        int serverResponseCode = uploadFile(audiofile);
                        if (serverResponseCode == 200) {
                            Log.i("Success", " is done! ");
                            flagChatting = false;
                            flagTransfer = true;
                            messageServer = "<img";
                            msg = "Voice Message";
                            recipientStkidGCM = recipientStkid;
                            new regTask().execute("GCM");
                            new regTask2().execute("Last Message!");
                        }
                    }
                }).start();
            }
            return false;
        }
    });
}