Example usage for android.graphics.drawable AnimationDrawable start

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

Introduction

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

Prototype

@Override
public void start() 

Source Link

Document

Starts the animation from the first frame, looping if necessary.

Usage

From source file:com.fatelon.partyphotobooth.fragments.CaptureFragment.java

/**
 * Initiates the capture sequence with count down.
 *//*from w  ww . j  a  v a  2 s .  c  o  m*/
private void initiateCountdownCapture() {
    if (mCamera != null) {
        mStartButton.setEnabled(false);
        // Start auto-focus.
        mCamera.autoFocus(null);

        if (PreferencesHelper.PhotoBoothMode.AUTOMATIC.equals(mPhotoBoothMode)) {
            //                mStartButton.set
        }

        // Start animation. Take picture when count down animation completes.
        final AnimationDrawable countdownAnimation = (AnimationDrawable) mStartButton.getBackground();
        countdownAnimation
                .setCallback(new TakePictureAnimationDrawableCallback(countdownAnimation, mStartButton));

        mStartButton.post(new Runnable() {
            @Override
            public void run() {
                countdownAnimation.start();
            }
        });
    }
}

From source file:com.kaku.weac.fragment.AlarmClockOntimeFragment.java

@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
        @Nullable Bundle savedInstanceState) {
    LogUtil.d(LOG_TAG, getActivity().toString() + "onCreateView");

    View view = inflater.inflate(R.layout.fm_alarm_clock_ontime, container, false);
    mTimeTv = (TextView) view.findViewById(R.id.ontime_time);
    // //w  w w.ja  v a 2 s  .c o  m
    mTimeTv.setText(new SimpleDateFormat("HH:mm", Locale.getDefault()).format(new Date()));
    mCurrentTimeDisplay = mTimeTv.getText().toString();
    // ?
    new Thread(new TimeUpdateThread()).start();

    // 
    TextView tagTv = (TextView) view.findViewById(R.id.ontime_tag);
    tagTv.setText(mAlarmClock.getTag());

    // ??
    TextView napTv = (TextView) view.findViewById(R.id.ontime_nap);
    // ????
    if (mAlarmClock.isNap()) {
        // X???????
        if (mNapTimesRan != mNapTimes) {
            // ??
            napTv.setText(String.format(getString(R.string.touch_here_nap), mNapInterval));
            napTv.setOnClickListener(this);
        } else {
            napTv.setVisibility(View.GONE);
        }
    } else {
        napTv.setVisibility(View.GONE);
    }

    LogUtil.i(LOG_TAG, "??" + mNapTimes);

    // ??
    TextView slidingTipIv = (TextView) view.findViewById(R.id.sliding_tip_tv);
    final AnimationDrawable animationDrawable = (AnimationDrawable) slidingTipIv.getCompoundDrawables()[0];
    // ?4.0
    slidingTipIv.post(new Runnable() {
        @Override
        public void run() {
            animationDrawable.start();
        }
    });

    MySlidingView mySlidingView = (MySlidingView) view.findViewById(R.id.my_sliding_view);
    mySlidingView.setSlidingTipListener(new MySlidingView.SlidingTipListener() {
        @Override
        public void onSlidFinish() {
            // ?
            finishActivity();
        }
    });

    // ??
    if (mAlarmClock.isWeaPrompt()) {
        mWeatherInfoGroup = (ViewGroup) view.findViewById(R.id.weather_info_group);
        mWeatherPbar = (ProgressBar) view.findViewById(R.id.progress_bar);
        mWeatherTypeTv = (TextView) view.findViewById(R.id.weather_type_tv);
        mUmbrellaTv = (TextView) view.findViewById(R.id.umbrella_tv);
        // ?
        initWeather();
    }
    return view;
}

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  av  a  2 s.  c  o  m*/
        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();
        }
    }

}

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

