Skip to content

Commit

Permalink
Added maven repo
Browse files Browse the repository at this point in the history
  • Loading branch information
Pedro Oliveira committed Feb 26, 2015
1 parent 8912cf7 commit 045e4db
Show file tree
Hide file tree
Showing 31 changed files with 637 additions and 31 deletions.
21 changes: 21 additions & 0 deletions README.md
@@ -1,5 +1,26 @@
android-parallax-recycleview
============================

**Integration**
====

**Step 1.** Add the JitPack repository to your build file

repositories {
maven {
url "https://jitpack.io"
}
}

**Step 2.** Add the dependency

dependencies {
compile 'com.poliveira.parallaxrecycleradapter:v1.2'
}




**USAGE**

(Example project - https://github.com/kanytu/example-parallaxrecycler)
Expand Down
33 changes: 14 additions & 19 deletions build.gradle
@@ -1,24 +1,19 @@
apply plugin: 'com.android.library'
// Top-level build file where you can add configuration options common to all sub-projects/modules.

android {
compileSdkVersion 21
buildToolsVersion "21.1.1"

defaultConfig {
minSdkVersion 7
targetSdkVersion 21
versionCode 2
versionName "1.1"
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.0'
classpath 'com.github.dcendents:android-maven-plugin:1.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:recyclerview-v7:21.0.0'
allprojects {
repositories {
jcenter()
}
}
1 change: 1 addition & 0 deletions example/.gitignore
@@ -0,0 +1 @@
/build
26 changes: 26 additions & 0 deletions example/build.gradle
@@ -0,0 +1,26 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 21
buildToolsVersion "21.1.2"

defaultConfig {
applicationId "com.poliveira.apps.parallaxrecycleradapter"
minSdkVersion 7
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project (':library')
compile 'com.android.support:cardview-v7:21.0.3'
}
2 changes: 1 addition & 1 deletion proguard-rules.pro → example/proguard-rules.pro
@@ -1,6 +1,6 @@
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in C:/Development/Android/sdk/tools/proguard/proguard-android.txt
# in C:\Development\Android\sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
Expand Down
18 changes: 18 additions & 0 deletions example/src/main/AndroidManifest.xml
@@ -0,0 +1,18 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.poliveira.apps.parallaxrecycleradapter">

<application
android:allowBackup="true"
android:label="@string/app_name"
android:icon="@mipmap/ic_launcher"
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>
@@ -0,0 +1,140 @@
package com.poliveira.apps.parallaxrecycleradapter;

import android.app.Activity;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import android.widget.Toast;

import com.poliveira.parallaxrecycleradapter.HeaderLayoutManagerFixed;
import com.poliveira.parallaxrecycleradapter.ParallaxRecyclerAdapter;

import java.util.ArrayList;
import java.util.List;

/**
* Created by poliveira on 26/02/2015.
*/
public class MainActivity extends Activity {

private boolean isNormalAdapter = false;
private RecyclerView mRecyclerView;


@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mRecyclerView = (RecyclerView) findViewById(R.id.recycler);
createAdapter(mRecyclerView);
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (isNormalAdapter) {
createCardAdapter(mRecyclerView);
} else {
createAdapter(mRecyclerView);
}
isNormalAdapter = !isNormalAdapter;
return super.onOptionsItemSelected(item);
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main, menu);
return super.onCreateOptionsMenu(menu);
}

private void createCardAdapter(RecyclerView recyclerView) {
final List<String> content = new ArrayList<>();
for (int i = 0; i < 50; i++) {
content.add("item " + i);
}
final ParallaxRecyclerAdapter<String> adapter = new ParallaxRecyclerAdapter<>(content);
HeaderLayoutManagerFixed layoutManagerFixed = new HeaderLayoutManagerFixed(this);
recyclerView.setLayoutManager(layoutManagerFixed);
View header = getLayoutInflater().inflate(R.layout.header, recyclerView, false);
layoutManagerFixed.setHeaderIncrementFixer(header);
adapter.setShouldClipView(false);
adapter.setParallaxHeader(header, recyclerView);
adapter.setData(content);
adapter.implementRecyclerAdapterMethods(new ParallaxRecyclerAdapter.RecyclerAdapterMethods() {
@Override
public void onBindViewHolder(RecyclerView.ViewHolder viewHolder, int i) {
((ViewHolder) viewHolder).textView.setText(adapter.getData().get(i));
}

@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
final ViewHolder holder = new ViewHolder(getLayoutInflater().inflate(R.layout.row_recyclerview_cards, viewGroup, false));
//don't set listeners on onBindViewHolder. For more info check http://androidshenanigans.blogspot.pt/2015/02/viewholder-pattern-common-mistakes.html
holder.textView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(MainActivity.this, "You clicked '" + adapter.getData().get(holder.getPosition() - (adapter.hasHeader() ? 1 : 0)) + "'", Toast.LENGTH_SHORT).show();
}
});
return holder;
}

@Override
public int getItemCount() {
return content.size();
}
});
recyclerView.setAdapter(adapter);
}

