Exemple #1
0
  public void loadAnimation() {
    Animation animation = AnimationUtils.loadAnimation(this, R.anim.slide_in_right_delay);
    Animation animation2 = AnimationUtils.loadAnimation(this, R.anim.slide_in_right_delay);
    Animation animation3 = AnimationUtils.loadAnimation(this, R.anim.slide_in_right_delay);
    Animation fadeAnimation = AnimationUtils.loadAnimation(this, R.anim.fade_in);
    overLay.setAnimation(animation);
    overLay2.setAnimation(animation2);
    overLay3.setAnimation(animation3);
    welcomeText.setAnimation(fadeAnimation);

    animation3.setStartOffset(500);
    animation2.setStartOffset(600);
    animation.setStartOffset(700);
    fadeAnimation.setStartOffset(1000);
    welcomeText.setVisibility(View.VISIBLE);

    fadeAnimation.setAnimationListener(
        new Animation.AnimationListener() {
          @Override
          public void onAnimationStart(Animation animation) {}

          @Override
          public void onAnimationEnd(Animation animation) {
            // searchNewMessages();

            loadOut();
          }

          @Override
          public void onAnimationRepeat(Animation animation) {}
        });

    //

  }
  public void refreshViews() {
    layout.removeAllViews();
    views = new ArrayList<View>();
    cardViews = new ArrayList<CardUI>();
    profilePictures = new ArrayList<MLRoundedImageView>();

    users = ItemsData.retrieveUserIdsCurrentlyRenting(getActivity());
    bitmaps = new ArrayList<Bitmap>();
    if (users.size() == 0) {
      CardUI cards = new CardUI(getActivity());
      cards.setPadding(0, 20, 0, 20);
      cards.addCard(new EmptyRentalListCard(getActivity()));
      cards.refresh();
      views.add(cards);
    } else {
      for (User u : users) {
        views.add(createProfile(u));
        views.add(
            createUserRentals(
                ItemsData.retrieveItemsLentByUserId(u.getFacebookId(), getActivity())));
      }
    }

    for (int i = 0; i < views.size(); i++) {
      View v = views.get(i);
      v.setVisibility(LinearLayout.VISIBLE);
      Animation animation = AnimationUtils.loadAnimation(getActivity(), R.animator.fade_in);
      animation.setDuration(300);
      animation.setStartOffset(i * 100);
      v.setAnimation(animation);
      layout.addView(v);
    }
  }
 private void showBitmapForView(ImageView v, final Bitmap bitmap) {
   v.setImageBitmap(bitmap);
   Animation a = AnimUtils.FadeIn.loadAnimation(UI.getActivity(), 500);
   a.setStartOffset(500);
   v.startAnimation(a);
   topicView
       .findViewById(R.id.forum_image_btn)
       .setOnClickListener(
           new View.OnClickListener() {
             @Override
             public void onClick(View v) {
               File f;
               try {
                 f = Utils.saveTmpBitmap(bitmap);
                 Intent intent = new Intent(Intent.ACTION_VIEW);
                 intent.setDataAndType(Uri.fromFile(f), "image/*");
                 startActivity(intent);
               } catch (IOException e) {
                 e.printStackTrace();
                 UI.toast("图片保存出错");
               } catch (ActivityNotFoundException e) {
                 UI.toast("无法查看图片,无图库程序");
               }
             }
           });
 }
 public static void fadeViewInOut(View view, long startDelay, long fadeTime, long stayTime) {
   AnimationSet set = new AnimationSet(false);
   Animation in = new AlphaAnimation(0.0f, 1.0f);
   in.setStartOffset(startDelay);
   in.setDuration(fadeTime);
   in.setFillAfter(false);
   in.setZAdjustment(Animation.ZORDER_TOP);
   set.addAnimation(in);
   Animation out = new AlphaAnimation(1.0f, 0.0f);
   out.setStartOffset(fadeTime + startDelay + stayTime);
   out.setDuration(fadeTime);
   out.setFillAfter(true);
   out.setZAdjustment(Animation.ZORDER_TOP);
   set.addAnimation(out);
   set.setFillAfter(true);
   view.startAnimation(set);
 }
Exemple #5
0
  /**
   * A fade animation that will fade the subject in by changing alpha from 0 to 1.
   *
   * @param duration the animation duration in milliseconds
   * @param delay how long to wait before starting the animation, in milliseconds
   * @return a fade animation
   * @see #fadeInAnimation(View, long)
   */
  public static Animation fadeInAnimation(long duration, long delay) {

    Animation fadeIn = new AlphaAnimation(0, 1);
    fadeIn.setInterpolator(new DecelerateInterpolator());
    fadeIn.setDuration(duration);
    fadeIn.setStartOffset(delay);

    return fadeIn;
  }
 private void fadePage() {
   if (eink || pageNumberAnim == null) {
     pageNumberTextView.setVisibility(View.GONE);
   } else {
     pageNumberAnim.setStartOffset(0);
     pageNumberAnim.setFillAfter(true);
     pageNumberTextView.startAnimation(pageNumberAnim);
   }
 }
