private void setCodeData(String path) { currCodeTree = CodeTree.allFolder.get(path); codeAdapter.setCodeTree(currCodeTree); codeList.setSelection(0); // ¸üÐÂpathview if (currCodeTree.currEntry == null) pathView.resetPath(CodeTree.ROOT); else pathView.resetPath(currCodeTree.currEntry.getPath()); }
@Override protected void initData() { repository = (Repository) context.getIntent().getSerializableExtra(Constants.Extra.REPOSITORY); curBranch = repository.getMasterBranch(); setLoadCache(CacheUtils.contain(getCacheName())); if (currCodeTree == null) execute(); else { ViewUtils.setVisibility(listPopup, View.VISIBLE, R.anim.alpha_in); branch.setText(curBranch); codeAdapter.setCodeTree(currCodeTree); if (!currCodeTree.name.equals(CodeTree.ROOT)) pathView.resetView(currCodeTree.currEntry.getPath()); } }
@Override protected void initView() { codeList = (ListView) findViewById(R.id.list); codeAdapter = new CodeTreeAdapter(context); codeList.setAdapter(codeAdapter); codeList.setOnItemClickListener( new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View arg1, int position, long arg3) { if (position < currCodeTree.getTreeCount()) { currCodeTree = currCodeTree.subTree.get(position); codeAdapter.setCodeTree(currCodeTree); codeList.setSelection(0); pathView.add(currCodeTree.currEntry.getPath()); } else { IntentUtils.create(context, CodeFileActivity.class) .putExtra( Constants.Extra.CODE_ENTRY, currCodeTree.subEntry.get(position - currCodeTree.getTreeCount())) .putExtra(Constants.Extra.REPOSITORY, repository) .start(); } } }); pathView = (PathView) findViewById(R.id.pathview); pathView.setPathListener( new PathClickListener() { @Override public void onPathClick(String path) { setCodeData(path); } }); branch = (TextView) findViewById(R.id.branch); branch.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { if (branchDialog == null) { branchDialog = new BranchDialog(context, repository) .setOnItemClickListener( new OnItemClickListener() { @Override public void onItemClick( AdapterView<?> parent, View view, int position, long id) { // TODO Auto-generated method stub String branch = branchDialog.getBranchList().get(position).getName(); if (!branch.equals(curBranch)) { curBranch = branch; execute(); } } }); } branchDialog.show(); } }); listPopup = (ListPopupView) findViewById(R.id.branch_popup); listPopup.bind(codeList); }