Android Open Source - Android-Lib-Pen Drawing Service






From Project

Back to project page Android-Lib-Pen.

License

The source code is released under:

Apache License

If you think the Android project Android-Lib-Pen 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 android.lib.pen.demo;
/*w  w w . j a  v a  2 s  . co  m*/
import android.app.Activity;
import android.lib.pen.PenService;
import android.view.MotionEvent;
import android.view.View;

import com.samsung.android.sdk.pen.document.SpenPageDoc;

final class DrawingService extends PenService {
    private View.OnTouchListener      onTouchListener;
    private OnPageUpdatedListener     onPageUpdatedListener;
    private OnReplayCompletedListener onReplayCompletedListener;

    public DrawingService(final Activity activity, final View rootLayout) {
        super(activity, rootLayout);
    }

    @Override
    public void onCommit(final SpenPageDoc doc) {
        super.onCommit(doc);

        // The page is changed, so update the thumbnail (if any).
        if (this.onPageUpdatedListener != null) {
            this.onPageUpdatedListener.onPageUpdated();
        }
    }

    @Override
    public void undo() {
        super.undo();

        // The page is changed, so update the thumbnail (if any).
        if (this.onPageUpdatedListener != null) {
            this.onPageUpdatedListener.onPageUpdated();
        }
    }

    @Override
    public void redo() {
        super.redo();

        // The page is changed, so update the thumbnail (if any).
        if (this.onPageUpdatedListener != null) {
            this.onPageUpdatedListener.onPageUpdated();
        }
    }

    public void setOnTouchListener(final View.OnTouchListener listener) {
        this.onTouchListener = listener;
    }

    public void setOnPageUpdatedListener(final OnPageUpdatedListener listener) {
        this.onPageUpdatedListener = listener;
    }

    public void setOnReplayCompletedListener(final OnReplayCompletedListener listener) {
        this.onReplayCompletedListener = listener;
    }

    @Override
    public boolean onTouch(final View view, final MotionEvent event) {
        if (this.onTouchListener == null) {
            return super.onTouch(view, event);
        }

        return this.onTouchListener.onTouch(view, event);
    }

    @Override
    public void onCompleted() {
        if (this.onReplayCompletedListener != null) {
            this.onReplayCompletedListener.onReplayCompleted();
        }
    }
}




Java Source Code List

android.lib.pen.PenButton.java
android.lib.pen.PenService.java
android.lib.pen.demo.Constants.java
android.lib.pen.demo.DragDropUtils.java
android.lib.pen.demo.DrawingActivity.java
android.lib.pen.demo.DrawingService.java
android.lib.pen.demo.GalleryAdapter.java
android.lib.pen.demo.IOUtils.java
android.lib.pen.demo.MainActivity.java
android.lib.pen.demo.MultiDragListener.java
android.lib.pen.demo.OnPageUpdatedListener.java
android.lib.pen.demo.OnReplayCompletedListener.java