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:com.example.demo_highlights.slidingmenu.fragment.PageFragment1.java

private LayoutAnimationController getListAnim() {
    AnimationSet set = new AnimationSet(true);
    Animation animation = new AlphaAnimation(0.0f, 1.0f);
    animation.setDuration(200);//www  .ja va 2s. com
    set.addAnimation(animation);

    animation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f,
            Animation.RELATIVE_TO_SELF, -1.0f, Animation.RELATIVE_TO_SELF, 0.0f);
    animation.setDuration(200);
    set.addAnimation(animation);

    Animation inAnimation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, -1.0f,
            Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF,
            0.0f);
    inAnimation.setDuration(200);
    inAnimation.setFillAfter(true);
    set.addAnimation(inAnimation);

    Animation outAnimation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0.0f,
            Animation.RELATIVE_TO_SELF, 1.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF,
            0.0f);
    outAnimation.setDuration(200);
    outAnimation.setFillAfter(true);
    // 
    LayoutAnimationController inController = new LayoutAnimationController(inAnimation, 0.3f);
    // 
    LayoutAnimationController outController = new LayoutAnimationController(outAnimation, 0.3f);

    LayoutAnimationController controller = new LayoutAnimationController(set, 0.5f);
    return controller;
}

From source file:townley.stuart.app.android.trekkinly.DisplayGPS.java

@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
        @Nullable Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.gps_layout, container, false);

    gps_data = new GPS_Data(getActivity());
    db = new DataBaseHelper(getActivity());
    db.getWritableDatabase();//from   www.j a  v  a2 s. co  m
    db.getGPS(gps_data);
    db.upDateDataBaseGPS(gps_data);

    final TextView textView_lat = (TextView) rootView.findViewById(R.id.gps_latitude_data);
    final TextView textView_long = (TextView) rootView.findViewById(R.id.gps_longitude_data);

    String latitude = db.rowone;
    String longitude = db.rowtwo;

    if (latitude == null && longitude == null) {
        textView_lat.setText("No information is present");
        textView_long.setText("No information is present");
    } else {
        textView_lat.setText("" + latitude);
        textView_long.setText("" + longitude);

    }
    final ImageButton imageButton = (ImageButton) rootView.findViewById(R.id.refresh_gps);
    imageButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            AlphaAnimation animation1 = new AlphaAnimation(0.2f, 1.0f);
            animation1.setDuration(500);
            imageButton.startAnimation(animation1);

            if (gps_data.locationObtainable()) {

                db.addGPS(gps_data);
                db.getGPS(gps_data);
                db.upDateDataBaseGPS(gps_data);

                textView_lat.setText("" + db.rowone);
                textView_long.setText("" + db.rowtwo);

                Log.w("GPS DATA Latitude is", "" + gps_data.lat);
                Log.w("GPS DATA Longitude is", "" + gps_data.longi);

                gps_data.stopUsingGPS();

            }

            else {

                gps_data.SettingsAlertDialog();

            }
        }
    });

    return rootView;
}

From source file:com.shizhefei.view.coolrefreshview.header.JellyHeader.java

public JellyHeader(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    setWillNotDraw(false);/*  w  w w. j a v  a 2s  .  com*/

    defaultMinHeight = Utils.dipToPix(context, 208);

    mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mPaint.setStyle(Paint.Style.FILL);

    mPath = new Path();

    showLoadingAnimation = new AlphaAnimation(0, 1);
    showLoadingAnimation.setDuration(300);
    showLoadingAnimation.setInterpolator(new AccelerateInterpolator());

    hideLoadingAnimation = new AlphaAnimation(1, 0);
    hideLoadingAnimation.setDuration(300);
    hideLoadingAnimation.setInterpolator(new DecelerateInterpolator());

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        mViewOutlineProvider = new ViewOutlineProvider() {
            @TargetApi(Build.VERSION_CODES.LOLLIPOP)
            @Override
            public void getOutline(View view, Outline outline) {
                if (mPath.isConvex())
                    outline.setConvexPath(mPath);
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) {
                    outline.offset(0, totalDistance() - currentDistance);
                }
            }
        };
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            setElevation(Utils.dipToPix(context, 4));
        }
    }
}

From source file:townley.stuart.app.android.trekkinly.Notification_picker_class.java

