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
aa4dd550
Commit
aa4dd550
authored
Dec 02, 2018
by
Ben Getsug
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updating android plugin to reflect changes made in dart
parent
eb80de17
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
51 additions
and
53 deletions
+51
-53
android/src/main/java/io/github/ponnamkarthik/toast/fluttertoast/FluttertoastPlugin.java
+51
-53
No files found.
android/src/main/java/io/github/ponnamkarthik/toast/fluttertoast/FluttertoastPlugin.java
View file @
aa4dd550
...
@@ -37,64 +37,62 @@ public class FluttertoastPlugin implements MethodCallHandler {
...
@@ -37,64 +37,62 @@ public class FluttertoastPlugin implements MethodCallHandler {
String
msg
=
call
.
argument
(
"msg"
).
toString
();
String
msg
=
call
.
argument
(
"msg"
).
toString
();
String
length
=
call
.
argument
(
"length"
).
toString
();
String
length
=
call
.
argument
(
"length"
).
toString
();
String
gravity
=
call
.
argument
(
"gravity"
).
toString
();
String
gravity
=
call
.
argument
(
"gravity"
).
toString
();
Integer
bgcolor
=
call
.
argument
(
"bgcolor"
);
Long
bgcolor
=
call
.
argument
(
"bgcolor"
);
Integer
textcolor
=
call
.
argument
(
"textcolor"
);
Long
textcolor
=
call
.
argument
(
"textcolor"
);
Toast
toast
=
Toast
.
makeText
(
ctx
,
msg
,
Toast
.
LENGTH_SHORT
);
Toast
toast
=
Toast
.
makeText
(
ctx
,
msg
,
Toast
.
LENGTH_SHORT
);
toast
.
setText
(
msg
);
if
(
length
.
equals
(
"long"
))
{
toast
.
setDuration
(
Toast
.
LENGTH_LONG
);
}
else
{
toast
.
setDuration
(
Toast
.
LENGTH_SHORT
);
}
switch
(
gravity
)
{
toast
.
setText
(
msg
);
case
"top"
:
toast
.
setGravity
(
Gravity
.
TOP
,
0
,
100
);
if
(
length
.
equals
(
"long"
))
{
break
;
toast
.
setDuration
(
Toast
.
LENGTH_LONG
);
case
"center"
:
}
else
{
toast
.
setGravity
(
Gravity
.
CENTER
,
0
,
0
);
toast
.
setDuration
(
Toast
.
LENGTH_SHORT
);
break
;
}
default
:
toast
.
setGravity
(
Gravity
.
BOTTOM
,
0
,
100
);
}
switch
(
gravity
)
{
TextView
text
=
toast
.
getView
().
findViewById
(
android
.
R
.
id
.
message
);
case
"top"
:
if
(
defaultTextColor
==
0
)
{
toast
.
setGravity
(
Gravity
.
TOP
,
0
,
100
);
defaultTextColor
=
text
.
getCurrentTextColor
();
break
;
}
case
"center"
:
if
(!
bgcolor
.
equals
(
"null"
))
{
toast
.
setGravity
(
Gravity
.
CENTER
,
0
,
0
);
break
;
try
{
default
:
toast
.
setGravity
(
Gravity
.
BOTTOM
,
0
,
100
);
RoundRectShape
rectShape
=
new
RoundRectShape
(
new
float
[]
{
100
f
,
100
f
,
100
f
,
100
f
,
100
f
,
100
f
,
100
f
,
100
f
},
null
,
null
);
ShapeDrawable
shapeDrawable
=
new
ShapeDrawable
(
rectShape
);
shapeDrawable
.
getPaint
().
setColor
(
bgcolor
);
shapeDrawable
.
getPaint
().
setStyle
(
Paint
.
Style
.
FILL
);
shapeDrawable
.
getPaint
().
setAntiAlias
(
true
);
shapeDrawable
.
getPaint
().
setFlags
(
Paint
.
ANTI_ALIAS_FLAG
);
if
(
android
.
os
.
Build
.
VERSION
.
SDK_INT
<=
27
)
{
toast
.
getView
().
setBackground
(
shapeDrawable
);
}
else
{
text
.
setBackground
(
shapeDrawable
);
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
if
(!
textcolor
.
equals
(
"null"
))
{
try
{
text
.
setTextColor
(
textcolor
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
else
{
text
.
setTextColor
(
defaultTextColor
);
}
}
toast
.
show
();
TextView
text
=
toast
.
getView
().
findViewById
(
android
.
R
.
id
.
message
);
if
(
defaultTextColor
==
0
)
{
defaultTextColor
=
text
.
getCurrentTextColor
();
}
try
{
RoundRectShape
rectShape
=
new
RoundRectShape
(
new
float
[]
{
100
f
,
100
f
,
100
f
,
100
f
,
100
f
,
100
f
,
100
f
,
100
f
},
null
,
null
);
ShapeDrawable
shapeDrawable
=
new
ShapeDrawable
(
rectShape
);
shapeDrawable
.
getPaint
().
setColor
(
bgcolor
!=
null
?
bgcolor
.
intValue
()
:
Color
.
BLACK
);
shapeDrawable
.
getPaint
().
setStyle
(
Paint
.
Style
.
FILL
);
shapeDrawable
.
getPaint
().
setAntiAlias
(
true
);
shapeDrawable
.
getPaint
().
setFlags
(
Paint
.
ANTI_ALIAS_FLAG
);
if
(
android
.
os
.
Build
.
VERSION
.
SDK_INT
<=
27
)
{
toast
.
getView
().
setBackground
(
shapeDrawable
);
}
else
{
text
.
setBackground
(
shapeDrawable
);
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
try
{
text
.
setTextColor
(
textcolor
!=
null
?
textcolor
.
intValue
()
:
defaultTextColor
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
toast
.
show
();
result
.
success
(
"Success"
);
result
.
success
(
"Success"
);
...
...
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