Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
fluttertoast
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
songyanzhi
fluttertoast
Commits
9de5a8f8
Commit
9de5a8f8
authored
Jan 18, 2019
by
Zac Chan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Attempting Android fix
parent
730145ee
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
50 additions
and
4 deletions
+50
-4
android/src/main/java/io/github/ponnamkarthik/toast/fluttertoast/FluttertoastPlugin.java
+50
-4
No files found.
android/src/main/java/io/github/ponnamkarthik/toast/fluttertoast/FluttertoastPlugin.java
View file @
9de5a8f8
...
...
@@ -4,7 +4,10 @@ import android.content.Context;
import
android.graphics.PorterDuff
;
import
android.graphics.drawable.Drawable
;
import
android.os.Build
;
import
android.os.Handler
;
import
android.view.Gravity
;
import
android.view.MotionEvent
;
import
android.view.View
;
import
android.widget.TextView
;
import
android.widget.Toast
;
...
...
@@ -31,16 +34,19 @@ public class FluttertoastPlugin implements MethodCallHandler {
}
@Override
public
void
onMethodCall
(
MethodCall
call
,
Result
result
)
{
public
void
onMethodCall
(
MethodCall
call
,
final
Result
result
)
{
if
(
call
.
method
.
equals
(
"showToast"
))
{
String
msg
=
call
.
argument
(
"msg"
).
toString
();
String
length
=
call
.
argument
(
"length"
).
toString
();
String
gravity
=
call
.
argument
(
"gravity"
).
toString
();
Number
bgcolor
=
call
.
argument
(
"bgcolor"
);
Number
textcolor
=
call
.
argument
(
"textcolor"
);
Number
textSize
=
call
.
argument
(
"fontSize"
);
final
Toast
toast
=
Toast
.
makeText
(
ctx
,
msg
,
Toast
.
LENGTH_SHORT
);
Toast
toast
=
Toast
.
makeText
(
ctx
,
msg
,
Toast
.
LENGTH_SHORT
);
toast
.
setText
(
msg
);
...
...
@@ -50,6 +56,16 @@ public class FluttertoastPlugin implements MethodCallHandler {
toast
.
setDuration
(
Toast
.
LENGTH_SHORT
);
}
final
Handler
handler
=
new
Handler
();
final
Runnable
run
=
new
Runnable
()
{
@Override
public
void
run
()
{
result
.
success
(
false
);
}
};
switch
(
gravity
)
{
case
"top"
:
toast
.
setGravity
(
Gravity
.
TOP
,
0
,
100
);
...
...
@@ -62,8 +78,11 @@ public class FluttertoastPlugin implements MethodCallHandler {
}
TextView
text
=
toast
.
getView
().
findViewById
(
android
.
R
.
id
.
message
);
text
.
setTextSize
(
textSize
.
floatValue
());
final
View
toastView
=
toast
.
getView
();
if
(
bgcolor
!=
null
)
{
if
(
bgcolor
!=
null
)
{
Drawable
shapeDrawable
=
ContextCompat
.
getDrawable
(
ctx
,
R
.
drawable
.
toast_bg
);
if
(
shapeDrawable
!=
null
)
{
...
...
@@ -77,13 +96,40 @@ public class FluttertoastPlugin implements MethodCallHandler {
}
toastView
.
setOnTouchListener
(
new
View
.
OnTouchListener
()
{
@Override
public
boolean
onTouch
(
View
v
,
MotionEvent
event
)
{
result
.
success
(
true
);
handler
.
removeCallbacks
(
run
);
return
false
;
}
});
if
(
textcolor
!=
null
)
{
text
.
setTextColor
(
textcolor
.
intValue
());
}
// Thread thread = new Thread(){
// @Override
// public void run(){
// try {
// Thread.sleep(toast.getDuration());
// } catch (Exception e) {
// e.printStackTrace();
// }
//
// result
//
// }
// };
toast
.
show
();
handler
.
postDelayed
(
run
,
toast
.
getDuration
()*
1000
);
// thread.run();
result
.
success
(
"Success"
);
//
result.success("Success");
}
else
{
result
.
notImplemented
();
...
...
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