[TIMOB-18876] TiUIMapView: Not loading at all (Nested fragments)
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Critical |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2015-08-28T01:00:49.000+0000 |
Affected Version/s | Release 4.0.0 |
Fix Version/s | Release 5.0.0 |
Components | Android |
Labels | android, drawerlayout, mapview, nested-fragem |
Reporter | Manojkumar Murugesan |
Assignee | Hieu Pham |
Created | 2015-05-07T13:35:11.000+0000 |
Updated | 2015-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();
This is expected since our add() method do not support the adding of a standalone fragment. We would need to add support for it.
[~hpham], Is this something to do with *TiUIView.java - add method*? Is there any work around you could suggest to fix this?
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.
[~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?
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:
Not sure of what case was intended to be fixed here, so putting results for both: Originally reported case: fails with:
And Hieu's test case fails with:
@[~emerriman]: Are you testing with the latest version of the module? Actually this issue can be closed. [~hpham]s fix is working great!
Is it possible that the latest version of the module isn't in the repo?
Nope. titanium_mobile and the module are both at 2.3.1.
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.
I was using the version from GitTio which was 1.1.1. The Repo has 1.3.4 which I am testing now.
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