Android Open Source - Android-Lib-Pen Main Activity






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;
/*  ww  w .ja  v  a 2s  .c o m*/
import java.io.File;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.GridView;

public final class MainActivity extends Activity implements View.OnClickListener, AdapterView.OnItemClickListener {
    private GalleryAdapter adapter;

    @Override
    protected void onCreate(final Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        this.setContentView(R.layout.activity_main);

        final GridView gallery = (GridView)this.findViewById(R.id.gallery);
        gallery.setAdapter(this.adapter = new GalleryAdapter(this));
        gallery.setOnItemClickListener(this);

        this.findViewById(R.id.create).setOnClickListener(this);
    }

    @Override
    protected void onActivityResult(final int requestCode, final int resultCode, final Intent data) {
        if (resultCode == Activity.RESULT_OK) {
            this.adapter.refresh();
        }
    }

    @Override
    public void onClick(final View view) {
        this.startActivityForResult(new Intent(this, DrawingActivity.class), 1);
    }

    @Override
    public void onItemClick(final AdapterView<?> parent, final View view, final int position, final long id) {
        final String thumbnailName = new File((String)this.adapter.getItem(position)).getName();

        this.startActivityForResult(new Intent(this, DrawingActivity.class).putExtra(Constants.EXTRA_SPD_PATH, new File(Constants.SPD_PATH, thumbnailName.substring(0, thumbnailName.lastIndexOf(".")) + Constants.SPD_EXTENSION).getAbsolutePath()), 1); //$NON-NLS-1$
    }
}




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