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
tudoNoob/poseidon
src/main/java/com/poseidon/controller/QuiropraxistaController.java
// Path: src/main/java/com/poseidon/dao/QuiropraxistaDao.java // @Repository // @Qualifier() // public interface QuiropraxistaDao extends CrudRepository<Quiropraxista, Integer>{ // public Quiropraxista findByNome(String nome); // public Quiropraxista findById(Integer id); // } // // Path: src/main/java/com/poseidon/enums/CRUDViewEnum.java // public enum CRUDViewEnum { // // IS_SAVE("isSave"), // IS_DELETE("isDelete"), // IS_UPDATE("isUpdate"), // IS_SEARCH("isSearch"); // // // // private String operation; // // CRUDViewEnum(String operation) { // this.operation=operation; // } // // public String getOperation() { // return operation; // } // } // // Path: src/main/java/com/poseidon/model/CRUDView.java // public class CRUDView { // // private String isSave; // // private String isUpdate; // // private String isSearch; // // private String isDelete; // // private String isToShowAll; // // public String getIsToShowAll() { // return isToShowAll; // } // // public void setIsToShowAll(String isToShowAll) { // this.isToShowAll = isToShowAll; // } // // public String getIsSave() { // return isSave; // } // // public void setIsSave(String isSave) { // this.isSave = isSave; // } // // public String getIsUpdate() { // return isUpdate; // } // // public void setIsUpdate(String isUpdate) { // this.isUpdate = isUpdate; // } // // public String getIsSearch() { // return isSearch; // } // // public void setIsSearch(String isSearch) { // this.isSearch = isSearch; // } // // public String getIsDelete() { // return isDelete; // } // // public void setIsDelete(String isDelete) { // this.isDelete = isDelete; // } // } // // Path: src/main/java/com/poseidon/model/Quiropraxista.java // @Entity // public class Quiropraxista { // // @Id // @GeneratedValue(strategy = GenerationType.AUTO) // private Integer id; // private String nome; // // public Quiropraxista() { // // } // // public Quiropraxista(Integer id, String nome) { // this.id = id; // this.nome = nome; // } // // public void setNome(String nome) { // this.nome = nome; // } // // public String getNome() { // return nome; // } // // public void setId(Integer id) { // this.id = id; // } // // public Integer getId() { // return id; // } // // @Override // public String toString() { // return "Quiropraxista [id=" + id + ", nome=" + nome + "]"; // } // }
import com.poseidon.annotation.NotNullArgs; import com.poseidon.annotation.ViewName; import com.poseidon.dao.QuiropraxistaDao; import com.poseidon.enums.CRUDViewEnum; import com.poseidon.model.CRUDView; import com.poseidon.model.Quiropraxista; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.mvc.support.RedirectAttributes; import java.util.List; import java.util.logging.Logger;
package com.poseidon.controller; @Controller @RequestMapping("/admin") public class QuiropraxistaController extends ControllerBase { public static final String REDIRECT_ADMIN_QUIROPRAXISTA = "redirect:/admin/quiropraxista"; public static final String QUIROPRAXISTA_VIEW_NAME = "Quiropraxista"; @Autowired QuiropraxistaDao quiropraxistaRepository; private static Logger logger = Logger.getLogger("QuiropraxistaController"); @RequestMapping("/quiropraxista") @ViewName(name = QUIROPRAXISTA_VIEW_NAME)
// Path: src/main/java/com/poseidon/dao/QuiropraxistaDao.java // @Repository // @Qualifier() // public interface QuiropraxistaDao extends CrudRepository<Quiropraxista, Integer>{ // public Quiropraxista findByNome(String nome); // public Quiropraxista findById(Integer id); // } // // Path: src/main/java/com/poseidon/enums/CRUDViewEnum.java // public enum CRUDViewEnum { // // IS_SAVE("isSave"), // IS_DELETE("isDelete"), // IS_UPDATE("isUpdate"), // IS_SEARCH("isSearch"); // // // // private String operation; // // CRUDViewEnum(String operation) { // this.operation=operation; // } // // public String getOperation() { // return operation; // } // } // // Path: src/main/java/com/poseidon/model/CRUDView.java // public class CRUDView { // // private String isSave; // // private String isUpdate; // // private String isSearch; // // private String isDelete; // // private String isToShowAll; // // public String getIsToShowAll() { // return isToShowAll; // } // // public void setIsToShowAll(String isToShowAll) { // this.isToShowAll = isToShowAll; // } // // public String getIsSave() { // return isSave; // } // // public void setIsSave(String isSave) { // this.isSave = isSave; // } // // public String getIsUpdate() { // return isUpdate; // } // // public void setIsUpdate(String isUpdate) { // this.isUpdate = isUpdate; // } // // public String getIsSearch() { // return isSearch; // } // // public void setIsSearch(String isSearch) { // this.isSearch = isSearch; // } // // public String getIsDelete() { // return isDelete; // } // // public void setIsDelete(String isDelete) { // this.isDelete = isDelete; // } // } // // Path: src/main/java/com/poseidon/model/Quiropraxista.java // @Entity // public class Quiropraxista { // // @Id // @GeneratedValue(strategy = GenerationType.AUTO) // private Integer id; // private String nome; // // public Quiropraxista() { // // } // // public Quiropraxista(Integer id, String nome) { // this.id = id; // this.nome = nome; // } // // public void setNome(String nome) { // this.nome = nome; // } // // public String getNome() { // return nome; // } // // public void setId(Integer id) { // this.id = id; // } // // public Integer getId() { // return id; // } // // @Override // public String toString() { // return "Quiropraxista [id=" + id + ", nome=" + nome + "]"; // } // } // Path: src/main/java/com/poseidon/controller/QuiropraxistaController.java import com.poseidon.annotation.NotNullArgs; import com.poseidon.annotation.ViewName; import com.poseidon.dao.QuiropraxistaDao; import com.poseidon.enums.CRUDViewEnum; import com.poseidon.model.CRUDView; import com.poseidon.model.Quiropraxista; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.mvc.support.RedirectAttributes; import java.util.List; import java.util.logging.Logger; package com.poseidon.controller; @Controller @RequestMapping("/admin") public class QuiropraxistaController extends ControllerBase { public static final String REDIRECT_ADMIN_QUIROPRAXISTA = "redirect:/admin/quiropraxista"; public static final String QUIROPRAXISTA_VIEW_NAME = "Quiropraxista"; @Autowired QuiropraxistaDao quiropraxistaRepository; private static Logger logger = Logger.getLogger("QuiropraxistaController"); @RequestMapping("/quiropraxista") @ViewName(name = QUIROPRAXISTA_VIEW_NAME)
public ModelAndView criarPaginaQuiropraxista(ModelAndView modelAndView, @ModelAttribute CRUDView crudView) {
tudoNoob/poseidon
src/main/java/com/poseidon/controller/QuiropraxistaController.java
// Path: src/main/java/com/poseidon/dao/QuiropraxistaDao.java // @Repository // @Qualifier() // public interface QuiropraxistaDao extends CrudRepository<Quiropraxista, Integer>{ // public Quiropraxista findByNome(String nome); // public Quiropraxista findById(Integer id); // } // // Path: src/main/java/com/poseidon/enums/CRUDViewEnum.java // public enum CRUDViewEnum { // // IS_SAVE("isSave"), // IS_DELETE("isDelete"), // IS_UPDATE("isUpdate"), // IS_SEARCH("isSearch"); // // // // private String operation; // // CRUDViewEnum(String operation) { // this.operation=operation; // } // // public String getOperation() { // return operation; // } // } // // Path: src/main/java/com/poseidon/model/CRUDView.java // public class CRUDView { // // private String isSave; // // private String isUpdate; // // private String isSearch; // // private String isDelete; // // private String isToShowAll; // // public String getIsToShowAll() { // return isToShowAll; // } // // public void setIsToShowAll(String isToShowAll) { // this.isToShowAll = isToShowAll; // } // // public String getIsSave() { // return isSave; // } // // public void setIsSave(String isSave) { // this.isSave = isSave; // } // // public String getIsUpdate() { // return isUpdate; // } // // public void setIsUpdate(String isUpdate) { // this.isUpdate = isUpdate; // } // // public String getIsSearch() { // return isSearch; // } // // public void setIsSearch(String isSearch) { // this.isSearch = isSearch; // } // // public String getIsDelete() { // return isDelete; // } // // public void setIsDelete(String isDelete) { // this.isDelete = isDelete; // } // } // // Path: src/main/java/com/poseidon/model/Quiropraxista.java // @Entity // public class Quiropraxista { // // @Id // @GeneratedValue(strategy = GenerationType.AUTO) // private Integer id; // private String nome; // // public Quiropraxista() { // // } // // public Quiropraxista(Integer id, String nome) { // this.id = id; // this.nome = nome; // } // // public void setNome(String nome) { // this.nome = nome; // } // // public String getNome() { // return nome; // } // // public void setId(Integer id) { // this.id = id; // } // // public Integer getId() { // return id; // } // // @Override // public String toString() { // return "Quiropraxista [id=" + id + ", nome=" + nome + "]"; // } // }
import com.poseidon.annotation.NotNullArgs; import com.poseidon.annotation.ViewName; import com.poseidon.dao.QuiropraxistaDao; import com.poseidon.enums.CRUDViewEnum; import com.poseidon.model.CRUDView; import com.poseidon.model.Quiropraxista; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.mvc.support.RedirectAttributes; import java.util.List; import java.util.logging.Logger;
@ViewName(name = QUIROPRAXISTA_VIEW_NAME) public ModelAndView criarPaginaQuiropraxista(ModelAndView modelAndView, @ModelAttribute CRUDView crudView) { modelAndView.getModelMap().addAttribute(CRUDVIEW_CLASS_NAME, crudView); achaTodosQuiropraxistas(modelAndView, null); return modelAndView; } private void achaTodosQuiropraxistas(ModelAndView modelAndView, RedirectAttributes redirectAttributes) { Iterable<Quiropraxista> listaTodosQuiropraxistas = quiropraxistaRepository.findAll(); List<Quiropraxista> quiropraxistasView = com.google.common.collect.Lists.newArrayList(); for (Quiropraxista quiropraxista : listaTodosQuiropraxistas) { quiropraxistasView.add(quiropraxista); } modelAndView.getModelMap().addAttribute("quiropraxistas", quiropraxistasView); } @RequestMapping(value = "/deletarQuiropraxista") @ViewName(name = REDIRECT_ADMIN_QUIROPRAXISTA) @NotNullArgs public ModelAndView deletarQuiropraxista(@ModelAttribute Quiropraxista quiropraxista, ModelAndView modelAndView, RedirectAttributes redirectAttributes) { Quiropraxista quiropraxistaEncontrado = quiropraxistaRepository.findById(quiropraxista.getId()); try { quiropraxistaRepository.delete(quiropraxistaEncontrado); } catch (RuntimeException exception) { logger.info("Deletando o quiropraxista."); }
// Path: src/main/java/com/poseidon/dao/QuiropraxistaDao.java // @Repository // @Qualifier() // public interface QuiropraxistaDao extends CrudRepository<Quiropraxista, Integer>{ // public Quiropraxista findByNome(String nome); // public Quiropraxista findById(Integer id); // } // // Path: src/main/java/com/poseidon/enums/CRUDViewEnum.java // public enum CRUDViewEnum { // // IS_SAVE("isSave"), // IS_DELETE("isDelete"), // IS_UPDATE("isUpdate"), // IS_SEARCH("isSearch"); // // // // private String operation; // // CRUDViewEnum(String operation) { // this.operation=operation; // } // // public String getOperation() { // return operation; // } // } // // Path: src/main/java/com/poseidon/model/CRUDView.java // public class CRUDView { // // private String isSave; // // private String isUpdate; // // private String isSearch; // // private String isDelete; // // private String isToShowAll; // // public String getIsToShowAll() { // return isToShowAll; // } // // public void setIsToShowAll(String isToShowAll) { // this.isToShowAll = isToShowAll; // } // // public String getIsSave() { // return isSave; // } // // public void setIsSave(String isSave) { // this.isSave = isSave; // } // // public String getIsUpdate() { // return isUpdate; // } // // public void setIsUpdate(String isUpdate) { // this.isUpdate = isUpdate; // } // // public String getIsSearch() { // return isSearch; // } // // public void setIsSearch(String isSearch) { // this.isSearch = isSearch; // } // // public String getIsDelete() { // return isDelete; // } // // public void setIsDelete(String isDelete) { // this.isDelete = isDelete; // } // } // // Path: src/main/java/com/poseidon/model/Quiropraxista.java // @Entity // public class Quiropraxista { // // @Id // @GeneratedValue(strategy = GenerationType.AUTO) // private Integer id; // private String nome; // // public Quiropraxista() { // // } // // public Quiropraxista(Integer id, String nome) { // this.id = id; // this.nome = nome; // } // // public void setNome(String nome) { // this.nome = nome; // } // // public String getNome() { // return nome; // } // // public void setId(Integer id) { // this.id = id; // } // // public Integer getId() { // return id; // } // // @Override // public String toString() { // return "Quiropraxista [id=" + id + ", nome=" + nome + "]"; // } // } // Path: src/main/java/com/poseidon/controller/QuiropraxistaController.java import com.poseidon.annotation.NotNullArgs; import com.poseidon.annotation.ViewName; import com.poseidon.dao.QuiropraxistaDao; import com.poseidon.enums.CRUDViewEnum; import com.poseidon.model.CRUDView; import com.poseidon.model.Quiropraxista; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.mvc.support.RedirectAttributes; import java.util.List; import java.util.logging.Logger; @ViewName(name = QUIROPRAXISTA_VIEW_NAME) public ModelAndView criarPaginaQuiropraxista(ModelAndView modelAndView, @ModelAttribute CRUDView crudView) { modelAndView.getModelMap().addAttribute(CRUDVIEW_CLASS_NAME, crudView); achaTodosQuiropraxistas(modelAndView, null); return modelAndView; } private void achaTodosQuiropraxistas(ModelAndView modelAndView, RedirectAttributes redirectAttributes) { Iterable<Quiropraxista> listaTodosQuiropraxistas = quiropraxistaRepository.findAll(); List<Quiropraxista> quiropraxistasView = com.google.common.collect.Lists.newArrayList(); for (Quiropraxista quiropraxista : listaTodosQuiropraxistas) { quiropraxistasView.add(quiropraxista); } modelAndView.getModelMap().addAttribute("quiropraxistas", quiropraxistasView); } @RequestMapping(value = "/deletarQuiropraxista") @ViewName(name = REDIRECT_ADMIN_QUIROPRAXISTA) @NotNullArgs public ModelAndView deletarQuiropraxista(@ModelAttribute Quiropraxista quiropraxista, ModelAndView modelAndView, RedirectAttributes redirectAttributes) { Quiropraxista quiropraxistaEncontrado = quiropraxistaRepository.findById(quiropraxista.getId()); try { quiropraxistaRepository.delete(quiropraxistaEncontrado); } catch (RuntimeException exception) { logger.info("Deletando o quiropraxista."); }
this.buildRedirectFlashAttributes(redirectAttributes,CRUDViewEnum.IS_DELETE);
tudoNoob/poseidon
src/main/java/com/poseidon/advices/NotNullArgsProcessAdvice.java
// Path: src/main/java/com/poseidon/exception/NotNullException.java // public class NotNullException extends PoseidonException { // // public NotNullException(String message) { // super(message); // // } // // }
import com.poseidon.annotation.NotNullArgs; import com.poseidon.exception.NotNullException; import org.aspectj.lang.JoinPoint; import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.annotation.Before; import org.aspectj.lang.reflect.MethodSignature; import org.springframework.stereotype.Component; import java.lang.reflect.Method;
package com.poseidon.advices; /** * Esta classe ira processar a annotation @NotNull em toda a aplicacao. * @author ahrons * @see NoNullArgs */ @Component @Aspect public class NotNullArgsProcessAdvice { /** * Este metodo ira fazer o processamento da annotation @NotNull * @param joinPoint * @see NotNullArgs */ @Before("execution(* com.poseidon.*..*(..))") public void logServiceAccess(JoinPoint joinPoint) { final MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature(); Method method = methodSignature.getMethod(); NotNullArgs annotation = method.getAnnotation(NotNullArgs.class); if (annotation == null) { return; } String[] nullArgs = annotation.nullArgs(); Object[] args = joinPoint.getArgs(); checkForNullArgs(nullArgs, args); } private void checkForNullArgs(String[] nullArgs, Object[] args) { for (int i = 0; i < args.length; i++) { if (!validatePositionArgs(i, nullArgs)) { if (args[i] == null) {
// Path: src/main/java/com/poseidon/exception/NotNullException.java // public class NotNullException extends PoseidonException { // // public NotNullException(String message) { // super(message); // // } // // } // Path: src/main/java/com/poseidon/advices/NotNullArgsProcessAdvice.java import com.poseidon.annotation.NotNullArgs; import com.poseidon.exception.NotNullException; import org.aspectj.lang.JoinPoint; import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.annotation.Before; import org.aspectj.lang.reflect.MethodSignature; import org.springframework.stereotype.Component; import java.lang.reflect.Method; package com.poseidon.advices; /** * Esta classe ira processar a annotation @NotNull em toda a aplicacao. * @author ahrons * @see NoNullArgs */ @Component @Aspect public class NotNullArgsProcessAdvice { /** * Este metodo ira fazer o processamento da annotation @NotNull * @param joinPoint * @see NotNullArgs */ @Before("execution(* com.poseidon.*..*(..))") public void logServiceAccess(JoinPoint joinPoint) { final MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature(); Method method = methodSignature.getMethod(); NotNullArgs annotation = method.getAnnotation(NotNullArgs.class); if (annotation == null) { return; } String[] nullArgs = annotation.nullArgs(); Object[] args = joinPoint.getArgs(); checkForNullArgs(nullArgs, args); } private void checkForNullArgs(String[] nullArgs, Object[] args) { for (int i = 0; i < args.length; i++) { if (!validatePositionArgs(i, nullArgs)) { if (args[i] == null) {
throw new NotNullException("argumento null, numero da ordem de declracao no metodo: " + i);
tudoNoob/poseidon
src/test/java/com/poseidon/controller/ContaControllerTest.java
// Path: src/main/java/com/poseidon/builder/AuthoritiesBuilder.java // public class AuthoritiesBuilder { // // private Authorities myObject; // // // public AuthoritiesBuilder(){ // myObject= new Authorities(); // } // // public Authorities build(){ // return myObject; // } // // public AuthoritiesBuilder withUsername(String username){ // myObject.setUsername(username); // return this; // } // // public AuthoritiesBuilder withAuthority(String authority){ // myObject.setAuthority(authority); // return this; // } // // // // } // // Path: src/main/java/com/poseidon/builder/ContaViewBuilder.java // public class ContaViewBuilder { // // private ContaView myObject; // // public ContaViewBuilder(){ // myObject= new ContaView(); // } // // public ContaView build(){ // return myObject; // } // // public ContaViewBuilder convertUsersThroughContaView(Users users){ // myObject.setPassword(users.getPassword()); // myObject.setUsername(users.getUsername()); // return this; // } // // public ContaViewBuilder withAuthority(String authority){ // myObject.setRole(authority); // return this; // } // // // // // // } // // Path: src/main/java/com/poseidon/builder/UsersBuilder.java // public class UsersBuilder { // // private Users myObject; // private List<Users> usersList; // // public UsersBuilder(){ // myObject= new Users(); // usersList= new ArrayList<>(); // } // // public Users build(){ // return myObject; // } // // public List<Users> buildAsList(){ // return usersList; // } // // public UsersBuilder add(){ // usersList.add(myObject); // myObject= new Users(); // return this; // } // // public UsersBuilder withPassword(String password){ // myObject.setPassword(password); // return this; // } // // public UsersBuilder withUsername(String username){ // myObject.setUsername(username); // return this; // } // // } // // Path: src/main/java/com/poseidon/dao/AuthoritiesRepository.java // public interface AuthoritiesRepository extends CrudRepository<Authorities, Long>{ // // public Authorities findByUsername(String username); // // } // // Path: src/main/java/com/poseidon/dao/UserRepository.java // public interface UserRepository extends CrudRepository<Users, Long> { // // public Users findByUsername(String username); // // } // // Path: src/test/java/com/poseidon/utils/RedirectAttributesMock.java // public class RedirectAttributesMock implements RedirectAttributes { // // // private HashMap<String,Object> map=new HashMap<>(); // // @Override // public RedirectAttributes addAttribute(String s, Object o) { // return null; // } // // @Override // public RedirectAttributes addAttribute(Object o) { // return null; // } // // @Override // public RedirectAttributes addAllAttributes(Collection<?> collection) { // return null; // } // // @Override // public Model addAllAttributes(Map<String, ?> map) { // return null; // } // // @Override // public RedirectAttributes mergeAttributes(Map<String, ?> map) { // return null; // } // // @Override // public boolean containsAttribute(String s) { // return false; // } // // @Override // public Map<String, Object> asMap() { // return null; // } // // @Override // public RedirectAttributes addFlashAttribute(String s, Object o) { // map.put(s,o); // return this; // } // // @Override // public RedirectAttributes addFlashAttribute(Object o) { // return null; // } // // @Override // public Map<String, ?> getFlashAttributes() { // return map; // } // }
import com.poseidon.builder.AuthoritiesBuilder; import com.poseidon.builder.ContaViewBuilder; import com.poseidon.builder.UsersBuilder; import com.poseidon.dao.AuthoritiesRepository; import com.poseidon.dao.UserRepository; import com.poseidon.model.*; import com.poseidon.utils.RedirectAttributesMock; import org.springframework.web.servlet.ModelAndView; import org.testng.Assert; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; import java.util.List; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import static org.testng.Assert.assertTrue; import static org.testng.AssertJUnit.assertEquals; import static org.testng.AssertJUnit.assertNotNull; import static org.testng.AssertJUnit.assertNull;
package com.poseidon.controller; @Test public class ContaControllerTest { private ContaController contaController;
// Path: src/main/java/com/poseidon/builder/AuthoritiesBuilder.java // public class AuthoritiesBuilder { // // private Authorities myObject; // // // public AuthoritiesBuilder(){ // myObject= new Authorities(); // } // // public Authorities build(){ // return myObject; // } // // public AuthoritiesBuilder withUsername(String username){ // myObject.setUsername(username); // return this; // } // // public AuthoritiesBuilder withAuthority(String authority){ // myObject.setAuthority(authority); // return this; // } // // // // } // // Path: src/main/java/com/poseidon/builder/ContaViewBuilder.java // public class ContaViewBuilder { // // private ContaView myObject; // // public ContaViewBuilder(){ // myObject= new ContaView(); // } // // public ContaView build(){ // return myObject; // } // // public ContaViewBuilder convertUsersThroughContaView(Users users){ // myObject.setPassword(users.getPassword()); // myObject.setUsername(users.getUsername()); // return this; // } // // public ContaViewBuilder withAuthority(String authority){ // myObject.setRole(authority); // return this; // } // // // // // // } // // Path: src/main/java/com/poseidon/builder/UsersBuilder.java // public class UsersBuilder { // // private Users myObject; // private List<Users> usersList; // // public UsersBuilder(){ // myObject= new Users(); // usersList= new ArrayList<>(); // } // // public Users build(){ // return myObject; // } // // public List<Users> buildAsList(){ // return usersList; // } // // public UsersBuilder add(){ // usersList.add(myObject); // myObject= new Users(); // return this; // } // // public UsersBuilder withPassword(String password){ // myObject.setPassword(password); // return this; // } // // public UsersBuilder withUsername(String username){ // myObject.setUsername(username); // return this; // } // // } // // Path: src/main/java/com/poseidon/dao/AuthoritiesRepository.java // public interface AuthoritiesRepository extends CrudRepository<Authorities, Long>{ // // public Authorities findByUsername(String username); // // } // // Path: src/main/java/com/poseidon/dao/UserRepository.java // public interface UserRepository extends CrudRepository<Users, Long> { // // public Users findByUsername(String username); // // } // // Path: src/test/java/com/poseidon/utils/RedirectAttributesMock.java // public class RedirectAttributesMock implements RedirectAttributes { // // // private HashMap<String,Object> map=new HashMap<>(); // // @Override // public RedirectAttributes addAttribute(String s, Object o) { // return null; // } // // @Override // public RedirectAttributes addAttribute(Object o) { // return null; // } // // @Override // public RedirectAttributes addAllAttributes(Collection<?> collection) { // return null; // } // // @Override // public Model addAllAttributes(Map<String, ?> map) { // return null; // } // // @Override // public RedirectAttributes mergeAttributes(Map<String, ?> map) { // return null; // } // // @Override // public boolean containsAttribute(String s) { // return false; // } // // @Override // public Map<String, Object> asMap() { // return null; // } // // @Override // public RedirectAttributes addFlashAttribute(String s, Object o) { // map.put(s,o); // return this; // } // // @Override // public RedirectAttributes addFlashAttribute(Object o) { // return null; // } // // @Override // public Map<String, ?> getFlashAttributes() { // return map; // } // } // Path: src/test/java/com/poseidon/controller/ContaControllerTest.java import com.poseidon.builder.AuthoritiesBuilder; import com.poseidon.builder.ContaViewBuilder; import com.poseidon.builder.UsersBuilder; import com.poseidon.dao.AuthoritiesRepository; import com.poseidon.dao.UserRepository; import com.poseidon.model.*; import com.poseidon.utils.RedirectAttributesMock; import org.springframework.web.servlet.ModelAndView; import org.testng.Assert; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; import java.util.List; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import static org.testng.Assert.assertTrue; import static org.testng.AssertJUnit.assertEquals; import static org.testng.AssertJUnit.assertNotNull; import static org.testng.AssertJUnit.assertNull; package com.poseidon.controller; @Test public class ContaControllerTest { private ContaController contaController;
private UserRepository userRepository;
tudoNoob/poseidon
src/test/java/com/poseidon/controller/ContaControllerTest.java
// Path: src/main/java/com/poseidon/builder/AuthoritiesBuilder.java // public class AuthoritiesBuilder { // // private Authorities myObject; // // // public AuthoritiesBuilder(){ // myObject= new Authorities(); // } // // public Authorities build(){ // return myObject; // } // // public AuthoritiesBuilder withUsername(String username){ // myObject.setUsername(username); // return this; // } // // public AuthoritiesBuilder withAuthority(String authority){ // myObject.setAuthority(authority); // return this; // } // // // // } // // Path: src/main/java/com/poseidon/builder/ContaViewBuilder.java // public class ContaViewBuilder { // // private ContaView myObject; // // public ContaViewBuilder(){ // myObject= new ContaView(); // } // // public ContaView build(){ // return myObject; // } // // public ContaViewBuilder convertUsersThroughContaView(Users users){ // myObject.setPassword(users.getPassword()); // myObject.setUsername(users.getUsername()); // return this; // } // // public ContaViewBuilder withAuthority(String authority){ // myObject.setRole(authority); // return this; // } // // // // // // } // // Path: src/main/java/com/poseidon/builder/UsersBuilder.java // public class UsersBuilder { // // private Users myObject; // private List<Users> usersList; // // public UsersBuilder(){ // myObject= new Users(); // usersList= new ArrayList<>(); // } // // public Users build(){ // return myObject; // } // // public List<Users> buildAsList(){ // return usersList; // } // // public UsersBuilder add(){ // usersList.add(myObject); // myObject= new Users(); // return this; // } // // public UsersBuilder withPassword(String password){ // myObject.setPassword(password); // return this; // } // // public UsersBuilder withUsername(String username){ // myObject.setUsername(username); // return this; // } // // } // // Path: src/main/java/com/poseidon/dao/AuthoritiesRepository.java // public interface AuthoritiesRepository extends CrudRepository<Authorities, Long>{ // // public Authorities findByUsername(String username); // // } // // Path: src/main/java/com/poseidon/dao/UserRepository.java // public interface UserRepository extends CrudRepository<Users, Long> { // // public Users findByUsername(String username); // // } // // Path: src/test/java/com/poseidon/utils/RedirectAttributesMock.java // public class RedirectAttributesMock implements RedirectAttributes { // // // private HashMap<String,Object> map=new HashMap<>(); // // @Override // public RedirectAttributes addAttribute(String s, Object o) { // return null; // } // // @Override // public RedirectAttributes addAttribute(Object o) { // return null; // } // // @Override // public RedirectAttributes addAllAttributes(Collection<?> collection) { // return null; // } // // @Override // public Model addAllAttributes(Map<String, ?> map) { // return null; // } // // @Override // public RedirectAttributes mergeAttributes(Map<String, ?> map) { // return null; // } // // @Override // public boolean containsAttribute(String s) { // return false; // } // // @Override // public Map<String, Object> asMap() { // return null; // } // // @Override // public RedirectAttributes addFlashAttribute(String s, Object o) { // map.put(s,o); // return this; // } // // @Override // public RedirectAttributes addFlashAttribute(Object o) { // return null; // } // // @Override // public Map<String, ?> getFlashAttributes() { // return map; // } // }
import com.poseidon.builder.AuthoritiesBuilder; import com.poseidon.builder.ContaViewBuilder; import com.poseidon.builder.UsersBuilder; import com.poseidon.dao.AuthoritiesRepository; import com.poseidon.dao.UserRepository; import com.poseidon.model.*; import com.poseidon.utils.RedirectAttributesMock; import org.springframework.web.servlet.ModelAndView; import org.testng.Assert; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; import java.util.List; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import static org.testng.Assert.assertTrue; import static org.testng.AssertJUnit.assertEquals; import static org.testng.AssertJUnit.assertNotNull; import static org.testng.AssertJUnit.assertNull;
package com.poseidon.controller; @Test public class ContaControllerTest { private ContaController contaController; private UserRepository userRepository;
// Path: src/main/java/com/poseidon/builder/AuthoritiesBuilder.java // public class AuthoritiesBuilder { // // private Authorities myObject; // // // public AuthoritiesBuilder(){ // myObject= new Authorities(); // } // // public Authorities build(){ // return myObject; // } // // public AuthoritiesBuilder withUsername(String username){ // myObject.setUsername(username); // return this; // } // // public AuthoritiesBuilder withAuthority(String authority){ // myObject.setAuthority(authority); // return this; // } // // // // } // // Path: src/main/java/com/poseidon/builder/ContaViewBuilder.java // public class ContaViewBuilder { // // private ContaView myObject; // // public ContaViewBuilder(){ // myObject= new ContaView(); // } // // public ContaView build(){ // return myObject; // } // // public ContaViewBuilder convertUsersThroughContaView(Users users){ // myObject.setPassword(users.getPassword()); // myObject.setUsername(users.getUsername()); // return this; // } // // public ContaViewBuilder withAuthority(String authority){ // myObject.setRole(authority); // return this; // } // // // // // // } // // Path: src/main/java/com/poseidon/builder/UsersBuilder.java // public class UsersBuilder { // // private Users myObject; // private List<Users> usersList; // // public UsersBuilder(){ // myObject= new Users(); // usersList= new ArrayList<>(); // } // // public Users build(){ // return myObject; // } // // public List<Users> buildAsList(){ // return usersList; // } // // public UsersBuilder add(){ // usersList.add(myObject); // myObject= new Users(); // return this; // } // // public UsersBuilder withPassword(String password){ // myObject.setPassword(password); // return this; // } // // public UsersBuilder withUsername(String username){ // myObject.setUsername(username); // return this; // } // // } // // Path: src/main/java/com/poseidon/dao/AuthoritiesRepository.java // public interface AuthoritiesRepository extends CrudRepository<Authorities, Long>{ // // public Authorities findByUsername(String username); // // } // // Path: src/main/java/com/poseidon/dao/UserRepository.java // public interface UserRepository extends CrudRepository<Users, Long> { // // public Users findByUsername(String username); // // } // // Path: src/test/java/com/poseidon/utils/RedirectAttributesMock.java // public class RedirectAttributesMock implements RedirectAttributes { // // // private HashMap<String,Object> map=new HashMap<>(); // // @Override // public RedirectAttributes addAttribute(String s, Object o) { // return null; // } // // @Override // public RedirectAttributes addAttribute(Object o) { // return null; // } // // @Override // public RedirectAttributes addAllAttributes(Collection<?> collection) { // return null; // } // // @Override // public Model addAllAttributes(Map<String, ?> map) { // return null; // } // // @Override // public RedirectAttributes mergeAttributes(Map<String, ?> map) { // return null; // } // // @Override // public boolean containsAttribute(String s) { // return false; // } // // @Override // public Map<String, Object> asMap() { // return null; // } // // @Override // public RedirectAttributes addFlashAttribute(String s, Object o) { // map.put(s,o); // return this; // } // // @Override // public RedirectAttributes addFlashAttribute(Object o) { // return null; // } // // @Override // public Map<String, ?> getFlashAttributes() { // return map; // } // } // Path: src/test/java/com/poseidon/controller/ContaControllerTest.java import com.poseidon.builder.AuthoritiesBuilder; import com.poseidon.builder.ContaViewBuilder; import com.poseidon.builder.UsersBuilder; import com.poseidon.dao.AuthoritiesRepository; import com.poseidon.dao.UserRepository; import com.poseidon.model.*; import com.poseidon.utils.RedirectAttributesMock; import org.springframework.web.servlet.ModelAndView; import org.testng.Assert; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; import java.util.List; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import static org.testng.Assert.assertTrue; import static org.testng.AssertJUnit.assertEquals; import static org.testng.AssertJUnit.assertNotNull; import static org.testng.AssertJUnit.assertNull; package com.poseidon.controller; @Test public class ContaControllerTest { private ContaController contaController; private UserRepository userRepository;
private AuthoritiesRepository authoritiesRepository;
tudoNoob/poseidon
src/test/java/com/poseidon/controller/ContaControllerTest.java
// Path: src/main/java/com/poseidon/builder/AuthoritiesBuilder.java // public class AuthoritiesBuilder { // // private Authorities myObject; // // // public AuthoritiesBuilder(){ // myObject= new Authorities(); // } // // public Authorities build(){ // return myObject; // } // // public AuthoritiesBuilder withUsername(String username){ // myObject.setUsername(username); // return this; // } // // public AuthoritiesBuilder withAuthority(String authority){ // myObject.setAuthority(authority); // return this; // } // // // // } // // Path: src/main/java/com/poseidon/builder/ContaViewBuilder.java // public class ContaViewBuilder { // // private ContaView myObject; // // public ContaViewBuilder(){ // myObject= new ContaView(); // } // // public ContaView build(){ // return myObject; // } // // public ContaViewBuilder convertUsersThroughContaView(Users users){ // myObject.setPassword(users.getPassword()); // myObject.setUsername(users.getUsername()); // return this; // } // // public ContaViewBuilder withAuthority(String authority){ // myObject.setRole(authority); // return this; // } // // // // // // } // // Path: src/main/java/com/poseidon/builder/UsersBuilder.java // public class UsersBuilder { // // private Users myObject; // private List<Users> usersList; // // public UsersBuilder(){ // myObject= new Users(); // usersList= new ArrayList<>(); // } // // public Users build(){ // return myObject; // } // // public List<Users> buildAsList(){ // return usersList; // } // // public UsersBuilder add(){ // usersList.add(myObject); // myObject= new Users(); // return this; // } // // public UsersBuilder withPassword(String password){ // myObject.setPassword(password); // return this; // } // // public UsersBuilder withUsername(String username){ // myObject.setUsername(username); // return this; // } // // } // // Path: src/main/java/com/poseidon/dao/AuthoritiesRepository.java // public interface AuthoritiesRepository extends CrudRepository<Authorities, Long>{ // // public Authorities findByUsername(String username); // // } // // Path: src/main/java/com/poseidon/dao/UserRepository.java // public interface UserRepository extends CrudRepository<Users, Long> { // // public Users findByUsername(String username); // // } // // Path: src/test/java/com/poseidon/utils/RedirectAttributesMock.java // public class RedirectAttributesMock implements RedirectAttributes { // // // private HashMap<String,Object> map=new HashMap<>(); // // @Override // public RedirectAttributes addAttribute(String s, Object o) { // return null; // } // // @Override // public RedirectAttributes addAttribute(Object o) { // return null; // } // // @Override // public RedirectAttributes addAllAttributes(Collection<?> collection) { // return null; // } // // @Override // public Model addAllAttributes(Map<String, ?> map) { // return null; // } // // @Override // public RedirectAttributes mergeAttributes(Map<String, ?> map) { // return null; // } // // @Override // public boolean containsAttribute(String s) { // return false; // } // // @Override // public Map<String, Object> asMap() { // return null; // } // // @Override // public RedirectAttributes addFlashAttribute(String s, Object o) { // map.put(s,o); // return this; // } // // @Override // public RedirectAttributes addFlashAttribute(Object o) { // return null; // } // // @Override // public Map<String, ?> getFlashAttributes() { // return map; // } // }
import com.poseidon.builder.AuthoritiesBuilder; import com.poseidon.builder.ContaViewBuilder; import com.poseidon.builder.UsersBuilder; import com.poseidon.dao.AuthoritiesRepository; import com.poseidon.dao.UserRepository; import com.poseidon.model.*; import com.poseidon.utils.RedirectAttributesMock; import org.springframework.web.servlet.ModelAndView; import org.testng.Assert; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; import java.util.List; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import static org.testng.Assert.assertTrue; import static org.testng.AssertJUnit.assertEquals; import static org.testng.AssertJUnit.assertNotNull; import static org.testng.AssertJUnit.assertNull;
package com.poseidon.controller; @Test public class ContaControllerTest { private ContaController contaController; private UserRepository userRepository; private AuthoritiesRepository authoritiesRepository; @BeforeTest public void setUp(){ contaController= new ContaController(); userRepository= mock(UserRepository.class); authoritiesRepository= mock(AuthoritiesRepository.class); contaController.userRepository=userRepository; contaController.authoritiesRepository=authoritiesRepository; } @Test public void shouldBuildContaPageForCadastro(){
// Path: src/main/java/com/poseidon/builder/AuthoritiesBuilder.java // public class AuthoritiesBuilder { // // private Authorities myObject; // // // public AuthoritiesBuilder(){ // myObject= new Authorities(); // } // // public Authorities build(){ // return myObject; // } // // public AuthoritiesBuilder withUsername(String username){ // myObject.setUsername(username); // return this; // } // // public AuthoritiesBuilder withAuthority(String authority){ // myObject.setAuthority(authority); // return this; // } // // // // } // // Path: src/main/java/com/poseidon/builder/ContaViewBuilder.java // public class ContaViewBuilder { // // private ContaView myObject; // // public ContaViewBuilder(){ // myObject= new ContaView(); // } // // public ContaView build(){ // return myObject; // } // // public ContaViewBuilder convertUsersThroughContaView(Users users){ // myObject.setPassword(users.getPassword()); // myObject.setUsername(users.getUsername()); // return this; // } // // public ContaViewBuilder withAuthority(String authority){ // myObject.setRole(authority); // return this; // } // // // // // // } // // Path: src/main/java/com/poseidon/builder/UsersBuilder.java // public class UsersBuilder { // // private Users myObject; // private List<Users> usersList; // // public UsersBuilder(){ // myObject= new Users(); // usersList= new ArrayList<>(); // } // // public Users build(){ // return myObject; // } // // public List<Users> buildAsList(){ // return usersList; // } // // public UsersBuilder add(){ // usersList.add(myObject); // myObject= new Users(); // return this; // } // // public UsersBuilder withPassword(String password){ // myObject.setPassword(password); // return this; // } // // public UsersBuilder withUsername(String username){ // myObject.setUsername(username); // return this; // } // // } // // Path: src/main/java/com/poseidon/dao/AuthoritiesRepository.java // public interface AuthoritiesRepository extends CrudRepository<Authorities, Long>{ // // public Authorities findByUsername(String username); // // } // // Path: src/main/java/com/poseidon/dao/UserRepository.java // public interface UserRepository extends CrudRepository<Users, Long> { // // public Users findByUsername(String username); // // } // // Path: src/test/java/com/poseidon/utils/RedirectAttributesMock.java // public class RedirectAttributesMock implements RedirectAttributes { // // // private HashMap<String,Object> map=new HashMap<>(); // // @Override // public RedirectAttributes addAttribute(String s, Object o) { // return null; // } // // @Override // public RedirectAttributes addAttribute(Object o) { // return null; // } // // @Override // public RedirectAttributes addAllAttributes(Collection<?> collection) { // return null; // } // // @Override // public Model addAllAttributes(Map<String, ?> map) { // return null; // } // // @Override // public RedirectAttributes mergeAttributes(Map<String, ?> map) { // return null; // } // // @Override // public boolean containsAttribute(String s) { // return false; // } // // @Override // public Map<String, Object> asMap() { // return null; // } // // @Override // public RedirectAttributes addFlashAttribute(String s, Object o) { // map.put(s,o); // return this; // } // // @Override // public RedirectAttributes addFlashAttribute(Object o) { // return null; // } // // @Override // public Map<String, ?> getFlashAttributes() { // return map; // } // } // Path: src/test/java/com/poseidon/controller/ContaControllerTest.java import com.poseidon.builder.AuthoritiesBuilder; import com.poseidon.builder.ContaViewBuilder; import com.poseidon.builder.UsersBuilder; import com.poseidon.dao.AuthoritiesRepository; import com.poseidon.dao.UserRepository; import com.poseidon.model.*; import com.poseidon.utils.RedirectAttributesMock; import org.springframework.web.servlet.ModelAndView; import org.testng.Assert; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; import java.util.List; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import static org.testng.Assert.assertTrue; import static org.testng.AssertJUnit.assertEquals; import static org.testng.AssertJUnit.assertNotNull; import static org.testng.AssertJUnit.assertNull; package com.poseidon.controller; @Test public class ContaControllerTest { private ContaController contaController; private UserRepository userRepository; private AuthoritiesRepository authoritiesRepository; @BeforeTest public void setUp(){ contaController= new ContaController(); userRepository= mock(UserRepository.class); authoritiesRepository= mock(AuthoritiesRepository.class); contaController.userRepository=userRepository; contaController.authoritiesRepository=authoritiesRepository; } @Test public void shouldBuildContaPageForCadastro(){
List<Users> usersList = new UsersBuilder()
tudoNoob/poseidon
src/test/java/com/poseidon/controller/ContaControllerTest.java
// Path: src/main/java/com/poseidon/builder/AuthoritiesBuilder.java // public class AuthoritiesBuilder { // // private Authorities myObject; // // // public AuthoritiesBuilder(){ // myObject= new Authorities(); // } // // public Authorities build(){ // return myObject; // } // // public AuthoritiesBuilder withUsername(String username){ // myObject.setUsername(username); // return this; // } // // public AuthoritiesBuilder withAuthority(String authority){ // myObject.setAuthority(authority); // return this; // } // // // // } // // Path: src/main/java/com/poseidon/builder/ContaViewBuilder.java // public class ContaViewBuilder { // // private ContaView myObject; // // public ContaViewBuilder(){ // myObject= new ContaView(); // } // // public ContaView build(){ // return myObject; // } // // public ContaViewBuilder convertUsersThroughContaView(Users users){ // myObject.setPassword(users.getPassword()); // myObject.setUsername(users.getUsername()); // return this; // } // // public ContaViewBuilder withAuthority(String authority){ // myObject.setRole(authority); // return this; // } // // // // // // } // // Path: src/main/java/com/poseidon/builder/UsersBuilder.java // public class UsersBuilder { // // private Users myObject; // private List<Users> usersList; // // public UsersBuilder(){ // myObject= new Users(); // usersList= new ArrayList<>(); // } // // public Users build(){ // return myObject; // } // // public List<Users> buildAsList(){ // return usersList; // } // // public UsersBuilder add(){ // usersList.add(myObject); // myObject= new Users(); // return this; // } // // public UsersBuilder withPassword(String password){ // myObject.setPassword(password); // return this; // } // // public UsersBuilder withUsername(String username){ // myObject.setUsername(username); // return this; // } // // } // // Path: src/main/java/com/poseidon/dao/AuthoritiesRepository.java // public interface AuthoritiesRepository extends CrudRepository<Authorities, Long>{ // // public Authorities findByUsername(String username); // // } // // Path: src/main/java/com/poseidon/dao/UserRepository.java // public interface UserRepository extends CrudRepository<Users, Long> { // // public Users findByUsername(String username); // // } // // Path: src/test/java/com/poseidon/utils/RedirectAttributesMock.java // public class RedirectAttributesMock implements RedirectAttributes { // // // private HashMap<String,Object> map=new HashMap<>(); // // @Override // public RedirectAttributes addAttribute(String s, Object o) { // return null; // } // // @Override // public RedirectAttributes addAttribute(Object o) { // return null; // } // // @Override // public RedirectAttributes addAllAttributes(Collection<?> collection) { // return null; // } // // @Override // public Model addAllAttributes(Map<String, ?> map) { // return null; // } // // @Override // public RedirectAttributes mergeAttributes(Map<String, ?> map) { // return null; // } // // @Override // public boolean containsAttribute(String s) { // return false; // } // // @Override // public Map<String, Object> asMap() { // return null; // } // // @Override // public RedirectAttributes addFlashAttribute(String s, Object o) { // map.put(s,o); // return this; // } // // @Override // public RedirectAttributes addFlashAttribute(Object o) { // return null; // } // // @Override // public Map<String, ?> getFlashAttributes() { // return map; // } // }
import com.poseidon.builder.AuthoritiesBuilder; import com.poseidon.builder.ContaViewBuilder; import com.poseidon.builder.UsersBuilder; import com.poseidon.dao.AuthoritiesRepository; import com.poseidon.dao.UserRepository; import com.poseidon.model.*; import com.poseidon.utils.RedirectAttributesMock; import org.springframework.web.servlet.ModelAndView; import org.testng.Assert; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; import java.util.List; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import static org.testng.Assert.assertTrue; import static org.testng.AssertJUnit.assertEquals; import static org.testng.AssertJUnit.assertNotNull; import static org.testng.AssertJUnit.assertNull;
package com.poseidon.controller; @Test public class ContaControllerTest { private ContaController contaController; private UserRepository userRepository; private AuthoritiesRepository authoritiesRepository; @BeforeTest public void setUp(){ contaController= new ContaController(); userRepository= mock(UserRepository.class); authoritiesRepository= mock(AuthoritiesRepository.class); contaController.userRepository=userRepository; contaController.authoritiesRepository=authoritiesRepository; } @Test public void shouldBuildContaPageForCadastro(){ List<Users> usersList = new UsersBuilder() .withPassword("pass").withUsername("Kakaroto").add() .withPassword("Bulma").withUsername("Vegetta").add() .buildAsList(); when(userRepository.findAll()).thenReturn(usersList);
// Path: src/main/java/com/poseidon/builder/AuthoritiesBuilder.java // public class AuthoritiesBuilder { // // private Authorities myObject; // // // public AuthoritiesBuilder(){ // myObject= new Authorities(); // } // // public Authorities build(){ // return myObject; // } // // public AuthoritiesBuilder withUsername(String username){ // myObject.setUsername(username); // return this; // } // // public AuthoritiesBuilder withAuthority(String authority){ // myObject.setAuthority(authority); // return this; // } // // // // } // // Path: src/main/java/com/poseidon/builder/ContaViewBuilder.java // public class ContaViewBuilder { // // private ContaView myObject; // // public ContaViewBuilder(){ // myObject= new ContaView(); // } // // public ContaView build(){ // return myObject; // } // // public ContaViewBuilder convertUsersThroughContaView(Users users){ // myObject.setPassword(users.getPassword()); // myObject.setUsername(users.getUsername()); // return this; // } // // public ContaViewBuilder withAuthority(String authority){ // myObject.setRole(authority); // return this; // } // // // // // // } // // Path: src/main/java/com/poseidon/builder/UsersBuilder.java // public class UsersBuilder { // // private Users myObject; // private List<Users> usersList; // // public UsersBuilder(){ // myObject= new Users(); // usersList= new ArrayList<>(); // } // // public Users build(){ // return myObject; // } // // public List<Users> buildAsList(){ // return usersList; // } // // public UsersBuilder add(){ // usersList.add(myObject); // myObject= new Users(); // return this; // } // // public UsersBuilder withPassword(String password){ // myObject.setPassword(password); // return this; // } // // public UsersBuilder withUsername(String username){ // myObject.setUsername(username); // return this; // } // // } // // Path: src/main/java/com/poseidon/dao/AuthoritiesRepository.java // public interface AuthoritiesRepository extends CrudRepository<Authorities, Long>{ // // public Authorities findByUsername(String username); // // } // // Path: src/main/java/com/poseidon/dao/UserRepository.java // public interface UserRepository extends CrudRepository<Users, Long> { // // public Users findByUsername(String username); // // } // // Path: src/test/java/com/poseidon/utils/RedirectAttributesMock.java // public class RedirectAttributesMock implements RedirectAttributes { // // // private HashMap<String,Object> map=new HashMap<>(); // // @Override // public RedirectAttributes addAttribute(String s, Object o) { // return null; // } // // @Override // public RedirectAttributes addAttribute(Object o) { // return null; // } // // @Override // public RedirectAttributes addAllAttributes(Collection<?> collection) { // return null; // } // // @Override // public Model addAllAttributes(Map<String, ?> map) { // return null; // } // // @Override // public RedirectAttributes mergeAttributes(Map<String, ?> map) { // return null; // } // // @Override // public boolean containsAttribute(String s) { // return false; // } // // @Override // public Map<String, Object> asMap() { // return null; // } // // @Override // public RedirectAttributes addFlashAttribute(String s, Object o) { // map.put(s,o); // return this; // } // // @Override // public RedirectAttributes addFlashAttribute(Object o) { // return null; // } // // @Override // public Map<String, ?> getFlashAttributes() { // return map; // } // } // Path: src/test/java/com/poseidon/controller/ContaControllerTest.java import com.poseidon.builder.AuthoritiesBuilder; import com.poseidon.builder.ContaViewBuilder; import com.poseidon.builder.UsersBuilder; import com.poseidon.dao.AuthoritiesRepository; import com.poseidon.dao.UserRepository; import com.poseidon.model.*; import com.poseidon.utils.RedirectAttributesMock; import org.springframework.web.servlet.ModelAndView; import org.testng.Assert; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; import java.util.List; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import static org.testng.Assert.assertTrue; import static org.testng.AssertJUnit.assertEquals; import static org.testng.AssertJUnit.assertNotNull; import static org.testng.AssertJUnit.assertNull; package com.poseidon.controller; @Test public class ContaControllerTest { private ContaController contaController; private UserRepository userRepository; private AuthoritiesRepository authoritiesRepository; @BeforeTest public void setUp(){ contaController= new ContaController(); userRepository= mock(UserRepository.class); authoritiesRepository= mock(AuthoritiesRepository.class); contaController.userRepository=userRepository; contaController.authoritiesRepository=authoritiesRepository; } @Test public void shouldBuildContaPageForCadastro(){ List<Users> usersList = new UsersBuilder() .withPassword("pass").withUsername("Kakaroto").add() .withPassword("Bulma").withUsername("Vegetta").add() .buildAsList(); when(userRepository.findAll()).thenReturn(usersList);
Authorities authoritiesKakaroto = new AuthoritiesBuilder().withAuthority("ROLE_ADMIN").withUsername("kakaroto").build();
tudoNoob/poseidon
src/test/java/com/poseidon/controller/ContaControllerTest.java
// Path: src/main/java/com/poseidon/builder/AuthoritiesBuilder.java // public class AuthoritiesBuilder { // // private Authorities myObject; // // // public AuthoritiesBuilder(){ // myObject= new Authorities(); // } // // public Authorities build(){ // return myObject; // } // // public AuthoritiesBuilder withUsername(String username){ // myObject.setUsername(username); // return this; // } // // public AuthoritiesBuilder withAuthority(String authority){ // myObject.setAuthority(authority); // return this; // } // // // // } // // Path: src/main/java/com/poseidon/builder/ContaViewBuilder.java // public class ContaViewBuilder { // // private ContaView myObject; // // public ContaViewBuilder(){ // myObject= new ContaView(); // } // // public ContaView build(){ // return myObject; // } // // public ContaViewBuilder convertUsersThroughContaView(Users users){ // myObject.setPassword(users.getPassword()); // myObject.setUsername(users.getUsername()); // return this; // } // // public ContaViewBuilder withAuthority(String authority){ // myObject.setRole(authority); // return this; // } // // // // // // } // // Path: src/main/java/com/poseidon/builder/UsersBuilder.java // public class UsersBuilder { // // private Users myObject; // private List<Users> usersList; // // public UsersBuilder(){ // myObject= new Users(); // usersList= new ArrayList<>(); // } // // public Users build(){ // return myObject; // } // // public List<Users> buildAsList(){ // return usersList; // } // // public UsersBuilder add(){ // usersList.add(myObject); // myObject= new Users(); // return this; // } // // public UsersBuilder withPassword(String password){ // myObject.setPassword(password); // return this; // } // // public UsersBuilder withUsername(String username){ // myObject.setUsername(username); // return this; // } // // } // // Path: src/main/java/com/poseidon/dao/AuthoritiesRepository.java // public interface AuthoritiesRepository extends CrudRepository<Authorities, Long>{ // // public Authorities findByUsername(String username); // // } // // Path: src/main/java/com/poseidon/dao/UserRepository.java // public interface UserRepository extends CrudRepository<Users, Long> { // // public Users findByUsername(String username); // // } // // Path: src/test/java/com/poseidon/utils/RedirectAttributesMock.java // public class RedirectAttributesMock implements RedirectAttributes { // // // private HashMap<String,Object> map=new HashMap<>(); // // @Override // public RedirectAttributes addAttribute(String s, Object o) { // return null; // } // // @Override // public RedirectAttributes addAttribute(Object o) { // return null; // } // // @Override // public RedirectAttributes addAllAttributes(Collection<?> collection) { // return null; // } // // @Override // public Model addAllAttributes(Map<String, ?> map) { // return null; // } // // @Override // public RedirectAttributes mergeAttributes(Map<String, ?> map) { // return null; // } // // @Override // public boolean containsAttribute(String s) { // return false; // } // // @Override // public Map<String, Object> asMap() { // return null; // } // // @Override // public RedirectAttributes addFlashAttribute(String s, Object o) { // map.put(s,o); // return this; // } // // @Override // public RedirectAttributes addFlashAttribute(Object o) { // return null; // } // // @Override // public Map<String, ?> getFlashAttributes() { // return map; // } // }
import com.poseidon.builder.AuthoritiesBuilder; import com.poseidon.builder.ContaViewBuilder; import com.poseidon.builder.UsersBuilder; import com.poseidon.dao.AuthoritiesRepository; import com.poseidon.dao.UserRepository; import com.poseidon.model.*; import com.poseidon.utils.RedirectAttributesMock; import org.springframework.web.servlet.ModelAndView; import org.testng.Assert; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; import java.util.List; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import static org.testng.Assert.assertTrue; import static org.testng.AssertJUnit.assertEquals; import static org.testng.AssertJUnit.assertNotNull; import static org.testng.AssertJUnit.assertNull;
assertNotNull(response.getModelMap().get("crudview")); } @Test public void shouldBuildContaPageForExibir(){ List<Users> usersList = new UsersBuilder() .withPassword("pass").withUsername("Kakaroto").add() .withPassword("Bulma").withUsername("Vegetta").add() .buildAsList(); when(userRepository.findAll()).thenReturn(usersList); Authorities authoritiesKakaroto = new AuthoritiesBuilder().withAuthority("ROLE_ADMIN").withUsername("kakaroto").build(); when(authoritiesRepository.findByUsername(usersList.get(1).getUsername())).thenReturn(authoritiesKakaroto); Authorities authoritiesVeggeta = new AuthoritiesBuilder().withAuthority("ROLE_USER").withUsername("Veggeta").build(); when(authoritiesRepository.findByUsername(usersList.get(0).getUsername())).thenReturn(authoritiesVeggeta); ModelAndView response = contaController.returnpage(new ModelAndView(), new CRUDView()); assertNotNull(response); assertNotNull(response.getModelMap().get("contas")); assertNotNull(response.getModelMap().get("crudview")); } @Test public void shouldCadatrarConta(){ Users users = new UsersBuilder().withPassword("Bulma").withUsername("Veggeta").build();
// Path: src/main/java/com/poseidon/builder/AuthoritiesBuilder.java // public class AuthoritiesBuilder { // // private Authorities myObject; // // // public AuthoritiesBuilder(){ // myObject= new Authorities(); // } // // public Authorities build(){ // return myObject; // } // // public AuthoritiesBuilder withUsername(String username){ // myObject.setUsername(username); // return this; // } // // public AuthoritiesBuilder withAuthority(String authority){ // myObject.setAuthority(authority); // return this; // } // // // // } // // Path: src/main/java/com/poseidon/builder/ContaViewBuilder.java // public class ContaViewBuilder { // // private ContaView myObject; // // public ContaViewBuilder(){ // myObject= new ContaView(); // } // // public ContaView build(){ // return myObject; // } // // public ContaViewBuilder convertUsersThroughContaView(Users users){ // myObject.setPassword(users.getPassword()); // myObject.setUsername(users.getUsername()); // return this; // } // // public ContaViewBuilder withAuthority(String authority){ // myObject.setRole(authority); // return this; // } // // // // // // } // // Path: src/main/java/com/poseidon/builder/UsersBuilder.java // public class UsersBuilder { // // private Users myObject; // private List<Users> usersList; // // public UsersBuilder(){ // myObject= new Users(); // usersList= new ArrayList<>(); // } // // public Users build(){ // return myObject; // } // // public List<Users> buildAsList(){ // return usersList; // } // // public UsersBuilder add(){ // usersList.add(myObject); // myObject= new Users(); // return this; // } // // public UsersBuilder withPassword(String password){ // myObject.setPassword(password); // return this; // } // // public UsersBuilder withUsername(String username){ // myObject.setUsername(username); // return this; // } // // } // // Path: src/main/java/com/poseidon/dao/AuthoritiesRepository.java // public interface AuthoritiesRepository extends CrudRepository<Authorities, Long>{ // // public Authorities findByUsername(String username); // // } // // Path: src/main/java/com/poseidon/dao/UserRepository.java // public interface UserRepository extends CrudRepository<Users, Long> { // // public Users findByUsername(String username); // // } // // Path: src/test/java/com/poseidon/utils/RedirectAttributesMock.java // public class RedirectAttributesMock implements RedirectAttributes { // // // private HashMap<String,Object> map=new HashMap<>(); // // @Override // public RedirectAttributes addAttribute(String s, Object o) { // return null; // } // // @Override // public RedirectAttributes addAttribute(Object o) { // return null; // } // // @Override // public RedirectAttributes addAllAttributes(Collection<?> collection) { // return null; // } // // @Override // public Model addAllAttributes(Map<String, ?> map) { // return null; // } // // @Override // public RedirectAttributes mergeAttributes(Map<String, ?> map) { // return null; // } // // @Override // public boolean containsAttribute(String s) { // return false; // } // // @Override // public Map<String, Object> asMap() { // return null; // } // // @Override // public RedirectAttributes addFlashAttribute(String s, Object o) { // map.put(s,o); // return this; // } // // @Override // public RedirectAttributes addFlashAttribute(Object o) { // return null; // } // // @Override // public Map<String, ?> getFlashAttributes() { // return map; // } // } // Path: src/test/java/com/poseidon/controller/ContaControllerTest.java import com.poseidon.builder.AuthoritiesBuilder; import com.poseidon.builder.ContaViewBuilder; import com.poseidon.builder.UsersBuilder; import com.poseidon.dao.AuthoritiesRepository; import com.poseidon.dao.UserRepository; import com.poseidon.model.*; import com.poseidon.utils.RedirectAttributesMock; import org.springframework.web.servlet.ModelAndView; import org.testng.Assert; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; import java.util.List; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import static org.testng.Assert.assertTrue; import static org.testng.AssertJUnit.assertEquals; import static org.testng.AssertJUnit.assertNotNull; import static org.testng.AssertJUnit.assertNull; assertNotNull(response.getModelMap().get("crudview")); } @Test public void shouldBuildContaPageForExibir(){ List<Users> usersList = new UsersBuilder() .withPassword("pass").withUsername("Kakaroto").add() .withPassword("Bulma").withUsername("Vegetta").add() .buildAsList(); when(userRepository.findAll()).thenReturn(usersList); Authorities authoritiesKakaroto = new AuthoritiesBuilder().withAuthority("ROLE_ADMIN").withUsername("kakaroto").build(); when(authoritiesRepository.findByUsername(usersList.get(1).getUsername())).thenReturn(authoritiesKakaroto); Authorities authoritiesVeggeta = new AuthoritiesBuilder().withAuthority("ROLE_USER").withUsername("Veggeta").build(); when(authoritiesRepository.findByUsername(usersList.get(0).getUsername())).thenReturn(authoritiesVeggeta); ModelAndView response = contaController.returnpage(new ModelAndView(), new CRUDView()); assertNotNull(response); assertNotNull(response.getModelMap().get("contas")); assertNotNull(response.getModelMap().get("crudview")); } @Test public void shouldCadatrarConta(){ Users users = new UsersBuilder().withPassword("Bulma").withUsername("Veggeta").build();
ContaView conta = new ContaViewBuilder().convertUsersThroughContaView(users).withAuthority("ROLE_ADMIN").build();
tudoNoob/poseidon
src/test/java/com/poseidon/controller/ContaControllerTest.java
// Path: src/main/java/com/poseidon/builder/AuthoritiesBuilder.java // public class AuthoritiesBuilder { // // private Authorities myObject; // // // public AuthoritiesBuilder(){ // myObject= new Authorities(); // } // // public Authorities build(){ // return myObject; // } // // public AuthoritiesBuilder withUsername(String username){ // myObject.setUsername(username); // return this; // } // // public AuthoritiesBuilder withAuthority(String authority){ // myObject.setAuthority(authority); // return this; // } // // // // } // // Path: src/main/java/com/poseidon/builder/ContaViewBuilder.java // public class ContaViewBuilder { // // private ContaView myObject; // // public ContaViewBuilder(){ // myObject= new ContaView(); // } // // public ContaView build(){ // return myObject; // } // // public ContaViewBuilder convertUsersThroughContaView(Users users){ // myObject.setPassword(users.getPassword()); // myObject.setUsername(users.getUsername()); // return this; // } // // public ContaViewBuilder withAuthority(String authority){ // myObject.setRole(authority); // return this; // } // // // // // // } // // Path: src/main/java/com/poseidon/builder/UsersBuilder.java // public class UsersBuilder { // // private Users myObject; // private List<Users> usersList; // // public UsersBuilder(){ // myObject= new Users(); // usersList= new ArrayList<>(); // } // // public Users build(){ // return myObject; // } // // public List<Users> buildAsList(){ // return usersList; // } // // public UsersBuilder add(){ // usersList.add(myObject); // myObject= new Users(); // return this; // } // // public UsersBuilder withPassword(String password){ // myObject.setPassword(password); // return this; // } // // public UsersBuilder withUsername(String username){ // myObject.setUsername(username); // return this; // } // // } // // Path: src/main/java/com/poseidon/dao/AuthoritiesRepository.java // public interface AuthoritiesRepository extends CrudRepository<Authorities, Long>{ // // public Authorities findByUsername(String username); // // } // // Path: src/main/java/com/poseidon/dao/UserRepository.java // public interface UserRepository extends CrudRepository<Users, Long> { // // public Users findByUsername(String username); // // } // // Path: src/test/java/com/poseidon/utils/RedirectAttributesMock.java // public class RedirectAttributesMock implements RedirectAttributes { // // // private HashMap<String,Object> map=new HashMap<>(); // // @Override // public RedirectAttributes addAttribute(String s, Object o) { // return null; // } // // @Override // public RedirectAttributes addAttribute(Object o) { // return null; // } // // @Override // public RedirectAttributes addAllAttributes(Collection<?> collection) { // return null; // } // // @Override // public Model addAllAttributes(Map<String, ?> map) { // return null; // } // // @Override // public RedirectAttributes mergeAttributes(Map<String, ?> map) { // return null; // } // // @Override // public boolean containsAttribute(String s) { // return false; // } // // @Override // public Map<String, Object> asMap() { // return null; // } // // @Override // public RedirectAttributes addFlashAttribute(String s, Object o) { // map.put(s,o); // return this; // } // // @Override // public RedirectAttributes addFlashAttribute(Object o) { // return null; // } // // @Override // public Map<String, ?> getFlashAttributes() { // return map; // } // }
import com.poseidon.builder.AuthoritiesBuilder; import com.poseidon.builder.ContaViewBuilder; import com.poseidon.builder.UsersBuilder; import com.poseidon.dao.AuthoritiesRepository; import com.poseidon.dao.UserRepository; import com.poseidon.model.*; import com.poseidon.utils.RedirectAttributesMock; import org.springframework.web.servlet.ModelAndView; import org.testng.Assert; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; import java.util.List; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import static org.testng.Assert.assertTrue; import static org.testng.AssertJUnit.assertEquals; import static org.testng.AssertJUnit.assertNotNull; import static org.testng.AssertJUnit.assertNull;
@Test public void shouldBuildContaPageForExibir(){ List<Users> usersList = new UsersBuilder() .withPassword("pass").withUsername("Kakaroto").add() .withPassword("Bulma").withUsername("Vegetta").add() .buildAsList(); when(userRepository.findAll()).thenReturn(usersList); Authorities authoritiesKakaroto = new AuthoritiesBuilder().withAuthority("ROLE_ADMIN").withUsername("kakaroto").build(); when(authoritiesRepository.findByUsername(usersList.get(1).getUsername())).thenReturn(authoritiesKakaroto); Authorities authoritiesVeggeta = new AuthoritiesBuilder().withAuthority("ROLE_USER").withUsername("Veggeta").build(); when(authoritiesRepository.findByUsername(usersList.get(0).getUsername())).thenReturn(authoritiesVeggeta); ModelAndView response = contaController.returnpage(new ModelAndView(), new CRUDView()); assertNotNull(response); assertNotNull(response.getModelMap().get("contas")); assertNotNull(response.getModelMap().get("crudview")); } @Test public void shouldCadatrarConta(){ Users users = new UsersBuilder().withPassword("Bulma").withUsername("Veggeta").build(); ContaView conta = new ContaViewBuilder().convertUsersThroughContaView(users).withAuthority("ROLE_ADMIN").build();
// Path: src/main/java/com/poseidon/builder/AuthoritiesBuilder.java // public class AuthoritiesBuilder { // // private Authorities myObject; // // // public AuthoritiesBuilder(){ // myObject= new Authorities(); // } // // public Authorities build(){ // return myObject; // } // // public AuthoritiesBuilder withUsername(String username){ // myObject.setUsername(username); // return this; // } // // public AuthoritiesBuilder withAuthority(String authority){ // myObject.setAuthority(authority); // return this; // } // // // // } // // Path: src/main/java/com/poseidon/builder/ContaViewBuilder.java // public class ContaViewBuilder { // // private ContaView myObject; // // public ContaViewBuilder(){ // myObject= new ContaView(); // } // // public ContaView build(){ // return myObject; // } // // public ContaViewBuilder convertUsersThroughContaView(Users users){ // myObject.setPassword(users.getPassword()); // myObject.setUsername(users.getUsername()); // return this; // } // // public ContaViewBuilder withAuthority(String authority){ // myObject.setRole(authority); // return this; // } // // // // // // } // // Path: src/main/java/com/poseidon/builder/UsersBuilder.java // public class UsersBuilder { // // private Users myObject; // private List<Users> usersList; // // public UsersBuilder(){ // myObject= new Users(); // usersList= new ArrayList<>(); // } // // public Users build(){ // return myObject; // } // // public List<Users> buildAsList(){ // return usersList; // } // // public UsersBuilder add(){ // usersList.add(myObject); // myObject= new Users(); // return this; // } // // public UsersBuilder withPassword(String password){ // myObject.setPassword(password); // return this; // } // // public UsersBuilder withUsername(String username){ // myObject.setUsername(username); // return this; // } // // } // // Path: src/main/java/com/poseidon/dao/AuthoritiesRepository.java // public interface AuthoritiesRepository extends CrudRepository<Authorities, Long>{ // // public Authorities findByUsername(String username); // // } // // Path: src/main/java/com/poseidon/dao/UserRepository.java // public interface UserRepository extends CrudRepository<Users, Long> { // // public Users findByUsername(String username); // // } // // Path: src/test/java/com/poseidon/utils/RedirectAttributesMock.java // public class RedirectAttributesMock implements RedirectAttributes { // // // private HashMap<String,Object> map=new HashMap<>(); // // @Override // public RedirectAttributes addAttribute(String s, Object o) { // return null; // } // // @Override // public RedirectAttributes addAttribute(Object o) { // return null; // } // // @Override // public RedirectAttributes addAllAttributes(Collection<?> collection) { // return null; // } // // @Override // public Model addAllAttributes(Map<String, ?> map) { // return null; // } // // @Override // public RedirectAttributes mergeAttributes(Map<String, ?> map) { // return null; // } // // @Override // public boolean containsAttribute(String s) { // return false; // } // // @Override // public Map<String, Object> asMap() { // return null; // } // // @Override // public RedirectAttributes addFlashAttribute(String s, Object o) { // map.put(s,o); // return this; // } // // @Override // public RedirectAttributes addFlashAttribute(Object o) { // return null; // } // // @Override // public Map<String, ?> getFlashAttributes() { // return map; // } // } // Path: src/test/java/com/poseidon/controller/ContaControllerTest.java import com.poseidon.builder.AuthoritiesBuilder; import com.poseidon.builder.ContaViewBuilder; import com.poseidon.builder.UsersBuilder; import com.poseidon.dao.AuthoritiesRepository; import com.poseidon.dao.UserRepository; import com.poseidon.model.*; import com.poseidon.utils.RedirectAttributesMock; import org.springframework.web.servlet.ModelAndView; import org.testng.Assert; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; import java.util.List; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import static org.testng.Assert.assertTrue; import static org.testng.AssertJUnit.assertEquals; import static org.testng.AssertJUnit.assertNotNull; import static org.testng.AssertJUnit.assertNull; @Test public void shouldBuildContaPageForExibir(){ List<Users> usersList = new UsersBuilder() .withPassword("pass").withUsername("Kakaroto").add() .withPassword("Bulma").withUsername("Vegetta").add() .buildAsList(); when(userRepository.findAll()).thenReturn(usersList); Authorities authoritiesKakaroto = new AuthoritiesBuilder().withAuthority("ROLE_ADMIN").withUsername("kakaroto").build(); when(authoritiesRepository.findByUsername(usersList.get(1).getUsername())).thenReturn(authoritiesKakaroto); Authorities authoritiesVeggeta = new AuthoritiesBuilder().withAuthority("ROLE_USER").withUsername("Veggeta").build(); when(authoritiesRepository.findByUsername(usersList.get(0).getUsername())).thenReturn(authoritiesVeggeta); ModelAndView response = contaController.returnpage(new ModelAndView(), new CRUDView()); assertNotNull(response); assertNotNull(response.getModelMap().get("contas")); assertNotNull(response.getModelMap().get("crudview")); } @Test public void shouldCadatrarConta(){ Users users = new UsersBuilder().withPassword("Bulma").withUsername("Veggeta").build(); ContaView conta = new ContaViewBuilder().convertUsersThroughContaView(users).withAuthority("ROLE_ADMIN").build();
ModelAndView response = contaController.cadastrarConta(conta, "ROLE_ADMIN", new ModelAndView(), new RedirectAttributesMock());
tudoNoob/poseidon
src/test/java/com/poseidon/controller/QuiropraxistaControllerTest.java
// Path: src/main/java/com/poseidon/builder/QuiropraxistaBuilder.java // public class QuiropraxistaBuilder { // // private Quiropraxista myObject; // // private List<Quiropraxista> quiropraxistaList; // // public QuiropraxistaBuilder(){ // myObject= new Quiropraxista(); // quiropraxistaList= new ArrayList<>(); // } // // public Quiropraxista build(){ // return myObject; // } // // public QuiropraxistaBuilder add(){ // quiropraxistaList.add(myObject); // myObject= new Quiropraxista(); // return this; // } // // public List<Quiropraxista> buildAsList(){ // return quiropraxistaList; // } // // public QuiropraxistaBuilder withName(String nome){ // myObject.setNome(nome); // return this; // } // // public QuiropraxistaBuilder withId(Integer id){ // myObject.setId(id); // return this; // } // // // // // } // // Path: src/main/java/com/poseidon/dao/QuiropraxistaDao.java // @Repository // @Qualifier() // public interface QuiropraxistaDao extends CrudRepository<Quiropraxista, Integer>{ // public Quiropraxista findByNome(String nome); // public Quiropraxista findById(Integer id); // } // // Path: src/main/java/com/poseidon/model/CRUDView.java // public class CRUDView { // // private String isSave; // // private String isUpdate; // // private String isSearch; // // private String isDelete; // // private String isToShowAll; // // public String getIsToShowAll() { // return isToShowAll; // } // // public void setIsToShowAll(String isToShowAll) { // this.isToShowAll = isToShowAll; // } // // public String getIsSave() { // return isSave; // } // // public void setIsSave(String isSave) { // this.isSave = isSave; // } // // public String getIsUpdate() { // return isUpdate; // } // // public void setIsUpdate(String isUpdate) { // this.isUpdate = isUpdate; // } // // public String getIsSearch() { // return isSearch; // } // // public void setIsSearch(String isSearch) { // this.isSearch = isSearch; // } // // public String getIsDelete() { // return isDelete; // } // // public void setIsDelete(String isDelete) { // this.isDelete = isDelete; // } // } // // Path: src/main/java/com/poseidon/model/Quiropraxista.java // @Entity // public class Quiropraxista { // // @Id // @GeneratedValue(strategy = GenerationType.AUTO) // private Integer id; // private String nome; // // public Quiropraxista() { // // } // // public Quiropraxista(Integer id, String nome) { // this.id = id; // this.nome = nome; // } // // public void setNome(String nome) { // this.nome = nome; // } // // public String getNome() { // return nome; // } // // public void setId(Integer id) { // this.id = id; // } // // public Integer getId() { // return id; // } // // @Override // public String toString() { // return "Quiropraxista [id=" + id + ", nome=" + nome + "]"; // } // } // // Path: src/test/java/com/poseidon/utils/RedirectAttributesMock.java // public class RedirectAttributesMock implements RedirectAttributes { // // // private HashMap<String,Object> map=new HashMap<>(); // // @Override // public RedirectAttributes addAttribute(String s, Object o) { // return null; // } // // @Override // public RedirectAttributes addAttribute(Object o) { // return null; // } // // @Override // public RedirectAttributes addAllAttributes(Collection<?> collection) { // return null; // } // // @Override // public Model addAllAttributes(Map<String, ?> map) { // return null; // } // // @Override // public RedirectAttributes mergeAttributes(Map<String, ?> map) { // return null; // } // // @Override // public boolean containsAttribute(String s) { // return false; // } // // @Override // public Map<String, Object> asMap() { // return null; // } // // @Override // public RedirectAttributes addFlashAttribute(String s, Object o) { // map.put(s,o); // return this; // } // // @Override // public RedirectAttributes addFlashAttribute(Object o) { // return null; // } // // @Override // public Map<String, ?> getFlashAttributes() { // return map; // } // }
import com.poseidon.builder.QuiropraxistaBuilder; import com.poseidon.dao.QuiropraxistaDao; import com.poseidon.model.CRUDView; import com.poseidon.model.Quiropraxista; import com.poseidon.utils.RedirectAttributesMock; import org.springframework.web.servlet.ModelAndView; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; import java.util.List; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import static org.testng.AssertJUnit.assertEquals; import static org.testng.AssertJUnit.assertNotNull; import static org.testng.AssertJUnit.assertNull;
package com.poseidon.controller; @Test() public class QuiropraxistaControllerTest { private QuiropraxistaController quiropraxistaController;
// Path: src/main/java/com/poseidon/builder/QuiropraxistaBuilder.java // public class QuiropraxistaBuilder { // // private Quiropraxista myObject; // // private List<Quiropraxista> quiropraxistaList; // // public QuiropraxistaBuilder(){ // myObject= new Quiropraxista(); // quiropraxistaList= new ArrayList<>(); // } // // public Quiropraxista build(){ // return myObject; // } // // public QuiropraxistaBuilder add(){ // quiropraxistaList.add(myObject); // myObject= new Quiropraxista(); // return this; // } // // public List<Quiropraxista> buildAsList(){ // return quiropraxistaList; // } // // public QuiropraxistaBuilder withName(String nome){ // myObject.setNome(nome); // return this; // } // // public QuiropraxistaBuilder withId(Integer id){ // myObject.setId(id); // return this; // } // // // // // } // // Path: src/main/java/com/poseidon/dao/QuiropraxistaDao.java // @Repository // @Qualifier() // public interface QuiropraxistaDao extends CrudRepository<Quiropraxista, Integer>{ // public Quiropraxista findByNome(String nome); // public Quiropraxista findById(Integer id); // } // // Path: src/main/java/com/poseidon/model/CRUDView.java // public class CRUDView { // // private String isSave; // // private String isUpdate; // // private String isSearch; // // private String isDelete; // // private String isToShowAll; // // public String getIsToShowAll() { // return isToShowAll; // } // // public void setIsToShowAll(String isToShowAll) { // this.isToShowAll = isToShowAll; // } // // public String getIsSave() { // return isSave; // } // // public void setIsSave(String isSave) { // this.isSave = isSave; // } // // public String getIsUpdate() { // return isUpdate; // } // // public void setIsUpdate(String isUpdate) { // this.isUpdate = isUpdate; // } // // public String getIsSearch() { // return isSearch; // } // // public void setIsSearch(String isSearch) { // this.isSearch = isSearch; // } // // public String getIsDelete() { // return isDelete; // } // // public void setIsDelete(String isDelete) { // this.isDelete = isDelete; // } // } // // Path: src/main/java/com/poseidon/model/Quiropraxista.java // @Entity // public class Quiropraxista { // // @Id // @GeneratedValue(strategy = GenerationType.AUTO) // private Integer id; // private String nome; // // public Quiropraxista() { // // } // // public Quiropraxista(Integer id, String nome) { // this.id = id; // this.nome = nome; // } // // public void setNome(String nome) { // this.nome = nome; // } // // public String getNome() { // return nome; // } // // public void setId(Integer id) { // this.id = id; // } // // public Integer getId() { // return id; // } // // @Override // public String toString() { // return "Quiropraxista [id=" + id + ", nome=" + nome + "]"; // } // } // // Path: src/test/java/com/poseidon/utils/RedirectAttributesMock.java // public class RedirectAttributesMock implements RedirectAttributes { // // // private HashMap<String,Object> map=new HashMap<>(); // // @Override // public RedirectAttributes addAttribute(String s, Object o) { // return null; // } // // @Override // public RedirectAttributes addAttribute(Object o) { // return null; // } // // @Override // public RedirectAttributes addAllAttributes(Collection<?> collection) { // return null; // } // // @Override // public Model addAllAttributes(Map<String, ?> map) { // return null; // } // // @Override // public RedirectAttributes mergeAttributes(Map<String, ?> map) { // return null; // } // // @Override // public boolean containsAttribute(String s) { // return false; // } // // @Override // public Map<String, Object> asMap() { // return null; // } // // @Override // public RedirectAttributes addFlashAttribute(String s, Object o) { // map.put(s,o); // return this; // } // // @Override // public RedirectAttributes addFlashAttribute(Object o) { // return null; // } // // @Override // public Map<String, ?> getFlashAttributes() { // return map; // } // } // Path: src/test/java/com/poseidon/controller/QuiropraxistaControllerTest.java import com.poseidon.builder.QuiropraxistaBuilder; import com.poseidon.dao.QuiropraxistaDao; import com.poseidon.model.CRUDView; import com.poseidon.model.Quiropraxista; import com.poseidon.utils.RedirectAttributesMock; import org.springframework.web.servlet.ModelAndView; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; import java.util.List; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import static org.testng.AssertJUnit.assertEquals; import static org.testng.AssertJUnit.assertNotNull; import static org.testng.AssertJUnit.assertNull; package com.poseidon.controller; @Test() public class QuiropraxistaControllerTest { private QuiropraxistaController quiropraxistaController;
private QuiropraxistaDao quiropraxistaDao;
tudoNoob/poseidon
src/main/java/com/poseidon/model/Paciente.java
// Path: src/main/java/com/poseidon/utils/PoseidonUtils.java // public class PoseidonUtils { // // private static final Logger LOGGER = LoggerFactory.getLogger(PoseidonUtils.class); // // public static java.sql.Date convertToDate(String toDate) { // // SimpleDateFormat format = new SimpleDateFormat("dd/mm/yyyy"); // Date parsed; // java.sql.Date sql = null; // try { // parsed = format.parse(toDate); // sql = new java.sql.Date(parsed.getTime()); // } catch (ParseException e) { // LOGGER.error("Falha na conversão da data.", e); // throw new DateSqlParseException(e); // } // // return sql; // } // // public static String convertDateToString(Date date) { // SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd/MM/yyyy"); // String stringFormatted = simpleDateFormat.format(date); // // return stringFormatted; // } // // public static java.sql.Date convertToDate(Date toDate) { // java.sql.Date sql = null; // sql = new java.sql.Date(toDate.getTime()); // // return sql; // } // // public static java.sql.Time convertToTime(Date toDate) { // java.sql.Time sql = null; // sql = new java.sql.Time(toDate.getTime()); // // return sql; // } // // public static String convertStringtoJSON(Object input) { // ObjectMapper mapper = new ObjectMapper(); // String result = ""; // try { // result = mapper.writeValueAsString(input); // } catch (JsonProcessingException e) { // LOGGER.info("Falha na conversão", e); // } // return result; // } // // public static String CADASTRO_SUCCESS = "Cadastro efetuado com sucesso."; // // public static String CADASTRO_ERROR = "Erro ao efetuar o cadastro."; // }
import com.poseidon.annotation.ValidateString; import com.poseidon.utils.PoseidonUtils; import javax.persistence.*; import java.util.Date;
public void setTelefone(String telefone) { this.telefone = telefone; } public String getCelular() { return celular; } public void setCelular(String celular) { this.celular = celular; } public String getEndereco() { return endereco; } public void setEndereco(String endereco) { this.endereco = endereco; } public String getCep() { return cep; } public void setCep(String cep) { this.cep = cep; } public Date getDataNasci_For_SQL() {
// Path: src/main/java/com/poseidon/utils/PoseidonUtils.java // public class PoseidonUtils { // // private static final Logger LOGGER = LoggerFactory.getLogger(PoseidonUtils.class); // // public static java.sql.Date convertToDate(String toDate) { // // SimpleDateFormat format = new SimpleDateFormat("dd/mm/yyyy"); // Date parsed; // java.sql.Date sql = null; // try { // parsed = format.parse(toDate); // sql = new java.sql.Date(parsed.getTime()); // } catch (ParseException e) { // LOGGER.error("Falha na conversão da data.", e); // throw new DateSqlParseException(e); // } // // return sql; // } // // public static String convertDateToString(Date date) { // SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd/MM/yyyy"); // String stringFormatted = simpleDateFormat.format(date); // // return stringFormatted; // } // // public static java.sql.Date convertToDate(Date toDate) { // java.sql.Date sql = null; // sql = new java.sql.Date(toDate.getTime()); // // return sql; // } // // public static java.sql.Time convertToTime(Date toDate) { // java.sql.Time sql = null; // sql = new java.sql.Time(toDate.getTime()); // // return sql; // } // // public static String convertStringtoJSON(Object input) { // ObjectMapper mapper = new ObjectMapper(); // String result = ""; // try { // result = mapper.writeValueAsString(input); // } catch (JsonProcessingException e) { // LOGGER.info("Falha na conversão", e); // } // return result; // } // // public static String CADASTRO_SUCCESS = "Cadastro efetuado com sucesso."; // // public static String CADASTRO_ERROR = "Erro ao efetuar o cadastro."; // } // Path: src/main/java/com/poseidon/model/Paciente.java import com.poseidon.annotation.ValidateString; import com.poseidon.utils.PoseidonUtils; import javax.persistence.*; import java.util.Date; public void setTelefone(String telefone) { this.telefone = telefone; } public String getCelular() { return celular; } public void setCelular(String celular) { this.celular = celular; } public String getEndereco() { return endereco; } public void setEndereco(String endereco) { this.endereco = endereco; } public String getCep() { return cep; } public void setCep(String cep) { this.cep = cep; } public Date getDataNasci_For_SQL() {
return PoseidonUtils.convertToDate(data_de_nascimento);
tudoNoob/poseidon
src/main/java/com/poseidon/dao/ConsultaDao.java
// Path: src/main/java/com/poseidon/model/Consulta.java // @Entity // public class Consulta { // // @Id // @GeneratedValue(strategy = GenerationType.AUTO) // private Integer id; // // private Integer id_quiropraxista; // private Integer id_paciente; // private Double valor; // private Date horario_consulta; // private Date data_consulta; // // public Consulta() { // } // // public Integer getId() { // return id; // } // // public void setId(Integer id) { // this.id = id; // } // // public Integer getId_quiropraxista() { // return id_quiropraxista; // } // // public void setId_quiropraxista(Integer id_quiropraxista) { // this.id_quiropraxista = id_quiropraxista; // } // // public Integer getId_paciente() { // return id_paciente; // } // // public void setId_paciente(Integer id_paciente) { // this.id_paciente = id_paciente; // } // // public Double getValor() { // return valor; // } // // public void setValor(Double valor) { // this.valor = valor; // } // // public Date getHorario_consulta() { // return horario_consulta; // } // // public Date getData_consulta() { // return data_consulta; // } // // public void setHorario_consulta(Date horario_consulta) { // this.horario_consulta = horario_consulta; // } // // public void setData_consulta(Date data_consulta) { // this.data_consulta = data_consulta; // } // // public Date getDataConsulta_For_SQL() { // return PoseidonUtils.convertToDate(data_consulta); // } // // public Date getHorarioConsulta_For_SQL() { // return PoseidonUtils.convertToTime(horario_consulta); // } // // }
import com.poseidon.model.Consulta; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.data.repository.CrudRepository; import org.springframework.stereotype.Repository;
package com.poseidon.dao; @Repository @Qualifier()
// Path: src/main/java/com/poseidon/model/Consulta.java // @Entity // public class Consulta { // // @Id // @GeneratedValue(strategy = GenerationType.AUTO) // private Integer id; // // private Integer id_quiropraxista; // private Integer id_paciente; // private Double valor; // private Date horario_consulta; // private Date data_consulta; // // public Consulta() { // } // // public Integer getId() { // return id; // } // // public void setId(Integer id) { // this.id = id; // } // // public Integer getId_quiropraxista() { // return id_quiropraxista; // } // // public void setId_quiropraxista(Integer id_quiropraxista) { // this.id_quiropraxista = id_quiropraxista; // } // // public Integer getId_paciente() { // return id_paciente; // } // // public void setId_paciente(Integer id_paciente) { // this.id_paciente = id_paciente; // } // // public Double getValor() { // return valor; // } // // public void setValor(Double valor) { // this.valor = valor; // } // // public Date getHorario_consulta() { // return horario_consulta; // } // // public Date getData_consulta() { // return data_consulta; // } // // public void setHorario_consulta(Date horario_consulta) { // this.horario_consulta = horario_consulta; // } // // public void setData_consulta(Date data_consulta) { // this.data_consulta = data_consulta; // } // // public Date getDataConsulta_For_SQL() { // return PoseidonUtils.convertToDate(data_consulta); // } // // public Date getHorarioConsulta_For_SQL() { // return PoseidonUtils.convertToTime(horario_consulta); // } // // } // Path: src/main/java/com/poseidon/dao/ConsultaDao.java import com.poseidon.model.Consulta; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.data.repository.CrudRepository; import org.springframework.stereotype.Repository; package com.poseidon.dao; @Repository @Qualifier()
public interface ConsultaDao extends CrudRepository<Consulta, Integer> {
tudoNoob/poseidon
src/test/java/com/poseidon/utils/PoseidonUtilsTest.java
// Path: src/main/java/com/poseidon/model/ContaView.java // public class ContaView { // private String username; // // private String password; // // private String role; // // public ContaView() { // } // // public static ContaView buildContaView(Users user){ // ContaView view = new ContaView(); // view.setPassword(user.getPassword()); // view.setUsername(user.getUsername()); // return view; // } // // public String getUsername() { // return username; // } // // public void setUsername(String username) { // this.username = username; // } // // public String getPassword() { // return password; // } // // public void setPassword(String password) { // this.password = password; // } // // public String getRole() { // return role; // } // // public void setRole(String role) { // this.role = role; // } // // public ContaView comPassword(String password){ // setPassword(password); // return this; // } // // public ContaView comUsername(String username){ // setUsername(username); // return this; // } // // public ContaView comRoles(String role){ // setRole(role); // return this; // } // // @Override // public String toString() { // return "UserView [username=" + username + ", password=" + password + ", role=" + role + "]"; // } // }
import static org.testng.AssertJUnit.assertEquals; import com.poseidon.model.ContaView; import org.testng.annotations.Test; import java.text.SimpleDateFormat;
package com.poseidon.utils; @Test public class PoseidonUtilsTest { @Test public void testConvertDateToString() throws Exception { java.util.Date date = new java.util.Date(); SimpleDateFormat dateformat = new SimpleDateFormat("dd/MM/yyyy"); date = dateformat.parse("10/10/2010"); assertEquals(PoseidonUtils.convertDateToString(date),"10/10/2010"); } @Test public void testConvertToDate1() throws Exception { } @Test public void testConvertToTime() throws Exception { } @Test public void testConvertStringtoJSON() throws Exception {
// Path: src/main/java/com/poseidon/model/ContaView.java // public class ContaView { // private String username; // // private String password; // // private String role; // // public ContaView() { // } // // public static ContaView buildContaView(Users user){ // ContaView view = new ContaView(); // view.setPassword(user.getPassword()); // view.setUsername(user.getUsername()); // return view; // } // // public String getUsername() { // return username; // } // // public void setUsername(String username) { // this.username = username; // } // // public String getPassword() { // return password; // } // // public void setPassword(String password) { // this.password = password; // } // // public String getRole() { // return role; // } // // public void setRole(String role) { // this.role = role; // } // // public ContaView comPassword(String password){ // setPassword(password); // return this; // } // // public ContaView comUsername(String username){ // setUsername(username); // return this; // } // // public ContaView comRoles(String role){ // setRole(role); // return this; // } // // @Override // public String toString() { // return "UserView [username=" + username + ", password=" + password + ", role=" + role + "]"; // } // } // Path: src/test/java/com/poseidon/utils/PoseidonUtilsTest.java import static org.testng.AssertJUnit.assertEquals; import com.poseidon.model.ContaView; import org.testng.annotations.Test; import java.text.SimpleDateFormat; package com.poseidon.utils; @Test public class PoseidonUtilsTest { @Test public void testConvertDateToString() throws Exception { java.util.Date date = new java.util.Date(); SimpleDateFormat dateformat = new SimpleDateFormat("dd/MM/yyyy"); date = dateformat.parse("10/10/2010"); assertEquals(PoseidonUtils.convertDateToString(date),"10/10/2010"); } @Test public void testConvertToDate1() throws Exception { } @Test public void testConvertToTime() throws Exception { } @Test public void testConvertStringtoJSON() throws Exception {
ContaView user= new ContaView().comUsername("user").comPassword("pass").comRoles("ADMIN");
tudoNoob/poseidon
src/main/java/com/poseidon/advices/ValidateAdvice.java
// Path: src/main/java/com/poseidon/exception/IllegalAnnotationPosition.java // public class IllegalAnnotationPosition extends PoseidonException { // // public IllegalAnnotationPosition(String message) { // super(message); // // } // } // // Path: src/main/java/com/poseidon/exception/ValidateStringException.java // public class ValidateStringException extends PoseidonException { // // public ValidateStringException(String message) { // super(message); // // } // }
import com.poseidon.annotation.ValidateArgs; import com.poseidon.annotation.ValidateString; import com.poseidon.exception.IllegalAnnotationPosition; import com.poseidon.exception.ValidateStringException; import org.aspectj.lang.JoinPoint; import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.annotation.Before; import org.aspectj.lang.reflect.MethodSignature; import org.springframework.stereotype.Component; import java.lang.reflect.Field; import java.lang.reflect.Method;
package com.poseidon.advices; /** * Esta classe ira processar as annotations ValidateArgs e ValidateString. * * @author ahrons * @see ValidateArgs,ValidateString */ @Component @Aspect public class ValidateAdvice { @Before("execution(* com.poseidon.*..*(..))") public void validateArgs(JoinPoint joinPoint) throws IllegalArgumentException, IllegalAccessException { final MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature(); Method method = methodSignature.getMethod(); if (!method.isAnnotationPresent(ValidateArgs.class)) { return; } Object[] args = joinPoint.getArgs(); for (int i = 0; i < args.length; i++) { Field[] fields = args[i].getClass().getDeclaredFields(); for (int j = 0; j < fields.length; j++) { validateString(args, i, fields, j); } } } private void validateString(Object[] args, int i, Field[] fields, int j) { if (fields[j].isAnnotationPresent(ValidateString.class)) { ValidateString validateString = fields[j].getAnnotation(ValidateString.class); if (!fields[j].getType().equals(String.class)) {
// Path: src/main/java/com/poseidon/exception/IllegalAnnotationPosition.java // public class IllegalAnnotationPosition extends PoseidonException { // // public IllegalAnnotationPosition(String message) { // super(message); // // } // } // // Path: src/main/java/com/poseidon/exception/ValidateStringException.java // public class ValidateStringException extends PoseidonException { // // public ValidateStringException(String message) { // super(message); // // } // } // Path: src/main/java/com/poseidon/advices/ValidateAdvice.java import com.poseidon.annotation.ValidateArgs; import com.poseidon.annotation.ValidateString; import com.poseidon.exception.IllegalAnnotationPosition; import com.poseidon.exception.ValidateStringException; import org.aspectj.lang.JoinPoint; import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.annotation.Before; import org.aspectj.lang.reflect.MethodSignature; import org.springframework.stereotype.Component; import java.lang.reflect.Field; import java.lang.reflect.Method; package com.poseidon.advices; /** * Esta classe ira processar as annotations ValidateArgs e ValidateString. * * @author ahrons * @see ValidateArgs,ValidateString */ @Component @Aspect public class ValidateAdvice { @Before("execution(* com.poseidon.*..*(..))") public void validateArgs(JoinPoint joinPoint) throws IllegalArgumentException, IllegalAccessException { final MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature(); Method method = methodSignature.getMethod(); if (!method.isAnnotationPresent(ValidateArgs.class)) { return; } Object[] args = joinPoint.getArgs(); for (int i = 0; i < args.length; i++) { Field[] fields = args[i].getClass().getDeclaredFields(); for (int j = 0; j < fields.length; j++) { validateString(args, i, fields, j); } } } private void validateString(Object[] args, int i, Field[] fields, int j) { if (fields[j].isAnnotationPresent(ValidateString.class)) { ValidateString validateString = fields[j].getAnnotation(ValidateString.class); if (!fields[j].getType().equals(String.class)) {
throw new IllegalAnnotationPosition(
tudoNoob/poseidon
src/main/java/com/poseidon/advices/ValidateAdvice.java
// Path: src/main/java/com/poseidon/exception/IllegalAnnotationPosition.java // public class IllegalAnnotationPosition extends PoseidonException { // // public IllegalAnnotationPosition(String message) { // super(message); // // } // } // // Path: src/main/java/com/poseidon/exception/ValidateStringException.java // public class ValidateStringException extends PoseidonException { // // public ValidateStringException(String message) { // super(message); // // } // }
import com.poseidon.annotation.ValidateArgs; import com.poseidon.annotation.ValidateString; import com.poseidon.exception.IllegalAnnotationPosition; import com.poseidon.exception.ValidateStringException; import org.aspectj.lang.JoinPoint; import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.annotation.Before; import org.aspectj.lang.reflect.MethodSignature; import org.springframework.stereotype.Component; import java.lang.reflect.Field; import java.lang.reflect.Method;
final MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature(); Method method = methodSignature.getMethod(); if (!method.isAnnotationPresent(ValidateArgs.class)) { return; } Object[] args = joinPoint.getArgs(); for (int i = 0; i < args.length; i++) { Field[] fields = args[i].getClass().getDeclaredFields(); for (int j = 0; j < fields.length; j++) { validateString(args, i, fields, j); } } } private void validateString(Object[] args, int i, Field[] fields, int j) { if (fields[j].isAnnotationPresent(ValidateString.class)) { ValidateString validateString = fields[j].getAnnotation(ValidateString.class); if (!fields[j].getType().equals(String.class)) { throw new IllegalAnnotationPosition( "a annotation ValidateString esta em um atributo que nao eh String."); } fields[j].setAccessible(true); Object object; try { object = fields[j].get(args[i]); if (object.toString().length() < validateString.minLength() || object.toString().length() > validateString.maxLength() ) {
// Path: src/main/java/com/poseidon/exception/IllegalAnnotationPosition.java // public class IllegalAnnotationPosition extends PoseidonException { // // public IllegalAnnotationPosition(String message) { // super(message); // // } // } // // Path: src/main/java/com/poseidon/exception/ValidateStringException.java // public class ValidateStringException extends PoseidonException { // // public ValidateStringException(String message) { // super(message); // // } // } // Path: src/main/java/com/poseidon/advices/ValidateAdvice.java import com.poseidon.annotation.ValidateArgs; import com.poseidon.annotation.ValidateString; import com.poseidon.exception.IllegalAnnotationPosition; import com.poseidon.exception.ValidateStringException; import org.aspectj.lang.JoinPoint; import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.annotation.Before; import org.aspectj.lang.reflect.MethodSignature; import org.springframework.stereotype.Component; import java.lang.reflect.Field; import java.lang.reflect.Method; final MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature(); Method method = methodSignature.getMethod(); if (!method.isAnnotationPresent(ValidateArgs.class)) { return; } Object[] args = joinPoint.getArgs(); for (int i = 0; i < args.length; i++) { Field[] fields = args[i].getClass().getDeclaredFields(); for (int j = 0; j < fields.length; j++) { validateString(args, i, fields, j); } } } private void validateString(Object[] args, int i, Field[] fields, int j) { if (fields[j].isAnnotationPresent(ValidateString.class)) { ValidateString validateString = fields[j].getAnnotation(ValidateString.class); if (!fields[j].getType().equals(String.class)) { throw new IllegalAnnotationPosition( "a annotation ValidateString esta em um atributo que nao eh String."); } fields[j].setAccessible(true); Object object; try { object = fields[j].get(args[i]); if (object.toString().length() < validateString.minLength() || object.toString().length() > validateString.maxLength() ) {
throw new ValidateStringException("Erro na validacao da string, do atributo:"+fields[j].getName());
uchicago/shibboleth-oidc
idp-oidc-impl/src/main/java/net/shibboleth/idp/oidc/flow/BuildAuthenticationContextAction.java
// Path: idp-oidc-impl/src/main/java/net/shibboleth/idp/oidc/config/OIDCConstants.java // public interface OIDCConstants { // // /** // * The constant ACR_VALUES. // */ // String ACR_VALUES = "acr_values"; // // /** // * The constant ID_TOKEN. // */ // String ID_TOKEN = "idtoken"; // // /** // * The constant AUTH_TIME. // */ // String AUTH_TIME = "auth_time"; // // /** // * The constant ACR. // */ // String ACR = "acr"; // // /** // * The constant AMR. // */ // String AMR = "amr"; // // /** // * The constant TOKEN. // */ // String TOKEN = "token"; // // /** // * The constant AT_HASH. // */ // String AT_HASH = "at_hash"; // // /** // * The constant KID. // */ // String KID = "kid"; // // /** // * The constant ROLE_USER. // */ // String ROLE_USER = "ROLE_USER"; // // /** // * The constant ROLE_CLIENT. // */ // String ROLE_CLIENT = "ROLE_CLIENT"; // }
import com.google.common.base.Strings; import net.shibboleth.idp.authn.AuthenticationFlowDescriptor; import net.shibboleth.idp.authn.context.AuthenticationContext; import net.shibboleth.idp.authn.context.RequestedPrincipalContext; import net.shibboleth.idp.oidc.config.OIDCConstants; import net.shibboleth.idp.profile.AbstractProfileAction; import net.shibboleth.idp.saml.authn.principal.AuthnContextClassRefPrincipal; import org.mitre.oauth2.service.ClientDetailsEntityService; import org.opensaml.profile.context.ProfileRequestContext; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.oauth2.provider.AuthorizationRequest; import org.springframework.webflow.execution.Event; import org.springframework.webflow.execution.RequestContext; import javax.annotation.Nonnull; import java.security.Principal; import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; import java.util.List; import java.util.Map;
private void addRequestedPrincipalIntoContext(final AuthenticationContext ac, final List<Principal> principals) { final RequestedPrincipalContext rpc = new RequestedPrincipalContext(); rpc.setOperator("exact"); rpc.setRequestedPrincipals(principals); ac.addSubcontext(rpc, true); } /** * Process acr values based on principal weight map. * * @param principals the principals */ private void processAcrValuesBasedOnPrincipalWeightMap(final List<Principal> principals) { if (principals.isEmpty()) { final AuthnContextClassRefPrincipal[] principalArray = this.authenticationPrincipalWeightMap.keySet() .toArray(new AuthnContextClassRefPrincipal[]{}); Arrays.sort(principalArray, new WeightedComparator()); principals.add(principalArray[principalArray.length - 1]); } } /** * Process requested acr values if any. * * @param authorizationRequest the authorization request * @param principals the principals */ private void processRequestedAcrValuesIfAny(final AuthorizationRequest authorizationRequest, final List<Principal> principals) {
// Path: idp-oidc-impl/src/main/java/net/shibboleth/idp/oidc/config/OIDCConstants.java // public interface OIDCConstants { // // /** // * The constant ACR_VALUES. // */ // String ACR_VALUES = "acr_values"; // // /** // * The constant ID_TOKEN. // */ // String ID_TOKEN = "idtoken"; // // /** // * The constant AUTH_TIME. // */ // String AUTH_TIME = "auth_time"; // // /** // * The constant ACR. // */ // String ACR = "acr"; // // /** // * The constant AMR. // */ // String AMR = "amr"; // // /** // * The constant TOKEN. // */ // String TOKEN = "token"; // // /** // * The constant AT_HASH. // */ // String AT_HASH = "at_hash"; // // /** // * The constant KID. // */ // String KID = "kid"; // // /** // * The constant ROLE_USER. // */ // String ROLE_USER = "ROLE_USER"; // // /** // * The constant ROLE_CLIENT. // */ // String ROLE_CLIENT = "ROLE_CLIENT"; // } // Path: idp-oidc-impl/src/main/java/net/shibboleth/idp/oidc/flow/BuildAuthenticationContextAction.java import com.google.common.base.Strings; import net.shibboleth.idp.authn.AuthenticationFlowDescriptor; import net.shibboleth.idp.authn.context.AuthenticationContext; import net.shibboleth.idp.authn.context.RequestedPrincipalContext; import net.shibboleth.idp.oidc.config.OIDCConstants; import net.shibboleth.idp.profile.AbstractProfileAction; import net.shibboleth.idp.saml.authn.principal.AuthnContextClassRefPrincipal; import org.mitre.oauth2.service.ClientDetailsEntityService; import org.opensaml.profile.context.ProfileRequestContext; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.oauth2.provider.AuthorizationRequest; import org.springframework.webflow.execution.Event; import org.springframework.webflow.execution.RequestContext; import javax.annotation.Nonnull; import java.security.Principal; import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; import java.util.List; import java.util.Map; private void addRequestedPrincipalIntoContext(final AuthenticationContext ac, final List<Principal> principals) { final RequestedPrincipalContext rpc = new RequestedPrincipalContext(); rpc.setOperator("exact"); rpc.setRequestedPrincipals(principals); ac.addSubcontext(rpc, true); } /** * Process acr values based on principal weight map. * * @param principals the principals */ private void processAcrValuesBasedOnPrincipalWeightMap(final List<Principal> principals) { if (principals.isEmpty()) { final AuthnContextClassRefPrincipal[] principalArray = this.authenticationPrincipalWeightMap.keySet() .toArray(new AuthnContextClassRefPrincipal[]{}); Arrays.sort(principalArray, new WeightedComparator()); principals.add(principalArray[principalArray.length - 1]); } } /** * Process requested acr values if any. * * @param authorizationRequest the authorization request * @param principals the principals */ private void processRequestedAcrValuesIfAny(final AuthorizationRequest authorizationRequest, final List<Principal> principals) {
if (authorizationRequest.getExtensions().containsKey(OIDCConstants.ACR_VALUES)) {
uchicago/shibboleth-oidc
idp-oidc-impl/src/main/java/net/shibboleth/idp/oidc/client/metadata/ClientEntityDescriptor.java
// Path: idp-oidc-impl/src/main/java/net/shibboleth/idp/oidc/OIDCException.java // public class OIDCException extends InvalidRequestException { // // // /** // * Instantiates a new Oidc exception. // */ // public OIDCException() { // super("Invalid request"); // } // // /** // * Instantiates a new Oidc exception. // * // * @param message the message // */ // public OIDCException(final String message) { // super(message); // } // // /** // * Instantiates a new Oidc exception. // * // * @param message the message // * @param cause the cause // */ // public OIDCException(final String message, final Throwable cause) { // super(message, cause); // } // // /** // * Instantiates a new Oidc exception. // * // * @param cause the cause // */ // public OIDCException(final Throwable cause) { // this(cause.getMessage(), cause); // } // }
import net.shibboleth.idp.oidc.OIDCException; import net.shibboleth.utilities.java.support.collection.LockableClassToInstanceMultiMap; import net.shibboleth.utilities.java.support.logic.Constraint; import org.joda.time.DateTime; import org.opensaml.core.xml.Namespace; import org.opensaml.core.xml.NamespaceManager; import org.opensaml.core.xml.XMLObject; import org.opensaml.core.xml.schema.XSBooleanValue; import org.opensaml.core.xml.util.AttributeMap; import org.opensaml.core.xml.util.IDIndex; import org.opensaml.saml.saml2.metadata.AdditionalMetadataLocation; import org.opensaml.saml.saml2.metadata.AffiliationDescriptor; import org.opensaml.saml.saml2.metadata.AttributeAuthorityDescriptor; import org.opensaml.saml.saml2.metadata.AuthnAuthorityDescriptor; import org.opensaml.saml.saml2.metadata.ContactPerson; import org.opensaml.saml.saml2.metadata.EntityDescriptor; import org.opensaml.saml.saml2.metadata.Extensions; import org.opensaml.saml.saml2.metadata.IDPSSODescriptor; import org.opensaml.saml.saml2.metadata.Organization; import org.opensaml.saml.saml2.metadata.PDPDescriptor; import org.opensaml.saml.saml2.metadata.RoleDescriptor; import org.opensaml.saml.saml2.metadata.SPSSODescriptor; import org.opensaml.xmlsec.signature.Signature; import org.w3c.dom.Element; import javax.annotation.Nonnull; import javax.annotation.Nullable; import javax.xml.namespace.QName; import java.util.Collections; import java.util.List; import java.util.Set;
/* * Licensed to the University Corporation for Advanced Internet Development, * Inc. (UCAID) under one or more contributor license agreements. See the * NOTICE file distributed with this work for additional information regarding * copyright ownership. The UCAID 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 net.shibboleth.idp.oidc.client.metadata; /** * Adapts OIDC protocol service metadata onto SAML metadata. */ public class ClientEntityDescriptor implements EntityDescriptor { /** * The Client id. */ private String clientId; /** * The Object metadata. */ @Nonnull private LockableClassToInstanceMultiMap<Object> objectMetadata; /** * Instantiates a new client entity descriptor. * * @param clientIdentifier the client identifier */ public ClientEntityDescriptor(@Nonnull final String clientIdentifier) { this.clientId = Constraint.isNotNull(clientIdentifier, "Client cannot be null"); this.objectMetadata = new LockableClassToInstanceMultiMap(true); } @Override public String getEntityID() { return clientId; } @Override public void setEntityID(final String id) {
// Path: idp-oidc-impl/src/main/java/net/shibboleth/idp/oidc/OIDCException.java // public class OIDCException extends InvalidRequestException { // // // /** // * Instantiates a new Oidc exception. // */ // public OIDCException() { // super("Invalid request"); // } // // /** // * Instantiates a new Oidc exception. // * // * @param message the message // */ // public OIDCException(final String message) { // super(message); // } // // /** // * Instantiates a new Oidc exception. // * // * @param message the message // * @param cause the cause // */ // public OIDCException(final String message, final Throwable cause) { // super(message, cause); // } // // /** // * Instantiates a new Oidc exception. // * // * @param cause the cause // */ // public OIDCException(final Throwable cause) { // this(cause.getMessage(), cause); // } // } // Path: idp-oidc-impl/src/main/java/net/shibboleth/idp/oidc/client/metadata/ClientEntityDescriptor.java import net.shibboleth.idp.oidc.OIDCException; import net.shibboleth.utilities.java.support.collection.LockableClassToInstanceMultiMap; import net.shibboleth.utilities.java.support.logic.Constraint; import org.joda.time.DateTime; import org.opensaml.core.xml.Namespace; import org.opensaml.core.xml.NamespaceManager; import org.opensaml.core.xml.XMLObject; import org.opensaml.core.xml.schema.XSBooleanValue; import org.opensaml.core.xml.util.AttributeMap; import org.opensaml.core.xml.util.IDIndex; import org.opensaml.saml.saml2.metadata.AdditionalMetadataLocation; import org.opensaml.saml.saml2.metadata.AffiliationDescriptor; import org.opensaml.saml.saml2.metadata.AttributeAuthorityDescriptor; import org.opensaml.saml.saml2.metadata.AuthnAuthorityDescriptor; import org.opensaml.saml.saml2.metadata.ContactPerson; import org.opensaml.saml.saml2.metadata.EntityDescriptor; import org.opensaml.saml.saml2.metadata.Extensions; import org.opensaml.saml.saml2.metadata.IDPSSODescriptor; import org.opensaml.saml.saml2.metadata.Organization; import org.opensaml.saml.saml2.metadata.PDPDescriptor; import org.opensaml.saml.saml2.metadata.RoleDescriptor; import org.opensaml.saml.saml2.metadata.SPSSODescriptor; import org.opensaml.xmlsec.signature.Signature; import org.w3c.dom.Element; import javax.annotation.Nonnull; import javax.annotation.Nullable; import javax.xml.namespace.QName; import java.util.Collections; import java.util.List; import java.util.Set; /* * Licensed to the University Corporation for Advanced Internet Development, * Inc. (UCAID) under one or more contributor license agreements. See the * NOTICE file distributed with this work for additional information regarding * copyright ownership. The UCAID 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 net.shibboleth.idp.oidc.client.metadata; /** * Adapts OIDC protocol service metadata onto SAML metadata. */ public class ClientEntityDescriptor implements EntityDescriptor { /** * The Client id. */ private String clientId; /** * The Object metadata. */ @Nonnull private LockableClassToInstanceMultiMap<Object> objectMetadata; /** * Instantiates a new client entity descriptor. * * @param clientIdentifier the client identifier */ public ClientEntityDescriptor(@Nonnull final String clientIdentifier) { this.clientId = Constraint.isNotNull(clientIdentifier, "Client cannot be null"); this.objectMetadata = new LockableClassToInstanceMultiMap(true); } @Override public String getEntityID() { return clientId; } @Override public void setEntityID(final String id) {
throw new OIDCException();
uchicago/shibboleth-oidc
idp-oidc-impl/src/main/java/net/shibboleth/idp/oidc/flow/OIDCAuthorizationRequestContext.java
// Path: idp-oidc-impl/src/main/java/net/shibboleth/idp/oidc/config/OIDCConstants.java // public interface OIDCConstants { // // /** // * The constant ACR_VALUES. // */ // String ACR_VALUES = "acr_values"; // // /** // * The constant ID_TOKEN. // */ // String ID_TOKEN = "idtoken"; // // /** // * The constant AUTH_TIME. // */ // String AUTH_TIME = "auth_time"; // // /** // * The constant ACR. // */ // String ACR = "acr"; // // /** // * The constant AMR. // */ // String AMR = "amr"; // // /** // * The constant TOKEN. // */ // String TOKEN = "token"; // // /** // * The constant AT_HASH. // */ // String AT_HASH = "at_hash"; // // /** // * The constant KID. // */ // String KID = "kid"; // // /** // * The constant ROLE_USER. // */ // String ROLE_USER = "ROLE_USER"; // // /** // * The constant ROLE_CLIENT. // */ // String ROLE_CLIENT = "ROLE_CLIENT"; // }
import com.google.common.base.MoreObjects; import net.shibboleth.idp.oidc.config.OIDCConstants; import org.mitre.openid.connect.request.ConnectRequestParameters; import org.opensaml.messaging.context.BaseContext; import org.springframework.security.oauth2.provider.AuthorizationRequest; import javax.annotation.Nonnull;
*/ public String getState() { return this.authorizationRequest.getState(); } /** * Is force authentication boolean. * * @return the boolean */ public boolean isForceAuthentication() { return forceAuthentication; } /** * Sets force authentication. * * @param force the force */ public void setForceAuthentication(final boolean force) { this.forceAuthentication = force; } /** * Is implicit response type boolean. * * @return the boolean */ public boolean isImplicitResponseType() {
// Path: idp-oidc-impl/src/main/java/net/shibboleth/idp/oidc/config/OIDCConstants.java // public interface OIDCConstants { // // /** // * The constant ACR_VALUES. // */ // String ACR_VALUES = "acr_values"; // // /** // * The constant ID_TOKEN. // */ // String ID_TOKEN = "idtoken"; // // /** // * The constant AUTH_TIME. // */ // String AUTH_TIME = "auth_time"; // // /** // * The constant ACR. // */ // String ACR = "acr"; // // /** // * The constant AMR. // */ // String AMR = "amr"; // // /** // * The constant TOKEN. // */ // String TOKEN = "token"; // // /** // * The constant AT_HASH. // */ // String AT_HASH = "at_hash"; // // /** // * The constant KID. // */ // String KID = "kid"; // // /** // * The constant ROLE_USER. // */ // String ROLE_USER = "ROLE_USER"; // // /** // * The constant ROLE_CLIENT. // */ // String ROLE_CLIENT = "ROLE_CLIENT"; // } // Path: idp-oidc-impl/src/main/java/net/shibboleth/idp/oidc/flow/OIDCAuthorizationRequestContext.java import com.google.common.base.MoreObjects; import net.shibboleth.idp.oidc.config.OIDCConstants; import org.mitre.openid.connect.request.ConnectRequestParameters; import org.opensaml.messaging.context.BaseContext; import org.springframework.security.oauth2.provider.AuthorizationRequest; import javax.annotation.Nonnull; */ public String getState() { return this.authorizationRequest.getState(); } /** * Is force authentication boolean. * * @return the boolean */ public boolean isForceAuthentication() { return forceAuthentication; } /** * Sets force authentication. * * @param force the force */ public void setForceAuthentication(final boolean force) { this.forceAuthentication = force; } /** * Is implicit response type boolean. * * @return the boolean */ public boolean isImplicitResponseType() {
return authorizationRequest.getResponseTypes().contains(OIDCConstants.TOKEN);
uchicago/shibboleth-oidc
idp-oidc-impl/src/main/java/net/shibboleth/idp/oidc/client/userinfo/ShibbolethUserInfoRepository.java
// Path: idp-oidc-impl/src/main/java/net/shibboleth/idp/oidc/OIDCException.java // public class OIDCException extends InvalidRequestException { // // // /** // * Instantiates a new Oidc exception. // */ // public OIDCException() { // super("Invalid request"); // } // // /** // * Instantiates a new Oidc exception. // * // * @param message the message // */ // public OIDCException(final String message) { // super(message); // } // // /** // * Instantiates a new Oidc exception. // * // * @param message the message // * @param cause the cause // */ // public OIDCException(final String message, final Throwable cause) { // super(message, cause); // } // // /** // * Instantiates a new Oidc exception. // * // * @param cause the cause // */ // public OIDCException(final Throwable cause) { // this(cause.getMessage(), cause); // } // }
import com.google.common.base.Strings; import net.shibboleth.idp.attribute.EmptyAttributeValue; import net.shibboleth.idp.attribute.IdPAttribute; import net.shibboleth.idp.attribute.IdPAttributeValue; import net.shibboleth.idp.attribute.filter.AttributeFilter; import net.shibboleth.idp.attribute.filter.context.AttributeFilterContext; import net.shibboleth.idp.attribute.resolver.AttributeResolver; import net.shibboleth.idp.attribute.resolver.context.AttributeResolutionContext; import net.shibboleth.idp.oidc.OIDCException; import net.shibboleth.utilities.java.support.service.ReloadableService; import org.mitre.openid.connect.model.DefaultAddress; import org.mitre.openid.connect.model.DefaultUserInfo; import org.mitre.openid.connect.model.UserInfo; import org.mitre.openid.connect.repository.UserInfoRepository; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.context.annotation.Primary; import org.springframework.stereotype.Repository; import java.util.Map;
resolver.resolveAttributes(attributeContext); final Map<String, IdPAttribute> resolvedAttributes = attributeContext.getResolvedIdPAttributes(); final AttributeFilterContext filterContext = new AttributeFilterContext(); filterContext.setPrincipal(username); filterContext.setAttributeIssuerID(getClass().getSimpleName()); filterContext.setPrefilteredIdPAttributes(resolvedAttributes.values()); filterContext.setAttributeRecipientID(recipientId); filter.filterAttributes(filterContext); final Map<String, IdPAttribute> filteredAttributes = filterContext.getFilteredIdPAttributes(); for (final String attributeKey : filteredAttributes.keySet()) { final IdPAttribute attribute = filteredAttributes.get(attributeKey); log.debug("Attribute {} is authorized for release. Mapping...", attribute.getId()); setUserInfoClaimByAttribute(username, userInfo, attribute); } } catch (final Exception e) { log.error(e.getMessage(), e); } if (Strings.isNullOrEmpty(userInfo.getSub())) { log.warn("userinfo sub claim cannot be null/empty. Reset claim value to {}", username); userInfo.setSub(username); } log.debug("Final userinfo object constructed from attributes is\n {}", userInfo.toJson()); return userInfo; } @Override public UserInfo getByEmailAddress(final String s) {
// Path: idp-oidc-impl/src/main/java/net/shibboleth/idp/oidc/OIDCException.java // public class OIDCException extends InvalidRequestException { // // // /** // * Instantiates a new Oidc exception. // */ // public OIDCException() { // super("Invalid request"); // } // // /** // * Instantiates a new Oidc exception. // * // * @param message the message // */ // public OIDCException(final String message) { // super(message); // } // // /** // * Instantiates a new Oidc exception. // * // * @param message the message // * @param cause the cause // */ // public OIDCException(final String message, final Throwable cause) { // super(message, cause); // } // // /** // * Instantiates a new Oidc exception. // * // * @param cause the cause // */ // public OIDCException(final Throwable cause) { // this(cause.getMessage(), cause); // } // } // Path: idp-oidc-impl/src/main/java/net/shibboleth/idp/oidc/client/userinfo/ShibbolethUserInfoRepository.java import com.google.common.base.Strings; import net.shibboleth.idp.attribute.EmptyAttributeValue; import net.shibboleth.idp.attribute.IdPAttribute; import net.shibboleth.idp.attribute.IdPAttributeValue; import net.shibboleth.idp.attribute.filter.AttributeFilter; import net.shibboleth.idp.attribute.filter.context.AttributeFilterContext; import net.shibboleth.idp.attribute.resolver.AttributeResolver; import net.shibboleth.idp.attribute.resolver.context.AttributeResolutionContext; import net.shibboleth.idp.oidc.OIDCException; import net.shibboleth.utilities.java.support.service.ReloadableService; import org.mitre.openid.connect.model.DefaultAddress; import org.mitre.openid.connect.model.DefaultUserInfo; import org.mitre.openid.connect.model.UserInfo; import org.mitre.openid.connect.repository.UserInfoRepository; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.context.annotation.Primary; import org.springframework.stereotype.Repository; import java.util.Map; resolver.resolveAttributes(attributeContext); final Map<String, IdPAttribute> resolvedAttributes = attributeContext.getResolvedIdPAttributes(); final AttributeFilterContext filterContext = new AttributeFilterContext(); filterContext.setPrincipal(username); filterContext.setAttributeIssuerID(getClass().getSimpleName()); filterContext.setPrefilteredIdPAttributes(resolvedAttributes.values()); filterContext.setAttributeRecipientID(recipientId); filter.filterAttributes(filterContext); final Map<String, IdPAttribute> filteredAttributes = filterContext.getFilteredIdPAttributes(); for (final String attributeKey : filteredAttributes.keySet()) { final IdPAttribute attribute = filteredAttributes.get(attributeKey); log.debug("Attribute {} is authorized for release. Mapping...", attribute.getId()); setUserInfoClaimByAttribute(username, userInfo, attribute); } } catch (final Exception e) { log.error(e.getMessage(), e); } if (Strings.isNullOrEmpty(userInfo.getSub())) { log.warn("userinfo sub claim cannot be null/empty. Reset claim value to {}", username); userInfo.setSub(username); } log.debug("Final userinfo object constructed from attributes is\n {}", userInfo.toJson()); return userInfo; } @Override public UserInfo getByEmailAddress(final String s) {
throw new OIDCException("Operation is not supported");
memfis19/Annca
annca/src/main/java/io/github/memfis19/annca/internal/configuration/ConfigurationProvider.java
// Path: annca/src/main/java/io/github/memfis19/annca/internal/ui/view/CameraSwitchView.java // public class CameraSwitchView extends AppCompatImageButton { // // public static final int CAMERA_TYPE_FRONT = 0; // public static final int CAMERA_TYPE_REAR = 1; // // @IntDef({CAMERA_TYPE_FRONT, CAMERA_TYPE_REAR}) // @Retention(RetentionPolicy.SOURCE) // public @interface CameraType { // } // // private OnCameraTypeChangeListener onCameraTypeChangeListener; // // public interface OnCameraTypeChangeListener { // void onCameraTypeChanged(@CameraType int cameraType); // } // // private Context context; // private Drawable frontCameraDrawable; // private Drawable rearCameraDrawable; // private int padding = 5; // // private // @CameraType // int currentCameraType = CAMERA_TYPE_REAR; // // public CameraSwitchView(Context context) { // this(context, null); // } // // public CameraSwitchView(Context context, AttributeSet attrs) { // super(context, attrs); // this.context = context; // initializeView(); // } // // public CameraSwitchView(Context context, AttributeSet attrs, int defStyleAttr) { // this(context, attrs); // } // // private void initializeView() { // frontCameraDrawable = ContextCompat.getDrawable(context, R.drawable.ic_camera_front_white_24dp); // frontCameraDrawable = DrawableCompat.wrap(frontCameraDrawable); // DrawableCompat.setTintList(frontCameraDrawable.mutate(), ContextCompat.getColorStateList(context, R.drawable.switch_camera_mode_selector)); // // rearCameraDrawable = ContextCompat.getDrawable(context, R.drawable.ic_camera_rear_white_24dp); // rearCameraDrawable = DrawableCompat.wrap(rearCameraDrawable); // DrawableCompat.setTintList(rearCameraDrawable.mutate(), ContextCompat.getColorStateList(context, R.drawable.switch_camera_mode_selector)); // // setBackgroundResource(R.drawable.circle_frame_background_dark); // setOnClickListener(new CameraTypeClickListener()); // setIcons(); // padding = Utils.convertDipToPixels(context, padding); // setPadding(padding, padding, padding, padding); // } // // private void setIcons() { // if (currentCameraType == CAMERA_TYPE_REAR) { // setImageDrawable(frontCameraDrawable); // } else setImageDrawable(rearCameraDrawable); // } // // @Override // public void setEnabled(boolean enabled) { // super.setEnabled(enabled); // if (Build.VERSION.SDK_INT > 10) { // if (enabled) { // setAlpha(1f); // } else { // setAlpha(0.5f); // } // } // } // // public void setCameraType(@CameraType int cameraType) { // this.currentCameraType = cameraType; // setIcons(); // } // // public // @CameraType // int getCameraType() { // return currentCameraType; // } // // public void setOnCameraTypeChangeListener(OnCameraTypeChangeListener onCameraTypeChangeListener) { // this.onCameraTypeChangeListener = onCameraTypeChangeListener; // } // // private class CameraTypeClickListener implements OnClickListener { // // @Override // public void onClick(View view) { // if (currentCameraType == CAMERA_TYPE_REAR) { // currentCameraType = CAMERA_TYPE_FRONT; // } else currentCameraType = CAMERA_TYPE_REAR; // // setIcons(); // // if (onCameraTypeChangeListener != null) // onCameraTypeChangeListener.onCameraTypeChanged(currentCameraType); // } // } // }
import io.github.memfis19.annca.internal.ui.view.CameraSwitchView;
package io.github.memfis19.annca.internal.configuration; /** * Created by memfis on 7/6/16. */ public interface ConfigurationProvider { int getRequestCode(); @AnncaConfiguration.MediaAction int getMediaAction(); @AnncaConfiguration.MediaQuality int getMediaQuality(); int getVideoDuration(); long getVideoFileSize(); @AnncaConfiguration.SensorPosition int getSensorPosition(); int getDegrees(); int getMinimumVideoDuration(); @AnncaConfiguration.FlashMode int getFlashMode();
// Path: annca/src/main/java/io/github/memfis19/annca/internal/ui/view/CameraSwitchView.java // public class CameraSwitchView extends AppCompatImageButton { // // public static final int CAMERA_TYPE_FRONT = 0; // public static final int CAMERA_TYPE_REAR = 1; // // @IntDef({CAMERA_TYPE_FRONT, CAMERA_TYPE_REAR}) // @Retention(RetentionPolicy.SOURCE) // public @interface CameraType { // } // // private OnCameraTypeChangeListener onCameraTypeChangeListener; // // public interface OnCameraTypeChangeListener { // void onCameraTypeChanged(@CameraType int cameraType); // } // // private Context context; // private Drawable frontCameraDrawable; // private Drawable rearCameraDrawable; // private int padding = 5; // // private // @CameraType // int currentCameraType = CAMERA_TYPE_REAR; // // public CameraSwitchView(Context context) { // this(context, null); // } // // public CameraSwitchView(Context context, AttributeSet attrs) { // super(context, attrs); // this.context = context; // initializeView(); // } // // public CameraSwitchView(Context context, AttributeSet attrs, int defStyleAttr) { // this(context, attrs); // } // // private void initializeView() { // frontCameraDrawable = ContextCompat.getDrawable(context, R.drawable.ic_camera_front_white_24dp); // frontCameraDrawable = DrawableCompat.wrap(frontCameraDrawable); // DrawableCompat.setTintList(frontCameraDrawable.mutate(), ContextCompat.getColorStateList(context, R.drawable.switch_camera_mode_selector)); // // rearCameraDrawable = ContextCompat.getDrawable(context, R.drawable.ic_camera_rear_white_24dp); // rearCameraDrawable = DrawableCompat.wrap(rearCameraDrawable); // DrawableCompat.setTintList(rearCameraDrawable.mutate(), ContextCompat.getColorStateList(context, R.drawable.switch_camera_mode_selector)); // // setBackgroundResource(R.drawable.circle_frame_background_dark); // setOnClickListener(new CameraTypeClickListener()); // setIcons(); // padding = Utils.convertDipToPixels(context, padding); // setPadding(padding, padding, padding, padding); // } // // private void setIcons() { // if (currentCameraType == CAMERA_TYPE_REAR) { // setImageDrawable(frontCameraDrawable); // } else setImageDrawable(rearCameraDrawable); // } // // @Override // public void setEnabled(boolean enabled) { // super.setEnabled(enabled); // if (Build.VERSION.SDK_INT > 10) { // if (enabled) { // setAlpha(1f); // } else { // setAlpha(0.5f); // } // } // } // // public void setCameraType(@CameraType int cameraType) { // this.currentCameraType = cameraType; // setIcons(); // } // // public // @CameraType // int getCameraType() { // return currentCameraType; // } // // public void setOnCameraTypeChangeListener(OnCameraTypeChangeListener onCameraTypeChangeListener) { // this.onCameraTypeChangeListener = onCameraTypeChangeListener; // } // // private class CameraTypeClickListener implements OnClickListener { // // @Override // public void onClick(View view) { // if (currentCameraType == CAMERA_TYPE_REAR) { // currentCameraType = CAMERA_TYPE_FRONT; // } else currentCameraType = CAMERA_TYPE_REAR; // // setIcons(); // // if (onCameraTypeChangeListener != null) // onCameraTypeChangeListener.onCameraTypeChanged(currentCameraType); // } // } // } // Path: annca/src/main/java/io/github/memfis19/annca/internal/configuration/ConfigurationProvider.java import io.github.memfis19.annca.internal.ui.view.CameraSwitchView; package io.github.memfis19.annca.internal.configuration; /** * Created by memfis on 7/6/16. */ public interface ConfigurationProvider { int getRequestCode(); @AnncaConfiguration.MediaAction int getMediaAction(); @AnncaConfiguration.MediaQuality int getMediaQuality(); int getVideoDuration(); long getVideoFileSize(); @AnncaConfiguration.SensorPosition int getSensorPosition(); int getDegrees(); int getMinimumVideoDuration(); @AnncaConfiguration.FlashMode int getFlashMode();
@CameraSwitchView.CameraType
memfis19/Annca
annca/src/main/java/io/github/memfis19/annca/internal/ui/view/MediaActionSwitchView.java
// Path: annca/src/main/java/io/github/memfis19/annca/internal/utils/Utils.java // public class Utils { // // public static int getDeviceDefaultOrientation(Context context) { // WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); // Configuration config = context.getResources().getConfiguration(); // // int rotation = windowManager.getDefaultDisplay().getRotation(); // // if (((rotation == Surface.ROTATION_0 || rotation == Surface.ROTATION_180) && // config.orientation == Configuration.ORIENTATION_LANDSCAPE) // || ((rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270) && // config.orientation == Configuration.ORIENTATION_PORTRAIT)) { // return Configuration.ORIENTATION_LANDSCAPE; // } else { // return Configuration.ORIENTATION_PORTRAIT; // } // } // // public static String getMimeType(String url) { // String type = ""; // String extension = MimeTypeMap.getFileExtensionFromUrl(url); // if (!TextUtils.isEmpty(extension)) { // type = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension); // } else { // String reCheckExtension = MimeTypeMap.getFileExtensionFromUrl(url.replaceAll("\\s+", "")); // if (!TextUtils.isEmpty(reCheckExtension)) { // type = MimeTypeMap.getSingleton().getMimeTypeFromExtension(reCheckExtension); // } // } // return type; // } // // public static int convertDipToPixels(Context context, int dip) { // Resources resources = context.getResources(); // float px = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dip, resources.getDisplayMetrics()); // return (int) px; // } // // }
import android.content.Context; import android.graphics.drawable.Drawable; import android.os.Build; import android.support.annotation.IntDef; import android.support.v4.content.ContextCompat; import android.support.v4.graphics.drawable.DrawableCompat; import android.util.AttributeSet; import android.view.View; import android.widget.ImageButton; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import io.github.memfis19.annca.R; import io.github.memfis19.annca.internal.utils.Utils;
private int padding = 5; public MediaActionSwitchView(Context context) { this(context, null); } public MediaActionSwitchView(Context context, AttributeSet attrs) { super(context, attrs); this.context = context; initializeView(); } public MediaActionSwitchView(Context context, AttributeSet attrs, int defStyleAttr) { this(context, attrs); } private void initializeView() { photoDrawable = ContextCompat.getDrawable(context, R.drawable.ic_photo_camera_white_24dp); photoDrawable = DrawableCompat.wrap(photoDrawable); DrawableCompat.setTintList(photoDrawable.mutate(), ContextCompat.getColorStateList(context, R.drawable.switch_camera_mode_selector)); videoDrawable = ContextCompat.getDrawable(context, R.drawable.ic_videocam_white_24dp); videoDrawable = DrawableCompat.wrap(videoDrawable); DrawableCompat.setTintList(videoDrawable.mutate(), ContextCompat.getColorStateList(context, R.drawable.switch_camera_mode_selector)); setBackgroundResource(R.drawable.circle_frame_background_dark); // setBackgroundResource(R.drawable.circle_frame_background); setOnClickListener(new MediaActionClickListener()); setIcons();
// Path: annca/src/main/java/io/github/memfis19/annca/internal/utils/Utils.java // public class Utils { // // public static int getDeviceDefaultOrientation(Context context) { // WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); // Configuration config = context.getResources().getConfiguration(); // // int rotation = windowManager.getDefaultDisplay().getRotation(); // // if (((rotation == Surface.ROTATION_0 || rotation == Surface.ROTATION_180) && // config.orientation == Configuration.ORIENTATION_LANDSCAPE) // || ((rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270) && // config.orientation == Configuration.ORIENTATION_PORTRAIT)) { // return Configuration.ORIENTATION_LANDSCAPE; // } else { // return Configuration.ORIENTATION_PORTRAIT; // } // } // // public static String getMimeType(String url) { // String type = ""; // String extension = MimeTypeMap.getFileExtensionFromUrl(url); // if (!TextUtils.isEmpty(extension)) { // type = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension); // } else { // String reCheckExtension = MimeTypeMap.getFileExtensionFromUrl(url.replaceAll("\\s+", "")); // if (!TextUtils.isEmpty(reCheckExtension)) { // type = MimeTypeMap.getSingleton().getMimeTypeFromExtension(reCheckExtension); // } // } // return type; // } // // public static int convertDipToPixels(Context context, int dip) { // Resources resources = context.getResources(); // float px = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dip, resources.getDisplayMetrics()); // return (int) px; // } // // } // Path: annca/src/main/java/io/github/memfis19/annca/internal/ui/view/MediaActionSwitchView.java import android.content.Context; import android.graphics.drawable.Drawable; import android.os.Build; import android.support.annotation.IntDef; import android.support.v4.content.ContextCompat; import android.support.v4.graphics.drawable.DrawableCompat; import android.util.AttributeSet; import android.view.View; import android.widget.ImageButton; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import io.github.memfis19.annca.R; import io.github.memfis19.annca.internal.utils.Utils; private int padding = 5; public MediaActionSwitchView(Context context) { this(context, null); } public MediaActionSwitchView(Context context, AttributeSet attrs) { super(context, attrs); this.context = context; initializeView(); } public MediaActionSwitchView(Context context, AttributeSet attrs, int defStyleAttr) { this(context, attrs); } private void initializeView() { photoDrawable = ContextCompat.getDrawable(context, R.drawable.ic_photo_camera_white_24dp); photoDrawable = DrawableCompat.wrap(photoDrawable); DrawableCompat.setTintList(photoDrawable.mutate(), ContextCompat.getColorStateList(context, R.drawable.switch_camera_mode_selector)); videoDrawable = ContextCompat.getDrawable(context, R.drawable.ic_videocam_white_24dp); videoDrawable = DrawableCompat.wrap(videoDrawable); DrawableCompat.setTintList(videoDrawable.mutate(), ContextCompat.getColorStateList(context, R.drawable.switch_camera_mode_selector)); setBackgroundResource(R.drawable.circle_frame_background_dark); // setBackgroundResource(R.drawable.circle_frame_background); setOnClickListener(new MediaActionClickListener()); setIcons();
padding = Utils.convertDipToPixels(context, padding);
memfis19/Annca
annca/src/main/java/io/github/memfis19/annca/internal/ui/view/AspectFrameLayout.java
// Path: annca/src/main/java/io/github/memfis19/annca/internal/utils/Size.java // public class Size { // // private int width; // private int height; // // public Size() { // width = 0; // height = 0; // } // // public Size(int width, int height) { // this.width = width; // this.height = height; // } // // @TargetApi(Build.VERSION_CODES.LOLLIPOP) // public Size(android.util.Size size) { // this.width = size.getWidth(); // this.height = size.getHeight(); // } // // @SuppressWarnings("deprecation") // public Size(Camera.Size size) { // this.width = size.width; // this.height = size.height; // } // // public int getWidth() { // return width; // } // // public void setWidth(int width) { // this.width = width; // } // // public int getHeight() { // return height; // } // // public void setHeight(int height) { // this.height = height; // } // // @TargetApi(Build.VERSION_CODES.LOLLIPOP) // public static List<Size> fromList2(List<android.util.Size> sizes) { // if (sizes == null) return null; // List<Size> result = new ArrayList<>(sizes.size()); // // for (android.util.Size size : sizes) { // result.add(new Size(size)); // } // // return result; // } // // @SuppressWarnings("deprecation") // public static List<Size> fromList(List<Camera.Size> sizes) { // if (sizes == null) return null; // List<Size> result = new ArrayList<>(sizes.size()); // // for (Camera.Size size : sizes) { // result.add(new Size(size)); // } // // return result; // } // // @TargetApi(Build.VERSION_CODES.LOLLIPOP) // public static Size[] fromArray2(android.util.Size[] sizes) { // if (sizes == null) return null; // Size[] result = new Size[sizes.length]; // // for (int i = 0; i < sizes.length; ++i) { // result[i] = new Size(sizes[i]); // } // // return result; // } // // @SuppressWarnings("deprecation") // public static Size[] fromArray(Camera.Size[] sizes) { // if (sizes == null) return null; // Size[] result = new Size[sizes.length]; // // for (int i = 0; i < sizes.length; ++i) { // result[i] = new Size(sizes[i]); // } // // return result; // } // }
import android.content.Context; import android.util.AttributeSet; import android.view.ViewGroup; import android.view.ViewTreeObserver; import android.widget.FrameLayout; import io.github.memfis19.annca.internal.utils.Size;
package io.github.memfis19.annca.internal.ui.view; /** * Layout that adjusts to maintain a specific aspect ratio. */ public class AspectFrameLayout extends FrameLayout { private static final String TAG = "AspectFrameLayout"; private double targetAspectRatio = -1.0; // initially use default window size
// Path: annca/src/main/java/io/github/memfis19/annca/internal/utils/Size.java // public class Size { // // private int width; // private int height; // // public Size() { // width = 0; // height = 0; // } // // public Size(int width, int height) { // this.width = width; // this.height = height; // } // // @TargetApi(Build.VERSION_CODES.LOLLIPOP) // public Size(android.util.Size size) { // this.width = size.getWidth(); // this.height = size.getHeight(); // } // // @SuppressWarnings("deprecation") // public Size(Camera.Size size) { // this.width = size.width; // this.height = size.height; // } // // public int getWidth() { // return width; // } // // public void setWidth(int width) { // this.width = width; // } // // public int getHeight() { // return height; // } // // public void setHeight(int height) { // this.height = height; // } // // @TargetApi(Build.VERSION_CODES.LOLLIPOP) // public static List<Size> fromList2(List<android.util.Size> sizes) { // if (sizes == null) return null; // List<Size> result = new ArrayList<>(sizes.size()); // // for (android.util.Size size : sizes) { // result.add(new Size(size)); // } // // return result; // } // // @SuppressWarnings("deprecation") // public static List<Size> fromList(List<Camera.Size> sizes) { // if (sizes == null) return null; // List<Size> result = new ArrayList<>(sizes.size()); // // for (Camera.Size size : sizes) { // result.add(new Size(size)); // } // // return result; // } // // @TargetApi(Build.VERSION_CODES.LOLLIPOP) // public static Size[] fromArray2(android.util.Size[] sizes) { // if (sizes == null) return null; // Size[] result = new Size[sizes.length]; // // for (int i = 0; i < sizes.length; ++i) { // result[i] = new Size(sizes[i]); // } // // return result; // } // // @SuppressWarnings("deprecation") // public static Size[] fromArray(Camera.Size[] sizes) { // if (sizes == null) return null; // Size[] result = new Size[sizes.length]; // // for (int i = 0; i < sizes.length; ++i) { // result[i] = new Size(sizes[i]); // } // // return result; // } // } // Path: annca/src/main/java/io/github/memfis19/annca/internal/ui/view/AspectFrameLayout.java import android.content.Context; import android.util.AttributeSet; import android.view.ViewGroup; import android.view.ViewTreeObserver; import android.widget.FrameLayout; import io.github.memfis19.annca.internal.utils.Size; package io.github.memfis19.annca.internal.ui.view; /** * Layout that adjusts to maintain a specific aspect ratio. */ public class AspectFrameLayout extends FrameLayout { private static final String TAG = "AspectFrameLayout"; private double targetAspectRatio = -1.0; // initially use default window size
private Size size = null;
memfis19/Annca
annca/src/main/java/io/github/memfis19/annca/internal/ui/view/CameraSwitchView.java
// Path: annca/src/main/java/io/github/memfis19/annca/internal/utils/Utils.java // public class Utils { // // public static int getDeviceDefaultOrientation(Context context) { // WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); // Configuration config = context.getResources().getConfiguration(); // // int rotation = windowManager.getDefaultDisplay().getRotation(); // // if (((rotation == Surface.ROTATION_0 || rotation == Surface.ROTATION_180) && // config.orientation == Configuration.ORIENTATION_LANDSCAPE) // || ((rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270) && // config.orientation == Configuration.ORIENTATION_PORTRAIT)) { // return Configuration.ORIENTATION_LANDSCAPE; // } else { // return Configuration.ORIENTATION_PORTRAIT; // } // } // // public static String getMimeType(String url) { // String type = ""; // String extension = MimeTypeMap.getFileExtensionFromUrl(url); // if (!TextUtils.isEmpty(extension)) { // type = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension); // } else { // String reCheckExtension = MimeTypeMap.getFileExtensionFromUrl(url.replaceAll("\\s+", "")); // if (!TextUtils.isEmpty(reCheckExtension)) { // type = MimeTypeMap.getSingleton().getMimeTypeFromExtension(reCheckExtension); // } // } // return type; // } // // public static int convertDipToPixels(Context context, int dip) { // Resources resources = context.getResources(); // float px = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dip, resources.getDisplayMetrics()); // return (int) px; // } // // }
import android.content.Context; import android.graphics.drawable.Drawable; import android.os.Build; import android.support.annotation.IntDef; import android.support.v4.content.ContextCompat; import android.support.v4.graphics.drawable.DrawableCompat; import android.support.v7.widget.AppCompatImageButton; import android.util.AttributeSet; import android.view.View; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import io.github.memfis19.annca.R; import io.github.memfis19.annca.internal.utils.Utils;
private @CameraType int currentCameraType = CAMERA_TYPE_REAR; public CameraSwitchView(Context context) { this(context, null); } public CameraSwitchView(Context context, AttributeSet attrs) { super(context, attrs); this.context = context; initializeView(); } public CameraSwitchView(Context context, AttributeSet attrs, int defStyleAttr) { this(context, attrs); } private void initializeView() { frontCameraDrawable = ContextCompat.getDrawable(context, R.drawable.ic_camera_front_white_24dp); frontCameraDrawable = DrawableCompat.wrap(frontCameraDrawable); DrawableCompat.setTintList(frontCameraDrawable.mutate(), ContextCompat.getColorStateList(context, R.drawable.switch_camera_mode_selector)); rearCameraDrawable = ContextCompat.getDrawable(context, R.drawable.ic_camera_rear_white_24dp); rearCameraDrawable = DrawableCompat.wrap(rearCameraDrawable); DrawableCompat.setTintList(rearCameraDrawable.mutate(), ContextCompat.getColorStateList(context, R.drawable.switch_camera_mode_selector)); setBackgroundResource(R.drawable.circle_frame_background_dark); setOnClickListener(new CameraTypeClickListener()); setIcons();
// Path: annca/src/main/java/io/github/memfis19/annca/internal/utils/Utils.java // public class Utils { // // public static int getDeviceDefaultOrientation(Context context) { // WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); // Configuration config = context.getResources().getConfiguration(); // // int rotation = windowManager.getDefaultDisplay().getRotation(); // // if (((rotation == Surface.ROTATION_0 || rotation == Surface.ROTATION_180) && // config.orientation == Configuration.ORIENTATION_LANDSCAPE) // || ((rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270) && // config.orientation == Configuration.ORIENTATION_PORTRAIT)) { // return Configuration.ORIENTATION_LANDSCAPE; // } else { // return Configuration.ORIENTATION_PORTRAIT; // } // } // // public static String getMimeType(String url) { // String type = ""; // String extension = MimeTypeMap.getFileExtensionFromUrl(url); // if (!TextUtils.isEmpty(extension)) { // type = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension); // } else { // String reCheckExtension = MimeTypeMap.getFileExtensionFromUrl(url.replaceAll("\\s+", "")); // if (!TextUtils.isEmpty(reCheckExtension)) { // type = MimeTypeMap.getSingleton().getMimeTypeFromExtension(reCheckExtension); // } // } // return type; // } // // public static int convertDipToPixels(Context context, int dip) { // Resources resources = context.getResources(); // float px = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dip, resources.getDisplayMetrics()); // return (int) px; // } // // } // Path: annca/src/main/java/io/github/memfis19/annca/internal/ui/view/CameraSwitchView.java import android.content.Context; import android.graphics.drawable.Drawable; import android.os.Build; import android.support.annotation.IntDef; import android.support.v4.content.ContextCompat; import android.support.v4.graphics.drawable.DrawableCompat; import android.support.v7.widget.AppCompatImageButton; import android.util.AttributeSet; import android.view.View; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import io.github.memfis19.annca.R; import io.github.memfis19.annca.internal.utils.Utils; private @CameraType int currentCameraType = CAMERA_TYPE_REAR; public CameraSwitchView(Context context) { this(context, null); } public CameraSwitchView(Context context, AttributeSet attrs) { super(context, attrs); this.context = context; initializeView(); } public CameraSwitchView(Context context, AttributeSet attrs, int defStyleAttr) { this(context, attrs); } private void initializeView() { frontCameraDrawable = ContextCompat.getDrawable(context, R.drawable.ic_camera_front_white_24dp); frontCameraDrawable = DrawableCompat.wrap(frontCameraDrawable); DrawableCompat.setTintList(frontCameraDrawable.mutate(), ContextCompat.getColorStateList(context, R.drawable.switch_camera_mode_selector)); rearCameraDrawable = ContextCompat.getDrawable(context, R.drawable.ic_camera_rear_white_24dp); rearCameraDrawable = DrawableCompat.wrap(rearCameraDrawable); DrawableCompat.setTintList(rearCameraDrawable.mutate(), ContextCompat.getColorStateList(context, R.drawable.switch_camera_mode_selector)); setBackgroundResource(R.drawable.circle_frame_background_dark); setOnClickListener(new CameraTypeClickListener()); setIcons();
padding = Utils.convertDipToPixels(context, padding);
evgenyneu/aes-crypto-android
app/src/main/java/com/evgenii/aescrypto/Decrypt.java
// Path: app/src/main/java/com/evgenii/aescrypto/interfaces/JsEncryptorInterface.java // public interface JsEncryptorInterface { // public void decrypt(String text, String password, JsCallback callback); // // public void encrypt(String text, String password, JsCallback callback); // // public boolean isEncrypted(String text); // } // // Path: app/src/main/java/com/evgenii/aescrypto/interfaces/MainActivityInterface.java // public interface MainActivityInterface { // public boolean hasMessage(); // // public boolean hasPassword(); // // public boolean isBusy(); // // public void setMessage(String message); // // public String trimmedMessage(); // // public String trimmedPassword(); // // public void updateBusy(boolean isBusy); // // public void updateEncryptButtonTitle(); // }
import com.evgenii.aescrypto.interfaces.JsEncryptorInterface; import com.evgenii.aescrypto.interfaces.MainActivityInterface; import com.evgenii.jsevaluator.interfaces.JsCallback;
package com.evgenii.aescrypto; public class Decrypt { private final MainActivityInterface mActivity;
// Path: app/src/main/java/com/evgenii/aescrypto/interfaces/JsEncryptorInterface.java // public interface JsEncryptorInterface { // public void decrypt(String text, String password, JsCallback callback); // // public void encrypt(String text, String password, JsCallback callback); // // public boolean isEncrypted(String text); // } // // Path: app/src/main/java/com/evgenii/aescrypto/interfaces/MainActivityInterface.java // public interface MainActivityInterface { // public boolean hasMessage(); // // public boolean hasPassword(); // // public boolean isBusy(); // // public void setMessage(String message); // // public String trimmedMessage(); // // public String trimmedPassword(); // // public void updateBusy(boolean isBusy); // // public void updateEncryptButtonTitle(); // } // Path: app/src/main/java/com/evgenii/aescrypto/Decrypt.java import com.evgenii.aescrypto.interfaces.JsEncryptorInterface; import com.evgenii.aescrypto.interfaces.MainActivityInterface; import com.evgenii.jsevaluator.interfaces.JsCallback; package com.evgenii.aescrypto; public class Decrypt { private final MainActivityInterface mActivity;
private final JsEncryptorInterface mJsEncryptor;
evgenyneu/aes-crypto-android
app/src/main/java/com/evgenii/aescrypto/Encrypt.java
// Path: app/src/main/java/com/evgenii/aescrypto/interfaces/ClipboardInterface.java // public interface ClipboardInterface { // public String get(); // // public void set(String text); // } // // Path: app/src/main/java/com/evgenii/aescrypto/interfaces/JsEncryptorInterface.java // public interface JsEncryptorInterface { // public void decrypt(String text, String password, JsCallback callback); // // public void encrypt(String text, String password, JsCallback callback); // // public boolean isEncrypted(String text); // } // // Path: app/src/main/java/com/evgenii/aescrypto/interfaces/MainActivityInterface.java // public interface MainActivityInterface { // public boolean hasMessage(); // // public boolean hasPassword(); // // public boolean isBusy(); // // public void setMessage(String message); // // public String trimmedMessage(); // // public String trimmedPassword(); // // public void updateBusy(boolean isBusy); // // public void updateEncryptButtonTitle(); // }
import com.evgenii.aescrypto.interfaces.ClipboardInterface; import com.evgenii.aescrypto.interfaces.JsEncryptorInterface; import com.evgenii.aescrypto.interfaces.MainActivityInterface; import com.evgenii.jsevaluator.interfaces.JsCallback;
package com.evgenii.aescrypto; public class Encrypt { private final MainActivityInterface mActivity;
// Path: app/src/main/java/com/evgenii/aescrypto/interfaces/ClipboardInterface.java // public interface ClipboardInterface { // public String get(); // // public void set(String text); // } // // Path: app/src/main/java/com/evgenii/aescrypto/interfaces/JsEncryptorInterface.java // public interface JsEncryptorInterface { // public void decrypt(String text, String password, JsCallback callback); // // public void encrypt(String text, String password, JsCallback callback); // // public boolean isEncrypted(String text); // } // // Path: app/src/main/java/com/evgenii/aescrypto/interfaces/MainActivityInterface.java // public interface MainActivityInterface { // public boolean hasMessage(); // // public boolean hasPassword(); // // public boolean isBusy(); // // public void setMessage(String message); // // public String trimmedMessage(); // // public String trimmedPassword(); // // public void updateBusy(boolean isBusy); // // public void updateEncryptButtonTitle(); // } // Path: app/src/main/java/com/evgenii/aescrypto/Encrypt.java import com.evgenii.aescrypto.interfaces.ClipboardInterface; import com.evgenii.aescrypto.interfaces.JsEncryptorInterface; import com.evgenii.aescrypto.interfaces.MainActivityInterface; import com.evgenii.jsevaluator.interfaces.JsCallback; package com.evgenii.aescrypto; public class Encrypt { private final MainActivityInterface mActivity;
private final JsEncryptorInterface mJsEncryptor;
evgenyneu/aes-crypto-android
app/src/main/java/com/evgenii/aescrypto/Encrypt.java
// Path: app/src/main/java/com/evgenii/aescrypto/interfaces/ClipboardInterface.java // public interface ClipboardInterface { // public String get(); // // public void set(String text); // } // // Path: app/src/main/java/com/evgenii/aescrypto/interfaces/JsEncryptorInterface.java // public interface JsEncryptorInterface { // public void decrypt(String text, String password, JsCallback callback); // // public void encrypt(String text, String password, JsCallback callback); // // public boolean isEncrypted(String text); // } // // Path: app/src/main/java/com/evgenii/aescrypto/interfaces/MainActivityInterface.java // public interface MainActivityInterface { // public boolean hasMessage(); // // public boolean hasPassword(); // // public boolean isBusy(); // // public void setMessage(String message); // // public String trimmedMessage(); // // public String trimmedPassword(); // // public void updateBusy(boolean isBusy); // // public void updateEncryptButtonTitle(); // }
import com.evgenii.aescrypto.interfaces.ClipboardInterface; import com.evgenii.aescrypto.interfaces.JsEncryptorInterface; import com.evgenii.aescrypto.interfaces.MainActivityInterface; import com.evgenii.jsevaluator.interfaces.JsCallback;
package com.evgenii.aescrypto; public class Encrypt { private final MainActivityInterface mActivity; private final JsEncryptorInterface mJsEncryptor;
// Path: app/src/main/java/com/evgenii/aescrypto/interfaces/ClipboardInterface.java // public interface ClipboardInterface { // public String get(); // // public void set(String text); // } // // Path: app/src/main/java/com/evgenii/aescrypto/interfaces/JsEncryptorInterface.java // public interface JsEncryptorInterface { // public void decrypt(String text, String password, JsCallback callback); // // public void encrypt(String text, String password, JsCallback callback); // // public boolean isEncrypted(String text); // } // // Path: app/src/main/java/com/evgenii/aescrypto/interfaces/MainActivityInterface.java // public interface MainActivityInterface { // public boolean hasMessage(); // // public boolean hasPassword(); // // public boolean isBusy(); // // public void setMessage(String message); // // public String trimmedMessage(); // // public String trimmedPassword(); // // public void updateBusy(boolean isBusy); // // public void updateEncryptButtonTitle(); // } // Path: app/src/main/java/com/evgenii/aescrypto/Encrypt.java import com.evgenii.aescrypto.interfaces.ClipboardInterface; import com.evgenii.aescrypto.interfaces.JsEncryptorInterface; import com.evgenii.aescrypto.interfaces.MainActivityInterface; import com.evgenii.jsevaluator.interfaces.JsCallback; package com.evgenii.aescrypto; public class Encrypt { private final MainActivityInterface mActivity; private final JsEncryptorInterface mJsEncryptor;
private final ClipboardInterface mClipboard;
evgenyneu/aes-crypto-android
app/src/androidTest/java/com/evgenii/aescrypto/JSEncryptorTests.java
// Path: app/src/main/java/com/evgenii/aescrypto/JsEncryptor.java // public class JsEncryptor implements JsEncryptorInterface { // public static JsEncryptor evaluateAllScripts(Activity context) { // final AssetsFileReader assetsFileReader = new AssetsFileReader(context); // final JsEvaluator jsEvaluator = new JsEvaluator(context); // final JsEncryptor jsEncryptor = new JsEncryptor(assetsFileReader, jsEvaluator); // try { // jsEncryptor.readScripts(); // } catch (final IOException e) { // ShowFatalError.showAlertAndExit(context, "Can not read JavaScript file.", e); // } // return jsEncryptor; // } // // private final AssetsFileReaderInterface mAssetsFileReader; // private final JsEvaluatorInterface mJsEvaluator; // private final String cryptoJsFileNames = "crypto_js"; // private final String aesCryptoFileName = "aes_crypto"; // private final String jsRootDir = "javascript"; // // private static final String prefix = "AESCryptoV10"; // // private ArrayList<String> mScriptsText; // // public JsEncryptor(AssetsFileReaderInterface assetsFileReader, JsEvaluatorInterface jsEvaluator) { // mAssetsFileReader = assetsFileReader; // mJsEvaluator = jsEvaluator; // } // // public String concatenateScripts() { // final StringBuilder stringBuilder = new StringBuilder(); // final ArrayList<String> scripts = getScripts(); // for (final String scriptText : scripts) { // stringBuilder.append(scriptText); // stringBuilder.append("; "); // } // // return stringBuilder.toString(); // } // // @Override // public void decrypt(String text, String password, JsCallback callback) { // final String libraryJsCode = concatenateScripts(); // mJsEvaluator.callFunction(libraryJsCode, callback, "aesCrypto.decrypt", text, password); // } // // @Override // public void encrypt(String text, String password, JsCallback callback) { // final String libraryJsCode = concatenateScripts(); // mJsEvaluator.callFunction(libraryJsCode, callback, "aesCrypto.encrypt", text, password); // } // // public ArrayList<String> getScripts() { // if (mScriptsText == null) { // mScriptsText = new ArrayList<String>(); // } // return mScriptsText; // } // // @Override // public boolean isEncrypted(String text) { // if (text == null) // return false; // // return text.trim().startsWith(prefix); // } // // public void readScripts() throws IOException { // final ArrayList<String> scriptsToLoad = new ArrayList<String>(); // // scriptsToLoad.add(jsRootDir + "/" + cryptoJsFileNames + ".js"); // scriptsToLoad.add(jsRootDir + "/" + aesCryptoFileName + ".js"); // // final ArrayList<String> scriptsText = getScripts(); // // for (final String scriptName : scriptsToLoad) { // scriptsText.add(mAssetsFileReader.ReadFile(scriptName)); // } // } // } // // Path: app/src/androidTest/java/com/evgenii/aescrypto/mocks/AssetsFileReaderMock.java // public class AssetsFileReaderMock implements AssetsFileReaderInterface { // @Override // public String ReadFile(String fileName) throws IOException { // return fileName + " script"; // } // // } // // Path: app/src/androidTest/java/com/evgenii/aescrypto/mocks/JsEvaluatorMock.java // public class JsEvaluatorMock implements JsEvaluatorInterface { // public ArrayList<String> mEvaluatedScripts = new ArrayList<String>(); // public ArrayList<JsCallback> mEvaluateCallbacks = new ArrayList<JsCallback>(); // public Object[] mEvaluateArguments = null; // // @Override // public void callFunction(String jsCode, JsCallback callabck, String script, // Object... jsArguments) { // mEvaluateCallbacks.add(callabck); // mEvaluatedScripts.add(script); // mEvaluateArguments = jsArguments; // } // // @Override // public void evaluate(String script) { // mEvaluatedScripts.add(script); // mEvaluateCallbacks.add(null); // } // // @Override // public void evaluate(String script, JsCallback callback) { // mEvaluatedScripts.add(script); // mEvaluateCallbacks.add(callback); // } // // @Override // public void destroy() { // // } // // @Override // public WebView getWebView() { // return null; // } // // }
import java.io.IOException; import java.util.ArrayList; import android.test.AndroidTestCase; import com.evgenii.aescrypto.JsEncryptor; import com.evgenii.aescrypto.mocks.AssetsFileReaderMock; import com.evgenii.aescrypto.mocks.JsEvaluatorMock; import com.evgenii.jsevaluator.interfaces.JsCallback;
package com.evgenii.aescrypto; public class JSEncryptorTests extends AndroidTestCase { JsEncryptor mJsEncryptor;
// Path: app/src/main/java/com/evgenii/aescrypto/JsEncryptor.java // public class JsEncryptor implements JsEncryptorInterface { // public static JsEncryptor evaluateAllScripts(Activity context) { // final AssetsFileReader assetsFileReader = new AssetsFileReader(context); // final JsEvaluator jsEvaluator = new JsEvaluator(context); // final JsEncryptor jsEncryptor = new JsEncryptor(assetsFileReader, jsEvaluator); // try { // jsEncryptor.readScripts(); // } catch (final IOException e) { // ShowFatalError.showAlertAndExit(context, "Can not read JavaScript file.", e); // } // return jsEncryptor; // } // // private final AssetsFileReaderInterface mAssetsFileReader; // private final JsEvaluatorInterface mJsEvaluator; // private final String cryptoJsFileNames = "crypto_js"; // private final String aesCryptoFileName = "aes_crypto"; // private final String jsRootDir = "javascript"; // // private static final String prefix = "AESCryptoV10"; // // private ArrayList<String> mScriptsText; // // public JsEncryptor(AssetsFileReaderInterface assetsFileReader, JsEvaluatorInterface jsEvaluator) { // mAssetsFileReader = assetsFileReader; // mJsEvaluator = jsEvaluator; // } // // public String concatenateScripts() { // final StringBuilder stringBuilder = new StringBuilder(); // final ArrayList<String> scripts = getScripts(); // for (final String scriptText : scripts) { // stringBuilder.append(scriptText); // stringBuilder.append("; "); // } // // return stringBuilder.toString(); // } // // @Override // public void decrypt(String text, String password, JsCallback callback) { // final String libraryJsCode = concatenateScripts(); // mJsEvaluator.callFunction(libraryJsCode, callback, "aesCrypto.decrypt", text, password); // } // // @Override // public void encrypt(String text, String password, JsCallback callback) { // final String libraryJsCode = concatenateScripts(); // mJsEvaluator.callFunction(libraryJsCode, callback, "aesCrypto.encrypt", text, password); // } // // public ArrayList<String> getScripts() { // if (mScriptsText == null) { // mScriptsText = new ArrayList<String>(); // } // return mScriptsText; // } // // @Override // public boolean isEncrypted(String text) { // if (text == null) // return false; // // return text.trim().startsWith(prefix); // } // // public void readScripts() throws IOException { // final ArrayList<String> scriptsToLoad = new ArrayList<String>(); // // scriptsToLoad.add(jsRootDir + "/" + cryptoJsFileNames + ".js"); // scriptsToLoad.add(jsRootDir + "/" + aesCryptoFileName + ".js"); // // final ArrayList<String> scriptsText = getScripts(); // // for (final String scriptName : scriptsToLoad) { // scriptsText.add(mAssetsFileReader.ReadFile(scriptName)); // } // } // } // // Path: app/src/androidTest/java/com/evgenii/aescrypto/mocks/AssetsFileReaderMock.java // public class AssetsFileReaderMock implements AssetsFileReaderInterface { // @Override // public String ReadFile(String fileName) throws IOException { // return fileName + " script"; // } // // } // // Path: app/src/androidTest/java/com/evgenii/aescrypto/mocks/JsEvaluatorMock.java // public class JsEvaluatorMock implements JsEvaluatorInterface { // public ArrayList<String> mEvaluatedScripts = new ArrayList<String>(); // public ArrayList<JsCallback> mEvaluateCallbacks = new ArrayList<JsCallback>(); // public Object[] mEvaluateArguments = null; // // @Override // public void callFunction(String jsCode, JsCallback callabck, String script, // Object... jsArguments) { // mEvaluateCallbacks.add(callabck); // mEvaluatedScripts.add(script); // mEvaluateArguments = jsArguments; // } // // @Override // public void evaluate(String script) { // mEvaluatedScripts.add(script); // mEvaluateCallbacks.add(null); // } // // @Override // public void evaluate(String script, JsCallback callback) { // mEvaluatedScripts.add(script); // mEvaluateCallbacks.add(callback); // } // // @Override // public void destroy() { // // } // // @Override // public WebView getWebView() { // return null; // } // // } // Path: app/src/androidTest/java/com/evgenii/aescrypto/JSEncryptorTests.java import java.io.IOException; import java.util.ArrayList; import android.test.AndroidTestCase; import com.evgenii.aescrypto.JsEncryptor; import com.evgenii.aescrypto.mocks.AssetsFileReaderMock; import com.evgenii.aescrypto.mocks.JsEvaluatorMock; import com.evgenii.jsevaluator.interfaces.JsCallback; package com.evgenii.aescrypto; public class JSEncryptorTests extends AndroidTestCase { JsEncryptor mJsEncryptor;
AssetsFileReaderMock mAssetsFileReaderMock;
evgenyneu/aes-crypto-android
app/src/androidTest/java/com/evgenii/aescrypto/JSEncryptorTests.java
// Path: app/src/main/java/com/evgenii/aescrypto/JsEncryptor.java // public class JsEncryptor implements JsEncryptorInterface { // public static JsEncryptor evaluateAllScripts(Activity context) { // final AssetsFileReader assetsFileReader = new AssetsFileReader(context); // final JsEvaluator jsEvaluator = new JsEvaluator(context); // final JsEncryptor jsEncryptor = new JsEncryptor(assetsFileReader, jsEvaluator); // try { // jsEncryptor.readScripts(); // } catch (final IOException e) { // ShowFatalError.showAlertAndExit(context, "Can not read JavaScript file.", e); // } // return jsEncryptor; // } // // private final AssetsFileReaderInterface mAssetsFileReader; // private final JsEvaluatorInterface mJsEvaluator; // private final String cryptoJsFileNames = "crypto_js"; // private final String aesCryptoFileName = "aes_crypto"; // private final String jsRootDir = "javascript"; // // private static final String prefix = "AESCryptoV10"; // // private ArrayList<String> mScriptsText; // // public JsEncryptor(AssetsFileReaderInterface assetsFileReader, JsEvaluatorInterface jsEvaluator) { // mAssetsFileReader = assetsFileReader; // mJsEvaluator = jsEvaluator; // } // // public String concatenateScripts() { // final StringBuilder stringBuilder = new StringBuilder(); // final ArrayList<String> scripts = getScripts(); // for (final String scriptText : scripts) { // stringBuilder.append(scriptText); // stringBuilder.append("; "); // } // // return stringBuilder.toString(); // } // // @Override // public void decrypt(String text, String password, JsCallback callback) { // final String libraryJsCode = concatenateScripts(); // mJsEvaluator.callFunction(libraryJsCode, callback, "aesCrypto.decrypt", text, password); // } // // @Override // public void encrypt(String text, String password, JsCallback callback) { // final String libraryJsCode = concatenateScripts(); // mJsEvaluator.callFunction(libraryJsCode, callback, "aesCrypto.encrypt", text, password); // } // // public ArrayList<String> getScripts() { // if (mScriptsText == null) { // mScriptsText = new ArrayList<String>(); // } // return mScriptsText; // } // // @Override // public boolean isEncrypted(String text) { // if (text == null) // return false; // // return text.trim().startsWith(prefix); // } // // public void readScripts() throws IOException { // final ArrayList<String> scriptsToLoad = new ArrayList<String>(); // // scriptsToLoad.add(jsRootDir + "/" + cryptoJsFileNames + ".js"); // scriptsToLoad.add(jsRootDir + "/" + aesCryptoFileName + ".js"); // // final ArrayList<String> scriptsText = getScripts(); // // for (final String scriptName : scriptsToLoad) { // scriptsText.add(mAssetsFileReader.ReadFile(scriptName)); // } // } // } // // Path: app/src/androidTest/java/com/evgenii/aescrypto/mocks/AssetsFileReaderMock.java // public class AssetsFileReaderMock implements AssetsFileReaderInterface { // @Override // public String ReadFile(String fileName) throws IOException { // return fileName + " script"; // } // // } // // Path: app/src/androidTest/java/com/evgenii/aescrypto/mocks/JsEvaluatorMock.java // public class JsEvaluatorMock implements JsEvaluatorInterface { // public ArrayList<String> mEvaluatedScripts = new ArrayList<String>(); // public ArrayList<JsCallback> mEvaluateCallbacks = new ArrayList<JsCallback>(); // public Object[] mEvaluateArguments = null; // // @Override // public void callFunction(String jsCode, JsCallback callabck, String script, // Object... jsArguments) { // mEvaluateCallbacks.add(callabck); // mEvaluatedScripts.add(script); // mEvaluateArguments = jsArguments; // } // // @Override // public void evaluate(String script) { // mEvaluatedScripts.add(script); // mEvaluateCallbacks.add(null); // } // // @Override // public void evaluate(String script, JsCallback callback) { // mEvaluatedScripts.add(script); // mEvaluateCallbacks.add(callback); // } // // @Override // public void destroy() { // // } // // @Override // public WebView getWebView() { // return null; // } // // }
import java.io.IOException; import java.util.ArrayList; import android.test.AndroidTestCase; import com.evgenii.aescrypto.JsEncryptor; import com.evgenii.aescrypto.mocks.AssetsFileReaderMock; import com.evgenii.aescrypto.mocks.JsEvaluatorMock; import com.evgenii.jsevaluator.interfaces.JsCallback;
package com.evgenii.aescrypto; public class JSEncryptorTests extends AndroidTestCase { JsEncryptor mJsEncryptor; AssetsFileReaderMock mAssetsFileReaderMock;
// Path: app/src/main/java/com/evgenii/aescrypto/JsEncryptor.java // public class JsEncryptor implements JsEncryptorInterface { // public static JsEncryptor evaluateAllScripts(Activity context) { // final AssetsFileReader assetsFileReader = new AssetsFileReader(context); // final JsEvaluator jsEvaluator = new JsEvaluator(context); // final JsEncryptor jsEncryptor = new JsEncryptor(assetsFileReader, jsEvaluator); // try { // jsEncryptor.readScripts(); // } catch (final IOException e) { // ShowFatalError.showAlertAndExit(context, "Can not read JavaScript file.", e); // } // return jsEncryptor; // } // // private final AssetsFileReaderInterface mAssetsFileReader; // private final JsEvaluatorInterface mJsEvaluator; // private final String cryptoJsFileNames = "crypto_js"; // private final String aesCryptoFileName = "aes_crypto"; // private final String jsRootDir = "javascript"; // // private static final String prefix = "AESCryptoV10"; // // private ArrayList<String> mScriptsText; // // public JsEncryptor(AssetsFileReaderInterface assetsFileReader, JsEvaluatorInterface jsEvaluator) { // mAssetsFileReader = assetsFileReader; // mJsEvaluator = jsEvaluator; // } // // public String concatenateScripts() { // final StringBuilder stringBuilder = new StringBuilder(); // final ArrayList<String> scripts = getScripts(); // for (final String scriptText : scripts) { // stringBuilder.append(scriptText); // stringBuilder.append("; "); // } // // return stringBuilder.toString(); // } // // @Override // public void decrypt(String text, String password, JsCallback callback) { // final String libraryJsCode = concatenateScripts(); // mJsEvaluator.callFunction(libraryJsCode, callback, "aesCrypto.decrypt", text, password); // } // // @Override // public void encrypt(String text, String password, JsCallback callback) { // final String libraryJsCode = concatenateScripts(); // mJsEvaluator.callFunction(libraryJsCode, callback, "aesCrypto.encrypt", text, password); // } // // public ArrayList<String> getScripts() { // if (mScriptsText == null) { // mScriptsText = new ArrayList<String>(); // } // return mScriptsText; // } // // @Override // public boolean isEncrypted(String text) { // if (text == null) // return false; // // return text.trim().startsWith(prefix); // } // // public void readScripts() throws IOException { // final ArrayList<String> scriptsToLoad = new ArrayList<String>(); // // scriptsToLoad.add(jsRootDir + "/" + cryptoJsFileNames + ".js"); // scriptsToLoad.add(jsRootDir + "/" + aesCryptoFileName + ".js"); // // final ArrayList<String> scriptsText = getScripts(); // // for (final String scriptName : scriptsToLoad) { // scriptsText.add(mAssetsFileReader.ReadFile(scriptName)); // } // } // } // // Path: app/src/androidTest/java/com/evgenii/aescrypto/mocks/AssetsFileReaderMock.java // public class AssetsFileReaderMock implements AssetsFileReaderInterface { // @Override // public String ReadFile(String fileName) throws IOException { // return fileName + " script"; // } // // } // // Path: app/src/androidTest/java/com/evgenii/aescrypto/mocks/JsEvaluatorMock.java // public class JsEvaluatorMock implements JsEvaluatorInterface { // public ArrayList<String> mEvaluatedScripts = new ArrayList<String>(); // public ArrayList<JsCallback> mEvaluateCallbacks = new ArrayList<JsCallback>(); // public Object[] mEvaluateArguments = null; // // @Override // public void callFunction(String jsCode, JsCallback callabck, String script, // Object... jsArguments) { // mEvaluateCallbacks.add(callabck); // mEvaluatedScripts.add(script); // mEvaluateArguments = jsArguments; // } // // @Override // public void evaluate(String script) { // mEvaluatedScripts.add(script); // mEvaluateCallbacks.add(null); // } // // @Override // public void evaluate(String script, JsCallback callback) { // mEvaluatedScripts.add(script); // mEvaluateCallbacks.add(callback); // } // // @Override // public void destroy() { // // } // // @Override // public WebView getWebView() { // return null; // } // // } // Path: app/src/androidTest/java/com/evgenii/aescrypto/JSEncryptorTests.java import java.io.IOException; import java.util.ArrayList; import android.test.AndroidTestCase; import com.evgenii.aescrypto.JsEncryptor; import com.evgenii.aescrypto.mocks.AssetsFileReaderMock; import com.evgenii.aescrypto.mocks.JsEvaluatorMock; import com.evgenii.jsevaluator.interfaces.JsCallback; package com.evgenii.aescrypto; public class JSEncryptorTests extends AndroidTestCase { JsEncryptor mJsEncryptor; AssetsFileReaderMock mAssetsFileReaderMock;
JsEvaluatorMock mJsEvaluatorMock;
evgenyneu/aes-crypto-android
app/src/androidTest/java/com/evgenii/aescrypto/DecryptTests.java
// Path: app/src/main/java/com/evgenii/aescrypto/Decrypt.java // public class Decrypt { // private final MainActivityInterface mActivity; // private final JsEncryptorInterface mJsEncryptor; // // public Decrypt(MainActivityInterface activity, JsEncryptorInterface jsEncryptor) { // mActivity = activity; // mJsEncryptor = jsEncryptor; // } // // public void decryptAndUpdate() { // if (!isDecryptable()) // return; // // mActivity.updateBusy(true); // mJsEncryptor.decrypt(mActivity.trimmedMessage(), mActivity.trimmedPassword(), // new JsCallback() { // @Override // public void onResult(final String decryptedTextFromJs) { // mActivity.updateBusy(false); // // if (decryptedTextFromJs != null && !decryptedTextFromJs.trim().isEmpty()) { // mActivity.setMessage(decryptedTextFromJs); // } // } // // @Override // public void onError(String errorMessage) { // // Process JavaScript error here. // // This method is called in the UI thread. // } // }); // } // // public boolean isDecryptable() { // if (mActivity.isBusy()) // return false; // // if (!mActivity.hasPassword()) // return false; // // if (!mJsEncryptor.isEncrypted(mActivity.trimmedMessage())) // return false; // // return true; // } // } // // Path: app/src/androidTest/java/com/evgenii/aescrypto/mocks/JsEncryptorMock.java // public class JsEncryptorMock implements JsEncryptorInterface { // public boolean mTestIsEcrypted; // // public String mTestDecryptText; // public String mTestDecryptPassword; // public JsCallback mTestDecryptCallback; // // public String mTestEncryptText; // public String mTestEncryptPassword; // public JsCallback mTestEncryptCallback; // // @Override // public void decrypt(String text, String password, JsCallback callback) { // mTestDecryptText = text; // mTestDecryptPassword = password; // mTestDecryptCallback = callback; // } // // @Override // public void encrypt(String text, String password, JsCallback callback) { // mTestEncryptText = text; // mTestEncryptPassword = password; // mTestEncryptCallback = callback; // } // // @Override // public boolean isEncrypted(String text) { // return mTestIsEcrypted; // } // // } // // Path: app/src/androidTest/java/com/evgenii/aescrypto/mocks/MainActivityMock.java // public class MainActivityMock implements MainActivityInterface { // public boolean mTestIsBusy; // public String mTestTrimmedMessage; // public String mTestTrimmedPassword; // public String mTestMessage; // public boolean mEncryptButtonTitleUpdated; // public boolean mTestHasMessage; // public boolean mTestHasPassword; // // @Override // public boolean hasMessage() { // return mTestHasMessage; // } // // @Override // public boolean hasPassword() { // return mTestHasPassword; // } // // @Override // public boolean isBusy() { // return mTestIsBusy; // } // // @Override // public void setMessage(String message) { // mTestMessage = message; // } // // @Override // public String trimmedMessage() { // return mTestTrimmedMessage; // } // // @Override // public String trimmedPassword() { // return mTestTrimmedPassword; // } // // @Override // public void updateBusy(boolean isBusy) { // // TODO Auto-generated method stub // // } // // @Override // public void updateEncryptButtonTitle() { // mEncryptButtonTitleUpdated = true; // } // }
import android.test.AndroidTestCase; import com.evgenii.aescrypto.Decrypt; import com.evgenii.aescrypto.mocks.JsEncryptorMock; import com.evgenii.aescrypto.mocks.MainActivityMock;
package com.evgenii.aescrypto; public class DecryptTests extends AndroidTestCase { protected Decrypt mDecrypt;
// Path: app/src/main/java/com/evgenii/aescrypto/Decrypt.java // public class Decrypt { // private final MainActivityInterface mActivity; // private final JsEncryptorInterface mJsEncryptor; // // public Decrypt(MainActivityInterface activity, JsEncryptorInterface jsEncryptor) { // mActivity = activity; // mJsEncryptor = jsEncryptor; // } // // public void decryptAndUpdate() { // if (!isDecryptable()) // return; // // mActivity.updateBusy(true); // mJsEncryptor.decrypt(mActivity.trimmedMessage(), mActivity.trimmedPassword(), // new JsCallback() { // @Override // public void onResult(final String decryptedTextFromJs) { // mActivity.updateBusy(false); // // if (decryptedTextFromJs != null && !decryptedTextFromJs.trim().isEmpty()) { // mActivity.setMessage(decryptedTextFromJs); // } // } // // @Override // public void onError(String errorMessage) { // // Process JavaScript error here. // // This method is called in the UI thread. // } // }); // } // // public boolean isDecryptable() { // if (mActivity.isBusy()) // return false; // // if (!mActivity.hasPassword()) // return false; // // if (!mJsEncryptor.isEncrypted(mActivity.trimmedMessage())) // return false; // // return true; // } // } // // Path: app/src/androidTest/java/com/evgenii/aescrypto/mocks/JsEncryptorMock.java // public class JsEncryptorMock implements JsEncryptorInterface { // public boolean mTestIsEcrypted; // // public String mTestDecryptText; // public String mTestDecryptPassword; // public JsCallback mTestDecryptCallback; // // public String mTestEncryptText; // public String mTestEncryptPassword; // public JsCallback mTestEncryptCallback; // // @Override // public void decrypt(String text, String password, JsCallback callback) { // mTestDecryptText = text; // mTestDecryptPassword = password; // mTestDecryptCallback = callback; // } // // @Override // public void encrypt(String text, String password, JsCallback callback) { // mTestEncryptText = text; // mTestEncryptPassword = password; // mTestEncryptCallback = callback; // } // // @Override // public boolean isEncrypted(String text) { // return mTestIsEcrypted; // } // // } // // Path: app/src/androidTest/java/com/evgenii/aescrypto/mocks/MainActivityMock.java // public class MainActivityMock implements MainActivityInterface { // public boolean mTestIsBusy; // public String mTestTrimmedMessage; // public String mTestTrimmedPassword; // public String mTestMessage; // public boolean mEncryptButtonTitleUpdated; // public boolean mTestHasMessage; // public boolean mTestHasPassword; // // @Override // public boolean hasMessage() { // return mTestHasMessage; // } // // @Override // public boolean hasPassword() { // return mTestHasPassword; // } // // @Override // public boolean isBusy() { // return mTestIsBusy; // } // // @Override // public void setMessage(String message) { // mTestMessage = message; // } // // @Override // public String trimmedMessage() { // return mTestTrimmedMessage; // } // // @Override // public String trimmedPassword() { // return mTestTrimmedPassword; // } // // @Override // public void updateBusy(boolean isBusy) { // // TODO Auto-generated method stub // // } // // @Override // public void updateEncryptButtonTitle() { // mEncryptButtonTitleUpdated = true; // } // } // Path: app/src/androidTest/java/com/evgenii/aescrypto/DecryptTests.java import android.test.AndroidTestCase; import com.evgenii.aescrypto.Decrypt; import com.evgenii.aescrypto.mocks.JsEncryptorMock; import com.evgenii.aescrypto.mocks.MainActivityMock; package com.evgenii.aescrypto; public class DecryptTests extends AndroidTestCase { protected Decrypt mDecrypt;
protected MainActivityMock mMainActivityMock;
evgenyneu/aes-crypto-android
app/src/androidTest/java/com/evgenii/aescrypto/DecryptTests.java
// Path: app/src/main/java/com/evgenii/aescrypto/Decrypt.java // public class Decrypt { // private final MainActivityInterface mActivity; // private final JsEncryptorInterface mJsEncryptor; // // public Decrypt(MainActivityInterface activity, JsEncryptorInterface jsEncryptor) { // mActivity = activity; // mJsEncryptor = jsEncryptor; // } // // public void decryptAndUpdate() { // if (!isDecryptable()) // return; // // mActivity.updateBusy(true); // mJsEncryptor.decrypt(mActivity.trimmedMessage(), mActivity.trimmedPassword(), // new JsCallback() { // @Override // public void onResult(final String decryptedTextFromJs) { // mActivity.updateBusy(false); // // if (decryptedTextFromJs != null && !decryptedTextFromJs.trim().isEmpty()) { // mActivity.setMessage(decryptedTextFromJs); // } // } // // @Override // public void onError(String errorMessage) { // // Process JavaScript error here. // // This method is called in the UI thread. // } // }); // } // // public boolean isDecryptable() { // if (mActivity.isBusy()) // return false; // // if (!mActivity.hasPassword()) // return false; // // if (!mJsEncryptor.isEncrypted(mActivity.trimmedMessage())) // return false; // // return true; // } // } // // Path: app/src/androidTest/java/com/evgenii/aescrypto/mocks/JsEncryptorMock.java // public class JsEncryptorMock implements JsEncryptorInterface { // public boolean mTestIsEcrypted; // // public String mTestDecryptText; // public String mTestDecryptPassword; // public JsCallback mTestDecryptCallback; // // public String mTestEncryptText; // public String mTestEncryptPassword; // public JsCallback mTestEncryptCallback; // // @Override // public void decrypt(String text, String password, JsCallback callback) { // mTestDecryptText = text; // mTestDecryptPassword = password; // mTestDecryptCallback = callback; // } // // @Override // public void encrypt(String text, String password, JsCallback callback) { // mTestEncryptText = text; // mTestEncryptPassword = password; // mTestEncryptCallback = callback; // } // // @Override // public boolean isEncrypted(String text) { // return mTestIsEcrypted; // } // // } // // Path: app/src/androidTest/java/com/evgenii/aescrypto/mocks/MainActivityMock.java // public class MainActivityMock implements MainActivityInterface { // public boolean mTestIsBusy; // public String mTestTrimmedMessage; // public String mTestTrimmedPassword; // public String mTestMessage; // public boolean mEncryptButtonTitleUpdated; // public boolean mTestHasMessage; // public boolean mTestHasPassword; // // @Override // public boolean hasMessage() { // return mTestHasMessage; // } // // @Override // public boolean hasPassword() { // return mTestHasPassword; // } // // @Override // public boolean isBusy() { // return mTestIsBusy; // } // // @Override // public void setMessage(String message) { // mTestMessage = message; // } // // @Override // public String trimmedMessage() { // return mTestTrimmedMessage; // } // // @Override // public String trimmedPassword() { // return mTestTrimmedPassword; // } // // @Override // public void updateBusy(boolean isBusy) { // // TODO Auto-generated method stub // // } // // @Override // public void updateEncryptButtonTitle() { // mEncryptButtonTitleUpdated = true; // } // }
import android.test.AndroidTestCase; import com.evgenii.aescrypto.Decrypt; import com.evgenii.aescrypto.mocks.JsEncryptorMock; import com.evgenii.aescrypto.mocks.MainActivityMock;
package com.evgenii.aescrypto; public class DecryptTests extends AndroidTestCase { protected Decrypt mDecrypt; protected MainActivityMock mMainActivityMock;
// Path: app/src/main/java/com/evgenii/aescrypto/Decrypt.java // public class Decrypt { // private final MainActivityInterface mActivity; // private final JsEncryptorInterface mJsEncryptor; // // public Decrypt(MainActivityInterface activity, JsEncryptorInterface jsEncryptor) { // mActivity = activity; // mJsEncryptor = jsEncryptor; // } // // public void decryptAndUpdate() { // if (!isDecryptable()) // return; // // mActivity.updateBusy(true); // mJsEncryptor.decrypt(mActivity.trimmedMessage(), mActivity.trimmedPassword(), // new JsCallback() { // @Override // public void onResult(final String decryptedTextFromJs) { // mActivity.updateBusy(false); // // if (decryptedTextFromJs != null && !decryptedTextFromJs.trim().isEmpty()) { // mActivity.setMessage(decryptedTextFromJs); // } // } // // @Override // public void onError(String errorMessage) { // // Process JavaScript error here. // // This method is called in the UI thread. // } // }); // } // // public boolean isDecryptable() { // if (mActivity.isBusy()) // return false; // // if (!mActivity.hasPassword()) // return false; // // if (!mJsEncryptor.isEncrypted(mActivity.trimmedMessage())) // return false; // // return true; // } // } // // Path: app/src/androidTest/java/com/evgenii/aescrypto/mocks/JsEncryptorMock.java // public class JsEncryptorMock implements JsEncryptorInterface { // public boolean mTestIsEcrypted; // // public String mTestDecryptText; // public String mTestDecryptPassword; // public JsCallback mTestDecryptCallback; // // public String mTestEncryptText; // public String mTestEncryptPassword; // public JsCallback mTestEncryptCallback; // // @Override // public void decrypt(String text, String password, JsCallback callback) { // mTestDecryptText = text; // mTestDecryptPassword = password; // mTestDecryptCallback = callback; // } // // @Override // public void encrypt(String text, String password, JsCallback callback) { // mTestEncryptText = text; // mTestEncryptPassword = password; // mTestEncryptCallback = callback; // } // // @Override // public boolean isEncrypted(String text) { // return mTestIsEcrypted; // } // // } // // Path: app/src/androidTest/java/com/evgenii/aescrypto/mocks/MainActivityMock.java // public class MainActivityMock implements MainActivityInterface { // public boolean mTestIsBusy; // public String mTestTrimmedMessage; // public String mTestTrimmedPassword; // public String mTestMessage; // public boolean mEncryptButtonTitleUpdated; // public boolean mTestHasMessage; // public boolean mTestHasPassword; // // @Override // public boolean hasMessage() { // return mTestHasMessage; // } // // @Override // public boolean hasPassword() { // return mTestHasPassword; // } // // @Override // public boolean isBusy() { // return mTestIsBusy; // } // // @Override // public void setMessage(String message) { // mTestMessage = message; // } // // @Override // public String trimmedMessage() { // return mTestTrimmedMessage; // } // // @Override // public String trimmedPassword() { // return mTestTrimmedPassword; // } // // @Override // public void updateBusy(boolean isBusy) { // // TODO Auto-generated method stub // // } // // @Override // public void updateEncryptButtonTitle() { // mEncryptButtonTitleUpdated = true; // } // } // Path: app/src/androidTest/java/com/evgenii/aescrypto/DecryptTests.java import android.test.AndroidTestCase; import com.evgenii.aescrypto.Decrypt; import com.evgenii.aescrypto.mocks.JsEncryptorMock; import com.evgenii.aescrypto.mocks.MainActivityMock; package com.evgenii.aescrypto; public class DecryptTests extends AndroidTestCase { protected Decrypt mDecrypt; protected MainActivityMock mMainActivityMock;
protected JsEncryptorMock mJsEncryptorMock;
evgenyneu/aes-crypto-android
app/src/androidTest/java/com/evgenii/aescrypto/EncryptTests.java
// Path: app/src/main/java/com/evgenii/aescrypto/Encrypt.java // public class Encrypt { // private final MainActivityInterface mActivity; // private final JsEncryptorInterface mJsEncryptor; // private final ClipboardInterface mClipboard; // private boolean mJustCopied; // // public Encrypt(MainActivityInterface activity, JsEncryptorInterface jsEncryptor, // ClipboardInterface clipboard) { // mActivity = activity; // mJsEncryptor = jsEncryptor; // mClipboard = clipboard; // } // // public void encryptAndUpdate() { // if (!isEncryptable()) // return; // // mActivity.updateBusy(true); // mJsEncryptor.encrypt(mActivity.trimmedMessage(), mActivity.trimmedPassword(), // new JsCallback() { // @Override // public void onResult(final String encryptedMessage) { // storeMessageInClipboard(encryptedMessage); // mActivity.setMessage(encryptedMessage); // mActivity.updateEncryptButtonTitle(); // mActivity.updateBusy(false); // } // // @Override // public void onError(String errorMessage) { // // Process JavaScript error here. // // This method is called in the UI thread. // } // }); // } // // public boolean getJustCopied() { // return mJustCopied; // } // // public boolean isEncryptable() { // return mActivity.hasMessage() && mActivity.hasPassword() && !mActivity.isBusy(); // } // // private void storeMessageInClipboard(String message) { // mClipboard.set(message); // updateJustCopied(true); // } // // public void updateJustCopied(boolean justCopied) { // mJustCopied = justCopied; // } // // } // // Path: app/src/androidTest/java/com/evgenii/aescrypto/mocks/ClipboardMock.java // public class ClipboardMock implements ClipboardInterface { // public String mTestClipboardContent; // // @Override // public String get() { // return mTestClipboardContent; // } // // @Override // public void set(String text) { // mTestClipboardContent = text; // } // // } // // Path: app/src/androidTest/java/com/evgenii/aescrypto/mocks/JsEncryptorMock.java // public class JsEncryptorMock implements JsEncryptorInterface { // public boolean mTestIsEcrypted; // // public String mTestDecryptText; // public String mTestDecryptPassword; // public JsCallback mTestDecryptCallback; // // public String mTestEncryptText; // public String mTestEncryptPassword; // public JsCallback mTestEncryptCallback; // // @Override // public void decrypt(String text, String password, JsCallback callback) { // mTestDecryptText = text; // mTestDecryptPassword = password; // mTestDecryptCallback = callback; // } // // @Override // public void encrypt(String text, String password, JsCallback callback) { // mTestEncryptText = text; // mTestEncryptPassword = password; // mTestEncryptCallback = callback; // } // // @Override // public boolean isEncrypted(String text) { // return mTestIsEcrypted; // } // // } // // Path: app/src/androidTest/java/com/evgenii/aescrypto/mocks/MainActivityMock.java // public class MainActivityMock implements MainActivityInterface { // public boolean mTestIsBusy; // public String mTestTrimmedMessage; // public String mTestTrimmedPassword; // public String mTestMessage; // public boolean mEncryptButtonTitleUpdated; // public boolean mTestHasMessage; // public boolean mTestHasPassword; // // @Override // public boolean hasMessage() { // return mTestHasMessage; // } // // @Override // public boolean hasPassword() { // return mTestHasPassword; // } // // @Override // public boolean isBusy() { // return mTestIsBusy; // } // // @Override // public void setMessage(String message) { // mTestMessage = message; // } // // @Override // public String trimmedMessage() { // return mTestTrimmedMessage; // } // // @Override // public String trimmedPassword() { // return mTestTrimmedPassword; // } // // @Override // public void updateBusy(boolean isBusy) { // // TODO Auto-generated method stub // // } // // @Override // public void updateEncryptButtonTitle() { // mEncryptButtonTitleUpdated = true; // } // }
import android.test.AndroidTestCase; import com.evgenii.aescrypto.Encrypt; import com.evgenii.aescrypto.mocks.ClipboardMock; import com.evgenii.aescrypto.mocks.JsEncryptorMock; import com.evgenii.aescrypto.mocks.MainActivityMock;
package com.evgenii.aescrypto; public class EncryptTests extends AndroidTestCase { protected Encrypt mEncrypt;
// Path: app/src/main/java/com/evgenii/aescrypto/Encrypt.java // public class Encrypt { // private final MainActivityInterface mActivity; // private final JsEncryptorInterface mJsEncryptor; // private final ClipboardInterface mClipboard; // private boolean mJustCopied; // // public Encrypt(MainActivityInterface activity, JsEncryptorInterface jsEncryptor, // ClipboardInterface clipboard) { // mActivity = activity; // mJsEncryptor = jsEncryptor; // mClipboard = clipboard; // } // // public void encryptAndUpdate() { // if (!isEncryptable()) // return; // // mActivity.updateBusy(true); // mJsEncryptor.encrypt(mActivity.trimmedMessage(), mActivity.trimmedPassword(), // new JsCallback() { // @Override // public void onResult(final String encryptedMessage) { // storeMessageInClipboard(encryptedMessage); // mActivity.setMessage(encryptedMessage); // mActivity.updateEncryptButtonTitle(); // mActivity.updateBusy(false); // } // // @Override // public void onError(String errorMessage) { // // Process JavaScript error here. // // This method is called in the UI thread. // } // }); // } // // public boolean getJustCopied() { // return mJustCopied; // } // // public boolean isEncryptable() { // return mActivity.hasMessage() && mActivity.hasPassword() && !mActivity.isBusy(); // } // // private void storeMessageInClipboard(String message) { // mClipboard.set(message); // updateJustCopied(true); // } // // public void updateJustCopied(boolean justCopied) { // mJustCopied = justCopied; // } // // } // // Path: app/src/androidTest/java/com/evgenii/aescrypto/mocks/ClipboardMock.java // public class ClipboardMock implements ClipboardInterface { // public String mTestClipboardContent; // // @Override // public String get() { // return mTestClipboardContent; // } // // @Override // public void set(String text) { // mTestClipboardContent = text; // } // // } // // Path: app/src/androidTest/java/com/evgenii/aescrypto/mocks/JsEncryptorMock.java // public class JsEncryptorMock implements JsEncryptorInterface { // public boolean mTestIsEcrypted; // // public String mTestDecryptText; // public String mTestDecryptPassword; // public JsCallback mTestDecryptCallback; // // public String mTestEncryptText; // public String mTestEncryptPassword; // public JsCallback mTestEncryptCallback; // // @Override // public void decrypt(String text, String password, JsCallback callback) { // mTestDecryptText = text; // mTestDecryptPassword = password; // mTestDecryptCallback = callback; // } // // @Override // public void encrypt(String text, String password, JsCallback callback) { // mTestEncryptText = text; // mTestEncryptPassword = password; // mTestEncryptCallback = callback; // } // // @Override // public boolean isEncrypted(String text) { // return mTestIsEcrypted; // } // // } // // Path: app/src/androidTest/java/com/evgenii/aescrypto/mocks/MainActivityMock.java // public class MainActivityMock implements MainActivityInterface { // public boolean mTestIsBusy; // public String mTestTrimmedMessage; // public String mTestTrimmedPassword; // public String mTestMessage; // public boolean mEncryptButtonTitleUpdated; // public boolean mTestHasMessage; // public boolean mTestHasPassword; // // @Override // public boolean hasMessage() { // return mTestHasMessage; // } // // @Override // public boolean hasPassword() { // return mTestHasPassword; // } // // @Override // public boolean isBusy() { // return mTestIsBusy; // } // // @Override // public void setMessage(String message) { // mTestMessage = message; // } // // @Override // public String trimmedMessage() { // return mTestTrimmedMessage; // } // // @Override // public String trimmedPassword() { // return mTestTrimmedPassword; // } // // @Override // public void updateBusy(boolean isBusy) { // // TODO Auto-generated method stub // // } // // @Override // public void updateEncryptButtonTitle() { // mEncryptButtonTitleUpdated = true; // } // } // Path: app/src/androidTest/java/com/evgenii/aescrypto/EncryptTests.java import android.test.AndroidTestCase; import com.evgenii.aescrypto.Encrypt; import com.evgenii.aescrypto.mocks.ClipboardMock; import com.evgenii.aescrypto.mocks.JsEncryptorMock; import com.evgenii.aescrypto.mocks.MainActivityMock; package com.evgenii.aescrypto; public class EncryptTests extends AndroidTestCase { protected Encrypt mEncrypt;
protected MainActivityMock mMainActivityMock;
evgenyneu/aes-crypto-android
app/src/androidTest/java/com/evgenii/aescrypto/EncryptTests.java
// Path: app/src/main/java/com/evgenii/aescrypto/Encrypt.java // public class Encrypt { // private final MainActivityInterface mActivity; // private final JsEncryptorInterface mJsEncryptor; // private final ClipboardInterface mClipboard; // private boolean mJustCopied; // // public Encrypt(MainActivityInterface activity, JsEncryptorInterface jsEncryptor, // ClipboardInterface clipboard) { // mActivity = activity; // mJsEncryptor = jsEncryptor; // mClipboard = clipboard; // } // // public void encryptAndUpdate() { // if (!isEncryptable()) // return; // // mActivity.updateBusy(true); // mJsEncryptor.encrypt(mActivity.trimmedMessage(), mActivity.trimmedPassword(), // new JsCallback() { // @Override // public void onResult(final String encryptedMessage) { // storeMessageInClipboard(encryptedMessage); // mActivity.setMessage(encryptedMessage); // mActivity.updateEncryptButtonTitle(); // mActivity.updateBusy(false); // } // // @Override // public void onError(String errorMessage) { // // Process JavaScript error here. // // This method is called in the UI thread. // } // }); // } // // public boolean getJustCopied() { // return mJustCopied; // } // // public boolean isEncryptable() { // return mActivity.hasMessage() && mActivity.hasPassword() && !mActivity.isBusy(); // } // // private void storeMessageInClipboard(String message) { // mClipboard.set(message); // updateJustCopied(true); // } // // public void updateJustCopied(boolean justCopied) { // mJustCopied = justCopied; // } // // } // // Path: app/src/androidTest/java/com/evgenii/aescrypto/mocks/ClipboardMock.java // public class ClipboardMock implements ClipboardInterface { // public String mTestClipboardContent; // // @Override // public String get() { // return mTestClipboardContent; // } // // @Override // public void set(String text) { // mTestClipboardContent = text; // } // // } // // Path: app/src/androidTest/java/com/evgenii/aescrypto/mocks/JsEncryptorMock.java // public class JsEncryptorMock implements JsEncryptorInterface { // public boolean mTestIsEcrypted; // // public String mTestDecryptText; // public String mTestDecryptPassword; // public JsCallback mTestDecryptCallback; // // public String mTestEncryptText; // public String mTestEncryptPassword; // public JsCallback mTestEncryptCallback; // // @Override // public void decrypt(String text, String password, JsCallback callback) { // mTestDecryptText = text; // mTestDecryptPassword = password; // mTestDecryptCallback = callback; // } // // @Override // public void encrypt(String text, String password, JsCallback callback) { // mTestEncryptText = text; // mTestEncryptPassword = password; // mTestEncryptCallback = callback; // } // // @Override // public boolean isEncrypted(String text) { // return mTestIsEcrypted; // } // // } // // Path: app/src/androidTest/java/com/evgenii/aescrypto/mocks/MainActivityMock.java // public class MainActivityMock implements MainActivityInterface { // public boolean mTestIsBusy; // public String mTestTrimmedMessage; // public String mTestTrimmedPassword; // public String mTestMessage; // public boolean mEncryptButtonTitleUpdated; // public boolean mTestHasMessage; // public boolean mTestHasPassword; // // @Override // public boolean hasMessage() { // return mTestHasMessage; // } // // @Override // public boolean hasPassword() { // return mTestHasPassword; // } // // @Override // public boolean isBusy() { // return mTestIsBusy; // } // // @Override // public void setMessage(String message) { // mTestMessage = message; // } // // @Override // public String trimmedMessage() { // return mTestTrimmedMessage; // } // // @Override // public String trimmedPassword() { // return mTestTrimmedPassword; // } // // @Override // public void updateBusy(boolean isBusy) { // // TODO Auto-generated method stub // // } // // @Override // public void updateEncryptButtonTitle() { // mEncryptButtonTitleUpdated = true; // } // }
import android.test.AndroidTestCase; import com.evgenii.aescrypto.Encrypt; import com.evgenii.aescrypto.mocks.ClipboardMock; import com.evgenii.aescrypto.mocks.JsEncryptorMock; import com.evgenii.aescrypto.mocks.MainActivityMock;
package com.evgenii.aescrypto; public class EncryptTests extends AndroidTestCase { protected Encrypt mEncrypt; protected MainActivityMock mMainActivityMock;
// Path: app/src/main/java/com/evgenii/aescrypto/Encrypt.java // public class Encrypt { // private final MainActivityInterface mActivity; // private final JsEncryptorInterface mJsEncryptor; // private final ClipboardInterface mClipboard; // private boolean mJustCopied; // // public Encrypt(MainActivityInterface activity, JsEncryptorInterface jsEncryptor, // ClipboardInterface clipboard) { // mActivity = activity; // mJsEncryptor = jsEncryptor; // mClipboard = clipboard; // } // // public void encryptAndUpdate() { // if (!isEncryptable()) // return; // // mActivity.updateBusy(true); // mJsEncryptor.encrypt(mActivity.trimmedMessage(), mActivity.trimmedPassword(), // new JsCallback() { // @Override // public void onResult(final String encryptedMessage) { // storeMessageInClipboard(encryptedMessage); // mActivity.setMessage(encryptedMessage); // mActivity.updateEncryptButtonTitle(); // mActivity.updateBusy(false); // } // // @Override // public void onError(String errorMessage) { // // Process JavaScript error here. // // This method is called in the UI thread. // } // }); // } // // public boolean getJustCopied() { // return mJustCopied; // } // // public boolean isEncryptable() { // return mActivity.hasMessage() && mActivity.hasPassword() && !mActivity.isBusy(); // } // // private void storeMessageInClipboard(String message) { // mClipboard.set(message); // updateJustCopied(true); // } // // public void updateJustCopied(boolean justCopied) { // mJustCopied = justCopied; // } // // } // // Path: app/src/androidTest/java/com/evgenii/aescrypto/mocks/ClipboardMock.java // public class ClipboardMock implements ClipboardInterface { // public String mTestClipboardContent; // // @Override // public String get() { // return mTestClipboardContent; // } // // @Override // public void set(String text) { // mTestClipboardContent = text; // } // // } // // Path: app/src/androidTest/java/com/evgenii/aescrypto/mocks/JsEncryptorMock.java // public class JsEncryptorMock implements JsEncryptorInterface { // public boolean mTestIsEcrypted; // // public String mTestDecryptText; // public String mTestDecryptPassword; // public JsCallback mTestDecryptCallback; // // public String mTestEncryptText; // public String mTestEncryptPassword; // public JsCallback mTestEncryptCallback; // // @Override // public void decrypt(String text, String password, JsCallback callback) { // mTestDecryptText = text; // mTestDecryptPassword = password; // mTestDecryptCallback = callback; // } // // @Override // public void encrypt(String text, String password, JsCallback callback) { // mTestEncryptText = text; // mTestEncryptPassword = password; // mTestEncryptCallback = callback; // } // // @Override // public boolean isEncrypted(String text) { // return mTestIsEcrypted; // } // // } // // Path: app/src/androidTest/java/com/evgenii/aescrypto/mocks/MainActivityMock.java // public class MainActivityMock implements MainActivityInterface { // public boolean mTestIsBusy; // public String mTestTrimmedMessage; // public String mTestTrimmedPassword; // public String mTestMessage; // public boolean mEncryptButtonTitleUpdated; // public boolean mTestHasMessage; // public boolean mTestHasPassword; // // @Override // public boolean hasMessage() { // return mTestHasMessage; // } // // @Override // public boolean hasPassword() { // return mTestHasPassword; // } // // @Override // public boolean isBusy() { // return mTestIsBusy; // } // // @Override // public void setMessage(String message) { // mTestMessage = message; // } // // @Override // public String trimmedMessage() { // return mTestTrimmedMessage; // } // // @Override // public String trimmedPassword() { // return mTestTrimmedPassword; // } // // @Override // public void updateBusy(boolean isBusy) { // // TODO Auto-generated method stub // // } // // @Override // public void updateEncryptButtonTitle() { // mEncryptButtonTitleUpdated = true; // } // } // Path: app/src/androidTest/java/com/evgenii/aescrypto/EncryptTests.java import android.test.AndroidTestCase; import com.evgenii.aescrypto.Encrypt; import com.evgenii.aescrypto.mocks.ClipboardMock; import com.evgenii.aescrypto.mocks.JsEncryptorMock; import com.evgenii.aescrypto.mocks.MainActivityMock; package com.evgenii.aescrypto; public class EncryptTests extends AndroidTestCase { protected Encrypt mEncrypt; protected MainActivityMock mMainActivityMock;
protected JsEncryptorMock mJsEncryptorMock;
evgenyneu/aes-crypto-android
app/src/androidTest/java/com/evgenii/aescrypto/EncryptTests.java
// Path: app/src/main/java/com/evgenii/aescrypto/Encrypt.java // public class Encrypt { // private final MainActivityInterface mActivity; // private final JsEncryptorInterface mJsEncryptor; // private final ClipboardInterface mClipboard; // private boolean mJustCopied; // // public Encrypt(MainActivityInterface activity, JsEncryptorInterface jsEncryptor, // ClipboardInterface clipboard) { // mActivity = activity; // mJsEncryptor = jsEncryptor; // mClipboard = clipboard; // } // // public void encryptAndUpdate() { // if (!isEncryptable()) // return; // // mActivity.updateBusy(true); // mJsEncryptor.encrypt(mActivity.trimmedMessage(), mActivity.trimmedPassword(), // new JsCallback() { // @Override // public void onResult(final String encryptedMessage) { // storeMessageInClipboard(encryptedMessage); // mActivity.setMessage(encryptedMessage); // mActivity.updateEncryptButtonTitle(); // mActivity.updateBusy(false); // } // // @Override // public void onError(String errorMessage) { // // Process JavaScript error here. // // This method is called in the UI thread. // } // }); // } // // public boolean getJustCopied() { // return mJustCopied; // } // // public boolean isEncryptable() { // return mActivity.hasMessage() && mActivity.hasPassword() && !mActivity.isBusy(); // } // // private void storeMessageInClipboard(String message) { // mClipboard.set(message); // updateJustCopied(true); // } // // public void updateJustCopied(boolean justCopied) { // mJustCopied = justCopied; // } // // } // // Path: app/src/androidTest/java/com/evgenii/aescrypto/mocks/ClipboardMock.java // public class ClipboardMock implements ClipboardInterface { // public String mTestClipboardContent; // // @Override // public String get() { // return mTestClipboardContent; // } // // @Override // public void set(String text) { // mTestClipboardContent = text; // } // // } // // Path: app/src/androidTest/java/com/evgenii/aescrypto/mocks/JsEncryptorMock.java // public class JsEncryptorMock implements JsEncryptorInterface { // public boolean mTestIsEcrypted; // // public String mTestDecryptText; // public String mTestDecryptPassword; // public JsCallback mTestDecryptCallback; // // public String mTestEncryptText; // public String mTestEncryptPassword; // public JsCallback mTestEncryptCallback; // // @Override // public void decrypt(String text, String password, JsCallback callback) { // mTestDecryptText = text; // mTestDecryptPassword = password; // mTestDecryptCallback = callback; // } // // @Override // public void encrypt(String text, String password, JsCallback callback) { // mTestEncryptText = text; // mTestEncryptPassword = password; // mTestEncryptCallback = callback; // } // // @Override // public boolean isEncrypted(String text) { // return mTestIsEcrypted; // } // // } // // Path: app/src/androidTest/java/com/evgenii/aescrypto/mocks/MainActivityMock.java // public class MainActivityMock implements MainActivityInterface { // public boolean mTestIsBusy; // public String mTestTrimmedMessage; // public String mTestTrimmedPassword; // public String mTestMessage; // public boolean mEncryptButtonTitleUpdated; // public boolean mTestHasMessage; // public boolean mTestHasPassword; // // @Override // public boolean hasMessage() { // return mTestHasMessage; // } // // @Override // public boolean hasPassword() { // return mTestHasPassword; // } // // @Override // public boolean isBusy() { // return mTestIsBusy; // } // // @Override // public void setMessage(String message) { // mTestMessage = message; // } // // @Override // public String trimmedMessage() { // return mTestTrimmedMessage; // } // // @Override // public String trimmedPassword() { // return mTestTrimmedPassword; // } // // @Override // public void updateBusy(boolean isBusy) { // // TODO Auto-generated method stub // // } // // @Override // public void updateEncryptButtonTitle() { // mEncryptButtonTitleUpdated = true; // } // }
import android.test.AndroidTestCase; import com.evgenii.aescrypto.Encrypt; import com.evgenii.aescrypto.mocks.ClipboardMock; import com.evgenii.aescrypto.mocks.JsEncryptorMock; import com.evgenii.aescrypto.mocks.MainActivityMock;
package com.evgenii.aescrypto; public class EncryptTests extends AndroidTestCase { protected Encrypt mEncrypt; protected MainActivityMock mMainActivityMock; protected JsEncryptorMock mJsEncryptorMock;
// Path: app/src/main/java/com/evgenii/aescrypto/Encrypt.java // public class Encrypt { // private final MainActivityInterface mActivity; // private final JsEncryptorInterface mJsEncryptor; // private final ClipboardInterface mClipboard; // private boolean mJustCopied; // // public Encrypt(MainActivityInterface activity, JsEncryptorInterface jsEncryptor, // ClipboardInterface clipboard) { // mActivity = activity; // mJsEncryptor = jsEncryptor; // mClipboard = clipboard; // } // // public void encryptAndUpdate() { // if (!isEncryptable()) // return; // // mActivity.updateBusy(true); // mJsEncryptor.encrypt(mActivity.trimmedMessage(), mActivity.trimmedPassword(), // new JsCallback() { // @Override // public void onResult(final String encryptedMessage) { // storeMessageInClipboard(encryptedMessage); // mActivity.setMessage(encryptedMessage); // mActivity.updateEncryptButtonTitle(); // mActivity.updateBusy(false); // } // // @Override // public void onError(String errorMessage) { // // Process JavaScript error here. // // This method is called in the UI thread. // } // }); // } // // public boolean getJustCopied() { // return mJustCopied; // } // // public boolean isEncryptable() { // return mActivity.hasMessage() && mActivity.hasPassword() && !mActivity.isBusy(); // } // // private void storeMessageInClipboard(String message) { // mClipboard.set(message); // updateJustCopied(true); // } // // public void updateJustCopied(boolean justCopied) { // mJustCopied = justCopied; // } // // } // // Path: app/src/androidTest/java/com/evgenii/aescrypto/mocks/ClipboardMock.java // public class ClipboardMock implements ClipboardInterface { // public String mTestClipboardContent; // // @Override // public String get() { // return mTestClipboardContent; // } // // @Override // public void set(String text) { // mTestClipboardContent = text; // } // // } // // Path: app/src/androidTest/java/com/evgenii/aescrypto/mocks/JsEncryptorMock.java // public class JsEncryptorMock implements JsEncryptorInterface { // public boolean mTestIsEcrypted; // // public String mTestDecryptText; // public String mTestDecryptPassword; // public JsCallback mTestDecryptCallback; // // public String mTestEncryptText; // public String mTestEncryptPassword; // public JsCallback mTestEncryptCallback; // // @Override // public void decrypt(String text, String password, JsCallback callback) { // mTestDecryptText = text; // mTestDecryptPassword = password; // mTestDecryptCallback = callback; // } // // @Override // public void encrypt(String text, String password, JsCallback callback) { // mTestEncryptText = text; // mTestEncryptPassword = password; // mTestEncryptCallback = callback; // } // // @Override // public boolean isEncrypted(String text) { // return mTestIsEcrypted; // } // // } // // Path: app/src/androidTest/java/com/evgenii/aescrypto/mocks/MainActivityMock.java // public class MainActivityMock implements MainActivityInterface { // public boolean mTestIsBusy; // public String mTestTrimmedMessage; // public String mTestTrimmedPassword; // public String mTestMessage; // public boolean mEncryptButtonTitleUpdated; // public boolean mTestHasMessage; // public boolean mTestHasPassword; // // @Override // public boolean hasMessage() { // return mTestHasMessage; // } // // @Override // public boolean hasPassword() { // return mTestHasPassword; // } // // @Override // public boolean isBusy() { // return mTestIsBusy; // } // // @Override // public void setMessage(String message) { // mTestMessage = message; // } // // @Override // public String trimmedMessage() { // return mTestTrimmedMessage; // } // // @Override // public String trimmedPassword() { // return mTestTrimmedPassword; // } // // @Override // public void updateBusy(boolean isBusy) { // // TODO Auto-generated method stub // // } // // @Override // public void updateEncryptButtonTitle() { // mEncryptButtonTitleUpdated = true; // } // } // Path: app/src/androidTest/java/com/evgenii/aescrypto/EncryptTests.java import android.test.AndroidTestCase; import com.evgenii.aescrypto.Encrypt; import com.evgenii.aescrypto.mocks.ClipboardMock; import com.evgenii.aescrypto.mocks.JsEncryptorMock; import com.evgenii.aescrypto.mocks.MainActivityMock; package com.evgenii.aescrypto; public class EncryptTests extends AndroidTestCase { protected Encrypt mEncrypt; protected MainActivityMock mMainActivityMock; protected JsEncryptorMock mJsEncryptorMock;
protected ClipboardMock mClipboardMock;
Despector/ObfuscationMapper
src/main/java/org/spongepowered/obfuscation/util/MethodGroupBuilder.java
// Path: src/main/java/org/spongepowered/obfuscation/merge/data/MethodGroup.java // public class MethodGroup { // // private final MethodEntry root; // private final Set<MethodEntry> methods = new HashSet<>(); // // public MethodGroup(MethodEntry root) { // this.root = root; // this.methods.add(root); // } // // public MethodEntry getArchetype() { // return this.root; // } // // public String getName() { // return this.root.getName(); // } // // public String getDescription() { // return this.root.getDescription(); // } // // public boolean isStatic() { // return this.root.isStatic(); // } // // public boolean isSynthetic() { // return this.root.isSynthetic(); // } // // public void addMethod(MethodEntry entry) { // this.methods.add(entry); // } // // public Collection<MethodEntry> getMethods() { // return this.methods; // } // // public MethodEntry getOverride(TypeEntry type) { // for (MethodEntry mth : this.methods) { // if (mth.getOwnerName().equals(type.getName())) { // return mth; // } // } // return null; // } // // }
import org.spongepowered.despector.ast.generic.TypeSignature; import org.spongepowered.despector.ast.generic.TypeVariableSignature; import org.spongepowered.despector.ast.type.ClassEntry; import org.spongepowered.despector.ast.type.MethodEntry; import org.spongepowered.despector.ast.type.TypeEntry; import org.spongepowered.obfuscation.merge.data.MethodGroup; import java.util.HashSet; import java.util.Map; import java.util.Set; import com.google.common.collect.Multimap; import org.spongepowered.despector.ast.SourceSet; import org.spongepowered.despector.ast.generic.ClassSignature; import org.spongepowered.despector.ast.generic.GenericClassTypeSignature; import org.spongepowered.despector.ast.generic.MethodSignature; import org.spongepowered.despector.ast.generic.TypeParameter;
/* * The MIT License (MIT) * * Copyright (c) SpongePowered <https://www.spongepowered.org> * Copyright (c) contributors * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ package org.spongepowered.obfuscation.util; public class MethodGroupBuilder { private final SourceSet set;
// Path: src/main/java/org/spongepowered/obfuscation/merge/data/MethodGroup.java // public class MethodGroup { // // private final MethodEntry root; // private final Set<MethodEntry> methods = new HashSet<>(); // // public MethodGroup(MethodEntry root) { // this.root = root; // this.methods.add(root); // } // // public MethodEntry getArchetype() { // return this.root; // } // // public String getName() { // return this.root.getName(); // } // // public String getDescription() { // return this.root.getDescription(); // } // // public boolean isStatic() { // return this.root.isStatic(); // } // // public boolean isSynthetic() { // return this.root.isSynthetic(); // } // // public void addMethod(MethodEntry entry) { // this.methods.add(entry); // } // // public Collection<MethodEntry> getMethods() { // return this.methods; // } // // public MethodEntry getOverride(TypeEntry type) { // for (MethodEntry mth : this.methods) { // if (mth.getOwnerName().equals(type.getName())) { // return mth; // } // } // return null; // } // // } // Path: src/main/java/org/spongepowered/obfuscation/util/MethodGroupBuilder.java import org.spongepowered.despector.ast.generic.TypeSignature; import org.spongepowered.despector.ast.generic.TypeVariableSignature; import org.spongepowered.despector.ast.type.ClassEntry; import org.spongepowered.despector.ast.type.MethodEntry; import org.spongepowered.despector.ast.type.TypeEntry; import org.spongepowered.obfuscation.merge.data.MethodGroup; import java.util.HashSet; import java.util.Map; import java.util.Set; import com.google.common.collect.Multimap; import org.spongepowered.despector.ast.SourceSet; import org.spongepowered.despector.ast.generic.ClassSignature; import org.spongepowered.despector.ast.generic.GenericClassTypeSignature; import org.spongepowered.despector.ast.generic.MethodSignature; import org.spongepowered.despector.ast.generic.TypeParameter; /* * The MIT License (MIT) * * Copyright (c) SpongePowered <https://www.spongepowered.org> * Copyright (c) contributors * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ package org.spongepowered.obfuscation.util; public class MethodGroupBuilder { private final SourceSet set;
private final Map<MethodEntry, MethodGroup> groups;
Despector/ObfuscationMapper
src/main/java/org/spongepowered/obfuscation/merge/data/MatchEntry.java
// Path: src/main/java/org/spongepowered/obfuscation/merge/MergeEngine.java // public static class DummyType extends TypeEntry { // // public DummyType(SourceSet source, Language lang, String name) { // super(source, lang, name); // } // // @Override // public void accept(AstVisitor visitor) { // } // // @Override // public void writeTo(MessagePacker pack) throws IOException { // } // // }
import java.util.Map; import static com.google.common.base.Preconditions.checkNotNull; import org.spongepowered.despector.ast.type.TypeEntry; import org.spongepowered.obfuscation.merge.MergeEngine.DummyType; import java.util.HashMap;
/* * The MIT License (MIT) * * Copyright (c) SpongePowered <https://www.spongepowered.org> * Copyright (c) contributors * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ package org.spongepowered.obfuscation.merge.data; public class MatchEntry { private final TypeEntry old_type; private TypeEntry new_type; private boolean merged = false; private int highest = 0; private TypeEntry highest_type = null; private int second = 0; private Map<TypeEntry, Integer> votes = new HashMap<>(); public MatchEntry(TypeEntry old) { this.old_type = checkNotNull(old, "old"); } public TypeEntry getOldType() { return this.old_type; } public TypeEntry getNewType() { return this.new_type; } public void setNewType(TypeEntry type) {
// Path: src/main/java/org/spongepowered/obfuscation/merge/MergeEngine.java // public static class DummyType extends TypeEntry { // // public DummyType(SourceSet source, Language lang, String name) { // super(source, lang, name); // } // // @Override // public void accept(AstVisitor visitor) { // } // // @Override // public void writeTo(MessagePacker pack) throws IOException { // } // // } // Path: src/main/java/org/spongepowered/obfuscation/merge/data/MatchEntry.java import java.util.Map; import static com.google.common.base.Preconditions.checkNotNull; import org.spongepowered.despector.ast.type.TypeEntry; import org.spongepowered.obfuscation.merge.MergeEngine.DummyType; import java.util.HashMap; /* * The MIT License (MIT) * * Copyright (c) SpongePowered <https://www.spongepowered.org> * Copyright (c) contributors * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ package org.spongepowered.obfuscation.merge.data; public class MatchEntry { private final TypeEntry old_type; private TypeEntry new_type; private boolean merged = false; private int highest = 0; private TypeEntry highest_type = null; private int second = 0; private Map<TypeEntry, Integer> votes = new HashMap<>(); public MatchEntry(TypeEntry old) { this.old_type = checkNotNull(old, "old"); } public TypeEntry getOldType() { return this.old_type; } public TypeEntry getNewType() { return this.new_type; } public void setNewType(TypeEntry type) {
if (!(this.old_type instanceof DummyType) && this.old_type.getClass() != type.getClass()) {
assemblits/eru
Eru/src/main/java/org/assemblits/eru/gui/service/ProjectCreator.java
// Path: Eru/src/main/java/org/assemblits/eru/entities/EruGroup.java // @Entity // @Table(name = "eru_group", schema = "public") // @Inheritance(strategy = InheritanceType.SINGLE_TABLE) // public class EruGroup { // // private IntegerProperty id; // private StringProperty name; // private ObjectProperty<EruType> type; // private ObjectProperty<EruGroup> parent; // private List<EruGroup> children; // // public EruGroup() { // this.id = new SimpleIntegerProperty(); // this.name = new SimpleStringProperty(); // this.type = new SimpleObjectProperty<>(EruType.UNKNOWN); // this.parent = new SimpleObjectProperty<>(); // this.children = new SimpleListProperty<>(FXCollections.observableArrayList()); // } // // @Id @GeneratedValue(strategy=GenerationType.AUTO) // public Integer getId() { // return id.get(); // } // public IntegerProperty idProperty() { // return id; // } // public void setId(Integer id) { // this.id.set(id); // } // // public String getName() { // return name.get(); // } // public StringProperty nameProperty() { // return name; // } // public void setName(String name) { // this.name.set(name); // } // // public EruType getType() { // return type.get(); // } // public ObjectProperty<EruType> typeProperty() { // return type; // } // public void setType(EruType type) { // this.type.set(type); // } // // @OneToOne(cascade= CascadeType.ALL, orphanRemoval = true) // public EruGroup getParent() { // return parent.get(); // } // public ObjectProperty<EruGroup> parentProperty() { // return parent; // } // public void setParent(EruGroup parent) { // this.parent.set(parent); // } // // @LazyCollection(LazyCollectionOption.FALSE) // @OneToMany(cascade= CascadeType.ALL, orphanRemoval = true) // public List<EruGroup> getChildren() { // return children; // } // public void setChildren(List<EruGroup> children) { // this.children = children; // } // // @Override // public String toString() { // return "EruGroup{" + getName() + // "=" + super.toString() + // ", children= <" + children + // "> }"; // } // } // // Path: Eru/src/main/java/org/assemblits/eru/entities/EruType.java // public enum EruType { // DEVICE, // CONNECTION, // TAG, // USER, // DISPLAY, // UNKNOWN // } // // Path: Eru/src/main/java/org/assemblits/eru/entities/Project.java // @Data // @Entity // @AllArgsConstructor // @Table(name = "project", schema = "public") // public class Project { // // @Id // @GeneratedValue(strategy = GenerationType.AUTO) // Integer id; // String name; // @LazyCollection(LazyCollectionOption.FALSE) // @OneToOne(cascade = CascadeType.ALL, orphanRemoval = true) // EruGroup group; // @LazyCollection(LazyCollectionOption.FALSE) // @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true) // List<Device> devices; // @LazyCollection(LazyCollectionOption.FALSE) // @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true) // List<Connection> connections; // @LazyCollection(LazyCollectionOption.FALSE) // @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true) // List<Tag> tags; // @LazyCollection(LazyCollectionOption.FALSE) // @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true) // List<User> users; // @LazyCollection(LazyCollectionOption.FALSE) // @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true) // List<Display> displays; // // public Project() { // this.id = null; // this.name = LocalDate.now().format(DateTimeFormatter.BASIC_ISO_DATE); // this.group = new EruGroup(); // this.devices = new ArrayList<>(); // this.connections = new ArrayList<>(); // this.tags = new ArrayList<>(); // this.users = new ArrayList<>(); // this.displays = new ArrayList<>(); // } // // }
import org.assemblits.eru.entities.EruGroup; import org.assemblits.eru.entities.EruType; import org.assemblits.eru.entities.Project;
/****************************************************************************** * Copyright (c) 2017 Assemblits contributors * * * * This file is part of Eru The open JavaFX SCADA by Assemblits Organization. * * * * Eru The open JavaFX SCADA is free software: you can redistribute it * * and/or modify it under the terms of the GNU General Public License * * as published by the Free Software Foundation, either version 3 * * of the License, or (at your option) any later version. * * * * Eru is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with Foobar. If not, see <http://www.gnu.org/licenses/>. * ******************************************************************************/ package org.assemblits.eru.gui.service; public class ProjectCreator { public Project defaultProject() { Project newProject = new Project(); newProject.setName("Project");
// Path: Eru/src/main/java/org/assemblits/eru/entities/EruGroup.java // @Entity // @Table(name = "eru_group", schema = "public") // @Inheritance(strategy = InheritanceType.SINGLE_TABLE) // public class EruGroup { // // private IntegerProperty id; // private StringProperty name; // private ObjectProperty<EruType> type; // private ObjectProperty<EruGroup> parent; // private List<EruGroup> children; // // public EruGroup() { // this.id = new SimpleIntegerProperty(); // this.name = new SimpleStringProperty(); // this.type = new SimpleObjectProperty<>(EruType.UNKNOWN); // this.parent = new SimpleObjectProperty<>(); // this.children = new SimpleListProperty<>(FXCollections.observableArrayList()); // } // // @Id @GeneratedValue(strategy=GenerationType.AUTO) // public Integer getId() { // return id.get(); // } // public IntegerProperty idProperty() { // return id; // } // public void setId(Integer id) { // this.id.set(id); // } // // public String getName() { // return name.get(); // } // public StringProperty nameProperty() { // return name; // } // public void setName(String name) { // this.name.set(name); // } // // public EruType getType() { // return type.get(); // } // public ObjectProperty<EruType> typeProperty() { // return type; // } // public void setType(EruType type) { // this.type.set(type); // } // // @OneToOne(cascade= CascadeType.ALL, orphanRemoval = true) // public EruGroup getParent() { // return parent.get(); // } // public ObjectProperty<EruGroup> parentProperty() { // return parent; // } // public void setParent(EruGroup parent) { // this.parent.set(parent); // } // // @LazyCollection(LazyCollectionOption.FALSE) // @OneToMany(cascade= CascadeType.ALL, orphanRemoval = true) // public List<EruGroup> getChildren() { // return children; // } // public void setChildren(List<EruGroup> children) { // this.children = children; // } // // @Override // public String toString() { // return "EruGroup{" + getName() + // "=" + super.toString() + // ", children= <" + children + // "> }"; // } // } // // Path: Eru/src/main/java/org/assemblits/eru/entities/EruType.java // public enum EruType { // DEVICE, // CONNECTION, // TAG, // USER, // DISPLAY, // UNKNOWN // } // // Path: Eru/src/main/java/org/assemblits/eru/entities/Project.java // @Data // @Entity // @AllArgsConstructor // @Table(name = "project", schema = "public") // public class Project { // // @Id // @GeneratedValue(strategy = GenerationType.AUTO) // Integer id; // String name; // @LazyCollection(LazyCollectionOption.FALSE) // @OneToOne(cascade = CascadeType.ALL, orphanRemoval = true) // EruGroup group; // @LazyCollection(LazyCollectionOption.FALSE) // @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true) // List<Device> devices; // @LazyCollection(LazyCollectionOption.FALSE) // @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true) // List<Connection> connections; // @LazyCollection(LazyCollectionOption.FALSE) // @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true) // List<Tag> tags; // @LazyCollection(LazyCollectionOption.FALSE) // @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true) // List<User> users; // @LazyCollection(LazyCollectionOption.FALSE) // @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true) // List<Display> displays; // // public Project() { // this.id = null; // this.name = LocalDate.now().format(DateTimeFormatter.BASIC_ISO_DATE); // this.group = new EruGroup(); // this.devices = new ArrayList<>(); // this.connections = new ArrayList<>(); // this.tags = new ArrayList<>(); // this.users = new ArrayList<>(); // this.displays = new ArrayList<>(); // } // // } // Path: Eru/src/main/java/org/assemblits/eru/gui/service/ProjectCreator.java import org.assemblits.eru.entities.EruGroup; import org.assemblits.eru.entities.EruType; import org.assemblits.eru.entities.Project; /****************************************************************************** * Copyright (c) 2017 Assemblits contributors * * * * This file is part of Eru The open JavaFX SCADA by Assemblits Organization. * * * * Eru The open JavaFX SCADA is free software: you can redistribute it * * and/or modify it under the terms of the GNU General Public License * * as published by the Free Software Foundation, either version 3 * * of the License, or (at your option) any later version. * * * * Eru is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with Foobar. If not, see <http://www.gnu.org/licenses/>. * ******************************************************************************/ package org.assemblits.eru.gui.service; public class ProjectCreator { public Project defaultProject() { Project newProject = new Project(); newProject.setName("Project");
EruGroup root = new EruGroup();
assemblits/eru
Eru/src/main/java/org/assemblits/eru/gui/service/ProjectCreator.java
// Path: Eru/src/main/java/org/assemblits/eru/entities/EruGroup.java // @Entity // @Table(name = "eru_group", schema = "public") // @Inheritance(strategy = InheritanceType.SINGLE_TABLE) // public class EruGroup { // // private IntegerProperty id; // private StringProperty name; // private ObjectProperty<EruType> type; // private ObjectProperty<EruGroup> parent; // private List<EruGroup> children; // // public EruGroup() { // this.id = new SimpleIntegerProperty(); // this.name = new SimpleStringProperty(); // this.type = new SimpleObjectProperty<>(EruType.UNKNOWN); // this.parent = new SimpleObjectProperty<>(); // this.children = new SimpleListProperty<>(FXCollections.observableArrayList()); // } // // @Id @GeneratedValue(strategy=GenerationType.AUTO) // public Integer getId() { // return id.get(); // } // public IntegerProperty idProperty() { // return id; // } // public void setId(Integer id) { // this.id.set(id); // } // // public String getName() { // return name.get(); // } // public StringProperty nameProperty() { // return name; // } // public void setName(String name) { // this.name.set(name); // } // // public EruType getType() { // return type.get(); // } // public ObjectProperty<EruType> typeProperty() { // return type; // } // public void setType(EruType type) { // this.type.set(type); // } // // @OneToOne(cascade= CascadeType.ALL, orphanRemoval = true) // public EruGroup getParent() { // return parent.get(); // } // public ObjectProperty<EruGroup> parentProperty() { // return parent; // } // public void setParent(EruGroup parent) { // this.parent.set(parent); // } // // @LazyCollection(LazyCollectionOption.FALSE) // @OneToMany(cascade= CascadeType.ALL, orphanRemoval = true) // public List<EruGroup> getChildren() { // return children; // } // public void setChildren(List<EruGroup> children) { // this.children = children; // } // // @Override // public String toString() { // return "EruGroup{" + getName() + // "=" + super.toString() + // ", children= <" + children + // "> }"; // } // } // // Path: Eru/src/main/java/org/assemblits/eru/entities/EruType.java // public enum EruType { // DEVICE, // CONNECTION, // TAG, // USER, // DISPLAY, // UNKNOWN // } // // Path: Eru/src/main/java/org/assemblits/eru/entities/Project.java // @Data // @Entity // @AllArgsConstructor // @Table(name = "project", schema = "public") // public class Project { // // @Id // @GeneratedValue(strategy = GenerationType.AUTO) // Integer id; // String name; // @LazyCollection(LazyCollectionOption.FALSE) // @OneToOne(cascade = CascadeType.ALL, orphanRemoval = true) // EruGroup group; // @LazyCollection(LazyCollectionOption.FALSE) // @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true) // List<Device> devices; // @LazyCollection(LazyCollectionOption.FALSE) // @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true) // List<Connection> connections; // @LazyCollection(LazyCollectionOption.FALSE) // @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true) // List<Tag> tags; // @LazyCollection(LazyCollectionOption.FALSE) // @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true) // List<User> users; // @LazyCollection(LazyCollectionOption.FALSE) // @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true) // List<Display> displays; // // public Project() { // this.id = null; // this.name = LocalDate.now().format(DateTimeFormatter.BASIC_ISO_DATE); // this.group = new EruGroup(); // this.devices = new ArrayList<>(); // this.connections = new ArrayList<>(); // this.tags = new ArrayList<>(); // this.users = new ArrayList<>(); // this.displays = new ArrayList<>(); // } // // }
import org.assemblits.eru.entities.EruGroup; import org.assemblits.eru.entities.EruType; import org.assemblits.eru.entities.Project;
/****************************************************************************** * Copyright (c) 2017 Assemblits contributors * * * * This file is part of Eru The open JavaFX SCADA by Assemblits Organization. * * * * Eru The open JavaFX SCADA is free software: you can redistribute it * * and/or modify it under the terms of the GNU General Public License * * as published by the Free Software Foundation, either version 3 * * of the License, or (at your option) any later version. * * * * Eru is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with Foobar. If not, see <http://www.gnu.org/licenses/>. * ******************************************************************************/ package org.assemblits.eru.gui.service; public class ProjectCreator { public Project defaultProject() { Project newProject = new Project(); newProject.setName("Project"); EruGroup root = new EruGroup(); root.setName("Project");
// Path: Eru/src/main/java/org/assemblits/eru/entities/EruGroup.java // @Entity // @Table(name = "eru_group", schema = "public") // @Inheritance(strategy = InheritanceType.SINGLE_TABLE) // public class EruGroup { // // private IntegerProperty id; // private StringProperty name; // private ObjectProperty<EruType> type; // private ObjectProperty<EruGroup> parent; // private List<EruGroup> children; // // public EruGroup() { // this.id = new SimpleIntegerProperty(); // this.name = new SimpleStringProperty(); // this.type = new SimpleObjectProperty<>(EruType.UNKNOWN); // this.parent = new SimpleObjectProperty<>(); // this.children = new SimpleListProperty<>(FXCollections.observableArrayList()); // } // // @Id @GeneratedValue(strategy=GenerationType.AUTO) // public Integer getId() { // return id.get(); // } // public IntegerProperty idProperty() { // return id; // } // public void setId(Integer id) { // this.id.set(id); // } // // public String getName() { // return name.get(); // } // public StringProperty nameProperty() { // return name; // } // public void setName(String name) { // this.name.set(name); // } // // public EruType getType() { // return type.get(); // } // public ObjectProperty<EruType> typeProperty() { // return type; // } // public void setType(EruType type) { // this.type.set(type); // } // // @OneToOne(cascade= CascadeType.ALL, orphanRemoval = true) // public EruGroup getParent() { // return parent.get(); // } // public ObjectProperty<EruGroup> parentProperty() { // return parent; // } // public void setParent(EruGroup parent) { // this.parent.set(parent); // } // // @LazyCollection(LazyCollectionOption.FALSE) // @OneToMany(cascade= CascadeType.ALL, orphanRemoval = true) // public List<EruGroup> getChildren() { // return children; // } // public void setChildren(List<EruGroup> children) { // this.children = children; // } // // @Override // public String toString() { // return "EruGroup{" + getName() + // "=" + super.toString() + // ", children= <" + children + // "> }"; // } // } // // Path: Eru/src/main/java/org/assemblits/eru/entities/EruType.java // public enum EruType { // DEVICE, // CONNECTION, // TAG, // USER, // DISPLAY, // UNKNOWN // } // // Path: Eru/src/main/java/org/assemblits/eru/entities/Project.java // @Data // @Entity // @AllArgsConstructor // @Table(name = "project", schema = "public") // public class Project { // // @Id // @GeneratedValue(strategy = GenerationType.AUTO) // Integer id; // String name; // @LazyCollection(LazyCollectionOption.FALSE) // @OneToOne(cascade = CascadeType.ALL, orphanRemoval = true) // EruGroup group; // @LazyCollection(LazyCollectionOption.FALSE) // @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true) // List<Device> devices; // @LazyCollection(LazyCollectionOption.FALSE) // @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true) // List<Connection> connections; // @LazyCollection(LazyCollectionOption.FALSE) // @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true) // List<Tag> tags; // @LazyCollection(LazyCollectionOption.FALSE) // @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true) // List<User> users; // @LazyCollection(LazyCollectionOption.FALSE) // @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true) // List<Display> displays; // // public Project() { // this.id = null; // this.name = LocalDate.now().format(DateTimeFormatter.BASIC_ISO_DATE); // this.group = new EruGroup(); // this.devices = new ArrayList<>(); // this.connections = new ArrayList<>(); // this.tags = new ArrayList<>(); // this.users = new ArrayList<>(); // this.displays = new ArrayList<>(); // } // // } // Path: Eru/src/main/java/org/assemblits/eru/gui/service/ProjectCreator.java import org.assemblits.eru.entities.EruGroup; import org.assemblits.eru.entities.EruType; import org.assemblits.eru.entities.Project; /****************************************************************************** * Copyright (c) 2017 Assemblits contributors * * * * This file is part of Eru The open JavaFX SCADA by Assemblits Organization. * * * * Eru The open JavaFX SCADA is free software: you can redistribute it * * and/or modify it under the terms of the GNU General Public License * * as published by the Free Software Foundation, either version 3 * * of the License, or (at your option) any later version. * * * * Eru is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with Foobar. If not, see <http://www.gnu.org/licenses/>. * ******************************************************************************/ package org.assemblits.eru.gui.service; public class ProjectCreator { public Project defaultProject() { Project newProject = new Project(); newProject.setName("Project"); EruGroup root = new EruGroup(); root.setName("Project");
root.setType(EruType.UNKNOWN);
assemblits/eru
Eru/src/main/java/org/assemblits/eru/entities/SerialConnection.java
// Path: Eru/src/main/java/org/assemblits/eru/exception/ConnectException.java // public class ConnectException extends java.net.ConnectException { // public ConnectException(String localizedMessage) { // super(localizedMessage); // } // } // // Path: Eru/src/main/java/org/assemblits/eru/fieldbus/protocols/modbus/Modbus.java // public interface Modbus { // }
import com.ghgande.j2mod.modbus.util.SerialParameters; import javafx.beans.property.IntegerProperty; import javafx.beans.property.SimpleIntegerProperty; import javafx.beans.property.SimpleStringProperty; import javafx.beans.property.StringProperty; import org.assemblits.eru.exception.ConnectException; import org.assemblits.eru.fieldbus.protocols.modbus.Modbus; import javax.persistence.Column; import javax.persistence.DiscriminatorValue; import javax.persistence.Entity; import javax.persistence.Transient;
/****************************************************************************** * Copyright (c) 2017 Assemblits contributors * * * * This file is part of Eru The open JavaFX SCADA by Assemblits Organization. * * * * Eru The open JavaFX SCADA is free software: you can redistribute it * * and/or modify it under the terms of the GNU General Public License * * as published by the Free Software Foundation, either version 3 * * of the License, or (at your option) any later version. * * * * Eru is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with Foobar. If not, see <http://www.gnu.org/licenses/>. * ******************************************************************************/ package org.assemblits.eru.entities; @Entity @DiscriminatorValue(value = "SERIAL")
// Path: Eru/src/main/java/org/assemblits/eru/exception/ConnectException.java // public class ConnectException extends java.net.ConnectException { // public ConnectException(String localizedMessage) { // super(localizedMessage); // } // } // // Path: Eru/src/main/java/org/assemblits/eru/fieldbus/protocols/modbus/Modbus.java // public interface Modbus { // } // Path: Eru/src/main/java/org/assemblits/eru/entities/SerialConnection.java import com.ghgande.j2mod.modbus.util.SerialParameters; import javafx.beans.property.IntegerProperty; import javafx.beans.property.SimpleIntegerProperty; import javafx.beans.property.SimpleStringProperty; import javafx.beans.property.StringProperty; import org.assemblits.eru.exception.ConnectException; import org.assemblits.eru.fieldbus.protocols.modbus.Modbus; import javax.persistence.Column; import javax.persistence.DiscriminatorValue; import javax.persistence.Entity; import javax.persistence.Transient; /****************************************************************************** * Copyright (c) 2017 Assemblits contributors * * * * This file is part of Eru The open JavaFX SCADA by Assemblits Organization. * * * * Eru The open JavaFX SCADA is free software: you can redistribute it * * and/or modify it under the terms of the GNU General Public License * * as published by the Free Software Foundation, either version 3 * * of the License, or (at your option) any later version. * * * * Eru is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with Foobar. If not, see <http://www.gnu.org/licenses/>. * ******************************************************************************/ package org.assemblits.eru.entities; @Entity @DiscriminatorValue(value = "SERIAL")
public class SerialConnection extends Connection implements Modbus{
assemblits/eru
Eru/src/main/java/org/assemblits/eru/entities/SerialConnection.java
// Path: Eru/src/main/java/org/assemblits/eru/exception/ConnectException.java // public class ConnectException extends java.net.ConnectException { // public ConnectException(String localizedMessage) { // super(localizedMessage); // } // } // // Path: Eru/src/main/java/org/assemblits/eru/fieldbus/protocols/modbus/Modbus.java // public interface Modbus { // }
import com.ghgande.j2mod.modbus.util.SerialParameters; import javafx.beans.property.IntegerProperty; import javafx.beans.property.SimpleIntegerProperty; import javafx.beans.property.SimpleStringProperty; import javafx.beans.property.StringProperty; import org.assemblits.eru.exception.ConnectException; import org.assemblits.eru.fieldbus.protocols.modbus.Modbus; import javax.persistence.Column; import javax.persistence.DiscriminatorValue; import javax.persistence.Entity; import javax.persistence.Transient;
/****************************************************************************** * Copyright (c) 2017 Assemblits contributors * * * * This file is part of Eru The open JavaFX SCADA by Assemblits Organization. * * * * Eru The open JavaFX SCADA is free software: you can redistribute it * * and/or modify it under the terms of the GNU General Public License * * as published by the Free Software Foundation, either version 3 * * of the License, or (at your option) any later version. * * * * Eru is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with Foobar. If not, see <http://www.gnu.org/licenses/>. * ******************************************************************************/ package org.assemblits.eru.entities; @Entity @DiscriminatorValue(value = "SERIAL") public class SerialConnection extends Connection implements Modbus{ private StringProperty port; private IntegerProperty bitsPerSeconds; private IntegerProperty dataBits; private StringProperty parity; private IntegerProperty stopsBits; private StringProperty frameEncoding; private com.ghgande.j2mod.modbus.net.SerialConnection coreConnection; public SerialConnection() { this.port = new SimpleStringProperty("COM1"); this.bitsPerSeconds = new SimpleIntegerProperty(19200); this.dataBits = new SimpleIntegerProperty(8); this.parity = new SimpleStringProperty("NONE"); this.stopsBits = new SimpleIntegerProperty(1); this.frameEncoding = new SimpleStringProperty("RTU"); } @Override
// Path: Eru/src/main/java/org/assemblits/eru/exception/ConnectException.java // public class ConnectException extends java.net.ConnectException { // public ConnectException(String localizedMessage) { // super(localizedMessage); // } // } // // Path: Eru/src/main/java/org/assemblits/eru/fieldbus/protocols/modbus/Modbus.java // public interface Modbus { // } // Path: Eru/src/main/java/org/assemblits/eru/entities/SerialConnection.java import com.ghgande.j2mod.modbus.util.SerialParameters; import javafx.beans.property.IntegerProperty; import javafx.beans.property.SimpleIntegerProperty; import javafx.beans.property.SimpleStringProperty; import javafx.beans.property.StringProperty; import org.assemblits.eru.exception.ConnectException; import org.assemblits.eru.fieldbus.protocols.modbus.Modbus; import javax.persistence.Column; import javax.persistence.DiscriminatorValue; import javax.persistence.Entity; import javax.persistence.Transient; /****************************************************************************** * Copyright (c) 2017 Assemblits contributors * * * * This file is part of Eru The open JavaFX SCADA by Assemblits Organization. * * * * Eru The open JavaFX SCADA is free software: you can redistribute it * * and/or modify it under the terms of the GNU General Public License * * as published by the Free Software Foundation, either version 3 * * of the License, or (at your option) any later version. * * * * Eru is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with Foobar. If not, see <http://www.gnu.org/licenses/>. * ******************************************************************************/ package org.assemblits.eru.entities; @Entity @DiscriminatorValue(value = "SERIAL") public class SerialConnection extends Connection implements Modbus{ private StringProperty port; private IntegerProperty bitsPerSeconds; private IntegerProperty dataBits; private StringProperty parity; private IntegerProperty stopsBits; private StringProperty frameEncoding; private com.ghgande.j2mod.modbus.net.SerialConnection coreConnection; public SerialConnection() { this.port = new SimpleStringProperty("COM1"); this.bitsPerSeconds = new SimpleIntegerProperty(19200); this.dataBits = new SimpleIntegerProperty(8); this.parity = new SimpleStringProperty("NONE"); this.stopsBits = new SimpleIntegerProperty(1); this.frameEncoding = new SimpleStringProperty("RTU"); } @Override
public void connect() throws ConnectException {
assemblits/eru
Eru/src/main/java/org/assemblits/eru/entities/TcpConnection.java
// Path: Eru/src/main/java/org/assemblits/eru/exception/ConnectException.java // public class ConnectException extends java.net.ConnectException { // public ConnectException(String localizedMessage) { // super(localizedMessage); // } // } // // Path: Eru/src/main/java/org/assemblits/eru/fieldbus/protocols/modbus/Modbus.java // public interface Modbus { // }
import com.ghgande.j2mod.modbus.net.TCPMasterConnection; import javafx.beans.property.IntegerProperty; import javafx.beans.property.SimpleIntegerProperty; import javafx.beans.property.SimpleStringProperty; import javafx.beans.property.StringProperty; import org.assemblits.eru.exception.ConnectException; import org.assemblits.eru.fieldbus.protocols.modbus.Modbus; import javax.persistence.DiscriminatorValue; import javax.persistence.Entity; import javax.persistence.Transient; import java.net.InetAddress;
/****************************************************************************** * Copyright (c) 2017 Assemblits contributors * * * * This file is part of Eru The open JavaFX SCADA by Assemblits Organization. * * * * Eru The open JavaFX SCADA is free software: you can redistribute it * * and/or modify it under the terms of the GNU General Public License * * as published by the Free Software Foundation, either version 3 * * of the License, or (at your option) any later version. * * * * Eru is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with Foobar. If not, see <http://www.gnu.org/licenses/>. * ******************************************************************************/ package org.assemblits.eru.entities; @Entity @DiscriminatorValue(value = "TCPIP")
// Path: Eru/src/main/java/org/assemblits/eru/exception/ConnectException.java // public class ConnectException extends java.net.ConnectException { // public ConnectException(String localizedMessage) { // super(localizedMessage); // } // } // // Path: Eru/src/main/java/org/assemblits/eru/fieldbus/protocols/modbus/Modbus.java // public interface Modbus { // } // Path: Eru/src/main/java/org/assemblits/eru/entities/TcpConnection.java import com.ghgande.j2mod.modbus.net.TCPMasterConnection; import javafx.beans.property.IntegerProperty; import javafx.beans.property.SimpleIntegerProperty; import javafx.beans.property.SimpleStringProperty; import javafx.beans.property.StringProperty; import org.assemblits.eru.exception.ConnectException; import org.assemblits.eru.fieldbus.protocols.modbus.Modbus; import javax.persistence.DiscriminatorValue; import javax.persistence.Entity; import javax.persistence.Transient; import java.net.InetAddress; /****************************************************************************** * Copyright (c) 2017 Assemblits contributors * * * * This file is part of Eru The open JavaFX SCADA by Assemblits Organization. * * * * Eru The open JavaFX SCADA is free software: you can redistribute it * * and/or modify it under the terms of the GNU General Public License * * as published by the Free Software Foundation, either version 3 * * of the License, or (at your option) any later version. * * * * Eru is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with Foobar. If not, see <http://www.gnu.org/licenses/>. * ******************************************************************************/ package org.assemblits.eru.entities; @Entity @DiscriminatorValue(value = "TCPIP")
public class TcpConnection extends Connection implements Modbus{
assemblits/eru
Eru/src/main/java/org/assemblits/eru/entities/TcpConnection.java
// Path: Eru/src/main/java/org/assemblits/eru/exception/ConnectException.java // public class ConnectException extends java.net.ConnectException { // public ConnectException(String localizedMessage) { // super(localizedMessage); // } // } // // Path: Eru/src/main/java/org/assemblits/eru/fieldbus/protocols/modbus/Modbus.java // public interface Modbus { // }
import com.ghgande.j2mod.modbus.net.TCPMasterConnection; import javafx.beans.property.IntegerProperty; import javafx.beans.property.SimpleIntegerProperty; import javafx.beans.property.SimpleStringProperty; import javafx.beans.property.StringProperty; import org.assemblits.eru.exception.ConnectException; import org.assemblits.eru.fieldbus.protocols.modbus.Modbus; import javax.persistence.DiscriminatorValue; import javax.persistence.Entity; import javax.persistence.Transient; import java.net.InetAddress;
/****************************************************************************** * Copyright (c) 2017 Assemblits contributors * * * * This file is part of Eru The open JavaFX SCADA by Assemblits Organization. * * * * Eru The open JavaFX SCADA is free software: you can redistribute it * * and/or modify it under the terms of the GNU General Public License * * as published by the Free Software Foundation, either version 3 * * of the License, or (at your option) any later version. * * * * Eru is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with Foobar. If not, see <http://www.gnu.org/licenses/>. * ******************************************************************************/ package org.assemblits.eru.entities; @Entity @DiscriminatorValue(value = "TCPIP") public class TcpConnection extends Connection implements Modbus{ private StringProperty hostname; private IntegerProperty port; private TCPMasterConnection coreConnection; public TcpConnection() { this.hostname = new SimpleStringProperty("localhost"); this.port = new SimpleIntegerProperty(502); } @Override
// Path: Eru/src/main/java/org/assemblits/eru/exception/ConnectException.java // public class ConnectException extends java.net.ConnectException { // public ConnectException(String localizedMessage) { // super(localizedMessage); // } // } // // Path: Eru/src/main/java/org/assemblits/eru/fieldbus/protocols/modbus/Modbus.java // public interface Modbus { // } // Path: Eru/src/main/java/org/assemblits/eru/entities/TcpConnection.java import com.ghgande.j2mod.modbus.net.TCPMasterConnection; import javafx.beans.property.IntegerProperty; import javafx.beans.property.SimpleIntegerProperty; import javafx.beans.property.SimpleStringProperty; import javafx.beans.property.StringProperty; import org.assemblits.eru.exception.ConnectException; import org.assemblits.eru.fieldbus.protocols.modbus.Modbus; import javax.persistence.DiscriminatorValue; import javax.persistence.Entity; import javax.persistence.Transient; import java.net.InetAddress; /****************************************************************************** * Copyright (c) 2017 Assemblits contributors * * * * This file is part of Eru The open JavaFX SCADA by Assemblits Organization. * * * * Eru The open JavaFX SCADA is free software: you can redistribute it * * and/or modify it under the terms of the GNU General Public License * * as published by the Free Software Foundation, either version 3 * * of the License, or (at your option) any later version. * * * * Eru is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with Foobar. If not, see <http://www.gnu.org/licenses/>. * ******************************************************************************/ package org.assemblits.eru.entities; @Entity @DiscriminatorValue(value = "TCPIP") public class TcpConnection extends Connection implements Modbus{ private StringProperty hostname; private IntegerProperty port; private TCPMasterConnection coreConnection; public TcpConnection() { this.hostname = new SimpleStringProperty("localhost"); this.port = new SimpleIntegerProperty(502); } @Override
public void connect() throws ConnectException{
assemblits/eru
Eru/src/main/java/org/assemblits/eru/jfx/scenebuilder/library/CustomLibraryLoader.java
// Path: Eru/src/main/java/org/assemblits/eru/jfx/JFXClassUtil.java // @Component // public class JFXClassUtil { // // public boolean isNotJavaFxComponent(@NonNull String className) { // return !className.startsWith("java.") && !className.startsWith("javax.") // && !className.startsWith("javafx.") && !className.startsWith("com.oracle.javafx.scenebuilder.") // && !className.startsWith("com.javafx."); // } // // public boolean isJFXComponentClass(String className, String classAbsolutePackage) { // if (className != null && isNotJavaFxComponent(className)) { // try { // Class<?> jfxComponentClass = ClassUtil.loadClass(classAbsolutePackage); // if (!Modifier.isAbstract(jfxComponentClass.getModifiers()) && Node.class.isAssignableFrom(jfxComponentClass)) { // JarExplorer.instantiateWithFXMLLoader(jfxComponentClass, this.getClass().getClassLoader()); // return true; // } // } catch (Exception ignored) { // return false; // } // } // return false; // } // } // // Path: Eru/src/main/java/org/assemblits/eru/packages/ClassInfo.java // @Value // @AllArgsConstructor // public class ClassInfo { // String name; // String absolutePackage; // File file; // Class<?> clazz; // } // // Path: Eru/src/main/java/org/assemblits/eru/packages/PackageExplorer.java // @Slf4j // @Component // @RequiredArgsConstructor // public class PackageExplorer { // // private static final List<String> TOP_PACKAGES = new ArrayList<String>() {{ // add("main"); // add("target"); // add("classes"); // }}; // // public Set<ClassInfo> exploreAndGetClassesInfo(Collection<String> packages) { // Stack<File> directories = new Stack<>(); // log.debug("Scanning packages {}", packages); // for (String location : packages) { // directories.push(new File(getClass().getResource(location).getPath())); // } // Set<ClassInfo> classesInfo = new HashSet<>(); // while (!directories.isEmpty()) { // File directory = directories.pop(); // for (File file : directory.listFiles()) { // if (file.isDirectory()) { // directories.push(file); // } else { // Optional<String> className = ClassUtil.makeClassNameFromCompiledClassName(file.getName()); // if (className.isPresent()) { // String canonicalPackage = getCanonicalPackage(className.get(), file); // try { // classesInfo.add(new ClassInfo(className.get(), canonicalPackage, file, // ClassUtil.loadClass(canonicalPackage))); // } catch (ClassNotFoundException ignore) { // } // } // } // } // } // return classesInfo; // } // // private String getCanonicalPackage(String className, File file) { // StringBuilder stringBuilder = new StringBuilder(); // while (file.getParentFile() != null && !TOP_PACKAGES.contains(file.getParentFile().getName())) { // stringBuilder.insert(0, ".").insert(0, file.getParentFile().getName()); // file = file.getParentFile(); // } // stringBuilder.append(className); // return stringBuilder.toString(); // } // }
import static java.io.File.separator; import static java.lang.String.*; import com.oracle.javafx.scenebuilder.kit.library.Library; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.assemblits.eru.jfx.JFXClassUtil; import org.assemblits.eru.packages.ClassInfo; import org.assemblits.eru.packages.PackageExplorer; import org.springframework.stereotype.Component; import java.util.ArrayList; import java.util.List; import java.util.Set; import java.util.stream.Collectors;
/****************************************************************************** * Copyright (c) 2017 Assemblits contributors * * * * This file is part of Eru The open JavaFX SCADA by Assemblits Organization. * * * * Eru The open JavaFX SCADA is free software: you can redistribute it * * and/or modify it under the terms of the GNU General Public License * * as published by the Free Software Foundation, either version 3 * * of the License, or (at your option) any later version. * * * * Eru is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with Foobar. If not, see <http://www.gnu.org/licenses/>. * ******************************************************************************/ package org.assemblits.eru.jfx.scenebuilder.library; @Slf4j @Component @RequiredArgsConstructor public class CustomLibraryLoader { private static final List<String> DYNAMO_CLASSES_LOCATION = new ArrayList<String>() {{ add(join(separator, "", "org", "assemblits", "eru", "gui", "dynamo")); }};
// Path: Eru/src/main/java/org/assemblits/eru/jfx/JFXClassUtil.java // @Component // public class JFXClassUtil { // // public boolean isNotJavaFxComponent(@NonNull String className) { // return !className.startsWith("java.") && !className.startsWith("javax.") // && !className.startsWith("javafx.") && !className.startsWith("com.oracle.javafx.scenebuilder.") // && !className.startsWith("com.javafx."); // } // // public boolean isJFXComponentClass(String className, String classAbsolutePackage) { // if (className != null && isNotJavaFxComponent(className)) { // try { // Class<?> jfxComponentClass = ClassUtil.loadClass(classAbsolutePackage); // if (!Modifier.isAbstract(jfxComponentClass.getModifiers()) && Node.class.isAssignableFrom(jfxComponentClass)) { // JarExplorer.instantiateWithFXMLLoader(jfxComponentClass, this.getClass().getClassLoader()); // return true; // } // } catch (Exception ignored) { // return false; // } // } // return false; // } // } // // Path: Eru/src/main/java/org/assemblits/eru/packages/ClassInfo.java // @Value // @AllArgsConstructor // public class ClassInfo { // String name; // String absolutePackage; // File file; // Class<?> clazz; // } // // Path: Eru/src/main/java/org/assemblits/eru/packages/PackageExplorer.java // @Slf4j // @Component // @RequiredArgsConstructor // public class PackageExplorer { // // private static final List<String> TOP_PACKAGES = new ArrayList<String>() {{ // add("main"); // add("target"); // add("classes"); // }}; // // public Set<ClassInfo> exploreAndGetClassesInfo(Collection<String> packages) { // Stack<File> directories = new Stack<>(); // log.debug("Scanning packages {}", packages); // for (String location : packages) { // directories.push(new File(getClass().getResource(location).getPath())); // } // Set<ClassInfo> classesInfo = new HashSet<>(); // while (!directories.isEmpty()) { // File directory = directories.pop(); // for (File file : directory.listFiles()) { // if (file.isDirectory()) { // directories.push(file); // } else { // Optional<String> className = ClassUtil.makeClassNameFromCompiledClassName(file.getName()); // if (className.isPresent()) { // String canonicalPackage = getCanonicalPackage(className.get(), file); // try { // classesInfo.add(new ClassInfo(className.get(), canonicalPackage, file, // ClassUtil.loadClass(canonicalPackage))); // } catch (ClassNotFoundException ignore) { // } // } // } // } // } // return classesInfo; // } // // private String getCanonicalPackage(String className, File file) { // StringBuilder stringBuilder = new StringBuilder(); // while (file.getParentFile() != null && !TOP_PACKAGES.contains(file.getParentFile().getName())) { // stringBuilder.insert(0, ".").insert(0, file.getParentFile().getName()); // file = file.getParentFile(); // } // stringBuilder.append(className); // return stringBuilder.toString(); // } // } // Path: Eru/src/main/java/org/assemblits/eru/jfx/scenebuilder/library/CustomLibraryLoader.java import static java.io.File.separator; import static java.lang.String.*; import com.oracle.javafx.scenebuilder.kit.library.Library; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.assemblits.eru.jfx.JFXClassUtil; import org.assemblits.eru.packages.ClassInfo; import org.assemblits.eru.packages.PackageExplorer; import org.springframework.stereotype.Component; import java.util.ArrayList; import java.util.List; import java.util.Set; import java.util.stream.Collectors; /****************************************************************************** * Copyright (c) 2017 Assemblits contributors * * * * This file is part of Eru The open JavaFX SCADA by Assemblits Organization. * * * * Eru The open JavaFX SCADA is free software: you can redistribute it * * and/or modify it under the terms of the GNU General Public License * * as published by the Free Software Foundation, either version 3 * * of the License, or (at your option) any later version. * * * * Eru is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with Foobar. If not, see <http://www.gnu.org/licenses/>. * ******************************************************************************/ package org.assemblits.eru.jfx.scenebuilder.library; @Slf4j @Component @RequiredArgsConstructor public class CustomLibraryLoader { private static final List<String> DYNAMO_CLASSES_LOCATION = new ArrayList<String>() {{ add(join(separator, "", "org", "assemblits", "eru", "gui", "dynamo")); }};
private final PackageExplorer packageExplorer;
assemblits/eru
Eru/src/main/java/org/assemblits/eru/jfx/scenebuilder/library/CustomLibraryLoader.java
// Path: Eru/src/main/java/org/assemblits/eru/jfx/JFXClassUtil.java // @Component // public class JFXClassUtil { // // public boolean isNotJavaFxComponent(@NonNull String className) { // return !className.startsWith("java.") && !className.startsWith("javax.") // && !className.startsWith("javafx.") && !className.startsWith("com.oracle.javafx.scenebuilder.") // && !className.startsWith("com.javafx."); // } // // public boolean isJFXComponentClass(String className, String classAbsolutePackage) { // if (className != null && isNotJavaFxComponent(className)) { // try { // Class<?> jfxComponentClass = ClassUtil.loadClass(classAbsolutePackage); // if (!Modifier.isAbstract(jfxComponentClass.getModifiers()) && Node.class.isAssignableFrom(jfxComponentClass)) { // JarExplorer.instantiateWithFXMLLoader(jfxComponentClass, this.getClass().getClassLoader()); // return true; // } // } catch (Exception ignored) { // return false; // } // } // return false; // } // } // // Path: Eru/src/main/java/org/assemblits/eru/packages/ClassInfo.java // @Value // @AllArgsConstructor // public class ClassInfo { // String name; // String absolutePackage; // File file; // Class<?> clazz; // } // // Path: Eru/src/main/java/org/assemblits/eru/packages/PackageExplorer.java // @Slf4j // @Component // @RequiredArgsConstructor // public class PackageExplorer { // // private static final List<String> TOP_PACKAGES = new ArrayList<String>() {{ // add("main"); // add("target"); // add("classes"); // }}; // // public Set<ClassInfo> exploreAndGetClassesInfo(Collection<String> packages) { // Stack<File> directories = new Stack<>(); // log.debug("Scanning packages {}", packages); // for (String location : packages) { // directories.push(new File(getClass().getResource(location).getPath())); // } // Set<ClassInfo> classesInfo = new HashSet<>(); // while (!directories.isEmpty()) { // File directory = directories.pop(); // for (File file : directory.listFiles()) { // if (file.isDirectory()) { // directories.push(file); // } else { // Optional<String> className = ClassUtil.makeClassNameFromCompiledClassName(file.getName()); // if (className.isPresent()) { // String canonicalPackage = getCanonicalPackage(className.get(), file); // try { // classesInfo.add(new ClassInfo(className.get(), canonicalPackage, file, // ClassUtil.loadClass(canonicalPackage))); // } catch (ClassNotFoundException ignore) { // } // } // } // } // } // return classesInfo; // } // // private String getCanonicalPackage(String className, File file) { // StringBuilder stringBuilder = new StringBuilder(); // while (file.getParentFile() != null && !TOP_PACKAGES.contains(file.getParentFile().getName())) { // stringBuilder.insert(0, ".").insert(0, file.getParentFile().getName()); // file = file.getParentFile(); // } // stringBuilder.append(className); // return stringBuilder.toString(); // } // }
import static java.io.File.separator; import static java.lang.String.*; import com.oracle.javafx.scenebuilder.kit.library.Library; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.assemblits.eru.jfx.JFXClassUtil; import org.assemblits.eru.packages.ClassInfo; import org.assemblits.eru.packages.PackageExplorer; import org.springframework.stereotype.Component; import java.util.ArrayList; import java.util.List; import java.util.Set; import java.util.stream.Collectors;
/****************************************************************************** * Copyright (c) 2017 Assemblits contributors * * * * This file is part of Eru The open JavaFX SCADA by Assemblits Organization. * * * * Eru The open JavaFX SCADA is free software: you can redistribute it * * and/or modify it under the terms of the GNU General Public License * * as published by the Free Software Foundation, either version 3 * * of the License, or (at your option) any later version. * * * * Eru is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with Foobar. If not, see <http://www.gnu.org/licenses/>. * ******************************************************************************/ package org.assemblits.eru.jfx.scenebuilder.library; @Slf4j @Component @RequiredArgsConstructor public class CustomLibraryLoader { private static final List<String> DYNAMO_CLASSES_LOCATION = new ArrayList<String>() {{ add(join(separator, "", "org", "assemblits", "eru", "gui", "dynamo")); }}; private final PackageExplorer packageExplorer;
// Path: Eru/src/main/java/org/assemblits/eru/jfx/JFXClassUtil.java // @Component // public class JFXClassUtil { // // public boolean isNotJavaFxComponent(@NonNull String className) { // return !className.startsWith("java.") && !className.startsWith("javax.") // && !className.startsWith("javafx.") && !className.startsWith("com.oracle.javafx.scenebuilder.") // && !className.startsWith("com.javafx."); // } // // public boolean isJFXComponentClass(String className, String classAbsolutePackage) { // if (className != null && isNotJavaFxComponent(className)) { // try { // Class<?> jfxComponentClass = ClassUtil.loadClass(classAbsolutePackage); // if (!Modifier.isAbstract(jfxComponentClass.getModifiers()) && Node.class.isAssignableFrom(jfxComponentClass)) { // JarExplorer.instantiateWithFXMLLoader(jfxComponentClass, this.getClass().getClassLoader()); // return true; // } // } catch (Exception ignored) { // return false; // } // } // return false; // } // } // // Path: Eru/src/main/java/org/assemblits/eru/packages/ClassInfo.java // @Value // @AllArgsConstructor // public class ClassInfo { // String name; // String absolutePackage; // File file; // Class<?> clazz; // } // // Path: Eru/src/main/java/org/assemblits/eru/packages/PackageExplorer.java // @Slf4j // @Component // @RequiredArgsConstructor // public class PackageExplorer { // // private static final List<String> TOP_PACKAGES = new ArrayList<String>() {{ // add("main"); // add("target"); // add("classes"); // }}; // // public Set<ClassInfo> exploreAndGetClassesInfo(Collection<String> packages) { // Stack<File> directories = new Stack<>(); // log.debug("Scanning packages {}", packages); // for (String location : packages) { // directories.push(new File(getClass().getResource(location).getPath())); // } // Set<ClassInfo> classesInfo = new HashSet<>(); // while (!directories.isEmpty()) { // File directory = directories.pop(); // for (File file : directory.listFiles()) { // if (file.isDirectory()) { // directories.push(file); // } else { // Optional<String> className = ClassUtil.makeClassNameFromCompiledClassName(file.getName()); // if (className.isPresent()) { // String canonicalPackage = getCanonicalPackage(className.get(), file); // try { // classesInfo.add(new ClassInfo(className.get(), canonicalPackage, file, // ClassUtil.loadClass(canonicalPackage))); // } catch (ClassNotFoundException ignore) { // } // } // } // } // } // return classesInfo; // } // // private String getCanonicalPackage(String className, File file) { // StringBuilder stringBuilder = new StringBuilder(); // while (file.getParentFile() != null && !TOP_PACKAGES.contains(file.getParentFile().getName())) { // stringBuilder.insert(0, ".").insert(0, file.getParentFile().getName()); // file = file.getParentFile(); // } // stringBuilder.append(className); // return stringBuilder.toString(); // } // } // Path: Eru/src/main/java/org/assemblits/eru/jfx/scenebuilder/library/CustomLibraryLoader.java import static java.io.File.separator; import static java.lang.String.*; import com.oracle.javafx.scenebuilder.kit.library.Library; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.assemblits.eru.jfx.JFXClassUtil; import org.assemblits.eru.packages.ClassInfo; import org.assemblits.eru.packages.PackageExplorer; import org.springframework.stereotype.Component; import java.util.ArrayList; import java.util.List; import java.util.Set; import java.util.stream.Collectors; /****************************************************************************** * Copyright (c) 2017 Assemblits contributors * * * * This file is part of Eru The open JavaFX SCADA by Assemblits Organization. * * * * Eru The open JavaFX SCADA is free software: you can redistribute it * * and/or modify it under the terms of the GNU General Public License * * as published by the Free Software Foundation, either version 3 * * of the License, or (at your option) any later version. * * * * Eru is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with Foobar. If not, see <http://www.gnu.org/licenses/>. * ******************************************************************************/ package org.assemblits.eru.jfx.scenebuilder.library; @Slf4j @Component @RequiredArgsConstructor public class CustomLibraryLoader { private static final List<String> DYNAMO_CLASSES_LOCATION = new ArrayList<String>() {{ add(join(separator, "", "org", "assemblits", "eru", "gui", "dynamo")); }}; private final PackageExplorer packageExplorer;
private final JFXClassUtil jfxClassUtil;
assemblits/eru
Eru/src/main/java/org/assemblits/eru/jfx/scenebuilder/library/CustomLibraryLoader.java
// Path: Eru/src/main/java/org/assemblits/eru/jfx/JFXClassUtil.java // @Component // public class JFXClassUtil { // // public boolean isNotJavaFxComponent(@NonNull String className) { // return !className.startsWith("java.") && !className.startsWith("javax.") // && !className.startsWith("javafx.") && !className.startsWith("com.oracle.javafx.scenebuilder.") // && !className.startsWith("com.javafx."); // } // // public boolean isJFXComponentClass(String className, String classAbsolutePackage) { // if (className != null && isNotJavaFxComponent(className)) { // try { // Class<?> jfxComponentClass = ClassUtil.loadClass(classAbsolutePackage); // if (!Modifier.isAbstract(jfxComponentClass.getModifiers()) && Node.class.isAssignableFrom(jfxComponentClass)) { // JarExplorer.instantiateWithFXMLLoader(jfxComponentClass, this.getClass().getClassLoader()); // return true; // } // } catch (Exception ignored) { // return false; // } // } // return false; // } // } // // Path: Eru/src/main/java/org/assemblits/eru/packages/ClassInfo.java // @Value // @AllArgsConstructor // public class ClassInfo { // String name; // String absolutePackage; // File file; // Class<?> clazz; // } // // Path: Eru/src/main/java/org/assemblits/eru/packages/PackageExplorer.java // @Slf4j // @Component // @RequiredArgsConstructor // public class PackageExplorer { // // private static final List<String> TOP_PACKAGES = new ArrayList<String>() {{ // add("main"); // add("target"); // add("classes"); // }}; // // public Set<ClassInfo> exploreAndGetClassesInfo(Collection<String> packages) { // Stack<File> directories = new Stack<>(); // log.debug("Scanning packages {}", packages); // for (String location : packages) { // directories.push(new File(getClass().getResource(location).getPath())); // } // Set<ClassInfo> classesInfo = new HashSet<>(); // while (!directories.isEmpty()) { // File directory = directories.pop(); // for (File file : directory.listFiles()) { // if (file.isDirectory()) { // directories.push(file); // } else { // Optional<String> className = ClassUtil.makeClassNameFromCompiledClassName(file.getName()); // if (className.isPresent()) { // String canonicalPackage = getCanonicalPackage(className.get(), file); // try { // classesInfo.add(new ClassInfo(className.get(), canonicalPackage, file, // ClassUtil.loadClass(canonicalPackage))); // } catch (ClassNotFoundException ignore) { // } // } // } // } // } // return classesInfo; // } // // private String getCanonicalPackage(String className, File file) { // StringBuilder stringBuilder = new StringBuilder(); // while (file.getParentFile() != null && !TOP_PACKAGES.contains(file.getParentFile().getName())) { // stringBuilder.insert(0, ".").insert(0, file.getParentFile().getName()); // file = file.getParentFile(); // } // stringBuilder.append(className); // return stringBuilder.toString(); // } // }
import static java.io.File.separator; import static java.lang.String.*; import com.oracle.javafx.scenebuilder.kit.library.Library; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.assemblits.eru.jfx.JFXClassUtil; import org.assemblits.eru.packages.ClassInfo; import org.assemblits.eru.packages.PackageExplorer; import org.springframework.stereotype.Component; import java.util.ArrayList; import java.util.List; import java.util.Set; import java.util.stream.Collectors;
/****************************************************************************** * Copyright (c) 2017 Assemblits contributors * * * * This file is part of Eru The open JavaFX SCADA by Assemblits Organization. * * * * Eru The open JavaFX SCADA is free software: you can redistribute it * * and/or modify it under the terms of the GNU General Public License * * as published by the Free Software Foundation, either version 3 * * of the License, or (at your option) any later version. * * * * Eru is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with Foobar. If not, see <http://www.gnu.org/licenses/>. * ******************************************************************************/ package org.assemblits.eru.jfx.scenebuilder.library; @Slf4j @Component @RequiredArgsConstructor public class CustomLibraryLoader { private static final List<String> DYNAMO_CLASSES_LOCATION = new ArrayList<String>() {{ add(join(separator, "", "org", "assemblits", "eru", "gui", "dynamo")); }}; private final PackageExplorer packageExplorer; private final JFXClassUtil jfxClassUtil; private Library library; public void loadFromClassPath() { log.info("Loading custom components from classpath");
// Path: Eru/src/main/java/org/assemblits/eru/jfx/JFXClassUtil.java // @Component // public class JFXClassUtil { // // public boolean isNotJavaFxComponent(@NonNull String className) { // return !className.startsWith("java.") && !className.startsWith("javax.") // && !className.startsWith("javafx.") && !className.startsWith("com.oracle.javafx.scenebuilder.") // && !className.startsWith("com.javafx."); // } // // public boolean isJFXComponentClass(String className, String classAbsolutePackage) { // if (className != null && isNotJavaFxComponent(className)) { // try { // Class<?> jfxComponentClass = ClassUtil.loadClass(classAbsolutePackage); // if (!Modifier.isAbstract(jfxComponentClass.getModifiers()) && Node.class.isAssignableFrom(jfxComponentClass)) { // JarExplorer.instantiateWithFXMLLoader(jfxComponentClass, this.getClass().getClassLoader()); // return true; // } // } catch (Exception ignored) { // return false; // } // } // return false; // } // } // // Path: Eru/src/main/java/org/assemblits/eru/packages/ClassInfo.java // @Value // @AllArgsConstructor // public class ClassInfo { // String name; // String absolutePackage; // File file; // Class<?> clazz; // } // // Path: Eru/src/main/java/org/assemblits/eru/packages/PackageExplorer.java // @Slf4j // @Component // @RequiredArgsConstructor // public class PackageExplorer { // // private static final List<String> TOP_PACKAGES = new ArrayList<String>() {{ // add("main"); // add("target"); // add("classes"); // }}; // // public Set<ClassInfo> exploreAndGetClassesInfo(Collection<String> packages) { // Stack<File> directories = new Stack<>(); // log.debug("Scanning packages {}", packages); // for (String location : packages) { // directories.push(new File(getClass().getResource(location).getPath())); // } // Set<ClassInfo> classesInfo = new HashSet<>(); // while (!directories.isEmpty()) { // File directory = directories.pop(); // for (File file : directory.listFiles()) { // if (file.isDirectory()) { // directories.push(file); // } else { // Optional<String> className = ClassUtil.makeClassNameFromCompiledClassName(file.getName()); // if (className.isPresent()) { // String canonicalPackage = getCanonicalPackage(className.get(), file); // try { // classesInfo.add(new ClassInfo(className.get(), canonicalPackage, file, // ClassUtil.loadClass(canonicalPackage))); // } catch (ClassNotFoundException ignore) { // } // } // } // } // } // return classesInfo; // } // // private String getCanonicalPackage(String className, File file) { // StringBuilder stringBuilder = new StringBuilder(); // while (file.getParentFile() != null && !TOP_PACKAGES.contains(file.getParentFile().getName())) { // stringBuilder.insert(0, ".").insert(0, file.getParentFile().getName()); // file = file.getParentFile(); // } // stringBuilder.append(className); // return stringBuilder.toString(); // } // } // Path: Eru/src/main/java/org/assemblits/eru/jfx/scenebuilder/library/CustomLibraryLoader.java import static java.io.File.separator; import static java.lang.String.*; import com.oracle.javafx.scenebuilder.kit.library.Library; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.assemblits.eru.jfx.JFXClassUtil; import org.assemblits.eru.packages.ClassInfo; import org.assemblits.eru.packages.PackageExplorer; import org.springframework.stereotype.Component; import java.util.ArrayList; import java.util.List; import java.util.Set; import java.util.stream.Collectors; /****************************************************************************** * Copyright (c) 2017 Assemblits contributors * * * * This file is part of Eru The open JavaFX SCADA by Assemblits Organization. * * * * Eru The open JavaFX SCADA is free software: you can redistribute it * * and/or modify it under the terms of the GNU General Public License * * as published by the Free Software Foundation, either version 3 * * of the License, or (at your option) any later version. * * * * Eru is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with Foobar. If not, see <http://www.gnu.org/licenses/>. * ******************************************************************************/ package org.assemblits.eru.jfx.scenebuilder.library; @Slf4j @Component @RequiredArgsConstructor public class CustomLibraryLoader { private static final List<String> DYNAMO_CLASSES_LOCATION = new ArrayList<String>() {{ add(join(separator, "", "org", "assemblits", "eru", "gui", "dynamo")); }}; private final PackageExplorer packageExplorer; private final JFXClassUtil jfxClassUtil; private Library library; public void loadFromClassPath() { log.info("Loading custom components from classpath");
Set<ClassInfo> classesInfo = packageExplorer.exploreAndGetClassesInfo(DYNAMO_CLASSES_LOCATION);
assemblits/eru
Eru/src/main/java/org/assemblits/eru/gui/controller/CenterPaneController.java
// Path: Eru/src/main/java/org/assemblits/eru/entities/EruGroup.java // @Entity // @Table(name = "eru_group", schema = "public") // @Inheritance(strategy = InheritanceType.SINGLE_TABLE) // public class EruGroup { // // private IntegerProperty id; // private StringProperty name; // private ObjectProperty<EruType> type; // private ObjectProperty<EruGroup> parent; // private List<EruGroup> children; // // public EruGroup() { // this.id = new SimpleIntegerProperty(); // this.name = new SimpleStringProperty(); // this.type = new SimpleObjectProperty<>(EruType.UNKNOWN); // this.parent = new SimpleObjectProperty<>(); // this.children = new SimpleListProperty<>(FXCollections.observableArrayList()); // } // // @Id @GeneratedValue(strategy=GenerationType.AUTO) // public Integer getId() { // return id.get(); // } // public IntegerProperty idProperty() { // return id; // } // public void setId(Integer id) { // this.id.set(id); // } // // public String getName() { // return name.get(); // } // public StringProperty nameProperty() { // return name; // } // public void setName(String name) { // this.name.set(name); // } // // public EruType getType() { // return type.get(); // } // public ObjectProperty<EruType> typeProperty() { // return type; // } // public void setType(EruType type) { // this.type.set(type); // } // // @OneToOne(cascade= CascadeType.ALL, orphanRemoval = true) // public EruGroup getParent() { // return parent.get(); // } // public ObjectProperty<EruGroup> parentProperty() { // return parent; // } // public void setParent(EruGroup parent) { // this.parent.set(parent); // } // // @LazyCollection(LazyCollectionOption.FALSE) // @OneToMany(cascade= CascadeType.ALL, orphanRemoval = true) // public List<EruGroup> getChildren() { // return children; // } // public void setChildren(List<EruGroup> children) { // this.children = children; // } // // @Override // public String toString() { // return "EruGroup{" + getName() + // "=" + super.toString() + // ", children= <" + children + // "> }"; // } // }
import javafx.fxml.FXML; import javafx.scene.layout.AnchorPane; import lombok.Getter; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.assemblits.eru.entities.EruGroup; import org.assemblits.eru.gui.component.*; import org.springframework.stereotype.Component;
/****************************************************************************** * Copyright (c) 2017 Assemblits contributors * * * * This file is part of Eru The open JavaFX SCADA by Assemblits Organization. * * * * Eru The open JavaFX SCADA is free software: you can redistribute it * * and/or modify it under the terms of the GNU General Public License * * as published by the Free Software Foundation, either version 3 * * of the License, or (at your option) any later version. * * * * Eru is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with Foobar. If not, see <http://www.gnu.org/licenses/>. * ******************************************************************************/ package org.assemblits.eru.gui.controller; @Slf4j @Getter @Component @RequiredArgsConstructor public class CenterPaneController { @FXML private UsersTableView usersTableView; @FXML private ConnectionsTableView connectionsTableView; @FXML private DevicesTableView devicesTableView; @FXML private TagsTableView tagsTableView; @FXML private DisplayTableView displayTableView; @FXML private AnchorPane tablesAnchorPane;
// Path: Eru/src/main/java/org/assemblits/eru/entities/EruGroup.java // @Entity // @Table(name = "eru_group", schema = "public") // @Inheritance(strategy = InheritanceType.SINGLE_TABLE) // public class EruGroup { // // private IntegerProperty id; // private StringProperty name; // private ObjectProperty<EruType> type; // private ObjectProperty<EruGroup> parent; // private List<EruGroup> children; // // public EruGroup() { // this.id = new SimpleIntegerProperty(); // this.name = new SimpleStringProperty(); // this.type = new SimpleObjectProperty<>(EruType.UNKNOWN); // this.parent = new SimpleObjectProperty<>(); // this.children = new SimpleListProperty<>(FXCollections.observableArrayList()); // } // // @Id @GeneratedValue(strategy=GenerationType.AUTO) // public Integer getId() { // return id.get(); // } // public IntegerProperty idProperty() { // return id; // } // public void setId(Integer id) { // this.id.set(id); // } // // public String getName() { // return name.get(); // } // public StringProperty nameProperty() { // return name; // } // public void setName(String name) { // this.name.set(name); // } // // public EruType getType() { // return type.get(); // } // public ObjectProperty<EruType> typeProperty() { // return type; // } // public void setType(EruType type) { // this.type.set(type); // } // // @OneToOne(cascade= CascadeType.ALL, orphanRemoval = true) // public EruGroup getParent() { // return parent.get(); // } // public ObjectProperty<EruGroup> parentProperty() { // return parent; // } // public void setParent(EruGroup parent) { // this.parent.set(parent); // } // // @LazyCollection(LazyCollectionOption.FALSE) // @OneToMany(cascade= CascadeType.ALL, orphanRemoval = true) // public List<EruGroup> getChildren() { // return children; // } // public void setChildren(List<EruGroup> children) { // this.children = children; // } // // @Override // public String toString() { // return "EruGroup{" + getName() + // "=" + super.toString() + // ", children= <" + children + // "> }"; // } // } // Path: Eru/src/main/java/org/assemblits/eru/gui/controller/CenterPaneController.java import javafx.fxml.FXML; import javafx.scene.layout.AnchorPane; import lombok.Getter; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.assemblits.eru.entities.EruGroup; import org.assemblits.eru.gui.component.*; import org.springframework.stereotype.Component; /****************************************************************************** * Copyright (c) 2017 Assemblits contributors * * * * This file is part of Eru The open JavaFX SCADA by Assemblits Organization. * * * * Eru The open JavaFX SCADA is free software: you can redistribute it * * and/or modify it under the terms of the GNU General Public License * * as published by the Free Software Foundation, either version 3 * * of the License, or (at your option) any later version. * * * * Eru is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with Foobar. If not, see <http://www.gnu.org/licenses/>. * ******************************************************************************/ package org.assemblits.eru.gui.controller; @Slf4j @Getter @Component @RequiredArgsConstructor public class CenterPaneController { @FXML private UsersTableView usersTableView; @FXML private ConnectionsTableView connectionsTableView; @FXML private DevicesTableView devicesTableView; @FXML private TagsTableView tagsTableView; @FXML private DisplayTableView displayTableView; @FXML private AnchorPane tablesAnchorPane;
public void setVisibleTable(EruGroup eruGroup) {
assemblits/eru
Eru/src/main/java/org/assemblits/eru/gui/component/DisplayTableView.java
// Path: Eru/src/main/java/org/assemblits/eru/entities/Display.java // @Entity // @Table(name = "display", schema = "public") // public class Display { // // private final IntegerProperty id; // private StringProperty name; // private StringProperty groupName; // private BooleanProperty initialDisplay; // private ObjectProperty<StageType> stageType; // private ObjectProperty<Parent> fxNode; // // public Display() { // this.id = new SimpleIntegerProperty(this, "display_id"); // this.name = new SimpleStringProperty(this, "name", ""); // this.groupName = new SimpleStringProperty(this, "name", ""); // this.initialDisplay = new SimpleBooleanProperty(this, "initial_display", false); // this.stageType = new SimpleObjectProperty<>(this, "stageType", StageType.REPLACE); // this.fxNode = new SimpleObjectProperty<>(this, "fxNode", null); // } // // @Id // @Column(name = "display_id") // @GeneratedValue(strategy = GenerationType.AUTO) // public Integer getId() { // return id.get(); // } // // public IntegerProperty idProperty() { // return id; // } // // public void setId(Integer id) { // this.id.set(id); // } // // @Column(name = "name") // public String getName() { // return name.get(); // } // // public StringProperty nameProperty() { // return name; // } // // public void setName(String name) { // this.name.set(name); // } // // @Column(name = "group_name") // public String getGroupName() { // return groupName.get(); // } // // public StringProperty groupNameProperty() { // return groupName; // } // // public void setGroupName(String groupName) { // this.groupName.set(groupName); // } // // @Column(name = "initial_display") // public boolean isInitialDisplay() { // return initialDisplay.get(); // } // // public BooleanProperty initialDisplayProperty() { // return initialDisplay; // } // // public void setInitialDisplay(boolean initialDisplay) { // this.initialDisplay.set(initialDisplay); // } // // @Transient // public StageType getStageType() { // return stageType.get(); // } // // public ObjectProperty<StageType> stageTypeProperty() { // return stageType; // } // // public void setStageType(StageType stageType) { // this.stageType.set(stageType); // } // // @Column(name = "stage_type") // public String getStageTypeName() { // return getStageType() == null ? "" : getStageType().name(); // } // // public void setStageTypeName(String name) { // setStageType(name == null || name.isEmpty() ? StageType.REPLACE : StageType.valueOf(name)); // } // // @Transient // public Parent getFxNode() { // return fxNode.get(); // } // // public ObjectProperty<Parent> fxNodeProperty() { // return fxNode; // } // // public void setFxNode(Parent fxNode) { // this.fxNode.set(fxNode); // } // // public enum StageType {REPLACE, NEW} // // @Override // public String toString() { // return getGroupName()+":"+getName(); // } // }
import lombok.Data; import lombok.EqualsAndHashCode; import lombok.extern.slf4j.Slf4j; import org.assemblits.eru.entities.Display; import java.util.Optional; import java.util.function.Consumer; import javafx.collections.FXCollections; import javafx.collections.ObservableList; import javafx.geometry.Insets; import javafx.geometry.Pos; import javafx.scene.Node; import javafx.scene.control.*; import javafx.scene.control.cell.CheckBoxTableCell; import javafx.scene.control.cell.ChoiceBoxTableCell; import javafx.scene.control.cell.TextFieldTableCell; import javafx.scene.image.Image; import javafx.scene.image.ImageView; import javafx.scene.layout.GridPane;
/****************************************************************************** * Copyright (c) 2017 Assemblits contributors * * * * This file is part of Eru The open JavaFX SCADA by Assemblits Organization. * * * * Eru The open JavaFX SCADA is free software: you can redistribute it * * and/or modify it under the terms of the GNU General Public License * * as published by the Free Software Foundation, either version 3 * * of the License, or (at your option) any later version. * * * * Eru is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with Foobar. If not, see <http://www.gnu.org/licenses/>. * ******************************************************************************/ package org.assemblits.eru.gui.component; @Slf4j @Data @EqualsAndHashCode(callSuper = true)
// Path: Eru/src/main/java/org/assemblits/eru/entities/Display.java // @Entity // @Table(name = "display", schema = "public") // public class Display { // // private final IntegerProperty id; // private StringProperty name; // private StringProperty groupName; // private BooleanProperty initialDisplay; // private ObjectProperty<StageType> stageType; // private ObjectProperty<Parent> fxNode; // // public Display() { // this.id = new SimpleIntegerProperty(this, "display_id"); // this.name = new SimpleStringProperty(this, "name", ""); // this.groupName = new SimpleStringProperty(this, "name", ""); // this.initialDisplay = new SimpleBooleanProperty(this, "initial_display", false); // this.stageType = new SimpleObjectProperty<>(this, "stageType", StageType.REPLACE); // this.fxNode = new SimpleObjectProperty<>(this, "fxNode", null); // } // // @Id // @Column(name = "display_id") // @GeneratedValue(strategy = GenerationType.AUTO) // public Integer getId() { // return id.get(); // } // // public IntegerProperty idProperty() { // return id; // } // // public void setId(Integer id) { // this.id.set(id); // } // // @Column(name = "name") // public String getName() { // return name.get(); // } // // public StringProperty nameProperty() { // return name; // } // // public void setName(String name) { // this.name.set(name); // } // // @Column(name = "group_name") // public String getGroupName() { // return groupName.get(); // } // // public StringProperty groupNameProperty() { // return groupName; // } // // public void setGroupName(String groupName) { // this.groupName.set(groupName); // } // // @Column(name = "initial_display") // public boolean isInitialDisplay() { // return initialDisplay.get(); // } // // public BooleanProperty initialDisplayProperty() { // return initialDisplay; // } // // public void setInitialDisplay(boolean initialDisplay) { // this.initialDisplay.set(initialDisplay); // } // // @Transient // public StageType getStageType() { // return stageType.get(); // } // // public ObjectProperty<StageType> stageTypeProperty() { // return stageType; // } // // public void setStageType(StageType stageType) { // this.stageType.set(stageType); // } // // @Column(name = "stage_type") // public String getStageTypeName() { // return getStageType() == null ? "" : getStageType().name(); // } // // public void setStageTypeName(String name) { // setStageType(name == null || name.isEmpty() ? StageType.REPLACE : StageType.valueOf(name)); // } // // @Transient // public Parent getFxNode() { // return fxNode.get(); // } // // public ObjectProperty<Parent> fxNodeProperty() { // return fxNode; // } // // public void setFxNode(Parent fxNode) { // this.fxNode.set(fxNode); // } // // public enum StageType {REPLACE, NEW} // // @Override // public String toString() { // return getGroupName()+":"+getName(); // } // } // Path: Eru/src/main/java/org/assemblits/eru/gui/component/DisplayTableView.java import lombok.Data; import lombok.EqualsAndHashCode; import lombok.extern.slf4j.Slf4j; import org.assemblits.eru.entities.Display; import java.util.Optional; import java.util.function.Consumer; import javafx.collections.FXCollections; import javafx.collections.ObservableList; import javafx.geometry.Insets; import javafx.geometry.Pos; import javafx.scene.Node; import javafx.scene.control.*; import javafx.scene.control.cell.CheckBoxTableCell; import javafx.scene.control.cell.ChoiceBoxTableCell; import javafx.scene.control.cell.TextFieldTableCell; import javafx.scene.image.Image; import javafx.scene.image.ImageView; import javafx.scene.layout.GridPane; /****************************************************************************** * Copyright (c) 2017 Assemblits contributors * * * * This file is part of Eru The open JavaFX SCADA by Assemblits Organization. * * * * Eru The open JavaFX SCADA is free software: you can redistribute it * * and/or modify it under the terms of the GNU General Public License * * as published by the Free Software Foundation, either version 3 * * of the License, or (at your option) any later version. * * * * Eru is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with Foobar. If not, see <http://www.gnu.org/licenses/>. * ******************************************************************************/ package org.assemblits.eru.gui.component; @Slf4j @Data @EqualsAndHashCode(callSuper = true)
public class DisplayTableView extends EruTableView<Display> {
assemblits/eru
Eru/src/main/java/org/assemblits/eru/jfx/JFXClassUtil.java
// Path: Eru/src/main/java/org/assemblits/eru/util/ClassUtil.java // @UtilityClass // public class ClassUtil { // // public Class<?> loadClass(String className) throws ClassNotFoundException { // return ClassUtil.class.getClassLoader().loadClass(className); // } // // public Optional<String> makeClassNameFromCompiledClassName(@NonNull String className) { // String result; // if (!className.endsWith(".class")) { // result = null; // } else if (className.contains("$")) { // result = null; // } else { // int endIndex = className.length() - 6; // result = className.substring(0, endIndex).replace(separator, "."); // } // return Optional.ofNullable(result); // } // }
import com.oracle.javafx.scenebuilder.kit.library.util.JarExplorer; import javafx.scene.Node; import lombok.NonNull; import org.assemblits.eru.util.ClassUtil; import org.springframework.stereotype.Component; import java.lang.reflect.Modifier;
/****************************************************************************** * Copyright (c) 2017 Assemblits contributors * * * * This file is part of Eru The open JavaFX SCADA by Assemblits Organization. * * * * Eru The open JavaFX SCADA is free software: you can redistribute it * * and/or modify it under the terms of the GNU General Public License * * as published by the Free Software Foundation, either version 3 * * of the License, or (at your option) any later version. * * * * Eru is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with Foobar. If not, see <http://www.gnu.org/licenses/>. * ******************************************************************************/ package org.assemblits.eru.jfx; @Component public class JFXClassUtil { public boolean isNotJavaFxComponent(@NonNull String className) { return !className.startsWith("java.") && !className.startsWith("javax.") && !className.startsWith("javafx.") && !className.startsWith("com.oracle.javafx.scenebuilder.") && !className.startsWith("com.javafx."); } public boolean isJFXComponentClass(String className, String classAbsolutePackage) { if (className != null && isNotJavaFxComponent(className)) { try {
// Path: Eru/src/main/java/org/assemblits/eru/util/ClassUtil.java // @UtilityClass // public class ClassUtil { // // public Class<?> loadClass(String className) throws ClassNotFoundException { // return ClassUtil.class.getClassLoader().loadClass(className); // } // // public Optional<String> makeClassNameFromCompiledClassName(@NonNull String className) { // String result; // if (!className.endsWith(".class")) { // result = null; // } else if (className.contains("$")) { // result = null; // } else { // int endIndex = className.length() - 6; // result = className.substring(0, endIndex).replace(separator, "."); // } // return Optional.ofNullable(result); // } // } // Path: Eru/src/main/java/org/assemblits/eru/jfx/JFXClassUtil.java import com.oracle.javafx.scenebuilder.kit.library.util.JarExplorer; import javafx.scene.Node; import lombok.NonNull; import org.assemblits.eru.util.ClassUtil; import org.springframework.stereotype.Component; import java.lang.reflect.Modifier; /****************************************************************************** * Copyright (c) 2017 Assemblits contributors * * * * This file is part of Eru The open JavaFX SCADA by Assemblits Organization. * * * * Eru The open JavaFX SCADA is free software: you can redistribute it * * and/or modify it under the terms of the GNU General Public License * * as published by the Free Software Foundation, either version 3 * * of the License, or (at your option) any later version. * * * * Eru is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with Foobar. If not, see <http://www.gnu.org/licenses/>. * ******************************************************************************/ package org.assemblits.eru.jfx; @Component public class JFXClassUtil { public boolean isNotJavaFxComponent(@NonNull String className) { return !className.startsWith("java.") && !className.startsWith("javax.") && !className.startsWith("javafx.") && !className.startsWith("com.oracle.javafx.scenebuilder.") && !className.startsWith("com.javafx."); } public boolean isJFXComponentClass(String className, String classAbsolutePackage) { if (className != null && isNotJavaFxComponent(className)) { try {
Class<?> jfxComponentClass = ClassUtil.loadClass(classAbsolutePackage);
assemblits/eru
Eru/src/main/java/org/assemblits/eru/entities/Connection.java
// Path: Eru/src/main/java/org/assemblits/eru/exception/ConnectException.java // public class ConnectException extends java.net.ConnectException { // public ConnectException(String localizedMessage) { // super(localizedMessage); // } // }
import javafx.beans.property.*; import org.assemblits.eru.exception.ConnectException; import javax.persistence.*;
/****************************************************************************** * Copyright (c) 2017 Assemblits contributors * * * * This file is part of Eru The open JavaFX SCADA by Assemblits Organization. * * * * Eru The open JavaFX SCADA is free software: you can redistribute it * * and/or modify it under the terms of the GNU General Public License * * as published by the Free Software Foundation, either version 3 * * of the License, or (at your option) any later version. * * * * Eru is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with Foobar. If not, see <http://www.gnu.org/licenses/>. * ******************************************************************************/ package org.assemblits.eru.entities; @Entity @Table(name = "connection", schema = "public") @Inheritance(strategy = InheritanceType.SINGLE_TABLE) @DiscriminatorColumn(name = "connection_type", discriminatorType = DiscriminatorType.STRING) @DiscriminatorValue(value = "CONNECTION") public abstract class Connection { private IntegerProperty id; private StringProperty name; private BooleanProperty enabled; private IntegerProperty timeout; private IntegerProperty samplingTime; private BooleanProperty connected; private StringProperty status; private StringProperty groupName; public Connection() { this.id = new SimpleIntegerProperty(); this.name = new SimpleStringProperty(""); this.enabled = new SimpleBooleanProperty(false); this.timeout = new SimpleIntegerProperty(3000); this.samplingTime = new SimpleIntegerProperty(500); this.connected = new SimpleBooleanProperty(false); this.status = new SimpleStringProperty(""); this.groupName = new SimpleStringProperty(""); } @Transient
// Path: Eru/src/main/java/org/assemblits/eru/exception/ConnectException.java // public class ConnectException extends java.net.ConnectException { // public ConnectException(String localizedMessage) { // super(localizedMessage); // } // } // Path: Eru/src/main/java/org/assemblits/eru/entities/Connection.java import javafx.beans.property.*; import org.assemblits.eru.exception.ConnectException; import javax.persistence.*; /****************************************************************************** * Copyright (c) 2017 Assemblits contributors * * * * This file is part of Eru The open JavaFX SCADA by Assemblits Organization. * * * * Eru The open JavaFX SCADA is free software: you can redistribute it * * and/or modify it under the terms of the GNU General Public License * * as published by the Free Software Foundation, either version 3 * * of the License, or (at your option) any later version. * * * * Eru is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with Foobar. If not, see <http://www.gnu.org/licenses/>. * ******************************************************************************/ package org.assemblits.eru.entities; @Entity @Table(name = "connection", schema = "public") @Inheritance(strategy = InheritanceType.SINGLE_TABLE) @DiscriminatorColumn(name = "connection_type", discriminatorType = DiscriminatorType.STRING) @DiscriminatorValue(value = "CONNECTION") public abstract class Connection { private IntegerProperty id; private StringProperty name; private BooleanProperty enabled; private IntegerProperty timeout; private IntegerProperty samplingTime; private BooleanProperty connected; private StringProperty status; private StringProperty groupName; public Connection() { this.id = new SimpleIntegerProperty(); this.name = new SimpleStringProperty(""); this.enabled = new SimpleBooleanProperty(false); this.timeout = new SimpleIntegerProperty(3000); this.samplingTime = new SimpleIntegerProperty(500); this.connected = new SimpleBooleanProperty(false); this.status = new SimpleStringProperty(""); this.groupName = new SimpleStringProperty(""); } @Transient
public abstract void connect() throws ConnectException;
assemblits/eru
Eru/src/main/java/org/assemblits/eru/preferences/EruPreferences.java
// Path: Eru/src/main/java/org/assemblits/eru/gui/Application.java // @Slf4j // @SpringBootApplication // @ComponentScan("org.assemblits.eru") // public class Application extends javafx.application.Application { // // private ConfigurableApplicationContext applicationContext; // @Autowired // private EruController eruController; // // public static void main(String[] args) { // launchApplication(Application.class, args); // } // // @Override // public void start(Stage stage) throws Exception { // final EruPreferences eruPreferences = new EruPreferences(); // if (!eruPreferences.getApplicationConfigured().getValue()) { // StartUpWizard startUpWizard = new StartUpWizard(stage, eruPreferences); // startUpWizard.startWizard(); // } // // ApplicationLoader applicationLoader = new ApplicationLoader(this, getClass(), getApplicationParameters()); // Preloader preloaderWindow = loadService(applicationLoader); // applicationLoader.setOnSucceeded(event -> { // applicationContext = (ConfigurableApplicationContext) event.getSource().getValue(); // eruController.startEru(stage); // }); // // preloaderWindow.start(stage); // applicationLoader.start(); // } // // @Override // public void stop() throws Exception { // super.stop(); // applicationContext.close(); // } // // private Preloader loadService(ApplicationLoader applicationLoader) { // // TODO: Set Eru Icon to the preloader stage // return new Preloader() { // @Override // public void start(Stage primaryStage) throws Exception { // FXMLLoader loader = new FXMLLoader(); // loader.setController(new EruPreloaderController(applicationLoader)); // loader.setLocation(getClass().getResource("/views/Preloader.fxml")); // Parent preLoader = loader.load(); // // primaryStage.setScene(new Scene(preLoader)); // primaryStage.show(); // } // }; // } // // private String[] getApplicationParameters() { // ApplicationArgsPreparer environmentPreparer = new ApplicationArgsPreparer(); // final Parameters parametersObject = getParameters(); // return environmentPreparer.prepare(parametersObject.getRaw().toArray(new String[0])); // } // // public enum Theme { // DEFAULT, DARK; // public String getStyleSheetURL(){ // return "/views/styles/" + name() + ".css"; // } // } // // }
import lombok.Data; import lombok.extern.slf4j.Slf4j; import org.assemblits.eru.gui.Application; import org.springframework.stereotype.Component; import java.util.prefs.Preferences;
/****************************************************************************** * Copyright (c) 2017 Assemblits contributors * * * * This file is part of Eru The open JavaFX SCADA by Assemblits Organization. * * * * Eru The open JavaFX SCADA is free software: you can redistribute it * * and/or modify it under the terms of the GNU General Public License * * as published by the Free Software Foundation, either version 3 * * of the License, or (at your option) any later version. * * * * Eru is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with Foobar. If not, see <http://www.gnu.org/licenses/>. * ******************************************************************************/ package org.assemblits.eru.preferences; @Slf4j @Data @Component public class EruPreferences { private final Preferences appPreferences;
// Path: Eru/src/main/java/org/assemblits/eru/gui/Application.java // @Slf4j // @SpringBootApplication // @ComponentScan("org.assemblits.eru") // public class Application extends javafx.application.Application { // // private ConfigurableApplicationContext applicationContext; // @Autowired // private EruController eruController; // // public static void main(String[] args) { // launchApplication(Application.class, args); // } // // @Override // public void start(Stage stage) throws Exception { // final EruPreferences eruPreferences = new EruPreferences(); // if (!eruPreferences.getApplicationConfigured().getValue()) { // StartUpWizard startUpWizard = new StartUpWizard(stage, eruPreferences); // startUpWizard.startWizard(); // } // // ApplicationLoader applicationLoader = new ApplicationLoader(this, getClass(), getApplicationParameters()); // Preloader preloaderWindow = loadService(applicationLoader); // applicationLoader.setOnSucceeded(event -> { // applicationContext = (ConfigurableApplicationContext) event.getSource().getValue(); // eruController.startEru(stage); // }); // // preloaderWindow.start(stage); // applicationLoader.start(); // } // // @Override // public void stop() throws Exception { // super.stop(); // applicationContext.close(); // } // // private Preloader loadService(ApplicationLoader applicationLoader) { // // TODO: Set Eru Icon to the preloader stage // return new Preloader() { // @Override // public void start(Stage primaryStage) throws Exception { // FXMLLoader loader = new FXMLLoader(); // loader.setController(new EruPreloaderController(applicationLoader)); // loader.setLocation(getClass().getResource("/views/Preloader.fxml")); // Parent preLoader = loader.load(); // // primaryStage.setScene(new Scene(preLoader)); // primaryStage.show(); // } // }; // } // // private String[] getApplicationParameters() { // ApplicationArgsPreparer environmentPreparer = new ApplicationArgsPreparer(); // final Parameters parametersObject = getParameters(); // return environmentPreparer.prepare(parametersObject.getRaw().toArray(new String[0])); // } // // public enum Theme { // DEFAULT, DARK; // public String getStyleSheetURL(){ // return "/views/styles/" + name() + ".css"; // } // } // // } // Path: Eru/src/main/java/org/assemblits/eru/preferences/EruPreferences.java import lombok.Data; import lombok.extern.slf4j.Slf4j; import org.assemblits.eru.gui.Application; import org.springframework.stereotype.Component; import java.util.prefs.Preferences; /****************************************************************************** * Copyright (c) 2017 Assemblits contributors * * * * This file is part of Eru The open JavaFX SCADA by Assemblits Organization. * * * * Eru The open JavaFX SCADA is free software: you can redistribute it * * and/or modify it under the terms of the GNU General Public License * * as published by the Free Software Foundation, either version 3 * * of the License, or (at your option) any later version. * * * * Eru is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with Foobar. If not, see <http://www.gnu.org/licenses/>. * ******************************************************************************/ package org.assemblits.eru.preferences; @Slf4j @Data @Component public class EruPreferences { private final Preferences appPreferences;
private final EruPreference<Application.Theme> theme;
assemblits/eru
Eru/src/main/java/org/assemblits/eru/gui/controller/EruPreloaderController.java
// Path: Eru/src/main/java/org/assemblits/eru/gui/service/ApplicationLoader.java // @Slf4j // public class ApplicationLoader extends Service<ConfigurableApplicationContext> { // // private final Object appObject; // private final Class<?> appClass; // private final String[] appArgs; // private ProjectCreator projectCreator; // // public ApplicationLoader(@NonNull Object appObject, @NonNull Class<?> appClass, @NonNull String[] appArgs) { // this.appObject = appObject; // this.appClass = appClass; // this.appArgs = appArgs; // projectCreator = new ProjectCreator(); // } // // @Override // protected Task<ConfigurableApplicationContext> createTask() { // return new Task<ConfigurableApplicationContext>() { // @Override // protected ConfigurableApplicationContext call() throws Exception { // log.info("Starting application context"); // updateMessage("Starting application context"); // updateProgress(5, 100); // ConfigurableApplicationContext applicationContext = startApplicationContext(); // try { // log.info("Preparing database"); // updateMessage("Starting application context"); // ConfigurableListableBeanFactory beanFactory = applicationContext.getBeanFactory(); // ProjectRepository projectRepository = beanFactory.getBean(ProjectRepository.class); // CustomLibraryLoader customLibraryLoader = beanFactory.getBean(CustomLibraryLoader.class); // ProjectModel projectModel = beanFactory.getBean(ProjectModel.class); // // log.info("Searching project"); // updateMessage("Searching project"); // updateProgress(75, 100); // Project project; // List<Project> projects = projectRepository.findAll(); // // if (projects.isEmpty()) { // log.info("No project found, creating a new one..."); // updateMessage("No project found, creating a new one..."); // project = projectRepository.save(projectCreator.defaultProject()); // } else { // project = projects.get(0); // TODO: Project picker: Issue #86 // } // // log.info("Loading " + project.getName() + " project..."); // updateMessage("Loading " + project.getName() + " project..."); // projectModel.load(project); // // log.info("Loading custom components"); // updateMessage("Loading custom components"); // updateProgress(85, 100); // customLibraryLoader.loadFromClassPath(); // // log.info("Application loaded successfully"); // updateMessage("Application loaded successfully"); // updateProgress(100, 100); // } catch (Exception e) { // e.printStackTrace(); // } // return applicationContext; // } // }; // } // // private ConfigurableApplicationContext startApplicationContext() { // ConfigurableApplicationContext applicationContext = SpringApplication.run(appClass, appArgs); // applicationContext.getAutowireCapableBeanFactory().autowireBean(appObject); // return applicationContext; // } // // }
import javafx.fxml.FXML; import javafx.scene.control.Label; import javafx.scene.control.ProgressBar; import lombok.RequiredArgsConstructor; import org.assemblits.eru.gui.service.ApplicationLoader;
/****************************************************************************** * Copyright (c) 2017 Assemblits contributors * * * * This file is part of Eru The open JavaFX SCADA by Assemblits Organization. * * * * Eru The open JavaFX SCADA is free software: you can redistribute it * * and/or modify it under the terms of the GNU General Public License * * as published by the Free Software Foundation, either version 3 * * of the License, or (at your option) any later version. * * * * Eru is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with Foobar. If not, see <http://www.gnu.org/licenses/>. * ******************************************************************************/ package org.assemblits.eru.gui.controller; @RequiredArgsConstructor public class EruPreloaderController {
// Path: Eru/src/main/java/org/assemblits/eru/gui/service/ApplicationLoader.java // @Slf4j // public class ApplicationLoader extends Service<ConfigurableApplicationContext> { // // private final Object appObject; // private final Class<?> appClass; // private final String[] appArgs; // private ProjectCreator projectCreator; // // public ApplicationLoader(@NonNull Object appObject, @NonNull Class<?> appClass, @NonNull String[] appArgs) { // this.appObject = appObject; // this.appClass = appClass; // this.appArgs = appArgs; // projectCreator = new ProjectCreator(); // } // // @Override // protected Task<ConfigurableApplicationContext> createTask() { // return new Task<ConfigurableApplicationContext>() { // @Override // protected ConfigurableApplicationContext call() throws Exception { // log.info("Starting application context"); // updateMessage("Starting application context"); // updateProgress(5, 100); // ConfigurableApplicationContext applicationContext = startApplicationContext(); // try { // log.info("Preparing database"); // updateMessage("Starting application context"); // ConfigurableListableBeanFactory beanFactory = applicationContext.getBeanFactory(); // ProjectRepository projectRepository = beanFactory.getBean(ProjectRepository.class); // CustomLibraryLoader customLibraryLoader = beanFactory.getBean(CustomLibraryLoader.class); // ProjectModel projectModel = beanFactory.getBean(ProjectModel.class); // // log.info("Searching project"); // updateMessage("Searching project"); // updateProgress(75, 100); // Project project; // List<Project> projects = projectRepository.findAll(); // // if (projects.isEmpty()) { // log.info("No project found, creating a new one..."); // updateMessage("No project found, creating a new one..."); // project = projectRepository.save(projectCreator.defaultProject()); // } else { // project = projects.get(0); // TODO: Project picker: Issue #86 // } // // log.info("Loading " + project.getName() + " project..."); // updateMessage("Loading " + project.getName() + " project..."); // projectModel.load(project); // // log.info("Loading custom components"); // updateMessage("Loading custom components"); // updateProgress(85, 100); // customLibraryLoader.loadFromClassPath(); // // log.info("Application loaded successfully"); // updateMessage("Application loaded successfully"); // updateProgress(100, 100); // } catch (Exception e) { // e.printStackTrace(); // } // return applicationContext; // } // }; // } // // private ConfigurableApplicationContext startApplicationContext() { // ConfigurableApplicationContext applicationContext = SpringApplication.run(appClass, appArgs); // applicationContext.getAutowireCapableBeanFactory().autowireBean(appObject); // return applicationContext; // } // // } // Path: Eru/src/main/java/org/assemblits/eru/gui/controller/EruPreloaderController.java import javafx.fxml.FXML; import javafx.scene.control.Label; import javafx.scene.control.ProgressBar; import lombok.RequiredArgsConstructor; import org.assemblits.eru.gui.service.ApplicationLoader; /****************************************************************************** * Copyright (c) 2017 Assemblits contributors * * * * This file is part of Eru The open JavaFX SCADA by Assemblits Organization. * * * * Eru The open JavaFX SCADA is free software: you can redistribute it * * and/or modify it under the terms of the GNU General Public License * * as published by the Free Software Foundation, either version 3 * * of the License, or (at your option) any later version. * * * * Eru is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with Foobar. If not, see <http://www.gnu.org/licenses/>. * ******************************************************************************/ package org.assemblits.eru.gui.controller; @RequiredArgsConstructor public class EruPreloaderController {
private final ApplicationLoader applicationLoader;
assemblits/eru
Eru/src/main/java/org/assemblits/eru/gui/controller/ProjectTreeController.java
// Path: Eru/src/main/java/org/assemblits/eru/entities/EruGroup.java // @Entity // @Table(name = "eru_group", schema = "public") // @Inheritance(strategy = InheritanceType.SINGLE_TABLE) // public class EruGroup { // // private IntegerProperty id; // private StringProperty name; // private ObjectProperty<EruType> type; // private ObjectProperty<EruGroup> parent; // private List<EruGroup> children; // // public EruGroup() { // this.id = new SimpleIntegerProperty(); // this.name = new SimpleStringProperty(); // this.type = new SimpleObjectProperty<>(EruType.UNKNOWN); // this.parent = new SimpleObjectProperty<>(); // this.children = new SimpleListProperty<>(FXCollections.observableArrayList()); // } // // @Id @GeneratedValue(strategy=GenerationType.AUTO) // public Integer getId() { // return id.get(); // } // public IntegerProperty idProperty() { // return id; // } // public void setId(Integer id) { // this.id.set(id); // } // // public String getName() { // return name.get(); // } // public StringProperty nameProperty() { // return name; // } // public void setName(String name) { // this.name.set(name); // } // // public EruType getType() { // return type.get(); // } // public ObjectProperty<EruType> typeProperty() { // return type; // } // public void setType(EruType type) { // this.type.set(type); // } // // @OneToOne(cascade= CascadeType.ALL, orphanRemoval = true) // public EruGroup getParent() { // return parent.get(); // } // public ObjectProperty<EruGroup> parentProperty() { // return parent; // } // public void setParent(EruGroup parent) { // this.parent.set(parent); // } // // @LazyCollection(LazyCollectionOption.FALSE) // @OneToMany(cascade= CascadeType.ALL, orphanRemoval = true) // public List<EruGroup> getChildren() { // return children; // } // public void setChildren(List<EruGroup> children) { // this.children = children; // } // // @Override // public String toString() { // return "EruGroup{" + getName() + // "=" + super.toString() + // ", children= <" + children + // "> }"; // } // } // // Path: Eru/src/main/java/org/assemblits/eru/entities/EruType.java // public enum EruType { // DEVICE, // CONNECTION, // TAG, // USER, // DISPLAY, // UNKNOWN // }
import javafx.fxml.FXML; import javafx.scene.control.*; import javafx.scene.image.Image; import javafx.scene.image.ImageView; import lombok.Getter; import org.assemblits.eru.entities.EruGroup; import org.assemblits.eru.entities.EruType; import org.springframework.stereotype.Component; import java.util.Optional; import java.util.function.Consumer;
/****************************************************************************** * Copyright (c) 2017 Assemblits contributors * * * * This file is part of Eru The open JavaFX SCADA by Assemblits Organization. * * * * Eru The open JavaFX SCADA is free software: you can redistribute it * * and/or modify it under the terms of the GNU General Public License * * as published by the Free Software Foundation, either version 3 * * of the License, or (at your option) any later version. * * * * Eru is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with Foobar. If not, see <http://www.gnu.org/licenses/>. * ******************************************************************************/ package org.assemblits.eru.gui.controller; @Getter @Component public class ProjectTreeController { @FXML
// Path: Eru/src/main/java/org/assemblits/eru/entities/EruGroup.java // @Entity // @Table(name = "eru_group", schema = "public") // @Inheritance(strategy = InheritanceType.SINGLE_TABLE) // public class EruGroup { // // private IntegerProperty id; // private StringProperty name; // private ObjectProperty<EruType> type; // private ObjectProperty<EruGroup> parent; // private List<EruGroup> children; // // public EruGroup() { // this.id = new SimpleIntegerProperty(); // this.name = new SimpleStringProperty(); // this.type = new SimpleObjectProperty<>(EruType.UNKNOWN); // this.parent = new SimpleObjectProperty<>(); // this.children = new SimpleListProperty<>(FXCollections.observableArrayList()); // } // // @Id @GeneratedValue(strategy=GenerationType.AUTO) // public Integer getId() { // return id.get(); // } // public IntegerProperty idProperty() { // return id; // } // public void setId(Integer id) { // this.id.set(id); // } // // public String getName() { // return name.get(); // } // public StringProperty nameProperty() { // return name; // } // public void setName(String name) { // this.name.set(name); // } // // public EruType getType() { // return type.get(); // } // public ObjectProperty<EruType> typeProperty() { // return type; // } // public void setType(EruType type) { // this.type.set(type); // } // // @OneToOne(cascade= CascadeType.ALL, orphanRemoval = true) // public EruGroup getParent() { // return parent.get(); // } // public ObjectProperty<EruGroup> parentProperty() { // return parent; // } // public void setParent(EruGroup parent) { // this.parent.set(parent); // } // // @LazyCollection(LazyCollectionOption.FALSE) // @OneToMany(cascade= CascadeType.ALL, orphanRemoval = true) // public List<EruGroup> getChildren() { // return children; // } // public void setChildren(List<EruGroup> children) { // this.children = children; // } // // @Override // public String toString() { // return "EruGroup{" + getName() + // "=" + super.toString() + // ", children= <" + children + // "> }"; // } // } // // Path: Eru/src/main/java/org/assemblits/eru/entities/EruType.java // public enum EruType { // DEVICE, // CONNECTION, // TAG, // USER, // DISPLAY, // UNKNOWN // } // Path: Eru/src/main/java/org/assemblits/eru/gui/controller/ProjectTreeController.java import javafx.fxml.FXML; import javafx.scene.control.*; import javafx.scene.image.Image; import javafx.scene.image.ImageView; import lombok.Getter; import org.assemblits.eru.entities.EruGroup; import org.assemblits.eru.entities.EruType; import org.springframework.stereotype.Component; import java.util.Optional; import java.util.function.Consumer; /****************************************************************************** * Copyright (c) 2017 Assemblits contributors * * * * This file is part of Eru The open JavaFX SCADA by Assemblits Organization. * * * * Eru The open JavaFX SCADA is free software: you can redistribute it * * and/or modify it under the terms of the GNU General Public License * * as published by the Free Software Foundation, either version 3 * * of the License, or (at your option) any later version. * * * * Eru is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with Foobar. If not, see <http://www.gnu.org/licenses/>. * ******************************************************************************/ package org.assemblits.eru.gui.controller; @Getter @Component public class ProjectTreeController { @FXML
private TreeView<EruGroup> projectTree;
assemblits/eru
Eru/src/main/java/org/assemblits/eru/gui/controller/ProjectTreeController.java
// Path: Eru/src/main/java/org/assemblits/eru/entities/EruGroup.java // @Entity // @Table(name = "eru_group", schema = "public") // @Inheritance(strategy = InheritanceType.SINGLE_TABLE) // public class EruGroup { // // private IntegerProperty id; // private StringProperty name; // private ObjectProperty<EruType> type; // private ObjectProperty<EruGroup> parent; // private List<EruGroup> children; // // public EruGroup() { // this.id = new SimpleIntegerProperty(); // this.name = new SimpleStringProperty(); // this.type = new SimpleObjectProperty<>(EruType.UNKNOWN); // this.parent = new SimpleObjectProperty<>(); // this.children = new SimpleListProperty<>(FXCollections.observableArrayList()); // } // // @Id @GeneratedValue(strategy=GenerationType.AUTO) // public Integer getId() { // return id.get(); // } // public IntegerProperty idProperty() { // return id; // } // public void setId(Integer id) { // this.id.set(id); // } // // public String getName() { // return name.get(); // } // public StringProperty nameProperty() { // return name; // } // public void setName(String name) { // this.name.set(name); // } // // public EruType getType() { // return type.get(); // } // public ObjectProperty<EruType> typeProperty() { // return type; // } // public void setType(EruType type) { // this.type.set(type); // } // // @OneToOne(cascade= CascadeType.ALL, orphanRemoval = true) // public EruGroup getParent() { // return parent.get(); // } // public ObjectProperty<EruGroup> parentProperty() { // return parent; // } // public void setParent(EruGroup parent) { // this.parent.set(parent); // } // // @LazyCollection(LazyCollectionOption.FALSE) // @OneToMany(cascade= CascadeType.ALL, orphanRemoval = true) // public List<EruGroup> getChildren() { // return children; // } // public void setChildren(List<EruGroup> children) { // this.children = children; // } // // @Override // public String toString() { // return "EruGroup{" + getName() + // "=" + super.toString() + // ", children= <" + children + // "> }"; // } // } // // Path: Eru/src/main/java/org/assemblits/eru/entities/EruType.java // public enum EruType { // DEVICE, // CONNECTION, // TAG, // USER, // DISPLAY, // UNKNOWN // }
import javafx.fxml.FXML; import javafx.scene.control.*; import javafx.scene.image.Image; import javafx.scene.image.ImageView; import lombok.Getter; import org.assemblits.eru.entities.EruGroup; import org.assemblits.eru.entities.EruType; import org.springframework.stereotype.Component; import java.util.Optional; import java.util.function.Consumer;
} }); return groupTreeCell; }); } private TreeItem<EruGroup> createTree(EruGroup eruGroup) { TreeItem<EruGroup> treeItem = new TreeItem<>(eruGroup); for (EruGroup t : eruGroup.getChildren()) { treeItem.getChildren().add(createTree(t)); } return treeItem; } private class GroupTreeCell extends TreeCell<EruGroup> { private final Image rootIcon = new Image(getClass().getResourceAsStream("/images/project-icon.png")); private final Image connectionIcon = new Image(getClass().getResourceAsStream("/images/connection-icon.png")); private final Image deviceIcon = new Image(getClass().getResourceAsStream("/images/device-icon.png")); private final Image tagIcon = new Image(getClass().getResourceAsStream("/images/tag-icon.png")); private final Image userIcon = new Image(getClass().getResourceAsStream("/images/user-icon.png")); private final Image displayIcon = new Image(getClass().getResourceAsStream("/images/display-icon.png")); private final ContextMenu connectionsMenu = new ContextMenu(); private final ContextMenu devicesMenu = new ContextMenu(); private final ContextMenu tagsMenu = new ContextMenu(); private final ContextMenu usersMenu = new ContextMenu(); private final ContextMenu displaysMenu = new ContextMenu(); public GroupTreeCell() {
// Path: Eru/src/main/java/org/assemblits/eru/entities/EruGroup.java // @Entity // @Table(name = "eru_group", schema = "public") // @Inheritance(strategy = InheritanceType.SINGLE_TABLE) // public class EruGroup { // // private IntegerProperty id; // private StringProperty name; // private ObjectProperty<EruType> type; // private ObjectProperty<EruGroup> parent; // private List<EruGroup> children; // // public EruGroup() { // this.id = new SimpleIntegerProperty(); // this.name = new SimpleStringProperty(); // this.type = new SimpleObjectProperty<>(EruType.UNKNOWN); // this.parent = new SimpleObjectProperty<>(); // this.children = new SimpleListProperty<>(FXCollections.observableArrayList()); // } // // @Id @GeneratedValue(strategy=GenerationType.AUTO) // public Integer getId() { // return id.get(); // } // public IntegerProperty idProperty() { // return id; // } // public void setId(Integer id) { // this.id.set(id); // } // // public String getName() { // return name.get(); // } // public StringProperty nameProperty() { // return name; // } // public void setName(String name) { // this.name.set(name); // } // // public EruType getType() { // return type.get(); // } // public ObjectProperty<EruType> typeProperty() { // return type; // } // public void setType(EruType type) { // this.type.set(type); // } // // @OneToOne(cascade= CascadeType.ALL, orphanRemoval = true) // public EruGroup getParent() { // return parent.get(); // } // public ObjectProperty<EruGroup> parentProperty() { // return parent; // } // public void setParent(EruGroup parent) { // this.parent.set(parent); // } // // @LazyCollection(LazyCollectionOption.FALSE) // @OneToMany(cascade= CascadeType.ALL, orphanRemoval = true) // public List<EruGroup> getChildren() { // return children; // } // public void setChildren(List<EruGroup> children) { // this.children = children; // } // // @Override // public String toString() { // return "EruGroup{" + getName() + // "=" + super.toString() + // ", children= <" + children + // "> }"; // } // } // // Path: Eru/src/main/java/org/assemblits/eru/entities/EruType.java // public enum EruType { // DEVICE, // CONNECTION, // TAG, // USER, // DISPLAY, // UNKNOWN // } // Path: Eru/src/main/java/org/assemblits/eru/gui/controller/ProjectTreeController.java import javafx.fxml.FXML; import javafx.scene.control.*; import javafx.scene.image.Image; import javafx.scene.image.ImageView; import lombok.Getter; import org.assemblits.eru.entities.EruGroup; import org.assemblits.eru.entities.EruType; import org.springframework.stereotype.Component; import java.util.Optional; import java.util.function.Consumer; } }); return groupTreeCell; }); } private TreeItem<EruGroup> createTree(EruGroup eruGroup) { TreeItem<EruGroup> treeItem = new TreeItem<>(eruGroup); for (EruGroup t : eruGroup.getChildren()) { treeItem.getChildren().add(createTree(t)); } return treeItem; } private class GroupTreeCell extends TreeCell<EruGroup> { private final Image rootIcon = new Image(getClass().getResourceAsStream("/images/project-icon.png")); private final Image connectionIcon = new Image(getClass().getResourceAsStream("/images/connection-icon.png")); private final Image deviceIcon = new Image(getClass().getResourceAsStream("/images/device-icon.png")); private final Image tagIcon = new Image(getClass().getResourceAsStream("/images/tag-icon.png")); private final Image userIcon = new Image(getClass().getResourceAsStream("/images/user-icon.png")); private final Image displayIcon = new Image(getClass().getResourceAsStream("/images/display-icon.png")); private final ContextMenu connectionsMenu = new ContextMenu(); private final ContextMenu devicesMenu = new ContextMenu(); private final ContextMenu tagsMenu = new ContextMenu(); private final ContextMenu usersMenu = new ContextMenu(); private final ContextMenu displaysMenu = new ContextMenu(); public GroupTreeCell() {
connectionsMenu.getItems().addAll(getMenuItemToAdd(EruType.CONNECTION), getMenuItemToRename(), getMenuItemToRemove());
assemblits/eru
Eru/src/main/java/org/assemblits/eru/packages/PackageExplorer.java
// Path: Eru/src/main/java/org/assemblits/eru/util/ClassUtil.java // @UtilityClass // public class ClassUtil { // // public Class<?> loadClass(String className) throws ClassNotFoundException { // return ClassUtil.class.getClassLoader().loadClass(className); // } // // public Optional<String> makeClassNameFromCompiledClassName(@NonNull String className) { // String result; // if (!className.endsWith(".class")) { // result = null; // } else if (className.contains("$")) { // result = null; // } else { // int endIndex = className.length() - 6; // result = className.substring(0, endIndex).replace(separator, "."); // } // return Optional.ofNullable(result); // } // }
import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.assemblits.eru.util.ClassUtil; import org.springframework.stereotype.Component; import java.io.File; import java.util.*;
/****************************************************************************** * Copyright (c) 2017 Assemblits contributors * * * * This file is part of Eru The open JavaFX SCADA by Assemblits Organization. * * * * Eru The open JavaFX SCADA is free software: you can redistribute it * * and/or modify it under the terms of the GNU General Public License * * as published by the Free Software Foundation, either version 3 * * of the License, or (at your option) any later version. * * * * Eru is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with Foobar. If not, see <http://www.gnu.org/licenses/>. * ******************************************************************************/ package org.assemblits.eru.packages; @Slf4j @Component @RequiredArgsConstructor public class PackageExplorer { private static final List<String> TOP_PACKAGES = new ArrayList<String>() {{ add("main"); add("target"); add("classes"); }}; public Set<ClassInfo> exploreAndGetClassesInfo(Collection<String> packages) { Stack<File> directories = new Stack<>(); log.debug("Scanning packages {}", packages); for (String location : packages) { directories.push(new File(getClass().getResource(location).getPath())); } Set<ClassInfo> classesInfo = new HashSet<>(); while (!directories.isEmpty()) { File directory = directories.pop(); for (File file : directory.listFiles()) { if (file.isDirectory()) { directories.push(file); } else {
// Path: Eru/src/main/java/org/assemblits/eru/util/ClassUtil.java // @UtilityClass // public class ClassUtil { // // public Class<?> loadClass(String className) throws ClassNotFoundException { // return ClassUtil.class.getClassLoader().loadClass(className); // } // // public Optional<String> makeClassNameFromCompiledClassName(@NonNull String className) { // String result; // if (!className.endsWith(".class")) { // result = null; // } else if (className.contains("$")) { // result = null; // } else { // int endIndex = className.length() - 6; // result = className.substring(0, endIndex).replace(separator, "."); // } // return Optional.ofNullable(result); // } // } // Path: Eru/src/main/java/org/assemblits/eru/packages/PackageExplorer.java import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.assemblits.eru.util.ClassUtil; import org.springframework.stereotype.Component; import java.io.File; import java.util.*; /****************************************************************************** * Copyright (c) 2017 Assemblits contributors * * * * This file is part of Eru The open JavaFX SCADA by Assemblits Organization. * * * * Eru The open JavaFX SCADA is free software: you can redistribute it * * and/or modify it under the terms of the GNU General Public License * * as published by the Free Software Foundation, either version 3 * * of the License, or (at your option) any later version. * * * * Eru is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with Foobar. If not, see <http://www.gnu.org/licenses/>. * ******************************************************************************/ package org.assemblits.eru.packages; @Slf4j @Component @RequiredArgsConstructor public class PackageExplorer { private static final List<String> TOP_PACKAGES = new ArrayList<String>() {{ add("main"); add("target"); add("classes"); }}; public Set<ClassInfo> exploreAndGetClassesInfo(Collection<String> packages) { Stack<File> directories = new Stack<>(); log.debug("Scanning packages {}", packages); for (String location : packages) { directories.push(new File(getClass().getResource(location).getPath())); } Set<ClassInfo> classesInfo = new HashSet<>(); while (!directories.isEmpty()) { File directory = directories.pop(); for (File file : directory.listFiles()) { if (file.isDirectory()) { directories.push(file); } else {
Optional<String> className = ClassUtil.makeClassNameFromCompiledClassName(file.getName());
whiskeyfei/SimpleNews.io
app/src/main/java/com/kong/lib/utils/ResourceUtil.java
// Path: app/src/main/java/com/kong/lib/AppRun.java // public class AppRun { // // private Context mContext = null; // // private static AppRun sInstance; // // public static AppRun get() { // if (sInstance == null) { // sInstance = new AppRun(); // } // return sInstance; // } // // public void init(Context context) { // if (mContext != null) { // throw new IllegalStateException("App just call once init!!"); // } // mContext = context; // } // // private void ensureAppContext() { // if (mContext == null) { // throw new IllegalStateException("App not call init!!."); // } // } // // public Context getApplicationContext() { // ensureAppContext(); // return mContext; // } // // }
import android.content.Context; import android.content.res.Resources; import android.graphics.drawable.Drawable; import com.kong.lib.AppRun; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader;
package com.kong.lib.utils; /** * Created by whiskeyfei on 16-2-28. */ public class ResourceUtil { public static String getString(int resId) { return getResources().getString(resId); } public static int getColor(int resId) { return getResources().getColor(resId); } public static Drawable getDrawable(int resId) { return getResources().getDrawable(resId); } public static int getDimen(int dimen) { return (int) getResources().getDimension(dimen); } public static Resources getResources() { return getContext().getResources(); } public static Context getContext() {
// Path: app/src/main/java/com/kong/lib/AppRun.java // public class AppRun { // // private Context mContext = null; // // private static AppRun sInstance; // // public static AppRun get() { // if (sInstance == null) { // sInstance = new AppRun(); // } // return sInstance; // } // // public void init(Context context) { // if (mContext != null) { // throw new IllegalStateException("App just call once init!!"); // } // mContext = context; // } // // private void ensureAppContext() { // if (mContext == null) { // throw new IllegalStateException("App not call init!!."); // } // } // // public Context getApplicationContext() { // ensureAppContext(); // return mContext; // } // // } // Path: app/src/main/java/com/kong/lib/utils/ResourceUtil.java import android.content.Context; import android.content.res.Resources; import android.graphics.drawable.Drawable; import com.kong.lib.AppRun; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; package com.kong.lib.utils; /** * Created by whiskeyfei on 16-2-28. */ public class ResourceUtil { public static String getString(int resId) { return getResources().getString(resId); } public static int getColor(int resId) { return getResources().getColor(resId); } public static Drawable getDrawable(int resId) { return getResources().getDrawable(resId); } public static int getDimen(int dimen) { return (int) getResources().getDimension(dimen); } public static Resources getResources() { return getContext().getResources(); } public static Context getContext() {
return AppRun.get().getApplicationContext();
whiskeyfei/SimpleNews.io
app/src/main/java/com/kong/app/news/ui/SettingActivity.java
// Path: app/src/main/java/com/kong/app/news/base/ToolBarActivity.java // public abstract class ToolBarActivity extends BaseActivity { // // private Toolbar mToolbar; // // @Override // protected void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // setContentView(getLayoutId()); // mToolbar = (Toolbar) findViewById(R.id.base_toolbar); // initToolBar(mToolbar); // } // // protected abstract int getLayoutId(); // // @Override // public void setTitle(CharSequence title) { // if (mToolbar != null) { // mToolbar.setTitle(title); // } // } // // @Override // public void setTitle(int titleId) { // if (mToolbar != null) { // mToolbar.setTitle(ResourceUtil.getString(titleId)); // } // } // // public Toolbar getToolbar() { // return mToolbar; // } // // public void initToolBar(Toolbar toolbar) { // if (null != toolbar) { // setSupportActionBar(toolbar); // getSupportActionBar().setDisplayShowHomeEnabled(false); // getSupportActionBar().setDisplayHomeAsUpEnabled(true); // toolbar.setNavigationOnClickListener(new View.OnClickListener() { // @Override // public void onClick(View view) { // onBackPressed(); // } // }); // } // } // // public void initToolBar(Toolbar toolbar, String title) { // toolbar.setTitle(title); // initToolBar(toolbar); // } // // } // // Path: app/src/main/java/com/kong/app/news/fragment/SettingFragment.java // public class SettingFragment extends PreferenceFragment implements Preference.OnPreferenceClickListener, Preference.OnPreferenceChangeListener { // // private Preference mPreferenceTheme; // private Preference mCleanCache; // // public static SettingFragment newInstance() { // Bundle args = new Bundle(); // SettingFragment fragment = new SettingFragment(); // fragment.setArguments(args); // return fragment; // } // // @Override // public void onCreate(@Nullable Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // addPreferencesFromResource(R.xml.setting); // SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getActivity()); // // mCleanCache = findPreference("clean_cache"); // mCleanCache.setOnPreferenceClickListener(this); // mCleanCache.setSummary("0MB"); // // mPreferenceTheme = findPreference("keyTheme"); // mPreferenceTheme.setOnPreferenceClickListener(this); // String[] colorNames = getActivity().getResources().getStringArray(R.array.SettingColorNames); // int currentThemeIndex = SettingsUtil.getThemeIndex(); // if (currentThemeIndex >= colorNames.length) { // mPreferenceTheme.setSummary("自定义色"); // } else { // mPreferenceTheme.setSummary(colorNames[currentThemeIndex]); // } // } // // @Override // public boolean onPreferenceChange(Preference preference, Object newValue) { // return false; // } // // @Override // public boolean onPreferenceClick(Preference preference) { // if (preference == mCleanCache){ // }else if (preference == mPreferenceTheme){ // // new ColorChooserDialog.Builder((SettingActivity)getActivity(), R.string.theme) // // .customColors(R.array.colors, null) // // .doneButton(R.string.done) // // .cancelButton(R.string.cancel) // // .allowUserColorInput(false) // // .allowUserColorInputAlpha(false) // // .show(); // } // return true; // } // // } // // Path: app/src/main/java/com/kong/lib/utils/ResourceUtil.java // public class ResourceUtil { // // public static String getString(int resId) { // return getResources().getString(resId); // } // // public static int getColor(int resId) { // return getResources().getColor(resId); // } // // public static Drawable getDrawable(int resId) { // return getResources().getDrawable(resId); // } // // public static int getDimen(int dimen) { // return (int) getResources().getDimension(dimen); // } // // public static Resources getResources() { // return getContext().getResources(); // } // // public static Context getContext() { // return AppRun.get().getApplicationContext(); // } // // public static String getRawFileStr(int rawId) throws IOException { // InputStream is = getResources().openRawResource(rawId); // BufferedReader reader = new BufferedReader(new InputStreamReader(is, "UTF-8")); // StringBuilder sb = new StringBuilder(); // String line; // while ((line = reader.readLine()) != null) { // sb.append(line).append("\n"); // } // sb.deleteCharAt(sb.length() - 1); // reader.close(); // return sb.toString(); // } // }
import android.os.Bundle; import com.kong.R; import com.kong.app.news.base.ToolBarActivity; import com.kong.app.news.fragment.SettingFragment; import com.kong.lib.utils.ResourceUtil;
package com.kong.app.news.ui; /** * Created by CaoPengfei on 17/6/17. */ public class SettingActivity extends ToolBarActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);
// Path: app/src/main/java/com/kong/app/news/base/ToolBarActivity.java // public abstract class ToolBarActivity extends BaseActivity { // // private Toolbar mToolbar; // // @Override // protected void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // setContentView(getLayoutId()); // mToolbar = (Toolbar) findViewById(R.id.base_toolbar); // initToolBar(mToolbar); // } // // protected abstract int getLayoutId(); // // @Override // public void setTitle(CharSequence title) { // if (mToolbar != null) { // mToolbar.setTitle(title); // } // } // // @Override // public void setTitle(int titleId) { // if (mToolbar != null) { // mToolbar.setTitle(ResourceUtil.getString(titleId)); // } // } // // public Toolbar getToolbar() { // return mToolbar; // } // // public void initToolBar(Toolbar toolbar) { // if (null != toolbar) { // setSupportActionBar(toolbar); // getSupportActionBar().setDisplayShowHomeEnabled(false); // getSupportActionBar().setDisplayHomeAsUpEnabled(true); // toolbar.setNavigationOnClickListener(new View.OnClickListener() { // @Override // public void onClick(View view) { // onBackPressed(); // } // }); // } // } // // public void initToolBar(Toolbar toolbar, String title) { // toolbar.setTitle(title); // initToolBar(toolbar); // } // // } // // Path: app/src/main/java/com/kong/app/news/fragment/SettingFragment.java // public class SettingFragment extends PreferenceFragment implements Preference.OnPreferenceClickListener, Preference.OnPreferenceChangeListener { // // private Preference mPreferenceTheme; // private Preference mCleanCache; // // public static SettingFragment newInstance() { // Bundle args = new Bundle(); // SettingFragment fragment = new SettingFragment(); // fragment.setArguments(args); // return fragment; // } // // @Override // public void onCreate(@Nullable Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // addPreferencesFromResource(R.xml.setting); // SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getActivity()); // // mCleanCache = findPreference("clean_cache"); // mCleanCache.setOnPreferenceClickListener(this); // mCleanCache.setSummary("0MB"); // // mPreferenceTheme = findPreference("keyTheme"); // mPreferenceTheme.setOnPreferenceClickListener(this); // String[] colorNames = getActivity().getResources().getStringArray(R.array.SettingColorNames); // int currentThemeIndex = SettingsUtil.getThemeIndex(); // if (currentThemeIndex >= colorNames.length) { // mPreferenceTheme.setSummary("自定义色"); // } else { // mPreferenceTheme.setSummary(colorNames[currentThemeIndex]); // } // } // // @Override // public boolean onPreferenceChange(Preference preference, Object newValue) { // return false; // } // // @Override // public boolean onPreferenceClick(Preference preference) { // if (preference == mCleanCache){ // }else if (preference == mPreferenceTheme){ // // new ColorChooserDialog.Builder((SettingActivity)getActivity(), R.string.theme) // // .customColors(R.array.colors, null) // // .doneButton(R.string.done) // // .cancelButton(R.string.cancel) // // .allowUserColorInput(false) // // .allowUserColorInputAlpha(false) // // .show(); // } // return true; // } // // } // // Path: app/src/main/java/com/kong/lib/utils/ResourceUtil.java // public class ResourceUtil { // // public static String getString(int resId) { // return getResources().getString(resId); // } // // public static int getColor(int resId) { // return getResources().getColor(resId); // } // // public static Drawable getDrawable(int resId) { // return getResources().getDrawable(resId); // } // // public static int getDimen(int dimen) { // return (int) getResources().getDimension(dimen); // } // // public static Resources getResources() { // return getContext().getResources(); // } // // public static Context getContext() { // return AppRun.get().getApplicationContext(); // } // // public static String getRawFileStr(int rawId) throws IOException { // InputStream is = getResources().openRawResource(rawId); // BufferedReader reader = new BufferedReader(new InputStreamReader(is, "UTF-8")); // StringBuilder sb = new StringBuilder(); // String line; // while ((line = reader.readLine()) != null) { // sb.append(line).append("\n"); // } // sb.deleteCharAt(sb.length() - 1); // reader.close(); // return sb.toString(); // } // } // Path: app/src/main/java/com/kong/app/news/ui/SettingActivity.java import android.os.Bundle; import com.kong.R; import com.kong.app.news.base.ToolBarActivity; import com.kong.app.news.fragment.SettingFragment; import com.kong.lib.utils.ResourceUtil; package com.kong.app.news.ui; /** * Created by CaoPengfei on 17/6/17. */ public class SettingActivity extends ToolBarActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);
setTitle(ResourceUtil.getString(R.string.settings));
whiskeyfei/SimpleNews.io
app/src/main/java/com/kong/lib/adapter/BaseAdapter.java
// Path: app/src/main/java/com/kong/lib/utils/ListUtils.java // public class ListUtils { // /** // * check list is null // * // * @param list // * @return // */ // public static boolean isEmpty(List<?> list) { // return (list == null) || list.isEmpty(); // } // // /** // * check map is null // * // * @param map // * @return // */ // public static boolean isEmpty(Map<?, ?> map) { // return (map == null) || map.isEmpty(); // } // // public static boolean isEmpty(SparseArray<?> map){ // return (map == null) || (map.size() == 0); // } // // /** // * get list count // * // * @param list // * @return // */ // public static int getCount(List<?> list) { // return isEmpty(list) ? 0 : list.size(); // } // }
import android.content.Context; import android.support.v7.widget.RecyclerView; import com.kong.lib.utils.ListUtils; import java.util.List;
package com.kong.lib.adapter; /** * Created by CaoPengfei on 17/8/27. */ public abstract class BaseAdapter<T> extends RecyclerView.Adapter<RecyclerView.ViewHolder> { protected Context mContext; protected List<T> mLists; public BaseAdapter() { } public BaseAdapter(Context context) { mContext = context; } public BaseAdapter(Context context, List<T> lists) { this(context); mLists = lists; } @Override public int getItemCount() {
// Path: app/src/main/java/com/kong/lib/utils/ListUtils.java // public class ListUtils { // /** // * check list is null // * // * @param list // * @return // */ // public static boolean isEmpty(List<?> list) { // return (list == null) || list.isEmpty(); // } // // /** // * check map is null // * // * @param map // * @return // */ // public static boolean isEmpty(Map<?, ?> map) { // return (map == null) || map.isEmpty(); // } // // public static boolean isEmpty(SparseArray<?> map){ // return (map == null) || (map.size() == 0); // } // // /** // * get list count // * // * @param list // * @return // */ // public static int getCount(List<?> list) { // return isEmpty(list) ? 0 : list.size(); // } // } // Path: app/src/main/java/com/kong/lib/adapter/BaseAdapter.java import android.content.Context; import android.support.v7.widget.RecyclerView; import com.kong.lib.utils.ListUtils; import java.util.List; package com.kong.lib.adapter; /** * Created by CaoPengfei on 17/8/27. */ public abstract class BaseAdapter<T> extends RecyclerView.Adapter<RecyclerView.ViewHolder> { protected Context mContext; protected List<T> mLists; public BaseAdapter() { } public BaseAdapter(Context context) { mContext = context; } public BaseAdapter(Context context, List<T> lists) { this(context); mLists = lists; } @Override public int getItemCount() {
return ListUtils.getCount(mLists);
whiskeyfei/SimpleNews.io
app/src/main/java/com/kong/app/news/utils/SettingsUtil.java
// Path: app/src/main/java/com/kong/lib/AppRun.java // public class AppRun { // // private Context mContext = null; // // private static AppRun sInstance; // // public static AppRun get() { // if (sInstance == null) { // sInstance = new AppRun(); // } // return sInstance; // } // // public void init(Context context) { // if (mContext != null) { // throw new IllegalStateException("App just call once init!!"); // } // mContext = context; // } // // private void ensureAppContext() { // if (mContext == null) { // throw new IllegalStateException("App not call init!!."); // } // } // // public Context getApplicationContext() { // ensureAppContext(); // return mContext; // } // // }
import android.content.SharedPreferences; import android.preference.PreferenceManager; import com.kong.lib.AppRun;
package com.kong.app.news.utils; /** * Created by CaoPengfei on 17/6/17. */ public class SettingsUtil { public static int getThemeIndex() {
// Path: app/src/main/java/com/kong/lib/AppRun.java // public class AppRun { // // private Context mContext = null; // // private static AppRun sInstance; // // public static AppRun get() { // if (sInstance == null) { // sInstance = new AppRun(); // } // return sInstance; // } // // public void init(Context context) { // if (mContext != null) { // throw new IllegalStateException("App just call once init!!"); // } // mContext = context; // } // // private void ensureAppContext() { // if (mContext == null) { // throw new IllegalStateException("App not call init!!."); // } // } // // public Context getApplicationContext() { // ensureAppContext(); // return mContext; // } // // } // Path: app/src/main/java/com/kong/app/news/utils/SettingsUtil.java import android.content.SharedPreferences; import android.preference.PreferenceManager; import com.kong.lib.AppRun; package com.kong.app.news.utils; /** * Created by CaoPengfei on 17/6/17. */ public class SettingsUtil { public static int getThemeIndex() {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(AppRun.get().getApplicationContext());
whiskeyfei/SimpleNews.io
app/src/main/java/com/kong/home/tab/widget/TabItemView.java
// Path: app/src/main/java/com/kong/lib/utils/ResourceUtil.java // public class ResourceUtil { // // public static String getString(int resId) { // return getResources().getString(resId); // } // // public static int getColor(int resId) { // return getResources().getColor(resId); // } // // public static Drawable getDrawable(int resId) { // return getResources().getDrawable(resId); // } // // public static int getDimen(int dimen) { // return (int) getResources().getDimension(dimen); // } // // public static Resources getResources() { // return getContext().getResources(); // } // // public static Context getContext() { // return AppRun.get().getApplicationContext(); // } // // public static String getRawFileStr(int rawId) throws IOException { // InputStream is = getResources().openRawResource(rawId); // BufferedReader reader = new BufferedReader(new InputStreamReader(is, "UTF-8")); // StringBuilder sb = new StringBuilder(); // String line; // while ((line = reader.readLine()) != null) { // sb.append(line).append("\n"); // } // sb.deleteCharAt(sb.length() - 1); // reader.close(); // return sb.toString(); // } // }
import android.content.Context; import android.support.annotation.ColorInt; import android.support.annotation.DrawableRes; import android.util.AttributeSet; import android.view.LayoutInflater; import android.widget.FrameLayout; import android.widget.ImageView; import android.widget.TextView; import com.kong.R; import com.kong.lib.utils.ResourceUtil;
package com.kong.home.tab.widget; public class TabItemView extends FrameLayout implements IMsgView { private final ImageView mIcon; private final TextView mTitle; private final IMsgView mMsgView; private int mDefaultDrawable; private int mCheckedDrawable;
// Path: app/src/main/java/com/kong/lib/utils/ResourceUtil.java // public class ResourceUtil { // // public static String getString(int resId) { // return getResources().getString(resId); // } // // public static int getColor(int resId) { // return getResources().getColor(resId); // } // // public static Drawable getDrawable(int resId) { // return getResources().getDrawable(resId); // } // // public static int getDimen(int dimen) { // return (int) getResources().getDimension(dimen); // } // // public static Resources getResources() { // return getContext().getResources(); // } // // public static Context getContext() { // return AppRun.get().getApplicationContext(); // } // // public static String getRawFileStr(int rawId) throws IOException { // InputStream is = getResources().openRawResource(rawId); // BufferedReader reader = new BufferedReader(new InputStreamReader(is, "UTF-8")); // StringBuilder sb = new StringBuilder(); // String line; // while ((line = reader.readLine()) != null) { // sb.append(line).append("\n"); // } // sb.deleteCharAt(sb.length() - 1); // reader.close(); // return sb.toString(); // } // } // Path: app/src/main/java/com/kong/home/tab/widget/TabItemView.java import android.content.Context; import android.support.annotation.ColorInt; import android.support.annotation.DrawableRes; import android.util.AttributeSet; import android.view.LayoutInflater; import android.widget.FrameLayout; import android.widget.ImageView; import android.widget.TextView; import com.kong.R; import com.kong.lib.utils.ResourceUtil; package com.kong.home.tab.widget; public class TabItemView extends FrameLayout implements IMsgView { private final ImageView mIcon; private final TextView mTitle; private final IMsgView mMsgView; private int mDefaultDrawable; private int mCheckedDrawable;
private int mDefaultTextColor = ResourceUtil.getColor(R.color.tab_normal);
whiskeyfei/SimpleNews.io
app/src/main/java/com/kong/app/demo/me/MeActivity.java
// Path: app/src/main/java/com/kong/app/demo/about/TextItemViewBinder.java // public class TextItemViewBinder extends ItemViewBinder<TextViewItem, TextItemViewBinder.TextHolder> { // // @NonNull // @Override // protected TextHolder onCreateViewHolder(@NonNull LayoutInflater inflater, @NonNull ViewGroup parent) { // View inflate = inflater.inflate(R.layout.item_textview, parent, false); // return new TextHolder(inflate); // } // // @Override // protected void onBindViewHolder(@NonNull TextHolder holder, @NonNull TextViewItem textItem) { // holder.text.setText(textItem.text); // } // // static class TextHolder extends RecyclerView.ViewHolder { // // private final TextView text; // // TextHolder(@NonNull View itemView) { // super(itemView); // this.text = (TextView) itemView.findViewById(R.id.item_textview_id); // } // } // } // // Path: app/src/main/java/com/kong/app/demo/about/TextViewItem.java // public class TextViewItem { // // public String text; // // } // // Path: app/src/main/java/com/kong/app/news/base/ToolBarActivity.java // public abstract class ToolBarActivity extends BaseActivity { // // private Toolbar mToolbar; // // @Override // protected void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // setContentView(getLayoutId()); // mToolbar = (Toolbar) findViewById(R.id.base_toolbar); // initToolBar(mToolbar); // } // // protected abstract int getLayoutId(); // // @Override // public void setTitle(CharSequence title) { // if (mToolbar != null) { // mToolbar.setTitle(title); // } // } // // @Override // public void setTitle(int titleId) { // if (mToolbar != null) { // mToolbar.setTitle(ResourceUtil.getString(titleId)); // } // } // // public Toolbar getToolbar() { // return mToolbar; // } // // public void initToolBar(Toolbar toolbar) { // if (null != toolbar) { // setSupportActionBar(toolbar); // getSupportActionBar().setDisplayShowHomeEnabled(false); // getSupportActionBar().setDisplayHomeAsUpEnabled(true); // toolbar.setNavigationOnClickListener(new View.OnClickListener() { // @Override // public void onClick(View view) { // onBackPressed(); // } // }); // } // } // // public void initToolBar(Toolbar toolbar, String title) { // toolbar.setTitle(title); // initToolBar(toolbar); // } // // } // // Path: app/src/main/java/com/kong/lib/utils/ResourceUtil.java // public class ResourceUtil { // // public static String getString(int resId) { // return getResources().getString(resId); // } // // public static int getColor(int resId) { // return getResources().getColor(resId); // } // // public static Drawable getDrawable(int resId) { // return getResources().getDrawable(resId); // } // // public static int getDimen(int dimen) { // return (int) getResources().getDimension(dimen); // } // // public static Resources getResources() { // return getContext().getResources(); // } // // public static Context getContext() { // return AppRun.get().getApplicationContext(); // } // // public static String getRawFileStr(int rawId) throws IOException { // InputStream is = getResources().openRawResource(rawId); // BufferedReader reader = new BufferedReader(new InputStreamReader(is, "UTF-8")); // StringBuilder sb = new StringBuilder(); // String line; // while ((line = reader.readLine()) != null) { // sb.append(line).append("\n"); // } // sb.deleteCharAt(sb.length() - 1); // reader.close(); // return sb.toString(); // } // }
import android.os.Bundle; import android.support.v7.widget.DividerItemDecoration; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; import com.kong.R; import com.kong.app.demo.about.TextItemViewBinder; import com.kong.app.demo.about.TextViewItem; import com.kong.app.news.base.ToolBarActivity; import com.kong.lib.utils.ResourceUtil; import java.util.ArrayList; import java.util.List; import me.drakeet.multitype.MultiTypeAdapter;
package com.kong.app.demo.me; /** * Created by CaoPengfei on 17/6/18. */ public class MeActivity extends ToolBarActivity { private RecyclerView mRecyclerView; private MultiTypeAdapter mAdapter; private List<Object> list = new ArrayList<>(); @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setTitle(R.string.descover); init(); } @Override protected int getLayoutId() { return R.layout.activity_me; } private void init() { mRecyclerView = (RecyclerView) findViewById(R.id.me_recycle_view); final LinearLayoutManager layoutManager = new LinearLayoutManager(this); mRecyclerView.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL)); mRecyclerView.setLayoutManager(layoutManager); mAdapter = new MultiTypeAdapter(); mAdapter.register(SettingImgTvItem.class, new SettingImgTvItemViewBinder()); mAdapter.register(AvatarItem.class,new AvatarItemViewBinder());
// Path: app/src/main/java/com/kong/app/demo/about/TextItemViewBinder.java // public class TextItemViewBinder extends ItemViewBinder<TextViewItem, TextItemViewBinder.TextHolder> { // // @NonNull // @Override // protected TextHolder onCreateViewHolder(@NonNull LayoutInflater inflater, @NonNull ViewGroup parent) { // View inflate = inflater.inflate(R.layout.item_textview, parent, false); // return new TextHolder(inflate); // } // // @Override // protected void onBindViewHolder(@NonNull TextHolder holder, @NonNull TextViewItem textItem) { // holder.text.setText(textItem.text); // } // // static class TextHolder extends RecyclerView.ViewHolder { // // private final TextView text; // // TextHolder(@NonNull View itemView) { // super(itemView); // this.text = (TextView) itemView.findViewById(R.id.item_textview_id); // } // } // } // // Path: app/src/main/java/com/kong/app/demo/about/TextViewItem.java // public class TextViewItem { // // public String text; // // } // // Path: app/src/main/java/com/kong/app/news/base/ToolBarActivity.java // public abstract class ToolBarActivity extends BaseActivity { // // private Toolbar mToolbar; // // @Override // protected void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // setContentView(getLayoutId()); // mToolbar = (Toolbar) findViewById(R.id.base_toolbar); // initToolBar(mToolbar); // } // // protected abstract int getLayoutId(); // // @Override // public void setTitle(CharSequence title) { // if (mToolbar != null) { // mToolbar.setTitle(title); // } // } // // @Override // public void setTitle(int titleId) { // if (mToolbar != null) { // mToolbar.setTitle(ResourceUtil.getString(titleId)); // } // } // // public Toolbar getToolbar() { // return mToolbar; // } // // public void initToolBar(Toolbar toolbar) { // if (null != toolbar) { // setSupportActionBar(toolbar); // getSupportActionBar().setDisplayShowHomeEnabled(false); // getSupportActionBar().setDisplayHomeAsUpEnabled(true); // toolbar.setNavigationOnClickListener(new View.OnClickListener() { // @Override // public void onClick(View view) { // onBackPressed(); // } // }); // } // } // // public void initToolBar(Toolbar toolbar, String title) { // toolbar.setTitle(title); // initToolBar(toolbar); // } // // } // // Path: app/src/main/java/com/kong/lib/utils/ResourceUtil.java // public class ResourceUtil { // // public static String getString(int resId) { // return getResources().getString(resId); // } // // public static int getColor(int resId) { // return getResources().getColor(resId); // } // // public static Drawable getDrawable(int resId) { // return getResources().getDrawable(resId); // } // // public static int getDimen(int dimen) { // return (int) getResources().getDimension(dimen); // } // // public static Resources getResources() { // return getContext().getResources(); // } // // public static Context getContext() { // return AppRun.get().getApplicationContext(); // } // // public static String getRawFileStr(int rawId) throws IOException { // InputStream is = getResources().openRawResource(rawId); // BufferedReader reader = new BufferedReader(new InputStreamReader(is, "UTF-8")); // StringBuilder sb = new StringBuilder(); // String line; // while ((line = reader.readLine()) != null) { // sb.append(line).append("\n"); // } // sb.deleteCharAt(sb.length() - 1); // reader.close(); // return sb.toString(); // } // } // Path: app/src/main/java/com/kong/app/demo/me/MeActivity.java import android.os.Bundle; import android.support.v7.widget.DividerItemDecoration; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; import com.kong.R; import com.kong.app.demo.about.TextItemViewBinder; import com.kong.app.demo.about.TextViewItem; import com.kong.app.news.base.ToolBarActivity; import com.kong.lib.utils.ResourceUtil; import java.util.ArrayList; import java.util.List; import me.drakeet.multitype.MultiTypeAdapter; package com.kong.app.demo.me; /** * Created by CaoPengfei on 17/6/18. */ public class MeActivity extends ToolBarActivity { private RecyclerView mRecyclerView; private MultiTypeAdapter mAdapter; private List<Object> list = new ArrayList<>(); @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setTitle(R.string.descover); init(); } @Override protected int getLayoutId() { return R.layout.activity_me; } private void init() { mRecyclerView = (RecyclerView) findViewById(R.id.me_recycle_view); final LinearLayoutManager layoutManager = new LinearLayoutManager(this); mRecyclerView.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL)); mRecyclerView.setLayoutManager(layoutManager); mAdapter = new MultiTypeAdapter(); mAdapter.register(SettingImgTvItem.class, new SettingImgTvItemViewBinder()); mAdapter.register(AvatarItem.class,new AvatarItemViewBinder());
mAdapter.register(TextViewItem.class, new TextItemViewBinder());
whiskeyfei/SimpleNews.io
app/src/main/java/com/kong/app/demo/me/MeActivity.java
// Path: app/src/main/java/com/kong/app/demo/about/TextItemViewBinder.java // public class TextItemViewBinder extends ItemViewBinder<TextViewItem, TextItemViewBinder.TextHolder> { // // @NonNull // @Override // protected TextHolder onCreateViewHolder(@NonNull LayoutInflater inflater, @NonNull ViewGroup parent) { // View inflate = inflater.inflate(R.layout.item_textview, parent, false); // return new TextHolder(inflate); // } // // @Override // protected void onBindViewHolder(@NonNull TextHolder holder, @NonNull TextViewItem textItem) { // holder.text.setText(textItem.text); // } // // static class TextHolder extends RecyclerView.ViewHolder { // // private final TextView text; // // TextHolder(@NonNull View itemView) { // super(itemView); // this.text = (TextView) itemView.findViewById(R.id.item_textview_id); // } // } // } // // Path: app/src/main/java/com/kong/app/demo/about/TextViewItem.java // public class TextViewItem { // // public String text; // // } // // Path: app/src/main/java/com/kong/app/news/base/ToolBarActivity.java // public abstract class ToolBarActivity extends BaseActivity { // // private Toolbar mToolbar; // // @Override // protected void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // setContentView(getLayoutId()); // mToolbar = (Toolbar) findViewById(R.id.base_toolbar); // initToolBar(mToolbar); // } // // protected abstract int getLayoutId(); // // @Override // public void setTitle(CharSequence title) { // if (mToolbar != null) { // mToolbar.setTitle(title); // } // } // // @Override // public void setTitle(int titleId) { // if (mToolbar != null) { // mToolbar.setTitle(ResourceUtil.getString(titleId)); // } // } // // public Toolbar getToolbar() { // return mToolbar; // } // // public void initToolBar(Toolbar toolbar) { // if (null != toolbar) { // setSupportActionBar(toolbar); // getSupportActionBar().setDisplayShowHomeEnabled(false); // getSupportActionBar().setDisplayHomeAsUpEnabled(true); // toolbar.setNavigationOnClickListener(new View.OnClickListener() { // @Override // public void onClick(View view) { // onBackPressed(); // } // }); // } // } // // public void initToolBar(Toolbar toolbar, String title) { // toolbar.setTitle(title); // initToolBar(toolbar); // } // // } // // Path: app/src/main/java/com/kong/lib/utils/ResourceUtil.java // public class ResourceUtil { // // public static String getString(int resId) { // return getResources().getString(resId); // } // // public static int getColor(int resId) { // return getResources().getColor(resId); // } // // public static Drawable getDrawable(int resId) { // return getResources().getDrawable(resId); // } // // public static int getDimen(int dimen) { // return (int) getResources().getDimension(dimen); // } // // public static Resources getResources() { // return getContext().getResources(); // } // // public static Context getContext() { // return AppRun.get().getApplicationContext(); // } // // public static String getRawFileStr(int rawId) throws IOException { // InputStream is = getResources().openRawResource(rawId); // BufferedReader reader = new BufferedReader(new InputStreamReader(is, "UTF-8")); // StringBuilder sb = new StringBuilder(); // String line; // while ((line = reader.readLine()) != null) { // sb.append(line).append("\n"); // } // sb.deleteCharAt(sb.length() - 1); // reader.close(); // return sb.toString(); // } // }
import android.os.Bundle; import android.support.v7.widget.DividerItemDecoration; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; import com.kong.R; import com.kong.app.demo.about.TextItemViewBinder; import com.kong.app.demo.about.TextViewItem; import com.kong.app.news.base.ToolBarActivity; import com.kong.lib.utils.ResourceUtil; import java.util.ArrayList; import java.util.List; import me.drakeet.multitype.MultiTypeAdapter;
package com.kong.app.demo.me; /** * Created by CaoPengfei on 17/6/18. */ public class MeActivity extends ToolBarActivity { private RecyclerView mRecyclerView; private MultiTypeAdapter mAdapter; private List<Object> list = new ArrayList<>(); @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setTitle(R.string.descover); init(); } @Override protected int getLayoutId() { return R.layout.activity_me; } private void init() { mRecyclerView = (RecyclerView) findViewById(R.id.me_recycle_view); final LinearLayoutManager layoutManager = new LinearLayoutManager(this); mRecyclerView.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL)); mRecyclerView.setLayoutManager(layoutManager); mAdapter = new MultiTypeAdapter(); mAdapter.register(SettingImgTvItem.class, new SettingImgTvItemViewBinder()); mAdapter.register(AvatarItem.class,new AvatarItemViewBinder());
// Path: app/src/main/java/com/kong/app/demo/about/TextItemViewBinder.java // public class TextItemViewBinder extends ItemViewBinder<TextViewItem, TextItemViewBinder.TextHolder> { // // @NonNull // @Override // protected TextHolder onCreateViewHolder(@NonNull LayoutInflater inflater, @NonNull ViewGroup parent) { // View inflate = inflater.inflate(R.layout.item_textview, parent, false); // return new TextHolder(inflate); // } // // @Override // protected void onBindViewHolder(@NonNull TextHolder holder, @NonNull TextViewItem textItem) { // holder.text.setText(textItem.text); // } // // static class TextHolder extends RecyclerView.ViewHolder { // // private final TextView text; // // TextHolder(@NonNull View itemView) { // super(itemView); // this.text = (TextView) itemView.findViewById(R.id.item_textview_id); // } // } // } // // Path: app/src/main/java/com/kong/app/demo/about/TextViewItem.java // public class TextViewItem { // // public String text; // // } // // Path: app/src/main/java/com/kong/app/news/base/ToolBarActivity.java // public abstract class ToolBarActivity extends BaseActivity { // // private Toolbar mToolbar; // // @Override // protected void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // setContentView(getLayoutId()); // mToolbar = (Toolbar) findViewById(R.id.base_toolbar); // initToolBar(mToolbar); // } // // protected abstract int getLayoutId(); // // @Override // public void setTitle(CharSequence title) { // if (mToolbar != null) { // mToolbar.setTitle(title); // } // } // // @Override // public void setTitle(int titleId) { // if (mToolbar != null) { // mToolbar.setTitle(ResourceUtil.getString(titleId)); // } // } // // public Toolbar getToolbar() { // return mToolbar; // } // // public void initToolBar(Toolbar toolbar) { // if (null != toolbar) { // setSupportActionBar(toolbar); // getSupportActionBar().setDisplayShowHomeEnabled(false); // getSupportActionBar().setDisplayHomeAsUpEnabled(true); // toolbar.setNavigationOnClickListener(new View.OnClickListener() { // @Override // public void onClick(View view) { // onBackPressed(); // } // }); // } // } // // public void initToolBar(Toolbar toolbar, String title) { // toolbar.setTitle(title); // initToolBar(toolbar); // } // // } // // Path: app/src/main/java/com/kong/lib/utils/ResourceUtil.java // public class ResourceUtil { // // public static String getString(int resId) { // return getResources().getString(resId); // } // // public static int getColor(int resId) { // return getResources().getColor(resId); // } // // public static Drawable getDrawable(int resId) { // return getResources().getDrawable(resId); // } // // public static int getDimen(int dimen) { // return (int) getResources().getDimension(dimen); // } // // public static Resources getResources() { // return getContext().getResources(); // } // // public static Context getContext() { // return AppRun.get().getApplicationContext(); // } // // public static String getRawFileStr(int rawId) throws IOException { // InputStream is = getResources().openRawResource(rawId); // BufferedReader reader = new BufferedReader(new InputStreamReader(is, "UTF-8")); // StringBuilder sb = new StringBuilder(); // String line; // while ((line = reader.readLine()) != null) { // sb.append(line).append("\n"); // } // sb.deleteCharAt(sb.length() - 1); // reader.close(); // return sb.toString(); // } // } // Path: app/src/main/java/com/kong/app/demo/me/MeActivity.java import android.os.Bundle; import android.support.v7.widget.DividerItemDecoration; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; import com.kong.R; import com.kong.app.demo.about.TextItemViewBinder; import com.kong.app.demo.about.TextViewItem; import com.kong.app.news.base.ToolBarActivity; import com.kong.lib.utils.ResourceUtil; import java.util.ArrayList; import java.util.List; import me.drakeet.multitype.MultiTypeAdapter; package com.kong.app.demo.me; /** * Created by CaoPengfei on 17/6/18. */ public class MeActivity extends ToolBarActivity { private RecyclerView mRecyclerView; private MultiTypeAdapter mAdapter; private List<Object> list = new ArrayList<>(); @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setTitle(R.string.descover); init(); } @Override protected int getLayoutId() { return R.layout.activity_me; } private void init() { mRecyclerView = (RecyclerView) findViewById(R.id.me_recycle_view); final LinearLayoutManager layoutManager = new LinearLayoutManager(this); mRecyclerView.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL)); mRecyclerView.setLayoutManager(layoutManager); mAdapter = new MultiTypeAdapter(); mAdapter.register(SettingImgTvItem.class, new SettingImgTvItemViewBinder()); mAdapter.register(AvatarItem.class,new AvatarItemViewBinder());
mAdapter.register(TextViewItem.class, new TextItemViewBinder());
whiskeyfei/SimpleNews.io
app/src/main/java/com/kong/app/demo/me/MeActivity.java
// Path: app/src/main/java/com/kong/app/demo/about/TextItemViewBinder.java // public class TextItemViewBinder extends ItemViewBinder<TextViewItem, TextItemViewBinder.TextHolder> { // // @NonNull // @Override // protected TextHolder onCreateViewHolder(@NonNull LayoutInflater inflater, @NonNull ViewGroup parent) { // View inflate = inflater.inflate(R.layout.item_textview, parent, false); // return new TextHolder(inflate); // } // // @Override // protected void onBindViewHolder(@NonNull TextHolder holder, @NonNull TextViewItem textItem) { // holder.text.setText(textItem.text); // } // // static class TextHolder extends RecyclerView.ViewHolder { // // private final TextView text; // // TextHolder(@NonNull View itemView) { // super(itemView); // this.text = (TextView) itemView.findViewById(R.id.item_textview_id); // } // } // } // // Path: app/src/main/java/com/kong/app/demo/about/TextViewItem.java // public class TextViewItem { // // public String text; // // } // // Path: app/src/main/java/com/kong/app/news/base/ToolBarActivity.java // public abstract class ToolBarActivity extends BaseActivity { // // private Toolbar mToolbar; // // @Override // protected void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // setContentView(getLayoutId()); // mToolbar = (Toolbar) findViewById(R.id.base_toolbar); // initToolBar(mToolbar); // } // // protected abstract int getLayoutId(); // // @Override // public void setTitle(CharSequence title) { // if (mToolbar != null) { // mToolbar.setTitle(title); // } // } // // @Override // public void setTitle(int titleId) { // if (mToolbar != null) { // mToolbar.setTitle(ResourceUtil.getString(titleId)); // } // } // // public Toolbar getToolbar() { // return mToolbar; // } // // public void initToolBar(Toolbar toolbar) { // if (null != toolbar) { // setSupportActionBar(toolbar); // getSupportActionBar().setDisplayShowHomeEnabled(false); // getSupportActionBar().setDisplayHomeAsUpEnabled(true); // toolbar.setNavigationOnClickListener(new View.OnClickListener() { // @Override // public void onClick(View view) { // onBackPressed(); // } // }); // } // } // // public void initToolBar(Toolbar toolbar, String title) { // toolbar.setTitle(title); // initToolBar(toolbar); // } // // } // // Path: app/src/main/java/com/kong/lib/utils/ResourceUtil.java // public class ResourceUtil { // // public static String getString(int resId) { // return getResources().getString(resId); // } // // public static int getColor(int resId) { // return getResources().getColor(resId); // } // // public static Drawable getDrawable(int resId) { // return getResources().getDrawable(resId); // } // // public static int getDimen(int dimen) { // return (int) getResources().getDimension(dimen); // } // // public static Resources getResources() { // return getContext().getResources(); // } // // public static Context getContext() { // return AppRun.get().getApplicationContext(); // } // // public static String getRawFileStr(int rawId) throws IOException { // InputStream is = getResources().openRawResource(rawId); // BufferedReader reader = new BufferedReader(new InputStreamReader(is, "UTF-8")); // StringBuilder sb = new StringBuilder(); // String line; // while ((line = reader.readLine()) != null) { // sb.append(line).append("\n"); // } // sb.deleteCharAt(sb.length() - 1); // reader.close(); // return sb.toString(); // } // }
import android.os.Bundle; import android.support.v7.widget.DividerItemDecoration; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; import com.kong.R; import com.kong.app.demo.about.TextItemViewBinder; import com.kong.app.demo.about.TextViewItem; import com.kong.app.news.base.ToolBarActivity; import com.kong.lib.utils.ResourceUtil; import java.util.ArrayList; import java.util.List; import me.drakeet.multitype.MultiTypeAdapter;
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setTitle(R.string.descover); init(); } @Override protected int getLayoutId() { return R.layout.activity_me; } private void init() { mRecyclerView = (RecyclerView) findViewById(R.id.me_recycle_view); final LinearLayoutManager layoutManager = new LinearLayoutManager(this); mRecyclerView.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL)); mRecyclerView.setLayoutManager(layoutManager); mAdapter = new MultiTypeAdapter(); mAdapter.register(SettingImgTvItem.class, new SettingImgTvItemViewBinder()); mAdapter.register(AvatarItem.class,new AvatarItemViewBinder()); mAdapter.register(TextViewItem.class, new TextItemViewBinder()); list.add(new AvatarItem()); for (int i = 0; i < 10; i++) { SettingImgTvItem item = new SettingImgTvItem(); item.title = "item:" + (i+1); list.add(item); } TextViewItem item1 = new TextViewItem();
// Path: app/src/main/java/com/kong/app/demo/about/TextItemViewBinder.java // public class TextItemViewBinder extends ItemViewBinder<TextViewItem, TextItemViewBinder.TextHolder> { // // @NonNull // @Override // protected TextHolder onCreateViewHolder(@NonNull LayoutInflater inflater, @NonNull ViewGroup parent) { // View inflate = inflater.inflate(R.layout.item_textview, parent, false); // return new TextHolder(inflate); // } // // @Override // protected void onBindViewHolder(@NonNull TextHolder holder, @NonNull TextViewItem textItem) { // holder.text.setText(textItem.text); // } // // static class TextHolder extends RecyclerView.ViewHolder { // // private final TextView text; // // TextHolder(@NonNull View itemView) { // super(itemView); // this.text = (TextView) itemView.findViewById(R.id.item_textview_id); // } // } // } // // Path: app/src/main/java/com/kong/app/demo/about/TextViewItem.java // public class TextViewItem { // // public String text; // // } // // Path: app/src/main/java/com/kong/app/news/base/ToolBarActivity.java // public abstract class ToolBarActivity extends BaseActivity { // // private Toolbar mToolbar; // // @Override // protected void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // setContentView(getLayoutId()); // mToolbar = (Toolbar) findViewById(R.id.base_toolbar); // initToolBar(mToolbar); // } // // protected abstract int getLayoutId(); // // @Override // public void setTitle(CharSequence title) { // if (mToolbar != null) { // mToolbar.setTitle(title); // } // } // // @Override // public void setTitle(int titleId) { // if (mToolbar != null) { // mToolbar.setTitle(ResourceUtil.getString(titleId)); // } // } // // public Toolbar getToolbar() { // return mToolbar; // } // // public void initToolBar(Toolbar toolbar) { // if (null != toolbar) { // setSupportActionBar(toolbar); // getSupportActionBar().setDisplayShowHomeEnabled(false); // getSupportActionBar().setDisplayHomeAsUpEnabled(true); // toolbar.setNavigationOnClickListener(new View.OnClickListener() { // @Override // public void onClick(View view) { // onBackPressed(); // } // }); // } // } // // public void initToolBar(Toolbar toolbar, String title) { // toolbar.setTitle(title); // initToolBar(toolbar); // } // // } // // Path: app/src/main/java/com/kong/lib/utils/ResourceUtil.java // public class ResourceUtil { // // public static String getString(int resId) { // return getResources().getString(resId); // } // // public static int getColor(int resId) { // return getResources().getColor(resId); // } // // public static Drawable getDrawable(int resId) { // return getResources().getDrawable(resId); // } // // public static int getDimen(int dimen) { // return (int) getResources().getDimension(dimen); // } // // public static Resources getResources() { // return getContext().getResources(); // } // // public static Context getContext() { // return AppRun.get().getApplicationContext(); // } // // public static String getRawFileStr(int rawId) throws IOException { // InputStream is = getResources().openRawResource(rawId); // BufferedReader reader = new BufferedReader(new InputStreamReader(is, "UTF-8")); // StringBuilder sb = new StringBuilder(); // String line; // while ((line = reader.readLine()) != null) { // sb.append(line).append("\n"); // } // sb.deleteCharAt(sb.length() - 1); // reader.close(); // return sb.toString(); // } // } // Path: app/src/main/java/com/kong/app/demo/me/MeActivity.java import android.os.Bundle; import android.support.v7.widget.DividerItemDecoration; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; import com.kong.R; import com.kong.app.demo.about.TextItemViewBinder; import com.kong.app.demo.about.TextViewItem; import com.kong.app.news.base.ToolBarActivity; import com.kong.lib.utils.ResourceUtil; import java.util.ArrayList; import java.util.List; import me.drakeet.multitype.MultiTypeAdapter; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setTitle(R.string.descover); init(); } @Override protected int getLayoutId() { return R.layout.activity_me; } private void init() { mRecyclerView = (RecyclerView) findViewById(R.id.me_recycle_view); final LinearLayoutManager layoutManager = new LinearLayoutManager(this); mRecyclerView.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL)); mRecyclerView.setLayoutManager(layoutManager); mAdapter = new MultiTypeAdapter(); mAdapter.register(SettingImgTvItem.class, new SettingImgTvItemViewBinder()); mAdapter.register(AvatarItem.class,new AvatarItemViewBinder()); mAdapter.register(TextViewItem.class, new TextItemViewBinder()); list.add(new AvatarItem()); for (int i = 0; i < 10; i++) { SettingImgTvItem item = new SettingImgTvItem(); item.title = "item:" + (i+1); list.add(item); } TextViewItem item1 = new TextViewItem();
item1.text = ResourceUtil.getString(R.string.about_copyright);
whiskeyfei/SimpleNews.io
app/src/main/java/com/kong/app/blog/BlogContract.java
// Path: app/src/main/java/com/kong/app/blog/model/Feed.java // public class Feed { // // private String title; // private String description; // private String home_page_url; // private String feed_url; // private boolean expired; // private List<PostsBean> posts; // // public String getTitle() { // return title; // } // // public void setTitle(String title) { // this.title = title; // } // // public String getDescription() { // return description; // } // // public void setDescription(String description) { // this.description = description; // } // // public String getHome_page_url() { // return home_page_url; // } // // public void setHome_page_url(String home_page_url) { // this.home_page_url = home_page_url; // } // // public String getFeed_url() { // return feed_url; // } // // public void setFeed_url(String feed_url) { // this.feed_url = feed_url; // } // // public boolean isExpired() { // return expired; // } // // public void setExpired(boolean expired) { // this.expired = expired; // } // // public List<PostsBean> getPosts() { // return posts; // } // // public void setPosts(List<PostsBean> posts) { // this.posts = posts; // } // // @Override // public String toString() { // return "Feed{" + // "title='" + title + '\'' + // ", description='" + description + '\'' + // ", home_page_url='" + home_page_url + '\'' + // ", feed_url='" + feed_url + '\'' + // ", expired=" + expired + // ", posts=" + posts + // '}'; // } // // public static class PostsBean implements Serializable { // // @Override // public String toString() { // return "PostsBean{" + // "category='" + category + '\'' + // ", items=" + items + // '}'; // } // // private String category; // private List<ItemsBean> items; // // public String getCategory() { // return category; // } // // public void setCategory(String category) { // this.category = category; // } // // public List<ItemsBean> getItems() { // return items; // } // // public void setItems(List<ItemsBean> items) { // this.items = items; // } // // public static class ItemsBean implements Serializable { // // private String id; // private String keywords; // private String url; // private String date_published; // private String date_modified; // private String title; // private String author; // private String description; // // public String getCover() { // return cover; // } // // public void setCover(String cover) { // this.cover = cover; // } // // private String cover; // // public String getDescription() { // return description; // } // // public void setDescription(String description) { // this.description = description; // } // // public String getId() { // return id; // } // // public void setId(String id) { // this.id = id; // } // // public String getKeywords() { // return keywords; // } // // public void setKeywords(String keywords) { // this.keywords = keywords; // } // // public String getUrl() { // return url; // } // // public void setUrl(String url) { // this.url = url; // } // // public String getDate_published() { // return date_published; // } // // public void setDate_published(String date_published) { // this.date_published = date_published; // } // // public String getDate_modified() { // return date_modified; // } // // public void setDate_modified(String date_modified) { // this.date_modified = date_modified; // } // // public String getTitle() { // return title; // } // // public void setTitle(String title) { // this.title = title; // } // // public String getAuthor() { // return author; // } // // public void setAuthor(String author) { // this.author = author; // } // // @Override // public String toString() { // return "ItemsBean{" + // "id='" + id + '\'' + // ", keywords='" + keywords + '\'' + // ", url='" + url + '\'' + // ", date_published='" + date_published + '\'' + // ", date_modified='" + date_modified + '\'' + // ", title='" + title + '\'' + // ", author='" + author + '\'' + // ", description='" + description + '\'' + // '}'; // } // } // } // } // // Path: app/src/main/java/com/kong/lib/mvp/BasePresenter.java // public interface BasePresenter { // // void start(); // // } // // Path: app/src/main/java/com/kong/lib/mvp/BaseView.java // public interface BaseView<T> { // // void setPresenter(T presenter); // // }
import com.kong.app.blog.model.Feed; import com.kong.lib.mvp.BasePresenter; import com.kong.lib.mvp.BaseView;
package com.kong.app.blog; /** * Created by whiskeyfei on 16/11/6. */ public interface BlogContract { interface View extends BaseView<Presenter> {
// Path: app/src/main/java/com/kong/app/blog/model/Feed.java // public class Feed { // // private String title; // private String description; // private String home_page_url; // private String feed_url; // private boolean expired; // private List<PostsBean> posts; // // public String getTitle() { // return title; // } // // public void setTitle(String title) { // this.title = title; // } // // public String getDescription() { // return description; // } // // public void setDescription(String description) { // this.description = description; // } // // public String getHome_page_url() { // return home_page_url; // } // // public void setHome_page_url(String home_page_url) { // this.home_page_url = home_page_url; // } // // public String getFeed_url() { // return feed_url; // } // // public void setFeed_url(String feed_url) { // this.feed_url = feed_url; // } // // public boolean isExpired() { // return expired; // } // // public void setExpired(boolean expired) { // this.expired = expired; // } // // public List<PostsBean> getPosts() { // return posts; // } // // public void setPosts(List<PostsBean> posts) { // this.posts = posts; // } // // @Override // public String toString() { // return "Feed{" + // "title='" + title + '\'' + // ", description='" + description + '\'' + // ", home_page_url='" + home_page_url + '\'' + // ", feed_url='" + feed_url + '\'' + // ", expired=" + expired + // ", posts=" + posts + // '}'; // } // // public static class PostsBean implements Serializable { // // @Override // public String toString() { // return "PostsBean{" + // "category='" + category + '\'' + // ", items=" + items + // '}'; // } // // private String category; // private List<ItemsBean> items; // // public String getCategory() { // return category; // } // // public void setCategory(String category) { // this.category = category; // } // // public List<ItemsBean> getItems() { // return items; // } // // public void setItems(List<ItemsBean> items) { // this.items = items; // } // // public static class ItemsBean implements Serializable { // // private String id; // private String keywords; // private String url; // private String date_published; // private String date_modified; // private String title; // private String author; // private String description; // // public String getCover() { // return cover; // } // // public void setCover(String cover) { // this.cover = cover; // } // // private String cover; // // public String getDescription() { // return description; // } // // public void setDescription(String description) { // this.description = description; // } // // public String getId() { // return id; // } // // public void setId(String id) { // this.id = id; // } // // public String getKeywords() { // return keywords; // } // // public void setKeywords(String keywords) { // this.keywords = keywords; // } // // public String getUrl() { // return url; // } // // public void setUrl(String url) { // this.url = url; // } // // public String getDate_published() { // return date_published; // } // // public void setDate_published(String date_published) { // this.date_published = date_published; // } // // public String getDate_modified() { // return date_modified; // } // // public void setDate_modified(String date_modified) { // this.date_modified = date_modified; // } // // public String getTitle() { // return title; // } // // public void setTitle(String title) { // this.title = title; // } // // public String getAuthor() { // return author; // } // // public void setAuthor(String author) { // this.author = author; // } // // @Override // public String toString() { // return "ItemsBean{" + // "id='" + id + '\'' + // ", keywords='" + keywords + '\'' + // ", url='" + url + '\'' + // ", date_published='" + date_published + '\'' + // ", date_modified='" + date_modified + '\'' + // ", title='" + title + '\'' + // ", author='" + author + '\'' + // ", description='" + description + '\'' + // '}'; // } // } // } // } // // Path: app/src/main/java/com/kong/lib/mvp/BasePresenter.java // public interface BasePresenter { // // void start(); // // } // // Path: app/src/main/java/com/kong/lib/mvp/BaseView.java // public interface BaseView<T> { // // void setPresenter(T presenter); // // } // Path: app/src/main/java/com/kong/app/blog/BlogContract.java import com.kong.app.blog.model.Feed; import com.kong.lib.mvp.BasePresenter; import com.kong.lib.mvp.BaseView; package com.kong.app.blog; /** * Created by whiskeyfei on 16/11/6. */ public interface BlogContract { interface View extends BaseView<Presenter> {
void onSuccess(Feed feed);
whiskeyfei/SimpleNews.io
app/src/main/java/com/kong/app/blog/BlogContract.java
// Path: app/src/main/java/com/kong/app/blog/model/Feed.java // public class Feed { // // private String title; // private String description; // private String home_page_url; // private String feed_url; // private boolean expired; // private List<PostsBean> posts; // // public String getTitle() { // return title; // } // // public void setTitle(String title) { // this.title = title; // } // // public String getDescription() { // return description; // } // // public void setDescription(String description) { // this.description = description; // } // // public String getHome_page_url() { // return home_page_url; // } // // public void setHome_page_url(String home_page_url) { // this.home_page_url = home_page_url; // } // // public String getFeed_url() { // return feed_url; // } // // public void setFeed_url(String feed_url) { // this.feed_url = feed_url; // } // // public boolean isExpired() { // return expired; // } // // public void setExpired(boolean expired) { // this.expired = expired; // } // // public List<PostsBean> getPosts() { // return posts; // } // // public void setPosts(List<PostsBean> posts) { // this.posts = posts; // } // // @Override // public String toString() { // return "Feed{" + // "title='" + title + '\'' + // ", description='" + description + '\'' + // ", home_page_url='" + home_page_url + '\'' + // ", feed_url='" + feed_url + '\'' + // ", expired=" + expired + // ", posts=" + posts + // '}'; // } // // public static class PostsBean implements Serializable { // // @Override // public String toString() { // return "PostsBean{" + // "category='" + category + '\'' + // ", items=" + items + // '}'; // } // // private String category; // private List<ItemsBean> items; // // public String getCategory() { // return category; // } // // public void setCategory(String category) { // this.category = category; // } // // public List<ItemsBean> getItems() { // return items; // } // // public void setItems(List<ItemsBean> items) { // this.items = items; // } // // public static class ItemsBean implements Serializable { // // private String id; // private String keywords; // private String url; // private String date_published; // private String date_modified; // private String title; // private String author; // private String description; // // public String getCover() { // return cover; // } // // public void setCover(String cover) { // this.cover = cover; // } // // private String cover; // // public String getDescription() { // return description; // } // // public void setDescription(String description) { // this.description = description; // } // // public String getId() { // return id; // } // // public void setId(String id) { // this.id = id; // } // // public String getKeywords() { // return keywords; // } // // public void setKeywords(String keywords) { // this.keywords = keywords; // } // // public String getUrl() { // return url; // } // // public void setUrl(String url) { // this.url = url; // } // // public String getDate_published() { // return date_published; // } // // public void setDate_published(String date_published) { // this.date_published = date_published; // } // // public String getDate_modified() { // return date_modified; // } // // public void setDate_modified(String date_modified) { // this.date_modified = date_modified; // } // // public String getTitle() { // return title; // } // // public void setTitle(String title) { // this.title = title; // } // // public String getAuthor() { // return author; // } // // public void setAuthor(String author) { // this.author = author; // } // // @Override // public String toString() { // return "ItemsBean{" + // "id='" + id + '\'' + // ", keywords='" + keywords + '\'' + // ", url='" + url + '\'' + // ", date_published='" + date_published + '\'' + // ", date_modified='" + date_modified + '\'' + // ", title='" + title + '\'' + // ", author='" + author + '\'' + // ", description='" + description + '\'' + // '}'; // } // } // } // } // // Path: app/src/main/java/com/kong/lib/mvp/BasePresenter.java // public interface BasePresenter { // // void start(); // // } // // Path: app/src/main/java/com/kong/lib/mvp/BaseView.java // public interface BaseView<T> { // // void setPresenter(T presenter); // // }
import com.kong.app.blog.model.Feed; import com.kong.lib.mvp.BasePresenter; import com.kong.lib.mvp.BaseView;
package com.kong.app.blog; /** * Created by whiskeyfei on 16/11/6. */ public interface BlogContract { interface View extends BaseView<Presenter> { void onSuccess(Feed feed); void showProgress(); void hideProgress(); }
// Path: app/src/main/java/com/kong/app/blog/model/Feed.java // public class Feed { // // private String title; // private String description; // private String home_page_url; // private String feed_url; // private boolean expired; // private List<PostsBean> posts; // // public String getTitle() { // return title; // } // // public void setTitle(String title) { // this.title = title; // } // // public String getDescription() { // return description; // } // // public void setDescription(String description) { // this.description = description; // } // // public String getHome_page_url() { // return home_page_url; // } // // public void setHome_page_url(String home_page_url) { // this.home_page_url = home_page_url; // } // // public String getFeed_url() { // return feed_url; // } // // public void setFeed_url(String feed_url) { // this.feed_url = feed_url; // } // // public boolean isExpired() { // return expired; // } // // public void setExpired(boolean expired) { // this.expired = expired; // } // // public List<PostsBean> getPosts() { // return posts; // } // // public void setPosts(List<PostsBean> posts) { // this.posts = posts; // } // // @Override // public String toString() { // return "Feed{" + // "title='" + title + '\'' + // ", description='" + description + '\'' + // ", home_page_url='" + home_page_url + '\'' + // ", feed_url='" + feed_url + '\'' + // ", expired=" + expired + // ", posts=" + posts + // '}'; // } // // public static class PostsBean implements Serializable { // // @Override // public String toString() { // return "PostsBean{" + // "category='" + category + '\'' + // ", items=" + items + // '}'; // } // // private String category; // private List<ItemsBean> items; // // public String getCategory() { // return category; // } // // public void setCategory(String category) { // this.category = category; // } // // public List<ItemsBean> getItems() { // return items; // } // // public void setItems(List<ItemsBean> items) { // this.items = items; // } // // public static class ItemsBean implements Serializable { // // private String id; // private String keywords; // private String url; // private String date_published; // private String date_modified; // private String title; // private String author; // private String description; // // public String getCover() { // return cover; // } // // public void setCover(String cover) { // this.cover = cover; // } // // private String cover; // // public String getDescription() { // return description; // } // // public void setDescription(String description) { // this.description = description; // } // // public String getId() { // return id; // } // // public void setId(String id) { // this.id = id; // } // // public String getKeywords() { // return keywords; // } // // public void setKeywords(String keywords) { // this.keywords = keywords; // } // // public String getUrl() { // return url; // } // // public void setUrl(String url) { // this.url = url; // } // // public String getDate_published() { // return date_published; // } // // public void setDate_published(String date_published) { // this.date_published = date_published; // } // // public String getDate_modified() { // return date_modified; // } // // public void setDate_modified(String date_modified) { // this.date_modified = date_modified; // } // // public String getTitle() { // return title; // } // // public void setTitle(String title) { // this.title = title; // } // // public String getAuthor() { // return author; // } // // public void setAuthor(String author) { // this.author = author; // } // // @Override // public String toString() { // return "ItemsBean{" + // "id='" + id + '\'' + // ", keywords='" + keywords + '\'' + // ", url='" + url + '\'' + // ", date_published='" + date_published + '\'' + // ", date_modified='" + date_modified + '\'' + // ", title='" + title + '\'' + // ", author='" + author + '\'' + // ", description='" + description + '\'' + // '}'; // } // } // } // } // // Path: app/src/main/java/com/kong/lib/mvp/BasePresenter.java // public interface BasePresenter { // // void start(); // // } // // Path: app/src/main/java/com/kong/lib/mvp/BaseView.java // public interface BaseView<T> { // // void setPresenter(T presenter); // // } // Path: app/src/main/java/com/kong/app/blog/BlogContract.java import com.kong.app.blog.model.Feed; import com.kong.lib.mvp.BasePresenter; import com.kong.lib.mvp.BaseView; package com.kong.app.blog; /** * Created by whiskeyfei on 16/11/6. */ public interface BlogContract { interface View extends BaseView<Presenter> { void onSuccess(Feed feed); void showProgress(); void hideProgress(); }
interface Presenter extends BasePresenter {
whiskeyfei/SimpleNews.io
app/src/main/java/com/kong/app/gank/GankAdapter.java
// Path: app/src/main/java/com/kong/app/news/NewsEntry.java // public class NewsEntry implements INewsEntry { // // private static class NewsEntryHelper { // private static NewsEntry sIns = new NewsEntry(); // } // // public static INewsEntry get() { // return NewsEntryHelper.sIns; // } // // @Override // public void startCommon(Context context, Class<?> cls) { // Intent intent = new Intent(context, cls); // ActivityUtils.startActivity(context,intent); // } // // @Override // public void startAbout(Context context) { // Intent intent = new Intent(context, AboutActivity.class); // ActivityUtils.startActivity(context,intent); // } // // // @Override // // public void startDemo(Context context) { // // Intent intent = new Intent(context, DemoActivity.class); // // ActivityUtils.startActivity(context,intent); // // } // // @Override // public void startSetting(Context context) { // Intent intent = new Intent(context, SettingActivity.class); // ActivityUtils.startActivity(context,intent); // } // // // @Override // // public void startNote(Context context) { // // Intent intent = new Intent(context, NoteActivity.class); // // ActivityUtils.startActivity(context,intent); // // } // // // @Override // // public void startNote(Context context, Intent intent) { // // ActivityUtils.startActivity(context,intent); // // } // // @Override // public void startMain(Context context) { // Intent intent = new Intent(context, HomeActivity.class); // ActivityUtils.startActivity(context,intent); // } // // @Override // public void startBrowser(Context context, String url) { // Intent intent = new Intent(context, BrowserActivity.class); // intent.putExtra(BrowserActivity.BWO_KEY,url); // ActivityUtils.startActivity(context,intent); // } // // @Override // public void startBrowser(Context context, String url, String title) { // Intent intent = new Intent(context, BrowserActivity.class); // intent.putExtra(BrowserActivity.BWO_KEY,url); // intent.putExtra(BrowserActivity.BWO_TITLE,title); // ActivityUtils.startActivity(context,intent); // } // // @Override // public void startDetailActivity(Context context, NewModel news) { // Intent intent = new Intent(context, NewsDetailActivity.class); // intent.putExtra(NewsDetailActivity.TITLE,news.title); // intent.putExtra(NewsDetailActivity.URL,news.newUrl); // ActivityUtils.startActivity(context, intent); // } // } // // Path: app/src/main/java/com/kong/lib/adapter/BaseAdapter.java // public abstract class BaseAdapter<T> extends RecyclerView.Adapter<RecyclerView.ViewHolder> { // // protected Context mContext; // // protected List<T> mLists; // // public BaseAdapter() { // // } // // public BaseAdapter(Context context) { // mContext = context; // } // // public BaseAdapter(Context context, List<T> lists) { // this(context); // mLists = lists; // } // // @Override // public int getItemCount() { // return ListUtils.getCount(mLists); // } // // public List<T> getLists() { // return mLists; // } // // public void setLists(List<T> lists) { // mLists = lists; // } // // public T getItem(int position) { // return mLists != null ? mLists.get(position) : null; // } // // } // // Path: app/src/main/java/com/kong/lib/adapter/BaseViewHolder.java // public abstract class BaseViewHolder<M> extends RecyclerView.ViewHolder { // // public BaseViewHolder(View itemView) { // super(itemView); // } // // public BaseViewHolder(ViewGroup parent, @LayoutRes int res) { // super(LayoutInflater.from(parent.getContext()).inflate(res, parent, false)); // } // // protected Context getContext() { // return itemView.getContext(); // } // // public View getItemView() { // return itemView; // } // // public void setOnClickListener(@Nullable View.OnClickListener l) { // itemView.setOnClickListener(l); // } // // protected <T extends View> T findViewById(@IdRes int id) { // return (T) itemView.findViewById(id); // } // // /** // * 可重写 // * // * @param m // */ // public void setData(M m) { // // } // // /** // * 回收 // */ // public void onViewRecycled() { // // } // }
import android.support.annotation.LayoutRes; import android.support.v7.widget.RecyclerView; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; import com.kong.R; import com.kong.app.news.NewsEntry; import com.kong.lib.adapter.BaseAdapter; import com.kong.lib.adapter.BaseViewHolder;
hideCategory(holder); } else { showCategory(holder); } } holder.setData(gank); } private void showCategory(GankViewHolder holder) { if (!isVisibleOf(holder.mCategory)) holder.mCategory.setVisibility(View.VISIBLE); } private void hideCategory(GankViewHolder holder) { if (isVisibleOf(holder.mCategory)) holder.mCategory.setVisibility(View.GONE); } private boolean isVisibleOf(View view) { return view.getVisibility() == View.VISIBLE; } @Override public void onViewRecycled(RecyclerView.ViewHolder holder) { if (holder instanceof GankViewHolder){ ((GankViewHolder) holder).onViewRecycled(); } }
// Path: app/src/main/java/com/kong/app/news/NewsEntry.java // public class NewsEntry implements INewsEntry { // // private static class NewsEntryHelper { // private static NewsEntry sIns = new NewsEntry(); // } // // public static INewsEntry get() { // return NewsEntryHelper.sIns; // } // // @Override // public void startCommon(Context context, Class<?> cls) { // Intent intent = new Intent(context, cls); // ActivityUtils.startActivity(context,intent); // } // // @Override // public void startAbout(Context context) { // Intent intent = new Intent(context, AboutActivity.class); // ActivityUtils.startActivity(context,intent); // } // // // @Override // // public void startDemo(Context context) { // // Intent intent = new Intent(context, DemoActivity.class); // // ActivityUtils.startActivity(context,intent); // // } // // @Override // public void startSetting(Context context) { // Intent intent = new Intent(context, SettingActivity.class); // ActivityUtils.startActivity(context,intent); // } // // // @Override // // public void startNote(Context context) { // // Intent intent = new Intent(context, NoteActivity.class); // // ActivityUtils.startActivity(context,intent); // // } // // // @Override // // public void startNote(Context context, Intent intent) { // // ActivityUtils.startActivity(context,intent); // // } // // @Override // public void startMain(Context context) { // Intent intent = new Intent(context, HomeActivity.class); // ActivityUtils.startActivity(context,intent); // } // // @Override // public void startBrowser(Context context, String url) { // Intent intent = new Intent(context, BrowserActivity.class); // intent.putExtra(BrowserActivity.BWO_KEY,url); // ActivityUtils.startActivity(context,intent); // } // // @Override // public void startBrowser(Context context, String url, String title) { // Intent intent = new Intent(context, BrowserActivity.class); // intent.putExtra(BrowserActivity.BWO_KEY,url); // intent.putExtra(BrowserActivity.BWO_TITLE,title); // ActivityUtils.startActivity(context,intent); // } // // @Override // public void startDetailActivity(Context context, NewModel news) { // Intent intent = new Intent(context, NewsDetailActivity.class); // intent.putExtra(NewsDetailActivity.TITLE,news.title); // intent.putExtra(NewsDetailActivity.URL,news.newUrl); // ActivityUtils.startActivity(context, intent); // } // } // // Path: app/src/main/java/com/kong/lib/adapter/BaseAdapter.java // public abstract class BaseAdapter<T> extends RecyclerView.Adapter<RecyclerView.ViewHolder> { // // protected Context mContext; // // protected List<T> mLists; // // public BaseAdapter() { // // } // // public BaseAdapter(Context context) { // mContext = context; // } // // public BaseAdapter(Context context, List<T> lists) { // this(context); // mLists = lists; // } // // @Override // public int getItemCount() { // return ListUtils.getCount(mLists); // } // // public List<T> getLists() { // return mLists; // } // // public void setLists(List<T> lists) { // mLists = lists; // } // // public T getItem(int position) { // return mLists != null ? mLists.get(position) : null; // } // // } // // Path: app/src/main/java/com/kong/lib/adapter/BaseViewHolder.java // public abstract class BaseViewHolder<M> extends RecyclerView.ViewHolder { // // public BaseViewHolder(View itemView) { // super(itemView); // } // // public BaseViewHolder(ViewGroup parent, @LayoutRes int res) { // super(LayoutInflater.from(parent.getContext()).inflate(res, parent, false)); // } // // protected Context getContext() { // return itemView.getContext(); // } // // public View getItemView() { // return itemView; // } // // public void setOnClickListener(@Nullable View.OnClickListener l) { // itemView.setOnClickListener(l); // } // // protected <T extends View> T findViewById(@IdRes int id) { // return (T) itemView.findViewById(id); // } // // /** // * 可重写 // * // * @param m // */ // public void setData(M m) { // // } // // /** // * 回收 // */ // public void onViewRecycled() { // // } // } // Path: app/src/main/java/com/kong/app/gank/GankAdapter.java import android.support.annotation.LayoutRes; import android.support.v7.widget.RecyclerView; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; import com.kong.R; import com.kong.app.news.NewsEntry; import com.kong.lib.adapter.BaseAdapter; import com.kong.lib.adapter.BaseViewHolder; hideCategory(holder); } else { showCategory(holder); } } holder.setData(gank); } private void showCategory(GankViewHolder holder) { if (!isVisibleOf(holder.mCategory)) holder.mCategory.setVisibility(View.VISIBLE); } private void hideCategory(GankViewHolder holder) { if (isVisibleOf(holder.mCategory)) holder.mCategory.setVisibility(View.GONE); } private boolean isVisibleOf(View view) { return view.getVisibility() == View.VISIBLE; } @Override public void onViewRecycled(RecyclerView.ViewHolder holder) { if (holder instanceof GankViewHolder){ ((GankViewHolder) holder).onViewRecycled(); } }
public class GankViewHolder extends BaseViewHolder<Gank> implements View.OnClickListener {
whiskeyfei/SimpleNews.io
app/src/main/java/com/kong/app/gank/GankAdapter.java
// Path: app/src/main/java/com/kong/app/news/NewsEntry.java // public class NewsEntry implements INewsEntry { // // private static class NewsEntryHelper { // private static NewsEntry sIns = new NewsEntry(); // } // // public static INewsEntry get() { // return NewsEntryHelper.sIns; // } // // @Override // public void startCommon(Context context, Class<?> cls) { // Intent intent = new Intent(context, cls); // ActivityUtils.startActivity(context,intent); // } // // @Override // public void startAbout(Context context) { // Intent intent = new Intent(context, AboutActivity.class); // ActivityUtils.startActivity(context,intent); // } // // // @Override // // public void startDemo(Context context) { // // Intent intent = new Intent(context, DemoActivity.class); // // ActivityUtils.startActivity(context,intent); // // } // // @Override // public void startSetting(Context context) { // Intent intent = new Intent(context, SettingActivity.class); // ActivityUtils.startActivity(context,intent); // } // // // @Override // // public void startNote(Context context) { // // Intent intent = new Intent(context, NoteActivity.class); // // ActivityUtils.startActivity(context,intent); // // } // // // @Override // // public void startNote(Context context, Intent intent) { // // ActivityUtils.startActivity(context,intent); // // } // // @Override // public void startMain(Context context) { // Intent intent = new Intent(context, HomeActivity.class); // ActivityUtils.startActivity(context,intent); // } // // @Override // public void startBrowser(Context context, String url) { // Intent intent = new Intent(context, BrowserActivity.class); // intent.putExtra(BrowserActivity.BWO_KEY,url); // ActivityUtils.startActivity(context,intent); // } // // @Override // public void startBrowser(Context context, String url, String title) { // Intent intent = new Intent(context, BrowserActivity.class); // intent.putExtra(BrowserActivity.BWO_KEY,url); // intent.putExtra(BrowserActivity.BWO_TITLE,title); // ActivityUtils.startActivity(context,intent); // } // // @Override // public void startDetailActivity(Context context, NewModel news) { // Intent intent = new Intent(context, NewsDetailActivity.class); // intent.putExtra(NewsDetailActivity.TITLE,news.title); // intent.putExtra(NewsDetailActivity.URL,news.newUrl); // ActivityUtils.startActivity(context, intent); // } // } // // Path: app/src/main/java/com/kong/lib/adapter/BaseAdapter.java // public abstract class BaseAdapter<T> extends RecyclerView.Adapter<RecyclerView.ViewHolder> { // // protected Context mContext; // // protected List<T> mLists; // // public BaseAdapter() { // // } // // public BaseAdapter(Context context) { // mContext = context; // } // // public BaseAdapter(Context context, List<T> lists) { // this(context); // mLists = lists; // } // // @Override // public int getItemCount() { // return ListUtils.getCount(mLists); // } // // public List<T> getLists() { // return mLists; // } // // public void setLists(List<T> lists) { // mLists = lists; // } // // public T getItem(int position) { // return mLists != null ? mLists.get(position) : null; // } // // } // // Path: app/src/main/java/com/kong/lib/adapter/BaseViewHolder.java // public abstract class BaseViewHolder<M> extends RecyclerView.ViewHolder { // // public BaseViewHolder(View itemView) { // super(itemView); // } // // public BaseViewHolder(ViewGroup parent, @LayoutRes int res) { // super(LayoutInflater.from(parent.getContext()).inflate(res, parent, false)); // } // // protected Context getContext() { // return itemView.getContext(); // } // // public View getItemView() { // return itemView; // } // // public void setOnClickListener(@Nullable View.OnClickListener l) { // itemView.setOnClickListener(l); // } // // protected <T extends View> T findViewById(@IdRes int id) { // return (T) itemView.findViewById(id); // } // // /** // * 可重写 // * // * @param m // */ // public void setData(M m) { // // } // // /** // * 回收 // */ // public void onViewRecycled() { // // } // }
import android.support.annotation.LayoutRes; import android.support.v7.widget.RecyclerView; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; import com.kong.R; import com.kong.app.news.NewsEntry; import com.kong.lib.adapter.BaseAdapter; import com.kong.lib.adapter.BaseViewHolder;
} public class GankViewHolder extends BaseViewHolder<Gank> implements View.OnClickListener { public TextView mCategory; public TextView mTitle; public GankViewHolder(ViewGroup parent, @LayoutRes int res) { super(parent, res); mCategory = findViewById(R.id.gank_category); mTitle = findViewById(R.id.gank_title); setOnClickListener(this); } @Override public void setData(Gank gank) { mCategory.setText(gank.type); mTitle.setText(gank.desc); } @Override public void onViewRecycled() { } @Override public void onClick(View v) { Gank gank = getItem(getLayoutPosition()); if (gank != null) {
// Path: app/src/main/java/com/kong/app/news/NewsEntry.java // public class NewsEntry implements INewsEntry { // // private static class NewsEntryHelper { // private static NewsEntry sIns = new NewsEntry(); // } // // public static INewsEntry get() { // return NewsEntryHelper.sIns; // } // // @Override // public void startCommon(Context context, Class<?> cls) { // Intent intent = new Intent(context, cls); // ActivityUtils.startActivity(context,intent); // } // // @Override // public void startAbout(Context context) { // Intent intent = new Intent(context, AboutActivity.class); // ActivityUtils.startActivity(context,intent); // } // // // @Override // // public void startDemo(Context context) { // // Intent intent = new Intent(context, DemoActivity.class); // // ActivityUtils.startActivity(context,intent); // // } // // @Override // public void startSetting(Context context) { // Intent intent = new Intent(context, SettingActivity.class); // ActivityUtils.startActivity(context,intent); // } // // // @Override // // public void startNote(Context context) { // // Intent intent = new Intent(context, NoteActivity.class); // // ActivityUtils.startActivity(context,intent); // // } // // // @Override // // public void startNote(Context context, Intent intent) { // // ActivityUtils.startActivity(context,intent); // // } // // @Override // public void startMain(Context context) { // Intent intent = new Intent(context, HomeActivity.class); // ActivityUtils.startActivity(context,intent); // } // // @Override // public void startBrowser(Context context, String url) { // Intent intent = new Intent(context, BrowserActivity.class); // intent.putExtra(BrowserActivity.BWO_KEY,url); // ActivityUtils.startActivity(context,intent); // } // // @Override // public void startBrowser(Context context, String url, String title) { // Intent intent = new Intent(context, BrowserActivity.class); // intent.putExtra(BrowserActivity.BWO_KEY,url); // intent.putExtra(BrowserActivity.BWO_TITLE,title); // ActivityUtils.startActivity(context,intent); // } // // @Override // public void startDetailActivity(Context context, NewModel news) { // Intent intent = new Intent(context, NewsDetailActivity.class); // intent.putExtra(NewsDetailActivity.TITLE,news.title); // intent.putExtra(NewsDetailActivity.URL,news.newUrl); // ActivityUtils.startActivity(context, intent); // } // } // // Path: app/src/main/java/com/kong/lib/adapter/BaseAdapter.java // public abstract class BaseAdapter<T> extends RecyclerView.Adapter<RecyclerView.ViewHolder> { // // protected Context mContext; // // protected List<T> mLists; // // public BaseAdapter() { // // } // // public BaseAdapter(Context context) { // mContext = context; // } // // public BaseAdapter(Context context, List<T> lists) { // this(context); // mLists = lists; // } // // @Override // public int getItemCount() { // return ListUtils.getCount(mLists); // } // // public List<T> getLists() { // return mLists; // } // // public void setLists(List<T> lists) { // mLists = lists; // } // // public T getItem(int position) { // return mLists != null ? mLists.get(position) : null; // } // // } // // Path: app/src/main/java/com/kong/lib/adapter/BaseViewHolder.java // public abstract class BaseViewHolder<M> extends RecyclerView.ViewHolder { // // public BaseViewHolder(View itemView) { // super(itemView); // } // // public BaseViewHolder(ViewGroup parent, @LayoutRes int res) { // super(LayoutInflater.from(parent.getContext()).inflate(res, parent, false)); // } // // protected Context getContext() { // return itemView.getContext(); // } // // public View getItemView() { // return itemView; // } // // public void setOnClickListener(@Nullable View.OnClickListener l) { // itemView.setOnClickListener(l); // } // // protected <T extends View> T findViewById(@IdRes int id) { // return (T) itemView.findViewById(id); // } // // /** // * 可重写 // * // * @param m // */ // public void setData(M m) { // // } // // /** // * 回收 // */ // public void onViewRecycled() { // // } // } // Path: app/src/main/java/com/kong/app/gank/GankAdapter.java import android.support.annotation.LayoutRes; import android.support.v7.widget.RecyclerView; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; import com.kong.R; import com.kong.app.news.NewsEntry; import com.kong.lib.adapter.BaseAdapter; import com.kong.lib.adapter.BaseViewHolder; } public class GankViewHolder extends BaseViewHolder<Gank> implements View.OnClickListener { public TextView mCategory; public TextView mTitle; public GankViewHolder(ViewGroup parent, @LayoutRes int res) { super(parent, res); mCategory = findViewById(R.id.gank_category); mTitle = findViewById(R.id.gank_title); setOnClickListener(this); } @Override public void setData(Gank gank) { mCategory.setText(gank.type); mTitle.setText(gank.desc); } @Override public void onViewRecycled() { } @Override public void onClick(View v) { Gank gank = getItem(getLayoutPosition()); if (gank != null) {
NewsEntry.get().startBrowser(v.getContext(), gank.url, gank.desc);
whiskeyfei/SimpleNews.io
app/src/main/java/com/kong/app/news/detail/NewsDetailPresenter.java
// Path: app/src/main/java/com/kong/lib/AppRun.java // public class AppRun { // // private Context mContext = null; // // private static AppRun sInstance; // // public static AppRun get() { // if (sInstance == null) { // sInstance = new AppRun(); // } // return sInstance; // } // // public void init(Context context) { // if (mContext != null) { // throw new IllegalStateException("App just call once init!!"); // } // mContext = context; // } // // private void ensureAppContext() { // if (mContext == null) { // throw new IllegalStateException("App not call init!!."); // } // } // // public Context getApplicationContext() { // ensureAppContext(); // return mContext; // } // // } // // Path: app/src/main/java/com/kong/lib/widget/SafeWebView.java // public class SafeWebView extends WebView { // // public SafeWebView(Context context) { // super(context); // removeSearchBox(); // } // // public SafeWebView(Context context, AttributeSet attrs) { // super(context, attrs); // removeSearchBox(); // } // // public SafeWebView(Context context, AttributeSet attrs, int defStyleAttr) { // super(context, attrs, defStyleAttr); // removeSearchBox(); // } // // /** // * 移除系统注入的对象,避免js漏洞 // * <p> // * https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2014-1939 // * https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2014-7224 // */ // private void removeSearchBox() { // super.removeJavascriptInterface("searchBoxJavaBridge_"); // super.removeJavascriptInterface("accessibility"); // super.removeJavascriptInterface("accessibilityTraversal"); // } // // public static void disableAccessibility(Context context) { // if (Build.VERSION.SDK_INT == 17/*4.2 (Build.VERSION_CODES.JELLY_BEAN_MR1)*/) { // if (context != null) { // try { // AccessibilityManager am = (AccessibilityManager) context.getSystemService(Context.ACCESSIBILITY_SERVICE); // if (!am.isEnabled()) { // //Not need to disable accessibility // return; // } // // Method setState = am.getClass().getDeclaredMethod("setState", int.class); // setState.setAccessible(true); // setState.invoke(am, 0);/**{@link AccessibilityManager#STATE_FLAG_ACCESSIBILITY_ENABLED}*/ // } catch (Exception ignored) { // ignored.printStackTrace(); // } // } // } // } // // @Override // public void setOverScrollMode(int mode) { // // try { // // super.setOverScrollMode(mode); // // } catch (Throwable e) { // // e.printStackTrace(); // // } // // try { // super.setOverScrollMode(mode); // } catch (Throwable e) { // String trace = Log.getStackTraceString(e); // if (trace.contains("android.content.pm.PackageManager$NameNotFoundException") // || trace.contains("java.lang.RuntimeException: Cannot load WebView") // || trace.contains("android.webkit.WebViewFactory$MissingWebViewPackageException: Failed to load WebView provider: No WebView installed")) { // e.printStackTrace(); // } else { // throw e; // } // } // } // // @Override // public boolean isPrivateBrowsingEnabled() { // if (Build.VERSION.SDK_INT == Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1 && getSettings() == null) { // return false; // } else { // return super.isPrivateBrowsingEnabled(); // } // } // // @Override // public void onResume() { // super.onResume(); // resumeTimers(); // } // // @Override // public void onPause() { // super.onPause(); // pauseTimers(); // } // // /** // * 释放相关操作 // */ // public void onDestroy() { // setWebViewClient(null); // removeAllViews(); // stopLoading(); // clearMatches(); // clearHistory(); // clearSslPreferences(); // clearCache(true); // destroy(); // } // } // // Path: app/src/main/java/com/kong/lib/utils/ActivityUtils.java // public class ActivityUtils { // // public static <T> T checkNotNull(T reference) { // if (reference == null) { // throw new NullPointerException(); // } // return reference; // } // // public static <T> T checkNotNull(T reference, String message) { // if (reference == null) { // throw new NullPointerException(message); // } // return reference; // } // // public static void startActivity(Context context, Intent intent) { // if (context instanceof Activity) { // startActivity((Activity) context, intent, -1); // } else { // intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); // context.startActivity(intent); // } // } // // public static void startActivity(Activity a, Intent intent, int requestCode) { // if (requestCode >= 0) { // a.startActivityForResult(intent, requestCode); // } else { // a.startActivity(intent); // } // a.overridePendingTransition(0, 0); // } // }
import android.graphics.Bitmap; import android.net.http.SslError; import android.text.TextUtils; import android.util.Log; import android.webkit.SslErrorHandler; import android.webkit.WebResourceError; import android.webkit.WebResourceRequest; import android.webkit.WebResourceResponse; import android.webkit.WebSettings; import android.webkit.WebView; import android.webkit.WebViewClient; import com.kong.lib.AppRun; import com.kong.lib.widget.SafeWebView; import com.kong.lib.utils.ActivityUtils;
package com.kong.app.news.detail; public class NewsDetailPresenter implements DetailContract.Presenter { private static final String TAG = "NewsDetailPresenter";
// Path: app/src/main/java/com/kong/lib/AppRun.java // public class AppRun { // // private Context mContext = null; // // private static AppRun sInstance; // // public static AppRun get() { // if (sInstance == null) { // sInstance = new AppRun(); // } // return sInstance; // } // // public void init(Context context) { // if (mContext != null) { // throw new IllegalStateException("App just call once init!!"); // } // mContext = context; // } // // private void ensureAppContext() { // if (mContext == null) { // throw new IllegalStateException("App not call init!!."); // } // } // // public Context getApplicationContext() { // ensureAppContext(); // return mContext; // } // // } // // Path: app/src/main/java/com/kong/lib/widget/SafeWebView.java // public class SafeWebView extends WebView { // // public SafeWebView(Context context) { // super(context); // removeSearchBox(); // } // // public SafeWebView(Context context, AttributeSet attrs) { // super(context, attrs); // removeSearchBox(); // } // // public SafeWebView(Context context, AttributeSet attrs, int defStyleAttr) { // super(context, attrs, defStyleAttr); // removeSearchBox(); // } // // /** // * 移除系统注入的对象,避免js漏洞 // * <p> // * https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2014-1939 // * https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2014-7224 // */ // private void removeSearchBox() { // super.removeJavascriptInterface("searchBoxJavaBridge_"); // super.removeJavascriptInterface("accessibility"); // super.removeJavascriptInterface("accessibilityTraversal"); // } // // public static void disableAccessibility(Context context) { // if (Build.VERSION.SDK_INT == 17/*4.2 (Build.VERSION_CODES.JELLY_BEAN_MR1)*/) { // if (context != null) { // try { // AccessibilityManager am = (AccessibilityManager) context.getSystemService(Context.ACCESSIBILITY_SERVICE); // if (!am.isEnabled()) { // //Not need to disable accessibility // return; // } // // Method setState = am.getClass().getDeclaredMethod("setState", int.class); // setState.setAccessible(true); // setState.invoke(am, 0);/**{@link AccessibilityManager#STATE_FLAG_ACCESSIBILITY_ENABLED}*/ // } catch (Exception ignored) { // ignored.printStackTrace(); // } // } // } // } // // @Override // public void setOverScrollMode(int mode) { // // try { // // super.setOverScrollMode(mode); // // } catch (Throwable e) { // // e.printStackTrace(); // // } // // try { // super.setOverScrollMode(mode); // } catch (Throwable e) { // String trace = Log.getStackTraceString(e); // if (trace.contains("android.content.pm.PackageManager$NameNotFoundException") // || trace.contains("java.lang.RuntimeException: Cannot load WebView") // || trace.contains("android.webkit.WebViewFactory$MissingWebViewPackageException: Failed to load WebView provider: No WebView installed")) { // e.printStackTrace(); // } else { // throw e; // } // } // } // // @Override // public boolean isPrivateBrowsingEnabled() { // if (Build.VERSION.SDK_INT == Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1 && getSettings() == null) { // return false; // } else { // return super.isPrivateBrowsingEnabled(); // } // } // // @Override // public void onResume() { // super.onResume(); // resumeTimers(); // } // // @Override // public void onPause() { // super.onPause(); // pauseTimers(); // } // // /** // * 释放相关操作 // */ // public void onDestroy() { // setWebViewClient(null); // removeAllViews(); // stopLoading(); // clearMatches(); // clearHistory(); // clearSslPreferences(); // clearCache(true); // destroy(); // } // } // // Path: app/src/main/java/com/kong/lib/utils/ActivityUtils.java // public class ActivityUtils { // // public static <T> T checkNotNull(T reference) { // if (reference == null) { // throw new NullPointerException(); // } // return reference; // } // // public static <T> T checkNotNull(T reference, String message) { // if (reference == null) { // throw new NullPointerException(message); // } // return reference; // } // // public static void startActivity(Context context, Intent intent) { // if (context instanceof Activity) { // startActivity((Activity) context, intent, -1); // } else { // intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); // context.startActivity(intent); // } // } // // public static void startActivity(Activity a, Intent intent, int requestCode) { // if (requestCode >= 0) { // a.startActivityForResult(intent, requestCode); // } else { // a.startActivity(intent); // } // a.overridePendingTransition(0, 0); // } // } // Path: app/src/main/java/com/kong/app/news/detail/NewsDetailPresenter.java import android.graphics.Bitmap; import android.net.http.SslError; import android.text.TextUtils; import android.util.Log; import android.webkit.SslErrorHandler; import android.webkit.WebResourceError; import android.webkit.WebResourceRequest; import android.webkit.WebResourceResponse; import android.webkit.WebSettings; import android.webkit.WebView; import android.webkit.WebViewClient; import com.kong.lib.AppRun; import com.kong.lib.widget.SafeWebView; import com.kong.lib.utils.ActivityUtils; package com.kong.app.news.detail; public class NewsDetailPresenter implements DetailContract.Presenter { private static final String TAG = "NewsDetailPresenter";
private SafeWebView mWebView;
whiskeyfei/SimpleNews.io
app/src/main/java/com/kong/app/news/fragment/SettingFragment.java
// Path: app/src/main/java/com/kong/app/news/utils/SettingsUtil.java // public class SettingsUtil { // // public static int getThemeIndex() { // SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(AppRun.get().getApplicationContext()); // return prefs.getInt("ThemeIndex", 0); // } // // public static void setThemeIndex(int index) { // SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(AppRun.get().getApplicationContext()); // prefs.edit().putInt("ThemeIndex", index).apply(); // } // }
import android.content.SharedPreferences; import android.os.Bundle; import android.preference.Preference; import android.preference.PreferenceFragment; import android.preference.PreferenceManager; import android.support.annotation.Nullable; import com.kong.R; import com.kong.app.news.utils.SettingsUtil;
package com.kong.app.news.fragment; /** * Created by CaoPengfei on 17/6/17. */ public class SettingFragment extends PreferenceFragment implements Preference.OnPreferenceClickListener, Preference.OnPreferenceChangeListener { private Preference mPreferenceTheme; private Preference mCleanCache; public static SettingFragment newInstance() { Bundle args = new Bundle(); SettingFragment fragment = new SettingFragment(); fragment.setArguments(args); return fragment; } @Override public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.setting); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getActivity()); mCleanCache = findPreference("clean_cache"); mCleanCache.setOnPreferenceClickListener(this); mCleanCache.setSummary("0MB"); mPreferenceTheme = findPreference("keyTheme"); mPreferenceTheme.setOnPreferenceClickListener(this); String[] colorNames = getActivity().getResources().getStringArray(R.array.SettingColorNames);
// Path: app/src/main/java/com/kong/app/news/utils/SettingsUtil.java // public class SettingsUtil { // // public static int getThemeIndex() { // SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(AppRun.get().getApplicationContext()); // return prefs.getInt("ThemeIndex", 0); // } // // public static void setThemeIndex(int index) { // SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(AppRun.get().getApplicationContext()); // prefs.edit().putInt("ThemeIndex", index).apply(); // } // } // Path: app/src/main/java/com/kong/app/news/fragment/SettingFragment.java import android.content.SharedPreferences; import android.os.Bundle; import android.preference.Preference; import android.preference.PreferenceFragment; import android.preference.PreferenceManager; import android.support.annotation.Nullable; import com.kong.R; import com.kong.app.news.utils.SettingsUtil; package com.kong.app.news.fragment; /** * Created by CaoPengfei on 17/6/17. */ public class SettingFragment extends PreferenceFragment implements Preference.OnPreferenceClickListener, Preference.OnPreferenceChangeListener { private Preference mPreferenceTheme; private Preference mCleanCache; public static SettingFragment newInstance() { Bundle args = new Bundle(); SettingFragment fragment = new SettingFragment(); fragment.setArguments(args); return fragment; } @Override public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.setting); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getActivity()); mCleanCache = findPreference("clean_cache"); mCleanCache.setOnPreferenceClickListener(this); mCleanCache.setSummary("0MB"); mPreferenceTheme = findPreference("keyTheme"); mPreferenceTheme.setOnPreferenceClickListener(this); String[] colorNames = getActivity().getResources().getStringArray(R.array.SettingColorNames);
int currentThemeIndex = SettingsUtil.getThemeIndex();
whiskeyfei/SimpleNews.io
app/src/main/java/com/kong/app/news/utils/TimeUtils.java
// Path: app/src/main/java/com/kong/lib/utils/ResourceUtil.java // public class ResourceUtil { // // public static String getString(int resId) { // return getResources().getString(resId); // } // // public static int getColor(int resId) { // return getResources().getColor(resId); // } // // public static Drawable getDrawable(int resId) { // return getResources().getDrawable(resId); // } // // public static int getDimen(int dimen) { // return (int) getResources().getDimension(dimen); // } // // public static Resources getResources() { // return getContext().getResources(); // } // // public static Context getContext() { // return AppRun.get().getApplicationContext(); // } // // public static String getRawFileStr(int rawId) throws IOException { // InputStream is = getResources().openRawResource(rawId); // BufferedReader reader = new BufferedReader(new InputStreamReader(is, "UTF-8")); // StringBuilder sb = new StringBuilder(); // String line; // while ((line = reader.readLine()) != null) { // sb.append(line).append("\n"); // } // sb.deleteCharAt(sb.length() - 1); // reader.close(); // return sb.toString(); // } // } // // Path: app/src/main/java/com/kong/lib/utils/StringUtils.java // public class StringUtils { // // public static boolean isEmpty(CharSequence str) { // return str == null || str.length() == 0; // } // // public static boolean isEmpty(String... strs) { // if (strs == null) { // return true; // } // // for (String str : strs) { // if ((str != null) && !str.isEmpty()) { // return false; // } // } // return true; // } // // public static boolean hasEmpty(String strs) { // if (isEmpty(strs)) { // return true; // } // // for (int i = 0; i < strs.length(); i++) { // char c = strs.charAt(i); // if (c != ' ' && c != '\t' && c != '\r' && c != '\n') { // return false; // } // } // return true; // } // // }
import com.kong.R; import com.kong.lib.utils.ResourceUtil; import com.kong.lib.utils.StringUtils; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date;
package com.kong.app.news.utils; /** * Created by CaoPengfei on 17/6/28. */ public class TimeUtils { private static final SimpleDateFormat sSimpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm"); private static java.util.Date sNowTime = new Date(); private static long nd = 1000 * 24 * 60 * 60; private static long nh = 1000 * 60 * 60;
// Path: app/src/main/java/com/kong/lib/utils/ResourceUtil.java // public class ResourceUtil { // // public static String getString(int resId) { // return getResources().getString(resId); // } // // public static int getColor(int resId) { // return getResources().getColor(resId); // } // // public static Drawable getDrawable(int resId) { // return getResources().getDrawable(resId); // } // // public static int getDimen(int dimen) { // return (int) getResources().getDimension(dimen); // } // // public static Resources getResources() { // return getContext().getResources(); // } // // public static Context getContext() { // return AppRun.get().getApplicationContext(); // } // // public static String getRawFileStr(int rawId) throws IOException { // InputStream is = getResources().openRawResource(rawId); // BufferedReader reader = new BufferedReader(new InputStreamReader(is, "UTF-8")); // StringBuilder sb = new StringBuilder(); // String line; // while ((line = reader.readLine()) != null) { // sb.append(line).append("\n"); // } // sb.deleteCharAt(sb.length() - 1); // reader.close(); // return sb.toString(); // } // } // // Path: app/src/main/java/com/kong/lib/utils/StringUtils.java // public class StringUtils { // // public static boolean isEmpty(CharSequence str) { // return str == null || str.length() == 0; // } // // public static boolean isEmpty(String... strs) { // if (strs == null) { // return true; // } // // for (String str : strs) { // if ((str != null) && !str.isEmpty()) { // return false; // } // } // return true; // } // // public static boolean hasEmpty(String strs) { // if (isEmpty(strs)) { // return true; // } // // for (int i = 0; i < strs.length(); i++) { // char c = strs.charAt(i); // if (c != ' ' && c != '\t' && c != '\r' && c != '\n') { // return false; // } // } // return true; // } // // } // Path: app/src/main/java/com/kong/app/news/utils/TimeUtils.java import com.kong.R; import com.kong.lib.utils.ResourceUtil; import com.kong.lib.utils.StringUtils; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; package com.kong.app.news.utils; /** * Created by CaoPengfei on 17/6/28. */ public class TimeUtils { private static final SimpleDateFormat sSimpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm"); private static java.util.Date sNowTime = new Date(); private static long nd = 1000 * 24 * 60 * 60; private static long nh = 1000 * 60 * 60;
private static String day = ResourceUtil.getString(R.string.today);
whiskeyfei/SimpleNews.io
app/src/main/java/com/kong/app/news/utils/TimeUtils.java
// Path: app/src/main/java/com/kong/lib/utils/ResourceUtil.java // public class ResourceUtil { // // public static String getString(int resId) { // return getResources().getString(resId); // } // // public static int getColor(int resId) { // return getResources().getColor(resId); // } // // public static Drawable getDrawable(int resId) { // return getResources().getDrawable(resId); // } // // public static int getDimen(int dimen) { // return (int) getResources().getDimension(dimen); // } // // public static Resources getResources() { // return getContext().getResources(); // } // // public static Context getContext() { // return AppRun.get().getApplicationContext(); // } // // public static String getRawFileStr(int rawId) throws IOException { // InputStream is = getResources().openRawResource(rawId); // BufferedReader reader = new BufferedReader(new InputStreamReader(is, "UTF-8")); // StringBuilder sb = new StringBuilder(); // String line; // while ((line = reader.readLine()) != null) { // sb.append(line).append("\n"); // } // sb.deleteCharAt(sb.length() - 1); // reader.close(); // return sb.toString(); // } // } // // Path: app/src/main/java/com/kong/lib/utils/StringUtils.java // public class StringUtils { // // public static boolean isEmpty(CharSequence str) { // return str == null || str.length() == 0; // } // // public static boolean isEmpty(String... strs) { // if (strs == null) { // return true; // } // // for (String str : strs) { // if ((str != null) && !str.isEmpty()) { // return false; // } // } // return true; // } // // public static boolean hasEmpty(String strs) { // if (isEmpty(strs)) { // return true; // } // // for (int i = 0; i < strs.length(); i++) { // char c = strs.charAt(i); // if (c != ' ' && c != '\t' && c != '\r' && c != '\n') { // return false; // } // } // return true; // } // // }
import com.kong.R; import com.kong.lib.utils.ResourceUtil; import com.kong.lib.utils.StringUtils; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date;
package com.kong.app.news.utils; /** * Created by CaoPengfei on 17/6/28. */ public class TimeUtils { private static final SimpleDateFormat sSimpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm"); private static java.util.Date sNowTime = new Date(); private static long nd = 1000 * 24 * 60 * 60; private static long nh = 1000 * 60 * 60; private static String day = ResourceUtil.getString(R.string.today); public static Date parse(String strDate) throws ParseException { return sSimpleDateFormat.parse(strDate); } /** * 计算当前时间差 * @param toTime * @return */ public static String getGapTime(String toTime) { String time = day;
// Path: app/src/main/java/com/kong/lib/utils/ResourceUtil.java // public class ResourceUtil { // // public static String getString(int resId) { // return getResources().getString(resId); // } // // public static int getColor(int resId) { // return getResources().getColor(resId); // } // // public static Drawable getDrawable(int resId) { // return getResources().getDrawable(resId); // } // // public static int getDimen(int dimen) { // return (int) getResources().getDimension(dimen); // } // // public static Resources getResources() { // return getContext().getResources(); // } // // public static Context getContext() { // return AppRun.get().getApplicationContext(); // } // // public static String getRawFileStr(int rawId) throws IOException { // InputStream is = getResources().openRawResource(rawId); // BufferedReader reader = new BufferedReader(new InputStreamReader(is, "UTF-8")); // StringBuilder sb = new StringBuilder(); // String line; // while ((line = reader.readLine()) != null) { // sb.append(line).append("\n"); // } // sb.deleteCharAt(sb.length() - 1); // reader.close(); // return sb.toString(); // } // } // // Path: app/src/main/java/com/kong/lib/utils/StringUtils.java // public class StringUtils { // // public static boolean isEmpty(CharSequence str) { // return str == null || str.length() == 0; // } // // public static boolean isEmpty(String... strs) { // if (strs == null) { // return true; // } // // for (String str : strs) { // if ((str != null) && !str.isEmpty()) { // return false; // } // } // return true; // } // // public static boolean hasEmpty(String strs) { // if (isEmpty(strs)) { // return true; // } // // for (int i = 0; i < strs.length(); i++) { // char c = strs.charAt(i); // if (c != ' ' && c != '\t' && c != '\r' && c != '\n') { // return false; // } // } // return true; // } // // } // Path: app/src/main/java/com/kong/app/news/utils/TimeUtils.java import com.kong.R; import com.kong.lib.utils.ResourceUtil; import com.kong.lib.utils.StringUtils; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; package com.kong.app.news.utils; /** * Created by CaoPengfei on 17/6/28. */ public class TimeUtils { private static final SimpleDateFormat sSimpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm"); private static java.util.Date sNowTime = new Date(); private static long nd = 1000 * 24 * 60 * 60; private static long nh = 1000 * 60 * 60; private static String day = ResourceUtil.getString(R.string.today); public static Date parse(String strDate) throws ParseException { return sSimpleDateFormat.parse(strDate); } /** * 计算当前时间差 * @param toTime * @return */ public static String getGapTime(String toTime) { String time = day;
if (StringUtils.isEmpty(toTime)) {
whiskeyfei/SimpleNews.io
app/src/main/java/com/kong/app/news/ui/BrowserActivity.java
// Path: app/src/main/java/com/kong/app/news/base/ToolBarActivity.java // public abstract class ToolBarActivity extends BaseActivity { // // private Toolbar mToolbar; // // @Override // protected void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // setContentView(getLayoutId()); // mToolbar = (Toolbar) findViewById(R.id.base_toolbar); // initToolBar(mToolbar); // } // // protected abstract int getLayoutId(); // // @Override // public void setTitle(CharSequence title) { // if (mToolbar != null) { // mToolbar.setTitle(title); // } // } // // @Override // public void setTitle(int titleId) { // if (mToolbar != null) { // mToolbar.setTitle(ResourceUtil.getString(titleId)); // } // } // // public Toolbar getToolbar() { // return mToolbar; // } // // public void initToolBar(Toolbar toolbar) { // if (null != toolbar) { // setSupportActionBar(toolbar); // getSupportActionBar().setDisplayShowHomeEnabled(false); // getSupportActionBar().setDisplayHomeAsUpEnabled(true); // toolbar.setNavigationOnClickListener(new View.OnClickListener() { // @Override // public void onClick(View view) { // onBackPressed(); // } // }); // } // } // // public void initToolBar(Toolbar toolbar, String title) { // toolbar.setTitle(title); // initToolBar(toolbar); // } // // } // // Path: app/src/main/java/com/kong/lib/utils/StringUtils.java // public class StringUtils { // // public static boolean isEmpty(CharSequence str) { // return str == null || str.length() == 0; // } // // public static boolean isEmpty(String... strs) { // if (strs == null) { // return true; // } // // for (String str : strs) { // if ((str != null) && !str.isEmpty()) { // return false; // } // } // return true; // } // // public static boolean hasEmpty(String strs) { // if (isEmpty(strs)) { // return true; // } // // for (int i = 0; i < strs.length(); i++) { // char c = strs.charAt(i); // if (c != ' ' && c != '\t' && c != '\r' && c != '\n') { // return false; // } // } // return true; // } // // }
import android.content.Intent; import android.graphics.Bitmap; import android.os.Bundle; import android.view.View; import android.webkit.WebChromeClient; import android.webkit.WebView; import android.webkit.WebViewClient; import android.widget.ProgressBar; import com.kong.R; import com.kong.app.news.base.ToolBarActivity; import com.kong.lib.utils.StringUtils;
public void onProgressChanged(WebView view, int newProgress) { mProgressBar.setProgress(newProgress); if (newProgress == 100) { mProgressBar.setVisibility(View.GONE); } else { mProgressBar.setVisibility(View.VISIBLE); } } @Override public void onReceivedTitle(WebView view, String title) { super.onReceivedTitle(view, title); } }); mWebView.setWebViewClient(new WebViewClient() { @Override public void onPageStarted(WebView view, String url, Bitmap favicon) { } @Override public void onPageFinished(WebView view, String url) { showResult(); } });
// Path: app/src/main/java/com/kong/app/news/base/ToolBarActivity.java // public abstract class ToolBarActivity extends BaseActivity { // // private Toolbar mToolbar; // // @Override // protected void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // setContentView(getLayoutId()); // mToolbar = (Toolbar) findViewById(R.id.base_toolbar); // initToolBar(mToolbar); // } // // protected abstract int getLayoutId(); // // @Override // public void setTitle(CharSequence title) { // if (mToolbar != null) { // mToolbar.setTitle(title); // } // } // // @Override // public void setTitle(int titleId) { // if (mToolbar != null) { // mToolbar.setTitle(ResourceUtil.getString(titleId)); // } // } // // public Toolbar getToolbar() { // return mToolbar; // } // // public void initToolBar(Toolbar toolbar) { // if (null != toolbar) { // setSupportActionBar(toolbar); // getSupportActionBar().setDisplayShowHomeEnabled(false); // getSupportActionBar().setDisplayHomeAsUpEnabled(true); // toolbar.setNavigationOnClickListener(new View.OnClickListener() { // @Override // public void onClick(View view) { // onBackPressed(); // } // }); // } // } // // public void initToolBar(Toolbar toolbar, String title) { // toolbar.setTitle(title); // initToolBar(toolbar); // } // // } // // Path: app/src/main/java/com/kong/lib/utils/StringUtils.java // public class StringUtils { // // public static boolean isEmpty(CharSequence str) { // return str == null || str.length() == 0; // } // // public static boolean isEmpty(String... strs) { // if (strs == null) { // return true; // } // // for (String str : strs) { // if ((str != null) && !str.isEmpty()) { // return false; // } // } // return true; // } // // public static boolean hasEmpty(String strs) { // if (isEmpty(strs)) { // return true; // } // // for (int i = 0; i < strs.length(); i++) { // char c = strs.charAt(i); // if (c != ' ' && c != '\t' && c != '\r' && c != '\n') { // return false; // } // } // return true; // } // // } // Path: app/src/main/java/com/kong/app/news/ui/BrowserActivity.java import android.content.Intent; import android.graphics.Bitmap; import android.os.Bundle; import android.view.View; import android.webkit.WebChromeClient; import android.webkit.WebView; import android.webkit.WebViewClient; import android.widget.ProgressBar; import com.kong.R; import com.kong.app.news.base.ToolBarActivity; import com.kong.lib.utils.StringUtils; public void onProgressChanged(WebView view, int newProgress) { mProgressBar.setProgress(newProgress); if (newProgress == 100) { mProgressBar.setVisibility(View.GONE); } else { mProgressBar.setVisibility(View.VISIBLE); } } @Override public void onReceivedTitle(WebView view, String title) { super.onReceivedTitle(view, title); } }); mWebView.setWebViewClient(new WebViewClient() { @Override public void onPageStarted(WebView view, String url, Bitmap favicon) { } @Override public void onPageFinished(WebView view, String url) { showResult(); } });
if (!StringUtils.isEmpty(mUrl)) {
whiskeyfei/SimpleNews.io
app/src/main/java/com/kong/lib/BaseActivity.java
// Path: app/src/main/java/com/kong/lib/event/AppExitEvent.java // public class AppExitEvent { // }
import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.util.Log; import android.view.KeyEvent; import com.kong.lib.event.AppExitEvent; import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.ThreadMode;
package com.kong.lib; /** * Created by CaoPengfei on 17/5/24. */ public class BaseActivity extends AppCompatActivity { private static final String TAG = "BaseActivity"; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); EventBus.getDefault().register(this); } @Override protected void onDestroy() { super.onDestroy(); EventBus.getDefault().unregister(this); } @Subscribe(threadMode = ThreadMode.MAIN)
// Path: app/src/main/java/com/kong/lib/event/AppExitEvent.java // public class AppExitEvent { // } // Path: app/src/main/java/com/kong/lib/BaseActivity.java import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.util.Log; import android.view.KeyEvent; import com.kong.lib.event.AppExitEvent; import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.ThreadMode; package com.kong.lib; /** * Created by CaoPengfei on 17/5/24. */ public class BaseActivity extends AppCompatActivity { private static final String TAG = "BaseActivity"; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); EventBus.getDefault().register(this); } @Override protected void onDestroy() { super.onDestroy(); EventBus.getDefault().unregister(this); } @Subscribe(threadMode = ThreadMode.MAIN)
public void onMessageEvent(AppExitEvent event) {
whiskeyfei/SimpleNews.io
app/src/main/java/com/kong/AppApplication.java
// Path: app/src/main/java/com/kong/lib/AppRun.java // public class AppRun { // // private Context mContext = null; // // private static AppRun sInstance; // // public static AppRun get() { // if (sInstance == null) { // sInstance = new AppRun(); // } // return sInstance; // } // // public void init(Context context) { // if (mContext != null) { // throw new IllegalStateException("App just call once init!!"); // } // mContext = context; // } // // private void ensureAppContext() { // if (mContext == null) { // throw new IllegalStateException("App not call init!!."); // } // } // // public Context getApplicationContext() { // ensureAppContext(); // return mContext; // } // // }
import android.app.Application; import com.kong.lib.AppRun;
package com.kong; public class AppApplication extends Application { @Override public void onCreate() { super.onCreate();
// Path: app/src/main/java/com/kong/lib/AppRun.java // public class AppRun { // // private Context mContext = null; // // private static AppRun sInstance; // // public static AppRun get() { // if (sInstance == null) { // sInstance = new AppRun(); // } // return sInstance; // } // // public void init(Context context) { // if (mContext != null) { // throw new IllegalStateException("App just call once init!!"); // } // mContext = context; // } // // private void ensureAppContext() { // if (mContext == null) { // throw new IllegalStateException("App not call init!!."); // } // } // // public Context getApplicationContext() { // ensureAppContext(); // return mContext; // } // // } // Path: app/src/main/java/com/kong/AppApplication.java import android.app.Application; import com.kong.lib.AppRun; package com.kong; public class AppApplication extends Application { @Override public void onCreate() { super.onCreate();
AppRun.get().init(getApplicationContext());
whiskeyfei/SimpleNews.io
app/src/main/java/com/kong/app/news/ListBaseFragment.java
// Path: app/src/main/java/com/kong/app/news/adapter/IRVPagerView.java // public interface IRVPagerView { // // String getTitle(); // // View getVeiw(); // // void scrollTop(); // } // // Path: app/src/main/java/com/kong/home/tab/event/SelectRepeatEvent.java // public class SelectRepeatEvent { // public static final int HOMEINDEX = 0; // public static final int BLOGINDEX = 1; // public static final int GANKINDEX = 2; // public int type; // // public SelectRepeatEvent(int type) { // this.type = type; // } // } // // Path: app/src/main/java/com/kong/lib/fragment/BaseFragment.java // public class BaseFragment extends Fragment { // // }
import android.os.Bundle; import android.os.Handler; import android.os.Looper; import android.support.annotation.Nullable; import android.support.design.widget.TabLayout; import android.support.v4.view.ViewPager; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.view.ViewStub; import com.kong.R; import com.kong.app.news.adapter.IRVPagerView; import com.kong.home.tab.event.SelectRepeatEvent; import com.kong.lib.fragment.BaseFragment; import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.ThreadMode; import java.util.ArrayList; import java.util.List;
package com.kong.app.news; public abstract class ListBaseFragment extends BaseFragment { private static final String TAG = "ListBaseFragment"; protected TabLayout mTablayout; protected ViewPager mViewPager; protected ViewStub mViewStub; private View mProgressView; private View mErrorView; protected View mRoot; protected Handler mHandler = new Handler(Looper.myLooper());
// Path: app/src/main/java/com/kong/app/news/adapter/IRVPagerView.java // public interface IRVPagerView { // // String getTitle(); // // View getVeiw(); // // void scrollTop(); // } // // Path: app/src/main/java/com/kong/home/tab/event/SelectRepeatEvent.java // public class SelectRepeatEvent { // public static final int HOMEINDEX = 0; // public static final int BLOGINDEX = 1; // public static final int GANKINDEX = 2; // public int type; // // public SelectRepeatEvent(int type) { // this.type = type; // } // } // // Path: app/src/main/java/com/kong/lib/fragment/BaseFragment.java // public class BaseFragment extends Fragment { // // } // Path: app/src/main/java/com/kong/app/news/ListBaseFragment.java import android.os.Bundle; import android.os.Handler; import android.os.Looper; import android.support.annotation.Nullable; import android.support.design.widget.TabLayout; import android.support.v4.view.ViewPager; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.view.ViewStub; import com.kong.R; import com.kong.app.news.adapter.IRVPagerView; import com.kong.home.tab.event.SelectRepeatEvent; import com.kong.lib.fragment.BaseFragment; import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.ThreadMode; import java.util.ArrayList; import java.util.List; package com.kong.app.news; public abstract class ListBaseFragment extends BaseFragment { private static final String TAG = "ListBaseFragment"; protected TabLayout mTablayout; protected ViewPager mViewPager; protected ViewStub mViewStub; private View mProgressView; private View mErrorView; protected View mRoot; protected Handler mHandler = new Handler(Looper.myLooper());
protected final List<IRVPagerView> mIRVPagerViews = new ArrayList<>();
whiskeyfei/SimpleNews.io
app/src/main/java/com/kong/app/news/ListBaseFragment.java
// Path: app/src/main/java/com/kong/app/news/adapter/IRVPagerView.java // public interface IRVPagerView { // // String getTitle(); // // View getVeiw(); // // void scrollTop(); // } // // Path: app/src/main/java/com/kong/home/tab/event/SelectRepeatEvent.java // public class SelectRepeatEvent { // public static final int HOMEINDEX = 0; // public static final int BLOGINDEX = 1; // public static final int GANKINDEX = 2; // public int type; // // public SelectRepeatEvent(int type) { // this.type = type; // } // } // // Path: app/src/main/java/com/kong/lib/fragment/BaseFragment.java // public class BaseFragment extends Fragment { // // }
import android.os.Bundle; import android.os.Handler; import android.os.Looper; import android.support.annotation.Nullable; import android.support.design.widget.TabLayout; import android.support.v4.view.ViewPager; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.view.ViewStub; import com.kong.R; import com.kong.app.news.adapter.IRVPagerView; import com.kong.home.tab.event.SelectRepeatEvent; import com.kong.lib.fragment.BaseFragment; import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.ThreadMode; import java.util.ArrayList; import java.util.List;
package com.kong.app.news; public abstract class ListBaseFragment extends BaseFragment { private static final String TAG = "ListBaseFragment"; protected TabLayout mTablayout; protected ViewPager mViewPager; protected ViewStub mViewStub; private View mProgressView; private View mErrorView; protected View mRoot; protected Handler mHandler = new Handler(Looper.myLooper()); protected final List<IRVPagerView> mIRVPagerViews = new ArrayList<>(); public abstract void onCreateView(); public abstract int getCurrentType(); @Subscribe(threadMode = ThreadMode.MAIN)
// Path: app/src/main/java/com/kong/app/news/adapter/IRVPagerView.java // public interface IRVPagerView { // // String getTitle(); // // View getVeiw(); // // void scrollTop(); // } // // Path: app/src/main/java/com/kong/home/tab/event/SelectRepeatEvent.java // public class SelectRepeatEvent { // public static final int HOMEINDEX = 0; // public static final int BLOGINDEX = 1; // public static final int GANKINDEX = 2; // public int type; // // public SelectRepeatEvent(int type) { // this.type = type; // } // } // // Path: app/src/main/java/com/kong/lib/fragment/BaseFragment.java // public class BaseFragment extends Fragment { // // } // Path: app/src/main/java/com/kong/app/news/ListBaseFragment.java import android.os.Bundle; import android.os.Handler; import android.os.Looper; import android.support.annotation.Nullable; import android.support.design.widget.TabLayout; import android.support.v4.view.ViewPager; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.view.ViewStub; import com.kong.R; import com.kong.app.news.adapter.IRVPagerView; import com.kong.home.tab.event.SelectRepeatEvent; import com.kong.lib.fragment.BaseFragment; import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.ThreadMode; import java.util.ArrayList; import java.util.List; package com.kong.app.news; public abstract class ListBaseFragment extends BaseFragment { private static final String TAG = "ListBaseFragment"; protected TabLayout mTablayout; protected ViewPager mViewPager; protected ViewStub mViewStub; private View mProgressView; private View mErrorView; protected View mRoot; protected Handler mHandler = new Handler(Looper.myLooper()); protected final List<IRVPagerView> mIRVPagerViews = new ArrayList<>(); public abstract void onCreateView(); public abstract int getCurrentType(); @Subscribe(threadMode = ThreadMode.MAIN)
public void onSelectRepeat(SelectRepeatEvent event){
whiskeyfei/SimpleNews.io
app/src/main/java/com/kong/home/tab/adapter/BaseTabAdapter.java
// Path: app/src/main/java/com/kong/lib/utils/ListUtils.java // public class ListUtils { // /** // * check list is null // * // * @param list // * @return // */ // public static boolean isEmpty(List<?> list) { // return (list == null) || list.isEmpty(); // } // // /** // * check map is null // * // * @param map // * @return // */ // public static boolean isEmpty(Map<?, ?> map) { // return (map == null) || map.isEmpty(); // } // // public static boolean isEmpty(SparseArray<?> map){ // return (map == null) || (map.size() == 0); // } // // /** // * get list count // * // * @param list // * @return // */ // public static int getCount(List<?> list) { // return isEmpty(list) ? 0 : list.size(); // } // }
import android.content.Context; import com.kong.lib.utils.ListUtils; import java.util.List;
package com.kong.home.tab.adapter; /** * Created by CaoPengfei on 16/4/13. */ public abstract class BaseTabAdapter<T> implements TabAdpater { private Context mContext; protected List<T> mLists; public BaseTabAdapter(Context context) { mContext = context; } public BaseTabAdapter(Context context, List<T> objects) { this(context); mLists = objects; } public void setData(List<T> list) { mLists = list; } public T getItem(int position) { return (mLists != null) ? mLists.get(position) : null; } @Override public int getCount() {
// Path: app/src/main/java/com/kong/lib/utils/ListUtils.java // public class ListUtils { // /** // * check list is null // * // * @param list // * @return // */ // public static boolean isEmpty(List<?> list) { // return (list == null) || list.isEmpty(); // } // // /** // * check map is null // * // * @param map // * @return // */ // public static boolean isEmpty(Map<?, ?> map) { // return (map == null) || map.isEmpty(); // } // // public static boolean isEmpty(SparseArray<?> map){ // return (map == null) || (map.size() == 0); // } // // /** // * get list count // * // * @param list // * @return // */ // public static int getCount(List<?> list) { // return isEmpty(list) ? 0 : list.size(); // } // } // Path: app/src/main/java/com/kong/home/tab/adapter/BaseTabAdapter.java import android.content.Context; import com.kong.lib.utils.ListUtils; import java.util.List; package com.kong.home.tab.adapter; /** * Created by CaoPengfei on 16/4/13. */ public abstract class BaseTabAdapter<T> implements TabAdpater { private Context mContext; protected List<T> mLists; public BaseTabAdapter(Context context) { mContext = context; } public BaseTabAdapter(Context context, List<T> objects) { this(context); mLists = objects; } public void setData(List<T> list) { mLists = list; } public T getItem(int position) { return (mLists != null) ? mLists.get(position) : null; } @Override public int getCount() {
return ListUtils.getCount(mLists);
whiskeyfei/SimpleNews.io
app/src/main/java/com/kong/app/gank/GangPresenter.java
// Path: app/src/main/java/com/kong/lib/utils/ListUtils.java // public class ListUtils { // /** // * check list is null // * // * @param list // * @return // */ // public static boolean isEmpty(List<?> list) { // return (list == null) || list.isEmpty(); // } // // /** // * check map is null // * // * @param map // * @return // */ // public static boolean isEmpty(Map<?, ?> map) { // return (map == null) || map.isEmpty(); // } // // public static boolean isEmpty(SparseArray<?> map){ // return (map == null) || (map.size() == 0); // } // // /** // * get list count // * // * @param list // * @return // */ // public static int getCount(List<?> list) { // return isEmpty(list) ? 0 : list.size(); // } // }
import com.kong.lib.utils.ListUtils; import java.util.ArrayList; import java.util.List; import rx.Observer; import rx.android.schedulers.AndroidSchedulers; import rx.schedulers.Schedulers;
private int mYear, mMonth, mDay; public GangPresenter(GankModel gankModel, GankContract.View view) { mGankModel = gankModel; mView = view; time = 0; } @Override public void loadData(int year, int month, int day) { mYear = year; mMonth = month; mDay = day; mGankModel.getGankResult(year, month, day) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(new Observer<GankResult>() { @Override public void onCompleted() { } @Override public void onError(Throwable e) { reLoad(); } @Override public void onNext(GankResult gankResult) { getGankList(gankResult);
// Path: app/src/main/java/com/kong/lib/utils/ListUtils.java // public class ListUtils { // /** // * check list is null // * // * @param list // * @return // */ // public static boolean isEmpty(List<?> list) { // return (list == null) || list.isEmpty(); // } // // /** // * check map is null // * // * @param map // * @return // */ // public static boolean isEmpty(Map<?, ?> map) { // return (map == null) || map.isEmpty(); // } // // public static boolean isEmpty(SparseArray<?> map){ // return (map == null) || (map.size() == 0); // } // // /** // * get list count // * // * @param list // * @return // */ // public static int getCount(List<?> list) { // return isEmpty(list) ? 0 : list.size(); // } // } // Path: app/src/main/java/com/kong/app/gank/GangPresenter.java import com.kong.lib.utils.ListUtils; import java.util.ArrayList; import java.util.List; import rx.Observer; import rx.android.schedulers.AndroidSchedulers; import rx.schedulers.Schedulers; private int mYear, mMonth, mDay; public GangPresenter(GankModel gankModel, GankContract.View view) { mGankModel = gankModel; mView = view; time = 0; } @Override public void loadData(int year, int month, int day) { mYear = year; mMonth = month; mDay = day; mGankModel.getGankResult(year, month, day) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(new Observer<GankResult>() { @Override public void onCompleted() { } @Override public void onError(Throwable e) { reLoad(); } @Override public void onNext(GankResult gankResult) { getGankList(gankResult);
if (ListUtils.isEmpty(mGankList)){
whiskeyfei/SimpleNews.io
app/src/main/java/com/kong/home/tab/adapter/BottomTabAdapter.java
// Path: app/src/main/java/com/kong/home/tab/widget/TabItemView.java // public class TabItemView extends FrameLayout implements IMsgView { // // private final ImageView mIcon; // private final TextView mTitle; // private final IMsgView mMsgView; // // private int mDefaultDrawable; // private int mCheckedDrawable; // // private int mDefaultTextColor = ResourceUtil.getColor(R.color.tab_normal); // private int mCheckedTextColor = ResourceUtil.getColor(R.color.tab_focus); // // public TabItemView(Context context) { // this(context, null); // } // // public TabItemView(Context context, AttributeSet attrs) { // this(context, attrs, 0); // } // // public TabItemView(Context context, AttributeSet attrs, int defStyleAttr) { // super(context, attrs, defStyleAttr); // LayoutInflater.from(context).inflate(R.layout.item_normal, this, true); // mIcon = (ImageView) findViewById(R.id.item_iv_icon); // mTitle = (TextView) findViewById(R.id.item_tv_title); // mMsgView = (MsgView) findViewById(R.id.item_msg_id); // } // // public void initialize(@DrawableRes int drawableRes, @DrawableRes int checkedDrawableRes, String title) { // mDefaultDrawable = drawableRes; // mCheckedDrawable = checkedDrawableRes; // mTitle.setText(title); // } // // public void setChecked(boolean checked) { // if (checked) { // mIcon.setImageResource(mCheckedDrawable); // mTitle.setTextColor(mCheckedTextColor); // } else { // mIcon.setImageResource(mDefaultDrawable); // mTitle.setTextColor(mDefaultTextColor); // } // } // // public String getTitle() { // return mTitle.getText().toString(); // } // // public void setTextDefaultColor(@ColorInt int color) { // mDefaultTextColor = color; // } // // public void setTextCheckedColor(@ColorInt int color) { // mCheckedTextColor = color; // } // // @Override // public void setMsgCount(int count) { // mMsgView.setMsgCount(count); // } // // @Override // public void showPoint() { // mMsgView.showPoint(); // } // // @Override // public void hidePoint() { // mMsgView.hidePoint(); // } // } // // Path: app/src/main/java/com/kong/home/tab/TabItemModel.java // public class TabItemModel { // public int drawable; // public int checkedDrawable; // public String text; // public int type; // // public TabItemModel(int drawable, int checkedDrawable, String text) { // this.drawable = drawable; // this.checkedDrawable = checkedDrawable; // this.text = text; // } // }
import android.content.Context; import android.view.View; import com.kong.home.tab.widget.TabItemView; import com.kong.home.tab.TabItemModel; import java.util.List;
package com.kong.home.tab.adapter; /** * Created by CaoPengfei on 16/4/13. */ public class BottomTabAdapter extends BaseTabAdapter<TabItemModel> { private static final String TAG = "BottomTabAdapter"; public BottomTabAdapter(Context context, List<TabItemModel> tabItemModels) { super(context, tabItemModels); } @Override public View getView(final int position) {
// Path: app/src/main/java/com/kong/home/tab/widget/TabItemView.java // public class TabItemView extends FrameLayout implements IMsgView { // // private final ImageView mIcon; // private final TextView mTitle; // private final IMsgView mMsgView; // // private int mDefaultDrawable; // private int mCheckedDrawable; // // private int mDefaultTextColor = ResourceUtil.getColor(R.color.tab_normal); // private int mCheckedTextColor = ResourceUtil.getColor(R.color.tab_focus); // // public TabItemView(Context context) { // this(context, null); // } // // public TabItemView(Context context, AttributeSet attrs) { // this(context, attrs, 0); // } // // public TabItemView(Context context, AttributeSet attrs, int defStyleAttr) { // super(context, attrs, defStyleAttr); // LayoutInflater.from(context).inflate(R.layout.item_normal, this, true); // mIcon = (ImageView) findViewById(R.id.item_iv_icon); // mTitle = (TextView) findViewById(R.id.item_tv_title); // mMsgView = (MsgView) findViewById(R.id.item_msg_id); // } // // public void initialize(@DrawableRes int drawableRes, @DrawableRes int checkedDrawableRes, String title) { // mDefaultDrawable = drawableRes; // mCheckedDrawable = checkedDrawableRes; // mTitle.setText(title); // } // // public void setChecked(boolean checked) { // if (checked) { // mIcon.setImageResource(mCheckedDrawable); // mTitle.setTextColor(mCheckedTextColor); // } else { // mIcon.setImageResource(mDefaultDrawable); // mTitle.setTextColor(mDefaultTextColor); // } // } // // public String getTitle() { // return mTitle.getText().toString(); // } // // public void setTextDefaultColor(@ColorInt int color) { // mDefaultTextColor = color; // } // // public void setTextCheckedColor(@ColorInt int color) { // mCheckedTextColor = color; // } // // @Override // public void setMsgCount(int count) { // mMsgView.setMsgCount(count); // } // // @Override // public void showPoint() { // mMsgView.showPoint(); // } // // @Override // public void hidePoint() { // mMsgView.hidePoint(); // } // } // // Path: app/src/main/java/com/kong/home/tab/TabItemModel.java // public class TabItemModel { // public int drawable; // public int checkedDrawable; // public String text; // public int type; // // public TabItemModel(int drawable, int checkedDrawable, String text) { // this.drawable = drawable; // this.checkedDrawable = checkedDrawable; // this.text = text; // } // } // Path: app/src/main/java/com/kong/home/tab/adapter/BottomTabAdapter.java import android.content.Context; import android.view.View; import com.kong.home.tab.widget.TabItemView; import com.kong.home.tab.TabItemModel; import java.util.List; package com.kong.home.tab.adapter; /** * Created by CaoPengfei on 16/4/13. */ public class BottomTabAdapter extends BaseTabAdapter<TabItemModel> { private static final String TAG = "BottomTabAdapter"; public BottomTabAdapter(Context context, List<TabItemModel> tabItemModels) { super(context, tabItemModels); } @Override public View getView(final int position) {
final TabItemView itemView = new TabItemView(getContext());
whiskeyfei/SimpleNews.io
app/src/main/java/com/kong/home/tab/widget/BottomTabLayout.java
// Path: app/src/main/java/com/kong/home/tab/OnTabItemSelectedListener.java // public interface OnTabItemSelectedListener { // // void onSelected(int index, int old); // // void onSelectRepeat(int index); // } // // Path: app/src/main/java/com/kong/home/tab/adapter/BottomTabAdapter.java // public class BottomTabAdapter extends BaseTabAdapter<TabItemModel> { // // private static final String TAG = "BottomTabAdapter"; // // public BottomTabAdapter(Context context, List<TabItemModel> tabItemModels) { // super(context, tabItemModels); // } // // @Override // public View getView(final int position) { // final TabItemView itemView = new TabItemView(getContext()); // final TabItemModel info = getItem(position); // itemView.initialize(info.drawable, info.checkedDrawable, info.text); // return itemView; // } // } // // Path: app/src/main/java/com/kong/home/tab/event/SelectRepeatEvent.java // public class SelectRepeatEvent { // public static final int HOMEINDEX = 0; // public static final int BLOGINDEX = 1; // public static final int GANKINDEX = 2; // public int type; // // public SelectRepeatEvent(int type) { // this.type = type; // } // }
import android.content.Context; import android.os.Bundle; import android.os.Parcelable; import android.support.v4.view.ViewPager; import android.util.AttributeSet; import android.util.Log; import android.util.SparseArray; import android.view.Gravity; import android.view.View; import android.widget.LinearLayout; import com.kong.home.tab.OnTabItemSelectedListener; import com.kong.home.tab.adapter.BottomTabAdapter; import com.kong.home.tab.event.SelectRepeatEvent; import org.greenrobot.eventbus.EventBus; import java.util.ArrayList; import java.util.List;
package com.kong.home.tab.widget; /** * Created by CaoPengfei on 16/4/11. */ public class BottomTabLayout extends LinearLayout { private static final String TAG = "BottomTabLayout"; private int mSelectedIndex = -1;
// Path: app/src/main/java/com/kong/home/tab/OnTabItemSelectedListener.java // public interface OnTabItemSelectedListener { // // void onSelected(int index, int old); // // void onSelectRepeat(int index); // } // // Path: app/src/main/java/com/kong/home/tab/adapter/BottomTabAdapter.java // public class BottomTabAdapter extends BaseTabAdapter<TabItemModel> { // // private static final String TAG = "BottomTabAdapter"; // // public BottomTabAdapter(Context context, List<TabItemModel> tabItemModels) { // super(context, tabItemModels); // } // // @Override // public View getView(final int position) { // final TabItemView itemView = new TabItemView(getContext()); // final TabItemModel info = getItem(position); // itemView.initialize(info.drawable, info.checkedDrawable, info.text); // return itemView; // } // } // // Path: app/src/main/java/com/kong/home/tab/event/SelectRepeatEvent.java // public class SelectRepeatEvent { // public static final int HOMEINDEX = 0; // public static final int BLOGINDEX = 1; // public static final int GANKINDEX = 2; // public int type; // // public SelectRepeatEvent(int type) { // this.type = type; // } // } // Path: app/src/main/java/com/kong/home/tab/widget/BottomTabLayout.java import android.content.Context; import android.os.Bundle; import android.os.Parcelable; import android.support.v4.view.ViewPager; import android.util.AttributeSet; import android.util.Log; import android.util.SparseArray; import android.view.Gravity; import android.view.View; import android.widget.LinearLayout; import com.kong.home.tab.OnTabItemSelectedListener; import com.kong.home.tab.adapter.BottomTabAdapter; import com.kong.home.tab.event.SelectRepeatEvent; import org.greenrobot.eventbus.EventBus; import java.util.ArrayList; import java.util.List; package com.kong.home.tab.widget; /** * Created by CaoPengfei on 16/4/11. */ public class BottomTabLayout extends LinearLayout { private static final String TAG = "BottomTabLayout"; private int mSelectedIndex = -1;
private BottomTabAdapter mBottomTabAdapter;
whiskeyfei/SimpleNews.io
app/src/main/java/com/kong/home/tab/widget/BottomTabLayout.java
// Path: app/src/main/java/com/kong/home/tab/OnTabItemSelectedListener.java // public interface OnTabItemSelectedListener { // // void onSelected(int index, int old); // // void onSelectRepeat(int index); // } // // Path: app/src/main/java/com/kong/home/tab/adapter/BottomTabAdapter.java // public class BottomTabAdapter extends BaseTabAdapter<TabItemModel> { // // private static final String TAG = "BottomTabAdapter"; // // public BottomTabAdapter(Context context, List<TabItemModel> tabItemModels) { // super(context, tabItemModels); // } // // @Override // public View getView(final int position) { // final TabItemView itemView = new TabItemView(getContext()); // final TabItemModel info = getItem(position); // itemView.initialize(info.drawable, info.checkedDrawable, info.text); // return itemView; // } // } // // Path: app/src/main/java/com/kong/home/tab/event/SelectRepeatEvent.java // public class SelectRepeatEvent { // public static final int HOMEINDEX = 0; // public static final int BLOGINDEX = 1; // public static final int GANKINDEX = 2; // public int type; // // public SelectRepeatEvent(int type) { // this.type = type; // } // }
import android.content.Context; import android.os.Bundle; import android.os.Parcelable; import android.support.v4.view.ViewPager; import android.util.AttributeSet; import android.util.Log; import android.util.SparseArray; import android.view.Gravity; import android.view.View; import android.widget.LinearLayout; import com.kong.home.tab.OnTabItemSelectedListener; import com.kong.home.tab.adapter.BottomTabAdapter; import com.kong.home.tab.event.SelectRepeatEvent; import org.greenrobot.eventbus.EventBus; import java.util.ArrayList; import java.util.List;
package com.kong.home.tab.widget; /** * Created by CaoPengfei on 16/4/11. */ public class BottomTabLayout extends LinearLayout { private static final String TAG = "BottomTabLayout"; private int mSelectedIndex = -1; private BottomTabAdapter mBottomTabAdapter; private Context mContext; private TabViewPager mViewPager; private SparseArray<View> mTabViews;
// Path: app/src/main/java/com/kong/home/tab/OnTabItemSelectedListener.java // public interface OnTabItemSelectedListener { // // void onSelected(int index, int old); // // void onSelectRepeat(int index); // } // // Path: app/src/main/java/com/kong/home/tab/adapter/BottomTabAdapter.java // public class BottomTabAdapter extends BaseTabAdapter<TabItemModel> { // // private static final String TAG = "BottomTabAdapter"; // // public BottomTabAdapter(Context context, List<TabItemModel> tabItemModels) { // super(context, tabItemModels); // } // // @Override // public View getView(final int position) { // final TabItemView itemView = new TabItemView(getContext()); // final TabItemModel info = getItem(position); // itemView.initialize(info.drawable, info.checkedDrawable, info.text); // return itemView; // } // } // // Path: app/src/main/java/com/kong/home/tab/event/SelectRepeatEvent.java // public class SelectRepeatEvent { // public static final int HOMEINDEX = 0; // public static final int BLOGINDEX = 1; // public static final int GANKINDEX = 2; // public int type; // // public SelectRepeatEvent(int type) { // this.type = type; // } // } // Path: app/src/main/java/com/kong/home/tab/widget/BottomTabLayout.java import android.content.Context; import android.os.Bundle; import android.os.Parcelable; import android.support.v4.view.ViewPager; import android.util.AttributeSet; import android.util.Log; import android.util.SparseArray; import android.view.Gravity; import android.view.View; import android.widget.LinearLayout; import com.kong.home.tab.OnTabItemSelectedListener; import com.kong.home.tab.adapter.BottomTabAdapter; import com.kong.home.tab.event.SelectRepeatEvent; import org.greenrobot.eventbus.EventBus; import java.util.ArrayList; import java.util.List; package com.kong.home.tab.widget; /** * Created by CaoPengfei on 16/4/11. */ public class BottomTabLayout extends LinearLayout { private static final String TAG = "BottomTabLayout"; private int mSelectedIndex = -1; private BottomTabAdapter mBottomTabAdapter; private Context mContext; private TabViewPager mViewPager; private SparseArray<View> mTabViews;
private List<OnTabItemSelectedListener> mListeners = new ArrayList<>();
whiskeyfei/SimpleNews.io
app/src/main/java/com/kong/home/tab/widget/BottomTabLayout.java
// Path: app/src/main/java/com/kong/home/tab/OnTabItemSelectedListener.java // public interface OnTabItemSelectedListener { // // void onSelected(int index, int old); // // void onSelectRepeat(int index); // } // // Path: app/src/main/java/com/kong/home/tab/adapter/BottomTabAdapter.java // public class BottomTabAdapter extends BaseTabAdapter<TabItemModel> { // // private static final String TAG = "BottomTabAdapter"; // // public BottomTabAdapter(Context context, List<TabItemModel> tabItemModels) { // super(context, tabItemModels); // } // // @Override // public View getView(final int position) { // final TabItemView itemView = new TabItemView(getContext()); // final TabItemModel info = getItem(position); // itemView.initialize(info.drawable, info.checkedDrawable, info.text); // return itemView; // } // } // // Path: app/src/main/java/com/kong/home/tab/event/SelectRepeatEvent.java // public class SelectRepeatEvent { // public static final int HOMEINDEX = 0; // public static final int BLOGINDEX = 1; // public static final int GANKINDEX = 2; // public int type; // // public SelectRepeatEvent(int type) { // this.type = type; // } // }
import android.content.Context; import android.os.Bundle; import android.os.Parcelable; import android.support.v4.view.ViewPager; import android.util.AttributeSet; import android.util.Log; import android.util.SparseArray; import android.view.Gravity; import android.view.View; import android.widget.LinearLayout; import com.kong.home.tab.OnTabItemSelectedListener; import com.kong.home.tab.adapter.BottomTabAdapter; import com.kong.home.tab.event.SelectRepeatEvent; import org.greenrobot.eventbus.EventBus; import java.util.ArrayList; import java.util.List;
if (viewPager == null) { return; } mViewPager = viewPager; if (mPageChangeListener != null) { mViewPager.removeOnPageChangeListener(mPageChangeListener); } else { mPageChangeListener = new ViewPagerPageChangeListener(); } int index = mViewPager.getCurrentItem(); if (getSelectedIndex() != index) { setSelectIndex(index); } mViewPager.addOnPageChangeListener(mPageChangeListener); addTabItemSelectedListener(mTabItemListener); } private OnTabItemSelectedListener mTabItemListener = new OnTabItemSelectedListener() { @Override public void onSelected(int index, int old) { if (mViewPager != null) mViewPager.setCurrentItem(index, false); } @Override public void onSelectRepeat(int index) { Log.i(TAG, "onSelectRepeat: index" + index);
// Path: app/src/main/java/com/kong/home/tab/OnTabItemSelectedListener.java // public interface OnTabItemSelectedListener { // // void onSelected(int index, int old); // // void onSelectRepeat(int index); // } // // Path: app/src/main/java/com/kong/home/tab/adapter/BottomTabAdapter.java // public class BottomTabAdapter extends BaseTabAdapter<TabItemModel> { // // private static final String TAG = "BottomTabAdapter"; // // public BottomTabAdapter(Context context, List<TabItemModel> tabItemModels) { // super(context, tabItemModels); // } // // @Override // public View getView(final int position) { // final TabItemView itemView = new TabItemView(getContext()); // final TabItemModel info = getItem(position); // itemView.initialize(info.drawable, info.checkedDrawable, info.text); // return itemView; // } // } // // Path: app/src/main/java/com/kong/home/tab/event/SelectRepeatEvent.java // public class SelectRepeatEvent { // public static final int HOMEINDEX = 0; // public static final int BLOGINDEX = 1; // public static final int GANKINDEX = 2; // public int type; // // public SelectRepeatEvent(int type) { // this.type = type; // } // } // Path: app/src/main/java/com/kong/home/tab/widget/BottomTabLayout.java import android.content.Context; import android.os.Bundle; import android.os.Parcelable; import android.support.v4.view.ViewPager; import android.util.AttributeSet; import android.util.Log; import android.util.SparseArray; import android.view.Gravity; import android.view.View; import android.widget.LinearLayout; import com.kong.home.tab.OnTabItemSelectedListener; import com.kong.home.tab.adapter.BottomTabAdapter; import com.kong.home.tab.event.SelectRepeatEvent; import org.greenrobot.eventbus.EventBus; import java.util.ArrayList; import java.util.List; if (viewPager == null) { return; } mViewPager = viewPager; if (mPageChangeListener != null) { mViewPager.removeOnPageChangeListener(mPageChangeListener); } else { mPageChangeListener = new ViewPagerPageChangeListener(); } int index = mViewPager.getCurrentItem(); if (getSelectedIndex() != index) { setSelectIndex(index); } mViewPager.addOnPageChangeListener(mPageChangeListener); addTabItemSelectedListener(mTabItemListener); } private OnTabItemSelectedListener mTabItemListener = new OnTabItemSelectedListener() { @Override public void onSelected(int index, int old) { if (mViewPager != null) mViewPager.setCurrentItem(index, false); } @Override public void onSelectRepeat(int index) { Log.i(TAG, "onSelectRepeat: index" + index);
EventBus.getDefault().post(new SelectRepeatEvent(index));
whiskeyfei/SimpleNews.io
app/src/main/java/com/kong/app/news/detail/DetailContract.java
// Path: app/src/main/java/com/kong/lib/widget/SafeWebView.java // public class SafeWebView extends WebView { // // public SafeWebView(Context context) { // super(context); // removeSearchBox(); // } // // public SafeWebView(Context context, AttributeSet attrs) { // super(context, attrs); // removeSearchBox(); // } // // public SafeWebView(Context context, AttributeSet attrs, int defStyleAttr) { // super(context, attrs, defStyleAttr); // removeSearchBox(); // } // // /** // * 移除系统注入的对象,避免js漏洞 // * <p> // * https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2014-1939 // * https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2014-7224 // */ // private void removeSearchBox() { // super.removeJavascriptInterface("searchBoxJavaBridge_"); // super.removeJavascriptInterface("accessibility"); // super.removeJavascriptInterface("accessibilityTraversal"); // } // // public static void disableAccessibility(Context context) { // if (Build.VERSION.SDK_INT == 17/*4.2 (Build.VERSION_CODES.JELLY_BEAN_MR1)*/) { // if (context != null) { // try { // AccessibilityManager am = (AccessibilityManager) context.getSystemService(Context.ACCESSIBILITY_SERVICE); // if (!am.isEnabled()) { // //Not need to disable accessibility // return; // } // // Method setState = am.getClass().getDeclaredMethod("setState", int.class); // setState.setAccessible(true); // setState.invoke(am, 0);/**{@link AccessibilityManager#STATE_FLAG_ACCESSIBILITY_ENABLED}*/ // } catch (Exception ignored) { // ignored.printStackTrace(); // } // } // } // } // // @Override // public void setOverScrollMode(int mode) { // // try { // // super.setOverScrollMode(mode); // // } catch (Throwable e) { // // e.printStackTrace(); // // } // // try { // super.setOverScrollMode(mode); // } catch (Throwable e) { // String trace = Log.getStackTraceString(e); // if (trace.contains("android.content.pm.PackageManager$NameNotFoundException") // || trace.contains("java.lang.RuntimeException: Cannot load WebView") // || trace.contains("android.webkit.WebViewFactory$MissingWebViewPackageException: Failed to load WebView provider: No WebView installed")) { // e.printStackTrace(); // } else { // throw e; // } // } // } // // @Override // public boolean isPrivateBrowsingEnabled() { // if (Build.VERSION.SDK_INT == Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1 && getSettings() == null) { // return false; // } else { // return super.isPrivateBrowsingEnabled(); // } // } // // @Override // public void onResume() { // super.onResume(); // resumeTimers(); // } // // @Override // public void onPause() { // super.onPause(); // pauseTimers(); // } // // /** // * 释放相关操作 // */ // public void onDestroy() { // setWebViewClient(null); // removeAllViews(); // stopLoading(); // clearMatches(); // clearHistory(); // clearSslPreferences(); // clearCache(true); // destroy(); // } // } // // Path: app/src/main/java/com/kong/lib/mvp/BasePresenter.java // public interface BasePresenter { // // void start(); // // } // // Path: app/src/main/java/com/kong/lib/mvp/BaseView.java // public interface BaseView<T> { // // void setPresenter(T presenter); // // }
import com.kong.lib.widget.SafeWebView; import com.kong.lib.mvp.BasePresenter; import com.kong.lib.mvp.BaseView;
package com.kong.app.news.detail; /** * Created by whiskeyfei on 16/11/6. */ public interface DetailContract { interface View extends BaseView<Presenter> { void showLoadErrorMessage(String description); }
// Path: app/src/main/java/com/kong/lib/widget/SafeWebView.java // public class SafeWebView extends WebView { // // public SafeWebView(Context context) { // super(context); // removeSearchBox(); // } // // public SafeWebView(Context context, AttributeSet attrs) { // super(context, attrs); // removeSearchBox(); // } // // public SafeWebView(Context context, AttributeSet attrs, int defStyleAttr) { // super(context, attrs, defStyleAttr); // removeSearchBox(); // } // // /** // * 移除系统注入的对象,避免js漏洞 // * <p> // * https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2014-1939 // * https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2014-7224 // */ // private void removeSearchBox() { // super.removeJavascriptInterface("searchBoxJavaBridge_"); // super.removeJavascriptInterface("accessibility"); // super.removeJavascriptInterface("accessibilityTraversal"); // } // // public static void disableAccessibility(Context context) { // if (Build.VERSION.SDK_INT == 17/*4.2 (Build.VERSION_CODES.JELLY_BEAN_MR1)*/) { // if (context != null) { // try { // AccessibilityManager am = (AccessibilityManager) context.getSystemService(Context.ACCESSIBILITY_SERVICE); // if (!am.isEnabled()) { // //Not need to disable accessibility // return; // } // // Method setState = am.getClass().getDeclaredMethod("setState", int.class); // setState.setAccessible(true); // setState.invoke(am, 0);/**{@link AccessibilityManager#STATE_FLAG_ACCESSIBILITY_ENABLED}*/ // } catch (Exception ignored) { // ignored.printStackTrace(); // } // } // } // } // // @Override // public void setOverScrollMode(int mode) { // // try { // // super.setOverScrollMode(mode); // // } catch (Throwable e) { // // e.printStackTrace(); // // } // // try { // super.setOverScrollMode(mode); // } catch (Throwable e) { // String trace = Log.getStackTraceString(e); // if (trace.contains("android.content.pm.PackageManager$NameNotFoundException") // || trace.contains("java.lang.RuntimeException: Cannot load WebView") // || trace.contains("android.webkit.WebViewFactory$MissingWebViewPackageException: Failed to load WebView provider: No WebView installed")) { // e.printStackTrace(); // } else { // throw e; // } // } // } // // @Override // public boolean isPrivateBrowsingEnabled() { // if (Build.VERSION.SDK_INT == Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1 && getSettings() == null) { // return false; // } else { // return super.isPrivateBrowsingEnabled(); // } // } // // @Override // public void onResume() { // super.onResume(); // resumeTimers(); // } // // @Override // public void onPause() { // super.onPause(); // pauseTimers(); // } // // /** // * 释放相关操作 // */ // public void onDestroy() { // setWebViewClient(null); // removeAllViews(); // stopLoading(); // clearMatches(); // clearHistory(); // clearSslPreferences(); // clearCache(true); // destroy(); // } // } // // Path: app/src/main/java/com/kong/lib/mvp/BasePresenter.java // public interface BasePresenter { // // void start(); // // } // // Path: app/src/main/java/com/kong/lib/mvp/BaseView.java // public interface BaseView<T> { // // void setPresenter(T presenter); // // } // Path: app/src/main/java/com/kong/app/news/detail/DetailContract.java import com.kong.lib.widget.SafeWebView; import com.kong.lib.mvp.BasePresenter; import com.kong.lib.mvp.BaseView; package com.kong.app.news.detail; /** * Created by whiskeyfei on 16/11/6. */ public interface DetailContract { interface View extends BaseView<Presenter> { void showLoadErrorMessage(String description); }
interface Presenter extends BasePresenter {
whiskeyfei/SimpleNews.io
app/src/main/java/com/kong/app/news/detail/DetailContract.java
// Path: app/src/main/java/com/kong/lib/widget/SafeWebView.java // public class SafeWebView extends WebView { // // public SafeWebView(Context context) { // super(context); // removeSearchBox(); // } // // public SafeWebView(Context context, AttributeSet attrs) { // super(context, attrs); // removeSearchBox(); // } // // public SafeWebView(Context context, AttributeSet attrs, int defStyleAttr) { // super(context, attrs, defStyleAttr); // removeSearchBox(); // } // // /** // * 移除系统注入的对象,避免js漏洞 // * <p> // * https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2014-1939 // * https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2014-7224 // */ // private void removeSearchBox() { // super.removeJavascriptInterface("searchBoxJavaBridge_"); // super.removeJavascriptInterface("accessibility"); // super.removeJavascriptInterface("accessibilityTraversal"); // } // // public static void disableAccessibility(Context context) { // if (Build.VERSION.SDK_INT == 17/*4.2 (Build.VERSION_CODES.JELLY_BEAN_MR1)*/) { // if (context != null) { // try { // AccessibilityManager am = (AccessibilityManager) context.getSystemService(Context.ACCESSIBILITY_SERVICE); // if (!am.isEnabled()) { // //Not need to disable accessibility // return; // } // // Method setState = am.getClass().getDeclaredMethod("setState", int.class); // setState.setAccessible(true); // setState.invoke(am, 0);/**{@link AccessibilityManager#STATE_FLAG_ACCESSIBILITY_ENABLED}*/ // } catch (Exception ignored) { // ignored.printStackTrace(); // } // } // } // } // // @Override // public void setOverScrollMode(int mode) { // // try { // // super.setOverScrollMode(mode); // // } catch (Throwable e) { // // e.printStackTrace(); // // } // // try { // super.setOverScrollMode(mode); // } catch (Throwable e) { // String trace = Log.getStackTraceString(e); // if (trace.contains("android.content.pm.PackageManager$NameNotFoundException") // || trace.contains("java.lang.RuntimeException: Cannot load WebView") // || trace.contains("android.webkit.WebViewFactory$MissingWebViewPackageException: Failed to load WebView provider: No WebView installed")) { // e.printStackTrace(); // } else { // throw e; // } // } // } // // @Override // public boolean isPrivateBrowsingEnabled() { // if (Build.VERSION.SDK_INT == Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1 && getSettings() == null) { // return false; // } else { // return super.isPrivateBrowsingEnabled(); // } // } // // @Override // public void onResume() { // super.onResume(); // resumeTimers(); // } // // @Override // public void onPause() { // super.onPause(); // pauseTimers(); // } // // /** // * 释放相关操作 // */ // public void onDestroy() { // setWebViewClient(null); // removeAllViews(); // stopLoading(); // clearMatches(); // clearHistory(); // clearSslPreferences(); // clearCache(true); // destroy(); // } // } // // Path: app/src/main/java/com/kong/lib/mvp/BasePresenter.java // public interface BasePresenter { // // void start(); // // } // // Path: app/src/main/java/com/kong/lib/mvp/BaseView.java // public interface BaseView<T> { // // void setPresenter(T presenter); // // }
import com.kong.lib.widget.SafeWebView; import com.kong.lib.mvp.BasePresenter; import com.kong.lib.mvp.BaseView;
package com.kong.app.news.detail; /** * Created by whiskeyfei on 16/11/6. */ public interface DetailContract { interface View extends BaseView<Presenter> { void showLoadErrorMessage(String description); } interface Presenter extends BasePresenter {
// Path: app/src/main/java/com/kong/lib/widget/SafeWebView.java // public class SafeWebView extends WebView { // // public SafeWebView(Context context) { // super(context); // removeSearchBox(); // } // // public SafeWebView(Context context, AttributeSet attrs) { // super(context, attrs); // removeSearchBox(); // } // // public SafeWebView(Context context, AttributeSet attrs, int defStyleAttr) { // super(context, attrs, defStyleAttr); // removeSearchBox(); // } // // /** // * 移除系统注入的对象,避免js漏洞 // * <p> // * https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2014-1939 // * https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2014-7224 // */ // private void removeSearchBox() { // super.removeJavascriptInterface("searchBoxJavaBridge_"); // super.removeJavascriptInterface("accessibility"); // super.removeJavascriptInterface("accessibilityTraversal"); // } // // public static void disableAccessibility(Context context) { // if (Build.VERSION.SDK_INT == 17/*4.2 (Build.VERSION_CODES.JELLY_BEAN_MR1)*/) { // if (context != null) { // try { // AccessibilityManager am = (AccessibilityManager) context.getSystemService(Context.ACCESSIBILITY_SERVICE); // if (!am.isEnabled()) { // //Not need to disable accessibility // return; // } // // Method setState = am.getClass().getDeclaredMethod("setState", int.class); // setState.setAccessible(true); // setState.invoke(am, 0);/**{@link AccessibilityManager#STATE_FLAG_ACCESSIBILITY_ENABLED}*/ // } catch (Exception ignored) { // ignored.printStackTrace(); // } // } // } // } // // @Override // public void setOverScrollMode(int mode) { // // try { // // super.setOverScrollMode(mode); // // } catch (Throwable e) { // // e.printStackTrace(); // // } // // try { // super.setOverScrollMode(mode); // } catch (Throwable e) { // String trace = Log.getStackTraceString(e); // if (trace.contains("android.content.pm.PackageManager$NameNotFoundException") // || trace.contains("java.lang.RuntimeException: Cannot load WebView") // || trace.contains("android.webkit.WebViewFactory$MissingWebViewPackageException: Failed to load WebView provider: No WebView installed")) { // e.printStackTrace(); // } else { // throw e; // } // } // } // // @Override // public boolean isPrivateBrowsingEnabled() { // if (Build.VERSION.SDK_INT == Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1 && getSettings() == null) { // return false; // } else { // return super.isPrivateBrowsingEnabled(); // } // } // // @Override // public void onResume() { // super.onResume(); // resumeTimers(); // } // // @Override // public void onPause() { // super.onPause(); // pauseTimers(); // } // // /** // * 释放相关操作 // */ // public void onDestroy() { // setWebViewClient(null); // removeAllViews(); // stopLoading(); // clearMatches(); // clearHistory(); // clearSslPreferences(); // clearCache(true); // destroy(); // } // } // // Path: app/src/main/java/com/kong/lib/mvp/BasePresenter.java // public interface BasePresenter { // // void start(); // // } // // Path: app/src/main/java/com/kong/lib/mvp/BaseView.java // public interface BaseView<T> { // // void setPresenter(T presenter); // // } // Path: app/src/main/java/com/kong/app/news/detail/DetailContract.java import com.kong.lib.widget.SafeWebView; import com.kong.lib.mvp.BasePresenter; import com.kong.lib.mvp.BaseView; package com.kong.app.news.detail; /** * Created by whiskeyfei on 16/11/6. */ public interface DetailContract { interface View extends BaseView<Presenter> { void showLoadErrorMessage(String description); } interface Presenter extends BasePresenter {
void init(SafeWebView webView);
whiskeyfei/SimpleNews.io
app/src/main/java/com/kong/app/demo/me/SettingImgTvItemViewBinder.java
// Path: app/src/main/java/com/kong/app/news/NewsEntry.java // public class NewsEntry implements INewsEntry { // // private static class NewsEntryHelper { // private static NewsEntry sIns = new NewsEntry(); // } // // public static INewsEntry get() { // return NewsEntryHelper.sIns; // } // // @Override // public void startCommon(Context context, Class<?> cls) { // Intent intent = new Intent(context, cls); // ActivityUtils.startActivity(context,intent); // } // // @Override // public void startAbout(Context context) { // Intent intent = new Intent(context, AboutActivity.class); // ActivityUtils.startActivity(context,intent); // } // // // @Override // // public void startDemo(Context context) { // // Intent intent = new Intent(context, DemoActivity.class); // // ActivityUtils.startActivity(context,intent); // // } // // @Override // public void startSetting(Context context) { // Intent intent = new Intent(context, SettingActivity.class); // ActivityUtils.startActivity(context,intent); // } // // // @Override // // public void startNote(Context context) { // // Intent intent = new Intent(context, NoteActivity.class); // // ActivityUtils.startActivity(context,intent); // // } // // // @Override // // public void startNote(Context context, Intent intent) { // // ActivityUtils.startActivity(context,intent); // // } // // @Override // public void startMain(Context context) { // Intent intent = new Intent(context, HomeActivity.class); // ActivityUtils.startActivity(context,intent); // } // // @Override // public void startBrowser(Context context, String url) { // Intent intent = new Intent(context, BrowserActivity.class); // intent.putExtra(BrowserActivity.BWO_KEY,url); // ActivityUtils.startActivity(context,intent); // } // // @Override // public void startBrowser(Context context, String url, String title) { // Intent intent = new Intent(context, BrowserActivity.class); // intent.putExtra(BrowserActivity.BWO_KEY,url); // intent.putExtra(BrowserActivity.BWO_TITLE,title); // ActivityUtils.startActivity(context,intent); // } // // @Override // public void startDetailActivity(Context context, NewModel news) { // Intent intent = new Intent(context, NewsDetailActivity.class); // intent.putExtra(NewsDetailActivity.TITLE,news.title); // intent.putExtra(NewsDetailActivity.URL,news.newUrl); // ActivityUtils.startActivity(context, intent); // } // } // // Path: app/src/main/java/com/kong/app/me/MeFragment.java // public static final int TYPE_ABOUT = 1; // // Path: app/src/main/java/com/kong/app/me/MeFragment.java // public static final int TYPE_PROBLEM = 2; // // Path: app/src/main/java/com/kong/app/me/MeFragment.java // public static final int TYPE_SETTING = 3;
import android.support.annotation.NonNull; import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.TextView; import com.kong.R; import com.kong.app.news.NewsEntry; import me.drakeet.multitype.ItemViewBinder; import static com.kong.app.me.MeFragment.TYPE_ABOUT; import static com.kong.app.me.MeFragment.TYPE_PROBLEM; import static com.kong.app.me.MeFragment.TYPE_SETTING;
package com.kong.app.demo.me; /** * Created by CaoPengfei on 17/6/18. */ public class SettingImgTvItemViewBinder extends ItemViewBinder<SettingImgTvItem, SettingImgTvItemViewBinder.ViewHolder> { @Override protected ViewHolder onCreateViewHolder(@NonNull LayoutInflater inflater, @NonNull ViewGroup parent) { View view = inflater.inflate(R.layout.item_setting_image_tv_h, parent, false); return new ViewHolder(view); } @Override protected void onBindViewHolder(@NonNull ViewHolder holder, @NonNull SettingImgTvItem item) { holder.setData(item); } static class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener { public TextView title; public ImageView icon; private SettingImgTvItem mData; public ViewHolder(View itemView) { super(itemView); title = (TextView) itemView.findViewById(R.id.setting_item_h_title); icon = (ImageView) itemView.findViewById(R.id.setting_item_h_icon); itemView.setOnClickListener(this); } @Override public void onClick(View v) { switch (getAdapterPosition()) {
// Path: app/src/main/java/com/kong/app/news/NewsEntry.java // public class NewsEntry implements INewsEntry { // // private static class NewsEntryHelper { // private static NewsEntry sIns = new NewsEntry(); // } // // public static INewsEntry get() { // return NewsEntryHelper.sIns; // } // // @Override // public void startCommon(Context context, Class<?> cls) { // Intent intent = new Intent(context, cls); // ActivityUtils.startActivity(context,intent); // } // // @Override // public void startAbout(Context context) { // Intent intent = new Intent(context, AboutActivity.class); // ActivityUtils.startActivity(context,intent); // } // // // @Override // // public void startDemo(Context context) { // // Intent intent = new Intent(context, DemoActivity.class); // // ActivityUtils.startActivity(context,intent); // // } // // @Override // public void startSetting(Context context) { // Intent intent = new Intent(context, SettingActivity.class); // ActivityUtils.startActivity(context,intent); // } // // // @Override // // public void startNote(Context context) { // // Intent intent = new Intent(context, NoteActivity.class); // // ActivityUtils.startActivity(context,intent); // // } // // // @Override // // public void startNote(Context context, Intent intent) { // // ActivityUtils.startActivity(context,intent); // // } // // @Override // public void startMain(Context context) { // Intent intent = new Intent(context, HomeActivity.class); // ActivityUtils.startActivity(context,intent); // } // // @Override // public void startBrowser(Context context, String url) { // Intent intent = new Intent(context, BrowserActivity.class); // intent.putExtra(BrowserActivity.BWO_KEY,url); // ActivityUtils.startActivity(context,intent); // } // // @Override // public void startBrowser(Context context, String url, String title) { // Intent intent = new Intent(context, BrowserActivity.class); // intent.putExtra(BrowserActivity.BWO_KEY,url); // intent.putExtra(BrowserActivity.BWO_TITLE,title); // ActivityUtils.startActivity(context,intent); // } // // @Override // public void startDetailActivity(Context context, NewModel news) { // Intent intent = new Intent(context, NewsDetailActivity.class); // intent.putExtra(NewsDetailActivity.TITLE,news.title); // intent.putExtra(NewsDetailActivity.URL,news.newUrl); // ActivityUtils.startActivity(context, intent); // } // } // // Path: app/src/main/java/com/kong/app/me/MeFragment.java // public static final int TYPE_ABOUT = 1; // // Path: app/src/main/java/com/kong/app/me/MeFragment.java // public static final int TYPE_PROBLEM = 2; // // Path: app/src/main/java/com/kong/app/me/MeFragment.java // public static final int TYPE_SETTING = 3; // Path: app/src/main/java/com/kong/app/demo/me/SettingImgTvItemViewBinder.java import android.support.annotation.NonNull; import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.TextView; import com.kong.R; import com.kong.app.news.NewsEntry; import me.drakeet.multitype.ItemViewBinder; import static com.kong.app.me.MeFragment.TYPE_ABOUT; import static com.kong.app.me.MeFragment.TYPE_PROBLEM; import static com.kong.app.me.MeFragment.TYPE_SETTING; package com.kong.app.demo.me; /** * Created by CaoPengfei on 17/6/18. */ public class SettingImgTvItemViewBinder extends ItemViewBinder<SettingImgTvItem, SettingImgTvItemViewBinder.ViewHolder> { @Override protected ViewHolder onCreateViewHolder(@NonNull LayoutInflater inflater, @NonNull ViewGroup parent) { View view = inflater.inflate(R.layout.item_setting_image_tv_h, parent, false); return new ViewHolder(view); } @Override protected void onBindViewHolder(@NonNull ViewHolder holder, @NonNull SettingImgTvItem item) { holder.setData(item); } static class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener { public TextView title; public ImageView icon; private SettingImgTvItem mData; public ViewHolder(View itemView) { super(itemView); title = (TextView) itemView.findViewById(R.id.setting_item_h_title); icon = (ImageView) itemView.findViewById(R.id.setting_item_h_icon); itemView.setOnClickListener(this); } @Override public void onClick(View v) { switch (getAdapterPosition()) {
case TYPE_ABOUT:
whiskeyfei/SimpleNews.io
app/src/main/java/com/kong/app/demo/me/SettingImgTvItemViewBinder.java
// Path: app/src/main/java/com/kong/app/news/NewsEntry.java // public class NewsEntry implements INewsEntry { // // private static class NewsEntryHelper { // private static NewsEntry sIns = new NewsEntry(); // } // // public static INewsEntry get() { // return NewsEntryHelper.sIns; // } // // @Override // public void startCommon(Context context, Class<?> cls) { // Intent intent = new Intent(context, cls); // ActivityUtils.startActivity(context,intent); // } // // @Override // public void startAbout(Context context) { // Intent intent = new Intent(context, AboutActivity.class); // ActivityUtils.startActivity(context,intent); // } // // // @Override // // public void startDemo(Context context) { // // Intent intent = new Intent(context, DemoActivity.class); // // ActivityUtils.startActivity(context,intent); // // } // // @Override // public void startSetting(Context context) { // Intent intent = new Intent(context, SettingActivity.class); // ActivityUtils.startActivity(context,intent); // } // // // @Override // // public void startNote(Context context) { // // Intent intent = new Intent(context, NoteActivity.class); // // ActivityUtils.startActivity(context,intent); // // } // // // @Override // // public void startNote(Context context, Intent intent) { // // ActivityUtils.startActivity(context,intent); // // } // // @Override // public void startMain(Context context) { // Intent intent = new Intent(context, HomeActivity.class); // ActivityUtils.startActivity(context,intent); // } // // @Override // public void startBrowser(Context context, String url) { // Intent intent = new Intent(context, BrowserActivity.class); // intent.putExtra(BrowserActivity.BWO_KEY,url); // ActivityUtils.startActivity(context,intent); // } // // @Override // public void startBrowser(Context context, String url, String title) { // Intent intent = new Intent(context, BrowserActivity.class); // intent.putExtra(BrowserActivity.BWO_KEY,url); // intent.putExtra(BrowserActivity.BWO_TITLE,title); // ActivityUtils.startActivity(context,intent); // } // // @Override // public void startDetailActivity(Context context, NewModel news) { // Intent intent = new Intent(context, NewsDetailActivity.class); // intent.putExtra(NewsDetailActivity.TITLE,news.title); // intent.putExtra(NewsDetailActivity.URL,news.newUrl); // ActivityUtils.startActivity(context, intent); // } // } // // Path: app/src/main/java/com/kong/app/me/MeFragment.java // public static final int TYPE_ABOUT = 1; // // Path: app/src/main/java/com/kong/app/me/MeFragment.java // public static final int TYPE_PROBLEM = 2; // // Path: app/src/main/java/com/kong/app/me/MeFragment.java // public static final int TYPE_SETTING = 3;
import android.support.annotation.NonNull; import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.TextView; import com.kong.R; import com.kong.app.news.NewsEntry; import me.drakeet.multitype.ItemViewBinder; import static com.kong.app.me.MeFragment.TYPE_ABOUT; import static com.kong.app.me.MeFragment.TYPE_PROBLEM; import static com.kong.app.me.MeFragment.TYPE_SETTING;
package com.kong.app.demo.me; /** * Created by CaoPengfei on 17/6/18. */ public class SettingImgTvItemViewBinder extends ItemViewBinder<SettingImgTvItem, SettingImgTvItemViewBinder.ViewHolder> { @Override protected ViewHolder onCreateViewHolder(@NonNull LayoutInflater inflater, @NonNull ViewGroup parent) { View view = inflater.inflate(R.layout.item_setting_image_tv_h, parent, false); return new ViewHolder(view); } @Override protected void onBindViewHolder(@NonNull ViewHolder holder, @NonNull SettingImgTvItem item) { holder.setData(item); } static class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener { public TextView title; public ImageView icon; private SettingImgTvItem mData; public ViewHolder(View itemView) { super(itemView); title = (TextView) itemView.findViewById(R.id.setting_item_h_title); icon = (ImageView) itemView.findViewById(R.id.setting_item_h_icon); itemView.setOnClickListener(this); } @Override public void onClick(View v) { switch (getAdapterPosition()) { case TYPE_ABOUT:
// Path: app/src/main/java/com/kong/app/news/NewsEntry.java // public class NewsEntry implements INewsEntry { // // private static class NewsEntryHelper { // private static NewsEntry sIns = new NewsEntry(); // } // // public static INewsEntry get() { // return NewsEntryHelper.sIns; // } // // @Override // public void startCommon(Context context, Class<?> cls) { // Intent intent = new Intent(context, cls); // ActivityUtils.startActivity(context,intent); // } // // @Override // public void startAbout(Context context) { // Intent intent = new Intent(context, AboutActivity.class); // ActivityUtils.startActivity(context,intent); // } // // // @Override // // public void startDemo(Context context) { // // Intent intent = new Intent(context, DemoActivity.class); // // ActivityUtils.startActivity(context,intent); // // } // // @Override // public void startSetting(Context context) { // Intent intent = new Intent(context, SettingActivity.class); // ActivityUtils.startActivity(context,intent); // } // // // @Override // // public void startNote(Context context) { // // Intent intent = new Intent(context, NoteActivity.class); // // ActivityUtils.startActivity(context,intent); // // } // // // @Override // // public void startNote(Context context, Intent intent) { // // ActivityUtils.startActivity(context,intent); // // } // // @Override // public void startMain(Context context) { // Intent intent = new Intent(context, HomeActivity.class); // ActivityUtils.startActivity(context,intent); // } // // @Override // public void startBrowser(Context context, String url) { // Intent intent = new Intent(context, BrowserActivity.class); // intent.putExtra(BrowserActivity.BWO_KEY,url); // ActivityUtils.startActivity(context,intent); // } // // @Override // public void startBrowser(Context context, String url, String title) { // Intent intent = new Intent(context, BrowserActivity.class); // intent.putExtra(BrowserActivity.BWO_KEY,url); // intent.putExtra(BrowserActivity.BWO_TITLE,title); // ActivityUtils.startActivity(context,intent); // } // // @Override // public void startDetailActivity(Context context, NewModel news) { // Intent intent = new Intent(context, NewsDetailActivity.class); // intent.putExtra(NewsDetailActivity.TITLE,news.title); // intent.putExtra(NewsDetailActivity.URL,news.newUrl); // ActivityUtils.startActivity(context, intent); // } // } // // Path: app/src/main/java/com/kong/app/me/MeFragment.java // public static final int TYPE_ABOUT = 1; // // Path: app/src/main/java/com/kong/app/me/MeFragment.java // public static final int TYPE_PROBLEM = 2; // // Path: app/src/main/java/com/kong/app/me/MeFragment.java // public static final int TYPE_SETTING = 3; // Path: app/src/main/java/com/kong/app/demo/me/SettingImgTvItemViewBinder.java import android.support.annotation.NonNull; import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.TextView; import com.kong.R; import com.kong.app.news.NewsEntry; import me.drakeet.multitype.ItemViewBinder; import static com.kong.app.me.MeFragment.TYPE_ABOUT; import static com.kong.app.me.MeFragment.TYPE_PROBLEM; import static com.kong.app.me.MeFragment.TYPE_SETTING; package com.kong.app.demo.me; /** * Created by CaoPengfei on 17/6/18. */ public class SettingImgTvItemViewBinder extends ItemViewBinder<SettingImgTvItem, SettingImgTvItemViewBinder.ViewHolder> { @Override protected ViewHolder onCreateViewHolder(@NonNull LayoutInflater inflater, @NonNull ViewGroup parent) { View view = inflater.inflate(R.layout.item_setting_image_tv_h, parent, false); return new ViewHolder(view); } @Override protected void onBindViewHolder(@NonNull ViewHolder holder, @NonNull SettingImgTvItem item) { holder.setData(item); } static class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener { public TextView title; public ImageView icon; private SettingImgTvItem mData; public ViewHolder(View itemView) { super(itemView); title = (TextView) itemView.findViewById(R.id.setting_item_h_title); icon = (ImageView) itemView.findViewById(R.id.setting_item_h_icon); itemView.setOnClickListener(this); } @Override public void onClick(View v) { switch (getAdapterPosition()) { case TYPE_ABOUT:
NewsEntry.get().startAbout(v.getContext());
whiskeyfei/SimpleNews.io
app/src/main/java/com/kong/app/demo/me/SettingImgTvItemViewBinder.java
// Path: app/src/main/java/com/kong/app/news/NewsEntry.java // public class NewsEntry implements INewsEntry { // // private static class NewsEntryHelper { // private static NewsEntry sIns = new NewsEntry(); // } // // public static INewsEntry get() { // return NewsEntryHelper.sIns; // } // // @Override // public void startCommon(Context context, Class<?> cls) { // Intent intent = new Intent(context, cls); // ActivityUtils.startActivity(context,intent); // } // // @Override // public void startAbout(Context context) { // Intent intent = new Intent(context, AboutActivity.class); // ActivityUtils.startActivity(context,intent); // } // // // @Override // // public void startDemo(Context context) { // // Intent intent = new Intent(context, DemoActivity.class); // // ActivityUtils.startActivity(context,intent); // // } // // @Override // public void startSetting(Context context) { // Intent intent = new Intent(context, SettingActivity.class); // ActivityUtils.startActivity(context,intent); // } // // // @Override // // public void startNote(Context context) { // // Intent intent = new Intent(context, NoteActivity.class); // // ActivityUtils.startActivity(context,intent); // // } // // // @Override // // public void startNote(Context context, Intent intent) { // // ActivityUtils.startActivity(context,intent); // // } // // @Override // public void startMain(Context context) { // Intent intent = new Intent(context, HomeActivity.class); // ActivityUtils.startActivity(context,intent); // } // // @Override // public void startBrowser(Context context, String url) { // Intent intent = new Intent(context, BrowserActivity.class); // intent.putExtra(BrowserActivity.BWO_KEY,url); // ActivityUtils.startActivity(context,intent); // } // // @Override // public void startBrowser(Context context, String url, String title) { // Intent intent = new Intent(context, BrowserActivity.class); // intent.putExtra(BrowserActivity.BWO_KEY,url); // intent.putExtra(BrowserActivity.BWO_TITLE,title); // ActivityUtils.startActivity(context,intent); // } // // @Override // public void startDetailActivity(Context context, NewModel news) { // Intent intent = new Intent(context, NewsDetailActivity.class); // intent.putExtra(NewsDetailActivity.TITLE,news.title); // intent.putExtra(NewsDetailActivity.URL,news.newUrl); // ActivityUtils.startActivity(context, intent); // } // } // // Path: app/src/main/java/com/kong/app/me/MeFragment.java // public static final int TYPE_ABOUT = 1; // // Path: app/src/main/java/com/kong/app/me/MeFragment.java // public static final int TYPE_PROBLEM = 2; // // Path: app/src/main/java/com/kong/app/me/MeFragment.java // public static final int TYPE_SETTING = 3;
import android.support.annotation.NonNull; import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.TextView; import com.kong.R; import com.kong.app.news.NewsEntry; import me.drakeet.multitype.ItemViewBinder; import static com.kong.app.me.MeFragment.TYPE_ABOUT; import static com.kong.app.me.MeFragment.TYPE_PROBLEM; import static com.kong.app.me.MeFragment.TYPE_SETTING;
package com.kong.app.demo.me; /** * Created by CaoPengfei on 17/6/18. */ public class SettingImgTvItemViewBinder extends ItemViewBinder<SettingImgTvItem, SettingImgTvItemViewBinder.ViewHolder> { @Override protected ViewHolder onCreateViewHolder(@NonNull LayoutInflater inflater, @NonNull ViewGroup parent) { View view = inflater.inflate(R.layout.item_setting_image_tv_h, parent, false); return new ViewHolder(view); } @Override protected void onBindViewHolder(@NonNull ViewHolder holder, @NonNull SettingImgTvItem item) { holder.setData(item); } static class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener { public TextView title; public ImageView icon; private SettingImgTvItem mData; public ViewHolder(View itemView) { super(itemView); title = (TextView) itemView.findViewById(R.id.setting_item_h_title); icon = (ImageView) itemView.findViewById(R.id.setting_item_h_icon); itemView.setOnClickListener(this); } @Override public void onClick(View v) { switch (getAdapterPosition()) { case TYPE_ABOUT: NewsEntry.get().startAbout(v.getContext()); break;
// Path: app/src/main/java/com/kong/app/news/NewsEntry.java // public class NewsEntry implements INewsEntry { // // private static class NewsEntryHelper { // private static NewsEntry sIns = new NewsEntry(); // } // // public static INewsEntry get() { // return NewsEntryHelper.sIns; // } // // @Override // public void startCommon(Context context, Class<?> cls) { // Intent intent = new Intent(context, cls); // ActivityUtils.startActivity(context,intent); // } // // @Override // public void startAbout(Context context) { // Intent intent = new Intent(context, AboutActivity.class); // ActivityUtils.startActivity(context,intent); // } // // // @Override // // public void startDemo(Context context) { // // Intent intent = new Intent(context, DemoActivity.class); // // ActivityUtils.startActivity(context,intent); // // } // // @Override // public void startSetting(Context context) { // Intent intent = new Intent(context, SettingActivity.class); // ActivityUtils.startActivity(context,intent); // } // // // @Override // // public void startNote(Context context) { // // Intent intent = new Intent(context, NoteActivity.class); // // ActivityUtils.startActivity(context,intent); // // } // // // @Override // // public void startNote(Context context, Intent intent) { // // ActivityUtils.startActivity(context,intent); // // } // // @Override // public void startMain(Context context) { // Intent intent = new Intent(context, HomeActivity.class); // ActivityUtils.startActivity(context,intent); // } // // @Override // public void startBrowser(Context context, String url) { // Intent intent = new Intent(context, BrowserActivity.class); // intent.putExtra(BrowserActivity.BWO_KEY,url); // ActivityUtils.startActivity(context,intent); // } // // @Override // public void startBrowser(Context context, String url, String title) { // Intent intent = new Intent(context, BrowserActivity.class); // intent.putExtra(BrowserActivity.BWO_KEY,url); // intent.putExtra(BrowserActivity.BWO_TITLE,title); // ActivityUtils.startActivity(context,intent); // } // // @Override // public void startDetailActivity(Context context, NewModel news) { // Intent intent = new Intent(context, NewsDetailActivity.class); // intent.putExtra(NewsDetailActivity.TITLE,news.title); // intent.putExtra(NewsDetailActivity.URL,news.newUrl); // ActivityUtils.startActivity(context, intent); // } // } // // Path: app/src/main/java/com/kong/app/me/MeFragment.java // public static final int TYPE_ABOUT = 1; // // Path: app/src/main/java/com/kong/app/me/MeFragment.java // public static final int TYPE_PROBLEM = 2; // // Path: app/src/main/java/com/kong/app/me/MeFragment.java // public static final int TYPE_SETTING = 3; // Path: app/src/main/java/com/kong/app/demo/me/SettingImgTvItemViewBinder.java import android.support.annotation.NonNull; import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.TextView; import com.kong.R; import com.kong.app.news.NewsEntry; import me.drakeet.multitype.ItemViewBinder; import static com.kong.app.me.MeFragment.TYPE_ABOUT; import static com.kong.app.me.MeFragment.TYPE_PROBLEM; import static com.kong.app.me.MeFragment.TYPE_SETTING; package com.kong.app.demo.me; /** * Created by CaoPengfei on 17/6/18. */ public class SettingImgTvItemViewBinder extends ItemViewBinder<SettingImgTvItem, SettingImgTvItemViewBinder.ViewHolder> { @Override protected ViewHolder onCreateViewHolder(@NonNull LayoutInflater inflater, @NonNull ViewGroup parent) { View view = inflater.inflate(R.layout.item_setting_image_tv_h, parent, false); return new ViewHolder(view); } @Override protected void onBindViewHolder(@NonNull ViewHolder holder, @NonNull SettingImgTvItem item) { holder.setData(item); } static class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener { public TextView title; public ImageView icon; private SettingImgTvItem mData; public ViewHolder(View itemView) { super(itemView); title = (TextView) itemView.findViewById(R.id.setting_item_h_title); icon = (ImageView) itemView.findViewById(R.id.setting_item_h_icon); itemView.setOnClickListener(this); } @Override public void onClick(View v) { switch (getAdapterPosition()) { case TYPE_ABOUT: NewsEntry.get().startAbout(v.getContext()); break;
case TYPE_PROBLEM:
whiskeyfei/SimpleNews.io
app/src/main/java/com/kong/app/demo/me/SettingImgTvItemViewBinder.java
// Path: app/src/main/java/com/kong/app/news/NewsEntry.java // public class NewsEntry implements INewsEntry { // // private static class NewsEntryHelper { // private static NewsEntry sIns = new NewsEntry(); // } // // public static INewsEntry get() { // return NewsEntryHelper.sIns; // } // // @Override // public void startCommon(Context context, Class<?> cls) { // Intent intent = new Intent(context, cls); // ActivityUtils.startActivity(context,intent); // } // // @Override // public void startAbout(Context context) { // Intent intent = new Intent(context, AboutActivity.class); // ActivityUtils.startActivity(context,intent); // } // // // @Override // // public void startDemo(Context context) { // // Intent intent = new Intent(context, DemoActivity.class); // // ActivityUtils.startActivity(context,intent); // // } // // @Override // public void startSetting(Context context) { // Intent intent = new Intent(context, SettingActivity.class); // ActivityUtils.startActivity(context,intent); // } // // // @Override // // public void startNote(Context context) { // // Intent intent = new Intent(context, NoteActivity.class); // // ActivityUtils.startActivity(context,intent); // // } // // // @Override // // public void startNote(Context context, Intent intent) { // // ActivityUtils.startActivity(context,intent); // // } // // @Override // public void startMain(Context context) { // Intent intent = new Intent(context, HomeActivity.class); // ActivityUtils.startActivity(context,intent); // } // // @Override // public void startBrowser(Context context, String url) { // Intent intent = new Intent(context, BrowserActivity.class); // intent.putExtra(BrowserActivity.BWO_KEY,url); // ActivityUtils.startActivity(context,intent); // } // // @Override // public void startBrowser(Context context, String url, String title) { // Intent intent = new Intent(context, BrowserActivity.class); // intent.putExtra(BrowserActivity.BWO_KEY,url); // intent.putExtra(BrowserActivity.BWO_TITLE,title); // ActivityUtils.startActivity(context,intent); // } // // @Override // public void startDetailActivity(Context context, NewModel news) { // Intent intent = new Intent(context, NewsDetailActivity.class); // intent.putExtra(NewsDetailActivity.TITLE,news.title); // intent.putExtra(NewsDetailActivity.URL,news.newUrl); // ActivityUtils.startActivity(context, intent); // } // } // // Path: app/src/main/java/com/kong/app/me/MeFragment.java // public static final int TYPE_ABOUT = 1; // // Path: app/src/main/java/com/kong/app/me/MeFragment.java // public static final int TYPE_PROBLEM = 2; // // Path: app/src/main/java/com/kong/app/me/MeFragment.java // public static final int TYPE_SETTING = 3;
import android.support.annotation.NonNull; import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.TextView; import com.kong.R; import com.kong.app.news.NewsEntry; import me.drakeet.multitype.ItemViewBinder; import static com.kong.app.me.MeFragment.TYPE_ABOUT; import static com.kong.app.me.MeFragment.TYPE_PROBLEM; import static com.kong.app.me.MeFragment.TYPE_SETTING;
package com.kong.app.demo.me; /** * Created by CaoPengfei on 17/6/18. */ public class SettingImgTvItemViewBinder extends ItemViewBinder<SettingImgTvItem, SettingImgTvItemViewBinder.ViewHolder> { @Override protected ViewHolder onCreateViewHolder(@NonNull LayoutInflater inflater, @NonNull ViewGroup parent) { View view = inflater.inflate(R.layout.item_setting_image_tv_h, parent, false); return new ViewHolder(view); } @Override protected void onBindViewHolder(@NonNull ViewHolder holder, @NonNull SettingImgTvItem item) { holder.setData(item); } static class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener { public TextView title; public ImageView icon; private SettingImgTvItem mData; public ViewHolder(View itemView) { super(itemView); title = (TextView) itemView.findViewById(R.id.setting_item_h_title); icon = (ImageView) itemView.findViewById(R.id.setting_item_h_icon); itemView.setOnClickListener(this); } @Override public void onClick(View v) { switch (getAdapterPosition()) { case TYPE_ABOUT: NewsEntry.get().startAbout(v.getContext()); break; case TYPE_PROBLEM: break;
// Path: app/src/main/java/com/kong/app/news/NewsEntry.java // public class NewsEntry implements INewsEntry { // // private static class NewsEntryHelper { // private static NewsEntry sIns = new NewsEntry(); // } // // public static INewsEntry get() { // return NewsEntryHelper.sIns; // } // // @Override // public void startCommon(Context context, Class<?> cls) { // Intent intent = new Intent(context, cls); // ActivityUtils.startActivity(context,intent); // } // // @Override // public void startAbout(Context context) { // Intent intent = new Intent(context, AboutActivity.class); // ActivityUtils.startActivity(context,intent); // } // // // @Override // // public void startDemo(Context context) { // // Intent intent = new Intent(context, DemoActivity.class); // // ActivityUtils.startActivity(context,intent); // // } // // @Override // public void startSetting(Context context) { // Intent intent = new Intent(context, SettingActivity.class); // ActivityUtils.startActivity(context,intent); // } // // // @Override // // public void startNote(Context context) { // // Intent intent = new Intent(context, NoteActivity.class); // // ActivityUtils.startActivity(context,intent); // // } // // // @Override // // public void startNote(Context context, Intent intent) { // // ActivityUtils.startActivity(context,intent); // // } // // @Override // public void startMain(Context context) { // Intent intent = new Intent(context, HomeActivity.class); // ActivityUtils.startActivity(context,intent); // } // // @Override // public void startBrowser(Context context, String url) { // Intent intent = new Intent(context, BrowserActivity.class); // intent.putExtra(BrowserActivity.BWO_KEY,url); // ActivityUtils.startActivity(context,intent); // } // // @Override // public void startBrowser(Context context, String url, String title) { // Intent intent = new Intent(context, BrowserActivity.class); // intent.putExtra(BrowserActivity.BWO_KEY,url); // intent.putExtra(BrowserActivity.BWO_TITLE,title); // ActivityUtils.startActivity(context,intent); // } // // @Override // public void startDetailActivity(Context context, NewModel news) { // Intent intent = new Intent(context, NewsDetailActivity.class); // intent.putExtra(NewsDetailActivity.TITLE,news.title); // intent.putExtra(NewsDetailActivity.URL,news.newUrl); // ActivityUtils.startActivity(context, intent); // } // } // // Path: app/src/main/java/com/kong/app/me/MeFragment.java // public static final int TYPE_ABOUT = 1; // // Path: app/src/main/java/com/kong/app/me/MeFragment.java // public static final int TYPE_PROBLEM = 2; // // Path: app/src/main/java/com/kong/app/me/MeFragment.java // public static final int TYPE_SETTING = 3; // Path: app/src/main/java/com/kong/app/demo/me/SettingImgTvItemViewBinder.java import android.support.annotation.NonNull; import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.TextView; import com.kong.R; import com.kong.app.news.NewsEntry; import me.drakeet.multitype.ItemViewBinder; import static com.kong.app.me.MeFragment.TYPE_ABOUT; import static com.kong.app.me.MeFragment.TYPE_PROBLEM; import static com.kong.app.me.MeFragment.TYPE_SETTING; package com.kong.app.demo.me; /** * Created by CaoPengfei on 17/6/18. */ public class SettingImgTvItemViewBinder extends ItemViewBinder<SettingImgTvItem, SettingImgTvItemViewBinder.ViewHolder> { @Override protected ViewHolder onCreateViewHolder(@NonNull LayoutInflater inflater, @NonNull ViewGroup parent) { View view = inflater.inflate(R.layout.item_setting_image_tv_h, parent, false); return new ViewHolder(view); } @Override protected void onBindViewHolder(@NonNull ViewHolder holder, @NonNull SettingImgTvItem item) { holder.setData(item); } static class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener { public TextView title; public ImageView icon; private SettingImgTvItem mData; public ViewHolder(View itemView) { super(itemView); title = (TextView) itemView.findViewById(R.id.setting_item_h_title); icon = (ImageView) itemView.findViewById(R.id.setting_item_h_icon); itemView.setOnClickListener(this); } @Override public void onClick(View v) { switch (getAdapterPosition()) { case TYPE_ABOUT: NewsEntry.get().startAbout(v.getContext()); break; case TYPE_PROBLEM: break;
case TYPE_SETTING:
whiskeyfei/SimpleNews.io
app/src/main/java/com/kong/app/news/base/ToolBarActivity.java
// Path: app/src/main/java/com/kong/lib/BaseActivity.java // public class BaseActivity extends AppCompatActivity { // // private static final String TAG = "BaseActivity"; // // @Override // protected void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // EventBus.getDefault().register(this); // } // // @Override // protected void onDestroy() { // super.onDestroy(); // EventBus.getDefault().unregister(this); // } // // @Subscribe(threadMode = ThreadMode.MAIN) // public void onMessageEvent(AppExitEvent event) { // Log.i(TAG, "onMessageEvent:" + event); // finish(); // } // // @Override // public boolean dispatchKeyEvent(KeyEvent event) { // if (event.getAction() != KeyEvent.ACTION_UP) { // return super.dispatchKeyEvent(event); // } // return super.dispatchKeyEvent(event); // } // // } // // Path: app/src/main/java/com/kong/lib/utils/ResourceUtil.java // public class ResourceUtil { // // public static String getString(int resId) { // return getResources().getString(resId); // } // // public static int getColor(int resId) { // return getResources().getColor(resId); // } // // public static Drawable getDrawable(int resId) { // return getResources().getDrawable(resId); // } // // public static int getDimen(int dimen) { // return (int) getResources().getDimension(dimen); // } // // public static Resources getResources() { // return getContext().getResources(); // } // // public static Context getContext() { // return AppRun.get().getApplicationContext(); // } // // public static String getRawFileStr(int rawId) throws IOException { // InputStream is = getResources().openRawResource(rawId); // BufferedReader reader = new BufferedReader(new InputStreamReader(is, "UTF-8")); // StringBuilder sb = new StringBuilder(); // String line; // while ((line = reader.readLine()) != null) { // sb.append(line).append("\n"); // } // sb.deleteCharAt(sb.length() - 1); // reader.close(); // return sb.toString(); // } // }
import android.os.Bundle; import android.support.v7.widget.Toolbar; import android.view.View; import com.kong.R; import com.kong.lib.BaseActivity; import com.kong.lib.utils.ResourceUtil;
package com.kong.app.news.base; /** * Created by CaoPengfei on 17/7/17. */ public abstract class ToolBarActivity extends BaseActivity { private Toolbar mToolbar; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(getLayoutId()); mToolbar = (Toolbar) findViewById(R.id.base_toolbar); initToolBar(mToolbar); } protected abstract int getLayoutId(); @Override public void setTitle(CharSequence title) { if (mToolbar != null) { mToolbar.setTitle(title); } } @Override public void setTitle(int titleId) { if (mToolbar != null) {
// Path: app/src/main/java/com/kong/lib/BaseActivity.java // public class BaseActivity extends AppCompatActivity { // // private static final String TAG = "BaseActivity"; // // @Override // protected void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // EventBus.getDefault().register(this); // } // // @Override // protected void onDestroy() { // super.onDestroy(); // EventBus.getDefault().unregister(this); // } // // @Subscribe(threadMode = ThreadMode.MAIN) // public void onMessageEvent(AppExitEvent event) { // Log.i(TAG, "onMessageEvent:" + event); // finish(); // } // // @Override // public boolean dispatchKeyEvent(KeyEvent event) { // if (event.getAction() != KeyEvent.ACTION_UP) { // return super.dispatchKeyEvent(event); // } // return super.dispatchKeyEvent(event); // } // // } // // Path: app/src/main/java/com/kong/lib/utils/ResourceUtil.java // public class ResourceUtil { // // public static String getString(int resId) { // return getResources().getString(resId); // } // // public static int getColor(int resId) { // return getResources().getColor(resId); // } // // public static Drawable getDrawable(int resId) { // return getResources().getDrawable(resId); // } // // public static int getDimen(int dimen) { // return (int) getResources().getDimension(dimen); // } // // public static Resources getResources() { // return getContext().getResources(); // } // // public static Context getContext() { // return AppRun.get().getApplicationContext(); // } // // public static String getRawFileStr(int rawId) throws IOException { // InputStream is = getResources().openRawResource(rawId); // BufferedReader reader = new BufferedReader(new InputStreamReader(is, "UTF-8")); // StringBuilder sb = new StringBuilder(); // String line; // while ((line = reader.readLine()) != null) { // sb.append(line).append("\n"); // } // sb.deleteCharAt(sb.length() - 1); // reader.close(); // return sb.toString(); // } // } // Path: app/src/main/java/com/kong/app/news/base/ToolBarActivity.java import android.os.Bundle; import android.support.v7.widget.Toolbar; import android.view.View; import com.kong.R; import com.kong.lib.BaseActivity; import com.kong.lib.utils.ResourceUtil; package com.kong.app.news.base; /** * Created by CaoPengfei on 17/7/17. */ public abstract class ToolBarActivity extends BaseActivity { private Toolbar mToolbar; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(getLayoutId()); mToolbar = (Toolbar) findViewById(R.id.base_toolbar); initToolBar(mToolbar); } protected abstract int getLayoutId(); @Override public void setTitle(CharSequence title) { if (mToolbar != null) { mToolbar.setTitle(title); } } @Override public void setTitle(int titleId) { if (mToolbar != null) {
mToolbar.setTitle(ResourceUtil.getString(titleId));
whiskeyfei/SimpleNews.io
app/src/main/java/com/kong/app/gank/GankFragment.java
// Path: app/src/main/java/com/kong/app/me/ToolBarFragment.java // public abstract class ToolBarFragment extends BaseFragment { // // private Toolbar mToolbar; // private TextView mTitle; // // @Override // public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // View view = inflater.inflate(getLayoutId(), null); // mToolbar = (Toolbar) view.findViewById(R.id.base_toolbar); // mTitle = (TextView) view.findViewById(R.id.base_toolbar_title); // mToolbar.setTitle(""); // return createView(view, container, savedInstanceState); // } // // public void setTitle(CharSequence title) { // if (mTitle != null) { // mTitle.setText(title); // } // } // // public void setTitle(int titleId) { // if (mTitle != null) { // mTitle.setText(ResourceUtil.getString(titleId)); // } // } // // public TextView getTitle() { // return mTitle; // } // // public Toolbar getToolbar() { // return mToolbar; // } // // protected abstract int getLayoutId(); // // public abstract View createView(View view, ViewGroup container, Bundle savedInstanceState); // } // // Path: app/src/main/java/com/kong/lib/utils/ResourceUtil.java // public class ResourceUtil { // // public static String getString(int resId) { // return getResources().getString(resId); // } // // public static int getColor(int resId) { // return getResources().getColor(resId); // } // // public static Drawable getDrawable(int resId) { // return getResources().getDrawable(resId); // } // // public static int getDimen(int dimen) { // return (int) getResources().getDimension(dimen); // } // // public static Resources getResources() { // return getContext().getResources(); // } // // public static Context getContext() { // return AppRun.get().getApplicationContext(); // } // // public static String getRawFileStr(int rawId) throws IOException { // InputStream is = getResources().openRawResource(rawId); // BufferedReader reader = new BufferedReader(new InputStreamReader(is, "UTF-8")); // StringBuilder sb = new StringBuilder(); // String line; // while ((line = reader.readLine()) != null) { // sb.append(line).append("\n"); // } // sb.deleteCharAt(sb.length() - 1); // reader.close(); // return sb.toString(); // } // }
import android.os.Bundle; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; import android.view.View; import android.view.ViewGroup; import android.view.ViewStub; import android.widget.TextView; import com.kong.R; import com.kong.app.me.ToolBarFragment; import com.kong.lib.utils.ResourceUtil; import java.util.List;
return fragment; } @Override protected int getLayoutId() { return R.layout.activity_gank; } @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mGankAdapter = new GankAdapter(); mGangPresenter = new GangPresenter(new GankModel(),this); parseArguments(); } private void parseArguments() { Bundle bundle = getArguments(); mYear = bundle.getInt(ARG_YEAR); mMonth = bundle.getInt(ARG_MONTH); mDay = bundle.getInt(ARG_DAY); } @Override public View createView(View view, ViewGroup container, Bundle savedInstanceState) { mRecyclerView = (RecyclerView) view.findViewById(R.id.me_recycle_view); mErrorStup = (ViewStub) view.findViewById(R.id.stub_error_view); mTitle = (TextView) view.findViewById(R.id.base_toolbar_title); mRecyclerView = (RecyclerView) view.findViewById(R.id.me_recycle_view);
// Path: app/src/main/java/com/kong/app/me/ToolBarFragment.java // public abstract class ToolBarFragment extends BaseFragment { // // private Toolbar mToolbar; // private TextView mTitle; // // @Override // public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // View view = inflater.inflate(getLayoutId(), null); // mToolbar = (Toolbar) view.findViewById(R.id.base_toolbar); // mTitle = (TextView) view.findViewById(R.id.base_toolbar_title); // mToolbar.setTitle(""); // return createView(view, container, savedInstanceState); // } // // public void setTitle(CharSequence title) { // if (mTitle != null) { // mTitle.setText(title); // } // } // // public void setTitle(int titleId) { // if (mTitle != null) { // mTitle.setText(ResourceUtil.getString(titleId)); // } // } // // public TextView getTitle() { // return mTitle; // } // // public Toolbar getToolbar() { // return mToolbar; // } // // protected abstract int getLayoutId(); // // public abstract View createView(View view, ViewGroup container, Bundle savedInstanceState); // } // // Path: app/src/main/java/com/kong/lib/utils/ResourceUtil.java // public class ResourceUtil { // // public static String getString(int resId) { // return getResources().getString(resId); // } // // public static int getColor(int resId) { // return getResources().getColor(resId); // } // // public static Drawable getDrawable(int resId) { // return getResources().getDrawable(resId); // } // // public static int getDimen(int dimen) { // return (int) getResources().getDimension(dimen); // } // // public static Resources getResources() { // return getContext().getResources(); // } // // public static Context getContext() { // return AppRun.get().getApplicationContext(); // } // // public static String getRawFileStr(int rawId) throws IOException { // InputStream is = getResources().openRawResource(rawId); // BufferedReader reader = new BufferedReader(new InputStreamReader(is, "UTF-8")); // StringBuilder sb = new StringBuilder(); // String line; // while ((line = reader.readLine()) != null) { // sb.append(line).append("\n"); // } // sb.deleteCharAt(sb.length() - 1); // reader.close(); // return sb.toString(); // } // } // Path: app/src/main/java/com/kong/app/gank/GankFragment.java import android.os.Bundle; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; import android.view.View; import android.view.ViewGroup; import android.view.ViewStub; import android.widget.TextView; import com.kong.R; import com.kong.app.me.ToolBarFragment; import com.kong.lib.utils.ResourceUtil; import java.util.List; return fragment; } @Override protected int getLayoutId() { return R.layout.activity_gank; } @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mGankAdapter = new GankAdapter(); mGangPresenter = new GangPresenter(new GankModel(),this); parseArguments(); } private void parseArguments() { Bundle bundle = getArguments(); mYear = bundle.getInt(ARG_YEAR); mMonth = bundle.getInt(ARG_MONTH); mDay = bundle.getInt(ARG_DAY); } @Override public View createView(View view, ViewGroup container, Bundle savedInstanceState) { mRecyclerView = (RecyclerView) view.findViewById(R.id.me_recycle_view); mErrorStup = (ViewStub) view.findViewById(R.id.stub_error_view); mTitle = (TextView) view.findViewById(R.id.base_toolbar_title); mRecyclerView = (RecyclerView) view.findViewById(R.id.me_recycle_view);
mTitle.setText(ResourceUtil.getString(R.string.tab_rec));
whiskeyfei/SimpleNews.io
app/src/main/java/com/kong/app/news/list/NewsContract.java
// Path: app/src/main/java/com/kong/app/news/beans/NewModel.java // public class NewModel implements Serializable { // // @SerializedName("ctime") // public String time; // // @SerializedName("title") // public String title; // // @SerializedName("description") // public String digest; // // @SerializedName("picUrl") // public String imageUrl; // // @SerializedName("url") // public String newUrl; // // @Override // public String toString() { // return "NewModel{" + // "time='" + time + '\'' + // ", title='" + title + '\'' + // ", digest='" + digest + '\'' + // ", imageUrl='" + imageUrl + '\'' + // ", newUrl='" + newUrl + // '}'+ '\n'; // } // } // // Path: app/src/main/java/com/kong/lib/mvp/BaseSubPresenter.java // public interface BaseSubPresenter extends BasePresenter{ // // void subscribe(); // // void unsubscribe(); // // } // // Path: app/src/main/java/com/kong/lib/mvp/BaseView.java // public interface BaseView<T> { // // void setPresenter(T presenter); // // }
import com.kong.app.news.beans.NewModel; import com.kong.lib.mvp.BaseSubPresenter; import com.kong.lib.mvp.BaseView; import java.util.List;
package com.kong.app.news.list; /** * Created by whiskeyfei on 16/11/6. */ public interface NewsContract { interface View extends BaseView<Presenter> { void showProgress();
// Path: app/src/main/java/com/kong/app/news/beans/NewModel.java // public class NewModel implements Serializable { // // @SerializedName("ctime") // public String time; // // @SerializedName("title") // public String title; // // @SerializedName("description") // public String digest; // // @SerializedName("picUrl") // public String imageUrl; // // @SerializedName("url") // public String newUrl; // // @Override // public String toString() { // return "NewModel{" + // "time='" + time + '\'' + // ", title='" + title + '\'' + // ", digest='" + digest + '\'' + // ", imageUrl='" + imageUrl + '\'' + // ", newUrl='" + newUrl + // '}'+ '\n'; // } // } // // Path: app/src/main/java/com/kong/lib/mvp/BaseSubPresenter.java // public interface BaseSubPresenter extends BasePresenter{ // // void subscribe(); // // void unsubscribe(); // // } // // Path: app/src/main/java/com/kong/lib/mvp/BaseView.java // public interface BaseView<T> { // // void setPresenter(T presenter); // // } // Path: app/src/main/java/com/kong/app/news/list/NewsContract.java import com.kong.app.news.beans.NewModel; import com.kong.lib.mvp.BaseSubPresenter; import com.kong.lib.mvp.BaseView; import java.util.List; package com.kong.app.news.list; /** * Created by whiskeyfei on 16/11/6. */ public interface NewsContract { interface View extends BaseView<Presenter> { void showProgress();
void addNews(List<NewModel> newsList);
whiskeyfei/SimpleNews.io
app/src/main/java/com/kong/app/news/list/NewsContract.java
// Path: app/src/main/java/com/kong/app/news/beans/NewModel.java // public class NewModel implements Serializable { // // @SerializedName("ctime") // public String time; // // @SerializedName("title") // public String title; // // @SerializedName("description") // public String digest; // // @SerializedName("picUrl") // public String imageUrl; // // @SerializedName("url") // public String newUrl; // // @Override // public String toString() { // return "NewModel{" + // "time='" + time + '\'' + // ", title='" + title + '\'' + // ", digest='" + digest + '\'' + // ", imageUrl='" + imageUrl + '\'' + // ", newUrl='" + newUrl + // '}'+ '\n'; // } // } // // Path: app/src/main/java/com/kong/lib/mvp/BaseSubPresenter.java // public interface BaseSubPresenter extends BasePresenter{ // // void subscribe(); // // void unsubscribe(); // // } // // Path: app/src/main/java/com/kong/lib/mvp/BaseView.java // public interface BaseView<T> { // // void setPresenter(T presenter); // // }
import com.kong.app.news.beans.NewModel; import com.kong.lib.mvp.BaseSubPresenter; import com.kong.lib.mvp.BaseView; import java.util.List;
package com.kong.app.news.list; /** * Created by whiskeyfei on 16/11/6. */ public interface NewsContract { interface View extends BaseView<Presenter> { void showProgress(); void addNews(List<NewModel> newsList); void hideProgress(); void showLoadFailMsg(); void setEnd(boolean isEnd); }
// Path: app/src/main/java/com/kong/app/news/beans/NewModel.java // public class NewModel implements Serializable { // // @SerializedName("ctime") // public String time; // // @SerializedName("title") // public String title; // // @SerializedName("description") // public String digest; // // @SerializedName("picUrl") // public String imageUrl; // // @SerializedName("url") // public String newUrl; // // @Override // public String toString() { // return "NewModel{" + // "time='" + time + '\'' + // ", title='" + title + '\'' + // ", digest='" + digest + '\'' + // ", imageUrl='" + imageUrl + '\'' + // ", newUrl='" + newUrl + // '}'+ '\n'; // } // } // // Path: app/src/main/java/com/kong/lib/mvp/BaseSubPresenter.java // public interface BaseSubPresenter extends BasePresenter{ // // void subscribe(); // // void unsubscribe(); // // } // // Path: app/src/main/java/com/kong/lib/mvp/BaseView.java // public interface BaseView<T> { // // void setPresenter(T presenter); // // } // Path: app/src/main/java/com/kong/app/news/list/NewsContract.java import com.kong.app.news.beans.NewModel; import com.kong.lib.mvp.BaseSubPresenter; import com.kong.lib.mvp.BaseView; import java.util.List; package com.kong.app.news.list; /** * Created by whiskeyfei on 16/11/6. */ public interface NewsContract { interface View extends BaseView<Presenter> { void showProgress(); void addNews(List<NewModel> newsList); void hideProgress(); void showLoadFailMsg(); void setEnd(boolean isEnd); }
interface Presenter extends BaseSubPresenter {
whiskeyfei/SimpleNews.io
app/src/main/java/com/kong/app/gank/GankContract.java
// Path: app/src/main/java/com/kong/lib/mvp/IModel.java // public interface IModel { // // }
import com.kong.lib.mvp.IModel; import java.util.List; import rx.Observable;
package com.kong.app.gank; /** * Created by whiskeyfei on 16/11/6. */ interface GankContract { interface View { void showReslut(List<Gank> gankList); void showError(); }
// Path: app/src/main/java/com/kong/lib/mvp/IModel.java // public interface IModel { // // } // Path: app/src/main/java/com/kong/app/gank/GankContract.java import com.kong.lib.mvp.IModel; import java.util.List; import rx.Observable; package com.kong.app.gank; /** * Created by whiskeyfei on 16/11/6. */ interface GankContract { interface View { void showReslut(List<Gank> gankList); void showError(); }
interface Model extends IModel {
whiskeyfei/SimpleNews.io
app/src/main/java/com/kong/app/news/ui/AboutActivity.java
// Path: app/src/main/java/com/kong/app/news/NewsEntry.java // public class NewsEntry implements INewsEntry { // // private static class NewsEntryHelper { // private static NewsEntry sIns = new NewsEntry(); // } // // public static INewsEntry get() { // return NewsEntryHelper.sIns; // } // // @Override // public void startCommon(Context context, Class<?> cls) { // Intent intent = new Intent(context, cls); // ActivityUtils.startActivity(context,intent); // } // // @Override // public void startAbout(Context context) { // Intent intent = new Intent(context, AboutActivity.class); // ActivityUtils.startActivity(context,intent); // } // // // @Override // // public void startDemo(Context context) { // // Intent intent = new Intent(context, DemoActivity.class); // // ActivityUtils.startActivity(context,intent); // // } // // @Override // public void startSetting(Context context) { // Intent intent = new Intent(context, SettingActivity.class); // ActivityUtils.startActivity(context,intent); // } // // // @Override // // public void startNote(Context context) { // // Intent intent = new Intent(context, NoteActivity.class); // // ActivityUtils.startActivity(context,intent); // // } // // // @Override // // public void startNote(Context context, Intent intent) { // // ActivityUtils.startActivity(context,intent); // // } // // @Override // public void startMain(Context context) { // Intent intent = new Intent(context, HomeActivity.class); // ActivityUtils.startActivity(context,intent); // } // // @Override // public void startBrowser(Context context, String url) { // Intent intent = new Intent(context, BrowserActivity.class); // intent.putExtra(BrowserActivity.BWO_KEY,url); // ActivityUtils.startActivity(context,intent); // } // // @Override // public void startBrowser(Context context, String url, String title) { // Intent intent = new Intent(context, BrowserActivity.class); // intent.putExtra(BrowserActivity.BWO_KEY,url); // intent.putExtra(BrowserActivity.BWO_TITLE,title); // ActivityUtils.startActivity(context,intent); // } // // @Override // public void startDetailActivity(Context context, NewModel news) { // Intent intent = new Intent(context, NewsDetailActivity.class); // intent.putExtra(NewsDetailActivity.TITLE,news.title); // intent.putExtra(NewsDetailActivity.URL,news.newUrl); // ActivityUtils.startActivity(context, intent); // } // } // // Path: app/src/main/java/com/kong/app/news/base/ToolBarActivity.java // public abstract class ToolBarActivity extends BaseActivity { // // private Toolbar mToolbar; // // @Override // protected void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // setContentView(getLayoutId()); // mToolbar = (Toolbar) findViewById(R.id.base_toolbar); // initToolBar(mToolbar); // } // // protected abstract int getLayoutId(); // // @Override // public void setTitle(CharSequence title) { // if (mToolbar != null) { // mToolbar.setTitle(title); // } // } // // @Override // public void setTitle(int titleId) { // if (mToolbar != null) { // mToolbar.setTitle(ResourceUtil.getString(titleId)); // } // } // // public Toolbar getToolbar() { // return mToolbar; // } // // public void initToolBar(Toolbar toolbar) { // if (null != toolbar) { // setSupportActionBar(toolbar); // getSupportActionBar().setDisplayShowHomeEnabled(false); // getSupportActionBar().setDisplayHomeAsUpEnabled(true); // toolbar.setNavigationOnClickListener(new View.OnClickListener() { // @Override // public void onClick(View view) { // onBackPressed(); // } // }); // } // } // // public void initToolBar(Toolbar toolbar, String title) { // toolbar.setTitle(title); // initToolBar(toolbar); // } // // } // // Path: app/src/main/java/com/kong/lib/utils/ResourceUtil.java // public class ResourceUtil { // // public static String getString(int resId) { // return getResources().getString(resId); // } // // public static int getColor(int resId) { // return getResources().getColor(resId); // } // // public static Drawable getDrawable(int resId) { // return getResources().getDrawable(resId); // } // // public static int getDimen(int dimen) { // return (int) getResources().getDimension(dimen); // } // // public static Resources getResources() { // return getContext().getResources(); // } // // public static Context getContext() { // return AppRun.get().getApplicationContext(); // } // // public static String getRawFileStr(int rawId) throws IOException { // InputStream is = getResources().openRawResource(rawId); // BufferedReader reader = new BufferedReader(new InputStreamReader(is, "UTF-8")); // StringBuilder sb = new StringBuilder(); // String line; // while ((line = reader.readLine()) != null) { // sb.append(line).append("\n"); // } // sb.deleteCharAt(sb.length() - 1); // reader.close(); // return sb.toString(); // } // }
import android.os.Bundle; import android.view.View; import com.kong.R; import com.kong.app.news.NewsEntry; import com.kong.app.news.base.ToolBarActivity; import com.kong.lib.utils.ResourceUtil;
package com.kong.app.news.ui; /** * Created by CaoPengfei on 17/5/26. * <p> * https://stackoverflow.com/questions/26651602/display-back-arrow-on-toolbar-android */ public class AboutActivity extends ToolBarActivity implements View.OnClickListener { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);
// Path: app/src/main/java/com/kong/app/news/NewsEntry.java // public class NewsEntry implements INewsEntry { // // private static class NewsEntryHelper { // private static NewsEntry sIns = new NewsEntry(); // } // // public static INewsEntry get() { // return NewsEntryHelper.sIns; // } // // @Override // public void startCommon(Context context, Class<?> cls) { // Intent intent = new Intent(context, cls); // ActivityUtils.startActivity(context,intent); // } // // @Override // public void startAbout(Context context) { // Intent intent = new Intent(context, AboutActivity.class); // ActivityUtils.startActivity(context,intent); // } // // // @Override // // public void startDemo(Context context) { // // Intent intent = new Intent(context, DemoActivity.class); // // ActivityUtils.startActivity(context,intent); // // } // // @Override // public void startSetting(Context context) { // Intent intent = new Intent(context, SettingActivity.class); // ActivityUtils.startActivity(context,intent); // } // // // @Override // // public void startNote(Context context) { // // Intent intent = new Intent(context, NoteActivity.class); // // ActivityUtils.startActivity(context,intent); // // } // // // @Override // // public void startNote(Context context, Intent intent) { // // ActivityUtils.startActivity(context,intent); // // } // // @Override // public void startMain(Context context) { // Intent intent = new Intent(context, HomeActivity.class); // ActivityUtils.startActivity(context,intent); // } // // @Override // public void startBrowser(Context context, String url) { // Intent intent = new Intent(context, BrowserActivity.class); // intent.putExtra(BrowserActivity.BWO_KEY,url); // ActivityUtils.startActivity(context,intent); // } // // @Override // public void startBrowser(Context context, String url, String title) { // Intent intent = new Intent(context, BrowserActivity.class); // intent.putExtra(BrowserActivity.BWO_KEY,url); // intent.putExtra(BrowserActivity.BWO_TITLE,title); // ActivityUtils.startActivity(context,intent); // } // // @Override // public void startDetailActivity(Context context, NewModel news) { // Intent intent = new Intent(context, NewsDetailActivity.class); // intent.putExtra(NewsDetailActivity.TITLE,news.title); // intent.putExtra(NewsDetailActivity.URL,news.newUrl); // ActivityUtils.startActivity(context, intent); // } // } // // Path: app/src/main/java/com/kong/app/news/base/ToolBarActivity.java // public abstract class ToolBarActivity extends BaseActivity { // // private Toolbar mToolbar; // // @Override // protected void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // setContentView(getLayoutId()); // mToolbar = (Toolbar) findViewById(R.id.base_toolbar); // initToolBar(mToolbar); // } // // protected abstract int getLayoutId(); // // @Override // public void setTitle(CharSequence title) { // if (mToolbar != null) { // mToolbar.setTitle(title); // } // } // // @Override // public void setTitle(int titleId) { // if (mToolbar != null) { // mToolbar.setTitle(ResourceUtil.getString(titleId)); // } // } // // public Toolbar getToolbar() { // return mToolbar; // } // // public void initToolBar(Toolbar toolbar) { // if (null != toolbar) { // setSupportActionBar(toolbar); // getSupportActionBar().setDisplayShowHomeEnabled(false); // getSupportActionBar().setDisplayHomeAsUpEnabled(true); // toolbar.setNavigationOnClickListener(new View.OnClickListener() { // @Override // public void onClick(View view) { // onBackPressed(); // } // }); // } // } // // public void initToolBar(Toolbar toolbar, String title) { // toolbar.setTitle(title); // initToolBar(toolbar); // } // // } // // Path: app/src/main/java/com/kong/lib/utils/ResourceUtil.java // public class ResourceUtil { // // public static String getString(int resId) { // return getResources().getString(resId); // } // // public static int getColor(int resId) { // return getResources().getColor(resId); // } // // public static Drawable getDrawable(int resId) { // return getResources().getDrawable(resId); // } // // public static int getDimen(int dimen) { // return (int) getResources().getDimension(dimen); // } // // public static Resources getResources() { // return getContext().getResources(); // } // // public static Context getContext() { // return AppRun.get().getApplicationContext(); // } // // public static String getRawFileStr(int rawId) throws IOException { // InputStream is = getResources().openRawResource(rawId); // BufferedReader reader = new BufferedReader(new InputStreamReader(is, "UTF-8")); // StringBuilder sb = new StringBuilder(); // String line; // while ((line = reader.readLine()) != null) { // sb.append(line).append("\n"); // } // sb.deleteCharAt(sb.length() - 1); // reader.close(); // return sb.toString(); // } // } // Path: app/src/main/java/com/kong/app/news/ui/AboutActivity.java import android.os.Bundle; import android.view.View; import com.kong.R; import com.kong.app.news.NewsEntry; import com.kong.app.news.base.ToolBarActivity; import com.kong.lib.utils.ResourceUtil; package com.kong.app.news.ui; /** * Created by CaoPengfei on 17/5/26. * <p> * https://stackoverflow.com/questions/26651602/display-back-arrow-on-toolbar-android */ public class AboutActivity extends ToolBarActivity implements View.OnClickListener { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);
setTitle(ResourceUtil.getString(R.string.about));
whiskeyfei/SimpleNews.io
app/src/main/java/com/kong/app/me/ToolBarFragment.java
// Path: app/src/main/java/com/kong/lib/fragment/BaseFragment.java // public class BaseFragment extends Fragment { // // } // // Path: app/src/main/java/com/kong/lib/utils/ResourceUtil.java // public class ResourceUtil { // // public static String getString(int resId) { // return getResources().getString(resId); // } // // public static int getColor(int resId) { // return getResources().getColor(resId); // } // // public static Drawable getDrawable(int resId) { // return getResources().getDrawable(resId); // } // // public static int getDimen(int dimen) { // return (int) getResources().getDimension(dimen); // } // // public static Resources getResources() { // return getContext().getResources(); // } // // public static Context getContext() { // return AppRun.get().getApplicationContext(); // } // // public static String getRawFileStr(int rawId) throws IOException { // InputStream is = getResources().openRawResource(rawId); // BufferedReader reader = new BufferedReader(new InputStreamReader(is, "UTF-8")); // StringBuilder sb = new StringBuilder(); // String line; // while ((line = reader.readLine()) != null) { // sb.append(line).append("\n"); // } // sb.deleteCharAt(sb.length() - 1); // reader.close(); // return sb.toString(); // } // }
import android.os.Bundle; import android.support.v7.widget.Toolbar; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; import com.kong.R; import com.kong.lib.fragment.BaseFragment; import com.kong.lib.utils.ResourceUtil;
package com.kong.app.me; /** * Created by CaoPengfei on 17/7/28. */ public abstract class ToolBarFragment extends BaseFragment { private Toolbar mToolbar; private TextView mTitle; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(getLayoutId(), null); mToolbar = (Toolbar) view.findViewById(R.id.base_toolbar); mTitle = (TextView) view.findViewById(R.id.base_toolbar_title); mToolbar.setTitle(""); return createView(view, container, savedInstanceState); } public void setTitle(CharSequence title) { if (mTitle != null) { mTitle.setText(title); } } public void setTitle(int titleId) { if (mTitle != null) {
// Path: app/src/main/java/com/kong/lib/fragment/BaseFragment.java // public class BaseFragment extends Fragment { // // } // // Path: app/src/main/java/com/kong/lib/utils/ResourceUtil.java // public class ResourceUtil { // // public static String getString(int resId) { // return getResources().getString(resId); // } // // public static int getColor(int resId) { // return getResources().getColor(resId); // } // // public static Drawable getDrawable(int resId) { // return getResources().getDrawable(resId); // } // // public static int getDimen(int dimen) { // return (int) getResources().getDimension(dimen); // } // // public static Resources getResources() { // return getContext().getResources(); // } // // public static Context getContext() { // return AppRun.get().getApplicationContext(); // } // // public static String getRawFileStr(int rawId) throws IOException { // InputStream is = getResources().openRawResource(rawId); // BufferedReader reader = new BufferedReader(new InputStreamReader(is, "UTF-8")); // StringBuilder sb = new StringBuilder(); // String line; // while ((line = reader.readLine()) != null) { // sb.append(line).append("\n"); // } // sb.deleteCharAt(sb.length() - 1); // reader.close(); // return sb.toString(); // } // } // Path: app/src/main/java/com/kong/app/me/ToolBarFragment.java import android.os.Bundle; import android.support.v7.widget.Toolbar; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; import com.kong.R; import com.kong.lib.fragment.BaseFragment; import com.kong.lib.utils.ResourceUtil; package com.kong.app.me; /** * Created by CaoPengfei on 17/7/28. */ public abstract class ToolBarFragment extends BaseFragment { private Toolbar mToolbar; private TextView mTitle; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(getLayoutId(), null); mToolbar = (Toolbar) view.findViewById(R.id.base_toolbar); mTitle = (TextView) view.findViewById(R.id.base_toolbar_title); mToolbar.setTitle(""); return createView(view, container, savedInstanceState); } public void setTitle(CharSequence title) { if (mTitle != null) { mTitle.setText(title); } } public void setTitle(int titleId) { if (mTitle != null) {
mTitle.setText(ResourceUtil.getString(titleId));
whiskeyfei/SimpleNews.io
app/src/main/java/com/kong/home/StartActivity.java
// Path: app/src/main/java/com/kong/app/news/NewsEntry.java // public class NewsEntry implements INewsEntry { // // private static class NewsEntryHelper { // private static NewsEntry sIns = new NewsEntry(); // } // // public static INewsEntry get() { // return NewsEntryHelper.sIns; // } // // @Override // public void startCommon(Context context, Class<?> cls) { // Intent intent = new Intent(context, cls); // ActivityUtils.startActivity(context,intent); // } // // @Override // public void startAbout(Context context) { // Intent intent = new Intent(context, AboutActivity.class); // ActivityUtils.startActivity(context,intent); // } // // // @Override // // public void startDemo(Context context) { // // Intent intent = new Intent(context, DemoActivity.class); // // ActivityUtils.startActivity(context,intent); // // } // // @Override // public void startSetting(Context context) { // Intent intent = new Intent(context, SettingActivity.class); // ActivityUtils.startActivity(context,intent); // } // // // @Override // // public void startNote(Context context) { // // Intent intent = new Intent(context, NoteActivity.class); // // ActivityUtils.startActivity(context,intent); // // } // // // @Override // // public void startNote(Context context, Intent intent) { // // ActivityUtils.startActivity(context,intent); // // } // // @Override // public void startMain(Context context) { // Intent intent = new Intent(context, HomeActivity.class); // ActivityUtils.startActivity(context,intent); // } // // @Override // public void startBrowser(Context context, String url) { // Intent intent = new Intent(context, BrowserActivity.class); // intent.putExtra(BrowserActivity.BWO_KEY,url); // ActivityUtils.startActivity(context,intent); // } // // @Override // public void startBrowser(Context context, String url, String title) { // Intent intent = new Intent(context, BrowserActivity.class); // intent.putExtra(BrowserActivity.BWO_KEY,url); // intent.putExtra(BrowserActivity.BWO_TITLE,title); // ActivityUtils.startActivity(context,intent); // } // // @Override // public void startDetailActivity(Context context, NewModel news) { // Intent intent = new Intent(context, NewsDetailActivity.class); // intent.putExtra(NewsDetailActivity.TITLE,news.title); // intent.putExtra(NewsDetailActivity.URL,news.newUrl); // ActivityUtils.startActivity(context, intent); // } // }
import android.app.Activity; import android.os.Bundle; import android.os.Handler; import android.os.Looper; import android.os.Message; import android.view.KeyEvent; import com.kong.R; import com.kong.app.news.NewsEntry;
package com.kong.home; public class StartActivity extends Activity { private final Handler mHandler = new Handler(Looper.myLooper()) { @Override public void handleMessage(Message msg) { super.handleMessage(msg);
// Path: app/src/main/java/com/kong/app/news/NewsEntry.java // public class NewsEntry implements INewsEntry { // // private static class NewsEntryHelper { // private static NewsEntry sIns = new NewsEntry(); // } // // public static INewsEntry get() { // return NewsEntryHelper.sIns; // } // // @Override // public void startCommon(Context context, Class<?> cls) { // Intent intent = new Intent(context, cls); // ActivityUtils.startActivity(context,intent); // } // // @Override // public void startAbout(Context context) { // Intent intent = new Intent(context, AboutActivity.class); // ActivityUtils.startActivity(context,intent); // } // // // @Override // // public void startDemo(Context context) { // // Intent intent = new Intent(context, DemoActivity.class); // // ActivityUtils.startActivity(context,intent); // // } // // @Override // public void startSetting(Context context) { // Intent intent = new Intent(context, SettingActivity.class); // ActivityUtils.startActivity(context,intent); // } // // // @Override // // public void startNote(Context context) { // // Intent intent = new Intent(context, NoteActivity.class); // // ActivityUtils.startActivity(context,intent); // // } // // // @Override // // public void startNote(Context context, Intent intent) { // // ActivityUtils.startActivity(context,intent); // // } // // @Override // public void startMain(Context context) { // Intent intent = new Intent(context, HomeActivity.class); // ActivityUtils.startActivity(context,intent); // } // // @Override // public void startBrowser(Context context, String url) { // Intent intent = new Intent(context, BrowserActivity.class); // intent.putExtra(BrowserActivity.BWO_KEY,url); // ActivityUtils.startActivity(context,intent); // } // // @Override // public void startBrowser(Context context, String url, String title) { // Intent intent = new Intent(context, BrowserActivity.class); // intent.putExtra(BrowserActivity.BWO_KEY,url); // intent.putExtra(BrowserActivity.BWO_TITLE,title); // ActivityUtils.startActivity(context,intent); // } // // @Override // public void startDetailActivity(Context context, NewModel news) { // Intent intent = new Intent(context, NewsDetailActivity.class); // intent.putExtra(NewsDetailActivity.TITLE,news.title); // intent.putExtra(NewsDetailActivity.URL,news.newUrl); // ActivityUtils.startActivity(context, intent); // } // } // Path: app/src/main/java/com/kong/home/StartActivity.java import android.app.Activity; import android.os.Bundle; import android.os.Handler; import android.os.Looper; import android.os.Message; import android.view.KeyEvent; import com.kong.R; import com.kong.app.news.NewsEntry; package com.kong.home; public class StartActivity extends Activity { private final Handler mHandler = new Handler(Looper.myLooper()) { @Override public void handleMessage(Message msg) { super.handleMessage(msg);
NewsEntry.get().startMain(StartActivity.this);
whiskeyfei/SimpleNews.io
app/src/main/java/com/kong/app/news/INewsEntry.java
// Path: app/src/main/java/com/kong/app/news/beans/NewModel.java // public class NewModel implements Serializable { // // @SerializedName("ctime") // public String time; // // @SerializedName("title") // public String title; // // @SerializedName("description") // public String digest; // // @SerializedName("picUrl") // public String imageUrl; // // @SerializedName("url") // public String newUrl; // // @Override // public String toString() { // return "NewModel{" + // "time='" + time + '\'' + // ", title='" + title + '\'' + // ", digest='" + digest + '\'' + // ", imageUrl='" + imageUrl + '\'' + // ", newUrl='" + newUrl + // '}'+ '\n'; // } // }
import android.content.Context; import com.kong.app.news.beans.NewModel;
package com.kong.app.news; /** * Created by CaoPengfei on 17/6/2. */ public interface INewsEntry { void startCommon(Context context, Class<?> cls); void startAbout(Context context); // void startDemo(Context context); void startSetting(Context context); // void startNote(Context context); // void startNote(Context context, Intent intent); void startMain(Context context); void startBrowser(Context context, String url); void startBrowser(Context context, String url, String title);
// Path: app/src/main/java/com/kong/app/news/beans/NewModel.java // public class NewModel implements Serializable { // // @SerializedName("ctime") // public String time; // // @SerializedName("title") // public String title; // // @SerializedName("description") // public String digest; // // @SerializedName("picUrl") // public String imageUrl; // // @SerializedName("url") // public String newUrl; // // @Override // public String toString() { // return "NewModel{" + // "time='" + time + '\'' + // ", title='" + title + '\'' + // ", digest='" + digest + '\'' + // ", imageUrl='" + imageUrl + '\'' + // ", newUrl='" + newUrl + // '}'+ '\n'; // } // } // Path: app/src/main/java/com/kong/app/news/INewsEntry.java import android.content.Context; import com.kong.app.news.beans.NewModel; package com.kong.app.news; /** * Created by CaoPengfei on 17/6/2. */ public interface INewsEntry { void startCommon(Context context, Class<?> cls); void startAbout(Context context); // void startDemo(Context context); void startSetting(Context context); // void startNote(Context context); // void startNote(Context context, Intent intent); void startMain(Context context); void startBrowser(Context context, String url); void startBrowser(Context context, String url, String title);
void startDetailActivity(Context context, NewModel news);
aatarasoff/spring-thrift-starter
examples/simple-client/src/test/java/info/developerblog/examples/thirft/proxyclient/async/TAsyncGreetingServiceHandlerTests.java
// Path: examples/simple-client/src/main/java/info/developerblog/examples/thirft/simpleclient/AsyncGreetingService.java // @Service // public class AsyncGreetingService { // // @ThriftClient(serviceId = "greeting-service", path = "/api") // TGreetingService.Client client; // // @Async // public Future<String> getGreeting(String lastName, String firstName) throws TException { // return new AsyncResult<>(client.greet(new TName(firstName, lastName))); // } // } // // Path: examples/simple-client/src/main/java/info/developerblog/examples/thirft/simpleclient/SimpleClientApplication.java // @EnableAsync // @SpringBootApplication // public class SimpleClientApplication { // // public static void main(String[] args) { // SpringApplication.run(SimpleClientApplication.class, args); // } // // @ThriftClient(serviceId = "greeting-service", path = "/api") // TGreetingService.Client client; // }
import info.developerblog.examples.thirft.simpleclient.AsyncGreetingService; import info.developerblog.examples.thirft.simpleclient.SimpleClientApplication; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringRunner; import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
package info.developerblog.examples.thirft.proxyclient.async; @RunWith(SpringRunner.class) @SpringBootTest(classes = SimpleClientApplication.class, webEnvironment = RANDOM_PORT) public class TAsyncGreetingServiceHandlerTests { @Autowired
// Path: examples/simple-client/src/main/java/info/developerblog/examples/thirft/simpleclient/AsyncGreetingService.java // @Service // public class AsyncGreetingService { // // @ThriftClient(serviceId = "greeting-service", path = "/api") // TGreetingService.Client client; // // @Async // public Future<String> getGreeting(String lastName, String firstName) throws TException { // return new AsyncResult<>(client.greet(new TName(firstName, lastName))); // } // } // // Path: examples/simple-client/src/main/java/info/developerblog/examples/thirft/simpleclient/SimpleClientApplication.java // @EnableAsync // @SpringBootApplication // public class SimpleClientApplication { // // public static void main(String[] args) { // SpringApplication.run(SimpleClientApplication.class, args); // } // // @ThriftClient(serviceId = "greeting-service", path = "/api") // TGreetingService.Client client; // } // Path: examples/simple-client/src/test/java/info/developerblog/examples/thirft/proxyclient/async/TAsyncGreetingServiceHandlerTests.java import info.developerblog.examples.thirft.simpleclient.AsyncGreetingService; import info.developerblog.examples.thirft.simpleclient.SimpleClientApplication; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringRunner; import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT; package info.developerblog.examples.thirft.proxyclient.async; @RunWith(SpringRunner.class) @SpringBootTest(classes = SimpleClientApplication.class, webEnvironment = RANDOM_PORT) public class TAsyncGreetingServiceHandlerTests { @Autowired
private AsyncGreetingService asyncGreetingService;
aatarasoff/spring-thrift-starter
autoconfigure/src/main/java/info/developerblog/spring/thrift/client/ThriftClientBeanPostProcessorService.java
// Path: autoconfigure/src/main/java/info/developerblog/spring/thrift/client/pool/ThriftClientKey.java // @Builder // @EqualsAndHashCode // public class ThriftClientKey { // private Class<? extends TServiceClient> clazz; // private String serviceName; // private String path; // // public String getServiceName() { // if (StringUtils.isEmpty(serviceName)) // return WordUtils.uncapitalize(clazz.getEnclosingClass().getSimpleName()); // return serviceName; // } // // public Class<? extends TServiceClient> getClazz() { // return clazz; // } // // public String getPath() { // return path; // } // }
import info.developerblog.spring.thrift.annotation.ThriftClient; import info.developerblog.spring.thrift.client.pool.ThriftClientKey; import java.lang.reflect.Field; import java.lang.reflect.Parameter; import java.lang.reflect.UndeclaredThrowableException; import java.util.function.Consumer; import org.aopalliance.intercept.MethodInterceptor; import org.aopalliance.intercept.MethodInvocation; import org.apache.commons.pool2.KeyedObjectPool; import org.apache.thrift.TException; import org.apache.thrift.TServiceClient; import org.apache.thrift.protocol.TProtocol; import org.springframework.aop.framework.ProxyFactory; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.boot.autoconfigure.AutoConfigureAfter; import org.springframework.context.annotation.Configuration; import org.springframework.stereotype.Component; import org.springframework.util.ReflectionUtils;
package info.developerblog.spring.thrift.client; @Component @Configuration @AutoConfigureAfter(PoolConfiguration.class) public class ThriftClientBeanPostProcessorService { @Autowired private DefaultListableBeanFactory beanFactory; @Autowired
// Path: autoconfigure/src/main/java/info/developerblog/spring/thrift/client/pool/ThriftClientKey.java // @Builder // @EqualsAndHashCode // public class ThriftClientKey { // private Class<? extends TServiceClient> clazz; // private String serviceName; // private String path; // // public String getServiceName() { // if (StringUtils.isEmpty(serviceName)) // return WordUtils.uncapitalize(clazz.getEnclosingClass().getSimpleName()); // return serviceName; // } // // public Class<? extends TServiceClient> getClazz() { // return clazz; // } // // public String getPath() { // return path; // } // } // Path: autoconfigure/src/main/java/info/developerblog/spring/thrift/client/ThriftClientBeanPostProcessorService.java import info.developerblog.spring.thrift.annotation.ThriftClient; import info.developerblog.spring.thrift.client.pool.ThriftClientKey; import java.lang.reflect.Field; import java.lang.reflect.Parameter; import java.lang.reflect.UndeclaredThrowableException; import java.util.function.Consumer; import org.aopalliance.intercept.MethodInterceptor; import org.aopalliance.intercept.MethodInvocation; import org.apache.commons.pool2.KeyedObjectPool; import org.apache.thrift.TException; import org.apache.thrift.TServiceClient; import org.apache.thrift.protocol.TProtocol; import org.springframework.aop.framework.ProxyFactory; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.boot.autoconfigure.AutoConfigureAfter; import org.springframework.context.annotation.Configuration; import org.springframework.stereotype.Component; import org.springframework.util.ReflectionUtils; package info.developerblog.spring.thrift.client; @Component @Configuration @AutoConfigureAfter(PoolConfiguration.class) public class ThriftClientBeanPostProcessorService { @Autowired private DefaultListableBeanFactory beanFactory; @Autowired
private KeyedObjectPool<ThriftClientKey, TServiceClient> thriftClientsPool;
aatarasoff/spring-thrift-starter
examples/simple-client/src/test/java/info/developerblog/examples/thirft/poolfactory/PoolFactoryTests.java
// Path: examples/simple-client/src/main/java/info/developerblog/examples/thirft/simpleclient/SimpleClientApplication.java // @EnableAsync // @SpringBootApplication // public class SimpleClientApplication { // // public static void main(String[] args) { // SpringApplication.run(SimpleClientApplication.class, args); // } // // @ThriftClient(serviceId = "greeting-service", path = "/api") // TGreetingService.Client client; // } // // Path: autoconfigure/src/main/java/info/developerblog/spring/thrift/client/pool/ThriftClientKey.java // @Builder // @EqualsAndHashCode // public class ThriftClientKey { // private Class<? extends TServiceClient> clazz; // private String serviceName; // private String path; // // public String getServiceName() { // if (StringUtils.isEmpty(serviceName)) // return WordUtils.uncapitalize(clazz.getEnclosingClass().getSimpleName()); // return serviceName; // } // // public Class<? extends TServiceClient> getClazz() { // return clazz; // } // // public String getPath() { // return path; // } // } // // Path: autoconfigure/src/main/java/info/developerblog/spring/thrift/client/pool/ThriftClientPool.java // public class ThriftClientPool extends GenericKeyedObjectPool<ThriftClientKey, TServiceClient> { // public ThriftClientPool(KeyedPooledObjectFactory<ThriftClientKey, TServiceClient> factory, GenericKeyedObjectPoolConfig config) { // super(factory, config); // } // }
import example.TGreetingService; import info.developerblog.examples.thirft.simpleclient.SimpleClientApplication; import info.developerblog.spring.thrift.client.pool.ThriftClientKey; import info.developerblog.spring.thrift.client.pool.ThriftClientPool; import org.apache.commons.pool2.KeyedPooledObjectFactory; import org.apache.commons.pool2.PooledObject; import org.apache.thrift.TServiceClient; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import javax.annotation.PostConstruct; import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
package info.developerblog.examples.thirft.poolfactory; /** * @author Dmitry Zhikharev (jihor@ya.ru) * Created on 13.09.2016 */ @RunWith(SpringJUnit4ClassRunner.class) @SpringBootTest(classes = SimpleClientApplication.class, webEnvironment = RANDOM_PORT) public class PoolFactoryTests { @Autowired
// Path: examples/simple-client/src/main/java/info/developerblog/examples/thirft/simpleclient/SimpleClientApplication.java // @EnableAsync // @SpringBootApplication // public class SimpleClientApplication { // // public static void main(String[] args) { // SpringApplication.run(SimpleClientApplication.class, args); // } // // @ThriftClient(serviceId = "greeting-service", path = "/api") // TGreetingService.Client client; // } // // Path: autoconfigure/src/main/java/info/developerblog/spring/thrift/client/pool/ThriftClientKey.java // @Builder // @EqualsAndHashCode // public class ThriftClientKey { // private Class<? extends TServiceClient> clazz; // private String serviceName; // private String path; // // public String getServiceName() { // if (StringUtils.isEmpty(serviceName)) // return WordUtils.uncapitalize(clazz.getEnclosingClass().getSimpleName()); // return serviceName; // } // // public Class<? extends TServiceClient> getClazz() { // return clazz; // } // // public String getPath() { // return path; // } // } // // Path: autoconfigure/src/main/java/info/developerblog/spring/thrift/client/pool/ThriftClientPool.java // public class ThriftClientPool extends GenericKeyedObjectPool<ThriftClientKey, TServiceClient> { // public ThriftClientPool(KeyedPooledObjectFactory<ThriftClientKey, TServiceClient> factory, GenericKeyedObjectPoolConfig config) { // super(factory, config); // } // } // Path: examples/simple-client/src/test/java/info/developerblog/examples/thirft/poolfactory/PoolFactoryTests.java import example.TGreetingService; import info.developerblog.examples.thirft.simpleclient.SimpleClientApplication; import info.developerblog.spring.thrift.client.pool.ThriftClientKey; import info.developerblog.spring.thrift.client.pool.ThriftClientPool; import org.apache.commons.pool2.KeyedPooledObjectFactory; import org.apache.commons.pool2.PooledObject; import org.apache.thrift.TServiceClient; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import javax.annotation.PostConstruct; import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT; package info.developerblog.examples.thirft.poolfactory; /** * @author Dmitry Zhikharev (jihor@ya.ru) * Created on 13.09.2016 */ @RunWith(SpringJUnit4ClassRunner.class) @SpringBootTest(classes = SimpleClientApplication.class, webEnvironment = RANDOM_PORT) public class PoolFactoryTests { @Autowired
private ThriftClientPool thriftClientsPool;
aatarasoff/spring-thrift-starter
examples/simple-client/src/test/java/info/developerblog/examples/thirft/poolfactory/PoolFactoryTests.java
// Path: examples/simple-client/src/main/java/info/developerblog/examples/thirft/simpleclient/SimpleClientApplication.java // @EnableAsync // @SpringBootApplication // public class SimpleClientApplication { // // public static void main(String[] args) { // SpringApplication.run(SimpleClientApplication.class, args); // } // // @ThriftClient(serviceId = "greeting-service", path = "/api") // TGreetingService.Client client; // } // // Path: autoconfigure/src/main/java/info/developerblog/spring/thrift/client/pool/ThriftClientKey.java // @Builder // @EqualsAndHashCode // public class ThriftClientKey { // private Class<? extends TServiceClient> clazz; // private String serviceName; // private String path; // // public String getServiceName() { // if (StringUtils.isEmpty(serviceName)) // return WordUtils.uncapitalize(clazz.getEnclosingClass().getSimpleName()); // return serviceName; // } // // public Class<? extends TServiceClient> getClazz() { // return clazz; // } // // public String getPath() { // return path; // } // } // // Path: autoconfigure/src/main/java/info/developerblog/spring/thrift/client/pool/ThriftClientPool.java // public class ThriftClientPool extends GenericKeyedObjectPool<ThriftClientKey, TServiceClient> { // public ThriftClientPool(KeyedPooledObjectFactory<ThriftClientKey, TServiceClient> factory, GenericKeyedObjectPoolConfig config) { // super(factory, config); // } // }
import example.TGreetingService; import info.developerblog.examples.thirft.simpleclient.SimpleClientApplication; import info.developerblog.spring.thrift.client.pool.ThriftClientKey; import info.developerblog.spring.thrift.client.pool.ThriftClientPool; import org.apache.commons.pool2.KeyedPooledObjectFactory; import org.apache.commons.pool2.PooledObject; import org.apache.thrift.TServiceClient; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import javax.annotation.PostConstruct; import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
package info.developerblog.examples.thirft.poolfactory; /** * @author Dmitry Zhikharev (jihor@ya.ru) * Created on 13.09.2016 */ @RunWith(SpringJUnit4ClassRunner.class) @SpringBootTest(classes = SimpleClientApplication.class, webEnvironment = RANDOM_PORT) public class PoolFactoryTests { @Autowired private ThriftClientPool thriftClientsPool;
// Path: examples/simple-client/src/main/java/info/developerblog/examples/thirft/simpleclient/SimpleClientApplication.java // @EnableAsync // @SpringBootApplication // public class SimpleClientApplication { // // public static void main(String[] args) { // SpringApplication.run(SimpleClientApplication.class, args); // } // // @ThriftClient(serviceId = "greeting-service", path = "/api") // TGreetingService.Client client; // } // // Path: autoconfigure/src/main/java/info/developerblog/spring/thrift/client/pool/ThriftClientKey.java // @Builder // @EqualsAndHashCode // public class ThriftClientKey { // private Class<? extends TServiceClient> clazz; // private String serviceName; // private String path; // // public String getServiceName() { // if (StringUtils.isEmpty(serviceName)) // return WordUtils.uncapitalize(clazz.getEnclosingClass().getSimpleName()); // return serviceName; // } // // public Class<? extends TServiceClient> getClazz() { // return clazz; // } // // public String getPath() { // return path; // } // } // // Path: autoconfigure/src/main/java/info/developerblog/spring/thrift/client/pool/ThriftClientPool.java // public class ThriftClientPool extends GenericKeyedObjectPool<ThriftClientKey, TServiceClient> { // public ThriftClientPool(KeyedPooledObjectFactory<ThriftClientKey, TServiceClient> factory, GenericKeyedObjectPoolConfig config) { // super(factory, config); // } // } // Path: examples/simple-client/src/test/java/info/developerblog/examples/thirft/poolfactory/PoolFactoryTests.java import example.TGreetingService; import info.developerblog.examples.thirft.simpleclient.SimpleClientApplication; import info.developerblog.spring.thrift.client.pool.ThriftClientKey; import info.developerblog.spring.thrift.client.pool.ThriftClientPool; import org.apache.commons.pool2.KeyedPooledObjectFactory; import org.apache.commons.pool2.PooledObject; import org.apache.thrift.TServiceClient; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import javax.annotation.PostConstruct; import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT; package info.developerblog.examples.thirft.poolfactory; /** * @author Dmitry Zhikharev (jihor@ya.ru) * Created on 13.09.2016 */ @RunWith(SpringJUnit4ClassRunner.class) @SpringBootTest(classes = SimpleClientApplication.class, webEnvironment = RANDOM_PORT) public class PoolFactoryTests { @Autowired private ThriftClientPool thriftClientsPool;
private final ThriftClientKey thriftClientKey = ThriftClientKey.builder()
aatarasoff/spring-thrift-starter
autoconfigure/src/main/java/info/developerblog/spring/thrift/client/ThriftClientsMapBeanPostProcessor.java
// Path: autoconfigure/src/main/java/info/developerblog/spring/thrift/client/pool/ThriftClientKey.java // @Builder // @EqualsAndHashCode // public class ThriftClientKey { // private Class<? extends TServiceClient> clazz; // private String serviceName; // private String path; // // public String getServiceName() { // if (StringUtils.isEmpty(serviceName)) // return WordUtils.uncapitalize(clazz.getEnclosingClass().getSimpleName()); // return serviceName; // } // // public Class<? extends TServiceClient> getClazz() { // return clazz; // } // // public String getPath() { // return path; // } // }
import info.developerblog.spring.thrift.annotation.ThriftClientsMap; import info.developerblog.spring.thrift.client.pool.ThriftClientKey; import java.lang.reflect.Field; import java.lang.reflect.UndeclaredThrowableException; import java.util.HashMap; import java.util.Map; import lombok.SneakyThrows; import org.aopalliance.intercept.MethodInterceptor; import org.apache.commons.pool2.KeyedObjectPool; import org.apache.thrift.TException; import org.apache.thrift.TServiceClient; import org.apache.thrift.protocol.TProtocol; import org.springframework.aop.framework.Advised; import org.springframework.aop.framework.ProxyFactory; import org.springframework.aop.support.AopUtils; import org.springframework.beans.BeanUtils; import org.springframework.beans.BeansException; import org.springframework.beans.InvalidPropertyException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.config.BeanPostProcessor; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.boot.autoconfigure.AutoConfigureAfter; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication; import org.springframework.context.annotation.Configuration; import org.springframework.core.annotation.AnnotationUtils; import org.springframework.stereotype.Component; import org.springframework.util.ReflectionUtils;
package info.developerblog.spring.thrift.client; /** * @author jihor (jihor@ya.ru) * Created on 2016-06-14 */ @Component @Configuration @ConditionalOnClass(ThriftClientsMap.class) @ConditionalOnWebApplication @AutoConfigureAfter(PoolConfiguration.class) public class ThriftClientsMapBeanPostProcessor implements BeanPostProcessor { private Map<String, Class> beansToProcess = new HashMap<>(); @Autowired private DefaultListableBeanFactory beanFactory; @Autowired
// Path: autoconfigure/src/main/java/info/developerblog/spring/thrift/client/pool/ThriftClientKey.java // @Builder // @EqualsAndHashCode // public class ThriftClientKey { // private Class<? extends TServiceClient> clazz; // private String serviceName; // private String path; // // public String getServiceName() { // if (StringUtils.isEmpty(serviceName)) // return WordUtils.uncapitalize(clazz.getEnclosingClass().getSimpleName()); // return serviceName; // } // // public Class<? extends TServiceClient> getClazz() { // return clazz; // } // // public String getPath() { // return path; // } // } // Path: autoconfigure/src/main/java/info/developerblog/spring/thrift/client/ThriftClientsMapBeanPostProcessor.java import info.developerblog.spring.thrift.annotation.ThriftClientsMap; import info.developerblog.spring.thrift.client.pool.ThriftClientKey; import java.lang.reflect.Field; import java.lang.reflect.UndeclaredThrowableException; import java.util.HashMap; import java.util.Map; import lombok.SneakyThrows; import org.aopalliance.intercept.MethodInterceptor; import org.apache.commons.pool2.KeyedObjectPool; import org.apache.thrift.TException; import org.apache.thrift.TServiceClient; import org.apache.thrift.protocol.TProtocol; import org.springframework.aop.framework.Advised; import org.springframework.aop.framework.ProxyFactory; import org.springframework.aop.support.AopUtils; import org.springframework.beans.BeanUtils; import org.springframework.beans.BeansException; import org.springframework.beans.InvalidPropertyException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.config.BeanPostProcessor; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.boot.autoconfigure.AutoConfigureAfter; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication; import org.springframework.context.annotation.Configuration; import org.springframework.core.annotation.AnnotationUtils; import org.springframework.stereotype.Component; import org.springframework.util.ReflectionUtils; package info.developerblog.spring.thrift.client; /** * @author jihor (jihor@ya.ru) * Created on 2016-06-14 */ @Component @Configuration @ConditionalOnClass(ThriftClientsMap.class) @ConditionalOnWebApplication @AutoConfigureAfter(PoolConfiguration.class) public class ThriftClientsMapBeanPostProcessor implements BeanPostProcessor { private Map<String, Class> beansToProcess = new HashMap<>(); @Autowired private DefaultListableBeanFactory beanFactory; @Autowired
private KeyedObjectPool<ThriftClientKey, TServiceClient> thriftClientsPool;