Exemple #7
0
  /**
   * A fade animation that will fade the subject out by changing alpha from 1 to 0.
   *
   * @param duration the animation duration in milliseconds
   * @param delay how long to wait before starting the animation, in milliseconds
   * @return a fade animation
   * @see #fadeOutAnimation(View, long)
   */
  public static Animation fadeOutAnimation(long duration, long delay) {

    Animation fadeOut = new AlphaAnimation(1, 0);
    fadeOut.setInterpolator(new AccelerateInterpolator());
    fadeOut.setStartOffset(delay);
    fadeOut.setDuration(duration);

    return fadeOut;
  }
 public void animateRegion() {
   if (regionIV != null) {
     Animation anim = AnimationUtils.loadAnimation(getActivity(), R.anim.fade_in);
     regionIV.setAnimation(anim);
     regionTV.setAnimation(anim);
     anim.setStartOffset(1500);
     anim.setFillAfter(true);
     anim.start();
   }
 }
 public void animateCards() {
   for (int i = 0; i < views.size(); i++) {
     View v = views.get(i);
     v.setVisibility(LinearLayout.VISIBLE);
     Animation animation = AnimationUtils.loadAnimation(getActivity(), R.animator.fade_in);
     animation.setDuration(200);
     animation.setStartOffset((i + 1) * 75);
     v.setAnimation(animation);
   }
 }
 public static Animation getFadeOutAnimation(
     Context context, long initialDelayMs, long durationMs, AnimationListener listener) {
   Animation fadeOutAnimation = AnimationUtils.loadAnimation(context, R.anim.fade_out);
   fadeOutAnimation.setStartOffset(initialDelayMs);
   fadeOutAnimation.setDuration(durationMs);
   if (listener != null) {
     fadeOutAnimation.setAnimationListener(listener);
   }
   return fadeOutAnimation;
 }
  /**
   * The function responsible for fade-in fade-out effect
   *
   * @imageView <-- The View which displays the images
   * @images[] <-- Holds R references to the images to display
   * @imageIndex <-- index of the first image to show in images[]
   * @forever <-- If equals true then after the last image it starts all over again with the first
   *     image resulting in an infinite loop. You have been warned.
   */
  private void animate(
      final ImageView imageView, final int images[], final int imageIndex, final boolean forever) {

    int fadeInDuration = 800; // Configure time values here
    int timeBetween = 200;
    int fadeOutDuration = 400;

    // imageView.setVisibility(View.INVISIBLE);    //Visible or invisible by default - this will
    // apply when the animation ends
    imageView.setImageResource(images[imageIndex]);

    Animation fadeIn = new AlphaAnimation((float) 0.1, (float) 1.0);
    fadeIn.setInterpolator(new DecelerateInterpolator()); // add this
    fadeIn.setDuration(fadeInDuration);
    Animation fadeOut = new AlphaAnimation((float) 1.0, (float) 1.0);
    fadeOut.setInterpolator(new AccelerateInterpolator()); // and this
    fadeOut.setStartOffset(fadeInDuration + timeBetween);
    fadeOut.setDuration(fadeOutDuration);

    AnimationSet animation = new AnimationSet(false); // change to false
    animation.addAnimation(fadeIn);
    animation.addAnimation(fadeOut);
    animation.setRepeatCount(1);
    imageView.setAnimation(animation);

    animation.setAnimationListener(
        new Animation.AnimationListener() {
          public void onAnimationEnd(Animation animation) {
            if (images.length - 1 > imageIndex) {
              animate(
                  imageView,
                  images,
                  imageIndex + 1,
                  forever); // Calls itself until it gets to the end of the array
            } else {
              if (forever == true) {
                animate(
                    imageView, images, 0,
                    forever); // Calls itself to start the animation all over again in a loop if
                // forever = true
              }
            }
          }

          public void onAnimationRepeat(Animation animation) {
            // TODO Auto-generated method stub
          }

          public void onAnimationStart(Animation animation) {
            // TODO Auto-generated method stub
          }
        });
  }
  /**
   * Create a pair of {@link FlipAnimation} that can be used to flip 3D transition from {@code
   * fromView} to {@code toView}. A typical use case is with {@link ViewAnimator} as an out and in
   * transition.
   *
   * <p>NOTE: Avoid using this method. Instead, use {@link #flipTransition}.
   *
   * @param fromView the view transition away from
   * @param toView the view transition to
   * @param dir the flip direction
   * @param duration the transition duration in milliseconds
   * @param interpolator the interpolator to use (pass {@code null} to use the {@link
   *     AccelerateInterpolator} interpolator)
   * @return
   */
  public static Animation[] flipAnimation(
      final View fromView,
      final View toView,
      FlipDirection dir,
      long duration,
      Interpolator interpolator) {
    Animation[] result = new Animation[2];
    float centerX;
    float centerY;

    centerX = fromView.getWidth() / 2.0f;
    centerY = fromView.getHeight() / 2.0f;

    Animation outFlip =
        new FlipAnimation(
            dir.getStartDegreeForFirstView(),
            dir.getEndDegreeForFirstView(),
            centerX,
            centerY,
            FlipAnimation.SCALE_DEFAULT,
            FlipAnimation.ScaleUpDownEnum.SCALE_DOWN);
    outFlip.setDuration(duration);
    outFlip.setFillAfter(true);
    outFlip.setInterpolator(interpolator == null ? new AccelerateInterpolator() : interpolator);

    AnimationSet outAnimation = new AnimationSet(true);
    outAnimation.addAnimation(outFlip);
    result[0] = outAnimation;

    // Uncomment the following if toView has its layout established (not the case if using
    // ViewFlipper and on first show)
    // centerX = toView.getWidth() / 2.0f;
    // centerY = toView.getHeight() / 2.0f;

    Animation inFlip =
        new FlipAnimation(
            dir.getStartDegreeForSecondView(),
            dir.getEndDegreeForSecondView(),
            centerX,
            centerY,
            FlipAnimation.SCALE_DEFAULT,
            FlipAnimation.ScaleUpDownEnum.SCALE_UP);
    inFlip.setDuration(duration);
    inFlip.setFillAfter(true);
    inFlip.setInterpolator(interpolator == null ? new AccelerateInterpolator() : interpolator);
    inFlip.setStartOffset(duration);

    AnimationSet inAnimation = new AnimationSet(true);
    inAnimation.addAnimation(inFlip);
    result[1] = inAnimation;

    return result;
  }
    protected void onPostExecute(Void result) {
      for (int i = 0; i < views.size(); i++) {
        View v = views.get(i);
        v.setVisibility(LinearLayout.VISIBLE);
        Animation animation = AnimationUtils.loadAnimation(getActivity(), R.animator.fade_in);
        animation.setDuration(300);
        animation.setStartOffset(i * 100);
        v.setAnimation(animation);
        layout.addView(v);
      }

      new FacebookPictures().execute(new Void[] {});
    }
