Skip to content

Commit 2d35aae

Browse files
committed
born
0 parents  commit 2d35aae

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+2195
-0
lines changed

.gitignore

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
.gradle
2+
/local.properties
3+
/.idea/workspace.xml
4+
.DS_Store
5+
/build
6+
# built application files
7+
*.apk
8+
*.ap_
9+
10+
# files for the dex VM
11+
*.dex
12+
13+
# Java class files
14+
*.class
15+
.DS_Store
16+
17+
# generated files
18+
bin/
19+
gen/
20+
Wiki/
21+
22+
# Local configuration file (sdk path, etc)
23+
local.properties
24+
25+
# Eclipse project files
26+
.classpath
27+
.project
28+
.settings/
29+
30+
# Proguard folder generated by Eclipse
31+
proguard/
32+
33+
#Android Studio
34+
build/
35+
36+
# Intellij project files
37+
*.iml
38+
*.ipr
39+
*.iws
40+
.idea/
41+
42+
#gradle
43+
.gradle/

app/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

app/build.gradle

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
apply plugin: 'com.android.application'
2+
3+
android {
4+
compileSdkVersion 19
5+
buildToolsVersion "19.1.0"
6+
7+
defaultConfig {
8+
applicationId "daimajia.com.eaing"
9+
minSdkVersion 19
10+
targetSdkVersion 19
11+
versionCode 1
12+
versionName "1.0"
13+
}
14+
buildTypes {
15+
release {
16+
runProguard false
17+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18+
}
19+
}
20+
}
21+
22+
dependencies {
23+
compile fileTree(dir: 'libs', include: ['*.jar'])
24+
compile project(":library")
25+
}

app/proguard-rules.pro

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Add project specific ProGuard rules here.
2+
# By default, the flags in this file are appended to flags specified
3+
# in /Applications/Android Studio.app/sdk/tools/proguard/proguard-android.txt
4+
# You can edit the include path and order by changing the proguardFiles
5+
# directive in build.gradle.
6+
#
7+
# For more details, see
8+
# http://developer.android.com/guide/developing/tools/proguard.html
9+
10+
# Add any project specific keep options here:
11+
12+
# If your project uses WebView with JS, uncomment the following
13+
# and specify the fully qualified class name to the JavaScript interface
14+
# class:
15+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16+
# public *;
17+
#}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package daimajia.com.eaing;
2+
3+
import android.app.Application;
4+
import android.test.ApplicationTestCase;
5+
6+
/**
7+
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
8+
*/
9+
public class ApplicationTest extends ApplicationTestCase<Application> {
10+
public ApplicationTest() {
11+
super(Application.class);
12+
}
13+
}

