Example usage for android.view.animation AlphaAnimation AlphaAnimation

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

Introduction

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

Prototype

public AlphaAnimation(float fromAlpha, float toAlpha) 

Source Link

Document

Constructor to use when building an AlphaAnimation from code

Usage

From source file:org.smssecure.smssecure.util.ViewUtil.java

private static Animation getAlphaAnimation(float from, float to, int duration) {
    final Animation anim = new AlphaAnimation(from, to);
    anim.setInterpolator(new FastOutSlowInInterpolator());
    anim.setDuration(duration);/*  w ww.  j a va  2s .c  om*/
    return anim;
}

From source file:com.numix.calculator.EventListener.java

private void deleteAnimation(View view) {
    final TextView colorLayout = (TextView) view.getRootView().findViewById(R.id.deleteColor);
    final LinearLayout displayView = (LinearLayout) view.getRootView().findViewById(R.id.displayLayout);
    final CalculatorDisplay calculatorDisplay = (CalculatorDisplay) view.getRootView()
            .findViewById(R.id.display);

    int finalRadius = Math.max(displayView.getWidth(), displayView.getHeight());

    // create the animator for this view (the start radius is zero)
    Animator colorAnim;//ww  w . ja  v  a  2 s .c o  m
    colorAnim = ViewAnimationUtils.createCircularReveal(colorLayout, (int) displayView.getRight(),
            (int) displayView.getBottom(), 0, finalRadius);
    final AlphaAnimation fadeAnim = new AlphaAnimation(1.0f, 0.0f);
    final AlphaAnimation fadeDisplay = new AlphaAnimation(1.0f, 0.0f);
    fadeAnim.setDuration(250);
    fadeAnim.setInterpolator(new AccelerateInterpolator());
    fadeAnim.setAnimationListener(new Animation.AnimationListener() {
        @Override
        public void onAnimationStart(Animation animation) {
        }

        @Override
        public void onAnimationEnd(Animation animation) {
            colorLayout.setVisibility(View.GONE);
        }

        @Override
        public void onAnimationRepeat(Animation animation) {

        }
    });

    fadeDisplay.setDuration(250);
    fadeDisplay.setInterpolator(new AccelerateInterpolator());
    fadeDisplay.setAnimationListener(new Animation.AnimationListener() {
        @Override
        public void onAnimationStart(Animation animation) {
        }

        @Override
        public void onAnimationEnd(Animation animation) {
            mHandler.onClear();
            displayView.setAlpha(1.0f);
        }

        @Override
        public void onAnimationRepeat(Animation animation) {

        }
    });

    colorAnim.setInterpolator(new AccelerateInterpolator());
    colorAnim.addListener(new android.animation.Animator.AnimatorListener() {
        @Override
        public void onAnimationStart(android.animation.Animator animation) {
            calculatorDisplay.startAnimation(fadeDisplay);
        }

        @Override
        public void onAnimationRepeat(android.animation.Animator animation) {
        }

        @Override
        public void onAnimationEnd(android.animation.Animator animation) {
            colorLayout.startAnimation(fadeAnim);
        }

        @Override
        public void onAnimationCancel(android.animation.Animator animation) {
        }
    });

    colorLayout.setVisibility(View.VISIBLE);
    colorAnim.start();
}

From source file:com.pepperonas.andbasx.animation.FadeAnimationColored.java

/**
 * Fade out.//from  w  w  w. j  a  va  2  s . co  m
 */
public void fadeOut() {
    this.view.setAlpha(1f);
    Animation anim = new AlphaAnimation(minBrightness, maxBrightness);
    anim.setDuration(duration);
    anim.setStartOffset(startOffset);
    anim.setFillEnabled(true);
    anim.setFillAfter(true);
    view.startAnimation(anim);
}

From source file:com.javierarboleda.visualtilestogether.activities.SignInActivity.java