Exemple #14
0
  public void loadOut() {
    Animation animation = AnimationUtils.loadAnimation(this, R.anim.slide_out_left_delay);
    Animation animation2 = AnimationUtils.loadAnimation(this, R.anim.slide_out_left_delay);
    Animation animation3 = AnimationUtils.loadAnimation(this, R.anim.slide_out_left_delay);
    Animation fadeAnimation = AnimationUtils.loadAnimation(this, R.anim.fade_out);
    overLay.clearAnimation();
    overLay.setAnimation(animation);
    overLay2.clearAnimation();
    overLay2.setAnimation(animation2);
    overLay3.clearAnimation();
    overLay3.setAnimation(animation3);
    welcomeText.clearAnimation();
    welcomeText.setAnimation(fadeAnimation);

    fadeAnimation.setStartOffset(1500);
    animation.setStartOffset(2000);
    animation2.setStartOffset(2100);
    animation3.setStartOffset(2200);

    welcomeText.setVisibility(View.GONE);
    overLay.setVisibility(View.GONE);
    overLay2.setVisibility(View.GONE);
    overLay3.setVisibility(View.GONE);

    animation3.setAnimationListener(
        new Animation.AnimationListener() {
          @Override
          public void onAnimationStart(Animation animation) {}

          @Override
          public void onAnimationEnd(Animation animation) {

            dashBoard();
          }

          @Override
          public void onAnimationRepeat(Animation animation) {}
        });
  }
  private void setupText1Marquee() {
    final int duration = (int) (mText1Difference * MS_PER_PX);

    mMoveText1TextOut = new TranslateAnimation(0, -mText1Difference, 0, 0);
    mMoveText1TextOut.setDuration(duration);
    mMoveText1TextOut.setInterpolator(new LinearInterpolator());
    mMoveText1TextOut.setFillAfter(true);

    mMoveText1TextIn = new TranslateAnimation(-mText1Difference, 0, 0, 0);
    mMoveText1TextIn.setDuration(duration);
    mMoveText1TextIn.setStartOffset(PAUSE_BETWEEN_ANIMATIONS);
    mMoveText1TextIn.setInterpolator(new LinearInterpolator());
    mMoveText1TextIn.setFillAfter(true);

    mMoveText1TextOut.setAnimationListener(
        new Animation.AnimationListener() {
          public void onAnimationStart(Animation animation) {
            //                mMoveText1TextOutPlaying = true;
            expandTextView(mTextField1);
          }

          public void onAnimationEnd(Animation animation) {
            //                mMoveText1TextOutPlaying = false;

            if (mCancelled) {
              return;
            }

            mTextField1.startAnimation(mMoveText1TextIn);
          }

          public void onAnimationRepeat(Animation animation) {}
        });

    mMoveText1TextIn.setAnimationListener(
        new Animation.AnimationListener() {
          public void onAnimationStart(Animation animation) {}

          public void onAnimationEnd(Animation animation) {

            cutTextView(mTextField1);

            if (mCancelled) {
              return;
            }
            startTextField1Animation();
          }

          public void onAnimationRepeat(Animation animation) {}
        });
  }
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    View v = convertView;
    if (convertView == null) {
      v = inflater.inflate(R.layout.list_radio_item, null);
    }

    ImageView stt = (ImageView) v.findViewById(R.id.imageViewRadioStat);
    TextView tvNama = (TextView) v.findViewById(R.id.textViewNamaRadio);
    TextView tvKota = (TextView) v.findViewById(R.id.textViewKota);
    ImageView blink = (ImageView) v.findViewById(R.id.imageViewRadioBlink);
    TextView tvStat = (TextView) v.findViewById(R.id.textViewStatus);

    Radio r = data.get(position);
    Animation anim = new AlphaAnimation(0.0f, 1.0f);
    anim.setDuration(500);
    anim.setStartOffset(200);
    anim.setRepeatMode(Animation.REVERSE);
    anim.setRepeatCount(Animation.INFINITE);

    if (url.equals(r.getUrl()) && isPlayed && serviceRunning && onRadio) {
      r.setPlayedAtm(true);
      r.setStatusMessage("Menjalankan");
      isPlayed = false;
    }

    tvNama.setText(r.getNamaRadio());
    //		int c = tvNama.getTextColors().getDefaultColor();
    tvKota.setText(r.getKota());
    if (r.isPlayedAtm()) {
      tvNama.setTextColor(_ac.getResources().getColor(R.color.hijau_1));
      stt.setImageResource(R.drawable.ic_radio_on);
      blink.setImageResource(R.drawable.lingkaran_kecil);
      blink.startAnimation(anim);
      tvStat.setText(r.getStatusMessage());
      tvStat.startAnimation(anim);
    } else {
      tvNama.setTextColor(Color.WHITE);
      stt.setImageResource(R.drawable.ic_radio_off);
      blink.setImageResource(android.R.color.transparent);
      blink.clearAnimation();
      if (r.getStatusMessage().equalsIgnoreCase("Error")) {
        tvStat.setText("Tidak ada koneksi.");
      } else {
        tvStat.setText("");
      }
      tvStat.clearAnimation();
    }

    return v;
  }
  /**
   * Code from http://stackoverflow.com/a/10471479/3399351
   *
   * <p>Cycles through an array of images in one ImageView, sequentially fading them out and fading
   * the new photo in.
   *
   * @param imageView ImageView : The View which displays the images
   * @param images int[] : Holds R references to the images to display
   * @param imageIndex int : index of the first image to show in images[]
   * @param forever boolean : If equals true than it loops back to the first image
   */
  public static void animate(
      final ImageView imageView, final int images[], final int imageIndex, final boolean forever) {
    // TODO: Smooth fade between images instead of fade through white
    int fadeInDuration = 500; // Configure time values here
    int timeBetween = 5000;
    int fadeOutDuration = 1000;

    imageView.setVisibility(View.VISIBLE);
    // Visible or invisible by default - this will apply when the animation ends
    imageView.setImageResource(images[imageIndex]);

    // Initialize the fade in animation
    Animation fadeIn = new AlphaAnimation(0, 1);
    fadeIn.setInterpolator(new DecelerateInterpolator());
    fadeIn.setDuration(fadeInDuration);

    // Initialize the fade out animation
    Animation fadeOut = new AlphaAnimation(1, 0);
    fadeOut.setInterpolator(new AccelerateInterpolator());
    fadeOut.setStartOffset(fadeInDuration + timeBetween);
    fadeOut.setDuration(fadeOutDuration);

    // Apply the animation set
    AnimationSet animation = new AnimationSet(false);
    animation.addAnimation(fadeIn);
    animation.addAnimation(fadeOut);
    animation.setRepeatCount(1);
    imageView.setAnimation(animation);

    // Overriding this function causes the animations to loop
    animation.setAnimationListener(
        new Animation.AnimationListener() {
          public void onAnimationEnd(Animation animation) {
            if (images.length - 1 > imageIndex) {
              animate(imageView, images, imageIndex + 1, forever);
              // Calls itself until it gets to the end of the array
              if (forever) {
                animate(imageView, images, 0, forever);
                // Calls itself to start the animation
                // all over again in a loop, if forever = true
              }
            }
          }

          public void onAnimationRepeat(Animation animation) {}

          public void onAnimationStart(Animation animation) {}
        });
  }
 private void fadeZoom() {
   // #ifdef pro
   //     	if (this.textReflowMode) {
   //     		this.zoomLayout.setVisibility(View.GONE);
   //     		return;
   //     	}
   // #endif
   if (eink || zoomAnim == null) {
     zoomLayout.setVisibility(View.GONE);
   } else {
     zoomAnim.setStartOffset(0);
     zoomAnim.setFillAfter(true);
     zoomLayout.startAnimation(zoomAnim);
   }
 }
