Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
flutter_boost_1.22.4
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
谢冠章
flutter_boost_1.22.4
Commits
7e30fa0b
Commit
7e30fa0b
authored
Oct 11, 2019
by
yangwu.jia
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
boost1.9升级
parent
6afc509d
Changes
8
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
163 additions
and
406 deletions
+163
-406
android/build.gradle
android/build.gradle
+1
-0
android/src/main/java/com/idlefish/flutterboost/Utils.java
android/src/main/java/com/idlefish/flutterboost/Utils.java
+56
-5
android/src/main/java/com/idlefish/flutterboost/containers/FlutterActivityAndFragmentDelegate.java
...rboost/containers/FlutterActivityAndFragmentDelegate.java
+9
-49
android/src/main/java/com/idlefish/flutterboost/containers/NewBoostFlutterActivity.java
...fish/flutterboost/containers/NewBoostFlutterActivity.java
+20
-146
android/src/main/java/com/idlefish/flutterboost/containers/NewFlutterFragment.java
.../idlefish/flutterboost/containers/NewFlutterFragment.java
+61
-198
example/android/app/src/main/java/com/taobao/idlefish/flutterboostexample/FlutterFragmentPageActivity.java
...fish/flutterboostexample/FlutterFragmentPageActivity.java
+8
-6
example/android/app/src/main/java/com/taobao/idlefish/flutterboostexample/MyApplication.java
...om/taobao/idlefish/flutterboostexample/MyApplication.java
+2
-1
example/android/app/src/main/java/com/taobao/idlefish/flutterboostexample/PageRouter.java
...a/com/taobao/idlefish/flutterboostexample/PageRouter.java
+6
-1
No files found.
android/build.gradle
View file @
7e30fa0b
...
...
@@ -39,6 +39,7 @@ dependencies {
implementation
'com.android.support:design:28.0.0'
implementation
'com.android.support:support-v4:28.0.0'
implementation
'android.arch.lifecycle:common-java8:1.1.1'
implementation
'com.alibaba:fastjson:1.2.41'
}
...
...
android/src/main/java/com/idlefish/flutterboost/Utils.java
View file @
7e30fa0b
...
...
@@ -35,14 +35,14 @@ import android.view.View;
import
android.view.Window
;
import
android.view.WindowManager
;
import
android.view.inputmethod.InputMethodManager
;
import
com.alibaba.fastjson.JSON
;
import
java.io.BufferedReader
;
import
java.io.File
;
import
java.io.FileOutputStream
;
import
java.io.IOException
;
import
java.io.InputStreamReader
;
import
java.io.*
;
import
java.lang.reflect.Field
;
import
java.lang.reflect.Method
;
import
java.net.URLEncoder
;
import
java.util.List
;
import
java.util.Map
;
public
class
Utils
{
...
...
@@ -289,4 +289,55 @@ public class Utils {
}
}
public
static
String
assembleUrl
(
String
url
,
Map
<
String
,
Object
>
urlParams
){
StringBuilder
targetUrl
=
new
StringBuilder
(
url
);
if
(
urlParams
!=
null
&&
!
urlParams
.
isEmpty
())
{
if
(!
targetUrl
.
toString
().
contains
(
"?"
)){
targetUrl
.
append
(
"?"
);
}
for
(
Map
.
Entry
entry:
urlParams
.
entrySet
())
{
if
(
entry
.
getValue
()
instanceof
Map
)
{
Map
<
String
,
Object
>
params
=
(
Map
<
String
,
Object
>
)
entry
.
getValue
();
for
(
Map
.
Entry
param:
params
.
entrySet
())
{
String
key
=
(
String
)
param
.
getKey
();
String
value
=
null
;
if
(
param
.
getValue
()
instanceof
Map
||
param
.
getValue
()
instanceof
List
)
{
try
{
value
=
URLEncoder
.
encode
(
JSON
.
toJSONString
(
param
.
getValue
()),
"UTF-8"
);
}
catch
(
UnsupportedEncodingException
e
)
{
e
.
printStackTrace
();
}
}
else
{
value
=
(
param
.
getValue
()==
null
?
null
:
URLEncoder
.
encode
(
String
.
valueOf
(
param
.
getValue
())));
}
if
(
value
==
null
){
continue
;
}
if
(
targetUrl
.
toString
().
endsWith
(
"?"
)){
targetUrl
.
append
(
key
).
append
(
"="
).
append
(
value
);
}
else
{
targetUrl
.
append
(
"&"
).
append
(
key
).
append
(
"="
).
append
(
value
);
}
}
}
}
}
return
targetUrl
.
toString
();
}
}
\ No newline at end of file
android/src/main/java/com/idlefish/flutterboost/containers/FlutterActivityAndFragmentDelegate.java
View file @
7e30fa0b
...
...
@@ -7,7 +7,6 @@ import android.content.Context;
import
android.content.Intent
;
import
android.os.Build
;
import
android.os.Bundle
;
import
android.os.Handler
;
import
android.support.annotation.NonNull
;
import
android.support.annotation.Nullable
;
import
android.view.LayoutInflater
;
...
...
@@ -16,7 +15,6 @@ import android.view.ViewGroup;
import
java.io.Serializable
;
import
java.util.Arrays
;
import
java.util.HashMap
;
import
java.util.Map
;
...
...
@@ -27,9 +25,7 @@ import io.flutter.Log;
import
io.flutter.app.FlutterActivity
;
import
io.flutter.embedding.android.*
;
import
io.flutter.embedding.engine.FlutterEngine
;
import
io.flutter.embedding.engine.FlutterEngineCache
;
import
io.flutter.embedding.engine.FlutterShellArgs
;
import
io.flutter.embedding.engine.dart.DartExecutor
;
import
io.flutter.embedding.engine.renderer.OnFirstFrameRenderedListener
;
import
io.flutter.plugin.platform.PlatformPlugin
;
import
io.flutter.view.FlutterMain
;
...
...
@@ -157,7 +153,7 @@ public class FlutterActivityAndFragmentDelegate implements IFlutterViewContaine
// Our host did not provide a custom FlutterEngine. Create a FlutterEngine to back our
// FlutterView.
Log
.
d
(
TAG
,
"No preferred FlutterEngine was provided. Creating a new FlutterEngine for"
+
" this FlutterFragment."
);
+
" this
New
FlutterFragment."
);
flutterEngine
=
new
FlutterEngine
(
host
.
getContext
());
isFlutterEngineFromHost
=
false
;
}
...
...
@@ -224,7 +220,7 @@ public class FlutterActivityAndFragmentDelegate implements IFlutterViewContaine
platformPlugin
.
updateSystemUiOverlays
();
}
}
else
{
Log
.
w
(
TAG
,
"onPostResume() invoked before FlutterFragment was attached to an Activity."
);
Log
.
w
(
TAG
,
"onPostResume() invoked before
New
FlutterFragment was attached to an Activity."
);
}
}
...
...
@@ -296,7 +292,7 @@ public class FlutterActivityAndFragmentDelegate implements IFlutterViewContaine
// Log.v(TAG, "Forwarding onBackPressed() to FlutterEngine.");
// flutterEngine.getNavigationChannel().popRoute();
// } else {
// Log.w(TAG, "Invoked onBackPressed() before FlutterFragment was attached to an Activity.");
// Log.w(TAG, "Invoked onBackPressed() before
New
FlutterFragment was attached to an Activity.");
// }
}
...
...
@@ -312,7 +308,7 @@ public class FlutterActivityAndFragmentDelegate implements IFlutterViewContaine
+
"grantResults: "
+
Arrays
.
toString
(
grantResults
));
flutterEngine
.
getActivityControlSurface
().
onRequestPermissionsResult
(
requestCode
,
permissions
,
grantResults
);
}
else
{
Log
.
w
(
TAG
,
"onRequestPermissionResult() invoked before FlutterFragment was attached to an Activity."
);
Log
.
w
(
TAG
,
"onRequestPermissionResult() invoked before
New
FlutterFragment was attached to an Activity."
);
}
}
...
...
@@ -325,7 +321,7 @@ public class FlutterActivityAndFragmentDelegate implements IFlutterViewContaine
Log
.
v
(
TAG
,
"Forwarding onNewIntent() to FlutterEngine."
);
flutterEngine
.
getActivityControlSurface
().
onNewIntent
(
intent
);
}
else
{
Log
.
w
(
TAG
,
"onNewIntent() invoked before FlutterFragment was attached to an Activity."
);
Log
.
w
(
TAG
,
"onNewIntent() invoked before
New
FlutterFragment was attached to an Activity."
);
}
}
...
...
@@ -351,7 +347,7 @@ public class FlutterActivityAndFragmentDelegate implements IFlutterViewContaine
+
"data: "
+
data
);
flutterEngine
.
getActivityControlSurface
().
onActivityResult
(
requestCode
,
resultCode
,
data
);
}
else
{
Log
.
w
(
TAG
,
"onActivityResult() invoked before FlutterFragment was attached to an Activity."
);
Log
.
w
(
TAG
,
"onActivityResult() invoked before
New
FlutterFragment was attached to an Activity."
);
}
}
...
...
@@ -362,7 +358,7 @@ public class FlutterActivityAndFragmentDelegate implements IFlutterViewContaine
Log
.
v
(
TAG
,
"Forwarding onUserLeaveHint() to FlutterEngine."
);
flutterEngine
.
getActivityControlSurface
().
onUserLeaveHint
();
}
else
{
Log
.
w
(
TAG
,
"onUserLeaveHint() invoked before FlutterFragment was attached to an Activity."
);
Log
.
w
(
TAG
,
"onUserLeaveHint() invoked before
New
FlutterFragment was attached to an Activity."
);
}
}
...
...
@@ -379,7 +375,7 @@ public class FlutterActivityAndFragmentDelegate implements IFlutterViewContaine
flutterEngine
.
getSystemChannel
().
sendMemoryPressureWarning
();
}
}
else
{
Log
.
w
(
TAG
,
"onTrimMemory() invoked before FlutterFragment was attached to an Activity."
);
Log
.
w
(
TAG
,
"onTrimMemory() invoked before
New
FlutterFragment was attached to an Activity."
);
}
}
...
...
@@ -440,7 +436,7 @@ public class FlutterActivityAndFragmentDelegate implements IFlutterViewContaine
}
/**
* The {@link FlutterActivity} or {@link FlutterFragment} that owns this
* The {@link FlutterActivity} or {@link
New
FlutterFragment} that owns this
* {@code FlutterActivityAndFragmentDelegate}.
*/
/* package */
interface
Host
extends
SplashScreenProvider
,
FlutterEngineProvider
,
FlutterEngineConfigurator
{
...
...
@@ -469,42 +465,6 @@ public class FlutterActivityAndFragmentDelegate implements IFlutterViewContaine
@NonNull
FlutterShellArgs
getFlutterShellArgs
();
/**
* Returns the ID of a statically cached {@link FlutterEngine} to use within this
* delegate's host, or {@code null} if this delegate's host does not want to
* use a cached {@link FlutterEngine}.
*/
@Nullable
String
getCachedEngineId
();
/**
* Returns true if the {@link FlutterEngine} used in this delegate should be destroyed
* when the host/delegate are destroyed.
* <p>
* The default value is {@code true} in cases where {@code FlutterFragment} created its own
* {@link FlutterEngine}, and {@code false} in cases where a cached {@link FlutterEngine} was
* provided.
*/
boolean
shouldDestroyEngineWithHost
();
/**
* Returns the Dart entrypoint that should run when a new {@link FlutterEngine} is
* created.
*/
@NonNull
String
getDartEntrypointFunctionName
();
/**
* Returns the path to the app bundle where the Dart code exists.
*/
@NonNull
String
getAppBundlePath
();
/**
* Returns the initial route that Flutter renders.
*/
@Nullable
String
getInitialRoute
();
/**
* Returns the {@link FlutterView.RenderMode} used by the {@link FlutterView} that
...
...
android/src/main/java/com/idlefish/flutterboost/containers/NewBoostFlutterActivity.java
View file @
7e30fa0b
This diff is collapsed.
Click to expand it.
android/src/main/java/com/idlefish/flutterboost/containers/FlutterFragment.java
→
android/src/main/java/com/idlefish/flutterboost/containers/
New
FlutterFragment.java
View file @
7e30fa0b
This diff is collapsed.
Click to expand it.
example/android/app/src/main/java/com/taobao/idlefish/flutterboostexample/FlutterFragmentPageActivity.java
View file @
7e30fa0b
...
...
@@ -9,12 +9,12 @@ import android.support.v7.app.AppCompatActivity;
import
android.view.View
;
import
android.view.Window
;
import
android.view.WindowManager
;
import
com.idlefish.flutterboost.containers.FlutterFragment
;
import
com.idlefish.flutterboost.containers.
New
FlutterFragment
;
import
io.flutter.plugin.platform.PlatformPlugin
;
public
class
FlutterFragmentPageActivity
extends
AppCompatActivity
implements
View
.
OnClickListener
{
private
FlutterFragment
mFragment
;
private
New
FlutterFragment
mFragment
;
private
View
mTab1
;
private
View
mTab2
;
...
...
@@ -61,16 +61,18 @@ public class FlutterFragmentPageActivity extends AppCompatActivity implements Vi
if
(
mTab1
==
v
)
{
mTab1
.
setBackgroundColor
(
Color
.
YELLOW
);
mFragment
=
FlutterFragment
.
createDefault
();
mFragment
=
new
NewFlutterFragment
.
NewEngineFragmentBuilder
().
url
(
"flutterFragment"
).
build
();
}
else
if
(
mTab2
==
v
)
{
mTab2
.
setBackgroundColor
(
Color
.
YELLOW
);
mFragment
=
FlutterFragment
.
createDefault
();
mFragment
=
new
NewFlutterFragment
.
NewEngineFragmentBuilder
().
url
(
"flutterFragment"
).
build
();
}
else
if
(
mTab3
==
v
)
{
mTab3
.
setBackgroundColor
(
Color
.
YELLOW
);
mFragment
=
FlutterFragment
.
createDefault
();
mFragment
=
new
NewFlutterFragment
.
NewEngineFragmentBuilder
().
url
(
"flutterFragment"
).
build
();
}
else
{
mTab4
.
setBackgroundColor
(
Color
.
YELLOW
);
mFragment
=
FlutterFragment
.
createDefault
();
mFragment
=
new
NewFlutterFragment
.
NewEngineFragmentBuilder
().
url
(
"flutterFragment"
).
build
();
}
getSupportFragmentManager
()
...
...
example/android/app/src/main/java/com/taobao/idlefish/flutterboostexample/MyApplication.java
View file @
7e30fa0b
...
...
@@ -19,7 +19,8 @@ public class MyApplication extends FlutterApplication {
INativeRouter
router
=
new
INativeRouter
()
{
@Override
public
void
openContainer
(
Context
context
,
String
url
,
Map
<
String
,
Object
>
urlParams
,
int
requestCode
,
Map
<
String
,
Object
>
exts
)
{
PageRouter
.
openPageByUrl
(
context
,
url
,
urlParams
);
String
assembleUrl
=
Utils
.
assembleUrl
(
url
,
urlParams
);
PageRouter
.
openPageByUrl
(
context
,
assembleUrl
,
urlParams
);
}
};
...
...
example/android/app/src/main/java/com/taobao/idlefish/flutterboostexample/PageRouter.java
View file @
7e30fa0b
...
...
@@ -5,6 +5,7 @@ import android.content.Intent;
import
android.text.TextUtils
;
import
com.idlefish.flutterboost.containers.NewBoostFlutterActivity
;
import
java.util.HashMap
;
import
java.util.Map
;
public
class
PageRouter
{
...
...
@@ -20,8 +21,12 @@ public class PageRouter {
public
static
boolean
openPageByUrl
(
Context
context
,
String
url
,
Map
params
,
int
requestCode
)
{
try
{
if
(
url
.
startsWith
(
FLUTTER_PAGE_URL
))
{
HashMap
p
=
new
HashMap
();
context
.
startActivity
(
NewBoostFlutterActivity
.
createDefaultIntent
(
context
));
Intent
intent
=
NewBoostFlutterActivity
.
withNewEngine
().
url
(
"flutterPage"
).
params
(
p
)
.
backgroundMode
(
NewBoostFlutterActivity
.
BackgroundMode
.
opaque
).
build
(
context
);
context
.
startActivity
(
intent
);
return
true
;
}
else
if
(
url
.
startsWith
(
FLUTTER_FRAGMENT_PAGE_URL
))
{
context
.
startActivity
(
new
Intent
(
context
,
FlutterFragmentPageActivity
.
class
));
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment