Skip to content

Commit 196b7a5

Browse files
committed
接入FlutterBoost简化Native与Flutter交互
1 parent d5eecff commit 196b7a5

File tree

5 files changed

+147
-138
lines changed

5 files changed

+147
-138
lines changed

app/build.gradle

+6-7
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,18 @@ aspectjx {
2020
exclude 'module-info', 'kotlinx.coroutines', 'androidx.paging', 'com.lxj.xpopup', 'com.just.agentweb'
2121
}
2222

23-
//kapt {
24-
// generateStubs = true
25-
//}
26-
2723
android {
2824
compileSdkVersion 29
2925
defaultConfig {
3026
applicationId "com.fmt.github"
3127
minSdkVersion 21
3228
targetSdkVersion 29
33-
versionCode 13
34-
versionName "2.8"
29+
versionCode 14
30+
versionName "3.0"
3531
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
32+
ndk {
33+
abiFilters 'arm64-v8a'
34+
}
3635
}
3736
signingConfigs {
3837
release {
@@ -134,7 +133,7 @@ dependencies {
134133
//okhttp + retrofit(2.6.0以后支持协程)
135134
implementation("com.squareup.okhttp3:logging-interceptor:5.0.0-alpha.2")
136135
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
137-
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
136+
implementation 'com.squareup.retrofit2:converter-moshi:2.9.0'
138137

139138
//协程 + room
140139
implementation "androidx.room:room-runtime:2.3.0"

app/src/main/java/com/fmt/github/data/http/Retrofit.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import com.fmt.github.user.api.UserApi
99
import okhttp3.OkHttpClient
1010
import okhttp3.logging.HttpLoggingInterceptor
1111
import retrofit2.Retrofit
12-
import retrofit2.converter.gson.GsonConverterFactory
12+
import retrofit2.converter.moshi.MoshiConverterFactory
1313
import java.util.concurrent.TimeUnit
1414

1515
private const val BASE_URL = "https://api.github.com/"
@@ -35,7 +35,7 @@ val okHttpClient = OkHttpClient.Builder()
3535
}.build()
3636

3737
val retrofit: Retrofit = Retrofit.Builder()
38-
.addConverterFactory(GsonConverterFactory.create())
38+
.addConverterFactory(MoshiConverterFactory.create())
3939
.client(okHttpClient)
4040
.baseUrl(BASE_URL)
4141
.build()

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

+13-7
Original file line numberDiff line numberDiff line change
@@ -97,44 +97,50 @@
9797

9898
<TextView
9999
android:id="@+id/tv_start_num"
100-
android:layout_width="wrap_content"
100+
android:layout_width="0dp"
101101
android:layout_height="wrap_content"
102-
android:layout_marginStart="@dimen/dp_8"
102+
android:layout_marginStart="@dimen/dp_58"
103103
android:layout_marginTop="@dimen/dp_5"
104104
android:drawableStart="@mipmap/icon_start"
105105
android:drawablePadding="@dimen/dp_5"
106106
android:text="@{String.valueOf(item.stargazers_count)}"
107107
android:textColor="@color/repos_common_text_color"
108108
android:textSize="@dimen/sp_12"
109-
app:layout_constraintLeft_toRightOf="@id/iv_head"
109+
app:layout_constraintHorizontal_weight="1"
110+
app:layout_constraintLeft_toLeftOf="parent"
111+
app:layout_constraintRight_toLeftOf="@id/tv_fork_num"
110112
app:layout_constraintTop_toBottomOf="@id/tv_repos_des" />
111113

112114
<TextView
113115
android:id="@+id/tv_fork_num"
114-
android:layout_width="wrap_content"
116+
android:layout_width="0dp"
115117
android:layout_height="wrap_content"
116-
android:layout_marginStart="@dimen/dp_40"
117118
android:layout_marginTop="@dimen/dp_5"
118119
android:drawableStart="@mipmap/icon_fork"
119120
android:drawablePadding="@dimen/dp_5"
120121
android:text="@{String.valueOf(item.forks)}"
121122
android:textColor="@color/repos_common_text_color"
122123
android:textSize="@dimen/sp_12"
124+
app:layout_constraintHorizontal_weight="1"
123125
app:layout_constraintLeft_toRightOf="@id/tv_start_num"
126+
app:layout_constraintRight_toLeftOf="@id/tv_author"
124127
app:layout_constraintTop_toBottomOf="@id/tv_repos_des" />
125128

126129
<TextView
127130
android:id="@+id/tv_author"
128-
android:layout_width="wrap_content"
131+
android:layout_width="0dp"
129132
android:layout_height="wrap_content"
130-
android:layout_marginStart="@dimen/dp_40"
131133
android:layout_marginTop="@dimen/dp_5"
132134
android:drawableStart="@mipmap/icon_author"
133135
android:drawablePadding="@dimen/dp_5"
134136
android:text="@{item.owner.login}"
135137
android:textColor="@color/repos_common_text_color"
136138
android:textSize="@dimen/sp_12"
139+
android:maxLines="1"
140+
android:ellipsize="end"
141+
app:layout_constraintHorizontal_weight="1"
137142
app:layout_constraintLeft_toRightOf="@id/tv_fork_num"
143+
app:layout_constraintRight_toRightOf="parent"
138144
app:layout_constraintTop_toBottomOf="@id/tv_repos_des" />
139145

140146

flutter_module/lib/widget/follow_page_item.dart

+28-26
Original file line numberDiff line numberDiff line change
@@ -14,35 +14,37 @@ class FollowPageItem extends StatelessWidget {
1414
Widget build(BuildContext context) {
1515
return Card(
1616
margin: EdgeInsets.fromLTRB(8, 8, 8, 4),
17-
child: InkWell(
18-
child: Padding(
19-
padding: EdgeInsets.all(15),
20-
child: Row(
21-
children: [
22-
ClipOval(
23-
child: CachedNetworkImage(
24-
imageUrl: followModel.avatarUrl,
25-
height: 40,
26-
width: 40,
27-
fit: BoxFit.cover),
28-
),
29-
Padding(
30-
padding: EdgeInsets.only(left: 10),
31-
child: Text(
32-
followModel.login,
33-
style: TextStyle(
34-
color: DColor.themeColor,
35-
fontSize: 18,
36-
fontWeight: FontWeight.bold),
17+
child: Material(
18+
child: InkWell(
19+
child: Padding(
20+
padding: EdgeInsets.all(15),
21+
child: Row(
22+
children: [
23+
ClipOval(
24+
child: CachedNetworkImage(
25+
imageUrl: followModel.avatarUrl,
26+
height: 40,
27+
width: 40,
28+
fit: BoxFit.cover),
3729
),
38-
)
39-
],
30+
Padding(
31+
padding: EdgeInsets.only(left: 10),
32+
child: Text(
33+
followModel.login,
34+
style: TextStyle(
35+
color: DColor.themeColor,
36+
fontSize: 18,
37+
fontWeight: FontWeight.bold),
38+
),
39+
)
40+
],
41+
),
4042
),
43+
onTap: () => NavigationUtil.push(USER_INFO_PAGE, arguments: {
44+
"user_name": followModel.login,
45+
"user_avatar": followModel.avatarUrl,
46+
}),
4147
),
42-
onTap: ()=>NavigationUtil.push(USER_INFO_PAGE, arguments: {
43-
"user_name": followModel.login,
44-
"user_avatar": followModel.avatarUrl,
45-
}),
4648
),
4749
);
4850
}

flutter_module/lib/widget/trend_page_item.dart

+98-96
Original file line numberDiff line numberDiff line change
@@ -14,111 +14,113 @@ class TrendPageItem extends StatelessWidget {
1414
Widget build(BuildContext context) {
1515
return Card(
1616
margin: EdgeInsets.fromLTRB(8, 8, 8, 4),
17-
child: InkWell(
18-
onTap: () => NavigationUtil.push(REPOS_DETAIL_PAGE, arguments: {
19-
"web_url": trendModel.url,
20-
"owner": trendModel.name,
21-
"repo": trendModel.reposName
22-
}),
23-
child: Padding(
24-
padding: EdgeInsets.all(8),
25-
child: Row(
26-
crossAxisAlignment: CrossAxisAlignment.start,
27-
children: <Widget>[
28-
ClipOval(
29-
child: CachedNetworkImage(
30-
imageUrl: trendModel.contributorsUrl,
31-
height: 40,
32-
width: 40,
33-
fit: BoxFit.cover),
34-
),
35-
Expanded(
36-
child: Padding(
37-
padding: EdgeInsets.only(left: 8),
38-
child: Column(
39-
crossAxisAlignment: CrossAxisAlignment.start,
40-
children: <Widget>[
41-
Row(
42-
mainAxisAlignment: MainAxisAlignment.spaceBetween,
43-
children: <Widget>[
44-
Expanded(
45-
child: Text(
46-
trendModel.reposName,
47-
overflow: TextOverflow.ellipsis,
48-
style: TextStyle(
49-
color: DColor.themeColor,
50-
fontSize: 16,
51-
fontWeight: FontWeight.bold),
52-
)),
53-
Container(
54-
margin: EdgeInsets.only(left: 10),
55-
child: Text(
56-
trendModel.language,
57-
style: TextStyle(
58-
color: DColor.desTextColor, fontSize: 12),
59-
),
60-
)
61-
],
62-
),
63-
Text(
64-
trendModel.description,
65-
style:
66-
TextStyle(color: DColor.desTextColor, fontSize: 14),
67-
),
68-
Padding(
69-
padding: EdgeInsets.only(top: 4),
70-
child: Row(
71-
mainAxisAlignment: MainAxisAlignment.spaceBetween,
17+
child: Material(
18+
child: InkWell(
19+
onTap: () => NavigationUtil.push(REPOS_DETAIL_PAGE, arguments: {
20+
"web_url": trendModel.url,
21+
"owner": trendModel.name,
22+
"repo": trendModel.reposName
23+
}),
24+
child: Padding(
25+
padding: EdgeInsets.all(8),
26+
child: Row(
27+
crossAxisAlignment: CrossAxisAlignment.start,
28+
children: <Widget>[
29+
ClipOval(
30+
child: CachedNetworkImage(
31+
imageUrl: trendModel.contributorsUrl,
32+
height: 40,
33+
width: 40,
34+
fit: BoxFit.cover),
35+
),
36+
Expanded(
37+
child: Padding(
38+
padding: EdgeInsets.only(left: 8),
39+
child: Column(
40+
crossAxisAlignment: CrossAxisAlignment.start,
7241
children: <Widget>[
73-
Column(
74-
mainAxisAlignment: MainAxisAlignment.center,
42+
Row(
43+
mainAxisAlignment: MainAxisAlignment.spaceBetween,
7544
children: <Widget>[
76-
Icon(
77-
Icons.star_border,
78-
color: DColor.desTextColor,
79-
size: 20,
80-
),
81-
Text(
82-
trendModel.starCount,
83-
style: TextStyle(color: DColor.desTextColor),
45+
Expanded(
46+
child: Text(
47+
trendModel.reposName,
48+
overflow: TextOverflow.ellipsis,
49+
style: TextStyle(
50+
color: DColor.themeColor,
51+
fontSize: 16,
52+
fontWeight: FontWeight.bold),
53+
)),
54+
Container(
55+
margin: EdgeInsets.only(left: 10),
56+
child: Text(
57+
trendModel.language,
58+
style: TextStyle(
59+
color: DColor.desTextColor, fontSize: 12),
60+
),
8461
)
8562
],
8663
),
87-
Column(
88-
mainAxisAlignment: MainAxisAlignment.center,
89-
children: <Widget>[
90-
Icon(
91-
Icons.device_hub,
92-
color: DColor.desTextColor,
93-
size: 20,
94-
),
95-
Text(
96-
trendModel.forkCount,
97-
style: TextStyle(color: DColor.desTextColor),
98-
)
99-
],
64+
Text(
65+
trendModel.description,
66+
style:
67+
TextStyle(color: DColor.desTextColor, fontSize: 14),
10068
),
101-
Column(
102-
mainAxisAlignment: MainAxisAlignment.center,
103-
children: <Widget>[
104-
Icon(
105-
Icons.remove_red_eye,
106-
color: DColor.desTextColor,
107-
size: 20,
108-
),
109-
Text(
110-
trendModel.meta,
111-
style: TextStyle(color: DColor.desTextColor),
112-
)
113-
],
69+
Padding(
70+
padding: EdgeInsets.only(top: 4),
71+
child: Row(
72+
mainAxisAlignment: MainAxisAlignment.spaceBetween,
73+
children: <Widget>[
74+
Column(
75+
mainAxisAlignment: MainAxisAlignment.center,
76+
children: <Widget>[
77+
Icon(
78+
Icons.star_border,
79+
color: DColor.desTextColor,
80+
size: 20,
81+
),
82+
Text(
83+
trendModel.starCount,
84+
style: TextStyle(color: DColor.desTextColor),
85+
)
86+
],
87+
),
88+
Column(
89+
mainAxisAlignment: MainAxisAlignment.center,
90+
children: <Widget>[
91+
Icon(
92+
Icons.device_hub,
93+
color: DColor.desTextColor,
94+
size: 20,
95+
),
96+
Text(
97+
trendModel.forkCount,
98+
style: TextStyle(color: DColor.desTextColor),
99+
)
100+
],
101+
),
102+
Column(
103+
mainAxisAlignment: MainAxisAlignment.center,
104+
children: <Widget>[
105+
Icon(
106+
Icons.remove_red_eye,
107+
color: DColor.desTextColor,
108+
size: 20,
109+
),
110+
Text(
111+
trendModel.meta,
112+
style: TextStyle(color: DColor.desTextColor),
113+
)
114+
],
115+
)
116+
],
117+
),
114118
)
115119
],
116120
),
117-
)
118-
],
119-
),
120-
))
121-
],
121+
))
122+
],
123+
),
122124
),
123125
),
124126
),

0 commit comments

Comments
 (0)