@@ -17,6 +17,7 @@ import {
1717 _updateTransitions , _reverseTransitions , _clearEntry , _clearFragment , AnimationType
1818} from "./fragment.transitions" ;
1919
20+ import { loadCss } from "../styling/style-scope" ;
2021import { profile } from "../../profiling" ;
2122
2223// TODO: Remove this and get it from global to decouple builder for angular
@@ -82,13 +83,24 @@ function getAttachListener(): android.view.View.OnAttachStateChangeListener {
8283 return attachStateChangeListener ;
8384}
8485
85- export function reloadPage ( ) : void {
86+ export function reloadPage ( context ?: HmrContext ) : void {
8687 const activity = application . android . foregroundActivity ;
8788 const callbacks : AndroidActivityCallbacks = activity [ CALLBACKS ] ;
8889 const rootView : View = callbacks . getRootView ( ) ;
8990
90- if ( ! rootView || ! rootView . _onLivesync ( ) ) {
91- callbacks . resetActivityContent ( activity ) ;
91+ let executeLivesync = true ;
92+ // HMR has context, livesync does not
93+ if ( context ) {
94+ if ( context . module === application . getCssFileName ( ) ) {
95+ loadCss ( context . module ) ;
96+ rootView . _onCssStateChange ( ) ;
97+ executeLivesync = false ;
98+ }
99+ }
100+ if ( executeLivesync ) {
101+ if ( ! rootView || ! rootView . _onLivesync ( ) ) {
102+ callbacks . resetActivityContent ( activity ) ;
103+ }
92104 }
93105}
94106
@@ -469,19 +481,19 @@ export class Frame extends FrameBase {
469481 switch ( this . actionBarVisibility ) {
470482 case "never" :
471483 return false ;
472-
484+
473485 case "always" :
474486 return true ;
475-
487+
476488 default :
477489 if ( page . actionBarHidden !== undefined ) {
478490 return ! page . actionBarHidden ;
479491 }
480-
492+
481493 if ( this . _android && this . _android . showActionBar !== undefined ) {
482494 return this . _android . showActionBar ;
483495 }
484-
496+
485497 return true ;
486498 }
487499 }
@@ -846,14 +858,14 @@ class FragmentCallbacksImplementation implements AndroidFragmentCallbacks {
846858 // parent while its supposed parent believes it properly removed its children; in order to "force" the child to
847859 // lose its parent we temporarily add it to the parent, and then remove it (addViewInLayout doesn't trigger layout pass)
848860 const nativeView = page . nativeViewProtected ;
849- if ( nativeView != null ) {
850- const parentView = nativeView . getParent ( ) ;
861+ if ( nativeView != null ) {
862+ const parentView = nativeView . getParent ( ) ;
851863 if ( parentView instanceof android . view . ViewGroup ) {
852864 if ( parentView . getChildCount ( ) === 0 ) {
853865 parentView . addViewInLayout ( nativeView , - 1 , new org . nativescript . widgets . CommonLayoutParams ( ) ) ;
854866 }
855867
856- parentView . removeView ( nativeView ) ;
868+ parentView . removeView ( nativeView ) ;
857869 }
858870 }
859871
0 commit comments