Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 807ae3f

Browse files
Upgrade project (gradle & other dependencies)
1 parent 85b1517 commit 807ae3f

File tree

11 files changed

+102
-73
lines changed

11 files changed

+102
-73
lines changed

‎app/build.gradle‎

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
apply plugin: 'com.android.application'
22
apply plugin: 'kotlin-android'
3-
apply plugin: 'kotlin-android-extensions'
43

54
android {
6-
compileSdkVersion 30
5+
compileSdkVersion 36
76
defaultConfig {
87
applicationId "com.sharmadhiraj.androidpaginglibrarystepbystepimplementationguide"
9-
minSdkVersion 16
10-
targetSdkVersion 30
8+
minSdkVersion 21
9+
targetSdkVersion 36
1110
multiDexEnabled true
1211
versionCode 1
1312
versionName "1.0"
@@ -20,6 +19,9 @@ android {
2019
}
2120
}
2221
namespace 'com.sharmadhiraj.androidpaginglibrarystepbystepimplementationguide'
22+
buildFeatures {
23+
viewBinding true
24+
}
2325
}
2426

2527
dependencies {
@@ -38,22 +40,22 @@ dependencies {
3840
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
3941

4042
//Paging
41-
implementation 'androidx.paging:paging-runtime-ktx:3.0.0'
43+
implementation 'androidx.paging:paging-runtime-ktx:3.3.6'
4244

4345
//Networking
4446
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
4547
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
4648
implementation 'com.squareup.retrofit2:adapter-rxjava2:2.9.0'
4749

4850
//Rx
49-
implementation 'io.reactivex.rxjava2:rxjava:2.2.10'
51+
implementation 'io.reactivex.rxjava2:rxjava:2.2.21'
5052
implementation 'io.reactivex.rxjava2:rxandroid:2.1.1'
5153

5254
//Image
5355
implementation 'com.squareup.picasso:picasso:2.71828'
5456

5557
//Testing
5658
testImplementation 'junit:junit:4.13.2'
57-
androidTestImplementation 'androidx.test:runner:1.3.0'
58-
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
59+
androidTestImplementation 'androidx.test:runner:1.6.2'
60+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.6.1'
5961
}

‎app/src/main/AndroidManifest.xml‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
android:theme="@style/AppTheme"
1212
tools:ignore="AllowBackup,GoogleAppIndexingWarning">
1313

14-
<activity android:name=".activity.NewsListActivity">
14+
<activity
15+
android:name=".activity.NewsListActivity"
16+
android:exported="true">
1517
<intent-filter>
1618
<action android:name="android.intent.action.MAIN" />
1719
<category android:name="android.intent.category.LAUNCHER" />

‎app/src/main/java/com/sharmadhiraj/androidpaginglibrarystepbystepimplementationguide/activity/NewsListActivity.kt‎

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,49 +4,52 @@ import android.os.Bundle
44
import android.view.View.GONE
55
import android.view.View.VISIBLE
66
import androidx.appcompat.app.AppCompatActivity
7-
import androidx.lifecycle.Observer
87
import androidx.lifecycle.ViewModelProvider
9-
import com.sharmadhiraj.androidpaginglibrarystepbystepimplementationguide.R
108
import com.sharmadhiraj.androidpaginglibrarystepbystepimplementationguide.adapter.NewsListAdapter
119
import com.sharmadhiraj.androidpaginglibrarystepbystepimplementationguide.data.State
1210
import com.sharmadhiraj.androidpaginglibrarystepbystepimplementationguide.data.State.ERROR
1311
import com.sharmadhiraj.androidpaginglibrarystepbystepimplementationguide.data.State.LOADING
12+
import com.sharmadhiraj.androidpaginglibrarystepbystepimplementationguide.databinding.ActivityNewsListBinding
1413
import com.sharmadhiraj.androidpaginglibrarystepbystepimplementationguide.viewModel.NewsListViewModel
15-
import kotlinx.android.synthetic.main.activity_news_list.*
1614

1715
class NewsListActivity : AppCompatActivity() {
1816

17+
private lateinit var binding: ActivityNewsListBinding
1918
private lateinit var viewModel: NewsListViewModel
2019
private lateinit var newsListAdapter: NewsListAdapter
2120

2221
override fun onCreate(savedInstanceState: Bundle?) {
2322
super.onCreate(savedInstanceState)
24-
setContentView(R.layout.activity_news_list)
23+
binding = ActivityNewsListBinding.inflate(layoutInflater)
24+
setContentView(binding.root)
25+
26+
viewModel = ViewModelProvider(this)[NewsListViewModel::class.java]
2527

26-
viewModel = ViewModelProvider(this).get(NewsListViewModel::class.java)
2728
initAdapter()
2829
initState()
2930
}
3031

3132
private fun initAdapter() {
3233
newsListAdapter = NewsListAdapter { viewModel.retry() }
33-
recycler_view.adapter = newsListAdapter
34-
viewModel.newsList.observe(this,
35-
Observer {
36-
newsListAdapter.submitList(it)
37-
})
34+
binding.recyclerView.adapter = newsListAdapter
35+
36+
viewModel.newsList.observe(this) {
37+
newsListAdapter.submitList(it)
38+
}
3839
}
3940

4041
private fun initState() {
41-
txt_error.setOnClickListener { viewModel.retry() }
42-
viewModel.getState().observe(this, Observer { state ->
43-
progress_bar.visibility =
42+
binding.txtError.setOnClickListener { viewModel.retry() }
43+
44+
viewModel.getState().observe(this) { state ->
45+
binding.progressBar.visibility =
4446
if (viewModel.listIsEmpty() && state == LOADING) VISIBLE else GONE
45-
txt_error.visibility = if (viewModel.listIsEmpty() && state == ERROR) VISIBLE else GONE
47+
binding.txtError.visibility =
48+
if (viewModel.listIsEmpty() && state == ERROR) VISIBLE else GONE
49+
4650
if (!viewModel.listIsEmpty()) {
4751
newsListAdapter.setState(state ?: State.DONE)
4852
}
49-
})
53+
}
5054
}
51-
52-
}
55+
}

