示例#1
0
    @Override
    protected User doInBackground(Boolean... params) {

      if (params[0]) {
        JSONObject object = new JSONObject();
        try {
          object.put("action", "loginemail");
          object.put("userEmail", "001");
          object.put("userPassword", "001");
          SharedPreferences prefs =
              getSharedPreferences("wxm.com.androiddesign", Context.MODE_PRIVATE);
          SharedPreferences.Editor editor = prefs.edit();
          editor.putString("UserId", "001");
          editor.putString("UserPassword", "001");
          editor.putBoolean("isSignup", false);
          editor.apply();
          String userJson = JsonConnection.getJSON(object.toString());
          return new Gson().fromJson(userJson, User.class);
        } catch (JSONException e) {
          e.printStackTrace();
        }
      }
      SharedPreferences prefs = getSharedPreferences("wxm.com.androiddesign", Context.MODE_PRIVATE);
      String type = prefs.getString("LoginType", "email");
      String name = prefs.getString("UserId", "001");
      String email = prefs.getString("UserEmail", "");
      String password = prefs.getString("UserPassword", "001");
      JSONObject object = new JSONObject();
      try {
        if (type.equals(MyUser.EMAIL)) {
          object.put("action", "loginemail");
          object.put("userEmail", email);
          object.put("userPassword", password);
        } else if (MyUser.SINA.equals(type)) {
          object.put("action", "loginsina");
          object.put("userId", name);
        } else if (MyUser.QQ.equals(type)) {
          object.put("action", "loginqq");
          object.put("userId", name);
        }
        Log.d(TAG, object.toString());

        String userJson = JsonConnection.getJSON(object.toString());
        Log.d(TAG, userJson);
        if (userJson.contains("false")) {
          return null;
        }
        return new Gson().fromJson(userJson, User.class);
      } catch (JSONException e) {
        e.printStackTrace();
      }
      return null;
    }
示例#2
0
 @Override
 protected Void doInBackground(String... params) {
   JSONObject object = new JSONObject();
   try {
     object = new JSONObject();
     object.put("action", "editAlbumRight");
     object.put("userId", MyUser.userId);
     object.put("userAlbumIsPublic", params[0]);
   } catch (JSONException e) {
     e.printStackTrace();
   }
   String json = JsonConnection.getJSON(object.toString());
   Log.i("mjson", json);
   return null;
 }
示例#3
0
    @Override
    protected Boolean doInBackground(Void... params) {

      JSONObject object = new JSONObject();
      try {
        object.put("action", "showCredit");

        object.put("userId", userId);
      } catch (JSONException e) {
        e.printStackTrace();
      }
      String json = JsonConnection.getJSON(object.toString());

      scoreList = new Gson().fromJson(json, new TypeToken<List<Score>>() {}.getType());
      return null;
    }