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
94f01e51
Commit
94f01e51
authored
Jun 27, 2019
by
Yacumima
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
improve
parent
436c5960
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
84 additions
and
35 deletions
+84
-35
android/src/main/java/com/taobao/idlefish/flutterboost/BoostFlutterView.java
...va/com/taobao/idlefish/flutterboost/BoostFlutterView.java
+15
-5
android/src/main/java/com/taobao/idlefish/flutterboost/ContainerRecord.java
...ava/com/taobao/idlefish/flutterboost/ContainerRecord.java
+27
-25
android/src/main/java/com/taobao/idlefish/flutterboost/Utils.java
...src/main/java/com/taobao/idlefish/flutterboost/Utils.java
+29
-0
android/src/main/java/com/taobao/idlefish/flutterboost/containers/BoostFlutterActivity.java
...dlefish/flutterboost/containers/BoostFlutterActivity.java
+1
-1
example/android/app/build.gradle
example/android/app/build.gradle
+4
-4
example/android/app/src/main/AndroidManifest.xml
example/android/app/src/main/AndroidManifest.xml
+4
-0
lib/container/container_coordinator.dart
lib/container/container_coordinator.dart
+4
-0
No files found.
android/src/main/java/com/taobao/idlefish/flutterboost/BoostFlutterView.java
View file @
94f01e51
...
...
@@ -26,10 +26,11 @@ package com.taobao.idlefish.flutterboost;
import
android.app.Activity
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.graphics.Bitmap
;
import
android.graphics.Color
;
import
android.os.Bundle
;
import
android.os.SystemClock
;
import
android.support.v4.view.ViewCompat
;
import
android.util.Log
;
import
android.view.Gravity
;
import
android.view.View
;
import
android.view.ViewGroup
;
...
...
@@ -71,6 +72,8 @@ public class BoostFlutterView extends FrameLayout {
new
io
.
flutter
.
embedding
.
engine
.
renderer
.
OnFirstFrameRenderedListener
()
{
@Override
public
void
onFirstFrameRendered
()
{
Debuger
.
log
(
"BoostFlutterView onFirstFrameRendered"
);
if
(
mRenderingProgressCover
!=
null
&&
mRenderingProgressCover
.
getParent
()
!=
null
)
{
((
ViewGroup
)
mRenderingProgressCover
.
getParent
()).
removeView
(
mRenderingProgressCover
);
}
...
...
@@ -240,13 +243,18 @@ public class BoostFlutterView extends FrameLayout {
((
ViewGroup
)
mSnapshot
.
getParent
()).
removeView
(
mSnapshot
);
}
Debuger
.
log
(
"BoostFlutterView snapshot"
);
final
Bitmap
bitmap
=
mFlutterEngine
.
getRenderer
().
getBitmap
();
if
(
bitmap
!=
null
)
{
Debuger
.
log
(
"BoostFlutterView snapshot "
+
bitmap
.
getByteCount
());
mSnapshot
.
setImageBitmap
(
mFlutterEngine
.
getRenderer
().
getBitmap
());
BoostFlutterView
.
this
.
addView
(
mSnapshot
);
//Utils.saveBitmap(bitmap,"/sdcard/idlefish/fb/ss-"+ SystemClock.uptimeMillis());
mSnapshot
.
setImageBitmap
(
bitmap
);
BoostFlutterView
.
this
.
addView
(
mSnapshot
);
}
}
mFlutterView
.
removeOnFirstFrameRenderedListener
(
mOnFirstFrameRenderedListener
);
final
IStateListener
stateListener
=
FlutterBoostPlugin
.
sInstance
.
mStateListener
;
if
(
stateListener
!=
null
)
{
stateListener
.
beforeEngineDetach
(
mFlutterEngine
,
this
);
...
...
@@ -259,6 +267,8 @@ public class BoostFlutterView extends FrameLayout {
public
void
onDestroy
()
{
Debuger
.
log
(
"BoostFlutterView onDestroy"
);
mFlutterView
.
removeOnFirstFrameRenderedListener
(
mOnFirstFrameRenderedListener
);
mPlatformPlugin
=
null
;
mFlutterEngine
=
null
;
}
...
...
android/src/main/java/com/taobao/idlefish/flutterboost/ContainerRecord.java
View file @
94f01e51
/*
* The MIT License (MIT)
*
*
* Copyright (c) 2019 Alibaba Group
*
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
...
...
@@ -65,7 +65,7 @@ public class ContainerRecord implements IContainerRecord {
Utils
.
assertCallOnMainThread
();
BoostEngineProvider
.
assertEngineRunning
();
if
(
mState
!=
STATE_UNKNOW
)
{
if
(
mState
!=
STATE_UNKNOW
)
{
Debuger
.
exception
(
"state error"
);
}
...
...
@@ -78,7 +78,7 @@ public class ContainerRecord implements IContainerRecord {
public
void
onAppear
()
{
Utils
.
assertCallOnMainThread
();
if
(
mState
!=
STATE_CREATED
&&
mState
!=
STATE_DISAPPEAR
)
{
if
(
mState
!=
STATE_CREATED
&&
mState
!=
STATE_DISAPPEAR
)
{
Debuger
.
exception
(
"state error"
);
}
...
...
@@ -95,7 +95,7 @@ public class ContainerRecord implements IContainerRecord {
public
void
onDisappear
()
{
Utils
.
assertCallOnMainThread
();
if
(
mState
!=
STATE_APPEAR
)
{
if
(
mState
!=
STATE_APPEAR
)
{
Debuger
.
exception
(
"state error"
);
}
...
...
@@ -112,7 +112,7 @@ public class ContainerRecord implements IContainerRecord {
public
void
onDestroy
()
{
Utils
.
assertCallOnMainThread
();
if
(
mState
!=
STATE_DISAPPEAR
)
{
if
(
mState
!=
STATE_DISAPPEAR
)
{
Debuger
.
exception
(
"state error"
);
}
...
...
@@ -120,9 +120,11 @@ public class ContainerRecord implements IContainerRecord {
mProxy
.
destroy
();
mContainer
.
getBoostFlutterView
().
onDestroy
();
mManager
.
removeRecord
(
this
);
if
(!
mManager
.
hasContainerAppear
())
{
if
(!
mManager
.
hasContainerAppear
())
{
mContainer
.
getBoostFlutterView
().
onPause
();
mContainer
.
getBoostFlutterView
().
onStop
();
}
...
...
@@ -132,7 +134,7 @@ public class ContainerRecord implements IContainerRecord {
public
void
onBackPressed
()
{
Utils
.
assertCallOnMainThread
();
if
(
mState
==
STATE_UNKNOW
||
mState
==
STATE_DESTROYED
)
{
if
(
mState
==
STATE_UNKNOW
||
mState
==
STATE_DESTROYED
)
{
Debuger
.
exception
(
"state error"
);
}
...
...
@@ -141,14 +143,14 @@ public class ContainerRecord implements IContainerRecord {
map
.
put
(
"name"
,
mContainer
.
getContainerUrl
());
map
.
put
(
"uniqueId"
,
mUniqueId
);
FlutterBoostPlugin
.
singleton
().
channel
().
sendEvent
(
"lifecycle"
,
map
);
FlutterBoostPlugin
.
singleton
().
channel
().
sendEvent
(
"lifecycle"
,
map
);
mContainer
.
getBoostFlutterView
().
onBackPressed
();
}
@Override
public
void
onRequestPermissionsResult
(
int
requestCode
,
String
[]
permissions
,
int
[]
grantResults
)
{
mContainer
.
getBoostFlutterView
().
onRequestPermissionsResult
(
requestCode
,
permissions
,
grantResults
);
mContainer
.
getBoostFlutterView
().
onRequestPermissionsResult
(
requestCode
,
permissions
,
grantResults
);
}
@Override
...
...
@@ -158,12 +160,12 @@ public class ContainerRecord implements IContainerRecord {
@Override
public
void
onActivityResult
(
int
requestCode
,
int
resultCode
,
Intent
data
)
{
mContainer
.
getBoostFlutterView
().
onActivityResult
(
requestCode
,
resultCode
,
data
);
mContainer
.
getBoostFlutterView
().
onActivityResult
(
requestCode
,
resultCode
,
data
);
}
@Override
public
void
onContainerResult
(
int
requestCode
,
Map
<
String
,
Object
>
result
)
{
mManager
.
setContainerResult
(
this
,
requestCode
,
result
);
public
void
onContainerResult
(
int
requestCode
,
Map
<
String
,
Object
>
result
)
{
mManager
.
setContainerResult
(
this
,
requestCode
,
result
);
}
@Override
...
...
@@ -187,7 +189,7 @@ public class ContainerRecord implements IContainerRecord {
private
void
create
()
{
if
(
mState
==
STATE_UNKNOW
)
{
invokeChannelUnsafe
(
invokeChannelUnsafe
(
"didInitPageContainer"
,
mContainer
.
getContainerUrl
(),
mContainer
.
getContainerUrlParams
(),
mUniqueId
...
...
@@ -198,7 +200,7 @@ public class ContainerRecord implements IContainerRecord {
}
private
void
appear
()
{
invokeChannelUnsafe
(
invokeChannelUnsafe
(
"didShowPageContainer"
,
mContainer
.
getContainerUrl
(),
mContainer
.
getContainerUrlParams
(),
mUniqueId
...
...
@@ -210,7 +212,7 @@ public class ContainerRecord implements IContainerRecord {
private
void
disappear
()
{
if
(
mState
<
STATE_DISAPPEAR
)
{
invokeChannel
(
invokeChannel
(
"didDisappearPageContainer"
,
mContainer
.
getContainerUrl
(),
mContainer
.
getContainerUrlParams
(),
mUniqueId
...
...
@@ -223,7 +225,7 @@ public class ContainerRecord implements IContainerRecord {
private
void
destroy
()
{
if
(
mState
<
STATE_DESTROYED
)
{
invokeChannel
(
invokeChannel
(
"willDeallocPageContainer"
,
mContainer
.
getContainerUrl
(),
mContainer
.
getContainerUrlParams
(),
mUniqueId
...
...
@@ -234,20 +236,20 @@ public class ContainerRecord implements IContainerRecord {
}
}
public
void
invokeChannel
(
String
pageName
,
Map
params
,
String
uniqueId
)
{
public
void
invokeChannel
(
String
method
,
String
url
,
Map
params
,
String
uniqueId
)
{
HashMap
<
String
,
Object
>
args
=
new
HashMap
<>();
args
.
put
(
"pageName"
,
pageName
);
args
.
put
(
"pageName"
,
url
);
args
.
put
(
"params"
,
params
);
args
.
put
(
"uniqueId"
,
uniqueId
);
FlutterBoostPlugin
.
singleton
().
channel
().
invokeMethod
(
"didInitPageContainer"
,
args
);
FlutterBoostPlugin
.
singleton
().
channel
().
invokeMethod
(
method
,
args
);
}
public
void
invokeChannelUnsafe
(
String
pageName
,
Map
params
,
String
uniqueId
)
{
public
void
invokeChannelUnsafe
(
String
method
,
String
url
,
Map
params
,
String
uniqueId
)
{
HashMap
<
String
,
Object
>
args
=
new
HashMap
<>();
args
.
put
(
"pageName"
,
pageName
);
args
.
put
(
"pageName"
,
url
);
args
.
put
(
"params"
,
params
);
args
.
put
(
"uniqueId"
,
uniqueId
);
FlutterBoostPlugin
.
singleton
().
channel
().
invokeMethodUnsafe
(
"didInitPageContainer"
,
args
);
FlutterBoostPlugin
.
singleton
().
channel
().
invokeMethodUnsafe
(
method
,
args
);
}
}
}
android/src/main/java/com/taobao/idlefish/flutterboost/Utils.java
View file @
94f01e51
...
...
@@ -26,6 +26,12 @@ package com.taobao.idlefish.flutterboost;
import
android.graphics.Bitmap
;
import
android.graphics.Color
;
import
android.os.Looper
;
import
android.util.Log
;
import
java.io.File
;
import
java.io.FileNotFoundException
;
import
java.io.FileOutputStream
;
import
java.io.IOException
;
public
class
Utils
{
...
...
@@ -35,6 +41,29 @@ public class Utils {
}
}
public
static
void
saveBitmap
(
Bitmap
bm
,
String
filePath
)
{
File
f
=
new
File
(
filePath
);
try
{
if
(!
f
.
exists
())
{
if
(!
f
.
getParentFile
().
exists
()
&&
!
f
.
getParentFile
().
mkdirs
())
{
throw
new
Exception
(
"mkdir except"
);
}
if
(!
f
.
createNewFile
()){
throw
new
Exception
(
"createNewFile except"
);
}
}
FileOutputStream
out
=
new
FileOutputStream
(
f
);
bm
.
compress
(
Bitmap
.
CompressFormat
.
PNG
,
100
,
out
);
out
.
flush
();
out
.
close
();
}
catch
(
Throwable
t
){
throw
new
RuntimeException
(
t
);
}
}
public
static
boolean
checkImageValid
(
final
Bitmap
bitmap
)
{
if
(
null
==
bitmap
)
{
return
false
;
...
...
android/src/main/java/com/taobao/idlefish/flutterboost/containers/BoostFlutterActivity.java
View file @
94f01e51
...
...
@@ -105,7 +105,7 @@ public abstract class BoostFlutterActivity extends Activity implements IFlutterV
BoostFlutterView
.
Builder
builder
=
new
BoostFlutterView
.
Builder
(
this
);
return
builder
.
flutterEngine
(
engine
)
.
renderMode
(
FlutterView
.
RenderMode
.
textur
e
)
.
renderMode
(
FlutterView
.
RenderMode
.
surfac
e
)
.
transparencyMode
(
isBackgroundTransparent
()
?
FlutterView
.
TransparencyMode
.
transparent
:
FlutterView
.
TransparencyMode
.
opaque
)
...
...
example/android/app/build.gradle
View file @
94f01e51
...
...
@@ -25,7 +25,7 @@ apply plugin: 'com.android.application'
apply
from:
"$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android
{
compileSdkVersion
2
7
compileSdkVersion
2
6
lintOptions
{
disable
'InvalidPackage'
...
...
@@ -35,7 +35,7 @@ android {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId
"com.taobao.idlefish.flutterboostexample"
minSdkVersion
16
targetSdkVersion
2
7
targetSdkVersion
2
6
versionCode
flutterVersionCode
.
toInteger
()
versionName
flutterVersionName
testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
...
...
@@ -58,6 +58,6 @@ dependencies {
testImplementation
'junit:junit:4.12'
androidTestImplementation
'com.android.support.test:runner:1.0.2'
androidTestImplementation
'com.android.support.test.espresso:espresso-core:3.0.2'
implementation
'com.android.support:support-v4:2
7.1.1
'
implementation
'com.android.support:appcompat-v7:2
7.1.1
'
implementation
'com.android.support:support-v4:2
6.1.0
'
implementation
'com.android.support:appcompat-v7:2
6.1.0
'
}
example/android/app/src/main/AndroidManifest.xml
View file @
94f01e51
...
...
@@ -7,6 +7,10 @@
-->
<uses-permission
android:name=
"android.permission.INTERNET"
/>
<uses-permission
android:name=
"android.permission.WRITE_EXTERNAL_STORAGE"
/>
<uses-permission
android:name=
"android.permission.READ_EXTERNAL_STORAGE"
/>
<!-- io.flutter.app.FlutterApplication is an android.app.Application that
calls FlutterMain.startInitialization(this); in its onCreate method.
In most cases you can leave this as-is, but you if you want to provide
...
...
lib/container/container_coordinator.dart
View file @
94f01e51
...
...
@@ -104,6 +104,8 @@ class ContainerCoordinator {
Map
map
=
event
;
final
String
type
=
map
[
'type'
];
Logger
.
log
(
"onEvent
$type
"
);
switch
(
type
)
{
//Handler back key pressed event.
case
'backPressedCallback'
:
...
...
@@ -141,6 +143,8 @@ class ContainerCoordinator {
}
Future
<
dynamic
>
_onMethodCall
(
MethodCall
call
)
{
Logger
.
log
(
"onMetohdCall
${call.method}
"
);
switch
(
call
.
method
)
{
case
"didInitPageContainer"
:
{
...
...
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