├── settings.gradle ├── lazyfragmentx ├── src │ └── main │ │ ├── AndroidManifest.xml │ │ ├── res │ │ └── values │ │ │ └── strings.xml │ │ └── java │ │ └── per │ │ └── goweii │ │ └── lazyfragmentx │ │ ├── CacheFragment.java │ │ └── LazyFragment.java ├── build.gradle └── proguard-rules.pro ├── app ├── release │ ├── app-release.apk │ └── output.json ├── src │ └── main │ │ ├── res │ │ ├── values │ │ │ ├── strings.xml │ │ │ ├── colors.xml │ │ │ └── styles.xml │ │ ├── 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 │ │ ├── mipmap-anydpi-v26 │ │ │ ├── ic_launcher.xml │ │ │ └── ic_launcher_round.xml │ │ ├── layout │ │ │ ├── fragment_test2.xml │ │ │ ├── fragment_test1.xml │ │ │ └── activity_main.xml │ │ ├── drawable-v24 │ │ │ └── ic_launcher_foreground.xml │ │ └── drawable │ │ │ └── ic_launcher_background.xml │ │ ├── AndroidManifest.xml │ │ └── java │ │ └── per │ │ └── goweii │ │ └── android │ │ └── lazyfragment │ │ ├── FixFragmentPagerAdapter.java │ │ ├── Test2Fragment.java │ │ ├── MainActivity.java │ │ └── Test1Fragment.java ├── proguard-rules.pro └── build.gradle ├── appx ├── release │ ├── appx-release.apk │ └── output.json ├── src │ └── main │ │ ├── res │ │ ├── values │ │ │ ├── strings.xml │ │ │ ├── colors.xml │ │ │ └── styles.xml │ │ ├── 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 │ │ ├── mipmap-anydpi-v26 │ │ │ ├── ic_launcher.xml │ │ │ └── ic_launcher_round.xml │ │ ├── layout │ │ │ ├── fragment_test2.xml │ │ │ ├── fragment_test1.xml │ │ │ └── activity_main.xml │ │ ├── drawable-v24 │ │ │ └── ic_launcher_foreground.xml │ │ └── drawable │ │ │ └── ic_launcher_background.xml │ │ ├── AndroidManifest.xml │ │ └── java │ │ └── per │ │ └── goweii │ │ └── android │ │ └── lazyfragmentx │ │ ├── FixFragmentPagerAdapter.java │ │ ├── Test2Fragment.java │ │ ├── MainActivity.java │ │ └── Test1Fragment.java ├── proguard-rules.pro └── build.gradle ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── lazyfragment ├── src │ └── main │ │ ├── res │ │ └── values │ │ │ └── strings.xml │ │ ├── AndroidManifest.xml │ │ └── java │ │ └── per │ │ └── goweii │ │ └── lazyfragment │ │ ├── CacheFragment.java │ │ └── LazyFragment.java ├── build.gradle └── proguard-rules.pro ├── README.md ├── gradle.properties ├── .gitignore ├── gradlew.bat ├── gradlew └── LICENSE /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app', ':lazyfragment', ':lazyfragmentx', ':appx' 2 | -------------------------------------------------------------------------------- /lazyfragmentx/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /app/release/app-release.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/goweii/LazyFragment/HEAD/app/release/app-release.apk -------------------------------------------------------------------------------- /appx/release/appx-release.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/goweii/LazyFragment/HEAD/appx/release/appx-release.apk -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | LazyFragment 3 | 4 | -------------------------------------------------------------------------------- /appx/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | LazyFragment 3 | 4 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/goweii/LazyFragment/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /lazyfragment/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | LazyFragment 3 | 4 | -------------------------------------------------------------------------------- /lazyfragmentx/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | lazyfragmentx 3 | 4 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/goweii/LazyFragment/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/goweii/LazyFragment/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/goweii/LazyFragment/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/goweii/LazyFragment/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /appx/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/goweii/LazyFragment/HEAD/appx/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /appx/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/goweii/LazyFragment/HEAD/appx/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /appx/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/goweii/LazyFragment/HEAD/appx/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/goweii/LazyFragment/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /appx/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/goweii/LazyFragment/HEAD/appx/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /appx/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/goweii/LazyFragment/HEAD/appx/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/goweii/LazyFragment/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/goweii/LazyFragment/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/goweii/LazyFragment/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /appx/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/goweii/LazyFragment/HEAD/appx/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /appx/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/goweii/LazyFragment/HEAD/appx/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/goweii/LazyFragment/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/goweii/LazyFragment/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /appx/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/goweii/LazyFragment/HEAD/appx/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /appx/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/goweii/LazyFragment/HEAD/appx/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /appx/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/goweii/LazyFragment/HEAD/appx/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /lazyfragment/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #008577 4 | #00574B 5 | #D81B60 6 | 7 | -------------------------------------------------------------------------------- /appx/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #008577 4 | #00574B 5 | #D81B60 6 | 7 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Tue Jul 09 18:26:21 CST 2019 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-5.1.1-all.zip 7 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /appx/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /appx/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /appx/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /app/release/output.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "outputType": { 4 | "type": "APK" 5 | }, 6 | "apkData": { 7 | "type": "MAIN", 8 | "splits": [], 9 | "versionCode": 1, 10 | "versionName": "1.0", 11 | "enabled": true, 12 | "outputFile": "app-release.apk", 13 | "fullName": "release", 14 | "baseName": "release" 15 | }, 16 | "path": "app-release.apk", 17 | "properties": {} 18 | } 19 | ] -------------------------------------------------------------------------------- /appx/release/output.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "outputType": { 4 | "type": "APK" 5 | }, 6 | "apkData": { 7 | "type": "MAIN", 8 | "splits": [], 9 | "versionCode": 1, 10 | "versionName": "1.0", 11 | "enabled": true, 12 | "outputFile": "appx-release.apk", 13 | "fullName": "release", 14 | "baseName": "release" 15 | }, 16 | "path": "appx-release.apk", 17 | "properties": {} 18 | } 19 | ] -------------------------------------------------------------------------------- /app/src/main/res/layout/fragment_test2.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 17 | 18 | -------------------------------------------------------------------------------- /appx/src/main/res/layout/fragment_test2.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 17 | 18 | -------------------------------------------------------------------------------- /lazyfragment/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | 3 | android { 4 | compileSdkVersion 29 5 | buildToolsVersion "29.0.0" 6 | 7 | defaultConfig { 8 | minSdkVersion 14 9 | targetSdkVersion 29 10 | versionCode 1 11 | versionName "1.0" 12 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 13 | } 14 | 15 | buildTypes { 16 | release { 17 | minifyEnabled false 18 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 19 | } 20 | } 21 | } 22 | 23 | dependencies { 24 | implementation fileTree(dir: 'libs', include: ['*.jar']) 25 | implementation 'com.android.support:appcompat-v7:28.0.0' 26 | } 27 | -------------------------------------------------------------------------------- /lazyfragmentx/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | 3 | android { 4 | compileSdkVersion 29 5 | buildToolsVersion "29.0.0" 6 | 7 | defaultConfig { 8 | minSdkVersion 14 9 | targetSdkVersion 29 10 | versionCode 1 11 | versionName "1.0" 12 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 13 | } 14 | 15 | buildTypes { 16 | release { 17 | minifyEnabled false 18 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 19 | } 20 | } 21 | } 22 | 23 | dependencies { 24 | implementation fileTree(dir: 'libs', include: ['*.jar']) 25 | implementation 'androidx.appcompat:appcompat:1.0.2' 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /appx/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # LazyFragment 2 | 3 | 4 | ## DEMO下载 5 | 6 | [androidx-demo](https://github.com/goweii/LazyFragment/raw/master/appx/release/app-release.apk) 7 | 8 | [support-demo](https://github.com/goweii/LazyFragment/raw/master/app/release/app-release.apk) 9 | 10 | 11 | ## 集成 12 | 13 | - ### 添加jitpack库 14 | 15 | ```java 16 | // build.gradle(Project:) 17 | allprojects { 18 | repositories { 19 | ... 20 | maven { url 'https://www.jitpack.io' } 21 | } 22 | } 23 | ``` 24 | 25 | - ### 添加依赖 26 | 27 | [点击查看最新版本号](https://github.com/goweii/LazyFragment/releases) 28 | ```java 29 | // build.gradle(Module:) 30 | dependencies { 31 | // support 32 | implementation 'com.github.goweii.LazyFragment:lazyfragment:1.1.0' 33 | // androidx 34 | implementation 'com.github.goweii.LazyFragment:lazyfragmentx:1.1.0' 35 | } 36 | ``` 37 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /appx/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 28 5 | buildToolsVersion "28.0.3" 6 | defaultConfig { 7 | applicationId "per.goweii.android.lazyfragment" 8 | minSdkVersion 14 9 | targetSdkVersion 28 10 | versionCode 1 11 | versionName "1.0" 12 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 13 | } 14 | buildTypes { 15 | release { 16 | minifyEnabled false 17 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 18 | } 19 | } 20 | } 21 | 22 | dependencies { 23 | implementation fileTree(dir: 'libs', include: ['*.jar']) 24 | implementation 'com.android.support:appcompat-v7:28.0.0' 25 | implementation project(":lazyfragment") 26 | } 27 | -------------------------------------------------------------------------------- /appx/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 28 5 | buildToolsVersion "28.0.3" 6 | defaultConfig { 7 | applicationId "per.goweii.android.lazyfragmentx" 8 | minSdkVersion 14 9 | targetSdkVersion 28 10 | versionCode 1 11 | versionName "1.0" 12 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 13 | } 14 | buildTypes { 15 | release { 16 | minifyEnabled false 17 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 18 | } 19 | } 20 | } 21 | 22 | dependencies { 23 | implementation fileTree(dir: 'libs', include: ['*.jar']) 24 | implementation 'androidx.appcompat:appcompat:1.0.2' 25 | implementation project(":lazyfragmentx") 26 | } 27 | -------------------------------------------------------------------------------- /lazyfragment/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /lazyfragmentx/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /app/src/main/java/per/goweii/android/lazyfragment/FixFragmentPagerAdapter.java: -------------------------------------------------------------------------------- 1 | package per.goweii.android.lazyfragment; 2 | 3 | import android.support.v4.app.Fragment; 4 | import android.support.v4.app.FragmentManager; 5 | import android.support.v4.app.FragmentPagerAdapter; 6 | 7 | import java.util.List; 8 | 9 | public class FixFragmentPagerAdapter extends FragmentPagerAdapter { 10 | 11 | private List fragments = null; 12 | 13 | public FixFragmentPagerAdapter(FragmentManager fm) { 14 | super(fm); 15 | } 16 | 17 | public FixFragmentPagerAdapter(FragmentManager fm, List fragments) { 18 | super(fm); 19 | this.fragments = fragments; 20 | } 21 | 22 | public void setFragments(List fragments) { 23 | this.fragments = fragments; 24 | notifyDataSetChanged(); 25 | } 26 | 27 | @Override 28 | public Fragment getItem(int i) { 29 | return fragments.get(i); 30 | } 31 | 32 | @Override 33 | public int getCount() { 34 | return fragments == null ? 0 : fragments.size(); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /appx/src/main/java/per/goweii/android/lazyfragmentx/FixFragmentPagerAdapter.java: -------------------------------------------------------------------------------- 1 | package per.goweii.android.lazyfragmentx; 2 | 3 | import androidx.fragment.app.Fragment; 4 | import androidx.fragment.app.FragmentManager; 5 | import androidx.fragment.app.FragmentPagerAdapter; 6 | 7 | import java.util.List; 8 | 9 | public class FixFragmentPagerAdapter extends FragmentPagerAdapter { 10 | 11 | private List fragments = null; 12 | 13 | public FixFragmentPagerAdapter(FragmentManager fm) { 14 | super(fm); 15 | } 16 | 17 | public FixFragmentPagerAdapter(FragmentManager fm, List fragments) { 18 | super(fm); 19 | this.fragments = fragments; 20 | } 21 | 22 | public void setFragments(List fragments) { 23 | this.fragments = fragments; 24 | notifyDataSetChanged(); 25 | } 26 | 27 | @Override 28 | public Fragment getItem(int i) { 29 | return fragments.get(i); 30 | } 31 | 32 | @Override 33 | public int getCount() { 34 | return fragments == null ? 0 : fragments.size(); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | # IDE (e.g. Android Studio) users: 3 | # Gradle settings configured through the IDE *will override* 4 | # any settings specified in this file. 5 | # For more details on how to configure your build environment visit 6 | # http://www.gradle.org/docs/current/userguide/build_environment.html 7 | # Specifies the JVM arguments used for the daemon process. 8 | # The setting is particularly useful for tweaking memory settings. 9 | org.gradle.jvmargs=-Xmx1536m 10 | # When configured, Gradle will run in incubating parallel mode. 11 | # This option should only be used with decoupled projects. More details, visit 12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 13 | # org.gradle.parallel=true 14 | # AndroidX package structure to make it clearer which packages are bundled with the 15 | # Android operating system, and which are packaged with your app's APK 16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn 17 | # Automatically convert third-party libraries to use AndroidX 18 | android.enableJetifier=false 19 | android.useAndroidX=true 20 | -------------------------------------------------------------------------------- /appx/src/main/java/per/goweii/android/lazyfragmentx/Test2Fragment.java: -------------------------------------------------------------------------------- 1 | package per.goweii.android.lazyfragmentx; 2 | 3 | import android.os.Bundle; 4 | import android.view.View; 5 | import android.widget.TextView; 6 | 7 | import androidx.annotation.NonNull; 8 | import androidx.annotation.Nullable; 9 | 10 | import per.goweii.lazyfragmentx.LazyFragment; 11 | 12 | public class Test2Fragment extends LazyFragment { 13 | 14 | public static final String TAG = Test2Fragment.class.getSimpleName(); 15 | private String name; 16 | 17 | public static Test2Fragment newInstance(String name) { 18 | Test2Fragment fragment = new Test2Fragment(); 19 | Bundle args = new Bundle(1); 20 | args.putString("name", name); 21 | fragment.setArguments(args); 22 | return fragment; 23 | } 24 | 25 | @Override 26 | protected int getLayoutRes() { 27 | return R.layout.fragment_test2; 28 | } 29 | 30 | @Override 31 | public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { 32 | super.onViewCreated(view, savedInstanceState); 33 | name = getArguments().getString("name"); 34 | TextView tv_name = findViewById(R.id.tv_name); 35 | tv_name.setText(name); 36 | } 37 | 38 | @Override 39 | public void onVisible(boolean isFirstVisible) { 40 | super.onVisible(isFirstVisible); 41 | MainActivity.log(name + " onVisible : isFirstVisible=" + isFirstVisible); 42 | } 43 | 44 | @Override 45 | public void onInvisible() { 46 | super.onInvisible(); 47 | MainActivity.log(name + " onInvisible"); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /app/src/main/java/per/goweii/android/lazyfragment/Test2Fragment.java: -------------------------------------------------------------------------------- 1 | package per.goweii.android.lazyfragment; 2 | 3 | import android.os.Bundle; 4 | import android.support.annotation.NonNull; 5 | import android.support.annotation.Nullable; 6 | import android.view.View; 7 | import android.widget.TextView; 8 | 9 | import per.goweii.lazyfragment.LazyFragment; 10 | 11 | public class Test2Fragment extends LazyFragment { 12 | 13 | public static final String TAG = Test2Fragment.class.getSimpleName(); 14 | private String name; 15 | 16 | public static Test2Fragment newInstance(String name) { 17 | Test2Fragment fragment = new Test2Fragment(); 18 | Bundle args = new Bundle(1); 19 | args.putString("name", name); 20 | fragment.setArguments(args); 21 | return fragment; 22 | } 23 | 24 | @Override 25 | protected int getLayoutRes() { 26 | return R.layout.fragment_test2; 27 | } 28 | 29 | @Override 30 | public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { 31 | super.onViewCreated(view, savedInstanceState); 32 | name = getArguments().getString("name"); 33 | TextView tv_name = findViewById(R.id.tv_name); 34 | tv_name.setText(name); 35 | } 36 | 37 | @Override 38 | public void onVisible(boolean isFirstVisible) { 39 | super.onVisible(isFirstVisible); 40 | MainActivity.log(name + " onVisible : isFirstVisible=" + isFirstVisible); 41 | } 42 | 43 | @Override 44 | public void onInvisible() { 45 | super.onInvisible(); 46 | MainActivity.log(name + " onInvisible"); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Created by .ignore support plugin (hsz.mobi) 2 | ### Android template 3 | # Built application files 4 | *.ap_ 5 | *.aab 6 | 7 | # Files for the ART/Dalvik VM 8 | *.dex 9 | 10 | # Java class files 11 | *.class 12 | 13 | # Generated files 14 | bin/ 15 | gen/ 16 | out/ 17 | 18 | # Gradle files 19 | .gradle/ 20 | build/ 21 | 22 | # Local configuration file (sdk path, etc) 23 | local.properties 24 | 25 | # Proguard folder generated by Eclipse 26 | proguard/ 27 | 28 | # Log Files 29 | *.log 30 | 31 | # Android Studio Navigation editor temp files 32 | .navigation/ 33 | 34 | # Android Studio captures folder 35 | captures/ 36 | 37 | # IntelliJ 38 | *.iml 39 | .idea/ 40 | .idea/workspace.xml 41 | .idea/tasks.xml 42 | .idea/gradle.xml 43 | .idea/assetWizardSettings.xml 44 | .idea/dictionaries 45 | .idea/libraries 46 | # Android Studio 3 in .gitignore file. 47 | .idea/caches 48 | .idea/modules.xml 49 | # Comment next line if keeping position of elements in Navigation Editor is relevant for you 50 | .idea/navEditor.xml 51 | 52 | # Keystore files 53 | # Uncomment the following lines if you do not want to check your keystore files in. 54 | #*.jks 55 | #*.keystore 56 | 57 | # External native build folder generated in Android Studio 2.2 and later 58 | .externalNativeBuild 59 | 60 | # Google Services (e.g. APIs or Firebase) 61 | # google-services.json 62 | 63 | # Freeline 64 | freeline.py 65 | freeline/ 66 | freeline_project_description.json 67 | 68 | # fastlane 69 | fastlane/report.xml 70 | fastlane/Preview.html 71 | fastlane/screenshots 72 | fastlane/test_output 73 | fastlane/readme.md 74 | 75 | # Version control 76 | vcs.xml 77 | 78 | # lint 79 | lint/intermediates/ 80 | lint/generated/ 81 | lint/outputs/ 82 | lint/tmp/ 83 | # lint/reports/ 84 | 85 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 12 | 13 | 19 | 22 | 25 | 26 | 27 | 28 | 34 | 35 | -------------------------------------------------------------------------------- /appx/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 12 | 13 | 19 | 22 | 25 | 26 | 27 | 28 | 34 | 35 | -------------------------------------------------------------------------------- /lazyfragmentx/src/main/java/per/goweii/lazyfragmentx/CacheFragment.java: -------------------------------------------------------------------------------- 1 | package per.goweii.lazyfragmentx; 2 | 3 | import android.os.Bundle; 4 | import android.util.SparseArray; 5 | import android.view.LayoutInflater; 6 | import android.view.View; 7 | import android.view.ViewGroup; 8 | 9 | import androidx.annotation.IdRes; 10 | import androidx.annotation.NonNull; 11 | import androidx.annotation.Nullable; 12 | import androidx.fragment.app.Fragment; 13 | 14 | abstract class CacheFragment extends Fragment { 15 | 16 | protected View mRootView = null; 17 | protected boolean mViewCreated = false; 18 | 19 | private SparseArray mCacheViews = null; 20 | 21 | @Nullable 22 | @Override 23 | public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { 24 | if (mRootView == null) { 25 | final int layoutId = getLayoutRes(); 26 | if (layoutId > 0) { 27 | mRootView = inflater.inflate(getLayoutRes(), container, false); 28 | } 29 | } 30 | mViewCreated = true; 31 | return mRootView; 32 | } 33 | 34 | @Override 35 | public void onDestroyView() { 36 | super.onDestroyView(); 37 | mRootView = null; 38 | if (mCacheViews != null) { 39 | mCacheViews.clear(); 40 | mCacheViews = null; 41 | } 42 | mViewCreated = false; 43 | } 44 | 45 | @Nullable 46 | public View getRootView() { 47 | return mRootView; 48 | } 49 | 50 | public final V getView(@IdRes int id) { 51 | if (mCacheViews == null) { 52 | mCacheViews = new SparseArray<>(); 53 | } 54 | View view = mCacheViews.get(id); 55 | if (view == null) { 56 | view = findViewById(id); 57 | if (view != null) { 58 | mCacheViews.put(id, view); 59 | } 60 | } 61 | return (V) view; 62 | } 63 | 64 | public final V findViewById(@IdRes int id) { 65 | if (mRootView == null) { 66 | return null; 67 | } 68 | return mRootView.findViewById(id); 69 | } 70 | 71 | protected abstract int getLayoutRes(); 72 | } 73 | -------------------------------------------------------------------------------- /lazyfragment/src/main/java/per/goweii/lazyfragment/CacheFragment.java: -------------------------------------------------------------------------------- 1 | package per.goweii.lazyfragment; 2 | 3 | import android.os.Bundle; 4 | import android.support.annotation.IdRes; 5 | import android.support.annotation.NonNull; 6 | import android.support.annotation.Nullable; 7 | import android.support.v4.app.Fragment; 8 | import android.util.SparseArray; 9 | import android.view.LayoutInflater; 10 | import android.view.View; 11 | import android.view.ViewGroup; 12 | 13 | abstract class CacheFragment extends Fragment { 14 | 15 | protected View mRootView = null; 16 | protected boolean mViewCreated = false; 17 | 18 | private SparseArray mCacheViews = null; 19 | 20 | @Nullable 21 | @Override 22 | public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { 23 | if (mRootView == null) { 24 | final int layoutId = getLayoutRes(); 25 | if (layoutId > 0) { 26 | mRootView = inflater.inflate(getLayoutRes(), container, false); 27 | } 28 | } 29 | mViewCreated = true; 30 | return mRootView; 31 | } 32 | 33 | @Override 34 | public void onDestroyView() { 35 | super.onDestroyView(); 36 | mRootView = null; 37 | if (mCacheViews != null) { 38 | mCacheViews.clear(); 39 | mCacheViews = null; 40 | } 41 | mViewCreated = false; 42 | } 43 | 44 | @Nullable 45 | public View getRootView() { 46 | return mRootView; 47 | } 48 | 49 | public final V getView(@IdRes int id) { 50 | if (mCacheViews == null) { 51 | mCacheViews = new SparseArray<>(); 52 | } 53 | View view = mCacheViews.get(id); 54 | if (view == null) { 55 | view = findViewById(id); 56 | if (view != null) { 57 | mCacheViews.put(id, view); 58 | } 59 | } 60 | return (V) view; 61 | } 62 | 63 | public final V findViewById(@IdRes int id) { 64 | if (mRootView == null) { 65 | return null; 66 | } 67 | return mRootView.findViewById(id); 68 | } 69 | 70 | protected abstract int getLayoutRes(); 71 | } 72 | -------------------------------------------------------------------------------- /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 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME% 15 | 16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 17 | set DEFAULT_JVM_OPTS= 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 Windows variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | 53 | :win9xME_args 54 | @rem Slurp the command line arguments. 55 | set CMD_LINE_ARGS= 56 | set _SKIP=2 57 | 58 | :win9xME_args_slurp 59 | if "x%~1" == "x" goto execute 60 | 61 | set CMD_LINE_ARGS=%* 62 | 63 | :execute 64 | @rem Setup the command line 65 | 66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 67 | 68 | @rem Execute Gradle 69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 70 | 71 | :end 72 | @rem End local scope for the variables with windows NT shell 73 | if "%ERRORLEVEL%"=="0" goto mainEnd 74 | 75 | :fail 76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 77 | rem the _cmd.exe /c_ return code! 78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 79 | exit /b 1 80 | 81 | :mainEnd 82 | if "%OS%"=="Windows_NT" endlocal 83 | 84 | :omega 85 | -------------------------------------------------------------------------------- /app/src/main/res/layout/fragment_test1.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 17 | 18 | 23 | 24 | 27 | 28 | 36 | 37 | 45 | 46 | 54 | 55 | 63 | 64 | 72 | 73 | 74 | 75 | -------------------------------------------------------------------------------- /appx/src/main/res/layout/fragment_test1.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 17 | 18 | 23 | 24 | 27 | 28 | 36 | 37 | 45 | 46 | 54 | 55 | 63 | 64 | 72 | 73 | 74 | 75 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 15 | 16 | 21 | 22 | 23 | 24 | 29 | 30 | 33 | 34 | 42 | 43 | 51 | 52 | 60 | 61 | 69 | 70 | 78 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /appx/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 15 | 16 | 21 | 22 | 23 | 24 | 29 | 30 | 33 | 34 | 42 | 43 | 51 | 52 | 60 | 61 | 69 | 70 | 78 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /app/src/main/java/per/goweii/android/lazyfragment/MainActivity.java: -------------------------------------------------------------------------------- 1 | package per.goweii.android.lazyfragment; 2 | 3 | import android.os.Bundle; 4 | import android.support.v4.app.Fragment; 5 | import android.support.v4.view.ViewPager; 6 | import android.support.v7.app.AppCompatActivity; 7 | import android.view.View; 8 | import android.widget.ScrollView; 9 | import android.widget.TextView; 10 | 11 | import java.util.ArrayList; 12 | import java.util.List; 13 | 14 | public class MainActivity extends AppCompatActivity { 15 | 16 | private static TextView tv_log; 17 | private static ScrollView sv_log; 18 | private ViewPager vp; 19 | 20 | @Override 21 | protected void onCreate(Bundle savedInstanceState) { 22 | super.onCreate(savedInstanceState); 23 | setContentView(R.layout.activity_main); 24 | 25 | tv_log = findViewById(R.id.tv_log); 26 | sv_log = findViewById(R.id.sv_log); 27 | 28 | List fragments = new ArrayList<>(5); 29 | for (int i = 0; i < 5; i++) { 30 | fragments.add(Test1Fragment.newInstance("Test1Fragment-" + i)); 31 | } 32 | FixFragmentPagerAdapter adapter = new FixFragmentPagerAdapter(getSupportFragmentManager(), fragments); 33 | vp = findViewById(R.id.vp); 34 | vp.setAdapter(adapter); 35 | vp.setOffscreenPageLimit(4); 36 | 37 | findViewById(R.id.tv1).setOnClickListener(new View.OnClickListener() { 38 | @Override 39 | public void onClick(View v) { 40 | vp.setCurrentItem(0); 41 | } 42 | }); 43 | findViewById(R.id.tv2).setOnClickListener(new View.OnClickListener() { 44 | @Override 45 | public void onClick(View v) { 46 | vp.setCurrentItem(1); 47 | } 48 | }); 49 | findViewById(R.id.tv3).setOnClickListener(new View.OnClickListener() { 50 | @Override 51 | public void onClick(View v) { 52 | vp.setCurrentItem(2); 53 | } 54 | }); 55 | findViewById(R.id.tv4).setOnClickListener(new View.OnClickListener() { 56 | @Override 57 | public void onClick(View v) { 58 | vp.setCurrentItem(3); 59 | } 60 | }); 61 | findViewById(R.id.tv5).setOnClickListener(new View.OnClickListener() { 62 | @Override 63 | public void onClick(View v) { 64 | vp.setCurrentItem(4); 65 | } 66 | }); 67 | } 68 | 69 | public static synchronized void log(String msg){ 70 | if (tv_log == null) { 71 | return; 72 | } 73 | String last = tv_log.getText().toString(); 74 | String curr = last + "\n" + msg; 75 | tv_log.setText(curr); 76 | tv_log.post(new Runnable() { 77 | @Override 78 | public void run() { 79 | if (sv_log != null) { 80 | sv_log.fullScroll(ScrollView.FOCUS_DOWN); 81 | } 82 | } 83 | }); 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /appx/src/main/java/per/goweii/android/lazyfragmentx/MainActivity.java: -------------------------------------------------------------------------------- 1 | package per.goweii.android.lazyfragmentx; 2 | 3 | import android.os.Bundle; 4 | import android.view.View; 5 | import android.widget.ScrollView; 6 | import android.widget.TextView; 7 | 8 | import androidx.appcompat.app.AppCompatActivity; 9 | import androidx.fragment.app.Fragment; 10 | import androidx.viewpager.widget.ViewPager; 11 | 12 | import java.util.ArrayList; 13 | import java.util.List; 14 | 15 | public class MainActivity extends AppCompatActivity { 16 | 17 | private static TextView tv_log; 18 | private static ScrollView sv_log; 19 | private ViewPager vp; 20 | 21 | public static synchronized void log(String msg) { 22 | if (tv_log == null) { 23 | return; 24 | } 25 | String last = tv_log.getText().toString(); 26 | String curr = last + "\n" + msg; 27 | tv_log.setText(curr); 28 | tv_log.post(new Runnable() { 29 | @Override 30 | public void run() { 31 | if (sv_log != null) { 32 | sv_log.fullScroll(ScrollView.FOCUS_DOWN); 33 | } 34 | } 35 | }); 36 | } 37 | 38 | @Override 39 | protected void onCreate(Bundle savedInstanceState) { 40 | super.onCreate(savedInstanceState); 41 | setContentView(R.layout.activity_main); 42 | 43 | tv_log = findViewById(R.id.tv_log); 44 | sv_log = findViewById(R.id.sv_log); 45 | 46 | List fragments = new ArrayList<>(5); 47 | for (int i = 0; i < 5; i++) { 48 | fragments.add(Test1Fragment.newInstance("Test1Fragment-" + i)); 49 | } 50 | FixFragmentPagerAdapter adapter = new FixFragmentPagerAdapter(getSupportFragmentManager(), fragments); 51 | vp = findViewById(R.id.vp); 52 | vp.setAdapter(adapter); 53 | vp.setOffscreenPageLimit(4); 54 | 55 | findViewById(R.id.tv1).setOnClickListener(new View.OnClickListener() { 56 | @Override 57 | public void onClick(View v) { 58 | vp.setCurrentItem(0); 59 | } 60 | }); 61 | findViewById(R.id.tv2).setOnClickListener(new View.OnClickListener() { 62 | @Override 63 | public void onClick(View v) { 64 | vp.setCurrentItem(1); 65 | } 66 | }); 67 | findViewById(R.id.tv3).setOnClickListener(new View.OnClickListener() { 68 | @Override 69 | public void onClick(View v) { 70 | vp.setCurrentItem(2); 71 | } 72 | }); 73 | findViewById(R.id.tv4).setOnClickListener(new View.OnClickListener() { 74 | @Override 75 | public void onClick(View v) { 76 | vp.setCurrentItem(3); 77 | } 78 | }); 79 | findViewById(R.id.tv5).setOnClickListener(new View.OnClickListener() { 80 | @Override 81 | public void onClick(View v) { 82 | vp.setCurrentItem(4); 83 | } 84 | }); 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /app/src/main/java/per/goweii/android/lazyfragment/Test1Fragment.java: -------------------------------------------------------------------------------- 1 | package per.goweii.android.lazyfragment; 2 | 3 | import android.os.Bundle; 4 | import android.support.annotation.NonNull; 5 | import android.support.annotation.Nullable; 6 | import android.support.v4.app.Fragment; 7 | import android.support.v4.view.ViewPager; 8 | import android.view.View; 9 | import android.widget.TextView; 10 | 11 | import java.util.ArrayList; 12 | import java.util.List; 13 | 14 | import per.goweii.lazyfragment.LazyFragment; 15 | 16 | public class Test1Fragment extends LazyFragment { 17 | 18 | public static final String TAG = Test1Fragment.class.getSimpleName(); 19 | private String name; 20 | private ViewPager vp; 21 | 22 | public static Test1Fragment newInstance(String name){ 23 | Test1Fragment fragment = new Test1Fragment(); 24 | Bundle args = new Bundle(1); 25 | args.putString("name", name); 26 | fragment.setArguments(args); 27 | return fragment; 28 | } 29 | 30 | @Override 31 | protected int getLayoutRes() { 32 | return R.layout.fragment_test1; 33 | } 34 | 35 | @Override 36 | public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { 37 | super.onViewCreated(view, savedInstanceState); 38 | name = getArguments().getString("name"); 39 | TextView tv_name = findViewById(R.id.tv_name); 40 | tv_name.setText(name); 41 | 42 | List fragments = new ArrayList<>(5); 43 | for (int i = 0; i < 5; i++) { 44 | fragments.add(Test2Fragment.newInstance("Test2Fragment-" + i)); 45 | } 46 | FixFragmentPagerAdapter adapter = new FixFragmentPagerAdapter(getChildFragmentManager(), fragments); 47 | vp = findViewById(R.id.vp); 48 | vp.setAdapter(adapter); 49 | 50 | findViewById(R.id.tv1).setOnClickListener(new View.OnClickListener() { 51 | @Override 52 | public void onClick(View v) { 53 | vp.setCurrentItem(0); 54 | } 55 | }); 56 | findViewById(R.id.tv2).setOnClickListener(new View.OnClickListener() { 57 | @Override 58 | public void onClick(View v) { 59 | vp.setCurrentItem(1); 60 | } 61 | }); 62 | findViewById(R.id.tv3).setOnClickListener(new View.OnClickListener() { 63 | @Override 64 | public void onClick(View v) { 65 | vp.setCurrentItem(2); 66 | } 67 | }); 68 | findViewById(R.id.tv4).setOnClickListener(new View.OnClickListener() { 69 | @Override 70 | public void onClick(View v) { 71 | vp.setCurrentItem(3); 72 | } 73 | }); 74 | findViewById(R.id.tv5).setOnClickListener(new View.OnClickListener() { 75 | @Override 76 | public void onClick(View v) { 77 | vp.setCurrentItem(4); 78 | } 79 | }); 80 | } 81 | 82 | @Override 83 | public void onVisible(boolean isFirstVisible) { 84 | super.onVisible(isFirstVisible); 85 | MainActivity.log(name + " onVisible : isFirstVisible=" + isFirstVisible); 86 | } 87 | 88 | @Override 89 | public void onInvisible() { 90 | super.onInvisible(); 91 | MainActivity.log(name + " onInvisible"); 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /appx/src/main/java/per/goweii/android/lazyfragmentx/Test1Fragment.java: -------------------------------------------------------------------------------- 1 | package per.goweii.android.lazyfragmentx; 2 | 3 | import android.os.Bundle; 4 | import android.view.View; 5 | import android.widget.TextView; 6 | 7 | import androidx.annotation.NonNull; 8 | import androidx.annotation.Nullable; 9 | import androidx.fragment.app.Fragment; 10 | import androidx.viewpager.widget.ViewPager; 11 | 12 | import java.util.ArrayList; 13 | import java.util.List; 14 | 15 | import per.goweii.lazyfragmentx.LazyFragment; 16 | 17 | public class Test1Fragment extends LazyFragment { 18 | 19 | public static final String TAG = Test1Fragment.class.getSimpleName(); 20 | private String name; 21 | private ViewPager vp; 22 | 23 | public static Test1Fragment newInstance(String name) { 24 | Test1Fragment fragment = new Test1Fragment(); 25 | Bundle args = new Bundle(1); 26 | args.putString("name", name); 27 | fragment.setArguments(args); 28 | return fragment; 29 | } 30 | 31 | @Override 32 | protected int getLayoutRes() { 33 | return R.layout.fragment_test1; 34 | } 35 | 36 | @Override 37 | public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { 38 | super.onViewCreated(view, savedInstanceState); 39 | name = getArguments().getString("name"); 40 | TextView tv_name = findViewById(R.id.tv_name); 41 | tv_name.setText(name); 42 | 43 | List fragments = new ArrayList<>(5); 44 | for (int i = 0; i < 5; i++) { 45 | fragments.add(Test2Fragment.newInstance("Test2Fragment-" + i)); 46 | } 47 | FixFragmentPagerAdapter adapter = new FixFragmentPagerAdapter(getChildFragmentManager(), fragments); 48 | vp = findViewById(R.id.vp); 49 | vp.setAdapter(adapter); 50 | 51 | findViewById(R.id.tv1).setOnClickListener(new View.OnClickListener() { 52 | @Override 53 | public void onClick(View v) { 54 | vp.setCurrentItem(0); 55 | } 56 | }); 57 | findViewById(R.id.tv2).setOnClickListener(new View.OnClickListener() { 58 | @Override 59 | public void onClick(View v) { 60 | vp.setCurrentItem(1); 61 | } 62 | }); 63 | findViewById(R.id.tv3).setOnClickListener(new View.OnClickListener() { 64 | @Override 65 | public void onClick(View v) { 66 | vp.setCurrentItem(2); 67 | } 68 | }); 69 | findViewById(R.id.tv4).setOnClickListener(new View.OnClickListener() { 70 | @Override 71 | public void onClick(View v) { 72 | vp.setCurrentItem(3); 73 | } 74 | }); 75 | findViewById(R.id.tv5).setOnClickListener(new View.OnClickListener() { 76 | @Override 77 | public void onClick(View v) { 78 | vp.setCurrentItem(4); 79 | } 80 | }); 81 | } 82 | 83 | @Override 84 | public void onVisible(boolean isFirstVisible) { 85 | super.onVisible(isFirstVisible); 86 | MainActivity.log(name + " onVisible : isFirstVisible=" + isFirstVisible); 87 | } 88 | 89 | @Override 90 | public void onInvisible() { 91 | super.onInvisible(); 92 | MainActivity.log(name + " onInvisible"); 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /lazyfragment/src/main/java/per/goweii/lazyfragment/LazyFragment.java: -------------------------------------------------------------------------------- 1 | package per.goweii.lazyfragment; 2 | 3 | import android.os.Bundle; 4 | import android.support.annotation.Nullable; 5 | import android.support.v4.app.Fragment; 6 | import android.support.v4.app.FragmentManager; 7 | 8 | import java.util.List; 9 | 10 | public abstract class LazyFragment extends CacheFragment { 11 | 12 | private boolean mIsFirstVisible = true; 13 | private boolean mUserVisible = false; 14 | 15 | @Override 16 | public void setUserVisibleHint(boolean isVisibleToUser) { 17 | super.setUserVisibleHint(isVisibleToUser); 18 | if (mViewCreated) { 19 | if (isVisibleToUser && !mUserVisible) { 20 | dispatchUserVisibleHint(true); 21 | } else if (!isVisibleToUser && mUserVisible) { 22 | dispatchUserVisibleHint(false); 23 | } 24 | } 25 | } 26 | 27 | @Override 28 | public void onActivityCreated(@Nullable Bundle savedInstanceState) { 29 | super.onActivityCreated(savedInstanceState); 30 | if (!isHidden() && getUserVisibleHint()) { 31 | dispatchUserVisibleHint(true); 32 | } 33 | } 34 | 35 | @Override 36 | public void onHiddenChanged(boolean hidden) { 37 | super.onHiddenChanged(hidden); 38 | if (hidden) { 39 | dispatchUserVisibleHint(false); 40 | } else { 41 | dispatchUserVisibleHint(true); 42 | } 43 | } 44 | 45 | @Override 46 | public void onResume() { 47 | super.onResume(); 48 | if (!mIsFirstVisible) { 49 | if (!isHidden() && !mUserVisible && getUserVisibleHint()) { 50 | dispatchUserVisibleHint(true); 51 | } 52 | } 53 | } 54 | 55 | @Override 56 | public void onPause() { 57 | super.onPause(); 58 | if (mUserVisible && getUserVisibleHint()) { 59 | dispatchUserVisibleHint(false); 60 | } 61 | } 62 | 63 | @Override 64 | public void onDestroyView() { 65 | super.onDestroyView(); 66 | mIsFirstVisible = true; 67 | } 68 | 69 | private void dispatchUserVisibleHint(boolean visible) { 70 | if (visible && !isParentVisible()) { 71 | return; 72 | } 73 | if (mUserVisible == visible) { 74 | return; 75 | } 76 | mUserVisible = visible; 77 | if (visible) { 78 | if (mIsFirstVisible) { 79 | mIsFirstVisible = false; 80 | onVisible(true); 81 | } else { 82 | onVisible(false); 83 | } 84 | dispatchChildVisibleState(true); 85 | } else { 86 | dispatchChildVisibleState(false); 87 | onInvisible(); 88 | } 89 | } 90 | 91 | private boolean isParentVisible() { 92 | Fragment fragment = getParentFragment(); 93 | if (fragment == null) { 94 | return true; 95 | } 96 | if (fragment instanceof LazyFragment) { 97 | LazyFragment lazyFragment = (LazyFragment) fragment; 98 | return lazyFragment.isSupportUserVisible(); 99 | } 100 | return fragment.isVisible(); 101 | } 102 | 103 | private boolean isSupportUserVisible() { 104 | return mUserVisible; 105 | } 106 | 107 | private void dispatchChildVisibleState(boolean visible) { 108 | FragmentManager childFragmentManager = getChildFragmentManager(); 109 | List fragments = childFragmentManager.getFragments(); 110 | if (!fragments.isEmpty()) { 111 | for (Fragment child : fragments) { 112 | if (child instanceof LazyFragment && !child.isHidden() && child.getUserVisibleHint()) { 113 | ((LazyFragment) child).dispatchUserVisibleHint(visible); 114 | } 115 | } 116 | } 117 | } 118 | 119 | protected void onVisible(boolean isFirstVisible) { 120 | } 121 | 122 | protected void onInvisible() { 123 | } 124 | } 125 | -------------------------------------------------------------------------------- /lazyfragmentx/src/main/java/per/goweii/lazyfragmentx/LazyFragment.java: -------------------------------------------------------------------------------- 1 | package per.goweii.lazyfragmentx; 2 | 3 | import android.os.Bundle; 4 | 5 | import androidx.annotation.Nullable; 6 | import androidx.fragment.app.Fragment; 7 | import androidx.fragment.app.FragmentManager; 8 | 9 | import java.util.List; 10 | 11 | public abstract class LazyFragment extends CacheFragment { 12 | 13 | private boolean mIsFirstVisible = true; 14 | private boolean mUserVisible = false; 15 | 16 | @Override 17 | public void setUserVisibleHint(boolean isVisibleToUser) { 18 | super.setUserVisibleHint(isVisibleToUser); 19 | if (mViewCreated) { 20 | if (isVisibleToUser && !mUserVisible) { 21 | dispatchUserVisibleHint(true); 22 | } else if (!isVisibleToUser && mUserVisible) { 23 | dispatchUserVisibleHint(false); 24 | } 25 | } 26 | } 27 | 28 | @Override 29 | public void onActivityCreated(@Nullable Bundle savedInstanceState) { 30 | super.onActivityCreated(savedInstanceState); 31 | if (!isHidden() && getUserVisibleHint()) { 32 | dispatchUserVisibleHint(true); 33 | } 34 | } 35 | 36 | @Override 37 | public void onHiddenChanged(boolean hidden) { 38 | super.onHiddenChanged(hidden); 39 | if (hidden) { 40 | dispatchUserVisibleHint(false); 41 | } else { 42 | dispatchUserVisibleHint(true); 43 | } 44 | } 45 | 46 | @Override 47 | public void onResume() { 48 | super.onResume(); 49 | if (!mIsFirstVisible) { 50 | if (!isHidden() && !mUserVisible && getUserVisibleHint()) { 51 | dispatchUserVisibleHint(true); 52 | } 53 | } 54 | } 55 | 56 | @Override 57 | public void onPause() { 58 | super.onPause(); 59 | if (mUserVisible && getUserVisibleHint()) { 60 | dispatchUserVisibleHint(false); 61 | } 62 | } 63 | 64 | @Override 65 | public void onDestroyView() { 66 | super.onDestroyView(); 67 | mIsFirstVisible = true; 68 | } 69 | 70 | private void dispatchUserVisibleHint(boolean visible) { 71 | if (visible && !isParentVisible()) { 72 | return; 73 | } 74 | if (mUserVisible == visible) { 75 | return; 76 | } 77 | mUserVisible = visible; 78 | if (visible) { 79 | if (mIsFirstVisible) { 80 | mIsFirstVisible = false; 81 | onVisible(true); 82 | } else { 83 | onVisible(false); 84 | } 85 | dispatchChildVisibleState(true); 86 | } else { 87 | dispatchChildVisibleState(false); 88 | onInvisible(); 89 | } 90 | } 91 | 92 | private boolean isParentVisible() { 93 | Fragment fragment = getParentFragment(); 94 | if (fragment == null) { 95 | return true; 96 | } 97 | if (fragment instanceof LazyFragment) { 98 | LazyFragment lazyFragment = (LazyFragment) fragment; 99 | return lazyFragment.isSupportUserVisible(); 100 | } 101 | return fragment.isVisible(); 102 | } 103 | 104 | private boolean isSupportUserVisible() { 105 | return mUserVisible; 106 | } 107 | 108 | private void dispatchChildVisibleState(boolean visible) { 109 | FragmentManager childFragmentManager = getChildFragmentManager(); 110 | List fragments = childFragmentManager.getFragments(); 111 | if (!fragments.isEmpty()) { 112 | for (Fragment child : fragments) { 113 | if (child instanceof LazyFragment && !child.isHidden() && child.getUserVisibleHint()) { 114 | ((LazyFragment) child).dispatchUserVisibleHint(visible); 115 | } 116 | } 117 | } 118 | } 119 | 120 | protected void onVisible(boolean isFirstVisible) { 121 | } 122 | 123 | protected void onInvisible() { 124 | } 125 | } 126 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Attempt to set APP_HOME 10 | # Resolve links: $0 may be a link 11 | PRG="$0" 12 | # Need this for relative symlinks. 13 | while [ -h "$PRG" ] ; do 14 | ls=`ls -ld "$PRG"` 15 | link=`expr "$ls" : '.*-> \(.*\)$'` 16 | if expr "$link" : '/.*' > /dev/null; then 17 | PRG="$link" 18 | else 19 | PRG=`dirname "$PRG"`"/$link" 20 | fi 21 | done 22 | SAVED="`pwd`" 23 | cd "`dirname \"$PRG\"`/" >/dev/null 24 | APP_HOME="`pwd -P`" 25 | cd "$SAVED" >/dev/null 26 | 27 | APP_NAME="Gradle" 28 | APP_BASE_NAME=`basename "$0"` 29 | 30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 31 | DEFAULT_JVM_OPTS="" 32 | 33 | # Use the maximum available, or set MAX_FD != -1 to use that value. 34 | MAX_FD="maximum" 35 | 36 | warn () { 37 | echo "$*" 38 | } 39 | 40 | die () { 41 | echo 42 | echo "$*" 43 | echo 44 | exit 1 45 | } 46 | 47 | # OS specific support (must be 'true' or 'false'). 48 | cygwin=false 49 | msys=false 50 | darwin=false 51 | nonstop=false 52 | case "`uname`" in 53 | CYGWIN* ) 54 | cygwin=true 55 | ;; 56 | Darwin* ) 57 | darwin=true 58 | ;; 59 | MINGW* ) 60 | msys=true 61 | ;; 62 | NONSTOP* ) 63 | nonstop=true 64 | ;; 65 | esac 66 | 67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 68 | 69 | # Determine the Java command to use to start the JVM. 70 | if [ -n "$JAVA_HOME" ] ; then 71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 72 | # IBM's JDK on AIX uses strange locations for the executables 73 | JAVACMD="$JAVA_HOME/jre/sh/java" 74 | else 75 | JAVACMD="$JAVA_HOME/bin/java" 76 | fi 77 | if [ ! -x "$JAVACMD" ] ; then 78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 79 | 80 | Please set the JAVA_HOME variable in your environment to match the 81 | location of your Java installation." 82 | fi 83 | else 84 | JAVACMD="java" 85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 86 | 87 | Please set the JAVA_HOME variable in your environment to match the 88 | location of your Java installation." 89 | fi 90 | 91 | # Increase the maximum file descriptors if we can. 92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 93 | MAX_FD_LIMIT=`ulimit -H -n` 94 | if [ $? -eq 0 ] ; then 95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 96 | MAX_FD="$MAX_FD_LIMIT" 97 | fi 98 | ulimit -n $MAX_FD 99 | if [ $? -ne 0 ] ; then 100 | warn "Could not set maximum file descriptor limit: $MAX_FD" 101 | fi 102 | else 103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 104 | fi 105 | fi 106 | 107 | # For Darwin, add options to specify how the application appears in the dock 108 | if $darwin; then 109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 110 | fi 111 | 112 | # For Cygwin, switch paths to Windows format before running java 113 | if $cygwin ; then 114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 116 | JAVACMD=`cygpath --unix "$JAVACMD"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Escape application args 158 | save () { 159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 160 | echo " " 161 | } 162 | APP_ARGS=$(save "$@") 163 | 164 | # Collect all arguments for the java command, following the shell quoting and substitution rules 165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 166 | 167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong 168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then 169 | cd "$(dirname "$0")" 170 | fi 171 | 172 | exec "$JAVACMD" "$@" 173 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 10 | 15 | 20 | 25 | 30 | 35 | 40 | 45 | 50 | 55 | 60 | 65 | 70 | 75 | 80 | 85 | 90 | 95 | 100 | 105 | 110 | 115 | 120 | 125 | 130 | 135 | 140 | 145 | 150 | 155 | 160 | 165 | 170 | 171 | -------------------------------------------------------------------------------- /appx/src/main/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 10 | 15 | 20 | 25 | 30 | 35 | 40 | 45 | 50 | 55 | 60 | 65 | 70 | 75 | 80 | 85 | 90 | 95 | 100 | 105 | 110 | 115 | 120 | 125 | 130 | 135 | 140 | 145 | 150 | 155 | 160 | 165 | 170 | 171 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU LESSER GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | 9 | This version of the GNU Lesser General Public License incorporates 10 | the terms and conditions of version 3 of the GNU General Public 11 | License, supplemented by the additional permissions listed below. 12 | 13 | 0. Additional Definitions. 14 | 15 | As used herein, "this License" refers to version 3 of the GNU Lesser 16 | General Public License, and the "GNU GPL" refers to version 3 of the GNU 17 | General Public License. 18 | 19 | "The Library" refers to a covered work governed by this License, 20 | other than an Application or a Combined Work as defined below. 21 | 22 | An "Application" is any work that makes use of an interface provided 23 | by the Library, but which is not otherwise based on the Library. 24 | Defining a subclass of a class defined by the Library is deemed a mode 25 | of using an interface provided by the Library. 26 | 27 | A "Combined Work" is a work produced by combining or linking an 28 | Application with the Library. The particular version of the Library 29 | with which the Combined Work was made is also called the "Linked 30 | Version". 31 | 32 | The "Minimal Corresponding Source" for a Combined Work means the 33 | Corresponding Source for the Combined Work, excluding any source code 34 | for portions of the Combined Work that, considered in isolation, are 35 | based on the Application, and not on the Linked Version. 36 | 37 | The "Corresponding Application Code" for a Combined Work means the 38 | object code and/or source code for the Application, including any data 39 | and utility programs needed for reproducing the Combined Work from the 40 | Application, but excluding the System Libraries of the Combined Work. 41 | 42 | 1. Exception to Section 3 of the GNU GPL. 43 | 44 | You may convey a covered work under sections 3 and 4 of this License 45 | without being bound by section 3 of the GNU GPL. 46 | 47 | 2. Conveying Modified Versions. 48 | 49 | If you modify a copy of the Library, and, in your modifications, a 50 | facility refers to a function or data to be supplied by an Application 51 | that uses the facility (other than as an argument passed when the 52 | facility is invoked), then you may convey a copy of the modified 53 | version: 54 | 55 | a) under this License, provided that you make a good faith effort to 56 | ensure that, in the event an Application does not supply the 57 | function or data, the facility still operates, and performs 58 | whatever part of its purpose remains meaningful, or 59 | 60 | b) under the GNU GPL, with none of the additional permissions of 61 | this License applicable to that copy. 62 | 63 | 3. Object Code Incorporating Material from Library Header Files. 64 | 65 | The object code form of an Application may incorporate material from 66 | a header file that is part of the Library. You may convey such object 67 | code under terms of your choice, provided that, if the incorporated 68 | material is not limited to numerical parameters, data structure 69 | layouts and accessors, or small macros, inline functions and templates 70 | (ten or fewer lines in length), you do both of the following: 71 | 72 | a) Give prominent notice with each copy of the object code that the 73 | Library is used in it and that the Library and its use are 74 | covered by this License. 75 | 76 | b) Accompany the object code with a copy of the GNU GPL and this license 77 | document. 78 | 79 | 4. Combined Works. 80 | 81 | You may convey a Combined Work under terms of your choice that, 82 | taken together, effectively do not restrict modification of the 83 | portions of the Library contained in the Combined Work and reverse 84 | engineering for debugging such modifications, if you also do each of 85 | the following: 86 | 87 | a) Give prominent notice with each copy of the Combined Work that 88 | the Library is used in it and that the Library and its use are 89 | covered by this License. 90 | 91 | b) Accompany the Combined Work with a copy of the GNU GPL and this license 92 | document. 93 | 94 | c) For a Combined Work that displays copyright notices during 95 | execution, include the copyright notice for the Library among 96 | these notices, as well as a reference directing the user to the 97 | copies of the GNU GPL and this license document. 98 | 99 | d) Do one of the following: 100 | 101 | 0) Convey the Minimal Corresponding Source under the terms of this 102 | License, and the Corresponding Application Code in a form 103 | suitable for, and under terms that permit, the user to 104 | recombine or relink the Application with a modified version of 105 | the Linked Version to produce a modified Combined Work, in the 106 | manner specified by section 6 of the GNU GPL for conveying 107 | Corresponding Source. 108 | 109 | 1) Use a suitable shared library mechanism for linking with the 110 | Library. A suitable mechanism is one that (a) uses at run time 111 | a copy of the Library already present on the user's computer 112 | system, and (b) will operate properly with a modified version 113 | of the Library that is interface-compatible with the Linked 114 | Version. 115 | 116 | e) Provide Installation Information, but only if you would otherwise 117 | be required to provide such information under section 6 of the 118 | GNU GPL, and only to the extent that such information is 119 | necessary to install and execute a modified version of the 120 | Combined Work produced by recombining or relinking the 121 | Application with a modified version of the Linked Version. (If 122 | you use option 4d0, the Installation Information must accompany 123 | the Minimal Corresponding Source and Corresponding Application 124 | Code. If you use option 4d1, you must provide the Installation 125 | Information in the manner specified by section 6 of the GNU GPL 126 | for conveying Corresponding Source.) 127 | 128 | 5. Combined Libraries. 129 | 130 | You may place library facilities that are a work based on the 131 | Library side by side in a single library together with other library 132 | facilities that are not Applications and are not covered by this 133 | License, and convey such a combined library under terms of your 134 | choice, if you do both of the following: 135 | 136 | a) Accompany the combined library with a copy of the same work based 137 | on the Library, uncombined with any other library facilities, 138 | conveyed under the terms of this License. 139 | 140 | b) Give prominent notice with the combined library that part of it 141 | is a work based on the Library, and explaining where to find the 142 | accompanying uncombined form of the same work. 143 | 144 | 6. Revised Versions of the GNU Lesser General Public License. 145 | 146 | The Free Software Foundation may publish revised and/or new versions 147 | of the GNU Lesser General Public License from time to time. Such new 148 | versions will be similar in spirit to the present version, but may 149 | differ in detail to address new problems or concerns. 150 | 151 | Each version is given a distinguishing version number. If the 152 | Library as you received it specifies that a certain numbered version 153 | of the GNU Lesser General Public License "or any later version" 154 | applies to it, you have the option of following the terms and 155 | conditions either of that published version or of any later version 156 | published by the Free Software Foundation. If the Library as you 157 | received it does not specify a version number of the GNU Lesser 158 | General Public License, you may choose any version of the GNU Lesser 159 | General Public License ever published by the Free Software Foundation. 160 | 161 | If the Library as you received it specifies that a proxy can decide 162 | whether future versions of the GNU Lesser General Public License shall 163 | apply, that proxy's public statement of acceptance of any version is 164 | permanent authorization for you to choose that version for the 165 | Library. 166 | --------------------------------------------------------------------------------