Android Open Source - markj Jw Animation






From Project

Back to project page markj.

License

The source code is released under:

GNU Lesser General Public License

If you think the Android project markj listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.markjmind.mobile.api.android.ui;
//from   w ww.  j  a v  a 2  s  .c o  m
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.view.animation.AnimationSet;
import android.view.animation.ScaleAnimation;
import android.view.animation.TranslateAnimation;
/**
 * 
 * @author ???
 * @email markjmind@gmail.com
 */
public class JwAnimation {
//   public static void drop(ViewGroup panel,int duration) {
//
//         AnimationSet set = new AnimationSet(true);
//
//         Animation animation = new AlphaAnimation(0.0f, 1.0f);
//         animation.setDuration(duration);
//         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(duration);
//         set.addAnimation(animation);
//         
////         ScaleAnimation scale = new ScaleAnimation(-1, 1, -1, 1, 
////           ScaleAnimation.RELATIVE_TO_SELF, 1f, 
////           ScaleAnimation.RELATIVE_TO_SELF, 1f); 
////         set.addAnimation(scale);
//         
//         panel.startAnimation(set);
//      }
   
   public static Animation down(View panel,int duration,AnimationListener al) {
         AnimationSet set = new AnimationSet(true);
         
         Animation animation = new TranslateAnimation(
             Animation.RELATIVE_TO_SELF, 0.0f, 
             Animation.RELATIVE_TO_SELF, 0.0f,
             Animation.RELATIVE_TO_SELF, 0.7f,
             Animation.RELATIVE_TO_SELF, 0.0f
         );
         if(al!=null){
           set.setAnimationListener(al);
         }
         animation.setDuration(duration);
         set.addAnimation(animation);
         panel.startAnimation(set);
         return animation;
   }
   
   public static AnimationSet getDisLeft(int duration) {
         AnimationSet set = new AnimationSet(true);
         
         Animation animation = 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
         );
         
         Animation animation2 = new AlphaAnimation(1.0f, 0.0f);
       animation2.setDuration(duration);
       set.addAnimation(animation2);
         
