Skip to content

Commit

Permalink
Fixed #4 NPE in Utils
Browse files Browse the repository at this point in the history
  • Loading branch information
Malinskiy committed Jun 11, 2016
1 parent 6545eab commit 09b4b8e
Showing 1 changed file with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,22 @@
import android.content.Context;
import android.util.Log;

import java.io.*;
import java.io.BufferedOutputStream;
import java.io.Closeable;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;

import static android.util.TypedValue.COMPLEX_UNIT_DIP;
import static android.util.TypedValue.applyDimension;
import static com.malinskiy.materialicons.Iconify.IconValue;
import static com.malinskiy.materialicons.Iconify.TAG;

class Utils {

public static final String ICON_FONT_FOLDER = "icon_tmp";
public static final String NAME_PREFIX = "{zmdi";
public static final String NAME_PREFIX = "{zmdi";

private Utils() {
// Prevents instantiation
Expand Down Expand Up @@ -49,6 +55,11 @@ static File resourceToFile(Context context, String resourceName) throws IOExcept
InputStream inputStream = null;
try {
inputStream = Iconify.class.getClassLoader().getResourceAsStream(resourceName);
if (inputStream == null) {
Log.e(TAG, "Font loading failed, getResourceAsStream returned null");
return null;
}

byte[] buffer = new byte[inputStream.available()];
bos = new BufferedOutputStream(new FileOutputStream(outPath));
int l = 0;
Expand Down

0 comments on commit 09b4b8e

Please sign in to comment.