Exemple #19
0
 @Override
 protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   requestWindowFeature(Window.FEATURE_NO_TITLE);
   getWindow()
       .setFlags(
           WindowManager.LayoutParams.FLAG_FULLSCREEN,
           (WindowManager.LayoutParams.FLAG_FULLSCREEN));
   setContentView(R.layout.splashjar);
   ImageView moviemaniac = (ImageView) findViewById(R.id.imageView2);
   // moviemaniac.setVisibility(View.INVISIBLE);
   final Animation anim = AnimationUtils.loadAnimation(this, R.anim.alpha);
   anim.setStartOffset(1000);
   moviemaniac.startAnimation(anim);
   // YoYo.with(Techniques.FadeInUp).duration(3000).playOn(moviemaniac);
 }
    /**
     * Opens the floating toolbar overflow. This method should not be called if menu items have not
     * been laid out with {@link #layoutMenuItems(java.util.List, MenuItem.OnMenuItemClickListener,
     * int)}.
     *
     * @throws IllegalStateException if called when menu items have not been laid out.
     */
    private void openOverflow() {
      Preconditions.checkState(mMainPanel != null);
      Preconditions.checkState(mOverflowPanel != null);

      mMainPanel.fadeOut(true);
      Size overflowPanelSize = mOverflowPanel.measure();
      final int targetWidth = overflowPanelSize.getWidth();
      final int targetHeight = overflowPanelSize.getHeight();
      final boolean morphUpwards = (mOverflowDirection == OVERFLOW_DIRECTION_UP);
      final int startWidth = mContentContainer.getWidth();
      final int startHeight = mContentContainer.getHeight();
      final float startY = mContentContainer.getY();
      final float right = mContentContainer.getX() + mContentContainer.getWidth();
      Animation widthAnimation =
          new Animation() {
            @Override
            protected void applyTransformation(float interpolatedTime, Transformation t) {
              ViewGroup.LayoutParams params = mContentContainer.getLayoutParams();
              int deltaWidth = (int) (interpolatedTime * (targetWidth - startWidth));
              params.width = startWidth + deltaWidth;
              mContentContainer.setLayoutParams(params);
              mContentContainer.setX(right - mContentContainer.getWidth());
            }
          };
      Animation heightAnimation =
          new Animation() {
            @Override
            protected void applyTransformation(float interpolatedTime, Transformation t) {
              ViewGroup.LayoutParams params = mContentContainer.getLayoutParams();
              int deltaHeight = (int) (interpolatedTime * (targetHeight - startHeight));
              params.height = startHeight + deltaHeight;
              mContentContainer.setLayoutParams(params);
              if (morphUpwards) {
                float y = startY - (mContentContainer.getHeight() - startHeight);
                mContentContainer.setY(y);
              }
            }
          };
      widthAnimation.setDuration(240);
      heightAnimation.setDuration(180);
      heightAnimation.setStartOffset(60);
      mOpenOverflowAnimation.getAnimations().clear();
      mOpenOverflowAnimation.setAnimationListener(mOnOverflowOpened);
      mOpenOverflowAnimation.addAnimation(widthAnimation);
      mOpenOverflowAnimation.addAnimation(heightAnimation);
      mContentContainer.startAnimation(mOpenOverflowAnimation);
    }
 public void startTickAnim() {
   // hide tick
   mLeftRectWidth = 0;
   mRightRectWidth = 0;
   invalidate();
   Animation tickAnim =
       new Animation() {
         @Override
         protected void applyTransformation(float interpolatedTime, Transformation t) {
           super.applyTransformation(interpolatedTime, t);
           if (0.54 < interpolatedTime
               && 0.7 >= interpolatedTime) { // grow left and right rect to right
             mLeftRectGrowMode = true;
             mLeftRectWidth = mMaxLeftRectWidth * ((interpolatedTime - 0.54f) / 0.16f);
             if (0.65 < interpolatedTime) {
               mRightRectWidth = MAX_RIGHT_RECT_W * ((interpolatedTime - 0.65f) / 0.19f);
             }
             invalidate();
           } else if (0.7 < interpolatedTime
               && 0.84
                   >= interpolatedTime) { // shorten left rect from right, still grow right rect
             mLeftRectGrowMode = false;
             mLeftRectWidth = mMaxLeftRectWidth * (1 - ((interpolatedTime - 0.7f) / 0.14f));
             mLeftRectWidth = mLeftRectWidth < MIN_LEFT_RECT_W ? MIN_LEFT_RECT_W : mLeftRectWidth;
             mRightRectWidth = MAX_RIGHT_RECT_W * ((interpolatedTime - 0.65f) / 0.19f);
             invalidate();
           } else if (0.84 < interpolatedTime
               && 1 >= interpolatedTime) { // restore left rect width, shorten right rect to const
             mLeftRectGrowMode = false;
             mLeftRectWidth =
                 MIN_LEFT_RECT_W
                     + (CONST_LEFT_RECT_W - MIN_LEFT_RECT_W)
                         * ((interpolatedTime - 0.84f) / 0.16f);
             mRightRectWidth =
                 CONST_RIGHT_RECT_W
                     + (MAX_RIGHT_RECT_W - CONST_RIGHT_RECT_W)
                         * (1 - ((interpolatedTime - 0.84f) / 0.16f));
             invalidate();
           }
         }
       };
   tickAnim.setDuration(750);
   tickAnim.setStartOffset(100);
   startAnimation(tickAnim);
 }
  /**
   * Create a pair of {@link FlipAnimation} that can be used to flip 3D transition from {@code
   * fromView} to {@code toView}. A typical use case is with {@link ViewAnimator} as an out and in
   * transition.
   *
   * <p>NOTE: Avoid using this method. Instead, use {@link #flipTransition}.
   *
   * @param fromView the view transition away from
   * @param toView the view transition to
   * @param dir the flip direction
   * @param duration the transition duration in milliseconds
   * @param interpolator the interpolator to use (pass {@code null} to use the {@link
   *     AccelerateInterpolator} interpolator)
   * @return
   */
  public static Animation[] flipAnimation(
      final View fromView, final View toView, FlipDirection dir, long duration) {

    Animation[] result = new Animation[2];
    float centerY;

    centerY = fromView.getHeight() / 2.0f;

    Animation outFlip =
        new FlipAnimation(
            dir.getStartDegreeForFirstView(),
            dir.getEndDegreeForFirstView(),
            true,
            centerY,
            dir,
            fromView.getWidth());
    outFlip.setDuration(duration);
    outFlip.setFillAfter(true);
    outFlip.setInterpolator(new AccelerateInterpolator());

    AnimationSet outAnimation = new AnimationSet(true);
    outAnimation.addAnimation(outFlip);
    result[0] = outAnimation;

    Animation inFlip =
        new FlipAnimation(
            dir.getStartDegreeForSecondView(),
            dir.getEndDegreeForSecondView(),
            false,
            centerY,
            dir,
            fromView.getWidth());
    inFlip.setDuration(duration);
    inFlip.setFillAfter(true);
    inFlip.setInterpolator(new DecelerateInterpolator());
    inFlip.setStartOffset(duration);

    AnimationSet inAnimation = new AnimationSet(true);
    inAnimation.addAnimation(inFlip);
    result[1] = inAnimation;

    return result;
  }
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    profilePictures = new ArrayList<MLRoundedImageView>();
    views = new ArrayList<View>();
    cardViews = new ArrayList<CardUI>();
    myInflater = inflater;
    scroller = new ScrollView(getActivity().getApplicationContext());
    layout = new LinearLayout(getActivity().getApplicationContext());
    layout.setPadding(0, 5, 0, 5);
    layout.setOrientation(LinearLayout.VERTICAL);

    scroller.addView(layout);
    scroller.setBackgroundColor(Color.parseColor(Utils.BACKGROUND_COLOR));

    users = ItemsData.retrieveUserIdsCurrentlyRenting(getActivity());
    bitmaps = new ArrayList<Bitmap>();
    if (users.size() == 0) {
      CardUI cards = new CardUI(getActivity());
      cards.setPadding(0, 20, 0, 20);
      cards.addCard(new EmptyRentalListCard(getActivity()));
      cards.refresh();
      views.add(cards);
    } else {
      for (User u : users) {
        views.add(createProfile(u));
        views.add(
            createUserRentals(
                ItemsData.retrieveItemsLentByUserId(u.getFacebookId(), getActivity())));
      }
    }
    for (int i = 0; i < views.size(); i++) {
      View v = views.get(i);
      v.setVisibility(LinearLayout.VISIBLE);
      Animation animation = AnimationUtils.loadAnimation(getActivity(), R.animator.fade_in);
      animation.setDuration(300);
      animation.setStartOffset(i * 100);
      v.setAnimation(animation);
      layout.addView(v);
    }

    return scroller;
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE); // 隐藏标题栏
    getWindow()
        .setFlags(
            WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN); // 隐藏状态栏
    setContentView(R.layout.activity_intr_b);
    instance = this;
    image1 = (ImageView) findViewById(R.id.image1);
    image2 = (ImageView) findViewById(R.id.image2);
    image3 = (ImageView) findViewById(R.id.image3);
    image4 = (ImageView) findViewById(R.id.image4);

    leftIn = AnimationUtils.loadAnimation(this, R.anim.left_in);
    topIn = AnimationUtils.loadAnimation(this, R.anim.right_in);
    leftIn.setStartOffset(500);
    leftIn.setAnimationListener(new AAnimationListener(1));
  }
