Ejemplo n.º 1
0
 @Override
 protected JSONObject doInBackground(Object... params) {
   String url = (String) params[0];
   activity = (FollowGroupsCallback) params[1];
   User u = (User) params[2];
   @SuppressWarnings("unchecked")
   ArrayList<Integer> groupIds = (ArrayList<Integer>) params[3];
   JSONObject body = new JSONObject();
   try {
     body.put("user", JSONUtil.fromObjectToJSON(u));
     body.put(
         "groupIds",
         JSONUtil.fromListToJSONArray(groupIds, new TypeToken<ArrayList<Integer>>() {}));
   } catch (JSONException e1) {
     e1.printStackTrace();
   }
   return HTTPUtil.getInstance().sendRequest(url, body, true);
 }
Ejemplo n.º 2
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View editProfileView = inflater.inflate(R.layout.fragment_edit_profile, container, false);

    originSpinner = (Spinner) editProfileView.findViewById(R.id.edit_profile_earth_spinner);
    originCursor = CountryDB.getInstance().loadAllCountries();
    originAdapter =
        new SimpleCursorAdapter(
            getActivity(),
            R.layout.item_country,
            originCursor,
            new String[] {"_id", "name", "region"},
            new int[] {R.id.text_country_id, R.id.text_country_name, R.id.text_country_region},
            0);
    originSpinner.setAdapter(originAdapter);

    langSpinner = (Spinner) editProfileView.findViewById(R.id.edit_profile_lang_spinner);
    langCursor = LanguageDB.getInstance().loadAllLanguages();
    langAdapter =
        new SimpleCursorAdapter(
            getActivity(),
            R.layout.item_language,
            langCursor,
            new String[] {"_id", "name", "region"},
            new int[] {R.id.text_language_id, R.id.text_language_name, R.id.text_language_region},
            0);
    langSpinner.setAdapter(langAdapter);

    userName = (EditText) editProfileView.findViewById(R.id.edit_profile_title_text);
    userGender = (EditText) editProfileView.findViewById(R.id.edit_profile_gender_text);
    userBio = (EditText) editProfileView.findViewById(R.id.edit_profile_bio_text);
    userAge = (EditText) editProfileView.findViewById(R.id.edit_profile_age_text);

    userDNA = (EditText) editProfileView.findViewById(R.id.edit_profile_dna_text);
    userTrophy = (EditText) editProfileView.findViewById(R.id.edit_profile_trophy_text);
    userTodo = (EditText) editProfileView.findViewById(R.id.edit_profile_todo_text);
    userPhilo = (EditText) editProfileView.findViewById(R.id.edit_profile_philo_text);
    userDesc = (EditText) editProfileView.findViewById(R.id.edit_profile_desc_text);
    userInterest = (EditText) editProfileView.findViewById(R.id.edit_profile_heart_text);
    userSec = (EditText) editProfileView.findViewById(R.id.edit_profile_sec_text);

    userTags = (EditText) editProfileView.findViewById(R.id.edit_profile_tag_text);
    userLikedTags = (EditText) editProfileView.findViewById(R.id.edit_profile_like_tag_text);
    userGroups = (EditText) editProfileView.findViewById(R.id.edit_profile_group_text);

    setAvatarView = (ImageView) editProfileView.findViewById(R.id.edit_profile_icon);
    resetPasswordView = (ImageView) editProfileView.findViewById(R.id.edit_profile_password);
    moreTagsView = (TextView) editProfileView.findViewById(R.id.edit_profile_tag_more);
    moreGroupsView = (TextView) editProfileView.findViewById(R.id.edit_profile_group_more);
    moreLikedTagsView = (TextView) editProfileView.findViewById(R.id.edit_profile_like_tag_more);

    String url =
        HTTPUtil.getInstance().composePreURL(getActivity())
            + getResources().getString(R.string.url_load_users);
    User user = new User();
    user.setId(
        (String)
            SPUtil.get(getActivity(), MyApp.PREF_TYPE_LOGIN, MyApp.LOGIN_ID, "", String.class));
    new UsersAsyncTask()
        .executeOnExecutor(
            AsyncTask.THREAD_POOL_EXECUTOR, url, this, UsersAsyncTask.USER_LOAD_BY_ID, user);

    setAvatarView.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            switchCallback.setAvatarSelection();
          }
        });
    resetPasswordView.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View arg0) {
            switchCallback.resetPassword();
          }
        });
    moreTagsView.setOnClickListener(new ViewMoreClickListener(MyApp.VIEW_MORE_TAG, MORE_SELF_TAGS));
    moreLikedTagsView.setOnClickListener(
        new ViewMoreClickListener(MyApp.VIEW_MORE_TAG, MORE_LIKE_TAGS));
    moreGroupsView.setOnClickListener(
        new ViewMoreClickListener(MyApp.VIEW_MORE_GROUP, MORE_FOLLOW_GROUPS));

    return editProfileView;
  }