This repository has been archived by the owner on Feb 8, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 254
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
florent champigny
committed
Feb 20, 2017
1 parent
d9e6a73
commit 4d0458e
Showing
68 changed files
with
2,709 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
apply plugin: 'com.android.application' | ||
|
||
android { | ||
compileSdkVersion project.sdk | ||
buildToolsVersion project.buildTools | ||
|
||
defaultConfig { | ||
minSdkVersion project.minSdk | ||
targetSdkVersion project.sdk | ||
|
||
applicationId "com.github.florent37.expectanim.sample" | ||
|
||
versionCode 1 | ||
versionName "1.0" | ||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" | ||
} | ||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
compile 'com.android.support:appcompat-v7:' + project.supportVersion | ||
compile 'com.android.support:cardview-v7:' + project.supportVersion | ||
|
||
compile 'com.jakewharton:butterknife:8.5.1' | ||
annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1' | ||
|
||
compile project(":expectanim") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Add project specific ProGuard rules here. | ||
# By default, the flags in this file are appended to flags specified | ||
# in /Users/florentchampigny/Library/Android/sdk/tools/proguard/proguard-android.txt | ||
# You can edit the include path and order by changing the proguardFiles | ||
# directive in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# Add any project specific keep options here: | ||
|
||
# If your project uses WebView with JS, uncomment the following | ||
# and specify the fully qualified class name to the JavaScript interface | ||
# class: | ||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
# public *; | ||
#} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.github.florent37.expectanim.sample"> | ||
|
||
<application | ||
android:allowBackup="true" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:supportsRtl="true" | ||
android:theme="@style/AppTheme"> | ||
<activity android:name=".MainActivity"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
</application> | ||
|
||
</manifest> |
127 changes: 127 additions & 0 deletions
127
app/src/main/java/com/github/florent37/expectanim/sample/MainActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
package com.github.florent37.expectanim.sample; | ||
|
||
import android.os.Bundle; | ||
import android.support.v4.widget.NestedScrollView; | ||
import android.support.v7.app.AppCompatActivity; | ||
import android.view.Gravity; | ||
import android.view.View; | ||
|
||
import com.github.florent37.expectanim.ExpectAnim; | ||
|
||
import butterknife.BindDimen; | ||
import butterknife.BindView; | ||
import butterknife.ButterKnife; | ||
import butterknife.OnClick; | ||
|
||
import static com.github.florent37.expectanim.core.Expectations.alphaValue; | ||
import static com.github.florent37.expectanim.core.Expectations.atHisOriginalPosition; | ||
import static com.github.florent37.expectanim.core.Expectations.atHisOriginalScale; | ||
import static com.github.florent37.expectanim.core.Expectations.height; | ||
import static com.github.florent37.expectanim.core.Expectations.leftOfParent; | ||
import static com.github.florent37.expectanim.core.Expectations.rightOfParent; | ||
import static com.github.florent37.expectanim.core.Expectations.sameCenterVerticalAs; | ||
import static com.github.florent37.expectanim.core.Expectations.scale; | ||
import static com.github.florent37.expectanim.core.Expectations.toRightOf; | ||
import static com.github.florent37.expectanim.core.Expectations.topOfParent; | ||
import static com.github.florent37.expectanim.core.Expectations.visible; | ||
|
||
|
||
public class MainActivity extends AppCompatActivity { | ||
|
||
@BindView(R.id.username) | ||
View username; | ||
@BindView(R.id.avatar) | ||
View avatar; | ||
@BindView(R.id.follow) | ||
View follow; | ||
@BindView(R.id.background) | ||
View backbground; | ||
|
||
@BindView(R.id.scrollview) | ||
NestedScrollView scrollView; | ||
|
||
@BindDimen(R.dimen.height) | ||
int height; | ||
|
||
private ExpectAnim expectAnimMove; | ||
private ExpectAnim expectAnimReset; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_main); | ||
ButterKnife.bind(this); | ||
|
||
this.expectAnimMove = new ExpectAnim() | ||
.expect(username) | ||
.toBe( | ||
toRightOf(avatar).withMarginDp(16), | ||
sameCenterVerticalAs(avatar), | ||
|
||
alphaValue(0.5f) | ||
) | ||
|
||
.andExpect(avatar) | ||
.toBe( | ||
topOfParent(), | ||
leftOfParent().withMarginDp(16), | ||
scale(0.5f, 0.5f) | ||
) | ||
.andExpect(follow) | ||
.toBe( | ||
rightOfParent().withMarginDp(16), | ||
sameCenterVerticalAs(avatar) | ||
) | ||
|
||
.andExpect(backbground) | ||
.toBe( | ||
height(height).withGravity(Gravity.LEFT, Gravity.TOP) | ||
) | ||
|
||
.toAnimation(); | ||
|
||
this.expectAnimReset = new ExpectAnim() | ||
.expect(username) | ||
.toBe( | ||
atHisOriginalPosition(), | ||
visible() | ||
) | ||
|
||
.andExpect(avatar) | ||
.toBe( | ||
atHisOriginalPosition(), | ||
atHisOriginalScale() | ||
) | ||
|
||
.andExpect(follow) | ||
.toBe( | ||
atHisOriginalPosition() | ||
) | ||
|
||
.andExpect(backbground) | ||
.toBe( | ||
atHisOriginalScale() | ||
) | ||
|
||
.toAnimation(); | ||
|
||
scrollView.setOnScrollChangeListener(new NestedScrollView.OnScrollChangeListener() { | ||
@Override | ||
public void onScrollChange(NestedScrollView v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) { | ||
final float percent = (scrollY * 1f) / v.getMaxScrollAmount(); | ||
expectAnimMove.setPercent(percent); | ||
} | ||
}); | ||
} | ||
|
||
@OnClick(R.id.move) | ||
public void onMoveClicked() { | ||
expectAnimMove.start(); | ||
} | ||
|
||
@OnClick(R.id.reset) | ||
public void onResetClicked() { | ||
expectAnimReset.start(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<shape xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:shape="oval"> | ||
<solid android:color="@color/colorAccent"/> | ||
</shape> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:id="@+id/activity_main" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
tools:context="com.github.florent37.expectanim.sample.MainActivity"> | ||
|
||
<Button | ||
android:id="@+id/move" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_alignParentBottom="true" | ||
android:text="move" /> | ||
|
||
<Button | ||
android:id="@+id/reset" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_alignParentBottom="true" | ||
android:layout_alignParentRight="true" | ||
android:text="reset" /> | ||
|
||
<android.support.v4.widget.NestedScrollView | ||
android:id="@+id/scrollview" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent"> | ||
|
||
<LinearLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:orientation="vertical"> | ||
|
||
<View | ||
android:layout_width="0dp" | ||
android:layout_height="200dp" /> | ||
|
||
<TextView | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_gravity="center_horizontal" | ||
android:layout_marginTop="10dp" | ||
android:text="scroll" /> | ||
|
||
<include layout="@layout/cell"/> | ||
<include layout="@layout/cell"/> | ||
<include layout="@layout/cell"/> | ||
<include layout="@layout/cell"/> | ||
<include layout="@layout/cell"/> | ||
<include layout="@layout/cell"/> | ||
<include layout="@layout/cell"/> | ||
<include layout="@layout/cell"/> | ||
<include layout="@layout/cell"/> | ||
<include layout="@layout/cell"/> | ||
<include layout="@layout/cell"/> | ||
<include layout="@layout/cell"/> | ||
<include layout="@layout/cell"/> | ||
|
||
</LinearLayout> | ||
|
||
</android.support.v4.widget.NestedScrollView> | ||
|
||
<FrameLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="200dp"> | ||
|
||
<View | ||
android:id="@+id/background" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:background="@android:color/white" | ||
android:elevation="4dp"/> | ||
</FrameLayout> | ||
|
||
<LinearLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="200dp" | ||
android:gravity="center" | ||
android:orientation="vertical" | ||
android:layout_alignParentTop="true" | ||
android:layout_alignParentLeft="true" | ||
android:layout_alignParentStart="true" | ||
android:elevation="4dp"> | ||
|
||
<View | ||
android:id="@+id/avatar" | ||
android:layout_width="100dp" | ||
android:layout_height="100dp" | ||
android:layout_above="@+id/username" | ||
android:layout_centerHorizontal="true" | ||
android:layout_marginBottom="10dp" | ||
android:background="@drawable/circle" | ||
android:gravity="center" /> | ||
|
||
<TextView | ||
android:id="@+id/username" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_centerInParent="true" | ||
android:text="Username" /> | ||
|
||
<TextView | ||
android:id="@+id/follow" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginTop="16dp" | ||
android:text="follow" | ||
android:textAllCaps="true" | ||
android:textColor="@color/colorAccent" /> | ||
|
||
</LinearLayout> | ||
|
||
</RelativeLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
android:orientation="vertical" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent"> | ||
|
||
<android.support.v7.widget.CardView | ||
android:layout_width="match_parent" | ||
android:layout_height="150dp" | ||
android:layout_margin="10dp" | ||
app:cardMaxElevation="4dp" | ||
app:cardBackgroundColor="@android:color/white" | ||
/> | ||
|
||
</FrameLayout> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<resources> | ||
<!-- Example customization of dimensions originally defined in res/values/dimens.xml | ||
(such as screen margins) for screens with more than 820dp of available width. This | ||
would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). --> | ||
<dimen name="activity_horizontal_margin">64dp</dimen> | ||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<color name="colorPrimary">#3F51B5</color> | ||
<color name="colorPrimaryDark">#303F9F</color> | ||
<color name="colorAccent">#FF4081</color> | ||
</resources> |
Oops, something went wrong.