Exemple #25
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.bi_hen5_activity);

    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);

    Uri path = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.hen);
    mediaPlayer = MediaPlayer.create(Bi_Hen_Activity.this, path);
    mediaPlayer.start();

    hen = (ImageView) findViewById(R.id.hen);

    hentext = (ImageView) findViewById(R.id.hentext);

    slidedown = AnimationUtils.loadAnimation(this, R.anim.bi_slidedown);
    slidedown.setStartOffset(2000);
    slidedown.setDuration(2000);

    hen.startAnimation(slidedown);

    mediaPlayer.setOnCompletionListener(
        new OnCompletionListener() {
          @Override
          public void onCompletion(MediaPlayer mp) {
            mediaPlayer.stop();
            mediaPlayer.release();
            slidedown.cancel();
            // after completion of this audio it will switch to eagle activity
            Intent intent = new Intent(Bi_Hen_Activity.this, Bi_Chil_Activity.class);
            intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
            startActivity(intent);
            finish();
          }
        });
  }
Exemple #26
0
  private void prepareAnimation() {
    // Measure
    mPaint.setTextSize(mTextField.getTextSize());
    mPaint.setTypeface(mTextField.getTypeface());
    float mTextWidth = mPaint.measureText(mTextField.getText().toString());

    // See how much functions are needed at all
    mMarqueeNeeded = mTextWidth > getMeasuredWidth();

    mTextDifference = Math.abs((mTextWidth - getMeasuredWidth())) + 5;

    if (BuildConfig.DEBUG) {
      Log.d(TAG, "mTextWidth       : " + mTextWidth);
      Log.d(TAG, "measuredWidth    : " + getMeasuredWidth());
      Log.d(TAG, "mMarqueeNeeded   : " + mMarqueeNeeded);
      Log.d(TAG, "mTextDifference  : " + mTextDifference);
    }

    final int duration = (int) (mTextDifference * mSpeed);

    mMoveTextOut = new TranslateAnimation(0, -mTextDifference, 0, 0);
    mMoveTextOut.setDuration(duration);
    mMoveTextOut.setInterpolator(mInterpolator);
    mMoveTextOut.setFillAfter(true);

    mMoveTextIn = new TranslateAnimation(-mTextDifference, 0, 0, 0);
    mMoveTextIn.setDuration(duration);
    mMoveTextIn.setStartOffset(mAnimationPause);
    mMoveTextIn.setInterpolator(mInterpolator);
    mMoveTextIn.setFillAfter(true);

    mMoveTextOut.setAnimationListener(
        new Animation.AnimationListener() {
          public void onAnimationStart(Animation animation) {
            expandTextView();
          }

          public void onAnimationEnd(Animation animation) {
            if (mCancelled) {
              return;
            }

            mTextField.startAnimation(mMoveTextIn);
          }

          public void onAnimationRepeat(Animation animation) {}
        });

    mMoveTextIn.setAnimationListener(
        new Animation.AnimationListener() {
          public void onAnimationStart(Animation animation) {}

          public void onAnimationEnd(Animation animation) {

            cutTextView();

            if (mCancelled) {
              return;
            }
            startTextFieldAnimation();
          }

          public void onAnimationRepeat(Animation animation) {}
        });
  }
