TopicDetailActivity.java 24.3 KB
Newer Older
konghaorui committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
package com.yidianling.dynamic.topic.topicDetail;

import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.ObjectAnimator;
import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.design.widget.AppBarLayout;
import android.support.design.widget.CollapsingToolbarLayout;
import android.support.design.widget.FloatingActionButton;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.view.KeyEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.umeng.socialize.bean.SHARE_MEDIA;
import com.ydl.webview.H5Params;
import com.ydl.webview.NewH5Activity;
import com.ydl.ydl_image.module.GlideApp;
import com.ydl.ydlcommon.actions.share.ShareUtils;
import com.ydl.ydlcommon.base.BaseMvpActivity;
import com.ydl.ydlcommon.ui.LogoLoadingView;
import com.ydl.ydlcommon.utils.BuryPointUtils;
konghaorui committed
43
import com.ydl.ydlcommon.utils.StatusBarUtils;
konghaorui committed
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152
import com.yidianling.common.tools.LogUtil;
import com.yidianling.dynamic.DynamicConstants;
import com.yidianling.dynamic.R;
import com.yidianling.dynamic.R2;
import com.yidianling.dynamic.adapter.TopicDetailMemberAdapter;
import com.yidianling.dynamic.model.Focus;
import com.yidianling.dynamic.model.TopicDetailBean;
import com.yidianling.dynamic.publishTrend.PublishTrendActivity;
import com.yidianling.dynamic.router.DynamicIn;
import com.yidianling.dynamic.trendList.TrendListInFragment;
import com.yidianling.dynamic.trendList.adapter.RecommendTopAdapter;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;


/**
 * 话题详情页
 * Refactor by Jim on 2017/12/27 0027.
 */
@Route(path = "/topic/detail")
public class TopicDetailActivity extends BaseMvpActivity<TopicDetailView, TopicDetailPresenterImpl> implements SwipeRefreshLayout.OnRefreshListener, TopicDetailView {


    @BindView(R2.id.topic_detail_top_bg_iv)
    ImageView mTopicDetailTopBgIv;
    @BindView(R2.id.topic_detail_title_tv)
    TextView mTopicDetailTitleTv;
    @BindView(R2.id.topic_detail_survey_tv)
    TextView mTopicDetailSurveyTv;
    @BindView(R2.id.topic_detail_visit_num_tv)
    TextView mTopicDetailVisitNumTv;
    @BindView(R2.id.topic_detail_visit_zj_tv)
    TextView mTopicDetailVisitZjTv;
    @BindView(R2.id.topic_detail_trend_num_tv)
    TextView mTopicDetailTrendNumTv;
    @BindView(R2.id.topic_detail_focus_tv)
    TextView mTopicDetailFocusTv;
    @BindView(R2.id.topic_detail_users_num_tv)
    TextView mTopicDetailUsersNumTv;
    @BindView(R2.id.topic_detail_users_rcv)
    RecyclerView mTopicDetailUsersRcv;
    @BindView(R2.id.topic_detail_users_rel)
    RelativeLayout mTopicDetailUsersRel;
    @BindView(R2.id.topic_detail_top_rel)
    RelativeLayout mTopicDetailTopRel;
    @BindView(R2.id.item_topic_detail_new_tv)
    TextView mItemTopicDetailNewTv;
    @BindView(R2.id.item_topic_detail_new_hint_tv)
    View mItemTopicDetailNewHintTv;
    @BindView(R2.id.item_topic_detail_new_rel)
    RelativeLayout mItemTopicDetailNewRel;
    @BindView(R2.id.item_topic_detail_hot_tv)
    TextView mItemTopicDetailHotTv;
    @BindView(R2.id.item_topic_detail_hot_hint_tv)
    View mItemTopicDetailHotHintTv;
    @BindView(R2.id.item_topic_detail_hot_rel)
    RelativeLayout mItemTopicDetailHotRel;
    @BindView(R2.id.topic_detail_type_lin)
    LinearLayout mTopicDetailTypeLin;
    @BindView(R2.id.app_bar)
    AppBarLayout mAppBar;
    @BindView(R2.id.topic_detail_vp)
    ViewPager mTopicDetailVp;
    @BindView(R2.id.swl)
    SwipeRefreshLayout mSwl;
    @BindView(R2.id.toolbar)
    Toolbar mToolbar;
    @BindView(R2.id.collapsingToolbarLayout)
    CollapsingToolbarLayout collapsingToolbarLayout;
    @BindView(R2.id.mine_next_iv)
    ImageView mMineNextIv;
    @BindView(R2.id.topic_detail_title_back_iv)
    ImageView mTopicDetailTitleBackIv;
    @BindView(R2.id.topic_detail_title_top_right_tv)
    ImageView mTopicDetailTitleTopRightTv;
    @BindView(R2.id.publish_trend_btn)
    FloatingActionButton mPublishTrendBtn;
    @BindView(R2.id.top_trends_rcv)
    RecyclerView topTrendsRcv;
    @BindView(R2.id.divide_line)
    View divideLine;
    @BindView(R2.id.v_loading)
    LogoLoadingView vLoading;


