Skip to content

Commit

Permalink
MaterialShowcase Part 2
Browse files Browse the repository at this point in the history
  • Loading branch information
mariusz committed Oct 29, 2015
1 parent 7e87138 commit 2231bc0
Show file tree
Hide file tree
Showing 22 changed files with 335 additions and 70 deletions.
Binary file added app/MaterialShowcase2.pptx
Binary file not shown.
22 changes: 11 additions & 11 deletions app/app.iml
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,11 @@
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dependency-cache" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex-cache" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/appcompat-v7/23.0.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/cardview-v7/23.0.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/design/23.0.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/recyclerview-v7/23.0.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-v4/23.0.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/appcompat-v7/23.1.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/cardview-v7/23.1.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/design/23.1.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/recyclerview-v7/23.1.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-v4/23.1.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/de.hdodenhof/circleimageview/1.3.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/uk.co.chrisjenx/calligraphy/2.1.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
Expand All @@ -99,18 +99,18 @@
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" exported="" name="butterknife-7.0.1" level="project" />
<orderEntry type="library" exported="" name="gson-2.3.1" level="project" />
<orderEntry type="library" exported="" name="cardview-v7-23.0.0" level="project" />
<orderEntry type="library" exported="" name="cardview-v7-23.1.0" level="project" />
<orderEntry type="library" exported="" name="retrofit-1.9.0" level="project" />
<orderEntry type="library" exported="" name="design-23.0.0" level="project" />
<orderEntry type="library" exported="" name="appcompat-v7-23.0.0" level="project" />
<orderEntry type="library" exported="" name="design-23.1.0" level="project" />
<orderEntry type="library" exported="" name="recyclerview-v7-23.1.0" level="project" />
<orderEntry type="library" exported="" name="circleimageview-1.3.0" level="project" />
<orderEntry type="library" exported="" name="recyclerview-v7-23.0.0" level="project" />
<orderEntry type="library" exported="" name="okhttp-2.0.0" level="project" />
<orderEntry type="library" exported="" name="calligraphy-2.1.0" level="project" />
<orderEntry type="library" exported="" name="okio-1.0.0" level="project" />
<orderEntry type="library" exported="" name="support-v4-23.0.0" level="project" />
<orderEntry type="library" exported="" name="otto-1.3.8" level="project" />
<orderEntry type="library" exported="" name="support-annotations-23.0.0" level="project" />
<orderEntry type="library" exported="" name="support-v4-23.1.0" level="project" />
<orderEntry type="library" exported="" name="appcompat-v7-23.1.0" level="project" />
<orderEntry type="library" exported="" name="support-annotations-23.1.0" level="project" />
<orderEntry type="library" exported="" name="okhttp-urlconnection-2.0.0" level="project" />
</component>
</module>
10 changes: 5 additions & 5 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ apply plugin: 'me.tatarka.retrolambda'

