Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-18876] TiUIMapView: Not loading at all (Nested fragments)

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionFixed
Resolution Date2015-08-28T01:00:49.000+0000
Affected Version/sRelease 4.0.0
Fix Version/sRelease 5.0.0
ComponentsAndroid
Labelsandroid, drawerlayout, mapview, nested-fragem
ReporterManojkumar Murugesan
AssigneeHieu Pham
Created2015-05-07T13:35:11.000+0000
Updated2015-08-28T01:00:54.000+0000

Description

TIMOB-18244 - Map view as center view for drawer layout works just fine. *But placing map view into a wrapper view and setting the same as center view for drawer layout, never lets the map load.* May be using http://developer.android.com/reference/android/app/Fragment.html#getChildFragmentManager() can fix this. Not sure how :(
var TiDrawerLayout = require('com.tripvi.drawerlayout');
var Map = require("ti.map");
var win = Ti.UI.createWindow({
    backgroundColor : 'white'
});
var drawer = TiDrawerLayout.createDrawer();
var menu = Ti.UI.createTableView({
    data : [{
        title : "Home"
    }, {
        title : "About"
    }]
});
var wrapperView = Ti.UI.createView({
    backgroundColor : 'orange',
});
wrapperView.add(Ti.UI.createLabel({
    top : 10,
    text : "I would like to place a list view or some other compoent here, now map never loads",
    color : "#fff"
}));
var mapview = Map.createView({
    bottom : 0,
    height : "50%",
    fragmentOnly : true //setting this to false crashes the app 
});
wrapperView.add(mapview);
drawer.setLeftView(menu);
drawer.setCenterView(wrapperView);
win.add(drawer);
win.open();

