Skip to content

Commit

Permalink
Add RecyclerView module
Browse files Browse the repository at this point in the history
  • Loading branch information
Aditya Sharat committed Mar 1, 2017
1 parent 478d055 commit 83a0b96
Show file tree
Hide file tree
Showing 10 changed files with 299 additions and 1 deletion.
1 change: 1 addition & 0 deletions demo/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ android {
compile project(':proteus-core')
compile project(':gson-adapter')
compile project(':support-v4')
compile project(':recyclerview-v7')
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
import com.flipkart.android.proteus.demo.converter.GsonConverterFactory;
import com.flipkart.android.proteus.demo.models.JsonResource;
import com.flipkart.android.proteus.gson.ProteusTypeAdapterFactory;
import com.flipkart.android.proteus.recyclerview.v7.RecyclerViewCollection;
import com.flipkart.android.proteus.support.v4.SupportV4Collection;
import com.flipkart.android.proteus.toolbox.EventType;
import com.flipkart.android.proteus.value.DrawableValue;
Expand Down Expand Up @@ -184,6 +185,7 @@ protected void onStart() {

Proteus proteus = new ProteusBuilder()
.register(SupportV4Collection.create())
.register(RecyclerViewCollection.create())
.register(new CircleViewParser())
.build();

Expand Down
1 change: 1 addition & 0 deletions recyclerview-v7/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
78 changes: 78 additions & 0 deletions recyclerview-v7/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/*
* Apache License
* Version 2.0, January 2004
* http://www.apache.org/licenses/LICENSE-2.0
*
* TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
*
* Copyright (c) 2017 Flipkart Internet Pvt. Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use
* this file except in compliance with the License. You may obtain a copy of the
* License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed
* under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
* CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*/

apply plugin: 'com.android.library'

android {
compileSdkVersion 25
buildToolsVersion "25.0.1"

defaultConfig {
minSdkVersion 14
targetSdkVersion 25
versionCode 1
versionName "1.0"

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

task sourcesJar(type: Jar) {
from android.sourceSets.main.java.srcDirs
classifier = 'sources'
}

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

afterEvaluate {
javadoc.classpath += files(android.libraryVariants.collect { variant ->
variant.javaCompile.classpath.files
})
}

task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}

artifacts {
archives javadocJar
archives sourcesJar
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:recyclerview-v7:25.1.0'
compile 'com.android.support:appcompat-v7:25.1.0'
testCompile 'junit:junit:4.12'
compile project(path: ':proteus-core')
}
33 changes: 33 additions & 0 deletions recyclerview-v7/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /Users/aditya.sharat/Library/Android/sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# Add any project specific keep options here:

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
-dontobfuscate
-printmapping out.map
-keepparameternames
-renamesourcefileattribute SourceFile
-keepattributes Exceptions,InnerClasses,Signature,Deprecated

# Preserve all annotations.

-keepattributes *Annotation*

# Preserve all public classes, and their public and protected fields and
# methods.

-keep public class * {
public protected *;
}
20 changes: 20 additions & 0 deletions recyclerview-v7/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!--
~ Apache License
~ Version 2.0, January 2004
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
~
~ Copyright (c) 2017 Flipkart Internet Pvt. Ltd.
~
~ Licensed under the Apache License, Version 2.0 (the "License"); you may not use
~ this file except in compliance with the License. You may obtain a copy of the
~ License at http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software distributed
~ under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
~ CONDITIONS OF ANY KIND, either express or implied. See the License for the
~ specific language governing permissions and limitations under the License.
-->

<manifest package="com.flipkart.android.proteus.recyclerview.v7"/>
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Apache License
* Version 2.0, January 2004
* http://www.apache.org/licenses/LICENSE-2.0
*
* TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
*
* Copyright (c) 2017 Flipkart Internet Pvt. Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use
* this file except in compliance with the License. You may obtain a copy of the
* License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed
* under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
* CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*/

package com.flipkart.android.proteus.recyclerview.v7;

import com.flipkart.android.proteus.ProteusBuilder;

/**
* RecyclerViewCollection
*
* @author adityasharat
*/
public class RecyclerViewCollection implements ProteusBuilder.Collection {

private RecyclerViewCollection() {

}

public static RecyclerViewCollection create() {
return new RecyclerViewCollection();
}

@Override
public void registerWith(ProteusBuilder builder) {
builder.register(new RecyclerViewParser());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/*
* Apache License
* Version 2.0, January 2004
* http://www.apache.org/licenses/LICENSE-2.0
*
* TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
*
* Copyright (c) 2017 Flipkart Internet Pvt. Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use
* this file except in compliance with the License. You may obtain a copy of the
* License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed
* under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
* CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*/

package com.flipkart.android.proteus.recyclerview.v7;

import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.widget.RecyclerView;
import android.view.ViewGroup;

import com.flipkart.android.proteus.ProteusContext;
import com.flipkart.android.proteus.ProteusView;
import com.flipkart.android.proteus.ViewTypeParser;
import com.flipkart.android.proteus.recyclerview.v7.widget.ProteusRecyclerView;
import com.flipkart.android.proteus.value.Layout;
import com.flipkart.android.proteus.value.ObjectValue;

/**
* RecyclerViewParser
*
* @author adityasharat
*/

public class RecyclerViewParser<T extends RecyclerView> extends ViewTypeParser {

@NonNull
@Override
public String getType() {
return "RecyclerView";
}

@Nullable
@Override
public String getParentType() {
return "ViewGroup";
}

@NonNull
@Override
public ProteusView createView(@NonNull ProteusContext context, @NonNull Layout layout, @NonNull ObjectValue data, @Nullable ViewGroup parent, int dataIndex) {
return new ProteusRecyclerView(context);
}

@Override
protected void addAttributeProcessors() {

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* Apache License
* Version 2.0, January 2004
* http://www.apache.org/licenses/LICENSE-2.0
*
* TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
*
* Copyright (c) 2017 Flipkart Internet Pvt. Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use
* this file except in compliance with the License. You may obtain a copy of the
* License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed
* under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
* CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*/

package com.flipkart.android.proteus.recyclerview.v7.widget;

import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.flipkart.android.proteus.ProteusContext;
import com.flipkart.android.proteus.ProteusView;

/**
* ProteusRecyclerView
*
* @author adityasharat
*/

public class ProteusRecyclerView extends RecyclerView implements ProteusView {

Manager manager;

public ProteusRecyclerView(ProteusContext context) {
super(context);
}

@Override
public Manager getViewManager() {
return manager;
}

@Override
public void setViewManager(Manager manager) {
this.manager = manager;
}

@Override
public View getAsView() {
return this;
}
}
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@
* specific language governing permissions and limitations under the License.
*/

include ':demo', ':proteus-core', ':gson-adapter', ':support-v4'
include ':demo', ':proteus-core', ':gson-adapter', ':support-v4', ':recyclerview-v7'

0 comments on commit 83a0b96

Please sign in to comment.