Skip to content

Commit

Permalink
分离库
Browse files Browse the repository at this point in the history
  • Loading branch information
weikaiyun committed Sep 10, 2020
1 parent 51912d8 commit ed09e97
Show file tree
Hide file tree
Showing 51 changed files with 184 additions and 84 deletions.
1 change: 0 additions & 1 deletion .idea/.name

This file was deleted.

1 change: 1 addition & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ kapt {
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])

implementation project(':fragmentation')

implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${versions.kotlin}"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:${versions.kotlinx_coroutines}"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:${versions.kotlinx_coroutines}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import org.junit.Assert.*
class ExampleInstrumentedTest {
@Test
fun useAppContext() {
// Context of the app under test.
// Context of the androidx.fragment.app under test.
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
assertEquals("com.common.weikaiyun", appContext.packageName)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.common.weikaiyun.adapter

import androidx.viewpager2.adapter.FragmentStateAdapter
import com.weikaiyun.fragmentation.SupportActivity
import com.weikaiyun.fragmentation.SupportFragment

class CustomFragmentStateAdapter(
activity: com.weikaiyun.fragmentation.SupportActivity,
private val fragments: MutableList<com.weikaiyun.fragmentation.SupportFragment>
) :
FragmentStateAdapter(activity) {

override fun getItemCount() = fragments.size

override fun createFragment(position: Int) = fragments[position]
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import androidx.lifecycle.lifecycleScope
import com.common.weikaiyun.R
import com.common.weikaiyun.demo.db.User
import com.common.weikaiyun.demo.viewmodel.UserViewModel
import com.common.weikaiyun.fragmentation.SupportActivity
import com.weikaiyun.fragmentation.SupportActivity

class DemoActivity : SupportActivity() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package com.common.weikaiyun.demo.ui
import android.os.Bundle
import android.view.View
import com.common.weikaiyun.R
import com.common.weikaiyun.fragmentation.SupportFragment
import com.common.weikaiyun.fragmentation.fragmentargument.argument
import com.weikaiyun.fragmentation.SupportFragment
import com.weikaiyun.fragmentation.fragmentargument.argument
import kotlinx.android.synthetic.main.fragment_demo.*

class DemoFragment1 : SupportFragment() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package com.common.weikaiyun.demo.ui
import android.os.Bundle
import android.view.View
import com.common.weikaiyun.R
import com.common.weikaiyun.fragmentation.SupportFragment
import com.common.weikaiyun.fragmentation.fragmentargument.argument
import com.weikaiyun.fragmentation.SupportFragment
import com.weikaiyun.fragmentation.fragmentargument.argument
import kotlinx.android.synthetic.main.fragment_demo.*

class DemoFragment2: SupportFragment() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package com.common.weikaiyun.demo.ui
import android.os.Bundle
import android.view.View
import com.common.weikaiyun.R
import com.common.weikaiyun.fragmentation.SupportFragment
import com.common.weikaiyun.fragmentation.fragmentargument.argument
import com.weikaiyun.fragmentation.SupportFragment
import com.weikaiyun.fragmentation.fragmentargument.argument
import kotlinx.android.synthetic.main.fragment_demo.*

class DemoFragment3: SupportFragment() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package com.common.weikaiyun.demo.ui
import android.os.Bundle
import android.view.View
import com.common.weikaiyun.R
import com.common.weikaiyun.fragmentation.SupportFragment
import com.common.weikaiyun.fragmentation.fragmentargument.argument
import com.weikaiyun.fragmentation.SupportFragment
import com.weikaiyun.fragmentation.fragmentargument.argument
import kotlinx.android.synthetic.main.fragment_demo4.*

class DemoFragment4: SupportFragment() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package com.common.weikaiyun.demo.ui
import android.os.Bundle
import android.view.View
import com.common.weikaiyun.R
import com.common.weikaiyun.fragmentation.SupportFragment
import com.common.weikaiyun.fragmentation.fragmentargument.argument
import com.weikaiyun.fragmentation.SupportFragment
import com.weikaiyun.fragmentation.fragmentargument.argument
import kotlinx.android.synthetic.main.fragment_demo.*

class DemoFragment5: SupportFragment() {
Expand Down

This file was deleted.

4 changes: 0 additions & 4 deletions app/src/main/res/anim/no_anim.xml

This file was deleted.

16 changes: 8 additions & 8 deletions app/src/main/res/layout/fragment_demo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,24 @@
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:androidx.fragment.app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<TextView
android:id="@+id/title"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
androidx.fragment.app:layout_constraintStart_toStartOf="parent"
androidx.fragment.app:layout_constraintEnd_toEndOf="parent"
androidx.fragment.app:layout_constraintTop_toTopOf="parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="30sp"
tools:text="Fragment"/>

<TextView
android:id="@+id/button"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
androidx.fragment.app:layout_constraintStart_toStartOf="parent"
androidx.fragment.app:layout_constraintEnd_toEndOf="parent"
androidx.fragment.app:layout_constraintTop_toTopOf="parent"
androidx.fragment.app:layout_constraintBottom_toBottomOf="parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="60sp"
Expand Down
28 changes: 14 additions & 14 deletions app/src/main/res/layout/fragment_demo4.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,23 @@
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:androidx.fragment.app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<TextView
android:id="@+id/title"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
androidx.fragment.app:layout_constraintStart_toStartOf="parent"
androidx.fragment.app:layout_constraintEnd_toEndOf="parent"
androidx.fragment.app:layout_constraintTop_toTopOf="parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="30sp"
tools:text="Fragment"/>

<TextView
android:id="@+id/button1"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/title"
androidx.fragment.app:layout_constraintStart_toStartOf="parent"
androidx.fragment.app:layout_constraintEnd_toEndOf="parent"
androidx.fragment.app:layout_constraintTop_toBottomOf="@id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="60sp"
Expand All @@ -29,10 +29,10 @@

<TextView
android:id="@+id/button2"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
androidx.fragment.app:layout_constraintStart_toStartOf="parent"
androidx.fragment.app:layout_constraintEnd_toEndOf="parent"
androidx.fragment.app:layout_constraintTop_toTopOf="parent"
androidx.fragment.app:layout_constraintBottom_toBottomOf="parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="60sp"
Expand All @@ -42,9 +42,9 @@

<TextView
android:id="@+id/button3"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
androidx.fragment.app:layout_constraintStart_toStartOf="parent"
androidx.fragment.app:layout_constraintEnd_toEndOf="parent"
androidx.fragment.app:layout_constraintBottom_toBottomOf="parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="60sp"
Expand Down
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ buildscript {
debug_db : '1.0.6',
adapterdelegate : '4.3.0'
]
kotlin_version = '1.4.0'
}

repositories {
Expand Down
1 change: 1 addition & 0 deletions fragmentation/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
37 changes: 37 additions & 0 deletions fragmentation/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

android {
compileSdkVersion 30
buildToolsVersion "30.0.2"

defaultConfig {
minSdkVersion 16
targetSdkVersion 30
versionCode 1
versionName "1.0"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.3.1'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation "androidx.fragment:fragment-ktx:1.3.0-alpha08"
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'

}
Empty file.
21 changes: 21 additions & 0 deletions fragmentation/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.weikaiyun.fragmentation

import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.ext.junit.runners.AndroidJUnit4

import org.junit.Test
import org.junit.runner.RunWith

import org.junit.Assert.*

/**
* Instrumented test, which will execute on an Android device.
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
@RunWith(AndroidJUnit4::class)
class ExampleInstrumentedTest {
@Test
fun useAppContext() {
// Context of the androidx.fragment.app under test.
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
assertEquals("com.weikaiyun.fragmentation.test", appContext.packageName)
}
}
3 changes: 3 additions & 0 deletions fragmentation/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.weikaiyun.fragmentation">
</manifest>
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package com.common.weikaiyun.fragmentation;
package com.weikaiyun.fragmentation;

import androidx.annotation.AnimRes;
import androidx.annotation.AnimatorRes;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.fragment.app.FragmentManager;

import com.common.weikaiyun.fragmentation.record.TransactionRecord;
import com.weikaiyun.fragmentation.record.TransactionRecord;

public abstract class ExtraTransaction {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.common.weikaiyun.fragmentation;
package com.weikaiyun.fragmentation;

import android.os.Bundle;
import android.view.MotionEvent;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.common.weikaiyun.fragmentation;
package com.weikaiyun.fragmentation;

import android.os.Bundle;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.common.weikaiyun.fragmentation;
package com.weikaiyun.fragmentation;

import android.os.Bundle;
import android.view.MotionEvent;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.common.weikaiyun.fragmentation;
package com.weikaiyun.fragmentation;

import android.os.Bundle;

Expand All @@ -7,7 +7,7 @@
import androidx.fragment.app.FragmentActivity;
import androidx.fragment.app.FragmentManager;

import com.common.weikaiyun.fragmentation.queue.Action;
import com.weikaiyun.fragmentation.queue.Action;

public class SupportActivityDelegate {
private ISupportActivity mSupport;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.common.weikaiyun.fragmentation;
package com.weikaiyun.fragmentation;

import android.app.Activity;
import android.content.Context;
Expand Down
Loading

0 comments on commit ed09e97

Please sign in to comment.