Skip to content

Commit

Permalink
required min sdk version changed to 15,
Browse files Browse the repository at this point in the history
you can now set custom layer type
  • Loading branch information
ozodrukh committed Jan 1, 2016
1 parent 6dd58c9 commit 318dc9f
Show file tree
Hide file tree
Showing 17 changed files with 242 additions and 321 deletions.
16 changes: 8 additions & 8 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
compileSdkVersion 23
buildToolsVersion "23.0.2"

defaultConfig {
applicationId "io.codetail.circualrevealsample"
minSdkVersion 9
targetSdkVersion 22
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
Expand All @@ -21,10 +21,10 @@ dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':circualreveal')

compile 'com.android.support:appcompat-v7:22.2.0'
compile 'com.android.support:recyclerview-v7:22.2.0'
compile 'com.android.support:cardview-v7:22.2.0'
compile 'com.android.support:design:22.2.0'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:recyclerview-v7:23.1.1'
compile 'com.android.support:cardview-v7:23.1.1'
compile 'com.android.support:design:23.1.1'

compile 'com.jakewharton:butterknife:6.0.0'
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
package io.codetail.circualrevealsample;

import android.animation.Animator;
import android.graphics.Color;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.view.animation.AccelerateDecelerateInterpolator;
import android.widget.FrameLayout;
import android.widget.ImageView;

import io.codetail.animation.ViewAnimationUtils;
import io.codetail.widget.RevealFrameLayout;

import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;

public class FragmentRevealExample extends Fragment {

private Animator mRevealAnimator;

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
final FrameLayout frameLayout = new RevealFrameLayout(getContext());

final FrameLayout content = new FrameLayout(getContext());
content.setBackgroundColor(Color.WHITE);
content.setVisibility(View.INVISIBLE);

frameLayout.addView(content, new FrameLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT));

final ImageView imageView = new ImageView(getContext());
imageView.setImageResource(R.drawable.example_raw_image);

FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(MATCH_PARENT, WRAP_CONTENT);
lp.topMargin = 16;
lp.leftMargin = 16;
lp.rightMargin = 16;
lp.bottomMargin = 16;

content.addView(imageView, lp);

content.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
@Override
public boolean onPreDraw() {
content.getViewTreeObserver().removeOnPreDrawListener(this);
content.setVisibility(View.VISIBLE);

// actually you need to set visibility before stating animation in listener

mRevealAnimator = ViewAnimationUtils.createCircularReveal(content, 0, 0, 0,
MainActivity.hypo(content.getWidth(), content.getHeight()));
mRevealAnimator.setDuration(500);
mRevealAnimator.setStartDelay(100);
mRevealAnimator.setInterpolator(new AccelerateDecelerateInterpolator());
mRevealAnimator.start();
return true;
}
});

return frameLayout;
}

}
37 changes: 16 additions & 21 deletions app/src/main/java/io/codetail/circualrevealsample/MainActivity.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.codetail.circualrevealsample;

import android.animation.ObjectAnimator;
import android.content.Intent;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
Expand All @@ -21,9 +22,6 @@
import android.view.animation.Interpolator;
import android.widget.Toast;

import com.nineoldandroids.animation.ObjectAnimator;
import com.nineoldandroids.view.ViewHelper;

import java.lang.ref.WeakReference;

