├── settings.gradle
├── app
├── build.gradle
└── src
│ └── main
│ ├── java
│ └── com
│ │ └── example
│ │ └── android
│ │ └── contentproviderpaging
│ │ ├── ImageViewHolder.java
│ │ ├── MainActivity.java
│ │ ├── ImageContract.java
│ │ ├── ImageAdapter.java
│ │ ├── ImageClientFragment.java
│ │ └── ImageProvider.java
│ └── AndroidManifest.xml
├── kotlinApp
├── settings.gradle
├── app
│ ├── build.gradle
│ └── src
│ │ └── main
│ │ ├── kotlin
│ │ └── com.example.android.contentproviderpaging
│ │ │ ├── ImageViewHolder.kt
│ │ │ ├── MainActivity.kt
│ │ │ ├── ImageContract.kt
│ │ │ ├── ImageAdapter.kt
│ │ │ ├── ImageClientFragment.kt
│ │ │ └── ImageProvider.kt
│ │ └── AndroidManifest.xml
├── resources
│ ├── src
│ │ └── main
│ │ │ ├── AndroidManifest.xml
│ │ │ └── res
│ │ │ ├── raw
│ │ │ ├── cat_1.jpg
│ │ │ ├── cat_2.jpg
│ │ │ ├── cat_3.jpg
│ │ │ ├── cat_4.jpg
│ │ │ ├── cat_5.jpg
│ │ │ ├── cat_6.jpg
│ │ │ ├── cat_7.jpg
│ │ │ ├── cat_8.jpg
│ │ │ ├── cat_9.jpg
│ │ │ ├── cat_10.jpg
│ │ │ ├── cat_11.jpg
│ │ │ ├── cat_12.jpg
│ │ │ └── cat_13.jpg
│ │ │ ├── drawable
│ │ │ └── cat_placeholder.png
│ │ │ ├── mipmap-hdpi
│ │ │ ├── ic_launcher.png
│ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-mdpi
│ │ │ ├── ic_launcher.png
│ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-xhdpi
│ │ │ ├── ic_launcher.png
│ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-xxhdpi
│ │ │ ├── ic_launcher.png
│ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-xxxhdpi
│ │ │ ├── ic_launcher.png
│ │ │ └── ic_launcher_round.png
│ │ │ ├── values
│ │ │ ├── colors.xml
│ │ │ ├── dimens.xml
│ │ │ ├── styles.xml
│ │ │ ├── strings.xml
│ │ │ └── arrays.xml
│ │ │ └── layout
│ │ │ ├── activity_main.xml
│ │ │ ├── viewholder_image.xml
│ │ │ └── fragment_image_client.xml
│ ├── build.gradle
│ └── proguard-rules.pro
├── screenshots
│ ├── icon-web.png
│ └── screenshot-1.png
├── gradle
│ └── wrapper
│ │ ├── gradle-wrapper.jar
│ │ └── gradle-wrapper.properties
├── build.gradle
├── common.gradle
├── .google
│ └── packaging.yaml
├── NOTICE
├── CONTRIBUTING.md
├── gradlew.bat
├── README.md
├── gradlew
└── LICENSE
├── resources
├── src
│ └── main
│ │ ├── AndroidManifest.xml
│ │ └── res
│ │ ├── raw
│ │ ├── cat_1.jpg
│ │ ├── cat_2.jpg
│ │ ├── cat_3.jpg
│ │ ├── cat_4.jpg
│ │ ├── cat_5.jpg
│ │ ├── cat_6.jpg
│ │ ├── cat_7.jpg
│ │ ├── cat_8.jpg
│ │ ├── cat_9.jpg
│ │ ├── cat_10.jpg
│ │ ├── cat_11.jpg
│ │ ├── cat_12.jpg
│ │ └── cat_13.jpg
│ │ ├── drawable
│ │ └── cat_placeholder.png
│ │ ├── mipmap-hdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-mdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── values
│ │ ├── colors.xml
│ │ ├── dimens.xml
│ │ ├── styles.xml
│ │ ├── strings.xml
│ │ └── arrays.xml
│ │ └── layout
│ │ ├── activity_main.xml
│ │ ├── viewholder_image.xml
│ │ └── fragment_image_client.xml
├── build.gradle
└── proguard-rules.pro
├── screenshots
├── icon-web.png
└── screenshot-1.png
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── README.md
├── common.gradle
├── .google
└── packaging.yaml
├── NOTICE
├── CONTRIBUTING.md
├── gradlew.bat
├── gradlew
└── LICENSE
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':resources'
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply from: '../common.gradle'
2 |
--------------------------------------------------------------------------------
/kotlinApp/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':resources'
2 |
--------------------------------------------------------------------------------
/kotlinApp/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply from: '../common.gradle'
2 |
--------------------------------------------------------------------------------
/resources/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/kotlinApp/resources/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/screenshots/icon-web.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/googlearchive/android-ContentProviderPaging/master/screenshots/icon-web.png
--------------------------------------------------------------------------------
/screenshots/screenshot-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/googlearchive/android-ContentProviderPaging/master/screenshots/screenshot-1.png
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/googlearchive/android-ContentProviderPaging/master/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/kotlinApp/screenshots/icon-web.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/googlearchive/android-ContentProviderPaging/master/kotlinApp/screenshots/icon-web.png
--------------------------------------------------------------------------------
/resources/src/main/res/raw/cat_1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/googlearchive/android-ContentProviderPaging/master/resources/src/main/res/raw/cat_1.jpg
--------------------------------------------------------------------------------
/resources/src/main/res/raw/cat_2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/googlearchive/android-ContentProviderPaging/master/resources/src/main/res/raw/cat_2.jpg
--------------------------------------------------------------------------------
/resources/src/main/res/raw/cat_3.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/googlearchive/android-ContentProviderPaging/master/resources/src/main/res/raw/cat_3.jpg
--------------------------------------------------------------------------------
/resources/src/main/res/raw/cat_4.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/googlearchive/android-ContentProviderPaging/master/resources/src/main/res/raw/cat_4.jpg
--------------------------------------------------------------------------------
/resources/src/main/res/raw/cat_5.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/googlearchive/android-ContentProviderPaging/master/resources/src/main/res/raw/cat_5.jpg
--------------------------------------------------------------------------------
/resources/src/main/res/raw/cat_6.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/googlearchive/android-ContentProviderPaging/master/resources/src/main/res/raw/cat_6.jpg
--------------------------------------------------------------------------------
/resources/src/main/res/raw/cat_7.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/googlearchive/android-ContentProviderPaging/master/resources/src/main/res/raw/cat_7.jpg
--------------------------------------------------------------------------------
/resources/src/main/res/raw/cat_8.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/googlearchive/android-ContentProviderPaging/master/resources/src/main/res/raw/cat_8.jpg
--------------------------------------------------------------------------------
/resources/src/main/res/raw/cat_9.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/googlearchive/android-ContentProviderPaging/master/resources/src/main/res/raw/cat_9.jpg
--------------------------------------------------------------------------------
/kotlinApp/screenshots/screenshot-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/googlearchive/android-ContentProviderPaging/master/kotlinApp/screenshots/screenshot-1.png
--------------------------------------------------------------------------------
/resources/src/main/res/raw/cat_10.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/googlearchive/android-ContentProviderPaging/master/resources/src/main/res/raw/cat_10.jpg
--------------------------------------------------------------------------------
/resources/src/main/res/raw/cat_11.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/googlearchive/android-ContentProviderPaging/master/resources/src/main/res/raw/cat_11.jpg
--------------------------------------------------------------------------------
/resources/src/main/res/raw/cat_12.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/googlearchive/android-ContentProviderPaging/master/resources/src/main/res/raw/cat_12.jpg
--------------------------------------------------------------------------------
/resources/src/main/res/raw/cat_13.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/googlearchive/android-ContentProviderPaging/master/resources/src/main/res/raw/cat_13.jpg
--------------------------------------------------------------------------------
/kotlinApp/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/googlearchive/android-ContentProviderPaging/master/kotlinApp/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/kotlinApp/resources/src/main/res/raw/cat_1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/googlearchive/android-ContentProviderPaging/master/kotlinApp/resources/src/main/res/raw/cat_1.jpg
--------------------------------------------------------------------------------
/kotlinApp/resources/src/main/res/raw/cat_2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/googlearchive/android-ContentProviderPaging/master/kotlinApp/resources/src/main/res/raw/cat_2.jpg
--------------------------------------------------------------------------------
/kotlinApp/resources/src/main/res/raw/cat_3.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/googlearchive/android-ContentProviderPaging/master/kotlinApp/resources/src/main/res/raw/cat_3.jpg
--------------------------------------------------------------------------------
/kotlinApp/resources/src/main/res/raw/cat_4.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/googlearchive/android-ContentProviderPaging/master/kotlinApp/resources/src/main/res/raw/cat_4.jpg
--------------------------------------------------------------------------------
/kotlinApp/resources/src/main/res/raw/cat_5.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/googlearchive/android-ContentProviderPaging/master/kotlinApp/resources/src/main/res/raw/cat_5.jpg
--------------------------------------------------------------------------------
/kotlinApp/resources/src/main/res/raw/cat_6.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/googlearchive/android-ContentProviderPaging/master/kotlinApp/resources/src/main/res/raw/cat_6.jpg
--------------------------------------------------------------------------------
/kotlinApp/resources/src/main/res/raw/cat_7.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/googlearchive/android-ContentProviderPaging/master/kotlinApp/resources/src/main/res/raw/cat_7.jpg
--------------------------------------------------------------------------------
/kotlinApp/resources/src/main/res/raw/cat_8.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/googlearchive/android-ContentProviderPaging/master/kotlinApp/resources/src/main/res/raw/cat_8.jpg
--------------------------------------------------------------------------------
/kotlinApp/resources/src/main/res/raw/cat_9.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/googlearchive/android-ContentProviderPaging/master/kotlinApp/resources/src/main/res/raw/cat_9.jpg
--------------------------------------------------------------------------------
/kotlinApp/resources/src/main/res/raw/cat_10.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/googlearchive/android-ContentProviderPaging/master/kotlinApp/resources/src/main/res/raw/cat_10.jpg
--------------------------------------------------------------------------------
/kotlinApp/resources/src/main/res/raw/cat_11.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/googlearchive/android-ContentProviderPaging/master/kotlinApp/resources/src/main/res/raw/cat_11.jpg
--------------------------------------------------------------------------------
/kotlinApp/resources/src/main/res/raw/cat_12.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/googlearchive/android-ContentProviderPaging/master/kotlinApp/resources/src/main/res/raw/cat_12.jpg
--------------------------------------------------------------------------------
/kotlinApp/resources/src/main/res/raw/cat_13.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/googlearchive/android-ContentProviderPaging/master/kotlinApp/resources/src/main/res/raw/cat_13.jpg
--------------------------------------------------------------------------------
/resources/src/main/res/drawable/cat_placeholder.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/googlearchive/android-ContentProviderPaging/master/resources/src/main/res/drawable/cat_placeholder.png
--------------------------------------------------------------------------------
/resources/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/googlearchive/android-ContentProviderPaging/master/resources/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/resources/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/googlearchive/android-ContentProviderPaging/master/resources/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/resources/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/googlearchive/android-ContentProviderPaging/master/resources/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/resources/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/googlearchive/android-ContentProviderPaging/master/resources/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/resources/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/googlearchive/android-ContentProviderPaging/master/resources/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/resources/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/googlearchive/android-ContentProviderPaging/master/resources/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/resources/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/googlearchive/android-ContentProviderPaging/master/resources/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/resources/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/googlearchive/android-ContentProviderPaging/master/resources/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/resources/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/googlearchive/android-ContentProviderPaging/master/resources/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/kotlinApp/resources/src/main/res/drawable/cat_placeholder.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/googlearchive/android-ContentProviderPaging/master/kotlinApp/resources/src/main/res/drawable/cat_placeholder.png
--------------------------------------------------------------------------------
/kotlinApp/resources/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/googlearchive/android-ContentProviderPaging/master/kotlinApp/resources/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/kotlinApp/resources/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/googlearchive/android-ContentProviderPaging/master/kotlinApp/resources/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/kotlinApp/resources/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/googlearchive/android-ContentProviderPaging/master/kotlinApp/resources/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/resources/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/googlearchive/android-ContentProviderPaging/master/resources/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/kotlinApp/resources/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/googlearchive/android-ContentProviderPaging/master/kotlinApp/resources/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/kotlinApp/resources/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/googlearchive/android-ContentProviderPaging/master/kotlinApp/resources/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/kotlinApp/resources/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/googlearchive/android-ContentProviderPaging/master/kotlinApp/resources/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/kotlinApp/resources/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/googlearchive/android-ContentProviderPaging/master/kotlinApp/resources/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/kotlinApp/resources/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/googlearchive/android-ContentProviderPaging/master/kotlinApp/resources/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/kotlinApp/resources/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/googlearchive/android-ContentProviderPaging/master/kotlinApp/resources/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/kotlinApp/resources/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/googlearchive/android-ContentProviderPaging/master/kotlinApp/resources/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/kotlinApp/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Mon Oct 17 16:40:13 PDT 2016
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
7 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Mon Oct 17 16:40:13 PDT 2016
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
7 | >>>>>>> ContentProviderPaging: Make kotlinApp module self-contained
8 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 | Android ContentProviderPaging Sample
3 | ====================================
4 |
5 | This sample has been deprecated/archived meaning it's read-only and it's no longer actively maintained (more details on archiving can be found [here][1]).
6 |
7 | For other related samples, check out the new [github.com/android/storage-samples][2] repo. Thank you!
8 |
9 | [1]: https://help.github.com/en/articles/about-archiving-repositories
10 | [2]: https://github.com/android/storage-samples
11 |
--------------------------------------------------------------------------------
/kotlinApp/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 | buildscript {
3 | ext.kotlin_version = '1.1.2-4'
4 | repositories {
5 | jcenter()
6 | }
7 | dependencies {
8 | classpath 'com.android.tools.build:gradle:3.0.0'
9 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
10 | }
11 | }
12 |
13 | allprojects {
14 | repositories {
15 | jcenter()
16 | }
17 | }
18 |
19 |
--------------------------------------------------------------------------------
/common.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 26
5 | buildToolsVersion "26.0.1"
6 |
7 | defaultConfig {
8 | applicationId "com.example.android.contentproviderpaging"
9 | minSdkVersion 26
10 | targetSdkVersion 26
11 | }
12 |
13 | buildTypes {
14 | release {
15 | minifyEnabled false
16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
17 | }
18 | }
19 |
20 | dependencies {
21 | compile project(':resources')
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/kotlinApp/common.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 26
5 | buildToolsVersion "26.0.1"
6 |
7 | defaultConfig {
8 | applicationId "com.example.android.contentproviderpaging"
9 | minSdkVersion 26
10 | targetSdkVersion 26
11 | }
12 |
13 | buildTypes {
14 | release {
15 | minifyEnabled false
16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
17 | }
18 | }
19 |
20 | dependencies {
21 | compile project(':resources')
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/.google/packaging.yaml:
--------------------------------------------------------------------------------
1 |
2 | # GOOGLE SAMPLE PACKAGING DATA
3 | #
4 | # This file is used by Google as part of our samples packaging process.
5 | # End users may safely ignore this file. It has no relevance to other systems.
6 | ---
7 | status: PUBLISHED
8 | technologies: [Android]
9 | categories: [Content, Android O Preview]
10 | languages: [Java]
11 | solutions: [Mobile]
12 | github: android-ContentProviderPaging
13 | level: INTERMEDIATE
14 | icon: screenshots/icon-web.png
15 | apiRefs:
16 | - android:android.content.ContentProvider
17 | - android:android.provider.DocumentsProvider
18 | license: apache2
19 |
--------------------------------------------------------------------------------
/kotlinApp/.google/packaging.yaml:
--------------------------------------------------------------------------------
1 |
2 | # GOOGLE SAMPLE PACKAGING DATA
3 | #
4 | # This file is used by Google as part of our samples packaging process.
5 | # End users may safely ignore this file. It has no relevance to other systems.
6 | ---
7 | status: PUBLISHED
8 | technologies: [Android]
9 | categories: [Content, Android O Preview]
10 | languages: [Java]
11 | solutions: [Mobile]
12 | github: android-ContentProviderPaging
13 | level: INTERMEDIATE
14 | icon: screenshots/icon-web.png
15 | apiRefs:
16 | - android:android.content.ContentProvider
17 | - android:android.provider.DocumentsProvider
18 | license: apache2
19 |
--------------------------------------------------------------------------------
/NOTICE:
--------------------------------------------------------------------------------
1 |
2 | This sample uses the following software:
3 |
4 | Copyright 2018 The Android Open Source Project
5 |
6 | Licensed under the Apache License, Version 2.0 (the "License");
7 | you may not use this file except in compliance with the License.
8 | You may obtain a copy of the License at
9 |
10 | http://www.apache.org/licenses/LICENSE-2.0
11 |
12 | Unless required by applicable law or agreed to in writing, software
13 | distributed under the License is distributed on an "AS IS" BASIS,
14 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | See the License for the specific language governing permissions and
16 | limitations under the License.
17 |
--------------------------------------------------------------------------------
/kotlinApp/NOTICE:
--------------------------------------------------------------------------------
1 |
2 | This sample uses the following software:
3 |
4 | Copyright 2017 The Android Open Source Project
5 |
6 | Licensed under the Apache License, Version 2.0 (the "License");
7 | you may not use this file except in compliance with the License.
8 | You may obtain a copy of the License at
9 |
10 | http://www.apache.org/licenses/LICENSE-2.0
11 |
12 | Unless required by applicable law or agreed to in writing, software
13 | distributed under the License is distributed on an "AS IS" BASIS,
14 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | See the License for the specific language governing permissions and
16 | limitations under the License.
17 |
--------------------------------------------------------------------------------
/resources/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | android {
4 | compileSdkVersion 25
5 | buildToolsVersion "25.0.2"
6 |
7 | defaultConfig {
8 | minSdkVersion 16
9 | targetSdkVersion 25
10 | versionCode 1
11 | versionName "1.0"
12 |
13 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
14 |
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 'com.android.support:appcompat-v7:25.3.1'
26 | compile 'com.android.support:recyclerview-v7:25.3.1'
27 | compile 'com.github.bumptech.glide:glide:3.7.0'
28 | testCompile 'junit:junit:4.12'
29 | }
30 |
--------------------------------------------------------------------------------
/kotlinApp/resources/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | android {
4 | compileSdkVersion 25
5 | buildToolsVersion "25.0.2"
6 |
7 | defaultConfig {
8 | minSdkVersion 16
9 | targetSdkVersion 25
10 | versionCode 1
11 | versionName "1.0"
12 |
13 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
14 |
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 'com.android.support:appcompat-v7:25.3.1'
26 | compile 'com.android.support:recyclerview-v7:25.3.1'
27 | compile 'com.github.bumptech.glide:glide:3.7.0'
28 | testCompile 'junit:junit:4.12'
29 | }
30 |
--------------------------------------------------------------------------------
/resources/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 | #3F51B5
19 | #303F9F
20 | #FF4081
21 |
22 |
--------------------------------------------------------------------------------
/resources/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
16 |
20 |
--------------------------------------------------------------------------------
/kotlinApp/resources/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 | #3F51B5
19 | #303F9F
20 | #FF4081
21 |
22 |
--------------------------------------------------------------------------------
/kotlinApp/resources/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
16 |
20 |
--------------------------------------------------------------------------------
/resources/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
16 |
17 |
18 |
19 | 4dp
20 | 4dp
21 |
22 | 16dp
23 |
24 |
--------------------------------------------------------------------------------
/kotlinApp/resources/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
16 |
17 |
18 |
19 | 4dp
20 | 4dp
21 |
22 | 16dp
23 |
24 |
--------------------------------------------------------------------------------
/resources/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /usr/local/google/home/thagikura/android-sdk_o_release_3855523/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
26 |
--------------------------------------------------------------------------------
/kotlinApp/resources/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /usr/local/google/home/thagikura/android-sdk_o_release_3855523/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
26 |
--------------------------------------------------------------------------------
/resources/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
15 |
16 |
17 |
23 |
24 |
--------------------------------------------------------------------------------
/kotlinApp/resources/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
15 |
16 |
17 |
23 |
24 |
--------------------------------------------------------------------------------
/resources/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
16 |
17 |
18 | ContentProvider Paging sample
19 | The root directory of the documents
20 |
21 | Fetched from %1$d to %2$d images out of %3$d in total.
22 | A cat image
23 | Show images
24 |
25 |
--------------------------------------------------------------------------------
/kotlinApp/resources/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
16 |
17 |
18 | ContentProvider Paging sample
19 | The root directory of the documents
20 |
21 | Fetched from %1$d to %2$d images out of %3$d in total.
22 | A cat image
23 | Show images
24 |
25 |
--------------------------------------------------------------------------------
/resources/src/main/res/values/arrays.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
18 |
19 | - @raw/cat_1
20 | - @raw/cat_2
21 | - @raw/cat_3
22 | - @raw/cat_4
23 | - @raw/cat_5
24 | - @raw/cat_6
25 | - @raw/cat_7
26 | - @raw/cat_8
27 | - @raw/cat_9
28 | - @raw/cat_10
29 | - @raw/cat_11
30 | - @raw/cat_12
31 | - @raw/cat_13
32 |
33 |
34 |
--------------------------------------------------------------------------------
/kotlinApp/resources/src/main/res/values/arrays.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
18 |
19 | - @raw/cat_1
20 | - @raw/cat_2
21 | - @raw/cat_3
22 | - @raw/cat_4
23 | - @raw/cat_5
24 | - @raw/cat_6
25 | - @raw/cat_7
26 | - @raw/cat_8
27 | - @raw/cat_9
28 | - @raw/cat_10
29 | - @raw/cat_11
30 | - @raw/cat_12
31 | - @raw/cat_13
32 |
33 |
34 |
--------------------------------------------------------------------------------
/kotlinApp/app/src/main/kotlin/com.example.android.contentproviderpaging/ImageViewHolder.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2017 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.example.android.contentproviderpaging
18 |
19 | import android.support.v7.widget.RecyclerView
20 | import android.view.View
21 | import android.widget.ImageView
22 | import android.widget.TextView
23 |
24 | /**
25 | * ViewHolder that represents an image.
26 | */
27 | internal class ImageViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
28 |
29 | var mImageView: ImageView = itemView.findViewById(R.id.imageview)
30 | var mTextView: TextView = itemView.findViewById(R.id.textview_image_label)
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/android/contentproviderpaging/ImageViewHolder.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2017 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.example.android.contentproviderpaging;
18 |
19 | import android.support.v7.widget.RecyclerView;
20 | import android.view.View;
21 | import android.widget.ImageView;
22 | import android.widget.TextView;
23 |
24 | /**
25 | * ViewHolder that represents an image.
26 | */
27 | class ImageViewHolder extends RecyclerView.ViewHolder {
28 |
29 | ImageView mImageView;
30 | TextView mTextView;
31 |
32 | ImageViewHolder(View itemView) {
33 | super(itemView);
34 |
35 | mImageView = itemView.findViewById(R.id.imageview);
36 | mTextView = itemView.findViewById(R.id.textview_image_label);
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/kotlinApp/app/src/main/kotlin/com.example.android.contentproviderpaging/MainActivity.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2017 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.example.android.contentproviderpaging
18 |
19 | import android.os.Bundle
20 | import android.support.v7.app.AppCompatActivity
21 |
22 | /**
23 | * The launcher Activity.
24 | */
25 | class MainActivity : AppCompatActivity() {
26 |
27 | override fun onCreate(savedInstanceState: Bundle?) {
28 | super.onCreate(savedInstanceState)
29 | setContentView(R.layout.activity_main)
30 |
31 | if (savedInstanceState == null) {
32 | supportFragmentManager.beginTransaction()
33 | .add(R.id.container, ImageClientFragment.newInstance())
34 | .commit()
35 | }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/android/contentproviderpaging/MainActivity.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2017 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.example.android.contentproviderpaging;
18 |
19 | import android.os.Bundle;
20 | import android.support.v7.app.AppCompatActivity;
21 |
22 | /**
23 | * The launcher Activity.
24 | */
25 | public class MainActivity extends AppCompatActivity {
26 |
27 | @Override
28 | protected void onCreate(Bundle savedInstanceState) {
29 | super.onCreate(savedInstanceState);
30 | setContentView(R.layout.activity_main);
31 |
32 | if (savedInstanceState == null) {
33 | getSupportFragmentManager().beginTransaction()
34 | .add(R.id.container, ImageClientFragment.newInstance())
35 | .commit();
36 | }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/kotlinApp/app/src/main/kotlin/com.example.android.contentproviderpaging/ImageContract.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2017 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.example.android.contentproviderpaging
18 |
19 | import android.net.Uri
20 | import android.provider.BaseColumns
21 |
22 | /**
23 | * The contract for the [ImageProvider].
24 | */
25 | internal object ImageContract {
26 |
27 | val AUTHORITY = "com.example.android.contentproviderpaging.documents"
28 |
29 | val CONTENT_URI = Uri.parse("content://$AUTHORITY/images")!!
30 |
31 | internal interface Columns : BaseColumns {
32 | companion object {
33 |
34 | val DISPLAY_NAME = "display_name"
35 |
36 | val ABSOLUTE_PATH = "absolute_path"
37 |
38 | val SIZE = "size"
39 | }
40 | }
41 |
42 | val PROJECTION_ALL = arrayOf(BaseColumns._ID, Columns.DISPLAY_NAME, Columns.ABSOLUTE_PATH, Columns.SIZE)
43 | }
44 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/android/contentproviderpaging/ImageContract.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2017 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.example.android.contentproviderpaging;
18 |
19 | import android.net.Uri;
20 | import android.provider.BaseColumns;
21 |
22 | /**
23 | * The contract for the {@link ImageProvider}.
24 | */
25 | class ImageContract {
26 |
27 | static final String AUTHORITY = "com.example.android.contentproviderpaging.documents";
28 |
29 | static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/images");
30 |
31 | interface Columns extends BaseColumns {
32 |
33 | String DISPLAY_NAME = "display_name";
34 |
35 | String ABSOLUTE_PATH = "absolute_path";
36 |
37 | String SIZE = "size";
38 | }
39 |
40 | static final String[] PROJECTION_ALL = new String[]{
41 | Columns._ID,
42 | Columns.DISPLAY_NAME,
43 | Columns.ABSOLUTE_PATH,
44 | Columns.SIZE
45 | };
46 | }
47 |
--------------------------------------------------------------------------------
/resources/src/main/res/layout/viewholder_image.xml:
--------------------------------------------------------------------------------
1 |
16 |
19 |
20 |
27 |
28 |
39 |
40 |
--------------------------------------------------------------------------------
/kotlinApp/resources/src/main/res/layout/viewholder_image.xml:
--------------------------------------------------------------------------------
1 |
16 |
19 |
20 |
27 |
28 |
39 |
40 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # How to become a contributor and submit your own code
2 |
3 | ## Contributor License Agreements
4 |
5 | We'd love to accept your sample apps and patches! Before we can take them, we
6 | have to jump a couple of legal hurdles.
7 |
8 | Please fill out either the individual or corporate Contributor License Agreement (CLA).
9 |
10 | * If you are an individual writing original source code and you're sure you
11 | own the intellectual property, then you'll need to sign an [individual CLA]
12 | (https://cla.developers.google.com).
13 | * If you work for a company that wants to allow you to contribute your work,
14 | then you'll need to sign a [corporate CLA]
15 | (https://cla.developers.google.com).
16 |
17 | Follow either of the two links above to access the appropriate CLA and
18 | instructions for how to sign and return it. Once we receive it, we'll be able to
19 | accept your pull requests.
20 |
21 | ## Contributing A Patch
22 |
23 | 1. Submit an issue describing your proposed change to the repo in question.
24 | 1. The repo owner will respond to your issue promptly.
25 | 1. If your proposed change is accepted, and you haven't already done so, sign a
26 | Contributor License Agreement (see details above).
27 | 1. Fork the desired repo, develop and test your code changes.
28 | 1. Ensure that your code adheres to the existing style in the sample to which
29 | you are contributing. Refer to the
30 | [Android Code Style Guide]
31 | (https://source.android.com/source/code-style.html) for the
32 | recommended coding standards for this organization.
33 | 1. Ensure that your code has an appropriate set of unit tests which all pass.
34 | 1. Submit a pull request.
35 |
36 |
--------------------------------------------------------------------------------
/kotlinApp/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # How to become a contributor and submit your own code
2 |
3 | ## Contributor License Agreements
4 |
5 | We'd love to accept your sample apps and patches! Before we can take them, we
6 | have to jump a couple of legal hurdles.
7 |
8 | Please fill out either the individual or corporate Contributor License Agreement (CLA).
9 |
10 | * If you are an individual writing original source code and you're sure you
11 | own the intellectual property, then you'll need to sign an [individual CLA]
12 | (https://cla.developers.google.com).
13 | * If you work for a company that wants to allow you to contribute your work,
14 | then you'll need to sign a [corporate CLA]
15 | (https://cla.developers.google.com).
16 |
17 | Follow either of the two links above to access the appropriate CLA and
18 | instructions for how to sign and return it. Once we receive it, we'll be able to
19 | accept your pull requests.
20 |
21 | ## Contributing A Patch
22 |
23 | 1. Submit an issue describing your proposed change to the repo in question.
24 | 1. The repo owner will respond to your issue promptly.
25 | 1. If your proposed change is accepted, and you haven't already done so, sign a
26 | Contributor License Agreement (see details above).
27 | 1. Fork the desired repo, develop and test your code changes.
28 | 1. Ensure that your code adheres to the existing style in the sample to which
29 | you are contributing. Refer to the
30 | [Android Code Style Guide]
31 | (https://source.android.com/source/code-style.html) for the
32 | recommended coding standards for this organization.
33 | 1. Ensure that your code has an appropriate set of unit tests which all pass.
34 | 1. Submit a pull request.
35 |
36 |
--------------------------------------------------------------------------------
/resources/src/main/res/layout/fragment_image_client.xml:
--------------------------------------------------------------------------------
1 |
16 |
25 |
26 |
33 |
34 |
39 |
40 |
--------------------------------------------------------------------------------
/kotlinApp/resources/src/main/res/layout/fragment_image_client.xml:
--------------------------------------------------------------------------------
1 |
16 |
25 |
26 |
33 |
34 |
39 |
40 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
16 |
17 |
19 |
20 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/kotlinApp/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
16 |
17 |
19 |
20 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/kotlinApp/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/kotlinApp/README.md:
--------------------------------------------------------------------------------
1 | Android ContentProviderPaging Sample (Kotlin)
2 | ===================================
3 |
4 | This sample demonstrates how to use the ContentProvider with paging support introduced
5 | in Android O. The ContentProvider now accepts additional arguments for the offset and
6 | the limit in the query method to support paging instead of fetching all the data in
7 | a single query method call.
8 |
9 | Introduction
10 | ------------
11 |
12 | [ContentProvider][1] and [DocumentsProvider][2] now supports paging instead of fetching the all
13 | data at once.
14 |
15 | Starting from Android O, ContentProvider#query(Uri, String[], Bundle, CancellationSignal) and
16 | DocumentsProvider#query(Uri, String[], Bundle, CancellationSignal) methods are introduced.
17 | The Bundle accepts the keys for ContentResolver.QUERY_ARG_OFFSET as an starting offset and
18 | ContentResolver.QUERY_ARG_LIMIT as the number of items included in the returned Cursor object.
19 |
20 | Similarly, the returned Cursor object now has a Bundle object obtained by Cursor#getExtras().
21 | The Bundle is able to include data such as the total size of the underlying data set.
22 |
23 | [1]: https://developer.android.com/reference/android/content/ContentProvider.html
24 | [2]: https://developer.android.com/reference/android/provider/DocumentsProvider.html
25 |
26 | Pre-requisites
27 | --------------
28 |
29 | - Android SDK 25
30 | - Android Build Tools v25.0.3
31 | - Android Support Repository
32 |
33 | Screenshots
34 | -------------
35 |
36 |
37 |
38 | Getting Started
39 | ---------------
40 |
41 | This sample uses the Gradle build system. To build this project, use the
42 | "gradlew build" command or use "Import Project" in Android Studio.
43 |
44 | Support
45 | -------
46 |
47 | - Google+ Community: https://plus.google.com/communities/105153134372062985968
48 | - Stack Overflow: http://stackoverflow.com/questions/tagged/android
49 |
50 | If you've found an error in this sample, please file an issue:
51 | https://github.com/googlesamples/android-ContentProviderPaging
52 |
53 | Patches are encouraged, and may be submitted by forking this project and
54 | submitting a pull request through GitHub. Please see CONTRIBUTING.md for more details.
55 |
56 | License
57 | -------
58 |
59 | Copyright 2017 The Android Open Source Project, Inc.
60 |
61 | Licensed to the Apache Software Foundation (ASF) under one or more contributor
62 | license agreements. See the NOTICE file distributed with this work for
63 | additional information regarding copyright ownership. The ASF licenses this
64 | file to you under the Apache License, Version 2.0 (the "License"); you may not
65 | use this file except in compliance with the License. You may obtain a copy of
66 | the License at
67 |
68 | http://www.apache.org/licenses/LICENSE-2.0
69 |
70 | Unless required by applicable law or agreed to in writing, software
71 | distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
72 | WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
73 | License for the specific language governing permissions and limitations under
74 | the License.
75 |
--------------------------------------------------------------------------------
/kotlinApp/app/src/main/kotlin/com.example.android.contentproviderpaging/ImageAdapter.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2017 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.example.android.contentproviderpaging
18 |
19 | import android.content.Context
20 | import android.support.v4.content.res.ResourcesCompat
21 | import android.support.v7.widget.RecyclerView
22 | import android.view.LayoutInflater
23 | import android.view.ViewGroup
24 | import com.bumptech.glide.Glide
25 | import java.util.*
26 |
27 | /**
28 | * Adapter for RecyclerView, which manages the image documents.
29 | */
30 | internal class ImageAdapter(private val mContext: Context) : RecyclerView.Adapter() {
31 |
32 | /** Holds the information for already retrieved images. */
33 | private val mImageDocuments = ArrayList()
34 |
35 | /**
36 | * The total size of the all images. This number should be the size for all images even if
37 | * they are not fetched from the ContentProvider.
38 | */
39 | private var mTotalSize: Int = 0
40 |
41 | override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ImageViewHolder {
42 | val view = LayoutInflater.from(parent.context)
43 | .inflate(R.layout.viewholder_image, parent, false)
44 | return ImageViewHolder(view)
45 | }
46 |
47 | override fun onBindViewHolder(holder: ImageViewHolder, position: Int) {
48 | val resources = mContext.resources
49 | if (mImageDocuments.size > position) {
50 | Glide.with(mContext)
51 | .load(mImageDocuments[position].absolutePath)
52 | .placeholder(R.drawable.cat_placeholder)
53 | .into(holder.mImageView)
54 | holder.mTextView.text = (position + 1).toString()
55 | } else {
56 | holder.mImageView.setImageDrawable(
57 | ResourcesCompat.getDrawable(resources, R.drawable.cat_placeholder, null))
58 | }
59 | }
60 |
61 | /**
62 | * Add an image as part of the adapter.
63 |
64 | * @param imageDocument the image information to be added
65 | */
66 | fun add(imageDocument: ImageDocument) {
67 | mImageDocuments.add(imageDocument)
68 | }
69 |
70 | /**
71 | * Set the total size of all images.
72 |
73 | * @param totalSize the total size
74 | */
75 | fun setTotalSize(totalSize: Int) {
76 | mTotalSize = totalSize
77 | }
78 |
79 | /**
80 | * @return the number of images already fetched and added to this adapter.
81 | */
82 | val fetchedItemCount: Int
83 | get() = mImageDocuments.size
84 |
85 | override fun getItemCount(): Int {
86 | return mTotalSize
87 | }
88 |
89 | /**
90 | * Represents information for an image.
91 | */
92 | internal data class ImageDocument(val absolutePath: String, val displayName: String)
93 | }
94 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/android/contentproviderpaging/ImageAdapter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2017 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.example.android.contentproviderpaging;
18 |
19 | import com.bumptech.glide.Glide;
20 |
21 | import android.content.Context;
22 | import android.content.res.Resources;
23 | import android.support.v4.content.res.ResourcesCompat;
24 | import android.support.v7.widget.RecyclerView;
25 | import android.view.LayoutInflater;
26 | import android.view.View;
27 | import android.view.ViewGroup;
28 |
29 | import java.util.ArrayList;
30 | import java.util.List;
31 |
32 | /**
33 | * Adapter for RecyclerView, which manages the image documents.
34 | */
35 | class ImageAdapter extends RecyclerView.Adapter {
36 |
37 | private final Context mContext;
38 |
39 | /** Holds the information for already retrieved images. */
40 | private final List mImageDocuments = new ArrayList<>();
41 |
42 | /**
43 | * The total size of the all images. This number should be the size for all images even if
44 | * they are not fetched from the ContentProvider.
45 | */
46 | private int mTotalSize;
47 |
48 | ImageAdapter(Context context) {
49 | mContext = context;
50 | }
51 |
52 | @Override
53 | public ImageViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
54 | View view = LayoutInflater.from(parent.getContext())
55 | .inflate(R.layout.viewholder_image, parent, false);
56 | return new ImageViewHolder(view);
57 | }
58 |
59 | @Override
60 | public void onBindViewHolder(ImageViewHolder holder, int position) {
61 | Resources resources = mContext.getResources();
62 | if (mImageDocuments.size() > position) {
63 | Glide.with(mContext)
64 | .load(mImageDocuments.get(position).mAbsolutePath)
65 | .placeholder(R.drawable.cat_placeholder)
66 | .into(holder.mImageView);
67 | holder.mTextView.setText(String.valueOf(position + 1));
68 | } else {
69 | holder.mImageView.setImageDrawable(
70 | ResourcesCompat.getDrawable(resources, R.drawable.cat_placeholder, null));
71 | }
72 | }
73 |
74 | /**
75 | * Add an image as part of the adapter.
76 | *
77 | * @param imageDocument the image information to be added
78 | */
79 | void add(ImageDocument imageDocument) {
80 | mImageDocuments.add(imageDocument);
81 | }
82 |
83 | /**
84 | * Set the total size of all images.
85 | *
86 | * @param totalSize the total size
87 | */
88 | void setTotalSize(int totalSize) {
89 | mTotalSize = totalSize;
90 | }
91 |
92 | /**
93 | * @return the number of images already fetched and added to this adapter.
94 | */
95 | int getFetchedItemCount() {
96 | return mImageDocuments.size();
97 | }
98 |
99 | @Override
100 | public int getItemCount() {
101 | return mTotalSize;
102 | }
103 |
104 | /**
105 | * Represents information for an image.
106 | */
107 | static class ImageDocument {
108 |
109 | String mAbsolutePath;
110 |
111 | String mDisplayName;
112 | }
113 | }
114 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/kotlinApp/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/kotlinApp/app/src/main/kotlin/com.example.android.contentproviderpaging/ImageClientFragment.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2017 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.example.android.contentproviderpaging
18 |
19 | import android.app.LoaderManager
20 | import android.content.ContentResolver
21 | import android.content.CursorLoader
22 | import android.content.Loader
23 | import android.database.Cursor
24 | import android.os.Bundle
25 | import android.support.v4.app.Fragment
26 | import android.support.v7.widget.LinearLayoutManager
27 | import android.support.v7.widget.RecyclerView
28 | import android.util.Log
29 | import android.view.LayoutInflater
30 | import android.view.View
31 | import android.view.ViewGroup
32 | import android.widget.Button
33 | import android.widget.Toast
34 | import java.util.concurrent.atomic.AtomicInteger
35 |
36 | /**
37 | * Fragment that works as a client for accessing the DocumentsProvider
38 | * ([ImageProvider].
39 | */
40 | class ImageClientFragment : Fragment() {
41 |
42 | private var mAdapter: ImageAdapter? = null
43 |
44 | private var mLayoutManager: LinearLayoutManager? = null
45 |
46 | private val mLoaderCallback = LoaderCallback()
47 |
48 | /**
49 | * The offset position for the ContentProvider to be used as a starting position to fetch
50 | * the images from.
51 | */
52 | private val mOffset = AtomicInteger(0)
53 |
54 | override fun onCreateView(inflater: LayoutInflater?, container: ViewGroup?,
55 | savedInstanceState: Bundle?): View? {
56 | return inflater?.inflate(R.layout.fragment_image_client, container, false)
57 | }
58 |
59 | override fun onViewCreated(rootView: View?, savedInstanceState: Bundle?) {
60 | super.onViewCreated(rootView, savedInstanceState)
61 |
62 | val activity = activity
63 | val recyclerView = activity.findViewById(R.id.recyclerview)
64 | if (mLayoutManager == null) {
65 | mLayoutManager = LinearLayoutManager(activity)
66 | }
67 | recyclerView.layoutManager = mLayoutManager
68 | if (mAdapter == null) {
69 | mAdapter = ImageAdapter(activity)
70 | }
71 | recyclerView.adapter = mAdapter
72 | recyclerView.addOnScrollListener(object : RecyclerView.OnScrollListener() {
73 | override fun onScrolled(recyclerView: RecyclerView?, dx: Int, dy: Int) {
74 | val lastVisiblePosition = mLayoutManager!!.findLastVisibleItemPosition()
75 | if (lastVisiblePosition >= mAdapter!!.fetchedItemCount) {
76 | Log.d(TAG,
77 | "Fetch new images. LastVisiblePosition: " + lastVisiblePosition
78 | + ", NonEmptyItemCount: " + mAdapter!!.fetchedItemCount)
79 |
80 | val pageId = lastVisiblePosition / LIMIT
81 | // Fetch new images once the last fetched item becomes visible
82 | activity.loaderManager
83 | .restartLoader(pageId, null, mLoaderCallback)
84 | }
85 | }
86 | })
87 |
88 | val showButton = rootView!!.findViewById