@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
        @Nullable Bundle savedInstanceState) {
    final View rootView = inflater.inflate(R.layout.notification_layout, container, false);

    final Button button = (Button) rootView.findViewById(R.id.Button);
    final Button button2 = (Button) rootView.findViewById(R.id.Button2);
    final Button button3 = (Button) rootView.findViewById(R.id.Button3);

    button.setOnClickListener(new View.OnClickListener() {
        @Override/*from w w  w . ja  va  2s . c  o m*/
        public void onClick(View v) {
            showTimePickerDialog(v);
            AlphaAnimation animation1 = new AlphaAnimation(0.2f, 1.0f);
            animation1.setDuration(500);
            button.startAnimation(animation1);

        }
    });

    button2.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            showDatePickerDialog(v);
            AlphaAnimation animation1 = new AlphaAnimation(0.2f, 1.0f);
            animation1.setDuration(500);
            button2.startAnimation(animation1);
        }
    });

    button3.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            setNotification();
            AlphaAnimation animation1 = new AlphaAnimation(0.2f, 1.0f);
            animation1.setDuration(500);
            button3.startAnimation(animation1);
        }
    });

    button3.setOnLongClickListener(new View.OnLongClickListener() {
        @Override
        public boolean onLongClick(View v) {
            ComponentName receiver = new ComponentName(getActivity(), AlertClass.class);
            PackageManager pm = getActivity().getPackageManager();
            pm.setComponentEnabledSetting(receiver, PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
                    PackageManager.DONT_KILL_APP);

            Intent intent = new Intent(getActivity(), AlertClass.class);
            AlarmManager alarmManager = (AlarmManager) getActivity().getSystemService(Context.ALARM_SERVICE);
            alarmManager.cancel(PendingIntent.getBroadcast(getActivity().getApplicationContext(), 1, intent,
                    PendingIntent.FLAG_UPDATE_CURRENT));
            Toast.makeText(getActivity(), "Notification reset!", Toast.LENGTH_SHORT).show();

            AlphaAnimation animation1 = new AlphaAnimation(0.2f, 1.0f);
            animation1.setDuration(500);
            button3.startAnimation(animation1);

            //It would not let me assign void so I
            return true;
        }
    });

    return rootView;
}

From source file:org.ohmage.prompts.SurveyItemFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    ViewGroup view = (ViewGroup) inflater.inflate(R.layout.prompt_basic, container, false);
    ((TextView) view.findViewById(R.id.text)).setText(getPromptText());
    mButtons = view.findViewById(R.id.buttons);
    skipButton = (TextView) view.findViewById(R.id.skip);
    okButton = (TextView) view.findViewById(R.id.ok);

    okButton.setOnClickListener(new OnClickListener() {
        @Override// w  ww  .  j  a va  2  s  .co  m
        public void onClick(View v) {
            mAnswered = true;
            onOkPressed();
        }
    });
    skipButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            mAnswered = true;
            onSkipPressed();
        }
    });

    if (isSkippable()) {
        skipButton.setVisibility(View.VISIBLE);
    } else {
        skipButton.setVisibility(View.GONE);
    }

    if (isAnswered()) {
        mButtons.setVisibility(View.GONE);
    } else {
        updateCanContinue();
    }

    onCreatePromptView(inflater, (ViewGroup) view.findViewById(R.id.content), savedInstanceState);

    // Fade the prompt in
    if (!isAnswered()) {
        AlphaAnimation aa = new AlphaAnimation(0f, 1f);
        aa.setFillAfter(true);
        aa.setDuration(200);
        view.startAnimation(aa);
    }

    return view;
}

From source file:Main.java

public static Animation getFadeOutAnimation(int durationInMilliseconds) {
    Animation fadeOut = new AlphaAnimation(1, 0);
    fadeOut.setFillAfter(true);//w w w  .j a va  2s .  c om
    fadeOut.setInterpolator(new AccelerateInterpolator());
    fadeOut.setDuration(durationInMilliseconds);
    return fadeOut;
}

From source file:eu.thedarken.rootvalidator.ValidatorFragment.java

@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    mRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
    AnimationSet set = new AnimationSet(true);
    Animation fadeIn = new AlphaAnimation(0.0f, 1.0f);
    fadeIn.setDuration(350);//ww  w.  j  a  v a 2s  . c  o m
    set.addAnimation(fadeIn);
    Animation dropDown = new TranslateAnimation(Animation.RELATIVE_TO_SELF, -1.0f, Animation.RELATIVE_TO_SELF,
            0.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f);
    dropDown.setDuration(400);
    set.addAnimation(dropDown);
    LayoutAnimationController controller = new LayoutAnimationController(set, 0.2f);
    mRecyclerView.setLayoutAnimation(controller);

    mFab.attachToRecyclerView(mRecyclerView);
    mFab.setVisibility(View.INVISIBLE);
    mEmptyStartView.setVisibility(View.GONE);
    mEmptyWorkingView.setVisibility(View.GONE);
    mListContainer.addView(mEmptyStartView);
    mListContainer.addView(mEmptyWorkingView);
    mRecyclerView.setEmptyView(mEmptyStartView);
    mRecyclerView.setItemAnimator(new DefaultItemAnimator());
}

