mirror of
https://github.com/PranshulGG/WeatherMaster.git
synced 2026-10-23 11:33:42 -05:00
1.1.8 updated
This commit is contained in:
1 parent
b78c0acee1
commit
1d9eafc7ad
11 files changed
+437
-150
No files matched your search
@@ -89,6 +89,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
|
||||
AndroidInterface androidInterface = new AndroidInterface(this);
|
||||
webview.addJavascriptInterface(androidInterface, "AndroidInterface");
|
||||
webview.addJavascriptInterface(new ShowToastInterface(this), "ToastAndroidShow");
|
||||
webview.setBackgroundColor(getResources().getColor(R.color.diffDefault));
|
||||
|
||||
|
||||
@@ -181,6 +182,25 @@ public class MainActivity extends AppCompatActivity {
|
||||
}
|
||||
|
||||
|
||||
public class ShowToastInterface {
|
||||
private final Context mContext;
|
||||
|
||||
public ShowToastInterface(Context context) {
|
||||
this.mContext = context;
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public void ShowToast(final String text, final String time) {
|
||||
int duration = Toast.LENGTH_SHORT;
|
||||
if (time.equals("long")) {
|
||||
duration = Toast.LENGTH_LONG;
|
||||
} else if(time.equals("short")){
|
||||
duration = Toast.LENGTH_SHORT;
|
||||
}
|
||||
Toast.makeText(mContext, text, duration).show();
|
||||
}
|
||||
}
|
||||
|
||||
public class AndroidInterface {
|
||||
private MainActivity mActivity;
|
||||
|
||||
|
||||
Reference in new issue
Block a user