Java Code Examples for com.activeandroid.util.Log#e()

The following examples show how to use com.activeandroid.util.Log#e() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Configuration.java    From clear-todolist with GNU General Public License v3.0 6 votes vote down vote up
private List<Class<? extends Model>> loadModelList(String[] models) {
	final List<Class<? extends Model>> modelClasses = new ArrayList<Class<? extends Model>>();
	final ClassLoader classLoader = mContext.getClass().getClassLoader();
	for (String model : models) {
		try {
			Class modelClass = Class.forName(model.trim(), false, classLoader);
			if (ReflectionUtils.isModel(modelClass)) {
				modelClasses.add(modelClass);
			}
		}
		catch (ClassNotFoundException e) {
			Log.e("Couldn't create class.", e);
		}
	}

	return modelClasses;
}
 
Example 2
Source File: Configuration.java    From clear-todolist with GNU General Public License v3.0 6 votes vote down vote up
private List<Class<? extends TypeSerializer>> loadSerializerList(String[] serializers) {
	final List<Class<? extends TypeSerializer>> typeSerializers = new ArrayList<Class<? extends TypeSerializer>>();
	final ClassLoader classLoader = mContext.getClass().getClassLoader();
	for (String serializer : serializers) {
		try {
			Class serializerClass = Class.forName(serializer.trim(), false, classLoader);
			if (ReflectionUtils.isTypeSerializer(serializerClass)) {
				typeSerializers.add(serializerClass);
			}
		}
		catch (ClassNotFoundException e) {
			Log.e("Couldn't create class.", e);
		}
	}

	return typeSerializers;
}
 
Example 3
Source File: Configuration.java    From mobile-android-survey-app with MIT License 6 votes vote down vote up
private List<Class<? extends Model>> loadModelList(String[] models) {
	final List<Class<? extends Model>> modelClasses = new ArrayList<Class<? extends Model>>();
	final ClassLoader classLoader = mContext.getClass().getClassLoader();
	for (String model : models) {
		try {
			Class modelClass = Class.forName(model.trim(), false, classLoader);
			if (ReflectionUtils.isModel(modelClass)) {
				modelClasses.add(modelClass);
			}
		}
		catch (ClassNotFoundException e) {
			Log.e("Couldn't create class.", e);
		}
	}

	return modelClasses;
}
 
Example 4
Source File: Configuration.java    From mobile-android-survey-app with MIT License 6 votes vote down vote up
private List<Class<? extends TypeSerializer>> loadSerializerList(String[] serializers) {
	final List<Class<? extends TypeSerializer>> typeSerializers = new ArrayList<Class<? extends TypeSerializer>>();
	final ClassLoader classLoader = mContext.getClass().getClassLoader();
	for (String serializer : serializers) {
		try {
			Class serializerClass = Class.forName(serializer.trim(), false, classLoader);
			if (ReflectionUtils.isTypeSerializer(serializerClass)) {
				typeSerializers.add(serializerClass);
			}
		}
		catch (ClassNotFoundException e) {
			Log.e("Couldn't create class.", e);
		}
	}

	return typeSerializers;
}
 
Example 5
Source File: ImporterAsyncTask.java    From 10000sentences with Apache License 2.0 5 votes vote down vote up
@Override
protected Void doInBackground(String... strings) {
    String url = strings[0];
    publishProgress(0);

    OkHttpClient httpClient = new OkHttpClient();
    Call call = httpClient.newCall(new Request.Builder().url(url).get().build());
    try {
        Response response = call.execute();

        InputStream stream = response.body().byteStream();
        BufferedReader reader = new BufferedReader(new InputStreamReader(stream));

        List<Sentence> sentences = new ArrayList<>();

        int order = 0;
        String line;
        while ((line = reader.readLine()) != null) {
            order += 1;
            sentences.add(parseSentence(order, line));
            if (sentences.size() == PROGRESS_EVERY) {
                importSentences(sentences);
                publishProgress(order);
            }
        }
        importSentences(sentences);
    } catch (Exception e) {
        Log.e(TAG, e.getMessage(), e);
        Toast.makeText(activity, R.string.error_retrieving, Toast.LENGTH_SHORT).show();
        return null;
    }

    dao.reloadCollectionCounter(collection);

    return null;
}
 
Example 6
Source File: ModelInfo.java    From clear-todolist with GNU General Public License v3.0 5 votes vote down vote up
public ModelInfo(Configuration configuration) {
	if (!loadModelFromMetaData(configuration)) {
		try {
			scanForModel(configuration.getContext());
		}
		catch (IOException e) {
			Log.e("Couldn't open source path.", e);
		}
	}

	Log.i("ModelInfo loaded.");
}
 
Example 7
Source File: IOUtils.java    From clear-todolist with GNU General Public License v3.0 5 votes vote down vote up
/**
 * <p>
 * Unconditionally close a {@link Closeable}.
 * </p>
 * Equivalent to {@link Closeable#close()}, except any exceptions will be ignored. This is
 * typically used in finally blocks.
 * @param closeable A {@link Closeable} to close.
 */
public static void closeQuietly(final Closeable closeable) {

    if (closeable == null) {
        return;
    }

    try {
        closeable.close();
    } catch (final IOException e) {
        Log.e("Couldn't close closeable.", e);
    }
}
 
