Beispiel #1
0
 @Override
 public void stopPlay() {
   final BaseViewAdapter adapter = internalAdapter();
   if (adapter != null) {
     adapter.stopRecord(false);
   }
 }
Beispiel #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;
  }
Beispiel #3
0
 @Override
 public void stopUndoRecord() {
   final BaseViewAdapter adapter = internalAdapter();
   if (adapter != null) {
     adapter.stopRecord(true);
   }
 }
Beispiel #4
0
 @Override
 public void redo() {
   final BaseViewAdapter adapter = internalAdapter();
   if (adapter != null) {
     adapter.redo();
   }
 }
Beispiel #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);
  }
Beispiel #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);
  }
Beispiel #7
0
 @Override
 public boolean onPause() {
   if (mViewAdapter != null) {
     mViewAdapter.hideContextActions();
     return mCoreView.onPause(BaseViewAdapter.getTick());
   }
   return false;
 }
Beispiel #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));
    }
  }
Beispiel #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();
    }
  }
Beispiel #10
0
 @Override
 public boolean onResume() {
   return mCoreView.onResume(BaseViewAdapter.getTick());
 }
Beispiel #11
0
 @Override
 public int getPlayProviderCount() {
   final BaseViewAdapter adapter = internalAdapter();
   return adapter != null ? adapter.getPlayProviderCount() : 0;
 }
Beispiel #12
0
 @Override
 public int getPlayTicks() {
   return mView.coreView().getRecordTick(false, BaseViewAdapter.getTick());
 }
Beispiel #13
0
 @Override
 public boolean playResume() {
   return mView != null && mView.coreView().onResume(BaseViewAdapter.getTick());
 }
Beispiel #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);
 }
Beispiel #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);
 }
Beispiel #16
0
 public BaseViewAdapter getMainAdapter() {
   return BaseViewAdapter.getMainAdapter(mView);
 }
Beispiel #17
0
 @Override
 public String getCommand() {
   final BaseViewAdapter adapter = internalAdapter();
   return adapter != null ? adapter.getCommand() : "";
 }