Skip to content

Commit 8ee75b7

Browse files
committed
Added follower card and list fragment
1 parent b58d32f commit 8ee75b7

File tree

12 files changed

+262
-30
lines changed

12 files changed

+262
-30
lines changed

Diff for: app/build.gradle

+21-7
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
apply plugin: 'com.android.application'
22

33
android {
4-
compileSdkVersion 26
4+
compileSdkVersion 25
55
defaultConfig {
66
applicationId "ru.nikartm.android_searchview_example"
77
minSdkVersion 21
8-
targetSdkVersion 26
8+
targetSdkVersion 25
99
versionCode 1
1010
versionName "1.0"
1111
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
@@ -16,13 +16,27 @@ android {
1616
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
1717
}
1818
}
19+
compileOptions {
20+
targetCompatibility 1.8
21+
sourceCompatibility 1.8
22+
}
1923
}
2024

2125
dependencies {
2226
implementation fileTree(dir: 'libs', include: ['*.jar'])
23-
implementation 'com.android.support:appcompat-v7:26.1.0'
24-
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
25-
testImplementation 'junit:junit:4.12'
26-
androidTestImplementation 'com.android.support.test:runner:1.0.1'
27-
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
27+
28+
compile project(':github-api')
29+
30+
compile 'com.android.support:appcompat-v7:25.4.0'
31+
compile 'com.android.support:design:25.4.0'
32+
compile 'com.android.support:recyclerview-v7:25.4.0'
33+
compile 'com.android.support:cardview-v7:25.4.0'
34+
compile 'com.android.support.constraint:constraint-layout:1.0.2'
35+
compile 'com.android.support:support-v4:25.4.0'
36+
compile 'com.github.bumptech.glide:glide:4.2.0'
37+
testCompile 'junit:junit:4.12'
38+
annotationProcessor 'com.github.bumptech.glide:compiler:4.2.0'
39+
compile('com.mikepenz:materialdrawer:5.9.2@aar') {
40+
transitive = true
41+
}
2842
}

Diff for: app/src/main/AndroidManifest.xml

+3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
33
package="ru.nikartm.android_searchview_example">
44

5+
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
6+
<uses-permission android:name="android.permission.INTERNET" />
7+
58
<application
69
android:allowBackup="true"
710
android:icon="@mipmap/ic_launcher"

Diff for: app/src/main/java/ru/nikartm/android_searchview_example/MainActivity.java

+40
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,52 @@
22

33
import android.support.v7.app.AppCompatActivity;
44
import android.os.Bundle;
5+
import android.util.Log;
6+
7+
import io.reactivex.android.schedulers.AndroidSchedulers;
8+
import io.reactivex.disposables.Disposable;
9+
import io.reactivex.schedulers.Schedulers;
10+
import ru.nikartm.android_searchview_example.util.AppProgressDialog;
11+
import ru.nikartm.github_api.GitHubManager;
512

