|
6 | 6 | import android.support.v4.app.FragmentTransaction;
|
7 | 7 | import android.support.v7.widget.Toolbar;
|
8 | 8 | import android.text.TextUtils;
|
9 |
| -import android.util.Log; |
10 | 9 | import android.view.View;
|
11 | 10 | import android.widget.ImageView;
|
12 | 11 | import android.widget.TextView;
|
@@ -68,6 +67,8 @@ public class BlogContentActivity extends SwipeBackBaseActivity {
|
68 | 67 | private BlogShareDialog mShareDialog;
|
69 | 68 | private BlogBean mBlog;
|
70 | 69 | private BlogType mBlogType;
|
| 70 | + private BlogCommentFragment mBlogCommentFragment; |
| 71 | + private BlogContentFragment mBlogContentFragment; |
71 | 72 |
|
72 | 73 | @Override
|
73 | 74 | protected void onCreate(@Nullable Bundle savedInstanceState) {
|
@@ -118,12 +119,16 @@ protected void onViewSourceClick() {
|
118 | 119 | RaeImageLoader.displayHeaderImage(mBlog.getAvatar(), mAvatarView);
|
119 | 120 | mAuthorView.setText(mBlog.getAuthor());
|
120 | 121 | }
|
| 122 | + // 评论 |
| 123 | + mBlogCommentFragment = BlogCommentFragment.newInstance(mBlog, mBlogType); |
| 124 | + // 内容 |
| 125 | + mBlogContentFragment = BlogContentFragment.newInstance(mBlog, mBlogType); |
121 | 126 |
|
122 | 127 |
|
123 | 128 | // 加载Fragment
|
124 | 129 | FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
|
125 |
| - transaction.add(R.id.fl_comment, BlogCommentFragment.newInstance(mBlog, mBlogType)); |
126 |
| - transaction.add(R.id.fl_content, BlogContentFragment.newInstance(mBlog, mBlogType)); |
| 130 | + transaction.add(R.id.fl_comment, mBlogCommentFragment); |
| 131 | + transaction.add(R.id.fl_content, mBlogContentFragment); |
127 | 132 | transaction.commit();
|
128 | 133 |
|
129 | 134 | }
|
@@ -166,13 +171,10 @@ public void onActionBarClick() {
|
166 | 171 | }
|
167 | 172 |
|
168 | 173 | if (mCommentLayout.getVisibility() == View.VISIBLE) {
|
169 |
| - BlogCommentFragment fragment = (BlogCommentFragment) fragments.get(0); |
170 |
| - fragment.scrollToTop(); |
| 174 | + mBlogCommentFragment.scrollToTop(); |
171 | 175 | } else {
|
172 |
| - BlogContentFragment fragment = (BlogContentFragment) fragments.get(1); |
173 |
| - fragment.scrollToTop(); |
| 176 | + mBlogContentFragment.scrollToTop(); |
174 | 177 | }
|
175 |
| - |
176 | 178 | }
|
177 | 179 |
|
178 | 180 |
|
|
0 commit comments