Example usage for android.view.animation AnimationUtils loadAnimation

List of usage examples for android.view.animation AnimationUtils loadAnimation

Introduction

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

Prototype

public static Animation loadAnimation(Context context, @AnimRes int id) throws NotFoundException 

Source Link

Document

Loads an Animation object from a resource

Usage

From source file:au.org.intersect.faims.android.ui.activity.ShowModuleActivity.java

@Override
protected void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
    setContentView(R.layout.activity_show_module);

    // inject faimsClient and serverDiscovery
    RoboGuice.getBaseApplicationInjector(this.getApplication()).injectMembers(this);

    // initialize server discovery
    serverDiscovery.setApplication(getApplication());

    // Need to register license for the map view before create an instance of map view
    CustomMapView.registerLicense(getApplicationContext());

    this.activityData = new ShowModuleActivityData();

    rotation = AnimationUtils.loadAnimation(this, R.anim.clockwise);
    rotation.setRepeatCount(Animation.INFINITE);

    LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    syncAnimImage = (ImageView) inflater.inflate(R.layout.rotate, null);

    setupSync();//from   w  w  w .j  av a2  s.c  o  m
    setupWifiBroadcast();
    setupModule();
    setProgressBarIndeterminateVisibility(false);

    // set file browser to reset last location when activity is created
    DisplayPrefs.setLastLocation(ShowModuleActivity.this, getModuleDir());

    busyDialog = new BusyDialog(this, getString(R.string.load_module_title),
            getString(R.string.load_module_message), null);
    busyDialog.show();

    new AsyncTask<Void, Void, Void>() {

        @Override
        protected void onPostExecute(Void result) {
            renderUI(savedInstanceState);
            busyDialog.dismiss();
        }

        @Override
        protected Void doInBackground(Void... params) {
            preRenderUI();
            return null;
        };

    }.execute();
}

From source file:com.contralabs.inmap.activities.MainActivity.java

private void returnToCategoryList() {
    isShowingStoreList = false;/*from  ww  w.j av  a2 s .c o  m*/
    mLayoutCategoryList.setVisibility(View.VISIBLE);
    mLayoutCategoryList.startAnimation(AnimationUtils.loadAnimation(this, R.anim.to_down_from__100_to_0));
    mLayoutStoreList.startAnimation(AnimationUtils.loadAnimation(this, R.anim.to_down_100));
}

From source file:com.rnd.snapsplit.view.OcrCaptureFragment.java

private void createNewThread() {
    t = new Thread() {

        @Override/*from   www .  j a  v a 2  s  .c  om*/
        public void run() {
            try {
                while (shouldContinue) {
                    Thread.sleep(1);

                    if (getActivity() == null) {
                        return;
                    }
                    getActivity().runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            if (mGraphicOverlay.amountItem != null) {
                                final ImageView upArrow = (ImageView) getView().findViewById(R.id.arrow_up);
                                upArrow.animate().rotation(180).setDuration(500).start();
                                rotationAngle = 180;
                                TextView amountTV = (TextView) getView().findViewById(R.id.text_amount_value);
                                String amount = mGraphicOverlay.amountItem.getTextBlock().getValue();
                                amount = amount.replaceAll("\\s+", "");
                                amount = amount.replaceAll("[$]", "");
                                amountTV.setText(amount);
                                RelativeLayout box = (RelativeLayout) getView()
                                        .findViewById(R.id.recognition_box);
                                box.setVisibility(View.VISIBLE);
                                Animation slide_up = AnimationUtils
                                        .loadAnimation(getActivity().getApplicationContext(), R.anim.slide_up);

                                box.startAnimation(slide_up);
                                onPause();
                                t.interrupt();

                            }
                        }
                    });
                }
            } catch (InterruptedException e) {
            }
        }
    };
}

