repo_name stringlengths 7 104 | file_path stringlengths 13 198 | context stringlengths 67 7.15k | import_statement stringlengths 16 4.43k | code stringlengths 40 6.98k | prompt stringlengths 227 8.27k | next_line stringlengths 8 795 |
|---|---|---|---|---|---|---|
irengrig/fossil4idea | test/org/github/irengrig/test/TextUtilTest.java | // Path: src/org/github/irengrig/fossil4idea/util/TextUtil.java
// public class TextUtil {
// private final static int optimal = 100;
// private final int myLimit;
//
// public TextUtil() {
// this(-1);
// }
//
// public TextUtil(int limit) {
// this.myLimit = limit < 0 ? optimal : limit;
// }
//
// public String insertLineCuts(final String s) {
// if (s == null || s.length() <= myLimit) return s;
// final int idx = s.substring(0, myLimit).lastIndexOf(' ');
// if (idx > 0) {
// return s.substring(0, idx) + "\n" + insertLineCuts(s.substring(idx + 1));
// }
// final int idx2 = s.indexOf(' ', myLimit);
// if (idx2 == -1) return s;
// return s.substring(0, idx2) + "\n" + insertLineCuts(s.substring(idx2 + 1));
// }
// }
| import org.github.irengrig.fossil4idea.util.TextUtil;
import org.junit.Test; | package org.github.irengrig.test;
/**
* Created by Irina.Chernushina on 5/29/2014.
*/
public class TextUtilTest {
@Test
public void testSimple() throws Exception {
final String s = "The ui command is intended for accessing the web interface from a local desktop. " +
"The ui command binds to the loopback IP address only (and thus makes the web interface visible only on the local machine)" +
" and it automatically start your web browser pointing at the server. " +
"someverylongfortest13213243254354365465765765 " +
"For cross-machine collaboration, use the server command, which binds on all IP addresses and does not try to start a web browser.";
// test is for it's not eternal | // Path: src/org/github/irengrig/fossil4idea/util/TextUtil.java
// public class TextUtil {
// private final static int optimal = 100;
// private final int myLimit;
//
// public TextUtil() {
// this(-1);
// }
//
// public TextUtil(int limit) {
// this.myLimit = limit < 0 ? optimal : limit;
// }
//
// public String insertLineCuts(final String s) {
// if (s == null || s.length() <= myLimit) return s;
// final int idx = s.substring(0, myLimit).lastIndexOf(' ');
// if (idx > 0) {
// return s.substring(0, idx) + "\n" + insertLineCuts(s.substring(idx + 1));
// }
// final int idx2 = s.indexOf(' ', myLimit);
// if (idx2 == -1) return s;
// return s.substring(0, idx2) + "\n" + insertLineCuts(s.substring(idx2 + 1));
// }
// }
// Path: test/org/github/irengrig/test/TextUtilTest.java
import org.github.irengrig.fossil4idea.util.TextUtil;
import org.junit.Test;
package org.github.irengrig.test;
/**
* Created by Irina.Chernushina on 5/29/2014.
*/
public class TextUtilTest {
@Test
public void testSimple() throws Exception {
final String s = "The ui command is intended for accessing the web interface from a local desktop. " +
"The ui command binds to the loopback IP address only (and thus makes the web interface visible only on the local machine)" +
" and it automatically start your web browser pointing at the server. " +
"someverylongfortest13213243254354365465765765 " +
"For cross-machine collaboration, use the server command, which binds on all IP addresses and does not try to start a web browser.";
// test is for it's not eternal | final String cuts = new TextUtil(15).insertLineCuts(s); |
irengrig/fossil4idea | src/org/github/irengrig/fossil4idea/actions/InitAction.java | // Path: src/org/github/irengrig/fossil4idea/checkout/CheckoutUtil.java
// public class CheckoutUtil {
// private final Project myProject;
//
// public CheckoutUtil(final Project project) {
// myProject = project;
// }
//
// public void cloneRepo(final String url, final String localPath) throws VcsException {
// final File file = new File(localPath);
// final FossilSimpleCommand command = new FossilSimpleCommand(myProject, file.getParentFile(), FCommandName.clone);
// command.addParameters(url, localPath);
// final String result = command.run();
// }
//
// public void checkout(final File repo, final File target, final String hash) throws VcsException {
// final FossilSimpleCommand command = new FossilSimpleCommand(myProject, target, FCommandName.open);
// command.addParameters(repo.getAbsolutePath());
// if (hash != null) {
// command.addParameters(hash);
// }
// command.run();
// }
//
// public void initRepository(final File repo) throws VcsException {
// final File parentFile = repo.getParentFile();
// if (parentFile.exists() && ! parentFile.isDirectory()) {
// throw new VcsException("Can not create Fossil repository, " + parentFile.getPath() + " is not a directory.");
// }
// if (! parentFile.exists() && ! parentFile.mkdirs()) {
// throw new VcsException("Can not create Fossil repository, can not create parent directory: " + parentFile.getPath());
// }
// final FossilSimpleCommand command = new FossilSimpleCommand(myProject, parentFile, FCommandName.init);
// command.addParameters(repo.getName());
// command.run();
// }
// }
| import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.fileChooser.FileChooserFactory;
import com.intellij.openapi.fileChooser.FileSaverDescriptor;
import com.intellij.openapi.fileChooser.FileSaverDialog;
import com.intellij.openapi.progress.PerformInBackgroundOption;
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.progress.ProgressManager;
import com.intellij.openapi.progress.Task;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.MessageType;
import com.intellij.openapi.vcs.VcsException;
import com.intellij.openapi.vcs.ui.VcsBalloonProblemNotifier;
import com.intellij.openapi.vfs.VirtualFileWrapper;
import org.github.irengrig.fossil4idea.checkout.CheckoutUtil;
import org.jetbrains.annotations.NotNull; | package org.github.irengrig.fossil4idea.actions;
/**
* Created by Irina.Chernushina on 5/29/2014.
*/
public class InitAction extends com.intellij.openapi.actionSystem.AnAction {
@Override
public void actionPerformed(AnActionEvent anActionEvent) {
final Project project = PlatformDataKeys.PROJECT.getData(anActionEvent.getDataContext());
if (project == null) return;
final FileSaverDialog dialog = FileChooserFactory.getInstance().createSaveFileDialog(new FileSaverDescriptor("Init Fossil Repository",
"Select file where to create new Fossil repository."), project);
final VirtualFileWrapper wrapper = dialog.save(null, null);
if (wrapper == null) return;
final Task.Backgroundable task = new Task.Backgroundable(project, "Init Fossil Repository", false, PerformInBackgroundOption.ALWAYS_BACKGROUND) {
@Override
public void run(@NotNull ProgressIndicator progressIndicator) {
try { | // Path: src/org/github/irengrig/fossil4idea/checkout/CheckoutUtil.java
// public class CheckoutUtil {
// private final Project myProject;
//
// public CheckoutUtil(final Project project) {
// myProject = project;
// }
//
// public void cloneRepo(final String url, final String localPath) throws VcsException {
// final File file = new File(localPath);
// final FossilSimpleCommand command = new FossilSimpleCommand(myProject, file.getParentFile(), FCommandName.clone);
// command.addParameters(url, localPath);
// final String result = command.run();
// }
//
// public void checkout(final File repo, final File target, final String hash) throws VcsException {
// final FossilSimpleCommand command = new FossilSimpleCommand(myProject, target, FCommandName.open);
// command.addParameters(repo.getAbsolutePath());
// if (hash != null) {
// command.addParameters(hash);
// }
// command.run();
// }
//
// public void initRepository(final File repo) throws VcsException {
// final File parentFile = repo.getParentFile();
// if (parentFile.exists() && ! parentFile.isDirectory()) {
// throw new VcsException("Can not create Fossil repository, " + parentFile.getPath() + " is not a directory.");
// }
// if (! parentFile.exists() && ! parentFile.mkdirs()) {
// throw new VcsException("Can not create Fossil repository, can not create parent directory: " + parentFile.getPath());
// }
// final FossilSimpleCommand command = new FossilSimpleCommand(myProject, parentFile, FCommandName.init);
// command.addParameters(repo.getName());
// command.run();
// }
// }
// Path: src/org/github/irengrig/fossil4idea/actions/InitAction.java
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.fileChooser.FileChooserFactory;
import com.intellij.openapi.fileChooser.FileSaverDescriptor;
import com.intellij.openapi.fileChooser.FileSaverDialog;
import com.intellij.openapi.progress.PerformInBackgroundOption;
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.progress.ProgressManager;
import com.intellij.openapi.progress.Task;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.MessageType;
import com.intellij.openapi.vcs.VcsException;
import com.intellij.openapi.vcs.ui.VcsBalloonProblemNotifier;
import com.intellij.openapi.vfs.VirtualFileWrapper;
import org.github.irengrig.fossil4idea.checkout.CheckoutUtil;
import org.jetbrains.annotations.NotNull;
package org.github.irengrig.fossil4idea.actions;
/**
* Created by Irina.Chernushina on 5/29/2014.
*/
public class InitAction extends com.intellij.openapi.actionSystem.AnAction {
@Override
public void actionPerformed(AnActionEvent anActionEvent) {
final Project project = PlatformDataKeys.PROJECT.getData(anActionEvent.getDataContext());
if (project == null) return;
final FileSaverDialog dialog = FileChooserFactory.getInstance().createSaveFileDialog(new FileSaverDescriptor("Init Fossil Repository",
"Select file where to create new Fossil repository."), project);
final VirtualFileWrapper wrapper = dialog.save(null, null);
if (wrapper == null) return;
final Task.Backgroundable task = new Task.Backgroundable(project, "Init Fossil Repository", false, PerformInBackgroundOption.ALWAYS_BACKGROUND) {
@Override
public void run(@NotNull ProgressIndicator progressIndicator) {
try { | new CheckoutUtil(project).initRepository(wrapper.getFile()); |
irengrig/fossil4idea | test/org/github/irengrig/test/DiffUtilTest.java | // Path: src/org/github/irengrig/fossil4idea/local/DiffUtil.java
// public class DiffUtil {
// private final static Logger LOG = Logger.getInstance(DiffUtil.class);
// public String execute(final String text, String patchContent, final String fileName) throws VcsException {
// patchContent = reversePatch(patchContent);
// final PatchReader patchReader = new PatchReader(patchContent);
// try {
// patchReader.parseAllPatches();
// } catch (PatchSyntaxException e) {
// throw new VcsException("Patch syntax exception in: " + fileName, e);
// }
// final List<TextFilePatch> patches = patchReader.getPatches();
// if (patches.size() != 1) throw new VcsException("Not one file patch in provided char sequence in: " + fileName);
//
// final TextFilePatch patch = patches.get(0);
// final GenericPatchApplier applier = new GenericPatchApplier(text, patch.getHunks());
// if (! applier.execute()) {
// LOG.info("Patch apply problems for: " + fileName);
// applier.trySolveSomehow();
// }
// return applier.getAfter();
// }
//
// public static String reversePatch(String patchContent) {
// final String[] strings = patchContent.split("\n");
// final StringBuilder sb = new StringBuilder();
// int cnt = 0;
// String s = strings[cnt];
//
// while (cnt < strings.length) {
// // context
// while (contextOrHeader(s) && cnt < strings.length) {
// sb.append(s);
// if (cnt < (strings.length - 1)) sb.append("\n");
// ++ cnt;
// if (cnt >= strings.length) break;
// s = strings[cnt];
// }
//
// if (cnt >= strings.length) break;
//
// final StringBuilder minus = new StringBuilder();
// final StringBuilder plus = new StringBuilder();
// while (cnt < strings.length && (s.startsWith("+") || s.startsWith("-"))) {
// if (s.startsWith("+")) {
// minus.append("-").append(s.substring(1));
// minus.append("\n");
// } else {
// plus.append("+").append(s.substring(1));
// plus.append("\n");
// }
// ++cnt;
// if (cnt >= strings.length) break;
// s = strings[cnt];
// }
// sb.append(minus.toString());
// sb.append(plus.toString());
// }
// final String val = sb.toString();
// // cut \n back if was added in the end
// if (val.endsWith("\n")) return val.substring(0, val.length() - 1);
// return val;
// }
//
// private static boolean contextOrHeader(String s) {
// if (s.startsWith("+++")) return true;
// if (s.startsWith("---")) return true;
// return !s.startsWith("+") && !s.startsWith("-");
// }
// }
| import org.github.irengrig.fossil4idea.local.DiffUtil;
import org.junit.Assert;
import org.junit.Test; | " }\n" +
"}\n";
final String changed = "package com.something;\n" +
"\n" +
"/**\n" +
" * Created by Irina.Chernushina on 5/29/2014.\n" +
" */\n" +
"public class Test4 {//\n" +
"\n" +
" public static void main(String[] args) {\n" +
" System.out.println(\"***\");\n" +
" }\n" +
"}\n";
final String patch = "Index: src/com/something/Test4.java\n" +
"==================================================================\n" +
"--- src/com/something/Test4.java\n" +
"+++ src/com/something/Test4.java\n" +
"@@ -1,11 +1,11 @@\n" +
" package com.something;\n" +
"\n" +
" /**\n" +
" * Created by Irina.Chernushina on 5/29/2014.\n" +
" */\n" +
"-public class Test3 {//\n" +
"+public class Test4 {//\n" +
"\n" +
" public static void main(String[] args) {\n" +
" System.out.println(\"***\");\n" +
" }\n" +
" }"; | // Path: src/org/github/irengrig/fossil4idea/local/DiffUtil.java
// public class DiffUtil {
// private final static Logger LOG = Logger.getInstance(DiffUtil.class);
// public String execute(final String text, String patchContent, final String fileName) throws VcsException {
// patchContent = reversePatch(patchContent);
// final PatchReader patchReader = new PatchReader(patchContent);
// try {
// patchReader.parseAllPatches();
// } catch (PatchSyntaxException e) {
// throw new VcsException("Patch syntax exception in: " + fileName, e);
// }
// final List<TextFilePatch> patches = patchReader.getPatches();
// if (patches.size() != 1) throw new VcsException("Not one file patch in provided char sequence in: " + fileName);
//
// final TextFilePatch patch = patches.get(0);
// final GenericPatchApplier applier = new GenericPatchApplier(text, patch.getHunks());
// if (! applier.execute()) {
// LOG.info("Patch apply problems for: " + fileName);
// applier.trySolveSomehow();
// }
// return applier.getAfter();
// }
//
// public static String reversePatch(String patchContent) {
// final String[] strings = patchContent.split("\n");
// final StringBuilder sb = new StringBuilder();
// int cnt = 0;
// String s = strings[cnt];
//
// while (cnt < strings.length) {
// // context
// while (contextOrHeader(s) && cnt < strings.length) {
// sb.append(s);
// if (cnt < (strings.length - 1)) sb.append("\n");
// ++ cnt;
// if (cnt >= strings.length) break;
// s = strings[cnt];
// }
//
// if (cnt >= strings.length) break;
//
// final StringBuilder minus = new StringBuilder();
// final StringBuilder plus = new StringBuilder();
// while (cnt < strings.length && (s.startsWith("+") || s.startsWith("-"))) {
// if (s.startsWith("+")) {
// minus.append("-").append(s.substring(1));
// minus.append("\n");
// } else {
// plus.append("+").append(s.substring(1));
// plus.append("\n");
// }
// ++cnt;
// if (cnt >= strings.length) break;
// s = strings[cnt];
// }
// sb.append(minus.toString());
// sb.append(plus.toString());
// }
// final String val = sb.toString();
// // cut \n back if was added in the end
// if (val.endsWith("\n")) return val.substring(0, val.length() - 1);
// return val;
// }
//
// private static boolean contextOrHeader(String s) {
// if (s.startsWith("+++")) return true;
// if (s.startsWith("---")) return true;
// return !s.startsWith("+") && !s.startsWith("-");
// }
// }
// Path: test/org/github/irengrig/test/DiffUtilTest.java
import org.github.irengrig.fossil4idea.local.DiffUtil;
import org.junit.Assert;
import org.junit.Test;
" }\n" +
"}\n";
final String changed = "package com.something;\n" +
"\n" +
"/**\n" +
" * Created by Irina.Chernushina on 5/29/2014.\n" +
" */\n" +
"public class Test4 {//\n" +
"\n" +
" public static void main(String[] args) {\n" +
" System.out.println(\"***\");\n" +
" }\n" +
"}\n";
final String patch = "Index: src/com/something/Test4.java\n" +
"==================================================================\n" +
"--- src/com/something/Test4.java\n" +
"+++ src/com/something/Test4.java\n" +
"@@ -1,11 +1,11 @@\n" +
" package com.something;\n" +
"\n" +
" /**\n" +
" * Created by Irina.Chernushina on 5/29/2014.\n" +
" */\n" +
"-public class Test3 {//\n" +
"+public class Test4 {//\n" +
"\n" +
" public static void main(String[] args) {\n" +
" System.out.println(\"***\");\n" +
" }\n" +
" }"; | final String test = new DiffUtil().execute(changed, patch, "test"); |
irengrig/fossil4idea | src/org/github/irengrig/fossil4idea/checkin/FossilCheckinEnvironment.java | // Path: src/org/github/irengrig/fossil4idea/util/FossilUtils.java
// public class FossilUtils {
// public static final Convertor<FilePath, File> FILE_PATH_FILE_CONVERTOR = new Convertor<FilePath, File>() {
// @Override
// public File convert(final FilePath filePath) {
// return filePath.getIOFile();
// }
// };
//
// public static <T> List<T> ensureList(@NotNull final Collection<T> coll) {
// return coll instanceof List ? (List<T>) coll : new ArrayList<T>(coll);
// }
// }
//
// Path: src/org/github/irengrig/fossil4idea/FossilVcs.java
// public class FossilVcs extends AbstractVcs {
// public static String NAME = "fossil";
// public static String DISPLAY_NAME = "Fossil";
// private FossilChangeProvider myChangeProvider;
// private static final VcsKey ourKey = createKey(NAME);
// private FossilVfsListener myVfsListener;
// private UiManager uiManager;
// private FossilCheckinEnvironment fossilCheckinEnvironment;
//
// public FossilVcs(Project project) {
// super(project, NAME);
// }
//
// @Override
// public String getDisplayName() {
// return DISPLAY_NAME;
// }
//
// @Override
// public Configurable getConfigurable() {
// return new FossilConfigurable(myProject);
// }
//
// @Override
// protected void activate() {
// myVfsListener = new FossilVfsListener(myProject);
// uiManager = new UiManager(myProject);
// }
//
// @Override
// protected void deactivate() {
// if (myVfsListener != null) {
// Disposer.dispose(myVfsListener);
// myVfsListener = null;
// uiManager.stop();
// }
// }
//
// public UiManager getUiManager() {
// return uiManager;
// }
//
// @Nullable
// @Override
// public ChangeProvider getChangeProvider() {
// if (myChangeProvider == null) {
// myChangeProvider = new FossilChangeProvider(myProject);
// }
// return myChangeProvider;
// }
//
// @Nullable
// @Override
// protected CheckinEnvironment createCheckinEnvironment() {
// if (fossilCheckinEnvironment == null) {
// fossilCheckinEnvironment = new FossilCheckinEnvironment(this);
// }
// return fossilCheckinEnvironment;
// }
//
// @Nullable
// @Override
// protected RollbackEnvironment createRollbackEnvironment() {
// return new FossilRollbackEnvironment(this);
// }
//
// @Nullable
// @Override
// public VcsHistoryProvider getVcsHistoryProvider() {
// return new FossilHistoryProvider(this);
// }
//
// @Nullable
// @Override
// protected UpdateEnvironment createUpdateEnvironment() {
// return new FossilUpdateEnvironment(this);
// }
//
// @Override
// public List<CommitExecutor> getCommitExecutors() {
// return Collections.<CommitExecutor>singletonList(new FossilCommitAndPushExecutor(myProject));
// }
//
// public void checkVersion() {
// //todo
// }
//
// @Nullable
// @Override
// public DiffProvider getDiffProvider() {
// return new FossilDiffProvider(this);
// }
//
// public static FossilVcs getInstance(final Project project) {
// return (FossilVcs) ProjectLevelVcsManager.getInstance(project).findVcsByName(NAME);
// }
//
// public static VcsKey getVcsKey() {
// return ourKey;
// }
//
// @Nullable
// @Override
// public AnnotationProvider getAnnotationProvider() {
// return new FossilAnnotationProvider(this);
// }
// }
| import com.intellij.openapi.ui.MessageType;
import com.intellij.openapi.ui.popup.util.PopupUtil;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vcs.CheckinProjectPanel;
import com.intellij.openapi.vcs.FilePath;
import com.intellij.openapi.vcs.ObjectsConvertor;
import com.intellij.openapi.vcs.VcsException;
import com.intellij.openapi.vcs.changes.Change;
import com.intellij.openapi.vcs.changes.ChangeList;
import com.intellij.openapi.vcs.changes.ChangesUtil;
import com.intellij.openapi.vcs.checkin.CheckinEnvironment;
import com.intellij.openapi.vcs.ui.RefreshableOnComponent;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.FunctionUtil;
import com.intellij.util.NullableFunction;
import com.intellij.util.PairConsumer;
import com.intellij.util.containers.Convertor;
import org.github.irengrig.fossil4idea.util.FossilUtils;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.github.irengrig.fossil4idea.FossilVcs;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Set; | final List<VcsException> exceptions = new ArrayList<VcsException>();
try {
final List<String> hashes = checkinUtil.checkin(files, preparedComment);
if (hashes != null && ! hashes.isEmpty()) {
if (feedback == null) {
// popup
PopupUtil.showBalloonForActiveComponent(createMessage(hashes), MessageType.INFO);
} else {
feedback.add(createMessage(hashes));
}
// something committed & need to push
if (wasToPush) {
checkinUtil.push();
}
}
} catch (VcsException e) {
exceptions.add(e);
}
return exceptions;
}
private String createMessage(final List<String> hashes) {
return "Fossil: committed: " + StringUtil.join(hashes, ",");
}
@Nullable
@Override
public List<VcsException> scheduleMissingFileForDeletion(final List<FilePath> files) {
final List<VcsException> result = new ArrayList<VcsException>();
try { | // Path: src/org/github/irengrig/fossil4idea/util/FossilUtils.java
// public class FossilUtils {
// public static final Convertor<FilePath, File> FILE_PATH_FILE_CONVERTOR = new Convertor<FilePath, File>() {
// @Override
// public File convert(final FilePath filePath) {
// return filePath.getIOFile();
// }
// };
//
// public static <T> List<T> ensureList(@NotNull final Collection<T> coll) {
// return coll instanceof List ? (List<T>) coll : new ArrayList<T>(coll);
// }
// }
//
// Path: src/org/github/irengrig/fossil4idea/FossilVcs.java
// public class FossilVcs extends AbstractVcs {
// public static String NAME = "fossil";
// public static String DISPLAY_NAME = "Fossil";
// private FossilChangeProvider myChangeProvider;
// private static final VcsKey ourKey = createKey(NAME);
// private FossilVfsListener myVfsListener;
// private UiManager uiManager;
// private FossilCheckinEnvironment fossilCheckinEnvironment;
//
// public FossilVcs(Project project) {
// super(project, NAME);
// }
//
// @Override
// public String getDisplayName() {
// return DISPLAY_NAME;
// }
//
// @Override
// public Configurable getConfigurable() {
// return new FossilConfigurable(myProject);
// }
//
// @Override
// protected void activate() {
// myVfsListener = new FossilVfsListener(myProject);
// uiManager = new UiManager(myProject);
// }
//
// @Override
// protected void deactivate() {
// if (myVfsListener != null) {
// Disposer.dispose(myVfsListener);
// myVfsListener = null;
// uiManager.stop();
// }
// }
//
// public UiManager getUiManager() {
// return uiManager;
// }
//
// @Nullable
// @Override
// public ChangeProvider getChangeProvider() {
// if (myChangeProvider == null) {
// myChangeProvider = new FossilChangeProvider(myProject);
// }
// return myChangeProvider;
// }
//
// @Nullable
// @Override
// protected CheckinEnvironment createCheckinEnvironment() {
// if (fossilCheckinEnvironment == null) {
// fossilCheckinEnvironment = new FossilCheckinEnvironment(this);
// }
// return fossilCheckinEnvironment;
// }
//
// @Nullable
// @Override
// protected RollbackEnvironment createRollbackEnvironment() {
// return new FossilRollbackEnvironment(this);
// }
//
// @Nullable
// @Override
// public VcsHistoryProvider getVcsHistoryProvider() {
// return new FossilHistoryProvider(this);
// }
//
// @Nullable
// @Override
// protected UpdateEnvironment createUpdateEnvironment() {
// return new FossilUpdateEnvironment(this);
// }
//
// @Override
// public List<CommitExecutor> getCommitExecutors() {
// return Collections.<CommitExecutor>singletonList(new FossilCommitAndPushExecutor(myProject));
// }
//
// public void checkVersion() {
// //todo
// }
//
// @Nullable
// @Override
// public DiffProvider getDiffProvider() {
// return new FossilDiffProvider(this);
// }
//
// public static FossilVcs getInstance(final Project project) {
// return (FossilVcs) ProjectLevelVcsManager.getInstance(project).findVcsByName(NAME);
// }
//
// public static VcsKey getVcsKey() {
// return ourKey;
// }
//
// @Nullable
// @Override
// public AnnotationProvider getAnnotationProvider() {
// return new FossilAnnotationProvider(this);
// }
// }
// Path: src/org/github/irengrig/fossil4idea/checkin/FossilCheckinEnvironment.java
import com.intellij.openapi.ui.MessageType;
import com.intellij.openapi.ui.popup.util.PopupUtil;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vcs.CheckinProjectPanel;
import com.intellij.openapi.vcs.FilePath;
import com.intellij.openapi.vcs.ObjectsConvertor;
import com.intellij.openapi.vcs.VcsException;
import com.intellij.openapi.vcs.changes.Change;
import com.intellij.openapi.vcs.changes.ChangeList;
import com.intellij.openapi.vcs.changes.ChangesUtil;
import com.intellij.openapi.vcs.checkin.CheckinEnvironment;
import com.intellij.openapi.vcs.ui.RefreshableOnComponent;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.FunctionUtil;
import com.intellij.util.NullableFunction;
import com.intellij.util.PairConsumer;
import com.intellij.util.containers.Convertor;
import org.github.irengrig.fossil4idea.util.FossilUtils;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.github.irengrig.fossil4idea.FossilVcs;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
final List<VcsException> exceptions = new ArrayList<VcsException>();
try {
final List<String> hashes = checkinUtil.checkin(files, preparedComment);
if (hashes != null && ! hashes.isEmpty()) {
if (feedback == null) {
// popup
PopupUtil.showBalloonForActiveComponent(createMessage(hashes), MessageType.INFO);
} else {
feedback.add(createMessage(hashes));
}
// something committed & need to push
if (wasToPush) {
checkinUtil.push();
}
}
} catch (VcsException e) {
exceptions.add(e);
}
return exceptions;
}
private String createMessage(final List<String> hashes) {
return "Fossil: committed: " + StringUtil.join(hashes, ",");
}
@Nullable
@Override
public List<VcsException> scheduleMissingFileForDeletion(final List<FilePath> files) {
final List<VcsException> result = new ArrayList<VcsException>();
try { | AddUtil.deleteImpl(myFossilVcs.getProject(), ObjectsConvertor.convert(files, FossilUtils.FILE_PATH_FILE_CONVERTOR)); |
irengrig/fossil4idea | src/org/github/irengrig/fossil4idea/actions/FossilGroup.java | // Path: src/org/github/irengrig/fossil4idea/FossilVcs.java
// public class FossilVcs extends AbstractVcs {
// public static String NAME = "fossil";
// public static String DISPLAY_NAME = "Fossil";
// private FossilChangeProvider myChangeProvider;
// private static final VcsKey ourKey = createKey(NAME);
// private FossilVfsListener myVfsListener;
// private UiManager uiManager;
// private FossilCheckinEnvironment fossilCheckinEnvironment;
//
// public FossilVcs(Project project) {
// super(project, NAME);
// }
//
// @Override
// public String getDisplayName() {
// return DISPLAY_NAME;
// }
//
// @Override
// public Configurable getConfigurable() {
// return new FossilConfigurable(myProject);
// }
//
// @Override
// protected void activate() {
// myVfsListener = new FossilVfsListener(myProject);
// uiManager = new UiManager(myProject);
// }
//
// @Override
// protected void deactivate() {
// if (myVfsListener != null) {
// Disposer.dispose(myVfsListener);
// myVfsListener = null;
// uiManager.stop();
// }
// }
//
// public UiManager getUiManager() {
// return uiManager;
// }
//
// @Nullable
// @Override
// public ChangeProvider getChangeProvider() {
// if (myChangeProvider == null) {
// myChangeProvider = new FossilChangeProvider(myProject);
// }
// return myChangeProvider;
// }
//
// @Nullable
// @Override
// protected CheckinEnvironment createCheckinEnvironment() {
// if (fossilCheckinEnvironment == null) {
// fossilCheckinEnvironment = new FossilCheckinEnvironment(this);
// }
// return fossilCheckinEnvironment;
// }
//
// @Nullable
// @Override
// protected RollbackEnvironment createRollbackEnvironment() {
// return new FossilRollbackEnvironment(this);
// }
//
// @Nullable
// @Override
// public VcsHistoryProvider getVcsHistoryProvider() {
// return new FossilHistoryProvider(this);
// }
//
// @Nullable
// @Override
// protected UpdateEnvironment createUpdateEnvironment() {
// return new FossilUpdateEnvironment(this);
// }
//
// @Override
// public List<CommitExecutor> getCommitExecutors() {
// return Collections.<CommitExecutor>singletonList(new FossilCommitAndPushExecutor(myProject));
// }
//
// public void checkVersion() {
// //todo
// }
//
// @Nullable
// @Override
// public DiffProvider getDiffProvider() {
// return new FossilDiffProvider(this);
// }
//
// public static FossilVcs getInstance(final Project project) {
// return (FossilVcs) ProjectLevelVcsManager.getInstance(project).findVcsByName(NAME);
// }
//
// public static VcsKey getVcsKey() {
// return ourKey;
// }
//
// @Nullable
// @Override
// public AnnotationProvider getAnnotationProvider() {
// return new FossilAnnotationProvider(this);
// }
// }
| import com.intellij.openapi.project.Project;
import com.intellij.openapi.vcs.AbstractVcs;
import com.intellij.openapi.vcs.actions.StandardVcsGroup;
import org.github.irengrig.fossil4idea.FossilVcs;
import org.jetbrains.annotations.Nullable; | package org.github.irengrig.fossil4idea.actions;
public class FossilGroup extends StandardVcsGroup {
@Override
public AbstractVcs getVcs(Project project) { | // Path: src/org/github/irengrig/fossil4idea/FossilVcs.java
// public class FossilVcs extends AbstractVcs {
// public static String NAME = "fossil";
// public static String DISPLAY_NAME = "Fossil";
// private FossilChangeProvider myChangeProvider;
// private static final VcsKey ourKey = createKey(NAME);
// private FossilVfsListener myVfsListener;
// private UiManager uiManager;
// private FossilCheckinEnvironment fossilCheckinEnvironment;
//
// public FossilVcs(Project project) {
// super(project, NAME);
// }
//
// @Override
// public String getDisplayName() {
// return DISPLAY_NAME;
// }
//
// @Override
// public Configurable getConfigurable() {
// return new FossilConfigurable(myProject);
// }
//
// @Override
// protected void activate() {
// myVfsListener = new FossilVfsListener(myProject);
// uiManager = new UiManager(myProject);
// }
//
// @Override
// protected void deactivate() {
// if (myVfsListener != null) {
// Disposer.dispose(myVfsListener);
// myVfsListener = null;
// uiManager.stop();
// }
// }
//
// public UiManager getUiManager() {
// return uiManager;
// }
//
// @Nullable
// @Override
// public ChangeProvider getChangeProvider() {
// if (myChangeProvider == null) {
// myChangeProvider = new FossilChangeProvider(myProject);
// }
// return myChangeProvider;
// }
//
// @Nullable
// @Override
// protected CheckinEnvironment createCheckinEnvironment() {
// if (fossilCheckinEnvironment == null) {
// fossilCheckinEnvironment = new FossilCheckinEnvironment(this);
// }
// return fossilCheckinEnvironment;
// }
//
// @Nullable
// @Override
// protected RollbackEnvironment createRollbackEnvironment() {
// return new FossilRollbackEnvironment(this);
// }
//
// @Nullable
// @Override
// public VcsHistoryProvider getVcsHistoryProvider() {
// return new FossilHistoryProvider(this);
// }
//
// @Nullable
// @Override
// protected UpdateEnvironment createUpdateEnvironment() {
// return new FossilUpdateEnvironment(this);
// }
//
// @Override
// public List<CommitExecutor> getCommitExecutors() {
// return Collections.<CommitExecutor>singletonList(new FossilCommitAndPushExecutor(myProject));
// }
//
// public void checkVersion() {
// //todo
// }
//
// @Nullable
// @Override
// public DiffProvider getDiffProvider() {
// return new FossilDiffProvider(this);
// }
//
// public static FossilVcs getInstance(final Project project) {
// return (FossilVcs) ProjectLevelVcsManager.getInstance(project).findVcsByName(NAME);
// }
//
// public static VcsKey getVcsKey() {
// return ourKey;
// }
//
// @Nullable
// @Override
// public AnnotationProvider getAnnotationProvider() {
// return new FossilAnnotationProvider(this);
// }
// }
// Path: src/org/github/irengrig/fossil4idea/actions/FossilGroup.java
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vcs.AbstractVcs;
import com.intellij.openapi.vcs.actions.StandardVcsGroup;
import org.github.irengrig.fossil4idea.FossilVcs;
import org.jetbrains.annotations.Nullable;
package org.github.irengrig.fossil4idea.actions;
public class FossilGroup extends StandardVcsGroup {
@Override
public AbstractVcs getVcs(Project project) { | return FossilVcs.getInstance(project); |
irengrig/fossil4idea | src/org/github/irengrig/fossil4idea/actions/OpenAction.java | // Path: src/org/github/irengrig/fossil4idea/checkout/CheckoutUtil.java
// public class CheckoutUtil {
// private final Project myProject;
//
// public CheckoutUtil(final Project project) {
// myProject = project;
// }
//
// public void cloneRepo(final String url, final String localPath) throws VcsException {
// final File file = new File(localPath);
// final FossilSimpleCommand command = new FossilSimpleCommand(myProject, file.getParentFile(), FCommandName.clone);
// command.addParameters(url, localPath);
// final String result = command.run();
// }
//
// public void checkout(final File repo, final File target, final String hash) throws VcsException {
// final FossilSimpleCommand command = new FossilSimpleCommand(myProject, target, FCommandName.open);
// command.addParameters(repo.getAbsolutePath());
// if (hash != null) {
// command.addParameters(hash);
// }
// command.run();
// }
//
// public void initRepository(final File repo) throws VcsException {
// final File parentFile = repo.getParentFile();
// if (parentFile.exists() && ! parentFile.isDirectory()) {
// throw new VcsException("Can not create Fossil repository, " + parentFile.getPath() + " is not a directory.");
// }
// if (! parentFile.exists() && ! parentFile.mkdirs()) {
// throw new VcsException("Can not create Fossil repository, can not create parent directory: " + parentFile.getPath());
// }
// final FossilSimpleCommand command = new FossilSimpleCommand(myProject, parentFile, FCommandName.init);
// command.addParameters(repo.getName());
// command.run();
// }
// }
| import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.fileChooser.FileChooserDescriptor;
import com.intellij.openapi.progress.PerformInBackgroundOption;
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.progress.ProgressManager;
import com.intellij.openapi.progress.Task;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.DialogBuilder;
import com.intellij.openapi.ui.MessageType;
import com.intellij.openapi.ui.TextFieldWithBrowseButton;
import com.intellij.openapi.vcs.VcsException;
import com.intellij.openapi.vcs.ui.VcsBalloonProblemNotifier;
import com.intellij.util.Consumer;
import org.github.irengrig.fossil4idea.checkout.CheckoutUtil;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import java.awt.*;
import java.io.File; | package org.github.irengrig.fossil4idea.actions;
public class OpenAction extends AnAction {
@Override
public void actionPerformed(AnActionEvent anActionEvent) {
final Project project = PlatformDataKeys.PROJECT.getData(anActionEvent.getDataContext());
if (project == null) return;
final CheckoutUIWorker uiWorker = new CheckoutUIWorker();
uiWorker.showDialog(project, new Runnable() {
@Override
public void run() {
ProgressManager.getInstance().run(new Task.Backgroundable(project, "Open Fossil Repository", false, PerformInBackgroundOption.ALWAYS_BACKGROUND) {
@Override
public void run(@NotNull ProgressIndicator progressIndicator) {
try { | // Path: src/org/github/irengrig/fossil4idea/checkout/CheckoutUtil.java
// public class CheckoutUtil {
// private final Project myProject;
//
// public CheckoutUtil(final Project project) {
// myProject = project;
// }
//
// public void cloneRepo(final String url, final String localPath) throws VcsException {
// final File file = new File(localPath);
// final FossilSimpleCommand command = new FossilSimpleCommand(myProject, file.getParentFile(), FCommandName.clone);
// command.addParameters(url, localPath);
// final String result = command.run();
// }
//
// public void checkout(final File repo, final File target, final String hash) throws VcsException {
// final FossilSimpleCommand command = new FossilSimpleCommand(myProject, target, FCommandName.open);
// command.addParameters(repo.getAbsolutePath());
// if (hash != null) {
// command.addParameters(hash);
// }
// command.run();
// }
//
// public void initRepository(final File repo) throws VcsException {
// final File parentFile = repo.getParentFile();
// if (parentFile.exists() && ! parentFile.isDirectory()) {
// throw new VcsException("Can not create Fossil repository, " + parentFile.getPath() + " is not a directory.");
// }
// if (! parentFile.exists() && ! parentFile.mkdirs()) {
// throw new VcsException("Can not create Fossil repository, can not create parent directory: " + parentFile.getPath());
// }
// final FossilSimpleCommand command = new FossilSimpleCommand(myProject, parentFile, FCommandName.init);
// command.addParameters(repo.getName());
// command.run();
// }
// }
// Path: src/org/github/irengrig/fossil4idea/actions/OpenAction.java
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.fileChooser.FileChooserDescriptor;
import com.intellij.openapi.progress.PerformInBackgroundOption;
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.progress.ProgressManager;
import com.intellij.openapi.progress.Task;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.DialogBuilder;
import com.intellij.openapi.ui.MessageType;
import com.intellij.openapi.ui.TextFieldWithBrowseButton;
import com.intellij.openapi.vcs.VcsException;
import com.intellij.openapi.vcs.ui.VcsBalloonProblemNotifier;
import com.intellij.util.Consumer;
import org.github.irengrig.fossil4idea.checkout.CheckoutUtil;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import java.awt.*;
import java.io.File;
package org.github.irengrig.fossil4idea.actions;
public class OpenAction extends AnAction {
@Override
public void actionPerformed(AnActionEvent anActionEvent) {
final Project project = PlatformDataKeys.PROJECT.getData(anActionEvent.getDataContext());
if (project == null) return;
final CheckoutUIWorker uiWorker = new CheckoutUIWorker();
uiWorker.showDialog(project, new Runnable() {
@Override
public void run() {
ProgressManager.getInstance().run(new Task.Backgroundable(project, "Open Fossil Repository", false, PerformInBackgroundOption.ALWAYS_BACKGROUND) {
@Override
public void run(@NotNull ProgressIndicator progressIndicator) {
try { | new CheckoutUtil(project).checkout(new File(uiWorker.getRepo()), new File(uiWorker.getLocalPath()), null); |
irengrig/fossil4idea | src/org/github/irengrig/fossil4idea/log/FossilFileRevision.java | // Path: src/org/github/irengrig/fossil4idea/repository/FossilContentRevision.java
// public class FossilContentRevision implements ContentRevision {
// private final Project myProject;
// private final FilePath myFilePath;
// private final FossilRevisionNumber myNumber;
//
// public FossilContentRevision(final Project project, final FilePath filePath, final FossilRevisionNumber number) {
// myProject = project;
// myFilePath = filePath;
// myNumber = number;
// }
//
// @Nullable
// @Override
// public String getContent() throws VcsException {
// try {
// return ContentRevisionCache.getOrLoadAsString(myProject, myFilePath, myNumber, FossilVcs.getVcsKey(),
// ContentRevisionCache.UniqueType.REPOSITORY_CONTENT, new Throwable2Computable<byte[], VcsException, IOException>() {
// @Override
// public byte[] compute() throws VcsException, IOException {
// return new CatWorker(myProject).cat(myFilePath.getIOFile(), myNumber.getHash()).getBytes();
// }
// });
// } catch (IOException e) {
// throw new FossilException(e);
// }
// }
//
// @NotNull
// @Override
// public FilePath getFile() {
// return myFilePath;
// }
//
// @NotNull
// @Override
// public FossilRevisionNumber getRevisionNumber() {
// return myNumber;
// }
//
// public Project getProject() {
// return myProject;
// }
// }
//
// Path: src/org/github/irengrig/fossil4idea/repository/FossilRevisionNumber.java
// public class FossilRevisionNumber implements VcsRevisionNumber {
// public final static FossilRevisionNumber UNKNOWN = new FossilRevisionNumber("0", null);
//
// // todo special HEAD revision??
// @NotNull
// private final String myHash;
// private final Date myDate;
//
// public FossilRevisionNumber(final String hash, @Nullable final Date date) {
// myHash = hash;
// myDate = date;
// }
//
// @Override
// public String asString() {
// return myHash;
// }
//
// @Override
// public int compareTo(final VcsRevisionNumber o) {
// if (o instanceof FossilRevisionNumber) {
// if (myDate != null && ((FossilRevisionNumber) o).myDate != null) {
// return myDate.compareTo(((FossilRevisionNumber) o).myDate);
// }
// }
// return 0;
// }
//
// @NotNull
// public String getHash() {
// return myHash;
// }
//
// public Date getDate() {
// return myDate;
// }
//
// @Override
// public boolean equals(final Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// final FossilRevisionNumber that = (FossilRevisionNumber) o;
//
// if (!myHash.equals(that.myHash)) return false;
//
// return true;
// }
//
// @Override
// public int hashCode() {
// return myHash.hashCode();
// }
// }
| import com.intellij.openapi.project.Project;
import com.intellij.openapi.vcs.FilePath;
import com.intellij.openapi.vcs.RepositoryLocation;
import com.intellij.openapi.vcs.VcsException;
import com.intellij.openapi.vcs.history.VcsFileRevision;
import com.intellij.openapi.vcs.history.VcsRevisionNumber;
import org.github.irengrig.fossil4idea.repository.FossilContentRevision;
import org.jetbrains.annotations.Nullable;
import org.github.irengrig.fossil4idea.repository.FossilRevisionNumber;
import java.io.IOException;
import java.util.Date; | package org.github.irengrig.fossil4idea.log;
/**
* Created with IntelliJ IDEA.
* User: Irina.Chernushina
* Date: 2/24/13
* Time: 8:13 PM
*/
public class FossilFileRevision implements VcsFileRevision {
private final String myAuthor;
private final String myComment; | // Path: src/org/github/irengrig/fossil4idea/repository/FossilContentRevision.java
// public class FossilContentRevision implements ContentRevision {
// private final Project myProject;
// private final FilePath myFilePath;
// private final FossilRevisionNumber myNumber;
//
// public FossilContentRevision(final Project project, final FilePath filePath, final FossilRevisionNumber number) {
// myProject = project;
// myFilePath = filePath;
// myNumber = number;
// }
//
// @Nullable
// @Override
// public String getContent() throws VcsException {
// try {
// return ContentRevisionCache.getOrLoadAsString(myProject, myFilePath, myNumber, FossilVcs.getVcsKey(),
// ContentRevisionCache.UniqueType.REPOSITORY_CONTENT, new Throwable2Computable<byte[], VcsException, IOException>() {
// @Override
// public byte[] compute() throws VcsException, IOException {
// return new CatWorker(myProject).cat(myFilePath.getIOFile(), myNumber.getHash()).getBytes();
// }
// });
// } catch (IOException e) {
// throw new FossilException(e);
// }
// }
//
// @NotNull
// @Override
// public FilePath getFile() {
// return myFilePath;
// }
//
// @NotNull
// @Override
// public FossilRevisionNumber getRevisionNumber() {
// return myNumber;
// }
//
// public Project getProject() {
// return myProject;
// }
// }
//
// Path: src/org/github/irengrig/fossil4idea/repository/FossilRevisionNumber.java
// public class FossilRevisionNumber implements VcsRevisionNumber {
// public final static FossilRevisionNumber UNKNOWN = new FossilRevisionNumber("0", null);
//
// // todo special HEAD revision??
// @NotNull
// private final String myHash;
// private final Date myDate;
//
// public FossilRevisionNumber(final String hash, @Nullable final Date date) {
// myHash = hash;
// myDate = date;
// }
//
// @Override
// public String asString() {
// return myHash;
// }
//
// @Override
// public int compareTo(final VcsRevisionNumber o) {
// if (o instanceof FossilRevisionNumber) {
// if (myDate != null && ((FossilRevisionNumber) o).myDate != null) {
// return myDate.compareTo(((FossilRevisionNumber) o).myDate);
// }
// }
// return 0;
// }
//
// @NotNull
// public String getHash() {
// return myHash;
// }
//
// public Date getDate() {
// return myDate;
// }
//
// @Override
// public boolean equals(final Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// final FossilRevisionNumber that = (FossilRevisionNumber) o;
//
// if (!myHash.equals(that.myHash)) return false;
//
// return true;
// }
//
// @Override
// public int hashCode() {
// return myHash.hashCode();
// }
// }
// Path: src/org/github/irengrig/fossil4idea/log/FossilFileRevision.java
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vcs.FilePath;
import com.intellij.openapi.vcs.RepositoryLocation;
import com.intellij.openapi.vcs.VcsException;
import com.intellij.openapi.vcs.history.VcsFileRevision;
import com.intellij.openapi.vcs.history.VcsRevisionNumber;
import org.github.irengrig.fossil4idea.repository.FossilContentRevision;
import org.jetbrains.annotations.Nullable;
import org.github.irengrig.fossil4idea.repository.FossilRevisionNumber;
import java.io.IOException;
import java.util.Date;
package org.github.irengrig.fossil4idea.log;
/**
* Created with IntelliJ IDEA.
* User: Irina.Chernushina
* Date: 2/24/13
* Time: 8:13 PM
*/
public class FossilFileRevision implements VcsFileRevision {
private final String myAuthor;
private final String myComment; | private final FossilContentRevision myContentRevision; |
irengrig/fossil4idea | src/org/github/irengrig/fossil4idea/log/FossilFileRevision.java | // Path: src/org/github/irengrig/fossil4idea/repository/FossilContentRevision.java
// public class FossilContentRevision implements ContentRevision {
// private final Project myProject;
// private final FilePath myFilePath;
// private final FossilRevisionNumber myNumber;
//
// public FossilContentRevision(final Project project, final FilePath filePath, final FossilRevisionNumber number) {
// myProject = project;
// myFilePath = filePath;
// myNumber = number;
// }
//
// @Nullable
// @Override
// public String getContent() throws VcsException {
// try {
// return ContentRevisionCache.getOrLoadAsString(myProject, myFilePath, myNumber, FossilVcs.getVcsKey(),
// ContentRevisionCache.UniqueType.REPOSITORY_CONTENT, new Throwable2Computable<byte[], VcsException, IOException>() {
// @Override
// public byte[] compute() throws VcsException, IOException {
// return new CatWorker(myProject).cat(myFilePath.getIOFile(), myNumber.getHash()).getBytes();
// }
// });
// } catch (IOException e) {
// throw new FossilException(e);
// }
// }
//
// @NotNull
// @Override
// public FilePath getFile() {
// return myFilePath;
// }
//
// @NotNull
// @Override
// public FossilRevisionNumber getRevisionNumber() {
// return myNumber;
// }
//
// public Project getProject() {
// return myProject;
// }
// }
//
// Path: src/org/github/irengrig/fossil4idea/repository/FossilRevisionNumber.java
// public class FossilRevisionNumber implements VcsRevisionNumber {
// public final static FossilRevisionNumber UNKNOWN = new FossilRevisionNumber("0", null);
//
// // todo special HEAD revision??
// @NotNull
// private final String myHash;
// private final Date myDate;
//
// public FossilRevisionNumber(final String hash, @Nullable final Date date) {
// myHash = hash;
// myDate = date;
// }
//
// @Override
// public String asString() {
// return myHash;
// }
//
// @Override
// public int compareTo(final VcsRevisionNumber o) {
// if (o instanceof FossilRevisionNumber) {
// if (myDate != null && ((FossilRevisionNumber) o).myDate != null) {
// return myDate.compareTo(((FossilRevisionNumber) o).myDate);
// }
// }
// return 0;
// }
//
// @NotNull
// public String getHash() {
// return myHash;
// }
//
// public Date getDate() {
// return myDate;
// }
//
// @Override
// public boolean equals(final Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// final FossilRevisionNumber that = (FossilRevisionNumber) o;
//
// if (!myHash.equals(that.myHash)) return false;
//
// return true;
// }
//
// @Override
// public int hashCode() {
// return myHash.hashCode();
// }
// }
| import com.intellij.openapi.project.Project;
import com.intellij.openapi.vcs.FilePath;
import com.intellij.openapi.vcs.RepositoryLocation;
import com.intellij.openapi.vcs.VcsException;
import com.intellij.openapi.vcs.history.VcsFileRevision;
import com.intellij.openapi.vcs.history.VcsRevisionNumber;
import org.github.irengrig.fossil4idea.repository.FossilContentRevision;
import org.jetbrains.annotations.Nullable;
import org.github.irengrig.fossil4idea.repository.FossilRevisionNumber;
import java.io.IOException;
import java.util.Date; | package org.github.irengrig.fossil4idea.log;
/**
* Created with IntelliJ IDEA.
* User: Irina.Chernushina
* Date: 2/24/13
* Time: 8:13 PM
*/
public class FossilFileRevision implements VcsFileRevision {
private final String myAuthor;
private final String myComment;
private final FossilContentRevision myContentRevision;
| // Path: src/org/github/irengrig/fossil4idea/repository/FossilContentRevision.java
// public class FossilContentRevision implements ContentRevision {
// private final Project myProject;
// private final FilePath myFilePath;
// private final FossilRevisionNumber myNumber;
//
// public FossilContentRevision(final Project project, final FilePath filePath, final FossilRevisionNumber number) {
// myProject = project;
// myFilePath = filePath;
// myNumber = number;
// }
//
// @Nullable
// @Override
// public String getContent() throws VcsException {
// try {
// return ContentRevisionCache.getOrLoadAsString(myProject, myFilePath, myNumber, FossilVcs.getVcsKey(),
// ContentRevisionCache.UniqueType.REPOSITORY_CONTENT, new Throwable2Computable<byte[], VcsException, IOException>() {
// @Override
// public byte[] compute() throws VcsException, IOException {
// return new CatWorker(myProject).cat(myFilePath.getIOFile(), myNumber.getHash()).getBytes();
// }
// });
// } catch (IOException e) {
// throw new FossilException(e);
// }
// }
//
// @NotNull
// @Override
// public FilePath getFile() {
// return myFilePath;
// }
//
// @NotNull
// @Override
// public FossilRevisionNumber getRevisionNumber() {
// return myNumber;
// }
//
// public Project getProject() {
// return myProject;
// }
// }
//
// Path: src/org/github/irengrig/fossil4idea/repository/FossilRevisionNumber.java
// public class FossilRevisionNumber implements VcsRevisionNumber {
// public final static FossilRevisionNumber UNKNOWN = new FossilRevisionNumber("0", null);
//
// // todo special HEAD revision??
// @NotNull
// private final String myHash;
// private final Date myDate;
//
// public FossilRevisionNumber(final String hash, @Nullable final Date date) {
// myHash = hash;
// myDate = date;
// }
//
// @Override
// public String asString() {
// return myHash;
// }
//
// @Override
// public int compareTo(final VcsRevisionNumber o) {
// if (o instanceof FossilRevisionNumber) {
// if (myDate != null && ((FossilRevisionNumber) o).myDate != null) {
// return myDate.compareTo(((FossilRevisionNumber) o).myDate);
// }
// }
// return 0;
// }
//
// @NotNull
// public String getHash() {
// return myHash;
// }
//
// public Date getDate() {
// return myDate;
// }
//
// @Override
// public boolean equals(final Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// final FossilRevisionNumber that = (FossilRevisionNumber) o;
//
// if (!myHash.equals(that.myHash)) return false;
//
// return true;
// }
//
// @Override
// public int hashCode() {
// return myHash.hashCode();
// }
// }
// Path: src/org/github/irengrig/fossil4idea/log/FossilFileRevision.java
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vcs.FilePath;
import com.intellij.openapi.vcs.RepositoryLocation;
import com.intellij.openapi.vcs.VcsException;
import com.intellij.openapi.vcs.history.VcsFileRevision;
import com.intellij.openapi.vcs.history.VcsRevisionNumber;
import org.github.irengrig.fossil4idea.repository.FossilContentRevision;
import org.jetbrains.annotations.Nullable;
import org.github.irengrig.fossil4idea.repository.FossilRevisionNumber;
import java.io.IOException;
import java.util.Date;
package org.github.irengrig.fossil4idea.log;
/**
* Created with IntelliJ IDEA.
* User: Irina.Chernushina
* Date: 2/24/13
* Time: 8:13 PM
*/
public class FossilFileRevision implements VcsFileRevision {
private final String myAuthor;
private final String myComment;
private final FossilContentRevision myContentRevision;
| public FossilFileRevision(final Project project, final FilePath filePath, final FossilRevisionNumber revisionNumber, |
irengrig/fossil4idea | src/org/github/irengrig/fossil4idea/commandLine/FossilSimpleCommand.java | // Path: src/org/github/irengrig/fossil4idea/FossilException.java
// public class FossilException extends VcsException {
// public FossilException(final String message) {
// super(message);
// }
//
// public FossilException(final Throwable throwable, final boolean isWarning) {
// super(throwable, isWarning);
// }
//
// public FossilException(final Throwable throwable) {
// super(throwable);
// }
//
// public FossilException(final String message, final Throwable cause) {
// super(message, cause);
// }
//
// public FossilException(final String message, final boolean isWarning) {
// super(message, isWarning);
// }
//
// public FossilException(final Collection<String> messages) {
// super(messages);
// }
// }
//
// Path: src/org/github/irengrig/fossil4idea/FossilVcs.java
// public class FossilVcs extends AbstractVcs {
// public static String NAME = "fossil";
// public static String DISPLAY_NAME = "Fossil";
// private FossilChangeProvider myChangeProvider;
// private static final VcsKey ourKey = createKey(NAME);
// private FossilVfsListener myVfsListener;
// private UiManager uiManager;
// private FossilCheckinEnvironment fossilCheckinEnvironment;
//
// public FossilVcs(Project project) {
// super(project, NAME);
// }
//
// @Override
// public String getDisplayName() {
// return DISPLAY_NAME;
// }
//
// @Override
// public Configurable getConfigurable() {
// return new FossilConfigurable(myProject);
// }
//
// @Override
// protected void activate() {
// myVfsListener = new FossilVfsListener(myProject);
// uiManager = new UiManager(myProject);
// }
//
// @Override
// protected void deactivate() {
// if (myVfsListener != null) {
// Disposer.dispose(myVfsListener);
// myVfsListener = null;
// uiManager.stop();
// }
// }
//
// public UiManager getUiManager() {
// return uiManager;
// }
//
// @Nullable
// @Override
// public ChangeProvider getChangeProvider() {
// if (myChangeProvider == null) {
// myChangeProvider = new FossilChangeProvider(myProject);
// }
// return myChangeProvider;
// }
//
// @Nullable
// @Override
// protected CheckinEnvironment createCheckinEnvironment() {
// if (fossilCheckinEnvironment == null) {
// fossilCheckinEnvironment = new FossilCheckinEnvironment(this);
// }
// return fossilCheckinEnvironment;
// }
//
// @Nullable
// @Override
// protected RollbackEnvironment createRollbackEnvironment() {
// return new FossilRollbackEnvironment(this);
// }
//
// @Nullable
// @Override
// public VcsHistoryProvider getVcsHistoryProvider() {
// return new FossilHistoryProvider(this);
// }
//
// @Nullable
// @Override
// protected UpdateEnvironment createUpdateEnvironment() {
// return new FossilUpdateEnvironment(this);
// }
//
// @Override
// public List<CommitExecutor> getCommitExecutors() {
// return Collections.<CommitExecutor>singletonList(new FossilCommitAndPushExecutor(myProject));
// }
//
// public void checkVersion() {
// //todo
// }
//
// @Nullable
// @Override
// public DiffProvider getDiffProvider() {
// return new FossilDiffProvider(this);
// }
//
// public static FossilVcs getInstance(final Project project) {
// return (FossilVcs) ProjectLevelVcsManager.getInstance(project).findVcsByName(NAME);
// }
//
// public static VcsKey getVcsKey() {
// return ourKey;
// }
//
// @Nullable
// @Override
// public AnnotationProvider getAnnotationProvider() {
// return new FossilAnnotationProvider(this);
// }
// }
| import com.intellij.execution.process.ProcessOutputTypes;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Key;
import com.intellij.openapi.vcs.ProcessEventListener;
import com.intellij.openapi.vcs.VcsException;
import org.github.irengrig.fossil4idea.FossilException;
import org.jetbrains.annotations.NotNull;
import org.github.irengrig.fossil4idea.FossilVcs;
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.util.HashSet;
import java.util.Set; | msg = "Fossil process exited with error code: " + exitCode;
}
LOG.info(myCommandLine.getCommandLineString() + " >>\n" + msg);
System.out.println(myCommandLine.getCommandLineString() + " >>\n" + msg);
ex[0] = new VcsException(msg);
}
}
catch (Throwable t) {
ex[0] = new VcsException(t.toString(), t);
}
}
private boolean skipError(String s) {
if (s == null || s.isEmpty()) return false;
for (String error : mySkipErrors) {
if (s.contains(error) || s.toLowerCase().contains(error.toLowerCase())) return true;
}
return false;
}
@Override
public void startFailed(Throwable exception) {
ex[0] = new VcsException("Process failed to start (" + myCommandLine.getCommandLineString() + "): " + exception.toString(), exception);
}
});
start();
if (myProcess != null) {
waitFor();
}
if (ex[0] != null) { | // Path: src/org/github/irengrig/fossil4idea/FossilException.java
// public class FossilException extends VcsException {
// public FossilException(final String message) {
// super(message);
// }
//
// public FossilException(final Throwable throwable, final boolean isWarning) {
// super(throwable, isWarning);
// }
//
// public FossilException(final Throwable throwable) {
// super(throwable);
// }
//
// public FossilException(final String message, final Throwable cause) {
// super(message, cause);
// }
//
// public FossilException(final String message, final boolean isWarning) {
// super(message, isWarning);
// }
//
// public FossilException(final Collection<String> messages) {
// super(messages);
// }
// }
//
// Path: src/org/github/irengrig/fossil4idea/FossilVcs.java
// public class FossilVcs extends AbstractVcs {
// public static String NAME = "fossil";
// public static String DISPLAY_NAME = "Fossil";
// private FossilChangeProvider myChangeProvider;
// private static final VcsKey ourKey = createKey(NAME);
// private FossilVfsListener myVfsListener;
// private UiManager uiManager;
// private FossilCheckinEnvironment fossilCheckinEnvironment;
//
// public FossilVcs(Project project) {
// super(project, NAME);
// }
//
// @Override
// public String getDisplayName() {
// return DISPLAY_NAME;
// }
//
// @Override
// public Configurable getConfigurable() {
// return new FossilConfigurable(myProject);
// }
//
// @Override
// protected void activate() {
// myVfsListener = new FossilVfsListener(myProject);
// uiManager = new UiManager(myProject);
// }
//
// @Override
// protected void deactivate() {
// if (myVfsListener != null) {
// Disposer.dispose(myVfsListener);
// myVfsListener = null;
// uiManager.stop();
// }
// }
//
// public UiManager getUiManager() {
// return uiManager;
// }
//
// @Nullable
// @Override
// public ChangeProvider getChangeProvider() {
// if (myChangeProvider == null) {
// myChangeProvider = new FossilChangeProvider(myProject);
// }
// return myChangeProvider;
// }
//
// @Nullable
// @Override
// protected CheckinEnvironment createCheckinEnvironment() {
// if (fossilCheckinEnvironment == null) {
// fossilCheckinEnvironment = new FossilCheckinEnvironment(this);
// }
// return fossilCheckinEnvironment;
// }
//
// @Nullable
// @Override
// protected RollbackEnvironment createRollbackEnvironment() {
// return new FossilRollbackEnvironment(this);
// }
//
// @Nullable
// @Override
// public VcsHistoryProvider getVcsHistoryProvider() {
// return new FossilHistoryProvider(this);
// }
//
// @Nullable
// @Override
// protected UpdateEnvironment createUpdateEnvironment() {
// return new FossilUpdateEnvironment(this);
// }
//
// @Override
// public List<CommitExecutor> getCommitExecutors() {
// return Collections.<CommitExecutor>singletonList(new FossilCommitAndPushExecutor(myProject));
// }
//
// public void checkVersion() {
// //todo
// }
//
// @Nullable
// @Override
// public DiffProvider getDiffProvider() {
// return new FossilDiffProvider(this);
// }
//
// public static FossilVcs getInstance(final Project project) {
// return (FossilVcs) ProjectLevelVcsManager.getInstance(project).findVcsByName(NAME);
// }
//
// public static VcsKey getVcsKey() {
// return ourKey;
// }
//
// @Nullable
// @Override
// public AnnotationProvider getAnnotationProvider() {
// return new FossilAnnotationProvider(this);
// }
// }
// Path: src/org/github/irengrig/fossil4idea/commandLine/FossilSimpleCommand.java
import com.intellij.execution.process.ProcessOutputTypes;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Key;
import com.intellij.openapi.vcs.ProcessEventListener;
import com.intellij.openapi.vcs.VcsException;
import org.github.irengrig.fossil4idea.FossilException;
import org.jetbrains.annotations.NotNull;
import org.github.irengrig.fossil4idea.FossilVcs;
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.util.HashSet;
import java.util.Set;
msg = "Fossil process exited with error code: " + exitCode;
}
LOG.info(myCommandLine.getCommandLineString() + " >>\n" + msg);
System.out.println(myCommandLine.getCommandLineString() + " >>\n" + msg);
ex[0] = new VcsException(msg);
}
}
catch (Throwable t) {
ex[0] = new VcsException(t.toString(), t);
}
}
private boolean skipError(String s) {
if (s == null || s.isEmpty()) return false;
for (String error : mySkipErrors) {
if (s.contains(error) || s.toLowerCase().contains(error.toLowerCase())) return true;
}
return false;
}
@Override
public void startFailed(Throwable exception) {
ex[0] = new VcsException("Process failed to start (" + myCommandLine.getCommandLineString() + "): " + exception.toString(), exception);
}
});
start();
if (myProcess != null) {
waitFor();
}
if (ex[0] != null) { | FossilVcs.getInstance(myProject).checkVersion(); |
irengrig/fossil4idea | src/org/github/irengrig/fossil4idea/log/FossilFileAnnotation.java | // Path: src/org/github/irengrig/fossil4idea/repository/FossilRevisionNumber.java
// public class FossilRevisionNumber implements VcsRevisionNumber {
// public final static FossilRevisionNumber UNKNOWN = new FossilRevisionNumber("0", null);
//
// // todo special HEAD revision??
// @NotNull
// private final String myHash;
// private final Date myDate;
//
// public FossilRevisionNumber(final String hash, @Nullable final Date date) {
// myHash = hash;
// myDate = date;
// }
//
// @Override
// public String asString() {
// return myHash;
// }
//
// @Override
// public int compareTo(final VcsRevisionNumber o) {
// if (o instanceof FossilRevisionNumber) {
// if (myDate != null && ((FossilRevisionNumber) o).myDate != null) {
// return myDate.compareTo(((FossilRevisionNumber) o).myDate);
// }
// }
// return 0;
// }
//
// @NotNull
// public String getHash() {
// return myHash;
// }
//
// public Date getDate() {
// return myDate;
// }
//
// @Override
// public boolean equals(final Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// final FossilRevisionNumber that = (FossilRevisionNumber) o;
//
// if (!myHash.equals(that.myHash)) return false;
//
// return true;
// }
//
// @Override
// public int hashCode() {
// return myHash.hashCode();
// }
// }
| import com.intellij.openapi.project.Project;
import com.intellij.openapi.vcs.FilePath;
import com.intellij.openapi.vcs.FilePathImpl;
import com.intellij.openapi.vcs.annotate.AnnotationSourceSwitcher;
import com.intellij.openapi.vcs.annotate.FileAnnotation;
import com.intellij.openapi.vcs.annotate.LineAnnotationAspect;
import com.intellij.openapi.vcs.annotate.LineAnnotationAspectAdapter;
import com.intellij.openapi.vcs.history.VcsFileRevision;
import com.intellij.openapi.vcs.history.VcsRevisionNumber;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.text.DateFormatUtil;
import org.jetbrains.annotations.Nullable;
import org.github.irengrig.fossil4idea.repository.FossilRevisionNumber;
import java.util.*; | package org.github.irengrig.fossil4idea.log;
/**
* Created with IntelliJ IDEA.
* User: Irina.Chernushina
* Date: 2/24/13
* Time: 9:14 PM
*/
public class FossilFileAnnotation extends FileAnnotation {
final Map<Integer, ArtifactInfo> myMap;
private int myMaxIdx;
private final Project myProject;
private final String myContent; | // Path: src/org/github/irengrig/fossil4idea/repository/FossilRevisionNumber.java
// public class FossilRevisionNumber implements VcsRevisionNumber {
// public final static FossilRevisionNumber UNKNOWN = new FossilRevisionNumber("0", null);
//
// // todo special HEAD revision??
// @NotNull
// private final String myHash;
// private final Date myDate;
//
// public FossilRevisionNumber(final String hash, @Nullable final Date date) {
// myHash = hash;
// myDate = date;
// }
//
// @Override
// public String asString() {
// return myHash;
// }
//
// @Override
// public int compareTo(final VcsRevisionNumber o) {
// if (o instanceof FossilRevisionNumber) {
// if (myDate != null && ((FossilRevisionNumber) o).myDate != null) {
// return myDate.compareTo(((FossilRevisionNumber) o).myDate);
// }
// }
// return 0;
// }
//
// @NotNull
// public String getHash() {
// return myHash;
// }
//
// public Date getDate() {
// return myDate;
// }
//
// @Override
// public boolean equals(final Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// final FossilRevisionNumber that = (FossilRevisionNumber) o;
//
// if (!myHash.equals(that.myHash)) return false;
//
// return true;
// }
//
// @Override
// public int hashCode() {
// return myHash.hashCode();
// }
// }
// Path: src/org/github/irengrig/fossil4idea/log/FossilFileAnnotation.java
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vcs.FilePath;
import com.intellij.openapi.vcs.FilePathImpl;
import com.intellij.openapi.vcs.annotate.AnnotationSourceSwitcher;
import com.intellij.openapi.vcs.annotate.FileAnnotation;
import com.intellij.openapi.vcs.annotate.LineAnnotationAspect;
import com.intellij.openapi.vcs.annotate.LineAnnotationAspectAdapter;
import com.intellij.openapi.vcs.history.VcsFileRevision;
import com.intellij.openapi.vcs.history.VcsRevisionNumber;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.text.DateFormatUtil;
import org.jetbrains.annotations.Nullable;
import org.github.irengrig.fossil4idea.repository.FossilRevisionNumber;
import java.util.*;
package org.github.irengrig.fossil4idea.log;
/**
* Created with IntelliJ IDEA.
* User: Irina.Chernushina
* Date: 2/24/13
* Time: 9:14 PM
*/
public class FossilFileAnnotation extends FileAnnotation {
final Map<Integer, ArtifactInfo> myMap;
private int myMaxIdx;
private final Project myProject;
private final String myContent; | private final FossilRevisionNumber myNumber; |
irengrig/fossil4idea | src/org/github/irengrig/fossil4idea/FossilCommitAndPushExecutor.java | // Path: src/org/github/irengrig/fossil4idea/checkin/FossilCheckinEnvironment.java
// public class FossilCheckinEnvironment implements CheckinEnvironment {
// private final FossilVcs myFossilVcs;
// // don't like it, but because of platform design
// private boolean myPush;
//
// public FossilCheckinEnvironment(final FossilVcs fossilVcs) {
// myFossilVcs = fossilVcs;
// }
//
// @Nullable
// @Override
// public RefreshableOnComponent createAdditionalOptionsPanel(final CheckinProjectPanel panel, final PairConsumer<Object, Object> additionalDataConsumer) {
// return null;
// }
//
// @Nullable
// @Override
// public String getDefaultMessageFor(final FilePath[] filesToCheckin) {
// return null;
// }
//
// @Nullable
// @Override
// public String getHelpId() {
// return null;
// }
//
// @Override
// public String getCheckinOperationName() {
// return "Commit";
// }
//
// @Nullable
// @Override
// public List<VcsException> commit(final List<Change> changes, final String preparedComment) {
// return commit(changes, preparedComment, FunctionUtil.<Object, Object>nullConstant(), null);
// }
//
// @Nullable
// @Override
// public List<VcsException> commit(final List<Change> changes, final String preparedComment,
// @NotNull final NullableFunction<Object, Object> parametersHolder, final Set<String> feedback) {
// final boolean wasToPush = myPush;
// myPush = false;
// final CheckinUtil checkinUtil = new CheckinUtil(myFossilVcs.getProject());
// final List<File> files = ChangesUtil.getIoFilesFromChanges(changes);
// final List<VcsException> exceptions = new ArrayList<VcsException>();
// try {
// final List<String> hashes = checkinUtil.checkin(files, preparedComment);
// if (hashes != null && ! hashes.isEmpty()) {
// if (feedback == null) {
// // popup
// PopupUtil.showBalloonForActiveComponent(createMessage(hashes), MessageType.INFO);
// } else {
// feedback.add(createMessage(hashes));
// }
// // something committed & need to push
// if (wasToPush) {
// checkinUtil.push();
// }
// }
// } catch (VcsException e) {
// exceptions.add(e);
// }
// return exceptions;
// }
//
// private String createMessage(final List<String> hashes) {
// return "Fossil: committed: " + StringUtil.join(hashes, ",");
// }
//
// @Nullable
// @Override
// public List<VcsException> scheduleMissingFileForDeletion(final List<FilePath> files) {
// final List<VcsException> result = new ArrayList<VcsException>();
// try {
// AddUtil.deleteImpl(myFossilVcs.getProject(), ObjectsConvertor.convert(files, FossilUtils.FILE_PATH_FILE_CONVERTOR));
// } catch (VcsException e) {
// result.add(e);
// }
// return result;
// }
//
// @Nullable
// @Override
// public List<VcsException> scheduleUnversionedFilesForAddition(final List<VirtualFile> files) {
// final List<VcsException> result = new ArrayList<VcsException>();
// try {
// AddUtil.scheduleForAddition(myFossilVcs.getProject(), ObjectsConvertor.convert(files,
// new Convertor<VirtualFile, File>() {
// @Override
// public File convert(final VirtualFile o) {
// return new File(o.getPath());
// }
// }));
// } catch (VcsException e) {
// result.add(e);
// }
// return result;
// }
//
// @Override
// public boolean keepChangeListAfterCommit(final ChangeList changeList) {
// return false;
// }
//
// @Override
// public boolean isRefreshAfterCommitNeeded() {
// return false;
// }
//
// public void setPush() {
// myPush = true;
// }
// }
| import com.intellij.openapi.project.Project;
import com.intellij.openapi.vcs.changes.CommitExecutor;
import com.intellij.openapi.vcs.changes.CommitSession;
import org.github.irengrig.fossil4idea.checkin.FossilCheckinEnvironment;
import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.NotNull;
import java.util.List; | package org.github.irengrig.fossil4idea;
/**
* Created by Irina.Chernushina on 6/1/2014.
*/
public class FossilCommitAndPushExecutor implements CommitExecutor {
private final Project project;
public FossilCommitAndPushExecutor(Project project) {
this.project = project;
}
@Nls
@Override
public String getActionText() {
return "Commit and &Push...";
}
@NotNull
@Override
public CommitSession createCommitSession() { | // Path: src/org/github/irengrig/fossil4idea/checkin/FossilCheckinEnvironment.java
// public class FossilCheckinEnvironment implements CheckinEnvironment {
// private final FossilVcs myFossilVcs;
// // don't like it, but because of platform design
// private boolean myPush;
//
// public FossilCheckinEnvironment(final FossilVcs fossilVcs) {
// myFossilVcs = fossilVcs;
// }
//
// @Nullable
// @Override
// public RefreshableOnComponent createAdditionalOptionsPanel(final CheckinProjectPanel panel, final PairConsumer<Object, Object> additionalDataConsumer) {
// return null;
// }
//
// @Nullable
// @Override
// public String getDefaultMessageFor(final FilePath[] filesToCheckin) {
// return null;
// }
//
// @Nullable
// @Override
// public String getHelpId() {
// return null;
// }
//
// @Override
// public String getCheckinOperationName() {
// return "Commit";
// }
//
// @Nullable
// @Override
// public List<VcsException> commit(final List<Change> changes, final String preparedComment) {
// return commit(changes, preparedComment, FunctionUtil.<Object, Object>nullConstant(), null);
// }
//
// @Nullable
// @Override
// public List<VcsException> commit(final List<Change> changes, final String preparedComment,
// @NotNull final NullableFunction<Object, Object> parametersHolder, final Set<String> feedback) {
// final boolean wasToPush = myPush;
// myPush = false;
// final CheckinUtil checkinUtil = new CheckinUtil(myFossilVcs.getProject());
// final List<File> files = ChangesUtil.getIoFilesFromChanges(changes);
// final List<VcsException> exceptions = new ArrayList<VcsException>();
// try {
// final List<String> hashes = checkinUtil.checkin(files, preparedComment);
// if (hashes != null && ! hashes.isEmpty()) {
// if (feedback == null) {
// // popup
// PopupUtil.showBalloonForActiveComponent(createMessage(hashes), MessageType.INFO);
// } else {
// feedback.add(createMessage(hashes));
// }
// // something committed & need to push
// if (wasToPush) {
// checkinUtil.push();
// }
// }
// } catch (VcsException e) {
// exceptions.add(e);
// }
// return exceptions;
// }
//
// private String createMessage(final List<String> hashes) {
// return "Fossil: committed: " + StringUtil.join(hashes, ",");
// }
//
// @Nullable
// @Override
// public List<VcsException> scheduleMissingFileForDeletion(final List<FilePath> files) {
// final List<VcsException> result = new ArrayList<VcsException>();
// try {
// AddUtil.deleteImpl(myFossilVcs.getProject(), ObjectsConvertor.convert(files, FossilUtils.FILE_PATH_FILE_CONVERTOR));
// } catch (VcsException e) {
// result.add(e);
// }
// return result;
// }
//
// @Nullable
// @Override
// public List<VcsException> scheduleUnversionedFilesForAddition(final List<VirtualFile> files) {
// final List<VcsException> result = new ArrayList<VcsException>();
// try {
// AddUtil.scheduleForAddition(myFossilVcs.getProject(), ObjectsConvertor.convert(files,
// new Convertor<VirtualFile, File>() {
// @Override
// public File convert(final VirtualFile o) {
// return new File(o.getPath());
// }
// }));
// } catch (VcsException e) {
// result.add(e);
// }
// return result;
// }
//
// @Override
// public boolean keepChangeListAfterCommit(final ChangeList changeList) {
// return false;
// }
//
// @Override
// public boolean isRefreshAfterCommitNeeded() {
// return false;
// }
//
// public void setPush() {
// myPush = true;
// }
// }
// Path: src/org/github/irengrig/fossil4idea/FossilCommitAndPushExecutor.java
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vcs.changes.CommitExecutor;
import com.intellij.openapi.vcs.changes.CommitSession;
import org.github.irengrig.fossil4idea.checkin.FossilCheckinEnvironment;
import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.NotNull;
import java.util.List;
package org.github.irengrig.fossil4idea;
/**
* Created by Irina.Chernushina on 6/1/2014.
*/
public class FossilCommitAndPushExecutor implements CommitExecutor {
private final Project project;
public FossilCommitAndPushExecutor(Project project) {
this.project = project;
}
@Nls
@Override
public String getActionText() {
return "Commit and &Push...";
}
@NotNull
@Override
public CommitSession createCommitSession() { | ((FossilCheckinEnvironment) FossilVcs.getInstance(project).createCheckinEnvironment()).setPush(); |
irengrig/fossil4idea | src/org/github/irengrig/fossil4idea/local/FossilInfo.java | // Path: src/org/github/irengrig/fossil4idea/repository/FossilRevisionNumber.java
// public class FossilRevisionNumber implements VcsRevisionNumber {
// public final static FossilRevisionNumber UNKNOWN = new FossilRevisionNumber("0", null);
//
// // todo special HEAD revision??
// @NotNull
// private final String myHash;
// private final Date myDate;
//
// public FossilRevisionNumber(final String hash, @Nullable final Date date) {
// myHash = hash;
// myDate = date;
// }
//
// @Override
// public String asString() {
// return myHash;
// }
//
// @Override
// public int compareTo(final VcsRevisionNumber o) {
// if (o instanceof FossilRevisionNumber) {
// if (myDate != null && ((FossilRevisionNumber) o).myDate != null) {
// return myDate.compareTo(((FossilRevisionNumber) o).myDate);
// }
// }
// return 0;
// }
//
// @NotNull
// public String getHash() {
// return myHash;
// }
//
// public Date getDate() {
// return myDate;
// }
//
// @Override
// public boolean equals(final Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// final FossilRevisionNumber that = (FossilRevisionNumber) o;
//
// if (!myHash.equals(that.myHash)) return false;
//
// return true;
// }
//
// @Override
// public int hashCode() {
// return myHash.hashCode();
// }
// }
| import org.github.irengrig.fossil4idea.repository.FossilRevisionNumber;
import java.util.List; | package org.github.irengrig.fossil4idea.local;
/**
* Created with IntelliJ IDEA.
* User: Irina.Chernushina
* Date: 2/24/13
* Time: 12:11 AM
*/
public class FossilInfo {
private String myProjectName;
private String myRepository;
private String myLocalPath;
private String myUserHome;
private String myProjectId; | // Path: src/org/github/irengrig/fossil4idea/repository/FossilRevisionNumber.java
// public class FossilRevisionNumber implements VcsRevisionNumber {
// public final static FossilRevisionNumber UNKNOWN = new FossilRevisionNumber("0", null);
//
// // todo special HEAD revision??
// @NotNull
// private final String myHash;
// private final Date myDate;
//
// public FossilRevisionNumber(final String hash, @Nullable final Date date) {
// myHash = hash;
// myDate = date;
// }
//
// @Override
// public String asString() {
// return myHash;
// }
//
// @Override
// public int compareTo(final VcsRevisionNumber o) {
// if (o instanceof FossilRevisionNumber) {
// if (myDate != null && ((FossilRevisionNumber) o).myDate != null) {
// return myDate.compareTo(((FossilRevisionNumber) o).myDate);
// }
// }
// return 0;
// }
//
// @NotNull
// public String getHash() {
// return myHash;
// }
//
// public Date getDate() {
// return myDate;
// }
//
// @Override
// public boolean equals(final Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// final FossilRevisionNumber that = (FossilRevisionNumber) o;
//
// if (!myHash.equals(that.myHash)) return false;
//
// return true;
// }
//
// @Override
// public int hashCode() {
// return myHash.hashCode();
// }
// }
// Path: src/org/github/irengrig/fossil4idea/local/FossilInfo.java
import org.github.irengrig.fossil4idea.repository.FossilRevisionNumber;
import java.util.List;
package org.github.irengrig.fossil4idea.local;
/**
* Created with IntelliJ IDEA.
* User: Irina.Chernushina
* Date: 2/24/13
* Time: 12:11 AM
*/
public class FossilInfo {
private String myProjectName;
private String myRepository;
private String myLocalPath;
private String myUserHome;
private String myProjectId; | private FossilRevisionNumber myNumber; |
irengrig/fossil4idea | src/org/github/irengrig/fossil4idea/pull/FossilUpdateConfigurable.java | // Path: src/org/github/irengrig/fossil4idea/FossilConfiguration.java
// @State(
// name = "FossilConfiguration",
// storages = {
// @Storage(file = StoragePathMacros.WORKSPACE_FILE)
// }
// )
// public class FossilConfiguration implements PersistentStateComponent<Element> {
// public String FOSSIL_PATH = "";
// private final Map<File, String> myRemoteUrls = new HashMap<File, String>();
//
// @Nullable
// public Element getState() {
// Element element = new Element("state");
// element.setAttribute("FOSSIL_PATH", FOSSIL_PATH);
// return element;
// }
//
// public void loadState(Element element) {
// final Attribute fossilPath = element.getAttribute("FOSSIL_PATH");
// if (fossilPath != null) {
// FOSSIL_PATH = fossilPath.getValue();
// }
// }
//
// public static FossilConfiguration getInstance(final Project project) {
// return ServiceManager.getService(project, FossilConfiguration.class);
// }
//
// public void setRemoteUrls(final Map<File, String> urls) {
// myRemoteUrls.clear();
// myRemoteUrls.putAll(urls);
// }
//
// public Map<File, String> getRemoteUrls() {
// return myRemoteUrls;
// }
// }
//
// Path: src/org/github/irengrig/fossil4idea/util/TextUtil.java
// public class TextUtil {
// private final static int optimal = 100;
// private final int myLimit;
//
// public TextUtil() {
// this(-1);
// }
//
// public TextUtil(int limit) {
// this.myLimit = limit < 0 ? optimal : limit;
// }
//
// public String insertLineCuts(final String s) {
// if (s == null || s.length() <= myLimit) return s;
// final int idx = s.substring(0, myLimit).lastIndexOf(' ');
// if (idx > 0) {
// return s.substring(0, idx) + "\n" + insertLineCuts(s.substring(idx + 1));
// }
// final int idx2 = s.indexOf(' ', myLimit);
// if (idx2 == -1) return s;
// return s.substring(0, idx2) + "\n" + insertLineCuts(s.substring(idx2 + 1));
// }
// }
| import com.google.common.base.Strings;
import com.intellij.openapi.options.Configurable;
import com.intellij.openapi.options.ConfigurationException;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.MultiLineLabelUI;
import com.intellij.openapi.vcs.FilePath;
import com.intellij.ui.SimpleTextAttributes;
import com.intellij.ui.components.JBLabel;
import com.intellij.ui.components.JBPanel;
import com.intellij.ui.components.JBTextField;
import com.intellij.util.ui.UIUtil;
import org.github.irengrig.fossil4idea.FossilConfiguration;
import org.github.irengrig.fossil4idea.util.TextUtil;
import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.awt.*;
import java.io.File;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.StringTokenizer; | comp.setFont(comp.getFont().deriveFont(Font.BOLD));
panel.add(comp, c);
c.gridwidth = 1;
for (FilePath root : myRoots) {
c.weighty = 0;
c.gridx = 0;
++ c.gridy;
c.fill = GridBagConstraints.NONE;
panel.add(new JBLabel(root.getName() + " (" + root.getParentPath() + ")"), c);
++ c.gridx;
c.fill = GridBagConstraints.HORIZONTAL;
c.weighty = 1;
final JBTextField field = new JBTextField();
panel.add(field, c);
myFields.put(root.getIOFile(), field);
final String preset = myCheckoutURLs.get(root.getIOFile());
if (preset != null) {
field.setText(preset);
}
}
addWarning(panel, c);
}
private void addWarning(JBPanel panel, GridBagConstraints c) {
if (myWarning != null && myWarning.length() > 0) {
++ c.gridy;
c.gridx = 0;
c.gridwidth = 2;
c.fill = GridBagConstraints.HORIZONTAL; | // Path: src/org/github/irengrig/fossil4idea/FossilConfiguration.java
// @State(
// name = "FossilConfiguration",
// storages = {
// @Storage(file = StoragePathMacros.WORKSPACE_FILE)
// }
// )
// public class FossilConfiguration implements PersistentStateComponent<Element> {
// public String FOSSIL_PATH = "";
// private final Map<File, String> myRemoteUrls = new HashMap<File, String>();
//
// @Nullable
// public Element getState() {
// Element element = new Element("state");
// element.setAttribute("FOSSIL_PATH", FOSSIL_PATH);
// return element;
// }
//
// public void loadState(Element element) {
// final Attribute fossilPath = element.getAttribute("FOSSIL_PATH");
// if (fossilPath != null) {
// FOSSIL_PATH = fossilPath.getValue();
// }
// }
//
// public static FossilConfiguration getInstance(final Project project) {
// return ServiceManager.getService(project, FossilConfiguration.class);
// }
//
// public void setRemoteUrls(final Map<File, String> urls) {
// myRemoteUrls.clear();
// myRemoteUrls.putAll(urls);
// }
//
// public Map<File, String> getRemoteUrls() {
// return myRemoteUrls;
// }
// }
//
// Path: src/org/github/irengrig/fossil4idea/util/TextUtil.java
// public class TextUtil {
// private final static int optimal = 100;
// private final int myLimit;
//
// public TextUtil() {
// this(-1);
// }
//
// public TextUtil(int limit) {
// this.myLimit = limit < 0 ? optimal : limit;
// }
//
// public String insertLineCuts(final String s) {
// if (s == null || s.length() <= myLimit) return s;
// final int idx = s.substring(0, myLimit).lastIndexOf(' ');
// if (idx > 0) {
// return s.substring(0, idx) + "\n" + insertLineCuts(s.substring(idx + 1));
// }
// final int idx2 = s.indexOf(' ', myLimit);
// if (idx2 == -1) return s;
// return s.substring(0, idx2) + "\n" + insertLineCuts(s.substring(idx2 + 1));
// }
// }
// Path: src/org/github/irengrig/fossil4idea/pull/FossilUpdateConfigurable.java
import com.google.common.base.Strings;
import com.intellij.openapi.options.Configurable;
import com.intellij.openapi.options.ConfigurationException;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.MultiLineLabelUI;
import com.intellij.openapi.vcs.FilePath;
import com.intellij.ui.SimpleTextAttributes;
import com.intellij.ui.components.JBLabel;
import com.intellij.ui.components.JBPanel;
import com.intellij.ui.components.JBTextField;
import com.intellij.util.ui.UIUtil;
import org.github.irengrig.fossil4idea.FossilConfiguration;
import org.github.irengrig.fossil4idea.util.TextUtil;
import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.awt.*;
import java.io.File;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.StringTokenizer;
comp.setFont(comp.getFont().deriveFont(Font.BOLD));
panel.add(comp, c);
c.gridwidth = 1;
for (FilePath root : myRoots) {
c.weighty = 0;
c.gridx = 0;
++ c.gridy;
c.fill = GridBagConstraints.NONE;
panel.add(new JBLabel(root.getName() + " (" + root.getParentPath() + ")"), c);
++ c.gridx;
c.fill = GridBagConstraints.HORIZONTAL;
c.weighty = 1;
final JBTextField field = new JBTextField();
panel.add(field, c);
myFields.put(root.getIOFile(), field);
final String preset = myCheckoutURLs.get(root.getIOFile());
if (preset != null) {
field.setText(preset);
}
}
addWarning(panel, c);
}
private void addWarning(JBPanel panel, GridBagConstraints c) {
if (myWarning != null && myWarning.length() > 0) {
++ c.gridy;
c.gridx = 0;
c.gridwidth = 2;
c.fill = GridBagConstraints.HORIZONTAL; | final JLabel label = new JLabel(new TextUtil().insertLineCuts("Warning: " + myWarning)); |
irengrig/fossil4idea | src/org/github/irengrig/fossil4idea/pull/FossilUpdateConfigurable.java | // Path: src/org/github/irengrig/fossil4idea/FossilConfiguration.java
// @State(
// name = "FossilConfiguration",
// storages = {
// @Storage(file = StoragePathMacros.WORKSPACE_FILE)
// }
// )
// public class FossilConfiguration implements PersistentStateComponent<Element> {
// public String FOSSIL_PATH = "";
// private final Map<File, String> myRemoteUrls = new HashMap<File, String>();
//
// @Nullable
// public Element getState() {
// Element element = new Element("state");
// element.setAttribute("FOSSIL_PATH", FOSSIL_PATH);
// return element;
// }
//
// public void loadState(Element element) {
// final Attribute fossilPath = element.getAttribute("FOSSIL_PATH");
// if (fossilPath != null) {
// FOSSIL_PATH = fossilPath.getValue();
// }
// }
//
// public static FossilConfiguration getInstance(final Project project) {
// return ServiceManager.getService(project, FossilConfiguration.class);
// }
//
// public void setRemoteUrls(final Map<File, String> urls) {
// myRemoteUrls.clear();
// myRemoteUrls.putAll(urls);
// }
//
// public Map<File, String> getRemoteUrls() {
// return myRemoteUrls;
// }
// }
//
// Path: src/org/github/irengrig/fossil4idea/util/TextUtil.java
// public class TextUtil {
// private final static int optimal = 100;
// private final int myLimit;
//
// public TextUtil() {
// this(-1);
// }
//
// public TextUtil(int limit) {
// this.myLimit = limit < 0 ? optimal : limit;
// }
//
// public String insertLineCuts(final String s) {
// if (s == null || s.length() <= myLimit) return s;
// final int idx = s.substring(0, myLimit).lastIndexOf(' ');
// if (idx > 0) {
// return s.substring(0, idx) + "\n" + insertLineCuts(s.substring(idx + 1));
// }
// final int idx2 = s.indexOf(' ', myLimit);
// if (idx2 == -1) return s;
// return s.substring(0, idx2) + "\n" + insertLineCuts(s.substring(idx2 + 1));
// }
// }
| import com.google.common.base.Strings;
import com.intellij.openapi.options.Configurable;
import com.intellij.openapi.options.ConfigurationException;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.MultiLineLabelUI;
import com.intellij.openapi.vcs.FilePath;
import com.intellij.ui.SimpleTextAttributes;
import com.intellij.ui.components.JBLabel;
import com.intellij.ui.components.JBPanel;
import com.intellij.ui.components.JBTextField;
import com.intellij.util.ui.UIUtil;
import org.github.irengrig.fossil4idea.FossilConfiguration;
import org.github.irengrig.fossil4idea.util.TextUtil;
import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.awt.*;
import java.io.File;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.StringTokenizer; | panel.add(field, c);
myFields.put(root.getIOFile(), field);
final String preset = myCheckoutURLs.get(root.getIOFile());
if (preset != null) {
field.setText(preset);
}
}
addWarning(panel, c);
}
private void addWarning(JBPanel panel, GridBagConstraints c) {
if (myWarning != null && myWarning.length() > 0) {
++ c.gridy;
c.gridx = 0;
c.gridwidth = 2;
c.fill = GridBagConstraints.HORIZONTAL;
final JLabel label = new JLabel(new TextUtil().insertLineCuts("Warning: " + myWarning));
label.setUI(new MultiLineLabelUI());
label.setForeground(SimpleTextAttributes.ERROR_ATTRIBUTES.getFgColor());
panel.add(label, c);
}
}
@Override
public boolean isModified() {
return false;
}
@Override
public void apply() throws ConfigurationException { | // Path: src/org/github/irengrig/fossil4idea/FossilConfiguration.java
// @State(
// name = "FossilConfiguration",
// storages = {
// @Storage(file = StoragePathMacros.WORKSPACE_FILE)
// }
// )
// public class FossilConfiguration implements PersistentStateComponent<Element> {
// public String FOSSIL_PATH = "";
// private final Map<File, String> myRemoteUrls = new HashMap<File, String>();
//
// @Nullable
// public Element getState() {
// Element element = new Element("state");
// element.setAttribute("FOSSIL_PATH", FOSSIL_PATH);
// return element;
// }
//
// public void loadState(Element element) {
// final Attribute fossilPath = element.getAttribute("FOSSIL_PATH");
// if (fossilPath != null) {
// FOSSIL_PATH = fossilPath.getValue();
// }
// }
//
// public static FossilConfiguration getInstance(final Project project) {
// return ServiceManager.getService(project, FossilConfiguration.class);
// }
//
// public void setRemoteUrls(final Map<File, String> urls) {
// myRemoteUrls.clear();
// myRemoteUrls.putAll(urls);
// }
//
// public Map<File, String> getRemoteUrls() {
// return myRemoteUrls;
// }
// }
//
// Path: src/org/github/irengrig/fossil4idea/util/TextUtil.java
// public class TextUtil {
// private final static int optimal = 100;
// private final int myLimit;
//
// public TextUtil() {
// this(-1);
// }
//
// public TextUtil(int limit) {
// this.myLimit = limit < 0 ? optimal : limit;
// }
//
// public String insertLineCuts(final String s) {
// if (s == null || s.length() <= myLimit) return s;
// final int idx = s.substring(0, myLimit).lastIndexOf(' ');
// if (idx > 0) {
// return s.substring(0, idx) + "\n" + insertLineCuts(s.substring(idx + 1));
// }
// final int idx2 = s.indexOf(' ', myLimit);
// if (idx2 == -1) return s;
// return s.substring(0, idx2) + "\n" + insertLineCuts(s.substring(idx2 + 1));
// }
// }
// Path: src/org/github/irengrig/fossil4idea/pull/FossilUpdateConfigurable.java
import com.google.common.base.Strings;
import com.intellij.openapi.options.Configurable;
import com.intellij.openapi.options.ConfigurationException;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.MultiLineLabelUI;
import com.intellij.openapi.vcs.FilePath;
import com.intellij.ui.SimpleTextAttributes;
import com.intellij.ui.components.JBLabel;
import com.intellij.ui.components.JBPanel;
import com.intellij.ui.components.JBTextField;
import com.intellij.util.ui.UIUtil;
import org.github.irengrig.fossil4idea.FossilConfiguration;
import org.github.irengrig.fossil4idea.util.TextUtil;
import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.awt.*;
import java.io.File;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.StringTokenizer;
panel.add(field, c);
myFields.put(root.getIOFile(), field);
final String preset = myCheckoutURLs.get(root.getIOFile());
if (preset != null) {
field.setText(preset);
}
}
addWarning(panel, c);
}
private void addWarning(JBPanel panel, GridBagConstraints c) {
if (myWarning != null && myWarning.length() > 0) {
++ c.gridy;
c.gridx = 0;
c.gridwidth = 2;
c.fill = GridBagConstraints.HORIZONTAL;
final JLabel label = new JLabel(new TextUtil().insertLineCuts("Warning: " + myWarning));
label.setUI(new MultiLineLabelUI());
label.setForeground(SimpleTextAttributes.ERROR_ATTRIBUTES.getFgColor());
panel.add(label, c);
}
}
@Override
public boolean isModified() {
return false;
}
@Override
public void apply() throws ConfigurationException { | FossilConfiguration configuration = FossilConfiguration.getInstance(myProject); |
fabioCollini/LifeCycleBinder | test-data-lib/src/main/java/com/test/retained/ActivityWithRetainedGenericAndField.java | // Path: test-data-lib/src/main/java/com/test/MyObjectGeneric.java
// public class MyObjectGeneric<T> implements LifeCycleAware<MyView> {
// @Override
// public void onCreate(MyView view, Bundle savedInstanceState, Intent intent, Bundle arguments) {
//
// }
//
// @Override
// public void onStart(MyView view) {
//
// }
//
// @Override
// public void onResume(MyView view) {
//
// }
//
// @Override
// public boolean hasOptionsMenu(MyView view) {
// return false;
// }
//
// @Override
// public void onCreateOptionsMenu(MyView view, Menu menu, MenuInflater inflater) {
//
// }
//
// @Override
// public boolean onOptionsItemSelected(MyView view, MenuItem item) {
// return false;
// }
//
// @Override
// public void onPause(MyView view) {
//
// }
//
// @Override
// public void onStop(MyView view) {
//
// }
//
// @Override
// public void onSaveInstanceState(MyView view, Bundle bundle) {
//
// }
//
// @Override
// public void onDestroy(MyView view, boolean changingConfigurations) {
//
// }
//
// @Override
// public void onActivityResult(MyView view, int requestCode, int resultCode, Intent data) {
//
// }
//
// @Override public void onViewCreated(MyView view, Bundle savedInstanceState) {
//
// }
//
// @Override public void onDestroyView(MyView view) {
//
// }
// }
//
// Path: test-data-lib/src/main/java/com/test/MyView.java
// public interface MyView {
// }
| import android.support.v4.app.FragmentActivity;
import com.test.MyObjectGeneric;
import com.test.MyView;
import java.util.concurrent.Callable;
import it.codingjam.lifecyclebinder.RetainedObjectProvider; | /*
* Copyright 2016 Fabio Collini.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.test.retained;
public class ActivityWithRetainedGenericAndField extends FragmentActivity implements MyView {
@RetainedObjectProvider("myObjectGeneric") | // Path: test-data-lib/src/main/java/com/test/MyObjectGeneric.java
// public class MyObjectGeneric<T> implements LifeCycleAware<MyView> {
// @Override
// public void onCreate(MyView view, Bundle savedInstanceState, Intent intent, Bundle arguments) {
//
// }
//
// @Override
// public void onStart(MyView view) {
//
// }
//
// @Override
// public void onResume(MyView view) {
//
// }
//
// @Override
// public boolean hasOptionsMenu(MyView view) {
// return false;
// }
//
// @Override
// public void onCreateOptionsMenu(MyView view, Menu menu, MenuInflater inflater) {
//
// }
//
// @Override
// public boolean onOptionsItemSelected(MyView view, MenuItem item) {
// return false;
// }
//
// @Override
// public void onPause(MyView view) {
//
// }
//
// @Override
// public void onStop(MyView view) {
//
// }
//
// @Override
// public void onSaveInstanceState(MyView view, Bundle bundle) {
//
// }
//
// @Override
// public void onDestroy(MyView view, boolean changingConfigurations) {
//
// }
//
// @Override
// public void onActivityResult(MyView view, int requestCode, int resultCode, Intent data) {
//
// }
//
// @Override public void onViewCreated(MyView view, Bundle savedInstanceState) {
//
// }
//
// @Override public void onDestroyView(MyView view) {
//
// }
// }
//
// Path: test-data-lib/src/main/java/com/test/MyView.java
// public interface MyView {
// }
// Path: test-data-lib/src/main/java/com/test/retained/ActivityWithRetainedGenericAndField.java
import android.support.v4.app.FragmentActivity;
import com.test.MyObjectGeneric;
import com.test.MyView;
import java.util.concurrent.Callable;
import it.codingjam.lifecyclebinder.RetainedObjectProvider;
/*
* Copyright 2016 Fabio Collini.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.test.retained;
public class ActivityWithRetainedGenericAndField extends FragmentActivity implements MyView {
@RetainedObjectProvider("myObjectGeneric") | Callable<MyObjectGeneric<String>> myObjectProvider = new Callable<MyObjectGeneric<String>>() { |
fabioCollini/LifeCycleBinder | test-data-lib/src/main/java/com/test/objectWithBaseClass/MyObjectWithBaseClass$LifeCycleBinder.java | // Path: test-data-lib/src/main/java/com/test/MyObject$LifeCycleBinder.java
// public class MyObject$LifeCycleBinder {
//
// public static MyObject bind(LifeCycleAwareCollector collector, MyObject lifeCycleAware, boolean addInList) {
// if (addInList) {
// collector.addLifeCycleAware(lifeCycleAware);
// }
// return lifeCycleAware;
// }
// }
//
// Path: lifecyclebinder-api/src/main/java/it/codingjam/lifecyclebinder/LifeCycleAwareCollector.java
// public interface LifeCycleAwareCollector {
// <R> R addRetainedFactory(String key, Callable<R> factory, boolean addInLifeCycleAwareList);
//
// void addLifeCycleAware(LifeCycleAware<?> lifeCycleAware);
//
// <R> R getOrCreate(R lifeCycleAware, String key, Callable<R> factory);
// }
| import com.test.MyObject$LifeCycleBinder;
import it.codingjam.lifecyclebinder.LifeCycleAwareCollector; | /*
* Copyright 2016 Fabio Collini.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.test.objectWithBaseClass;
public class MyObjectWithBaseClass$LifeCycleBinder {
public static MyObjectWithBaseClass bind(LifeCycleAwareCollector collector, MyObjectWithBaseClass lifeCycleAware, boolean addInList) { | // Path: test-data-lib/src/main/java/com/test/MyObject$LifeCycleBinder.java
// public class MyObject$LifeCycleBinder {
//
// public static MyObject bind(LifeCycleAwareCollector collector, MyObject lifeCycleAware, boolean addInList) {
// if (addInList) {
// collector.addLifeCycleAware(lifeCycleAware);
// }
// return lifeCycleAware;
// }
// }
//
// Path: lifecyclebinder-api/src/main/java/it/codingjam/lifecyclebinder/LifeCycleAwareCollector.java
// public interface LifeCycleAwareCollector {
// <R> R addRetainedFactory(String key, Callable<R> factory, boolean addInLifeCycleAwareList);
//
// void addLifeCycleAware(LifeCycleAware<?> lifeCycleAware);
//
// <R> R getOrCreate(R lifeCycleAware, String key, Callable<R> factory);
// }
// Path: test-data-lib/src/main/java/com/test/objectWithBaseClass/MyObjectWithBaseClass$LifeCycleBinder.java
import com.test.MyObject$LifeCycleBinder;
import it.codingjam.lifecyclebinder.LifeCycleAwareCollector;
/*
* Copyright 2016 Fabio Collini.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.test.objectWithBaseClass;
public class MyObjectWithBaseClass$LifeCycleBinder {
public static MyObjectWithBaseClass bind(LifeCycleAwareCollector collector, MyObjectWithBaseClass lifeCycleAware, boolean addInList) { | MyObject$LifeCycleBinder.bind(collector, collector.getOrCreate(lifeCycleAware.myObject, null, null), true); |
fabioCollini/LifeCycleBinder | test-data-lib/src/main/java/com/test/objectWithBaseClass/MyObjectWithBaseClass.java | // Path: lifecyclebinder-processor/src/test/java/com/test/MyObject.java
// public class MyObject implements LifeCycleAware<MyView> {
// @Override
// public void onCreate(MyView view, Bundle savedInstanceState, Intent intent, Bundle arguments) {
//
// }
//
// @Override
// public void onStart(MyView view) {
//
// }
//
// @Override
// public void onResume(MyView view) {
//
// }
//
// @Override
// public boolean hasOptionsMenu(MyView view) {
// return false;
// }
//
// @Override
// public void onCreateOptionsMenu(MyView view, Menu menu, MenuInflater inflater) {
//
// }
//
// @Override
// public boolean onOptionsItemSelected(MyView view, MenuItem item) {
// return false;
// }
//
// @Override
// public void onPause(MyView view) {
//
// }
//
// @Override
// public void onStop(MyView view) {
//
// }
//
// @Override
// public void onSaveInstanceState(MyView view, Bundle bundle) {
//
// }
//
// @Override
// public void onDestroy(MyView view, boolean changingConfigurations) {
//
// }
//
// @Override
// public void onActivityResult(MyView view, int requestCode, int resultCode, Intent data) {
//
// }
//
// @Override public void onViewCreated(MyView view, Bundle savedInstanceState) {
//
// }
//
// @Override public void onDestroyView(MyView view) {
//
// }
// }
//
// Path: test-data-lib/src/main/java/com/test/MyView.java
// public interface MyView {
// }
//
// Path: lifecyclebinder-api/src/main/java/it/codingjam/lifecyclebinder/LifeCycleAware.java
// public interface LifeCycleAware<T> {
// void onCreate(T view, Bundle savedInstanceState, Intent intent, Bundle arguments);
//
// void onStart(T view);
//
// void onResume(T view);
//
// boolean hasOptionsMenu(T view);
//
// void onCreateOptionsMenu(T view, Menu menu, MenuInflater inflater);
//
// boolean onOptionsItemSelected(T view, MenuItem item);
//
// void onPause(T view);
//
// void onStop(T view);
//
// void onSaveInstanceState(T view, Bundle bundle);
//
// void onDestroy(T view, boolean changingConfigurations);
//
// void onActivityResult(T view, int requestCode, int resultCode, Intent data);
//
// void onViewCreated(T view, Bundle savedInstanceState);
//
// void onDestroyView(T view);
// }
| import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import com.test.MyObject;
import com.test.MyView;
import it.codingjam.lifecyclebinder.BindLifeCycle;
import it.codingjam.lifecyclebinder.LifeCycleAware; | public void onStop(MyView view) {
}
@Override
public void onSaveInstanceState(MyView view, Bundle bundle) {
}
@Override
public void onDestroy(MyView view, boolean changingConfigurations) {
}
@Override
public void onActivityResult(MyView view, int requestCode, int resultCode, Intent data) {
}
@Override public void onViewCreated(MyView view, Bundle savedInstanceState) {
}
@Override public void onDestroyView(MyView view) {
}
}
public class MyObjectWithBaseClass extends MyBaseClass {
@BindLifeCycle | // Path: lifecyclebinder-processor/src/test/java/com/test/MyObject.java
// public class MyObject implements LifeCycleAware<MyView> {
// @Override
// public void onCreate(MyView view, Bundle savedInstanceState, Intent intent, Bundle arguments) {
//
// }
//
// @Override
// public void onStart(MyView view) {
//
// }
//
// @Override
// public void onResume(MyView view) {
//
// }
//
// @Override
// public boolean hasOptionsMenu(MyView view) {
// return false;
// }
//
// @Override
// public void onCreateOptionsMenu(MyView view, Menu menu, MenuInflater inflater) {
//
// }
//
// @Override
// public boolean onOptionsItemSelected(MyView view, MenuItem item) {
// return false;
// }
//
// @Override
// public void onPause(MyView view) {
//
// }
//
// @Override
// public void onStop(MyView view) {
//
// }
//
// @Override
// public void onSaveInstanceState(MyView view, Bundle bundle) {
//
// }
//
// @Override
// public void onDestroy(MyView view, boolean changingConfigurations) {
//
// }
//
// @Override
// public void onActivityResult(MyView view, int requestCode, int resultCode, Intent data) {
//
// }
//
// @Override public void onViewCreated(MyView view, Bundle savedInstanceState) {
//
// }
//
// @Override public void onDestroyView(MyView view) {
//
// }
// }
//
// Path: test-data-lib/src/main/java/com/test/MyView.java
// public interface MyView {
// }
//
// Path: lifecyclebinder-api/src/main/java/it/codingjam/lifecyclebinder/LifeCycleAware.java
// public interface LifeCycleAware<T> {
// void onCreate(T view, Bundle savedInstanceState, Intent intent, Bundle arguments);
//
// void onStart(T view);
//
// void onResume(T view);
//
// boolean hasOptionsMenu(T view);
//
// void onCreateOptionsMenu(T view, Menu menu, MenuInflater inflater);
//
// boolean onOptionsItemSelected(T view, MenuItem item);
//
// void onPause(T view);
//
// void onStop(T view);
//
// void onSaveInstanceState(T view, Bundle bundle);
//
// void onDestroy(T view, boolean changingConfigurations);
//
// void onActivityResult(T view, int requestCode, int resultCode, Intent data);
//
// void onViewCreated(T view, Bundle savedInstanceState);
//
// void onDestroyView(T view);
// }
// Path: test-data-lib/src/main/java/com/test/objectWithBaseClass/MyObjectWithBaseClass.java
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import com.test.MyObject;
import com.test.MyView;
import it.codingjam.lifecyclebinder.BindLifeCycle;
import it.codingjam.lifecyclebinder.LifeCycleAware;
public void onStop(MyView view) {
}
@Override
public void onSaveInstanceState(MyView view, Bundle bundle) {
}
@Override
public void onDestroy(MyView view, boolean changingConfigurations) {
}
@Override
public void onActivityResult(MyView view, int requestCode, int resultCode, Intent data) {
}
@Override public void onViewCreated(MyView view, Bundle savedInstanceState) {
}
@Override public void onDestroyView(MyView view) {
}
}
public class MyObjectWithBaseClass extends MyBaseClass {
@BindLifeCycle | MyObject myObject; |
fabioCollini/LifeCycleBinder | test-data-lib/src/main/java/com/test/myActivityEventsViewParam/MyObjectWithEvents$LifeCycleBinder.java | // Path: test-data-lib/src/main/java/com/test/MyView.java
// public interface MyView {
// }
//
// Path: lifecyclebinder-api/src/main/java/it/codingjam/lifecyclebinder/DefaultLifeCycleAware.java
// public class DefaultLifeCycleAware<T> implements LifeCycleAware<T> {
// @Override
// public void onCreate(T view, Bundle savedInstanceState, Intent intent, Bundle arguments) {
// }
//
// @Override
// public void onStart(T view) {
// }
//
// @Override
// public void onResume(T view) {
// }
//
// @Override
// public boolean hasOptionsMenu(T view) {
// return false;
// }
//
// @Override
// public void onCreateOptionsMenu(T view, Menu menu, MenuInflater inflater) {
// }
//
// @Override
// public boolean onOptionsItemSelected(T view, MenuItem item) {
// return false;
// }
//
// @Override
// public void onPause(T view) {
// }
//
// @Override
// public void onStop(T view) {
// }
//
// @Override
// public void onSaveInstanceState(T view, Bundle bundle) {
// }
//
// @Override
// public void onDestroy(T view, boolean changingConfigurations) {
// }
//
// @Override
// public void onActivityResult(T view, int requestCode, int resultCode, Intent data) {
// }
//
// @Override public void onViewCreated(T view, Bundle savedInstanceState) {
// }
//
// @Override public void onDestroyView(T view) {
// }
// }
//
// Path: lifecyclebinder-api/src/main/java/it/codingjam/lifecyclebinder/LifeCycleAwareCollector.java
// public interface LifeCycleAwareCollector {
// <R> R addRetainedFactory(String key, Callable<R> factory, boolean addInLifeCycleAwareList);
//
// void addLifeCycleAware(LifeCycleAware<?> lifeCycleAware);
//
// <R> R getOrCreate(R lifeCycleAware, String key, Callable<R> factory);
// }
| import android.content.Intent;
import android.os.Bundle;
import com.test.MyView;
import it.codingjam.lifecyclebinder.DefaultLifeCycleAware;
import it.codingjam.lifecyclebinder.LifeCycleAwareCollector; | package com.test.myActivityEventsViewParam;
public class MyObjectWithEvents$LifeCycleBinder {
public static MyObjectWithEvents bind(LifeCycleAwareCollector collector, final MyObjectWithEvents lifeCycleAware, boolean addInList) {
if (addInList) { | // Path: test-data-lib/src/main/java/com/test/MyView.java
// public interface MyView {
// }
//
// Path: lifecyclebinder-api/src/main/java/it/codingjam/lifecyclebinder/DefaultLifeCycleAware.java
// public class DefaultLifeCycleAware<T> implements LifeCycleAware<T> {
// @Override
// public void onCreate(T view, Bundle savedInstanceState, Intent intent, Bundle arguments) {
// }
//
// @Override
// public void onStart(T view) {
// }
//
// @Override
// public void onResume(T view) {
// }
//
// @Override
// public boolean hasOptionsMenu(T view) {
// return false;
// }
//
// @Override
// public void onCreateOptionsMenu(T view, Menu menu, MenuInflater inflater) {
// }
//
// @Override
// public boolean onOptionsItemSelected(T view, MenuItem item) {
// return false;
// }
//
// @Override
// public void onPause(T view) {
// }
//
// @Override
// public void onStop(T view) {
// }
//
// @Override
// public void onSaveInstanceState(T view, Bundle bundle) {
// }
//
// @Override
// public void onDestroy(T view, boolean changingConfigurations) {
// }
//
// @Override
// public void onActivityResult(T view, int requestCode, int resultCode, Intent data) {
// }
//
// @Override public void onViewCreated(T view, Bundle savedInstanceState) {
// }
//
// @Override public void onDestroyView(T view) {
// }
// }
//
// Path: lifecyclebinder-api/src/main/java/it/codingjam/lifecyclebinder/LifeCycleAwareCollector.java
// public interface LifeCycleAwareCollector {
// <R> R addRetainedFactory(String key, Callable<R> factory, boolean addInLifeCycleAwareList);
//
// void addLifeCycleAware(LifeCycleAware<?> lifeCycleAware);
//
// <R> R getOrCreate(R lifeCycleAware, String key, Callable<R> factory);
// }
// Path: test-data-lib/src/main/java/com/test/myActivityEventsViewParam/MyObjectWithEvents$LifeCycleBinder.java
import android.content.Intent;
import android.os.Bundle;
import com.test.MyView;
import it.codingjam.lifecyclebinder.DefaultLifeCycleAware;
import it.codingjam.lifecyclebinder.LifeCycleAwareCollector;
package com.test.myActivityEventsViewParam;
public class MyObjectWithEvents$LifeCycleBinder {
public static MyObjectWithEvents bind(LifeCycleAwareCollector collector, final MyObjectWithEvents lifeCycleAware, boolean addInList) {
if (addInList) { | collector.addLifeCycleAware(new DefaultLifeCycleAware<MyView>() { |
fabioCollini/LifeCycleBinder | test-data-lib/src/main/java/com/test/myActivityEventsViewParam/MyObjectWithEvents$LifeCycleBinder.java | // Path: test-data-lib/src/main/java/com/test/MyView.java
// public interface MyView {
// }
//
// Path: lifecyclebinder-api/src/main/java/it/codingjam/lifecyclebinder/DefaultLifeCycleAware.java
// public class DefaultLifeCycleAware<T> implements LifeCycleAware<T> {
// @Override
// public void onCreate(T view, Bundle savedInstanceState, Intent intent, Bundle arguments) {
// }
//
// @Override
// public void onStart(T view) {
// }
//
// @Override
// public void onResume(T view) {
// }
//
// @Override
// public boolean hasOptionsMenu(T view) {
// return false;
// }
//
// @Override
// public void onCreateOptionsMenu(T view, Menu menu, MenuInflater inflater) {
// }
//
// @Override
// public boolean onOptionsItemSelected(T view, MenuItem item) {
// return false;
// }
//
// @Override
// public void onPause(T view) {
// }
//
// @Override
// public void onStop(T view) {
// }
//
// @Override
// public void onSaveInstanceState(T view, Bundle bundle) {
// }
//
// @Override
// public void onDestroy(T view, boolean changingConfigurations) {
// }
//
// @Override
// public void onActivityResult(T view, int requestCode, int resultCode, Intent data) {
// }
//
// @Override public void onViewCreated(T view, Bundle savedInstanceState) {
// }
//
// @Override public void onDestroyView(T view) {
// }
// }
//
// Path: lifecyclebinder-api/src/main/java/it/codingjam/lifecyclebinder/LifeCycleAwareCollector.java
// public interface LifeCycleAwareCollector {
// <R> R addRetainedFactory(String key, Callable<R> factory, boolean addInLifeCycleAwareList);
//
// void addLifeCycleAware(LifeCycleAware<?> lifeCycleAware);
//
// <R> R getOrCreate(R lifeCycleAware, String key, Callable<R> factory);
// }
| import android.content.Intent;
import android.os.Bundle;
import com.test.MyView;
import it.codingjam.lifecyclebinder.DefaultLifeCycleAware;
import it.codingjam.lifecyclebinder.LifeCycleAwareCollector; | package com.test.myActivityEventsViewParam;
public class MyObjectWithEvents$LifeCycleBinder {
public static MyObjectWithEvents bind(LifeCycleAwareCollector collector, final MyObjectWithEvents lifeCycleAware, boolean addInList) {
if (addInList) { | // Path: test-data-lib/src/main/java/com/test/MyView.java
// public interface MyView {
// }
//
// Path: lifecyclebinder-api/src/main/java/it/codingjam/lifecyclebinder/DefaultLifeCycleAware.java
// public class DefaultLifeCycleAware<T> implements LifeCycleAware<T> {
// @Override
// public void onCreate(T view, Bundle savedInstanceState, Intent intent, Bundle arguments) {
// }
//
// @Override
// public void onStart(T view) {
// }
//
// @Override
// public void onResume(T view) {
// }
//
// @Override
// public boolean hasOptionsMenu(T view) {
// return false;
// }
//
// @Override
// public void onCreateOptionsMenu(T view, Menu menu, MenuInflater inflater) {
// }
//
// @Override
// public boolean onOptionsItemSelected(T view, MenuItem item) {
// return false;
// }
//
// @Override
// public void onPause(T view) {
// }
//
// @Override
// public void onStop(T view) {
// }
//
// @Override
// public void onSaveInstanceState(T view, Bundle bundle) {
// }
//
// @Override
// public void onDestroy(T view, boolean changingConfigurations) {
// }
//
// @Override
// public void onActivityResult(T view, int requestCode, int resultCode, Intent data) {
// }
//
// @Override public void onViewCreated(T view, Bundle savedInstanceState) {
// }
//
// @Override public void onDestroyView(T view) {
// }
// }
//
// Path: lifecyclebinder-api/src/main/java/it/codingjam/lifecyclebinder/LifeCycleAwareCollector.java
// public interface LifeCycleAwareCollector {
// <R> R addRetainedFactory(String key, Callable<R> factory, boolean addInLifeCycleAwareList);
//
// void addLifeCycleAware(LifeCycleAware<?> lifeCycleAware);
//
// <R> R getOrCreate(R lifeCycleAware, String key, Callable<R> factory);
// }
// Path: test-data-lib/src/main/java/com/test/myActivityEventsViewParam/MyObjectWithEvents$LifeCycleBinder.java
import android.content.Intent;
import android.os.Bundle;
import com.test.MyView;
import it.codingjam.lifecyclebinder.DefaultLifeCycleAware;
import it.codingjam.lifecyclebinder.LifeCycleAwareCollector;
package com.test.myActivityEventsViewParam;
public class MyObjectWithEvents$LifeCycleBinder {
public static MyObjectWithEvents bind(LifeCycleAwareCollector collector, final MyObjectWithEvents lifeCycleAware, boolean addInList) {
if (addInList) { | collector.addLifeCycleAware(new DefaultLifeCycleAware<MyView>() { |
fabioCollini/LifeCycleBinder | test-data-lib/src/main/java/com/test/retained/ActivityWithRetained$LifeCycleBinder.java | // Path: test-data-lib/src/main/java/com/test/MyObject$LifeCycleBinder.java
// public class MyObject$LifeCycleBinder {
//
// public static MyObject bind(LifeCycleAwareCollector collector, MyObject lifeCycleAware, boolean addInList) {
// if (addInList) {
// collector.addLifeCycleAware(lifeCycleAware);
// }
// return lifeCycleAware;
// }
// }
//
// Path: lifecyclebinder-api/src/main/java/it/codingjam/lifecyclebinder/LifeCycleAwareCollector.java
// public interface LifeCycleAwareCollector {
// <R> R addRetainedFactory(String key, Callable<R> factory, boolean addInLifeCycleAwareList);
//
// void addLifeCycleAware(LifeCycleAware<?> lifeCycleAware);
//
// <R> R getOrCreate(R lifeCycleAware, String key, Callable<R> factory);
// }
| import com.test.MyObject$LifeCycleBinder;
import it.codingjam.lifecyclebinder.LifeCycleAwareCollector; | /*
* Copyright 2016 Fabio Collini.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.test.retained;
public class ActivityWithRetained$LifeCycleBinder {
public static void bind(LifeCycleAwareCollector collector, final ActivityWithRetained view) { | // Path: test-data-lib/src/main/java/com/test/MyObject$LifeCycleBinder.java
// public class MyObject$LifeCycleBinder {
//
// public static MyObject bind(LifeCycleAwareCollector collector, MyObject lifeCycleAware, boolean addInList) {
// if (addInList) {
// collector.addLifeCycleAware(lifeCycleAware);
// }
// return lifeCycleAware;
// }
// }
//
// Path: lifecyclebinder-api/src/main/java/it/codingjam/lifecyclebinder/LifeCycleAwareCollector.java
// public interface LifeCycleAwareCollector {
// <R> R addRetainedFactory(String key, Callable<R> factory, boolean addInLifeCycleAwareList);
//
// void addLifeCycleAware(LifeCycleAware<?> lifeCycleAware);
//
// <R> R getOrCreate(R lifeCycleAware, String key, Callable<R> factory);
// }
// Path: test-data-lib/src/main/java/com/test/retained/ActivityWithRetained$LifeCycleBinder.java
import com.test.MyObject$LifeCycleBinder;
import it.codingjam.lifecyclebinder.LifeCycleAwareCollector;
/*
* Copyright 2016 Fabio Collini.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.test.retained;
public class ActivityWithRetained$LifeCycleBinder {
public static void bind(LifeCycleAwareCollector collector, final ActivityWithRetained view) { | MyObject$LifeCycleBinder.bind(collector, collector.getOrCreate(null, "myObjectProvider", view.myObjectProvider), true); |
fabioCollini/LifeCycleBinder | test-data-lib/src/main/java/com/test/retained/ActivityWithRetainedGeneric$LifeCycleBinder.java | // Path: test-data-lib/src/main/java/com/test/MyObjectGeneric$LifeCycleBinder.java
// public class MyObjectGeneric$LifeCycleBinder {
//
// public static MyObjectGeneric bind(LifeCycleAwareCollector collector, MyObjectGeneric lifeCycleAware, boolean addInList) {
// if (addInList) {
// collector.addLifeCycleAware(lifeCycleAware);
// }
// return lifeCycleAware;
// }
// }
//
// Path: lifecyclebinder-api/src/main/java/it/codingjam/lifecyclebinder/LifeCycleAwareCollector.java
// public interface LifeCycleAwareCollector {
// <R> R addRetainedFactory(String key, Callable<R> factory, boolean addInLifeCycleAwareList);
//
// void addLifeCycleAware(LifeCycleAware<?> lifeCycleAware);
//
// <R> R getOrCreate(R lifeCycleAware, String key, Callable<R> factory);
// }
| import com.test.MyObjectGeneric$LifeCycleBinder;
import it.codingjam.lifecyclebinder.LifeCycleAwareCollector; | /*
* Copyright 2016 Fabio Collini.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.test.retained;
public class ActivityWithRetainedGeneric$LifeCycleBinder {
public static void bind(LifeCycleAwareCollector collector, final ActivityWithRetainedGeneric view) { | // Path: test-data-lib/src/main/java/com/test/MyObjectGeneric$LifeCycleBinder.java
// public class MyObjectGeneric$LifeCycleBinder {
//
// public static MyObjectGeneric bind(LifeCycleAwareCollector collector, MyObjectGeneric lifeCycleAware, boolean addInList) {
// if (addInList) {
// collector.addLifeCycleAware(lifeCycleAware);
// }
// return lifeCycleAware;
// }
// }
//
// Path: lifecyclebinder-api/src/main/java/it/codingjam/lifecyclebinder/LifeCycleAwareCollector.java
// public interface LifeCycleAwareCollector {
// <R> R addRetainedFactory(String key, Callable<R> factory, boolean addInLifeCycleAwareList);
//
// void addLifeCycleAware(LifeCycleAware<?> lifeCycleAware);
//
// <R> R getOrCreate(R lifeCycleAware, String key, Callable<R> factory);
// }
// Path: test-data-lib/src/main/java/com/test/retained/ActivityWithRetainedGeneric$LifeCycleBinder.java
import com.test.MyObjectGeneric$LifeCycleBinder;
import it.codingjam.lifecyclebinder.LifeCycleAwareCollector;
/*
* Copyright 2016 Fabio Collini.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.test.retained;
public class ActivityWithRetainedGeneric$LifeCycleBinder {
public static void bind(LifeCycleAwareCollector collector, final ActivityWithRetainedGeneric view) { | MyObjectGeneric$LifeCycleBinder.bind(collector, collector.getOrCreate(null, "myObjectProvider", view.myObjectProvider), true); |
fabioCollini/LifeCycleBinder | test-data-lib/src/main/java/com/test/myActivityEventsNoViewParam/MyObjectWithEvents$LifeCycleBinder.java | // Path: lifecyclebinder-api/src/main/java/it/codingjam/lifecyclebinder/DefaultLifeCycleAware.java
// public class DefaultLifeCycleAware<T> implements LifeCycleAware<T> {
// @Override
// public void onCreate(T view, Bundle savedInstanceState, Intent intent, Bundle arguments) {
// }
//
// @Override
// public void onStart(T view) {
// }
//
// @Override
// public void onResume(T view) {
// }
//
// @Override
// public boolean hasOptionsMenu(T view) {
// return false;
// }
//
// @Override
// public void onCreateOptionsMenu(T view, Menu menu, MenuInflater inflater) {
// }
//
// @Override
// public boolean onOptionsItemSelected(T view, MenuItem item) {
// return false;
// }
//
// @Override
// public void onPause(T view) {
// }
//
// @Override
// public void onStop(T view) {
// }
//
// @Override
// public void onSaveInstanceState(T view, Bundle bundle) {
// }
//
// @Override
// public void onDestroy(T view, boolean changingConfigurations) {
// }
//
// @Override
// public void onActivityResult(T view, int requestCode, int resultCode, Intent data) {
// }
//
// @Override public void onViewCreated(T view, Bundle savedInstanceState) {
// }
//
// @Override public void onDestroyView(T view) {
// }
// }
//
// Path: lifecyclebinder-api/src/main/java/it/codingjam/lifecyclebinder/LifeCycleAwareCollector.java
// public interface LifeCycleAwareCollector {
// <R> R addRetainedFactory(String key, Callable<R> factory, boolean addInLifeCycleAwareList);
//
// void addLifeCycleAware(LifeCycleAware<?> lifeCycleAware);
//
// <R> R getOrCreate(R lifeCycleAware, String key, Callable<R> factory);
// }
//
// Path: lifecyclebinder-api/src/main/java/it/codingjam/lifecyclebinder/LifeCycleEvent.java
// public enum LifeCycleEvent {
// CREATE, START, RESUME, PAUSE, STOP, DESTROY, SAVE_INSTANCE_STATE, ACTIVITY_RESULT, HAS_OPTION_MENU, CREATE_OPTION_MENU, OPTION_ITEM_SELECTED, VIEW_CREATED, DESTROY_VIEW;
// }
| import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import it.codingjam.lifecyclebinder.DefaultLifeCycleAware;
import it.codingjam.lifecyclebinder.LifeCycleAwareCollector;
import it.codingjam.lifecyclebinder.LifeCycleEvent; | package com.test.myActivityEventsNoViewParam;
public class MyObjectWithEvents$LifeCycleBinder {
public static MyObjectWithEvents bind(LifeCycleAwareCollector collector, final MyObjectWithEvents lifeCycleAware, boolean addInList) {
if (addInList) { | // Path: lifecyclebinder-api/src/main/java/it/codingjam/lifecyclebinder/DefaultLifeCycleAware.java
// public class DefaultLifeCycleAware<T> implements LifeCycleAware<T> {
// @Override
// public void onCreate(T view, Bundle savedInstanceState, Intent intent, Bundle arguments) {
// }
//
// @Override
// public void onStart(T view) {
// }
//
// @Override
// public void onResume(T view) {
// }
//
// @Override
// public boolean hasOptionsMenu(T view) {
// return false;
// }
//
// @Override
// public void onCreateOptionsMenu(T view, Menu menu, MenuInflater inflater) {
// }
//
// @Override
// public boolean onOptionsItemSelected(T view, MenuItem item) {
// return false;
// }
//
// @Override
// public void onPause(T view) {
// }
//
// @Override
// public void onStop(T view) {
// }
//
// @Override
// public void onSaveInstanceState(T view, Bundle bundle) {
// }
//
// @Override
// public void onDestroy(T view, boolean changingConfigurations) {
// }
//
// @Override
// public void onActivityResult(T view, int requestCode, int resultCode, Intent data) {
// }
//
// @Override public void onViewCreated(T view, Bundle savedInstanceState) {
// }
//
// @Override public void onDestroyView(T view) {
// }
// }
//
// Path: lifecyclebinder-api/src/main/java/it/codingjam/lifecyclebinder/LifeCycleAwareCollector.java
// public interface LifeCycleAwareCollector {
// <R> R addRetainedFactory(String key, Callable<R> factory, boolean addInLifeCycleAwareList);
//
// void addLifeCycleAware(LifeCycleAware<?> lifeCycleAware);
//
// <R> R getOrCreate(R lifeCycleAware, String key, Callable<R> factory);
// }
//
// Path: lifecyclebinder-api/src/main/java/it/codingjam/lifecyclebinder/LifeCycleEvent.java
// public enum LifeCycleEvent {
// CREATE, START, RESUME, PAUSE, STOP, DESTROY, SAVE_INSTANCE_STATE, ACTIVITY_RESULT, HAS_OPTION_MENU, CREATE_OPTION_MENU, OPTION_ITEM_SELECTED, VIEW_CREATED, DESTROY_VIEW;
// }
// Path: test-data-lib/src/main/java/com/test/myActivityEventsNoViewParam/MyObjectWithEvents$LifeCycleBinder.java
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import it.codingjam.lifecyclebinder.DefaultLifeCycleAware;
import it.codingjam.lifecyclebinder.LifeCycleAwareCollector;
import it.codingjam.lifecyclebinder.LifeCycleEvent;
package com.test.myActivityEventsNoViewParam;
public class MyObjectWithEvents$LifeCycleBinder {
public static MyObjectWithEvents bind(LifeCycleAwareCollector collector, final MyObjectWithEvents lifeCycleAware, boolean addInList) {
if (addInList) { | collector.addLifeCycleAware(new DefaultLifeCycleAware<Object>() { |
fabioCollini/LifeCycleBinder | test-data-lib/src/main/java/com/test/myActivityEventsNoViewParam/MyObjectWithEvents$LifeCycleBinder.java | // Path: lifecyclebinder-api/src/main/java/it/codingjam/lifecyclebinder/DefaultLifeCycleAware.java
// public class DefaultLifeCycleAware<T> implements LifeCycleAware<T> {
// @Override
// public void onCreate(T view, Bundle savedInstanceState, Intent intent, Bundle arguments) {
// }
//
// @Override
// public void onStart(T view) {
// }
//
// @Override
// public void onResume(T view) {
// }
//
// @Override
// public boolean hasOptionsMenu(T view) {
// return false;
// }
//
// @Override
// public void onCreateOptionsMenu(T view, Menu menu, MenuInflater inflater) {
// }
//
// @Override
// public boolean onOptionsItemSelected(T view, MenuItem item) {
// return false;
// }
//
// @Override
// public void onPause(T view) {
// }
//
// @Override
// public void onStop(T view) {
// }
//
// @Override
// public void onSaveInstanceState(T view, Bundle bundle) {
// }
//
// @Override
// public void onDestroy(T view, boolean changingConfigurations) {
// }
//
// @Override
// public void onActivityResult(T view, int requestCode, int resultCode, Intent data) {
// }
//
// @Override public void onViewCreated(T view, Bundle savedInstanceState) {
// }
//
// @Override public void onDestroyView(T view) {
// }
// }
//
// Path: lifecyclebinder-api/src/main/java/it/codingjam/lifecyclebinder/LifeCycleAwareCollector.java
// public interface LifeCycleAwareCollector {
// <R> R addRetainedFactory(String key, Callable<R> factory, boolean addInLifeCycleAwareList);
//
// void addLifeCycleAware(LifeCycleAware<?> lifeCycleAware);
//
// <R> R getOrCreate(R lifeCycleAware, String key, Callable<R> factory);
// }
//
// Path: lifecyclebinder-api/src/main/java/it/codingjam/lifecyclebinder/LifeCycleEvent.java
// public enum LifeCycleEvent {
// CREATE, START, RESUME, PAUSE, STOP, DESTROY, SAVE_INSTANCE_STATE, ACTIVITY_RESULT, HAS_OPTION_MENU, CREATE_OPTION_MENU, OPTION_ITEM_SELECTED, VIEW_CREATED, DESTROY_VIEW;
// }
| import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import it.codingjam.lifecyclebinder.DefaultLifeCycleAware;
import it.codingjam.lifecyclebinder.LifeCycleAwareCollector;
import it.codingjam.lifecyclebinder.LifeCycleEvent; | package com.test.myActivityEventsNoViewParam;
public class MyObjectWithEvents$LifeCycleBinder {
public static MyObjectWithEvents bind(LifeCycleAwareCollector collector, final MyObjectWithEvents lifeCycleAware, boolean addInList) {
if (addInList) {
collector.addLifeCycleAware(new DefaultLifeCycleAware<Object>() {
public void onCreate(Object argView, Bundle arg0, Intent arg1, Bundle arg2) {
lifeCycleAware.myOnCreate();
}
public void onStart(Object argView) { | // Path: lifecyclebinder-api/src/main/java/it/codingjam/lifecyclebinder/DefaultLifeCycleAware.java
// public class DefaultLifeCycleAware<T> implements LifeCycleAware<T> {
// @Override
// public void onCreate(T view, Bundle savedInstanceState, Intent intent, Bundle arguments) {
// }
//
// @Override
// public void onStart(T view) {
// }
//
// @Override
// public void onResume(T view) {
// }
//
// @Override
// public boolean hasOptionsMenu(T view) {
// return false;
// }
//
// @Override
// public void onCreateOptionsMenu(T view, Menu menu, MenuInflater inflater) {
// }
//
// @Override
// public boolean onOptionsItemSelected(T view, MenuItem item) {
// return false;
// }
//
// @Override
// public void onPause(T view) {
// }
//
// @Override
// public void onStop(T view) {
// }
//
// @Override
// public void onSaveInstanceState(T view, Bundle bundle) {
// }
//
// @Override
// public void onDestroy(T view, boolean changingConfigurations) {
// }
//
// @Override
// public void onActivityResult(T view, int requestCode, int resultCode, Intent data) {
// }
//
// @Override public void onViewCreated(T view, Bundle savedInstanceState) {
// }
//
// @Override public void onDestroyView(T view) {
// }
// }
//
// Path: lifecyclebinder-api/src/main/java/it/codingjam/lifecyclebinder/LifeCycleAwareCollector.java
// public interface LifeCycleAwareCollector {
// <R> R addRetainedFactory(String key, Callable<R> factory, boolean addInLifeCycleAwareList);
//
// void addLifeCycleAware(LifeCycleAware<?> lifeCycleAware);
//
// <R> R getOrCreate(R lifeCycleAware, String key, Callable<R> factory);
// }
//
// Path: lifecyclebinder-api/src/main/java/it/codingjam/lifecyclebinder/LifeCycleEvent.java
// public enum LifeCycleEvent {
// CREATE, START, RESUME, PAUSE, STOP, DESTROY, SAVE_INSTANCE_STATE, ACTIVITY_RESULT, HAS_OPTION_MENU, CREATE_OPTION_MENU, OPTION_ITEM_SELECTED, VIEW_CREATED, DESTROY_VIEW;
// }
// Path: test-data-lib/src/main/java/com/test/myActivityEventsNoViewParam/MyObjectWithEvents$LifeCycleBinder.java
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import it.codingjam.lifecyclebinder.DefaultLifeCycleAware;
import it.codingjam.lifecyclebinder.LifeCycleAwareCollector;
import it.codingjam.lifecyclebinder.LifeCycleEvent;
package com.test.myActivityEventsNoViewParam;
public class MyObjectWithEvents$LifeCycleBinder {
public static MyObjectWithEvents bind(LifeCycleAwareCollector collector, final MyObjectWithEvents lifeCycleAware, boolean addInList) {
if (addInList) {
collector.addLifeCycleAware(new DefaultLifeCycleAware<Object>() {
public void onCreate(Object argView, Bundle arg0, Intent arg1, Bundle arg2) {
lifeCycleAware.myOnCreate();
}
public void onStart(Object argView) { | lifeCycleAware.myOnStart(LifeCycleEvent.START); |
fabioCollini/LifeCycleBinder | test-data-lib/src/main/java/com/test/retained/ActivityWithRetained2.java | // Path: lifecyclebinder-processor/src/test/java/com/test/MyObject.java
// public class MyObject implements LifeCycleAware<MyView> {
// @Override
// public void onCreate(MyView view, Bundle savedInstanceState, Intent intent, Bundle arguments) {
//
// }
//
// @Override
// public void onStart(MyView view) {
//
// }
//
// @Override
// public void onResume(MyView view) {
//
// }
//
// @Override
// public boolean hasOptionsMenu(MyView view) {
// return false;
// }
//
// @Override
// public void onCreateOptionsMenu(MyView view, Menu menu, MenuInflater inflater) {
//
// }
//
// @Override
// public boolean onOptionsItemSelected(MyView view, MenuItem item) {
// return false;
// }
//
// @Override
// public void onPause(MyView view) {
//
// }
//
// @Override
// public void onStop(MyView view) {
//
// }
//
// @Override
// public void onSaveInstanceState(MyView view, Bundle bundle) {
//
// }
//
// @Override
// public void onDestroy(MyView view, boolean changingConfigurations) {
//
// }
//
// @Override
// public void onActivityResult(MyView view, int requestCode, int resultCode, Intent data) {
//
// }
//
// @Override public void onViewCreated(MyView view, Bundle savedInstanceState) {
//
// }
//
// @Override public void onDestroyView(MyView view) {
//
// }
// }
//
// Path: test-data-lib/src/main/java/com/test/MyView.java
// public interface MyView {
// }
| import android.support.v4.app.FragmentActivity;
import com.test.MyObject;
import com.test.MyView;
import java.util.concurrent.Callable;
import it.codingjam.lifecyclebinder.RetainedObjectProvider; | /*
* Copyright 2016 Fabio Collini.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.test.retained;
public class ActivityWithRetained2 extends FragmentActivity implements MyView {
@RetainedObjectProvider | // Path: lifecyclebinder-processor/src/test/java/com/test/MyObject.java
// public class MyObject implements LifeCycleAware<MyView> {
// @Override
// public void onCreate(MyView view, Bundle savedInstanceState, Intent intent, Bundle arguments) {
//
// }
//
// @Override
// public void onStart(MyView view) {
//
// }
//
// @Override
// public void onResume(MyView view) {
//
// }
//
// @Override
// public boolean hasOptionsMenu(MyView view) {
// return false;
// }
//
// @Override
// public void onCreateOptionsMenu(MyView view, Menu menu, MenuInflater inflater) {
//
// }
//
// @Override
// public boolean onOptionsItemSelected(MyView view, MenuItem item) {
// return false;
// }
//
// @Override
// public void onPause(MyView view) {
//
// }
//
// @Override
// public void onStop(MyView view) {
//
// }
//
// @Override
// public void onSaveInstanceState(MyView view, Bundle bundle) {
//
// }
//
// @Override
// public void onDestroy(MyView view, boolean changingConfigurations) {
//
// }
//
// @Override
// public void onActivityResult(MyView view, int requestCode, int resultCode, Intent data) {
//
// }
//
// @Override public void onViewCreated(MyView view, Bundle savedInstanceState) {
//
// }
//
// @Override public void onDestroyView(MyView view) {
//
// }
// }
//
// Path: test-data-lib/src/main/java/com/test/MyView.java
// public interface MyView {
// }
// Path: test-data-lib/src/main/java/com/test/retained/ActivityWithRetained2.java
import android.support.v4.app.FragmentActivity;
import com.test.MyObject;
import com.test.MyView;
import java.util.concurrent.Callable;
import it.codingjam.lifecyclebinder.RetainedObjectProvider;
/*
* Copyright 2016 Fabio Collini.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.test.retained;
public class ActivityWithRetained2 extends FragmentActivity implements MyView {
@RetainedObjectProvider | Callable<MyObject> myObject = new Callable<MyObject>() { |
fabioCollini/LifeCycleBinder | test-data-lib/src/main/java/com/test/myActivity/MyActivity.java | // Path: test-data-lib/src/main/java/com/test/MyView.java
// public interface MyView {
// }
//
// Path: lifecyclebinder-api/src/main/java/it/codingjam/lifecyclebinder/LifeCycleAware.java
// public interface LifeCycleAware<T> {
// void onCreate(T view, Bundle savedInstanceState, Intent intent, Bundle arguments);
//
// void onStart(T view);
//
// void onResume(T view);
//
// boolean hasOptionsMenu(T view);
//
// void onCreateOptionsMenu(T view, Menu menu, MenuInflater inflater);
//
// boolean onOptionsItemSelected(T view, MenuItem item);
//
// void onPause(T view);
//
// void onStop(T view);
//
// void onSaveInstanceState(T view, Bundle bundle);
//
// void onDestroy(T view, boolean changingConfigurations);
//
// void onActivityResult(T view, int requestCode, int resultCode, Intent data);
//
// void onViewCreated(T view, Bundle savedInstanceState);
//
// void onDestroyView(T view);
// }
| import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import com.test.MyView;
import it.codingjam.lifecyclebinder.BindLifeCycle;
import it.codingjam.lifecyclebinder.LifeCycleAware; | /*
* Copyright 2016 Fabio Collini.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.test.myActivity;
public class MyActivity extends FragmentActivity implements MyView {
@BindLifeCycle
MyObject myObject;
}
@BindLifeCycle | // Path: test-data-lib/src/main/java/com/test/MyView.java
// public interface MyView {
// }
//
// Path: lifecyclebinder-api/src/main/java/it/codingjam/lifecyclebinder/LifeCycleAware.java
// public interface LifeCycleAware<T> {
// void onCreate(T view, Bundle savedInstanceState, Intent intent, Bundle arguments);
//
// void onStart(T view);
//
// void onResume(T view);
//
// boolean hasOptionsMenu(T view);
//
// void onCreateOptionsMenu(T view, Menu menu, MenuInflater inflater);
//
// boolean onOptionsItemSelected(T view, MenuItem item);
//
// void onPause(T view);
//
// void onStop(T view);
//
// void onSaveInstanceState(T view, Bundle bundle);
//
// void onDestroy(T view, boolean changingConfigurations);
//
// void onActivityResult(T view, int requestCode, int resultCode, Intent data);
//
// void onViewCreated(T view, Bundle savedInstanceState);
//
// void onDestroyView(T view);
// }
// Path: test-data-lib/src/main/java/com/test/myActivity/MyActivity.java
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import com.test.MyView;
import it.codingjam.lifecyclebinder.BindLifeCycle;
import it.codingjam.lifecyclebinder.LifeCycleAware;
/*
* Copyright 2016 Fabio Collini.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.test.myActivity;
public class MyActivity extends FragmentActivity implements MyView {
@BindLifeCycle
MyObject myObject;
}
@BindLifeCycle | class MyObject implements LifeCycleAware<MyView> { |
fabioCollini/LifeCycleBinder | test-data-lib/src/main/java/com/test/objectWithGenericBaseClass/MyObjectWithGenericBaseClass.java | // Path: lifecyclebinder-processor/src/test/java/com/test/MyObject.java
// public class MyObject implements LifeCycleAware<MyView> {
// @Override
// public void onCreate(MyView view, Bundle savedInstanceState, Intent intent, Bundle arguments) {
//
// }
//
// @Override
// public void onStart(MyView view) {
//
// }
//
// @Override
// public void onResume(MyView view) {
//
// }
//
// @Override
// public boolean hasOptionsMenu(MyView view) {
// return false;
// }
//
// @Override
// public void onCreateOptionsMenu(MyView view, Menu menu, MenuInflater inflater) {
//
// }
//
// @Override
// public boolean onOptionsItemSelected(MyView view, MenuItem item) {
// return false;
// }
//
// @Override
// public void onPause(MyView view) {
//
// }
//
// @Override
// public void onStop(MyView view) {
//
// }
//
// @Override
// public void onSaveInstanceState(MyView view, Bundle bundle) {
//
// }
//
// @Override
// public void onDestroy(MyView view, boolean changingConfigurations) {
//
// }
//
// @Override
// public void onActivityResult(MyView view, int requestCode, int resultCode, Intent data) {
//
// }
//
// @Override public void onViewCreated(MyView view, Bundle savedInstanceState) {
//
// }
//
// @Override public void onDestroyView(MyView view) {
//
// }
// }
//
// Path: test-data-lib/src/main/java/com/test/MyView.java
// public interface MyView {
// }
//
// Path: lifecyclebinder-api/src/main/java/it/codingjam/lifecyclebinder/LifeCycleAware.java
// public interface LifeCycleAware<T> {
// void onCreate(T view, Bundle savedInstanceState, Intent intent, Bundle arguments);
//
// void onStart(T view);
//
// void onResume(T view);
//
// boolean hasOptionsMenu(T view);
//
// void onCreateOptionsMenu(T view, Menu menu, MenuInflater inflater);
//
// boolean onOptionsItemSelected(T view, MenuItem item);
//
// void onPause(T view);
//
// void onStop(T view);
//
// void onSaveInstanceState(T view, Bundle bundle);
//
// void onDestroy(T view, boolean changingConfigurations);
//
// void onActivityResult(T view, int requestCode, int resultCode, Intent data);
//
// void onViewCreated(T view, Bundle savedInstanceState);
//
// void onDestroyView(T view);
// }
| import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import com.test.MyObject;
import com.test.MyView;
import it.codingjam.lifecyclebinder.BindLifeCycle;
import it.codingjam.lifecyclebinder.LifeCycleAware; |
@Override
public void onStop(T view) {
}
@Override
public void onSaveInstanceState(T view, Bundle bundle) {
}
@Override
public void onDestroy(T view, boolean changingConfigurations) {
}
@Override
public void onActivityResult(T view, int requestCode, int resultCode, Intent data) {
}
@Override public void onViewCreated(T view, Bundle savedInstanceState) {
}
@Override public void onDestroyView(T view) {
}
}
| // Path: lifecyclebinder-processor/src/test/java/com/test/MyObject.java
// public class MyObject implements LifeCycleAware<MyView> {
// @Override
// public void onCreate(MyView view, Bundle savedInstanceState, Intent intent, Bundle arguments) {
//
// }
//
// @Override
// public void onStart(MyView view) {
//
// }
//
// @Override
// public void onResume(MyView view) {
//
// }
//
// @Override
// public boolean hasOptionsMenu(MyView view) {
// return false;
// }
//
// @Override
// public void onCreateOptionsMenu(MyView view, Menu menu, MenuInflater inflater) {
//
// }
//
// @Override
// public boolean onOptionsItemSelected(MyView view, MenuItem item) {
// return false;
// }
//
// @Override
// public void onPause(MyView view) {
//
// }
//
// @Override
// public void onStop(MyView view) {
//
// }
//
// @Override
// public void onSaveInstanceState(MyView view, Bundle bundle) {
//
// }
//
// @Override
// public void onDestroy(MyView view, boolean changingConfigurations) {
//
// }
//
// @Override
// public void onActivityResult(MyView view, int requestCode, int resultCode, Intent data) {
//
// }
//
// @Override public void onViewCreated(MyView view, Bundle savedInstanceState) {
//
// }
//
// @Override public void onDestroyView(MyView view) {
//
// }
// }
//
// Path: test-data-lib/src/main/java/com/test/MyView.java
// public interface MyView {
// }
//
// Path: lifecyclebinder-api/src/main/java/it/codingjam/lifecyclebinder/LifeCycleAware.java
// public interface LifeCycleAware<T> {
// void onCreate(T view, Bundle savedInstanceState, Intent intent, Bundle arguments);
//
// void onStart(T view);
//
// void onResume(T view);
//
// boolean hasOptionsMenu(T view);
//
// void onCreateOptionsMenu(T view, Menu menu, MenuInflater inflater);
//
// boolean onOptionsItemSelected(T view, MenuItem item);
//
// void onPause(T view);
//
// void onStop(T view);
//
// void onSaveInstanceState(T view, Bundle bundle);
//
// void onDestroy(T view, boolean changingConfigurations);
//
// void onActivityResult(T view, int requestCode, int resultCode, Intent data);
//
// void onViewCreated(T view, Bundle savedInstanceState);
//
// void onDestroyView(T view);
// }
// Path: test-data-lib/src/main/java/com/test/objectWithGenericBaseClass/MyObjectWithGenericBaseClass.java
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import com.test.MyObject;
import com.test.MyView;
import it.codingjam.lifecyclebinder.BindLifeCycle;
import it.codingjam.lifecyclebinder.LifeCycleAware;
@Override
public void onStop(T view) {
}
@Override
public void onSaveInstanceState(T view, Bundle bundle) {
}
@Override
public void onDestroy(T view, boolean changingConfigurations) {
}
@Override
public void onActivityResult(T view, int requestCode, int resultCode, Intent data) {
}
@Override public void onViewCreated(T view, Bundle savedInstanceState) {
}
@Override public void onDestroyView(T view) {
}
}
| public class MyObjectWithGenericBaseClass extends MyGenericBaseClass<MyView> { |
fabioCollini/LifeCycleBinder | test-data-lib/src/main/java/com/test/objectWithGenericBaseClass/MyObjectWithGenericBaseClass.java | // Path: lifecyclebinder-processor/src/test/java/com/test/MyObject.java
// public class MyObject implements LifeCycleAware<MyView> {
// @Override
// public void onCreate(MyView view, Bundle savedInstanceState, Intent intent, Bundle arguments) {
//
// }
//
// @Override
// public void onStart(MyView view) {
//
// }
//
// @Override
// public void onResume(MyView view) {
//
// }
//
// @Override
// public boolean hasOptionsMenu(MyView view) {
// return false;
// }
//
// @Override
// public void onCreateOptionsMenu(MyView view, Menu menu, MenuInflater inflater) {
//
// }
//
// @Override
// public boolean onOptionsItemSelected(MyView view, MenuItem item) {
// return false;
// }
//
// @Override
// public void onPause(MyView view) {
//
// }
//
// @Override
// public void onStop(MyView view) {
//
// }
//
// @Override
// public void onSaveInstanceState(MyView view, Bundle bundle) {
//
// }
//
// @Override
// public void onDestroy(MyView view, boolean changingConfigurations) {
//
// }
//
// @Override
// public void onActivityResult(MyView view, int requestCode, int resultCode, Intent data) {
//
// }
//
// @Override public void onViewCreated(MyView view, Bundle savedInstanceState) {
//
// }
//
// @Override public void onDestroyView(MyView view) {
//
// }
// }
//
// Path: test-data-lib/src/main/java/com/test/MyView.java
// public interface MyView {
// }
//
// Path: lifecyclebinder-api/src/main/java/it/codingjam/lifecyclebinder/LifeCycleAware.java
// public interface LifeCycleAware<T> {
// void onCreate(T view, Bundle savedInstanceState, Intent intent, Bundle arguments);
//
// void onStart(T view);
//
// void onResume(T view);
//
// boolean hasOptionsMenu(T view);
//
// void onCreateOptionsMenu(T view, Menu menu, MenuInflater inflater);
//
// boolean onOptionsItemSelected(T view, MenuItem item);
//
// void onPause(T view);
//
// void onStop(T view);
//
// void onSaveInstanceState(T view, Bundle bundle);
//
// void onDestroy(T view, boolean changingConfigurations);
//
// void onActivityResult(T view, int requestCode, int resultCode, Intent data);
//
// void onViewCreated(T view, Bundle savedInstanceState);
//
// void onDestroyView(T view);
// }
| import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import com.test.MyObject;
import com.test.MyView;
import it.codingjam.lifecyclebinder.BindLifeCycle;
import it.codingjam.lifecyclebinder.LifeCycleAware; | public void onStop(T view) {
}
@Override
public void onSaveInstanceState(T view, Bundle bundle) {
}
@Override
public void onDestroy(T view, boolean changingConfigurations) {
}
@Override
public void onActivityResult(T view, int requestCode, int resultCode, Intent data) {
}
@Override public void onViewCreated(T view, Bundle savedInstanceState) {
}
@Override public void onDestroyView(T view) {
}
}
public class MyObjectWithGenericBaseClass extends MyGenericBaseClass<MyView> {
@BindLifeCycle | // Path: lifecyclebinder-processor/src/test/java/com/test/MyObject.java
// public class MyObject implements LifeCycleAware<MyView> {
// @Override
// public void onCreate(MyView view, Bundle savedInstanceState, Intent intent, Bundle arguments) {
//
// }
//
// @Override
// public void onStart(MyView view) {
//
// }
//
// @Override
// public void onResume(MyView view) {
//
// }
//
// @Override
// public boolean hasOptionsMenu(MyView view) {
// return false;
// }
//
// @Override
// public void onCreateOptionsMenu(MyView view, Menu menu, MenuInflater inflater) {
//
// }
//
// @Override
// public boolean onOptionsItemSelected(MyView view, MenuItem item) {
// return false;
// }
//
// @Override
// public void onPause(MyView view) {
//
// }
//
// @Override
// public void onStop(MyView view) {
//
// }
//
// @Override
// public void onSaveInstanceState(MyView view, Bundle bundle) {
//
// }
//
// @Override
// public void onDestroy(MyView view, boolean changingConfigurations) {
//
// }
//
// @Override
// public void onActivityResult(MyView view, int requestCode, int resultCode, Intent data) {
//
// }
//
// @Override public void onViewCreated(MyView view, Bundle savedInstanceState) {
//
// }
//
// @Override public void onDestroyView(MyView view) {
//
// }
// }
//
// Path: test-data-lib/src/main/java/com/test/MyView.java
// public interface MyView {
// }
//
// Path: lifecyclebinder-api/src/main/java/it/codingjam/lifecyclebinder/LifeCycleAware.java
// public interface LifeCycleAware<T> {
// void onCreate(T view, Bundle savedInstanceState, Intent intent, Bundle arguments);
//
// void onStart(T view);
//
// void onResume(T view);
//
// boolean hasOptionsMenu(T view);
//
// void onCreateOptionsMenu(T view, Menu menu, MenuInflater inflater);
//
// boolean onOptionsItemSelected(T view, MenuItem item);
//
// void onPause(T view);
//
// void onStop(T view);
//
// void onSaveInstanceState(T view, Bundle bundle);
//
// void onDestroy(T view, boolean changingConfigurations);
//
// void onActivityResult(T view, int requestCode, int resultCode, Intent data);
//
// void onViewCreated(T view, Bundle savedInstanceState);
//
// void onDestroyView(T view);
// }
// Path: test-data-lib/src/main/java/com/test/objectWithGenericBaseClass/MyObjectWithGenericBaseClass.java
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import com.test.MyObject;
import com.test.MyView;
import it.codingjam.lifecyclebinder.BindLifeCycle;
import it.codingjam.lifecyclebinder.LifeCycleAware;
public void onStop(T view) {
}
@Override
public void onSaveInstanceState(T view, Bundle bundle) {
}
@Override
public void onDestroy(T view, boolean changingConfigurations) {
}
@Override
public void onActivityResult(T view, int requestCode, int resultCode, Intent data) {
}
@Override public void onViewCreated(T view, Bundle savedInstanceState) {
}
@Override public void onDestroyView(T view) {
}
}
public class MyObjectWithGenericBaseClass extends MyGenericBaseClass<MyView> {
@BindLifeCycle | MyObject myObject; |
fabioCollini/LifeCycleBinder | test-data-lib/src/main/java/com/test/myActivityEvents/MyObjectWithEvents$LifeCycleBinder.java | // Path: test-data-lib/src/main/java/com/test/MyView.java
// public interface MyView {
// }
//
// Path: lifecyclebinder-api/src/main/java/it/codingjam/lifecyclebinder/DefaultLifeCycleAware.java
// public class DefaultLifeCycleAware<T> implements LifeCycleAware<T> {
// @Override
// public void onCreate(T view, Bundle savedInstanceState, Intent intent, Bundle arguments) {
// }
//
// @Override
// public void onStart(T view) {
// }
//
// @Override
// public void onResume(T view) {
// }
//
// @Override
// public boolean hasOptionsMenu(T view) {
// return false;
// }
//
// @Override
// public void onCreateOptionsMenu(T view, Menu menu, MenuInflater inflater) {
// }
//
// @Override
// public boolean onOptionsItemSelected(T view, MenuItem item) {
// return false;
// }
//
// @Override
// public void onPause(T view) {
// }
//
// @Override
// public void onStop(T view) {
// }
//
// @Override
// public void onSaveInstanceState(T view, Bundle bundle) {
// }
//
// @Override
// public void onDestroy(T view, boolean changingConfigurations) {
// }
//
// @Override
// public void onActivityResult(T view, int requestCode, int resultCode, Intent data) {
// }
//
// @Override public void onViewCreated(T view, Bundle savedInstanceState) {
// }
//
// @Override public void onDestroyView(T view) {
// }
// }
//
// Path: lifecyclebinder-api/src/main/java/it/codingjam/lifecyclebinder/LifeCycleAwareCollector.java
// public interface LifeCycleAwareCollector {
// <R> R addRetainedFactory(String key, Callable<R> factory, boolean addInLifeCycleAwareList);
//
// void addLifeCycleAware(LifeCycleAware<?> lifeCycleAware);
//
// <R> R getOrCreate(R lifeCycleAware, String key, Callable<R> factory);
// }
| import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import com.test.MyView;
import it.codingjam.lifecyclebinder.DefaultLifeCycleAware;
import it.codingjam.lifecyclebinder.LifeCycleAwareCollector; | package com.test.myActivityEvents;
public class MyObjectWithEvents$LifeCycleBinder {
public static MyObjectWithEvents bind(LifeCycleAwareCollector collector, final MyObjectWithEvents lifeCycleAware, boolean addInList) {
if (addInList) { | // Path: test-data-lib/src/main/java/com/test/MyView.java
// public interface MyView {
// }
//
// Path: lifecyclebinder-api/src/main/java/it/codingjam/lifecyclebinder/DefaultLifeCycleAware.java
// public class DefaultLifeCycleAware<T> implements LifeCycleAware<T> {
// @Override
// public void onCreate(T view, Bundle savedInstanceState, Intent intent, Bundle arguments) {
// }
//
// @Override
// public void onStart(T view) {
// }
//
// @Override
// public void onResume(T view) {
// }
//
// @Override
// public boolean hasOptionsMenu(T view) {
// return false;
// }
//
// @Override
// public void onCreateOptionsMenu(T view, Menu menu, MenuInflater inflater) {
// }
//
// @Override
// public boolean onOptionsItemSelected(T view, MenuItem item) {
// return false;
// }
//
// @Override
// public void onPause(T view) {
// }
//
// @Override
// public void onStop(T view) {
// }
//
// @Override
// public void onSaveInstanceState(T view, Bundle bundle) {
// }
//
// @Override
// public void onDestroy(T view, boolean changingConfigurations) {
// }
//
// @Override
// public void onActivityResult(T view, int requestCode, int resultCode, Intent data) {
// }
//
// @Override public void onViewCreated(T view, Bundle savedInstanceState) {
// }
//
// @Override public void onDestroyView(T view) {
// }
// }
//
// Path: lifecyclebinder-api/src/main/java/it/codingjam/lifecyclebinder/LifeCycleAwareCollector.java
// public interface LifeCycleAwareCollector {
// <R> R addRetainedFactory(String key, Callable<R> factory, boolean addInLifeCycleAwareList);
//
// void addLifeCycleAware(LifeCycleAware<?> lifeCycleAware);
//
// <R> R getOrCreate(R lifeCycleAware, String key, Callable<R> factory);
// }
// Path: test-data-lib/src/main/java/com/test/myActivityEvents/MyObjectWithEvents$LifeCycleBinder.java
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import com.test.MyView;
import it.codingjam.lifecyclebinder.DefaultLifeCycleAware;
import it.codingjam.lifecyclebinder.LifeCycleAwareCollector;
package com.test.myActivityEvents;
public class MyObjectWithEvents$LifeCycleBinder {
public static MyObjectWithEvents bind(LifeCycleAwareCollector collector, final MyObjectWithEvents lifeCycleAware, boolean addInList) {
if (addInList) { | collector.addLifeCycleAware(new DefaultLifeCycleAware<MyView>() { |
fabioCollini/LifeCycleBinder | test-data-lib/src/main/java/com/test/myActivityEvents/MyObjectWithEvents$LifeCycleBinder.java | // Path: test-data-lib/src/main/java/com/test/MyView.java
// public interface MyView {
// }
//
// Path: lifecyclebinder-api/src/main/java/it/codingjam/lifecyclebinder/DefaultLifeCycleAware.java
// public class DefaultLifeCycleAware<T> implements LifeCycleAware<T> {
// @Override
// public void onCreate(T view, Bundle savedInstanceState, Intent intent, Bundle arguments) {
// }
//
// @Override
// public void onStart(T view) {
// }
//
// @Override
// public void onResume(T view) {
// }
//
// @Override
// public boolean hasOptionsMenu(T view) {
// return false;
// }
//
// @Override
// public void onCreateOptionsMenu(T view, Menu menu, MenuInflater inflater) {
// }
//
// @Override
// public boolean onOptionsItemSelected(T view, MenuItem item) {
// return false;
// }
//
// @Override
// public void onPause(T view) {
// }
//
// @Override
// public void onStop(T view) {
// }
//
// @Override
// public void onSaveInstanceState(T view, Bundle bundle) {
// }
//
// @Override
// public void onDestroy(T view, boolean changingConfigurations) {
// }
//
// @Override
// public void onActivityResult(T view, int requestCode, int resultCode, Intent data) {
// }
//
// @Override public void onViewCreated(T view, Bundle savedInstanceState) {
// }
//
// @Override public void onDestroyView(T view) {
// }
// }
//
// Path: lifecyclebinder-api/src/main/java/it/codingjam/lifecyclebinder/LifeCycleAwareCollector.java
// public interface LifeCycleAwareCollector {
// <R> R addRetainedFactory(String key, Callable<R> factory, boolean addInLifeCycleAwareList);
//
// void addLifeCycleAware(LifeCycleAware<?> lifeCycleAware);
//
// <R> R getOrCreate(R lifeCycleAware, String key, Callable<R> factory);
// }
| import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import com.test.MyView;
import it.codingjam.lifecyclebinder.DefaultLifeCycleAware;
import it.codingjam.lifecyclebinder.LifeCycleAwareCollector; | package com.test.myActivityEvents;
public class MyObjectWithEvents$LifeCycleBinder {
public static MyObjectWithEvents bind(LifeCycleAwareCollector collector, final MyObjectWithEvents lifeCycleAware, boolean addInList) {
if (addInList) { | // Path: test-data-lib/src/main/java/com/test/MyView.java
// public interface MyView {
// }
//
// Path: lifecyclebinder-api/src/main/java/it/codingjam/lifecyclebinder/DefaultLifeCycleAware.java
// public class DefaultLifeCycleAware<T> implements LifeCycleAware<T> {
// @Override
// public void onCreate(T view, Bundle savedInstanceState, Intent intent, Bundle arguments) {
// }
//
// @Override
// public void onStart(T view) {
// }
//
// @Override
// public void onResume(T view) {
// }
//
// @Override
// public boolean hasOptionsMenu(T view) {
// return false;
// }
//
// @Override
// public void onCreateOptionsMenu(T view, Menu menu, MenuInflater inflater) {
// }
//
// @Override
// public boolean onOptionsItemSelected(T view, MenuItem item) {
// return false;
// }
//
// @Override
// public void onPause(T view) {
// }
//
// @Override
// public void onStop(T view) {
// }
//
// @Override
// public void onSaveInstanceState(T view, Bundle bundle) {
// }
//
// @Override
// public void onDestroy(T view, boolean changingConfigurations) {
// }
//
// @Override
// public void onActivityResult(T view, int requestCode, int resultCode, Intent data) {
// }
//
// @Override public void onViewCreated(T view, Bundle savedInstanceState) {
// }
//
// @Override public void onDestroyView(T view) {
// }
// }
//
// Path: lifecyclebinder-api/src/main/java/it/codingjam/lifecyclebinder/LifeCycleAwareCollector.java
// public interface LifeCycleAwareCollector {
// <R> R addRetainedFactory(String key, Callable<R> factory, boolean addInLifeCycleAwareList);
//
// void addLifeCycleAware(LifeCycleAware<?> lifeCycleAware);
//
// <R> R getOrCreate(R lifeCycleAware, String key, Callable<R> factory);
// }
// Path: test-data-lib/src/main/java/com/test/myActivityEvents/MyObjectWithEvents$LifeCycleBinder.java
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import com.test.MyView;
import it.codingjam.lifecyclebinder.DefaultLifeCycleAware;
import it.codingjam.lifecyclebinder.LifeCycleAwareCollector;
package com.test.myActivityEvents;
public class MyObjectWithEvents$LifeCycleBinder {
public static MyObjectWithEvents bind(LifeCycleAwareCollector collector, final MyObjectWithEvents lifeCycleAware, boolean addInList) {
if (addInList) { | collector.addLifeCycleAware(new DefaultLifeCycleAware<MyView>() { |
fabioCollini/LifeCycleBinder | lifecyclebinder-processor/src/main/java/it/codingjam/lifecyclebinder/data/EventMethodElement.java | // Path: lifecyclebinder-processor/src/main/java/it/codingjam/lifecyclebinder/EventMethodDefinition.java
// public class EventMethodDefinition {
// public static final EnumMap<LifeCycleEvent, EventMethodDefinition> EVENTS = createMap();
//
// private static EnumMap<LifeCycleEvent, EventMethodDefinition> createMap() {
// EnumMap<LifeCycleEvent, EventMethodDefinition> ret = new EnumMap<>(LifeCycleEvent.class);
//
// ClassName bundle = bestGuess("android.os.Bundle");
// ClassName intent = bestGuess("android.content.Intent");
// ClassName menu = bestGuess("android.view.Menu");
// ClassName menuInflater = bestGuess("android.view.MenuInflater");
// ClassName menuItem = bestGuess("android.view.MenuItem");
//
// ret.put(CREATE, voidMethod("onCreate", bundle, intent, bundle));
// ret.put(START, voidMethod("onStart"));
// ret.put(RESUME, voidMethod("onResume"));
// ret.put(HAS_OPTION_MENU, booleanMethod("hasOptionsMenu"));
// ret.put(CREATE_OPTION_MENU, voidMethod("onCreateOptionsMenu", menu, menuInflater));
// ret.put(OPTION_ITEM_SELECTED, booleanMethod("onOptionsItemSelected", menuItem));
// ret.put(PAUSE, voidMethod("onPause"));
// ret.put(STOP, voidMethod("onStop"));
// ret.put(SAVE_INSTANCE_STATE, voidMethod("onSaveInstanceState", bundle));
// ret.put(DESTROY, voidMethod("onDestroy", BOOLEAN));
// ret.put(ACTIVITY_RESULT, voidMethod("onActivityResult", INT, INT, intent));
// ret.put(VIEW_CREATED, voidMethod("onViewCreated", bundle));
// ret.put(DESTROY_VIEW, voidMethod("onDestroyView"));
//
// return ret;
// }
//
// public final String name;
//
// public final TypeName returnType;
//
// public final TypeName[] parameterTypes;
//
// private EventMethodDefinition(String name, TypeName returnType, TypeName... parameterTypes) {
// this.name = name;
// this.parameterTypes = parameterTypes;
// this.returnType = returnType;
// }
//
// private static EventMethodDefinition voidMethod(String name, TypeName... parameterTypes) {
// return new EventMethodDefinition(name, null, parameterTypes);
// }
//
// private static EventMethodDefinition booleanMethod(String name, TypeName... parameterTypes) {
// return new EventMethodDefinition(name, ClassName.BOOLEAN, parameterTypes);
// }
// }
//
// Path: lifecyclebinder-api/src/main/java/it/codingjam/lifecyclebinder/LifeCycleEvent.java
// public enum LifeCycleEvent {
// CREATE, START, RESUME, PAUSE, STOP, DESTROY, SAVE_INSTANCE_STATE, ACTIVITY_RESULT, HAS_OPTION_MENU, CREATE_OPTION_MENU, OPTION_ITEM_SELECTED, VIEW_CREATED, DESTROY_VIEW;
// }
| import com.squareup.javapoet.ClassName;
import com.squareup.javapoet.MethodSpec;
import com.squareup.javapoet.TypeName;
import it.codingjam.lifecyclebinder.BindEvent;
import it.codingjam.lifecyclebinder.EventMethodDefinition;
import it.codingjam.lifecyclebinder.LifeCycleEvent;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import javax.lang.model.element.ExecutableElement;
import javax.lang.model.element.VariableElement; | package it.codingjam.lifecyclebinder.data;
public class EventMethodElement {
private static final ClassName EVENT_CLASS_NAME = ClassName.get(LifeCycleEvent.class);
public final ExecutableElement element;
public final LifeCycleEvent[] events;
public final TypeName viewTypeName;
public EventMethodElement(ExecutableElement element) {
this.element = element;
events = element.getAnnotation(BindEvent.class).value();
viewTypeName = retrieveViewTypeName(element);
}
private TypeName retrieveViewTypeName(ExecutableElement element) {
for (LifeCycleEvent lifeCycleEvent : events) { | // Path: lifecyclebinder-processor/src/main/java/it/codingjam/lifecyclebinder/EventMethodDefinition.java
// public class EventMethodDefinition {
// public static final EnumMap<LifeCycleEvent, EventMethodDefinition> EVENTS = createMap();
//
// private static EnumMap<LifeCycleEvent, EventMethodDefinition> createMap() {
// EnumMap<LifeCycleEvent, EventMethodDefinition> ret = new EnumMap<>(LifeCycleEvent.class);
//
// ClassName bundle = bestGuess("android.os.Bundle");
// ClassName intent = bestGuess("android.content.Intent");
// ClassName menu = bestGuess("android.view.Menu");
// ClassName menuInflater = bestGuess("android.view.MenuInflater");
// ClassName menuItem = bestGuess("android.view.MenuItem");
//
// ret.put(CREATE, voidMethod("onCreate", bundle, intent, bundle));
// ret.put(START, voidMethod("onStart"));
// ret.put(RESUME, voidMethod("onResume"));
// ret.put(HAS_OPTION_MENU, booleanMethod("hasOptionsMenu"));
// ret.put(CREATE_OPTION_MENU, voidMethod("onCreateOptionsMenu", menu, menuInflater));
// ret.put(OPTION_ITEM_SELECTED, booleanMethod("onOptionsItemSelected", menuItem));
// ret.put(PAUSE, voidMethod("onPause"));
// ret.put(STOP, voidMethod("onStop"));
// ret.put(SAVE_INSTANCE_STATE, voidMethod("onSaveInstanceState", bundle));
// ret.put(DESTROY, voidMethod("onDestroy", BOOLEAN));
// ret.put(ACTIVITY_RESULT, voidMethod("onActivityResult", INT, INT, intent));
// ret.put(VIEW_CREATED, voidMethod("onViewCreated", bundle));
// ret.put(DESTROY_VIEW, voidMethod("onDestroyView"));
//
// return ret;
// }
//
// public final String name;
//
// public final TypeName returnType;
//
// public final TypeName[] parameterTypes;
//
// private EventMethodDefinition(String name, TypeName returnType, TypeName... parameterTypes) {
// this.name = name;
// this.parameterTypes = parameterTypes;
// this.returnType = returnType;
// }
//
// private static EventMethodDefinition voidMethod(String name, TypeName... parameterTypes) {
// return new EventMethodDefinition(name, null, parameterTypes);
// }
//
// private static EventMethodDefinition booleanMethod(String name, TypeName... parameterTypes) {
// return new EventMethodDefinition(name, ClassName.BOOLEAN, parameterTypes);
// }
// }
//
// Path: lifecyclebinder-api/src/main/java/it/codingjam/lifecyclebinder/LifeCycleEvent.java
// public enum LifeCycleEvent {
// CREATE, START, RESUME, PAUSE, STOP, DESTROY, SAVE_INSTANCE_STATE, ACTIVITY_RESULT, HAS_OPTION_MENU, CREATE_OPTION_MENU, OPTION_ITEM_SELECTED, VIEW_CREATED, DESTROY_VIEW;
// }
// Path: lifecyclebinder-processor/src/main/java/it/codingjam/lifecyclebinder/data/EventMethodElement.java
import com.squareup.javapoet.ClassName;
import com.squareup.javapoet.MethodSpec;
import com.squareup.javapoet.TypeName;
import it.codingjam.lifecyclebinder.BindEvent;
import it.codingjam.lifecyclebinder.EventMethodDefinition;
import it.codingjam.lifecyclebinder.LifeCycleEvent;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import javax.lang.model.element.ExecutableElement;
import javax.lang.model.element.VariableElement;
package it.codingjam.lifecyclebinder.data;
public class EventMethodElement {
private static final ClassName EVENT_CLASS_NAME = ClassName.get(LifeCycleEvent.class);
public final ExecutableElement element;
public final LifeCycleEvent[] events;
public final TypeName viewTypeName;
public EventMethodElement(ExecutableElement element) {
this.element = element;
events = element.getAnnotation(BindEvent.class).value();
viewTypeName = retrieveViewTypeName(element);
}
private TypeName retrieveViewTypeName(ExecutableElement element) {
for (LifeCycleEvent lifeCycleEvent : events) { | EventMethodDefinition definition = EventMethodDefinition.EVENTS.get(lifeCycleEvent); |
fabioCollini/LifeCycleBinder | test-data-lib/src/main/java/com/test/activityWithBaseClass/MyActivityWithBaseClass.java | // Path: lifecyclebinder-processor/src/test/java/com/test/MyObject.java
// public class MyObject implements LifeCycleAware<MyView> {
// @Override
// public void onCreate(MyView view, Bundle savedInstanceState, Intent intent, Bundle arguments) {
//
// }
//
// @Override
// public void onStart(MyView view) {
//
// }
//
// @Override
// public void onResume(MyView view) {
//
// }
//
// @Override
// public boolean hasOptionsMenu(MyView view) {
// return false;
// }
//
// @Override
// public void onCreateOptionsMenu(MyView view, Menu menu, MenuInflater inflater) {
//
// }
//
// @Override
// public boolean onOptionsItemSelected(MyView view, MenuItem item) {
// return false;
// }
//
// @Override
// public void onPause(MyView view) {
//
// }
//
// @Override
// public void onStop(MyView view) {
//
// }
//
// @Override
// public void onSaveInstanceState(MyView view, Bundle bundle) {
//
// }
//
// @Override
// public void onDestroy(MyView view, boolean changingConfigurations) {
//
// }
//
// @Override
// public void onActivityResult(MyView view, int requestCode, int resultCode, Intent data) {
//
// }
//
// @Override public void onViewCreated(MyView view, Bundle savedInstanceState) {
//
// }
//
// @Override public void onDestroyView(MyView view) {
//
// }
// }
//
// Path: test-data-lib/src/main/java/com/test/MyView.java
// public interface MyView {
// }
| import android.support.v4.app.FragmentActivity;
import com.test.MyObject;
import com.test.MyView;
import it.codingjam.lifecyclebinder.BindLifeCycle; | /*
* Copyright 2016 Fabio Collini.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.test.activityWithBaseClass;
class BaseClass extends FragmentActivity implements MyView {
@BindLifeCycle | // Path: lifecyclebinder-processor/src/test/java/com/test/MyObject.java
// public class MyObject implements LifeCycleAware<MyView> {
// @Override
// public void onCreate(MyView view, Bundle savedInstanceState, Intent intent, Bundle arguments) {
//
// }
//
// @Override
// public void onStart(MyView view) {
//
// }
//
// @Override
// public void onResume(MyView view) {
//
// }
//
// @Override
// public boolean hasOptionsMenu(MyView view) {
// return false;
// }
//
// @Override
// public void onCreateOptionsMenu(MyView view, Menu menu, MenuInflater inflater) {
//
// }
//
// @Override
// public boolean onOptionsItemSelected(MyView view, MenuItem item) {
// return false;
// }
//
// @Override
// public void onPause(MyView view) {
//
// }
//
// @Override
// public void onStop(MyView view) {
//
// }
//
// @Override
// public void onSaveInstanceState(MyView view, Bundle bundle) {
//
// }
//
// @Override
// public void onDestroy(MyView view, boolean changingConfigurations) {
//
// }
//
// @Override
// public void onActivityResult(MyView view, int requestCode, int resultCode, Intent data) {
//
// }
//
// @Override public void onViewCreated(MyView view, Bundle savedInstanceState) {
//
// }
//
// @Override public void onDestroyView(MyView view) {
//
// }
// }
//
// Path: test-data-lib/src/main/java/com/test/MyView.java
// public interface MyView {
// }
// Path: test-data-lib/src/main/java/com/test/activityWithBaseClass/MyActivityWithBaseClass.java
import android.support.v4.app.FragmentActivity;
import com.test.MyObject;
import com.test.MyView;
import it.codingjam.lifecyclebinder.BindLifeCycle;
/*
* Copyright 2016 Fabio Collini.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.test.activityWithBaseClass;
class BaseClass extends FragmentActivity implements MyView {
@BindLifeCycle | MyObject myBaseObject; |
fabioCollini/LifeCycleBinder | lifecyclebinder-demo-fragments/src/main/java/it/codingjam/lifecyclebinder/demo/MyFragment2.java | // Path: lifecyclebinder-lib/src/main/java/it/codingjam/lifecyclebinder/LifeCycleBinder.java
// public class LifeCycleBinder {
// public static void bind(Fragment fragment) {
// bind(fragment, fragment.getChildFragmentManager());
// }
//
// public static void bind(FragmentActivity activity) {
// bind(activity, activity.getSupportFragmentManager());
// }
//
// public static <T extends Fragment> void bind(T fragment, Class<?> objectBinderClass) {
// bind(fragment.getChildFragmentManager(), objectBinderClass);
// }
//
// public static <T extends FragmentActivity> void bind(T activity, Class<?> objectBinderClass) {
// bind(activity.getSupportFragmentManager(), objectBinderClass);
// }
//
// private static <T> void bind(T obj, FragmentManager fragmentManager) {
// LifeCycleBinderFragment<T> fragment = LifeCycleBinderFragment.get(fragmentManager);
// if (fragment == null) {
// Class<?> c = ReflectionUtils.getObjectBinderClass(obj);
// fragment = LifeCycleBinderFragment.createAndAdd(fragmentManager, c);
// }
// fragment.invokeOnCreate();
// }
//
// private static <T> void bind(FragmentManager fragmentManager, Class<?> objectBinderClass) {
// LifeCycleBinderFragment<T> fragment = LifeCycleBinderFragment.get(fragmentManager);
// if (fragment == null) {
// fragment = LifeCycleBinderFragment.createAndAdd(fragmentManager, objectBinderClass);
// }
// fragment.invokeOnCreate();
// }
//
// public static void startActivityForResult(FragmentActivity activity, Intent intent, int requestCode) {
// LifeCycleBinderFragment.get(activity.getSupportFragmentManager()).startActivityForResult(intent, requestCode);
// }
//
// public static void startActivityForResult(Fragment fragment, Intent intent, int requestCode) {
// LifeCycleBinderFragment.get(fragment.getChildFragmentManager()).startActivityForResult(intent, requestCode);
// }
// }
| import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import it.codingjam.lifecyclebinder.BindLifeCycle;
import it.codingjam.lifecyclebinder.LifeCycleBinder; | /*
* Copyright 2016 Fabio Collini.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package it.codingjam.lifecyclebinder.demo;
public class MyFragment2 extends Fragment {
@BindLifeCycle FragmentLogger fragmentLogger = new FragmentLogger("MyFragment2");
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState); | // Path: lifecyclebinder-lib/src/main/java/it/codingjam/lifecyclebinder/LifeCycleBinder.java
// public class LifeCycleBinder {
// public static void bind(Fragment fragment) {
// bind(fragment, fragment.getChildFragmentManager());
// }
//
// public static void bind(FragmentActivity activity) {
// bind(activity, activity.getSupportFragmentManager());
// }
//
// public static <T extends Fragment> void bind(T fragment, Class<?> objectBinderClass) {
// bind(fragment.getChildFragmentManager(), objectBinderClass);
// }
//
// public static <T extends FragmentActivity> void bind(T activity, Class<?> objectBinderClass) {
// bind(activity.getSupportFragmentManager(), objectBinderClass);
// }
//
// private static <T> void bind(T obj, FragmentManager fragmentManager) {
// LifeCycleBinderFragment<T> fragment = LifeCycleBinderFragment.get(fragmentManager);
// if (fragment == null) {
// Class<?> c = ReflectionUtils.getObjectBinderClass(obj);
// fragment = LifeCycleBinderFragment.createAndAdd(fragmentManager, c);
// }
// fragment.invokeOnCreate();
// }
//
// private static <T> void bind(FragmentManager fragmentManager, Class<?> objectBinderClass) {
// LifeCycleBinderFragment<T> fragment = LifeCycleBinderFragment.get(fragmentManager);
// if (fragment == null) {
// fragment = LifeCycleBinderFragment.createAndAdd(fragmentManager, objectBinderClass);
// }
// fragment.invokeOnCreate();
// }
//
// public static void startActivityForResult(FragmentActivity activity, Intent intent, int requestCode) {
// LifeCycleBinderFragment.get(activity.getSupportFragmentManager()).startActivityForResult(intent, requestCode);
// }
//
// public static void startActivityForResult(Fragment fragment, Intent intent, int requestCode) {
// LifeCycleBinderFragment.get(fragment.getChildFragmentManager()).startActivityForResult(intent, requestCode);
// }
// }
// Path: lifecyclebinder-demo-fragments/src/main/java/it/codingjam/lifecyclebinder/demo/MyFragment2.java
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import it.codingjam.lifecyclebinder.BindLifeCycle;
import it.codingjam.lifecyclebinder.LifeCycleBinder;
/*
* Copyright 2016 Fabio Collini.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package it.codingjam.lifecyclebinder.demo;
public class MyFragment2 extends Fragment {
@BindLifeCycle FragmentLogger fragmentLogger = new FragmentLogger("MyFragment2");
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState); | LifeCycleBinder.bind(this); |
fabioCollini/LifeCycleBinder | lifecyclebinder-processor/src/test/java/it/codingjam/lifecyclebinder/test/ProcessorEventsTest.java | // Path: lifecyclebinder-processor/src/test/java/it/codingjam/lifecyclebinder/test/FileLoader.java
// public static void check(String name) {
// check(name, name);
// }
| import org.junit.Test;
import static it.codingjam.lifecyclebinder.test.FileLoader.check; | /*
* Copyright 2016 Fabio Collini.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package it.codingjam.lifecyclebinder.test;
public class ProcessorEventsTest {
@Test public void testObjectWithEvents() throws Exception { | // Path: lifecyclebinder-processor/src/test/java/it/codingjam/lifecyclebinder/test/FileLoader.java
// public static void check(String name) {
// check(name, name);
// }
// Path: lifecyclebinder-processor/src/test/java/it/codingjam/lifecyclebinder/test/ProcessorEventsTest.java
import org.junit.Test;
import static it.codingjam.lifecyclebinder.test.FileLoader.check;
/*
* Copyright 2016 Fabio Collini.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package it.codingjam.lifecyclebinder.test;
public class ProcessorEventsTest {
@Test public void testObjectWithEvents() throws Exception { | check("com.test.MyObjectWithEvents"); |
fabioCollini/LifeCycleBinder | lifecyclebinder-demo-fragments/src/main/java/it/codingjam/lifecyclebinder/demo/MainActivity.java | // Path: lifecyclebinder-lib/src/main/java/it/codingjam/lifecyclebinder/LifeCycleBinder.java
// public class LifeCycleBinder {
// public static void bind(Fragment fragment) {
// bind(fragment, fragment.getChildFragmentManager());
// }
//
// public static void bind(FragmentActivity activity) {
// bind(activity, activity.getSupportFragmentManager());
// }
//
// public static <T extends Fragment> void bind(T fragment, Class<?> objectBinderClass) {
// bind(fragment.getChildFragmentManager(), objectBinderClass);
// }
//
// public static <T extends FragmentActivity> void bind(T activity, Class<?> objectBinderClass) {
// bind(activity.getSupportFragmentManager(), objectBinderClass);
// }
//
// private static <T> void bind(T obj, FragmentManager fragmentManager) {
// LifeCycleBinderFragment<T> fragment = LifeCycleBinderFragment.get(fragmentManager);
// if (fragment == null) {
// Class<?> c = ReflectionUtils.getObjectBinderClass(obj);
// fragment = LifeCycleBinderFragment.createAndAdd(fragmentManager, c);
// }
// fragment.invokeOnCreate();
// }
//
// private static <T> void bind(FragmentManager fragmentManager, Class<?> objectBinderClass) {
// LifeCycleBinderFragment<T> fragment = LifeCycleBinderFragment.get(fragmentManager);
// if (fragment == null) {
// fragment = LifeCycleBinderFragment.createAndAdd(fragmentManager, objectBinderClass);
// }
// fragment.invokeOnCreate();
// }
//
// public static void startActivityForResult(FragmentActivity activity, Intent intent, int requestCode) {
// LifeCycleBinderFragment.get(activity.getSupportFragmentManager()).startActivityForResult(intent, requestCode);
// }
//
// public static void startActivityForResult(Fragment fragment, Intent intent, int requestCode) {
// LifeCycleBinderFragment.get(fragment.getChildFragmentManager()).startActivityForResult(intent, requestCode);
// }
// }
| import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import it.codingjam.lifecyclebinder.BindLifeCycle;
import it.codingjam.lifecyclebinder.LifeCycleBinder; | /*
* Copyright 2016 Fabio Collini.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package it.codingjam.lifecyclebinder.demo;
public class MainActivity extends AppCompatActivity {
@BindLifeCycle ActivityLogger activityLogger = new ActivityLogger();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); | // Path: lifecyclebinder-lib/src/main/java/it/codingjam/lifecyclebinder/LifeCycleBinder.java
// public class LifeCycleBinder {
// public static void bind(Fragment fragment) {
// bind(fragment, fragment.getChildFragmentManager());
// }
//
// public static void bind(FragmentActivity activity) {
// bind(activity, activity.getSupportFragmentManager());
// }
//
// public static <T extends Fragment> void bind(T fragment, Class<?> objectBinderClass) {
// bind(fragment.getChildFragmentManager(), objectBinderClass);
// }
//
// public static <T extends FragmentActivity> void bind(T activity, Class<?> objectBinderClass) {
// bind(activity.getSupportFragmentManager(), objectBinderClass);
// }
//
// private static <T> void bind(T obj, FragmentManager fragmentManager) {
// LifeCycleBinderFragment<T> fragment = LifeCycleBinderFragment.get(fragmentManager);
// if (fragment == null) {
// Class<?> c = ReflectionUtils.getObjectBinderClass(obj);
// fragment = LifeCycleBinderFragment.createAndAdd(fragmentManager, c);
// }
// fragment.invokeOnCreate();
// }
//
// private static <T> void bind(FragmentManager fragmentManager, Class<?> objectBinderClass) {
// LifeCycleBinderFragment<T> fragment = LifeCycleBinderFragment.get(fragmentManager);
// if (fragment == null) {
// fragment = LifeCycleBinderFragment.createAndAdd(fragmentManager, objectBinderClass);
// }
// fragment.invokeOnCreate();
// }
//
// public static void startActivityForResult(FragmentActivity activity, Intent intent, int requestCode) {
// LifeCycleBinderFragment.get(activity.getSupportFragmentManager()).startActivityForResult(intent, requestCode);
// }
//
// public static void startActivityForResult(Fragment fragment, Intent intent, int requestCode) {
// LifeCycleBinderFragment.get(fragment.getChildFragmentManager()).startActivityForResult(intent, requestCode);
// }
// }
// Path: lifecyclebinder-demo-fragments/src/main/java/it/codingjam/lifecyclebinder/demo/MainActivity.java
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import it.codingjam.lifecyclebinder.BindLifeCycle;
import it.codingjam.lifecyclebinder.LifeCycleBinder;
/*
* Copyright 2016 Fabio Collini.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package it.codingjam.lifecyclebinder.demo;
public class MainActivity extends AppCompatActivity {
@BindLifeCycle ActivityLogger activityLogger = new ActivityLogger();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); | LifeCycleBinder.bind(this); |
fabioCollini/LifeCycleBinder | test-data-lib/src/main/java/com/test/retained/ActivityWithRetainedGenericAndField$LifeCycleBinder.java | // Path: test-data-lib/src/main/java/com/test/MyObjectGeneric$LifeCycleBinder.java
// public class MyObjectGeneric$LifeCycleBinder {
//
// public static MyObjectGeneric bind(LifeCycleAwareCollector collector, MyObjectGeneric lifeCycleAware, boolean addInList) {
// if (addInList) {
// collector.addLifeCycleAware(lifeCycleAware);
// }
// return lifeCycleAware;
// }
// }
//
// Path: lifecyclebinder-api/src/main/java/it/codingjam/lifecyclebinder/LifeCycleAwareCollector.java
// public interface LifeCycleAwareCollector {
// <R> R addRetainedFactory(String key, Callable<R> factory, boolean addInLifeCycleAwareList);
//
// void addLifeCycleAware(LifeCycleAware<?> lifeCycleAware);
//
// <R> R getOrCreate(R lifeCycleAware, String key, Callable<R> factory);
// }
| import com.test.MyObjectGeneric$LifeCycleBinder;
import it.codingjam.lifecyclebinder.LifeCycleAwareCollector; | /*
* Copyright 2016 Fabio Collini.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.test.retained;
public class ActivityWithRetainedGenericAndField$LifeCycleBinder {
public static void bind(LifeCycleAwareCollector collector, final ActivityWithRetainedGenericAndField view) { | // Path: test-data-lib/src/main/java/com/test/MyObjectGeneric$LifeCycleBinder.java
// public class MyObjectGeneric$LifeCycleBinder {
//
// public static MyObjectGeneric bind(LifeCycleAwareCollector collector, MyObjectGeneric lifeCycleAware, boolean addInList) {
// if (addInList) {
// collector.addLifeCycleAware(lifeCycleAware);
// }
// return lifeCycleAware;
// }
// }
//
// Path: lifecyclebinder-api/src/main/java/it/codingjam/lifecyclebinder/LifeCycleAwareCollector.java
// public interface LifeCycleAwareCollector {
// <R> R addRetainedFactory(String key, Callable<R> factory, boolean addInLifeCycleAwareList);
//
// void addLifeCycleAware(LifeCycleAware<?> lifeCycleAware);
//
// <R> R getOrCreate(R lifeCycleAware, String key, Callable<R> factory);
// }
// Path: test-data-lib/src/main/java/com/test/retained/ActivityWithRetainedGenericAndField$LifeCycleBinder.java
import com.test.MyObjectGeneric$LifeCycleBinder;
import it.codingjam.lifecyclebinder.LifeCycleAwareCollector;
/*
* Copyright 2016 Fabio Collini.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.test.retained;
public class ActivityWithRetainedGenericAndField$LifeCycleBinder {
public static void bind(LifeCycleAwareCollector collector, final ActivityWithRetainedGenericAndField view) { | view.myObjectGeneric = MyObjectGeneric$LifeCycleBinder.bind(collector, collector.getOrCreate(null, "myObjectProvider", view.myObjectProvider), true); |
fabioCollini/LifeCycleBinder | testapp/src/main/java/it/codingjam/lifecyclebinder/testapp/MySecondRetainedFragment.java | // Path: lifecyclebinder-lib/src/main/java/it/codingjam/lifecyclebinder/LifeCycleBinder.java
// public class LifeCycleBinder {
// public static void bind(Fragment fragment) {
// bind(fragment, fragment.getChildFragmentManager());
// }
//
// public static void bind(FragmentActivity activity) {
// bind(activity, activity.getSupportFragmentManager());
// }
//
// public static <T extends Fragment> void bind(T fragment, Class<?> objectBinderClass) {
// bind(fragment.getChildFragmentManager(), objectBinderClass);
// }
//
// public static <T extends FragmentActivity> void bind(T activity, Class<?> objectBinderClass) {
// bind(activity.getSupportFragmentManager(), objectBinderClass);
// }
//
// private static <T> void bind(T obj, FragmentManager fragmentManager) {
// LifeCycleBinderFragment<T> fragment = LifeCycleBinderFragment.get(fragmentManager);
// if (fragment == null) {
// Class<?> c = ReflectionUtils.getObjectBinderClass(obj);
// fragment = LifeCycleBinderFragment.createAndAdd(fragmentManager, c);
// }
// fragment.invokeOnCreate();
// }
//
// private static <T> void bind(FragmentManager fragmentManager, Class<?> objectBinderClass) {
// LifeCycleBinderFragment<T> fragment = LifeCycleBinderFragment.get(fragmentManager);
// if (fragment == null) {
// fragment = LifeCycleBinderFragment.createAndAdd(fragmentManager, objectBinderClass);
// }
// fragment.invokeOnCreate();
// }
//
// public static void startActivityForResult(FragmentActivity activity, Intent intent, int requestCode) {
// LifeCycleBinderFragment.get(activity.getSupportFragmentManager()).startActivityForResult(intent, requestCode);
// }
//
// public static void startActivityForResult(Fragment fragment, Intent intent, int requestCode) {
// LifeCycleBinderFragment.get(fragment.getChildFragmentManager()).startActivityForResult(intent, requestCode);
// }
// }
| import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import java.util.concurrent.Callable;
import it.codingjam.lifecyclebinder.LifeCycleBinder;
import it.codingjam.lifecyclebinder.RetainedObjectProvider; | /*
* Copyright 2016 Fabio Collini.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package it.codingjam.lifecyclebinder.testapp;
public class MySecondRetainedFragment extends Fragment {
@RetainedObjectProvider
public Callable<Logger> logger = new Callable<Logger>() {
@Override
public Logger call() throws Exception {
return new Logger("MySecondRetainedFragment");
}
};
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState); | // Path: lifecyclebinder-lib/src/main/java/it/codingjam/lifecyclebinder/LifeCycleBinder.java
// public class LifeCycleBinder {
// public static void bind(Fragment fragment) {
// bind(fragment, fragment.getChildFragmentManager());
// }
//
// public static void bind(FragmentActivity activity) {
// bind(activity, activity.getSupportFragmentManager());
// }
//
// public static <T extends Fragment> void bind(T fragment, Class<?> objectBinderClass) {
// bind(fragment.getChildFragmentManager(), objectBinderClass);
// }
//
// public static <T extends FragmentActivity> void bind(T activity, Class<?> objectBinderClass) {
// bind(activity.getSupportFragmentManager(), objectBinderClass);
// }
//
// private static <T> void bind(T obj, FragmentManager fragmentManager) {
// LifeCycleBinderFragment<T> fragment = LifeCycleBinderFragment.get(fragmentManager);
// if (fragment == null) {
// Class<?> c = ReflectionUtils.getObjectBinderClass(obj);
// fragment = LifeCycleBinderFragment.createAndAdd(fragmentManager, c);
// }
// fragment.invokeOnCreate();
// }
//
// private static <T> void bind(FragmentManager fragmentManager, Class<?> objectBinderClass) {
// LifeCycleBinderFragment<T> fragment = LifeCycleBinderFragment.get(fragmentManager);
// if (fragment == null) {
// fragment = LifeCycleBinderFragment.createAndAdd(fragmentManager, objectBinderClass);
// }
// fragment.invokeOnCreate();
// }
//
// public static void startActivityForResult(FragmentActivity activity, Intent intent, int requestCode) {
// LifeCycleBinderFragment.get(activity.getSupportFragmentManager()).startActivityForResult(intent, requestCode);
// }
//
// public static void startActivityForResult(Fragment fragment, Intent intent, int requestCode) {
// LifeCycleBinderFragment.get(fragment.getChildFragmentManager()).startActivityForResult(intent, requestCode);
// }
// }
// Path: testapp/src/main/java/it/codingjam/lifecyclebinder/testapp/MySecondRetainedFragment.java
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import java.util.concurrent.Callable;
import it.codingjam.lifecyclebinder.LifeCycleBinder;
import it.codingjam.lifecyclebinder.RetainedObjectProvider;
/*
* Copyright 2016 Fabio Collini.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package it.codingjam.lifecyclebinder.testapp;
public class MySecondRetainedFragment extends Fragment {
@RetainedObjectProvider
public Callable<Logger> logger = new Callable<Logger>() {
@Override
public Logger call() throws Exception {
return new Logger("MySecondRetainedFragment");
}
};
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState); | LifeCycleBinder.bind(this); |
fabioCollini/LifeCycleBinder | test-data-lib/src/main/java/com/test/retained/ActivityWithRetained2$LifeCycleBinder.java | // Path: test-data-lib/src/main/java/com/test/MyObject$LifeCycleBinder.java
// public class MyObject$LifeCycleBinder {
//
// public static MyObject bind(LifeCycleAwareCollector collector, MyObject lifeCycleAware, boolean addInList) {
// if (addInList) {
// collector.addLifeCycleAware(lifeCycleAware);
// }
// return lifeCycleAware;
// }
// }
//
// Path: lifecyclebinder-api/src/main/java/it/codingjam/lifecyclebinder/LifeCycleAwareCollector.java
// public interface LifeCycleAwareCollector {
// <R> R addRetainedFactory(String key, Callable<R> factory, boolean addInLifeCycleAwareList);
//
// void addLifeCycleAware(LifeCycleAware<?> lifeCycleAware);
//
// <R> R getOrCreate(R lifeCycleAware, String key, Callable<R> factory);
// }
| import com.test.MyObject$LifeCycleBinder;
import it.codingjam.lifecyclebinder.LifeCycleAwareCollector; | /*
* Copyright 2016 Fabio Collini.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.test.retained;
public class ActivityWithRetained2$LifeCycleBinder {
public static void bind(LifeCycleAwareCollector collector, final ActivityWithRetained2 view) { | // Path: test-data-lib/src/main/java/com/test/MyObject$LifeCycleBinder.java
// public class MyObject$LifeCycleBinder {
//
// public static MyObject bind(LifeCycleAwareCollector collector, MyObject lifeCycleAware, boolean addInList) {
// if (addInList) {
// collector.addLifeCycleAware(lifeCycleAware);
// }
// return lifeCycleAware;
// }
// }
//
// Path: lifecyclebinder-api/src/main/java/it/codingjam/lifecyclebinder/LifeCycleAwareCollector.java
// public interface LifeCycleAwareCollector {
// <R> R addRetainedFactory(String key, Callable<R> factory, boolean addInLifeCycleAwareList);
//
// void addLifeCycleAware(LifeCycleAware<?> lifeCycleAware);
//
// <R> R getOrCreate(R lifeCycleAware, String key, Callable<R> factory);
// }
// Path: test-data-lib/src/main/java/com/test/retained/ActivityWithRetained2$LifeCycleBinder.java
import com.test.MyObject$LifeCycleBinder;
import it.codingjam.lifecyclebinder.LifeCycleAwareCollector;
/*
* Copyright 2016 Fabio Collini.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.test.retained;
public class ActivityWithRetained2$LifeCycleBinder {
public static void bind(LifeCycleAwareCollector collector, final ActivityWithRetained2 view) { | MyObject$LifeCycleBinder.bind(collector, collector.getOrCreate(null, "myObject", view.myObject), true); |
fabioCollini/LifeCycleBinder | test-data-lib/src/main/java/com/test/retainedEvents/MyObjectWithEvents1$LifeCycleBinder.java | // Path: test-data-lib/src/main/java/com/test/MyView.java
// public interface MyView {
// }
//
// Path: lifecyclebinder-api/src/main/java/it/codingjam/lifecyclebinder/DefaultLifeCycleAware.java
// public class DefaultLifeCycleAware<T> implements LifeCycleAware<T> {
// @Override
// public void onCreate(T view, Bundle savedInstanceState, Intent intent, Bundle arguments) {
// }
//
// @Override
// public void onStart(T view) {
// }
//
// @Override
// public void onResume(T view) {
// }
//
// @Override
// public boolean hasOptionsMenu(T view) {
// return false;
// }
//
// @Override
// public void onCreateOptionsMenu(T view, Menu menu, MenuInflater inflater) {
// }
//
// @Override
// public boolean onOptionsItemSelected(T view, MenuItem item) {
// return false;
// }
//
// @Override
// public void onPause(T view) {
// }
//
// @Override
// public void onStop(T view) {
// }
//
// @Override
// public void onSaveInstanceState(T view, Bundle bundle) {
// }
//
// @Override
// public void onDestroy(T view, boolean changingConfigurations) {
// }
//
// @Override
// public void onActivityResult(T view, int requestCode, int resultCode, Intent data) {
// }
//
// @Override public void onViewCreated(T view, Bundle savedInstanceState) {
// }
//
// @Override public void onDestroyView(T view) {
// }
// }
//
// Path: lifecyclebinder-api/src/main/java/it/codingjam/lifecyclebinder/LifeCycleAwareCollector.java
// public interface LifeCycleAwareCollector {
// <R> R addRetainedFactory(String key, Callable<R> factory, boolean addInLifeCycleAwareList);
//
// void addLifeCycleAware(LifeCycleAware<?> lifeCycleAware);
//
// <R> R getOrCreate(R lifeCycleAware, String key, Callable<R> factory);
// }
| import android.content.Intent;
import android.os.Bundle;
import com.test.MyView;
import it.codingjam.lifecyclebinder.DefaultLifeCycleAware;
import it.codingjam.lifecyclebinder.LifeCycleAwareCollector; | package com.test.retainedEvents;
public class MyObjectWithEvents1$LifeCycleBinder {
public static MyObjectWithEvents1 bind(LifeCycleAwareCollector collector, final MyObjectWithEvents1 lifeCycleAware, boolean addInList) {
if (addInList) { | // Path: test-data-lib/src/main/java/com/test/MyView.java
// public interface MyView {
// }
//
// Path: lifecyclebinder-api/src/main/java/it/codingjam/lifecyclebinder/DefaultLifeCycleAware.java
// public class DefaultLifeCycleAware<T> implements LifeCycleAware<T> {
// @Override
// public void onCreate(T view, Bundle savedInstanceState, Intent intent, Bundle arguments) {
// }
//
// @Override
// public void onStart(T view) {
// }
//
// @Override
// public void onResume(T view) {
// }
//
// @Override
// public boolean hasOptionsMenu(T view) {
// return false;
// }
//
// @Override
// public void onCreateOptionsMenu(T view, Menu menu, MenuInflater inflater) {
// }
//
// @Override
// public boolean onOptionsItemSelected(T view, MenuItem item) {
// return false;
// }
//
// @Override
// public void onPause(T view) {
// }
//
// @Override
// public void onStop(T view) {
// }
//
// @Override
// public void onSaveInstanceState(T view, Bundle bundle) {
// }
//
// @Override
// public void onDestroy(T view, boolean changingConfigurations) {
// }
//
// @Override
// public void onActivityResult(T view, int requestCode, int resultCode, Intent data) {
// }
//
// @Override public void onViewCreated(T view, Bundle savedInstanceState) {
// }
//
// @Override public void onDestroyView(T view) {
// }
// }
//
// Path: lifecyclebinder-api/src/main/java/it/codingjam/lifecyclebinder/LifeCycleAwareCollector.java
// public interface LifeCycleAwareCollector {
// <R> R addRetainedFactory(String key, Callable<R> factory, boolean addInLifeCycleAwareList);
//
// void addLifeCycleAware(LifeCycleAware<?> lifeCycleAware);
//
// <R> R getOrCreate(R lifeCycleAware, String key, Callable<R> factory);
// }
// Path: test-data-lib/src/main/java/com/test/retainedEvents/MyObjectWithEvents1$LifeCycleBinder.java
import android.content.Intent;
import android.os.Bundle;
import com.test.MyView;
import it.codingjam.lifecyclebinder.DefaultLifeCycleAware;
import it.codingjam.lifecyclebinder.LifeCycleAwareCollector;
package com.test.retainedEvents;
public class MyObjectWithEvents1$LifeCycleBinder {
public static MyObjectWithEvents1 bind(LifeCycleAwareCollector collector, final MyObjectWithEvents1 lifeCycleAware, boolean addInList) {
if (addInList) { | collector.addLifeCycleAware(new DefaultLifeCycleAware<MyView>() { |
fabioCollini/LifeCycleBinder | test-data-lib/src/main/java/com/test/retainedEvents/MyObjectWithEvents1$LifeCycleBinder.java | // Path: test-data-lib/src/main/java/com/test/MyView.java
// public interface MyView {
// }
//
// Path: lifecyclebinder-api/src/main/java/it/codingjam/lifecyclebinder/DefaultLifeCycleAware.java
// public class DefaultLifeCycleAware<T> implements LifeCycleAware<T> {
// @Override
// public void onCreate(T view, Bundle savedInstanceState, Intent intent, Bundle arguments) {
// }
//
// @Override
// public void onStart(T view) {
// }
//
// @Override
// public void onResume(T view) {
// }
//
// @Override
// public boolean hasOptionsMenu(T view) {
// return false;
// }
//
// @Override
// public void onCreateOptionsMenu(T view, Menu menu, MenuInflater inflater) {
// }
//
// @Override
// public boolean onOptionsItemSelected(T view, MenuItem item) {
// return false;
// }
//
// @Override
// public void onPause(T view) {
// }
//
// @Override
// public void onStop(T view) {
// }
//
// @Override
// public void onSaveInstanceState(T view, Bundle bundle) {
// }
//
// @Override
// public void onDestroy(T view, boolean changingConfigurations) {
// }
//
// @Override
// public void onActivityResult(T view, int requestCode, int resultCode, Intent data) {
// }
//
// @Override public void onViewCreated(T view, Bundle savedInstanceState) {
// }
//
// @Override public void onDestroyView(T view) {
// }
// }
//
// Path: lifecyclebinder-api/src/main/java/it/codingjam/lifecyclebinder/LifeCycleAwareCollector.java
// public interface LifeCycleAwareCollector {
// <R> R addRetainedFactory(String key, Callable<R> factory, boolean addInLifeCycleAwareList);
//
// void addLifeCycleAware(LifeCycleAware<?> lifeCycleAware);
//
// <R> R getOrCreate(R lifeCycleAware, String key, Callable<R> factory);
// }
| import android.content.Intent;
import android.os.Bundle;
import com.test.MyView;
import it.codingjam.lifecyclebinder.DefaultLifeCycleAware;
import it.codingjam.lifecyclebinder.LifeCycleAwareCollector; | package com.test.retainedEvents;
public class MyObjectWithEvents1$LifeCycleBinder {
public static MyObjectWithEvents1 bind(LifeCycleAwareCollector collector, final MyObjectWithEvents1 lifeCycleAware, boolean addInList) {
if (addInList) { | // Path: test-data-lib/src/main/java/com/test/MyView.java
// public interface MyView {
// }
//
// Path: lifecyclebinder-api/src/main/java/it/codingjam/lifecyclebinder/DefaultLifeCycleAware.java
// public class DefaultLifeCycleAware<T> implements LifeCycleAware<T> {
// @Override
// public void onCreate(T view, Bundle savedInstanceState, Intent intent, Bundle arguments) {
// }
//
// @Override
// public void onStart(T view) {
// }
//
// @Override
// public void onResume(T view) {
// }
//
// @Override
// public boolean hasOptionsMenu(T view) {
// return false;
// }
//
// @Override
// public void onCreateOptionsMenu(T view, Menu menu, MenuInflater inflater) {
// }
//
// @Override
// public boolean onOptionsItemSelected(T view, MenuItem item) {
// return false;
// }
//
// @Override
// public void onPause(T view) {
// }
//
// @Override
// public void onStop(T view) {
// }
//
// @Override
// public void onSaveInstanceState(T view, Bundle bundle) {
// }
//
// @Override
// public void onDestroy(T view, boolean changingConfigurations) {
// }
//
// @Override
// public void onActivityResult(T view, int requestCode, int resultCode, Intent data) {
// }
//
// @Override public void onViewCreated(T view, Bundle savedInstanceState) {
// }
//
// @Override public void onDestroyView(T view) {
// }
// }
//
// Path: lifecyclebinder-api/src/main/java/it/codingjam/lifecyclebinder/LifeCycleAwareCollector.java
// public interface LifeCycleAwareCollector {
// <R> R addRetainedFactory(String key, Callable<R> factory, boolean addInLifeCycleAwareList);
//
// void addLifeCycleAware(LifeCycleAware<?> lifeCycleAware);
//
// <R> R getOrCreate(R lifeCycleAware, String key, Callable<R> factory);
// }
// Path: test-data-lib/src/main/java/com/test/retainedEvents/MyObjectWithEvents1$LifeCycleBinder.java
import android.content.Intent;
import android.os.Bundle;
import com.test.MyView;
import it.codingjam.lifecyclebinder.DefaultLifeCycleAware;
import it.codingjam.lifecyclebinder.LifeCycleAwareCollector;
package com.test.retainedEvents;
public class MyObjectWithEvents1$LifeCycleBinder {
public static MyObjectWithEvents1 bind(LifeCycleAwareCollector collector, final MyObjectWithEvents1 lifeCycleAware, boolean addInList) {
if (addInList) { | collector.addLifeCycleAware(new DefaultLifeCycleAware<MyView>() { |
fabioCollini/LifeCycleBinder | test-data-lib/src/main/java/com/test/myActivityEventsNoViewParam/MyObjectWithEvents.java | // Path: lifecyclebinder-api/src/main/java/it/codingjam/lifecyclebinder/LifeCycleEvent.java
// public enum LifeCycleEvent {
// CREATE, START, RESUME, PAUSE, STOP, DESTROY, SAVE_INSTANCE_STATE, ACTIVITY_RESULT, HAS_OPTION_MENU, CREATE_OPTION_MENU, OPTION_ITEM_SELECTED, VIEW_CREATED, DESTROY_VIEW;
// }
| import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import it.codingjam.lifecyclebinder.BindEvent;
import it.codingjam.lifecyclebinder.LifeCycleEvent;
import static it.codingjam.lifecyclebinder.LifeCycleEvent.ACTIVITY_RESULT;
import static it.codingjam.lifecyclebinder.LifeCycleEvent.CREATE;
import static it.codingjam.lifecyclebinder.LifeCycleEvent.CREATE_OPTION_MENU;
import static it.codingjam.lifecyclebinder.LifeCycleEvent.DESTROY;
import static it.codingjam.lifecyclebinder.LifeCycleEvent.DESTROY_VIEW;
import static it.codingjam.lifecyclebinder.LifeCycleEvent.HAS_OPTION_MENU;
import static it.codingjam.lifecyclebinder.LifeCycleEvent.OPTION_ITEM_SELECTED;
import static it.codingjam.lifecyclebinder.LifeCycleEvent.PAUSE;
import static it.codingjam.lifecyclebinder.LifeCycleEvent.RESUME;
import static it.codingjam.lifecyclebinder.LifeCycleEvent.SAVE_INSTANCE_STATE;
import static it.codingjam.lifecyclebinder.LifeCycleEvent.START;
import static it.codingjam.lifecyclebinder.LifeCycleEvent.STOP;
import static it.codingjam.lifecyclebinder.LifeCycleEvent.VIEW_CREATED; | package com.test.myActivityEventsNoViewParam;
public class MyObjectWithEvents {
@BindEvent(CREATE) public void myOnCreate() {
}
| // Path: lifecyclebinder-api/src/main/java/it/codingjam/lifecyclebinder/LifeCycleEvent.java
// public enum LifeCycleEvent {
// CREATE, START, RESUME, PAUSE, STOP, DESTROY, SAVE_INSTANCE_STATE, ACTIVITY_RESULT, HAS_OPTION_MENU, CREATE_OPTION_MENU, OPTION_ITEM_SELECTED, VIEW_CREATED, DESTROY_VIEW;
// }
// Path: test-data-lib/src/main/java/com/test/myActivityEventsNoViewParam/MyObjectWithEvents.java
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import it.codingjam.lifecyclebinder.BindEvent;
import it.codingjam.lifecyclebinder.LifeCycleEvent;
import static it.codingjam.lifecyclebinder.LifeCycleEvent.ACTIVITY_RESULT;
import static it.codingjam.lifecyclebinder.LifeCycleEvent.CREATE;
import static it.codingjam.lifecyclebinder.LifeCycleEvent.CREATE_OPTION_MENU;
import static it.codingjam.lifecyclebinder.LifeCycleEvent.DESTROY;
import static it.codingjam.lifecyclebinder.LifeCycleEvent.DESTROY_VIEW;
import static it.codingjam.lifecyclebinder.LifeCycleEvent.HAS_OPTION_MENU;
import static it.codingjam.lifecyclebinder.LifeCycleEvent.OPTION_ITEM_SELECTED;
import static it.codingjam.lifecyclebinder.LifeCycleEvent.PAUSE;
import static it.codingjam.lifecyclebinder.LifeCycleEvent.RESUME;
import static it.codingjam.lifecyclebinder.LifeCycleEvent.SAVE_INSTANCE_STATE;
import static it.codingjam.lifecyclebinder.LifeCycleEvent.START;
import static it.codingjam.lifecyclebinder.LifeCycleEvent.STOP;
import static it.codingjam.lifecyclebinder.LifeCycleEvent.VIEW_CREATED;
package com.test.myActivityEventsNoViewParam;
public class MyObjectWithEvents {
@BindEvent(CREATE) public void myOnCreate() {
}
| @BindEvent(START) public void myOnStart(LifeCycleEvent event) { |
fabioCollini/LifeCycleBinder | lifecyclebinder-demo-fragments/src/main/java/it/codingjam/lifecyclebinder/demo/MyFragment.java | // Path: lifecyclebinder-lib/src/main/java/it/codingjam/lifecyclebinder/LifeCycleBinder.java
// public class LifeCycleBinder {
// public static void bind(Fragment fragment) {
// bind(fragment, fragment.getChildFragmentManager());
// }
//
// public static void bind(FragmentActivity activity) {
// bind(activity, activity.getSupportFragmentManager());
// }
//
// public static <T extends Fragment> void bind(T fragment, Class<?> objectBinderClass) {
// bind(fragment.getChildFragmentManager(), objectBinderClass);
// }
//
// public static <T extends FragmentActivity> void bind(T activity, Class<?> objectBinderClass) {
// bind(activity.getSupportFragmentManager(), objectBinderClass);
// }
//
// private static <T> void bind(T obj, FragmentManager fragmentManager) {
// LifeCycleBinderFragment<T> fragment = LifeCycleBinderFragment.get(fragmentManager);
// if (fragment == null) {
// Class<?> c = ReflectionUtils.getObjectBinderClass(obj);
// fragment = LifeCycleBinderFragment.createAndAdd(fragmentManager, c);
// }
// fragment.invokeOnCreate();
// }
//
// private static <T> void bind(FragmentManager fragmentManager, Class<?> objectBinderClass) {
// LifeCycleBinderFragment<T> fragment = LifeCycleBinderFragment.get(fragmentManager);
// if (fragment == null) {
// fragment = LifeCycleBinderFragment.createAndAdd(fragmentManager, objectBinderClass);
// }
// fragment.invokeOnCreate();
// }
//
// public static void startActivityForResult(FragmentActivity activity, Intent intent, int requestCode) {
// LifeCycleBinderFragment.get(activity.getSupportFragmentManager()).startActivityForResult(intent, requestCode);
// }
//
// public static void startActivityForResult(Fragment fragment, Intent intent, int requestCode) {
// LifeCycleBinderFragment.get(fragment.getChildFragmentManager()).startActivityForResult(intent, requestCode);
// }
// }
| import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import java.util.concurrent.Callable;
import it.codingjam.lifecyclebinder.LifeCycleBinder;
import it.codingjam.lifecyclebinder.RetainedObjectProvider; | /*
* Copyright 2016 Fabio Collini.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package it.codingjam.lifecyclebinder.demo;
public class MyFragment extends Fragment {
@RetainedObjectProvider
Callable<FragmentLogger> fragmentLogger = new Callable<FragmentLogger>() {
@Override
public FragmentLogger call() throws Exception {
return new FragmentLogger("MyFragment");
}
};
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState); | // Path: lifecyclebinder-lib/src/main/java/it/codingjam/lifecyclebinder/LifeCycleBinder.java
// public class LifeCycleBinder {
// public static void bind(Fragment fragment) {
// bind(fragment, fragment.getChildFragmentManager());
// }
//
// public static void bind(FragmentActivity activity) {
// bind(activity, activity.getSupportFragmentManager());
// }
//
// public static <T extends Fragment> void bind(T fragment, Class<?> objectBinderClass) {
// bind(fragment.getChildFragmentManager(), objectBinderClass);
// }
//
// public static <T extends FragmentActivity> void bind(T activity, Class<?> objectBinderClass) {
// bind(activity.getSupportFragmentManager(), objectBinderClass);
// }
//
// private static <T> void bind(T obj, FragmentManager fragmentManager) {
// LifeCycleBinderFragment<T> fragment = LifeCycleBinderFragment.get(fragmentManager);
// if (fragment == null) {
// Class<?> c = ReflectionUtils.getObjectBinderClass(obj);
// fragment = LifeCycleBinderFragment.createAndAdd(fragmentManager, c);
// }
// fragment.invokeOnCreate();
// }
//
// private static <T> void bind(FragmentManager fragmentManager, Class<?> objectBinderClass) {
// LifeCycleBinderFragment<T> fragment = LifeCycleBinderFragment.get(fragmentManager);
// if (fragment == null) {
// fragment = LifeCycleBinderFragment.createAndAdd(fragmentManager, objectBinderClass);
// }
// fragment.invokeOnCreate();
// }
//
// public static void startActivityForResult(FragmentActivity activity, Intent intent, int requestCode) {
// LifeCycleBinderFragment.get(activity.getSupportFragmentManager()).startActivityForResult(intent, requestCode);
// }
//
// public static void startActivityForResult(Fragment fragment, Intent intent, int requestCode) {
// LifeCycleBinderFragment.get(fragment.getChildFragmentManager()).startActivityForResult(intent, requestCode);
// }
// }
// Path: lifecyclebinder-demo-fragments/src/main/java/it/codingjam/lifecyclebinder/demo/MyFragment.java
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import java.util.concurrent.Callable;
import it.codingjam.lifecyclebinder.LifeCycleBinder;
import it.codingjam.lifecyclebinder.RetainedObjectProvider;
/*
* Copyright 2016 Fabio Collini.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package it.codingjam.lifecyclebinder.demo;
public class MyFragment extends Fragment {
@RetainedObjectProvider
Callable<FragmentLogger> fragmentLogger = new Callable<FragmentLogger>() {
@Override
public FragmentLogger call() throws Exception {
return new FragmentLogger("MyFragment");
}
};
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState); | LifeCycleBinder.bind(this); |
fabioCollini/LifeCycleBinder | test-data-lib/src/main/java/com/test/nestedfactory/MyObjectWithParcelableAndInnerObject$LifeCycleBinder.java | // Path: test-data-lib/src/main/java/com/test/MyObject$LifeCycleBinder.java
// public class MyObject$LifeCycleBinder {
//
// public static MyObject bind(LifeCycleAwareCollector collector, MyObject lifeCycleAware, boolean addInList) {
// if (addInList) {
// collector.addLifeCycleAware(lifeCycleAware);
// }
// return lifeCycleAware;
// }
// }
//
// Path: lifecyclebinder-api/src/main/java/it/codingjam/lifecyclebinder/LifeCycleAwareCollector.java
// public interface LifeCycleAwareCollector {
// <R> R addRetainedFactory(String key, Callable<R> factory, boolean addInLifeCycleAwareList);
//
// void addLifeCycleAware(LifeCycleAware<?> lifeCycleAware);
//
// <R> R getOrCreate(R lifeCycleAware, String key, Callable<R> factory);
// }
| import com.test.MyObject$LifeCycleBinder;
import it.codingjam.lifecyclebinder.LifeCycleAwareCollector; | /*
* Copyright 2016 Fabio Collini.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.test.nestedfactory;
public class MyObjectWithParcelableAndInnerObject$LifeCycleBinder {
public static MyObjectWithParcelableAndInnerObject bind(LifeCycleAwareCollector collector, MyObjectWithParcelableAndInnerObject lifeCycleAware,
boolean addInList) {
lifeCycleAware.myObject2 = | // Path: test-data-lib/src/main/java/com/test/MyObject$LifeCycleBinder.java
// public class MyObject$LifeCycleBinder {
//
// public static MyObject bind(LifeCycleAwareCollector collector, MyObject lifeCycleAware, boolean addInList) {
// if (addInList) {
// collector.addLifeCycleAware(lifeCycleAware);
// }
// return lifeCycleAware;
// }
// }
//
// Path: lifecyclebinder-api/src/main/java/it/codingjam/lifecyclebinder/LifeCycleAwareCollector.java
// public interface LifeCycleAwareCollector {
// <R> R addRetainedFactory(String key, Callable<R> factory, boolean addInLifeCycleAwareList);
//
// void addLifeCycleAware(LifeCycleAware<?> lifeCycleAware);
//
// <R> R getOrCreate(R lifeCycleAware, String key, Callable<R> factory);
// }
// Path: test-data-lib/src/main/java/com/test/nestedfactory/MyObjectWithParcelableAndInnerObject$LifeCycleBinder.java
import com.test.MyObject$LifeCycleBinder;
import it.codingjam.lifecyclebinder.LifeCycleAwareCollector;
/*
* Copyright 2016 Fabio Collini.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.test.nestedfactory;
public class MyObjectWithParcelableAndInnerObject$LifeCycleBinder {
public static MyObjectWithParcelableAndInnerObject bind(LifeCycleAwareCollector collector, MyObjectWithParcelableAndInnerObject lifeCycleAware,
boolean addInList) {
lifeCycleAware.myObject2 = | MyObject$LifeCycleBinder.bind(collector, collector.getOrCreate(null, "myObject2Provider", lifeCycleAware.myObject2Provider), true); |
fabioCollini/LifeCycleBinder | test-data-lib/src/main/java/com/test/retained/ActivityWithRetained.java | // Path: lifecyclebinder-processor/src/test/java/com/test/MyObject.java
// public class MyObject implements LifeCycleAware<MyView> {
// @Override
// public void onCreate(MyView view, Bundle savedInstanceState, Intent intent, Bundle arguments) {
//
// }
//
// @Override
// public void onStart(MyView view) {
//
// }
//
// @Override
// public void onResume(MyView view) {
//
// }
//
// @Override
// public boolean hasOptionsMenu(MyView view) {
// return false;
// }
//
// @Override
// public void onCreateOptionsMenu(MyView view, Menu menu, MenuInflater inflater) {
//
// }
//
// @Override
// public boolean onOptionsItemSelected(MyView view, MenuItem item) {
// return false;
// }
//
// @Override
// public void onPause(MyView view) {
//
// }
//
// @Override
// public void onStop(MyView view) {
//
// }
//
// @Override
// public void onSaveInstanceState(MyView view, Bundle bundle) {
//
// }
//
// @Override
// public void onDestroy(MyView view, boolean changingConfigurations) {
//
// }
//
// @Override
// public void onActivityResult(MyView view, int requestCode, int resultCode, Intent data) {
//
// }
//
// @Override public void onViewCreated(MyView view, Bundle savedInstanceState) {
//
// }
//
// @Override public void onDestroyView(MyView view) {
//
// }
// }
//
// Path: test-data-lib/src/main/java/com/test/MyView.java
// public interface MyView {
// }
| import android.support.v4.app.FragmentActivity;
import com.test.MyObject;
import com.test.MyView;
import it.codingjam.lifecyclebinder.RetainedObjectProvider;
import java.util.concurrent.Callable; | /*
* Copyright 2016 Fabio Collini.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.test.retained;
public class ActivityWithRetained extends FragmentActivity implements MyView {
@RetainedObjectProvider | // Path: lifecyclebinder-processor/src/test/java/com/test/MyObject.java
// public class MyObject implements LifeCycleAware<MyView> {
// @Override
// public void onCreate(MyView view, Bundle savedInstanceState, Intent intent, Bundle arguments) {
//
// }
//
// @Override
// public void onStart(MyView view) {
//
// }
//
// @Override
// public void onResume(MyView view) {
//
// }
//
// @Override
// public boolean hasOptionsMenu(MyView view) {
// return false;
// }
//
// @Override
// public void onCreateOptionsMenu(MyView view, Menu menu, MenuInflater inflater) {
//
// }
//
// @Override
// public boolean onOptionsItemSelected(MyView view, MenuItem item) {
// return false;
// }
//
// @Override
// public void onPause(MyView view) {
//
// }
//
// @Override
// public void onStop(MyView view) {
//
// }
//
// @Override
// public void onSaveInstanceState(MyView view, Bundle bundle) {
//
// }
//
// @Override
// public void onDestroy(MyView view, boolean changingConfigurations) {
//
// }
//
// @Override
// public void onActivityResult(MyView view, int requestCode, int resultCode, Intent data) {
//
// }
//
// @Override public void onViewCreated(MyView view, Bundle savedInstanceState) {
//
// }
//
// @Override public void onDestroyView(MyView view) {
//
// }
// }
//
// Path: test-data-lib/src/main/java/com/test/MyView.java
// public interface MyView {
// }
// Path: test-data-lib/src/main/java/com/test/retained/ActivityWithRetained.java
import android.support.v4.app.FragmentActivity;
import com.test.MyObject;
import com.test.MyView;
import it.codingjam.lifecyclebinder.RetainedObjectProvider;
import java.util.concurrent.Callable;
/*
* Copyright 2016 Fabio Collini.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.test.retained;
public class ActivityWithRetained extends FragmentActivity implements MyView {
@RetainedObjectProvider | Callable<MyObject> myObjectProvider = new Callable<MyObject>() { |
fabioCollini/LifeCycleBinder | lifecyclebinder-demo-fragments/src/main/java/it/codingjam/lifecyclebinder/demo/MyFragment3.java | // Path: lifecyclebinder-lib/src/main/java/it/codingjam/lifecyclebinder/LifeCycleBinder.java
// public class LifeCycleBinder {
// public static void bind(Fragment fragment) {
// bind(fragment, fragment.getChildFragmentManager());
// }
//
// public static void bind(FragmentActivity activity) {
// bind(activity, activity.getSupportFragmentManager());
// }
//
// public static <T extends Fragment> void bind(T fragment, Class<?> objectBinderClass) {
// bind(fragment.getChildFragmentManager(), objectBinderClass);
// }
//
// public static <T extends FragmentActivity> void bind(T activity, Class<?> objectBinderClass) {
// bind(activity.getSupportFragmentManager(), objectBinderClass);
// }
//
// private static <T> void bind(T obj, FragmentManager fragmentManager) {
// LifeCycleBinderFragment<T> fragment = LifeCycleBinderFragment.get(fragmentManager);
// if (fragment == null) {
// Class<?> c = ReflectionUtils.getObjectBinderClass(obj);
// fragment = LifeCycleBinderFragment.createAndAdd(fragmentManager, c);
// }
// fragment.invokeOnCreate();
// }
//
// private static <T> void bind(FragmentManager fragmentManager, Class<?> objectBinderClass) {
// LifeCycleBinderFragment<T> fragment = LifeCycleBinderFragment.get(fragmentManager);
// if (fragment == null) {
// fragment = LifeCycleBinderFragment.createAndAdd(fragmentManager, objectBinderClass);
// }
// fragment.invokeOnCreate();
// }
//
// public static void startActivityForResult(FragmentActivity activity, Intent intent, int requestCode) {
// LifeCycleBinderFragment.get(activity.getSupportFragmentManager()).startActivityForResult(intent, requestCode);
// }
//
// public static void startActivityForResult(Fragment fragment, Intent intent, int requestCode) {
// LifeCycleBinderFragment.get(fragment.getChildFragmentManager()).startActivityForResult(intent, requestCode);
// }
// }
| import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import java.util.concurrent.Callable;
import it.codingjam.lifecyclebinder.LifeCycleBinder;
import it.codingjam.lifecyclebinder.RetainedObjectProvider; | /*
* Copyright 2016 Fabio Collini.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package it.codingjam.lifecyclebinder.demo;
public class MyFragment3 extends Fragment {
@RetainedObjectProvider
Callable<FragmentLogger> fragmentLogger = new Callable<FragmentLogger>() {
@Override
public FragmentLogger call() throws Exception {
return new FragmentLogger("MyFragment3");
}
};
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState); | // Path: lifecyclebinder-lib/src/main/java/it/codingjam/lifecyclebinder/LifeCycleBinder.java
// public class LifeCycleBinder {
// public static void bind(Fragment fragment) {
// bind(fragment, fragment.getChildFragmentManager());
// }
//
// public static void bind(FragmentActivity activity) {
// bind(activity, activity.getSupportFragmentManager());
// }
//
// public static <T extends Fragment> void bind(T fragment, Class<?> objectBinderClass) {
// bind(fragment.getChildFragmentManager(), objectBinderClass);
// }
//
// public static <T extends FragmentActivity> void bind(T activity, Class<?> objectBinderClass) {
// bind(activity.getSupportFragmentManager(), objectBinderClass);
// }
//
// private static <T> void bind(T obj, FragmentManager fragmentManager) {
// LifeCycleBinderFragment<T> fragment = LifeCycleBinderFragment.get(fragmentManager);
// if (fragment == null) {
// Class<?> c = ReflectionUtils.getObjectBinderClass(obj);
// fragment = LifeCycleBinderFragment.createAndAdd(fragmentManager, c);
// }
// fragment.invokeOnCreate();
// }
//
// private static <T> void bind(FragmentManager fragmentManager, Class<?> objectBinderClass) {
// LifeCycleBinderFragment<T> fragment = LifeCycleBinderFragment.get(fragmentManager);
// if (fragment == null) {
// fragment = LifeCycleBinderFragment.createAndAdd(fragmentManager, objectBinderClass);
// }
// fragment.invokeOnCreate();
// }
//
// public static void startActivityForResult(FragmentActivity activity, Intent intent, int requestCode) {
// LifeCycleBinderFragment.get(activity.getSupportFragmentManager()).startActivityForResult(intent, requestCode);
// }
//
// public static void startActivityForResult(Fragment fragment, Intent intent, int requestCode) {
// LifeCycleBinderFragment.get(fragment.getChildFragmentManager()).startActivityForResult(intent, requestCode);
// }
// }
// Path: lifecyclebinder-demo-fragments/src/main/java/it/codingjam/lifecyclebinder/demo/MyFragment3.java
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import java.util.concurrent.Callable;
import it.codingjam.lifecyclebinder.LifeCycleBinder;
import it.codingjam.lifecyclebinder.RetainedObjectProvider;
/*
* Copyright 2016 Fabio Collini.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package it.codingjam.lifecyclebinder.demo;
public class MyFragment3 extends Fragment {
@RetainedObjectProvider
Callable<FragmentLogger> fragmentLogger = new Callable<FragmentLogger>() {
@Override
public FragmentLogger call() throws Exception {
return new FragmentLogger("MyFragment3");
}
};
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState); | LifeCycleBinder.bind(this); |
fabioCollini/LifeCycleBinder | test-data-lib/src/main/java/com/test/objectWithNestedGenericBaseClass/MyObjectWithGenericBaseClass$LifeCycleBinder.java | // Path: test-data-lib/src/main/java/com/test/MyObject$LifeCycleBinder.java
// public class MyObject$LifeCycleBinder {
//
// public static MyObject bind(LifeCycleAwareCollector collector, MyObject lifeCycleAware, boolean addInList) {
// if (addInList) {
// collector.addLifeCycleAware(lifeCycleAware);
// }
// return lifeCycleAware;
// }
// }
//
// Path: lifecyclebinder-api/src/main/java/it/codingjam/lifecyclebinder/LifeCycleAwareCollector.java
// public interface LifeCycleAwareCollector {
// <R> R addRetainedFactory(String key, Callable<R> factory, boolean addInLifeCycleAwareList);
//
// void addLifeCycleAware(LifeCycleAware<?> lifeCycleAware);
//
// <R> R getOrCreate(R lifeCycleAware, String key, Callable<R> factory);
// }
| import com.test.MyObject$LifeCycleBinder;
import it.codingjam.lifecyclebinder.LifeCycleAwareCollector; | /*
* Copyright 2016 Fabio Collini.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.test.objectWithNestedGenericBaseClass;
public class MyObjectWithGenericBaseClass$LifeCycleBinder {
public static MyObjectWithGenericBaseClass bind(LifeCycleAwareCollector collector, MyObjectWithGenericBaseClass lifeCycleAware, boolean addInList) {
MyGenericBaseClass$LifeCycleBinder.bind(collector, lifeCycleAware, false); | // Path: test-data-lib/src/main/java/com/test/MyObject$LifeCycleBinder.java
// public class MyObject$LifeCycleBinder {
//
// public static MyObject bind(LifeCycleAwareCollector collector, MyObject lifeCycleAware, boolean addInList) {
// if (addInList) {
// collector.addLifeCycleAware(lifeCycleAware);
// }
// return lifeCycleAware;
// }
// }
//
// Path: lifecyclebinder-api/src/main/java/it/codingjam/lifecyclebinder/LifeCycleAwareCollector.java
// public interface LifeCycleAwareCollector {
// <R> R addRetainedFactory(String key, Callable<R> factory, boolean addInLifeCycleAwareList);
//
// void addLifeCycleAware(LifeCycleAware<?> lifeCycleAware);
//
// <R> R getOrCreate(R lifeCycleAware, String key, Callable<R> factory);
// }
// Path: test-data-lib/src/main/java/com/test/objectWithNestedGenericBaseClass/MyObjectWithGenericBaseClass$LifeCycleBinder.java
import com.test.MyObject$LifeCycleBinder;
import it.codingjam.lifecyclebinder.LifeCycleAwareCollector;
/*
* Copyright 2016 Fabio Collini.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.test.objectWithNestedGenericBaseClass;
public class MyObjectWithGenericBaseClass$LifeCycleBinder {
public static MyObjectWithGenericBaseClass bind(LifeCycleAwareCollector collector, MyObjectWithGenericBaseClass lifeCycleAware, boolean addInList) {
MyGenericBaseClass$LifeCycleBinder.bind(collector, lifeCycleAware, false); | MyObject$LifeCycleBinder.bind(collector, collector.getOrCreate(lifeCycleAware.myObject, null, null), true); |
fabioCollini/LifeCycleBinder | test-data-lib/src/main/java/com/test/retainedObjectsInBaseClassWithProvider/ActivityWithRetainedProvider$LifeCycleBinder.java | // Path: lifecyclebinder-processor/src/test/java/com/test/MyObject.java
// public class MyObject implements LifeCycleAware<MyView> {
// @Override
// public void onCreate(MyView view, Bundle savedInstanceState, Intent intent, Bundle arguments) {
//
// }
//
// @Override
// public void onStart(MyView view) {
//
// }
//
// @Override
// public void onResume(MyView view) {
//
// }
//
// @Override
// public boolean hasOptionsMenu(MyView view) {
// return false;
// }
//
// @Override
// public void onCreateOptionsMenu(MyView view, Menu menu, MenuInflater inflater) {
//
// }
//
// @Override
// public boolean onOptionsItemSelected(MyView view, MenuItem item) {
// return false;
// }
//
// @Override
// public void onPause(MyView view) {
//
// }
//
// @Override
// public void onStop(MyView view) {
//
// }
//
// @Override
// public void onSaveInstanceState(MyView view, Bundle bundle) {
//
// }
//
// @Override
// public void onDestroy(MyView view, boolean changingConfigurations) {
//
// }
//
// @Override
// public void onActivityResult(MyView view, int requestCode, int resultCode, Intent data) {
//
// }
//
// @Override public void onViewCreated(MyView view, Bundle savedInstanceState) {
//
// }
//
// @Override public void onDestroyView(MyView view) {
//
// }
// }
//
// Path: test-data-lib/src/main/java/com/test/MyObject$LifeCycleBinder.java
// public class MyObject$LifeCycleBinder {
//
// public static MyObject bind(LifeCycleAwareCollector collector, MyObject lifeCycleAware, boolean addInList) {
// if (addInList) {
// collector.addLifeCycleAware(lifeCycleAware);
// }
// return lifeCycleAware;
// }
// }
//
// Path: lifecyclebinder-api/src/main/java/it/codingjam/lifecyclebinder/LifeCycleAwareCollector.java
// public interface LifeCycleAwareCollector {
// <R> R addRetainedFactory(String key, Callable<R> factory, boolean addInLifeCycleAwareList);
//
// void addLifeCycleAware(LifeCycleAware<?> lifeCycleAware);
//
// <R> R getOrCreate(R lifeCycleAware, String key, Callable<R> factory);
// }
| import com.test.MyObject;
import com.test.MyObject$LifeCycleBinder;
import it.codingjam.lifecyclebinder.LifeCycleAwareCollector;
import java.util.concurrent.Callable; | /*
* Copyright 2016 Fabio Collini.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.test.retainedObjectsInBaseClassWithProvider;
public class ActivityWithRetainedProvider$LifeCycleBinder {
public static void bind(LifeCycleAwareCollector collector, final ActivityWithRetainedProvider view) { | // Path: lifecyclebinder-processor/src/test/java/com/test/MyObject.java
// public class MyObject implements LifeCycleAware<MyView> {
// @Override
// public void onCreate(MyView view, Bundle savedInstanceState, Intent intent, Bundle arguments) {
//
// }
//
// @Override
// public void onStart(MyView view) {
//
// }
//
// @Override
// public void onResume(MyView view) {
//
// }
//
// @Override
// public boolean hasOptionsMenu(MyView view) {
// return false;
// }
//
// @Override
// public void onCreateOptionsMenu(MyView view, Menu menu, MenuInflater inflater) {
//
// }
//
// @Override
// public boolean onOptionsItemSelected(MyView view, MenuItem item) {
// return false;
// }
//
// @Override
// public void onPause(MyView view) {
//
// }
//
// @Override
// public void onStop(MyView view) {
//
// }
//
// @Override
// public void onSaveInstanceState(MyView view, Bundle bundle) {
//
// }
//
// @Override
// public void onDestroy(MyView view, boolean changingConfigurations) {
//
// }
//
// @Override
// public void onActivityResult(MyView view, int requestCode, int resultCode, Intent data) {
//
// }
//
// @Override public void onViewCreated(MyView view, Bundle savedInstanceState) {
//
// }
//
// @Override public void onDestroyView(MyView view) {
//
// }
// }
//
// Path: test-data-lib/src/main/java/com/test/MyObject$LifeCycleBinder.java
// public class MyObject$LifeCycleBinder {
//
// public static MyObject bind(LifeCycleAwareCollector collector, MyObject lifeCycleAware, boolean addInList) {
// if (addInList) {
// collector.addLifeCycleAware(lifeCycleAware);
// }
// return lifeCycleAware;
// }
// }
//
// Path: lifecyclebinder-api/src/main/java/it/codingjam/lifecyclebinder/LifeCycleAwareCollector.java
// public interface LifeCycleAwareCollector {
// <R> R addRetainedFactory(String key, Callable<R> factory, boolean addInLifeCycleAwareList);
//
// void addLifeCycleAware(LifeCycleAware<?> lifeCycleAware);
//
// <R> R getOrCreate(R lifeCycleAware, String key, Callable<R> factory);
// }
// Path: test-data-lib/src/main/java/com/test/retainedObjectsInBaseClassWithProvider/ActivityWithRetainedProvider$LifeCycleBinder.java
import com.test.MyObject;
import com.test.MyObject$LifeCycleBinder;
import it.codingjam.lifecyclebinder.LifeCycleAwareCollector;
import java.util.concurrent.Callable;
/*
* Copyright 2016 Fabio Collini.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.test.retainedObjectsInBaseClassWithProvider;
public class ActivityWithRetainedProvider$LifeCycleBinder {
public static void bind(LifeCycleAwareCollector collector, final ActivityWithRetainedProvider view) { | view.myObjectInBaseActivity = MyObject$LifeCycleBinder.bind(collector, collector.getOrCreate(null, "myObject", new Callable<MyObject>() { |
fabioCollini/LifeCycleBinder | test-data-lib/src/main/java/com/test/retainedObjectsInBaseClassWithProvider/ActivityWithRetainedProvider$LifeCycleBinder.java | // Path: lifecyclebinder-processor/src/test/java/com/test/MyObject.java
// public class MyObject implements LifeCycleAware<MyView> {
// @Override
// public void onCreate(MyView view, Bundle savedInstanceState, Intent intent, Bundle arguments) {
//
// }
//
// @Override
// public void onStart(MyView view) {
//
// }
//
// @Override
// public void onResume(MyView view) {
//
// }
//
// @Override
// public boolean hasOptionsMenu(MyView view) {
// return false;
// }
//
// @Override
// public void onCreateOptionsMenu(MyView view, Menu menu, MenuInflater inflater) {
//
// }
//
// @Override
// public boolean onOptionsItemSelected(MyView view, MenuItem item) {
// return false;
// }
//
// @Override
// public void onPause(MyView view) {
//
// }
//
// @Override
// public void onStop(MyView view) {
//
// }
//
// @Override
// public void onSaveInstanceState(MyView view, Bundle bundle) {
//
// }
//
// @Override
// public void onDestroy(MyView view, boolean changingConfigurations) {
//
// }
//
// @Override
// public void onActivityResult(MyView view, int requestCode, int resultCode, Intent data) {
//
// }
//
// @Override public void onViewCreated(MyView view, Bundle savedInstanceState) {
//
// }
//
// @Override public void onDestroyView(MyView view) {
//
// }
// }
//
// Path: test-data-lib/src/main/java/com/test/MyObject$LifeCycleBinder.java
// public class MyObject$LifeCycleBinder {
//
// public static MyObject bind(LifeCycleAwareCollector collector, MyObject lifeCycleAware, boolean addInList) {
// if (addInList) {
// collector.addLifeCycleAware(lifeCycleAware);
// }
// return lifeCycleAware;
// }
// }
//
// Path: lifecyclebinder-api/src/main/java/it/codingjam/lifecyclebinder/LifeCycleAwareCollector.java
// public interface LifeCycleAwareCollector {
// <R> R addRetainedFactory(String key, Callable<R> factory, boolean addInLifeCycleAwareList);
//
// void addLifeCycleAware(LifeCycleAware<?> lifeCycleAware);
//
// <R> R getOrCreate(R lifeCycleAware, String key, Callable<R> factory);
// }
| import com.test.MyObject;
import com.test.MyObject$LifeCycleBinder;
import it.codingjam.lifecyclebinder.LifeCycleAwareCollector;
import java.util.concurrent.Callable; | /*
* Copyright 2016 Fabio Collini.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.test.retainedObjectsInBaseClassWithProvider;
public class ActivityWithRetainedProvider$LifeCycleBinder {
public static void bind(LifeCycleAwareCollector collector, final ActivityWithRetainedProvider view) { | // Path: lifecyclebinder-processor/src/test/java/com/test/MyObject.java
// public class MyObject implements LifeCycleAware<MyView> {
// @Override
// public void onCreate(MyView view, Bundle savedInstanceState, Intent intent, Bundle arguments) {
//
// }
//
// @Override
// public void onStart(MyView view) {
//
// }
//
// @Override
// public void onResume(MyView view) {
//
// }
//
// @Override
// public boolean hasOptionsMenu(MyView view) {
// return false;
// }
//
// @Override
// public void onCreateOptionsMenu(MyView view, Menu menu, MenuInflater inflater) {
//
// }
//
// @Override
// public boolean onOptionsItemSelected(MyView view, MenuItem item) {
// return false;
// }
//
// @Override
// public void onPause(MyView view) {
//
// }
//
// @Override
// public void onStop(MyView view) {
//
// }
//
// @Override
// public void onSaveInstanceState(MyView view, Bundle bundle) {
//
// }
//
// @Override
// public void onDestroy(MyView view, boolean changingConfigurations) {
//
// }
//
// @Override
// public void onActivityResult(MyView view, int requestCode, int resultCode, Intent data) {
//
// }
//
// @Override public void onViewCreated(MyView view, Bundle savedInstanceState) {
//
// }
//
// @Override public void onDestroyView(MyView view) {
//
// }
// }
//
// Path: test-data-lib/src/main/java/com/test/MyObject$LifeCycleBinder.java
// public class MyObject$LifeCycleBinder {
//
// public static MyObject bind(LifeCycleAwareCollector collector, MyObject lifeCycleAware, boolean addInList) {
// if (addInList) {
// collector.addLifeCycleAware(lifeCycleAware);
// }
// return lifeCycleAware;
// }
// }
//
// Path: lifecyclebinder-api/src/main/java/it/codingjam/lifecyclebinder/LifeCycleAwareCollector.java
// public interface LifeCycleAwareCollector {
// <R> R addRetainedFactory(String key, Callable<R> factory, boolean addInLifeCycleAwareList);
//
// void addLifeCycleAware(LifeCycleAware<?> lifeCycleAware);
//
// <R> R getOrCreate(R lifeCycleAware, String key, Callable<R> factory);
// }
// Path: test-data-lib/src/main/java/com/test/retainedObjectsInBaseClassWithProvider/ActivityWithRetainedProvider$LifeCycleBinder.java
import com.test.MyObject;
import com.test.MyObject$LifeCycleBinder;
import it.codingjam.lifecyclebinder.LifeCycleAwareCollector;
import java.util.concurrent.Callable;
/*
* Copyright 2016 Fabio Collini.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.test.retainedObjectsInBaseClassWithProvider;
public class ActivityWithRetainedProvider$LifeCycleBinder {
public static void bind(LifeCycleAwareCollector collector, final ActivityWithRetainedProvider view) { | view.myObjectInBaseActivity = MyObject$LifeCycleBinder.bind(collector, collector.getOrCreate(null, "myObject", new Callable<MyObject>() { |
fabioCollini/LifeCycleBinder | test-data-lib/src/main/java/com/test/retained/ActivityWithRetainedAndField$LifeCycleBinder.java | // Path: test-data-lib/src/main/java/com/test/MyObject$LifeCycleBinder.java
// public class MyObject$LifeCycleBinder {
//
// public static MyObject bind(LifeCycleAwareCollector collector, MyObject lifeCycleAware, boolean addInList) {
// if (addInList) {
// collector.addLifeCycleAware(lifeCycleAware);
// }
// return lifeCycleAware;
// }
// }
//
// Path: lifecyclebinder-api/src/main/java/it/codingjam/lifecyclebinder/LifeCycleAwareCollector.java
// public interface LifeCycleAwareCollector {
// <R> R addRetainedFactory(String key, Callable<R> factory, boolean addInLifeCycleAwareList);
//
// void addLifeCycleAware(LifeCycleAware<?> lifeCycleAware);
//
// <R> R getOrCreate(R lifeCycleAware, String key, Callable<R> factory);
// }
| import com.test.MyObject$LifeCycleBinder;
import it.codingjam.lifecyclebinder.LifeCycleAwareCollector; | package com.test.retained;
public class ActivityWithRetainedAndField$LifeCycleBinder {
public static void bind(LifeCycleAwareCollector collector, final ActivityWithRetainedAndField view) { | // Path: test-data-lib/src/main/java/com/test/MyObject$LifeCycleBinder.java
// public class MyObject$LifeCycleBinder {
//
// public static MyObject bind(LifeCycleAwareCollector collector, MyObject lifeCycleAware, boolean addInList) {
// if (addInList) {
// collector.addLifeCycleAware(lifeCycleAware);
// }
// return lifeCycleAware;
// }
// }
//
// Path: lifecyclebinder-api/src/main/java/it/codingjam/lifecyclebinder/LifeCycleAwareCollector.java
// public interface LifeCycleAwareCollector {
// <R> R addRetainedFactory(String key, Callable<R> factory, boolean addInLifeCycleAwareList);
//
// void addLifeCycleAware(LifeCycleAware<?> lifeCycleAware);
//
// <R> R getOrCreate(R lifeCycleAware, String key, Callable<R> factory);
// }
// Path: test-data-lib/src/main/java/com/test/retained/ActivityWithRetainedAndField$LifeCycleBinder.java
import com.test.MyObject$LifeCycleBinder;
import it.codingjam.lifecyclebinder.LifeCycleAwareCollector;
package com.test.retained;
public class ActivityWithRetainedAndField$LifeCycleBinder {
public static void bind(LifeCycleAwareCollector collector, final ActivityWithRetainedAndField view) { | view.myObject = MyObject$LifeCycleBinder.bind(collector, collector.getOrCreate(null, "myObjectProvider", view.myObjectProvider), true); |
fabioCollini/LifeCycleBinder | lifecyclebinder-demo-mvvm/src/main/java/it/codingjam/lifecyclebinder/mvvm/Navigator.java | // Path: lifecyclebinder-lib/src/main/java/it/codingjam/lifecyclebinder/LifeCycleBinder.java
// public class LifeCycleBinder {
// public static void bind(Fragment fragment) {
// bind(fragment, fragment.getChildFragmentManager());
// }
//
// public static void bind(FragmentActivity activity) {
// bind(activity, activity.getSupportFragmentManager());
// }
//
// public static <T extends Fragment> void bind(T fragment, Class<?> objectBinderClass) {
// bind(fragment.getChildFragmentManager(), objectBinderClass);
// }
//
// public static <T extends FragmentActivity> void bind(T activity, Class<?> objectBinderClass) {
// bind(activity.getSupportFragmentManager(), objectBinderClass);
// }
//
// private static <T> void bind(T obj, FragmentManager fragmentManager) {
// LifeCycleBinderFragment<T> fragment = LifeCycleBinderFragment.get(fragmentManager);
// if (fragment == null) {
// Class<?> c = ReflectionUtils.getObjectBinderClass(obj);
// fragment = LifeCycleBinderFragment.createAndAdd(fragmentManager, c);
// }
// fragment.invokeOnCreate();
// }
//
// private static <T> void bind(FragmentManager fragmentManager, Class<?> objectBinderClass) {
// LifeCycleBinderFragment<T> fragment = LifeCycleBinderFragment.get(fragmentManager);
// if (fragment == null) {
// fragment = LifeCycleBinderFragment.createAndAdd(fragmentManager, objectBinderClass);
// }
// fragment.invokeOnCreate();
// }
//
// public static void startActivityForResult(FragmentActivity activity, Intent intent, int requestCode) {
// LifeCycleBinderFragment.get(activity.getSupportFragmentManager()).startActivityForResult(intent, requestCode);
// }
//
// public static void startActivityForResult(Fragment fragment, Intent intent, int requestCode) {
// LifeCycleBinderFragment.get(fragment.getChildFragmentManager()).startActivityForResult(intent, requestCode);
// }
// }
| import android.content.Intent;
import android.support.v4.app.FragmentActivity;
import it.codingjam.lifecyclebinder.BindEvent;
import it.codingjam.lifecyclebinder.LifeCycleBinder;
import it.codingjam.lifecyclebinder.mvp.R;
import static it.codingjam.lifecyclebinder.LifeCycleEvent.CREATE; | package it.codingjam.lifecyclebinder.mvvm;
public class Navigator {
private FragmentActivity activity;
@BindEvent(CREATE) public void onCreate(FragmentActivity activity) {
this.activity = activity;
}
public void share(String message, int requestCode) {
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, message);
sendIntent.setType("text/plain");
Intent chooser = Intent.createChooser(sendIntent, activity.getResources().getText(R.string.share)); | // Path: lifecyclebinder-lib/src/main/java/it/codingjam/lifecyclebinder/LifeCycleBinder.java
// public class LifeCycleBinder {
// public static void bind(Fragment fragment) {
// bind(fragment, fragment.getChildFragmentManager());
// }
//
// public static void bind(FragmentActivity activity) {
// bind(activity, activity.getSupportFragmentManager());
// }
//
// public static <T extends Fragment> void bind(T fragment, Class<?> objectBinderClass) {
// bind(fragment.getChildFragmentManager(), objectBinderClass);
// }
//
// public static <T extends FragmentActivity> void bind(T activity, Class<?> objectBinderClass) {
// bind(activity.getSupportFragmentManager(), objectBinderClass);
// }
//
// private static <T> void bind(T obj, FragmentManager fragmentManager) {
// LifeCycleBinderFragment<T> fragment = LifeCycleBinderFragment.get(fragmentManager);
// if (fragment == null) {
// Class<?> c = ReflectionUtils.getObjectBinderClass(obj);
// fragment = LifeCycleBinderFragment.createAndAdd(fragmentManager, c);
// }
// fragment.invokeOnCreate();
// }
//
// private static <T> void bind(FragmentManager fragmentManager, Class<?> objectBinderClass) {
// LifeCycleBinderFragment<T> fragment = LifeCycleBinderFragment.get(fragmentManager);
// if (fragment == null) {
// fragment = LifeCycleBinderFragment.createAndAdd(fragmentManager, objectBinderClass);
// }
// fragment.invokeOnCreate();
// }
//
// public static void startActivityForResult(FragmentActivity activity, Intent intent, int requestCode) {
// LifeCycleBinderFragment.get(activity.getSupportFragmentManager()).startActivityForResult(intent, requestCode);
// }
//
// public static void startActivityForResult(Fragment fragment, Intent intent, int requestCode) {
// LifeCycleBinderFragment.get(fragment.getChildFragmentManager()).startActivityForResult(intent, requestCode);
// }
// }
// Path: lifecyclebinder-demo-mvvm/src/main/java/it/codingjam/lifecyclebinder/mvvm/Navigator.java
import android.content.Intent;
import android.support.v4.app.FragmentActivity;
import it.codingjam.lifecyclebinder.BindEvent;
import it.codingjam.lifecyclebinder.LifeCycleBinder;
import it.codingjam.lifecyclebinder.mvp.R;
import static it.codingjam.lifecyclebinder.LifeCycleEvent.CREATE;
package it.codingjam.lifecyclebinder.mvvm;
public class Navigator {
private FragmentActivity activity;
@BindEvent(CREATE) public void onCreate(FragmentActivity activity) {
this.activity = activity;
}
public void share(String message, int requestCode) {
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, message);
sendIntent.setType("text/plain");
Intent chooser = Intent.createChooser(sendIntent, activity.getResources().getText(R.string.share)); | LifeCycleBinder.startActivityForResult(activity, chooser, requestCode); |
fabioCollini/LifeCycleBinder | test-data-lib/src/main/java/com/test/nestedfactory/ActivityMyObjectWithParcelableAndInnerObject.java | // Path: lifecyclebinder-processor/src/test/java/com/test/MyObject.java
// public class MyObject implements LifeCycleAware<MyView> {
// @Override
// public void onCreate(MyView view, Bundle savedInstanceState, Intent intent, Bundle arguments) {
//
// }
//
// @Override
// public void onStart(MyView view) {
//
// }
//
// @Override
// public void onResume(MyView view) {
//
// }
//
// @Override
// public boolean hasOptionsMenu(MyView view) {
// return false;
// }
//
// @Override
// public void onCreateOptionsMenu(MyView view, Menu menu, MenuInflater inflater) {
//
// }
//
// @Override
// public boolean onOptionsItemSelected(MyView view, MenuItem item) {
// return false;
// }
//
// @Override
// public void onPause(MyView view) {
//
// }
//
// @Override
// public void onStop(MyView view) {
//
// }
//
// @Override
// public void onSaveInstanceState(MyView view, Bundle bundle) {
//
// }
//
// @Override
// public void onDestroy(MyView view, boolean changingConfigurations) {
//
// }
//
// @Override
// public void onActivityResult(MyView view, int requestCode, int resultCode, Intent data) {
//
// }
//
// @Override public void onViewCreated(MyView view, Bundle savedInstanceState) {
//
// }
//
// @Override public void onDestroyView(MyView view) {
//
// }
// }
//
// Path: test-data-lib/src/main/java/com/test/MyView.java
// public interface MyView {
// }
//
// Path: lifecyclebinder-api/src/main/java/it/codingjam/lifecyclebinder/LifeCycleAware.java
// public interface LifeCycleAware<T> {
// void onCreate(T view, Bundle savedInstanceState, Intent intent, Bundle arguments);
//
// void onStart(T view);
//
// void onResume(T view);
//
// boolean hasOptionsMenu(T view);
//
// void onCreateOptionsMenu(T view, Menu menu, MenuInflater inflater);
//
// boolean onOptionsItemSelected(T view, MenuItem item);
//
// void onPause(T view);
//
// void onStop(T view);
//
// void onSaveInstanceState(T view, Bundle bundle);
//
// void onDestroy(T view, boolean changingConfigurations);
//
// void onActivityResult(T view, int requestCode, int resultCode, Intent data);
//
// void onViewCreated(T view, Bundle savedInstanceState);
//
// void onDestroyView(T view);
// }
| import it.codingjam.lifecyclebinder.LifeCycleAware;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import com.test.MyObject;
import com.test.MyView;
import java.util.concurrent.Callable;
import it.codingjam.lifecyclebinder.BindLifeCycle;
import it.codingjam.lifecyclebinder.RetainedObjectProvider; | /*
* Copyright 2016 Fabio Collini.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.test.nestedfactory;
class MyObjectWithParcelableAndInnerObject implements LifeCycleAware<MyView> {
@BindLifeCycle | // Path: lifecyclebinder-processor/src/test/java/com/test/MyObject.java
// public class MyObject implements LifeCycleAware<MyView> {
// @Override
// public void onCreate(MyView view, Bundle savedInstanceState, Intent intent, Bundle arguments) {
//
// }
//
// @Override
// public void onStart(MyView view) {
//
// }
//
// @Override
// public void onResume(MyView view) {
//
// }
//
// @Override
// public boolean hasOptionsMenu(MyView view) {
// return false;
// }
//
// @Override
// public void onCreateOptionsMenu(MyView view, Menu menu, MenuInflater inflater) {
//
// }
//
// @Override
// public boolean onOptionsItemSelected(MyView view, MenuItem item) {
// return false;
// }
//
// @Override
// public void onPause(MyView view) {
//
// }
//
// @Override
// public void onStop(MyView view) {
//
// }
//
// @Override
// public void onSaveInstanceState(MyView view, Bundle bundle) {
//
// }
//
// @Override
// public void onDestroy(MyView view, boolean changingConfigurations) {
//
// }
//
// @Override
// public void onActivityResult(MyView view, int requestCode, int resultCode, Intent data) {
//
// }
//
// @Override public void onViewCreated(MyView view, Bundle savedInstanceState) {
//
// }
//
// @Override public void onDestroyView(MyView view) {
//
// }
// }
//
// Path: test-data-lib/src/main/java/com/test/MyView.java
// public interface MyView {
// }
//
// Path: lifecyclebinder-api/src/main/java/it/codingjam/lifecyclebinder/LifeCycleAware.java
// public interface LifeCycleAware<T> {
// void onCreate(T view, Bundle savedInstanceState, Intent intent, Bundle arguments);
//
// void onStart(T view);
//
// void onResume(T view);
//
// boolean hasOptionsMenu(T view);
//
// void onCreateOptionsMenu(T view, Menu menu, MenuInflater inflater);
//
// boolean onOptionsItemSelected(T view, MenuItem item);
//
// void onPause(T view);
//
// void onStop(T view);
//
// void onSaveInstanceState(T view, Bundle bundle);
//
// void onDestroy(T view, boolean changingConfigurations);
//
// void onActivityResult(T view, int requestCode, int resultCode, Intent data);
//
// void onViewCreated(T view, Bundle savedInstanceState);
//
// void onDestroyView(T view);
// }
// Path: test-data-lib/src/main/java/com/test/nestedfactory/ActivityMyObjectWithParcelableAndInnerObject.java
import it.codingjam.lifecyclebinder.LifeCycleAware;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import com.test.MyObject;
import com.test.MyView;
import java.util.concurrent.Callable;
import it.codingjam.lifecyclebinder.BindLifeCycle;
import it.codingjam.lifecyclebinder.RetainedObjectProvider;
/*
* Copyright 2016 Fabio Collini.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.test.nestedfactory;
class MyObjectWithParcelableAndInnerObject implements LifeCycleAware<MyView> {
@BindLifeCycle | MyObject myObject; |
fabioCollini/LifeCycleBinder | lifecyclebinder-processor/src/main/java/it/codingjam/lifecyclebinder/LifeCycleBinderProcessor.java | // Path: lifecyclebinder-processor/src/main/java/it/codingjam/lifecyclebinder/data/LifeCycleAwareInfo.java
// public class LifeCycleAwareInfo {
// public final TypeElement element;
//
// public final List<VariableElement> lifeCycleAwareElements = new ArrayList<>();
//
// public final List<EventMethodElement> eventsElements = new ArrayList<>();
//
// public final List<NestedLifeCycleAwareInfo> nestedElements = new ArrayList<>();
//
// public final List<RetainedObjectInfo> retainedObjects = new ArrayList<>();
//
// public final List<TypeName> superClasses = new ArrayList<>();
//
// public LifeCycleAwareInfo(TypeElement element) {
// this.element = element;
// }
//
// @Override
// public String toString() {
// return "LifeCycleAwareInfo{" +
// "element=" + element +
// ", lifeCycleAwareElements=" + lifeCycleAwareElements +
// ", nestedElements=" + nestedElements +
// ", retainedObjects=" + retainedObjects +
// '}';
// }
//
// public boolean isNested(String name) {
// for (NestedLifeCycleAwareInfo nestedElement : nestedElements) {
// if (nestedElement.getFieldName().equals(name)) {
// return true;
// }
// }
// return false;
// }
//
// public boolean containsField(String field, Types typeUtils) {
// TypeElement currentElement = this.element;
// while (currentElement != null) {
// List<? extends Element> enclosedElements = currentElement.getEnclosedElements();
// for (Element e : enclosedElements) {
// if (e.getKind() == ElementKind.FIELD && e.getSimpleName().toString().equals(field)) {
// return true;
// }
// }
// TypeMirror superclass = currentElement.getSuperclass();
// if (!superclass.toString().equals("java.lang.Object")) {
// currentElement = (TypeElement) typeUtils.asElement(superclass);
// } else {
// return false;
// }
// }
// return false;
// }
// }
| import it.codingjam.lifecyclebinder.data.LifeCycleAwareInfo;
import java.util.List;
import java.util.Set;
import javax.annotation.processing.AbstractProcessor;
import javax.annotation.processing.Filer;
import javax.annotation.processing.Messager;
import javax.annotation.processing.ProcessingEnvironment;
import javax.annotation.processing.RoundEnvironment;
import javax.annotation.processing.SupportedAnnotationTypes;
import javax.lang.model.SourceVersion;
import javax.lang.model.element.TypeElement;
import javax.lang.model.util.Elements;
import javax.lang.model.util.Types; | /*
* Copyright 2016 Fabio Collini.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package it.codingjam.lifecyclebinder;
@SupportedAnnotationTypes({
"it.codingjam.lifecyclebinder.BindLifeCycle",
"it.codingjam.lifecyclebinder.RetainedObjectProvider",
"it.codingjam.lifecyclebinder.BindEvent"
})
public class LifeCycleBinderProcessor extends AbstractProcessor {
private Types types;
private Elements elements;
private Filer filer;
private Messager messager;
private ElementsCollector elementsCollector;
private BinderGenerator binderGenerator;
@Override
public synchronized void init(ProcessingEnvironment processingEnv) {
super.init(processingEnv);
types = processingEnv.getTypeUtils();
elements = processingEnv.getElementUtils();
filer = processingEnv.getFiler();
messager = processingEnv.getMessager();
elementsCollector = new ElementsCollector(messager, types, elements);
binderGenerator = new BinderGenerator(processingEnv, types, messager, elements);
}
@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { | // Path: lifecyclebinder-processor/src/main/java/it/codingjam/lifecyclebinder/data/LifeCycleAwareInfo.java
// public class LifeCycleAwareInfo {
// public final TypeElement element;
//
// public final List<VariableElement> lifeCycleAwareElements = new ArrayList<>();
//
// public final List<EventMethodElement> eventsElements = new ArrayList<>();
//
// public final List<NestedLifeCycleAwareInfo> nestedElements = new ArrayList<>();
//
// public final List<RetainedObjectInfo> retainedObjects = new ArrayList<>();
//
// public final List<TypeName> superClasses = new ArrayList<>();
//
// public LifeCycleAwareInfo(TypeElement element) {
// this.element = element;
// }
//
// @Override
// public String toString() {
// return "LifeCycleAwareInfo{" +
// "element=" + element +
// ", lifeCycleAwareElements=" + lifeCycleAwareElements +
// ", nestedElements=" + nestedElements +
// ", retainedObjects=" + retainedObjects +
// '}';
// }
//
// public boolean isNested(String name) {
// for (NestedLifeCycleAwareInfo nestedElement : nestedElements) {
// if (nestedElement.getFieldName().equals(name)) {
// return true;
// }
// }
// return false;
// }
//
// public boolean containsField(String field, Types typeUtils) {
// TypeElement currentElement = this.element;
// while (currentElement != null) {
// List<? extends Element> enclosedElements = currentElement.getEnclosedElements();
// for (Element e : enclosedElements) {
// if (e.getKind() == ElementKind.FIELD && e.getSimpleName().toString().equals(field)) {
// return true;
// }
// }
// TypeMirror superclass = currentElement.getSuperclass();
// if (!superclass.toString().equals("java.lang.Object")) {
// currentElement = (TypeElement) typeUtils.asElement(superclass);
// } else {
// return false;
// }
// }
// return false;
// }
// }
// Path: lifecyclebinder-processor/src/main/java/it/codingjam/lifecyclebinder/LifeCycleBinderProcessor.java
import it.codingjam.lifecyclebinder.data.LifeCycleAwareInfo;
import java.util.List;
import java.util.Set;
import javax.annotation.processing.AbstractProcessor;
import javax.annotation.processing.Filer;
import javax.annotation.processing.Messager;
import javax.annotation.processing.ProcessingEnvironment;
import javax.annotation.processing.RoundEnvironment;
import javax.annotation.processing.SupportedAnnotationTypes;
import javax.lang.model.SourceVersion;
import javax.lang.model.element.TypeElement;
import javax.lang.model.util.Elements;
import javax.lang.model.util.Types;
/*
* Copyright 2016 Fabio Collini.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package it.codingjam.lifecyclebinder;
@SupportedAnnotationTypes({
"it.codingjam.lifecyclebinder.BindLifeCycle",
"it.codingjam.lifecyclebinder.RetainedObjectProvider",
"it.codingjam.lifecyclebinder.BindEvent"
})
public class LifeCycleBinderProcessor extends AbstractProcessor {
private Types types;
private Elements elements;
private Filer filer;
private Messager messager;
private ElementsCollector elementsCollector;
private BinderGenerator binderGenerator;
@Override
public synchronized void init(ProcessingEnvironment processingEnv) {
super.init(processingEnv);
types = processingEnv.getTypeUtils();
elements = processingEnv.getElementUtils();
filer = processingEnv.getFiler();
messager = processingEnv.getMessager();
elementsCollector = new ElementsCollector(messager, types, elements);
binderGenerator = new BinderGenerator(processingEnv, types, messager, elements);
}
@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { | List<LifeCycleAwareInfo> elementsByClass = elementsCollector.createLifeCycleAwareElements( |
fabioCollini/LifeCycleBinder | test-data-lib/src/main/java/com/test/activityWithBaseClass/BaseClass$LifeCycleBinder.java | // Path: test-data-lib/src/main/java/com/test/MyObject$LifeCycleBinder.java
// public class MyObject$LifeCycleBinder {
//
// public static MyObject bind(LifeCycleAwareCollector collector, MyObject lifeCycleAware, boolean addInList) {
// if (addInList) {
// collector.addLifeCycleAware(lifeCycleAware);
// }
// return lifeCycleAware;
// }
// }
//
// Path: lifecyclebinder-api/src/main/java/it/codingjam/lifecyclebinder/LifeCycleAwareCollector.java
// public interface LifeCycleAwareCollector {
// <R> R addRetainedFactory(String key, Callable<R> factory, boolean addInLifeCycleAwareList);
//
// void addLifeCycleAware(LifeCycleAware<?> lifeCycleAware);
//
// <R> R getOrCreate(R lifeCycleAware, String key, Callable<R> factory);
// }
| import com.test.MyObject$LifeCycleBinder;
import it.codingjam.lifecyclebinder.LifeCycleAwareCollector; | /*
* Copyright 2016 Fabio Collini.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.test.activityWithBaseClass;
public class BaseClass$LifeCycleBinder {
public static void bind(LifeCycleAwareCollector collector, BaseClass view) { | // Path: test-data-lib/src/main/java/com/test/MyObject$LifeCycleBinder.java
// public class MyObject$LifeCycleBinder {
//
// public static MyObject bind(LifeCycleAwareCollector collector, MyObject lifeCycleAware, boolean addInList) {
// if (addInList) {
// collector.addLifeCycleAware(lifeCycleAware);
// }
// return lifeCycleAware;
// }
// }
//
// Path: lifecyclebinder-api/src/main/java/it/codingjam/lifecyclebinder/LifeCycleAwareCollector.java
// public interface LifeCycleAwareCollector {
// <R> R addRetainedFactory(String key, Callable<R> factory, boolean addInLifeCycleAwareList);
//
// void addLifeCycleAware(LifeCycleAware<?> lifeCycleAware);
//
// <R> R getOrCreate(R lifeCycleAware, String key, Callable<R> factory);
// }
// Path: test-data-lib/src/main/java/com/test/activityWithBaseClass/BaseClass$LifeCycleBinder.java
import com.test.MyObject$LifeCycleBinder;
import it.codingjam.lifecyclebinder.LifeCycleAwareCollector;
/*
* Copyright 2016 Fabio Collini.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.test.activityWithBaseClass;
public class BaseClass$LifeCycleBinder {
public static void bind(LifeCycleAwareCollector collector, BaseClass view) { | MyObject$LifeCycleBinder.bind(collector, view.myBaseObject, true); |
fabioCollini/LifeCycleBinder | lifecyclebinder-demo-mvvm/src/main/java/it/codingjam/lifecyclebinder/mvvm/Logger.java | // Path: lifecyclebinder-api/src/main/java/it/codingjam/lifecyclebinder/LifeCycleEvent.java
// public enum LifeCycleEvent {
// CREATE, START, RESUME, PAUSE, STOP, DESTROY, SAVE_INSTANCE_STATE, ACTIVITY_RESULT, HAS_OPTION_MENU, CREATE_OPTION_MENU, OPTION_ITEM_SELECTED, VIEW_CREATED, DESTROY_VIEW;
// }
| import static it.codingjam.lifecyclebinder.LifeCycleEvent.STOP;
import android.util.Log;
import it.codingjam.lifecyclebinder.BindEvent;
import it.codingjam.lifecyclebinder.LifeCycleEvent;
import static it.codingjam.lifecyclebinder.LifeCycleEvent.ACTIVITY_RESULT;
import static it.codingjam.lifecyclebinder.LifeCycleEvent.CREATE;
import static it.codingjam.lifecyclebinder.LifeCycleEvent.CREATE_OPTION_MENU;
import static it.codingjam.lifecyclebinder.LifeCycleEvent.DESTROY;
import static it.codingjam.lifecyclebinder.LifeCycleEvent.HAS_OPTION_MENU;
import static it.codingjam.lifecyclebinder.LifeCycleEvent.OPTION_ITEM_SELECTED;
import static it.codingjam.lifecyclebinder.LifeCycleEvent.PAUSE;
import static it.codingjam.lifecyclebinder.LifeCycleEvent.RESUME;
import static it.codingjam.lifecyclebinder.LifeCycleEvent.SAVE_INSTANCE_STATE;
import static it.codingjam.lifecyclebinder.LifeCycleEvent.START; | /*
* Copyright 2016 Fabio Collini.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package it.codingjam.lifecyclebinder.mvvm;
public class Logger {
private static final String TAG = "ACTIVITY_LOG";
@BindEvent({
CREATE, START, RESUME, PAUSE, STOP, DESTROY, SAVE_INSTANCE_STATE, ACTIVITY_RESULT, HAS_OPTION_MENU, CREATE_OPTION_MENU,
OPTION_ITEM_SELECTED
}) | // Path: lifecyclebinder-api/src/main/java/it/codingjam/lifecyclebinder/LifeCycleEvent.java
// public enum LifeCycleEvent {
// CREATE, START, RESUME, PAUSE, STOP, DESTROY, SAVE_INSTANCE_STATE, ACTIVITY_RESULT, HAS_OPTION_MENU, CREATE_OPTION_MENU, OPTION_ITEM_SELECTED, VIEW_CREATED, DESTROY_VIEW;
// }
// Path: lifecyclebinder-demo-mvvm/src/main/java/it/codingjam/lifecyclebinder/mvvm/Logger.java
import static it.codingjam.lifecyclebinder.LifeCycleEvent.STOP;
import android.util.Log;
import it.codingjam.lifecyclebinder.BindEvent;
import it.codingjam.lifecyclebinder.LifeCycleEvent;
import static it.codingjam.lifecyclebinder.LifeCycleEvent.ACTIVITY_RESULT;
import static it.codingjam.lifecyclebinder.LifeCycleEvent.CREATE;
import static it.codingjam.lifecyclebinder.LifeCycleEvent.CREATE_OPTION_MENU;
import static it.codingjam.lifecyclebinder.LifeCycleEvent.DESTROY;
import static it.codingjam.lifecyclebinder.LifeCycleEvent.HAS_OPTION_MENU;
import static it.codingjam.lifecyclebinder.LifeCycleEvent.OPTION_ITEM_SELECTED;
import static it.codingjam.lifecyclebinder.LifeCycleEvent.PAUSE;
import static it.codingjam.lifecyclebinder.LifeCycleEvent.RESUME;
import static it.codingjam.lifecyclebinder.LifeCycleEvent.SAVE_INSTANCE_STATE;
import static it.codingjam.lifecyclebinder.LifeCycleEvent.START;
/*
* Copyright 2016 Fabio Collini.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package it.codingjam.lifecyclebinder.mvvm;
public class Logger {
private static final String TAG = "ACTIVITY_LOG";
@BindEvent({
CREATE, START, RESUME, PAUSE, STOP, DESTROY, SAVE_INSTANCE_STATE, ACTIVITY_RESULT, HAS_OPTION_MENU, CREATE_OPTION_MENU,
OPTION_ITEM_SELECTED
}) | public void log(Object activity, LifeCycleEvent event) { |
fabioCollini/LifeCycleBinder | lifecyclebinder-demo-mvvm/src/main/java/it/codingjam/lifecyclebinder/mvvm/MainActivity.java | // Path: lifecyclebinder-lib/src/main/java/it/codingjam/lifecyclebinder/LifeCycleBinder.java
// public class LifeCycleBinder {
// public static void bind(Fragment fragment) {
// bind(fragment, fragment.getChildFragmentManager());
// }
//
// public static void bind(FragmentActivity activity) {
// bind(activity, activity.getSupportFragmentManager());
// }
//
// public static <T extends Fragment> void bind(T fragment, Class<?> objectBinderClass) {
// bind(fragment.getChildFragmentManager(), objectBinderClass);
// }
//
// public static <T extends FragmentActivity> void bind(T activity, Class<?> objectBinderClass) {
// bind(activity.getSupportFragmentManager(), objectBinderClass);
// }
//
// private static <T> void bind(T obj, FragmentManager fragmentManager) {
// LifeCycleBinderFragment<T> fragment = LifeCycleBinderFragment.get(fragmentManager);
// if (fragment == null) {
// Class<?> c = ReflectionUtils.getObjectBinderClass(obj);
// fragment = LifeCycleBinderFragment.createAndAdd(fragmentManager, c);
// }
// fragment.invokeOnCreate();
// }
//
// private static <T> void bind(FragmentManager fragmentManager, Class<?> objectBinderClass) {
// LifeCycleBinderFragment<T> fragment = LifeCycleBinderFragment.get(fragmentManager);
// if (fragment == null) {
// fragment = LifeCycleBinderFragment.createAndAdd(fragmentManager, objectBinderClass);
// }
// fragment.invokeOnCreate();
// }
//
// public static void startActivityForResult(FragmentActivity activity, Intent intent, int requestCode) {
// LifeCycleBinderFragment.get(activity.getSupportFragmentManager()).startActivityForResult(intent, requestCode);
// }
//
// public static void startActivityForResult(Fragment fragment, Intent intent, int requestCode) {
// LifeCycleBinderFragment.get(fragment.getChildFragmentManager()).startActivityForResult(intent, requestCode);
// }
// }
| import android.databinding.DataBindingUtil;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import it.codingjam.lifecyclebinder.LifeCycleBinder;
import it.codingjam.lifecyclebinder.RetainedObjectProvider;
import it.codingjam.lifecyclebinder.mvp.R;
import it.codingjam.lifecyclebinder.mvp.databinding.ActivityMainBinding;
import java.util.concurrent.Callable; | /*
* Copyright 2016 Fabio Collini.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package it.codingjam.lifecyclebinder.mvvm;
public class MainActivity extends AppCompatActivity {
@RetainedObjectProvider("viewModel")
Callable<ViewModel> viewModelFactory = new Callable<ViewModel>() {
@Override
public ViewModel call() throws Exception {
return new ViewModel();
}
};
ViewModel viewModel;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
| // Path: lifecyclebinder-lib/src/main/java/it/codingjam/lifecyclebinder/LifeCycleBinder.java
// public class LifeCycleBinder {
// public static void bind(Fragment fragment) {
// bind(fragment, fragment.getChildFragmentManager());
// }
//
// public static void bind(FragmentActivity activity) {
// bind(activity, activity.getSupportFragmentManager());
// }
//
// public static <T extends Fragment> void bind(T fragment, Class<?> objectBinderClass) {
// bind(fragment.getChildFragmentManager(), objectBinderClass);
// }
//
// public static <T extends FragmentActivity> void bind(T activity, Class<?> objectBinderClass) {
// bind(activity.getSupportFragmentManager(), objectBinderClass);
// }
//
// private static <T> void bind(T obj, FragmentManager fragmentManager) {
// LifeCycleBinderFragment<T> fragment = LifeCycleBinderFragment.get(fragmentManager);
// if (fragment == null) {
// Class<?> c = ReflectionUtils.getObjectBinderClass(obj);
// fragment = LifeCycleBinderFragment.createAndAdd(fragmentManager, c);
// }
// fragment.invokeOnCreate();
// }
//
// private static <T> void bind(FragmentManager fragmentManager, Class<?> objectBinderClass) {
// LifeCycleBinderFragment<T> fragment = LifeCycleBinderFragment.get(fragmentManager);
// if (fragment == null) {
// fragment = LifeCycleBinderFragment.createAndAdd(fragmentManager, objectBinderClass);
// }
// fragment.invokeOnCreate();
// }
//
// public static void startActivityForResult(FragmentActivity activity, Intent intent, int requestCode) {
// LifeCycleBinderFragment.get(activity.getSupportFragmentManager()).startActivityForResult(intent, requestCode);
// }
//
// public static void startActivityForResult(Fragment fragment, Intent intent, int requestCode) {
// LifeCycleBinderFragment.get(fragment.getChildFragmentManager()).startActivityForResult(intent, requestCode);
// }
// }
// Path: lifecyclebinder-demo-mvvm/src/main/java/it/codingjam/lifecyclebinder/mvvm/MainActivity.java
import android.databinding.DataBindingUtil;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import it.codingjam.lifecyclebinder.LifeCycleBinder;
import it.codingjam.lifecyclebinder.RetainedObjectProvider;
import it.codingjam.lifecyclebinder.mvp.R;
import it.codingjam.lifecyclebinder.mvp.databinding.ActivityMainBinding;
import java.util.concurrent.Callable;
/*
* Copyright 2016 Fabio Collini.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package it.codingjam.lifecyclebinder.mvvm;
public class MainActivity extends AppCompatActivity {
@RetainedObjectProvider("viewModel")
Callable<ViewModel> viewModelFactory = new Callable<ViewModel>() {
@Override
public ViewModel call() throws Exception {
return new ViewModel();
}
};
ViewModel viewModel;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
| LifeCycleBinder.bind(this); |
fabioCollini/LifeCycleBinder | lifecyclebinder-demo-fragments/src/main/java/it/codingjam/lifecyclebinder/demo/MyFragment4.java | // Path: lifecyclebinder-lib/src/main/java/it/codingjam/lifecyclebinder/LifeCycleBinder.java
// public class LifeCycleBinder {
// public static void bind(Fragment fragment) {
// bind(fragment, fragment.getChildFragmentManager());
// }
//
// public static void bind(FragmentActivity activity) {
// bind(activity, activity.getSupportFragmentManager());
// }
//
// public static <T extends Fragment> void bind(T fragment, Class<?> objectBinderClass) {
// bind(fragment.getChildFragmentManager(), objectBinderClass);
// }
//
// public static <T extends FragmentActivity> void bind(T activity, Class<?> objectBinderClass) {
// bind(activity.getSupportFragmentManager(), objectBinderClass);
// }
//
// private static <T> void bind(T obj, FragmentManager fragmentManager) {
// LifeCycleBinderFragment<T> fragment = LifeCycleBinderFragment.get(fragmentManager);
// if (fragment == null) {
// Class<?> c = ReflectionUtils.getObjectBinderClass(obj);
// fragment = LifeCycleBinderFragment.createAndAdd(fragmentManager, c);
// }
// fragment.invokeOnCreate();
// }
//
// private static <T> void bind(FragmentManager fragmentManager, Class<?> objectBinderClass) {
// LifeCycleBinderFragment<T> fragment = LifeCycleBinderFragment.get(fragmentManager);
// if (fragment == null) {
// fragment = LifeCycleBinderFragment.createAndAdd(fragmentManager, objectBinderClass);
// }
// fragment.invokeOnCreate();
// }
//
// public static void startActivityForResult(FragmentActivity activity, Intent intent, int requestCode) {
// LifeCycleBinderFragment.get(activity.getSupportFragmentManager()).startActivityForResult(intent, requestCode);
// }
//
// public static void startActivityForResult(Fragment fragment, Intent intent, int requestCode) {
// LifeCycleBinderFragment.get(fragment.getChildFragmentManager()).startActivityForResult(intent, requestCode);
// }
// }
| import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import it.codingjam.lifecyclebinder.BindLifeCycle;
import it.codingjam.lifecyclebinder.LifeCycleBinder; | /*
* Copyright 2016 Fabio Collini.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package it.codingjam.lifecyclebinder.demo;
public class MyFragment4 extends Fragment {
@BindLifeCycle FragmentLogger fragmentLogger = new FragmentLogger("MyFragment4");
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState); | // Path: lifecyclebinder-lib/src/main/java/it/codingjam/lifecyclebinder/LifeCycleBinder.java
// public class LifeCycleBinder {
// public static void bind(Fragment fragment) {
// bind(fragment, fragment.getChildFragmentManager());
// }
//
// public static void bind(FragmentActivity activity) {
// bind(activity, activity.getSupportFragmentManager());
// }
//
// public static <T extends Fragment> void bind(T fragment, Class<?> objectBinderClass) {
// bind(fragment.getChildFragmentManager(), objectBinderClass);
// }
//
// public static <T extends FragmentActivity> void bind(T activity, Class<?> objectBinderClass) {
// bind(activity.getSupportFragmentManager(), objectBinderClass);
// }
//
// private static <T> void bind(T obj, FragmentManager fragmentManager) {
// LifeCycleBinderFragment<T> fragment = LifeCycleBinderFragment.get(fragmentManager);
// if (fragment == null) {
// Class<?> c = ReflectionUtils.getObjectBinderClass(obj);
// fragment = LifeCycleBinderFragment.createAndAdd(fragmentManager, c);
// }
// fragment.invokeOnCreate();
// }
//
// private static <T> void bind(FragmentManager fragmentManager, Class<?> objectBinderClass) {
// LifeCycleBinderFragment<T> fragment = LifeCycleBinderFragment.get(fragmentManager);
// if (fragment == null) {
// fragment = LifeCycleBinderFragment.createAndAdd(fragmentManager, objectBinderClass);
// }
// fragment.invokeOnCreate();
// }
//
// public static void startActivityForResult(FragmentActivity activity, Intent intent, int requestCode) {
// LifeCycleBinderFragment.get(activity.getSupportFragmentManager()).startActivityForResult(intent, requestCode);
// }
//
// public static void startActivityForResult(Fragment fragment, Intent intent, int requestCode) {
// LifeCycleBinderFragment.get(fragment.getChildFragmentManager()).startActivityForResult(intent, requestCode);
// }
// }
// Path: lifecyclebinder-demo-fragments/src/main/java/it/codingjam/lifecyclebinder/demo/MyFragment4.java
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import it.codingjam.lifecyclebinder.BindLifeCycle;
import it.codingjam.lifecyclebinder.LifeCycleBinder;
/*
* Copyright 2016 Fabio Collini.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package it.codingjam.lifecyclebinder.demo;
public class MyFragment4 extends Fragment {
@BindLifeCycle FragmentLogger fragmentLogger = new FragmentLogger("MyFragment4");
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState); | LifeCycleBinder.bind(this); |
fabioCollini/LifeCycleBinder | test-data-lib/src/main/java/com/test/retainedObjectsWithProvider/ActivityWithRetainedProvider.java | // Path: lifecyclebinder-processor/src/test/java/com/test/MyObject.java
// public class MyObject implements LifeCycleAware<MyView> {
// @Override
// public void onCreate(MyView view, Bundle savedInstanceState, Intent intent, Bundle arguments) {
//
// }
//
// @Override
// public void onStart(MyView view) {
//
// }
//
// @Override
// public void onResume(MyView view) {
//
// }
//
// @Override
// public boolean hasOptionsMenu(MyView view) {
// return false;
// }
//
// @Override
// public void onCreateOptionsMenu(MyView view, Menu menu, MenuInflater inflater) {
//
// }
//
// @Override
// public boolean onOptionsItemSelected(MyView view, MenuItem item) {
// return false;
// }
//
// @Override
// public void onPause(MyView view) {
//
// }
//
// @Override
// public void onStop(MyView view) {
//
// }
//
// @Override
// public void onSaveInstanceState(MyView view, Bundle bundle) {
//
// }
//
// @Override
// public void onDestroy(MyView view, boolean changingConfigurations) {
//
// }
//
// @Override
// public void onActivityResult(MyView view, int requestCode, int resultCode, Intent data) {
//
// }
//
// @Override public void onViewCreated(MyView view, Bundle savedInstanceState) {
//
// }
//
// @Override public void onDestroyView(MyView view) {
//
// }
// }
//
// Path: test-data-lib/src/main/java/com/test/MyView.java
// public interface MyView {
// }
| import android.support.v4.app.FragmentActivity;
import com.test.MyObject;
import com.test.MyView;
import it.codingjam.lifecyclebinder.RetainedObjectProvider; | /*
* Copyright 2016 Fabio Collini.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.test.retainedObjectsWithProvider;
interface Provider<T> {
T get();
}
| // Path: lifecyclebinder-processor/src/test/java/com/test/MyObject.java
// public class MyObject implements LifeCycleAware<MyView> {
// @Override
// public void onCreate(MyView view, Bundle savedInstanceState, Intent intent, Bundle arguments) {
//
// }
//
// @Override
// public void onStart(MyView view) {
//
// }
//
// @Override
// public void onResume(MyView view) {
//
// }
//
// @Override
// public boolean hasOptionsMenu(MyView view) {
// return false;
// }
//
// @Override
// public void onCreateOptionsMenu(MyView view, Menu menu, MenuInflater inflater) {
//
// }
//
// @Override
// public boolean onOptionsItemSelected(MyView view, MenuItem item) {
// return false;
// }
//
// @Override
// public void onPause(MyView view) {
//
// }
//
// @Override
// public void onStop(MyView view) {
//
// }
//
// @Override
// public void onSaveInstanceState(MyView view, Bundle bundle) {
//
// }
//
// @Override
// public void onDestroy(MyView view, boolean changingConfigurations) {
//
// }
//
// @Override
// public void onActivityResult(MyView view, int requestCode, int resultCode, Intent data) {
//
// }
//
// @Override public void onViewCreated(MyView view, Bundle savedInstanceState) {
//
// }
//
// @Override public void onDestroyView(MyView view) {
//
// }
// }
//
// Path: test-data-lib/src/main/java/com/test/MyView.java
// public interface MyView {
// }
// Path: test-data-lib/src/main/java/com/test/retainedObjectsWithProvider/ActivityWithRetainedProvider.java
import android.support.v4.app.FragmentActivity;
import com.test.MyObject;
import com.test.MyView;
import it.codingjam.lifecyclebinder.RetainedObjectProvider;
/*
* Copyright 2016 Fabio Collini.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.test.retainedObjectsWithProvider;
interface Provider<T> {
T get();
}
| public class ActivityWithRetainedProvider extends FragmentActivity implements MyView { |
fabioCollini/LifeCycleBinder | test-data-lib/src/main/java/com/test/retainedObjectsWithProvider/ActivityWithRetainedProvider.java | // Path: lifecyclebinder-processor/src/test/java/com/test/MyObject.java
// public class MyObject implements LifeCycleAware<MyView> {
// @Override
// public void onCreate(MyView view, Bundle savedInstanceState, Intent intent, Bundle arguments) {
//
// }
//
// @Override
// public void onStart(MyView view) {
//
// }
//
// @Override
// public void onResume(MyView view) {
//
// }
//
// @Override
// public boolean hasOptionsMenu(MyView view) {
// return false;
// }
//
// @Override
// public void onCreateOptionsMenu(MyView view, Menu menu, MenuInflater inflater) {
//
// }
//
// @Override
// public boolean onOptionsItemSelected(MyView view, MenuItem item) {
// return false;
// }
//
// @Override
// public void onPause(MyView view) {
//
// }
//
// @Override
// public void onStop(MyView view) {
//
// }
//
// @Override
// public void onSaveInstanceState(MyView view, Bundle bundle) {
//
// }
//
// @Override
// public void onDestroy(MyView view, boolean changingConfigurations) {
//
// }
//
// @Override
// public void onActivityResult(MyView view, int requestCode, int resultCode, Intent data) {
//
// }
//
// @Override public void onViewCreated(MyView view, Bundle savedInstanceState) {
//
// }
//
// @Override public void onDestroyView(MyView view) {
//
// }
// }
//
// Path: test-data-lib/src/main/java/com/test/MyView.java
// public interface MyView {
// }
| import android.support.v4.app.FragmentActivity;
import com.test.MyObject;
import com.test.MyView;
import it.codingjam.lifecyclebinder.RetainedObjectProvider; | /*
* Copyright 2016 Fabio Collini.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.test.retainedObjectsWithProvider;
interface Provider<T> {
T get();
}
public class ActivityWithRetainedProvider extends FragmentActivity implements MyView {
@RetainedObjectProvider | // Path: lifecyclebinder-processor/src/test/java/com/test/MyObject.java
// public class MyObject implements LifeCycleAware<MyView> {
// @Override
// public void onCreate(MyView view, Bundle savedInstanceState, Intent intent, Bundle arguments) {
//
// }
//
// @Override
// public void onStart(MyView view) {
//
// }
//
// @Override
// public void onResume(MyView view) {
//
// }
//
// @Override
// public boolean hasOptionsMenu(MyView view) {
// return false;
// }
//
// @Override
// public void onCreateOptionsMenu(MyView view, Menu menu, MenuInflater inflater) {
//
// }
//
// @Override
// public boolean onOptionsItemSelected(MyView view, MenuItem item) {
// return false;
// }
//
// @Override
// public void onPause(MyView view) {
//
// }
//
// @Override
// public void onStop(MyView view) {
//
// }
//
// @Override
// public void onSaveInstanceState(MyView view, Bundle bundle) {
//
// }
//
// @Override
// public void onDestroy(MyView view, boolean changingConfigurations) {
//
// }
//
// @Override
// public void onActivityResult(MyView view, int requestCode, int resultCode, Intent data) {
//
// }
//
// @Override public void onViewCreated(MyView view, Bundle savedInstanceState) {
//
// }
//
// @Override public void onDestroyView(MyView view) {
//
// }
// }
//
// Path: test-data-lib/src/main/java/com/test/MyView.java
// public interface MyView {
// }
// Path: test-data-lib/src/main/java/com/test/retainedObjectsWithProvider/ActivityWithRetainedProvider.java
import android.support.v4.app.FragmentActivity;
import com.test.MyObject;
import com.test.MyView;
import it.codingjam.lifecyclebinder.RetainedObjectProvider;
/*
* Copyright 2016 Fabio Collini.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.test.retainedObjectsWithProvider;
interface Provider<T> {
T get();
}
public class ActivityWithRetainedProvider extends FragmentActivity implements MyView {
@RetainedObjectProvider | Provider<MyObject> myObject = new Provider<MyObject>() { |
fabioCollini/LifeCycleBinder | test-data-lib/src/main/java/com/test/objectWithNestedGenericBaseClass/MyGenericBaseClass$LifeCycleBinder.java | // Path: test-data-lib/src/main/java/com/test/MyObject$LifeCycleBinder.java
// public class MyObject$LifeCycleBinder {
//
// public static MyObject bind(LifeCycleAwareCollector collector, MyObject lifeCycleAware, boolean addInList) {
// if (addInList) {
// collector.addLifeCycleAware(lifeCycleAware);
// }
// return lifeCycleAware;
// }
// }
//
// Path: test-data-lib/src/main/java/com/test/MyView.java
// public interface MyView {
// }
//
// Path: lifecyclebinder-api/src/main/java/it/codingjam/lifecyclebinder/LifeCycleAwareCollector.java
// public interface LifeCycleAwareCollector {
// <R> R addRetainedFactory(String key, Callable<R> factory, boolean addInLifeCycleAwareList);
//
// void addLifeCycleAware(LifeCycleAware<?> lifeCycleAware);
//
// <R> R getOrCreate(R lifeCycleAware, String key, Callable<R> factory);
// }
| import com.test.MyObject$LifeCycleBinder;
import com.test.MyView;
import it.codingjam.lifecyclebinder.LifeCycleAwareCollector; | /*
* Copyright 2016 Fabio Collini.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.test.objectWithNestedGenericBaseClass;
public class MyGenericBaseClass$LifeCycleBinder {
public static <T extends MyView> MyGenericBaseClass<T> bind(LifeCycleAwareCollector collector, MyGenericBaseClass<T> lifeCycleAware,
boolean addInList) { | // Path: test-data-lib/src/main/java/com/test/MyObject$LifeCycleBinder.java
// public class MyObject$LifeCycleBinder {
//
// public static MyObject bind(LifeCycleAwareCollector collector, MyObject lifeCycleAware, boolean addInList) {
// if (addInList) {
// collector.addLifeCycleAware(lifeCycleAware);
// }
// return lifeCycleAware;
// }
// }
//
// Path: test-data-lib/src/main/java/com/test/MyView.java
// public interface MyView {
// }
//
// Path: lifecyclebinder-api/src/main/java/it/codingjam/lifecyclebinder/LifeCycleAwareCollector.java
// public interface LifeCycleAwareCollector {
// <R> R addRetainedFactory(String key, Callable<R> factory, boolean addInLifeCycleAwareList);
//
// void addLifeCycleAware(LifeCycleAware<?> lifeCycleAware);
//
// <R> R getOrCreate(R lifeCycleAware, String key, Callable<R> factory);
// }
// Path: test-data-lib/src/main/java/com/test/objectWithNestedGenericBaseClass/MyGenericBaseClass$LifeCycleBinder.java
import com.test.MyObject$LifeCycleBinder;
import com.test.MyView;
import it.codingjam.lifecyclebinder.LifeCycleAwareCollector;
/*
* Copyright 2016 Fabio Collini.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.test.objectWithNestedGenericBaseClass;
public class MyGenericBaseClass$LifeCycleBinder {
public static <T extends MyView> MyGenericBaseClass<T> bind(LifeCycleAwareCollector collector, MyGenericBaseClass<T> lifeCycleAware,
boolean addInList) { | MyObject$LifeCycleBinder.bind(collector, collector.getOrCreate(lifeCycleAware.myBaseObject, null, null), true); |
fabioCollini/LifeCycleBinder | test-data-lib/src/main/java/com/test/objectWithGenericBaseClass/MyObjectWithGenericBaseClass$LifeCycleBinder.java | // Path: test-data-lib/src/main/java/com/test/MyObject$LifeCycleBinder.java
// public class MyObject$LifeCycleBinder {
//
// public static MyObject bind(LifeCycleAwareCollector collector, MyObject lifeCycleAware, boolean addInList) {
// if (addInList) {
// collector.addLifeCycleAware(lifeCycleAware);
// }
// return lifeCycleAware;
// }
// }
//
// Path: lifecyclebinder-api/src/main/java/it/codingjam/lifecyclebinder/LifeCycleAwareCollector.java
// public interface LifeCycleAwareCollector {
// <R> R addRetainedFactory(String key, Callable<R> factory, boolean addInLifeCycleAwareList);
//
// void addLifeCycleAware(LifeCycleAware<?> lifeCycleAware);
//
// <R> R getOrCreate(R lifeCycleAware, String key, Callable<R> factory);
// }
| import com.test.MyObject$LifeCycleBinder;
import it.codingjam.lifecyclebinder.LifeCycleAwareCollector; | /*
* Copyright 2016 Fabio Collini.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.test.objectWithGenericBaseClass;
public class MyObjectWithGenericBaseClass$LifeCycleBinder {
public static MyObjectWithGenericBaseClass bind(LifeCycleAwareCollector collector, MyObjectWithGenericBaseClass lifeCycleAware, boolean addInList) { | // Path: test-data-lib/src/main/java/com/test/MyObject$LifeCycleBinder.java
// public class MyObject$LifeCycleBinder {
//
// public static MyObject bind(LifeCycleAwareCollector collector, MyObject lifeCycleAware, boolean addInList) {
// if (addInList) {
// collector.addLifeCycleAware(lifeCycleAware);
// }
// return lifeCycleAware;
// }
// }
//
// Path: lifecyclebinder-api/src/main/java/it/codingjam/lifecyclebinder/LifeCycleAwareCollector.java
// public interface LifeCycleAwareCollector {
// <R> R addRetainedFactory(String key, Callable<R> factory, boolean addInLifeCycleAwareList);
//
// void addLifeCycleAware(LifeCycleAware<?> lifeCycleAware);
//
// <R> R getOrCreate(R lifeCycleAware, String key, Callable<R> factory);
// }
// Path: test-data-lib/src/main/java/com/test/objectWithGenericBaseClass/MyObjectWithGenericBaseClass$LifeCycleBinder.java
import com.test.MyObject$LifeCycleBinder;
import it.codingjam.lifecyclebinder.LifeCycleAwareCollector;
/*
* Copyright 2016 Fabio Collini.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.test.objectWithGenericBaseClass;
public class MyObjectWithGenericBaseClass$LifeCycleBinder {
public static MyObjectWithGenericBaseClass bind(LifeCycleAwareCollector collector, MyObjectWithGenericBaseClass lifeCycleAware, boolean addInList) { | MyObject$LifeCycleBinder.bind(collector, collector.getOrCreate(lifeCycleAware.myObject, null, null), true); |
fabioCollini/LifeCycleBinder | test-data-lib/src/main/java/com/test/objectWithNestedGenericBaseClass/MyObjectWithGenericBaseClass.java | // Path: lifecyclebinder-processor/src/test/java/com/test/MyObject.java
// public class MyObject implements LifeCycleAware<MyView> {
// @Override
// public void onCreate(MyView view, Bundle savedInstanceState, Intent intent, Bundle arguments) {
//
// }
//
// @Override
// public void onStart(MyView view) {
//
// }
//
// @Override
// public void onResume(MyView view) {
//
// }
//
// @Override
// public boolean hasOptionsMenu(MyView view) {
// return false;
// }
//
// @Override
// public void onCreateOptionsMenu(MyView view, Menu menu, MenuInflater inflater) {
//
// }
//
// @Override
// public boolean onOptionsItemSelected(MyView view, MenuItem item) {
// return false;
// }
//
// @Override
// public void onPause(MyView view) {
//
// }
//
// @Override
// public void onStop(MyView view) {
//
// }
//
// @Override
// public void onSaveInstanceState(MyView view, Bundle bundle) {
//
// }
//
// @Override
// public void onDestroy(MyView view, boolean changingConfigurations) {
//
// }
//
// @Override
// public void onActivityResult(MyView view, int requestCode, int resultCode, Intent data) {
//
// }
//
// @Override public void onViewCreated(MyView view, Bundle savedInstanceState) {
//
// }
//
// @Override public void onDestroyView(MyView view) {
//
// }
// }
//
// Path: test-data-lib/src/main/java/com/test/MyView.java
// public interface MyView {
// }
//
// Path: lifecyclebinder-api/src/main/java/it/codingjam/lifecyclebinder/LifeCycleAware.java
// public interface LifeCycleAware<T> {
// void onCreate(T view, Bundle savedInstanceState, Intent intent, Bundle arguments);
//
// void onStart(T view);
//
// void onResume(T view);
//
// boolean hasOptionsMenu(T view);
//
// void onCreateOptionsMenu(T view, Menu menu, MenuInflater inflater);
//
// boolean onOptionsItemSelected(T view, MenuItem item);
//
// void onPause(T view);
//
// void onStop(T view);
//
// void onSaveInstanceState(T view, Bundle bundle);
//
// void onDestroy(T view, boolean changingConfigurations);
//
// void onActivityResult(T view, int requestCode, int resultCode, Intent data);
//
// void onViewCreated(T view, Bundle savedInstanceState);
//
// void onDestroyView(T view);
// }
| import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import com.test.MyObject;
import com.test.MyView;
import it.codingjam.lifecyclebinder.BindLifeCycle;
import it.codingjam.lifecyclebinder.LifeCycleAware; | /*
* Copyright 2016 Fabio Collini.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.test.objectWithNestedGenericBaseClass;
class MyGenericBaseClass<T extends MyView> implements LifeCycleAware<T> {
@BindLifeCycle | // Path: lifecyclebinder-processor/src/test/java/com/test/MyObject.java
// public class MyObject implements LifeCycleAware<MyView> {
// @Override
// public void onCreate(MyView view, Bundle savedInstanceState, Intent intent, Bundle arguments) {
//
// }
//
// @Override
// public void onStart(MyView view) {
//
// }
//
// @Override
// public void onResume(MyView view) {
//
// }
//
// @Override
// public boolean hasOptionsMenu(MyView view) {
// return false;
// }
//
// @Override
// public void onCreateOptionsMenu(MyView view, Menu menu, MenuInflater inflater) {
//
// }
//
// @Override
// public boolean onOptionsItemSelected(MyView view, MenuItem item) {
// return false;
// }
//
// @Override
// public void onPause(MyView view) {
//
// }
//
// @Override
// public void onStop(MyView view) {
//
// }
//
// @Override
// public void onSaveInstanceState(MyView view, Bundle bundle) {
//
// }
//
// @Override
// public void onDestroy(MyView view, boolean changingConfigurations) {
//
// }
//
// @Override
// public void onActivityResult(MyView view, int requestCode, int resultCode, Intent data) {
//
// }
//
// @Override public void onViewCreated(MyView view, Bundle savedInstanceState) {
//
// }
//
// @Override public void onDestroyView(MyView view) {
//
// }
// }
//
// Path: test-data-lib/src/main/java/com/test/MyView.java
// public interface MyView {
// }
//
// Path: lifecyclebinder-api/src/main/java/it/codingjam/lifecyclebinder/LifeCycleAware.java
// public interface LifeCycleAware<T> {
// void onCreate(T view, Bundle savedInstanceState, Intent intent, Bundle arguments);
//
// void onStart(T view);
//
// void onResume(T view);
//
// boolean hasOptionsMenu(T view);
//
// void onCreateOptionsMenu(T view, Menu menu, MenuInflater inflater);
//
// boolean onOptionsItemSelected(T view, MenuItem item);
//
// void onPause(T view);
//
// void onStop(T view);
//
// void onSaveInstanceState(T view, Bundle bundle);
//
// void onDestroy(T view, boolean changingConfigurations);
//
// void onActivityResult(T view, int requestCode, int resultCode, Intent data);
//
// void onViewCreated(T view, Bundle savedInstanceState);
//
// void onDestroyView(T view);
// }
// Path: test-data-lib/src/main/java/com/test/objectWithNestedGenericBaseClass/MyObjectWithGenericBaseClass.java
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import com.test.MyObject;
import com.test.MyView;
import it.codingjam.lifecyclebinder.BindLifeCycle;
import it.codingjam.lifecyclebinder.LifeCycleAware;
/*
* Copyright 2016 Fabio Collini.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.test.objectWithNestedGenericBaseClass;
class MyGenericBaseClass<T extends MyView> implements LifeCycleAware<T> {
@BindLifeCycle | MyObject myBaseObject; |
fabioCollini/LifeCycleBinder | lifecyclebinder-processor/src/test/java/it/codingjam/lifecyclebinder/test/FileLoader.java | // Path: lifecyclebinder-processor/src/main/java/it/codingjam/lifecyclebinder/LifeCycleBinderProcessor.java
// @SupportedAnnotationTypes({
// "it.codingjam.lifecyclebinder.BindLifeCycle",
// "it.codingjam.lifecyclebinder.RetainedObjectProvider",
// "it.codingjam.lifecyclebinder.BindEvent"
// })
// public class LifeCycleBinderProcessor extends AbstractProcessor {
//
// private Types types;
// private Elements elements;
// private Filer filer;
// private Messager messager;
//
// private ElementsCollector elementsCollector;
//
// private BinderGenerator binderGenerator;
//
// @Override
// public synchronized void init(ProcessingEnvironment processingEnv) {
// super.init(processingEnv);
// types = processingEnv.getTypeUtils();
// elements = processingEnv.getElementUtils();
// filer = processingEnv.getFiler();
// messager = processingEnv.getMessager();
// elementsCollector = new ElementsCollector(messager, types, elements);
// binderGenerator = new BinderGenerator(processingEnv, types, messager, elements);
// }
//
// @Override
// public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
// List<LifeCycleAwareInfo> elementsByClass = elementsCollector.createLifeCycleAwareElements(
// roundEnv.getElementsAnnotatedWith(BindLifeCycle.class),
// roundEnv.getElementsAnnotatedWith(RetainedObjectProvider.class),
// roundEnv.getElementsAnnotatedWith(BindEvent.class)
// );
//
// if (elementsByClass == null) {
// return true;
// }
//
// elementsCollector.calculateNestedElements(elementsByClass);
//
// for (LifeCycleAwareInfo entry : elementsByClass) {
// binderGenerator.generateBinder(entry);
// }
// return false;
// }
//
// @Override public SourceVersion getSupportedSourceVersion() {
// return SourceVersion.latestSupported();
// }
// }
| import com.google.testing.compile.JavaFileObjects;
import com.google.testing.compile.JavaSourceSubjectFactory;
import org.truth0.Truth;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import javax.tools.JavaFileObject;
import it.codingjam.lifecyclebinder.LifeCycleBinderProcessor; | StringBuilder b = new StringBuilder();
String s;
while ((s = reader.readLine()) != null) {
b.append(s).append("\n");
}
return JavaFileObjects.forSourceString(source, b.toString());
} catch (Exception e) {
throw new RuntimeException(e);
} finally {
if (reader != null) {
try {
reader.close();
} catch (IOException ignored) {
}
}
}
}
public static void check(String name) {
check(name, name);
}
public static void check(String name, String expected) {
checkSingleFile(name, expected + "$LifeCycleBinder");
}
private static void checkSingleFile(String name, String expected) {
JavaFileObject target = loadClass(name);
Truth.ASSERT.about(JavaSourceSubjectFactory.javaSource())
.that(target) | // Path: lifecyclebinder-processor/src/main/java/it/codingjam/lifecyclebinder/LifeCycleBinderProcessor.java
// @SupportedAnnotationTypes({
// "it.codingjam.lifecyclebinder.BindLifeCycle",
// "it.codingjam.lifecyclebinder.RetainedObjectProvider",
// "it.codingjam.lifecyclebinder.BindEvent"
// })
// public class LifeCycleBinderProcessor extends AbstractProcessor {
//
// private Types types;
// private Elements elements;
// private Filer filer;
// private Messager messager;
//
// private ElementsCollector elementsCollector;
//
// private BinderGenerator binderGenerator;
//
// @Override
// public synchronized void init(ProcessingEnvironment processingEnv) {
// super.init(processingEnv);
// types = processingEnv.getTypeUtils();
// elements = processingEnv.getElementUtils();
// filer = processingEnv.getFiler();
// messager = processingEnv.getMessager();
// elementsCollector = new ElementsCollector(messager, types, elements);
// binderGenerator = new BinderGenerator(processingEnv, types, messager, elements);
// }
//
// @Override
// public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
// List<LifeCycleAwareInfo> elementsByClass = elementsCollector.createLifeCycleAwareElements(
// roundEnv.getElementsAnnotatedWith(BindLifeCycle.class),
// roundEnv.getElementsAnnotatedWith(RetainedObjectProvider.class),
// roundEnv.getElementsAnnotatedWith(BindEvent.class)
// );
//
// if (elementsByClass == null) {
// return true;
// }
//
// elementsCollector.calculateNestedElements(elementsByClass);
//
// for (LifeCycleAwareInfo entry : elementsByClass) {
// binderGenerator.generateBinder(entry);
// }
// return false;
// }
//
// @Override public SourceVersion getSupportedSourceVersion() {
// return SourceVersion.latestSupported();
// }
// }
// Path: lifecyclebinder-processor/src/test/java/it/codingjam/lifecyclebinder/test/FileLoader.java
import com.google.testing.compile.JavaFileObjects;
import com.google.testing.compile.JavaSourceSubjectFactory;
import org.truth0.Truth;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import javax.tools.JavaFileObject;
import it.codingjam.lifecyclebinder.LifeCycleBinderProcessor;
StringBuilder b = new StringBuilder();
String s;
while ((s = reader.readLine()) != null) {
b.append(s).append("\n");
}
return JavaFileObjects.forSourceString(source, b.toString());
} catch (Exception e) {
throw new RuntimeException(e);
} finally {
if (reader != null) {
try {
reader.close();
} catch (IOException ignored) {
}
}
}
}
public static void check(String name) {
check(name, name);
}
public static void check(String name, String expected) {
checkSingleFile(name, expected + "$LifeCycleBinder");
}
private static void checkSingleFile(String name, String expected) {
JavaFileObject target = loadClass(name);
Truth.ASSERT.about(JavaSourceSubjectFactory.javaSource())
.that(target) | .processedWith(new LifeCycleBinderProcessor()) |
fabioCollini/LifeCycleBinder | testapp/src/main/java/it/codingjam/lifecyclebinder/testapp/MyFragment.java | // Path: lifecyclebinder-lib/src/main/java/it/codingjam/lifecyclebinder/LifeCycleBinder.java
// public class LifeCycleBinder {
// public static void bind(Fragment fragment) {
// bind(fragment, fragment.getChildFragmentManager());
// }
//
// public static void bind(FragmentActivity activity) {
// bind(activity, activity.getSupportFragmentManager());
// }
//
// public static <T extends Fragment> void bind(T fragment, Class<?> objectBinderClass) {
// bind(fragment.getChildFragmentManager(), objectBinderClass);
// }
//
// public static <T extends FragmentActivity> void bind(T activity, Class<?> objectBinderClass) {
// bind(activity.getSupportFragmentManager(), objectBinderClass);
// }
//
// private static <T> void bind(T obj, FragmentManager fragmentManager) {
// LifeCycleBinderFragment<T> fragment = LifeCycleBinderFragment.get(fragmentManager);
// if (fragment == null) {
// Class<?> c = ReflectionUtils.getObjectBinderClass(obj);
// fragment = LifeCycleBinderFragment.createAndAdd(fragmentManager, c);
// }
// fragment.invokeOnCreate();
// }
//
// private static <T> void bind(FragmentManager fragmentManager, Class<?> objectBinderClass) {
// LifeCycleBinderFragment<T> fragment = LifeCycleBinderFragment.get(fragmentManager);
// if (fragment == null) {
// fragment = LifeCycleBinderFragment.createAndAdd(fragmentManager, objectBinderClass);
// }
// fragment.invokeOnCreate();
// }
//
// public static void startActivityForResult(FragmentActivity activity, Intent intent, int requestCode) {
// LifeCycleBinderFragment.get(activity.getSupportFragmentManager()).startActivityForResult(intent, requestCode);
// }
//
// public static void startActivityForResult(Fragment fragment, Intent intent, int requestCode) {
// LifeCycleBinderFragment.get(fragment.getChildFragmentManager()).startActivityForResult(intent, requestCode);
// }
// }
| import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import it.codingjam.lifecyclebinder.BindLifeCycle;
import it.codingjam.lifecyclebinder.LifeCycleBinder; | /*
* Copyright 2016 Fabio Collini.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package it.codingjam.lifecyclebinder.testapp;
public class MyFragment extends Fragment {
@BindLifeCycle
public Logger logger = new Logger("MyFragment");
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState); | // Path: lifecyclebinder-lib/src/main/java/it/codingjam/lifecyclebinder/LifeCycleBinder.java
// public class LifeCycleBinder {
// public static void bind(Fragment fragment) {
// bind(fragment, fragment.getChildFragmentManager());
// }
//
// public static void bind(FragmentActivity activity) {
// bind(activity, activity.getSupportFragmentManager());
// }
//
// public static <T extends Fragment> void bind(T fragment, Class<?> objectBinderClass) {
// bind(fragment.getChildFragmentManager(), objectBinderClass);
// }
//
// public static <T extends FragmentActivity> void bind(T activity, Class<?> objectBinderClass) {
// bind(activity.getSupportFragmentManager(), objectBinderClass);
// }
//
// private static <T> void bind(T obj, FragmentManager fragmentManager) {
// LifeCycleBinderFragment<T> fragment = LifeCycleBinderFragment.get(fragmentManager);
// if (fragment == null) {
// Class<?> c = ReflectionUtils.getObjectBinderClass(obj);
// fragment = LifeCycleBinderFragment.createAndAdd(fragmentManager, c);
// }
// fragment.invokeOnCreate();
// }
//
// private static <T> void bind(FragmentManager fragmentManager, Class<?> objectBinderClass) {
// LifeCycleBinderFragment<T> fragment = LifeCycleBinderFragment.get(fragmentManager);
// if (fragment == null) {
// fragment = LifeCycleBinderFragment.createAndAdd(fragmentManager, objectBinderClass);
// }
// fragment.invokeOnCreate();
// }
//
// public static void startActivityForResult(FragmentActivity activity, Intent intent, int requestCode) {
// LifeCycleBinderFragment.get(activity.getSupportFragmentManager()).startActivityForResult(intent, requestCode);
// }
//
// public static void startActivityForResult(Fragment fragment, Intent intent, int requestCode) {
// LifeCycleBinderFragment.get(fragment.getChildFragmentManager()).startActivityForResult(intent, requestCode);
// }
// }
// Path: testapp/src/main/java/it/codingjam/lifecyclebinder/testapp/MyFragment.java
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import it.codingjam.lifecyclebinder.BindLifeCycle;
import it.codingjam.lifecyclebinder.LifeCycleBinder;
/*
* Copyright 2016 Fabio Collini.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package it.codingjam.lifecyclebinder.testapp;
public class MyFragment extends Fragment {
@BindLifeCycle
public Logger logger = new Logger("MyFragment");
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState); | LifeCycleBinder.bind(this); |
fabioCollini/LifeCycleBinder | testapp/src/main/java/it/codingjam/lifecyclebinder/testapp/MainActivity.java | // Path: lifecyclebinder-lib/src/main/java/it/codingjam/lifecyclebinder/LifeCycleBinder.java
// public class LifeCycleBinder {
// public static void bind(Fragment fragment) {
// bind(fragment, fragment.getChildFragmentManager());
// }
//
// public static void bind(FragmentActivity activity) {
// bind(activity, activity.getSupportFragmentManager());
// }
//
// public static <T extends Fragment> void bind(T fragment, Class<?> objectBinderClass) {
// bind(fragment.getChildFragmentManager(), objectBinderClass);
// }
//
// public static <T extends FragmentActivity> void bind(T activity, Class<?> objectBinderClass) {
// bind(activity.getSupportFragmentManager(), objectBinderClass);
// }
//
// private static <T> void bind(T obj, FragmentManager fragmentManager) {
// LifeCycleBinderFragment<T> fragment = LifeCycleBinderFragment.get(fragmentManager);
// if (fragment == null) {
// Class<?> c = ReflectionUtils.getObjectBinderClass(obj);
// fragment = LifeCycleBinderFragment.createAndAdd(fragmentManager, c);
// }
// fragment.invokeOnCreate();
// }
//
// private static <T> void bind(FragmentManager fragmentManager, Class<?> objectBinderClass) {
// LifeCycleBinderFragment<T> fragment = LifeCycleBinderFragment.get(fragmentManager);
// if (fragment == null) {
// fragment = LifeCycleBinderFragment.createAndAdd(fragmentManager, objectBinderClass);
// }
// fragment.invokeOnCreate();
// }
//
// public static void startActivityForResult(FragmentActivity activity, Intent intent, int requestCode) {
// LifeCycleBinderFragment.get(activity.getSupportFragmentManager()).startActivityForResult(intent, requestCode);
// }
//
// public static void startActivityForResult(Fragment fragment, Intent intent, int requestCode) {
// LifeCycleBinderFragment.get(fragment.getChildFragmentManager()).startActivityForResult(intent, requestCode);
// }
// }
| import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.app.AppCompatActivity;
import it.codingjam.lifecyclebinder.BindLifeCycle;
import it.codingjam.lifecyclebinder.LifeCycleBinder; | /*
* Copyright 2016 Fabio Collini.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package it.codingjam.lifecyclebinder.testapp;
public class MainActivity extends AppCompatActivity {
public static final String LAYOUT = "layout";
@BindLifeCycle
public Logger logger = new Logger("MainActivity");
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(getIntent().getIntExtra(LAYOUT, 0));
| // Path: lifecyclebinder-lib/src/main/java/it/codingjam/lifecyclebinder/LifeCycleBinder.java
// public class LifeCycleBinder {
// public static void bind(Fragment fragment) {
// bind(fragment, fragment.getChildFragmentManager());
// }
//
// public static void bind(FragmentActivity activity) {
// bind(activity, activity.getSupportFragmentManager());
// }
//
// public static <T extends Fragment> void bind(T fragment, Class<?> objectBinderClass) {
// bind(fragment.getChildFragmentManager(), objectBinderClass);
// }
//
// public static <T extends FragmentActivity> void bind(T activity, Class<?> objectBinderClass) {
// bind(activity.getSupportFragmentManager(), objectBinderClass);
// }
//
// private static <T> void bind(T obj, FragmentManager fragmentManager) {
// LifeCycleBinderFragment<T> fragment = LifeCycleBinderFragment.get(fragmentManager);
// if (fragment == null) {
// Class<?> c = ReflectionUtils.getObjectBinderClass(obj);
// fragment = LifeCycleBinderFragment.createAndAdd(fragmentManager, c);
// }
// fragment.invokeOnCreate();
// }
//
// private static <T> void bind(FragmentManager fragmentManager, Class<?> objectBinderClass) {
// LifeCycleBinderFragment<T> fragment = LifeCycleBinderFragment.get(fragmentManager);
// if (fragment == null) {
// fragment = LifeCycleBinderFragment.createAndAdd(fragmentManager, objectBinderClass);
// }
// fragment.invokeOnCreate();
// }
//
// public static void startActivityForResult(FragmentActivity activity, Intent intent, int requestCode) {
// LifeCycleBinderFragment.get(activity.getSupportFragmentManager()).startActivityForResult(intent, requestCode);
// }
//
// public static void startActivityForResult(Fragment fragment, Intent intent, int requestCode) {
// LifeCycleBinderFragment.get(fragment.getChildFragmentManager()).startActivityForResult(intent, requestCode);
// }
// }
// Path: testapp/src/main/java/it/codingjam/lifecyclebinder/testapp/MainActivity.java
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.app.AppCompatActivity;
import it.codingjam.lifecyclebinder.BindLifeCycle;
import it.codingjam.lifecyclebinder.LifeCycleBinder;
/*
* Copyright 2016 Fabio Collini.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package it.codingjam.lifecyclebinder.testapp;
public class MainActivity extends AppCompatActivity {
public static final String LAYOUT = "layout";
@BindLifeCycle
public Logger logger = new Logger("MainActivity");
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(getIntent().getIntExtra(LAYOUT, 0));
| LifeCycleBinder.bind(this); |
fabioCollini/LifeCycleBinder | test-data-lib/src/main/java/com/test/retained/ActivityWithRetainedGeneric.java | // Path: test-data-lib/src/main/java/com/test/MyObjectGeneric.java
// public class MyObjectGeneric<T> implements LifeCycleAware<MyView> {
// @Override
// public void onCreate(MyView view, Bundle savedInstanceState, Intent intent, Bundle arguments) {
//
// }
//
// @Override
// public void onStart(MyView view) {
//
// }
//
// @Override
// public void onResume(MyView view) {
//
// }
//
// @Override
// public boolean hasOptionsMenu(MyView view) {
// return false;
// }
//
// @Override
// public void onCreateOptionsMenu(MyView view, Menu menu, MenuInflater inflater) {
//
// }
//
// @Override
// public boolean onOptionsItemSelected(MyView view, MenuItem item) {
// return false;
// }
//
// @Override
// public void onPause(MyView view) {
//
// }
//
// @Override
// public void onStop(MyView view) {
//
// }
//
// @Override
// public void onSaveInstanceState(MyView view, Bundle bundle) {
//
// }
//
// @Override
// public void onDestroy(MyView view, boolean changingConfigurations) {
//
// }
//
// @Override
// public void onActivityResult(MyView view, int requestCode, int resultCode, Intent data) {
//
// }
//
// @Override public void onViewCreated(MyView view, Bundle savedInstanceState) {
//
// }
//
// @Override public void onDestroyView(MyView view) {
//
// }
// }
//
// Path: test-data-lib/src/main/java/com/test/MyView.java
// public interface MyView {
// }
| import android.support.v4.app.FragmentActivity;
import com.test.MyObjectGeneric;
import com.test.MyView;
import java.util.concurrent.Callable;
import it.codingjam.lifecyclebinder.RetainedObjectProvider; | /*
* Copyright 2016 Fabio Collini.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.test.retained;
public class ActivityWithRetainedGeneric extends FragmentActivity implements MyView {
@RetainedObjectProvider | // Path: test-data-lib/src/main/java/com/test/MyObjectGeneric.java
// public class MyObjectGeneric<T> implements LifeCycleAware<MyView> {
// @Override
// public void onCreate(MyView view, Bundle savedInstanceState, Intent intent, Bundle arguments) {
//
// }
//
// @Override
// public void onStart(MyView view) {
//
// }
//
// @Override
// public void onResume(MyView view) {
//
// }
//
// @Override
// public boolean hasOptionsMenu(MyView view) {
// return false;
// }
//
// @Override
// public void onCreateOptionsMenu(MyView view, Menu menu, MenuInflater inflater) {
//
// }
//
// @Override
// public boolean onOptionsItemSelected(MyView view, MenuItem item) {
// return false;
// }
//
// @Override
// public void onPause(MyView view) {
//
// }
//
// @Override
// public void onStop(MyView view) {
//
// }
//
// @Override
// public void onSaveInstanceState(MyView view, Bundle bundle) {
//
// }
//
// @Override
// public void onDestroy(MyView view, boolean changingConfigurations) {
//
// }
//
// @Override
// public void onActivityResult(MyView view, int requestCode, int resultCode, Intent data) {
//
// }
//
// @Override public void onViewCreated(MyView view, Bundle savedInstanceState) {
//
// }
//
// @Override public void onDestroyView(MyView view) {
//
// }
// }
//
// Path: test-data-lib/src/main/java/com/test/MyView.java
// public interface MyView {
// }
// Path: test-data-lib/src/main/java/com/test/retained/ActivityWithRetainedGeneric.java
import android.support.v4.app.FragmentActivity;
import com.test.MyObjectGeneric;
import com.test.MyView;
import java.util.concurrent.Callable;
import it.codingjam.lifecyclebinder.RetainedObjectProvider;
/*
* Copyright 2016 Fabio Collini.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.test.retained;
public class ActivityWithRetainedGeneric extends FragmentActivity implements MyView {
@RetainedObjectProvider | Callable<MyObjectGeneric<String>> myObjectProvider = new Callable<MyObjectGeneric<String>>() { |
fabioCollini/LifeCycleBinder | test-data-lib/src/main/java/com/test/activityWithBaseClass/MyActivityWithBaseClass$LifeCycleBinder.java | // Path: test-data-lib/src/main/java/com/test/MyObject$LifeCycleBinder.java
// public class MyObject$LifeCycleBinder {
//
// public static MyObject bind(LifeCycleAwareCollector collector, MyObject lifeCycleAware, boolean addInList) {
// if (addInList) {
// collector.addLifeCycleAware(lifeCycleAware);
// }
// return lifeCycleAware;
// }
// }
//
// Path: lifecyclebinder-api/src/main/java/it/codingjam/lifecyclebinder/LifeCycleAwareCollector.java
// public interface LifeCycleAwareCollector {
// <R> R addRetainedFactory(String key, Callable<R> factory, boolean addInLifeCycleAwareList);
//
// void addLifeCycleAware(LifeCycleAware<?> lifeCycleAware);
//
// <R> R getOrCreate(R lifeCycleAware, String key, Callable<R> factory);
// }
| import com.test.MyObject$LifeCycleBinder;
import it.codingjam.lifecyclebinder.LifeCycleAwareCollector; | /*
* Copyright 2016 Fabio Collini.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.test.activityWithBaseClass;
public class MyActivityWithBaseClass$LifeCycleBinder {
public static void bind(LifeCycleAwareCollector collector, final MyActivityWithBaseClass view) {
BaseClass$LifeCycleBinder.bind(collector, view); | // Path: test-data-lib/src/main/java/com/test/MyObject$LifeCycleBinder.java
// public class MyObject$LifeCycleBinder {
//
// public static MyObject bind(LifeCycleAwareCollector collector, MyObject lifeCycleAware, boolean addInList) {
// if (addInList) {
// collector.addLifeCycleAware(lifeCycleAware);
// }
// return lifeCycleAware;
// }
// }
//
// Path: lifecyclebinder-api/src/main/java/it/codingjam/lifecyclebinder/LifeCycleAwareCollector.java
// public interface LifeCycleAwareCollector {
// <R> R addRetainedFactory(String key, Callable<R> factory, boolean addInLifeCycleAwareList);
//
// void addLifeCycleAware(LifeCycleAware<?> lifeCycleAware);
//
// <R> R getOrCreate(R lifeCycleAware, String key, Callable<R> factory);
// }
// Path: test-data-lib/src/main/java/com/test/activityWithBaseClass/MyActivityWithBaseClass$LifeCycleBinder.java
import com.test.MyObject$LifeCycleBinder;
import it.codingjam.lifecyclebinder.LifeCycleAwareCollector;
/*
* Copyright 2016 Fabio Collini.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.test.activityWithBaseClass;
public class MyActivityWithBaseClass$LifeCycleBinder {
public static void bind(LifeCycleAwareCollector collector, final MyActivityWithBaseClass view) {
BaseClass$LifeCycleBinder.bind(collector, view); | MyObject$LifeCycleBinder.bind(collector, collector.getOrCreate(view.myObject, null, null), true); |
fabioCollini/LifeCycleBinder | testapp/src/main/java/it/codingjam/lifecyclebinder/testapp/MyRetainedFragment.java | // Path: lifecyclebinder-lib/src/main/java/it/codingjam/lifecyclebinder/LifeCycleBinder.java
// public class LifeCycleBinder {
// public static void bind(Fragment fragment) {
// bind(fragment, fragment.getChildFragmentManager());
// }
//
// public static void bind(FragmentActivity activity) {
// bind(activity, activity.getSupportFragmentManager());
// }
//
// public static <T extends Fragment> void bind(T fragment, Class<?> objectBinderClass) {
// bind(fragment.getChildFragmentManager(), objectBinderClass);
// }
//
// public static <T extends FragmentActivity> void bind(T activity, Class<?> objectBinderClass) {
// bind(activity.getSupportFragmentManager(), objectBinderClass);
// }
//
// private static <T> void bind(T obj, FragmentManager fragmentManager) {
// LifeCycleBinderFragment<T> fragment = LifeCycleBinderFragment.get(fragmentManager);
// if (fragment == null) {
// Class<?> c = ReflectionUtils.getObjectBinderClass(obj);
// fragment = LifeCycleBinderFragment.createAndAdd(fragmentManager, c);
// }
// fragment.invokeOnCreate();
// }
//
// private static <T> void bind(FragmentManager fragmentManager, Class<?> objectBinderClass) {
// LifeCycleBinderFragment<T> fragment = LifeCycleBinderFragment.get(fragmentManager);
// if (fragment == null) {
// fragment = LifeCycleBinderFragment.createAndAdd(fragmentManager, objectBinderClass);
// }
// fragment.invokeOnCreate();
// }
//
// public static void startActivityForResult(FragmentActivity activity, Intent intent, int requestCode) {
// LifeCycleBinderFragment.get(activity.getSupportFragmentManager()).startActivityForResult(intent, requestCode);
// }
//
// public static void startActivityForResult(Fragment fragment, Intent intent, int requestCode) {
// LifeCycleBinderFragment.get(fragment.getChildFragmentManager()).startActivityForResult(intent, requestCode);
// }
// }
| import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import java.util.concurrent.Callable;
import it.codingjam.lifecyclebinder.LifeCycleBinder;
import it.codingjam.lifecyclebinder.RetainedObjectProvider; | /*
* Copyright 2016 Fabio Collini.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package it.codingjam.lifecyclebinder.testapp;
public class MyRetainedFragment extends Fragment {
@RetainedObjectProvider
public Callable<Logger> logger = new Callable<Logger>() {
@Override
public Logger call() throws Exception {
return new Logger("MyRetainedFragment");
}
};
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState); | // Path: lifecyclebinder-lib/src/main/java/it/codingjam/lifecyclebinder/LifeCycleBinder.java
// public class LifeCycleBinder {
// public static void bind(Fragment fragment) {
// bind(fragment, fragment.getChildFragmentManager());
// }
//
// public static void bind(FragmentActivity activity) {
// bind(activity, activity.getSupportFragmentManager());
// }
//
// public static <T extends Fragment> void bind(T fragment, Class<?> objectBinderClass) {
// bind(fragment.getChildFragmentManager(), objectBinderClass);
// }
//
// public static <T extends FragmentActivity> void bind(T activity, Class<?> objectBinderClass) {
// bind(activity.getSupportFragmentManager(), objectBinderClass);
// }
//
// private static <T> void bind(T obj, FragmentManager fragmentManager) {
// LifeCycleBinderFragment<T> fragment = LifeCycleBinderFragment.get(fragmentManager);
// if (fragment == null) {
// Class<?> c = ReflectionUtils.getObjectBinderClass(obj);
// fragment = LifeCycleBinderFragment.createAndAdd(fragmentManager, c);
// }
// fragment.invokeOnCreate();
// }
//
// private static <T> void bind(FragmentManager fragmentManager, Class<?> objectBinderClass) {
// LifeCycleBinderFragment<T> fragment = LifeCycleBinderFragment.get(fragmentManager);
// if (fragment == null) {
// fragment = LifeCycleBinderFragment.createAndAdd(fragmentManager, objectBinderClass);
// }
// fragment.invokeOnCreate();
// }
//
// public static void startActivityForResult(FragmentActivity activity, Intent intent, int requestCode) {
// LifeCycleBinderFragment.get(activity.getSupportFragmentManager()).startActivityForResult(intent, requestCode);
// }
//
// public static void startActivityForResult(Fragment fragment, Intent intent, int requestCode) {
// LifeCycleBinderFragment.get(fragment.getChildFragmentManager()).startActivityForResult(intent, requestCode);
// }
// }
// Path: testapp/src/main/java/it/codingjam/lifecyclebinder/testapp/MyRetainedFragment.java
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import java.util.concurrent.Callable;
import it.codingjam.lifecyclebinder.LifeCycleBinder;
import it.codingjam.lifecyclebinder.RetainedObjectProvider;
/*
* Copyright 2016 Fabio Collini.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package it.codingjam.lifecyclebinder.testapp;
public class MyRetainedFragment extends Fragment {
@RetainedObjectProvider
public Callable<Logger> logger = new Callable<Logger>() {
@Override
public Logger call() throws Exception {
return new Logger("MyRetainedFragment");
}
};
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState); | LifeCycleBinder.bind(this); |
fabioCollini/LifeCycleBinder | test-data-lib/src/main/java/com/test/errors/WrongFieldName.java | // Path: lifecyclebinder-processor/src/test/java/com/test/MyObject.java
// public class MyObject implements LifeCycleAware<MyView> {
// @Override
// public void onCreate(MyView view, Bundle savedInstanceState, Intent intent, Bundle arguments) {
//
// }
//
// @Override
// public void onStart(MyView view) {
//
// }
//
// @Override
// public void onResume(MyView view) {
//
// }
//
// @Override
// public boolean hasOptionsMenu(MyView view) {
// return false;
// }
//
// @Override
// public void onCreateOptionsMenu(MyView view, Menu menu, MenuInflater inflater) {
//
// }
//
// @Override
// public boolean onOptionsItemSelected(MyView view, MenuItem item) {
// return false;
// }
//
// @Override
// public void onPause(MyView view) {
//
// }
//
// @Override
// public void onStop(MyView view) {
//
// }
//
// @Override
// public void onSaveInstanceState(MyView view, Bundle bundle) {
//
// }
//
// @Override
// public void onDestroy(MyView view, boolean changingConfigurations) {
//
// }
//
// @Override
// public void onActivityResult(MyView view, int requestCode, int resultCode, Intent data) {
//
// }
//
// @Override public void onViewCreated(MyView view, Bundle savedInstanceState) {
//
// }
//
// @Override public void onDestroyView(MyView view) {
//
// }
// }
//
// Path: test-data-lib/src/main/java/com/test/MyView.java
// public interface MyView {
// }
| import android.support.v4.app.FragmentActivity;
import com.test.MyObject;
import com.test.MyView;
import java.util.concurrent.Callable;
import it.codingjam.lifecyclebinder.RetainedObjectProvider; | /*
* Copyright 2016 Fabio Collini.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.test.errors;
public class WrongFieldName extends FragmentActivity implements MyView {
@RetainedObjectProvider("wrong") | // Path: lifecyclebinder-processor/src/test/java/com/test/MyObject.java
// public class MyObject implements LifeCycleAware<MyView> {
// @Override
// public void onCreate(MyView view, Bundle savedInstanceState, Intent intent, Bundle arguments) {
//
// }
//
// @Override
// public void onStart(MyView view) {
//
// }
//
// @Override
// public void onResume(MyView view) {
//
// }
//
// @Override
// public boolean hasOptionsMenu(MyView view) {
// return false;
// }
//
// @Override
// public void onCreateOptionsMenu(MyView view, Menu menu, MenuInflater inflater) {
//
// }
//
// @Override
// public boolean onOptionsItemSelected(MyView view, MenuItem item) {
// return false;
// }
//
// @Override
// public void onPause(MyView view) {
//
// }
//
// @Override
// public void onStop(MyView view) {
//
// }
//
// @Override
// public void onSaveInstanceState(MyView view, Bundle bundle) {
//
// }
//
// @Override
// public void onDestroy(MyView view, boolean changingConfigurations) {
//
// }
//
// @Override
// public void onActivityResult(MyView view, int requestCode, int resultCode, Intent data) {
//
// }
//
// @Override public void onViewCreated(MyView view, Bundle savedInstanceState) {
//
// }
//
// @Override public void onDestroyView(MyView view) {
//
// }
// }
//
// Path: test-data-lib/src/main/java/com/test/MyView.java
// public interface MyView {
// }
// Path: test-data-lib/src/main/java/com/test/errors/WrongFieldName.java
import android.support.v4.app.FragmentActivity;
import com.test.MyObject;
import com.test.MyView;
import java.util.concurrent.Callable;
import it.codingjam.lifecyclebinder.RetainedObjectProvider;
/*
* Copyright 2016 Fabio Collini.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.test.errors;
public class WrongFieldName extends FragmentActivity implements MyView {
@RetainedObjectProvider("wrong") | Callable<MyObject> myObjectProvider = new Callable<MyObject>() { |
fabioCollini/LifeCycleBinder | test-data-lib/src/main/java/com/test/nested/ActivityMyObjectWithInnerObject.java | // Path: lifecyclebinder-processor/src/test/java/com/test/MyObject.java
// public class MyObject implements LifeCycleAware<MyView> {
// @Override
// public void onCreate(MyView view, Bundle savedInstanceState, Intent intent, Bundle arguments) {
//
// }
//
// @Override
// public void onStart(MyView view) {
//
// }
//
// @Override
// public void onResume(MyView view) {
//
// }
//
// @Override
// public boolean hasOptionsMenu(MyView view) {
// return false;
// }
//
// @Override
// public void onCreateOptionsMenu(MyView view, Menu menu, MenuInflater inflater) {
//
// }
//
// @Override
// public boolean onOptionsItemSelected(MyView view, MenuItem item) {
// return false;
// }
//
// @Override
// public void onPause(MyView view) {
//
// }
//
// @Override
// public void onStop(MyView view) {
//
// }
//
// @Override
// public void onSaveInstanceState(MyView view, Bundle bundle) {
//
// }
//
// @Override
// public void onDestroy(MyView view, boolean changingConfigurations) {
//
// }
//
// @Override
// public void onActivityResult(MyView view, int requestCode, int resultCode, Intent data) {
//
// }
//
// @Override public void onViewCreated(MyView view, Bundle savedInstanceState) {
//
// }
//
// @Override public void onDestroyView(MyView view) {
//
// }
// }
//
// Path: test-data-lib/src/main/java/com/test/MyView.java
// public interface MyView {
// }
//
// Path: lifecyclebinder-api/src/main/java/it/codingjam/lifecyclebinder/LifeCycleAware.java
// public interface LifeCycleAware<T> {
// void onCreate(T view, Bundle savedInstanceState, Intent intent, Bundle arguments);
//
// void onStart(T view);
//
// void onResume(T view);
//
// boolean hasOptionsMenu(T view);
//
// void onCreateOptionsMenu(T view, Menu menu, MenuInflater inflater);
//
// boolean onOptionsItemSelected(T view, MenuItem item);
//
// void onPause(T view);
//
// void onStop(T view);
//
// void onSaveInstanceState(T view, Bundle bundle);
//
// void onDestroy(T view, boolean changingConfigurations);
//
// void onActivityResult(T view, int requestCode, int resultCode, Intent data);
//
// void onViewCreated(T view, Bundle savedInstanceState);
//
// void onDestroyView(T view);
// }
| import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import com.test.MyObject;
import com.test.MyView;
import it.codingjam.lifecyclebinder.BindLifeCycle;
import it.codingjam.lifecyclebinder.LifeCycleAware;
import it.codingjam.lifecyclebinder.RetainedObjectProvider;
import java.util.concurrent.Callable; | /*
* Copyright 2016 Fabio Collini.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.test.nested;
class MyObjectWithInnerObject implements LifeCycleAware<Object> {
@BindLifeCycle | // Path: lifecyclebinder-processor/src/test/java/com/test/MyObject.java
// public class MyObject implements LifeCycleAware<MyView> {
// @Override
// public void onCreate(MyView view, Bundle savedInstanceState, Intent intent, Bundle arguments) {
//
// }
//
// @Override
// public void onStart(MyView view) {
//
// }
//
// @Override
// public void onResume(MyView view) {
//
// }
//
// @Override
// public boolean hasOptionsMenu(MyView view) {
// return false;
// }
//
// @Override
// public void onCreateOptionsMenu(MyView view, Menu menu, MenuInflater inflater) {
//
// }
//
// @Override
// public boolean onOptionsItemSelected(MyView view, MenuItem item) {
// return false;
// }
//
// @Override
// public void onPause(MyView view) {
//
// }
//
// @Override
// public void onStop(MyView view) {
//
// }
//
// @Override
// public void onSaveInstanceState(MyView view, Bundle bundle) {
//
// }
//
// @Override
// public void onDestroy(MyView view, boolean changingConfigurations) {
//
// }
//
// @Override
// public void onActivityResult(MyView view, int requestCode, int resultCode, Intent data) {
//
// }
//
// @Override public void onViewCreated(MyView view, Bundle savedInstanceState) {
//
// }
//
// @Override public void onDestroyView(MyView view) {
//
// }
// }
//
// Path: test-data-lib/src/main/java/com/test/MyView.java
// public interface MyView {
// }
//
// Path: lifecyclebinder-api/src/main/java/it/codingjam/lifecyclebinder/LifeCycleAware.java
// public interface LifeCycleAware<T> {
// void onCreate(T view, Bundle savedInstanceState, Intent intent, Bundle arguments);
//
// void onStart(T view);
//
// void onResume(T view);
//
// boolean hasOptionsMenu(T view);
//
// void onCreateOptionsMenu(T view, Menu menu, MenuInflater inflater);
//
// boolean onOptionsItemSelected(T view, MenuItem item);
//
// void onPause(T view);
//
// void onStop(T view);
//
// void onSaveInstanceState(T view, Bundle bundle);
//
// void onDestroy(T view, boolean changingConfigurations);
//
// void onActivityResult(T view, int requestCode, int resultCode, Intent data);
//
// void onViewCreated(T view, Bundle savedInstanceState);
//
// void onDestroyView(T view);
// }
// Path: test-data-lib/src/main/java/com/test/nested/ActivityMyObjectWithInnerObject.java
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import com.test.MyObject;
import com.test.MyView;
import it.codingjam.lifecyclebinder.BindLifeCycle;
import it.codingjam.lifecyclebinder.LifeCycleAware;
import it.codingjam.lifecyclebinder.RetainedObjectProvider;
import java.util.concurrent.Callable;
/*
* Copyright 2016 Fabio Collini.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.test.nested;
class MyObjectWithInnerObject implements LifeCycleAware<Object> {
@BindLifeCycle | MyObject myObject; |
fabioCollini/LifeCycleBinder | test-data-lib/src/main/java/com/test/nested/ActivityMyObjectWithInnerObject.java | // Path: lifecyclebinder-processor/src/test/java/com/test/MyObject.java
// public class MyObject implements LifeCycleAware<MyView> {
// @Override
// public void onCreate(MyView view, Bundle savedInstanceState, Intent intent, Bundle arguments) {
//
// }
//
// @Override
// public void onStart(MyView view) {
//
// }
//
// @Override
// public void onResume(MyView view) {
//
// }
//
// @Override
// public boolean hasOptionsMenu(MyView view) {
// return false;
// }
//
// @Override
// public void onCreateOptionsMenu(MyView view, Menu menu, MenuInflater inflater) {
//
// }
//
// @Override
// public boolean onOptionsItemSelected(MyView view, MenuItem item) {
// return false;
// }
//
// @Override
// public void onPause(MyView view) {
//
// }
//
// @Override
// public void onStop(MyView view) {
//
// }
//
// @Override
// public void onSaveInstanceState(MyView view, Bundle bundle) {
//
// }
//
// @Override
// public void onDestroy(MyView view, boolean changingConfigurations) {
//
// }
//
// @Override
// public void onActivityResult(MyView view, int requestCode, int resultCode, Intent data) {
//
// }
//
// @Override public void onViewCreated(MyView view, Bundle savedInstanceState) {
//
// }
//
// @Override public void onDestroyView(MyView view) {
//
// }
// }
//
// Path: test-data-lib/src/main/java/com/test/MyView.java
// public interface MyView {
// }
//
// Path: lifecyclebinder-api/src/main/java/it/codingjam/lifecyclebinder/LifeCycleAware.java
// public interface LifeCycleAware<T> {
// void onCreate(T view, Bundle savedInstanceState, Intent intent, Bundle arguments);
//
// void onStart(T view);
//
// void onResume(T view);
//
// boolean hasOptionsMenu(T view);
//
// void onCreateOptionsMenu(T view, Menu menu, MenuInflater inflater);
//
// boolean onOptionsItemSelected(T view, MenuItem item);
//
// void onPause(T view);
//
// void onStop(T view);
//
// void onSaveInstanceState(T view, Bundle bundle);
//
// void onDestroy(T view, boolean changingConfigurations);
//
// void onActivityResult(T view, int requestCode, int resultCode, Intent data);
//
// void onViewCreated(T view, Bundle savedInstanceState);
//
// void onDestroyView(T view);
// }
| import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import com.test.MyObject;
import com.test.MyView;
import it.codingjam.lifecyclebinder.BindLifeCycle;
import it.codingjam.lifecyclebinder.LifeCycleAware;
import it.codingjam.lifecyclebinder.RetainedObjectProvider;
import java.util.concurrent.Callable; |
@Override
public void onStop(Object view) {
}
@Override
public void onSaveInstanceState(Object view, Bundle bundle) {
}
@Override
public void onDestroy(Object view, boolean changingConfigurations) {
}
@Override
public void onActivityResult(Object view, int requestCode, int resultCode, Intent data) {
}
@Override public void onViewCreated(Object view, Bundle savedInstanceState) {
}
@Override public void onDestroyView(Object view) {
}
}
| // Path: lifecyclebinder-processor/src/test/java/com/test/MyObject.java
// public class MyObject implements LifeCycleAware<MyView> {
// @Override
// public void onCreate(MyView view, Bundle savedInstanceState, Intent intent, Bundle arguments) {
//
// }
//
// @Override
// public void onStart(MyView view) {
//
// }
//
// @Override
// public void onResume(MyView view) {
//
// }
//
// @Override
// public boolean hasOptionsMenu(MyView view) {
// return false;
// }
//
// @Override
// public void onCreateOptionsMenu(MyView view, Menu menu, MenuInflater inflater) {
//
// }
//
// @Override
// public boolean onOptionsItemSelected(MyView view, MenuItem item) {
// return false;
// }
//
// @Override
// public void onPause(MyView view) {
//
// }
//
// @Override
// public void onStop(MyView view) {
//
// }
//
// @Override
// public void onSaveInstanceState(MyView view, Bundle bundle) {
//
// }
//
// @Override
// public void onDestroy(MyView view, boolean changingConfigurations) {
//
// }
//
// @Override
// public void onActivityResult(MyView view, int requestCode, int resultCode, Intent data) {
//
// }
//
// @Override public void onViewCreated(MyView view, Bundle savedInstanceState) {
//
// }
//
// @Override public void onDestroyView(MyView view) {
//
// }
// }
//
// Path: test-data-lib/src/main/java/com/test/MyView.java
// public interface MyView {
// }
//
// Path: lifecyclebinder-api/src/main/java/it/codingjam/lifecyclebinder/LifeCycleAware.java
// public interface LifeCycleAware<T> {
// void onCreate(T view, Bundle savedInstanceState, Intent intent, Bundle arguments);
//
// void onStart(T view);
//
// void onResume(T view);
//
// boolean hasOptionsMenu(T view);
//
// void onCreateOptionsMenu(T view, Menu menu, MenuInflater inflater);
//
// boolean onOptionsItemSelected(T view, MenuItem item);
//
// void onPause(T view);
//
// void onStop(T view);
//
// void onSaveInstanceState(T view, Bundle bundle);
//
// void onDestroy(T view, boolean changingConfigurations);
//
// void onActivityResult(T view, int requestCode, int resultCode, Intent data);
//
// void onViewCreated(T view, Bundle savedInstanceState);
//
// void onDestroyView(T view);
// }
// Path: test-data-lib/src/main/java/com/test/nested/ActivityMyObjectWithInnerObject.java
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import com.test.MyObject;
import com.test.MyView;
import it.codingjam.lifecyclebinder.BindLifeCycle;
import it.codingjam.lifecyclebinder.LifeCycleAware;
import it.codingjam.lifecyclebinder.RetainedObjectProvider;
import java.util.concurrent.Callable;
@Override
public void onStop(Object view) {
}
@Override
public void onSaveInstanceState(Object view, Bundle bundle) {
}
@Override
public void onDestroy(Object view, boolean changingConfigurations) {
}
@Override
public void onActivityResult(Object view, int requestCode, int resultCode, Intent data) {
}
@Override public void onViewCreated(Object view, Bundle savedInstanceState) {
}
@Override public void onDestroyView(Object view) {
}
}
| public class ActivityMyObjectWithInnerObject extends FragmentActivity implements MyView { |
fabioCollini/LifeCycleBinder | test-data-lib/src/main/java/com/test/retained/ActivityWithRetainedAndField.java | // Path: lifecyclebinder-processor/src/test/java/com/test/MyObject.java
// public class MyObject implements LifeCycleAware<MyView> {
// @Override
// public void onCreate(MyView view, Bundle savedInstanceState, Intent intent, Bundle arguments) {
//
// }
//
// @Override
// public void onStart(MyView view) {
//
// }
//
// @Override
// public void onResume(MyView view) {
//
// }
//
// @Override
// public boolean hasOptionsMenu(MyView view) {
// return false;
// }
//
// @Override
// public void onCreateOptionsMenu(MyView view, Menu menu, MenuInflater inflater) {
//
// }
//
// @Override
// public boolean onOptionsItemSelected(MyView view, MenuItem item) {
// return false;
// }
//
// @Override
// public void onPause(MyView view) {
//
// }
//
// @Override
// public void onStop(MyView view) {
//
// }
//
// @Override
// public void onSaveInstanceState(MyView view, Bundle bundle) {
//
// }
//
// @Override
// public void onDestroy(MyView view, boolean changingConfigurations) {
//
// }
//
// @Override
// public void onActivityResult(MyView view, int requestCode, int resultCode, Intent data) {
//
// }
//
// @Override public void onViewCreated(MyView view, Bundle savedInstanceState) {
//
// }
//
// @Override public void onDestroyView(MyView view) {
//
// }
// }
//
// Path: test-data-lib/src/main/java/com/test/MyView.java
// public interface MyView {
// }
| import android.support.v4.app.FragmentActivity;
import com.test.MyObject;
import com.test.MyView;
import java.util.concurrent.Callable;
import it.codingjam.lifecyclebinder.RetainedObjectProvider; | /*
* Copyright 2016 Fabio Collini.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.test.retained;
public class ActivityWithRetainedAndField extends FragmentActivity implements MyView {
@RetainedObjectProvider("myObject") | // Path: lifecyclebinder-processor/src/test/java/com/test/MyObject.java
// public class MyObject implements LifeCycleAware<MyView> {
// @Override
// public void onCreate(MyView view, Bundle savedInstanceState, Intent intent, Bundle arguments) {
//
// }
//
// @Override
// public void onStart(MyView view) {
//
// }
//
// @Override
// public void onResume(MyView view) {
//
// }
//
// @Override
// public boolean hasOptionsMenu(MyView view) {
// return false;
// }
//
// @Override
// public void onCreateOptionsMenu(MyView view, Menu menu, MenuInflater inflater) {
//
// }
//
// @Override
// public boolean onOptionsItemSelected(MyView view, MenuItem item) {
// return false;
// }
//
// @Override
// public void onPause(MyView view) {
//
// }
//
// @Override
// public void onStop(MyView view) {
//
// }
//
// @Override
// public void onSaveInstanceState(MyView view, Bundle bundle) {
//
// }
//
// @Override
// public void onDestroy(MyView view, boolean changingConfigurations) {
//
// }
//
// @Override
// public void onActivityResult(MyView view, int requestCode, int resultCode, Intent data) {
//
// }
//
// @Override public void onViewCreated(MyView view, Bundle savedInstanceState) {
//
// }
//
// @Override public void onDestroyView(MyView view) {
//
// }
// }
//
// Path: test-data-lib/src/main/java/com/test/MyView.java
// public interface MyView {
// }
// Path: test-data-lib/src/main/java/com/test/retained/ActivityWithRetainedAndField.java
import android.support.v4.app.FragmentActivity;
import com.test.MyObject;
import com.test.MyView;
import java.util.concurrent.Callable;
import it.codingjam.lifecyclebinder.RetainedObjectProvider;
/*
* Copyright 2016 Fabio Collini.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.test.retained;
public class ActivityWithRetainedAndField extends FragmentActivity implements MyView {
@RetainedObjectProvider("myObject") | Callable<MyObject> myObjectProvider = new Callable<MyObject>() { |
fabioCollini/LifeCycleBinder | lifecyclebinder-processor/src/main/java/it/codingjam/lifecyclebinder/data/RetainedObjectInfo.java | // Path: lifecyclebinder-processor/src/main/java/it/codingjam/lifecyclebinder/utils/TypeUtils.java
// public class TypeUtils {
// public static boolean isRawTypeEquals(TypeMirror type1, TypeMirror type2) {
// return getRawType(type1).equals(getRawType(type2));
// }
//
// public static ClassName getRawType(TypeMirror type) {
// TypeName typeName = TypeName.get(type);
// return getRawType(typeName);
// }
//
// public static ClassName getRawType(TypeName typeName) {
// if (typeName instanceof ParameterizedTypeName) {
// return ((ParameterizedTypeName) typeName).rawType;
// } else {
// return (ClassName) typeName;
// }
// }
//
// public static List<TypeName> getTypeArguments(TypeMirror mirror) {
// TypeName typeName = ParameterizedTypeName.get(mirror);
// return getTypeArguments(typeName);
// }
//
// public static List<TypeName> getTypeArguments(TypeName typeName) {
// if (typeName instanceof ParameterizedTypeName) {
// return ((ParameterizedTypeName) typeName).typeArguments;
// } else {
// return Collections.emptyList();
// }
// }
//
// public static boolean isAssignable(Elements elements, TypeName t1, TypeName t2) {
// TypeElement e1 = elements.getTypeElement(getRawType(t1).toString());
// List<? extends TypeMirror> interfaces = e1.getInterfaces();
// for (TypeMirror anInterface : interfaces) {
// if (getRawType(anInterface).equals(getRawType(t2))) {
// return true;
// }
// }
// TypeMirror superclass = e1.getSuperclass();
// if (TypeName.get(superclass).equals(TypeName.get(Object.class))) {
// return false;
// } else {
// return isAssignable(elements, getRawType(superclass), t2);
// }
// }
// }
| import com.squareup.javapoet.ClassName;
import com.squareup.javapoet.ParameterizedTypeName;
import com.squareup.javapoet.TypeName;
import javax.lang.model.element.VariableElement;
import it.codingjam.lifecyclebinder.RetainedObjectProvider;
import it.codingjam.lifecyclebinder.utils.TypeUtils; | /*
* Copyright 2016 Fabio Collini.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package it.codingjam.lifecyclebinder.data;
public class RetainedObjectInfo {
public final String name;
public final VariableElement field;
public final TypeName typeName;
public final TypeName binderClassName;
public final String fieldToPopulate;
public RetainedObjectInfo(VariableElement field) {
this.name = field.getSimpleName().toString();
this.field = field; | // Path: lifecyclebinder-processor/src/main/java/it/codingjam/lifecyclebinder/utils/TypeUtils.java
// public class TypeUtils {
// public static boolean isRawTypeEquals(TypeMirror type1, TypeMirror type2) {
// return getRawType(type1).equals(getRawType(type2));
// }
//
// public static ClassName getRawType(TypeMirror type) {
// TypeName typeName = TypeName.get(type);
// return getRawType(typeName);
// }
//
// public static ClassName getRawType(TypeName typeName) {
// if (typeName instanceof ParameterizedTypeName) {
// return ((ParameterizedTypeName) typeName).rawType;
// } else {
// return (ClassName) typeName;
// }
// }
//
// public static List<TypeName> getTypeArguments(TypeMirror mirror) {
// TypeName typeName = ParameterizedTypeName.get(mirror);
// return getTypeArguments(typeName);
// }
//
// public static List<TypeName> getTypeArguments(TypeName typeName) {
// if (typeName instanceof ParameterizedTypeName) {
// return ((ParameterizedTypeName) typeName).typeArguments;
// } else {
// return Collections.emptyList();
// }
// }
//
// public static boolean isAssignable(Elements elements, TypeName t1, TypeName t2) {
// TypeElement e1 = elements.getTypeElement(getRawType(t1).toString());
// List<? extends TypeMirror> interfaces = e1.getInterfaces();
// for (TypeMirror anInterface : interfaces) {
// if (getRawType(anInterface).equals(getRawType(t2))) {
// return true;
// }
// }
// TypeMirror superclass = e1.getSuperclass();
// if (TypeName.get(superclass).equals(TypeName.get(Object.class))) {
// return false;
// } else {
// return isAssignable(elements, getRawType(superclass), t2);
// }
// }
// }
// Path: lifecyclebinder-processor/src/main/java/it/codingjam/lifecyclebinder/data/RetainedObjectInfo.java
import com.squareup.javapoet.ClassName;
import com.squareup.javapoet.ParameterizedTypeName;
import com.squareup.javapoet.TypeName;
import javax.lang.model.element.VariableElement;
import it.codingjam.lifecyclebinder.RetainedObjectProvider;
import it.codingjam.lifecyclebinder.utils.TypeUtils;
/*
* Copyright 2016 Fabio Collini.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package it.codingjam.lifecyclebinder.data;
public class RetainedObjectInfo {
public final String name;
public final VariableElement field;
public final TypeName typeName;
public final TypeName binderClassName;
public final String fieldToPopulate;
public RetainedObjectInfo(VariableElement field) {
this.name = field.getSimpleName().toString();
this.field = field; | this.typeName = TypeUtils.getTypeArguments(field.asType()).get(0); |
fabioCollini/LifeCycleBinder | lifecyclebinder-processor/src/test/java/it/codingjam/lifecyclebinder/test/ProcessorTest.java | // Path: lifecyclebinder-processor/src/main/java/it/codingjam/lifecyclebinder/LifeCycleBinderProcessor.java
// @SupportedAnnotationTypes({
// "it.codingjam.lifecyclebinder.BindLifeCycle",
// "it.codingjam.lifecyclebinder.RetainedObjectProvider",
// "it.codingjam.lifecyclebinder.BindEvent"
// })
// public class LifeCycleBinderProcessor extends AbstractProcessor {
//
// private Types types;
// private Elements elements;
// private Filer filer;
// private Messager messager;
//
// private ElementsCollector elementsCollector;
//
// private BinderGenerator binderGenerator;
//
// @Override
// public synchronized void init(ProcessingEnvironment processingEnv) {
// super.init(processingEnv);
// types = processingEnv.getTypeUtils();
// elements = processingEnv.getElementUtils();
// filer = processingEnv.getFiler();
// messager = processingEnv.getMessager();
// elementsCollector = new ElementsCollector(messager, types, elements);
// binderGenerator = new BinderGenerator(processingEnv, types, messager, elements);
// }
//
// @Override
// public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
// List<LifeCycleAwareInfo> elementsByClass = elementsCollector.createLifeCycleAwareElements(
// roundEnv.getElementsAnnotatedWith(BindLifeCycle.class),
// roundEnv.getElementsAnnotatedWith(RetainedObjectProvider.class),
// roundEnv.getElementsAnnotatedWith(BindEvent.class)
// );
//
// if (elementsByClass == null) {
// return true;
// }
//
// elementsCollector.calculateNestedElements(elementsByClass);
//
// for (LifeCycleAwareInfo entry : elementsByClass) {
// binderGenerator.generateBinder(entry);
// }
// return false;
// }
//
// @Override public SourceVersion getSupportedSourceVersion() {
// return SourceVersion.latestSupported();
// }
// }
//
// Path: lifecyclebinder-processor/src/test/java/it/codingjam/lifecyclebinder/test/FileLoader.java
// public static void check(String name) {
// check(name, name);
// }
| import com.google.testing.compile.JavaSourceSubjectFactory;
import org.junit.Test;
import org.truth0.Truth;
import javax.tools.JavaFileObject;
import it.codingjam.lifecyclebinder.LifeCycleBinderProcessor;
import static it.codingjam.lifecyclebinder.test.FileLoader.check; | /*
* Copyright 2016 Fabio Collini.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package it.codingjam.lifecyclebinder.test;
public class ProcessorTest {
@Test public void testMyObject() throws Exception { | // Path: lifecyclebinder-processor/src/main/java/it/codingjam/lifecyclebinder/LifeCycleBinderProcessor.java
// @SupportedAnnotationTypes({
// "it.codingjam.lifecyclebinder.BindLifeCycle",
// "it.codingjam.lifecyclebinder.RetainedObjectProvider",
// "it.codingjam.lifecyclebinder.BindEvent"
// })
// public class LifeCycleBinderProcessor extends AbstractProcessor {
//
// private Types types;
// private Elements elements;
// private Filer filer;
// private Messager messager;
//
// private ElementsCollector elementsCollector;
//
// private BinderGenerator binderGenerator;
//
// @Override
// public synchronized void init(ProcessingEnvironment processingEnv) {
// super.init(processingEnv);
// types = processingEnv.getTypeUtils();
// elements = processingEnv.getElementUtils();
// filer = processingEnv.getFiler();
// messager = processingEnv.getMessager();
// elementsCollector = new ElementsCollector(messager, types, elements);
// binderGenerator = new BinderGenerator(processingEnv, types, messager, elements);
// }
//
// @Override
// public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
// List<LifeCycleAwareInfo> elementsByClass = elementsCollector.createLifeCycleAwareElements(
// roundEnv.getElementsAnnotatedWith(BindLifeCycle.class),
// roundEnv.getElementsAnnotatedWith(RetainedObjectProvider.class),
// roundEnv.getElementsAnnotatedWith(BindEvent.class)
// );
//
// if (elementsByClass == null) {
// return true;
// }
//
// elementsCollector.calculateNestedElements(elementsByClass);
//
// for (LifeCycleAwareInfo entry : elementsByClass) {
// binderGenerator.generateBinder(entry);
// }
// return false;
// }
//
// @Override public SourceVersion getSupportedSourceVersion() {
// return SourceVersion.latestSupported();
// }
// }
//
// Path: lifecyclebinder-processor/src/test/java/it/codingjam/lifecyclebinder/test/FileLoader.java
// public static void check(String name) {
// check(name, name);
// }
// Path: lifecyclebinder-processor/src/test/java/it/codingjam/lifecyclebinder/test/ProcessorTest.java
import com.google.testing.compile.JavaSourceSubjectFactory;
import org.junit.Test;
import org.truth0.Truth;
import javax.tools.JavaFileObject;
import it.codingjam.lifecyclebinder.LifeCycleBinderProcessor;
import static it.codingjam.lifecyclebinder.test.FileLoader.check;
/*
* Copyright 2016 Fabio Collini.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package it.codingjam.lifecyclebinder.test;
public class ProcessorTest {
@Test public void testMyObject() throws Exception { | check("com.test.myObject.MyObject"); |
fabioCollini/LifeCycleBinder | lifecyclebinder-processor/src/test/java/it/codingjam/lifecyclebinder/test/ProcessorTest.java | // Path: lifecyclebinder-processor/src/main/java/it/codingjam/lifecyclebinder/LifeCycleBinderProcessor.java
// @SupportedAnnotationTypes({
// "it.codingjam.lifecyclebinder.BindLifeCycle",
// "it.codingjam.lifecyclebinder.RetainedObjectProvider",
// "it.codingjam.lifecyclebinder.BindEvent"
// })
// public class LifeCycleBinderProcessor extends AbstractProcessor {
//
// private Types types;
// private Elements elements;
// private Filer filer;
// private Messager messager;
//
// private ElementsCollector elementsCollector;
//
// private BinderGenerator binderGenerator;
//
// @Override
// public synchronized void init(ProcessingEnvironment processingEnv) {
// super.init(processingEnv);
// types = processingEnv.getTypeUtils();
// elements = processingEnv.getElementUtils();
// filer = processingEnv.getFiler();
// messager = processingEnv.getMessager();
// elementsCollector = new ElementsCollector(messager, types, elements);
// binderGenerator = new BinderGenerator(processingEnv, types, messager, elements);
// }
//
// @Override
// public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
// List<LifeCycleAwareInfo> elementsByClass = elementsCollector.createLifeCycleAwareElements(
// roundEnv.getElementsAnnotatedWith(BindLifeCycle.class),
// roundEnv.getElementsAnnotatedWith(RetainedObjectProvider.class),
// roundEnv.getElementsAnnotatedWith(BindEvent.class)
// );
//
// if (elementsByClass == null) {
// return true;
// }
//
// elementsCollector.calculateNestedElements(elementsByClass);
//
// for (LifeCycleAwareInfo entry : elementsByClass) {
// binderGenerator.generateBinder(entry);
// }
// return false;
// }
//
// @Override public SourceVersion getSupportedSourceVersion() {
// return SourceVersion.latestSupported();
// }
// }
//
// Path: lifecyclebinder-processor/src/test/java/it/codingjam/lifecyclebinder/test/FileLoader.java
// public static void check(String name) {
// check(name, name);
// }
| import com.google.testing.compile.JavaSourceSubjectFactory;
import org.junit.Test;
import org.truth0.Truth;
import javax.tools.JavaFileObject;
import it.codingjam.lifecyclebinder.LifeCycleBinderProcessor;
import static it.codingjam.lifecyclebinder.test.FileLoader.check; |
@Test public void testActivityWithBaseClass() throws Exception {
check("com.test.activityWithBaseClass.MyActivityWithBaseClass");
}
@Test public void testObjectWithBaseClass() throws Exception {
check("com.test.objectWithBaseClass.MyObjectWithBaseClass");
}
@Test public void testObjectWithGenericBaseClass() throws Exception {
check("com.test.objectWithGenericBaseClass.MyObjectWithGenericBaseClass");
}
@Test public void testObjectWithNestedGenericBaseClass() throws Exception {
check("com.test.objectWithNestedGenericBaseClass.MyObjectWithGenericBaseClass");
}
//@Test public void testActivityObjectNotExtendsLifeCycleAware() throws Exception {
// JavaFileObject target = FileLoader.loadClass("com.test.errors.ActivityObjectNotExtendsLifeCycleAware");
// Truth.ASSERT.about(JavaSourceSubjectFactory.javaSource())
// .that(target)
// .processedWith(new LifeCycleBinderProcessor())
// .failsToCompile()
// .withErrorContaining("must implement " + LifeCycleAware.class.getSimpleName());
//}
@Test public void testWrongFieldName() throws Exception {
JavaFileObject target = FileLoader.loadClass("com.test.errors.WrongFieldName");
Truth.ASSERT.about(JavaSourceSubjectFactory.javaSource())
.that(target) | // Path: lifecyclebinder-processor/src/main/java/it/codingjam/lifecyclebinder/LifeCycleBinderProcessor.java
// @SupportedAnnotationTypes({
// "it.codingjam.lifecyclebinder.BindLifeCycle",
// "it.codingjam.lifecyclebinder.RetainedObjectProvider",
// "it.codingjam.lifecyclebinder.BindEvent"
// })
// public class LifeCycleBinderProcessor extends AbstractProcessor {
//
// private Types types;
// private Elements elements;
// private Filer filer;
// private Messager messager;
//
// private ElementsCollector elementsCollector;
//
// private BinderGenerator binderGenerator;
//
// @Override
// public synchronized void init(ProcessingEnvironment processingEnv) {
// super.init(processingEnv);
// types = processingEnv.getTypeUtils();
// elements = processingEnv.getElementUtils();
// filer = processingEnv.getFiler();
// messager = processingEnv.getMessager();
// elementsCollector = new ElementsCollector(messager, types, elements);
// binderGenerator = new BinderGenerator(processingEnv, types, messager, elements);
// }
//
// @Override
// public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
// List<LifeCycleAwareInfo> elementsByClass = elementsCollector.createLifeCycleAwareElements(
// roundEnv.getElementsAnnotatedWith(BindLifeCycle.class),
// roundEnv.getElementsAnnotatedWith(RetainedObjectProvider.class),
// roundEnv.getElementsAnnotatedWith(BindEvent.class)
// );
//
// if (elementsByClass == null) {
// return true;
// }
//
// elementsCollector.calculateNestedElements(elementsByClass);
//
// for (LifeCycleAwareInfo entry : elementsByClass) {
// binderGenerator.generateBinder(entry);
// }
// return false;
// }
//
// @Override public SourceVersion getSupportedSourceVersion() {
// return SourceVersion.latestSupported();
// }
// }
//
// Path: lifecyclebinder-processor/src/test/java/it/codingjam/lifecyclebinder/test/FileLoader.java
// public static void check(String name) {
// check(name, name);
// }
// Path: lifecyclebinder-processor/src/test/java/it/codingjam/lifecyclebinder/test/ProcessorTest.java
import com.google.testing.compile.JavaSourceSubjectFactory;
import org.junit.Test;
import org.truth0.Truth;
import javax.tools.JavaFileObject;
import it.codingjam.lifecyclebinder.LifeCycleBinderProcessor;
import static it.codingjam.lifecyclebinder.test.FileLoader.check;
@Test public void testActivityWithBaseClass() throws Exception {
check("com.test.activityWithBaseClass.MyActivityWithBaseClass");
}
@Test public void testObjectWithBaseClass() throws Exception {
check("com.test.objectWithBaseClass.MyObjectWithBaseClass");
}
@Test public void testObjectWithGenericBaseClass() throws Exception {
check("com.test.objectWithGenericBaseClass.MyObjectWithGenericBaseClass");
}
@Test public void testObjectWithNestedGenericBaseClass() throws Exception {
check("com.test.objectWithNestedGenericBaseClass.MyObjectWithGenericBaseClass");
}
//@Test public void testActivityObjectNotExtendsLifeCycleAware() throws Exception {
// JavaFileObject target = FileLoader.loadClass("com.test.errors.ActivityObjectNotExtendsLifeCycleAware");
// Truth.ASSERT.about(JavaSourceSubjectFactory.javaSource())
// .that(target)
// .processedWith(new LifeCycleBinderProcessor())
// .failsToCompile()
// .withErrorContaining("must implement " + LifeCycleAware.class.getSimpleName());
//}
@Test public void testWrongFieldName() throws Exception {
JavaFileObject target = FileLoader.loadClass("com.test.errors.WrongFieldName");
Truth.ASSERT.about(JavaSourceSubjectFactory.javaSource())
.that(target) | .processedWith(new LifeCycleBinderProcessor()) |
fabioCollini/LifeCycleBinder | test-data-lib/src/main/java/com/test/retainedObjectsInBaseClassWithProvider/ActivityWithRetainedProvider.java | // Path: lifecyclebinder-processor/src/test/java/com/test/MyObject.java
// public class MyObject implements LifeCycleAware<MyView> {
// @Override
// public void onCreate(MyView view, Bundle savedInstanceState, Intent intent, Bundle arguments) {
//
// }
//
// @Override
// public void onStart(MyView view) {
//
// }
//
// @Override
// public void onResume(MyView view) {
//
// }
//
// @Override
// public boolean hasOptionsMenu(MyView view) {
// return false;
// }
//
// @Override
// public void onCreateOptionsMenu(MyView view, Menu menu, MenuInflater inflater) {
//
// }
//
// @Override
// public boolean onOptionsItemSelected(MyView view, MenuItem item) {
// return false;
// }
//
// @Override
// public void onPause(MyView view) {
//
// }
//
// @Override
// public void onStop(MyView view) {
//
// }
//
// @Override
// public void onSaveInstanceState(MyView view, Bundle bundle) {
//
// }
//
// @Override
// public void onDestroy(MyView view, boolean changingConfigurations) {
//
// }
//
// @Override
// public void onActivityResult(MyView view, int requestCode, int resultCode, Intent data) {
//
// }
//
// @Override public void onViewCreated(MyView view, Bundle savedInstanceState) {
//
// }
//
// @Override public void onDestroyView(MyView view) {
//
// }
// }
//
// Path: test-data-lib/src/main/java/com/test/MyView.java
// public interface MyView {
// }
| import com.test.MyObject;
import com.test.MyView;
import it.codingjam.lifecyclebinder.RetainedObjectProvider; | /*
* Copyright 2016 Fabio Collini.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.test.retainedObjectsInBaseClassWithProvider;
interface Provider<T> {
T get();
}
| // Path: lifecyclebinder-processor/src/test/java/com/test/MyObject.java
// public class MyObject implements LifeCycleAware<MyView> {
// @Override
// public void onCreate(MyView view, Bundle savedInstanceState, Intent intent, Bundle arguments) {
//
// }
//
// @Override
// public void onStart(MyView view) {
//
// }
//
// @Override
// public void onResume(MyView view) {
//
// }
//
// @Override
// public boolean hasOptionsMenu(MyView view) {
// return false;
// }
//
// @Override
// public void onCreateOptionsMenu(MyView view, Menu menu, MenuInflater inflater) {
//
// }
//
// @Override
// public boolean onOptionsItemSelected(MyView view, MenuItem item) {
// return false;
// }
//
// @Override
// public void onPause(MyView view) {
//
// }
//
// @Override
// public void onStop(MyView view) {
//
// }
//
// @Override
// public void onSaveInstanceState(MyView view, Bundle bundle) {
//
// }
//
// @Override
// public void onDestroy(MyView view, boolean changingConfigurations) {
//
// }
//
// @Override
// public void onActivityResult(MyView view, int requestCode, int resultCode, Intent data) {
//
// }
//
// @Override public void onViewCreated(MyView view, Bundle savedInstanceState) {
//
// }
//
// @Override public void onDestroyView(MyView view) {
//
// }
// }
//
// Path: test-data-lib/src/main/java/com/test/MyView.java
// public interface MyView {
// }
// Path: test-data-lib/src/main/java/com/test/retainedObjectsInBaseClassWithProvider/ActivityWithRetainedProvider.java
import com.test.MyObject;
import com.test.MyView;
import it.codingjam.lifecyclebinder.RetainedObjectProvider;
/*
* Copyright 2016 Fabio Collini.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.test.retainedObjectsInBaseClassWithProvider;
interface Provider<T> {
T get();
}
| class BaseActivity<T> implements MyView { |
fabioCollini/LifeCycleBinder | test-data-lib/src/main/java/com/test/retainedObjectsInBaseClassWithProvider/ActivityWithRetainedProvider.java | // Path: lifecyclebinder-processor/src/test/java/com/test/MyObject.java
// public class MyObject implements LifeCycleAware<MyView> {
// @Override
// public void onCreate(MyView view, Bundle savedInstanceState, Intent intent, Bundle arguments) {
//
// }
//
// @Override
// public void onStart(MyView view) {
//
// }
//
// @Override
// public void onResume(MyView view) {
//
// }
//
// @Override
// public boolean hasOptionsMenu(MyView view) {
// return false;
// }
//
// @Override
// public void onCreateOptionsMenu(MyView view, Menu menu, MenuInflater inflater) {
//
// }
//
// @Override
// public boolean onOptionsItemSelected(MyView view, MenuItem item) {
// return false;
// }
//
// @Override
// public void onPause(MyView view) {
//
// }
//
// @Override
// public void onStop(MyView view) {
//
// }
//
// @Override
// public void onSaveInstanceState(MyView view, Bundle bundle) {
//
// }
//
// @Override
// public void onDestroy(MyView view, boolean changingConfigurations) {
//
// }
//
// @Override
// public void onActivityResult(MyView view, int requestCode, int resultCode, Intent data) {
//
// }
//
// @Override public void onViewCreated(MyView view, Bundle savedInstanceState) {
//
// }
//
// @Override public void onDestroyView(MyView view) {
//
// }
// }
//
// Path: test-data-lib/src/main/java/com/test/MyView.java
// public interface MyView {
// }
| import com.test.MyObject;
import com.test.MyView;
import it.codingjam.lifecyclebinder.RetainedObjectProvider; | /*
* Copyright 2016 Fabio Collini.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.test.retainedObjectsInBaseClassWithProvider;
interface Provider<T> {
T get();
}
class BaseActivity<T> implements MyView {
T myObjectInBaseActivity;
}
| // Path: lifecyclebinder-processor/src/test/java/com/test/MyObject.java
// public class MyObject implements LifeCycleAware<MyView> {
// @Override
// public void onCreate(MyView view, Bundle savedInstanceState, Intent intent, Bundle arguments) {
//
// }
//
// @Override
// public void onStart(MyView view) {
//
// }
//
// @Override
// public void onResume(MyView view) {
//
// }
//
// @Override
// public boolean hasOptionsMenu(MyView view) {
// return false;
// }
//
// @Override
// public void onCreateOptionsMenu(MyView view, Menu menu, MenuInflater inflater) {
//
// }
//
// @Override
// public boolean onOptionsItemSelected(MyView view, MenuItem item) {
// return false;
// }
//
// @Override
// public void onPause(MyView view) {
//
// }
//
// @Override
// public void onStop(MyView view) {
//
// }
//
// @Override
// public void onSaveInstanceState(MyView view, Bundle bundle) {
//
// }
//
// @Override
// public void onDestroy(MyView view, boolean changingConfigurations) {
//
// }
//
// @Override
// public void onActivityResult(MyView view, int requestCode, int resultCode, Intent data) {
//
// }
//
// @Override public void onViewCreated(MyView view, Bundle savedInstanceState) {
//
// }
//
// @Override public void onDestroyView(MyView view) {
//
// }
// }
//
// Path: test-data-lib/src/main/java/com/test/MyView.java
// public interface MyView {
// }
// Path: test-data-lib/src/main/java/com/test/retainedObjectsInBaseClassWithProvider/ActivityWithRetainedProvider.java
import com.test.MyObject;
import com.test.MyView;
import it.codingjam.lifecyclebinder.RetainedObjectProvider;
/*
* Copyright 2016 Fabio Collini.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.test.retainedObjectsInBaseClassWithProvider;
interface Provider<T> {
T get();
}
class BaseActivity<T> implements MyView {
T myObjectInBaseActivity;
}
| public class ActivityWithRetainedProvider extends BaseActivity<MyObject> { |
fabioCollini/LifeCycleBinder | test-data-lib/src/main/java/com/test/MyObjectWithEvents$LifeCycleBinder.java | // Path: lifecyclebinder-api/src/main/java/it/codingjam/lifecyclebinder/DefaultLifeCycleAware.java
// public class DefaultLifeCycleAware<T> implements LifeCycleAware<T> {
// @Override
// public void onCreate(T view, Bundle savedInstanceState, Intent intent, Bundle arguments) {
// }
//
// @Override
// public void onStart(T view) {
// }
//
// @Override
// public void onResume(T view) {
// }
//
// @Override
// public boolean hasOptionsMenu(T view) {
// return false;
// }
//
// @Override
// public void onCreateOptionsMenu(T view, Menu menu, MenuInflater inflater) {
// }
//
// @Override
// public boolean onOptionsItemSelected(T view, MenuItem item) {
// return false;
// }
//
// @Override
// public void onPause(T view) {
// }
//
// @Override
// public void onStop(T view) {
// }
//
// @Override
// public void onSaveInstanceState(T view, Bundle bundle) {
// }
//
// @Override
// public void onDestroy(T view, boolean changingConfigurations) {
// }
//
// @Override
// public void onActivityResult(T view, int requestCode, int resultCode, Intent data) {
// }
//
// @Override public void onViewCreated(T view, Bundle savedInstanceState) {
// }
//
// @Override public void onDestroyView(T view) {
// }
// }
//
// Path: lifecyclebinder-api/src/main/java/it/codingjam/lifecyclebinder/LifeCycleAwareCollector.java
// public interface LifeCycleAwareCollector {
// <R> R addRetainedFactory(String key, Callable<R> factory, boolean addInLifeCycleAwareList);
//
// void addLifeCycleAware(LifeCycleAware<?> lifeCycleAware);
//
// <R> R getOrCreate(R lifeCycleAware, String key, Callable<R> factory);
// }
| import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import it.codingjam.lifecyclebinder.DefaultLifeCycleAware;
import it.codingjam.lifecyclebinder.LifeCycleAwareCollector; | package com.test;
public class MyObjectWithEvents$LifeCycleBinder {
public static MyObjectWithEvents bind(LifeCycleAwareCollector collector, final MyObjectWithEvents lifeCycleAware, boolean addInList) {
if (addInList) { | // Path: lifecyclebinder-api/src/main/java/it/codingjam/lifecyclebinder/DefaultLifeCycleAware.java
// public class DefaultLifeCycleAware<T> implements LifeCycleAware<T> {
// @Override
// public void onCreate(T view, Bundle savedInstanceState, Intent intent, Bundle arguments) {
// }
//
// @Override
// public void onStart(T view) {
// }
//
// @Override
// public void onResume(T view) {
// }
//
// @Override
// public boolean hasOptionsMenu(T view) {
// return false;
// }
//
// @Override
// public void onCreateOptionsMenu(T view, Menu menu, MenuInflater inflater) {
// }
//
// @Override
// public boolean onOptionsItemSelected(T view, MenuItem item) {
// return false;
// }
//
// @Override
// public void onPause(T view) {
// }
//
// @Override
// public void onStop(T view) {
// }
//
// @Override
// public void onSaveInstanceState(T view, Bundle bundle) {
// }
//
// @Override
// public void onDestroy(T view, boolean changingConfigurations) {
// }
//
// @Override
// public void onActivityResult(T view, int requestCode, int resultCode, Intent data) {
// }
//
// @Override public void onViewCreated(T view, Bundle savedInstanceState) {
// }
//
// @Override public void onDestroyView(T view) {
// }
// }
//
// Path: lifecyclebinder-api/src/main/java/it/codingjam/lifecyclebinder/LifeCycleAwareCollector.java
// public interface LifeCycleAwareCollector {
// <R> R addRetainedFactory(String key, Callable<R> factory, boolean addInLifeCycleAwareList);
//
// void addLifeCycleAware(LifeCycleAware<?> lifeCycleAware);
//
// <R> R getOrCreate(R lifeCycleAware, String key, Callable<R> factory);
// }
// Path: test-data-lib/src/main/java/com/test/MyObjectWithEvents$LifeCycleBinder.java
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import it.codingjam.lifecyclebinder.DefaultLifeCycleAware;
import it.codingjam.lifecyclebinder.LifeCycleAwareCollector;
package com.test;
public class MyObjectWithEvents$LifeCycleBinder {
public static MyObjectWithEvents bind(LifeCycleAwareCollector collector, final MyObjectWithEvents lifeCycleAware, boolean addInList) {
if (addInList) { | collector.addLifeCycleAware(new DefaultLifeCycleAware<MyView>() { |
fabioCollini/LifeCycleBinder | test-data-lib/src/main/java/com/test/nested/MyObjectWithInnerObject$LifeCycleBinder.java | // Path: test-data-lib/src/main/java/com/test/MyObject$LifeCycleBinder.java
// public class MyObject$LifeCycleBinder {
//
// public static MyObject bind(LifeCycleAwareCollector collector, MyObject lifeCycleAware, boolean addInList) {
// if (addInList) {
// collector.addLifeCycleAware(lifeCycleAware);
// }
// return lifeCycleAware;
// }
// }
//
// Path: lifecyclebinder-api/src/main/java/it/codingjam/lifecyclebinder/LifeCycleAwareCollector.java
// public interface LifeCycleAwareCollector {
// <R> R addRetainedFactory(String key, Callable<R> factory, boolean addInLifeCycleAwareList);
//
// void addLifeCycleAware(LifeCycleAware<?> lifeCycleAware);
//
// <R> R getOrCreate(R lifeCycleAware, String key, Callable<R> factory);
// }
| import com.test.MyObject$LifeCycleBinder;
import it.codingjam.lifecyclebinder.LifeCycleAwareCollector; | /*
* Copyright 2016 Fabio Collini.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.test.nested;
public class MyObjectWithInnerObject$LifeCycleBinder {
public static MyObjectWithInnerObject bind(LifeCycleAwareCollector collector, MyObjectWithInnerObject lifeCycleAware, boolean addInList) { | // Path: test-data-lib/src/main/java/com/test/MyObject$LifeCycleBinder.java
// public class MyObject$LifeCycleBinder {
//
// public static MyObject bind(LifeCycleAwareCollector collector, MyObject lifeCycleAware, boolean addInList) {
// if (addInList) {
// collector.addLifeCycleAware(lifeCycleAware);
// }
// return lifeCycleAware;
// }
// }
//
// Path: lifecyclebinder-api/src/main/java/it/codingjam/lifecyclebinder/LifeCycleAwareCollector.java
// public interface LifeCycleAwareCollector {
// <R> R addRetainedFactory(String key, Callable<R> factory, boolean addInLifeCycleAwareList);
//
// void addLifeCycleAware(LifeCycleAware<?> lifeCycleAware);
//
// <R> R getOrCreate(R lifeCycleAware, String key, Callable<R> factory);
// }
// Path: test-data-lib/src/main/java/com/test/nested/MyObjectWithInnerObject$LifeCycleBinder.java
import com.test.MyObject$LifeCycleBinder;
import it.codingjam.lifecyclebinder.LifeCycleAwareCollector;
/*
* Copyright 2016 Fabio Collini.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.test.nested;
public class MyObjectWithInnerObject$LifeCycleBinder {
public static MyObjectWithInnerObject bind(LifeCycleAwareCollector collector, MyObjectWithInnerObject lifeCycleAware, boolean addInList) { | lifeCycleAware.myObject2 = MyObject$LifeCycleBinder.bind(collector, collector.getOrCreate(null, "myObject2Provider", lifeCycleAware.myObject2Provider), true); |
fabioCollini/LifeCycleBinder | test-data-lib/src/main/java/com/test/retainedEvents/MyObjectWithEvents2$LifeCycleBinder.java | // Path: test-data-lib/src/main/java/com/test/MyView.java
// public interface MyView {
// }
//
// Path: lifecyclebinder-api/src/main/java/it/codingjam/lifecyclebinder/DefaultLifeCycleAware.java
// public class DefaultLifeCycleAware<T> implements LifeCycleAware<T> {
// @Override
// public void onCreate(T view, Bundle savedInstanceState, Intent intent, Bundle arguments) {
// }
//
// @Override
// public void onStart(T view) {
// }
//
// @Override
// public void onResume(T view) {
// }
//
// @Override
// public boolean hasOptionsMenu(T view) {
// return false;
// }
//
// @Override
// public void onCreateOptionsMenu(T view, Menu menu, MenuInflater inflater) {
// }
//
// @Override
// public boolean onOptionsItemSelected(T view, MenuItem item) {
// return false;
// }
//
// @Override
// public void onPause(T view) {
// }
//
// @Override
// public void onStop(T view) {
// }
//
// @Override
// public void onSaveInstanceState(T view, Bundle bundle) {
// }
//
// @Override
// public void onDestroy(T view, boolean changingConfigurations) {
// }
//
// @Override
// public void onActivityResult(T view, int requestCode, int resultCode, Intent data) {
// }
//
// @Override public void onViewCreated(T view, Bundle savedInstanceState) {
// }
//
// @Override public void onDestroyView(T view) {
// }
// }
//
// Path: lifecyclebinder-api/src/main/java/it/codingjam/lifecyclebinder/LifeCycleAwareCollector.java
// public interface LifeCycleAwareCollector {
// <R> R addRetainedFactory(String key, Callable<R> factory, boolean addInLifeCycleAwareList);
//
// void addLifeCycleAware(LifeCycleAware<?> lifeCycleAware);
//
// <R> R getOrCreate(R lifeCycleAware, String key, Callable<R> factory);
// }
| import android.content.Intent;
import android.os.Bundle;
import com.test.MyView;
import it.codingjam.lifecyclebinder.DefaultLifeCycleAware;
import it.codingjam.lifecyclebinder.LifeCycleAwareCollector; | package com.test.retainedEvents;
public class MyObjectWithEvents2$LifeCycleBinder {
public static MyObjectWithEvents2 bind(LifeCycleAwareCollector collector, final MyObjectWithEvents2 lifeCycleAware, boolean addInList) {
if (addInList) { | // Path: test-data-lib/src/main/java/com/test/MyView.java
// public interface MyView {
// }
//
// Path: lifecyclebinder-api/src/main/java/it/codingjam/lifecyclebinder/DefaultLifeCycleAware.java
// public class DefaultLifeCycleAware<T> implements LifeCycleAware<T> {
// @Override
// public void onCreate(T view, Bundle savedInstanceState, Intent intent, Bundle arguments) {
// }
//
// @Override
// public void onStart(T view) {
// }
//
// @Override
// public void onResume(T view) {
// }
//
// @Override
// public boolean hasOptionsMenu(T view) {
// return false;
// }
//
// @Override
// public void onCreateOptionsMenu(T view, Menu menu, MenuInflater inflater) {
// }
//
// @Override
// public boolean onOptionsItemSelected(T view, MenuItem item) {
// return false;
// }
//
// @Override
// public void onPause(T view) {
// }
//
// @Override
// public void onStop(T view) {
// }
//
// @Override
// public void onSaveInstanceState(T view, Bundle bundle) {
// }
//
// @Override
// public void onDestroy(T view, boolean changingConfigurations) {
// }
//
// @Override
// public void onActivityResult(T view, int requestCode, int resultCode, Intent data) {
// }
//
// @Override public void onViewCreated(T view, Bundle savedInstanceState) {
// }
//
// @Override public void onDestroyView(T view) {
// }
// }
//
// Path: lifecyclebinder-api/src/main/java/it/codingjam/lifecyclebinder/LifeCycleAwareCollector.java
// public interface LifeCycleAwareCollector {
// <R> R addRetainedFactory(String key, Callable<R> factory, boolean addInLifeCycleAwareList);
//
// void addLifeCycleAware(LifeCycleAware<?> lifeCycleAware);
//
// <R> R getOrCreate(R lifeCycleAware, String key, Callable<R> factory);
// }
// Path: test-data-lib/src/main/java/com/test/retainedEvents/MyObjectWithEvents2$LifeCycleBinder.java
import android.content.Intent;
import android.os.Bundle;
import com.test.MyView;
import it.codingjam.lifecyclebinder.DefaultLifeCycleAware;
import it.codingjam.lifecyclebinder.LifeCycleAwareCollector;
package com.test.retainedEvents;
public class MyObjectWithEvents2$LifeCycleBinder {
public static MyObjectWithEvents2 bind(LifeCycleAwareCollector collector, final MyObjectWithEvents2 lifeCycleAware, boolean addInList) {
if (addInList) { | collector.addLifeCycleAware(new DefaultLifeCycleAware<MyView>() { |
fabioCollini/LifeCycleBinder | test-data-lib/src/main/java/com/test/retainedEvents/MyObjectWithEvents2$LifeCycleBinder.java | // Path: test-data-lib/src/main/java/com/test/MyView.java
// public interface MyView {
// }
//
// Path: lifecyclebinder-api/src/main/java/it/codingjam/lifecyclebinder/DefaultLifeCycleAware.java
// public class DefaultLifeCycleAware<T> implements LifeCycleAware<T> {
// @Override
// public void onCreate(T view, Bundle savedInstanceState, Intent intent, Bundle arguments) {
// }
//
// @Override
// public void onStart(T view) {
// }
//
// @Override
// public void onResume(T view) {
// }
//
// @Override
// public boolean hasOptionsMenu(T view) {
// return false;
// }
//
// @Override
// public void onCreateOptionsMenu(T view, Menu menu, MenuInflater inflater) {
// }
//
// @Override
// public boolean onOptionsItemSelected(T view, MenuItem item) {
// return false;
// }
//
// @Override
// public void onPause(T view) {
// }
//
// @Override
// public void onStop(T view) {
// }
//
// @Override
// public void onSaveInstanceState(T view, Bundle bundle) {
// }
//
// @Override
// public void onDestroy(T view, boolean changingConfigurations) {
// }
//
// @Override
// public void onActivityResult(T view, int requestCode, int resultCode, Intent data) {
// }
//
// @Override public void onViewCreated(T view, Bundle savedInstanceState) {
// }
//
// @Override public void onDestroyView(T view) {
// }
// }
//
// Path: lifecyclebinder-api/src/main/java/it/codingjam/lifecyclebinder/LifeCycleAwareCollector.java
// public interface LifeCycleAwareCollector {
// <R> R addRetainedFactory(String key, Callable<R> factory, boolean addInLifeCycleAwareList);
//
// void addLifeCycleAware(LifeCycleAware<?> lifeCycleAware);
//
// <R> R getOrCreate(R lifeCycleAware, String key, Callable<R> factory);
// }
| import android.content.Intent;
import android.os.Bundle;
import com.test.MyView;
import it.codingjam.lifecyclebinder.DefaultLifeCycleAware;
import it.codingjam.lifecyclebinder.LifeCycleAwareCollector; | package com.test.retainedEvents;
public class MyObjectWithEvents2$LifeCycleBinder {
public static MyObjectWithEvents2 bind(LifeCycleAwareCollector collector, final MyObjectWithEvents2 lifeCycleAware, boolean addInList) {
if (addInList) { | // Path: test-data-lib/src/main/java/com/test/MyView.java
// public interface MyView {
// }
//
// Path: lifecyclebinder-api/src/main/java/it/codingjam/lifecyclebinder/DefaultLifeCycleAware.java
// public class DefaultLifeCycleAware<T> implements LifeCycleAware<T> {
// @Override
// public void onCreate(T view, Bundle savedInstanceState, Intent intent, Bundle arguments) {
// }
//
// @Override
// public void onStart(T view) {
// }
//
// @Override
// public void onResume(T view) {
// }
//
// @Override
// public boolean hasOptionsMenu(T view) {
// return false;
// }
//
// @Override
// public void onCreateOptionsMenu(T view, Menu menu, MenuInflater inflater) {
// }
//
// @Override
// public boolean onOptionsItemSelected(T view, MenuItem item) {
// return false;
// }
//
// @Override
// public void onPause(T view) {
// }
//
// @Override
// public void onStop(T view) {
// }
//
// @Override
// public void onSaveInstanceState(T view, Bundle bundle) {
// }
//
// @Override
// public void onDestroy(T view, boolean changingConfigurations) {
// }
//
// @Override
// public void onActivityResult(T view, int requestCode, int resultCode, Intent data) {
// }
//
// @Override public void onViewCreated(T view, Bundle savedInstanceState) {
// }
//
// @Override public void onDestroyView(T view) {
// }
// }
//
// Path: lifecyclebinder-api/src/main/java/it/codingjam/lifecyclebinder/LifeCycleAwareCollector.java
// public interface LifeCycleAwareCollector {
// <R> R addRetainedFactory(String key, Callable<R> factory, boolean addInLifeCycleAwareList);
//
// void addLifeCycleAware(LifeCycleAware<?> lifeCycleAware);
//
// <R> R getOrCreate(R lifeCycleAware, String key, Callable<R> factory);
// }
// Path: test-data-lib/src/main/java/com/test/retainedEvents/MyObjectWithEvents2$LifeCycleBinder.java
import android.content.Intent;
import android.os.Bundle;
import com.test.MyView;
import it.codingjam.lifecyclebinder.DefaultLifeCycleAware;
import it.codingjam.lifecyclebinder.LifeCycleAwareCollector;
package com.test.retainedEvents;
public class MyObjectWithEvents2$LifeCycleBinder {
public static MyObjectWithEvents2 bind(LifeCycleAwareCollector collector, final MyObjectWithEvents2 lifeCycleAware, boolean addInList) {
if (addInList) { | collector.addLifeCycleAware(new DefaultLifeCycleAware<MyView>() { |
fabioCollini/LifeCycleBinder | test-data-lib/src/main/java/com/test/retainedObjectsWithProvider/ActivityWithRetainedProvider$LifeCycleBinder.java | // Path: lifecyclebinder-processor/src/test/java/com/test/MyObject.java
// public class MyObject implements LifeCycleAware<MyView> {
// @Override
// public void onCreate(MyView view, Bundle savedInstanceState, Intent intent, Bundle arguments) {
//
// }
//
// @Override
// public void onStart(MyView view) {
//
// }
//
// @Override
// public void onResume(MyView view) {
//
// }
//
// @Override
// public boolean hasOptionsMenu(MyView view) {
// return false;
// }
//
// @Override
// public void onCreateOptionsMenu(MyView view, Menu menu, MenuInflater inflater) {
//
// }
//
// @Override
// public boolean onOptionsItemSelected(MyView view, MenuItem item) {
// return false;
// }
//
// @Override
// public void onPause(MyView view) {
//
// }
//
// @Override
// public void onStop(MyView view) {
//
// }
//
// @Override
// public void onSaveInstanceState(MyView view, Bundle bundle) {
//
// }
//
// @Override
// public void onDestroy(MyView view, boolean changingConfigurations) {
//
// }
//
// @Override
// public void onActivityResult(MyView view, int requestCode, int resultCode, Intent data) {
//
// }
//
// @Override public void onViewCreated(MyView view, Bundle savedInstanceState) {
//
// }
//
// @Override public void onDestroyView(MyView view) {
//
// }
// }
//
// Path: test-data-lib/src/main/java/com/test/MyObject$LifeCycleBinder.java
// public class MyObject$LifeCycleBinder {
//
// public static MyObject bind(LifeCycleAwareCollector collector, MyObject lifeCycleAware, boolean addInList) {
// if (addInList) {
// collector.addLifeCycleAware(lifeCycleAware);
// }
// return lifeCycleAware;
// }
// }
//
// Path: lifecyclebinder-api/src/main/java/it/codingjam/lifecyclebinder/LifeCycleAwareCollector.java
// public interface LifeCycleAwareCollector {
// <R> R addRetainedFactory(String key, Callable<R> factory, boolean addInLifeCycleAwareList);
//
// void addLifeCycleAware(LifeCycleAware<?> lifeCycleAware);
//
// <R> R getOrCreate(R lifeCycleAware, String key, Callable<R> factory);
// }
| import com.test.MyObject;
import com.test.MyObject$LifeCycleBinder;
import it.codingjam.lifecyclebinder.LifeCycleAwareCollector;
import java.util.concurrent.Callable; | package com.test.retainedObjectsWithProvider;
public class ActivityWithRetainedProvider$LifeCycleBinder {
public static void bind(LifeCycleAwareCollector collector, final ActivityWithRetainedProvider view) { | // Path: lifecyclebinder-processor/src/test/java/com/test/MyObject.java
// public class MyObject implements LifeCycleAware<MyView> {
// @Override
// public void onCreate(MyView view, Bundle savedInstanceState, Intent intent, Bundle arguments) {
//
// }
//
// @Override
// public void onStart(MyView view) {
//
// }
//
// @Override
// public void onResume(MyView view) {
//
// }
//
// @Override
// public boolean hasOptionsMenu(MyView view) {
// return false;
// }
//
// @Override
// public void onCreateOptionsMenu(MyView view, Menu menu, MenuInflater inflater) {
//
// }
//
// @Override
// public boolean onOptionsItemSelected(MyView view, MenuItem item) {
// return false;
// }
//
// @Override
// public void onPause(MyView view) {
//
// }
//
// @Override
// public void onStop(MyView view) {
//
// }
//
// @Override
// public void onSaveInstanceState(MyView view, Bundle bundle) {
//
// }
//
// @Override
// public void onDestroy(MyView view, boolean changingConfigurations) {
//
// }
//
// @Override
// public void onActivityResult(MyView view, int requestCode, int resultCode, Intent data) {
//
// }
//
// @Override public void onViewCreated(MyView view, Bundle savedInstanceState) {
//
// }
//
// @Override public void onDestroyView(MyView view) {
//
// }
// }
//
// Path: test-data-lib/src/main/java/com/test/MyObject$LifeCycleBinder.java
// public class MyObject$LifeCycleBinder {
//
// public static MyObject bind(LifeCycleAwareCollector collector, MyObject lifeCycleAware, boolean addInList) {
// if (addInList) {
// collector.addLifeCycleAware(lifeCycleAware);
// }
// return lifeCycleAware;
// }
// }
//
// Path: lifecyclebinder-api/src/main/java/it/codingjam/lifecyclebinder/LifeCycleAwareCollector.java
// public interface LifeCycleAwareCollector {
// <R> R addRetainedFactory(String key, Callable<R> factory, boolean addInLifeCycleAwareList);
//
// void addLifeCycleAware(LifeCycleAware<?> lifeCycleAware);
//
// <R> R getOrCreate(R lifeCycleAware, String key, Callable<R> factory);
// }
// Path: test-data-lib/src/main/java/com/test/retainedObjectsWithProvider/ActivityWithRetainedProvider$LifeCycleBinder.java
import com.test.MyObject;
import com.test.MyObject$LifeCycleBinder;
import it.codingjam.lifecyclebinder.LifeCycleAwareCollector;
import java.util.concurrent.Callable;
package com.test.retainedObjectsWithProvider;
public class ActivityWithRetainedProvider$LifeCycleBinder {
public static void bind(LifeCycleAwareCollector collector, final ActivityWithRetainedProvider view) { | MyObject$LifeCycleBinder.bind(collector, collector.getOrCreate(null, "myObject", new Callable<MyObject>() { |
fabioCollini/LifeCycleBinder | test-data-lib/src/main/java/com/test/retainedObjectsWithProvider/ActivityWithRetainedProvider$LifeCycleBinder.java | // Path: lifecyclebinder-processor/src/test/java/com/test/MyObject.java
// public class MyObject implements LifeCycleAware<MyView> {
// @Override
// public void onCreate(MyView view, Bundle savedInstanceState, Intent intent, Bundle arguments) {
//
// }
//
// @Override
// public void onStart(MyView view) {
//
// }
//
// @Override
// public void onResume(MyView view) {
//
// }
//
// @Override
// public boolean hasOptionsMenu(MyView view) {
// return false;
// }
//
// @Override
// public void onCreateOptionsMenu(MyView view, Menu menu, MenuInflater inflater) {
//
// }
//
// @Override
// public boolean onOptionsItemSelected(MyView view, MenuItem item) {
// return false;
// }
//
// @Override
// public void onPause(MyView view) {
//
// }
//
// @Override
// public void onStop(MyView view) {
//
// }
//
// @Override
// public void onSaveInstanceState(MyView view, Bundle bundle) {
//
// }
//
// @Override
// public void onDestroy(MyView view, boolean changingConfigurations) {
//
// }
//
// @Override
// public void onActivityResult(MyView view, int requestCode, int resultCode, Intent data) {
//
// }
//
// @Override public void onViewCreated(MyView view, Bundle savedInstanceState) {
//
// }
//
// @Override public void onDestroyView(MyView view) {
//
// }
// }
//
// Path: test-data-lib/src/main/java/com/test/MyObject$LifeCycleBinder.java
// public class MyObject$LifeCycleBinder {
//
// public static MyObject bind(LifeCycleAwareCollector collector, MyObject lifeCycleAware, boolean addInList) {
// if (addInList) {
// collector.addLifeCycleAware(lifeCycleAware);
// }
// return lifeCycleAware;
// }
// }
//
// Path: lifecyclebinder-api/src/main/java/it/codingjam/lifecyclebinder/LifeCycleAwareCollector.java
// public interface LifeCycleAwareCollector {
// <R> R addRetainedFactory(String key, Callable<R> factory, boolean addInLifeCycleAwareList);
//
// void addLifeCycleAware(LifeCycleAware<?> lifeCycleAware);
//
// <R> R getOrCreate(R lifeCycleAware, String key, Callable<R> factory);
// }
| import com.test.MyObject;
import com.test.MyObject$LifeCycleBinder;
import it.codingjam.lifecyclebinder.LifeCycleAwareCollector;
import java.util.concurrent.Callable; | package com.test.retainedObjectsWithProvider;
public class ActivityWithRetainedProvider$LifeCycleBinder {
public static void bind(LifeCycleAwareCollector collector, final ActivityWithRetainedProvider view) { | // Path: lifecyclebinder-processor/src/test/java/com/test/MyObject.java
// public class MyObject implements LifeCycleAware<MyView> {
// @Override
// public void onCreate(MyView view, Bundle savedInstanceState, Intent intent, Bundle arguments) {
//
// }
//
// @Override
// public void onStart(MyView view) {
//
// }
//
// @Override
// public void onResume(MyView view) {
//
// }
//
// @Override
// public boolean hasOptionsMenu(MyView view) {
// return false;
// }
//
// @Override
// public void onCreateOptionsMenu(MyView view, Menu menu, MenuInflater inflater) {
//
// }
//
// @Override
// public boolean onOptionsItemSelected(MyView view, MenuItem item) {
// return false;
// }
//
// @Override
// public void onPause(MyView view) {
//
// }
//
// @Override
// public void onStop(MyView view) {
//
// }
//
// @Override
// public void onSaveInstanceState(MyView view, Bundle bundle) {
//
// }
//
// @Override
// public void onDestroy(MyView view, boolean changingConfigurations) {
//
// }
//
// @Override
// public void onActivityResult(MyView view, int requestCode, int resultCode, Intent data) {
//
// }
//
// @Override public void onViewCreated(MyView view, Bundle savedInstanceState) {
//
// }
//
// @Override public void onDestroyView(MyView view) {
//
// }
// }
//
// Path: test-data-lib/src/main/java/com/test/MyObject$LifeCycleBinder.java
// public class MyObject$LifeCycleBinder {
//
// public static MyObject bind(LifeCycleAwareCollector collector, MyObject lifeCycleAware, boolean addInList) {
// if (addInList) {
// collector.addLifeCycleAware(lifeCycleAware);
// }
// return lifeCycleAware;
// }
// }
//
// Path: lifecyclebinder-api/src/main/java/it/codingjam/lifecyclebinder/LifeCycleAwareCollector.java
// public interface LifeCycleAwareCollector {
// <R> R addRetainedFactory(String key, Callable<R> factory, boolean addInLifeCycleAwareList);
//
// void addLifeCycleAware(LifeCycleAware<?> lifeCycleAware);
//
// <R> R getOrCreate(R lifeCycleAware, String key, Callable<R> factory);
// }
// Path: test-data-lib/src/main/java/com/test/retainedObjectsWithProvider/ActivityWithRetainedProvider$LifeCycleBinder.java
import com.test.MyObject;
import com.test.MyObject$LifeCycleBinder;
import it.codingjam.lifecyclebinder.LifeCycleAwareCollector;
import java.util.concurrent.Callable;
package com.test.retainedObjectsWithProvider;
public class ActivityWithRetainedProvider$LifeCycleBinder {
public static void bind(LifeCycleAwareCollector collector, final ActivityWithRetainedProvider view) { | MyObject$LifeCycleBinder.bind(collector, collector.getOrCreate(null, "myObject", new Callable<MyObject>() { |
fabioCollini/LifeCycleBinder | lifecyclebinder-demo-mvp/src/main/java/it/codingjam/lifecyclebinder/mvp/MainActivity.java | // Path: lifecyclebinder-lib/src/main/java/it/codingjam/lifecyclebinder/LifeCycleBinder.java
// public class LifeCycleBinder {
// public static void bind(Fragment fragment) {
// bind(fragment, fragment.getChildFragmentManager());
// }
//
// public static void bind(FragmentActivity activity) {
// bind(activity, activity.getSupportFragmentManager());
// }
//
// public static <T extends Fragment> void bind(T fragment, Class<?> objectBinderClass) {
// bind(fragment.getChildFragmentManager(), objectBinderClass);
// }
//
// public static <T extends FragmentActivity> void bind(T activity, Class<?> objectBinderClass) {
// bind(activity.getSupportFragmentManager(), objectBinderClass);
// }
//
// private static <T> void bind(T obj, FragmentManager fragmentManager) {
// LifeCycleBinderFragment<T> fragment = LifeCycleBinderFragment.get(fragmentManager);
// if (fragment == null) {
// Class<?> c = ReflectionUtils.getObjectBinderClass(obj);
// fragment = LifeCycleBinderFragment.createAndAdd(fragmentManager, c);
// }
// fragment.invokeOnCreate();
// }
//
// private static <T> void bind(FragmentManager fragmentManager, Class<?> objectBinderClass) {
// LifeCycleBinderFragment<T> fragment = LifeCycleBinderFragment.get(fragmentManager);
// if (fragment == null) {
// fragment = LifeCycleBinderFragment.createAndAdd(fragmentManager, objectBinderClass);
// }
// fragment.invokeOnCreate();
// }
//
// public static void startActivityForResult(FragmentActivity activity, Intent intent, int requestCode) {
// LifeCycleBinderFragment.get(activity.getSupportFragmentManager()).startActivityForResult(intent, requestCode);
// }
//
// public static void startActivityForResult(Fragment fragment, Intent intent, int requestCode) {
// LifeCycleBinderFragment.get(fragment.getChildFragmentManager()).startActivityForResult(intent, requestCode);
// }
// }
| import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.ProgressBar;
import android.widget.TextView;
import java.util.concurrent.Callable;
import it.codingjam.lifecyclebinder.BindLifeCycle;
import it.codingjam.lifecyclebinder.LifeCycleBinder;
import it.codingjam.lifecyclebinder.RetainedObjectProvider;
import static android.view.View.GONE;
import static android.view.View.VISIBLE; | /*
* Copyright 2016 Fabio Collini.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package it.codingjam.lifecyclebinder.mvp;
public class MainActivity extends AppCompatActivity implements MvpView {
private ProgressBar progress;
private TextView title;
private TextView description;
@BindLifeCycle
Logger logger = new Logger();
@RetainedObjectProvider("presenter")
Callable<Presenter> presenterFactory = new Callable<Presenter>() {
@Override
public Presenter call() throws Exception {
return new Presenter();
}
};
Presenter presenter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
progress = (ProgressBar) findViewById(R.id.progress);
title = (TextView) findViewById(R.id.title);
description = (TextView) findViewById(R.id.description);
| // Path: lifecyclebinder-lib/src/main/java/it/codingjam/lifecyclebinder/LifeCycleBinder.java
// public class LifeCycleBinder {
// public static void bind(Fragment fragment) {
// bind(fragment, fragment.getChildFragmentManager());
// }
//
// public static void bind(FragmentActivity activity) {
// bind(activity, activity.getSupportFragmentManager());
// }
//
// public static <T extends Fragment> void bind(T fragment, Class<?> objectBinderClass) {
// bind(fragment.getChildFragmentManager(), objectBinderClass);
// }
//
// public static <T extends FragmentActivity> void bind(T activity, Class<?> objectBinderClass) {
// bind(activity.getSupportFragmentManager(), objectBinderClass);
// }
//
// private static <T> void bind(T obj, FragmentManager fragmentManager) {
// LifeCycleBinderFragment<T> fragment = LifeCycleBinderFragment.get(fragmentManager);
// if (fragment == null) {
// Class<?> c = ReflectionUtils.getObjectBinderClass(obj);
// fragment = LifeCycleBinderFragment.createAndAdd(fragmentManager, c);
// }
// fragment.invokeOnCreate();
// }
//
// private static <T> void bind(FragmentManager fragmentManager, Class<?> objectBinderClass) {
// LifeCycleBinderFragment<T> fragment = LifeCycleBinderFragment.get(fragmentManager);
// if (fragment == null) {
// fragment = LifeCycleBinderFragment.createAndAdd(fragmentManager, objectBinderClass);
// }
// fragment.invokeOnCreate();
// }
//
// public static void startActivityForResult(FragmentActivity activity, Intent intent, int requestCode) {
// LifeCycleBinderFragment.get(activity.getSupportFragmentManager()).startActivityForResult(intent, requestCode);
// }
//
// public static void startActivityForResult(Fragment fragment, Intent intent, int requestCode) {
// LifeCycleBinderFragment.get(fragment.getChildFragmentManager()).startActivityForResult(intent, requestCode);
// }
// }
// Path: lifecyclebinder-demo-mvp/src/main/java/it/codingjam/lifecyclebinder/mvp/MainActivity.java
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.ProgressBar;
import android.widget.TextView;
import java.util.concurrent.Callable;
import it.codingjam.lifecyclebinder.BindLifeCycle;
import it.codingjam.lifecyclebinder.LifeCycleBinder;
import it.codingjam.lifecyclebinder.RetainedObjectProvider;
import static android.view.View.GONE;
import static android.view.View.VISIBLE;
/*
* Copyright 2016 Fabio Collini.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package it.codingjam.lifecyclebinder.mvp;
public class MainActivity extends AppCompatActivity implements MvpView {
private ProgressBar progress;
private TextView title;
private TextView description;
@BindLifeCycle
Logger logger = new Logger();
@RetainedObjectProvider("presenter")
Callable<Presenter> presenterFactory = new Callable<Presenter>() {
@Override
public Presenter call() throws Exception {
return new Presenter();
}
};
Presenter presenter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
progress = (ProgressBar) findViewById(R.id.progress);
title = (TextView) findViewById(R.id.title);
description = (TextView) findViewById(R.id.description);
| LifeCycleBinder.bind(this); |
AndroidCreativeDesign/AndroidSharingPlatform | app/src/main/java/cn/daixiaodong/myapp/fragment/UserFollowFragment.java | // Path: app/src/main/java/cn/daixiaodong/myapp/adapter/UserFollowListAdapter.java
// public class UserFollowListAdapter extends RecyclerView.Adapter<UserFollowListAdapter.MyViewHolder> {
//
// private Context mContext;
// private List<AVObject> mDataSet;
// private LayoutInflater mLayoutInflater;
// private OnItemClickListener mListener;
//
// public UserFollowListAdapter(Context context) {
// this.mContext = context;
// this.mLayoutInflater = LayoutInflater.from(context);
// }
//
// public UserFollowListAdapter(Context context, List<AVObject> data) {
// this.mContext = context;
// this.mDataSet = data;
// this.mLayoutInflater = LayoutInflater.from(context);
//
// }
//
// public void setDataSet(List<AVObject> data) {
// this.mDataSet = data;
// notifyDataSetChanged();
// }
//
// public void addData(List<AVObject> data) {
// this.mDataSet.addAll(0, data);
// this.notifyItemInserted(1);
// }
//
// @Override
// public UserFollowListAdapter.MyViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
//
// View view = mLayoutInflater.inflate(R.layout.item_follow, viewGroup, false);
// MyViewHolder viewHolder = new MyViewHolder(view);
// return viewHolder;
// }
//
// @Override
// public void onBindViewHolder(final UserFollowListAdapter.MyViewHolder viewHolder, final int i) {
// viewHolder.itemView.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View v) {
// if (mListener != null) {
// mListener.onItemClick(viewHolder, i);
// }
// }
// });
//
// viewHolder.title.setText(mDataSet.get(i).getString("username"));
// }
//
// @Override
// public int getItemCount() {
// if (mDataSet == null) {
// return 0;
// }
// return mDataSet.size();
// }
//
//
// public interface OnItemClickListener {
// void onItemClick(MyViewHolder viewHolder, int pos);
// }
//
// public void setOnItemClickListener(OnItemClickListener listener) {
// this.mListener = listener;
// }
//
// public class MyViewHolder extends RecyclerView.ViewHolder {
//
// public TextView title;
//
// public MyViewHolder(View itemView) {
// super(itemView);
// title = (TextView) itemView.findViewById(R.id.id_tv_title);
// }
// }
//
//
// }
//
// Path: app/src/main/java/cn/daixiaodong/myapp/fragment/common/BaseFragment.java
// public class BaseFragment extends Fragment {
//
//
// public void showToast(Context context, String message) {
// Toast.makeText(context, message, Toast.LENGTH_SHORT).show();
// }
//
// public void onPause() {
// super.onPause();
// Log.i("onPause", this.getClass().getSimpleName());
// /*AVAnalytics.onFragmentEnd("my-list-fragment");*/
// }
//
// public void onResume() {
// super.onResume();
// Log.i("onResume", this.getClass().getSimpleName());
//
// /* AVAnalytics.onFragmentStart("my-list-fragment");*/
// }
//
// protected boolean isSignIn() {
// if (AVUser.getCurrentUser() == null) {
// return false;
// }
// return true;
// }
// }
| import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.avos.avoscloud.AVException;
import com.avos.avoscloud.AVObject;
import com.avos.avoscloud.AVRelation;
import com.avos.avoscloud.AVUser;
import com.avos.avoscloud.FindCallback;
import java.util.ArrayList;
import java.util.List;
import cn.daixiaodong.myapp.R;
import cn.daixiaodong.myapp.adapter.UserFollowListAdapter;
import cn.daixiaodong.myapp.fragment.common.BaseFragment;
import static android.support.v7.widget.RecyclerView.OnScrollListener; | package cn.daixiaodong.myapp.fragment;
/**
* 用户关注的其他用户
*/
public class UserFollowFragment extends BaseFragment implements SwipeRefreshLayout.OnRefreshListener {
private View mRootView;
private SwipeRefreshLayout mRefreshLayout;
private RecyclerView mRecyclerView; | // Path: app/src/main/java/cn/daixiaodong/myapp/adapter/UserFollowListAdapter.java
// public class UserFollowListAdapter extends RecyclerView.Adapter<UserFollowListAdapter.MyViewHolder> {
//
// private Context mContext;
// private List<AVObject> mDataSet;
// private LayoutInflater mLayoutInflater;
// private OnItemClickListener mListener;
//
// public UserFollowListAdapter(Context context) {
// this.mContext = context;
// this.mLayoutInflater = LayoutInflater.from(context);
// }
//
// public UserFollowListAdapter(Context context, List<AVObject> data) {
// this.mContext = context;
// this.mDataSet = data;
// this.mLayoutInflater = LayoutInflater.from(context);
//
// }
//
// public void setDataSet(List<AVObject> data) {
// this.mDataSet = data;
// notifyDataSetChanged();
// }
//
// public void addData(List<AVObject> data) {
// this.mDataSet.addAll(0, data);
// this.notifyItemInserted(1);
// }
//
// @Override
// public UserFollowListAdapter.MyViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
//
// View view = mLayoutInflater.inflate(R.layout.item_follow, viewGroup, false);
// MyViewHolder viewHolder = new MyViewHolder(view);
// return viewHolder;
// }
//
// @Override
// public void onBindViewHolder(final UserFollowListAdapter.MyViewHolder viewHolder, final int i) {
// viewHolder.itemView.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View v) {
// if (mListener != null) {
// mListener.onItemClick(viewHolder, i);
// }
// }
// });
//
// viewHolder.title.setText(mDataSet.get(i).getString("username"));
// }
//
// @Override
// public int getItemCount() {
// if (mDataSet == null) {
// return 0;
// }
// return mDataSet.size();
// }
//
//
// public interface OnItemClickListener {
// void onItemClick(MyViewHolder viewHolder, int pos);
// }
//
// public void setOnItemClickListener(OnItemClickListener listener) {
// this.mListener = listener;
// }
//
// public class MyViewHolder extends RecyclerView.ViewHolder {
//
// public TextView title;
//
// public MyViewHolder(View itemView) {
// super(itemView);
// title = (TextView) itemView.findViewById(R.id.id_tv_title);
// }
// }
//
//
// }
//
// Path: app/src/main/java/cn/daixiaodong/myapp/fragment/common/BaseFragment.java
// public class BaseFragment extends Fragment {
//
//
// public void showToast(Context context, String message) {
// Toast.makeText(context, message, Toast.LENGTH_SHORT).show();
// }
//
// public void onPause() {
// super.onPause();
// Log.i("onPause", this.getClass().getSimpleName());
// /*AVAnalytics.onFragmentEnd("my-list-fragment");*/
// }
//
// public void onResume() {
// super.onResume();
// Log.i("onResume", this.getClass().getSimpleName());
//
// /* AVAnalytics.onFragmentStart("my-list-fragment");*/
// }
//
// protected boolean isSignIn() {
// if (AVUser.getCurrentUser() == null) {
// return false;
// }
// return true;
// }
// }
// Path: app/src/main/java/cn/daixiaodong/myapp/fragment/UserFollowFragment.java
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.avos.avoscloud.AVException;
import com.avos.avoscloud.AVObject;
import com.avos.avoscloud.AVRelation;
import com.avos.avoscloud.AVUser;
import com.avos.avoscloud.FindCallback;
import java.util.ArrayList;
import java.util.List;
import cn.daixiaodong.myapp.R;
import cn.daixiaodong.myapp.adapter.UserFollowListAdapter;
import cn.daixiaodong.myapp.fragment.common.BaseFragment;
import static android.support.v7.widget.RecyclerView.OnScrollListener;
package cn.daixiaodong.myapp.fragment;
/**
* 用户关注的其他用户
*/
public class UserFollowFragment extends BaseFragment implements SwipeRefreshLayout.OnRefreshListener {
private View mRootView;
private SwipeRefreshLayout mRefreshLayout;
private RecyclerView mRecyclerView; | private UserFollowListAdapter mAdapter; |
AndroidCreativeDesign/AndroidSharingPlatform | app/src/main/java/cn/daixiaodong/myapp/activity/SearchActivity.java | // Path: app/src/main/java/cn/daixiaodong/myapp/activity/common/BaseActivity.java
// public class BaseActivity extends AppCompatActivity {
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// Log.i("BaseActivity", this.getClass().getSimpleName() + "add");
// ActivityCollector.addActivity(this);
// ActivityCollector.addActivity(this.getClass().getSimpleName(), this);
// }
//
// @Override
// protected void onResume() {
// super.onResume();
// AVAnalytics.onResume(this);
// }
//
// @Override
// protected void onPause() {
// super.onPause();
// AVAnalytics.onPause(this);
// }
//
// public void showToast(String message) {
// Toast.makeText(this, message, Toast.LENGTH_SHORT).show();
//
// }
//
// @Override
// protected void onDestroy() {
// super.onDestroy();
// Log.i("BaseActivity", this.getClass().getSimpleName() + "remove");
// ActivityCollector.removeActivity(this.getClass().getSimpleName(), this);
//
// ActivityCollector.removeActivity(this);
// }
// }
//
// Path: app/src/main/java/cn/daixiaodong/myapp/adapter/UserPublishListAdapter.java
// public class UserPublishListAdapter extends RecyclerView.Adapter<UserPublishListAdapter.MyViewHolder> {
//
// private Context mContext;
// private List<AVObject> mDataSet;
// private LayoutInflater mLayoutInflater;
// private OnItemClickListener mListener;
//
// public UserPublishListAdapter(Context context) {
// this.mContext = context;
// this.mLayoutInflater = LayoutInflater.from(context);
// }
//
// public UserPublishListAdapter(Context context, List<AVObject> data) {
// this.mContext = context;
// this.mDataSet = data;
// this.mLayoutInflater = LayoutInflater.from(context);
//
// }
//
// public void setDataSet(List<AVObject> data) {
// this.mDataSet = data;
// notifyDataSetChanged();
// }
//
// public void addData(List<AVObject> data) {
// this.mDataSet.addAll(0, data);
// this.notifyItemInserted(1);
// }
//
// @Override
// public UserPublishListAdapter.MyViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
//
// View view = mLayoutInflater.inflate(R.layout.item_publish, viewGroup, false);
// MyViewHolder viewHolder = new MyViewHolder(view);
// return viewHolder;
// }
//
// @Override
// public void onBindViewHolder(final UserPublishListAdapter.MyViewHolder viewHolder, final int i) {
// viewHolder.itemView.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View v) {
// if (mListener != null) {
// mListener.onItemClick(viewHolder, i);
// }
// }
// });
// viewHolder.title.setText(mDataSet.get(i).getString("title"));
// }
//
// @Override
// public int getItemCount() {
// if (mDataSet == null) {
// return 0;
// }
// return mDataSet.size();
// }
//
//
// public interface OnItemClickListener {
// void onItemClick(MyViewHolder viewHolder, int pos);
// }
//
// public void setOnItemClickListener(OnItemClickListener listener) {
// this.mListener = listener;
// }
//
// public class MyViewHolder extends RecyclerView.ViewHolder {
//
// public TextView title;
//
// public MyViewHolder(View itemView) {
// super(itemView);
// title = (TextView) itemView.findViewById(R.id.id_tv_title);
// }
// }
//
//
// }
| import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.SearchView;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.MenuItem;
import android.view.View;
import com.avos.avoscloud.AVException;
import com.avos.avoscloud.AVObject;
import com.avos.avoscloud.AVQuery;
import com.avos.avoscloud.FindCallback;
import java.util.ArrayList;
import java.util.List;
import cn.daixiaodong.myapp.R;
import cn.daixiaodong.myapp.activity.common.BaseActivity;
import cn.daixiaodong.myapp.adapter.UserPublishListAdapter; | package cn.daixiaodong.myapp.activity;
/**
* 搜索界面
*/
public class SearchActivity extends BaseActivity {
private ArrayList<AVObject> mData;
| // Path: app/src/main/java/cn/daixiaodong/myapp/activity/common/BaseActivity.java
// public class BaseActivity extends AppCompatActivity {
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// Log.i("BaseActivity", this.getClass().getSimpleName() + "add");
// ActivityCollector.addActivity(this);
// ActivityCollector.addActivity(this.getClass().getSimpleName(), this);
// }
//
// @Override
// protected void onResume() {
// super.onResume();
// AVAnalytics.onResume(this);
// }
//
// @Override
// protected void onPause() {
// super.onPause();
// AVAnalytics.onPause(this);
// }
//
// public void showToast(String message) {
// Toast.makeText(this, message, Toast.LENGTH_SHORT).show();
//
// }
//
// @Override
// protected void onDestroy() {
// super.onDestroy();
// Log.i("BaseActivity", this.getClass().getSimpleName() + "remove");
// ActivityCollector.removeActivity(this.getClass().getSimpleName(), this);
//
// ActivityCollector.removeActivity(this);
// }
// }
//
// Path: app/src/main/java/cn/daixiaodong/myapp/adapter/UserPublishListAdapter.java
// public class UserPublishListAdapter extends RecyclerView.Adapter<UserPublishListAdapter.MyViewHolder> {
//
// private Context mContext;
// private List<AVObject> mDataSet;
// private LayoutInflater mLayoutInflater;
// private OnItemClickListener mListener;
//
// public UserPublishListAdapter(Context context) {
// this.mContext = context;
// this.mLayoutInflater = LayoutInflater.from(context);
// }
//
// public UserPublishListAdapter(Context context, List<AVObject> data) {
// this.mContext = context;
// this.mDataSet = data;
// this.mLayoutInflater = LayoutInflater.from(context);
//
// }
//
// public void setDataSet(List<AVObject> data) {
// this.mDataSet = data;
// notifyDataSetChanged();
// }
//
// public void addData(List<AVObject> data) {
// this.mDataSet.addAll(0, data);
// this.notifyItemInserted(1);
// }
//
// @Override
// public UserPublishListAdapter.MyViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
//
// View view = mLayoutInflater.inflate(R.layout.item_publish, viewGroup, false);
// MyViewHolder viewHolder = new MyViewHolder(view);
// return viewHolder;
// }
//
// @Override
// public void onBindViewHolder(final UserPublishListAdapter.MyViewHolder viewHolder, final int i) {
// viewHolder.itemView.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View v) {
// if (mListener != null) {
// mListener.onItemClick(viewHolder, i);
// }
// }
// });
// viewHolder.title.setText(mDataSet.get(i).getString("title"));
// }
//
// @Override
// public int getItemCount() {
// if (mDataSet == null) {
// return 0;
// }
// return mDataSet.size();
// }
//
//
// public interface OnItemClickListener {
// void onItemClick(MyViewHolder viewHolder, int pos);
// }
//
// public void setOnItemClickListener(OnItemClickListener listener) {
// this.mListener = listener;
// }
//
// public class MyViewHolder extends RecyclerView.ViewHolder {
//
// public TextView title;
//
// public MyViewHolder(View itemView) {
// super(itemView);
// title = (TextView) itemView.findViewById(R.id.id_tv_title);
// }
// }
//
//
// }
// Path: app/src/main/java/cn/daixiaodong/myapp/activity/SearchActivity.java
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.SearchView;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.MenuItem;
import android.view.View;
import com.avos.avoscloud.AVException;
import com.avos.avoscloud.AVObject;
import com.avos.avoscloud.AVQuery;
import com.avos.avoscloud.FindCallback;
import java.util.ArrayList;
import java.util.List;
import cn.daixiaodong.myapp.R;
import cn.daixiaodong.myapp.activity.common.BaseActivity;
import cn.daixiaodong.myapp.adapter.UserPublishListAdapter;
package cn.daixiaodong.myapp.activity;
/**
* 搜索界面
*/
public class SearchActivity extends BaseActivity {
private ArrayList<AVObject> mData;
| private UserPublishListAdapter mAdapter; |
AndroidCreativeDesign/AndroidSharingPlatform | app/src/main/java/cn/daixiaodong/myapp/adapter/PushMessageAdapter.java | // Path: app/src/main/java/cn/daixiaodong/myapp/model/PushMessageModel.java
// @DatabaseTable(tableName = "push_message")
// public class PushMessageModel {
//
//
// @DatabaseField(generatedId = true)
// private int id;
//
// @DatabaseField(columnName = "message")
// private String message;
//
//
// public PushMessageModel() {
// }
//
//
// public PushMessageModel(String message) {
//
// this.message = message;
// }
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public String getMessage() {
// return message;
// }
//
// public void setMessage(String message) {
// this.message = message;
// }
// }
| import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import java.util.List;
import cn.daixiaodong.myapp.R;
import cn.daixiaodong.myapp.model.PushMessageModel; | package cn.daixiaodong.myapp.adapter;
/**
* 推送消息记录列表 Adapter
*/
public class PushMessageAdapter extends RecyclerView.Adapter<PushMessageAdapter.MyViewHolder> {
private Context mContext; | // Path: app/src/main/java/cn/daixiaodong/myapp/model/PushMessageModel.java
// @DatabaseTable(tableName = "push_message")
// public class PushMessageModel {
//
//
// @DatabaseField(generatedId = true)
// private int id;
//
// @DatabaseField(columnName = "message")
// private String message;
//
//
// public PushMessageModel() {
// }
//
//
// public PushMessageModel(String message) {
//
// this.message = message;
// }
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public String getMessage() {
// return message;
// }
//
// public void setMessage(String message) {
// this.message = message;
// }
// }
// Path: app/src/main/java/cn/daixiaodong/myapp/adapter/PushMessageAdapter.java
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import java.util.List;
import cn.daixiaodong.myapp.R;
import cn.daixiaodong.myapp.model.PushMessageModel;
package cn.daixiaodong.myapp.adapter;
/**
* 推送消息记录列表 Adapter
*/
public class PushMessageAdapter extends RecyclerView.Adapter<PushMessageAdapter.MyViewHolder> {
private Context mContext; | private List<PushMessageModel> mDataSet; |
AndroidCreativeDesign/AndroidSharingPlatform | app/src/main/java/cn/daixiaodong/myapp/db/PushMessageDao.java | // Path: app/src/main/java/cn/daixiaodong/myapp/model/PushMessageModel.java
// @DatabaseTable(tableName = "push_message")
// public class PushMessageModel {
//
//
// @DatabaseField(generatedId = true)
// private int id;
//
// @DatabaseField(columnName = "message")
// private String message;
//
//
// public PushMessageModel() {
// }
//
//
// public PushMessageModel(String message) {
//
// this.message = message;
// }
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public String getMessage() {
// return message;
// }
//
// public void setMessage(String message) {
// this.message = message;
// }
// }
| import android.content.Context;
import com.j256.ormlite.dao.Dao;
import java.sql.SQLException;
import java.util.List;
import cn.daixiaodong.myapp.model.PushMessageModel; | package cn.daixiaodong.myapp.db;
/**
* Created by daixiaodong on 15/7/23.
*/
public class PushMessageDao {
private Context mContext; | // Path: app/src/main/java/cn/daixiaodong/myapp/model/PushMessageModel.java
// @DatabaseTable(tableName = "push_message")
// public class PushMessageModel {
//
//
// @DatabaseField(generatedId = true)
// private int id;
//
// @DatabaseField(columnName = "message")
// private String message;
//
//
// public PushMessageModel() {
// }
//
//
// public PushMessageModel(String message) {
//
// this.message = message;
// }
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public String getMessage() {
// return message;
// }
//
// public void setMessage(String message) {
// this.message = message;
// }
// }
// Path: app/src/main/java/cn/daixiaodong/myapp/db/PushMessageDao.java
import android.content.Context;
import com.j256.ormlite.dao.Dao;
import java.sql.SQLException;
import java.util.List;
import cn.daixiaodong.myapp.model.PushMessageModel;
package cn.daixiaodong.myapp.db;
/**
* Created by daixiaodong on 15/7/23.
*/
public class PushMessageDao {
private Context mContext; | private Dao<PushMessageModel, Integer> mPushMessageDao; |
AndroidCreativeDesign/AndroidSharingPlatform | app/src/main/java/cn/daixiaodong/myapp/db/DatabaseHelper.java | // Path: app/src/main/java/cn/daixiaodong/myapp/model/PushMessageModel.java
// @DatabaseTable(tableName = "push_message")
// public class PushMessageModel {
//
//
// @DatabaseField(generatedId = true)
// private int id;
//
// @DatabaseField(columnName = "message")
// private String message;
//
//
// public PushMessageModel() {
// }
//
//
// public PushMessageModel(String message) {
//
// this.message = message;
// }
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public String getMessage() {
// return message;
// }
//
// public void setMessage(String message) {
// this.message = message;
// }
// }
| import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import com.j256.ormlite.android.apptools.OrmLiteSqliteOpenHelper;
import com.j256.ormlite.dao.Dao;
import com.j256.ormlite.support.ConnectionSource;
import com.j256.ormlite.table.TableUtils;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;
import cn.daixiaodong.myapp.model.PushMessageModel; | package cn.daixiaodong.myapp.db;
/**
* Created by daixiaodong on 15/7/21.
*/
public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
private static final String TABLE_NAME = "push_message";
private static final String DATABASE_NAME = "data.db";
private Map<String, Dao> mDaos = new HashMap<>();
private DatabaseHelper(Context context, String databaseName, SQLiteDatabase.CursorFactory factory, int databaseVersion) {
super(context, DATABASE_NAME, null, 1);
}
@Override
public void onCreate(SQLiteDatabase sqLiteDatabase, ConnectionSource connectionSource) {
try { | // Path: app/src/main/java/cn/daixiaodong/myapp/model/PushMessageModel.java
// @DatabaseTable(tableName = "push_message")
// public class PushMessageModel {
//
//
// @DatabaseField(generatedId = true)
// private int id;
//
// @DatabaseField(columnName = "message")
// private String message;
//
//
// public PushMessageModel() {
// }
//
//
// public PushMessageModel(String message) {
//
// this.message = message;
// }
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public String getMessage() {
// return message;
// }
//
// public void setMessage(String message) {
// this.message = message;
// }
// }
// Path: app/src/main/java/cn/daixiaodong/myapp/db/DatabaseHelper.java
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import com.j256.ormlite.android.apptools.OrmLiteSqliteOpenHelper;
import com.j256.ormlite.dao.Dao;
import com.j256.ormlite.support.ConnectionSource;
import com.j256.ormlite.table.TableUtils;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;
import cn.daixiaodong.myapp.model.PushMessageModel;
package cn.daixiaodong.myapp.db;
/**
* Created by daixiaodong on 15/7/21.
*/
public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
private static final String TABLE_NAME = "push_message";
private static final String DATABASE_NAME = "data.db";
private Map<String, Dao> mDaos = new HashMap<>();
private DatabaseHelper(Context context, String databaseName, SQLiteDatabase.CursorFactory factory, int databaseVersion) {
super(context, DATABASE_NAME, null, 1);
}
@Override
public void onCreate(SQLiteDatabase sqLiteDatabase, ConnectionSource connectionSource) {
try { | TableUtils.createTable(connectionSource, PushMessageModel.class); |
AndroidCreativeDesign/AndroidSharingPlatform | app/src/main/java/cn/daixiaodong/myapp/activity/SignInActivity.java | // Path: app/src/main/java/cn/daixiaodong/myapp/activity/common/BaseActivity.java
// public class BaseActivity extends AppCompatActivity {
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// Log.i("BaseActivity", this.getClass().getSimpleName() + "add");
// ActivityCollector.addActivity(this);
// ActivityCollector.addActivity(this.getClass().getSimpleName(), this);
// }
//
// @Override
// protected void onResume() {
// super.onResume();
// AVAnalytics.onResume(this);
// }
//
// @Override
// protected void onPause() {
// super.onPause();
// AVAnalytics.onPause(this);
// }
//
// public void showToast(String message) {
// Toast.makeText(this, message, Toast.LENGTH_SHORT).show();
//
// }
//
// @Override
// protected void onDestroy() {
// super.onDestroy();
// Log.i("BaseActivity", this.getClass().getSimpleName() + "remove");
// ActivityCollector.removeActivity(this.getClass().getSimpleName(), this);
//
// ActivityCollector.removeActivity(this);
// }
// }
//
// Path: app/src/main/java/cn/daixiaodong/myapp/utils/NetworkUtil.java
// public class NetworkUtil {
// public static boolean isNetworkConnected(Context context) {
// if (context != null) {
// ConnectivityManager mConnectivityManager = (ConnectivityManager) context
// .getSystemService(Context.CONNECTIVITY_SERVICE);
// NetworkInfo mNetworkInfo = mConnectivityManager.getActiveNetworkInfo();
// if (mNetworkInfo != null) {
// return mNetworkInfo.isAvailable();
// }
// }
// return false;
// }
// }
| import android.support.v7.widget.Toolbar;
import android.view.MenuItem;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import com.avos.avoscloud.AVException;
import com.avos.avoscloud.AVUser;
import com.avos.avoscloud.LogInCallback;
import org.androidannotations.annotations.AfterViews;
import org.androidannotations.annotations.Click;
import org.androidannotations.annotations.EActivity;
import org.androidannotations.annotations.ViewById;
import cn.daixiaodong.myapp.R;
import cn.daixiaodong.myapp.activity.common.BaseActivity;
import cn.daixiaodong.myapp.utils.NetworkUtil; |
@ViewById(R.id.id_btn_sign_up_now)
Button mViewSignUp;
@ViewById(R.id.id_tv_forgot_password)
TextView mViewForgotPassword;
@Click(R.id.id_btn_sign_up_now)
void signUp() {
SignUpFirstStepActivity_.intent(this).start();
}
@AfterViews
void init() {
initToolbar();
}
@Click(R.id.id_btn_sign_in)
void signIn() {
String phoneNumber = mViewPhoneNumber.getText().toString();
String password = mViewPassword.getText().toString();
if (!checkData(phoneNumber, password)) {
return;
} | // Path: app/src/main/java/cn/daixiaodong/myapp/activity/common/BaseActivity.java
// public class BaseActivity extends AppCompatActivity {
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// Log.i("BaseActivity", this.getClass().getSimpleName() + "add");
// ActivityCollector.addActivity(this);
// ActivityCollector.addActivity(this.getClass().getSimpleName(), this);
// }
//
// @Override
// protected void onResume() {
// super.onResume();
// AVAnalytics.onResume(this);
// }
//
// @Override
// protected void onPause() {
// super.onPause();
// AVAnalytics.onPause(this);
// }
//
// public void showToast(String message) {
// Toast.makeText(this, message, Toast.LENGTH_SHORT).show();
//
// }
//
// @Override
// protected void onDestroy() {
// super.onDestroy();
// Log.i("BaseActivity", this.getClass().getSimpleName() + "remove");
// ActivityCollector.removeActivity(this.getClass().getSimpleName(), this);
//
// ActivityCollector.removeActivity(this);
// }
// }
//
// Path: app/src/main/java/cn/daixiaodong/myapp/utils/NetworkUtil.java
// public class NetworkUtil {
// public static boolean isNetworkConnected(Context context) {
// if (context != null) {
// ConnectivityManager mConnectivityManager = (ConnectivityManager) context
// .getSystemService(Context.CONNECTIVITY_SERVICE);
// NetworkInfo mNetworkInfo = mConnectivityManager.getActiveNetworkInfo();
// if (mNetworkInfo != null) {
// return mNetworkInfo.isAvailable();
// }
// }
// return false;
// }
// }
// Path: app/src/main/java/cn/daixiaodong/myapp/activity/SignInActivity.java
import android.support.v7.widget.Toolbar;
import android.view.MenuItem;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import com.avos.avoscloud.AVException;
import com.avos.avoscloud.AVUser;
import com.avos.avoscloud.LogInCallback;
import org.androidannotations.annotations.AfterViews;
import org.androidannotations.annotations.Click;
import org.androidannotations.annotations.EActivity;
import org.androidannotations.annotations.ViewById;
import cn.daixiaodong.myapp.R;
import cn.daixiaodong.myapp.activity.common.BaseActivity;
import cn.daixiaodong.myapp.utils.NetworkUtil;
@ViewById(R.id.id_btn_sign_up_now)
Button mViewSignUp;
@ViewById(R.id.id_tv_forgot_password)
TextView mViewForgotPassword;
@Click(R.id.id_btn_sign_up_now)
void signUp() {
SignUpFirstStepActivity_.intent(this).start();
}
@AfterViews
void init() {
initToolbar();
}
@Click(R.id.id_btn_sign_in)
void signIn() {
String phoneNumber = mViewPhoneNumber.getText().toString();
String password = mViewPassword.getText().toString();
if (!checkData(phoneNumber, password)) {
return;
} | if (!NetworkUtil.isNetworkConnected(this)) { |
AndroidCreativeDesign/AndroidSharingPlatform | app/src/main/java/cn/daixiaodong/myapp/activity/SignUpSecondStepActivity.java | // Path: app/src/main/java/cn/daixiaodong/myapp/activity/common/BaseActivity.java
// public class BaseActivity extends AppCompatActivity {
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// Log.i("BaseActivity", this.getClass().getSimpleName() + "add");
// ActivityCollector.addActivity(this);
// ActivityCollector.addActivity(this.getClass().getSimpleName(), this);
// }
//
// @Override
// protected void onResume() {
// super.onResume();
// AVAnalytics.onResume(this);
// }
//
// @Override
// protected void onPause() {
// super.onPause();
// AVAnalytics.onPause(this);
// }
//
// public void showToast(String message) {
// Toast.makeText(this, message, Toast.LENGTH_SHORT).show();
//
// }
//
// @Override
// protected void onDestroy() {
// super.onDestroy();
// Log.i("BaseActivity", this.getClass().getSimpleName() + "remove");
// ActivityCollector.removeActivity(this.getClass().getSimpleName(), this);
//
// ActivityCollector.removeActivity(this);
// }
// }
//
// Path: app/src/main/java/cn/daixiaodong/myapp/activity/common/ActivityCollector.java
// public class ActivityCollector {
//
// public static List<Activity> collector = new ArrayList<>();
//
// public static Map<String, Activity> activities = new HashMap<>();
//
//
// public static void addActivity(Activity activity) {
// collector.add(activity);
// }
//
// public static void addActivity(String classSimpleName, Activity activity) {
// activities.put(classSimpleName, activity);
// }
//
// public static void removeActivity(Activity activity) {
// collector.remove(activity);
// }
//
// public static void removeActivity(String classSimpleName, Activity activity) {
// activities.remove(classSimpleName);
// }
//
//
// public static void finishActivity(String classSimpleName) {
// if (activities.get(classSimpleName) != null) {
// activities.get(classSimpleName).finish();
// activities.remove(classSimpleName);
// }
// }
//
// public static void finishAllActivities() {
// for (Map.Entry<String, Activity> entry : activities.entrySet()) {
// entry.getValue().finish();
// }
// }
//
// public static void finishAll() {
// for (Activity activity : collector) {
// if (!activity.isFinishing()) {
// activity.finish();
// }
// }
// }
//
// }
| import android.graphics.Color;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import com.avos.avoscloud.AVException;
import com.avos.avoscloud.AVMobilePhoneVerifyCallback;
import com.avos.avoscloud.AVUser;
import com.avos.avoscloud.RequestMobileCodeCallback;
import org.androidannotations.annotations.Click;
import org.androidannotations.annotations.EActivity;
import org.androidannotations.annotations.ViewById;
import cn.daixiaodong.myapp.R;
import cn.daixiaodong.myapp.activity.common.BaseActivity;
import cn.daixiaodong.myapp.activity.common.ActivityCollector; |
@Override
public void done(AVException e) {
//发送了验证码以后做点什么呢
if (e == null) {
showToast("发送成功");
} else {
e.printStackTrace();
}
}
});
}
@ViewById(R.id.id_btn_sign_up_second_step_done)
Button mViewDone;
@Click(R.id.id_btn_sign_up_second_step_done)
void done() {
String verifyCode = mViewVerifyCode.getText().toString();
if (verifyCode.isEmpty()) {
showToast("请输入验证码");
return;
}
AVUser.verifyMobilePhoneInBackground(verifyCode, new AVMobilePhoneVerifyCallback() {
@Override
public void done(AVException e) {
if (e == null) {
showToast("验证成功");
MainActivity_.intent(SignUpSecondStepActivity.this).start(); | // Path: app/src/main/java/cn/daixiaodong/myapp/activity/common/BaseActivity.java
// public class BaseActivity extends AppCompatActivity {
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// Log.i("BaseActivity", this.getClass().getSimpleName() + "add");
// ActivityCollector.addActivity(this);
// ActivityCollector.addActivity(this.getClass().getSimpleName(), this);
// }
//
// @Override
// protected void onResume() {
// super.onResume();
// AVAnalytics.onResume(this);
// }
//
// @Override
// protected void onPause() {
// super.onPause();
// AVAnalytics.onPause(this);
// }
//
// public void showToast(String message) {
// Toast.makeText(this, message, Toast.LENGTH_SHORT).show();
//
// }
//
// @Override
// protected void onDestroy() {
// super.onDestroy();
// Log.i("BaseActivity", this.getClass().getSimpleName() + "remove");
// ActivityCollector.removeActivity(this.getClass().getSimpleName(), this);
//
// ActivityCollector.removeActivity(this);
// }
// }
//
// Path: app/src/main/java/cn/daixiaodong/myapp/activity/common/ActivityCollector.java
// public class ActivityCollector {
//
// public static List<Activity> collector = new ArrayList<>();
//
// public static Map<String, Activity> activities = new HashMap<>();
//
//
// public static void addActivity(Activity activity) {
// collector.add(activity);
// }
//
// public static void addActivity(String classSimpleName, Activity activity) {
// activities.put(classSimpleName, activity);
// }
//
// public static void removeActivity(Activity activity) {
// collector.remove(activity);
// }
//
// public static void removeActivity(String classSimpleName, Activity activity) {
// activities.remove(classSimpleName);
// }
//
//
// public static void finishActivity(String classSimpleName) {
// if (activities.get(classSimpleName) != null) {
// activities.get(classSimpleName).finish();
// activities.remove(classSimpleName);
// }
// }
//
// public static void finishAllActivities() {
// for (Map.Entry<String, Activity> entry : activities.entrySet()) {
// entry.getValue().finish();
// }
// }
//
// public static void finishAll() {
// for (Activity activity : collector) {
// if (!activity.isFinishing()) {
// activity.finish();
// }
// }
// }
//
// }
// Path: app/src/main/java/cn/daixiaodong/myapp/activity/SignUpSecondStepActivity.java
import android.graphics.Color;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import com.avos.avoscloud.AVException;
import com.avos.avoscloud.AVMobilePhoneVerifyCallback;
import com.avos.avoscloud.AVUser;
import com.avos.avoscloud.RequestMobileCodeCallback;
import org.androidannotations.annotations.Click;
import org.androidannotations.annotations.EActivity;
import org.androidannotations.annotations.ViewById;
import cn.daixiaodong.myapp.R;
import cn.daixiaodong.myapp.activity.common.BaseActivity;
import cn.daixiaodong.myapp.activity.common.ActivityCollector;
@Override
public void done(AVException e) {
//发送了验证码以后做点什么呢
if (e == null) {
showToast("发送成功");
} else {
e.printStackTrace();
}
}
});
}
@ViewById(R.id.id_btn_sign_up_second_step_done)
Button mViewDone;
@Click(R.id.id_btn_sign_up_second_step_done)
void done() {
String verifyCode = mViewVerifyCode.getText().toString();
if (verifyCode.isEmpty()) {
showToast("请输入验证码");
return;
}
AVUser.verifyMobilePhoneInBackground(verifyCode, new AVMobilePhoneVerifyCallback() {
@Override
public void done(AVException e) {
if (e == null) {
showToast("验证成功");
MainActivity_.intent(SignUpSecondStepActivity.this).start(); | ActivityCollector.finishActivity(SignUpFirstStepActivity_.class.getSimpleName()); |
openmrs/openmrs-module-hl7query | api/src/main/java/org/openmrs/module/hl7query/util/ExceptionUtil.java | // Path: api/src/main/java/org/openmrs/module/hl7query/AuthenticationErrorObject.java
// public class AuthenticationErrorObject extends LinkedHashMap<String, Object> {
//
// private static final long serialVersionUID = 1L;
//
// public AuthenticationErrorObject() {
// super();
// }
//
// /**
// * Puts a property in this map, and returns the map itself (for chained method calls)
// *
// * @param key
// * @param value
// * @return
// */
// public AuthenticationErrorObject add(String key, Object value) {
// put(key, value);
// return this;
// }
//
// /**
// * Removes a property from the map, and returns the map itself (for chained method calls)
// *
// * @param key
// * @return
// */
// public AuthenticationErrorObject removeProperty(String key) {
// remove(key);
// return this;
// }
//
// /**
// * Creates an instance from the given json string.
// *
// * @param json
// * @return the simpleObject
// * @throws JsonParseException
// * @throws JsonMappingException
// * @throws IOException
// */
// public static AuthenticationErrorObject parseJson(String json) throws JsonParseException, JsonMappingException, IOException {
// ObjectMapper objectMapper = new ObjectMapper();
// AuthenticationErrorObject object = objectMapper.readValue(json, AuthenticationErrorObject.class);
// return object;
// }
// }
| import java.io.IOException;
import java.io.StringWriter;
import java.io.Writer;
import java.util.LinkedHashMap;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.OutputKeys;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import org.apache.commons.lang.exception.ExceptionUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.codehaus.jackson.JsonGenerationException;
import org.codehaus.jackson.map.JsonMappingException;
import org.codehaus.jackson.map.ObjectMapper;
import org.openmrs.module.hl7query.AuthenticationErrorObject;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Text;
| //add a text element to the child
Text errorCodeText = doc.createTextNode(Integer.toString(error.getCode()));
errorCode.appendChild(errorCodeText);
//set up a transformer
TransformerFactory transfac = TransformerFactory.newInstance();
Transformer trans = transfac.newTransformer();
trans.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
trans.setOutputProperty(OutputKeys.INDENT, "yes");
//create string from xml tree
StringWriter sw = new StringWriter();
StreamResult result = new StreamResult(sw);
DOMSource source = new DOMSource(doc);
trans.transform(source, result);
xmlString = sw.toString();
} catch (Exception e) {
e.printStackTrace();
}
return xmlString;
}
/**
* Wraps the exception message as a SimpleObject to be sent to client
*
* @param ex
* @param reason
* @return
*/
| // Path: api/src/main/java/org/openmrs/module/hl7query/AuthenticationErrorObject.java
// public class AuthenticationErrorObject extends LinkedHashMap<String, Object> {
//
// private static final long serialVersionUID = 1L;
//
// public AuthenticationErrorObject() {
// super();
// }
//
// /**
// * Puts a property in this map, and returns the map itself (for chained method calls)
// *
// * @param key
// * @param value
// * @return
// */
// public AuthenticationErrorObject add(String key, Object value) {
// put(key, value);
// return this;
// }
//
// /**
// * Removes a property from the map, and returns the map itself (for chained method calls)
// *
// * @param key
// * @return
// */
// public AuthenticationErrorObject removeProperty(String key) {
// remove(key);
// return this;
// }
//
// /**
// * Creates an instance from the given json string.
// *
// * @param json
// * @return the simpleObject
// * @throws JsonParseException
// * @throws JsonMappingException
// * @throws IOException
// */
// public static AuthenticationErrorObject parseJson(String json) throws JsonParseException, JsonMappingException, IOException {
// ObjectMapper objectMapper = new ObjectMapper();
// AuthenticationErrorObject object = objectMapper.readValue(json, AuthenticationErrorObject.class);
// return object;
// }
// }
// Path: api/src/main/java/org/openmrs/module/hl7query/util/ExceptionUtil.java
import java.io.IOException;
import java.io.StringWriter;
import java.io.Writer;
import java.util.LinkedHashMap;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.OutputKeys;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import org.apache.commons.lang.exception.ExceptionUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.codehaus.jackson.JsonGenerationException;
import org.codehaus.jackson.map.JsonMappingException;
import org.codehaus.jackson.map.ObjectMapper;
import org.openmrs.module.hl7query.AuthenticationErrorObject;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Text;
//add a text element to the child
Text errorCodeText = doc.createTextNode(Integer.toString(error.getCode()));
errorCode.appendChild(errorCodeText);
//set up a transformer
TransformerFactory transfac = TransformerFactory.newInstance();
Transformer trans = transfac.newTransformer();
trans.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
trans.setOutputProperty(OutputKeys.INDENT, "yes");
//create string from xml tree
StringWriter sw = new StringWriter();
StreamResult result = new StreamResult(sw);
DOMSource source = new DOMSource(doc);
trans.transform(source, result);
xmlString = sw.toString();
} catch (Exception e) {
e.printStackTrace();
}
return xmlString;
}
/**
* Wraps the exception message as a SimpleObject to be sent to client
*
* @param ex
* @param reason
* @return
*/
| public static AuthenticationErrorObject wrapErrorResponse(Exception ex, String reason) {
|
openmrs/openmrs-module-hl7query | api/src/test/java/org/openmrs/module/hl7query/api/impl/GroovyTemplateFactoryTest.java | // Path: api/src/main/java/org/openmrs/module/hl7query/HL7TemplateException.java
// public class HL7TemplateException extends APIException {
//
// private static final long serialVersionUID = 1L;
//
// public HL7TemplateException() {
// super();
// }
//
// /**
// * @param cause
// */
// public HL7TemplateException(Exception cause) {
// super(cause);
// }
//
// /**
// * @param message
// * @param cause
// */
// public HL7TemplateException(String message, Exception cause) {
// super(message, cause);
// }
//
// }
| import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.openmrs.module.hl7query.HL7TemplateException; | /**
* The contents of this file are subject to the OpenMRS Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://license.openmrs.org
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
* License for the specific language governing rights and limitations
* under the License.
*
* Copyright (C) OpenMRS, LLC. All Rights Reserved.
*/
package org.openmrs.module.hl7query.api.impl;
/**
* Integration tests for {@link GroovyTemplateFactory}
*/
public class GroovyTemplateFactoryTest {
GroovyTemplateFactory factory;
@Before
public void beforeEachTest() {
factory = new GroovyTemplateFactory();
}
@Test
public void testEvaluatingTemplateWithNullBindings() throws Exception {
String evaluated = factory.prepareTemplate("Easy as ${ [ 1, 2, 3 ].join(', ') }").evaluate(null);
Assert.assertEquals("Easy as 1, 2, 3", evaluated);
}
@Test
public void testEvaluatingTemplateWithBindings() throws Exception {
Map<String, Object> bindings = new HashMap<String, Object>();
bindings.put("list", Arrays.asList("1", "2", "3"));
String evaluated = factory.prepareTemplate("Easy as ${ list.join(', ') }").evaluate(bindings);
Assert.assertEquals("Easy as 1, 2, 3", evaluated);
}
| // Path: api/src/main/java/org/openmrs/module/hl7query/HL7TemplateException.java
// public class HL7TemplateException extends APIException {
//
// private static final long serialVersionUID = 1L;
//
// public HL7TemplateException() {
// super();
// }
//
// /**
// * @param cause
// */
// public HL7TemplateException(Exception cause) {
// super(cause);
// }
//
// /**
// * @param message
// * @param cause
// */
// public HL7TemplateException(String message, Exception cause) {
// super(message, cause);
// }
//
// }
// Path: api/src/test/java/org/openmrs/module/hl7query/api/impl/GroovyTemplateFactoryTest.java
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.openmrs.module.hl7query.HL7TemplateException;
/**
* The contents of this file are subject to the OpenMRS Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://license.openmrs.org
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
* License for the specific language governing rights and limitations
* under the License.
*
* Copyright (C) OpenMRS, LLC. All Rights Reserved.
*/
package org.openmrs.module.hl7query.api.impl;
/**
* Integration tests for {@link GroovyTemplateFactory}
*/
public class GroovyTemplateFactoryTest {
GroovyTemplateFactory factory;
@Before
public void beforeEachTest() {
factory = new GroovyTemplateFactory();
}
@Test
public void testEvaluatingTemplateWithNullBindings() throws Exception {
String evaluated = factory.prepareTemplate("Easy as ${ [ 1, 2, 3 ].join(', ') }").evaluate(null);
Assert.assertEquals("Easy as 1, 2, 3", evaluated);
}
@Test
public void testEvaluatingTemplateWithBindings() throws Exception {
Map<String, Object> bindings = new HashMap<String, Object>();
bindings.put("list", Arrays.asList("1", "2", "3"));
String evaluated = factory.prepareTemplate("Easy as ${ list.join(', ') }").evaluate(bindings);
Assert.assertEquals("Easy as 1, 2, 3", evaluated);
}
| @Test(expected=HL7TemplateException.class) |
openmrs/openmrs-module-hl7query | api/src/main/java/org/openmrs/module/hl7query/api/HL7QueryService.java | // Path: api/src/main/java/org/openmrs/module/hl7query/HL7Template.java
// public class HL7Template extends BaseOpenmrsMetadata implements OpenmrsMetadata {
//
// private Integer hl7TemplateId;
//
// private String hl7Entity;
//
// private String language = HL7QueryService.LANGUAGE_GROOVY;
//
// private String template;
//
// /**
// * @see org.openmrs.OpenmrsObject#getId()
// */
// @Override
// public Integer getId() {
// return getHl7TemplateId();
// }
//
// /**
// * @see org.openmrs.OpenmrsObject#setId(java.lang.Integer)
// */
// @Override
// public void setId(Integer id) {
// setHl7TemplateId(id);
// }
//
// /**
// * @return the hl7TemplateId
// */
// public Integer getHl7TemplateId() {
// return hl7TemplateId;
// }
//
// /**
// * @param hl7TemplateId the hl7TemplateId to set
// */
// public void setHl7TemplateId(Integer hl7TemplateId) {
// this.hl7TemplateId = hl7TemplateId;
// }
//
// /**
// * @return the hl7Entity
// */
// public String getHl7Entity() {
// return hl7Entity;
// }
//
// /**
// * @param hl7Entity the hl7Entity to set
// */
// public void setHl7Entity(String hl7Entity) {
// this.hl7Entity = hl7Entity;
// }
//
// /**
// * @return the language
// */
// public String getLanguage() {
// return language;
// }
//
// /**
// * @param language the language to set
// */
// public void setLanguage(String language) {
// this.language = language;
// }
//
// /**
// * @return the template
// */
// public String getTemplate() {
// return template;
// }
//
// /**
// * @param template the template to set
// */
// public void setTemplate(String template) {
// this.template = template;
// }
//
// }
//
// Path: api/src/main/java/org/openmrs/module/hl7query/util/HL7QueryPrivilegeConstants.java
// public class HL7QueryPrivilegeConstants {
// @AddOnStartup(description = "Ability to Add, Edit or Delete HL7 templates")
// public static final String MANAGE_HL7_TEMPLATES = "Manage HL7 Templates";
//
// @AddOnStartup(description = "Ability to get, find or View HL7 templates")
// public static final String GET_HL7_TEMPLATES = "Get HL7 Templates";
//
// }
| import java.util.List;
import java.util.Map;
import org.openmrs.annotation.Authorized;
import org.openmrs.api.OpenmrsService;
import org.openmrs.module.hl7query.HL7Template;
import org.openmrs.module.hl7query.util.HL7QueryPrivilegeConstants;
import org.openmrs.util.PrivilegeConstants;
import org.springframework.transaction.annotation.Transactional; | /**
* The contents of this file are subject to the OpenMRS Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://license.openmrs.org
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
* License for the specific language governing rights and limitations
* under the License.
*
* Copyright (C) OpenMRS, LLC. All Rights Reserved.
*/
package org.openmrs.module.hl7query.api;
/**
* This service exposes module's core functionality. It is a Spring managed bean which is configured in moduleApplicationContext.xml.
* <p>
* It can be accessed only via Context:<br>
* <code>
* Context.getService(HL7QueryService.class).someMethod();
* </code>
*
* @see org.openmrs.api.context.Context
*/
@Transactional
public interface HL7QueryService extends OpenmrsService {
static final String LANGUAGE_GROOVY = "groovy";
/**
* Evaluates the given template against the given bindings, returning the text result (which should be XML)
*
* @param hl7Template
* @param bindings
* @return the result of evaluating the given template against the given bindings
*/ | // Path: api/src/main/java/org/openmrs/module/hl7query/HL7Template.java
// public class HL7Template extends BaseOpenmrsMetadata implements OpenmrsMetadata {
//
// private Integer hl7TemplateId;
//
// private String hl7Entity;
//
// private String language = HL7QueryService.LANGUAGE_GROOVY;
//
// private String template;
//
// /**
// * @see org.openmrs.OpenmrsObject#getId()
// */
// @Override
// public Integer getId() {
// return getHl7TemplateId();
// }
//
// /**
// * @see org.openmrs.OpenmrsObject#setId(java.lang.Integer)
// */
// @Override
// public void setId(Integer id) {
// setHl7TemplateId(id);
// }
//
// /**
// * @return the hl7TemplateId
// */
// public Integer getHl7TemplateId() {
// return hl7TemplateId;
// }
//
// /**
// * @param hl7TemplateId the hl7TemplateId to set
// */
// public void setHl7TemplateId(Integer hl7TemplateId) {
// this.hl7TemplateId = hl7TemplateId;
// }
//
// /**
// * @return the hl7Entity
// */
// public String getHl7Entity() {
// return hl7Entity;
// }
//
// /**
// * @param hl7Entity the hl7Entity to set
// */
// public void setHl7Entity(String hl7Entity) {
// this.hl7Entity = hl7Entity;
// }
//
// /**
// * @return the language
// */
// public String getLanguage() {
// return language;
// }
//
// /**
// * @param language the language to set
// */
// public void setLanguage(String language) {
// this.language = language;
// }
//
// /**
// * @return the template
// */
// public String getTemplate() {
// return template;
// }
//
// /**
// * @param template the template to set
// */
// public void setTemplate(String template) {
// this.template = template;
// }
//
// }
//
// Path: api/src/main/java/org/openmrs/module/hl7query/util/HL7QueryPrivilegeConstants.java
// public class HL7QueryPrivilegeConstants {
// @AddOnStartup(description = "Ability to Add, Edit or Delete HL7 templates")
// public static final String MANAGE_HL7_TEMPLATES = "Manage HL7 Templates";
//
// @AddOnStartup(description = "Ability to get, find or View HL7 templates")
// public static final String GET_HL7_TEMPLATES = "Get HL7 Templates";
//
// }
// Path: api/src/main/java/org/openmrs/module/hl7query/api/HL7QueryService.java
import java.util.List;
import java.util.Map;
import org.openmrs.annotation.Authorized;
import org.openmrs.api.OpenmrsService;
import org.openmrs.module.hl7query.HL7Template;
import org.openmrs.module.hl7query.util.HL7QueryPrivilegeConstants;
import org.openmrs.util.PrivilegeConstants;
import org.springframework.transaction.annotation.Transactional;
/**
* The contents of this file are subject to the OpenMRS Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://license.openmrs.org
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
* License for the specific language governing rights and limitations
* under the License.
*
* Copyright (C) OpenMRS, LLC. All Rights Reserved.
*/
package org.openmrs.module.hl7query.api;
/**
* This service exposes module's core functionality. It is a Spring managed bean which is configured in moduleApplicationContext.xml.
* <p>
* It can be accessed only via Context:<br>
* <code>
* Context.getService(HL7QueryService.class).someMethod();
* </code>
*
* @see org.openmrs.api.context.Context
*/
@Transactional
public interface HL7QueryService extends OpenmrsService {
static final String LANGUAGE_GROOVY = "groovy";
/**
* Evaluates the given template against the given bindings, returning the text result (which should be XML)
*
* @param hl7Template
* @param bindings
* @return the result of evaluating the given template against the given bindings
*/ | String evaluateTemplate(HL7Template hl7Template, Map<String, Object> bindings); |
openmrs/openmrs-module-hl7query | api/src/main/java/org/openmrs/module/hl7query/api/HL7QueryService.java | // Path: api/src/main/java/org/openmrs/module/hl7query/HL7Template.java
// public class HL7Template extends BaseOpenmrsMetadata implements OpenmrsMetadata {
//
// private Integer hl7TemplateId;
//
// private String hl7Entity;
//
// private String language = HL7QueryService.LANGUAGE_GROOVY;
//
// private String template;
//
// /**
// * @see org.openmrs.OpenmrsObject#getId()
// */
// @Override
// public Integer getId() {
// return getHl7TemplateId();
// }
//
// /**
// * @see org.openmrs.OpenmrsObject#setId(java.lang.Integer)
// */
// @Override
// public void setId(Integer id) {
// setHl7TemplateId(id);
// }
//
// /**
// * @return the hl7TemplateId
// */
// public Integer getHl7TemplateId() {
// return hl7TemplateId;
// }
//
// /**
// * @param hl7TemplateId the hl7TemplateId to set
// */
// public void setHl7TemplateId(Integer hl7TemplateId) {
// this.hl7TemplateId = hl7TemplateId;
// }
//
// /**
// * @return the hl7Entity
// */
// public String getHl7Entity() {
// return hl7Entity;
// }
//
// /**
// * @param hl7Entity the hl7Entity to set
// */
// public void setHl7Entity(String hl7Entity) {
// this.hl7Entity = hl7Entity;
// }
//
// /**
// * @return the language
// */
// public String getLanguage() {
// return language;
// }
//
// /**
// * @param language the language to set
// */
// public void setLanguage(String language) {
// this.language = language;
// }
//
// /**
// * @return the template
// */
// public String getTemplate() {
// return template;
// }
//
// /**
// * @param template the template to set
// */
// public void setTemplate(String template) {
// this.template = template;
// }
//
// }
//
// Path: api/src/main/java/org/openmrs/module/hl7query/util/HL7QueryPrivilegeConstants.java
// public class HL7QueryPrivilegeConstants {
// @AddOnStartup(description = "Ability to Add, Edit or Delete HL7 templates")
// public static final String MANAGE_HL7_TEMPLATES = "Manage HL7 Templates";
//
// @AddOnStartup(description = "Ability to get, find or View HL7 templates")
// public static final String GET_HL7_TEMPLATES = "Get HL7 Templates";
//
// }
| import java.util.List;
import java.util.Map;
import org.openmrs.annotation.Authorized;
import org.openmrs.api.OpenmrsService;
import org.openmrs.module.hl7query.HL7Template;
import org.openmrs.module.hl7query.util.HL7QueryPrivilegeConstants;
import org.openmrs.util.PrivilegeConstants;
import org.springframework.transaction.annotation.Transactional; | /**
* The contents of this file are subject to the OpenMRS Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://license.openmrs.org
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
* License for the specific language governing rights and limitations
* under the License.
*
* Copyright (C) OpenMRS, LLC. All Rights Reserved.
*/
package org.openmrs.module.hl7query.api;
/**
* This service exposes module's core functionality. It is a Spring managed bean which is configured in moduleApplicationContext.xml.
* <p>
* It can be accessed only via Context:<br>
* <code>
* Context.getService(HL7QueryService.class).someMethod();
* </code>
*
* @see org.openmrs.api.context.Context
*/
@Transactional
public interface HL7QueryService extends OpenmrsService {
static final String LANGUAGE_GROOVY = "groovy";
/**
* Evaluates the given template against the given bindings, returning the text result (which should be XML)
*
* @param hl7Template
* @param bindings
* @return the result of evaluating the given template against the given bindings
*/
String evaluateTemplate(HL7Template hl7Template, Map<String, Object> bindings);
/**
* Gets HL7Template by ID.
*
* @param id
* @return HL7Template or null
* @should return template if exists
* @should return null if does not exist
*/
@Transactional(readOnly = true) | // Path: api/src/main/java/org/openmrs/module/hl7query/HL7Template.java
// public class HL7Template extends BaseOpenmrsMetadata implements OpenmrsMetadata {
//
// private Integer hl7TemplateId;
//
// private String hl7Entity;
//
// private String language = HL7QueryService.LANGUAGE_GROOVY;
//
// private String template;
//
// /**
// * @see org.openmrs.OpenmrsObject#getId()
// */
// @Override
// public Integer getId() {
// return getHl7TemplateId();
// }
//
// /**
// * @see org.openmrs.OpenmrsObject#setId(java.lang.Integer)
// */
// @Override
// public void setId(Integer id) {
// setHl7TemplateId(id);
// }
//
// /**
// * @return the hl7TemplateId
// */
// public Integer getHl7TemplateId() {
// return hl7TemplateId;
// }
//
// /**
// * @param hl7TemplateId the hl7TemplateId to set
// */
// public void setHl7TemplateId(Integer hl7TemplateId) {
// this.hl7TemplateId = hl7TemplateId;
// }
//
// /**
// * @return the hl7Entity
// */
// public String getHl7Entity() {
// return hl7Entity;
// }
//
// /**
// * @param hl7Entity the hl7Entity to set
// */
// public void setHl7Entity(String hl7Entity) {
// this.hl7Entity = hl7Entity;
// }
//
// /**
// * @return the language
// */
// public String getLanguage() {
// return language;
// }
//
// /**
// * @param language the language to set
// */
// public void setLanguage(String language) {
// this.language = language;
// }
//
// /**
// * @return the template
// */
// public String getTemplate() {
// return template;
// }
//
// /**
// * @param template the template to set
// */
// public void setTemplate(String template) {
// this.template = template;
// }
//
// }
//
// Path: api/src/main/java/org/openmrs/module/hl7query/util/HL7QueryPrivilegeConstants.java
// public class HL7QueryPrivilegeConstants {
// @AddOnStartup(description = "Ability to Add, Edit or Delete HL7 templates")
// public static final String MANAGE_HL7_TEMPLATES = "Manage HL7 Templates";
//
// @AddOnStartup(description = "Ability to get, find or View HL7 templates")
// public static final String GET_HL7_TEMPLATES = "Get HL7 Templates";
//
// }
// Path: api/src/main/java/org/openmrs/module/hl7query/api/HL7QueryService.java
import java.util.List;
import java.util.Map;
import org.openmrs.annotation.Authorized;
import org.openmrs.api.OpenmrsService;
import org.openmrs.module.hl7query.HL7Template;
import org.openmrs.module.hl7query.util.HL7QueryPrivilegeConstants;
import org.openmrs.util.PrivilegeConstants;
import org.springframework.transaction.annotation.Transactional;
/**
* The contents of this file are subject to the OpenMRS Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://license.openmrs.org
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
* License for the specific language governing rights and limitations
* under the License.
*
* Copyright (C) OpenMRS, LLC. All Rights Reserved.
*/
package org.openmrs.module.hl7query.api;
/**
* This service exposes module's core functionality. It is a Spring managed bean which is configured in moduleApplicationContext.xml.
* <p>
* It can be accessed only via Context:<br>
* <code>
* Context.getService(HL7QueryService.class).someMethod();
* </code>
*
* @see org.openmrs.api.context.Context
*/
@Transactional
public interface HL7QueryService extends OpenmrsService {
static final String LANGUAGE_GROOVY = "groovy";
/**
* Evaluates the given template against the given bindings, returning the text result (which should be XML)
*
* @param hl7Template
* @param bindings
* @return the result of evaluating the given template against the given bindings
*/
String evaluateTemplate(HL7Template hl7Template, Map<String, Object> bindings);
/**
* Gets HL7Template by ID.
*
* @param id
* @return HL7Template or null
* @should return template if exists
* @should return null if does not exist
*/
@Transactional(readOnly = true) | @Authorized({HL7QueryPrivilegeConstants.GET_HL7_TEMPLATES}) |
openmrs/openmrs-module-hl7query | api/src/main/java/org/openmrs/module/hl7query/api/db/hibernate/HibernateHL7QueryDAO.java | // Path: api/src/main/java/org/openmrs/module/hl7query/HL7Template.java
// public class HL7Template extends BaseOpenmrsMetadata implements OpenmrsMetadata {
//
// private Integer hl7TemplateId;
//
// private String hl7Entity;
//
// private String language = HL7QueryService.LANGUAGE_GROOVY;
//
// private String template;
//
// /**
// * @see org.openmrs.OpenmrsObject#getId()
// */
// @Override
// public Integer getId() {
// return getHl7TemplateId();
// }
//
// /**
// * @see org.openmrs.OpenmrsObject#setId(java.lang.Integer)
// */
// @Override
// public void setId(Integer id) {
// setHl7TemplateId(id);
// }
//
// /**
// * @return the hl7TemplateId
// */
// public Integer getHl7TemplateId() {
// return hl7TemplateId;
// }
//
// /**
// * @param hl7TemplateId the hl7TemplateId to set
// */
// public void setHl7TemplateId(Integer hl7TemplateId) {
// this.hl7TemplateId = hl7TemplateId;
// }
//
// /**
// * @return the hl7Entity
// */
// public String getHl7Entity() {
// return hl7Entity;
// }
//
// /**
// * @param hl7Entity the hl7Entity to set
// */
// public void setHl7Entity(String hl7Entity) {
// this.hl7Entity = hl7Entity;
// }
//
// /**
// * @return the language
// */
// public String getLanguage() {
// return language;
// }
//
// /**
// * @param language the language to set
// */
// public void setLanguage(String language) {
// this.language = language;
// }
//
// /**
// * @return the template
// */
// public String getTemplate() {
// return template;
// }
//
// /**
// * @param template the template to set
// */
// public void setTemplate(String template) {
// this.template = template;
// }
//
// }
//
// Path: api/src/main/java/org/openmrs/module/hl7query/api/db/HL7QueryDAO.java
// public interface HL7QueryDAO {
//
// /**
// * @see HL7QueryService#getHL7Template(Integer)
// */
// HL7Template getHL7Template(Integer id);
//
// /**
// * @see HL7QueryService#getHL7TemplateByUuid(String)
// */
// HL7Template getHL7TemplateByUuid(String uuid);
//
// /**
// * @see HL7QueryService#getHL7TemplateByName(String)
// */
// HL7Template getHL7TemplateByName(String name);
//
// /**
// * @see HL7QueryService#getHL7TemplatesByName(String)
// */
// List<HL7Template> getHL7TemplatesByName(String name);
//
// /**
// * @see HL7QueryService#getHL7TemplatesByEntity(String)
// */
// List<HL7Template> getHL7TemplatesByEntity(String entity);
//
// /**
// * @see HL7QueryService#saveHL7Template(HL7Template)
// */
// HL7Template saveHL7Template(HL7Template hl7Template);
//
// /**
// * @see HL7QueryService#retireHL7Template(HL7Template, String)
// */
// HL7Template retireHL7Template(HL7Template hl7Template, String reason);
//
// /**
// * @see HL7QueryService#unretireHL7Template(HL7Template)
// */
// HL7Template unretireHL7Template(HL7Template hl7Template);
//
// /**
// * @see HL7QueryService#purgeHL7Template(HL7Template)
// */
// void purgeHL7Template(HL7Template hl7Template);
//
// /**
// * @see HL7QueryService#getHL7Templates(boolean)
// */
// List<HL7Template> getHL7Templates(boolean includeRetired);
// }
| import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.Criteria;
import org.hibernate.SessionFactory;
import org.hibernate.criterion.MatchMode;
import org.hibernate.criterion.Order;
import org.hibernate.criterion.Restrictions;
import org.openmrs.module.hl7query.HL7Template;
import org.openmrs.module.hl7query.api.db.HL7QueryDAO; | /**
* The contents of this file are subject to the OpenMRS Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://license.openmrs.org
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
* License for the specific language governing rights and limitations
* under the License.
*
* Copyright (C) OpenMRS, LLC. All Rights Reserved.
*/
package org.openmrs.module.hl7query.api.db.hibernate;
/**
* It is a default implementation of {@link HL7QueryDAO}.
*/
public class HibernateHL7QueryDAO implements HL7QueryDAO {
protected final Log log = LogFactory.getLog(this.getClass());
private SessionFactory sessionFactory;
/**
* @param sessionFactory the sessionFactory to set
*/
public void setSessionFactory(SessionFactory sessionFactory) {
this.sessionFactory = sessionFactory;
}
/**
* @return the sessionFactory
*/
public SessionFactory getSessionFactory() {
return sessionFactory;
}
@Override | // Path: api/src/main/java/org/openmrs/module/hl7query/HL7Template.java
// public class HL7Template extends BaseOpenmrsMetadata implements OpenmrsMetadata {
//
// private Integer hl7TemplateId;
//
// private String hl7Entity;
//
// private String language = HL7QueryService.LANGUAGE_GROOVY;
//
// private String template;
//
// /**
// * @see org.openmrs.OpenmrsObject#getId()
// */
// @Override
// public Integer getId() {
// return getHl7TemplateId();
// }
//
// /**
// * @see org.openmrs.OpenmrsObject#setId(java.lang.Integer)
// */
// @Override
// public void setId(Integer id) {
// setHl7TemplateId(id);
// }
//
// /**
// * @return the hl7TemplateId
// */
// public Integer getHl7TemplateId() {
// return hl7TemplateId;
// }
//
// /**
// * @param hl7TemplateId the hl7TemplateId to set
// */
// public void setHl7TemplateId(Integer hl7TemplateId) {
// this.hl7TemplateId = hl7TemplateId;
// }
//
// /**
// * @return the hl7Entity
// */
// public String getHl7Entity() {
// return hl7Entity;
// }
//
// /**
// * @param hl7Entity the hl7Entity to set
// */
// public void setHl7Entity(String hl7Entity) {
// this.hl7Entity = hl7Entity;
// }
//
// /**
// * @return the language
// */
// public String getLanguage() {
// return language;
// }
//
// /**
// * @param language the language to set
// */
// public void setLanguage(String language) {
// this.language = language;
// }
//
// /**
// * @return the template
// */
// public String getTemplate() {
// return template;
// }
//
// /**
// * @param template the template to set
// */
// public void setTemplate(String template) {
// this.template = template;
// }
//
// }
//
// Path: api/src/main/java/org/openmrs/module/hl7query/api/db/HL7QueryDAO.java
// public interface HL7QueryDAO {
//
// /**
// * @see HL7QueryService#getHL7Template(Integer)
// */
// HL7Template getHL7Template(Integer id);
//
// /**
// * @see HL7QueryService#getHL7TemplateByUuid(String)
// */
// HL7Template getHL7TemplateByUuid(String uuid);
//
// /**
// * @see HL7QueryService#getHL7TemplateByName(String)
// */
// HL7Template getHL7TemplateByName(String name);
//
// /**
// * @see HL7QueryService#getHL7TemplatesByName(String)
// */
// List<HL7Template> getHL7TemplatesByName(String name);
//
// /**
// * @see HL7QueryService#getHL7TemplatesByEntity(String)
// */
// List<HL7Template> getHL7TemplatesByEntity(String entity);
//
// /**
// * @see HL7QueryService#saveHL7Template(HL7Template)
// */
// HL7Template saveHL7Template(HL7Template hl7Template);
//
// /**
// * @see HL7QueryService#retireHL7Template(HL7Template, String)
// */
// HL7Template retireHL7Template(HL7Template hl7Template, String reason);
//
// /**
// * @see HL7QueryService#unretireHL7Template(HL7Template)
// */
// HL7Template unretireHL7Template(HL7Template hl7Template);
//
// /**
// * @see HL7QueryService#purgeHL7Template(HL7Template)
// */
// void purgeHL7Template(HL7Template hl7Template);
//
// /**
// * @see HL7QueryService#getHL7Templates(boolean)
// */
// List<HL7Template> getHL7Templates(boolean includeRetired);
// }
// Path: api/src/main/java/org/openmrs/module/hl7query/api/db/hibernate/HibernateHL7QueryDAO.java
import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.Criteria;
import org.hibernate.SessionFactory;
import org.hibernate.criterion.MatchMode;
import org.hibernate.criterion.Order;
import org.hibernate.criterion.Restrictions;
import org.openmrs.module.hl7query.HL7Template;
import org.openmrs.module.hl7query.api.db.HL7QueryDAO;
/**
* The contents of this file are subject to the OpenMRS Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://license.openmrs.org
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
* License for the specific language governing rights and limitations
* under the License.
*
* Copyright (C) OpenMRS, LLC. All Rights Reserved.
*/
package org.openmrs.module.hl7query.api.db.hibernate;
/**
* It is a default implementation of {@link HL7QueryDAO}.
*/
public class HibernateHL7QueryDAO implements HL7QueryDAO {
protected final Log log = LogFactory.getLog(this.getClass());
private SessionFactory sessionFactory;
/**
* @param sessionFactory the sessionFactory to set
*/
public void setSessionFactory(SessionFactory sessionFactory) {
this.sessionFactory = sessionFactory;
}
/**
* @return the sessionFactory
*/
public SessionFactory getSessionFactory() {
return sessionFactory;
}
@Override | public HL7Template getHL7Template(Integer id) { |
openmrs/openmrs-module-hl7query | omod/src/main/java/org/openmrs/module/hl7query/web/controller/Hl7QuerySessionController.java | // Path: api/src/main/java/org/openmrs/module/hl7query/AuthenticationErrorObject.java
// public class AuthenticationErrorObject extends LinkedHashMap<String, Object> {
//
// private static final long serialVersionUID = 1L;
//
// public AuthenticationErrorObject() {
// super();
// }
//
// /**
// * Puts a property in this map, and returns the map itself (for chained method calls)
// *
// * @param key
// * @param value
// * @return
// */
// public AuthenticationErrorObject add(String key, Object value) {
// put(key, value);
// return this;
// }
//
// /**
// * Removes a property from the map, and returns the map itself (for chained method calls)
// *
// * @param key
// * @return
// */
// public AuthenticationErrorObject removeProperty(String key) {
// remove(key);
// return this;
// }
//
// /**
// * Creates an instance from the given json string.
// *
// * @param json
// * @return the simpleObject
// * @throws JsonParseException
// * @throws JsonMappingException
// * @throws IOException
// */
// public static AuthenticationErrorObject parseJson(String json) throws JsonParseException, JsonMappingException, IOException {
// ObjectMapper objectMapper = new ObjectMapper();
// AuthenticationErrorObject object = objectMapper.readValue(json, AuthenticationErrorObject.class);
// return object;
// }
// }
| import org.openmrs.api.context.Context;
import org.openmrs.module.hl7query.AuthenticationErrorObject;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.context.request.WebRequest; | package org.openmrs.module.hl7query.web.controller;
/**
* The contents of this file are subject to the OpenMRS Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://license.openmrs.org
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
* License for the specific language governing rights and limitations
* under the License.
*
* Copyright (C) OpenMRS, LLC. All Rights Reserved.
*/
/**
* Controller that lets a client check the status of their session, and log out. (Authenticating is handled through a filter, and may happen through this or
* any other resource.
*/
@Controller
@RequestMapping(value = "/module/hl7query/session")
public class Hl7QuerySessionController extends BaseHL7QueryController {
/**
* Tells the user their sessionId, and whether or not they are authenticated.
*
* @param request
* @return
* @should return the session id if the user is authenticated
* @should return the session id if the user is not authenticated
*/
@RequestMapping(method = RequestMethod.GET)
@ResponseBody
public Object get(WebRequest request) { | // Path: api/src/main/java/org/openmrs/module/hl7query/AuthenticationErrorObject.java
// public class AuthenticationErrorObject extends LinkedHashMap<String, Object> {
//
// private static final long serialVersionUID = 1L;
//
// public AuthenticationErrorObject() {
// super();
// }
//
// /**
// * Puts a property in this map, and returns the map itself (for chained method calls)
// *
// * @param key
// * @param value
// * @return
// */
// public AuthenticationErrorObject add(String key, Object value) {
// put(key, value);
// return this;
// }
//
// /**
// * Removes a property from the map, and returns the map itself (for chained method calls)
// *
// * @param key
// * @return
// */
// public AuthenticationErrorObject removeProperty(String key) {
// remove(key);
// return this;
// }
//
// /**
// * Creates an instance from the given json string.
// *
// * @param json
// * @return the simpleObject
// * @throws JsonParseException
// * @throws JsonMappingException
// * @throws IOException
// */
// public static AuthenticationErrorObject parseJson(String json) throws JsonParseException, JsonMappingException, IOException {
// ObjectMapper objectMapper = new ObjectMapper();
// AuthenticationErrorObject object = objectMapper.readValue(json, AuthenticationErrorObject.class);
// return object;
// }
// }
// Path: omod/src/main/java/org/openmrs/module/hl7query/web/controller/Hl7QuerySessionController.java
import org.openmrs.api.context.Context;
import org.openmrs.module.hl7query.AuthenticationErrorObject;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.context.request.WebRequest;
package org.openmrs.module.hl7query.web.controller;
/**
* The contents of this file are subject to the OpenMRS Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://license.openmrs.org
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
* License for the specific language governing rights and limitations
* under the License.
*
* Copyright (C) OpenMRS, LLC. All Rights Reserved.
*/
/**
* Controller that lets a client check the status of their session, and log out. (Authenticating is handled through a filter, and may happen through this or
* any other resource.
*/
@Controller
@RequestMapping(value = "/module/hl7query/session")
public class Hl7QuerySessionController extends BaseHL7QueryController {
/**
* Tells the user their sessionId, and whether or not they are authenticated.
*
* @param request
* @return
* @should return the session id if the user is authenticated
* @should return the session id if the user is not authenticated
*/
@RequestMapping(method = RequestMethod.GET)
@ResponseBody
public Object get(WebRequest request) { | return new AuthenticationErrorObject().add("sessionId", request.getSessionId()).add("authenticated", Context.isAuthenticated()); |
openmrs/openmrs-module-hl7query | api/src/main/java/org/openmrs/module/hl7query/api/impl/GroovyTemplateFactory.java | // Path: api/src/main/java/org/openmrs/module/hl7query/HL7TemplateException.java
// public class HL7TemplateException extends APIException {
//
// private static final long serialVersionUID = 1L;
//
// public HL7TemplateException() {
// super();
// }
//
// /**
// * @param cause
// */
// public HL7TemplateException(Exception cause) {
// super(cause);
// }
//
// /**
// * @param message
// * @param cause
// */
// public HL7TemplateException(String message, Exception cause) {
// super(message, cause);
// }
//
// }
| import org.openmrs.module.hl7query.HL7TemplateException;
import groovy.text.SimpleTemplateEngine; | /**
* The contents of this file are subject to the OpenMRS Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://license.openmrs.org
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
* License for the specific language governing rights and limitations
* under the License.
*
* Copyright (C) OpenMRS, LLC. All Rights Reserved.
*/
package org.openmrs.module.hl7query.api.impl;
/**
* Groovy-based implementation of TemplateFactory
*/
public class GroovyTemplateFactory implements TemplateFactory<PreparedGroovyTemplate> {
SimpleTemplateEngine templateEngine;
public GroovyTemplateFactory() {
// use this module's ModuleClassLoader
templateEngine = new SimpleTemplateEngine(getClass().getClassLoader());
}
/**
* @see org.openmrs.module.hl7query.api.impl.TemplateFactory#prepareTemplate(java.lang.String)
*/
@Override | // Path: api/src/main/java/org/openmrs/module/hl7query/HL7TemplateException.java
// public class HL7TemplateException extends APIException {
//
// private static final long serialVersionUID = 1L;
//
// public HL7TemplateException() {
// super();
// }
//
// /**
// * @param cause
// */
// public HL7TemplateException(Exception cause) {
// super(cause);
// }
//
// /**
// * @param message
// * @param cause
// */
// public HL7TemplateException(String message, Exception cause) {
// super(message, cause);
// }
//
// }
// Path: api/src/main/java/org/openmrs/module/hl7query/api/impl/GroovyTemplateFactory.java
import org.openmrs.module.hl7query.HL7TemplateException;
import groovy.text.SimpleTemplateEngine;
/**
* The contents of this file are subject to the OpenMRS Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://license.openmrs.org
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
* License for the specific language governing rights and limitations
* under the License.
*
* Copyright (C) OpenMRS, LLC. All Rights Reserved.
*/
package org.openmrs.module.hl7query.api.impl;
/**
* Groovy-based implementation of TemplateFactory
*/
public class GroovyTemplateFactory implements TemplateFactory<PreparedGroovyTemplate> {
SimpleTemplateEngine templateEngine;
public GroovyTemplateFactory() {
// use this module's ModuleClassLoader
templateEngine = new SimpleTemplateEngine(getClass().getClassLoader());
}
/**
* @see org.openmrs.module.hl7query.api.impl.TemplateFactory#prepareTemplate(java.lang.String)
*/
@Override | public PreparedGroovyTemplate prepareTemplate(String templateText) throws HL7TemplateException { |
openmrs/openmrs-module-hl7query | api/src/main/java/org/openmrs/module/hl7query/api/impl/PreparedGroovyTemplate.java | // Path: api/src/main/java/org/openmrs/module/hl7query/HL7TemplateException.java
// public class HL7TemplateException extends APIException {
//
// private static final long serialVersionUID = 1L;
//
// public HL7TemplateException() {
// super();
// }
//
// /**
// * @param cause
// */
// public HL7TemplateException(Exception cause) {
// super(cause);
// }
//
// /**
// * @param message
// * @param cause
// */
// public HL7TemplateException(String message, Exception cause) {
// super(message, cause);
// }
//
// }
| import java.util.Map;
import org.openmrs.module.hl7query.HL7TemplateException;
import groovy.text.Template; | /**
* The contents of this file are subject to the OpenMRS Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://license.openmrs.org
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
* License for the specific language governing rights and limitations
* under the License.
*
* Copyright (C) OpenMRS, LLC. All Rights Reserved.
*/
package org.openmrs.module.hl7query.api.impl;
/**
* Simple wrapper around a Groovy {@link Template} object
*/
public class PreparedGroovyTemplate implements PreparedTemplate {
Template template;
public PreparedGroovyTemplate(Template template) {
this.template = template;
}
/**
* @see org.openmrs.module.hl7query.api.impl.PreparedTemplate#evaluate(java.util.Map)
*/
@Override | // Path: api/src/main/java/org/openmrs/module/hl7query/HL7TemplateException.java
// public class HL7TemplateException extends APIException {
//
// private static final long serialVersionUID = 1L;
//
// public HL7TemplateException() {
// super();
// }
//
// /**
// * @param cause
// */
// public HL7TemplateException(Exception cause) {
// super(cause);
// }
//
// /**
// * @param message
// * @param cause
// */
// public HL7TemplateException(String message, Exception cause) {
// super(message, cause);
// }
//
// }
// Path: api/src/main/java/org/openmrs/module/hl7query/api/impl/PreparedGroovyTemplate.java
import java.util.Map;
import org.openmrs.module.hl7query.HL7TemplateException;
import groovy.text.Template;
/**
* The contents of this file are subject to the OpenMRS Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://license.openmrs.org
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
* License for the specific language governing rights and limitations
* under the License.
*
* Copyright (C) OpenMRS, LLC. All Rights Reserved.
*/
package org.openmrs.module.hl7query.api.impl;
/**
* Simple wrapper around a Groovy {@link Template} object
*/
public class PreparedGroovyTemplate implements PreparedTemplate {
Template template;
public PreparedGroovyTemplate(Template template) {
this.template = template;
}
/**
* @see org.openmrs.module.hl7query.api.impl.PreparedTemplate#evaluate(java.util.Map)
*/
@Override | public String evaluate(Map<String, Object> bindings) throws HL7TemplateException { |
mattkist/ADReNA | Java/ADReNA_API/src/ADReNA_API/Backpropagation/BackpropagationConnection.java | // Path: Java/ADReNA_API/src/ADReNA_API/Util/Randomizer.java
// public class Randomizer {
//
// private Randomizer(){}
//
// private static Random rnd = new Random();
//
// /*
// * Retorna um valor double aleatório
// */
// public static double NextDouble()
// {
// return rnd.nextDouble();
// }
//
// /*
// * Retorna um valor double aleatório de 0 até determinado número
// */
// public static double NextDouble(int max)
// {
// return rnd.nextDouble() * max;
// }
// }
| import ADReNA_API.Util.Randomizer; | package ADReNA_API.Backpropagation;
public class BackpropagationConnection {
public BackpropagationNeuron neuron;
public double valueWeight; //{peso da ligação}
public double deltaWeight;
public BackpropagationConnection(BackpropagationNeuron neuron)
{
this.neuron = neuron; | // Path: Java/ADReNA_API/src/ADReNA_API/Util/Randomizer.java
// public class Randomizer {
//
// private Randomizer(){}
//
// private static Random rnd = new Random();
//
// /*
// * Retorna um valor double aleatório
// */
// public static double NextDouble()
// {
// return rnd.nextDouble();
// }
//
// /*
// * Retorna um valor double aleatório de 0 até determinado número
// */
// public static double NextDouble(int max)
// {
// return rnd.nextDouble() * max;
// }
// }
// Path: Java/ADReNA_API/src/ADReNA_API/Backpropagation/BackpropagationConnection.java
import ADReNA_API.Util.Randomizer;
package ADReNA_API.Backpropagation;
public class BackpropagationConnection {
public BackpropagationNeuron neuron;
public double valueWeight; //{peso da ligação}
public double deltaWeight;
public BackpropagationConnection(BackpropagationNeuron neuron)
{
this.neuron = neuron; | this.valueWeight = (Randomizer.NextDouble(1)-0.5); //RANDON VALUE BETWEEN [-0.5 AND +0.5] |
mattkist/ADReNA | Java/ADReNA_API/src/ADReNA_API/Util/CommonStructure.java | // Path: Java/ADReNA_API/src/ADReNA_API/Util/ExportImportCommon.java
// public enum AnnType { Backpropagation, Kohonen }
| import ADReNA_API.Util.ExportImportCommon.AnnType; | package ADReNA_API.Util;
public class CommonStructure
{ | // Path: Java/ADReNA_API/src/ADReNA_API/Util/ExportImportCommon.java
// public enum AnnType { Backpropagation, Kohonen }
// Path: Java/ADReNA_API/src/ADReNA_API/Util/CommonStructure.java
import ADReNA_API.Util.ExportImportCommon.AnnType;
package ADReNA_API.Util;
public class CommonStructure
{ | public AnnType type; |
mattkist/ADReNA | Java/ADReNA_API/src/ADReNA_API/NeuralNetwork/INeuralNetwork.java | // Path: Java/ADReNA_API/src/ADReNA_API/Data/DataSet.java
// public class DataSet {
//
// public ArrayList<DataSetObject> data;
// public int inputSize, outputSize;
//
// /*
// * Cria uma instância de um conjunto de dados nulo
// */
// public DataSet()
// {
// BuildNewDataSet(0, 0);
// }
//
// /*
// * Cria uma instância de um novo conjunto de dados
// */
// public DataSet(int inputSize)
// {
// BuildNewDataSet(inputSize, 0);
// }
//
// /*
// * Cria uma instância de um novo conjunto de dados
// */
// public DataSet(int inputSize, int outputSize)
// {
// BuildNewDataSet(inputSize, outputSize);
// }
//
// private void BuildNewDataSet(int inputSize, int outputSize)
// {
// this.inputSize = inputSize;
// this.outputSize = outputSize;
// data = new ArrayList<DataSetObject>();
// }
//
//
// /*
// * Adiciona um dado ao conjunto de dados
// * Retorna um erro se o dado tiver um formato incorreto
// */
// public void Add(DataSetObject obj) throws Exception
// {
// if (obj.GetInputLenght() == inputSize && obj.GetTargetOutputLenght() == outputSize)
// data.add(obj);
// else
// throw new Exception("Incorrect data format!");
// }
//
// /*
// * Retorna a lista de padrões
// */
// public ArrayList<DataSetObject> GetList()
// {
// return data;
// }
//
// /*
// * Retorna a quantidade de padrões
// */
// public int Length()
// {
// return data.size();
// }
//
// /*
// * Retorna o tamanho dos padroes de entrada
// */
// public int GetInputSize()
// {
// return this.inputSize;
// }
//
// /*
// * Retorna o tamanho dos padroes de saida
// */
// public int GetOutputSize()
// {
// return this.outputSize;
// }
//
// }
| import ADReNA_API.Data.DataSet; | package ADReNA_API.NeuralNetwork;
public interface INeuralNetwork
{ | // Path: Java/ADReNA_API/src/ADReNA_API/Data/DataSet.java
// public class DataSet {
//
// public ArrayList<DataSetObject> data;
// public int inputSize, outputSize;
//
// /*
// * Cria uma instância de um conjunto de dados nulo
// */
// public DataSet()
// {
// BuildNewDataSet(0, 0);
// }
//
// /*
// * Cria uma instância de um novo conjunto de dados
// */
// public DataSet(int inputSize)
// {
// BuildNewDataSet(inputSize, 0);
// }
//
// /*
// * Cria uma instância de um novo conjunto de dados
// */
// public DataSet(int inputSize, int outputSize)
// {
// BuildNewDataSet(inputSize, outputSize);
// }
//
// private void BuildNewDataSet(int inputSize, int outputSize)
// {
// this.inputSize = inputSize;
// this.outputSize = outputSize;
// data = new ArrayList<DataSetObject>();
// }
//
//
// /*
// * Adiciona um dado ao conjunto de dados
// * Retorna um erro se o dado tiver um formato incorreto
// */
// public void Add(DataSetObject obj) throws Exception
// {
// if (obj.GetInputLenght() == inputSize && obj.GetTargetOutputLenght() == outputSize)
// data.add(obj);
// else
// throw new Exception("Incorrect data format!");
// }
//
// /*
// * Retorna a lista de padrões
// */
// public ArrayList<DataSetObject> GetList()
// {
// return data;
// }
//
// /*
// * Retorna a quantidade de padrões
// */
// public int Length()
// {
// return data.size();
// }
//
// /*
// * Retorna o tamanho dos padroes de entrada
// */
// public int GetInputSize()
// {
// return this.inputSize;
// }
//
// /*
// * Retorna o tamanho dos padroes de saida
// */
// public int GetOutputSize()
// {
// return this.outputSize;
// }
//
// }
// Path: Java/ADReNA_API/src/ADReNA_API/NeuralNetwork/INeuralNetwork.java
import ADReNA_API.Data.DataSet;
package ADReNA_API.NeuralNetwork;
public interface INeuralNetwork
{ | void Learn(DataSet trainingSet) throws Exception; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.