How to set Screen Size Qualifiers typescript & angluar2 in nativescript - angular2-nativescript

I'm currently developing nativescript app using typescript & angluar2.
I'm going to change layout between tablet and phone.
But there was not support multiple screensize qualifiers in typescript & angluar2.
So I'm try to use nativescript-platfrom-css plugin.
tns plugin add nativescript-platform-css
But it doesn't work with my project.
There are some code in my project as follows.
///directory structure///
... ...
pages/login.html/
pages/login.component.ts/
pages/login.common.css/
... ...
////main.ts///
... ...
import nativescriptPlatfromCss = require('nativescript-platform-css');
... ...
//////login.ts////////
#Component({
selector: "login",
providers:[UserService],
templateUrl:"pages/login/login.html" ,
styleUrls:["pages/login/login-common.css", "pages/login/login.css"]
})
... ...
/////login.html
<StackLayout #container>
<TextField class="inputEmail" hint="Email Address"></TextField>
... ...
</StackLayout>
////login.common.css
.inputEmail {
backgournd-color:'white';
}
.android600 .inputEmail{
background-color:'red';
}
.android720 .inputEmail{
background-color:'blue';
}
... ...
I've already seen https://www.nativescript.org/blog/supporting-multiple-screen-resolutions-in-your-nativescript-app and https://github.com/nathanaela/nativescript-platform-css.
But I could not get my goal.
If you know the best way that implement multiple screensize in typescript & angluar2 app, please let me know it.
thanks

const isTablet: boolean = device.deviceType == DeviceType.Tablet;
#Component({
styleUrls: ['default.css', (isTablet ? 'tablet.css' : 'phone.css')]
})
- https://github.com/NativeScript/nativescript-angular/issues/404
"EddyVerbruggen Comment".
Also can include the platform detection like so it is helpfull for creating css depending on device and width or height.
import platformModule = require("platform");
console.log("Device model: " + platformModule.device.model);
console.log("Device type: " + platformModule.device.deviceType);
console.log("OS: " + platformModule.device.os);
console.log("OS version: " + platformModule.device.osVersion);
console.log("SDK Version: " + platformModule.device.sdkVersion);
console.log("Screen width: " + platformModule.screen.mainScreen.widthPixels);
console.log("Screen height: " + platformModule.screen.mainScreen.heightPixels);
console.log("Screen scale: " + platformModule.screen.mainScreen.scale);

Related

Rest Assured cannot be resolved to a variable

I have created a java project and am getting the error in my console
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
RestAssured cannot be resolved to a variable
added jar- rest-assured-4.3.3-dist.zip- all extracted
from official website- https://github.com/rest-assured/rest-assured/wiki/Downloads
here is my code-
//java class basics
import io.restassured.RestAssured;
import static io.restassured.RestAssured.*;
public class Basics {
public static void main(String[] args) {
//adding given, when , then conditions
RestAssured.baseURI = "https://rahulshettyacademy.com"; //added the base URI here
//adding given condition here with log report
given().log().all().queryParam("key", "qaclick123").header("Content-Type", "application/json")
.body("{\r\n" +
" \"location\": {\r\n" +
" \"lat\": -38.383494,\r\n" +
" \"lng\": 33.427362\r\n" +
" },\r\n" +
" \"accuracy\": 50,\r\n" +
" \"name\": \" Muzammil house\",\r\n" +
" \"phone_number\": \"(+91) 983 893 3937\",\r\n" +
" \"address\": \"29, side layout, cohen 09\",\r\n" +
" \"types\": [\r\n" +
" \"shoe park\",\r\n" +
" \"shop\"\r\n" +
" ],\r\n" +
" \"website\": \"http://google.com\",\r\n" +
" \"language\": \"French-IN\"\r\n" +`enter code here`
"}") // end of body
.when().post("maps/api/place/add/json") // added the resource here
.then().log().all().assertThat().statusCode(200); // validating response here
}
}
How do I resolve this?
I assume that you are using maven. If that is the case you need to remove
<scope> test </scope>
node form your rest assured dependency in pom.xml file. If you are not using maven, then try to set build path and make sure that you added all your .jar files into the project.

Integrating Driverless AI with Anylogic Simulation, MOJO Pipeline error

