Titanium JIRA Archive
Appcelerator Community (AC)

[AC-2051] alloy/measurement pxToDP returns the same value on Android

GitHub Issuen/a
TypeBug
Priorityn/a
StatusClosed
ResolutionInvalid
Resolution Date2014-02-03T17:34:11.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsAlloy, Appcelerator Modules
Labelsalloy, android, builtins, measurement, regression
ReporterEmanuele Salamone
AssigneeShak Hossain
Created2014-02-03T10:28:49.000+0000
Updated2016-03-08T07:41:00.000+0000

Description

Using the function pxToDP on Titanium.Platform.displayCaps.platformWidth, on an Android Galaxy Nexus should return 360 (in dp). Instead it's returning 720, that is the original pixel value. I used the same module on previous Alloy versions and it worked.

Comments

  1. Manuel Lehner 2014-02-03

    Can't reproduce. I've just tested this on my Nexus 5 with this code (same environment):
       var measurement = require('alloy/measurement');
       Ti.API.info('dpWidth: ' + measurement.pxToDP(Ti.Platform.displayCaps.platformWidth));
       
    It returned 360 as expected.
  2. Emanuele Salamone 2014-02-03

    You're right, your code returns the expected result even to me (i made a new test project to test it). However, the usage inside my project returns the wrong result, and i'm not doing much more. I'll try to isolate the bug and be more detailed.
  3. Emanuele Salamone 2014-02-03

    Nope, can't manage to understand what's happening. The same code that's working on the test project doesn't work when copied on my real project index.js. Additional info: i recently switched from Titanium 3.1.3 to Titanium 3.2.0, and it worked before. I don't know if this switch can somehow interfere with paths or other things.
  4. Emanuele Salamone 2014-02-03

    Last comment: i copied my WHOLE project inside the test project folder. I compiled and then it worked, so i guess my project was somehow in a "dirty" state. Sorry for the false issue! Thanks for your help!
  5. Ritu Agrawal 2014-02-03

    Closing on the basis of last comment by the reporter.
  6. Guile 2014-03-20

    I've just had the same problem (a 3.1 project migrated to 3.2) and I found a nicer solution : Remove the "Resources" directory, and recompile it, it solves the problem for me.
  7. Guile 2014-03-20

    I've just had the same problem (a 3.1 project migrated to 3.2) and I found a nicer solution : Remove the "Resources" directory, and recompile it, it solves the problem for me (Clean project doesn't solve it!)
  8. Manuel Lehner 2015-07-03

    Just faced this issue too! Strange thing. Suggested solution solved it for me too

JSON Source