-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
151 additions
and
22 deletions.
There are no files selected for viewing
22 changes: 3 additions & 19 deletions
22
app/src/main/java/com/joey/xwebassistant/sample/JavaMethod/JSToast.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,19 @@ | ||
package com.joey.xwebassistant.sample.JavaMethod; | ||
|
||
import android.content.Context; | ||
import android.widget.Toast; | ||
|
||
import com.joey.xwebview.jsbridge.method.JSMessage; | ||
import com.joey.xwebview.jsbridge.method.XJavaMethod; | ||
|
||
/** | ||
* Description: | ||
* author:Joey | ||
* date:2018/8/20 | ||
* date:2018/8/21 | ||
*/ | ||
public class JSToast extends XJavaMethod{ | ||
private Context context; | ||
public abstract class JSToast extends XJavaMethod{ | ||
protected Context context; | ||
|
||
public void setContext(Context context) { | ||
this.context = context; | ||
} | ||
|
||
@Override | ||
public void call(JSMessage message) { | ||
if (context != null){ | ||
Toast.makeText(context, message.params.optString("message"), Toast.LENGTH_SHORT).show(); | ||
callback(message.callback, "call JSToast success"); | ||
} else { | ||
callError(message.errorCallback, "call JSToast failed! context is null!"); | ||
} | ||
} | ||
|
||
@Override | ||
public Permission permission() { | ||
return Permission.PUBLIC; | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
app/src/main/java/com/joey/xwebassistant/sample/JavaMethod/JSToastAuthorized.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.joey.xwebassistant.sample.JavaMethod; | ||
|
||
import android.widget.Toast; | ||
|
||
import com.joey.xwebview.jsbridge.method.JSMessage; | ||
|
||
/** | ||
* Description: | ||
* author:Joey | ||
* date:2018/8/20 | ||
*/ | ||
public class JSToastAuthorized extends JSToast{ | ||
|
||
@Override | ||
public void call(JSMessage message) { | ||
if (context != null){ | ||
Toast.makeText(context, message.params.optString("message"), Toast.LENGTH_SHORT).show(); | ||
callback(message.callback, "call JSToastAuthorized success"); | ||
} else { | ||
callError(message.errorCallback, "call JSToastAuthorized failed! context is null!"); | ||
} | ||
} | ||
|
||
@Override | ||
public Permission permission() { | ||
return Permission.PUBLIC; | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
app/src/main/java/com/joey/xwebassistant/sample/JavaMethod/JSToastPrivate.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.joey.xwebassistant.sample.JavaMethod; | ||
|
||
import android.widget.Toast; | ||
|
||
import com.joey.xwebview.jsbridge.method.JSMessage; | ||
|
||
/** | ||
* Description: | ||
* author:Joey | ||
* date:2018/8/20 | ||
*/ | ||
public class JSToastPrivate extends JSToast{ | ||
@Override | ||
public void call(JSMessage message) { | ||
if (context != null){ | ||
Toast.makeText(context, message.params.optString("message"), Toast.LENGTH_SHORT).show(); | ||
callback(message.callback, "call JSToastPrivate success"); | ||
} else { | ||
callError(message.errorCallback, "call JSToastPrivate failed! context is null!"); | ||
} | ||
} | ||
|
||
@Override | ||
public Permission permission() { | ||
return Permission.PRIVATE; | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
app/src/main/java/com/joey/xwebassistant/sample/JavaMethod/JSToastPublic.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.joey.xwebassistant.sample.JavaMethod; | ||
|
||
import android.widget.Toast; | ||
|
||
import com.joey.xwebview.jsbridge.method.JSMessage; | ||
|
||
/** | ||
* Description: | ||
* author:Joey | ||
* date:2018/8/20 | ||
*/ | ||
public class JSToastPublic extends JSToast{ | ||
@Override | ||
public void call(JSMessage message) { | ||
if (context != null){ | ||
Toast.makeText(context, message.params.optString("message"), Toast.LENGTH_SHORT).show(); | ||
callback(message.callback, "call JSToastPublic success"); | ||
} else { | ||
callError(message.errorCallback, "call JSToastPublic failed! context is null!"); | ||
} | ||
} | ||
|
||
@Override | ||
public Permission permission() { | ||
return Permission.PUBLIC; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters