Android Open Source - codemap Workspace State Loader






From Project

Back to project page codemap.

License

The source code is released under:

GNU General Public License

If you think the Android project codemap listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.hdweiss.codemap.view.workspace;
//ww w.j a  v  a2 s. co  m
import java.util.ArrayList;
import java.util.HashMap;
import java.util.UUID;

import android.app.ProgressDialog;
import android.os.AsyncTask;

import com.hdweiss.codemap.data.SerializableItem;
import com.hdweiss.codemap.data.SerializableLink;
import com.hdweiss.codemap.view.workspace.fragments.CodeMapItem;
import com.hdweiss.codemap.view.workspace.fragments.CodeMapLink;

public class WorkspaceStateLoader extends AsyncTask<ArrayList<SerializableItem>, CodeMapItem, Long> {
  
  private WorkspaceState state;
  private WorkspaceView codeMapView;
  private WorkspaceController controller;

  private ProgressDialog dialog;
  private HashMap<UUID, CodeMapItem> codeMapItems = new HashMap<UUID, CodeMapItem>();
  
  public WorkspaceStateLoader(WorkspaceState state, WorkspaceView codeMapView, WorkspaceController controller) {
    this.state = state;
    this.codeMapView = codeMapView;
    this.controller = controller;
  }
  
  @Override
  protected void onPreExecute() {
    super.onPreExecute();
    
    this.dialog = ProgressDialog.show(codeMapView.getContext(), "Loading",
        "Loading state...");
  }

  protected Long doInBackground(ArrayList<SerializableItem>... objects) {
    ArrayList<SerializableItem> items = objects[0];
    
    for (int i = 0; i < items.size(); i++) {
      CodeMapItem fragment = loadObjectState(items.get(i));
      this.publishProgress(fragment);
      codeMapItems.put(fragment.id, fragment);
    }

    return (long) 0;
  }

  @Override
  protected void onProgressUpdate(CodeMapItem... progress) {
    super.onProgressUpdate(progress);
    for(int i = 0; i < progress.length; i++)
      codeMapView.addMapItem(progress[i]);
  }

  @Override
  protected void onPostExecute(Long result) {
    super.onPostExecute(result);
    loadLinksState(state);
    dialog.dismiss();
  }
  

  private CodeMapItem loadObjectState(SerializableItem item) {
    CodeMapItem itemView = item.createCodeMapItem(controller,
        codeMapView.getContext());
    itemView.id = item.id;
    return itemView;
  }
  
  private void loadLinksState(WorkspaceState state) {
    for (SerializableLink link : state.links) {
      CodeMapItem parent = codeMapItems.get(link.parent);
      CodeMapItem child = codeMapItems.get(link.child);

      codeMapView.addMapLink(new CodeMapLink(parent, child,
          link.offset));
    }
  }
}




Java Source Code List

com.hdweiss.codemap.data.CodeMapApp.java
com.hdweiss.codemap.data.CscopeEntry.java
com.hdweiss.codemap.data.CscopeWrapper.java
com.hdweiss.codemap.data.Cscope.java
com.hdweiss.codemap.data.ICodeMapItem.java
com.hdweiss.codemap.data.JGitWrapper.java
com.hdweiss.codemap.data.ProjectController.java
com.hdweiss.codemap.data.Project.java
com.hdweiss.codemap.data.SerializableItem.java
com.hdweiss.codemap.data.SerializableLink.java
com.hdweiss.codemap.util.AbsoluteLayout.java
com.hdweiss.codemap.util.CodeMapCursorPoint.java
com.hdweiss.codemap.util.CodeMapPoint.java
com.hdweiss.codemap.util.FlowLayout.java
com.hdweiss.codemap.util.ObjectSerializer.java
com.hdweiss.codemap.util.SpanUtils.java
com.hdweiss.codemap.util.SyntaxHighlighter.java
com.hdweiss.codemap.util.Utils.java
com.hdweiss.codemap.util.ZoomableAbsoluteLayout.java
com.hdweiss.codemap.util.ZoomableLinearLayout.java
com.hdweiss.codemap.view.CodeMapActivity.java
com.hdweiss.codemap.view.CodeMapTabListener.java
com.hdweiss.codemap.view.Preferences.java
com.hdweiss.codemap.view.project.ProjectAdapter.java
com.hdweiss.codemap.view.project.ProjectBrowser.java
com.hdweiss.codemap.view.project.ProjectItemView.java
com.hdweiss.codemap.view.project.ProjectWizard.java
com.hdweiss.codemap.view.workspace.CollisionManager.java
com.hdweiss.codemap.view.workspace.FindDeclarationTask.java
com.hdweiss.codemap.view.workspace.WorkspaceController.java
com.hdweiss.codemap.view.workspace.WorkspaceFragment.java
com.hdweiss.codemap.view.workspace.WorkspaceStateLoader.java
com.hdweiss.codemap.view.workspace.WorkspaceState.java
com.hdweiss.codemap.view.workspace.WorkspaceViewListeners.java
com.hdweiss.codemap.view.workspace.WorkspaceView.java
com.hdweiss.codemap.view.workspace.browser.WorkspaceBrowserAdapter.java
com.hdweiss.codemap.view.workspace.browser.WorkspaceBrowser.java
com.hdweiss.codemap.view.workspace.fragments.CodeMapAnnotation.java
com.hdweiss.codemap.view.workspace.fragments.CodeMapFunction.java
com.hdweiss.codemap.view.workspace.fragments.CodeMapImage.java
com.hdweiss.codemap.view.workspace.fragments.CodeMapItem.java
com.hdweiss.codemap.view.workspace.fragments.CodeMapLink.java
com.hdweiss.codemap.view.workspace.fragments.FunctionLinkSpan.java
com.hdweiss.codemap.view.workspace.outline.CscopeEntryAdapter.java
com.hdweiss.codemap.view.workspace.outline.OutlineAdapter.java
com.hdweiss.codemap.view.workspace.outline.OutlineBrowser.java
com.hdweiss.codemap.view.workspace.outline.OutlineItemComparator.java
com.hdweiss.codemap.view.workspace.outline.OutlineItemView.java
com.hdweiss.codemap.view.workspace.outline.OutlineItem.java