예제 #1
0
 @Override
 public void stopPlay() {
   final BaseViewAdapter adapter = internalAdapter();
   if (adapter != null) {
     adapter.stopRecord(false);
   }
 }
예제 #2
0
  @Override
  public int insertImageFromFile(String filename) {
    final BaseViewAdapter adapter = internalAdapter();

    if (adapter == null || filename == null) return 0;

    String name = filename.substring(filename.lastIndexOf('/') + 1).toLowerCase(Locale.US);
    Drawable d;

    if (name.endsWith(".svg")) {
      d = mView.getImageCache().addSVGFile(filename, name);
    } else {
      d = mView.getImageCache().addBitmapFile(getContext().getResources(), filename, name);
    }
    if (d != null) {
      final String destPath = adapter.getRecordPath();
      if (destPath != null) {
        ImageCache.copyFileTo(filename, destPath);
      }
      synchronized (mView.coreView()) {
        int w = ImageCache.getWidth(d);
        int h = ImageCache.getHeight(d);
        return mView.coreView().addImageShape(name, w, h);
      }
    }
    return 0;
  }
예제 #3
0
 @Override
 public void stopUndoRecord() {
   final BaseViewAdapter adapter = internalAdapter();
   if (adapter != null) {
     adapter.stopRecord(true);
   }
 }
예제 #4
0
 @Override
 public void redo() {
   final BaseViewAdapter adapter = internalAdapter();
   if (adapter != null) {
     adapter.redo();
   }
 }
예제 #5
0
  @Override
  public boolean startPlay(String path) {
    final BaseViewAdapter adapter = internalAdapter();

    if (adapter == null
        || adapter.getSavedState() != null
        || mView.coreView().isPlaying()
        || !new File(path).exists()) {
      return false;
    }
    return adapter.startPlay(path);
  }
예제 #6
0
  @Override
  public boolean startRecord(String path) {
    final BaseViewAdapter adapter = internalAdapter();

    if (adapter == null
        || adapter.getSavedState() != null
        || mView.coreView().isRecording()
        || !deleteDirectory(new File(path))
        || !createDirectory(path, true)) {
      return false;
    }
    return adapter.startRecord(path);
  }
예제 #7
0
 @Override
 public boolean onPause() {
   if (mViewAdapter != null) {
     mViewAdapter.hideContextActions();
     return mCoreView.onPause(BaseViewAdapter.getTick());
   }
   return false;
 }
예제 #8
0
  @Override
  public void onRestoreInstanceState(Bundle savedState) {
    final BaseViewAdapter adapter = internalAdapter();
    final Bundle state = savedState.getBundle("vg");

    if (adapter != null && state != null) {
      final LogHelper log = new LogHelper();
      final String filename = state.getString("bakFile");
      boolean readOnly = state.getBoolean("readOnly");

      if (filename != null && loadFromFile(filename, readOnly)) {
        Log.d(TAG, "Auto load from " + filename);
      }
      adapter.onRestoreInstanceState(state);
      log.r();
    } else {
      Log.w(TAG, "onRestoreInstanceState fail, state:" + (state != null));
    }
  }
예제 #9
0
  @Override
  public void onSaveInstanceState(Bundle outState, String path) {
    final BaseViewAdapter adapter = internalAdapter();

    if (adapter == null) {
      Log.w(TAG, "onSaveInstanceState fail due to no view adapter");
    } else {
      final LogHelper log = new LogHelper();
      Bundle state = adapter.getSavedState();

      if (state == null) {
        final String filename = new File(path, "resume.vg").getPath();
        final String playFile = new File(path, "playresume.vg").getPath();

        state = new Bundle();
        adapter.onSaveInstanceState(state);
        if (mView.coreView().isPlaying()) {
          if (saveToFile(playFile)) {
            Log.d(TAG, "Auto save playing shapes to " + playFile);
            state.putString("playFile", playFile);
          }
          if (saveToFile(filename, mView.coreView().backDoc())) {
            Log.d(TAG, "Auto save to " + filename);
            state.putString("bakFile", filename);
          }
        } else {
          if (saveToFile(filename)) {
            Log.d(TAG, "Auto save to " + filename);
            state.putString("bakFile", filename);
          }
        }
        state.putBoolean("readOnly", cmdView().isReadOnly());
      }
      outState.putBundle("vg", state);
      log.r();
    }
  }
예제 #10
0
 @Override
 public boolean onResume() {
   return mCoreView.onResume(BaseViewAdapter.getTick());
 }
예제 #11
0
 @Override
 public int getPlayProviderCount() {
   final BaseViewAdapter adapter = internalAdapter();
   return adapter != null ? adapter.getPlayProviderCount() : 0;
 }
예제 #12
0
 @Override
 public int getPlayTicks() {
   return mView.coreView().getRecordTick(false, BaseViewAdapter.getTick());
 }
예제 #13
0
 @Override
 public boolean playResume() {
   return mView != null && mView.coreView().onResume(BaseViewAdapter.getTick());
 }
예제 #14
0
 public void createDummyView(Context context, int width, int height) {
   final StdGraphView view = new StdGraphView(context, (BaseGraphView) null);
   view.layout(0, 0, width, height);
   mView = view;
   mView.coreView().onSize(BaseViewAdapter.getMainAdapter(mView), width, height);
 }
예제 #15
0
 @Override
 public boolean addPlayProvider(PlayProvider p, int tag, Object extra) {
   final BaseViewAdapter adapter = internalAdapter();
   return adapter != null && p != null && adapter.addPlayProvider(p, tag, extra);
 }
예제 #16
0
 public BaseViewAdapter getMainAdapter() {
   return BaseViewAdapter.getMainAdapter(mView);
 }
예제 #17
0
 @Override
 public String getCommand() {
   final BaseViewAdapter adapter = internalAdapter();
   return adapter != null ? adapter.getCommand() : "";
 }