Skip to content
This repository was archived by the owner on Dec 9, 2024. It is now read-only.

Commit 49fb422

Browse files
authored
GridToPager: Update dependencies (#34)
* GridToPager: Update dependencies Replace uses of deprecated APIs. * Remove a debug log
1 parent a427465 commit 49fb422

File tree

7 files changed

+24
-20
lines changed

7 files changed

+24
-20
lines changed

GridToPager/app/build.gradle

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,13 @@
1515
*/
1616

1717
apply plugin: 'com.android.application'
18-
apply plugin: 'kotlin-android'
1918

2019
android {
21-
compileSdkVersion 28
20+
compileSdkVersion 29
2221
defaultConfig {
2322
applicationId "com.google.samples.gridtopager"
2423
minSdkVersion 21
25-
targetSdkVersion 28
24+
targetSdkVersion 29
2625
versionCode 1
2726
versionName "1.0"
2827
testInstrumentationRunner = 'androidx.test.runner.AndroidJUnitRunner'
@@ -40,14 +39,13 @@ android {
4039
}
4140

4241
dependencies {
43-
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
44-
implementation "androidx.appcompat:appcompat:1.0.2"
42+
implementation "androidx.appcompat:appcompat:1.1.0"
4543
implementation "androidx.cardview:cardview:1.0.0"
4644
implementation "androidx.constraintlayout:constraintlayout:1.1.3"
47-
implementation "androidx.recyclerview:recyclerview:1.0.0"
48-
implementation "androidx.annotation:annotation:1.0.1"
49-
implementation "com.github.bumptech.glide:glide:4.8.0"
50-
androidTestImplementation "androidx.test.espresso:espresso-core:3.1.1"
51-
androidTestImplementation "androidx.test:rules:1.1.1"
52-
androidTestImplementation "androidx.test.ext:junit:1.1.0"
45+
implementation "androidx.recyclerview:recyclerview:1.1.0"
46+
implementation "androidx.annotation:annotation:1.1.0"
47+
implementation "com.github.bumptech.glide:glide:4.9.0"
48+
androidTestImplementation "androidx.test.espresso:espresso-core:3.2.0"
49+
androidTestImplementation "androidx.test:rules:1.2.0"
50+
androidTestImplementation "androidx.test.ext:junit:1.1.1"
5351
}

GridToPager/app/src/main/java/com/google/samples/gridtopager/MainActivity.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
import android.os.Bundle;
1919

20+
import androidx.annotation.NonNull;
2021
import androidx.fragment.app.FragmentManager;
2122
import androidx.appcompat.app.AppCompatActivity;
2223
import com.google.samples.gridtopager.fragment.GridFragment;
@@ -53,7 +54,7 @@ protected void onCreate(Bundle savedInstanceState) {
5354
}
5455

5556
@Override
56-
protected void onSaveInstanceState(Bundle outState) {
57+
protected void onSaveInstanceState(@NonNull Bundle outState) {
5758
super.onSaveInstanceState(outState);
5859
outState.putInt(KEY_CURRENT_POSITION, currentPosition);
5960
}

GridToPager/app/src/main/java/com/google/samples/gridtopager/adapter/GridAdapter.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
import static com.google.samples.gridtopager.adapter.ImageData.IMAGE_DRAWABLES;
2020

2121
import android.graphics.drawable.Drawable;
22+
23+
import androidx.annotation.NonNull;
2224
import androidx.annotation.Nullable;
2325
import androidx.fragment.app.Fragment;
2426
import androidx.recyclerview.widget.RecyclerView;
@@ -37,6 +39,7 @@
3739
import com.google.samples.gridtopager.R;
3840
import com.google.samples.gridtopager.adapter.GridAdapter.ImageViewHolder;
3941
import com.google.samples.gridtopager.fragment.ImagePagerFragment;
42+
4043
import java.util.concurrent.atomic.AtomicBoolean;
4144

4245
/**
@@ -65,6 +68,7 @@ public GridAdapter(Fragment fragment) {
6568
this.viewHolderListener = new ViewHolderListenerImpl(fragment);
6669
}
6770

71+
@NonNull
6872
@Override
6973
public ImageViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
7074
View view = LayoutInflater.from(parent.getContext())

GridToPager/app/src/main/java/com/google/samples/gridtopager/adapter/ImagePagerAdapter.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import static com.google.samples.gridtopager.adapter.ImageData.IMAGE_DRAWABLES;
2020

21+
import androidx.annotation.NonNull;
2122
import androidx.fragment.app.Fragment;
2223
import androidx.fragment.app.FragmentStatePagerAdapter;
2324
import com.google.samples.gridtopager.fragment.ImageFragment;
@@ -26,14 +27,15 @@ public class ImagePagerAdapter extends FragmentStatePagerAdapter {
2627

2728
public ImagePagerAdapter(Fragment fragment) {
2829
// Note: Initialize with the child fragment manager.
29-
super(fragment.getChildFragmentManager());
30+
super(fragment.getChildFragmentManager(), BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT);
3031
}
3132

3233
@Override
3334
public int getCount() {
3435
return IMAGE_DRAWABLES.length;
3536
}
3637

38+
@NonNull
3739
@Override
3840
public Fragment getItem(int position) {
3941
return ImageFragment.newInstance(IMAGE_DRAWABLES[position]);

GridToPager/app/src/main/java/com/google/samples/gridtopager/fragment/GridFragment.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public void onMapSharedElements(List<String> names, Map<String, View> sharedElem
105105
// Locate the ViewHolder for the clicked position.
106106
RecyclerView.ViewHolder selectedViewHolder = recyclerView
107107
.findViewHolderForAdapterPosition(MainActivity.currentPosition);
108-
if (selectedViewHolder == null || selectedViewHolder.itemView == null) {
108+
if (selectedViewHolder == null) {
109109
return;
110110
}
111111

GridToPager/build.gradle

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@
1717
// Top-level build file where you can add configuration options common to all sub-projects/modules.
1818

1919
buildscript {
20-
ext.kotlin_version = '1.3.11'
20+
ext.kotlin_version = '1.3.70'
2121
repositories {
2222
google()
23-
mavenCentral()
23+
jcenter()
2424
}
2525
dependencies {
26-
classpath 'com.android.tools.build:gradle:3.2.1'
26+
classpath 'com.android.tools.build:gradle:3.6.1'
2727
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
2828

2929
// NOTE: Do not place your application dependencies here; they belong
@@ -34,7 +34,6 @@ buildscript {
3434
allprojects {
3535
repositories {
3636
google()
37-
mavenCentral()
3837
jcenter()
3938
}
4039
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#Tue Feb 06 14:40:02 PST 2018
1+
#Mon Mar 09 14:35:23 JST 2020
22
distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-bin.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip

0 commit comments

Comments
 (0)