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.guoxiaoxing.cloud.music.magicasakura.widgets.AppCompatImageHelper.java

/**
 * Internal use/*from w  w w .j a va2  s  . c o m*/
 */
private void setImageDrawable(Drawable drawable) {
    if (skipNextApply())
        return;
    if (drawable instanceof AnimationDrawable) {
        Log.e("drawable", "instanceof true");
        AnimationDrawable drawable1 = ((AnimationDrawable) drawable);
        ((ImageView) mView).setImageDrawable(drawable1);
        drawable1.start();
    } else {
        ((ImageView) mView).setImageDrawable(drawable);
    }

}

From source file:com.scoreloop.android.coreui.BaseActivity.java

@Override
public void onWindowFocusChanged(final boolean hasFocus) {
    if (hasFocus) {
        final ImageView imageView = ((ImageView) getTopActivity().findViewById(R.id.progress_indicator));
        if ((imageView != null) && (imageView.getVisibility() == View.VISIBLE)) {
            final AnimationDrawable frameAnimation = (AnimationDrawable) imageView.getBackground();
            frameAnimation.start();
        }//from   ww w .  j  av a  2 s.c  o m
    }
}

From source file:com.alexandrepiveteau.library.tutorial.TutorialFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    Bundle arguments = getArguments();// ww w.  j  av  a 2s.c  om

    mTutorialImage = arguments.getInt(ARGUMENTS_TUTORIAL_IMAGE);
    mTutorialImageBackground = arguments.getInt(ARGUMENTS_TUTORIAL_IMAGE_BACKGROUND);
    mTutorialImageForeground = arguments.getInt(ARGUMENTS_TUTORIAL_IMAGE_FOREGROUND);

    mTutorialName = arguments.getString(ARGUMENTS_TUTORIAL_NAME);
    mTutorialDescription = arguments.getString(ARGUMENTS_TUTORIAL_DESCRIPTION);

    mHasAnimatedImage = arguments.getBoolean(ARGUMENTS_HAS_ANIMATED_IMAGE);
    mHasAnimatedImageBackground = arguments.getBoolean(ARGUMENTS_HAS_ANIMATED_IMAGE_BACKGROUND);
    mHasAnimatedImageForeground = arguments.getBoolean(ARGUMENTS_HAS_ANIMATED_IMAGE_FOREGROUND);

    View rootView = inflater.inflate(R.layout.fragment_tutorial, container, false);

    mTutorialImageImageView = (ImageView) rootView.findViewById(R.id.tutorial_image);
    mTutorialImageImageViewBackground = (ImageView) rootView.findViewById(R.id.tutorial_image_background);
    mTutorialImageImageViewForeground = (ImageView) rootView.findViewById(R.id.tutorial_image_foreground);

    TextView mTutorialNameTextView = (TextView) rootView.findViewById(R.id.tutorial_name);
    TextView mTutorialDescriptionTextView = (TextView) rootView.findViewById(R.id.tutorial_description);

    if (mTutorialImage != NO_IMAGE) {
        if (!mHasAnimatedImage) {
            Glide.with(getActivity()).load(mTutorialImage).fitCenter().into(mTutorialImageImageView);
        } else {
            mTutorialImageImageView.setImageResource(mTutorialImage);
            AnimationDrawable animationDrawable = (AnimationDrawable) mTutorialImageImageView.getDrawable();
            animationDrawable.start();
        }
    }
    if (mTutorialImageBackground != NO_IMAGE) {
        if (!mHasAnimatedImageBackground) {
            Glide.with(getActivity()).load(mTutorialImageBackground).fitCenter()
                    .into(mTutorialImageImageViewBackground);
        } else {
            mTutorialImageImageViewBackground.setImageResource(mTutorialImageBackground);
            AnimationDrawable animationDrawable = (AnimationDrawable) mTutorialImageImageViewBackground
                    .getDrawable();
            animationDrawable.start();
        }
    }
    if (mTutorialImageForeground != NO_IMAGE) {
        if (!mHasAnimatedImageForeground) {
            Glide.with(getActivity()).load(mTutorialImageForeground).fitCenter()
                    .into(mTutorialImageImageViewForeground);
        } else {
            mTutorialImageImageViewForeground.setImageResource(mTutorialImageForeground);
            AnimationDrawable animationDrawable = (AnimationDrawable) mTutorialImageImageViewForeground
                    .getDrawable();
            animationDrawable.start();
        }
    }

    mTutorialNameTextView.setText(mTutorialName);
    mTutorialDescriptionTextView.setText(mTutorialDescription);

    return rootView;
}

From source file:com.visenze.visearch.camerademo.fragments.CameraFragment.java

private void changeUploadUI() {
    ButterKnife.apply(cameraUIs, HIDE);//from www .  j  a  va 2 s  .co  m
    ButterKnife.apply(searchUIs, SHOW);

    //start scan
    AnimationDrawable anim = (AnimationDrawable) loadingImage.getDrawable();
    anim.start();
}

From source file:com.visenze.visearch.camerademo.fragments.PhotoEditFragment.java

private void changeUploadUI() {
    loadingImage.setVisibility(View.VISIBLE);
    ButterKnife.apply(photoUIs, HIDE);//from  w  w  w .ja  v  a2 s  .c  o m
    rotateButton.setClickable(false);

    //start scan
    AnimationDrawable anim = (AnimationDrawable) loadingImage.getDrawable();
    anim.start();
}

From source file:org.chromium.chrome.browser.physicalweb.ListUrlsActivity.java

private void startRefresh(boolean isUserInitiated, boolean isSwipeInitiated) {
    if (mIsRefreshing) {
        return;/*from   w  w  w .j  a v a  2 s  .  c o m*/
    }

    mIsRefreshing = true;
    mIsRefreshUserInitiated = isUserInitiated;

    // Clear the list adapter to trigger the empty list display.
    mAdapter.clear();

    Collection<UrlInfo> urls = UrlManager.getInstance().getUrls(true);

    // Check the Physical Web preference to ensure we do not resolve URLs when Physical Web is
    // off or onboarding. Normally the user will not reach this activity unless the preference
    // is explicitly enabled, but there is a button on the diagnostics page that launches into
    // the activity without checking the preference state.
    if (urls.isEmpty() || !PhysicalWeb.isPhysicalWebPreferenceEnabled()) {
        finishRefresh();
    } else {
        // Show the swipe-to-refresh busy indicator for refreshes initiated by a swipe.
        if (isSwipeInitiated) {
            mSwipeRefreshWidget.setRefreshing(true);
        }

        // Update the empty list view to show a scanning animation.
        mEmptyListText.setText(R.string.physical_web_empty_list_scanning);

        mScanningImageView.setImageResource(R.drawable.physical_web_scanning_animation);
        mScanningImageView.setColorFilter(null);

        AnimationDrawable animationDrawable = (AnimationDrawable) mScanningImageView.getDrawable();
        animationDrawable.start();

        mPwsResults.clear();
        resolve(urls, isUserInitiated);
    }
}

From source file:libraries.caifudemo.widget.sdliding.SlidingTabLayout.java

private void populateTabStrip() {
    final PagerAdapter adapter = mViewPager.getAdapter();
    final OnClickListener tabClickListener = new TabClickListener();
    frgCount = adapter.getCount();// w  ww .j a v a  2 s.co  m

    for (int i = 0; i < adapter.getCount(); i++) {
        View tabView = null;
        TextView tabTitleView = null;

        if (mTabViewLayoutId != 0) {
            // If there is a custom tab view layout id set, try and inflate it
            tabView = LayoutInflater.from(getContext()).inflate(mTabViewLayoutId, mTabStrip, false);
            tabTitleView = (TextView) tabView.findViewById(mTabViewTextViewId);

            CharSequence pageTitle = adapter.getPageTitle(i);
            //?
            if ("".equals(pageTitle)) {
                tabView = LayoutInflater.from(getContext()).inflate(R.layout.gif_tab_layout, mTabStrip, false);
                ImageView hotimage = (ImageView) tabView.findViewById(R.id.hot_log);
                AnimationDrawable hotgif = (AnimationDrawable) hotimage.getBackground();
                hotgif.start();
                tabTitleView = (TextView) tabView.findViewById(R.id.gif_tv_tab);
            }
        }

        if (tabView == null) {
            tabView = createDefaultTabView(getContext());
        }

        if (tabTitleView == null && TextView.class.isInstance(tabView)) {
            tabTitleView = (TextView) tabView;
        }

        if (mDistributeEvenly) {
            LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                    LayoutParams.WRAP_CONTENT);
            lp.width = 0;
            lp.weight = 1;
            tabView.setLayoutParams(lp);
        }

        tabTitleView.setText(adapter.getPageTitle(i));
        tabView.setOnClickListener(tabClickListener);

        mTabStrip.addView(tabView);

        if (i == mViewPager.getCurrentItem()) {
            tabView.setSelected(true);
        }
        textViewList.add(tabTitleView);
    }
    for (int i = 0; i < frgCount; i++) {
        textViewList.get(i).setTextColor(unselectedTitleTextColor);
    }
    textViewList.get(mViewPager.getCurrentItem()).setTextColor(selectedTitleTextColor);

}