I am trying to integrate Driverless AI in my Anylogic Simulation project, but am unable to make the mojo pipeline work. I have placed the license.sig file in the same directory as mojo pipeline. The license.sig file I am using has been created using a text file of the license key, hope that is not a problem here. The error I am getting is "Model cannot be resolved"
Below is the code I used to run MOJO:
MojoFrameBuilder fb = stayDurationModel.getInputFrameBuilder();
MojoRowBuilder rb = fb.getMojoRowBuilder();
rb.setString("ORG", ORG);
rb.setString("Org_Product", Org_Product);
rb.setString("Org_Region", Org_Region);
rb.setDate("Due Date", new java.sql.Date(Due_Date.getTime()));
rb.setString("Customer Name", Customer_Name);
rb.setDouble("Invoice Amount", Invoice_Amount);
rb.setString("Bank Account Name", Bank_Account_Name);
fb.addRow(rb);
MojoFrame iframe = fb.toMojoFrame();
MojoFrame oframe = DSOModel.transform(iframe);
// Extract output from frame:
String[] outputArray = oframe.getColumn(0).getDataAsStrings();
double DSO = Double.valueOf(outputArray[0]);
lblPatientTxt.setText("Invoice(\n ORG: " + ORG + ",\n Org_Product: " +
Org_Product + ",\n Due Date " + Due_Date + ",\n Invoice Amount" +
Invoice_Amount + ",\n Customer Name " + Customer_Name + ",\n Bank Account
Name"
+ Bank_Account_Name + ")");
lblBedDays.setText("DSO" + DSO + " days");
stayDurationDS.add(DSO);
return DSO;
Have attached the console error logs and the code. Thanks in advance!
Console Error Message

Google Web Toolkit - XSRF Protected Services : Invalid RPC Token

I've implemented XSRF Protected Services in GWT project. I'm using GWT 2.6.0 release. When I try to load my app in a browser I get a very strange exception as follows:
Uncaught com.google.gwt.user.client.rpc.RpcTokenException: Invalid RPC token (Invalid RpcToken type: expected 'com.google.gwt.user.client.rpc.XsrfToken' but got 'class com.google.gwt.user.client.rpc.XsrfToken')
I've searched my classpath and I only have one XsrfToken class provided by gwt-servlet.jar located inside my WAR file. I downloaded 2.6 code from GIT and I see the code that is throwing the exception is provided by ProxyCreator.java in the method generateCheckRpcTokenTypeOverride.
Does anyone have any idea as to why this exception would be thrown. The error indicates to me at least that it should pass given that what is expected is what it has.
I'm pasting the method in for completeness:
protected void generateCheckRpcTokenTypeOverride(SourceWriter srcWriter, TypeOracle typeOracle,
SerializableTypeOracle typesSentFromBrowser) {
JClassType rpcTokenType = typeOracle.findType(RpcToken.class.getName());
JClassType[] rpcTokenSubtypes = rpcTokenType.getSubtypes();
String rpcTokenImplementation = "";
for (JClassType rpcTokenSubtype : rpcTokenSubtypes) {
if (typesSentFromBrowser.isSerializable(rpcTokenSubtype)) {
if (rpcTokenImplementation.length() > 0) {
// >1 implematation of RpcToken, bail
rpcTokenImplementation = "";
break;
} else {
rpcTokenImplementation = rpcTokenSubtype.getQualifiedSourceName();
}
}
}
if (rpcTokenImplementation.length() > 0) {
srcWriter.println("#Override");
srcWriter.println("protected void checkRpcTokenType(RpcToken token) {");
srcWriter.indent();
srcWriter.println("if (!(token instanceof " + rpcTokenImplementation + ")) {");
srcWriter.indent();
srcWriter.println("throw new RpcTokenException(\"Invalid RpcToken type: " + "expected '"
+ rpcTokenImplementation + "' but got '\" + " + "token.getClass() + \"'\");");
srcWriter.outdent();
srcWriter.println("}");
srcWriter.outdent();
srcWriter.println("}");
}
}
Thanks very much in advance.

phonegap 3.1 BarcodeScanner uncaught module cordova/plugin/BarcodeScanner not found