    private TopicDetailMemberAdapter adapter;
    private Fragment[] mFragments;
    String topicId, topicTitle;
    boolean isSplash;
    private int totalMembers;
    private int backgroundColor;
    private int selectTab;
    private RecommendTopAdapter mRecommendTopAdapter;

    private static final String IS_SPLASH = "isSplash";
    private static final String TOPIC_ID = "topic_id";

    public static Intent newIntent(Context context, boolean isSplash, String topicId) {
        Intent intent = new Intent(context, TopicDetailActivity.class);
        intent.putExtra(IS_SPLASH, isSplash);
        intent.putExtra(TOPIC_ID, topicId);
        return intent;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
konghaorui committed
153
        setContentView(R.layout.dynamic_activity_topic_detail);
konghaorui committed
154 155 156 157 158
        ButterKnife.bind(this);
        initDatas();
        initViews();
        fetchDatas();
        initNetLossView();
konghaorui committed
159
        StatusBarUtils.Companion.setCustomStatusView(this,mToolbar,true);
konghaorui committed
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183
    }

    private void initNetLossView() {
        vLoading.setListener(new LogoLoadingView.LogoLoadingListener() {
            @Override
            public void onDataResetClick() {
                vLoading.setVisibility(View.VISIBLE);
                vLoading.setViewType(LogoLoadingView.TYPE_LOADING, null);

                initDatas();
                initViews();
                fetchDatas();
            }

            @Override
            public void onBackClick() {
                finish();
            }
        });
    }

    private void initViews() {
        setSupportActionBar(mToolbar);
        mSwl.setOnRefreshListener(this);
konghaorui committed
184
        mSwl.setColorSchemeResources(R.color.dynamic_main_theme);
konghaorui committed
185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237
        mSwl.setProgressViewOffset(false, 0, 200);
        topTrendsRcv.setLayoutManager(new LinearLayoutManager(this));
        topTrendsRcv.setAdapter(mRecommendTopAdapter);
        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
        linearLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
        mTopicDetailUsersRcv.setLayoutManager(linearLayoutManager);
        mTopicDetailUsersRcv.setAdapter(adapter);
        mTopicDetailVp.setAdapter(new FragmentPagerAdapter(getSupportFragmentManager()) {
            @Override
            public Fragment getItem(int position) {
                return mFragments[position];
            }

            @Override
            public int getCount() {
                return mFragments.length;
            }
        });
        mTopicDetailVp.setOffscreenPageLimit(2);
        mTopicDetailVp.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
            @Override
            public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

            }

            @Override
            public void onPageSelected(int position) {
                switch (position) {
                    case 0:
                        setTabSelection(0);
                        break;
                    case 1:
                        setTabSelection(1);
                        break;

                }
            }