import butterknife.ButterKnife;
Expand Down Expand Up @@ -62,6 +60,7 @@ protected void onCreate(Bundle savedInstanceState) {
mCardsAdapter = new RecycleAdapter();
mCardsAdapter.setHasStableIds(true);

mCardsGroup.addOnScrollListener(new HideExtraOnScroll(mToolbar));
mCardsGroup.setHasFixedSize(true);
mCardsGroup.setItemViewCacheSize(3);
mCardsGroup.setClipToPadding(false);
Expand Down Expand Up @@ -158,20 +157,6 @@ static float hypo(int a, int b){
return (float) Math.sqrt(Math.pow(a, 2) + Math.pow(b, 2));
}

@Override
protected void onStart() {
super.onStart();
mCardsGroup.setOnScrollListener(new HideExtraOnScroll(mToolbar));
}

@Override
protected void onStop() {
super.onStop();

// Prevent memory leaks, fuck yeah!
mCardsGroup.setOnScrollListener(null);
}

public static class RecycleAdapter extends RecyclerView.Adapter<CardHolder>{

@Override
Expand Down Expand Up @@ -302,14 +287,14 @@ public boolean isVisible(View target){

public void hide(final View target, float distance){
ObjectAnimator animator = ObjectAnimator.ofFloat(target, "translationY",
ViewHelper.getTranslationY(target), distance);
target.getTranslationY(), distance);
animator.setInterpolator(DECELERATE);
animator.start();
}

public void show(final View target){
ObjectAnimator animator = ObjectAnimator.ofFloat(target, "translationY",
ViewHelper.getTranslationY(target), 0f);
target.getTranslationY(), 0f);
animator.setInterpolator(ACCELERATE);
animator.start();
}
Expand All @@ -327,13 +312,23 @@ public boolean onOptionsItemSelected(MenuItem item) {
Intent intent = null;

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

case R.id.sampl3:
case R.id.sample3:
intent = new Intent(this, Sample3Activity.class);
break;

case R.id.sample4:

getSupportFragmentManager()
.beginTransaction()
.add(android.R.id.content, new FragmentRevealExample(), "fragment:reveal")
.addToBackStack("fragment:reveal")
.commit();

return true;
}

startActivity(intent);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
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.ViewTreeObserver.OnPreDrawListener;
import android.view.animation.AccelerateDecelerateInterpolator;

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

public class Sample3Activity extends AppCompatActivity
implements ViewTreeObserver.OnGlobalLayoutListener{
implements OnPreDrawListener{

private CardViewPlus mContentView;

Expand All @@ -23,7 +22,7 @@ protected void onCreate(Bundle savedInstanceState) {

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

getViewTreeObserver().addOnGlobalLayoutListener(this);
getViewTreeObserver().addOnPreDrawListener(this);
}

protected View getRootView(){
Expand All @@ -35,23 +34,19 @@ protected ViewTreeObserver 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()));
getRootView().getRight(), getRootView().getBottom(), 0,
Sample2Activity.hypo(getRootView().getHeight(), getRootView().getWidth()),
View.LAYER_TYPE_SOFTWARE);
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);
}

public boolean onPreDraw() {
getViewTreeObserver().removeOnPreDrawListener(this);
startRevealTransition();
return true;
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions app/src/main/res/drawable/image_borders.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<shape android:shape="rectangle" xmlns:android="http://schemas.android.com/apk/res/android">
<stroke android:width="4dp" android:color="#fff" />
</shape>
9 changes: 7 additions & 2 deletions app/src/main/res/menu/menu_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,18 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" tools:context=".MainActivity">

<item android:id="@+id/sampl2"
<item android:id="@+id/sample2"
android:title="Sample2"
android:orderInCategory="100"
app:showAsAction="never" />

<item android:id="@+id/sampl3"
<item android:id="@+id/sample3"
android:title="Sample2"
android:orderInCategory="100"
app:showAsAction="never" />

<item android:id="@+id/sample4"
android:title="FragmentSample"
android:orderInCategory="100"
app:showAsAction="never" />
</menu>
2 changes: 1 addition & 1 deletion app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
</attr>
<!-- Defines whether the foreground drawable should be drawn inside the padding.
This property is turned on by default. -->
<attr name="foregroundInsidePadding" format="boolean" />
<attr name="foregroundInsidePadding" />
<!-- Determines whether to measure all children or just those in
the VISIBLE or INVISIBLE state when measuring. Defaults to false. -->
<attr name="measureAllChildren" format="boolean" />
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.2.3'
classpath 'com.github.dcendents:android-maven-plugin:1.2'
classpath 'com.android.tools.build:gradle:1.5.0'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
Expand Down
34 changes: 27 additions & 7 deletions circualreveal/build.gradle
Original file line number Diff line number Diff line change
@@ -1,17 +1,37 @@
apply plugin: 'com.android.library'
apply plugin: 'android-maven'
apply plugin: 'com.github.dcendents.android-maven'

android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
compileSdkVersion 23
buildToolsVersion "23.0.2"


defaultConfig {
minSdkVersion 9
targetSdkVersion 22
minSdkVersion 15
targetSdkVersion 23
}
}

dependencies {
compile 'com.nineoldandroids:library:2.4.0'
// build a jar with source files
task sourcesJar(type: Jar) {
from android.sourceSets.main.java.srcDirs
classifier = 'sources'
}

task javadoc(type: Javadoc) {
failOnError false
source = android.sourceSets.main.java.sourceFiles
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
classpath += configurations.compile
}

// build a jar with javadoc
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}

artifacts {
archives sourcesJar
archives javadocJar
}
Loading

0 comments on commit 318dc9f

Please sign in to comment.