Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
This repository was archived by the owner on Feb 26, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@
*/
package org.androidannotations.handler;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import javax.annotation.processing.ProcessingEnvironment;

import org.androidannotations.handler.rest.DeleteHandler;
import org.androidannotations.handler.rest.GetHandler;
import org.androidannotations.handler.rest.HeadHandler;
Expand All @@ -32,13 +40,6 @@
import org.androidannotations.process.ProcessHolder;
import org.androidannotations.rclass.IRClass;

import javax.annotation.processing.ProcessingEnvironment;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

public class AnnotationHandlers {

private List<AnnotationHandler<? extends GeneratedClassHolder>> annotationHandlers = new ArrayList<AnnotationHandler<? extends GeneratedClassHolder>>();
Expand Down Expand Up @@ -147,8 +148,10 @@ public AnnotationHandlers(ProcessingEnvironment processingEnvironment) {
* SupposeUiThreadHandler and SupposeBackgroundHandler must be after all
* handlers that modifies generated method body
*/
add(new SupposeUiThreadHandler(processingEnvironment));
add(new SupposeBackgroundHandler(processingEnvironment));
if (optionsHelper.shouldEnsureThreadControl()) {
add(new SupposeUiThreadHandler(processingEnvironment));
add(new SupposeBackgroundHandler(processingEnvironment));
}
}

public void add(AnnotationHandler<? extends GeneratedClassHolder> annotationHandler) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,29 @@
public class OptionsHelper {

enum Option {
TRACE("trace"), //
ANDROID_MANIFEST_FILE("androidManifestFile"), //
RESOURCE_PACKAGE_NAME("resourcePackageName"), //
LOG_FILE("logFile"), //
LOG_LEVEL("logLevel"), //
LOG_APPENDER_CONSOLE("logAppenderConsole");
TRACE("trace", "false"), //
THREAD_CONTROL("threadControl", "true"), //
ANDROID_MANIFEST_FILE("androidManifestFile", null), //
RESOURCE_PACKAGE_NAME("resourcePackageName", null), //
LOG_FILE("logFile", null), //
LOG_LEVEL("logLevel", "DEBUG"), //
LOG_APPENDER_CONSOLE("logAppenderConsole", "false");

private String key;
private String defaultValue;

private Option(String key) {
private Option(String key, String defaultValue) {
this.key = key;
this.defaultValue = defaultValue;
}

public String getKey() {
return key;
}

public String getDefaultValue() {
return defaultValue;
}
}

private final Map<String, String> options;
Expand All @@ -62,6 +69,10 @@ public boolean shouldLogTrace() {
return getBoolean(Option.TRACE);
}

public boolean shouldEnsureThreadControl() {
return getBoolean(Option.THREAD_CONTROL);
}

public String getAndroidManifestFile() {
return getString(Option.ANDROID_MANIFEST_FILE);
}
Expand All @@ -78,7 +89,7 @@ public Level getLogLevel() {
try {
return Level.parse(getString(Option.LOG_LEVEL));
} catch (Exception e) {
return Level.DEBUG;
return Level.parse(Option.LOG_LEVEL.getDefaultValue());
}
}

Expand All @@ -87,17 +98,16 @@ public boolean shouldUseConsoleAppender() {
}

private String getString(Option option) {
return options.get(option.getKey());
}

private boolean getBoolean(Option option) {
String key = option.getKey();
if (options.containsKey(key)) {
String trace = options.get(key);
return !"false".equals(trace);
return options.get(key);
} else {
return false;
return option.getDefaultValue();
}
}

private boolean getBoolean(Option option) {
return Boolean.valueOf(getString(option));
}

}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.