Exemple #27
0
  private void Initialize() {
    _playerID = getIntent().getExtras().getInt(Constants.KEY_PLAYER_ID);
    _playerName = getIntent().getExtras().getString(Constants.KEY_PLAYER_NAME);
    _category = getIntent().getExtras().getInt(Constants.KEY_CATEGORY);
    _category_in = getIntent().getExtras().getString(Constants.KEY_CATEGORY_IN);
    _image = getIntent().getExtras().getInt(Constants.KEY_IMAGE);

    // INTENTS
    intentGame = new Intent(this, Game.class);

    // BUTTONS
    btnAnimals = (Button) findViewById(R.id.btnAnimals);
    btnCartoons = (Button) findViewById(R.id.btnCartoons);
    btnMathematics = (Button) findViewById(R.id.btnMathematics);
    btnShapes = (Button) findViewById(R.id.btnShapes);
    btnColors = (Button) findViewById(R.id.btnColors);
    btnObjects = (Button) findViewById(R.id.btnObjects);
    btnBody = (Button) findViewById(R.id.btnBody);
    btnNurseryRhimes = (Button) findViewById(R.id.btnNurseryRhimes);
    btnObjectsInstruments = (Button) findViewById(R.id.btnObjectsInstruments);

    mpAnimals = MediaPlayer.create(this, R.raw.animals);
    mpCartoons = MediaPlayer.create(this, R.raw.cartoons);
    mpMathematics = MediaPlayer.create(this, R.raw.mathematics);
    mpShapes = MediaPlayer.create(this, R.raw.shapes);
    mpColors = MediaPlayer.create(this, R.raw.colors);
    mpObjects = MediaPlayer.create(this, R.raw.z_objects);
    mpBody = MediaPlayer.create(this, R.raw.z_body);

    // mpNurseryRhimes = MediaPlayer.create(this, R.raw.);
    // mpObjectsInstruments = MediaPlayer.create(this, R.raw.z_body);

    // IMAGE
    ivSubCatImage = (ImageView) findViewById(R.id.ivSubCatImage);

    @SuppressWarnings("unused")
    Typeface fontButton = Typeface.createFromAsset(getAssets(), Constants.FONT_BUTTON);
    // SET BUTTONS's ONCLICKLISTENERS

    Button[] buttons = {
      btnAnimals,
      btnCartoons,
      btnMathematics,
      btnShapes,
      btnColors,
      btnObjects,
      btnBody,
      btnNurseryRhimes,
      btnObjectsInstruments
    };
    for (Button b : buttons) {
      b.setOnClickListener(this);
      b.setTypeface(Typeface.createFromAsset(getAssets(), Constants.FONT_BUTTON));
    }

    anim = new TranslateAnimation(0.0f, 0.0f, -200, 0.0f);
    anim.setDuration(1000);
    anim.setInterpolator(AnimationUtils.loadInterpolator(this, android.R.anim.bounce_interpolator));
    anim.setStartOffset(300);

    // AnimateButtons();

    spTap = new SoundPool(4, AudioManager.STREAM_MUSIC, 0);
    spTapSoundID = spTap.load(this, R.raw.tap, 0);

    // PREFERENCES
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
    sounds = (prefs.getBoolean(Constants.KEY_PREFS_SOUND, true) == false) ? false : true;
  }