From source file:apps.junkuvo.alertapptowalksafely.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Fabric.with(this, new Crashlytics());

    ActionBar actionbar = getSupportActionBar();
    if (actionbar != null) {
        actionbar.show();//from ww  w.jav  a  2 s . c om
    }
    // ????APK???????BG???onCreate??Activity??
    // Intent??????????????
    if ((getIntent().getFlags() & Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT) != 0) {
        finish();
        return;
    }

    if (!isRunningJunit) {
        setContentView(R.layout.activity_main);

        FirebaseRemoteConfigUtil.initialize();

        LikeView likeView = (LikeView) findViewById(R.id.like_view);
        likeView.setObjectIdAndType(String.format(getString(R.string.app_googlePlay_url), getPackageName()),
                LikeView.ObjectType.PAGE);

        // Create the interstitial.
        mInterstitialAd = new InterstitialAd(this);
        mInterstitialAd.setAdUnitId(getString(R.string.ad_mob_id));

        // Create ad request.
        final AdRequest adRequest = new AdRequest.Builder().addTestDevice(AdRequest.DEVICE_ID_EMULATOR) // All emulators
                .addTestDevice("1BEC3806A9717F2A87F4D1FC2039D5F2") // An device ID ASUS
                .addTestDevice("64D37FCE47B679A7F4639D180EC4C547").build();

        // Begin loading your interstitial.
        mInterstitialAd.loadAd(adRequest);
        mInterstitialAd.setAdListener(new AdListener() {
            @Override
            public void onAdLeftApplication() {
                super.onAdLeftApplication();
                enableNewFunction = true;
                supportInvalidateOptionsMenu();
            }

            @Override
            public void onAdClosed() {
                super.onAdClosed();
                // ?????????????
                if (!enableNewFunction) {
                    // Begin loading your interstitial.
                    mInterstitialAd.loadAd(adRequest);
                } else {
                    LayoutInflater inflater = LayoutInflater.from(MainActivity.this);
                    final View layout = inflater.inflate(R.layout.new_function_dialog,
                            (ViewGroup) findViewById(R.id.layout_root_new));
                    new MaterialStyledDialog(MainActivity.this).setTitle("?").setDescription(
                            "????????\n???????????")
                            .setCustomView(layout).setIcon(R.drawable.ic_fiber_new_white_48dp)
                            .setHeaderDrawable(R.drawable.pattern_bg_blue)
                            .setPositive(getString(R.string.ok), null).show();

                    RealmUtil.insertHistoryItemAsync(realm, createHistoryItemData(),
                            new RealmUtil.realmTransactionCallbackListener() {
                                @Override
                                public void OnSuccess() {

                                }

                                @Override
                                public void OnError() {

                                }
                            });
                }
            }
        });

        // FIXME : ??????
        AdView mAdView = (AdView) findViewById(R.id.adView);
        //            mAdView.loadAd(adRequest);

        DefaultLayoutPromptView promptView = (DefaultLayoutPromptView) findViewById(R.id.prompt_view);

        final BasePromptViewConfig basePromptViewConfig = new BasePromptViewConfig.Builder()
                .setUserOpinionQuestionTitle(getString(R.string.prompt_title))
                .setUserOpinionQuestionPositiveButtonLabel(getString(R.string.prompt_btn_yes))
                .setUserOpinionQuestionNegativeButtonLabel(getString(R.string.prompt_btn_no))
                .setPositiveFeedbackQuestionTitle(getString(R.string.prompt_title_feedback))
                .setPositiveFeedbackQuestionPositiveButtonLabel(getString(R.string.prompt_btn_sure))
                .setPositiveFeedbackQuestionNegativeButtonLabel(getString(R.string.prompt_btn_notnow))
                .setCriticalFeedbackQuestionTitle(getString(R.string.prompt_title_feedback_2))
                .setCriticalFeedbackQuestionNegativeButtonLabel(getString(R.string.prompt_btn_notnow))
                .setCriticalFeedbackQuestionPositiveButtonLabel(getString(R.string.prompt_btn_sure))
                .setThanksTitle(getString(R.string.prompt_thanks)).build();

        promptView.applyBaseConfig(basePromptViewConfig);
        Amplify.getSharedInstance().promptIfReady(promptView);

        mAnimationBlink = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.blink);

        int buttonColor = ContextCompat.getColor(this, R.color.colorPrimary);
        int buttonPressedColor = ContextCompat.getColor(this, R.color.colorPrimaryDark);
        mbtnStart = (ActionButton) findViewById(R.id.fabStart);
        mbtnStart.setButtonColor(buttonColor);
        mbtnStart.setButtonColorPressed(buttonPressedColor);

        // ?
        new MaterialIntroView.Builder(this).enableDotAnimation(false).enableIcon(true)
                .setFocusGravity(FocusGravity.CENTER).setFocusType(Focus.MINIMUM).setDelayMillis(500)
                .enableFadeAnimation(true).performClick(true).setInfoText(getString(R.string.intro_description))
                .setTarget(mbtnStart).setUsageId(TUTORIAL_ID) //THIS SHOULD BE UNIQUE ID
                .dismissOnTouch(true).show();

        mbtnStart.setOnClickListener(this);

        Intent mAlertServiceIntent = new Intent(MainActivity.this, AlertService.class);

        // ?????????????(???????)
        // ????????
        if (!Utility.isTabletNotPhone(this)) {
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        }
        mTwitter = TwitterUtility.getTwitterInstance(this);
        mCallbackURL = getString(R.string.twitter_callback_url);

        mPlusOneButton = (PlusOneButton) findViewById(R.id.plus_one_button);
        // Refresh the state of the +1 button each time the activity receives focus.
        mPlusOneButton.initialize(
                String.format(getString(R.string.app_googlePlay_url_plusOne), getPackageName()),
                PLUS_ONE_REQUEST_CODE);

        RelativeLayout relativeLayout = (RelativeLayout) findViewById(R.id.rtlMain);
        relativeLayout.setOnClickListener(this);

        findViewById(R.id.llStepCount).setVisibility(mShouldShowPedometer ? View.VISIBLE : View.INVISIBLE);

        //        // Service?????Activity?Destroy????Activity??????
        //        // UI?Service????????Service??????????Bind????????
        //        // Application????
        //        if (((AlertApplication) getApplication()).IsRunningService()) {
        //            btnIsStarted = false;
        //            setStartButtonFunction(findViewById(R.id.fabStart));
        //        }
        // 
        //            startService(mAlertServiceIntent);
        bindService(mAlertServiceIntent, mConnection, Context.BIND_AUTO_CREATE);

    }

    mIsToastOn = SharedPreferencesUtil.getBoolean(this, SETTING_SHAREDPREF_NAME, "message", true);
    mIsVibrationOn = SharedPreferencesUtil.getBoolean(this, SETTING_SHAREDPREF_NAME, "vibrate", true);
    mToastPosition = SharedPreferencesUtil.getInt(this, SETTING_SHAREDPREF_NAME, "toastPosition",
            Gravity.CENTER);
    mAlertStartAngle = SharedPreferencesUtil.getInt(this, SETTING_SHAREDPREF_NAME, "progress",
            ALERT_ANGLE_INITIAL_VALUE) + ALERT_ANGLE_INITIAL_OFFSET;
    mShouldShowPedometer = SharedPreferencesUtil.getBoolean(this, SETTING_SHAREDPREF_NAME, "pedometer", true);

    // ?????(update??) or ???
    enableNewFunction = RealmUtil.hasHistoryItem(realm) || SharedPreferencesUtil.getBoolean(this,
            AD_STATUS_SHAREDPREF_NAME, "AD_STATUS_SHAREDPREF_NAME", false);

}

