Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TIMOB-20332] Android: Closing a Ti.UI.TabGroup that contains a ti.map view crashes the app #9628

Merged
merged 10 commits into from
Dec 18, 2017
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.appcelerator.titanium.view;

import org.appcelerator.kroll.common.TiMessenger;
import org.appcelerator.titanium.TiC;
import org.appcelerator.titanium.proxy.TiViewProxy;
import org.appcelerator.titanium.util.TiConvert;
Expand Down Expand Up @@ -79,7 +78,7 @@ public void release()
FragmentTransaction transaction = null;
Fragment tabFragment = fragmentManager.findFragmentById(android.R.id.tabcontent);
if (tabFragment != null) {
FragmentManager childManager = tabFragment.getChildFragmentManager();
FragmentManager childManager = fragment.getActivity().getSupportFragmentManager();
transaction = childManager.beginTransaction();
} else {
transaction = fragmentManager.beginTransaction();
Expand Down
48 changes: 48 additions & 0 deletions tests/Resources/ti.ui.tabgroup.addontest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* Appcelerator Titanium Mobile
* Copyright (c) 2011-Present by Appcelerator, Inc. All Rights Reserved.
* Licensed under the terms of the Apache Public License
* Please see the LICENSE included with this distribution for details.
*/
/* eslint-env mocha */
/* global Ti, L */
/* eslint no-unused-expressions: "off" */
'use strict';
var should = require('./utilities/assertions');

describe('Titanium.UI.Tabgroup', function () {

it('Remove MapView from TabGroup', function(finish) {
// create tab group
var tabGroup = Titanium.UI.createTabGroup();

var win1 = Titanium.UI.createWindow({
title:'Tab 1',
backgroundColor:'#fff'
});

var tab1 = Titanium.UI.createTab({
title:'Tab 1',
window:win1
});

var Map = require('ti.map');

var mapview = Map.createView({top: 0, height: '80%'});

mapview.addEventListener('complete', function() {
tabGroup.close();
});

win1.add(mapview);

tabGroup.addTab(tab1);

tabGroup.open();

tabGroup.addEventListener('close', function() {
finish();
});

}).timeout(5000);
});