// Path: app/src/main/java/com/example/offline/domain/AddCommentUseCase.java
// public class AddCommentUseCase {
//     private final LocalCommentRepository localCommentRepository;
//     private final SyncCommentUseCase syncCommentUseCase;
// 
//     public AddCommentUseCase(LocalCommentRepository localCommentRepository, SyncCommentUseCase syncCommentUseCase) {
//         this.localCommentRepository = localCommentRepository;
//         this.syncCommentUseCase = syncCommentUseCase;
//     }
// 
//     public Completable addComment(String commentText) {
//         return localCommentRepository.add(ModelConstants.DUMMY_PHOTO_ID, commentText)
//                 .flatMapCompletable(syncCommentUseCase::syncComment);
//     }
// }
// 
// Path: app/src/main/java/com/example/offline/domain/GetCommentsUseCase.java
// public class GetCommentsUseCase {
//     private final LocalCommentRepository localCommentRepository;
// 
//     public GetCommentsUseCase(LocalCommentRepository localCommentRepository) {
//         this.localCommentRepository = localCommentRepository;
//     }
// 
//     public Flowable<List<Comment>> getComments() {
//         return localCommentRepository.getComments(ModelConstants.DUMMY_PHOTO_ID);
//     }
// }
// 
// Path: app/src/main/java/com/example/offline/model/Comment.java
// @Entity
// public class Comment implements Serializable {
// 
//     @PrimaryKey(autoGenerate = true)
//     private long id;
// 
//     @ColumnInfo(name = "photo_id")
//     private long photoId;
// 
//     @SerializedName("body")
//     @ColumnInfo(name = "comment_text")
//     private String commentText;
// 
//     @ColumnInfo(name = "timestamp")
//     private long timestamp;
// 
//     @ColumnInfo(name = "sync_pending")
//     private boolean syncPending;
// 
//     public long getId() {
//         return id;
//     }
// 
//     public long getPhotoId() {
//         return photoId;
//     }
// 
//     public String getCommentText() {
//         return commentText;
//     }
// 
//     public long getTimestamp() {
//         return timestamp;
//     }
// 
//     public boolean isSyncPending() {
//         return syncPending;
//     }
// 
//     @Ignore
//     public Comment(long photoId, String commentText) {
//         this.photoId = photoId;
//         this.commentText = commentText;
//         this.timestamp = System.currentTimeMillis();
//         this.syncPending = true;
//     }
// 
//     public Comment(long id, long photoId, String commentText, long timestamp, boolean syncPending) {
//         this.id = id;
//         this.photoId = photoId;
//         this.commentText = commentText;
//         this.timestamp = timestamp;
//         this.syncPending = syncPending;
//     }
// 
//     @Override
//     public String toString() {
//         return String.format("Comment id: %s, text: %s, syncPending: %s", id, commentText, syncPending);
//     }
// }


import android.arch.lifecycle.LiveData;
import android.arch.lifecycle.MutableLiveData;
import android.arch.lifecycle.ViewModel;
import com.example.offline.domain.AddCommentUseCase;
import com.example.offline.domain.GetCommentsUseCase;
import com.example.offline.model.Comment;
import java.util.List;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.CompositeDisposable;
import io.reactivex.schedulers.Schedulers;
import timber.log.Timber;
package com.example.offline.presentation;





public class CommentsViewModel extends ViewModel {

    private final GetCommentsUseCase getCommentsUseCase;
    private final AddCommentUseCase addCommentUseCase;
    private final CompositeDisposable disposables = new CompositeDisposable();
    private MutableLiveData<List<Comment>> commentsLiveData = new MutableLiveData<>();

    public CommentsViewModel(GetCommentsUseCase getCommentsUseCase,
// Path: app/src/main/java/com/example/offline/domain/AddCommentUseCase.java
// public class AddCommentUseCase {
//     private final LocalCommentRepository localCommentRepository;
//     private final SyncCommentUseCase syncCommentUseCase;
// 
//     public AddCommentUseCase(LocalCommentRepository localCommentRepository, SyncCommentUseCase syncCommentUseCase) {
//         this.localCommentRepository = localCommentRepository;
//         this.syncCommentUseCase = syncCommentUseCase;
//     }
// 
//     public Completable addComment(String commentText) {
//         return localCommentRepository.add(ModelConstants.DUMMY_PHOTO_ID, commentText)
//                 .flatMapCompletable(syncCommentUseCase::syncComment);
//     }
// }
// 
// Path: app/src/main/java/com/example/offline/domain/GetCommentsUseCase.java
// public class GetCommentsUseCase {
//     private final LocalCommentRepository localCommentRepository;
// 
//     public GetCommentsUseCase(LocalCommentRepository localCommentRepository) {
//         this.localCommentRepository = localCommentRepository;
//     }
// 
//     public Flowable<List<Comment>> getComments() {
//         return localCommentRepository.getComments(ModelConstants.DUMMY_PHOTO_ID);
//     }
// }
// 
// Path: app/src/main/java/com/example/offline/model/Comment.java
// @Entity
// public class Comment implements Serializable {
// 
//     @PrimaryKey(autoGenerate = true)
//     private long id;
// 
//     @ColumnInfo(name = "photo_id")
//     private long photoId;
// 
//     @SerializedName("body")
//     @ColumnInfo(name = "comment_text")
//     private String commentText;
// 
//     @ColumnInfo(name = "timestamp")
//     private long timestamp;
// 
//     @ColumnInfo(name = "sync_pending")
//     private boolean syncPending;
// 
//     public long getId() {
//         return id;
//     }
// 
//     public long getPhotoId() {
//         return photoId;
//     }
// 
//     public String getCommentText() {
//         return commentText;
//     }
// 
//     public long getTimestamp() {
//         return timestamp;
//     }
// 
//     public boolean isSyncPending() {
//         return syncPending;
//     }
// 
//     @Ignore
//     public Comment(long photoId, String commentText) {
//         this.photoId = photoId;
//         this.commentText = commentText;
//         this.timestamp = System.currentTimeMillis();
//         this.syncPending = true;
//     }
// 
//     public Comment(long id, long photoId, String commentText, long timestamp, boolean syncPending) {
//         this.id = id;
//         this.photoId = photoId;
//         this.commentText = commentText;
//         this.timestamp = timestamp;
//         this.syncPending = syncPending;
//     }
// 
//     @Override
//     public String toString() {
//         return String.format("Comment id: %s, text: %s, syncPending: %s", id, commentText, syncPending);
//     }
// }


// Path: app/src/main/java/com/example/offline/presentation/CommentsViewModel.java
import android.arch.lifecycle.LiveData;
import android.arch.lifecycle.MutableLiveData;
import android.arch.lifecycle.ViewModel;
import com.example.offline.domain.AddCommentUseCase;
import com.example.offline.domain.GetCommentsUseCase;
import com.example.offline.model.Comment;
import java.util.List;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.CompositeDisposable;
import io.reactivex.schedulers.Schedulers;
import timber.log.Timber;

package com.example.offline.presentation;





public class CommentsViewModel extends ViewModel {

    private final GetCommentsUseCase getCommentsUseCase;
    private final AddCommentUseCase addCommentUseCase;
    private final CompositeDisposable disposables = new CompositeDisposable();
    private MutableLiveData<List<Comment>> commentsLiveData = new MutableLiveData<>();

    public CommentsViewModel(GetCommentsUseCase getCommentsUseCase,
                      AddCommentUseCase addCommentUseCase) {