Permalink
Browse files

Start static hash table for file mime matching.

  • Loading branch information...
1 parent cd26da5 commit 1bbdf9e5b7a8f04bf00dd109af044417f057db75 @exallium committed May 13, 2012
@@ -0,0 +1,19 @@
+package com.exallium.expressfiles;
+
+import java.util.HashMap;
+
+public class Constants {
+ public final static HashMap<String, String> mimemap = new HashMap<String, String>();
+ static {
+
+ // Images
+ mimemap.put("jpg", "image/*");
+ mimemap.put("jpeg", "image/*");
+ mimemap.put("png", "image/*");
+ mimemap.put("bmp", "image/*");
+ mimemap.put("gif", "image/*");
+
+ // Video
+ // Music
+ }
+}
@@ -15,13 +15,16 @@
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
+import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;
public class ExpressFilesActivity extends Activity {
+ private static String TAG = "ExpressFilesActivity";
+
private ListView listResults;
private FileAdapter fileAdapter;
private String workingPath;
@@ -60,10 +63,17 @@ public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
workingPath = workingDirectory.getAbsolutePath();
displayList();
} else {
+ // XXX: This needs to be able to map MIME to file type
Uri uri = Uri.fromFile(item);
+
+ Log.d(TAG, item.getName());
+
+ String [] item_split = item.getName().split("[.]");
+ String type = item_split[item_split.length - 1];
+
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
- intent.setDataAndType(uri, "image/*");
+ intent.setDataAndType(uri, Constants.mimemap.get(type));
startActivity(intent);
}
}

0 comments on commit 1bbdf9e

Please sign in to comment.