Skip to content

Commit

Permalink
Animate scan button appearance
Browse files Browse the repository at this point in the history
  • Loading branch information
ViliusKraujutis committed Mar 29, 2014
1 parent ef5c213 commit 2cd23df
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 0 deletions.
6 changes: 6 additions & 0 deletions app/src/main/java/lt/andro/maistobankas/MainFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import lt.andro.maistobankas.db.ScannedItem;
import lt.andro.maistobankas.util.ScanUtil;

import static android.view.animation.AnimationUtils.loadAnimation;

/**
* A placeholder fragment containing a simple view.
*/
Expand Down Expand Up @@ -53,6 +55,9 @@ public void onResume() {
} catch (SQLException e) {
e.printStackTrace();
}

final View buttonScan = getView().findViewById(R.id.buttonScan);
buttonScan.startAnimation(loadAnimation(getActivity(), R.anim.scan_button_show));
}

private void showScannedItems(List<ScannedItem> scannedItems) {
Expand Down Expand Up @@ -83,6 +88,7 @@ public boolean onOptionsItemSelected(MenuItem item) {
if (id == R.id.action_settings) {
getActivity().getSupportFragmentManager().beginTransaction()
.replace(R.id.container, new ShopInformationFragment())
.addToBackStack("Settings")
.commit();
return true;
}
Expand Down
81 changes: 81 additions & 0 deletions app/src/main/res/anim/scan_button_show.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<?xml version="1.0" encoding="utf-8"?>

<set xmlns:android="http://schemas.android.com/apk/res/android"
android:ordering="sequentially"
android:shareInterpolator="false">

<set
android:interpolator="@android:anim/decelerate_interpolator">
<alpha
android:interpolator="@android:anim/accelerate_decelerate_interpolator"
android:fromAlpha="0"
android:toAlpha="1"
android:duration="400" />
</set>

<scale
android:fromXScale="1"
android:toXScale="1.1"
android:fromYScale="1"
android:toYScale="1.1"
android:pivotX="50%"
android:pivotY="50%"
android:startOffset="400"
android:duration="200"
android:fillBefore="false" />

<scale
android:fromXScale="1.1"
android:toXScale="1"
android:fromYScale="1.1"
android:toYScale="1"
android:pivotX="50%"
android:pivotY="50%"
android:startOffset="600"
android:duration="200"
android:fillBefore="false" />

<scale
android:fromXScale="1"
android:toXScale="1.1"
android:fromYScale="1"
android:toYScale="1.1"
android:pivotX="50%"
android:pivotY="50%"
android:startOffset="800"
android:duration="200"
android:fillBefore="false" />

<scale
android:fromXScale="1.1"
android:toXScale="1"
android:fromYScale="1.1"
android:toYScale="1"
android:pivotX="50%"
android:pivotY="50%"
android:startOffset="1000"
android:duration="200"
android:fillBefore="false" />

<scale
android:fromXScale="1"
android:toXScale="1.1"
android:fromYScale="1"
android:toYScale="1.1"
android:pivotX="50%"
android:pivotY="50%"
android:startOffset="1200"
android:duration="200"
android:fillBefore="false" />

<scale
android:fromXScale="1.1"
android:toXScale="1"
android:fromYScale="1.1"
android:toYScale="1"
android:pivotX="50%"
android:pivotY="50%"
android:startOffset="1400"
android:duration="200"
android:fillBefore="false" />
</set>

1 comment on commit 2cd23df

@ViliusKraujutis
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now it looks like this:
2014-03-29 14 37 12

Please sign in to comment.