Skip to content

Commit

Permalink
Critical bugfix. Error caused by removed assets
Browse files Browse the repository at this point in the history
  • Loading branch information
niranjan94 committed Dec 2, 2015
1 parent fb24722 commit f230175
Show file tree
Hide file tree
Showing 10 changed files with 13 additions and 15 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ props.each { key, val ->

def versionMajor = 2
def versionMinor = 0
def versionPatch = 8
def versionPatch = 85
def versionBuild = 10

android {
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/java/com/njlabs/showjava/modals/Item.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ public class Item implements Comparable<Item> {
private String data;
private String date;
private String path;
private String image;
private int image;

public Item(String n, String d, String dt, String p, String img) {
public Item(String n, String d, String dt, String p, int img) {
name = n;
data = d;
date = dt;
Expand All @@ -34,7 +34,7 @@ public String getPath() {
return path;
}

public String getImage() {
public int getImage() {
return image;
}

Expand Down
14 changes: 7 additions & 7 deletions app/src/main/java/com/njlabs/showjava/ui/JavaExplorer.java
Original file line number Diff line number Diff line change
Expand Up @@ -97,18 +97,18 @@ private void fill(File f) {
String num_item = String.valueOf(buf);
if (buf == 0) num_item = num_item + " item";
else num_item = num_item + " items";
dir.add(new Item(ff.getName(), num_item, date_modify, ff.getAbsolutePath(), "viewer_folder"));
dir.add(new Item(ff.getName(), num_item, date_modify, ff.getAbsolutePath(), R.drawable.viewer_folder));
} else {
String extension = FilenameUtils.getExtension(ff.getName());
String fileSize = StringUtils.humanReadableByteCount(ff.length(), true);
if (extension.equalsIgnoreCase("java")) {
fls.add(new Item(ff.getName(), fileSize, date_modify, ff.getAbsolutePath(), "viewer_java"));
fls.add(new Item(ff.getName(), fileSize, date_modify, ff.getAbsolutePath(), R.drawable.viewer_java));
} else if (extension.equalsIgnoreCase("xml")) {
fls.add(new Item(ff.getName(), fileSize, date_modify, ff.getAbsolutePath(), "viewer_xml"));
fls.add(new Item(ff.getName(), fileSize, date_modify, ff.getAbsolutePath(), R.drawable.viewer_xml));
} else if (extension.equalsIgnoreCase("txt")) {
fls.add(new Item(ff.getName(), fileSize, date_modify, ff.getAbsolutePath(), "viewer_summary"));
fls.add(new Item(ff.getName(), fileSize, date_modify, ff.getAbsolutePath(),R.drawable.viewer_summary));
} else if (extension.equalsIgnoreCase("png") | extension.equalsIgnoreCase("jpg")) {
fls.add(new Item(ff.getName(), fileSize, date_modify, ff.getAbsolutePath(), "viewer_image"));
fls.add(new Item(ff.getName(), fileSize, date_modify, ff.getAbsolutePath(), R.drawable.viewer_image));
}
}
}
Expand All @@ -120,14 +120,14 @@ private void fill(File f) {
dir.addAll(fls);

if (!f.equals(new File(sourceDir)))
dir.add(0, new Item("..", "Parent Directory", "", f.getParent(), "directory_up"));
dir.add(0, new Item("..", "Parent Directory", "", f.getParent(), R.drawable.directory_up));

adapter = new FileArrayAdapter(JavaExplorer.this, R.layout.java_explorer_list_item, dir);
lv.setAdapter(adapter);
lv.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Item o = adapter.getItem(position);
if (o.getImage().equalsIgnoreCase("viewer_folder") || o.getImage().equalsIgnoreCase("directory_up")) {
if (o.getImage() == R.drawable.viewer_folder || o.getImage() == R.drawable.directory_up) {
currentDir = new File(o.getPath());
fill(currentDir);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,8 @@ public View getView(int position, View convertView, ViewGroup parent) {
TextView fileSizeView = (TextView) v.findViewById(R.id.file_size);

ImageView fileIconView = (ImageView) v.findViewById(R.id.file_icon);
String uri = "drawable/" + o.getImage();
int imageResource = context.getResources().getIdentifier(uri, null, context.getPackageName());
//noinspection deprecation
Drawable image = context.getResources().getDrawable(imageResource);

Drawable image = context.getResources().getDrawable(o.getImage());

if (FilenameUtils.getExtension(o.getPath()).equals("png") || FilenameUtils.getExtension(o.getPath()).equals("jpg")) {
image = Drawable.createFromPath(o.getPath());
Expand Down
Binary file added app/src/main/res/drawable/directory_up.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable/viewer_folder.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable/viewer_image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable/viewer_jar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable/viewer_java.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable/viewer_xml.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit f230175

Please sign in to comment.