Skip to content

Commit 841c828

Browse files
committed
添加App启动优化代码
1 parent b6a0321 commit 841c828

File tree

10 files changed

+316
-319
lines changed

10 files changed

+316
-319
lines changed

app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ android {
1010
compileSdkVersion 28
1111
defaultConfig {
1212
applicationId "com.fmt.github"
13-
minSdkVersion 16
13+
minSdkVersion 17
1414
targetSdkVersion 28
1515
versionCode 8
1616
versionName "1.8"

app/src/main/java/com/fmt/github/home/activity/HomeActivity.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import android.view.Menu
66
import android.view.MenuItem
77
import androidx.appcompat.app.ActionBarDrawerToggle
88
import androidx.core.content.ContextCompat
9-
import androidx.databinding.DataBindingUtil
109
import androidx.fragment.app.Fragment
1110
import androidx.fragment.app.FragmentStatePagerAdapter
1211
import androidx.lifecycle.Observer
Lines changed: 63 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,87 +1,91 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<layout xmlns:android="http://schemas.android.com/apk/res/android"
3-
xmlns:app="http://schemas.android.com/apk/res-auto">
3+
xmlns:app="http://schemas.android.com/apk/res-auto">
44

55
<data>
6-
<variable name="userLoginModel" type="com.fmt.github.user.model.UserLoginModel"/>
6+
7+
<variable
8+
name="userLoginModel"
9+
type="com.fmt.github.user.model.UserLoginModel" />
710
</data>
811

912
<LinearLayout
10-
android:orientation="vertical"
11-
android:layout_width="match_parent"
12-
android:layout_height="match_parent">
13+
android:layout_width="match_parent"
14+
android:layout_height="match_parent"
15+
android:background="@android:color/white"
16+
android:orientation="vertical">
1317

1418
<androidx.appcompat.widget.Toolbar
15-
android:id="@+id/mToolbar"
16-
android:layout_width="match_parent"
17-
android:layout_height="wrap_content"
18-
android:background="@color/colorPrimary"
19-
app:title="@string/go_to_login"
20-
app:titleTextColor="@android:color/white"/>
19+
android:id="@+id/mToolbar"
20+
android:layout_width="match_parent"
21+
android:layout_height="wrap_content"
22+
android:background="@color/colorPrimary"
23+
app:title="@string/go_to_login"
24+
app:titleTextColor="@android:color/white" />
2125

2226
<de.hdodenhof.circleimageview.CircleImageView
23-
android:layout_width="wrap_content"
24-
android:layout_height="wrap_content"
25-
android:src="@mipmap/ic_github"
26-
android:layout_gravity="center_horizontal"
27-
android:layout_marginTop="80dp"/>
27+
android:layout_width="wrap_content"
28+
android:layout_height="wrap_content"
29+
android:layout_gravity="center_horizontal"
30+
android:layout_marginTop="80dp"
31+
android:src="@mipmap/ic_github" />
2832

2933
<com.google.android.material.textfield.TextInputLayout
30-
android:id="@+id/mUserNameInputLayout"
31-
android:layout_width="match_parent"
32-
android:layout_height="wrap_content"
33-
android:layout_marginLeft="20dp"
34-
android:layout_marginRight="20dp"
35-
android:layout_marginTop="20dp">
34+
android:id="@+id/mUserNameInputLayout"
35+
android:layout_width="match_parent"
36+
android:layout_height="wrap_content"
37+
android:layout_marginLeft="20dp"
38+
android:layout_marginTop="20dp"
39+
android:layout_marginRight="20dp">
3640

3741
<com.google.android.material.textfield.TextInputEditText
38-
android:id="@+id/mUserNameEditText"
39-
android:layout_width="match_parent"
40-
android:layout_height="match_parent"
41-
android:hint="Username"
42-
android:singleLine="true"
43-
android:text="@={userLoginModel.username}"/>
42+
android:id="@+id/mUserNameEditText"
43+
android:layout_width="match_parent"
44+
android:layout_height="match_parent"
45+
android:hint="Username"
46+
android:singleLine="true"
47+
android:text="@={userLoginModel.username}" />
4448
</com.google.android.material.textfield.TextInputLayout>
4549

4650
<com.google.android.material.textfield.TextInputLayout
47-
android:id="@+id/mPasswordInputLayout"
48-
android:layout_width="match_parent"
49-
android:layout_height="wrap_content"
50-
android:layout_marginLeft="20dp"
51-
android:layout_marginRight="20dp"
52-
android:layout_marginTop="20dp"
53-
app:passwordToggleEnabled="true">
51+
android:id="@+id/mPasswordInputLayout"
52+
android:layout_width="match_parent"
53+
android:layout_height="wrap_content"
54+
android:layout_marginLeft="20dp"
55+
android:layout_marginTop="20dp"
56+
android:layout_marginRight="20dp"
57+
app:passwordToggleEnabled="true">
5458

5559
<com.google.android.material.textfield.TextInputEditText
56-
android:id="@+id/mPasswordEditText"
57-
android:layout_width="match_parent"
58-
android:layout_height="match_parent"
59-
android:inputType="textPassword"
60-
android:hint="Password"
61-
android:singleLine="true"
62-
android:text="@={userLoginModel.password}"/>
60+
android:id="@+id/mPasswordEditText"
61+
android:layout_width="match_parent"
62+
android:layout_height="match_parent"
63+
android:hint="Password"
64+
android:inputType="textPassword"
65+
android:singleLine="true"
66+
android:text="@={userLoginModel.password}" />
6367
</com.google.android.material.textfield.TextInputLayout>
6468

6569
<Button
66-
android:id="@+id/mSignInBt"
67-
android:layout_width="match_parent"
68-
android:layout_height="44dp"
69-
android:text="Sign in"
70-
android:layout_marginLeft="20dp"
71-
android:layout_marginRight="20dp"
72-
android:layout_marginTop="35dp"
73-
android:background="@drawable/selector_login_bg"
74-
android:textColor="@drawable/selector_login_text_color"
75-
android:textSize="16sp"
76-
android:textAllCaps="false"/>
70+
android:id="@+id/mSignInBt"
71+
android:layout_width="match_parent"
72+
android:layout_height="44dp"
73+
android:layout_marginLeft="20dp"
74+
android:layout_marginTop="35dp"
75+
android:layout_marginRight="20dp"
76+
android:background="@drawable/selector_login_bg"
77+
android:text="Sign in"
78+
android:textAllCaps="false"
79+
android:textColor="@drawable/selector_login_text_color"
80+
android:textSize="16sp" />
7781

7882
<ProgressBar
79-
android:id="@+id/mProgressBar"
80-
android:layout_width="wrap_content"
81-
android:layout_height="wrap_content"
82-
android:layout_gravity="center_horizontal"
83-
android:layout_marginTop="35dp"
84-
android:visibility="gone"/>
83+
android:id="@+id/mProgressBar"
84+
android:layout_width="wrap_content"
85+
android:layout_height="wrap_content"
86+
android:layout_gravity="center_horizontal"
87+
android:layout_marginTop="35dp"
88+
android:visibility="gone" />
8589

8690
</LinearLayout>
8791
</layout>
Lines changed: 53 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,57 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<androidx.drawerlayout.widget.DrawerLayout
3-
xmlns:android="http://schemas.android.com/apk/res/android"
4-
xmlns:app="http://schemas.android.com/apk/res-auto"
5-
android:id="@+id/mDrawerLayout"
6-
android:layout_width="match_parent"
7-
android:layout_height="match_parent"
8-
style="@style/DrawerArrowStyle"
9-
>
10-
11-
<!--主界面-->
12-
13-
<androidx.coordinatorlayout.widget.CoordinatorLayout
14-
android:layout_width="match_parent"
15-
android:layout_height="match_parent">
16-
17-
<com.google.android.material.appbar.AppBarLayout
18-
android:layout_width="match_parent"
19-
android:layout_height="wrap_content">
20-
21-
<androidx.appcompat.widget.Toolbar
22-
android:id="@+id/mToolbar"
23-
android:layout_width="match_parent"
24-
android:layout_height="wrap_content"
25-
android:background="@color/colorPrimary"
26-
app:layout_scrollFlags="scroll|enterAlways"
27-
app:title="@string/app_name"
28-
app:titleTextColor="@android:color/white"
29-
/>
30-
31-
<com.google.android.material.tabs.TabLayout
32-
android:id="@+id/mTabLayout"
33-
android:layout_width="match_parent"
34-
android:layout_height="wrap_content"
35-
app:tabTextColor="@android:color/white"
36-
app:tabIndicatorColor="@android:color/white"
37-
app:tabTextAppearance="@android:style/TextAppearance.Widget.TabWidget"
38-
/>
39-
40-
</com.google.android.material.appbar.AppBarLayout>
41-
42-
<androidx.viewpager.widget.ViewPager
43-
android:id="@+id/mViewPager"
44-
android:layout_width="match_parent"
45-
android:layout_height="match_parent"
46-
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
47-
</androidx.coordinatorlayout.widget.CoordinatorLayout>
48-
49-
50-
<!--侧滑界面-->
51-
52-
<com.google.android.material.navigation.NavigationView
53-
android:id="@+id/mNavigationView"
54-
android:layout_width="wrap_content"
55-
android:layout_height="match_parent"
56-
android:layout_gravity="start"
57-
app:menu="@menu/menu_navigation"
58-
app:itemIconTint="@color/colorPrimary"
59-
app:itemTextColor="@color/colorPrimary"
60-
/>
2+
<androidx.drawerlayout.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:app="http://schemas.android.com/apk/res-auto"
4+
android:id="@+id/mDrawerLayout"
5+
style="@style/DrawerArrowStyle"
6+
android:layout_width="match_parent"
7+
android:layout_height="match_parent">
8+
9+
<!--主界面-->
10+
11+
<androidx.coordinatorlayout.widget.CoordinatorLayout
12+
android:layout_width="match_parent"
13+
android:layout_height="match_parent">
14+
15+
<com.google.android.material.appbar.AppBarLayout
16+
android:layout_width="match_parent"
17+
android:layout_height="wrap_content">
18+
19+
<androidx.appcompat.widget.Toolbar
20+
android:id="@+id/mToolbar"
21+
android:layout_width="match_parent"
22+
android:layout_height="wrap_content"
23+
app:layout_scrollFlags="scroll|enterAlways"
24+
app:title="@string/app_name"
25+
app:titleTextColor="@android:color/white" />
26+
27+
<com.google.android.material.tabs.TabLayout
28+
android:id="@+id/mTabLayout"
29+
android:layout_width="match_parent"
30+
android:layout_height="wrap_content"
31+
app:tabIndicatorColor="@android:color/white"
32+
app:tabTextAppearance="@android:style/TextAppearance.Widget.TabWidget"
33+
app:tabTextColor="@android:color/white" />
34+
35+
</com.google.android.material.appbar.AppBarLayout>
36+
37+
<androidx.viewpager.widget.ViewPager
38+
android:id="@+id/mViewPager"
39+
android:layout_width="match_parent"
40+
android:layout_height="match_parent"
41+
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
42+
</androidx.coordinatorlayout.widget.CoordinatorLayout>
43+
44+
45+
<!--侧滑界面-->
46+
47+
<com.google.android.material.navigation.NavigationView
48+
android:id="@+id/mNavigationView"
49+
android:layout_width="wrap_content"
50+
android:layout_height="match_parent"
51+
android:layout_gravity="start"
52+
app:itemIconTint="@color/colorPrimary"
53+
app:itemTextColor="@color/colorPrimary"
54+
app:menu="@menu/menu_navigation" />
6155

6256

6357
</androidx.drawerlayout.widget.DrawerLayout>

app/src/main/res/layout/activity_welcome.xml

Lines changed: 30 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,44 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<layout
3-
xmlns:android="http://schemas.android.com/apk/res/android"
4-
xmlns:app="http://schemas.android.com/apk/res-auto">
2+
<layout xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:app="http://schemas.android.com/apk/res-auto">
54

65
<data>
7-
<variable name="versionName" type="java.lang.String"/>
6+
7+
<variable
8+
name="versionName"
9+
type="java.lang.String" />
810
</data>
911

1012
<FrameLayout
11-
android:layout_width="match_parent"
12-
android:layout_height="match_parent">
13+
android:layout_width="match_parent"
14+
android:layout_height="match_parent"
15+
android:background="@android:color/white">
1316

1417
<com.jaredrummler.android.widget.AnimatedSvgView
15-
android:id="@+id/mAnimatedSvgView"
16-
android:layout_width="180dp"
17-
android:layout_height="180dp"
18-
android:layout_gravity="center"
19-
app:animatedSvgFillColors="@array/github_glyph_colors"
20-
app:animatedSvgGlyphStrings="@array/github_glyph_strings"
21-
app:animatedSvgFillStart="1200"
22-
app:animatedSvgFillTime="1000"
23-
app:animatedSvgTraceMarkerLength="50"
24-
app:animatedSvgTraceTime="2000"
25-
app:animatedSvgTraceTimePerGlyph="1000"/>
18+
android:id="@+id/mAnimatedSvgView"
19+
android:layout_width="180dp"
20+
android:layout_height="180dp"
21+
android:layout_gravity="center"
22+
app:animatedSvgFillColors="@array/github_glyph_colors"
23+
app:animatedSvgFillStart="1200"
24+
app:animatedSvgFillTime="1000"
25+
app:animatedSvgGlyphStrings="@array/github_glyph_strings"
26+
app:animatedSvgTraceMarkerLength="50"
27+
app:animatedSvgTraceTime="2000"
28+
app:animatedSvgTraceTimePerGlyph="1000" />
2629

2730

2831
<TextView
29-
android:id="@+id/mVersionTv"
30-
android:layout_width="wrap_content"
31-
android:layout_height="wrap_content"
32-
android:layout_gravity="bottom|center_horizontal"
33-
android:layout_marginBottom="16dp"
34-
android:layout_weight="1"
35-
android:gravity="bottom"
36-
android:textColor="@color/version_text_color"
37-
android:textSize="12sp"
38-
android:text='@{"v" + versionName}'/>
32+
android:id="@+id/mVersionTv"
33+
android:layout_width="wrap_content"
34+
android:layout_height="wrap_content"
35+
android:layout_gravity="bottom|center_horizontal"
36+
android:layout_marginBottom="16dp"
37+
android:layout_weight="1"
38+
android:gravity="bottom"
39+
android:text='@{"v" + versionName}'
40+
android:textColor="@color/version_text_color"
41+
android:textSize="12sp" />
3942

4043

4144
</FrameLayout>

0 commit comments

Comments
 (0)