Exemple #28
0
 public void animate(View view) {
   Animation animation = new AlphaAnimation(0.0f, 1.0f);
   animation.setDuration(1000);
   animation.setStartOffset(500);
   view.startAnimation(animation);
 }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    final Intent callingIntent = getIntent();
    mAnimationType = callingIntent.getIntExtra("animation", KYLE_DEATH);

    if (mAnimationType == KYLE_DEATH) {
      setContentView(R.layout.animation_player);

      ImageView canvasImage = (ImageView) findViewById(R.id.animation_canvas);
      canvasImage.setImageResource(R.anim.kyle_fall);
      mAnimation = (AnimationDrawable) canvasImage.getDrawable();
    } else {
      if (mAnimationType == WANDA_ENDING || mAnimationType == KABOCHA_ENDING) {
        float startX = 0.0f;
        DisplayMetrics metrics = new DisplayMetrics();
        getWindowManager().getDefaultDisplay().getMetrics(metrics);
        if (mAnimationType == WANDA_ENDING) {
          setContentView(R.layout.good_ending_animation);
          startX = 200 * metrics.density;
        } else {
          setContentView(R.layout.kabocha_ending_animation);
          startX = -200 * metrics.density;
        }

        // HACK
        // The TranslateAnimation system doesn't support device independent
        // pixels. So for the Wanda ending and Kabocha endings, in which the
        // game over text scrolls in horizontally, compute the size based on
        // the actual density of the display and just generate the anim in
        // code.  The Rokudou animation can be safely loaded from a file.
        Animation gameOverAnim = new TranslateAnimation(startX, 0, 0, 0);
        gameOverAnim.setDuration(6000);
        gameOverAnim.setFillAfter(true);
        gameOverAnim.setFillEnabled(true);
        gameOverAnim.setStartOffset(8000);

        View background = findViewById(R.id.animation_background);
        View foreground = findViewById(R.id.animation_foreground);
        View gameOver = findViewById(R.id.game_over);

        Animation foregroundAnim =
            AnimationUtils.loadAnimation(this, R.anim.horizontal_layer2_slide);
        Animation backgroundAnim =
            AnimationUtils.loadAnimation(this, R.anim.horizontal_layer1_slide);

        background.startAnimation(backgroundAnim);
        foreground.startAnimation(foregroundAnim);
        gameOver.startAnimation(gameOverAnim);

        mAnimationEndTime = gameOverAnim.getDuration() + System.currentTimeMillis();
      } else if (mAnimationType == ROKUDOU_ENDING) {
        setContentView(R.layout.rokudou_ending_animation);
        View background = findViewById(R.id.animation_background);
        View sphere = findViewById(R.id.animation_sphere);
        View cliffs = findViewById(R.id.animation_cliffs);
        View rokudou = findViewById(R.id.animation_rokudou);
        View gameOver = findViewById(R.id.game_over);

        Animation backgroundAnim = AnimationUtils.loadAnimation(this, R.anim.rokudou_slide_bg);
        Animation sphereAnim = AnimationUtils.loadAnimation(this, R.anim.rokudou_slide_sphere);
        Animation cliffsAnim = AnimationUtils.loadAnimation(this, R.anim.rokudou_slide_cliffs);
        Animation rokudouAnim = AnimationUtils.loadAnimation(this, R.anim.rokudou_slide_rokudou);
        Animation gameOverAnim = AnimationUtils.loadAnimation(this, R.anim.rokudou_game_over);

        background.startAnimation(backgroundAnim);
        sphere.startAnimation(sphereAnim);
        cliffs.startAnimation(cliffsAnim);
        rokudou.startAnimation(rokudouAnim);
        gameOver.startAnimation(gameOverAnim);
        mAnimationEndTime = gameOverAnim.getDuration() + System.currentTimeMillis();
      } else {
        assert false;
      }
    }
    // Pass the calling intent back so that we can figure out which animation just played.
    setResult(RESULT_OK, callingIntent);
  }
  public View getView(int position, View convertView, ViewGroup parent) {
    NodeViewHolder holder;

    if (convertView == null) {
      // ProgressBar sfumata
      final ShapeDrawable pgDrawable =
          new ShapeDrawable(new RoundRectShape(Constants.roundedCorners, null, null));
      final LinearGradient gradient =
          new LinearGradient(
              0,
              0,
              250,
              0,
              context.getResources().getColor(color.aa_red),
              context.getResources().getColor(color.aa_green),
              android.graphics.Shader.TileMode.CLAMP);

      convertView = mInflater.inflate(R.layout.listview, parent, false);
      holder = new NodeViewHolder();
      holder.text = (TextView) convertView.findViewById(R.id.TextView01);
      holder.textTyp = (TextView) convertView.findViewById(R.id.TextViewTypicals);
      holder.textHlt = (TextView) convertView.findViewById(R.id.TextViewHealth);
      holder.image = (ImageView) convertView.findViewById(R.id.node_icon);
      holder.hlt = (ProgressBar) convertView.findViewById(R.id.progressBarHealth);
      holder.hlt.setIndeterminate(false);
      holder.hlt.setMax(50);
      holder.hlt.setProgress(20);
      holder.hlt.setProgress(0);
      holder.hlt.setMax((int) Constants.MAX_HEALTH);
      holder.hlt.setBackgroundResource(android.R.drawable.progress_horizontal);
      holder.imageRes = nodi[position].getIconResourceId();
      // pgDrawable.getPaint().setStrokeWidth(3);
      pgDrawable.getPaint().setDither(true);
      pgDrawable.getPaint().setShader(gradient);

      ClipDrawable progress = new ClipDrawable(pgDrawable, Gravity.LEFT, ClipDrawable.HORIZONTAL);

      // Rect bounds = holder.hlt.getProgressDrawable().getBounds();
      holder.hlt.setProgressDrawable(progress);
      // holder.hlt.getProgressDrawable().setBounds(bounds);

      convertView.setTag(holder);
    } else {

      holder = (NodeViewHolder) convertView.getTag();
      // ClipDrawable progress = new ClipDrawable(pgDrawable,
      // Gravity.LEFT, ClipDrawable.HORIZONTAL);
      // holder.hlt.setProgressDrawable(progress);
    }
    holder.text.setText(nodi[position].getNiceName());
    // holder.text.setTextAppearance(context, R.style.CodeFontTitle);

    // Progress = health
    holder.hlt.setProgress(0);
    holder.hlt.setProgress(nodi[position].getHealth());
    /* Dimensioni del testo settate dalle opzioni */
    // holder.textTyp.setTextSize(TypedValue.COMPLEX_UNIT_SP,holder.textTyp.getTextSize()
    // + opzioni.getListDimensTesto());
    // holder.textTyp.setTextAppearance(context, R.style.CodeFontMain);

    holder.textTyp.setText(
        nodi[position].getActiveTypicals().size()
            + " "
            + context.getString(R.string.manual_typicals)
            + " - "
            + context.getString(R.string.update)
            + " "
            + Constants.getTimeAgo(nodi[position].getRefreshedAt()));

    if (opzioni.isLightThemeSelected()) {
      holder.textTyp.setTextColor(context.getResources().getColor(R.color.black));
      holder.text.setTextColor(context.getResources().getColor(R.color.black));
      holder.textHlt.setTextColor(context.getResources().getColor(R.color.black));
    }

    /* Icona del nodo */
    holder.image.setImageResource(holder.imageRes);

    if (opzioni.getTextFx()) {
      Animation a2 = AnimationUtils.loadAnimation(context, R.anim.alpha);
      a2.reset();
      // a2.setStartTime(System.currentTimeMillis() + 400 * position);
      a2.setStartOffset(250 * position);
      // Animazione immagine holder.image.clearAnimation();
      holder.image.startAnimation(a2);
      // holder.text.clearAnimation();
      // holder.text.startAnimation(a2);
    }

    holder.data = nodi[position];

    return convertView;
  }