From source file:com.dirkgassen.wator.ui.activity.MainActivity.java

/**
 * Shows the "new world" fragment if it was hidden.
 * @return {@code true} if the fragment was not visible; {@code false} otherwise
 *///from   ww w  . j  a  v  a 2 s  . c om
synchronized private boolean showNewWorldFragment() {
    if (newWorldView.getVisibility() == View.GONE) {
        FragmentManager fm = getSupportFragmentManager();
        FragmentTransaction ft = fm.beginTransaction();
        Fragment newWorldFragment = new NewWorld();
        ft.add(R.id.new_world_fragment_container, newWorldFragment, NEW_WORLD_FRAGMENT_TAG);
        ft.commit();
        fm.executePendingTransactions();
        newWorldView.startAnimation(AnimationUtils.loadAnimation(this, R.anim.slide_in_down));
        newWorldView.setVisibility(View.VISIBLE);
        return true;
    }
    return false;
}

From source file:com.scoreflex.ScoreflexView.java

public void startOpeningAnimation() {
    int gravity = getLayoutGravity();
    int anim = (Gravity.TOP == (gravity & Gravity.VERTICAL_GRAVITY_MASK)) ? R.anim.scoreflex_enter_slide_down
            : R.anim.scoreflex_enter_slide_up;
    Animation animation = AnimationUtils.loadAnimation(mParentActivity, anim);
    this.startAnimation(animation);
}

