Example usage for android.view.animation AnimationSet AnimationSet

List of usage examples for android.view.animation AnimationSet AnimationSet

Introduction

In this page you can find the example usage for android.view.animation AnimationSet AnimationSet.

Prototype

public AnimationSet(boolean shareInterpolator) 

Source Link

Document

Constructor to use when building an AnimationSet from code

Usage

From source file:com.alibaba.weex.extend.component.WXParallax.java

@Override
public void onScrolled(View view, int dx, int dy) {
    if (ViewCompat.isInLayout(view)) {
        if (mBindingComponent == null && mBindingRef != null) {
            mBindingComponent = findComponent(mBindingRef);
        }/*  w  w  w .  jav a  2  s .c o  m*/
        if (mBindingComponent instanceof BasicListComponent && view instanceof RecyclerView) {
            BasicListComponent listComponent = (BasicListComponent) mBindingComponent;
            mOffsetY = Math.abs(listComponent.calcContentOffset((RecyclerView) view));
        } else if (mBindingComponent instanceof WXRecyclerTemplateList && view instanceof RecyclerView) {
            WXRecyclerTemplateList listComponent = (WXRecyclerTemplateList) mBindingComponent;
            mOffsetY = Math.abs(listComponent.calcContentOffset((RecyclerView) view));
        }
    } else {
        mOffsetY = mOffsetY + dy;
    }

    AnimationSet animationSet = new AnimationSet(true);
    boolean hasAnimation = false;
    for (int i = 0; i < mTransformPropArrayList.size(); i++) {
        TransformCreator creator = mTransformPropArrayList.get(i);
        Animation animation = creator.getAnimation(dx, dy);
        if (animation != null) {
            animationSet.addAnimation(animation);
            hasAnimation = true;
        }
    }

    if (hasAnimation) {
        animationSet.setFillAfter(true);
        if (getHostView() != null) {
            getHostView().startAnimation(animationSet);
        }
    }

    if (mBackgroundColor != null) {
        int color = mBackgroundColor.getColor(dx, dy);
        if (mBackGroundColor != color) {
            getHostView().setBackgroundColor(color);
            mBackGroundColor = color;
        }
    }
}

From source file:com.cachirulop.moneybox.fragment.MoneyboxFragment.java

/**
 * Create dynamically an android animation for a coin or a bill droping into
 * the moneybox./*  w w w  . j a v a2 s . c  om*/
 * 
 * @param img
 *            ImageView to receive the animation
 * @param layout
 *            Layout that paint the image
 * @param curr
 *            Currency value of the image
 * @return Set of animations to apply to the image
 */
private AnimationSet createDropAnimation(ImageView img, View layout, CurrencyValueDef curr) {
    AnimationSet result;

    result = new AnimationSet(false);
    result.setFillAfter(true);

    // Fade in
    AlphaAnimation fadeIn;

    fadeIn = new AlphaAnimation(0.0f, 1.0f);
    fadeIn.setDuration(300);
    result.addAnimation(fadeIn);

    // drop
    TranslateAnimation drop;
    int bottom;

    bottom = Math.abs(layout.getHeight() - img.getLayoutParams().height);
    drop = new TranslateAnimation(1.0f, 1.0f, 1.0f, bottom);
    drop.setStartOffset(300);
    drop.setDuration(1500);

    if (curr.getType() == CurrencyValueDef.MoneyType.COIN) {
        drop.setInterpolator(new BounceInterpolator());
    } else {
        // drop.setInterpolator(new DecelerateInterpolator(0.7f));
        drop.setInterpolator(new AnticipateOvershootInterpolator());
    }

    result.addAnimation(drop);

    return result;
}

From source file:org.videolan.vlc.gui.helpers.UiTools.java

public static void fillAboutView(View v) {
    TextView link = (TextView) v.findViewById(R.id.main_link);
    link.setText(Html.fromHtml(VLCApplication.getAppResources().getString(R.string.about_link)));

    String revision = VLCApplication.getAppResources().getString(R.string.build_revision) + " VLC: "
            + VLCApplication.getAppResources().getString(R.string.build_vlc_revision);
    String builddate = VLCApplication.getAppResources().getString(R.string.build_time);
    String builder = VLCApplication.getAppResources().getString(R.string.build_host);

    TextView compiled = (TextView) v.findViewById(R.id.main_compiled);
    compiled.setText(builder + " (" + builddate + ")");
    TextView textview_rev = (TextView) v.findViewById(R.id.main_revision);
    textview_rev.setText(VLCApplication.getAppResources().getString(R.string.revision) + " " + revision + " ("
            + builddate + ") " + BuildConfig.FLAVOR_abi);

    final ImageView logo = (ImageView) v.findViewById(R.id.logo);
    logo.setOnClickListener(new View.OnClickListener() {
        @Override/*from  ww w.  j a v  a  2  s  .c  o  m*/
        public void onClick(View v) {
            AnimationSet anim = new AnimationSet(true);
            RotateAnimation rotate = new RotateAnimation(0f, 360f, Animation.RELATIVE_TO_SELF, 0.5f,
                    Animation.RELATIVE_TO_SELF, 0.5f);
            rotate.setDuration(800);
            rotate.setInterpolator(new DecelerateInterpolator());
            anim.addAnimation(rotate);
            logo.startAnimation(anim);
        }
    });
}

