also show info on rotation

This commit is contained in:
tobiaskaminsky 2018-01-04 07:29:42 +01:00 committed by tobiasKaminsky
parent 2a39e00f3b
commit 44c1c725c0
No known key found for this signature in database
GPG key ID: 0E00D4D47D0C5AF7

View file

@ -207,8 +207,6 @@ public class UserInfoActivity extends FileActivity {
if (userInfo != null) { if (userInfo != null) {
populateUserInfoUi(userInfo); populateUserInfoUi(userInfo);
emptyContentContainer.setVisibility(View.GONE);
userInfoView.setVisibility(View.VISIBLE);
} else { } else {
setMultiListLoadingMessage(); setMultiListLoadingMessage();
fetchAndSetData(); fetchAndSetData();
@ -320,39 +318,36 @@ public class UserInfoActivity extends FileActivity {
} }
private void populateUserInfoUi(UserInfo userInfo) { private void populateUserInfoUi(UserInfo userInfo) {
if (userInfo.getPhone() == null && userInfo.getEmail() == null && userInfo.getAddress() == null
&& userInfo.getTwitter() == null & userInfo.getWebpage() == null) {
setErrorMessageForMultiList(getString(R.string.userinfo_no_info_headline),
getString(R.string.userinfo_no_info_text));
} else {
emptyContentContainer.setVisibility(View.GONE);
userInfoView.setVisibility(View.VISIBLE);
userName.setText(account.name); userName.setText(account.name);
DisplayUtils.setAvatar(account, UserInfoActivity.this, DisplayUtils.setAvatar(account, UserInfoActivity.this,
mCurrentAccountAvatarRadiusDimension, getResources(), getStorageManager(), avatar); mCurrentAccountAvatarRadiusDimension, getResources(), getStorageManager(), avatar);
int tint = ThemeUtils.primaryColor(account); int tint = ThemeUtils.primaryColor(account);
if (userInfo != null) {
if (!TextUtils.isEmpty(userInfo.getDisplayName())) { if (!TextUtils.isEmpty(userInfo.getDisplayName())) {
fullName.setText(userInfo.getDisplayName()); fullName.setText(userInfo.getDisplayName());
} }
populateUserInfoElement(mPhoneNumberContainer, mPhoneNumberTextView, userInfo.getPhone(), populateUserInfoElement(mPhoneNumberContainer, mPhoneNumberTextView, userInfo.getPhone(), mPhoneNumberIcon,
mPhoneNumberIcon, tint); tint);
populateUserInfoElement(mEmailContainer, mEmailAddressTextView, userInfo.getEmail(), mEmailIcon, tint); populateUserInfoElement(mEmailContainer, mEmailAddressTextView, userInfo.getEmail(), mEmailIcon, tint);
populateUserInfoElement(mAddressContainer, mAddressTextView, userInfo.getAddress(), mAddressIcon, tint); populateUserInfoElement(mAddressContainer, mAddressTextView, userInfo.getAddress(), mAddressIcon, tint);
populateUserInfoElement(mWebsiteContainer, mWebsiteTextView,
populateUserInfoElement( DisplayUtils.beautifyURL(userInfo.getWebpage()), mWebsiteIcon, tint);
mWebsiteContainer, populateUserInfoElement(mTwitterContainer, mTwitterHandleTextView,
mWebsiteTextView, DisplayUtils.beautifyTwitterHandle(userInfo.getTwitter()), mTwitterIcon, tint);
DisplayUtils.beautifyURL(userInfo.getWebpage()),
mWebsiteIcon,
tint);
populateUserInfoElement(
mTwitterContainer,
mTwitterHandleTextView,
DisplayUtils.beautifyTwitterHandle(userInfo.getTwitter()),
mTwitterIcon,
tint);
} }
} }
private void populateUserInfoElement(View container, TextView textView, String text, ImageView icon, @ColorInt int private void populateUserInfoElement(View container, TextView textView, String text, ImageView icon,
tint) { @ColorInt int tint) {
if (!TextUtils.isEmpty(text)) { if (!TextUtils.isEmpty(text)) {
textView.setText(text); textView.setText(text);
DrawableCompat.setTint(icon.getDrawable(), tint); DrawableCompat.setTint(icon.getDrawable(), tint);
@ -471,18 +466,8 @@ public class UserInfoActivity extends FileActivity {
if (result.isSuccess() && result.getData() != null) { if (result.isSuccess() && result.getData() != null) {
userInfo = (UserInfo) result.getData().get(0); userInfo = (UserInfo) result.getData().get(0);
if (userInfo.getPhone() == null && userInfo.getEmail() == null && userInfo.getAddress() == null runOnUiThread(() -> populateUserInfoUi(userInfo));
&& userInfo.getTwitter() == null & userInfo.getWebpage() == null) {
runOnUiThread(() -> setErrorMessageForMultiList(getString(R.string.userinfo_no_info_headline),
getString(R.string.userinfo_no_info_text)));
} else {
runOnUiThread(() -> {
populateUserInfoUi(userInfo);
emptyContentContainer.setVisibility(View.GONE);
userInfoView.setVisibility(View.VISIBLE);
});
}
} else { } else {
// show error // show error
runOnUiThread(() -> setErrorMessageForMultiList(sorryMessage, result.getLogMessage())); runOnUiThread(() -> setErrorMessageForMultiList(sorryMessage, result.getLogMessage()));