public User getUser() { User user = new User(); user.setId( (String) SPUtil.get(getActivity(), MyApp.PREF_TYPE_LOGIN, MyApp.LOGIN_ID, "", String.class)); user.setUserName(userName.getText().toString()); user.setTimeZone(0); user.setGender(userGender.getText().toString()); String ageTxt = userAge.getText().toString(); int age = 0; try { age = Integer.parseInt(ageTxt); } catch (NumberFormatException e) { age = 0; } user.setAge(age); user.setBirthday(""); user.setCountryId(0); int homeId = originSpinner.getSelectedItemPosition() + 1; user.setHomeId(homeId); user.setBio(userBio.getText().toString()); user.setSthInteresting(userDNA.getText().toString()); user.setAmzExp(userTrophy.getText().toString()); user.setToDo(userTodo.getText().toString()); user.setPhilosophy(userPhilo.getText().toString()); user.setFriendsDesc(userDesc.getText().toString()); user.setInterest(userInterest.getText().toString()); user.setLittleSecret(userSec.getText().toString()); int langId = langSpinner.getSelectedItemPosition() + 1; user.setLangId(langId); user.setLocale(""); return user; }
@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; }