Skip to content

Commit

Permalink
3rd sample
Browse files Browse the repository at this point in the history
  • Loading branch information
ozodrukh committed May 30, 2015
1 parent 2fed5f9 commit 25aeca5
Show file tree
Hide file tree
Showing 7 changed files with 122 additions and 7 deletions.
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
</activity>

<activity android:name=".Sample2Activity" />
<activity android:name=".Sample3Activity" />
</application>

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -324,12 +324,19 @@ public boolean onCreateOptionsMenu(Menu menu) {

@Override
public boolean onOptionsItemSelected(MenuItem item) {
Intent intent = null;

switch (item.getItemId()){
case R.id.sampl2:
Intent intent = new Intent(this, Sample2Activity.class);
startActivity(intent);
return true;
intent = new Intent(this, Sample2Activity.class);
break;

case R.id.sampl3:
intent = new Intent(this, Sample3Activity.class);
break;
}
return super.onOptionsItemSelected(item);

startActivity(intent);
return intent != null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ interface Creation{
SupportAnimator create(View view, Rect bounds);
}

static float hypo(float a, float b){
public static float hypo(float a, float b){
return (float) Math.sqrt( Math.pow(a, 2) + Math.pow(b, 2) );
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package io.codetail.circualrevealsample;

import android.graphics.Rect;
import android.os.Build;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.view.ViewTreeObserver;
import android.view.animation.AccelerateDecelerateInterpolator;

import io.codetail.animation.SupportAnimator;
import io.codetail.animation.ViewAnimationUtils;

public class Sample3Activity extends AppCompatActivity
implements ViewTreeObserver.OnGlobalLayoutListener{

private CardViewPlus mContentView;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sample_3);

mContentView = (CardViewPlus) findViewById(R.id.content);

getViewTreeObserver().addOnGlobalLayoutListener(this);
}

protected View getRootView(){
return mContentView;
}

protected ViewTreeObserver getViewTreeObserver(){
return getRootView().getViewTreeObserver();
}

protected void startRevealTransition(){
final Rect bounds = new Rect();
getRootView().getHitRect(bounds);
SupportAnimator animator = ViewAnimationUtils.createCircularReveal(getRootView(),
bounds.right, bounds.bottom, 0, Sample2Activity.hypo(bounds.height(), bounds.width()));
animator.setDuration(1000);
animator.setInterpolator(new AccelerateDecelerateInterpolator());
animator.start();
}

@Override
public void onGlobalLayout() {
if(Build.VERSION.SDK_INT >= 16) {
getViewTreeObserver().removeOnGlobalLayoutListener(this);
}else{
getViewTreeObserver().removeGlobalOnLayoutListener(this);
}

startRevealTransition();
}
}
47 changes: 47 additions & 0 deletions app/src/main/res/layout/activity_sample_3.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?xml version="1.0" encoding="utf-8"?>
<io.codetail.widget.RevealFrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">

<io.codetail.circualrevealsample.CardViewPlus
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/content"
style="@style/CardView"
app:cardElevation="2dp"
app:cardPreventCornerOverlap="false"
app:cardUseCompatPadding="true"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center_horizontal">

<io.codetail.circualrevealsample.CardViewPlus
app:cardBackgroundColor="?colorPrimary"
android:layout_width="match_parent"
android:layout_height="112dp" />

<io.codetail.circualrevealsample.CardViewPlus
android:layout_width="300dp"
android:layout_height="200dp"
android:layout_marginTop="146dp"
android:layout_gravity="center_horizontal"
/>

<io.codetail.circualrevealsample.CardViewPlus
android:layout_width="300dp"
android:layout_height="200dp"
android:layout_marginTop="354dp"
android:layout_gravity="center_horizontal"
/>

<android.support.design.widget.FloatingActionButton
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_gravity="right"
android:layout_marginRight="16dp"
android:layout_marginTop="86dp"
/>

</io.codetail.circualrevealsample.CardViewPlus>

</io.codetail.widget.RevealFrameLayout>
5 changes: 5 additions & 0 deletions app/src/main/res/menu/menu_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,9 @@
android:title="Sample2"
android:orderInCategory="100"
app:showAsAction="never" />

<item android:id="@+id/sampl3"
android:title="Sample2"
android:orderInCategory="100"
app:showAsAction="never" />
</menu>
2 changes: 0 additions & 2 deletions app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
<attr name="actionColor" format="color" />
</declare-styleable>



<declare-styleable name="FrameLayoutCompat">
<!-- Defines the drawable to draw over the content. This can be used as an overlay.
The foreground drawable participates in the padding of the content if the gravity
Expand Down

0 comments on commit 25aeca5

Please sign in to comment.