@@ -191,6 +191,10 @@ public class WXSDKInstance implements IWXActivityStateListener,View.OnLayoutChan
191
191
192
192
private List <String > mLayerOverFlowListeners ;
193
193
194
+ private List <ActionBarHandler > mWXActionbarHandlers ;
195
+
196
+ private List <OnBackPressedHandler > mWXBackPressedHandlers ;
197
+
194
198
private WXSDKInstance mParentInstance ;
195
199
196
200
/**
@@ -274,6 +278,19 @@ public void setCustomFontNetworkHandler(CustomFontNetworkHandler customFontNetwo
274
278
this .mCustomFontNetworkHandler = customFontNetworkHandler ;
275
279
}
276
280
281
+
282
+ /**
283
+ * ActionBar Handler
284
+ */
285
+
286
+ public interface ActionBarHandler {
287
+ boolean onSupportNavigateUp ();
288
+ }
289
+
290
+ public interface OnBackPressedHandler {
291
+ boolean onBackPressed ();
292
+ }
293
+
277
294
/**
278
295
* set make weexCore run in single process mode
279
296
* @param flag true means weexCore run in single process mode or multi process mode
@@ -1359,7 +1376,26 @@ public boolean onActivityBack() {
1359
1376
return false ;
1360
1377
}
1361
1378
1379
+ public boolean onSupportNavigateUp () {
1380
+ if (mWXActionbarHandlers != null ) {
1381
+ for (ActionBarHandler handler : mWXActionbarHandlers ) {
1382
+ if (handler .onSupportNavigateUp ()) {
1383
+ return true ;
1384
+ }
1385
+ }
1386
+ }
1387
+ return false ;
1388
+ }
1389
+
1362
1390
public boolean onBackPressed () {
1391
+ if (mWXBackPressedHandlers != null ) {
1392
+ for (OnBackPressedHandler handler : mWXBackPressedHandlers ) {
1393
+ if (handler .onBackPressed ()) {
1394
+ return true ;
1395
+ }
1396
+ }
1397
+ }
1398
+
1363
1399
WXComponent comp = getRootComponent ();
1364
1400
if (comp != null ) {
1365
1401
WXEvent events = comp .getEvents ();
@@ -1712,6 +1748,8 @@ public synchronized void destroy() {
1712
1748
mFlatGUIContext = null ;
1713
1749
mInstanceOnFireEventInterceptorList = null ;
1714
1750
mWXScrollListeners = null ;
1751
+ mWXActionbarHandlers = null ;
1752
+ mWXBackPressedHandlers = null ;
1715
1753
mRenderContainer = null ;
1716
1754
mNestedInstanceInterceptor = null ;
1717
1755
mUserTrackAdapter = null ;
@@ -1845,6 +1883,41 @@ public synchronized void registerOnWXScrollListener(OnWXScrollListener wxScrollL
1845
1883
mWXScrollListeners .add (wxScrollListener );
1846
1884
}
1847
1885
1886
+ public synchronized void registerActionbarHandler (ActionBarHandler actionBarHandler ) {
1887
+ if (actionBarHandler == null ) {
1888
+ return ;
1889
+ }
1890
+ if (mWXActionbarHandlers == null ) {
1891
+ mWXActionbarHandlers = new ArrayList <>();
1892
+ }
1893
+
1894
+ mWXActionbarHandlers .add (actionBarHandler );
1895
+ }
1896
+
1897
+ public synchronized void unRegisterActionbarHandler (ActionBarHandler actionBarHandler ) {
1898
+ if (mWXActionbarHandlers != null && actionBarHandler != null ) {
1899
+ mWXActionbarHandlers .remove (actionBarHandler );
1900
+ }
1901
+ }
1902
+
1903
+ public synchronized void registerBackPressedHandler (OnBackPressedHandler backPressedHandler ) {
1904
+ if (backPressedHandler == null ) {
1905
+ return ;
1906
+ }
1907
+
1908
+ if (mWXBackPressedHandlers == null ) {
1909
+ mWXBackPressedHandlers = new ArrayList <>();
1910
+ }
1911
+
1912
+ mWXBackPressedHandlers .add (backPressedHandler );
1913
+ }
1914
+
1915
+ public synchronized void unRegisterBackPressedHandler (OnBackPressedHandler backPressedHandler ) {
1916
+ if (mWXBackPressedHandlers != null && backPressedHandler != null ) {
1917
+ mWXBackPressedHandlers .remove (backPressedHandler );
1918
+ }
1919
+ }
1920
+
1848
1921
static int sScreenHeight = -1 ;
1849
1922
public void setSize (int width , int height ) {
1850
1923
if (width > 0 && height > 0 & !isDestroy && mRendered && mRenderContainer != null ) {
0 commit comments