Skip to content

Commit

Permalink
fix(android): execute transaction in TiUIFragment only once
Browse files Browse the repository at this point in the history
execution transaction on every "onAttachedToWindow" causes loss of objects on map

refs tidev#13243
  • Loading branch information
drauggres committed Feb 3, 2022
1 parent 14859b8 commit 7fe150f
Showing 1 changed file with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public TiUIFragment(TiViewProxy proxy, Activity activity)
fragment = createFragment();
} else {
TiCompositeLayout container = new TiCompositeLayout(activity, proxy) {
private boolean transactionCommited = false;
@Override
public boolean dispatchTouchEvent(MotionEvent ev)
{
Expand All @@ -48,12 +49,15 @@ public boolean dispatchTouchEvent(MotionEvent ev)
protected void onAttachedToWindow()
{
super.onAttachedToWindow();
FragmentManager manager = ((FragmentActivity) getContext()).getSupportFragmentManager();
FragmentTransaction transaction = manager.beginTransaction();
transaction.runOnCommit(onCommitRunnable);
fragment = createFragment();
transaction.add(getId(), fragment);
transaction.commitAllowingStateLoss();
if (!transactionCommited) {
transactionCommited = true;
FragmentManager manager = ((FragmentActivity) getContext()).getSupportFragmentManager();
FragmentTransaction transaction = manager.beginTransaction();
transaction.runOnCommit(onCommitRunnable);
fragment = createFragment();
transaction.add(getId(), fragment);
transaction.commitAllowingStateLoss();
}
}
};
container.setId(View.generateViewId());
Expand Down

0 comments on commit 7fe150f

Please sign in to comment.