Android Open Source - surveygcp Open File Dialog






From Project

Back to project page surveygcp.

License

The source code is released under:

GNU General Public License

If you think the Android project surveygcp 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 org.droidplanner.gcp.dialogs.openfile;
/*  w ww .ja  v  a2 s .  com*/
import org.droidplanner.gcp.R;

import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.widget.Toast;

public abstract class OpenFileDialog implements OnClickListener {

  public interface FileReader {
    public String getPath();

    public String[] getFileList();

    public boolean openFile(String file);
  }

  protected abstract FileReader createReader();

  protected abstract void onDataLoaded(FileReader reader);

  private String[] itemList;
  private Context context;
  private FileReader reader;

  public void openDialog(Context context) {
    this.context = context;
    reader = createReader();

    itemList = reader.getFileList();
    if (itemList.length == 0) {
      Toast.makeText(context, R.string.no_files, Toast.LENGTH_SHORT)
          .show();
      return;
    }
    AlertDialog.Builder dialog = new AlertDialog.Builder(context);
    dialog.setTitle(R.string.select_file_to_open);
    dialog.setItems(itemList, this);
    dialog.create().show();
  }

  @Override
  public void onClick(DialogInterface dialog, int which) {
    boolean isFileOpen = reader
        .openFile(reader.getPath() + itemList[which]);

    if (isFileOpen) {
      Toast.makeText(context, itemList[which], Toast.LENGTH_LONG).show();
    } else {
      Toast.makeText(context, R.string.error_when_opening_file,
          Toast.LENGTH_SHORT).show();
    }

    onDataLoaded(reader);
  }

}




Java Source Code List

android.UnusedStub.java
org.droidplanner.gcp.GCPApp.java
org.droidplanner.gcp.activitys.GCPActivity.java
org.droidplanner.gcp.activitys.SettingsActivity.java
org.droidplanner.gcp.dialogs.openfile.OpenFileDialog.java
org.droidplanner.gcp.dialogs.openfile.OpenGcpFileDialog.java
org.droidplanner.gcp.file.DirectoryPath.java
org.droidplanner.gcp.file.FileList.java
org.droidplanner.gcp.file.IO.GcpReader.java
org.droidplanner.gcp.fragments.GcpMapFragment.java
org.droidplanner.gcp.fragments.helpers.OfflineMapFragment.java
org.droidplanner.gcp.fragments.markers.GcpMarker.java
org.droidplanner.gcp.fragments.markers.MarkerManager.java
org.droidplanner.gcp.gcp.Gcp.java
org.droidplanner.gcp.helpers.LocalMapTileProvider.java
org.droidplanner.gcp.helpers.TTS.java