1717import android .support .v7 .widget .LinearLayoutManager ;
1818import android .support .v7 .widget .RecyclerView ;
1919import android .support .v7 .widget .Toolbar ;
20+ import android .util .Log ;
2021import android .view .LayoutInflater ;
2122import android .view .MenuItem ;
2223import android .view .View ;
@@ -207,7 +208,7 @@ public GetNotificationsTask(int type,
207208 int targetPage ) {
208209 this .targetPage = targetPage ;
209210 this .type = type ;
210- this .keyName = type == 1 ? "MentionArray " : "ReplyArray " ;
211+ this .keyName = type == 1 ? "ReplyArray " : "MentionArray " ;
211212 this .loadFromCache = loadFromCache ;
212213 this .mSwipeRefreshLayout = mSwipeRefreshLayout ;
213214 this .mRecyclerView = mRecyclerView ;
@@ -230,6 +231,9 @@ public void run() {
230231 protected void onPostExecute (JSONObject jsonObject ) {
231232 super .onPostExecute (jsonObject );
232233 int status = 0 ;
234+ if (loadFromCache ){
235+ status = 1 ;
236+ }
233237 //先保存缓存
234238 if (jsonObject != null && !loadFromCache ){
235239 try {
@@ -249,12 +253,15 @@ protected void onPostExecute(JSONObject jsonObject) {
249253 //防止异步任务未完成时,用户按下返回,Fragment被GC,造成NullPointer
250254 if (mRecyclerView != null && mSwipeRefreshLayout !=null && mAdapter != null && rootView != null && getActivity () != null ) {
251255 mSwipeRefreshLayout .setRefreshing (false );
252- if (list != null && status == 1 ) {
253- if (!list .isEmpty ()){
256+ Log .d ("Status : " , keyName + String .valueOf (status ));
257+ if (status == 1 ) {
258+ if (list != null && !list .isEmpty ()){
259+ Log .d ("Action : " , keyName + " SetData" );
254260 mAdapter .setData (list );
255261 mAdapter .notifyDataSetChanged ();
256262 }else {
257- //TODO: 新注册用户,网络正常但是当前无任何通知,准备做个提示
263+ //新注册用户,网络正常但是当前无任何通知,准备做个提示
264+ Snackbar .make (rootView , R .string .empty_notification , Snackbar .LENGTH_LONG ).setAction ("Action" , null ).show ();
258265 }
259266 } else {
260267 Snackbar .make (rootView , R .string .network_error , Snackbar .LENGTH_LONG ).setAction ("Action" , null ).show ();
0 commit comments