            @Override
            public void onPageScrollStateChanged(int state) {

            }
        });
        mAppBar.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() {
            @Override
            public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
                if (verticalOffset == 0) {
                    mSwl.setEnabled(true);
                } else {
                    mSwl.setEnabled(false);
                }
                LogUtil.d("tool bar size: " + mToolbar.getHeight());
                if (verticalOffset <= (-appBarLayout.getTotalScrollRange() + mToolbar.getHeight() / 2)) {
konghaorui committed
238 239
                    if (backgroundColor != R.color.dynamic_white) {
                        mToolbar.setBackgroundColor(getResources().getColor(R.color.dynamic_white));
konghaorui committed
240
                        alPhaAnimation(mToolbar, 0, 1, null);
konghaorui committed
241
                        mTopicDetailTitleBackIv.setImageResource(R.drawable.platform_common_back);
konghaorui committed
242
                        mTopicDetailTitleTopRightTv.setImageResource(R.drawable.platform_common_notice_more_un);
konghaorui committed
243
                        backgroundColor = R.color.dynamic_white;
konghaorui committed
244 245 246
                    }
                    collapsingToolbarLayout.setTitle(topicTitle);
                    //使用下面两个CollapsingToolbarLayout的方法设置展开透明->折叠时你想要的颜色
konghaorui committed
247 248
                    collapsingToolbarLayout.setExpandedTitleColor(getResources().getColor(R.color.dynamic_transparent));
                    collapsingToolbarLayout.setCollapsedTitleTextColor(getResources().getColor(R.color.dynamic_black));
konghaorui committed
249 250
                } else if (verticalOffset >= -appBarLayout.getTotalScrollRange() / 5) {
                    collapsingToolbarLayout.setTitle("");
konghaorui committed
251
                    if (backgroundColor != R.color.dynamic_transparent) {
konghaorui committed
252 253 254 255
                        alPhaAnimation(mToolbar, 1, 0f, new AnimatorListenerAdapter() {
                            @Override
                            public void onAnimationEnd(Animator animation) {
                                super.onAnimationEnd(animation);
konghaorui committed
256
                                mToolbar.setBackgroundColor(getResources().getColor(R.color.dynamic_transparent));
konghaorui committed
257
                                mToolbar.setAlpha(1f);
konghaorui committed
258 259
                                mTopicDetailTitleBackIv.setImageResource(R.drawable.dynamic_titlebar_back2);
                                mTopicDetailTitleTopRightTv.setImageResource(R.drawable.dynamic_more_green2);
konghaorui committed
260 261
                            }
                        });
konghaorui committed
262
                        backgroundColor = R.color.dynamic_transparent;
konghaorui committed
263 264
                    }
                } else {
konghaorui committed
265 266
                    if (backgroundColor != R.color.dynamic_transparent) {
                        mToolbar.setBackgroundColor(getResources().getColor(R.color.dynamic_transparent));
konghaorui committed
267
                        mToolbar.setAlpha(1f);
konghaorui committed
268 269 270
                        mTopicDetailTitleBackIv.setImageResource(R.drawable.dynamic_titlebar_back2);
                        mTopicDetailTitleTopRightTv.setImageResource(R.drawable.dynamic_more_green2);
                        backgroundColor = R.color.dynamic_transparent;
konghaorui committed
271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378
                    }
                    collapsingToolbarLayout.setTitle("");
                }
            }
        });
    }

    private void alPhaAnimation(View v, float originAlpha, float desAlpha, @Nullable AnimatorListenerAdapter listener) {
        ObjectAnimator animator = ObjectAnimator.ofFloat(v, "alpha", originAlpha, desAlpha);
        animator.setDuration(200);
        animator.start();
        if (listener != null) {
            animator.addListener(listener);
        }
    }

    private void initDatas() {
        selectTab = 0;
        backgroundColor = -1;
        totalMembers = 0;
        topicId = getIntent().getStringExtra("topic_id");
        isSplash = getIntent().getBooleanExtra("isSplash", false);
        adapter = new TopicDetailMemberAdapter(this);
        mFragments = new Fragment[]{TrendListInFragment.newInstance("1", topicId, "default", "0"),
                TrendListInFragment.newInstance("2", topicId, "default", "0")};
        mRecommendTopAdapter = new RecommendTopAdapter(this);
    }

    @NonNull
    @Override
    public TopicDetailPresenterImpl createPresenter() {
        return new TopicDetailPresenterImpl();
    }


    @Override
    public void onRefresh() {
        mSwl.setRefreshing(true);
        fetchDatas();
        if (selectTab == 0) {
            LogUtil.d("send to refresh");
            Message message = mHandler1.obtainMessage(DynamicConstants.TOPIC_DETAIL_NEW_REFRESH, topicId);
            message.sendToTarget();
        } else if (selectTab == 1) {
            LogUtil.d("send to refresh");
            Message message = mHandler2.obtainMessage(DynamicConstants.TOPIC_DETAIL_HOT_REFRESH, topicId);
            message.sendToTarget();
        }
    }

    private Handler mHandler1;
    private Handler mHandler2;

    public void setHandler(Handler handler, String tab) {
        LogUtil.d("tab: " + tab);
        if (tab.equals("1")) {
            mHandler1 = handler;
        } else if (tab.equals("2")) {
            mHandler2 = handler;
        }
    }


    @OnClick({R2.id.item_topic_detail_new_rel, R2.id.item_topic_detail_hot_rel, R2.id.publish_trend_btn, R2.id.topic_detail_focus_tv,
            R2.id.topic_detail_users_rel, R2.id.topic_detail_title_top_right_tv, R2.id.topic_detail_title_back_iv})
    void doClick(View view) {
        if (view.getId() == R.id.item_topic_detail_new_rel) {
            mTopicDetailVp.setCurrentItem(0);
            setTabSelection(0);
        } else if (view.getId() == R.id.item_topic_detail_hot_rel) {

            mTopicDetailVp.setCurrentItem(1);
            setTabSelection(1);
        } else if (view.getId() == R.id.publish_trend_btn) {
            if (!DynamicIn.INSTANCE.isLogin()) {
                startActivity(DynamicIn.INSTANCE.loginWayIntent(TopicDetailActivity.this));
            } else {
                Intent intent = new Intent();
                intent.setClass(TopicDetailActivity.this, PublishTrendActivity.class);
                Bundle bundle = new Bundle();
                bundle.putString(DynamicConstants.PUBLISH_TYPE, "topic_publish");
                bundle.putString("topic_id", topicId);
                bundle.putString("topic_title", topicTitle);
                intent.putExtra("bundle", bundle);
                startActivity(intent);
            }
        } else if (view.getId() == R.id.topic_detail_focus_tv) {
            if (!DynamicIn.INSTANCE.isLogin()) {
                startActivity(DynamicIn.INSTANCE.loginWayIntent(TopicDetailActivity.this));
            } else {
                getPresenter().focusTopic(topicId);
            }
        } else if (view.getId() == R.id.topic_detail_users_rel) {
            String url = DynamicConstants.Companion.getTOPIC_DETAIL_H5() + topicId;
            NewH5Activity.start(getMContext(), new H5Params(url, null));
        } else if (view.getId() == R.id.topic_detail_title_top_right_tv) {
            if (share == null) {
                return;
            }
            ShowCustomShareDialog(share.title, share.shareUrl, share.desc, share.cover);
        } else if (view.getId() == R.id.topic_detail_title_back_iv) {

            back();
        }
    }

    private void back() {
        if (isSplash) {
konghaorui committed
379
            DynamicIn.INSTANCE.mainIntent(this);
konghaorui committed
380 381 382 383 384 385 386 387 388 389 390 391 392 393 394
        }
        finish();
    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_BACK) {
            back();
            return true;
        }
        return super.onKeyDown(keyCode, event);
    }


    private void ShowCustomShareDialog(final String share_title, final String share_url, final String share_context, final String share_head) {
konghaorui committed
395
        View view = getLayoutInflater().inflate(R.layout.dynamic_share_select_dialog,
konghaorui committed
396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439
                null);
        final Dialog dialog = new Dialog(this,
                R.style.transparentFrameWindowStyle);
        dialog.setContentView(view, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.WRAP_CONTENT));
        Window window = dialog.getWindow();
        // 设置显示动画
        window.setWindowAnimations(R.style.main_menu_animstyle);
        WindowManager.LayoutParams wl = window.getAttributes();
        wl.x = 0;
        wl.y = getWindowManager().getDefaultDisplay().getHeight();
        // 以下这两句是为了保证按钮可以水平满屏
        wl.width = ViewGroup.LayoutParams.MATCH_PARENT;
        wl.height = ViewGroup.LayoutParams.WRAP_CONTENT;
        // 设置显示位置
        dialog.onWindowAttributesChanged(wl);
        // 设置点击外围解散
        dialog.setCanceledOnTouchOutside(true);
        LinearLayout wechat_lin = (LinearLayout) view.findViewById(R.id.share_weichat);
        LinearLayout pyq_lin = (LinearLayout) view.findViewById(R.id.share_pyq);
        LinearLayout qqzone_lin = (LinearLayout) view.findViewById(R.id.share_qqzone);
        LinearLayout qq_lin = (LinearLayout) view.findViewById(R.id.share_qq);
        LinearLayout backhome_lin = (LinearLayout) view.findViewById(R.id.share_back_home);
        if (!TopicDetailActivity.this.isFinishing() && !dialog.isShowing()) {
            dialog.show();
        }
        wechat_lin.setOnClickListener(v -> {
            ShareUtils.INSTANCE.shareTo(SHARE_MEDIA.WEIXIN, TopicDetailActivity.this, share_title, share_url, share_context, share_head);
            dialog.dismiss();
        });

        pyq_lin.setOnClickListener(v -> {
            ShareUtils.INSTANCE.shareTo(SHARE_MEDIA.WEIXIN_CIRCLE, TopicDetailActivity.this, share_title, share_url, share_context, share_head);
            dialog.dismiss();
        });
        qqzone_lin.setOnClickListener(v -> {
            ShareUtils.INSTANCE.shareTo(SHARE_MEDIA.QZONE, TopicDetailActivity.this, share_title, share_url, share_context, share_head);
            dialog.dismiss();
        });
        qq_lin.setOnClickListener(v -> {
            ShareUtils.INSTANCE.shareTo(SHARE_MEDIA.QQ, TopicDetailActivity.this, share_title, share_url, share_context, share_head);
            dialog.dismiss();
        });
        backhome_lin.setOnClickListener(v -> {
konghaorui committed
440
            DynamicIn.INSTANCE.mainIntent(this);
konghaorui committed
441 442 443 444 445
            dialog.dismiss();
        });
    }

    private void resetText() {
konghaorui committed
446 447 448 449
        mItemTopicDetailNewTv.setTextColor(getResources().getColor(R.color.dynamic_text_gray));
        mItemTopicDetailNewHintTv.setBackgroundColor(getResources().getColor(R.color.dynamic_white));
        mItemTopicDetailHotTv.setTextColor(getResources().getColor(R.color.dynamic_text_gray));
        mItemTopicDetailHotHintTv.setBackgroundColor(getResources().getColor(R.color.dynamic_white));
konghaorui committed
450 451 452 453 454 455 456 457 458 459 460
    }

    private void setTabSelection(int index) {
        // 重置按钮
        resetText();
        switch (index) {
            case 0:
                if (mTopicDetailVp.getCurrentItem() != 0) {
                    mTopicDetailVp.setCurrentItem(0);
                }
                selectTab = 0;
konghaorui committed
461 462
                mItemTopicDetailNewTv.setTextColor(getResources().getColor(R.color.dynamic_main_theme));
                mItemTopicDetailNewHintTv.setBackgroundColor(getResources().getColor(R.color.dynamic_main_theme));
konghaorui committed
463 464 465 466 467 468
                break;
            case 1:
                if (mTopicDetailVp.getCurrentItem() != 1) {
                    mTopicDetailVp.setCurrentItem(1);
                }
                selectTab = 1;
konghaorui committed
469 470
                mItemTopicDetailHotTv.setTextColor(getResources().getColor(R.color.dynamic_main_theme));
                mItemTopicDetailHotHintTv.setBackgroundColor(getResources().getColor(R.color.dynamic_main_theme));
konghaorui committed
471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497
                break;

        }
    }

    private void fetchDatas() {
        getPresenter().getTopicDetail(topicId);
    }

    @Override
    public void showToast(String msg) {
    }

    private TopicDetailBean.Share share;

    @Override
    public void showTopicHeadDetail(TopicDetailBean topicDetail) {
        topicTitle = topicDetail.topic.title;
        totalMembers = topicDetail.totalMembers;
        String is_focused = topicDetail.topic.isFocused;
        String cover = topicDetail.topic.cover;
        mTopicDetailTitleTv.setText(topicDetail.topic.title);
        mTopicDetailSurveyTv.setText(topicDetail.topic.description);
        mTopicDetailVisitNumTv.setText("" + topicDetail.topic.visitCount);
        mTopicDetailTrendNumTv.setText("" + topicDetail.topic.postsCount);
        GlideApp.with(TopicDetailActivity.this)
                .load(cover)
konghaorui committed
498 499
                .placeholder(R.drawable.dynamic_default_img)
                .error(R.drawable.dynamic_default_img)
konghaorui committed
500
                .into(mTopicDetailTopBgIv);
konghaorui committed
501
        mTopicDetailFocusTv.setBackgroundResource("1".equals(is_focused) ? R.drawable.dynamic_focused_topic_detail_bg : R.drawable.dynamic_focus_topic_detail_bg);
konghaorui committed
502
        mTopicDetailFocusTv.setTextColor(getResources().getColor("1".equals(is_focused) ? R.color.platform_white : R.color.dynamic_but_text_color));
konghaorui committed
503
        mTopicDetailFocusTv.setText("1".equals(is_focused) ? this.getString(R.string.dynamic_trend_foucused) : "+" + this.getString(R.string.dynamic_trend_foucus));
konghaorui committed
504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554
        if (!"2".equals(topicId)) {
            mTopicDetailFocusTv.setVisibility(View.VISIBLE);
        }
        adapter.setDatas(topicDetail.members);
        mTopicDetailUsersNumTv.setText(topicDetail.totalMembers + "人");
        share = topicDetail.share;
        if (topicDetail.top_data != null && topicDetail.top_data.size() > 0) {
            divideLine.setVisibility(View.VISIBLE);
            topTrendsRcv.setVisibility(View.VISIBLE);
            mRecommendTopAdapter.setExtData(topicDetail.top_data);
            mRecommendTopAdapter.notifyDataSetChanged();
        } else {
            divideLine.setVisibility(View.GONE);
            topTrendsRcv.setVisibility(View.GONE);
        }
    }

    @Override
    public void showLoadingView(String message) {
        if (mSwl.isRefreshing()) {
            return;
        }
        vLoading.setVisibility(View.VISIBLE);
        vLoading.setViewType(LogoLoadingView.TYPE_LOADING, null);
    }

    @Override
    public void hideLoadingView() {
        vLoading.setVisibility(View.GONE);
    }

    @Override
    public void hideProgressView() {
        vLoading.setVisibility(View.GONE);
        if (mSwl.isRefreshing()) {
            mSwl.setRefreshing(false);
        }
    }

    @Override
    public void showFocusResult(Focus result) {
        //关注成功
        String status = String.valueOf(result.status);//1关注,2取消关注
        //关注成功
        if ("1".equals(status)) {
            BuryPointUtils.getInstance().createMap()
                    .put("theme_name", topicTitle)
                    .put("theme_ID", topicId)
                    .burryPoint("Theme_attention");
            totalMembers += 1;
            mTopicDetailUsersNumTv.setText(totalMembers + "人");
konghaorui committed
555 556
            mTopicDetailFocusTv.setBackgroundResource(R.drawable.dynamic_focused_topic_detail_bg);
            mTopicDetailFocusTv.setText(this.getString(R.string.dynamic_trend_foucused));
konghaorui committed
557 558 559 560 561 562 563
            TopicDetailBean.Member member = new TopicDetailBean.Member();
            member.head = DynamicIn.INSTANCE.getUserInfo().getHead();
            member.uid = DynamicIn.INSTANCE.getUserInfo().getUid() + "";
            adapter.addData(0, member);
        } else {
            totalMembers = totalMembers - 1;
            mTopicDetailUsersNumTv.setText(totalMembers + "人");
konghaorui committed
564 565
            mTopicDetailFocusTv.setBackgroundResource(R.drawable.dynamic_focus_topic_detail_bg);
            mTopicDetailFocusTv.setText("+" + this.getString(R.string.dynamic_trend_foucus));
konghaorui committed
566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598
            if (adapter.getDatas() != null && adapter.getDatas().size() > 0) {
                for (TopicDetailBean.Member m : adapter.getDatas()) {
                    if (m.uid.equals(DynamicIn.INSTANCE.getUserInfo().getUid())) {
                        adapter.removeData(m);
                    }
                }
            }

        }
    }

    @Override
    public void showErrorView() {
        vLoading.setVisibility(View.VISIBLE);
        vLoading.setViewType(LogoLoadingView.TYPE_NET_LOSS, "哎呦,网络开小差了");
    }

    @Override
    public void showFocusError(Throwable throwable) {
        vLoading.setVisibility(View.VISIBLE);
        vLoading.setViewType(LogoLoadingView.TYPE_NET_LOSS, "哎呦,网络开小差了");
    }

    @Override
    protected int layoutResId() {
        return 0;
    }

    @Override
    protected void initDataAndEvent() {

    }
}