Android Open Source - game_guess_lib Guess Api






From Project

Back to project page game_guess_lib.

License

The source code is released under:

MIT License

If you think the Android project game_guess_lib listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.wkmf.guess.lib.common.api;
/*  ww w  . j  av a  2 s  . c  o m*/
import com.wkmf.guess.lib.structure.GuessConfig;
import com.wkmf.guess.lib.structure.GuessGame;
import com.wkmf.guess.lib.structure.GuessLevel;
import com.wkmf.guess.lib.structure.GuessQuestion;

import org.codehaus.jackson.map.DeserializationConfig;
import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.map.ObjectWriter;
import org.codehaus.jackson.type.TypeReference;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by ernestofndz on 12/02/14.
 */
public class GuessApi {

    // JSON -> Obj
    public static GuessGame fromJsonGuessGame(String json) {
        GuessGame guessGame = null;
        try {
            ObjectMapper mapper = new ObjectMapper().configure(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true);
            guessGame = mapper.readValue(json, new TypeReference<GuessGame>() {
            });
        } catch (IOException ioe) {
            ioe.printStackTrace();
        }
        return guessGame;
    }

    // Obj -> JSON
    public static String toJsonGuessGame(GuessGame guessGame) {
        String json = null;
        try {
            ObjectWriter ow = new ObjectMapper().writer().withDefaultPrettyPrinter();
            json = ow.writeValueAsString(guessGame);
        } catch (IOException ioe) {
            ioe.printStackTrace();
        }
        return json;
    }

    // JSON -> Config
    public static GuessConfig fromJsonGuessConfig(String json) {
        GuessConfig guessConfig = null;
        try {
            ObjectMapper mapper = new ObjectMapper().configure(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true);
            guessConfig = mapper.readValue(json, new TypeReference<GuessConfig>() {
            });
        } catch (IOException ioe) {
            ioe.printStackTrace();
        }
        return guessConfig;
    }

    // Config -> JSON
    public static String toJsonGuessConfig(GuessConfig guessConfig) {
        String json = null;
        try {
            ObjectWriter ow = new ObjectMapper().writer().withDefaultPrettyPrinter();
            json = ow.writeValueAsString(guessConfig);
        } catch (IOException ioe) {
            ioe.printStackTrace();
        }
        return json;
    }

    // JSON -> Levels
    public static List<GuessLevel> toLevels(String json) {
        List<GuessLevel> levels = null;
        try {
            ObjectMapper mapper = new ObjectMapper().configure(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true);
            levels = mapper.readValue(json, new TypeReference<ArrayList<GuessLevel>>() {
            });
        } catch (IOException ioe) {
            ioe.printStackTrace();
        }
        return levels;
    }

    // JSON -> Questions
    public static List<GuessQuestion> toQuestions(String json) {
        List<GuessQuestion> questions = null;
        try {
            ObjectMapper mapper = new ObjectMapper().configure(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true);
            questions = mapper.readValue(json, new TypeReference<ArrayList<GuessQuestion>>() {
            });
        } catch (IOException ioe) {
            ioe.printStackTrace();
        }
        return questions;
    }
}




Java Source Code List

com.android.vending.billing.util.Base64DecoderException.java
com.android.vending.billing.util.Base64.java
com.android.vending.billing.util.IabException.java
com.android.vending.billing.util.IabHelper.java
com.android.vending.billing.util.IabResult.java
com.android.vending.billing.util.Inventory.java
com.android.vending.billing.util.Purchase.java
com.android.vending.billing.util.Security.java
com.android.vending.billing.util.SkuDetails.java
com.wkmf.guess.lib.common.Constants.java
com.wkmf.guess.lib.common.ads.GuessGameAdsListener.java
com.wkmf.guess.lib.common.ads.GuessGameAds.java
com.wkmf.guess.lib.common.api.GuessApi.java
com.wkmf.guess.lib.common.api.GuessRestApi.java
com.wkmf.guess.lib.common.async.DownloadTask.java
com.wkmf.guess.lib.common.dialog.DialogElement.java
com.wkmf.guess.lib.common.dialog.DialogModalListAdapter.java
com.wkmf.guess.lib.common.dialog.DialogModal.java
com.wkmf.guess.lib.data.GuessGameBDDHandler.java
com.wkmf.guess.lib.data.GuessSQL.java
com.wkmf.guess.lib.impl.GuessGameBaseApp.java
com.wkmf.guess.lib.impl.GuessGameImageDownload.java
com.wkmf.guess.lib.impl.GuessGameInterface.java
com.wkmf.guess.lib.purchase.items.GuessGameItems.java
com.wkmf.guess.lib.screen.GuessLevelScreen.java
com.wkmf.guess.lib.screen.GuessMainScreen.java
com.wkmf.guess.lib.screen.GuessQuestionScreen.java
com.wkmf.guess.lib.screen.adapter.LevelsAdapter.java
com.wkmf.guess.lib.screen.adapter.QuestionsAdapter.java
com.wkmf.guess.lib.service.GuessGameService.java
com.wkmf.guess.lib.service.GuessGameUpdater.java
com.wkmf.guess.lib.service.ServiceStarter.java
com.wkmf.guess.lib.structure.GuessConfig.java
com.wkmf.guess.lib.structure.GuessDrawable.java
com.wkmf.guess.lib.structure.GuessGame.java
com.wkmf.guess.lib.structure.GuessLevelType.java
com.wkmf.guess.lib.structure.GuessLevel.java
com.wkmf.guess.lib.structure.GuessQuestion.java