/**
 * Show 'AnimationDrawable'  information
 *
 * @param imageView//w  w  w .  j  a  v  a  2s. co m
 * @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.example.search.car.pools.welcome.java

@Override
public void onClick(View v) {
    // TODO Auto-generated method stub
    Fragment fragment = null;//from  ww w  .j  a v a  2s .c  om
    if ((v.equals(l_1) || (v.equals(sp_city)))) {
        String[] city = { "Delhi/NCR", "Bengaluru", "Kolkata", "Mumbai", "Pune", "Ahmedabad" };
        dialog("City", city, sp_city);
    } else if ((v.equals(l_2) || (v.equals(sp_category)))) {
        String[] category = { "All", "Carpool", "Cab", "Rideshare" };
        dialog("Category", category, sp_category);
    } else if ((v.equals(l_3) || (v.equals(sp_search_for)))) {
        String[] search_for = { "Seeker", "Provider", "Both" };
        dialog(" Search For", search_for, sp_search_for);
    } else if (v.equals(close)) {
        promptsView.dismiss();
    } else if (v.equals(rlCities)) {
        layout = "Cities";
        fragment = new Cities();
        frag_tag = "Cities";
        set_fragment(fragment);
        mDrawerLayout.closeDrawer(mDrawerList);
        // getActionBar().setTitle("Cities");
        svg_cities = SVGParser.getSVGFromResource(welcome.this.getResources(), R.raw.city1);
        iv_cities.setImageDrawable(svg_cities.createPictureDrawable());
        rlCities.setBackgroundColor(Color.parseColor("#00ca98"));
        l_cities.setBackground(getResources().getDrawable(R.drawable.white_circle_side_menu));

        svg_dashboard = SVGParser.getSVGFromResource(welcome.this.getResources(), R.raw.dashboard);
        iv_dashboard.setImageDrawable(svg_dashboard.createPictureDrawable());
        rlDashboard.setBackgroundColor(Color.parseColor("#2C3E50"));
        l_dashboard.setBackground(getResources().getDrawable(R.drawable.search_blue));
        svg_search = SVGParser.getSVGFromResource(welcome.this.getResources(), R.raw.search);
        iv_search.setImageDrawable(svg_search.createPictureDrawable());
        rlSearch.setBackgroundColor(Color.parseColor("#2C3E50"));
        l_search.setBackground(getResources().getDrawable(R.drawable.search_blue));
    } else if (v.equals(rlDashboard)) {
        if (task.getString("user_id", null) != null) {
            //            layout = "Dashboard";
            //            fragment = new dashboard();
            //            frag_tag = "Dashboard";
            //            // getActionBar().setTitle("My Profile");
            //            set_fragment(fragment);
            //            mDrawerLayout.closeDrawer(mDrawerList);
            //            svg_dashboard = SVGParser.getSVGFromResource(welcome.this.getResources(), R.raw.dashboard1);
            //            iv_dashboard.setImageDrawable(svg_dashboard.createPictureDrawable());
            //            rlDashboard.setBackgroundColor(Color.parseColor("#00ca98"));
            //            l_dashboard.setBackground(getResources().getDrawable(R.drawable.white_circle_side_menu));
            //
            //            svg_cities = SVGParser.getSVGFromResource(welcome.this.getResources(), R.raw.city);
            //            iv_cities.setImageDrawable(svg_cities.createPictureDrawable());
            //            rlCities.setBackgroundColor(Color.parseColor("#2C3E50"));
            //            l_cities.setBackground(getResources().getDrawable(R.drawable.search_blue));
            //            svg_search = SVGParser.getSVGFromResource(welcome.this.getResources(), R.raw.search);
            //            iv_search.setImageDrawable(svg_search.createPictureDrawable());
            //            rlSearch.setBackgroundColor(Color.parseColor("#2C3E50"));
            //            l_search.setBackground(getResources().getDrawable(R.drawable.search_blue));
            Intent i = new Intent(welcome.this, dashboard_main.class);
            i.putExtra("edit", "1");
            startActivity(i);
            mDrawerLayout.closeDrawer(mDrawerList);
        } else {
            Toast.makeText(welcome.this, "Please Login First", Toast.LENGTH_SHORT).show();
            mDrawerLayout.closeDrawer(mDrawerList);
        }
    } else if (v.equals(rlSearch)) {
        layout = "Search";
        frag_tag = "Search";
        fragment = new Search();
        set_fragment(fragment);
        mDrawerLayout.closeDrawer(mDrawerList);
        // getActionBar().setTitle("Search");

        svg_search = SVGParser.getSVGFromResource(welcome.this.getResources(), R.raw.search1);
        iv_search.setImageDrawable(svg_search.createPictureDrawable());
        rlSearch.setBackgroundColor(Color.parseColor("#00ca98"));
        l_search.setBackground(getResources().getDrawable(R.drawable.white_circle_side_menu));

        svg_dashboard = SVGParser.getSVGFromResource(welcome.this.getResources(), R.raw.dashboard);
        iv_dashboard.setImageDrawable(svg_dashboard.createPictureDrawable());
        rlDashboard.setBackgroundColor(Color.parseColor("#2C3E50"));
        l_dashboard.setBackground(getResources().getDrawable(R.drawable.search_blue));
        svg_cities = SVGParser.getSVGFromResource(welcome.this.getResources(), R.raw.city);
        iv_cities.setImageDrawable(svg_cities.createPictureDrawable());
        rlCities.setBackgroundColor(Color.parseColor("#2C3E50"));
        l_cities.setBackground(getResources().getDrawable(R.drawable.search_blue));
    } else if (v.equals(rlProfile_login) || v.equals(profile_login)) {
        if (task.getString("user_id", null) == null) {
            Intent i = new Intent(getBaseContext(), user_login.class);
            i.putExtra("frag_id", frag_id);
            startActivity(i);
        }
        mDrawerLayout.closeDrawer(mDrawerList);
    }
    //      else if (v.equals(rlEditProfile)) {
    //         if (task.getString("user_id", null) != null) {
    //            Intent i = new Intent(welcome.this, dashboard_main.class);
    //            i.putExtra("edit", "3");
    //            startActivity(i);
    //         } else {
    //            Toast.makeText(welcome.this, "Please Login First", Toast.LENGTH_SHORT).show();
    //         }
    //         mDrawerLayout.closeDrawer(mDrawerList);
    //      } 
    else if (v.equals(login) || v.equals(rlLogin)) {
        if (task.getString("user_id", null) != null && login.getText().toString().contentEquals("Logout")) {
            SharedPreferences.Editor editor = getSharedPreferences("user", MODE_PRIVATE).edit();
            editor.clear();
            editor.commit();
            login.setText("Login");
            rlDashboard.setVisibility(View.GONE);
            //            rlEditProfile.setVisibility(View.GONE);

            if (layout.contentEquals("Dashboard") || frag_tag.contentEquals("Dashboard")) {
                // highlight search menu on slider during on resume
                // change fragment to search
                FragmentManager fm = getFragmentManager();
                FragmentTransaction fragmentTransaction = fm.beginTransaction();
                fragmentTransaction.replace(R.id.content_frame, new Search());
                fragmentTransaction.commit();
                svg_search = SVGParser.getSVGFromResource(welcome.this.getResources(), R.raw.search1);
                iv_search.setImageDrawable(svg_search.createPictureDrawable());
                rlSearch.setBackgroundColor(Color.parseColor("#00ca98"));
                l_search.setBackground(getResources().getDrawable(R.drawable.white_circle_side_menu));
            }

            iv_login.setImageDrawable(svg_login.createPictureDrawable());
            rlProfile.setVisibility(View.GONE);
            rlProfile_login.setVisibility(View.VISIBLE);
            if (frag_id == 6) {
                Intent i_user = new Intent(getBaseContext(), user_login.class);
                i_user.putExtra("frag_id", frag_id);
                startActivity(i_user);
            }
        } else {
            Intent i = new Intent(getBaseContext(), user_login.class);
            i.putExtra("frag_id", frag_id);
            startActivity(i);
        }
        mDrawerLayout.closeDrawer(mDrawerList);
    } else if (v.equals(b_search)) {
        if (sp_city.getText().toString().toUpperCase().equals("SELECT CITY")) {
            Toast.makeText(welcome.this, "First Select the City", Toast.LENGTH_LONG).show();
        } else {
            Intent i = new Intent(welcome.this, search_result.class);
            i.putExtra("city", sp_city.getText().toString());
            i.putExtra("category", sp_category.getText().toString());
            i.putExtra("search_for", sp_search_for.getText().toString());
            i.putExtra("from", et_from.getText().toString());
            i.putExtra("to", et_to.getText().toString());
            i.putExtra("frag_id", 1);
            i.putExtra("company_id", 0);

            startActivity(i);
            promptsView.dismiss();
        }
    } else if (v.equals(l_nav_search) || v.equals(ib_search)) {
        final int DELAY = 200;
        // ColorDrawable f = new
        // ColorDrawable(Color.parseColor("#0087ca"));
        // ColorDrawable f1 = new
        // ColorDrawable(Color.parseColor("#3398ca"));
        AnimationDrawable a = new AnimationDrawable();
        a.addFrame(d1, DELAY);
        a.addFrame(d2, DELAY);
        a.setOneShot(true);
        l_nav_search.setBackground(a);
        a.start();
        showSearchDialog();
    } else if (v.equals(l_handle) || v.equals(ib_handle)) {
        final int DELAY = 200;
        // ColorDrawable f = new
        // ColorDrawable(Color.parseColor("#0087ca"));
        // ColorDrawable f1 = new
        // ColorDrawable(Color.parseColor("#3398ca"));

        AnimationDrawable a = new AnimationDrawable();
        a.addFrame(d1, DELAY);
        a.addFrame(d2, DELAY);
        a.setOneShot(true);
        l_handle.setBackground(a);
        a.start();
        if (mDrawerLayout.isDrawerOpen(GravityCompat.START)) {
            mDrawerLayout.closeDrawer(mDrawerList);
        } else {
            mDrawerLayout.openDrawer(mDrawerList);
        }
    } else if (v.equals(l_menu) || v.equals(ib_menu)) {
        final int DELAY = 200;
        // for light background
        // ColorDrawable f = new
        // ColorDrawable(Color.parseColor("#0087ca"));
        // ColorDrawable f1 = new
        // ColorDrawable(Color.parseColor("#3398ca"));
        AnimationDrawable a = new AnimationDrawable();
        a.addFrame(d1, DELAY);
        a.addFrame(d2, DELAY);
        a.setOneShot(true);
        l_menu.setBackground(a);
        a.start();

        final PopupMenu popup = new PopupMenu(welcome.this, v);
        popup.getMenuInflater().inflate(R.menu.main, popup.getMenu());

        bedMenuItem = popup.getMenu().findItem(R.id.menu_login);
        final SharedPreferences task = getSharedPreferences("user", MODE_PRIVATE);
        popup.getMenu().findItem(R.id.menu_add_new_list).setVisible(!(task.getString("user_id", null) == null));
        popup.getMenu().findItem(R.id.menu_dashboard).setVisible(!(task.getString("user_id", null) == null));

        if (task.getString("user_id", null) != null) {
            bedMenuItem.setTitle("Logout");
            login.setText("Logout");
            iv_login.setImageDrawable(svg_logout.createPictureDrawable());
            rlProfile.setVisibility(View.VISIBLE);
            rlProfile_login.setVisibility(View.GONE);
            rlDashboard.setVisibility(View.VISIBLE);
            //            rlEditProfile.setVisibility(View.VISIBLE);
            set_data();
        } else {
            bedMenuItem.setTitle("Login/Register");
            login.setText("Login");
            iv_login.setImageDrawable(svg_login.createPictureDrawable());
            rlDashboard.setVisibility(View.GONE);
            //            rlEditProfile.setVisibility(View.GONE);
            rlProfile.setVisibility(View.GONE);
            rlProfile_login.setVisibility(View.VISIBLE);
        }

        if (task.getString("user_id", null) != null) {
            popup.getMenu().findItem(R.id.menu_login).setTitle("Logout");
        } else {
            popup.getMenu().findItem(R.id.menu_login).setTitle("Login/Register");
        }
        popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {

            @Override
            public boolean onMenuItemClick(MenuItem item) {
                // TODO Auto-generated method stub
                int id = item.getItemId();
                Intent i;
                switch (id) {
                case R.id.menu_add_new_list:
                    if (task.getString("user_id", null) != null) {
                        i = new Intent(welcome.this, create_activity.class);
                        startActivity(i);
                    } else {
                        Toast.makeText(welcome.this, "Login first", Toast.LENGTH_SHORT).show();
                    }

                    return true;
                case R.id.menu_dashboard:
                    if (task.getString("user_id", null) != null) {
                        i = new Intent(welcome.this, dashboard_main.class);
                        i.putExtra("edit", "12344");
                        startActivity(i);
                    } else {
                        Toast.makeText(welcome.this, "Please Login first", Toast.LENGTH_LONG).show();
                    }
                    return true;
                case R.id.menu_login:
                    if (bedMenuItem.getTitle().equals("Logout")) {
                        SharedPreferences.Editor editor = getSharedPreferences("user", MODE_PRIVATE).edit();
                        editor.clear();
                        editor.commit();
                        // bedMenuItem.setTitle("Login/Register");
                        login.setText("Login");
                        rlDashboard.setVisibility(View.GONE);
                        //                     rlEditProfile.setVisibility(View.GONE);

                        if (layout.contentEquals("Dashboard") || frag_tag.contentEquals("Dashboard")) {
                            // highlight search menu on slider during on
                            // resume
                            // change fragment to search
                            FragmentManager fm = getFragmentManager();
                            FragmentTransaction fragmentTransaction = fm.beginTransaction();
                            fragmentTransaction.replace(R.id.content_frame, new Search());
                            fragmentTransaction.commit();
                            SVG svg_search = SVGParser.getSVGFromResource(welcome.this.getResources(),
                                    R.raw.search1);
                            iv_search.setImageDrawable(svg_search.createPictureDrawable());
                            rlSearch.setBackgroundColor(Color.parseColor("#00ca98"));
                            l_search.setBackground(
                                    getResources().getDrawable(R.drawable.white_circle_side_menu));
                        }

                        iv_login.setImageDrawable(svg_login.createPictureDrawable());
                        rlProfile.setVisibility(View.GONE);
                        rlProfile_login.setVisibility(View.VISIBLE);
                        if (frag_id == 6) {
                            Intent i_user = new Intent(getBaseContext(), user_login.class);
                            i_user.putExtra("frag_id", frag_id);
                            startActivity(i_user);
                        }
                    } else {
                        i = new Intent(getBaseContext(), user_login.class);
                        i.putExtra("frag_id", frag_id);
                        startActivity(i);
                    }
                    return true;
                }
                return false;
            }
        });
        popup.show();
        // } else {
        // openOptionsMenu();
        // }
    }

}

From source file:com.shengtao.chat.chatUI.adapter.MessageAdapter.java

/**
 * ?// ww w .  j  a v  a2  s .  co m
 *
 * @param message
 * @param holder
 * @param position
 * @param convertView
 */
