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

Commit

Permalink
Merge pull request #19 from hieupham007/timob-18244
Browse files Browse the repository at this point in the history
[TIMOB-18244]: Fix map with centerView
  • Loading branch information
manumaticx committed Mar 25, 2015
2 parents 118ef5c + 502feff commit 6eca6d8
Showing 1 changed file with 21 additions and 7 deletions.
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

0 comments on commit 6eca6d8

Please sign in to comment.