@@ -97,6 +97,7 @@ public class ReactMsgListManager extends ViewGroupManager<SmartRefreshLayout> im
9797 private ReactContext mContext ;
9898 private MessageList msgList ;
9999 private SmartRefreshLayout swipeRefreshLayout ;
100+
100101 static {
101102 ClassicsHeader .REFRESH_HEADER_PULLDOWN = "" ;
102103 ClassicsHeader .REFRESH_HEADER_REFRESHING = "" ;
@@ -106,6 +107,7 @@ public class ReactMsgListManager extends ViewGroupManager<SmartRefreshLayout> im
106107 ClassicsHeader .REFRESH_HEADER_FAILED = "" ;
107108 ClassicsHeader .REFRESH_HEADER_LASTTIME = "" ;
108109 }
110+
109111 @ Override
110112 public String getName () {
111113 return REACT_MESSAGE_LIST ;
@@ -130,7 +132,7 @@ protected SmartRefreshLayout createViewInstance(final ThemedReactContext reactCo
130132 SessorUtil .getInstance (reactContext ).register (true );
131133 mContext .registerReceiver (RCTMsgListReceiver , intentFilter );
132134
133- swipeRefreshLayout = new SmartRefreshLayout (reactContext ){
135+ swipeRefreshLayout = new SmartRefreshLayout (reactContext ) {
134136 private final Runnable measureAndLayout = new Runnable () {
135137
136138 int width = 0 ;
@@ -139,12 +141,8 @@ protected SmartRefreshLayout createViewInstance(final ThemedReactContext reactCo
139141 @ Override
140142 public void run () {
141143
142- if (width == 0 ) {
143- width = getWidth ();
144- }
145- if (height == 0 ) {
146- height = getHeight ();
147- }
144+ width = getWidth ();
145+ height = getHeight ();
148146 measure (MeasureSpec .makeMeasureSpec (width , MeasureSpec .EXACTLY ),
149147 MeasureSpec .makeMeasureSpec (height , MeasureSpec .EXACTLY ));
150148 layout (getLeft (), getTop (), getRight (), getBottom ());
@@ -157,14 +155,15 @@ public void requestLayout() {
157155 post (measureAndLayout );
158156 }
159157 };
160- msgList = new MessageList (reactContext , null );
158+ Activity activity = reactContext .getCurrentActivity ();
159+ msgList = new MessageList (activity , null );
161160 swipeRefreshLayout .addView (msgList );
162161
163- final Handler handler = new Handler (){
162+ final Handler handler = new Handler () {
164163
165164 @ Override
166165 public void handleMessage (Message msg ) {
167- switch (msg .what ){
166+ switch (msg .what ) {
168167 case 1 :
169168 swipeRefreshLayout .finishRefresh (true );
170169 break ;
@@ -185,7 +184,7 @@ public void handleMessage(Message msg) {
185184 public void onRefresh (RefreshLayout refreshlayout ) {
186185 reactContext .getJSModule (RCTEventEmitter .class ).receiveEvent (getId (),
187186 ON_PULL_TO_REFRESH_EVENT , null );
188- handler .sendEmptyMessageDelayed (1 ,5000 );
187+ handler .sendEmptyMessageDelayed (1 , 5000 );
189188 }
190189 });
191190 // Use default layout
@@ -343,9 +342,10 @@ public void onAutoScroll(boolean autoScroll) {
343342 return swipeRefreshLayout ;
344343 }
345344
346- int getId (){
345+ int getId () {
347346 return swipeRefreshLayout .getId ();
348347 }
348+
349349 private PhotoViewPagerViewUtil .IPhotoLongClickListener longClickListener = new PhotoViewPagerViewUtil .IPhotoLongClickListener () {
350350 @ Override
351351 public boolean onClick (final Dialog dialog , View v , final IMediaFile mediaFile ) {
@@ -615,7 +615,8 @@ public void run() {
615615 mAdapter .addToEnd (list );
616616 } else if (intent .getAction ().equals (RCT_SCROLL_TO_BOTTOM_ACTION )) {
617617 Log .i ("RCTMessageListManager" , "Scroll to bottom" );
618- msgList .smoothScrollToPosition (0 );
618+ if (msgList != null )
619+ msgList .smoothScrollToPosition (0 );
619620// mAdapter.getLayoutManager().scrollToPosition(0);
620621 } else if (intent .getAction ().equals (RCT_DELETE_MESSAGES_ACTION )) {
621622 String [] messages = intent .getStringArrayExtra ("messages" );
0 commit comments