private void handleVoiceMessage(final EMMessage message, final ViewHolder holder, final int position,
        View convertView) {
    VoiceMessageBody voiceBody = (VoiceMessageBody) message.getBody();
    int len = voiceBody.getLength();
    if (len > 0) {
        holder.tv.setText(voiceBody.getLength() + "\"");
        holder.tv.setVisibility(View.VISIBLE);
    } else {
        holder.tv.setVisibility(View.INVISIBLE);
    }
    holder.iv.setOnClickListener(
            new VoicePlayClickListener(message, holder.iv, holder.iv_read_status, this, activity, username));
    holder.iv.setOnLongClickListener(new OnLongClickListener() {
        @Override
        public boolean onLongClick(View v) {
            activity.startActivityForResult((new Intent(activity, ContextMenu.class))
                    .putExtra("position", position).putExtra("type", Type.VOICE.ordinal()),
                    ChatActivity.REQUEST_CODE_CONTEXT_MENU);
            return true;
        }
    });
    if (((ChatActivity) activity).playMsgId != null
            && ((ChatActivity) activity).playMsgId.equals(message.getMsgId())
            && VoicePlayClickListener.isPlaying) {
        AnimationDrawable voiceAnimation;

        voiceAnimation = (AnimationDrawable) holder.iv.getDrawable();
        voiceAnimation.start();
    } else {
        if (message.direct == Direct.RECEIVE) {
            holder.iv.setImageResource(drawable.chatfrom_voice_playing);
        } else {
            holder.iv.setImageResource(drawable.chatto_voice_playing);
        }
    }

    if (message.direct == Direct.RECEIVE) {
        if (message.isListened()) {
            // ???
            holder.iv_read_status.setVisibility(View.INVISIBLE);
        } else {
            holder.iv_read_status.setVisibility(View.VISIBLE);
        }
        EMLog.d(TAG, "it is receive msg");
        if (message.status == EMMessage.Status.INPROGRESS) {
            holder.pb.setVisibility(View.VISIBLE);
            EMLog.d(TAG, "!!!! back receive");
            ((FileMessageBody) message.getBody()).setDownloadCallback(new EMCallBack() {

                @Override
                public void onSuccess() {
                    activity.runOnUiThread(new Runnable() {

                        @Override
                        public void run() {
                            holder.pb.setVisibility(View.INVISIBLE);
                            notifyDataSetChanged();
                        }
                    });

                }

                @Override
                public void onProgress(int progress, String status) {
                }

                @Override
                public void onError(int code, String message) {
                    activity.runOnUiThread(new Runnable() {

                        @Override
                        public void run() {
                            holder.pb.setVisibility(View.INVISIBLE);
                        }
                    });

                }
            });

        } else {
            holder.pb.setVisibility(View.INVISIBLE);

        }
        return;
    }

    // until here, deal with send voice msg
    switch (message.status) {
    case SUCCESS:
        holder.pb.setVisibility(View.GONE);
        holder.staus_iv.setVisibility(View.GONE);
        break;
    case FAIL:
        holder.pb.setVisibility(View.GONE);
        holder.staus_iv.setVisibility(View.VISIBLE);
        break;
    case INPROGRESS:
        holder.pb.setVisibility(View.VISIBLE);
        holder.staus_iv.setVisibility(View.GONE);
        break;
    default:
        sendMsgInBackground(message, holder);
    }
}