613
public class MainActivity extends AppCompatActivity {
714

15+
public static final String TAG = MainActivity.class.getSimpleName();
16+
17+
private Disposable disposable;
18+
819
@Override
920
protected void onCreate(Bundle savedInstanceState) {
1021
super.onCreate(savedInstanceState);
1122
setContentView(R.layout.activity_main);
23+
24+
getFollowers();
25+
}
26+
27+
private void getFollowers() {
28+
disposable = GitHubManager.getInstance(getApplicationContext())
29+
.getFollowers("nikartm")
30+
.subscribeOn(Schedulers.io())
31+
.observeOn(AndroidSchedulers.mainThread())
32+
.doOnSubscribe(disposable -> AppProgressDialog.show(this))
33+
.doOnTerminate(AppProgressDialog::dismiss)
34+
.subscribe(followers -> Log.d(TAG, "Followers list size: " + followers.size()),
35+
e -> Log.e(TAG, "Get followers error", e));
36+
}
37+
38+
private void initFollowersList() {
39+
40+
}
41+
42+
private void initFailure() {
43+
44+
}
45+
46+
@Override
47+
public void onDestroy() {
48+
super.onDestroy();
49+
if (disposable != null && !disposable.isDisposed()) {
50+
disposable.dispose();
51+
}
1252
}
1353
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package ru.nikartm.android_searchview_example.fragment;
2+
3+
4+
import android.os.Bundle;
5+
import android.support.v4.app.Fragment;
6+
import android.view.LayoutInflater;
7+
import android.view.View;
8+
import android.view.ViewGroup;
9+
10+
import ru.nikartm.android_searchview_example.R;
11+
12+
13+
public class FollowersFragment extends Fragment {
14+
15+
16+
public FollowersFragment() {
17+
}
18+
19+
@Override
20+
public View onCreateView(LayoutInflater inflater, ViewGroup container,
21+
Bundle savedInstanceState) {
22+
View view = inflater.inflate(R.layout.fragment_followers, container, false);
23+
24+
return view;
25+
}
26+
27+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package ru.nikartm.android_searchview_example.util;
2+
3+
import android.app.ProgressDialog;
4+
import android.content.Context;
5+
6+
/**
7+
* Progress dialog
8+
* @author Ivan V on 29.10.2017.
9+
* @version 1.0
10+
*/
11+
public class AppProgressDialog {
12+
13+
private static ProgressDialog progress;
14+
15+
public static void show(Context context) {
16+
if (progress == null) {
17+
progress = new ProgressDialog(context);
18+
progress.setMessage("Please wait...");
19+
progress.setCanceledOnTouchOutside(false);
20+
progress.setCancelable(false);
21+
}
22+
progress.show();
23+
}
24+
25+
public static void dismiss() {
26+
if (progress != null && progress.isShowing()) {
27+
progress.dismiss();
28+
}
29+
}
30+
}

Diff for: app/src/main/res/drawable/no_photo.png

13.5 KB
Loading

Diff for: app/src/main/res/layout/activity_main.xml

+7-10
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
3-
xmlns:app="http://schemas.android.com/apk/res-auto"
2+
<android.support.constraint.ConstraintLayout
3+
xmlns:android="http://schemas.android.com/apk/res/android"
44
xmlns:tools="http://schemas.android.com/tools"
55
android:layout_width="match_parent"
66
android:layout_height="match_parent"
77
tools:context="ru.nikartm.android_searchview_example.MainActivity">
88

9-
<TextView
10-
android:layout_width="wrap_content"
11-
android:layout_height="wrap_content"
12-
android:text="Hello World!"
13-
app:layout_constraintBottom_toBottomOf="parent"
14-
app:layout_constraintLeft_toLeftOf="parent"
15-
app:layout_constraintRight_toRightOf="parent"
16-
app:layout_constraintTop_toTopOf="parent" />
9+
<LinearLayout
10+
android:id="@+id/main_container"
11+
android:orientation="vertical"
12+
android:layout_width="match_parent"
13+
android:layout_height="match_parent" />
1714

1815
</android.support.constraint.ConstraintLayout>

Diff for: app/src/main/res/layout/follower_item.xml

+101
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
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+
xmlns:card_view="http://schemas.android.com/apk/res-auto"
6+
android:id="@+id/follower_item"
7+
android:layout_width="match_parent"
8+
android:layout_height="wrap_content"
9+
android:layout_marginStart="7dp"
10+
android:layout_marginEnd="7dp"
11+
android:layout_marginBottom="7dp"
12+
android:orientation="vertical" >
13+
14+
<android.support.v7.widget.CardView
15+
android:id="@+id/cv_follower"
16+
android:layout_gravity="center"
17+
android:layout_width="match_parent"
18+
android:layout_height="115dp"
19+
android:layout_marginBottom="6dp"
20+
android:elevation="2dp"
21+
card_view:cardCornerRadius="3dp"
22+
card_view:cardPreventCornerOverlap="false"
23+
card_view:cardUseCompatPadding="true">
24+
25+
<LinearLayout
26+
android:id="@+id/ll_card_view"
27+
android:orientation="horizontal"
28+
android:layout_width="match_parent"
29+
android:layout_height="match_parent">
30+
31+
<ImageView
32+
android:id="@+id/iv_card_view"
33+
tools:src="@drawable/no_photo"
34+
android:layout_width="110dp"
35+
android:layout_height="match_parent"
36+
android:padding="5dp"/>
37+
38+
<LinearLayout
39+
android:orientation="vertical"
40+
android:paddingStart="5dp"
41+
android:paddingEnd="16dp"
42+
android:layout_width="match_parent"
43+
android:layout_height="match_parent">
44+
45+
<TextView
46+
android:id="@+id/tv_user_name"
47+
tools:text="Super User"
48+
android:maxLines="1"
49+
android:ellipsize="end"
50+
android:textColor="#596d79"
51+
android:textSize="18sp"
52+
android:textStyle="bold"
53+
android:layout_width="match_parent"
54+
android:layout_height="wrap_content" />
55+
56+
<LinearLayout
57+
android:orientation="horizontal"
58+
android:layout_width="match_parent"
59+
android:layout_height="wrap_content">
60+
61+
<TextView
62+
android:layout_marginTop="5dp"
63+
android:text="id: "
64+
android:textSize="14sp"
65+
android:layout_width="wrap_content"
66+
android:layout_height="wrap_content" />
67+
68+
<TextView
69+
android:id="@+id/tv_offer_description"
70+
android:layout_marginTop="5dp"
71+
android:maxLines="1"
72+
android:ellipsize="end"
73+
tools:text="123456789"
74+
android:textSize="14sp"
75+
android:layout_width="match_parent"
76+
android:layout_height="wrap_content" />
77+
78+
</LinearLayout>
79+
80+
<LinearLayout
81+
android:orientation="horizontal"
82+
android:layout_width="match_parent"
83+
android:layout_height="wrap_content">
84+
85+
<TextView
86+
android:id="@+id/tv_github_url"
87+
android:layout_marginTop="5dp"
88+
android:maxLines="2"
89+
android:ellipsize="end"
90+
tools:text="https://api.github.com/users/superUser"
91+
android:textSize="14sp"
92+
android:layout_width="match_parent"
93+
android:layout_height="wrap_content" />
94+
95+
</LinearLayout>
96+
97+
</LinearLayout>
98+
</LinearLayout>
99+
</android.support.v7.widget.CardView>
100+
101+
</LinearLayout>

Diff for: app/src/main/res/layout/fragment_followers.xml

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
2+
xmlns:tools="http://schemas.android.com/tools"
3+
android:layout_width="match_parent"
4+
android:layout_height="match_parent"
5+
tools:context="ru.nikartm.android_searchview_example.fragment.FollowersFragment">
6+
7+
<android.support.v7.widget.RecyclerView
8+
android:id="@+id/rv_material_list"
9+
android:layout_width="match_parent"
10+
android:layout_height="match_parent"
11+
android:clipToPadding="false"
12+
android:scrollbars="vertical"
13+
tools:listitem="@layout/follower_item" />
14+
15+
</FrameLayout>

Diff for: app/src/main/res/values/colors.xml

+13-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<resources>
3-
<color name="colorPrimary">#3F51B5</color>
4-
<color name="colorPrimaryDark">#303F9F</color>
5-
<color name="colorAccent">#FF4081</color>
3+
<color name="colorPrimary">#009688</color>
4+
<color name="colorPrimaryDark">#00796B</color>
5+
<color name="colorAccent">#FF9800</color>
6+
<color name="colorPrimaryLight">#B2DFDB</color>
7+
8+
<color name="colorPrimaryText">#212121</color>
9+
<color name="colorSecondaryText">#757575</color>
10+
<color name="colorBackground">#EEEEEE</color>
11+
<color name="colorDivider">#BDBDBD</color>
12+
13+
<color name="colorDark">#263238</color>
14+
<color name="colorBlueGrey">#596d79</color>
15+
<color name="colorWhite">#FFFFFF</color>
616
</resources>

Diff for: app/src/main/res/values/strings.xml

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
<resources>
2-
<string name="app_name">Android-SearchView-Example</string>
2+
<string name="app_name">GitHub Viewer</string>
3+
34
</resources>

Diff for: github-api/build.gradle

+3-9
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,14 @@
11
apply plugin: 'com.android.library'
22

33
android {
4-
compileSdkVersion 26
5-
6-
4+
compileSdkVersion 25
75

86
defaultConfig {
97
minSdkVersion 21
10-
targetSdkVersion 26
8+
targetSdkVersion 25
119
versionCode 1
1210
versionName "1.0"
13-
1411
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
15-
1612
}
1713

1814
buildTypes {
@@ -31,10 +27,8 @@ android {
3127
dependencies {
3228
implementation fileTree(dir: 'libs', include: ['*.jar'])
3329

34-
implementation 'com.android.support:appcompat-v7:26.1.0'
30+
implementation 'com.android.support:appcompat-v7:25.4.0'
3531
testImplementation 'junit:junit:4.12'
36-
androidTestImplementation 'com.android.support.test:runner:1.0.1'
37-
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
3832

3933
compile 'com.squareup.retrofit2:retrofit:2.3.0'
4034
compile 'com.squareup.retrofit2:converter-gson:2.3.0'

0 commit comments

Comments
 (0)