Search in sources :

Example 96 with AnimationListener

use of android.view.animation.Animation.AnimationListener in project newsrob by marianokamp.

the class ShowArticleActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if ("1".equals(NewsRob.getDebugProperties(this).getProperty("traceArticleDetailViewLaunch", "0")))
        Debug.startMethodTracing("traceArticleDetialViewLaunch");
    boolean isHwAccelerationEnabled = EntryManager.getInstance(this).isHardwareAccelerationAdvEnabled();
    PL.log("User set hw accel to enabled=" + isHwAccelerationEnabled + " (activity: " + this + ").", this);
    if (isHwAccelerationEnabled && !getEntryManager().isLightColorSchemeSelected()) {
        PL.log("HW accel still disabled because of dark theme.", this);
        isHwAccelerationEnabled = false;
    }
    if (isHwAccelerationEnabled)
        SDK11Helper.enableHWAccelerationForActivity(this);
    setTheme(getEntryManager().getCurrentThemeResourceId());
    // setDefaultKeyMode(DEFAULT_KEYS_SEARCH_LOCAL);
    // gui
    debug = "1".equals(NewsRob.getDebugProperties(this).getProperty("_articleDetailViewVerbose", "0"));
    savedContentCursorPosition = -1;
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    if (getIntent().getExtras() == null) {
        finish();
        return;
    }
    setContentView(com.newsrob.R.layout.show_article);
    googleAdsUtil = new GoogleAdsUtil(getEntryManager());
    uiHelper = new UIHelper(getEntryManager());
    RelativeLayout container = getContainer();
    registerForContextMenu(container);
    container.setOnClickListener(this);
    container.setOnLongClickListener(new View.OnLongClickListener() {

        public boolean onLongClick(View v) {
            lastLongClickTarget = v;
            return false;
        }
    });
    embeddedWebClient = new EmbeddedWebViewClient();
    createWebView(container);
    createOnScreenControls(container);
    // end-gui
    // runnables
    refreshUIRunnable = new Runnable() {

        public void run() {
            refreshUI();
        }
    };
    hideTitlePreviewRunnable = new Runnable() {

        public void run() {
            hideTitlePreview();
        }
    };
    titlePreviewContainer = findViewById(R.id.title_preview);
    hideAnimation = new ScaleAnimation(1f, 0f, 1f, 0f, Animation.RELATIVE_TO_PARENT, 0.5f, Animation.RELATIVE_TO_PARENT, 0.5f);
    hideAnimation.setDuration(300);
    hideAnimation.setAnimationListener(new AnimationListener() {

        @Override
        public void onAnimationStart(Animation animation) {
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
        }

        @Override
        public void onAnimationEnd(Animation animation) {
            titlePreviewContainer.setVisibility(View.INVISIBLE);
        }
    });
    showAnimation = new ScaleAnimation(0f, 1f, 0f, 1f, Animation.RELATIVE_TO_PARENT, 0.5f, Animation.RELATIVE_TO_PARENT, 0.5f);
    showAnimation.setDuration(300);
    showAnimation.setAnimationListener(new AnimationListener() {

        @Override
        public void onAnimationStart(Animation animation) {
            titlePreviewContainer.setVisibility(View.VISIBLE);
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
        }

        @Override
        public void onAnimationEnd(Animation animation) {
        }
    });
    // end-runnables
    initialize(getIntent());
}
Also used : GoogleAdsUtil(com.newsrob.util.GoogleAdsUtil) RelativeLayout(com.newsrob.widget.RelativeLayout) ScaleAnimation(android.view.animation.ScaleAnimation) TranslateAnimation(android.view.animation.TranslateAnimation) Animation(android.view.animation.Animation) AnimationListener(android.view.animation.Animation.AnimationListener) View(android.view.View) WebView(android.webkit.WebView) TextView(android.widget.TextView) ScaleAnimation(android.view.animation.ScaleAnimation)

Example 97 with AnimationListener

use of android.view.animation.Animation.AnimationListener in project StandOut by pingpongboss.

the class StandOutWindow method close.

/**
 * Close a window corresponding to the id.
 *
 * @param id
 *            The id of the window.
 */
public final synchronized void close(final int id) {
    // get the view corresponding to the id
    final Window window = getWindow(id);
    if (window == null) {
        throw new IllegalArgumentException("Tried to close(" + id + ") a null window.");
    }
    if (window.visibility == Window.VISIBILITY_TRANSITION) {
        return;
    }
    // alert callbacks and cancel if instructed
    if (onClose(id, window)) {
        Log.w(TAG, "Window " + id + " close cancelled by implementation.");
        return;
    }
    // remove hidden notification
    mNotificationManager.cancel(getClass().hashCode() + id);
    unfocus(window);
    window.visibility = Window.VISIBILITY_TRANSITION;
    // get animation
    Animation animation = getCloseAnimation(id);
    // remove window
    try {
        // animate
        if (animation != null) {
            animation.setAnimationListener(new AnimationListener() {

                @Override
                public void onAnimationStart(Animation animation) {
                }

                @Override
                public void onAnimationRepeat(Animation animation) {
                }

                @Override
                public void onAnimationEnd(Animation animation) {
                    // remove the window from the window manager
                    mWindowManager.removeView(window);
                    window.visibility = Window.VISIBILITY_GONE;
                    // remove view from internal map
                    sWindowCache.removeCache(id, StandOutWindow.this.getClass());
                    // if we just released the last window, quit
                    if (getExistingIds().size() == 0) {
                        // tell Android to remove the persistent
                        // notification
                        // the Service will be shutdown by the system on low
                        // memory
                        startedForeground = false;
                        stopForeground(true);
                    }
                }
            });
            window.getChildAt(0).startAnimation(animation);
        } else {
            // remove the window from the window manager
            mWindowManager.removeView(window);
            // remove view from internal map
            sWindowCache.removeCache(id, getClass());
            // if we just released the last window, quit
            if (sWindowCache.getCacheSize(getClass()) == 0) {
                // tell Android to remove the persistent notification
                // the Service will be shutdown by the system on low memory
                startedForeground = false;
                stopForeground(true);
            }
        }
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}
Also used : Window(wei.mark.standout.ui.Window) PopupWindow(android.widget.PopupWindow) Animation(android.view.animation.Animation) AnimationListener(android.view.animation.Animation.AnimationListener)

Aggregations

Animation (android.view.animation.Animation)97 AnimationListener (android.view.animation.Animation.AnimationListener)97 AlphaAnimation (android.view.animation.AlphaAnimation)32 TranslateAnimation (android.view.animation.TranslateAnimation)27 View (android.view.View)15 LinearInterpolator (android.view.animation.LinearInterpolator)12 ScaleAnimation (android.view.animation.ScaleAnimation)11 RotateAnimation (android.view.animation.RotateAnimation)10 ImageView (android.widget.ImageView)10 Rect (android.graphics.Rect)7 ViewGroup (android.view.ViewGroup)6 PopupWindow (android.widget.PopupWindow)6 Window (wei.mark.standout.ui.Window)6 SuppressLint (android.annotation.SuppressLint)5 AccelerateInterpolator (android.view.animation.AccelerateInterpolator)5 AnimationSet (android.view.animation.AnimationSet)4 Interpolator (android.view.animation.Interpolator)4 OvershootInterpolator (android.view.animation.OvershootInterpolator)4 Transformation (android.view.animation.Transformation)4 InputMethodManager (android.view.inputmethod.InputMethodManager)4