From source file:com.xiaoyu.DoctorHelp.chat.chatuidemo.adapter.MessageAdapter.java

/**
 * ?/*from ww w.  j av a  2s. c  om*/
 *
 * @param message
 * @param holder
 * @param position
 * @param convertView
 */
private void handleVoiceMessage(final EMMessage message, final ViewHolder holder, final int position,
        View convertView) {
    VoiceMessageBody voiceBody = (VoiceMessageBody) message.getBody();
    holder.tv.setText(voiceBody.getLength() + "\"");
    holder.iv.setOnClickListener(
            new VoicePlayClickListener(message, holder.iv, holder.iv_read_status, this, activity, username));
    holder.iv.setOnLongClickListener(new OnLongClickListener() {
        @Override
        public boolean onLongClick(View v) {
            activity.startActivityForResult((new Intent(activity, ContextMenu.class))
                    .putExtra("position", position).putExtra("type", EMMessage.Type.VOICE.ordinal()),
                    ChatActivity.REQUEST_CODE_CONTEXT_MENU);
            return true;
        }
    });
    if (((ChatActivity) activity).playMsgId != null
            && ((ChatActivity) activity).playMsgId.equals(message.getMsgId())
            && VoicePlayClickListener.isPlaying) {
        AnimationDrawable voiceAnimation;
        if (message.direct == EMMessage.Direct.RECEIVE) {
            holder.iv.setImageResource(R.anim.voice_from_icon);
        } else {
            holder.iv.setImageResource(R.anim.voice_to_icon);
        }
        voiceAnimation = (AnimationDrawable) holder.iv.getDrawable();
        voiceAnimation.start();
    } else {
        if (message.direct == EMMessage.Direct.RECEIVE) {
            holder.iv.setImageResource(R.drawable.chatfrom_voice_playing);
        } else {
            holder.iv.setImageResource(R.drawable.chatto_voice_playing);
        }
    }

    if (message.direct == EMMessage.Direct.RECEIVE) {
        if (message.isListened()) {
            // ???
            holder.iv_read_status.setVisibility(View.INVISIBLE);
        } else {
            holder.iv_read_status.setVisibility(View.VISIBLE);
        }
        EMLog.d(TAG, "it is receive msg");
        if (message.status == EMMessage.Status.INPROGRESS) {
            holder.pb.setVisibility(View.VISIBLE);
            EMLog.d(TAG, "!!!! back receive");
            ((FileMessageBody) message.getBody()).setDownloadCallback(new EMCallBack() {

                @Override
                public void onSuccess() {
                    activity.runOnUiThread(new Runnable() {

                        @Override
                        public void run() {
                            holder.pb.setVisibility(View.INVISIBLE);
                            notifyDataSetChanged();
                        }
                    });

                }

                @Override
                public void onProgress(int progress, String status) {
                }

                @Override
                public void onError(int code, String message) {
                    activity.runOnUiThread(new Runnable() {

                        @Override
                        public void run() {
                            holder.pb.setVisibility(View.INVISIBLE);
                        }
                    });

                }
            });

        } else {
            holder.pb.setVisibility(View.INVISIBLE);

        }
        return;
    }

    // until here, deal with send voice msg
    switch (message.status) {
    case SUCCESS:
        holder.pb.setVisibility(View.GONE);
        holder.staus_iv.setVisibility(View.GONE);
        break;
    case FAIL:
        holder.pb.setVisibility(View.GONE);
        holder.staus_iv.setVisibility(View.VISIBLE);
        break;
    case INPROGRESS:
        holder.pb.setVisibility(View.VISIBLE);
        holder.staus_iv.setVisibility(View.GONE);
        break;
    default:
        sendMsgInBackground(message, holder);
    }
}

