@Override protected void onStart() { GKIMLog.lf(this, 0, TAG + "=>onStart."); if (mStoryId == null || mStoryId.length() <= 0) { this.finish(); } mPagerAdapter.setStories(mListStoryIds); mPagerAdapter.notifyDataSetChanged(); int index = mPagerAdapter.getStoryIndex(mStoryId); mPager.setCurrentItem(index, true); if (index == 0) { myOnPageSelectedLogic(index); } mHashStoryCommentCount.clear(); mHashStoryFBLikeCount.clear(); super.onStart(); Tracking.startSession(this); }
private void myOnPageSelectedLogic(int position) { // if(TNPreferenceManager.isConnectionAvailable()) { mStoryId = mPagerAdapter.getPageStoryId(position); GKIMLog.lf(null, 1, TAG + "=>onPageSelected: " + position + " story: " + mStoryId); TNPreferenceManager.putReadStory(mStoryId); String storyName = ""; try { FragmentManager fm = getSupportFragmentManager(); VideoStoryDetailFragment frag = (VideoStoryDetailFragment) fm.findFragmentByTag(getFragmentTag(mPager.getCurrentItem())); if (frag != null) { StoryDetail sd = frag.getStoryDetail(); String sectionid = ""; if (sd != null) { sectionid = sd.getSectionid(); storyName = sd.getStorytitle(); } GKIMLog.lf(this, 0, TAG + "=>myOnPageSelectedLogic, saving section code: " + sectionid); TNPreferenceManager.updateCurrentStandingSectionId(sectionid); } } catch (Exception e) { GKIMLog.lf( this, 0, TAG + "=> failed to get current section code from story: " + mStoryId + ", " + e.getMessage()); } HashMap<String, String> map = new HashMap<String, String>(); map.put(TNPreferenceManager.EVENT_KEY_STORY_NAME, storyName); map.put(TNPreferenceManager.EVENT_KEY_STORY_ID, mStoryId); Tracking.sendEvent(TNPreferenceManager.EVENT_STORY_VIEW, map); updateFragmentTextmode(TNPreferenceManager.isNightMode()); updateFragmentTextZoommode(); if (!mTabletVersion) { int count = 0; if (mHashStoryCommentCount != null && mHashStoryCommentCount.containsKey(mStoryId) && mGuiFooter != null) { count = mHashStoryCommentCount.get(mStoryId); } mGuiFooter.setCommentCountView(count); count = 0; if (mHashStoryFBLikeCount != null && mHashStoryFBLikeCount.containsKey(mStoryId)) { count = mHashStoryFBLikeCount.get(mStoryId); } mGuiFooter.setFbLikeCountView(count); } // boolean bLoggedIn = TNPreferenceManager.checkLoggedIn(); // if (bLoggedIn) { GKIMLog.l(1, TAG + " myOnPageSelectedLogic call setSavedStory"); setSavedStory(TNPreferenceManager.hasSavedStory(mStoryId)); // } else { // setSavedStory(false); // } if (mGuiFooter != null && !mTabletVersion) { int mFbLikeCount = getSharedPreferences(mStoryId + "_", Context.MODE_PRIVATE).getInt(mStoryId + "_", 0); boolean is = getSharedPreferences(mStoryId, Context.MODE_PRIVATE).getBoolean(mStoryId, false); TextView tvlikefb = (TextView) mGuiFooter.findViewById(R.id.tv_storydetail_fblike_count); tvlikefb.setText(mFbLikeCount + ""); if (is) { tvlikefb.setBackgroundResource(R.drawable.ic_storyfooter_fblike_over); } else { tvlikefb.setBackgroundResource(R.drawable.ic_storyfooter_fblike); } } }