Example usage for android.widget TextView animate

List of usage examples for android.widget TextView animate

Introduction

In this page you can find the example usage for android.widget TextView animate.

Prototype

public ViewPropertyAnimator animate() 

Source Link

Document

This method returns a ViewPropertyAnimator object, which can be used to animate specific properties on this View.

Usage

From source file:com.filemanager.free.activities.MainActivity.java

public void updatePath(@NonNull final String news, boolean results, int openmode, int folder_count,
        int file_count) {

    if (news.length() == 0)
        return;//from  w w  w  .j  a  va 2  s .c o m
    if (news == null)
        return;
    if (openmode == 1 && news.startsWith("smb:/"))
        newPath = mainActivityHelper.parseSmbPath(news);
    else if (openmode == 2)
        newPath = mainActivityHelper.getIntegralNames(news);
    else
        newPath = news;
    final TextView bapath = (TextView) pathbar.findViewById(R.id.fullpath);
    final TextView animPath = (TextView) pathbar.findViewById(R.id.fullpath_anim);
    TextView textView = (TextView) pathbar.findViewById(R.id.pathname);
    if (!results) {
        textView.setText(folder_count + " " + getResources().getString(R.string.folders) + "" + " " + file_count
                + " " + getResources().getString(R.string.files));
    } else {
        bapath.setText(R.string.searchresults);
        textView.setText(R.string.empty);
        return;
    }
    final String oldPath = bapath.getText().toString();
    if (null != oldPath && oldPath.equals(newPath))
        return;

    // implement animation while setting text
    newPathBuilder = new StringBuffer().append(newPath);
    oldPathBuilder = new StringBuffer().append(oldPath);

    final Animation slideIn = AnimationUtils.loadAnimation(this, R.anim.slide_in);
    Animation slideOut = AnimationUtils.loadAnimation(this, R.anim.slide_out);

    if (newPath.length() > oldPath.length()
            && newPathBuilder.delete(oldPath.length(), newPath.length()).toString().equals(oldPath)
            && oldPath.length() != 0) {

        // navigate forward
        newPathBuilder.delete(0, newPathBuilder.length());
        newPathBuilder.append(newPath);
        newPathBuilder.delete(0, oldPath.length());
        animPath.setAnimation(slideIn);
        animPath.animate().setListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                super.onAnimationEnd(animation);
                new Handler().postDelayed(new Runnable() {
                    @Override
                    public void run() {

                        animPath.setVisibility(View.GONE);
                        bapath.setText(newPath);
                    }
                }, PATH_ANIM_END_DELAY);
            }

            @Override
            public void onAnimationStart(Animator animation) {
                super.onAnimationStart(animation);
                animPath.setVisibility(View.VISIBLE);
                animPath.setText(newPathBuilder.toString());
                //bapath.setText(oldPath);

                scroll.post(new Runnable() {
                    @Override
                    public void run() {
                        scroll1.fullScroll(View.FOCUS_RIGHT);
                    }
                });
            }

            @Override
            public void onAnimationCancel(Animator animation) {
                super.onAnimationCancel(animation);
                //onAnimationEnd(animation);
            }
        }).setStartDelay(PATH_ANIM_START_DELAY).start();
    } else if (newPath.length() < oldPath.length()
            && oldPathBuilder.delete(newPath.length(), oldPath.length()).toString().equals(newPath)) {

        // navigate backwards
        oldPathBuilder.delete(0, oldPathBuilder.length());
        oldPathBuilder.append(oldPath);
        oldPathBuilder.delete(0, newPath.length());
        animPath.setAnimation(slideOut);
        animPath.animate().setListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                super.onAnimationEnd(animation);
                animPath.setVisibility(View.GONE);
                bapath.setText(newPath);

                scroll.post(new Runnable() {
                    @Override
                    public void run() {
                        scroll1.fullScroll(View.FOCUS_RIGHT);
                    }
                });
            }

            @Override
            public void onAnimationStart(Animator animation) {
                super.onAnimationStart(animation);
                animPath.setVisibility(View.VISIBLE);
                animPath.setText(oldPathBuilder.toString());
                bapath.setText(newPath);

                scroll.post(new Runnable() {
                    @Override
                    public void run() {
                        scroll1.fullScroll(View.FOCUS_LEFT);
                    }
                });
            }
        }).setStartDelay(PATH_ANIM_START_DELAY).start();
    } else if (oldPath.isEmpty()) {

        // case when app starts
        // FIXME: COUNTER is incremented twice on app startup
        COUNTER++;
        if (COUNTER == 2) {

            animPath.setAnimation(slideIn);
            animPath.setText(newPath);
            animPath.animate().setListener(new AnimatorListenerAdapter() {
                @Override
                public void onAnimationStart(Animator animation) {
                    super.onAnimationStart(animation);
                    animPath.setVisibility(View.VISIBLE);
                    bapath.setText("");
                    scroll.post(new Runnable() {
                        @Override
                        public void run() {
                            scroll1.fullScroll(View.FOCUS_RIGHT);
                        }
                    });
                }

                @Override
                public void onAnimationEnd(Animator animation) {
                    super.onAnimationEnd(animation);
                    new Handler().postDelayed(new Runnable() {
                        @Override
                        public void run() {
                            animPath.setVisibility(View.GONE);
                            bapath.setText(newPath);
                        }
                    }, PATH_ANIM_END_DELAY);
                }

                @Override
                public void onAnimationCancel(Animator animation) {
                    super.onAnimationCancel(animation);
                    //onAnimationEnd(animation);
                }
            }).setStartDelay(PATH_ANIM_START_DELAY).start();
        }

    } else {

        // completely different path
        // first slide out of old path followed by slide in of new path
        animPath.setAnimation(slideOut);
        animPath.animate().setListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationStart(Animator animator) {
                super.onAnimationStart(animator);
                animPath.setVisibility(View.VISIBLE);
                animPath.setText(oldPath);
                bapath.setText("");

                scroll.post(new Runnable() {
                    @Override
                    public void run() {
                        scroll1.fullScroll(View.FOCUS_LEFT);
                    }
                });
            }

            @Override
            public void onAnimationEnd(Animator animator) {
                super.onAnimationEnd(animator);

                //animPath.setVisibility(View.GONE);
                animPath.setText(newPath);
                bapath.setText("");
                animPath.setAnimation(slideIn);

                animPath.animate().setListener(new AnimatorListenerAdapter() {
                    @Override
                    public void onAnimationEnd(Animator animation) {
                        super.onAnimationEnd(animation);
                        new Handler().postDelayed(new Runnable() {
                            @Override
                            public void run() {
                                animPath.setVisibility(View.GONE);
                                bapath.setText(newPath);
                            }
                        }, PATH_ANIM_END_DELAY);
                    }

                    @Override
                    public void onAnimationStart(Animator animation) {
                        super.onAnimationStart(animation);
                        // we should not be having anything here in path bar
                        animPath.setVisibility(View.VISIBLE);
                        bapath.setText("");
                        scroll.post(new Runnable() {
                            @Override
                            public void run() {
                                scroll1.fullScroll(View.FOCUS_RIGHT);
                            }
                        });
                    }
                }).start();
            }

            @Override
            public void onAnimationCancel(Animator animation) {
                super.onAnimationCancel(animation);
                //onAnimationEnd(animation);
            }
        }).setStartDelay(PATH_ANIM_START_DELAY).start();
    }
}