From source file:maimeng.yodian.app.client.android.chat.adapter.MessageAdapter.java

/**
 * ?/*from  www. j  a v a  2s .  c o  m*/
 *
 * @param message
 * @param holder
 * @param position
 * @param convertView
 */
private void handleVoiceMessage(final EMMessage message, final ViewHolder holder, final int position,
        View convertView) {
    VoiceMessageBody voiceBody = (VoiceMessageBody) message.getBody();
    int len = voiceBody.getLength();
    if (len > 0) {
        holder.tv.setText(voiceBody.getLength() + "\"");
        holder.tv.setVisibility(View.VISIBLE);
    } else {
        holder.tv.setVisibility(View.INVISIBLE);
    }
    holder.iv.setOnClickListener(
            new VoicePlayClickListener(message, holder.iv, holder.iv_read_status, this, activity, username));
    holder.iv.setOnLongClickListener(new OnLongClickListener() {
        @Override
        public boolean onLongClick(View v) {
            activity.startActivityForResult(
                    (new Intent(activity, ContextMenu.class)).putExtra("position", position).putExtra("type",
                            EMMessage.Type.VOICE.ordinal()),
                    ChatActivity.REQUEST_CODE_CONTEXT_MENU, new Bundle());
            return true;
        }
    });
    if (((ChatActivity) activity).playMsgId != null
            && ((ChatActivity) activity).playMsgId.equals(message.getMsgId())
            && VoicePlayClickListener.isPlaying) {
        AnimationDrawable voiceAnimation;
        if (message.direct == EMMessage.Direct.RECEIVE) {
            holder.iv.setImageResource(R.drawable.voice_from_icon);
        } else {
            holder.iv.setImageResource(R.drawable.voice_to_icon);
        }
        voiceAnimation = (AnimationDrawable) holder.iv.getDrawable();
        voiceAnimation.start();
    } else {
        if (message.direct == EMMessage.Direct.RECEIVE) {
            holder.iv.setImageResource(R.mipmap.chatfrom_voice_playing);
        } else {
            holder.iv.setImageResource(R.mipmap.chatto_voice_playing);
        }
    }

    if (message.direct == EMMessage.Direct.RECEIVE) {
        if (message.isListened()) {
            // ???
            holder.iv_read_status.setVisibility(View.INVISIBLE);
        } else {
            holder.iv_read_status.setVisibility(View.VISIBLE);
        }
        EMLog.d(TAG, "it is receive msg");
        if (message.status == EMMessage.Status.INPROGRESS) {
            holder.pb.setVisibility(View.VISIBLE);
            EMLog.d(TAG, "!!!! back receive");
            ((FileMessageBody) message.getBody()).setDownloadCallback(new EMCallBack() {

                @Override
                public void onSuccess() {
                    activity.runOnUiThread(new Runnable() {

                        @Override
                        public void run() {
                            holder.pb.setVisibility(View.INVISIBLE);
                            notifyDataSetChanged();
                        }
                    });

                }

                @Override
                public void onProgress(int progress, String status) {
                }

                @Override
                public void onError(int code, String message) {
                    activity.runOnUiThread(new Runnable() {

                        @Override
                        public void run() {
                            holder.pb.setVisibility(View.INVISIBLE);
                        }
                    });

                }
            });

        } else {
            holder.pb.setVisibility(View.INVISIBLE);

        }
        return;
    }

    // until here, deal with send voice msg
    switch (message.status) {
    case SUCCESS:
        holder.pb.setVisibility(View.GONE);
        holder.staus_iv.setVisibility(View.GONE);
        break;
    case FAIL:
        holder.pb.setVisibility(View.GONE);
        holder.staus_iv.setVisibility(View.VISIBLE);
        break;
    case INPROGRESS:
        holder.pb.setVisibility(View.VISIBLE);
        holder.staus_iv.setVisibility(View.GONE);
        break;
    default:
        sendMsgInBackground(message, holder);
    }
}

From source file:com.fullteem.yueba.app.adapter.MessageAdapter.java

/**
 * ?/*from  ww  w .  j  a va2 s. co  m*/
 * 
 * @param message
 * @param holder
 * @param position
 * @param convertView
 */
private void handleVoiceMessage(final EMMessage message, final ViewHolder holder, final int position,
        View convertView) {
    VoiceMessageBody voiceBody = (VoiceMessageBody) message.getBody();
    holder.tv.setText(voiceBody.getLength() + "\"");
    holder.iv.setOnClickListener(
            new VoicePlayClickListener(message, holder.iv, holder.iv_read_status, this, activity, username));
    holder.iv.setOnLongClickListener(new OnLongClickListener() {
        @Override
        public boolean onLongClick(View v) {
            activity.startActivityForResult((new Intent(activity, ContextMenu.class))
                    .putExtra("position", position).putExtra("type", EMMessage.Type.VOICE.ordinal()),
                    ChatActivity.REQUEST_CODE_CONTEXT_MENU);
            return true;
        }
    });
    if (((ChatActivity) activity).playMsgId != null
            && ((ChatActivity) activity).playMsgId.equals(message.getMsgId())
            && VoicePlayClickListener.isPlaying) {
        AnimationDrawable voiceAnimation;
        if (message.direct == EMMessage.Direct.RECEIVE) {
            holder.iv.setImageResource(R.anim.voice_from_icon);
        } else {
            holder.iv.setImageResource(R.anim.voice_to_icon);
        }
        voiceAnimation = (AnimationDrawable) holder.iv.getDrawable();
        voiceAnimation.start();
    } else {
        if (message.direct == EMMessage.Direct.RECEIVE) {
            holder.iv.setImageResource(R.drawable.chatfrom_voice_playing);
        } else {
            holder.iv.setImageResource(R.drawable.chatto_voice_playing);
        }
    }

    if (message.direct == EMMessage.Direct.RECEIVE) {
        if (message.isListened()) {
            // ???
            holder.iv_read_status.setVisibility(View.INVISIBLE);
        } else {
            holder.iv_read_status.setVisibility(View.VISIBLE);
        }
        System.err.println("it is receive msg");
        if (message.status == EMMessage.Status.INPROGRESS) {
            holder.pb.setVisibility(View.VISIBLE);
            System.err.println("!!!! back receive");
            ((FileMessageBody) message.getBody()).setDownloadCallback(new EMCallBack() {

                @Override
                public void onSuccess() {
                    activity.runOnUiThread(new Runnable() {

                        @Override
                        public void run() {
                            holder.pb.setVisibility(View.INVISIBLE);
                            notifyDataSetChanged();
                        }
                    });

                }

                @Override
                public void onProgress(int progress, String status) {
                }

                @Override
                public void onError(int code, String message) {
                    activity.runOnUiThread(new Runnable() {

                        @Override
                        public void run() {
                            holder.pb.setVisibility(View.INVISIBLE);
                        }
                    });

                }
            });

        } else {
            holder.pb.setVisibility(View.INVISIBLE);

        }
        return;
    }

    // until here, deal with send voice msg
    switch (message.status) {
    case SUCCESS:
        holder.pb.setVisibility(View.GONE);
        holder.staus_iv.setVisibility(View.GONE);
        break;
    case FAIL:
        holder.pb.setVisibility(View.GONE);
        holder.staus_iv.setVisibility(View.VISIBLE);
        break;
    case INPROGRESS:
        holder.pb.setVisibility(View.VISIBLE);
        holder.staus_iv.setVisibility(View.GONE);
        break;
    default:
        sendMsgInBackground(message, holder);
    }
}

