profile updater bug fix

This commit is contained in:
nuclearfog 2021-03-01 20:32:43 +01:00
parent 9fc9360856
commit 8a06d3149c
No known key found for this signature in database
GPG Key ID: D5490E4A81F97B14
3 changed files with 25 additions and 15 deletions

View File

@ -250,6 +250,9 @@ public class UserProfile extends AppCompatActivity implements OnClickListener, O
if (returnCode == RETURN_PROFILE_CHANGED) {
Object data = i.getSerializableExtra(RETURN_PROFILE_DATA);
if (data instanceof User) {
// remove blur background
toolbarBackground.setImageResource(0);
// re initialize updated user
setUser((User) data);
adapter.notifySettingsChanged();
}

View File

@ -38,7 +38,13 @@ public class UserUpdater extends AsyncTask<String, Void, User> {
@Override
protected User doInBackground(String[] param) {
try {
User user = mTwitter.updateProfile(param);
String name = param[0];
String link = param[1];
String location = param[2];
String bio = param[3];
String profileImg = param[4];
String bannerImg = param[5];
User user = mTwitter.updateProfile(name, link, location, bio, profileImg, bannerImg);
db.storeUser(user);
return user;
} catch (EngineException twException) {

View File

@ -893,23 +893,24 @@ public class TwitterEngine {
/**
* Update user profile
* update current users profile
*
* @param userParam User data
* @return updated user profile
* @throws EngineException if Access is unavailable
* @param name new username
* @param url new profile link or empty if none
* @param loc new location name or empty if none
* @param bio new bio description or empty if none
* @param profileImg local path to the profile image or null
* @param bannerImg local path to the banner image or null
* @return updated user information
* @throws EngineException if access is unavailable
*/
public User updateProfile(String[] userParam) throws EngineException {
public User updateProfile(String name, String url, String loc, String bio, String profileImg, String bannerImg) throws EngineException {
try {
if (userParam[4] != null && userParam[4].isEmpty()) {
File profileImage = new File(userParam[4]);
twitter.updateProfileImage(profileImage);
}
if (userParam[5] != null && userParam[5].isEmpty()) {
File profileBanner = new File(userParam[5]);
twitter.updateProfileBanner(profileBanner);
}
twitter4j.User user = twitter.updateProfile(userParam[0], userParam[1], userParam[2], userParam[3]);
if (profileImg != null && !profileImg.isEmpty())
twitter.updateProfileImage(new File(profileImg));
if (bannerImg != null && !bannerImg.isEmpty())
twitter.updateProfileBanner(new File(bannerImg));
twitter4j.User user = twitter.updateProfile(name, url, loc, bio);
return new User(user, twitter.getId());
} catch (Exception err) {
throw new EngineException(err);