‎app/src/main/java/com/sharmadhiraj/androidpaginglibrarystepbystepimplementationguide/adapter/ListFooterViewHolder.kt‎

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,28 @@ package com.sharmadhiraj.androidpaginglibrarystepbystepimplementationguide.adapt
22

33
import android.view.LayoutInflater
44
import android.view.View
5-
import android.view.View.INVISIBLE
6-
import android.view.View.VISIBLE
75
import android.view.ViewGroup
86
import androidx.recyclerview.widget.RecyclerView
9-
import com.sharmadhiraj.androidpaginglibrarystepbystepimplementationguide.R
107
import com.sharmadhiraj.androidpaginglibrarystepbystepimplementationguide.data.State
118
import com.sharmadhiraj.androidpaginglibrarystepbystepimplementationguide.data.State.ERROR
129
import com.sharmadhiraj.androidpaginglibrarystepbystepimplementationguide.data.State.LOADING
13-
import kotlinx.android.synthetic.main.item_list_footer.view.progress_bar
14-
import kotlinx.android.synthetic.main.item_list_footer.view.txt_error
10+
import com.sharmadhiraj.androidpaginglibrarystepbystepimplementationguide.databinding.ItemListFooterBinding
1511

16-
class ListFooterViewHolder(view: View) : RecyclerView.ViewHolder(view) {
12+
class ListFooterViewHolder(
13+
private val binding: ItemListFooterBinding
14+
) : RecyclerView.ViewHolder(binding.root) {
1715

1816
fun bind(status: State?) {
19-
itemView.progress_bar.visibility = if (status == LOADING) VISIBLE else INVISIBLE
20-
itemView.txt_error.visibility = if (status == ERROR) VISIBLE else INVISIBLE
17+
binding.progressBar.visibility = if (status == LOADING) View.VISIBLE else View.INVISIBLE
18+
binding.txtError.visibility = if (status == ERROR) View.VISIBLE else View.INVISIBLE
2119
}
2220

2321
companion object {
2422
fun create(retry: () -> Unit, parent: ViewGroup): ListFooterViewHolder {
25-
val view = LayoutInflater.from(parent.context)
26-
.inflate(R.layout.item_list_footer, parent, false)
27-
view.txt_error.setOnClickListener { retry() }
28-
return ListFooterViewHolder(view)
23+
val inflater = LayoutInflater.from(parent.context)
24+
val binding =ItemListFooterBinding.inflate(inflater, parent, false)
25+
binding.txtError.setOnClickListener { retry() }
26+
return ListFooterViewHolder(binding)
2927
}
3028
}
31-
}
29+
}
Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,31 @@
11
package com.sharmadhiraj.androidpaginglibrarystepbystepimplementationguide.adapter
22

33
import android.view.LayoutInflater
4-
import android.view.View
54
import android.view.ViewGroup
65
import androidx.recyclerview.widget.RecyclerView
7-
import com.sharmadhiraj.androidpaginglibrarystepbystepimplementationguide.R
86
import com.sharmadhiraj.androidpaginglibrarystepbystepimplementationguide.data.News
7+
import com.sharmadhiraj.androidpaginglibrarystepbystepimplementationguide.databinding.ItemNewsBinding
98
import com.squareup.picasso.Picasso
10-
import kotlinx.android.synthetic.main.item_news.view.img_news_banner
11-
import kotlinx.android.synthetic.main.item_news.view.txt_news_name
129