From source file:com.alexandrepiveteau.library.tutorial.TutorialActivity.java

@Override
public void onPageSelected(int position) {

    if (mViewPager.getCurrentItem() == 0) {
        mButtonLeft.setText(getIgnoreText());

        animateViewFadeIn(mButtonLeft);/*from w  w  w .j  a  v  a2 s  .c om*/
        animateViewScaleOut(mImageButtonLeft);
    } else if (mViewPager.getCurrentItem() == getCount() - 1) {
        animateViewFadeOut(mButtonLeft);
        animateViewScaleIn(mImageButtonLeft);
    } else {
        animateViewFadeOut(mButtonLeft);
        animateViewScaleIn(mImageButtonLeft);
    }

    if (mViewPager.getCurrentItem() == getCount() - 1 && mViewPager.getCurrentItem() != mPreviousPage) {
        mImageButtonRight.setImageResource(R.drawable.animated_next_to_ok);
        AnimationDrawable animationDrawable = (AnimationDrawable) mImageButtonRight.getDrawable();
        animationDrawable.start();
    } else if (mViewPager.getCurrentItem() != mPreviousPage && mPreviousPage == getCount() - 1) {
        mImageButtonRight.setImageResource(R.drawable.animated_ok_to_next);
        AnimationDrawable animationDrawable = (AnimationDrawable) mImageButtonRight.getDrawable();
        animationDrawable.start();
    }

    handleCustomIcons(position);
}

From source file:org.gots.allotment.adapter.ListAllotmentAdapter.java

