Example usage for android.view View startAnimation

List of usage examples for android.view View startAnimation

Introduction

In this page you can find the example usage for android.view View startAnimation.

Prototype

public void startAnimation(Animation animation) 

Source Link

Document

Start the specified animation now.

Usage

From source file:com.aboveware.common.crouton.Manager.java

/**
 * Removes the {@link Crouton}'s view after it's display
 * durationInMilliseconds./*w  w  w  . j a  v  a2 s  .  com*/
 *
 * @param crouton
 *          The {@link Crouton} added to a {@link ViewGroup} and should be
 *          removed.
 */
private void removeCrouton(Crouton crouton) {
    View croutonView = crouton.getView();
    ViewGroup croutonParentView = (ViewGroup) croutonView.getParent();

    if (croutonParentView != null) {
        croutonView.startAnimation(crouton.getOutAnimation());

        // Remove the Crouton from the queue.
        Crouton removed = croutonQueue.poll();

        // Remove the crouton from the view's parent.
        croutonParentView.removeView(croutonView);
        if (removed != null) {
            removed.detachActivity();
            removed.detachViewGroup();
            if (removed.getLifecycleCallback() != null) {
                removed.getLifecycleCallback().onRemoved();
            }
            removed.detachLifecycleCallback();
        }

        // Send a message to display the next crouton but delay it by the out
        // animation duration to make sure it finishes
        sendMessageDelayed(crouton, Messages.DISPLAY_CROUTON, crouton.getOutAnimation().getDuration());
    }
}

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

/**
 * First part of the click animation./*  w  w w .  j a v  a 2 s.  co  m*/
 *
 * @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);
}

From source file:com.lightplus.MainActivity.java

/**
 * Click event for all light controllers
 *///  w w w . jav a2 s .  c om
public void toggleLight(View v) {
    if (on) {
        turnOff();
        if (v.getId() == R.id.button_black) {
            Animation fadeIn = AnimationUtils.loadAnimation(this, R.anim.fade_in);
            v.startAnimation(fadeIn);
        }
    } else {
        turnOn();
        if (v.getId() == R.id.button_black) {
            Animation fadeOut = AnimationUtils.loadAnimation(this, R.anim.fade_out);
            v.startAnimation(fadeOut);
        }
    }
}

From source file:net.henryco.opalette.application.StartUpActivity.java

private void loadControlViews() {
    findViewById(R.id.firstPickLayout).setVisibility(View.VISIBLE);
    loadAds();//from w ww. j  a  v a  2  s .c  o m
    View text = findViewById(R.id.textView);
    text.setVisibility(View.VISIBLE);
    text.startAnimation(AnimationUtils.loadAnimation(getApplicationContext(), R.anim.fade_in));
    findViewById(R.id.imageButtonGall)
            .startAnimation(AnimationUtils.loadAnimation(getApplicationContext(), R.anim.fade_in));
    text.setOnClickListener(this::imagePickAction);
    findViewById(R.id.imageButtonGall).setVisibility(View.VISIBLE);
    enableButtons();
}

From source file:de.geeksfactory.opacclient.frontend.AccountEditActivity.java

public void setProgress(boolean show, boolean animate) {
    ProgressBar progress = (ProgressBar) findViewById(R.id.progressBar);
    View content = findViewById(R.id.svAccount);

    if (show) {//from w  w w. j a  v  a 2  s .  c o  m
        if (animate) {
            progress.startAnimation(AnimationUtils.loadAnimation(this, android.R.anim.fade_in));
            content.startAnimation(AnimationUtils.loadAnimation(this, android.R.anim.fade_out));
        } else {
            progress.clearAnimation();
            content.clearAnimation();
        }
        progress.setVisibility(View.VISIBLE);
        content.setVisibility(View.GONE);
    } else {
        if (animate) {
            progress.startAnimation(AnimationUtils.loadAnimation(this, android.R.anim.fade_out));
            content.startAnimation(AnimationUtils.loadAnimation(this, android.R.anim.fade_in));
        } else {
            progress.clearAnimation();
            content.clearAnimation();
        }
        progress.setVisibility(View.GONE);
        content.setVisibility(View.VISIBLE);
    }
}

