package com.spiddekauga.android.feedback;

import com.spiddekauga.cloudshine.feedbackApi.model.Feedback;
import com.spiddekauga.utils.EventBus;
import com.squareup.otto.Subscribe;

import java.util.List;

/**
 * Repository for handling feedbacks
 */
public class FeedbackRepo {
private static FeedbackRepo mInstance = null;
private FeedbackPrefsGateway mPrefsGateway = new FeedbackPrefsGateway();

/**
 * Enforces singleton pattern
 */
protected FeedbackRepo() {
	EventBus.getInstance().register(this);
}

/**
 * Get singleton instance
 * @return get instance
 */
public static FeedbackRepo getInstance() {
	if (mInstance == null) {
		mInstance = new FeedbackRepo();
	}
	return mInstance;
}

/**
 * Send a new menu_feedback. Will store the menu_feedback locally until it has been successfully sent
 * @param feedback the menu_feedback to send.
 */
void sendFeedback(Feedback feedback) {
	feedback.setSyncing(true);
	mPrefsGateway.addFeedback(feedback);
	FeedbackSendTask feedbackSendTask = new FeedbackSendTask();
	feedbackSendTask.execute(feedback);
}

/**
 * Called after sendFeedback server response
 * @param event the menu_feedback response event
 */
@Subscribe
public void onFeedbackResponse(FeedbackResponseEvent event) {
	if (event.isSuccessful()) {
		List<Feedback> syncedFeedbacks = event.getFeedbacks();
		mPrefsGateway.removeFeedbacks(syncedFeedbacks);
	}
}

/**
 * Sync unsynced preferences
 */
public void syncUnsyncedFeedbacks() {
	List<Feedback> feedbacks = mPrefsGateway.getUnsyncedFeedbacks();

	if (!feedbacks.isEmpty()) {
		FeedbackSendTask feedbackSendTask = new FeedbackSendTask();
		Feedback[] feedbackArray = new Feedback[feedbacks.size()];
		feedbackArray = feedbacks.toArray(feedbackArray);
		feedbackSendTask.execute(feedbackArray);
	}
}

/**
 * Reset syncing feedbacks
 */
public void resetSyncingFeedbacks() {
	mPrefsGateway.resetSyncingFeedbacks();
}
}

@@ -703,21 +703,16 @@
 d a new 
-menu_
 feedback
@@ -805,29 +805,24 @@
 eedback the 
-menu_
 feedback to 
@@ -1102,29 +1102,24 @@
 m event the 
-menu_
 feedback res
@@ -1145,16 +1145,44 @@
 bscribe%0A
+@SuppressWarnings(%22unused%22)%0A
 public v

Fix javadoc spelling