Skip to content

Commit 4c579d0

Browse files
committed
https://github.com/YoKeyword/Fragmentation/issues/586
1 parent e3800e5 commit 4c579d0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+1373
-0
lines changed

issues586/.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
*.iml
2+
.gradle
3+
/local.properties
4+
/.idea/workspace.xml
5+
/.idea/libraries
6+
.DS_Store
7+
/build
8+
/captures
9+
.externalNativeBuild

issues586/.idea/encodings.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

issues586/.idea/gradle.xml

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

issues586/.idea/misc.xml

Lines changed: 33 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

issues586/.idea/modules.xml

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

issues586/.idea/runConfigurations.xml

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

issues586/app/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

issues586/app/build.gradle

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
apply plugin: 'com.android.application'
2+
3+
android {
4+
compileSdkVersion 26
5+
defaultConfig {
6+
applicationId "com.minister.myapplication"
7+
minSdkVersion 22
8+
targetSdkVersion 26
9+
versionCode 1
10+
versionName "1.0"
11+
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
12+
}
13+
buildTypes {
14+
release {
15+
minifyEnabled false
16+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
17+
}
18+
}
19+
}
20+
21+
dependencies {
22+
implementation fileTree(dir: 'libs', include: ['*.jar'])
23+
implementation 'com.android.support:appcompat-v7:26.1.0'
24+
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
25+
implementation 'me.yokeyword:fragmentation:1.1.9'
26+
testImplementation 'junit:junit:4.12'
27+
androidTestImplementation 'com.android.support.test:runner:1.0.1'
28+
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
29+
}