From source file:com.oginotihiro.snackbar.Snackbar.java

private void animateViewIn() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        ViewPropertyAnimatorCompat vpac = ViewCompat.animate(mView);

        if (mDirection == LEFT_RIGHT) {
            ViewCompat.setTranslationX(mView, -mView.getWidth());
            vpac.translationX(0f);/* www.jav a 2  s . c  o m*/
        } else if (mDirection == TOP_BOTTOM) {
            ViewCompat.setTranslationY(mView, -mView.getHeight());
            vpac.translationY(0f);
        } else if (mDirection == RIGHT_LEFT) {
            ViewCompat.setTranslationX(mView, mView.getWidth());
            vpac.translationX(0f);
        } else if (mDirection == BOTTOM_TOP) {
            ViewCompat.setTranslationY(mView, mView.getHeight());
            vpac.translationY(0f);
        }

        vpac.setInterpolator(new FastOutSlowInInterpolator()).setDuration(mAnimDuration)
                .setListener(new ViewPropertyAnimatorListenerAdapter() {
                    @Override
                    public void onAnimationStart(View view) {
                        mView.animateChildrenIn(mAnimDuration - mAnimFadeDuration, mAnimFadeDuration);
                    }

                    @Override
                    public void onAnimationEnd(View view) {
                        if (mCallback != null) {
                            mCallback.onShow(Snackbar.this);
                        }
                        SnackbarManager.getInstance().onShown(mManagerCallback);
                    }
                }).start();
    } else {
        Animation anim = null;

        if (mDirection == LEFT_RIGHT) {
            anim = AnimationUtils.loadAnimation(mView.getContext(), R.anim.oginotihiro_snackbar_left_in);
        } else if (mDirection == TOP_BOTTOM) {
            anim = AnimationUtils.loadAnimation(mView.getContext(), R.anim.oginotihiro_snackbar_top_in);
        } else if (mDirection == RIGHT_LEFT) {
            anim = AnimationUtils.loadAnimation(mView.getContext(), R.anim.oginotihiro_snackbar_right_in);
        } else if (mDirection == BOTTOM_TOP) {
            anim = AnimationUtils.loadAnimation(mView.getContext(), R.anim.oginotihiro_snackbar_bottom_in);
        }

        if (anim == null)
            return;

        anim.setInterpolator(new FastOutSlowInInterpolator());
        anim.setDuration(mAnimDuration);
        anim.setAnimationListener(new Animation.AnimationListener() {
            @Override
            public void onAnimationStart(Animation animation) {
            }

            @Override
            public void onAnimationEnd(Animation animation) {
                if (mCallback != null) {
                    mCallback.onShow(Snackbar.this);
                }
                SnackbarManager.getInstance().onShown(mManagerCallback);
            }

            @Override
            public void onAnimationRepeat(Animation animation) {
            }
        });
        mView.setAnimation(anim);
    }
}

