public static Like createLikeRequest( String memoryId, int categoryType, Context context, String memoryType) { Like like = new Like( null, null, TJPreferences.getActiveJourneyId(context), memoryId, TJPreferences.getUserId(context), memoryType, true, null, HelpMe.getCurrentTime(), HelpMe.getCurrentTime()); like.setId(String.valueOf(LikeDataSource.createLike(like, context))); Log.d(TAG, "like created in database = " + like + memoryType); Request request = new Request( null, like.getId(), TJPreferences.getActiveJourneyId(context), Request.OPERATION_TYPE_LIKE, categoryType, Request.REQUEST_STATUS_NOT_STARTED, 0); RequestQueueDataSource.createRequest(request, context); if (HelpMe.isNetworkAvailable(context)) { Intent intent = new Intent(context, MakeServerRequestsService.class); context.startService(intent); } else { Log.d(TAG, "since no network not starting service RQ"); } return like; }
public static void createUnlikeRequest(Like like, int categoryType, Context context) { Log.d(TAG, "unliking a memory with id = " + like.getId() + like.getMemType()); // LikeDataSource.deleteLike(context, like); like.setIsValid(false); LikeDataSource.updateLike(like, context); Request request = new Request( null, like.getId(), TJPreferences.getActiveJourneyId(context), Request.OPERATION_TYPE_UNLIKE, categoryType, Request.REQUEST_STATUS_NOT_STARTED, 0); RequestQueueDataSource.createRequest(request, context); if (HelpMe.isNetworkAvailable(context)) { Intent intent = new Intent(context, MakeServerRequestsService.class); context.startService(intent); } else { Log.d(TAG, "since no network not starting service RQ"); } }