         animation.setDuration(duration);
         set.addAnimation(animation);
         return set;
   }
   public static AnimationSet getEnLeft(int duration) {
         AnimationSet set = new AnimationSet(true);
         
         Animation animation = 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
         );
         Animation animation2 = new AlphaAnimation(0.0f, 1.0f);
       animation2.setDuration(duration);
       set.addAnimation(animation2);
       
         animation.setDuration(duration);
         set.addAnimation(animation);
         return set;
   }
   
   public static AnimationSet getDisRight(int duration) {
         AnimationSet set = new AnimationSet(true);
         
         Animation animation = 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
         );
         
         Animation animation2 = new AlphaAnimation(1.0f, 0.0f);
       animation2.setDuration(duration);
       set.addAnimation(animation2);
       
         animation.setDuration(duration);
         set.addAnimation(animation);
         return set;
   }
   
   public static AnimationSet getComeLeft(int duration) {
       AnimationSet set = new AnimationSet(true);
         
         Animation animation = new TranslateAnimation(
             Animation.RELATIVE_TO_SELF, 0.0f, 
             Animation.RELATIVE_TO_SELF, -0.3f,
             Animation.RELATIVE_TO_SELF, 0.0f,
             Animation.RELATIVE_TO_SELF, 0.0f
         );
         animation.setDuration(duration/2);
         set.addAnimation(animation);
         
         Animation animation2 = new TranslateAnimation(
               Animation.RELATIVE_TO_SELF, 0.0f, 
               Animation.RELATIVE_TO_SELF, 0.3f,
               Animation.RELATIVE_TO_SELF, 0.0f,
               Animation.RELATIVE_TO_SELF, 0.0f
           );
       animation2.setDuration(duration/2);
       animation2.setStartOffset(duration/2);
         set.addAnimation(animation2);
         return set;
   }
   public static AnimationSet getComeRight(int duration) {
         AnimationSet set = new AnimationSet(true);
         
         Animation animation = new TranslateAnimation(
             Animation.RELATIVE_TO_SELF, 0.0f, 
             Animation.RELATIVE_TO_SELF, 0.3f,
             Animation.RELATIVE_TO_SELF, 0.0f,
             Animation.RELATIVE_TO_SELF, 0.0f
         );
         animation.setDuration(duration/2);
         set.addAnimation(animation);
         
         Animation animation2 = new TranslateAnimation(
               Animation.RELATIVE_TO_SELF, 0.0f, 
               Animation.RELATIVE_TO_SELF, -0.3f,
               Animation.RELATIVE_TO_SELF, 0.0f,
               Animation.RELATIVE_TO_SELF, 0.0f
           );
       animation2.setDuration(duration/2);
       animation2.setStartOffset(duration/2);
         set.addAnimation(animation2);
         return set;
   }

   public static AnimationSet getEnRight(int duration) {
         AnimationSet set = new AnimationSet(true);
         
         Animation animation = 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
         );
         Animation animation2 = new AlphaAnimation(0.0f, 1.0f);
       animation2.setDuration(duration);
       set.addAnimation(animation2);
       
         animation.setDuration(duration);
         set.addAnimation(animation);
         return set;
   }
   public static AnimationSet getEnUp(int duration) {
         AnimationSet set = new AnimationSet(true);
         
         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 animation2 = new AlphaAnimation(0.0f, 1.0f);
       animation2.setDuration(duration);
       set.addAnimation(animation2);
       
         animation.setDuration(duration);
         set.addAnimation(animation);
         return set;
   }
   
   public static Animation bottom(View panel,int duration,AnimationListener al) {
         AnimationSet set = new AnimationSet(true);
         
         Animation animation = new TranslateAnimation(
             Animation.RELATIVE_TO_SELF, 0.0f,  //x? ????
             Animation.RELATIVE_TO_SELF, 0.0f,  //x? ????
             Animation.RELATIVE_TO_SELF, 0.0f,  //y? ????
             Animation.RELATIVE_TO_SELF, 1.0f    //y? ????
         );
         if(al!=null){
           set.setAnimationListener(al);
         }
         animation.setDuration(duration);
         set.addAnimation(animation);
         panel.startAnimation(set);
         return animation;
   }
   
   public static Animation up(View panel,int duration,AnimationListener al) {
         AnimationSet set = new AnimationSet(true);
         
         Animation animation = new TranslateAnimation(
             Animation.RELATIVE_TO_SELF, 0.0f,  //x? ????
             Animation.RELATIVE_TO_SELF, 0.0f,  //x? ????
             Animation.RELATIVE_TO_SELF, 0.0f,  //y? ????
             Animation.RELATIVE_TO_SELF, -1.0f  //y? ????
         );
         animation.setDuration(duration);
         
         set.addAnimation(animation);
         
         if(al!=null){
           set.setAnimationListener(al);
         }
         panel.startAnimation(set);
         return animation;         
   }
   
   
   
   public static Animation upFromDown(View panel,int duration,AnimationListener al) {
         AnimationSet set = new AnimationSet(true);
         
         Animation animation = new TranslateAnimation(
             Animation.RELATIVE_TO_SELF, 0.0f,  //x? ????
             Animation.RELATIVE_TO_SELF, 0.0f,  //x? ????
             Animation.RELATIVE_TO_SELF, -0.2f,  //y? ????
             Animation.RELATIVE_TO_SELF, 0.2f  //y? ????
         );
         animation.setDuration(duration);
         
         set.addAnimation(animation);
         
         if(al!=null){
           set.setAnimationListener(al);
         }
         panel.startAnimation(set);
         return animation;         
   }
   
   public static Animation right(ViewGroup panel,int duration,AnimationListener al) {
         AnimationSet set = new AnimationSet(true);
         
         Animation animation = new TranslateAnimation(
             Animation.RELATIVE_TO_SELF, -0.1f,  //x? ????
             Animation.RELATIVE_TO_SELF, 0.1f,  //x? ????
             Animation.RELATIVE_TO_SELF, 0.0f,  //y? ????
             Animation.RELATIVE_TO_SELF, 0.0f    //y? ????
         );
         animation.setDuration(duration);
         set.addAnimation(animation);
         
                
         if(al!=null){
           set.setAnimationListener(al);
         }
         panel.startAnimation(set);
         return animation;         
   }
   
   public static Animation rightOut(ViewGroup panel,int duration,AnimationListener al) {
         AnimationSet set = new AnimationSet(true);
         
         Animation animation = new TranslateAnimation(
             Animation.RELATIVE_TO_SELF, 0.0f,  //x? ????
             Animation.RELATIVE_TO_SELF, 1.0f,  //x? ????
             Animation.RELATIVE_TO_SELF, 0.0f,  //y? ????
             Animation.RELATIVE_TO_SELF, 0.0f    //y? ????
         );
         animation.setDuration(duration);
         set.addAnimation(animation);
         
                
         if(al!=null){
           set.setAnimationListener(al);
         }
         panel.startAnimation(set);
         return animation;         
   }
   
   public static Animation left(ViewGroup panel,int duration,AnimationListener al) {
         AnimationSet set = new AnimationSet(true);
         
         Animation animation = new TranslateAnimation(
             Animation.RELATIVE_TO_SELF, 1.0f,  //x? ????
             Animation.RELATIVE_TO_SELF, 0.0f,  //x? ????
             Animation.RELATIVE_TO_SELF, 0.0f,  //y? ????
             Animation.RELATIVE_TO_SELF, 0.0f    //y? ????
         );
         animation.setDuration(duration);
         set.addAnimation(animation);
         
                
         if(al!=null){
           set.setAnimationListener(al);
         }
         panel.startAnimation(set);
         return animation;         
   }
   
   public static Animation leftToRemove(ViewGroup panel,int duration) {
     AnimationSet set = new AnimationSet(true);
         
         Animation animation = new TranslateAnimation(
             Animation.RELATIVE_TO_SELF, 1.0f,  //x? ????
             Animation.RELATIVE_TO_SELF, -1.0f,  //x? ????
             Animation.RELATIVE_TO_SELF, 0.0f,  //y? ????
             Animation.RELATIVE_TO_SELF, 0.0f    //y? ????
         );
         animation.setDuration(duration);
         set.addAnimation(animation);
         
         set.setAnimationListener(new RemoveFirst(panel));

         panel.startAnimation(set);
         return animation;         
   }
   public static Animation show(ViewGroup panel,int duration,AnimationListener al) {
     AnimationSet set = new AnimationSet(true);
       
       Animation animation = new AlphaAnimation(0.0f, 1.0f);
       animation.setDuration(duration);
       set.addAnimation(animation);
       
       
              
       if(al!=null){
         set.setAnimationListener(al);
       }
       panel.startAnimation(set);
       return animation;  
   }
   
   public static Animation showView(View panel,int duration,AnimationListener al) {
     AnimationSet set = new AnimationSet(true);
       
     Animation animation = new TranslateAnimation(
               Animation.RELATIVE_TO_SELF, -1.0f,  //x? ????
               Animation.RELATIVE_TO_SELF, 0.0f,  //x? ????
               Animation.RELATIVE_TO_SELF, -1.0f,  //y? ????
               Animation.RELATIVE_TO_SELF, 0.0f    //y? ????
           );
     animation.setDuration(duration);
       set.addAnimation(animation);
     
       animation = new AlphaAnimation(0.0f, 1.0f);
       animation.setDuration(duration);
       set.addAnimation(animation);
       
       ScaleAnimation scale = new ScaleAnimation(
                             -1.0f,  //x? ????
                             1.0f,//x? ????
                             -1.0f,  //y? ????
                             1.0f,//y? ????   
           ScaleAnimation.RELATIVE_TO_SELF, 0.7f, 
           ScaleAnimation.RELATIVE_TO_SELF, 0.7f);
       scale.setDuration(duration);
       set.addAnimation(scale);
   
       
       
              
       if(al!=null){
         set.setAnimationListener(al);
       }
       panel.startAnimation(set);
       return null;  
   }
   
   public static Animation hide(ViewGroup panel,int duration) {
     AnimationSet set = new AnimationSet(true);
       
       Animation animation = new AlphaAnimation(1.0f,0.0f);
       animation.setDuration(duration);
       set.addAnimation(animation);
     
              
       set.setAnimationListener(new RemoveFirst(panel));
       
       panel.startAnimation(set);
       return animation;  
   }
   
   public static Animation remove(ViewGroup panel) {
    return hide(panel,100);
   }
   
   public static Animation add(ViewGroup panel) {
     return show(panel,300,null);  
   }
   
   
   public static Animation upToleft(ViewGroup panel,int duration,AnimationListener al) {
     AnimationSet set = new AnimationSet(true);
         
         Animation animation = new TranslateAnimation(
             Animation.RELATIVE_TO_SELF, -1.0f,  //x? ????
             Animation.RELATIVE_TO_SELF, 0.0f,  //x? ????
             Animation.RELATIVE_TO_SELF, 0.5f,  //y? ????
             Animation.RELATIVE_TO_SELF, 0.0f    //y? ????
         );
         animation.setDuration(duration);
         set.addAnimation(animation);
         
         if(al!=null){
           set.setAnimationListener(al);
         }

         panel.startAnimation(set);
         return animation;         
   }
   public static Animation downToright(ViewGroup panel,int duration,AnimationListener al) {
     AnimationSet set = new AnimationSet(true);
         
         Animation animation = new TranslateAnimation(
             Animation.RELATIVE_TO_SELF, -1.0f,  //x? ????
             Animation.RELATIVE_TO_SELF, 0.0f,  //x? ????
             Animation.RELATIVE_TO_SELF, -0.5f,  //y? ????
             Animation.RELATIVE_TO_SELF, 0.0f    //y? ????
         );
         animation.setDuration(duration);
         set.addAnimation(animation);
         
         if(al!=null){
           set.setAnimationListener(al);
         }

         panel.startAnimation(set);
         return animation;         
   }
   static class RemoveFirst implements AnimationListener{
    ViewGroup panel;
    public RemoveFirst(ViewGroup panel){
       this.panel = panel;
    }
    public void onAnimationStart(Animation animation) {}  
    public void onAnimationRepeat(Animation animation) {}
    public void onAnimationEnd(Animation animation) {
      panel.removeViewAt(0);
    }
   }
   
   

}




