Skip to content
This repository has been archived by the owner on Dec 4, 2019. It is now read-only.

[TIMOB-18244]: Fix map with centerView #19

Merged
merged 1 commit into from
Mar 25, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
28 changes: 21 additions & 7 deletions src/com/tripvi/drawerlayout/Drawer.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import org.appcelerator.titanium.util.TiRHelper.ResourceNotFoundException;
import org.appcelerator.titanium.util.TiUIHelper;
import org.appcelerator.titanium.view.TiUIView;
import org.appcelerator.titanium.view.TiUIFragment;

import ti.modules.titanium.ui.WindowProxy;
import android.support.v4.app.ActionBarDrawerToggle;
Expand Down Expand Up @@ -425,15 +426,28 @@ private void replaceCenterView(TiViewProxy viewProxy) {
return;
}

// update the main content by replacing fragments
View contentView = viewProxy.getOrCreateView().getOuterView();
ContentWrapperFragment fragment = new ContentWrapperFragment();
fragment.setContentView(contentView);

String name = viewProxy.getApiName();
// If view is map, we need to create a standalone fragment. This
// can be done by set the property here before creating the view
// or set it when you create the map in Javascript.
if (name == "Ti.Map") {
viewProxy.setProperty(TiC.PROPERTY_FRAGMENT_ONLY, true);
}
TiUIView contentView = viewProxy.getOrCreateView();
FragmentManager fragmentManager = ((ActionBarActivity) proxy
.getActivity()).getSupportFragmentManager();
fragmentManager.beginTransaction().replace(id_content_frame, fragment)
.commit();
// since only map uses TiUIFragment, here we check if view is a map,
// then we add the fragment directly.
if (contentView instanceof TiUIFragment) {
fragmentManager.beginTransaction().replace(id_content_frame, ((TiUIFragment)contentView).getFragment())
.commit();
} else {
View view = contentView.getOuterView();
ContentWrapperFragment fragment = new ContentWrapperFragment();
fragment.setContentView(view);
fragmentManager.beginTransaction().replace(id_content_frame, fragment)
.commit();
}

this.centerView = viewProxy;
}
Expand Down