android {
compileSdkVersion 23
buildToolsVersion "23.0.0"
buildToolsVersion "23.0.1"

defaultConfig {
applicationId "com.droidsonroids.materialshowcase"
Expand Down Expand Up @@ -32,10 +32,10 @@ retrolambda {
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.squareup.retrofit:retrofit:1.9.0'
compile 'com.android.support:design:23.0.0'
compile 'com.android.support:appcompat-v7:23.0.0'
compile 'com.android.support:cardview-v7:23.0.0'
compile 'com.android.support:recyclerview-v7:23.0.0'
compile 'com.android.support:design:23.1.0'
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'com.android.support:cardview-v7:23.1.0'
compile 'com.android.support:recyclerview-v7:23.1.0'
compile 'com.jakewharton:butterknife:7.0.1'
compile 'uk.co.chrisjenx:calligraphy:2.1.0'
compile 'de.hdodenhof:circleimageview:1.3.0'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.droidsonroids.materialshowcase.screen_details;

import android.animation.ObjectAnimator;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
Expand All @@ -9,13 +8,11 @@
import android.os.Looper;
import android.support.v7.widget.CardView;
import android.support.v7.widget.Toolbar;
import android.telecom.Call;
import android.transition.Fade;
import android.transition.Transition;
import android.transition.TransitionInflater;
import android.view.View;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.widget.TextView;
import butterknife.Bind;
import butterknife.BindString;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class GithubRepoViewHolder extends RecyclerView.ViewHolder {
@Bind(R.id.cardview_github_tv_stars) TextView mTvStars;
@Bind(R.id.cardview_github_tv_watchers) TextView mTvWatchers;
@Bind(R.id.cardview_github_tv_forks) TextView mTvForks;
@Bind(R.id.activity_details_vw_circle) View mFab;
//@Bind(R.id.activity_details_vw_circle) View mFab;

@BindString(R.string.stars) String mStars;
@BindString(R.string.watchers) String mWatchers;
Expand All @@ -28,7 +28,7 @@ public class GithubRepoViewHolder extends RecyclerView.ViewHolder {
public GithubRepoViewHolder(View itemView, OnGithubRepoViewClickListener listener) {
super(itemView);
ButterKnife.bind(this, itemView);
mFab.setOnClickListener(v -> listener.onItemClick(this, currentPosition));
//mFab.setOnClickListener(v -> listener.onItemClick(this, currentPosition));
}

public void updateViews(GithubRepo githubRepo, int position) {
Expand All @@ -41,9 +41,9 @@ public void updateViews(GithubRepo githubRepo, int position) {
});
}

public View getFab() {
return mFab;
}
//public View getFab() {
// return mFab;
//}

public TextView getTitle() {
return mTvHeader;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import android.content.Context;
import android.os.Bundle;
import android.os.Debug;
import android.support.design.widget.AppBarLayout;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.Menu;
Expand All @@ -15,12 +16,13 @@
import java.util.List;
import uk.co.chrisjenx.calligraphy.CalligraphyContextWrapper;

public class MainActivity extends Activity implements MainView {
public class MainActivity extends Activity implements MainView, AppBarLayout.OnOffsetChangedListener {

private MainPresenter mainPresenter;
private MainActivityRecyclerAdapter adapter;

@Bind(R.id.sample_list) RecyclerView mRecyclerView;
@Bind(R.id.activity_main_appbar) AppBarLayout mAppBarLayout;

@Override
protected void attachBaseContext(Context newBase) {
Expand Down Expand Up @@ -52,4 +54,11 @@ protected void onDestroy() {
public void loadData(List<GithubRepo> githubRepoList) {
adapter.setGithubRepoList(githubRepoList);
}

@Override
public void onOffsetChanged(AppBarLayout appBarLayout, int i) {
int maxScroll = mAppBarLayout.getTotalScrollRange();
float percentage = (float) Math.abs(i) / (float)maxScroll;
//TODO: C'mon Android Team, do the magic here!
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ public void setGithubRepoList(List<GithubRepo> githubRepoList) {
@Override
public void onItemClick(GithubRepoViewHolder viewHolder, int repoPosition) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
Intent intent = DetailsActivity.getIntent(mMainActivity, githubRepoList.get(repoPosition));
ActivityOptionsCompat option =
ActivityOptionsCompat.makeSceneTransitionAnimation(mMainActivity,
new Pair<View, String>(viewHolder.getFab(), "reveal"));
ActivityCompat.startActivity(mMainActivity, intent, option.toBundle());
//Intent intent = DetailsActivity.getIntent(mMainActivity, githubRepoList.get(repoPosition));
//ActivityOptionsCompat option =
// ActivityOptionsCompat.makeSceneTransitionAnimation(mMainActivity,
// new Pair<View, String>(viewHolder.getFab(), "reveal"));
//ActivityCompat.startActivity(mMainActivity, intent, option.toBundle());
}
}
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.droidsonroids.materialshowcase.screen_main;

import android.util.Log;
import com.droidsonroids.materialshowcase.data.ApiManager;
import com.droidsonroids.materialshowcase.data.entities.GithubRepo;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
package com.droidsonroids.materialshowcase.utils;

public class Constants {

public static final String REST_ENDPOINT = "https://api.github.com";
public static final String USER_AGENT = "User-Agent";

public static final String PHOTO_PAULINA = "http://www.thedroidsonroids.com/wp-content/themes/droidsonroids2015/new-img/team/paulina.jpg";
public static final String PHOTO_ANETA = "http://www.thedroidsonroids.com/wp-content/themes/droidsonroids2015/new-img/team/aneta.jpg";
public static final String PHOTO_DAWID = "http://www.thedroidsonroids.com/wp-content/themes/droidsonroids2015/new-img/team/dawid.jpg";
public static final String PHOTO_MARIUSZ = "http://www.thedroidsonroids.com/wp-content/themes/droidsonroids2015/new-img/team/mariusz.jpg";
public static final String PHOTO_MAKOR = "http://www.thedroidsonroids.com/wp-content/themes/droidsonroids2015/new-img/team/makor.jpg";
public static final String PHOTO_KAROL = "http://www.thedroidsonroids.com/wp-content/themes/droidsonroids2015/new-img/team/karol.jpg";
public static final String PHOTO_MICHAL = "http://www.thedroidsonroids.com/wp-content/themes/droidsonroids2015/new-img/team/michal.jpg";
public static final String PHOTO_MACIEK = "http://www.thedroidsonroids.com/wp-content/themes/droidsonroids2015/new-img/team/maciek.jpg";
public static final String PHOTO_MARCIN = "http://www.thedroidsonroids.com/wp-content/themes/droidsonroids2015/new-img/team/marcin.jpg";
public static final String PHOTO_SEBA = "http://www.thedroidsonroids.com/wp-content/themes/droidsonroids2015/new-img/team/sebastian.jpg";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package com.droidsonroids.materialshowcase.utils;

import android.content.Context;
import android.support.design.widget.CoordinatorLayout;
import android.support.design.widget.FloatingActionButton;
import android.support.v4.view.ViewCompat;
import android.util.AttributeSet;
import android.view.View;

public class FabLayoutBehavior extends FloatingActionButton.Behavior {

public FabLayoutBehavior(Context context, AttributeSet attrs) {
super();
}

@Override
public boolean onStartNestedScroll(CoordinatorLayout coordinatorLayout,
FloatingActionButton child, View directTargetChild, View target, int nestedScrollAxes) {
return nestedScrollAxes == ViewCompat.SCROLL_AXIS_VERTICAL ||
super.onStartNestedScroll(coordinatorLayout, child, directTargetChild, target,
nestedScrollAxes);
}

@Override
public void onNestedScroll(CoordinatorLayout coordinatorLayout, FloatingActionButton child,
View target, int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed) {
super.onNestedScroll(coordinatorLayout, child, target, dxConsumed, dyConsumed, dxUnconsumed,
dyUnconsumed);

if (dyConsumed > 0 && child.getVisibility() == View.VISIBLE) {
child.hide();
} else if (dyConsumed < 0 && child.getVisibility() != View.VISIBLE) {
child.show();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@
import android.animation.AnimatorListenerAdapter;
import android.content.Context;
import android.support.annotation.ColorRes;
import android.support.v4.view.animation.LinearOutSlowInInterpolator;
import android.view.View;
import android.view.ViewAnimationUtils;
import android.view.animation.AccelerateDecelerateInterpolator;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import com.droidsonroids.materialshowcase.R;
import com.droidsonroids.materialshowcase.screen_details.OnRevealAnimationListener;

Expand Down Expand Up @@ -61,4 +64,109 @@ public void onAnimationEnd(Animator animation) {
});
anim.start();
}
public static void startEnterTransitionSlideUp(Context ctx, View... views) {
Animation slideAnimationUp = AnimationUtils.loadAnimation(ctx, R.anim.abc_slide_in_bottom);
slideAnimationUp.setDuration(300);
slideAnimationUp.setInterpolator(new LinearOutSlowInInterpolator());
slideAnimationUp.setAnimationListener(getShowAnimationListener(null, views));
startAnimations(slideAnimationUp, views);
}

public static void startEnterTransitionSlideDown(Context ctx, View... views) {
Animation slideAnimationDown = AnimationUtils.loadAnimation(ctx, R.anim.abc_slide_in_top);
slideAnimationDown.setDuration(300);
slideAnimationDown.setInterpolator(new LinearOutSlowInInterpolator());
slideAnimationDown.setAnimationListener(getShowAnimationListener(null, views));
startAnimations(slideAnimationDown, views);
}

public static void startReturnTransitionSlideDown(Context ctx, OnReturnAnimationFinished listener, View... views) {
Animation slideAnimation = AnimationUtils.loadAnimation(ctx, R.anim.slide_out_bottom);
slideAnimation.setDuration(300);
slideAnimation.setInterpolator(new AccelerateDecelerateInterpolator());
slideAnimation.setAnimationListener(getGoneAnimationListener(listener, views));
startAnimations(slideAnimation, views);
}

public static void startReturnTransitionSlideUp(Context ctx, OnReturnAnimationFinished listener, View... views) {
Animation slideAnimationUp = AnimationUtils.loadAnimation(ctx, R.anim.slide_out_top);
slideAnimationUp.setDuration(300);
slideAnimationUp.setInterpolator(new AccelerateDecelerateInterpolator());
slideAnimationUp.setAnimationListener(getGoneAnimationListener(listener, views));
startAnimations(slideAnimationUp, views);
}

public static void startScaleUpAnimation(Context ctx, View... views) {
Animation scaleAnimation = AnimationUtils.loadAnimation(ctx, R.anim.scale_up);
scaleAnimation.setDuration(300);
scaleAnimation.setInterpolator(new AccelerateDecelerateInterpolator());
scaleAnimation.setAnimationListener(getShowAnimationListener(null, views));
startAnimations(scaleAnimation, views);
}

public static void startScaleDownAnimation(Context ctx, View... views) {
Animation scaleAnimation = AnimationUtils.loadAnimation(ctx, R.anim.scale_down);
scaleAnimation.setDuration(300);
scaleAnimation.setInterpolator(new AccelerateDecelerateInterpolator());
scaleAnimation.setAnimationListener(getGoneAnimationListener(null, views));
startAnimations(scaleAnimation, views);
}

private static Animation.AnimationListener getGoneAnimationListener(OnReturnAnimationFinished listener, View... views) {
return new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {

}

@Override
public void onAnimationEnd(Animation animation) {
for(View v : views) {
v.setVisibility(View.INVISIBLE);
}
if(listener != null) {
listener.onAnimationFinished();
}
}

@Override
public void onAnimationRepeat(Animation animation) {

}
};
}

private static Animation.AnimationListener getShowAnimationListener(OnReturnAnimationFinished listener, View... views) {
return new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {

}

@Override
public void onAnimationEnd(Animation animation) {
for(View v : views) {
v.setVisibility(View.VISIBLE);
}
if(listener != null) {
listener.onAnimationFinished();
}
}

@Override
public void onAnimationRepeat(Animation animation) {

}
};
}

private static void startAnimations(Animation animation, View... views) {
for(View v : views) {
v.startAnimation(animation);
}
}

public interface OnReturnAnimationFinished {
void onAnimationFinished();
}
}
10 changes: 10 additions & 0 deletions app/src/main/res/anim/scale_down.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<scale
android:fromXScale="1.0"
android:fromYScale="1.0"
android:pivotX="50%"
android:pivotY="50%"
android:toXScale="0"
android:toYScale="0" />
</set>
10 changes: 10 additions & 0 deletions app/src/main/res/anim/scale_up.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<scale
android:fromXScale="0.0"
android:fromYScale="0.0"
android:pivotX="50%"
android:pivotY="50%"
android:toXScale="1.0"
android:toYScale="1.0" />
</set>
6 changes: 6 additions & 0 deletions app/src/main/res/anim/slide_out_bottom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_interpolator"
android:fromYDelta="0"
android:toYDelta="100%"
android:duration="@android:integer/config_mediumAnimTime"/>
5 changes: 5 additions & 0 deletions app/src/main/res/anim/slide_out_top.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_interpolator"
android:fromYDelta="0" android:toYDelta="-100%"
android:duration="@android:integer/config_mediumAnimTime"/>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable-xxxhdpi/dor.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 2231bc0

Please sign in to comment.