<commit_before>package com.google.android.apps.iosched.util;

import android.app.Activity;
import android.content.Context;
import android.util.Log;
import android.widget.Toast;

import com.google.android.apps.iosched.io.model.Constants;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;

import no.java.schedule.io.model.JZFeedback;
import retrofit.Callback;
import retrofit.RestAdapter;
import retrofit.RetrofitError;
import retrofit.client.Response;

public class RestServiceDevNull {
    private static RestServiceDevNull instance = null;
    private RestDevApi restDevApi = null;
    private Activity activity = null;

    private RestServiceDevNull(String mode, Activity activity) {
        //TODO
        String endPoint = null;
        if(mode.equals("TEST")) {
         endPoint = Constants.SESSION_FEEDBACK_WEB_URI_TEST;
        }

        RestAdapter movieAPIRest = new RestAdapter.Builder()
                .setEndpoint(endPoint)
                .setLogLevel(RestAdapter.LogLevel.HEADERS_AND_ARGS)
                .build();
        restDevApi = movieAPIRest.create(RestDevApi.class);
        this.activity = activity;
    }

    public static RestServiceDevNull getInstance(String mode, Activity activity) {
        if (instance == null) {
            instance = new RestServiceDevNull(mode, activity);
        }
        return instance;
    }

    public void submitFeedbackToDevNull(String eventId, String sessionId, String voterId, JZFeedback feedbackBody) {
        restDevApi.postSessionFeedback(eventId, sessionId, voterId, feedbackBody, retrofitCallBack);
    }

    public void submitFeedbackTestToDevNull(String voterId, JZFeedback feedbackBody) {
        restDevApi.postSessionFeedbackTest(voterId, feedbackBody, retrofitCallBack);
    }

    public Callback retrofitCallBack = new Callback() {

        @Override
        public void success(Object o, Response response) {
            if (o instanceof JsonElement) {
                JsonObject jsonObj = ((JsonElement)o).getAsJsonObject();
                String strObj = jsonObj.toString();
                Toast.makeText(activity,
                        "Thank you for the feedback!",
                        Toast.LENGTH_SHORT).show();
                activity.finish();
            }
        }

        @Override
        public void failure(RetrofitError error) {
            Toast.makeText(activity,
                    "Something went wrong with the connection, please try again!",
                    Toast.LENGTH_SHORT).show();
        }<commit_msg>bugfix. need to set activity everytime when we enter feedbacksession.<commit_after>package com.google.android.apps.iosched.util;

import android.app.Activity;
import android.content.Context;
import android.util.Log;
import android.widget.Toast;

import com.google.android.apps.iosched.io.model.Constants;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;

import no.java.schedule.io.model.JZFeedback;
import retrofit.Callback;
import retrofit.RestAdapter;
import retrofit.RetrofitError;
import retrofit.client.Response;

public class RestServiceDevNull {
    private static RestServiceDevNull instance = null;
    private RestDevApi restDevApi = null;
    private Activity activity = null;

    private RestServiceDevNull(String mode) {
        //TODO
        String endPoint = null;
        if(mode.equals("TEST")) {
         endPoint = Constants.SESSION_FEEDBACK_WEB_URI_TEST;
        }

        RestAdapter movieAPIRest = new RestAdapter.Builder()
                .setEndpoint(endPoint)
                .setLogLevel(RestAdapter.LogLevel.HEADERS_AND_ARGS)
                .build();
        restDevApi = movieAPIRest.create(RestDevApi.class);
    }

    public void setActivity(Activity activity) {
        this.activity = activity;
    }

    public static RestServiceDevNull getInstance(String mode, Activity activity) {
        if (instance == null) {
            instance = new RestServiceDevNull(mode);
        }
        instance.setActivity(activity);
        return instance;
    }

    public void submitFeedbackToDevNull(String eventId, String sessionId, String voterId, JZFeedback feedbackBody) {
        restDevApi.postSessionFeedback(eventId, sessionId, voterId, feedbackBody, retrofitCallBack);
    }

    public void submitFeedbackTestToDevNull(String voterId, JZFeedback feedbackBody) {
        restDevApi.postSessionFeedbackTest(voterId, feedbackBody, retrofitCallBack);
    }

    public Callback retrofitCallBack = new Callback() {

        @Override
        public void success(Object o, Response response) {
            if (o instanceof JsonElement) {
                JsonObject jsonObj = ((JsonElement)o).getAsJsonObject();
                String strObj = jsonObj.toString();
                Toast.makeText(activity,
                        "Thank you for the feedback!",
                        Toast.LENGTH_SHORT).show();
                activity.finish();
            }
        }

        @Override
        public void failure(RetrofitError error) {
            Toast.makeText(activity,
                    "Something went wrong with the connection, please try again!",
                    Toast.LENGTH_SHORT).show();
        }
{'fraction_non_alphanumeric': 0.08271108558299828, 'fraction_numerical': 0.0, 'mean_word_length': 2.622746185852982, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1698159', 'n_tokens_mistral': 1421, 'n_tokens_neox': 1370, 'n_words': 313}