Skip to content

Commit f04645e

Browse files
author
nyakokishi
committed
initial commit
0 parents  commit f04645e

40 files changed

+1043
-0
lines changed

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
*.iml
2+
.gradle
3+
/local.properties
4+
/.idea
5+
.DS_Store
6+
/build
7+
/captures
8+
.externalNativeBuild

README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
EasyRecyclerView
2+
3+
![](https://im2.ezgif.com/tmp/ezgif-2-b7f5cfaf16.gif)
4+
![](https://im2.ezgif.com/tmp/ezgif-2-766bf97f96.gif)
5+
6+
![](https://im2.ezgif.com/tmp/ezgif-2-b198a93ca7.gif)
7+
8+
# License
9+
10+
```
11+
Copyright 2015 jianghejie
12+
13+
Licensed under the Apache License, Version 2.0 (the "License");
14+
you may not use this file except in compliance with the License.
15+
You may obtain a copy of the License at
16+
17+
http://www.apache.org/licenses/LICENSE-2.0
18+
19+
Unless required by applicable law or agreed to in writing, software
20+
distributed under the License is distributed on an "AS IS" BASIS,
21+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22+
See the License for the specific language governing permissions and
23+
limitations under the License.
24+
```

app/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

app/build.gradle

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
apply plugin: 'com.android.application'
2+
apply plugin: 'kotlin-android'
3+
apply plugin: 'kotlin-android-extensions'
4+
5+
android {
6+
compileSdkVersion 25
7+
buildToolsVersion "25.0.3"
8+
defaultConfig {
9+
applicationId "com.nyakokishi.app"
10+
minSdkVersion 16
11+
targetSdkVersion 25
12+
versionCode 1
13+
versionName "1.0"
14+
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
15+
}
16+
buildTypes {
17+
release {
18+
minifyEnabled false
19+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
20+
}
21+
}
22+
}
23+
24+
dependencies {
25+
compile fileTree(dir: 'libs', include: ['*.jar'])
26+
compile project(':easyrecyclerview')
27+
28+
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
29+
exclude group: 'com.android.support', module: 'support-annotations'
30+
})
31+
compile 'com.android.support:appcompat-v7:25.3.1'
32+
compile "com.android.support:recyclerview-v7:25.3.1"
33+
compile "com.android.support:design:25.3.1"
34+
compile 'com.android.support.constraint:constraint-layout:1.0.2'
35+
36+
compile 'com.github.nekocode:ItemPool:0.5.2'
37+
38+
testCompile 'junit:junit:4.12'
39+
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
40+
}
41+
repositories {
42+
maven { url "https://jitpack.io" }
43+
mavenCentral()
44+
}

app/proguard-rules.pro

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Add project specific ProGuard rules here.
2+
# By default, the flags in this file are appended to flags specified
3+
# in /Users/liveapp/Library/Android/sdk/tools/proguard/proguard-android.txt
4+
# You can edit the include path and order by changing the proguardFiles
5+
# directive in build.gradle.
6+
#
7+
# For more details, see
8+
# http://developer.android.com/guide/developing/tools/proguard.html
9+
10+
# Add any project specific keep options here:
11+
12+
# If your project uses WebView with JS, uncomment the following
13+
# and specify the fully qualified class name to the JavaScript interface
14+
# class:
15+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16+
# public *;
17+
#}
18+
19+
# Uncomment this to preserve the line number information for
20+
# debugging stack traces.
21+
#-keepattributes SourceFile,LineNumberTable
22+
23+
# If you keep the line number information, uncomment this to
24+
# hide the original source file name.
25+
#-renamesourcefileattribute SourceFile

app/src/main/AndroidManifest.xml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="com.nyakokishi.app">
4+
5+
<application
6+
android:allowBackup="true"
7+
android:icon="@mipmap/ic_launcher"
8+
android:label="@string/app_name"
9+
android:roundIcon="@mipmap/ic_launcher_round"
10+
android:supportsRtl="true"
11+
android:theme="@style/AppTheme">
12+
<activity android:name=".MainActivity">
13+
<intent-filter>
14+
<action android:name="android.intent.action.MAIN" />
15+
16+
<category android:name="android.intent.category.LAUNCHER" />
17+
</intent-filter>
18+
</activity>
19+
</application>
20+
21+
</manifest>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package com.nyakokishi.app
2+
3+
import android.view.LayoutInflater
4+
import android.view.View
5+
import android.view.ViewGroup
6+
import cn.nekocode.itempool.Item
7+
import kotlinx.android.synthetic.main.item_view.view.*
8+
9+
/**
10+
* Created by nyakokishi on 2017/7/19.
11+
*/
12+
class DemoItem: Item<DemoItem.ColorVO>(){
13+
14+
override fun onCreateItemView(inflater: LayoutInflater, container: ViewGroup): View {
15+
return inflater.inflate(R.layout.item_view, container, false)
16+
}
17+
18+
override fun onBindItem(vo: ColorVO) {
19+
with(viewHolder.itemView){
20+
textview.setBackgroundColor(vo.colorValue)
21+
}
22+
}
23+
24+
class ColorVO(
25+
val colorValue:Int
26+
)
27+
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
package com.nyakokishi.app;
2+
3+
import android.os.Bundle
4+
import android.os.Handler
5+
import android.support.v7.app.AppCompatActivity
6+
import android.support.v7.widget.GridLayoutManager
7+
import android.support.v7.widget.LinearLayoutManager
8+
import cn.nekocode.itempool.ItemPool
9+
import kotlinx.android.synthetic.main.activity_main.*
10+
11+
class MainActivity : AppCompatActivity() {
12+
13+
val itemPool = ItemPool()
14+
var count = 0
15+
16+
override fun onCreate(savedInstanceState: Bundle?) {
17+
super.onCreate(savedInstanceState)
18+
setContentView(R.layout.activity_main)
19+
20+
itemPool.addType(DemoItem::class.java)
21+
22+
loadData()
23+
24+
// LinearLayoutManager - normal
25+
recyclerView.layoutManager = LinearLayoutManager(this)
26+
27+
// LinearLayoutManager - reverse
28+
recyclerView.layoutManager = LinearLayoutManager(this).apply {
29+
reverseLayout = true
30+
}
31+
32+
// GridLayoutManager
33+
recyclerView.layoutManager = GridLayoutManager(this, 2)
34+
35+
recyclerView.adapter = itemPool.adapter
36+
recyclerView.setLoadingListener {
37+
Handler().postDelayed({
38+
loadData()
39+
}, 1500)
40+
}
41+
42+
}
43+
44+
45+
fun loadData() {
46+
47+
itemPool.add(DemoItem.ColorVO(0xffEE5C42.toInt()))
48+
itemPool.add(DemoItem.ColorVO(0xff5CACEE.toInt()))
49+
itemPool.add(DemoItem.ColorVO(0xffAB82FF.toInt()))
50+
itemPool.add(DemoItem.ColorVO(0xffEE6AA7.toInt()))
51+
itemPool.add(DemoItem.ColorVO(0xffE6E6FA.toInt()))
52+
itemPool.add(DemoItem.ColorVO(0xffEEB4B4.toInt()))
53+
itemPool.add(DemoItem.ColorVO(0xffD1EEEE.toInt()))
54+
55+
itemPool.notifyDataSetChanged()
56+
recyclerView.loadMoreComplete()
57+
recyclerView.setHasMore(count++ <= 3)
58+
}
59+
60+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:tools="http://schemas.android.com/tools"
4+
android:layout_width="match_parent"
5+
android:layout_height="match_parent"
6+
xmlns:app="http://schemas.android.com/apk/res-auto"
7+
tools:context="com.nyakokishi.app.MainActivity"
8+
>
9+
10+
<com.nyakokishi.easyrecyclerview.EasyRecyclerView
11+
android:id="@+id/recyclerView"
12+
android:layout_width="match_parent"
13+
android:layout_height="match_parent"
14+
app:footerLayout="@layout/view_loading"
15+
/>
16+
17+
</FrameLayout>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
android:layout_width="match_parent"
4+
android:layout_height="150dp"
5+
android:orientation="vertical"
6+
android:padding="10dp"
7+
>
8+
9+
<TextView
10+
android:id="@+id/textview"
11+
android:layout_width="match_parent"
12+
android:layout_height="match_parent"
13+
android:background="#da6286"
14+
/>
15+
16+
</LinearLayout>

0 commit comments

Comments
 (0)