private void createAdapter(RecyclerView recyclerView) {
final List<String> content = new ArrayList<>();
for (int i = 0; i < 50; i++) {
content.add("item " + i);
}
final ParallaxRecyclerAdapter<String> adapter = new ParallaxRecyclerAdapter<>(content);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
View header = getLayoutInflater().inflate(R.layout.header, recyclerView, false);
adapter.setParallaxHeader(header, recyclerView);
adapter.setData(content);
adapter.implementRecyclerAdapterMethods(new ParallaxRecyclerAdapter.RecyclerAdapterMethods() {
@Override
public void onBindViewHolder(RecyclerView.ViewHolder viewHolder, int i) {
((ViewHolder) viewHolder).textView.setText(adapter.getData().get(i));
}

@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
final ViewHolder holder = new ViewHolder(getLayoutInflater().inflate(R.layout.row_recyclerview, viewGroup, false));
//don't set listeners on onBindViewHolder. For more info check http://androidshenanigans.blogspot.pt/2015/02/viewholder-pattern-common-mistakes.html
holder.textView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(MainActivity.this, "You clicked '" + adapter.getData().get(holder.getPosition() - (adapter.hasHeader() ? 1 : 0)) + "'", Toast.LENGTH_SHORT).show();
}
});
return holder;
}

@Override
public int getItemCount() {
return content.size();
}
});
recyclerView.setAdapter(adapter);
}


static class ViewHolder extends RecyclerView.ViewHolder {
public TextView textView;

public ViewHolder(View itemView) {
super(itemView);
textView = (TextView) itemView.findViewById(R.id.textView);
}
}
}
Binary file added example/src/main/res/drawable/wallpaper.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions example/src/main/res/layout/activity_main.xml
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">

<view
android:layout_width="match_parent"
android:layout_height="match_parent"
class="android.support.v7.widget.RecyclerView"
android:id="@+id/recycler"
android:layout_gravity="left|top"/>
</FrameLayout>
13 changes: 13 additions & 0 deletions example/src/main/res/layout/header.xml
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">

<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/imageView"
android:src="@drawable/wallpaper"
android:adjustViewBounds="true"/>
</LinearLayout>
13 changes: 13 additions & 0 deletions example/src/main/res/layout/row_recyclerview.xml
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="50dp">

<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/textView"
android:layout_gravity="center_horizontal"
android:gravity="center"/>
</LinearLayout>
24 changes: 24 additions & 0 deletions example/src/main/res/layout/row_recyclerview_cards.xml
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="250dp">

<android.support.v7.widget.CardView
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/card"
card_view:cardCornerRadius="4dp"
android:layout_margin="15dp"
card_view:cardBackgroundColor="#ffb7f0ff">

<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/textView"
android:layout_gravity="center"
android:gravity="center"/>
</android.support.v7.widget.CardView>


</FrameLayout>
5 changes: 5 additions & 0 deletions example/src/main/res/menu/main.xml
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:title="Change Adapter"/>
</menu>
Binary file added example/src/main/res/mipmap-hdpi/ic_launcher.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added example/src/main/res/mipmap-mdpi/ic_launcher.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added example/src/main/res/mipmap-xhdpi/ic_launcher.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions example/src/main/res/values-v21/styles.xml
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="AppTheme" parent="android:Theme.Material.Light">
</style>
</resources>
3 changes: 3 additions & 0 deletions example/src/main/res/values/strings.xml
@@ -0,0 +1,3 @@
<resources>
<string name="app_name">ParallaxRecyclerAdapter</string>
</resources>
8 changes: 8 additions & 0 deletions example/src/main/res/values/styles.xml
@@ -0,0 +1,8 @@
<resources>

<!-- Base application theme. -->
<style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar">
<!-- Customize your theme here. -->
</style>

</resources>
18 changes: 18 additions & 0 deletions gradle.properties
@@ -0,0 +1,18 @@
# Project-wide Gradle settings.

# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.

# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html

# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx10248m -XX:MaxPermSize=256m
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8

# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
Binary file added gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
6 changes: 6 additions & 0 deletions gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,6 @@
#Wed Apr 10 15:27:10 PDT 2013
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip

0 comments on commit 045e4db

Please sign in to comment.