Search in sources :

Example 41 with Gson

use of com.google.gson.Gson in project glimmr by brk3.

the class GsonHelper method marshallObject.

public boolean marshallObject(Object o, Bundle bundle, String key) {
    Gson gson = new Gson();
    String json = gson.toJson(o);
    bundle.putString(key, json);
    return true;
}
Also used : Gson(com.google.gson.Gson)

Example 42 with Gson

use of com.google.gson.Gson in project glimmr by brk3.

the class TaskQueueDelegateFactory method get.

public FileObjectQueue<T> get(String fileName, Class<T> taskType) {
    final Converter<T> converter = new GsonConverter<T>(new Gson(), taskType);
    final File queueFile = new File(mContext.getFilesDir(), fileName);
    FileObjectQueue<T> delegate = null;
    try {
        delegate = new FileObjectQueue<T>(queueFile, converter);
    } catch (IOException e) {
        // TODO: how should we handle this
        e.printStackTrace();
    }
    return delegate;
}
Also used : GsonConverter(com.bourke.glimmr.tape.GsonConverter) Gson(com.google.gson.Gson) IOException(java.io.IOException) File(java.io.File)

Example 43 with Gson

use of com.google.gson.Gson in project glimmr by brk3.

the class PhotosetViewerActivity method onRestoreInstanceState.

@Override
protected void onRestoreInstanceState(Bundle bundle) {
    super.onRestoreInstanceState(bundle);
    Gson gson = new Gson();
    if (mPhotoset == null) {
        String json = bundle.getString(KEY_PHOTOSET);
        if (json != null) {
            mPhotoset = gson.fromJson(json, Photoset.class);
        } else {
            Log.e(TAG, "No photoset found in savedInstanceState");
        }
    }
    if (mUser == null) {
        String json = bundle.getString(KEY_USER);
        if (json != null) {
            mUser = new Gson().fromJson(json, User.class);
        } else {
            Log.e(TAG, "No user found in savedInstanceState");
        }
    }
    mPhotoset.setOwner(mUser);
    initViewPager();
    updateBottomOverlay();
}
Also used : User(com.googlecode.flickrjandroid.people.User) Photoset(com.googlecode.flickrjandroid.photosets.Photoset) Gson(com.google.gson.Gson)

Example 44 with Gson

use of com.google.gson.Gson in project bigbluebutton by bigbluebutton.

the class EventListenerImp method sendShareStartedEvent.

private void sendShareStartedEvent(ScreenShareStartedEvent event) {
    Map<String, Object> data = new HashMap<String, Object>();
    data.put("meetingId", event.meetingId);
    data.put("streamId", event.streamId);
    data.put("width", event.width);
    data.put("height", event.height);
    data.put("url", event.url);
    data.put("session", event.session);
    Map<String, Object> message = new HashMap<String, Object>();
    Gson gson = new Gson();
    message.put("msg", gson.toJson(data));
    BroadcastClientMessage msg = new BroadcastClientMessage(event.meetingId, "screenShareStartedMessage", message);
    sender.sendMessage(msg);
    Map<String, Object> logData = new HashMap<String, Object>();
    logData.put("meetingId", event.meetingId);
    logData.put("streamId", event.streamId);
    logData.put("width", event.width);
    logData.put("height", event.height);
    logData.put("url", event.url);
    logData.put("session", event.session);
    gson = new Gson();
    String logStr = gson.toJson(logData);
    log.info("Send to client screen share started message: data={}", logStr);
}
Also used : HashMap(java.util.HashMap) Gson(com.google.gson.Gson)

Example 45 with Gson

use of com.google.gson.Gson in project bigbluebutton by bigbluebutton.

the class EventListenerImp method sendStartShareRequestResponse.

private void sendStartShareRequestResponse(ScreenShareRequestTokenSuccessResponse event) {
    Map<String, Object> data = new HashMap<String, Object>();
    data.put("authToken", event.token);
    data.put("jnlp", event.jnlp);
    data.put("streamId", event.streamId);
    data.put("session", event.session);
    Map<String, Object> message = new HashMap<String, Object>();
    Gson gson = new Gson();
    message.put("msg", gson.toJson(data));
    DirectClientMessage msg = new DirectClientMessage(event.meetingId, event.userId, "startShareRequestResponse", message);
    sender.sendMessage(msg);
    Map<String, Object> logData = new HashMap<String, Object>();
    logData.put("meetingId", event.meetingId);
    logData.put("userId", event.userId);
    logData.put("session", event.session);
    logData.put("authToken", event.token);
    logData.put("jnlp", event.jnlp);
    Gson gson2 = new Gson();
    String logStr = gson2.toJson(logData);
    log.info("Send to client start screen share request response: data={}", logStr);
}
Also used : HashMap(java.util.HashMap) Gson(com.google.gson.Gson)

Aggregations

Gson (com.google.gson.Gson)1309 Test (org.junit.Test)280 HashMap (java.util.HashMap)227 GsonBuilder (com.google.gson.GsonBuilder)174 JsonObject (com.google.gson.JsonObject)157 IOException (java.io.IOException)147 CommandWrapper (ClientServerApi.CommandWrapper)123 ArrayList (java.util.ArrayList)121 CommandExecuter (CommandHandler.CommandExecuter)119 CriticalError (SQLDatabase.SQLDatabaseException.CriticalError)118 JsonSyntaxException (com.google.gson.JsonSyntaxException)103 ClientNotConnected (SQLDatabase.SQLDatabaseException.ClientNotConnected)96 JsonElement (com.google.gson.JsonElement)78 Type (java.lang.reflect.Type)77 Map (java.util.Map)63 ProductNotExistInCatalog (SQLDatabase.SQLDatabaseException.ProductNotExistInCatalog)53 SmartCode (BasicCommonClasses.SmartCode)50 InputStreamReader (java.io.InputStreamReader)49 List (java.util.List)49 TypeToken (com.google.gson.reflect.TypeToken)44