From source file:com.bhb27.isu.Main.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    MainContext = this;

    LinearLayout layout = (LinearLayout) findViewById(R.id.MainLayout);
    AlphaAnimation animation = new AlphaAnimation(0.0f, 1.0f);
    animation.setFillAfter(true);//from   ww w  .j a  v a2s . co  m
    animation.setDuration(750);
    layout.startAnimation(animation);

    suVersion = Tools.SuVersion(MainContext);
    isCMSU = SuVersionBool(suVersion);

    Runnable runSepolicy = new Runnable() {
        public void run() {
            Sepolicy();
            // Only run boot service if app was used and is CM SU
            if (isCMSU && !Tools.getBoolean("run_boot", false, MainContext))
                Tools.saveBoolean("run_boot", true, MainContext);
        }
    };
    new Thread(runSepolicy).start();

    suSwitch = (Switch) findViewById(R.id.suSwitch);
    SuSwitchSummary = (TextView) findViewById(R.id.SuSwitchSummary);
    SuStatus = (TextView) findViewById(R.id.SuStatus);
    su_version = (TextView) findViewById(R.id.su_version);
    su_version_summary = (TextView) findViewById(R.id.su_version_summary);
    su_version_summary.setText(suVersion);

    SelinuxSwitch = (Switch) findViewById(R.id.SelinuxSwitch);
    SelinuxStatus = (TextView) findViewById(R.id.SelinuxStatus);
    Selinux_State = (TextView) findViewById(R.id.Selinux_State);
    Selinux_State.setText(Tools.getSELinuxStatus());

    iSuNotification = (Switch) findViewById(R.id.iSuNotification);
    SuSelinuxSwitch = (Switch) findViewById(R.id.SuSelinuxSwitch);
    SuSelinuxSwitchSummary = (TextView) findViewById(R.id.SuSelinuxSwitchSummary);

    per_app = (Button) findViewById(R.id.buttonPer_app);
    per_app_summary = (TextView) findViewById(R.id.per_app);

    download_folder_link = (TextView) findViewById(R.id.download_folder_link);
    kernel_check = (TextView) findViewById(R.id.kernel_check);
    // about button
    about = (Button) findViewById(R.id.buttonAbout);
    about.setOnClickListener(new View.OnClickListener() {
        Intent myIntent = new Intent(getApplicationContext(), AboutActivity.class);

        @Override
        public void onClick(View v) {
            startActivity(myIntent);
        }
    });

    ic_launcher = (ImageView) findViewById(R.id.ic_launcher);
    ic_launcher.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Tools.DoAToast(getString(R.string.isu_by), MainContext);
        }
    });

    //reboot support check
    if (RebootSupport()) {
        kernel_check.setText(getString(R.string.isu_reboot));
        download_folder_link.setVisibility(View.GONE);
    } else if (Tools.KernelSupport()) {
        kernel_check.setText(getString(R.string.isu_kernel_good));
        download_folder_link.setVisibility(View.GONE);
    } else {
        kernel_check.setTextColor(getColorWrapper(MainContext, R.color.colorAccent));
        kernel_check.setText(getString(R.string.isu_kernel_bad));
        download_folder_link.setText(getString(R.string.download_folder_link));
        download_folder_link.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                try {
                    startActivity(new Intent(Intent.ACTION_VIEW,
                            Uri.parse("https://www.androidfilehost.com/?w=files&flid=120360")));
                } catch (ActivityNotFoundException ex) {
                    Tools.DoAToast(getString(R.string.no_browser), MainContext);
                }
            }
        });
    }
    UpdateMain(isCMSU);
}

From source file:com.todoroo.astrid.helper.ProgressBarSyncResultCallback.java

@Override
public void started() {
    if (providers.incrementAndGet() == 1) {
        activity.runOnUiThread(new Runnable() {
            @Override//from   w w w  .  ja  va  2 s  . co m
            public void run() {
                progressBar.setVisibility(View.VISIBLE);
                AlphaAnimation animation = new AlphaAnimation(0, 1);
                animation.setFillAfter(true);
                animation.setDuration(1000L);
                progressBar.startAnimation(animation);
            }
        });
    }
}

From source file:fr.shywim.antoinedaniel.utils.Utils.java

/**
 * First part of the click animation.//from   w  w w  .  j a  v  a  2s . c om
 *
 * @param context Any context.
 * @param v View who will have the effect.
 * @param isRoot Whether the passed view is the ViewGroup parent.
 */
public static void clickAnimDown(Context context, View v, boolean isRoot) {
    RelativeLayout root;
    if (isRoot)
        root = (RelativeLayout) v;
    else
        root = (RelativeLayout) v.getParent();
    final View rectView = new View(context);
    rectView.setId(R.id.rect_view_id);
    rectView.setVisibility(View.GONE);
    rectView.setBackgroundResource(R.drawable.square);
    RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(v.getMeasuredWidth(),
            v.getMeasuredHeight());
    params.addRule(RelativeLayout.ALIGN_TOP, v.getId());
    rectView.setLayoutParams(params);
    AlphaAnimation rectAnim = new AlphaAnimation(0f, 0.4f);
    rectAnim.setFillAfter(true);
    rectAnim.setInterpolator(new AccelerateInterpolator());
    rectAnim.setDuration(150);
    rectAnim.setAnimationListener(new Animation.AnimationListener() {
        @Override
        public void onAnimationStart(Animation animation) {
            rectView.setVisibility(View.VISIBLE);
        }

        @Override
        public void onAnimationEnd(Animation animation) {

        }

        @Override
        public void onAnimationRepeat(Animation animation) {

        }
    });
    root.addView(rectView);
    rectView.startAnimation(rectAnim);
}