I'm new on Phonegap and JS... and I tried it with a barcode scanner... I installed the phonegap and everything with this tutorial http://teusink.blogspot.com/2013/07/guide-phonegap-3-android-windows.html
I installed the BarcodeScanner from CMD and exported the project as android platform...
Add it to Eclipse ... followed all the tutorials how to do it, added all permissions and stuff..
when i try the app on ma samsung tab2 ... the app comes up but when i click the "scan" link i get the error uncaught module cordova/plugin/BarcodeScanner not found in the logcat.
this is the call <a href="#" class="btn large" onclick="scaning();">Scan</a
i have this in the index html head
<script src="phonegap.js"></script>
<script src="barcodescanner.js"></script>
this is the scaning function
function scaning(){
var scanner = cordova.require("cordova/plugin/BarcodeScanner");
scanner.scan(
function (result) {
alert("We got a barcode\n" +
"Result: " + result.text + "\n" +
"Format: " + result.format + "\n" +
"Cancelled: " + result.cancelled);
},
function (error) {
alert("Scanning failed: " + error);
}
);};
and this is in the config.xml
<feature name="BarcodeScanner">
<param name="android-package" value="com.phonegap.plugins.barcodescanner.BarcodeScanner" />
</feature>
I think I checked the whole Google for the answer ... but till now nothing worked... and still for the phonegap 3.0+ version there is almost none documentation for the barcode scanner ... at least for a beginner ...
if you can help me guys .... couse I'm totally lost :S
Although I've never used older versions as I'm quite new into Phonegap/Cordova, Version 3.1 seems to use a slightly different approach for accessing plugins. Following worked for me with Cordova 3.1 and BarcodeScanner.
Install plugin with
plugman install --platform android --project=DIR-TO-CORDOVA-PROJECT --plugin=https://github.com/wildabeast/BarcodeScanner
You don't have to reference barcodescanner.js by your own, cordova takes care of the includes - the example code from https://github.com/wildabeast/BarcodeDemo worked except I had to change the plugin path from
var scanner = cordova.require("cordova/plugin/BarcodeScanner");
to
var scanner = cordova.require("com.phonegap.plugins.barcodescanner.BarcodeScanner");
edit the file: js/index.js
find the code: var scanner = cordova.require("cordova/plugin/BarcodeScanner");
replace "cordova/plugin/BarcodeScanner"
to "com.phonegap.plugins.barcodescanner.BarcodeScanner"
This one worked for me:
var scanner = cordova.plugins.barcodeScanner;
Had the same problem , got fixed by installing it via plugman like this
plugman install --platform android --project=DIR-TO-CORDOVA-PROJECT --plugin=https://github.com/wildabeast/BarcodeScanner
where DIR-TO-CORDOVA-PROJECT is E:/ProjectName/platform/android
If I didn't add the /platform/android it gave an error
and then put this in the scanning() function
cordova.plugins.barcodeScanner.scan(
function (result) {
alert("We got a barcode\n" +
"Result: " + result.text + "\n" +
"Format: " + result.format + "\n" +
"Cancelled: " + result.cancelled);
},
function (error) {
alert("Scanning failed: " + error);
}
);

GWT and Response Object Problem

OK so this is a very strange problem. I have a servlet running on my machine that returns XML code for use in fusion charts. I know the server is writing the data to to the stream because I have it printing out what it is writing. Which looks like this:
Data: "<chart caption='FusionChart' xAxisName='Month in 1200' yAxisName='Men Killed'>" + "<set label='January' value='10.0' />" + "<set label='February' value='13.0' />" + "<set label='March' value='18.0' />" + "<set label='April' value='12.0' />" + "<set label='May' value='22.0' />" + "<set label='June' value='14.0' />" + "<set label='July' value='18.0' />" + "<set label='August' value='12.0' />" + "<set label='September' value='14.0' />" + "<set label='October' value='10.0' />" + "<set label='November' value='19.0' />" + "<set label='December' value='15.0' />" + "</chart>"
Now heres the strange part when GWT 2.3 gets the data from a response and is shown in an alert window or an HTML widget all it shows is "" + "" + "" + "" + "" + "" + "" + "" and so on. Its like all the XML data was stripped out. Anyone know a reason for that?
Thanks.
How are you adding the returned data to the DOM? If you're treating it as raw HTML (e.g. calling setInnerHtml()) that would explain the behavior that you're seeing. If you inspect the DOM structure with FireBug/WebInspector, do you see a <chart> element?
Depending on the widget that you're using to display the XML, you'll want something like setInnerText().