use of com.android.example.devsummit.archdemo.event.post.NewPostEvent in project dev-summit-architecture-demo by yigit.
the class SaveNewPostJob method onAdded.
@Override
public void onAdded() {
Post post = new Post();
post.setText(mText);
post.setId(mFeedModel.generateIdForNewLocalPost());
post.setClientId(mClientId);
post.setUserId(mUserId);
post.setPending(true);
// make sure whatever time we put here is greater / eq to last known time in database.
// this will work around issues related to client's time.
// this time is temporary anyways as it will be overriden when it is synched to server
long feedTs = mFeedModel.getLatestTimestamp(null);
long now = System.currentTimeMillis();
post.setCreated(Math.max(feedTs, now) + 1);
L.d("assigned timestamp %s to the post", post.getCreated());
mPostModel.save(post);
mEventBus.post(new NewPostEvent(post));
}
Aggregations