/** Hide and remove the XActivityToast */ void removeSuperToast(final XActivityToast xActivityToast) { /* If XActivityToast has been dismissed before it shows, do not attempt to show it */ if (!xActivityToast.isShowing()) { mList.remove(xActivityToast); return; } /* If being called somewhere else get rid of delayed remove message */ removeMessages(Messages.REMOVE, xActivityToast); final ViewGroup viewGroup = xActivityToast.getViewGroup(); final View toastView = xActivityToast.getView(); if (viewGroup != null) { Animation animation = getDismissAnimation(xActivityToast); animation.setAnimationListener( new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { /* Do nothing */ } @Override public void onAnimationEnd(Animation animation) { if (xActivityToast.getOnDismissWrapper() != null) { xActivityToast.getOnDismissWrapper().onDismiss(xActivityToast.getView()); } /* Show the XActivityToast next in the list if any exist */ ManagerXActivityToast.this.showNextSuperToast(); } @Override public void onAnimationRepeat(Animation animation) { /* Do nothing */ } }); toastView.startAnimation(animation); viewGroup.removeView(toastView); mList.poll(); } }
@SuppressLint("NewApi") @SuppressWarnings("deprecation") private void dismissWithAnimation() { Animation animation = this.getDismissAnimation(); animation.setAnimationListener( new Animation.AnimationListener() { @Override public void onAnimationEnd(Animation animation) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { /** Must use Handler to modify ViewGroup in onAnimationEnd() * */ Handler handler = new Handler(); handler.post(mHideWithAnimationRunnable); } else { /** Must use Handler to modify ViewGroup in onAnimationEnd() * */ Handler handler = new Handler(); handler.post(mHideImmediateRunnable); } } @Override public void onAnimationRepeat(Animation animation) { // Not used } @Override public void onAnimationStart(Animation animation) { // Not used } }); if (mToastView != null) { mToastView.startAnimation(animation); } }
/** Shows the SuperCardToast. */ public void show() { ManagerSuperCardToast.getInstance().add(this); if (!isIndeterminate) { mHandler = new Handler(); mHandler.postDelayed(mHideRunnable, mDuration); } mViewGroup.addView(mToastView); if (!showImmediate) { final Animation animation = this.getShowAnimation(); /** Invalidate the ViewGroup after the show animation completes * */ animation.setAnimationListener( new Animation.AnimationListener() { @Override public void onAnimationEnd(Animation arg0) { /** Must use Handler to modify ViewGroup in onAnimationEnd() * */ Handler mHandler = new Handler(); mHandler.post(mInvalidateRunnable); } @Override public void onAnimationRepeat(Animation arg0) { // Do nothing } @Override public void onAnimationStart(Animation arg0) { // Do nothing } }); mToastView.startAnimation(animation); } }
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.tweenlistener); mLinear = (LinearLayout) findViewById(R.id.linear); mBtn = (Button) findViewById(R.id.start); mBtn.setOnClickListener( new Button.OnClickListener() { public void onClick(View v) { // * 리스너로 연결하기 mBtn.startAnimation(mAni1); // */ /* 오프셋으로 연결하기 mBtn.startAnimation(AnimationUtils.loadAnimation( TweenListener.this, R.anim.offset)); //*/ } }); mAni1 = AnimationUtils.loadAnimation(this, R.anim.rotate2); mAni2 = AnimationUtils.loadAnimation(this, R.anim.alpha2); mAni3 = AnimationUtils.loadAnimation(this, R.anim.scale2); mAni1.setAnimationListener( new AnimationListener() { public void onAnimationEnd(Animation animation) { mBtn.startAnimation(mAni2); } public void onAnimationRepeat(Animation animation) { ; } public void onAnimationStart(Animation animation) { ; } }); mAni2.setAnimationListener( new AnimationListener() { public void onAnimationEnd(Animation animation) { mBtn.startAnimation(mAni3); } public void onAnimationRepeat(Animation animation) { ; } public void onAnimationStart(Animation animation) { ; } }); mAni3.setAnimationListener( new AnimationListener() { public void onAnimationEnd(Animation animation) { Toast.makeText(TweenListener.this, "Animation End", 0).show(); } public void onAnimationRepeat(Animation animation) { ; } public void onAnimationStart(Animation animation) { ; } }); }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); linearLayout = (LinearLayout) findViewById(R.id.linearLayout); linearLayout.setBackgroundColor(Color.BLACK); // Navbar setup navbar = (LinearLayout) findViewById(R.id.navbar); goButton = (Button) findViewById(R.id.go_button); urlField = (EditText) findViewById(R.id.url); goButton.setOnClickListener( new View.OnClickListener() { public void onClick(View v) { doNav(); } }); urlField.setOnEditorActionListener( new OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { boolean handled = false; if (actionId == EditorInfo.IME_ACTION_GO) { doNav(); handled = true; } return handled; } }); SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0); String lastUrl = settings.getString("lastUrl", ""); urlField.setText(lastUrl); // Navbar animation settings AnimationListener slideListener = new AnimationListener() { @Override public void onAnimationEnd(Animation animation) { if (animation.equals(slideUp)) { navbar.setVisibility(View.GONE); } } @Override public void onAnimationRepeat(Animation animation) {} @Override public void onAnimationStart(Animation animation) { if (animation.equals(slideDown)) { navbar.setVisibility(View.VISIBLE); } } }; slideUp = new TranslateAnimation( Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, -1.0f); slideUp.setDuration(500); slideUp.setAnimationListener(slideListener); slideDown = 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); slideDown.setDuration(500); slideDown.setAnimationListener(slideListener); // WebView setup webView = (WebView) findViewById(R.id.webView); WebSettings webSettings = webView.getSettings(); webView.setWebChromeClient(new WebChromeClient()); webView.setWebViewClient( new WebViewClient() { @Override public void onPageFinished(WebView view, String url) { Log.d("scale", view.getScale() + ""); Log.d("pageFinished", url); view.setInitialScale(70); if (url.equalsIgnoreCase(HOME_PAGE)) { // navbar.setVisibility(View.VISIBLE); navbar.startAnimation(slideDown); } } @Override public void onScaleChanged(WebView view, float oldScale, float newScale) { Log.d("scale changed", oldScale + " - " + newScale); if (newScale > 0.7) { Log.d("scale", "reset"); // view.setInitialScale(70); } } }); webView.setInitialScale(70); webView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE); webView.setVerticalScrollBarEnabled(false); webView.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY); webView.setOverScrollMode(WebView.OVER_SCROLL_NEVER); webSettings.setBuiltInZoomControls(true); webSettings.setDisplayZoomControls(false); webSettings.setSupportZoom(true); webSettings.setCacheMode(WebSettings.LOAD_NO_CACHE); webSettings.setPluginState(WebSettings.PluginState.ON); webSettings.setJavaScriptEnabled(true); webSettings.setDomStorageEnabled(true); webSettings.setDatabaseEnabled(true); webSettings.setDatabasePath( "/data/data/" + webView.getContext().getPackageName() + "/databases/"); webSettings.setSaveFormData(false); webSettings.setLightTouchEnabled(false); webSettings.setLayoutAlgorithm(LayoutAlgorithm.NORMAL); webSettings.setRenderPriority(RenderPriority.HIGH); webSettings.setUserAgentString( "Mozilla/5.0 (X11; Linux i686) AppleWebKit/534.24 (KHTML, like Gecko) Chrome/11.0.696.77 Large Screen Safari/534.24 GoogleTV"); final Intent intent = getIntent(); if ((intent.getAction() == Intent.ACTION_VIEW) && (intent.getData() != null)) { final String url = intent.getDataString(); urlField.setText(url); webView.loadUrl(url); navbar.setVisibility(View.GONE); } else { webView.loadUrl(HOME_PAGE); } webView.requestFocus(); }