Example 8
Source File: IOUtils.java    From clear-todolist with GNU General Public License v3.0 5 votes vote down vote up
/**
 * <p>
 * Unconditionally close a {@link Cursor}.
 * </p>
 * Equivalent to {@link Cursor#close()}, except any exceptions will be ignored. This is
 * typically used in finally blocks.
 * @param cursor A {@link Cursor} to close.
 */
public static void closeQuietly(final Cursor cursor) {

    if (cursor == null) {
        return;
    }

    try {
        cursor.close();
    } catch (final Exception e) {
        Log.e("Couldn't close cursor.", e);
    }
}
 
Example 9
Source File: DatabaseHelper.java    From clear-todolist with GNU General Public License v3.0 5 votes vote down vote up
public void copyAttachedDatabase(Context context, String databaseName) {
	final File dbPath = context.getDatabasePath(databaseName);

	// If the database already exists, return
	if (dbPath.exists()) {
		return;
	}

	// Make sure we have a path to the file
	dbPath.getParentFile().mkdirs();

	// Try to copy database file
	try {
		final InputStream inputStream = context.getAssets().open(databaseName);
		final OutputStream output = new FileOutputStream(dbPath);

		byte[] buffer = new byte[8192];
		int length;

		while ((length = inputStream.read(buffer, 0, 8192)) > 0) {
			output.write(buffer, 0, length);
		}

		output.flush();
		output.close();
		inputStream.close();
	}
	catch (IOException e) {
		Log.e("Failed to open file", e);
	}
}
 
Example 10
Source File: ModelInfo.java    From mobile-android-survey-app with MIT License 5 votes vote down vote up
public ModelInfo(Configuration configuration) {
	if (!loadModelFromMetaData(configuration)) {
		try {
			scanForModel(configuration.getContext());
		}
		catch (IOException e) {
			Log.e("Couldn't open source path.", e);
		}
	}

	Log.i("ModelInfo loaded.");
}
 
Example 11
Source File: IOUtils.java    From mobile-android-survey-app with MIT License 5 votes vote down vote up
/**
 * <p>
 * Unconditionally close a {@link Closeable}.
 * </p>
 * Equivalent to {@link Closeable#close()}, except any exceptions will be ignored. This is
 * typically used in finally blocks.
 * @param closeable A {@link Closeable} to close.
 */
public static void closeQuietly(final Closeable closeable) {

    if (closeable == null) {
        return;
    }

    try {
        closeable.close();
    } catch (final IOException e) {
        Log.e("Couldn't close closeable.", e);
    }
}
 
Example 12
Source File: IOUtils.java    From mobile-android-survey-app with MIT License 5 votes vote down vote up
/**
 * <p>
 * Unconditionally close a {@link Cursor}.
 * </p>
 * Equivalent to {@link Cursor#close()}, except any exceptions will be ignored. This is
 * typically used in finally blocks.
 * @param cursor A {@link Cursor} to close.
 */
public static void closeQuietly(final Cursor cursor) {

    if (cursor == null) {
        return;
    }

    try {
        cursor.close();
    } catch (final Exception e) {
        Log.e("Couldn't close cursor.", e);
    }
}
 
Example 13
Source File: DatabaseHelper.java    From mobile-android-survey-app with MIT License 5 votes vote down vote up
public void copyAttachedDatabase(Context context, String databaseName) {
	final File dbPath = context.getDatabasePath(databaseName);

	// If the database already exists, return
	if (dbPath.exists()) {
		return;
	}

	// Make sure we have a path to the file
	dbPath.getParentFile().mkdirs();

	// Try to copy database file
	try {
		final InputStream inputStream = context.getAssets().open(databaseName);
		final OutputStream output = new FileOutputStream(dbPath);

		byte[] buffer = new byte[8192];
		int length;

		while ((length = inputStream.read(buffer, 0, 8192)) > 0) {
			output.write(buffer, 0, length);
		}

		output.flush();
		output.close();
		inputStream.close();
	}
	catch (IOException e) {
		Log.e("Failed to open file", e);
	}
}
 
Example 14
Source File: DatabaseHelper.java    From clear-todolist with GNU General Public License v3.0 4 votes vote down vote up
private void executeSqlScript(SQLiteDatabase db, String file) {

	    InputStream stream = null;

		try {
		    stream = Cache.getContext().getAssets().open(MIGRATION_PATH + "/" + file);

		    if (Configuration.SQL_PARSER_DELIMITED.equalsIgnoreCase(mSqlParser)) {
		        executeDelimitedSqlScript(db, stream);

		    } else {
		        executeLegacySqlScript(db, stream);

		    }

		} catch (IOException e) {
			Log.e("Failed to execute " + file, e);

		} finally {
		    IOUtils.closeQuietly(stream);

		}
	}
 
Example 15
Source File: DatabaseHelper.java    From mobile-android-survey-app with MIT License 4 votes vote down vote up
private void executeSqlScript(SQLiteDatabase db, String file) {

	    InputStream stream = null;

		try {
		    stream = Cache.getContext().getAssets().open(MIGRATION_PATH + "/" + file);

		    if (Configuration.SQL_PARSER_DELIMITED.equalsIgnoreCase(mSqlParser)) {
		        executeDelimitedSqlScript(db, stream);

		    } else {
		        executeLegacySqlScript(db, stream);

		    }

		} catch (IOException e) {
			Log.e("Failed to execute " + file, e);

		} finally {
		    IOUtils.closeQuietly(stream);

		}
	}