From source file:com.fabernovel.alertevoirie.HomeActivity.java

@Override
public void onRequestcompleted(int requestCode, Object result) {
    try {/* w ww. ja va 2  s  .c o  m*/
        JSONArray responses;
        //Log.d(Constants.PROJECT_TAG, (String) result);
        responses = new JSONArray((String) result);

        JSONObject response = responses.getJSONObject(0);

        final AnimationSet set = new AnimationSet(false);

        final float centerX = findViewById(R.id.LinearLayout02).getWidth() / 2;
        final float centerY = findViewById(R.id.LinearLayout02).getHeight() / 2;
        final Flip3dAnimation animation = new Flip3dAnimation(0, 360, centerX, centerY);
        animation.setDuration(500);
        set.setFillAfter(true);
        set.setFillBefore(true);
        animation.setInterpolator(new AccelerateInterpolator());

        set.addAnimation(animation);

        if (requestCode == AVService.REQUEST_JSON) {
            if (JsonData.VALUE_REQUEST_GET_INCIDENTS_STATS.equals(response.getString(JsonData.PARAM_REQUEST))) {
                Last_Location.Incidents = response.getJSONObject(JsonData.PARAM_ANSWER);
                int resolved_incidents = response.getJSONObject(JsonData.PARAM_ANSWER)
                        .getInt(JsonData.PARAM_RESOLVED_INCIDENTS);
                int ongoing_incidents = response.getJSONObject(JsonData.PARAM_ANSWER)
                        .getInt(JsonData.PARAM_ONGOING_INCIDENTS);
                int updated_incidents = response.getJSONObject(JsonData.PARAM_ANSWER)
                        .getInt(JsonData.PARAM_UPDATED_INCIDENTS);

                ((TextView) findViewById(R.id.Home_TextView_Solved)).setText(getResources().getQuantityString(
                        R.plurals.home_label_solved, resolved_incidents, resolved_incidents));
                ((TextView) findViewById(R.id.Home_TextView_Current)).setText(getResources()
                        .getQuantityString(R.plurals.home_label_current, ongoing_incidents, ongoing_incidents));
                ((TextView) findViewById(R.id.Home_TextView_Update)).setText(getResources()
                        .getQuantityString(R.plurals.home_label_update, updated_incidents, updated_incidents));
            }
        }

        findViewById(R.id.LinearLayout02).startAnimation(set);
        findViewById(R.id.LinearLayout04).startAnimation(set);
        findViewById(R.id.LinearLayout03).startAnimation(set);
    } catch (JSONException e) {
        Log.e(Constants.PROJECT_TAG, "JSONException", e);
    } catch (ClassCastException e) {
        Log.e(Constants.PROJECT_TAG, "Invalid result. Trying to cast " + result.getClass() + "into String", e);
    } finally {
        if (hidedialog)
            dismissDialog(DIALOG_PROGRESS);
        dialog_shown = false;
    }
}

From source file:uk.org.ngo.squeezer.itemlist.AlarmView.java

