Android Open Source - game_guess_lib Guess Rest 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;
/*from   w  w w .  j  a  v  a 2 s .c  o m*/
import android.content.Context;
import android.os.AsyncTask;
import android.os.Build;

import com.wkmf.guess.lib.R;
import com.wkmf.lib.curl.Curl;
import com.wkmf.lib.curl.CurlConnection;
import com.wkmf.lib.curl.CurlListener;

import org.apache.http.NameValuePair;

import java.util.List;

/**
 * Created by ernestofndz on 9/02/14.
 */
public class GuessRestApi extends Curl{

    //private String url = "http://androidgame.eu1.frbit.net/apps/";
    private String url = "http://weguess.wkmfstudios.com/apps/";
    // REST
    private static final String REST_LEVELS = "/levels/";
    // switch mostrar dialog
    private boolean showDialog = false;


    // constructor
    public GuessRestApi(Context context, CurlListener curlListener, boolean showDialog) {
        super(context, curlListener);
        this.showDialog = showDialog;
    }

    // realizar peticion
    private void doCurl(int curlType, String rest, List<NameValuePair> nameValuePairs){
        // inicializamos el curlConnection
        setCurlConnection(
                new CurlConnection(
                        getContext(),
                        curlType,
                        getCurlListener(),
                        nameValuePairs,
                        this.showDialog,
                        getContext().getString(R.string.curl_retrieving_data)
                ));
        // realizamos la peticion
        if(Build.VERSION.SDK_INT >= 11){
            getCurlConnection().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, rest);
        }else{
            getCurlConnection().execute(rest);
        }
    }

    // peticion para recibir el json de los niveles de un determinado juego
    public void getLevels(String appId){
        doCurl(CurlConnection.CURL_GET, this.url.concat(appId).concat(REST_LEVELS), null);
    }

    // peticion para recibir el json de las preguntas de un determinado nivel
    public void getQuestions(String appId, String levelId){
        doCurl(CurlConnection.CURL_GET, this.url.concat(appId).concat(REST_LEVELS).concat(levelId), null);
    }

}




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