From source file:com.wms.opensource.ezchannel.activity.VideoListFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    if (layout != null) {
        // We need to remove layout from its parent first. Otherwise, adding layout to different viewgroup will result in error 
        ViewGroup parent = (ViewGroup) layout.getParent();
        parent.removeView(layout);//from   w  w w  .  j av  a2 s.co  m
        return layout;
    }

    if (listView == null) {
        layout = new RelativeLayout(getActivity());
        listView = new ListView(getActivity());
        layout.addView(listView);

        imageViewStandardThumbnail = new ImageView(getActivity());
        RelativeLayout.LayoutParams imageViewParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                LayoutParams.WRAP_CONTENT);
        imageViewParams.addRule(RelativeLayout.CENTER_IN_PARENT);
        imageViewStandardThumbnail.setLayoutParams(imageViewParams);
        imageViewStandardThumbnail.setVisibility(View.INVISIBLE);
        imageViewStandardThumbnail.setBackgroundResource(R.drawable.border);
        imageViewStandardThumbnail.setOnClickListener(new ImageView.OnClickListener() {

            @Override
            public void onClick(View v) {
                // Dismiss the image view
                v.setVisibility(View.INVISIBLE);
                Animation myAnim = AnimationUtils.loadAnimation(VideoListFragment.this.getActivity(),
                        R.anim.fadeout);
                v.startAnimation(myAnim);
            }

        });
        layout.addView(imageViewStandardThumbnail);

        progressBar = new ProgressBar(getActivity(), null, android.R.attr.progressBarStyleLarge);

        // Center a view in relative layout
        RelativeLayout.LayoutParams progressBarBarams = new RelativeLayout.LayoutParams(
                LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
        progressBarBarams.addRule(RelativeLayout.CENTER_IN_PARENT);
        progressBar.setLayoutParams(progressBarBarams);
        progressBar.setVisibility(View.INVISIBLE);
        layout.addView(progressBar);

        // Before reloading videos, display videos if they have been saved before.            
        String videosFilePath = "";
        if (VideoListFragmentActivity.videoSource == YouTubeVideoSource.Playlist) {
            videosFilePath = StorageUtil.getTempDirectory(this.getActivity()) + "/"
                    + PersistFileNameProvider.getYouTubePlaylistPersistFileName(playlistID, page);
        } else {
            videosFilePath = StorageUtil.getTempDirectory(this.getActivity()) + "/" + PersistFileNameProvider
                    .getYouTubeSearchListPersistFileName(getActivity().getString(R.string.appID), page);
        }

        boolean videosFileExists = FileUtil.fileExist(videosFilePath);
        if (videosFileExists) {
            loadPlaylistVideosFromLocalTask = new LoadCachedVideosTask(getActivity(), loadVideosHandler,
                    VideoListFragmentActivity.videoSource, progressBar, playlistID, page);
            loadPlaylistVideosFromLocalTask.execute();
        } else {
            NetworkStatus networkStatus = NetworkUtil.getNetworkStatus(getActivity());
            if (networkStatus.equals(NetworkStatus.WIFI_CONNECTED)
                    || networkStatus.equals(NetworkStatus.MOBILE_CONNECTED)) {
                String pageToken = page == 1 ? null : VideoListFragmentActivity.pageTokens.get(page - 1); // page start from 1
                if (VideoListFragmentActivity.videoSource == YouTubeVideoSource.Playlist) {
                    loadVideosTask = new LoadVideosTask(getActivity(), loadVideosHandler,
                            YouTubeVideoSource.Playlist, playlistID, pageToken, page);
                } else {
                    loadVideosTask = new LoadVideosTask(getActivity(), loadVideosHandler,
                            YouTubeVideoSource.Search, queryTerm, pageToken, page);
                }
                loadVideosTask.execute();
            } else {
                Toast.makeText(getActivity(), getString(R.string.noNetworkAvailable), Toast.LENGTH_LONG).show();
            }
        }
    }
    return layout;
}

From source file:com.lithiumli.fiction.LibraryActivity.java

private void showPlayerInfo() {
    View bab = findViewById(R.id.bab);
    View bab_hr = findViewById(R.id.bab_hr);
    if (bab.getVisibility() == View.GONE) {
        bab.setVisibility(View.VISIBLE);
        Animation showBab = AnimationUtils.loadAnimation(this, R.anim.bab);
        bab.startAnimation(showBab);
        bab_hr.startAnimation(showBab);/*from  w w w .  j  a  v a  2 s . c  o  m*/
    }
}

