Fixes a crash that can occur when entering or rotating within the profile page. Closes #43
This commit is contained in:
parent
eef0f82e96
commit
5fd9b6732d
|
@ -44,6 +44,7 @@ import com.keylesspalace.tusky.entity.Relationship;
|
||||||
import com.pkmmte.view.CircularImageView;
|
import com.pkmmte.view.CircularImageView;
|
||||||
import com.squareup.picasso.Picasso;
|
import com.squareup.picasso.Picasso;
|
||||||
|
|
||||||
|
import java.text.NumberFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -72,8 +73,12 @@ public class AccountActivity extends BaseActivity {
|
||||||
setContentView(R.layout.activity_account);
|
setContentView(R.layout.activity_account);
|
||||||
ButterKnife.bind(this);
|
ButterKnife.bind(this);
|
||||||
|
|
||||||
Intent intent = getIntent();
|
if (savedInstanceState != null) {
|
||||||
accountId = intent.getStringExtra("id");
|
accountId = savedInstanceState.getString("accountId");
|
||||||
|
} else {
|
||||||
|
Intent intent = getIntent();
|
||||||
|
accountId = intent.getStringExtra("id");
|
||||||
|
}
|
||||||
|
|
||||||
SharedPreferences preferences = getSharedPreferences(
|
SharedPreferences preferences = getSharedPreferences(
|
||||||
getString(R.string.preferences_file_key), Context.MODE_PRIVATE);
|
getString(R.string.preferences_file_key), Context.MODE_PRIVATE);
|
||||||
|
@ -178,6 +183,12 @@ public class AccountActivity extends BaseActivity {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onSaveInstanceState(Bundle outState) {
|
||||||
|
outState.putString("accountId", accountId);
|
||||||
|
super.onSaveInstanceState(outState);
|
||||||
|
}
|
||||||
|
|
||||||
private void onObtainAccountSuccess(Account account) {
|
private void onObtainAccountSuccess(Account account) {
|
||||||
loadedAccount = account;
|
loadedAccount = account;
|
||||||
|
|
||||||
|
@ -213,7 +224,7 @@ public class AccountActivity extends BaseActivity {
|
||||||
.placeholder(R.drawable.account_header_missing)
|
.placeholder(R.drawable.account_header_missing)
|
||||||
.into(header);
|
.into(header);
|
||||||
|
|
||||||
java.text.NumberFormat nf = java.text.NumberFormat.getInstance();
|
NumberFormat nf = NumberFormat.getInstance();
|
||||||
|
|
||||||
// Add counts to the tabs in the TabLayout.
|
// Add counts to the tabs in the TabLayout.
|
||||||
String[] counts = {
|
String[] counts = {
|
||||||
|
|
|
@ -243,9 +243,11 @@ public class MainActivity extends BaseActivity {
|
||||||
long drawerItemIdentifier = drawerItem.getIdentifier();
|
long drawerItemIdentifier = drawerItem.getIdentifier();
|
||||||
|
|
||||||
if (drawerItemIdentifier == 0) {
|
if (drawerItemIdentifier == 0) {
|
||||||
Intent intent = new Intent(MainActivity.this, AccountActivity.class);
|
if (loggedInAccountId != null) {
|
||||||
intent.putExtra("id", loggedInAccountId);
|
Intent intent = new Intent(MainActivity.this, AccountActivity.class);
|
||||||
startActivity(intent);
|
intent.putExtra("id", loggedInAccountId);
|
||||||
|
startActivity(intent);
|
||||||
|
}
|
||||||
} else if (drawerItemIdentifier == 1) {
|
} else if (drawerItemIdentifier == 1) {
|
||||||
Intent intent = new Intent(MainActivity.this, FavouritesActivity.class);
|
Intent intent = new Intent(MainActivity.this, FavouritesActivity.class);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
|
|
|
@ -22,6 +22,7 @@ import android.support.v4.content.ContextCompat;
|
||||||
import android.support.v7.widget.RecyclerView;
|
import android.support.v7.widget.RecyclerView;
|
||||||
import android.text.SpannableStringBuilder;
|
import android.text.SpannableStringBuilder;
|
||||||
import android.text.Spanned;
|
import android.text.Spanned;
|
||||||
|
import android.text.style.StyleSpan;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
@ -261,7 +262,7 @@ class NotificationsAdapter extends RecyclerView.Adapter implements AdapterItemRe
|
||||||
}
|
}
|
||||||
String wholeMessage = String.format(format, displayName);
|
String wholeMessage = String.format(format, displayName);
|
||||||
final SpannableStringBuilder str = new SpannableStringBuilder(wholeMessage);
|
final SpannableStringBuilder str = new SpannableStringBuilder(wholeMessage);
|
||||||
str.setSpan(new android.text.style.StyleSpan(Typeface.BOLD), 0, displayName.length(),
|
str.setSpan(new StyleSpan(Typeface.BOLD), 0, displayName.length(),
|
||||||
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||||
message.setText(str);
|
message.setText(str);
|
||||||
statusContent.setText(status.content);
|
statusContent.setText(status.content);
|
||||||
|
|
Loading…
Reference in New Issue