Ejemplo n.º 1
0
  /** Some simple animations run on user login */
  private void animateUserWelcome() {
    mUserImage.setImageResource(mCurrentUser.getUserImageResource());

    ViewUtils.setScale(mUserImage, 1);
    ScaleAnimation scale_in =
        new ScaleAnimation(
            0f, 1f, 0f, 1f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
    scale_in.setDuration(1000);
    scale_in.setFillAfter(true);
    scale_in.setInterpolator(new DecelerateInterpolator());
    mUserImage.startAnimation(scale_in);

    final long button_scale_time = 1000;
    final long button_scale_increment_time = 250;

    // Animate the buttons coming in
    ViewUtils.animateButtonShow(
        mLitterButton, button_scale_time + (button_scale_increment_time * 0));
    ViewUtils.animateButtonShow(
        mSearchButton, button_scale_time + (button_scale_increment_time * 1));
    ViewUtils.animateButtonShow(
        mFollowersButton, button_scale_time + (button_scale_increment_time * 2));
    ViewUtils.animateButtonShow(
        mSettingsButton, button_scale_time + (button_scale_increment_time * 3));

    // Make the background of the button bar visible
    mButtonBar.setAlpha(1);
  }
Ejemplo n.º 2
0
 /** 初始化闪屏页的动画方法 */
 private void initAnimotion() {
   // 设置动画集合
   set = new AnimationSet(false);
   // 旋转动画
   RotateAnimation rotate =
       new RotateAnimation(
           0, 360, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
   rotate.setDuration(1000);
   rotate.setFillAfter(true); // 设置动画结束后保持原状
   // 缩放动画
   ScaleAnimation scale =
       new ScaleAnimation(
           0, 1, 0, 1, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
   scale.setDuration(1000);
   scale.setFillAfter(true); // 设置动画结束后保持原状
   // 渐变动画
   AlphaAnimation alpha = new AlphaAnimation(0, 1);
   alpha.setDuration(3000);
   alpha.setFillAfter(true); // 设置动画结束后保持原状
   // 添加到动画集合中
   set.addAnimation(rotate);
   set.addAnimation(scale);
   set.addAnimation(alpha);
   rl_spalash.startAnimation(set);
 }
Ejemplo n.º 3
0
 /**
  * 以中心为缩放中心 的缩放动画
  *
  * @param v 执行动画的view
  * @param fromX
  * @param toX
  * @param fromY
  * @param toY
  * @param fillAfter
  * @param durationMillis
  * @return 返回 动画对象
  */
 public static ScaleAnimation scacle(
     View v,
     float fromX,
     float toX,
     float fromY,
     float toY,
     boolean fillAfter,
     long durationMillis) {
   if (sa == null) {
     sa =
         new ScaleAnimation(
             fromX,
             toX,
             fromY,
             toY,
             Animation.RELATIVE_TO_SELF,
             0.5f,
             Animation.RELATIVE_TO_SELF,
             0.5f);
   }
   sa.setFillAfter(fillAfter);
   sa.setDuration(durationMillis);
   v.startAnimation(sa);
   return sa;
 }
 public ScaleAnimation getScaleHeightAnimation(float start, float end) {
   ScaleAnimation animation = new ScaleAnimation(1.0f, 1.0f, start, end);
   animation.setDuration(1000);
   animation.setFillAfter(true);
   animation.setFillEnabled(true);
   animation.setFillBefore(true);
   return animation;
 }
Ejemplo n.º 5
0
 /** Animation for the logo on app launch */
 private void animateLogoIn() {
   ScaleAnimation fade_in =
       new ScaleAnimation(
           0f, 1f, 0f, 1f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
   fade_in.setDuration(750);
   fade_in.setFillAfter(true);
   fade_in.setInterpolator(new DecelerateInterpolator());
   mGlitterLogo.startAnimation(fade_in);
 }
Ejemplo n.º 6
0
 public Animation createAnimation() {
   ScaleAnimation localScaleAnimation =
       new ScaleAnimation(
           this.fromXScale, this.toXScale, this.fromYScale, this.toYScale, 1, 0.5F, 1, 0.5F);
   localScaleAnimation.setFillAfter(true);
   localScaleAnimation.setInterpolator(new AccelerateInterpolator());
   localScaleAnimation.setDuration(this.duration);
   return localScaleAnimation;
 }
 public static Animation ScaleSmallLeftTop(Interpolator inter) {
   scaleAnim =
       new ScaleAnimation(
           1.0f, 0, 1.0f, 0, Animation.RELATIVE_TO_PARENT, 0, Animation.RELATIVE_TO_PARENT, 0);
   if (inter != null) {
     scaleAnim.setInterpolator(inter);
   }
   scaleAnim.setFillAfter(true);
   scaleAnim.setDuration(animDuration);
   return scaleAnim;
 }
Ejemplo n.º 8
0
  /*
   * 开启动画,旋转,缩放
   */
  private void startAnimation() {

    AnimationSet set = new AnimationSet(false);

    // 旋转动画,以自身的中心点为枢轴,从0旋转到360度
    RotateAnimation rotate =
        new RotateAnimation(
            0, 360, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);

    rotate.setDuration(1000); // 动画持续的时间1s
    rotate.setFillAfter(true); // 是动画在结束之后保持该状态

    // 缩放动画
    ScaleAnimation scale =
        new ScaleAnimation(
            0, 1, 0, 1, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
    scale.setDuration(1000);
    scale.setFillAfter(true);

    // 渐变动画
    AlphaAnimation alpha = new AlphaAnimation(0f, 1f);
    alpha.setDuration(1000);
    alpha.setFillAfter(true);

    set.addAnimation(rotate);
    set.addAnimation(scale);
    set.addAnimation(alpha);

    set.setAnimationListener(
        new AnimationListener() {

          // 动画开始的时候回调
          @Override
          public void onAnimationStart(Animation animation) {}

          // 动画重复播放的时候调用
          @Override
          public void onAnimationRepeat(Animation animation) {}

          // 动画结束的时候调用,去跳转到新手引导的页面
          @Override
          public void onAnimationEnd(Animation animation) {
            /*Intent intent = new Intent(SplashActivity.this,
            		GuideActivity.class);
            startActivity(intent);
            finish();*/
            jumpNextPage();
          }
        });

    rlRoot.startAnimation(set);
  }
Ejemplo n.º 9
0
 private synchronized void scaleSmallView(View v) {
   ScaleAnimation mLitteAnimation =
       new ScaleAnimation(
           1.0f,
           0.9f,
           1.0f,
           0.9f,
           Animation.RELATIVE_TO_SELF,
           0.5f,
           Animation.RELATIVE_TO_SELF,
           0.5f);
   mLitteAnimation.setDuration(animTime);
   mLitteAnimation.setFillAfter(true);
   v.startAnimation(mLitteAnimation);
 }
 public static Animation ScaleToBigVerticalOut(Interpolator inter) {
   scaleAnim =
       new ScaleAnimation(
           1.0f,
           1.0f,
           1.0f,
           0f,
           Animation.RELATIVE_TO_PARENT,
           0f,
           Animation.RELATIVE_TO_PARENT,
           0.5f);
   if (inter != null) {
     scaleAnim.setInterpolator(inter);
   }
   scaleAnim.setFillAfter(true);
   scaleAnim.setDuration(animDuration);
   return scaleAnim;
 }
Ejemplo n.º 11
0
  /** 开启动画 */
  private void startAnim() {
    // 动画集合
    AnimationSet set = new AnimationSet(false);

    // 旋转动画
    RotateAnimation rotate =
        new RotateAnimation(
            0, 360, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
    rotate.setDuration(2000); // 旋转时间
    rotate.setFillAfter(true); // 保持动画状态
    // 缩放动画
    ScaleAnimation scale =
        new ScaleAnimation(
            0, 1, 0, 1, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
    scale.setDuration(2000); // 时间
    scale.setFillAfter(true); // 保持动画状态
    // 渐变动画
    AlphaAnimation alpha = new AlphaAnimation(0, 1);
    alpha.setDuration(2000); // 时间
    alpha.setFillAfter(true); // 保持动画状态

    set.addAnimation(rotate);
    set.addAnimation(scale);
    set.addAnimation(alpha);
    // 设定动画监听
    set.setAnimationListener(
        new Animation.AnimationListener() {
          @Override
          public void onAnimationStart(Animation animation) {}

          @Override
          public void onAnimationEnd(Animation animation) {
            // 动画结束后跳转到GuideActivity中
            jumpNextPage();
          }

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

    rlRoot.startAnimation(set);
  }
Ejemplo n.º 12
0
  private synchronized void scaleBigView(final View v) {
    ScaleAnimation mLitteAnimation =
        new ScaleAnimation(
            0.9f,
            1.0f,
            0.9f,
            1.0f,
            Animation.RELATIVE_TO_SELF,
            0.5f,
            Animation.RELATIVE_TO_SELF,
            0.5f);
    mLitteAnimation.setDuration(animTime);
    mLitteAnimation.setFillAfter(true);
    mLitteAnimation.setAnimationListener(
        new Animation.AnimationListener() {

          @Override
          public void onAnimationStart(Animation animation) {
            // TODO Auto-generated method stub

          }

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

          }

          @Override
          public void onAnimationEnd(Animation animation) {
            // TODO Auto-generated method stub
            //                clickListener.onClick(v);
          }
        });
    v.startAnimation(mLitteAnimation);
  }
Ejemplo n.º 13
0
  private void init() {
    r = new Random();

    // settings
    // setStartOffset(getRandom(3000));
    setInterpolator(new LinearInterpolator());

    // rotate
    RotateAnimation rotateAnimation;
    if (getRandomBoolean()) {
      rotateAnimation =
          new RotateAnimation(
              0f, 359f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
    } else {
      rotateAnimation =
          new RotateAnimation(
              0f, -359f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
    }
    rotateAnimation.setRepeatMode(Animation.RESTART);
    rotateAnimation.setRepeatCount(Animation.INFINITE);
    rotateAnimation.setDuration(getRandom(10000, 13000));
    rotateAnimation.setFillAfter(true);
    this.addAnimation(rotateAnimation);

    // scale
    if (getRandomBoolean()) {
      ScaleAnimation scaleAnimation = new ScaleAnimation(0.4f, 1.2f, 0.4f, 1.2f, 0.5f, 0.5f);
      scaleAnimation.setDuration(getRandom(7500, 10000));
      scaleAnimation.setRepeatMode(Animation.REVERSE);
      scaleAnimation.setRepeatCount(Animation.INFINITE);
      scaleAnimation.setFillAfter(true);
      this.addAnimation(scaleAnimation);
    }

    // x movement
    TranslateAnimation translateAnimationX =
        new TranslateAnimation(
            Animation.ABSOLUTE,
            -100,
            Animation.ABSOLUTE,
            100,
            Animation.ABSOLUTE,
            0,
            Animation.ABSOLUTE,
            0);
    translateAnimationX.setRepeatMode(Animation.REVERSE);
    translateAnimationX.setRepeatCount(Animation.INFINITE);
    translateAnimationX.setDuration(getRandom(8000, 10000));
    translateAnimationX.setFillAfter(true);
    this.addAnimation(translateAnimationX);

    // y movement
    TranslateAnimation translateAnimationY =
        new TranslateAnimation(
            Animation.ABSOLUTE,
            0,
            Animation.ABSOLUTE,
            0,
            Animation.ABSOLUTE,
            0,
            Animation.ABSOLUTE,
            2500);
    translateAnimationY.setRepeatMode(Animation.RESTART);
    translateAnimationY.setRepeatCount(Animation.INFINITE);
    translateAnimationY.setDuration(getRandom(26000, 38000));
    translateAnimationY.setFillAfter(true);
    this.addAnimation(translateAnimationY);
  }
Ejemplo n.º 14
0
  public static void Create(FrameLayout mFrameContainer, Activity activity, int aDelay) {
    Log.d("Python", "ProgressScreen");

    // Compute the width of a carousel item based on the screen width and number of initial items.
    final DisplayMetrics displayMetrics = new DisplayMetrics();
    activity.getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
    final int displayWidth = (int) (displayMetrics.widthPixels);
    final int displayHeight = (int) (displayMetrics.heightPixels);

    // create the linear layout
    mContainer = new RelativeLayout(activity);
    RelativeLayout.LayoutParams params =
        new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
    mContainer.setHorizontalScrollBarEnabled(true);
    mContainer.setLayoutParams(params);
    mContainer.setBackgroundColor(0xFF212121);

    // Set the image view resource
    InputStream is = activity.getClass().getResourceAsStream("/res/welcome.png");
    ImageView imageItem = new ImageView(activity);
    imageItem.setImageDrawable(Drawable.createFromStream(is, ""));
    imageItem.setScaleType(ImageView.ScaleType.CENTER_CROP);
    float fact =
        (float) imageItem.getDrawable().getIntrinsicHeight()
            / (float) imageItem.getDrawable().getIntrinsicWidth();
    imageItem.setLayoutParams(
        new RelativeLayout.LayoutParams(displayWidth, (int) (displayWidth * fact)));
    // imageItem.setLayoutParams(new
    // RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.FILL_PARENT,
    // RelativeLayout.LayoutParams.WRAP_CONTENT));

    /// Add image view to the carousel container
    mContainer.addView(imageItem);

    // Set the image view resource
    InputStream is2 = activity.getClass().getResourceAsStream("/res/progress.png");
    mImageProgress = new ImageView(activity);
    mImageProgress.setImageDrawable(Drawable.createFromStream(is2, ""));
    int w = mImageProgress.getDrawable().getIntrinsicWidth();
    int h = mImageProgress.getDrawable().getIntrinsicHeight();
    RelativeLayout.LayoutParams progressparams = new RelativeLayout.LayoutParams(w, h);
    int maxW = (int) (displayWidth * 0.7);
    progressparams.leftMargin = (int) ((displayWidth - maxW) / 2);
    progressparams.topMargin = (int) (displayHeight * 720 / 1280);
    mImageProgress.setLayoutParams(progressparams);
    /// Add image view to the carousel container
    mContainer.addView(mImageProgress);

    mFrameContainer.addView(mContainer);
    mContainer.bringToFront();

    // Set animation
    ScaleAnimation anim =
        new ScaleAnimation(
            1.0f,
            (float) maxW / (float) w,
            (float) displayWidth / (float) 720,
            (float) displayWidth / (float) 720,
            Animation.RELATIVE_TO_SELF,
            0.0f,
            Animation.RELATIVE_TO_SELF,
            0.0f);
    anim.setDuration(aDelay);
    anim.setFillAfter(true);
    anim.setAnimationListener(
        new AnimationListener() {
          @Override
          public void onAnimationStart(Animation animation) {
            Log.d("Python", "Progress Animation started");
          }

          @Override
          public void onAnimationRepeat(Animation animation) {}

          @Override
          public void onAnimationEnd(Animation animation) {
            Log.d("Python", "Progress Animation ended");
            ProgressScreen.mImageProgress = null;
          }
        });
    mImageProgress.startAnimation(anim);
  }
  private void initAnimation() {

    final ScaleAnimation selfScaleIn =
        new ScaleAnimation(
            2.0f,
            1.0f,
            2.0f,
            1.0f,
            ScaleAnimation.RELATIVE_TO_SELF,
            0.5f,
            ScaleAnimation.RELATIVE_TO_SELF,
            0.5f);
    selfScaleIn.setDuration(200);
    selfScaleIn.setInterpolator(new LinearInterpolator());
    selfScaleIn.setAnimationListener(
        new AnimationListener() {

          @Override
          public void onAnimationStart(Animation arg0) {}

          @Override
          public void onAnimationRepeat(Animation arg0) {}

          @Override
          public void onAnimationEnd(Animation arg0) {
            mPraiseView.postDelayed(
                new Runnable() {

                  @Override
                  public void run() {
                    mPraiseView.startAnimation(outToTop);
                  }
                },
                100);
          }
        });

    final ScaleAnimation selfScaleOut =
        new ScaleAnimation(
            1.0f,
            2.0f,
            1.0f,
            2.0f,
            ScaleAnimation.RELATIVE_TO_SELF,
            0.5f,
            ScaleAnimation.RELATIVE_TO_SELF,
            0.5f);
    selfScaleOut.setDuration(250);
    selfScaleOut.setFillAfter(true);
    selfScaleOut.setInterpolator(new LinearInterpolator());
    selfScaleOut.setAnimationListener(
        new AnimationListener() {

          @Override
          public void onAnimationStart(Animation arg0) {}

          @Override
          public void onAnimationRepeat(Animation arg0) {}

          @Override
          public void onAnimationEnd(Animation arg0) {
            mPraiseView.startAnimation(selfScaleIn);
          }
        });

    comeFromBottom = new AnimationSet(true);
    comeFromBottom.setInterpolator(new LinearInterpolator());

    TranslateAnimation translate_anim_in = new TranslateAnimation(0, 0, mViewHeight / 4, 0);
    AlphaAnimation alpha_anim_in = new AlphaAnimation(0.3f, 1f);

    comeFromBottom.addAnimation(translate_anim_in);
    comeFromBottom.addAnimation(alpha_anim_in);
    comeFromBottom.setDuration(300);
    comeFromBottom.setFillAfter(true);

    comeFromBottom.setAnimationListener(
        new AnimationListener() {
          @Override
          public void onAnimationStart(Animation animation) {
            mPraiseView.setVisibility(View.VISIBLE);
          }

          @Override
          public void onAnimationRepeat(Animation animation) {}

          @Override
          public void onAnimationEnd(Animation animation) {
            mPraiseView.startAnimation(selfScaleOut);
          }
        });

    outToTop = new AnimationSet(true);
    outToTop.setInterpolator(new LinearInterpolator());

    TranslateAnimation translate_anim_out = new TranslateAnimation(0, 0, 0, -mViewHeight / 6);
    AlphaAnimation alpha_anim_out = new AlphaAnimation(1f, 0.3f);

    outToTop.addAnimation(translate_anim_out);
    outToTop.addAnimation(alpha_anim_out);
    outToTop.setDuration(200);
    outToTop.setFillAfter(false);

    outToTop.setAnimationListener(
        new AnimationListener() {

          @Override
          public void onAnimationStart(Animation animation) {}

          @Override
          public void onAnimationRepeat(Animation animation) {}

          @Override
          public void onAnimationEnd(Animation animation) {
            mPraiseView.setVisibility(View.GONE);
          }
        });
  }
  // *************************      Initialize Question       *********************************
  private void initQuestion() {
    Log.i("fullCClassName", className);
    if (numberOfQuestionsRemaining < 1) {
      Intent intent = new Intent(NegativeCoordActivity.this, ResultActivity.class);
      intent.putExtra("Score", scoreTotal);
      intent.putExtra("ClassName", className);
      intent.putExtra("Level", 3);
      startActivity(intent);
      finish();
    } else {

      if (firstQuestion == false) {
        numberOfQuestionsRemaining--;

        Random randScore = new Random();
        int low = 0;
        int high = 0;
        if (seconds <= 5) {
          low = 40;
          high = 50;
        }
        if (seconds > 5 && seconds <= 7) {
          low = 30;
          high = 40;
        }
        if (seconds > 7) {
          low = 10;
          high = 30;
        }
        score = randScore.nextInt(high - low + 1) + low;
        scoreTotal = scoreTotal + score;
        scoreText.setText(Integer.toString(score));
        scoreText.startAnimation(scoreTextAnimmation);
        timerHandler.removeCallbacks(timerRunnable);
      }
      firstQuestion = false;
      seconds = 0;
      timerHandler.postDelayed(timerRunnable, 0);

      ProgressBarAnimation anim =
          new ProgressBarAnimation(scoreBar, scoreBar.getProgress(), scoreTotal);
      anim.setDuration(300);
      scoreBar.startAnimation(anim);

      if (STAR_ONE_ENABLED == 0) {
        if (scoreBar.getProgress() >= (scoreBar.getMax() / 2)) {
          StarView star1 =
              new StarView(
                  this,
                  scoreLayout,
                  new RelativeLayout.LayoutParams(starOne.getWidth(), starOne.getHeight()),
                  starOne);
          scoreLayout.addView(star1);
          star1.translateAndShine(new ImageView(this));
          STAR_ONE_ENABLED = 1;
        }
      }
      if (STAR_TWO_ENABLED == 0) {
        if (scoreBar.getProgress() >= ((scoreBar.getMax() * 1.7) - scoreBar.getMax())) {
          StarView star2 =
              new StarView(
                  this,
                  scoreLayout,
                  new RelativeLayout.LayoutParams(starTwo.getWidth(), starTwo.getHeight()),
                  starTwo);
          scoreLayout.addView(star2);
          star2.translateAndShine(new ImageView(this));
          STAR_TWO_ENABLED = 1;
        }
      }
      if (STAR_THREE_ENABLED == 0) {
        if (scoreBar.getProgress() >= ((scoreBar.getMax() * 1.8) - scoreBar.getMax())) {
          StarView star3 =
              new StarView(
                  this,
                  scoreLayout,
                  new RelativeLayout.LayoutParams(starThree.getWidth(), starThree.getHeight()),
                  starThree);
          scoreLayout.addView(star3);
          star3.translateAndShine(new ImageView(this));
          STAR_THREE_ENABLED = 1;
        }
      }
      // *****  Type of Question  *****

      // Init question
      Random random = new Random();
      int randomCoordX = random.nextInt(8) - 4;
      int randomCoordY = random.nextInt(8) - 4;
      question = new QuestionCoord(randomCoordX, randomCoordY);

      // Move Lines
      if (numberOfQuestionsRemaining > (numberOfQuestions / 2)) {
        marker.setVisibility(View.INVISIBLE);

        // Positive
        questionCoordX.setText(question.getxString());
        questionCoordY.setText(question.getyString());

        currentLineXcoord = 0;
        currentLineYcoord = 0;
        setLinePositions(glv);

        coordNumbersX.setText("x");
        coordNumbersY.setText("y");

      }
      // Drag Number Panels Positive
      else {
        if (numberOfQuestionsRemaining == (numberOfQuestions / 2)) {
          gridLayout.removeView(lineX);
          gridLayout.removeView(lineY);

          questionCoordX.setText("x");
          questionCoordY.setText("y");

          initNumberPadAndAnswePanel();
          initSwitches();
        }

        marker.setVisibility(View.INVISIBLE);

        // Match x&y to question x&y
        AxisX x = null;
        AxisY y = null;
        for (int i = 0; i < glv.getAxisXlines().size(); i++) {
          if (glv.getAxisXlines().get(i).xNumber == question.getXNumber()) {
            x = glv.getAxisXlines().get(i);
          }
          if (glv.getAxisYlines().get(i).yNumber == question.getYNumber()) {
            y = glv.getAxisYlines().get(i);
          }
        }
        marker.setX(((int) x.x) - marker.getWidth() / 2);
        marker.setY(((int) y.y) - marker.getHeight() / 2);
        scaleIn = new ScaleAnimation(0.0f, 1.0f, 0.0f, 1.0f);
        scaleIn.setDuration(300);
        scaleIn.setStartOffset(200);
        scaleIn.setInterpolator(new OvershootInterpolator());
        scaleIn.setFillAfter(true);
        scaleIn.setAnimationListener(
            new AnimationListener() {
              @Override
              public void onAnimationEnd(Animation arg0) {}

              @Override
              public void onAnimationRepeat(Animation animation) {}

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

        coordNumbersX.setText("x");
        coordNumbersY.setText("y");
      }
    }
  }
Ejemplo n.º 17
0
  private void initStartImg() {

    File dir = getFilesDir();

    final File imgFile = new File(dir, "start.jpg");

    if (imgFile.exists()) {
      imgStart.setImageBitmap(BitmapFactory.decodeFile(imgFile.getAbsolutePath()));
    } else {
      imgStart.setImageResource(R.mipmap.splash);

      //            imgStart.setBackgroundResource(R.mipmap.splash);
    }

    // 设置缩放动画

    /**
     * float fromX 动画起始时 X坐标上的伸缩尺寸 float toX 动画结束时 X坐标上的伸缩尺寸 float fromY 动画起始时Y坐标上的伸缩尺寸 float toY
     * 动画结束时Y坐标上的伸缩尺寸 int pivotXType 动画在X轴相对于物件位置类型 float pivotXValue 动画相对于物件的X坐标的开始位置 int
     * pivotYType 动画在Y轴相对于物件位置类型 float pivotYValue 动画相对于物件的Y坐标的开始位置
     */
    ScaleAnimation animation =
        new ScaleAnimation(
            1.0f,
            1.2f,
            1.0f,
            1.2f,
            Animation.RELATIVE_TO_SELF,
            0.5f,
            Animation.RELATIVE_TO_SELF,
            0.5f);

    // 动画执行完后是否停留在执行完的状态
    animation.setFillAfter(true);

    animation.setDuration(4000);

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

            HttpUtils.get(
                Constant.START,
                new AsyncHttpResponseHandler() {
                  @Override
                  public void onSuccess(int i, Header[] headers, byte[] bytes) {

                    try {
                      JSONObject jsonObject = new JSONObject(new String(bytes));

                      String author = jsonObject.getString("text");

                      String imgURL = jsonObject.getString("img");

                      LogUtils.log(author);
                      LogUtils.log(imgURL);
                      tvAuthor.setText(author);

                      HttpUtils.getImage(
                          imgURL,
                          new BinaryHttpResponseHandler() {
                            @Override
                            public void onSuccess(int i, Header[] headers, byte[] bytes) {

                              saveImage(imgFile, bytes);

                              imgStart.setImageBitmap(
                                  BitmapFactory.decodeFile(imgFile.getAbsolutePath()));

                              startActivity();
                            }

                            @Override
                            public void onFailure(
                                int i, Header[] headers, byte[] bytes, Throwable throwable) {
                              startActivity();
                            }
                          });

                    } catch (JSONException e) {
                      e.printStackTrace();
                    }
                  }

                  @Override
                  public void onFailure(
                      int i, Header[] headers, byte[] bytes, Throwable throwable) {}
                });
          }

          @Override
          public void onAnimationEnd(Animation animation) {}

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

    imgStart.setAnimation(animation);
  }