private void initTutorialView() {
    mPager = (ViewPager) findViewById(R.id.tutorial_view_pager);
    mPager.setAdapter(new TutorialImageAdapter(this));
    TabLayout tabLayout = (TabLayout) findViewById(R.id.tutorial_tab_layout);
    tabLayout.setupWithViewPager(mPager, true);

    mTimer = new Timer();
    mTimer.scheduleAtFixedRate(new RemindTask(), 0, 4000);

    mPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
        @Override/*from  ww w  .j av a2 s .  c om*/
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
            mPage = position;
        }

        @Override
        public void onPageSelected(int position) {

        }

        @Override
        public void onPageScrollStateChanged(int state) {

        }
    });

    Animation animation = new AlphaAnimation(0f, 1f);
    animation.setDuration(1400);
    findViewById(R.id.ivTutorial).startAnimation(animation);
    findViewById(R.id.tutorial_view_pager).startAnimation(animation);
    findViewById(R.id.tutorial_tab_layout).startAnimation(animation);
    findViewById(R.id.view_footer).startAnimation(animation);

    final VideoView videoView = (VideoView) findViewById(R.id.vvTutorialVideo);

    videoView.setVideoURI(Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.video_tutorial_1));

    videoView.requestFocus();

    videoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
        @Override
        public void onPrepared(MediaPlayer mediaPlayer) {
            videoView.seekTo(0);
            videoView.start();
        }
    });

    videoView.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
        @Override
        public void onCompletion(MediaPlayer mediaPlayer) {
            videoView.seekTo(0);
            videoView.start();
        }
    });
}

From source file:com.pepperonas.andbasx.animation.FadeAnimationColored.java

/**
 * Fade in.//from   www . j a v  a  2  s  .co  m
 */
public void fadeIn() {
    Animation anim = new AlphaAnimation(maxBrightness, minBrightness);
    anim.setDuration(duration);
    anim.setStartOffset(startOffset);
    anim.setFillEnabled(true);
    anim.setFillAfter(true);
    view.startAnimation(anim);
}

From source file:ca.frozen.curlingtv.activities.VideoFragment.java

@Override
public void onCreate(Bundle savedInstanceState) {
    // configure the activity
    super.onCreate(savedInstanceState);

    // load the settings and cameras
    Utils.loadData();//  www.j a  v  a  2 s . com

    // get the parameters
    camera = getArguments().getParcelable(CAMERA);
    fullScreen = getArguments().getBoolean(FULL_SCREEN);

    // create the gesture recognizers
    simpleDetector = new GestureDetector(getActivity(), new SimpleListener());
    scaleDetector = new ScaleGestureDetector(getActivity(), new ScaleListener());

    // create the fade in handler and runnable
    fadeInHandler = new Handler();
    fadeInRunner = new Runnable() {
        @Override
        public void run() {
            Animation fadeInName = new AlphaAnimation(0, 1);
            fadeInName.setDuration(FADEIN_ANIMATION_TIME);
            fadeInName.setFillAfter(true);
            Animation fadeInSnapshot = new AlphaAnimation(0, 1);
            fadeInSnapshot.setDuration(FADEIN_ANIMATION_TIME);
            fadeInSnapshot.setFillAfter(true);
            nameView.startAnimation(fadeInName);
            snapshotButton.startAnimation(fadeInSnapshot);
            fadeListener.onStartFadeIn();
        }
    };

    // create the fade out handler and runnable
    fadeOutHandler = new Handler();
    fadeOutRunner = new Runnable() {
        @Override
        public void run() {
            Animation fadeOutName = new AlphaAnimation(1, 0);
            fadeOutName.setDuration(FADEOUT_ANIMATION_TIME);
            fadeOutName.setFillAfter(true);
            Animation fadeOutSnapshot = new AlphaAnimation(1, 0);
            fadeOutSnapshot.setDuration(FADEOUT_ANIMATION_TIME);
            fadeOutSnapshot.setFillAfter(true);
            nameView.startAnimation(fadeOutName);
            snapshotButton.startAnimation(fadeOutSnapshot);
            fadeListener.onStartFadeOut();
        }
    };

    // create the finish handler and runnable
    finishHandler = new Handler();
    finishRunner = new Runnable() {
        @Override
        public void run() {
            getActivity().finish();
        }
    };
}

From source file:com.hookedonplay.decoviewsample.SampleFit2Fragment.java

