@Override
  protected void onCreate(Bundle arg0) {
    super.onCreate(arg0);
    this.setContentView(R.layout.topiclist_activity);
    PullToRefreshAttacher.Options options = new PullToRefreshAttacher.Options();
    options.refreshScrollDistance = 0.3f;
    options.refreshOnUp = true;
    mPullToRefreshAttacher = PullToRefreshAttacher.get(this, options);

    if (ActivityUtil.isNotLessThan_4_0()) setNfcCallBack();

    if (null == findViewById(R.id.item_detail_container)) {
      dualScreen = false;
    }
    FragmentManager fm = getSupportFragmentManager();
    Fragment f1 = fm.findFragmentById(R.id.item_list);
    if (f1 == null) {
      f1 = new TopiclistContainer();
      Bundle args = new Bundle(); // (getIntent().getExtras());
      if (null != getIntent().getExtras()) {
        args.putAll(getIntent().getExtras());
      }
      args.putString("url", getIntent().getDataString());
      f1.setArguments(args);
      FragmentTransaction ft = fm.beginTransaction().add(R.id.item_list, f1);
      // .add(R.id.item_detail_container, f);
      ft.commit();
    }
    Fragment f2 = fm.findFragmentById(R.id.item_detail_container);
    if (null == f2) {
      f1.setHasOptionsMenu(true);
    } else if (!dualScreen) {
      this.setTitle(R.string.app_name);
      fm.beginTransaction().remove(f2).commit();
      f1.setHasOptionsMenu(true);
    } else {
      f1.setHasOptionsMenu(false);
      f2.setHasOptionsMenu(true);
    }

    int fid = getIntent().getIntExtra("fid", 0);
    if (fid != 0) {
      String boardName = BoardHolder.boardNameMap.get(fid);
      if (null != boardName) {
        strs[0] = boardName;
      }
    }
    int favor = getIntent().getIntExtra("favor", 0);
    int authorid = getIntent().getIntExtra("authorid", 0);
    if (favor == 0 && authorid == 0) {
      setNavigation();
    } else {
      flags = ThemeManager.ACTION_BAR_FLAG;
    }
  }
 @Override
 public void OnChildFragmentRemoved(int id) {
   if (id == R.id.item_detail_container) {
     FragmentManager fm = getSupportFragmentManager();
     Fragment f1 = fm.findFragmentById(R.id.item_list);
     f1.setHasOptionsMenu(true);
     setTitle(R.string.app_name);
   }
 }
  @Override
  public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

    if (!dualScreen) {
      if (null == onItemClickNewActivity) {
        onItemClickNewActivity = new EnterJsonArticle(this);
      }
      onItemClickNewActivity.onItemClick(parent, view, position, id);

    } else {
      String guid = (String) parent.getItemAtPosition(position);
      if (StringUtil.isEmpty(guid)) return;

      guid = guid.trim();

      int pid = StringUtil.getUrlParameter(guid, "pid");
      int tid = StringUtil.getUrlParameter(guid, "tid");
      int authorid = StringUtil.getUrlParameter(guid, "authorid");
      ArticleContainerFragment f = ArticleContainerFragment.create(tid, pid, authorid);
      FragmentManager fm = getSupportFragmentManager();
      FragmentTransaction ft = fm.beginTransaction();

      ft.replace(R.id.item_detail_container, f);
      Fragment f1 = fm.findFragmentById(R.id.item_list);
      f1.setHasOptionsMenu(false);
      f.setHasOptionsMenu(true);
      ft.commit();

      ListView listview = (ListView) parent;
      Object a = parent.getAdapter();
      TopicListAdapter adapter = null;
      if (a instanceof TopicListAdapter) {
        adapter = (TopicListAdapter) a;
      } else if (a instanceof HeaderViewListAdapter) {
        HeaderViewListAdapter ha = (HeaderViewListAdapter) a;
        adapter = (TopicListAdapter) ha.getWrappedAdapter();
        position -= ha.getHeadersCount();
      }
      adapter.setSelected(position);
      listview.setItemChecked(position, true);
    }
  }
示例#4
0
 public void setHasOptionsMenu(boolean flag) {
   zzadh.setHasOptionsMenu(flag);
 }