From source file:com.xpple.jahoqy.adapter.MessageAdapter.java

/**
 * ?/*from   w ww  .  ja va  2  s .c o  m*/
 * 
 * @param message
 * @param holder
 * @param position
 * @param convertView
 */
private void handleVoiceMessage(final EMMessage message, final ViewHolder holder, final int position,
        View convertView) {
    VoiceMessageBody voiceBody = (VoiceMessageBody) message.getBody();
    int len = voiceBody.getLength();
    //      ImageView imageView=holder.iv;
    if (len > 0) {
        holder.tv.setText(voiceBody.getLength() + "\"");
        holder.tv.setVisibility(View.VISIBLE);
    } else {
        holder.tv.setVisibility(View.INVISIBLE);
    }
    holder.iv.setOnClickListener(
            new VoicePlayClickListener(message, holder.iv, holder.iv_read_status, this, activity, username));
    holder.iv.setOnLongClickListener(new OnLongClickListener() {
        @Override
        public boolean onLongClick(View v) {
            activity.startActivityForResult((new Intent(activity, ContextMenu.class))
                    .putExtra("position", position).putExtra("type", Type.VOICE.ordinal()),
                    ChatActivity.REQUEST_CODE_CONTEXT_MENU);
            return true;
        }
    });
    if (((ChatActivity) activity).playMsgId != null
            && ((ChatActivity) activity).playMsgId.equals(message.getMsgId())
            && VoicePlayClickListener.isPlaying) {
        AnimationDrawable voiceAnimation;
        if (message.direct == Direct.RECEIVE) {
            holder.iv.setImageResource(R.anim.voice_from_icon);
        } else {
            holder.iv.setImageResource(R.anim.voice_to_icon);
        }
        voiceAnimation = (AnimationDrawable) holder.iv.getDrawable();
        voiceAnimation.start();
    } else {
        if (message.direct == Direct.RECEIVE) {
            holder.iv.setImageResource(R.drawable.chatfrom_voice_playing);
        } else {
            holder.iv.setImageResource(R.drawable.chatto_voice_playing);
        }
    }

    if (message.direct == Direct.RECEIVE) {
        if (message.isListened()) {
            // ???
            holder.iv_read_status.setVisibility(View.INVISIBLE);
        } else {
            holder.iv_read_status.setVisibility(View.VISIBLE);
        }
        EMLog.d(TAG, "it is receive msg");
        if (message.status == EMMessage.Status.INPROGRESS) {
            holder.pb.setVisibility(View.VISIBLE);
            EMLog.d(TAG, "!!!! back receive");
            ((FileMessageBody) message.getBody()).setDownloadCallback(new EMCallBack() {

                @Override
                public void onSuccess() {
                    activity.runOnUiThread(new Runnable() {

                        @Override
                        public void run() {
                            holder.pb.setVisibility(View.INVISIBLE);
                            notifyDataSetChanged();
                        }
                    });

                }

                @Override
                public void onProgress(int progress, String status) {
                }

                @Override
                public void onError(int code, String message) {
                    activity.runOnUiThread(new Runnable() {

                        @Override
                        public void run() {
                            holder.pb.setVisibility(View.INVISIBLE);
                        }
                    });

                }
            });

        } else {
            holder.pb.setVisibility(View.INVISIBLE);

        }
        return;
    }

    // until here, deal with send voice msg
    switch (message.status) {
    case SUCCESS:
        holder.pb.setVisibility(View.GONE);
        holder.staus_iv.setVisibility(View.GONE);
        break;
    case FAIL:
        holder.pb.setVisibility(View.GONE);
        holder.staus_iv.setVisibility(View.VISIBLE);
        break;
    case INPROGRESS:
        holder.pb.setVisibility(View.VISIBLE);
        holder.staus_iv.setVisibility(View.GONE);
        break;
    default:
        sendMsgInBackground(message, holder);
    }
}