private void showAvatar(boolean show, View view) {
    AlphaAnimation animation = new AlphaAnimation(show ? 0.0f : 1.0f, show ? 1.0f : 0.0f);
    animation.setDuration(2000);//from www . j av a  2  s.  co m
    animation.setFillAfter(true);
    view.startAnimation(animation);
}

From source file:ca.frozen.rpicameraviewer.activities.VideoFragment.java

@Override
public void onCreate(Bundle savedInstanceState) {
    // configure the activity
    super.onCreate(savedInstanceState);

    // load the settings and cameras
    Utils.loadData();/*from   w ww.ja  v  a 2 s.  c o m*/

    // get the parameters
    camera = getArguments().getParcelable(CAMERA);
    fullScreen = getArguments().getBoolean(FULL_SCREEN);

    // create the fade in handler and runnable
    fadeInHandler = new Handler();
    fadeInRunner = new Runnable() {
        @Override
        public void run() {
            Animation fadeInName = new AlphaAnimation(0, 1);
            fadeInName.setDuration(FADEIN_ANIMATION_TIME);
            fadeInName.setFillAfter(true);
            Animation fadeInSnapshot = new AlphaAnimation(0, 1);
            fadeInSnapshot.setDuration(FADEIN_ANIMATION_TIME);
            fadeInSnapshot.setFillAfter(true);
            nameView.startAnimation(fadeInName);
            snapshotButton.startAnimation(fadeInSnapshot);
            fadeListener.onStartFadeIn();
        }
    };

    // create the fade out handler and runnable
    fadeOutHandler = new Handler();
    fadeOutRunner = new Runnable() {
        @Override
        public void run() {
            Animation fadeOutName = new AlphaAnimation(1, 0);
            fadeOutName.setDuration(FADEOUT_ANIMATION_TIME);
            fadeOutName.setFillAfter(true);
            Animation fadeOutSnapshot = new AlphaAnimation(1, 0);
            fadeOutSnapshot.setDuration(FADEOUT_ANIMATION_TIME);
            fadeOutSnapshot.setFillAfter(true);
            nameView.startAnimation(fadeOutName);
            snapshotButton.startAnimation(fadeOutSnapshot);
            fadeListener.onStartFadeOut();
        }
    };

    // create the finish handler and runnable
    finishHandler = new Handler();
    finishRunner = new Runnable() {
        @Override
        public void run() {
            getActivity().finish();
        }
    };

    // create the start video handler and runnable
    startVideoHandler = new Handler();
    startVideoRunner = new Runnable() {
        @Override
        public void run() {
            MediaFormat format = decoder.getMediaFormat();
            int videoWidth = format.getInteger(MediaFormat.KEY_WIDTH);
            int videoHeight = format.getInteger(MediaFormat.KEY_HEIGHT);
            textureView.setVideoSize(videoWidth, videoHeight);
        }
    };
}

From source file:widgets.Graphical_History.java