private View getAdapterView(View convertView, final ViewGroup parent) {
    AlarmViewHolder currentViewHolder = (convertView != null && convertView.getTag() instanceof AlarmViewHolder)
            ? (AlarmViewHolder) convertView.getTag()
            : null;/*from ww  w  . j ava  2s.  c o m*/

    if (currentViewHolder == null) {
        convertView = getLayoutInflater().inflate(R.layout.list_item_alarm, parent, false);
        final View alarmView = convertView;
        final AlarmViewHolder viewHolder = new AlarmViewHolder();
        viewHolder.is24HourFormat = DateFormat.is24HourFormat(getActivity());
        viewHolder.timeFormat = viewHolder.is24HourFormat ? "%02d:%02d" : "%d:%02d";
        String[] amPmStrings = new DateFormatSymbols().getAmPmStrings();
        viewHolder.am = amPmStrings[0];
        viewHolder.pm = amPmStrings[1];
        viewHolder.time = (TextView) convertView.findViewById(R.id.time);
        viewHolder.amPm = (TextView) convertView.findViewById(R.id.am_pm);
        viewHolder.amPm.setVisibility(viewHolder.is24HourFormat ? View.GONE : View.VISIBLE);
        viewHolder.enabled = new CompoundButtonWrapper((CompoundButton) convertView.findViewById(R.id.enabled));
        viewHolder.enabled.setOncheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
                if (getActivity().getService() != null) {
                    viewHolder.alarm.setEnabled(b);
                    getActivity().getService().alarmEnable(viewHolder.alarm.getId(), b);
                }
            }
        });
        viewHolder.repeat = new CompoundButtonWrapper((CompoundButton) convertView.findViewById(R.id.repeat));
        viewHolder.repeat.setOncheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
                if (getActivity().getService() != null) {
                    viewHolder.alarm.setRepeat(b);
                    getActivity().getService().alarmRepeat(viewHolder.alarm.getId(), b);
                    viewHolder.dowHolder.setVisibility(b ? View.VISIBLE : View.GONE);
                }
            }
        });
        viewHolder.repeat.getButton().setText(ServerString.ALARM_ALARM_REPEAT.getLocalizedString());
        viewHolder.delete = (ImageView) convertView.findViewById(R.id.delete);
        viewHolder.playlist = (Spinner) convertView.findViewById(R.id.playlist);
        viewHolder.dowHolder = (LinearLayout) convertView.findViewById(R.id.dow);
        for (int day = 0; day < 7; day++) {
            ViewGroup dowButton = (ViewGroup) viewHolder.dowHolder.getChildAt(day);
            final int finalDay = day;
            dowButton.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    if (getActivity().getService() != null) {
                        final Alarm alarm = viewHolder.alarm;
                        boolean wasChecked = alarm.isDayActive(finalDay);
                        if (wasChecked) {
                            alarm.clearDay(finalDay);
                            getActivity().getService().alarmRemoveDay(alarm.getId(), finalDay);
                        } else {
                            alarm.setDay(finalDay);
                            getActivity().getService().alarmAddDay(alarm.getId(), finalDay);
                        }
                        setDowText(viewHolder, finalDay);
                    }
                }
            });
            viewHolder.dowTexts[day] = (TextView) dowButton.getChildAt(0);
        }
        viewHolder.delete.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(final View view) {
                final AnimationSet animationSet = new AnimationSet(true);
                animationSet.addAnimation(new ScaleAnimation(1F, 1F, 1F, 0.5F));
                animationSet.addAnimation(new AlphaAnimation(1F, 0F));
                animationSet.setDuration(ANIMATION_DURATION);
                animationSet.setAnimationListener(new AnimationEndListener() {
                    @Override
                    public void onAnimationEnd(Animation animation) {
                        mActivity.getItemAdapter().removeItem(viewHolder.position);
                        UndoBarController.show(getActivity(), ServerString.ALARM_DELETING.getLocalizedString(),
                                new UndoListener(viewHolder.position, viewHolder.alarm));
                    }
                });

                alarmView.startAnimation(animationSet);
            }
        });
        viewHolder.playlist.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
            @Override
            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
                final AlarmPlaylist selectedAlarmPlaylist = mAlarmPlaylists.get(position);
                final Alarm alarm = viewHolder.alarm;
                if (getActivity().getService() != null && selectedAlarmPlaylist.getId() != null
                        && !selectedAlarmPlaylist.getId().equals(alarm.getUrl())) {
                    alarm.setUrl(selectedAlarmPlaylist.getId());
                    getActivity().getService().alarmSetPlaylist(alarm.getId(), selectedAlarmPlaylist);
                }
            }

            @Override
            public void onNothingSelected(AdapterView<?> parent) {
            }
        });

        convertView.setTag(viewHolder);
    }

    return convertView;
}

From source file:enterprayz.megatools.Tools.java

public static void replace(View source, int xTo, int yTo, float xScale, float yScale) {
    AnimationSet replaceAnimation = new AnimationSet(false);
    replaceAnimation.setFillAfter(true);

    ScaleAnimation scale = new ScaleAnimation(1.0f, xScale, 1.0f, yScale);
    scale.setDuration(1000);/*from ww w  .  j  a  v  a2s .c  o  m*/

    TranslateAnimation trans = new TranslateAnimation(0, 0, TranslateAnimation.ABSOLUTE, xTo - source.getLeft(),
            0, 0, TranslateAnimation.ABSOLUTE, yTo - source.getTop());
    trans.setDuration(1000);

    replaceAnimation.addAnimation(scale);
    replaceAnimation.addAnimation(trans);

    source.startAnimation(replaceAnimation);
}

