return false;
}
- NScreenModel targetModel = getNScreenModel(model.getName());
- if (targetModel != null) {
- removeNScreenModel(targetModel);
+ int targetIndex = getNScreenModelIndex(model.getName());
+ if (targetIndex == -1) {
+ return addNScreenModel(model);
}
- return addNScreenModel(model);
+
+ nscreenDatas.set(targetIndex, model);
+ return true;
}
public List<NScreenModel> getNScreenModels() {
return model;
}
+ public int getNScreenModelIndex(String nscreenName) {
+ if (nscreenName == null) {
+ return -1;
+ }
+
+ if (nscreenName.isEmpty()) {
+ return -1;
+ }
+
+ if (nscreenDatas.size() == 0) {
+ return -1;
+ }
+
+ int index = -1;
+ for (int i = 0; i < nscreenDatas.size(); i++) {
+ if (nscreenName.equalsIgnoreCase(nscreenDatas.get(i).getName())) {
+ index = i;
+ break;
+ }
+ }
+
+ return index;
+ }
+
public NScreenModel getCommonNscreen() {
if (nscreenDatas.size() == 0) {
return createCommonNscreen();
import org.tizen.webuibuilder.model.nscreen.NScreenModel.Orientation;
import org.tizen.webuibuilder.model.page.PageData;
import org.tizen.webuibuilder.model.page.PageDataSet;
-import org.tizen.webuibuilder.model.project.ProjectManager;
public class NScreenDescriptor {
Logger logger = LoggerFactory.getLogger(NScreenDescriptor.class);
- private ProjectManager projectManger = null;
private AppManager appManager = null;
private List<NScreenModel> list = null;
if (appManager != null) {
this.appManager = appManager;
this.list = this.appManager.getNScreenModelManger().getNScreenModels();
- this.projectManger = this.appManager.getProjectManager();
} else {
logger.info("NScreen Descriptor is null");
}
}
public void load() {
- String platform = projectManger.getPlatform();
-
createCommonNscreen();
// createOrientationNscreen();
// createPixelRatioNscreen();
- createDeviceNscreen(platform);
+ createDeviceNscreen();
setPagesForNscreenData();
}
addNscreenModel("Pixel Ratio 3.0", NScreenType.PIXELRATIO, null, 3.0, 0, 0);
}
- public void createDeviceNscreen(String platform) {
- if (platform == null) {
- logger.info("Platform is null");
- return;
- }
-
- if (platform.contains(BuilderConstants.PROFILE_WEARABLE)) {
- addNscreenModel("320x320 (1:1)", NScreenType.RESOLUTION, null, 0, 320, 320);
- addNscreenModel("360x480 (3:4)", NScreenType.RESOLUTION, null, 0, 360, 480);
- addNscreenModel("480x360 (4:3)", NScreenType.RESOLUTION, null, 0, 480, 360);
-
- } else if (platform.contains(BuilderConstants.PROFILE_MOBILE)) {
- addNscreenModel("360x640 (9:16)", NScreenType.RESOLUTION, null, 0, 720, 1280);
- addNscreenModel("640x360 (16:9)", NScreenType.RESOLUTION, null, 0, 1280, 720);
- addNscreenModel("800x1280 (10:16)", NScreenType.RESOLUTION, null, 0, 800, 1280);
- addNscreenModel("1280x800 (16:10)", NScreenType.RESOLUTION, null, 0, 1280, 800);
-
- } else {
- logger.info("Not support profile :" + platform);
- }
+ public void createDeviceNscreen() {
+ addNscreenModel("320x320 (1:1)", NScreenType.RESOLUTION, null, 0, 320, 320);
+ addNscreenModel("360x480 (3:4)", NScreenType.RESOLUTION, null, 0, 360, 480);
+ addNscreenModel("480x360 (4:3)", NScreenType.RESOLUTION, null, 0, 480, 360);
+ addNscreenModel("360x640 (9:16)", NScreenType.RESOLUTION, null, 0, 720, 1280);
+ addNscreenModel("640x360 (16:9)", NScreenType.RESOLUTION, null, 0, 1280, 720);
+ addNscreenModel("800x1280 (10:16)", NScreenType.RESOLUTION, null, 0, 800, 1280);
+ addNscreenModel("1280x800 (16:10)", NScreenType.RESOLUTION, null, 0, 1280, 800);
}
public void addNscreenModel(String name, NScreenType type, Orientation orientation,