Skip to content

Commit de325fa

Browse files
committed
WIP: Add sample app
1 parent bc97c50 commit de325fa

File tree

7 files changed

+134
-9
lines changed

7 files changed

+134
-9
lines changed

sample/build.gradle

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@ android {
77
defaultConfig {
88
minSdkVersion 14
99
targetSdkVersion project.ext.targetSdkVersion
10-
versionCode project.ext.versionCode
11-
versionName project.ext.versionName
12-
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
10+
versionCode 1
11+
versionName '1.0.0'
1312
}
1413
buildTypes {
1514
release {
@@ -20,10 +19,7 @@ android {
2019
}
2120

2221
dependencies {
23-
androidTestImplementation "com.android.support.test:runner:${libraryVersion.testRunner}"
24-
androidTestImplementation "com.android.support.test.espresso:espresso-core:${libraryVersion.espresso}"
25-
22+
implementation project(':library')
2623
implementation "com.android.support:appcompat-v7:${libraryVersion.androidSupport}"
27-
28-
testImplementation "junit:junit:${libraryVersion.junit}"
24+
implementation "com.android.support:recyclerview-v7:${libraryVersion.androidSupport}"
2925
}

sample/src/main/AndroidManifest.xml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<manifest
22
xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:tools="http://schemas.android.com/tools"
34
package="com.xmartlabs.xmartrecyclerview.sample"
45
>
56

@@ -9,6 +10,20 @@
910
android:roundIcon="@mipmap/ic_launcher_round"
1011
android:supportsRtl="true"
1112
android:theme="@style/AppTheme"
12-
/>
13+
tools:ignore="AllowBackup">
14+
15+
<activity
16+
android:name=".MainActivity"
17+
>
18+
19+
<intent-filter>
20+
<action android:name="android.intent.action.MAIN" />
21+
22+
<category android:name="android.intent.category.LAUNCHER" />
23+
</intent-filter>
24+
25+
</activity>
26+
27+
</application>
1328

1429
</manifest>
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package com.xmartlabs.xmartrecyclerview.sample;
2+
3+
import android.app.Activity;
4+
import android.os.Bundle;
5+
import android.support.annotation.Nullable;
6+
7+
import com.xmartlabs.xmartrecyclerview.emptysupport.RecyclerViewEmptySupport;
8+
9+
public class MainActivity extends Activity {
10+
@Override
11+
protected void onCreate(@Nullable Bundle savedInstanceState) {
12+
super.onCreate(savedInstanceState);
13+
setContentView(R.layout.activity_main);
14+
RecyclerViewEmptySupport recyclerView = findViewById(R.id.recyclerView);
15+
16+
MainAdapter adapter = new MainAdapter();
17+
recyclerView.setAdapter(adapter);
18+
19+
adapter.addItem();
20+
}
21+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package com.xmartlabs.xmartrecyclerview.sample;
2+
3+
import android.support.annotation.NonNull;
4+
import android.view.ViewGroup;
5+
6+
import com.xmartlabs.xmartrecyclerview.adapter.SingleItemTypeRecyclerViewAdapter;
7+
import com.xmartlabs.xmartrecyclerview.adapter.SingleItemViewHolder;
8+
9+
public class MainAdapter extends SingleItemTypeRecyclerViewAdapter<Person, SingleItemViewHolder<Person>> {
10+
@NonNull
11+
@Override
12+
public SingleItemViewHolder<Person> onCreateViewHolder(@NonNull ViewGroup parent) {
13+
return new SingleItemViewHolder<>(inflateView(parent, R.layout.item));
14+
}
15+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package com.xmartlabs.xmartrecyclerview.sample;
2+
3+
public class Person {
4+
private int id;
5+
private String name;
6+
7+
public int getId() {
8+
return id;
9+
}
10+
11+
public void setId(int id) {
12+
this.id = id;
13+
}
14+
15+
public String getName() {
16+
return name;
17+
}
18+
19+
public void setName(String name) {
20+
this.name = name;
21+
}
22+
23+
@Override
24+
public int hashCode() {
25+
int result = id;
26+
result = 31 * result + name.hashCode();
27+
return result;
28+
}
29+
30+
@Override
31+
public boolean equals(Object o) {
32+
if (this == o) {
33+
return true;
34+
}
35+
if (o == null || getClass() != o.getClass()) {
36+
return false;
37+
}
38+
39+
Person person = (Person) o;
40+
41+
if (id != person.id) {
42+
return false;
43+
}
44+
return name.equals(person.name);
45+
}
46+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<FrameLayout
3+
xmlns:android="http://schemas.android.com/apk/res/android"
4+
android:layout_width="match_parent"
5+
android:layout_height="match_parent"
6+
>
7+
8+
<com.xmartlabs.xmartrecyclerview.RecyclerViewEmptySupport
9+
android:id="@+id/recyclerView"
10+
android:layout_width="match_parent"
11+
android:layout_height="match_parent"
12+
/>
13+
14+
</FrameLayout>

sample/src/main/res/layout/item.xml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<LinearLayout
3+
xmlns:android="http://schemas.android.com/apk/res/android"
4+
xmlns:tools="http://schemas.android.com/tools"
5+
android:layout_width="match_parent"
6+
android:layout_height="match_parent"
7+
android:orientation="vertical"
8+
android:padding="16dp"
9+
>
10+
11+
<TextView
12+
android:id="@android:id/text1"
13+
android:layout_width="wrap_content"
14+
android:layout_height="wrap_content"
15+
tools:text="Homer Simpson"
16+
/>
17+
18+
</LinearLayout>

0 commit comments

Comments
 (0)