From source file:net.inbox.Pager.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Show first use help
    boolean show_help = false;

    // Init SharedPreferences
    prefs = PreferenceManager.getDefaultSharedPreferences(this);
    if (!prefs.contains("initialized")) {
        PreferenceManager.setDefaultValues(this, R.xml.settings, false);
        prefs.edit().putBoolean("initialized", true).apply();

        // Initial values that don't have a preference screen
        prefs.edit().putBoolean("imap_or_pop", true).apply();
        prefs.edit().putBoolean("using_smtp", false).apply();
        prefs.edit().putBoolean("enable_pw", false).apply();
        show_help = true;//from  w  w w  . j  a  v  a2  s.c  o  m
    }

    if (show_help || !prefs.getBoolean("enable_pw", false)) {
        init_db("cleartext");

        // Initial entry view
        View v = View.inflate(this, R.layout.pager, null);
        v.startAnimation(AnimationUtils.loadAnimation(this, R.anim.fade_in));
        setContentView(v);

        rv_main = (RelativeLayout) findViewById(R.id.app_main);
        rv_main.setVisibility(View.VISIBLE);
        rv_main.setAlpha(0.01f);
        rv_main.animate().alpha(1f).setListener(new AnimatorListenerAdapter() {

            @Override
            public void onAnimationEnd(Animator animation) {
                super.onAnimationEnd(animation);
                activity_load();
            }
        });
    } else {
        // Initial entry view
        View v = View.inflate(this, R.layout.pager, null);
        v.startAnimation(AnimationUtils.loadAnimation(this, R.anim.fade_in));
        setContentView(v);

        // Entry text edit
        llay_pw = (LinearLayout) findViewById(R.id.llay_pw);
        llay_pw.setVisibility(View.VISIBLE);
        rv_main = (RelativeLayout) findViewById(R.id.app_main);
        et_pw = (EditText) findViewById(R.id.pw);
        et_pw.setOnKeyListener(new View.OnKeyListener() {
            public boolean onKey(View v, int key, KeyEvent event) {
                if (event.getAction() == KeyEvent.ACTION_DOWN && key == KeyEvent.KEYCODE_ENTER) {
                    init_db(et_pw.getText().toString());
                    et_pw.setText("");
                    if (unlocked) {
                        activity_load();
                        fade_in_ui();
                    } else {
                        if (++over >= 3)
                            finish();
                    }
                    return true;
                }
                return false;
            }
        });
    }

    // Helper dialog
    if (show_help) {
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setCancelable(true);
        builder.setTitle(getString(R.string.helper_title));
        builder.setMessage(getString(R.string.helper_msg));
        builder.setPositiveButton(getString(android.R.string.ok), null);
        builder.setNegativeButton(getString(R.string.btn_pw), new AlertDialog.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                startActivity(new Intent(getApplicationContext(), Settings.class));
                overridePendingTransition(R.anim.right_in, R.anim.right_out);
            }
        });
        builder.show();
    }
}

From source file:org.catrobat.catroid.ui.fragment.AddBrickFragment.java

private void animateBrick(final Brick brick, PrototypeBrickAdapter adapter) {
    Context context = getActivity();
    Animation animation = AnimationUtils.loadAnimation(context, R.anim.blink);

    animation.setAnimationListener(new AnimationListener() {

        @Override/*from w w  w.  ja  v a 2  s  .  c  om*/
        public void onAnimationStart(Animation animation) {
            brick.setAnimationState(true);
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
        }

        @Override
        public void onAnimationEnd(Animation animation) {
            brick.setAnimationState(false);
        }
    });

    View view = brick.getView(context, 0, adapter);

    view.startAnimation(animation);
}

From source file:com.nikhilnayak.games.octoshootar.ui.fragments.GameHomeFragment.java

private void updateTutoButtonAnimation() {
    final boolean hasTutoEverBeenSeen = PreferenceManager.getDefaultSharedPreferences(getActivity())
            .getBoolean(HomeActivity.KEY_HAS_TUTO_BEEN_SEEN, false);
    final View buttonTutoHelp = getView().findViewById(R.id.home_help_tuto);
    if (buttonTutoHelp != null) {
        if (!hasTutoEverBeenSeen) {
            final Animation animation = AnimationUtils.loadAnimation(getActivity(), R.anim.tuto_anim);
            if (animation != null) {
                buttonTutoHelp.startAnimation(animation);
            }//from  ww  w .j  a  v a2 s  . c  o  m
        } else {
            buttonTutoHelp.clearAnimation();
        }
    }
}