@SuppressWarnings("deprecation")
@Override/*from ww  w. j  a v a  2 s  . c  om*/
public View getView(final int position, View convertView, ViewGroup parent) {
    LinearLayout ll = (LinearLayout) convertView;
    Holder holder;
    if (ll == null) {
        holder = new Holder();
        ll = (LinearLayout) LayoutInflater.from(mContext).inflate(R.layout.list_allotments, parent, false);
        if (GotsPreferences.DEBUG) {
            TextView textView = new TextView(mContext);
            textView.setText("(" + getItem(position).getId() + ")" + getItem(position).getUUID());
            ll.addView(textView);
        }

        holder.listSeeds = (GridView) ll.findViewById(R.id.IdGrowingSeedList);
        holder.titlebar = (LinearLayout) ll.findViewById(R.id.idAllotmentTitlebar);
        holder.allotmentName = (TextView) ll.findViewById(R.id.textAllotmentName);
        holder.menu = (LinearLayout) ll.findViewById(R.id.idAllotmentMenu);

        holder.allotment = getItem(position);
        ll.setTag(holder);
        ll.setDescendantFocusability(LinearLayout.FOCUS_BLOCK_DESCENDANTS);
        // ll.setOnClickListener(this);

    } else
        holder = (Holder) ll.getTag();

    WindowManager wm = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);
    Display display = wm.getDefaultDisplay();
    int width;
    int sdk = android.os.Build.VERSION.SDK_INT;
    if (sdk < android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        width = display.getWidth();
    } else {
        Point size = new Point();
        display.getSize(size);
        width = size.x;
    }
    int layoutsize = 150;
    if (width <= 480)
        layoutsize = 50;
    int nbcolumn = (width - 200) / layoutsize;
    if (nbcolumn < 1)
        nbcolumn = 1;
    holder.listSeeds.setNumColumns(nbcolumn);

    listGrowingSeedAdapter = new ListGrowingSeedAdapter(mContext, getItem(position).getSeeds());
    holder.listSeeds.setAdapter(listGrowingSeedAdapter);
    holder.listSeeds.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, layoutsize));
    if (listGrowingSeedAdapter.getCount() > 0) {
        holder.listSeeds.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,
                (holder.listSeeds.getCount() / nbcolumn + 1) * layoutsize + layoutsize));
        // holder.listSeeds.setLayoutParams(new
        // LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,
        // LayoutParams.WRAP_CONTENT));
    }
    // else
    // holder.listSeeds.setLayoutParams(new
    // LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,
    // ((holder.listSeeds.getCount() / nbcolumn) + 1) * layoutsize));

    holder.allotmentName.setText(getItem(position).getName());

    // holder.titlebar.removeAllViews();

    holder.menu.setTag(holder);
    holder.menu.setOnClickListener(this);
    // SowingAction sow = new SowingAction(mContext);
    // ActionWidget widget = new ActionWidget(mContext, sow);
    // widget.setTag(position);

    if (isSelectable) {
        holder.menu.setBackgroundResource(R.anim.rotate_alerte);
        // Animation myFadeInAnimation =
        // AnimationUtils.loadAnimation(mContext, R.anim.rotate_alerte);
        // menu.startAnimation(myFadeInAnimation);
        AnimationDrawable frameAnimation = (AnimationDrawable) holder.menu.getBackground();
        frameAnimation.start();
        holder.menu.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                new AsyncTask<Void, Integer, GrowingSeedInterface>() {
                    @Override
                    protected GrowingSeedInterface doInBackground(Void... params) {

                        GotsGrowingSeedManager growingSeedManager = GotsGrowingSeedManager.getInstance()
                                .initIfNew(mContext);
                        GotsSeedManager seedManager = GotsSeedManager.getInstance().initIfNew(mContext);
                        // NuxeoGrowingSeedProvider provider = new
                        // NuxeoGrowingSeedProvider(mContext);
                        GrowingSeedInterface growingSeed = (GrowingSeedInterface) seedManager
                                .getSeedById(currentSeedId);
                        growingSeed.setDateSowing(Calendar.getInstance().getTime());

                        return growingSeedManager.plantingSeed(growingSeed, getItem(position));
                    }

                    @Override
                    protected void onPostExecute(GrowingSeedInterface seed) {
                        // notifyDataSetChanged();
                        Toast.makeText(mContext, "Sowing" + " " + SeedUtil.translateSpecie(mContext, seed),
                                Toast.LENGTH_LONG).show();
                        mContext.sendBroadcast(new Intent(BroadCastMessages.SEED_DISPLAYLIST));
                        ((Activity) mContext).finish();
                    }
                }.execute();
            }
        });
    }

    // widget.setPadding(4, 4, 4, 8);
    // holder.menu.addView(widget);

    // // SowingAction sow = new SowingAction(mContext);
    // ImageView widgetSensor = new ImageView(mContext);
    // widgetSensor.setImageDrawable(mContext.getResources().getDrawable(R.drawable.ic_sensor));
    // widgetSensor.setBackgroundDrawable(mContext.getResources().getDrawable(R.drawable.action_selector));
    // widgetSensor.setTag(position);
    // widgetSensor.setOnClickListener(new View.OnClickListener() {
    //
    // @Override
    // public void onClick(View v) {
    //
    // GotsPurchaseItem purchaseItem = new GotsPurchaseItem(mContext);
    //
    // // if (!purchaseItem.getFeatureParrot() ? true :
    // purchaseItem.isPremium()) {
    // if (!purchaseItem.getFeatureParrot() || purchaseItem.isPremium()) {
    // FragmentManager fm = mContext.getSupportFragmentManager();
    // GotsBillingDialog editNameDialog = new
    // GotsBillingDialog(GotsPurchaseItem.SKU_FEATURE_PARROT);
    // editNameDialog.setStyle(DialogFragment.STYLE_NORMAL,
    // R.style.CustomDialog);
    // editNameDialog.show(fm, "fragment_edit_name");
    // } else {
    // Intent sensorIntent = new Intent(mContext, SensorActivity.class);
    // mContext.startActivity(sensorIntent);
    // }// new AsyncTask<Void, Void, List<ParrotLocation>>() {
    // // private LocationListAdapter sensorListAdapter;
    // //
    // // List<ParrotSampleFertilizer> samplesFertilizer = null;
    // //
    // // List<ParrotSampleTemperature> samplesTemp = null;
    // //
    // // @Override
    // // protected List<ParrotLocation> doInBackground(Void... params) {
    // // ParrotSensorProvider sensorProvider = new
    // ParrotSensorProvider(mContext);
    // // List<ParrotLocation> locations = sensorProvider.getLocations();
    // // sensorProvider.getStatus();
    // // samplesFertilizer =
    // sensorProvider.getSamples(locations.get(0).getLocation_identifier());
    // // samplesTemp =
    // sensorProvider.getSamples2(locations.get(0).getLocation_identifier());
    // //
    // // return locations;
    // // }
    // //
    // // protected void onPostExecute(List<ParrotLocation> result) {
    // // // sensorListAdapter = new SensorListAdapter(mContext, result);
    // // sensorListAdapter = new LocationListAdapter(mContext, result);
    // // // new AlertDialog.Builder(mContext).setAdapter(sensorListAdapter,
    // // // new DialogInterface.OnClickListener() {
    // // //
    // // // @Override
    // // // public void onClick(DialogInterface dialog, int which) {
    // // // Toast.makeText(mContext,
    // sensorListAdapter.getItem(which).getSensor_serial(),
    // // // Toast.LENGTH_SHORT).show();
    // // // ;
    // // // }
    // // // }).show();
    // //
    // // Intent sensorIntent = new Intent(mContext, SensorActivity.class);
    // // mContext.startActivity(sensorIntent);
    // //
    // // if (samplesFertilizer != null) {
    // // WebView webView = new WebView(mContext);
    // // String chd = new String();
    // // for (ParrotSampleFertilizer fertilizer : samplesFertilizer) {
    // // chd = chd.concat(String.valueOf(fertilizer.getFertilizer_level() *
    // 100));
    // // chd = chd.concat(",");
    // // }
    // // chd = chd.substring(0, chd.length() - 1);
    // // String url =
    // "http://chart.apis.google.com/chart?cht=ls&chs=250x100&chd=t:" + chd;
    // // webView.loadUrl(url);
    // // Log.d(ListAllotmentAdapter.class.getName(), url);
    // // AlertDialog.Builder alert = new AlertDialog.Builder(mContext);
    // // alert.setView(webView);
    // // alert.show();
    // // }
    // // if (samplesTemp != null) {
    // // WebView webView = new WebView(mContext);
    // // String chd = new String();
    // // int i = 0;
    // // for (ParrotSampleTemperature sampleTemp : samplesTemp) {
    // // chd =
    // chd.concat(String.valueOf(sampleTemp.getAir_temperature_celsius()));
    // // chd = chd.concat(",");
    // // if (i++ >= 50)
    // // break;
    // // }
    // // chd = chd.substring(0, chd.length() - 1);
    // // String url =
    // "http://chart.apis.google.com/chart?cht=ls&chs=250x100&chd=t:" + chd;
    // // webView.loadUrl(url);
    // // Log.d(ListAllotmentAdapter.class.getName(), url);
    // // AlertDialog.Builder alert = new AlertDialog.Builder(mContext);
    // // alert.setView(webView);
    // // alert.show();
    // // }
    // // };
    // // }.execute();
    // }
    // });
    //
    // widgetSensor.setPadding(4, 4, 4, 8);
    // holder.menu.addView(widgetSensor);
    return ll;
}

From source file:com.renard.ocr.DocumentGridActivity.java

@Override
public void onWindowFocusChanged(boolean hasFocus) {
    super.onWindowFocusChanged(hasFocus);
    final AnimationDrawable animation = (AnimationDrawable) getResources()
            .getDrawable(R.drawable.textfairy_title);
    getSupportActionBar().setIcon(animation);
    animation.start();
}