From source file:com.amaze.filemanager.activities.MainActivity.java

public void updatePath(@NonNull final String news, boolean results, int openmode, int folder_count,
        int file_count) {

    if (news.length() == 0)
        return;/*from   w ww. j  a  v a 2 s .c  o m*/
    if (news == null)
        return;
    if (openmode == 1 && news.startsWith("smb:/"))
        newPath = mainActivityHelper.parseSmbPath(news);
    else if (openmode == 2)
        newPath = mainActivityHelper.getIntegralNames(news);
    else
        newPath = news;
    final TextView bapath = (TextView) pathbar.findViewById(R.id.fullpath);
    final TextView animPath = (TextView) pathbar.findViewById(R.id.fullpath_anim);
    TextView textView = (TextView) pathbar.findViewById(R.id.pathname);
    if (!results) {
        textView.setText(folder_count + " " + getResources().getString(R.string.folders) + "" + " " + file_count
                + " " + getResources().getString(R.string.files));
    } else {
        bapath.setText(R.string.searchresults);
        textView.setText(R.string.empty);
        return;
    }
    final String oldPath = bapath.getText().toString();
    if (oldPath != null && oldPath.equals(newPath))
        return;

    // implement animation while setting text
    newPathBuilder = new StringBuffer().append(newPath);
    oldPathBuilder = new StringBuffer().append(oldPath);

    final Animation slideIn = AnimationUtils.loadAnimation(this, R.anim.slide_in);
    Animation slideOut = AnimationUtils.loadAnimation(this, R.anim.slide_out);

    if (newPath.length() > oldPath.length()
            && newPathBuilder.delete(oldPath.length(), newPath.length()).toString().equals(oldPath)
            && oldPath.length() != 0) {

        // navigate forward
        newPathBuilder.delete(0, newPathBuilder.length());
        newPathBuilder.append(newPath);
        newPathBuilder.delete(0, oldPath.length());
        animPath.setAnimation(slideIn);
        animPath.animate().setListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                super.onAnimationEnd(animation);
                new Handler().postDelayed(new Runnable() {
                    @Override
                    public void run() {

                        animPath.setVisibility(View.GONE);
                        bapath.setText(newPath);
                    }
                }, PATH_ANIM_END_DELAY);
            }

            @Override
            public void onAnimationStart(Animator animation) {
                super.onAnimationStart(animation);
                animPath.setVisibility(View.VISIBLE);
                animPath.setText(newPathBuilder.toString());
                //bapath.setText(oldPath);

                scroll.post(new Runnable() {
                    @Override
                    public void run() {
                        scroll1.fullScroll(View.FOCUS_RIGHT);
                    }
                });
            }

            @Override
            public void onAnimationCancel(Animator animation) {
                super.onAnimationCancel(animation);
                //onAnimationEnd(animation);
            }
        }).setStartDelay(PATH_ANIM_START_DELAY).start();
    } else if (newPath.length() < oldPath.length()
            && oldPathBuilder.delete(newPath.length(), oldPath.length()).toString().equals(newPath)) {

        // navigate backwards
        oldPathBuilder.delete(0, oldPathBuilder.length());
        oldPathBuilder.append(oldPath);
        oldPathBuilder.delete(0, newPath.length());
        animPath.setAnimation(slideOut);
        animPath.animate().setListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                super.onAnimationEnd(animation);
                animPath.setVisibility(View.GONE);
                bapath.setText(newPath);

                scroll.post(new Runnable() {
                    @Override
                    public void run() {
                        scroll1.fullScroll(View.FOCUS_RIGHT);
                    }
                });
            }

            @Override
            public void onAnimationStart(Animator animation) {
                super.onAnimationStart(animation);
                animPath.setVisibility(View.VISIBLE);
                animPath.setText(oldPathBuilder.toString());
                bapath.setText(newPath);

                scroll.post(new Runnable() {
                    @Override
                    public void run() {
                        scroll1.fullScroll(View.FOCUS_LEFT);
                    }
                });
            }
        }).setStartDelay(PATH_ANIM_START_DELAY).start();
    } else if (oldPath.isEmpty()) {

        // case when app starts
        // FIXME: COUNTER is incremented twice on app startup
        COUNTER++;
        if (COUNTER == 2) {

            animPath.setAnimation(slideIn);
            animPath.setText(newPath);
            animPath.animate().setListener(new AnimatorListenerAdapter() {
                @Override
                public void onAnimationStart(Animator animation) {
                    super.onAnimationStart(animation);
                    animPath.setVisibility(View.VISIBLE);
                    bapath.setText("");
                    scroll.post(new Runnable() {
                        @Override
                        public void run() {
                            scroll1.fullScroll(View.FOCUS_RIGHT);
                        }
                    });
                }

                @Override
                public void onAnimationEnd(Animator animation) {
                    super.onAnimationEnd(animation);
                    new Handler().postDelayed(new Runnable() {
                        @Override
                        public void run() {
                            animPath.setVisibility(View.GONE);
                            bapath.setText(newPath);
                        }
                    }, PATH_ANIM_END_DELAY);
                }

                @Override
                public void onAnimationCancel(Animator animation) {
                    super.onAnimationCancel(animation);
                    //onAnimationEnd(animation);
                }
            }).setStartDelay(PATH_ANIM_START_DELAY).start();
        }

    } else {

        // completely different path
        // first slide out of old path followed by slide in of new path
        animPath.setAnimation(slideOut);
        animPath.animate().setListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationStart(Animator animator) {
                super.onAnimationStart(animator);
                animPath.setVisibility(View.VISIBLE);
                animPath.setText(oldPath);
                bapath.setText("");

                scroll.post(new Runnable() {
                    @Override
                    public void run() {
                        scroll1.fullScroll(View.FOCUS_LEFT);
                    }
                });
            }

            @Override
            public void onAnimationEnd(Animator animator) {
                super.onAnimationEnd(animator);

                //animPath.setVisibility(View.GONE);
                animPath.setText(newPath);
                bapath.setText("");
                animPath.setAnimation(slideIn);

                animPath.animate().setListener(new AnimatorListenerAdapter() {
                    @Override
                    public void onAnimationEnd(Animator animation) {
                        super.onAnimationEnd(animation);
                        new Handler().postDelayed(new Runnable() {
                            @Override
                            public void run() {
                                animPath.setVisibility(View.GONE);
                                bapath.setText(newPath);
                            }
                        }, PATH_ANIM_END_DELAY);
                    }

                    @Override
                    public void onAnimationStart(Animator animation) {
                        super.onAnimationStart(animation);
                        // we should not be having anything here in path bar
                        animPath.setVisibility(View.VISIBLE);
                        bapath.setText("");
                        scroll.post(new Runnable() {
                            @Override
                            public void run() {
                                scroll1.fullScroll(View.FOCUS_RIGHT);
                            }
                        });
                    }
                }).start();
            }

            @Override
            public void onAnimationCancel(Animator animation) {
                super.onAnimationCancel(animation);
                //onAnimationEnd(animation);
            }
        }).setStartDelay(PATH_ANIM_START_DELAY).start();
    }
}