From source file:com.juick.android.MainActivity.java

public void openNavigationMenu(boolean animate) {
    if (isNavigationMenuShown())
        return;//from   www .j a  v  a  2  s  .  co m
    navigationMenuShown = true;
    final ViewGroup navigationPanel = (ViewGroup) findViewById(R.id.navigation_panel);
    navigationPanel.setVisibility(View.VISIBLE);
    final View frag = (ViewGroup) findViewById(R.id.messagesfragment);
    if (animate) {
        AnimationSet set = new AnimationSet(true);
        TranslateAnimation translate = new TranslateAnimation(0, navigationPanel.getWidth(), 0, 0);
        translate.setFillAfter(false);
        translate.setFillEnabled(true);
        translate.setDuration(400);
        set.addAnimation(translate);
        set.setAnimationListener(new Animation.AnimationListener() {
            @Override
            public void onAnimationStart(Animation animation) {
                //To change body of implemented methods use File | Settings | File Templates.
            }

            @Override
            public void onAnimationEnd(Animation animation) {
                frag.clearAnimation();
                layoutNavigationPane();
            }

            @Override
            public void onAnimationRepeat(Animation animation) {
                //To change body of implemented methods use File | Settings | File Templates.
            }
        });
        frag.startAnimation(set);
    } else {
        layoutNavigationPane();
    }
}

From source file:com.cachirulop.moneybox.fragment.MoneyboxFragment.java

/**
 * Create dynamically an android animation for a coin or a bill getting from
 * the moneybox.//  w ww  .j ava 2 s  . c o m
 * 
 * @param img
 *            ImageView to receive the animation
 * @param layout
 *            Layout that paint the image
 * @return Set of animations to apply to the image
 */
private AnimationSet createGetAnimation(ImageView img, View layout) {
    AnimationSet result;

    result = new AnimationSet(false);
    result.setFillAfter(true);

    // get
    TranslateAnimation get;
    int bottom;

    bottom = Math.abs(layout.getHeight() - img.getLayoutParams().height);
    get = new TranslateAnimation(1.0f, 1.0f, bottom, 1.0f);
    get.setDuration(1500);
    result.addAnimation(get);

    // Fade out
    AlphaAnimation fadeOut;

    fadeOut = new AlphaAnimation(1.0f, 0.0f);
    fadeOut.setDuration(300);
    fadeOut.setStartOffset(1500);

    result.addAnimation(fadeOut);

    return result;
}

From source file:com.chinabike.plugins.mip.activity.LocalAlbumDetail.java

private void showViewPager(int index) {
    pagerContainer.setVisibility(View.VISIBLE);
    gridView.setVisibility(View.GONE);
    findViewById(FakeR.getId(this, "id", "album_title_bar")).setVisibility(View.GONE);
    viewpager.setAdapter(viewpager.new LocalViewPagerAdapter(currentFolder));
    viewpager.setCurrentItem(index);//w w  w .  j  a v  a 2s. co m
    mCountView.setText((index + 1) + "/" + currentFolder.size());
    //?
    if (index == 0) {
        checkBox.setTag(currentFolder.get(index));
        checkBox.setChecked(checkedItems.contains(currentFolder.get(index)));
    }
    AnimationSet set = new AnimationSet(true);
    ScaleAnimation scaleAnimation = new ScaleAnimation((float) 0.9, 1, (float) 0.9, 1,
            pagerContainer.getWidth() / 2, pagerContainer.getHeight() / 2);
    scaleAnimation.setDuration(300);
    set.addAnimation(scaleAnimation);
    AlphaAnimation alphaAnimation = new AlphaAnimation((float) 0.1, 1);
    alphaAnimation.setDuration(200);
    set.addAnimation(alphaAnimation);
    pagerContainer.startAnimation(set);
}

From source file:com.tr4android.support.extension.widget.LabelView.java

private static Animation createAnimationSet(float fromAlpha, float toAlpha, int fromXDelta, int toXDelta) {
    AnimationSet anim = new AnimationSet(true);
    anim.addAnimation(new AlphaAnimation(fromAlpha, toAlpha));
    anim.addAnimation(new TranslateAnimation(fromXDelta, toXDelta, 0, 0));
    return anim;/*from   w ww.  j a  v a  2  s.  c  o  m*/
}