issues586/app/proguard-rules.pro

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.minister.myapplication;
2+
3+
import android.content.Context;
4+
import android.support.test.InstrumentationRegistry;
5+
import android.support.test.runner.AndroidJUnit4;
6+
7+
import org.junit.Test;
8+
import org.junit.runner.RunWith;
9+
10+
import static org.junit.Assert.*;
11+
12+
/**
13+
* Instrumented test, which will execute on an Android device.
14+
*
15+
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
16+
*/
17+
@RunWith(AndroidJUnit4.class)
18+
public class ExampleInstrumentedTest {
19+
@Test
20+
public void useAppContext() throws Exception {
21+
// Context of the app under test.
22+
Context appContext = InstrumentationRegistry.getTargetContext();
23+
24+
assertEquals("com.minister.myapplication", appContext.getPackageName());
25+
}
26+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="com.minister.myapplication">
4+
5+
<application
6+
android:allowBackup="true"
7+
android:icon="@mipmap/ic_launcher"
8+
android:label="@string/app_name"
9+
android:roundIcon="@mipmap/ic_launcher_round"
10+
android:supportsRtl="true"
11+
android:theme="@style/AppTheme">
12+
<activity android:name=".MainActivity">
13+
<intent-filter>
14+
<action android:name="android.intent.action.MAIN"/>
15+
16+
<category android:name="android.intent.category.LAUNCHER"/>
17+
</intent-filter>
18+
</activity>
19+
</application>
20+
21+
</manifest>
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package com.minister.myapplication;
2+
3+
import android.os.Bundle;
4+
import android.support.annotation.Nullable;
5+
import android.util.Log;
6+
import android.view.LayoutInflater;
7+
import android.view.View;
8+
import android.view.ViewGroup;
9+
import android.widget.TextView;
10+
11+
import me.yokeyword.fragmentation.SupportFragment;
12+
13+
/**
14+
* Created by 被咯苏州 on 2017/12/11.
15+
*/
16+
17+
public class Fragment1 extends SupportFragment {
18+
public static Fragment1 newInstance(){
19+
Fragment1 fragment = new Fragment1();
20+
return fragment;
21+
}
22+
23+
@Nullable
24+
@Override
25+
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
26+
View view = LayoutInflater.from(_mActivity).inflate(R.layout.fragment_main, null);
27+
TextView textView = view.findViewById(R.id.tv_content);
28+
textView.setText("1");
29+
return view;
30+
}
31+
32+
@Override
33+
public void onLazyInitView(@Nullable Bundle savedInstanceState) {
34+
super.onLazyInitView(savedInstanceState);
35+
Log.d("onLazyInitView", "Fragment1: ");
36+
}
37+
}
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
package com.minister.myapplication;
2+
3+
import android.os.Bundle;
4+
import android.support.annotation.Nullable;
5+
import android.util.Log;
6+
import android.view.LayoutInflater;
7+
import android.view.View;
8+
import android.view.ViewGroup;
9+
10+
import com.minister.myapplication.view.BottomBar;
11+
import com.minister.myapplication.view.BottomBarTab;
12+
13+
import me.yokeyword.fragmentation.SupportFragment;
14+
15+
/**
16+
* Created by 被咯苏州 on 2017/12/11.
17+
*/
18+
19+
public class Fragment2 extends SupportFragment {
20+
public static Fragment2 newInstance(){
21+
Fragment2 fragment = new Fragment2();
22+
return fragment;
23+
}
24+
25+
SupportFragment[] mFragments = new SupportFragment[3];
26+
27+
private BottomBar mBottomBar;
28+
29+
@Nullable
30+
@Override
31+
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
32+
View view = LayoutInflater.from(_mActivity).inflate(R.layout.activity_main, null);
33+
mBottomBar = (BottomBar) view.findViewById(R.id.bottomBar);
34+
35+
mFragments[0] = FragmentA.newInstance();
36+
mFragments[1] = FragmentB.newInstance();
37+
mFragments[2] = FragmentC.newInstance();
38+
loadMultipleRootFragment(R.id.fl_container, 0, mFragments);
39+
40+
mBottomBar.addItem(new BottomBarTab(_mActivity, R.drawable.ic_home_white_24dp))
41+
.addItem(new BottomBarTab(_mActivity, R.drawable.ic_discover_white_24dp))
42+
.addItem(new BottomBarTab(_mActivity, R.drawable.ic_message_white_24dp));
43+
44+
mBottomBar.setOnTabSelectedListener(new BottomBar.OnTabSelectedListener() {
45+
@Override
46+
public void onTabSelected(int position, int prePosition) {
47+
showHideFragment(mFragments[position], mFragments[prePosition]);
48+
}
49+
50+
@Override
51+
public void onTabUnselected(int position) {
52+
53+
}
54+
55+
@Override
56+
public void onTabReselected(int position) {
57+
58+
}
59+
});
60+
return view;
61+
}
62+
63+
@Override
64+
public void onLazyInitView(@Nullable Bundle savedInstanceState) {
65+
super.onLazyInitView(savedInstanceState);
66+
Log.d("onLazyInitView", "Fragment2: ");
67+
}
68+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package com.minister.myapplication;
2+
3+
import android.os.Bundle;
4+
import android.support.annotation.Nullable;
5+
import android.util.Log;
6+
import android.view.LayoutInflater;
7+
import android.view.View;
8+
import android.view.ViewGroup;
9+
import android.widget.TextView;
10+
11+
import me.yokeyword.fragmentation.SupportFragment;
12+
13+
/**
14+
* Created by 被咯苏州 on 2017/12/11.
15+
*/
16+
17+
public class Fragment3 extends SupportFragment {
18+
public static Fragment3 newInstance(){
19+
Fragment3 fragment = new Fragment3();
20+
return fragment;
21+
}
22+
23+
@Nullable
24+
@Override
25+
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
26+
View view = LayoutInflater.from(_mActivity).inflate(R.layout.fragment_main, null);
27+
TextView textView = view.findViewById(R.id.tv_content);
28+
textView.setText("3");
29+
return view;
30+
}
31+
32+
@Override
33+
public void onLazyInitView(@Nullable Bundle savedInstanceState) {
34+
super.onLazyInitView(savedInstanceState);
35+
Log.d("onLazyInitView", "Fragment3: ");
36+
}
37+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package com.minister.myapplication;
2+
3+
import android.os.Bundle;
4+
import android.support.annotation.Nullable;
5+
import android.util.Log;
6+
import android.view.LayoutInflater;
7+
import android.view.View;
8+
import android.view.ViewGroup;
9+
import android.widget.TextView;
10+
11+
import me.yokeyword.fragmentation.SupportFragment;
12+
13+
/**
14+
* Created by 被咯苏州 on 2017/12/11.
15+
*/
16+
17+
public class FragmentA extends SupportFragment {
18+
public static FragmentA newInstance(){
19+
FragmentA fragment = new FragmentA();
20+
return fragment;
21+
}
22+
23+
@Nullable
24+
@Override
25+
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
26+
View view = LayoutInflater.from(_mActivity).inflate(R.layout.fragment_main, null);
27+
TextView textView = view.findViewById(R.id.tv_content);
28+
textView.setText("1");
29+
return view;
30+
}
31+
32+
@Override
33+
public void onLazyInitView(@Nullable Bundle savedInstanceState) {
34+
super.onLazyInitView(savedInstanceState);
35+
Log.d("onLazyInitView", "FragmentA: ");
36+
}
37+
}

0 commit comments

Comments
 (0)