Java Source Code List

com.markjmind.mobile.api.android.controller.JwAsyncTask.java
com.markjmind.mobile.api.android.controller.JwMapperException.java
com.markjmind.mobile.api.android.controller.JwMemberMapper.java
com.markjmind.mobile.api.android.controller.JwStringID.java
com.markjmind.mobile.api.android.controller.JwViewController.java
com.markjmind.mobile.api.android.controller.JwViewerCache.java
com.markjmind.mobile.api.android.controller.JwViewer.java
com.markjmind.mobile.api.android.controller.Jwc.java
com.markjmind.mobile.api.android.controller.OnClickListenerReceiver.java
com.markjmind.mobile.api.android.controller.ViewerXmlMapper.java
com.markjmind.mobile.api.android.exception.JwErrorCode.java
com.markjmind.mobile.api.android.exception.JwException.java
com.markjmind.mobile.api.android.json.JSONMsgString.java
com.markjmind.mobile.api.android.json.JwJOSNTreeArray.java
com.markjmind.mobile.api.android.json.JwJSONReader.java
com.markjmind.mobile.api.android.ui.JwAnimation.java
com.markjmind.mobile.api.android.ui.JwGroup.java
com.markjmind.mobile.api.android.ui.JwMenu.java
com.markjmind.mobile.api.android.ui.JwOnGroupSelect.java
com.markjmind.mobile.api.android.ui.JwTabGroup.java
com.markjmind.mobile.api.android.ui.JwTouchGroupListener.java
com.markjmind.mobile.api.android.ui.JwTouchGroup.java
com.markjmind.mobile.api.android.ui.JwTouchMotionGroupLisener.java
com.markjmind.mobile.api.android.ui.JwTouchMotionGroup.java
com.markjmind.mobile.api.android.ui.drawgraph.GraphBoard.java
com.markjmind.mobile.api.android.ui.drawgraph.GraphSkin.java
com.markjmind.mobile.api.android.ui.drawgraph.HBackLineSkin.java
com.markjmind.mobile.api.android.ui.drawgraph.LineGraphSkin.java
com.markjmind.mobile.api.android.ui.drawgraph.PieGraph.java
com.markjmind.mobile.api.android.ui.drawgraph.RectGraphSkin.java
com.markjmind.mobile.api.android.ui.drawgraph.SimpleStyle.java
com.markjmind.mobile.api.android.ui.drawgraph.TextArraySkin.java
com.markjmind.mobile.api.android.ui.drawgraph.VBackLineSkin.java
com.markjmind.mobile.api.android.ui.graph.Arc.java
com.markjmind.mobile.api.android.ui.graph.BarElement.java
com.markjmind.mobile.api.android.ui.graph.BarLayout.java
com.markjmind.mobile.api.android.ui.graph.Bar.java
com.markjmind.mobile.api.android.ui.graph.IPieSkin.java
com.markjmind.mobile.api.android.ui.graph.LineLayout.java
com.markjmind.mobile.api.android.ui.graph.MeasureLayout.java
com.markjmind.mobile.api.android.ui.graph.PieArcRoundSkin.java
com.markjmind.mobile.api.android.ui.graph.PieLayout.java
com.markjmind.mobile.api.android.ui.graph.PiePercentSkin.java
com.markjmind.mobile.api.android.ui.view.JwBaseDropDown.java
com.markjmind.mobile.api.android.ui.view.JwDropDown.java
com.markjmind.mobile.api.android.ui.view.JwSlidingLayout.java
com.markjmind.mobile.api.android.ui.view.JwWheelView.java
com.markjmind.mobile.api.android.ui.view.StickerListener.java
com.markjmind.mobile.api.android.ui.view.StickerView.java
com.markjmind.mobile.api.android.ui.view.textview.JwTextViewAutoScale.java
com.markjmind.mobile.api.android.ui.view.textview.JwTextViewFonts.java
com.markjmind.mobile.api.android.ui.view.textview.JwTextViewWrapScale.java
com.markjmind.mobile.api.android.ui.wrapper.JwAlertDialog.java
com.markjmind.mobile.api.android.ui.wrapper.JwToast.java
com.markjmind.mobile.api.android.util.JwFile.java
com.markjmind.mobile.api.android.util.JwPreferenceList.java
com.markjmind.mobile.api.android.util.JwPreference.java
com.markjmind.mobile.api.android.util.JwSound.java
com.markjmind.mobile.api.android.util.JwTextUtils.java
com.markjmind.mobile.api.android.util.PhoneInfo.java
com.markjmind.mobile.api.android.util.WebConnection.java
com.markjmind.mobile.api.android.xml.JwDomHandler.java
com.markjmind.mobile.api.android.xml.JwDomLoader.java
com.markjmind.mobile.api.android.xml.JwEditElementHandler.java
com.markjmind.mobile.api.android.xml.JwXmlLoader.java
com.markjmind.mobile.api.android.xml.JwXmlResoure.java
com.markjmind.mobile.api.hub.ArrayJDhub.java
com.markjmind.mobile.api.hub.DBhub.java
com.markjmind.mobile.api.hub.JDhub.java
com.markjmind.mobile.api.hub.Loader.java
com.markjmind.mobile.api.hub.StoreList.java
com.markjmind.mobile.api.hub.Store.java