示例#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() : "";
 }