Skip to content

Commit

Permalink
Fix the progress bar calibration algorithm
Browse files Browse the repository at this point in the history
  • Loading branch information
HotBitmapGG committed Oct 13, 2016
1 parent a2b8920 commit 1e11e74
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 12 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -22,3 +22,5 @@
.idea/vcs.xml

.idea/runConfigurations.xml

projectFilesBackup/.idea/workspace.xml
Expand Up @@ -2,6 +2,7 @@

import android.animation.ArgbEvaluator;
import android.animation.ObjectAnimator;
import android.annotation.SuppressLint;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
Expand All @@ -11,6 +12,8 @@
import android.widget.ImageView;
import android.widget.RelativeLayout;

import java.util.Random;

import io.netopen.hotbitmapgg.view.NewCreditSesameView;

/**
Expand All @@ -29,10 +32,9 @@ public class Fragment1 extends Fragment

private RelativeLayout mLayout;

private ImageView mButton;

private NewCreditSesameView newCreditSesameView;

private Random random = new Random();

public static Fragment1 newInstance()
{
Expand All @@ -43,12 +45,13 @@ public static Fragment1 newInstance()

@Nullable
@Override
@SuppressLint("InflateParams")
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState)
{

View view = inflater.inflate(R.layout.fragment_1, null);
mLayout = (RelativeLayout) view.findViewById(R.id.layout);
mButton = (ImageView) view.findViewById(R.id.btn);
ImageView mButton = (ImageView) view.findViewById(R.id.btn);
newCreditSesameView = (NewCreditSesameView) view.findViewById(R.id.sesame_view);
mLayout.setBackgroundColor(mColors[0]);
mButton.setOnClickListener(new View.OnClickListener()
Expand All @@ -58,7 +61,8 @@ public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
public void onClick(View view)
{

newCreditSesameView.setSesameValues(639);
int i = random.nextInt(950);
newCreditSesameView.setSesameValues(i);
startColorChangeAnim();
}
});
Expand Down
@@ -1,5 +1,6 @@
package io.netopen.hotbitmapgg.creditsesameringview;

import android.annotation.SuppressLint;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
Expand All @@ -8,6 +9,8 @@
import android.view.ViewGroup;
import android.widget.ImageView;

import java.util.Random;

import io.netopen.hotbitmapgg.view.OldCreditSesameView;

/**
Expand All @@ -19,7 +22,7 @@ public class Fragment2 extends Fragment

private OldCreditSesameView oldCreditSesameView;

private ImageView mButton;
private Random random = new Random();

public static Fragment2 newInstance()
{
Expand All @@ -30,20 +33,22 @@ public static Fragment2 newInstance()

@Nullable
@Override
@SuppressLint("InflateParams")
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState)
{

View view = inflater.inflate(R.layout.fragment_2, null);
oldCreditSesameView = (OldCreditSesameView) view.findViewById(R.id.sesame_view);
mButton = (ImageView) view.findViewById(R.id.btn);
ImageView mButton = (ImageView) view.findViewById(R.id.btn);
mButton.setOnClickListener(new View.OnClickListener()
{

@Override
public void onClick(View view)
{

oldCreditSesameView.setSesameValues(639);
int i = random.nextInt(950);
oldCreditSesameView.setSesameValues(i);
}
});

Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Expand Up @@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.3'
classpath 'com.android.tools.build:gradle:2.2.1'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down
Expand Up @@ -437,14 +437,16 @@ public void setSesameValues(int values)
if (values > 550 && values <= 600)
{
sesameLevel = "信用中等";
mTotalAngle = (values - 550) * 120 / 150f + 43;
} else if (values > 600 && values <= 650)
{
sesameLevel = "信用良好";
mTotalAngle = (values - 550) * 120 / 150f + 45;
} else
{
sesameLevel = "信用优秀";
mTotalAngle = (values - 550) * 120 / 150f + 48;
}
mTotalAngle = (values - 550) * 120 / 150f + 43;
evaluationTime = "评估时间:" + getCurrentTime();
} else if (values <= 950)
{
Expand Down
Expand Up @@ -19,7 +19,7 @@
import android.graphics.SweepGradient;
import android.util.AttributeSet;
import android.view.View;
import android.view.animation.BounceInterpolator;
import android.view.animation.AccelerateDecelerateInterpolator;
import android.view.animation.LinearInterpolator;

import java.text.SimpleDateFormat;
Expand Down Expand Up @@ -466,14 +466,16 @@ public void setSesameValues(int num)
if (num > 550 && num <= 600)
{
sesameLevel = "信用中等";
mTotalAngle = (num - 550) * 120 / 150f + 43;
} else if (num > 600 && num <= 650)
{
sesameLevel = "信用良好";
mTotalAngle = (num - 550) * 120 / 150f + 45;
} else
{
sesameLevel = "信用优秀";
mTotalAngle = (num - 550) * 120 / 150f + 48;
}
mTotalAngle = (num - 550) * 120 / 150f + 45;
evaluationTime = "评估时间:" + getCurrentTime();
} else if (num <= 950)
{
Expand All @@ -497,7 +499,7 @@ public void startRotateAnim()
{

ValueAnimator mAngleAnim = ValueAnimator.ofFloat(mCurrentAngle, mTotalAngle);
mAngleAnim.setInterpolator(new BounceInterpolator());
mAngleAnim.setInterpolator(new AccelerateDecelerateInterpolator());
mAngleAnim.setDuration(3000);
mAngleAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener()
{
Expand Down

0 comments on commit 1e11e74

Please sign in to comment.