13-
class NewsViewHolder(view:View) : RecyclerView.ViewHolder(view) {
10+
class NewsViewHolder(privatevalbinding:ItemNewsBinding) : RecyclerView.ViewHolder(binding.root) {
1411

1512
fun bind(news: News?) {
1613
if (news != null) {
17-
itemView.txt_news_name.text = news.title
18-
if (!news.image.isNullOrEmpty())
19-
Picasso.get().load(news.image).into(itemView.img_news_banner)
14+
binding.txtNewsName.text = news.title
15+
if (!news.image.isNullOrEmpty()) {
16+
Picasso.get().load(news.image).into(binding.imgNewsBanner)
17+
}
2018
}
2119
}
2220

2321
companion object {
2422
fun create(parent: ViewGroup): NewsViewHolder {
25-
val view = LayoutInflater.from(parent.context)
26-
.inflate(R.layout.item_news, parent, false)
27-
return NewsViewHolder(view)
23+
val binding = ItemNewsBinding.inflate(
24+
LayoutInflater.from(parent.context),
25+
parent,
26+
false
27+
)
28+
return NewsViewHolder(binding)
2829
}
2930
}
3031
}

‎app/src/main/java/com/sharmadhiraj/androidpaginglibrarystepbystepimplementationguide/data/NewsDataSource.kt‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class NewsDataSource(
3737
},
3838
{
3939
updateState(ERROR)
40-
setRetry(Action { loadInitial(params, callback) })
40+
setRetry { loadInitial(params, callback) }
4141
}
4242
)
4343
)
@@ -57,7 +57,7 @@ class NewsDataSource(
5757
},
5858
{
5959
updateState(ERROR)
60-
setRetry(Action { loadAfter(params, callback) })
60+
setRetry { loadAfter(params, callback) }
6161
}
6262
)
6363
)

‎build.gradle‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ buildscript {
55
mavenCentral()
66
}
77
dependencies {
8-
classpath 'com.android.tools.build:gradle:7.4.2'
8+
classpath 'com.android.tools.build:gradle:8.11.1'
99
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
1010
}
1111
}

‎gradle.properties‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@
66
# http://www.gradle.org/docs/current/userguide/build_environment.html
77
# Specifies the JVM arguments used for the daemon process.
88
# The setting is particularly useful for tweaking memory settings.
9+
android.defaults.buildfeatures.buildconfig=true
910
android.enableJetifier=true
11+
android.nonFinalResIds=false
12+
android.nonTransitiveRClass=false
1013
android.useAndroidX=true
1114
org.gradle.jvmargs=-Xmx1536m
1215
# When configured, Gradle will run in incubating parallel mode.
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip
4+
networkTimeout=10000
5+
validateDistributionUrl=true
46
zipStoreBase=GRADLE_USER_HOME
57
zipStorePath=wrapper/dists

‎gradlew‎

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
# Darwin, MinGW, and NonStop.
5656
#
5757
# (3) This script is generated from the Groovy template
58-
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
58+
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
5959
# within the Gradle project.
6060
#
6161
# You can find Gradle at https://github.com/gradle/gradle/.
@@ -80,13 +80,11 @@ do
8080
esac
8181
done
8282

83-
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
84-
85-
APP_NAME="Gradle"
83+
# This is normally unused
84+
# shellcheck disable=SC2034
8685
APP_BASE_NAME=${0##*/}
87-
88-
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
89-
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
86+
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
87+
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
9088

9189
# Use the maximum available, or set MAX_FD != -1 to use that value.
9290
MAX_FD=maximum
@@ -133,22 +131,29 @@ location of your Java installation."
133131
fi
134132
else
135133
JAVACMD=java
136-
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
134+
if ! command -v java >/dev/null 2>&1
135+
then
136+
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
137137
138138
Please set the JAVA_HOME variable in your environment to match the
139139
location of your Java installation."
140+
fi
140141
fi
141142

142143
# Increase the maximum file descriptors if we can.
143144
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
144145
case $MAX_FD in #(
145146
max*)
147+
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
148+
# shellcheck disable=SC2039,SC3045
146149
MAX_FD=$( ulimit -H -n ) ||
147150
warn "Could not query maximum file descriptor limit"
148151
esac
149152
case $MAX_FD in #(
150153
'' | soft) :;; #(
151154
*)
155+
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
156+
# shellcheck disable=SC2039,SC3045
152157
ulimit -n "$MAX_FD" ||
153158
warn "Could not set maximum file descriptor limit to $MAX_FD"
154159
esac
@@ -193,18 +198,28 @@ if "$cygwin" || "$msys" ; then
193198
done
194199
fi
195200

196-
# Collect all arguments for the java command;
197-
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
198-
# shell script including quotes and variable substitutions, so put them in
199-
# double quotes to make sure that they get re-expanded; and
200-
# * put everything else in single quotes, so that it's not re-expanded.
201+
202+
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
203+
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
204+
205+
# Collect all arguments for the java command:
206+
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
207+
# and any embedded shellness will be escaped.
208+
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
209+
# treated as '${Hostname}' itself on the command line.
201210

202211
set -- \
203212
"-Dorg.gradle.appname=$APP_BASE_NAME" \
204213
-classpath "$CLASSPATH" \
205214
org.gradle.wrapper.GradleWrapperMain \
206215
"$@"
207216

217+
# Stop when "xargs" is not available.
218+
if ! command -v xargs >/dev/null 2>&1
219+
then
220+
die "xargs is not available"
221+
fi
222+
208223
# Use "xargs" to parse quoted args.
209224
#
210225
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /