@Override public void reset(int pid, int authorid, int floor) { this.pid = pid; this.authorid = authorid; mTabsAdapter.setArgument("pid", pid); mTabsAdapter.setArgument("authorid", authorid); if (tabhost != null) tabhost.getTabWidget().removeAllViews(); int page = floor / 20; mTabsAdapter.setCount(page + 1); mViewPager.setAdapter(mTabsAdapter); mViewPager.setCurrentItem(page); }
@Override public void finishLoad(ThreadData data) { int exactCount = 1 + data.getThreadInfo().getReplies() / 20; if (mTabsAdapter.getCount() != exactCount && this.authorid == 0) { if (this.pid != 0) exactCount = 1; mTabsAdapter.setCount(exactCount); } if (this.authorid > 0) { exactCount = 1 + data.get__ROWS() / 20; mTabsAdapter.setCount(exactCount); } if (tid != data.getThreadInfo().getTid()) // mirror thread tid = data.getThreadInfo().getTid(); fid = data.getThreadInfo().getFid(); setTitle(StringUtil.unEscapeHtml(data.getThreadInfo().getSubject())); }
@Override protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putInt("pageCount", mTabsAdapter.getCount()); outState.putInt("tab", mViewPager.getCurrentItem()); // outState.putInt("tid",tid); }
private void createGotoDialog() { int count = mTabsAdapter.getCount(); Bundle args = new Bundle(); args.putInt("count", count); DialogFragment df = new GotoDialogFragment(); df.setArguments(args); FragmentManager fm = getSupportFragmentManager(); Fragment prev = fm.findFragmentByTag(GOTO_TAG); if (prev != null) { fm.beginTransaction().remove(prev).commit(); } df.show(fm, GOTO_TAG); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(getViewId()); if (PhoneConfiguration.getInstance().uploadLocation && PhoneConfiguration.getInstance().location == null) { ActivityUtil.reflushLocation(this); } /*PullToRefreshViewPager refreshPager = (PullToRefreshViewPager) findViewById(R.id.pull_refresh_viewpager); refreshPager.setMode(Mode.PULL_FROM_START); refreshPager.setOnRefreshListener(new OnRefreshListener<ViewPager>(){ @Override public void onRefresh(PullToRefreshBase<ViewPager> refreshView) { finish(); } }); mViewPager = refreshPager.getRefreshableView(); */ mViewPager = (ViewPager) findViewById(R.id.pager); if (ActivityUtil.isNotLessThan_4_0()) { setNfcCallBack(); } tid = 7; int pageFromUrl = 0; String url = this.getIntent().getDataString(); if (null != url) { tid = this.getUrlParameter(url, "tid"); pid = this.getUrlParameter(url, "pid"); authorid = this.getUrlParameter(url, "authorid"); pageFromUrl = this.getUrlParameter(url, "page"); } else { tid = this.getIntent().getIntExtra("tid", 0); pid = this.getIntent().getIntExtra("pid", 0); authorid = this.getIntent().getIntExtra("authorid", 0); } View v = findViewById(android.R.id.content); // .getChildAt(0); tabhost = (TabHost) findViewById(android.R.id.tabhost); if (tabhost != null) { tabhost.setup(); mTabsAdapter = new TabsAdapter(this, tabhost, mViewPager, ArticleListFragment.class); } else { mTabsAdapter = new ThreadFragmentAdapter( this, getSupportFragmentManager(), mViewPager, ArticleListFragment.class); } mTabsAdapter.setArgument("id", tid); mTabsAdapter.setArgument("pid", pid); mTabsAdapter.setArgument("authorid", authorid); ActivityUtil.getInstance().noticeSaying(this); if (savedInstanceState != null) { int pageCount = savedInstanceState.getInt("pageCount"); if (pageCount != 0) { mTabsAdapter.setCount(pageCount); mViewPager.setCurrentItem(savedInstanceState.getInt("tab")); } } else if (0 != getUrlParameter(url, "page")) { mTabsAdapter.setCount(pageFromUrl); mViewPager.setCurrentItem(pageFromUrl); } }