Comments

  1. Hieu Pham 2015-05-07

    This is expected since our add() method do not support the adding of a standalone fragment. We would need to add support for it.
  2. Manojkumar Murugesan 2015-05-07

    [~hpham], Is this something to do with *TiUIView.java - add method*? Is there any work around you could suggest to fix this?
  3. Hieu Pham 2015-05-07

    Yea, that method only supports instances of TiCompositeLayout (ViewGroup) - which is the base of all Titanium views. I'm not aware of any immediate workarounds. We would need to support standalone fragments if you want to add the map fragment to Titanium views.
  4. Manojkumar Murugesan 2015-05-08

    [~hpham], how about supporting [MapView](http://developer.android.com/reference/com/google/android/gms/maps/MapView.html) within *Ti.Map* module. Do you think that will be a fast and easy solution for now?
  5. Hieu Pham 2015-06-04

    Manoj, I dig a little deeper into the module. It seems that your fragment is just a wrapper around the actual view. In that case, why don't you just use TiCompositeLayout? Perhaps something like this: https://github.com/manumaticx/Ti.DrawerLayout/pull/36? With that PR, you don't even need "fragmentOnly" property, since its not using any fragments. The PR should work with maps as well. This is the test case I use:
       var TiDrawerLayout = require("com.tripvi.drawerlayout");
       var Map = require("ti.map");
       var win = Ti.UI.createWindow({
           backgroundColor : 'white'
       });
       var drawer = TiDrawerLayout.createDrawer();
       var menu = Ti.UI.createTableView({
           data : [{
               title : "Home"
           }, {
               title : "About"
           }]
       });
       var wrapperView = Ti.UI.createView({
           backgroundColor : 'orange',
       });
       wrapperView.add(Ti.UI.createLabel({
           top : 10,
           text : "I would like to place a list view or some other compoent here, now map never loads",
           color : "#fff"
       }));
       var mapview = Map.createView({
           bottom : 0,
           height : "50%"
       });
       wrapperView.add(mapview);
       drawer.setLeftView(menu);
       drawer.setCenterView(wrapperView);
       win.add(drawer);
       win.open();
       
  6. Eric Merriman 2015-07-06

    Not sure of what case was intended to be fixed here, so putting results for both: Originally reported case: fails with:
       E/TiApplication( 1540): (main) [140,2964] Sending event: exception on thread: main msg:java.lang.IllegalArgumentException: DrawerLayout must be measured with MeasureSpec.EXACTLY.; Titanium 4.1.0,2015/07/06 11:15,d57aa7d
       E/TiApplication( 1540): java.lang.IllegalArgumentException: DrawerLayout must be measured with MeasureSpec.EXACTLY.
       E/TiApplication( 1540): 	at android.support.v4.widget.DrawerLayout.onMeasure(DrawerLayout.java:831)
       E/TiApplication( 1540): 	at android.view.View.measure(View.java:17430)
       E/TiApplication( 1540): 	at org.appcelerator.titanium.view.TiCompositeLayout.constrainChild(TiCompositeLayout.java:398)
       E/TiApplication( 1540): 	at org.appcelerator.titanium.view.TiCompositeLayout.onMeasure(TiCompositeLayout.java:278)
       E/TiApplication( 1540): 	at android.view.View.measure(View.java:17430)
       E/TiApplication( 1540): 	at org.appcelerator.titanium.view.TiCompositeLayout.constrainChild(TiCompositeLayout.java:398)
       E/TiApplication( 1540): 	at org.appcelerator.titanium.view.TiCompositeLayout.onMeasure(TiCompositeLayout.java:278)
       E/TiApplication( 1540): 	at android.view.View.measure(View.java:17430)
       E/TiApplication( 1540): 	at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5463)
       E/TiApplication( 1540): 	at android.widget.FrameLayout.onMeasure(FrameLayout.java:430)
       E/TiApplication( 1540): 	at android.support.v7.internal.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:124)
       E/TiApplication( 1540): 	at android.view.View.measure(View.java:17430)
       E/TiApplication( 1540): 	at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5463)
       E/TiApplication( 1540): 	at android.support.v7.internal.widget.ActionBarOverlayLayout.onMeasure(ActionBarOverlayLayout.java:444)
       E/TiApplication( 1540): 	at android.view.View.measure(View.java:17430)
       E/TiApplication( 1540): 	at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5463)
       E/TiApplication( 1540): 	at android.widget.FrameLayout.onMeasure(FrameLayout.java:430)
       E/TiApplication( 1540): 	at android.view.View.measure(View.java:17430)
       E/TiApplication( 1540): 	at android.widget.LinearLayout.measureVertical(LinearLayout.java:875)
       E/TiApplication( 1540): 	at android.widget.LinearLayout.onMeasure(LinearLayout.java:613)
       E/TiApplication( 1540): 	at android.view.View.measure(View.java:17430)
       E/TiApplication( 1540): 	at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5463)
       E/TiApplication( 1540): 	at android.widget.FrameLayout.onMeasure(FrameLayout.java:430)
       E/TiApplication( 1540): 	at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2560)
       E/TiApplication( 1540): 	at android.view.View.measure(View.java:17430)
       E/TiApplication( 1540): 	at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2001)
       E/TiApplication( 1540): 	at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1166)
       E/TiApplication( 1540): 	at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1372)
       E/TiApplication( 1540): 	at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1054)
       E/TiApplication( 1540): 	at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5779)
       E/TiApplication( 1540): 	at android.view.Choreographer$CallbackRecord.run(Choreographer.java:767)
       E/TiApplication( 1540): 	at android.view.Choreographer.doCallbacks(Choreographer.java:580)
       E/TiApplication( 1540): 	at android.view.Choreographer.doFrame(Choreographer.java:550)
       E/TiApplication( 1540): 	at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:753)
       E/TiApplication( 1540): 	at android.os.Handler.handleCallback(Handler.java:739)
       E/TiApplication( 1540): 	at android.os.Handler.dispatchMessage(Handler.java:95)
       E/TiApplication( 1540): 	at android.os.Looper.loop(Looper.java:135)
       E/TiApplication( 1540): 	at android.app.ActivityThread.main(ActivityThread.java:5221)
       E/TiApplication( 1540): 	at java.lang.reflect.Method.invoke(Native Method)
       E/TiApplication( 1540): 	at java.lang.reflect.Method.invoke(Method.java:372)
       E/TiApplication( 1540): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
       E/TiApplication( 1540): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
       --------- beginning of crash
       E/AndroidRuntime( 1540): FATAL EXCEPTION: main
       E/AndroidRuntime( 1540): Process: com.appc.timob18876, PID: 1540
       E/AndroidRuntime( 1540): java.lang.IllegalArgumentException: DrawerLayout must be measured with MeasureSpec.EXACTLY.
       E/AndroidRuntime( 1540): 	at android.support.v4.widget.DrawerLayout.onMeasure(DrawerLayout.java:831)
       E/AndroidRuntime( 1540): 	at android.view.View.measure(View.java:17430)
       E/AndroidRuntime( 1540): 	at org.appcelerator.titanium.view.TiCompositeLayout.constrainChild(TiCompositeLayout.java:398)
       E/AndroidRuntime( 1540): 	at org.appcelerator.titanium.view.TiCompositeLayout.onMeasure(TiCompositeLayout.java:278)
       E/AndroidRuntime( 1540): 	at android.view.View.measure(View.java:17430)
       E/AndroidRuntime( 1540): 	at org.appcelerator.titanium.view.TiCompositeLayout.constrainChild(TiCompositeLayout.java:398)
       E/AndroidRuntime( 1540): 	at org.appcelerator.titanium.view.TiCompositeLayout.onMeasure(TiCompositeLayout.java:278)
       E/AndroidRuntime( 1540): 	at android.view.View.measure(View.java:17430)
       E/AndroidRuntime( 1540): 	at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5463)
       E/AndroidRuntime( 1540): 	at android.widget.FrameLayout.onMeasure(FrameLayout.java:430)
       E/AndroidRuntime( 1540): 	at android.support.v7.internal.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:124)
       E/AndroidRuntime( 1540): 	at android.view.View.measure(View.java:17430)
       E/AndroidRuntime( 1540): 	at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5463)
       E/AndroidRuntime( 1540): 	at android.support.v7.internal.widget.ActionBarOverlayLayout.onMeasure(ActionBarOverlayLayout.java:444)
       E/AndroidRuntime( 1540): 	at android.view.View.measure(View.java:17430)
       E/AndroidRuntime( 1540): 	at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5463)
       E/AndroidRuntime( 1540): 	at android.widget.FrameLayout.onMeasure(FrameLayout.java:430)
       E/AndroidRuntime( 1540): 	at android.view.View.measure(View.java:17430)
       E/AndroidRuntime( 1540): 	at android.widget.LinearLayout.measureVertical(LinearLayout.java:875)
       E/AndroidRuntime( 1540): 	at android.widget.LinearLayout.onMeasure(LinearLayout.java:613)
       E/AndroidRuntime( 1540): 	at android.view.View.measure(View.java:17430)
       E/AndroidRuntime( 1540): 	at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5463)
       E/AndroidRuntime( 1540): 	at android.widget.FrameLayout.onMeasure(FrameLayout.java:430)
       E/AndroidRuntime( 1540): 	at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2560)
       E/AndroidRuntime( 1540): 	at android.view.View.measure(View.java:17430)
       E/AndroidRuntime( 1540): 	at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2001)
       E/AndroidRuntime( 1540): 	at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1166)
       E/AndroidRuntime( 1540): 	at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1372)
       E/AndroidRuntime( 1540): 	at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1054)
       E/AndroidRuntime( 1540): 	at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5779)
       E/AndroidRuntime( 1540): 	at android.view.Choreographer$CallbackRecord.run(Choreographer.java:767)
       E/AndroidRuntime( 1540): 	at android.view.Choreographer.doCallbacks(Choreographer.java:580)
       E/AndroidRuntime( 1540): 	at android.view.Choreographer.doFrame(Choreographer.java:550)
       E/AndroidRuntime( 1540): 	at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:753)
       E/AndroidRuntime( 1540): 	at android.os.Handler.handleCallback(Handler.java:739)
       E/AndroidRuntime( 1540): 	at android.os.Handler.dispatchMessage(Handler.java:95)
       E/AndroidRuntime( 1540): 	at android.os.Looper.loop(Looper.java:135)
       E/AndroidRuntime( 1540): 	at android.app.ActivityThread.main(ActivityThread.java:5221)
       E/AndroidRuntime( 1540): 	at java.lang.reflect.Method.invoke(Native Method)
       E/AndroidRuntime( 1540): 	at java.lang.reflect.Method.invoke(Method.java:372)
       E/AndroidRuntime( 1540): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
       E/AndroidRuntime( 1540): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
       
    And Hieu's test case fails with:
       E/TiApplication( 1634): (main) [3106,3106] Sending event: exception on thread: main msg:android.content.res.Resources$NotFoundException: Unable to find resource ID #0x3e8; Titanium 4.1.0,2015/07/06 11:15,d57aa7d
       E/TiApplication( 1634): android.content.res.Resources$NotFoundException: Unable to find resource ID #0x3e8
       E/TiApplication( 1634): 	at android.content.res.Resources.getResourceName(Resources.java:2026)
       E/TiApplication( 1634): 	at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:947)
       E/TiApplication( 1634): 	at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1138)
       E/TiApplication( 1634): 	at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:740)
       E/TiApplication( 1634): 	at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1501)
       E/TiApplication( 1634): 	at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:458)
       E/TiApplication( 1634): 	at android.os.Handler.handleCallback(Handler.java:739)
       E/TiApplication( 1634): 	at android.os.Handler.dispatchMessage(Handler.java:95)
       E/TiApplication( 1634): 	at android.os.Looper.loop(Looper.java:135)
       E/TiApplication( 1634): 	at android.app.ActivityThread.main(ActivityThread.java:5221)
       E/TiApplication( 1634): 	at java.lang.reflect.Method.invoke(Native Method)
       E/TiApplication( 1634): 	at java.lang.reflect.Method.invoke(Method.java:372)
       E/TiApplication( 1634): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
       E/TiApplication( 1634): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
       E/AndroidRuntime( 1634): FATAL EXCEPTION: main
       E/AndroidRuntime( 1634): Process: com.appc.timob18876, PID: 1634
       E/AndroidRuntime( 1634): android.content.res.Resources$NotFoundException: Unable to find resource ID #0x3e8
       E/AndroidRuntime( 1634): 	at android.content.res.Resources.getResourceName(Resources.java:2026)
       E/AndroidRuntime( 1634): 	at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:947)
       E/AndroidRuntime( 1634): 	at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1138)
       E/AndroidRuntime( 1634): 	at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:740)
       E/AndroidRuntime( 1634): 	at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1501)
       E/AndroidRuntime( 1634): 	at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:458)
       E/AndroidRuntime( 1634): 	at android.os.Handler.handleCallback(Handler.java:739)
       E/AndroidRuntime( 1634): 	at android.os.Handler.dispatchMessage(Handler.java:95)
       E/AndroidRuntime( 1634): 	at android.os.Looper.loop(Looper.java:135)
       E/AndroidRuntime( 1634): 	at android.app.ActivityThread.main(ActivityThread.java:5221)
       E/AndroidRuntime( 1634): 	at java.lang.reflect.Method.invoke(Native Method)
       E/AndroidRuntime( 1634): 	at java.lang.reflect.Method.invoke(Method.java:372)
       E/AndroidRuntime( 1634): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
       E/AndroidRuntime( 1634): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
       
  7. Manuel Lehner 2015-07-07

    @[~emerriman]: Are you testing with the latest version of the module? Actually this issue can be closed. [~hpham]s fix is working great!
  8. Ingo Muschenetz 2015-07-07

    Is it possible that the latest version of the module isn't in the repo?
  9. Ingo Muschenetz 2015-07-07

    Nope. titanium_mobile and the module are both at 2.3.1.
  10. Manuel Lehner 2015-07-07

    Sorry, I mean the drawer module. Hieu Phams PR to my fork of it made it work without having to update the ti.map module since it doesn't use Fragments anymore.
  11. Eric Merriman 2015-07-09

    I was using the version from GitTio which was 1.1.1. The Repo has 1.3.4 which I am testing now.
  12. Lokesh Choudhary 2015-08-28

    Resolving & Closing the issue & the map loads fine with Ti.Drawer.Layout module 1.3.4. Checked with both the original code & [~hpham]'s code. Environment: Appc Studio : 5.0.0.201508251028 Ti SDK : 4.1.0.GA Ti.Drawer.Layout module: 1.3.4 Ti CLI : 4.1.5 Alloy : 1.7.6 MAC Yosemite : 10.10.4 Appc NPM : 4.2.0-1 Appc CLI : 5.0.0-27 Node: v0.10.37 Nexus 5 - Android 5.1.1 Node : v0.10.37

JSON Source