From source file:com.amaze.carbonfilemanager.activities.MainActivity.java

public void updatePath(@NonNull final String news, boolean results, OpenMode openmode, int folder_count,
        int file_count) {

    if (news.length() == 0)
        return;//  w ww  . j  a v a  2s  .co  m

    switch (openmode) {
    case SMB:
        newPath = mainActivityHelper.parseSmbPath(news);
        break;
    case OTG:
        newPath = mainActivityHelper.parseOTGPath(news);
        break;
    case CUSTOM:
        newPath = mainActivityHelper.getIntegralNames(news);
        break;
    case DROPBOX:
    case BOX:
    case ONEDRIVE:
    case GDRIVE:
        newPath = mainActivityHelper.parseCloudPath(openmode, news);
        break;
    default:
        newPath = news;
    }

    final TextView bapath = (TextView) pathbar.findViewById(R.id.fullpath);
    final TextView animPath = (TextView) pathbar.findViewById(R.id.fullpath_anim);
    TextView textView = (TextView) pathbar.findViewById(R.id.pathname);
    if (!results) {
        textView.setText(folder_count + " " + getResources().getString(R.string.folders) + "" + " " + file_count
                + " " + getResources().getString(R.string.files));
    } else {
        bapath.setText(R.string.searchresults);
        textView.setText(R.string.empty);
        return;
    }
    final String oldPath = bapath.getText().toString();
    if (oldPath.equals(newPath))
        return;

    // implement animation while setting text
    newPathBuilder = new StringBuffer().append(newPath);
    oldPathBuilder = new StringBuffer().append(oldPath);

    final Animation slideIn = AnimationUtils.loadAnimation(this, R.anim.slide_in);
    Animation slideOut = AnimationUtils.loadAnimation(this, R.anim.slide_out);

    if (newPath.length() > oldPath.length()
            && newPathBuilder.delete(oldPath.length(), newPath.length()).toString().equals(oldPath)
            && oldPath.length() != 0) {

        // navigate forward
        newPathBuilder.delete(0, newPathBuilder.length());
        newPathBuilder.append(newPath);
        newPathBuilder.delete(0, oldPath.length());
        animPath.setAnimation(slideIn);
        animPath.animate().setListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                super.onAnimationEnd(animation);
                new Handler().postDelayed(new Runnable() {
                    @Override
                    public void run() {

                        animPath.setVisibility(View.GONE);
                        bapath.setText(newPath);
                    }
                }, PATH_ANIM_END_DELAY);
            }

            @Override
            public void onAnimationStart(Animator animation) {
                super.onAnimationStart(animation);
                animPath.setVisibility(View.VISIBLE);
                animPath.setText(newPathBuilder.toString());
                //bapath.setText(oldPath);

                scroll.post(new Runnable() {
                    @Override
                    public void run() {
                        scroll1.fullScroll(View.FOCUS_RIGHT);
                    }
                });
            }

            @Override
            public void onAnimationCancel(Animator animation) {
                super.onAnimationCancel(animation);
                //onAnimationEnd(animation);
            }
        }).setStartDelay(PATH_ANIM_START_DELAY).start();
    } else if (newPath.length() < oldPath.length()
            && oldPathBuilder.delete(newPath.length(), oldPath.length()).toString().equals(newPath)) {

        // navigate backwards
        oldPathBuilder.delete(0, oldPathBuilder.length());
        oldPathBuilder.append(oldPath);
        oldPathBuilder.delete(0, newPath.length());
        animPath.setAnimation(slideOut);
        animPath.animate().setListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                super.onAnimationEnd(animation);
                animPath.setVisibility(View.GONE);
                bapath.setText(newPath);

                scroll.post(new Runnable() {
                    @Override
                    public void run() {
                        scroll1.fullScroll(View.FOCUS_RIGHT);
                    }
                });
            }

            @Override
            public void onAnimationStart(Animator animation) {
                super.onAnimationStart(animation);
                animPath.setVisibility(View.VISIBLE);
                animPath.setText(oldPathBuilder.toString());
                bapath.setText(newPath);

                scroll.post(new Runnable() {
                    @Override
                    public void run() {
                        scroll1.fullScroll(View.FOCUS_LEFT);
                    }
                });
            }
        }).setStartDelay(PATH_ANIM_START_DELAY).start();
    } else if (oldPath.isEmpty()) {
        // case when app starts
        // FIXME: COUNTER is incremented twice on app startup
        COUNTER++;
        if (COUNTER == 2) {
            animPath.setAnimation(slideIn);
            animPath.setText(newPath);
            animPath.animate().setListener(new AnimatorListenerAdapter() {
                @Override
                public void onAnimationStart(Animator animation) {
                    super.onAnimationStart(animation);
                    animPath.setVisibility(View.VISIBLE);
                    bapath.setText("");
                    scroll.post(new Runnable() {
                        @Override
                        public void run() {
                            scroll1.fullScroll(View.FOCUS_RIGHT);
                        }
                    });
                }

                @Override
                public void onAnimationEnd(Animator animation) {
                    super.onAnimationEnd(animation);
                    new Handler().postDelayed(new Runnable() {
                        @Override
                        public void run() {
                            animPath.setVisibility(View.GONE);
                            bapath.setText(newPath);
                        }
                    }, PATH_ANIM_END_DELAY);
                }

                @Override
                public void onAnimationCancel(Animator animation) {
                    super.onAnimationCancel(animation);
                    //onAnimationEnd(animation);
                }
            }).setStartDelay(PATH_ANIM_START_DELAY).start();
        }
    } else {
        // completely different path
        // first slide out of old path followed by slide in of new path
        animPath.setAnimation(slideOut);
        animPath.animate().setListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationStart(Animator animator) {
                super.onAnimationStart(animator);
                animPath.setVisibility(View.VISIBLE);
                animPath.setText(oldPath);
                bapath.setText("");

                scroll.post(new Runnable() {
                    @Override
                    public void run() {
                        scroll1.fullScroll(View.FOCUS_LEFT);
                    }
                });
            }

            @Override
            public void onAnimationEnd(Animator animator) {
                super.onAnimationEnd(animator);

                //animPath.setVisibility(View.GONE);
                animPath.setText(newPath);
                bapath.setText("");
                animPath.setAnimation(slideIn);

                animPath.animate().setListener(new AnimatorListenerAdapter() {
                    @Override
                    public void onAnimationEnd(Animator animation) {
                        super.onAnimationEnd(animation);
                        new Handler().postDelayed(new Runnable() {
                            @Override
                            public void run() {
                                animPath.setVisibility(View.GONE);
                                bapath.setText(newPath);
                            }
                        }, PATH_ANIM_END_DELAY);
                    }

                    @Override
                    public void onAnimationStart(Animator animation) {
                        super.onAnimationStart(animation);
                        // we should not be having anything here in path bar
                        animPath.setVisibility(View.VISIBLE);
                        bapath.setText("");
                        scroll.post(new Runnable() {
                            @Override
                            public void run() {
                                scroll1.fullScroll(View.FOCUS_RIGHT);
                            }
                        });
                    }
                }).start();
            }

            @Override
            public void onAnimationCancel(Animator animation) {
                super.onAnimationCancel(animation);
                //onAnimationEnd(animation);
            }
        }).setStartDelay(PATH_ANIM_START_DELAY).start();
    }
}

From source file:com.android.soma.Launcher.java

private void setCustomContentHintVisibility(Cling cling, String ccHintStr, boolean visible, boolean animate) {
    final TextView ccHint = (TextView) cling.findViewById(R.id.custom_content_hint);
    if (ccHint != null) {
        if (visible && !ccHintStr.isEmpty()) {
            ccHint.setText(ccHintStr);//from   ww w .  ja v  a  2s . c o m
            ccHint.setVisibility(View.VISIBLE);
            if (animate) {
                ccHint.setAlpha(0f);
                ccHint.animate().alpha(1f).setDuration(SHOW_CLING_DURATION).start();
            } else {
                ccHint.setAlpha(1f);
            }
        } else {
            if (animate) {
                ccHint.animate().alpha(0f).setDuration(SHOW_CLING_DURATION)
                        .setListener(new AnimatorListenerAdapter() {
                            @Override
                            public void onAnimationEnd(Animator animation) {
                                ccHint.setVisibility(View.GONE);
                            }
                        }).start();
            } else {
                ccHint.setAlpha(0f);
                ccHint.setVisibility(View.GONE);
            }
        }
    }
}