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
44dc3fe7
Commit
44dc3fe7
authored
Jan 26, 2019
by
Karthik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
2.2.11
parent
1fd36b3b
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
56 deletions
+39
-56
android/src/main/java/io/github/ponnamkarthik/toast/fluttertoast/FluttertoastPlugin.java
+39
-56
No files found.
android/src/main/java/io/github/ponnamkarthik/toast/fluttertoast/FluttertoastPlugin.java
View file @
44dc3fe7
...
...
@@ -21,10 +21,9 @@ import io.flutter.plugin.common.PluginRegistry.Registrar;
/** FluttertoastPlugin */
public
class
FluttertoastPlugin
implements
MethodCallHandler
{
private
Context
ctx
;
private
Toast
toast
=
null
;
Context
ctx
;
private
FluttertoastPlugin
(
Context
context
)
{
FluttertoastPlugin
(
Context
context
)
{
ctx
=
context
;
}
...
...
@@ -36,23 +35,7 @@ public class FluttertoastPlugin implements MethodCallHandler {
@Override
public
void
onMethodCall
(
MethodCall
call
,
final
Result
result
)
{
switch
(
call
.
method
)
{
case
"showToast"
:
showToast
(
call
,
result
);
break
;
case
"cancel"
:
if
(
toast
!=
null
)
{
toast
.
cancel
();
}
result
.
success
(
true
);
break
;
default
:
result
.
notImplemented
();
break
;
}
}
private
void
showToast
(
MethodCall
call
,
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
();
...
...
@@ -61,7 +44,7 @@ public class FluttertoastPlugin implements MethodCallHandler {
Number
textSize
=
call
.
argument
(
"fontSize"
);
toast
=
Toast
.
makeText
(
ctx
,
msg
,
Toast
.
LENGTH_SHORT
);
final
Toast
toast
=
Toast
.
makeText
(
ctx
,
msg
,
Toast
.
LENGTH_SHORT
);
toast
.
setText
(
msg
);
...
...
@@ -71,21 +54,20 @@ public class FluttertoastPlugin implements MethodCallHandler {
toast
.
setDuration
(
Toast
.
LENGTH_SHORT
);
}
// later
// Boolean sent = false;
// final Handler handler = new Handler();
// final Runnable run = new Runnable() {
//
// @Override
// public void run() {
// try {
// result.success(false);
//
// } catch (Exception e){
// e.printStackTrace();
// }
// }
// };
Boolean
sent
=
false
;
final
Handler
handler
=
new
Handler
();
final
Runnable
run
=
new
Runnable
()
{
@Override
public
void
run
()
{
try
{
result
.
success
(
false
);
}
catch
(
Exception
e
){
e
.
printStackTrace
();
}
}
};
switch
(
gravity
)
{
...
...
@@ -101,6 +83,7 @@ public class FluttertoastPlugin implements MethodCallHandler {
final
TextView
text
=
toast
.
getView
().
findViewById
(
android
.
R
.
id
.
message
);
text
.
setTextSize
(
textSize
.
floatValue
());
text
.
setMaxLines
(
1
);
if
(
bgcolor
!=
null
)
{
...
...
@@ -116,31 +99,31 @@ public class FluttertoastPlugin implements MethodCallHandler {
}
}
//later
// text.setOnTouchListener(new View.OnTouchListener() {
// @Override
// public boolean onTouch(View v, MotionEvent event) {
// handler.removeCallbacks(run);
// text.setOnTouchListener(null);
// toast.cancel();
// try {
//
// result.success(true);
//
// } catch (Exception e){
// e.printStackTrace();
// }
//
// return false;
// }
// });
text
.
setOnTouchListener
(
new
View
.
OnTouchListener
()
{
@Override
public
boolean
onTouch
(
View
v
,
MotionEvent
event
)
{
handler
.
removeCallbacks
(
run
);
text
.
setOnTouchListener
(
null
);
toast
.
cancel
();
try
{
result
.
success
(
true
);
}
catch
(
Exception
e
){
e
.
printStackTrace
();
}
return
false
;
}
});
if
(
textcolor
!=
null
)
{
text
.
setTextColor
(
textcolor
.
intValue
());
}
toast
.
show
();
result
.
success
(
true
);
// handler.postDelayed(run,toast.getDuration()*1000);
handler
.
postDelayed
(
run
,
toast
.
getDuration
()*
1000
);
}
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