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;
...
@@ -21,10 +21,9 @@ import io.flutter.plugin.common.PluginRegistry.Registrar;
/** FluttertoastPlugin */
/** FluttertoastPlugin */
public
class
FluttertoastPlugin
implements
MethodCallHandler
{
public
class
FluttertoastPlugin
implements
MethodCallHandler
{
private
Context
ctx
;
Context
ctx
;
private
Toast
toast
=
null
;
private
FluttertoastPlugin
(
Context
context
)
{
FluttertoastPlugin
(
Context
context
)
{
ctx
=
context
;
ctx
=
context
;
}
}
...
@@ -36,23 +35,7 @@ public class FluttertoastPlugin implements MethodCallHandler {
...
@@ -36,23 +35,7 @@ public class FluttertoastPlugin implements MethodCallHandler {
@Override
@Override
public
void
onMethodCall
(
MethodCall
call
,
final
Result
result
)
{
public
void
onMethodCall
(
MethodCall
call
,
final
Result
result
)
{
switch
(
call
.
method
)
{
if
(
call
.
method
.
equals
(
"showToast"
))
{
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
)
{
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
();
...
@@ -61,7 +44,7 @@ public class FluttertoastPlugin implements MethodCallHandler {
...
@@ -61,7 +44,7 @@ public class FluttertoastPlugin implements MethodCallHandler {
Number
textSize
=
call
.
argument
(
"fontSize"
);
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
);
toast
.
setText
(
msg
);
...
@@ -71,21 +54,20 @@ public class FluttertoastPlugin implements MethodCallHandler {
...
@@ -71,21 +54,20 @@ public class FluttertoastPlugin implements MethodCallHandler {
toast
.
setDuration
(
Toast
.
LENGTH_SHORT
);
toast
.
setDuration
(
Toast
.
LENGTH_SHORT
);
}
}
// later
Boolean
sent
=
false
;
// Boolean sent = false;
final
Handler
handler
=
new
Handler
();
// final Handler handler = new Handler();
final
Runnable
run
=
new
Runnable
()
{
// final Runnable run = new Runnable() {
//
@Override
// @Override
public
void
run
()
{
// public void run() {
try
{
// try {
result
.
success
(
false
);
// result.success(false);
//
}
catch
(
Exception
e
){
// } catch (Exception e){
e
.
printStackTrace
();
// e.printStackTrace();
}
// }
}
// }
};
// };
switch
(
gravity
)
{
switch
(
gravity
)
{
...
@@ -101,6 +83,7 @@ public class FluttertoastPlugin implements MethodCallHandler {
...
@@ -101,6 +83,7 @@ public class FluttertoastPlugin implements MethodCallHandler {
final
TextView
text
=
toast
.
getView
().
findViewById
(
android
.
R
.
id
.
message
);
final
TextView
text
=
toast
.
getView
().
findViewById
(
android
.
R
.
id
.
message
);
text
.
setTextSize
(
textSize
.
floatValue
());
text
.
setTextSize
(
textSize
.
floatValue
());
text
.
setMaxLines
(
1
);
if
(
bgcolor
!=
null
)
{
if
(
bgcolor
!=
null
)
{
...
@@ -116,31 +99,31 @@ public class FluttertoastPlugin implements MethodCallHandler {
...
@@ -116,31 +99,31 @@ public class FluttertoastPlugin implements MethodCallHandler {
}
}
}
}
//later
text
.
setOnTouchListener
(
new
View
.
OnTouchListener
()
{
// text.setOnTouchListener(new View.OnTouchListener() {
@Override
// @Override
public
boolean
onTouch
(
View
v
,
MotionEvent
event
)
{
// public boolean onTouch(View v, MotionEvent event) {
handler
.
removeCallbacks
(
run
);
// handler.removeCallbacks(run);
text
.
setOnTouchListener
(
null
);
// text.setOnTouchListener(null);
toast
.
cancel
();
// toast.cancel();
try
{
// try {
result
.
success
(
true
);
//
}
catch
(
Exception
e
){
// result.success(true);
e
.
printStackTrace
();
//
}
// } catch (Exception e){
// e.printStackTrace();
return
false
;
// }
}
//
});
// return false;
// }
// });
if
(
textcolor
!=
null
)
{
if
(
textcolor
!=
null
)
{
text
.
setTextColor
(
textcolor
.
intValue
());
text
.
setTextColor
(
textcolor
.
intValue
());
}
}
toast
.
show
();
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