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
greenrobot/EventBus
EventBus/src/org/greenrobot/eventbus/android/AndroidComponents.java
// Path: EventBus/src/org/greenrobot/eventbus/Logger.java // public interface Logger { // // void log(Level level, String msg); // // void log(Level level, String msg, Throwable th); // // class JavaLogger implements Logger { // protected final java.util.logging.Logger logger; // // public JavaLogger(String tag) { // logger = java.util.logging.Logger.getLogger(tag); // } // // @Override // public void log(Level level, String msg) { // // TODO Replace logged method with caller method // logger.log(level, msg); // } // // @Override // public void log(Level level, String msg, Throwable th) { // // TODO Replace logged method with caller method // logger.log(level, msg, th); // } // // } // // class SystemOutLogger implements Logger { // // @Override // public void log(Level level, String msg) { // System.out.println("[" + level + "] " + msg); // } // // @Override // public void log(Level level, String msg, Throwable th) { // System.out.println("[" + level + "] " + msg); // th.printStackTrace(System.out); // } // // } // // class Default { // public static Logger get() { // if (AndroidComponents.areAvailable()) { // return AndroidComponents.get().logger; // } // // return new SystemOutLogger(); // } // } // // } // // Path: EventBus/src/org/greenrobot/eventbus/MainThreadSupport.java // public interface MainThreadSupport { // // boolean isMainThread(); // // Poster createPoster(EventBus eventBus); // }
import org.greenrobot.eventbus.Logger; import org.greenrobot.eventbus.MainThreadSupport;
package org.greenrobot.eventbus.android; public abstract class AndroidComponents { private static final AndroidComponents implementation; static { implementation = AndroidDependenciesDetector.isAndroidSDKAvailable() ? AndroidDependenciesDetector.instantiateAndroidComponents() : null; } public static boolean areAvailable() { return implementation != null; } public static AndroidComponents get() { return implementation; } public final Logger logger;
// Path: EventBus/src/org/greenrobot/eventbus/Logger.java // public interface Logger { // // void log(Level level, String msg); // // void log(Level level, String msg, Throwable th); // // class JavaLogger implements Logger { // protected final java.util.logging.Logger logger; // // public JavaLogger(String tag) { // logger = java.util.logging.Logger.getLogger(tag); // } // // @Override // public void log(Level level, String msg) { // // TODO Replace logged method with caller method // logger.log(level, msg); // } // // @Override // public void log(Level level, String msg, Throwable th) { // // TODO Replace logged method with caller method // logger.log(level, msg, th); // } // // } // // class SystemOutLogger implements Logger { // // @Override // public void log(Level level, String msg) { // System.out.println("[" + level + "] " + msg); // } // // @Override // public void log(Level level, String msg, Throwable th) { // System.out.println("[" + level + "] " + msg); // th.printStackTrace(System.out); // } // // } // // class Default { // public static Logger get() { // if (AndroidComponents.areAvailable()) { // return AndroidComponents.get().logger; // } // // return new SystemOutLogger(); // } // } // // } // // Path: EventBus/src/org/greenrobot/eventbus/MainThreadSupport.java // public interface MainThreadSupport { // // boolean isMainThread(); // // Poster createPoster(EventBus eventBus); // } // Path: EventBus/src/org/greenrobot/eventbus/android/AndroidComponents.java import org.greenrobot.eventbus.Logger; import org.greenrobot.eventbus.MainThreadSupport; package org.greenrobot.eventbus.android; public abstract class AndroidComponents { private static final AndroidComponents implementation; static { implementation = AndroidDependenciesDetector.isAndroidSDKAvailable() ? AndroidDependenciesDetector.instantiateAndroidComponents() : null; } public static boolean areAvailable() { return implementation != null; } public static AndroidComponents get() { return implementation; } public final Logger logger;
public final MainThreadSupport defaultMainThreadSupport;
GiraffaFS/giraffa
giraffa-core/src/main/java/org/apache/giraffa/RowKeyFactoryProvider.java
// Path: giraffa-core/src/main/java/org/apache/giraffa/GiraffaConfiguration.java // public static final Boolean GRFA_CACHING_DEFAULT = true; // // Path: giraffa-core/src/main/java/org/apache/giraffa/GiraffaConfiguration.java // public static final String GRFA_CACHING_KEY = "grfa.rowkey.caching"; // // Path: giraffa-core/src/main/java/org/apache/giraffa/GiraffaConfiguration.java // public static final Class<? extends RowKeyFactory> // GRFA_ROWKEY_FACTORY_DEFAULT = FullPathRowKeyFactory.class; // // Path: giraffa-core/src/main/java/org/apache/giraffa/GiraffaConfiguration.java // public static final String GRFA_ROWKEY_FACTORY_KEY = // "grfa.rowkey.factory.class";
import static org.apache.giraffa.GiraffaConfiguration.GRFA_CACHING_DEFAULT; import static org.apache.giraffa.GiraffaConfiguration.GRFA_CACHING_KEY; import static org.apache.giraffa.GiraffaConfiguration.GRFA_ROWKEY_FACTORY_DEFAULT; import static org.apache.giraffa.GiraffaConfiguration.GRFA_ROWKEY_FACTORY_KEY; import java.io.IOException; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.util.ReflectionUtils;
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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 org.apache.giraffa; public class RowKeyFactoryProvider { private static Class<? extends RowKeyFactory> rowKeyFactoryClass; public static RowKeyFactory createFactory(Configuration conf) throws IOException {
// Path: giraffa-core/src/main/java/org/apache/giraffa/GiraffaConfiguration.java // public static final Boolean GRFA_CACHING_DEFAULT = true; // // Path: giraffa-core/src/main/java/org/apache/giraffa/GiraffaConfiguration.java // public static final String GRFA_CACHING_KEY = "grfa.rowkey.caching"; // // Path: giraffa-core/src/main/java/org/apache/giraffa/GiraffaConfiguration.java // public static final Class<? extends RowKeyFactory> // GRFA_ROWKEY_FACTORY_DEFAULT = FullPathRowKeyFactory.class; // // Path: giraffa-core/src/main/java/org/apache/giraffa/GiraffaConfiguration.java // public static final String GRFA_ROWKEY_FACTORY_KEY = // "grfa.rowkey.factory.class"; // Path: giraffa-core/src/main/java/org/apache/giraffa/RowKeyFactoryProvider.java import static org.apache.giraffa.GiraffaConfiguration.GRFA_CACHING_DEFAULT; import static org.apache.giraffa.GiraffaConfiguration.GRFA_CACHING_KEY; import static org.apache.giraffa.GiraffaConfiguration.GRFA_ROWKEY_FACTORY_DEFAULT; import static org.apache.giraffa.GiraffaConfiguration.GRFA_ROWKEY_FACTORY_KEY; import java.io.IOException; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.util.ReflectionUtils; /** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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 org.apache.giraffa; public class RowKeyFactoryProvider { private static Class<? extends RowKeyFactory> rowKeyFactoryClass; public static RowKeyFactory createFactory(Configuration conf) throws IOException {
boolean caching = conf.getBoolean(GRFA_CACHING_KEY, GRFA_CACHING_DEFAULT);
GiraffaFS/giraffa
giraffa-core/src/main/java/org/apache/giraffa/RowKeyFactoryProvider.java
// Path: giraffa-core/src/main/java/org/apache/giraffa/GiraffaConfiguration.java // public static final Boolean GRFA_CACHING_DEFAULT = true; // // Path: giraffa-core/src/main/java/org/apache/giraffa/GiraffaConfiguration.java // public static final String GRFA_CACHING_KEY = "grfa.rowkey.caching"; // // Path: giraffa-core/src/main/java/org/apache/giraffa/GiraffaConfiguration.java // public static final Class<? extends RowKeyFactory> // GRFA_ROWKEY_FACTORY_DEFAULT = FullPathRowKeyFactory.class; // // Path: giraffa-core/src/main/java/org/apache/giraffa/GiraffaConfiguration.java // public static final String GRFA_ROWKEY_FACTORY_KEY = // "grfa.rowkey.factory.class";
import static org.apache.giraffa.GiraffaConfiguration.GRFA_CACHING_DEFAULT; import static org.apache.giraffa.GiraffaConfiguration.GRFA_CACHING_KEY; import static org.apache.giraffa.GiraffaConfiguration.GRFA_ROWKEY_FACTORY_DEFAULT; import static org.apache.giraffa.GiraffaConfiguration.GRFA_ROWKEY_FACTORY_KEY; import java.io.IOException; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.util.ReflectionUtils;
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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 org.apache.giraffa; public class RowKeyFactoryProvider { private static Class<? extends RowKeyFactory> rowKeyFactoryClass; public static RowKeyFactory createFactory(Configuration conf) throws IOException {
// Path: giraffa-core/src/main/java/org/apache/giraffa/GiraffaConfiguration.java // public static final Boolean GRFA_CACHING_DEFAULT = true; // // Path: giraffa-core/src/main/java/org/apache/giraffa/GiraffaConfiguration.java // public static final String GRFA_CACHING_KEY = "grfa.rowkey.caching"; // // Path: giraffa-core/src/main/java/org/apache/giraffa/GiraffaConfiguration.java // public static final Class<? extends RowKeyFactory> // GRFA_ROWKEY_FACTORY_DEFAULT = FullPathRowKeyFactory.class; // // Path: giraffa-core/src/main/java/org/apache/giraffa/GiraffaConfiguration.java // public static final String GRFA_ROWKEY_FACTORY_KEY = // "grfa.rowkey.factory.class"; // Path: giraffa-core/src/main/java/org/apache/giraffa/RowKeyFactoryProvider.java import static org.apache.giraffa.GiraffaConfiguration.GRFA_CACHING_DEFAULT; import static org.apache.giraffa.GiraffaConfiguration.GRFA_CACHING_KEY; import static org.apache.giraffa.GiraffaConfiguration.GRFA_ROWKEY_FACTORY_DEFAULT; import static org.apache.giraffa.GiraffaConfiguration.GRFA_ROWKEY_FACTORY_KEY; import java.io.IOException; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.util.ReflectionUtils; /** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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 org.apache.giraffa; public class RowKeyFactoryProvider { private static Class<? extends RowKeyFactory> rowKeyFactoryClass; public static RowKeyFactory createFactory(Configuration conf) throws IOException {
boolean caching = conf.getBoolean(GRFA_CACHING_KEY, GRFA_CACHING_DEFAULT);
GiraffaFS/giraffa
giraffa-core/src/main/java/org/apache/giraffa/RowKeyFactoryProvider.java
// Path: giraffa-core/src/main/java/org/apache/giraffa/GiraffaConfiguration.java // public static final Boolean GRFA_CACHING_DEFAULT = true; // // Path: giraffa-core/src/main/java/org/apache/giraffa/GiraffaConfiguration.java // public static final String GRFA_CACHING_KEY = "grfa.rowkey.caching"; // // Path: giraffa-core/src/main/java/org/apache/giraffa/GiraffaConfiguration.java // public static final Class<? extends RowKeyFactory> // GRFA_ROWKEY_FACTORY_DEFAULT = FullPathRowKeyFactory.class; // // Path: giraffa-core/src/main/java/org/apache/giraffa/GiraffaConfiguration.java // public static final String GRFA_ROWKEY_FACTORY_KEY = // "grfa.rowkey.factory.class";
import static org.apache.giraffa.GiraffaConfiguration.GRFA_CACHING_DEFAULT; import static org.apache.giraffa.GiraffaConfiguration.GRFA_CACHING_KEY; import static org.apache.giraffa.GiraffaConfiguration.GRFA_ROWKEY_FACTORY_DEFAULT; import static org.apache.giraffa.GiraffaConfiguration.GRFA_ROWKEY_FACTORY_KEY; import java.io.IOException; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.util.ReflectionUtils;
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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 org.apache.giraffa; public class RowKeyFactoryProvider { private static Class<? extends RowKeyFactory> rowKeyFactoryClass; public static RowKeyFactory createFactory(Configuration conf) throws IOException { boolean caching = conf.getBoolean(GRFA_CACHING_KEY, GRFA_CACHING_DEFAULT); RowKeyFactory.setCache(caching); Class<? extends RowKeyFactory> rkfClass = registerFactory(conf); RowKeyFactory rkf = ReflectionUtils.newInstance(rkfClass, conf); rkf.initialize(conf); rowKeyFactoryClass = rkfClass; return rkf; } @SuppressWarnings("unchecked") private static synchronized Class<? extends RowKeyFactory> registerFactory(Configuration conf) throws IOException { Class<? extends RowKeyFactory> factory; try { if(rowKeyFactoryClass != null) return rowKeyFactoryClass; factory = (Class<? extends RowKeyFactory>) conf.getClass(
// Path: giraffa-core/src/main/java/org/apache/giraffa/GiraffaConfiguration.java // public static final Boolean GRFA_CACHING_DEFAULT = true; // // Path: giraffa-core/src/main/java/org/apache/giraffa/GiraffaConfiguration.java // public static final String GRFA_CACHING_KEY = "grfa.rowkey.caching"; // // Path: giraffa-core/src/main/java/org/apache/giraffa/GiraffaConfiguration.java // public static final Class<? extends RowKeyFactory> // GRFA_ROWKEY_FACTORY_DEFAULT = FullPathRowKeyFactory.class; // // Path: giraffa-core/src/main/java/org/apache/giraffa/GiraffaConfiguration.java // public static final String GRFA_ROWKEY_FACTORY_KEY = // "grfa.rowkey.factory.class"; // Path: giraffa-core/src/main/java/org/apache/giraffa/RowKeyFactoryProvider.java import static org.apache.giraffa.GiraffaConfiguration.GRFA_CACHING_DEFAULT; import static org.apache.giraffa.GiraffaConfiguration.GRFA_CACHING_KEY; import static org.apache.giraffa.GiraffaConfiguration.GRFA_ROWKEY_FACTORY_DEFAULT; import static org.apache.giraffa.GiraffaConfiguration.GRFA_ROWKEY_FACTORY_KEY; import java.io.IOException; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.util.ReflectionUtils; /** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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 org.apache.giraffa; public class RowKeyFactoryProvider { private static Class<? extends RowKeyFactory> rowKeyFactoryClass; public static RowKeyFactory createFactory(Configuration conf) throws IOException { boolean caching = conf.getBoolean(GRFA_CACHING_KEY, GRFA_CACHING_DEFAULT); RowKeyFactory.setCache(caching); Class<? extends RowKeyFactory> rkfClass = registerFactory(conf); RowKeyFactory rkf = ReflectionUtils.newInstance(rkfClass, conf); rkf.initialize(conf); rowKeyFactoryClass = rkfClass; return rkf; } @SuppressWarnings("unchecked") private static synchronized Class<? extends RowKeyFactory> registerFactory(Configuration conf) throws IOException { Class<? extends RowKeyFactory> factory; try { if(rowKeyFactoryClass != null) return rowKeyFactoryClass; factory = (Class<? extends RowKeyFactory>) conf.getClass(
GRFA_ROWKEY_FACTORY_KEY, GRFA_ROWKEY_FACTORY_DEFAULT);
GiraffaFS/giraffa
giraffa-core/src/main/java/org/apache/giraffa/RowKeyFactoryProvider.java
// Path: giraffa-core/src/main/java/org/apache/giraffa/GiraffaConfiguration.java // public static final Boolean GRFA_CACHING_DEFAULT = true; // // Path: giraffa-core/src/main/java/org/apache/giraffa/GiraffaConfiguration.java // public static final String GRFA_CACHING_KEY = "grfa.rowkey.caching"; // // Path: giraffa-core/src/main/java/org/apache/giraffa/GiraffaConfiguration.java // public static final Class<? extends RowKeyFactory> // GRFA_ROWKEY_FACTORY_DEFAULT = FullPathRowKeyFactory.class; // // Path: giraffa-core/src/main/java/org/apache/giraffa/GiraffaConfiguration.java // public static final String GRFA_ROWKEY_FACTORY_KEY = // "grfa.rowkey.factory.class";
import static org.apache.giraffa.GiraffaConfiguration.GRFA_CACHING_DEFAULT; import static org.apache.giraffa.GiraffaConfiguration.GRFA_CACHING_KEY; import static org.apache.giraffa.GiraffaConfiguration.GRFA_ROWKEY_FACTORY_DEFAULT; import static org.apache.giraffa.GiraffaConfiguration.GRFA_ROWKEY_FACTORY_KEY; import java.io.IOException; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.util.ReflectionUtils;
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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 org.apache.giraffa; public class RowKeyFactoryProvider { private static Class<? extends RowKeyFactory> rowKeyFactoryClass; public static RowKeyFactory createFactory(Configuration conf) throws IOException { boolean caching = conf.getBoolean(GRFA_CACHING_KEY, GRFA_CACHING_DEFAULT); RowKeyFactory.setCache(caching); Class<? extends RowKeyFactory> rkfClass = registerFactory(conf); RowKeyFactory rkf = ReflectionUtils.newInstance(rkfClass, conf); rkf.initialize(conf); rowKeyFactoryClass = rkfClass; return rkf; } @SuppressWarnings("unchecked") private static synchronized Class<? extends RowKeyFactory> registerFactory(Configuration conf) throws IOException { Class<? extends RowKeyFactory> factory; try { if(rowKeyFactoryClass != null) return rowKeyFactoryClass; factory = (Class<? extends RowKeyFactory>) conf.getClass(
// Path: giraffa-core/src/main/java/org/apache/giraffa/GiraffaConfiguration.java // public static final Boolean GRFA_CACHING_DEFAULT = true; // // Path: giraffa-core/src/main/java/org/apache/giraffa/GiraffaConfiguration.java // public static final String GRFA_CACHING_KEY = "grfa.rowkey.caching"; // // Path: giraffa-core/src/main/java/org/apache/giraffa/GiraffaConfiguration.java // public static final Class<? extends RowKeyFactory> // GRFA_ROWKEY_FACTORY_DEFAULT = FullPathRowKeyFactory.class; // // Path: giraffa-core/src/main/java/org/apache/giraffa/GiraffaConfiguration.java // public static final String GRFA_ROWKEY_FACTORY_KEY = // "grfa.rowkey.factory.class"; // Path: giraffa-core/src/main/java/org/apache/giraffa/RowKeyFactoryProvider.java import static org.apache.giraffa.GiraffaConfiguration.GRFA_CACHING_DEFAULT; import static org.apache.giraffa.GiraffaConfiguration.GRFA_CACHING_KEY; import static org.apache.giraffa.GiraffaConfiguration.GRFA_ROWKEY_FACTORY_DEFAULT; import static org.apache.giraffa.GiraffaConfiguration.GRFA_ROWKEY_FACTORY_KEY; import java.io.IOException; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.util.ReflectionUtils; /** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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 org.apache.giraffa; public class RowKeyFactoryProvider { private static Class<? extends RowKeyFactory> rowKeyFactoryClass; public static RowKeyFactory createFactory(Configuration conf) throws IOException { boolean caching = conf.getBoolean(GRFA_CACHING_KEY, GRFA_CACHING_DEFAULT); RowKeyFactory.setCache(caching); Class<? extends RowKeyFactory> rkfClass = registerFactory(conf); RowKeyFactory rkf = ReflectionUtils.newInstance(rkfClass, conf); rkf.initialize(conf); rowKeyFactoryClass = rkfClass; return rkf; } @SuppressWarnings("unchecked") private static synchronized Class<? extends RowKeyFactory> registerFactory(Configuration conf) throws IOException { Class<? extends RowKeyFactory> factory; try { if(rowKeyFactoryClass != null) return rowKeyFactoryClass; factory = (Class<? extends RowKeyFactory>) conf.getClass(
GRFA_ROWKEY_FACTORY_KEY, GRFA_ROWKEY_FACTORY_DEFAULT);
GiraffaFS/giraffa
giraffa-core/src/test/java/org/apache/giraffa/TestGiraffaFS.java
// Path: giraffa-core/src/test/java/org/apache/giraffa/GiraffaTestUtils.java // public static void printFileStatus(FileStatus fileStat) throws IOException { // printFileStatus(fileStat, -1); // }
import java.io.IOException; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.hadoop.fs.FileAlreadyExistsException; import org.apache.hadoop.fs.FileStatus; import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.Path; import org.apache.hadoop.fs.PathIsNotEmptyDirectoryException; import org.apache.hadoop.fs.permission.FsPermission; import org.apache.hadoop.hbase.HBaseTestingUtility; import org.apache.hadoop.io.IOUtils; import org.junit.After; import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; import static org.apache.giraffa.GiraffaTestUtils.printFileStatus; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail;
public static void beforeClass() throws Exception { System.setProperty( HBaseTestingUtility.BASE_TEST_DIRECTORY_KEY, GiraffaTestUtils.BASE_TEST_DIRECTORY); UTIL.startMiniCluster(1); } @Before public void before() throws IOException { GiraffaConfiguration conf = new GiraffaConfiguration(UTIL.getConfiguration()); GiraffaTestUtils.setGiraffaURI(conf); GiraffaFileSystem.format(conf, false); grfs = (GiraffaFileSystem) FileSystem.get(conf); } @After public void after() throws IOException { IOUtils.cleanup(LOG, grfs); } @AfterClass public static void afterClass() throws Exception { UTIL.shutdownMiniCluster(); } @Test public void testFileCreation() throws IOException { grfs.create(new Path("text.txt")); grfs.create(new Path("plamen's test")); FileStatus[] files = grfs.listStatus(new Path("."));
// Path: giraffa-core/src/test/java/org/apache/giraffa/GiraffaTestUtils.java // public static void printFileStatus(FileStatus fileStat) throws IOException { // printFileStatus(fileStat, -1); // } // Path: giraffa-core/src/test/java/org/apache/giraffa/TestGiraffaFS.java import java.io.IOException; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.hadoop.fs.FileAlreadyExistsException; import org.apache.hadoop.fs.FileStatus; import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.Path; import org.apache.hadoop.fs.PathIsNotEmptyDirectoryException; import org.apache.hadoop.fs.permission.FsPermission; import org.apache.hadoop.hbase.HBaseTestingUtility; import org.apache.hadoop.io.IOUtils; import org.junit.After; import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; import static org.apache.giraffa.GiraffaTestUtils.printFileStatus; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; public static void beforeClass() throws Exception { System.setProperty( HBaseTestingUtility.BASE_TEST_DIRECTORY_KEY, GiraffaTestUtils.BASE_TEST_DIRECTORY); UTIL.startMiniCluster(1); } @Before public void before() throws IOException { GiraffaConfiguration conf = new GiraffaConfiguration(UTIL.getConfiguration()); GiraffaTestUtils.setGiraffaURI(conf); GiraffaFileSystem.format(conf, false); grfs = (GiraffaFileSystem) FileSystem.get(conf); } @After public void after() throws IOException { IOUtils.cleanup(LOG, grfs); } @AfterClass public static void afterClass() throws Exception { UTIL.shutdownMiniCluster(); } @Test public void testFileCreation() throws IOException { grfs.create(new Path("text.txt")); grfs.create(new Path("plamen's test")); FileStatus[] files = grfs.listStatus(new Path("."));
printFileStatus(files);
GiraffaFS/giraffa
giraffa-core/src/main/java/org/apache/giraffa/web/GiraffaWebObserver.java
// Path: giraffa-core/src/main/java/org/apache/giraffa/GiraffaConfiguration.java // public class GiraffaConfiguration extends Configuration { // public static final String GRFA_URI_SCHEME = "grfa"; // public static final String GRFA_TABLE_NAME_KEY = "grfa.table.name"; // public static final String GRFA_TABLE_NAME_DEFAULT = "Namespace"; // public static final String GRFA_ROWKEY_FACTORY_KEY = // "grfa.rowkey.factory.class"; // public static final Class<? extends RowKeyFactory> // GRFA_ROWKEY_FACTORY_DEFAULT = FullPathRowKeyFactory.class; // public static final String GRFA_CACHING_KEY = "grfa.rowkey.caching"; // public static final Boolean GRFA_CACHING_DEFAULT = true; // public static final String GRFA_NAMESPACE_SERVICE_KEY = // "grfa.namespace.service.class"; // public static final Class<? extends NamespaceService> // GRFA_NAMESPACE_SERVICE_DEFAULT = NamespaceAgent.class; // public static final String GRFA_HDFS_ADDRESS_KEY = "grfa.hdfs.address"; // public static final String GRFA_HDFS_ADDRESS_DEFAULT = "file:///"; // public static final String GRFA_HBASE_ADDRESS_KEY = "grfa.hbase.address"; // public static final String GRFA_HBASE_ADDRESS_DEFAULT = "file:///"; // public static final String GRFA_LIST_LIMIT_KEY = // DFSConfigKeys.DFS_LIST_LIMIT; // public static final int GRFA_LIST_LIMIT_DEFAULT = // DFSConfigKeys.DFS_LIST_LIMIT_DEFAULT; // // public static final String GRFA_WEB_ADDRESS_KEY = "grfa.http-address"; // public static final String GRFA_WEB_ADDRESS_DEFAULT = "0.0.0.0:40010"; // // static { // // adds the default resources // addDefaultResource("giraffa-default.xml"); // addDefaultResource("giraffa-site.xml"); // addDefaultResource("hbase-default.xml"); // addDefaultResource("hbase-site.xml"); // } // // public GiraffaConfiguration() { // super(); // } // // public GiraffaConfiguration(Configuration conf) { // super(conf); // } // // public NamespaceService newNamespaceService() { // Class<? extends NamespaceService> serviceClass = // getClass(GRFA_NAMESPACE_SERVICE_KEY, GRFA_NAMESPACE_SERVICE_DEFAULT, // NamespaceService.class); // return ReflectionUtils.newInstance(serviceClass, null); // } // // public static String getGiraffaTableName(Configuration conf) { // return conf.get(GRFA_TABLE_NAME_KEY, GRFA_TABLE_NAME_DEFAULT); // } // }
import java.io.IOException; import java.net.InetSocketAddress; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.giraffa.GiraffaConfiguration; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.client.Admin; import org.apache.hadoop.hbase.client.Connection; import org.apache.hadoop.hbase.client.ConnectionFactory; import org.apache.hadoop.hbase.coprocessor.BaseMasterObserver; import org.apache.hadoop.hbase.coprocessor.MasterCoprocessorEnvironment; import org.apache.hadoop.hbase.coprocessor.ObserverContext; import org.apache.hadoop.net.NetUtils; import javax.servlet.jsp.jstl.core.Config;
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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 org.apache.giraffa.web; public class GiraffaWebObserver extends BaseMasterObserver { private static final Log LOG = LogFactory.getLog(GiraffaWebObserver.class); // server for the web ui private GiraffaWebServer giraffaServer; private Connection connection; private InetSocketAddress getHttpServerAddress(Configuration conf) { return NetUtils.createSocketAddr(
// Path: giraffa-core/src/main/java/org/apache/giraffa/GiraffaConfiguration.java // public class GiraffaConfiguration extends Configuration { // public static final String GRFA_URI_SCHEME = "grfa"; // public static final String GRFA_TABLE_NAME_KEY = "grfa.table.name"; // public static final String GRFA_TABLE_NAME_DEFAULT = "Namespace"; // public static final String GRFA_ROWKEY_FACTORY_KEY = // "grfa.rowkey.factory.class"; // public static final Class<? extends RowKeyFactory> // GRFA_ROWKEY_FACTORY_DEFAULT = FullPathRowKeyFactory.class; // public static final String GRFA_CACHING_KEY = "grfa.rowkey.caching"; // public static final Boolean GRFA_CACHING_DEFAULT = true; // public static final String GRFA_NAMESPACE_SERVICE_KEY = // "grfa.namespace.service.class"; // public static final Class<? extends NamespaceService> // GRFA_NAMESPACE_SERVICE_DEFAULT = NamespaceAgent.class; // public static final String GRFA_HDFS_ADDRESS_KEY = "grfa.hdfs.address"; // public static final String GRFA_HDFS_ADDRESS_DEFAULT = "file:///"; // public static final String GRFA_HBASE_ADDRESS_KEY = "grfa.hbase.address"; // public static final String GRFA_HBASE_ADDRESS_DEFAULT = "file:///"; // public static final String GRFA_LIST_LIMIT_KEY = // DFSConfigKeys.DFS_LIST_LIMIT; // public static final int GRFA_LIST_LIMIT_DEFAULT = // DFSConfigKeys.DFS_LIST_LIMIT_DEFAULT; // // public static final String GRFA_WEB_ADDRESS_KEY = "grfa.http-address"; // public static final String GRFA_WEB_ADDRESS_DEFAULT = "0.0.0.0:40010"; // // static { // // adds the default resources // addDefaultResource("giraffa-default.xml"); // addDefaultResource("giraffa-site.xml"); // addDefaultResource("hbase-default.xml"); // addDefaultResource("hbase-site.xml"); // } // // public GiraffaConfiguration() { // super(); // } // // public GiraffaConfiguration(Configuration conf) { // super(conf); // } // // public NamespaceService newNamespaceService() { // Class<? extends NamespaceService> serviceClass = // getClass(GRFA_NAMESPACE_SERVICE_KEY, GRFA_NAMESPACE_SERVICE_DEFAULT, // NamespaceService.class); // return ReflectionUtils.newInstance(serviceClass, null); // } // // public static String getGiraffaTableName(Configuration conf) { // return conf.get(GRFA_TABLE_NAME_KEY, GRFA_TABLE_NAME_DEFAULT); // } // } // Path: giraffa-core/src/main/java/org/apache/giraffa/web/GiraffaWebObserver.java import java.io.IOException; import java.net.InetSocketAddress; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.giraffa.GiraffaConfiguration; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.client.Admin; import org.apache.hadoop.hbase.client.Connection; import org.apache.hadoop.hbase.client.ConnectionFactory; import org.apache.hadoop.hbase.coprocessor.BaseMasterObserver; import org.apache.hadoop.hbase.coprocessor.MasterCoprocessorEnvironment; import org.apache.hadoop.hbase.coprocessor.ObserverContext; import org.apache.hadoop.net.NetUtils; import javax.servlet.jsp.jstl.core.Config; /** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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 org.apache.giraffa.web; public class GiraffaWebObserver extends BaseMasterObserver { private static final Log LOG = LogFactory.getLog(GiraffaWebObserver.class); // server for the web ui private GiraffaWebServer giraffaServer; private Connection connection; private InetSocketAddress getHttpServerAddress(Configuration conf) { return NetUtils.createSocketAddr(
conf.get(GiraffaConfiguration.GRFA_WEB_ADDRESS_KEY,
GiraffaFS/giraffa
giraffa-core/src/test/java/org/apache/giraffa/TestCreate.java
// Path: giraffa-core/src/test/java/org/apache/giraffa/GiraffaTestUtils.java // public static void printFileStatus(FileStatus fileStat) throws IOException { // printFileStatus(fileStat, -1); // }
import java.io.IOException; import java.io.FileNotFoundException; import java.util.EnumSet; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.hadoop.fs.FileAlreadyExistsException; import org.apache.hadoop.fs.FileStatus; import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.FSDataOutputStream; import org.apache.hadoop.fs.Path; import org.apache.hadoop.fs.permission.FsPermission; import org.apache.hadoop.fs.CreateFlag; import org.apache.hadoop.hbase.HBaseTestingUtility; import org.apache.hadoop.hdfs.protocol.AlreadyBeingCreatedException; import org.apache.hadoop.io.IOUtils; import org.junit.After; import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; import static org.apache.giraffa.GiraffaTestUtils.printFileStatus; import static org.apache.hadoop.fs.CreateFlag.APPEND; import static org.apache.hadoop.fs.CreateFlag.CREATE; import static org.apache.hadoop.fs.CreateFlag.OVERWRITE; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse;
GiraffaFileSystem.format(conf, false); grfs = (GiraffaFileSystem) FileSystem.get(conf); path = new Path("newlyCreatedFile.txt"); permission = new FsPermission((short)0666); bufferSize = 4096; replication = 3; blockSize = 512; } @After public void after() throws IOException { IOUtils.cleanup(LOG, grfs); } @AfterClass public static void afterClass() throws Exception { UTIL.shutdownMiniCluster(); } /** * Tests for different CreateFlag combinations */ @Test public void testCanCreateNewFileWithCreateFlagOnly() throws IOException { EnumSet<CreateFlag> flags = EnumSet.of(CREATE); grfs.create(path, permission, flags, bufferSize, replication, blockSize, null); FileStatus[] files = grfs.listStatus(new Path(".")); LOG.debug("list files under home dir");
// Path: giraffa-core/src/test/java/org/apache/giraffa/GiraffaTestUtils.java // public static void printFileStatus(FileStatus fileStat) throws IOException { // printFileStatus(fileStat, -1); // } // Path: giraffa-core/src/test/java/org/apache/giraffa/TestCreate.java import java.io.IOException; import java.io.FileNotFoundException; import java.util.EnumSet; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.hadoop.fs.FileAlreadyExistsException; import org.apache.hadoop.fs.FileStatus; import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.FSDataOutputStream; import org.apache.hadoop.fs.Path; import org.apache.hadoop.fs.permission.FsPermission; import org.apache.hadoop.fs.CreateFlag; import org.apache.hadoop.hbase.HBaseTestingUtility; import org.apache.hadoop.hdfs.protocol.AlreadyBeingCreatedException; import org.apache.hadoop.io.IOUtils; import org.junit.After; import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; import static org.apache.giraffa.GiraffaTestUtils.printFileStatus; import static org.apache.hadoop.fs.CreateFlag.APPEND; import static org.apache.hadoop.fs.CreateFlag.CREATE; import static org.apache.hadoop.fs.CreateFlag.OVERWRITE; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; GiraffaFileSystem.format(conf, false); grfs = (GiraffaFileSystem) FileSystem.get(conf); path = new Path("newlyCreatedFile.txt"); permission = new FsPermission((short)0666); bufferSize = 4096; replication = 3; blockSize = 512; } @After public void after() throws IOException { IOUtils.cleanup(LOG, grfs); } @AfterClass public static void afterClass() throws Exception { UTIL.shutdownMiniCluster(); } /** * Tests for different CreateFlag combinations */ @Test public void testCanCreateNewFileWithCreateFlagOnly() throws IOException { EnumSet<CreateFlag> flags = EnumSet.of(CREATE); grfs.create(path, permission, flags, bufferSize, replication, blockSize, null); FileStatus[] files = grfs.listStatus(new Path(".")); LOG.debug("list files under home dir");
printFileStatus(files);
onebeartoe/photorama
photorama-raspberry-pi-lcd-keypad/src/main/java/se/hirt/pi/adafruitlcd/ILCD.java
// Path: photorama-raspberry-pi-lcd-keypad/src/main/java/se/hirt/pi/adafruitlcd/impl/RealLCD.java // public enum Direction { // LEFT, RIGHT; // }
import java.io.IOException; import se.hirt.pi.adafruitlcd.impl.RealLCD.Direction;
/* * Copyright (C) 2014 Marcus Hirt * www.hirt.se * * This software is free: * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESSED OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * Copyright (C) Marcus Hirt, 2014 */ package se.hirt.pi.adafruitlcd; public interface ILCD { void setText(String s) throws IOException; void setText(int row, String string) throws IOException; void setCursorPosition(int row, int column) throws IOException; void stop() throws IOException; void clear() throws IOException; void home() throws IOException; void setCursorEnabled(boolean enable) throws IOException; boolean isCursorEnabled(); void setDisplayEnabled(boolean enable) throws IOException; boolean isDisplayEnabled(); void setBlinkEnabled(boolean enable) throws IOException; boolean isBlinkEnabled(); void setBacklight(Color color) throws IOException; Color getBacklight() throws IOException;
// Path: photorama-raspberry-pi-lcd-keypad/src/main/java/se/hirt/pi/adafruitlcd/impl/RealLCD.java // public enum Direction { // LEFT, RIGHT; // } // Path: photorama-raspberry-pi-lcd-keypad/src/main/java/se/hirt/pi/adafruitlcd/ILCD.java import java.io.IOException; import se.hirt.pi.adafruitlcd.impl.RealLCD.Direction; /* * Copyright (C) 2014 Marcus Hirt * www.hirt.se * * This software is free: * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESSED OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * Copyright (C) Marcus Hirt, 2014 */ package se.hirt.pi.adafruitlcd; public interface ILCD { void setText(String s) throws IOException; void setText(int row, String string) throws IOException; void setCursorPosition(int row, int column) throws IOException; void stop() throws IOException; void clear() throws IOException; void home() throws IOException; void setCursorEnabled(boolean enable) throws IOException; boolean isCursorEnabled(); void setDisplayEnabled(boolean enable) throws IOException; boolean isDisplayEnabled(); void setBlinkEnabled(boolean enable) throws IOException; boolean isBlinkEnabled(); void setBacklight(Color color) throws IOException; Color getBacklight() throws IOException;
void scrollDisplay(Direction direction) throws IOException;
onebeartoe/photorama
photorama-raspberry-pi-webapp/src/main/java/org/onebeartoe/electronics/photorama/FrequencyUnitServlet.java
// Path: photorama-raspberry-pi-webapp/src/main/java/org/onebeartoe/electronics/photorama/ConfigurationServlet.java // public static final String CAMERA_KEY = "camera";
import java.io.IOException; import java.io.OutputStream; import java.io.PrintWriter; import java.util.logging.Level; import java.util.logging.Logger; import javax.servlet.ServletContext; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import static org.onebeartoe.electronics.photorama.ConfigurationServlet.CAMERA_KEY;
package org.onebeartoe.electronics.photorama; /** * @author Roberto Marquez */ @WebServlet(urlPatterns = {"/frequency/unit/*"}) public class FrequencyUnitServlet extends HttpServlet { private Logger logger; //TODO: GET RID OF THIS for production, only used for debugging protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doPost(request, response); } @Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { ServletContext context = getServletContext();
// Path: photorama-raspberry-pi-webapp/src/main/java/org/onebeartoe/electronics/photorama/ConfigurationServlet.java // public static final String CAMERA_KEY = "camera"; // Path: photorama-raspberry-pi-webapp/src/main/java/org/onebeartoe/electronics/photorama/FrequencyUnitServlet.java import java.io.IOException; import java.io.OutputStream; import java.io.PrintWriter; import java.util.logging.Level; import java.util.logging.Logger; import javax.servlet.ServletContext; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import static org.onebeartoe.electronics.photorama.ConfigurationServlet.CAMERA_KEY; package org.onebeartoe.electronics.photorama; /** * @author Roberto Marquez */ @WebServlet(urlPatterns = {"/frequency/unit/*"}) public class FrequencyUnitServlet extends HttpServlet { private Logger logger; //TODO: GET RID OF THIS for production, only used for debugging protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doPost(request, response); } @Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { ServletContext context = getServletContext();
Camera camera = (Camera) context.getAttribute(CAMERA_KEY);
onebeartoe/photorama
photorama-model/src/main/java/org/onebeartoe/electronics/photorama/states/time/lapse/TimeLapseHoursState.java
// Path: photorama-model/src/main/java/org/onebeartoe/electronics/photorama/states/PhotoramaState.java // public interface PhotoramaState // { // public void setCamera(Camera camera); // // public String getLabel(); // public String getValue(); // // public PhotoramaState leftButton(); // public PhotoramaState rightButton(); // public PhotoramaState upButton(); // public PhotoramaState downButton(); // public PhotoramaState selectButton(); // // public void setLeftButton(PhotoramaState leftState); // public void setRightButton(PhotoramaState rightState); // public void setUpButton(PhotoramaState upState); // public void setDownButton(PhotoramaState downState); // public void setSelectButton(PhotoramaState selectState); // }
import org.onebeartoe.electronics.photorama.states.PhotoramaState;
package org.onebeartoe.electronics.photorama.states.time.lapse; /** * @author Roberto Marquez */ public class TimeLapseHoursState extends TimeLapseStates { public TimeLapseHoursState() { value = "<- Hours"; } @Override
// Path: photorama-model/src/main/java/org/onebeartoe/electronics/photorama/states/PhotoramaState.java // public interface PhotoramaState // { // public void setCamera(Camera camera); // // public String getLabel(); // public String getValue(); // // public PhotoramaState leftButton(); // public PhotoramaState rightButton(); // public PhotoramaState upButton(); // public PhotoramaState downButton(); // public PhotoramaState selectButton(); // // public void setLeftButton(PhotoramaState leftState); // public void setRightButton(PhotoramaState rightState); // public void setUpButton(PhotoramaState upState); // public void setDownButton(PhotoramaState downState); // public void setSelectButton(PhotoramaState selectState); // } // Path: photorama-model/src/main/java/org/onebeartoe/electronics/photorama/states/time/lapse/TimeLapseHoursState.java import org.onebeartoe.electronics.photorama.states.PhotoramaState; package org.onebeartoe.electronics.photorama.states.time.lapse; /** * @author Roberto Marquez */ public class TimeLapseHoursState extends TimeLapseStates { public TimeLapseHoursState() { value = "<- Hours"; } @Override
public PhotoramaState leftButton()
onebeartoe/photorama
photorama-model/src/main/java/org/onebeartoe/electronics/photorama/states/time/lapse/TimeLapseMinutesState.java
// Path: photorama-model/src/main/java/org/onebeartoe/electronics/photorama/states/PhotoramaState.java // public interface PhotoramaState // { // public void setCamera(Camera camera); // // public String getLabel(); // public String getValue(); // // public PhotoramaState leftButton(); // public PhotoramaState rightButton(); // public PhotoramaState upButton(); // public PhotoramaState downButton(); // public PhotoramaState selectButton(); // // public void setLeftButton(PhotoramaState leftState); // public void setRightButton(PhotoramaState rightState); // public void setUpButton(PhotoramaState upState); // public void setDownButton(PhotoramaState downState); // public void setSelectButton(PhotoramaState selectState); // }
import org.onebeartoe.electronics.photorama.states.PhotoramaState;
package org.onebeartoe.electronics.photorama.states.time.lapse; /** * @author Roberto Marquez */ public class TimeLapseMinutesState extends TimeLapseStates { public TimeLapseMinutesState() { value = "<- Minutes ->"; } @Override
// Path: photorama-model/src/main/java/org/onebeartoe/electronics/photorama/states/PhotoramaState.java // public interface PhotoramaState // { // public void setCamera(Camera camera); // // public String getLabel(); // public String getValue(); // // public PhotoramaState leftButton(); // public PhotoramaState rightButton(); // public PhotoramaState upButton(); // public PhotoramaState downButton(); // public PhotoramaState selectButton(); // // public void setLeftButton(PhotoramaState leftState); // public void setRightButton(PhotoramaState rightState); // public void setUpButton(PhotoramaState upState); // public void setDownButton(PhotoramaState downState); // public void setSelectButton(PhotoramaState selectState); // } // Path: photorama-model/src/main/java/org/onebeartoe/electronics/photorama/states/time/lapse/TimeLapseMinutesState.java import org.onebeartoe.electronics.photorama.states.PhotoramaState; package org.onebeartoe.electronics.photorama.states.time.lapse; /** * @author Roberto Marquez */ public class TimeLapseMinutesState extends TimeLapseStates { public TimeLapseMinutesState() { value = "<- Minutes ->"; } @Override
public PhotoramaState leftButton()
onebeartoe/photorama
photorama-raspberry-pi-lcd-keypad/src/main/java/se/hirt/pi/adafruitlcd/demo/ColorDemo.java
// Path: photorama-raspberry-pi-lcd-keypad/src/main/java/se/hirt/pi/adafruitlcd/Color.java // public enum Color { // OFF(0x00), RED(0x01), GREEN(0x02), BLUE(0x04), YELLOW(RED.getValue() // + GREEN.getValue()), TEAL(GREEN.getValue() + BLUE.getValue()), VIOLET( // RED.getValue() + BLUE.getValue()), WHITE(RED.getValue() // + GREEN.getValue() + BLUE.getValue()), ON(WHITE.getValue()); // // private final int value; // // Color(int value) { // this.value = value; // } // // public int getValue() { // return value; // } // // /** // * Returns the matching color value, or WHITE if no matching color could be found. // * // * @param colorValue // * @return // */ // public static Color getByValue(int colorValue) { // for (Color c : values()) { // if (c.getValue() == colorValue) { // return c; // } // } // return WHITE; // } // } // // Path: photorama-raspberry-pi-lcd-keypad/src/main/java/se/hirt/pi/adafruitlcd/ILCD.java // public interface ILCD { // // void setText(String s) throws IOException; // // void setText(int row, String string) throws IOException; // // void setCursorPosition(int row, int column) throws IOException; // // void stop() throws IOException; // // void clear() throws IOException; // // void home() throws IOException; // // void setCursorEnabled(boolean enable) throws IOException; // // boolean isCursorEnabled(); // // void setDisplayEnabled(boolean enable) throws IOException; // // boolean isDisplayEnabled(); // // void setBlinkEnabled(boolean enable) throws IOException; // // boolean isBlinkEnabled(); // // void setBacklight(Color color) throws IOException; // // Color getBacklight() throws IOException; // // void scrollDisplay(Direction direction) throws IOException; // // void setTextFlowDirection(Direction direction) throws IOException; // // void setAutoScrollEnabled(boolean enable) throws IOException; // // boolean isAutoScrollEnabled(); // // boolean isButtonPressed(Button button) throws IOException; // // int buttonsPressedBitmask() throws IOException; // // }
import java.io.IOException; import se.hirt.pi.adafruitlcd.Color; import se.hirt.pi.adafruitlcd.ILCD;
/* * Copyright (C) 2013 Marcus Hirt * www.hirt.se * * This software is free: * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESSED OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * Copyright (C) Marcus Hirt, 2013 */ package se.hirt.pi.adafruitlcd.demo; /** * This demo should cycle through the background colors. I only have the monochrome one, * so I really can't tell if this works. :) * * @author Marcus Hirt */ public class ColorDemo implements LCDTest { @Override public String getName() { return "Backlight"; } @Override
// Path: photorama-raspberry-pi-lcd-keypad/src/main/java/se/hirt/pi/adafruitlcd/Color.java // public enum Color { // OFF(0x00), RED(0x01), GREEN(0x02), BLUE(0x04), YELLOW(RED.getValue() // + GREEN.getValue()), TEAL(GREEN.getValue() + BLUE.getValue()), VIOLET( // RED.getValue() + BLUE.getValue()), WHITE(RED.getValue() // + GREEN.getValue() + BLUE.getValue()), ON(WHITE.getValue()); // // private final int value; // // Color(int value) { // this.value = value; // } // // public int getValue() { // return value; // } // // /** // * Returns the matching color value, or WHITE if no matching color could be found. // * // * @param colorValue // * @return // */ // public static Color getByValue(int colorValue) { // for (Color c : values()) { // if (c.getValue() == colorValue) { // return c; // } // } // return WHITE; // } // } // // Path: photorama-raspberry-pi-lcd-keypad/src/main/java/se/hirt/pi/adafruitlcd/ILCD.java // public interface ILCD { // // void setText(String s) throws IOException; // // void setText(int row, String string) throws IOException; // // void setCursorPosition(int row, int column) throws IOException; // // void stop() throws IOException; // // void clear() throws IOException; // // void home() throws IOException; // // void setCursorEnabled(boolean enable) throws IOException; // // boolean isCursorEnabled(); // // void setDisplayEnabled(boolean enable) throws IOException; // // boolean isDisplayEnabled(); // // void setBlinkEnabled(boolean enable) throws IOException; // // boolean isBlinkEnabled(); // // void setBacklight(Color color) throws IOException; // // Color getBacklight() throws IOException; // // void scrollDisplay(Direction direction) throws IOException; // // void setTextFlowDirection(Direction direction) throws IOException; // // void setAutoScrollEnabled(boolean enable) throws IOException; // // boolean isAutoScrollEnabled(); // // boolean isButtonPressed(Button button) throws IOException; // // int buttonsPressedBitmask() throws IOException; // // } // Path: photorama-raspberry-pi-lcd-keypad/src/main/java/se/hirt/pi/adafruitlcd/demo/ColorDemo.java import java.io.IOException; import se.hirt.pi.adafruitlcd.Color; import se.hirt.pi.adafruitlcd.ILCD; /* * Copyright (C) 2013 Marcus Hirt * www.hirt.se * * This software is free: * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESSED OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * Copyright (C) Marcus Hirt, 2013 */ package se.hirt.pi.adafruitlcd.demo; /** * This demo should cycle through the background colors. I only have the monochrome one, * so I really can't tell if this works. :) * * @author Marcus Hirt */ public class ColorDemo implements LCDTest { @Override public String getName() { return "Backlight"; } @Override
public void run(ILCD lcd) throws IOException {
onebeartoe/photorama
photorama-raspberry-pi-lcd-keypad/src/main/java/se/hirt/pi/adafruitlcd/demo/ColorDemo.java
// Path: photorama-raspberry-pi-lcd-keypad/src/main/java/se/hirt/pi/adafruitlcd/Color.java // public enum Color { // OFF(0x00), RED(0x01), GREEN(0x02), BLUE(0x04), YELLOW(RED.getValue() // + GREEN.getValue()), TEAL(GREEN.getValue() + BLUE.getValue()), VIOLET( // RED.getValue() + BLUE.getValue()), WHITE(RED.getValue() // + GREEN.getValue() + BLUE.getValue()), ON(WHITE.getValue()); // // private final int value; // // Color(int value) { // this.value = value; // } // // public int getValue() { // return value; // } // // /** // * Returns the matching color value, or WHITE if no matching color could be found. // * // * @param colorValue // * @return // */ // public static Color getByValue(int colorValue) { // for (Color c : values()) { // if (c.getValue() == colorValue) { // return c; // } // } // return WHITE; // } // } // // Path: photorama-raspberry-pi-lcd-keypad/src/main/java/se/hirt/pi/adafruitlcd/ILCD.java // public interface ILCD { // // void setText(String s) throws IOException; // // void setText(int row, String string) throws IOException; // // void setCursorPosition(int row, int column) throws IOException; // // void stop() throws IOException; // // void clear() throws IOException; // // void home() throws IOException; // // void setCursorEnabled(boolean enable) throws IOException; // // boolean isCursorEnabled(); // // void setDisplayEnabled(boolean enable) throws IOException; // // boolean isDisplayEnabled(); // // void setBlinkEnabled(boolean enable) throws IOException; // // boolean isBlinkEnabled(); // // void setBacklight(Color color) throws IOException; // // Color getBacklight() throws IOException; // // void scrollDisplay(Direction direction) throws IOException; // // void setTextFlowDirection(Direction direction) throws IOException; // // void setAutoScrollEnabled(boolean enable) throws IOException; // // boolean isAutoScrollEnabled(); // // boolean isButtonPressed(Button button) throws IOException; // // int buttonsPressedBitmask() throws IOException; // // }
import java.io.IOException; import se.hirt.pi.adafruitlcd.Color; import se.hirt.pi.adafruitlcd.ILCD;
/* * Copyright (C) 2013 Marcus Hirt * www.hirt.se * * This software is free: * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESSED OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * Copyright (C) Marcus Hirt, 2013 */ package se.hirt.pi.adafruitlcd.demo; /** * This demo should cycle through the background colors. I only have the monochrome one, * so I really can't tell if this works. :) * * @author Marcus Hirt */ public class ColorDemo implements LCDTest { @Override public String getName() { return "Backlight"; } @Override public void run(ILCD lcd) throws IOException { lcd.clear(); lcd.setText("Color changes:"); Util.sleep(1000);
// Path: photorama-raspberry-pi-lcd-keypad/src/main/java/se/hirt/pi/adafruitlcd/Color.java // public enum Color { // OFF(0x00), RED(0x01), GREEN(0x02), BLUE(0x04), YELLOW(RED.getValue() // + GREEN.getValue()), TEAL(GREEN.getValue() + BLUE.getValue()), VIOLET( // RED.getValue() + BLUE.getValue()), WHITE(RED.getValue() // + GREEN.getValue() + BLUE.getValue()), ON(WHITE.getValue()); // // private final int value; // // Color(int value) { // this.value = value; // } // // public int getValue() { // return value; // } // // /** // * Returns the matching color value, or WHITE if no matching color could be found. // * // * @param colorValue // * @return // */ // public static Color getByValue(int colorValue) { // for (Color c : values()) { // if (c.getValue() == colorValue) { // return c; // } // } // return WHITE; // } // } // // Path: photorama-raspberry-pi-lcd-keypad/src/main/java/se/hirt/pi/adafruitlcd/ILCD.java // public interface ILCD { // // void setText(String s) throws IOException; // // void setText(int row, String string) throws IOException; // // void setCursorPosition(int row, int column) throws IOException; // // void stop() throws IOException; // // void clear() throws IOException; // // void home() throws IOException; // // void setCursorEnabled(boolean enable) throws IOException; // // boolean isCursorEnabled(); // // void setDisplayEnabled(boolean enable) throws IOException; // // boolean isDisplayEnabled(); // // void setBlinkEnabled(boolean enable) throws IOException; // // boolean isBlinkEnabled(); // // void setBacklight(Color color) throws IOException; // // Color getBacklight() throws IOException; // // void scrollDisplay(Direction direction) throws IOException; // // void setTextFlowDirection(Direction direction) throws IOException; // // void setAutoScrollEnabled(boolean enable) throws IOException; // // boolean isAutoScrollEnabled(); // // boolean isButtonPressed(Button button) throws IOException; // // int buttonsPressedBitmask() throws IOException; // // } // Path: photorama-raspberry-pi-lcd-keypad/src/main/java/se/hirt/pi/adafruitlcd/demo/ColorDemo.java import java.io.IOException; import se.hirt.pi.adafruitlcd.Color; import se.hirt.pi.adafruitlcd.ILCD; /* * Copyright (C) 2013 Marcus Hirt * www.hirt.se * * This software is free: * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESSED OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * Copyright (C) Marcus Hirt, 2013 */ package se.hirt.pi.adafruitlcd.demo; /** * This demo should cycle through the background colors. I only have the monochrome one, * so I really can't tell if this works. :) * * @author Marcus Hirt */ public class ColorDemo implements LCDTest { @Override public String getName() { return "Backlight"; } @Override public void run(ILCD lcd) throws IOException { lcd.clear(); lcd.setText("Color changes:"); Util.sleep(1000);
for (Color c : Color.values()) {
onebeartoe/photorama
photorama-raspberry-pi-lcd-keypad/src/main/java/se/hirt/pi/adafruitlcd/demo/ExitTest.java
// Path: photorama-raspberry-pi-lcd-keypad/src/main/java/se/hirt/pi/adafruitlcd/ILCD.java // public interface ILCD { // // void setText(String s) throws IOException; // // void setText(int row, String string) throws IOException; // // void setCursorPosition(int row, int column) throws IOException; // // void stop() throws IOException; // // void clear() throws IOException; // // void home() throws IOException; // // void setCursorEnabled(boolean enable) throws IOException; // // boolean isCursorEnabled(); // // void setDisplayEnabled(boolean enable) throws IOException; // // boolean isDisplayEnabled(); // // void setBlinkEnabled(boolean enable) throws IOException; // // boolean isBlinkEnabled(); // // void setBacklight(Color color) throws IOException; // // Color getBacklight() throws IOException; // // void scrollDisplay(Direction direction) throws IOException; // // void setTextFlowDirection(Direction direction) throws IOException; // // void setAutoScrollEnabled(boolean enable) throws IOException; // // boolean isAutoScrollEnabled(); // // boolean isButtonPressed(Button button) throws IOException; // // int buttonsPressedBitmask() throws IOException; // // }
import java.io.IOException; import se.hirt.pi.adafruitlcd.ILCD;
/* * Copyright (C) 2013 Marcus Hirt * www.hirt.se * * This software is free: * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESSED OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * Copyright (C) Marcus Hirt, 2013 */ package se.hirt.pi.adafruitlcd.demo; /** * This one really doesn't anything but clean up and exit. * * @author Marcus Hirt */ public class ExitTest implements LCDTest { @Override public String getName() { return "<Exit>"; } @Override
// Path: photorama-raspberry-pi-lcd-keypad/src/main/java/se/hirt/pi/adafruitlcd/ILCD.java // public interface ILCD { // // void setText(String s) throws IOException; // // void setText(int row, String string) throws IOException; // // void setCursorPosition(int row, int column) throws IOException; // // void stop() throws IOException; // // void clear() throws IOException; // // void home() throws IOException; // // void setCursorEnabled(boolean enable) throws IOException; // // boolean isCursorEnabled(); // // void setDisplayEnabled(boolean enable) throws IOException; // // boolean isDisplayEnabled(); // // void setBlinkEnabled(boolean enable) throws IOException; // // boolean isBlinkEnabled(); // // void setBacklight(Color color) throws IOException; // // Color getBacklight() throws IOException; // // void scrollDisplay(Direction direction) throws IOException; // // void setTextFlowDirection(Direction direction) throws IOException; // // void setAutoScrollEnabled(boolean enable) throws IOException; // // boolean isAutoScrollEnabled(); // // boolean isButtonPressed(Button button) throws IOException; // // int buttonsPressedBitmask() throws IOException; // // } // Path: photorama-raspberry-pi-lcd-keypad/src/main/java/se/hirt/pi/adafruitlcd/demo/ExitTest.java import java.io.IOException; import se.hirt.pi.adafruitlcd.ILCD; /* * Copyright (C) 2013 Marcus Hirt * www.hirt.se * * This software is free: * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESSED OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * Copyright (C) Marcus Hirt, 2013 */ package se.hirt.pi.adafruitlcd.demo; /** * This one really doesn't anything but clean up and exit. * * @author Marcus Hirt */ public class ExitTest implements LCDTest { @Override public String getName() { return "<Exit>"; } @Override
public void run(ILCD lcd) throws IOException {
onebeartoe/photorama
photorama-model/src/main/java/org/onebeartoe/electronics/photorama/states/raspberry/pi/RaspberryPiOnState.java
// Path: photorama-model/src/main/java/org/onebeartoe/electronics/photorama/states/PhotoramaState.java // public interface PhotoramaState // { // public void setCamera(Camera camera); // // public String getLabel(); // public String getValue(); // // public PhotoramaState leftButton(); // public PhotoramaState rightButton(); // public PhotoramaState upButton(); // public PhotoramaState downButton(); // public PhotoramaState selectButton(); // // public void setLeftButton(PhotoramaState leftState); // public void setRightButton(PhotoramaState rightState); // public void setUpButton(PhotoramaState upState); // public void setDownButton(PhotoramaState downState); // public void setSelectButton(PhotoramaState selectState); // }
import org.onebeartoe.electronics.photorama.states.PhotoramaState;
package org.onebeartoe.electronics.photorama.states.raspberry.pi; /** * @author Roberto Marquez */ public class RaspberryPiOnState extends RaspberryPiStates { @Override public String getValue() { return "On ->"; } @Override
// Path: photorama-model/src/main/java/org/onebeartoe/electronics/photorama/states/PhotoramaState.java // public interface PhotoramaState // { // public void setCamera(Camera camera); // // public String getLabel(); // public String getValue(); // // public PhotoramaState leftButton(); // public PhotoramaState rightButton(); // public PhotoramaState upButton(); // public PhotoramaState downButton(); // public PhotoramaState selectButton(); // // public void setLeftButton(PhotoramaState leftState); // public void setRightButton(PhotoramaState rightState); // public void setUpButton(PhotoramaState upState); // public void setDownButton(PhotoramaState downState); // public void setSelectButton(PhotoramaState selectState); // } // Path: photorama-model/src/main/java/org/onebeartoe/electronics/photorama/states/raspberry/pi/RaspberryPiOnState.java import org.onebeartoe.electronics.photorama.states.PhotoramaState; package org.onebeartoe.electronics.photorama.states.raspberry.pi; /** * @author Roberto Marquez */ public class RaspberryPiOnState extends RaspberryPiStates { @Override public String getValue() { return "On ->"; } @Override
public PhotoramaState rightButton()
onebeartoe/photorama
photorama-model/src/main/java/org/onebeartoe/electronics/photorama/states/mode/ModeTimeLapseState.java
// Path: photorama-model/src/main/java/org/onebeartoe/electronics/photorama/states/PhotoramaState.java // public interface PhotoramaState // { // public void setCamera(Camera camera); // // public String getLabel(); // public String getValue(); // // public PhotoramaState leftButton(); // public PhotoramaState rightButton(); // public PhotoramaState upButton(); // public PhotoramaState downButton(); // public PhotoramaState selectButton(); // // public void setLeftButton(PhotoramaState leftState); // public void setRightButton(PhotoramaState rightState); // public void setUpButton(PhotoramaState upState); // public void setDownButton(PhotoramaState downState); // public void setSelectButton(PhotoramaState selectState); // }
import org.onebeartoe.electronics.photorama.states.PhotoramaState;
package org.onebeartoe.electronics.photorama.states.mode; /** * @author Roberto Marquez */ public class ModeTimeLapseState extends ModeStates { public ModeTimeLapseState() { value = "<- Time Lapse"; } @Override
// Path: photorama-model/src/main/java/org/onebeartoe/electronics/photorama/states/PhotoramaState.java // public interface PhotoramaState // { // public void setCamera(Camera camera); // // public String getLabel(); // public String getValue(); // // public PhotoramaState leftButton(); // public PhotoramaState rightButton(); // public PhotoramaState upButton(); // public PhotoramaState downButton(); // public PhotoramaState selectButton(); // // public void setLeftButton(PhotoramaState leftState); // public void setRightButton(PhotoramaState rightState); // public void setUpButton(PhotoramaState upState); // public void setDownButton(PhotoramaState downState); // public void setSelectButton(PhotoramaState selectState); // } // Path: photorama-model/src/main/java/org/onebeartoe/electronics/photorama/states/mode/ModeTimeLapseState.java import org.onebeartoe.electronics.photorama.states.PhotoramaState; package org.onebeartoe.electronics.photorama.states.mode; /** * @author Roberto Marquez */ public class ModeTimeLapseState extends ModeStates { public ModeTimeLapseState() { value = "<- Time Lapse"; } @Override
public PhotoramaState leftButton()
onebeartoe/photorama
photorama-raspberry-pi-webapp/src/main/java/org/onebeartoe/electronics/photorama/FrequencyServlet.java
// Path: photorama-raspberry-pi-webapp/src/main/java/org/onebeartoe/electronics/photorama/ConfigurationServlet.java // public static final String CAMERA_KEY = "camera";
import java.io.IOException; import java.io.OutputStream; import java.io.PrintWriter; import java.util.logging.Level; import java.util.logging.Logger; import javax.servlet.ServletContext; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import static org.onebeartoe.electronics.photorama.ConfigurationServlet.CAMERA_KEY;
package org.onebeartoe.electronics.photorama; /** * @author Roberto Marquez */ @WebServlet(urlPatterns = {"/frequency/*"}) public class FrequencyServlet extends HttpServlet { private Logger logger; @Override //Todo: UPDATE THIS TO USE THE PlainTextResponseServlet CLASS protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { ServletContext context = getServletContext();
// Path: photorama-raspberry-pi-webapp/src/main/java/org/onebeartoe/electronics/photorama/ConfigurationServlet.java // public static final String CAMERA_KEY = "camera"; // Path: photorama-raspberry-pi-webapp/src/main/java/org/onebeartoe/electronics/photorama/FrequencyServlet.java import java.io.IOException; import java.io.OutputStream; import java.io.PrintWriter; import java.util.logging.Level; import java.util.logging.Logger; import javax.servlet.ServletContext; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import static org.onebeartoe.electronics.photorama.ConfigurationServlet.CAMERA_KEY; package org.onebeartoe.electronics.photorama; /** * @author Roberto Marquez */ @WebServlet(urlPatterns = {"/frequency/*"}) public class FrequencyServlet extends HttpServlet { private Logger logger; @Override //Todo: UPDATE THIS TO USE THE PlainTextResponseServlet CLASS protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { ServletContext context = getServletContext();
Camera camera = (Camera) context.getAttribute(CAMERA_KEY);
onebeartoe/photorama
photorama-raspberry-pi-webapp/src/main/java/org/onebeartoe/electronics/photorama/TimeLapseServlet.java
// Path: photorama-raspberry-pi-webapp/src/main/java/org/onebeartoe/electronics/photorama/ConfigurationServlet.java // public static final String CAMERA_KEY = "camera";
import java.io.IOException; import java.io.OutputStream; import java.io.PrintWriter; import java.util.logging.Level; import java.util.logging.Logger; import javax.servlet.ServletContext; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import static org.onebeartoe.electronics.photorama.ConfigurationServlet.CAMERA_KEY;
package org.onebeartoe.electronics.photorama; /** * @author Roberto Marquez */ @WebServlet(urlPatterns = {"/time-lapse/*"}) public class TimeLapseServlet extends HttpServlet { private Logger logger; @Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String m = "context path: " + request.getContextPath() + "\n" + "querystring: " + request.getQueryString() + "\n" + "servlet path: " + request.getServletPath() + "\n" + "path info: " + request.getPathInfo() + "\n" + "path translated: " + request.getPathTranslated() + "\n" + "request uri : " + request.getRequestURI() + "\n" + "request url : " + request.getRequestURL(); ServletContext context = getServletContext();
// Path: photorama-raspberry-pi-webapp/src/main/java/org/onebeartoe/electronics/photorama/ConfigurationServlet.java // public static final String CAMERA_KEY = "camera"; // Path: photorama-raspberry-pi-webapp/src/main/java/org/onebeartoe/electronics/photorama/TimeLapseServlet.java import java.io.IOException; import java.io.OutputStream; import java.io.PrintWriter; import java.util.logging.Level; import java.util.logging.Logger; import javax.servlet.ServletContext; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import static org.onebeartoe.electronics.photorama.ConfigurationServlet.CAMERA_KEY; package org.onebeartoe.electronics.photorama; /** * @author Roberto Marquez */ @WebServlet(urlPatterns = {"/time-lapse/*"}) public class TimeLapseServlet extends HttpServlet { private Logger logger; @Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String m = "context path: " + request.getContextPath() + "\n" + "querystring: " + request.getQueryString() + "\n" + "servlet path: " + request.getServletPath() + "\n" + "path info: " + request.getPathInfo() + "\n" + "path translated: " + request.getPathTranslated() + "\n" + "request uri : " + request.getRequestURI() + "\n" + "request url : " + request.getRequestURL(); ServletContext context = getServletContext();
Camera camera = (Camera) context.getAttribute(CAMERA_KEY);
onebeartoe/photorama
photorama-raspberry-pi-lcd-keypad/src/main/java/se/hirt/pi/adafruitlcd/demo/AutoScrollDemo.java
// Path: photorama-raspberry-pi-lcd-keypad/src/main/java/se/hirt/pi/adafruitlcd/ILCD.java // public interface ILCD { // // void setText(String s) throws IOException; // // void setText(int row, String string) throws IOException; // // void setCursorPosition(int row, int column) throws IOException; // // void stop() throws IOException; // // void clear() throws IOException; // // void home() throws IOException; // // void setCursorEnabled(boolean enable) throws IOException; // // boolean isCursorEnabled(); // // void setDisplayEnabled(boolean enable) throws IOException; // // boolean isDisplayEnabled(); // // void setBlinkEnabled(boolean enable) throws IOException; // // boolean isBlinkEnabled(); // // void setBacklight(Color color) throws IOException; // // Color getBacklight() throws IOException; // // void scrollDisplay(Direction direction) throws IOException; // // void setTextFlowDirection(Direction direction) throws IOException; // // void setAutoScrollEnabled(boolean enable) throws IOException; // // boolean isAutoScrollEnabled(); // // boolean isButtonPressed(Button button) throws IOException; // // int buttonsPressedBitmask() throws IOException; // // }
import java.io.IOException; import se.hirt.pi.adafruitlcd.ILCD;
/* * Copyright (C) 2013 Marcus Hirt * www.hirt.se * * This software is free: * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESSED OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * Copyright (C) Marcus Hirt, 2013 */ package se.hirt.pi.adafruitlcd.demo; /** * Tests autoscroll. Check out the documentation for the HD44780 for more info * on how the buffer is handled. * * @author Marcus Hirt */ public class AutoScrollDemo implements LCDTest { @Override public String getName() { return "AutoScroll"; } @Override
// Path: photorama-raspberry-pi-lcd-keypad/src/main/java/se/hirt/pi/adafruitlcd/ILCD.java // public interface ILCD { // // void setText(String s) throws IOException; // // void setText(int row, String string) throws IOException; // // void setCursorPosition(int row, int column) throws IOException; // // void stop() throws IOException; // // void clear() throws IOException; // // void home() throws IOException; // // void setCursorEnabled(boolean enable) throws IOException; // // boolean isCursorEnabled(); // // void setDisplayEnabled(boolean enable) throws IOException; // // boolean isDisplayEnabled(); // // void setBlinkEnabled(boolean enable) throws IOException; // // boolean isBlinkEnabled(); // // void setBacklight(Color color) throws IOException; // // Color getBacklight() throws IOException; // // void scrollDisplay(Direction direction) throws IOException; // // void setTextFlowDirection(Direction direction) throws IOException; // // void setAutoScrollEnabled(boolean enable) throws IOException; // // boolean isAutoScrollEnabled(); // // boolean isButtonPressed(Button button) throws IOException; // // int buttonsPressedBitmask() throws IOException; // // } // Path: photorama-raspberry-pi-lcd-keypad/src/main/java/se/hirt/pi/adafruitlcd/demo/AutoScrollDemo.java import java.io.IOException; import se.hirt.pi.adafruitlcd.ILCD; /* * Copyright (C) 2013 Marcus Hirt * www.hirt.se * * This software is free: * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESSED OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * Copyright (C) Marcus Hirt, 2013 */ package se.hirt.pi.adafruitlcd.demo; /** * Tests autoscroll. Check out the documentation for the HD44780 for more info * on how the buffer is handled. * * @author Marcus Hirt */ public class AutoScrollDemo implements LCDTest { @Override public String getName() { return "AutoScroll"; } @Override
public void run(ILCD lcd) throws IOException {
onebeartoe/photorama
photorama-model/src/main/java/org/onebeartoe/electronics/photorama/states/foot/pedal/SnapshotOffState.java
// Path: photorama-model/src/main/java/org/onebeartoe/electronics/photorama/states/PhotoramaState.java // public interface PhotoramaState // { // public void setCamera(Camera camera); // // public String getLabel(); // public String getValue(); // // public PhotoramaState leftButton(); // public PhotoramaState rightButton(); // public PhotoramaState upButton(); // public PhotoramaState downButton(); // public PhotoramaState selectButton(); // // public void setLeftButton(PhotoramaState leftState); // public void setRightButton(PhotoramaState rightState); // public void setUpButton(PhotoramaState upState); // public void setDownButton(PhotoramaState downState); // public void setSelectButton(PhotoramaState selectState); // }
import org.onebeartoe.electronics.photorama.states.PhotoramaState;
package org.onebeartoe.electronics.photorama.states.foot.pedal; /** * @author Roberto Marquez */ public class SnapshotOffState extends FootPedalStates { @Override public String getValue() { return "<- Off"; } @Override
// Path: photorama-model/src/main/java/org/onebeartoe/electronics/photorama/states/PhotoramaState.java // public interface PhotoramaState // { // public void setCamera(Camera camera); // // public String getLabel(); // public String getValue(); // // public PhotoramaState leftButton(); // public PhotoramaState rightButton(); // public PhotoramaState upButton(); // public PhotoramaState downButton(); // public PhotoramaState selectButton(); // // public void setLeftButton(PhotoramaState leftState); // public void setRightButton(PhotoramaState rightState); // public void setUpButton(PhotoramaState upState); // public void setDownButton(PhotoramaState downState); // public void setSelectButton(PhotoramaState selectState); // } // Path: photorama-model/src/main/java/org/onebeartoe/electronics/photorama/states/foot/pedal/SnapshotOffState.java import org.onebeartoe.electronics.photorama.states.PhotoramaState; package org.onebeartoe.electronics.photorama.states.foot.pedal; /** * @author Roberto Marquez */ public class SnapshotOffState extends FootPedalStates { @Override public String getValue() { return "<- Off"; } @Override
public PhotoramaState leftButton()
onebeartoe/photorama
photorama-raspberry-pi-lcd-keypad/src/main/java/se/hirt/pi/adafruitlcd/impl/RealLCD.java
// Path: photorama-raspberry-pi-lcd-keypad/src/main/java/se/hirt/pi/adafruitlcd/Button.java // public enum Button { // SELECT(0), RIGHT(1), DOWN(2), UP(3), LEFT(4); // // // Port expander input pin definition // private final int pin; // // Button(int pin) { // this.pin = pin; // } // // /** // * The pin corresponding to the button. // * // * @return the pin of the button. // */ // public int getPin() { // return pin; // } // // /** // * Checks if a button is pressed, given an input mask. // * // * @param mask // * the input mask. // * @return true if the button is pressed, false otherwise. // * // * @see RealLCD#buttonsPressedBitmask() // */ // public boolean isButtonPressed(int mask) { // return ((mask >> getPin()) & 1) > 0; // } // // /** // * Returns a set of the buttons that are pressed, according to the input // * mask. // * // * @param mask // * the input mask. // * @return a set of the buttons pressed. // * // * @see RealLCD#buttonsPressedBitmask() // */ // public static Set<Button> getButtonsPressed(int mask) { // Set<Button> buttons = new HashSet<Button>(); // for (Button button : values()) { // if (button.isButtonPressed(mask)) { // buttons.add(button); // } // } // return buttons; // } // } // // Path: photorama-raspberry-pi-lcd-keypad/src/main/java/se/hirt/pi/adafruitlcd/Color.java // public enum Color { // OFF(0x00), RED(0x01), GREEN(0x02), BLUE(0x04), YELLOW(RED.getValue() // + GREEN.getValue()), TEAL(GREEN.getValue() + BLUE.getValue()), VIOLET( // RED.getValue() + BLUE.getValue()), WHITE(RED.getValue() // + GREEN.getValue() + BLUE.getValue()), ON(WHITE.getValue()); // // private final int value; // // Color(int value) { // this.value = value; // } // // public int getValue() { // return value; // } // // /** // * Returns the matching color value, or WHITE if no matching color could be found. // * // * @param colorValue // * @return // */ // public static Color getByValue(int colorValue) { // for (Color c : values()) { // if (c.getValue() == colorValue) { // return c; // } // } // return WHITE; // } // } // // Path: photorama-raspberry-pi-lcd-keypad/src/main/java/se/hirt/pi/adafruitlcd/ILCD.java // public interface ILCD { // // void setText(String s) throws IOException; // // void setText(int row, String string) throws IOException; // // void setCursorPosition(int row, int column) throws IOException; // // void stop() throws IOException; // // void clear() throws IOException; // // void home() throws IOException; // // void setCursorEnabled(boolean enable) throws IOException; // // boolean isCursorEnabled(); // // void setDisplayEnabled(boolean enable) throws IOException; // // boolean isDisplayEnabled(); // // void setBlinkEnabled(boolean enable) throws IOException; // // boolean isBlinkEnabled(); // // void setBacklight(Color color) throws IOException; // // Color getBacklight() throws IOException; // // void scrollDisplay(Direction direction) throws IOException; // // void setTextFlowDirection(Direction direction) throws IOException; // // void setAutoScrollEnabled(boolean enable) throws IOException; // // boolean isAutoScrollEnabled(); // // boolean isButtonPressed(Button button) throws IOException; // // int buttonsPressedBitmask() throws IOException; // // }
import java.io.IOException; import se.hirt.pi.adafruitlcd.Button; import se.hirt.pi.adafruitlcd.Color; import se.hirt.pi.adafruitlcd.ILCD; import com.pi4j.io.i2c.I2CBus; import com.pi4j.io.i2c.I2CDevice; import com.pi4j.io.i2c.I2CFactory;
} /* (non-Javadoc) * @see se.hirt.pi.adafruitlcd.ILCD#setAutoScrollEnabled(boolean) */ @Override public void setAutoScrollEnabled(boolean enable) throws IOException { if (enable) { // This will 'right justify' text from the cursor displayMode |= LCD_ENTRYSHIFTINCREMENT; write(LCD_ENTRYMODESET | displayMode); } else { // This will 'left justify' text from the cursor displayMode &= ~LCD_ENTRYSHIFTINCREMENT; write(LCD_ENTRYMODESET | displayMode); } } /* (non-Javadoc) * @see se.hirt.pi.adafruitlcd.ILCD#isAutoScrollEnabled() */ @Override public boolean isAutoScrollEnabled() { return (displayControl & LCD_ENTRYSHIFTINCREMENT) > 0; } /* (non-Javadoc) * @see se.hirt.pi.adafruitlcd.ILCD#isButtonPressed(se.hirt.pi.adafruitlcd.Button) */ @Override
// Path: photorama-raspberry-pi-lcd-keypad/src/main/java/se/hirt/pi/adafruitlcd/Button.java // public enum Button { // SELECT(0), RIGHT(1), DOWN(2), UP(3), LEFT(4); // // // Port expander input pin definition // private final int pin; // // Button(int pin) { // this.pin = pin; // } // // /** // * The pin corresponding to the button. // * // * @return the pin of the button. // */ // public int getPin() { // return pin; // } // // /** // * Checks if a button is pressed, given an input mask. // * // * @param mask // * the input mask. // * @return true if the button is pressed, false otherwise. // * // * @see RealLCD#buttonsPressedBitmask() // */ // public boolean isButtonPressed(int mask) { // return ((mask >> getPin()) & 1) > 0; // } // // /** // * Returns a set of the buttons that are pressed, according to the input // * mask. // * // * @param mask // * the input mask. // * @return a set of the buttons pressed. // * // * @see RealLCD#buttonsPressedBitmask() // */ // public static Set<Button> getButtonsPressed(int mask) { // Set<Button> buttons = new HashSet<Button>(); // for (Button button : values()) { // if (button.isButtonPressed(mask)) { // buttons.add(button); // } // } // return buttons; // } // } // // Path: photorama-raspberry-pi-lcd-keypad/src/main/java/se/hirt/pi/adafruitlcd/Color.java // public enum Color { // OFF(0x00), RED(0x01), GREEN(0x02), BLUE(0x04), YELLOW(RED.getValue() // + GREEN.getValue()), TEAL(GREEN.getValue() + BLUE.getValue()), VIOLET( // RED.getValue() + BLUE.getValue()), WHITE(RED.getValue() // + GREEN.getValue() + BLUE.getValue()), ON(WHITE.getValue()); // // private final int value; // // Color(int value) { // this.value = value; // } // // public int getValue() { // return value; // } // // /** // * Returns the matching color value, or WHITE if no matching color could be found. // * // * @param colorValue // * @return // */ // public static Color getByValue(int colorValue) { // for (Color c : values()) { // if (c.getValue() == colorValue) { // return c; // } // } // return WHITE; // } // } // // Path: photorama-raspberry-pi-lcd-keypad/src/main/java/se/hirt/pi/adafruitlcd/ILCD.java // public interface ILCD { // // void setText(String s) throws IOException; // // void setText(int row, String string) throws IOException; // // void setCursorPosition(int row, int column) throws IOException; // // void stop() throws IOException; // // void clear() throws IOException; // // void home() throws IOException; // // void setCursorEnabled(boolean enable) throws IOException; // // boolean isCursorEnabled(); // // void setDisplayEnabled(boolean enable) throws IOException; // // boolean isDisplayEnabled(); // // void setBlinkEnabled(boolean enable) throws IOException; // // boolean isBlinkEnabled(); // // void setBacklight(Color color) throws IOException; // // Color getBacklight() throws IOException; // // void scrollDisplay(Direction direction) throws IOException; // // void setTextFlowDirection(Direction direction) throws IOException; // // void setAutoScrollEnabled(boolean enable) throws IOException; // // boolean isAutoScrollEnabled(); // // boolean isButtonPressed(Button button) throws IOException; // // int buttonsPressedBitmask() throws IOException; // // } // Path: photorama-raspberry-pi-lcd-keypad/src/main/java/se/hirt/pi/adafruitlcd/impl/RealLCD.java import java.io.IOException; import se.hirt.pi.adafruitlcd.Button; import se.hirt.pi.adafruitlcd.Color; import se.hirt.pi.adafruitlcd.ILCD; import com.pi4j.io.i2c.I2CBus; import com.pi4j.io.i2c.I2CDevice; import com.pi4j.io.i2c.I2CFactory; } /* (non-Javadoc) * @see se.hirt.pi.adafruitlcd.ILCD#setAutoScrollEnabled(boolean) */ @Override public void setAutoScrollEnabled(boolean enable) throws IOException { if (enable) { // This will 'right justify' text from the cursor displayMode |= LCD_ENTRYSHIFTINCREMENT; write(LCD_ENTRYMODESET | displayMode); } else { // This will 'left justify' text from the cursor displayMode &= ~LCD_ENTRYSHIFTINCREMENT; write(LCD_ENTRYMODESET | displayMode); } } /* (non-Javadoc) * @see se.hirt.pi.adafruitlcd.ILCD#isAutoScrollEnabled() */ @Override public boolean isAutoScrollEnabled() { return (displayControl & LCD_ENTRYSHIFTINCREMENT) > 0; } /* (non-Javadoc) * @see se.hirt.pi.adafruitlcd.ILCD#isButtonPressed(se.hirt.pi.adafruitlcd.Button) */ @Override
public boolean isButtonPressed(Button button) throws IOException {
onebeartoe/photorama
photorama-raspberry-pi-lcd-keypad/src/main/java/se/hirt/pi/adafruitlcd/demo/LCDTest.java
// Path: photorama-raspberry-pi-lcd-keypad/src/main/java/se/hirt/pi/adafruitlcd/ILCD.java // public interface ILCD { // // void setText(String s) throws IOException; // // void setText(int row, String string) throws IOException; // // void setCursorPosition(int row, int column) throws IOException; // // void stop() throws IOException; // // void clear() throws IOException; // // void home() throws IOException; // // void setCursorEnabled(boolean enable) throws IOException; // // boolean isCursorEnabled(); // // void setDisplayEnabled(boolean enable) throws IOException; // // boolean isDisplayEnabled(); // // void setBlinkEnabled(boolean enable) throws IOException; // // boolean isBlinkEnabled(); // // void setBacklight(Color color) throws IOException; // // Color getBacklight() throws IOException; // // void scrollDisplay(Direction direction) throws IOException; // // void setTextFlowDirection(Direction direction) throws IOException; // // void setAutoScrollEnabled(boolean enable) throws IOException; // // boolean isAutoScrollEnabled(); // // boolean isButtonPressed(Button button) throws IOException; // // int buttonsPressedBitmask() throws IOException; // // }
import java.io.IOException; import se.hirt.pi.adafruitlcd.ILCD;
/* * Copyright (C) 2013 Marcus Hirt * www.hirt.se * * This software is free: * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESSED OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * Copyright (C) Marcus Hirt, 2013 */ package se.hirt.pi.adafruitlcd.demo; /** * The interface for the demos. * * @author Marcus Hirt */ public interface LCDTest { public String getName();
// Path: photorama-raspberry-pi-lcd-keypad/src/main/java/se/hirt/pi/adafruitlcd/ILCD.java // public interface ILCD { // // void setText(String s) throws IOException; // // void setText(int row, String string) throws IOException; // // void setCursorPosition(int row, int column) throws IOException; // // void stop() throws IOException; // // void clear() throws IOException; // // void home() throws IOException; // // void setCursorEnabled(boolean enable) throws IOException; // // boolean isCursorEnabled(); // // void setDisplayEnabled(boolean enable) throws IOException; // // boolean isDisplayEnabled(); // // void setBlinkEnabled(boolean enable) throws IOException; // // boolean isBlinkEnabled(); // // void setBacklight(Color color) throws IOException; // // Color getBacklight() throws IOException; // // void scrollDisplay(Direction direction) throws IOException; // // void setTextFlowDirection(Direction direction) throws IOException; // // void setAutoScrollEnabled(boolean enable) throws IOException; // // boolean isAutoScrollEnabled(); // // boolean isButtonPressed(Button button) throws IOException; // // int buttonsPressedBitmask() throws IOException; // // } // Path: photorama-raspberry-pi-lcd-keypad/src/main/java/se/hirt/pi/adafruitlcd/demo/LCDTest.java import java.io.IOException; import se.hirt.pi.adafruitlcd.ILCD; /* * Copyright (C) 2013 Marcus Hirt * www.hirt.se * * This software is free: * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESSED OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * Copyright (C) Marcus Hirt, 2013 */ package se.hirt.pi.adafruitlcd.demo; /** * The interface for the demos. * * @author Marcus Hirt */ public interface LCDTest { public String getName();
public void run(ILCD lcd) throws IOException;
onebeartoe/photorama
photorama-model/src/main/java/org/onebeartoe/electronics/photorama/states/time/lapse/TimeLapseSecondsState.java
// Path: photorama-model/src/main/java/org/onebeartoe/electronics/photorama/states/PhotoramaState.java // public interface PhotoramaState // { // public void setCamera(Camera camera); // // public String getLabel(); // public String getValue(); // // public PhotoramaState leftButton(); // public PhotoramaState rightButton(); // public PhotoramaState upButton(); // public PhotoramaState downButton(); // public PhotoramaState selectButton(); // // public void setLeftButton(PhotoramaState leftState); // public void setRightButton(PhotoramaState rightState); // public void setUpButton(PhotoramaState upState); // public void setDownButton(PhotoramaState downState); // public void setSelectButton(PhotoramaState selectState); // }
import org.onebeartoe.electronics.photorama.states.PhotoramaState;
package org.onebeartoe.electronics.photorama.states.time.lapse; /** * @author Roberto Marquez */ public class TimeLapseSecondsState extends TimeLapseStates { public TimeLapseSecondsState() { value = "Seconds ->"; } @Override
// Path: photorama-model/src/main/java/org/onebeartoe/electronics/photorama/states/PhotoramaState.java // public interface PhotoramaState // { // public void setCamera(Camera camera); // // public String getLabel(); // public String getValue(); // // public PhotoramaState leftButton(); // public PhotoramaState rightButton(); // public PhotoramaState upButton(); // public PhotoramaState downButton(); // public PhotoramaState selectButton(); // // public void setLeftButton(PhotoramaState leftState); // public void setRightButton(PhotoramaState rightState); // public void setUpButton(PhotoramaState upState); // public void setDownButton(PhotoramaState downState); // public void setSelectButton(PhotoramaState selectState); // } // Path: photorama-model/src/main/java/org/onebeartoe/electronics/photorama/states/time/lapse/TimeLapseSecondsState.java import org.onebeartoe.electronics.photorama.states.PhotoramaState; package org.onebeartoe.electronics.photorama.states.time.lapse; /** * @author Roberto Marquez */ public class TimeLapseSecondsState extends TimeLapseStates { public TimeLapseSecondsState() { value = "Seconds ->"; } @Override
public PhotoramaState rightButton()
onebeartoe/photorama
photorama-model/src/main/java/org/onebeartoe/electronics/photorama/states/PhotoramaState.java
// Path: photorama-model/src/main/java/org/onebeartoe/electronics/photorama/Camera.java // public abstract class Camera // { // protected PhotoramaModes mode; // // protected String outputPath; // // protected TimeLapseConfiguration configuration; // // protected boolean timeLapseOn; // // public PhotoramaModes getMode() // { // return mode; // } // // public String getOutputPath() // { // return outputPath; // } // // public abstract long getTimelapse(); // // public FrequencyUnits getTimelapseUnit() // { // return configuration.unit; // } // // public void setMode(PhotoramaModes mode) // { // this.mode = mode; // // stopTimelapse(); // } // // /** // * Make sure the path has a path separator character at the end. // * @param path // */ // public void setOutputPath(String path) throws Exception // { // File outdir = new File(path); // // if( ! outdir.exists() ) // { // // the output directory does not exist, // // try creating it // boolean dirCreated = outdir.mkdirs(); // // if( !dirCreated ) // { // String message = "could not set output directory: " + path; // // throw new Exception(message); // } // } // // outputPath = path; // } // // public void setTimelapse(long delay, FrequencyUnits unit) // { // configuration.delay = delay; // configuration.unit = unit; // // if(timeLapseOn) // { // startTimelapse(); // } // } // // public abstract void startTimelapse(); // // public abstract void stopTimelapse(); // // public abstract void takeSnapshot(); // }
import org.onebeartoe.electronics.photorama.Camera;
package org.onebeartoe.electronics.photorama.states; /** * This interface is used to move between the various screen in Photorama. * @author Roberto Marquez */ public interface PhotoramaState {
// Path: photorama-model/src/main/java/org/onebeartoe/electronics/photorama/Camera.java // public abstract class Camera // { // protected PhotoramaModes mode; // // protected String outputPath; // // protected TimeLapseConfiguration configuration; // // protected boolean timeLapseOn; // // public PhotoramaModes getMode() // { // return mode; // } // // public String getOutputPath() // { // return outputPath; // } // // public abstract long getTimelapse(); // // public FrequencyUnits getTimelapseUnit() // { // return configuration.unit; // } // // public void setMode(PhotoramaModes mode) // { // this.mode = mode; // // stopTimelapse(); // } // // /** // * Make sure the path has a path separator character at the end. // * @param path // */ // public void setOutputPath(String path) throws Exception // { // File outdir = new File(path); // // if( ! outdir.exists() ) // { // // the output directory does not exist, // // try creating it // boolean dirCreated = outdir.mkdirs(); // // if( !dirCreated ) // { // String message = "could not set output directory: " + path; // // throw new Exception(message); // } // } // // outputPath = path; // } // // public void setTimelapse(long delay, FrequencyUnits unit) // { // configuration.delay = delay; // configuration.unit = unit; // // if(timeLapseOn) // { // startTimelapse(); // } // } // // public abstract void startTimelapse(); // // public abstract void stopTimelapse(); // // public abstract void takeSnapshot(); // } // Path: photorama-model/src/main/java/org/onebeartoe/electronics/photorama/states/PhotoramaState.java import org.onebeartoe.electronics.photorama.Camera; package org.onebeartoe.electronics.photorama.states; /** * This interface is used to move between the various screen in Photorama. * @author Roberto Marquez */ public interface PhotoramaState {
public void setCamera(Camera camera);
onebeartoe/photorama
photorama-raspberry-pi-lcd-keypad/src/main/java/se/hirt/pi/adafruitlcd/demo/CursorDemo.java
// Path: photorama-raspberry-pi-lcd-keypad/src/main/java/se/hirt/pi/adafruitlcd/ILCD.java // public interface ILCD { // // void setText(String s) throws IOException; // // void setText(int row, String string) throws IOException; // // void setCursorPosition(int row, int column) throws IOException; // // void stop() throws IOException; // // void clear() throws IOException; // // void home() throws IOException; // // void setCursorEnabled(boolean enable) throws IOException; // // boolean isCursorEnabled(); // // void setDisplayEnabled(boolean enable) throws IOException; // // boolean isDisplayEnabled(); // // void setBlinkEnabled(boolean enable) throws IOException; // // boolean isBlinkEnabled(); // // void setBacklight(Color color) throws IOException; // // Color getBacklight() throws IOException; // // void scrollDisplay(Direction direction) throws IOException; // // void setTextFlowDirection(Direction direction) throws IOException; // // void setAutoScrollEnabled(boolean enable) throws IOException; // // boolean isAutoScrollEnabled(); // // boolean isButtonPressed(Button button) throws IOException; // // int buttonsPressedBitmask() throws IOException; // // }
import java.io.IOException; import se.hirt.pi.adafruitlcd.ILCD;
/* * Copyright (C) 2013 Marcus Hirt * www.hirt.se * * This software is free: * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESSED OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * Copyright (C) Marcus Hirt, 2013 */ package se.hirt.pi.adafruitlcd.demo; /** * Plays around with the cursor a bit. * * @author Marcus Hirt * */ public class CursorDemo implements LCDTest { @Override public String getName() { return "Cursor"; } @Override
// Path: photorama-raspberry-pi-lcd-keypad/src/main/java/se/hirt/pi/adafruitlcd/ILCD.java // public interface ILCD { // // void setText(String s) throws IOException; // // void setText(int row, String string) throws IOException; // // void setCursorPosition(int row, int column) throws IOException; // // void stop() throws IOException; // // void clear() throws IOException; // // void home() throws IOException; // // void setCursorEnabled(boolean enable) throws IOException; // // boolean isCursorEnabled(); // // void setDisplayEnabled(boolean enable) throws IOException; // // boolean isDisplayEnabled(); // // void setBlinkEnabled(boolean enable) throws IOException; // // boolean isBlinkEnabled(); // // void setBacklight(Color color) throws IOException; // // Color getBacklight() throws IOException; // // void scrollDisplay(Direction direction) throws IOException; // // void setTextFlowDirection(Direction direction) throws IOException; // // void setAutoScrollEnabled(boolean enable) throws IOException; // // boolean isAutoScrollEnabled(); // // boolean isButtonPressed(Button button) throws IOException; // // int buttonsPressedBitmask() throws IOException; // // } // Path: photorama-raspberry-pi-lcd-keypad/src/main/java/se/hirt/pi/adafruitlcd/demo/CursorDemo.java import java.io.IOException; import se.hirt.pi.adafruitlcd.ILCD; /* * Copyright (C) 2013 Marcus Hirt * www.hirt.se * * This software is free: * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESSED OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * Copyright (C) Marcus Hirt, 2013 */ package se.hirt.pi.adafruitlcd.demo; /** * Plays around with the cursor a bit. * * @author Marcus Hirt * */ public class CursorDemo implements LCDTest { @Override public String getName() { return "Cursor"; } @Override
public void run(ILCD lcd) throws IOException {
onebeartoe/photorama
photorama-model/src/main/java/org/onebeartoe/electronics/photorama/states/foot/pedal/FootPedalSnapshotState.java
// Path: photorama-model/src/main/java/org/onebeartoe/electronics/photorama/states/PhotoramaState.java // public interface PhotoramaState // { // public void setCamera(Camera camera); // // public String getLabel(); // public String getValue(); // // public PhotoramaState leftButton(); // public PhotoramaState rightButton(); // public PhotoramaState upButton(); // public PhotoramaState downButton(); // public PhotoramaState selectButton(); // // public void setLeftButton(PhotoramaState leftState); // public void setRightButton(PhotoramaState rightState); // public void setUpButton(PhotoramaState upState); // public void setDownButton(PhotoramaState downState); // public void setSelectButton(PhotoramaState selectState); // }
import org.onebeartoe.electronics.photorama.states.PhotoramaState; import org.onebeartoe.system.Sleeper;
package org.onebeartoe.electronics.photorama.states.foot.pedal; /** * @author Roberto Marquez */ public class FootPedalSnapshotState extends FootPedalStates { public FootPedalSnapshotState() { value = "[select]"; } @Override
// Path: photorama-model/src/main/java/org/onebeartoe/electronics/photorama/states/PhotoramaState.java // public interface PhotoramaState // { // public void setCamera(Camera camera); // // public String getLabel(); // public String getValue(); // // public PhotoramaState leftButton(); // public PhotoramaState rightButton(); // public PhotoramaState upButton(); // public PhotoramaState downButton(); // public PhotoramaState selectButton(); // // public void setLeftButton(PhotoramaState leftState); // public void setRightButton(PhotoramaState rightState); // public void setUpButton(PhotoramaState upState); // public void setDownButton(PhotoramaState downState); // public void setSelectButton(PhotoramaState selectState); // } // Path: photorama-model/src/main/java/org/onebeartoe/electronics/photorama/states/foot/pedal/FootPedalSnapshotState.java import org.onebeartoe.electronics.photorama.states.PhotoramaState; import org.onebeartoe.system.Sleeper; package org.onebeartoe.electronics.photorama.states.foot.pedal; /** * @author Roberto Marquez */ public class FootPedalSnapshotState extends FootPedalStates { public FootPedalSnapshotState() { value = "[select]"; } @Override
public PhotoramaState selectButton()
onebeartoe/photorama
photorama-raspberry-pi-webapp/src/main/java/org/onebeartoe/electronics/photorama/PhotoBoothServlet.java
// Path: photorama-raspberry-pi-webapp/src/main/java/org/onebeartoe/electronics/photorama/ConfigurationServlet.java // public static final String CAMERA_KEY = "camera"; // // Path: photorama-raspberry-pi/src/main/java/org/onebeartoe/electronics/photorama/PhotoBoothButtonTester.java // public static final Pin buttonPin = RaspiPin.GPIO_02;
import com.pi4j.io.gpio.GpioController; import com.pi4j.io.gpio.GpioFactory; import com.pi4j.io.gpio.GpioPinDigitalInput; import com.pi4j.io.gpio.PinPullResistance; import com.pi4j.io.gpio.PinState; import com.pi4j.io.gpio.event.GpioPinDigitalStateChangeEvent; import com.pi4j.io.gpio.event.GpioPinListenerDigital; import java.util.logging.Level; import java.util.logging.Logger; import javax.servlet.ServletContext; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import static org.onebeartoe.electronics.photorama.ConfigurationServlet.CAMERA_KEY; import static org.onebeartoe.electronics.photorama.PhotoBoothButtonTester.buttonPin; import org.onebeartoe.system.Sleeper;
Sleeper.sleepo(SNAPSHOT_DELAY); camera.takeSnapshot(); } } @Override public void destroy() { ServletContext servletContext = getServletContext(); GpioController gpio = (GpioController) servletContext.getAttribute(PHOTO_BOOTH_GPIO_CONTROLLER_KEY); gpio.shutdown(); } @Override public void init() throws ServletException { super.init(); logger = Logger.getLogger(getClass().getName()); takingSnapshots = false; ServletContext servletContext = getServletContext(); GpioController gpio = (GpioController) servletContext.getAttribute(PHOTO_BOOTH_GPIO_CONTROLLER_KEY); if(gpio == null) { System.out.println("*Provisioning GPIO."); gpio = GpioFactory.getInstance(); servletContext.setAttribute(PHOTO_BOOTH_GPIO_CONTROLLER_KEY, gpio);
// Path: photorama-raspberry-pi-webapp/src/main/java/org/onebeartoe/electronics/photorama/ConfigurationServlet.java // public static final String CAMERA_KEY = "camera"; // // Path: photorama-raspberry-pi/src/main/java/org/onebeartoe/electronics/photorama/PhotoBoothButtonTester.java // public static final Pin buttonPin = RaspiPin.GPIO_02; // Path: photorama-raspberry-pi-webapp/src/main/java/org/onebeartoe/electronics/photorama/PhotoBoothServlet.java import com.pi4j.io.gpio.GpioController; import com.pi4j.io.gpio.GpioFactory; import com.pi4j.io.gpio.GpioPinDigitalInput; import com.pi4j.io.gpio.PinPullResistance; import com.pi4j.io.gpio.PinState; import com.pi4j.io.gpio.event.GpioPinDigitalStateChangeEvent; import com.pi4j.io.gpio.event.GpioPinListenerDigital; import java.util.logging.Level; import java.util.logging.Logger; import javax.servlet.ServletContext; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import static org.onebeartoe.electronics.photorama.ConfigurationServlet.CAMERA_KEY; import static org.onebeartoe.electronics.photorama.PhotoBoothButtonTester.buttonPin; import org.onebeartoe.system.Sleeper; Sleeper.sleepo(SNAPSHOT_DELAY); camera.takeSnapshot(); } } @Override public void destroy() { ServletContext servletContext = getServletContext(); GpioController gpio = (GpioController) servletContext.getAttribute(PHOTO_BOOTH_GPIO_CONTROLLER_KEY); gpio.shutdown(); } @Override public void init() throws ServletException { super.init(); logger = Logger.getLogger(getClass().getName()); takingSnapshots = false; ServletContext servletContext = getServletContext(); GpioController gpio = (GpioController) servletContext.getAttribute(PHOTO_BOOTH_GPIO_CONTROLLER_KEY); if(gpio == null) { System.out.println("*Provisioning GPIO."); gpio = GpioFactory.getInstance(); servletContext.setAttribute(PHOTO_BOOTH_GPIO_CONTROLLER_KEY, gpio);
GpioPinDigitalInput photoBoothButton = gpio.provisionDigitalInputPin(buttonPin,
onebeartoe/photorama
photorama-raspberry-pi-webapp/src/main/java/org/onebeartoe/electronics/photorama/PhotoBoothServlet.java
// Path: photorama-raspberry-pi-webapp/src/main/java/org/onebeartoe/electronics/photorama/ConfigurationServlet.java // public static final String CAMERA_KEY = "camera"; // // Path: photorama-raspberry-pi/src/main/java/org/onebeartoe/electronics/photorama/PhotoBoothButtonTester.java // public static final Pin buttonPin = RaspiPin.GPIO_02;
import com.pi4j.io.gpio.GpioController; import com.pi4j.io.gpio.GpioFactory; import com.pi4j.io.gpio.GpioPinDigitalInput; import com.pi4j.io.gpio.PinPullResistance; import com.pi4j.io.gpio.PinState; import com.pi4j.io.gpio.event.GpioPinDigitalStateChangeEvent; import com.pi4j.io.gpio.event.GpioPinListenerDigital; import java.util.logging.Level; import java.util.logging.Logger; import javax.servlet.ServletContext; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import static org.onebeartoe.electronics.photorama.ConfigurationServlet.CAMERA_KEY; import static org.onebeartoe.electronics.photorama.PhotoBoothButtonTester.buttonPin; import org.onebeartoe.system.Sleeper;
System.out.println("*Provisioning GPIO."); gpio = GpioFactory.getInstance(); servletContext.setAttribute(PHOTO_BOOTH_GPIO_CONTROLLER_KEY, gpio); GpioPinDigitalInput photoBoothButton = gpio.provisionDigitalInputPin(buttonPin, "photo booth button", PinPullResistance.PULL_UP); // works with the Adafruit massive arcade button // PinPullResistance.PULL_DOWN); // works with a tactile/simple push button System.out.println("*GPIO provisioned :)"); photoBoothButton.addListener(this); servletContext.setAttribute(PHOTO_BOOTH_BUTTON_KEY, photoBoothButton); } } @Override public void handleGpioPinDigitalStateChangeEvent(GpioPinDigitalStateChangeEvent event) { PinState state = event.getState(); if(state == PinState.LOW) { System.out.println("Photo booth button pin state changed to LOW."); if(takingSnapshots) { String message = "The photobooth button was pressed, while already taking photos."; System.out.println(message); } else { ServletContext servletContext = getServletContext();
// Path: photorama-raspberry-pi-webapp/src/main/java/org/onebeartoe/electronics/photorama/ConfigurationServlet.java // public static final String CAMERA_KEY = "camera"; // // Path: photorama-raspberry-pi/src/main/java/org/onebeartoe/electronics/photorama/PhotoBoothButtonTester.java // public static final Pin buttonPin = RaspiPin.GPIO_02; // Path: photorama-raspberry-pi-webapp/src/main/java/org/onebeartoe/electronics/photorama/PhotoBoothServlet.java import com.pi4j.io.gpio.GpioController; import com.pi4j.io.gpio.GpioFactory; import com.pi4j.io.gpio.GpioPinDigitalInput; import com.pi4j.io.gpio.PinPullResistance; import com.pi4j.io.gpio.PinState; import com.pi4j.io.gpio.event.GpioPinDigitalStateChangeEvent; import com.pi4j.io.gpio.event.GpioPinListenerDigital; import java.util.logging.Level; import java.util.logging.Logger; import javax.servlet.ServletContext; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import static org.onebeartoe.electronics.photorama.ConfigurationServlet.CAMERA_KEY; import static org.onebeartoe.electronics.photorama.PhotoBoothButtonTester.buttonPin; import org.onebeartoe.system.Sleeper; System.out.println("*Provisioning GPIO."); gpio = GpioFactory.getInstance(); servletContext.setAttribute(PHOTO_BOOTH_GPIO_CONTROLLER_KEY, gpio); GpioPinDigitalInput photoBoothButton = gpio.provisionDigitalInputPin(buttonPin, "photo booth button", PinPullResistance.PULL_UP); // works with the Adafruit massive arcade button // PinPullResistance.PULL_DOWN); // works with a tactile/simple push button System.out.println("*GPIO provisioned :)"); photoBoothButton.addListener(this); servletContext.setAttribute(PHOTO_BOOTH_BUTTON_KEY, photoBoothButton); } } @Override public void handleGpioPinDigitalStateChangeEvent(GpioPinDigitalStateChangeEvent event) { PinState state = event.getState(); if(state == PinState.LOW) { System.out.println("Photo booth button pin state changed to LOW."); if(takingSnapshots) { String message = "The photobooth button was pressed, while already taking photos."; System.out.println(message); } else { ServletContext servletContext = getServletContext();
Camera camera = (Camera) servletContext.getAttribute(CAMERA_KEY);
onebeartoe/photorama
photorama-raspberry-pi-webapp/src/main/java/org/onebeartoe/electronics/photorama/FootPedalServlet.java
// Path: photorama-raspberry-pi-webapp/src/main/java/org/onebeartoe/electronics/photorama/ConfigurationServlet.java // public static final String CAMERA_KEY = "camera"; // // Path: photorama-raspberry-pi-webapp/src/main/java/org/onebeartoe/electronics/photorama/PhotoBoothServlet.java // public static final String PHOTO_BOOTH_GPIO_CONTROLLER_KEY = "PHOTO_BOOTH_GPIO_CONTROLLER_KEY";
import com.pi4j.io.gpio.GpioController; import com.pi4j.io.gpio.GpioPinDigitalInput; import com.pi4j.io.gpio.PinPullResistance; import com.pi4j.io.gpio.PinState; import com.pi4j.io.gpio.RaspiPin; import com.pi4j.io.gpio.event.GpioPinDigitalStateChangeEvent; import com.pi4j.io.gpio.event.GpioPinListenerDigital; import javax.servlet.ServletContext; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import static org.onebeartoe.electronics.photorama.ConfigurationServlet.CAMERA_KEY; import static org.onebeartoe.electronics.photorama.PhotoBoothServlet.PHOTO_BOOTH_GPIO_CONTROLLER_KEY;
package org.onebeartoe.electronics.photorama; /** * @author Roberto Marquez */ @WebServlet(urlPatterns = {"/foot-pedal"}) public class FootPedalServlet extends HttpServlet implements GpioPinListenerDigital { private final String PHOTO_BOOTH_FOOT_PEDAL_KEY = "PHOTO_BOOTH_FOOT_PEDAL_KEY"; private volatile boolean takingSnapshot; @Override public void init() throws ServletException { super.init(); takingSnapshot = false; ServletContext servletContext = getServletContext();
// Path: photorama-raspberry-pi-webapp/src/main/java/org/onebeartoe/electronics/photorama/ConfigurationServlet.java // public static final String CAMERA_KEY = "camera"; // // Path: photorama-raspberry-pi-webapp/src/main/java/org/onebeartoe/electronics/photorama/PhotoBoothServlet.java // public static final String PHOTO_BOOTH_GPIO_CONTROLLER_KEY = "PHOTO_BOOTH_GPIO_CONTROLLER_KEY"; // Path: photorama-raspberry-pi-webapp/src/main/java/org/onebeartoe/electronics/photorama/FootPedalServlet.java import com.pi4j.io.gpio.GpioController; import com.pi4j.io.gpio.GpioPinDigitalInput; import com.pi4j.io.gpio.PinPullResistance; import com.pi4j.io.gpio.PinState; import com.pi4j.io.gpio.RaspiPin; import com.pi4j.io.gpio.event.GpioPinDigitalStateChangeEvent; import com.pi4j.io.gpio.event.GpioPinListenerDigital; import javax.servlet.ServletContext; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import static org.onebeartoe.electronics.photorama.ConfigurationServlet.CAMERA_KEY; import static org.onebeartoe.electronics.photorama.PhotoBoothServlet.PHOTO_BOOTH_GPIO_CONTROLLER_KEY; package org.onebeartoe.electronics.photorama; /** * @author Roberto Marquez */ @WebServlet(urlPatterns = {"/foot-pedal"}) public class FootPedalServlet extends HttpServlet implements GpioPinListenerDigital { private final String PHOTO_BOOTH_FOOT_PEDAL_KEY = "PHOTO_BOOTH_FOOT_PEDAL_KEY"; private volatile boolean takingSnapshot; @Override public void init() throws ServletException { super.init(); takingSnapshot = false; ServletContext servletContext = getServletContext();
GpioController gpio = (GpioController) servletContext.getAttribute(PHOTO_BOOTH_GPIO_CONTROLLER_KEY);
onebeartoe/photorama
photorama-raspberry-pi-webapp/src/main/java/org/onebeartoe/electronics/photorama/FootPedalServlet.java
// Path: photorama-raspberry-pi-webapp/src/main/java/org/onebeartoe/electronics/photorama/ConfigurationServlet.java // public static final String CAMERA_KEY = "camera"; // // Path: photorama-raspberry-pi-webapp/src/main/java/org/onebeartoe/electronics/photorama/PhotoBoothServlet.java // public static final String PHOTO_BOOTH_GPIO_CONTROLLER_KEY = "PHOTO_BOOTH_GPIO_CONTROLLER_KEY";
import com.pi4j.io.gpio.GpioController; import com.pi4j.io.gpio.GpioPinDigitalInput; import com.pi4j.io.gpio.PinPullResistance; import com.pi4j.io.gpio.PinState; import com.pi4j.io.gpio.RaspiPin; import com.pi4j.io.gpio.event.GpioPinDigitalStateChangeEvent; import com.pi4j.io.gpio.event.GpioPinListenerDigital; import javax.servlet.ServletContext; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import static org.onebeartoe.electronics.photorama.ConfigurationServlet.CAMERA_KEY; import static org.onebeartoe.electronics.photorama.PhotoBoothServlet.PHOTO_BOOTH_GPIO_CONTROLLER_KEY;
ServletContext servletContext = getServletContext(); GpioController gpio = (GpioController) servletContext.getAttribute(PHOTO_BOOTH_GPIO_CONTROLLER_KEY); if(gpio == null) { System.err.println("The foot pedal servlet could not obtain a GPIO contorller from the servlet context"); } else { GpioPinDigitalInput photoBoothButton = gpio.provisionDigitalInputPin(RaspiPin.GPIO_17, "foot pedal button", PinPullResistance.PULL_UP); photoBoothButton.addListener(this); servletContext.setAttribute(PHOTO_BOOTH_FOOT_PEDAL_KEY, photoBoothButton); } } @Override public void handleGpioPinDigitalStateChangeEvent(GpioPinDigitalStateChangeEvent event) { PinState state = event.getState(); if(state == PinState.HIGH) { if(takingSnapshot) { String message = "The foot pedal was pressed, while already taking a photo."; System.out.println(message); } else { ServletContext servletContext = getServletContext();
// Path: photorama-raspberry-pi-webapp/src/main/java/org/onebeartoe/electronics/photorama/ConfigurationServlet.java // public static final String CAMERA_KEY = "camera"; // // Path: photorama-raspberry-pi-webapp/src/main/java/org/onebeartoe/electronics/photorama/PhotoBoothServlet.java // public static final String PHOTO_BOOTH_GPIO_CONTROLLER_KEY = "PHOTO_BOOTH_GPIO_CONTROLLER_KEY"; // Path: photorama-raspberry-pi-webapp/src/main/java/org/onebeartoe/electronics/photorama/FootPedalServlet.java import com.pi4j.io.gpio.GpioController; import com.pi4j.io.gpio.GpioPinDigitalInput; import com.pi4j.io.gpio.PinPullResistance; import com.pi4j.io.gpio.PinState; import com.pi4j.io.gpio.RaspiPin; import com.pi4j.io.gpio.event.GpioPinDigitalStateChangeEvent; import com.pi4j.io.gpio.event.GpioPinListenerDigital; import javax.servlet.ServletContext; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import static org.onebeartoe.electronics.photorama.ConfigurationServlet.CAMERA_KEY; import static org.onebeartoe.electronics.photorama.PhotoBoothServlet.PHOTO_BOOTH_GPIO_CONTROLLER_KEY; ServletContext servletContext = getServletContext(); GpioController gpio = (GpioController) servletContext.getAttribute(PHOTO_BOOTH_GPIO_CONTROLLER_KEY); if(gpio == null) { System.err.println("The foot pedal servlet could not obtain a GPIO contorller from the servlet context"); } else { GpioPinDigitalInput photoBoothButton = gpio.provisionDigitalInputPin(RaspiPin.GPIO_17, "foot pedal button", PinPullResistance.PULL_UP); photoBoothButton.addListener(this); servletContext.setAttribute(PHOTO_BOOTH_FOOT_PEDAL_KEY, photoBoothButton); } } @Override public void handleGpioPinDigitalStateChangeEvent(GpioPinDigitalStateChangeEvent event) { PinState state = event.getState(); if(state == PinState.HIGH) { if(takingSnapshot) { String message = "The foot pedal was pressed, while already taking a photo."; System.out.println(message); } else { ServletContext servletContext = getServletContext();
Camera camera = (Camera) servletContext.getAttribute(CAMERA_KEY);
onebeartoe/photorama
photorama-raspberry-pi-lcd-keypad/src/main/java/se/hirt/pi/adafruitlcd/demo/HelloWorldTest.java
// Path: photorama-raspberry-pi-lcd-keypad/src/main/java/se/hirt/pi/adafruitlcd/ILCD.java // public interface ILCD { // // void setText(String s) throws IOException; // // void setText(int row, String string) throws IOException; // // void setCursorPosition(int row, int column) throws IOException; // // void stop() throws IOException; // // void clear() throws IOException; // // void home() throws IOException; // // void setCursorEnabled(boolean enable) throws IOException; // // boolean isCursorEnabled(); // // void setDisplayEnabled(boolean enable) throws IOException; // // boolean isDisplayEnabled(); // // void setBlinkEnabled(boolean enable) throws IOException; // // boolean isBlinkEnabled(); // // void setBacklight(Color color) throws IOException; // // Color getBacklight() throws IOException; // // void scrollDisplay(Direction direction) throws IOException; // // void setTextFlowDirection(Direction direction) throws IOException; // // void setAutoScrollEnabled(boolean enable) throws IOException; // // boolean isAutoScrollEnabled(); // // boolean isButtonPressed(Button button) throws IOException; // // int buttonsPressedBitmask() throws IOException; // // }
import java.io.IOException; import se.hirt.pi.adafruitlcd.ILCD;
/* * Copyright (C) 2013 Marcus Hirt * www.hirt.se * * This software is free: * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESSED OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * Copyright (C) Marcus Hirt, 2013 */ package se.hirt.pi.adafruitlcd.demo; /** * The mandatory Hello World! * * @author Marcus Hirt */ public class HelloWorldTest implements LCDTest { @Override public String getName() { return "Hello World"; } @Override
// Path: photorama-raspberry-pi-lcd-keypad/src/main/java/se/hirt/pi/adafruitlcd/ILCD.java // public interface ILCD { // // void setText(String s) throws IOException; // // void setText(int row, String string) throws IOException; // // void setCursorPosition(int row, int column) throws IOException; // // void stop() throws IOException; // // void clear() throws IOException; // // void home() throws IOException; // // void setCursorEnabled(boolean enable) throws IOException; // // boolean isCursorEnabled(); // // void setDisplayEnabled(boolean enable) throws IOException; // // boolean isDisplayEnabled(); // // void setBlinkEnabled(boolean enable) throws IOException; // // boolean isBlinkEnabled(); // // void setBacklight(Color color) throws IOException; // // Color getBacklight() throws IOException; // // void scrollDisplay(Direction direction) throws IOException; // // void setTextFlowDirection(Direction direction) throws IOException; // // void setAutoScrollEnabled(boolean enable) throws IOException; // // boolean isAutoScrollEnabled(); // // boolean isButtonPressed(Button button) throws IOException; // // int buttonsPressedBitmask() throws IOException; // // } // Path: photorama-raspberry-pi-lcd-keypad/src/main/java/se/hirt/pi/adafruitlcd/demo/HelloWorldTest.java import java.io.IOException; import se.hirt.pi.adafruitlcd.ILCD; /* * Copyright (C) 2013 Marcus Hirt * www.hirt.se * * This software is free: * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESSED OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * Copyright (C) Marcus Hirt, 2013 */ package se.hirt.pi.adafruitlcd.demo; /** * The mandatory Hello World! * * @author Marcus Hirt */ public class HelloWorldTest implements LCDTest { @Override public String getName() { return "Hello World"; } @Override
public void run(ILCD lcd) throws IOException {
onebeartoe/photorama
photorama-model/src/main/java/org/onebeartoe/electronics/photorama/states/time/lapse/MinutesState.java
// Path: photorama-model/src/main/java/org/onebeartoe/electronics/photorama/states/PhotoramaState.java // public interface PhotoramaState // { // public void setCamera(Camera camera); // // public String getLabel(); // public String getValue(); // // public PhotoramaState leftButton(); // public PhotoramaState rightButton(); // public PhotoramaState upButton(); // public PhotoramaState downButton(); // public PhotoramaState selectButton(); // // public void setLeftButton(PhotoramaState leftState); // public void setRightButton(PhotoramaState rightState); // public void setUpButton(PhotoramaState upState); // public void setDownButton(PhotoramaState downState); // public void setSelectButton(PhotoramaState selectState); // } // // Path: photorama-model/src/main/java/org/onebeartoe/electronics/photorama/states/RootState.java // public class RootState implements PhotoramaState // { // protected PhotoramaState upState; // protected PhotoramaState downState; // protected PhotoramaState leftState; // protected PhotoramaState rightState; // protected PhotoramaState selectState; // // protected String label = "no label"; // protected String value = "no value"; // // static protected Camera camera; // // public String getLabel() // { // return label; // } // // public String getValue() // { // return value; // } // // public PhotoramaState leftButton() // { // String className = getClass().getSimpleName(); // // System.out.println(className + " does nothing for LEFT button pushes."); // // return this; // } // // protected void printMovingTo(PhotoramaState state) // { // String stateName = state.getClass().getSimpleName(); // // System.out.println("Moving to " + stateName); // } // // public PhotoramaState rightButton() // { // String className = getClass().getSimpleName(); // System.out.println(className + " does nothing for RIGHT button pushes."); // // return this; // } // // @Override // public PhotoramaState upButton() // { // printMovingTo(upState); // // return upState; // } // // public PhotoramaState downButton() // { // String className = getClass().getSimpleName(); // System.out.println(className + " does nothing for DOWN button pushes."); // // return this; // } // // @Override // public PhotoramaState selectButton() // { // printMovingTo(selectState); // // return selectState; // } // // public PhotoramaState selectButton() // // { // // String className = getClass().getSimpleName(); // // System.out.println(className + " does nothing for SELECT button pushes."); // // // // return this; // // } // // @Override // public void setCamera(Camera camera) // { // this.camera = camera; // } // // @Override // public void setLeftButton(PhotoramaState leftState) // { // this.leftState = leftState; // } // // @Override // public void setRightButton(PhotoramaState rightState) // { // this.rightState = rightState; // } // // @Override // public void setUpButton(PhotoramaState upState) // { // this.upState = upState; // } // // @Override // public void setDownButton(PhotoramaState downState) // { // this.downState = downState; // } // // @Override // public void setSelectButton(PhotoramaState selectState) // { // this.selectState = selectState; // } // }
import org.onebeartoe.electronics.photorama.states.PhotoramaState; import org.onebeartoe.electronics.photorama.states.RootState;
package org.onebeartoe.electronics.photorama.states.time.lapse; /** * @author Roberto Marquez */ public class MinutesState extends RootState { protected int delta = 1; public MinutesState() { label = "Minutes"; value = "5"; } @Override
// Path: photorama-model/src/main/java/org/onebeartoe/electronics/photorama/states/PhotoramaState.java // public interface PhotoramaState // { // public void setCamera(Camera camera); // // public String getLabel(); // public String getValue(); // // public PhotoramaState leftButton(); // public PhotoramaState rightButton(); // public PhotoramaState upButton(); // public PhotoramaState downButton(); // public PhotoramaState selectButton(); // // public void setLeftButton(PhotoramaState leftState); // public void setRightButton(PhotoramaState rightState); // public void setUpButton(PhotoramaState upState); // public void setDownButton(PhotoramaState downState); // public void setSelectButton(PhotoramaState selectState); // } // // Path: photorama-model/src/main/java/org/onebeartoe/electronics/photorama/states/RootState.java // public class RootState implements PhotoramaState // { // protected PhotoramaState upState; // protected PhotoramaState downState; // protected PhotoramaState leftState; // protected PhotoramaState rightState; // protected PhotoramaState selectState; // // protected String label = "no label"; // protected String value = "no value"; // // static protected Camera camera; // // public String getLabel() // { // return label; // } // // public String getValue() // { // return value; // } // // public PhotoramaState leftButton() // { // String className = getClass().getSimpleName(); // // System.out.println(className + " does nothing for LEFT button pushes."); // // return this; // } // // protected void printMovingTo(PhotoramaState state) // { // String stateName = state.getClass().getSimpleName(); // // System.out.println("Moving to " + stateName); // } // // public PhotoramaState rightButton() // { // String className = getClass().getSimpleName(); // System.out.println(className + " does nothing for RIGHT button pushes."); // // return this; // } // // @Override // public PhotoramaState upButton() // { // printMovingTo(upState); // // return upState; // } // // public PhotoramaState downButton() // { // String className = getClass().getSimpleName(); // System.out.println(className + " does nothing for DOWN button pushes."); // // return this; // } // // @Override // public PhotoramaState selectButton() // { // printMovingTo(selectState); // // return selectState; // } // // public PhotoramaState selectButton() // // { // // String className = getClass().getSimpleName(); // // System.out.println(className + " does nothing for SELECT button pushes."); // // // // return this; // // } // // @Override // public void setCamera(Camera camera) // { // this.camera = camera; // } // // @Override // public void setLeftButton(PhotoramaState leftState) // { // this.leftState = leftState; // } // // @Override // public void setRightButton(PhotoramaState rightState) // { // this.rightState = rightState; // } // // @Override // public void setUpButton(PhotoramaState upState) // { // this.upState = upState; // } // // @Override // public void setDownButton(PhotoramaState downState) // { // this.downState = downState; // } // // @Override // public void setSelectButton(PhotoramaState selectState) // { // this.selectState = selectState; // } // } // Path: photorama-model/src/main/java/org/onebeartoe/electronics/photorama/states/time/lapse/MinutesState.java import org.onebeartoe.electronics.photorama.states.PhotoramaState; import org.onebeartoe.electronics.photorama.states.RootState; package org.onebeartoe.electronics.photorama.states.time.lapse; /** * @author Roberto Marquez */ public class MinutesState extends RootState { protected int delta = 1; public MinutesState() { label = "Minutes"; value = "5"; } @Override
public PhotoramaState leftButton()
onebeartoe/photorama
photorama-model/src/main/java/org/onebeartoe/electronics/photorama/states/mode/ModeSnapshotState.java
// Path: photorama-model/src/main/java/org/onebeartoe/electronics/photorama/states/PhotoramaState.java // public interface PhotoramaState // { // public void setCamera(Camera camera); // // public String getLabel(); // public String getValue(); // // public PhotoramaState leftButton(); // public PhotoramaState rightButton(); // public PhotoramaState upButton(); // public PhotoramaState downButton(); // public PhotoramaState selectButton(); // // public void setLeftButton(PhotoramaState leftState); // public void setRightButton(PhotoramaState rightState); // public void setUpButton(PhotoramaState upState); // public void setDownButton(PhotoramaState downState); // public void setSelectButton(PhotoramaState selectState); // }
import org.onebeartoe.electronics.photorama.states.PhotoramaState;
package org.onebeartoe.electronics.photorama.states.mode; /** * @author Roberto Marquez */ //TODO: rename this calss to ModeSnapshotState public class ModeSnapshotState extends ModeStates { @Override public String getValue() { return "Snapshot ->"; } @Override
// Path: photorama-model/src/main/java/org/onebeartoe/electronics/photorama/states/PhotoramaState.java // public interface PhotoramaState // { // public void setCamera(Camera camera); // // public String getLabel(); // public String getValue(); // // public PhotoramaState leftButton(); // public PhotoramaState rightButton(); // public PhotoramaState upButton(); // public PhotoramaState downButton(); // public PhotoramaState selectButton(); // // public void setLeftButton(PhotoramaState leftState); // public void setRightButton(PhotoramaState rightState); // public void setUpButton(PhotoramaState upState); // public void setDownButton(PhotoramaState downState); // public void setSelectButton(PhotoramaState selectState); // } // Path: photorama-model/src/main/java/org/onebeartoe/electronics/photorama/states/mode/ModeSnapshotState.java import org.onebeartoe.electronics.photorama.states.PhotoramaState; package org.onebeartoe.electronics.photorama.states.mode; /** * @author Roberto Marquez */ //TODO: rename this calss to ModeSnapshotState public class ModeSnapshotState extends ModeStates { @Override public String getValue() { return "Snapshot ->"; } @Override
public PhotoramaState rightButton()
onebeartoe/photorama
photorama-model/src/main/java/org/onebeartoe/electronics/photorama/states/foot/pedal/FootPedalOnState.java
// Path: photorama-model/src/main/java/org/onebeartoe/electronics/photorama/states/PhotoramaState.java // public interface PhotoramaState // { // public void setCamera(Camera camera); // // public String getLabel(); // public String getValue(); // // public PhotoramaState leftButton(); // public PhotoramaState rightButton(); // public PhotoramaState upButton(); // public PhotoramaState downButton(); // public PhotoramaState selectButton(); // // public void setLeftButton(PhotoramaState leftState); // public void setRightButton(PhotoramaState rightState); // public void setUpButton(PhotoramaState upState); // public void setDownButton(PhotoramaState downState); // public void setSelectButton(PhotoramaState selectState); // }
import org.onebeartoe.electronics.photorama.states.PhotoramaState;
package org.onebeartoe.electronics.photorama.states.foot.pedal; /** * @author Roberto Marquez */ public class FootPedalOnState extends FootPedalStates { @Override public String getValue() { return "On ->"; } @Override
// Path: photorama-model/src/main/java/org/onebeartoe/electronics/photorama/states/PhotoramaState.java // public interface PhotoramaState // { // public void setCamera(Camera camera); // // public String getLabel(); // public String getValue(); // // public PhotoramaState leftButton(); // public PhotoramaState rightButton(); // public PhotoramaState upButton(); // public PhotoramaState downButton(); // public PhotoramaState selectButton(); // // public void setLeftButton(PhotoramaState leftState); // public void setRightButton(PhotoramaState rightState); // public void setUpButton(PhotoramaState upState); // public void setDownButton(PhotoramaState downState); // public void setSelectButton(PhotoramaState selectState); // } // Path: photorama-model/src/main/java/org/onebeartoe/electronics/photorama/states/foot/pedal/FootPedalOnState.java import org.onebeartoe.electronics.photorama.states.PhotoramaState; package org.onebeartoe.electronics.photorama.states.foot.pedal; /** * @author Roberto Marquez */ public class FootPedalOnState extends FootPedalStates { @Override public String getValue() { return "On ->"; } @Override
public PhotoramaState rightButton()
onebeartoe/photorama
photorama-model/src/main/java/org/onebeartoe/electronics/photorama/states/raspberry/pi/RaspberryPiShutdownState.java
// Path: photorama-model/src/main/java/org/onebeartoe/electronics/photorama/states/PhotoramaState.java // public interface PhotoramaState // { // public void setCamera(Camera camera); // // public String getLabel(); // public String getValue(); // // public PhotoramaState leftButton(); // public PhotoramaState rightButton(); // public PhotoramaState upButton(); // public PhotoramaState downButton(); // public PhotoramaState selectButton(); // // public void setLeftButton(PhotoramaState leftState); // public void setRightButton(PhotoramaState rightState); // public void setUpButton(PhotoramaState upState); // public void setDownButton(PhotoramaState downState); // public void setSelectButton(PhotoramaState selectState); // }
import org.onebeartoe.electronics.photorama.states.PhotoramaState;
package org.onebeartoe.electronics.photorama.states.raspberry.pi; /** * @author Roberto Marquez */ public class RaspberryPiShutdownState extends RaspberryPiStates { @Override public String getValue() { return "<- Shutdown"; } @Override
// Path: photorama-model/src/main/java/org/onebeartoe/electronics/photorama/states/PhotoramaState.java // public interface PhotoramaState // { // public void setCamera(Camera camera); // // public String getLabel(); // public String getValue(); // // public PhotoramaState leftButton(); // public PhotoramaState rightButton(); // public PhotoramaState upButton(); // public PhotoramaState downButton(); // public PhotoramaState selectButton(); // // public void setLeftButton(PhotoramaState leftState); // public void setRightButton(PhotoramaState rightState); // public void setUpButton(PhotoramaState upState); // public void setDownButton(PhotoramaState downState); // public void setSelectButton(PhotoramaState selectState); // } // Path: photorama-model/src/main/java/org/onebeartoe/electronics/photorama/states/raspberry/pi/RaspberryPiShutdownState.java import org.onebeartoe.electronics.photorama.states.PhotoramaState; package org.onebeartoe.electronics.photorama.states.raspberry.pi; /** * @author Roberto Marquez */ public class RaspberryPiShutdownState extends RaspberryPiStates { @Override public String getValue() { return "<- Shutdown"; } @Override
public PhotoramaState leftButton()
onebeartoe/photorama
photorama-raspberry-pi-lcd-keypad/src/main/java/se/hirt/pi/adafruitlcd/demo/DisplayDemo.java
// Path: photorama-raspberry-pi-lcd-keypad/src/main/java/se/hirt/pi/adafruitlcd/ILCD.java // public interface ILCD { // // void setText(String s) throws IOException; // // void setText(int row, String string) throws IOException; // // void setCursorPosition(int row, int column) throws IOException; // // void stop() throws IOException; // // void clear() throws IOException; // // void home() throws IOException; // // void setCursorEnabled(boolean enable) throws IOException; // // boolean isCursorEnabled(); // // void setDisplayEnabled(boolean enable) throws IOException; // // boolean isDisplayEnabled(); // // void setBlinkEnabled(boolean enable) throws IOException; // // boolean isBlinkEnabled(); // // void setBacklight(Color color) throws IOException; // // Color getBacklight() throws IOException; // // void scrollDisplay(Direction direction) throws IOException; // // void setTextFlowDirection(Direction direction) throws IOException; // // void setAutoScrollEnabled(boolean enable) throws IOException; // // boolean isAutoScrollEnabled(); // // boolean isButtonPressed(Button button) throws IOException; // // int buttonsPressedBitmask() throws IOException; // // }
import java.io.IOException; import se.hirt.pi.adafruitlcd.ILCD;
/* * Copyright (C) 2013 Marcus Hirt * www.hirt.se * * This software is free: * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESSED OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * Copyright (C) Marcus Hirt, 2013 */ package se.hirt.pi.adafruitlcd.demo; /** * Simply turns off and on the display a few times. * * @author Marcus Hirt */ public class DisplayDemo implements LCDTest { @Override public String getName() { return "Display"; } @Override
// Path: photorama-raspberry-pi-lcd-keypad/src/main/java/se/hirt/pi/adafruitlcd/ILCD.java // public interface ILCD { // // void setText(String s) throws IOException; // // void setText(int row, String string) throws IOException; // // void setCursorPosition(int row, int column) throws IOException; // // void stop() throws IOException; // // void clear() throws IOException; // // void home() throws IOException; // // void setCursorEnabled(boolean enable) throws IOException; // // boolean isCursorEnabled(); // // void setDisplayEnabled(boolean enable) throws IOException; // // boolean isDisplayEnabled(); // // void setBlinkEnabled(boolean enable) throws IOException; // // boolean isBlinkEnabled(); // // void setBacklight(Color color) throws IOException; // // Color getBacklight() throws IOException; // // void scrollDisplay(Direction direction) throws IOException; // // void setTextFlowDirection(Direction direction) throws IOException; // // void setAutoScrollEnabled(boolean enable) throws IOException; // // boolean isAutoScrollEnabled(); // // boolean isButtonPressed(Button button) throws IOException; // // int buttonsPressedBitmask() throws IOException; // // } // Path: photorama-raspberry-pi-lcd-keypad/src/main/java/se/hirt/pi/adafruitlcd/demo/DisplayDemo.java import java.io.IOException; import se.hirt.pi.adafruitlcd.ILCD; /* * Copyright (C) 2013 Marcus Hirt * www.hirt.se * * This software is free: * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESSED OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * Copyright (C) Marcus Hirt, 2013 */ package se.hirt.pi.adafruitlcd.demo; /** * Simply turns off and on the display a few times. * * @author Marcus Hirt */ public class DisplayDemo implements LCDTest { @Override public String getName() { return "Display"; } @Override
public void run(ILCD lcd) throws IOException {
onebeartoe/photorama
photorama-raspberry-pi-webapp/src/main/java/org/onebeartoe/electronics/photorama/ModeServlet.java
// Path: photorama-raspberry-pi-webapp/src/main/java/org/onebeartoe/electronics/photorama/ConfigurationServlet.java // public static final String CAMERA_KEY = "camera";
import java.io.File; import java.io.FileFilter; import java.io.FilenameFilter; import javax.servlet.ServletContext; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.onebeartoe.application.Enums; import static org.onebeartoe.electronics.photorama.ConfigurationServlet.CAMERA_KEY; import org.onebeartoe.web.PlainTextResponseServlet;
switch(mode) { case FOOT_PEDAL: { subpath = "foot-pedal/"; break; } case PHOTO_BOOTH: { subpath = "photo-booth/"; break; } case TIME_LAPSE: { subpath = "time-lapse/"; break; } default: { // off subpath = ""; } } return subpath; } private String updateMode(PhotoramaModes mode) { ServletContext context = getServletContext();
// Path: photorama-raspberry-pi-webapp/src/main/java/org/onebeartoe/electronics/photorama/ConfigurationServlet.java // public static final String CAMERA_KEY = "camera"; // Path: photorama-raspberry-pi-webapp/src/main/java/org/onebeartoe/electronics/photorama/ModeServlet.java import java.io.File; import java.io.FileFilter; import java.io.FilenameFilter; import javax.servlet.ServletContext; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.onebeartoe.application.Enums; import static org.onebeartoe.electronics.photorama.ConfigurationServlet.CAMERA_KEY; import org.onebeartoe.web.PlainTextResponseServlet; switch(mode) { case FOOT_PEDAL: { subpath = "foot-pedal/"; break; } case PHOTO_BOOTH: { subpath = "photo-booth/"; break; } case TIME_LAPSE: { subpath = "time-lapse/"; break; } default: { // off subpath = ""; } } return subpath; } private String updateMode(PhotoramaModes mode) { ServletContext context = getServletContext();
Camera camera = (Camera) context.getAttribute(CAMERA_KEY);
onebeartoe/photorama
photorama-model/src/main/java/org/onebeartoe/electronics/photorama/states/raspberry/pi/RaspberryPiConfirmShutdownState.java
// Path: photorama-model/src/main/java/org/onebeartoe/electronics/photorama/states/PhotoramaState.java // public interface PhotoramaState // { // public void setCamera(Camera camera); // // public String getLabel(); // public String getValue(); // // public PhotoramaState leftButton(); // public PhotoramaState rightButton(); // public PhotoramaState upButton(); // public PhotoramaState downButton(); // public PhotoramaState selectButton(); // // public void setLeftButton(PhotoramaState leftState); // public void setRightButton(PhotoramaState rightState); // public void setUpButton(PhotoramaState upState); // public void setDownButton(PhotoramaState downState); // public void setSelectButton(PhotoramaState selectState); // }
import org.onebeartoe.electronics.photorama.states.PhotoramaState;
package org.onebeartoe.electronics.photorama.states.raspberry.pi; /** * @author Roberto Marquez */ public class RaspberryPiConfirmShutdownState extends RaspberryPiStates { private String value = "Confirm Shutdown?"; @Override public String getValue() { return value; } @Override
// Path: photorama-model/src/main/java/org/onebeartoe/electronics/photorama/states/PhotoramaState.java // public interface PhotoramaState // { // public void setCamera(Camera camera); // // public String getLabel(); // public String getValue(); // // public PhotoramaState leftButton(); // public PhotoramaState rightButton(); // public PhotoramaState upButton(); // public PhotoramaState downButton(); // public PhotoramaState selectButton(); // // public void setLeftButton(PhotoramaState leftState); // public void setRightButton(PhotoramaState rightState); // public void setUpButton(PhotoramaState upState); // public void setDownButton(PhotoramaState downState); // public void setSelectButton(PhotoramaState selectState); // } // Path: photorama-model/src/main/java/org/onebeartoe/electronics/photorama/states/raspberry/pi/RaspberryPiConfirmShutdownState.java import org.onebeartoe.electronics.photorama.states.PhotoramaState; package org.onebeartoe.electronics.photorama.states.raspberry.pi; /** * @author Roberto Marquez */ public class RaspberryPiConfirmShutdownState extends RaspberryPiStates { private String value = "Confirm Shutdown?"; @Override public String getValue() { return value; } @Override
public PhotoramaState selectButton()
onebeartoe/photorama
photorama-raspberry-pi-lcd-keypad/src/main/java/se/hirt/pi/adafruitlcd/demo/ScrollTest.java
// Path: photorama-raspberry-pi-lcd-keypad/src/main/java/se/hirt/pi/adafruitlcd/ILCD.java // public interface ILCD { // // void setText(String s) throws IOException; // // void setText(int row, String string) throws IOException; // // void setCursorPosition(int row, int column) throws IOException; // // void stop() throws IOException; // // void clear() throws IOException; // // void home() throws IOException; // // void setCursorEnabled(boolean enable) throws IOException; // // boolean isCursorEnabled(); // // void setDisplayEnabled(boolean enable) throws IOException; // // boolean isDisplayEnabled(); // // void setBlinkEnabled(boolean enable) throws IOException; // // boolean isBlinkEnabled(); // // void setBacklight(Color color) throws IOException; // // Color getBacklight() throws IOException; // // void scrollDisplay(Direction direction) throws IOException; // // void setTextFlowDirection(Direction direction) throws IOException; // // void setAutoScrollEnabled(boolean enable) throws IOException; // // boolean isAutoScrollEnabled(); // // boolean isButtonPressed(Button button) throws IOException; // // int buttonsPressedBitmask() throws IOException; // // } // // Path: photorama-raspberry-pi-lcd-keypad/src/main/java/se/hirt/pi/adafruitlcd/impl/RealLCD.java // public enum Direction { // LEFT, RIGHT; // }
import java.io.IOException; import se.hirt.pi.adafruitlcd.ILCD; import se.hirt.pi.adafruitlcd.impl.RealLCD.Direction;
/* * Copyright (C) 2013 Marcus Hirt * www.hirt.se * * This software is free: * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESSED OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * Copyright (C) Marcus Hirt, 2013 */ package se.hirt.pi.adafruitlcd.demo; /** * Scrolls the view area back and forth a few times. Check out the documentation * for the HD44780 for more info on how the tiny (DDRAM) buffer is handled. * * @author Marcus Hirt */ public class ScrollTest implements LCDTest { @Override public String getName() { return "Scroller"; } @Override
// Path: photorama-raspberry-pi-lcd-keypad/src/main/java/se/hirt/pi/adafruitlcd/ILCD.java // public interface ILCD { // // void setText(String s) throws IOException; // // void setText(int row, String string) throws IOException; // // void setCursorPosition(int row, int column) throws IOException; // // void stop() throws IOException; // // void clear() throws IOException; // // void home() throws IOException; // // void setCursorEnabled(boolean enable) throws IOException; // // boolean isCursorEnabled(); // // void setDisplayEnabled(boolean enable) throws IOException; // // boolean isDisplayEnabled(); // // void setBlinkEnabled(boolean enable) throws IOException; // // boolean isBlinkEnabled(); // // void setBacklight(Color color) throws IOException; // // Color getBacklight() throws IOException; // // void scrollDisplay(Direction direction) throws IOException; // // void setTextFlowDirection(Direction direction) throws IOException; // // void setAutoScrollEnabled(boolean enable) throws IOException; // // boolean isAutoScrollEnabled(); // // boolean isButtonPressed(Button button) throws IOException; // // int buttonsPressedBitmask() throws IOException; // // } // // Path: photorama-raspberry-pi-lcd-keypad/src/main/java/se/hirt/pi/adafruitlcd/impl/RealLCD.java // public enum Direction { // LEFT, RIGHT; // } // Path: photorama-raspberry-pi-lcd-keypad/src/main/java/se/hirt/pi/adafruitlcd/demo/ScrollTest.java import java.io.IOException; import se.hirt.pi.adafruitlcd.ILCD; import se.hirt.pi.adafruitlcd.impl.RealLCD.Direction; /* * Copyright (C) 2013 Marcus Hirt * www.hirt.se * * This software is free: * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESSED OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * Copyright (C) Marcus Hirt, 2013 */ package se.hirt.pi.adafruitlcd.demo; /** * Scrolls the view area back and forth a few times. Check out the documentation * for the HD44780 for more info on how the tiny (DDRAM) buffer is handled. * * @author Marcus Hirt */ public class ScrollTest implements LCDTest { @Override public String getName() { return "Scroller"; } @Override
public void run(ILCD lcd) throws IOException {
onebeartoe/photorama
photorama-raspberry-pi-lcd-keypad/src/main/java/se/hirt/pi/adafruitlcd/demo/ScrollTest.java
// Path: photorama-raspberry-pi-lcd-keypad/src/main/java/se/hirt/pi/adafruitlcd/ILCD.java // public interface ILCD { // // void setText(String s) throws IOException; // // void setText(int row, String string) throws IOException; // // void setCursorPosition(int row, int column) throws IOException; // // void stop() throws IOException; // // void clear() throws IOException; // // void home() throws IOException; // // void setCursorEnabled(boolean enable) throws IOException; // // boolean isCursorEnabled(); // // void setDisplayEnabled(boolean enable) throws IOException; // // boolean isDisplayEnabled(); // // void setBlinkEnabled(boolean enable) throws IOException; // // boolean isBlinkEnabled(); // // void setBacklight(Color color) throws IOException; // // Color getBacklight() throws IOException; // // void scrollDisplay(Direction direction) throws IOException; // // void setTextFlowDirection(Direction direction) throws IOException; // // void setAutoScrollEnabled(boolean enable) throws IOException; // // boolean isAutoScrollEnabled(); // // boolean isButtonPressed(Button button) throws IOException; // // int buttonsPressedBitmask() throws IOException; // // } // // Path: photorama-raspberry-pi-lcd-keypad/src/main/java/se/hirt/pi/adafruitlcd/impl/RealLCD.java // public enum Direction { // LEFT, RIGHT; // }
import java.io.IOException; import se.hirt.pi.adafruitlcd.ILCD; import se.hirt.pi.adafruitlcd.impl.RealLCD.Direction;
/* * Copyright (C) 2013 Marcus Hirt * www.hirt.se * * This software is free: * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESSED OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * Copyright (C) Marcus Hirt, 2013 */ package se.hirt.pi.adafruitlcd.demo; /** * Scrolls the view area back and forth a few times. Check out the documentation * for the HD44780 for more info on how the tiny (DDRAM) buffer is handled. * * @author Marcus Hirt */ public class ScrollTest implements LCDTest { @Override public String getName() { return "Scroller"; } @Override public void run(ILCD lcd) throws IOException { String message = "Running scroller. Be patient!\nBouncing this scroller once."; lcd.setText(message); for (int i = 0; i < 24; i++) { Util.sleep(100);
// Path: photorama-raspberry-pi-lcd-keypad/src/main/java/se/hirt/pi/adafruitlcd/ILCD.java // public interface ILCD { // // void setText(String s) throws IOException; // // void setText(int row, String string) throws IOException; // // void setCursorPosition(int row, int column) throws IOException; // // void stop() throws IOException; // // void clear() throws IOException; // // void home() throws IOException; // // void setCursorEnabled(boolean enable) throws IOException; // // boolean isCursorEnabled(); // // void setDisplayEnabled(boolean enable) throws IOException; // // boolean isDisplayEnabled(); // // void setBlinkEnabled(boolean enable) throws IOException; // // boolean isBlinkEnabled(); // // void setBacklight(Color color) throws IOException; // // Color getBacklight() throws IOException; // // void scrollDisplay(Direction direction) throws IOException; // // void setTextFlowDirection(Direction direction) throws IOException; // // void setAutoScrollEnabled(boolean enable) throws IOException; // // boolean isAutoScrollEnabled(); // // boolean isButtonPressed(Button button) throws IOException; // // int buttonsPressedBitmask() throws IOException; // // } // // Path: photorama-raspberry-pi-lcd-keypad/src/main/java/se/hirt/pi/adafruitlcd/impl/RealLCD.java // public enum Direction { // LEFT, RIGHT; // } // Path: photorama-raspberry-pi-lcd-keypad/src/main/java/se/hirt/pi/adafruitlcd/demo/ScrollTest.java import java.io.IOException; import se.hirt.pi.adafruitlcd.ILCD; import se.hirt.pi.adafruitlcd.impl.RealLCD.Direction; /* * Copyright (C) 2013 Marcus Hirt * www.hirt.se * * This software is free: * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESSED OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * Copyright (C) Marcus Hirt, 2013 */ package se.hirt.pi.adafruitlcd.demo; /** * Scrolls the view area back and forth a few times. Check out the documentation * for the HD44780 for more info on how the tiny (DDRAM) buffer is handled. * * @author Marcus Hirt */ public class ScrollTest implements LCDTest { @Override public String getName() { return "Scroller"; } @Override public void run(ILCD lcd) throws IOException { String message = "Running scroller. Be patient!\nBouncing this scroller once."; lcd.setText(message); for (int i = 0; i < 24; i++) { Util.sleep(100);
lcd.scrollDisplay(Direction.LEFT);
onebeartoe/photorama
photorama-model/src/main/java/org/onebeartoe/electronics/photorama/states/RootState.java
// Path: photorama-model/src/main/java/org/onebeartoe/electronics/photorama/Camera.java // public abstract class Camera // { // protected PhotoramaModes mode; // // protected String outputPath; // // protected TimeLapseConfiguration configuration; // // protected boolean timeLapseOn; // // public PhotoramaModes getMode() // { // return mode; // } // // public String getOutputPath() // { // return outputPath; // } // // public abstract long getTimelapse(); // // public FrequencyUnits getTimelapseUnit() // { // return configuration.unit; // } // // public void setMode(PhotoramaModes mode) // { // this.mode = mode; // // stopTimelapse(); // } // // /** // * Make sure the path has a path separator character at the end. // * @param path // */ // public void setOutputPath(String path) throws Exception // { // File outdir = new File(path); // // if( ! outdir.exists() ) // { // // the output directory does not exist, // // try creating it // boolean dirCreated = outdir.mkdirs(); // // if( !dirCreated ) // { // String message = "could not set output directory: " + path; // // throw new Exception(message); // } // } // // outputPath = path; // } // // public void setTimelapse(long delay, FrequencyUnits unit) // { // configuration.delay = delay; // configuration.unit = unit; // // if(timeLapseOn) // { // startTimelapse(); // } // } // // public abstract void startTimelapse(); // // public abstract void stopTimelapse(); // // public abstract void takeSnapshot(); // }
import org.onebeartoe.electronics.photorama.Camera;
package org.onebeartoe.electronics.photorama.states; /** * @author Roberto Marquez */ public class RootState implements PhotoramaState { protected PhotoramaState upState; protected PhotoramaState downState; protected PhotoramaState leftState; protected PhotoramaState rightState; protected PhotoramaState selectState; protected String label = "no label"; protected String value = "no value";
// Path: photorama-model/src/main/java/org/onebeartoe/electronics/photorama/Camera.java // public abstract class Camera // { // protected PhotoramaModes mode; // // protected String outputPath; // // protected TimeLapseConfiguration configuration; // // protected boolean timeLapseOn; // // public PhotoramaModes getMode() // { // return mode; // } // // public String getOutputPath() // { // return outputPath; // } // // public abstract long getTimelapse(); // // public FrequencyUnits getTimelapseUnit() // { // return configuration.unit; // } // // public void setMode(PhotoramaModes mode) // { // this.mode = mode; // // stopTimelapse(); // } // // /** // * Make sure the path has a path separator character at the end. // * @param path // */ // public void setOutputPath(String path) throws Exception // { // File outdir = new File(path); // // if( ! outdir.exists() ) // { // // the output directory does not exist, // // try creating it // boolean dirCreated = outdir.mkdirs(); // // if( !dirCreated ) // { // String message = "could not set output directory: " + path; // // throw new Exception(message); // } // } // // outputPath = path; // } // // public void setTimelapse(long delay, FrequencyUnits unit) // { // configuration.delay = delay; // configuration.unit = unit; // // if(timeLapseOn) // { // startTimelapse(); // } // } // // public abstract void startTimelapse(); // // public abstract void stopTimelapse(); // // public abstract void takeSnapshot(); // } // Path: photorama-model/src/main/java/org/onebeartoe/electronics/photorama/states/RootState.java import org.onebeartoe.electronics.photorama.Camera; package org.onebeartoe.electronics.photorama.states; /** * @author Roberto Marquez */ public class RootState implements PhotoramaState { protected PhotoramaState upState; protected PhotoramaState downState; protected PhotoramaState leftState; protected PhotoramaState rightState; protected PhotoramaState selectState; protected String label = "no label"; protected String value = "no value";
static protected Camera camera;
onebeartoe/photorama
photorama-model/src/main/java/org/onebeartoe/electronics/photorama/mock/MockCamera.java
// Path: photorama-model/src/main/java/org/onebeartoe/electronics/photorama/Camera.java // public abstract class Camera // { // protected PhotoramaModes mode; // // protected String outputPath; // // protected TimeLapseConfiguration configuration; // // protected boolean timeLapseOn; // // public PhotoramaModes getMode() // { // return mode; // } // // public String getOutputPath() // { // return outputPath; // } // // public abstract long getTimelapse(); // // public FrequencyUnits getTimelapseUnit() // { // return configuration.unit; // } // // public void setMode(PhotoramaModes mode) // { // this.mode = mode; // // stopTimelapse(); // } // // /** // * Make sure the path has a path separator character at the end. // * @param path // */ // public void setOutputPath(String path) throws Exception // { // File outdir = new File(path); // // if( ! outdir.exists() ) // { // // the output directory does not exist, // // try creating it // boolean dirCreated = outdir.mkdirs(); // // if( !dirCreated ) // { // String message = "could not set output directory: " + path; // // throw new Exception(message); // } // } // // outputPath = path; // } // // public void setTimelapse(long delay, FrequencyUnits unit) // { // configuration.delay = delay; // configuration.unit = unit; // // if(timeLapseOn) // { // startTimelapse(); // } // } // // public abstract void startTimelapse(); // // public abstract void stopTimelapse(); // // public abstract void takeSnapshot(); // } // // Path: photorama-model/src/main/java/org/onebeartoe/electronics/photorama/TimeLapseConfiguration.java // public class TimeLapseConfiguration // { // public long delay; // // public File outputDirectory; // // public FrequencyUnits unit; // }
import java.util.logging.Level; import java.util.logging.Logger; import org.onebeartoe.electronics.photorama.Camera; import org.onebeartoe.electronics.photorama.TimeLapseConfiguration;
package org.onebeartoe.electronics.photorama.mock; /** * @author Roberto Marquez */ public class MockCamera extends Camera { private Logger logger; public MockCamera() { logger = Logger.getLogger( getClass().getName() );
// Path: photorama-model/src/main/java/org/onebeartoe/electronics/photorama/Camera.java // public abstract class Camera // { // protected PhotoramaModes mode; // // protected String outputPath; // // protected TimeLapseConfiguration configuration; // // protected boolean timeLapseOn; // // public PhotoramaModes getMode() // { // return mode; // } // // public String getOutputPath() // { // return outputPath; // } // // public abstract long getTimelapse(); // // public FrequencyUnits getTimelapseUnit() // { // return configuration.unit; // } // // public void setMode(PhotoramaModes mode) // { // this.mode = mode; // // stopTimelapse(); // } // // /** // * Make sure the path has a path separator character at the end. // * @param path // */ // public void setOutputPath(String path) throws Exception // { // File outdir = new File(path); // // if( ! outdir.exists() ) // { // // the output directory does not exist, // // try creating it // boolean dirCreated = outdir.mkdirs(); // // if( !dirCreated ) // { // String message = "could not set output directory: " + path; // // throw new Exception(message); // } // } // // outputPath = path; // } // // public void setTimelapse(long delay, FrequencyUnits unit) // { // configuration.delay = delay; // configuration.unit = unit; // // if(timeLapseOn) // { // startTimelapse(); // } // } // // public abstract void startTimelapse(); // // public abstract void stopTimelapse(); // // public abstract void takeSnapshot(); // } // // Path: photorama-model/src/main/java/org/onebeartoe/electronics/photorama/TimeLapseConfiguration.java // public class TimeLapseConfiguration // { // public long delay; // // public File outputDirectory; // // public FrequencyUnits unit; // } // Path: photorama-model/src/main/java/org/onebeartoe/electronics/photorama/mock/MockCamera.java import java.util.logging.Level; import java.util.logging.Logger; import org.onebeartoe.electronics.photorama.Camera; import org.onebeartoe.electronics.photorama.TimeLapseConfiguration; package org.onebeartoe.electronics.photorama.mock; /** * @author Roberto Marquez */ public class MockCamera extends Camera { private Logger logger; public MockCamera() { logger = Logger.getLogger( getClass().getName() );
configuration = new TimeLapseConfiguration();
52North/geoar-app
src/main/java/org/n52/geoar/ar/view/IntroViewer.java
// Path: src/main/java/org/n52/geoar/ar/view/IntroController.java // public static class Task implements Comparable<Task> { // protected int index; // // protected boolean completed = false; // protected boolean refreshPopupOnShow = false; // // protected int id; // protected int description; // // protected int bitmapResource; // protected View view; // // public Task(int index, int title, int description, int bitmapResource, // boolean refreshOnPopup) { // this.index = index; // this.id = title; // this.description = description; // this.bitmapResource = bitmapResource; // this.refreshPopupOnShow = refreshOnPopup; // } // // @Override // public int compareTo(Task another) { // return this.index > another.index ? 1 : -1; // } // }
import org.n52.geoar.R; import org.n52.geoar.ar.view.IntroController.Task; import android.app.Activity; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; import android.graphics.PorterDuff.Mode; import android.graphics.PorterDuffXfermode; import android.graphics.RadialGradient; import android.graphics.Rect; import android.graphics.RectF; import android.graphics.Shader; import android.graphics.drawable.Drawable; import android.view.LayoutInflater; import android.view.MotionEvent; import android.view.View; import android.widget.ImageView; import android.widget.RelativeLayout; import android.widget.TextView;
/** * Copyright 2012 52°North Initiative for Geospatial Open Source Software GmbH * * 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 org.n52.geoar.ar.view; /** * * @author Arne de Wall <a.dewall@52North.org> * */ public class IntroViewer extends RelativeLayout implements View.OnTouchListener { private Activity activity;
// Path: src/main/java/org/n52/geoar/ar/view/IntroController.java // public static class Task implements Comparable<Task> { // protected int index; // // protected boolean completed = false; // protected boolean refreshPopupOnShow = false; // // protected int id; // protected int description; // // protected int bitmapResource; // protected View view; // // public Task(int index, int title, int description, int bitmapResource, // boolean refreshOnPopup) { // this.index = index; // this.id = title; // this.description = description; // this.bitmapResource = bitmapResource; // this.refreshPopupOnShow = refreshOnPopup; // } // // @Override // public int compareTo(Task another) { // return this.index > another.index ? 1 : -1; // } // } // Path: src/main/java/org/n52/geoar/ar/view/IntroViewer.java import org.n52.geoar.R; import org.n52.geoar.ar.view.IntroController.Task; import android.app.Activity; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; import android.graphics.PorterDuff.Mode; import android.graphics.PorterDuffXfermode; import android.graphics.RadialGradient; import android.graphics.Rect; import android.graphics.RectF; import android.graphics.Shader; import android.graphics.drawable.Drawable; import android.view.LayoutInflater; import android.view.MotionEvent; import android.view.View; import android.widget.ImageView; import android.widget.RelativeLayout; import android.widget.TextView; /** * Copyright 2012 52°North Initiative for Geospatial Open Source Software GmbH * * 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 org.n52.geoar.ar.view; /** * * @author Arne de Wall <a.dewall@52North.org> * */ public class IntroViewer extends RelativeLayout implements View.OnTouchListener { private Activity activity;
private Task currentStep;
52North/geoar-app
src/main/java/org/n52/geoar/ar/view/gl/GLESCamera.java
// Path: src/main/java/org/n52/geoar/tracking/camera/RealityCamera.java // public class RealityCamera { // private static final String CAMERA_HEIGHT_PREF = "cameraHeight"; // // public interface CameraUpdateListener { // void onCameraUpdate(); // } // // public static float height = 1.6f; // "usage height", distance between // // ground and device // public static float fovY = 42.5f; // // Viewport of camera preview // public static int cameraViewportWidth; // public static int cameraViewportHeight; // private static boolean hasViewportSize = false; // // private static List<CameraUpdateListener> listeners = new ArrayList<CameraUpdateListener>(); // public static float aspect; // // public static void addCameraUpdateListener(CameraUpdateListener listener) { // listeners.add(listener); // } // // public static void removeCameraUpdateListener(CameraUpdateListener listener) { // listeners.remove(listener); // } // // private static void onUpdate() { // for (CameraUpdateListener listener : listeners) { // listener.onCameraUpdate(); // } // } // // public static void setFovY(float fov) { // boolean changed = RealityCamera.fovY != fov; // RealityCamera.fovY = fov; // if (changed) // onUpdate(); // } // // public static void setViewportSize(Size size) { // setViewportSize(size.width, size.height); // } // // public static void setViewportSize(int width, int height) { // boolean changed = cameraViewportHeight != height // || cameraViewportWidth != width; // cameraViewportHeight = height; // cameraViewportWidth = width; // RealityCamera.aspect = width / (float) height; // hasViewportSize = true; // if (changed) // onUpdate(); // } // // public static boolean hasViewportSize() { // return hasViewportSize; // } // // @Deprecated // public static void setAspect(float aspect) { // // RealityCamera.aspect = aspect; // } // // public static void changeHeight(float inc) { // height += inc; // onUpdate(); // } // // public static void setHeight(float height) { // RealityCamera.height = height; // onUpdate(); // } // // public static void saveState() { // SharedPreferences preferences = GeoARApplication.applicationContext // .getSharedPreferences(GeoARApplication.PREFERENCES_FILE, // Context.MODE_PRIVATE); // Editor editor = preferences.edit(); // editor.putFloat(CAMERA_HEIGHT_PREF, RealityCamera.height); // editor.commit(); // } // // public static void restoreState() { // SharedPreferences prefs = GeoARApplication.applicationContext // .getSharedPreferences(GeoARApplication.PREFERENCES_FILE, // Context.MODE_PRIVATE); // RealityCamera.setHeight(prefs.getFloat(CAMERA_HEIGHT_PREF, 1.6f)); // } // } // // Path: src/main/java/org/n52/geoar/view/geoar/Settings.java // public class Settings { // // // AR view settings // // Radius in meters for the interpolation in AR view // public static final int SIZE_AR_INTERPOLATION = 1500; // // Threshold in position to request new interpolation // public static final int RELOAD_DIST_AR = 50; // // Zoom used in AR view for interpolation, please make sure it fits somehow // // with SIZE_AR_INTERPOLATION... // public static final byte ZOOM_AR = 12; // // // Buffer in px to request in advance around map extent // public static final int BUFFER_MAPINTERPOLATION = 100; // // }
import java.util.Arrays; import org.n52.geoar.tracking.camera.RealityCamera; import org.n52.geoar.view.geoar.Settings; import android.opengl.Matrix;
// m[4] = sy; // m[5] = uy; // m[6] = -fy; // m[7] = 0.0f; // // m[8] = sz; // m[9] = uz; // m[10] = -fz; // m[11] = 0.0f; // // m[12] = 0.0f; // m[13] = 0.0f; // m[14] = 0.0f; // m[15] = 1.0f; // // // Matrix.m // // gl.glMultMatrixf(m, 0); // // gl.glTranslatef(-eyeX, -eyeY, -eyeZ); // } public static boolean pointInFrustum(float[] p) { for (int i = 0; i < frustumPlanes.length; i++) { if (!frustumPlanes[i].isOutside(p)) return false; } return true; } public static void resetProjectionMatrix() { Matrix.setIdentityM(projectionMatrix, 0);
// Path: src/main/java/org/n52/geoar/tracking/camera/RealityCamera.java // public class RealityCamera { // private static final String CAMERA_HEIGHT_PREF = "cameraHeight"; // // public interface CameraUpdateListener { // void onCameraUpdate(); // } // // public static float height = 1.6f; // "usage height", distance between // // ground and device // public static float fovY = 42.5f; // // Viewport of camera preview // public static int cameraViewportWidth; // public static int cameraViewportHeight; // private static boolean hasViewportSize = false; // // private static List<CameraUpdateListener> listeners = new ArrayList<CameraUpdateListener>(); // public static float aspect; // // public static void addCameraUpdateListener(CameraUpdateListener listener) { // listeners.add(listener); // } // // public static void removeCameraUpdateListener(CameraUpdateListener listener) { // listeners.remove(listener); // } // // private static void onUpdate() { // for (CameraUpdateListener listener : listeners) { // listener.onCameraUpdate(); // } // } // // public static void setFovY(float fov) { // boolean changed = RealityCamera.fovY != fov; // RealityCamera.fovY = fov; // if (changed) // onUpdate(); // } // // public static void setViewportSize(Size size) { // setViewportSize(size.width, size.height); // } // // public static void setViewportSize(int width, int height) { // boolean changed = cameraViewportHeight != height // || cameraViewportWidth != width; // cameraViewportHeight = height; // cameraViewportWidth = width; // RealityCamera.aspect = width / (float) height; // hasViewportSize = true; // if (changed) // onUpdate(); // } // // public static boolean hasViewportSize() { // return hasViewportSize; // } // // @Deprecated // public static void setAspect(float aspect) { // // RealityCamera.aspect = aspect; // } // // public static void changeHeight(float inc) { // height += inc; // onUpdate(); // } // // public static void setHeight(float height) { // RealityCamera.height = height; // onUpdate(); // } // // public static void saveState() { // SharedPreferences preferences = GeoARApplication.applicationContext // .getSharedPreferences(GeoARApplication.PREFERENCES_FILE, // Context.MODE_PRIVATE); // Editor editor = preferences.edit(); // editor.putFloat(CAMERA_HEIGHT_PREF, RealityCamera.height); // editor.commit(); // } // // public static void restoreState() { // SharedPreferences prefs = GeoARApplication.applicationContext // .getSharedPreferences(GeoARApplication.PREFERENCES_FILE, // Context.MODE_PRIVATE); // RealityCamera.setHeight(prefs.getFloat(CAMERA_HEIGHT_PREF, 1.6f)); // } // } // // Path: src/main/java/org/n52/geoar/view/geoar/Settings.java // public class Settings { // // // AR view settings // // Radius in meters for the interpolation in AR view // public static final int SIZE_AR_INTERPOLATION = 1500; // // Threshold in position to request new interpolation // public static final int RELOAD_DIST_AR = 50; // // Zoom used in AR view for interpolation, please make sure it fits somehow // // with SIZE_AR_INTERPOLATION... // public static final byte ZOOM_AR = 12; // // // Buffer in px to request in advance around map extent // public static final int BUFFER_MAPINTERPOLATION = 100; // // } // Path: src/main/java/org/n52/geoar/ar/view/gl/GLESCamera.java import java.util.Arrays; import org.n52.geoar.tracking.camera.RealityCamera; import org.n52.geoar.view.geoar.Settings; import android.opengl.Matrix; // m[4] = sy; // m[5] = uy; // m[6] = -fy; // m[7] = 0.0f; // // m[8] = sz; // m[9] = uz; // m[10] = -fz; // m[11] = 0.0f; // // m[12] = 0.0f; // m[13] = 0.0f; // m[14] = 0.0f; // m[15] = 1.0f; // // // Matrix.m // // gl.glMultMatrixf(m, 0); // // gl.glTranslatef(-eyeX, -eyeY, -eyeZ); // } public static boolean pointInFrustum(float[] p) { for (int i = 0; i < frustumPlanes.length; i++) { if (!frustumPlanes[i].isOutside(p)) return false; } return true; } public static void resetProjectionMatrix() { Matrix.setIdentityM(projectionMatrix, 0);
perspectiveMatrix(projectionMatrix, 0, RealityCamera.fovY,
52North/geoar-app
src/main/java/org/n52/geoar/ar/view/gl/SurfaceTopology.java
// Path: src/main/java/org/n52/geoar/tracking/camera/RealityCamera.java // public class RealityCamera { // private static final String CAMERA_HEIGHT_PREF = "cameraHeight"; // // public interface CameraUpdateListener { // void onCameraUpdate(); // } // // public static float height = 1.6f; // "usage height", distance between // // ground and device // public static float fovY = 42.5f; // // Viewport of camera preview // public static int cameraViewportWidth; // public static int cameraViewportHeight; // private static boolean hasViewportSize = false; // // private static List<CameraUpdateListener> listeners = new ArrayList<CameraUpdateListener>(); // public static float aspect; // // public static void addCameraUpdateListener(CameraUpdateListener listener) { // listeners.add(listener); // } // // public static void removeCameraUpdateListener(CameraUpdateListener listener) { // listeners.remove(listener); // } // // private static void onUpdate() { // for (CameraUpdateListener listener : listeners) { // listener.onCameraUpdate(); // } // } // // public static void setFovY(float fov) { // boolean changed = RealityCamera.fovY != fov; // RealityCamera.fovY = fov; // if (changed) // onUpdate(); // } // // public static void setViewportSize(Size size) { // setViewportSize(size.width, size.height); // } // // public static void setViewportSize(int width, int height) { // boolean changed = cameraViewportHeight != height // || cameraViewportWidth != width; // cameraViewportHeight = height; // cameraViewportWidth = width; // RealityCamera.aspect = width / (float) height; // hasViewportSize = true; // if (changed) // onUpdate(); // } // // public static boolean hasViewportSize() { // return hasViewportSize; // } // // @Deprecated // public static void setAspect(float aspect) { // // RealityCamera.aspect = aspect; // } // // public static void changeHeight(float inc) { // height += inc; // onUpdate(); // } // // public static void setHeight(float height) { // RealityCamera.height = height; // onUpdate(); // } // // public static void saveState() { // SharedPreferences preferences = GeoARApplication.applicationContext // .getSharedPreferences(GeoARApplication.PREFERENCES_FILE, // Context.MODE_PRIVATE); // Editor editor = preferences.edit(); // editor.putFloat(CAMERA_HEIGHT_PREF, RealityCamera.height); // editor.commit(); // } // // public static void restoreState() { // SharedPreferences prefs = GeoARApplication.applicationContext // .getSharedPreferences(GeoARApplication.PREFERENCES_FILE, // Context.MODE_PRIVATE); // RealityCamera.setHeight(prefs.getFloat(CAMERA_HEIGHT_PREF, 1.6f)); // } // }
import org.n52.geoar.tracking.camera.RealityCamera; import android.opengl.Matrix;
/** * Copyright 2012 52°North Initiative for Geospatial Open Source Software GmbH * * 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 org.n52.geoar.ar.view.gl; public class SurfaceTopology { protected abstract class TopologyFunction{ abstract float getHeightValue(float x, float z); } private TopologyFunction topology;
// Path: src/main/java/org/n52/geoar/tracking/camera/RealityCamera.java // public class RealityCamera { // private static final String CAMERA_HEIGHT_PREF = "cameraHeight"; // // public interface CameraUpdateListener { // void onCameraUpdate(); // } // // public static float height = 1.6f; // "usage height", distance between // // ground and device // public static float fovY = 42.5f; // // Viewport of camera preview // public static int cameraViewportWidth; // public static int cameraViewportHeight; // private static boolean hasViewportSize = false; // // private static List<CameraUpdateListener> listeners = new ArrayList<CameraUpdateListener>(); // public static float aspect; // // public static void addCameraUpdateListener(CameraUpdateListener listener) { // listeners.add(listener); // } // // public static void removeCameraUpdateListener(CameraUpdateListener listener) { // listeners.remove(listener); // } // // private static void onUpdate() { // for (CameraUpdateListener listener : listeners) { // listener.onCameraUpdate(); // } // } // // public static void setFovY(float fov) { // boolean changed = RealityCamera.fovY != fov; // RealityCamera.fovY = fov; // if (changed) // onUpdate(); // } // // public static void setViewportSize(Size size) { // setViewportSize(size.width, size.height); // } // // public static void setViewportSize(int width, int height) { // boolean changed = cameraViewportHeight != height // || cameraViewportWidth != width; // cameraViewportHeight = height; // cameraViewportWidth = width; // RealityCamera.aspect = width / (float) height; // hasViewportSize = true; // if (changed) // onUpdate(); // } // // public static boolean hasViewportSize() { // return hasViewportSize; // } // // @Deprecated // public static void setAspect(float aspect) { // // RealityCamera.aspect = aspect; // } // // public static void changeHeight(float inc) { // height += inc; // onUpdate(); // } // // public static void setHeight(float height) { // RealityCamera.height = height; // onUpdate(); // } // // public static void saveState() { // SharedPreferences preferences = GeoARApplication.applicationContext // .getSharedPreferences(GeoARApplication.PREFERENCES_FILE, // Context.MODE_PRIVATE); // Editor editor = preferences.edit(); // editor.putFloat(CAMERA_HEIGHT_PREF, RealityCamera.height); // editor.commit(); // } // // public static void restoreState() { // SharedPreferences prefs = GeoARApplication.applicationContext // .getSharedPreferences(GeoARApplication.PREFERENCES_FILE, // Context.MODE_PRIVATE); // RealityCamera.setHeight(prefs.getFloat(CAMERA_HEIGHT_PREF, 1.6f)); // } // } // Path: src/main/java/org/n52/geoar/ar/view/gl/SurfaceTopology.java import org.n52.geoar.tracking.camera.RealityCamera; import android.opengl.Matrix; /** * Copyright 2012 52°North Initiative for Geospatial Open Source Software GmbH * * 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 org.n52.geoar.ar.view.gl; public class SurfaceTopology { protected abstract class TopologyFunction{ abstract float getHeightValue(float x, float z); } private TopologyFunction topology;
private float cameraLandOffset = RealityCamera.height;
52North/geoar-app
src/main/java/org/n52/geoar/GeoARApplication.java
// Path: src/main/java/org/n52/geoar/newdata/PluginLogger.java // public class PluginLogger implements DataSourceLoggerFactory.Logger { // // private org.slf4j.Logger logger; // // public PluginLogger(PluginHolder plugin, Class<?> clazz) { // logger = LoggerFactory.getLogger(plugin.getIdentifier() + "-" // + clazz.getSimpleName()); // } // // public PluginLogger(Class<?> clazz) { // logger = LoggerFactory.getLogger(clazz); // } // // @Override // public void warn(String message) { // logger.warn(message); // } // // @Override // public void error(String message) { // logger.error(message); // } // // @Override // public void info(String message) { // logger.info(message); // } // // @Override // public void warn(String message, Throwable ex) { // logger.warn(message, ex); // } // // @Override // public void error(String message, Throwable ex) { // logger.error(message, ex); // } // // @Override // public void info(String message, Throwable ex) { // logger.info(message, ex); // } // // }
import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintStream; import java.lang.Thread.UncaughtExceptionHandler; import java.util.ArrayList; import java.util.List; import org.n52.geoar.utils.DataSourceLoggerFactory; import org.n52.geoar.utils.DataSourceLoggerFactory.LoggerCallable; import org.n52.geoar.newdata.PluginLogger; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import android.app.Activity; import android.app.Application; import android.content.ActivityNotFoundException; import android.content.Context; import android.content.Intent; import android.net.Uri; import android.widget.Toast;
Thread.setDefaultUncaughtExceptionHandler(new UncaughtExceptionHandler() { @Override public void uncaughtException(Thread thread, Throwable ex) { LOG.error("Uncaught exception in thread " + thread.getName(), ex); try { FileOutputStream fos = openFileOutput(STACKTRACE_FILENAME, Context.MODE_PRIVATE); ex.printStackTrace(new PrintStream(fos)); fos.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } // fall back to standard handler if (defaultUncaughtExceptionHandler != null) { defaultUncaughtExceptionHandler.uncaughtException(thread, ex); } } }); // ensure that plugins can access the main logger DataSourceLoggerFactory.setLoggerCallable(new LoggerCallable() { @Override public org.n52.geoar.utils.DataSourceLoggerFactory.Logger call( Class<?> clazz) {
// Path: src/main/java/org/n52/geoar/newdata/PluginLogger.java // public class PluginLogger implements DataSourceLoggerFactory.Logger { // // private org.slf4j.Logger logger; // // public PluginLogger(PluginHolder plugin, Class<?> clazz) { // logger = LoggerFactory.getLogger(plugin.getIdentifier() + "-" // + clazz.getSimpleName()); // } // // public PluginLogger(Class<?> clazz) { // logger = LoggerFactory.getLogger(clazz); // } // // @Override // public void warn(String message) { // logger.warn(message); // } // // @Override // public void error(String message) { // logger.error(message); // } // // @Override // public void info(String message) { // logger.info(message); // } // // @Override // public void warn(String message, Throwable ex) { // logger.warn(message, ex); // } // // @Override // public void error(String message, Throwable ex) { // logger.error(message, ex); // } // // @Override // public void info(String message, Throwable ex) { // logger.info(message, ex); // } // // } // Path: src/main/java/org/n52/geoar/GeoARApplication.java import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintStream; import java.lang.Thread.UncaughtExceptionHandler; import java.util.ArrayList; import java.util.List; import org.n52.geoar.utils.DataSourceLoggerFactory; import org.n52.geoar.utils.DataSourceLoggerFactory.LoggerCallable; import org.n52.geoar.newdata.PluginLogger; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import android.app.Activity; import android.app.Application; import android.content.ActivityNotFoundException; import android.content.Context; import android.content.Intent; import android.net.Uri; import android.widget.Toast; Thread.setDefaultUncaughtExceptionHandler(new UncaughtExceptionHandler() { @Override public void uncaughtException(Thread thread, Throwable ex) { LOG.error("Uncaught exception in thread " + thread.getName(), ex); try { FileOutputStream fos = openFileOutput(STACKTRACE_FILENAME, Context.MODE_PRIVATE); ex.printStackTrace(new PrintStream(fos)); fos.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } // fall back to standard handler if (defaultUncaughtExceptionHandler != null) { defaultUncaughtExceptionHandler.uncaughtException(thread, ex); } } }); // ensure that plugins can access the main logger DataSourceLoggerFactory.setLoggerCallable(new LoggerCallable() { @Override public org.n52.geoar.utils.DataSourceLoggerFactory.Logger call( Class<?> clazz) {
return new PluginLogger(clazz);
52North/geoar-app
src/main/java/org/n52/geoar/map/view/overlay/DataSourceOverlay.java
// Path: src/main/java/org/n52/geoar/map/view/overlay/DataSourcesOverlay.java // public interface OnOverlayItemTapListener { // boolean onOverlayItemTap(OverlayType<? extends Geometry> item); // }
import java.util.List; import org.mapsforge.android.maps.Projection; import org.mapsforge.android.maps.overlay.Overlay; import org.n52.geoar.map.view.overlay.DataSourcesOverlay.OnOverlayItemTapListener; import android.graphics.Canvas; import android.graphics.Point; import com.vividsolutions.jts.geom.Geometry; import com.vividsolutions.jts.geom.GeometryFactory;
/** * Copyright 2012 52°North Initiative for Geospatial Open Source Software GmbH * * 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 org.n52.geoar.map.view.overlay; /** * * @author Arne de Wall <a.dewall@52North.org> * */ public abstract class DataSourceOverlay<G extends Geometry, T extends OverlayType<G>> extends Overlay { protected static final GeometryFactory FACTORY = new GeometryFactory();
// Path: src/main/java/org/n52/geoar/map/view/overlay/DataSourcesOverlay.java // public interface OnOverlayItemTapListener { // boolean onOverlayItemTap(OverlayType<? extends Geometry> item); // } // Path: src/main/java/org/n52/geoar/map/view/overlay/DataSourceOverlay.java import java.util.List; import org.mapsforge.android.maps.Projection; import org.mapsforge.android.maps.overlay.Overlay; import org.n52.geoar.map.view.overlay.DataSourcesOverlay.OnOverlayItemTapListener; import android.graphics.Canvas; import android.graphics.Point; import com.vividsolutions.jts.geom.Geometry; import com.vividsolutions.jts.geom.GeometryFactory; /** * Copyright 2012 52°North Initiative for Geospatial Open Source Software GmbH * * 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 org.n52.geoar.map.view.overlay; /** * * @author Arne de Wall <a.dewall@52North.org> * */ public abstract class DataSourceOverlay<G extends Geometry, T extends OverlayType<G>> extends Overlay { protected static final GeometryFactory FACTORY = new GeometryFactory();
protected OnOverlayItemTapListener overlayItemTapListener;
apollo-rsps/apollo
game/src/main/java/org/apollo/game/release/r377/SpamPacketMessageDecoder.java
// Path: net/src/main/java/org/apollo/net/codec/game/GamePacket.java // public final class GamePacket extends DefaultByteBufHolder { // // /** // * The length. // */ // private final int length; // // /** // * The opcode. // */ // private final int opcode; // // /** // * The packet type. // */ // private final PacketType type; // // /** // * Creates the game packet. // * // * @param opcode The opcode. // * @param type The packet type. // * @param payload The payload. // */ // public GamePacket(int opcode, PacketType type, ByteBuf payload) { // super(payload); // this.opcode = opcode; // this.type = type; // length = payload.readableBytes(); // } // // /** // * Gets the payload length. // * // * @return The payload length. // */ // public int getLength() { // return length; // } // // /** // * Gets the opcode. // * // * @return The opcode. // */ // public int getOpcode() { // return opcode; // } // // /** // * Gets the packet type. // * // * @return The packet type. // */ // public PacketType getType() { // return type; // } // // }
import org.apollo.game.message.impl.SpamPacketMessage; import org.apollo.net.codec.game.GamePacket; import org.apollo.net.release.MessageDecoder;
package org.apollo.game.release.r377; /** * A {@link MessageDecoder} for the {@link SpamPacketMessage}. * * @author Major */ public final class SpamPacketMessageDecoder extends MessageDecoder<SpamPacketMessage> { @Override
// Path: net/src/main/java/org/apollo/net/codec/game/GamePacket.java // public final class GamePacket extends DefaultByteBufHolder { // // /** // * The length. // */ // private final int length; // // /** // * The opcode. // */ // private final int opcode; // // /** // * The packet type. // */ // private final PacketType type; // // /** // * Creates the game packet. // * // * @param opcode The opcode. // * @param type The packet type. // * @param payload The payload. // */ // public GamePacket(int opcode, PacketType type, ByteBuf payload) { // super(payload); // this.opcode = opcode; // this.type = type; // length = payload.readableBytes(); // } // // /** // * Gets the payload length. // * // * @return The payload length. // */ // public int getLength() { // return length; // } // // /** // * Gets the opcode. // * // * @return The opcode. // */ // public int getOpcode() { // return opcode; // } // // /** // * Gets the packet type. // * // * @return The packet type. // */ // public PacketType getType() { // return type; // } // // } // Path: game/src/main/java/org/apollo/game/release/r377/SpamPacketMessageDecoder.java import org.apollo.game.message.impl.SpamPacketMessage; import org.apollo.net.codec.game.GamePacket; import org.apollo.net.release.MessageDecoder; package org.apollo.game.release.r377; /** * A {@link MessageDecoder} for the {@link SpamPacketMessage}. * * @author Major */ public final class SpamPacketMessageDecoder extends MessageDecoder<SpamPacketMessage> { @Override
public SpamPacketMessage decode(GamePacket packet) {
apollo-rsps/apollo
game/src/main/java/org/apollo/game/release/r317/SpamPacketMessageDecoder.java
// Path: net/src/main/java/org/apollo/net/codec/game/GamePacket.java // public final class GamePacket extends DefaultByteBufHolder { // // /** // * The length. // */ // private final int length; // // /** // * The opcode. // */ // private final int opcode; // // /** // * The packet type. // */ // private final PacketType type; // // /** // * Creates the game packet. // * // * @param opcode The opcode. // * @param type The packet type. // * @param payload The payload. // */ // public GamePacket(int opcode, PacketType type, ByteBuf payload) { // super(payload); // this.opcode = opcode; // this.type = type; // length = payload.readableBytes(); // } // // /** // * Gets the payload length. // * // * @return The payload length. // */ // public int getLength() { // return length; // } // // /** // * Gets the opcode. // * // * @return The opcode. // */ // public int getOpcode() { // return opcode; // } // // /** // * Gets the packet type. // * // * @return The packet type. // */ // public PacketType getType() { // return type; // } // // }
import org.apollo.game.message.impl.SpamPacketMessage; import org.apollo.net.codec.game.GamePacket; import org.apollo.net.release.MessageDecoder;
package org.apollo.game.release.r317; /** * A {@link MessageDecoder} for the {@link SpamPacketMessage}. * * @author Major */ public final class SpamPacketMessageDecoder extends MessageDecoder<SpamPacketMessage> { @Override
// Path: net/src/main/java/org/apollo/net/codec/game/GamePacket.java // public final class GamePacket extends DefaultByteBufHolder { // // /** // * The length. // */ // private final int length; // // /** // * The opcode. // */ // private final int opcode; // // /** // * The packet type. // */ // private final PacketType type; // // /** // * Creates the game packet. // * // * @param opcode The opcode. // * @param type The packet type. // * @param payload The payload. // */ // public GamePacket(int opcode, PacketType type, ByteBuf payload) { // super(payload); // this.opcode = opcode; // this.type = type; // length = payload.readableBytes(); // } // // /** // * Gets the payload length. // * // * @return The payload length. // */ // public int getLength() { // return length; // } // // /** // * Gets the opcode. // * // * @return The opcode. // */ // public int getOpcode() { // return opcode; // } // // /** // * Gets the packet type. // * // * @return The packet type. // */ // public PacketType getType() { // return type; // } // // } // Path: game/src/main/java/org/apollo/game/release/r317/SpamPacketMessageDecoder.java import org.apollo.game.message.impl.SpamPacketMessage; import org.apollo.net.codec.game.GamePacket; import org.apollo.net.release.MessageDecoder; package org.apollo.game.release.r317; /** * A {@link MessageDecoder} for the {@link SpamPacketMessage}. * * @author Major */ public final class SpamPacketMessageDecoder extends MessageDecoder<SpamPacketMessage> { @Override
public SpamPacketMessage decode(GamePacket packet) {
apollo-rsps/apollo
game/src/main/java/org/apollo/game/release/r317/GroupedRegionUpdateMessageEncoder.java
// Path: net/src/main/java/org/apollo/net/codec/game/GamePacket.java // public final class GamePacket extends DefaultByteBufHolder { // // /** // * The length. // */ // private final int length; // // /** // * The opcode. // */ // private final int opcode; // // /** // * The packet type. // */ // private final PacketType type; // // /** // * Creates the game packet. // * // * @param opcode The opcode. // * @param type The packet type. // * @param payload The payload. // */ // public GamePacket(int opcode, PacketType type, ByteBuf payload) { // super(payload); // this.opcode = opcode; // this.type = type; // length = payload.readableBytes(); // } // // /** // * Gets the payload length. // * // * @return The payload length. // */ // public int getLength() { // return length; // } // // /** // * Gets the opcode. // * // * @return The opcode. // */ // public int getOpcode() { // return opcode; // } // // /** // * Gets the packet type. // * // * @return The packet type. // */ // public PacketType getType() { // return type; // } // // }
import org.apollo.game.message.impl.GroupedRegionUpdateMessage; import org.apollo.game.message.impl.RegionUpdateMessage; import org.apollo.game.model.Position; import org.apollo.net.codec.game.DataTransformation; import org.apollo.net.codec.game.DataType; import org.apollo.net.codec.game.GamePacket; import org.apollo.net.codec.game.GamePacketBuilder; import org.apollo.net.meta.PacketType; import org.apollo.net.release.MessageEncoder; import org.apollo.net.release.Release;
package org.apollo.game.release.r317; /** * A {@link MessageEncoder} for the {@link GroupedRegionUpdateMessage}. * * @author Major */ public final class GroupedRegionUpdateMessageEncoder extends MessageEncoder<GroupedRegionUpdateMessage> { /** * The Release containing the MessageEncoders for the RegionUpdateMessages. */ private final Release release; /** * Creates the GroupedRegionUpdateMessageEncoder. * * @param release The {@link Release} containing the {@link MessageEncoder}s for the {@link RegionUpdateMessage}s. */ public GroupedRegionUpdateMessageEncoder(Release release) { this.release = release; } @Override
// Path: net/src/main/java/org/apollo/net/codec/game/GamePacket.java // public final class GamePacket extends DefaultByteBufHolder { // // /** // * The length. // */ // private final int length; // // /** // * The opcode. // */ // private final int opcode; // // /** // * The packet type. // */ // private final PacketType type; // // /** // * Creates the game packet. // * // * @param opcode The opcode. // * @param type The packet type. // * @param payload The payload. // */ // public GamePacket(int opcode, PacketType type, ByteBuf payload) { // super(payload); // this.opcode = opcode; // this.type = type; // length = payload.readableBytes(); // } // // /** // * Gets the payload length. // * // * @return The payload length. // */ // public int getLength() { // return length; // } // // /** // * Gets the opcode. // * // * @return The opcode. // */ // public int getOpcode() { // return opcode; // } // // /** // * Gets the packet type. // * // * @return The packet type. // */ // public PacketType getType() { // return type; // } // // } // Path: game/src/main/java/org/apollo/game/release/r317/GroupedRegionUpdateMessageEncoder.java import org.apollo.game.message.impl.GroupedRegionUpdateMessage; import org.apollo.game.message.impl.RegionUpdateMessage; import org.apollo.game.model.Position; import org.apollo.net.codec.game.DataTransformation; import org.apollo.net.codec.game.DataType; import org.apollo.net.codec.game.GamePacket; import org.apollo.net.codec.game.GamePacketBuilder; import org.apollo.net.meta.PacketType; import org.apollo.net.release.MessageEncoder; import org.apollo.net.release.Release; package org.apollo.game.release.r317; /** * A {@link MessageEncoder} for the {@link GroupedRegionUpdateMessage}. * * @author Major */ public final class GroupedRegionUpdateMessageEncoder extends MessageEncoder<GroupedRegionUpdateMessage> { /** * The Release containing the MessageEncoders for the RegionUpdateMessages. */ private final Release release; /** * Creates the GroupedRegionUpdateMessageEncoder. * * @param release The {@link Release} containing the {@link MessageEncoder}s for the {@link RegionUpdateMessage}s. */ public GroupedRegionUpdateMessageEncoder(Release release) { this.release = release; } @Override
public GamePacket encode(GroupedRegionUpdateMessage message) {
apollo-rsps/apollo
game/src/main/java/org/apollo/game/release/r377/GroupedRegionUpdateMessageEncoder.java
// Path: net/src/main/java/org/apollo/net/codec/game/GamePacket.java // public final class GamePacket extends DefaultByteBufHolder { // // /** // * The length. // */ // private final int length; // // /** // * The opcode. // */ // private final int opcode; // // /** // * The packet type. // */ // private final PacketType type; // // /** // * Creates the game packet. // * // * @param opcode The opcode. // * @param type The packet type. // * @param payload The payload. // */ // public GamePacket(int opcode, PacketType type, ByteBuf payload) { // super(payload); // this.opcode = opcode; // this.type = type; // length = payload.readableBytes(); // } // // /** // * Gets the payload length. // * // * @return The payload length. // */ // public int getLength() { // return length; // } // // /** // * Gets the opcode. // * // * @return The opcode. // */ // public int getOpcode() { // return opcode; // } // // /** // * Gets the packet type. // * // * @return The packet type. // */ // public PacketType getType() { // return type; // } // // }
import org.apollo.game.message.impl.GroupedRegionUpdateMessage; import org.apollo.game.message.impl.RegionUpdateMessage; import org.apollo.game.model.Position; import org.apollo.net.codec.game.DataTransformation; import org.apollo.net.codec.game.DataType; import org.apollo.net.codec.game.GamePacket; import org.apollo.net.codec.game.GamePacketBuilder; import org.apollo.net.meta.PacketType; import org.apollo.net.release.MessageEncoder; import org.apollo.net.release.Release;
package org.apollo.game.release.r377; /** * A {@link MessageEncoder} for the {@link GroupedRegionUpdateMessage}. * * @author Major */ public final class GroupedRegionUpdateMessageEncoder extends MessageEncoder<GroupedRegionUpdateMessage> { /** * The Release containing the MessageEncoders for the RegionUpdateMessages. */ private final Release release; /** * Creates the GroupedRegionUpdateMessageEncoder. * * @param release The {@link Release} containing the {@link MessageEncoder}s for the {@link RegionUpdateMessage}s. */ public GroupedRegionUpdateMessageEncoder(Release release) { this.release = release; } @Override
// Path: net/src/main/java/org/apollo/net/codec/game/GamePacket.java // public final class GamePacket extends DefaultByteBufHolder { // // /** // * The length. // */ // private final int length; // // /** // * The opcode. // */ // private final int opcode; // // /** // * The packet type. // */ // private final PacketType type; // // /** // * Creates the game packet. // * // * @param opcode The opcode. // * @param type The packet type. // * @param payload The payload. // */ // public GamePacket(int opcode, PacketType type, ByteBuf payload) { // super(payload); // this.opcode = opcode; // this.type = type; // length = payload.readableBytes(); // } // // /** // * Gets the payload length. // * // * @return The payload length. // */ // public int getLength() { // return length; // } // // /** // * Gets the opcode. // * // * @return The opcode. // */ // public int getOpcode() { // return opcode; // } // // /** // * Gets the packet type. // * // * @return The packet type. // */ // public PacketType getType() { // return type; // } // // } // Path: game/src/main/java/org/apollo/game/release/r377/GroupedRegionUpdateMessageEncoder.java import org.apollo.game.message.impl.GroupedRegionUpdateMessage; import org.apollo.game.message.impl.RegionUpdateMessage; import org.apollo.game.model.Position; import org.apollo.net.codec.game.DataTransformation; import org.apollo.net.codec.game.DataType; import org.apollo.net.codec.game.GamePacket; import org.apollo.net.codec.game.GamePacketBuilder; import org.apollo.net.meta.PacketType; import org.apollo.net.release.MessageEncoder; import org.apollo.net.release.Release; package org.apollo.game.release.r377; /** * A {@link MessageEncoder} for the {@link GroupedRegionUpdateMessage}. * * @author Major */ public final class GroupedRegionUpdateMessageEncoder extends MessageEncoder<GroupedRegionUpdateMessage> { /** * The Release containing the MessageEncoders for the RegionUpdateMessages. */ private final Release release; /** * Creates the GroupedRegionUpdateMessageEncoder. * * @param release The {@link Release} containing the {@link MessageEncoder}s for the {@link RegionUpdateMessage}s. */ public GroupedRegionUpdateMessageEncoder(Release release) { this.release = release; } @Override
public GamePacket encode(GroupedRegionUpdateMessage message) {
apollo-rsps/apollo
game/src/main/java/org/apollo/game/release/r377/SendFriendMessageEncoder.java
// Path: game/src/main/java/org/apollo/game/message/impl/SendFriendMessage.java // public final class SendFriendMessage extends Message { // // /** // * The username of the friend. // */ // private final String username; // // /** // * The world id the friend is in. // */ // private final int world; // // /** // * Creates a new send friend message. // * // * @param username The username of the friend. // * @param world The world the friend is in. // */ // public SendFriendMessage(String username, int world) { // this.username = username; // this.world = world; // } // // /** // * Gets the username of the friend. // * // * @return The username. // */ // public String getUsername() { // return username; // } // // /** // * Gets the world id the friend is in. // * // * @return The world id. // */ // public int getWorld() { // return world; // } // // /** // * Gets the encoded world id to be sent to the client. // * // * @return The encoded world id. // */ // public int getEncodedWorld() { // return world == 0 ? 0 : world + 9; // } // } // // Path: net/src/main/java/org/apollo/net/codec/game/GamePacket.java // public final class GamePacket extends DefaultByteBufHolder { // // /** // * The length. // */ // private final int length; // // /** // * The opcode. // */ // private final int opcode; // // /** // * The packet type. // */ // private final PacketType type; // // /** // * Creates the game packet. // * // * @param opcode The opcode. // * @param type The packet type. // * @param payload The payload. // */ // public GamePacket(int opcode, PacketType type, ByteBuf payload) { // super(payload); // this.opcode = opcode; // this.type = type; // length = payload.readableBytes(); // } // // /** // * Gets the payload length. // * // * @return The payload length. // */ // public int getLength() { // return length; // } // // /** // * Gets the opcode. // * // * @return The opcode. // */ // public int getOpcode() { // return opcode; // } // // /** // * Gets the packet type. // * // * @return The packet type. // */ // public PacketType getType() { // return type; // } // // }
import org.apollo.game.message.impl.SendFriendMessage; import org.apollo.net.codec.game.DataType; import org.apollo.net.codec.game.GamePacket; import org.apollo.net.codec.game.GamePacketBuilder; import org.apollo.net.release.MessageEncoder; import org.apollo.util.NameUtil;
package org.apollo.game.release.r377; /** * A {@link MessageEncoder} for the {@link SendFriendMessage}. * * @author Major */ public final class SendFriendMessageEncoder extends MessageEncoder<SendFriendMessage> { @Override
// Path: game/src/main/java/org/apollo/game/message/impl/SendFriendMessage.java // public final class SendFriendMessage extends Message { // // /** // * The username of the friend. // */ // private final String username; // // /** // * The world id the friend is in. // */ // private final int world; // // /** // * Creates a new send friend message. // * // * @param username The username of the friend. // * @param world The world the friend is in. // */ // public SendFriendMessage(String username, int world) { // this.username = username; // this.world = world; // } // // /** // * Gets the username of the friend. // * // * @return The username. // */ // public String getUsername() { // return username; // } // // /** // * Gets the world id the friend is in. // * // * @return The world id. // */ // public int getWorld() { // return world; // } // // /** // * Gets the encoded world id to be sent to the client. // * // * @return The encoded world id. // */ // public int getEncodedWorld() { // return world == 0 ? 0 : world + 9; // } // } // // Path: net/src/main/java/org/apollo/net/codec/game/GamePacket.java // public final class GamePacket extends DefaultByteBufHolder { // // /** // * The length. // */ // private final int length; // // /** // * The opcode. // */ // private final int opcode; // // /** // * The packet type. // */ // private final PacketType type; // // /** // * Creates the game packet. // * // * @param opcode The opcode. // * @param type The packet type. // * @param payload The payload. // */ // public GamePacket(int opcode, PacketType type, ByteBuf payload) { // super(payload); // this.opcode = opcode; // this.type = type; // length = payload.readableBytes(); // } // // /** // * Gets the payload length. // * // * @return The payload length. // */ // public int getLength() { // return length; // } // // /** // * Gets the opcode. // * // * @return The opcode. // */ // public int getOpcode() { // return opcode; // } // // /** // * Gets the packet type. // * // * @return The packet type. // */ // public PacketType getType() { // return type; // } // // } // Path: game/src/main/java/org/apollo/game/release/r377/SendFriendMessageEncoder.java import org.apollo.game.message.impl.SendFriendMessage; import org.apollo.net.codec.game.DataType; import org.apollo.net.codec.game.GamePacket; import org.apollo.net.codec.game.GamePacketBuilder; import org.apollo.net.release.MessageEncoder; import org.apollo.util.NameUtil; package org.apollo.game.release.r377; /** * A {@link MessageEncoder} for the {@link SendFriendMessage}. * * @author Major */ public final class SendFriendMessageEncoder extends MessageEncoder<SendFriendMessage> { @Override
public GamePacket encode(SendFriendMessage message) {
apollo-rsps/apollo
game/src/main/java/org/apollo/game/release/r317/SendFriendMessageEncoder.java
// Path: game/src/main/java/org/apollo/game/message/impl/SendFriendMessage.java // public final class SendFriendMessage extends Message { // // /** // * The username of the friend. // */ // private final String username; // // /** // * The world id the friend is in. // */ // private final int world; // // /** // * Creates a new send friend message. // * // * @param username The username of the friend. // * @param world The world the friend is in. // */ // public SendFriendMessage(String username, int world) { // this.username = username; // this.world = world; // } // // /** // * Gets the username of the friend. // * // * @return The username. // */ // public String getUsername() { // return username; // } // // /** // * Gets the world id the friend is in. // * // * @return The world id. // */ // public int getWorld() { // return world; // } // // /** // * Gets the encoded world id to be sent to the client. // * // * @return The encoded world id. // */ // public int getEncodedWorld() { // return world == 0 ? 0 : world + 9; // } // } // // Path: net/src/main/java/org/apollo/net/codec/game/GamePacket.java // public final class GamePacket extends DefaultByteBufHolder { // // /** // * The length. // */ // private final int length; // // /** // * The opcode. // */ // private final int opcode; // // /** // * The packet type. // */ // private final PacketType type; // // /** // * Creates the game packet. // * // * @param opcode The opcode. // * @param type The packet type. // * @param payload The payload. // */ // public GamePacket(int opcode, PacketType type, ByteBuf payload) { // super(payload); // this.opcode = opcode; // this.type = type; // length = payload.readableBytes(); // } // // /** // * Gets the payload length. // * // * @return The payload length. // */ // public int getLength() { // return length; // } // // /** // * Gets the opcode. // * // * @return The opcode. // */ // public int getOpcode() { // return opcode; // } // // /** // * Gets the packet type. // * // * @return The packet type. // */ // public PacketType getType() { // return type; // } // // }
import org.apollo.game.message.impl.SendFriendMessage; import org.apollo.net.codec.game.DataType; import org.apollo.net.codec.game.GamePacket; import org.apollo.net.codec.game.GamePacketBuilder; import org.apollo.net.release.MessageEncoder; import org.apollo.util.NameUtil;
package org.apollo.game.release.r317; /** * A {@link MessageEncoder} for the {@link SendFriendMessage}. * * @author Major */ public final class SendFriendMessageEncoder extends MessageEncoder<SendFriendMessage> { @Override
// Path: game/src/main/java/org/apollo/game/message/impl/SendFriendMessage.java // public final class SendFriendMessage extends Message { // // /** // * The username of the friend. // */ // private final String username; // // /** // * The world id the friend is in. // */ // private final int world; // // /** // * Creates a new send friend message. // * // * @param username The username of the friend. // * @param world The world the friend is in. // */ // public SendFriendMessage(String username, int world) { // this.username = username; // this.world = world; // } // // /** // * Gets the username of the friend. // * // * @return The username. // */ // public String getUsername() { // return username; // } // // /** // * Gets the world id the friend is in. // * // * @return The world id. // */ // public int getWorld() { // return world; // } // // /** // * Gets the encoded world id to be sent to the client. // * // * @return The encoded world id. // */ // public int getEncodedWorld() { // return world == 0 ? 0 : world + 9; // } // } // // Path: net/src/main/java/org/apollo/net/codec/game/GamePacket.java // public final class GamePacket extends DefaultByteBufHolder { // // /** // * The length. // */ // private final int length; // // /** // * The opcode. // */ // private final int opcode; // // /** // * The packet type. // */ // private final PacketType type; // // /** // * Creates the game packet. // * // * @param opcode The opcode. // * @param type The packet type. // * @param payload The payload. // */ // public GamePacket(int opcode, PacketType type, ByteBuf payload) { // super(payload); // this.opcode = opcode; // this.type = type; // length = payload.readableBytes(); // } // // /** // * Gets the payload length. // * // * @return The payload length. // */ // public int getLength() { // return length; // } // // /** // * Gets the opcode. // * // * @return The opcode. // */ // public int getOpcode() { // return opcode; // } // // /** // * Gets the packet type. // * // * @return The packet type. // */ // public PacketType getType() { // return type; // } // // } // Path: game/src/main/java/org/apollo/game/release/r317/SendFriendMessageEncoder.java import org.apollo.game.message.impl.SendFriendMessage; import org.apollo.net.codec.game.DataType; import org.apollo.net.codec.game.GamePacket; import org.apollo.net.codec.game.GamePacketBuilder; import org.apollo.net.release.MessageEncoder; import org.apollo.util.NameUtil; package org.apollo.game.release.r317; /** * A {@link MessageEncoder} for the {@link SendFriendMessage}. * * @author Major */ public final class SendFriendMessageEncoder extends MessageEncoder<SendFriendMessage> { @Override
public GamePacket encode(SendFriendMessage message) {
leonardo2204/Flow1.0.0-alphaExample
app/src/main/java/leonardo2204/com/br/flowtests/di/component/FirstScreenComponent.java
// Path: app/src/main/java/leonardo2204/com/br/flowtests/di/module/FirstScreenModule.java // @Module // public class FirstScreenModule { // // @Provides // @DaggerScope(FirstScreenComponent.class) // public GetContacts providesGetContacts(ContactsRepository contactsRepository, ThreadExecutor threadExecutor, PostExecutionThread postExecutionThread) { // return new GetContacts(contactsRepository, threadExecutor, postExecutionThread); // } // // @Provides // @DaggerScope(FirstScreenComponent.class) // public FirstScreenPresenter providesFirstScreenPresenter(GetContacts getContacts, ActionBarOwner actionBarOwner) { // return new FirstScreenPresenter(getContacts, actionBarOwner); // } // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/view/FirstView.java // public class FirstView extends FrameLayout { // // @Bind(R.id.contacts_rv) // public RecyclerView contacts_rv; // @Inject // protected FirstScreenPresenter presenter; // // @Inject // // protected NavigationPresenter navigationPresenter; // LinearLayoutManager linearLayoutManager; // boolean mustHaveNumber; // // public FirstView(Context context) { // super(context); // inject(context); // } // // public FirstView(Context context, AttributeSet attrs) { // super(context, attrs); // inject(context); // } // // public FirstView(Context context, AttributeSet attrs, int defStyleAttr) { // super(context, attrs, defStyleAttr); // inject(context); // } // // private void inject(Context context) { // MortarScope scope = Flow.getService(Flow.getKey(this).getClass().getName(), context); // ((FirstScreenComponent)scope.getService(DaggerService.SERVICE_NAME)).inject(this); // //DaggerService.<FirstScreenComponent>getDaggerComponent(context).inject(this); // } // // @Override // protected Parcelable onSaveInstanceState() { // Parcelable parcelable = super.onSaveInstanceState(); // // SavedState ss = new SavedState(parcelable); // ss.mustHaveNumber = this.mustHaveNumber; // // return ss; // } // // @Override // protected void onRestoreInstanceState(Parcelable state) { // if (!(state instanceof SavedState)) { // super.onRestoreInstanceState(state); // return; // } // // SavedState ss = (SavedState) state; // super.onRestoreInstanceState(ss.getSuperState()); // // this.mustHaveNumber = ss.mustHaveNumber; // } // // @Override // protected void onAttachedToWindow() { // super.onAttachedToWindow(); // //toolbarPresenter.takeView(toolbar); // //navigationPresenter.takeView(navigationView); // presenter.takeView(this); // presenter.fetchContacts(mustHaveNumber); // } // // @Override // protected void onDetachedFromWindow() { // //toolbarPresenter.dropView(toolbar); // //navigationPresenter.dropView(navigationView); // presenter.dropView(this); // super.onDetachedFromWindow(); // } // // @Override // protected void onFinishInflate() { // super.onFinishInflate(); // ButterKnife.bind(this); // setupUI(); // } // // private void setupUI() { // this.setFitsSystemWindows(true); // linearLayoutManager = new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false); // this.contacts_rv.setLayoutManager(linearLayoutManager); // // ViewCompat.setElevation(toolbar, 5f); // // } // // public void setMustHaveNumber(boolean mustHaveNumber) { // this.mustHaveNumber = mustHaveNumber; // } // // public interface ContactListener { // void onClick(Contact contact); // } // // static class SavedState extends BaseSavedState { // // public static final Parcelable.Creator<SavedState> CREATOR = // new Creator<SavedState>() { // @Override // public SavedState createFromParcel(Parcel source) { // return new SavedState(source); // } // // @Override // public SavedState[] newArray(int size) { // return new SavedState[size]; // } // }; // boolean mustHaveNumber; // // public SavedState(Parcel source) { // super(source); // this.mustHaveNumber = source.readInt() == 1; // } // // public SavedState(Parcelable superState) { // super(superState); // } // // @Override // public void writeToParcel(Parcel out, int flags) { // super.writeToParcel(out, flags); // out.writeInt(this.mustHaveNumber ? 1 : 0); // } // } // // }
import dagger.Component; import leonardo2204.com.br.flowtests.di.module.FirstScreenModule; import leonardo2204.com.br.flowtests.di.scope.DaggerScope; import leonardo2204.com.br.flowtests.view.FirstView;
package leonardo2204.com.br.flowtests.di.component; /** * Created by Leonardo on 05/03/2016. */ @DaggerScope(FirstScreenComponent.class) @Component(dependencies = ActivityComponent.class, modules = FirstScreenModule.class) public interface FirstScreenComponent extends AppComponent {
// Path: app/src/main/java/leonardo2204/com/br/flowtests/di/module/FirstScreenModule.java // @Module // public class FirstScreenModule { // // @Provides // @DaggerScope(FirstScreenComponent.class) // public GetContacts providesGetContacts(ContactsRepository contactsRepository, ThreadExecutor threadExecutor, PostExecutionThread postExecutionThread) { // return new GetContacts(contactsRepository, threadExecutor, postExecutionThread); // } // // @Provides // @DaggerScope(FirstScreenComponent.class) // public FirstScreenPresenter providesFirstScreenPresenter(GetContacts getContacts, ActionBarOwner actionBarOwner) { // return new FirstScreenPresenter(getContacts, actionBarOwner); // } // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/view/FirstView.java // public class FirstView extends FrameLayout { // // @Bind(R.id.contacts_rv) // public RecyclerView contacts_rv; // @Inject // protected FirstScreenPresenter presenter; // // @Inject // // protected NavigationPresenter navigationPresenter; // LinearLayoutManager linearLayoutManager; // boolean mustHaveNumber; // // public FirstView(Context context) { // super(context); // inject(context); // } // // public FirstView(Context context, AttributeSet attrs) { // super(context, attrs); // inject(context); // } // // public FirstView(Context context, AttributeSet attrs, int defStyleAttr) { // super(context, attrs, defStyleAttr); // inject(context); // } // // private void inject(Context context) { // MortarScope scope = Flow.getService(Flow.getKey(this).getClass().getName(), context); // ((FirstScreenComponent)scope.getService(DaggerService.SERVICE_NAME)).inject(this); // //DaggerService.<FirstScreenComponent>getDaggerComponent(context).inject(this); // } // // @Override // protected Parcelable onSaveInstanceState() { // Parcelable parcelable = super.onSaveInstanceState(); // // SavedState ss = new SavedState(parcelable); // ss.mustHaveNumber = this.mustHaveNumber; // // return ss; // } // // @Override // protected void onRestoreInstanceState(Parcelable state) { // if (!(state instanceof SavedState)) { // super.onRestoreInstanceState(state); // return; // } // // SavedState ss = (SavedState) state; // super.onRestoreInstanceState(ss.getSuperState()); // // this.mustHaveNumber = ss.mustHaveNumber; // } // // @Override // protected void onAttachedToWindow() { // super.onAttachedToWindow(); // //toolbarPresenter.takeView(toolbar); // //navigationPresenter.takeView(navigationView); // presenter.takeView(this); // presenter.fetchContacts(mustHaveNumber); // } // // @Override // protected void onDetachedFromWindow() { // //toolbarPresenter.dropView(toolbar); // //navigationPresenter.dropView(navigationView); // presenter.dropView(this); // super.onDetachedFromWindow(); // } // // @Override // protected void onFinishInflate() { // super.onFinishInflate(); // ButterKnife.bind(this); // setupUI(); // } // // private void setupUI() { // this.setFitsSystemWindows(true); // linearLayoutManager = new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false); // this.contacts_rv.setLayoutManager(linearLayoutManager); // // ViewCompat.setElevation(toolbar, 5f); // // } // // public void setMustHaveNumber(boolean mustHaveNumber) { // this.mustHaveNumber = mustHaveNumber; // } // // public interface ContactListener { // void onClick(Contact contact); // } // // static class SavedState extends BaseSavedState { // // public static final Parcelable.Creator<SavedState> CREATOR = // new Creator<SavedState>() { // @Override // public SavedState createFromParcel(Parcel source) { // return new SavedState(source); // } // // @Override // public SavedState[] newArray(int size) { // return new SavedState[size]; // } // }; // boolean mustHaveNumber; // // public SavedState(Parcel source) { // super(source); // this.mustHaveNumber = source.readInt() == 1; // } // // public SavedState(Parcelable superState) { // super(superState); // } // // @Override // public void writeToParcel(Parcel out, int flags) { // super.writeToParcel(out, flags); // out.writeInt(this.mustHaveNumber ? 1 : 0); // } // } // // } // Path: app/src/main/java/leonardo2204/com/br/flowtests/di/component/FirstScreenComponent.java import dagger.Component; import leonardo2204.com.br.flowtests.di.module.FirstScreenModule; import leonardo2204.com.br.flowtests.di.scope.DaggerScope; import leonardo2204.com.br.flowtests.view.FirstView; package leonardo2204.com.br.flowtests.di.component; /** * Created by Leonardo on 05/03/2016. */ @DaggerScope(FirstScreenComponent.class) @Component(dependencies = ActivityComponent.class, modules = FirstScreenModule.class) public interface FirstScreenComponent extends AppComponent {
void inject(FirstView firstView);
leonardo2204/Flow1.0.0-alphaExample
app/src/main/java/leonardo2204/com/br/flowtests/FlowTestApplication.java
// Path: app/src/main/java/leonardo2204/com/br/flowtests/di/component/AppComponent.java // @ApplicationScope // @Component(modules = AppModule.class) // public interface AppComponent { // void inject(FlowTestApplication flowTestApplication); // // PostExecutionThread postExecutionThread(); // UIThread uiThread(); // ThreadExecutor threadExecutor(); // ContactsRepository contactsRepository(); // // SharedPreferences sharedPreferences(); // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/di/module/AppModule.java // @Module // public class AppModule { // // private final static String SHARED_NAME = "global_config"; // private final Application application; // // public AppModule(Application application) { // this.application = application; // } // // @Provides // @ApplicationScope // public Application providesApplication() { // return application; // } // // @Provides // @ApplicationScope // public UIThread provideUIThread() { // return new UIThread(); // } // // @Provides // @ApplicationScope // public ThreadExecutor provideThreadExecutor(JobExecutor jobExecutor) { // return jobExecutor; // } // // @Provides // @ApplicationScope // public PostExecutionThread providePostExecutionThread(UIThread uiThread) { // return uiThread; // } // // @Provides // @ApplicationScope // public ContentResolver providesContentResolver() { // return this.application.getContentResolver(); // } // // @Provides // @ApplicationScope // public ContactsRepository providesContactsRepository(ContentResolver contentResolver) { // return new ContactsRepositoryImpl(contentResolver); // } // // @Provides // @ApplicationScope // public SharedPreferences providesSharedPreferences() { // return this.application.getSharedPreferences(SHARED_NAME, Context.MODE_PRIVATE); // } // }
import android.app.Application; import com.squareup.leakcanary.LeakCanary; import leonardo2204.com.br.flowtests.di.DaggerService; import leonardo2204.com.br.flowtests.di.component.AppComponent; import leonardo2204.com.br.flowtests.di.component.DaggerAppComponent; import leonardo2204.com.br.flowtests.di.module.AppModule; import mortar.MortarScope;
package leonardo2204.com.br.flowtests; /** * Created by Leonardo on 05/03/2016. */ public class FlowTestApplication extends Application { private MortarScope mortarScope; @Override public Object getSystemService(String name) { if(mortarScope == null){ setupMortar(); } return (mortarScope.hasService(name)) ? mortarScope.getService(name) : super.getSystemService(name); } @Override public void onCreate() { super.onCreate(); LeakCanary.install(this); } private void setupMortar(){
// Path: app/src/main/java/leonardo2204/com/br/flowtests/di/component/AppComponent.java // @ApplicationScope // @Component(modules = AppModule.class) // public interface AppComponent { // void inject(FlowTestApplication flowTestApplication); // // PostExecutionThread postExecutionThread(); // UIThread uiThread(); // ThreadExecutor threadExecutor(); // ContactsRepository contactsRepository(); // // SharedPreferences sharedPreferences(); // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/di/module/AppModule.java // @Module // public class AppModule { // // private final static String SHARED_NAME = "global_config"; // private final Application application; // // public AppModule(Application application) { // this.application = application; // } // // @Provides // @ApplicationScope // public Application providesApplication() { // return application; // } // // @Provides // @ApplicationScope // public UIThread provideUIThread() { // return new UIThread(); // } // // @Provides // @ApplicationScope // public ThreadExecutor provideThreadExecutor(JobExecutor jobExecutor) { // return jobExecutor; // } // // @Provides // @ApplicationScope // public PostExecutionThread providePostExecutionThread(UIThread uiThread) { // return uiThread; // } // // @Provides // @ApplicationScope // public ContentResolver providesContentResolver() { // return this.application.getContentResolver(); // } // // @Provides // @ApplicationScope // public ContactsRepository providesContactsRepository(ContentResolver contentResolver) { // return new ContactsRepositoryImpl(contentResolver); // } // // @Provides // @ApplicationScope // public SharedPreferences providesSharedPreferences() { // return this.application.getSharedPreferences(SHARED_NAME, Context.MODE_PRIVATE); // } // } // Path: app/src/main/java/leonardo2204/com/br/flowtests/FlowTestApplication.java import android.app.Application; import com.squareup.leakcanary.LeakCanary; import leonardo2204.com.br.flowtests.di.DaggerService; import leonardo2204.com.br.flowtests.di.component.AppComponent; import leonardo2204.com.br.flowtests.di.component.DaggerAppComponent; import leonardo2204.com.br.flowtests.di.module.AppModule; import mortar.MortarScope; package leonardo2204.com.br.flowtests; /** * Created by Leonardo on 05/03/2016. */ public class FlowTestApplication extends Application { private MortarScope mortarScope; @Override public Object getSystemService(String name) { if(mortarScope == null){ setupMortar(); } return (mortarScope.hasService(name)) ? mortarScope.getService(name) : super.getSystemService(name); } @Override public void onCreate() { super.onCreate(); LeakCanary.install(this); } private void setupMortar(){
AppComponent component = DaggerAppComponent
leonardo2204/Flow1.0.0-alphaExample
app/src/main/java/leonardo2204/com/br/flowtests/FlowTestApplication.java
// Path: app/src/main/java/leonardo2204/com/br/flowtests/di/component/AppComponent.java // @ApplicationScope // @Component(modules = AppModule.class) // public interface AppComponent { // void inject(FlowTestApplication flowTestApplication); // // PostExecutionThread postExecutionThread(); // UIThread uiThread(); // ThreadExecutor threadExecutor(); // ContactsRepository contactsRepository(); // // SharedPreferences sharedPreferences(); // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/di/module/AppModule.java // @Module // public class AppModule { // // private final static String SHARED_NAME = "global_config"; // private final Application application; // // public AppModule(Application application) { // this.application = application; // } // // @Provides // @ApplicationScope // public Application providesApplication() { // return application; // } // // @Provides // @ApplicationScope // public UIThread provideUIThread() { // return new UIThread(); // } // // @Provides // @ApplicationScope // public ThreadExecutor provideThreadExecutor(JobExecutor jobExecutor) { // return jobExecutor; // } // // @Provides // @ApplicationScope // public PostExecutionThread providePostExecutionThread(UIThread uiThread) { // return uiThread; // } // // @Provides // @ApplicationScope // public ContentResolver providesContentResolver() { // return this.application.getContentResolver(); // } // // @Provides // @ApplicationScope // public ContactsRepository providesContactsRepository(ContentResolver contentResolver) { // return new ContactsRepositoryImpl(contentResolver); // } // // @Provides // @ApplicationScope // public SharedPreferences providesSharedPreferences() { // return this.application.getSharedPreferences(SHARED_NAME, Context.MODE_PRIVATE); // } // }
import android.app.Application; import com.squareup.leakcanary.LeakCanary; import leonardo2204.com.br.flowtests.di.DaggerService; import leonardo2204.com.br.flowtests.di.component.AppComponent; import leonardo2204.com.br.flowtests.di.component.DaggerAppComponent; import leonardo2204.com.br.flowtests.di.module.AppModule; import mortar.MortarScope;
package leonardo2204.com.br.flowtests; /** * Created by Leonardo on 05/03/2016. */ public class FlowTestApplication extends Application { private MortarScope mortarScope; @Override public Object getSystemService(String name) { if(mortarScope == null){ setupMortar(); } return (mortarScope.hasService(name)) ? mortarScope.getService(name) : super.getSystemService(name); } @Override public void onCreate() { super.onCreate(); LeakCanary.install(this); } private void setupMortar(){ AppComponent component = DaggerAppComponent .builder()
// Path: app/src/main/java/leonardo2204/com/br/flowtests/di/component/AppComponent.java // @ApplicationScope // @Component(modules = AppModule.class) // public interface AppComponent { // void inject(FlowTestApplication flowTestApplication); // // PostExecutionThread postExecutionThread(); // UIThread uiThread(); // ThreadExecutor threadExecutor(); // ContactsRepository contactsRepository(); // // SharedPreferences sharedPreferences(); // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/di/module/AppModule.java // @Module // public class AppModule { // // private final static String SHARED_NAME = "global_config"; // private final Application application; // // public AppModule(Application application) { // this.application = application; // } // // @Provides // @ApplicationScope // public Application providesApplication() { // return application; // } // // @Provides // @ApplicationScope // public UIThread provideUIThread() { // return new UIThread(); // } // // @Provides // @ApplicationScope // public ThreadExecutor provideThreadExecutor(JobExecutor jobExecutor) { // return jobExecutor; // } // // @Provides // @ApplicationScope // public PostExecutionThread providePostExecutionThread(UIThread uiThread) { // return uiThread; // } // // @Provides // @ApplicationScope // public ContentResolver providesContentResolver() { // return this.application.getContentResolver(); // } // // @Provides // @ApplicationScope // public ContactsRepository providesContactsRepository(ContentResolver contentResolver) { // return new ContactsRepositoryImpl(contentResolver); // } // // @Provides // @ApplicationScope // public SharedPreferences providesSharedPreferences() { // return this.application.getSharedPreferences(SHARED_NAME, Context.MODE_PRIVATE); // } // } // Path: app/src/main/java/leonardo2204/com/br/flowtests/FlowTestApplication.java import android.app.Application; import com.squareup.leakcanary.LeakCanary; import leonardo2204.com.br.flowtests.di.DaggerService; import leonardo2204.com.br.flowtests.di.component.AppComponent; import leonardo2204.com.br.flowtests.di.component.DaggerAppComponent; import leonardo2204.com.br.flowtests.di.module.AppModule; import mortar.MortarScope; package leonardo2204.com.br.flowtests; /** * Created by Leonardo on 05/03/2016. */ public class FlowTestApplication extends Application { private MortarScope mortarScope; @Override public Object getSystemService(String name) { if(mortarScope == null){ setupMortar(); } return (mortarScope.hasService(name)) ? mortarScope.getService(name) : super.getSystemService(name); } @Override public void onCreate() { super.onCreate(); LeakCanary.install(this); } private void setupMortar(){ AppComponent component = DaggerAppComponent .builder()
.appModule(new AppModule(this))
leonardo2204/Flow1.0.0-alphaExample
app/src/main/java/leonardo2204/com/br/flowtests/di/module/DetailScreenModule.java
// Path: app/src/main/java/leonardo2204/com/br/flowtests/di/component/DetailScreenComponent.java // @DaggerScope(DetailScreenComponent.class) // @Component(dependencies = ActivityComponent.class, modules = DetailScreenModule.class) // public interface DetailScreenComponent extends AppComponent { // void inject(DetailsView detailsView); // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/presenter/ActionBarOwner.java // @DaggerScope(ActivityComponent.class) // public class ActionBarOwner extends Presenter<ActionBarOwner.Activity> { // // private Config config; // // @Override // protected BundleService extractBundleService(Activity view) { // return BundleService.getBundleService(view.getContext()); // } // // @Override // protected void onLoad(Bundle savedInstanceState) { // if (config != null) update(); // } // // private void update() { // if (!hasView()) return; // // Activity activity = getView(); // activity.setMenu(config.menuActionList); // activity.setShowHomeEnabled(config.showHomeEnabled); // activity.setUpButtonEnabled(config.upButtonEnabled); // activity.setToolbarTitle(config.title); // } // // public Config getConfig() { // return config; // } // // public void setConfig(Config config) { // this.config = config; // this.update(); // } // // public interface Activity { // void setMenu(List<MenuAction> menuActionList); // // void setToolbarTitle(CharSequence title); // // void setShowHomeEnabled(boolean enabled); // // void setUpButtonEnabled(boolean enabled); // // Context getContext(); // } // // public static class Config { // public final List<MenuAction> menuActionList; // public final CharSequence title; // public final boolean showHomeEnabled; // public final boolean upButtonEnabled; // // // public Config(List<MenuAction> menuActionList, CharSequence title, boolean showHomeEnabled, boolean upButtonEnabled) { // this.menuActionList = menuActionList; // this.title = title; // this.showHomeEnabled = showHomeEnabled; // this.upButtonEnabled = upButtonEnabled; // } // // public Config withAction(List<MenuAction> menuActionList) { // return new Config(menuActionList, title, showHomeEnabled, upButtonEnabled); // } // } // // public static class MenuAction { // public final CharSequence title; // public final Action0 action; // public final int icon; // // public MenuAction(CharSequence title, Action0 action, int icon) { // this.title = title; // this.action = action; // this.icon = icon; // } // } // // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/presenter/DetailsScreenPresenter.java // @DaggerScope(DetailScreenComponent.class) // public class DetailsScreenPresenter extends ViewPresenter<DetailsView> { // // private final GetDetailedContact getDetailedContact; // private final ActionBarOwner actionBarOwner; // private Contact contact; // // @Inject // public DetailsScreenPresenter(GetDetailedContact getDetailedContact, ActionBarOwner actionBarOwner) { // this.getDetailedContact = getDetailedContact; // this.actionBarOwner = actionBarOwner; // } // // @Override // protected void onLoad(Bundle savedInstanceState) { // super.onLoad(savedInstanceState); // this.contact = ((DetailsScreen) Flow.getKey(getView())).getContact(); // Bundle bundle = new Bundle(1); // bundle.putParcelable("contact", Parcels.wrap(contact)); // this.getDetailedContact.execute(new DetailedSubscriber(), bundle); // // ActionBarOwner.MenuAction menuAction = new ActionBarOwner.MenuAction(contact.getName(), new Action0() { // @Override // public void call() { // Toast.makeText(getView().getContext(), "Call", Toast.LENGTH_SHORT).show(); // } // }, R.drawable.ic_call_black_24dp); // // ActionBarOwner.MenuAction menuAction2 = new ActionBarOwner.MenuAction(contact.getName(), new Action0() { // @Override // public void call() { // Toast.makeText(getView().getContext(), "Call 2", Toast.LENGTH_SHORT).show(); // } // }, R.drawable.ic_call_black_24dp); // // ActionBarOwner.Config config = new ActionBarOwner.Config(Arrays.asList(menuAction, menuAction2), contact.getName(), false, true); // this.actionBarOwner.setConfig(config); // // // this.toolbarPresenter.setNavigationIcon(R.drawable.ic_arrow_back_black_24dp); // // this.toolbarPresenter.setNavigationAction(new View.OnClickListener() { // // @Override // // public void onClick(View v) { // // //noinspection CheckResult // // Flow.get(getView()).goBack(); // // } // // }); // } // // @Override // protected void onExitScope() { // super.onExitScope(); // this.getDetailedContact.unsubscribe(); // } // // class DetailedSubscriber extends DefaultSubscriber<Contact> { // // @Override // public void onNext(Contact contact) { // if (getView() != null) { // getView().setTelephoneField(contact.getTelephone()); // } // } // // @Override // public void onError(Throwable e) { // if(getView() != null) // Toast.makeText(getView().getContext(), e.getMessage(), Toast.LENGTH_SHORT).show(); // } // } // }
import dagger.Module; import dagger.Provides; import leonardo2204.com.br.flowtests.di.component.DetailScreenComponent; import leonardo2204.com.br.flowtests.di.scope.DaggerScope; import leonardo2204.com.br.flowtests.domain.executor.PostExecutionThread; import leonardo2204.com.br.flowtests.domain.executor.ThreadExecutor; import leonardo2204.com.br.flowtests.domain.interactor.GetDetailedContact; import leonardo2204.com.br.flowtests.domain.repository.ContactsRepository; import leonardo2204.com.br.flowtests.presenter.ActionBarOwner; import leonardo2204.com.br.flowtests.presenter.DetailsScreenPresenter;
package leonardo2204.com.br.flowtests.di.module; /** * Created by Leonardo on 05/03/2016. */ @Module public class DetailScreenModule { @Provides
// Path: app/src/main/java/leonardo2204/com/br/flowtests/di/component/DetailScreenComponent.java // @DaggerScope(DetailScreenComponent.class) // @Component(dependencies = ActivityComponent.class, modules = DetailScreenModule.class) // public interface DetailScreenComponent extends AppComponent { // void inject(DetailsView detailsView); // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/presenter/ActionBarOwner.java // @DaggerScope(ActivityComponent.class) // public class ActionBarOwner extends Presenter<ActionBarOwner.Activity> { // // private Config config; // // @Override // protected BundleService extractBundleService(Activity view) { // return BundleService.getBundleService(view.getContext()); // } // // @Override // protected void onLoad(Bundle savedInstanceState) { // if (config != null) update(); // } // // private void update() { // if (!hasView()) return; // // Activity activity = getView(); // activity.setMenu(config.menuActionList); // activity.setShowHomeEnabled(config.showHomeEnabled); // activity.setUpButtonEnabled(config.upButtonEnabled); // activity.setToolbarTitle(config.title); // } // // public Config getConfig() { // return config; // } // // public void setConfig(Config config) { // this.config = config; // this.update(); // } // // public interface Activity { // void setMenu(List<MenuAction> menuActionList); // // void setToolbarTitle(CharSequence title); // // void setShowHomeEnabled(boolean enabled); // // void setUpButtonEnabled(boolean enabled); // // Context getContext(); // } // // public static class Config { // public final List<MenuAction> menuActionList; // public final CharSequence title; // public final boolean showHomeEnabled; // public final boolean upButtonEnabled; // // // public Config(List<MenuAction> menuActionList, CharSequence title, boolean showHomeEnabled, boolean upButtonEnabled) { // this.menuActionList = menuActionList; // this.title = title; // this.showHomeEnabled = showHomeEnabled; // this.upButtonEnabled = upButtonEnabled; // } // // public Config withAction(List<MenuAction> menuActionList) { // return new Config(menuActionList, title, showHomeEnabled, upButtonEnabled); // } // } // // public static class MenuAction { // public final CharSequence title; // public final Action0 action; // public final int icon; // // public MenuAction(CharSequence title, Action0 action, int icon) { // this.title = title; // this.action = action; // this.icon = icon; // } // } // // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/presenter/DetailsScreenPresenter.java // @DaggerScope(DetailScreenComponent.class) // public class DetailsScreenPresenter extends ViewPresenter<DetailsView> { // // private final GetDetailedContact getDetailedContact; // private final ActionBarOwner actionBarOwner; // private Contact contact; // // @Inject // public DetailsScreenPresenter(GetDetailedContact getDetailedContact, ActionBarOwner actionBarOwner) { // this.getDetailedContact = getDetailedContact; // this.actionBarOwner = actionBarOwner; // } // // @Override // protected void onLoad(Bundle savedInstanceState) { // super.onLoad(savedInstanceState); // this.contact = ((DetailsScreen) Flow.getKey(getView())).getContact(); // Bundle bundle = new Bundle(1); // bundle.putParcelable("contact", Parcels.wrap(contact)); // this.getDetailedContact.execute(new DetailedSubscriber(), bundle); // // ActionBarOwner.MenuAction menuAction = new ActionBarOwner.MenuAction(contact.getName(), new Action0() { // @Override // public void call() { // Toast.makeText(getView().getContext(), "Call", Toast.LENGTH_SHORT).show(); // } // }, R.drawable.ic_call_black_24dp); // // ActionBarOwner.MenuAction menuAction2 = new ActionBarOwner.MenuAction(contact.getName(), new Action0() { // @Override // public void call() { // Toast.makeText(getView().getContext(), "Call 2", Toast.LENGTH_SHORT).show(); // } // }, R.drawable.ic_call_black_24dp); // // ActionBarOwner.Config config = new ActionBarOwner.Config(Arrays.asList(menuAction, menuAction2), contact.getName(), false, true); // this.actionBarOwner.setConfig(config); // // // this.toolbarPresenter.setNavigationIcon(R.drawable.ic_arrow_back_black_24dp); // // this.toolbarPresenter.setNavigationAction(new View.OnClickListener() { // // @Override // // public void onClick(View v) { // // //noinspection CheckResult // // Flow.get(getView()).goBack(); // // } // // }); // } // // @Override // protected void onExitScope() { // super.onExitScope(); // this.getDetailedContact.unsubscribe(); // } // // class DetailedSubscriber extends DefaultSubscriber<Contact> { // // @Override // public void onNext(Contact contact) { // if (getView() != null) { // getView().setTelephoneField(contact.getTelephone()); // } // } // // @Override // public void onError(Throwable e) { // if(getView() != null) // Toast.makeText(getView().getContext(), e.getMessage(), Toast.LENGTH_SHORT).show(); // } // } // } // Path: app/src/main/java/leonardo2204/com/br/flowtests/di/module/DetailScreenModule.java import dagger.Module; import dagger.Provides; import leonardo2204.com.br.flowtests.di.component.DetailScreenComponent; import leonardo2204.com.br.flowtests.di.scope.DaggerScope; import leonardo2204.com.br.flowtests.domain.executor.PostExecutionThread; import leonardo2204.com.br.flowtests.domain.executor.ThreadExecutor; import leonardo2204.com.br.flowtests.domain.interactor.GetDetailedContact; import leonardo2204.com.br.flowtests.domain.repository.ContactsRepository; import leonardo2204.com.br.flowtests.presenter.ActionBarOwner; import leonardo2204.com.br.flowtests.presenter.DetailsScreenPresenter; package leonardo2204.com.br.flowtests.di.module; /** * Created by Leonardo on 05/03/2016. */ @Module public class DetailScreenModule { @Provides
@DaggerScope(DetailScreenComponent.class)
leonardo2204/Flow1.0.0-alphaExample
flow-sample-multikey/src/main/java/flow/sample/multikey/CustomServiceFactory.java
// Path: flow/src/main/java/flow/Services.java // public class Services { // static final Services ROOT_SERVICES = // new Services(Flow.ROOT_KEY, null, Collections.<String, Object>emptyMap()); // // public static final class Binder extends Services { // private final Map<String, Object> services = new LinkedHashMap<>(); // private final Services base; // // private Binder(Services base, Object key) { // super(key, base, Collections.<String, Object>emptyMap()); // checkNotNull(base, "only root Services should have a null base"); // this.base = base; // } // // @NonNull public Binder bind(@NonNull String serviceName, @NonNull Object service) { // services.put(serviceName, service); // return this; // } // // @NonNull Services build() { // return new Services(getKey(), base, services); // } // } // // private final Object key; // @Nullable private final Services delegate; // private final Map<String, Object> localServices = new LinkedHashMap<>(); // // private Services(Object key, @Nullable Services delegate, Map<String, Object> localServices) { // this.delegate = delegate; // this.key = key; // this.localServices.putAll(localServices); // } // // @Nullable public <T> T getService(@NonNull String name) { // if (localServices.containsKey(name)) { // @SuppressWarnings("unchecked") // // final T service = (T) localServices.get(name); // return service; // } // if (delegate != null) return delegate.getService(name); // return null; // } // // @NonNull public <T> T getKey() { // //noinspection unchecked // return (T) this.key; // } // // @NonNull Binder extend(@NonNull Object key) { // return new Binder(this, key); // } // }
import android.support.annotation.NonNull; import flow.Services; import flow.ServicesFactory;
package flow.sample.multikey; /** * Created by Leonardo on 19/03/2016. */ public class CustomServiceFactory extends ServicesFactory { @Override
// Path: flow/src/main/java/flow/Services.java // public class Services { // static final Services ROOT_SERVICES = // new Services(Flow.ROOT_KEY, null, Collections.<String, Object>emptyMap()); // // public static final class Binder extends Services { // private final Map<String, Object> services = new LinkedHashMap<>(); // private final Services base; // // private Binder(Services base, Object key) { // super(key, base, Collections.<String, Object>emptyMap()); // checkNotNull(base, "only root Services should have a null base"); // this.base = base; // } // // @NonNull public Binder bind(@NonNull String serviceName, @NonNull Object service) { // services.put(serviceName, service); // return this; // } // // @NonNull Services build() { // return new Services(getKey(), base, services); // } // } // // private final Object key; // @Nullable private final Services delegate; // private final Map<String, Object> localServices = new LinkedHashMap<>(); // // private Services(Object key, @Nullable Services delegate, Map<String, Object> localServices) { // this.delegate = delegate; // this.key = key; // this.localServices.putAll(localServices); // } // // @Nullable public <T> T getService(@NonNull String name) { // if (localServices.containsKey(name)) { // @SuppressWarnings("unchecked") // // final T service = (T) localServices.get(name); // return service; // } // if (delegate != null) return delegate.getService(name); // return null; // } // // @NonNull public <T> T getKey() { // //noinspection unchecked // return (T) this.key; // } // // @NonNull Binder extend(@NonNull Object key) { // return new Binder(this, key); // } // } // Path: flow-sample-multikey/src/main/java/flow/sample/multikey/CustomServiceFactory.java import android.support.annotation.NonNull; import flow.Services; import flow.ServicesFactory; package flow.sample.multikey; /** * Created by Leonardo on 19/03/2016. */ public class CustomServiceFactory extends ServicesFactory { @Override
public void bindServices(@NonNull Services.Binder services) {
leonardo2204/Flow1.0.0-alphaExample
app/src/main/java/leonardo2204/com/br/flowtests/di/component/DetailScreenComponent.java
// Path: app/src/main/java/leonardo2204/com/br/flowtests/di/module/DetailScreenModule.java // @Module // public class DetailScreenModule { // // @Provides // @DaggerScope(DetailScreenComponent.class) // public GetDetailedContact providesGetDetailedContact(ContactsRepository contactsRepository, ThreadExecutor threadExecutor, PostExecutionThread postExecutionThread) { // return new GetDetailedContact(contactsRepository, threadExecutor, postExecutionThread); // } // // @Provides // @DaggerScope(DetailScreenComponent.class) // public DetailsScreenPresenter providesDetailsScreenPresenter(GetDetailedContact getDetailedContact, ActionBarOwner actionBarOwner) { // return new DetailsScreenPresenter(getDetailedContact, actionBarOwner); // } // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/view/DetailsView.java // public class DetailsView extends LinearLayout { // // @Inject // protected DetailsScreenPresenter presenter; // @Bind(R.id.name) // EndDrawableTextView name; // @Bind(R.id.telephone_header) // TextView telephoneHeader; // @Bind(R.id.multi_telephone) // MultiEditableTextView telephone; // // public DetailsView(Context context) { // super(context); // initUI(context); // } // // public DetailsView(Context context, AttributeSet attrs) { // super(context, attrs); // initUI(context); // } // // public DetailsView(Context context, AttributeSet attrs, int defStyleAttr) { // super(context, attrs, defStyleAttr); // initUI(context); // } // // @Override // protected void onAttachedToWindow() { // super.onAttachedToWindow(); // presenter.takeView(this); // } // // @Override // protected void onDetachedFromWindow() { // presenter.dropView(this); // super.onDetachedFromWindow(); // } // // @Override // protected void onFinishInflate() { // super.onFinishInflate(); // ButterKnife.bind(this); // // //ViewCompat.setBackgroundTintList(telephoneHeader, ColorStateList.valueOf(ContextCompat.getColor(getContext(), R.color.colorAccent))); // // final DetailsScreen screen = Flow.getKey(this); // name.setText(screen.getContact().getName()); // name.setOnDrawableClickListener(new EndDrawableTextView.OnDrawableClickListener() { // @Override // public void onEndDrawableClick() { // Flow.get(DetailsView.this).set(new EditDialogScreen(screen.getContact())); // } // }); // // // telephone.setOnDrawableClickListener(new EndDrawableTextView.OnDrawableClickListener() { // // @Override // // public void onEndDrawableClick() { // // Toast.makeText(getContext(), "Open Edit Phone Dialog...", Toast.LENGTH_SHORT).show(); // // } // // }); // } // // public void setTelephoneField(List<String> telephoneNumberList) { // telephone.addItems(telephoneNumberList); // } // // private void initUI(Context context) { // setOrientation(VERTICAL); // initializeInjection(context); // } // // private void initializeInjection(Context context) { // MortarScope scope = Flow.getService(Flow.getKey(this).getClass().getName(), context); // ((DetailScreenComponent)scope.getService(DaggerService.SERVICE_NAME)).inject(this); // } // // }
import dagger.Component; import leonardo2204.com.br.flowtests.di.module.DetailScreenModule; import leonardo2204.com.br.flowtests.di.scope.DaggerScope; import leonardo2204.com.br.flowtests.view.DetailsView;
package leonardo2204.com.br.flowtests.di.component; /** * Created by Leonardo on 05/03/2016. */ @DaggerScope(DetailScreenComponent.class) @Component(dependencies = ActivityComponent.class, modules = DetailScreenModule.class) public interface DetailScreenComponent extends AppComponent {
// Path: app/src/main/java/leonardo2204/com/br/flowtests/di/module/DetailScreenModule.java // @Module // public class DetailScreenModule { // // @Provides // @DaggerScope(DetailScreenComponent.class) // public GetDetailedContact providesGetDetailedContact(ContactsRepository contactsRepository, ThreadExecutor threadExecutor, PostExecutionThread postExecutionThread) { // return new GetDetailedContact(contactsRepository, threadExecutor, postExecutionThread); // } // // @Provides // @DaggerScope(DetailScreenComponent.class) // public DetailsScreenPresenter providesDetailsScreenPresenter(GetDetailedContact getDetailedContact, ActionBarOwner actionBarOwner) { // return new DetailsScreenPresenter(getDetailedContact, actionBarOwner); // } // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/view/DetailsView.java // public class DetailsView extends LinearLayout { // // @Inject // protected DetailsScreenPresenter presenter; // @Bind(R.id.name) // EndDrawableTextView name; // @Bind(R.id.telephone_header) // TextView telephoneHeader; // @Bind(R.id.multi_telephone) // MultiEditableTextView telephone; // // public DetailsView(Context context) { // super(context); // initUI(context); // } // // public DetailsView(Context context, AttributeSet attrs) { // super(context, attrs); // initUI(context); // } // // public DetailsView(Context context, AttributeSet attrs, int defStyleAttr) { // super(context, attrs, defStyleAttr); // initUI(context); // } // // @Override // protected void onAttachedToWindow() { // super.onAttachedToWindow(); // presenter.takeView(this); // } // // @Override // protected void onDetachedFromWindow() { // presenter.dropView(this); // super.onDetachedFromWindow(); // } // // @Override // protected void onFinishInflate() { // super.onFinishInflate(); // ButterKnife.bind(this); // // //ViewCompat.setBackgroundTintList(telephoneHeader, ColorStateList.valueOf(ContextCompat.getColor(getContext(), R.color.colorAccent))); // // final DetailsScreen screen = Flow.getKey(this); // name.setText(screen.getContact().getName()); // name.setOnDrawableClickListener(new EndDrawableTextView.OnDrawableClickListener() { // @Override // public void onEndDrawableClick() { // Flow.get(DetailsView.this).set(new EditDialogScreen(screen.getContact())); // } // }); // // // telephone.setOnDrawableClickListener(new EndDrawableTextView.OnDrawableClickListener() { // // @Override // // public void onEndDrawableClick() { // // Toast.makeText(getContext(), "Open Edit Phone Dialog...", Toast.LENGTH_SHORT).show(); // // } // // }); // } // // public void setTelephoneField(List<String> telephoneNumberList) { // telephone.addItems(telephoneNumberList); // } // // private void initUI(Context context) { // setOrientation(VERTICAL); // initializeInjection(context); // } // // private void initializeInjection(Context context) { // MortarScope scope = Flow.getService(Flow.getKey(this).getClass().getName(), context); // ((DetailScreenComponent)scope.getService(DaggerService.SERVICE_NAME)).inject(this); // } // // } // Path: app/src/main/java/leonardo2204/com/br/flowtests/di/component/DetailScreenComponent.java import dagger.Component; import leonardo2204.com.br.flowtests.di.module.DetailScreenModule; import leonardo2204.com.br.flowtests.di.scope.DaggerScope; import leonardo2204.com.br.flowtests.view.DetailsView; package leonardo2204.com.br.flowtests.di.component; /** * Created by Leonardo on 05/03/2016. */ @DaggerScope(DetailScreenComponent.class) @Component(dependencies = ActivityComponent.class, modules = DetailScreenModule.class) public interface DetailScreenComponent extends AppComponent {
void inject(DetailsView detailsView);
leonardo2204/Flow1.0.0-alphaExample
app/src/main/java/leonardo2204/com/br/flowtests/di/module/AppModule.java
// Path: app/src/main/java/leonardo2204/com/br/flowtests/data/repository/ContactsRepositoryImpl.java // public class ContactsRepositoryImpl implements ContactsRepository { // // private final ContentResolver contentResolver; // // public ContactsRepositoryImpl(ContentResolver contentResolver) { // this.contentResolver = contentResolver; // } // // @Override // public Observable<List<Contact>> getContactsFromPhone(final boolean mustHaveNumber) { // return Observable.create(new Observable.OnSubscribe<List<Contact>>() { // @Override // public void call(Subscriber<? super List<Contact>> subscriber) { // Cursor queryContacts; // // if(mustHaveNumber) // queryContacts = contentResolver.query(ContactsContract.Contacts.CONTENT_URI, // null, ContactsContract.Contacts.HAS_PHONE_NUMBER + " > ?",new String[]{"0"}, ContactsContract.Contacts.DISPLAY_NAME + " ASC"); // else // queryContacts = contentResolver.query(ContactsContract.Contacts.CONTENT_URI, // null, null, null, ContactsContract.Contacts.DISPLAY_NAME + " ASC"); // // if(queryContacts.getCount() > 0) { // List<Contact> contacts = new ArrayList<>(queryContacts.getColumnCount()); // // while (queryContacts.moveToNext()) { // Contact contact = new Contact(); // // String id = queryContacts.getString( // queryContacts.getColumnIndex(ContactsContract.Contacts._ID)); // String name = queryContacts.getString( // queryContacts.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME)); // // contact.setId(id); // contact.setName(name); // contacts.add(contact); // } // subscriber.onNext(contacts); // subscriber.onCompleted(); // }else{ // subscriber.onError(new Exception("No contacts were found")); // subscriber.onCompleted(); // } // queryContacts.close(); // } // }); // } // // @Override // public Observable<Contact> getContactById(final Contact contact) { // return Observable.create(new Observable.OnSubscribe<Contact>() { // @Override // public void call(Subscriber<? super Contact> subscriber) { // Cursor queryContacts = contentResolver.query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, // new String[] {ContactsContract.Contacts._ID, // ContactsContract.CommonDataKinds.Phone.NUMBER}, // ContactsContract.CommonDataKinds.Phone.CONTACT_ID +" = ?", // new String[]{contact.getId()}, // null); // // if(queryContacts.getCount() > 0) { // while (queryContacts.moveToNext()) { // Cursor pCur = contentResolver.query( // ContactsContract.CommonDataKinds.Phone.CONTENT_URI, // null, // ContactsContract.CommonDataKinds.Phone.CONTACT_ID +" = ?", // new String[]{contact.getId()}, null); // // List<String> phones = new ArrayList<>(); // contact.setTelephone(phones); // // while (pCur.moveToNext()) { // contact.getTelephone().add(pCur.getString((pCur.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER)))); // } // pCur.close(); // } // subscriber.onNext(contact); // subscriber.onCompleted(); // }else{ // subscriber.onError(new Exception("No telephones were found")); // subscriber.onCompleted(); // } // // queryContacts.close(); // } // }); // } // // }
import android.app.Application; import android.content.ContentResolver; import android.content.Context; import android.content.SharedPreferences; import dagger.Module; import dagger.Provides; import leonardo2204.com.br.flowtests.UIThread; import leonardo2204.com.br.flowtests.data.executor.JobExecutor; import leonardo2204.com.br.flowtests.data.repository.ContactsRepositoryImpl; import leonardo2204.com.br.flowtests.di.scope.ApplicationScope; import leonardo2204.com.br.flowtests.domain.executor.PostExecutionThread; import leonardo2204.com.br.flowtests.domain.executor.ThreadExecutor; import leonardo2204.com.br.flowtests.domain.repository.ContactsRepository;
return application; } @Provides @ApplicationScope public UIThread provideUIThread() { return new UIThread(); } @Provides @ApplicationScope public ThreadExecutor provideThreadExecutor(JobExecutor jobExecutor) { return jobExecutor; } @Provides @ApplicationScope public PostExecutionThread providePostExecutionThread(UIThread uiThread) { return uiThread; } @Provides @ApplicationScope public ContentResolver providesContentResolver() { return this.application.getContentResolver(); } @Provides @ApplicationScope public ContactsRepository providesContactsRepository(ContentResolver contentResolver) {
// Path: app/src/main/java/leonardo2204/com/br/flowtests/data/repository/ContactsRepositoryImpl.java // public class ContactsRepositoryImpl implements ContactsRepository { // // private final ContentResolver contentResolver; // // public ContactsRepositoryImpl(ContentResolver contentResolver) { // this.contentResolver = contentResolver; // } // // @Override // public Observable<List<Contact>> getContactsFromPhone(final boolean mustHaveNumber) { // return Observable.create(new Observable.OnSubscribe<List<Contact>>() { // @Override // public void call(Subscriber<? super List<Contact>> subscriber) { // Cursor queryContacts; // // if(mustHaveNumber) // queryContacts = contentResolver.query(ContactsContract.Contacts.CONTENT_URI, // null, ContactsContract.Contacts.HAS_PHONE_NUMBER + " > ?",new String[]{"0"}, ContactsContract.Contacts.DISPLAY_NAME + " ASC"); // else // queryContacts = contentResolver.query(ContactsContract.Contacts.CONTENT_URI, // null, null, null, ContactsContract.Contacts.DISPLAY_NAME + " ASC"); // // if(queryContacts.getCount() > 0) { // List<Contact> contacts = new ArrayList<>(queryContacts.getColumnCount()); // // while (queryContacts.moveToNext()) { // Contact contact = new Contact(); // // String id = queryContacts.getString( // queryContacts.getColumnIndex(ContactsContract.Contacts._ID)); // String name = queryContacts.getString( // queryContacts.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME)); // // contact.setId(id); // contact.setName(name); // contacts.add(contact); // } // subscriber.onNext(contacts); // subscriber.onCompleted(); // }else{ // subscriber.onError(new Exception("No contacts were found")); // subscriber.onCompleted(); // } // queryContacts.close(); // } // }); // } // // @Override // public Observable<Contact> getContactById(final Contact contact) { // return Observable.create(new Observable.OnSubscribe<Contact>() { // @Override // public void call(Subscriber<? super Contact> subscriber) { // Cursor queryContacts = contentResolver.query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, // new String[] {ContactsContract.Contacts._ID, // ContactsContract.CommonDataKinds.Phone.NUMBER}, // ContactsContract.CommonDataKinds.Phone.CONTACT_ID +" = ?", // new String[]{contact.getId()}, // null); // // if(queryContacts.getCount() > 0) { // while (queryContacts.moveToNext()) { // Cursor pCur = contentResolver.query( // ContactsContract.CommonDataKinds.Phone.CONTENT_URI, // null, // ContactsContract.CommonDataKinds.Phone.CONTACT_ID +" = ?", // new String[]{contact.getId()}, null); // // List<String> phones = new ArrayList<>(); // contact.setTelephone(phones); // // while (pCur.moveToNext()) { // contact.getTelephone().add(pCur.getString((pCur.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER)))); // } // pCur.close(); // } // subscriber.onNext(contact); // subscriber.onCompleted(); // }else{ // subscriber.onError(new Exception("No telephones were found")); // subscriber.onCompleted(); // } // // queryContacts.close(); // } // }); // } // // } // Path: app/src/main/java/leonardo2204/com/br/flowtests/di/module/AppModule.java import android.app.Application; import android.content.ContentResolver; import android.content.Context; import android.content.SharedPreferences; import dagger.Module; import dagger.Provides; import leonardo2204.com.br.flowtests.UIThread; import leonardo2204.com.br.flowtests.data.executor.JobExecutor; import leonardo2204.com.br.flowtests.data.repository.ContactsRepositoryImpl; import leonardo2204.com.br.flowtests.di.scope.ApplicationScope; import leonardo2204.com.br.flowtests.domain.executor.PostExecutionThread; import leonardo2204.com.br.flowtests.domain.executor.ThreadExecutor; import leonardo2204.com.br.flowtests.domain.repository.ContactsRepository; return application; } @Provides @ApplicationScope public UIThread provideUIThread() { return new UIThread(); } @Provides @ApplicationScope public ThreadExecutor provideThreadExecutor(JobExecutor jobExecutor) { return jobExecutor; } @Provides @ApplicationScope public PostExecutionThread providePostExecutionThread(UIThread uiThread) { return uiThread; } @Provides @ApplicationScope public ContentResolver providesContentResolver() { return this.application.getContentResolver(); } @Provides @ApplicationScope public ContactsRepository providesContactsRepository(ContentResolver contentResolver) {
return new ContactsRepositoryImpl(contentResolver);
leonardo2204/Flow1.0.0-alphaExample
app/src/main/java/leonardo2204/com/br/flowtests/flow/dispatcher/MortarDispatcher.java
// Path: flow/src/main/java/flow/Dispatcher.java // public interface Dispatcher { // /** // * Called when the history is about to change. Note that Flow does not consider the // * Traversal to be finished, and will not actually update the history, until the callback is // * triggered. Traversals cannot be canceled. // * // * @param callback Must be called to indicate completion of the traversal. // */ // void dispatch(@NonNull Traversal traversal, @NonNull TraversalCallback callback); // } // // Path: flow/src/main/java/flow/KeyChanger.java // public interface KeyChanger { // void changeKey(@Nullable State outgoingState, @NonNull State incomingState, // @NonNull Direction direction, @NonNull Map<Object, Context> incomingContexts, // @NonNull TraversalCallback callback); // } // // Path: flow/src/main/java/flow/State.java // public class State { // /** Creates a State instance that has no state and is effectively immutable. */ // @NonNull public static State empty(@NonNull final Object key) { // return new EmptyState(key); // } // // @NonNull static State fromBundle(@NonNull Bundle savedState, @NonNull KeyParceler parceler) { // Object key = parceler.toKey(savedState.getParcelable("KEY")); // State state = new State(key); // state.viewState = savedState.getSparseParcelableArray("VIEW_STATE"); // state.bundle = savedState.getBundle("BUNDLE"); // return state; // } // // private final Object key; // @Nullable private Bundle bundle; // @Nullable SparseArray<Parcelable> viewState; // // State(Object key) { // // No external instances. // this.key = key; // } // // @NonNull public final <T> T getKey() { // @SuppressWarnings("unchecked") final T state = (T) key; // return state; // } // // public void save(@NonNull View view) { // SparseArray<Parcelable> state = new SparseArray<>(); // view.saveHierarchyState(state); // viewState = state; // } // // public void restore(@NonNull View view) { // if (viewState != null) { // view.restoreHierarchyState(viewState); // } // } // // public void setBundle(@Nullable Bundle bundle) { // this.bundle = bundle; // } // // @Nullable public Bundle getBundle() { // return bundle; // } // // Bundle toBundle(KeyParceler parceler) { // Bundle outState = new Bundle(); // outState.putParcelable("KEY", parceler.toParcelable(getKey())); // if (viewState != null && viewState.size() > 0) { // outState.putSparseParcelableArray("VIEW_STATE", viewState); // } // if (bundle != null && !bundle.isEmpty()) { // outState.putBundle("BUNDLE", bundle); // } // return outState; // } // // @Override public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // State state = (State) o; // return (getKey().equals(state.getKey())); // } // // @Override public int hashCode() { // return getKey().hashCode(); // } // // @Override public String toString() { // return getKey().toString(); // } // // private static final class EmptyState extends State { // public EmptyState(Object flowState) { // super(flowState); // } // // @Override public void save(@NonNull View view) { // } // // @Override public void restore(@NonNull View view) { // } // // @Override public void setBundle(Bundle bundle) { // } // // @Nullable @Override public Bundle getBundle() { // return null; // } // } // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/mortar/ScreenScoper.java // public class ScreenScoper { // // public MortarScope getScreenScope(MortarScope parentScope, String name, Object key) { // // parentScope = parentScope.findChild(RootActivity.class.getName()); // MortarScope childScope = parentScope.findChild(name); // // if (childScope != null) // return childScope; // // if (!(key instanceof InjectionComponent)) { // //throw new IllegalStateException(String.format(Locale.getDefault(),"The screen (%s) must implement InjectionComponent",key.getClass().getSimpleName())); // return null; // } // // InjectionComponent screenComponent = (InjectionComponent) key; // Object component = screenComponent.createComponent(parentScope.getService(DaggerService.SERVICE_NAME)); // // return parentScope.buildChild().withService(DaggerService.SERVICE_NAME, component).build(name); // } // // }
import android.app.Activity; import android.content.Context; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import java.util.Collections; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import flow.Direction; import flow.Dispatcher; import flow.KeyChanger; import flow.MultiKey; import flow.State; import flow.Traversal; import flow.TraversalCallback; import leonardo2204.com.br.flowtests.mortar.ScreenScoper;
package leonardo2204.com.br.flowtests.flow.dispatcher; /** * Created by Leonardo on 08/03/2016. */ public class MortarDispatcher implements Dispatcher { public static final class Builder { private final Activity activity;
// Path: flow/src/main/java/flow/Dispatcher.java // public interface Dispatcher { // /** // * Called when the history is about to change. Note that Flow does not consider the // * Traversal to be finished, and will not actually update the history, until the callback is // * triggered. Traversals cannot be canceled. // * // * @param callback Must be called to indicate completion of the traversal. // */ // void dispatch(@NonNull Traversal traversal, @NonNull TraversalCallback callback); // } // // Path: flow/src/main/java/flow/KeyChanger.java // public interface KeyChanger { // void changeKey(@Nullable State outgoingState, @NonNull State incomingState, // @NonNull Direction direction, @NonNull Map<Object, Context> incomingContexts, // @NonNull TraversalCallback callback); // } // // Path: flow/src/main/java/flow/State.java // public class State { // /** Creates a State instance that has no state and is effectively immutable. */ // @NonNull public static State empty(@NonNull final Object key) { // return new EmptyState(key); // } // // @NonNull static State fromBundle(@NonNull Bundle savedState, @NonNull KeyParceler parceler) { // Object key = parceler.toKey(savedState.getParcelable("KEY")); // State state = new State(key); // state.viewState = savedState.getSparseParcelableArray("VIEW_STATE"); // state.bundle = savedState.getBundle("BUNDLE"); // return state; // } // // private final Object key; // @Nullable private Bundle bundle; // @Nullable SparseArray<Parcelable> viewState; // // State(Object key) { // // No external instances. // this.key = key; // } // // @NonNull public final <T> T getKey() { // @SuppressWarnings("unchecked") final T state = (T) key; // return state; // } // // public void save(@NonNull View view) { // SparseArray<Parcelable> state = new SparseArray<>(); // view.saveHierarchyState(state); // viewState = state; // } // // public void restore(@NonNull View view) { // if (viewState != null) { // view.restoreHierarchyState(viewState); // } // } // // public void setBundle(@Nullable Bundle bundle) { // this.bundle = bundle; // } // // @Nullable public Bundle getBundle() { // return bundle; // } // // Bundle toBundle(KeyParceler parceler) { // Bundle outState = new Bundle(); // outState.putParcelable("KEY", parceler.toParcelable(getKey())); // if (viewState != null && viewState.size() > 0) { // outState.putSparseParcelableArray("VIEW_STATE", viewState); // } // if (bundle != null && !bundle.isEmpty()) { // outState.putBundle("BUNDLE", bundle); // } // return outState; // } // // @Override public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // State state = (State) o; // return (getKey().equals(state.getKey())); // } // // @Override public int hashCode() { // return getKey().hashCode(); // } // // @Override public String toString() { // return getKey().toString(); // } // // private static final class EmptyState extends State { // public EmptyState(Object flowState) { // super(flowState); // } // // @Override public void save(@NonNull View view) { // } // // @Override public void restore(@NonNull View view) { // } // // @Override public void setBundle(Bundle bundle) { // } // // @Nullable @Override public Bundle getBundle() { // return null; // } // } // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/mortar/ScreenScoper.java // public class ScreenScoper { // // public MortarScope getScreenScope(MortarScope parentScope, String name, Object key) { // // parentScope = parentScope.findChild(RootActivity.class.getName()); // MortarScope childScope = parentScope.findChild(name); // // if (childScope != null) // return childScope; // // if (!(key instanceof InjectionComponent)) { // //throw new IllegalStateException(String.format(Locale.getDefault(),"The screen (%s) must implement InjectionComponent",key.getClass().getSimpleName())); // return null; // } // // InjectionComponent screenComponent = (InjectionComponent) key; // Object component = screenComponent.createComponent(parentScope.getService(DaggerService.SERVICE_NAME)); // // return parentScope.buildChild().withService(DaggerService.SERVICE_NAME, component).build(name); // } // // } // Path: app/src/main/java/leonardo2204/com/br/flowtests/flow/dispatcher/MortarDispatcher.java import android.app.Activity; import android.content.Context; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import java.util.Collections; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import flow.Direction; import flow.Dispatcher; import flow.KeyChanger; import flow.MultiKey; import flow.State; import flow.Traversal; import flow.TraversalCallback; import leonardo2204.com.br.flowtests.mortar.ScreenScoper; package leonardo2204.com.br.flowtests.flow.dispatcher; /** * Created by Leonardo on 08/03/2016. */ public class MortarDispatcher implements Dispatcher { public static final class Builder { private final Activity activity;
private final KeyChanger keyChanger;
leonardo2204/Flow1.0.0-alphaExample
app/src/main/java/leonardo2204/com/br/flowtests/flow/dispatcher/MortarDispatcher.java
// Path: flow/src/main/java/flow/Dispatcher.java // public interface Dispatcher { // /** // * Called when the history is about to change. Note that Flow does not consider the // * Traversal to be finished, and will not actually update the history, until the callback is // * triggered. Traversals cannot be canceled. // * // * @param callback Must be called to indicate completion of the traversal. // */ // void dispatch(@NonNull Traversal traversal, @NonNull TraversalCallback callback); // } // // Path: flow/src/main/java/flow/KeyChanger.java // public interface KeyChanger { // void changeKey(@Nullable State outgoingState, @NonNull State incomingState, // @NonNull Direction direction, @NonNull Map<Object, Context> incomingContexts, // @NonNull TraversalCallback callback); // } // // Path: flow/src/main/java/flow/State.java // public class State { // /** Creates a State instance that has no state and is effectively immutable. */ // @NonNull public static State empty(@NonNull final Object key) { // return new EmptyState(key); // } // // @NonNull static State fromBundle(@NonNull Bundle savedState, @NonNull KeyParceler parceler) { // Object key = parceler.toKey(savedState.getParcelable("KEY")); // State state = new State(key); // state.viewState = savedState.getSparseParcelableArray("VIEW_STATE"); // state.bundle = savedState.getBundle("BUNDLE"); // return state; // } // // private final Object key; // @Nullable private Bundle bundle; // @Nullable SparseArray<Parcelable> viewState; // // State(Object key) { // // No external instances. // this.key = key; // } // // @NonNull public final <T> T getKey() { // @SuppressWarnings("unchecked") final T state = (T) key; // return state; // } // // public void save(@NonNull View view) { // SparseArray<Parcelable> state = new SparseArray<>(); // view.saveHierarchyState(state); // viewState = state; // } // // public void restore(@NonNull View view) { // if (viewState != null) { // view.restoreHierarchyState(viewState); // } // } // // public void setBundle(@Nullable Bundle bundle) { // this.bundle = bundle; // } // // @Nullable public Bundle getBundle() { // return bundle; // } // // Bundle toBundle(KeyParceler parceler) { // Bundle outState = new Bundle(); // outState.putParcelable("KEY", parceler.toParcelable(getKey())); // if (viewState != null && viewState.size() > 0) { // outState.putSparseParcelableArray("VIEW_STATE", viewState); // } // if (bundle != null && !bundle.isEmpty()) { // outState.putBundle("BUNDLE", bundle); // } // return outState; // } // // @Override public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // State state = (State) o; // return (getKey().equals(state.getKey())); // } // // @Override public int hashCode() { // return getKey().hashCode(); // } // // @Override public String toString() { // return getKey().toString(); // } // // private static final class EmptyState extends State { // public EmptyState(Object flowState) { // super(flowState); // } // // @Override public void save(@NonNull View view) { // } // // @Override public void restore(@NonNull View view) { // } // // @Override public void setBundle(Bundle bundle) { // } // // @Nullable @Override public Bundle getBundle() { // return null; // } // } // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/mortar/ScreenScoper.java // public class ScreenScoper { // // public MortarScope getScreenScope(MortarScope parentScope, String name, Object key) { // // parentScope = parentScope.findChild(RootActivity.class.getName()); // MortarScope childScope = parentScope.findChild(name); // // if (childScope != null) // return childScope; // // if (!(key instanceof InjectionComponent)) { // //throw new IllegalStateException(String.format(Locale.getDefault(),"The screen (%s) must implement InjectionComponent",key.getClass().getSimpleName())); // return null; // } // // InjectionComponent screenComponent = (InjectionComponent) key; // Object component = screenComponent.createComponent(parentScope.getService(DaggerService.SERVICE_NAME)); // // return parentScope.buildChild().withService(DaggerService.SERVICE_NAME, component).build(name); // } // // }
import android.app.Activity; import android.content.Context; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import java.util.Collections; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import flow.Direction; import flow.Dispatcher; import flow.KeyChanger; import flow.MultiKey; import flow.State; import flow.Traversal; import flow.TraversalCallback; import leonardo2204.com.br.flowtests.mortar.ScreenScoper;
package leonardo2204.com.br.flowtests.flow.dispatcher; /** * Created by Leonardo on 08/03/2016. */ public class MortarDispatcher implements Dispatcher { public static final class Builder { private final Activity activity; private final KeyChanger keyChanger; private Builder(Activity activity, KeyChanger keyChanger) { this.activity = activity; this.keyChanger = keyChanger; } public Dispatcher build() { return new MortarDispatcher(activity, this.keyChanger); } } public static Builder configure(Activity activity, KeyChanger changer) { return new Builder(activity, changer); } private final Activity activity; private final KeyChanger keyChanger; private MortarDispatcher(Activity activity, KeyChanger keyChanger) { this.activity = activity; this.keyChanger = keyChanger; } @Override public void dispatch(@NonNull Traversal traversal, @NonNull TraversalCallback callback) {
// Path: flow/src/main/java/flow/Dispatcher.java // public interface Dispatcher { // /** // * Called when the history is about to change. Note that Flow does not consider the // * Traversal to be finished, and will not actually update the history, until the callback is // * triggered. Traversals cannot be canceled. // * // * @param callback Must be called to indicate completion of the traversal. // */ // void dispatch(@NonNull Traversal traversal, @NonNull TraversalCallback callback); // } // // Path: flow/src/main/java/flow/KeyChanger.java // public interface KeyChanger { // void changeKey(@Nullable State outgoingState, @NonNull State incomingState, // @NonNull Direction direction, @NonNull Map<Object, Context> incomingContexts, // @NonNull TraversalCallback callback); // } // // Path: flow/src/main/java/flow/State.java // public class State { // /** Creates a State instance that has no state and is effectively immutable. */ // @NonNull public static State empty(@NonNull final Object key) { // return new EmptyState(key); // } // // @NonNull static State fromBundle(@NonNull Bundle savedState, @NonNull KeyParceler parceler) { // Object key = parceler.toKey(savedState.getParcelable("KEY")); // State state = new State(key); // state.viewState = savedState.getSparseParcelableArray("VIEW_STATE"); // state.bundle = savedState.getBundle("BUNDLE"); // return state; // } // // private final Object key; // @Nullable private Bundle bundle; // @Nullable SparseArray<Parcelable> viewState; // // State(Object key) { // // No external instances. // this.key = key; // } // // @NonNull public final <T> T getKey() { // @SuppressWarnings("unchecked") final T state = (T) key; // return state; // } // // public void save(@NonNull View view) { // SparseArray<Parcelable> state = new SparseArray<>(); // view.saveHierarchyState(state); // viewState = state; // } // // public void restore(@NonNull View view) { // if (viewState != null) { // view.restoreHierarchyState(viewState); // } // } // // public void setBundle(@Nullable Bundle bundle) { // this.bundle = bundle; // } // // @Nullable public Bundle getBundle() { // return bundle; // } // // Bundle toBundle(KeyParceler parceler) { // Bundle outState = new Bundle(); // outState.putParcelable("KEY", parceler.toParcelable(getKey())); // if (viewState != null && viewState.size() > 0) { // outState.putSparseParcelableArray("VIEW_STATE", viewState); // } // if (bundle != null && !bundle.isEmpty()) { // outState.putBundle("BUNDLE", bundle); // } // return outState; // } // // @Override public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // State state = (State) o; // return (getKey().equals(state.getKey())); // } // // @Override public int hashCode() { // return getKey().hashCode(); // } // // @Override public String toString() { // return getKey().toString(); // } // // private static final class EmptyState extends State { // public EmptyState(Object flowState) { // super(flowState); // } // // @Override public void save(@NonNull View view) { // } // // @Override public void restore(@NonNull View view) { // } // // @Override public void setBundle(Bundle bundle) { // } // // @Nullable @Override public Bundle getBundle() { // return null; // } // } // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/mortar/ScreenScoper.java // public class ScreenScoper { // // public MortarScope getScreenScope(MortarScope parentScope, String name, Object key) { // // parentScope = parentScope.findChild(RootActivity.class.getName()); // MortarScope childScope = parentScope.findChild(name); // // if (childScope != null) // return childScope; // // if (!(key instanceof InjectionComponent)) { // //throw new IllegalStateException(String.format(Locale.getDefault(),"The screen (%s) must implement InjectionComponent",key.getClass().getSimpleName())); // return null; // } // // InjectionComponent screenComponent = (InjectionComponent) key; // Object component = screenComponent.createComponent(parentScope.getService(DaggerService.SERVICE_NAME)); // // return parentScope.buildChild().withService(DaggerService.SERVICE_NAME, component).build(name); // } // // } // Path: app/src/main/java/leonardo2204/com/br/flowtests/flow/dispatcher/MortarDispatcher.java import android.app.Activity; import android.content.Context; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import java.util.Collections; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import flow.Direction; import flow.Dispatcher; import flow.KeyChanger; import flow.MultiKey; import flow.State; import flow.Traversal; import flow.TraversalCallback; import leonardo2204.com.br.flowtests.mortar.ScreenScoper; package leonardo2204.com.br.flowtests.flow.dispatcher; /** * Created by Leonardo on 08/03/2016. */ public class MortarDispatcher implements Dispatcher { public static final class Builder { private final Activity activity; private final KeyChanger keyChanger; private Builder(Activity activity, KeyChanger keyChanger) { this.activity = activity; this.keyChanger = keyChanger; } public Dispatcher build() { return new MortarDispatcher(activity, this.keyChanger); } } public static Builder configure(Activity activity, KeyChanger changer) { return new Builder(activity, changer); } private final Activity activity; private final KeyChanger keyChanger; private MortarDispatcher(Activity activity, KeyChanger keyChanger) { this.activity = activity; this.keyChanger = keyChanger; } @Override public void dispatch(@NonNull Traversal traversal, @NonNull TraversalCallback callback) {
State inState = traversal.getState(traversal.destination.top());
leonardo2204/Flow1.0.0-alphaExample
app/src/main/java/leonardo2204/com/br/flowtests/flow/dispatcher/MortarDispatcher.java
// Path: flow/src/main/java/flow/Dispatcher.java // public interface Dispatcher { // /** // * Called when the history is about to change. Note that Flow does not consider the // * Traversal to be finished, and will not actually update the history, until the callback is // * triggered. Traversals cannot be canceled. // * // * @param callback Must be called to indicate completion of the traversal. // */ // void dispatch(@NonNull Traversal traversal, @NonNull TraversalCallback callback); // } // // Path: flow/src/main/java/flow/KeyChanger.java // public interface KeyChanger { // void changeKey(@Nullable State outgoingState, @NonNull State incomingState, // @NonNull Direction direction, @NonNull Map<Object, Context> incomingContexts, // @NonNull TraversalCallback callback); // } // // Path: flow/src/main/java/flow/State.java // public class State { // /** Creates a State instance that has no state and is effectively immutable. */ // @NonNull public static State empty(@NonNull final Object key) { // return new EmptyState(key); // } // // @NonNull static State fromBundle(@NonNull Bundle savedState, @NonNull KeyParceler parceler) { // Object key = parceler.toKey(savedState.getParcelable("KEY")); // State state = new State(key); // state.viewState = savedState.getSparseParcelableArray("VIEW_STATE"); // state.bundle = savedState.getBundle("BUNDLE"); // return state; // } // // private final Object key; // @Nullable private Bundle bundle; // @Nullable SparseArray<Parcelable> viewState; // // State(Object key) { // // No external instances. // this.key = key; // } // // @NonNull public final <T> T getKey() { // @SuppressWarnings("unchecked") final T state = (T) key; // return state; // } // // public void save(@NonNull View view) { // SparseArray<Parcelable> state = new SparseArray<>(); // view.saveHierarchyState(state); // viewState = state; // } // // public void restore(@NonNull View view) { // if (viewState != null) { // view.restoreHierarchyState(viewState); // } // } // // public void setBundle(@Nullable Bundle bundle) { // this.bundle = bundle; // } // // @Nullable public Bundle getBundle() { // return bundle; // } // // Bundle toBundle(KeyParceler parceler) { // Bundle outState = new Bundle(); // outState.putParcelable("KEY", parceler.toParcelable(getKey())); // if (viewState != null && viewState.size() > 0) { // outState.putSparseParcelableArray("VIEW_STATE", viewState); // } // if (bundle != null && !bundle.isEmpty()) { // outState.putBundle("BUNDLE", bundle); // } // return outState; // } // // @Override public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // State state = (State) o; // return (getKey().equals(state.getKey())); // } // // @Override public int hashCode() { // return getKey().hashCode(); // } // // @Override public String toString() { // return getKey().toString(); // } // // private static final class EmptyState extends State { // public EmptyState(Object flowState) { // super(flowState); // } // // @Override public void save(@NonNull View view) { // } // // @Override public void restore(@NonNull View view) { // } // // @Override public void setBundle(Bundle bundle) { // } // // @Nullable @Override public Bundle getBundle() { // return null; // } // } // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/mortar/ScreenScoper.java // public class ScreenScoper { // // public MortarScope getScreenScope(MortarScope parentScope, String name, Object key) { // // parentScope = parentScope.findChild(RootActivity.class.getName()); // MortarScope childScope = parentScope.findChild(name); // // if (childScope != null) // return childScope; // // if (!(key instanceof InjectionComponent)) { // //throw new IllegalStateException(String.format(Locale.getDefault(),"The screen (%s) must implement InjectionComponent",key.getClass().getSimpleName())); // return null; // } // // InjectionComponent screenComponent = (InjectionComponent) key; // Object component = screenComponent.createComponent(parentScope.getService(DaggerService.SERVICE_NAME)); // // return parentScope.buildChild().withService(DaggerService.SERVICE_NAME, component).build(name); // } // // }
import android.app.Activity; import android.content.Context; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import java.util.Collections; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import flow.Direction; import flow.Dispatcher; import flow.KeyChanger; import flow.MultiKey; import flow.State; import flow.Traversal; import flow.TraversalCallback; import leonardo2204.com.br.flowtests.mortar.ScreenScoper;
public Dispatcher build() { return new MortarDispatcher(activity, this.keyChanger); } } public static Builder configure(Activity activity, KeyChanger changer) { return new Builder(activity, changer); } private final Activity activity; private final KeyChanger keyChanger; private MortarDispatcher(Activity activity, KeyChanger keyChanger) { this.activity = activity; this.keyChanger = keyChanger; } @Override public void dispatch(@NonNull Traversal traversal, @NonNull TraversalCallback callback) { State inState = traversal.getState(traversal.destination.top()); Object inKey = inState.getKey(); State outState = traversal.origin == null ? null : traversal.getState(traversal.origin.top()); Object outKey = outState == null ? null : outState.getKey(); // TODO(#126): short-circuit may belong in Flow, since every Dispatcher we have implements it. if (inKey.equals(outKey)) { callback.onTraversalCompleted(); return; }
// Path: flow/src/main/java/flow/Dispatcher.java // public interface Dispatcher { // /** // * Called when the history is about to change. Note that Flow does not consider the // * Traversal to be finished, and will not actually update the history, until the callback is // * triggered. Traversals cannot be canceled. // * // * @param callback Must be called to indicate completion of the traversal. // */ // void dispatch(@NonNull Traversal traversal, @NonNull TraversalCallback callback); // } // // Path: flow/src/main/java/flow/KeyChanger.java // public interface KeyChanger { // void changeKey(@Nullable State outgoingState, @NonNull State incomingState, // @NonNull Direction direction, @NonNull Map<Object, Context> incomingContexts, // @NonNull TraversalCallback callback); // } // // Path: flow/src/main/java/flow/State.java // public class State { // /** Creates a State instance that has no state and is effectively immutable. */ // @NonNull public static State empty(@NonNull final Object key) { // return new EmptyState(key); // } // // @NonNull static State fromBundle(@NonNull Bundle savedState, @NonNull KeyParceler parceler) { // Object key = parceler.toKey(savedState.getParcelable("KEY")); // State state = new State(key); // state.viewState = savedState.getSparseParcelableArray("VIEW_STATE"); // state.bundle = savedState.getBundle("BUNDLE"); // return state; // } // // private final Object key; // @Nullable private Bundle bundle; // @Nullable SparseArray<Parcelable> viewState; // // State(Object key) { // // No external instances. // this.key = key; // } // // @NonNull public final <T> T getKey() { // @SuppressWarnings("unchecked") final T state = (T) key; // return state; // } // // public void save(@NonNull View view) { // SparseArray<Parcelable> state = new SparseArray<>(); // view.saveHierarchyState(state); // viewState = state; // } // // public void restore(@NonNull View view) { // if (viewState != null) { // view.restoreHierarchyState(viewState); // } // } // // public void setBundle(@Nullable Bundle bundle) { // this.bundle = bundle; // } // // @Nullable public Bundle getBundle() { // return bundle; // } // // Bundle toBundle(KeyParceler parceler) { // Bundle outState = new Bundle(); // outState.putParcelable("KEY", parceler.toParcelable(getKey())); // if (viewState != null && viewState.size() > 0) { // outState.putSparseParcelableArray("VIEW_STATE", viewState); // } // if (bundle != null && !bundle.isEmpty()) { // outState.putBundle("BUNDLE", bundle); // } // return outState; // } // // @Override public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // State state = (State) o; // return (getKey().equals(state.getKey())); // } // // @Override public int hashCode() { // return getKey().hashCode(); // } // // @Override public String toString() { // return getKey().toString(); // } // // private static final class EmptyState extends State { // public EmptyState(Object flowState) { // super(flowState); // } // // @Override public void save(@NonNull View view) { // } // // @Override public void restore(@NonNull View view) { // } // // @Override public void setBundle(Bundle bundle) { // } // // @Nullable @Override public Bundle getBundle() { // return null; // } // } // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/mortar/ScreenScoper.java // public class ScreenScoper { // // public MortarScope getScreenScope(MortarScope parentScope, String name, Object key) { // // parentScope = parentScope.findChild(RootActivity.class.getName()); // MortarScope childScope = parentScope.findChild(name); // // if (childScope != null) // return childScope; // // if (!(key instanceof InjectionComponent)) { // //throw new IllegalStateException(String.format(Locale.getDefault(),"The screen (%s) must implement InjectionComponent",key.getClass().getSimpleName())); // return null; // } // // InjectionComponent screenComponent = (InjectionComponent) key; // Object component = screenComponent.createComponent(parentScope.getService(DaggerService.SERVICE_NAME)); // // return parentScope.buildChild().withService(DaggerService.SERVICE_NAME, component).build(name); // } // // } // Path: app/src/main/java/leonardo2204/com/br/flowtests/flow/dispatcher/MortarDispatcher.java import android.app.Activity; import android.content.Context; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import java.util.Collections; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import flow.Direction; import flow.Dispatcher; import flow.KeyChanger; import flow.MultiKey; import flow.State; import flow.Traversal; import flow.TraversalCallback; import leonardo2204.com.br.flowtests.mortar.ScreenScoper; public Dispatcher build() { return new MortarDispatcher(activity, this.keyChanger); } } public static Builder configure(Activity activity, KeyChanger changer) { return new Builder(activity, changer); } private final Activity activity; private final KeyChanger keyChanger; private MortarDispatcher(Activity activity, KeyChanger keyChanger) { this.activity = activity; this.keyChanger = keyChanger; } @Override public void dispatch(@NonNull Traversal traversal, @NonNull TraversalCallback callback) { State inState = traversal.getState(traversal.destination.top()); Object inKey = inState.getKey(); State outState = traversal.origin == null ? null : traversal.getState(traversal.origin.top()); Object outKey = outState == null ? null : outState.getKey(); // TODO(#126): short-circuit may belong in Flow, since every Dispatcher we have implements it. if (inKey.equals(outKey)) { callback.onTraversalCompleted(); return; }
ScreenScoper scoper = new ScreenScoper();
leonardo2204/Flow1.0.0-alphaExample
app/src/main/java/leonardo2204/com/br/flowtests/di/component/AppComponent.java
// Path: app/src/main/java/leonardo2204/com/br/flowtests/FlowTestApplication.java // public class FlowTestApplication extends Application { // // private MortarScope mortarScope; // // @Override // public Object getSystemService(String name) { // if(mortarScope == null){ // setupMortar(); // } // // return (mortarScope.hasService(name)) ? mortarScope.getService(name) : super.getSystemService(name); // } // // @Override // public void onCreate() { // super.onCreate(); // LeakCanary.install(this); // } // // private void setupMortar(){ // AppComponent component = DaggerAppComponent // .builder() // .appModule(new AppModule(this)) // .build(); // // component.inject(this); // // mortarScope = MortarScope.buildRootScope() // .withService(DaggerService.SERVICE_NAME,component) // .build("Root"); // } // // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/di/module/AppModule.java // @Module // public class AppModule { // // private final static String SHARED_NAME = "global_config"; // private final Application application; // // public AppModule(Application application) { // this.application = application; // } // // @Provides // @ApplicationScope // public Application providesApplication() { // return application; // } // // @Provides // @ApplicationScope // public UIThread provideUIThread() { // return new UIThread(); // } // // @Provides // @ApplicationScope // public ThreadExecutor provideThreadExecutor(JobExecutor jobExecutor) { // return jobExecutor; // } // // @Provides // @ApplicationScope // public PostExecutionThread providePostExecutionThread(UIThread uiThread) { // return uiThread; // } // // @Provides // @ApplicationScope // public ContentResolver providesContentResolver() { // return this.application.getContentResolver(); // } // // @Provides // @ApplicationScope // public ContactsRepository providesContactsRepository(ContentResolver contentResolver) { // return new ContactsRepositoryImpl(contentResolver); // } // // @Provides // @ApplicationScope // public SharedPreferences providesSharedPreferences() { // return this.application.getSharedPreferences(SHARED_NAME, Context.MODE_PRIVATE); // } // }
import android.content.SharedPreferences; import dagger.Component; import leonardo2204.com.br.flowtests.FlowTestApplication; import leonardo2204.com.br.flowtests.UIThread; import leonardo2204.com.br.flowtests.di.module.AppModule; import leonardo2204.com.br.flowtests.di.scope.ApplicationScope; import leonardo2204.com.br.flowtests.domain.executor.PostExecutionThread; import leonardo2204.com.br.flowtests.domain.executor.ThreadExecutor; import leonardo2204.com.br.flowtests.domain.repository.ContactsRepository;
package leonardo2204.com.br.flowtests.di.component; /** * Created by Leonardo on 04/03/2016. */ @ApplicationScope @Component(modules = AppModule.class) public interface AppComponent {
// Path: app/src/main/java/leonardo2204/com/br/flowtests/FlowTestApplication.java // public class FlowTestApplication extends Application { // // private MortarScope mortarScope; // // @Override // public Object getSystemService(String name) { // if(mortarScope == null){ // setupMortar(); // } // // return (mortarScope.hasService(name)) ? mortarScope.getService(name) : super.getSystemService(name); // } // // @Override // public void onCreate() { // super.onCreate(); // LeakCanary.install(this); // } // // private void setupMortar(){ // AppComponent component = DaggerAppComponent // .builder() // .appModule(new AppModule(this)) // .build(); // // component.inject(this); // // mortarScope = MortarScope.buildRootScope() // .withService(DaggerService.SERVICE_NAME,component) // .build("Root"); // } // // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/di/module/AppModule.java // @Module // public class AppModule { // // private final static String SHARED_NAME = "global_config"; // private final Application application; // // public AppModule(Application application) { // this.application = application; // } // // @Provides // @ApplicationScope // public Application providesApplication() { // return application; // } // // @Provides // @ApplicationScope // public UIThread provideUIThread() { // return new UIThread(); // } // // @Provides // @ApplicationScope // public ThreadExecutor provideThreadExecutor(JobExecutor jobExecutor) { // return jobExecutor; // } // // @Provides // @ApplicationScope // public PostExecutionThread providePostExecutionThread(UIThread uiThread) { // return uiThread; // } // // @Provides // @ApplicationScope // public ContentResolver providesContentResolver() { // return this.application.getContentResolver(); // } // // @Provides // @ApplicationScope // public ContactsRepository providesContactsRepository(ContentResolver contentResolver) { // return new ContactsRepositoryImpl(contentResolver); // } // // @Provides // @ApplicationScope // public SharedPreferences providesSharedPreferences() { // return this.application.getSharedPreferences(SHARED_NAME, Context.MODE_PRIVATE); // } // } // Path: app/src/main/java/leonardo2204/com/br/flowtests/di/component/AppComponent.java import android.content.SharedPreferences; import dagger.Component; import leonardo2204.com.br.flowtests.FlowTestApplication; import leonardo2204.com.br.flowtests.UIThread; import leonardo2204.com.br.flowtests.di.module.AppModule; import leonardo2204.com.br.flowtests.di.scope.ApplicationScope; import leonardo2204.com.br.flowtests.domain.executor.PostExecutionThread; import leonardo2204.com.br.flowtests.domain.executor.ThreadExecutor; import leonardo2204.com.br.flowtests.domain.repository.ContactsRepository; package leonardo2204.com.br.flowtests.di.component; /** * Created by Leonardo on 04/03/2016. */ @ApplicationScope @Component(modules = AppModule.class) public interface AppComponent {
void inject(FlowTestApplication flowTestApplication);
leonardo2204/Flow1.0.0-alphaExample
app/src/main/java/leonardo2204/com/br/flowtests/data/repository/ContactsRepositoryImpl.java
// Path: app/src/main/java/leonardo2204/com/br/flowtests/model/Contact.java // @Parcel // public class Contact { // // //Don't use private fields, due to reflection penalties using @Parcel // String id; // String name; // List<String> telephone; // // public Contact() { // } // // @ParcelConstructor // public Contact(String id, String name, List<String> telephone) { // this.id = id; // this.name = name; // this.telephone = telephone; // } // // public String getId() { // return id; // } // // public void setId(String id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public List<String> getTelephone() { // return telephone; // } // // public void setTelephone(List<String> telephone) { // this.telephone = telephone; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // Contact contact = (Contact) o; // // return id.equals(contact.id); // // } // // @Override // public int hashCode() { // return id.hashCode(); // } // // @Override // public String toString() { // return "Contact{" + // "id='" + id + '\'' + // ", name='" + name + '\'' + // '}'; // } // }
import android.content.ContentResolver; import android.database.Cursor; import android.provider.ContactsContract; import java.util.ArrayList; import java.util.List; import leonardo2204.com.br.flowtests.domain.repository.ContactsRepository; import leonardo2204.com.br.flowtests.model.Contact; import rx.Observable; import rx.Subscriber;
package leonardo2204.com.br.flowtests.data.repository; /** * Created by Leonardo on 05/03/2016. */ public class ContactsRepositoryImpl implements ContactsRepository { private final ContentResolver contentResolver; public ContactsRepositoryImpl(ContentResolver contentResolver) { this.contentResolver = contentResolver; } @Override
// Path: app/src/main/java/leonardo2204/com/br/flowtests/model/Contact.java // @Parcel // public class Contact { // // //Don't use private fields, due to reflection penalties using @Parcel // String id; // String name; // List<String> telephone; // // public Contact() { // } // // @ParcelConstructor // public Contact(String id, String name, List<String> telephone) { // this.id = id; // this.name = name; // this.telephone = telephone; // } // // public String getId() { // return id; // } // // public void setId(String id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public List<String> getTelephone() { // return telephone; // } // // public void setTelephone(List<String> telephone) { // this.telephone = telephone; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // Contact contact = (Contact) o; // // return id.equals(contact.id); // // } // // @Override // public int hashCode() { // return id.hashCode(); // } // // @Override // public String toString() { // return "Contact{" + // "id='" + id + '\'' + // ", name='" + name + '\'' + // '}'; // } // } // Path: app/src/main/java/leonardo2204/com/br/flowtests/data/repository/ContactsRepositoryImpl.java import android.content.ContentResolver; import android.database.Cursor; import android.provider.ContactsContract; import java.util.ArrayList; import java.util.List; import leonardo2204.com.br.flowtests.domain.repository.ContactsRepository; import leonardo2204.com.br.flowtests.model.Contact; import rx.Observable; import rx.Subscriber; package leonardo2204.com.br.flowtests.data.repository; /** * Created by Leonardo on 05/03/2016. */ public class ContactsRepositoryImpl implements ContactsRepository { private final ContentResolver contentResolver; public ContactsRepositoryImpl(ContentResolver contentResolver) { this.contentResolver = contentResolver; } @Override
public Observable<List<Contact>> getContactsFromPhone(final boolean mustHaveNumber) {
leonardo2204/Flow1.0.0-alphaExample
app/src/main/java/leonardo2204/com/br/flowtests/flow/serviceFactory/DaggerServiceFactory.java
// Path: flow/src/main/java/flow/Services.java // public class Services { // static final Services ROOT_SERVICES = // new Services(Flow.ROOT_KEY, null, Collections.<String, Object>emptyMap()); // // public static final class Binder extends Services { // private final Map<String, Object> services = new LinkedHashMap<>(); // private final Services base; // // private Binder(Services base, Object key) { // super(key, base, Collections.<String, Object>emptyMap()); // checkNotNull(base, "only root Services should have a null base"); // this.base = base; // } // // @NonNull public Binder bind(@NonNull String serviceName, @NonNull Object service) { // services.put(serviceName, service); // return this; // } // // @NonNull Services build() { // return new Services(getKey(), base, services); // } // } // // private final Object key; // @Nullable private final Services delegate; // private final Map<String, Object> localServices = new LinkedHashMap<>(); // // private Services(Object key, @Nullable Services delegate, Map<String, Object> localServices) { // this.delegate = delegate; // this.key = key; // this.localServices.putAll(localServices); // } // // @Nullable public <T> T getService(@NonNull String name) { // if (localServices.containsKey(name)) { // @SuppressWarnings("unchecked") // // final T service = (T) localServices.get(name); // return service; // } // if (delegate != null) return delegate.getService(name); // return null; // } // // @NonNull public <T> T getKey() { // //noinspection unchecked // return (T) this.key; // } // // @NonNull Binder extend(@NonNull Object key) { // return new Binder(this, key); // } // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/flow/keys/ContactsUIKey.java // public class ContactsUIKey extends ClassKey { // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/flow/keys/EditContactKey.java // public final class EditContactKey extends ContactKey implements TreeKey { // // public EditContactKey(Contact contact) { // super(contact); // } // // @NonNull // @Override // public Object getParentKey() { // return new ContactsUIKey(); // } // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/mortar/ScreenScoper.java // public class ScreenScoper { // // public MortarScope getScreenScope(MortarScope parentScope, String name, Object key) { // // parentScope = parentScope.findChild(RootActivity.class.getName()); // MortarScope childScope = parentScope.findChild(name); // // if (childScope != null) // return childScope; // // if (!(key instanceof InjectionComponent)) { // //throw new IllegalStateException(String.format(Locale.getDefault(),"The screen (%s) must implement InjectionComponent",key.getClass().getSimpleName())); // return null; // } // // InjectionComponent screenComponent = (InjectionComponent) key; // Object component = screenComponent.createComponent(parentScope.getService(DaggerService.SERVICE_NAME)); // // return parentScope.buildChild().withService(DaggerService.SERVICE_NAME, component).build(name); // } // // }
import android.util.Log; import flow.Services; import flow.ServicesFactory; import leonardo2204.com.br.flowtests.flow.keys.ContactsUIKey; import leonardo2204.com.br.flowtests.flow.keys.EditContactKey; import leonardo2204.com.br.flowtests.mortar.ScreenScoper; import mortar.MortarScope;
package leonardo2204.com.br.flowtests.flow.serviceFactory; /** * Created by Leonardo on 04/03/2016. */ public class DaggerServiceFactory extends ServicesFactory { private final MortarScope parentScope;
// Path: flow/src/main/java/flow/Services.java // public class Services { // static final Services ROOT_SERVICES = // new Services(Flow.ROOT_KEY, null, Collections.<String, Object>emptyMap()); // // public static final class Binder extends Services { // private final Map<String, Object> services = new LinkedHashMap<>(); // private final Services base; // // private Binder(Services base, Object key) { // super(key, base, Collections.<String, Object>emptyMap()); // checkNotNull(base, "only root Services should have a null base"); // this.base = base; // } // // @NonNull public Binder bind(@NonNull String serviceName, @NonNull Object service) { // services.put(serviceName, service); // return this; // } // // @NonNull Services build() { // return new Services(getKey(), base, services); // } // } // // private final Object key; // @Nullable private final Services delegate; // private final Map<String, Object> localServices = new LinkedHashMap<>(); // // private Services(Object key, @Nullable Services delegate, Map<String, Object> localServices) { // this.delegate = delegate; // this.key = key; // this.localServices.putAll(localServices); // } // // @Nullable public <T> T getService(@NonNull String name) { // if (localServices.containsKey(name)) { // @SuppressWarnings("unchecked") // // final T service = (T) localServices.get(name); // return service; // } // if (delegate != null) return delegate.getService(name); // return null; // } // // @NonNull public <T> T getKey() { // //noinspection unchecked // return (T) this.key; // } // // @NonNull Binder extend(@NonNull Object key) { // return new Binder(this, key); // } // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/flow/keys/ContactsUIKey.java // public class ContactsUIKey extends ClassKey { // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/flow/keys/EditContactKey.java // public final class EditContactKey extends ContactKey implements TreeKey { // // public EditContactKey(Contact contact) { // super(contact); // } // // @NonNull // @Override // public Object getParentKey() { // return new ContactsUIKey(); // } // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/mortar/ScreenScoper.java // public class ScreenScoper { // // public MortarScope getScreenScope(MortarScope parentScope, String name, Object key) { // // parentScope = parentScope.findChild(RootActivity.class.getName()); // MortarScope childScope = parentScope.findChild(name); // // if (childScope != null) // return childScope; // // if (!(key instanceof InjectionComponent)) { // //throw new IllegalStateException(String.format(Locale.getDefault(),"The screen (%s) must implement InjectionComponent",key.getClass().getSimpleName())); // return null; // } // // InjectionComponent screenComponent = (InjectionComponent) key; // Object component = screenComponent.createComponent(parentScope.getService(DaggerService.SERVICE_NAME)); // // return parentScope.buildChild().withService(DaggerService.SERVICE_NAME, component).build(name); // } // // } // Path: app/src/main/java/leonardo2204/com/br/flowtests/flow/serviceFactory/DaggerServiceFactory.java import android.util.Log; import flow.Services; import flow.ServicesFactory; import leonardo2204.com.br.flowtests.flow.keys.ContactsUIKey; import leonardo2204.com.br.flowtests.flow.keys.EditContactKey; import leonardo2204.com.br.flowtests.mortar.ScreenScoper; import mortar.MortarScope; package leonardo2204.com.br.flowtests.flow.serviceFactory; /** * Created by Leonardo on 04/03/2016. */ public class DaggerServiceFactory extends ServicesFactory { private final MortarScope parentScope;
private final ScreenScoper screenScoper;
leonardo2204/Flow1.0.0-alphaExample
app/src/main/java/leonardo2204/com/br/flowtests/flow/serviceFactory/DaggerServiceFactory.java
// Path: flow/src/main/java/flow/Services.java // public class Services { // static final Services ROOT_SERVICES = // new Services(Flow.ROOT_KEY, null, Collections.<String, Object>emptyMap()); // // public static final class Binder extends Services { // private final Map<String, Object> services = new LinkedHashMap<>(); // private final Services base; // // private Binder(Services base, Object key) { // super(key, base, Collections.<String, Object>emptyMap()); // checkNotNull(base, "only root Services should have a null base"); // this.base = base; // } // // @NonNull public Binder bind(@NonNull String serviceName, @NonNull Object service) { // services.put(serviceName, service); // return this; // } // // @NonNull Services build() { // return new Services(getKey(), base, services); // } // } // // private final Object key; // @Nullable private final Services delegate; // private final Map<String, Object> localServices = new LinkedHashMap<>(); // // private Services(Object key, @Nullable Services delegate, Map<String, Object> localServices) { // this.delegate = delegate; // this.key = key; // this.localServices.putAll(localServices); // } // // @Nullable public <T> T getService(@NonNull String name) { // if (localServices.containsKey(name)) { // @SuppressWarnings("unchecked") // // final T service = (T) localServices.get(name); // return service; // } // if (delegate != null) return delegate.getService(name); // return null; // } // // @NonNull public <T> T getKey() { // //noinspection unchecked // return (T) this.key; // } // // @NonNull Binder extend(@NonNull Object key) { // return new Binder(this, key); // } // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/flow/keys/ContactsUIKey.java // public class ContactsUIKey extends ClassKey { // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/flow/keys/EditContactKey.java // public final class EditContactKey extends ContactKey implements TreeKey { // // public EditContactKey(Contact contact) { // super(contact); // } // // @NonNull // @Override // public Object getParentKey() { // return new ContactsUIKey(); // } // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/mortar/ScreenScoper.java // public class ScreenScoper { // // public MortarScope getScreenScope(MortarScope parentScope, String name, Object key) { // // parentScope = parentScope.findChild(RootActivity.class.getName()); // MortarScope childScope = parentScope.findChild(name); // // if (childScope != null) // return childScope; // // if (!(key instanceof InjectionComponent)) { // //throw new IllegalStateException(String.format(Locale.getDefault(),"The screen (%s) must implement InjectionComponent",key.getClass().getSimpleName())); // return null; // } // // InjectionComponent screenComponent = (InjectionComponent) key; // Object component = screenComponent.createComponent(parentScope.getService(DaggerService.SERVICE_NAME)); // // return parentScope.buildChild().withService(DaggerService.SERVICE_NAME, component).build(name); // } // // }
import android.util.Log; import flow.Services; import flow.ServicesFactory; import leonardo2204.com.br.flowtests.flow.keys.ContactsUIKey; import leonardo2204.com.br.flowtests.flow.keys.EditContactKey; import leonardo2204.com.br.flowtests.mortar.ScreenScoper; import mortar.MortarScope;
package leonardo2204.com.br.flowtests.flow.serviceFactory; /** * Created by Leonardo on 04/03/2016. */ public class DaggerServiceFactory extends ServicesFactory { private final MortarScope parentScope; private final ScreenScoper screenScoper; public DaggerServiceFactory(MortarScope parentScope) { this.parentScope = parentScope; this.screenScoper = new ScreenScoper(); } @Override
// Path: flow/src/main/java/flow/Services.java // public class Services { // static final Services ROOT_SERVICES = // new Services(Flow.ROOT_KEY, null, Collections.<String, Object>emptyMap()); // // public static final class Binder extends Services { // private final Map<String, Object> services = new LinkedHashMap<>(); // private final Services base; // // private Binder(Services base, Object key) { // super(key, base, Collections.<String, Object>emptyMap()); // checkNotNull(base, "only root Services should have a null base"); // this.base = base; // } // // @NonNull public Binder bind(@NonNull String serviceName, @NonNull Object service) { // services.put(serviceName, service); // return this; // } // // @NonNull Services build() { // return new Services(getKey(), base, services); // } // } // // private final Object key; // @Nullable private final Services delegate; // private final Map<String, Object> localServices = new LinkedHashMap<>(); // // private Services(Object key, @Nullable Services delegate, Map<String, Object> localServices) { // this.delegate = delegate; // this.key = key; // this.localServices.putAll(localServices); // } // // @Nullable public <T> T getService(@NonNull String name) { // if (localServices.containsKey(name)) { // @SuppressWarnings("unchecked") // // final T service = (T) localServices.get(name); // return service; // } // if (delegate != null) return delegate.getService(name); // return null; // } // // @NonNull public <T> T getKey() { // //noinspection unchecked // return (T) this.key; // } // // @NonNull Binder extend(@NonNull Object key) { // return new Binder(this, key); // } // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/flow/keys/ContactsUIKey.java // public class ContactsUIKey extends ClassKey { // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/flow/keys/EditContactKey.java // public final class EditContactKey extends ContactKey implements TreeKey { // // public EditContactKey(Contact contact) { // super(contact); // } // // @NonNull // @Override // public Object getParentKey() { // return new ContactsUIKey(); // } // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/mortar/ScreenScoper.java // public class ScreenScoper { // // public MortarScope getScreenScope(MortarScope parentScope, String name, Object key) { // // parentScope = parentScope.findChild(RootActivity.class.getName()); // MortarScope childScope = parentScope.findChild(name); // // if (childScope != null) // return childScope; // // if (!(key instanceof InjectionComponent)) { // //throw new IllegalStateException(String.format(Locale.getDefault(),"The screen (%s) must implement InjectionComponent",key.getClass().getSimpleName())); // return null; // } // // InjectionComponent screenComponent = (InjectionComponent) key; // Object component = screenComponent.createComponent(parentScope.getService(DaggerService.SERVICE_NAME)); // // return parentScope.buildChild().withService(DaggerService.SERVICE_NAME, component).build(name); // } // // } // Path: app/src/main/java/leonardo2204/com/br/flowtests/flow/serviceFactory/DaggerServiceFactory.java import android.util.Log; import flow.Services; import flow.ServicesFactory; import leonardo2204.com.br.flowtests.flow.keys.ContactsUIKey; import leonardo2204.com.br.flowtests.flow.keys.EditContactKey; import leonardo2204.com.br.flowtests.mortar.ScreenScoper; import mortar.MortarScope; package leonardo2204.com.br.flowtests.flow.serviceFactory; /** * Created by Leonardo on 04/03/2016. */ public class DaggerServiceFactory extends ServicesFactory { private final MortarScope parentScope; private final ScreenScoper screenScoper; public DaggerServiceFactory(MortarScope parentScope) { this.parentScope = parentScope; this.screenScoper = new ScreenScoper(); } @Override
public void bindServices(Services.Binder services) {
leonardo2204/Flow1.0.0-alphaExample
app/src/main/java/leonardo2204/com/br/flowtests/flow/serviceFactory/DaggerServiceFactory.java
// Path: flow/src/main/java/flow/Services.java // public class Services { // static final Services ROOT_SERVICES = // new Services(Flow.ROOT_KEY, null, Collections.<String, Object>emptyMap()); // // public static final class Binder extends Services { // private final Map<String, Object> services = new LinkedHashMap<>(); // private final Services base; // // private Binder(Services base, Object key) { // super(key, base, Collections.<String, Object>emptyMap()); // checkNotNull(base, "only root Services should have a null base"); // this.base = base; // } // // @NonNull public Binder bind(@NonNull String serviceName, @NonNull Object service) { // services.put(serviceName, service); // return this; // } // // @NonNull Services build() { // return new Services(getKey(), base, services); // } // } // // private final Object key; // @Nullable private final Services delegate; // private final Map<String, Object> localServices = new LinkedHashMap<>(); // // private Services(Object key, @Nullable Services delegate, Map<String, Object> localServices) { // this.delegate = delegate; // this.key = key; // this.localServices.putAll(localServices); // } // // @Nullable public <T> T getService(@NonNull String name) { // if (localServices.containsKey(name)) { // @SuppressWarnings("unchecked") // // final T service = (T) localServices.get(name); // return service; // } // if (delegate != null) return delegate.getService(name); // return null; // } // // @NonNull public <T> T getKey() { // //noinspection unchecked // return (T) this.key; // } // // @NonNull Binder extend(@NonNull Object key) { // return new Binder(this, key); // } // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/flow/keys/ContactsUIKey.java // public class ContactsUIKey extends ClassKey { // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/flow/keys/EditContactKey.java // public final class EditContactKey extends ContactKey implements TreeKey { // // public EditContactKey(Contact contact) { // super(contact); // } // // @NonNull // @Override // public Object getParentKey() { // return new ContactsUIKey(); // } // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/mortar/ScreenScoper.java // public class ScreenScoper { // // public MortarScope getScreenScope(MortarScope parentScope, String name, Object key) { // // parentScope = parentScope.findChild(RootActivity.class.getName()); // MortarScope childScope = parentScope.findChild(name); // // if (childScope != null) // return childScope; // // if (!(key instanceof InjectionComponent)) { // //throw new IllegalStateException(String.format(Locale.getDefault(),"The screen (%s) must implement InjectionComponent",key.getClass().getSimpleName())); // return null; // } // // InjectionComponent screenComponent = (InjectionComponent) key; // Object component = screenComponent.createComponent(parentScope.getService(DaggerService.SERVICE_NAME)); // // return parentScope.buildChild().withService(DaggerService.SERVICE_NAME, component).build(name); // } // // }
import android.util.Log; import flow.Services; import flow.ServicesFactory; import leonardo2204.com.br.flowtests.flow.keys.ContactsUIKey; import leonardo2204.com.br.flowtests.flow.keys.EditContactKey; import leonardo2204.com.br.flowtests.mortar.ScreenScoper; import mortar.MortarScope;
package leonardo2204.com.br.flowtests.flow.serviceFactory; /** * Created by Leonardo on 04/03/2016. */ public class DaggerServiceFactory extends ServicesFactory { private final MortarScope parentScope; private final ScreenScoper screenScoper; public DaggerServiceFactory(MortarScope parentScope) { this.parentScope = parentScope; this.screenScoper = new ScreenScoper(); } @Override public void bindServices(Services.Binder services) { MortarScope scope = null; Log.d("services", services.getKey().toString());
// Path: flow/src/main/java/flow/Services.java // public class Services { // static final Services ROOT_SERVICES = // new Services(Flow.ROOT_KEY, null, Collections.<String, Object>emptyMap()); // // public static final class Binder extends Services { // private final Map<String, Object> services = new LinkedHashMap<>(); // private final Services base; // // private Binder(Services base, Object key) { // super(key, base, Collections.<String, Object>emptyMap()); // checkNotNull(base, "only root Services should have a null base"); // this.base = base; // } // // @NonNull public Binder bind(@NonNull String serviceName, @NonNull Object service) { // services.put(serviceName, service); // return this; // } // // @NonNull Services build() { // return new Services(getKey(), base, services); // } // } // // private final Object key; // @Nullable private final Services delegate; // private final Map<String, Object> localServices = new LinkedHashMap<>(); // // private Services(Object key, @Nullable Services delegate, Map<String, Object> localServices) { // this.delegate = delegate; // this.key = key; // this.localServices.putAll(localServices); // } // // @Nullable public <T> T getService(@NonNull String name) { // if (localServices.containsKey(name)) { // @SuppressWarnings("unchecked") // // final T service = (T) localServices.get(name); // return service; // } // if (delegate != null) return delegate.getService(name); // return null; // } // // @NonNull public <T> T getKey() { // //noinspection unchecked // return (T) this.key; // } // // @NonNull Binder extend(@NonNull Object key) { // return new Binder(this, key); // } // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/flow/keys/ContactsUIKey.java // public class ContactsUIKey extends ClassKey { // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/flow/keys/EditContactKey.java // public final class EditContactKey extends ContactKey implements TreeKey { // // public EditContactKey(Contact contact) { // super(contact); // } // // @NonNull // @Override // public Object getParentKey() { // return new ContactsUIKey(); // } // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/mortar/ScreenScoper.java // public class ScreenScoper { // // public MortarScope getScreenScope(MortarScope parentScope, String name, Object key) { // // parentScope = parentScope.findChild(RootActivity.class.getName()); // MortarScope childScope = parentScope.findChild(name); // // if (childScope != null) // return childScope; // // if (!(key instanceof InjectionComponent)) { // //throw new IllegalStateException(String.format(Locale.getDefault(),"The screen (%s) must implement InjectionComponent",key.getClass().getSimpleName())); // return null; // } // // InjectionComponent screenComponent = (InjectionComponent) key; // Object component = screenComponent.createComponent(parentScope.getService(DaggerService.SERVICE_NAME)); // // return parentScope.buildChild().withService(DaggerService.SERVICE_NAME, component).build(name); // } // // } // Path: app/src/main/java/leonardo2204/com/br/flowtests/flow/serviceFactory/DaggerServiceFactory.java import android.util.Log; import flow.Services; import flow.ServicesFactory; import leonardo2204.com.br.flowtests.flow.keys.ContactsUIKey; import leonardo2204.com.br.flowtests.flow.keys.EditContactKey; import leonardo2204.com.br.flowtests.mortar.ScreenScoper; import mortar.MortarScope; package leonardo2204.com.br.flowtests.flow.serviceFactory; /** * Created by Leonardo on 04/03/2016. */ public class DaggerServiceFactory extends ServicesFactory { private final MortarScope parentScope; private final ScreenScoper screenScoper; public DaggerServiceFactory(MortarScope parentScope) { this.parentScope = parentScope; this.screenScoper = new ScreenScoper(); } @Override public void bindServices(Services.Binder services) { MortarScope scope = null; Log.d("services", services.getKey().toString());
if(services.getKey() instanceof ContactsUIKey) {
leonardo2204/Flow1.0.0-alphaExample
app/src/main/java/leonardo2204/com/br/flowtests/flow/serviceFactory/DaggerServiceFactory.java
// Path: flow/src/main/java/flow/Services.java // public class Services { // static final Services ROOT_SERVICES = // new Services(Flow.ROOT_KEY, null, Collections.<String, Object>emptyMap()); // // public static final class Binder extends Services { // private final Map<String, Object> services = new LinkedHashMap<>(); // private final Services base; // // private Binder(Services base, Object key) { // super(key, base, Collections.<String, Object>emptyMap()); // checkNotNull(base, "only root Services should have a null base"); // this.base = base; // } // // @NonNull public Binder bind(@NonNull String serviceName, @NonNull Object service) { // services.put(serviceName, service); // return this; // } // // @NonNull Services build() { // return new Services(getKey(), base, services); // } // } // // private final Object key; // @Nullable private final Services delegate; // private final Map<String, Object> localServices = new LinkedHashMap<>(); // // private Services(Object key, @Nullable Services delegate, Map<String, Object> localServices) { // this.delegate = delegate; // this.key = key; // this.localServices.putAll(localServices); // } // // @Nullable public <T> T getService(@NonNull String name) { // if (localServices.containsKey(name)) { // @SuppressWarnings("unchecked") // // final T service = (T) localServices.get(name); // return service; // } // if (delegate != null) return delegate.getService(name); // return null; // } // // @NonNull public <T> T getKey() { // //noinspection unchecked // return (T) this.key; // } // // @NonNull Binder extend(@NonNull Object key) { // return new Binder(this, key); // } // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/flow/keys/ContactsUIKey.java // public class ContactsUIKey extends ClassKey { // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/flow/keys/EditContactKey.java // public final class EditContactKey extends ContactKey implements TreeKey { // // public EditContactKey(Contact contact) { // super(contact); // } // // @NonNull // @Override // public Object getParentKey() { // return new ContactsUIKey(); // } // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/mortar/ScreenScoper.java // public class ScreenScoper { // // public MortarScope getScreenScope(MortarScope parentScope, String name, Object key) { // // parentScope = parentScope.findChild(RootActivity.class.getName()); // MortarScope childScope = parentScope.findChild(name); // // if (childScope != null) // return childScope; // // if (!(key instanceof InjectionComponent)) { // //throw new IllegalStateException(String.format(Locale.getDefault(),"The screen (%s) must implement InjectionComponent",key.getClass().getSimpleName())); // return null; // } // // InjectionComponent screenComponent = (InjectionComponent) key; // Object component = screenComponent.createComponent(parentScope.getService(DaggerService.SERVICE_NAME)); // // return parentScope.buildChild().withService(DaggerService.SERVICE_NAME, component).build(name); // } // // }
import android.util.Log; import flow.Services; import flow.ServicesFactory; import leonardo2204.com.br.flowtests.flow.keys.ContactsUIKey; import leonardo2204.com.br.flowtests.flow.keys.EditContactKey; import leonardo2204.com.br.flowtests.mortar.ScreenScoper; import mortar.MortarScope;
package leonardo2204.com.br.flowtests.flow.serviceFactory; /** * Created by Leonardo on 04/03/2016. */ public class DaggerServiceFactory extends ServicesFactory { private final MortarScope parentScope; private final ScreenScoper screenScoper; public DaggerServiceFactory(MortarScope parentScope) { this.parentScope = parentScope; this.screenScoper = new ScreenScoper(); } @Override public void bindServices(Services.Binder services) { MortarScope scope = null; Log.d("services", services.getKey().toString()); if(services.getKey() instanceof ContactsUIKey) { scope = parentScope;
// Path: flow/src/main/java/flow/Services.java // public class Services { // static final Services ROOT_SERVICES = // new Services(Flow.ROOT_KEY, null, Collections.<String, Object>emptyMap()); // // public static final class Binder extends Services { // private final Map<String, Object> services = new LinkedHashMap<>(); // private final Services base; // // private Binder(Services base, Object key) { // super(key, base, Collections.<String, Object>emptyMap()); // checkNotNull(base, "only root Services should have a null base"); // this.base = base; // } // // @NonNull public Binder bind(@NonNull String serviceName, @NonNull Object service) { // services.put(serviceName, service); // return this; // } // // @NonNull Services build() { // return new Services(getKey(), base, services); // } // } // // private final Object key; // @Nullable private final Services delegate; // private final Map<String, Object> localServices = new LinkedHashMap<>(); // // private Services(Object key, @Nullable Services delegate, Map<String, Object> localServices) { // this.delegate = delegate; // this.key = key; // this.localServices.putAll(localServices); // } // // @Nullable public <T> T getService(@NonNull String name) { // if (localServices.containsKey(name)) { // @SuppressWarnings("unchecked") // // final T service = (T) localServices.get(name); // return service; // } // if (delegate != null) return delegate.getService(name); // return null; // } // // @NonNull public <T> T getKey() { // //noinspection unchecked // return (T) this.key; // } // // @NonNull Binder extend(@NonNull Object key) { // return new Binder(this, key); // } // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/flow/keys/ContactsUIKey.java // public class ContactsUIKey extends ClassKey { // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/flow/keys/EditContactKey.java // public final class EditContactKey extends ContactKey implements TreeKey { // // public EditContactKey(Contact contact) { // super(contact); // } // // @NonNull // @Override // public Object getParentKey() { // return new ContactsUIKey(); // } // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/mortar/ScreenScoper.java // public class ScreenScoper { // // public MortarScope getScreenScope(MortarScope parentScope, String name, Object key) { // // parentScope = parentScope.findChild(RootActivity.class.getName()); // MortarScope childScope = parentScope.findChild(name); // // if (childScope != null) // return childScope; // // if (!(key instanceof InjectionComponent)) { // //throw new IllegalStateException(String.format(Locale.getDefault(),"The screen (%s) must implement InjectionComponent",key.getClass().getSimpleName())); // return null; // } // // InjectionComponent screenComponent = (InjectionComponent) key; // Object component = screenComponent.createComponent(parentScope.getService(DaggerService.SERVICE_NAME)); // // return parentScope.buildChild().withService(DaggerService.SERVICE_NAME, component).build(name); // } // // } // Path: app/src/main/java/leonardo2204/com/br/flowtests/flow/serviceFactory/DaggerServiceFactory.java import android.util.Log; import flow.Services; import flow.ServicesFactory; import leonardo2204.com.br.flowtests.flow.keys.ContactsUIKey; import leonardo2204.com.br.flowtests.flow.keys.EditContactKey; import leonardo2204.com.br.flowtests.mortar.ScreenScoper; import mortar.MortarScope; package leonardo2204.com.br.flowtests.flow.serviceFactory; /** * Created by Leonardo on 04/03/2016. */ public class DaggerServiceFactory extends ServicesFactory { private final MortarScope parentScope; private final ScreenScoper screenScoper; public DaggerServiceFactory(MortarScope parentScope) { this.parentScope = parentScope; this.screenScoper = new ScreenScoper(); } @Override public void bindServices(Services.Binder services) { MortarScope scope = null; Log.d("services", services.getKey().toString()); if(services.getKey() instanceof ContactsUIKey) { scope = parentScope;
}else if(services.getKey() instanceof EditContactKey) {
leonardo2204/Flow1.0.0-alphaExample
app/src/main/java/leonardo2204/com/br/flowtests/di/module/ActivityModule.java
// Path: app/src/main/java/leonardo2204/com/br/flowtests/di/component/ActivityComponent.java // @DaggerScope(ActivityComponent.class) // @Component(dependencies = AppComponent.class, modules = ActivityModule.class) // public interface ActivityComponent extends AppComponent { // void inject(RootActivity rootActivity); // // ActionBarOwner actionBarOwner(); // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/presenter/ActionBarOwner.java // @DaggerScope(ActivityComponent.class) // public class ActionBarOwner extends Presenter<ActionBarOwner.Activity> { // // private Config config; // // @Override // protected BundleService extractBundleService(Activity view) { // return BundleService.getBundleService(view.getContext()); // } // // @Override // protected void onLoad(Bundle savedInstanceState) { // if (config != null) update(); // } // // private void update() { // if (!hasView()) return; // // Activity activity = getView(); // activity.setMenu(config.menuActionList); // activity.setShowHomeEnabled(config.showHomeEnabled); // activity.setUpButtonEnabled(config.upButtonEnabled); // activity.setToolbarTitle(config.title); // } // // public Config getConfig() { // return config; // } // // public void setConfig(Config config) { // this.config = config; // this.update(); // } // // public interface Activity { // void setMenu(List<MenuAction> menuActionList); // // void setToolbarTitle(CharSequence title); // // void setShowHomeEnabled(boolean enabled); // // void setUpButtonEnabled(boolean enabled); // // Context getContext(); // } // // public static class Config { // public final List<MenuAction> menuActionList; // public final CharSequence title; // public final boolean showHomeEnabled; // public final boolean upButtonEnabled; // // // public Config(List<MenuAction> menuActionList, CharSequence title, boolean showHomeEnabled, boolean upButtonEnabled) { // this.menuActionList = menuActionList; // this.title = title; // this.showHomeEnabled = showHomeEnabled; // this.upButtonEnabled = upButtonEnabled; // } // // public Config withAction(List<MenuAction> menuActionList) { // return new Config(menuActionList, title, showHomeEnabled, upButtonEnabled); // } // } // // public static class MenuAction { // public final CharSequence title; // public final Action0 action; // public final int icon; // // public MenuAction(CharSequence title, Action0 action, int icon) { // this.title = title; // this.action = action; // this.icon = icon; // } // } // // }
import dagger.Module; import dagger.Provides; import leonardo2204.com.br.flowtests.di.component.ActivityComponent; import leonardo2204.com.br.flowtests.di.scope.DaggerScope; import leonardo2204.com.br.flowtests.presenter.ActionBarOwner;
package leonardo2204.com.br.flowtests.di.module; /** * Created by Leonardo on 20/03/2016. */ @Module public class ActivityModule { @Provides
// Path: app/src/main/java/leonardo2204/com/br/flowtests/di/component/ActivityComponent.java // @DaggerScope(ActivityComponent.class) // @Component(dependencies = AppComponent.class, modules = ActivityModule.class) // public interface ActivityComponent extends AppComponent { // void inject(RootActivity rootActivity); // // ActionBarOwner actionBarOwner(); // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/presenter/ActionBarOwner.java // @DaggerScope(ActivityComponent.class) // public class ActionBarOwner extends Presenter<ActionBarOwner.Activity> { // // private Config config; // // @Override // protected BundleService extractBundleService(Activity view) { // return BundleService.getBundleService(view.getContext()); // } // // @Override // protected void onLoad(Bundle savedInstanceState) { // if (config != null) update(); // } // // private void update() { // if (!hasView()) return; // // Activity activity = getView(); // activity.setMenu(config.menuActionList); // activity.setShowHomeEnabled(config.showHomeEnabled); // activity.setUpButtonEnabled(config.upButtonEnabled); // activity.setToolbarTitle(config.title); // } // // public Config getConfig() { // return config; // } // // public void setConfig(Config config) { // this.config = config; // this.update(); // } // // public interface Activity { // void setMenu(List<MenuAction> menuActionList); // // void setToolbarTitle(CharSequence title); // // void setShowHomeEnabled(boolean enabled); // // void setUpButtonEnabled(boolean enabled); // // Context getContext(); // } // // public static class Config { // public final List<MenuAction> menuActionList; // public final CharSequence title; // public final boolean showHomeEnabled; // public final boolean upButtonEnabled; // // // public Config(List<MenuAction> menuActionList, CharSequence title, boolean showHomeEnabled, boolean upButtonEnabled) { // this.menuActionList = menuActionList; // this.title = title; // this.showHomeEnabled = showHomeEnabled; // this.upButtonEnabled = upButtonEnabled; // } // // public Config withAction(List<MenuAction> menuActionList) { // return new Config(menuActionList, title, showHomeEnabled, upButtonEnabled); // } // } // // public static class MenuAction { // public final CharSequence title; // public final Action0 action; // public final int icon; // // public MenuAction(CharSequence title, Action0 action, int icon) { // this.title = title; // this.action = action; // this.icon = icon; // } // } // // } // Path: app/src/main/java/leonardo2204/com/br/flowtests/di/module/ActivityModule.java import dagger.Module; import dagger.Provides; import leonardo2204.com.br.flowtests.di.component.ActivityComponent; import leonardo2204.com.br.flowtests.di.scope.DaggerScope; import leonardo2204.com.br.flowtests.presenter.ActionBarOwner; package leonardo2204.com.br.flowtests.di.module; /** * Created by Leonardo on 20/03/2016. */ @Module public class ActivityModule { @Provides
@DaggerScope(ActivityComponent.class)
leonardo2204/Flow1.0.0-alphaExample
app/src/main/java/leonardo2204/com/br/flowtests/di/module/ActivityModule.java
// Path: app/src/main/java/leonardo2204/com/br/flowtests/di/component/ActivityComponent.java // @DaggerScope(ActivityComponent.class) // @Component(dependencies = AppComponent.class, modules = ActivityModule.class) // public interface ActivityComponent extends AppComponent { // void inject(RootActivity rootActivity); // // ActionBarOwner actionBarOwner(); // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/presenter/ActionBarOwner.java // @DaggerScope(ActivityComponent.class) // public class ActionBarOwner extends Presenter<ActionBarOwner.Activity> { // // private Config config; // // @Override // protected BundleService extractBundleService(Activity view) { // return BundleService.getBundleService(view.getContext()); // } // // @Override // protected void onLoad(Bundle savedInstanceState) { // if (config != null) update(); // } // // private void update() { // if (!hasView()) return; // // Activity activity = getView(); // activity.setMenu(config.menuActionList); // activity.setShowHomeEnabled(config.showHomeEnabled); // activity.setUpButtonEnabled(config.upButtonEnabled); // activity.setToolbarTitle(config.title); // } // // public Config getConfig() { // return config; // } // // public void setConfig(Config config) { // this.config = config; // this.update(); // } // // public interface Activity { // void setMenu(List<MenuAction> menuActionList); // // void setToolbarTitle(CharSequence title); // // void setShowHomeEnabled(boolean enabled); // // void setUpButtonEnabled(boolean enabled); // // Context getContext(); // } // // public static class Config { // public final List<MenuAction> menuActionList; // public final CharSequence title; // public final boolean showHomeEnabled; // public final boolean upButtonEnabled; // // // public Config(List<MenuAction> menuActionList, CharSequence title, boolean showHomeEnabled, boolean upButtonEnabled) { // this.menuActionList = menuActionList; // this.title = title; // this.showHomeEnabled = showHomeEnabled; // this.upButtonEnabled = upButtonEnabled; // } // // public Config withAction(List<MenuAction> menuActionList) { // return new Config(menuActionList, title, showHomeEnabled, upButtonEnabled); // } // } // // public static class MenuAction { // public final CharSequence title; // public final Action0 action; // public final int icon; // // public MenuAction(CharSequence title, Action0 action, int icon) { // this.title = title; // this.action = action; // this.icon = icon; // } // } // // }
import dagger.Module; import dagger.Provides; import leonardo2204.com.br.flowtests.di.component.ActivityComponent; import leonardo2204.com.br.flowtests.di.scope.DaggerScope; import leonardo2204.com.br.flowtests.presenter.ActionBarOwner;
package leonardo2204.com.br.flowtests.di.module; /** * Created by Leonardo on 20/03/2016. */ @Module public class ActivityModule { @Provides @DaggerScope(ActivityComponent.class)
// Path: app/src/main/java/leonardo2204/com/br/flowtests/di/component/ActivityComponent.java // @DaggerScope(ActivityComponent.class) // @Component(dependencies = AppComponent.class, modules = ActivityModule.class) // public interface ActivityComponent extends AppComponent { // void inject(RootActivity rootActivity); // // ActionBarOwner actionBarOwner(); // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/presenter/ActionBarOwner.java // @DaggerScope(ActivityComponent.class) // public class ActionBarOwner extends Presenter<ActionBarOwner.Activity> { // // private Config config; // // @Override // protected BundleService extractBundleService(Activity view) { // return BundleService.getBundleService(view.getContext()); // } // // @Override // protected void onLoad(Bundle savedInstanceState) { // if (config != null) update(); // } // // private void update() { // if (!hasView()) return; // // Activity activity = getView(); // activity.setMenu(config.menuActionList); // activity.setShowHomeEnabled(config.showHomeEnabled); // activity.setUpButtonEnabled(config.upButtonEnabled); // activity.setToolbarTitle(config.title); // } // // public Config getConfig() { // return config; // } // // public void setConfig(Config config) { // this.config = config; // this.update(); // } // // public interface Activity { // void setMenu(List<MenuAction> menuActionList); // // void setToolbarTitle(CharSequence title); // // void setShowHomeEnabled(boolean enabled); // // void setUpButtonEnabled(boolean enabled); // // Context getContext(); // } // // public static class Config { // public final List<MenuAction> menuActionList; // public final CharSequence title; // public final boolean showHomeEnabled; // public final boolean upButtonEnabled; // // // public Config(List<MenuAction> menuActionList, CharSequence title, boolean showHomeEnabled, boolean upButtonEnabled) { // this.menuActionList = menuActionList; // this.title = title; // this.showHomeEnabled = showHomeEnabled; // this.upButtonEnabled = upButtonEnabled; // } // // public Config withAction(List<MenuAction> menuActionList) { // return new Config(menuActionList, title, showHomeEnabled, upButtonEnabled); // } // } // // public static class MenuAction { // public final CharSequence title; // public final Action0 action; // public final int icon; // // public MenuAction(CharSequence title, Action0 action, int icon) { // this.title = title; // this.action = action; // this.icon = icon; // } // } // // } // Path: app/src/main/java/leonardo2204/com/br/flowtests/di/module/ActivityModule.java import dagger.Module; import dagger.Provides; import leonardo2204.com.br.flowtests.di.component.ActivityComponent; import leonardo2204.com.br.flowtests.di.scope.DaggerScope; import leonardo2204.com.br.flowtests.presenter.ActionBarOwner; package leonardo2204.com.br.flowtests.di.module; /** * Created by Leonardo on 20/03/2016. */ @Module public class ActivityModule { @Provides @DaggerScope(ActivityComponent.class)
public ActionBarOwner providesActionBarOwner() {
leonardo2204/Flow1.0.0-alphaExample
app/src/main/java/leonardo2204/com/br/flowtests/screen/EditDialogScreen.java
// Path: app/src/main/java/leonardo2204/com/br/flowtests/di/component/DetailScreenComponent.java // @DaggerScope(DetailScreenComponent.class) // @Component(dependencies = ActivityComponent.class, modules = DetailScreenModule.class) // public interface DetailScreenComponent extends AppComponent { // void inject(DetailsView detailsView); // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/di/module/EditDialogModule.java // @Module // public class EditDialogModule { // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/flow/keys/EditContactKey.java // public final class EditContactKey extends ContactKey implements TreeKey { // // public EditContactKey(Contact contact) { // super(contact); // } // // @NonNull // @Override // public Object getParentKey() { // return new ContactsUIKey(); // } // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/flow/serviceFactory/InjectionComponent.java // public interface InjectionComponent<T> { // Object createComponent(T parent); // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/model/Contact.java // @Parcel // public class Contact { // // //Don't use private fields, due to reflection penalties using @Parcel // String id; // String name; // List<String> telephone; // // public Contact() { // } // // @ParcelConstructor // public Contact(String id, String name, List<String> telephone) { // this.id = id; // this.name = name; // this.telephone = telephone; // } // // public String getId() { // return id; // } // // public void setId(String id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public List<String> getTelephone() { // return telephone; // } // // public void setTelephone(List<String> telephone) { // this.telephone = telephone; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // Contact contact = (Contact) o; // // return id.equals(contact.id); // // } // // @Override // public int hashCode() { // return id.hashCode(); // } // // @Override // public String toString() { // return "Contact{" + // "id='" + id + '\'' + // ", name='" + name + '\'' + // '}'; // } // }
import android.support.annotation.NonNull; import android.util.Log; import flow.TreeKey; import leonardo2204.com.br.flowtests.Layout; import leonardo2204.com.br.flowtests.R; import leonardo2204.com.br.flowtests.di.component.DaggerEditDialogComponent; import leonardo2204.com.br.flowtests.di.component.DetailScreenComponent; import leonardo2204.com.br.flowtests.di.module.EditDialogModule; import leonardo2204.com.br.flowtests.flow.keys.EditContactKey; import leonardo2204.com.br.flowtests.flow.serviceFactory.InjectionComponent; import leonardo2204.com.br.flowtests.model.Contact;
package leonardo2204.com.br.flowtests.screen; /** * Created by Leonardo on 08/03/2016. */ //@Dialog @Layout(R.layout.edit_dialog_screen) public class EditDialogScreen implements InjectionComponent<DetailScreenComponent>, TreeKey {
// Path: app/src/main/java/leonardo2204/com/br/flowtests/di/component/DetailScreenComponent.java // @DaggerScope(DetailScreenComponent.class) // @Component(dependencies = ActivityComponent.class, modules = DetailScreenModule.class) // public interface DetailScreenComponent extends AppComponent { // void inject(DetailsView detailsView); // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/di/module/EditDialogModule.java // @Module // public class EditDialogModule { // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/flow/keys/EditContactKey.java // public final class EditContactKey extends ContactKey implements TreeKey { // // public EditContactKey(Contact contact) { // super(contact); // } // // @NonNull // @Override // public Object getParentKey() { // return new ContactsUIKey(); // } // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/flow/serviceFactory/InjectionComponent.java // public interface InjectionComponent<T> { // Object createComponent(T parent); // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/model/Contact.java // @Parcel // public class Contact { // // //Don't use private fields, due to reflection penalties using @Parcel // String id; // String name; // List<String> telephone; // // public Contact() { // } // // @ParcelConstructor // public Contact(String id, String name, List<String> telephone) { // this.id = id; // this.name = name; // this.telephone = telephone; // } // // public String getId() { // return id; // } // // public void setId(String id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public List<String> getTelephone() { // return telephone; // } // // public void setTelephone(List<String> telephone) { // this.telephone = telephone; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // Contact contact = (Contact) o; // // return id.equals(contact.id); // // } // // @Override // public int hashCode() { // return id.hashCode(); // } // // @Override // public String toString() { // return "Contact{" + // "id='" + id + '\'' + // ", name='" + name + '\'' + // '}'; // } // } // Path: app/src/main/java/leonardo2204/com/br/flowtests/screen/EditDialogScreen.java import android.support.annotation.NonNull; import android.util.Log; import flow.TreeKey; import leonardo2204.com.br.flowtests.Layout; import leonardo2204.com.br.flowtests.R; import leonardo2204.com.br.flowtests.di.component.DaggerEditDialogComponent; import leonardo2204.com.br.flowtests.di.component.DetailScreenComponent; import leonardo2204.com.br.flowtests.di.module.EditDialogModule; import leonardo2204.com.br.flowtests.flow.keys.EditContactKey; import leonardo2204.com.br.flowtests.flow.serviceFactory.InjectionComponent; import leonardo2204.com.br.flowtests.model.Contact; package leonardo2204.com.br.flowtests.screen; /** * Created by Leonardo on 08/03/2016. */ //@Dialog @Layout(R.layout.edit_dialog_screen) public class EditDialogScreen implements InjectionComponent<DetailScreenComponent>, TreeKey {
final Contact contact;
leonardo2204/Flow1.0.0-alphaExample
app/src/main/java/leonardo2204/com/br/flowtests/screen/EditDialogScreen.java
// Path: app/src/main/java/leonardo2204/com/br/flowtests/di/component/DetailScreenComponent.java // @DaggerScope(DetailScreenComponent.class) // @Component(dependencies = ActivityComponent.class, modules = DetailScreenModule.class) // public interface DetailScreenComponent extends AppComponent { // void inject(DetailsView detailsView); // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/di/module/EditDialogModule.java // @Module // public class EditDialogModule { // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/flow/keys/EditContactKey.java // public final class EditContactKey extends ContactKey implements TreeKey { // // public EditContactKey(Contact contact) { // super(contact); // } // // @NonNull // @Override // public Object getParentKey() { // return new ContactsUIKey(); // } // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/flow/serviceFactory/InjectionComponent.java // public interface InjectionComponent<T> { // Object createComponent(T parent); // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/model/Contact.java // @Parcel // public class Contact { // // //Don't use private fields, due to reflection penalties using @Parcel // String id; // String name; // List<String> telephone; // // public Contact() { // } // // @ParcelConstructor // public Contact(String id, String name, List<String> telephone) { // this.id = id; // this.name = name; // this.telephone = telephone; // } // // public String getId() { // return id; // } // // public void setId(String id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public List<String> getTelephone() { // return telephone; // } // // public void setTelephone(List<String> telephone) { // this.telephone = telephone; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // Contact contact = (Contact) o; // // return id.equals(contact.id); // // } // // @Override // public int hashCode() { // return id.hashCode(); // } // // @Override // public String toString() { // return "Contact{" + // "id='" + id + '\'' + // ", name='" + name + '\'' + // '}'; // } // }
import android.support.annotation.NonNull; import android.util.Log; import flow.TreeKey; import leonardo2204.com.br.flowtests.Layout; import leonardo2204.com.br.flowtests.R; import leonardo2204.com.br.flowtests.di.component.DaggerEditDialogComponent; import leonardo2204.com.br.flowtests.di.component.DetailScreenComponent; import leonardo2204.com.br.flowtests.di.module.EditDialogModule; import leonardo2204.com.br.flowtests.flow.keys.EditContactKey; import leonardo2204.com.br.flowtests.flow.serviceFactory.InjectionComponent; import leonardo2204.com.br.flowtests.model.Contact;
package leonardo2204.com.br.flowtests.screen; /** * Created by Leonardo on 08/03/2016. */ //@Dialog @Layout(R.layout.edit_dialog_screen) public class EditDialogScreen implements InjectionComponent<DetailScreenComponent>, TreeKey { final Contact contact; public EditDialogScreen(Contact contact) { this.contact = contact; } @Override public Object createComponent(DetailScreenComponent parent) { Log.d("injection", "injecting details"); return DaggerEditDialogComponent.builder() .detailScreenComponent(parent)
// Path: app/src/main/java/leonardo2204/com/br/flowtests/di/component/DetailScreenComponent.java // @DaggerScope(DetailScreenComponent.class) // @Component(dependencies = ActivityComponent.class, modules = DetailScreenModule.class) // public interface DetailScreenComponent extends AppComponent { // void inject(DetailsView detailsView); // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/di/module/EditDialogModule.java // @Module // public class EditDialogModule { // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/flow/keys/EditContactKey.java // public final class EditContactKey extends ContactKey implements TreeKey { // // public EditContactKey(Contact contact) { // super(contact); // } // // @NonNull // @Override // public Object getParentKey() { // return new ContactsUIKey(); // } // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/flow/serviceFactory/InjectionComponent.java // public interface InjectionComponent<T> { // Object createComponent(T parent); // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/model/Contact.java // @Parcel // public class Contact { // // //Don't use private fields, due to reflection penalties using @Parcel // String id; // String name; // List<String> telephone; // // public Contact() { // } // // @ParcelConstructor // public Contact(String id, String name, List<String> telephone) { // this.id = id; // this.name = name; // this.telephone = telephone; // } // // public String getId() { // return id; // } // // public void setId(String id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public List<String> getTelephone() { // return telephone; // } // // public void setTelephone(List<String> telephone) { // this.telephone = telephone; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // Contact contact = (Contact) o; // // return id.equals(contact.id); // // } // // @Override // public int hashCode() { // return id.hashCode(); // } // // @Override // public String toString() { // return "Contact{" + // "id='" + id + '\'' + // ", name='" + name + '\'' + // '}'; // } // } // Path: app/src/main/java/leonardo2204/com/br/flowtests/screen/EditDialogScreen.java import android.support.annotation.NonNull; import android.util.Log; import flow.TreeKey; import leonardo2204.com.br.flowtests.Layout; import leonardo2204.com.br.flowtests.R; import leonardo2204.com.br.flowtests.di.component.DaggerEditDialogComponent; import leonardo2204.com.br.flowtests.di.component.DetailScreenComponent; import leonardo2204.com.br.flowtests.di.module.EditDialogModule; import leonardo2204.com.br.flowtests.flow.keys.EditContactKey; import leonardo2204.com.br.flowtests.flow.serviceFactory.InjectionComponent; import leonardo2204.com.br.flowtests.model.Contact; package leonardo2204.com.br.flowtests.screen; /** * Created by Leonardo on 08/03/2016. */ //@Dialog @Layout(R.layout.edit_dialog_screen) public class EditDialogScreen implements InjectionComponent<DetailScreenComponent>, TreeKey { final Contact contact; public EditDialogScreen(Contact contact) { this.contact = contact; } @Override public Object createComponent(DetailScreenComponent parent) { Log.d("injection", "injecting details"); return DaggerEditDialogComponent.builder() .detailScreenComponent(parent)
.editDialogModule(new EditDialogModule())
leonardo2204/Flow1.0.0-alphaExample
app/src/main/java/leonardo2204/com/br/flowtests/screen/EditDialogScreen.java
// Path: app/src/main/java/leonardo2204/com/br/flowtests/di/component/DetailScreenComponent.java // @DaggerScope(DetailScreenComponent.class) // @Component(dependencies = ActivityComponent.class, modules = DetailScreenModule.class) // public interface DetailScreenComponent extends AppComponent { // void inject(DetailsView detailsView); // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/di/module/EditDialogModule.java // @Module // public class EditDialogModule { // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/flow/keys/EditContactKey.java // public final class EditContactKey extends ContactKey implements TreeKey { // // public EditContactKey(Contact contact) { // super(contact); // } // // @NonNull // @Override // public Object getParentKey() { // return new ContactsUIKey(); // } // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/flow/serviceFactory/InjectionComponent.java // public interface InjectionComponent<T> { // Object createComponent(T parent); // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/model/Contact.java // @Parcel // public class Contact { // // //Don't use private fields, due to reflection penalties using @Parcel // String id; // String name; // List<String> telephone; // // public Contact() { // } // // @ParcelConstructor // public Contact(String id, String name, List<String> telephone) { // this.id = id; // this.name = name; // this.telephone = telephone; // } // // public String getId() { // return id; // } // // public void setId(String id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public List<String> getTelephone() { // return telephone; // } // // public void setTelephone(List<String> telephone) { // this.telephone = telephone; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // Contact contact = (Contact) o; // // return id.equals(contact.id); // // } // // @Override // public int hashCode() { // return id.hashCode(); // } // // @Override // public String toString() { // return "Contact{" + // "id='" + id + '\'' + // ", name='" + name + '\'' + // '}'; // } // }
import android.support.annotation.NonNull; import android.util.Log; import flow.TreeKey; import leonardo2204.com.br.flowtests.Layout; import leonardo2204.com.br.flowtests.R; import leonardo2204.com.br.flowtests.di.component.DaggerEditDialogComponent; import leonardo2204.com.br.flowtests.di.component.DetailScreenComponent; import leonardo2204.com.br.flowtests.di.module.EditDialogModule; import leonardo2204.com.br.flowtests.flow.keys.EditContactKey; import leonardo2204.com.br.flowtests.flow.serviceFactory.InjectionComponent; import leonardo2204.com.br.flowtests.model.Contact;
package leonardo2204.com.br.flowtests.screen; /** * Created by Leonardo on 08/03/2016. */ //@Dialog @Layout(R.layout.edit_dialog_screen) public class EditDialogScreen implements InjectionComponent<DetailScreenComponent>, TreeKey { final Contact contact; public EditDialogScreen(Contact contact) { this.contact = contact; } @Override public Object createComponent(DetailScreenComponent parent) { Log.d("injection", "injecting details"); return DaggerEditDialogComponent.builder() .detailScreenComponent(parent) .editDialogModule(new EditDialogModule()) .build(); } @NonNull @Override public Object getParentKey() {
// Path: app/src/main/java/leonardo2204/com/br/flowtests/di/component/DetailScreenComponent.java // @DaggerScope(DetailScreenComponent.class) // @Component(dependencies = ActivityComponent.class, modules = DetailScreenModule.class) // public interface DetailScreenComponent extends AppComponent { // void inject(DetailsView detailsView); // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/di/module/EditDialogModule.java // @Module // public class EditDialogModule { // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/flow/keys/EditContactKey.java // public final class EditContactKey extends ContactKey implements TreeKey { // // public EditContactKey(Contact contact) { // super(contact); // } // // @NonNull // @Override // public Object getParentKey() { // return new ContactsUIKey(); // } // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/flow/serviceFactory/InjectionComponent.java // public interface InjectionComponent<T> { // Object createComponent(T parent); // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/model/Contact.java // @Parcel // public class Contact { // // //Don't use private fields, due to reflection penalties using @Parcel // String id; // String name; // List<String> telephone; // // public Contact() { // } // // @ParcelConstructor // public Contact(String id, String name, List<String> telephone) { // this.id = id; // this.name = name; // this.telephone = telephone; // } // // public String getId() { // return id; // } // // public void setId(String id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public List<String> getTelephone() { // return telephone; // } // // public void setTelephone(List<String> telephone) { // this.telephone = telephone; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // Contact contact = (Contact) o; // // return id.equals(contact.id); // // } // // @Override // public int hashCode() { // return id.hashCode(); // } // // @Override // public String toString() { // return "Contact{" + // "id='" + id + '\'' + // ", name='" + name + '\'' + // '}'; // } // } // Path: app/src/main/java/leonardo2204/com/br/flowtests/screen/EditDialogScreen.java import android.support.annotation.NonNull; import android.util.Log; import flow.TreeKey; import leonardo2204.com.br.flowtests.Layout; import leonardo2204.com.br.flowtests.R; import leonardo2204.com.br.flowtests.di.component.DaggerEditDialogComponent; import leonardo2204.com.br.flowtests.di.component.DetailScreenComponent; import leonardo2204.com.br.flowtests.di.module.EditDialogModule; import leonardo2204.com.br.flowtests.flow.keys.EditContactKey; import leonardo2204.com.br.flowtests.flow.serviceFactory.InjectionComponent; import leonardo2204.com.br.flowtests.model.Contact; package leonardo2204.com.br.flowtests.screen; /** * Created by Leonardo on 08/03/2016. */ //@Dialog @Layout(R.layout.edit_dialog_screen) public class EditDialogScreen implements InjectionComponent<DetailScreenComponent>, TreeKey { final Contact contact; public EditDialogScreen(Contact contact) { this.contact = contact; } @Override public Object createComponent(DetailScreenComponent parent) { Log.d("injection", "injecting details"); return DaggerEditDialogComponent.builder() .detailScreenComponent(parent) .editDialogModule(new EditDialogModule()) .build(); } @NonNull @Override public Object getParentKey() {
return new EditContactKey(contact);
leonardo2204/Flow1.0.0-alphaExample
app/src/main/java/leonardo2204/com/br/flowtests/mortar/ScreenScoper.java
// Path: app/src/main/java/leonardo2204/com/br/flowtests/RootActivity.java // @DaggerScope(ActivityComponent.class) // public class RootActivity extends AppCompatActivity implements ActionBarOwner.Activity { // // @Bind(R.id.content) // FrameLayout content; // @Bind(R.id.toolbar) // Toolbar toolbar; // // @Inject // ActionBarOwner actionBarOwner; // // private MortarScope mortarScope; // private List<ActionBarOwner.MenuAction> actionBarMenuActionList; // // @Override // protected void attachBaseContext(Context newBase) { // newBase = Flow.configure(newBase,this) // .addServicesFactory(new DaggerServiceFactory(MortarScope.getScope(newBase))) // .dispatcher(KeyDispatcher.configure(this, new Changer(this)).build()) // .defaultKey(new FirstScreen()) // .keyParceler(new BasicKeyParceler()) // .install(); // super.attachBaseContext(newBase); // } // // @Override // public Object getSystemService(String name) { // if(mortarScope == null){ // setupMortar(); // } // // return (mortarScope.hasService(name)) ? mortarScope.getService(name) : super.getSystemService(name); // } // // @Override // protected void onCreate(@Nullable Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // setupUI(); // setupDagger(); // BundleServiceRunner.getBundleServiceRunner(this).onCreate(savedInstanceState); // } // // private ActivityComponent setupDagger() { // return DaggerActivityComponent // .builder() // .appComponent(DaggerService.<AppComponent>getDaggerComponent(getApplicationContext())) // .activityModule(new ActivityModule()) // .build(); // } // // @Override // public boolean onCreateOptionsMenu(Menu menu) { // if (actionBarMenuActionList != null && actionBarMenuActionList.size() > 0) { // // for (final ActionBarOwner.MenuAction menuAction : actionBarMenuActionList) { // menu.add(menuAction.title) // .setIcon(menuAction.icon) // .setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_IF_ROOM) // .setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { // @Override // public boolean onMenuItemClick(MenuItem item) { // menuAction.action.call(); // return true; // } // }); // } // } // // return true; // } // // private void setupUI() { // actionBarOwner.takeView(this); // setContentView(R.layout.activity_root); // ButterKnife.bind(this); // setSupportActionBar(toolbar); // } // // @Override // protected void onDestroy() { // actionBarOwner.dropView(this); // actionBarOwner.setConfig(null); // // if (isFinishing() && mortarScope != null) { // mortarScope.destroy(); // mortarScope = null; // } // // super.onDestroy(); // } // // @Override // protected void onSaveInstanceState(Bundle outState) { // super.onSaveInstanceState(outState); // BundleServiceRunner.getBundleServiceRunner(this).onSaveInstanceState(outState); // } // // @Override // public boolean onOptionsItemSelected(MenuItem item) { // if (item.getItemId() == android.R.id.home) { // return Flow.get(this).goBack(); // } // // return super.onOptionsItemSelected(item); // } // // private void setupMortar() { // mortarScope = MortarScope.findChild(getApplicationContext(), getClass().getName()); // ActivityComponent component = setupDagger(); // // if(mortarScope == null) { // mortarScope = MortarScope // .buildChild(getApplicationContext()) // .withService(BundleServiceRunner.SERVICE_NAME, new BundleServiceRunner()) // .withService(DaggerService.SERVICE_NAME, component) // .build(getClass().getName()); // } // // component.inject(this); // } // // @Override // public void onBackPressed() { // if (!Flow.get(this).goBack()) // super.onBackPressed(); // } // // @Override // public void setMenu(List<ActionBarOwner.MenuAction> menuActionList) { // if (menuActionList != actionBarMenuActionList) { // actionBarMenuActionList = menuActionList; // invalidateOptionsMenu(); // } // } // // @Override // public void setToolbarTitle(CharSequence title) { // if (getSupportActionBar() != null) // getSupportActionBar().setTitle(title); // } // // @Override // public void setShowHomeEnabled(boolean enabled) { // if (getSupportActionBar() != null) // getSupportActionBar().setDisplayShowHomeEnabled(false); // } // // @Override // public void setUpButtonEnabled(boolean enabled) { // if (getSupportActionBar() != null) { // getSupportActionBar().setDisplayHomeAsUpEnabled(enabled); // getSupportActionBar().setHomeButtonEnabled(enabled); // } // } // // @Override // public Context getContext() { // return this; // } // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/flow/serviceFactory/InjectionComponent.java // public interface InjectionComponent<T> { // Object createComponent(T parent); // }
import leonardo2204.com.br.flowtests.RootActivity; import leonardo2204.com.br.flowtests.di.DaggerService; import leonardo2204.com.br.flowtests.flow.serviceFactory.InjectionComponent; import mortar.MortarScope;
package leonardo2204.com.br.flowtests.mortar; /** * Created by Leonardo on 08/03/2016. */ public class ScreenScoper { public MortarScope getScreenScope(MortarScope parentScope, String name, Object key) {
// Path: app/src/main/java/leonardo2204/com/br/flowtests/RootActivity.java // @DaggerScope(ActivityComponent.class) // public class RootActivity extends AppCompatActivity implements ActionBarOwner.Activity { // // @Bind(R.id.content) // FrameLayout content; // @Bind(R.id.toolbar) // Toolbar toolbar; // // @Inject // ActionBarOwner actionBarOwner; // // private MortarScope mortarScope; // private List<ActionBarOwner.MenuAction> actionBarMenuActionList; // // @Override // protected void attachBaseContext(Context newBase) { // newBase = Flow.configure(newBase,this) // .addServicesFactory(new DaggerServiceFactory(MortarScope.getScope(newBase))) // .dispatcher(KeyDispatcher.configure(this, new Changer(this)).build()) // .defaultKey(new FirstScreen()) // .keyParceler(new BasicKeyParceler()) // .install(); // super.attachBaseContext(newBase); // } // // @Override // public Object getSystemService(String name) { // if(mortarScope == null){ // setupMortar(); // } // // return (mortarScope.hasService(name)) ? mortarScope.getService(name) : super.getSystemService(name); // } // // @Override // protected void onCreate(@Nullable Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // setupUI(); // setupDagger(); // BundleServiceRunner.getBundleServiceRunner(this).onCreate(savedInstanceState); // } // // private ActivityComponent setupDagger() { // return DaggerActivityComponent // .builder() // .appComponent(DaggerService.<AppComponent>getDaggerComponent(getApplicationContext())) // .activityModule(new ActivityModule()) // .build(); // } // // @Override // public boolean onCreateOptionsMenu(Menu menu) { // if (actionBarMenuActionList != null && actionBarMenuActionList.size() > 0) { // // for (final ActionBarOwner.MenuAction menuAction : actionBarMenuActionList) { // menu.add(menuAction.title) // .setIcon(menuAction.icon) // .setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_IF_ROOM) // .setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { // @Override // public boolean onMenuItemClick(MenuItem item) { // menuAction.action.call(); // return true; // } // }); // } // } // // return true; // } // // private void setupUI() { // actionBarOwner.takeView(this); // setContentView(R.layout.activity_root); // ButterKnife.bind(this); // setSupportActionBar(toolbar); // } // // @Override // protected void onDestroy() { // actionBarOwner.dropView(this); // actionBarOwner.setConfig(null); // // if (isFinishing() && mortarScope != null) { // mortarScope.destroy(); // mortarScope = null; // } // // super.onDestroy(); // } // // @Override // protected void onSaveInstanceState(Bundle outState) { // super.onSaveInstanceState(outState); // BundleServiceRunner.getBundleServiceRunner(this).onSaveInstanceState(outState); // } // // @Override // public boolean onOptionsItemSelected(MenuItem item) { // if (item.getItemId() == android.R.id.home) { // return Flow.get(this).goBack(); // } // // return super.onOptionsItemSelected(item); // } // // private void setupMortar() { // mortarScope = MortarScope.findChild(getApplicationContext(), getClass().getName()); // ActivityComponent component = setupDagger(); // // if(mortarScope == null) { // mortarScope = MortarScope // .buildChild(getApplicationContext()) // .withService(BundleServiceRunner.SERVICE_NAME, new BundleServiceRunner()) // .withService(DaggerService.SERVICE_NAME, component) // .build(getClass().getName()); // } // // component.inject(this); // } // // @Override // public void onBackPressed() { // if (!Flow.get(this).goBack()) // super.onBackPressed(); // } // // @Override // public void setMenu(List<ActionBarOwner.MenuAction> menuActionList) { // if (menuActionList != actionBarMenuActionList) { // actionBarMenuActionList = menuActionList; // invalidateOptionsMenu(); // } // } // // @Override // public void setToolbarTitle(CharSequence title) { // if (getSupportActionBar() != null) // getSupportActionBar().setTitle(title); // } // // @Override // public void setShowHomeEnabled(boolean enabled) { // if (getSupportActionBar() != null) // getSupportActionBar().setDisplayShowHomeEnabled(false); // } // // @Override // public void setUpButtonEnabled(boolean enabled) { // if (getSupportActionBar() != null) { // getSupportActionBar().setDisplayHomeAsUpEnabled(enabled); // getSupportActionBar().setHomeButtonEnabled(enabled); // } // } // // @Override // public Context getContext() { // return this; // } // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/flow/serviceFactory/InjectionComponent.java // public interface InjectionComponent<T> { // Object createComponent(T parent); // } // Path: app/src/main/java/leonardo2204/com/br/flowtests/mortar/ScreenScoper.java import leonardo2204.com.br.flowtests.RootActivity; import leonardo2204.com.br.flowtests.di.DaggerService; import leonardo2204.com.br.flowtests.flow.serviceFactory.InjectionComponent; import mortar.MortarScope; package leonardo2204.com.br.flowtests.mortar; /** * Created by Leonardo on 08/03/2016. */ public class ScreenScoper { public MortarScope getScreenScope(MortarScope parentScope, String name, Object key) {
parentScope = parentScope.findChild(RootActivity.class.getName());
leonardo2204/Flow1.0.0-alphaExample
app/src/main/java/leonardo2204/com/br/flowtests/mortar/ScreenScoper.java
// Path: app/src/main/java/leonardo2204/com/br/flowtests/RootActivity.java // @DaggerScope(ActivityComponent.class) // public class RootActivity extends AppCompatActivity implements ActionBarOwner.Activity { // // @Bind(R.id.content) // FrameLayout content; // @Bind(R.id.toolbar) // Toolbar toolbar; // // @Inject // ActionBarOwner actionBarOwner; // // private MortarScope mortarScope; // private List<ActionBarOwner.MenuAction> actionBarMenuActionList; // // @Override // protected void attachBaseContext(Context newBase) { // newBase = Flow.configure(newBase,this) // .addServicesFactory(new DaggerServiceFactory(MortarScope.getScope(newBase))) // .dispatcher(KeyDispatcher.configure(this, new Changer(this)).build()) // .defaultKey(new FirstScreen()) // .keyParceler(new BasicKeyParceler()) // .install(); // super.attachBaseContext(newBase); // } // // @Override // public Object getSystemService(String name) { // if(mortarScope == null){ // setupMortar(); // } // // return (mortarScope.hasService(name)) ? mortarScope.getService(name) : super.getSystemService(name); // } // // @Override // protected void onCreate(@Nullable Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // setupUI(); // setupDagger(); // BundleServiceRunner.getBundleServiceRunner(this).onCreate(savedInstanceState); // } // // private ActivityComponent setupDagger() { // return DaggerActivityComponent // .builder() // .appComponent(DaggerService.<AppComponent>getDaggerComponent(getApplicationContext())) // .activityModule(new ActivityModule()) // .build(); // } // // @Override // public boolean onCreateOptionsMenu(Menu menu) { // if (actionBarMenuActionList != null && actionBarMenuActionList.size() > 0) { // // for (final ActionBarOwner.MenuAction menuAction : actionBarMenuActionList) { // menu.add(menuAction.title) // .setIcon(menuAction.icon) // .setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_IF_ROOM) // .setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { // @Override // public boolean onMenuItemClick(MenuItem item) { // menuAction.action.call(); // return true; // } // }); // } // } // // return true; // } // // private void setupUI() { // actionBarOwner.takeView(this); // setContentView(R.layout.activity_root); // ButterKnife.bind(this); // setSupportActionBar(toolbar); // } // // @Override // protected void onDestroy() { // actionBarOwner.dropView(this); // actionBarOwner.setConfig(null); // // if (isFinishing() && mortarScope != null) { // mortarScope.destroy(); // mortarScope = null; // } // // super.onDestroy(); // } // // @Override // protected void onSaveInstanceState(Bundle outState) { // super.onSaveInstanceState(outState); // BundleServiceRunner.getBundleServiceRunner(this).onSaveInstanceState(outState); // } // // @Override // public boolean onOptionsItemSelected(MenuItem item) { // if (item.getItemId() == android.R.id.home) { // return Flow.get(this).goBack(); // } // // return super.onOptionsItemSelected(item); // } // // private void setupMortar() { // mortarScope = MortarScope.findChild(getApplicationContext(), getClass().getName()); // ActivityComponent component = setupDagger(); // // if(mortarScope == null) { // mortarScope = MortarScope // .buildChild(getApplicationContext()) // .withService(BundleServiceRunner.SERVICE_NAME, new BundleServiceRunner()) // .withService(DaggerService.SERVICE_NAME, component) // .build(getClass().getName()); // } // // component.inject(this); // } // // @Override // public void onBackPressed() { // if (!Flow.get(this).goBack()) // super.onBackPressed(); // } // // @Override // public void setMenu(List<ActionBarOwner.MenuAction> menuActionList) { // if (menuActionList != actionBarMenuActionList) { // actionBarMenuActionList = menuActionList; // invalidateOptionsMenu(); // } // } // // @Override // public void setToolbarTitle(CharSequence title) { // if (getSupportActionBar() != null) // getSupportActionBar().setTitle(title); // } // // @Override // public void setShowHomeEnabled(boolean enabled) { // if (getSupportActionBar() != null) // getSupportActionBar().setDisplayShowHomeEnabled(false); // } // // @Override // public void setUpButtonEnabled(boolean enabled) { // if (getSupportActionBar() != null) { // getSupportActionBar().setDisplayHomeAsUpEnabled(enabled); // getSupportActionBar().setHomeButtonEnabled(enabled); // } // } // // @Override // public Context getContext() { // return this; // } // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/flow/serviceFactory/InjectionComponent.java // public interface InjectionComponent<T> { // Object createComponent(T parent); // }
import leonardo2204.com.br.flowtests.RootActivity; import leonardo2204.com.br.flowtests.di.DaggerService; import leonardo2204.com.br.flowtests.flow.serviceFactory.InjectionComponent; import mortar.MortarScope;
package leonardo2204.com.br.flowtests.mortar; /** * Created by Leonardo on 08/03/2016. */ public class ScreenScoper { public MortarScope getScreenScope(MortarScope parentScope, String name, Object key) { parentScope = parentScope.findChild(RootActivity.class.getName()); MortarScope childScope = parentScope.findChild(name); if (childScope != null) return childScope;
// Path: app/src/main/java/leonardo2204/com/br/flowtests/RootActivity.java // @DaggerScope(ActivityComponent.class) // public class RootActivity extends AppCompatActivity implements ActionBarOwner.Activity { // // @Bind(R.id.content) // FrameLayout content; // @Bind(R.id.toolbar) // Toolbar toolbar; // // @Inject // ActionBarOwner actionBarOwner; // // private MortarScope mortarScope; // private List<ActionBarOwner.MenuAction> actionBarMenuActionList; // // @Override // protected void attachBaseContext(Context newBase) { // newBase = Flow.configure(newBase,this) // .addServicesFactory(new DaggerServiceFactory(MortarScope.getScope(newBase))) // .dispatcher(KeyDispatcher.configure(this, new Changer(this)).build()) // .defaultKey(new FirstScreen()) // .keyParceler(new BasicKeyParceler()) // .install(); // super.attachBaseContext(newBase); // } // // @Override // public Object getSystemService(String name) { // if(mortarScope == null){ // setupMortar(); // } // // return (mortarScope.hasService(name)) ? mortarScope.getService(name) : super.getSystemService(name); // } // // @Override // protected void onCreate(@Nullable Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // setupUI(); // setupDagger(); // BundleServiceRunner.getBundleServiceRunner(this).onCreate(savedInstanceState); // } // // private ActivityComponent setupDagger() { // return DaggerActivityComponent // .builder() // .appComponent(DaggerService.<AppComponent>getDaggerComponent(getApplicationContext())) // .activityModule(new ActivityModule()) // .build(); // } // // @Override // public boolean onCreateOptionsMenu(Menu menu) { // if (actionBarMenuActionList != null && actionBarMenuActionList.size() > 0) { // // for (final ActionBarOwner.MenuAction menuAction : actionBarMenuActionList) { // menu.add(menuAction.title) // .setIcon(menuAction.icon) // .setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_IF_ROOM) // .setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { // @Override // public boolean onMenuItemClick(MenuItem item) { // menuAction.action.call(); // return true; // } // }); // } // } // // return true; // } // // private void setupUI() { // actionBarOwner.takeView(this); // setContentView(R.layout.activity_root); // ButterKnife.bind(this); // setSupportActionBar(toolbar); // } // // @Override // protected void onDestroy() { // actionBarOwner.dropView(this); // actionBarOwner.setConfig(null); // // if (isFinishing() && mortarScope != null) { // mortarScope.destroy(); // mortarScope = null; // } // // super.onDestroy(); // } // // @Override // protected void onSaveInstanceState(Bundle outState) { // super.onSaveInstanceState(outState); // BundleServiceRunner.getBundleServiceRunner(this).onSaveInstanceState(outState); // } // // @Override // public boolean onOptionsItemSelected(MenuItem item) { // if (item.getItemId() == android.R.id.home) { // return Flow.get(this).goBack(); // } // // return super.onOptionsItemSelected(item); // } // // private void setupMortar() { // mortarScope = MortarScope.findChild(getApplicationContext(), getClass().getName()); // ActivityComponent component = setupDagger(); // // if(mortarScope == null) { // mortarScope = MortarScope // .buildChild(getApplicationContext()) // .withService(BundleServiceRunner.SERVICE_NAME, new BundleServiceRunner()) // .withService(DaggerService.SERVICE_NAME, component) // .build(getClass().getName()); // } // // component.inject(this); // } // // @Override // public void onBackPressed() { // if (!Flow.get(this).goBack()) // super.onBackPressed(); // } // // @Override // public void setMenu(List<ActionBarOwner.MenuAction> menuActionList) { // if (menuActionList != actionBarMenuActionList) { // actionBarMenuActionList = menuActionList; // invalidateOptionsMenu(); // } // } // // @Override // public void setToolbarTitle(CharSequence title) { // if (getSupportActionBar() != null) // getSupportActionBar().setTitle(title); // } // // @Override // public void setShowHomeEnabled(boolean enabled) { // if (getSupportActionBar() != null) // getSupportActionBar().setDisplayShowHomeEnabled(false); // } // // @Override // public void setUpButtonEnabled(boolean enabled) { // if (getSupportActionBar() != null) { // getSupportActionBar().setDisplayHomeAsUpEnabled(enabled); // getSupportActionBar().setHomeButtonEnabled(enabled); // } // } // // @Override // public Context getContext() { // return this; // } // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/flow/serviceFactory/InjectionComponent.java // public interface InjectionComponent<T> { // Object createComponent(T parent); // } // Path: app/src/main/java/leonardo2204/com/br/flowtests/mortar/ScreenScoper.java import leonardo2204.com.br.flowtests.RootActivity; import leonardo2204.com.br.flowtests.di.DaggerService; import leonardo2204.com.br.flowtests.flow.serviceFactory.InjectionComponent; import mortar.MortarScope; package leonardo2204.com.br.flowtests.mortar; /** * Created by Leonardo on 08/03/2016. */ public class ScreenScoper { public MortarScope getScreenScope(MortarScope parentScope, String name, Object key) { parentScope = parentScope.findChild(RootActivity.class.getName()); MortarScope childScope = parentScope.findChild(name); if (childScope != null) return childScope;
if (!(key instanceof InjectionComponent)) {
leonardo2204/Flow1.0.0-alphaExample
app/src/main/java/leonardo2204/com/br/flowtests/flow/dispatcher/Changer.java
// Path: flow/src/main/java/flow/KeyChanger.java // public interface KeyChanger { // void changeKey(@Nullable State outgoingState, @NonNull State incomingState, // @NonNull Direction direction, @NonNull Map<Object, Context> incomingContexts, // @NonNull TraversalCallback callback); // } // // Path: flow/src/main/java/flow/State.java // public class State { // /** Creates a State instance that has no state and is effectively immutable. */ // @NonNull public static State empty(@NonNull final Object key) { // return new EmptyState(key); // } // // @NonNull static State fromBundle(@NonNull Bundle savedState, @NonNull KeyParceler parceler) { // Object key = parceler.toKey(savedState.getParcelable("KEY")); // State state = new State(key); // state.viewState = savedState.getSparseParcelableArray("VIEW_STATE"); // state.bundle = savedState.getBundle("BUNDLE"); // return state; // } // // private final Object key; // @Nullable private Bundle bundle; // @Nullable SparseArray<Parcelable> viewState; // // State(Object key) { // // No external instances. // this.key = key; // } // // @NonNull public final <T> T getKey() { // @SuppressWarnings("unchecked") final T state = (T) key; // return state; // } // // public void save(@NonNull View view) { // SparseArray<Parcelable> state = new SparseArray<>(); // view.saveHierarchyState(state); // viewState = state; // } // // public void restore(@NonNull View view) { // if (viewState != null) { // view.restoreHierarchyState(viewState); // } // } // // public void setBundle(@Nullable Bundle bundle) { // this.bundle = bundle; // } // // @Nullable public Bundle getBundle() { // return bundle; // } // // Bundle toBundle(KeyParceler parceler) { // Bundle outState = new Bundle(); // outState.putParcelable("KEY", parceler.toParcelable(getKey())); // if (viewState != null && viewState.size() > 0) { // outState.putSparseParcelableArray("VIEW_STATE", viewState); // } // if (bundle != null && !bundle.isEmpty()) { // outState.putBundle("BUNDLE", bundle); // } // return outState; // } // // @Override public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // State state = (State) o; // return (getKey().equals(state.getKey())); // } // // @Override public int hashCode() { // return getKey().hashCode(); // } // // @Override public String toString() { // return getKey().toString(); // } // // private static final class EmptyState extends State { // public EmptyState(Object flowState) { // super(flowState); // } // // @Override public void save(@NonNull View view) { // } // // @Override public void restore(@NonNull View view) { // } // // @Override public void setBundle(Bundle bundle) { // } // // @Nullable @Override public Bundle getBundle() { // return null; // } // } // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/flow/FlowUtils.java // public final class FlowUtils { // // public interface OnMeasuredCallback { // void onMeasured(View view, int width, int height); // } // // public static void waitForMeasure(final View view, final OnMeasuredCallback callback) { // int width = view.getWidth(); // int height = view.getHeight(); // // if (width > 0 && height > 0) { // callback.onMeasured(view, width, height); // return; // } // // view.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() { // @Override // public boolean onPreDraw() { // final ViewTreeObserver observer = view.getViewTreeObserver(); // if (observer.isAlive()) { // observer.removeOnPreDrawListener(this); // } // // callback.onMeasured(view, view.getWidth(), view.getHeight()); // // return true; // } // }); // } // // private FlowUtils() { // } // }
import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.AnimatorSet; import android.animation.ObjectAnimator; import android.app.Activity; import android.content.Context; import android.support.annotation.LayoutRes; import android.support.annotation.Nullable; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import java.util.LinkedHashMap; import java.util.Locale; import java.util.Map; import flow.Direction; import flow.KeyChanger; import flow.State; import flow.TraversalCallback; import leonardo2204.com.br.flowtests.Layout; import leonardo2204.com.br.flowtests.R; import leonardo2204.com.br.flowtests.flow.FlowUtils;
package leonardo2204.com.br.flowtests.flow.dispatcher; /** * Created by Leonardo on 08/03/2016. */ public class Changer implements KeyChanger { private static Map<Class,Integer> LAYOUT_CACHE = new LinkedHashMap<>(); private final Activity activity; public Changer(Activity activity) { this.activity = activity; } @Override
// Path: flow/src/main/java/flow/KeyChanger.java // public interface KeyChanger { // void changeKey(@Nullable State outgoingState, @NonNull State incomingState, // @NonNull Direction direction, @NonNull Map<Object, Context> incomingContexts, // @NonNull TraversalCallback callback); // } // // Path: flow/src/main/java/flow/State.java // public class State { // /** Creates a State instance that has no state and is effectively immutable. */ // @NonNull public static State empty(@NonNull final Object key) { // return new EmptyState(key); // } // // @NonNull static State fromBundle(@NonNull Bundle savedState, @NonNull KeyParceler parceler) { // Object key = parceler.toKey(savedState.getParcelable("KEY")); // State state = new State(key); // state.viewState = savedState.getSparseParcelableArray("VIEW_STATE"); // state.bundle = savedState.getBundle("BUNDLE"); // return state; // } // // private final Object key; // @Nullable private Bundle bundle; // @Nullable SparseArray<Parcelable> viewState; // // State(Object key) { // // No external instances. // this.key = key; // } // // @NonNull public final <T> T getKey() { // @SuppressWarnings("unchecked") final T state = (T) key; // return state; // } // // public void save(@NonNull View view) { // SparseArray<Parcelable> state = new SparseArray<>(); // view.saveHierarchyState(state); // viewState = state; // } // // public void restore(@NonNull View view) { // if (viewState != null) { // view.restoreHierarchyState(viewState); // } // } // // public void setBundle(@Nullable Bundle bundle) { // this.bundle = bundle; // } // // @Nullable public Bundle getBundle() { // return bundle; // } // // Bundle toBundle(KeyParceler parceler) { // Bundle outState = new Bundle(); // outState.putParcelable("KEY", parceler.toParcelable(getKey())); // if (viewState != null && viewState.size() > 0) { // outState.putSparseParcelableArray("VIEW_STATE", viewState); // } // if (bundle != null && !bundle.isEmpty()) { // outState.putBundle("BUNDLE", bundle); // } // return outState; // } // // @Override public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // State state = (State) o; // return (getKey().equals(state.getKey())); // } // // @Override public int hashCode() { // return getKey().hashCode(); // } // // @Override public String toString() { // return getKey().toString(); // } // // private static final class EmptyState extends State { // public EmptyState(Object flowState) { // super(flowState); // } // // @Override public void save(@NonNull View view) { // } // // @Override public void restore(@NonNull View view) { // } // // @Override public void setBundle(Bundle bundle) { // } // // @Nullable @Override public Bundle getBundle() { // return null; // } // } // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/flow/FlowUtils.java // public final class FlowUtils { // // public interface OnMeasuredCallback { // void onMeasured(View view, int width, int height); // } // // public static void waitForMeasure(final View view, final OnMeasuredCallback callback) { // int width = view.getWidth(); // int height = view.getHeight(); // // if (width > 0 && height > 0) { // callback.onMeasured(view, width, height); // return; // } // // view.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() { // @Override // public boolean onPreDraw() { // final ViewTreeObserver observer = view.getViewTreeObserver(); // if (observer.isAlive()) { // observer.removeOnPreDrawListener(this); // } // // callback.onMeasured(view, view.getWidth(), view.getHeight()); // // return true; // } // }); // } // // private FlowUtils() { // } // } // Path: app/src/main/java/leonardo2204/com/br/flowtests/flow/dispatcher/Changer.java import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.AnimatorSet; import android.animation.ObjectAnimator; import android.app.Activity; import android.content.Context; import android.support.annotation.LayoutRes; import android.support.annotation.Nullable; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import java.util.LinkedHashMap; import java.util.Locale; import java.util.Map; import flow.Direction; import flow.KeyChanger; import flow.State; import flow.TraversalCallback; import leonardo2204.com.br.flowtests.Layout; import leonardo2204.com.br.flowtests.R; import leonardo2204.com.br.flowtests.flow.FlowUtils; package leonardo2204.com.br.flowtests.flow.dispatcher; /** * Created by Leonardo on 08/03/2016. */ public class Changer implements KeyChanger { private static Map<Class,Integer> LAYOUT_CACHE = new LinkedHashMap<>(); private final Activity activity; public Changer(Activity activity) { this.activity = activity; } @Override
public void changeKey(@Nullable State outgoingState, State incomingState,
leonardo2204/Flow1.0.0-alphaExample
app/src/main/java/leonardo2204/com/br/flowtests/flow/dispatcher/Changer.java
// Path: flow/src/main/java/flow/KeyChanger.java // public interface KeyChanger { // void changeKey(@Nullable State outgoingState, @NonNull State incomingState, // @NonNull Direction direction, @NonNull Map<Object, Context> incomingContexts, // @NonNull TraversalCallback callback); // } // // Path: flow/src/main/java/flow/State.java // public class State { // /** Creates a State instance that has no state and is effectively immutable. */ // @NonNull public static State empty(@NonNull final Object key) { // return new EmptyState(key); // } // // @NonNull static State fromBundle(@NonNull Bundle savedState, @NonNull KeyParceler parceler) { // Object key = parceler.toKey(savedState.getParcelable("KEY")); // State state = new State(key); // state.viewState = savedState.getSparseParcelableArray("VIEW_STATE"); // state.bundle = savedState.getBundle("BUNDLE"); // return state; // } // // private final Object key; // @Nullable private Bundle bundle; // @Nullable SparseArray<Parcelable> viewState; // // State(Object key) { // // No external instances. // this.key = key; // } // // @NonNull public final <T> T getKey() { // @SuppressWarnings("unchecked") final T state = (T) key; // return state; // } // // public void save(@NonNull View view) { // SparseArray<Parcelable> state = new SparseArray<>(); // view.saveHierarchyState(state); // viewState = state; // } // // public void restore(@NonNull View view) { // if (viewState != null) { // view.restoreHierarchyState(viewState); // } // } // // public void setBundle(@Nullable Bundle bundle) { // this.bundle = bundle; // } // // @Nullable public Bundle getBundle() { // return bundle; // } // // Bundle toBundle(KeyParceler parceler) { // Bundle outState = new Bundle(); // outState.putParcelable("KEY", parceler.toParcelable(getKey())); // if (viewState != null && viewState.size() > 0) { // outState.putSparseParcelableArray("VIEW_STATE", viewState); // } // if (bundle != null && !bundle.isEmpty()) { // outState.putBundle("BUNDLE", bundle); // } // return outState; // } // // @Override public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // State state = (State) o; // return (getKey().equals(state.getKey())); // } // // @Override public int hashCode() { // return getKey().hashCode(); // } // // @Override public String toString() { // return getKey().toString(); // } // // private static final class EmptyState extends State { // public EmptyState(Object flowState) { // super(flowState); // } // // @Override public void save(@NonNull View view) { // } // // @Override public void restore(@NonNull View view) { // } // // @Override public void setBundle(Bundle bundle) { // } // // @Nullable @Override public Bundle getBundle() { // return null; // } // } // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/flow/FlowUtils.java // public final class FlowUtils { // // public interface OnMeasuredCallback { // void onMeasured(View view, int width, int height); // } // // public static void waitForMeasure(final View view, final OnMeasuredCallback callback) { // int width = view.getWidth(); // int height = view.getHeight(); // // if (width > 0 && height > 0) { // callback.onMeasured(view, width, height); // return; // } // // view.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() { // @Override // public boolean onPreDraw() { // final ViewTreeObserver observer = view.getViewTreeObserver(); // if (observer.isAlive()) { // observer.removeOnPreDrawListener(this); // } // // callback.onMeasured(view, view.getWidth(), view.getHeight()); // // return true; // } // }); // } // // private FlowUtils() { // } // }
import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.AnimatorSet; import android.animation.ObjectAnimator; import android.app.Activity; import android.content.Context; import android.support.annotation.LayoutRes; import android.support.annotation.Nullable; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import java.util.LinkedHashMap; import java.util.Locale; import java.util.Map; import flow.Direction; import flow.KeyChanger; import flow.State; import flow.TraversalCallback; import leonardo2204.com.br.flowtests.Layout; import leonardo2204.com.br.flowtests.R; import leonardo2204.com.br.flowtests.flow.FlowUtils;
final TraversalCallback callback) { final ViewGroup frame = (ViewGroup) activity.findViewById(R.id.content); View fromView = null; if(incomingState != null){ if(frame.getChildCount() > 0){ fromView = frame.getChildAt(0); incomingState.save(frame.getChildAt(0)); } } Context context = incomingContexts.get(incomingState.getKey()); @LayoutRes final int layout = getLayout(incomingState.getKey()); //MortarScope scope = MortarScope.getScope(context.getApplicationContext()); //Context newContext = scope.findChild(incomingState.getKey().getClass().getName()).createContext(context); final View incomingView = LayoutInflater.from(context).inflate(layout,frame,false); if(outgoingState != null) outgoingState.restore(incomingView); if(fromView == null || direction == Direction.REPLACE) { frame.removeAllViews(); frame.addView(incomingView); callback.onTraversalCompleted(); } else { frame.addView(incomingView); final View fromViewFinal = fromView;
// Path: flow/src/main/java/flow/KeyChanger.java // public interface KeyChanger { // void changeKey(@Nullable State outgoingState, @NonNull State incomingState, // @NonNull Direction direction, @NonNull Map<Object, Context> incomingContexts, // @NonNull TraversalCallback callback); // } // // Path: flow/src/main/java/flow/State.java // public class State { // /** Creates a State instance that has no state and is effectively immutable. */ // @NonNull public static State empty(@NonNull final Object key) { // return new EmptyState(key); // } // // @NonNull static State fromBundle(@NonNull Bundle savedState, @NonNull KeyParceler parceler) { // Object key = parceler.toKey(savedState.getParcelable("KEY")); // State state = new State(key); // state.viewState = savedState.getSparseParcelableArray("VIEW_STATE"); // state.bundle = savedState.getBundle("BUNDLE"); // return state; // } // // private final Object key; // @Nullable private Bundle bundle; // @Nullable SparseArray<Parcelable> viewState; // // State(Object key) { // // No external instances. // this.key = key; // } // // @NonNull public final <T> T getKey() { // @SuppressWarnings("unchecked") final T state = (T) key; // return state; // } // // public void save(@NonNull View view) { // SparseArray<Parcelable> state = new SparseArray<>(); // view.saveHierarchyState(state); // viewState = state; // } // // public void restore(@NonNull View view) { // if (viewState != null) { // view.restoreHierarchyState(viewState); // } // } // // public void setBundle(@Nullable Bundle bundle) { // this.bundle = bundle; // } // // @Nullable public Bundle getBundle() { // return bundle; // } // // Bundle toBundle(KeyParceler parceler) { // Bundle outState = new Bundle(); // outState.putParcelable("KEY", parceler.toParcelable(getKey())); // if (viewState != null && viewState.size() > 0) { // outState.putSparseParcelableArray("VIEW_STATE", viewState); // } // if (bundle != null && !bundle.isEmpty()) { // outState.putBundle("BUNDLE", bundle); // } // return outState; // } // // @Override public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // State state = (State) o; // return (getKey().equals(state.getKey())); // } // // @Override public int hashCode() { // return getKey().hashCode(); // } // // @Override public String toString() { // return getKey().toString(); // } // // private static final class EmptyState extends State { // public EmptyState(Object flowState) { // super(flowState); // } // // @Override public void save(@NonNull View view) { // } // // @Override public void restore(@NonNull View view) { // } // // @Override public void setBundle(Bundle bundle) { // } // // @Nullable @Override public Bundle getBundle() { // return null; // } // } // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/flow/FlowUtils.java // public final class FlowUtils { // // public interface OnMeasuredCallback { // void onMeasured(View view, int width, int height); // } // // public static void waitForMeasure(final View view, final OnMeasuredCallback callback) { // int width = view.getWidth(); // int height = view.getHeight(); // // if (width > 0 && height > 0) { // callback.onMeasured(view, width, height); // return; // } // // view.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() { // @Override // public boolean onPreDraw() { // final ViewTreeObserver observer = view.getViewTreeObserver(); // if (observer.isAlive()) { // observer.removeOnPreDrawListener(this); // } // // callback.onMeasured(view, view.getWidth(), view.getHeight()); // // return true; // } // }); // } // // private FlowUtils() { // } // } // Path: app/src/main/java/leonardo2204/com/br/flowtests/flow/dispatcher/Changer.java import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.AnimatorSet; import android.animation.ObjectAnimator; import android.app.Activity; import android.content.Context; import android.support.annotation.LayoutRes; import android.support.annotation.Nullable; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import java.util.LinkedHashMap; import java.util.Locale; import java.util.Map; import flow.Direction; import flow.KeyChanger; import flow.State; import flow.TraversalCallback; import leonardo2204.com.br.flowtests.Layout; import leonardo2204.com.br.flowtests.R; import leonardo2204.com.br.flowtests.flow.FlowUtils; final TraversalCallback callback) { final ViewGroup frame = (ViewGroup) activity.findViewById(R.id.content); View fromView = null; if(incomingState != null){ if(frame.getChildCount() > 0){ fromView = frame.getChildAt(0); incomingState.save(frame.getChildAt(0)); } } Context context = incomingContexts.get(incomingState.getKey()); @LayoutRes final int layout = getLayout(incomingState.getKey()); //MortarScope scope = MortarScope.getScope(context.getApplicationContext()); //Context newContext = scope.findChild(incomingState.getKey().getClass().getName()).createContext(context); final View incomingView = LayoutInflater.from(context).inflate(layout,frame,false); if(outgoingState != null) outgoingState.restore(incomingView); if(fromView == null || direction == Direction.REPLACE) { frame.removeAllViews(); frame.addView(incomingView); callback.onTraversalCompleted(); } else { frame.addView(incomingView); final View fromViewFinal = fromView;
FlowUtils.waitForMeasure(incomingView, new FlowUtils.OnMeasuredCallback() {
leonardo2204/Flow1.0.0-alphaExample
app/src/main/java/leonardo2204/com/br/flowtests/screen/DetailsScreen.java
// Path: app/src/main/java/leonardo2204/com/br/flowtests/di/component/ActivityComponent.java // @DaggerScope(ActivityComponent.class) // @Component(dependencies = AppComponent.class, modules = ActivityModule.class) // public interface ActivityComponent extends AppComponent { // void inject(RootActivity rootActivity); // // ActionBarOwner actionBarOwner(); // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/di/module/DetailScreenModule.java // @Module // public class DetailScreenModule { // // @Provides // @DaggerScope(DetailScreenComponent.class) // public GetDetailedContact providesGetDetailedContact(ContactsRepository contactsRepository, ThreadExecutor threadExecutor, PostExecutionThread postExecutionThread) { // return new GetDetailedContact(contactsRepository, threadExecutor, postExecutionThread); // } // // @Provides // @DaggerScope(DetailScreenComponent.class) // public DetailsScreenPresenter providesDetailsScreenPresenter(GetDetailedContact getDetailedContact, ActionBarOwner actionBarOwner) { // return new DetailsScreenPresenter(getDetailedContact, actionBarOwner); // } // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/flow/keys/DetailsKey.java // public class DetailsKey extends ContactKey { // // protected DetailsKey(Contact contact) { // super(contact); // } // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/flow/keys/EditContactKey.java // public final class EditContactKey extends ContactKey implements TreeKey { // // public EditContactKey(Contact contact) { // super(contact); // } // // @NonNull // @Override // public Object getParentKey() { // return new ContactsUIKey(); // } // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/flow/serviceFactory/InjectionComponent.java // public interface InjectionComponent<T> { // Object createComponent(T parent); // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/model/Contact.java // @Parcel // public class Contact { // // //Don't use private fields, due to reflection penalties using @Parcel // String id; // String name; // List<String> telephone; // // public Contact() { // } // // @ParcelConstructor // public Contact(String id, String name, List<String> telephone) { // this.id = id; // this.name = name; // this.telephone = telephone; // } // // public String getId() { // return id; // } // // public void setId(String id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public List<String> getTelephone() { // return telephone; // } // // public void setTelephone(List<String> telephone) { // this.telephone = telephone; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // Contact contact = (Contact) o; // // return id.equals(contact.id); // // } // // @Override // public int hashCode() { // return id.hashCode(); // } // // @Override // public String toString() { // return "Contact{" + // "id='" + id + '\'' + // ", name='" + name + '\'' + // '}'; // } // }
import android.support.annotation.NonNull; import org.parceler.Parcel; import org.parceler.ParcelConstructor; import flow.TreeKey; import leonardo2204.com.br.flowtests.Layout; import leonardo2204.com.br.flowtests.R; import leonardo2204.com.br.flowtests.di.component.ActivityComponent; import leonardo2204.com.br.flowtests.di.component.DaggerDetailScreenComponent; import leonardo2204.com.br.flowtests.di.module.DetailScreenModule; import leonardo2204.com.br.flowtests.flow.keys.DetailsKey; import leonardo2204.com.br.flowtests.flow.keys.EditContactKey; import leonardo2204.com.br.flowtests.flow.serviceFactory.InjectionComponent; import leonardo2204.com.br.flowtests.model.Contact;
package leonardo2204.com.br.flowtests.screen; /** * Created by Leonardo on 05/03/2016. */ @Parcel @Layout(R.layout.screen_details)
// Path: app/src/main/java/leonardo2204/com/br/flowtests/di/component/ActivityComponent.java // @DaggerScope(ActivityComponent.class) // @Component(dependencies = AppComponent.class, modules = ActivityModule.class) // public interface ActivityComponent extends AppComponent { // void inject(RootActivity rootActivity); // // ActionBarOwner actionBarOwner(); // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/di/module/DetailScreenModule.java // @Module // public class DetailScreenModule { // // @Provides // @DaggerScope(DetailScreenComponent.class) // public GetDetailedContact providesGetDetailedContact(ContactsRepository contactsRepository, ThreadExecutor threadExecutor, PostExecutionThread postExecutionThread) { // return new GetDetailedContact(contactsRepository, threadExecutor, postExecutionThread); // } // // @Provides // @DaggerScope(DetailScreenComponent.class) // public DetailsScreenPresenter providesDetailsScreenPresenter(GetDetailedContact getDetailedContact, ActionBarOwner actionBarOwner) { // return new DetailsScreenPresenter(getDetailedContact, actionBarOwner); // } // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/flow/keys/DetailsKey.java // public class DetailsKey extends ContactKey { // // protected DetailsKey(Contact contact) { // super(contact); // } // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/flow/keys/EditContactKey.java // public final class EditContactKey extends ContactKey implements TreeKey { // // public EditContactKey(Contact contact) { // super(contact); // } // // @NonNull // @Override // public Object getParentKey() { // return new ContactsUIKey(); // } // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/flow/serviceFactory/InjectionComponent.java // public interface InjectionComponent<T> { // Object createComponent(T parent); // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/model/Contact.java // @Parcel // public class Contact { // // //Don't use private fields, due to reflection penalties using @Parcel // String id; // String name; // List<String> telephone; // // public Contact() { // } // // @ParcelConstructor // public Contact(String id, String name, List<String> telephone) { // this.id = id; // this.name = name; // this.telephone = telephone; // } // // public String getId() { // return id; // } // // public void setId(String id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public List<String> getTelephone() { // return telephone; // } // // public void setTelephone(List<String> telephone) { // this.telephone = telephone; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // Contact contact = (Contact) o; // // return id.equals(contact.id); // // } // // @Override // public int hashCode() { // return id.hashCode(); // } // // @Override // public String toString() { // return "Contact{" + // "id='" + id + '\'' + // ", name='" + name + '\'' + // '}'; // } // } // Path: app/src/main/java/leonardo2204/com/br/flowtests/screen/DetailsScreen.java import android.support.annotation.NonNull; import org.parceler.Parcel; import org.parceler.ParcelConstructor; import flow.TreeKey; import leonardo2204.com.br.flowtests.Layout; import leonardo2204.com.br.flowtests.R; import leonardo2204.com.br.flowtests.di.component.ActivityComponent; import leonardo2204.com.br.flowtests.di.component.DaggerDetailScreenComponent; import leonardo2204.com.br.flowtests.di.module.DetailScreenModule; import leonardo2204.com.br.flowtests.flow.keys.DetailsKey; import leonardo2204.com.br.flowtests.flow.keys.EditContactKey; import leonardo2204.com.br.flowtests.flow.serviceFactory.InjectionComponent; import leonardo2204.com.br.flowtests.model.Contact; package leonardo2204.com.br.flowtests.screen; /** * Created by Leonardo on 05/03/2016. */ @Parcel @Layout(R.layout.screen_details)
public final class DetailsScreen extends DetailsKey implements InjectionComponent<ActivityComponent>, TreeKey {
leonardo2204/Flow1.0.0-alphaExample
app/src/main/java/leonardo2204/com/br/flowtests/screen/DetailsScreen.java
// Path: app/src/main/java/leonardo2204/com/br/flowtests/di/component/ActivityComponent.java // @DaggerScope(ActivityComponent.class) // @Component(dependencies = AppComponent.class, modules = ActivityModule.class) // public interface ActivityComponent extends AppComponent { // void inject(RootActivity rootActivity); // // ActionBarOwner actionBarOwner(); // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/di/module/DetailScreenModule.java // @Module // public class DetailScreenModule { // // @Provides // @DaggerScope(DetailScreenComponent.class) // public GetDetailedContact providesGetDetailedContact(ContactsRepository contactsRepository, ThreadExecutor threadExecutor, PostExecutionThread postExecutionThread) { // return new GetDetailedContact(contactsRepository, threadExecutor, postExecutionThread); // } // // @Provides // @DaggerScope(DetailScreenComponent.class) // public DetailsScreenPresenter providesDetailsScreenPresenter(GetDetailedContact getDetailedContact, ActionBarOwner actionBarOwner) { // return new DetailsScreenPresenter(getDetailedContact, actionBarOwner); // } // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/flow/keys/DetailsKey.java // public class DetailsKey extends ContactKey { // // protected DetailsKey(Contact contact) { // super(contact); // } // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/flow/keys/EditContactKey.java // public final class EditContactKey extends ContactKey implements TreeKey { // // public EditContactKey(Contact contact) { // super(contact); // } // // @NonNull // @Override // public Object getParentKey() { // return new ContactsUIKey(); // } // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/flow/serviceFactory/InjectionComponent.java // public interface InjectionComponent<T> { // Object createComponent(T parent); // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/model/Contact.java // @Parcel // public class Contact { // // //Don't use private fields, due to reflection penalties using @Parcel // String id; // String name; // List<String> telephone; // // public Contact() { // } // // @ParcelConstructor // public Contact(String id, String name, List<String> telephone) { // this.id = id; // this.name = name; // this.telephone = telephone; // } // // public String getId() { // return id; // } // // public void setId(String id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public List<String> getTelephone() { // return telephone; // } // // public void setTelephone(List<String> telephone) { // this.telephone = telephone; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // Contact contact = (Contact) o; // // return id.equals(contact.id); // // } // // @Override // public int hashCode() { // return id.hashCode(); // } // // @Override // public String toString() { // return "Contact{" + // "id='" + id + '\'' + // ", name='" + name + '\'' + // '}'; // } // }
import android.support.annotation.NonNull; import org.parceler.Parcel; import org.parceler.ParcelConstructor; import flow.TreeKey; import leonardo2204.com.br.flowtests.Layout; import leonardo2204.com.br.flowtests.R; import leonardo2204.com.br.flowtests.di.component.ActivityComponent; import leonardo2204.com.br.flowtests.di.component.DaggerDetailScreenComponent; import leonardo2204.com.br.flowtests.di.module.DetailScreenModule; import leonardo2204.com.br.flowtests.flow.keys.DetailsKey; import leonardo2204.com.br.flowtests.flow.keys.EditContactKey; import leonardo2204.com.br.flowtests.flow.serviceFactory.InjectionComponent; import leonardo2204.com.br.flowtests.model.Contact;
package leonardo2204.com.br.flowtests.screen; /** * Created by Leonardo on 05/03/2016. */ @Parcel @Layout(R.layout.screen_details)
// Path: app/src/main/java/leonardo2204/com/br/flowtests/di/component/ActivityComponent.java // @DaggerScope(ActivityComponent.class) // @Component(dependencies = AppComponent.class, modules = ActivityModule.class) // public interface ActivityComponent extends AppComponent { // void inject(RootActivity rootActivity); // // ActionBarOwner actionBarOwner(); // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/di/module/DetailScreenModule.java // @Module // public class DetailScreenModule { // // @Provides // @DaggerScope(DetailScreenComponent.class) // public GetDetailedContact providesGetDetailedContact(ContactsRepository contactsRepository, ThreadExecutor threadExecutor, PostExecutionThread postExecutionThread) { // return new GetDetailedContact(contactsRepository, threadExecutor, postExecutionThread); // } // // @Provides // @DaggerScope(DetailScreenComponent.class) // public DetailsScreenPresenter providesDetailsScreenPresenter(GetDetailedContact getDetailedContact, ActionBarOwner actionBarOwner) { // return new DetailsScreenPresenter(getDetailedContact, actionBarOwner); // } // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/flow/keys/DetailsKey.java // public class DetailsKey extends ContactKey { // // protected DetailsKey(Contact contact) { // super(contact); // } // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/flow/keys/EditContactKey.java // public final class EditContactKey extends ContactKey implements TreeKey { // // public EditContactKey(Contact contact) { // super(contact); // } // // @NonNull // @Override // public Object getParentKey() { // return new ContactsUIKey(); // } // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/flow/serviceFactory/InjectionComponent.java // public interface InjectionComponent<T> { // Object createComponent(T parent); // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/model/Contact.java // @Parcel // public class Contact { // // //Don't use private fields, due to reflection penalties using @Parcel // String id; // String name; // List<String> telephone; // // public Contact() { // } // // @ParcelConstructor // public Contact(String id, String name, List<String> telephone) { // this.id = id; // this.name = name; // this.telephone = telephone; // } // // public String getId() { // return id; // } // // public void setId(String id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public List<String> getTelephone() { // return telephone; // } // // public void setTelephone(List<String> telephone) { // this.telephone = telephone; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // Contact contact = (Contact) o; // // return id.equals(contact.id); // // } // // @Override // public int hashCode() { // return id.hashCode(); // } // // @Override // public String toString() { // return "Contact{" + // "id='" + id + '\'' + // ", name='" + name + '\'' + // '}'; // } // } // Path: app/src/main/java/leonardo2204/com/br/flowtests/screen/DetailsScreen.java import android.support.annotation.NonNull; import org.parceler.Parcel; import org.parceler.ParcelConstructor; import flow.TreeKey; import leonardo2204.com.br.flowtests.Layout; import leonardo2204.com.br.flowtests.R; import leonardo2204.com.br.flowtests.di.component.ActivityComponent; import leonardo2204.com.br.flowtests.di.component.DaggerDetailScreenComponent; import leonardo2204.com.br.flowtests.di.module.DetailScreenModule; import leonardo2204.com.br.flowtests.flow.keys.DetailsKey; import leonardo2204.com.br.flowtests.flow.keys.EditContactKey; import leonardo2204.com.br.flowtests.flow.serviceFactory.InjectionComponent; import leonardo2204.com.br.flowtests.model.Contact; package leonardo2204.com.br.flowtests.screen; /** * Created by Leonardo on 05/03/2016. */ @Parcel @Layout(R.layout.screen_details)
public final class DetailsScreen extends DetailsKey implements InjectionComponent<ActivityComponent>, TreeKey {
leonardo2204/Flow1.0.0-alphaExample
app/src/main/java/leonardo2204/com/br/flowtests/screen/DetailsScreen.java
// Path: app/src/main/java/leonardo2204/com/br/flowtests/di/component/ActivityComponent.java // @DaggerScope(ActivityComponent.class) // @Component(dependencies = AppComponent.class, modules = ActivityModule.class) // public interface ActivityComponent extends AppComponent { // void inject(RootActivity rootActivity); // // ActionBarOwner actionBarOwner(); // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/di/module/DetailScreenModule.java // @Module // public class DetailScreenModule { // // @Provides // @DaggerScope(DetailScreenComponent.class) // public GetDetailedContact providesGetDetailedContact(ContactsRepository contactsRepository, ThreadExecutor threadExecutor, PostExecutionThread postExecutionThread) { // return new GetDetailedContact(contactsRepository, threadExecutor, postExecutionThread); // } // // @Provides // @DaggerScope(DetailScreenComponent.class) // public DetailsScreenPresenter providesDetailsScreenPresenter(GetDetailedContact getDetailedContact, ActionBarOwner actionBarOwner) { // return new DetailsScreenPresenter(getDetailedContact, actionBarOwner); // } // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/flow/keys/DetailsKey.java // public class DetailsKey extends ContactKey { // // protected DetailsKey(Contact contact) { // super(contact); // } // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/flow/keys/EditContactKey.java // public final class EditContactKey extends ContactKey implements TreeKey { // // public EditContactKey(Contact contact) { // super(contact); // } // // @NonNull // @Override // public Object getParentKey() { // return new ContactsUIKey(); // } // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/flow/serviceFactory/InjectionComponent.java // public interface InjectionComponent<T> { // Object createComponent(T parent); // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/model/Contact.java // @Parcel // public class Contact { // // //Don't use private fields, due to reflection penalties using @Parcel // String id; // String name; // List<String> telephone; // // public Contact() { // } // // @ParcelConstructor // public Contact(String id, String name, List<String> telephone) { // this.id = id; // this.name = name; // this.telephone = telephone; // } // // public String getId() { // return id; // } // // public void setId(String id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public List<String> getTelephone() { // return telephone; // } // // public void setTelephone(List<String> telephone) { // this.telephone = telephone; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // Contact contact = (Contact) o; // // return id.equals(contact.id); // // } // // @Override // public int hashCode() { // return id.hashCode(); // } // // @Override // public String toString() { // return "Contact{" + // "id='" + id + '\'' + // ", name='" + name + '\'' + // '}'; // } // }
import android.support.annotation.NonNull; import org.parceler.Parcel; import org.parceler.ParcelConstructor; import flow.TreeKey; import leonardo2204.com.br.flowtests.Layout; import leonardo2204.com.br.flowtests.R; import leonardo2204.com.br.flowtests.di.component.ActivityComponent; import leonardo2204.com.br.flowtests.di.component.DaggerDetailScreenComponent; import leonardo2204.com.br.flowtests.di.module.DetailScreenModule; import leonardo2204.com.br.flowtests.flow.keys.DetailsKey; import leonardo2204.com.br.flowtests.flow.keys.EditContactKey; import leonardo2204.com.br.flowtests.flow.serviceFactory.InjectionComponent; import leonardo2204.com.br.flowtests.model.Contact;
package leonardo2204.com.br.flowtests.screen; /** * Created by Leonardo on 05/03/2016. */ @Parcel @Layout(R.layout.screen_details)
// Path: app/src/main/java/leonardo2204/com/br/flowtests/di/component/ActivityComponent.java // @DaggerScope(ActivityComponent.class) // @Component(dependencies = AppComponent.class, modules = ActivityModule.class) // public interface ActivityComponent extends AppComponent { // void inject(RootActivity rootActivity); // // ActionBarOwner actionBarOwner(); // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/di/module/DetailScreenModule.java // @Module // public class DetailScreenModule { // // @Provides // @DaggerScope(DetailScreenComponent.class) // public GetDetailedContact providesGetDetailedContact(ContactsRepository contactsRepository, ThreadExecutor threadExecutor, PostExecutionThread postExecutionThread) { // return new GetDetailedContact(contactsRepository, threadExecutor, postExecutionThread); // } // // @Provides // @DaggerScope(DetailScreenComponent.class) // public DetailsScreenPresenter providesDetailsScreenPresenter(GetDetailedContact getDetailedContact, ActionBarOwner actionBarOwner) { // return new DetailsScreenPresenter(getDetailedContact, actionBarOwner); // } // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/flow/keys/DetailsKey.java // public class DetailsKey extends ContactKey { // // protected DetailsKey(Contact contact) { // super(contact); // } // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/flow/keys/EditContactKey.java // public final class EditContactKey extends ContactKey implements TreeKey { // // public EditContactKey(Contact contact) { // super(contact); // } // // @NonNull // @Override // public Object getParentKey() { // return new ContactsUIKey(); // } // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/flow/serviceFactory/InjectionComponent.java // public interface InjectionComponent<T> { // Object createComponent(T parent); // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/model/Contact.java // @Parcel // public class Contact { // // //Don't use private fields, due to reflection penalties using @Parcel // String id; // String name; // List<String> telephone; // // public Contact() { // } // // @ParcelConstructor // public Contact(String id, String name, List<String> telephone) { // this.id = id; // this.name = name; // this.telephone = telephone; // } // // public String getId() { // return id; // } // // public void setId(String id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public List<String> getTelephone() { // return telephone; // } // // public void setTelephone(List<String> telephone) { // this.telephone = telephone; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // Contact contact = (Contact) o; // // return id.equals(contact.id); // // } // // @Override // public int hashCode() { // return id.hashCode(); // } // // @Override // public String toString() { // return "Contact{" + // "id='" + id + '\'' + // ", name='" + name + '\'' + // '}'; // } // } // Path: app/src/main/java/leonardo2204/com/br/flowtests/screen/DetailsScreen.java import android.support.annotation.NonNull; import org.parceler.Parcel; import org.parceler.ParcelConstructor; import flow.TreeKey; import leonardo2204.com.br.flowtests.Layout; import leonardo2204.com.br.flowtests.R; import leonardo2204.com.br.flowtests.di.component.ActivityComponent; import leonardo2204.com.br.flowtests.di.component.DaggerDetailScreenComponent; import leonardo2204.com.br.flowtests.di.module.DetailScreenModule; import leonardo2204.com.br.flowtests.flow.keys.DetailsKey; import leonardo2204.com.br.flowtests.flow.keys.EditContactKey; import leonardo2204.com.br.flowtests.flow.serviceFactory.InjectionComponent; import leonardo2204.com.br.flowtests.model.Contact; package leonardo2204.com.br.flowtests.screen; /** * Created by Leonardo on 05/03/2016. */ @Parcel @Layout(R.layout.screen_details)
public final class DetailsScreen extends DetailsKey implements InjectionComponent<ActivityComponent>, TreeKey {
leonardo2204/Flow1.0.0-alphaExample
app/src/main/java/leonardo2204/com/br/flowtests/screen/DetailsScreen.java
// Path: app/src/main/java/leonardo2204/com/br/flowtests/di/component/ActivityComponent.java // @DaggerScope(ActivityComponent.class) // @Component(dependencies = AppComponent.class, modules = ActivityModule.class) // public interface ActivityComponent extends AppComponent { // void inject(RootActivity rootActivity); // // ActionBarOwner actionBarOwner(); // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/di/module/DetailScreenModule.java // @Module // public class DetailScreenModule { // // @Provides // @DaggerScope(DetailScreenComponent.class) // public GetDetailedContact providesGetDetailedContact(ContactsRepository contactsRepository, ThreadExecutor threadExecutor, PostExecutionThread postExecutionThread) { // return new GetDetailedContact(contactsRepository, threadExecutor, postExecutionThread); // } // // @Provides // @DaggerScope(DetailScreenComponent.class) // public DetailsScreenPresenter providesDetailsScreenPresenter(GetDetailedContact getDetailedContact, ActionBarOwner actionBarOwner) { // return new DetailsScreenPresenter(getDetailedContact, actionBarOwner); // } // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/flow/keys/DetailsKey.java // public class DetailsKey extends ContactKey { // // protected DetailsKey(Contact contact) { // super(contact); // } // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/flow/keys/EditContactKey.java // public final class EditContactKey extends ContactKey implements TreeKey { // // public EditContactKey(Contact contact) { // super(contact); // } // // @NonNull // @Override // public Object getParentKey() { // return new ContactsUIKey(); // } // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/flow/serviceFactory/InjectionComponent.java // public interface InjectionComponent<T> { // Object createComponent(T parent); // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/model/Contact.java // @Parcel // public class Contact { // // //Don't use private fields, due to reflection penalties using @Parcel // String id; // String name; // List<String> telephone; // // public Contact() { // } // // @ParcelConstructor // public Contact(String id, String name, List<String> telephone) { // this.id = id; // this.name = name; // this.telephone = telephone; // } // // public String getId() { // return id; // } // // public void setId(String id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public List<String> getTelephone() { // return telephone; // } // // public void setTelephone(List<String> telephone) { // this.telephone = telephone; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // Contact contact = (Contact) o; // // return id.equals(contact.id); // // } // // @Override // public int hashCode() { // return id.hashCode(); // } // // @Override // public String toString() { // return "Contact{" + // "id='" + id + '\'' + // ", name='" + name + '\'' + // '}'; // } // }
import android.support.annotation.NonNull; import org.parceler.Parcel; import org.parceler.ParcelConstructor; import flow.TreeKey; import leonardo2204.com.br.flowtests.Layout; import leonardo2204.com.br.flowtests.R; import leonardo2204.com.br.flowtests.di.component.ActivityComponent; import leonardo2204.com.br.flowtests.di.component.DaggerDetailScreenComponent; import leonardo2204.com.br.flowtests.di.module.DetailScreenModule; import leonardo2204.com.br.flowtests.flow.keys.DetailsKey; import leonardo2204.com.br.flowtests.flow.keys.EditContactKey; import leonardo2204.com.br.flowtests.flow.serviceFactory.InjectionComponent; import leonardo2204.com.br.flowtests.model.Contact;
package leonardo2204.com.br.flowtests.screen; /** * Created by Leonardo on 05/03/2016. */ @Parcel @Layout(R.layout.screen_details) public final class DetailsScreen extends DetailsKey implements InjectionComponent<ActivityComponent>, TreeKey { @ParcelConstructor
// Path: app/src/main/java/leonardo2204/com/br/flowtests/di/component/ActivityComponent.java // @DaggerScope(ActivityComponent.class) // @Component(dependencies = AppComponent.class, modules = ActivityModule.class) // public interface ActivityComponent extends AppComponent { // void inject(RootActivity rootActivity); // // ActionBarOwner actionBarOwner(); // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/di/module/DetailScreenModule.java // @Module // public class DetailScreenModule { // // @Provides // @DaggerScope(DetailScreenComponent.class) // public GetDetailedContact providesGetDetailedContact(ContactsRepository contactsRepository, ThreadExecutor threadExecutor, PostExecutionThread postExecutionThread) { // return new GetDetailedContact(contactsRepository, threadExecutor, postExecutionThread); // } // // @Provides // @DaggerScope(DetailScreenComponent.class) // public DetailsScreenPresenter providesDetailsScreenPresenter(GetDetailedContact getDetailedContact, ActionBarOwner actionBarOwner) { // return new DetailsScreenPresenter(getDetailedContact, actionBarOwner); // } // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/flow/keys/DetailsKey.java // public class DetailsKey extends ContactKey { // // protected DetailsKey(Contact contact) { // super(contact); // } // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/flow/keys/EditContactKey.java // public final class EditContactKey extends ContactKey implements TreeKey { // // public EditContactKey(Contact contact) { // super(contact); // } // // @NonNull // @Override // public Object getParentKey() { // return new ContactsUIKey(); // } // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/flow/serviceFactory/InjectionComponent.java // public interface InjectionComponent<T> { // Object createComponent(T parent); // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/model/Contact.java // @Parcel // public class Contact { // // //Don't use private fields, due to reflection penalties using @Parcel // String id; // String name; // List<String> telephone; // // public Contact() { // } // // @ParcelConstructor // public Contact(String id, String name, List<String> telephone) { // this.id = id; // this.name = name; // this.telephone = telephone; // } // // public String getId() { // return id; // } // // public void setId(String id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public List<String> getTelephone() { // return telephone; // } // // public void setTelephone(List<String> telephone) { // this.telephone = telephone; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // Contact contact = (Contact) o; // // return id.equals(contact.id); // // } // // @Override // public int hashCode() { // return id.hashCode(); // } // // @Override // public String toString() { // return "Contact{" + // "id='" + id + '\'' + // ", name='" + name + '\'' + // '}'; // } // } // Path: app/src/main/java/leonardo2204/com/br/flowtests/screen/DetailsScreen.java import android.support.annotation.NonNull; import org.parceler.Parcel; import org.parceler.ParcelConstructor; import flow.TreeKey; import leonardo2204.com.br.flowtests.Layout; import leonardo2204.com.br.flowtests.R; import leonardo2204.com.br.flowtests.di.component.ActivityComponent; import leonardo2204.com.br.flowtests.di.component.DaggerDetailScreenComponent; import leonardo2204.com.br.flowtests.di.module.DetailScreenModule; import leonardo2204.com.br.flowtests.flow.keys.DetailsKey; import leonardo2204.com.br.flowtests.flow.keys.EditContactKey; import leonardo2204.com.br.flowtests.flow.serviceFactory.InjectionComponent; import leonardo2204.com.br.flowtests.model.Contact; package leonardo2204.com.br.flowtests.screen; /** * Created by Leonardo on 05/03/2016. */ @Parcel @Layout(R.layout.screen_details) public final class DetailsScreen extends DetailsKey implements InjectionComponent<ActivityComponent>, TreeKey { @ParcelConstructor
public DetailsScreen(Contact contact) {
leonardo2204/Flow1.0.0-alphaExample
app/src/main/java/leonardo2204/com/br/flowtests/screen/DetailsScreen.java
// Path: app/src/main/java/leonardo2204/com/br/flowtests/di/component/ActivityComponent.java // @DaggerScope(ActivityComponent.class) // @Component(dependencies = AppComponent.class, modules = ActivityModule.class) // public interface ActivityComponent extends AppComponent { // void inject(RootActivity rootActivity); // // ActionBarOwner actionBarOwner(); // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/di/module/DetailScreenModule.java // @Module // public class DetailScreenModule { // // @Provides // @DaggerScope(DetailScreenComponent.class) // public GetDetailedContact providesGetDetailedContact(ContactsRepository contactsRepository, ThreadExecutor threadExecutor, PostExecutionThread postExecutionThread) { // return new GetDetailedContact(contactsRepository, threadExecutor, postExecutionThread); // } // // @Provides // @DaggerScope(DetailScreenComponent.class) // public DetailsScreenPresenter providesDetailsScreenPresenter(GetDetailedContact getDetailedContact, ActionBarOwner actionBarOwner) { // return new DetailsScreenPresenter(getDetailedContact, actionBarOwner); // } // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/flow/keys/DetailsKey.java // public class DetailsKey extends ContactKey { // // protected DetailsKey(Contact contact) { // super(contact); // } // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/flow/keys/EditContactKey.java // public final class EditContactKey extends ContactKey implements TreeKey { // // public EditContactKey(Contact contact) { // super(contact); // } // // @NonNull // @Override // public Object getParentKey() { // return new ContactsUIKey(); // } // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/flow/serviceFactory/InjectionComponent.java // public interface InjectionComponent<T> { // Object createComponent(T parent); // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/model/Contact.java // @Parcel // public class Contact { // // //Don't use private fields, due to reflection penalties using @Parcel // String id; // String name; // List<String> telephone; // // public Contact() { // } // // @ParcelConstructor // public Contact(String id, String name, List<String> telephone) { // this.id = id; // this.name = name; // this.telephone = telephone; // } // // public String getId() { // return id; // } // // public void setId(String id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public List<String> getTelephone() { // return telephone; // } // // public void setTelephone(List<String> telephone) { // this.telephone = telephone; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // Contact contact = (Contact) o; // // return id.equals(contact.id); // // } // // @Override // public int hashCode() { // return id.hashCode(); // } // // @Override // public String toString() { // return "Contact{" + // "id='" + id + '\'' + // ", name='" + name + '\'' + // '}'; // } // }
import android.support.annotation.NonNull; import org.parceler.Parcel; import org.parceler.ParcelConstructor; import flow.TreeKey; import leonardo2204.com.br.flowtests.Layout; import leonardo2204.com.br.flowtests.R; import leonardo2204.com.br.flowtests.di.component.ActivityComponent; import leonardo2204.com.br.flowtests.di.component.DaggerDetailScreenComponent; import leonardo2204.com.br.flowtests.di.module.DetailScreenModule; import leonardo2204.com.br.flowtests.flow.keys.DetailsKey; import leonardo2204.com.br.flowtests.flow.keys.EditContactKey; import leonardo2204.com.br.flowtests.flow.serviceFactory.InjectionComponent; import leonardo2204.com.br.flowtests.model.Contact;
package leonardo2204.com.br.flowtests.screen; /** * Created by Leonardo on 05/03/2016. */ @Parcel @Layout(R.layout.screen_details) public final class DetailsScreen extends DetailsKey implements InjectionComponent<ActivityComponent>, TreeKey { @ParcelConstructor public DetailsScreen(Contact contact) { super(contact); } public Contact getContact() { return contact; } @Override public Object createComponent(ActivityComponent parent) { return DaggerDetailScreenComponent .builder() .activityComponent(parent)
// Path: app/src/main/java/leonardo2204/com/br/flowtests/di/component/ActivityComponent.java // @DaggerScope(ActivityComponent.class) // @Component(dependencies = AppComponent.class, modules = ActivityModule.class) // public interface ActivityComponent extends AppComponent { // void inject(RootActivity rootActivity); // // ActionBarOwner actionBarOwner(); // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/di/module/DetailScreenModule.java // @Module // public class DetailScreenModule { // // @Provides // @DaggerScope(DetailScreenComponent.class) // public GetDetailedContact providesGetDetailedContact(ContactsRepository contactsRepository, ThreadExecutor threadExecutor, PostExecutionThread postExecutionThread) { // return new GetDetailedContact(contactsRepository, threadExecutor, postExecutionThread); // } // // @Provides // @DaggerScope(DetailScreenComponent.class) // public DetailsScreenPresenter providesDetailsScreenPresenter(GetDetailedContact getDetailedContact, ActionBarOwner actionBarOwner) { // return new DetailsScreenPresenter(getDetailedContact, actionBarOwner); // } // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/flow/keys/DetailsKey.java // public class DetailsKey extends ContactKey { // // protected DetailsKey(Contact contact) { // super(contact); // } // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/flow/keys/EditContactKey.java // public final class EditContactKey extends ContactKey implements TreeKey { // // public EditContactKey(Contact contact) { // super(contact); // } // // @NonNull // @Override // public Object getParentKey() { // return new ContactsUIKey(); // } // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/flow/serviceFactory/InjectionComponent.java // public interface InjectionComponent<T> { // Object createComponent(T parent); // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/model/Contact.java // @Parcel // public class Contact { // // //Don't use private fields, due to reflection penalties using @Parcel // String id; // String name; // List<String> telephone; // // public Contact() { // } // // @ParcelConstructor // public Contact(String id, String name, List<String> telephone) { // this.id = id; // this.name = name; // this.telephone = telephone; // } // // public String getId() { // return id; // } // // public void setId(String id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public List<String> getTelephone() { // return telephone; // } // // public void setTelephone(List<String> telephone) { // this.telephone = telephone; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // Contact contact = (Contact) o; // // return id.equals(contact.id); // // } // // @Override // public int hashCode() { // return id.hashCode(); // } // // @Override // public String toString() { // return "Contact{" + // "id='" + id + '\'' + // ", name='" + name + '\'' + // '}'; // } // } // Path: app/src/main/java/leonardo2204/com/br/flowtests/screen/DetailsScreen.java import android.support.annotation.NonNull; import org.parceler.Parcel; import org.parceler.ParcelConstructor; import flow.TreeKey; import leonardo2204.com.br.flowtests.Layout; import leonardo2204.com.br.flowtests.R; import leonardo2204.com.br.flowtests.di.component.ActivityComponent; import leonardo2204.com.br.flowtests.di.component.DaggerDetailScreenComponent; import leonardo2204.com.br.flowtests.di.module.DetailScreenModule; import leonardo2204.com.br.flowtests.flow.keys.DetailsKey; import leonardo2204.com.br.flowtests.flow.keys.EditContactKey; import leonardo2204.com.br.flowtests.flow.serviceFactory.InjectionComponent; import leonardo2204.com.br.flowtests.model.Contact; package leonardo2204.com.br.flowtests.screen; /** * Created by Leonardo on 05/03/2016. */ @Parcel @Layout(R.layout.screen_details) public final class DetailsScreen extends DetailsKey implements InjectionComponent<ActivityComponent>, TreeKey { @ParcelConstructor public DetailsScreen(Contact contact) { super(contact); } public Contact getContact() { return contact; } @Override public Object createComponent(ActivityComponent parent) { return DaggerDetailScreenComponent .builder() .activityComponent(parent)
.detailScreenModule(new DetailScreenModule())
leonardo2204/Flow1.0.0-alphaExample
app/src/main/java/leonardo2204/com/br/flowtests/screen/DetailsScreen.java
// Path: app/src/main/java/leonardo2204/com/br/flowtests/di/component/ActivityComponent.java // @DaggerScope(ActivityComponent.class) // @Component(dependencies = AppComponent.class, modules = ActivityModule.class) // public interface ActivityComponent extends AppComponent { // void inject(RootActivity rootActivity); // // ActionBarOwner actionBarOwner(); // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/di/module/DetailScreenModule.java // @Module // public class DetailScreenModule { // // @Provides // @DaggerScope(DetailScreenComponent.class) // public GetDetailedContact providesGetDetailedContact(ContactsRepository contactsRepository, ThreadExecutor threadExecutor, PostExecutionThread postExecutionThread) { // return new GetDetailedContact(contactsRepository, threadExecutor, postExecutionThread); // } // // @Provides // @DaggerScope(DetailScreenComponent.class) // public DetailsScreenPresenter providesDetailsScreenPresenter(GetDetailedContact getDetailedContact, ActionBarOwner actionBarOwner) { // return new DetailsScreenPresenter(getDetailedContact, actionBarOwner); // } // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/flow/keys/DetailsKey.java // public class DetailsKey extends ContactKey { // // protected DetailsKey(Contact contact) { // super(contact); // } // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/flow/keys/EditContactKey.java // public final class EditContactKey extends ContactKey implements TreeKey { // // public EditContactKey(Contact contact) { // super(contact); // } // // @NonNull // @Override // public Object getParentKey() { // return new ContactsUIKey(); // } // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/flow/serviceFactory/InjectionComponent.java // public interface InjectionComponent<T> { // Object createComponent(T parent); // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/model/Contact.java // @Parcel // public class Contact { // // //Don't use private fields, due to reflection penalties using @Parcel // String id; // String name; // List<String> telephone; // // public Contact() { // } // // @ParcelConstructor // public Contact(String id, String name, List<String> telephone) { // this.id = id; // this.name = name; // this.telephone = telephone; // } // // public String getId() { // return id; // } // // public void setId(String id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public List<String> getTelephone() { // return telephone; // } // // public void setTelephone(List<String> telephone) { // this.telephone = telephone; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // Contact contact = (Contact) o; // // return id.equals(contact.id); // // } // // @Override // public int hashCode() { // return id.hashCode(); // } // // @Override // public String toString() { // return "Contact{" + // "id='" + id + '\'' + // ", name='" + name + '\'' + // '}'; // } // }
import android.support.annotation.NonNull; import org.parceler.Parcel; import org.parceler.ParcelConstructor; import flow.TreeKey; import leonardo2204.com.br.flowtests.Layout; import leonardo2204.com.br.flowtests.R; import leonardo2204.com.br.flowtests.di.component.ActivityComponent; import leonardo2204.com.br.flowtests.di.component.DaggerDetailScreenComponent; import leonardo2204.com.br.flowtests.di.module.DetailScreenModule; import leonardo2204.com.br.flowtests.flow.keys.DetailsKey; import leonardo2204.com.br.flowtests.flow.keys.EditContactKey; import leonardo2204.com.br.flowtests.flow.serviceFactory.InjectionComponent; import leonardo2204.com.br.flowtests.model.Contact;
package leonardo2204.com.br.flowtests.screen; /** * Created by Leonardo on 05/03/2016. */ @Parcel @Layout(R.layout.screen_details) public final class DetailsScreen extends DetailsKey implements InjectionComponent<ActivityComponent>, TreeKey { @ParcelConstructor public DetailsScreen(Contact contact) { super(contact); } public Contact getContact() { return contact; } @Override public Object createComponent(ActivityComponent parent) { return DaggerDetailScreenComponent .builder() .activityComponent(parent) .detailScreenModule(new DetailScreenModule()) .build(); } @NonNull @Override public Object getParentKey() {
// Path: app/src/main/java/leonardo2204/com/br/flowtests/di/component/ActivityComponent.java // @DaggerScope(ActivityComponent.class) // @Component(dependencies = AppComponent.class, modules = ActivityModule.class) // public interface ActivityComponent extends AppComponent { // void inject(RootActivity rootActivity); // // ActionBarOwner actionBarOwner(); // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/di/module/DetailScreenModule.java // @Module // public class DetailScreenModule { // // @Provides // @DaggerScope(DetailScreenComponent.class) // public GetDetailedContact providesGetDetailedContact(ContactsRepository contactsRepository, ThreadExecutor threadExecutor, PostExecutionThread postExecutionThread) { // return new GetDetailedContact(contactsRepository, threadExecutor, postExecutionThread); // } // // @Provides // @DaggerScope(DetailScreenComponent.class) // public DetailsScreenPresenter providesDetailsScreenPresenter(GetDetailedContact getDetailedContact, ActionBarOwner actionBarOwner) { // return new DetailsScreenPresenter(getDetailedContact, actionBarOwner); // } // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/flow/keys/DetailsKey.java // public class DetailsKey extends ContactKey { // // protected DetailsKey(Contact contact) { // super(contact); // } // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/flow/keys/EditContactKey.java // public final class EditContactKey extends ContactKey implements TreeKey { // // public EditContactKey(Contact contact) { // super(contact); // } // // @NonNull // @Override // public Object getParentKey() { // return new ContactsUIKey(); // } // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/flow/serviceFactory/InjectionComponent.java // public interface InjectionComponent<T> { // Object createComponent(T parent); // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/model/Contact.java // @Parcel // public class Contact { // // //Don't use private fields, due to reflection penalties using @Parcel // String id; // String name; // List<String> telephone; // // public Contact() { // } // // @ParcelConstructor // public Contact(String id, String name, List<String> telephone) { // this.id = id; // this.name = name; // this.telephone = telephone; // } // // public String getId() { // return id; // } // // public void setId(String id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public List<String> getTelephone() { // return telephone; // } // // public void setTelephone(List<String> telephone) { // this.telephone = telephone; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // Contact contact = (Contact) o; // // return id.equals(contact.id); // // } // // @Override // public int hashCode() { // return id.hashCode(); // } // // @Override // public String toString() { // return "Contact{" + // "id='" + id + '\'' + // ", name='" + name + '\'' + // '}'; // } // } // Path: app/src/main/java/leonardo2204/com/br/flowtests/screen/DetailsScreen.java import android.support.annotation.NonNull; import org.parceler.Parcel; import org.parceler.ParcelConstructor; import flow.TreeKey; import leonardo2204.com.br.flowtests.Layout; import leonardo2204.com.br.flowtests.R; import leonardo2204.com.br.flowtests.di.component.ActivityComponent; import leonardo2204.com.br.flowtests.di.component.DaggerDetailScreenComponent; import leonardo2204.com.br.flowtests.di.module.DetailScreenModule; import leonardo2204.com.br.flowtests.flow.keys.DetailsKey; import leonardo2204.com.br.flowtests.flow.keys.EditContactKey; import leonardo2204.com.br.flowtests.flow.serviceFactory.InjectionComponent; import leonardo2204.com.br.flowtests.model.Contact; package leonardo2204.com.br.flowtests.screen; /** * Created by Leonardo on 05/03/2016. */ @Parcel @Layout(R.layout.screen_details) public final class DetailsScreen extends DetailsKey implements InjectionComponent<ActivityComponent>, TreeKey { @ParcelConstructor public DetailsScreen(Contact contact) { super(contact); } public Contact getContact() { return contact; } @Override public Object createComponent(ActivityComponent parent) { return DaggerDetailScreenComponent .builder() .activityComponent(parent) .detailScreenModule(new DetailScreenModule()) .build(); } @NonNull @Override public Object getParentKey() {
return new EditContactKey(contact);
leonardo2204/Flow1.0.0-alphaExample
app/src/main/java/leonardo2204/com/br/flowtests/flow/dispatcher/BasicDispatcher.java
// Path: flow/src/main/java/flow/Dispatcher.java // public interface Dispatcher { // /** // * Called when the history is about to change. Note that Flow does not consider the // * Traversal to be finished, and will not actually update the history, until the callback is // * triggered. Traversals cannot be canceled. // * // * @param callback Must be called to indicate completion of the traversal. // */ // void dispatch(@NonNull Traversal traversal, @NonNull TraversalCallback callback); // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/flow/FlowUtils.java // public final class FlowUtils { // // public interface OnMeasuredCallback { // void onMeasured(View view, int width, int height); // } // // public static void waitForMeasure(final View view, final OnMeasuredCallback callback) { // int width = view.getWidth(); // int height = view.getHeight(); // // if (width > 0 && height > 0) { // callback.onMeasured(view, width, height); // return; // } // // view.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() { // @Override // public boolean onPreDraw() { // final ViewTreeObserver observer = view.getViewTreeObserver(); // if (observer.isAlive()) { // observer.removeOnPreDrawListener(this); // } // // callback.onMeasured(view, view.getWidth(), view.getHeight()); // // return true; // } // }); // } // // private FlowUtils() { // } // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/screen/BaseScreen.java // public abstract class BaseScreen extends ClassKey implements InjectionComponent { // // public abstract // @LayoutRes // int layoutResId(); // }
import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.AnimatorSet; import android.animation.ObjectAnimator; import android.app.Activity; import android.support.annotation.LayoutRes; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import java.util.Locale; import flow.Direction; import flow.Dispatcher; import flow.Traversal; import flow.TraversalCallback; import leonardo2204.com.br.flowtests.R; import leonardo2204.com.br.flowtests.flow.FlowUtils; import leonardo2204.com.br.flowtests.screen.BaseScreen;
package leonardo2204.com.br.flowtests.flow.dispatcher; /** * Created by Leonardo on 04/03/2016. */ public final class BasicDispatcher implements Dispatcher { //private static Map<Class,Integer> LAYOUT_CACHE = new LinkedHashMap<>(); private final Activity activity; public BasicDispatcher(Activity activity) { this.activity = activity; } @Override public void dispatch(final Traversal traversal, final TraversalCallback callback) { Object dest = traversal.destination.top(); final ViewGroup frame = (ViewGroup) activity.findViewById(R.id.content); View fromView = null; if(traversal.origin != null){ if(frame.getChildCount() > 0){ fromView = frame.getChildAt(0); traversal.getState(traversal.origin.top()).save(frame.getChildAt(0)); } }
// Path: flow/src/main/java/flow/Dispatcher.java // public interface Dispatcher { // /** // * Called when the history is about to change. Note that Flow does not consider the // * Traversal to be finished, and will not actually update the history, until the callback is // * triggered. Traversals cannot be canceled. // * // * @param callback Must be called to indicate completion of the traversal. // */ // void dispatch(@NonNull Traversal traversal, @NonNull TraversalCallback callback); // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/flow/FlowUtils.java // public final class FlowUtils { // // public interface OnMeasuredCallback { // void onMeasured(View view, int width, int height); // } // // public static void waitForMeasure(final View view, final OnMeasuredCallback callback) { // int width = view.getWidth(); // int height = view.getHeight(); // // if (width > 0 && height > 0) { // callback.onMeasured(view, width, height); // return; // } // // view.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() { // @Override // public boolean onPreDraw() { // final ViewTreeObserver observer = view.getViewTreeObserver(); // if (observer.isAlive()) { // observer.removeOnPreDrawListener(this); // } // // callback.onMeasured(view, view.getWidth(), view.getHeight()); // // return true; // } // }); // } // // private FlowUtils() { // } // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/screen/BaseScreen.java // public abstract class BaseScreen extends ClassKey implements InjectionComponent { // // public abstract // @LayoutRes // int layoutResId(); // } // Path: app/src/main/java/leonardo2204/com/br/flowtests/flow/dispatcher/BasicDispatcher.java import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.AnimatorSet; import android.animation.ObjectAnimator; import android.app.Activity; import android.support.annotation.LayoutRes; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import java.util.Locale; import flow.Direction; import flow.Dispatcher; import flow.Traversal; import flow.TraversalCallback; import leonardo2204.com.br.flowtests.R; import leonardo2204.com.br.flowtests.flow.FlowUtils; import leonardo2204.com.br.flowtests.screen.BaseScreen; package leonardo2204.com.br.flowtests.flow.dispatcher; /** * Created by Leonardo on 04/03/2016. */ public final class BasicDispatcher implements Dispatcher { //private static Map<Class,Integer> LAYOUT_CACHE = new LinkedHashMap<>(); private final Activity activity; public BasicDispatcher(Activity activity) { this.activity = activity; } @Override public void dispatch(final Traversal traversal, final TraversalCallback callback) { Object dest = traversal.destination.top(); final ViewGroup frame = (ViewGroup) activity.findViewById(R.id.content); View fromView = null; if(traversal.origin != null){ if(frame.getChildCount() > 0){ fromView = frame.getChildAt(0); traversal.getState(traversal.origin.top()).save(frame.getChildAt(0)); } }
if (!(dest instanceof BaseScreen))
leonardo2204/Flow1.0.0-alphaExample
app/src/main/java/leonardo2204/com/br/flowtests/flow/dispatcher/BasicDispatcher.java
// Path: flow/src/main/java/flow/Dispatcher.java // public interface Dispatcher { // /** // * Called when the history is about to change. Note that Flow does not consider the // * Traversal to be finished, and will not actually update the history, until the callback is // * triggered. Traversals cannot be canceled. // * // * @param callback Must be called to indicate completion of the traversal. // */ // void dispatch(@NonNull Traversal traversal, @NonNull TraversalCallback callback); // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/flow/FlowUtils.java // public final class FlowUtils { // // public interface OnMeasuredCallback { // void onMeasured(View view, int width, int height); // } // // public static void waitForMeasure(final View view, final OnMeasuredCallback callback) { // int width = view.getWidth(); // int height = view.getHeight(); // // if (width > 0 && height > 0) { // callback.onMeasured(view, width, height); // return; // } // // view.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() { // @Override // public boolean onPreDraw() { // final ViewTreeObserver observer = view.getViewTreeObserver(); // if (observer.isAlive()) { // observer.removeOnPreDrawListener(this); // } // // callback.onMeasured(view, view.getWidth(), view.getHeight()); // // return true; // } // }); // } // // private FlowUtils() { // } // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/screen/BaseScreen.java // public abstract class BaseScreen extends ClassKey implements InjectionComponent { // // public abstract // @LayoutRes // int layoutResId(); // }
import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.AnimatorSet; import android.animation.ObjectAnimator; import android.app.Activity; import android.support.annotation.LayoutRes; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import java.util.Locale; import flow.Direction; import flow.Dispatcher; import flow.Traversal; import flow.TraversalCallback; import leonardo2204.com.br.flowtests.R; import leonardo2204.com.br.flowtests.flow.FlowUtils; import leonardo2204.com.br.flowtests.screen.BaseScreen;
package leonardo2204.com.br.flowtests.flow.dispatcher; /** * Created by Leonardo on 04/03/2016. */ public final class BasicDispatcher implements Dispatcher { //private static Map<Class,Integer> LAYOUT_CACHE = new LinkedHashMap<>(); private final Activity activity; public BasicDispatcher(Activity activity) { this.activity = activity; } @Override public void dispatch(final Traversal traversal, final TraversalCallback callback) { Object dest = traversal.destination.top(); final ViewGroup frame = (ViewGroup) activity.findViewById(R.id.content); View fromView = null; if(traversal.origin != null){ if(frame.getChildCount() > 0){ fromView = frame.getChildAt(0); traversal.getState(traversal.origin.top()).save(frame.getChildAt(0)); } } if (!(dest instanceof BaseScreen)) throw new IllegalStateException(String.format(Locale.getDefault(), "The screen %s must implement BaseScreen", dest.getClass().getName())); @LayoutRes final int layout = ((BaseScreen) dest).layoutResId(); final View incomingView = LayoutInflater.from(traversal.createContext(dest,activity)).inflate(layout,frame,false); traversal.getState(traversal.destination.top()).restore(incomingView); if(fromView == null || traversal.direction == Direction.REPLACE) { frame.removeAllViews(); frame.addView(incomingView); callback.onTraversalCompleted(); }else{ frame.addView(incomingView); final View fromViewFinal = fromView;
// Path: flow/src/main/java/flow/Dispatcher.java // public interface Dispatcher { // /** // * Called when the history is about to change. Note that Flow does not consider the // * Traversal to be finished, and will not actually update the history, until the callback is // * triggered. Traversals cannot be canceled. // * // * @param callback Must be called to indicate completion of the traversal. // */ // void dispatch(@NonNull Traversal traversal, @NonNull TraversalCallback callback); // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/flow/FlowUtils.java // public final class FlowUtils { // // public interface OnMeasuredCallback { // void onMeasured(View view, int width, int height); // } // // public static void waitForMeasure(final View view, final OnMeasuredCallback callback) { // int width = view.getWidth(); // int height = view.getHeight(); // // if (width > 0 && height > 0) { // callback.onMeasured(view, width, height); // return; // } // // view.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() { // @Override // public boolean onPreDraw() { // final ViewTreeObserver observer = view.getViewTreeObserver(); // if (observer.isAlive()) { // observer.removeOnPreDrawListener(this); // } // // callback.onMeasured(view, view.getWidth(), view.getHeight()); // // return true; // } // }); // } // // private FlowUtils() { // } // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/screen/BaseScreen.java // public abstract class BaseScreen extends ClassKey implements InjectionComponent { // // public abstract // @LayoutRes // int layoutResId(); // } // Path: app/src/main/java/leonardo2204/com/br/flowtests/flow/dispatcher/BasicDispatcher.java import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.AnimatorSet; import android.animation.ObjectAnimator; import android.app.Activity; import android.support.annotation.LayoutRes; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import java.util.Locale; import flow.Direction; import flow.Dispatcher; import flow.Traversal; import flow.TraversalCallback; import leonardo2204.com.br.flowtests.R; import leonardo2204.com.br.flowtests.flow.FlowUtils; import leonardo2204.com.br.flowtests.screen.BaseScreen; package leonardo2204.com.br.flowtests.flow.dispatcher; /** * Created by Leonardo on 04/03/2016. */ public final class BasicDispatcher implements Dispatcher { //private static Map<Class,Integer> LAYOUT_CACHE = new LinkedHashMap<>(); private final Activity activity; public BasicDispatcher(Activity activity) { this.activity = activity; } @Override public void dispatch(final Traversal traversal, final TraversalCallback callback) { Object dest = traversal.destination.top(); final ViewGroup frame = (ViewGroup) activity.findViewById(R.id.content); View fromView = null; if(traversal.origin != null){ if(frame.getChildCount() > 0){ fromView = frame.getChildAt(0); traversal.getState(traversal.origin.top()).save(frame.getChildAt(0)); } } if (!(dest instanceof BaseScreen)) throw new IllegalStateException(String.format(Locale.getDefault(), "The screen %s must implement BaseScreen", dest.getClass().getName())); @LayoutRes final int layout = ((BaseScreen) dest).layoutResId(); final View incomingView = LayoutInflater.from(traversal.createContext(dest,activity)).inflate(layout,frame,false); traversal.getState(traversal.destination.top()).restore(incomingView); if(fromView == null || traversal.direction == Direction.REPLACE) { frame.removeAllViews(); frame.addView(incomingView); callback.onTraversalCompleted(); }else{ frame.addView(incomingView); final View fromViewFinal = fromView;
FlowUtils.waitForMeasure(incomingView, new FlowUtils.OnMeasuredCallback() {
leonardo2204/Flow1.0.0-alphaExample
app/src/main/java/leonardo2204/com/br/flowtests/screen/FirstScreen.java
// Path: app/src/main/java/leonardo2204/com/br/flowtests/di/component/ActivityComponent.java // @DaggerScope(ActivityComponent.class) // @Component(dependencies = AppComponent.class, modules = ActivityModule.class) // public interface ActivityComponent extends AppComponent { // void inject(RootActivity rootActivity); // // ActionBarOwner actionBarOwner(); // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/di/module/FirstScreenModule.java // @Module // public class FirstScreenModule { // // @Provides // @DaggerScope(FirstScreenComponent.class) // public GetContacts providesGetContacts(ContactsRepository contactsRepository, ThreadExecutor threadExecutor, PostExecutionThread postExecutionThread) { // return new GetContacts(contactsRepository, threadExecutor, postExecutionThread); // } // // @Provides // @DaggerScope(FirstScreenComponent.class) // public FirstScreenPresenter providesFirstScreenPresenter(GetContacts getContacts, ActionBarOwner actionBarOwner) { // return new FirstScreenPresenter(getContacts, actionBarOwner); // } // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/flow/serviceFactory/InjectionComponent.java // public interface InjectionComponent<T> { // Object createComponent(T parent); // }
import flow.ClassKey; import leonardo2204.com.br.flowtests.Layout; import leonardo2204.com.br.flowtests.R; import leonardo2204.com.br.flowtests.di.component.ActivityComponent; import leonardo2204.com.br.flowtests.di.component.DaggerFirstScreenComponent; import leonardo2204.com.br.flowtests.di.module.FirstScreenModule; import leonardo2204.com.br.flowtests.flow.serviceFactory.InjectionComponent;
package leonardo2204.com.br.flowtests.screen; /** * Created by Leonardo on 04/03/2016. */ @Layout(R.layout.screen_first) @org.parceler.Parcel
// Path: app/src/main/java/leonardo2204/com/br/flowtests/di/component/ActivityComponent.java // @DaggerScope(ActivityComponent.class) // @Component(dependencies = AppComponent.class, modules = ActivityModule.class) // public interface ActivityComponent extends AppComponent { // void inject(RootActivity rootActivity); // // ActionBarOwner actionBarOwner(); // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/di/module/FirstScreenModule.java // @Module // public class FirstScreenModule { // // @Provides // @DaggerScope(FirstScreenComponent.class) // public GetContacts providesGetContacts(ContactsRepository contactsRepository, ThreadExecutor threadExecutor, PostExecutionThread postExecutionThread) { // return new GetContacts(contactsRepository, threadExecutor, postExecutionThread); // } // // @Provides // @DaggerScope(FirstScreenComponent.class) // public FirstScreenPresenter providesFirstScreenPresenter(GetContacts getContacts, ActionBarOwner actionBarOwner) { // return new FirstScreenPresenter(getContacts, actionBarOwner); // } // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/flow/serviceFactory/InjectionComponent.java // public interface InjectionComponent<T> { // Object createComponent(T parent); // } // Path: app/src/main/java/leonardo2204/com/br/flowtests/screen/FirstScreen.java import flow.ClassKey; import leonardo2204.com.br.flowtests.Layout; import leonardo2204.com.br.flowtests.R; import leonardo2204.com.br.flowtests.di.component.ActivityComponent; import leonardo2204.com.br.flowtests.di.component.DaggerFirstScreenComponent; import leonardo2204.com.br.flowtests.di.module.FirstScreenModule; import leonardo2204.com.br.flowtests.flow.serviceFactory.InjectionComponent; package leonardo2204.com.br.flowtests.screen; /** * Created by Leonardo on 04/03/2016. */ @Layout(R.layout.screen_first) @org.parceler.Parcel
public class FirstScreen extends ClassKey implements InjectionComponent<ActivityComponent> {
leonardo2204/Flow1.0.0-alphaExample
app/src/main/java/leonardo2204/com/br/flowtests/screen/FirstScreen.java
// Path: app/src/main/java/leonardo2204/com/br/flowtests/di/component/ActivityComponent.java // @DaggerScope(ActivityComponent.class) // @Component(dependencies = AppComponent.class, modules = ActivityModule.class) // public interface ActivityComponent extends AppComponent { // void inject(RootActivity rootActivity); // // ActionBarOwner actionBarOwner(); // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/di/module/FirstScreenModule.java // @Module // public class FirstScreenModule { // // @Provides // @DaggerScope(FirstScreenComponent.class) // public GetContacts providesGetContacts(ContactsRepository contactsRepository, ThreadExecutor threadExecutor, PostExecutionThread postExecutionThread) { // return new GetContacts(contactsRepository, threadExecutor, postExecutionThread); // } // // @Provides // @DaggerScope(FirstScreenComponent.class) // public FirstScreenPresenter providesFirstScreenPresenter(GetContacts getContacts, ActionBarOwner actionBarOwner) { // return new FirstScreenPresenter(getContacts, actionBarOwner); // } // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/flow/serviceFactory/InjectionComponent.java // public interface InjectionComponent<T> { // Object createComponent(T parent); // }
import flow.ClassKey; import leonardo2204.com.br.flowtests.Layout; import leonardo2204.com.br.flowtests.R; import leonardo2204.com.br.flowtests.di.component.ActivityComponent; import leonardo2204.com.br.flowtests.di.component.DaggerFirstScreenComponent; import leonardo2204.com.br.flowtests.di.module.FirstScreenModule; import leonardo2204.com.br.flowtests.flow.serviceFactory.InjectionComponent;
package leonardo2204.com.br.flowtests.screen; /** * Created by Leonardo on 04/03/2016. */ @Layout(R.layout.screen_first) @org.parceler.Parcel
// Path: app/src/main/java/leonardo2204/com/br/flowtests/di/component/ActivityComponent.java // @DaggerScope(ActivityComponent.class) // @Component(dependencies = AppComponent.class, modules = ActivityModule.class) // public interface ActivityComponent extends AppComponent { // void inject(RootActivity rootActivity); // // ActionBarOwner actionBarOwner(); // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/di/module/FirstScreenModule.java // @Module // public class FirstScreenModule { // // @Provides // @DaggerScope(FirstScreenComponent.class) // public GetContacts providesGetContacts(ContactsRepository contactsRepository, ThreadExecutor threadExecutor, PostExecutionThread postExecutionThread) { // return new GetContacts(contactsRepository, threadExecutor, postExecutionThread); // } // // @Provides // @DaggerScope(FirstScreenComponent.class) // public FirstScreenPresenter providesFirstScreenPresenter(GetContacts getContacts, ActionBarOwner actionBarOwner) { // return new FirstScreenPresenter(getContacts, actionBarOwner); // } // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/flow/serviceFactory/InjectionComponent.java // public interface InjectionComponent<T> { // Object createComponent(T parent); // } // Path: app/src/main/java/leonardo2204/com/br/flowtests/screen/FirstScreen.java import flow.ClassKey; import leonardo2204.com.br.flowtests.Layout; import leonardo2204.com.br.flowtests.R; import leonardo2204.com.br.flowtests.di.component.ActivityComponent; import leonardo2204.com.br.flowtests.di.component.DaggerFirstScreenComponent; import leonardo2204.com.br.flowtests.di.module.FirstScreenModule; import leonardo2204.com.br.flowtests.flow.serviceFactory.InjectionComponent; package leonardo2204.com.br.flowtests.screen; /** * Created by Leonardo on 04/03/2016. */ @Layout(R.layout.screen_first) @org.parceler.Parcel
public class FirstScreen extends ClassKey implements InjectionComponent<ActivityComponent> {
leonardo2204/Flow1.0.0-alphaExample
app/src/main/java/leonardo2204/com/br/flowtests/screen/FirstScreen.java
// Path: app/src/main/java/leonardo2204/com/br/flowtests/di/component/ActivityComponent.java // @DaggerScope(ActivityComponent.class) // @Component(dependencies = AppComponent.class, modules = ActivityModule.class) // public interface ActivityComponent extends AppComponent { // void inject(RootActivity rootActivity); // // ActionBarOwner actionBarOwner(); // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/di/module/FirstScreenModule.java // @Module // public class FirstScreenModule { // // @Provides // @DaggerScope(FirstScreenComponent.class) // public GetContacts providesGetContacts(ContactsRepository contactsRepository, ThreadExecutor threadExecutor, PostExecutionThread postExecutionThread) { // return new GetContacts(contactsRepository, threadExecutor, postExecutionThread); // } // // @Provides // @DaggerScope(FirstScreenComponent.class) // public FirstScreenPresenter providesFirstScreenPresenter(GetContacts getContacts, ActionBarOwner actionBarOwner) { // return new FirstScreenPresenter(getContacts, actionBarOwner); // } // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/flow/serviceFactory/InjectionComponent.java // public interface InjectionComponent<T> { // Object createComponent(T parent); // }
import flow.ClassKey; import leonardo2204.com.br.flowtests.Layout; import leonardo2204.com.br.flowtests.R; import leonardo2204.com.br.flowtests.di.component.ActivityComponent; import leonardo2204.com.br.flowtests.di.component.DaggerFirstScreenComponent; import leonardo2204.com.br.flowtests.di.module.FirstScreenModule; import leonardo2204.com.br.flowtests.flow.serviceFactory.InjectionComponent;
package leonardo2204.com.br.flowtests.screen; /** * Created by Leonardo on 04/03/2016. */ @Layout(R.layout.screen_first) @org.parceler.Parcel public class FirstScreen extends ClassKey implements InjectionComponent<ActivityComponent> { public FirstScreen() { } @Override public Object createComponent(ActivityComponent parent) { return DaggerFirstScreenComponent .builder() .activityComponent(parent)
// Path: app/src/main/java/leonardo2204/com/br/flowtests/di/component/ActivityComponent.java // @DaggerScope(ActivityComponent.class) // @Component(dependencies = AppComponent.class, modules = ActivityModule.class) // public interface ActivityComponent extends AppComponent { // void inject(RootActivity rootActivity); // // ActionBarOwner actionBarOwner(); // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/di/module/FirstScreenModule.java // @Module // public class FirstScreenModule { // // @Provides // @DaggerScope(FirstScreenComponent.class) // public GetContacts providesGetContacts(ContactsRepository contactsRepository, ThreadExecutor threadExecutor, PostExecutionThread postExecutionThread) { // return new GetContacts(contactsRepository, threadExecutor, postExecutionThread); // } // // @Provides // @DaggerScope(FirstScreenComponent.class) // public FirstScreenPresenter providesFirstScreenPresenter(GetContacts getContacts, ActionBarOwner actionBarOwner) { // return new FirstScreenPresenter(getContacts, actionBarOwner); // } // } // // Path: app/src/main/java/leonardo2204/com/br/flowtests/flow/serviceFactory/InjectionComponent.java // public interface InjectionComponent<T> { // Object createComponent(T parent); // } // Path: app/src/main/java/leonardo2204/com/br/flowtests/screen/FirstScreen.java import flow.ClassKey; import leonardo2204.com.br.flowtests.Layout; import leonardo2204.com.br.flowtests.R; import leonardo2204.com.br.flowtests.di.component.ActivityComponent; import leonardo2204.com.br.flowtests.di.component.DaggerFirstScreenComponent; import leonardo2204.com.br.flowtests.di.module.FirstScreenModule; import leonardo2204.com.br.flowtests.flow.serviceFactory.InjectionComponent; package leonardo2204.com.br.flowtests.screen; /** * Created by Leonardo on 04/03/2016. */ @Layout(R.layout.screen_first) @org.parceler.Parcel public class FirstScreen extends ClassKey implements InjectionComponent<ActivityComponent> { public FirstScreen() { } @Override public Object createComponent(ActivityComponent parent) { return DaggerFirstScreenComponent .builder() .activityComponent(parent)
.firstScreenModule(new FirstScreenModule())
FIRST-Team-2557-The-SOTABots/FRC_Robot
Robot/src/main/java/org/usfirst/frc/team2557/robot/subsystems/Dashboard.java
// Path: Robot/src/main/java/org/usfirst/frc/team2557/robot/commands/DashboardPrintCommand.java // public class DashboardPrintCommand extends Command { // // public DashboardPrintCommand() { // requires(Robot.dashboard); // // // Can't be interrupted, nor does // // it make sense TO interrupt it // setInterruptible(false); // } // // @Override // protected void initialize() { // // } // // @Override // protected void execute() { // SmartDashboard.putNumber("Lidar Distance Forward", RobotMap.lidarSensor.getData(352).getDistance()); // // SmartDashboard.putNumber("Encoder Pos (L)", Robot.chassis.getLeftEncoderPos()); // SmartDashboard.putNumber("Encoder Pos (R)", Robot.chassis.getRightEncoderPos()); // // SmartDashboard.putNumber("Left Potentiometer", RobotMap.leftPotentiometer.getAverageVoltage()); // SmartDashboard.putNumber("Right Potentiometer", RobotMap.rightPotentiometer.getAverageVoltage()); // SmartDashboard.putNumber("Arm Position", Robot.arm.getPosition()); // // SmartDashboard.putNumber("Left Potentiometer Speed", Robot.arm.getLeftSpeed()); // SmartDashboard.putNumber("Right Potentiometer Speed", Robot.arm.getRightSpeed()); // } // // @Override // protected boolean isFinished() { // return false; // } // // @Override // protected void end() { // // } // // @Override // protected void interrupted() { // // } // // }
import edu.wpi.first.wpilibj.command.Subsystem; import org.usfirst.frc.team2557.robot.commands.DashboardPrintCommand;
package org.usfirst.frc.team2557.robot.subsystems; public class Dashboard extends Subsystem { @Override protected void initDefaultCommand() {
// Path: Robot/src/main/java/org/usfirst/frc/team2557/robot/commands/DashboardPrintCommand.java // public class DashboardPrintCommand extends Command { // // public DashboardPrintCommand() { // requires(Robot.dashboard); // // // Can't be interrupted, nor does // // it make sense TO interrupt it // setInterruptible(false); // } // // @Override // protected void initialize() { // // } // // @Override // protected void execute() { // SmartDashboard.putNumber("Lidar Distance Forward", RobotMap.lidarSensor.getData(352).getDistance()); // // SmartDashboard.putNumber("Encoder Pos (L)", Robot.chassis.getLeftEncoderPos()); // SmartDashboard.putNumber("Encoder Pos (R)", Robot.chassis.getRightEncoderPos()); // // SmartDashboard.putNumber("Left Potentiometer", RobotMap.leftPotentiometer.getAverageVoltage()); // SmartDashboard.putNumber("Right Potentiometer", RobotMap.rightPotentiometer.getAverageVoltage()); // SmartDashboard.putNumber("Arm Position", Robot.arm.getPosition()); // // SmartDashboard.putNumber("Left Potentiometer Speed", Robot.arm.getLeftSpeed()); // SmartDashboard.putNumber("Right Potentiometer Speed", Robot.arm.getRightSpeed()); // } // // @Override // protected boolean isFinished() { // return false; // } // // @Override // protected void end() { // // } // // @Override // protected void interrupted() { // // } // // } // Path: Robot/src/main/java/org/usfirst/frc/team2557/robot/subsystems/Dashboard.java import edu.wpi.first.wpilibj.command.Subsystem; import org.usfirst.frc.team2557.robot.commands.DashboardPrintCommand; package org.usfirst.frc.team2557.robot.subsystems; public class Dashboard extends Subsystem { @Override protected void initDefaultCommand() {
setDefaultCommand(new DashboardPrintCommand());
FIRST-Team-2557-The-SOTABots/FRC_Robot
Robot/src/main/java/org/usfirst/frc/team2557/robot/commands/chassis/TurnByAngleCommand.java
// Path: Robot/src/main/java/org/usfirst/frc/team2557/robot/Robot.java // public class Robot extends IterativeRobot { // // //Subsystem Declarations// // public static OI oi; // public static Chassis chassis; // public static Arm arm; // public static Intake intake; // public static Catapult catapult; // public static Winch winch; // public static SecondArm secondArm; // public static Camera camera; // public static Lidar lidar; // public static Dashboard dashboard; // // //Command Declarations// // Command autonomousCommand; // // SendableChooser autoChooser; // public SendableChooser posChooser; // public SendableChooser batterChooser; // // public static Robot instance; // // public Robot() { // super(); // // instance = this; // } // // /** // * This function is run when the robot is first started up and should be // * used for any initialization code. // */ // public void robotInit() { // // Initialize RobotMap // RobotMap.init(); // // //Subsystem Connections// // chassis = new Chassis(); // arm = new Arm(); // intake = new Intake(); // catapult = new Catapult(); // winch = new Winch(); // secondArm = new SecondArm(); // camera = new Camera(); // lidar = new Lidar(); // dashboard = new Dashboard(); // // //OI Connection// // // NOTE: oi MUST be constructed after subsystems // oi = new OI(); // // // Make a SendableChooser on the SmartDashboard for changing auto programs // autoChooser = new SendableChooser(); // autoChooser.addDefault("Do Nothing (AUTO)", new Auto_DoNothing()); // autoChooser.addObject("Lowbar (AUTO)", new Auto_Lowbar()); // autoChooser.addObject("Lowbar Left Batter (AUTO)", new Auto_LowbarLeft()); // autoChooser.addObject("Lowbar Center Batter (AUTO)", new Auto_LowbarCenter()); // autoChooser.addObject("Chival De Frise (AUTO)", new Auto_ChivalDeFrise()); // autoChooser.addObject("Portcullis (AUTO)", new Auto_Portcullis()); // autoChooser.addObject("Rough Terrain (AUTO)", new Auto_RoughTerrain()); // autoChooser.addObject("Ramparts (AUTO)", new Auto_Rampards()); // autoChooser.addObject("Rock Wall (AUTO)", new Auto_RockWall()); // autoChooser.addObject("Moat (AUTO)", new Auto_Moat()); // // posChooser = new SendableChooser(); // posChooser.addDefault("No Shoot", 0); // posChooser.addObject("Position 1", 1); // posChooser.addObject("Position 2", 2); // posChooser.addObject("Position 3", 3); // posChooser.addObject("Position 4", 4); // // batterChooser = new SendableChooser(); // batterChooser.addDefault("Left", -1); // batterChooser.addObject("Center", 0); // batterChooser.addObject("Right", 1); // // SmartDashboard.putData("Autonomous Chooser", autoChooser); // SmartDashboard.putData("Position Chooser", posChooser); // SmartDashboard.putData("Batter Chooser", batterChooser); // } // // public void disabledPeriodic() { // Scheduler.getInstance().run(); // } // // public void autonomousInit() { // autonomousCommand = (Command) autoChooser.getSelected(); // autonomousCommand.start(); // } // // /** // * This function is called periodically during autonomous // */ // public void autonomousPeriodic() { // // Update the arm subsystem (updates PIDs and such) // arm.update(); // // Scheduler.getInstance().run(); // } // // public void teleopInit() { // // Cancel the autonomous command (if there was one previously running // if(autonomousCommand != null) // autonomousCommand.cancel(); // } // // /** // * This function is called when the disabled button is hit. // * You can use it to reset subsystems before shutting down. // */ // public void disabledInit() { // // } // // /* // // * This function is called periodically during operator control // */ // public void teleopPeriodic() { // // Update the arm // Robot.arm.update(); // // Scheduler.getInstance().run(); // } // // public void testInit() { // // } // // /** // * This function is called periodically during test mode // */ // public void testPeriodic() { // SmartDashboard.putNumber("The lidar is reading; ", RobotMap.lidarSensor.getData(10).getDistance()); // // LiveWindow.run(); // } // }
import edu.wpi.first.wpilibj.PIDController; import edu.wpi.first.wpilibj.PIDOutput; import edu.wpi.first.wpilibj.PIDSource; import edu.wpi.first.wpilibj.PIDSourceType; import edu.wpi.first.wpilibj.command.Command; import edu.wpi.first.wpilibj.command.PIDCommand; import org.usfirst.frc.team2557.robot.Robot;
package org.usfirst.frc.team2557.robot.commands.chassis; public class TurnByAngleCommand extends Command { private PIDController _controller; private double _degrees; public TurnByAngleCommand(double degrees) { this._degrees = degrees; // Kp, Ki, Kd, input (gyro), output (chassis) this._controller = new PIDController(0.01, 0.05, 0, new PIDSource() { @Override public void setPIDSourceType(PIDSourceType pidSource) { } @Override public PIDSourceType getPIDSourceType() { return PIDSourceType.kDisplacement; } @Override public double pidGet() {
// Path: Robot/src/main/java/org/usfirst/frc/team2557/robot/Robot.java // public class Robot extends IterativeRobot { // // //Subsystem Declarations// // public static OI oi; // public static Chassis chassis; // public static Arm arm; // public static Intake intake; // public static Catapult catapult; // public static Winch winch; // public static SecondArm secondArm; // public static Camera camera; // public static Lidar lidar; // public static Dashboard dashboard; // // //Command Declarations// // Command autonomousCommand; // // SendableChooser autoChooser; // public SendableChooser posChooser; // public SendableChooser batterChooser; // // public static Robot instance; // // public Robot() { // super(); // // instance = this; // } // // /** // * This function is run when the robot is first started up and should be // * used for any initialization code. // */ // public void robotInit() { // // Initialize RobotMap // RobotMap.init(); // // //Subsystem Connections// // chassis = new Chassis(); // arm = new Arm(); // intake = new Intake(); // catapult = new Catapult(); // winch = new Winch(); // secondArm = new SecondArm(); // camera = new Camera(); // lidar = new Lidar(); // dashboard = new Dashboard(); // // //OI Connection// // // NOTE: oi MUST be constructed after subsystems // oi = new OI(); // // // Make a SendableChooser on the SmartDashboard for changing auto programs // autoChooser = new SendableChooser(); // autoChooser.addDefault("Do Nothing (AUTO)", new Auto_DoNothing()); // autoChooser.addObject("Lowbar (AUTO)", new Auto_Lowbar()); // autoChooser.addObject("Lowbar Left Batter (AUTO)", new Auto_LowbarLeft()); // autoChooser.addObject("Lowbar Center Batter (AUTO)", new Auto_LowbarCenter()); // autoChooser.addObject("Chival De Frise (AUTO)", new Auto_ChivalDeFrise()); // autoChooser.addObject("Portcullis (AUTO)", new Auto_Portcullis()); // autoChooser.addObject("Rough Terrain (AUTO)", new Auto_RoughTerrain()); // autoChooser.addObject("Ramparts (AUTO)", new Auto_Rampards()); // autoChooser.addObject("Rock Wall (AUTO)", new Auto_RockWall()); // autoChooser.addObject("Moat (AUTO)", new Auto_Moat()); // // posChooser = new SendableChooser(); // posChooser.addDefault("No Shoot", 0); // posChooser.addObject("Position 1", 1); // posChooser.addObject("Position 2", 2); // posChooser.addObject("Position 3", 3); // posChooser.addObject("Position 4", 4); // // batterChooser = new SendableChooser(); // batterChooser.addDefault("Left", -1); // batterChooser.addObject("Center", 0); // batterChooser.addObject("Right", 1); // // SmartDashboard.putData("Autonomous Chooser", autoChooser); // SmartDashboard.putData("Position Chooser", posChooser); // SmartDashboard.putData("Batter Chooser", batterChooser); // } // // public void disabledPeriodic() { // Scheduler.getInstance().run(); // } // // public void autonomousInit() { // autonomousCommand = (Command) autoChooser.getSelected(); // autonomousCommand.start(); // } // // /** // * This function is called periodically during autonomous // */ // public void autonomousPeriodic() { // // Update the arm subsystem (updates PIDs and such) // arm.update(); // // Scheduler.getInstance().run(); // } // // public void teleopInit() { // // Cancel the autonomous command (if there was one previously running // if(autonomousCommand != null) // autonomousCommand.cancel(); // } // // /** // * This function is called when the disabled button is hit. // * You can use it to reset subsystems before shutting down. // */ // public void disabledInit() { // // } // // /* // // * This function is called periodically during operator control // */ // public void teleopPeriodic() { // // Update the arm // Robot.arm.update(); // // Scheduler.getInstance().run(); // } // // public void testInit() { // // } // // /** // * This function is called periodically during test mode // */ // public void testPeriodic() { // SmartDashboard.putNumber("The lidar is reading; ", RobotMap.lidarSensor.getData(10).getDistance()); // // LiveWindow.run(); // } // } // Path: Robot/src/main/java/org/usfirst/frc/team2557/robot/commands/chassis/TurnByAngleCommand.java import edu.wpi.first.wpilibj.PIDController; import edu.wpi.first.wpilibj.PIDOutput; import edu.wpi.first.wpilibj.PIDSource; import edu.wpi.first.wpilibj.PIDSourceType; import edu.wpi.first.wpilibj.command.Command; import edu.wpi.first.wpilibj.command.PIDCommand; import org.usfirst.frc.team2557.robot.Robot; package org.usfirst.frc.team2557.robot.commands.chassis; public class TurnByAngleCommand extends Command { private PIDController _controller; private double _degrees; public TurnByAngleCommand(double degrees) { this._degrees = degrees; // Kp, Ki, Kd, input (gyro), output (chassis) this._controller = new PIDController(0.01, 0.05, 0, new PIDSource() { @Override public void setPIDSourceType(PIDSourceType pidSource) { } @Override public PIDSourceType getPIDSourceType() { return PIDSourceType.kDisplacement; } @Override public double pidGet() {
return Robot.chassis.getGyroAngle();
FIRST-Team-2557-The-SOTABots/FRC_Robot
Robot/src/main/java/org/usfirst/frc/team2557/robot/commands/catapult/CatapultRetractCommand.java
// Path: Robot/src/main/java/org/usfirst/frc/team2557/robot/Robot.java // public class Robot extends IterativeRobot { // // //Subsystem Declarations// // public static OI oi; // public static Chassis chassis; // public static Arm arm; // public static Intake intake; // public static Catapult catapult; // public static Winch winch; // public static SecondArm secondArm; // public static Camera camera; // public static Lidar lidar; // public static Dashboard dashboard; // // //Command Declarations// // Command autonomousCommand; // // SendableChooser autoChooser; // public SendableChooser posChooser; // public SendableChooser batterChooser; // // public static Robot instance; // // public Robot() { // super(); // // instance = this; // } // // /** // * This function is run when the robot is first started up and should be // * used for any initialization code. // */ // public void robotInit() { // // Initialize RobotMap // RobotMap.init(); // // //Subsystem Connections// // chassis = new Chassis(); // arm = new Arm(); // intake = new Intake(); // catapult = new Catapult(); // winch = new Winch(); // secondArm = new SecondArm(); // camera = new Camera(); // lidar = new Lidar(); // dashboard = new Dashboard(); // // //OI Connection// // // NOTE: oi MUST be constructed after subsystems // oi = new OI(); // // // Make a SendableChooser on the SmartDashboard for changing auto programs // autoChooser = new SendableChooser(); // autoChooser.addDefault("Do Nothing (AUTO)", new Auto_DoNothing()); // autoChooser.addObject("Lowbar (AUTO)", new Auto_Lowbar()); // autoChooser.addObject("Lowbar Left Batter (AUTO)", new Auto_LowbarLeft()); // autoChooser.addObject("Lowbar Center Batter (AUTO)", new Auto_LowbarCenter()); // autoChooser.addObject("Chival De Frise (AUTO)", new Auto_ChivalDeFrise()); // autoChooser.addObject("Portcullis (AUTO)", new Auto_Portcullis()); // autoChooser.addObject("Rough Terrain (AUTO)", new Auto_RoughTerrain()); // autoChooser.addObject("Ramparts (AUTO)", new Auto_Rampards()); // autoChooser.addObject("Rock Wall (AUTO)", new Auto_RockWall()); // autoChooser.addObject("Moat (AUTO)", new Auto_Moat()); // // posChooser = new SendableChooser(); // posChooser.addDefault("No Shoot", 0); // posChooser.addObject("Position 1", 1); // posChooser.addObject("Position 2", 2); // posChooser.addObject("Position 3", 3); // posChooser.addObject("Position 4", 4); // // batterChooser = new SendableChooser(); // batterChooser.addDefault("Left", -1); // batterChooser.addObject("Center", 0); // batterChooser.addObject("Right", 1); // // SmartDashboard.putData("Autonomous Chooser", autoChooser); // SmartDashboard.putData("Position Chooser", posChooser); // SmartDashboard.putData("Batter Chooser", batterChooser); // } // // public void disabledPeriodic() { // Scheduler.getInstance().run(); // } // // public void autonomousInit() { // autonomousCommand = (Command) autoChooser.getSelected(); // autonomousCommand.start(); // } // // /** // * This function is called periodically during autonomous // */ // public void autonomousPeriodic() { // // Update the arm subsystem (updates PIDs and such) // arm.update(); // // Scheduler.getInstance().run(); // } // // public void teleopInit() { // // Cancel the autonomous command (if there was one previously running // if(autonomousCommand != null) // autonomousCommand.cancel(); // } // // /** // * This function is called when the disabled button is hit. // * You can use it to reset subsystems before shutting down. // */ // public void disabledInit() { // // } // // /* // // * This function is called periodically during operator control // */ // public void teleopPeriodic() { // // Update the arm // Robot.arm.update(); // // Scheduler.getInstance().run(); // } // // public void testInit() { // // } // // /** // * This function is called periodically during test mode // */ // public void testPeriodic() { // SmartDashboard.putNumber("The lidar is reading; ", RobotMap.lidarSensor.getData(10).getDistance()); // // LiveWindow.run(); // } // }
import edu.wpi.first.wpilibj.command.Command; import org.usfirst.frc.team2557.robot.Robot;
package org.usfirst.frc.team2557.robot.commands.catapult; public class CatapultRetractCommand extends Command { public CatapultRetractCommand() {
// Path: Robot/src/main/java/org/usfirst/frc/team2557/robot/Robot.java // public class Robot extends IterativeRobot { // // //Subsystem Declarations// // public static OI oi; // public static Chassis chassis; // public static Arm arm; // public static Intake intake; // public static Catapult catapult; // public static Winch winch; // public static SecondArm secondArm; // public static Camera camera; // public static Lidar lidar; // public static Dashboard dashboard; // // //Command Declarations// // Command autonomousCommand; // // SendableChooser autoChooser; // public SendableChooser posChooser; // public SendableChooser batterChooser; // // public static Robot instance; // // public Robot() { // super(); // // instance = this; // } // // /** // * This function is run when the robot is first started up and should be // * used for any initialization code. // */ // public void robotInit() { // // Initialize RobotMap // RobotMap.init(); // // //Subsystem Connections// // chassis = new Chassis(); // arm = new Arm(); // intake = new Intake(); // catapult = new Catapult(); // winch = new Winch(); // secondArm = new SecondArm(); // camera = new Camera(); // lidar = new Lidar(); // dashboard = new Dashboard(); // // //OI Connection// // // NOTE: oi MUST be constructed after subsystems // oi = new OI(); // // // Make a SendableChooser on the SmartDashboard for changing auto programs // autoChooser = new SendableChooser(); // autoChooser.addDefault("Do Nothing (AUTO)", new Auto_DoNothing()); // autoChooser.addObject("Lowbar (AUTO)", new Auto_Lowbar()); // autoChooser.addObject("Lowbar Left Batter (AUTO)", new Auto_LowbarLeft()); // autoChooser.addObject("Lowbar Center Batter (AUTO)", new Auto_LowbarCenter()); // autoChooser.addObject("Chival De Frise (AUTO)", new Auto_ChivalDeFrise()); // autoChooser.addObject("Portcullis (AUTO)", new Auto_Portcullis()); // autoChooser.addObject("Rough Terrain (AUTO)", new Auto_RoughTerrain()); // autoChooser.addObject("Ramparts (AUTO)", new Auto_Rampards()); // autoChooser.addObject("Rock Wall (AUTO)", new Auto_RockWall()); // autoChooser.addObject("Moat (AUTO)", new Auto_Moat()); // // posChooser = new SendableChooser(); // posChooser.addDefault("No Shoot", 0); // posChooser.addObject("Position 1", 1); // posChooser.addObject("Position 2", 2); // posChooser.addObject("Position 3", 3); // posChooser.addObject("Position 4", 4); // // batterChooser = new SendableChooser(); // batterChooser.addDefault("Left", -1); // batterChooser.addObject("Center", 0); // batterChooser.addObject("Right", 1); // // SmartDashboard.putData("Autonomous Chooser", autoChooser); // SmartDashboard.putData("Position Chooser", posChooser); // SmartDashboard.putData("Batter Chooser", batterChooser); // } // // public void disabledPeriodic() { // Scheduler.getInstance().run(); // } // // public void autonomousInit() { // autonomousCommand = (Command) autoChooser.getSelected(); // autonomousCommand.start(); // } // // /** // * This function is called periodically during autonomous // */ // public void autonomousPeriodic() { // // Update the arm subsystem (updates PIDs and such) // arm.update(); // // Scheduler.getInstance().run(); // } // // public void teleopInit() { // // Cancel the autonomous command (if there was one previously running // if(autonomousCommand != null) // autonomousCommand.cancel(); // } // // /** // * This function is called when the disabled button is hit. // * You can use it to reset subsystems before shutting down. // */ // public void disabledInit() { // // } // // /* // // * This function is called periodically during operator control // */ // public void teleopPeriodic() { // // Update the arm // Robot.arm.update(); // // Scheduler.getInstance().run(); // } // // public void testInit() { // // } // // /** // * This function is called periodically during test mode // */ // public void testPeriodic() { // SmartDashboard.putNumber("The lidar is reading; ", RobotMap.lidarSensor.getData(10).getDistance()); // // LiveWindow.run(); // } // } // Path: Robot/src/main/java/org/usfirst/frc/team2557/robot/commands/catapult/CatapultRetractCommand.java import edu.wpi.first.wpilibj.command.Command; import org.usfirst.frc.team2557.robot.Robot; package org.usfirst.frc.team2557.robot.commands.catapult; public class CatapultRetractCommand extends Command { public CatapultRetractCommand() {
requires(Robot.catapult);
FIRST-Team-2557-The-SOTABots/FRC_Robot
Robot/src/main/java/org/usfirst/frc/team2557/robot/subsystems/Camera.java
// Path: Robot/src/main/java/org/usfirst/frc/team2557/robot/Robot.java // public class Robot extends IterativeRobot { // // //Subsystem Declarations// // public static OI oi; // public static Chassis chassis; // public static Arm arm; // public static Intake intake; // public static Catapult catapult; // public static Winch winch; // public static SecondArm secondArm; // public static Camera camera; // public static Lidar lidar; // public static Dashboard dashboard; // // //Command Declarations// // Command autonomousCommand; // // SendableChooser autoChooser; // public SendableChooser posChooser; // public SendableChooser batterChooser; // // public static Robot instance; // // public Robot() { // super(); // // instance = this; // } // // /** // * This function is run when the robot is first started up and should be // * used for any initialization code. // */ // public void robotInit() { // // Initialize RobotMap // RobotMap.init(); // // //Subsystem Connections// // chassis = new Chassis(); // arm = new Arm(); // intake = new Intake(); // catapult = new Catapult(); // winch = new Winch(); // secondArm = new SecondArm(); // camera = new Camera(); // lidar = new Lidar(); // dashboard = new Dashboard(); // // //OI Connection// // // NOTE: oi MUST be constructed after subsystems // oi = new OI(); // // // Make a SendableChooser on the SmartDashboard for changing auto programs // autoChooser = new SendableChooser(); // autoChooser.addDefault("Do Nothing (AUTO)", new Auto_DoNothing()); // autoChooser.addObject("Lowbar (AUTO)", new Auto_Lowbar()); // autoChooser.addObject("Lowbar Left Batter (AUTO)", new Auto_LowbarLeft()); // autoChooser.addObject("Lowbar Center Batter (AUTO)", new Auto_LowbarCenter()); // autoChooser.addObject("Chival De Frise (AUTO)", new Auto_ChivalDeFrise()); // autoChooser.addObject("Portcullis (AUTO)", new Auto_Portcullis()); // autoChooser.addObject("Rough Terrain (AUTO)", new Auto_RoughTerrain()); // autoChooser.addObject("Ramparts (AUTO)", new Auto_Rampards()); // autoChooser.addObject("Rock Wall (AUTO)", new Auto_RockWall()); // autoChooser.addObject("Moat (AUTO)", new Auto_Moat()); // // posChooser = new SendableChooser(); // posChooser.addDefault("No Shoot", 0); // posChooser.addObject("Position 1", 1); // posChooser.addObject("Position 2", 2); // posChooser.addObject("Position 3", 3); // posChooser.addObject("Position 4", 4); // // batterChooser = new SendableChooser(); // batterChooser.addDefault("Left", -1); // batterChooser.addObject("Center", 0); // batterChooser.addObject("Right", 1); // // SmartDashboard.putData("Autonomous Chooser", autoChooser); // SmartDashboard.putData("Position Chooser", posChooser); // SmartDashboard.putData("Batter Chooser", batterChooser); // } // // public void disabledPeriodic() { // Scheduler.getInstance().run(); // } // // public void autonomousInit() { // autonomousCommand = (Command) autoChooser.getSelected(); // autonomousCommand.start(); // } // // /** // * This function is called periodically during autonomous // */ // public void autonomousPeriodic() { // // Update the arm subsystem (updates PIDs and such) // arm.update(); // // Scheduler.getInstance().run(); // } // // public void teleopInit() { // // Cancel the autonomous command (if there was one previously running // if(autonomousCommand != null) // autonomousCommand.cancel(); // } // // /** // * This function is called when the disabled button is hit. // * You can use it to reset subsystems before shutting down. // */ // public void disabledInit() { // // } // // /* // // * This function is called periodically during operator control // */ // public void teleopPeriodic() { // // Update the arm // Robot.arm.update(); // // Scheduler.getInstance().run(); // } // // public void testInit() { // // } // // /** // * This function is called periodically during test mode // */ // public void testPeriodic() { // SmartDashboard.putNumber("The lidar is reading; ", RobotMap.lidarSensor.getData(10).getDistance()); // // LiveWindow.run(); // } // }
import edu.wpi.first.wpilibj.command.Subsystem; import edu.wpi.first.wpilibj.networktables.NetworkTable; import edu.wpi.first.wpilibj.tables.ITable; import org.usfirst.frc.team2557.robot.Robot;
targets[i].height = heights[i]; targets[i].area = areas[i]; targets[i].solidity = soliditys[i]; targets[i].aspectRatio = targets[i].width / targets[i].height; targets[i].offset = targets[i].centerX - (targets[i].width / 2); // Distance calculation // Width of the target is proportional to its height. // We cannot depend on width being accurate, since different // perspectives give different widths, // however the height remains the same. // Using this reasoning, we can approximate the distance // to the target withing about a foot. If this error // is too large, we can account it with additional calculations. /* * width widthp * ----- = ----- * height heightp */ double targetPixels = 0.508 * targets[i].height / 0.3048; targets[i].distance = (targetWidth * cameraWidth) / (2 * targetPixels * Math.tan(Math.toRadians(fov / 2))); // TODO: Angle from the target (0 is dead straight), assumes target is in center of camera } return targets; } public Camera.Target getTarget() {
// Path: Robot/src/main/java/org/usfirst/frc/team2557/robot/Robot.java // public class Robot extends IterativeRobot { // // //Subsystem Declarations// // public static OI oi; // public static Chassis chassis; // public static Arm arm; // public static Intake intake; // public static Catapult catapult; // public static Winch winch; // public static SecondArm secondArm; // public static Camera camera; // public static Lidar lidar; // public static Dashboard dashboard; // // //Command Declarations// // Command autonomousCommand; // // SendableChooser autoChooser; // public SendableChooser posChooser; // public SendableChooser batterChooser; // // public static Robot instance; // // public Robot() { // super(); // // instance = this; // } // // /** // * This function is run when the robot is first started up and should be // * used for any initialization code. // */ // public void robotInit() { // // Initialize RobotMap // RobotMap.init(); // // //Subsystem Connections// // chassis = new Chassis(); // arm = new Arm(); // intake = new Intake(); // catapult = new Catapult(); // winch = new Winch(); // secondArm = new SecondArm(); // camera = new Camera(); // lidar = new Lidar(); // dashboard = new Dashboard(); // // //OI Connection// // // NOTE: oi MUST be constructed after subsystems // oi = new OI(); // // // Make a SendableChooser on the SmartDashboard for changing auto programs // autoChooser = new SendableChooser(); // autoChooser.addDefault("Do Nothing (AUTO)", new Auto_DoNothing()); // autoChooser.addObject("Lowbar (AUTO)", new Auto_Lowbar()); // autoChooser.addObject("Lowbar Left Batter (AUTO)", new Auto_LowbarLeft()); // autoChooser.addObject("Lowbar Center Batter (AUTO)", new Auto_LowbarCenter()); // autoChooser.addObject("Chival De Frise (AUTO)", new Auto_ChivalDeFrise()); // autoChooser.addObject("Portcullis (AUTO)", new Auto_Portcullis()); // autoChooser.addObject("Rough Terrain (AUTO)", new Auto_RoughTerrain()); // autoChooser.addObject("Ramparts (AUTO)", new Auto_Rampards()); // autoChooser.addObject("Rock Wall (AUTO)", new Auto_RockWall()); // autoChooser.addObject("Moat (AUTO)", new Auto_Moat()); // // posChooser = new SendableChooser(); // posChooser.addDefault("No Shoot", 0); // posChooser.addObject("Position 1", 1); // posChooser.addObject("Position 2", 2); // posChooser.addObject("Position 3", 3); // posChooser.addObject("Position 4", 4); // // batterChooser = new SendableChooser(); // batterChooser.addDefault("Left", -1); // batterChooser.addObject("Center", 0); // batterChooser.addObject("Right", 1); // // SmartDashboard.putData("Autonomous Chooser", autoChooser); // SmartDashboard.putData("Position Chooser", posChooser); // SmartDashboard.putData("Batter Chooser", batterChooser); // } // // public void disabledPeriodic() { // Scheduler.getInstance().run(); // } // // public void autonomousInit() { // autonomousCommand = (Command) autoChooser.getSelected(); // autonomousCommand.start(); // } // // /** // * This function is called periodically during autonomous // */ // public void autonomousPeriodic() { // // Update the arm subsystem (updates PIDs and such) // arm.update(); // // Scheduler.getInstance().run(); // } // // public void teleopInit() { // // Cancel the autonomous command (if there was one previously running // if(autonomousCommand != null) // autonomousCommand.cancel(); // } // // /** // * This function is called when the disabled button is hit. // * You can use it to reset subsystems before shutting down. // */ // public void disabledInit() { // // } // // /* // // * This function is called periodically during operator control // */ // public void teleopPeriodic() { // // Update the arm // Robot.arm.update(); // // Scheduler.getInstance().run(); // } // // public void testInit() { // // } // // /** // * This function is called periodically during test mode // */ // public void testPeriodic() { // SmartDashboard.putNumber("The lidar is reading; ", RobotMap.lidarSensor.getData(10).getDistance()); // // LiveWindow.run(); // } // } // Path: Robot/src/main/java/org/usfirst/frc/team2557/robot/subsystems/Camera.java import edu.wpi.first.wpilibj.command.Subsystem; import edu.wpi.first.wpilibj.networktables.NetworkTable; import edu.wpi.first.wpilibj.tables.ITable; import org.usfirst.frc.team2557.robot.Robot; targets[i].height = heights[i]; targets[i].area = areas[i]; targets[i].solidity = soliditys[i]; targets[i].aspectRatio = targets[i].width / targets[i].height; targets[i].offset = targets[i].centerX - (targets[i].width / 2); // Distance calculation // Width of the target is proportional to its height. // We cannot depend on width being accurate, since different // perspectives give different widths, // however the height remains the same. // Using this reasoning, we can approximate the distance // to the target withing about a foot. If this error // is too large, we can account it with additional calculations. /* * width widthp * ----- = ----- * height heightp */ double targetPixels = 0.508 * targets[i].height / 0.3048; targets[i].distance = (targetWidth * cameraWidth) / (2 * targetPixels * Math.tan(Math.toRadians(fov / 2))); // TODO: Angle from the target (0 is dead straight), assumes target is in center of camera } return targets; } public Camera.Target getTarget() {
Camera.Target[] targets = Robot.camera.getTargets();
FIRST-Team-2557-The-SOTABots/FRC_Robot
Robot/src/main/java/org/usfirst/frc/team2557/robot/commands/chassis/TimeDriveCommand.java
// Path: Robot/src/main/java/org/usfirst/frc/team2557/robot/Robot.java // public class Robot extends IterativeRobot { // // //Subsystem Declarations// // public static OI oi; // public static Chassis chassis; // public static Arm arm; // public static Intake intake; // public static Catapult catapult; // public static Winch winch; // public static SecondArm secondArm; // public static Camera camera; // public static Lidar lidar; // public static Dashboard dashboard; // // //Command Declarations// // Command autonomousCommand; // // SendableChooser autoChooser; // public SendableChooser posChooser; // public SendableChooser batterChooser; // // public static Robot instance; // // public Robot() { // super(); // // instance = this; // } // // /** // * This function is run when the robot is first started up and should be // * used for any initialization code. // */ // public void robotInit() { // // Initialize RobotMap // RobotMap.init(); // // //Subsystem Connections// // chassis = new Chassis(); // arm = new Arm(); // intake = new Intake(); // catapult = new Catapult(); // winch = new Winch(); // secondArm = new SecondArm(); // camera = new Camera(); // lidar = new Lidar(); // dashboard = new Dashboard(); // // //OI Connection// // // NOTE: oi MUST be constructed after subsystems // oi = new OI(); // // // Make a SendableChooser on the SmartDashboard for changing auto programs // autoChooser = new SendableChooser(); // autoChooser.addDefault("Do Nothing (AUTO)", new Auto_DoNothing()); // autoChooser.addObject("Lowbar (AUTO)", new Auto_Lowbar()); // autoChooser.addObject("Lowbar Left Batter (AUTO)", new Auto_LowbarLeft()); // autoChooser.addObject("Lowbar Center Batter (AUTO)", new Auto_LowbarCenter()); // autoChooser.addObject("Chival De Frise (AUTO)", new Auto_ChivalDeFrise()); // autoChooser.addObject("Portcullis (AUTO)", new Auto_Portcullis()); // autoChooser.addObject("Rough Terrain (AUTO)", new Auto_RoughTerrain()); // autoChooser.addObject("Ramparts (AUTO)", new Auto_Rampards()); // autoChooser.addObject("Rock Wall (AUTO)", new Auto_RockWall()); // autoChooser.addObject("Moat (AUTO)", new Auto_Moat()); // // posChooser = new SendableChooser(); // posChooser.addDefault("No Shoot", 0); // posChooser.addObject("Position 1", 1); // posChooser.addObject("Position 2", 2); // posChooser.addObject("Position 3", 3); // posChooser.addObject("Position 4", 4); // // batterChooser = new SendableChooser(); // batterChooser.addDefault("Left", -1); // batterChooser.addObject("Center", 0); // batterChooser.addObject("Right", 1); // // SmartDashboard.putData("Autonomous Chooser", autoChooser); // SmartDashboard.putData("Position Chooser", posChooser); // SmartDashboard.putData("Batter Chooser", batterChooser); // } // // public void disabledPeriodic() { // Scheduler.getInstance().run(); // } // // public void autonomousInit() { // autonomousCommand = (Command) autoChooser.getSelected(); // autonomousCommand.start(); // } // // /** // * This function is called periodically during autonomous // */ // public void autonomousPeriodic() { // // Update the arm subsystem (updates PIDs and such) // arm.update(); // // Scheduler.getInstance().run(); // } // // public void teleopInit() { // // Cancel the autonomous command (if there was one previously running // if(autonomousCommand != null) // autonomousCommand.cancel(); // } // // /** // * This function is called when the disabled button is hit. // * You can use it to reset subsystems before shutting down. // */ // public void disabledInit() { // // } // // /* // // * This function is called periodically during operator control // */ // public void teleopPeriodic() { // // Update the arm // Robot.arm.update(); // // Scheduler.getInstance().run(); // } // // public void testInit() { // // } // // /** // * This function is called periodically during test mode // */ // public void testPeriodic() { // SmartDashboard.putNumber("The lidar is reading; ", RobotMap.lidarSensor.getData(10).getDistance()); // // LiveWindow.run(); // } // }
import edu.wpi.first.wpilibj.command.Command; import edu.wpi.first.wpilibj.Timer; import org.usfirst.frc.team2557.robot.Robot;
package org.usfirst.frc.team2557.robot.commands.chassis; public class TimeDriveCommand extends Command { private Timer _timer; private double _expiration; private double _speed; public TimeDriveCommand(double time, double speed) { this._timer = new Timer(); this._expiration = time; this._speed = speed;
// Path: Robot/src/main/java/org/usfirst/frc/team2557/robot/Robot.java // public class Robot extends IterativeRobot { // // //Subsystem Declarations// // public static OI oi; // public static Chassis chassis; // public static Arm arm; // public static Intake intake; // public static Catapult catapult; // public static Winch winch; // public static SecondArm secondArm; // public static Camera camera; // public static Lidar lidar; // public static Dashboard dashboard; // // //Command Declarations// // Command autonomousCommand; // // SendableChooser autoChooser; // public SendableChooser posChooser; // public SendableChooser batterChooser; // // public static Robot instance; // // public Robot() { // super(); // // instance = this; // } // // /** // * This function is run when the robot is first started up and should be // * used for any initialization code. // */ // public void robotInit() { // // Initialize RobotMap // RobotMap.init(); // // //Subsystem Connections// // chassis = new Chassis(); // arm = new Arm(); // intake = new Intake(); // catapult = new Catapult(); // winch = new Winch(); // secondArm = new SecondArm(); // camera = new Camera(); // lidar = new Lidar(); // dashboard = new Dashboard(); // // //OI Connection// // // NOTE: oi MUST be constructed after subsystems // oi = new OI(); // // // Make a SendableChooser on the SmartDashboard for changing auto programs // autoChooser = new SendableChooser(); // autoChooser.addDefault("Do Nothing (AUTO)", new Auto_DoNothing()); // autoChooser.addObject("Lowbar (AUTO)", new Auto_Lowbar()); // autoChooser.addObject("Lowbar Left Batter (AUTO)", new Auto_LowbarLeft()); // autoChooser.addObject("Lowbar Center Batter (AUTO)", new Auto_LowbarCenter()); // autoChooser.addObject("Chival De Frise (AUTO)", new Auto_ChivalDeFrise()); // autoChooser.addObject("Portcullis (AUTO)", new Auto_Portcullis()); // autoChooser.addObject("Rough Terrain (AUTO)", new Auto_RoughTerrain()); // autoChooser.addObject("Ramparts (AUTO)", new Auto_Rampards()); // autoChooser.addObject("Rock Wall (AUTO)", new Auto_RockWall()); // autoChooser.addObject("Moat (AUTO)", new Auto_Moat()); // // posChooser = new SendableChooser(); // posChooser.addDefault("No Shoot", 0); // posChooser.addObject("Position 1", 1); // posChooser.addObject("Position 2", 2); // posChooser.addObject("Position 3", 3); // posChooser.addObject("Position 4", 4); // // batterChooser = new SendableChooser(); // batterChooser.addDefault("Left", -1); // batterChooser.addObject("Center", 0); // batterChooser.addObject("Right", 1); // // SmartDashboard.putData("Autonomous Chooser", autoChooser); // SmartDashboard.putData("Position Chooser", posChooser); // SmartDashboard.putData("Batter Chooser", batterChooser); // } // // public void disabledPeriodic() { // Scheduler.getInstance().run(); // } // // public void autonomousInit() { // autonomousCommand = (Command) autoChooser.getSelected(); // autonomousCommand.start(); // } // // /** // * This function is called periodically during autonomous // */ // public void autonomousPeriodic() { // // Update the arm subsystem (updates PIDs and such) // arm.update(); // // Scheduler.getInstance().run(); // } // // public void teleopInit() { // // Cancel the autonomous command (if there was one previously running // if(autonomousCommand != null) // autonomousCommand.cancel(); // } // // /** // * This function is called when the disabled button is hit. // * You can use it to reset subsystems before shutting down. // */ // public void disabledInit() { // // } // // /* // // * This function is called periodically during operator control // */ // public void teleopPeriodic() { // // Update the arm // Robot.arm.update(); // // Scheduler.getInstance().run(); // } // // public void testInit() { // // } // // /** // * This function is called periodically during test mode // */ // public void testPeriodic() { // SmartDashboard.putNumber("The lidar is reading; ", RobotMap.lidarSensor.getData(10).getDistance()); // // LiveWindow.run(); // } // } // Path: Robot/src/main/java/org/usfirst/frc/team2557/robot/commands/chassis/TimeDriveCommand.java import edu.wpi.first.wpilibj.command.Command; import edu.wpi.first.wpilibj.Timer; import org.usfirst.frc.team2557.robot.Robot; package org.usfirst.frc.team2557.robot.commands.chassis; public class TimeDriveCommand extends Command { private Timer _timer; private double _expiration; private double _speed; public TimeDriveCommand(double time, double speed) { this._timer = new Timer(); this._expiration = time; this._speed = speed;
requires(Robot.chassis);
FIRST-Team-2557-The-SOTABots/FRC_Robot
Robot/src/main/java/org/usfirst/frc/team2557/robot/subsystems/Winch.java
// Path: Robot/src/main/java/org/usfirst/frc/team2557/robot/RobotMap.java // public class RobotMap { // // // public static CANTalon driveLeft1; // public static CANTalon driveLeft2; // public static CANTalon driveRight1; // public static CANTalon driveRight2; // public static CANTalon catapultMotor; // public static CANTalon climbingMotor; // public static CANTalon leftActuatorMotor; // public static CANTalon rightActuatorMotor; // // public static CANTalon intakeMotor; // // public static Servo secondaryArm; // // public static DigitalInput catapultHallEffect; // // public static Accelerometer rioAccelerometer; // // public static Gyro mainGyro; // // public static AnalogInput leftPotentiometer; // public static AnalogInput rightPotentiometer; // // public static LidarRangeFinder lidarSensor; // public static AnalogInput sonar; // // public static ArduinoComm arduinoComm; // // public static RobotDrive robotDrive; // // /** // * Initializes all the parts of RobotMap. This must be called main init method // * in Robot.java, as WPI needs to set up before these objects can be constructed. // */ // public static void init() { // // /* // * CAN ports 6, 8, 2, and 3 have encoder breakouts. // */ // driveLeft1 = new CANTalon(7); // driveLeft2 = new CANTalon(6); // driveRight1 = new CANTalon(8); // driveRight2 = new CANTalon(5); // catapultMotor = new CANTalon(1); // climbingMotor = new CANTalon(9); // intakeMotor = new CANTalon(4); // // leftActuatorMotor = new CANTalon(2); // leftActuatorMotor.enableLimitSwitch(false, false); // leftActuatorMotor.enableBrakeMode(true); // rightActuatorMotor = new CANTalon(3); // rightActuatorMotor.enableLimitSwitch(false, false); // rightActuatorMotor.enableBrakeMode(true); // // secondaryArm = new Servo(4); // // catapultHallEffect = new DigitalInput(0); // // rioAccelerometer = new BuiltInAccelerometer(); // // mainGyro = new ADXRS450_Gyro(); // // leftPotentiometer = new AnalogInput(1); // rightPotentiometer = new AnalogInput(2); // // lidarSensor = new LidarRangeFinder(SerialPort.Port.kMXP); // Using the MXP breakout for tx/rx (serial) // // robotDrive = new RobotDrive(driveLeft1, driveLeft2, driveRight1, driveRight2); // robotDrive.setExpiration(0.2); // robotDrive.setSafetyEnabled(false); // // arduinoComm = new ArduinoComm(); // Using the MXP breakout for sda/sdt (i2c) // } // // } // // Path: Robot/src/main/java/org/usfirst/frc/team2557/robot/commands/winch/WinchCommand.java // public class WinchCommand extends Command { // // public WinchCommand() { // requires(Robot.winch); // // // Not interruptible! Winch should be entirely driver controlled // setInterruptible(false); // } // // @Override // protected void initialize() { // // } // // @Override // protected void execute() { // if(Robot.oi.driver.getRawButton(7)){ // RobotMap.climbingMotor.set(1); // } else{ // RobotMap.climbingMotor.set(0); // } // } // // @Override // protected boolean isFinished() { // return false; // } // // @Override // protected void end() { // // } // // @Override // protected void interrupted() { // this.end(); // } // }
import edu.wpi.first.wpilibj.CANTalon; import edu.wpi.first.wpilibj.command.Subsystem; import org.usfirst.frc.team2557.robot.RobotMap; import org.usfirst.frc.team2557.robot.commands.winch.WinchCommand;
package org.usfirst.frc.team2557.robot.subsystems; public class Winch extends Subsystem { CANTalon climbingMotor = RobotMap.climbingMotor; @Override protected void initDefaultCommand() {
// Path: Robot/src/main/java/org/usfirst/frc/team2557/robot/RobotMap.java // public class RobotMap { // // // public static CANTalon driveLeft1; // public static CANTalon driveLeft2; // public static CANTalon driveRight1; // public static CANTalon driveRight2; // public static CANTalon catapultMotor; // public static CANTalon climbingMotor; // public static CANTalon leftActuatorMotor; // public static CANTalon rightActuatorMotor; // // public static CANTalon intakeMotor; // // public static Servo secondaryArm; // // public static DigitalInput catapultHallEffect; // // public static Accelerometer rioAccelerometer; // // public static Gyro mainGyro; // // public static AnalogInput leftPotentiometer; // public static AnalogInput rightPotentiometer; // // public static LidarRangeFinder lidarSensor; // public static AnalogInput sonar; // // public static ArduinoComm arduinoComm; // // public static RobotDrive robotDrive; // // /** // * Initializes all the parts of RobotMap. This must be called main init method // * in Robot.java, as WPI needs to set up before these objects can be constructed. // */ // public static void init() { // // /* // * CAN ports 6, 8, 2, and 3 have encoder breakouts. // */ // driveLeft1 = new CANTalon(7); // driveLeft2 = new CANTalon(6); // driveRight1 = new CANTalon(8); // driveRight2 = new CANTalon(5); // catapultMotor = new CANTalon(1); // climbingMotor = new CANTalon(9); // intakeMotor = new CANTalon(4); // // leftActuatorMotor = new CANTalon(2); // leftActuatorMotor.enableLimitSwitch(false, false); // leftActuatorMotor.enableBrakeMode(true); // rightActuatorMotor = new CANTalon(3); // rightActuatorMotor.enableLimitSwitch(false, false); // rightActuatorMotor.enableBrakeMode(true); // // secondaryArm = new Servo(4); // // catapultHallEffect = new DigitalInput(0); // // rioAccelerometer = new BuiltInAccelerometer(); // // mainGyro = new ADXRS450_Gyro(); // // leftPotentiometer = new AnalogInput(1); // rightPotentiometer = new AnalogInput(2); // // lidarSensor = new LidarRangeFinder(SerialPort.Port.kMXP); // Using the MXP breakout for tx/rx (serial) // // robotDrive = new RobotDrive(driveLeft1, driveLeft2, driveRight1, driveRight2); // robotDrive.setExpiration(0.2); // robotDrive.setSafetyEnabled(false); // // arduinoComm = new ArduinoComm(); // Using the MXP breakout for sda/sdt (i2c) // } // // } // // Path: Robot/src/main/java/org/usfirst/frc/team2557/robot/commands/winch/WinchCommand.java // public class WinchCommand extends Command { // // public WinchCommand() { // requires(Robot.winch); // // // Not interruptible! Winch should be entirely driver controlled // setInterruptible(false); // } // // @Override // protected void initialize() { // // } // // @Override // protected void execute() { // if(Robot.oi.driver.getRawButton(7)){ // RobotMap.climbingMotor.set(1); // } else{ // RobotMap.climbingMotor.set(0); // } // } // // @Override // protected boolean isFinished() { // return false; // } // // @Override // protected void end() { // // } // // @Override // protected void interrupted() { // this.end(); // } // } // Path: Robot/src/main/java/org/usfirst/frc/team2557/robot/subsystems/Winch.java import edu.wpi.first.wpilibj.CANTalon; import edu.wpi.first.wpilibj.command.Subsystem; import org.usfirst.frc.team2557.robot.RobotMap; import org.usfirst.frc.team2557.robot.commands.winch.WinchCommand; package org.usfirst.frc.team2557.robot.subsystems; public class Winch extends Subsystem { CANTalon climbingMotor = RobotMap.climbingMotor; @Override protected void initDefaultCommand() {
setDefaultCommand(new WinchCommand());
FIRST-Team-2557-The-SOTABots/FRC_Robot
Robot/src/main/java/org/usfirst/frc/team2557/robot/commands/autonomous/sequences/Auto_Pos3Center.java
// Path: Robot/src/main/java/org/usfirst/frc/team2557/robot/commands/automation/Auto_LoadBall.java // public class Auto_LoadBall extends CommandGroup { // // public Auto_LoadBall() { // // Move the arm to the correct position // this.addSequential(new MoveArmToAngleCommand(Arm.ARM_LOADBALL)); // // Spin the intake for 2 seconds // this.addSequential(new IntakeInCommand(), 1.0); // } // // } // // Path: Robot/src/main/java/org/usfirst/frc/team2557/robot/commands/chassis/EncoderPosDriveCommand.java // public class EncoderPosDriveCommand extends Command { // // private double _speed; // private double _encpos; // // public EncoderPosDriveCommand(double encpos, double speed) { // requires(Robot.chassis); // // this._speed = speed; // this._encpos = encpos; // } // // @Override // protected void initialize() { // Robot.chassis.resetDriveStraight(); // } // // @Override // protected void execute() { // Robot.chassis.driveStraight(this._speed); // } // // @Override // protected boolean isFinished() { // return Math.abs(Robot.chassis.getLeftEncoderPos()) > this._encpos; // } // // @Override // protected void end() { // Robot.chassis.stop(); // } // // @Override // protected void interrupted() { // this.end(); // } // } // // Path: Robot/src/main/java/org/usfirst/frc/team2557/robot/commands/chassis/TurnByAngleCommand.java // public class TurnByAngleCommand extends Command { // // private PIDController _controller; // private double _degrees; // // public TurnByAngleCommand(double degrees) { // this._degrees = degrees; // // // Kp, Ki, Kd, input (gyro), output (chassis) // this._controller = new PIDController(0.01, 0.05, 0, // new PIDSource() { // @Override // public void setPIDSourceType(PIDSourceType pidSource) { // } // // @Override // public PIDSourceType getPIDSourceType() { // return PIDSourceType.kDisplacement; // } // // @Override // public double pidGet() { // return Robot.chassis.getGyroAngle(); // } // }, new PIDOutput() { // @Override // public void pidWrite(double output) { // Robot.chassis.set(output * 0.65, -output * 0.65); // } // }); // requires(Robot.chassis); // // this._controller.setContinuous(true); // this._controller.setOutputRange(-1, 1); // this._controller.setAbsoluteTolerance(1); // 1 degree tolerance // } // // @Override // protected void initialize() { // // Reset the gyro // Robot.chassis.resetGyro(); // // Reset the PID // this._controller.reset(); // // Set the setpoint for the PID // this._controller.setSetpoint(this._degrees); // } // // @Override // protected void execute() { // this._controller.enable(); // } // // @Override // protected boolean isFinished() { // return this._controller.onTarget(); // } // // protected void end() { // this._controller.disable(); // } // // @Override // protected void interrupted() { // this.end(); // } // // // // }
import edu.wpi.first.wpilibj.command.CommandGroup; import org.usfirst.frc.team2557.robot.commands.automation.Auto_LoadBall; import org.usfirst.frc.team2557.robot.commands.chassis.EncoderPosDriveCommand; import org.usfirst.frc.team2557.robot.commands.chassis.TurnByAngleCommand;
package org.usfirst.frc.team2557.robot.commands.autonomous.sequences; public class Auto_Pos3Center extends CommandGroup { public Auto_Pos3Center() {
// Path: Robot/src/main/java/org/usfirst/frc/team2557/robot/commands/automation/Auto_LoadBall.java // public class Auto_LoadBall extends CommandGroup { // // public Auto_LoadBall() { // // Move the arm to the correct position // this.addSequential(new MoveArmToAngleCommand(Arm.ARM_LOADBALL)); // // Spin the intake for 2 seconds // this.addSequential(new IntakeInCommand(), 1.0); // } // // } // // Path: Robot/src/main/java/org/usfirst/frc/team2557/robot/commands/chassis/EncoderPosDriveCommand.java // public class EncoderPosDriveCommand extends Command { // // private double _speed; // private double _encpos; // // public EncoderPosDriveCommand(double encpos, double speed) { // requires(Robot.chassis); // // this._speed = speed; // this._encpos = encpos; // } // // @Override // protected void initialize() { // Robot.chassis.resetDriveStraight(); // } // // @Override // protected void execute() { // Robot.chassis.driveStraight(this._speed); // } // // @Override // protected boolean isFinished() { // return Math.abs(Robot.chassis.getLeftEncoderPos()) > this._encpos; // } // // @Override // protected void end() { // Robot.chassis.stop(); // } // // @Override // protected void interrupted() { // this.end(); // } // } // // Path: Robot/src/main/java/org/usfirst/frc/team2557/robot/commands/chassis/TurnByAngleCommand.java // public class TurnByAngleCommand extends Command { // // private PIDController _controller; // private double _degrees; // // public TurnByAngleCommand(double degrees) { // this._degrees = degrees; // // // Kp, Ki, Kd, input (gyro), output (chassis) // this._controller = new PIDController(0.01, 0.05, 0, // new PIDSource() { // @Override // public void setPIDSourceType(PIDSourceType pidSource) { // } // // @Override // public PIDSourceType getPIDSourceType() { // return PIDSourceType.kDisplacement; // } // // @Override // public double pidGet() { // return Robot.chassis.getGyroAngle(); // } // }, new PIDOutput() { // @Override // public void pidWrite(double output) { // Robot.chassis.set(output * 0.65, -output * 0.65); // } // }); // requires(Robot.chassis); // // this._controller.setContinuous(true); // this._controller.setOutputRange(-1, 1); // this._controller.setAbsoluteTolerance(1); // 1 degree tolerance // } // // @Override // protected void initialize() { // // Reset the gyro // Robot.chassis.resetGyro(); // // Reset the PID // this._controller.reset(); // // Set the setpoint for the PID // this._controller.setSetpoint(this._degrees); // } // // @Override // protected void execute() { // this._controller.enable(); // } // // @Override // protected boolean isFinished() { // return this._controller.onTarget(); // } // // protected void end() { // this._controller.disable(); // } // // @Override // protected void interrupted() { // this.end(); // } // // // // } // Path: Robot/src/main/java/org/usfirst/frc/team2557/robot/commands/autonomous/sequences/Auto_Pos3Center.java import edu.wpi.first.wpilibj.command.CommandGroup; import org.usfirst.frc.team2557.robot.commands.automation.Auto_LoadBall; import org.usfirst.frc.team2557.robot.commands.chassis.EncoderPosDriveCommand; import org.usfirst.frc.team2557.robot.commands.chassis.TurnByAngleCommand; package org.usfirst.frc.team2557.robot.commands.autonomous.sequences; public class Auto_Pos3Center extends CommandGroup { public Auto_Pos3Center() {
this.addParallel(new Auto_LoadBall());
FIRST-Team-2557-The-SOTABots/FRC_Robot
Robot/src/main/java/org/usfirst/frc/team2557/robot/commands/autonomous/sequences/Auto_Pos3Center.java
// Path: Robot/src/main/java/org/usfirst/frc/team2557/robot/commands/automation/Auto_LoadBall.java // public class Auto_LoadBall extends CommandGroup { // // public Auto_LoadBall() { // // Move the arm to the correct position // this.addSequential(new MoveArmToAngleCommand(Arm.ARM_LOADBALL)); // // Spin the intake for 2 seconds // this.addSequential(new IntakeInCommand(), 1.0); // } // // } // // Path: Robot/src/main/java/org/usfirst/frc/team2557/robot/commands/chassis/EncoderPosDriveCommand.java // public class EncoderPosDriveCommand extends Command { // // private double _speed; // private double _encpos; // // public EncoderPosDriveCommand(double encpos, double speed) { // requires(Robot.chassis); // // this._speed = speed; // this._encpos = encpos; // } // // @Override // protected void initialize() { // Robot.chassis.resetDriveStraight(); // } // // @Override // protected void execute() { // Robot.chassis.driveStraight(this._speed); // } // // @Override // protected boolean isFinished() { // return Math.abs(Robot.chassis.getLeftEncoderPos()) > this._encpos; // } // // @Override // protected void end() { // Robot.chassis.stop(); // } // // @Override // protected void interrupted() { // this.end(); // } // } // // Path: Robot/src/main/java/org/usfirst/frc/team2557/robot/commands/chassis/TurnByAngleCommand.java // public class TurnByAngleCommand extends Command { // // private PIDController _controller; // private double _degrees; // // public TurnByAngleCommand(double degrees) { // this._degrees = degrees; // // // Kp, Ki, Kd, input (gyro), output (chassis) // this._controller = new PIDController(0.01, 0.05, 0, // new PIDSource() { // @Override // public void setPIDSourceType(PIDSourceType pidSource) { // } // // @Override // public PIDSourceType getPIDSourceType() { // return PIDSourceType.kDisplacement; // } // // @Override // public double pidGet() { // return Robot.chassis.getGyroAngle(); // } // }, new PIDOutput() { // @Override // public void pidWrite(double output) { // Robot.chassis.set(output * 0.65, -output * 0.65); // } // }); // requires(Robot.chassis); // // this._controller.setContinuous(true); // this._controller.setOutputRange(-1, 1); // this._controller.setAbsoluteTolerance(1); // 1 degree tolerance // } // // @Override // protected void initialize() { // // Reset the gyro // Robot.chassis.resetGyro(); // // Reset the PID // this._controller.reset(); // // Set the setpoint for the PID // this._controller.setSetpoint(this._degrees); // } // // @Override // protected void execute() { // this._controller.enable(); // } // // @Override // protected boolean isFinished() { // return this._controller.onTarget(); // } // // protected void end() { // this._controller.disable(); // } // // @Override // protected void interrupted() { // this.end(); // } // // // // }
import edu.wpi.first.wpilibj.command.CommandGroup; import org.usfirst.frc.team2557.robot.commands.automation.Auto_LoadBall; import org.usfirst.frc.team2557.robot.commands.chassis.EncoderPosDriveCommand; import org.usfirst.frc.team2557.robot.commands.chassis.TurnByAngleCommand;
package org.usfirst.frc.team2557.robot.commands.autonomous.sequences; public class Auto_Pos3Center extends CommandGroup { public Auto_Pos3Center() { this.addParallel(new Auto_LoadBall());
// Path: Robot/src/main/java/org/usfirst/frc/team2557/robot/commands/automation/Auto_LoadBall.java // public class Auto_LoadBall extends CommandGroup { // // public Auto_LoadBall() { // // Move the arm to the correct position // this.addSequential(new MoveArmToAngleCommand(Arm.ARM_LOADBALL)); // // Spin the intake for 2 seconds // this.addSequential(new IntakeInCommand(), 1.0); // } // // } // // Path: Robot/src/main/java/org/usfirst/frc/team2557/robot/commands/chassis/EncoderPosDriveCommand.java // public class EncoderPosDriveCommand extends Command { // // private double _speed; // private double _encpos; // // public EncoderPosDriveCommand(double encpos, double speed) { // requires(Robot.chassis); // // this._speed = speed; // this._encpos = encpos; // } // // @Override // protected void initialize() { // Robot.chassis.resetDriveStraight(); // } // // @Override // protected void execute() { // Robot.chassis.driveStraight(this._speed); // } // // @Override // protected boolean isFinished() { // return Math.abs(Robot.chassis.getLeftEncoderPos()) > this._encpos; // } // // @Override // protected void end() { // Robot.chassis.stop(); // } // // @Override // protected void interrupted() { // this.end(); // } // } // // Path: Robot/src/main/java/org/usfirst/frc/team2557/robot/commands/chassis/TurnByAngleCommand.java // public class TurnByAngleCommand extends Command { // // private PIDController _controller; // private double _degrees; // // public TurnByAngleCommand(double degrees) { // this._degrees = degrees; // // // Kp, Ki, Kd, input (gyro), output (chassis) // this._controller = new PIDController(0.01, 0.05, 0, // new PIDSource() { // @Override // public void setPIDSourceType(PIDSourceType pidSource) { // } // // @Override // public PIDSourceType getPIDSourceType() { // return PIDSourceType.kDisplacement; // } // // @Override // public double pidGet() { // return Robot.chassis.getGyroAngle(); // } // }, new PIDOutput() { // @Override // public void pidWrite(double output) { // Robot.chassis.set(output * 0.65, -output * 0.65); // } // }); // requires(Robot.chassis); // // this._controller.setContinuous(true); // this._controller.setOutputRange(-1, 1); // this._controller.setAbsoluteTolerance(1); // 1 degree tolerance // } // // @Override // protected void initialize() { // // Reset the gyro // Robot.chassis.resetGyro(); // // Reset the PID // this._controller.reset(); // // Set the setpoint for the PID // this._controller.setSetpoint(this._degrees); // } // // @Override // protected void execute() { // this._controller.enable(); // } // // @Override // protected boolean isFinished() { // return this._controller.onTarget(); // } // // protected void end() { // this._controller.disable(); // } // // @Override // protected void interrupted() { // this.end(); // } // // // // } // Path: Robot/src/main/java/org/usfirst/frc/team2557/robot/commands/autonomous/sequences/Auto_Pos3Center.java import edu.wpi.first.wpilibj.command.CommandGroup; import org.usfirst.frc.team2557.robot.commands.automation.Auto_LoadBall; import org.usfirst.frc.team2557.robot.commands.chassis.EncoderPosDriveCommand; import org.usfirst.frc.team2557.robot.commands.chassis.TurnByAngleCommand; package org.usfirst.frc.team2557.robot.commands.autonomous.sequences; public class Auto_Pos3Center extends CommandGroup { public Auto_Pos3Center() { this.addParallel(new Auto_LoadBall());
this.addSequential(new TurnByAngleCommand(-20));
FIRST-Team-2557-The-SOTABots/FRC_Robot
Robot/src/main/java/org/usfirst/frc/team2557/robot/commands/autonomous/sequences/Auto_Pos3Center.java
// Path: Robot/src/main/java/org/usfirst/frc/team2557/robot/commands/automation/Auto_LoadBall.java // public class Auto_LoadBall extends CommandGroup { // // public Auto_LoadBall() { // // Move the arm to the correct position // this.addSequential(new MoveArmToAngleCommand(Arm.ARM_LOADBALL)); // // Spin the intake for 2 seconds // this.addSequential(new IntakeInCommand(), 1.0); // } // // } // // Path: Robot/src/main/java/org/usfirst/frc/team2557/robot/commands/chassis/EncoderPosDriveCommand.java // public class EncoderPosDriveCommand extends Command { // // private double _speed; // private double _encpos; // // public EncoderPosDriveCommand(double encpos, double speed) { // requires(Robot.chassis); // // this._speed = speed; // this._encpos = encpos; // } // // @Override // protected void initialize() { // Robot.chassis.resetDriveStraight(); // } // // @Override // protected void execute() { // Robot.chassis.driveStraight(this._speed); // } // // @Override // protected boolean isFinished() { // return Math.abs(Robot.chassis.getLeftEncoderPos()) > this._encpos; // } // // @Override // protected void end() { // Robot.chassis.stop(); // } // // @Override // protected void interrupted() { // this.end(); // } // } // // Path: Robot/src/main/java/org/usfirst/frc/team2557/robot/commands/chassis/TurnByAngleCommand.java // public class TurnByAngleCommand extends Command { // // private PIDController _controller; // private double _degrees; // // public TurnByAngleCommand(double degrees) { // this._degrees = degrees; // // // Kp, Ki, Kd, input (gyro), output (chassis) // this._controller = new PIDController(0.01, 0.05, 0, // new PIDSource() { // @Override // public void setPIDSourceType(PIDSourceType pidSource) { // } // // @Override // public PIDSourceType getPIDSourceType() { // return PIDSourceType.kDisplacement; // } // // @Override // public double pidGet() { // return Robot.chassis.getGyroAngle(); // } // }, new PIDOutput() { // @Override // public void pidWrite(double output) { // Robot.chassis.set(output * 0.65, -output * 0.65); // } // }); // requires(Robot.chassis); // // this._controller.setContinuous(true); // this._controller.setOutputRange(-1, 1); // this._controller.setAbsoluteTolerance(1); // 1 degree tolerance // } // // @Override // protected void initialize() { // // Reset the gyro // Robot.chassis.resetGyro(); // // Reset the PID // this._controller.reset(); // // Set the setpoint for the PID // this._controller.setSetpoint(this._degrees); // } // // @Override // protected void execute() { // this._controller.enable(); // } // // @Override // protected boolean isFinished() { // return this._controller.onTarget(); // } // // protected void end() { // this._controller.disable(); // } // // @Override // protected void interrupted() { // this.end(); // } // // // // }
import edu.wpi.first.wpilibj.command.CommandGroup; import org.usfirst.frc.team2557.robot.commands.automation.Auto_LoadBall; import org.usfirst.frc.team2557.robot.commands.chassis.EncoderPosDriveCommand; import org.usfirst.frc.team2557.robot.commands.chassis.TurnByAngleCommand;
package org.usfirst.frc.team2557.robot.commands.autonomous.sequences; public class Auto_Pos3Center extends CommandGroup { public Auto_Pos3Center() { this.addParallel(new Auto_LoadBall()); this.addSequential(new TurnByAngleCommand(-20));
// Path: Robot/src/main/java/org/usfirst/frc/team2557/robot/commands/automation/Auto_LoadBall.java // public class Auto_LoadBall extends CommandGroup { // // public Auto_LoadBall() { // // Move the arm to the correct position // this.addSequential(new MoveArmToAngleCommand(Arm.ARM_LOADBALL)); // // Spin the intake for 2 seconds // this.addSequential(new IntakeInCommand(), 1.0); // } // // } // // Path: Robot/src/main/java/org/usfirst/frc/team2557/robot/commands/chassis/EncoderPosDriveCommand.java // public class EncoderPosDriveCommand extends Command { // // private double _speed; // private double _encpos; // // public EncoderPosDriveCommand(double encpos, double speed) { // requires(Robot.chassis); // // this._speed = speed; // this._encpos = encpos; // } // // @Override // protected void initialize() { // Robot.chassis.resetDriveStraight(); // } // // @Override // protected void execute() { // Robot.chassis.driveStraight(this._speed); // } // // @Override // protected boolean isFinished() { // return Math.abs(Robot.chassis.getLeftEncoderPos()) > this._encpos; // } // // @Override // protected void end() { // Robot.chassis.stop(); // } // // @Override // protected void interrupted() { // this.end(); // } // } // // Path: Robot/src/main/java/org/usfirst/frc/team2557/robot/commands/chassis/TurnByAngleCommand.java // public class TurnByAngleCommand extends Command { // // private PIDController _controller; // private double _degrees; // // public TurnByAngleCommand(double degrees) { // this._degrees = degrees; // // // Kp, Ki, Kd, input (gyro), output (chassis) // this._controller = new PIDController(0.01, 0.05, 0, // new PIDSource() { // @Override // public void setPIDSourceType(PIDSourceType pidSource) { // } // // @Override // public PIDSourceType getPIDSourceType() { // return PIDSourceType.kDisplacement; // } // // @Override // public double pidGet() { // return Robot.chassis.getGyroAngle(); // } // }, new PIDOutput() { // @Override // public void pidWrite(double output) { // Robot.chassis.set(output * 0.65, -output * 0.65); // } // }); // requires(Robot.chassis); // // this._controller.setContinuous(true); // this._controller.setOutputRange(-1, 1); // this._controller.setAbsoluteTolerance(1); // 1 degree tolerance // } // // @Override // protected void initialize() { // // Reset the gyro // Robot.chassis.resetGyro(); // // Reset the PID // this._controller.reset(); // // Set the setpoint for the PID // this._controller.setSetpoint(this._degrees); // } // // @Override // protected void execute() { // this._controller.enable(); // } // // @Override // protected boolean isFinished() { // return this._controller.onTarget(); // } // // protected void end() { // this._controller.disable(); // } // // @Override // protected void interrupted() { // this.end(); // } // // // // } // Path: Robot/src/main/java/org/usfirst/frc/team2557/robot/commands/autonomous/sequences/Auto_Pos3Center.java import edu.wpi.first.wpilibj.command.CommandGroup; import org.usfirst.frc.team2557.robot.commands.automation.Auto_LoadBall; import org.usfirst.frc.team2557.robot.commands.chassis.EncoderPosDriveCommand; import org.usfirst.frc.team2557.robot.commands.chassis.TurnByAngleCommand; package org.usfirst.frc.team2557.robot.commands.autonomous.sequences; public class Auto_Pos3Center extends CommandGroup { public Auto_Pos3Center() { this.addParallel(new Auto_LoadBall()); this.addSequential(new TurnByAngleCommand(-20));
this.addSequential(new EncoderPosDriveCommand(6776, 0.5));
FIRST-Team-2557-The-SOTABots/FRC_Robot
Robot/src/main/java/org/usfirst/frc/team2557/robot/commands/autonomous/sequences/Auto_Pos1Left.java
// Path: Robot/src/main/java/org/usfirst/frc/team2557/robot/commands/automation/Auto_LoadBall.java // public class Auto_LoadBall extends CommandGroup { // // public Auto_LoadBall() { // // Move the arm to the correct position // this.addSequential(new MoveArmToAngleCommand(Arm.ARM_LOADBALL)); // // Spin the intake for 2 seconds // this.addSequential(new IntakeInCommand(), 1.0); // } // // } // // Path: Robot/src/main/java/org/usfirst/frc/team2557/robot/commands/chassis/EncoderPosDriveCommand.java // public class EncoderPosDriveCommand extends Command { // // private double _speed; // private double _encpos; // // public EncoderPosDriveCommand(double encpos, double speed) { // requires(Robot.chassis); // // this._speed = speed; // this._encpos = encpos; // } // // @Override // protected void initialize() { // Robot.chassis.resetDriveStraight(); // } // // @Override // protected void execute() { // Robot.chassis.driveStraight(this._speed); // } // // @Override // protected boolean isFinished() { // return Math.abs(Robot.chassis.getLeftEncoderPos()) > this._encpos; // } // // @Override // protected void end() { // Robot.chassis.stop(); // } // // @Override // protected void interrupted() { // this.end(); // } // } // // Path: Robot/src/main/java/org/usfirst/frc/team2557/robot/commands/chassis/TurnByAngleCommand.java // public class TurnByAngleCommand extends Command { // // private PIDController _controller; // private double _degrees; // // public TurnByAngleCommand(double degrees) { // this._degrees = degrees; // // // Kp, Ki, Kd, input (gyro), output (chassis) // this._controller = new PIDController(0.01, 0.05, 0, // new PIDSource() { // @Override // public void setPIDSourceType(PIDSourceType pidSource) { // } // // @Override // public PIDSourceType getPIDSourceType() { // return PIDSourceType.kDisplacement; // } // // @Override // public double pidGet() { // return Robot.chassis.getGyroAngle(); // } // }, new PIDOutput() { // @Override // public void pidWrite(double output) { // Robot.chassis.set(output * 0.65, -output * 0.65); // } // }); // requires(Robot.chassis); // // this._controller.setContinuous(true); // this._controller.setOutputRange(-1, 1); // this._controller.setAbsoluteTolerance(1); // 1 degree tolerance // } // // @Override // protected void initialize() { // // Reset the gyro // Robot.chassis.resetGyro(); // // Reset the PID // this._controller.reset(); // // Set the setpoint for the PID // this._controller.setSetpoint(this._degrees); // } // // @Override // protected void execute() { // this._controller.enable(); // } // // @Override // protected boolean isFinished() { // return this._controller.onTarget(); // } // // protected void end() { // this._controller.disable(); // } // // @Override // protected void interrupted() { // this.end(); // } // // // // }
import edu.wpi.first.wpilibj.command.CommandGroup; import org.usfirst.frc.team2557.robot.commands.automation.Auto_LoadBall; import org.usfirst.frc.team2557.robot.commands.chassis.EncoderPosDriveCommand; import org.usfirst.frc.team2557.robot.commands.chassis.TurnByAngleCommand;
package org.usfirst.frc.team2557.robot.commands.autonomous.sequences; public class Auto_Pos1Left extends CommandGroup { public Auto_Pos1Left() {
// Path: Robot/src/main/java/org/usfirst/frc/team2557/robot/commands/automation/Auto_LoadBall.java // public class Auto_LoadBall extends CommandGroup { // // public Auto_LoadBall() { // // Move the arm to the correct position // this.addSequential(new MoveArmToAngleCommand(Arm.ARM_LOADBALL)); // // Spin the intake for 2 seconds // this.addSequential(new IntakeInCommand(), 1.0); // } // // } // // Path: Robot/src/main/java/org/usfirst/frc/team2557/robot/commands/chassis/EncoderPosDriveCommand.java // public class EncoderPosDriveCommand extends Command { // // private double _speed; // private double _encpos; // // public EncoderPosDriveCommand(double encpos, double speed) { // requires(Robot.chassis); // // this._speed = speed; // this._encpos = encpos; // } // // @Override // protected void initialize() { // Robot.chassis.resetDriveStraight(); // } // // @Override // protected void execute() { // Robot.chassis.driveStraight(this._speed); // } // // @Override // protected boolean isFinished() { // return Math.abs(Robot.chassis.getLeftEncoderPos()) > this._encpos; // } // // @Override // protected void end() { // Robot.chassis.stop(); // } // // @Override // protected void interrupted() { // this.end(); // } // } // // Path: Robot/src/main/java/org/usfirst/frc/team2557/robot/commands/chassis/TurnByAngleCommand.java // public class TurnByAngleCommand extends Command { // // private PIDController _controller; // private double _degrees; // // public TurnByAngleCommand(double degrees) { // this._degrees = degrees; // // // Kp, Ki, Kd, input (gyro), output (chassis) // this._controller = new PIDController(0.01, 0.05, 0, // new PIDSource() { // @Override // public void setPIDSourceType(PIDSourceType pidSource) { // } // // @Override // public PIDSourceType getPIDSourceType() { // return PIDSourceType.kDisplacement; // } // // @Override // public double pidGet() { // return Robot.chassis.getGyroAngle(); // } // }, new PIDOutput() { // @Override // public void pidWrite(double output) { // Robot.chassis.set(output * 0.65, -output * 0.65); // } // }); // requires(Robot.chassis); // // this._controller.setContinuous(true); // this._controller.setOutputRange(-1, 1); // this._controller.setAbsoluteTolerance(1); // 1 degree tolerance // } // // @Override // protected void initialize() { // // Reset the gyro // Robot.chassis.resetGyro(); // // Reset the PID // this._controller.reset(); // // Set the setpoint for the PID // this._controller.setSetpoint(this._degrees); // } // // @Override // protected void execute() { // this._controller.enable(); // } // // @Override // protected boolean isFinished() { // return this._controller.onTarget(); // } // // protected void end() { // this._controller.disable(); // } // // @Override // protected void interrupted() { // this.end(); // } // // // // } // Path: Robot/src/main/java/org/usfirst/frc/team2557/robot/commands/autonomous/sequences/Auto_Pos1Left.java import edu.wpi.first.wpilibj.command.CommandGroup; import org.usfirst.frc.team2557.robot.commands.automation.Auto_LoadBall; import org.usfirst.frc.team2557.robot.commands.chassis.EncoderPosDriveCommand; import org.usfirst.frc.team2557.robot.commands.chassis.TurnByAngleCommand; package org.usfirst.frc.team2557.robot.commands.autonomous.sequences; public class Auto_Pos1Left extends CommandGroup { public Auto_Pos1Left() {
this.addParallel(new Auto_LoadBall());