From source file:com.pursuer.reader.easyrss.VerticalSingleItemView.java

@Override
public void onScrollChanged(final View view, final int x, final int y, final int oldx, final int oldy) {
    if (y + view.getHeight() > nextItemView.getTop() + 5) {
        itemViewCtrl.hideItemMenu();//from  w w  w.ja v a 2s . c  om
    } else {
        itemViewCtrl.awakenItemMenu();
    }
    if (lastUid != null) {
        final boolean shouldShowTop = (y < lastItemView.getTop() + 50);
        if (!showTop && shouldShowTop) {
            final Animation anim = AnimationUtils.loadAnimation(context, R.anim.up_arrow_anim_rev);
            final View img = lastItemView.findViewById(R.id.LastItemArrow);
            anim.setFillEnabled(true);
            anim.setFillAfter(true);
            img.startAnimation(anim);
            showTop = true;
        } else if (showTop && !shouldShowTop) {
            final Animation anim = AnimationUtils.loadAnimation(context, R.anim.up_arrow_anim);
            final View img = lastItemView.findViewById(R.id.LastItemArrow);
            anim.setFillEnabled(true);
            anim.setFillAfter(true);
            img.startAnimation(anim);
            showTop = false;
        }
    }
    if (nextUid != null) {
        final boolean shouldShowBottom = (y + view.getHeight() > nextItemView.getBottom() - 50);
        if (!showBottom && shouldShowBottom) {
            final Animation anim = AnimationUtils.loadAnimation(context, R.anim.down_arrow_anim_rev);
            final View img = nextItemView.findViewById(R.id.NextItemArrow);
            anim.setFillEnabled(true);
            anim.setFillAfter(true);
            img.startAnimation(anim);
            showBottom = true;
        } else if (showBottom && !shouldShowBottom) {
            final Animation anim = AnimationUtils.loadAnimation(context, R.anim.down_arrow_anim);
            final View img = nextItemView.findViewById(R.id.NextItemArrow);
            anim.setFillEnabled(true);
            anim.setFillAfter(true);
            img.startAnimation(anim);
            showBottom = false;
        }
    }
}

From source file:com.example.ffmpegtest.HWRecorderActivity.java

public void stopRecording() {
    if (!recording)
        return;/*from  www. j a v a  2s  .co m*/

    Log.i(TAG, "Stopped recording");

    liveRecorder.stopRecording();
    button.setText("Start Recording");
    liveIndicator.startAnimation(AnimationUtils.loadAnimation(this, R.anim.slide_to_left));

    recording = false;
}

From source file:com.dirkgassen.wator.ui.activity.MainActivity.java

/**
 * Hides the "new world" fragment if it was showing.
 * @return {@code true} if the fragment was visible; {@code false} otherwise
 *//*from   w  w  w  .java  2s.co m*/
synchronized private boolean hideNewWorldFragment() {
    if (newWorldView.getVisibility() != View.GONE) {
        Animation animation = AnimationUtils.loadAnimation(this, R.anim.slide_out_up);
        animation.setAnimationListener(new Animation.AnimationListener() {
            @Override
            public void onAnimationStart(Animation animation) {
                // Nothing to do here
            }

            @Override
            public void onAnimationEnd(Animation animation) {
                FragmentManager fm = getSupportFragmentManager();
                Fragment fragment = fm.findFragmentByTag(NEW_WORLD_FRAGMENT_TAG);
                FragmentTransaction ft = fm.beginTransaction();
                ft.remove(fragment);
                ft.commit();
            }

            @Override
            public void onAnimationRepeat(Animation animation) {
                // Nothing to do here
            }
        });
        newWorldView.startAnimation(animation);
        newWorldView.setVisibility(View.GONE);

        View viewWithFocus = getCurrentFocus();
        if (viewWithFocus != null) {
            InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(viewWithFocus.getWindowToken(), 0);
        }
        return true;
    }
    return false;
}