@SuppressLint("HandlerLeak")
public Graphical_History(tracerengine Trac, Activity context, int id, int dev_id, String name,
        final String state_key, String url, final String usage, int update, int widgetSize, int session_type,
        final String parameters, int place_id, String place_type, SharedPreferences params) {
    super(context, Trac, id, name, "", usage, widgetSize, session_type, place_id, place_type, mytag, container);
    this.context = context;
    this.Tracer = Trac;
    this.state_key = state_key;
    this.dev_id = dev_id;
    this.id = id;
    this.url = url;
    this.usage = usage;
    this.update = update;
    this.wname = name;
    this.myself = this;
    this.session_type = session_type;
    this.stateS = getResources().getText(R.string.State).toString();
    this.place_id = place_id;
    this.place_type = place_type;
    setOnClickListener(this);

    login = params.getString("http_auth_username", null);
    password = params.getString("http_auth_password", null);

    mytag = "Graphical_History(" + dev_id + ")";

    //state key/*  w  w w  .  j av a 2s.  com*/
    state_key_view = new TextView(context);
    state_key_view.setText(state_key);
    state_key_view.setTextColor(Color.parseColor("#333333"));

    //value
    value = new TextView(context);
    value.setTextSize(28);
    value.setTextColor(Color.BLACK);
    animation = new AlphaAnimation(0.0f, 1.0f);
    animation.setDuration(1000);

    super.LL_featurePan.addView(value);
    super.LL_infoPan.addView(state_key_view);

    handler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            String status;
            if (msg.what == 9999) {
                if (session == null)
                    return;
                status = session.getValue();
                String loc_Value = session.getValue();
                Tracer.d(mytag, "Handler receives a new value <" + loc_Value + ">");
                value.setAnimation(animation);
                value.setText(loc_Value);
                //To have the icon colored as it has no state
                IV_img.setBackgroundResource(Graphics_Manager.Icones_Agent(usage, 2));

            } else if (msg.what == 9998) {
                // state_engine send us a signal to notify it'll die !
                Tracer.d(mytag, "state engine disappeared ===> Harakiri !");
                session = null;
                realtime = false;
                removeView(LL_background);
                myself.setVisibility(GONE);
                if (container != null) {
                    container.removeView(myself);
                    container.recomputeViewAttributes(myself);
                }
                try {
                    finalize();
                } catch (Throwable t) {
                } //kill the handler thread itself
            }

        }

    };
    //================================================================================
    /*
     * New mechanism to be notified by widgetupdate engine when our value is changed
     * 
     */
    WidgetUpdate cache_engine = WidgetUpdate.getInstance();
    if (cache_engine != null) {
        session = new Entity_client(dev_id, state_key, mytag, handler, session_type);
        if (Tracer.get_engine().subscribe(session)) {
            realtime = true; //we're connected to engine
            //each time our value change, the engine will call handler
            handler.sendEmptyMessage(9999); //Force to consider current value in session
        }

    }

    //================================================================================
}

From source file:de.grobox.liberario.ui.LocationInputGPSView.java

public void activateGPS() {
    if (isSearching())
        return;//from  w  w w.j av  a2s .c  o  m

    // check permissions
    if (ContextCompat.checkSelfPermission(context,
            Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
        // we don't have a permission, so store the information that we are requesting it
        request_permission = true;

        // Should we show an explanation?
        if (ActivityCompat.shouldShowRequestPermissionRationale(context,
                Manifest.permission.ACCESS_FINE_LOCATION)) {
            Toast.makeText(context, R.string.permission_denied_gps, Toast.LENGTH_LONG).show();
        } else {
            // No explanation needed, we can request the permission
            ActivityCompat.requestPermissions(context,
                    new String[] { Manifest.permission.ACCESS_FINE_LOCATION }, caller);
        }

        return;
    }

    // we arrive here only once we have got the permission and are not longer requesting it
    request_permission = false;

    List<String> providers = locationManager.getProviders(true);

    for (String provider : providers) {
        // Register the listener with the Location Manager to receive location updates
        locationManager.requestSingleUpdate(provider, this, null);

        Log.d(getClass().getSimpleName(), "Register provider for location updates: " + provider);
    }

    // check if there is a non-passive provider available
    if (providers.size() == 0
            || (providers.size() == 1 && providers.get(0).equals(LocationManager.PASSIVE_PROVIDER))) {

        locationManager.removeUpdates(this);
        Toast.makeText(context, context.getResources().getString(R.string.error_no_location_provider),
                Toast.LENGTH_LONG).show();

        return;
    }

    // clear input
    //noinspection deprecation
    setLocation(null, context.getResources().getDrawable(R.drawable.ic_gps));
    ui.clear.setVisibility(View.VISIBLE);

    // clear current GPS location, because we are looking to find a new one
    gps_location = null;

    // show GPS button blinking
    final Animation animation = new AlphaAnimation(1, 0);
    animation.setDuration(500);
    animation.setInterpolator(new LinearInterpolator());
    animation.setRepeatCount(Animation.INFINITE);
    animation.setRepeatMode(Animation.REVERSE);
    ui.status.setAnimation(animation);

    ui.location.setHint(R.string.stations_searching_position);
    ui.location.clearFocus();

    searching = true;
}