Skip to content

Commit

Permalink
refine code to mark item as readed; force mail to reload upon notific…
Browse files Browse the repository at this point in the history
…ation
  • Loading branch information
zfdang committed May 15, 2016
1 parent 9736016 commit 616f5d3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,15 @@ public void markMailAsReaded(final int position) {
final Mail mail = MailListContent.MAILS.get(position);
if (!mail.isNew) return;

// this is a new mail, mark it as read in remote and local
// only referred post need explicit marking. for mails, there is no need to mark
if(TextUtils.equals(currentFolder, INBOX_LABEL) || TextUtils.equals(currentFolder, OUTBOX_LABEL)
|| TextUtils.equals(currentFolder, DELETED_LABEL)) {
mail.isNew = false;
recyclerView.getAdapter().notifyItemChanged(position);
return;
}

// mark it as read in remote and local
SMTHHelper helper = SMTHHelper.getInstance();
helper.wService.readReferPosts(currentFolder, mail.referIndex)
.subscribeOn(Schedulers.io())
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/java/com/zfdang/zsmth_android/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import com.zfdang.zsmth_android.listeners.OnVolumeUpDownListener;
import com.zfdang.zsmth_android.models.Board;
import com.zfdang.zsmth_android.models.Mail;
import com.zfdang.zsmth_android.models.MailListContent;
import com.zfdang.zsmth_android.models.Topic;
import com.zfdang.zsmth_android.newsmth.AjaxResponse;
import com.zfdang.zsmth_android.newsmth.SMTHHelper;
Expand Down Expand Up @@ -350,6 +351,8 @@ protected void onNewIntent(Intent intent) {
} else if(message.contains(SMTHApplication.NOTIFICATION_NEW_REPLY)) {
mailListFragment.setCurrentFolder(MailListFragment.REPLY_LABEL);
}
// force mail fragment to reload
MailListContent.clear();

fm.beginTransaction().replace(R.id.content_frame, mailListFragment).commitAllowingStateLoss();
}
Expand Down

0 comments on commit 616f5d3

Please sign in to comment.