private void addOrRemoveSaveBoxStory(View fromView, StoryDetail storyDetail) { GKIMLog.lf(this, 0, TAG + "=>addOrRemoveSaveBoxStory"); if (!mStoryId.equals(String.valueOf(storyDetail.getStoryid()))) { GKIMLog.lf( this, 0, TAG + "=> not match current story, won't save. (" + mStoryId + ", " + storyDetail.getStoryid() + ")."); return; } String currentStoryId = mStoryId; if (TNPreferenceManager.hasSavedStory(currentStoryId)) { // if (!TNPreferenceManager.checkLoggedIn()) { // UIUtils.showToast(this, // getResources().getString(R.string.request_for_login)); // } else { TNPreferenceManager.deleteStory(currentStoryId); fromView.setSelected(false); GKIMLog.lf(this, 0, TAG + "=>removed story: " + currentStoryId); TNPreferenceManager.updateSaved(currentStoryId, 0); UIUtils.showToast(this, getResources().getString(R.string.storydetail_story_has_removed)); // } } else { // if (!TNPreferenceManager.checkLoggedIn()) { // UIUtils.showToast(this, // getResources().getString(R.string.request_for_login)); // } else { TNPreferenceManager.saveStory(storyDetail); fromView.setSelected(true); GKIMLog.lf(this, 0, TAG + "=>added story: " + currentStoryId); TNPreferenceManager.updateSaved(currentStoryId, 1); UIUtils.showToast(this, getResources().getString(R.string.storydetail_story_has_saved)); // } } }
@Override public boolean handleMessage(Message msg) { switch (msg.what) { case TNPreferenceManager.HANDLER_MSG_HAS_LOGGIN_CHANGED: GKIMLog.lf(null, 0, TAG + "=>login has changed."); // XXX: not correct on the UID from logout to login state. // boolean bLoggedIn = TNPreferenceManager.checkLoggedIn(); if (mTabletVersion) { FragmentManager fm = getSupportFragmentManager(); VideoStoryDetailFragment frag = (VideoStoryDetailFragment) fm.findFragmentByTag(getFragmentTag(mPager.getCurrentItem())); // if (bLoggedIn) { frag.setCheckSave(TNPreferenceManager.hasSavedStory(mStoryId)); // } else { // frag.setCheckSave(false); // } } else { // if (bLoggedIn) { GKIMLog.l(1, TAG + " handleMessage call setSavedStory"); setSavedStory(TNPreferenceManager.hasSavedStory(mStoryId)); // } else { // setSavedStory(false); // } } hideGUIListMenu(); return true; case TNPreferenceManager.HANDLER_MSG_HAS_STORYDETAIL_LOAD_COMPLETED: // Story activity will receive this event when a // StoryDetail is completely loaded in fragment. StoryDetail sd = (StoryDetail) msg.obj; if (sd == null || TextUtils.isEmpty(sd.getSectionid())) { return false; } String sectionid = sd.getSectionid(); String storyid = String.valueOf(sd.getStoryid()); try { if (mStoryId == null || storyid.equals(mStoryId)) { GKIMLog.lf( VideoStoryDetailFragmentActivity.this, 0, TAG + "=>myOnPageSelectedLogic, update section code from current story: " + storyid + ", section: " + sectionid); TNPreferenceManager.updateCurrentStandingSectionId(sectionid); } } catch (Exception e) { GKIMLog.lf( VideoStoryDetailFragmentActivity.this, 0, TAG + "=> failed to get current section code from story: " + sectionid + ", " + e.getMessage()); } break; default: break; } return false; }
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); } } }