mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2025-10-05 21:39:50 +02:00
Fix always go to the first post in a post list in ViewPostDetailActivity.
This commit is contained in:
@@ -187,7 +187,7 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
checkNewAccountAndBindView();
|
checkNewAccountAndBindView(savedInstanceState);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTitle(String title) {
|
public void setTitle(String title) {
|
||||||
@@ -225,7 +225,7 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS
|
|||||||
applyFABTheme(fab);
|
applyFABTheme(fab);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkNewAccountAndBindView() {
|
private void checkNewAccountAndBindView(Bundle savedInstanceState) {
|
||||||
if (mNewAccountName != null) {
|
if (mNewAccountName != null) {
|
||||||
if (mAccountName == null || !mAccountName.equals(mNewAccountName)) {
|
if (mAccountName == null || !mAccountName.equals(mNewAccountName)) {
|
||||||
SwitchAccount.switchAccount(mRedditDataRoomDatabase, mCurrentAccountSharedPreferences,
|
SwitchAccount.switchAccount(mRedditDataRoomDatabase, mCurrentAccountSharedPreferences,
|
||||||
@@ -235,19 +235,22 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS
|
|||||||
|
|
||||||
mNewAccountName = null;
|
mNewAccountName = null;
|
||||||
|
|
||||||
bindView();
|
bindView(savedInstanceState);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
bindView();
|
bindView(savedInstanceState);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
bindView();
|
bindView(savedInstanceState);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void bindView() {
|
private void bindView(Bundle savedInstanceState) {
|
||||||
sectionsPagerAdapter = new SectionsPagerAdapter(this);
|
sectionsPagerAdapter = new SectionsPagerAdapter(this);
|
||||||
viewPager2.setAdapter(sectionsPagerAdapter);
|
viewPager2.setAdapter(sectionsPagerAdapter);
|
||||||
|
if (savedInstanceState == null) {
|
||||||
|
viewPager2.setCurrentItem(getIntent().getIntExtra(EXTRA_POST_LIST_POSITION, 0), false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void editComment(String commentAuthor, String commentContentMarkdown, int position) {
|
private void editComment(String commentAuthor, String commentContentMarkdown, int position) {
|
||||||
@@ -411,10 +414,14 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS
|
|||||||
public Fragment createFragment(int position) {
|
public Fragment createFragment(int position) {
|
||||||
ViewPostDetailFragment fragment = new ViewPostDetailFragment();
|
ViewPostDetailFragment fragment = new ViewPostDetailFragment();
|
||||||
Bundle bundle = new Bundle();
|
Bundle bundle = new Bundle();
|
||||||
if (posts == null) {
|
if (posts != null) {
|
||||||
bundle.putParcelable(ViewPostDetailFragment.EXTRA_POST_DATA, post);
|
|
||||||
} else {
|
|
||||||
bundle.putParcelable(ViewPostDetailFragment.EXTRA_POST_DATA, posts.get(position));
|
bundle.putParcelable(ViewPostDetailFragment.EXTRA_POST_DATA, posts.get(position));
|
||||||
|
} else {
|
||||||
|
if (post == null) {
|
||||||
|
bundle.putString(ViewPostDetailFragment.EXTRA_POST_ID, getIntent().getStringExtra(EXTRA_POST_ID));
|
||||||
|
} else {
|
||||||
|
bundle.putParcelable(ViewPostDetailFragment.EXTRA_POST_DATA, post);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
fragment.setArguments(bundle);
|
fragment.setArguments(bundle);
|
||||||
return fragment;
|
return fragment;
|
||||||
|
@@ -1006,6 +1006,12 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
|
|||||||
Bridge.clear(this);
|
Bridge.clear(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDestroy() {
|
||||||
|
EventBus.getDefault().unregister(this);
|
||||||
|
super.onDestroy();
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressLint("RestrictedApi")
|
@SuppressLint("RestrictedApi")
|
||||||
protected boolean applyMenuItemTheme(Menu menu) {
|
protected boolean applyMenuItemTheme(Menu menu) {
|
||||||
if (mCustomThemeWrapper != null) {
|
if (mCustomThemeWrapper != null) {
|
||||||
|
Reference in New Issue
Block a user