app/src/main/AndroidManifest.xml

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="daimajia.com.eaing" >
4+
5+
<application
6+
android:allowBackup="true"
7+
android:icon="@drawable/ic_launcher"
8+
android:label="@string/app_name"
9+
android:theme="@style/AppTheme" >
10+
<activity
11+
android:name=".MyActivity"
12+
android:label="@string/app_name" >
13+
<intent-filter>
14+
<action android:name="android.intent.action.MAIN" />
15+
16+
<category android:name="android.intent.category.LAUNCHER" />
17+
</intent-filter>
18+
</activity>
19+
<activity android:name=".ExampleActivity"/>
20+
</application>
21+
22+
</manifest>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
/*
2+
*
3+
* * The MIT License (MIT)
4+
* *
5+
* * Copyright (c) 2014 daimajia
6+
* *
7+
* * Permission is hereby granted, free of charge, to any person obtaining a copy
8+
* * of this software and associated documentation files (the "Software"), to deal
9+
* * in the Software without restriction, including without limitation the rights
10+
* * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
* * copies of the Software, and to permit persons to whom the Software is
12+
* * furnished to do so, subject to the following conditions:
13+
* *
14+
* * The above copyright notice and this permission notice shall be included in all
15+
* * copies or substantial portions of the Software.
16+
* *
17+
* * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
* * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
* * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
* * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
* * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
* * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23+
* * SOFTWARE.
24+
*
25+
*/
26+
27+
package daimajia.com.eaing;
28+
29+
import android.content.Context;
30+
import android.graphics.Canvas;
31+
import android.graphics.Color;
32+
import android.graphics.Paint;
33+
import android.graphics.Path;
34+
import android.util.AttributeSet;
35+
import android.util.DisplayMetrics;
36+
import android.util.TypedValue;
37+
import android.view.View;
38+
39+
import java.util.ArrayList;
40+
41+
public class DrawView extends View{
42+
43+
private Paint mBackgroundPaint = new Paint();
44+
private Paint mLinePaint = new Paint();
45+
private Path path = new Path();
46+
private boolean start = false;
47+
48+
private ArrayList<Float> mHistory = new ArrayList<Float>();
49+
50+
{
51+
mBackgroundPaint.setColor(Color.WHITE);
52+
mLinePaint.setColor(Color.rgb(77,83,96));
53+
mLinePaint.setAntiAlias(true);
54+
mLinePaint.setStrokeWidth((float) 3.0);
55+
mLinePaint.setStyle(Paint.Style.STROKE);
56+
}
57+
public DrawView(Context context) {
58+
super(context);
59+
}
60+
61+
public DrawView(Context context, AttributeSet attrs) {
62+
super(context, attrs);
63+
}
64+
65+
public DrawView(Context context, AttributeSet attrs, int defStyleAttr) {
66+
super(context, attrs, defStyleAttr);
67+
}
68+
69+
@Override
70+
protected void onDraw(Canvas canvas) {
71+
super.onDraw(canvas);
72+
float l = 0;
73+
float t = getHeight() - getPaddingBottom() - dipToPixels(getContext(),217);
74+
float r = getWidth() - getPaddingRight();
75+
float b = getHeight() - dipToPixels(getContext(),60);
76+
canvas.drawRect(l,t,r,b,mLinePaint);
77+
canvas.drawPath(path,mLinePaint);
78+
}
79+
80+
public static float dipToPixels(Context context, float dipValue) {
81+
DisplayMetrics metrics = context.getResources().getDisplayMetrics();
82+
return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dipValue, metrics);
83+
}
84+
85+
public void drawPoint(float time, float duration, float y){
86+
float p = time/duration;
87+
float x = p*getWidth();
88+
float z = getHeight() + y;
89+
if(!start){
90+
path.moveTo(x,z);
91+
start = true;
92+
}
93+
path.lineTo(x,z);
94+
invalidate();
95+
}
96+
97+
public void clear(){
98+
path.reset();
99+
start = false;
100+
invalidate();
101+
}
102+
103+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package daimajia.com.eaing;
2+
3+
import android.content.Context;
4+
import android.view.LayoutInflater;
5+
import android.view.View;
6+
import android.view.ViewGroup;
7+
import android.widget.BaseAdapter;
8+
import android.widget.TextView;
9+
10+
import com.daimajia.easing.BaseEasingMethod;
11+
import com.daimajia.easing.Skill;
12+
13+
public class EasingAdapter extends BaseAdapter {
14+
15+
private Context mContext;
16+
public EasingAdapter(Context context) {
17+
mContext = context;
18+
}
19+
20+
@Override
21+
public int getCount() {
22+
return Skill.values().length;
23+
}
24+
25+
@Override
26+
public Object getItem(int i) {
27+
return Skill.values()[i];
28+
}
29+
30+
@Override
31+
public long getItemId(int i) {
32+
return i;
33+
}
34+
35+
@Override
36+
public View getView(int i, View view, ViewGroup viewGroup) {
37+
Object o = getItem(i);
38+
BaseEasingMethod b = ((Skill)o).getMethod(1000);
39+
int start = b.getClass().getName().lastIndexOf(".") + 1;
40+
String name = b.getClass().getName().substring(start);
41+
View v = LayoutInflater.from(mContext).inflate(R.layout.item,null);
42+
TextView tv = (TextView)v.findViewById(R.id.list_item_text);
43+
tv.setText(name);
44+
v.setTag(o);
45+
return v;
46+
}
47+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
package daimajia.com.eaing;
2+
3+
import android.app.Activity;
4+
import android.content.Context;
5+
import android.os.Bundle;
6+
import android.util.DisplayMetrics;
7+
import android.util.TypedValue;
8+
import android.view.Menu;
9+
import android.view.MenuItem;
10+
import android.view.View;
11+
import android.widget.AdapterView;
12+
import android.widget.ListView;
13+
14+
import com.daimajia.easing.BaseEasingMethod;
15+
import com.daimajia.easing.Glider;
16+
import com.daimajia.easing.Skill;
17+
import com.nineoldandroids.animation.AnimatorSet;
18+
import com.nineoldandroids.animation.ObjectAnimator;
19+
20+
21+
public class MyActivity extends Activity {
22+
23+
private ListView mEasingList;
24+
private EasingAdapter mAdapter;
25+
private View mTarget;
26+
27+
private DrawView mHistory;
28+
29+
@Override
30+
protected void onCreate(Bundle savedInstanceState) {
31+
super.onCreate(savedInstanceState);
32+
setContentView(R.layout.activity_my);
33+
mEasingList = (ListView)findViewById(R.id.easing_list);
34+
mAdapter = new EasingAdapter(this);
35+
mEasingList.setAdapter(mAdapter);
36+
mTarget = findViewById(R.id.target);
37+
mHistory = (DrawView)findViewById(R.id.history);
38+
mEasingList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
39+
@Override
40+
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
41+
mHistory.clear();
42+
Skill s = (Skill)view.getTag();
43+
AnimatorSet set = new AnimatorSet();
44+
mTarget.setTranslationX(0);
45+
mTarget.setTranslationY(0);
46+
set.playTogether(
47+
Glider.glide(s, 1200, ObjectAnimator.ofFloat(mTarget, "translationY", 0, dipToPixels(MyActivity.this, -(160 - 3))),new BaseEasingMethod.EasingListener() {
48+
@Override
49+
public void on(float time, float value, float start, float end, float duration) {
50+
mHistory.drawPoint(time,duration,value - dipToPixels(MyActivity.this,60));
51+
}
52+
})
53+
);
54+
set.setDuration(1200);
55+
set.start();
56+
}
57+
});
58+
59+
}
60+
61+
public static float dipToPixels(Context context, float dipValue) {
62+
DisplayMetrics metrics = context.getResources().getDisplayMetrics();
63+
return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dipValue, metrics);
64+
}
65+
66+
@Override
67+
public boolean onCreateOptionsMenu(Menu menu) {
68+
// Inflate the menu; this adds items to the action bar if it is present.
69+
getMenuInflater().inflate(R.menu.my, menu);
70+
return true;
71+
}
72+
73+
@Override
74+
public boolean onOptionsItemSelected(MenuItem item) {
75+
// Handle action bar item clicks here. The action bar will
76+
// automatically handle clicks on the Home/Up button, so long
77+
// as you specify a parent activity in AndroidManifest.xml.
78+
int id = item.getItemId();
79+
if (id == R.id.action_settings) {
80+
return true;
81+
}
82+
return super.onOptionsItemSelected(item);
83+
}
84+
}
9.18 KB
Loading
5.11 KB
Loading
Loading
18.9 KB
Loading

app/src/main/res/drawable/circle.xml

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
3+
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="oval">
4+
<solid android:color="#E67A77"/>
5+
<size android:height="10dp" android:width="10dp"/>
6+
</shape>

0 commit comments

Comments
 (0)