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 |
|---|---|---|---|---|---|---|
alexdeleon/lupa | src/test/java/com/lumata/lib/lupa/internal/ScraperImplTest.java | // Path: src/main/java/com/lumata/lib/lupa/ServiceLocator.java
// public interface ServiceLocator {
//
// Scraper getScraper();
//
// HttpService getHttpService();
//
// ImageService getImageService();
// }
//
// Path: src/main/java/com/lumata/lib/lupa/content/WebContent.java
// public abstract class WebContent {
//
// public static enum Type {
// WEBPAGE,
// IMAGE,
// VIDEO,
// AUDIO,
// FEED
// }
//
// private final String url;
// private final String[] aliasUrls;
// private Set<String> keywords;
//
// WebContent(String url, String... aliasUrls) {
// this.url = url;
// this.aliasUrls = aliasUrls;
// }
//
// /**
// * Gets the preferred URL of this content
// *
// * @return the url
// */
// public String getUrl() {
// return url;
// }
//
// /**
// * Gets the known alias URLs where this content can be also located. The order is defined by the redirection path.
// *
// * @return the referingUrls
// */
// public String[] getAliasUrls() {
// return aliasUrls;
// }
//
// /**
// * @return the type of this web content.
// */
// public abstract Type getType();
//
// /**
// * @return the keywords of this web content.
// */
// public Set<String> getKeywords() {
// return keywords;
// }
//
// /**
// * @param keywords
// * the keywords to set
// */
// public void setKeywords(Set<String> keywords) {
// this.keywords = keywords;
// }
//
// @Override
// public int hashCode() {
// return Objects.hashCode(url, getType());
// }
//
// @Override
// public boolean equals(Object obj) {
// if (obj == null || !(obj instanceof WebContent)) {
// return false;
// }
// WebContent that = (WebContent) obj;
// return Objects.equal(this.url, that.url) && Objects.equal(this.getType(), that.getType())
// && Arrays.equals(this.aliasUrls, that.aliasUrls) && Objects.equal(this.keywords, that.keywords);
// }
//
// protected ToStringHelper toStringHelper(Object instance) {
// return Objects.toStringHelper(this).omitNullValues().add("url", url)
// .add("aliasUrls", Arrays.toString(aliasUrls)).add("keywords", keywords);
// }
//
// }
//
// Path: src/main/java/com/lumata/lib/lupa/extractor/ContentExtractorFactory.java
// public interface ContentExtractorFactory {
// /**
// * @param resource
// * the resource to extract the content from.
// * @param scraper
// * the scraper to use internally by the content scraper.
// * @return
// */
// <E extends WebContent> Optional<ContentExtractor<E>> getExtractor(ReadableResource resource, Class<E> webContentType);
//
// /**
// * @param resource
// * the resource to extract the content from.
// * @param scraper
// * the scraper to use internally by the content scraper.
// * @return
// */
// Optional<ContentExtractor<WebContent>> getExtractor(ReadableResource resource);
//
// }
| import static org.mockito.Mockito.mock;
import java.io.IOException;
import org.junit.Before;
import org.junit.Test;
import com.lumata.lib.lupa.ServiceLocator;
import com.lumata.lib.lupa.content.WebContent;
import com.lumata.lib.lupa.extractor.ContentExtractorFactory;
| package com.lumata.lib.lupa.internal;
public class ScraperImplTest {
private static final String TEST_URL = "http://example.com";
private ScraperImpl scraper;
| // Path: src/main/java/com/lumata/lib/lupa/ServiceLocator.java
// public interface ServiceLocator {
//
// Scraper getScraper();
//
// HttpService getHttpService();
//
// ImageService getImageService();
// }
//
// Path: src/main/java/com/lumata/lib/lupa/content/WebContent.java
// public abstract class WebContent {
//
// public static enum Type {
// WEBPAGE,
// IMAGE,
// VIDEO,
// AUDIO,
// FEED
// }
//
// private final String url;
// private final String[] aliasUrls;
// private Set<String> keywords;
//
// WebContent(String url, String... aliasUrls) {
// this.url = url;
// this.aliasUrls = aliasUrls;
// }
//
// /**
// * Gets the preferred URL of this content
// *
// * @return the url
// */
// public String getUrl() {
// return url;
// }
//
// /**
// * Gets the known alias URLs where this content can be also located. The order is defined by the redirection path.
// *
// * @return the referingUrls
// */
// public String[] getAliasUrls() {
// return aliasUrls;
// }
//
// /**
// * @return the type of this web content.
// */
// public abstract Type getType();
//
// /**
// * @return the keywords of this web content.
// */
// public Set<String> getKeywords() {
// return keywords;
// }
//
// /**
// * @param keywords
// * the keywords to set
// */
// public void setKeywords(Set<String> keywords) {
// this.keywords = keywords;
// }
//
// @Override
// public int hashCode() {
// return Objects.hashCode(url, getType());
// }
//
// @Override
// public boolean equals(Object obj) {
// if (obj == null || !(obj instanceof WebContent)) {
// return false;
// }
// WebContent that = (WebContent) obj;
// return Objects.equal(this.url, that.url) && Objects.equal(this.getType(), that.getType())
// && Arrays.equals(this.aliasUrls, that.aliasUrls) && Objects.equal(this.keywords, that.keywords);
// }
//
// protected ToStringHelper toStringHelper(Object instance) {
// return Objects.toStringHelper(this).omitNullValues().add("url", url)
// .add("aliasUrls", Arrays.toString(aliasUrls)).add("keywords", keywords);
// }
//
// }
//
// Path: src/main/java/com/lumata/lib/lupa/extractor/ContentExtractorFactory.java
// public interface ContentExtractorFactory {
// /**
// * @param resource
// * the resource to extract the content from.
// * @param scraper
// * the scraper to use internally by the content scraper.
// * @return
// */
// <E extends WebContent> Optional<ContentExtractor<E>> getExtractor(ReadableResource resource, Class<E> webContentType);
//
// /**
// * @param resource
// * the resource to extract the content from.
// * @param scraper
// * the scraper to use internally by the content scraper.
// * @return
// */
// Optional<ContentExtractor<WebContent>> getExtractor(ReadableResource resource);
//
// }
// Path: src/test/java/com/lumata/lib/lupa/internal/ScraperImplTest.java
import static org.mockito.Mockito.mock;
import java.io.IOException;
import org.junit.Before;
import org.junit.Test;
import com.lumata.lib.lupa.ServiceLocator;
import com.lumata.lib.lupa.content.WebContent;
import com.lumata.lib.lupa.extractor.ContentExtractorFactory;
package com.lumata.lib.lupa.internal;
public class ScraperImplTest {
private static final String TEST_URL = "http://example.com";
private ScraperImpl scraper;
| private ContentExtractorFactory extractorFactoryMock;
|
alexdeleon/lupa | src/test/java/com/lumata/lib/lupa/internal/ScraperImplTest.java | // Path: src/main/java/com/lumata/lib/lupa/ServiceLocator.java
// public interface ServiceLocator {
//
// Scraper getScraper();
//
// HttpService getHttpService();
//
// ImageService getImageService();
// }
//
// Path: src/main/java/com/lumata/lib/lupa/content/WebContent.java
// public abstract class WebContent {
//
// public static enum Type {
// WEBPAGE,
// IMAGE,
// VIDEO,
// AUDIO,
// FEED
// }
//
// private final String url;
// private final String[] aliasUrls;
// private Set<String> keywords;
//
// WebContent(String url, String... aliasUrls) {
// this.url = url;
// this.aliasUrls = aliasUrls;
// }
//
// /**
// * Gets the preferred URL of this content
// *
// * @return the url
// */
// public String getUrl() {
// return url;
// }
//
// /**
// * Gets the known alias URLs where this content can be also located. The order is defined by the redirection path.
// *
// * @return the referingUrls
// */
// public String[] getAliasUrls() {
// return aliasUrls;
// }
//
// /**
// * @return the type of this web content.
// */
// public abstract Type getType();
//
// /**
// * @return the keywords of this web content.
// */
// public Set<String> getKeywords() {
// return keywords;
// }
//
// /**
// * @param keywords
// * the keywords to set
// */
// public void setKeywords(Set<String> keywords) {
// this.keywords = keywords;
// }
//
// @Override
// public int hashCode() {
// return Objects.hashCode(url, getType());
// }
//
// @Override
// public boolean equals(Object obj) {
// if (obj == null || !(obj instanceof WebContent)) {
// return false;
// }
// WebContent that = (WebContent) obj;
// return Objects.equal(this.url, that.url) && Objects.equal(this.getType(), that.getType())
// && Arrays.equals(this.aliasUrls, that.aliasUrls) && Objects.equal(this.keywords, that.keywords);
// }
//
// protected ToStringHelper toStringHelper(Object instance) {
// return Objects.toStringHelper(this).omitNullValues().add("url", url)
// .add("aliasUrls", Arrays.toString(aliasUrls)).add("keywords", keywords);
// }
//
// }
//
// Path: src/main/java/com/lumata/lib/lupa/extractor/ContentExtractorFactory.java
// public interface ContentExtractorFactory {
// /**
// * @param resource
// * the resource to extract the content from.
// * @param scraper
// * the scraper to use internally by the content scraper.
// * @return
// */
// <E extends WebContent> Optional<ContentExtractor<E>> getExtractor(ReadableResource resource, Class<E> webContentType);
//
// /**
// * @param resource
// * the resource to extract the content from.
// * @param scraper
// * the scraper to use internally by the content scraper.
// * @return
// */
// Optional<ContentExtractor<WebContent>> getExtractor(ReadableResource resource);
//
// }
| import static org.mockito.Mockito.mock;
import java.io.IOException;
import org.junit.Before;
import org.junit.Test;
import com.lumata.lib.lupa.ServiceLocator;
import com.lumata.lib.lupa.content.WebContent;
import com.lumata.lib.lupa.extractor.ContentExtractorFactory;
| package com.lumata.lib.lupa.internal;
public class ScraperImplTest {
private static final String TEST_URL = "http://example.com";
private ScraperImpl scraper;
private ContentExtractorFactory extractorFactoryMock;
| // Path: src/main/java/com/lumata/lib/lupa/ServiceLocator.java
// public interface ServiceLocator {
//
// Scraper getScraper();
//
// HttpService getHttpService();
//
// ImageService getImageService();
// }
//
// Path: src/main/java/com/lumata/lib/lupa/content/WebContent.java
// public abstract class WebContent {
//
// public static enum Type {
// WEBPAGE,
// IMAGE,
// VIDEO,
// AUDIO,
// FEED
// }
//
// private final String url;
// private final String[] aliasUrls;
// private Set<String> keywords;
//
// WebContent(String url, String... aliasUrls) {
// this.url = url;
// this.aliasUrls = aliasUrls;
// }
//
// /**
// * Gets the preferred URL of this content
// *
// * @return the url
// */
// public String getUrl() {
// return url;
// }
//
// /**
// * Gets the known alias URLs where this content can be also located. The order is defined by the redirection path.
// *
// * @return the referingUrls
// */
// public String[] getAliasUrls() {
// return aliasUrls;
// }
//
// /**
// * @return the type of this web content.
// */
// public abstract Type getType();
//
// /**
// * @return the keywords of this web content.
// */
// public Set<String> getKeywords() {
// return keywords;
// }
//
// /**
// * @param keywords
// * the keywords to set
// */
// public void setKeywords(Set<String> keywords) {
// this.keywords = keywords;
// }
//
// @Override
// public int hashCode() {
// return Objects.hashCode(url, getType());
// }
//
// @Override
// public boolean equals(Object obj) {
// if (obj == null || !(obj instanceof WebContent)) {
// return false;
// }
// WebContent that = (WebContent) obj;
// return Objects.equal(this.url, that.url) && Objects.equal(this.getType(), that.getType())
// && Arrays.equals(this.aliasUrls, that.aliasUrls) && Objects.equal(this.keywords, that.keywords);
// }
//
// protected ToStringHelper toStringHelper(Object instance) {
// return Objects.toStringHelper(this).omitNullValues().add("url", url)
// .add("aliasUrls", Arrays.toString(aliasUrls)).add("keywords", keywords);
// }
//
// }
//
// Path: src/main/java/com/lumata/lib/lupa/extractor/ContentExtractorFactory.java
// public interface ContentExtractorFactory {
// /**
// * @param resource
// * the resource to extract the content from.
// * @param scraper
// * the scraper to use internally by the content scraper.
// * @return
// */
// <E extends WebContent> Optional<ContentExtractor<E>> getExtractor(ReadableResource resource, Class<E> webContentType);
//
// /**
// * @param resource
// * the resource to extract the content from.
// * @param scraper
// * the scraper to use internally by the content scraper.
// * @return
// */
// Optional<ContentExtractor<WebContent>> getExtractor(ReadableResource resource);
//
// }
// Path: src/test/java/com/lumata/lib/lupa/internal/ScraperImplTest.java
import static org.mockito.Mockito.mock;
import java.io.IOException;
import org.junit.Before;
import org.junit.Test;
import com.lumata.lib.lupa.ServiceLocator;
import com.lumata.lib.lupa.content.WebContent;
import com.lumata.lib.lupa.extractor.ContentExtractorFactory;
package com.lumata.lib.lupa.internal;
public class ScraperImplTest {
private static final String TEST_URL = "http://example.com";
private ScraperImpl scraper;
private ContentExtractorFactory extractorFactoryMock;
| private ServiceLocator serviceLocatorMock;
|
alexdeleon/lupa | src/test/java/com/lumata/lib/lupa/internal/ScraperImplTest.java | // Path: src/main/java/com/lumata/lib/lupa/ServiceLocator.java
// public interface ServiceLocator {
//
// Scraper getScraper();
//
// HttpService getHttpService();
//
// ImageService getImageService();
// }
//
// Path: src/main/java/com/lumata/lib/lupa/content/WebContent.java
// public abstract class WebContent {
//
// public static enum Type {
// WEBPAGE,
// IMAGE,
// VIDEO,
// AUDIO,
// FEED
// }
//
// private final String url;
// private final String[] aliasUrls;
// private Set<String> keywords;
//
// WebContent(String url, String... aliasUrls) {
// this.url = url;
// this.aliasUrls = aliasUrls;
// }
//
// /**
// * Gets the preferred URL of this content
// *
// * @return the url
// */
// public String getUrl() {
// return url;
// }
//
// /**
// * Gets the known alias URLs where this content can be also located. The order is defined by the redirection path.
// *
// * @return the referingUrls
// */
// public String[] getAliasUrls() {
// return aliasUrls;
// }
//
// /**
// * @return the type of this web content.
// */
// public abstract Type getType();
//
// /**
// * @return the keywords of this web content.
// */
// public Set<String> getKeywords() {
// return keywords;
// }
//
// /**
// * @param keywords
// * the keywords to set
// */
// public void setKeywords(Set<String> keywords) {
// this.keywords = keywords;
// }
//
// @Override
// public int hashCode() {
// return Objects.hashCode(url, getType());
// }
//
// @Override
// public boolean equals(Object obj) {
// if (obj == null || !(obj instanceof WebContent)) {
// return false;
// }
// WebContent that = (WebContent) obj;
// return Objects.equal(this.url, that.url) && Objects.equal(this.getType(), that.getType())
// && Arrays.equals(this.aliasUrls, that.aliasUrls) && Objects.equal(this.keywords, that.keywords);
// }
//
// protected ToStringHelper toStringHelper(Object instance) {
// return Objects.toStringHelper(this).omitNullValues().add("url", url)
// .add("aliasUrls", Arrays.toString(aliasUrls)).add("keywords", keywords);
// }
//
// }
//
// Path: src/main/java/com/lumata/lib/lupa/extractor/ContentExtractorFactory.java
// public interface ContentExtractorFactory {
// /**
// * @param resource
// * the resource to extract the content from.
// * @param scraper
// * the scraper to use internally by the content scraper.
// * @return
// */
// <E extends WebContent> Optional<ContentExtractor<E>> getExtractor(ReadableResource resource, Class<E> webContentType);
//
// /**
// * @param resource
// * the resource to extract the content from.
// * @param scraper
// * the scraper to use internally by the content scraper.
// * @return
// */
// Optional<ContentExtractor<WebContent>> getExtractor(ReadableResource resource);
//
// }
| import static org.mockito.Mockito.mock;
import java.io.IOException;
import org.junit.Before;
import org.junit.Test;
import com.lumata.lib.lupa.ServiceLocator;
import com.lumata.lib.lupa.content.WebContent;
import com.lumata.lib.lupa.extractor.ContentExtractorFactory;
| package com.lumata.lib.lupa.internal;
public class ScraperImplTest {
private static final String TEST_URL = "http://example.com";
private ScraperImpl scraper;
private ContentExtractorFactory extractorFactoryMock;
private ServiceLocator serviceLocatorMock;
@Before
public void setup() {
extractorFactoryMock = mock(ContentExtractorFactory.class);
serviceLocatorMock = mock(ServiceLocator.class);
scraper = new ScraperImpl(extractorFactoryMock, serviceLocatorMock);
}
@Test
public void testScrapFromUrl() throws IOException {
| // Path: src/main/java/com/lumata/lib/lupa/ServiceLocator.java
// public interface ServiceLocator {
//
// Scraper getScraper();
//
// HttpService getHttpService();
//
// ImageService getImageService();
// }
//
// Path: src/main/java/com/lumata/lib/lupa/content/WebContent.java
// public abstract class WebContent {
//
// public static enum Type {
// WEBPAGE,
// IMAGE,
// VIDEO,
// AUDIO,
// FEED
// }
//
// private final String url;
// private final String[] aliasUrls;
// private Set<String> keywords;
//
// WebContent(String url, String... aliasUrls) {
// this.url = url;
// this.aliasUrls = aliasUrls;
// }
//
// /**
// * Gets the preferred URL of this content
// *
// * @return the url
// */
// public String getUrl() {
// return url;
// }
//
// /**
// * Gets the known alias URLs where this content can be also located. The order is defined by the redirection path.
// *
// * @return the referingUrls
// */
// public String[] getAliasUrls() {
// return aliasUrls;
// }
//
// /**
// * @return the type of this web content.
// */
// public abstract Type getType();
//
// /**
// * @return the keywords of this web content.
// */
// public Set<String> getKeywords() {
// return keywords;
// }
//
// /**
// * @param keywords
// * the keywords to set
// */
// public void setKeywords(Set<String> keywords) {
// this.keywords = keywords;
// }
//
// @Override
// public int hashCode() {
// return Objects.hashCode(url, getType());
// }
//
// @Override
// public boolean equals(Object obj) {
// if (obj == null || !(obj instanceof WebContent)) {
// return false;
// }
// WebContent that = (WebContent) obj;
// return Objects.equal(this.url, that.url) && Objects.equal(this.getType(), that.getType())
// && Arrays.equals(this.aliasUrls, that.aliasUrls) && Objects.equal(this.keywords, that.keywords);
// }
//
// protected ToStringHelper toStringHelper(Object instance) {
// return Objects.toStringHelper(this).omitNullValues().add("url", url)
// .add("aliasUrls", Arrays.toString(aliasUrls)).add("keywords", keywords);
// }
//
// }
//
// Path: src/main/java/com/lumata/lib/lupa/extractor/ContentExtractorFactory.java
// public interface ContentExtractorFactory {
// /**
// * @param resource
// * the resource to extract the content from.
// * @param scraper
// * the scraper to use internally by the content scraper.
// * @return
// */
// <E extends WebContent> Optional<ContentExtractor<E>> getExtractor(ReadableResource resource, Class<E> webContentType);
//
// /**
// * @param resource
// * the resource to extract the content from.
// * @param scraper
// * the scraper to use internally by the content scraper.
// * @return
// */
// Optional<ContentExtractor<WebContent>> getExtractor(ReadableResource resource);
//
// }
// Path: src/test/java/com/lumata/lib/lupa/internal/ScraperImplTest.java
import static org.mockito.Mockito.mock;
import java.io.IOException;
import org.junit.Before;
import org.junit.Test;
import com.lumata.lib.lupa.ServiceLocator;
import com.lumata.lib.lupa.content.WebContent;
import com.lumata.lib.lupa.extractor.ContentExtractorFactory;
package com.lumata.lib.lupa.internal;
public class ScraperImplTest {
private static final String TEST_URL = "http://example.com";
private ScraperImpl scraper;
private ContentExtractorFactory extractorFactoryMock;
private ServiceLocator serviceLocatorMock;
@Before
public void setup() {
extractorFactoryMock = mock(ContentExtractorFactory.class);
serviceLocatorMock = mock(ServiceLocator.class);
scraper = new ScraperImpl(extractorFactoryMock, serviceLocatorMock);
}
@Test
public void testScrapFromUrl() throws IOException {
| WebContent content = scraper.scrapContent(TEST_URL);
|
melix/japicmp-gradle-plugin | src/main/java/me/champeau/gradle/japicmp/report/stdrules/RecordSeenMembersSetup.java | // Path: src/main/java/me/champeau/gradle/japicmp/report/SetupRule.java
// public interface SetupRule extends Action<ViolationCheckContext> {
// }
//
// Path: src/main/java/me/champeau/gradle/japicmp/report/ViolationCheckContext.java
// public interface ViolationCheckContext {
// /**
// * Returns the fully-qualified class name of the class being currently checked
// * @return the fully-qualified class name of the class being currently checked, or null if it's a pre/post rule
// */
// String getClassName();
//
// /**
// * Returns a map that can be used by the writer of a rule to read and write arbitrary data.
// * @return a user-data map, never null
// */
// Map<String, ?> getUserData();
//
// <T> T getUserData(String key);
//
// <T> void putUserData(String key, T value);
// }
| import japicmp.model.JApiCompatibility;
import me.champeau.gradle.japicmp.report.SetupRule;
import me.champeau.gradle.japicmp.report.ViolationCheckContext;
import java.util.HashSet; | /*
* Copyright 2003-2012 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package me.champeau.gradle.japicmp.report.stdrules;
public class RecordSeenMembersSetup implements SetupRule {
static final String SEEN = RecordSeenMembersSetup.class.getName();
@Override | // Path: src/main/java/me/champeau/gradle/japicmp/report/SetupRule.java
// public interface SetupRule extends Action<ViolationCheckContext> {
// }
//
// Path: src/main/java/me/champeau/gradle/japicmp/report/ViolationCheckContext.java
// public interface ViolationCheckContext {
// /**
// * Returns the fully-qualified class name of the class being currently checked
// * @return the fully-qualified class name of the class being currently checked, or null if it's a pre/post rule
// */
// String getClassName();
//
// /**
// * Returns a map that can be used by the writer of a rule to read and write arbitrary data.
// * @return a user-data map, never null
// */
// Map<String, ?> getUserData();
//
// <T> T getUserData(String key);
//
// <T> void putUserData(String key, T value);
// }
// Path: src/main/java/me/champeau/gradle/japicmp/report/stdrules/RecordSeenMembersSetup.java
import japicmp.model.JApiCompatibility;
import me.champeau.gradle.japicmp.report.SetupRule;
import me.champeau.gradle.japicmp.report.ViolationCheckContext;
import java.util.HashSet;
/*
* Copyright 2003-2012 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package me.champeau.gradle.japicmp.report.stdrules;
public class RecordSeenMembersSetup implements SetupRule {
static final String SEEN = RecordSeenMembersSetup.class.getName();
@Override | public void execute(final ViolationCheckContext violationCheckContext) { |
melix/japicmp-gradle-plugin | src/main/java/me/champeau/gradle/japicmp/report/ViolationsGenerator.java | // Path: src/main/java/me/champeau/gradle/japicmp/report/stdrules/BinaryIncompatibleRule.java
// public class BinaryIncompatibleRule extends AbstractRecordingSeenMembers {
// private final Severity severity;
//
// public BinaryIncompatibleRule(final Severity severity) {
// this.severity = severity;
// }
//
// public BinaryIncompatibleRule() {
// this(Severity.error);
// }
//
// @Override
// public Violation maybeAddViolation(final JApiCompatibility member) {
// if (!member.isBinaryCompatible()) {
// return Violation.notBinaryCompatible(member, severity);
// }
// return null;
// }
// }
//
// Path: src/main/java/me/champeau/gradle/japicmp/report/stdrules/RecordSeenMembersSetup.java
// public class RecordSeenMembersSetup implements SetupRule {
// static final String SEEN = RecordSeenMembersSetup.class.getName();
//
// @Override
// public void execute(final ViolationCheckContext violationCheckContext) {
// violationCheckContext.putUserData(SEEN, new HashSet<JApiCompatibility>());
// }
// }
//
// Path: src/main/java/me/champeau/gradle/japicmp/report/stdrules/SourceCompatibleRule.java
// public class SourceCompatibleRule extends AbstractRecordingSeenMembers {
// private final Severity severity;
// private final String message;
//
// public SourceCompatibleRule(final Severity severity, String message) {
// this.severity = severity;
// this.message = message;
// }
//
// public SourceCompatibleRule() {
// this(Severity.warning, "is source compatible");
// }
//
// @Override
// public Violation maybeAddViolation(final JApiCompatibility member) {
// if (member.isSourceCompatible()) {
// return Violation.any(member, severity, message);
// }
// return null;
// }
// }
//
// Path: src/main/java/me/champeau/gradle/japicmp/report/stdrules/UnchangedMemberRule.java
// public class UnchangedMemberRule extends AbstractRecordingSeenMembers {
//
// @Override
// public Violation maybeAddViolation(final JApiCompatibility member) {
// Set<JApiCompatibility> seen = getContext().getUserData(RecordSeenMembersSetup.SEEN);
// seen.add(member);
// return null;
// }
// }
| import japicmp.model.JApiChangeStatus;
import japicmp.model.JApiClass;
import japicmp.model.JApiCompatibility;
import japicmp.model.JApiCompatibilityChange;
import japicmp.model.JApiConstructor;
import japicmp.model.JApiField;
import japicmp.model.JApiHasChangeStatus;
import japicmp.model.JApiImplementedInterface;
import japicmp.model.JApiMethod;
import me.champeau.gradle.japicmp.report.stdrules.BinaryIncompatibleRule;
import me.champeau.gradle.japicmp.report.stdrules.RecordSeenMembersSetup;
import me.champeau.gradle.japicmp.report.stdrules.SourceCompatibleRule;
import me.champeau.gradle.japicmp.report.stdrules.UnchangedMemberRule;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.regex.Pattern; | violationTransformers.add(violationTransformer);
}
public Map<String, List<Violation>> toViolations(List<JApiClass> classes) {
addDefaultRuleIfNotConfigured();
Context ctx = new Context(violationTransformers);
for (SetupRule setupRule : setupRules) {
setupRule.execute(ctx);
}
injectContextIntoRules(ctx);
for (JApiClass aClass : classes) {
maybeProcess(aClass, ctx);
}
for (PostProcessViolationsRule postProcessViolationsRule : postProcessRules) {
postProcessViolationsRule.execute(ctx);
}
return ctx.violations;
}
private void addDefaultRuleIfNotConfigured() {
if (setupRules.isEmpty()
&& postProcessRules.isEmpty()
&& apiCompatibilityRules.isEmpty()
&& statusRules.isEmpty()
&& genericRules.isEmpty()) {
addDefaultRules();
}
}
public void addDefaultRules() { | // Path: src/main/java/me/champeau/gradle/japicmp/report/stdrules/BinaryIncompatibleRule.java
// public class BinaryIncompatibleRule extends AbstractRecordingSeenMembers {
// private final Severity severity;
//
// public BinaryIncompatibleRule(final Severity severity) {
// this.severity = severity;
// }
//
// public BinaryIncompatibleRule() {
// this(Severity.error);
// }
//
// @Override
// public Violation maybeAddViolation(final JApiCompatibility member) {
// if (!member.isBinaryCompatible()) {
// return Violation.notBinaryCompatible(member, severity);
// }
// return null;
// }
// }
//
// Path: src/main/java/me/champeau/gradle/japicmp/report/stdrules/RecordSeenMembersSetup.java
// public class RecordSeenMembersSetup implements SetupRule {
// static final String SEEN = RecordSeenMembersSetup.class.getName();
//
// @Override
// public void execute(final ViolationCheckContext violationCheckContext) {
// violationCheckContext.putUserData(SEEN, new HashSet<JApiCompatibility>());
// }
// }
//
// Path: src/main/java/me/champeau/gradle/japicmp/report/stdrules/SourceCompatibleRule.java
// public class SourceCompatibleRule extends AbstractRecordingSeenMembers {
// private final Severity severity;
// private final String message;
//
// public SourceCompatibleRule(final Severity severity, String message) {
// this.severity = severity;
// this.message = message;
// }
//
// public SourceCompatibleRule() {
// this(Severity.warning, "is source compatible");
// }
//
// @Override
// public Violation maybeAddViolation(final JApiCompatibility member) {
// if (member.isSourceCompatible()) {
// return Violation.any(member, severity, message);
// }
// return null;
// }
// }
//
// Path: src/main/java/me/champeau/gradle/japicmp/report/stdrules/UnchangedMemberRule.java
// public class UnchangedMemberRule extends AbstractRecordingSeenMembers {
//
// @Override
// public Violation maybeAddViolation(final JApiCompatibility member) {
// Set<JApiCompatibility> seen = getContext().getUserData(RecordSeenMembersSetup.SEEN);
// seen.add(member);
// return null;
// }
// }
// Path: src/main/java/me/champeau/gradle/japicmp/report/ViolationsGenerator.java
import japicmp.model.JApiChangeStatus;
import japicmp.model.JApiClass;
import japicmp.model.JApiCompatibility;
import japicmp.model.JApiCompatibilityChange;
import japicmp.model.JApiConstructor;
import japicmp.model.JApiField;
import japicmp.model.JApiHasChangeStatus;
import japicmp.model.JApiImplementedInterface;
import japicmp.model.JApiMethod;
import me.champeau.gradle.japicmp.report.stdrules.BinaryIncompatibleRule;
import me.champeau.gradle.japicmp.report.stdrules.RecordSeenMembersSetup;
import me.champeau.gradle.japicmp.report.stdrules.SourceCompatibleRule;
import me.champeau.gradle.japicmp.report.stdrules.UnchangedMemberRule;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.regex.Pattern;
violationTransformers.add(violationTransformer);
}
public Map<String, List<Violation>> toViolations(List<JApiClass> classes) {
addDefaultRuleIfNotConfigured();
Context ctx = new Context(violationTransformers);
for (SetupRule setupRule : setupRules) {
setupRule.execute(ctx);
}
injectContextIntoRules(ctx);
for (JApiClass aClass : classes) {
maybeProcess(aClass, ctx);
}
for (PostProcessViolationsRule postProcessViolationsRule : postProcessRules) {
postProcessViolationsRule.execute(ctx);
}
return ctx.violations;
}
private void addDefaultRuleIfNotConfigured() {
if (setupRules.isEmpty()
&& postProcessRules.isEmpty()
&& apiCompatibilityRules.isEmpty()
&& statusRules.isEmpty()
&& genericRules.isEmpty()) {
addDefaultRules();
}
}
public void addDefaultRules() { | setupRules.add(new RecordSeenMembersSetup()); |
melix/japicmp-gradle-plugin | src/main/java/me/champeau/gradle/japicmp/report/ViolationsGenerator.java | // Path: src/main/java/me/champeau/gradle/japicmp/report/stdrules/BinaryIncompatibleRule.java
// public class BinaryIncompatibleRule extends AbstractRecordingSeenMembers {
// private final Severity severity;
//
// public BinaryIncompatibleRule(final Severity severity) {
// this.severity = severity;
// }
//
// public BinaryIncompatibleRule() {
// this(Severity.error);
// }
//
// @Override
// public Violation maybeAddViolation(final JApiCompatibility member) {
// if (!member.isBinaryCompatible()) {
// return Violation.notBinaryCompatible(member, severity);
// }
// return null;
// }
// }
//
// Path: src/main/java/me/champeau/gradle/japicmp/report/stdrules/RecordSeenMembersSetup.java
// public class RecordSeenMembersSetup implements SetupRule {
// static final String SEEN = RecordSeenMembersSetup.class.getName();
//
// @Override
// public void execute(final ViolationCheckContext violationCheckContext) {
// violationCheckContext.putUserData(SEEN, new HashSet<JApiCompatibility>());
// }
// }
//
// Path: src/main/java/me/champeau/gradle/japicmp/report/stdrules/SourceCompatibleRule.java
// public class SourceCompatibleRule extends AbstractRecordingSeenMembers {
// private final Severity severity;
// private final String message;
//
// public SourceCompatibleRule(final Severity severity, String message) {
// this.severity = severity;
// this.message = message;
// }
//
// public SourceCompatibleRule() {
// this(Severity.warning, "is source compatible");
// }
//
// @Override
// public Violation maybeAddViolation(final JApiCompatibility member) {
// if (member.isSourceCompatible()) {
// return Violation.any(member, severity, message);
// }
// return null;
// }
// }
//
// Path: src/main/java/me/champeau/gradle/japicmp/report/stdrules/UnchangedMemberRule.java
// public class UnchangedMemberRule extends AbstractRecordingSeenMembers {
//
// @Override
// public Violation maybeAddViolation(final JApiCompatibility member) {
// Set<JApiCompatibility> seen = getContext().getUserData(RecordSeenMembersSetup.SEEN);
// seen.add(member);
// return null;
// }
// }
| import japicmp.model.JApiChangeStatus;
import japicmp.model.JApiClass;
import japicmp.model.JApiCompatibility;
import japicmp.model.JApiCompatibilityChange;
import japicmp.model.JApiConstructor;
import japicmp.model.JApiField;
import japicmp.model.JApiHasChangeStatus;
import japicmp.model.JApiImplementedInterface;
import japicmp.model.JApiMethod;
import me.champeau.gradle.japicmp.report.stdrules.BinaryIncompatibleRule;
import me.champeau.gradle.japicmp.report.stdrules.RecordSeenMembersSetup;
import me.champeau.gradle.japicmp.report.stdrules.SourceCompatibleRule;
import me.champeau.gradle.japicmp.report.stdrules.UnchangedMemberRule;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.regex.Pattern; | }
public Map<String, List<Violation>> toViolations(List<JApiClass> classes) {
addDefaultRuleIfNotConfigured();
Context ctx = new Context(violationTransformers);
for (SetupRule setupRule : setupRules) {
setupRule.execute(ctx);
}
injectContextIntoRules(ctx);
for (JApiClass aClass : classes) {
maybeProcess(aClass, ctx);
}
for (PostProcessViolationsRule postProcessViolationsRule : postProcessRules) {
postProcessViolationsRule.execute(ctx);
}
return ctx.violations;
}
private void addDefaultRuleIfNotConfigured() {
if (setupRules.isEmpty()
&& postProcessRules.isEmpty()
&& apiCompatibilityRules.isEmpty()
&& statusRules.isEmpty()
&& genericRules.isEmpty()) {
addDefaultRules();
}
}
public void addDefaultRules() {
setupRules.add(new RecordSeenMembersSetup()); | // Path: src/main/java/me/champeau/gradle/japicmp/report/stdrules/BinaryIncompatibleRule.java
// public class BinaryIncompatibleRule extends AbstractRecordingSeenMembers {
// private final Severity severity;
//
// public BinaryIncompatibleRule(final Severity severity) {
// this.severity = severity;
// }
//
// public BinaryIncompatibleRule() {
// this(Severity.error);
// }
//
// @Override
// public Violation maybeAddViolation(final JApiCompatibility member) {
// if (!member.isBinaryCompatible()) {
// return Violation.notBinaryCompatible(member, severity);
// }
// return null;
// }
// }
//
// Path: src/main/java/me/champeau/gradle/japicmp/report/stdrules/RecordSeenMembersSetup.java
// public class RecordSeenMembersSetup implements SetupRule {
// static final String SEEN = RecordSeenMembersSetup.class.getName();
//
// @Override
// public void execute(final ViolationCheckContext violationCheckContext) {
// violationCheckContext.putUserData(SEEN, new HashSet<JApiCompatibility>());
// }
// }
//
// Path: src/main/java/me/champeau/gradle/japicmp/report/stdrules/SourceCompatibleRule.java
// public class SourceCompatibleRule extends AbstractRecordingSeenMembers {
// private final Severity severity;
// private final String message;
//
// public SourceCompatibleRule(final Severity severity, String message) {
// this.severity = severity;
// this.message = message;
// }
//
// public SourceCompatibleRule() {
// this(Severity.warning, "is source compatible");
// }
//
// @Override
// public Violation maybeAddViolation(final JApiCompatibility member) {
// if (member.isSourceCompatible()) {
// return Violation.any(member, severity, message);
// }
// return null;
// }
// }
//
// Path: src/main/java/me/champeau/gradle/japicmp/report/stdrules/UnchangedMemberRule.java
// public class UnchangedMemberRule extends AbstractRecordingSeenMembers {
//
// @Override
// public Violation maybeAddViolation(final JApiCompatibility member) {
// Set<JApiCompatibility> seen = getContext().getUserData(RecordSeenMembersSetup.SEEN);
// seen.add(member);
// return null;
// }
// }
// Path: src/main/java/me/champeau/gradle/japicmp/report/ViolationsGenerator.java
import japicmp.model.JApiChangeStatus;
import japicmp.model.JApiClass;
import japicmp.model.JApiCompatibility;
import japicmp.model.JApiCompatibilityChange;
import japicmp.model.JApiConstructor;
import japicmp.model.JApiField;
import japicmp.model.JApiHasChangeStatus;
import japicmp.model.JApiImplementedInterface;
import japicmp.model.JApiMethod;
import me.champeau.gradle.japicmp.report.stdrules.BinaryIncompatibleRule;
import me.champeau.gradle.japicmp.report.stdrules.RecordSeenMembersSetup;
import me.champeau.gradle.japicmp.report.stdrules.SourceCompatibleRule;
import me.champeau.gradle.japicmp.report.stdrules.UnchangedMemberRule;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.regex.Pattern;
}
public Map<String, List<Violation>> toViolations(List<JApiClass> classes) {
addDefaultRuleIfNotConfigured();
Context ctx = new Context(violationTransformers);
for (SetupRule setupRule : setupRules) {
setupRule.execute(ctx);
}
injectContextIntoRules(ctx);
for (JApiClass aClass : classes) {
maybeProcess(aClass, ctx);
}
for (PostProcessViolationsRule postProcessViolationsRule : postProcessRules) {
postProcessViolationsRule.execute(ctx);
}
return ctx.violations;
}
private void addDefaultRuleIfNotConfigured() {
if (setupRules.isEmpty()
&& postProcessRules.isEmpty()
&& apiCompatibilityRules.isEmpty()
&& statusRules.isEmpty()
&& genericRules.isEmpty()) {
addDefaultRules();
}
}
public void addDefaultRules() {
setupRules.add(new RecordSeenMembersSetup()); | addRule(JApiChangeStatus.NEW, new SourceCompatibleRule(Severity.info, "has been added in source compatible way")); |
melix/japicmp-gradle-plugin | src/main/java/me/champeau/gradle/japicmp/report/ViolationsGenerator.java | // Path: src/main/java/me/champeau/gradle/japicmp/report/stdrules/BinaryIncompatibleRule.java
// public class BinaryIncompatibleRule extends AbstractRecordingSeenMembers {
// private final Severity severity;
//
// public BinaryIncompatibleRule(final Severity severity) {
// this.severity = severity;
// }
//
// public BinaryIncompatibleRule() {
// this(Severity.error);
// }
//
// @Override
// public Violation maybeAddViolation(final JApiCompatibility member) {
// if (!member.isBinaryCompatible()) {
// return Violation.notBinaryCompatible(member, severity);
// }
// return null;
// }
// }
//
// Path: src/main/java/me/champeau/gradle/japicmp/report/stdrules/RecordSeenMembersSetup.java
// public class RecordSeenMembersSetup implements SetupRule {
// static final String SEEN = RecordSeenMembersSetup.class.getName();
//
// @Override
// public void execute(final ViolationCheckContext violationCheckContext) {
// violationCheckContext.putUserData(SEEN, new HashSet<JApiCompatibility>());
// }
// }
//
// Path: src/main/java/me/champeau/gradle/japicmp/report/stdrules/SourceCompatibleRule.java
// public class SourceCompatibleRule extends AbstractRecordingSeenMembers {
// private final Severity severity;
// private final String message;
//
// public SourceCompatibleRule(final Severity severity, String message) {
// this.severity = severity;
// this.message = message;
// }
//
// public SourceCompatibleRule() {
// this(Severity.warning, "is source compatible");
// }
//
// @Override
// public Violation maybeAddViolation(final JApiCompatibility member) {
// if (member.isSourceCompatible()) {
// return Violation.any(member, severity, message);
// }
// return null;
// }
// }
//
// Path: src/main/java/me/champeau/gradle/japicmp/report/stdrules/UnchangedMemberRule.java
// public class UnchangedMemberRule extends AbstractRecordingSeenMembers {
//
// @Override
// public Violation maybeAddViolation(final JApiCompatibility member) {
// Set<JApiCompatibility> seen = getContext().getUserData(RecordSeenMembersSetup.SEEN);
// seen.add(member);
// return null;
// }
// }
| import japicmp.model.JApiChangeStatus;
import japicmp.model.JApiClass;
import japicmp.model.JApiCompatibility;
import japicmp.model.JApiCompatibilityChange;
import japicmp.model.JApiConstructor;
import japicmp.model.JApiField;
import japicmp.model.JApiHasChangeStatus;
import japicmp.model.JApiImplementedInterface;
import japicmp.model.JApiMethod;
import me.champeau.gradle.japicmp.report.stdrules.BinaryIncompatibleRule;
import me.champeau.gradle.japicmp.report.stdrules.RecordSeenMembersSetup;
import me.champeau.gradle.japicmp.report.stdrules.SourceCompatibleRule;
import me.champeau.gradle.japicmp.report.stdrules.UnchangedMemberRule;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.regex.Pattern; | public Map<String, List<Violation>> toViolations(List<JApiClass> classes) {
addDefaultRuleIfNotConfigured();
Context ctx = new Context(violationTransformers);
for (SetupRule setupRule : setupRules) {
setupRule.execute(ctx);
}
injectContextIntoRules(ctx);
for (JApiClass aClass : classes) {
maybeProcess(aClass, ctx);
}
for (PostProcessViolationsRule postProcessViolationsRule : postProcessRules) {
postProcessViolationsRule.execute(ctx);
}
return ctx.violations;
}
private void addDefaultRuleIfNotConfigured() {
if (setupRules.isEmpty()
&& postProcessRules.isEmpty()
&& apiCompatibilityRules.isEmpty()
&& statusRules.isEmpty()
&& genericRules.isEmpty()) {
addDefaultRules();
}
}
public void addDefaultRules() {
setupRules.add(new RecordSeenMembersSetup());
addRule(JApiChangeStatus.NEW, new SourceCompatibleRule(Severity.info, "has been added in source compatible way"));
addRule(JApiChangeStatus.MODIFIED, new SourceCompatibleRule(Severity.info, "has been modified in source compatible way")); | // Path: src/main/java/me/champeau/gradle/japicmp/report/stdrules/BinaryIncompatibleRule.java
// public class BinaryIncompatibleRule extends AbstractRecordingSeenMembers {
// private final Severity severity;
//
// public BinaryIncompatibleRule(final Severity severity) {
// this.severity = severity;
// }
//
// public BinaryIncompatibleRule() {
// this(Severity.error);
// }
//
// @Override
// public Violation maybeAddViolation(final JApiCompatibility member) {
// if (!member.isBinaryCompatible()) {
// return Violation.notBinaryCompatible(member, severity);
// }
// return null;
// }
// }
//
// Path: src/main/java/me/champeau/gradle/japicmp/report/stdrules/RecordSeenMembersSetup.java
// public class RecordSeenMembersSetup implements SetupRule {
// static final String SEEN = RecordSeenMembersSetup.class.getName();
//
// @Override
// public void execute(final ViolationCheckContext violationCheckContext) {
// violationCheckContext.putUserData(SEEN, new HashSet<JApiCompatibility>());
// }
// }
//
// Path: src/main/java/me/champeau/gradle/japicmp/report/stdrules/SourceCompatibleRule.java
// public class SourceCompatibleRule extends AbstractRecordingSeenMembers {
// private final Severity severity;
// private final String message;
//
// public SourceCompatibleRule(final Severity severity, String message) {
// this.severity = severity;
// this.message = message;
// }
//
// public SourceCompatibleRule() {
// this(Severity.warning, "is source compatible");
// }
//
// @Override
// public Violation maybeAddViolation(final JApiCompatibility member) {
// if (member.isSourceCompatible()) {
// return Violation.any(member, severity, message);
// }
// return null;
// }
// }
//
// Path: src/main/java/me/champeau/gradle/japicmp/report/stdrules/UnchangedMemberRule.java
// public class UnchangedMemberRule extends AbstractRecordingSeenMembers {
//
// @Override
// public Violation maybeAddViolation(final JApiCompatibility member) {
// Set<JApiCompatibility> seen = getContext().getUserData(RecordSeenMembersSetup.SEEN);
// seen.add(member);
// return null;
// }
// }
// Path: src/main/java/me/champeau/gradle/japicmp/report/ViolationsGenerator.java
import japicmp.model.JApiChangeStatus;
import japicmp.model.JApiClass;
import japicmp.model.JApiCompatibility;
import japicmp.model.JApiCompatibilityChange;
import japicmp.model.JApiConstructor;
import japicmp.model.JApiField;
import japicmp.model.JApiHasChangeStatus;
import japicmp.model.JApiImplementedInterface;
import japicmp.model.JApiMethod;
import me.champeau.gradle.japicmp.report.stdrules.BinaryIncompatibleRule;
import me.champeau.gradle.japicmp.report.stdrules.RecordSeenMembersSetup;
import me.champeau.gradle.japicmp.report.stdrules.SourceCompatibleRule;
import me.champeau.gradle.japicmp.report.stdrules.UnchangedMemberRule;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.regex.Pattern;
public Map<String, List<Violation>> toViolations(List<JApiClass> classes) {
addDefaultRuleIfNotConfigured();
Context ctx = new Context(violationTransformers);
for (SetupRule setupRule : setupRules) {
setupRule.execute(ctx);
}
injectContextIntoRules(ctx);
for (JApiClass aClass : classes) {
maybeProcess(aClass, ctx);
}
for (PostProcessViolationsRule postProcessViolationsRule : postProcessRules) {
postProcessViolationsRule.execute(ctx);
}
return ctx.violations;
}
private void addDefaultRuleIfNotConfigured() {
if (setupRules.isEmpty()
&& postProcessRules.isEmpty()
&& apiCompatibilityRules.isEmpty()
&& statusRules.isEmpty()
&& genericRules.isEmpty()) {
addDefaultRules();
}
}
public void addDefaultRules() {
setupRules.add(new RecordSeenMembersSetup());
addRule(JApiChangeStatus.NEW, new SourceCompatibleRule(Severity.info, "has been added in source compatible way"));
addRule(JApiChangeStatus.MODIFIED, new SourceCompatibleRule(Severity.info, "has been modified in source compatible way")); | addRule(JApiChangeStatus.UNCHANGED, new UnchangedMemberRule()); |
melix/japicmp-gradle-plugin | src/main/java/me/champeau/gradle/japicmp/report/ViolationsGenerator.java | // Path: src/main/java/me/champeau/gradle/japicmp/report/stdrules/BinaryIncompatibleRule.java
// public class BinaryIncompatibleRule extends AbstractRecordingSeenMembers {
// private final Severity severity;
//
// public BinaryIncompatibleRule(final Severity severity) {
// this.severity = severity;
// }
//
// public BinaryIncompatibleRule() {
// this(Severity.error);
// }
//
// @Override
// public Violation maybeAddViolation(final JApiCompatibility member) {
// if (!member.isBinaryCompatible()) {
// return Violation.notBinaryCompatible(member, severity);
// }
// return null;
// }
// }
//
// Path: src/main/java/me/champeau/gradle/japicmp/report/stdrules/RecordSeenMembersSetup.java
// public class RecordSeenMembersSetup implements SetupRule {
// static final String SEEN = RecordSeenMembersSetup.class.getName();
//
// @Override
// public void execute(final ViolationCheckContext violationCheckContext) {
// violationCheckContext.putUserData(SEEN, new HashSet<JApiCompatibility>());
// }
// }
//
// Path: src/main/java/me/champeau/gradle/japicmp/report/stdrules/SourceCompatibleRule.java
// public class SourceCompatibleRule extends AbstractRecordingSeenMembers {
// private final Severity severity;
// private final String message;
//
// public SourceCompatibleRule(final Severity severity, String message) {
// this.severity = severity;
// this.message = message;
// }
//
// public SourceCompatibleRule() {
// this(Severity.warning, "is source compatible");
// }
//
// @Override
// public Violation maybeAddViolation(final JApiCompatibility member) {
// if (member.isSourceCompatible()) {
// return Violation.any(member, severity, message);
// }
// return null;
// }
// }
//
// Path: src/main/java/me/champeau/gradle/japicmp/report/stdrules/UnchangedMemberRule.java
// public class UnchangedMemberRule extends AbstractRecordingSeenMembers {
//
// @Override
// public Violation maybeAddViolation(final JApiCompatibility member) {
// Set<JApiCompatibility> seen = getContext().getUserData(RecordSeenMembersSetup.SEEN);
// seen.add(member);
// return null;
// }
// }
| import japicmp.model.JApiChangeStatus;
import japicmp.model.JApiClass;
import japicmp.model.JApiCompatibility;
import japicmp.model.JApiCompatibilityChange;
import japicmp.model.JApiConstructor;
import japicmp.model.JApiField;
import japicmp.model.JApiHasChangeStatus;
import japicmp.model.JApiImplementedInterface;
import japicmp.model.JApiMethod;
import me.champeau.gradle.japicmp.report.stdrules.BinaryIncompatibleRule;
import me.champeau.gradle.japicmp.report.stdrules.RecordSeenMembersSetup;
import me.champeau.gradle.japicmp.report.stdrules.SourceCompatibleRule;
import me.champeau.gradle.japicmp.report.stdrules.UnchangedMemberRule;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.regex.Pattern; | addDefaultRuleIfNotConfigured();
Context ctx = new Context(violationTransformers);
for (SetupRule setupRule : setupRules) {
setupRule.execute(ctx);
}
injectContextIntoRules(ctx);
for (JApiClass aClass : classes) {
maybeProcess(aClass, ctx);
}
for (PostProcessViolationsRule postProcessViolationsRule : postProcessRules) {
postProcessViolationsRule.execute(ctx);
}
return ctx.violations;
}
private void addDefaultRuleIfNotConfigured() {
if (setupRules.isEmpty()
&& postProcessRules.isEmpty()
&& apiCompatibilityRules.isEmpty()
&& statusRules.isEmpty()
&& genericRules.isEmpty()) {
addDefaultRules();
}
}
public void addDefaultRules() {
setupRules.add(new RecordSeenMembersSetup());
addRule(JApiChangeStatus.NEW, new SourceCompatibleRule(Severity.info, "has been added in source compatible way"));
addRule(JApiChangeStatus.MODIFIED, new SourceCompatibleRule(Severity.info, "has been modified in source compatible way"));
addRule(JApiChangeStatus.UNCHANGED, new UnchangedMemberRule()); | // Path: src/main/java/me/champeau/gradle/japicmp/report/stdrules/BinaryIncompatibleRule.java
// public class BinaryIncompatibleRule extends AbstractRecordingSeenMembers {
// private final Severity severity;
//
// public BinaryIncompatibleRule(final Severity severity) {
// this.severity = severity;
// }
//
// public BinaryIncompatibleRule() {
// this(Severity.error);
// }
//
// @Override
// public Violation maybeAddViolation(final JApiCompatibility member) {
// if (!member.isBinaryCompatible()) {
// return Violation.notBinaryCompatible(member, severity);
// }
// return null;
// }
// }
//
// Path: src/main/java/me/champeau/gradle/japicmp/report/stdrules/RecordSeenMembersSetup.java
// public class RecordSeenMembersSetup implements SetupRule {
// static final String SEEN = RecordSeenMembersSetup.class.getName();
//
// @Override
// public void execute(final ViolationCheckContext violationCheckContext) {
// violationCheckContext.putUserData(SEEN, new HashSet<JApiCompatibility>());
// }
// }
//
// Path: src/main/java/me/champeau/gradle/japicmp/report/stdrules/SourceCompatibleRule.java
// public class SourceCompatibleRule extends AbstractRecordingSeenMembers {
// private final Severity severity;
// private final String message;
//
// public SourceCompatibleRule(final Severity severity, String message) {
// this.severity = severity;
// this.message = message;
// }
//
// public SourceCompatibleRule() {
// this(Severity.warning, "is source compatible");
// }
//
// @Override
// public Violation maybeAddViolation(final JApiCompatibility member) {
// if (member.isSourceCompatible()) {
// return Violation.any(member, severity, message);
// }
// return null;
// }
// }
//
// Path: src/main/java/me/champeau/gradle/japicmp/report/stdrules/UnchangedMemberRule.java
// public class UnchangedMemberRule extends AbstractRecordingSeenMembers {
//
// @Override
// public Violation maybeAddViolation(final JApiCompatibility member) {
// Set<JApiCompatibility> seen = getContext().getUserData(RecordSeenMembersSetup.SEEN);
// seen.add(member);
// return null;
// }
// }
// Path: src/main/java/me/champeau/gradle/japicmp/report/ViolationsGenerator.java
import japicmp.model.JApiChangeStatus;
import japicmp.model.JApiClass;
import japicmp.model.JApiCompatibility;
import japicmp.model.JApiCompatibilityChange;
import japicmp.model.JApiConstructor;
import japicmp.model.JApiField;
import japicmp.model.JApiHasChangeStatus;
import japicmp.model.JApiImplementedInterface;
import japicmp.model.JApiMethod;
import me.champeau.gradle.japicmp.report.stdrules.BinaryIncompatibleRule;
import me.champeau.gradle.japicmp.report.stdrules.RecordSeenMembersSetup;
import me.champeau.gradle.japicmp.report.stdrules.SourceCompatibleRule;
import me.champeau.gradle.japicmp.report.stdrules.UnchangedMemberRule;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.regex.Pattern;
addDefaultRuleIfNotConfigured();
Context ctx = new Context(violationTransformers);
for (SetupRule setupRule : setupRules) {
setupRule.execute(ctx);
}
injectContextIntoRules(ctx);
for (JApiClass aClass : classes) {
maybeProcess(aClass, ctx);
}
for (PostProcessViolationsRule postProcessViolationsRule : postProcessRules) {
postProcessViolationsRule.execute(ctx);
}
return ctx.violations;
}
private void addDefaultRuleIfNotConfigured() {
if (setupRules.isEmpty()
&& postProcessRules.isEmpty()
&& apiCompatibilityRules.isEmpty()
&& statusRules.isEmpty()
&& genericRules.isEmpty()) {
addDefaultRules();
}
}
public void addDefaultRules() {
setupRules.add(new RecordSeenMembersSetup());
addRule(JApiChangeStatus.NEW, new SourceCompatibleRule(Severity.info, "has been added in source compatible way"));
addRule(JApiChangeStatus.MODIFIED, new SourceCompatibleRule(Severity.info, "has been modified in source compatible way"));
addRule(JApiChangeStatus.UNCHANGED, new UnchangedMemberRule()); | genericRules.add(new BinaryIncompatibleRule()); |
Furkanzmc/qutils | android/src/org/zmc/qutils/TimePickerFragment.java | // Path: android/src/org/zmc/qutils/CppCallbacks.java
// public class CppCallbacks
// {
// public static native void notificationReceived(String tag, int id, String notificationManagerName);
// public static native void backButtonPressed();
// public static native void menuButtonPressed();
//
// // If an item is clicked, item index will be non-zero and buttonType will be -3
// public static native void alertDialogClicked(int buttonType, int itemIndex);
// // If all of the dates are -1, then the datePickerCancelled signal is emitted.
// public static native void datePicked(int year, int month, int day);
// // If all of the parameters are -1, then the timePickerCancelled signal is emitted.
// public static native void timePicked(int hourOfDay, int minute);
//
// public static native void cameraCaptured(String capturePath);
// }
//
// Path: android/src/org/zmc/qutils/QutilsActivity.java
// public class QutilsActivity extends QtActivity
// {
// private static QutilsActivity m_Instance;
// protected static NotificationClient m_NotificationClient;
// protected static AndroidUtils m_AndroidUtils;
//
// protected static boolean m_IsImmersiveModeEnabled = false;
// protected static boolean m_IsStatusBarVisible = true;
// public static HashMap m_CustomData;
//
// public QutilsActivity()
// {
// m_Instance = this;
// m_CustomData = new HashMap();
// }
//
// @Override
// public void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// m_NotificationClient = new NotificationClient(this);
// m_AndroidUtils = new AndroidUtils(this);
// }
//
// @Override
// public void onResume() {
// super.onResume();
//
// Intent in = getIntent();
// String tag = in.getStringExtra(NotificationReceiver.KEY_NOTIFICATION_TAG);
// String notificationManagerName = in.getStringExtra(NotificationReceiver.KEY_NOTIFICATION_MANAGER);
// int id = in.getIntExtra(NotificationReceiver.KEY_NOTIFICATION_ID, -1);
// if (id > -1) {
// CppCallbacks.notificationReceived(tag, 0, notificationManagerName);
// }
// }
//
// @Override
// public void onWindowFocusChanged(boolean hasFocus) {
// super.onWindowFocusChanged(hasFocus);
// if (hasFocus) {
// if (m_IsImmersiveModeEnabled) {
// m_AndroidUtils.setImmersiveMode(true);
// }
//
// if (m_IsStatusBarVisible == false) {
// m_AndroidUtils.setStatusBarVisible(false);
// }
// }
// }
//
// @Override
// protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// super.onActivityResult(requestCode, resultCode, data);
// // TODO: 1 is the request for camera capture. Put this number in a class for easy access.
// if (requestCode == 1 && resultCode == RESULT_OK) {
// CppCallbacks.cameraCaptured((String)getCustomData("capture_save_path"));
// removeCustomData("capture_save_path");
// }
// }
//
// public static void setImmersiveModeEnabled(boolean enabled)
// {
// m_IsImmersiveModeEnabled = enabled;
// }
//
// public static void setStatusBarVisible(boolean visible)
// {
// m_IsStatusBarVisible = visible;
// }
//
// @Override
// public boolean onKeyUp(int keyCode, KeyEvent event) {
// if (keyCode == KeyEvent.KEYCODE_BACK) {
// CppCallbacks.backButtonPressed();
// }
// else if (keyCode == KeyEvent.KEYCODE_MENU) {
// CppCallbacks.menuButtonPressed();
// }
//
// return super.onKeyUp(keyCode, event);
// }
//
// public static void setCustomData(String key, Object value)
// {
// m_CustomData.put(key, value);
// }
//
// public static Object getCustomData(String key)
// {
// return m_CustomData.get(key);
// }
//
// public static void removeCustomData(String key)
// {
// m_CustomData.remove(key);
// }
// }
| import android.app.DialogFragment;
import android.app.Dialog;
import android.os.Bundle;
import android.app.TimePickerDialog;
import android.widget.TimePicker;
import android.content.DialogInterface;
import java.util.Calendar;
import java.text.DateFormat;
import org.zmc.qutils.notification.CppCallbacks;
import org.zmc.qutils.QutilsActivity; | package org.zmc.qutils;
// qutils
public class TimePickerFragment extends DialogFragment implements TimePickerDialog.OnTimeSetListener {
private static QutilsActivity m_MainContext;
public TimePickerFragment(QutilsActivity mainActivity)
{
m_MainContext = mainActivity;
}
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
// Use the current time as the default values for the picker
final Calendar c = Calendar.getInstance();
int hour = c.get(Calendar.HOUR_OF_DAY);
int minute = c.get(Calendar.MINUTE);
// Create a new instance of TimePickerDialog and return it
return new TimePickerDialog(m_MainContext, this, hour, minute, true);
}
public void onTimeSet(TimePicker view, int hourOfDay, int minute) { | // Path: android/src/org/zmc/qutils/CppCallbacks.java
// public class CppCallbacks
// {
// public static native void notificationReceived(String tag, int id, String notificationManagerName);
// public static native void backButtonPressed();
// public static native void menuButtonPressed();
//
// // If an item is clicked, item index will be non-zero and buttonType will be -3
// public static native void alertDialogClicked(int buttonType, int itemIndex);
// // If all of the dates are -1, then the datePickerCancelled signal is emitted.
// public static native void datePicked(int year, int month, int day);
// // If all of the parameters are -1, then the timePickerCancelled signal is emitted.
// public static native void timePicked(int hourOfDay, int minute);
//
// public static native void cameraCaptured(String capturePath);
// }
//
// Path: android/src/org/zmc/qutils/QutilsActivity.java
// public class QutilsActivity extends QtActivity
// {
// private static QutilsActivity m_Instance;
// protected static NotificationClient m_NotificationClient;
// protected static AndroidUtils m_AndroidUtils;
//
// protected static boolean m_IsImmersiveModeEnabled = false;
// protected static boolean m_IsStatusBarVisible = true;
// public static HashMap m_CustomData;
//
// public QutilsActivity()
// {
// m_Instance = this;
// m_CustomData = new HashMap();
// }
//
// @Override
// public void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// m_NotificationClient = new NotificationClient(this);
// m_AndroidUtils = new AndroidUtils(this);
// }
//
// @Override
// public void onResume() {
// super.onResume();
//
// Intent in = getIntent();
// String tag = in.getStringExtra(NotificationReceiver.KEY_NOTIFICATION_TAG);
// String notificationManagerName = in.getStringExtra(NotificationReceiver.KEY_NOTIFICATION_MANAGER);
// int id = in.getIntExtra(NotificationReceiver.KEY_NOTIFICATION_ID, -1);
// if (id > -1) {
// CppCallbacks.notificationReceived(tag, 0, notificationManagerName);
// }
// }
//
// @Override
// public void onWindowFocusChanged(boolean hasFocus) {
// super.onWindowFocusChanged(hasFocus);
// if (hasFocus) {
// if (m_IsImmersiveModeEnabled) {
// m_AndroidUtils.setImmersiveMode(true);
// }
//
// if (m_IsStatusBarVisible == false) {
// m_AndroidUtils.setStatusBarVisible(false);
// }
// }
// }
//
// @Override
// protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// super.onActivityResult(requestCode, resultCode, data);
// // TODO: 1 is the request for camera capture. Put this number in a class for easy access.
// if (requestCode == 1 && resultCode == RESULT_OK) {
// CppCallbacks.cameraCaptured((String)getCustomData("capture_save_path"));
// removeCustomData("capture_save_path");
// }
// }
//
// public static void setImmersiveModeEnabled(boolean enabled)
// {
// m_IsImmersiveModeEnabled = enabled;
// }
//
// public static void setStatusBarVisible(boolean visible)
// {
// m_IsStatusBarVisible = visible;
// }
//
// @Override
// public boolean onKeyUp(int keyCode, KeyEvent event) {
// if (keyCode == KeyEvent.KEYCODE_BACK) {
// CppCallbacks.backButtonPressed();
// }
// else if (keyCode == KeyEvent.KEYCODE_MENU) {
// CppCallbacks.menuButtonPressed();
// }
//
// return super.onKeyUp(keyCode, event);
// }
//
// public static void setCustomData(String key, Object value)
// {
// m_CustomData.put(key, value);
// }
//
// public static Object getCustomData(String key)
// {
// return m_CustomData.get(key);
// }
//
// public static void removeCustomData(String key)
// {
// m_CustomData.remove(key);
// }
// }
// Path: android/src/org/zmc/qutils/TimePickerFragment.java
import android.app.DialogFragment;
import android.app.Dialog;
import android.os.Bundle;
import android.app.TimePickerDialog;
import android.widget.TimePicker;
import android.content.DialogInterface;
import java.util.Calendar;
import java.text.DateFormat;
import org.zmc.qutils.notification.CppCallbacks;
import org.zmc.qutils.QutilsActivity;
package org.zmc.qutils;
// qutils
public class TimePickerFragment extends DialogFragment implements TimePickerDialog.OnTimeSetListener {
private static QutilsActivity m_MainContext;
public TimePickerFragment(QutilsActivity mainActivity)
{
m_MainContext = mainActivity;
}
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
// Use the current time as the default values for the picker
final Calendar c = Calendar.getInstance();
int hour = c.get(Calendar.HOUR_OF_DAY);
int minute = c.get(Calendar.MINUTE);
// Create a new instance of TimePickerDialog and return it
return new TimePickerDialog(m_MainContext, this, hour, minute, true);
}
public void onTimeSet(TimePicker view, int hourOfDay, int minute) { | CppCallbacks.timePicked(hourOfDay, minute); |
Furkanzmc/qutils | android/src/org/zmc/qutils/DatePickerFragment.java | // Path: android/src/org/zmc/qutils/CppCallbacks.java
// public class CppCallbacks
// {
// public static native void notificationReceived(String tag, int id, String notificationManagerName);
// public static native void backButtonPressed();
// public static native void menuButtonPressed();
//
// // If an item is clicked, item index will be non-zero and buttonType will be -3
// public static native void alertDialogClicked(int buttonType, int itemIndex);
// // If all of the dates are -1, then the datePickerCancelled signal is emitted.
// public static native void datePicked(int year, int month, int day);
// // If all of the parameters are -1, then the timePickerCancelled signal is emitted.
// public static native void timePicked(int hourOfDay, int minute);
//
// public static native void cameraCaptured(String capturePath);
// }
//
// Path: android/src/org/zmc/qutils/QutilsActivity.java
// public class QutilsActivity extends QtActivity
// {
// private static QutilsActivity m_Instance;
// protected static NotificationClient m_NotificationClient;
// protected static AndroidUtils m_AndroidUtils;
//
// protected static boolean m_IsImmersiveModeEnabled = false;
// protected static boolean m_IsStatusBarVisible = true;
// public static HashMap m_CustomData;
//
// public QutilsActivity()
// {
// m_Instance = this;
// m_CustomData = new HashMap();
// }
//
// @Override
// public void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// m_NotificationClient = new NotificationClient(this);
// m_AndroidUtils = new AndroidUtils(this);
// }
//
// @Override
// public void onResume() {
// super.onResume();
//
// Intent in = getIntent();
// String tag = in.getStringExtra(NotificationReceiver.KEY_NOTIFICATION_TAG);
// String notificationManagerName = in.getStringExtra(NotificationReceiver.KEY_NOTIFICATION_MANAGER);
// int id = in.getIntExtra(NotificationReceiver.KEY_NOTIFICATION_ID, -1);
// if (id > -1) {
// CppCallbacks.notificationReceived(tag, 0, notificationManagerName);
// }
// }
//
// @Override
// public void onWindowFocusChanged(boolean hasFocus) {
// super.onWindowFocusChanged(hasFocus);
// if (hasFocus) {
// if (m_IsImmersiveModeEnabled) {
// m_AndroidUtils.setImmersiveMode(true);
// }
//
// if (m_IsStatusBarVisible == false) {
// m_AndroidUtils.setStatusBarVisible(false);
// }
// }
// }
//
// @Override
// protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// super.onActivityResult(requestCode, resultCode, data);
// // TODO: 1 is the request for camera capture. Put this number in a class for easy access.
// if (requestCode == 1 && resultCode == RESULT_OK) {
// CppCallbacks.cameraCaptured((String)getCustomData("capture_save_path"));
// removeCustomData("capture_save_path");
// }
// }
//
// public static void setImmersiveModeEnabled(boolean enabled)
// {
// m_IsImmersiveModeEnabled = enabled;
// }
//
// public static void setStatusBarVisible(boolean visible)
// {
// m_IsStatusBarVisible = visible;
// }
//
// @Override
// public boolean onKeyUp(int keyCode, KeyEvent event) {
// if (keyCode == KeyEvent.KEYCODE_BACK) {
// CppCallbacks.backButtonPressed();
// }
// else if (keyCode == KeyEvent.KEYCODE_MENU) {
// CppCallbacks.menuButtonPressed();
// }
//
// return super.onKeyUp(keyCode, event);
// }
//
// public static void setCustomData(String key, Object value)
// {
// m_CustomData.put(key, value);
// }
//
// public static Object getCustomData(String key)
// {
// return m_CustomData.get(key);
// }
//
// public static void removeCustomData(String key)
// {
// m_CustomData.remove(key);
// }
// }
| import android.app.DialogFragment;
import android.app.Dialog;
import android.os.Bundle;
import android.app.DatePickerDialog;
import android.widget.DatePicker;
import android.content.DialogInterface;
import java.util.Calendar;
import org.zmc.qutils.notification.CppCallbacks;
import org.zmc.qutils.QutilsActivity; | package org.zmc.qutils;
// qutils
public class DatePickerFragment extends DialogFragment implements DatePickerDialog.OnDateSetListener {
private static QutilsActivity m_MainContext;
public DatePickerFragment(QutilsActivity mainActivity)
{
m_MainContext = mainActivity;
}
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
// Use the current date as the default date in the picker
final Calendar c = Calendar.getInstance();
int year = c.get(Calendar.YEAR);
int month = c.get(Calendar.MONTH);
int day = c.get(Calendar.DAY_OF_MONTH);
// Create a new instance of DatePickerDialog and return it
DatePickerDialog dialog = new DatePickerDialog(m_MainContext, this, year, month, day);
return dialog;
}
public void onDateSet(DatePicker view, int year, int month, int day) { | // Path: android/src/org/zmc/qutils/CppCallbacks.java
// public class CppCallbacks
// {
// public static native void notificationReceived(String tag, int id, String notificationManagerName);
// public static native void backButtonPressed();
// public static native void menuButtonPressed();
//
// // If an item is clicked, item index will be non-zero and buttonType will be -3
// public static native void alertDialogClicked(int buttonType, int itemIndex);
// // If all of the dates are -1, then the datePickerCancelled signal is emitted.
// public static native void datePicked(int year, int month, int day);
// // If all of the parameters are -1, then the timePickerCancelled signal is emitted.
// public static native void timePicked(int hourOfDay, int minute);
//
// public static native void cameraCaptured(String capturePath);
// }
//
// Path: android/src/org/zmc/qutils/QutilsActivity.java
// public class QutilsActivity extends QtActivity
// {
// private static QutilsActivity m_Instance;
// protected static NotificationClient m_NotificationClient;
// protected static AndroidUtils m_AndroidUtils;
//
// protected static boolean m_IsImmersiveModeEnabled = false;
// protected static boolean m_IsStatusBarVisible = true;
// public static HashMap m_CustomData;
//
// public QutilsActivity()
// {
// m_Instance = this;
// m_CustomData = new HashMap();
// }
//
// @Override
// public void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// m_NotificationClient = new NotificationClient(this);
// m_AndroidUtils = new AndroidUtils(this);
// }
//
// @Override
// public void onResume() {
// super.onResume();
//
// Intent in = getIntent();
// String tag = in.getStringExtra(NotificationReceiver.KEY_NOTIFICATION_TAG);
// String notificationManagerName = in.getStringExtra(NotificationReceiver.KEY_NOTIFICATION_MANAGER);
// int id = in.getIntExtra(NotificationReceiver.KEY_NOTIFICATION_ID, -1);
// if (id > -1) {
// CppCallbacks.notificationReceived(tag, 0, notificationManagerName);
// }
// }
//
// @Override
// public void onWindowFocusChanged(boolean hasFocus) {
// super.onWindowFocusChanged(hasFocus);
// if (hasFocus) {
// if (m_IsImmersiveModeEnabled) {
// m_AndroidUtils.setImmersiveMode(true);
// }
//
// if (m_IsStatusBarVisible == false) {
// m_AndroidUtils.setStatusBarVisible(false);
// }
// }
// }
//
// @Override
// protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// super.onActivityResult(requestCode, resultCode, data);
// // TODO: 1 is the request for camera capture. Put this number in a class for easy access.
// if (requestCode == 1 && resultCode == RESULT_OK) {
// CppCallbacks.cameraCaptured((String)getCustomData("capture_save_path"));
// removeCustomData("capture_save_path");
// }
// }
//
// public static void setImmersiveModeEnabled(boolean enabled)
// {
// m_IsImmersiveModeEnabled = enabled;
// }
//
// public static void setStatusBarVisible(boolean visible)
// {
// m_IsStatusBarVisible = visible;
// }
//
// @Override
// public boolean onKeyUp(int keyCode, KeyEvent event) {
// if (keyCode == KeyEvent.KEYCODE_BACK) {
// CppCallbacks.backButtonPressed();
// }
// else if (keyCode == KeyEvent.KEYCODE_MENU) {
// CppCallbacks.menuButtonPressed();
// }
//
// return super.onKeyUp(keyCode, event);
// }
//
// public static void setCustomData(String key, Object value)
// {
// m_CustomData.put(key, value);
// }
//
// public static Object getCustomData(String key)
// {
// return m_CustomData.get(key);
// }
//
// public static void removeCustomData(String key)
// {
// m_CustomData.remove(key);
// }
// }
// Path: android/src/org/zmc/qutils/DatePickerFragment.java
import android.app.DialogFragment;
import android.app.Dialog;
import android.os.Bundle;
import android.app.DatePickerDialog;
import android.widget.DatePicker;
import android.content.DialogInterface;
import java.util.Calendar;
import org.zmc.qutils.notification.CppCallbacks;
import org.zmc.qutils.QutilsActivity;
package org.zmc.qutils;
// qutils
public class DatePickerFragment extends DialogFragment implements DatePickerDialog.OnDateSetListener {
private static QutilsActivity m_MainContext;
public DatePickerFragment(QutilsActivity mainActivity)
{
m_MainContext = mainActivity;
}
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
// Use the current date as the default date in the picker
final Calendar c = Calendar.getInstance();
int year = c.get(Calendar.YEAR);
int month = c.get(Calendar.MONTH);
int day = c.get(Calendar.DAY_OF_MONTH);
// Create a new instance of DatePickerDialog and return it
DatePickerDialog dialog = new DatePickerDialog(m_MainContext, this, year, month, day);
return dialog;
}
public void onDateSet(DatePicker view, int year, int month, int day) { | CppCallbacks.datePicked(year, month, day); |
KDE/kdeconnect-android | src/org/kde/kdeconnect/Plugins/NotificationsPlugin/NotificationFilterActivity.java | // Path: src/org/kde/kdeconnect/UserInterface/ThemeUtil.java
// public class ThemeUtil {
//
// public static final String LIGHT_MODE = "light";
// public static final String DARK_MODE = "dark";
// public static final String DEFAULT_MODE = "default";
//
// public static void applyTheme(@NonNull String themePref) {
// switch (themePref) {
// case LIGHT_MODE: {
// AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
// break;
// }
// case DARK_MODE: {
// AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
// break;
// }
// default: {
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
// AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM);
// } else {
// AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_AUTO_BATTERY);
// }
// break;
// }
// }
// }
//
// /**
// * Called when an activity is created for the first time to reliably load correct theme.
// **/
// public static void setUserPreferredTheme(Activity activity) {
// String appTheme = PreferenceManager.getDefaultSharedPreferences(activity)
// .getString("theme_pref", DEFAULT_MODE);
// applyTheme(appTheme);
// }
// }
| import android.content.Context;
import android.content.SharedPreferences;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.BaseAdapter;
import android.widget.CheckBox;
import android.widget.CheckedTextView;
import android.widget.CompoundButton;
import android.widget.ListView;
import org.kde.kdeconnect.UserInterface.ThemeUtil;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.widget.TextViewCompat;
import com.google.android.material.switchmaterial.SwitchMaterial;
import org.kde.kdeconnect_tp.R;
import org.kde.kdeconnect_tp.databinding.ActivityNotificationFilterBinding;
import java.util.Arrays;
import java.util.List;
import java.util.Objects; | }
@Override
public long getItemId(int position) {
return position - 1;
}
public View getView(int position, View view, ViewGroup parent) {
if (view == null) {
LayoutInflater inflater = getLayoutInflater();
view = inflater.inflate(android.R.layout.simple_list_item_multiple_choice, null, true);
}
CheckedTextView checkedTextView = (CheckedTextView) view;
if (position == 0) {
checkedTextView.setText(R.string.all);
TextViewCompat.setCompoundDrawablesRelativeWithIntrinsicBounds(checkedTextView, null, null, null, null);
} else {
checkedTextView.setText(apps[position - 1].name);
TextViewCompat.setCompoundDrawablesRelativeWithIntrinsicBounds(checkedTextView, apps[position - 1].icon, null, null, null);
checkedTextView.setCompoundDrawablePadding((int) (8 * getResources().getDisplayMetrics().density));
}
return view;
}
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); | // Path: src/org/kde/kdeconnect/UserInterface/ThemeUtil.java
// public class ThemeUtil {
//
// public static final String LIGHT_MODE = "light";
// public static final String DARK_MODE = "dark";
// public static final String DEFAULT_MODE = "default";
//
// public static void applyTheme(@NonNull String themePref) {
// switch (themePref) {
// case LIGHT_MODE: {
// AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
// break;
// }
// case DARK_MODE: {
// AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
// break;
// }
// default: {
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
// AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM);
// } else {
// AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_AUTO_BATTERY);
// }
// break;
// }
// }
// }
//
// /**
// * Called when an activity is created for the first time to reliably load correct theme.
// **/
// public static void setUserPreferredTheme(Activity activity) {
// String appTheme = PreferenceManager.getDefaultSharedPreferences(activity)
// .getString("theme_pref", DEFAULT_MODE);
// applyTheme(appTheme);
// }
// }
// Path: src/org/kde/kdeconnect/Plugins/NotificationsPlugin/NotificationFilterActivity.java
import android.content.Context;
import android.content.SharedPreferences;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.BaseAdapter;
import android.widget.CheckBox;
import android.widget.CheckedTextView;
import android.widget.CompoundButton;
import android.widget.ListView;
import org.kde.kdeconnect.UserInterface.ThemeUtil;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.widget.TextViewCompat;
import com.google.android.material.switchmaterial.SwitchMaterial;
import org.kde.kdeconnect_tp.R;
import org.kde.kdeconnect_tp.databinding.ActivityNotificationFilterBinding;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
}
@Override
public long getItemId(int position) {
return position - 1;
}
public View getView(int position, View view, ViewGroup parent) {
if (view == null) {
LayoutInflater inflater = getLayoutInflater();
view = inflater.inflate(android.R.layout.simple_list_item_multiple_choice, null, true);
}
CheckedTextView checkedTextView = (CheckedTextView) view;
if (position == 0) {
checkedTextView.setText(R.string.all);
TextViewCompat.setCompoundDrawablesRelativeWithIntrinsicBounds(checkedTextView, null, null, null, null);
} else {
checkedTextView.setText(apps[position - 1].name);
TextViewCompat.setCompoundDrawablesRelativeWithIntrinsicBounds(checkedTextView, apps[position - 1].icon, null, null, null);
checkedTextView.setCompoundDrawablePadding((int) (8 * getResources().getDisplayMetrics().density));
}
return view;
}
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); | ThemeUtil.setUserPreferredTheme(this); |
KDE/kdeconnect-android | src/org/kde/kdeconnect/Plugins/FindMyPhonePlugin/FindMyPhonePlugin.java | // Path: src/org/kde/kdeconnect/Helpers/NotificationHelper.java
// public class NotificationHelper {
//
// public static class Channels {
// public final static String PERSISTENT = "persistent";
// public final static String DEFAULT = "default";
// public final static String MEDIA_CONTROL = "media_control";
// public final static String FILETRANSFER = "filetransfer";
// public final static String SMS_MMS = "sms_mms";
// public final static String RECEIVENOTIFICATION = "receive";
// public final static String HIGHPRIORITY = "highpriority";
// }
//
// public static void notifyCompat(NotificationManager notificationManager, int notificationId, Notification notification) {
// try {
// notificationManager.notify(notificationId, notification);
// } catch (Exception e) {
// //4.1 will throw an exception about not having the VIBRATE permission, ignore it.
// //https://android.googlesource.com/platform/frameworks/base/+/android-4.2.1_r1.2%5E%5E!/
// }
// }
//
// public static void notifyCompat(NotificationManager notificationManager, String tag, int notificationId, Notification notification) {
// try {
// notificationManager.notify(tag, notificationId, notification);
// } catch (Exception e) {
// //4.1 will throw an exception about not having the VIBRATE permission, ignore it.
// //https://android.googlesource.com/platform/frameworks/base/+/android-4.2.1_r1.2%5E%5E!/
// }
// }
//
// public static void initializeChannels(Context context) {
//
// if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.O) {
// return;
// }
//
// NotificationManager manager = ContextCompat.getSystemService(context, NotificationManager.class);
//
// NotificationChannel persistentChannel = new NotificationChannel(
// Channels.PERSISTENT,
// context.getString(R.string.notification_channel_persistent),
// NotificationManager.IMPORTANCE_MIN);
//
// manager.createNotificationChannel(persistentChannel);
//
// manager.createNotificationChannel(new NotificationChannel(
// Channels.DEFAULT,
// context.getString(R.string.notification_channel_default),
// NotificationManager.IMPORTANCE_DEFAULT)
// );
//
// manager.createNotificationChannel(new NotificationChannel(
// Channels.MEDIA_CONTROL,
// context.getString(R.string.notification_channel_media_control),
// NotificationManager.IMPORTANCE_LOW)
// );
//
// NotificationChannel fileTransfer = new NotificationChannel(
// Channels.FILETRANSFER,
// context.getString(R.string.notification_channel_filetransfer),
// NotificationManager.IMPORTANCE_LOW);
//
// fileTransfer.enableVibration(false);
//
// manager.createNotificationChannel(fileTransfer);
//
// manager.createNotificationChannel(new NotificationChannel(
// Channels.RECEIVENOTIFICATION,
// context.getString(R.string.notification_channel_receivenotification),
// NotificationManager.IMPORTANCE_DEFAULT)
// );
//
// manager.createNotificationChannel(new NotificationChannel(
// Channels.SMS_MMS,
// context.getString(R.string.notification_channel_sms_mms),
// NotificationManager.IMPORTANCE_DEFAULT)
// );
//
// NotificationChannel highPriority = new NotificationChannel(Channels.HIGHPRIORITY, context.getString(R.string.notification_channel_high_priority), NotificationManager.IMPORTANCE_HIGH);
// manager.createNotificationChannel(highPriority);
// }
//
//
// public static void setPersistentNotificationEnabled(Context context, boolean enabled) {
// SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
// prefs.edit().putBoolean("persistentNotification", enabled).apply();
// }
//
// public static boolean isPersistentNotificationEnabled(Context context) {
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
// return true;
// }
// SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
// return prefs.getBoolean("persistentNotification", false);
// }
//
// }
| import android.app.Activity;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Intent;
import android.content.SharedPreferences;
import android.media.AudioManager;
import android.media.MediaPlayer;
import android.net.Uri;
import android.os.Build;
import android.os.PowerManager;
import android.preference.PreferenceManager;
import android.provider.Settings;
import android.util.Log;
import androidx.annotation.RequiresApi;
import androidx.core.app.NotificationCompat;
import androidx.core.content.ContextCompat;
import org.apache.commons.lang3.ArrayUtils;
import org.kde.kdeconnect.Helpers.DeviceHelper;
import org.kde.kdeconnect.Helpers.NotificationHelper;
import org.kde.kdeconnect.MyApplication;
import org.kde.kdeconnect.NetworkPacket;
import org.kde.kdeconnect.Plugins.Plugin;
import org.kde.kdeconnect.Plugins.PluginFactory;
import org.kde.kdeconnect.UserInterface.PluginSettingsFragment;
import org.kde.kdeconnect_tp.R;
import java.io.IOException; | showBroadcastNotification();
} else {
showActivityNotification();
}
}
return true;
}
@RequiresApi(16)
private void showBroadcastNotification() {
Intent intent = new Intent(context, FindMyPhoneReceiver.class);
intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
intent.setAction(FindMyPhoneReceiver.ACTION_FOUND_IT);
intent.putExtra(FindMyPhoneReceiver.EXTRA_DEVICE_ID, device.getDeviceId());
PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
createNotification(pendingIntent);
}
private void showActivityNotification() {
Intent intent = new Intent(context, FindMyPhoneActivity.class);
intent.putExtra(FindMyPhoneActivity.EXTRA_DEVICE_ID, device.getDeviceId());
PendingIntent pi = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
createNotification(pi);
}
private void createNotification(PendingIntent pendingIntent) { | // Path: src/org/kde/kdeconnect/Helpers/NotificationHelper.java
// public class NotificationHelper {
//
// public static class Channels {
// public final static String PERSISTENT = "persistent";
// public final static String DEFAULT = "default";
// public final static String MEDIA_CONTROL = "media_control";
// public final static String FILETRANSFER = "filetransfer";
// public final static String SMS_MMS = "sms_mms";
// public final static String RECEIVENOTIFICATION = "receive";
// public final static String HIGHPRIORITY = "highpriority";
// }
//
// public static void notifyCompat(NotificationManager notificationManager, int notificationId, Notification notification) {
// try {
// notificationManager.notify(notificationId, notification);
// } catch (Exception e) {
// //4.1 will throw an exception about not having the VIBRATE permission, ignore it.
// //https://android.googlesource.com/platform/frameworks/base/+/android-4.2.1_r1.2%5E%5E!/
// }
// }
//
// public static void notifyCompat(NotificationManager notificationManager, String tag, int notificationId, Notification notification) {
// try {
// notificationManager.notify(tag, notificationId, notification);
// } catch (Exception e) {
// //4.1 will throw an exception about not having the VIBRATE permission, ignore it.
// //https://android.googlesource.com/platform/frameworks/base/+/android-4.2.1_r1.2%5E%5E!/
// }
// }
//
// public static void initializeChannels(Context context) {
//
// if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.O) {
// return;
// }
//
// NotificationManager manager = ContextCompat.getSystemService(context, NotificationManager.class);
//
// NotificationChannel persistentChannel = new NotificationChannel(
// Channels.PERSISTENT,
// context.getString(R.string.notification_channel_persistent),
// NotificationManager.IMPORTANCE_MIN);
//
// manager.createNotificationChannel(persistentChannel);
//
// manager.createNotificationChannel(new NotificationChannel(
// Channels.DEFAULT,
// context.getString(R.string.notification_channel_default),
// NotificationManager.IMPORTANCE_DEFAULT)
// );
//
// manager.createNotificationChannel(new NotificationChannel(
// Channels.MEDIA_CONTROL,
// context.getString(R.string.notification_channel_media_control),
// NotificationManager.IMPORTANCE_LOW)
// );
//
// NotificationChannel fileTransfer = new NotificationChannel(
// Channels.FILETRANSFER,
// context.getString(R.string.notification_channel_filetransfer),
// NotificationManager.IMPORTANCE_LOW);
//
// fileTransfer.enableVibration(false);
//
// manager.createNotificationChannel(fileTransfer);
//
// manager.createNotificationChannel(new NotificationChannel(
// Channels.RECEIVENOTIFICATION,
// context.getString(R.string.notification_channel_receivenotification),
// NotificationManager.IMPORTANCE_DEFAULT)
// );
//
// manager.createNotificationChannel(new NotificationChannel(
// Channels.SMS_MMS,
// context.getString(R.string.notification_channel_sms_mms),
// NotificationManager.IMPORTANCE_DEFAULT)
// );
//
// NotificationChannel highPriority = new NotificationChannel(Channels.HIGHPRIORITY, context.getString(R.string.notification_channel_high_priority), NotificationManager.IMPORTANCE_HIGH);
// manager.createNotificationChannel(highPriority);
// }
//
//
// public static void setPersistentNotificationEnabled(Context context, boolean enabled) {
// SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
// prefs.edit().putBoolean("persistentNotification", enabled).apply();
// }
//
// public static boolean isPersistentNotificationEnabled(Context context) {
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
// return true;
// }
// SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
// return prefs.getBoolean("persistentNotification", false);
// }
//
// }
// Path: src/org/kde/kdeconnect/Plugins/FindMyPhonePlugin/FindMyPhonePlugin.java
import android.app.Activity;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Intent;
import android.content.SharedPreferences;
import android.media.AudioManager;
import android.media.MediaPlayer;
import android.net.Uri;
import android.os.Build;
import android.os.PowerManager;
import android.preference.PreferenceManager;
import android.provider.Settings;
import android.util.Log;
import androidx.annotation.RequiresApi;
import androidx.core.app.NotificationCompat;
import androidx.core.content.ContextCompat;
import org.apache.commons.lang3.ArrayUtils;
import org.kde.kdeconnect.Helpers.DeviceHelper;
import org.kde.kdeconnect.Helpers.NotificationHelper;
import org.kde.kdeconnect.MyApplication;
import org.kde.kdeconnect.NetworkPacket;
import org.kde.kdeconnect.Plugins.Plugin;
import org.kde.kdeconnect.Plugins.PluginFactory;
import org.kde.kdeconnect.UserInterface.PluginSettingsFragment;
import org.kde.kdeconnect_tp.R;
import java.io.IOException;
showBroadcastNotification();
} else {
showActivityNotification();
}
}
return true;
}
@RequiresApi(16)
private void showBroadcastNotification() {
Intent intent = new Intent(context, FindMyPhoneReceiver.class);
intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
intent.setAction(FindMyPhoneReceiver.ACTION_FOUND_IT);
intent.putExtra(FindMyPhoneReceiver.EXTRA_DEVICE_ID, device.getDeviceId());
PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
createNotification(pendingIntent);
}
private void showActivityNotification() {
Intent intent = new Intent(context, FindMyPhoneActivity.class);
intent.putExtra(FindMyPhoneActivity.EXTRA_DEVICE_ID, device.getDeviceId());
PendingIntent pi = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
createNotification(pi);
}
private void createNotification(PendingIntent pendingIntent) { | NotificationCompat.Builder notification = new NotificationCompat.Builder(context, NotificationHelper.Channels.HIGHPRIORITY); |
KDE/kdeconnect-android | src/org/kde/kdeconnect/Plugins/PresenterPlugin/PresenterPlugin.java | // Path: src/org/kde/kdeconnect/Plugins/MousePadPlugin/KeyListenerView.java
// public static final SparseIntArray SpecialKeysMap = new SparseIntArray();
| import android.app.Activity;
import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.view.KeyEvent;
import androidx.core.content.ContextCompat;
import org.apache.commons.lang3.ArrayUtils;
import org.kde.kdeconnect.NetworkPacket;
import org.kde.kdeconnect.Plugins.Plugin;
import org.kde.kdeconnect.Plugins.PluginFactory;
import org.kde.kdeconnect_tp.R;
import static org.kde.kdeconnect.Plugins.MousePadPlugin.KeyListenerView.SpecialKeysMap; | return false;
}
@Override
public boolean hasMainActivity() {
return true;
}
@Override
public void startMainActivity(Activity parentActivity) {
Intent intent = new Intent(parentActivity, PresenterActivity.class);
intent.putExtra("deviceId", device.getDeviceId());
parentActivity.startActivity(intent);
}
@Override
public String[] getSupportedPacketTypes() { return ArrayUtils.EMPTY_STRING_ARRAY; }
@Override
public String[] getOutgoingPacketTypes() {
return new String[]{PACKET_TYPE_MOUSEPAD_REQUEST, PACKET_TYPE_PRESENTER};
}
@Override
public String getActionName() {
return context.getString(R.string.pref_plugin_presenter);
}
public void sendNext() {
NetworkPacket np = new NetworkPacket(PACKET_TYPE_MOUSEPAD_REQUEST); | // Path: src/org/kde/kdeconnect/Plugins/MousePadPlugin/KeyListenerView.java
// public static final SparseIntArray SpecialKeysMap = new SparseIntArray();
// Path: src/org/kde/kdeconnect/Plugins/PresenterPlugin/PresenterPlugin.java
import android.app.Activity;
import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.view.KeyEvent;
import androidx.core.content.ContextCompat;
import org.apache.commons.lang3.ArrayUtils;
import org.kde.kdeconnect.NetworkPacket;
import org.kde.kdeconnect.Plugins.Plugin;
import org.kde.kdeconnect.Plugins.PluginFactory;
import org.kde.kdeconnect_tp.R;
import static org.kde.kdeconnect.Plugins.MousePadPlugin.KeyListenerView.SpecialKeysMap;
return false;
}
@Override
public boolean hasMainActivity() {
return true;
}
@Override
public void startMainActivity(Activity parentActivity) {
Intent intent = new Intent(parentActivity, PresenterActivity.class);
intent.putExtra("deviceId", device.getDeviceId());
parentActivity.startActivity(intent);
}
@Override
public String[] getSupportedPacketTypes() { return ArrayUtils.EMPTY_STRING_ARRAY; }
@Override
public String[] getOutgoingPacketTypes() {
return new String[]{PACKET_TYPE_MOUSEPAD_REQUEST, PACKET_TYPE_PRESENTER};
}
@Override
public String getActionName() {
return context.getString(R.string.pref_plugin_presenter);
}
public void sendNext() {
NetworkPacket np = new NetworkPacket(PACKET_TYPE_MOUSEPAD_REQUEST); | np.set("specialKey", SpecialKeysMap.get(KeyEvent.KEYCODE_PAGE_DOWN)); |
KDE/kdeconnect-android | src/org/kde/kdeconnect/UserInterface/TrustedNetworksActivity.java | // Path: src/org/kde/kdeconnect/Helpers/TrustedNetworkHelper.java
// public class TrustedNetworkHelper {
//
// private static final String KEY_CUSTOM_TRUSTED_NETWORKS = "trusted_network_preference";
// private static final String KEY_CUSTOM_TRUST_ALL_NETWORKS = "trust_all_network_preference";
// private static final String NETWORK_SSID_DELIMITER = "#_#";
// private static final String NOT_AVAILABLE_SSID_RESULT = "<unknown ssid>";
//
//
// private final Context context;
//
// public TrustedNetworkHelper(Context context) {
// this.context = context;
// }
//
// public String[] read() {
// String serializeTrustedNetwork = PreferenceManager.getDefaultSharedPreferences(context).getString(
// KEY_CUSTOM_TRUSTED_NETWORKS, "");
// if (serializeTrustedNetwork.isEmpty())
// return ArrayUtils.EMPTY_STRING_ARRAY;
// return serializeTrustedNetwork.split(NETWORK_SSID_DELIMITER);
// }
//
// public void update(List<String> trustedNetworks) {
// String serialized = TextUtils.join(NETWORK_SSID_DELIMITER, trustedNetworks);
// PreferenceManager.getDefaultSharedPreferences(context).edit().putString(
// KEY_CUSTOM_TRUSTED_NETWORKS, serialized).apply();
// }
//
// public boolean allAllowed() {
// if (!hasPermissions()) {
// return true;
// }
// return PreferenceManager
// .getDefaultSharedPreferences(context)
// .getBoolean(KEY_CUSTOM_TRUST_ALL_NETWORKS, Boolean.TRUE);
// }
//
// public void allAllowed(boolean isChecked) {
// PreferenceManager
// .getDefaultSharedPreferences(context)
// .edit()
// .putBoolean(KEY_CUSTOM_TRUST_ALL_NETWORKS, isChecked)
// .apply();
// }
//
// public boolean hasPermissions() {
// int result = ContextCompat.checkSelfPermission(context, Manifest.permission.ACCESS_FINE_LOCATION);
// return (result == PackageManager.PERMISSION_GRANTED);
// }
//
// public String currentSSID() {
// WifiManager wifiManager = ContextCompat.getSystemService(context.getApplicationContext(),
// WifiManager.class);
// if (wifiManager == null) return "";
// WifiInfo wifiInfo = wifiManager.getConnectionInfo();
// if (wifiInfo.getSupplicantState() != SupplicantState.COMPLETED) {
// return "";
// }
// String ssid = wifiInfo.getSSID();
// if (ssid.equalsIgnoreCase(NOT_AVAILABLE_SSID_RESULT)){
// Log.d("TrustedNetworkHelper", "Current SSID is unknown");
// return "";
// }
// return ssid;
// }
//
// public static boolean isTrustedNetwork(Context context) {
// TrustedNetworkHelper trustedNetworkHelper = new TrustedNetworkHelper(context);
// if (trustedNetworkHelper.allAllowed()){
// return true;
// }
// return ArrayUtils.contains(trustedNetworkHelper.read(), trustedNetworkHelper.currentSSID());
// }
// }
| import android.Manifest;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.ListView;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import com.android.internal.util.ArrayUtils;
import org.kde.kdeconnect.Helpers.TrustedNetworkHelper;
import org.kde.kdeconnect_tp.R;
import org.kde.kdeconnect_tp.databinding.TrustedNetworkListBinding;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Objects; | package org.kde.kdeconnect.UserInterface;
public class TrustedNetworksActivity extends AppCompatActivity {
private TrustedNetworkListBinding binding;
private List<String> trustedNetworks;
private ListView trustedNetworksView;
private CheckBox allowAllCheckBox; | // Path: src/org/kde/kdeconnect/Helpers/TrustedNetworkHelper.java
// public class TrustedNetworkHelper {
//
// private static final String KEY_CUSTOM_TRUSTED_NETWORKS = "trusted_network_preference";
// private static final String KEY_CUSTOM_TRUST_ALL_NETWORKS = "trust_all_network_preference";
// private static final String NETWORK_SSID_DELIMITER = "#_#";
// private static final String NOT_AVAILABLE_SSID_RESULT = "<unknown ssid>";
//
//
// private final Context context;
//
// public TrustedNetworkHelper(Context context) {
// this.context = context;
// }
//
// public String[] read() {
// String serializeTrustedNetwork = PreferenceManager.getDefaultSharedPreferences(context).getString(
// KEY_CUSTOM_TRUSTED_NETWORKS, "");
// if (serializeTrustedNetwork.isEmpty())
// return ArrayUtils.EMPTY_STRING_ARRAY;
// return serializeTrustedNetwork.split(NETWORK_SSID_DELIMITER);
// }
//
// public void update(List<String> trustedNetworks) {
// String serialized = TextUtils.join(NETWORK_SSID_DELIMITER, trustedNetworks);
// PreferenceManager.getDefaultSharedPreferences(context).edit().putString(
// KEY_CUSTOM_TRUSTED_NETWORKS, serialized).apply();
// }
//
// public boolean allAllowed() {
// if (!hasPermissions()) {
// return true;
// }
// return PreferenceManager
// .getDefaultSharedPreferences(context)
// .getBoolean(KEY_CUSTOM_TRUST_ALL_NETWORKS, Boolean.TRUE);
// }
//
// public void allAllowed(boolean isChecked) {
// PreferenceManager
// .getDefaultSharedPreferences(context)
// .edit()
// .putBoolean(KEY_CUSTOM_TRUST_ALL_NETWORKS, isChecked)
// .apply();
// }
//
// public boolean hasPermissions() {
// int result = ContextCompat.checkSelfPermission(context, Manifest.permission.ACCESS_FINE_LOCATION);
// return (result == PackageManager.PERMISSION_GRANTED);
// }
//
// public String currentSSID() {
// WifiManager wifiManager = ContextCompat.getSystemService(context.getApplicationContext(),
// WifiManager.class);
// if (wifiManager == null) return "";
// WifiInfo wifiInfo = wifiManager.getConnectionInfo();
// if (wifiInfo.getSupplicantState() != SupplicantState.COMPLETED) {
// return "";
// }
// String ssid = wifiInfo.getSSID();
// if (ssid.equalsIgnoreCase(NOT_AVAILABLE_SSID_RESULT)){
// Log.d("TrustedNetworkHelper", "Current SSID is unknown");
// return "";
// }
// return ssid;
// }
//
// public static boolean isTrustedNetwork(Context context) {
// TrustedNetworkHelper trustedNetworkHelper = new TrustedNetworkHelper(context);
// if (trustedNetworkHelper.allAllowed()){
// return true;
// }
// return ArrayUtils.contains(trustedNetworkHelper.read(), trustedNetworkHelper.currentSSID());
// }
// }
// Path: src/org/kde/kdeconnect/UserInterface/TrustedNetworksActivity.java
import android.Manifest;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.ListView;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import com.android.internal.util.ArrayUtils;
import org.kde.kdeconnect.Helpers.TrustedNetworkHelper;
import org.kde.kdeconnect_tp.R;
import org.kde.kdeconnect_tp.databinding.TrustedNetworkListBinding;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
package org.kde.kdeconnect.UserInterface;
public class TrustedNetworksActivity extends AppCompatActivity {
private TrustedNetworkListBinding binding;
private List<String> trustedNetworks;
private ListView trustedNetworksView;
private CheckBox allowAllCheckBox; | private TrustedNetworkHelper trustedNetworkHelper; |
KDE/kdeconnect-android | src/org/kde/kdeconnect/Plugins/SftpPlugin/SftpPlugin.java | // Path: src/org/kde/kdeconnect/UserInterface/DeviceSettingsAlertDialogFragment.java
// public class DeviceSettingsAlertDialogFragment extends AlertDialogFragment {
// private static final String KEY_PLUGIN_KEY = "PluginKey";
// private static final String KEY_DEVICE_ID = "DeviceId";
//
// private String pluginKey;
// private String deviceId;
//
// public DeviceSettingsAlertDialogFragment() {}
//
// @Override
// public void onCreate(@Nullable Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
//
// Bundle args = getArguments();
//
// if (args == null || !args.containsKey(KEY_PLUGIN_KEY)) {
// throw new RuntimeException("You must call Builder.setPluginKey() to set the plugin");
// }
// if (!args.containsKey(KEY_DEVICE_ID)) {
// throw new RuntimeException("You must call Builder.setDeviceId() to set the device");
// }
//
// pluginKey = args.getString(KEY_PLUGIN_KEY);
// deviceId = args.getString(KEY_DEVICE_ID);
//
// setCallback(new Callback() {
// @Override
// public void onPositiveButtonClicked() {
// Intent intent = new Intent(requireActivity(), PluginSettingsActivity.class);
//
// intent.putExtra(PluginSettingsActivity.EXTRA_DEVICE_ID, deviceId);
// intent.putExtra(PluginSettingsActivity.EXTRA_PLUGIN_KEY, pluginKey);
// requireActivity().startActivity(intent);
// }
// });
// }
//
// public static class Builder extends AbstractBuilder<DeviceSettingsAlertDialogFragment.Builder, DeviceSettingsAlertDialogFragment> {
// @Override
// public DeviceSettingsAlertDialogFragment.Builder getThis() {
// return this;
// }
//
// public DeviceSettingsAlertDialogFragment.Builder setPluginKey(String pluginKey) {
// args.putString(KEY_PLUGIN_KEY, pluginKey);
// return getThis();
// }
//
// public DeviceSettingsAlertDialogFragment.Builder setDeviceId(String deviceId) {
// args.putString(KEY_DEVICE_ID, deviceId);
// return getThis();
// }
//
// @Override
// protected DeviceSettingsAlertDialogFragment createFragment() {
// return new DeviceSettingsAlertDialogFragment();
// }
// }
// }
| import android.app.Activity;
import android.content.ContentResolver;
import android.content.SharedPreferences;
import android.net.Uri;
import android.os.Build;
import android.util.Log;
import androidx.annotation.NonNull;
import org.json.JSONException;
import org.json.JSONObject;
import org.kde.kdeconnect.NetworkPacket;
import org.kde.kdeconnect.Plugins.Plugin;
import org.kde.kdeconnect.Plugins.PluginFactory;
import org.kde.kdeconnect.UserInterface.AlertDialogFragment;
import org.kde.kdeconnect.UserInterface.DeviceSettingsAlertDialogFragment;
import org.kde.kdeconnect.UserInterface.PluginSettingsFragment;
import org.kde.kdeconnect_tp.R;
import java.io.File;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List; | return context.getResources().getString(R.string.pref_plugin_sftp_desc);
}
@Override
public boolean onCreate() {
try {
server.init(context, device);
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT) {
return SftpSettingsFragment.getStorageInfoList(context, this).size() != 0;
}
return true;
} catch (Exception e) {
Log.e("SFTP", "Exception in server.init()", e);
return false;
}
}
@Override
public boolean checkOptionalPermissions() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
return SftpSettingsFragment.getStorageInfoList(context, this).size() != 0;
}
return true;
}
@Override
public AlertDialogFragment getOptionalPermissionExplanationDialog() { | // Path: src/org/kde/kdeconnect/UserInterface/DeviceSettingsAlertDialogFragment.java
// public class DeviceSettingsAlertDialogFragment extends AlertDialogFragment {
// private static final String KEY_PLUGIN_KEY = "PluginKey";
// private static final String KEY_DEVICE_ID = "DeviceId";
//
// private String pluginKey;
// private String deviceId;
//
// public DeviceSettingsAlertDialogFragment() {}
//
// @Override
// public void onCreate(@Nullable Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
//
// Bundle args = getArguments();
//
// if (args == null || !args.containsKey(KEY_PLUGIN_KEY)) {
// throw new RuntimeException("You must call Builder.setPluginKey() to set the plugin");
// }
// if (!args.containsKey(KEY_DEVICE_ID)) {
// throw new RuntimeException("You must call Builder.setDeviceId() to set the device");
// }
//
// pluginKey = args.getString(KEY_PLUGIN_KEY);
// deviceId = args.getString(KEY_DEVICE_ID);
//
// setCallback(new Callback() {
// @Override
// public void onPositiveButtonClicked() {
// Intent intent = new Intent(requireActivity(), PluginSettingsActivity.class);
//
// intent.putExtra(PluginSettingsActivity.EXTRA_DEVICE_ID, deviceId);
// intent.putExtra(PluginSettingsActivity.EXTRA_PLUGIN_KEY, pluginKey);
// requireActivity().startActivity(intent);
// }
// });
// }
//
// public static class Builder extends AbstractBuilder<DeviceSettingsAlertDialogFragment.Builder, DeviceSettingsAlertDialogFragment> {
// @Override
// public DeviceSettingsAlertDialogFragment.Builder getThis() {
// return this;
// }
//
// public DeviceSettingsAlertDialogFragment.Builder setPluginKey(String pluginKey) {
// args.putString(KEY_PLUGIN_KEY, pluginKey);
// return getThis();
// }
//
// public DeviceSettingsAlertDialogFragment.Builder setDeviceId(String deviceId) {
// args.putString(KEY_DEVICE_ID, deviceId);
// return getThis();
// }
//
// @Override
// protected DeviceSettingsAlertDialogFragment createFragment() {
// return new DeviceSettingsAlertDialogFragment();
// }
// }
// }
// Path: src/org/kde/kdeconnect/Plugins/SftpPlugin/SftpPlugin.java
import android.app.Activity;
import android.content.ContentResolver;
import android.content.SharedPreferences;
import android.net.Uri;
import android.os.Build;
import android.util.Log;
import androidx.annotation.NonNull;
import org.json.JSONException;
import org.json.JSONObject;
import org.kde.kdeconnect.NetworkPacket;
import org.kde.kdeconnect.Plugins.Plugin;
import org.kde.kdeconnect.Plugins.PluginFactory;
import org.kde.kdeconnect.UserInterface.AlertDialogFragment;
import org.kde.kdeconnect.UserInterface.DeviceSettingsAlertDialogFragment;
import org.kde.kdeconnect.UserInterface.PluginSettingsFragment;
import org.kde.kdeconnect_tp.R;
import java.io.File;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
return context.getResources().getString(R.string.pref_plugin_sftp_desc);
}
@Override
public boolean onCreate() {
try {
server.init(context, device);
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT) {
return SftpSettingsFragment.getStorageInfoList(context, this).size() != 0;
}
return true;
} catch (Exception e) {
Log.e("SFTP", "Exception in server.init()", e);
return false;
}
}
@Override
public boolean checkOptionalPermissions() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
return SftpSettingsFragment.getStorageInfoList(context, this).size() != 0;
}
return true;
}
@Override
public AlertDialogFragment getOptionalPermissionExplanationDialog() { | return new DeviceSettingsAlertDialogFragment.Builder() |
ZhuoKeTeam/MasterHelper | app/src/main/java/com/team/zhuoke/masterhelper/api/TestApi/TestAPI2.java | // Path: app/src/main/java/com/team/zhuoke/masterhelper/api/NetWorkApi.java
// public class NetWorkApi {
//
// public static String baseUrl = "https://zkteam.wilddogio.com";
// // test
// public static final String getMasterList = "/master_list.json";
// public static final String getTestList = "/master_list.json";
//
// public static final String newBaseUrl = "http://www.zkteam.cc";
//
// public static final String masterInfo = newBaseUrl + "/api/jsonMasterInfo";
// public static final String masterArticle = "/api/jsonMasterArticle";
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/model/test/TestList.java
// public class TestList {
//
//
// /**
// * des : 生命不息,奋斗不止,万事起于忽微,量变引起质变
// * grade : 1
// * img : http://tva2.sinaimg.cn/crop.200.80.480.480.180/bca65a60gw1eiedwawzi2j20m80i57a7.jpg
// * info : http://blog.csdn.net/lmj623565791
// * isVip : true
// * name : hongyang
// * weiBo :
// * zhiHu :
// */
//
// private String des;
// private String grade;
// private String img;
// private String info;
// private boolean isVip;
// private String name;
// private String weiBo;
// private String zhiHu;
//
// public String getDes() {
// return des;
// }
//
// public void setDes(String des) {
// this.des = des;
// }
//
// public String getGrade() {
// return grade;
// }
//
// public void setGrade(String grade) {
// this.grade = grade;
// }
//
// public String getImg() {
// return img;
// }
//
// public void setImg(String img) {
// this.img = img;
// }
//
// public String getInfo() {
// return info;
// }
//
// public void setInfo(String info) {
// this.info = info;
// }
//
// public boolean isIsVip() {
// return isVip;
// }
//
// public void setIsVip(boolean isVip) {
// this.isVip = isVip;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getWeiBo() {
// return weiBo;
// }
//
// public void setWeiBo(String weiBo) {
// this.weiBo = weiBo;
// }
//
// public String getZhiHu() {
// return zhiHu;
// }
//
// public void setZhiHu(String zhiHu) {
// this.zhiHu = zhiHu;
// }
//
//
// // 修改模板,快速生成
// @Override
// public String toString() {
// return "{" +
// "des:'" + des + '\'' +
// ", grade:'" + grade + '\'' +
// ", img:'" + img + '\'' +
// ", info:'" + info + '\'' +
// ", isVip:" + isVip +
// ", name:'" + name + '\'' +
// ", weiBo:'" + weiBo + '\'' +
// ", zhiHu:'" + zhiHu + '\'' +
// '}';
// }
//
// // @Override
// // public String toString() {
// // return "MasterList{" +
// // "des='" + des + '\'' +
// // ", grade='" + grade + '\'' +
// // ", img='" + img + '\'' +
// // ", info='" + info + '\'' +
// // ", isVip=" + isVip +
// // ", name='" + name + '\'' +
// // ", weiBo='" + weiBo + '\'' +
// // ", zhiHu='" + zhiHu + '\'' +
// // '}';
// // }
//
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/net/response/HttpResponse.java
// public class HttpResponse<T> {
//
// private String code ;
//
// private T result;
//
// private String message;
//
// public String getCode() {
// return code;
// }
//
// public void setCode(String code) {
// this.code = code;
// }
//
// public T getResult() {
// return result;
// }
//
// public void setResult(T result) {
// this.result = result;
// }
//
// public String getMessage() {
// return message;
// }
//
// public void setMessage(String message) {
// this.message = message;
// }
//
// @Override
// public String toString() {
// return "{" +
// "code:'" + code + '\'' +
// ", result:" + result +
// ", message:'" + message + '\'' +
// '}';
// }
// }
| import com.team.zhuoke.masterhelper.api.NetWorkApi;
import com.team.zhuoke.masterhelper.model.test.TestList;
import com.team.zhuoke.masterhelper.net.response.HttpResponse;
import java.util.List;
import retrofit2.http.GET;
import rx.Observable; | package com.team.zhuoke.masterhelper.api.TestApi;
/**
* Created by WangQing on 2016/12/7.
*/
public interface TestAPI2 {
@GET(NetWorkApi.getTestList) | // Path: app/src/main/java/com/team/zhuoke/masterhelper/api/NetWorkApi.java
// public class NetWorkApi {
//
// public static String baseUrl = "https://zkteam.wilddogio.com";
// // test
// public static final String getMasterList = "/master_list.json";
// public static final String getTestList = "/master_list.json";
//
// public static final String newBaseUrl = "http://www.zkteam.cc";
//
// public static final String masterInfo = newBaseUrl + "/api/jsonMasterInfo";
// public static final String masterArticle = "/api/jsonMasterArticle";
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/model/test/TestList.java
// public class TestList {
//
//
// /**
// * des : 生命不息,奋斗不止,万事起于忽微,量变引起质变
// * grade : 1
// * img : http://tva2.sinaimg.cn/crop.200.80.480.480.180/bca65a60gw1eiedwawzi2j20m80i57a7.jpg
// * info : http://blog.csdn.net/lmj623565791
// * isVip : true
// * name : hongyang
// * weiBo :
// * zhiHu :
// */
//
// private String des;
// private String grade;
// private String img;
// private String info;
// private boolean isVip;
// private String name;
// private String weiBo;
// private String zhiHu;
//
// public String getDes() {
// return des;
// }
//
// public void setDes(String des) {
// this.des = des;
// }
//
// public String getGrade() {
// return grade;
// }
//
// public void setGrade(String grade) {
// this.grade = grade;
// }
//
// public String getImg() {
// return img;
// }
//
// public void setImg(String img) {
// this.img = img;
// }
//
// public String getInfo() {
// return info;
// }
//
// public void setInfo(String info) {
// this.info = info;
// }
//
// public boolean isIsVip() {
// return isVip;
// }
//
// public void setIsVip(boolean isVip) {
// this.isVip = isVip;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getWeiBo() {
// return weiBo;
// }
//
// public void setWeiBo(String weiBo) {
// this.weiBo = weiBo;
// }
//
// public String getZhiHu() {
// return zhiHu;
// }
//
// public void setZhiHu(String zhiHu) {
// this.zhiHu = zhiHu;
// }
//
//
// // 修改模板,快速生成
// @Override
// public String toString() {
// return "{" +
// "des:'" + des + '\'' +
// ", grade:'" + grade + '\'' +
// ", img:'" + img + '\'' +
// ", info:'" + info + '\'' +
// ", isVip:" + isVip +
// ", name:'" + name + '\'' +
// ", weiBo:'" + weiBo + '\'' +
// ", zhiHu:'" + zhiHu + '\'' +
// '}';
// }
//
// // @Override
// // public String toString() {
// // return "MasterList{" +
// // "des='" + des + '\'' +
// // ", grade='" + grade + '\'' +
// // ", img='" + img + '\'' +
// // ", info='" + info + '\'' +
// // ", isVip=" + isVip +
// // ", name='" + name + '\'' +
// // ", weiBo='" + weiBo + '\'' +
// // ", zhiHu='" + zhiHu + '\'' +
// // '}';
// // }
//
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/net/response/HttpResponse.java
// public class HttpResponse<T> {
//
// private String code ;
//
// private T result;
//
// private String message;
//
// public String getCode() {
// return code;
// }
//
// public void setCode(String code) {
// this.code = code;
// }
//
// public T getResult() {
// return result;
// }
//
// public void setResult(T result) {
// this.result = result;
// }
//
// public String getMessage() {
// return message;
// }
//
// public void setMessage(String message) {
// this.message = message;
// }
//
// @Override
// public String toString() {
// return "{" +
// "code:'" + code + '\'' +
// ", result:" + result +
// ", message:'" + message + '\'' +
// '}';
// }
// }
// Path: app/src/main/java/com/team/zhuoke/masterhelper/api/TestApi/TestAPI2.java
import com.team.zhuoke.masterhelper.api.NetWorkApi;
import com.team.zhuoke.masterhelper.model.test.TestList;
import com.team.zhuoke.masterhelper.net.response.HttpResponse;
import java.util.List;
import retrofit2.http.GET;
import rx.Observable;
package com.team.zhuoke.masterhelper.api.TestApi;
/**
* Created by WangQing on 2016/12/7.
*/
public interface TestAPI2 {
@GET(NetWorkApi.getTestList) | Observable<HttpResponse<List<TestList>>> getTestList(); |
ZhuoKeTeam/MasterHelper | app/src/main/java/com/team/zhuoke/masterhelper/api/TestApi/TestAPI2.java | // Path: app/src/main/java/com/team/zhuoke/masterhelper/api/NetWorkApi.java
// public class NetWorkApi {
//
// public static String baseUrl = "https://zkteam.wilddogio.com";
// // test
// public static final String getMasterList = "/master_list.json";
// public static final String getTestList = "/master_list.json";
//
// public static final String newBaseUrl = "http://www.zkteam.cc";
//
// public static final String masterInfo = newBaseUrl + "/api/jsonMasterInfo";
// public static final String masterArticle = "/api/jsonMasterArticle";
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/model/test/TestList.java
// public class TestList {
//
//
// /**
// * des : 生命不息,奋斗不止,万事起于忽微,量变引起质变
// * grade : 1
// * img : http://tva2.sinaimg.cn/crop.200.80.480.480.180/bca65a60gw1eiedwawzi2j20m80i57a7.jpg
// * info : http://blog.csdn.net/lmj623565791
// * isVip : true
// * name : hongyang
// * weiBo :
// * zhiHu :
// */
//
// private String des;
// private String grade;
// private String img;
// private String info;
// private boolean isVip;
// private String name;
// private String weiBo;
// private String zhiHu;
//
// public String getDes() {
// return des;
// }
//
// public void setDes(String des) {
// this.des = des;
// }
//
// public String getGrade() {
// return grade;
// }
//
// public void setGrade(String grade) {
// this.grade = grade;
// }
//
// public String getImg() {
// return img;
// }
//
// public void setImg(String img) {
// this.img = img;
// }
//
// public String getInfo() {
// return info;
// }
//
// public void setInfo(String info) {
// this.info = info;
// }
//
// public boolean isIsVip() {
// return isVip;
// }
//
// public void setIsVip(boolean isVip) {
// this.isVip = isVip;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getWeiBo() {
// return weiBo;
// }
//
// public void setWeiBo(String weiBo) {
// this.weiBo = weiBo;
// }
//
// public String getZhiHu() {
// return zhiHu;
// }
//
// public void setZhiHu(String zhiHu) {
// this.zhiHu = zhiHu;
// }
//
//
// // 修改模板,快速生成
// @Override
// public String toString() {
// return "{" +
// "des:'" + des + '\'' +
// ", grade:'" + grade + '\'' +
// ", img:'" + img + '\'' +
// ", info:'" + info + '\'' +
// ", isVip:" + isVip +
// ", name:'" + name + '\'' +
// ", weiBo:'" + weiBo + '\'' +
// ", zhiHu:'" + zhiHu + '\'' +
// '}';
// }
//
// // @Override
// // public String toString() {
// // return "MasterList{" +
// // "des='" + des + '\'' +
// // ", grade='" + grade + '\'' +
// // ", img='" + img + '\'' +
// // ", info='" + info + '\'' +
// // ", isVip=" + isVip +
// // ", name='" + name + '\'' +
// // ", weiBo='" + weiBo + '\'' +
// // ", zhiHu='" + zhiHu + '\'' +
// // '}';
// // }
//
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/net/response/HttpResponse.java
// public class HttpResponse<T> {
//
// private String code ;
//
// private T result;
//
// private String message;
//
// public String getCode() {
// return code;
// }
//
// public void setCode(String code) {
// this.code = code;
// }
//
// public T getResult() {
// return result;
// }
//
// public void setResult(T result) {
// this.result = result;
// }
//
// public String getMessage() {
// return message;
// }
//
// public void setMessage(String message) {
// this.message = message;
// }
//
// @Override
// public String toString() {
// return "{" +
// "code:'" + code + '\'' +
// ", result:" + result +
// ", message:'" + message + '\'' +
// '}';
// }
// }
| import com.team.zhuoke.masterhelper.api.NetWorkApi;
import com.team.zhuoke.masterhelper.model.test.TestList;
import com.team.zhuoke.masterhelper.net.response.HttpResponse;
import java.util.List;
import retrofit2.http.GET;
import rx.Observable; | package com.team.zhuoke.masterhelper.api.TestApi;
/**
* Created by WangQing on 2016/12/7.
*/
public interface TestAPI2 {
@GET(NetWorkApi.getTestList) | // Path: app/src/main/java/com/team/zhuoke/masterhelper/api/NetWorkApi.java
// public class NetWorkApi {
//
// public static String baseUrl = "https://zkteam.wilddogio.com";
// // test
// public static final String getMasterList = "/master_list.json";
// public static final String getTestList = "/master_list.json";
//
// public static final String newBaseUrl = "http://www.zkteam.cc";
//
// public static final String masterInfo = newBaseUrl + "/api/jsonMasterInfo";
// public static final String masterArticle = "/api/jsonMasterArticle";
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/model/test/TestList.java
// public class TestList {
//
//
// /**
// * des : 生命不息,奋斗不止,万事起于忽微,量变引起质变
// * grade : 1
// * img : http://tva2.sinaimg.cn/crop.200.80.480.480.180/bca65a60gw1eiedwawzi2j20m80i57a7.jpg
// * info : http://blog.csdn.net/lmj623565791
// * isVip : true
// * name : hongyang
// * weiBo :
// * zhiHu :
// */
//
// private String des;
// private String grade;
// private String img;
// private String info;
// private boolean isVip;
// private String name;
// private String weiBo;
// private String zhiHu;
//
// public String getDes() {
// return des;
// }
//
// public void setDes(String des) {
// this.des = des;
// }
//
// public String getGrade() {
// return grade;
// }
//
// public void setGrade(String grade) {
// this.grade = grade;
// }
//
// public String getImg() {
// return img;
// }
//
// public void setImg(String img) {
// this.img = img;
// }
//
// public String getInfo() {
// return info;
// }
//
// public void setInfo(String info) {
// this.info = info;
// }
//
// public boolean isIsVip() {
// return isVip;
// }
//
// public void setIsVip(boolean isVip) {
// this.isVip = isVip;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getWeiBo() {
// return weiBo;
// }
//
// public void setWeiBo(String weiBo) {
// this.weiBo = weiBo;
// }
//
// public String getZhiHu() {
// return zhiHu;
// }
//
// public void setZhiHu(String zhiHu) {
// this.zhiHu = zhiHu;
// }
//
//
// // 修改模板,快速生成
// @Override
// public String toString() {
// return "{" +
// "des:'" + des + '\'' +
// ", grade:'" + grade + '\'' +
// ", img:'" + img + '\'' +
// ", info:'" + info + '\'' +
// ", isVip:" + isVip +
// ", name:'" + name + '\'' +
// ", weiBo:'" + weiBo + '\'' +
// ", zhiHu:'" + zhiHu + '\'' +
// '}';
// }
//
// // @Override
// // public String toString() {
// // return "MasterList{" +
// // "des='" + des + '\'' +
// // ", grade='" + grade + '\'' +
// // ", img='" + img + '\'' +
// // ", info='" + info + '\'' +
// // ", isVip=" + isVip +
// // ", name='" + name + '\'' +
// // ", weiBo='" + weiBo + '\'' +
// // ", zhiHu='" + zhiHu + '\'' +
// // '}';
// // }
//
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/net/response/HttpResponse.java
// public class HttpResponse<T> {
//
// private String code ;
//
// private T result;
//
// private String message;
//
// public String getCode() {
// return code;
// }
//
// public void setCode(String code) {
// this.code = code;
// }
//
// public T getResult() {
// return result;
// }
//
// public void setResult(T result) {
// this.result = result;
// }
//
// public String getMessage() {
// return message;
// }
//
// public void setMessage(String message) {
// this.message = message;
// }
//
// @Override
// public String toString() {
// return "{" +
// "code:'" + code + '\'' +
// ", result:" + result +
// ", message:'" + message + '\'' +
// '}';
// }
// }
// Path: app/src/main/java/com/team/zhuoke/masterhelper/api/TestApi/TestAPI2.java
import com.team.zhuoke.masterhelper.api.NetWorkApi;
import com.team.zhuoke.masterhelper.model.test.TestList;
import com.team.zhuoke.masterhelper.net.response.HttpResponse;
import java.util.List;
import retrofit2.http.GET;
import rx.Observable;
package com.team.zhuoke.masterhelper.api.TestApi;
/**
* Created by WangQing on 2016/12/7.
*/
public interface TestAPI2 {
@GET(NetWorkApi.getTestList) | Observable<HttpResponse<List<TestList>>> getTestList(); |
ZhuoKeTeam/MasterHelper | app/src/main/java/com/team/zhuoke/masterhelper/fragment/marster/MasterPresenter.java | // Path: app/src/main/java/com/team/zhuoke/masterhelper/fragment/MasterInfoBean.java
// public class MasterInfoBean {
// /**
// * id : 1
// * uid : 1246141947
// * name : lmj623565791
// * nick_name : Hongyang
// * img : http://avatar.csdn.net/F/F/5/1_lmj623565791.jpg
// * info : 生命不息,奋斗不止,万事起于忽微,量变引起质变
// * isVip : 1
// * index : 0
// * blog : http://blog.csdn.net/lmj623565791?viewmode=contents
// */
//
// private int id;
// private String uid;
// private String name;
// private String nick_name;
// private String img;
// private String info;
// private String isVip;
// private int index;
// private String blog;
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public String getUid() {
// return uid;
// }
//
// public void setUid(String uid) {
// this.uid = uid;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getNick_name() {
// return nick_name;
// }
//
// public void setNick_name(String nick_name) {
// this.nick_name = nick_name;
// }
//
// public String getImg() {
// return img;
// }
//
// public void setImg(String img) {
// this.img = img;
// }
//
// public String getInfo() {
// return info;
// }
//
// public void setInfo(String info) {
// this.info = info;
// }
//
// public String getIsVip() {
// return isVip;
// }
//
// public void setIsVip(String isVip) {
// this.isVip = isVip;
// }
//
// public int getIndex() {
// return index;
// }
//
// public void setIndex(int index) {
// this.index = index;
// }
//
// public String getBlog() {
// return blog;
// }
//
// public void setBlog(String blog) {
// this.blog = blog;
// }
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/net/callback/RxSubscriber.java
// public abstract class RxSubscriber<T> extends ErrorSubscriber<T> {
//
//
//
// @Override
// protected void onError(ResponeThrowable ex) {
// Log.e("aaaaa", "onError: " + ex.message + "code: " + ex.code);
// }
//
// /**
// * 开始请求网络
// */
// @Override
// public void onStart() {
// super.onStart();
// // todo some common as show loadding and check netWork is NetworkAvailable
// }
// /**
// * 请求网络完成
// */
// @Override
// public void onCompleted() {
// }
// /**
// * 获取网络数据
// * @param t
// */
// @Override
// public void onNext(T t) {
//
// onSuccess(t);
// }
// public abstract void onSuccess(T t);
//
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/net/exception/ResponeThrowable.java
// public class ResponeThrowable extends Exception {
// public int code;
// public String message;
//
// public ResponeThrowable(Throwable throwable, int code) {
// super(throwable);
// this.code = code;
// }
// }
| import com.team.zhuoke.masterhelper.fragment.MasterInfoBean;
import com.team.zhuoke.masterhelper.net.callback.RxSubscriber;
import com.team.zhuoke.masterhelper.net.exception.ResponeThrowable;
import java.util.List; | package com.team.zhuoke.masterhelper.fragment.marster;
/**
* Created by WangQing on 2017/4/20.
*/
public class MasterPresenter extends MasterContract.Presenter{
@Override
void getMasterList() { | // Path: app/src/main/java/com/team/zhuoke/masterhelper/fragment/MasterInfoBean.java
// public class MasterInfoBean {
// /**
// * id : 1
// * uid : 1246141947
// * name : lmj623565791
// * nick_name : Hongyang
// * img : http://avatar.csdn.net/F/F/5/1_lmj623565791.jpg
// * info : 生命不息,奋斗不止,万事起于忽微,量变引起质变
// * isVip : 1
// * index : 0
// * blog : http://blog.csdn.net/lmj623565791?viewmode=contents
// */
//
// private int id;
// private String uid;
// private String name;
// private String nick_name;
// private String img;
// private String info;
// private String isVip;
// private int index;
// private String blog;
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public String getUid() {
// return uid;
// }
//
// public void setUid(String uid) {
// this.uid = uid;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getNick_name() {
// return nick_name;
// }
//
// public void setNick_name(String nick_name) {
// this.nick_name = nick_name;
// }
//
// public String getImg() {
// return img;
// }
//
// public void setImg(String img) {
// this.img = img;
// }
//
// public String getInfo() {
// return info;
// }
//
// public void setInfo(String info) {
// this.info = info;
// }
//
// public String getIsVip() {
// return isVip;
// }
//
// public void setIsVip(String isVip) {
// this.isVip = isVip;
// }
//
// public int getIndex() {
// return index;
// }
//
// public void setIndex(int index) {
// this.index = index;
// }
//
// public String getBlog() {
// return blog;
// }
//
// public void setBlog(String blog) {
// this.blog = blog;
// }
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/net/callback/RxSubscriber.java
// public abstract class RxSubscriber<T> extends ErrorSubscriber<T> {
//
//
//
// @Override
// protected void onError(ResponeThrowable ex) {
// Log.e("aaaaa", "onError: " + ex.message + "code: " + ex.code);
// }
//
// /**
// * 开始请求网络
// */
// @Override
// public void onStart() {
// super.onStart();
// // todo some common as show loadding and check netWork is NetworkAvailable
// }
// /**
// * 请求网络完成
// */
// @Override
// public void onCompleted() {
// }
// /**
// * 获取网络数据
// * @param t
// */
// @Override
// public void onNext(T t) {
//
// onSuccess(t);
// }
// public abstract void onSuccess(T t);
//
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/net/exception/ResponeThrowable.java
// public class ResponeThrowable extends Exception {
// public int code;
// public String message;
//
// public ResponeThrowable(Throwable throwable, int code) {
// super(throwable);
// this.code = code;
// }
// }
// Path: app/src/main/java/com/team/zhuoke/masterhelper/fragment/marster/MasterPresenter.java
import com.team.zhuoke.masterhelper.fragment.MasterInfoBean;
import com.team.zhuoke.masterhelper.net.callback.RxSubscriber;
import com.team.zhuoke.masterhelper.net.exception.ResponeThrowable;
import java.util.List;
package com.team.zhuoke.masterhelper.fragment.marster;
/**
* Created by WangQing on 2017/4/20.
*/
public class MasterPresenter extends MasterContract.Presenter{
@Override
void getMasterList() { | addSubscribe(mModel.getMasterData(mContext).subscribe(new RxSubscriber<List<MasterInfoBean>>() { |
ZhuoKeTeam/MasterHelper | app/src/main/java/com/team/zhuoke/masterhelper/fragment/marster/MasterPresenter.java | // Path: app/src/main/java/com/team/zhuoke/masterhelper/fragment/MasterInfoBean.java
// public class MasterInfoBean {
// /**
// * id : 1
// * uid : 1246141947
// * name : lmj623565791
// * nick_name : Hongyang
// * img : http://avatar.csdn.net/F/F/5/1_lmj623565791.jpg
// * info : 生命不息,奋斗不止,万事起于忽微,量变引起质变
// * isVip : 1
// * index : 0
// * blog : http://blog.csdn.net/lmj623565791?viewmode=contents
// */
//
// private int id;
// private String uid;
// private String name;
// private String nick_name;
// private String img;
// private String info;
// private String isVip;
// private int index;
// private String blog;
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public String getUid() {
// return uid;
// }
//
// public void setUid(String uid) {
// this.uid = uid;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getNick_name() {
// return nick_name;
// }
//
// public void setNick_name(String nick_name) {
// this.nick_name = nick_name;
// }
//
// public String getImg() {
// return img;
// }
//
// public void setImg(String img) {
// this.img = img;
// }
//
// public String getInfo() {
// return info;
// }
//
// public void setInfo(String info) {
// this.info = info;
// }
//
// public String getIsVip() {
// return isVip;
// }
//
// public void setIsVip(String isVip) {
// this.isVip = isVip;
// }
//
// public int getIndex() {
// return index;
// }
//
// public void setIndex(int index) {
// this.index = index;
// }
//
// public String getBlog() {
// return blog;
// }
//
// public void setBlog(String blog) {
// this.blog = blog;
// }
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/net/callback/RxSubscriber.java
// public abstract class RxSubscriber<T> extends ErrorSubscriber<T> {
//
//
//
// @Override
// protected void onError(ResponeThrowable ex) {
// Log.e("aaaaa", "onError: " + ex.message + "code: " + ex.code);
// }
//
// /**
// * 开始请求网络
// */
// @Override
// public void onStart() {
// super.onStart();
// // todo some common as show loadding and check netWork is NetworkAvailable
// }
// /**
// * 请求网络完成
// */
// @Override
// public void onCompleted() {
// }
// /**
// * 获取网络数据
// * @param t
// */
// @Override
// public void onNext(T t) {
//
// onSuccess(t);
// }
// public abstract void onSuccess(T t);
//
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/net/exception/ResponeThrowable.java
// public class ResponeThrowable extends Exception {
// public int code;
// public String message;
//
// public ResponeThrowable(Throwable throwable, int code) {
// super(throwable);
// this.code = code;
// }
// }
| import com.team.zhuoke.masterhelper.fragment.MasterInfoBean;
import com.team.zhuoke.masterhelper.net.callback.RxSubscriber;
import com.team.zhuoke.masterhelper.net.exception.ResponeThrowable;
import java.util.List; | package com.team.zhuoke.masterhelper.fragment.marster;
/**
* Created by WangQing on 2017/4/20.
*/
public class MasterPresenter extends MasterContract.Presenter{
@Override
void getMasterList() { | // Path: app/src/main/java/com/team/zhuoke/masterhelper/fragment/MasterInfoBean.java
// public class MasterInfoBean {
// /**
// * id : 1
// * uid : 1246141947
// * name : lmj623565791
// * nick_name : Hongyang
// * img : http://avatar.csdn.net/F/F/5/1_lmj623565791.jpg
// * info : 生命不息,奋斗不止,万事起于忽微,量变引起质变
// * isVip : 1
// * index : 0
// * blog : http://blog.csdn.net/lmj623565791?viewmode=contents
// */
//
// private int id;
// private String uid;
// private String name;
// private String nick_name;
// private String img;
// private String info;
// private String isVip;
// private int index;
// private String blog;
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public String getUid() {
// return uid;
// }
//
// public void setUid(String uid) {
// this.uid = uid;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getNick_name() {
// return nick_name;
// }
//
// public void setNick_name(String nick_name) {
// this.nick_name = nick_name;
// }
//
// public String getImg() {
// return img;
// }
//
// public void setImg(String img) {
// this.img = img;
// }
//
// public String getInfo() {
// return info;
// }
//
// public void setInfo(String info) {
// this.info = info;
// }
//
// public String getIsVip() {
// return isVip;
// }
//
// public void setIsVip(String isVip) {
// this.isVip = isVip;
// }
//
// public int getIndex() {
// return index;
// }
//
// public void setIndex(int index) {
// this.index = index;
// }
//
// public String getBlog() {
// return blog;
// }
//
// public void setBlog(String blog) {
// this.blog = blog;
// }
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/net/callback/RxSubscriber.java
// public abstract class RxSubscriber<T> extends ErrorSubscriber<T> {
//
//
//
// @Override
// protected void onError(ResponeThrowable ex) {
// Log.e("aaaaa", "onError: " + ex.message + "code: " + ex.code);
// }
//
// /**
// * 开始请求网络
// */
// @Override
// public void onStart() {
// super.onStart();
// // todo some common as show loadding and check netWork is NetworkAvailable
// }
// /**
// * 请求网络完成
// */
// @Override
// public void onCompleted() {
// }
// /**
// * 获取网络数据
// * @param t
// */
// @Override
// public void onNext(T t) {
//
// onSuccess(t);
// }
// public abstract void onSuccess(T t);
//
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/net/exception/ResponeThrowable.java
// public class ResponeThrowable extends Exception {
// public int code;
// public String message;
//
// public ResponeThrowable(Throwable throwable, int code) {
// super(throwable);
// this.code = code;
// }
// }
// Path: app/src/main/java/com/team/zhuoke/masterhelper/fragment/marster/MasterPresenter.java
import com.team.zhuoke.masterhelper.fragment.MasterInfoBean;
import com.team.zhuoke.masterhelper.net.callback.RxSubscriber;
import com.team.zhuoke.masterhelper.net.exception.ResponeThrowable;
import java.util.List;
package com.team.zhuoke.masterhelper.fragment.marster;
/**
* Created by WangQing on 2017/4/20.
*/
public class MasterPresenter extends MasterContract.Presenter{
@Override
void getMasterList() { | addSubscribe(mModel.getMasterData(mContext).subscribe(new RxSubscriber<List<MasterInfoBean>>() { |
ZhuoKeTeam/MasterHelper | app/src/main/java/com/team/zhuoke/masterhelper/fragment/marster/MasterPresenter.java | // Path: app/src/main/java/com/team/zhuoke/masterhelper/fragment/MasterInfoBean.java
// public class MasterInfoBean {
// /**
// * id : 1
// * uid : 1246141947
// * name : lmj623565791
// * nick_name : Hongyang
// * img : http://avatar.csdn.net/F/F/5/1_lmj623565791.jpg
// * info : 生命不息,奋斗不止,万事起于忽微,量变引起质变
// * isVip : 1
// * index : 0
// * blog : http://blog.csdn.net/lmj623565791?viewmode=contents
// */
//
// private int id;
// private String uid;
// private String name;
// private String nick_name;
// private String img;
// private String info;
// private String isVip;
// private int index;
// private String blog;
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public String getUid() {
// return uid;
// }
//
// public void setUid(String uid) {
// this.uid = uid;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getNick_name() {
// return nick_name;
// }
//
// public void setNick_name(String nick_name) {
// this.nick_name = nick_name;
// }
//
// public String getImg() {
// return img;
// }
//
// public void setImg(String img) {
// this.img = img;
// }
//
// public String getInfo() {
// return info;
// }
//
// public void setInfo(String info) {
// this.info = info;
// }
//
// public String getIsVip() {
// return isVip;
// }
//
// public void setIsVip(String isVip) {
// this.isVip = isVip;
// }
//
// public int getIndex() {
// return index;
// }
//
// public void setIndex(int index) {
// this.index = index;
// }
//
// public String getBlog() {
// return blog;
// }
//
// public void setBlog(String blog) {
// this.blog = blog;
// }
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/net/callback/RxSubscriber.java
// public abstract class RxSubscriber<T> extends ErrorSubscriber<T> {
//
//
//
// @Override
// protected void onError(ResponeThrowable ex) {
// Log.e("aaaaa", "onError: " + ex.message + "code: " + ex.code);
// }
//
// /**
// * 开始请求网络
// */
// @Override
// public void onStart() {
// super.onStart();
// // todo some common as show loadding and check netWork is NetworkAvailable
// }
// /**
// * 请求网络完成
// */
// @Override
// public void onCompleted() {
// }
// /**
// * 获取网络数据
// * @param t
// */
// @Override
// public void onNext(T t) {
//
// onSuccess(t);
// }
// public abstract void onSuccess(T t);
//
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/net/exception/ResponeThrowable.java
// public class ResponeThrowable extends Exception {
// public int code;
// public String message;
//
// public ResponeThrowable(Throwable throwable, int code) {
// super(throwable);
// this.code = code;
// }
// }
| import com.team.zhuoke.masterhelper.fragment.MasterInfoBean;
import com.team.zhuoke.masterhelper.net.callback.RxSubscriber;
import com.team.zhuoke.masterhelper.net.exception.ResponeThrowable;
import java.util.List; | package com.team.zhuoke.masterhelper.fragment.marster;
/**
* Created by WangQing on 2017/4/20.
*/
public class MasterPresenter extends MasterContract.Presenter{
@Override
void getMasterList() {
addSubscribe(mModel.getMasterData(mContext).subscribe(new RxSubscriber<List<MasterInfoBean>>() {
@Override
public void onSuccess(List<MasterInfoBean> masterInfoBeanList) {
mView.setData(masterInfoBeanList);
}
@Override | // Path: app/src/main/java/com/team/zhuoke/masterhelper/fragment/MasterInfoBean.java
// public class MasterInfoBean {
// /**
// * id : 1
// * uid : 1246141947
// * name : lmj623565791
// * nick_name : Hongyang
// * img : http://avatar.csdn.net/F/F/5/1_lmj623565791.jpg
// * info : 生命不息,奋斗不止,万事起于忽微,量变引起质变
// * isVip : 1
// * index : 0
// * blog : http://blog.csdn.net/lmj623565791?viewmode=contents
// */
//
// private int id;
// private String uid;
// private String name;
// private String nick_name;
// private String img;
// private String info;
// private String isVip;
// private int index;
// private String blog;
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public String getUid() {
// return uid;
// }
//
// public void setUid(String uid) {
// this.uid = uid;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getNick_name() {
// return nick_name;
// }
//
// public void setNick_name(String nick_name) {
// this.nick_name = nick_name;
// }
//
// public String getImg() {
// return img;
// }
//
// public void setImg(String img) {
// this.img = img;
// }
//
// public String getInfo() {
// return info;
// }
//
// public void setInfo(String info) {
// this.info = info;
// }
//
// public String getIsVip() {
// return isVip;
// }
//
// public void setIsVip(String isVip) {
// this.isVip = isVip;
// }
//
// public int getIndex() {
// return index;
// }
//
// public void setIndex(int index) {
// this.index = index;
// }
//
// public String getBlog() {
// return blog;
// }
//
// public void setBlog(String blog) {
// this.blog = blog;
// }
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/net/callback/RxSubscriber.java
// public abstract class RxSubscriber<T> extends ErrorSubscriber<T> {
//
//
//
// @Override
// protected void onError(ResponeThrowable ex) {
// Log.e("aaaaa", "onError: " + ex.message + "code: " + ex.code);
// }
//
// /**
// * 开始请求网络
// */
// @Override
// public void onStart() {
// super.onStart();
// // todo some common as show loadding and check netWork is NetworkAvailable
// }
// /**
// * 请求网络完成
// */
// @Override
// public void onCompleted() {
// }
// /**
// * 获取网络数据
// * @param t
// */
// @Override
// public void onNext(T t) {
//
// onSuccess(t);
// }
// public abstract void onSuccess(T t);
//
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/net/exception/ResponeThrowable.java
// public class ResponeThrowable extends Exception {
// public int code;
// public String message;
//
// public ResponeThrowable(Throwable throwable, int code) {
// super(throwable);
// this.code = code;
// }
// }
// Path: app/src/main/java/com/team/zhuoke/masterhelper/fragment/marster/MasterPresenter.java
import com.team.zhuoke.masterhelper.fragment.MasterInfoBean;
import com.team.zhuoke.masterhelper.net.callback.RxSubscriber;
import com.team.zhuoke.masterhelper.net.exception.ResponeThrowable;
import java.util.List;
package com.team.zhuoke.masterhelper.fragment.marster;
/**
* Created by WangQing on 2017/4/20.
*/
public class MasterPresenter extends MasterContract.Presenter{
@Override
void getMasterList() {
addSubscribe(mModel.getMasterData(mContext).subscribe(new RxSubscriber<List<MasterInfoBean>>() {
@Override
public void onSuccess(List<MasterInfoBean> masterInfoBeanList) {
mView.setData(masterInfoBeanList);
}
@Override | protected void onError(ResponeThrowable ex) { |
ZhuoKeTeam/MasterHelper | app/src/main/java/com/team/zhuoke/masterhelper/net/callback/RxSubscriber.java | // Path: app/src/main/java/com/team/zhuoke/masterhelper/net/exception/ResponeThrowable.java
// public class ResponeThrowable extends Exception {
// public int code;
// public String message;
//
// public ResponeThrowable(Throwable throwable, int code) {
// super(throwable);
// this.code = code;
// }
// }
| import android.util.Log;
import com.team.zhuoke.masterhelper.net.exception.ResponeThrowable; | package com.team.zhuoke.masterhelper.net.callback;
/**
* 作者:gaoyin
* 电话:18810474975
* 邮箱:18810474975@163.com
* 版本号:1.0
* 类描述:
* 备注消息:
* 修改时间:2016/11/24 上午10:56
**/
public abstract class RxSubscriber<T> extends ErrorSubscriber<T> {
@Override | // Path: app/src/main/java/com/team/zhuoke/masterhelper/net/exception/ResponeThrowable.java
// public class ResponeThrowable extends Exception {
// public int code;
// public String message;
//
// public ResponeThrowable(Throwable throwable, int code) {
// super(throwable);
// this.code = code;
// }
// }
// Path: app/src/main/java/com/team/zhuoke/masterhelper/net/callback/RxSubscriber.java
import android.util.Log;
import com.team.zhuoke.masterhelper.net.exception.ResponeThrowable;
package com.team.zhuoke.masterhelper.net.callback;
/**
* 作者:gaoyin
* 电话:18810474975
* 邮箱:18810474975@163.com
* 版本号:1.0
* 类描述:
* 备注消息:
* 修改时间:2016/11/24 上午10:56
**/
public abstract class RxSubscriber<T> extends ErrorSubscriber<T> {
@Override | protected void onError(ResponeThrowable ex) { |
ZhuoKeTeam/MasterHelper | app/src/main/java/com/yalantis/euclid/library/EuclidActivity.java | // Path: app/src/main/java/com/team/zhuoke/masterhelper/fragment/MasterInfoBean.java
// public class MasterInfoBean {
// /**
// * id : 1
// * uid : 1246141947
// * name : lmj623565791
// * nick_name : Hongyang
// * img : http://avatar.csdn.net/F/F/5/1_lmj623565791.jpg
// * info : 生命不息,奋斗不止,万事起于忽微,量变引起质变
// * isVip : 1
// * index : 0
// * blog : http://blog.csdn.net/lmj623565791?viewmode=contents
// */
//
// private int id;
// private String uid;
// private String name;
// private String nick_name;
// private String img;
// private String info;
// private String isVip;
// private int index;
// private String blog;
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public String getUid() {
// return uid;
// }
//
// public void setUid(String uid) {
// this.uid = uid;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getNick_name() {
// return nick_name;
// }
//
// public void setNick_name(String nick_name) {
// this.nick_name = nick_name;
// }
//
// public String getImg() {
// return img;
// }
//
// public void setImg(String img) {
// this.img = img;
// }
//
// public String getInfo() {
// return info;
// }
//
// public void setInfo(String info) {
// this.info = info;
// }
//
// public String getIsVip() {
// return isVip;
// }
//
// public void setIsVip(String isVip) {
// this.isVip = isVip;
// }
//
// public int getIndex() {
// return index;
// }
//
// public void setIndex(int index) {
// this.index = index;
// }
//
// public String getBlog() {
// return blog;
// }
//
// public void setBlog(String blog) {
// this.blog = blog;
// }
// }
| import android.animation.Animator;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.app.Activity;
import android.graphics.RectF;
import android.graphics.drawable.ShapeDrawable;
import android.graphics.drawable.shapes.RoundRectShape;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.AccelerateInterpolator;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.view.animation.DecelerateInterpolator;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.facebook.drawee.view.SimpleDraweeView;
import com.facebook.fresco.helper.ImageLoader;
import com.nhaarman.listviewanimations.appearance.ViewAnimator;
import com.nhaarman.listviewanimations.appearance.simple.SwingLeftInAnimationAdapter;
import com.team.zhuoke.masterhelper.R;
import com.team.zhuoke.masterhelper.fragment.MasterInfoBean;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import io.codetail.animation.SupportAnimator;
import io.codetail.animation.ViewAnimationUtils; | }
});
findViewById(R.id.toolbar_profile_back).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
animateCloseProfileDetails();
}
});
sScreenWidth = getResources().getDisplayMetrics().widthPixels;
sProfileImageHeight = getResources().getDimensionPixelSize(R.dimen.height_profile_image);
sOverlayShape = buildAvatarCircleOverlay();
initList();
}
private void initList() {
mListViewAnimationAdapter = new SwingLeftInAnimationAdapter(getAdapter());
mListViewAnimationAdapter.setAbsListView(mListView);
mListViewAnimator = mListViewAnimationAdapter.getViewAnimator();
if (mListViewAnimator != null) {
mListViewAnimator.setAnimationDurationMillis(getAnimationDurationCloseProfileDetails());
mListViewAnimator.disableAnimations();
}
mListView.setAdapter(mListViewAnimationAdapter);
mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
mState = EuclidState.Opening;
| // Path: app/src/main/java/com/team/zhuoke/masterhelper/fragment/MasterInfoBean.java
// public class MasterInfoBean {
// /**
// * id : 1
// * uid : 1246141947
// * name : lmj623565791
// * nick_name : Hongyang
// * img : http://avatar.csdn.net/F/F/5/1_lmj623565791.jpg
// * info : 生命不息,奋斗不止,万事起于忽微,量变引起质变
// * isVip : 1
// * index : 0
// * blog : http://blog.csdn.net/lmj623565791?viewmode=contents
// */
//
// private int id;
// private String uid;
// private String name;
// private String nick_name;
// private String img;
// private String info;
// private String isVip;
// private int index;
// private String blog;
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public String getUid() {
// return uid;
// }
//
// public void setUid(String uid) {
// this.uid = uid;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getNick_name() {
// return nick_name;
// }
//
// public void setNick_name(String nick_name) {
// this.nick_name = nick_name;
// }
//
// public String getImg() {
// return img;
// }
//
// public void setImg(String img) {
// this.img = img;
// }
//
// public String getInfo() {
// return info;
// }
//
// public void setInfo(String info) {
// this.info = info;
// }
//
// public String getIsVip() {
// return isVip;
// }
//
// public void setIsVip(String isVip) {
// this.isVip = isVip;
// }
//
// public int getIndex() {
// return index;
// }
//
// public void setIndex(int index) {
// this.index = index;
// }
//
// public String getBlog() {
// return blog;
// }
//
// public void setBlog(String blog) {
// this.blog = blog;
// }
// }
// Path: app/src/main/java/com/yalantis/euclid/library/EuclidActivity.java
import android.animation.Animator;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.app.Activity;
import android.graphics.RectF;
import android.graphics.drawable.ShapeDrawable;
import android.graphics.drawable.shapes.RoundRectShape;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.AccelerateInterpolator;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.view.animation.DecelerateInterpolator;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.facebook.drawee.view.SimpleDraweeView;
import com.facebook.fresco.helper.ImageLoader;
import com.nhaarman.listviewanimations.appearance.ViewAnimator;
import com.nhaarman.listviewanimations.appearance.simple.SwingLeftInAnimationAdapter;
import com.team.zhuoke.masterhelper.R;
import com.team.zhuoke.masterhelper.fragment.MasterInfoBean;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import io.codetail.animation.SupportAnimator;
import io.codetail.animation.ViewAnimationUtils;
}
});
findViewById(R.id.toolbar_profile_back).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
animateCloseProfileDetails();
}
});
sScreenWidth = getResources().getDisplayMetrics().widthPixels;
sProfileImageHeight = getResources().getDimensionPixelSize(R.dimen.height_profile_image);
sOverlayShape = buildAvatarCircleOverlay();
initList();
}
private void initList() {
mListViewAnimationAdapter = new SwingLeftInAnimationAdapter(getAdapter());
mListViewAnimationAdapter.setAbsListView(mListView);
mListViewAnimator = mListViewAnimationAdapter.getViewAnimator();
if (mListViewAnimator != null) {
mListViewAnimator.setAnimationDurationMillis(getAnimationDurationCloseProfileDetails());
mListViewAnimator.disableAnimations();
}
mListView.setAdapter(mListViewAnimationAdapter);
mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
mState = EuclidState.Opening;
| MasterInfoBean masterInfoBean = (MasterInfoBean) parent.getAdapter().getItem(position); |
ZhuoKeTeam/MasterHelper | app/src/main/java/com/team/zhuoke/masterhelper/fragment/marster/ArticleListContract.java | // Path: app/src/main/java/com/team/zhuoke/masterhelper/base/BaseView.java
// public interface BaseView<P> {
//
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/fragment/ArticleInfoBean.java
// public class ArticleInfoBean {
//
// /**
// * id : 14
// * uid : 1246141947
// * name : lmj623565791
// * nick_name : Hongyang
// * des : 生命不息,奋斗不止,万事起于忽微,量变引起质变
// * article_title : Android UI性能优化 检测应用中的UI卡顿
// * article_address : http://blog.csdn.net/lmj623565791/article/details/60874334
// */
//
// private int id;
// private long uid;
// private String name;
// private String nick_name;
// private String des;
// private String article_title;
// private String article_address;
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public long getUid() {
// return uid;
// }
//
// public void setUid(long uid) {
// this.uid = uid;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getNick_name() {
// return nick_name;
// }
//
// public void setNick_name(String nick_name) {
// this.nick_name = nick_name;
// }
//
// public String getDes() {
// return des;
// }
//
// public void setDes(String des) {
// this.des = des;
// }
//
// public String getArticle_title() {
// return article_title;
// }
//
// public void setArticle_title(String article_title) {
// this.article_title = article_title;
// }
//
// public String getArticle_address() {
// return article_address;
// }
//
// public void setArticle_address(String article_address) {
// this.article_address = article_address;
// }
//
// @Override
// public String toString() {
// return "ArticleInfoBean{" +
// "id=" + id +
// ", uid=" + uid +
// ", name='" + name + '\'' +
// ", nick_name='" + nick_name + '\'' +
// ", des='" + des + '\'' +
// ", article_title='" + article_title + '\'' +
// ", article_address='" + article_address + '\'' +
// '}';
// }
// }
| import com.team.zhuoke.masterhelper.base.BaseView;
import com.team.zhuoke.masterhelper.fragment.ArticleInfoBean;
import java.util.List; | package com.team.zhuoke.masterhelper.fragment.marster;
/**
* Created by renxl
* On 2017/4/21 18:45.
*/
interface ArticleListContract {
interface IArticleListView extends BaseView { | // Path: app/src/main/java/com/team/zhuoke/masterhelper/base/BaseView.java
// public interface BaseView<P> {
//
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/fragment/ArticleInfoBean.java
// public class ArticleInfoBean {
//
// /**
// * id : 14
// * uid : 1246141947
// * name : lmj623565791
// * nick_name : Hongyang
// * des : 生命不息,奋斗不止,万事起于忽微,量变引起质变
// * article_title : Android UI性能优化 检测应用中的UI卡顿
// * article_address : http://blog.csdn.net/lmj623565791/article/details/60874334
// */
//
// private int id;
// private long uid;
// private String name;
// private String nick_name;
// private String des;
// private String article_title;
// private String article_address;
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public long getUid() {
// return uid;
// }
//
// public void setUid(long uid) {
// this.uid = uid;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getNick_name() {
// return nick_name;
// }
//
// public void setNick_name(String nick_name) {
// this.nick_name = nick_name;
// }
//
// public String getDes() {
// return des;
// }
//
// public void setDes(String des) {
// this.des = des;
// }
//
// public String getArticle_title() {
// return article_title;
// }
//
// public void setArticle_title(String article_title) {
// this.article_title = article_title;
// }
//
// public String getArticle_address() {
// return article_address;
// }
//
// public void setArticle_address(String article_address) {
// this.article_address = article_address;
// }
//
// @Override
// public String toString() {
// return "ArticleInfoBean{" +
// "id=" + id +
// ", uid=" + uid +
// ", name='" + name + '\'' +
// ", nick_name='" + nick_name + '\'' +
// ", des='" + des + '\'' +
// ", article_title='" + article_title + '\'' +
// ", article_address='" + article_address + '\'' +
// '}';
// }
// }
// Path: app/src/main/java/com/team/zhuoke/masterhelper/fragment/marster/ArticleListContract.java
import com.team.zhuoke.masterhelper.base.BaseView;
import com.team.zhuoke.masterhelper.fragment.ArticleInfoBean;
import java.util.List;
package com.team.zhuoke.masterhelper.fragment.marster;
/**
* Created by renxl
* On 2017/4/21 18:45.
*/
interface ArticleListContract {
interface IArticleListView extends BaseView { | void setData(List<ArticleInfoBean> datas); |
ZhuoKeTeam/MasterHelper | app/src/main/java/com/team/zhuoke/masterhelper/fragment/main/MainFragmentPresenter.java | // Path: app/src/main/java/com/team/zhuoke/masterhelper/utils/adapter/CommonHeaderAdapter.java
// public abstract class CommonHeaderAdapter<H, N> extends BaseAdapter<H, N, Object> {
// private static final String TAG = "CommonHeaderAdapter";
//
// public CommonHeaderAdapter(List<N> ns) {
// super(ns);
// }
//
// @Override
// protected BaseHolder onCreateFooterVH(ViewGroup parent, int viewType) {
// return null;
// }
// }
| import android.view.ViewGroup;
import com.team.zhuoke.masterhelper.R;
import com.team.zhuoke.masterhelper.utils.adapter.CommonHeaderAdapter;
import java.util.ArrayList;
import java.util.List; | mModel.getVData(dataList -> {
mAdapter.setNormal(dataList, false);
mAdapter.notifyDataSetChanged();
});
mModel.getHData(new CallBack<List<HData>>() {
@Override
public void getSuccess(List<List<HData>> dataList) {
mAdapter.setHeader(dataList, false);
mAdapter.notifyDataSetChanged();
}
});
mView.setTitle("主页");
mView.setAdapter(mAdapter);
}
public static class HData {
public int resImg = R.drawable.photo;
}
public static class VData {
public int resImg = R.drawable.photo;
}
public interface CallBack<T> {
void getSuccess(List<T> dataList);
}
| // Path: app/src/main/java/com/team/zhuoke/masterhelper/utils/adapter/CommonHeaderAdapter.java
// public abstract class CommonHeaderAdapter<H, N> extends BaseAdapter<H, N, Object> {
// private static final String TAG = "CommonHeaderAdapter";
//
// public CommonHeaderAdapter(List<N> ns) {
// super(ns);
// }
//
// @Override
// protected BaseHolder onCreateFooterVH(ViewGroup parent, int viewType) {
// return null;
// }
// }
// Path: app/src/main/java/com/team/zhuoke/masterhelper/fragment/main/MainFragmentPresenter.java
import android.view.ViewGroup;
import com.team.zhuoke.masterhelper.R;
import com.team.zhuoke.masterhelper.utils.adapter.CommonHeaderAdapter;
import java.util.ArrayList;
import java.util.List;
mModel.getVData(dataList -> {
mAdapter.setNormal(dataList, false);
mAdapter.notifyDataSetChanged();
});
mModel.getHData(new CallBack<List<HData>>() {
@Override
public void getSuccess(List<List<HData>> dataList) {
mAdapter.setHeader(dataList, false);
mAdapter.notifyDataSetChanged();
}
});
mView.setTitle("主页");
mView.setAdapter(mAdapter);
}
public static class HData {
public int resImg = R.drawable.photo;
}
public static class VData {
public int resImg = R.drawable.photo;
}
public interface CallBack<T> {
void getSuccess(List<T> dataList);
}
| private class MainAdapter extends CommonHeaderAdapter<List<HData>, VData> { |
ZhuoKeTeam/MasterHelper | app/src/main/java/com/team/zhuoke/masterhelper/net/callback/ErrorSubscriber.java | // Path: app/src/main/java/com/team/zhuoke/masterhelper/net/exception/ResponeThrowable.java
// public class ResponeThrowable extends Exception {
// public int code;
// public String message;
//
// public ResponeThrowable(Throwable throwable, int code) {
// super(throwable);
// this.code = code;
// }
// }
| import com.team.zhuoke.masterhelper.net.exception.ResponeThrowable;
import rx.Subscriber; | package com.team.zhuoke.masterhelper.net.callback;
/**
* 作者:${User}
* 电话:18810474975
* 邮箱:18810474975@163.com
* 版本号:
* 类描述:
* 修改时间:${DATA}0056
*/
public abstract class ErrorSubscriber<T> extends Subscriber<T> {
@Override
public void onError(Throwable e) { | // Path: app/src/main/java/com/team/zhuoke/masterhelper/net/exception/ResponeThrowable.java
// public class ResponeThrowable extends Exception {
// public int code;
// public String message;
//
// public ResponeThrowable(Throwable throwable, int code) {
// super(throwable);
// this.code = code;
// }
// }
// Path: app/src/main/java/com/team/zhuoke/masterhelper/net/callback/ErrorSubscriber.java
import com.team.zhuoke.masterhelper.net.exception.ResponeThrowable;
import rx.Subscriber;
package com.team.zhuoke.masterhelper.net.callback;
/**
* 作者:${User}
* 电话:18810474975
* 邮箱:18810474975@163.com
* 版本号:
* 类描述:
* 修改时间:${DATA}0056
*/
public abstract class ErrorSubscriber<T> extends Subscriber<T> {
@Override
public void onError(Throwable e) { | if(e instanceof ResponeThrowable){ |
ZhuoKeTeam/MasterHelper | app/src/main/java/com/team/zhuoke/masterhelper/utils/SharedPreferenceCommen.java | // Path: app/src/main/java/com/team/zhuoke/masterhelper/ZhuoKeApplication.java
// public class ZhuoKeApplication extends Application {
// private static ZhuoKeApplication instance=null;
//
// public static ZhuoKeApplication getInstance(){
// return instance;
// }
//
// private static Context sContext;
//
// @Override
// public void onCreate() {
// super.onCreate();
// instance=this;
// sContext = this;
//
// L.init();
// initOkHttpUtils();
//
// Fresco.initialize(sContext);
//
// // 预加载X5
// // QbSdk.initX5Environment(getApplicationContext(), null);
// }
//
// /**
// * 初始化网络请求
// */
// private void initOkHttpUtils() {
// // Cookie
// CookieJarImpl cookieJar = new CookieJarImpl(new PersistentCookieStore(getApplicationContext()));
// // Https
// HttpsUtils.SSLParams sslParams = HttpsUtils.getSslSocketFactory(null, null, null);
//
// OkHttpClient okHttpClient = new OkHttpClient.Builder()
// .connectTimeout(10000L, TimeUnit.MILLISECONDS)
// .readTimeout(10000L, TimeUnit.MILLISECONDS)
// .sslSocketFactory(sslParams.sSLSocketFactory, sslParams.trustManager)
// .cookieJar(cookieJar)
// //其他配置
// .build();
// OkHttpUtils.initClient(okHttpClient);
// /**
// * 网络配置
// */
// NetWorkConfiguration configuration=new NetWorkConfiguration(this)
// .baseUrl(NetWorkApi.baseUrl)
// .isCache(true)
// .isDiskCache(true)
// .isMemoryCache(false);
// HttpUtils.setConFiguration(configuration);
//
//
// }
//
// public static Context getContext() {
// return sContext;
// }
//
// }
| import android.content.Context;
import android.content.SharedPreferences;
import com.team.zhuoke.masterhelper.ZhuoKeApplication;
import java.io.File; | package com.team.zhuoke.masterhelper.utils;
/**
* // TODO: 2016/11/26 变量名起的看不下去啦。。。 FIRSTBLOOD --> FIRST_BLOOD 看起来是不是比以前好看很多?
*
* Created by zhangchuanqiang on 2016/11/22.
*/
public class SharedPreferenceCommen {
Context mContext;
/**
* 第一次进入app
*/
public static String FIRSTBLOOD = "frist_blood";
public static final String SHAREDPREFERENCES = "sf";
public static SharedPreferences share_pf;
private static SharedPreferences getShare_pf() {
if (share_pf == null) { | // Path: app/src/main/java/com/team/zhuoke/masterhelper/ZhuoKeApplication.java
// public class ZhuoKeApplication extends Application {
// private static ZhuoKeApplication instance=null;
//
// public static ZhuoKeApplication getInstance(){
// return instance;
// }
//
// private static Context sContext;
//
// @Override
// public void onCreate() {
// super.onCreate();
// instance=this;
// sContext = this;
//
// L.init();
// initOkHttpUtils();
//
// Fresco.initialize(sContext);
//
// // 预加载X5
// // QbSdk.initX5Environment(getApplicationContext(), null);
// }
//
// /**
// * 初始化网络请求
// */
// private void initOkHttpUtils() {
// // Cookie
// CookieJarImpl cookieJar = new CookieJarImpl(new PersistentCookieStore(getApplicationContext()));
// // Https
// HttpsUtils.SSLParams sslParams = HttpsUtils.getSslSocketFactory(null, null, null);
//
// OkHttpClient okHttpClient = new OkHttpClient.Builder()
// .connectTimeout(10000L, TimeUnit.MILLISECONDS)
// .readTimeout(10000L, TimeUnit.MILLISECONDS)
// .sslSocketFactory(sslParams.sSLSocketFactory, sslParams.trustManager)
// .cookieJar(cookieJar)
// //其他配置
// .build();
// OkHttpUtils.initClient(okHttpClient);
// /**
// * 网络配置
// */
// NetWorkConfiguration configuration=new NetWorkConfiguration(this)
// .baseUrl(NetWorkApi.baseUrl)
// .isCache(true)
// .isDiskCache(true)
// .isMemoryCache(false);
// HttpUtils.setConFiguration(configuration);
//
//
// }
//
// public static Context getContext() {
// return sContext;
// }
//
// }
// Path: app/src/main/java/com/team/zhuoke/masterhelper/utils/SharedPreferenceCommen.java
import android.content.Context;
import android.content.SharedPreferences;
import com.team.zhuoke.masterhelper.ZhuoKeApplication;
import java.io.File;
package com.team.zhuoke.masterhelper.utils;
/**
* // TODO: 2016/11/26 变量名起的看不下去啦。。。 FIRSTBLOOD --> FIRST_BLOOD 看起来是不是比以前好看很多?
*
* Created by zhangchuanqiang on 2016/11/22.
*/
public class SharedPreferenceCommen {
Context mContext;
/**
* 第一次进入app
*/
public static String FIRSTBLOOD = "frist_blood";
public static final String SHAREDPREFERENCES = "sf";
public static SharedPreferences share_pf;
private static SharedPreferences getShare_pf() {
if (share_pf == null) { | share_pf = ZhuoKeApplication.getInstance().getSharedPreferences(SHAREDPREFERENCES, Context.MODE_PRIVATE); |
ZhuoKeTeam/MasterHelper | app/src/main/java/com/team/zhuoke/masterhelper/fragment/main/MainFragmentContract.java | // Path: app/src/main/java/com/team/zhuoke/masterhelper/utils/adapter/BaseAdapter.java
// public abstract class BaseAdapter<HeaderData, NormalData, FooterData> extends RecyclerView.Adapter<BaseAdapter.BaseHolder> {
// private List<NormalData> innerNormalList = new ArrayList<>(); //Normal节点
// private List<HeaderData> innerHeaderList = new ArrayList<>(); //Header节点
// private List<FooterData> innerFooterList = new ArrayList<>(); //Header节点
// private static final int TYPE_HEADER = 0;
// private static final int TYPE_NORMAL = 1;
// private static final int TYPE_FOOTER = 2;
//
//
// public BaseAdapter(List<NormalData> dataList) {
// this.innerNormalList.addAll(dataList);
// }
//
// public void setNormal(List<NormalData> dataList, boolean remove) {
// if (remove) {
// this.innerNormalList.clear();
// }
// this.innerNormalList.addAll(dataList);
// }
//
// public void setHeader(List<HeaderData> dataList, boolean remove) {
// if (remove) {
// this.innerHeaderList.clear();
// }
// this.innerHeaderList.addAll(dataList);
// }
//
//
// public void setFooter(List<FooterData> dataList, boolean remove) {
// if (remove) {
// this.innerFooterList.clear();
// }
// this.innerFooterList.addAll(dataList);
// }
//
// private static int getSizeOfList(List list) {
// return list != null ? list.size() : 0;
// }
//
// private int getHeaderCount() {
// return getSizeOfList(innerHeaderList);
// }
//
// private int getNormalCount() {
// return getSizeOfList(innerNormalList);
// }
//
// private int getFooterCount() {
// return getSizeOfList(innerFooterList);
// }
//
// @Override
// public BaseHolder onCreateViewHolder(ViewGroup parent, int viewType) {
// switch (viewType) {
// case TYPE_FOOTER:
// return onCreateFooterVH(parent, viewType);
// case TYPE_HEADER:
// return onCreateHeaderVH(parent, viewType);
// case TYPE_NORMAL:
// return onCreateNormalVH(parent, viewType);
// }
// return null;
// }
//
// protected abstract BaseHolder onCreateHeaderVH(ViewGroup parent, int viewType);
//
// protected abstract BaseHolder onCreateNormalVH(ViewGroup parent, int viewType);
//
// protected abstract BaseHolder onCreateFooterVH(ViewGroup parent, int viewType);
//
// @Override
// public void onBindViewHolder(BaseHolder holder, int position) {
// holder.bindData(getDataFromPosition(position));
// }
//
// private Object getDataFromPosition(int position) {
// int header = getHeaderCount();
// if (position < header) {
// return innerHeaderList.get(position);
// }
// int normal = getNormalCount();
// if (position < header + normal) {
// return innerNormalList.get(position - header);
// }
// int footer = getFooterCount();
// if (position < header + normal + footer) {
// return innerFooterList.get(position - header - normal);
// } else {
// throw new ArrayIndexOutOfBoundsException();
// }
// }
//
// @Override
// public int getItemViewType(int position) {
// int header = getHeaderCount();
// if (position < header) {
// return TYPE_HEADER;
// }
// int normal = getNormalCount();
// if (position < header + normal) {
// return TYPE_NORMAL;
// }
// int footer = getFooterCount();
// if (position < header + normal + footer) {
// return TYPE_FOOTER;
// } else {
// throw new ArrayIndexOutOfBoundsException();
// }
// }
//
// @Override
// public int getItemCount() {
// return getFooterCount() + getNormalCount() + getHeaderCount();
// }
//
// public static abstract class BaseHolder<T> extends RecyclerView.ViewHolder {
// protected View container;
//
// public BaseHolder(View itemView) {
// super(itemView);
// this.container = itemView;
// }
//
// public void bindData(T data) {
// onCover(container, data);
// }
//
// protected abstract void onCover(View view, T data);
//
//
// }
//
// }
| import android.support.v7.widget.RecyclerView;
import com.team.zhuoke.masterhelper.utils.adapter.BaseAdapter;
import java.util.List; | package com.team.zhuoke.masterhelper.fragment.main;
/**
* Created by kutear on 16-11-23.
*/
interface MainFragmentContract {
interface IMainFragmentView {
void setTitle(String title);
void setPresenter(IMainFragmentPresenter presenter);
| // Path: app/src/main/java/com/team/zhuoke/masterhelper/utils/adapter/BaseAdapter.java
// public abstract class BaseAdapter<HeaderData, NormalData, FooterData> extends RecyclerView.Adapter<BaseAdapter.BaseHolder> {
// private List<NormalData> innerNormalList = new ArrayList<>(); //Normal节点
// private List<HeaderData> innerHeaderList = new ArrayList<>(); //Header节点
// private List<FooterData> innerFooterList = new ArrayList<>(); //Header节点
// private static final int TYPE_HEADER = 0;
// private static final int TYPE_NORMAL = 1;
// private static final int TYPE_FOOTER = 2;
//
//
// public BaseAdapter(List<NormalData> dataList) {
// this.innerNormalList.addAll(dataList);
// }
//
// public void setNormal(List<NormalData> dataList, boolean remove) {
// if (remove) {
// this.innerNormalList.clear();
// }
// this.innerNormalList.addAll(dataList);
// }
//
// public void setHeader(List<HeaderData> dataList, boolean remove) {
// if (remove) {
// this.innerHeaderList.clear();
// }
// this.innerHeaderList.addAll(dataList);
// }
//
//
// public void setFooter(List<FooterData> dataList, boolean remove) {
// if (remove) {
// this.innerFooterList.clear();
// }
// this.innerFooterList.addAll(dataList);
// }
//
// private static int getSizeOfList(List list) {
// return list != null ? list.size() : 0;
// }
//
// private int getHeaderCount() {
// return getSizeOfList(innerHeaderList);
// }
//
// private int getNormalCount() {
// return getSizeOfList(innerNormalList);
// }
//
// private int getFooterCount() {
// return getSizeOfList(innerFooterList);
// }
//
// @Override
// public BaseHolder onCreateViewHolder(ViewGroup parent, int viewType) {
// switch (viewType) {
// case TYPE_FOOTER:
// return onCreateFooterVH(parent, viewType);
// case TYPE_HEADER:
// return onCreateHeaderVH(parent, viewType);
// case TYPE_NORMAL:
// return onCreateNormalVH(parent, viewType);
// }
// return null;
// }
//
// protected abstract BaseHolder onCreateHeaderVH(ViewGroup parent, int viewType);
//
// protected abstract BaseHolder onCreateNormalVH(ViewGroup parent, int viewType);
//
// protected abstract BaseHolder onCreateFooterVH(ViewGroup parent, int viewType);
//
// @Override
// public void onBindViewHolder(BaseHolder holder, int position) {
// holder.bindData(getDataFromPosition(position));
// }
//
// private Object getDataFromPosition(int position) {
// int header = getHeaderCount();
// if (position < header) {
// return innerHeaderList.get(position);
// }
// int normal = getNormalCount();
// if (position < header + normal) {
// return innerNormalList.get(position - header);
// }
// int footer = getFooterCount();
// if (position < header + normal + footer) {
// return innerFooterList.get(position - header - normal);
// } else {
// throw new ArrayIndexOutOfBoundsException();
// }
// }
//
// @Override
// public int getItemViewType(int position) {
// int header = getHeaderCount();
// if (position < header) {
// return TYPE_HEADER;
// }
// int normal = getNormalCount();
// if (position < header + normal) {
// return TYPE_NORMAL;
// }
// int footer = getFooterCount();
// if (position < header + normal + footer) {
// return TYPE_FOOTER;
// } else {
// throw new ArrayIndexOutOfBoundsException();
// }
// }
//
// @Override
// public int getItemCount() {
// return getFooterCount() + getNormalCount() + getHeaderCount();
// }
//
// public static abstract class BaseHolder<T> extends RecyclerView.ViewHolder {
// protected View container;
//
// public BaseHolder(View itemView) {
// super(itemView);
// this.container = itemView;
// }
//
// public void bindData(T data) {
// onCover(container, data);
// }
//
// protected abstract void onCover(View view, T data);
//
//
// }
//
// }
// Path: app/src/main/java/com/team/zhuoke/masterhelper/fragment/main/MainFragmentContract.java
import android.support.v7.widget.RecyclerView;
import com.team.zhuoke.masterhelper.utils.adapter.BaseAdapter;
import java.util.List;
package com.team.zhuoke.masterhelper.fragment.main;
/**
* Created by kutear on 16-11-23.
*/
interface MainFragmentContract {
interface IMainFragmentView {
void setTitle(String title);
void setPresenter(IMainFragmentPresenter presenter);
| BaseAdapter.BaseHolder getVItem(); |
ZhuoKeTeam/MasterHelper | app/src/main/java/com/team/zhuoke/masterhelper/activity/PageCtrl.java | // Path: app/src/main/java/com/team/zhuoke/masterhelper/WebViewActivity.java
// public class WebViewActivity extends AppCompatActivity {
//
// public static final String WEB_URL = "web_url";
// public static final String WEB_TITLE = "web_title";
//
// private WebView mWebView;
// private ProgressBar mProgressBar;
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_web_view);
//
// Intent intent = getIntent();
// String url = intent.getStringExtra(WEB_URL);
// String title = intent.getStringExtra(WEB_TITLE);
// setTitle(title);
//
// initView();
// mWebView.loadUrl(url);
// }
//
// private void initView() {
// mWebView = (WebView) findViewById(R.id.web_main);
// mProgressBar = (ProgressBar) findViewById(R.id.progressbar_webview);
// initWebView();
// }
//
// @SuppressLint("SetJavaScriptEnabled")
// private void initWebView() {
// mWebView.setWebViewClient(new WebViewClient() {
// @Override
// public boolean shouldOverrideUrlLoading(WebView webView, String s) {
// webView.loadUrl(s);
// return false;
// }
// });
//
// mWebView.setWebChromeClient(new WebChromeClient() {
// @Override
// public void onProgressChanged(WebView webView, int i) {
// super.onProgressChanged(webView, i);
// changeProgress(i);
// }
// });
//
// WebSettings webSettings = mWebView.getSettings();
// if (Utils.isNetworkConnected(getApplicationContext())) {
// webSettings.setCacheMode(WebSettings.LOAD_DEFAULT);
// } else {
// webSettings.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
// }
//
// webSettings.setJavaScriptEnabled(true);
// webSettings.setSupportZoom(true);
// webSettings.setBuiltInZoomControls(true);
//
// }
//
// private void changeProgress(int i) {
// if (i >= 0 && i < 100) {
// mProgressBar.setProgress(i);
// mProgressBar.setVisibility(View.VISIBLE);
// } else if (i == 100) {
// mProgressBar.setProgress(100);
// mProgressBar.setVisibility(View.GONE);
// }
// }
//
// @Override
// public boolean onKeyDown(int keyCode, KeyEvent event) {
// if (mWebView.canGoBack()) {
// mWebView.goBack();
// return true;
// }
// return super.onKeyDown(keyCode, event);
// }
// }
| import android.content.Context;
import android.content.Intent;
import com.team.zhuoke.masterhelper.WebViewActivity; | package com.team.zhuoke.masterhelper.activity;
/**
* Created by renxl
* On 2017/4/27 16:00.
*/
public class PageCtrl {
/**
* 跳转到大神文章详情WebView界面
*
* @param context 上下文
* @param url 网址
*/
public static void startArticleDetailActivity(Context context, String url, String title) { | // Path: app/src/main/java/com/team/zhuoke/masterhelper/WebViewActivity.java
// public class WebViewActivity extends AppCompatActivity {
//
// public static final String WEB_URL = "web_url";
// public static final String WEB_TITLE = "web_title";
//
// private WebView mWebView;
// private ProgressBar mProgressBar;
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_web_view);
//
// Intent intent = getIntent();
// String url = intent.getStringExtra(WEB_URL);
// String title = intent.getStringExtra(WEB_TITLE);
// setTitle(title);
//
// initView();
// mWebView.loadUrl(url);
// }
//
// private void initView() {
// mWebView = (WebView) findViewById(R.id.web_main);
// mProgressBar = (ProgressBar) findViewById(R.id.progressbar_webview);
// initWebView();
// }
//
// @SuppressLint("SetJavaScriptEnabled")
// private void initWebView() {
// mWebView.setWebViewClient(new WebViewClient() {
// @Override
// public boolean shouldOverrideUrlLoading(WebView webView, String s) {
// webView.loadUrl(s);
// return false;
// }
// });
//
// mWebView.setWebChromeClient(new WebChromeClient() {
// @Override
// public void onProgressChanged(WebView webView, int i) {
// super.onProgressChanged(webView, i);
// changeProgress(i);
// }
// });
//
// WebSettings webSettings = mWebView.getSettings();
// if (Utils.isNetworkConnected(getApplicationContext())) {
// webSettings.setCacheMode(WebSettings.LOAD_DEFAULT);
// } else {
// webSettings.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
// }
//
// webSettings.setJavaScriptEnabled(true);
// webSettings.setSupportZoom(true);
// webSettings.setBuiltInZoomControls(true);
//
// }
//
// private void changeProgress(int i) {
// if (i >= 0 && i < 100) {
// mProgressBar.setProgress(i);
// mProgressBar.setVisibility(View.VISIBLE);
// } else if (i == 100) {
// mProgressBar.setProgress(100);
// mProgressBar.setVisibility(View.GONE);
// }
// }
//
// @Override
// public boolean onKeyDown(int keyCode, KeyEvent event) {
// if (mWebView.canGoBack()) {
// mWebView.goBack();
// return true;
// }
// return super.onKeyDown(keyCode, event);
// }
// }
// Path: app/src/main/java/com/team/zhuoke/masterhelper/activity/PageCtrl.java
import android.content.Context;
import android.content.Intent;
import com.team.zhuoke.masterhelper.WebViewActivity;
package com.team.zhuoke.masterhelper.activity;
/**
* Created by renxl
* On 2017/4/27 16:00.
*/
public class PageCtrl {
/**
* 跳转到大神文章详情WebView界面
*
* @param context 上下文
* @param url 网址
*/
public static void startArticleDetailActivity(Context context, String url, String title) { | Intent intent = new Intent(context, WebViewActivity.class); |
ZhuoKeTeam/MasterHelper | app/src/main/java/wq/gdy005/mvp/TestActivity3.java | // Path: app/src/main/java/com/team/zhuoke/masterhelper/base/BaseActivity.java
// public abstract class BaseActivity<M extends BaseModel , P extends BasePresenter> extends RxAppCompatActivity {
//
// // 定义Presenter
// protected P mPresenter;
//
// // 获取布局资源文件
// protected abstract int getLayoutId();
//
// // 初始化数据
//
// protected abstract void onInitView(Bundle bundle);
//
// // 初始化事件Event
//
// protected abstract void onEvent();
//
// // 获取抽取View对象
// protected abstract BaseView getView();
// // 获得抽取接口Model对象
// protected Class getModelClazz() {
// return (Class<M>)ContractProxy.getModelClazz(getClass(), 0);
// }
// // 获得抽取接口Presenter对象
// protected Class getPresenterClazz() {
// return (Class<P>)ContractProxy.getPresnterClazz(getClass(), 1);
// }
// @Override
// protected void onCreate(@Nullable Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// if(getLayoutId()!=0)
// {
// // 设置布局资源文件
// setContentView(getLayoutId());
// bindMVP();
// // 注解绑定
// ButterKnife.bind(this);
// onInitView(savedInstanceState);
// onEvent();
// }
// }
//
// /**
// * 获取presenter 实例
// */
// private void bindMVP()
// {
// if(getPresenterClazz()!=null)
// {
// mPresenter=getPresenterImpl();
// mPresenter.mContext=this;
// bindVM();
// }
// }
// private <T> T getPresenterImpl()
// {
// return ContractProxy.getInstance().presenter(getPresenterClazz());
// }
// @Override
// protected void onStart() {
// if(mPresenter==null)
// {
// bindMVP();
// }
// super.onStart();
// }
// private void bindVM()
// {
// if(mPresenter!=null&&!mPresenter.isViewBind()&&getModelClazz()!=null&&getView()!=null)
// {
// ContractProxy.getInstance().bindModel(getModelClazz(),mPresenter);
// ContractProxy.getInstance().bindView(getView(),mPresenter);
// mPresenter.mContext=this;
// }
// }
//
// /**
// * activity摧毁
// */
// @Override
// protected void onDestroy() {
// super.onDestroy();
// if(mPresenter!=null)
// {
// ContractProxy.getInstance().unbindView(getView(),mPresenter);
// ContractProxy.getInstance().unbindModel(getModelClazz(),mPresenter);
// }
// }
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/base/BaseView.java
// public interface BaseView<P> {
//
// }
| import android.os.Bundle;
import android.widget.Button;
import android.widget.EditText;
import com.team.zhuoke.masterhelper.R;
import com.team.zhuoke.masterhelper.base.BaseActivity;
import com.team.zhuoke.masterhelper.base.BaseView;
import butterknife.BindView;
import butterknife.OnClick; | package wq.gdy005.mvp;
/**
* Created by WangQing on 2016/12/9.
*/
public class TestActivity3 extends BaseActivity<Test3Model, Test3Presenter> implements Test3Contract.View {
@BindView(R.id.edit_text)
EditText editText;
@BindView(R.id.btn_home)
Button btnHome;
@Override
public void setData(String s) {
editText.setText(s);
}
@Override
public void setErrorInfo(String message) {
editText.setText(message);
}
@Override
protected int getLayoutId() {
return R.layout.activity_test3;
}
@Override
protected void onInitView(Bundle bundle) {
}
@Override
protected void onEvent() {
}
@Override | // Path: app/src/main/java/com/team/zhuoke/masterhelper/base/BaseActivity.java
// public abstract class BaseActivity<M extends BaseModel , P extends BasePresenter> extends RxAppCompatActivity {
//
// // 定义Presenter
// protected P mPresenter;
//
// // 获取布局资源文件
// protected abstract int getLayoutId();
//
// // 初始化数据
//
// protected abstract void onInitView(Bundle bundle);
//
// // 初始化事件Event
//
// protected abstract void onEvent();
//
// // 获取抽取View对象
// protected abstract BaseView getView();
// // 获得抽取接口Model对象
// protected Class getModelClazz() {
// return (Class<M>)ContractProxy.getModelClazz(getClass(), 0);
// }
// // 获得抽取接口Presenter对象
// protected Class getPresenterClazz() {
// return (Class<P>)ContractProxy.getPresnterClazz(getClass(), 1);
// }
// @Override
// protected void onCreate(@Nullable Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// if(getLayoutId()!=0)
// {
// // 设置布局资源文件
// setContentView(getLayoutId());
// bindMVP();
// // 注解绑定
// ButterKnife.bind(this);
// onInitView(savedInstanceState);
// onEvent();
// }
// }
//
// /**
// * 获取presenter 实例
// */
// private void bindMVP()
// {
// if(getPresenterClazz()!=null)
// {
// mPresenter=getPresenterImpl();
// mPresenter.mContext=this;
// bindVM();
// }
// }
// private <T> T getPresenterImpl()
// {
// return ContractProxy.getInstance().presenter(getPresenterClazz());
// }
// @Override
// protected void onStart() {
// if(mPresenter==null)
// {
// bindMVP();
// }
// super.onStart();
// }
// private void bindVM()
// {
// if(mPresenter!=null&&!mPresenter.isViewBind()&&getModelClazz()!=null&&getView()!=null)
// {
// ContractProxy.getInstance().bindModel(getModelClazz(),mPresenter);
// ContractProxy.getInstance().bindView(getView(),mPresenter);
// mPresenter.mContext=this;
// }
// }
//
// /**
// * activity摧毁
// */
// @Override
// protected void onDestroy() {
// super.onDestroy();
// if(mPresenter!=null)
// {
// ContractProxy.getInstance().unbindView(getView(),mPresenter);
// ContractProxy.getInstance().unbindModel(getModelClazz(),mPresenter);
// }
// }
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/base/BaseView.java
// public interface BaseView<P> {
//
// }
// Path: app/src/main/java/wq/gdy005/mvp/TestActivity3.java
import android.os.Bundle;
import android.widget.Button;
import android.widget.EditText;
import com.team.zhuoke.masterhelper.R;
import com.team.zhuoke.masterhelper.base.BaseActivity;
import com.team.zhuoke.masterhelper.base.BaseView;
import butterknife.BindView;
import butterknife.OnClick;
package wq.gdy005.mvp;
/**
* Created by WangQing on 2016/12/9.
*/
public class TestActivity3 extends BaseActivity<Test3Model, Test3Presenter> implements Test3Contract.View {
@BindView(R.id.edit_text)
EditText editText;
@BindView(R.id.btn_home)
Button btnHome;
@Override
public void setData(String s) {
editText.setText(s);
}
@Override
public void setErrorInfo(String message) {
editText.setText(message);
}
@Override
protected int getLayoutId() {
return R.layout.activity_test3;
}
@Override
protected void onInitView(Bundle bundle) {
}
@Override
protected void onEvent() {
}
@Override | protected BaseView getView() { |
ZhuoKeTeam/MasterHelper | app/src/main/java/com/team/zhuoke/masterhelper/presenter/test/interfaces/SharePreferencesContract.java | // Path: app/src/main/java/com/team/zhuoke/masterhelper/base/BaseModel.java
// public interface BaseModel {
//
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/base/BasePresenter.java
// public abstract class BasePresenter<V extends BaseView, M extends BaseModel> implements Presenter<V,M> {
//
//
// protected Context mContext;
//
// protected V mView;
//
// protected M mModel;
//
// protected CompositeSubscription mCompositeSubscription;
//
// protected void unSubscribe() {
// if (mCompositeSubscription != null) {
// mCompositeSubscription.unsubscribe();
// }
// }
// protected void addSubscribe(Subscription subscription) {
// if (mCompositeSubscription == null) {
// mCompositeSubscription = new CompositeSubscription();
// }
// mCompositeSubscription.add(subscription);
// }
//
// // 获取绑定View实例
// @Override
// public void attachView(V view) {
// this.mView=view;
// }
// // 获取绑定Model层实例
// @Override
// public void attachModel(M m) {
// this.mModel=m;
// }
//
//
// public M getModel() {
// return mModel;
// }
// // 注销mModel实例
// @Override
// public void detachModel() {
// this.mModel=null;
// }
//
// // 注销View实例
// @Override
// public void detachView() {
// this.mView=null;
// unSubscribe();
// }
//
// public V getView() {
// return mView;
// }
//
// public boolean isViewBind()
// {
// return mView!=null;
// }
//
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/base/BaseView.java
// public interface BaseView<P> {
//
// }
| import com.team.zhuoke.masterhelper.base.BaseModel;
import com.team.zhuoke.masterhelper.base.BasePresenter;
import com.team.zhuoke.masterhelper.base.BaseView;
import java.util.List; | package com.team.zhuoke.masterhelper.presenter.test.interfaces;
/**
* Created by admin on 2017/1/11.
*/
public interface SharePreferencesContract {
interface View extends BaseView {
// 设置数据 数据类型为List<String>
void setUserInfo(List<String> userInfo);
// 设置数据 数据类型为List<String>
void setDeviceId(String deviceId);
// 设置错误信息 若List为空则显示无数据
void setErrorInfo(String message);
}
| // Path: app/src/main/java/com/team/zhuoke/masterhelper/base/BaseModel.java
// public interface BaseModel {
//
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/base/BasePresenter.java
// public abstract class BasePresenter<V extends BaseView, M extends BaseModel> implements Presenter<V,M> {
//
//
// protected Context mContext;
//
// protected V mView;
//
// protected M mModel;
//
// protected CompositeSubscription mCompositeSubscription;
//
// protected void unSubscribe() {
// if (mCompositeSubscription != null) {
// mCompositeSubscription.unsubscribe();
// }
// }
// protected void addSubscribe(Subscription subscription) {
// if (mCompositeSubscription == null) {
// mCompositeSubscription = new CompositeSubscription();
// }
// mCompositeSubscription.add(subscription);
// }
//
// // 获取绑定View实例
// @Override
// public void attachView(V view) {
// this.mView=view;
// }
// // 获取绑定Model层实例
// @Override
// public void attachModel(M m) {
// this.mModel=m;
// }
//
//
// public M getModel() {
// return mModel;
// }
// // 注销mModel实例
// @Override
// public void detachModel() {
// this.mModel=null;
// }
//
// // 注销View实例
// @Override
// public void detachView() {
// this.mView=null;
// unSubscribe();
// }
//
// public V getView() {
// return mView;
// }
//
// public boolean isViewBind()
// {
// return mView!=null;
// }
//
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/base/BaseView.java
// public interface BaseView<P> {
//
// }
// Path: app/src/main/java/com/team/zhuoke/masterhelper/presenter/test/interfaces/SharePreferencesContract.java
import com.team.zhuoke.masterhelper.base.BaseModel;
import com.team.zhuoke.masterhelper.base.BasePresenter;
import com.team.zhuoke.masterhelper.base.BaseView;
import java.util.List;
package com.team.zhuoke.masterhelper.presenter.test.interfaces;
/**
* Created by admin on 2017/1/11.
*/
public interface SharePreferencesContract {
interface View extends BaseView {
// 设置数据 数据类型为List<String>
void setUserInfo(List<String> userInfo);
// 设置数据 数据类型为List<String>
void setDeviceId(String deviceId);
// 设置错误信息 若List为空则显示无数据
void setErrorInfo(String message);
}
| interface Model extends BaseModel { |
ZhuoKeTeam/MasterHelper | app/src/main/java/com/team/zhuoke/masterhelper/presenter/test/interfaces/SharePreferencesContract.java | // Path: app/src/main/java/com/team/zhuoke/masterhelper/base/BaseModel.java
// public interface BaseModel {
//
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/base/BasePresenter.java
// public abstract class BasePresenter<V extends BaseView, M extends BaseModel> implements Presenter<V,M> {
//
//
// protected Context mContext;
//
// protected V mView;
//
// protected M mModel;
//
// protected CompositeSubscription mCompositeSubscription;
//
// protected void unSubscribe() {
// if (mCompositeSubscription != null) {
// mCompositeSubscription.unsubscribe();
// }
// }
// protected void addSubscribe(Subscription subscription) {
// if (mCompositeSubscription == null) {
// mCompositeSubscription = new CompositeSubscription();
// }
// mCompositeSubscription.add(subscription);
// }
//
// // 获取绑定View实例
// @Override
// public void attachView(V view) {
// this.mView=view;
// }
// // 获取绑定Model层实例
// @Override
// public void attachModel(M m) {
// this.mModel=m;
// }
//
//
// public M getModel() {
// return mModel;
// }
// // 注销mModel实例
// @Override
// public void detachModel() {
// this.mModel=null;
// }
//
// // 注销View实例
// @Override
// public void detachView() {
// this.mView=null;
// unSubscribe();
// }
//
// public V getView() {
// return mView;
// }
//
// public boolean isViewBind()
// {
// return mView!=null;
// }
//
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/base/BaseView.java
// public interface BaseView<P> {
//
// }
| import com.team.zhuoke.masterhelper.base.BaseModel;
import com.team.zhuoke.masterhelper.base.BasePresenter;
import com.team.zhuoke.masterhelper.base.BaseView;
import java.util.List; | package com.team.zhuoke.masterhelper.presenter.test.interfaces;
/**
* Created by admin on 2017/1/11.
*/
public interface SharePreferencesContract {
interface View extends BaseView {
// 设置数据 数据类型为List<String>
void setUserInfo(List<String> userInfo);
// 设置数据 数据类型为List<String>
void setDeviceId(String deviceId);
// 设置错误信息 若List为空则显示无数据
void setErrorInfo(String message);
}
interface Model extends BaseModel {
// 获取用户信息
List<String> userInfo();
// 获取设备号
String deviceId();
}
| // Path: app/src/main/java/com/team/zhuoke/masterhelper/base/BaseModel.java
// public interface BaseModel {
//
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/base/BasePresenter.java
// public abstract class BasePresenter<V extends BaseView, M extends BaseModel> implements Presenter<V,M> {
//
//
// protected Context mContext;
//
// protected V mView;
//
// protected M mModel;
//
// protected CompositeSubscription mCompositeSubscription;
//
// protected void unSubscribe() {
// if (mCompositeSubscription != null) {
// mCompositeSubscription.unsubscribe();
// }
// }
// protected void addSubscribe(Subscription subscription) {
// if (mCompositeSubscription == null) {
// mCompositeSubscription = new CompositeSubscription();
// }
// mCompositeSubscription.add(subscription);
// }
//
// // 获取绑定View实例
// @Override
// public void attachView(V view) {
// this.mView=view;
// }
// // 获取绑定Model层实例
// @Override
// public void attachModel(M m) {
// this.mModel=m;
// }
//
//
// public M getModel() {
// return mModel;
// }
// // 注销mModel实例
// @Override
// public void detachModel() {
// this.mModel=null;
// }
//
// // 注销View实例
// @Override
// public void detachView() {
// this.mView=null;
// unSubscribe();
// }
//
// public V getView() {
// return mView;
// }
//
// public boolean isViewBind()
// {
// return mView!=null;
// }
//
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/base/BaseView.java
// public interface BaseView<P> {
//
// }
// Path: app/src/main/java/com/team/zhuoke/masterhelper/presenter/test/interfaces/SharePreferencesContract.java
import com.team.zhuoke.masterhelper.base.BaseModel;
import com.team.zhuoke.masterhelper.base.BasePresenter;
import com.team.zhuoke.masterhelper.base.BaseView;
import java.util.List;
package com.team.zhuoke.masterhelper.presenter.test.interfaces;
/**
* Created by admin on 2017/1/11.
*/
public interface SharePreferencesContract {
interface View extends BaseView {
// 设置数据 数据类型为List<String>
void setUserInfo(List<String> userInfo);
// 设置数据 数据类型为List<String>
void setDeviceId(String deviceId);
// 设置错误信息 若List为空则显示无数据
void setErrorInfo(String message);
}
interface Model extends BaseModel {
// 获取用户信息
List<String> userInfo();
// 获取设备号
String deviceId();
}
| abstract class Presenter extends BasePresenter<SharePreferencesContract.View, SharePreferencesContract.Model> { |
ZhuoKeTeam/MasterHelper | app/src/main/java/com/team/zhuoke/masterhelper/model/ContractProxy.java | // Path: app/src/main/java/com/team/zhuoke/masterhelper/base/BaseModel.java
// public interface BaseModel {
//
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/base/BasePresenter.java
// public abstract class BasePresenter<V extends BaseView, M extends BaseModel> implements Presenter<V,M> {
//
//
// protected Context mContext;
//
// protected V mView;
//
// protected M mModel;
//
// protected CompositeSubscription mCompositeSubscription;
//
// protected void unSubscribe() {
// if (mCompositeSubscription != null) {
// mCompositeSubscription.unsubscribe();
// }
// }
// protected void addSubscribe(Subscription subscription) {
// if (mCompositeSubscription == null) {
// mCompositeSubscription = new CompositeSubscription();
// }
// mCompositeSubscription.add(subscription);
// }
//
// // 获取绑定View实例
// @Override
// public void attachView(V view) {
// this.mView=view;
// }
// // 获取绑定Model层实例
// @Override
// public void attachModel(M m) {
// this.mModel=m;
// }
//
//
// public M getModel() {
// return mModel;
// }
// // 注销mModel实例
// @Override
// public void detachModel() {
// this.mModel=null;
// }
//
// // 注销View实例
// @Override
// public void detachView() {
// this.mView=null;
// unSubscribe();
// }
//
// public V getView() {
// return mView;
// }
//
// public boolean isViewBind()
// {
// return mView!=null;
// }
//
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/base/BaseView.java
// public interface BaseView<P> {
//
// }
| import com.team.zhuoke.masterhelper.base.BaseModel;
import com.team.zhuoke.masterhelper.base.BasePresenter;
import com.team.zhuoke.masterhelper.base.BaseView;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.HashMap;
import java.util.Map; | package com.team.zhuoke.masterhelper.model;
public class ContractProxy {
private static final ContractProxy m_instance = new ContractProxy();
public static ContractProxy getInstance() {
return m_instance;
}
private ContractProxy() {
m_objects = new HashMap<>();
}
private Map<Class, Object> m_objects;
// /**
// * 进行初始化
// *
// * @param clss
// */
// public void init(Class... clss) {
// for (Class cls : clss) {
// if (cls.isAnnotationPresent(Implement.class)) {
//// list.add(cls);
// for (Annotation ann : cls.getDeclaredAnnotations()) {
// if (ann instanceof Implement) {
// try {
// m_objects.put(cls, ((Implement) ann).value().newInstance());
// } catch (InstantiationException e) {
// e.printStackTrace();
// } catch (IllegalAccessException e) {
// e.printStackTrace();
// }
// }
// }
// }
// }
// }
/**
* Presenter
* 通过反射, 获得定义Class时声明的父类的泛型参数的类型.
*
*@param clazz
* clazz The class to introspect
* @param index
* the Index of the generic ddeclaration,start from 0.
* @return the index generic declaration, or Object.class if cannot be
* determined
*/
@SuppressWarnings("unchecked") | // Path: app/src/main/java/com/team/zhuoke/masterhelper/base/BaseModel.java
// public interface BaseModel {
//
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/base/BasePresenter.java
// public abstract class BasePresenter<V extends BaseView, M extends BaseModel> implements Presenter<V,M> {
//
//
// protected Context mContext;
//
// protected V mView;
//
// protected M mModel;
//
// protected CompositeSubscription mCompositeSubscription;
//
// protected void unSubscribe() {
// if (mCompositeSubscription != null) {
// mCompositeSubscription.unsubscribe();
// }
// }
// protected void addSubscribe(Subscription subscription) {
// if (mCompositeSubscription == null) {
// mCompositeSubscription = new CompositeSubscription();
// }
// mCompositeSubscription.add(subscription);
// }
//
// // 获取绑定View实例
// @Override
// public void attachView(V view) {
// this.mView=view;
// }
// // 获取绑定Model层实例
// @Override
// public void attachModel(M m) {
// this.mModel=m;
// }
//
//
// public M getModel() {
// return mModel;
// }
// // 注销mModel实例
// @Override
// public void detachModel() {
// this.mModel=null;
// }
//
// // 注销View实例
// @Override
// public void detachView() {
// this.mView=null;
// unSubscribe();
// }
//
// public V getView() {
// return mView;
// }
//
// public boolean isViewBind()
// {
// return mView!=null;
// }
//
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/base/BaseView.java
// public interface BaseView<P> {
//
// }
// Path: app/src/main/java/com/team/zhuoke/masterhelper/model/ContractProxy.java
import com.team.zhuoke.masterhelper.base.BaseModel;
import com.team.zhuoke.masterhelper.base.BasePresenter;
import com.team.zhuoke.masterhelper.base.BaseView;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.HashMap;
import java.util.Map;
package com.team.zhuoke.masterhelper.model;
public class ContractProxy {
private static final ContractProxy m_instance = new ContractProxy();
public static ContractProxy getInstance() {
return m_instance;
}
private ContractProxy() {
m_objects = new HashMap<>();
}
private Map<Class, Object> m_objects;
// /**
// * 进行初始化
// *
// * @param clss
// */
// public void init(Class... clss) {
// for (Class cls : clss) {
// if (cls.isAnnotationPresent(Implement.class)) {
//// list.add(cls);
// for (Annotation ann : cls.getDeclaredAnnotations()) {
// if (ann instanceof Implement) {
// try {
// m_objects.put(cls, ((Implement) ann).value().newInstance());
// } catch (InstantiationException e) {
// e.printStackTrace();
// } catch (IllegalAccessException e) {
// e.printStackTrace();
// }
// }
// }
// }
// }
// }
/**
* Presenter
* 通过反射, 获得定义Class时声明的父类的泛型参数的类型.
*
*@param clazz
* clazz The class to introspect
* @param index
* the Index of the generic ddeclaration,start from 0.
* @return the index generic declaration, or Object.class if cannot be
* determined
*/
@SuppressWarnings("unchecked") | public static Class<BasePresenter> getPresnterClazz(final Class clazz, final int index) { |
ZhuoKeTeam/MasterHelper | app/src/main/java/com/team/zhuoke/masterhelper/model/ContractProxy.java | // Path: app/src/main/java/com/team/zhuoke/masterhelper/base/BaseModel.java
// public interface BaseModel {
//
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/base/BasePresenter.java
// public abstract class BasePresenter<V extends BaseView, M extends BaseModel> implements Presenter<V,M> {
//
//
// protected Context mContext;
//
// protected V mView;
//
// protected M mModel;
//
// protected CompositeSubscription mCompositeSubscription;
//
// protected void unSubscribe() {
// if (mCompositeSubscription != null) {
// mCompositeSubscription.unsubscribe();
// }
// }
// protected void addSubscribe(Subscription subscription) {
// if (mCompositeSubscription == null) {
// mCompositeSubscription = new CompositeSubscription();
// }
// mCompositeSubscription.add(subscription);
// }
//
// // 获取绑定View实例
// @Override
// public void attachView(V view) {
// this.mView=view;
// }
// // 获取绑定Model层实例
// @Override
// public void attachModel(M m) {
// this.mModel=m;
// }
//
//
// public M getModel() {
// return mModel;
// }
// // 注销mModel实例
// @Override
// public void detachModel() {
// this.mModel=null;
// }
//
// // 注销View实例
// @Override
// public void detachView() {
// this.mView=null;
// unSubscribe();
// }
//
// public V getView() {
// return mView;
// }
//
// public boolean isViewBind()
// {
// return mView!=null;
// }
//
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/base/BaseView.java
// public interface BaseView<P> {
//
// }
| import com.team.zhuoke.masterhelper.base.BaseModel;
import com.team.zhuoke.masterhelper.base.BasePresenter;
import com.team.zhuoke.masterhelper.base.BaseView;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.HashMap;
import java.util.Map; | package com.team.zhuoke.masterhelper.model;
public class ContractProxy {
private static final ContractProxy m_instance = new ContractProxy();
public static ContractProxy getInstance() {
return m_instance;
}
private ContractProxy() {
m_objects = new HashMap<>();
}
private Map<Class, Object> m_objects;
// /**
// * 进行初始化
// *
// * @param clss
// */
// public void init(Class... clss) {
// for (Class cls : clss) {
// if (cls.isAnnotationPresent(Implement.class)) {
//// list.add(cls);
// for (Annotation ann : cls.getDeclaredAnnotations()) {
// if (ann instanceof Implement) {
// try {
// m_objects.put(cls, ((Implement) ann).value().newInstance());
// } catch (InstantiationException e) {
// e.printStackTrace();
// } catch (IllegalAccessException e) {
// e.printStackTrace();
// }
// }
// }
// }
// }
// }
/**
* Presenter
* 通过反射, 获得定义Class时声明的父类的泛型参数的类型.
*
*@param clazz
* clazz The class to introspect
* @param index
* the Index of the generic ddeclaration,start from 0.
* @return the index generic declaration, or Object.class if cannot be
* determined
*/
@SuppressWarnings("unchecked")
public static Class<BasePresenter> getPresnterClazz(final Class clazz, final int index) {
//返回表示此 Class 所表示的实体(类、接口、基本类型或 void)的直接超类的 Type。
Type genType = clazz.getGenericSuperclass();
if (!(genType instanceof ParameterizedType)) {
return BasePresenter.class;
}
//返回表示此类型实际类型参数的 Type 对象的数组。
Type[] params = ((ParameterizedType) genType).getActualTypeArguments();
if (index >= params.length || index < 0) {
return BasePresenter.class;
}
if (!(params[index] instanceof Class)) {
return BasePresenter.class;
}
return (Class) params[index];
}
/**
* Model
* 通过反射, 获得定义Class时声明的父类的泛型参数的类型.
*
*@param clazz
* clazz The class to introspect
* @param index
* the Index of the generic ddeclaration,start from 0.
* @return the index generic declaration, or Object.class if cannot be
* determined
*/
@SuppressWarnings("unchecked") | // Path: app/src/main/java/com/team/zhuoke/masterhelper/base/BaseModel.java
// public interface BaseModel {
//
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/base/BasePresenter.java
// public abstract class BasePresenter<V extends BaseView, M extends BaseModel> implements Presenter<V,M> {
//
//
// protected Context mContext;
//
// protected V mView;
//
// protected M mModel;
//
// protected CompositeSubscription mCompositeSubscription;
//
// protected void unSubscribe() {
// if (mCompositeSubscription != null) {
// mCompositeSubscription.unsubscribe();
// }
// }
// protected void addSubscribe(Subscription subscription) {
// if (mCompositeSubscription == null) {
// mCompositeSubscription = new CompositeSubscription();
// }
// mCompositeSubscription.add(subscription);
// }
//
// // 获取绑定View实例
// @Override
// public void attachView(V view) {
// this.mView=view;
// }
// // 获取绑定Model层实例
// @Override
// public void attachModel(M m) {
// this.mModel=m;
// }
//
//
// public M getModel() {
// return mModel;
// }
// // 注销mModel实例
// @Override
// public void detachModel() {
// this.mModel=null;
// }
//
// // 注销View实例
// @Override
// public void detachView() {
// this.mView=null;
// unSubscribe();
// }
//
// public V getView() {
// return mView;
// }
//
// public boolean isViewBind()
// {
// return mView!=null;
// }
//
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/base/BaseView.java
// public interface BaseView<P> {
//
// }
// Path: app/src/main/java/com/team/zhuoke/masterhelper/model/ContractProxy.java
import com.team.zhuoke.masterhelper.base.BaseModel;
import com.team.zhuoke.masterhelper.base.BasePresenter;
import com.team.zhuoke.masterhelper.base.BaseView;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.HashMap;
import java.util.Map;
package com.team.zhuoke.masterhelper.model;
public class ContractProxy {
private static final ContractProxy m_instance = new ContractProxy();
public static ContractProxy getInstance() {
return m_instance;
}
private ContractProxy() {
m_objects = new HashMap<>();
}
private Map<Class, Object> m_objects;
// /**
// * 进行初始化
// *
// * @param clss
// */
// public void init(Class... clss) {
// for (Class cls : clss) {
// if (cls.isAnnotationPresent(Implement.class)) {
//// list.add(cls);
// for (Annotation ann : cls.getDeclaredAnnotations()) {
// if (ann instanceof Implement) {
// try {
// m_objects.put(cls, ((Implement) ann).value().newInstance());
// } catch (InstantiationException e) {
// e.printStackTrace();
// } catch (IllegalAccessException e) {
// e.printStackTrace();
// }
// }
// }
// }
// }
// }
/**
* Presenter
* 通过反射, 获得定义Class时声明的父类的泛型参数的类型.
*
*@param clazz
* clazz The class to introspect
* @param index
* the Index of the generic ddeclaration,start from 0.
* @return the index generic declaration, or Object.class if cannot be
* determined
*/
@SuppressWarnings("unchecked")
public static Class<BasePresenter> getPresnterClazz(final Class clazz, final int index) {
//返回表示此 Class 所表示的实体(类、接口、基本类型或 void)的直接超类的 Type。
Type genType = clazz.getGenericSuperclass();
if (!(genType instanceof ParameterizedType)) {
return BasePresenter.class;
}
//返回表示此类型实际类型参数的 Type 对象的数组。
Type[] params = ((ParameterizedType) genType).getActualTypeArguments();
if (index >= params.length || index < 0) {
return BasePresenter.class;
}
if (!(params[index] instanceof Class)) {
return BasePresenter.class;
}
return (Class) params[index];
}
/**
* Model
* 通过反射, 获得定义Class时声明的父类的泛型参数的类型.
*
*@param clazz
* clazz The class to introspect
* @param index
* the Index of the generic ddeclaration,start from 0.
* @return the index generic declaration, or Object.class if cannot be
* determined
*/
@SuppressWarnings("unchecked") | public static Class<BaseModel> getModelClazz(final Class clazz, final int index) { |
ZhuoKeTeam/MasterHelper | app/src/main/java/com/team/zhuoke/masterhelper/model/ContractProxy.java | // Path: app/src/main/java/com/team/zhuoke/masterhelper/base/BaseModel.java
// public interface BaseModel {
//
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/base/BasePresenter.java
// public abstract class BasePresenter<V extends BaseView, M extends BaseModel> implements Presenter<V,M> {
//
//
// protected Context mContext;
//
// protected V mView;
//
// protected M mModel;
//
// protected CompositeSubscription mCompositeSubscription;
//
// protected void unSubscribe() {
// if (mCompositeSubscription != null) {
// mCompositeSubscription.unsubscribe();
// }
// }
// protected void addSubscribe(Subscription subscription) {
// if (mCompositeSubscription == null) {
// mCompositeSubscription = new CompositeSubscription();
// }
// mCompositeSubscription.add(subscription);
// }
//
// // 获取绑定View实例
// @Override
// public void attachView(V view) {
// this.mView=view;
// }
// // 获取绑定Model层实例
// @Override
// public void attachModel(M m) {
// this.mModel=m;
// }
//
//
// public M getModel() {
// return mModel;
// }
// // 注销mModel实例
// @Override
// public void detachModel() {
// this.mModel=null;
// }
//
// // 注销View实例
// @Override
// public void detachView() {
// this.mView=null;
// unSubscribe();
// }
//
// public V getView() {
// return mView;
// }
//
// public boolean isViewBind()
// {
// return mView!=null;
// }
//
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/base/BaseView.java
// public interface BaseView<P> {
//
// }
| import com.team.zhuoke.masterhelper.base.BaseModel;
import com.team.zhuoke.masterhelper.base.BasePresenter;
import com.team.zhuoke.masterhelper.base.BaseView;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.HashMap;
import java.util.Map; |
//返回表示此 Class 所表示的实体(类、接口、基本类型或 void)的直接超类的 Type。
Type genType = clazz.getGenericSuperclass();
if (!(genType instanceof ParameterizedType)) {
return BaseModel.class;
}
//返回表示此类型实际类型参数的 Type 对象的数组。
Type[] params = ((ParameterizedType) genType).getActualTypeArguments();
if (index >= params.length || index < 0) {
return BaseModel.class;
}
if (!(params[index] instanceof Class)) {
return BaseModel.class;
}
return (Class) params[index];
}
/**
* View
* 通过反射, 获得定义Class时声明的父类的泛型参数的类型.
*
*@param clazz
* clazz The class to introspect
* @param index
* the Index of the generic ddeclaration,start from 0.
* @return the index generic declaration, or Object.class if cannot be
* determined
*/
@SuppressWarnings("unchecked") | // Path: app/src/main/java/com/team/zhuoke/masterhelper/base/BaseModel.java
// public interface BaseModel {
//
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/base/BasePresenter.java
// public abstract class BasePresenter<V extends BaseView, M extends BaseModel> implements Presenter<V,M> {
//
//
// protected Context mContext;
//
// protected V mView;
//
// protected M mModel;
//
// protected CompositeSubscription mCompositeSubscription;
//
// protected void unSubscribe() {
// if (mCompositeSubscription != null) {
// mCompositeSubscription.unsubscribe();
// }
// }
// protected void addSubscribe(Subscription subscription) {
// if (mCompositeSubscription == null) {
// mCompositeSubscription = new CompositeSubscription();
// }
// mCompositeSubscription.add(subscription);
// }
//
// // 获取绑定View实例
// @Override
// public void attachView(V view) {
// this.mView=view;
// }
// // 获取绑定Model层实例
// @Override
// public void attachModel(M m) {
// this.mModel=m;
// }
//
//
// public M getModel() {
// return mModel;
// }
// // 注销mModel实例
// @Override
// public void detachModel() {
// this.mModel=null;
// }
//
// // 注销View实例
// @Override
// public void detachView() {
// this.mView=null;
// unSubscribe();
// }
//
// public V getView() {
// return mView;
// }
//
// public boolean isViewBind()
// {
// return mView!=null;
// }
//
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/base/BaseView.java
// public interface BaseView<P> {
//
// }
// Path: app/src/main/java/com/team/zhuoke/masterhelper/model/ContractProxy.java
import com.team.zhuoke.masterhelper.base.BaseModel;
import com.team.zhuoke.masterhelper.base.BasePresenter;
import com.team.zhuoke.masterhelper.base.BaseView;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.HashMap;
import java.util.Map;
//返回表示此 Class 所表示的实体(类、接口、基本类型或 void)的直接超类的 Type。
Type genType = clazz.getGenericSuperclass();
if (!(genType instanceof ParameterizedType)) {
return BaseModel.class;
}
//返回表示此类型实际类型参数的 Type 对象的数组。
Type[] params = ((ParameterizedType) genType).getActualTypeArguments();
if (index >= params.length || index < 0) {
return BaseModel.class;
}
if (!(params[index] instanceof Class)) {
return BaseModel.class;
}
return (Class) params[index];
}
/**
* View
* 通过反射, 获得定义Class时声明的父类的泛型参数的类型.
*
*@param clazz
* clazz The class to introspect
* @param index
* the Index of the generic ddeclaration,start from 0.
* @return the index generic declaration, or Object.class if cannot be
* determined
*/
@SuppressWarnings("unchecked") | public static Class<BaseView> getViewClazz(final Class clazz, final int index) { |
ZhuoKeTeam/MasterHelper | app/src/main/java/wq/gdy005/mvp/Test3Presenter.java | // Path: app/src/main/java/com/team/zhuoke/masterhelper/model/test/TestList.java
// public class TestList {
//
//
// /**
// * des : 生命不息,奋斗不止,万事起于忽微,量变引起质变
// * grade : 1
// * img : http://tva2.sinaimg.cn/crop.200.80.480.480.180/bca65a60gw1eiedwawzi2j20m80i57a7.jpg
// * info : http://blog.csdn.net/lmj623565791
// * isVip : true
// * name : hongyang
// * weiBo :
// * zhiHu :
// */
//
// private String des;
// private String grade;
// private String img;
// private String info;
// private boolean isVip;
// private String name;
// private String weiBo;
// private String zhiHu;
//
// public String getDes() {
// return des;
// }
//
// public void setDes(String des) {
// this.des = des;
// }
//
// public String getGrade() {
// return grade;
// }
//
// public void setGrade(String grade) {
// this.grade = grade;
// }
//
// public String getImg() {
// return img;
// }
//
// public void setImg(String img) {
// this.img = img;
// }
//
// public String getInfo() {
// return info;
// }
//
// public void setInfo(String info) {
// this.info = info;
// }
//
// public boolean isIsVip() {
// return isVip;
// }
//
// public void setIsVip(boolean isVip) {
// this.isVip = isVip;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getWeiBo() {
// return weiBo;
// }
//
// public void setWeiBo(String weiBo) {
// this.weiBo = weiBo;
// }
//
// public String getZhiHu() {
// return zhiHu;
// }
//
// public void setZhiHu(String zhiHu) {
// this.zhiHu = zhiHu;
// }
//
//
// // 修改模板,快速生成
// @Override
// public String toString() {
// return "{" +
// "des:'" + des + '\'' +
// ", grade:'" + grade + '\'' +
// ", img:'" + img + '\'' +
// ", info:'" + info + '\'' +
// ", isVip:" + isVip +
// ", name:'" + name + '\'' +
// ", weiBo:'" + weiBo + '\'' +
// ", zhiHu:'" + zhiHu + '\'' +
// '}';
// }
//
// // @Override
// // public String toString() {
// // return "MasterList{" +
// // "des='" + des + '\'' +
// // ", grade='" + grade + '\'' +
// // ", img='" + img + '\'' +
// // ", info='" + info + '\'' +
// // ", isVip=" + isVip +
// // ", name='" + name + '\'' +
// // ", weiBo='" + weiBo + '\'' +
// // ", zhiHu='" + zhiHu + '\'' +
// // '}';
// // }
//
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/net/callback/RxSubscriber.java
// public abstract class RxSubscriber<T> extends ErrorSubscriber<T> {
//
//
//
// @Override
// protected void onError(ResponeThrowable ex) {
// Log.e("aaaaa", "onError: " + ex.message + "code: " + ex.code);
// }
//
// /**
// * 开始请求网络
// */
// @Override
// public void onStart() {
// super.onStart();
// // todo some common as show loadding and check netWork is NetworkAvailable
// }
// /**
// * 请求网络完成
// */
// @Override
// public void onCompleted() {
// }
// /**
// * 获取网络数据
// * @param t
// */
// @Override
// public void onNext(T t) {
//
// onSuccess(t);
// }
// public abstract void onSuccess(T t);
//
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/net/exception/ResponeThrowable.java
// public class ResponeThrowable extends Exception {
// public int code;
// public String message;
//
// public ResponeThrowable(Throwable throwable, int code) {
// super(throwable);
// this.code = code;
// }
// }
| import com.team.zhuoke.masterhelper.model.test.TestList;
import com.team.zhuoke.masterhelper.net.callback.RxSubscriber;
import com.team.zhuoke.masterhelper.net.exception.ResponeThrowable;
import java.util.List; | package wq.gdy005.mvp;
/**
* Created by WangQing on 2016/12/9.
*/
public class Test3Presenter extends Test3Contract.Presenter {
@Override
void getTestList() {
| // Path: app/src/main/java/com/team/zhuoke/masterhelper/model/test/TestList.java
// public class TestList {
//
//
// /**
// * des : 生命不息,奋斗不止,万事起于忽微,量变引起质变
// * grade : 1
// * img : http://tva2.sinaimg.cn/crop.200.80.480.480.180/bca65a60gw1eiedwawzi2j20m80i57a7.jpg
// * info : http://blog.csdn.net/lmj623565791
// * isVip : true
// * name : hongyang
// * weiBo :
// * zhiHu :
// */
//
// private String des;
// private String grade;
// private String img;
// private String info;
// private boolean isVip;
// private String name;
// private String weiBo;
// private String zhiHu;
//
// public String getDes() {
// return des;
// }
//
// public void setDes(String des) {
// this.des = des;
// }
//
// public String getGrade() {
// return grade;
// }
//
// public void setGrade(String grade) {
// this.grade = grade;
// }
//
// public String getImg() {
// return img;
// }
//
// public void setImg(String img) {
// this.img = img;
// }
//
// public String getInfo() {
// return info;
// }
//
// public void setInfo(String info) {
// this.info = info;
// }
//
// public boolean isIsVip() {
// return isVip;
// }
//
// public void setIsVip(boolean isVip) {
// this.isVip = isVip;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getWeiBo() {
// return weiBo;
// }
//
// public void setWeiBo(String weiBo) {
// this.weiBo = weiBo;
// }
//
// public String getZhiHu() {
// return zhiHu;
// }
//
// public void setZhiHu(String zhiHu) {
// this.zhiHu = zhiHu;
// }
//
//
// // 修改模板,快速生成
// @Override
// public String toString() {
// return "{" +
// "des:'" + des + '\'' +
// ", grade:'" + grade + '\'' +
// ", img:'" + img + '\'' +
// ", info:'" + info + '\'' +
// ", isVip:" + isVip +
// ", name:'" + name + '\'' +
// ", weiBo:'" + weiBo + '\'' +
// ", zhiHu:'" + zhiHu + '\'' +
// '}';
// }
//
// // @Override
// // public String toString() {
// // return "MasterList{" +
// // "des='" + des + '\'' +
// // ", grade='" + grade + '\'' +
// // ", img='" + img + '\'' +
// // ", info='" + info + '\'' +
// // ", isVip=" + isVip +
// // ", name='" + name + '\'' +
// // ", weiBo='" + weiBo + '\'' +
// // ", zhiHu='" + zhiHu + '\'' +
// // '}';
// // }
//
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/net/callback/RxSubscriber.java
// public abstract class RxSubscriber<T> extends ErrorSubscriber<T> {
//
//
//
// @Override
// protected void onError(ResponeThrowable ex) {
// Log.e("aaaaa", "onError: " + ex.message + "code: " + ex.code);
// }
//
// /**
// * 开始请求网络
// */
// @Override
// public void onStart() {
// super.onStart();
// // todo some common as show loadding and check netWork is NetworkAvailable
// }
// /**
// * 请求网络完成
// */
// @Override
// public void onCompleted() {
// }
// /**
// * 获取网络数据
// * @param t
// */
// @Override
// public void onNext(T t) {
//
// onSuccess(t);
// }
// public abstract void onSuccess(T t);
//
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/net/exception/ResponeThrowable.java
// public class ResponeThrowable extends Exception {
// public int code;
// public String message;
//
// public ResponeThrowable(Throwable throwable, int code) {
// super(throwable);
// this.code = code;
// }
// }
// Path: app/src/main/java/wq/gdy005/mvp/Test3Presenter.java
import com.team.zhuoke.masterhelper.model.test.TestList;
import com.team.zhuoke.masterhelper.net.callback.RxSubscriber;
import com.team.zhuoke.masterhelper.net.exception.ResponeThrowable;
import java.util.List;
package wq.gdy005.mvp;
/**
* Created by WangQing on 2016/12/9.
*/
public class Test3Presenter extends Test3Contract.Presenter {
@Override
void getTestList() {
| addSubscribe(mModel.testList(mContext).subscribe(new RxSubscriber<List<TestList>>() { |
ZhuoKeTeam/MasterHelper | app/src/main/java/wq/gdy005/mvp/Test3Presenter.java | // Path: app/src/main/java/com/team/zhuoke/masterhelper/model/test/TestList.java
// public class TestList {
//
//
// /**
// * des : 生命不息,奋斗不止,万事起于忽微,量变引起质变
// * grade : 1
// * img : http://tva2.sinaimg.cn/crop.200.80.480.480.180/bca65a60gw1eiedwawzi2j20m80i57a7.jpg
// * info : http://blog.csdn.net/lmj623565791
// * isVip : true
// * name : hongyang
// * weiBo :
// * zhiHu :
// */
//
// private String des;
// private String grade;
// private String img;
// private String info;
// private boolean isVip;
// private String name;
// private String weiBo;
// private String zhiHu;
//
// public String getDes() {
// return des;
// }
//
// public void setDes(String des) {
// this.des = des;
// }
//
// public String getGrade() {
// return grade;
// }
//
// public void setGrade(String grade) {
// this.grade = grade;
// }
//
// public String getImg() {
// return img;
// }
//
// public void setImg(String img) {
// this.img = img;
// }
//
// public String getInfo() {
// return info;
// }
//
// public void setInfo(String info) {
// this.info = info;
// }
//
// public boolean isIsVip() {
// return isVip;
// }
//
// public void setIsVip(boolean isVip) {
// this.isVip = isVip;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getWeiBo() {
// return weiBo;
// }
//
// public void setWeiBo(String weiBo) {
// this.weiBo = weiBo;
// }
//
// public String getZhiHu() {
// return zhiHu;
// }
//
// public void setZhiHu(String zhiHu) {
// this.zhiHu = zhiHu;
// }
//
//
// // 修改模板,快速生成
// @Override
// public String toString() {
// return "{" +
// "des:'" + des + '\'' +
// ", grade:'" + grade + '\'' +
// ", img:'" + img + '\'' +
// ", info:'" + info + '\'' +
// ", isVip:" + isVip +
// ", name:'" + name + '\'' +
// ", weiBo:'" + weiBo + '\'' +
// ", zhiHu:'" + zhiHu + '\'' +
// '}';
// }
//
// // @Override
// // public String toString() {
// // return "MasterList{" +
// // "des='" + des + '\'' +
// // ", grade='" + grade + '\'' +
// // ", img='" + img + '\'' +
// // ", info='" + info + '\'' +
// // ", isVip=" + isVip +
// // ", name='" + name + '\'' +
// // ", weiBo='" + weiBo + '\'' +
// // ", zhiHu='" + zhiHu + '\'' +
// // '}';
// // }
//
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/net/callback/RxSubscriber.java
// public abstract class RxSubscriber<T> extends ErrorSubscriber<T> {
//
//
//
// @Override
// protected void onError(ResponeThrowable ex) {
// Log.e("aaaaa", "onError: " + ex.message + "code: " + ex.code);
// }
//
// /**
// * 开始请求网络
// */
// @Override
// public void onStart() {
// super.onStart();
// // todo some common as show loadding and check netWork is NetworkAvailable
// }
// /**
// * 请求网络完成
// */
// @Override
// public void onCompleted() {
// }
// /**
// * 获取网络数据
// * @param t
// */
// @Override
// public void onNext(T t) {
//
// onSuccess(t);
// }
// public abstract void onSuccess(T t);
//
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/net/exception/ResponeThrowable.java
// public class ResponeThrowable extends Exception {
// public int code;
// public String message;
//
// public ResponeThrowable(Throwable throwable, int code) {
// super(throwable);
// this.code = code;
// }
// }
| import com.team.zhuoke.masterhelper.model.test.TestList;
import com.team.zhuoke.masterhelper.net.callback.RxSubscriber;
import com.team.zhuoke.masterhelper.net.exception.ResponeThrowable;
import java.util.List; | package wq.gdy005.mvp;
/**
* Created by WangQing on 2016/12/9.
*/
public class Test3Presenter extends Test3Contract.Presenter {
@Override
void getTestList() {
| // Path: app/src/main/java/com/team/zhuoke/masterhelper/model/test/TestList.java
// public class TestList {
//
//
// /**
// * des : 生命不息,奋斗不止,万事起于忽微,量变引起质变
// * grade : 1
// * img : http://tva2.sinaimg.cn/crop.200.80.480.480.180/bca65a60gw1eiedwawzi2j20m80i57a7.jpg
// * info : http://blog.csdn.net/lmj623565791
// * isVip : true
// * name : hongyang
// * weiBo :
// * zhiHu :
// */
//
// private String des;
// private String grade;
// private String img;
// private String info;
// private boolean isVip;
// private String name;
// private String weiBo;
// private String zhiHu;
//
// public String getDes() {
// return des;
// }
//
// public void setDes(String des) {
// this.des = des;
// }
//
// public String getGrade() {
// return grade;
// }
//
// public void setGrade(String grade) {
// this.grade = grade;
// }
//
// public String getImg() {
// return img;
// }
//
// public void setImg(String img) {
// this.img = img;
// }
//
// public String getInfo() {
// return info;
// }
//
// public void setInfo(String info) {
// this.info = info;
// }
//
// public boolean isIsVip() {
// return isVip;
// }
//
// public void setIsVip(boolean isVip) {
// this.isVip = isVip;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getWeiBo() {
// return weiBo;
// }
//
// public void setWeiBo(String weiBo) {
// this.weiBo = weiBo;
// }
//
// public String getZhiHu() {
// return zhiHu;
// }
//
// public void setZhiHu(String zhiHu) {
// this.zhiHu = zhiHu;
// }
//
//
// // 修改模板,快速生成
// @Override
// public String toString() {
// return "{" +
// "des:'" + des + '\'' +
// ", grade:'" + grade + '\'' +
// ", img:'" + img + '\'' +
// ", info:'" + info + '\'' +
// ", isVip:" + isVip +
// ", name:'" + name + '\'' +
// ", weiBo:'" + weiBo + '\'' +
// ", zhiHu:'" + zhiHu + '\'' +
// '}';
// }
//
// // @Override
// // public String toString() {
// // return "MasterList{" +
// // "des='" + des + '\'' +
// // ", grade='" + grade + '\'' +
// // ", img='" + img + '\'' +
// // ", info='" + info + '\'' +
// // ", isVip=" + isVip +
// // ", name='" + name + '\'' +
// // ", weiBo='" + weiBo + '\'' +
// // ", zhiHu='" + zhiHu + '\'' +
// // '}';
// // }
//
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/net/callback/RxSubscriber.java
// public abstract class RxSubscriber<T> extends ErrorSubscriber<T> {
//
//
//
// @Override
// protected void onError(ResponeThrowable ex) {
// Log.e("aaaaa", "onError: " + ex.message + "code: " + ex.code);
// }
//
// /**
// * 开始请求网络
// */
// @Override
// public void onStart() {
// super.onStart();
// // todo some common as show loadding and check netWork is NetworkAvailable
// }
// /**
// * 请求网络完成
// */
// @Override
// public void onCompleted() {
// }
// /**
// * 获取网络数据
// * @param t
// */
// @Override
// public void onNext(T t) {
//
// onSuccess(t);
// }
// public abstract void onSuccess(T t);
//
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/net/exception/ResponeThrowable.java
// public class ResponeThrowable extends Exception {
// public int code;
// public String message;
//
// public ResponeThrowable(Throwable throwable, int code) {
// super(throwable);
// this.code = code;
// }
// }
// Path: app/src/main/java/wq/gdy005/mvp/Test3Presenter.java
import com.team.zhuoke.masterhelper.model.test.TestList;
import com.team.zhuoke.masterhelper.net.callback.RxSubscriber;
import com.team.zhuoke.masterhelper.net.exception.ResponeThrowable;
import java.util.List;
package wq.gdy005.mvp;
/**
* Created by WangQing on 2016/12/9.
*/
public class Test3Presenter extends Test3Contract.Presenter {
@Override
void getTestList() {
| addSubscribe(mModel.testList(mContext).subscribe(new RxSubscriber<List<TestList>>() { |
ZhuoKeTeam/MasterHelper | app/src/main/java/wq/gdy005/mvp/Test3Presenter.java | // Path: app/src/main/java/com/team/zhuoke/masterhelper/model/test/TestList.java
// public class TestList {
//
//
// /**
// * des : 生命不息,奋斗不止,万事起于忽微,量变引起质变
// * grade : 1
// * img : http://tva2.sinaimg.cn/crop.200.80.480.480.180/bca65a60gw1eiedwawzi2j20m80i57a7.jpg
// * info : http://blog.csdn.net/lmj623565791
// * isVip : true
// * name : hongyang
// * weiBo :
// * zhiHu :
// */
//
// private String des;
// private String grade;
// private String img;
// private String info;
// private boolean isVip;
// private String name;
// private String weiBo;
// private String zhiHu;
//
// public String getDes() {
// return des;
// }
//
// public void setDes(String des) {
// this.des = des;
// }
//
// public String getGrade() {
// return grade;
// }
//
// public void setGrade(String grade) {
// this.grade = grade;
// }
//
// public String getImg() {
// return img;
// }
//
// public void setImg(String img) {
// this.img = img;
// }
//
// public String getInfo() {
// return info;
// }
//
// public void setInfo(String info) {
// this.info = info;
// }
//
// public boolean isIsVip() {
// return isVip;
// }
//
// public void setIsVip(boolean isVip) {
// this.isVip = isVip;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getWeiBo() {
// return weiBo;
// }
//
// public void setWeiBo(String weiBo) {
// this.weiBo = weiBo;
// }
//
// public String getZhiHu() {
// return zhiHu;
// }
//
// public void setZhiHu(String zhiHu) {
// this.zhiHu = zhiHu;
// }
//
//
// // 修改模板,快速生成
// @Override
// public String toString() {
// return "{" +
// "des:'" + des + '\'' +
// ", grade:'" + grade + '\'' +
// ", img:'" + img + '\'' +
// ", info:'" + info + '\'' +
// ", isVip:" + isVip +
// ", name:'" + name + '\'' +
// ", weiBo:'" + weiBo + '\'' +
// ", zhiHu:'" + zhiHu + '\'' +
// '}';
// }
//
// // @Override
// // public String toString() {
// // return "MasterList{" +
// // "des='" + des + '\'' +
// // ", grade='" + grade + '\'' +
// // ", img='" + img + '\'' +
// // ", info='" + info + '\'' +
// // ", isVip=" + isVip +
// // ", name='" + name + '\'' +
// // ", weiBo='" + weiBo + '\'' +
// // ", zhiHu='" + zhiHu + '\'' +
// // '}';
// // }
//
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/net/callback/RxSubscriber.java
// public abstract class RxSubscriber<T> extends ErrorSubscriber<T> {
//
//
//
// @Override
// protected void onError(ResponeThrowable ex) {
// Log.e("aaaaa", "onError: " + ex.message + "code: " + ex.code);
// }
//
// /**
// * 开始请求网络
// */
// @Override
// public void onStart() {
// super.onStart();
// // todo some common as show loadding and check netWork is NetworkAvailable
// }
// /**
// * 请求网络完成
// */
// @Override
// public void onCompleted() {
// }
// /**
// * 获取网络数据
// * @param t
// */
// @Override
// public void onNext(T t) {
//
// onSuccess(t);
// }
// public abstract void onSuccess(T t);
//
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/net/exception/ResponeThrowable.java
// public class ResponeThrowable extends Exception {
// public int code;
// public String message;
//
// public ResponeThrowable(Throwable throwable, int code) {
// super(throwable);
// this.code = code;
// }
// }
| import com.team.zhuoke.masterhelper.model.test.TestList;
import com.team.zhuoke.masterhelper.net.callback.RxSubscriber;
import com.team.zhuoke.masterhelper.net.exception.ResponeThrowable;
import java.util.List; | package wq.gdy005.mvp;
/**
* Created by WangQing on 2016/12/9.
*/
public class Test3Presenter extends Test3Contract.Presenter {
@Override
void getTestList() {
addSubscribe(mModel.testList(mContext).subscribe(new RxSubscriber<List<TestList>>() {
@Override
public void onSuccess(List<TestList> testLists) {
mView.setData(testLists.toString());
}
@Override | // Path: app/src/main/java/com/team/zhuoke/masterhelper/model/test/TestList.java
// public class TestList {
//
//
// /**
// * des : 生命不息,奋斗不止,万事起于忽微,量变引起质变
// * grade : 1
// * img : http://tva2.sinaimg.cn/crop.200.80.480.480.180/bca65a60gw1eiedwawzi2j20m80i57a7.jpg
// * info : http://blog.csdn.net/lmj623565791
// * isVip : true
// * name : hongyang
// * weiBo :
// * zhiHu :
// */
//
// private String des;
// private String grade;
// private String img;
// private String info;
// private boolean isVip;
// private String name;
// private String weiBo;
// private String zhiHu;
//
// public String getDes() {
// return des;
// }
//
// public void setDes(String des) {
// this.des = des;
// }
//
// public String getGrade() {
// return grade;
// }
//
// public void setGrade(String grade) {
// this.grade = grade;
// }
//
// public String getImg() {
// return img;
// }
//
// public void setImg(String img) {
// this.img = img;
// }
//
// public String getInfo() {
// return info;
// }
//
// public void setInfo(String info) {
// this.info = info;
// }
//
// public boolean isIsVip() {
// return isVip;
// }
//
// public void setIsVip(boolean isVip) {
// this.isVip = isVip;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getWeiBo() {
// return weiBo;
// }
//
// public void setWeiBo(String weiBo) {
// this.weiBo = weiBo;
// }
//
// public String getZhiHu() {
// return zhiHu;
// }
//
// public void setZhiHu(String zhiHu) {
// this.zhiHu = zhiHu;
// }
//
//
// // 修改模板,快速生成
// @Override
// public String toString() {
// return "{" +
// "des:'" + des + '\'' +
// ", grade:'" + grade + '\'' +
// ", img:'" + img + '\'' +
// ", info:'" + info + '\'' +
// ", isVip:" + isVip +
// ", name:'" + name + '\'' +
// ", weiBo:'" + weiBo + '\'' +
// ", zhiHu:'" + zhiHu + '\'' +
// '}';
// }
//
// // @Override
// // public String toString() {
// // return "MasterList{" +
// // "des='" + des + '\'' +
// // ", grade='" + grade + '\'' +
// // ", img='" + img + '\'' +
// // ", info='" + info + '\'' +
// // ", isVip=" + isVip +
// // ", name='" + name + '\'' +
// // ", weiBo='" + weiBo + '\'' +
// // ", zhiHu='" + zhiHu + '\'' +
// // '}';
// // }
//
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/net/callback/RxSubscriber.java
// public abstract class RxSubscriber<T> extends ErrorSubscriber<T> {
//
//
//
// @Override
// protected void onError(ResponeThrowable ex) {
// Log.e("aaaaa", "onError: " + ex.message + "code: " + ex.code);
// }
//
// /**
// * 开始请求网络
// */
// @Override
// public void onStart() {
// super.onStart();
// // todo some common as show loadding and check netWork is NetworkAvailable
// }
// /**
// * 请求网络完成
// */
// @Override
// public void onCompleted() {
// }
// /**
// * 获取网络数据
// * @param t
// */
// @Override
// public void onNext(T t) {
//
// onSuccess(t);
// }
// public abstract void onSuccess(T t);
//
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/net/exception/ResponeThrowable.java
// public class ResponeThrowable extends Exception {
// public int code;
// public String message;
//
// public ResponeThrowable(Throwable throwable, int code) {
// super(throwable);
// this.code = code;
// }
// }
// Path: app/src/main/java/wq/gdy005/mvp/Test3Presenter.java
import com.team.zhuoke.masterhelper.model.test.TestList;
import com.team.zhuoke.masterhelper.net.callback.RxSubscriber;
import com.team.zhuoke.masterhelper.net.exception.ResponeThrowable;
import java.util.List;
package wq.gdy005.mvp;
/**
* Created by WangQing on 2016/12/9.
*/
public class Test3Presenter extends Test3Contract.Presenter {
@Override
void getTestList() {
addSubscribe(mModel.testList(mContext).subscribe(new RxSubscriber<List<TestList>>() {
@Override
public void onSuccess(List<TestList> testLists) {
mView.setData(testLists.toString());
}
@Override | protected void onError(ResponeThrowable ex) { |
ZhuoKeTeam/MasterHelper | app/src/main/java/com/team/zhuoke/masterhelper/fragment/marster/MasterInfoApi.java | // Path: app/src/main/java/com/team/zhuoke/masterhelper/api/NetWorkApi.java
// public class NetWorkApi {
//
// public static String baseUrl = "https://zkteam.wilddogio.com";
// // test
// public static final String getMasterList = "/master_list.json";
// public static final String getTestList = "/master_list.json";
//
// public static final String newBaseUrl = "http://www.zkteam.cc";
//
// public static final String masterInfo = newBaseUrl + "/api/jsonMasterInfo";
// public static final String masterArticle = "/api/jsonMasterArticle";
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/fragment/MasterInfoBean.java
// public class MasterInfoBean {
// /**
// * id : 1
// * uid : 1246141947
// * name : lmj623565791
// * nick_name : Hongyang
// * img : http://avatar.csdn.net/F/F/5/1_lmj623565791.jpg
// * info : 生命不息,奋斗不止,万事起于忽微,量变引起质变
// * isVip : 1
// * index : 0
// * blog : http://blog.csdn.net/lmj623565791?viewmode=contents
// */
//
// private int id;
// private String uid;
// private String name;
// private String nick_name;
// private String img;
// private String info;
// private String isVip;
// private int index;
// private String blog;
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public String getUid() {
// return uid;
// }
//
// public void setUid(String uid) {
// this.uid = uid;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getNick_name() {
// return nick_name;
// }
//
// public void setNick_name(String nick_name) {
// this.nick_name = nick_name;
// }
//
// public String getImg() {
// return img;
// }
//
// public void setImg(String img) {
// this.img = img;
// }
//
// public String getInfo() {
// return info;
// }
//
// public void setInfo(String info) {
// this.info = info;
// }
//
// public String getIsVip() {
// return isVip;
// }
//
// public void setIsVip(String isVip) {
// this.isVip = isVip;
// }
//
// public int getIndex() {
// return index;
// }
//
// public void setIndex(int index) {
// this.index = index;
// }
//
// public String getBlog() {
// return blog;
// }
//
// public void setBlog(String blog) {
// this.blog = blog;
// }
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/net/response/HttpResponse.java
// public class HttpResponse<T> {
//
// private String code ;
//
// private T result;
//
// private String message;
//
// public String getCode() {
// return code;
// }
//
// public void setCode(String code) {
// this.code = code;
// }
//
// public T getResult() {
// return result;
// }
//
// public void setResult(T result) {
// this.result = result;
// }
//
// public String getMessage() {
// return message;
// }
//
// public void setMessage(String message) {
// this.message = message;
// }
//
// @Override
// public String toString() {
// return "{" +
// "code:'" + code + '\'' +
// ", result:" + result +
// ", message:'" + message + '\'' +
// '}';
// }
// }
| import com.team.zhuoke.masterhelper.api.NetWorkApi;
import com.team.zhuoke.masterhelper.fragment.MasterInfoBean;
import com.team.zhuoke.masterhelper.net.response.HttpResponse;
import java.util.List;
import retrofit2.http.GET;
import rx.Observable; | package com.team.zhuoke.masterhelper.fragment.marster;
/**
* Created by WangQing on 2017/4/20.
*/
public interface MasterInfoApi {
@GET(NetWorkApi.masterInfo) | // Path: app/src/main/java/com/team/zhuoke/masterhelper/api/NetWorkApi.java
// public class NetWorkApi {
//
// public static String baseUrl = "https://zkteam.wilddogio.com";
// // test
// public static final String getMasterList = "/master_list.json";
// public static final String getTestList = "/master_list.json";
//
// public static final String newBaseUrl = "http://www.zkteam.cc";
//
// public static final String masterInfo = newBaseUrl + "/api/jsonMasterInfo";
// public static final String masterArticle = "/api/jsonMasterArticle";
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/fragment/MasterInfoBean.java
// public class MasterInfoBean {
// /**
// * id : 1
// * uid : 1246141947
// * name : lmj623565791
// * nick_name : Hongyang
// * img : http://avatar.csdn.net/F/F/5/1_lmj623565791.jpg
// * info : 生命不息,奋斗不止,万事起于忽微,量变引起质变
// * isVip : 1
// * index : 0
// * blog : http://blog.csdn.net/lmj623565791?viewmode=contents
// */
//
// private int id;
// private String uid;
// private String name;
// private String nick_name;
// private String img;
// private String info;
// private String isVip;
// private int index;
// private String blog;
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public String getUid() {
// return uid;
// }
//
// public void setUid(String uid) {
// this.uid = uid;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getNick_name() {
// return nick_name;
// }
//
// public void setNick_name(String nick_name) {
// this.nick_name = nick_name;
// }
//
// public String getImg() {
// return img;
// }
//
// public void setImg(String img) {
// this.img = img;
// }
//
// public String getInfo() {
// return info;
// }
//
// public void setInfo(String info) {
// this.info = info;
// }
//
// public String getIsVip() {
// return isVip;
// }
//
// public void setIsVip(String isVip) {
// this.isVip = isVip;
// }
//
// public int getIndex() {
// return index;
// }
//
// public void setIndex(int index) {
// this.index = index;
// }
//
// public String getBlog() {
// return blog;
// }
//
// public void setBlog(String blog) {
// this.blog = blog;
// }
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/net/response/HttpResponse.java
// public class HttpResponse<T> {
//
// private String code ;
//
// private T result;
//
// private String message;
//
// public String getCode() {
// return code;
// }
//
// public void setCode(String code) {
// this.code = code;
// }
//
// public T getResult() {
// return result;
// }
//
// public void setResult(T result) {
// this.result = result;
// }
//
// public String getMessage() {
// return message;
// }
//
// public void setMessage(String message) {
// this.message = message;
// }
//
// @Override
// public String toString() {
// return "{" +
// "code:'" + code + '\'' +
// ", result:" + result +
// ", message:'" + message + '\'' +
// '}';
// }
// }
// Path: app/src/main/java/com/team/zhuoke/masterhelper/fragment/marster/MasterInfoApi.java
import com.team.zhuoke.masterhelper.api.NetWorkApi;
import com.team.zhuoke.masterhelper.fragment.MasterInfoBean;
import com.team.zhuoke.masterhelper.net.response.HttpResponse;
import java.util.List;
import retrofit2.http.GET;
import rx.Observable;
package com.team.zhuoke.masterhelper.fragment.marster;
/**
* Created by WangQing on 2017/4/20.
*/
public interface MasterInfoApi {
@GET(NetWorkApi.masterInfo) | Observable<HttpResponse<List<MasterInfoBean>>> getMasterList(); |
ZhuoKeTeam/MasterHelper | app/src/main/java/com/team/zhuoke/masterhelper/fragment/marster/MasterInfoApi.java | // Path: app/src/main/java/com/team/zhuoke/masterhelper/api/NetWorkApi.java
// public class NetWorkApi {
//
// public static String baseUrl = "https://zkteam.wilddogio.com";
// // test
// public static final String getMasterList = "/master_list.json";
// public static final String getTestList = "/master_list.json";
//
// public static final String newBaseUrl = "http://www.zkteam.cc";
//
// public static final String masterInfo = newBaseUrl + "/api/jsonMasterInfo";
// public static final String masterArticle = "/api/jsonMasterArticle";
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/fragment/MasterInfoBean.java
// public class MasterInfoBean {
// /**
// * id : 1
// * uid : 1246141947
// * name : lmj623565791
// * nick_name : Hongyang
// * img : http://avatar.csdn.net/F/F/5/1_lmj623565791.jpg
// * info : 生命不息,奋斗不止,万事起于忽微,量变引起质变
// * isVip : 1
// * index : 0
// * blog : http://blog.csdn.net/lmj623565791?viewmode=contents
// */
//
// private int id;
// private String uid;
// private String name;
// private String nick_name;
// private String img;
// private String info;
// private String isVip;
// private int index;
// private String blog;
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public String getUid() {
// return uid;
// }
//
// public void setUid(String uid) {
// this.uid = uid;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getNick_name() {
// return nick_name;
// }
//
// public void setNick_name(String nick_name) {
// this.nick_name = nick_name;
// }
//
// public String getImg() {
// return img;
// }
//
// public void setImg(String img) {
// this.img = img;
// }
//
// public String getInfo() {
// return info;
// }
//
// public void setInfo(String info) {
// this.info = info;
// }
//
// public String getIsVip() {
// return isVip;
// }
//
// public void setIsVip(String isVip) {
// this.isVip = isVip;
// }
//
// public int getIndex() {
// return index;
// }
//
// public void setIndex(int index) {
// this.index = index;
// }
//
// public String getBlog() {
// return blog;
// }
//
// public void setBlog(String blog) {
// this.blog = blog;
// }
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/net/response/HttpResponse.java
// public class HttpResponse<T> {
//
// private String code ;
//
// private T result;
//
// private String message;
//
// public String getCode() {
// return code;
// }
//
// public void setCode(String code) {
// this.code = code;
// }
//
// public T getResult() {
// return result;
// }
//
// public void setResult(T result) {
// this.result = result;
// }
//
// public String getMessage() {
// return message;
// }
//
// public void setMessage(String message) {
// this.message = message;
// }
//
// @Override
// public String toString() {
// return "{" +
// "code:'" + code + '\'' +
// ", result:" + result +
// ", message:'" + message + '\'' +
// '}';
// }
// }
| import com.team.zhuoke.masterhelper.api.NetWorkApi;
import com.team.zhuoke.masterhelper.fragment.MasterInfoBean;
import com.team.zhuoke.masterhelper.net.response.HttpResponse;
import java.util.List;
import retrofit2.http.GET;
import rx.Observable; | package com.team.zhuoke.masterhelper.fragment.marster;
/**
* Created by WangQing on 2017/4/20.
*/
public interface MasterInfoApi {
@GET(NetWorkApi.masterInfo) | // Path: app/src/main/java/com/team/zhuoke/masterhelper/api/NetWorkApi.java
// public class NetWorkApi {
//
// public static String baseUrl = "https://zkteam.wilddogio.com";
// // test
// public static final String getMasterList = "/master_list.json";
// public static final String getTestList = "/master_list.json";
//
// public static final String newBaseUrl = "http://www.zkteam.cc";
//
// public static final String masterInfo = newBaseUrl + "/api/jsonMasterInfo";
// public static final String masterArticle = "/api/jsonMasterArticle";
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/fragment/MasterInfoBean.java
// public class MasterInfoBean {
// /**
// * id : 1
// * uid : 1246141947
// * name : lmj623565791
// * nick_name : Hongyang
// * img : http://avatar.csdn.net/F/F/5/1_lmj623565791.jpg
// * info : 生命不息,奋斗不止,万事起于忽微,量变引起质变
// * isVip : 1
// * index : 0
// * blog : http://blog.csdn.net/lmj623565791?viewmode=contents
// */
//
// private int id;
// private String uid;
// private String name;
// private String nick_name;
// private String img;
// private String info;
// private String isVip;
// private int index;
// private String blog;
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public String getUid() {
// return uid;
// }
//
// public void setUid(String uid) {
// this.uid = uid;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getNick_name() {
// return nick_name;
// }
//
// public void setNick_name(String nick_name) {
// this.nick_name = nick_name;
// }
//
// public String getImg() {
// return img;
// }
//
// public void setImg(String img) {
// this.img = img;
// }
//
// public String getInfo() {
// return info;
// }
//
// public void setInfo(String info) {
// this.info = info;
// }
//
// public String getIsVip() {
// return isVip;
// }
//
// public void setIsVip(String isVip) {
// this.isVip = isVip;
// }
//
// public int getIndex() {
// return index;
// }
//
// public void setIndex(int index) {
// this.index = index;
// }
//
// public String getBlog() {
// return blog;
// }
//
// public void setBlog(String blog) {
// this.blog = blog;
// }
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/net/response/HttpResponse.java
// public class HttpResponse<T> {
//
// private String code ;
//
// private T result;
//
// private String message;
//
// public String getCode() {
// return code;
// }
//
// public void setCode(String code) {
// this.code = code;
// }
//
// public T getResult() {
// return result;
// }
//
// public void setResult(T result) {
// this.result = result;
// }
//
// public String getMessage() {
// return message;
// }
//
// public void setMessage(String message) {
// this.message = message;
// }
//
// @Override
// public String toString() {
// return "{" +
// "code:'" + code + '\'' +
// ", result:" + result +
// ", message:'" + message + '\'' +
// '}';
// }
// }
// Path: app/src/main/java/com/team/zhuoke/masterhelper/fragment/marster/MasterInfoApi.java
import com.team.zhuoke.masterhelper.api.NetWorkApi;
import com.team.zhuoke.masterhelper.fragment.MasterInfoBean;
import com.team.zhuoke.masterhelper.net.response.HttpResponse;
import java.util.List;
import retrofit2.http.GET;
import rx.Observable;
package com.team.zhuoke.masterhelper.fragment.marster;
/**
* Created by WangQing on 2017/4/20.
*/
public interface MasterInfoApi {
@GET(NetWorkApi.masterInfo) | Observable<HttpResponse<List<MasterInfoBean>>> getMasterList(); |
ZhuoKeTeam/MasterHelper | app/src/main/java/com/team/zhuoke/masterhelper/api/TestApi/TestApi.java | // Path: app/src/main/java/com/team/zhuoke/masterhelper/api/NetWorkApi.java
// public class NetWorkApi {
//
// public static String baseUrl = "https://zkteam.wilddogio.com";
// // test
// public static final String getMasterList = "/master_list.json";
// public static final String getTestList = "/master_list.json";
//
// public static final String newBaseUrl = "http://www.zkteam.cc";
//
// public static final String masterInfo = newBaseUrl + "/api/jsonMasterInfo";
// public static final String masterArticle = "/api/jsonMasterArticle";
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/model/test/MasterList.java
// public class MasterList {
//
// /**
// * des : 生命不息,奋斗不止,万事起于忽微,量变引起质变
// * grade : 1
// * img : http://tva2.sinaimg.cn/crop.200.80.480.480.180/bca65a60gw1eiedwawzi2j20m80i57a7.jpg
// * info : http://blog.csdn.net/lmj623565791
// * isVip : true
// * name : hongyang
// * weiBo :
// * zhiHu :
// */
//
// private String des;
// private String grade;
// private String img;
// private String info;
// private boolean isVip;
// private String name;
// private String weiBo;
// private String zhiHu;
//
// public String getDes() {
// return des;
// }
//
// public void setDes(String des) {
// this.des = des;
// }
//
// public String getGrade() {
// return grade;
// }
//
// public void setGrade(String grade) {
// this.grade = grade;
// }
//
// public String getImg() {
// return img;
// }
//
// public void setImg(String img) {
// this.img = img;
// }
//
// public String getInfo() {
// return info;
// }
//
// public void setInfo(String info) {
// this.info = info;
// }
//
// public boolean isIsVip() {
// return isVip;
// }
//
// public void setIsVip(boolean isVip) {
// this.isVip = isVip;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getWeiBo() {
// return weiBo;
// }
//
// public void setWeiBo(String weiBo) {
// this.weiBo = weiBo;
// }
//
// public String getZhiHu() {
// return zhiHu;
// }
//
// public void setZhiHu(String zhiHu) {
// this.zhiHu = zhiHu;
// }
//
// @Override
// public String toString() {
// return "MasterList{" +
// "des='" + des + '\'' +
// ", grade='" + grade + '\'' +
// ", img='" + img + '\'' +
// ", info='" + info + '\'' +
// ", isVip=" + isVip +
// ", name='" + name + '\'' +
// ", weiBo='" + weiBo + '\'' +
// ", zhiHu='" + zhiHu + '\'' +
// '}';
// }
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/net/response/HttpResponse.java
// public class HttpResponse<T> {
//
// private String code ;
//
// private T result;
//
// private String message;
//
// public String getCode() {
// return code;
// }
//
// public void setCode(String code) {
// this.code = code;
// }
//
// public T getResult() {
// return result;
// }
//
// public void setResult(T result) {
// this.result = result;
// }
//
// public String getMessage() {
// return message;
// }
//
// public void setMessage(String message) {
// this.message = message;
// }
//
// @Override
// public String toString() {
// return "{" +
// "code:'" + code + '\'' +
// ", result:" + result +
// ", message:'" + message + '\'' +
// '}';
// }
// }
| import com.team.zhuoke.masterhelper.api.NetWorkApi;
import com.team.zhuoke.masterhelper.model.test.MasterList;
import com.team.zhuoke.masterhelper.net.response.HttpResponse;
import java.util.List;
import retrofit2.http.GET;
import rx.Observable; | package com.team.zhuoke.masterhelper.api.TestApi;
/**
* 作者:${User}
* 电话:18810474975
* 邮箱:18810474975@163.com
* 版本号:
* 类描述:
* 修改时间:${DATA}1734
*/
public interface TestApi {
@GET(NetWorkApi.getMasterList) | // Path: app/src/main/java/com/team/zhuoke/masterhelper/api/NetWorkApi.java
// public class NetWorkApi {
//
// public static String baseUrl = "https://zkteam.wilddogio.com";
// // test
// public static final String getMasterList = "/master_list.json";
// public static final String getTestList = "/master_list.json";
//
// public static final String newBaseUrl = "http://www.zkteam.cc";
//
// public static final String masterInfo = newBaseUrl + "/api/jsonMasterInfo";
// public static final String masterArticle = "/api/jsonMasterArticle";
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/model/test/MasterList.java
// public class MasterList {
//
// /**
// * des : 生命不息,奋斗不止,万事起于忽微,量变引起质变
// * grade : 1
// * img : http://tva2.sinaimg.cn/crop.200.80.480.480.180/bca65a60gw1eiedwawzi2j20m80i57a7.jpg
// * info : http://blog.csdn.net/lmj623565791
// * isVip : true
// * name : hongyang
// * weiBo :
// * zhiHu :
// */
//
// private String des;
// private String grade;
// private String img;
// private String info;
// private boolean isVip;
// private String name;
// private String weiBo;
// private String zhiHu;
//
// public String getDes() {
// return des;
// }
//
// public void setDes(String des) {
// this.des = des;
// }
//
// public String getGrade() {
// return grade;
// }
//
// public void setGrade(String grade) {
// this.grade = grade;
// }
//
// public String getImg() {
// return img;
// }
//
// public void setImg(String img) {
// this.img = img;
// }
//
// public String getInfo() {
// return info;
// }
//
// public void setInfo(String info) {
// this.info = info;
// }
//
// public boolean isIsVip() {
// return isVip;
// }
//
// public void setIsVip(boolean isVip) {
// this.isVip = isVip;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getWeiBo() {
// return weiBo;
// }
//
// public void setWeiBo(String weiBo) {
// this.weiBo = weiBo;
// }
//
// public String getZhiHu() {
// return zhiHu;
// }
//
// public void setZhiHu(String zhiHu) {
// this.zhiHu = zhiHu;
// }
//
// @Override
// public String toString() {
// return "MasterList{" +
// "des='" + des + '\'' +
// ", grade='" + grade + '\'' +
// ", img='" + img + '\'' +
// ", info='" + info + '\'' +
// ", isVip=" + isVip +
// ", name='" + name + '\'' +
// ", weiBo='" + weiBo + '\'' +
// ", zhiHu='" + zhiHu + '\'' +
// '}';
// }
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/net/response/HttpResponse.java
// public class HttpResponse<T> {
//
// private String code ;
//
// private T result;
//
// private String message;
//
// public String getCode() {
// return code;
// }
//
// public void setCode(String code) {
// this.code = code;
// }
//
// public T getResult() {
// return result;
// }
//
// public void setResult(T result) {
// this.result = result;
// }
//
// public String getMessage() {
// return message;
// }
//
// public void setMessage(String message) {
// this.message = message;
// }
//
// @Override
// public String toString() {
// return "{" +
// "code:'" + code + '\'' +
// ", result:" + result +
// ", message:'" + message + '\'' +
// '}';
// }
// }
// Path: app/src/main/java/com/team/zhuoke/masterhelper/api/TestApi/TestApi.java
import com.team.zhuoke.masterhelper.api.NetWorkApi;
import com.team.zhuoke.masterhelper.model.test.MasterList;
import com.team.zhuoke.masterhelper.net.response.HttpResponse;
import java.util.List;
import retrofit2.http.GET;
import rx.Observable;
package com.team.zhuoke.masterhelper.api.TestApi;
/**
* 作者:${User}
* 电话:18810474975
* 邮箱:18810474975@163.com
* 版本号:
* 类描述:
* 修改时间:${DATA}1734
*/
public interface TestApi {
@GET(NetWorkApi.getMasterList) | Observable<HttpResponse<List<MasterList>>> getMasterList(); |
ZhuoKeTeam/MasterHelper | app/src/main/java/com/team/zhuoke/masterhelper/api/TestApi/TestApi.java | // Path: app/src/main/java/com/team/zhuoke/masterhelper/api/NetWorkApi.java
// public class NetWorkApi {
//
// public static String baseUrl = "https://zkteam.wilddogio.com";
// // test
// public static final String getMasterList = "/master_list.json";
// public static final String getTestList = "/master_list.json";
//
// public static final String newBaseUrl = "http://www.zkteam.cc";
//
// public static final String masterInfo = newBaseUrl + "/api/jsonMasterInfo";
// public static final String masterArticle = "/api/jsonMasterArticle";
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/model/test/MasterList.java
// public class MasterList {
//
// /**
// * des : 生命不息,奋斗不止,万事起于忽微,量变引起质变
// * grade : 1
// * img : http://tva2.sinaimg.cn/crop.200.80.480.480.180/bca65a60gw1eiedwawzi2j20m80i57a7.jpg
// * info : http://blog.csdn.net/lmj623565791
// * isVip : true
// * name : hongyang
// * weiBo :
// * zhiHu :
// */
//
// private String des;
// private String grade;
// private String img;
// private String info;
// private boolean isVip;
// private String name;
// private String weiBo;
// private String zhiHu;
//
// public String getDes() {
// return des;
// }
//
// public void setDes(String des) {
// this.des = des;
// }
//
// public String getGrade() {
// return grade;
// }
//
// public void setGrade(String grade) {
// this.grade = grade;
// }
//
// public String getImg() {
// return img;
// }
//
// public void setImg(String img) {
// this.img = img;
// }
//
// public String getInfo() {
// return info;
// }
//
// public void setInfo(String info) {
// this.info = info;
// }
//
// public boolean isIsVip() {
// return isVip;
// }
//
// public void setIsVip(boolean isVip) {
// this.isVip = isVip;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getWeiBo() {
// return weiBo;
// }
//
// public void setWeiBo(String weiBo) {
// this.weiBo = weiBo;
// }
//
// public String getZhiHu() {
// return zhiHu;
// }
//
// public void setZhiHu(String zhiHu) {
// this.zhiHu = zhiHu;
// }
//
// @Override
// public String toString() {
// return "MasterList{" +
// "des='" + des + '\'' +
// ", grade='" + grade + '\'' +
// ", img='" + img + '\'' +
// ", info='" + info + '\'' +
// ", isVip=" + isVip +
// ", name='" + name + '\'' +
// ", weiBo='" + weiBo + '\'' +
// ", zhiHu='" + zhiHu + '\'' +
// '}';
// }
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/net/response/HttpResponse.java
// public class HttpResponse<T> {
//
// private String code ;
//
// private T result;
//
// private String message;
//
// public String getCode() {
// return code;
// }
//
// public void setCode(String code) {
// this.code = code;
// }
//
// public T getResult() {
// return result;
// }
//
// public void setResult(T result) {
// this.result = result;
// }
//
// public String getMessage() {
// return message;
// }
//
// public void setMessage(String message) {
// this.message = message;
// }
//
// @Override
// public String toString() {
// return "{" +
// "code:'" + code + '\'' +
// ", result:" + result +
// ", message:'" + message + '\'' +
// '}';
// }
// }
| import com.team.zhuoke.masterhelper.api.NetWorkApi;
import com.team.zhuoke.masterhelper.model.test.MasterList;
import com.team.zhuoke.masterhelper.net.response.HttpResponse;
import java.util.List;
import retrofit2.http.GET;
import rx.Observable; | package com.team.zhuoke.masterhelper.api.TestApi;
/**
* 作者:${User}
* 电话:18810474975
* 邮箱:18810474975@163.com
* 版本号:
* 类描述:
* 修改时间:${DATA}1734
*/
public interface TestApi {
@GET(NetWorkApi.getMasterList) | // Path: app/src/main/java/com/team/zhuoke/masterhelper/api/NetWorkApi.java
// public class NetWorkApi {
//
// public static String baseUrl = "https://zkteam.wilddogio.com";
// // test
// public static final String getMasterList = "/master_list.json";
// public static final String getTestList = "/master_list.json";
//
// public static final String newBaseUrl = "http://www.zkteam.cc";
//
// public static final String masterInfo = newBaseUrl + "/api/jsonMasterInfo";
// public static final String masterArticle = "/api/jsonMasterArticle";
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/model/test/MasterList.java
// public class MasterList {
//
// /**
// * des : 生命不息,奋斗不止,万事起于忽微,量变引起质变
// * grade : 1
// * img : http://tva2.sinaimg.cn/crop.200.80.480.480.180/bca65a60gw1eiedwawzi2j20m80i57a7.jpg
// * info : http://blog.csdn.net/lmj623565791
// * isVip : true
// * name : hongyang
// * weiBo :
// * zhiHu :
// */
//
// private String des;
// private String grade;
// private String img;
// private String info;
// private boolean isVip;
// private String name;
// private String weiBo;
// private String zhiHu;
//
// public String getDes() {
// return des;
// }
//
// public void setDes(String des) {
// this.des = des;
// }
//
// public String getGrade() {
// return grade;
// }
//
// public void setGrade(String grade) {
// this.grade = grade;
// }
//
// public String getImg() {
// return img;
// }
//
// public void setImg(String img) {
// this.img = img;
// }
//
// public String getInfo() {
// return info;
// }
//
// public void setInfo(String info) {
// this.info = info;
// }
//
// public boolean isIsVip() {
// return isVip;
// }
//
// public void setIsVip(boolean isVip) {
// this.isVip = isVip;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getWeiBo() {
// return weiBo;
// }
//
// public void setWeiBo(String weiBo) {
// this.weiBo = weiBo;
// }
//
// public String getZhiHu() {
// return zhiHu;
// }
//
// public void setZhiHu(String zhiHu) {
// this.zhiHu = zhiHu;
// }
//
// @Override
// public String toString() {
// return "MasterList{" +
// "des='" + des + '\'' +
// ", grade='" + grade + '\'' +
// ", img='" + img + '\'' +
// ", info='" + info + '\'' +
// ", isVip=" + isVip +
// ", name='" + name + '\'' +
// ", weiBo='" + weiBo + '\'' +
// ", zhiHu='" + zhiHu + '\'' +
// '}';
// }
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/net/response/HttpResponse.java
// public class HttpResponse<T> {
//
// private String code ;
//
// private T result;
//
// private String message;
//
// public String getCode() {
// return code;
// }
//
// public void setCode(String code) {
// this.code = code;
// }
//
// public T getResult() {
// return result;
// }
//
// public void setResult(T result) {
// this.result = result;
// }
//
// public String getMessage() {
// return message;
// }
//
// public void setMessage(String message) {
// this.message = message;
// }
//
// @Override
// public String toString() {
// return "{" +
// "code:'" + code + '\'' +
// ", result:" + result +
// ", message:'" + message + '\'' +
// '}';
// }
// }
// Path: app/src/main/java/com/team/zhuoke/masterhelper/api/TestApi/TestApi.java
import com.team.zhuoke.masterhelper.api.NetWorkApi;
import com.team.zhuoke.masterhelper.model.test.MasterList;
import com.team.zhuoke.masterhelper.net.response.HttpResponse;
import java.util.List;
import retrofit2.http.GET;
import rx.Observable;
package com.team.zhuoke.masterhelper.api.TestApi;
/**
* 作者:${User}
* 电话:18810474975
* 邮箱:18810474975@163.com
* 版本号:
* 类描述:
* 修改时间:${DATA}1734
*/
public interface TestApi {
@GET(NetWorkApi.getMasterList) | Observable<HttpResponse<List<MasterList>>> getMasterList(); |
ZhuoKeTeam/MasterHelper | app/src/main/java/com/team/zhuoke/masterhelper/net/config/NetWorkConfiguration.java | // Path: app/src/main/java/com/team/zhuoke/masterhelper/utils/L.java
// public class L {
//
// private static final String DEFAULT_TAG = "masterhelper";
//
// //no instance
// private L() {
// }
//
// public static void init() {
//
// init(DEFAULT_TAG)
// .methodCount(3)
// .logLevel(BuildConfig.DEBUG ? LogLevel.FULL : LogLevel.NONE);
// }
//
// public static Settings init(String tag) {
// return Logger.init(tag);
// }
//
// public static void d(String message, Object... args) {
// Logger.d(message, args);
// }
//
// public static void d(Object object) {
// Logger.d(object);
// }
//
// public static void e(String message, Object... args) {
// Logger.e(message, args);
// }
//
// public static void e(Throwable throwable, String message, Object... args) {
// Logger.e(throwable, message, args);
// }
//
// public static void i(String message, Object... args) {
// Logger.i(message, args);
// }
//
// public static void v(String message, Object... args) {
// Logger.v(message, args);
// }
//
// public static void w(String message, Object... args) {
// Logger.w(message, args);
// }
//
// public static void wtf(String message, Object... args) {
// Logger.wtf(message, args);
// }
//
// public static void json(String json) {
// Logger.json(json);
// }
//
// public static void xml(String xml) {
// Logger.xml(xml);
// }
// }
| import android.content.Context;
import com.team.zhuoke.masterhelper.utils.L;
import java.io.File;
import java.io.InputStream;
import java.util.Arrays;
import java.util.concurrent.TimeUnit;
import okhttp3.Cache;
import okhttp3.ConnectionPool; | return this;
}
public boolean getIsDiskCache()
{
return this.isDiskCache;
}
/**
* 是否进行内存缓存
* @param memorycache
* @return
*/
public NetWorkConfiguration isMemoryCache(boolean memorycache)
{
this.isMemoryCache=memorycache;
return this;
}
public boolean getIsMemoryCache()
{
return this.isMemoryCache;
}
/**
* 设置内存缓存时间
* @param memorycachetime
* @return
*/
public NetWorkConfiguration memoryCacheTime(int memorycachetime)
{
if(memorycachetime<=0)
{ | // Path: app/src/main/java/com/team/zhuoke/masterhelper/utils/L.java
// public class L {
//
// private static final String DEFAULT_TAG = "masterhelper";
//
// //no instance
// private L() {
// }
//
// public static void init() {
//
// init(DEFAULT_TAG)
// .methodCount(3)
// .logLevel(BuildConfig.DEBUG ? LogLevel.FULL : LogLevel.NONE);
// }
//
// public static Settings init(String tag) {
// return Logger.init(tag);
// }
//
// public static void d(String message, Object... args) {
// Logger.d(message, args);
// }
//
// public static void d(Object object) {
// Logger.d(object);
// }
//
// public static void e(String message, Object... args) {
// Logger.e(message, args);
// }
//
// public static void e(Throwable throwable, String message, Object... args) {
// Logger.e(throwable, message, args);
// }
//
// public static void i(String message, Object... args) {
// Logger.i(message, args);
// }
//
// public static void v(String message, Object... args) {
// Logger.v(message, args);
// }
//
// public static void w(String message, Object... args) {
// Logger.w(message, args);
// }
//
// public static void wtf(String message, Object... args) {
// Logger.wtf(message, args);
// }
//
// public static void json(String json) {
// Logger.json(json);
// }
//
// public static void xml(String xml) {
// Logger.xml(xml);
// }
// }
// Path: app/src/main/java/com/team/zhuoke/masterhelper/net/config/NetWorkConfiguration.java
import android.content.Context;
import com.team.zhuoke.masterhelper.utils.L;
import java.io.File;
import java.io.InputStream;
import java.util.Arrays;
import java.util.concurrent.TimeUnit;
import okhttp3.Cache;
import okhttp3.ConnectionPool;
return this;
}
public boolean getIsDiskCache()
{
return this.isDiskCache;
}
/**
* 是否进行内存缓存
* @param memorycache
* @return
*/
public NetWorkConfiguration isMemoryCache(boolean memorycache)
{
this.isMemoryCache=memorycache;
return this;
}
public boolean getIsMemoryCache()
{
return this.isMemoryCache;
}
/**
* 设置内存缓存时间
* @param memorycachetime
* @return
*/
public NetWorkConfiguration memoryCacheTime(int memorycachetime)
{
if(memorycachetime<=0)
{ | L.e("NetWorkConfiguration", " configure memoryCacheTime exception!"); |
ZhuoKeTeam/MasterHelper | app/src/main/java/com/yalantis/euclid/library/EuclidListAdapter.java | // Path: app/src/main/java/com/team/zhuoke/masterhelper/fragment/MasterInfoBean.java
// public class MasterInfoBean {
// /**
// * id : 1
// * uid : 1246141947
// * name : lmj623565791
// * nick_name : Hongyang
// * img : http://avatar.csdn.net/F/F/5/1_lmj623565791.jpg
// * info : 生命不息,奋斗不止,万事起于忽微,量变引起质变
// * isVip : 1
// * index : 0
// * blog : http://blog.csdn.net/lmj623565791?viewmode=contents
// */
//
// private int id;
// private String uid;
// private String name;
// private String nick_name;
// private String img;
// private String info;
// private String isVip;
// private int index;
// private String blog;
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public String getUid() {
// return uid;
// }
//
// public void setUid(String uid) {
// this.uid = uid;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getNick_name() {
// return nick_name;
// }
//
// public void setNick_name(String nick_name) {
// this.nick_name = nick_name;
// }
//
// public String getImg() {
// return img;
// }
//
// public void setImg(String img) {
// this.img = img;
// }
//
// public String getInfo() {
// return info;
// }
//
// public void setInfo(String info) {
// this.info = info;
// }
//
// public String getIsVip() {
// return isVip;
// }
//
// public void setIsVip(String isVip) {
// this.isVip = isVip;
// }
//
// public int getIndex() {
// return index;
// }
//
// public void setIndex(int index) {
// this.index = index;
// }
//
// public String getBlog() {
// return blog;
// }
//
// public void setBlog(String blog) {
// this.blog = blog;
// }
// }
| import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import com.facebook.drawee.view.SimpleDraweeView;
import com.facebook.fresco.helper.ImageLoader;
import com.team.zhuoke.masterhelper.R;
import com.team.zhuoke.masterhelper.fragment.MasterInfoBean;
import java.util.List; | package com.yalantis.euclid.library;
/**
* Created by Oleksii Shliama on 1/27/15.
*/
public class EuclidListAdapter extends BaseAdapter {
public static final String KEY_AVATAR = "avatar";
public static final String KEY_NAME = "name";
public static final String KEY_DESCRIPTION_SHORT = "description_short";
public static final String KEY_DESCRIPTION_FULL = "description_full";
private final LayoutInflater mInflater; | // Path: app/src/main/java/com/team/zhuoke/masterhelper/fragment/MasterInfoBean.java
// public class MasterInfoBean {
// /**
// * id : 1
// * uid : 1246141947
// * name : lmj623565791
// * nick_name : Hongyang
// * img : http://avatar.csdn.net/F/F/5/1_lmj623565791.jpg
// * info : 生命不息,奋斗不止,万事起于忽微,量变引起质变
// * isVip : 1
// * index : 0
// * blog : http://blog.csdn.net/lmj623565791?viewmode=contents
// */
//
// private int id;
// private String uid;
// private String name;
// private String nick_name;
// private String img;
// private String info;
// private String isVip;
// private int index;
// private String blog;
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public String getUid() {
// return uid;
// }
//
// public void setUid(String uid) {
// this.uid = uid;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getNick_name() {
// return nick_name;
// }
//
// public void setNick_name(String nick_name) {
// this.nick_name = nick_name;
// }
//
// public String getImg() {
// return img;
// }
//
// public void setImg(String img) {
// this.img = img;
// }
//
// public String getInfo() {
// return info;
// }
//
// public void setInfo(String info) {
// this.info = info;
// }
//
// public String getIsVip() {
// return isVip;
// }
//
// public void setIsVip(String isVip) {
// this.isVip = isVip;
// }
//
// public int getIndex() {
// return index;
// }
//
// public void setIndex(int index) {
// this.index = index;
// }
//
// public String getBlog() {
// return blog;
// }
//
// public void setBlog(String blog) {
// this.blog = blog;
// }
// }
// Path: app/src/main/java/com/yalantis/euclid/library/EuclidListAdapter.java
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import com.facebook.drawee.view.SimpleDraweeView;
import com.facebook.fresco.helper.ImageLoader;
import com.team.zhuoke.masterhelper.R;
import com.team.zhuoke.masterhelper.fragment.MasterInfoBean;
import java.util.List;
package com.yalantis.euclid.library;
/**
* Created by Oleksii Shliama on 1/27/15.
*/
public class EuclidListAdapter extends BaseAdapter {
public static final String KEY_AVATAR = "avatar";
public static final String KEY_NAME = "name";
public static final String KEY_DESCRIPTION_SHORT = "description_short";
public static final String KEY_DESCRIPTION_FULL = "description_full";
private final LayoutInflater mInflater; | private List<MasterInfoBean> mData; |
ZhuoKeTeam/MasterHelper | app/src/main/java/com/team/zhuoke/masterhelper/net/interceptor/LogInterceptor.java | // Path: app/src/main/java/com/team/zhuoke/masterhelper/utils/L.java
// public class L {
//
// private static final String DEFAULT_TAG = "masterhelper";
//
// //no instance
// private L() {
// }
//
// public static void init() {
//
// init(DEFAULT_TAG)
// .methodCount(3)
// .logLevel(BuildConfig.DEBUG ? LogLevel.FULL : LogLevel.NONE);
// }
//
// public static Settings init(String tag) {
// return Logger.init(tag);
// }
//
// public static void d(String message, Object... args) {
// Logger.d(message, args);
// }
//
// public static void d(Object object) {
// Logger.d(object);
// }
//
// public static void e(String message, Object... args) {
// Logger.e(message, args);
// }
//
// public static void e(Throwable throwable, String message, Object... args) {
// Logger.e(throwable, message, args);
// }
//
// public static void i(String message, Object... args) {
// Logger.i(message, args);
// }
//
// public static void v(String message, Object... args) {
// Logger.v(message, args);
// }
//
// public static void w(String message, Object... args) {
// Logger.w(message, args);
// }
//
// public static void wtf(String message, Object... args) {
// Logger.wtf(message, args);
// }
//
// public static void json(String json) {
// Logger.json(json);
// }
//
// public static void xml(String xml) {
// Logger.xml(xml);
// }
// }
| import com.team.zhuoke.masterhelper.utils.L;
import java.io.IOException;
import okhttp3.Interceptor;
import okhttp3.MediaType;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.ResponseBody; | package com.team.zhuoke.masterhelper.net.interceptor;
/**
* 作者:gaoyin
* 电话:18810474975
* 邮箱:18810474975@163.com
* 版本号:1.0
* 类描述: 网络日志过滤器
* 备注消息:
* 修改时间:16/9/18 下午2:25
**/
public class LogInterceptor implements Interceptor{
@Override
public Response intercept(Chain chain) throws IOException {
Request request=chain.request();
Response response=chain.proceed(chain.request());
MediaType mediaType=response.body().contentType();
String content=response.body().string();
long t1 = System.nanoTime(); | // Path: app/src/main/java/com/team/zhuoke/masterhelper/utils/L.java
// public class L {
//
// private static final String DEFAULT_TAG = "masterhelper";
//
// //no instance
// private L() {
// }
//
// public static void init() {
//
// init(DEFAULT_TAG)
// .methodCount(3)
// .logLevel(BuildConfig.DEBUG ? LogLevel.FULL : LogLevel.NONE);
// }
//
// public static Settings init(String tag) {
// return Logger.init(tag);
// }
//
// public static void d(String message, Object... args) {
// Logger.d(message, args);
// }
//
// public static void d(Object object) {
// Logger.d(object);
// }
//
// public static void e(String message, Object... args) {
// Logger.e(message, args);
// }
//
// public static void e(Throwable throwable, String message, Object... args) {
// Logger.e(throwable, message, args);
// }
//
// public static void i(String message, Object... args) {
// Logger.i(message, args);
// }
//
// public static void v(String message, Object... args) {
// Logger.v(message, args);
// }
//
// public static void w(String message, Object... args) {
// Logger.w(message, args);
// }
//
// public static void wtf(String message, Object... args) {
// Logger.wtf(message, args);
// }
//
// public static void json(String json) {
// Logger.json(json);
// }
//
// public static void xml(String xml) {
// Logger.xml(xml);
// }
// }
// Path: app/src/main/java/com/team/zhuoke/masterhelper/net/interceptor/LogInterceptor.java
import com.team.zhuoke.masterhelper.utils.L;
import java.io.IOException;
import okhttp3.Interceptor;
import okhttp3.MediaType;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.ResponseBody;
package com.team.zhuoke.masterhelper.net.interceptor;
/**
* 作者:gaoyin
* 电话:18810474975
* 邮箱:18810474975@163.com
* 版本号:1.0
* 类描述: 网络日志过滤器
* 备注消息:
* 修改时间:16/9/18 下午2:25
**/
public class LogInterceptor implements Interceptor{
@Override
public Response intercept(Chain chain) throws IOException {
Request request=chain.request();
Response response=chain.proceed(chain.request());
MediaType mediaType=response.body().contentType();
String content=response.body().string();
long t1 = System.nanoTime(); | L.i(String.format("Sending request %s on %s%n%s", request.url(), chain.connection(), request.headers())); |
ZhuoKeTeam/MasterHelper | app/src/androidTest/java/com/team/zhuoke/masterhelper/AndroidTest.java | // Path: app/src/main/java/com/team/zhuoke/masterhelper/bean/MasterBean.java
// public class MasterBean {
// private String name;
// private String weiBo;
// private String zhiHu;
// private String grade;
// private boolean isVip;
// private String info;
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getWeiBo() {
// return weiBo;
// }
//
// public void setWeiBo(String weiBo) {
// this.weiBo = weiBo;
// }
//
// public String getZhiHu() {
// return zhiHu;
// }
//
// public void setZhiHu(String zhiHu) {
// this.zhiHu = zhiHu;
// }
//
// public String getGrade() {
// return grade;
// }
//
// public void setGrade(String grade) {
// this.grade = grade;
// }
//
// public boolean isVip() {
// return isVip;
// }
//
// public void setVip(boolean vip) {
// isVip = vip;
// }
//
// public String getInfo() {
// return info;
// }
//
// public void setInfo(String info) {
// this.info = info;
// }
//
// @Override
// public String toString() {
// return "{" +
// "name:'" + name + '\'' +
// ", weiBo:'" + weiBo + '\'' +
// ", zhiHu:'" + zhiHu + '\'' +
// ", grade:'" + grade + '\'' +
// ", isVip:" + isVip +
// ", info:'" + info + '\'' +
// '}';
// }
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/utils/L.java
// public class L {
//
// private static final String DEFAULT_TAG = "masterhelper";
//
// //no instance
// private L() {
// }
//
// public static void init() {
//
// init(DEFAULT_TAG)
// .methodCount(3)
// .logLevel(BuildConfig.DEBUG ? LogLevel.FULL : LogLevel.NONE);
// }
//
// public static Settings init(String tag) {
// return Logger.init(tag);
// }
//
// public static void d(String message, Object... args) {
// Logger.d(message, args);
// }
//
// public static void d(Object object) {
// Logger.d(object);
// }
//
// public static void e(String message, Object... args) {
// Logger.e(message, args);
// }
//
// public static void e(Throwable throwable, String message, Object... args) {
// Logger.e(throwable, message, args);
// }
//
// public static void i(String message, Object... args) {
// Logger.i(message, args);
// }
//
// public static void v(String message, Object... args) {
// Logger.v(message, args);
// }
//
// public static void w(String message, Object... args) {
// Logger.w(message, args);
// }
//
// public static void wtf(String message, Object... args) {
// Logger.wtf(message, args);
// }
//
// public static void json(String json) {
// Logger.json(json);
// }
//
// public static void xml(String xml) {
// Logger.xml(xml);
// }
// }
| import android.content.Context;
import android.os.Handler;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import android.util.Log;
import android.widget.Toast;
import com.team.zhuoke.masterhelper.bean.MasterBean;
import com.team.zhuoke.masterhelper.utils.L;
import com.zhy.http.okhttp.OkHttpUtils;
import com.zhy.http.okhttp.callback.StringCallback;
import com.zhy.http.okhttp.request.RequestCall;
import org.json.JSONException;
import org.json.JSONObject;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import java.util.ArrayList;
import java.util.concurrent.CountDownLatch;
import okhttp3.Call; | @Override
public void onResponse(String response, int id) {
countDownLatch.countDown();
}
});
try {
countDownLatch.await();
} catch (InterruptedException e) {
e.printStackTrace();
}
//以上方法比下面的 Sleep 好
// try {
// Thread.sleep(3000);
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
}
@Test
public void masterList() {
String[] names = new String[] {"hongyang", "任玉刚", "Trinea", "胡凯", "郭霖"};
// JSONArray jsonArray = new JSONArray();
ArrayList list = new ArrayList();
for (int i = 0; i < names.length; i++) { | // Path: app/src/main/java/com/team/zhuoke/masterhelper/bean/MasterBean.java
// public class MasterBean {
// private String name;
// private String weiBo;
// private String zhiHu;
// private String grade;
// private boolean isVip;
// private String info;
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getWeiBo() {
// return weiBo;
// }
//
// public void setWeiBo(String weiBo) {
// this.weiBo = weiBo;
// }
//
// public String getZhiHu() {
// return zhiHu;
// }
//
// public void setZhiHu(String zhiHu) {
// this.zhiHu = zhiHu;
// }
//
// public String getGrade() {
// return grade;
// }
//
// public void setGrade(String grade) {
// this.grade = grade;
// }
//
// public boolean isVip() {
// return isVip;
// }
//
// public void setVip(boolean vip) {
// isVip = vip;
// }
//
// public String getInfo() {
// return info;
// }
//
// public void setInfo(String info) {
// this.info = info;
// }
//
// @Override
// public String toString() {
// return "{" +
// "name:'" + name + '\'' +
// ", weiBo:'" + weiBo + '\'' +
// ", zhiHu:'" + zhiHu + '\'' +
// ", grade:'" + grade + '\'' +
// ", isVip:" + isVip +
// ", info:'" + info + '\'' +
// '}';
// }
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/utils/L.java
// public class L {
//
// private static final String DEFAULT_TAG = "masterhelper";
//
// //no instance
// private L() {
// }
//
// public static void init() {
//
// init(DEFAULT_TAG)
// .methodCount(3)
// .logLevel(BuildConfig.DEBUG ? LogLevel.FULL : LogLevel.NONE);
// }
//
// public static Settings init(String tag) {
// return Logger.init(tag);
// }
//
// public static void d(String message, Object... args) {
// Logger.d(message, args);
// }
//
// public static void d(Object object) {
// Logger.d(object);
// }
//
// public static void e(String message, Object... args) {
// Logger.e(message, args);
// }
//
// public static void e(Throwable throwable, String message, Object... args) {
// Logger.e(throwable, message, args);
// }
//
// public static void i(String message, Object... args) {
// Logger.i(message, args);
// }
//
// public static void v(String message, Object... args) {
// Logger.v(message, args);
// }
//
// public static void w(String message, Object... args) {
// Logger.w(message, args);
// }
//
// public static void wtf(String message, Object... args) {
// Logger.wtf(message, args);
// }
//
// public static void json(String json) {
// Logger.json(json);
// }
//
// public static void xml(String xml) {
// Logger.xml(xml);
// }
// }
// Path: app/src/androidTest/java/com/team/zhuoke/masterhelper/AndroidTest.java
import android.content.Context;
import android.os.Handler;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import android.util.Log;
import android.widget.Toast;
import com.team.zhuoke.masterhelper.bean.MasterBean;
import com.team.zhuoke.masterhelper.utils.L;
import com.zhy.http.okhttp.OkHttpUtils;
import com.zhy.http.okhttp.callback.StringCallback;
import com.zhy.http.okhttp.request.RequestCall;
import org.json.JSONException;
import org.json.JSONObject;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import java.util.ArrayList;
import java.util.concurrent.CountDownLatch;
import okhttp3.Call;
@Override
public void onResponse(String response, int id) {
countDownLatch.countDown();
}
});
try {
countDownLatch.await();
} catch (InterruptedException e) {
e.printStackTrace();
}
//以上方法比下面的 Sleep 好
// try {
// Thread.sleep(3000);
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
}
@Test
public void masterList() {
String[] names = new String[] {"hongyang", "任玉刚", "Trinea", "胡凯", "郭霖"};
// JSONArray jsonArray = new JSONArray();
ArrayList list = new ArrayList();
for (int i = 0; i < names.length; i++) { | MasterBean masterBean = new MasterBean(); |
ZhuoKeTeam/MasterHelper | app/src/main/java/com/team/zhuoke/masterhelper/fragment/marster/ArticleListFragment.java | // Path: app/src/main/java/com/team/zhuoke/masterhelper/activity/PageCtrl.java
// public class PageCtrl {
//
// /**
// * 跳转到大神文章详情WebView界面
// *
// * @param context 上下文
// * @param url 网址
// */
// public static void startArticleDetailActivity(Context context, String url, String title) {
// Intent intent = new Intent(context, WebViewActivity.class);
// intent.putExtra(WebViewActivity.WEB_URL, url);
// intent.putExtra(WebViewActivity.WEB_TITLE, title);
// context.startActivity(intent);
// }
//
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/fragment/ArticleInfoBean.java
// public class ArticleInfoBean {
//
// /**
// * id : 14
// * uid : 1246141947
// * name : lmj623565791
// * nick_name : Hongyang
// * des : 生命不息,奋斗不止,万事起于忽微,量变引起质变
// * article_title : Android UI性能优化 检测应用中的UI卡顿
// * article_address : http://blog.csdn.net/lmj623565791/article/details/60874334
// */
//
// private int id;
// private long uid;
// private String name;
// private String nick_name;
// private String des;
// private String article_title;
// private String article_address;
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public long getUid() {
// return uid;
// }
//
// public void setUid(long uid) {
// this.uid = uid;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getNick_name() {
// return nick_name;
// }
//
// public void setNick_name(String nick_name) {
// this.nick_name = nick_name;
// }
//
// public String getDes() {
// return des;
// }
//
// public void setDes(String des) {
// this.des = des;
// }
//
// public String getArticle_title() {
// return article_title;
// }
//
// public void setArticle_title(String article_title) {
// this.article_title = article_title;
// }
//
// public String getArticle_address() {
// return article_address;
// }
//
// public void setArticle_address(String article_address) {
// this.article_address = article_address;
// }
//
// @Override
// public String toString() {
// return "ArticleInfoBean{" +
// "id=" + id +
// ", uid=" + uid +
// ", name='" + name + '\'' +
// ", nick_name='" + nick_name + '\'' +
// ", des='" + des + '\'' +
// ", article_title='" + article_title + '\'' +
// ", article_address='" + article_address + '\'' +
// '}';
// }
// }
| import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.widget.DividerItemDecoration;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.team.zhuoke.masterhelper.R;
import com.team.zhuoke.masterhelper.activity.PageCtrl;
import com.team.zhuoke.masterhelper.fragment.ArticleInfoBean;
import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife; | package com.team.zhuoke.masterhelper.fragment.marster;
/**
* Created by renxl
* On 2017/4/22 15:30.
*/
public class ArticleListFragment extends Fragment implements ArticleListContract.IArticleListView {
@BindView(R.id.recycleview_articles)
RecyclerView recycleviewArticles;
private ArticleListContract.IArticleListPresenter mArticleListPresenter;
private ArticleListAdapter adapter;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_articles, null, false);
ButterKnife.bind(this, view);
mArticleListPresenter = new ArticleListPresenter(this);
return view;
}
public void init(String uid) {
mArticleListPresenter.getArticleDatas(uid, 5);
}
@Override | // Path: app/src/main/java/com/team/zhuoke/masterhelper/activity/PageCtrl.java
// public class PageCtrl {
//
// /**
// * 跳转到大神文章详情WebView界面
// *
// * @param context 上下文
// * @param url 网址
// */
// public static void startArticleDetailActivity(Context context, String url, String title) {
// Intent intent = new Intent(context, WebViewActivity.class);
// intent.putExtra(WebViewActivity.WEB_URL, url);
// intent.putExtra(WebViewActivity.WEB_TITLE, title);
// context.startActivity(intent);
// }
//
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/fragment/ArticleInfoBean.java
// public class ArticleInfoBean {
//
// /**
// * id : 14
// * uid : 1246141947
// * name : lmj623565791
// * nick_name : Hongyang
// * des : 生命不息,奋斗不止,万事起于忽微,量变引起质变
// * article_title : Android UI性能优化 检测应用中的UI卡顿
// * article_address : http://blog.csdn.net/lmj623565791/article/details/60874334
// */
//
// private int id;
// private long uid;
// private String name;
// private String nick_name;
// private String des;
// private String article_title;
// private String article_address;
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public long getUid() {
// return uid;
// }
//
// public void setUid(long uid) {
// this.uid = uid;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getNick_name() {
// return nick_name;
// }
//
// public void setNick_name(String nick_name) {
// this.nick_name = nick_name;
// }
//
// public String getDes() {
// return des;
// }
//
// public void setDes(String des) {
// this.des = des;
// }
//
// public String getArticle_title() {
// return article_title;
// }
//
// public void setArticle_title(String article_title) {
// this.article_title = article_title;
// }
//
// public String getArticle_address() {
// return article_address;
// }
//
// public void setArticle_address(String article_address) {
// this.article_address = article_address;
// }
//
// @Override
// public String toString() {
// return "ArticleInfoBean{" +
// "id=" + id +
// ", uid=" + uid +
// ", name='" + name + '\'' +
// ", nick_name='" + nick_name + '\'' +
// ", des='" + des + '\'' +
// ", article_title='" + article_title + '\'' +
// ", article_address='" + article_address + '\'' +
// '}';
// }
// }
// Path: app/src/main/java/com/team/zhuoke/masterhelper/fragment/marster/ArticleListFragment.java
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.widget.DividerItemDecoration;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.team.zhuoke.masterhelper.R;
import com.team.zhuoke.masterhelper.activity.PageCtrl;
import com.team.zhuoke.masterhelper.fragment.ArticleInfoBean;
import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
package com.team.zhuoke.masterhelper.fragment.marster;
/**
* Created by renxl
* On 2017/4/22 15:30.
*/
public class ArticleListFragment extends Fragment implements ArticleListContract.IArticleListView {
@BindView(R.id.recycleview_articles)
RecyclerView recycleviewArticles;
private ArticleListContract.IArticleListPresenter mArticleListPresenter;
private ArticleListAdapter adapter;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_articles, null, false);
ButterKnife.bind(this, view);
mArticleListPresenter = new ArticleListPresenter(this);
return view;
}
public void init(String uid) {
mArticleListPresenter.getArticleDatas(uid, 5);
}
@Override | public void refresh(List<ArticleInfoBean> datas) { |
ZhuoKeTeam/MasterHelper | app/src/main/java/com/team/zhuoke/masterhelper/fragment/marster/ArticleListFragment.java | // Path: app/src/main/java/com/team/zhuoke/masterhelper/activity/PageCtrl.java
// public class PageCtrl {
//
// /**
// * 跳转到大神文章详情WebView界面
// *
// * @param context 上下文
// * @param url 网址
// */
// public static void startArticleDetailActivity(Context context, String url, String title) {
// Intent intent = new Intent(context, WebViewActivity.class);
// intent.putExtra(WebViewActivity.WEB_URL, url);
// intent.putExtra(WebViewActivity.WEB_TITLE, title);
// context.startActivity(intent);
// }
//
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/fragment/ArticleInfoBean.java
// public class ArticleInfoBean {
//
// /**
// * id : 14
// * uid : 1246141947
// * name : lmj623565791
// * nick_name : Hongyang
// * des : 生命不息,奋斗不止,万事起于忽微,量变引起质变
// * article_title : Android UI性能优化 检测应用中的UI卡顿
// * article_address : http://blog.csdn.net/lmj623565791/article/details/60874334
// */
//
// private int id;
// private long uid;
// private String name;
// private String nick_name;
// private String des;
// private String article_title;
// private String article_address;
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public long getUid() {
// return uid;
// }
//
// public void setUid(long uid) {
// this.uid = uid;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getNick_name() {
// return nick_name;
// }
//
// public void setNick_name(String nick_name) {
// this.nick_name = nick_name;
// }
//
// public String getDes() {
// return des;
// }
//
// public void setDes(String des) {
// this.des = des;
// }
//
// public String getArticle_title() {
// return article_title;
// }
//
// public void setArticle_title(String article_title) {
// this.article_title = article_title;
// }
//
// public String getArticle_address() {
// return article_address;
// }
//
// public void setArticle_address(String article_address) {
// this.article_address = article_address;
// }
//
// @Override
// public String toString() {
// return "ArticleInfoBean{" +
// "id=" + id +
// ", uid=" + uid +
// ", name='" + name + '\'' +
// ", nick_name='" + nick_name + '\'' +
// ", des='" + des + '\'' +
// ", article_title='" + article_title + '\'' +
// ", article_address='" + article_address + '\'' +
// '}';
// }
// }
| import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.widget.DividerItemDecoration;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.team.zhuoke.masterhelper.R;
import com.team.zhuoke.masterhelper.activity.PageCtrl;
import com.team.zhuoke.masterhelper.fragment.ArticleInfoBean;
import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife; | package com.team.zhuoke.masterhelper.fragment.marster;
/**
* Created by renxl
* On 2017/4/22 15:30.
*/
public class ArticleListFragment extends Fragment implements ArticleListContract.IArticleListView {
@BindView(R.id.recycleview_articles)
RecyclerView recycleviewArticles;
private ArticleListContract.IArticleListPresenter mArticleListPresenter;
private ArticleListAdapter adapter;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_articles, null, false);
ButterKnife.bind(this, view);
mArticleListPresenter = new ArticleListPresenter(this);
return view;
}
public void init(String uid) {
mArticleListPresenter.getArticleDatas(uid, 5);
}
@Override
public void refresh(List<ArticleInfoBean> datas) {
if (adapter != null) {
adapter.setData(datas);
}
}
@Override
public void setData(List<ArticleInfoBean> datas) {
if (datas == null || datas.size() <= 0)
return;
adapter = new ArticleListAdapter(datas);
adapter.setOnItemClickListener(position -> {
if (TextUtils.isEmpty(datas.get(position).getArticle_title()) || TextUtils.isEmpty(datas.get(position).getArticle_address()))
return; | // Path: app/src/main/java/com/team/zhuoke/masterhelper/activity/PageCtrl.java
// public class PageCtrl {
//
// /**
// * 跳转到大神文章详情WebView界面
// *
// * @param context 上下文
// * @param url 网址
// */
// public static void startArticleDetailActivity(Context context, String url, String title) {
// Intent intent = new Intent(context, WebViewActivity.class);
// intent.putExtra(WebViewActivity.WEB_URL, url);
// intent.putExtra(WebViewActivity.WEB_TITLE, title);
// context.startActivity(intent);
// }
//
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/fragment/ArticleInfoBean.java
// public class ArticleInfoBean {
//
// /**
// * id : 14
// * uid : 1246141947
// * name : lmj623565791
// * nick_name : Hongyang
// * des : 生命不息,奋斗不止,万事起于忽微,量变引起质变
// * article_title : Android UI性能优化 检测应用中的UI卡顿
// * article_address : http://blog.csdn.net/lmj623565791/article/details/60874334
// */
//
// private int id;
// private long uid;
// private String name;
// private String nick_name;
// private String des;
// private String article_title;
// private String article_address;
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public long getUid() {
// return uid;
// }
//
// public void setUid(long uid) {
// this.uid = uid;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getNick_name() {
// return nick_name;
// }
//
// public void setNick_name(String nick_name) {
// this.nick_name = nick_name;
// }
//
// public String getDes() {
// return des;
// }
//
// public void setDes(String des) {
// this.des = des;
// }
//
// public String getArticle_title() {
// return article_title;
// }
//
// public void setArticle_title(String article_title) {
// this.article_title = article_title;
// }
//
// public String getArticle_address() {
// return article_address;
// }
//
// public void setArticle_address(String article_address) {
// this.article_address = article_address;
// }
//
// @Override
// public String toString() {
// return "ArticleInfoBean{" +
// "id=" + id +
// ", uid=" + uid +
// ", name='" + name + '\'' +
// ", nick_name='" + nick_name + '\'' +
// ", des='" + des + '\'' +
// ", article_title='" + article_title + '\'' +
// ", article_address='" + article_address + '\'' +
// '}';
// }
// }
// Path: app/src/main/java/com/team/zhuoke/masterhelper/fragment/marster/ArticleListFragment.java
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.widget.DividerItemDecoration;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.team.zhuoke.masterhelper.R;
import com.team.zhuoke.masterhelper.activity.PageCtrl;
import com.team.zhuoke.masterhelper.fragment.ArticleInfoBean;
import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
package com.team.zhuoke.masterhelper.fragment.marster;
/**
* Created by renxl
* On 2017/4/22 15:30.
*/
public class ArticleListFragment extends Fragment implements ArticleListContract.IArticleListView {
@BindView(R.id.recycleview_articles)
RecyclerView recycleviewArticles;
private ArticleListContract.IArticleListPresenter mArticleListPresenter;
private ArticleListAdapter adapter;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_articles, null, false);
ButterKnife.bind(this, view);
mArticleListPresenter = new ArticleListPresenter(this);
return view;
}
public void init(String uid) {
mArticleListPresenter.getArticleDatas(uid, 5);
}
@Override
public void refresh(List<ArticleInfoBean> datas) {
if (adapter != null) {
adapter.setData(datas);
}
}
@Override
public void setData(List<ArticleInfoBean> datas) {
if (datas == null || datas.size() <= 0)
return;
adapter = new ArticleListAdapter(datas);
adapter.setOnItemClickListener(position -> {
if (TextUtils.isEmpty(datas.get(position).getArticle_title()) || TextUtils.isEmpty(datas.get(position).getArticle_address()))
return; | PageCtrl.startArticleDetailActivity(getActivity(), datas.get(position).getArticle_address(), datas.get(position).getArticle_title()); |
ZhuoKeTeam/MasterHelper | app/src/main/java/wq/gdy005/mvp/Test3Contract.java | // Path: app/src/main/java/com/team/zhuoke/masterhelper/base/BaseModel.java
// public interface BaseModel {
//
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/base/BasePresenter.java
// public abstract class BasePresenter<V extends BaseView, M extends BaseModel> implements Presenter<V,M> {
//
//
// protected Context mContext;
//
// protected V mView;
//
// protected M mModel;
//
// protected CompositeSubscription mCompositeSubscription;
//
// protected void unSubscribe() {
// if (mCompositeSubscription != null) {
// mCompositeSubscription.unsubscribe();
// }
// }
// protected void addSubscribe(Subscription subscription) {
// if (mCompositeSubscription == null) {
// mCompositeSubscription = new CompositeSubscription();
// }
// mCompositeSubscription.add(subscription);
// }
//
// // 获取绑定View实例
// @Override
// public void attachView(V view) {
// this.mView=view;
// }
// // 获取绑定Model层实例
// @Override
// public void attachModel(M m) {
// this.mModel=m;
// }
//
//
// public M getModel() {
// return mModel;
// }
// // 注销mModel实例
// @Override
// public void detachModel() {
// this.mModel=null;
// }
//
// // 注销View实例
// @Override
// public void detachView() {
// this.mView=null;
// unSubscribe();
// }
//
// public V getView() {
// return mView;
// }
//
// public boolean isViewBind()
// {
// return mView!=null;
// }
//
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/base/BaseView.java
// public interface BaseView<P> {
//
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/model/test/TestList.java
// public class TestList {
//
//
// /**
// * des : 生命不息,奋斗不止,万事起于忽微,量变引起质变
// * grade : 1
// * img : http://tva2.sinaimg.cn/crop.200.80.480.480.180/bca65a60gw1eiedwawzi2j20m80i57a7.jpg
// * info : http://blog.csdn.net/lmj623565791
// * isVip : true
// * name : hongyang
// * weiBo :
// * zhiHu :
// */
//
// private String des;
// private String grade;
// private String img;
// private String info;
// private boolean isVip;
// private String name;
// private String weiBo;
// private String zhiHu;
//
// public String getDes() {
// return des;
// }
//
// public void setDes(String des) {
// this.des = des;
// }
//
// public String getGrade() {
// return grade;
// }
//
// public void setGrade(String grade) {
// this.grade = grade;
// }
//
// public String getImg() {
// return img;
// }
//
// public void setImg(String img) {
// this.img = img;
// }
//
// public String getInfo() {
// return info;
// }
//
// public void setInfo(String info) {
// this.info = info;
// }
//
// public boolean isIsVip() {
// return isVip;
// }
//
// public void setIsVip(boolean isVip) {
// this.isVip = isVip;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getWeiBo() {
// return weiBo;
// }
//
// public void setWeiBo(String weiBo) {
// this.weiBo = weiBo;
// }
//
// public String getZhiHu() {
// return zhiHu;
// }
//
// public void setZhiHu(String zhiHu) {
// this.zhiHu = zhiHu;
// }
//
//
// // 修改模板,快速生成
// @Override
// public String toString() {
// return "{" +
// "des:'" + des + '\'' +
// ", grade:'" + grade + '\'' +
// ", img:'" + img + '\'' +
// ", info:'" + info + '\'' +
// ", isVip:" + isVip +
// ", name:'" + name + '\'' +
// ", weiBo:'" + weiBo + '\'' +
// ", zhiHu:'" + zhiHu + '\'' +
// '}';
// }
//
// // @Override
// // public String toString() {
// // return "MasterList{" +
// // "des='" + des + '\'' +
// // ", grade='" + grade + '\'' +
// // ", img='" + img + '\'' +
// // ", info='" + info + '\'' +
// // ", isVip=" + isVip +
// // ", name='" + name + '\'' +
// // ", weiBo='" + weiBo + '\'' +
// // ", zhiHu='" + zhiHu + '\'' +
// // '}';
// // }
//
// }
| import android.content.Context;
import com.team.zhuoke.masterhelper.base.BaseModel;
import com.team.zhuoke.masterhelper.base.BasePresenter;
import com.team.zhuoke.masterhelper.base.BaseView;
import com.team.zhuoke.masterhelper.model.test.TestList;
import java.util.List;
import rx.Observable; | package wq.gdy005.mvp;
/**
* Created by WangQing on 2016/12/9.
*/
public interface Test3Contract {
interface View extends BaseView {
void setData(String s);
void setErrorInfo(String message);
}
| // Path: app/src/main/java/com/team/zhuoke/masterhelper/base/BaseModel.java
// public interface BaseModel {
//
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/base/BasePresenter.java
// public abstract class BasePresenter<V extends BaseView, M extends BaseModel> implements Presenter<V,M> {
//
//
// protected Context mContext;
//
// protected V mView;
//
// protected M mModel;
//
// protected CompositeSubscription mCompositeSubscription;
//
// protected void unSubscribe() {
// if (mCompositeSubscription != null) {
// mCompositeSubscription.unsubscribe();
// }
// }
// protected void addSubscribe(Subscription subscription) {
// if (mCompositeSubscription == null) {
// mCompositeSubscription = new CompositeSubscription();
// }
// mCompositeSubscription.add(subscription);
// }
//
// // 获取绑定View实例
// @Override
// public void attachView(V view) {
// this.mView=view;
// }
// // 获取绑定Model层实例
// @Override
// public void attachModel(M m) {
// this.mModel=m;
// }
//
//
// public M getModel() {
// return mModel;
// }
// // 注销mModel实例
// @Override
// public void detachModel() {
// this.mModel=null;
// }
//
// // 注销View实例
// @Override
// public void detachView() {
// this.mView=null;
// unSubscribe();
// }
//
// public V getView() {
// return mView;
// }
//
// public boolean isViewBind()
// {
// return mView!=null;
// }
//
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/base/BaseView.java
// public interface BaseView<P> {
//
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/model/test/TestList.java
// public class TestList {
//
//
// /**
// * des : 生命不息,奋斗不止,万事起于忽微,量变引起质变
// * grade : 1
// * img : http://tva2.sinaimg.cn/crop.200.80.480.480.180/bca65a60gw1eiedwawzi2j20m80i57a7.jpg
// * info : http://blog.csdn.net/lmj623565791
// * isVip : true
// * name : hongyang
// * weiBo :
// * zhiHu :
// */
//
// private String des;
// private String grade;
// private String img;
// private String info;
// private boolean isVip;
// private String name;
// private String weiBo;
// private String zhiHu;
//
// public String getDes() {
// return des;
// }
//
// public void setDes(String des) {
// this.des = des;
// }
//
// public String getGrade() {
// return grade;
// }
//
// public void setGrade(String grade) {
// this.grade = grade;
// }
//
// public String getImg() {
// return img;
// }
//
// public void setImg(String img) {
// this.img = img;
// }
//
// public String getInfo() {
// return info;
// }
//
// public void setInfo(String info) {
// this.info = info;
// }
//
// public boolean isIsVip() {
// return isVip;
// }
//
// public void setIsVip(boolean isVip) {
// this.isVip = isVip;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getWeiBo() {
// return weiBo;
// }
//
// public void setWeiBo(String weiBo) {
// this.weiBo = weiBo;
// }
//
// public String getZhiHu() {
// return zhiHu;
// }
//
// public void setZhiHu(String zhiHu) {
// this.zhiHu = zhiHu;
// }
//
//
// // 修改模板,快速生成
// @Override
// public String toString() {
// return "{" +
// "des:'" + des + '\'' +
// ", grade:'" + grade + '\'' +
// ", img:'" + img + '\'' +
// ", info:'" + info + '\'' +
// ", isVip:" + isVip +
// ", name:'" + name + '\'' +
// ", weiBo:'" + weiBo + '\'' +
// ", zhiHu:'" + zhiHu + '\'' +
// '}';
// }
//
// // @Override
// // public String toString() {
// // return "MasterList{" +
// // "des='" + des + '\'' +
// // ", grade='" + grade + '\'' +
// // ", img='" + img + '\'' +
// // ", info='" + info + '\'' +
// // ", isVip=" + isVip +
// // ", name='" + name + '\'' +
// // ", weiBo='" + weiBo + '\'' +
// // ", zhiHu='" + zhiHu + '\'' +
// // '}';
// // }
//
// }
// Path: app/src/main/java/wq/gdy005/mvp/Test3Contract.java
import android.content.Context;
import com.team.zhuoke.masterhelper.base.BaseModel;
import com.team.zhuoke.masterhelper.base.BasePresenter;
import com.team.zhuoke.masterhelper.base.BaseView;
import com.team.zhuoke.masterhelper.model.test.TestList;
import java.util.List;
import rx.Observable;
package wq.gdy005.mvp;
/**
* Created by WangQing on 2016/12/9.
*/
public interface Test3Contract {
interface View extends BaseView {
void setData(String s);
void setErrorInfo(String message);
}
| interface Model extends BaseModel { |
ZhuoKeTeam/MasterHelper | app/src/main/java/wq/gdy005/mvp/Test3Contract.java | // Path: app/src/main/java/com/team/zhuoke/masterhelper/base/BaseModel.java
// public interface BaseModel {
//
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/base/BasePresenter.java
// public abstract class BasePresenter<V extends BaseView, M extends BaseModel> implements Presenter<V,M> {
//
//
// protected Context mContext;
//
// protected V mView;
//
// protected M mModel;
//
// protected CompositeSubscription mCompositeSubscription;
//
// protected void unSubscribe() {
// if (mCompositeSubscription != null) {
// mCompositeSubscription.unsubscribe();
// }
// }
// protected void addSubscribe(Subscription subscription) {
// if (mCompositeSubscription == null) {
// mCompositeSubscription = new CompositeSubscription();
// }
// mCompositeSubscription.add(subscription);
// }
//
// // 获取绑定View实例
// @Override
// public void attachView(V view) {
// this.mView=view;
// }
// // 获取绑定Model层实例
// @Override
// public void attachModel(M m) {
// this.mModel=m;
// }
//
//
// public M getModel() {
// return mModel;
// }
// // 注销mModel实例
// @Override
// public void detachModel() {
// this.mModel=null;
// }
//
// // 注销View实例
// @Override
// public void detachView() {
// this.mView=null;
// unSubscribe();
// }
//
// public V getView() {
// return mView;
// }
//
// public boolean isViewBind()
// {
// return mView!=null;
// }
//
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/base/BaseView.java
// public interface BaseView<P> {
//
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/model/test/TestList.java
// public class TestList {
//
//
// /**
// * des : 生命不息,奋斗不止,万事起于忽微,量变引起质变
// * grade : 1
// * img : http://tva2.sinaimg.cn/crop.200.80.480.480.180/bca65a60gw1eiedwawzi2j20m80i57a7.jpg
// * info : http://blog.csdn.net/lmj623565791
// * isVip : true
// * name : hongyang
// * weiBo :
// * zhiHu :
// */
//
// private String des;
// private String grade;
// private String img;
// private String info;
// private boolean isVip;
// private String name;
// private String weiBo;
// private String zhiHu;
//
// public String getDes() {
// return des;
// }
//
// public void setDes(String des) {
// this.des = des;
// }
//
// public String getGrade() {
// return grade;
// }
//
// public void setGrade(String grade) {
// this.grade = grade;
// }
//
// public String getImg() {
// return img;
// }
//
// public void setImg(String img) {
// this.img = img;
// }
//
// public String getInfo() {
// return info;
// }
//
// public void setInfo(String info) {
// this.info = info;
// }
//
// public boolean isIsVip() {
// return isVip;
// }
//
// public void setIsVip(boolean isVip) {
// this.isVip = isVip;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getWeiBo() {
// return weiBo;
// }
//
// public void setWeiBo(String weiBo) {
// this.weiBo = weiBo;
// }
//
// public String getZhiHu() {
// return zhiHu;
// }
//
// public void setZhiHu(String zhiHu) {
// this.zhiHu = zhiHu;
// }
//
//
// // 修改模板,快速生成
// @Override
// public String toString() {
// return "{" +
// "des:'" + des + '\'' +
// ", grade:'" + grade + '\'' +
// ", img:'" + img + '\'' +
// ", info:'" + info + '\'' +
// ", isVip:" + isVip +
// ", name:'" + name + '\'' +
// ", weiBo:'" + weiBo + '\'' +
// ", zhiHu:'" + zhiHu + '\'' +
// '}';
// }
//
// // @Override
// // public String toString() {
// // return "MasterList{" +
// // "des='" + des + '\'' +
// // ", grade='" + grade + '\'' +
// // ", img='" + img + '\'' +
// // ", info='" + info + '\'' +
// // ", isVip=" + isVip +
// // ", name='" + name + '\'' +
// // ", weiBo='" + weiBo + '\'' +
// // ", zhiHu='" + zhiHu + '\'' +
// // '}';
// // }
//
// }
| import android.content.Context;
import com.team.zhuoke.masterhelper.base.BaseModel;
import com.team.zhuoke.masterhelper.base.BasePresenter;
import com.team.zhuoke.masterhelper.base.BaseView;
import com.team.zhuoke.masterhelper.model.test.TestList;
import java.util.List;
import rx.Observable; | package wq.gdy005.mvp;
/**
* Created by WangQing on 2016/12/9.
*/
public interface Test3Contract {
interface View extends BaseView {
void setData(String s);
void setErrorInfo(String message);
}
interface Model extends BaseModel { | // Path: app/src/main/java/com/team/zhuoke/masterhelper/base/BaseModel.java
// public interface BaseModel {
//
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/base/BasePresenter.java
// public abstract class BasePresenter<V extends BaseView, M extends BaseModel> implements Presenter<V,M> {
//
//
// protected Context mContext;
//
// protected V mView;
//
// protected M mModel;
//
// protected CompositeSubscription mCompositeSubscription;
//
// protected void unSubscribe() {
// if (mCompositeSubscription != null) {
// mCompositeSubscription.unsubscribe();
// }
// }
// protected void addSubscribe(Subscription subscription) {
// if (mCompositeSubscription == null) {
// mCompositeSubscription = new CompositeSubscription();
// }
// mCompositeSubscription.add(subscription);
// }
//
// // 获取绑定View实例
// @Override
// public void attachView(V view) {
// this.mView=view;
// }
// // 获取绑定Model层实例
// @Override
// public void attachModel(M m) {
// this.mModel=m;
// }
//
//
// public M getModel() {
// return mModel;
// }
// // 注销mModel实例
// @Override
// public void detachModel() {
// this.mModel=null;
// }
//
// // 注销View实例
// @Override
// public void detachView() {
// this.mView=null;
// unSubscribe();
// }
//
// public V getView() {
// return mView;
// }
//
// public boolean isViewBind()
// {
// return mView!=null;
// }
//
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/base/BaseView.java
// public interface BaseView<P> {
//
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/model/test/TestList.java
// public class TestList {
//
//
// /**
// * des : 生命不息,奋斗不止,万事起于忽微,量变引起质变
// * grade : 1
// * img : http://tva2.sinaimg.cn/crop.200.80.480.480.180/bca65a60gw1eiedwawzi2j20m80i57a7.jpg
// * info : http://blog.csdn.net/lmj623565791
// * isVip : true
// * name : hongyang
// * weiBo :
// * zhiHu :
// */
//
// private String des;
// private String grade;
// private String img;
// private String info;
// private boolean isVip;
// private String name;
// private String weiBo;
// private String zhiHu;
//
// public String getDes() {
// return des;
// }
//
// public void setDes(String des) {
// this.des = des;
// }
//
// public String getGrade() {
// return grade;
// }
//
// public void setGrade(String grade) {
// this.grade = grade;
// }
//
// public String getImg() {
// return img;
// }
//
// public void setImg(String img) {
// this.img = img;
// }
//
// public String getInfo() {
// return info;
// }
//
// public void setInfo(String info) {
// this.info = info;
// }
//
// public boolean isIsVip() {
// return isVip;
// }
//
// public void setIsVip(boolean isVip) {
// this.isVip = isVip;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getWeiBo() {
// return weiBo;
// }
//
// public void setWeiBo(String weiBo) {
// this.weiBo = weiBo;
// }
//
// public String getZhiHu() {
// return zhiHu;
// }
//
// public void setZhiHu(String zhiHu) {
// this.zhiHu = zhiHu;
// }
//
//
// // 修改模板,快速生成
// @Override
// public String toString() {
// return "{" +
// "des:'" + des + '\'' +
// ", grade:'" + grade + '\'' +
// ", img:'" + img + '\'' +
// ", info:'" + info + '\'' +
// ", isVip:" + isVip +
// ", name:'" + name + '\'' +
// ", weiBo:'" + weiBo + '\'' +
// ", zhiHu:'" + zhiHu + '\'' +
// '}';
// }
//
// // @Override
// // public String toString() {
// // return "MasterList{" +
// // "des='" + des + '\'' +
// // ", grade='" + grade + '\'' +
// // ", img='" + img + '\'' +
// // ", info='" + info + '\'' +
// // ", isVip=" + isVip +
// // ", name='" + name + '\'' +
// // ", weiBo='" + weiBo + '\'' +
// // ", zhiHu='" + zhiHu + '\'' +
// // '}';
// // }
//
// }
// Path: app/src/main/java/wq/gdy005/mvp/Test3Contract.java
import android.content.Context;
import com.team.zhuoke.masterhelper.base.BaseModel;
import com.team.zhuoke.masterhelper.base.BasePresenter;
import com.team.zhuoke.masterhelper.base.BaseView;
import com.team.zhuoke.masterhelper.model.test.TestList;
import java.util.List;
import rx.Observable;
package wq.gdy005.mvp;
/**
* Created by WangQing on 2016/12/9.
*/
public interface Test3Contract {
interface View extends BaseView {
void setData(String s);
void setErrorInfo(String message);
}
interface Model extends BaseModel { | Observable<List<TestList>> testList(Context context); |
ZhuoKeTeam/MasterHelper | app/src/main/java/com/team/zhuoke/masterhelper/fragment/marster/ArticleModel.java | // Path: app/src/main/java/com/team/zhuoke/masterhelper/api/NetWorkApi.java
// public class NetWorkApi {
//
// public static String baseUrl = "https://zkteam.wilddogio.com";
// // test
// public static final String getMasterList = "/master_list.json";
// public static final String getTestList = "/master_list.json";
//
// public static final String newBaseUrl = "http://www.zkteam.cc";
//
// public static final String masterInfo = newBaseUrl + "/api/jsonMasterInfo";
// public static final String masterArticle = "/api/jsonMasterArticle";
// }
| import com.team.zhuoke.masterhelper.api.NetWorkApi;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory; | package com.team.zhuoke.masterhelper.fragment.marster;
/**
* Created by renxl
* On 2017/4/21 18:43.
*/
class ArticleModel {
static ArticleListService getArticleDatas() {
Retrofit retrofit = new Retrofit.Builder() | // Path: app/src/main/java/com/team/zhuoke/masterhelper/api/NetWorkApi.java
// public class NetWorkApi {
//
// public static String baseUrl = "https://zkteam.wilddogio.com";
// // test
// public static final String getMasterList = "/master_list.json";
// public static final String getTestList = "/master_list.json";
//
// public static final String newBaseUrl = "http://www.zkteam.cc";
//
// public static final String masterInfo = newBaseUrl + "/api/jsonMasterInfo";
// public static final String masterArticle = "/api/jsonMasterArticle";
// }
// Path: app/src/main/java/com/team/zhuoke/masterhelper/fragment/marster/ArticleModel.java
import com.team.zhuoke.masterhelper.api.NetWorkApi;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory;
package com.team.zhuoke.masterhelper.fragment.marster;
/**
* Created by renxl
* On 2017/4/21 18:43.
*/
class ArticleModel {
static ArticleListService getArticleDatas() {
Retrofit retrofit = new Retrofit.Builder() | .baseUrl(NetWorkApi.newBaseUrl) |
ZhuoKeTeam/MasterHelper | app/src/main/java/com/team/zhuoke/masterhelper/view/test/activity/TestActivity2.java | // Path: app/src/main/java/com/team/zhuoke/masterhelper/base/BaseActivity.java
// public abstract class BaseActivity<M extends BaseModel , P extends BasePresenter> extends RxAppCompatActivity {
//
// // 定义Presenter
// protected P mPresenter;
//
// // 获取布局资源文件
// protected abstract int getLayoutId();
//
// // 初始化数据
//
// protected abstract void onInitView(Bundle bundle);
//
// // 初始化事件Event
//
// protected abstract void onEvent();
//
// // 获取抽取View对象
// protected abstract BaseView getView();
// // 获得抽取接口Model对象
// protected Class getModelClazz() {
// return (Class<M>)ContractProxy.getModelClazz(getClass(), 0);
// }
// // 获得抽取接口Presenter对象
// protected Class getPresenterClazz() {
// return (Class<P>)ContractProxy.getPresnterClazz(getClass(), 1);
// }
// @Override
// protected void onCreate(@Nullable Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// if(getLayoutId()!=0)
// {
// // 设置布局资源文件
// setContentView(getLayoutId());
// bindMVP();
// // 注解绑定
// ButterKnife.bind(this);
// onInitView(savedInstanceState);
// onEvent();
// }
// }
//
// /**
// * 获取presenter 实例
// */
// private void bindMVP()
// {
// if(getPresenterClazz()!=null)
// {
// mPresenter=getPresenterImpl();
// mPresenter.mContext=this;
// bindVM();
// }
// }
// private <T> T getPresenterImpl()
// {
// return ContractProxy.getInstance().presenter(getPresenterClazz());
// }
// @Override
// protected void onStart() {
// if(mPresenter==null)
// {
// bindMVP();
// }
// super.onStart();
// }
// private void bindVM()
// {
// if(mPresenter!=null&&!mPresenter.isViewBind()&&getModelClazz()!=null&&getView()!=null)
// {
// ContractProxy.getInstance().bindModel(getModelClazz(),mPresenter);
// ContractProxy.getInstance().bindView(getView(),mPresenter);
// mPresenter.mContext=this;
// }
// }
//
// /**
// * activity摧毁
// */
// @Override
// protected void onDestroy() {
// super.onDestroy();
// if(mPresenter!=null)
// {
// ContractProxy.getInstance().unbindView(getView(),mPresenter);
// ContractProxy.getInstance().unbindModel(getModelClazz(),mPresenter);
// }
// }
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/base/BaseView.java
// public interface BaseView<P> {
//
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/model/test/TestModel.java
// public class TestModel implements TestContract.Model {
//
// @Override
// public Observable<List<TestList>> testList(Context context) {
//
// return HttpUtils.getInstance(context)
// .getRetofitClinet()
// .builder(TestAPI2.class)
// .getTestList()
// .compose(new DefaultTransformer<>());
// }
//
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/model/test/TestView.java
// public interface TestView extends TestContract.View {
//
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/presenter/test/imp/TestPresenter.java
// public class TestPresenter extends TestContract.Presenter {
//
// @Override
// public void getTestList() {
// addSubscribe(mModel.testList(mContext).subscribe(new RxSubscriber<List<TestList>>() {
// @Override
// public void onSuccess(List<TestList> testLists) {
// mView.setData(testLists.toString());
// }
//
// @Override
// protected void onError(ResponeThrowable ex) {
// super.onError(ex);
// mView.setErrorInfo(ex.message);
// }
// }));
// }
// }
| import android.os.Bundle;
import android.widget.Button;
import android.widget.EditText;
import com.team.zhuoke.masterhelper.R;
import com.team.zhuoke.masterhelper.base.BaseActivity;
import com.team.zhuoke.masterhelper.base.BaseView;
import com.team.zhuoke.masterhelper.model.test.TestModel;
import com.team.zhuoke.masterhelper.model.test.TestView;
import com.team.zhuoke.masterhelper.presenter.test.imp.TestPresenter;
import butterknife.BindView;
import butterknife.OnClick; | package com.team.zhuoke.masterhelper.view.test.activity;
/**
* Created by WangQing on 2016/12/7.
*/
public class TestActivity2 extends BaseActivity<TestModel,TestPresenter> implements TestView {
@BindView(R.id.edit_text)
EditText editText;
@BindView(R.id.btn_home)
Button btnHome;
@Override
protected int getLayoutId() {
return R.layout.activity_test2;
}
@Override
protected void onInitView(Bundle bundle) {
}
@Override
protected void onEvent() {
}
@Override | // Path: app/src/main/java/com/team/zhuoke/masterhelper/base/BaseActivity.java
// public abstract class BaseActivity<M extends BaseModel , P extends BasePresenter> extends RxAppCompatActivity {
//
// // 定义Presenter
// protected P mPresenter;
//
// // 获取布局资源文件
// protected abstract int getLayoutId();
//
// // 初始化数据
//
// protected abstract void onInitView(Bundle bundle);
//
// // 初始化事件Event
//
// protected abstract void onEvent();
//
// // 获取抽取View对象
// protected abstract BaseView getView();
// // 获得抽取接口Model对象
// protected Class getModelClazz() {
// return (Class<M>)ContractProxy.getModelClazz(getClass(), 0);
// }
// // 获得抽取接口Presenter对象
// protected Class getPresenterClazz() {
// return (Class<P>)ContractProxy.getPresnterClazz(getClass(), 1);
// }
// @Override
// protected void onCreate(@Nullable Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// if(getLayoutId()!=0)
// {
// // 设置布局资源文件
// setContentView(getLayoutId());
// bindMVP();
// // 注解绑定
// ButterKnife.bind(this);
// onInitView(savedInstanceState);
// onEvent();
// }
// }
//
// /**
// * 获取presenter 实例
// */
// private void bindMVP()
// {
// if(getPresenterClazz()!=null)
// {
// mPresenter=getPresenterImpl();
// mPresenter.mContext=this;
// bindVM();
// }
// }
// private <T> T getPresenterImpl()
// {
// return ContractProxy.getInstance().presenter(getPresenterClazz());
// }
// @Override
// protected void onStart() {
// if(mPresenter==null)
// {
// bindMVP();
// }
// super.onStart();
// }
// private void bindVM()
// {
// if(mPresenter!=null&&!mPresenter.isViewBind()&&getModelClazz()!=null&&getView()!=null)
// {
// ContractProxy.getInstance().bindModel(getModelClazz(),mPresenter);
// ContractProxy.getInstance().bindView(getView(),mPresenter);
// mPresenter.mContext=this;
// }
// }
//
// /**
// * activity摧毁
// */
// @Override
// protected void onDestroy() {
// super.onDestroy();
// if(mPresenter!=null)
// {
// ContractProxy.getInstance().unbindView(getView(),mPresenter);
// ContractProxy.getInstance().unbindModel(getModelClazz(),mPresenter);
// }
// }
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/base/BaseView.java
// public interface BaseView<P> {
//
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/model/test/TestModel.java
// public class TestModel implements TestContract.Model {
//
// @Override
// public Observable<List<TestList>> testList(Context context) {
//
// return HttpUtils.getInstance(context)
// .getRetofitClinet()
// .builder(TestAPI2.class)
// .getTestList()
// .compose(new DefaultTransformer<>());
// }
//
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/model/test/TestView.java
// public interface TestView extends TestContract.View {
//
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/presenter/test/imp/TestPresenter.java
// public class TestPresenter extends TestContract.Presenter {
//
// @Override
// public void getTestList() {
// addSubscribe(mModel.testList(mContext).subscribe(new RxSubscriber<List<TestList>>() {
// @Override
// public void onSuccess(List<TestList> testLists) {
// mView.setData(testLists.toString());
// }
//
// @Override
// protected void onError(ResponeThrowable ex) {
// super.onError(ex);
// mView.setErrorInfo(ex.message);
// }
// }));
// }
// }
// Path: app/src/main/java/com/team/zhuoke/masterhelper/view/test/activity/TestActivity2.java
import android.os.Bundle;
import android.widget.Button;
import android.widget.EditText;
import com.team.zhuoke.masterhelper.R;
import com.team.zhuoke.masterhelper.base.BaseActivity;
import com.team.zhuoke.masterhelper.base.BaseView;
import com.team.zhuoke.masterhelper.model.test.TestModel;
import com.team.zhuoke.masterhelper.model.test.TestView;
import com.team.zhuoke.masterhelper.presenter.test.imp.TestPresenter;
import butterknife.BindView;
import butterknife.OnClick;
package com.team.zhuoke.masterhelper.view.test.activity;
/**
* Created by WangQing on 2016/12/7.
*/
public class TestActivity2 extends BaseActivity<TestModel,TestPresenter> implements TestView {
@BindView(R.id.edit_text)
EditText editText;
@BindView(R.id.btn_home)
Button btnHome;
@Override
protected int getLayoutId() {
return R.layout.activity_test2;
}
@Override
protected void onInitView(Bundle bundle) {
}
@Override
protected void onEvent() {
}
@Override | protected BaseView getView() { |
ZhuoKeTeam/MasterHelper | app/src/main/java/com/team/zhuoke/masterhelper/fragment/marster/ArticleListService.java | // Path: app/src/main/java/com/team/zhuoke/masterhelper/api/NetWorkApi.java
// public class NetWorkApi {
//
// public static String baseUrl = "https://zkteam.wilddogio.com";
// // test
// public static final String getMasterList = "/master_list.json";
// public static final String getTestList = "/master_list.json";
//
// public static final String newBaseUrl = "http://www.zkteam.cc";
//
// public static final String masterInfo = newBaseUrl + "/api/jsonMasterInfo";
// public static final String masterArticle = "/api/jsonMasterArticle";
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/fragment/ArticleInfoBean.java
// public class ArticleInfoBean {
//
// /**
// * id : 14
// * uid : 1246141947
// * name : lmj623565791
// * nick_name : Hongyang
// * des : 生命不息,奋斗不止,万事起于忽微,量变引起质变
// * article_title : Android UI性能优化 检测应用中的UI卡顿
// * article_address : http://blog.csdn.net/lmj623565791/article/details/60874334
// */
//
// private int id;
// private long uid;
// private String name;
// private String nick_name;
// private String des;
// private String article_title;
// private String article_address;
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public long getUid() {
// return uid;
// }
//
// public void setUid(long uid) {
// this.uid = uid;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getNick_name() {
// return nick_name;
// }
//
// public void setNick_name(String nick_name) {
// this.nick_name = nick_name;
// }
//
// public String getDes() {
// return des;
// }
//
// public void setDes(String des) {
// this.des = des;
// }
//
// public String getArticle_title() {
// return article_title;
// }
//
// public void setArticle_title(String article_title) {
// this.article_title = article_title;
// }
//
// public String getArticle_address() {
// return article_address;
// }
//
// public void setArticle_address(String article_address) {
// this.article_address = article_address;
// }
//
// @Override
// public String toString() {
// return "ArticleInfoBean{" +
// "id=" + id +
// ", uid=" + uid +
// ", name='" + name + '\'' +
// ", nick_name='" + nick_name + '\'' +
// ", des='" + des + '\'' +
// ", article_title='" + article_title + '\'' +
// ", article_address='" + article_address + '\'' +
// '}';
// }
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/fragment/BaseBean.java
// public class BaseBean<T> {
//
//
// /**
// * code : 0
// * message : ok
// * result : [{"id":14,"uid":1246141947,"name":"lmj623565791","nick_name":"Hongyang","des":"生命不息,奋斗不止,万事起于忽微,量变引起质变","article_title":"Android UI性能优化 检测应用中的UI卡顿","article_address":"http://blog.csdn.net/lmj623565791/article/details/60874334"}]
// */
//
// private int code;
// private String message;
// private List<T> result;
//
// public int getCode() {
// return code;
// }
//
// public void setCode(int code) {
// this.code = code;
// }
//
// public String getMessage() {
// return message;
// }
//
// public void setMessage(String message) {
// this.message = message;
// }
//
// public List<T> getResult() {
// return result;
// }
//
// public void setResult(List<T> datas) {
// this.result = datas;
// }
//
// @Override
// public String toString() {
// return "BaseBean{" +
// "code=" + code +
// ", message='" + message + '\'' +
// ", datas=" + result +
// '}';
// }
// }
| import com.team.zhuoke.masterhelper.api.NetWorkApi;
import com.team.zhuoke.masterhelper.fragment.ArticleInfoBean;
import com.team.zhuoke.masterhelper.fragment.BaseBean;
import retrofit2.http.GET;
import retrofit2.http.Query;
import rx.Observable; | package com.team.zhuoke.masterhelper.fragment.marster;
/**
* Created by renxl
* On 2017/4/24 16:08.
*/
interface ArticleListService {
@GET(NetWorkApi.masterArticle) | // Path: app/src/main/java/com/team/zhuoke/masterhelper/api/NetWorkApi.java
// public class NetWorkApi {
//
// public static String baseUrl = "https://zkteam.wilddogio.com";
// // test
// public static final String getMasterList = "/master_list.json";
// public static final String getTestList = "/master_list.json";
//
// public static final String newBaseUrl = "http://www.zkteam.cc";
//
// public static final String masterInfo = newBaseUrl + "/api/jsonMasterInfo";
// public static final String masterArticle = "/api/jsonMasterArticle";
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/fragment/ArticleInfoBean.java
// public class ArticleInfoBean {
//
// /**
// * id : 14
// * uid : 1246141947
// * name : lmj623565791
// * nick_name : Hongyang
// * des : 生命不息,奋斗不止,万事起于忽微,量变引起质变
// * article_title : Android UI性能优化 检测应用中的UI卡顿
// * article_address : http://blog.csdn.net/lmj623565791/article/details/60874334
// */
//
// private int id;
// private long uid;
// private String name;
// private String nick_name;
// private String des;
// private String article_title;
// private String article_address;
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public long getUid() {
// return uid;
// }
//
// public void setUid(long uid) {
// this.uid = uid;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getNick_name() {
// return nick_name;
// }
//
// public void setNick_name(String nick_name) {
// this.nick_name = nick_name;
// }
//
// public String getDes() {
// return des;
// }
//
// public void setDes(String des) {
// this.des = des;
// }
//
// public String getArticle_title() {
// return article_title;
// }
//
// public void setArticle_title(String article_title) {
// this.article_title = article_title;
// }
//
// public String getArticle_address() {
// return article_address;
// }
//
// public void setArticle_address(String article_address) {
// this.article_address = article_address;
// }
//
// @Override
// public String toString() {
// return "ArticleInfoBean{" +
// "id=" + id +
// ", uid=" + uid +
// ", name='" + name + '\'' +
// ", nick_name='" + nick_name + '\'' +
// ", des='" + des + '\'' +
// ", article_title='" + article_title + '\'' +
// ", article_address='" + article_address + '\'' +
// '}';
// }
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/fragment/BaseBean.java
// public class BaseBean<T> {
//
//
// /**
// * code : 0
// * message : ok
// * result : [{"id":14,"uid":1246141947,"name":"lmj623565791","nick_name":"Hongyang","des":"生命不息,奋斗不止,万事起于忽微,量变引起质变","article_title":"Android UI性能优化 检测应用中的UI卡顿","article_address":"http://blog.csdn.net/lmj623565791/article/details/60874334"}]
// */
//
// private int code;
// private String message;
// private List<T> result;
//
// public int getCode() {
// return code;
// }
//
// public void setCode(int code) {
// this.code = code;
// }
//
// public String getMessage() {
// return message;
// }
//
// public void setMessage(String message) {
// this.message = message;
// }
//
// public List<T> getResult() {
// return result;
// }
//
// public void setResult(List<T> datas) {
// this.result = datas;
// }
//
// @Override
// public String toString() {
// return "BaseBean{" +
// "code=" + code +
// ", message='" + message + '\'' +
// ", datas=" + result +
// '}';
// }
// }
// Path: app/src/main/java/com/team/zhuoke/masterhelper/fragment/marster/ArticleListService.java
import com.team.zhuoke.masterhelper.api.NetWorkApi;
import com.team.zhuoke.masterhelper.fragment.ArticleInfoBean;
import com.team.zhuoke.masterhelper.fragment.BaseBean;
import retrofit2.http.GET;
import retrofit2.http.Query;
import rx.Observable;
package com.team.zhuoke.masterhelper.fragment.marster;
/**
* Created by renxl
* On 2017/4/24 16:08.
*/
interface ArticleListService {
@GET(NetWorkApi.masterArticle) | Observable<BaseBean<ArticleInfoBean>> getArticleList(@Query("uid") String uid, @Query("pageCount") int pageCount); |
ZhuoKeTeam/MasterHelper | app/src/main/java/com/team/zhuoke/masterhelper/fragment/marster/ArticleListService.java | // Path: app/src/main/java/com/team/zhuoke/masterhelper/api/NetWorkApi.java
// public class NetWorkApi {
//
// public static String baseUrl = "https://zkteam.wilddogio.com";
// // test
// public static final String getMasterList = "/master_list.json";
// public static final String getTestList = "/master_list.json";
//
// public static final String newBaseUrl = "http://www.zkteam.cc";
//
// public static final String masterInfo = newBaseUrl + "/api/jsonMasterInfo";
// public static final String masterArticle = "/api/jsonMasterArticle";
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/fragment/ArticleInfoBean.java
// public class ArticleInfoBean {
//
// /**
// * id : 14
// * uid : 1246141947
// * name : lmj623565791
// * nick_name : Hongyang
// * des : 生命不息,奋斗不止,万事起于忽微,量变引起质变
// * article_title : Android UI性能优化 检测应用中的UI卡顿
// * article_address : http://blog.csdn.net/lmj623565791/article/details/60874334
// */
//
// private int id;
// private long uid;
// private String name;
// private String nick_name;
// private String des;
// private String article_title;
// private String article_address;
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public long getUid() {
// return uid;
// }
//
// public void setUid(long uid) {
// this.uid = uid;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getNick_name() {
// return nick_name;
// }
//
// public void setNick_name(String nick_name) {
// this.nick_name = nick_name;
// }
//
// public String getDes() {
// return des;
// }
//
// public void setDes(String des) {
// this.des = des;
// }
//
// public String getArticle_title() {
// return article_title;
// }
//
// public void setArticle_title(String article_title) {
// this.article_title = article_title;
// }
//
// public String getArticle_address() {
// return article_address;
// }
//
// public void setArticle_address(String article_address) {
// this.article_address = article_address;
// }
//
// @Override
// public String toString() {
// return "ArticleInfoBean{" +
// "id=" + id +
// ", uid=" + uid +
// ", name='" + name + '\'' +
// ", nick_name='" + nick_name + '\'' +
// ", des='" + des + '\'' +
// ", article_title='" + article_title + '\'' +
// ", article_address='" + article_address + '\'' +
// '}';
// }
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/fragment/BaseBean.java
// public class BaseBean<T> {
//
//
// /**
// * code : 0
// * message : ok
// * result : [{"id":14,"uid":1246141947,"name":"lmj623565791","nick_name":"Hongyang","des":"生命不息,奋斗不止,万事起于忽微,量变引起质变","article_title":"Android UI性能优化 检测应用中的UI卡顿","article_address":"http://blog.csdn.net/lmj623565791/article/details/60874334"}]
// */
//
// private int code;
// private String message;
// private List<T> result;
//
// public int getCode() {
// return code;
// }
//
// public void setCode(int code) {
// this.code = code;
// }
//
// public String getMessage() {
// return message;
// }
//
// public void setMessage(String message) {
// this.message = message;
// }
//
// public List<T> getResult() {
// return result;
// }
//
// public void setResult(List<T> datas) {
// this.result = datas;
// }
//
// @Override
// public String toString() {
// return "BaseBean{" +
// "code=" + code +
// ", message='" + message + '\'' +
// ", datas=" + result +
// '}';
// }
// }
| import com.team.zhuoke.masterhelper.api.NetWorkApi;
import com.team.zhuoke.masterhelper.fragment.ArticleInfoBean;
import com.team.zhuoke.masterhelper.fragment.BaseBean;
import retrofit2.http.GET;
import retrofit2.http.Query;
import rx.Observable; | package com.team.zhuoke.masterhelper.fragment.marster;
/**
* Created by renxl
* On 2017/4/24 16:08.
*/
interface ArticleListService {
@GET(NetWorkApi.masterArticle) | // Path: app/src/main/java/com/team/zhuoke/masterhelper/api/NetWorkApi.java
// public class NetWorkApi {
//
// public static String baseUrl = "https://zkteam.wilddogio.com";
// // test
// public static final String getMasterList = "/master_list.json";
// public static final String getTestList = "/master_list.json";
//
// public static final String newBaseUrl = "http://www.zkteam.cc";
//
// public static final String masterInfo = newBaseUrl + "/api/jsonMasterInfo";
// public static final String masterArticle = "/api/jsonMasterArticle";
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/fragment/ArticleInfoBean.java
// public class ArticleInfoBean {
//
// /**
// * id : 14
// * uid : 1246141947
// * name : lmj623565791
// * nick_name : Hongyang
// * des : 生命不息,奋斗不止,万事起于忽微,量变引起质变
// * article_title : Android UI性能优化 检测应用中的UI卡顿
// * article_address : http://blog.csdn.net/lmj623565791/article/details/60874334
// */
//
// private int id;
// private long uid;
// private String name;
// private String nick_name;
// private String des;
// private String article_title;
// private String article_address;
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public long getUid() {
// return uid;
// }
//
// public void setUid(long uid) {
// this.uid = uid;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getNick_name() {
// return nick_name;
// }
//
// public void setNick_name(String nick_name) {
// this.nick_name = nick_name;
// }
//
// public String getDes() {
// return des;
// }
//
// public void setDes(String des) {
// this.des = des;
// }
//
// public String getArticle_title() {
// return article_title;
// }
//
// public void setArticle_title(String article_title) {
// this.article_title = article_title;
// }
//
// public String getArticle_address() {
// return article_address;
// }
//
// public void setArticle_address(String article_address) {
// this.article_address = article_address;
// }
//
// @Override
// public String toString() {
// return "ArticleInfoBean{" +
// "id=" + id +
// ", uid=" + uid +
// ", name='" + name + '\'' +
// ", nick_name='" + nick_name + '\'' +
// ", des='" + des + '\'' +
// ", article_title='" + article_title + '\'' +
// ", article_address='" + article_address + '\'' +
// '}';
// }
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/fragment/BaseBean.java
// public class BaseBean<T> {
//
//
// /**
// * code : 0
// * message : ok
// * result : [{"id":14,"uid":1246141947,"name":"lmj623565791","nick_name":"Hongyang","des":"生命不息,奋斗不止,万事起于忽微,量变引起质变","article_title":"Android UI性能优化 检测应用中的UI卡顿","article_address":"http://blog.csdn.net/lmj623565791/article/details/60874334"}]
// */
//
// private int code;
// private String message;
// private List<T> result;
//
// public int getCode() {
// return code;
// }
//
// public void setCode(int code) {
// this.code = code;
// }
//
// public String getMessage() {
// return message;
// }
//
// public void setMessage(String message) {
// this.message = message;
// }
//
// public List<T> getResult() {
// return result;
// }
//
// public void setResult(List<T> datas) {
// this.result = datas;
// }
//
// @Override
// public String toString() {
// return "BaseBean{" +
// "code=" + code +
// ", message='" + message + '\'' +
// ", datas=" + result +
// '}';
// }
// }
// Path: app/src/main/java/com/team/zhuoke/masterhelper/fragment/marster/ArticleListService.java
import com.team.zhuoke.masterhelper.api.NetWorkApi;
import com.team.zhuoke.masterhelper.fragment.ArticleInfoBean;
import com.team.zhuoke.masterhelper.fragment.BaseBean;
import retrofit2.http.GET;
import retrofit2.http.Query;
import rx.Observable;
package com.team.zhuoke.masterhelper.fragment.marster;
/**
* Created by renxl
* On 2017/4/24 16:08.
*/
interface ArticleListService {
@GET(NetWorkApi.masterArticle) | Observable<BaseBean<ArticleInfoBean>> getArticleList(@Query("uid") String uid, @Query("pageCount") int pageCount); |
ZhuoKeTeam/MasterHelper | app/src/main/java/com/team/zhuoke/masterhelper/utils/SharePreferencesHelper.java | // Path: app/src/main/java/com/team/zhuoke/masterhelper/ZhuoKeApplication.java
// public class ZhuoKeApplication extends Application {
// private static ZhuoKeApplication instance=null;
//
// public static ZhuoKeApplication getInstance(){
// return instance;
// }
//
// private static Context sContext;
//
// @Override
// public void onCreate() {
// super.onCreate();
// instance=this;
// sContext = this;
//
// L.init();
// initOkHttpUtils();
//
// Fresco.initialize(sContext);
//
// // 预加载X5
// // QbSdk.initX5Environment(getApplicationContext(), null);
// }
//
// /**
// * 初始化网络请求
// */
// private void initOkHttpUtils() {
// // Cookie
// CookieJarImpl cookieJar = new CookieJarImpl(new PersistentCookieStore(getApplicationContext()));
// // Https
// HttpsUtils.SSLParams sslParams = HttpsUtils.getSslSocketFactory(null, null, null);
//
// OkHttpClient okHttpClient = new OkHttpClient.Builder()
// .connectTimeout(10000L, TimeUnit.MILLISECONDS)
// .readTimeout(10000L, TimeUnit.MILLISECONDS)
// .sslSocketFactory(sslParams.sSLSocketFactory, sslParams.trustManager)
// .cookieJar(cookieJar)
// //其他配置
// .build();
// OkHttpUtils.initClient(okHttpClient);
// /**
// * 网络配置
// */
// NetWorkConfiguration configuration=new NetWorkConfiguration(this)
// .baseUrl(NetWorkApi.baseUrl)
// .isCache(true)
// .isDiskCache(true)
// .isMemoryCache(false);
// HttpUtils.setConFiguration(configuration);
//
//
// }
//
// public static Context getContext() {
// return sContext;
// }
//
// }
| import android.content.Context;
import android.content.SharedPreferences;
import android.util.Log;
import com.team.zhuoke.masterhelper.ZhuoKeApplication; | package com.team.zhuoke.masterhelper.utils;
/**
* SharePreferences帮助类 暂时是写了存String的 拿来给大家看一下
* Created by Gzw on 16/7/8.
*/
public class SharePreferencesHelper {
private static final String TAG = "SharePreferencesHelper";
/**
* TagName区域
*/
public static final String USER_INFO = "user_info"; // 用户信息
public static final String DEVICE_INFO = "phone_info"; // 用户设备信息
/**
* Key区域
*/
public static final String USER_ACCOUNT = "user_account"; // USER_INFO中的用户账号
public static final String USER_PWD = "user_pwd"; // USER_INFO中的用户密码
public static final String USER_NAME = "user_name"; // USER_INFO中的用户名称
public static final String DEVICE_ID = "device_id"; // DEVICE_INFO中的设备Id 区分不同设备的唯一编号 | // Path: app/src/main/java/com/team/zhuoke/masterhelper/ZhuoKeApplication.java
// public class ZhuoKeApplication extends Application {
// private static ZhuoKeApplication instance=null;
//
// public static ZhuoKeApplication getInstance(){
// return instance;
// }
//
// private static Context sContext;
//
// @Override
// public void onCreate() {
// super.onCreate();
// instance=this;
// sContext = this;
//
// L.init();
// initOkHttpUtils();
//
// Fresco.initialize(sContext);
//
// // 预加载X5
// // QbSdk.initX5Environment(getApplicationContext(), null);
// }
//
// /**
// * 初始化网络请求
// */
// private void initOkHttpUtils() {
// // Cookie
// CookieJarImpl cookieJar = new CookieJarImpl(new PersistentCookieStore(getApplicationContext()));
// // Https
// HttpsUtils.SSLParams sslParams = HttpsUtils.getSslSocketFactory(null, null, null);
//
// OkHttpClient okHttpClient = new OkHttpClient.Builder()
// .connectTimeout(10000L, TimeUnit.MILLISECONDS)
// .readTimeout(10000L, TimeUnit.MILLISECONDS)
// .sslSocketFactory(sslParams.sSLSocketFactory, sslParams.trustManager)
// .cookieJar(cookieJar)
// //其他配置
// .build();
// OkHttpUtils.initClient(okHttpClient);
// /**
// * 网络配置
// */
// NetWorkConfiguration configuration=new NetWorkConfiguration(this)
// .baseUrl(NetWorkApi.baseUrl)
// .isCache(true)
// .isDiskCache(true)
// .isMemoryCache(false);
// HttpUtils.setConFiguration(configuration);
//
//
// }
//
// public static Context getContext() {
// return sContext;
// }
//
// }
// Path: app/src/main/java/com/team/zhuoke/masterhelper/utils/SharePreferencesHelper.java
import android.content.Context;
import android.content.SharedPreferences;
import android.util.Log;
import com.team.zhuoke.masterhelper.ZhuoKeApplication;
package com.team.zhuoke.masterhelper.utils;
/**
* SharePreferences帮助类 暂时是写了存String的 拿来给大家看一下
* Created by Gzw on 16/7/8.
*/
public class SharePreferencesHelper {
private static final String TAG = "SharePreferencesHelper";
/**
* TagName区域
*/
public static final String USER_INFO = "user_info"; // 用户信息
public static final String DEVICE_INFO = "phone_info"; // 用户设备信息
/**
* Key区域
*/
public static final String USER_ACCOUNT = "user_account"; // USER_INFO中的用户账号
public static final String USER_PWD = "user_pwd"; // USER_INFO中的用户密码
public static final String USER_NAME = "user_name"; // USER_INFO中的用户名称
public static final String DEVICE_ID = "device_id"; // DEVICE_INFO中的设备Id 区分不同设备的唯一编号 | private static final Context CONTEXT = ZhuoKeApplication.getContext(); // 上下文对象 |
ZhuoKeTeam/MasterHelper | app/src/main/java/com/team/zhuoke/masterhelper/fragment/marster/MasterContract.java | // Path: app/src/main/java/com/team/zhuoke/masterhelper/base/BaseModel.java
// public interface BaseModel {
//
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/base/BasePresenter.java
// public abstract class BasePresenter<V extends BaseView, M extends BaseModel> implements Presenter<V,M> {
//
//
// protected Context mContext;
//
// protected V mView;
//
// protected M mModel;
//
// protected CompositeSubscription mCompositeSubscription;
//
// protected void unSubscribe() {
// if (mCompositeSubscription != null) {
// mCompositeSubscription.unsubscribe();
// }
// }
// protected void addSubscribe(Subscription subscription) {
// if (mCompositeSubscription == null) {
// mCompositeSubscription = new CompositeSubscription();
// }
// mCompositeSubscription.add(subscription);
// }
//
// // 获取绑定View实例
// @Override
// public void attachView(V view) {
// this.mView=view;
// }
// // 获取绑定Model层实例
// @Override
// public void attachModel(M m) {
// this.mModel=m;
// }
//
//
// public M getModel() {
// return mModel;
// }
// // 注销mModel实例
// @Override
// public void detachModel() {
// this.mModel=null;
// }
//
// // 注销View实例
// @Override
// public void detachView() {
// this.mView=null;
// unSubscribe();
// }
//
// public V getView() {
// return mView;
// }
//
// public boolean isViewBind()
// {
// return mView!=null;
// }
//
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/base/BaseView.java
// public interface BaseView<P> {
//
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/fragment/MasterInfoBean.java
// public class MasterInfoBean {
// /**
// * id : 1
// * uid : 1246141947
// * name : lmj623565791
// * nick_name : Hongyang
// * img : http://avatar.csdn.net/F/F/5/1_lmj623565791.jpg
// * info : 生命不息,奋斗不止,万事起于忽微,量变引起质变
// * isVip : 1
// * index : 0
// * blog : http://blog.csdn.net/lmj623565791?viewmode=contents
// */
//
// private int id;
// private String uid;
// private String name;
// private String nick_name;
// private String img;
// private String info;
// private String isVip;
// private int index;
// private String blog;
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public String getUid() {
// return uid;
// }
//
// public void setUid(String uid) {
// this.uid = uid;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getNick_name() {
// return nick_name;
// }
//
// public void setNick_name(String nick_name) {
// this.nick_name = nick_name;
// }
//
// public String getImg() {
// return img;
// }
//
// public void setImg(String img) {
// this.img = img;
// }
//
// public String getInfo() {
// return info;
// }
//
// public void setInfo(String info) {
// this.info = info;
// }
//
// public String getIsVip() {
// return isVip;
// }
//
// public void setIsVip(String isVip) {
// this.isVip = isVip;
// }
//
// public int getIndex() {
// return index;
// }
//
// public void setIndex(int index) {
// this.index = index;
// }
//
// public String getBlog() {
// return blog;
// }
//
// public void setBlog(String blog) {
// this.blog = blog;
// }
// }
| import android.content.Context;
import com.team.zhuoke.masterhelper.base.BaseModel;
import com.team.zhuoke.masterhelper.base.BasePresenter;
import com.team.zhuoke.masterhelper.base.BaseView;
import com.team.zhuoke.masterhelper.fragment.MasterInfoBean;
import java.util.List;
import rx.Observable; | package com.team.zhuoke.masterhelper.fragment.marster;
/**
* Created by WangQing on 2017/4/20.
*/
public class MasterContract {
interface View extends BaseView { | // Path: app/src/main/java/com/team/zhuoke/masterhelper/base/BaseModel.java
// public interface BaseModel {
//
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/base/BasePresenter.java
// public abstract class BasePresenter<V extends BaseView, M extends BaseModel> implements Presenter<V,M> {
//
//
// protected Context mContext;
//
// protected V mView;
//
// protected M mModel;
//
// protected CompositeSubscription mCompositeSubscription;
//
// protected void unSubscribe() {
// if (mCompositeSubscription != null) {
// mCompositeSubscription.unsubscribe();
// }
// }
// protected void addSubscribe(Subscription subscription) {
// if (mCompositeSubscription == null) {
// mCompositeSubscription = new CompositeSubscription();
// }
// mCompositeSubscription.add(subscription);
// }
//
// // 获取绑定View实例
// @Override
// public void attachView(V view) {
// this.mView=view;
// }
// // 获取绑定Model层实例
// @Override
// public void attachModel(M m) {
// this.mModel=m;
// }
//
//
// public M getModel() {
// return mModel;
// }
// // 注销mModel实例
// @Override
// public void detachModel() {
// this.mModel=null;
// }
//
// // 注销View实例
// @Override
// public void detachView() {
// this.mView=null;
// unSubscribe();
// }
//
// public V getView() {
// return mView;
// }
//
// public boolean isViewBind()
// {
// return mView!=null;
// }
//
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/base/BaseView.java
// public interface BaseView<P> {
//
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/fragment/MasterInfoBean.java
// public class MasterInfoBean {
// /**
// * id : 1
// * uid : 1246141947
// * name : lmj623565791
// * nick_name : Hongyang
// * img : http://avatar.csdn.net/F/F/5/1_lmj623565791.jpg
// * info : 生命不息,奋斗不止,万事起于忽微,量变引起质变
// * isVip : 1
// * index : 0
// * blog : http://blog.csdn.net/lmj623565791?viewmode=contents
// */
//
// private int id;
// private String uid;
// private String name;
// private String nick_name;
// private String img;
// private String info;
// private String isVip;
// private int index;
// private String blog;
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public String getUid() {
// return uid;
// }
//
// public void setUid(String uid) {
// this.uid = uid;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getNick_name() {
// return nick_name;
// }
//
// public void setNick_name(String nick_name) {
// this.nick_name = nick_name;
// }
//
// public String getImg() {
// return img;
// }
//
// public void setImg(String img) {
// this.img = img;
// }
//
// public String getInfo() {
// return info;
// }
//
// public void setInfo(String info) {
// this.info = info;
// }
//
// public String getIsVip() {
// return isVip;
// }
//
// public void setIsVip(String isVip) {
// this.isVip = isVip;
// }
//
// public int getIndex() {
// return index;
// }
//
// public void setIndex(int index) {
// this.index = index;
// }
//
// public String getBlog() {
// return blog;
// }
//
// public void setBlog(String blog) {
// this.blog = blog;
// }
// }
// Path: app/src/main/java/com/team/zhuoke/masterhelper/fragment/marster/MasterContract.java
import android.content.Context;
import com.team.zhuoke.masterhelper.base.BaseModel;
import com.team.zhuoke.masterhelper.base.BasePresenter;
import com.team.zhuoke.masterhelper.base.BaseView;
import com.team.zhuoke.masterhelper.fragment.MasterInfoBean;
import java.util.List;
import rx.Observable;
package com.team.zhuoke.masterhelper.fragment.marster;
/**
* Created by WangQing on 2017/4/20.
*/
public class MasterContract {
interface View extends BaseView { | void setData(List<MasterInfoBean> masterInfoBeanList); |
ZhuoKeTeam/MasterHelper | app/src/main/java/com/team/zhuoke/masterhelper/fragment/marster/MasterContract.java | // Path: app/src/main/java/com/team/zhuoke/masterhelper/base/BaseModel.java
// public interface BaseModel {
//
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/base/BasePresenter.java
// public abstract class BasePresenter<V extends BaseView, M extends BaseModel> implements Presenter<V,M> {
//
//
// protected Context mContext;
//
// protected V mView;
//
// protected M mModel;
//
// protected CompositeSubscription mCompositeSubscription;
//
// protected void unSubscribe() {
// if (mCompositeSubscription != null) {
// mCompositeSubscription.unsubscribe();
// }
// }
// protected void addSubscribe(Subscription subscription) {
// if (mCompositeSubscription == null) {
// mCompositeSubscription = new CompositeSubscription();
// }
// mCompositeSubscription.add(subscription);
// }
//
// // 获取绑定View实例
// @Override
// public void attachView(V view) {
// this.mView=view;
// }
// // 获取绑定Model层实例
// @Override
// public void attachModel(M m) {
// this.mModel=m;
// }
//
//
// public M getModel() {
// return mModel;
// }
// // 注销mModel实例
// @Override
// public void detachModel() {
// this.mModel=null;
// }
//
// // 注销View实例
// @Override
// public void detachView() {
// this.mView=null;
// unSubscribe();
// }
//
// public V getView() {
// return mView;
// }
//
// public boolean isViewBind()
// {
// return mView!=null;
// }
//
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/base/BaseView.java
// public interface BaseView<P> {
//
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/fragment/MasterInfoBean.java
// public class MasterInfoBean {
// /**
// * id : 1
// * uid : 1246141947
// * name : lmj623565791
// * nick_name : Hongyang
// * img : http://avatar.csdn.net/F/F/5/1_lmj623565791.jpg
// * info : 生命不息,奋斗不止,万事起于忽微,量变引起质变
// * isVip : 1
// * index : 0
// * blog : http://blog.csdn.net/lmj623565791?viewmode=contents
// */
//
// private int id;
// private String uid;
// private String name;
// private String nick_name;
// private String img;
// private String info;
// private String isVip;
// private int index;
// private String blog;
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public String getUid() {
// return uid;
// }
//
// public void setUid(String uid) {
// this.uid = uid;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getNick_name() {
// return nick_name;
// }
//
// public void setNick_name(String nick_name) {
// this.nick_name = nick_name;
// }
//
// public String getImg() {
// return img;
// }
//
// public void setImg(String img) {
// this.img = img;
// }
//
// public String getInfo() {
// return info;
// }
//
// public void setInfo(String info) {
// this.info = info;
// }
//
// public String getIsVip() {
// return isVip;
// }
//
// public void setIsVip(String isVip) {
// this.isVip = isVip;
// }
//
// public int getIndex() {
// return index;
// }
//
// public void setIndex(int index) {
// this.index = index;
// }
//
// public String getBlog() {
// return blog;
// }
//
// public void setBlog(String blog) {
// this.blog = blog;
// }
// }
| import android.content.Context;
import com.team.zhuoke.masterhelper.base.BaseModel;
import com.team.zhuoke.masterhelper.base.BasePresenter;
import com.team.zhuoke.masterhelper.base.BaseView;
import com.team.zhuoke.masterhelper.fragment.MasterInfoBean;
import java.util.List;
import rx.Observable; | package com.team.zhuoke.masterhelper.fragment.marster;
/**
* Created by WangQing on 2017/4/20.
*/
public class MasterContract {
interface View extends BaseView {
void setData(List<MasterInfoBean> masterInfoBeanList);
void setErrorInfo(String message);
}
| // Path: app/src/main/java/com/team/zhuoke/masterhelper/base/BaseModel.java
// public interface BaseModel {
//
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/base/BasePresenter.java
// public abstract class BasePresenter<V extends BaseView, M extends BaseModel> implements Presenter<V,M> {
//
//
// protected Context mContext;
//
// protected V mView;
//
// protected M mModel;
//
// protected CompositeSubscription mCompositeSubscription;
//
// protected void unSubscribe() {
// if (mCompositeSubscription != null) {
// mCompositeSubscription.unsubscribe();
// }
// }
// protected void addSubscribe(Subscription subscription) {
// if (mCompositeSubscription == null) {
// mCompositeSubscription = new CompositeSubscription();
// }
// mCompositeSubscription.add(subscription);
// }
//
// // 获取绑定View实例
// @Override
// public void attachView(V view) {
// this.mView=view;
// }
// // 获取绑定Model层实例
// @Override
// public void attachModel(M m) {
// this.mModel=m;
// }
//
//
// public M getModel() {
// return mModel;
// }
// // 注销mModel实例
// @Override
// public void detachModel() {
// this.mModel=null;
// }
//
// // 注销View实例
// @Override
// public void detachView() {
// this.mView=null;
// unSubscribe();
// }
//
// public V getView() {
// return mView;
// }
//
// public boolean isViewBind()
// {
// return mView!=null;
// }
//
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/base/BaseView.java
// public interface BaseView<P> {
//
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/fragment/MasterInfoBean.java
// public class MasterInfoBean {
// /**
// * id : 1
// * uid : 1246141947
// * name : lmj623565791
// * nick_name : Hongyang
// * img : http://avatar.csdn.net/F/F/5/1_lmj623565791.jpg
// * info : 生命不息,奋斗不止,万事起于忽微,量变引起质变
// * isVip : 1
// * index : 0
// * blog : http://blog.csdn.net/lmj623565791?viewmode=contents
// */
//
// private int id;
// private String uid;
// private String name;
// private String nick_name;
// private String img;
// private String info;
// private String isVip;
// private int index;
// private String blog;
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public String getUid() {
// return uid;
// }
//
// public void setUid(String uid) {
// this.uid = uid;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getNick_name() {
// return nick_name;
// }
//
// public void setNick_name(String nick_name) {
// this.nick_name = nick_name;
// }
//
// public String getImg() {
// return img;
// }
//
// public void setImg(String img) {
// this.img = img;
// }
//
// public String getInfo() {
// return info;
// }
//
// public void setInfo(String info) {
// this.info = info;
// }
//
// public String getIsVip() {
// return isVip;
// }
//
// public void setIsVip(String isVip) {
// this.isVip = isVip;
// }
//
// public int getIndex() {
// return index;
// }
//
// public void setIndex(int index) {
// this.index = index;
// }
//
// public String getBlog() {
// return blog;
// }
//
// public void setBlog(String blog) {
// this.blog = blog;
// }
// }
// Path: app/src/main/java/com/team/zhuoke/masterhelper/fragment/marster/MasterContract.java
import android.content.Context;
import com.team.zhuoke.masterhelper.base.BaseModel;
import com.team.zhuoke.masterhelper.base.BasePresenter;
import com.team.zhuoke.masterhelper.base.BaseView;
import com.team.zhuoke.masterhelper.fragment.MasterInfoBean;
import java.util.List;
import rx.Observable;
package com.team.zhuoke.masterhelper.fragment.marster;
/**
* Created by WangQing on 2017/4/20.
*/
public class MasterContract {
interface View extends BaseView {
void setData(List<MasterInfoBean> masterInfoBeanList);
void setErrorInfo(String message);
}
| interface Model extends BaseModel { |
ZhuoKeTeam/MasterHelper | app/src/main/java/com/team/zhuoke/masterhelper/fragment/marster/MasterContract.java | // Path: app/src/main/java/com/team/zhuoke/masterhelper/base/BaseModel.java
// public interface BaseModel {
//
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/base/BasePresenter.java
// public abstract class BasePresenter<V extends BaseView, M extends BaseModel> implements Presenter<V,M> {
//
//
// protected Context mContext;
//
// protected V mView;
//
// protected M mModel;
//
// protected CompositeSubscription mCompositeSubscription;
//
// protected void unSubscribe() {
// if (mCompositeSubscription != null) {
// mCompositeSubscription.unsubscribe();
// }
// }
// protected void addSubscribe(Subscription subscription) {
// if (mCompositeSubscription == null) {
// mCompositeSubscription = new CompositeSubscription();
// }
// mCompositeSubscription.add(subscription);
// }
//
// // 获取绑定View实例
// @Override
// public void attachView(V view) {
// this.mView=view;
// }
// // 获取绑定Model层实例
// @Override
// public void attachModel(M m) {
// this.mModel=m;
// }
//
//
// public M getModel() {
// return mModel;
// }
// // 注销mModel实例
// @Override
// public void detachModel() {
// this.mModel=null;
// }
//
// // 注销View实例
// @Override
// public void detachView() {
// this.mView=null;
// unSubscribe();
// }
//
// public V getView() {
// return mView;
// }
//
// public boolean isViewBind()
// {
// return mView!=null;
// }
//
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/base/BaseView.java
// public interface BaseView<P> {
//
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/fragment/MasterInfoBean.java
// public class MasterInfoBean {
// /**
// * id : 1
// * uid : 1246141947
// * name : lmj623565791
// * nick_name : Hongyang
// * img : http://avatar.csdn.net/F/F/5/1_lmj623565791.jpg
// * info : 生命不息,奋斗不止,万事起于忽微,量变引起质变
// * isVip : 1
// * index : 0
// * blog : http://blog.csdn.net/lmj623565791?viewmode=contents
// */
//
// private int id;
// private String uid;
// private String name;
// private String nick_name;
// private String img;
// private String info;
// private String isVip;
// private int index;
// private String blog;
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public String getUid() {
// return uid;
// }
//
// public void setUid(String uid) {
// this.uid = uid;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getNick_name() {
// return nick_name;
// }
//
// public void setNick_name(String nick_name) {
// this.nick_name = nick_name;
// }
//
// public String getImg() {
// return img;
// }
//
// public void setImg(String img) {
// this.img = img;
// }
//
// public String getInfo() {
// return info;
// }
//
// public void setInfo(String info) {
// this.info = info;
// }
//
// public String getIsVip() {
// return isVip;
// }
//
// public void setIsVip(String isVip) {
// this.isVip = isVip;
// }
//
// public int getIndex() {
// return index;
// }
//
// public void setIndex(int index) {
// this.index = index;
// }
//
// public String getBlog() {
// return blog;
// }
//
// public void setBlog(String blog) {
// this.blog = blog;
// }
// }
| import android.content.Context;
import com.team.zhuoke.masterhelper.base.BaseModel;
import com.team.zhuoke.masterhelper.base.BasePresenter;
import com.team.zhuoke.masterhelper.base.BaseView;
import com.team.zhuoke.masterhelper.fragment.MasterInfoBean;
import java.util.List;
import rx.Observable; | package com.team.zhuoke.masterhelper.fragment.marster;
/**
* Created by WangQing on 2017/4/20.
*/
public class MasterContract {
interface View extends BaseView {
void setData(List<MasterInfoBean> masterInfoBeanList);
void setErrorInfo(String message);
}
interface Model extends BaseModel {
Observable<List<MasterInfoBean>> getMasterData(Context context);
}
| // Path: app/src/main/java/com/team/zhuoke/masterhelper/base/BaseModel.java
// public interface BaseModel {
//
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/base/BasePresenter.java
// public abstract class BasePresenter<V extends BaseView, M extends BaseModel> implements Presenter<V,M> {
//
//
// protected Context mContext;
//
// protected V mView;
//
// protected M mModel;
//
// protected CompositeSubscription mCompositeSubscription;
//
// protected void unSubscribe() {
// if (mCompositeSubscription != null) {
// mCompositeSubscription.unsubscribe();
// }
// }
// protected void addSubscribe(Subscription subscription) {
// if (mCompositeSubscription == null) {
// mCompositeSubscription = new CompositeSubscription();
// }
// mCompositeSubscription.add(subscription);
// }
//
// // 获取绑定View实例
// @Override
// public void attachView(V view) {
// this.mView=view;
// }
// // 获取绑定Model层实例
// @Override
// public void attachModel(M m) {
// this.mModel=m;
// }
//
//
// public M getModel() {
// return mModel;
// }
// // 注销mModel实例
// @Override
// public void detachModel() {
// this.mModel=null;
// }
//
// // 注销View实例
// @Override
// public void detachView() {
// this.mView=null;
// unSubscribe();
// }
//
// public V getView() {
// return mView;
// }
//
// public boolean isViewBind()
// {
// return mView!=null;
// }
//
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/base/BaseView.java
// public interface BaseView<P> {
//
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/fragment/MasterInfoBean.java
// public class MasterInfoBean {
// /**
// * id : 1
// * uid : 1246141947
// * name : lmj623565791
// * nick_name : Hongyang
// * img : http://avatar.csdn.net/F/F/5/1_lmj623565791.jpg
// * info : 生命不息,奋斗不止,万事起于忽微,量变引起质变
// * isVip : 1
// * index : 0
// * blog : http://blog.csdn.net/lmj623565791?viewmode=contents
// */
//
// private int id;
// private String uid;
// private String name;
// private String nick_name;
// private String img;
// private String info;
// private String isVip;
// private int index;
// private String blog;
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public String getUid() {
// return uid;
// }
//
// public void setUid(String uid) {
// this.uid = uid;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getNick_name() {
// return nick_name;
// }
//
// public void setNick_name(String nick_name) {
// this.nick_name = nick_name;
// }
//
// public String getImg() {
// return img;
// }
//
// public void setImg(String img) {
// this.img = img;
// }
//
// public String getInfo() {
// return info;
// }
//
// public void setInfo(String info) {
// this.info = info;
// }
//
// public String getIsVip() {
// return isVip;
// }
//
// public void setIsVip(String isVip) {
// this.isVip = isVip;
// }
//
// public int getIndex() {
// return index;
// }
//
// public void setIndex(int index) {
// this.index = index;
// }
//
// public String getBlog() {
// return blog;
// }
//
// public void setBlog(String blog) {
// this.blog = blog;
// }
// }
// Path: app/src/main/java/com/team/zhuoke/masterhelper/fragment/marster/MasterContract.java
import android.content.Context;
import com.team.zhuoke.masterhelper.base.BaseModel;
import com.team.zhuoke.masterhelper.base.BasePresenter;
import com.team.zhuoke.masterhelper.base.BaseView;
import com.team.zhuoke.masterhelper.fragment.MasterInfoBean;
import java.util.List;
import rx.Observable;
package com.team.zhuoke.masterhelper.fragment.marster;
/**
* Created by WangQing on 2017/4/20.
*/
public class MasterContract {
interface View extends BaseView {
void setData(List<MasterInfoBean> masterInfoBeanList);
void setErrorInfo(String message);
}
interface Model extends BaseModel {
Observable<List<MasterInfoBean>> getMasterData(Context context);
}
| public static abstract class Presenter extends BasePresenter<View, Model> { |
ZhuoKeTeam/MasterHelper | app/src/main/java/wq/gdy005/mvp/TestAPI3.java | // Path: app/src/main/java/com/team/zhuoke/masterhelper/api/NetWorkApi.java
// public class NetWorkApi {
//
// public static String baseUrl = "https://zkteam.wilddogio.com";
// // test
// public static final String getMasterList = "/master_list.json";
// public static final String getTestList = "/master_list.json";
//
// public static final String newBaseUrl = "http://www.zkteam.cc";
//
// public static final String masterInfo = newBaseUrl + "/api/jsonMasterInfo";
// public static final String masterArticle = "/api/jsonMasterArticle";
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/model/test/TestList.java
// public class TestList {
//
//
// /**
// * des : 生命不息,奋斗不止,万事起于忽微,量变引起质变
// * grade : 1
// * img : http://tva2.sinaimg.cn/crop.200.80.480.480.180/bca65a60gw1eiedwawzi2j20m80i57a7.jpg
// * info : http://blog.csdn.net/lmj623565791
// * isVip : true
// * name : hongyang
// * weiBo :
// * zhiHu :
// */
//
// private String des;
// private String grade;
// private String img;
// private String info;
// private boolean isVip;
// private String name;
// private String weiBo;
// private String zhiHu;
//
// public String getDes() {
// return des;
// }
//
// public void setDes(String des) {
// this.des = des;
// }
//
// public String getGrade() {
// return grade;
// }
//
// public void setGrade(String grade) {
// this.grade = grade;
// }
//
// public String getImg() {
// return img;
// }
//
// public void setImg(String img) {
// this.img = img;
// }
//
// public String getInfo() {
// return info;
// }
//
// public void setInfo(String info) {
// this.info = info;
// }
//
// public boolean isIsVip() {
// return isVip;
// }
//
// public void setIsVip(boolean isVip) {
// this.isVip = isVip;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getWeiBo() {
// return weiBo;
// }
//
// public void setWeiBo(String weiBo) {
// this.weiBo = weiBo;
// }
//
// public String getZhiHu() {
// return zhiHu;
// }
//
// public void setZhiHu(String zhiHu) {
// this.zhiHu = zhiHu;
// }
//
//
// // 修改模板,快速生成
// @Override
// public String toString() {
// return "{" +
// "des:'" + des + '\'' +
// ", grade:'" + grade + '\'' +
// ", img:'" + img + '\'' +
// ", info:'" + info + '\'' +
// ", isVip:" + isVip +
// ", name:'" + name + '\'' +
// ", weiBo:'" + weiBo + '\'' +
// ", zhiHu:'" + zhiHu + '\'' +
// '}';
// }
//
// // @Override
// // public String toString() {
// // return "MasterList{" +
// // "des='" + des + '\'' +
// // ", grade='" + grade + '\'' +
// // ", img='" + img + '\'' +
// // ", info='" + info + '\'' +
// // ", isVip=" + isVip +
// // ", name='" + name + '\'' +
// // ", weiBo='" + weiBo + '\'' +
// // ", zhiHu='" + zhiHu + '\'' +
// // '}';
// // }
//
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/net/response/HttpResponse.java
// public class HttpResponse<T> {
//
// private String code ;
//
// private T result;
//
// private String message;
//
// public String getCode() {
// return code;
// }
//
// public void setCode(String code) {
// this.code = code;
// }
//
// public T getResult() {
// return result;
// }
//
// public void setResult(T result) {
// this.result = result;
// }
//
// public String getMessage() {
// return message;
// }
//
// public void setMessage(String message) {
// this.message = message;
// }
//
// @Override
// public String toString() {
// return "{" +
// "code:'" + code + '\'' +
// ", result:" + result +
// ", message:'" + message + '\'' +
// '}';
// }
// }
| import com.team.zhuoke.masterhelper.api.NetWorkApi;
import com.team.zhuoke.masterhelper.model.test.TestList;
import com.team.zhuoke.masterhelper.net.response.HttpResponse;
import java.util.List;
import retrofit2.http.GET;
import rx.Observable; | package wq.gdy005.mvp;
/**
* Created by WangQing on 2016/12/7.
*/
public interface TestAPI3 {
@GET(NetWorkApi.getTestList) | // Path: app/src/main/java/com/team/zhuoke/masterhelper/api/NetWorkApi.java
// public class NetWorkApi {
//
// public static String baseUrl = "https://zkteam.wilddogio.com";
// // test
// public static final String getMasterList = "/master_list.json";
// public static final String getTestList = "/master_list.json";
//
// public static final String newBaseUrl = "http://www.zkteam.cc";
//
// public static final String masterInfo = newBaseUrl + "/api/jsonMasterInfo";
// public static final String masterArticle = "/api/jsonMasterArticle";
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/model/test/TestList.java
// public class TestList {
//
//
// /**
// * des : 生命不息,奋斗不止,万事起于忽微,量变引起质变
// * grade : 1
// * img : http://tva2.sinaimg.cn/crop.200.80.480.480.180/bca65a60gw1eiedwawzi2j20m80i57a7.jpg
// * info : http://blog.csdn.net/lmj623565791
// * isVip : true
// * name : hongyang
// * weiBo :
// * zhiHu :
// */
//
// private String des;
// private String grade;
// private String img;
// private String info;
// private boolean isVip;
// private String name;
// private String weiBo;
// private String zhiHu;
//
// public String getDes() {
// return des;
// }
//
// public void setDes(String des) {
// this.des = des;
// }
//
// public String getGrade() {
// return grade;
// }
//
// public void setGrade(String grade) {
// this.grade = grade;
// }
//
// public String getImg() {
// return img;
// }
//
// public void setImg(String img) {
// this.img = img;
// }
//
// public String getInfo() {
// return info;
// }
//
// public void setInfo(String info) {
// this.info = info;
// }
//
// public boolean isIsVip() {
// return isVip;
// }
//
// public void setIsVip(boolean isVip) {
// this.isVip = isVip;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getWeiBo() {
// return weiBo;
// }
//
// public void setWeiBo(String weiBo) {
// this.weiBo = weiBo;
// }
//
// public String getZhiHu() {
// return zhiHu;
// }
//
// public void setZhiHu(String zhiHu) {
// this.zhiHu = zhiHu;
// }
//
//
// // 修改模板,快速生成
// @Override
// public String toString() {
// return "{" +
// "des:'" + des + '\'' +
// ", grade:'" + grade + '\'' +
// ", img:'" + img + '\'' +
// ", info:'" + info + '\'' +
// ", isVip:" + isVip +
// ", name:'" + name + '\'' +
// ", weiBo:'" + weiBo + '\'' +
// ", zhiHu:'" + zhiHu + '\'' +
// '}';
// }
//
// // @Override
// // public String toString() {
// // return "MasterList{" +
// // "des='" + des + '\'' +
// // ", grade='" + grade + '\'' +
// // ", img='" + img + '\'' +
// // ", info='" + info + '\'' +
// // ", isVip=" + isVip +
// // ", name='" + name + '\'' +
// // ", weiBo='" + weiBo + '\'' +
// // ", zhiHu='" + zhiHu + '\'' +
// // '}';
// // }
//
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/net/response/HttpResponse.java
// public class HttpResponse<T> {
//
// private String code ;
//
// private T result;
//
// private String message;
//
// public String getCode() {
// return code;
// }
//
// public void setCode(String code) {
// this.code = code;
// }
//
// public T getResult() {
// return result;
// }
//
// public void setResult(T result) {
// this.result = result;
// }
//
// public String getMessage() {
// return message;
// }
//
// public void setMessage(String message) {
// this.message = message;
// }
//
// @Override
// public String toString() {
// return "{" +
// "code:'" + code + '\'' +
// ", result:" + result +
// ", message:'" + message + '\'' +
// '}';
// }
// }
// Path: app/src/main/java/wq/gdy005/mvp/TestAPI3.java
import com.team.zhuoke.masterhelper.api.NetWorkApi;
import com.team.zhuoke.masterhelper.model.test.TestList;
import com.team.zhuoke.masterhelper.net.response.HttpResponse;
import java.util.List;
import retrofit2.http.GET;
import rx.Observable;
package wq.gdy005.mvp;
/**
* Created by WangQing on 2016/12/7.
*/
public interface TestAPI3 {
@GET(NetWorkApi.getTestList) | Observable<HttpResponse<List<TestList>>> getTestList(); |
ZhuoKeTeam/MasterHelper | app/src/main/java/wq/gdy005/mvp/TestAPI3.java | // Path: app/src/main/java/com/team/zhuoke/masterhelper/api/NetWorkApi.java
// public class NetWorkApi {
//
// public static String baseUrl = "https://zkteam.wilddogio.com";
// // test
// public static final String getMasterList = "/master_list.json";
// public static final String getTestList = "/master_list.json";
//
// public static final String newBaseUrl = "http://www.zkteam.cc";
//
// public static final String masterInfo = newBaseUrl + "/api/jsonMasterInfo";
// public static final String masterArticle = "/api/jsonMasterArticle";
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/model/test/TestList.java
// public class TestList {
//
//
// /**
// * des : 生命不息,奋斗不止,万事起于忽微,量变引起质变
// * grade : 1
// * img : http://tva2.sinaimg.cn/crop.200.80.480.480.180/bca65a60gw1eiedwawzi2j20m80i57a7.jpg
// * info : http://blog.csdn.net/lmj623565791
// * isVip : true
// * name : hongyang
// * weiBo :
// * zhiHu :
// */
//
// private String des;
// private String grade;
// private String img;
// private String info;
// private boolean isVip;
// private String name;
// private String weiBo;
// private String zhiHu;
//
// public String getDes() {
// return des;
// }
//
// public void setDes(String des) {
// this.des = des;
// }
//
// public String getGrade() {
// return grade;
// }
//
// public void setGrade(String grade) {
// this.grade = grade;
// }
//
// public String getImg() {
// return img;
// }
//
// public void setImg(String img) {
// this.img = img;
// }
//
// public String getInfo() {
// return info;
// }
//
// public void setInfo(String info) {
// this.info = info;
// }
//
// public boolean isIsVip() {
// return isVip;
// }
//
// public void setIsVip(boolean isVip) {
// this.isVip = isVip;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getWeiBo() {
// return weiBo;
// }
//
// public void setWeiBo(String weiBo) {
// this.weiBo = weiBo;
// }
//
// public String getZhiHu() {
// return zhiHu;
// }
//
// public void setZhiHu(String zhiHu) {
// this.zhiHu = zhiHu;
// }
//
//
// // 修改模板,快速生成
// @Override
// public String toString() {
// return "{" +
// "des:'" + des + '\'' +
// ", grade:'" + grade + '\'' +
// ", img:'" + img + '\'' +
// ", info:'" + info + '\'' +
// ", isVip:" + isVip +
// ", name:'" + name + '\'' +
// ", weiBo:'" + weiBo + '\'' +
// ", zhiHu:'" + zhiHu + '\'' +
// '}';
// }
//
// // @Override
// // public String toString() {
// // return "MasterList{" +
// // "des='" + des + '\'' +
// // ", grade='" + grade + '\'' +
// // ", img='" + img + '\'' +
// // ", info='" + info + '\'' +
// // ", isVip=" + isVip +
// // ", name='" + name + '\'' +
// // ", weiBo='" + weiBo + '\'' +
// // ", zhiHu='" + zhiHu + '\'' +
// // '}';
// // }
//
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/net/response/HttpResponse.java
// public class HttpResponse<T> {
//
// private String code ;
//
// private T result;
//
// private String message;
//
// public String getCode() {
// return code;
// }
//
// public void setCode(String code) {
// this.code = code;
// }
//
// public T getResult() {
// return result;
// }
//
// public void setResult(T result) {
// this.result = result;
// }
//
// public String getMessage() {
// return message;
// }
//
// public void setMessage(String message) {
// this.message = message;
// }
//
// @Override
// public String toString() {
// return "{" +
// "code:'" + code + '\'' +
// ", result:" + result +
// ", message:'" + message + '\'' +
// '}';
// }
// }
| import com.team.zhuoke.masterhelper.api.NetWorkApi;
import com.team.zhuoke.masterhelper.model.test.TestList;
import com.team.zhuoke.masterhelper.net.response.HttpResponse;
import java.util.List;
import retrofit2.http.GET;
import rx.Observable; | package wq.gdy005.mvp;
/**
* Created by WangQing on 2016/12/7.
*/
public interface TestAPI3 {
@GET(NetWorkApi.getTestList) | // Path: app/src/main/java/com/team/zhuoke/masterhelper/api/NetWorkApi.java
// public class NetWorkApi {
//
// public static String baseUrl = "https://zkteam.wilddogio.com";
// // test
// public static final String getMasterList = "/master_list.json";
// public static final String getTestList = "/master_list.json";
//
// public static final String newBaseUrl = "http://www.zkteam.cc";
//
// public static final String masterInfo = newBaseUrl + "/api/jsonMasterInfo";
// public static final String masterArticle = "/api/jsonMasterArticle";
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/model/test/TestList.java
// public class TestList {
//
//
// /**
// * des : 生命不息,奋斗不止,万事起于忽微,量变引起质变
// * grade : 1
// * img : http://tva2.sinaimg.cn/crop.200.80.480.480.180/bca65a60gw1eiedwawzi2j20m80i57a7.jpg
// * info : http://blog.csdn.net/lmj623565791
// * isVip : true
// * name : hongyang
// * weiBo :
// * zhiHu :
// */
//
// private String des;
// private String grade;
// private String img;
// private String info;
// private boolean isVip;
// private String name;
// private String weiBo;
// private String zhiHu;
//
// public String getDes() {
// return des;
// }
//
// public void setDes(String des) {
// this.des = des;
// }
//
// public String getGrade() {
// return grade;
// }
//
// public void setGrade(String grade) {
// this.grade = grade;
// }
//
// public String getImg() {
// return img;
// }
//
// public void setImg(String img) {
// this.img = img;
// }
//
// public String getInfo() {
// return info;
// }
//
// public void setInfo(String info) {
// this.info = info;
// }
//
// public boolean isIsVip() {
// return isVip;
// }
//
// public void setIsVip(boolean isVip) {
// this.isVip = isVip;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getWeiBo() {
// return weiBo;
// }
//
// public void setWeiBo(String weiBo) {
// this.weiBo = weiBo;
// }
//
// public String getZhiHu() {
// return zhiHu;
// }
//
// public void setZhiHu(String zhiHu) {
// this.zhiHu = zhiHu;
// }
//
//
// // 修改模板,快速生成
// @Override
// public String toString() {
// return "{" +
// "des:'" + des + '\'' +
// ", grade:'" + grade + '\'' +
// ", img:'" + img + '\'' +
// ", info:'" + info + '\'' +
// ", isVip:" + isVip +
// ", name:'" + name + '\'' +
// ", weiBo:'" + weiBo + '\'' +
// ", zhiHu:'" + zhiHu + '\'' +
// '}';
// }
//
// // @Override
// // public String toString() {
// // return "MasterList{" +
// // "des='" + des + '\'' +
// // ", grade='" + grade + '\'' +
// // ", img='" + img + '\'' +
// // ", info='" + info + '\'' +
// // ", isVip=" + isVip +
// // ", name='" + name + '\'' +
// // ", weiBo='" + weiBo + '\'' +
// // ", zhiHu='" + zhiHu + '\'' +
// // '}';
// // }
//
// }
//
// Path: app/src/main/java/com/team/zhuoke/masterhelper/net/response/HttpResponse.java
// public class HttpResponse<T> {
//
// private String code ;
//
// private T result;
//
// private String message;
//
// public String getCode() {
// return code;
// }
//
// public void setCode(String code) {
// this.code = code;
// }
//
// public T getResult() {
// return result;
// }
//
// public void setResult(T result) {
// this.result = result;
// }
//
// public String getMessage() {
// return message;
// }
//
// public void setMessage(String message) {
// this.message = message;
// }
//
// @Override
// public String toString() {
// return "{" +
// "code:'" + code + '\'' +
// ", result:" + result +
// ", message:'" + message + '\'' +
// '}';
// }
// }
// Path: app/src/main/java/wq/gdy005/mvp/TestAPI3.java
import com.team.zhuoke.masterhelper.api.NetWorkApi;
import com.team.zhuoke.masterhelper.model.test.TestList;
import com.team.zhuoke.masterhelper.net.response.HttpResponse;
import java.util.List;
import retrofit2.http.GET;
import rx.Observable;
package wq.gdy005.mvp;
/**
* Created by WangQing on 2016/12/7.
*/
public interface TestAPI3 {
@GET(NetWorkApi.getTestList) | Observable<HttpResponse<List<TestList>>> getTestList(); |
indeedeng/status | status-core/src/main/java/com/indeed/status/core/CheckResult.java | // Path: status-core/src/main/java/com/indeed/status/core/DependencyChecker.java
// public static class CheckException extends Exception {
// private static final long serialVersionUID = -5161759492011453513L;
//
// private CheckException(final String message, final Throwable cause) {
// super(message, cause);
// }
//
// @SuppressWarnings({"UnusedDeclaration"})
// private CheckException(final Throwable cause) {
// super(cause);
// }
// }
| import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.google.common.base.Functions;
import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
import com.google.common.primitives.Longs;
import com.indeed.status.core.DependencyChecker.CheckException;
import javax.annotation.Nonnegative;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Set; | }
@Nonnegative
public long getPeriod() {
return period;
}
@Nullable
public Thrown getThrown() {
return null == throwable ? null : new Thrown(throwable);
}
@JsonIgnore
public Throwable getThrowable() {
return throwable;
}
@Nonnull
public String toString() {
return "{'id':'" + getId() + "';'status':'" + status + "';}";
}
@SuppressWarnings({"UnusedDeclaration"})
@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
public static class Thrown {
private static final int MAX_DEPTH = 20;
private static final int MAX_TRACE = 20;
public Thrown(@Nonnull final Throwable throwable) {
this( | // Path: status-core/src/main/java/com/indeed/status/core/DependencyChecker.java
// public static class CheckException extends Exception {
// private static final long serialVersionUID = -5161759492011453513L;
//
// private CheckException(final String message, final Throwable cause) {
// super(message, cause);
// }
//
// @SuppressWarnings({"UnusedDeclaration"})
// private CheckException(final Throwable cause) {
// super(cause);
// }
// }
// Path: status-core/src/main/java/com/indeed/status/core/CheckResult.java
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.google.common.base.Functions;
import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
import com.google.common.primitives.Longs;
import com.indeed.status.core.DependencyChecker.CheckException;
import javax.annotation.Nonnegative;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
}
@Nonnegative
public long getPeriod() {
return period;
}
@Nullable
public Thrown getThrown() {
return null == throwable ? null : new Thrown(throwable);
}
@JsonIgnore
public Throwable getThrowable() {
return throwable;
}
@Nonnull
public String toString() {
return "{'id':'" + getId() + "';'status':'" + status + "';}";
}
@SuppressWarnings({"UnusedDeclaration"})
@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
public static class Thrown {
private static final int MAX_DEPTH = 20;
private static final int MAX_TRACE = 20;
public Thrown(@Nonnull final Throwable throwable) {
this( | throwable instanceof CheckException ? throwable.getCause() : throwable, |
indeedeng/status | status-core/src/test/java/com/indeed/status/core/CheckResultSetTest.java | // Path: status-core/src/test/java/com/indeed/status/core/test/ControlledDependency.java
// public class ControlledDependency extends PingableDependency {
// public static final RuntimeException EXCEPTION = new RuntimeException("BAD");
// @Nonnull private final Supplier<Boolean> toggle;
// private boolean inError = true;
// private int times;
//
// private ControlledDependency(
// @Nonnull final Supplier<Boolean> toggle, @Nonnull final Urgency urgency) {
// super("controlled-id", "controlled-description", urgency);
// this.toggle = toggle;
// }
//
// public static final class TestDepControlledBuilder
// extends PingableDependencyBuilder<ControlledDependency, TestDepControlledBuilder> {
// private TestDepControlledBuilder() {}
//
// @Override
// public ControlledDependency build() {
// return new ControlledDependency(toggle, urgency != null ? urgency : Urgency.REQUIRED);
// }
// }
//
// public static ControlledDependency build() {
// return new TestDepControlledBuilder().build();
// }
//
// public static TestDepControlledBuilder builder() {
// return new TestDepControlledBuilder();
// }
//
// public void setInError(boolean toggle) {
// this.inError = toggle;
// }
//
// public int getTimes() {
// return times;
// }
//
// @Override
// public void ping() throws Exception {
// if (toggle.get()) {
// times++;
// if (inError) {
// throw EXCEPTION;
// }
// }
// }
// }
| import com.indeed.status.core.test.ControlledDependency;
import org.junit.Test;
import static com.indeed.status.core.CheckStatus.MAJOR;
import static com.indeed.status.core.CheckStatus.MINOR;
import static com.indeed.status.core.CheckStatus.OK;
import static com.indeed.status.core.CheckStatus.OUTAGE;
import static com.indeed.status.core.Urgency.NONE;
import static com.indeed.status.core.Urgency.REQUIRED;
import static com.indeed.status.core.Urgency.STRONG;
import static com.indeed.status.core.Urgency.WEAK;
import static org.junit.Assert.assertEquals; | assertDowngradeStatus(REQUIRED, OUTAGE, OUTAGE);
}
@Test
public void testStrong() throws Exception {
assertDowngradeStatus(STRONG, OK, OK);
assertDowngradeStatus(STRONG, MINOR, MINOR);
assertDowngradeStatus(STRONG, MAJOR, MAJOR);
assertDowngradeStatus(STRONG, OUTAGE, MAJOR);
}
@Test
public void testWeak() throws Exception {
assertDowngradeStatus(WEAK, OK, OK);
assertDowngradeStatus(WEAK, MINOR, MINOR);
assertDowngradeStatus(WEAK, MAJOR, MINOR);
assertDowngradeStatus(WEAK, OUTAGE, MINOR);
}
@Test
public void testNone() throws Exception {
assertDowngradeStatus(NONE, OK, OK);
assertDowngradeStatus(NONE, MINOR, OK);
assertDowngradeStatus(NONE, MAJOR, OK);
assertDowngradeStatus(NONE, OUTAGE, OK);
}
private void assertDowngradeStatus(
Urgency depUrgency, CheckStatus checkStatus, CheckStatus sysStatus) {
final CheckResultSet set = CheckResultSet.newInstance(); | // Path: status-core/src/test/java/com/indeed/status/core/test/ControlledDependency.java
// public class ControlledDependency extends PingableDependency {
// public static final RuntimeException EXCEPTION = new RuntimeException("BAD");
// @Nonnull private final Supplier<Boolean> toggle;
// private boolean inError = true;
// private int times;
//
// private ControlledDependency(
// @Nonnull final Supplier<Boolean> toggle, @Nonnull final Urgency urgency) {
// super("controlled-id", "controlled-description", urgency);
// this.toggle = toggle;
// }
//
// public static final class TestDepControlledBuilder
// extends PingableDependencyBuilder<ControlledDependency, TestDepControlledBuilder> {
// private TestDepControlledBuilder() {}
//
// @Override
// public ControlledDependency build() {
// return new ControlledDependency(toggle, urgency != null ? urgency : Urgency.REQUIRED);
// }
// }
//
// public static ControlledDependency build() {
// return new TestDepControlledBuilder().build();
// }
//
// public static TestDepControlledBuilder builder() {
// return new TestDepControlledBuilder();
// }
//
// public void setInError(boolean toggle) {
// this.inError = toggle;
// }
//
// public int getTimes() {
// return times;
// }
//
// @Override
// public void ping() throws Exception {
// if (toggle.get()) {
// times++;
// if (inError) {
// throw EXCEPTION;
// }
// }
// }
// }
// Path: status-core/src/test/java/com/indeed/status/core/CheckResultSetTest.java
import com.indeed.status.core.test.ControlledDependency;
import org.junit.Test;
import static com.indeed.status.core.CheckStatus.MAJOR;
import static com.indeed.status.core.CheckStatus.MINOR;
import static com.indeed.status.core.CheckStatus.OK;
import static com.indeed.status.core.CheckStatus.OUTAGE;
import static com.indeed.status.core.Urgency.NONE;
import static com.indeed.status.core.Urgency.REQUIRED;
import static com.indeed.status.core.Urgency.STRONG;
import static com.indeed.status.core.Urgency.WEAK;
import static org.junit.Assert.assertEquals;
assertDowngradeStatus(REQUIRED, OUTAGE, OUTAGE);
}
@Test
public void testStrong() throws Exception {
assertDowngradeStatus(STRONG, OK, OK);
assertDowngradeStatus(STRONG, MINOR, MINOR);
assertDowngradeStatus(STRONG, MAJOR, MAJOR);
assertDowngradeStatus(STRONG, OUTAGE, MAJOR);
}
@Test
public void testWeak() throws Exception {
assertDowngradeStatus(WEAK, OK, OK);
assertDowngradeStatus(WEAK, MINOR, MINOR);
assertDowngradeStatus(WEAK, MAJOR, MINOR);
assertDowngradeStatus(WEAK, OUTAGE, MINOR);
}
@Test
public void testNone() throws Exception {
assertDowngradeStatus(NONE, OK, OK);
assertDowngradeStatus(NONE, MINOR, OK);
assertDowngradeStatus(NONE, MAJOR, OK);
assertDowngradeStatus(NONE, OUTAGE, OK);
}
private void assertDowngradeStatus(
Urgency depUrgency, CheckStatus checkStatus, CheckStatus sysStatus) {
final CheckResultSet set = CheckResultSet.newInstance(); | final ControlledDependency dep = |
searchisko/elasticsearch-river-jira | src/test/java/org/jboss/elasticsearch/river/jira/mgm/fullupdate/TransportFullUpdateActionTest.java | // Path: src/main/java/org/jboss/elasticsearch/river/jira/IJiraRiverMgm.java
// public interface IJiraRiverMgm {
//
// /**
// * Stop jira river, but leave instance existing in {@link #riverInstances} so it can be found over management REST
// * calls and/or reconfigured and started later again. Note that standard ES river {@link #close()} method
// * implementation removes river instance from {@link #riverInstances}.
// *
// * @param permanent set to true if info about river stopped can be persisted
// */
// public abstract void stop(boolean permanent);
//
// /**
// * Restart jira river. Configuration of river is updated.
// */
// public abstract void restart();
//
// /**
// * Force full index update for some project(s) in this jira river. Used for REST management operations handling.
// *
// * @param jiraProjectKey optional key of project to reindex, if null or empty then all projects are forced to full
// * reindex
// * @return CSV list of projects forced to reindex. <code>null</code> if project passed over
// * <code>jiraProjectKey</code> parameter was not found in this indexer
// * @throws Exception
// */
// public abstract String forceFullReindex(String jiraProjectKey) throws Exception;
//
// /**
// * Force incremental index update for some project(s) in this jira river. Used for REST management operations
// * handling.
// *
// * @param jiraProjectKey optional key of project to reindex, if null or empty then all projects are forced to reindex
// * @return CSV list of projects forced to reindex. <code>null</code> if project passed over
// * <code>jiraProjectKey</code> parameter was not found in this indexer
// * @throws Exception
// */
// public abstract String forceIncrementalReindex(String jiraProjectKey) throws Exception;
//
// /**
// * Get info about current operation of this river. Used for REST management operations handling.
// *
// * @return String with JSON formatted info.
// * @throws Exception
// */
// public abstract String getRiverOperationInfo(DiscoveryNode esNode, Date currentDate) throws Exception;
//
// /**
// * Get name of river.
// *
// * @return name of jira river
// */
// public abstract RiverName riverName();
//
// }
| import junit.framework.Assert;
import org.elasticsearch.Version;
import org.elasticsearch.action.support.ActionFilters;
import org.elasticsearch.cluster.ClusterName;
import org.elasticsearch.cluster.ClusterService;
import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.transport.DummyTransportAddress;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.transport.Transport;
import org.elasticsearch.transport.TransportService;
import org.jboss.elasticsearch.river.jira.IJiraRiverMgm;
import org.junit.Test;
import org.mockito.Mockito; | NodeFullUpdateResponse resp = tested.newNodeResponse();
Assert.assertNotNull(resp);
Assert.assertEquals(dn, resp.getNode());
}
@Test
public void newNodeResponseArray() {
TransportFullUpdateAction tested = prepareTestedInstance(clusterName);
NodeFullUpdateResponse[] array = tested.newNodeResponseArray(2);
Assert.assertNotNull(array);
Assert.assertEquals(2, array.length);
}
@Test
public void newResponse() {
TransportFullUpdateAction tested = prepareTestedInstance(clusterName);
NodeFullUpdateResponse[] array = new NodeFullUpdateResponse[0];
FullUpdateResponse resp = tested.newResponse(clusterName, array);
Assert.assertNotNull(resp);
Assert.assertEquals(resp.getClusterName(), clusterName);
Assert.assertEquals(resp.getNodes(), array);
}
@Test
public void performOperationOnJiraRiver() throws Exception {
TransportFullUpdateAction tested = prepareTestedInstance(clusterName);
| // Path: src/main/java/org/jboss/elasticsearch/river/jira/IJiraRiverMgm.java
// public interface IJiraRiverMgm {
//
// /**
// * Stop jira river, but leave instance existing in {@link #riverInstances} so it can be found over management REST
// * calls and/or reconfigured and started later again. Note that standard ES river {@link #close()} method
// * implementation removes river instance from {@link #riverInstances}.
// *
// * @param permanent set to true if info about river stopped can be persisted
// */
// public abstract void stop(boolean permanent);
//
// /**
// * Restart jira river. Configuration of river is updated.
// */
// public abstract void restart();
//
// /**
// * Force full index update for some project(s) in this jira river. Used for REST management operations handling.
// *
// * @param jiraProjectKey optional key of project to reindex, if null or empty then all projects are forced to full
// * reindex
// * @return CSV list of projects forced to reindex. <code>null</code> if project passed over
// * <code>jiraProjectKey</code> parameter was not found in this indexer
// * @throws Exception
// */
// public abstract String forceFullReindex(String jiraProjectKey) throws Exception;
//
// /**
// * Force incremental index update for some project(s) in this jira river. Used for REST management operations
// * handling.
// *
// * @param jiraProjectKey optional key of project to reindex, if null or empty then all projects are forced to reindex
// * @return CSV list of projects forced to reindex. <code>null</code> if project passed over
// * <code>jiraProjectKey</code> parameter was not found in this indexer
// * @throws Exception
// */
// public abstract String forceIncrementalReindex(String jiraProjectKey) throws Exception;
//
// /**
// * Get info about current operation of this river. Used for REST management operations handling.
// *
// * @return String with JSON formatted info.
// * @throws Exception
// */
// public abstract String getRiverOperationInfo(DiscoveryNode esNode, Date currentDate) throws Exception;
//
// /**
// * Get name of river.
// *
// * @return name of jira river
// */
// public abstract RiverName riverName();
//
// }
// Path: src/test/java/org/jboss/elasticsearch/river/jira/mgm/fullupdate/TransportFullUpdateActionTest.java
import junit.framework.Assert;
import org.elasticsearch.Version;
import org.elasticsearch.action.support.ActionFilters;
import org.elasticsearch.cluster.ClusterName;
import org.elasticsearch.cluster.ClusterService;
import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.transport.DummyTransportAddress;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.transport.Transport;
import org.elasticsearch.transport.TransportService;
import org.jboss.elasticsearch.river.jira.IJiraRiverMgm;
import org.junit.Test;
import org.mockito.Mockito;
NodeFullUpdateResponse resp = tested.newNodeResponse();
Assert.assertNotNull(resp);
Assert.assertEquals(dn, resp.getNode());
}
@Test
public void newNodeResponseArray() {
TransportFullUpdateAction tested = prepareTestedInstance(clusterName);
NodeFullUpdateResponse[] array = tested.newNodeResponseArray(2);
Assert.assertNotNull(array);
Assert.assertEquals(2, array.length);
}
@Test
public void newResponse() {
TransportFullUpdateAction tested = prepareTestedInstance(clusterName);
NodeFullUpdateResponse[] array = new NodeFullUpdateResponse[0];
FullUpdateResponse resp = tested.newResponse(clusterName, array);
Assert.assertNotNull(resp);
Assert.assertEquals(resp.getClusterName(), clusterName);
Assert.assertEquals(resp.getNodes(), array);
}
@Test
public void performOperationOnJiraRiver() throws Exception {
TransportFullUpdateAction tested = prepareTestedInstance(clusterName);
| IJiraRiverMgm river = Mockito.mock(IJiraRiverMgm.class); |
searchisko/elasticsearch-river-jira | src/main/java/org/jboss/elasticsearch/river/jira/mgm/state/RestJRStateAction.java | // Path: src/main/java/org/jboss/elasticsearch/river/jira/mgm/JRMgmBaseActionListener.java
// public abstract class JRMgmBaseActionListener<Request extends JRMgmBaseRequest<?>, Response extends JRMgmBaseResponse<NodeResponse>, NodeResponse extends NodeJRMgmBaseResponse>
// implements ActionListener<Response> {
//
// protected final ESLogger logger;
//
// protected final RestRequest restRequest;
// protected final RestChannel restChannel;
// protected final Request actionRequest;
//
// /**
// * Create new action listener.
// *
// * @param actionRequest this listener process result for
// * @param restRequest we handle
// * @param restChannel to write rest response into
// */
// public JRMgmBaseActionListener(Request actionRequest, RestRequest restRequest, RestChannel restChannel) {
// super();
// this.restRequest = restRequest;
// this.restChannel = restChannel;
// this.actionRequest = actionRequest;
// logger = Loggers.getLogger(getClass());
// }
//
// @Override
// public void onResponse(Response response) {
// try {
// NodeResponse nodeInfo = response.getSuccessNodeResponse();
// if (nodeInfo == null) {
// restChannel.sendResponse(new BytesRestResponse(RestStatus.NOT_FOUND, buildMessageDocument(restRequest,
// "No JiraRiver found for name: " + actionRequest.getRiverName())));
// } else {
// handleJiraRiverResponse(nodeInfo);
// }
// } catch (Exception e) {
// onFailure(e);
// }
// }
//
// /**
// * Implement this in subclasses to handle response from jira river and return REST response based on it.
// *
// * @param nodeInfo operation response from node with jira river, never null
// * @throws Exception if something is wrong
// */
// protected abstract void handleJiraRiverResponse(NodeResponse nodeInfo) throws Exception;
//
// @Override
// public void onFailure(Throwable e) {
// try {
// restChannel.sendResponse(new BytesRestResponse(restChannel, e));
// } catch (IOException e1) {
// logger.error("Failed to send failure response", e1);
// }
// }
//
// /**
// * Build response document with only one field called <code>message</code>. You can use this in
// * {@link #handleJiraRiverResponse(NodeJRMgmBaseResponse)} implementation if you only need to return simple message.
// *
// * @param restRequest to build response document for
// * @param message to be placed in document
// * @return document with message
// * @throws IOException
// */
// public static XContentBuilder buildMessageDocument(RestRequest restRequest, String message) throws IOException {
// XContentBuilder builder = RestXContentBuilder.restContentBuilder(restRequest);
// builder.startObject();
// builder.field("message", message);
// builder.endObject();
// return builder;
// }
//
// }
//
// Path: src/main/java/org/jboss/elasticsearch/river/jira/mgm/RestJRMgmBaseAction.java
// public abstract class RestJRMgmBaseAction extends BaseRestHandler {
//
// protected RestJRMgmBaseAction(Settings settings, RestController controller, Client client) {
// super(settings, controller, client);
// }
//
// /**
// * Prepare base REST URL for JIRA river management operations. <code>riverName</code> request parameter is defined
// * here.
// *
// * @return base REST management url ending by <code>/</code>
// */
// protected String baseRestMgmUrl() {
// return "/" + RiverIndexName.Conf.indexName(settings) + "/{riverName}/_mgm_jr/";
// }
//
// }
| import org.elasticsearch.client.Client;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.XContentType;
import org.elasticsearch.rest.BytesRestResponse;
import org.elasticsearch.rest.RestChannel;
import org.elasticsearch.rest.RestController;
import org.elasticsearch.rest.RestRequest;
import org.elasticsearch.rest.RestStatus;
import org.jboss.elasticsearch.river.jira.mgm.JRMgmBaseActionListener;
import org.jboss.elasticsearch.river.jira.mgm.RestJRMgmBaseAction; | /*
* JBoss, Home of Professional Open Source
* Copyright 2012 Red Hat Inc. and/or its affiliates and other contributors
* as indicated by the @authors tag. All rights reserved.
*/
package org.jboss.elasticsearch.river.jira.mgm.state;
/**
* REST action handler for Jira river get state operation.
*
* @author Vlastimil Elias (velias at redhat dot com)
*/
public class RestJRStateAction extends RestJRMgmBaseAction {
@Inject
protected RestJRStateAction(Settings settings, Client client, RestController controller) {
super(settings, controller, client);
String baseUrl = baseRestMgmUrl();
controller.registerHandler(org.elasticsearch.rest.RestRequest.Method.GET, baseUrl + "state", this);
}
@Override
public void handleRequest(final RestRequest restRequest, final RestChannel restChannel, Client client) {
JRStateRequest actionRequest = new JRStateRequest(restRequest.param("riverName"));
client
.admin()
.cluster()
.execute(
JRStateAction.INSTANCE,
actionRequest, | // Path: src/main/java/org/jboss/elasticsearch/river/jira/mgm/JRMgmBaseActionListener.java
// public abstract class JRMgmBaseActionListener<Request extends JRMgmBaseRequest<?>, Response extends JRMgmBaseResponse<NodeResponse>, NodeResponse extends NodeJRMgmBaseResponse>
// implements ActionListener<Response> {
//
// protected final ESLogger logger;
//
// protected final RestRequest restRequest;
// protected final RestChannel restChannel;
// protected final Request actionRequest;
//
// /**
// * Create new action listener.
// *
// * @param actionRequest this listener process result for
// * @param restRequest we handle
// * @param restChannel to write rest response into
// */
// public JRMgmBaseActionListener(Request actionRequest, RestRequest restRequest, RestChannel restChannel) {
// super();
// this.restRequest = restRequest;
// this.restChannel = restChannel;
// this.actionRequest = actionRequest;
// logger = Loggers.getLogger(getClass());
// }
//
// @Override
// public void onResponse(Response response) {
// try {
// NodeResponse nodeInfo = response.getSuccessNodeResponse();
// if (nodeInfo == null) {
// restChannel.sendResponse(new BytesRestResponse(RestStatus.NOT_FOUND, buildMessageDocument(restRequest,
// "No JiraRiver found for name: " + actionRequest.getRiverName())));
// } else {
// handleJiraRiverResponse(nodeInfo);
// }
// } catch (Exception e) {
// onFailure(e);
// }
// }
//
// /**
// * Implement this in subclasses to handle response from jira river and return REST response based on it.
// *
// * @param nodeInfo operation response from node with jira river, never null
// * @throws Exception if something is wrong
// */
// protected abstract void handleJiraRiverResponse(NodeResponse nodeInfo) throws Exception;
//
// @Override
// public void onFailure(Throwable e) {
// try {
// restChannel.sendResponse(new BytesRestResponse(restChannel, e));
// } catch (IOException e1) {
// logger.error("Failed to send failure response", e1);
// }
// }
//
// /**
// * Build response document with only one field called <code>message</code>. You can use this in
// * {@link #handleJiraRiverResponse(NodeJRMgmBaseResponse)} implementation if you only need to return simple message.
// *
// * @param restRequest to build response document for
// * @param message to be placed in document
// * @return document with message
// * @throws IOException
// */
// public static XContentBuilder buildMessageDocument(RestRequest restRequest, String message) throws IOException {
// XContentBuilder builder = RestXContentBuilder.restContentBuilder(restRequest);
// builder.startObject();
// builder.field("message", message);
// builder.endObject();
// return builder;
// }
//
// }
//
// Path: src/main/java/org/jboss/elasticsearch/river/jira/mgm/RestJRMgmBaseAction.java
// public abstract class RestJRMgmBaseAction extends BaseRestHandler {
//
// protected RestJRMgmBaseAction(Settings settings, RestController controller, Client client) {
// super(settings, controller, client);
// }
//
// /**
// * Prepare base REST URL for JIRA river management operations. <code>riverName</code> request parameter is defined
// * here.
// *
// * @return base REST management url ending by <code>/</code>
// */
// protected String baseRestMgmUrl() {
// return "/" + RiverIndexName.Conf.indexName(settings) + "/{riverName}/_mgm_jr/";
// }
//
// }
// Path: src/main/java/org/jboss/elasticsearch/river/jira/mgm/state/RestJRStateAction.java
import org.elasticsearch.client.Client;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.XContentType;
import org.elasticsearch.rest.BytesRestResponse;
import org.elasticsearch.rest.RestChannel;
import org.elasticsearch.rest.RestController;
import org.elasticsearch.rest.RestRequest;
import org.elasticsearch.rest.RestStatus;
import org.jboss.elasticsearch.river.jira.mgm.JRMgmBaseActionListener;
import org.jboss.elasticsearch.river.jira.mgm.RestJRMgmBaseAction;
/*
* JBoss, Home of Professional Open Source
* Copyright 2012 Red Hat Inc. and/or its affiliates and other contributors
* as indicated by the @authors tag. All rights reserved.
*/
package org.jboss.elasticsearch.river.jira.mgm.state;
/**
* REST action handler for Jira river get state operation.
*
* @author Vlastimil Elias (velias at redhat dot com)
*/
public class RestJRStateAction extends RestJRMgmBaseAction {
@Inject
protected RestJRStateAction(Settings settings, Client client, RestController controller) {
super(settings, controller, client);
String baseUrl = baseRestMgmUrl();
controller.registerHandler(org.elasticsearch.rest.RestRequest.Method.GET, baseUrl + "state", this);
}
@Override
public void handleRequest(final RestRequest restRequest, final RestChannel restChannel, Client client) {
JRStateRequest actionRequest = new JRStateRequest(restRequest.param("riverName"));
client
.admin()
.cluster()
.execute(
JRStateAction.INSTANCE,
actionRequest, | new JRMgmBaseActionListener<JRStateRequest, JRStateResponse, NodeJRStateResponse>(actionRequest, |
searchisko/elasticsearch-river-jira | src/main/java/org/jboss/elasticsearch/river/jira/mgm/lifecycle/RestJRLifecycleAction.java | // Path: src/main/java/org/jboss/elasticsearch/river/jira/mgm/JRMgmBaseActionListener.java
// public abstract class JRMgmBaseActionListener<Request extends JRMgmBaseRequest<?>, Response extends JRMgmBaseResponse<NodeResponse>, NodeResponse extends NodeJRMgmBaseResponse>
// implements ActionListener<Response> {
//
// protected final ESLogger logger;
//
// protected final RestRequest restRequest;
// protected final RestChannel restChannel;
// protected final Request actionRequest;
//
// /**
// * Create new action listener.
// *
// * @param actionRequest this listener process result for
// * @param restRequest we handle
// * @param restChannel to write rest response into
// */
// public JRMgmBaseActionListener(Request actionRequest, RestRequest restRequest, RestChannel restChannel) {
// super();
// this.restRequest = restRequest;
// this.restChannel = restChannel;
// this.actionRequest = actionRequest;
// logger = Loggers.getLogger(getClass());
// }
//
// @Override
// public void onResponse(Response response) {
// try {
// NodeResponse nodeInfo = response.getSuccessNodeResponse();
// if (nodeInfo == null) {
// restChannel.sendResponse(new BytesRestResponse(RestStatus.NOT_FOUND, buildMessageDocument(restRequest,
// "No JiraRiver found for name: " + actionRequest.getRiverName())));
// } else {
// handleJiraRiverResponse(nodeInfo);
// }
// } catch (Exception e) {
// onFailure(e);
// }
// }
//
// /**
// * Implement this in subclasses to handle response from jira river and return REST response based on it.
// *
// * @param nodeInfo operation response from node with jira river, never null
// * @throws Exception if something is wrong
// */
// protected abstract void handleJiraRiverResponse(NodeResponse nodeInfo) throws Exception;
//
// @Override
// public void onFailure(Throwable e) {
// try {
// restChannel.sendResponse(new BytesRestResponse(restChannel, e));
// } catch (IOException e1) {
// logger.error("Failed to send failure response", e1);
// }
// }
//
// /**
// * Build response document with only one field called <code>message</code>. You can use this in
// * {@link #handleJiraRiverResponse(NodeJRMgmBaseResponse)} implementation if you only need to return simple message.
// *
// * @param restRequest to build response document for
// * @param message to be placed in document
// * @return document with message
// * @throws IOException
// */
// public static XContentBuilder buildMessageDocument(RestRequest restRequest, String message) throws IOException {
// XContentBuilder builder = RestXContentBuilder.restContentBuilder(restRequest);
// builder.startObject();
// builder.field("message", message);
// builder.endObject();
// return builder;
// }
//
// }
//
// Path: src/main/java/org/jboss/elasticsearch/river/jira/mgm/RestJRMgmBaseAction.java
// public abstract class RestJRMgmBaseAction extends BaseRestHandler {
//
// protected RestJRMgmBaseAction(Settings settings, RestController controller, Client client) {
// super(settings, controller, client);
// }
//
// /**
// * Prepare base REST URL for JIRA river management operations. <code>riverName</code> request parameter is defined
// * here.
// *
// * @return base REST management url ending by <code>/</code>
// */
// protected String baseRestMgmUrl() {
// return "/" + RiverIndexName.Conf.indexName(settings) + "/{riverName}/_mgm_jr/";
// }
//
// }
| import org.elasticsearch.client.Client;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.rest.BytesRestResponse;
import org.elasticsearch.rest.RestChannel;
import org.elasticsearch.rest.RestController;
import org.elasticsearch.rest.RestRequest;
import org.jboss.elasticsearch.river.jira.mgm.JRMgmBaseActionListener;
import org.jboss.elasticsearch.river.jira.mgm.RestJRMgmBaseAction;
import static org.elasticsearch.rest.RestStatus.OK; | /*
* JBoss, Home of Professional Open Source
* Copyright 2012 Red Hat Inc. and/or its affiliates and other contributors
* as indicated by the @authors tag. All rights reserved.
*/
package org.jboss.elasticsearch.river.jira.mgm.lifecycle;
/**
* REST action handler for Jira river get state operation.
*
* @author Vlastimil Elias (velias at redhat dot com)
*/
public class RestJRLifecycleAction extends RestJRMgmBaseAction {
@Inject
protected RestJRLifecycleAction(Settings settings, Client client, RestController controller) {
super(settings, controller, client);
String baseUrl = baseRestMgmUrl();
controller.registerHandler(org.elasticsearch.rest.RestRequest.Method.POST, baseUrl + "stop", this);
controller.registerHandler(org.elasticsearch.rest.RestRequest.Method.POST, baseUrl + "restart", this);
}
@Override
public void handleRequest(final RestRequest restRequest, final RestChannel restChannel, Client client) {
JRLifecycleCommand command = JRLifecycleCommand.RESTART;
if (restRequest.path().endsWith("stop"))
command = JRLifecycleCommand.STOP;
JRLifecycleRequest actionRequest = new JRLifecycleRequest(restRequest.param("riverName"), command);
client
.admin()
.cluster()
.execute(
JRLifecycleAction.INSTANCE,
actionRequest, | // Path: src/main/java/org/jboss/elasticsearch/river/jira/mgm/JRMgmBaseActionListener.java
// public abstract class JRMgmBaseActionListener<Request extends JRMgmBaseRequest<?>, Response extends JRMgmBaseResponse<NodeResponse>, NodeResponse extends NodeJRMgmBaseResponse>
// implements ActionListener<Response> {
//
// protected final ESLogger logger;
//
// protected final RestRequest restRequest;
// protected final RestChannel restChannel;
// protected final Request actionRequest;
//
// /**
// * Create new action listener.
// *
// * @param actionRequest this listener process result for
// * @param restRequest we handle
// * @param restChannel to write rest response into
// */
// public JRMgmBaseActionListener(Request actionRequest, RestRequest restRequest, RestChannel restChannel) {
// super();
// this.restRequest = restRequest;
// this.restChannel = restChannel;
// this.actionRequest = actionRequest;
// logger = Loggers.getLogger(getClass());
// }
//
// @Override
// public void onResponse(Response response) {
// try {
// NodeResponse nodeInfo = response.getSuccessNodeResponse();
// if (nodeInfo == null) {
// restChannel.sendResponse(new BytesRestResponse(RestStatus.NOT_FOUND, buildMessageDocument(restRequest,
// "No JiraRiver found for name: " + actionRequest.getRiverName())));
// } else {
// handleJiraRiverResponse(nodeInfo);
// }
// } catch (Exception e) {
// onFailure(e);
// }
// }
//
// /**
// * Implement this in subclasses to handle response from jira river and return REST response based on it.
// *
// * @param nodeInfo operation response from node with jira river, never null
// * @throws Exception if something is wrong
// */
// protected abstract void handleJiraRiverResponse(NodeResponse nodeInfo) throws Exception;
//
// @Override
// public void onFailure(Throwable e) {
// try {
// restChannel.sendResponse(new BytesRestResponse(restChannel, e));
// } catch (IOException e1) {
// logger.error("Failed to send failure response", e1);
// }
// }
//
// /**
// * Build response document with only one field called <code>message</code>. You can use this in
// * {@link #handleJiraRiverResponse(NodeJRMgmBaseResponse)} implementation if you only need to return simple message.
// *
// * @param restRequest to build response document for
// * @param message to be placed in document
// * @return document with message
// * @throws IOException
// */
// public static XContentBuilder buildMessageDocument(RestRequest restRequest, String message) throws IOException {
// XContentBuilder builder = RestXContentBuilder.restContentBuilder(restRequest);
// builder.startObject();
// builder.field("message", message);
// builder.endObject();
// return builder;
// }
//
// }
//
// Path: src/main/java/org/jboss/elasticsearch/river/jira/mgm/RestJRMgmBaseAction.java
// public abstract class RestJRMgmBaseAction extends BaseRestHandler {
//
// protected RestJRMgmBaseAction(Settings settings, RestController controller, Client client) {
// super(settings, controller, client);
// }
//
// /**
// * Prepare base REST URL for JIRA river management operations. <code>riverName</code> request parameter is defined
// * here.
// *
// * @return base REST management url ending by <code>/</code>
// */
// protected String baseRestMgmUrl() {
// return "/" + RiverIndexName.Conf.indexName(settings) + "/{riverName}/_mgm_jr/";
// }
//
// }
// Path: src/main/java/org/jboss/elasticsearch/river/jira/mgm/lifecycle/RestJRLifecycleAction.java
import org.elasticsearch.client.Client;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.rest.BytesRestResponse;
import org.elasticsearch.rest.RestChannel;
import org.elasticsearch.rest.RestController;
import org.elasticsearch.rest.RestRequest;
import org.jboss.elasticsearch.river.jira.mgm.JRMgmBaseActionListener;
import org.jboss.elasticsearch.river.jira.mgm.RestJRMgmBaseAction;
import static org.elasticsearch.rest.RestStatus.OK;
/*
* JBoss, Home of Professional Open Source
* Copyright 2012 Red Hat Inc. and/or its affiliates and other contributors
* as indicated by the @authors tag. All rights reserved.
*/
package org.jboss.elasticsearch.river.jira.mgm.lifecycle;
/**
* REST action handler for Jira river get state operation.
*
* @author Vlastimil Elias (velias at redhat dot com)
*/
public class RestJRLifecycleAction extends RestJRMgmBaseAction {
@Inject
protected RestJRLifecycleAction(Settings settings, Client client, RestController controller) {
super(settings, controller, client);
String baseUrl = baseRestMgmUrl();
controller.registerHandler(org.elasticsearch.rest.RestRequest.Method.POST, baseUrl + "stop", this);
controller.registerHandler(org.elasticsearch.rest.RestRequest.Method.POST, baseUrl + "restart", this);
}
@Override
public void handleRequest(final RestRequest restRequest, final RestChannel restChannel, Client client) {
JRLifecycleCommand command = JRLifecycleCommand.RESTART;
if (restRequest.path().endsWith("stop"))
command = JRLifecycleCommand.STOP;
JRLifecycleRequest actionRequest = new JRLifecycleRequest(restRequest.param("riverName"), command);
client
.admin()
.cluster()
.execute(
JRLifecycleAction.INSTANCE,
actionRequest, | new JRMgmBaseActionListener<JRLifecycleRequest, JRLifecycleResponse, NodeJRLifecycleResponse>( |
searchisko/elasticsearch-river-jira | src/main/java/org/jboss/elasticsearch/river/jira/mgm/fullupdate/RestFullUpdateAction.java | // Path: src/main/java/org/jboss/elasticsearch/river/jira/mgm/JRMgmBaseActionListener.java
// public abstract class JRMgmBaseActionListener<Request extends JRMgmBaseRequest<?>, Response extends JRMgmBaseResponse<NodeResponse>, NodeResponse extends NodeJRMgmBaseResponse>
// implements ActionListener<Response> {
//
// protected final ESLogger logger;
//
// protected final RestRequest restRequest;
// protected final RestChannel restChannel;
// protected final Request actionRequest;
//
// /**
// * Create new action listener.
// *
// * @param actionRequest this listener process result for
// * @param restRequest we handle
// * @param restChannel to write rest response into
// */
// public JRMgmBaseActionListener(Request actionRequest, RestRequest restRequest, RestChannel restChannel) {
// super();
// this.restRequest = restRequest;
// this.restChannel = restChannel;
// this.actionRequest = actionRequest;
// logger = Loggers.getLogger(getClass());
// }
//
// @Override
// public void onResponse(Response response) {
// try {
// NodeResponse nodeInfo = response.getSuccessNodeResponse();
// if (nodeInfo == null) {
// restChannel.sendResponse(new BytesRestResponse(RestStatus.NOT_FOUND, buildMessageDocument(restRequest,
// "No JiraRiver found for name: " + actionRequest.getRiverName())));
// } else {
// handleJiraRiverResponse(nodeInfo);
// }
// } catch (Exception e) {
// onFailure(e);
// }
// }
//
// /**
// * Implement this in subclasses to handle response from jira river and return REST response based on it.
// *
// * @param nodeInfo operation response from node with jira river, never null
// * @throws Exception if something is wrong
// */
// protected abstract void handleJiraRiverResponse(NodeResponse nodeInfo) throws Exception;
//
// @Override
// public void onFailure(Throwable e) {
// try {
// restChannel.sendResponse(new BytesRestResponse(restChannel, e));
// } catch (IOException e1) {
// logger.error("Failed to send failure response", e1);
// }
// }
//
// /**
// * Build response document with only one field called <code>message</code>. You can use this in
// * {@link #handleJiraRiverResponse(NodeJRMgmBaseResponse)} implementation if you only need to return simple message.
// *
// * @param restRequest to build response document for
// * @param message to be placed in document
// * @return document with message
// * @throws IOException
// */
// public static XContentBuilder buildMessageDocument(RestRequest restRequest, String message) throws IOException {
// XContentBuilder builder = RestXContentBuilder.restContentBuilder(restRequest);
// builder.startObject();
// builder.field("message", message);
// builder.endObject();
// return builder;
// }
//
// }
//
// Path: src/main/java/org/jboss/elasticsearch/river/jira/mgm/RestJRMgmBaseAction.java
// public abstract class RestJRMgmBaseAction extends BaseRestHandler {
//
// protected RestJRMgmBaseAction(Settings settings, RestController controller, Client client) {
// super(settings, controller, client);
// }
//
// /**
// * Prepare base REST URL for JIRA river management operations. <code>riverName</code> request parameter is defined
// * here.
// *
// * @return base REST management url ending by <code>/</code>
// */
// protected String baseRestMgmUrl() {
// return "/" + RiverIndexName.Conf.indexName(settings) + "/{riverName}/_mgm_jr/";
// }
//
// }
| import org.elasticsearch.client.Client;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.rest.BytesRestResponse;
import org.elasticsearch.rest.RestChannel;
import org.elasticsearch.rest.RestController;
import org.elasticsearch.rest.RestRequest;
import org.elasticsearch.rest.RestStatus;
import org.jboss.elasticsearch.river.jira.mgm.JRMgmBaseActionListener;
import org.jboss.elasticsearch.river.jira.mgm.RestJRMgmBaseAction;
import static org.elasticsearch.rest.RestStatus.OK; | /*
* JBoss, Home of Professional Open Source
* Copyright 2012 Red Hat Inc. and/or its affiliates and other contributors
* as indicated by the @authors tag. All rights reserved.
*/
package org.jboss.elasticsearch.river.jira.mgm.fullupdate;
/**
* REST action handler for force full index update operation.
*
* @author Vlastimil Elias (velias at redhat dot com)
*/
public class RestFullUpdateAction extends RestJRMgmBaseAction {
@Inject
protected RestFullUpdateAction(Settings settings, Client client, RestController controller) {
super(settings, controller, client);
String baseUrl = baseRestMgmUrl();
controller.registerHandler(org.elasticsearch.rest.RestRequest.Method.POST, baseUrl + "fullupdate", this);
controller.registerHandler(org.elasticsearch.rest.RestRequest.Method.POST, baseUrl + "fullupdate/{projectKey}",
this);
}
@Override
public void handleRequest(final RestRequest restRequest, final RestChannel restChannel, Client client) {
final String riverName = restRequest.param("riverName");
final String projectKey = restRequest.param("projectKey");
FullUpdateRequest actionRequest = new FullUpdateRequest(riverName, projectKey);
client
.admin()
.cluster()
.execute(
FullUpdateAction.INSTANCE,
actionRequest, | // Path: src/main/java/org/jboss/elasticsearch/river/jira/mgm/JRMgmBaseActionListener.java
// public abstract class JRMgmBaseActionListener<Request extends JRMgmBaseRequest<?>, Response extends JRMgmBaseResponse<NodeResponse>, NodeResponse extends NodeJRMgmBaseResponse>
// implements ActionListener<Response> {
//
// protected final ESLogger logger;
//
// protected final RestRequest restRequest;
// protected final RestChannel restChannel;
// protected final Request actionRequest;
//
// /**
// * Create new action listener.
// *
// * @param actionRequest this listener process result for
// * @param restRequest we handle
// * @param restChannel to write rest response into
// */
// public JRMgmBaseActionListener(Request actionRequest, RestRequest restRequest, RestChannel restChannel) {
// super();
// this.restRequest = restRequest;
// this.restChannel = restChannel;
// this.actionRequest = actionRequest;
// logger = Loggers.getLogger(getClass());
// }
//
// @Override
// public void onResponse(Response response) {
// try {
// NodeResponse nodeInfo = response.getSuccessNodeResponse();
// if (nodeInfo == null) {
// restChannel.sendResponse(new BytesRestResponse(RestStatus.NOT_FOUND, buildMessageDocument(restRequest,
// "No JiraRiver found for name: " + actionRequest.getRiverName())));
// } else {
// handleJiraRiverResponse(nodeInfo);
// }
// } catch (Exception e) {
// onFailure(e);
// }
// }
//
// /**
// * Implement this in subclasses to handle response from jira river and return REST response based on it.
// *
// * @param nodeInfo operation response from node with jira river, never null
// * @throws Exception if something is wrong
// */
// protected abstract void handleJiraRiverResponse(NodeResponse nodeInfo) throws Exception;
//
// @Override
// public void onFailure(Throwable e) {
// try {
// restChannel.sendResponse(new BytesRestResponse(restChannel, e));
// } catch (IOException e1) {
// logger.error("Failed to send failure response", e1);
// }
// }
//
// /**
// * Build response document with only one field called <code>message</code>. You can use this in
// * {@link #handleJiraRiverResponse(NodeJRMgmBaseResponse)} implementation if you only need to return simple message.
// *
// * @param restRequest to build response document for
// * @param message to be placed in document
// * @return document with message
// * @throws IOException
// */
// public static XContentBuilder buildMessageDocument(RestRequest restRequest, String message) throws IOException {
// XContentBuilder builder = RestXContentBuilder.restContentBuilder(restRequest);
// builder.startObject();
// builder.field("message", message);
// builder.endObject();
// return builder;
// }
//
// }
//
// Path: src/main/java/org/jboss/elasticsearch/river/jira/mgm/RestJRMgmBaseAction.java
// public abstract class RestJRMgmBaseAction extends BaseRestHandler {
//
// protected RestJRMgmBaseAction(Settings settings, RestController controller, Client client) {
// super(settings, controller, client);
// }
//
// /**
// * Prepare base REST URL for JIRA river management operations. <code>riverName</code> request parameter is defined
// * here.
// *
// * @return base REST management url ending by <code>/</code>
// */
// protected String baseRestMgmUrl() {
// return "/" + RiverIndexName.Conf.indexName(settings) + "/{riverName}/_mgm_jr/";
// }
//
// }
// Path: src/main/java/org/jboss/elasticsearch/river/jira/mgm/fullupdate/RestFullUpdateAction.java
import org.elasticsearch.client.Client;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.rest.BytesRestResponse;
import org.elasticsearch.rest.RestChannel;
import org.elasticsearch.rest.RestController;
import org.elasticsearch.rest.RestRequest;
import org.elasticsearch.rest.RestStatus;
import org.jboss.elasticsearch.river.jira.mgm.JRMgmBaseActionListener;
import org.jboss.elasticsearch.river.jira.mgm.RestJRMgmBaseAction;
import static org.elasticsearch.rest.RestStatus.OK;
/*
* JBoss, Home of Professional Open Source
* Copyright 2012 Red Hat Inc. and/or its affiliates and other contributors
* as indicated by the @authors tag. All rights reserved.
*/
package org.jboss.elasticsearch.river.jira.mgm.fullupdate;
/**
* REST action handler for force full index update operation.
*
* @author Vlastimil Elias (velias at redhat dot com)
*/
public class RestFullUpdateAction extends RestJRMgmBaseAction {
@Inject
protected RestFullUpdateAction(Settings settings, Client client, RestController controller) {
super(settings, controller, client);
String baseUrl = baseRestMgmUrl();
controller.registerHandler(org.elasticsearch.rest.RestRequest.Method.POST, baseUrl + "fullupdate", this);
controller.registerHandler(org.elasticsearch.rest.RestRequest.Method.POST, baseUrl + "fullupdate/{projectKey}",
this);
}
@Override
public void handleRequest(final RestRequest restRequest, final RestChannel restChannel, Client client) {
final String riverName = restRequest.param("riverName");
final String projectKey = restRequest.param("projectKey");
FullUpdateRequest actionRequest = new FullUpdateRequest(riverName, projectKey);
client
.admin()
.cluster()
.execute(
FullUpdateAction.INSTANCE,
actionRequest, | new JRMgmBaseActionListener<FullUpdateRequest, FullUpdateResponse, NodeFullUpdateResponse>(actionRequest, |
searchisko/elasticsearch-river-jira | src/test/java/org/jboss/elasticsearch/river/jira/JIRAProjectIndexerCoordinatorTest.java | // Path: src/test/java/org/jboss/elasticsearch/river/jira/testtools/MockThread.java
// public class MockThread extends Thread {
//
// public boolean wasStarted = false;
//
// public boolean interruptWasCalled = false;
//
// @Override
// public synchronized void start() {
// wasStarted = true;
// }
//
// @Override
// public void interrupt() {
// interruptWasCalled = true;
// }
//
// }
| import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.elasticsearch.action.bulk.BulkRequestBuilder;
import org.elasticsearch.common.logging.ESLoggerFactory;
import org.jboss.elasticsearch.river.jira.testtools.MockThread;
import org.junit.Assert;
import org.junit.Test;
import org.mockito.Mockito;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.reset;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when; | {
tested.startIndexers();
Assert.assertTrue(tested.projectIndexerThreads.isEmpty());
Assert.assertTrue(tested.projectIndexers.isEmpty());
verify(esIntegrationMock, times(0)).acquireIndexingThread(Mockito.any(String.class), Mockito.any(Runnable.class));
}
// case - all indexer slots full, do not start new ones
{
reset(esIntegrationMock);
tested.projectKeysToIndexQueue.addAll(Utils.parseCsvString("ORG,AAA,BBB,CCC,DDD"));
tested.projectIndexerThreads.put("JJ", new Thread());
tested.projectIndexerThreads.put("II", new Thread());
tested.startIndexers();
Assert.assertEquals(2, tested.projectIndexerThreads.size());
Assert.assertEquals(5, tested.projectKeysToIndexQueue.size());
verify(esIntegrationMock, times(0)).acquireIndexingThread(Mockito.any(String.class), Mockito.any(Runnable.class));
Mockito.verifyNoMoreInteractions(esIntegrationMock);
}
// case - one indexer slot empty, start new one
{
reset(esIntegrationMock);
tested.projectIndexerThreads.clear();
tested.projectIndexerThreads.put("II", new Thread());
tested.projectIndexers.clear();
tested.projectIndexers.put("II", new JIRAProjectIndexer("II", true, null, esIntegrationMock, null));
tested.projectKeysToIndexQueue.clear();
tested.projectKeysToIndexQueue.addAll(Utils.parseCsvString("ORG,AAA,BBB,CCC,DDD"));
when(esIntegrationMock.acquireIndexingThread(Mockito.eq("jira_river_indexer_ORG"), Mockito.any(Runnable.class))) | // Path: src/test/java/org/jboss/elasticsearch/river/jira/testtools/MockThread.java
// public class MockThread extends Thread {
//
// public boolean wasStarted = false;
//
// public boolean interruptWasCalled = false;
//
// @Override
// public synchronized void start() {
// wasStarted = true;
// }
//
// @Override
// public void interrupt() {
// interruptWasCalled = true;
// }
//
// }
// Path: src/test/java/org/jboss/elasticsearch/river/jira/JIRAProjectIndexerCoordinatorTest.java
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.elasticsearch.action.bulk.BulkRequestBuilder;
import org.elasticsearch.common.logging.ESLoggerFactory;
import org.jboss.elasticsearch.river.jira.testtools.MockThread;
import org.junit.Assert;
import org.junit.Test;
import org.mockito.Mockito;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.reset;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
{
tested.startIndexers();
Assert.assertTrue(tested.projectIndexerThreads.isEmpty());
Assert.assertTrue(tested.projectIndexers.isEmpty());
verify(esIntegrationMock, times(0)).acquireIndexingThread(Mockito.any(String.class), Mockito.any(Runnable.class));
}
// case - all indexer slots full, do not start new ones
{
reset(esIntegrationMock);
tested.projectKeysToIndexQueue.addAll(Utils.parseCsvString("ORG,AAA,BBB,CCC,DDD"));
tested.projectIndexerThreads.put("JJ", new Thread());
tested.projectIndexerThreads.put("II", new Thread());
tested.startIndexers();
Assert.assertEquals(2, tested.projectIndexerThreads.size());
Assert.assertEquals(5, tested.projectKeysToIndexQueue.size());
verify(esIntegrationMock, times(0)).acquireIndexingThread(Mockito.any(String.class), Mockito.any(Runnable.class));
Mockito.verifyNoMoreInteractions(esIntegrationMock);
}
// case - one indexer slot empty, start new one
{
reset(esIntegrationMock);
tested.projectIndexerThreads.clear();
tested.projectIndexerThreads.put("II", new Thread());
tested.projectIndexers.clear();
tested.projectIndexers.put("II", new JIRAProjectIndexer("II", true, null, esIntegrationMock, null));
tested.projectKeysToIndexQueue.clear();
tested.projectKeysToIndexQueue.addAll(Utils.parseCsvString("ORG,AAA,BBB,CCC,DDD"));
when(esIntegrationMock.acquireIndexingThread(Mockito.eq("jira_river_indexer_ORG"), Mockito.any(Runnable.class))) | .thenReturn(new MockThread()); |
searchisko/elasticsearch-river-jira | src/test/java/org/jboss/elasticsearch/river/jira/mgm/state/TransportJRStateActionTest.java | // Path: src/main/java/org/jboss/elasticsearch/river/jira/IJiraRiverMgm.java
// public interface IJiraRiverMgm {
//
// /**
// * Stop jira river, but leave instance existing in {@link #riverInstances} so it can be found over management REST
// * calls and/or reconfigured and started later again. Note that standard ES river {@link #close()} method
// * implementation removes river instance from {@link #riverInstances}.
// *
// * @param permanent set to true if info about river stopped can be persisted
// */
// public abstract void stop(boolean permanent);
//
// /**
// * Restart jira river. Configuration of river is updated.
// */
// public abstract void restart();
//
// /**
// * Force full index update for some project(s) in this jira river. Used for REST management operations handling.
// *
// * @param jiraProjectKey optional key of project to reindex, if null or empty then all projects are forced to full
// * reindex
// * @return CSV list of projects forced to reindex. <code>null</code> if project passed over
// * <code>jiraProjectKey</code> parameter was not found in this indexer
// * @throws Exception
// */
// public abstract String forceFullReindex(String jiraProjectKey) throws Exception;
//
// /**
// * Force incremental index update for some project(s) in this jira river. Used for REST management operations
// * handling.
// *
// * @param jiraProjectKey optional key of project to reindex, if null or empty then all projects are forced to reindex
// * @return CSV list of projects forced to reindex. <code>null</code> if project passed over
// * <code>jiraProjectKey</code> parameter was not found in this indexer
// * @throws Exception
// */
// public abstract String forceIncrementalReindex(String jiraProjectKey) throws Exception;
//
// /**
// * Get info about current operation of this river. Used for REST management operations handling.
// *
// * @return String with JSON formatted info.
// * @throws Exception
// */
// public abstract String getRiverOperationInfo(DiscoveryNode esNode, Date currentDate) throws Exception;
//
// /**
// * Get name of river.
// *
// * @return name of jira river
// */
// public abstract RiverName riverName();
//
// }
| import java.util.Date;
import junit.framework.Assert;
import org.elasticsearch.Version;
import org.elasticsearch.action.support.ActionFilters;
import org.elasticsearch.cluster.ClusterName;
import org.elasticsearch.cluster.ClusterService;
import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.transport.DummyTransportAddress;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.transport.Transport;
import org.elasticsearch.transport.TransportService;
import org.jboss.elasticsearch.river.jira.IJiraRiverMgm;
import org.junit.Test;
import org.mockito.Mockito; | NodeJRStateResponse resp = tested.newNodeResponse();
Assert.assertNotNull(resp);
Assert.assertEquals(dn, resp.getNode());
}
@Test
public void newNodeResponseArray() {
TransportJRStateAction tested = prepareTestedInstance(clusterName);
NodeJRStateResponse[] array = tested.newNodeResponseArray(2);
Assert.assertNotNull(array);
Assert.assertEquals(2, array.length);
}
@Test
public void newResponse() {
TransportJRStateAction tested = prepareTestedInstance(clusterName);
NodeJRStateResponse[] array = new NodeJRStateResponse[0];
JRStateResponse resp = tested.newResponse(clusterName, array);
Assert.assertNotNull(resp);
Assert.assertEquals(resp.getClusterName(), clusterName);
Assert.assertEquals(resp.getNodes(), array);
}
@Test
public void performOperationOnJiraRiver() throws Exception {
TransportJRStateAction tested = prepareTestedInstance(clusterName);
| // Path: src/main/java/org/jboss/elasticsearch/river/jira/IJiraRiverMgm.java
// public interface IJiraRiverMgm {
//
// /**
// * Stop jira river, but leave instance existing in {@link #riverInstances} so it can be found over management REST
// * calls and/or reconfigured and started later again. Note that standard ES river {@link #close()} method
// * implementation removes river instance from {@link #riverInstances}.
// *
// * @param permanent set to true if info about river stopped can be persisted
// */
// public abstract void stop(boolean permanent);
//
// /**
// * Restart jira river. Configuration of river is updated.
// */
// public abstract void restart();
//
// /**
// * Force full index update for some project(s) in this jira river. Used for REST management operations handling.
// *
// * @param jiraProjectKey optional key of project to reindex, if null or empty then all projects are forced to full
// * reindex
// * @return CSV list of projects forced to reindex. <code>null</code> if project passed over
// * <code>jiraProjectKey</code> parameter was not found in this indexer
// * @throws Exception
// */
// public abstract String forceFullReindex(String jiraProjectKey) throws Exception;
//
// /**
// * Force incremental index update for some project(s) in this jira river. Used for REST management operations
// * handling.
// *
// * @param jiraProjectKey optional key of project to reindex, if null or empty then all projects are forced to reindex
// * @return CSV list of projects forced to reindex. <code>null</code> if project passed over
// * <code>jiraProjectKey</code> parameter was not found in this indexer
// * @throws Exception
// */
// public abstract String forceIncrementalReindex(String jiraProjectKey) throws Exception;
//
// /**
// * Get info about current operation of this river. Used for REST management operations handling.
// *
// * @return String with JSON formatted info.
// * @throws Exception
// */
// public abstract String getRiverOperationInfo(DiscoveryNode esNode, Date currentDate) throws Exception;
//
// /**
// * Get name of river.
// *
// * @return name of jira river
// */
// public abstract RiverName riverName();
//
// }
// Path: src/test/java/org/jboss/elasticsearch/river/jira/mgm/state/TransportJRStateActionTest.java
import java.util.Date;
import junit.framework.Assert;
import org.elasticsearch.Version;
import org.elasticsearch.action.support.ActionFilters;
import org.elasticsearch.cluster.ClusterName;
import org.elasticsearch.cluster.ClusterService;
import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.transport.DummyTransportAddress;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.transport.Transport;
import org.elasticsearch.transport.TransportService;
import org.jboss.elasticsearch.river.jira.IJiraRiverMgm;
import org.junit.Test;
import org.mockito.Mockito;
NodeJRStateResponse resp = tested.newNodeResponse();
Assert.assertNotNull(resp);
Assert.assertEquals(dn, resp.getNode());
}
@Test
public void newNodeResponseArray() {
TransportJRStateAction tested = prepareTestedInstance(clusterName);
NodeJRStateResponse[] array = tested.newNodeResponseArray(2);
Assert.assertNotNull(array);
Assert.assertEquals(2, array.length);
}
@Test
public void newResponse() {
TransportJRStateAction tested = prepareTestedInstance(clusterName);
NodeJRStateResponse[] array = new NodeJRStateResponse[0];
JRStateResponse resp = tested.newResponse(clusterName, array);
Assert.assertNotNull(resp);
Assert.assertEquals(resp.getClusterName(), clusterName);
Assert.assertEquals(resp.getNodes(), array);
}
@Test
public void performOperationOnJiraRiver() throws Exception {
TransportJRStateAction tested = prepareTestedInstance(clusterName);
| IJiraRiverMgm river = Mockito.mock(IJiraRiverMgm.class); |
searchisko/elasticsearch-river-jira | src/test/java/org/jboss/elasticsearch/river/jira/ProjectIndexingInfoTest.java | // Path: src/test/java/org/jboss/elasticsearch/river/jira/testtools/TestUtils.java
// public abstract class TestUtils {
//
// private static ObjectMapper mapper;
// static {
// mapper = new ObjectMapper();
// mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false);
// }
//
// private static JsonNode toJsonNode(String source) {
// JsonNode node = null;
// try {
// node = mapper.readValue(source, JsonNode.class);
// } catch (IOException e) {
// Assert.fail("Exception while parsing!: " + e);
// }
// return node;
// }
//
// /**
// * Assert two strings with JSON to be equal.
// *
// * @param expected
// * @param actual
// */
// public static void assertJsonEqual(String expected, String actual) {
// if (!toJsonNode(expected).equals(toJsonNode(actual))) {
// throw new ComparisonFailure("JSON's are not equal", expected, actual);
// }
// }
//
// /**
// * Assert passed string is same as content of given file loaded from classpath.
// *
// * @param expectedFilePath path to file inside classpath
// * @param actual content to assert
// * @throws IOException
// */
// public static void assertStringFromClasspathFile(String expectedFilePath, String actual) throws IOException {
// Assert.assertEquals(readStringFromClasspathFile(expectedFilePath), actual);
// }
//
// /**
// * Read JIRA JSON issue data for tests. Loaded from folder <code>/src/test/resources/jira_issue_json/</code>.
// *
// * @param key of issue to load data for
// * @return Map of Maps structure with issue data
// * @throws IOException
// */
// public static Map<String, Object> readJiraJsonIssueDataFromClasspathFile(String key) throws IOException {
// return Utils.loadJSONFromJarPackagedFile("/jira_issue_json/" + key + ".json");
// }
//
// /**
// * Read file from classpath into String. UTF-8 encoding expected.
// *
// * @param filePath in classpath to read data from.
// * @return file content.
// * @throws IOException
// */
// public static String readStringFromClasspathFile(String filePath) throws IOException {
// StringWriter stringWriter = new StringWriter();
// IOUtils.copy(TestUtils.class.getResourceAsStream(filePath), stringWriter, "UTF-8");
// return stringWriter.toString();
// }
//
// /**
// * Read JSON from string representation.
// *
// * @param jsonString to parse
// * @return parsed JSON
// * @throws SettingsException
// */
// public static Map<String, Object> getJSONMapFromString(String jsonString) throws IOException {
// XContentParser parser = null;
// try {
// parser = XContentFactory.xContent(XContentType.JSON).createParser(jsonString);
// return parser.mapAndClose();
// } finally {
// if (parser != null)
// parser.close();
// }
// }
//
// }
| import java.io.IOException;
import junit.framework.Assert;
import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.common.xcontent.XContentType;
import org.jboss.elasticsearch.river.jira.testtools.TestUtils;
import org.junit.Test; | /*
* JBoss, Home of Professional Open Source
* Copyright 2012 Red Hat Inc. and/or its affiliates and other contributors
* as indicated by the @authors tag. All rights reserved.
*/
package org.jboss.elasticsearch.river.jira;
/**
* Unit test for {@link ProjectIndexingInfo}.
*
* @author Vlastimil Elias (velias at redhat dot com)
*/
public class ProjectIndexingInfoTest {
@Test
public void buildDocument() throws Exception {
| // Path: src/test/java/org/jboss/elasticsearch/river/jira/testtools/TestUtils.java
// public abstract class TestUtils {
//
// private static ObjectMapper mapper;
// static {
// mapper = new ObjectMapper();
// mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false);
// }
//
// private static JsonNode toJsonNode(String source) {
// JsonNode node = null;
// try {
// node = mapper.readValue(source, JsonNode.class);
// } catch (IOException e) {
// Assert.fail("Exception while parsing!: " + e);
// }
// return node;
// }
//
// /**
// * Assert two strings with JSON to be equal.
// *
// * @param expected
// * @param actual
// */
// public static void assertJsonEqual(String expected, String actual) {
// if (!toJsonNode(expected).equals(toJsonNode(actual))) {
// throw new ComparisonFailure("JSON's are not equal", expected, actual);
// }
// }
//
// /**
// * Assert passed string is same as content of given file loaded from classpath.
// *
// * @param expectedFilePath path to file inside classpath
// * @param actual content to assert
// * @throws IOException
// */
// public static void assertStringFromClasspathFile(String expectedFilePath, String actual) throws IOException {
// Assert.assertEquals(readStringFromClasspathFile(expectedFilePath), actual);
// }
//
// /**
// * Read JIRA JSON issue data for tests. Loaded from folder <code>/src/test/resources/jira_issue_json/</code>.
// *
// * @param key of issue to load data for
// * @return Map of Maps structure with issue data
// * @throws IOException
// */
// public static Map<String, Object> readJiraJsonIssueDataFromClasspathFile(String key) throws IOException {
// return Utils.loadJSONFromJarPackagedFile("/jira_issue_json/" + key + ".json");
// }
//
// /**
// * Read file from classpath into String. UTF-8 encoding expected.
// *
// * @param filePath in classpath to read data from.
// * @return file content.
// * @throws IOException
// */
// public static String readStringFromClasspathFile(String filePath) throws IOException {
// StringWriter stringWriter = new StringWriter();
// IOUtils.copy(TestUtils.class.getResourceAsStream(filePath), stringWriter, "UTF-8");
// return stringWriter.toString();
// }
//
// /**
// * Read JSON from string representation.
// *
// * @param jsonString to parse
// * @return parsed JSON
// * @throws SettingsException
// */
// public static Map<String, Object> getJSONMapFromString(String jsonString) throws IOException {
// XContentParser parser = null;
// try {
// parser = XContentFactory.xContent(XContentType.JSON).createParser(jsonString);
// return parser.mapAndClose();
// } finally {
// if (parser != null)
// parser.close();
// }
// }
//
// }
// Path: src/test/java/org/jboss/elasticsearch/river/jira/ProjectIndexingInfoTest.java
import java.io.IOException;
import junit.framework.Assert;
import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.common.xcontent.XContentType;
import org.jboss.elasticsearch.river.jira.testtools.TestUtils;
import org.junit.Test;
/*
* JBoss, Home of Professional Open Source
* Copyright 2012 Red Hat Inc. and/or its affiliates and other contributors
* as indicated by the @authors tag. All rights reserved.
*/
package org.jboss.elasticsearch.river.jira;
/**
* Unit test for {@link ProjectIndexingInfo}.
*
* @author Vlastimil Elias (velias at redhat dot com)
*/
public class ProjectIndexingInfoTest {
@Test
public void buildDocument() throws Exception {
| TestUtils.assertJsonEqual(TestUtils.readStringFromClasspathFile("/asserts/ProjectIndexingInfoTest_1.json"), |
searchisko/elasticsearch-river-jira | src/test/java/org/jboss/elasticsearch/river/jira/JIRAProjectIndexerTest.java | // Path: src/test/java/org/jboss/elasticsearch/river/jira/testtools/ProjectInfoMatcher.java
// public class ProjectInfoMatcher extends BaseMatcher<ProjectIndexingInfo> {
//
// String project;
// boolean fullUpdate;
// boolean finishedOK;
// int issuesUpdated;
// int issuesDeleted;
// String errorMessage;
//
// /**
// * @param project
// * @param fullUpdate
// * @param finishedOK
// * @param issuesUpdated
// * @param issuesDeleted
// * @param errorMessage
// */
// public ProjectInfoMatcher(String project, boolean fullUpdate, boolean finishedOK, int issuesUpdated,
// int issuesDeleted, String errorMessage) {
// super();
// this.project = project;
// this.fullUpdate = fullUpdate;
// this.finishedOK = finishedOK;
// this.issuesUpdated = issuesUpdated;
// this.issuesDeleted = issuesDeleted;
// this.errorMessage = errorMessage;
// }
//
// @Override
// public boolean matches(Object arg0) {
// ProjectIndexingInfo info = (ProjectIndexingInfo) arg0;
// Assert.assertEquals(project, info.projectKey);
// Assert.assertEquals(fullUpdate, info.fullUpdate);
// Assert.assertEquals(finishedOK, info.finishedOK);
// Assert.assertEquals(issuesUpdated, info.issuesUpdated);
// Assert.assertEquals(issuesDeleted, info.issuesDeleted);
// Assert.assertEquals(errorMessage, info.errorMessage);
// Assert.assertNotNull(info.startDate);
// return true;
// }
//
// @Override
// public void describeTo(Description arg0) {
// }
//
// }
| import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import junit.framework.Assert;
import org.elasticsearch.action.bulk.BulkRequestBuilder;
import org.elasticsearch.action.search.SearchRequestBuilder;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.client.Client;
import org.elasticsearch.common.joda.time.format.ISODateTimeFormat;
import org.elasticsearch.common.logging.ESLoggerFactory;
import org.elasticsearch.common.text.StringText;
import org.elasticsearch.search.SearchHit;
import org.elasticsearch.search.internal.InternalSearchHit;
import org.elasticsearch.search.internal.InternalSearchHits;
import org.elasticsearch.search.internal.InternalSearchResponse;
import org.jboss.elasticsearch.river.jira.testtools.ProjectInfoMatcher;
import org.junit.Test;
import org.mockito.Mockito;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.reset;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when; | public void run() throws Exception {
IJIRAClient jiraClientMock = mock(IJIRAClient.class);
IESIntegration esIntegrationMock = mockEsIntegrationComponent();
IJIRAIssueIndexStructureBuilder jiraIssueIndexStructureBuilderMock = mock(IJIRAIssueIndexStructureBuilder.class);
JIRAProjectIndexer tested = new JIRAProjectIndexer("ORG", false, jiraClientMock, esIntegrationMock,
jiraIssueIndexStructureBuilderMock);
List<Map<String, Object>> issues = new ArrayList<Map<String, Object>>();
Date lastUpdatedDate = DateTimeUtils.parseISODateTime("2012-08-14T07:00:00.000-0400");
addIssueMock(issues, "ORG-45", "2012-08-14T08:00:00.000-0400");
addIssueMock(issues, "ORG-46", "2012-08-14T08:00:10.000-0400");
addIssueMock(issues, "ORG-47", "2012-08-14T08:00:20.000-0400");
Client client = Mockito.mock(Client.class);
BulkRequestBuilder brb = new BulkRequestBuilder(client);
SearchRequestBuilder srb = new SearchRequestBuilder(client);
// test case with indexing finished OK
{
when(
esIntegrationMock.readDatetimeValue("ORG",
JIRAProjectIndexer.STORE_PROPERTYNAME_LAST_INDEXED_ISSUE_UPDATE_DATE)).thenReturn(lastUpdatedDate);
when(jiraClientMock.getJIRAChangedIssues("ORG", 0, lastUpdatedDate, null)).thenReturn(
new ChangedIssuesResults(issues, 0, 50, 3));
when(esIntegrationMock.prepareESBulkRequestBuilder()).thenReturn(brb);
configureStructureBuilderMockDefaults(jiraIssueIndexStructureBuilderMock);
tested.run();
verify(esIntegrationMock, times(1)).reportIndexingFinished( | // Path: src/test/java/org/jboss/elasticsearch/river/jira/testtools/ProjectInfoMatcher.java
// public class ProjectInfoMatcher extends BaseMatcher<ProjectIndexingInfo> {
//
// String project;
// boolean fullUpdate;
// boolean finishedOK;
// int issuesUpdated;
// int issuesDeleted;
// String errorMessage;
//
// /**
// * @param project
// * @param fullUpdate
// * @param finishedOK
// * @param issuesUpdated
// * @param issuesDeleted
// * @param errorMessage
// */
// public ProjectInfoMatcher(String project, boolean fullUpdate, boolean finishedOK, int issuesUpdated,
// int issuesDeleted, String errorMessage) {
// super();
// this.project = project;
// this.fullUpdate = fullUpdate;
// this.finishedOK = finishedOK;
// this.issuesUpdated = issuesUpdated;
// this.issuesDeleted = issuesDeleted;
// this.errorMessage = errorMessage;
// }
//
// @Override
// public boolean matches(Object arg0) {
// ProjectIndexingInfo info = (ProjectIndexingInfo) arg0;
// Assert.assertEquals(project, info.projectKey);
// Assert.assertEquals(fullUpdate, info.fullUpdate);
// Assert.assertEquals(finishedOK, info.finishedOK);
// Assert.assertEquals(issuesUpdated, info.issuesUpdated);
// Assert.assertEquals(issuesDeleted, info.issuesDeleted);
// Assert.assertEquals(errorMessage, info.errorMessage);
// Assert.assertNotNull(info.startDate);
// return true;
// }
//
// @Override
// public void describeTo(Description arg0) {
// }
//
// }
// Path: src/test/java/org/jboss/elasticsearch/river/jira/JIRAProjectIndexerTest.java
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import junit.framework.Assert;
import org.elasticsearch.action.bulk.BulkRequestBuilder;
import org.elasticsearch.action.search.SearchRequestBuilder;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.client.Client;
import org.elasticsearch.common.joda.time.format.ISODateTimeFormat;
import org.elasticsearch.common.logging.ESLoggerFactory;
import org.elasticsearch.common.text.StringText;
import org.elasticsearch.search.SearchHit;
import org.elasticsearch.search.internal.InternalSearchHit;
import org.elasticsearch.search.internal.InternalSearchHits;
import org.elasticsearch.search.internal.InternalSearchResponse;
import org.jboss.elasticsearch.river.jira.testtools.ProjectInfoMatcher;
import org.junit.Test;
import org.mockito.Mockito;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.reset;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
public void run() throws Exception {
IJIRAClient jiraClientMock = mock(IJIRAClient.class);
IESIntegration esIntegrationMock = mockEsIntegrationComponent();
IJIRAIssueIndexStructureBuilder jiraIssueIndexStructureBuilderMock = mock(IJIRAIssueIndexStructureBuilder.class);
JIRAProjectIndexer tested = new JIRAProjectIndexer("ORG", false, jiraClientMock, esIntegrationMock,
jiraIssueIndexStructureBuilderMock);
List<Map<String, Object>> issues = new ArrayList<Map<String, Object>>();
Date lastUpdatedDate = DateTimeUtils.parseISODateTime("2012-08-14T07:00:00.000-0400");
addIssueMock(issues, "ORG-45", "2012-08-14T08:00:00.000-0400");
addIssueMock(issues, "ORG-46", "2012-08-14T08:00:10.000-0400");
addIssueMock(issues, "ORG-47", "2012-08-14T08:00:20.000-0400");
Client client = Mockito.mock(Client.class);
BulkRequestBuilder brb = new BulkRequestBuilder(client);
SearchRequestBuilder srb = new SearchRequestBuilder(client);
// test case with indexing finished OK
{
when(
esIntegrationMock.readDatetimeValue("ORG",
JIRAProjectIndexer.STORE_PROPERTYNAME_LAST_INDEXED_ISSUE_UPDATE_DATE)).thenReturn(lastUpdatedDate);
when(jiraClientMock.getJIRAChangedIssues("ORG", 0, lastUpdatedDate, null)).thenReturn(
new ChangedIssuesResults(issues, 0, 50, 3));
when(esIntegrationMock.prepareESBulkRequestBuilder()).thenReturn(brb);
configureStructureBuilderMockDefaults(jiraIssueIndexStructureBuilderMock);
tested.run();
verify(esIntegrationMock, times(1)).reportIndexingFinished( | Mockito.argThat(new ProjectInfoMatcher("ORG", false, true, 3, 0, null))); |
searchisko/elasticsearch-river-jira | src/main/java/org/jboss/elasticsearch/river/jira/mgm/incrementalupdate/RestIncrementalUpdateAction.java | // Path: src/main/java/org/jboss/elasticsearch/river/jira/mgm/JRMgmBaseActionListener.java
// public abstract class JRMgmBaseActionListener<Request extends JRMgmBaseRequest<?>, Response extends JRMgmBaseResponse<NodeResponse>, NodeResponse extends NodeJRMgmBaseResponse>
// implements ActionListener<Response> {
//
// protected final ESLogger logger;
//
// protected final RestRequest restRequest;
// protected final RestChannel restChannel;
// protected final Request actionRequest;
//
// /**
// * Create new action listener.
// *
// * @param actionRequest this listener process result for
// * @param restRequest we handle
// * @param restChannel to write rest response into
// */
// public JRMgmBaseActionListener(Request actionRequest, RestRequest restRequest, RestChannel restChannel) {
// super();
// this.restRequest = restRequest;
// this.restChannel = restChannel;
// this.actionRequest = actionRequest;
// logger = Loggers.getLogger(getClass());
// }
//
// @Override
// public void onResponse(Response response) {
// try {
// NodeResponse nodeInfo = response.getSuccessNodeResponse();
// if (nodeInfo == null) {
// restChannel.sendResponse(new BytesRestResponse(RestStatus.NOT_FOUND, buildMessageDocument(restRequest,
// "No JiraRiver found for name: " + actionRequest.getRiverName())));
// } else {
// handleJiraRiverResponse(nodeInfo);
// }
// } catch (Exception e) {
// onFailure(e);
// }
// }
//
// /**
// * Implement this in subclasses to handle response from jira river and return REST response based on it.
// *
// * @param nodeInfo operation response from node with jira river, never null
// * @throws Exception if something is wrong
// */
// protected abstract void handleJiraRiverResponse(NodeResponse nodeInfo) throws Exception;
//
// @Override
// public void onFailure(Throwable e) {
// try {
// restChannel.sendResponse(new BytesRestResponse(restChannel, e));
// } catch (IOException e1) {
// logger.error("Failed to send failure response", e1);
// }
// }
//
// /**
// * Build response document with only one field called <code>message</code>. You can use this in
// * {@link #handleJiraRiverResponse(NodeJRMgmBaseResponse)} implementation if you only need to return simple message.
// *
// * @param restRequest to build response document for
// * @param message to be placed in document
// * @return document with message
// * @throws IOException
// */
// public static XContentBuilder buildMessageDocument(RestRequest restRequest, String message) throws IOException {
// XContentBuilder builder = RestXContentBuilder.restContentBuilder(restRequest);
// builder.startObject();
// builder.field("message", message);
// builder.endObject();
// return builder;
// }
//
// }
//
// Path: src/main/java/org/jboss/elasticsearch/river/jira/mgm/RestJRMgmBaseAction.java
// public abstract class RestJRMgmBaseAction extends BaseRestHandler {
//
// protected RestJRMgmBaseAction(Settings settings, RestController controller, Client client) {
// super(settings, controller, client);
// }
//
// /**
// * Prepare base REST URL for JIRA river management operations. <code>riverName</code> request parameter is defined
// * here.
// *
// * @return base REST management url ending by <code>/</code>
// */
// protected String baseRestMgmUrl() {
// return "/" + RiverIndexName.Conf.indexName(settings) + "/{riverName}/_mgm_jr/";
// }
//
// }
| import org.elasticsearch.client.Client;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.rest.BytesRestResponse;
import org.elasticsearch.rest.RestChannel;
import org.elasticsearch.rest.RestController;
import org.elasticsearch.rest.RestRequest;
import org.elasticsearch.rest.RestStatus;
import org.jboss.elasticsearch.river.jira.mgm.JRMgmBaseActionListener;
import org.jboss.elasticsearch.river.jira.mgm.RestJRMgmBaseAction;
import static org.elasticsearch.rest.RestStatus.OK; | /*
* JBoss, Home of Professional Open Source
* Copyright 2012 Red Hat Inc. and/or its affiliates and other contributors
* as indicated by the @authors tag. All rights reserved.
*/
package org.jboss.elasticsearch.river.jira.mgm.incrementalupdate;
/**
* REST action handler for force incremental index update operation.
*
* @author Vlastimil Elias (velias at redhat dot com)
*/
public class RestIncrementalUpdateAction extends RestJRMgmBaseAction {
@Inject
protected RestIncrementalUpdateAction(Settings settings, Client client, RestController controller) {
super(settings, controller, client);
String baseUrl = baseRestMgmUrl();
controller.registerHandler(org.elasticsearch.rest.RestRequest.Method.POST, baseUrl + "incrementalupdate", this);
controller.registerHandler(org.elasticsearch.rest.RestRequest.Method.POST, baseUrl
+ "incrementalupdate/{projectKey}", this);
}
@Override
public void handleRequest(final RestRequest restRequest, final RestChannel restChannel, Client client) {
final String riverName = restRequest.param("riverName");
final String projectKey = restRequest.param("projectKey");
IncrementalUpdateRequest actionRequest = new IncrementalUpdateRequest(riverName, projectKey);
client
.admin()
.cluster()
.execute(
IncrementalUpdateAction.INSTANCE,
actionRequest, | // Path: src/main/java/org/jboss/elasticsearch/river/jira/mgm/JRMgmBaseActionListener.java
// public abstract class JRMgmBaseActionListener<Request extends JRMgmBaseRequest<?>, Response extends JRMgmBaseResponse<NodeResponse>, NodeResponse extends NodeJRMgmBaseResponse>
// implements ActionListener<Response> {
//
// protected final ESLogger logger;
//
// protected final RestRequest restRequest;
// protected final RestChannel restChannel;
// protected final Request actionRequest;
//
// /**
// * Create new action listener.
// *
// * @param actionRequest this listener process result for
// * @param restRequest we handle
// * @param restChannel to write rest response into
// */
// public JRMgmBaseActionListener(Request actionRequest, RestRequest restRequest, RestChannel restChannel) {
// super();
// this.restRequest = restRequest;
// this.restChannel = restChannel;
// this.actionRequest = actionRequest;
// logger = Loggers.getLogger(getClass());
// }
//
// @Override
// public void onResponse(Response response) {
// try {
// NodeResponse nodeInfo = response.getSuccessNodeResponse();
// if (nodeInfo == null) {
// restChannel.sendResponse(new BytesRestResponse(RestStatus.NOT_FOUND, buildMessageDocument(restRequest,
// "No JiraRiver found for name: " + actionRequest.getRiverName())));
// } else {
// handleJiraRiverResponse(nodeInfo);
// }
// } catch (Exception e) {
// onFailure(e);
// }
// }
//
// /**
// * Implement this in subclasses to handle response from jira river and return REST response based on it.
// *
// * @param nodeInfo operation response from node with jira river, never null
// * @throws Exception if something is wrong
// */
// protected abstract void handleJiraRiverResponse(NodeResponse nodeInfo) throws Exception;
//
// @Override
// public void onFailure(Throwable e) {
// try {
// restChannel.sendResponse(new BytesRestResponse(restChannel, e));
// } catch (IOException e1) {
// logger.error("Failed to send failure response", e1);
// }
// }
//
// /**
// * Build response document with only one field called <code>message</code>. You can use this in
// * {@link #handleJiraRiverResponse(NodeJRMgmBaseResponse)} implementation if you only need to return simple message.
// *
// * @param restRequest to build response document for
// * @param message to be placed in document
// * @return document with message
// * @throws IOException
// */
// public static XContentBuilder buildMessageDocument(RestRequest restRequest, String message) throws IOException {
// XContentBuilder builder = RestXContentBuilder.restContentBuilder(restRequest);
// builder.startObject();
// builder.field("message", message);
// builder.endObject();
// return builder;
// }
//
// }
//
// Path: src/main/java/org/jboss/elasticsearch/river/jira/mgm/RestJRMgmBaseAction.java
// public abstract class RestJRMgmBaseAction extends BaseRestHandler {
//
// protected RestJRMgmBaseAction(Settings settings, RestController controller, Client client) {
// super(settings, controller, client);
// }
//
// /**
// * Prepare base REST URL for JIRA river management operations. <code>riverName</code> request parameter is defined
// * here.
// *
// * @return base REST management url ending by <code>/</code>
// */
// protected String baseRestMgmUrl() {
// return "/" + RiverIndexName.Conf.indexName(settings) + "/{riverName}/_mgm_jr/";
// }
//
// }
// Path: src/main/java/org/jboss/elasticsearch/river/jira/mgm/incrementalupdate/RestIncrementalUpdateAction.java
import org.elasticsearch.client.Client;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.rest.BytesRestResponse;
import org.elasticsearch.rest.RestChannel;
import org.elasticsearch.rest.RestController;
import org.elasticsearch.rest.RestRequest;
import org.elasticsearch.rest.RestStatus;
import org.jboss.elasticsearch.river.jira.mgm.JRMgmBaseActionListener;
import org.jboss.elasticsearch.river.jira.mgm.RestJRMgmBaseAction;
import static org.elasticsearch.rest.RestStatus.OK;
/*
* JBoss, Home of Professional Open Source
* Copyright 2012 Red Hat Inc. and/or its affiliates and other contributors
* as indicated by the @authors tag. All rights reserved.
*/
package org.jboss.elasticsearch.river.jira.mgm.incrementalupdate;
/**
* REST action handler for force incremental index update operation.
*
* @author Vlastimil Elias (velias at redhat dot com)
*/
public class RestIncrementalUpdateAction extends RestJRMgmBaseAction {
@Inject
protected RestIncrementalUpdateAction(Settings settings, Client client, RestController controller) {
super(settings, controller, client);
String baseUrl = baseRestMgmUrl();
controller.registerHandler(org.elasticsearch.rest.RestRequest.Method.POST, baseUrl + "incrementalupdate", this);
controller.registerHandler(org.elasticsearch.rest.RestRequest.Method.POST, baseUrl
+ "incrementalupdate/{projectKey}", this);
}
@Override
public void handleRequest(final RestRequest restRequest, final RestChannel restChannel, Client client) {
final String riverName = restRequest.param("riverName");
final String projectKey = restRequest.param("projectKey");
IncrementalUpdateRequest actionRequest = new IncrementalUpdateRequest(riverName, projectKey);
client
.admin()
.cluster()
.execute(
IncrementalUpdateAction.INSTANCE,
actionRequest, | new JRMgmBaseActionListener<IncrementalUpdateRequest, IncrementalUpdateResponse, NodeIncrementalUpdateResponse>( |
searchisko/elasticsearch-river-jira | src/test/java/org/jboss/elasticsearch/river/jira/mgm/incrementalupdate/TransportIncrementalUpdateActionTest.java | // Path: src/main/java/org/jboss/elasticsearch/river/jira/IJiraRiverMgm.java
// public interface IJiraRiverMgm {
//
// /**
// * Stop jira river, but leave instance existing in {@link #riverInstances} so it can be found over management REST
// * calls and/or reconfigured and started later again. Note that standard ES river {@link #close()} method
// * implementation removes river instance from {@link #riverInstances}.
// *
// * @param permanent set to true if info about river stopped can be persisted
// */
// public abstract void stop(boolean permanent);
//
// /**
// * Restart jira river. Configuration of river is updated.
// */
// public abstract void restart();
//
// /**
// * Force full index update for some project(s) in this jira river. Used for REST management operations handling.
// *
// * @param jiraProjectKey optional key of project to reindex, if null or empty then all projects are forced to full
// * reindex
// * @return CSV list of projects forced to reindex. <code>null</code> if project passed over
// * <code>jiraProjectKey</code> parameter was not found in this indexer
// * @throws Exception
// */
// public abstract String forceFullReindex(String jiraProjectKey) throws Exception;
//
// /**
// * Force incremental index update for some project(s) in this jira river. Used for REST management operations
// * handling.
// *
// * @param jiraProjectKey optional key of project to reindex, if null or empty then all projects are forced to reindex
// * @return CSV list of projects forced to reindex. <code>null</code> if project passed over
// * <code>jiraProjectKey</code> parameter was not found in this indexer
// * @throws Exception
// */
// public abstract String forceIncrementalReindex(String jiraProjectKey) throws Exception;
//
// /**
// * Get info about current operation of this river. Used for REST management operations handling.
// *
// * @return String with JSON formatted info.
// * @throws Exception
// */
// public abstract String getRiverOperationInfo(DiscoveryNode esNode, Date currentDate) throws Exception;
//
// /**
// * Get name of river.
// *
// * @return name of jira river
// */
// public abstract RiverName riverName();
//
// }
| import junit.framework.Assert;
import org.elasticsearch.Version;
import org.elasticsearch.action.support.ActionFilters;
import org.elasticsearch.cluster.ClusterName;
import org.elasticsearch.cluster.ClusterService;
import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.transport.DummyTransportAddress;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.transport.Transport;
import org.elasticsearch.transport.TransportService;
import org.jboss.elasticsearch.river.jira.IJiraRiverMgm;
import org.junit.Test;
import org.mockito.Mockito; | NodeIncrementalUpdateResponse resp = tested.newNodeResponse();
Assert.assertNotNull(resp);
Assert.assertEquals(dn, resp.getNode());
}
@Test
public void newNodeResponseArray() {
TransportIncrementalUpdateAction tested = prepareTestedInstance(clusterName);
NodeIncrementalUpdateResponse[] array = tested.newNodeResponseArray(2);
Assert.assertNotNull(array);
Assert.assertEquals(2, array.length);
}
@Test
public void newResponse() {
TransportIncrementalUpdateAction tested = prepareTestedInstance(clusterName);
NodeIncrementalUpdateResponse[] array = new NodeIncrementalUpdateResponse[0];
IncrementalUpdateResponse resp = tested.newResponse(clusterName, array);
Assert.assertNotNull(resp);
Assert.assertEquals(resp.getClusterName(), clusterName);
Assert.assertEquals(resp.getNodes(), array);
}
@Test
public void performOperationOnJiraRiver() throws Exception {
TransportIncrementalUpdateAction tested = prepareTestedInstance(clusterName);
| // Path: src/main/java/org/jboss/elasticsearch/river/jira/IJiraRiverMgm.java
// public interface IJiraRiverMgm {
//
// /**
// * Stop jira river, but leave instance existing in {@link #riverInstances} so it can be found over management REST
// * calls and/or reconfigured and started later again. Note that standard ES river {@link #close()} method
// * implementation removes river instance from {@link #riverInstances}.
// *
// * @param permanent set to true if info about river stopped can be persisted
// */
// public abstract void stop(boolean permanent);
//
// /**
// * Restart jira river. Configuration of river is updated.
// */
// public abstract void restart();
//
// /**
// * Force full index update for some project(s) in this jira river. Used for REST management operations handling.
// *
// * @param jiraProjectKey optional key of project to reindex, if null or empty then all projects are forced to full
// * reindex
// * @return CSV list of projects forced to reindex. <code>null</code> if project passed over
// * <code>jiraProjectKey</code> parameter was not found in this indexer
// * @throws Exception
// */
// public abstract String forceFullReindex(String jiraProjectKey) throws Exception;
//
// /**
// * Force incremental index update for some project(s) in this jira river. Used for REST management operations
// * handling.
// *
// * @param jiraProjectKey optional key of project to reindex, if null or empty then all projects are forced to reindex
// * @return CSV list of projects forced to reindex. <code>null</code> if project passed over
// * <code>jiraProjectKey</code> parameter was not found in this indexer
// * @throws Exception
// */
// public abstract String forceIncrementalReindex(String jiraProjectKey) throws Exception;
//
// /**
// * Get info about current operation of this river. Used for REST management operations handling.
// *
// * @return String with JSON formatted info.
// * @throws Exception
// */
// public abstract String getRiverOperationInfo(DiscoveryNode esNode, Date currentDate) throws Exception;
//
// /**
// * Get name of river.
// *
// * @return name of jira river
// */
// public abstract RiverName riverName();
//
// }
// Path: src/test/java/org/jboss/elasticsearch/river/jira/mgm/incrementalupdate/TransportIncrementalUpdateActionTest.java
import junit.framework.Assert;
import org.elasticsearch.Version;
import org.elasticsearch.action.support.ActionFilters;
import org.elasticsearch.cluster.ClusterName;
import org.elasticsearch.cluster.ClusterService;
import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.transport.DummyTransportAddress;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.transport.Transport;
import org.elasticsearch.transport.TransportService;
import org.jboss.elasticsearch.river.jira.IJiraRiverMgm;
import org.junit.Test;
import org.mockito.Mockito;
NodeIncrementalUpdateResponse resp = tested.newNodeResponse();
Assert.assertNotNull(resp);
Assert.assertEquals(dn, resp.getNode());
}
@Test
public void newNodeResponseArray() {
TransportIncrementalUpdateAction tested = prepareTestedInstance(clusterName);
NodeIncrementalUpdateResponse[] array = tested.newNodeResponseArray(2);
Assert.assertNotNull(array);
Assert.assertEquals(2, array.length);
}
@Test
public void newResponse() {
TransportIncrementalUpdateAction tested = prepareTestedInstance(clusterName);
NodeIncrementalUpdateResponse[] array = new NodeIncrementalUpdateResponse[0];
IncrementalUpdateResponse resp = tested.newResponse(clusterName, array);
Assert.assertNotNull(resp);
Assert.assertEquals(resp.getClusterName(), clusterName);
Assert.assertEquals(resp.getNodes(), array);
}
@Test
public void performOperationOnJiraRiver() throws Exception {
TransportIncrementalUpdateAction tested = prepareTestedInstance(clusterName);
| IJiraRiverMgm river = Mockito.mock(IJiraRiverMgm.class); |
simlar/simlar-android | app/src/main/java/org/simlar/helper/PreferencesHelper.java | // Path: app/src/main/java/org/simlar/utils/Util.java
// public final class Util
// {
// public static final String[] EMPTY_STRING_ARRAY = {};
// private static final int MAX_BUFFER_SIZE = 1024 * 1024;
//
// private Util()
// {
// throw new AssertionError("This class was not meant to be instantiated");
// }
//
// public static boolean isNullOrEmpty(final String string)
// {
// return string == null || string.isEmpty();
// }
//
// public static int compareString(final String lhs, final String rhs)
// {
// if (isNullOrEmpty(lhs) && isNullOrEmpty(rhs)) {
// return 0;
// }
//
// if (isNullOrEmpty(lhs)) {
// return -1;
// }
//
// if (isNullOrEmpty(rhs)) {
// return 1;
// }
//
// return lhs.compareToIgnoreCase(rhs);
// }
//
// public static boolean equalString(final String lhs, final String rhs)
// {
// return compareString(lhs, rhs) == 0;
// }
//
// public static boolean equals(final Object lhs, final Object rhs)
// {
// //noinspection EqualsReplaceableByObjectsCall,ObjectEquality /// Objects.equals is available in android sdk >= 19
// return lhs == rhs || lhs != null && lhs.equals(rhs);
// }
//
// public static void copyStream(final InputStream is, final OutputStream os) throws IOException
// {
// final byte[] buffer = new byte[MAX_BUFFER_SIZE];
// int length;
// while ((length = is.read(buffer)) != -1) {
// os.write(buffer, 0, length);
// }
// }
//
// public static Spanned fromHtml(final String string)
// {
// return Build.VERSION.SDK_INT >= Build.VERSION_CODES.N ? Html.fromHtml(string, Html.FROM_HTML_MODE_LEGACY) : Html.fromHtml(string);
// }
//
// public static String formatMilliSeconds(final long milliSeconds)
// {
// if (milliSeconds >= 0) {
// return formatPositiveMilliSeconds(milliSeconds);
// }
//
// return '-' + formatPositiveMilliSeconds(-1 * milliSeconds);
// }
//
// private static String formatPositiveMilliSeconds(final long milliSeconds)
// {
// final SimpleDateFormat sdf = createSimpleDateFormat(milliSeconds);
// sdf.setTimeZone(TimeZone.getTimeZone("GMT+0"));
// return sdf.format(new Date(milliSeconds));
// }
//
// private static SimpleDateFormat createSimpleDateFormat(final long milliSeconds)
// {
// if (milliSeconds >= 3600000) {
// return new SimpleDateFormat("HH:mm:ss", Locale.US);
// }
//
// return new SimpleDateFormat("mm:ss", Locale.US);
// }
//
// @NonNull
// public static <T> T getSystemService(final Context context, final String name)
// {
// if (context == null) {
// throw new IllegalArgumentException("no context");
// }
//
// @SuppressWarnings("unchecked")
// final T service = (T) context.getSystemService(name);
// if (service == null) {
// throw new IllegalArgumentException("no system service matching name: " + name);
// }
// return service;
// }
// }
| import android.content.Context;
import android.content.SharedPreferences;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import org.simlar.utils.Util; |
private static void createPasswordHash()
{
// kamailio password hash md5(username:realm:password)
mPasswordHash = md5(mMySimlarId + ':' + ServerSettings.DOMAIN + ':' + mPassword);
}
private static String md5(final String str)
{
try {
final MessageDigest digest = MessageDigest.getInstance("md5");
digest.update(str.getBytes());
final StringBuilder sb = new StringBuilder();
for (final byte b : digest.digest()) {
sb.append(String.format("%02x", b));
}
return sb.toString();
} catch (final NoSuchAlgorithmException e) {
return "";
}
}
@SuppressWarnings("WeakerAccess")
public static final class NotInitedException extends IllegalStateException
{
private static final long serialVersionUID = 1;
}
public static String getMySimlarId() throws NotInitedException
{ | // Path: app/src/main/java/org/simlar/utils/Util.java
// public final class Util
// {
// public static final String[] EMPTY_STRING_ARRAY = {};
// private static final int MAX_BUFFER_SIZE = 1024 * 1024;
//
// private Util()
// {
// throw new AssertionError("This class was not meant to be instantiated");
// }
//
// public static boolean isNullOrEmpty(final String string)
// {
// return string == null || string.isEmpty();
// }
//
// public static int compareString(final String lhs, final String rhs)
// {
// if (isNullOrEmpty(lhs) && isNullOrEmpty(rhs)) {
// return 0;
// }
//
// if (isNullOrEmpty(lhs)) {
// return -1;
// }
//
// if (isNullOrEmpty(rhs)) {
// return 1;
// }
//
// return lhs.compareToIgnoreCase(rhs);
// }
//
// public static boolean equalString(final String lhs, final String rhs)
// {
// return compareString(lhs, rhs) == 0;
// }
//
// public static boolean equals(final Object lhs, final Object rhs)
// {
// //noinspection EqualsReplaceableByObjectsCall,ObjectEquality /// Objects.equals is available in android sdk >= 19
// return lhs == rhs || lhs != null && lhs.equals(rhs);
// }
//
// public static void copyStream(final InputStream is, final OutputStream os) throws IOException
// {
// final byte[] buffer = new byte[MAX_BUFFER_SIZE];
// int length;
// while ((length = is.read(buffer)) != -1) {
// os.write(buffer, 0, length);
// }
// }
//
// public static Spanned fromHtml(final String string)
// {
// return Build.VERSION.SDK_INT >= Build.VERSION_CODES.N ? Html.fromHtml(string, Html.FROM_HTML_MODE_LEGACY) : Html.fromHtml(string);
// }
//
// public static String formatMilliSeconds(final long milliSeconds)
// {
// if (milliSeconds >= 0) {
// return formatPositiveMilliSeconds(milliSeconds);
// }
//
// return '-' + formatPositiveMilliSeconds(-1 * milliSeconds);
// }
//
// private static String formatPositiveMilliSeconds(final long milliSeconds)
// {
// final SimpleDateFormat sdf = createSimpleDateFormat(milliSeconds);
// sdf.setTimeZone(TimeZone.getTimeZone("GMT+0"));
// return sdf.format(new Date(milliSeconds));
// }
//
// private static SimpleDateFormat createSimpleDateFormat(final long milliSeconds)
// {
// if (milliSeconds >= 3600000) {
// return new SimpleDateFormat("HH:mm:ss", Locale.US);
// }
//
// return new SimpleDateFormat("mm:ss", Locale.US);
// }
//
// @NonNull
// public static <T> T getSystemService(final Context context, final String name)
// {
// if (context == null) {
// throw new IllegalArgumentException("no context");
// }
//
// @SuppressWarnings("unchecked")
// final T service = (T) context.getSystemService(name);
// if (service == null) {
// throw new IllegalArgumentException("no system service matching name: " + name);
// }
// return service;
// }
// }
// Path: app/src/main/java/org/simlar/helper/PreferencesHelper.java
import android.content.Context;
import android.content.SharedPreferences;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import org.simlar.utils.Util;
private static void createPasswordHash()
{
// kamailio password hash md5(username:realm:password)
mPasswordHash = md5(mMySimlarId + ':' + ServerSettings.DOMAIN + ':' + mPassword);
}
private static String md5(final String str)
{
try {
final MessageDigest digest = MessageDigest.getInstance("md5");
digest.update(str.getBytes());
final StringBuilder sb = new StringBuilder();
for (final byte b : digest.digest()) {
sb.append(String.format("%02x", b));
}
return sb.toString();
} catch (final NoSuchAlgorithmException e) {
return "";
}
}
@SuppressWarnings("WeakerAccess")
public static final class NotInitedException extends IllegalStateException
{
private static final long serialVersionUID = 1;
}
public static String getMySimlarId() throws NotInitedException
{ | if (Util.isNullOrEmpty(mMySimlarId)) { |
simlar/simlar-android | app/src/main/java/org/simlar/helper/PermissionsHelper.java | // Path: app/src/main/java/org/simlar/utils/Util.java
// public final class Util
// {
// public static final String[] EMPTY_STRING_ARRAY = {};
// private static final int MAX_BUFFER_SIZE = 1024 * 1024;
//
// private Util()
// {
// throw new AssertionError("This class was not meant to be instantiated");
// }
//
// public static boolean isNullOrEmpty(final String string)
// {
// return string == null || string.isEmpty();
// }
//
// public static int compareString(final String lhs, final String rhs)
// {
// if (isNullOrEmpty(lhs) && isNullOrEmpty(rhs)) {
// return 0;
// }
//
// if (isNullOrEmpty(lhs)) {
// return -1;
// }
//
// if (isNullOrEmpty(rhs)) {
// return 1;
// }
//
// return lhs.compareToIgnoreCase(rhs);
// }
//
// public static boolean equalString(final String lhs, final String rhs)
// {
// return compareString(lhs, rhs) == 0;
// }
//
// public static boolean equals(final Object lhs, final Object rhs)
// {
// //noinspection EqualsReplaceableByObjectsCall,ObjectEquality /// Objects.equals is available in android sdk >= 19
// return lhs == rhs || lhs != null && lhs.equals(rhs);
// }
//
// public static void copyStream(final InputStream is, final OutputStream os) throws IOException
// {
// final byte[] buffer = new byte[MAX_BUFFER_SIZE];
// int length;
// while ((length = is.read(buffer)) != -1) {
// os.write(buffer, 0, length);
// }
// }
//
// public static Spanned fromHtml(final String string)
// {
// return Build.VERSION.SDK_INT >= Build.VERSION_CODES.N ? Html.fromHtml(string, Html.FROM_HTML_MODE_LEGACY) : Html.fromHtml(string);
// }
//
// public static String formatMilliSeconds(final long milliSeconds)
// {
// if (milliSeconds >= 0) {
// return formatPositiveMilliSeconds(milliSeconds);
// }
//
// return '-' + formatPositiveMilliSeconds(-1 * milliSeconds);
// }
//
// private static String formatPositiveMilliSeconds(final long milliSeconds)
// {
// final SimpleDateFormat sdf = createSimpleDateFormat(milliSeconds);
// sdf.setTimeZone(TimeZone.getTimeZone("GMT+0"));
// return sdf.format(new Date(milliSeconds));
// }
//
// private static SimpleDateFormat createSimpleDateFormat(final long milliSeconds)
// {
// if (milliSeconds >= 3600000) {
// return new SimpleDateFormat("HH:mm:ss", Locale.US);
// }
//
// return new SimpleDateFormat("mm:ss", Locale.US);
// }
//
// @NonNull
// public static <T> T getSystemService(final Context context, final String name)
// {
// if (context == null) {
// throw new IllegalArgumentException("no context");
// }
//
// @SuppressWarnings("unchecked")
// final T service = (T) context.getSystemService(name);
// if (service == null) {
// throw new IllegalArgumentException("no system service matching name: " + name);
// }
// return service;
// }
// }
| import android.Manifest;
import android.app.NotificationManager;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Build;
import android.provider.Settings;
import android.text.TextUtils;
import androidx.appcompat.app.AlertDialog;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import androidx.fragment.app.FragmentActivity;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.EnumSet;
import java.util.HashSet;
import java.util.Set;
import org.simlar.R;
import org.simlar.utils.Util; | }
}
}
if (requestPermissions.isEmpty()) {
// all permissions granted
return;
}
if (rationalMessages.isEmpty()) {
listener.requestPermissions(requestPermissions);
} else {
new AlertDialog.Builder(activity)
.setMessage(TextUtils.join("\n\n", rationalMessages))
.setOnDismissListener(dialog -> listener.requestPermissions(requestPermissions))
.create().show();
}
}
public static boolean needsExternalStoragePermission(final Context context, final Uri uri)
{
if (context == null) {
return false;
}
if (uri == null) {
return false;
}
final String path = uri.getPath(); | // Path: app/src/main/java/org/simlar/utils/Util.java
// public final class Util
// {
// public static final String[] EMPTY_STRING_ARRAY = {};
// private static final int MAX_BUFFER_SIZE = 1024 * 1024;
//
// private Util()
// {
// throw new AssertionError("This class was not meant to be instantiated");
// }
//
// public static boolean isNullOrEmpty(final String string)
// {
// return string == null || string.isEmpty();
// }
//
// public static int compareString(final String lhs, final String rhs)
// {
// if (isNullOrEmpty(lhs) && isNullOrEmpty(rhs)) {
// return 0;
// }
//
// if (isNullOrEmpty(lhs)) {
// return -1;
// }
//
// if (isNullOrEmpty(rhs)) {
// return 1;
// }
//
// return lhs.compareToIgnoreCase(rhs);
// }
//
// public static boolean equalString(final String lhs, final String rhs)
// {
// return compareString(lhs, rhs) == 0;
// }
//
// public static boolean equals(final Object lhs, final Object rhs)
// {
// //noinspection EqualsReplaceableByObjectsCall,ObjectEquality /// Objects.equals is available in android sdk >= 19
// return lhs == rhs || lhs != null && lhs.equals(rhs);
// }
//
// public static void copyStream(final InputStream is, final OutputStream os) throws IOException
// {
// final byte[] buffer = new byte[MAX_BUFFER_SIZE];
// int length;
// while ((length = is.read(buffer)) != -1) {
// os.write(buffer, 0, length);
// }
// }
//
// public static Spanned fromHtml(final String string)
// {
// return Build.VERSION.SDK_INT >= Build.VERSION_CODES.N ? Html.fromHtml(string, Html.FROM_HTML_MODE_LEGACY) : Html.fromHtml(string);
// }
//
// public static String formatMilliSeconds(final long milliSeconds)
// {
// if (milliSeconds >= 0) {
// return formatPositiveMilliSeconds(milliSeconds);
// }
//
// return '-' + formatPositiveMilliSeconds(-1 * milliSeconds);
// }
//
// private static String formatPositiveMilliSeconds(final long milliSeconds)
// {
// final SimpleDateFormat sdf = createSimpleDateFormat(milliSeconds);
// sdf.setTimeZone(TimeZone.getTimeZone("GMT+0"));
// return sdf.format(new Date(milliSeconds));
// }
//
// private static SimpleDateFormat createSimpleDateFormat(final long milliSeconds)
// {
// if (milliSeconds >= 3600000) {
// return new SimpleDateFormat("HH:mm:ss", Locale.US);
// }
//
// return new SimpleDateFormat("mm:ss", Locale.US);
// }
//
// @NonNull
// public static <T> T getSystemService(final Context context, final String name)
// {
// if (context == null) {
// throw new IllegalArgumentException("no context");
// }
//
// @SuppressWarnings("unchecked")
// final T service = (T) context.getSystemService(name);
// if (service == null) {
// throw new IllegalArgumentException("no system service matching name: " + name);
// }
// return service;
// }
// }
// Path: app/src/main/java/org/simlar/helper/PermissionsHelper.java
import android.Manifest;
import android.app.NotificationManager;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Build;
import android.provider.Settings;
import android.text.TextUtils;
import androidx.appcompat.app.AlertDialog;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import androidx.fragment.app.FragmentActivity;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.EnumSet;
import java.util.HashSet;
import java.util.Set;
import org.simlar.R;
import org.simlar.utils.Util;
}
}
}
if (requestPermissions.isEmpty()) {
// all permissions granted
return;
}
if (rationalMessages.isEmpty()) {
listener.requestPermissions(requestPermissions);
} else {
new AlertDialog.Builder(activity)
.setMessage(TextUtils.join("\n\n", rationalMessages))
.setOnDismissListener(dialog -> listener.requestPermissions(requestPermissions))
.create().show();
}
}
public static boolean needsExternalStoragePermission(final Context context, final Uri uri)
{
if (context == null) {
return false;
}
if (uri == null) {
return false;
}
final String path = uri.getPath(); | if (Util.isNullOrEmpty(path)) { |
simlar/simlar-android | app/src/main/java/org/simlar/helper/ContactDataComplete.java | // Path: app/src/main/java/org/simlar/utils/Util.java
// public final class Util
// {
// public static final String[] EMPTY_STRING_ARRAY = {};
// private static final int MAX_BUFFER_SIZE = 1024 * 1024;
//
// private Util()
// {
// throw new AssertionError("This class was not meant to be instantiated");
// }
//
// public static boolean isNullOrEmpty(final String string)
// {
// return string == null || string.isEmpty();
// }
//
// public static int compareString(final String lhs, final String rhs)
// {
// if (isNullOrEmpty(lhs) && isNullOrEmpty(rhs)) {
// return 0;
// }
//
// if (isNullOrEmpty(lhs)) {
// return -1;
// }
//
// if (isNullOrEmpty(rhs)) {
// return 1;
// }
//
// return lhs.compareToIgnoreCase(rhs);
// }
//
// public static boolean equalString(final String lhs, final String rhs)
// {
// return compareString(lhs, rhs) == 0;
// }
//
// public static boolean equals(final Object lhs, final Object rhs)
// {
// //noinspection EqualsReplaceableByObjectsCall,ObjectEquality /// Objects.equals is available in android sdk >= 19
// return lhs == rhs || lhs != null && lhs.equals(rhs);
// }
//
// public static void copyStream(final InputStream is, final OutputStream os) throws IOException
// {
// final byte[] buffer = new byte[MAX_BUFFER_SIZE];
// int length;
// while ((length = is.read(buffer)) != -1) {
// os.write(buffer, 0, length);
// }
// }
//
// public static Spanned fromHtml(final String string)
// {
// return Build.VERSION.SDK_INT >= Build.VERSION_CODES.N ? Html.fromHtml(string, Html.FROM_HTML_MODE_LEGACY) : Html.fromHtml(string);
// }
//
// public static String formatMilliSeconds(final long milliSeconds)
// {
// if (milliSeconds >= 0) {
// return formatPositiveMilliSeconds(milliSeconds);
// }
//
// return '-' + formatPositiveMilliSeconds(-1 * milliSeconds);
// }
//
// private static String formatPositiveMilliSeconds(final long milliSeconds)
// {
// final SimpleDateFormat sdf = createSimpleDateFormat(milliSeconds);
// sdf.setTimeZone(TimeZone.getTimeZone("GMT+0"));
// return sdf.format(new Date(milliSeconds));
// }
//
// private static SimpleDateFormat createSimpleDateFormat(final long milliSeconds)
// {
// if (milliSeconds >= 3600000) {
// return new SimpleDateFormat("HH:mm:ss", Locale.US);
// }
//
// return new SimpleDateFormat("mm:ss", Locale.US);
// }
//
// @NonNull
// public static <T> T getSystemService(final Context context, final String name)
// {
// if (context == null) {
// throw new IllegalArgumentException("no context");
// }
//
// @SuppressWarnings("unchecked")
// final T service = (T) context.getSystemService(name);
// if (service == null) {
// throw new IllegalArgumentException("no system service matching name: " + name);
// }
// return service;
// }
// }
| import org.simlar.utils.Util; | /*
* Copyright (C) 2013 - 2015 The Simlar Authors.
*
* This file is part of Simlar. (https://www.simlar.org)
*
* This program 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 2
* of the License, or (at your option) any later version.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
package org.simlar.helper;
public final class ContactDataComplete extends ContactData
{
public final String simlarId;
public ContactDataComplete(final String simlarId, final ContactData cd)
{
super(cd.name, cd.guiTelephoneNumber, cd.status, cd.photoId);
this.simlarId = simlarId;
}
public String getNameOrNumber()
{ | // Path: app/src/main/java/org/simlar/utils/Util.java
// public final class Util
// {
// public static final String[] EMPTY_STRING_ARRAY = {};
// private static final int MAX_BUFFER_SIZE = 1024 * 1024;
//
// private Util()
// {
// throw new AssertionError("This class was not meant to be instantiated");
// }
//
// public static boolean isNullOrEmpty(final String string)
// {
// return string == null || string.isEmpty();
// }
//
// public static int compareString(final String lhs, final String rhs)
// {
// if (isNullOrEmpty(lhs) && isNullOrEmpty(rhs)) {
// return 0;
// }
//
// if (isNullOrEmpty(lhs)) {
// return -1;
// }
//
// if (isNullOrEmpty(rhs)) {
// return 1;
// }
//
// return lhs.compareToIgnoreCase(rhs);
// }
//
// public static boolean equalString(final String lhs, final String rhs)
// {
// return compareString(lhs, rhs) == 0;
// }
//
// public static boolean equals(final Object lhs, final Object rhs)
// {
// //noinspection EqualsReplaceableByObjectsCall,ObjectEquality /// Objects.equals is available in android sdk >= 19
// return lhs == rhs || lhs != null && lhs.equals(rhs);
// }
//
// public static void copyStream(final InputStream is, final OutputStream os) throws IOException
// {
// final byte[] buffer = new byte[MAX_BUFFER_SIZE];
// int length;
// while ((length = is.read(buffer)) != -1) {
// os.write(buffer, 0, length);
// }
// }
//
// public static Spanned fromHtml(final String string)
// {
// return Build.VERSION.SDK_INT >= Build.VERSION_CODES.N ? Html.fromHtml(string, Html.FROM_HTML_MODE_LEGACY) : Html.fromHtml(string);
// }
//
// public static String formatMilliSeconds(final long milliSeconds)
// {
// if (milliSeconds >= 0) {
// return formatPositiveMilliSeconds(milliSeconds);
// }
//
// return '-' + formatPositiveMilliSeconds(-1 * milliSeconds);
// }
//
// private static String formatPositiveMilliSeconds(final long milliSeconds)
// {
// final SimpleDateFormat sdf = createSimpleDateFormat(milliSeconds);
// sdf.setTimeZone(TimeZone.getTimeZone("GMT+0"));
// return sdf.format(new Date(milliSeconds));
// }
//
// private static SimpleDateFormat createSimpleDateFormat(final long milliSeconds)
// {
// if (milliSeconds >= 3600000) {
// return new SimpleDateFormat("HH:mm:ss", Locale.US);
// }
//
// return new SimpleDateFormat("mm:ss", Locale.US);
// }
//
// @NonNull
// public static <T> T getSystemService(final Context context, final String name)
// {
// if (context == null) {
// throw new IllegalArgumentException("no context");
// }
//
// @SuppressWarnings("unchecked")
// final T service = (T) context.getSystemService(name);
// if (service == null) {
// throw new IllegalArgumentException("no system service matching name: " + name);
// }
// return service;
// }
// }
// Path: app/src/main/java/org/simlar/helper/ContactDataComplete.java
import org.simlar.utils.Util;
/*
* Copyright (C) 2013 - 2015 The Simlar Authors.
*
* This file is part of Simlar. (https://www.simlar.org)
*
* This program 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 2
* of the License, or (at your option) any later version.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
package org.simlar.helper;
public final class ContactDataComplete extends ContactData
{
public final String simlarId;
public ContactDataComplete(final String simlarId, final ContactData cd)
{
super(cd.name, cd.guiTelephoneNumber, cd.status, cd.photoId);
this.simlarId = simlarId;
}
public String getNameOrNumber()
{ | if (Util.isNullOrEmpty(name)) { |
simlar/simlar-android | app/src/main/java/org/simlar/logging/Lg.java | // Path: app/src/main/java/org/simlar/utils/Util.java
// public final class Util
// {
// public static final String[] EMPTY_STRING_ARRAY = {};
// private static final int MAX_BUFFER_SIZE = 1024 * 1024;
//
// private Util()
// {
// throw new AssertionError("This class was not meant to be instantiated");
// }
//
// public static boolean isNullOrEmpty(final String string)
// {
// return string == null || string.isEmpty();
// }
//
// public static int compareString(final String lhs, final String rhs)
// {
// if (isNullOrEmpty(lhs) && isNullOrEmpty(rhs)) {
// return 0;
// }
//
// if (isNullOrEmpty(lhs)) {
// return -1;
// }
//
// if (isNullOrEmpty(rhs)) {
// return 1;
// }
//
// return lhs.compareToIgnoreCase(rhs);
// }
//
// public static boolean equalString(final String lhs, final String rhs)
// {
// return compareString(lhs, rhs) == 0;
// }
//
// public static boolean equals(final Object lhs, final Object rhs)
// {
// //noinspection EqualsReplaceableByObjectsCall,ObjectEquality /// Objects.equals is available in android sdk >= 19
// return lhs == rhs || lhs != null && lhs.equals(rhs);
// }
//
// public static void copyStream(final InputStream is, final OutputStream os) throws IOException
// {
// final byte[] buffer = new byte[MAX_BUFFER_SIZE];
// int length;
// while ((length = is.read(buffer)) != -1) {
// os.write(buffer, 0, length);
// }
// }
//
// public static Spanned fromHtml(final String string)
// {
// return Build.VERSION.SDK_INT >= Build.VERSION_CODES.N ? Html.fromHtml(string, Html.FROM_HTML_MODE_LEGACY) : Html.fromHtml(string);
// }
//
// public static String formatMilliSeconds(final long milliSeconds)
// {
// if (milliSeconds >= 0) {
// return formatPositiveMilliSeconds(milliSeconds);
// }
//
// return '-' + formatPositiveMilliSeconds(-1 * milliSeconds);
// }
//
// private static String formatPositiveMilliSeconds(final long milliSeconds)
// {
// final SimpleDateFormat sdf = createSimpleDateFormat(milliSeconds);
// sdf.setTimeZone(TimeZone.getTimeZone("GMT+0"));
// return sdf.format(new Date(milliSeconds));
// }
//
// private static SimpleDateFormat createSimpleDateFormat(final long milliSeconds)
// {
// if (milliSeconds >= 3600000) {
// return new SimpleDateFormat("HH:mm:ss", Locale.US);
// }
//
// return new SimpleDateFormat("mm:ss", Locale.US);
// }
//
// @NonNull
// public static <T> T getSystemService(final Context context, final String name)
// {
// if (context == null) {
// throw new IllegalArgumentException("no context");
// }
//
// @SuppressWarnings("unchecked")
// final T service = (T) context.getSystemService(name);
// if (service == null) {
// throw new IllegalArgumentException("no system service matching name: " + name);
// }
// return service;
// }
// }
| import android.util.Log;
import androidx.annotation.NonNull;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.Arrays;
import org.simlar.utils.Util; | }
private static String createEqualSizedTag(final String prefix, final String tag, final String postfix)
{
final int size = TAG_SIZE_MAX - length(prefix) - length(postfix);
final StringBuilder tagBuilder = new StringBuilder();
if (prefix != null) {
tagBuilder.append(prefix);
}
final int beginIndex = Math.max(tag.length() - size, 0);
tagBuilder.append(tag.substring(beginIndex));
if (postfix != null) {
tagBuilder.append(postfix);
}
final char[] padding = new char[Math.max(size - tag.length(), 0)];
Arrays.fill(padding, '.');
tagBuilder.append(padding);
return tagBuilder.toString();
}
private static int length(final String str)
{
return str == null ? 0 : str.length();
}
private static String anonymize(final String string)
{ | // Path: app/src/main/java/org/simlar/utils/Util.java
// public final class Util
// {
// public static final String[] EMPTY_STRING_ARRAY = {};
// private static final int MAX_BUFFER_SIZE = 1024 * 1024;
//
// private Util()
// {
// throw new AssertionError("This class was not meant to be instantiated");
// }
//
// public static boolean isNullOrEmpty(final String string)
// {
// return string == null || string.isEmpty();
// }
//
// public static int compareString(final String lhs, final String rhs)
// {
// if (isNullOrEmpty(lhs) && isNullOrEmpty(rhs)) {
// return 0;
// }
//
// if (isNullOrEmpty(lhs)) {
// return -1;
// }
//
// if (isNullOrEmpty(rhs)) {
// return 1;
// }
//
// return lhs.compareToIgnoreCase(rhs);
// }
//
// public static boolean equalString(final String lhs, final String rhs)
// {
// return compareString(lhs, rhs) == 0;
// }
//
// public static boolean equals(final Object lhs, final Object rhs)
// {
// //noinspection EqualsReplaceableByObjectsCall,ObjectEquality /// Objects.equals is available in android sdk >= 19
// return lhs == rhs || lhs != null && lhs.equals(rhs);
// }
//
// public static void copyStream(final InputStream is, final OutputStream os) throws IOException
// {
// final byte[] buffer = new byte[MAX_BUFFER_SIZE];
// int length;
// while ((length = is.read(buffer)) != -1) {
// os.write(buffer, 0, length);
// }
// }
//
// public static Spanned fromHtml(final String string)
// {
// return Build.VERSION.SDK_INT >= Build.VERSION_CODES.N ? Html.fromHtml(string, Html.FROM_HTML_MODE_LEGACY) : Html.fromHtml(string);
// }
//
// public static String formatMilliSeconds(final long milliSeconds)
// {
// if (milliSeconds >= 0) {
// return formatPositiveMilliSeconds(milliSeconds);
// }
//
// return '-' + formatPositiveMilliSeconds(-1 * milliSeconds);
// }
//
// private static String formatPositiveMilliSeconds(final long milliSeconds)
// {
// final SimpleDateFormat sdf = createSimpleDateFormat(milliSeconds);
// sdf.setTimeZone(TimeZone.getTimeZone("GMT+0"));
// return sdf.format(new Date(milliSeconds));
// }
//
// private static SimpleDateFormat createSimpleDateFormat(final long milliSeconds)
// {
// if (milliSeconds >= 3600000) {
// return new SimpleDateFormat("HH:mm:ss", Locale.US);
// }
//
// return new SimpleDateFormat("mm:ss", Locale.US);
// }
//
// @NonNull
// public static <T> T getSystemService(final Context context, final String name)
// {
// if (context == null) {
// throw new IllegalArgumentException("no context");
// }
//
// @SuppressWarnings("unchecked")
// final T service = (T) context.getSystemService(name);
// if (service == null) {
// throw new IllegalArgumentException("no system service matching name: " + name);
// }
// return service;
// }
// }
// Path: app/src/main/java/org/simlar/logging/Lg.java
import android.util.Log;
import androidx.annotation.NonNull;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.Arrays;
import org.simlar.utils.Util;
}
private static String createEqualSizedTag(final String prefix, final String tag, final String postfix)
{
final int size = TAG_SIZE_MAX - length(prefix) - length(postfix);
final StringBuilder tagBuilder = new StringBuilder();
if (prefix != null) {
tagBuilder.append(prefix);
}
final int beginIndex = Math.max(tag.length() - size, 0);
tagBuilder.append(tag.substring(beginIndex));
if (postfix != null) {
tagBuilder.append(postfix);
}
final char[] padding = new char[Math.max(size - tag.length(), 0)];
Arrays.fill(padding, '.');
tagBuilder.append(padding);
return tagBuilder.toString();
}
private static int length(final String str)
{
return str == null ? 0 : str.length();
}
private static String anonymize(final String string)
{ | if (Util.isNullOrEmpty(string)) { |
simlar/simlar-android | app/src/main/java/org/simlar/helper/CallConnectionDetails.java | // Path: app/src/main/java/org/simlar/utils/Util.java
// public final class Util
// {
// public static final String[] EMPTY_STRING_ARRAY = {};
// private static final int MAX_BUFFER_SIZE = 1024 * 1024;
//
// private Util()
// {
// throw new AssertionError("This class was not meant to be instantiated");
// }
//
// public static boolean isNullOrEmpty(final String string)
// {
// return string == null || string.isEmpty();
// }
//
// public static int compareString(final String lhs, final String rhs)
// {
// if (isNullOrEmpty(lhs) && isNullOrEmpty(rhs)) {
// return 0;
// }
//
// if (isNullOrEmpty(lhs)) {
// return -1;
// }
//
// if (isNullOrEmpty(rhs)) {
// return 1;
// }
//
// return lhs.compareToIgnoreCase(rhs);
// }
//
// public static boolean equalString(final String lhs, final String rhs)
// {
// return compareString(lhs, rhs) == 0;
// }
//
// public static boolean equals(final Object lhs, final Object rhs)
// {
// //noinspection EqualsReplaceableByObjectsCall,ObjectEquality /// Objects.equals is available in android sdk >= 19
// return lhs == rhs || lhs != null && lhs.equals(rhs);
// }
//
// public static void copyStream(final InputStream is, final OutputStream os) throws IOException
// {
// final byte[] buffer = new byte[MAX_BUFFER_SIZE];
// int length;
// while ((length = is.read(buffer)) != -1) {
// os.write(buffer, 0, length);
// }
// }
//
// public static Spanned fromHtml(final String string)
// {
// return Build.VERSION.SDK_INT >= Build.VERSION_CODES.N ? Html.fromHtml(string, Html.FROM_HTML_MODE_LEGACY) : Html.fromHtml(string);
// }
//
// public static String formatMilliSeconds(final long milliSeconds)
// {
// if (milliSeconds >= 0) {
// return formatPositiveMilliSeconds(milliSeconds);
// }
//
// return '-' + formatPositiveMilliSeconds(-1 * milliSeconds);
// }
//
// private static String formatPositiveMilliSeconds(final long milliSeconds)
// {
// final SimpleDateFormat sdf = createSimpleDateFormat(milliSeconds);
// sdf.setTimeZone(TimeZone.getTimeZone("GMT+0"));
// return sdf.format(new Date(milliSeconds));
// }
//
// private static SimpleDateFormat createSimpleDateFormat(final long milliSeconds)
// {
// if (milliSeconds >= 3600000) {
// return new SimpleDateFormat("HH:mm:ss", Locale.US);
// }
//
// return new SimpleDateFormat("mm:ss", Locale.US);
// }
//
// @NonNull
// public static <T> T getSystemService(final Context context, final String name)
// {
// if (context == null) {
// throw new IllegalArgumentException("no context");
// }
//
// @SuppressWarnings("unchecked")
// final T service = (T) context.getSystemService(name);
// if (service == null) {
// throw new IllegalArgumentException("no system service matching name: " + name);
// }
// return service;
// }
// }
| import java.text.DecimalFormat;
import org.simlar.utils.Util;
import androidx.annotation.NonNull; | /**
* Copyright (C) 2013 The Simlar Authors.
*
* This file is part of Simlar. (https://www.simlar.org)
*
* This program 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 2
* of the License, or (at your option) any later version.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package org.simlar.helper;
public final class CallConnectionDetails
{
private static final DecimalFormat GUI_VALUE = new DecimalFormat("#0.0");
private NetworkQuality mQuality = NetworkQuality.UNKNOWN;
private String mCodec = null;
private String mIceState = null;
private int mUpload = -1;
private int mDownload = -1;
private int mJitter = -1;
private int mPacketLoss = -1;
private long mLatePackets = -1;
private int mRoundTripDelay = -1;
private boolean mEndedCall = false;
public boolean updateCallStats(final NetworkQuality quality, final String codec, final String iceState, final int upload, final int download,
final int jitter, final int packetLoss, final long latePackets, final int roundTripDelay)
{ | // Path: app/src/main/java/org/simlar/utils/Util.java
// public final class Util
// {
// public static final String[] EMPTY_STRING_ARRAY = {};
// private static final int MAX_BUFFER_SIZE = 1024 * 1024;
//
// private Util()
// {
// throw new AssertionError("This class was not meant to be instantiated");
// }
//
// public static boolean isNullOrEmpty(final String string)
// {
// return string == null || string.isEmpty();
// }
//
// public static int compareString(final String lhs, final String rhs)
// {
// if (isNullOrEmpty(lhs) && isNullOrEmpty(rhs)) {
// return 0;
// }
//
// if (isNullOrEmpty(lhs)) {
// return -1;
// }
//
// if (isNullOrEmpty(rhs)) {
// return 1;
// }
//
// return lhs.compareToIgnoreCase(rhs);
// }
//
// public static boolean equalString(final String lhs, final String rhs)
// {
// return compareString(lhs, rhs) == 0;
// }
//
// public static boolean equals(final Object lhs, final Object rhs)
// {
// //noinspection EqualsReplaceableByObjectsCall,ObjectEquality /// Objects.equals is available in android sdk >= 19
// return lhs == rhs || lhs != null && lhs.equals(rhs);
// }
//
// public static void copyStream(final InputStream is, final OutputStream os) throws IOException
// {
// final byte[] buffer = new byte[MAX_BUFFER_SIZE];
// int length;
// while ((length = is.read(buffer)) != -1) {
// os.write(buffer, 0, length);
// }
// }
//
// public static Spanned fromHtml(final String string)
// {
// return Build.VERSION.SDK_INT >= Build.VERSION_CODES.N ? Html.fromHtml(string, Html.FROM_HTML_MODE_LEGACY) : Html.fromHtml(string);
// }
//
// public static String formatMilliSeconds(final long milliSeconds)
// {
// if (milliSeconds >= 0) {
// return formatPositiveMilliSeconds(milliSeconds);
// }
//
// return '-' + formatPositiveMilliSeconds(-1 * milliSeconds);
// }
//
// private static String formatPositiveMilliSeconds(final long milliSeconds)
// {
// final SimpleDateFormat sdf = createSimpleDateFormat(milliSeconds);
// sdf.setTimeZone(TimeZone.getTimeZone("GMT+0"));
// return sdf.format(new Date(milliSeconds));
// }
//
// private static SimpleDateFormat createSimpleDateFormat(final long milliSeconds)
// {
// if (milliSeconds >= 3600000) {
// return new SimpleDateFormat("HH:mm:ss", Locale.US);
// }
//
// return new SimpleDateFormat("mm:ss", Locale.US);
// }
//
// @NonNull
// public static <T> T getSystemService(final Context context, final String name)
// {
// if (context == null) {
// throw new IllegalArgumentException("no context");
// }
//
// @SuppressWarnings("unchecked")
// final T service = (T) context.getSystemService(name);
// if (service == null) {
// throw new IllegalArgumentException("no system service matching name: " + name);
// }
// return service;
// }
// }
// Path: app/src/main/java/org/simlar/helper/CallConnectionDetails.java
import java.text.DecimalFormat;
import org.simlar.utils.Util;
import androidx.annotation.NonNull;
/**
* Copyright (C) 2013 The Simlar Authors.
*
* This file is part of Simlar. (https://www.simlar.org)
*
* This program 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 2
* of the License, or (at your option) any later version.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package org.simlar.helper;
public final class CallConnectionDetails
{
private static final DecimalFormat GUI_VALUE = new DecimalFormat("#0.0");
private NetworkQuality mQuality = NetworkQuality.UNKNOWN;
private String mCodec = null;
private String mIceState = null;
private int mUpload = -1;
private int mDownload = -1;
private int mJitter = -1;
private int mPacketLoss = -1;
private long mLatePackets = -1;
private int mRoundTripDelay = -1;
private boolean mEndedCall = false;
public boolean updateCallStats(final NetworkQuality quality, final String codec, final String iceState, final int upload, final int download,
final int jitter, final int packetLoss, final long latePackets, final int roundTripDelay)
{ | if (quality == mQuality && Util.equalString(codec, mCodec) && Util.equalString(iceState, mIceState) |
simlar/simlar-android | app/src/main/java/org/simlar/widgets/ContactsAdapter.java | // Path: app/src/main/java/org/simlar/helper/ContactDataComplete.java
// public final class ContactDataComplete extends ContactData
// {
// public final String simlarId;
//
// public ContactDataComplete(final String simlarId, final ContactData cd)
// {
// super(cd.name, cd.guiTelephoneNumber, cd.status, cd.photoId);
// this.simlarId = simlarId;
// }
//
// public String getNameOrNumber()
// {
// if (Util.isNullOrEmpty(name)) {
// return simlarId;
// }
//
// return name;
// }
//
// public char getFirstChar()
// {
// final String nameOrNumber = getNameOrNumber();
// return Util.isNullOrEmpty(nameOrNumber) ? ' ' : Character.toTitleCase(nameOrNumber.charAt(0));
// }
// }
//
// Path: app/src/main/java/org/simlar/utils/Util.java
// public final class Util
// {
// public static final String[] EMPTY_STRING_ARRAY = {};
// private static final int MAX_BUFFER_SIZE = 1024 * 1024;
//
// private Util()
// {
// throw new AssertionError("This class was not meant to be instantiated");
// }
//
// public static boolean isNullOrEmpty(final String string)
// {
// return string == null || string.isEmpty();
// }
//
// public static int compareString(final String lhs, final String rhs)
// {
// if (isNullOrEmpty(lhs) && isNullOrEmpty(rhs)) {
// return 0;
// }
//
// if (isNullOrEmpty(lhs)) {
// return -1;
// }
//
// if (isNullOrEmpty(rhs)) {
// return 1;
// }
//
// return lhs.compareToIgnoreCase(rhs);
// }
//
// public static boolean equalString(final String lhs, final String rhs)
// {
// return compareString(lhs, rhs) == 0;
// }
//
// public static boolean equals(final Object lhs, final Object rhs)
// {
// //noinspection EqualsReplaceableByObjectsCall,ObjectEquality /// Objects.equals is available in android sdk >= 19
// return lhs == rhs || lhs != null && lhs.equals(rhs);
// }
//
// public static void copyStream(final InputStream is, final OutputStream os) throws IOException
// {
// final byte[] buffer = new byte[MAX_BUFFER_SIZE];
// int length;
// while ((length = is.read(buffer)) != -1) {
// os.write(buffer, 0, length);
// }
// }
//
// public static Spanned fromHtml(final String string)
// {
// return Build.VERSION.SDK_INT >= Build.VERSION_CODES.N ? Html.fromHtml(string, Html.FROM_HTML_MODE_LEGACY) : Html.fromHtml(string);
// }
//
// public static String formatMilliSeconds(final long milliSeconds)
// {
// if (milliSeconds >= 0) {
// return formatPositiveMilliSeconds(milliSeconds);
// }
//
// return '-' + formatPositiveMilliSeconds(-1 * milliSeconds);
// }
//
// private static String formatPositiveMilliSeconds(final long milliSeconds)
// {
// final SimpleDateFormat sdf = createSimpleDateFormat(milliSeconds);
// sdf.setTimeZone(TimeZone.getTimeZone("GMT+0"));
// return sdf.format(new Date(milliSeconds));
// }
//
// private static SimpleDateFormat createSimpleDateFormat(final long milliSeconds)
// {
// if (milliSeconds >= 3600000) {
// return new SimpleDateFormat("HH:mm:ss", Locale.US);
// }
//
// return new SimpleDateFormat("mm:ss", Locale.US);
// }
//
// @NonNull
// public static <T> T getSystemService(final Context context, final String name)
// {
// if (context == null) {
// throw new IllegalArgumentException("no context");
// }
//
// @SuppressWarnings("unchecked")
// final T service = (T) context.getSystemService(name);
// if (service == null) {
// throw new IllegalArgumentException("no system service matching name: " + name);
// }
// return service;
// }
// }
| import java.io.Serializable;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Set;
import org.simlar.R;
import org.simlar.helper.ContactDataComplete;
import org.simlar.utils.Util;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable; | /**
* Copyright (C) 2013 The Simlar Authors.
*
* This file is part of Simlar. (https://www.simlar.org)
*
* This program 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 2
* of the License, or (at your option) any later version.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package org.simlar.widgets;
final class ContactsAdapter extends ArrayAdapter<ContactDataComplete>
{
private final int mLayout;
private final LayoutInflater mInflater;
private static final class SortByName implements Comparator<ContactDataComplete>, Serializable
{
private static final long serialVersionUID = 1;
@Override
public int compare(final ContactDataComplete lhs, final ContactDataComplete rhs)
{
if (lhs == null && rhs == null) {
return 0;
}
if (lhs == null) {
return -1;
}
if (rhs == null) {
return 1;
}
| // Path: app/src/main/java/org/simlar/helper/ContactDataComplete.java
// public final class ContactDataComplete extends ContactData
// {
// public final String simlarId;
//
// public ContactDataComplete(final String simlarId, final ContactData cd)
// {
// super(cd.name, cd.guiTelephoneNumber, cd.status, cd.photoId);
// this.simlarId = simlarId;
// }
//
// public String getNameOrNumber()
// {
// if (Util.isNullOrEmpty(name)) {
// return simlarId;
// }
//
// return name;
// }
//
// public char getFirstChar()
// {
// final String nameOrNumber = getNameOrNumber();
// return Util.isNullOrEmpty(nameOrNumber) ? ' ' : Character.toTitleCase(nameOrNumber.charAt(0));
// }
// }
//
// Path: app/src/main/java/org/simlar/utils/Util.java
// public final class Util
// {
// public static final String[] EMPTY_STRING_ARRAY = {};
// private static final int MAX_BUFFER_SIZE = 1024 * 1024;
//
// private Util()
// {
// throw new AssertionError("This class was not meant to be instantiated");
// }
//
// public static boolean isNullOrEmpty(final String string)
// {
// return string == null || string.isEmpty();
// }
//
// public static int compareString(final String lhs, final String rhs)
// {
// if (isNullOrEmpty(lhs) && isNullOrEmpty(rhs)) {
// return 0;
// }
//
// if (isNullOrEmpty(lhs)) {
// return -1;
// }
//
// if (isNullOrEmpty(rhs)) {
// return 1;
// }
//
// return lhs.compareToIgnoreCase(rhs);
// }
//
// public static boolean equalString(final String lhs, final String rhs)
// {
// return compareString(lhs, rhs) == 0;
// }
//
// public static boolean equals(final Object lhs, final Object rhs)
// {
// //noinspection EqualsReplaceableByObjectsCall,ObjectEquality /// Objects.equals is available in android sdk >= 19
// return lhs == rhs || lhs != null && lhs.equals(rhs);
// }
//
// public static void copyStream(final InputStream is, final OutputStream os) throws IOException
// {
// final byte[] buffer = new byte[MAX_BUFFER_SIZE];
// int length;
// while ((length = is.read(buffer)) != -1) {
// os.write(buffer, 0, length);
// }
// }
//
// public static Spanned fromHtml(final String string)
// {
// return Build.VERSION.SDK_INT >= Build.VERSION_CODES.N ? Html.fromHtml(string, Html.FROM_HTML_MODE_LEGACY) : Html.fromHtml(string);
// }
//
// public static String formatMilliSeconds(final long milliSeconds)
// {
// if (milliSeconds >= 0) {
// return formatPositiveMilliSeconds(milliSeconds);
// }
//
// return '-' + formatPositiveMilliSeconds(-1 * milliSeconds);
// }
//
// private static String formatPositiveMilliSeconds(final long milliSeconds)
// {
// final SimpleDateFormat sdf = createSimpleDateFormat(milliSeconds);
// sdf.setTimeZone(TimeZone.getTimeZone("GMT+0"));
// return sdf.format(new Date(milliSeconds));
// }
//
// private static SimpleDateFormat createSimpleDateFormat(final long milliSeconds)
// {
// if (milliSeconds >= 3600000) {
// return new SimpleDateFormat("HH:mm:ss", Locale.US);
// }
//
// return new SimpleDateFormat("mm:ss", Locale.US);
// }
//
// @NonNull
// public static <T> T getSystemService(final Context context, final String name)
// {
// if (context == null) {
// throw new IllegalArgumentException("no context");
// }
//
// @SuppressWarnings("unchecked")
// final T service = (T) context.getSystemService(name);
// if (service == null) {
// throw new IllegalArgumentException("no system service matching name: " + name);
// }
// return service;
// }
// }
// Path: app/src/main/java/org/simlar/widgets/ContactsAdapter.java
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Set;
import org.simlar.R;
import org.simlar.helper.ContactDataComplete;
import org.simlar.utils.Util;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
/**
* Copyright (C) 2013 The Simlar Authors.
*
* This file is part of Simlar. (https://www.simlar.org)
*
* This program 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 2
* of the License, or (at your option) any later version.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package org.simlar.widgets;
final class ContactsAdapter extends ArrayAdapter<ContactDataComplete>
{
private final int mLayout;
private final LayoutInflater mInflater;
private static final class SortByName implements Comparator<ContactDataComplete>, Serializable
{
private static final long serialVersionUID = 1;
@Override
public int compare(final ContactDataComplete lhs, final ContactDataComplete rhs)
{
if (lhs == null && rhs == null) {
return 0;
}
if (lhs == null) {
return -1;
}
if (rhs == null) {
return 1;
}
| final int retVal = Util.compareString(lhs.name, rhs.name); |
simlar/simlar-android | app/src/main/java/org/simlar/service/liblinphone/LinphoneManagerListener.java | // Path: app/src/main/java/org/simlar/helper/CallEndReason.java
// public enum CallEndReason
// {
// NONE,
// DECLINED,
// OFFLINE,
// UNSUPPORTED_MEDIA,
// BUSY,
// SERVER_CONNECTION_TIMEOUT;
//
// public static CallEndReason fromReason(final Reason reason)
// {
// if (reason == null) {
// return NONE;
// }
//
// switch (reason) {
// case Declined:
// return DECLINED;
// case NotFound:
// return OFFLINE;
// case NotImplemented:
// case NotAcceptable:
// case UnsupportedContent:
// return UNSUPPORTED_MEDIA;
// case Busy:
// return BUSY;
// case Transferred:
// case BadEvent:
// case SessionIntervalTooSmall:
// case None:
// case NoResponse:
// case Forbidden:
// case NotAnswered:
// case IOError:
// case DoNotDisturb:
// case Unauthorized:
// case NoMatch:
// case MovedPermanently:
// case Gone:
// case TemporarilyUnavailable:
// case AddressIncomplete:
// case BadGateway:
// case ServerTimeout:
// case Unknown:
// default:
// return NONE;
// }
// }
//
// public int getDisplayMessageId()
// {
// switch (this) {
// case DECLINED:
// return R.string.call_activity_call_ended_because_declined;
// case OFFLINE:
// return R.string.call_activity_call_ended_because_user_offline;
// case UNSUPPORTED_MEDIA:
// return R.string.call_activity_call_ended_because_incompatible_media;
// case BUSY:
// return R.string.call_activity_call_ended_because_user_busy;
// case SERVER_CONNECTION_TIMEOUT:
// return R.string.call_activity_connecting_to_server_timed_out;
// case NONE:
// default:
// return R.string.call_activity_call_ended_normally;
// }
// }
// }
//
// Path: app/src/main/java/org/simlar/helper/NetworkQuality.java
// public enum NetworkQuality
// {
// UNKNOWN,
// GOOD,
// AVERAGE,
// POOR,
// VERY_POOR,
// UNUSABLE;
//
// public static NetworkQuality fromFloat(final float quality)
// {
// if (4 <= quality && quality <= 5) {
// return GOOD;
// }
//
// if (3 <= quality && quality < 4) {
// return AVERAGE;
// }
//
// if (2 <= quality && quality < 3) {
// return POOR;
// }
//
// if (1 <= quality && quality < 2) {
// return VERY_POOR;
// }
//
// if (0 <= quality && quality < 1) {
// return UNUSABLE;
// }
//
// return UNKNOWN;
// }
//
// public int getDescription()
// {
// switch (this) {
// case GOOD:
// return R.string.network_quality_good;
// case AVERAGE:
// return R.string.network_quality_average;
// case POOR:
// return R.string.network_quality_poor;
// case VERY_POOR:
// return R.string.network_quality_very_poor;
// case UNUSABLE:
// return R.string.network_quality_unusable;
// case UNKNOWN:
// default:
// return R.string.network_quality_unknown;
// }
// }
//
// public boolean isKnown()
// {
// return this != UNKNOWN;
// }
// }
//
// Path: app/src/main/java/org/simlar/helper/VideoState.java
// public enum VideoState
// {
// OFF,
// REQUESTING,
// REMOTE_REQUESTED,
// DENIED,
// ACCEPTED,
// INITIALIZING,
// PLAYING
// }
//
// Path: app/src/main/java/org/simlar/service/AudioOutputType.java
// public enum AudioOutputType
// {
// PHONE(R.string.audio_output_type_phone),
// WIRED_HEADSET(R.string.audio_output_type_wired_headset),
// SPEAKER(R.string.audio_output_type_speaker),
// BLUETOOTH(R.string.audio_output_type_bluetooth);
//
// private final int mResourceId;
//
// AudioOutputType(final int resourceId)
// {
// mResourceId = resourceId;
// }
//
// public String toDisplayName(final Context context)
// {
// return context.getString(mResourceId);
// }
// }
| import java.util.Set;
import org.linphone.core.Call.State;
import org.linphone.core.RegistrationState;
import org.simlar.helper.CallEndReason;
import org.simlar.helper.NetworkQuality;
import org.simlar.helper.VideoState;
import org.simlar.service.AudioOutputType; | /**
* Copyright (C) 2013 The Simlar Authors.
*
* This file is part of Simlar. (https://www.simlar.org)
*
* This program 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 2
* of the License, or (at your option) any later version.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package org.simlar.service.liblinphone;
public interface LinphoneManagerListener
{
void onRegistrationStateChanged(final RegistrationState state);
| // Path: app/src/main/java/org/simlar/helper/CallEndReason.java
// public enum CallEndReason
// {
// NONE,
// DECLINED,
// OFFLINE,
// UNSUPPORTED_MEDIA,
// BUSY,
// SERVER_CONNECTION_TIMEOUT;
//
// public static CallEndReason fromReason(final Reason reason)
// {
// if (reason == null) {
// return NONE;
// }
//
// switch (reason) {
// case Declined:
// return DECLINED;
// case NotFound:
// return OFFLINE;
// case NotImplemented:
// case NotAcceptable:
// case UnsupportedContent:
// return UNSUPPORTED_MEDIA;
// case Busy:
// return BUSY;
// case Transferred:
// case BadEvent:
// case SessionIntervalTooSmall:
// case None:
// case NoResponse:
// case Forbidden:
// case NotAnswered:
// case IOError:
// case DoNotDisturb:
// case Unauthorized:
// case NoMatch:
// case MovedPermanently:
// case Gone:
// case TemporarilyUnavailable:
// case AddressIncomplete:
// case BadGateway:
// case ServerTimeout:
// case Unknown:
// default:
// return NONE;
// }
// }
//
// public int getDisplayMessageId()
// {
// switch (this) {
// case DECLINED:
// return R.string.call_activity_call_ended_because_declined;
// case OFFLINE:
// return R.string.call_activity_call_ended_because_user_offline;
// case UNSUPPORTED_MEDIA:
// return R.string.call_activity_call_ended_because_incompatible_media;
// case BUSY:
// return R.string.call_activity_call_ended_because_user_busy;
// case SERVER_CONNECTION_TIMEOUT:
// return R.string.call_activity_connecting_to_server_timed_out;
// case NONE:
// default:
// return R.string.call_activity_call_ended_normally;
// }
// }
// }
//
// Path: app/src/main/java/org/simlar/helper/NetworkQuality.java
// public enum NetworkQuality
// {
// UNKNOWN,
// GOOD,
// AVERAGE,
// POOR,
// VERY_POOR,
// UNUSABLE;
//
// public static NetworkQuality fromFloat(final float quality)
// {
// if (4 <= quality && quality <= 5) {
// return GOOD;
// }
//
// if (3 <= quality && quality < 4) {
// return AVERAGE;
// }
//
// if (2 <= quality && quality < 3) {
// return POOR;
// }
//
// if (1 <= quality && quality < 2) {
// return VERY_POOR;
// }
//
// if (0 <= quality && quality < 1) {
// return UNUSABLE;
// }
//
// return UNKNOWN;
// }
//
// public int getDescription()
// {
// switch (this) {
// case GOOD:
// return R.string.network_quality_good;
// case AVERAGE:
// return R.string.network_quality_average;
// case POOR:
// return R.string.network_quality_poor;
// case VERY_POOR:
// return R.string.network_quality_very_poor;
// case UNUSABLE:
// return R.string.network_quality_unusable;
// case UNKNOWN:
// default:
// return R.string.network_quality_unknown;
// }
// }
//
// public boolean isKnown()
// {
// return this != UNKNOWN;
// }
// }
//
// Path: app/src/main/java/org/simlar/helper/VideoState.java
// public enum VideoState
// {
// OFF,
// REQUESTING,
// REMOTE_REQUESTED,
// DENIED,
// ACCEPTED,
// INITIALIZING,
// PLAYING
// }
//
// Path: app/src/main/java/org/simlar/service/AudioOutputType.java
// public enum AudioOutputType
// {
// PHONE(R.string.audio_output_type_phone),
// WIRED_HEADSET(R.string.audio_output_type_wired_headset),
// SPEAKER(R.string.audio_output_type_speaker),
// BLUETOOTH(R.string.audio_output_type_bluetooth);
//
// private final int mResourceId;
//
// AudioOutputType(final int resourceId)
// {
// mResourceId = resourceId;
// }
//
// public String toDisplayName(final Context context)
// {
// return context.getString(mResourceId);
// }
// }
// Path: app/src/main/java/org/simlar/service/liblinphone/LinphoneManagerListener.java
import java.util.Set;
import org.linphone.core.Call.State;
import org.linphone.core.RegistrationState;
import org.simlar.helper.CallEndReason;
import org.simlar.helper.NetworkQuality;
import org.simlar.helper.VideoState;
import org.simlar.service.AudioOutputType;
/**
* Copyright (C) 2013 The Simlar Authors.
*
* This file is part of Simlar. (https://www.simlar.org)
*
* This program 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 2
* of the License, or (at your option) any later version.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package org.simlar.service.liblinphone;
public interface LinphoneManagerListener
{
void onRegistrationStateChanged(final RegistrationState state);
| void onCallStatsChanged(final NetworkQuality quality, final int callDuration, final String codec, final String iceState, |
simlar/simlar-android | app/src/main/java/org/simlar/service/liblinphone/LinphoneManagerListener.java | // Path: app/src/main/java/org/simlar/helper/CallEndReason.java
// public enum CallEndReason
// {
// NONE,
// DECLINED,
// OFFLINE,
// UNSUPPORTED_MEDIA,
// BUSY,
// SERVER_CONNECTION_TIMEOUT;
//
// public static CallEndReason fromReason(final Reason reason)
// {
// if (reason == null) {
// return NONE;
// }
//
// switch (reason) {
// case Declined:
// return DECLINED;
// case NotFound:
// return OFFLINE;
// case NotImplemented:
// case NotAcceptable:
// case UnsupportedContent:
// return UNSUPPORTED_MEDIA;
// case Busy:
// return BUSY;
// case Transferred:
// case BadEvent:
// case SessionIntervalTooSmall:
// case None:
// case NoResponse:
// case Forbidden:
// case NotAnswered:
// case IOError:
// case DoNotDisturb:
// case Unauthorized:
// case NoMatch:
// case MovedPermanently:
// case Gone:
// case TemporarilyUnavailable:
// case AddressIncomplete:
// case BadGateway:
// case ServerTimeout:
// case Unknown:
// default:
// return NONE;
// }
// }
//
// public int getDisplayMessageId()
// {
// switch (this) {
// case DECLINED:
// return R.string.call_activity_call_ended_because_declined;
// case OFFLINE:
// return R.string.call_activity_call_ended_because_user_offline;
// case UNSUPPORTED_MEDIA:
// return R.string.call_activity_call_ended_because_incompatible_media;
// case BUSY:
// return R.string.call_activity_call_ended_because_user_busy;
// case SERVER_CONNECTION_TIMEOUT:
// return R.string.call_activity_connecting_to_server_timed_out;
// case NONE:
// default:
// return R.string.call_activity_call_ended_normally;
// }
// }
// }
//
// Path: app/src/main/java/org/simlar/helper/NetworkQuality.java
// public enum NetworkQuality
// {
// UNKNOWN,
// GOOD,
// AVERAGE,
// POOR,
// VERY_POOR,
// UNUSABLE;
//
// public static NetworkQuality fromFloat(final float quality)
// {
// if (4 <= quality && quality <= 5) {
// return GOOD;
// }
//
// if (3 <= quality && quality < 4) {
// return AVERAGE;
// }
//
// if (2 <= quality && quality < 3) {
// return POOR;
// }
//
// if (1 <= quality && quality < 2) {
// return VERY_POOR;
// }
//
// if (0 <= quality && quality < 1) {
// return UNUSABLE;
// }
//
// return UNKNOWN;
// }
//
// public int getDescription()
// {
// switch (this) {
// case GOOD:
// return R.string.network_quality_good;
// case AVERAGE:
// return R.string.network_quality_average;
// case POOR:
// return R.string.network_quality_poor;
// case VERY_POOR:
// return R.string.network_quality_very_poor;
// case UNUSABLE:
// return R.string.network_quality_unusable;
// case UNKNOWN:
// default:
// return R.string.network_quality_unknown;
// }
// }
//
// public boolean isKnown()
// {
// return this != UNKNOWN;
// }
// }
//
// Path: app/src/main/java/org/simlar/helper/VideoState.java
// public enum VideoState
// {
// OFF,
// REQUESTING,
// REMOTE_REQUESTED,
// DENIED,
// ACCEPTED,
// INITIALIZING,
// PLAYING
// }
//
// Path: app/src/main/java/org/simlar/service/AudioOutputType.java
// public enum AudioOutputType
// {
// PHONE(R.string.audio_output_type_phone),
// WIRED_HEADSET(R.string.audio_output_type_wired_headset),
// SPEAKER(R.string.audio_output_type_speaker),
// BLUETOOTH(R.string.audio_output_type_bluetooth);
//
// private final int mResourceId;
//
// AudioOutputType(final int resourceId)
// {
// mResourceId = resourceId;
// }
//
// public String toDisplayName(final Context context)
// {
// return context.getString(mResourceId);
// }
// }
| import java.util.Set;
import org.linphone.core.Call.State;
import org.linphone.core.RegistrationState;
import org.simlar.helper.CallEndReason;
import org.simlar.helper.NetworkQuality;
import org.simlar.helper.VideoState;
import org.simlar.service.AudioOutputType; | /**
* Copyright (C) 2013 The Simlar Authors.
*
* This file is part of Simlar. (https://www.simlar.org)
*
* This program 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 2
* of the License, or (at your option) any later version.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package org.simlar.service.liblinphone;
public interface LinphoneManagerListener
{
void onRegistrationStateChanged(final RegistrationState state);
void onCallStatsChanged(final NetworkQuality quality, final int callDuration, final String codec, final String iceState,
final int upload, final int download, final int jitter, final int packetLoss, final long latePackets, final int roundTripDelay);
| // Path: app/src/main/java/org/simlar/helper/CallEndReason.java
// public enum CallEndReason
// {
// NONE,
// DECLINED,
// OFFLINE,
// UNSUPPORTED_MEDIA,
// BUSY,
// SERVER_CONNECTION_TIMEOUT;
//
// public static CallEndReason fromReason(final Reason reason)
// {
// if (reason == null) {
// return NONE;
// }
//
// switch (reason) {
// case Declined:
// return DECLINED;
// case NotFound:
// return OFFLINE;
// case NotImplemented:
// case NotAcceptable:
// case UnsupportedContent:
// return UNSUPPORTED_MEDIA;
// case Busy:
// return BUSY;
// case Transferred:
// case BadEvent:
// case SessionIntervalTooSmall:
// case None:
// case NoResponse:
// case Forbidden:
// case NotAnswered:
// case IOError:
// case DoNotDisturb:
// case Unauthorized:
// case NoMatch:
// case MovedPermanently:
// case Gone:
// case TemporarilyUnavailable:
// case AddressIncomplete:
// case BadGateway:
// case ServerTimeout:
// case Unknown:
// default:
// return NONE;
// }
// }
//
// public int getDisplayMessageId()
// {
// switch (this) {
// case DECLINED:
// return R.string.call_activity_call_ended_because_declined;
// case OFFLINE:
// return R.string.call_activity_call_ended_because_user_offline;
// case UNSUPPORTED_MEDIA:
// return R.string.call_activity_call_ended_because_incompatible_media;
// case BUSY:
// return R.string.call_activity_call_ended_because_user_busy;
// case SERVER_CONNECTION_TIMEOUT:
// return R.string.call_activity_connecting_to_server_timed_out;
// case NONE:
// default:
// return R.string.call_activity_call_ended_normally;
// }
// }
// }
//
// Path: app/src/main/java/org/simlar/helper/NetworkQuality.java
// public enum NetworkQuality
// {
// UNKNOWN,
// GOOD,
// AVERAGE,
// POOR,
// VERY_POOR,
// UNUSABLE;
//
// public static NetworkQuality fromFloat(final float quality)
// {
// if (4 <= quality && quality <= 5) {
// return GOOD;
// }
//
// if (3 <= quality && quality < 4) {
// return AVERAGE;
// }
//
// if (2 <= quality && quality < 3) {
// return POOR;
// }
//
// if (1 <= quality && quality < 2) {
// return VERY_POOR;
// }
//
// if (0 <= quality && quality < 1) {
// return UNUSABLE;
// }
//
// return UNKNOWN;
// }
//
// public int getDescription()
// {
// switch (this) {
// case GOOD:
// return R.string.network_quality_good;
// case AVERAGE:
// return R.string.network_quality_average;
// case POOR:
// return R.string.network_quality_poor;
// case VERY_POOR:
// return R.string.network_quality_very_poor;
// case UNUSABLE:
// return R.string.network_quality_unusable;
// case UNKNOWN:
// default:
// return R.string.network_quality_unknown;
// }
// }
//
// public boolean isKnown()
// {
// return this != UNKNOWN;
// }
// }
//
// Path: app/src/main/java/org/simlar/helper/VideoState.java
// public enum VideoState
// {
// OFF,
// REQUESTING,
// REMOTE_REQUESTED,
// DENIED,
// ACCEPTED,
// INITIALIZING,
// PLAYING
// }
//
// Path: app/src/main/java/org/simlar/service/AudioOutputType.java
// public enum AudioOutputType
// {
// PHONE(R.string.audio_output_type_phone),
// WIRED_HEADSET(R.string.audio_output_type_wired_headset),
// SPEAKER(R.string.audio_output_type_speaker),
// BLUETOOTH(R.string.audio_output_type_bluetooth);
//
// private final int mResourceId;
//
// AudioOutputType(final int resourceId)
// {
// mResourceId = resourceId;
// }
//
// public String toDisplayName(final Context context)
// {
// return context.getString(mResourceId);
// }
// }
// Path: app/src/main/java/org/simlar/service/liblinphone/LinphoneManagerListener.java
import java.util.Set;
import org.linphone.core.Call.State;
import org.linphone.core.RegistrationState;
import org.simlar.helper.CallEndReason;
import org.simlar.helper.NetworkQuality;
import org.simlar.helper.VideoState;
import org.simlar.service.AudioOutputType;
/**
* Copyright (C) 2013 The Simlar Authors.
*
* This file is part of Simlar. (https://www.simlar.org)
*
* This program 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 2
* of the License, or (at your option) any later version.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package org.simlar.service.liblinphone;
public interface LinphoneManagerListener
{
void onRegistrationStateChanged(final RegistrationState state);
void onCallStatsChanged(final NetworkQuality quality, final int callDuration, final String codec, final String iceState,
final int upload, final int download, final int jitter, final int packetLoss, final long latePackets, final int roundTripDelay);
| void onCallStateChanged(final String number, final State callState, final CallEndReason callEndReason); |
simlar/simlar-android | app/src/main/java/org/simlar/service/SimlarServiceBroadcast.java | // Path: app/src/main/java/org/simlar/helper/VideoState.java
// public enum VideoState
// {
// OFF,
// REQUESTING,
// REMOTE_REQUESTED,
// DENIED,
// ACCEPTED,
// INITIALIZING,
// PLAYING
// }
| import android.content.Context;
import android.content.Intent;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import java.io.Serializable;
import java.util.Collections;
import java.util.Set;
import org.simlar.helper.VideoState; |
public Type getType()
{
return mType;
}
public Parameters getParameters()
{
return mParameters;
}
public static void sendSimlarStatusChanged(final Context context)
{
new SimlarServiceBroadcast(Type.SIMLAR_STATUS, null).send(context);
}
public static void sendSimlarCallStateChanged(final Context context)
{
new SimlarServiceBroadcast(Type.SIMLAR_CALL_STATE, null).send(context);
}
public static void sendCallConnectionDetailsChanged(final Context context)
{
new SimlarServiceBroadcast(Type.CALL_CONNECTION_DETAILS, null).send(context);
}
public static class VideoStateChanged implements Parameters
{
private static final long serialVersionUID = 1;
| // Path: app/src/main/java/org/simlar/helper/VideoState.java
// public enum VideoState
// {
// OFF,
// REQUESTING,
// REMOTE_REQUESTED,
// DENIED,
// ACCEPTED,
// INITIALIZING,
// PLAYING
// }
// Path: app/src/main/java/org/simlar/service/SimlarServiceBroadcast.java
import android.content.Context;
import android.content.Intent;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import java.io.Serializable;
import java.util.Collections;
import java.util.Set;
import org.simlar.helper.VideoState;
public Type getType()
{
return mType;
}
public Parameters getParameters()
{
return mParameters;
}
public static void sendSimlarStatusChanged(final Context context)
{
new SimlarServiceBroadcast(Type.SIMLAR_STATUS, null).send(context);
}
public static void sendSimlarCallStateChanged(final Context context)
{
new SimlarServiceBroadcast(Type.SIMLAR_CALL_STATE, null).send(context);
}
public static void sendCallConnectionDetailsChanged(final Context context)
{
new SimlarServiceBroadcast(Type.CALL_CONNECTION_DETAILS, null).send(context);
}
public static class VideoStateChanged implements Parameters
{
private static final long serialVersionUID = 1;
| public final VideoState videoState; |
simlar/simlar-android | app/src/main/java/org/simlar/widgets/AboutActivity.java | // Path: app/src/main/java/org/simlar/helper/Version.java
// public final class Version
// {
// private static final boolean DEVELOPER_MENU = false;
//
// private Version()
// {
// throw new AssertionError("This class was not meant to be instantiated");
// }
//
// public static String getVersionName(final Context context)
// {
// final String versionName = getPackageInfo(context).versionName;
// if (Util.isNullOrEmpty(versionName)) {
// return "";
// }
//
// return versionName;
// }
//
// public static int getVersionCode(final Context context)
// {
// return getPackageInfo(context).versionCode;
// }
//
// public static boolean showDeveloperMenu()
// {
// return DEVELOPER_MENU;
// }
//
// private static PackageInfo createEmptyPackageInfo()
// {
// final PackageInfo info = new PackageInfo();
// info.versionName = "";
// info.versionCode = -1;
// return info;
// }
//
// private static PackageInfo getPackageInfo(final Context context)
// {
// if (context == null) {
// return createEmptyPackageInfo();
// }
//
// try {
// return context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
// } catch (final NameNotFoundException e) {
// Lg.ex(e, "NameNotFoundException in Version.getPackageInfo:");
// return createEmptyPackageInfo();
// }
// }
// }
| import android.os.Bundle;
import android.text.method.LinkMovementMethod;
import android.view.Menu;
import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;
import org.simlar.R;
import org.simlar.helper.Version; | /**
* Copyright (C) 2013 The Simlar Authors.
*
* This file is part of Simlar. (https://www.simlar.org)
*
* This program 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 2
* of the License, or (at your option) any later version.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package org.simlar.widgets;
public final class AboutActivity extends AppCompatActivity
{
@Override
protected void onCreate(final Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_about);
final TextView version = findViewById(R.id.textViewVersion); | // Path: app/src/main/java/org/simlar/helper/Version.java
// public final class Version
// {
// private static final boolean DEVELOPER_MENU = false;
//
// private Version()
// {
// throw new AssertionError("This class was not meant to be instantiated");
// }
//
// public static String getVersionName(final Context context)
// {
// final String versionName = getPackageInfo(context).versionName;
// if (Util.isNullOrEmpty(versionName)) {
// return "";
// }
//
// return versionName;
// }
//
// public static int getVersionCode(final Context context)
// {
// return getPackageInfo(context).versionCode;
// }
//
// public static boolean showDeveloperMenu()
// {
// return DEVELOPER_MENU;
// }
//
// private static PackageInfo createEmptyPackageInfo()
// {
// final PackageInfo info = new PackageInfo();
// info.versionName = "";
// info.versionCode = -1;
// return info;
// }
//
// private static PackageInfo getPackageInfo(final Context context)
// {
// if (context == null) {
// return createEmptyPackageInfo();
// }
//
// try {
// return context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
// } catch (final NameNotFoundException e) {
// Lg.ex(e, "NameNotFoundException in Version.getPackageInfo:");
// return createEmptyPackageInfo();
// }
// }
// }
// Path: app/src/main/java/org/simlar/widgets/AboutActivity.java
import android.os.Bundle;
import android.text.method.LinkMovementMethod;
import android.view.Menu;
import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;
import org.simlar.R;
import org.simlar.helper.Version;
/**
* Copyright (C) 2013 The Simlar Authors.
*
* This file is part of Simlar. (https://www.simlar.org)
*
* This program 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 2
* of the License, or (at your option) any later version.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package org.simlar.widgets;
public final class AboutActivity extends AppCompatActivity
{
@Override
protected void onCreate(final Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_about);
final TextView version = findViewById(R.id.textViewVersion); | version.setText(Version.getVersionName(this)); |
Dabomstew/universal-pokemon-randomizer | src/com/dabomstew/pkrandom/constants/Gen4Constants.java | // Path: src/com/dabomstew/pkrandom/pokemon/ItemList.java
// public class ItemList {
//
// private boolean[] items;
// private boolean[] tms;
//
// public ItemList(int highestIndex) {
// items = new boolean[highestIndex + 1];
// tms = new boolean[highestIndex + 1];
// for (int i = 1; i <= highestIndex; i++) {
// items[i] = true;
// }
// }
//
// public boolean isTM(int index) {
// if (index < 0 || index >= tms.length) {
// return false;
// }
// return tms[index];
// }
//
// public boolean isAllowed(int index) {
// if (index < 0 || index >= tms.length) {
// return false;
// }
// return items[index];
// }
//
// public void banSingles(int... indexes) {
// for (int index : indexes) {
// items[index] = false;
// }
// }
//
// public void banRange(int startIndex, int length) {
// for (int i = 0; i < length; i++) {
// items[i + startIndex] = false;
// }
// }
//
// public void tmRange(int startIndex, int length) {
// for (int i = 0; i < length; i++) {
// tms[i + startIndex] = true;
// }
// }
//
// public int randomItem(Random random) {
// int chosen = 0;
// while (!items[chosen]) {
// chosen = random.nextInt(items.length);
// }
// return chosen;
// }
//
// public int randomNonTM(Random random) {
// int chosen = 0;
// while (!items[chosen] || tms[chosen]) {
// chosen = random.nextInt(items.length);
// }
// return chosen;
// }
//
// public int randomTM(Random random) {
// int chosen = 0;
// while (!tms[chosen]) {
// chosen = random.nextInt(items.length);
// }
// return chosen;
// }
//
// public ItemList copy() {
// ItemList other = new ItemList(items.length - 1);
// System.arraycopy(items, 0, other.items, 0, items.length);
// System.arraycopy(tms, 0, other.tms, 0, tms.length);
// return other;
// }
//
// }
//
// Path: src/com/dabomstew/pkrandom/pokemon/MoveCategory.java
// public enum MoveCategory {
// PHYSICAL, SPECIAL, STATUS;
// }
//
// Path: src/com/dabomstew/pkrandom/pokemon/Type.java
// public enum Type {
//
// NORMAL, FIGHTING, FLYING, GRASS, WATER, FIRE, ROCK, GROUND, PSYCHIC, BUG, DRAGON, ELECTRIC, GHOST, POISON, ICE, STEEL, DARK, GAS(
// true), FAIRY(true), WOOD(true), ABNORMAL(true), WIND(true), SOUND(true), LIGHT(true), TRI(true);
//
// public boolean isHackOnly;
//
// private Type() {
// this.isHackOnly = false;
// }
//
// private Type(boolean isHackOnly) {
// this.isHackOnly = isHackOnly;
// }
//
// private static final List<Type> VALUES = Collections.unmodifiableList(Arrays.asList(values()));
// private static final int SIZE = VALUES.size();
//
// public static Type randomType(Random random) {
// return VALUES.get(random.nextInt(SIZE));
// }
//
// public String camelCase() {
// return RomFunctions.camelCase(this.toString());
// }
//
// }
| import java.util.Arrays;
import java.util.List;
import com.dabomstew.pkrandom.pokemon.ItemList;
import com.dabomstew.pkrandom.pokemon.MoveCategory;
import com.dabomstew.pkrandom.pokemon.Trainer;
import com.dabomstew.pkrandom.pokemon.Type; |
public static final int evolutionMethodCount = 26;
public static final int waterStoneIndex = 84, leafStoneIndex = 85, dawnStoneIndex = 109;
public static final int highestAbilityIndex = 123;
public static final int dpptSetVarScript = 0x28, hgssSetVarScript = 0x29;
public static final int scriptListTerminator = 0xFD13;
public static final int itemScriptVariable = 0x8008;
public static final int luckyEggIndex = 0xE7;
// The original slot each of the 20 "alternate" slots is mapped to
// swarmx2, dayx2, nightx2, pokeradarx4, GBAx10
// NOTE: in the game data there are 6 fillers between pokeradar and GBA
public static final int[] dpptAlternateSlots = new int[] { 0, 1, 2, 3, 2, 3, 4, 5, 10, 11, 8, 9, 8, 9, 8, 9, 8, 9,
8, 9 };
public static final String[] dpptWaterSlotSetNames = new String[] { "Surfing", "Filler", "Old Rod", "Good Rod",
"Super Rod" };
public static final String[] hgssTimeOfDayNames = new String[] { "Morning", "Day", "Night" };
public static final String[] hgssNonGrassSetNames = new String[] { "", "Surfing", "Rock Smash", "Old Rod",
"Good Rod", "Super Rod" };
| // Path: src/com/dabomstew/pkrandom/pokemon/ItemList.java
// public class ItemList {
//
// private boolean[] items;
// private boolean[] tms;
//
// public ItemList(int highestIndex) {
// items = new boolean[highestIndex + 1];
// tms = new boolean[highestIndex + 1];
// for (int i = 1; i <= highestIndex; i++) {
// items[i] = true;
// }
// }
//
// public boolean isTM(int index) {
// if (index < 0 || index >= tms.length) {
// return false;
// }
// return tms[index];
// }
//
// public boolean isAllowed(int index) {
// if (index < 0 || index >= tms.length) {
// return false;
// }
// return items[index];
// }
//
// public void banSingles(int... indexes) {
// for (int index : indexes) {
// items[index] = false;
// }
// }
//
// public void banRange(int startIndex, int length) {
// for (int i = 0; i < length; i++) {
// items[i + startIndex] = false;
// }
// }
//
// public void tmRange(int startIndex, int length) {
// for (int i = 0; i < length; i++) {
// tms[i + startIndex] = true;
// }
// }
//
// public int randomItem(Random random) {
// int chosen = 0;
// while (!items[chosen]) {
// chosen = random.nextInt(items.length);
// }
// return chosen;
// }
//
// public int randomNonTM(Random random) {
// int chosen = 0;
// while (!items[chosen] || tms[chosen]) {
// chosen = random.nextInt(items.length);
// }
// return chosen;
// }
//
// public int randomTM(Random random) {
// int chosen = 0;
// while (!tms[chosen]) {
// chosen = random.nextInt(items.length);
// }
// return chosen;
// }
//
// public ItemList copy() {
// ItemList other = new ItemList(items.length - 1);
// System.arraycopy(items, 0, other.items, 0, items.length);
// System.arraycopy(tms, 0, other.tms, 0, tms.length);
// return other;
// }
//
// }
//
// Path: src/com/dabomstew/pkrandom/pokemon/MoveCategory.java
// public enum MoveCategory {
// PHYSICAL, SPECIAL, STATUS;
// }
//
// Path: src/com/dabomstew/pkrandom/pokemon/Type.java
// public enum Type {
//
// NORMAL, FIGHTING, FLYING, GRASS, WATER, FIRE, ROCK, GROUND, PSYCHIC, BUG, DRAGON, ELECTRIC, GHOST, POISON, ICE, STEEL, DARK, GAS(
// true), FAIRY(true), WOOD(true), ABNORMAL(true), WIND(true), SOUND(true), LIGHT(true), TRI(true);
//
// public boolean isHackOnly;
//
// private Type() {
// this.isHackOnly = false;
// }
//
// private Type(boolean isHackOnly) {
// this.isHackOnly = isHackOnly;
// }
//
// private static final List<Type> VALUES = Collections.unmodifiableList(Arrays.asList(values()));
// private static final int SIZE = VALUES.size();
//
// public static Type randomType(Random random) {
// return VALUES.get(random.nextInt(SIZE));
// }
//
// public String camelCase() {
// return RomFunctions.camelCase(this.toString());
// }
//
// }
// Path: src/com/dabomstew/pkrandom/constants/Gen4Constants.java
import java.util.Arrays;
import java.util.List;
import com.dabomstew.pkrandom.pokemon.ItemList;
import com.dabomstew.pkrandom.pokemon.MoveCategory;
import com.dabomstew.pkrandom.pokemon.Trainer;
import com.dabomstew.pkrandom.pokemon.Type;
public static final int evolutionMethodCount = 26;
public static final int waterStoneIndex = 84, leafStoneIndex = 85, dawnStoneIndex = 109;
public static final int highestAbilityIndex = 123;
public static final int dpptSetVarScript = 0x28, hgssSetVarScript = 0x29;
public static final int scriptListTerminator = 0xFD13;
public static final int itemScriptVariable = 0x8008;
public static final int luckyEggIndex = 0xE7;
// The original slot each of the 20 "alternate" slots is mapped to
// swarmx2, dayx2, nightx2, pokeradarx4, GBAx10
// NOTE: in the game data there are 6 fillers between pokeradar and GBA
public static final int[] dpptAlternateSlots = new int[] { 0, 1, 2, 3, 2, 3, 4, 5, 10, 11, 8, 9, 8, 9, 8, 9, 8, 9,
8, 9 };
public static final String[] dpptWaterSlotSetNames = new String[] { "Surfing", "Filler", "Old Rod", "Good Rod",
"Super Rod" };
public static final String[] hgssTimeOfDayNames = new String[] { "Morning", "Day", "Night" };
public static final String[] hgssNonGrassSetNames = new String[] { "", "Surfing", "Rock Smash", "Old Rod",
"Good Rod", "Super Rod" };
| public static final MoveCategory[] moveCategoryIndices = { MoveCategory.PHYSICAL, MoveCategory.SPECIAL, |
Dabomstew/universal-pokemon-randomizer | src/com/dabomstew/pkrandom/constants/Gen4Constants.java | // Path: src/com/dabomstew/pkrandom/pokemon/ItemList.java
// public class ItemList {
//
// private boolean[] items;
// private boolean[] tms;
//
// public ItemList(int highestIndex) {
// items = new boolean[highestIndex + 1];
// tms = new boolean[highestIndex + 1];
// for (int i = 1; i <= highestIndex; i++) {
// items[i] = true;
// }
// }
//
// public boolean isTM(int index) {
// if (index < 0 || index >= tms.length) {
// return false;
// }
// return tms[index];
// }
//
// public boolean isAllowed(int index) {
// if (index < 0 || index >= tms.length) {
// return false;
// }
// return items[index];
// }
//
// public void banSingles(int... indexes) {
// for (int index : indexes) {
// items[index] = false;
// }
// }
//
// public void banRange(int startIndex, int length) {
// for (int i = 0; i < length; i++) {
// items[i + startIndex] = false;
// }
// }
//
// public void tmRange(int startIndex, int length) {
// for (int i = 0; i < length; i++) {
// tms[i + startIndex] = true;
// }
// }
//
// public int randomItem(Random random) {
// int chosen = 0;
// while (!items[chosen]) {
// chosen = random.nextInt(items.length);
// }
// return chosen;
// }
//
// public int randomNonTM(Random random) {
// int chosen = 0;
// while (!items[chosen] || tms[chosen]) {
// chosen = random.nextInt(items.length);
// }
// return chosen;
// }
//
// public int randomTM(Random random) {
// int chosen = 0;
// while (!tms[chosen]) {
// chosen = random.nextInt(items.length);
// }
// return chosen;
// }
//
// public ItemList copy() {
// ItemList other = new ItemList(items.length - 1);
// System.arraycopy(items, 0, other.items, 0, items.length);
// System.arraycopy(tms, 0, other.tms, 0, tms.length);
// return other;
// }
//
// }
//
// Path: src/com/dabomstew/pkrandom/pokemon/MoveCategory.java
// public enum MoveCategory {
// PHYSICAL, SPECIAL, STATUS;
// }
//
// Path: src/com/dabomstew/pkrandom/pokemon/Type.java
// public enum Type {
//
// NORMAL, FIGHTING, FLYING, GRASS, WATER, FIRE, ROCK, GROUND, PSYCHIC, BUG, DRAGON, ELECTRIC, GHOST, POISON, ICE, STEEL, DARK, GAS(
// true), FAIRY(true), WOOD(true), ABNORMAL(true), WIND(true), SOUND(true), LIGHT(true), TRI(true);
//
// public boolean isHackOnly;
//
// private Type() {
// this.isHackOnly = false;
// }
//
// private Type(boolean isHackOnly) {
// this.isHackOnly = isHackOnly;
// }
//
// private static final List<Type> VALUES = Collections.unmodifiableList(Arrays.asList(values()));
// private static final int SIZE = VALUES.size();
//
// public static Type randomType(Random random) {
// return VALUES.get(random.nextInt(SIZE));
// }
//
// public String camelCase() {
// return RomFunctions.camelCase(this.toString());
// }
//
// }
| import java.util.Arrays;
import java.util.List;
import com.dabomstew.pkrandom.pokemon.ItemList;
import com.dabomstew.pkrandom.pokemon.MoveCategory;
import com.dabomstew.pkrandom.pokemon.Trainer;
import com.dabomstew.pkrandom.pokemon.Type; | switch (cat) {
case PHYSICAL:
return 0;
case SPECIAL:
return 1;
case STATUS:
default:
return 2;
}
}
public static final List<Integer> dpRequiredFieldTMs = Arrays.asList(new Integer[] { 2, 3, 5, 9, 12, 19, 23, 28,
34, 39, 41, 43, 46, 47, 49, 50, 62, 69, 79, 80, 82, 84, 85, 87 });
public static final List<Integer> ptRequiredFieldTMs = Arrays.asList(new Integer[] { 2, 3, 5, 7, 9, 11, 12, 18, 19,
23, 28, 34, 37, 39, 41, 43, 46, 47, 49, 50, 62, 69, 79, 80, 82, 84, 85, 87 });
// DPPt:
// cut, fly, surf, strength, flash, dig, teleport, waterfall,
// rock smash, sweet scent, defog, rock climb
public static final List<Integer> dpptFieldMoves = Arrays.asList(15, 19, 57, 70, 148, 91, 100, 127, 249, 230, 432,
431);
public static final List<Integer> hgssFieldMoves = Arrays.asList(15, 19, 57, 70, 148, 91, 100, 250, 127, 249, 29,
230, 431);
// DPPt: rock smash, cut
public static final List<Integer> dpptEarlyRequiredHMMoves = Arrays.asList(249, 15);
// HGSS: just cut
public static final List<Integer> hgssEarlyRequiredHMMoves = Arrays.asList(15);
| // Path: src/com/dabomstew/pkrandom/pokemon/ItemList.java
// public class ItemList {
//
// private boolean[] items;
// private boolean[] tms;
//
// public ItemList(int highestIndex) {
// items = new boolean[highestIndex + 1];
// tms = new boolean[highestIndex + 1];
// for (int i = 1; i <= highestIndex; i++) {
// items[i] = true;
// }
// }
//
// public boolean isTM(int index) {
// if (index < 0 || index >= tms.length) {
// return false;
// }
// return tms[index];
// }
//
// public boolean isAllowed(int index) {
// if (index < 0 || index >= tms.length) {
// return false;
// }
// return items[index];
// }
//
// public void banSingles(int... indexes) {
// for (int index : indexes) {
// items[index] = false;
// }
// }
//
// public void banRange(int startIndex, int length) {
// for (int i = 0; i < length; i++) {
// items[i + startIndex] = false;
// }
// }
//
// public void tmRange(int startIndex, int length) {
// for (int i = 0; i < length; i++) {
// tms[i + startIndex] = true;
// }
// }
//
// public int randomItem(Random random) {
// int chosen = 0;
// while (!items[chosen]) {
// chosen = random.nextInt(items.length);
// }
// return chosen;
// }
//
// public int randomNonTM(Random random) {
// int chosen = 0;
// while (!items[chosen] || tms[chosen]) {
// chosen = random.nextInt(items.length);
// }
// return chosen;
// }
//
// public int randomTM(Random random) {
// int chosen = 0;
// while (!tms[chosen]) {
// chosen = random.nextInt(items.length);
// }
// return chosen;
// }
//
// public ItemList copy() {
// ItemList other = new ItemList(items.length - 1);
// System.arraycopy(items, 0, other.items, 0, items.length);
// System.arraycopy(tms, 0, other.tms, 0, tms.length);
// return other;
// }
//
// }
//
// Path: src/com/dabomstew/pkrandom/pokemon/MoveCategory.java
// public enum MoveCategory {
// PHYSICAL, SPECIAL, STATUS;
// }
//
// Path: src/com/dabomstew/pkrandom/pokemon/Type.java
// public enum Type {
//
// NORMAL, FIGHTING, FLYING, GRASS, WATER, FIRE, ROCK, GROUND, PSYCHIC, BUG, DRAGON, ELECTRIC, GHOST, POISON, ICE, STEEL, DARK, GAS(
// true), FAIRY(true), WOOD(true), ABNORMAL(true), WIND(true), SOUND(true), LIGHT(true), TRI(true);
//
// public boolean isHackOnly;
//
// private Type() {
// this.isHackOnly = false;
// }
//
// private Type(boolean isHackOnly) {
// this.isHackOnly = isHackOnly;
// }
//
// private static final List<Type> VALUES = Collections.unmodifiableList(Arrays.asList(values()));
// private static final int SIZE = VALUES.size();
//
// public static Type randomType(Random random) {
// return VALUES.get(random.nextInt(SIZE));
// }
//
// public String camelCase() {
// return RomFunctions.camelCase(this.toString());
// }
//
// }
// Path: src/com/dabomstew/pkrandom/constants/Gen4Constants.java
import java.util.Arrays;
import java.util.List;
import com.dabomstew.pkrandom.pokemon.ItemList;
import com.dabomstew.pkrandom.pokemon.MoveCategory;
import com.dabomstew.pkrandom.pokemon.Trainer;
import com.dabomstew.pkrandom.pokemon.Type;
switch (cat) {
case PHYSICAL:
return 0;
case SPECIAL:
return 1;
case STATUS:
default:
return 2;
}
}
public static final List<Integer> dpRequiredFieldTMs = Arrays.asList(new Integer[] { 2, 3, 5, 9, 12, 19, 23, 28,
34, 39, 41, 43, 46, 47, 49, 50, 62, 69, 79, 80, 82, 84, 85, 87 });
public static final List<Integer> ptRequiredFieldTMs = Arrays.asList(new Integer[] { 2, 3, 5, 7, 9, 11, 12, 18, 19,
23, 28, 34, 37, 39, 41, 43, 46, 47, 49, 50, 62, 69, 79, 80, 82, 84, 85, 87 });
// DPPt:
// cut, fly, surf, strength, flash, dig, teleport, waterfall,
// rock smash, sweet scent, defog, rock climb
public static final List<Integer> dpptFieldMoves = Arrays.asList(15, 19, 57, 70, 148, 91, 100, 127, 249, 230, 432,
431);
public static final List<Integer> hgssFieldMoves = Arrays.asList(15, 19, 57, 70, 148, 91, 100, 250, 127, 249, 29,
230, 431);
// DPPt: rock smash, cut
public static final List<Integer> dpptEarlyRequiredHMMoves = Arrays.asList(249, 15);
// HGSS: just cut
public static final List<Integer> hgssEarlyRequiredHMMoves = Arrays.asList(15);
| public static ItemList allowedItems, nonBadItems; |
Dabomstew/universal-pokemon-randomizer | src/com/dabomstew/pkrandom/constants/Gen4Constants.java | // Path: src/com/dabomstew/pkrandom/pokemon/ItemList.java
// public class ItemList {
//
// private boolean[] items;
// private boolean[] tms;
//
// public ItemList(int highestIndex) {
// items = new boolean[highestIndex + 1];
// tms = new boolean[highestIndex + 1];
// for (int i = 1; i <= highestIndex; i++) {
// items[i] = true;
// }
// }
//
// public boolean isTM(int index) {
// if (index < 0 || index >= tms.length) {
// return false;
// }
// return tms[index];
// }
//
// public boolean isAllowed(int index) {
// if (index < 0 || index >= tms.length) {
// return false;
// }
// return items[index];
// }
//
// public void banSingles(int... indexes) {
// for (int index : indexes) {
// items[index] = false;
// }
// }
//
// public void banRange(int startIndex, int length) {
// for (int i = 0; i < length; i++) {
// items[i + startIndex] = false;
// }
// }
//
// public void tmRange(int startIndex, int length) {
// for (int i = 0; i < length; i++) {
// tms[i + startIndex] = true;
// }
// }
//
// public int randomItem(Random random) {
// int chosen = 0;
// while (!items[chosen]) {
// chosen = random.nextInt(items.length);
// }
// return chosen;
// }
//
// public int randomNonTM(Random random) {
// int chosen = 0;
// while (!items[chosen] || tms[chosen]) {
// chosen = random.nextInt(items.length);
// }
// return chosen;
// }
//
// public int randomTM(Random random) {
// int chosen = 0;
// while (!tms[chosen]) {
// chosen = random.nextInt(items.length);
// }
// return chosen;
// }
//
// public ItemList copy() {
// ItemList other = new ItemList(items.length - 1);
// System.arraycopy(items, 0, other.items, 0, items.length);
// System.arraycopy(tms, 0, other.tms, 0, tms.length);
// return other;
// }
//
// }
//
// Path: src/com/dabomstew/pkrandom/pokemon/MoveCategory.java
// public enum MoveCategory {
// PHYSICAL, SPECIAL, STATUS;
// }
//
// Path: src/com/dabomstew/pkrandom/pokemon/Type.java
// public enum Type {
//
// NORMAL, FIGHTING, FLYING, GRASS, WATER, FIRE, ROCK, GROUND, PSYCHIC, BUG, DRAGON, ELECTRIC, GHOST, POISON, ICE, STEEL, DARK, GAS(
// true), FAIRY(true), WOOD(true), ABNORMAL(true), WIND(true), SOUND(true), LIGHT(true), TRI(true);
//
// public boolean isHackOnly;
//
// private Type() {
// this.isHackOnly = false;
// }
//
// private Type(boolean isHackOnly) {
// this.isHackOnly = isHackOnly;
// }
//
// private static final List<Type> VALUES = Collections.unmodifiableList(Arrays.asList(values()));
// private static final int SIZE = VALUES.size();
//
// public static Type randomType(Random random) {
// return VALUES.get(random.nextInt(SIZE));
// }
//
// public String camelCase() {
// return RomFunctions.camelCase(this.toString());
// }
//
// }
| import java.util.Arrays;
import java.util.List;
import com.dabomstew.pkrandom.pokemon.ItemList;
import com.dabomstew.pkrandom.pokemon.MoveCategory;
import com.dabomstew.pkrandom.pokemon.Trainer;
import com.dabomstew.pkrandom.pokemon.Type; | public static ItemList allowedItems, nonBadItems;
static {
setupAllowedItems();
}
private static void setupAllowedItems() {
allowedItems = new ItemList(536);
// Key items + version exclusives
allowedItems.banRange(428, 109);
// Unknown blank items or version exclusives
allowedItems.banRange(112, 23);
// HMs
allowedItems.banRange(420, 8);
// TMs
allowedItems.tmRange(328, 92);
// non-bad items
// ban specific pokemon hold items, berries, apricorns, mail
nonBadItems = allowedItems.copy();
nonBadItems.banSingles(0x6F, 0x70, 0xEC, 0x9B);
nonBadItems.banRange(0x5F, 4); // mulch
nonBadItems.banRange(0x87, 2); // orbs
nonBadItems.banRange(0x89, 12); // mails
nonBadItems.banRange(0x9F, 54); // berries DansGame
nonBadItems.banRange(0x100, 4); // pokemon specific
nonBadItems.banRange(0x104, 5); // contest scarves
}
| // Path: src/com/dabomstew/pkrandom/pokemon/ItemList.java
// public class ItemList {
//
// private boolean[] items;
// private boolean[] tms;
//
// public ItemList(int highestIndex) {
// items = new boolean[highestIndex + 1];
// tms = new boolean[highestIndex + 1];
// for (int i = 1; i <= highestIndex; i++) {
// items[i] = true;
// }
// }
//
// public boolean isTM(int index) {
// if (index < 0 || index >= tms.length) {
// return false;
// }
// return tms[index];
// }
//
// public boolean isAllowed(int index) {
// if (index < 0 || index >= tms.length) {
// return false;
// }
// return items[index];
// }
//
// public void banSingles(int... indexes) {
// for (int index : indexes) {
// items[index] = false;
// }
// }
//
// public void banRange(int startIndex, int length) {
// for (int i = 0; i < length; i++) {
// items[i + startIndex] = false;
// }
// }
//
// public void tmRange(int startIndex, int length) {
// for (int i = 0; i < length; i++) {
// tms[i + startIndex] = true;
// }
// }
//
// public int randomItem(Random random) {
// int chosen = 0;
// while (!items[chosen]) {
// chosen = random.nextInt(items.length);
// }
// return chosen;
// }
//
// public int randomNonTM(Random random) {
// int chosen = 0;
// while (!items[chosen] || tms[chosen]) {
// chosen = random.nextInt(items.length);
// }
// return chosen;
// }
//
// public int randomTM(Random random) {
// int chosen = 0;
// while (!tms[chosen]) {
// chosen = random.nextInt(items.length);
// }
// return chosen;
// }
//
// public ItemList copy() {
// ItemList other = new ItemList(items.length - 1);
// System.arraycopy(items, 0, other.items, 0, items.length);
// System.arraycopy(tms, 0, other.tms, 0, tms.length);
// return other;
// }
//
// }
//
// Path: src/com/dabomstew/pkrandom/pokemon/MoveCategory.java
// public enum MoveCategory {
// PHYSICAL, SPECIAL, STATUS;
// }
//
// Path: src/com/dabomstew/pkrandom/pokemon/Type.java
// public enum Type {
//
// NORMAL, FIGHTING, FLYING, GRASS, WATER, FIRE, ROCK, GROUND, PSYCHIC, BUG, DRAGON, ELECTRIC, GHOST, POISON, ICE, STEEL, DARK, GAS(
// true), FAIRY(true), WOOD(true), ABNORMAL(true), WIND(true), SOUND(true), LIGHT(true), TRI(true);
//
// public boolean isHackOnly;
//
// private Type() {
// this.isHackOnly = false;
// }
//
// private Type(boolean isHackOnly) {
// this.isHackOnly = isHackOnly;
// }
//
// private static final List<Type> VALUES = Collections.unmodifiableList(Arrays.asList(values()));
// private static final int SIZE = VALUES.size();
//
// public static Type randomType(Random random) {
// return VALUES.get(random.nextInt(SIZE));
// }
//
// public String camelCase() {
// return RomFunctions.camelCase(this.toString());
// }
//
// }
// Path: src/com/dabomstew/pkrandom/constants/Gen4Constants.java
import java.util.Arrays;
import java.util.List;
import com.dabomstew.pkrandom.pokemon.ItemList;
import com.dabomstew.pkrandom.pokemon.MoveCategory;
import com.dabomstew.pkrandom.pokemon.Trainer;
import com.dabomstew.pkrandom.pokemon.Type;
public static ItemList allowedItems, nonBadItems;
static {
setupAllowedItems();
}
private static void setupAllowedItems() {
allowedItems = new ItemList(536);
// Key items + version exclusives
allowedItems.banRange(428, 109);
// Unknown blank items or version exclusives
allowedItems.banRange(112, 23);
// HMs
allowedItems.banRange(420, 8);
// TMs
allowedItems.tmRange(328, 92);
// non-bad items
// ban specific pokemon hold items, berries, apricorns, mail
nonBadItems = allowedItems.copy();
nonBadItems.banSingles(0x6F, 0x70, 0xEC, 0x9B);
nonBadItems.banRange(0x5F, 4); // mulch
nonBadItems.banRange(0x87, 2); // orbs
nonBadItems.banRange(0x89, 12); // mails
nonBadItems.banRange(0x9F, 54); // berries DansGame
nonBadItems.banRange(0x100, 4); // pokemon specific
nonBadItems.banRange(0x104, 5); // contest scarves
}
| public static final Type[] typeTable = constructTypeTable(); |
Dabomstew/universal-pokemon-randomizer | src/com/dabomstew/pkrandom/constants/Gen3Constants.java | // Path: src/com/dabomstew/pkrandom/pokemon/ItemList.java
// public class ItemList {
//
// private boolean[] items;
// private boolean[] tms;
//
// public ItemList(int highestIndex) {
// items = new boolean[highestIndex + 1];
// tms = new boolean[highestIndex + 1];
// for (int i = 1; i <= highestIndex; i++) {
// items[i] = true;
// }
// }
//
// public boolean isTM(int index) {
// if (index < 0 || index >= tms.length) {
// return false;
// }
// return tms[index];
// }
//
// public boolean isAllowed(int index) {
// if (index < 0 || index >= tms.length) {
// return false;
// }
// return items[index];
// }
//
// public void banSingles(int... indexes) {
// for (int index : indexes) {
// items[index] = false;
// }
// }
//
// public void banRange(int startIndex, int length) {
// for (int i = 0; i < length; i++) {
// items[i + startIndex] = false;
// }
// }
//
// public void tmRange(int startIndex, int length) {
// for (int i = 0; i < length; i++) {
// tms[i + startIndex] = true;
// }
// }
//
// public int randomItem(Random random) {
// int chosen = 0;
// while (!items[chosen]) {
// chosen = random.nextInt(items.length);
// }
// return chosen;
// }
//
// public int randomNonTM(Random random) {
// int chosen = 0;
// while (!items[chosen] || tms[chosen]) {
// chosen = random.nextInt(items.length);
// }
// return chosen;
// }
//
// public int randomTM(Random random) {
// int chosen = 0;
// while (!tms[chosen]) {
// chosen = random.nextInt(items.length);
// }
// return chosen;
// }
//
// public ItemList copy() {
// ItemList other = new ItemList(items.length - 1);
// System.arraycopy(items, 0, other.items, 0, items.length);
// System.arraycopy(tms, 0, other.tms, 0, tms.length);
// return other;
// }
//
// }
//
// Path: src/com/dabomstew/pkrandom/pokemon/Type.java
// public enum Type {
//
// NORMAL, FIGHTING, FLYING, GRASS, WATER, FIRE, ROCK, GROUND, PSYCHIC, BUG, DRAGON, ELECTRIC, GHOST, POISON, ICE, STEEL, DARK, GAS(
// true), FAIRY(true), WOOD(true), ABNORMAL(true), WIND(true), SOUND(true), LIGHT(true), TRI(true);
//
// public boolean isHackOnly;
//
// private Type() {
// this.isHackOnly = false;
// }
//
// private Type(boolean isHackOnly) {
// this.isHackOnly = isHackOnly;
// }
//
// private static final List<Type> VALUES = Collections.unmodifiableList(Arrays.asList(values()));
// private static final int SIZE = VALUES.size();
//
// public static Type randomType(Random random) {
// return VALUES.get(random.nextInt(SIZE));
// }
//
// public String camelCase() {
// return RomFunctions.camelCase(this.toString());
// }
//
// }
| import java.util.Arrays;
import java.util.List;
import com.dabomstew.pkrandom.pokemon.ItemList;
import com.dabomstew.pkrandom.pokemon.Trainer;
import com.dabomstew.pkrandom.pokemon.Type; | efrlgAbilityNamesPointer = 0x1C0, efrlgItemDataPointer = 0x1C8, efrlgMoveDataPointer = 0x1CC,
efrlgPokemonStatsPointer = 0x1BC, efrlgFrontSpritesPointer = 0x128, efrlgPokemonPalettesPointer = 0x130;
public static final byte[] emptyPokemonSig = new byte[] { 0x32, (byte) 0x96, 0x32, (byte) 0x96, (byte) 0x96, 0x32,
0x00, 0x00, 0x03, 0x01, (byte) 0xAA, 0x0A, 0x00, 0x00, 0x00, 0x00, (byte) 0xFF, 0x78, 0x00, 0x00, 0x0F,
0x0F, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00 };
public static final int baseStatsEntrySize = 0x1C;
public static final int bsHPOffset = 0, bsAttackOffset = 1, bsDefenseOffset = 2, bsSpeedOffset = 3,
bsSpAtkOffset = 4, bsSpDefOffset = 5, bsPrimaryTypeOffset = 6, bsSecondaryTypeOffset = 7,
bsCatchRateOffset = 8, bsCommonHeldItemOffset = 12, bsRareHeldItemOffset = 14, bsGenderRatioOffset = 16,
bsGrowthCurveOffset = 19, bsAbility1Offset = 22, bsAbility2Offset = 23;
public static final int textTerminator = 0xFF, textVariable = 0xFD;
public static final byte freeSpaceByte = (byte) 0xFF;
public static final int rseStarter2Offset = 2, rseStarter3Offset = 4, frlgStarter2Offset = 515,
frlgStarter3Offset = 461, frlgStarterRepeatOffset = 5;
public static final int frlgBaseStarter1 = 1, frlgBaseStarter2 = 4, frlgBaseStarter3 = 7;
public static final int frlgStarterItemsOffset = 218;
public static final int gbaAddRxOpcode = 0x30, gbaUnconditionalJumpOpcode = 0xE0, gbaSetRxOpcode = 0x20,
gbaCmpRxOpcode = 0x28, gbaNopOpcode = 0x46C0;
public static final int gbaR0 = 0, gbaR1 = 1, gbaR2 = 2, gbaR3 = 3, gbaR4 = 4, gbaR5 = 5, gbaR6 = 6, gbaR7 = 7;
| // Path: src/com/dabomstew/pkrandom/pokemon/ItemList.java
// public class ItemList {
//
// private boolean[] items;
// private boolean[] tms;
//
// public ItemList(int highestIndex) {
// items = new boolean[highestIndex + 1];
// tms = new boolean[highestIndex + 1];
// for (int i = 1; i <= highestIndex; i++) {
// items[i] = true;
// }
// }
//
// public boolean isTM(int index) {
// if (index < 0 || index >= tms.length) {
// return false;
// }
// return tms[index];
// }
//
// public boolean isAllowed(int index) {
// if (index < 0 || index >= tms.length) {
// return false;
// }
// return items[index];
// }
//
// public void banSingles(int... indexes) {
// for (int index : indexes) {
// items[index] = false;
// }
// }
//
// public void banRange(int startIndex, int length) {
// for (int i = 0; i < length; i++) {
// items[i + startIndex] = false;
// }
// }
//
// public void tmRange(int startIndex, int length) {
// for (int i = 0; i < length; i++) {
// tms[i + startIndex] = true;
// }
// }
//
// public int randomItem(Random random) {
// int chosen = 0;
// while (!items[chosen]) {
// chosen = random.nextInt(items.length);
// }
// return chosen;
// }
//
// public int randomNonTM(Random random) {
// int chosen = 0;
// while (!items[chosen] || tms[chosen]) {
// chosen = random.nextInt(items.length);
// }
// return chosen;
// }
//
// public int randomTM(Random random) {
// int chosen = 0;
// while (!tms[chosen]) {
// chosen = random.nextInt(items.length);
// }
// return chosen;
// }
//
// public ItemList copy() {
// ItemList other = new ItemList(items.length - 1);
// System.arraycopy(items, 0, other.items, 0, items.length);
// System.arraycopy(tms, 0, other.tms, 0, tms.length);
// return other;
// }
//
// }
//
// Path: src/com/dabomstew/pkrandom/pokemon/Type.java
// public enum Type {
//
// NORMAL, FIGHTING, FLYING, GRASS, WATER, FIRE, ROCK, GROUND, PSYCHIC, BUG, DRAGON, ELECTRIC, GHOST, POISON, ICE, STEEL, DARK, GAS(
// true), FAIRY(true), WOOD(true), ABNORMAL(true), WIND(true), SOUND(true), LIGHT(true), TRI(true);
//
// public boolean isHackOnly;
//
// private Type() {
// this.isHackOnly = false;
// }
//
// private Type(boolean isHackOnly) {
// this.isHackOnly = isHackOnly;
// }
//
// private static final List<Type> VALUES = Collections.unmodifiableList(Arrays.asList(values()));
// private static final int SIZE = VALUES.size();
//
// public static Type randomType(Random random) {
// return VALUES.get(random.nextInt(SIZE));
// }
//
// public String camelCase() {
// return RomFunctions.camelCase(this.toString());
// }
//
// }
// Path: src/com/dabomstew/pkrandom/constants/Gen3Constants.java
import java.util.Arrays;
import java.util.List;
import com.dabomstew.pkrandom.pokemon.ItemList;
import com.dabomstew.pkrandom.pokemon.Trainer;
import com.dabomstew.pkrandom.pokemon.Type;
efrlgAbilityNamesPointer = 0x1C0, efrlgItemDataPointer = 0x1C8, efrlgMoveDataPointer = 0x1CC,
efrlgPokemonStatsPointer = 0x1BC, efrlgFrontSpritesPointer = 0x128, efrlgPokemonPalettesPointer = 0x130;
public static final byte[] emptyPokemonSig = new byte[] { 0x32, (byte) 0x96, 0x32, (byte) 0x96, (byte) 0x96, 0x32,
0x00, 0x00, 0x03, 0x01, (byte) 0xAA, 0x0A, 0x00, 0x00, 0x00, 0x00, (byte) 0xFF, 0x78, 0x00, 0x00, 0x0F,
0x0F, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00 };
public static final int baseStatsEntrySize = 0x1C;
public static final int bsHPOffset = 0, bsAttackOffset = 1, bsDefenseOffset = 2, bsSpeedOffset = 3,
bsSpAtkOffset = 4, bsSpDefOffset = 5, bsPrimaryTypeOffset = 6, bsSecondaryTypeOffset = 7,
bsCatchRateOffset = 8, bsCommonHeldItemOffset = 12, bsRareHeldItemOffset = 14, bsGenderRatioOffset = 16,
bsGrowthCurveOffset = 19, bsAbility1Offset = 22, bsAbility2Offset = 23;
public static final int textTerminator = 0xFF, textVariable = 0xFD;
public static final byte freeSpaceByte = (byte) 0xFF;
public static final int rseStarter2Offset = 2, rseStarter3Offset = 4, frlgStarter2Offset = 515,
frlgStarter3Offset = 461, frlgStarterRepeatOffset = 5;
public static final int frlgBaseStarter1 = 1, frlgBaseStarter2 = 4, frlgBaseStarter3 = 7;
public static final int frlgStarterItemsOffset = 218;
public static final int gbaAddRxOpcode = 0x30, gbaUnconditionalJumpOpcode = 0xE0, gbaSetRxOpcode = 0x20,
gbaCmpRxOpcode = 0x28, gbaNopOpcode = 0x46C0;
public static final int gbaR0 = 0, gbaR1 = 1, gbaR2 = 2, gbaR3 = 3, gbaR4 = 4, gbaR5 = 5, gbaR6 = 6, gbaR7 = 7;
| public static final Type[] typeTable = constructTypeTable(); |
Dabomstew/universal-pokemon-randomizer | src/com/dabomstew/pkrandom/constants/Gen3Constants.java | // Path: src/com/dabomstew/pkrandom/pokemon/ItemList.java
// public class ItemList {
//
// private boolean[] items;
// private boolean[] tms;
//
// public ItemList(int highestIndex) {
// items = new boolean[highestIndex + 1];
// tms = new boolean[highestIndex + 1];
// for (int i = 1; i <= highestIndex; i++) {
// items[i] = true;
// }
// }
//
// public boolean isTM(int index) {
// if (index < 0 || index >= tms.length) {
// return false;
// }
// return tms[index];
// }
//
// public boolean isAllowed(int index) {
// if (index < 0 || index >= tms.length) {
// return false;
// }
// return items[index];
// }
//
// public void banSingles(int... indexes) {
// for (int index : indexes) {
// items[index] = false;
// }
// }
//
// public void banRange(int startIndex, int length) {
// for (int i = 0; i < length; i++) {
// items[i + startIndex] = false;
// }
// }
//
// public void tmRange(int startIndex, int length) {
// for (int i = 0; i < length; i++) {
// tms[i + startIndex] = true;
// }
// }
//
// public int randomItem(Random random) {
// int chosen = 0;
// while (!items[chosen]) {
// chosen = random.nextInt(items.length);
// }
// return chosen;
// }
//
// public int randomNonTM(Random random) {
// int chosen = 0;
// while (!items[chosen] || tms[chosen]) {
// chosen = random.nextInt(items.length);
// }
// return chosen;
// }
//
// public int randomTM(Random random) {
// int chosen = 0;
// while (!tms[chosen]) {
// chosen = random.nextInt(items.length);
// }
// return chosen;
// }
//
// public ItemList copy() {
// ItemList other = new ItemList(items.length - 1);
// System.arraycopy(items, 0, other.items, 0, items.length);
// System.arraycopy(tms, 0, other.tms, 0, tms.length);
// return other;
// }
//
// }
//
// Path: src/com/dabomstew/pkrandom/pokemon/Type.java
// public enum Type {
//
// NORMAL, FIGHTING, FLYING, GRASS, WATER, FIRE, ROCK, GROUND, PSYCHIC, BUG, DRAGON, ELECTRIC, GHOST, POISON, ICE, STEEL, DARK, GAS(
// true), FAIRY(true), WOOD(true), ABNORMAL(true), WIND(true), SOUND(true), LIGHT(true), TRI(true);
//
// public boolean isHackOnly;
//
// private Type() {
// this.isHackOnly = false;
// }
//
// private Type(boolean isHackOnly) {
// this.isHackOnly = isHackOnly;
// }
//
// private static final List<Type> VALUES = Collections.unmodifiableList(Arrays.asList(values()));
// private static final int SIZE = VALUES.size();
//
// public static Type randomType(Random random) {
// return VALUES.get(random.nextInt(SIZE));
// }
//
// public String camelCase() {
// return RomFunctions.camelCase(this.toString());
// }
//
// }
| import java.util.Arrays;
import java.util.List;
import com.dabomstew.pkrandom.pokemon.ItemList;
import com.dabomstew.pkrandom.pokemon.Trainer;
import com.dabomstew.pkrandom.pokemon.Type; | return 0x04;
case ROCK:
return 0x05;
case BUG:
return 0x06;
case GHOST:
return 0x07;
case FIRE:
return 0x0A;
case WATER:
return 0x0B;
case GRASS:
return 0x0C;
case ELECTRIC:
return 0x0D;
case PSYCHIC:
return 0x0E;
case ICE:
return 0x0F;
case DRAGON:
return 0x10;
case STEEL:
return 0x08;
case DARK:
return 0x11;
default:
return 0; // normal by default
}
}
| // Path: src/com/dabomstew/pkrandom/pokemon/ItemList.java
// public class ItemList {
//
// private boolean[] items;
// private boolean[] tms;
//
// public ItemList(int highestIndex) {
// items = new boolean[highestIndex + 1];
// tms = new boolean[highestIndex + 1];
// for (int i = 1; i <= highestIndex; i++) {
// items[i] = true;
// }
// }
//
// public boolean isTM(int index) {
// if (index < 0 || index >= tms.length) {
// return false;
// }
// return tms[index];
// }
//
// public boolean isAllowed(int index) {
// if (index < 0 || index >= tms.length) {
// return false;
// }
// return items[index];
// }
//
// public void banSingles(int... indexes) {
// for (int index : indexes) {
// items[index] = false;
// }
// }
//
// public void banRange(int startIndex, int length) {
// for (int i = 0; i < length; i++) {
// items[i + startIndex] = false;
// }
// }
//
// public void tmRange(int startIndex, int length) {
// for (int i = 0; i < length; i++) {
// tms[i + startIndex] = true;
// }
// }
//
// public int randomItem(Random random) {
// int chosen = 0;
// while (!items[chosen]) {
// chosen = random.nextInt(items.length);
// }
// return chosen;
// }
//
// public int randomNonTM(Random random) {
// int chosen = 0;
// while (!items[chosen] || tms[chosen]) {
// chosen = random.nextInt(items.length);
// }
// return chosen;
// }
//
// public int randomTM(Random random) {
// int chosen = 0;
// while (!tms[chosen]) {
// chosen = random.nextInt(items.length);
// }
// return chosen;
// }
//
// public ItemList copy() {
// ItemList other = new ItemList(items.length - 1);
// System.arraycopy(items, 0, other.items, 0, items.length);
// System.arraycopy(tms, 0, other.tms, 0, tms.length);
// return other;
// }
//
// }
//
// Path: src/com/dabomstew/pkrandom/pokemon/Type.java
// public enum Type {
//
// NORMAL, FIGHTING, FLYING, GRASS, WATER, FIRE, ROCK, GROUND, PSYCHIC, BUG, DRAGON, ELECTRIC, GHOST, POISON, ICE, STEEL, DARK, GAS(
// true), FAIRY(true), WOOD(true), ABNORMAL(true), WIND(true), SOUND(true), LIGHT(true), TRI(true);
//
// public boolean isHackOnly;
//
// private Type() {
// this.isHackOnly = false;
// }
//
// private Type(boolean isHackOnly) {
// this.isHackOnly = isHackOnly;
// }
//
// private static final List<Type> VALUES = Collections.unmodifiableList(Arrays.asList(values()));
// private static final int SIZE = VALUES.size();
//
// public static Type randomType(Random random) {
// return VALUES.get(random.nextInt(SIZE));
// }
//
// public String camelCase() {
// return RomFunctions.camelCase(this.toString());
// }
//
// }
// Path: src/com/dabomstew/pkrandom/constants/Gen3Constants.java
import java.util.Arrays;
import java.util.List;
import com.dabomstew.pkrandom.pokemon.ItemList;
import com.dabomstew.pkrandom.pokemon.Trainer;
import com.dabomstew.pkrandom.pokemon.Type;
return 0x04;
case ROCK:
return 0x05;
case BUG:
return 0x06;
case GHOST:
return 0x07;
case FIRE:
return 0x0A;
case WATER:
return 0x0B;
case GRASS:
return 0x0C;
case ELECTRIC:
return 0x0D;
case PSYCHIC:
return 0x0E;
case ICE:
return 0x0F;
case DRAGON:
return 0x10;
case STEEL:
return 0x08;
case DARK:
return 0x11;
default:
return 0; // normal by default
}
}
| public static ItemList allowedItems, nonBadItems; |
Dabomstew/universal-pokemon-randomizer | src/com/dabomstew/pkrandom/constants/Gen2Constants.java | // Path: src/com/dabomstew/pkrandom/pokemon/ItemList.java
// public class ItemList {
//
// private boolean[] items;
// private boolean[] tms;
//
// public ItemList(int highestIndex) {
// items = new boolean[highestIndex + 1];
// tms = new boolean[highestIndex + 1];
// for (int i = 1; i <= highestIndex; i++) {
// items[i] = true;
// }
// }
//
// public boolean isTM(int index) {
// if (index < 0 || index >= tms.length) {
// return false;
// }
// return tms[index];
// }
//
// public boolean isAllowed(int index) {
// if (index < 0 || index >= tms.length) {
// return false;
// }
// return items[index];
// }
//
// public void banSingles(int... indexes) {
// for (int index : indexes) {
// items[index] = false;
// }
// }
//
// public void banRange(int startIndex, int length) {
// for (int i = 0; i < length; i++) {
// items[i + startIndex] = false;
// }
// }
//
// public void tmRange(int startIndex, int length) {
// for (int i = 0; i < length; i++) {
// tms[i + startIndex] = true;
// }
// }
//
// public int randomItem(Random random) {
// int chosen = 0;
// while (!items[chosen]) {
// chosen = random.nextInt(items.length);
// }
// return chosen;
// }
//
// public int randomNonTM(Random random) {
// int chosen = 0;
// while (!items[chosen] || tms[chosen]) {
// chosen = random.nextInt(items.length);
// }
// return chosen;
// }
//
// public int randomTM(Random random) {
// int chosen = 0;
// while (!tms[chosen]) {
// chosen = random.nextInt(items.length);
// }
// return chosen;
// }
//
// public ItemList copy() {
// ItemList other = new ItemList(items.length - 1);
// System.arraycopy(items, 0, other.items, 0, items.length);
// System.arraycopy(tms, 0, other.tms, 0, tms.length);
// return other;
// }
//
// }
//
// Path: src/com/dabomstew/pkrandom/pokemon/Type.java
// public enum Type {
//
// NORMAL, FIGHTING, FLYING, GRASS, WATER, FIRE, ROCK, GROUND, PSYCHIC, BUG, DRAGON, ELECTRIC, GHOST, POISON, ICE, STEEL, DARK, GAS(
// true), FAIRY(true), WOOD(true), ABNORMAL(true), WIND(true), SOUND(true), LIGHT(true), TRI(true);
//
// public boolean isHackOnly;
//
// private Type() {
// this.isHackOnly = false;
// }
//
// private Type(boolean isHackOnly) {
// this.isHackOnly = isHackOnly;
// }
//
// private static final List<Type> VALUES = Collections.unmodifiableList(Arrays.asList(values()));
// private static final int SIZE = VALUES.size();
//
// public static Type randomType(Random random) {
// return VALUES.get(random.nextInt(SIZE));
// }
//
// public String camelCase() {
// return RomFunctions.camelCase(this.toString());
// }
//
// }
| import java.util.Arrays;
import java.util.List;
import com.dabomstew.pkrandom.pokemon.ItemList;
import com.dabomstew.pkrandom.pokemon.Trainer;
import com.dabomstew.pkrandom.pokemon.Type; | package com.dabomstew.pkrandom.constants;
public class Gen2Constants {
public static final int vietCrystalCheckOffset = 0x63;
public static final byte vietCrystalCheckValue = (byte) 0xF5;
public static final String vietCrystalROMName = "Pokemon VietCrystal";
public static final int pokemonCount = 251, moveCount = 251;
public static final int baseStatsEntrySize = 0x20;
| // Path: src/com/dabomstew/pkrandom/pokemon/ItemList.java
// public class ItemList {
//
// private boolean[] items;
// private boolean[] tms;
//
// public ItemList(int highestIndex) {
// items = new boolean[highestIndex + 1];
// tms = new boolean[highestIndex + 1];
// for (int i = 1; i <= highestIndex; i++) {
// items[i] = true;
// }
// }
//
// public boolean isTM(int index) {
// if (index < 0 || index >= tms.length) {
// return false;
// }
// return tms[index];
// }
//
// public boolean isAllowed(int index) {
// if (index < 0 || index >= tms.length) {
// return false;
// }
// return items[index];
// }
//
// public void banSingles(int... indexes) {
// for (int index : indexes) {
// items[index] = false;
// }
// }
//
// public void banRange(int startIndex, int length) {
// for (int i = 0; i < length; i++) {
// items[i + startIndex] = false;
// }
// }
//
// public void tmRange(int startIndex, int length) {
// for (int i = 0; i < length; i++) {
// tms[i + startIndex] = true;
// }
// }
//
// public int randomItem(Random random) {
// int chosen = 0;
// while (!items[chosen]) {
// chosen = random.nextInt(items.length);
// }
// return chosen;
// }
//
// public int randomNonTM(Random random) {
// int chosen = 0;
// while (!items[chosen] || tms[chosen]) {
// chosen = random.nextInt(items.length);
// }
// return chosen;
// }
//
// public int randomTM(Random random) {
// int chosen = 0;
// while (!tms[chosen]) {
// chosen = random.nextInt(items.length);
// }
// return chosen;
// }
//
// public ItemList copy() {
// ItemList other = new ItemList(items.length - 1);
// System.arraycopy(items, 0, other.items, 0, items.length);
// System.arraycopy(tms, 0, other.tms, 0, tms.length);
// return other;
// }
//
// }
//
// Path: src/com/dabomstew/pkrandom/pokemon/Type.java
// public enum Type {
//
// NORMAL, FIGHTING, FLYING, GRASS, WATER, FIRE, ROCK, GROUND, PSYCHIC, BUG, DRAGON, ELECTRIC, GHOST, POISON, ICE, STEEL, DARK, GAS(
// true), FAIRY(true), WOOD(true), ABNORMAL(true), WIND(true), SOUND(true), LIGHT(true), TRI(true);
//
// public boolean isHackOnly;
//
// private Type() {
// this.isHackOnly = false;
// }
//
// private Type(boolean isHackOnly) {
// this.isHackOnly = isHackOnly;
// }
//
// private static final List<Type> VALUES = Collections.unmodifiableList(Arrays.asList(values()));
// private static final int SIZE = VALUES.size();
//
// public static Type randomType(Random random) {
// return VALUES.get(random.nextInt(SIZE));
// }
//
// public String camelCase() {
// return RomFunctions.camelCase(this.toString());
// }
//
// }
// Path: src/com/dabomstew/pkrandom/constants/Gen2Constants.java
import java.util.Arrays;
import java.util.List;
import com.dabomstew.pkrandom.pokemon.ItemList;
import com.dabomstew.pkrandom.pokemon.Trainer;
import com.dabomstew.pkrandom.pokemon.Type;
package com.dabomstew.pkrandom.constants;
public class Gen2Constants {
public static final int vietCrystalCheckOffset = 0x63;
public static final byte vietCrystalCheckValue = (byte) 0xF5;
public static final String vietCrystalROMName = "Pokemon VietCrystal";
public static final int pokemonCount = 251, moveCount = 251;
public static final int baseStatsEntrySize = 0x20;
| public static final Type[] typeTable = constructTypeTable(); |
Dabomstew/universal-pokemon-randomizer | src/com/dabomstew/pkrandom/constants/Gen2Constants.java | // Path: src/com/dabomstew/pkrandom/pokemon/ItemList.java
// public class ItemList {
//
// private boolean[] items;
// private boolean[] tms;
//
// public ItemList(int highestIndex) {
// items = new boolean[highestIndex + 1];
// tms = new boolean[highestIndex + 1];
// for (int i = 1; i <= highestIndex; i++) {
// items[i] = true;
// }
// }
//
// public boolean isTM(int index) {
// if (index < 0 || index >= tms.length) {
// return false;
// }
// return tms[index];
// }
//
// public boolean isAllowed(int index) {
// if (index < 0 || index >= tms.length) {
// return false;
// }
// return items[index];
// }
//
// public void banSingles(int... indexes) {
// for (int index : indexes) {
// items[index] = false;
// }
// }
//
// public void banRange(int startIndex, int length) {
// for (int i = 0; i < length; i++) {
// items[i + startIndex] = false;
// }
// }
//
// public void tmRange(int startIndex, int length) {
// for (int i = 0; i < length; i++) {
// tms[i + startIndex] = true;
// }
// }
//
// public int randomItem(Random random) {
// int chosen = 0;
// while (!items[chosen]) {
// chosen = random.nextInt(items.length);
// }
// return chosen;
// }
//
// public int randomNonTM(Random random) {
// int chosen = 0;
// while (!items[chosen] || tms[chosen]) {
// chosen = random.nextInt(items.length);
// }
// return chosen;
// }
//
// public int randomTM(Random random) {
// int chosen = 0;
// while (!tms[chosen]) {
// chosen = random.nextInt(items.length);
// }
// return chosen;
// }
//
// public ItemList copy() {
// ItemList other = new ItemList(items.length - 1);
// System.arraycopy(items, 0, other.items, 0, items.length);
// System.arraycopy(tms, 0, other.tms, 0, tms.length);
// return other;
// }
//
// }
//
// Path: src/com/dabomstew/pkrandom/pokemon/Type.java
// public enum Type {
//
// NORMAL, FIGHTING, FLYING, GRASS, WATER, FIRE, ROCK, GROUND, PSYCHIC, BUG, DRAGON, ELECTRIC, GHOST, POISON, ICE, STEEL, DARK, GAS(
// true), FAIRY(true), WOOD(true), ABNORMAL(true), WIND(true), SOUND(true), LIGHT(true), TRI(true);
//
// public boolean isHackOnly;
//
// private Type() {
// this.isHackOnly = false;
// }
//
// private Type(boolean isHackOnly) {
// this.isHackOnly = isHackOnly;
// }
//
// private static final List<Type> VALUES = Collections.unmodifiableList(Arrays.asList(values()));
// private static final int SIZE = VALUES.size();
//
// public static Type randomType(Random random) {
// return VALUES.get(random.nextInt(SIZE));
// }
//
// public String camelCase() {
// return RomFunctions.camelCase(this.toString());
// }
//
// }
| import java.util.Arrays;
import java.util.List;
import com.dabomstew.pkrandom.pokemon.ItemList;
import com.dabomstew.pkrandom.pokemon.Trainer;
import com.dabomstew.pkrandom.pokemon.Type; | return 0x04;
case ROCK:
return 0x05;
case BUG:
return 0x07;
case GHOST:
return 0x08;
case FIRE:
return 0x14;
case WATER:
return 0x15;
case GRASS:
return 0x16;
case ELECTRIC:
return 0x17;
case PSYCHIC:
return 0x18;
case ICE:
return 0x19;
case DRAGON:
return 0x1A;
case STEEL:
return 0x09;
case DARK:
return 0x1B;
default:
return 0; // normal by default
}
}
| // Path: src/com/dabomstew/pkrandom/pokemon/ItemList.java
// public class ItemList {
//
// private boolean[] items;
// private boolean[] tms;
//
// public ItemList(int highestIndex) {
// items = new boolean[highestIndex + 1];
// tms = new boolean[highestIndex + 1];
// for (int i = 1; i <= highestIndex; i++) {
// items[i] = true;
// }
// }
//
// public boolean isTM(int index) {
// if (index < 0 || index >= tms.length) {
// return false;
// }
// return tms[index];
// }
//
// public boolean isAllowed(int index) {
// if (index < 0 || index >= tms.length) {
// return false;
// }
// return items[index];
// }
//
// public void banSingles(int... indexes) {
// for (int index : indexes) {
// items[index] = false;
// }
// }
//
// public void banRange(int startIndex, int length) {
// for (int i = 0; i < length; i++) {
// items[i + startIndex] = false;
// }
// }
//
// public void tmRange(int startIndex, int length) {
// for (int i = 0; i < length; i++) {
// tms[i + startIndex] = true;
// }
// }
//
// public int randomItem(Random random) {
// int chosen = 0;
// while (!items[chosen]) {
// chosen = random.nextInt(items.length);
// }
// return chosen;
// }
//
// public int randomNonTM(Random random) {
// int chosen = 0;
// while (!items[chosen] || tms[chosen]) {
// chosen = random.nextInt(items.length);
// }
// return chosen;
// }
//
// public int randomTM(Random random) {
// int chosen = 0;
// while (!tms[chosen]) {
// chosen = random.nextInt(items.length);
// }
// return chosen;
// }
//
// public ItemList copy() {
// ItemList other = new ItemList(items.length - 1);
// System.arraycopy(items, 0, other.items, 0, items.length);
// System.arraycopy(tms, 0, other.tms, 0, tms.length);
// return other;
// }
//
// }
//
// Path: src/com/dabomstew/pkrandom/pokemon/Type.java
// public enum Type {
//
// NORMAL, FIGHTING, FLYING, GRASS, WATER, FIRE, ROCK, GROUND, PSYCHIC, BUG, DRAGON, ELECTRIC, GHOST, POISON, ICE, STEEL, DARK, GAS(
// true), FAIRY(true), WOOD(true), ABNORMAL(true), WIND(true), SOUND(true), LIGHT(true), TRI(true);
//
// public boolean isHackOnly;
//
// private Type() {
// this.isHackOnly = false;
// }
//
// private Type(boolean isHackOnly) {
// this.isHackOnly = isHackOnly;
// }
//
// private static final List<Type> VALUES = Collections.unmodifiableList(Arrays.asList(values()));
// private static final int SIZE = VALUES.size();
//
// public static Type randomType(Random random) {
// return VALUES.get(random.nextInt(SIZE));
// }
//
// public String camelCase() {
// return RomFunctions.camelCase(this.toString());
// }
//
// }
// Path: src/com/dabomstew/pkrandom/constants/Gen2Constants.java
import java.util.Arrays;
import java.util.List;
import com.dabomstew.pkrandom.pokemon.ItemList;
import com.dabomstew.pkrandom.pokemon.Trainer;
import com.dabomstew.pkrandom.pokemon.Type;
return 0x04;
case ROCK:
return 0x05;
case BUG:
return 0x07;
case GHOST:
return 0x08;
case FIRE:
return 0x14;
case WATER:
return 0x15;
case GRASS:
return 0x16;
case ELECTRIC:
return 0x17;
case PSYCHIC:
return 0x18;
case ICE:
return 0x19;
case DRAGON:
return 0x1A;
case STEEL:
return 0x09;
case DARK:
return 0x1B;
default:
return 0; // normal by default
}
}
| public static ItemList allowedItems; |
Dabomstew/universal-pokemon-randomizer | src/com/dabomstew/pkrandom/constants/Gen5Constants.java | // Path: src/com/dabomstew/pkrandom/pokemon/ItemList.java
// public class ItemList {
//
// private boolean[] items;
// private boolean[] tms;
//
// public ItemList(int highestIndex) {
// items = new boolean[highestIndex + 1];
// tms = new boolean[highestIndex + 1];
// for (int i = 1; i <= highestIndex; i++) {
// items[i] = true;
// }
// }
//
// public boolean isTM(int index) {
// if (index < 0 || index >= tms.length) {
// return false;
// }
// return tms[index];
// }
//
// public boolean isAllowed(int index) {
// if (index < 0 || index >= tms.length) {
// return false;
// }
// return items[index];
// }
//
// public void banSingles(int... indexes) {
// for (int index : indexes) {
// items[index] = false;
// }
// }
//
// public void banRange(int startIndex, int length) {
// for (int i = 0; i < length; i++) {
// items[i + startIndex] = false;
// }
// }
//
// public void tmRange(int startIndex, int length) {
// for (int i = 0; i < length; i++) {
// tms[i + startIndex] = true;
// }
// }
//
// public int randomItem(Random random) {
// int chosen = 0;
// while (!items[chosen]) {
// chosen = random.nextInt(items.length);
// }
// return chosen;
// }
//
// public int randomNonTM(Random random) {
// int chosen = 0;
// while (!items[chosen] || tms[chosen]) {
// chosen = random.nextInt(items.length);
// }
// return chosen;
// }
//
// public int randomTM(Random random) {
// int chosen = 0;
// while (!tms[chosen]) {
// chosen = random.nextInt(items.length);
// }
// return chosen;
// }
//
// public ItemList copy() {
// ItemList other = new ItemList(items.length - 1);
// System.arraycopy(items, 0, other.items, 0, items.length);
// System.arraycopy(tms, 0, other.tms, 0, tms.length);
// return other;
// }
//
// }
//
// Path: src/com/dabomstew/pkrandom/pokemon/MoveCategory.java
// public enum MoveCategory {
// PHYSICAL, SPECIAL, STATUS;
// }
//
// Path: src/com/dabomstew/pkrandom/pokemon/Type.java
// public enum Type {
//
// NORMAL, FIGHTING, FLYING, GRASS, WATER, FIRE, ROCK, GROUND, PSYCHIC, BUG, DRAGON, ELECTRIC, GHOST, POISON, ICE, STEEL, DARK, GAS(
// true), FAIRY(true), WOOD(true), ABNORMAL(true), WIND(true), SOUND(true), LIGHT(true), TRI(true);
//
// public boolean isHackOnly;
//
// private Type() {
// this.isHackOnly = false;
// }
//
// private Type(boolean isHackOnly) {
// this.isHackOnly = isHackOnly;
// }
//
// private static final List<Type> VALUES = Collections.unmodifiableList(Arrays.asList(values()));
// private static final int SIZE = VALUES.size();
//
// public static Type randomType(Random random) {
// return VALUES.get(random.nextInt(SIZE));
// }
//
// public String camelCase() {
// return RomFunctions.camelCase(this.toString());
// }
//
// }
| import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import com.dabomstew.pkrandom.pokemon.ItemList;
import com.dabomstew.pkrandom.pokemon.MoveCategory;
import com.dabomstew.pkrandom.pokemon.Trainer;
import com.dabomstew.pkrandom.pokemon.Type; |
public static final int[] bw2HiddenHollowUnovaPokemon = { 505, 507, 510, 511, 513, 515, 519, 523, 525, 527, 529,
531, 533, 535, 538, 539, 542, 545, 546, 548, 550, 553, 556, 558, 559, 561, 564, 569, 572, 575, 578, 580,
583, 587, 588, 594, 596, 601, 605, 607, 610, 613, 616, 618, 619, 621, 622, 624, 626, 628, 630, 631, 632, };
public static final String tmDataPrefix = "87038803";
public static final int tmCount = 95, hmCount = 6, tmBlockOneCount = 92, tmBlockOneOffset = 328,
tmBlockTwoOffset = 618;
public static final String bw1ItemPalettesPrefix = "E903EA03020003000400050006000700",
bw2ItemPalettesPrefix = "FD03FE03020003000400050006000700";
public static final int bw2MoveTutorCount = 60, bw2MoveTutorBytesPerEntry = 12;
public static final int evolutionMethodCount = 27;
public static final int slowpokeIndex = 79, karrablastIndex = 588, shelmetIndex = 616;
public static final int waterStoneIndex = 84;
public static final int highestAbilityIndex = 123;
public static final int normalItemSetVarCommand = 0x28, hiddenItemSetVarCommand = 0x2A, normalItemVarSet = 0x800C,
hiddenItemVarSet = 0x8000;
public static final int scriptListTerminator = 0xFD13;
public static final int luckyEggIndex = 0xE7;
| // Path: src/com/dabomstew/pkrandom/pokemon/ItemList.java
// public class ItemList {
//
// private boolean[] items;
// private boolean[] tms;
//
// public ItemList(int highestIndex) {
// items = new boolean[highestIndex + 1];
// tms = new boolean[highestIndex + 1];
// for (int i = 1; i <= highestIndex; i++) {
// items[i] = true;
// }
// }
//
// public boolean isTM(int index) {
// if (index < 0 || index >= tms.length) {
// return false;
// }
// return tms[index];
// }
//
// public boolean isAllowed(int index) {
// if (index < 0 || index >= tms.length) {
// return false;
// }
// return items[index];
// }
//
// public void banSingles(int... indexes) {
// for (int index : indexes) {
// items[index] = false;
// }
// }
//
// public void banRange(int startIndex, int length) {
// for (int i = 0; i < length; i++) {
// items[i + startIndex] = false;
// }
// }
//
// public void tmRange(int startIndex, int length) {
// for (int i = 0; i < length; i++) {
// tms[i + startIndex] = true;
// }
// }
//
// public int randomItem(Random random) {
// int chosen = 0;
// while (!items[chosen]) {
// chosen = random.nextInt(items.length);
// }
// return chosen;
// }
//
// public int randomNonTM(Random random) {
// int chosen = 0;
// while (!items[chosen] || tms[chosen]) {
// chosen = random.nextInt(items.length);
// }
// return chosen;
// }
//
// public int randomTM(Random random) {
// int chosen = 0;
// while (!tms[chosen]) {
// chosen = random.nextInt(items.length);
// }
// return chosen;
// }
//
// public ItemList copy() {
// ItemList other = new ItemList(items.length - 1);
// System.arraycopy(items, 0, other.items, 0, items.length);
// System.arraycopy(tms, 0, other.tms, 0, tms.length);
// return other;
// }
//
// }
//
// Path: src/com/dabomstew/pkrandom/pokemon/MoveCategory.java
// public enum MoveCategory {
// PHYSICAL, SPECIAL, STATUS;
// }
//
// Path: src/com/dabomstew/pkrandom/pokemon/Type.java
// public enum Type {
//
// NORMAL, FIGHTING, FLYING, GRASS, WATER, FIRE, ROCK, GROUND, PSYCHIC, BUG, DRAGON, ELECTRIC, GHOST, POISON, ICE, STEEL, DARK, GAS(
// true), FAIRY(true), WOOD(true), ABNORMAL(true), WIND(true), SOUND(true), LIGHT(true), TRI(true);
//
// public boolean isHackOnly;
//
// private Type() {
// this.isHackOnly = false;
// }
//
// private Type(boolean isHackOnly) {
// this.isHackOnly = isHackOnly;
// }
//
// private static final List<Type> VALUES = Collections.unmodifiableList(Arrays.asList(values()));
// private static final int SIZE = VALUES.size();
//
// public static Type randomType(Random random) {
// return VALUES.get(random.nextInt(SIZE));
// }
//
// public String camelCase() {
// return RomFunctions.camelCase(this.toString());
// }
//
// }
// Path: src/com/dabomstew/pkrandom/constants/Gen5Constants.java
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import com.dabomstew.pkrandom.pokemon.ItemList;
import com.dabomstew.pkrandom.pokemon.MoveCategory;
import com.dabomstew.pkrandom.pokemon.Trainer;
import com.dabomstew.pkrandom.pokemon.Type;
public static final int[] bw2HiddenHollowUnovaPokemon = { 505, 507, 510, 511, 513, 515, 519, 523, 525, 527, 529,
531, 533, 535, 538, 539, 542, 545, 546, 548, 550, 553, 556, 558, 559, 561, 564, 569, 572, 575, 578, 580,
583, 587, 588, 594, 596, 601, 605, 607, 610, 613, 616, 618, 619, 621, 622, 624, 626, 628, 630, 631, 632, };
public static final String tmDataPrefix = "87038803";
public static final int tmCount = 95, hmCount = 6, tmBlockOneCount = 92, tmBlockOneOffset = 328,
tmBlockTwoOffset = 618;
public static final String bw1ItemPalettesPrefix = "E903EA03020003000400050006000700",
bw2ItemPalettesPrefix = "FD03FE03020003000400050006000700";
public static final int bw2MoveTutorCount = 60, bw2MoveTutorBytesPerEntry = 12;
public static final int evolutionMethodCount = 27;
public static final int slowpokeIndex = 79, karrablastIndex = 588, shelmetIndex = 616;
public static final int waterStoneIndex = 84;
public static final int highestAbilityIndex = 123;
public static final int normalItemSetVarCommand = 0x28, hiddenItemSetVarCommand = 0x2A, normalItemVarSet = 0x800C,
hiddenItemVarSet = 0x8000;
public static final int scriptListTerminator = 0xFD13;
public static final int luckyEggIndex = 0xE7;
| public static final MoveCategory[] moveCategoryIndices = { MoveCategory.STATUS, MoveCategory.PHYSICAL, |
Dabomstew/universal-pokemon-randomizer | src/com/dabomstew/pkrandom/constants/Gen5Constants.java | // Path: src/com/dabomstew/pkrandom/pokemon/ItemList.java
// public class ItemList {
//
// private boolean[] items;
// private boolean[] tms;
//
// public ItemList(int highestIndex) {
// items = new boolean[highestIndex + 1];
// tms = new boolean[highestIndex + 1];
// for (int i = 1; i <= highestIndex; i++) {
// items[i] = true;
// }
// }
//
// public boolean isTM(int index) {
// if (index < 0 || index >= tms.length) {
// return false;
// }
// return tms[index];
// }
//
// public boolean isAllowed(int index) {
// if (index < 0 || index >= tms.length) {
// return false;
// }
// return items[index];
// }
//
// public void banSingles(int... indexes) {
// for (int index : indexes) {
// items[index] = false;
// }
// }
//
// public void banRange(int startIndex, int length) {
// for (int i = 0; i < length; i++) {
// items[i + startIndex] = false;
// }
// }
//
// public void tmRange(int startIndex, int length) {
// for (int i = 0; i < length; i++) {
// tms[i + startIndex] = true;
// }
// }
//
// public int randomItem(Random random) {
// int chosen = 0;
// while (!items[chosen]) {
// chosen = random.nextInt(items.length);
// }
// return chosen;
// }
//
// public int randomNonTM(Random random) {
// int chosen = 0;
// while (!items[chosen] || tms[chosen]) {
// chosen = random.nextInt(items.length);
// }
// return chosen;
// }
//
// public int randomTM(Random random) {
// int chosen = 0;
// while (!tms[chosen]) {
// chosen = random.nextInt(items.length);
// }
// return chosen;
// }
//
// public ItemList copy() {
// ItemList other = new ItemList(items.length - 1);
// System.arraycopy(items, 0, other.items, 0, items.length);
// System.arraycopy(tms, 0, other.tms, 0, tms.length);
// return other;
// }
//
// }
//
// Path: src/com/dabomstew/pkrandom/pokemon/MoveCategory.java
// public enum MoveCategory {
// PHYSICAL, SPECIAL, STATUS;
// }
//
// Path: src/com/dabomstew/pkrandom/pokemon/Type.java
// public enum Type {
//
// NORMAL, FIGHTING, FLYING, GRASS, WATER, FIRE, ROCK, GROUND, PSYCHIC, BUG, DRAGON, ELECTRIC, GHOST, POISON, ICE, STEEL, DARK, GAS(
// true), FAIRY(true), WOOD(true), ABNORMAL(true), WIND(true), SOUND(true), LIGHT(true), TRI(true);
//
// public boolean isHackOnly;
//
// private Type() {
// this.isHackOnly = false;
// }
//
// private Type(boolean isHackOnly) {
// this.isHackOnly = isHackOnly;
// }
//
// private static final List<Type> VALUES = Collections.unmodifiableList(Arrays.asList(values()));
// private static final int SIZE = VALUES.size();
//
// public static Type randomType(Random random) {
// return VALUES.get(random.nextInt(SIZE));
// }
//
// public String camelCase() {
// return RomFunctions.camelCase(this.toString());
// }
//
// }
| import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import com.dabomstew.pkrandom.pokemon.ItemList;
import com.dabomstew.pkrandom.pokemon.MoveCategory;
import com.dabomstew.pkrandom.pokemon.Trainer;
import com.dabomstew.pkrandom.pokemon.Type; | public static final int evolutionMethodCount = 27;
public static final int slowpokeIndex = 79, karrablastIndex = 588, shelmetIndex = 616;
public static final int waterStoneIndex = 84;
public static final int highestAbilityIndex = 123;
public static final int normalItemSetVarCommand = 0x28, hiddenItemSetVarCommand = 0x2A, normalItemVarSet = 0x800C,
hiddenItemVarSet = 0x8000;
public static final int scriptListTerminator = 0xFD13;
public static final int luckyEggIndex = 0xE7;
public static final MoveCategory[] moveCategoryIndices = { MoveCategory.STATUS, MoveCategory.PHYSICAL,
MoveCategory.SPECIAL };
public static byte moveCategoryToByte(MoveCategory cat) {
switch (cat) {
case PHYSICAL:
return 1;
case SPECIAL:
return 2;
case STATUS:
default:
return 0;
}
}
| // Path: src/com/dabomstew/pkrandom/pokemon/ItemList.java
// public class ItemList {
//
// private boolean[] items;
// private boolean[] tms;
//
// public ItemList(int highestIndex) {
// items = new boolean[highestIndex + 1];
// tms = new boolean[highestIndex + 1];
// for (int i = 1; i <= highestIndex; i++) {
// items[i] = true;
// }
// }
//
// public boolean isTM(int index) {
// if (index < 0 || index >= tms.length) {
// return false;
// }
// return tms[index];
// }
//
// public boolean isAllowed(int index) {
// if (index < 0 || index >= tms.length) {
// return false;
// }
// return items[index];
// }
//
// public void banSingles(int... indexes) {
// for (int index : indexes) {
// items[index] = false;
// }
// }
//
// public void banRange(int startIndex, int length) {
// for (int i = 0; i < length; i++) {
// items[i + startIndex] = false;
// }
// }
//
// public void tmRange(int startIndex, int length) {
// for (int i = 0; i < length; i++) {
// tms[i + startIndex] = true;
// }
// }
//
// public int randomItem(Random random) {
// int chosen = 0;
// while (!items[chosen]) {
// chosen = random.nextInt(items.length);
// }
// return chosen;
// }
//
// public int randomNonTM(Random random) {
// int chosen = 0;
// while (!items[chosen] || tms[chosen]) {
// chosen = random.nextInt(items.length);
// }
// return chosen;
// }
//
// public int randomTM(Random random) {
// int chosen = 0;
// while (!tms[chosen]) {
// chosen = random.nextInt(items.length);
// }
// return chosen;
// }
//
// public ItemList copy() {
// ItemList other = new ItemList(items.length - 1);
// System.arraycopy(items, 0, other.items, 0, items.length);
// System.arraycopy(tms, 0, other.tms, 0, tms.length);
// return other;
// }
//
// }
//
// Path: src/com/dabomstew/pkrandom/pokemon/MoveCategory.java
// public enum MoveCategory {
// PHYSICAL, SPECIAL, STATUS;
// }
//
// Path: src/com/dabomstew/pkrandom/pokemon/Type.java
// public enum Type {
//
// NORMAL, FIGHTING, FLYING, GRASS, WATER, FIRE, ROCK, GROUND, PSYCHIC, BUG, DRAGON, ELECTRIC, GHOST, POISON, ICE, STEEL, DARK, GAS(
// true), FAIRY(true), WOOD(true), ABNORMAL(true), WIND(true), SOUND(true), LIGHT(true), TRI(true);
//
// public boolean isHackOnly;
//
// private Type() {
// this.isHackOnly = false;
// }
//
// private Type(boolean isHackOnly) {
// this.isHackOnly = isHackOnly;
// }
//
// private static final List<Type> VALUES = Collections.unmodifiableList(Arrays.asList(values()));
// private static final int SIZE = VALUES.size();
//
// public static Type randomType(Random random) {
// return VALUES.get(random.nextInt(SIZE));
// }
//
// public String camelCase() {
// return RomFunctions.camelCase(this.toString());
// }
//
// }
// Path: src/com/dabomstew/pkrandom/constants/Gen5Constants.java
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import com.dabomstew.pkrandom.pokemon.ItemList;
import com.dabomstew.pkrandom.pokemon.MoveCategory;
import com.dabomstew.pkrandom.pokemon.Trainer;
import com.dabomstew.pkrandom.pokemon.Type;
public static final int evolutionMethodCount = 27;
public static final int slowpokeIndex = 79, karrablastIndex = 588, shelmetIndex = 616;
public static final int waterStoneIndex = 84;
public static final int highestAbilityIndex = 123;
public static final int normalItemSetVarCommand = 0x28, hiddenItemSetVarCommand = 0x2A, normalItemVarSet = 0x800C,
hiddenItemVarSet = 0x8000;
public static final int scriptListTerminator = 0xFD13;
public static final int luckyEggIndex = 0xE7;
public static final MoveCategory[] moveCategoryIndices = { MoveCategory.STATUS, MoveCategory.PHYSICAL,
MoveCategory.SPECIAL };
public static byte moveCategoryToByte(MoveCategory cat) {
switch (cat) {
case PHYSICAL:
return 1;
case SPECIAL:
return 2;
case STATUS:
default:
return 0;
}
}
| public static final Type[] typeTable = constructTypeTable(); |
Dabomstew/universal-pokemon-randomizer | src/com/dabomstew/pkrandom/constants/Gen5Constants.java | // Path: src/com/dabomstew/pkrandom/pokemon/ItemList.java
// public class ItemList {
//
// private boolean[] items;
// private boolean[] tms;
//
// public ItemList(int highestIndex) {
// items = new boolean[highestIndex + 1];
// tms = new boolean[highestIndex + 1];
// for (int i = 1; i <= highestIndex; i++) {
// items[i] = true;
// }
// }
//
// public boolean isTM(int index) {
// if (index < 0 || index >= tms.length) {
// return false;
// }
// return tms[index];
// }
//
// public boolean isAllowed(int index) {
// if (index < 0 || index >= tms.length) {
// return false;
// }
// return items[index];
// }
//
// public void banSingles(int... indexes) {
// for (int index : indexes) {
// items[index] = false;
// }
// }
//
// public void banRange(int startIndex, int length) {
// for (int i = 0; i < length; i++) {
// items[i + startIndex] = false;
// }
// }
//
// public void tmRange(int startIndex, int length) {
// for (int i = 0; i < length; i++) {
// tms[i + startIndex] = true;
// }
// }
//
// public int randomItem(Random random) {
// int chosen = 0;
// while (!items[chosen]) {
// chosen = random.nextInt(items.length);
// }
// return chosen;
// }
//
// public int randomNonTM(Random random) {
// int chosen = 0;
// while (!items[chosen] || tms[chosen]) {
// chosen = random.nextInt(items.length);
// }
// return chosen;
// }
//
// public int randomTM(Random random) {
// int chosen = 0;
// while (!tms[chosen]) {
// chosen = random.nextInt(items.length);
// }
// return chosen;
// }
//
// public ItemList copy() {
// ItemList other = new ItemList(items.length - 1);
// System.arraycopy(items, 0, other.items, 0, items.length);
// System.arraycopy(tms, 0, other.tms, 0, tms.length);
// return other;
// }
//
// }
//
// Path: src/com/dabomstew/pkrandom/pokemon/MoveCategory.java
// public enum MoveCategory {
// PHYSICAL, SPECIAL, STATUS;
// }
//
// Path: src/com/dabomstew/pkrandom/pokemon/Type.java
// public enum Type {
//
// NORMAL, FIGHTING, FLYING, GRASS, WATER, FIRE, ROCK, GROUND, PSYCHIC, BUG, DRAGON, ELECTRIC, GHOST, POISON, ICE, STEEL, DARK, GAS(
// true), FAIRY(true), WOOD(true), ABNORMAL(true), WIND(true), SOUND(true), LIGHT(true), TRI(true);
//
// public boolean isHackOnly;
//
// private Type() {
// this.isHackOnly = false;
// }
//
// private Type(boolean isHackOnly) {
// this.isHackOnly = isHackOnly;
// }
//
// private static final List<Type> VALUES = Collections.unmodifiableList(Arrays.asList(values()));
// private static final int SIZE = VALUES.size();
//
// public static Type randomType(Random random) {
// return VALUES.get(random.nextInt(SIZE));
// }
//
// public String camelCase() {
// return RomFunctions.camelCase(this.toString());
// }
//
// }
| import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import com.dabomstew.pkrandom.pokemon.ItemList;
import com.dabomstew.pkrandom.pokemon.MoveCategory;
import com.dabomstew.pkrandom.pokemon.Trainer;
import com.dabomstew.pkrandom.pokemon.Type; | return 0x04;
case ROCK:
return 0x05;
case BUG:
return 0x06;
case GHOST:
return 0x07;
case FIRE:
return 0x09;
case WATER:
return 0x0A;
case GRASS:
return 0x0B;
case ELECTRIC:
return 0x0C;
case PSYCHIC:
return 0x0D;
case ICE:
return 0x0E;
case DRAGON:
return 0x0F;
case STEEL:
return 0x08;
case DARK:
return 0x10;
default:
return 0; // normal by default
}
}
| // Path: src/com/dabomstew/pkrandom/pokemon/ItemList.java
// public class ItemList {
//
// private boolean[] items;
// private boolean[] tms;
//
// public ItemList(int highestIndex) {
// items = new boolean[highestIndex + 1];
// tms = new boolean[highestIndex + 1];
// for (int i = 1; i <= highestIndex; i++) {
// items[i] = true;
// }
// }
//
// public boolean isTM(int index) {
// if (index < 0 || index >= tms.length) {
// return false;
// }
// return tms[index];
// }
//
// public boolean isAllowed(int index) {
// if (index < 0 || index >= tms.length) {
// return false;
// }
// return items[index];
// }
//
// public void banSingles(int... indexes) {
// for (int index : indexes) {
// items[index] = false;
// }
// }
//
// public void banRange(int startIndex, int length) {
// for (int i = 0; i < length; i++) {
// items[i + startIndex] = false;
// }
// }
//
// public void tmRange(int startIndex, int length) {
// for (int i = 0; i < length; i++) {
// tms[i + startIndex] = true;
// }
// }
//
// public int randomItem(Random random) {
// int chosen = 0;
// while (!items[chosen]) {
// chosen = random.nextInt(items.length);
// }
// return chosen;
// }
//
// public int randomNonTM(Random random) {
// int chosen = 0;
// while (!items[chosen] || tms[chosen]) {
// chosen = random.nextInt(items.length);
// }
// return chosen;
// }
//
// public int randomTM(Random random) {
// int chosen = 0;
// while (!tms[chosen]) {
// chosen = random.nextInt(items.length);
// }
// return chosen;
// }
//
// public ItemList copy() {
// ItemList other = new ItemList(items.length - 1);
// System.arraycopy(items, 0, other.items, 0, items.length);
// System.arraycopy(tms, 0, other.tms, 0, tms.length);
// return other;
// }
//
// }
//
// Path: src/com/dabomstew/pkrandom/pokemon/MoveCategory.java
// public enum MoveCategory {
// PHYSICAL, SPECIAL, STATUS;
// }
//
// Path: src/com/dabomstew/pkrandom/pokemon/Type.java
// public enum Type {
//
// NORMAL, FIGHTING, FLYING, GRASS, WATER, FIRE, ROCK, GROUND, PSYCHIC, BUG, DRAGON, ELECTRIC, GHOST, POISON, ICE, STEEL, DARK, GAS(
// true), FAIRY(true), WOOD(true), ABNORMAL(true), WIND(true), SOUND(true), LIGHT(true), TRI(true);
//
// public boolean isHackOnly;
//
// private Type() {
// this.isHackOnly = false;
// }
//
// private Type(boolean isHackOnly) {
// this.isHackOnly = isHackOnly;
// }
//
// private static final List<Type> VALUES = Collections.unmodifiableList(Arrays.asList(values()));
// private static final int SIZE = VALUES.size();
//
// public static Type randomType(Random random) {
// return VALUES.get(random.nextInt(SIZE));
// }
//
// public String camelCase() {
// return RomFunctions.camelCase(this.toString());
// }
//
// }
// Path: src/com/dabomstew/pkrandom/constants/Gen5Constants.java
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import com.dabomstew.pkrandom.pokemon.ItemList;
import com.dabomstew.pkrandom.pokemon.MoveCategory;
import com.dabomstew.pkrandom.pokemon.Trainer;
import com.dabomstew.pkrandom.pokemon.Type;
return 0x04;
case ROCK:
return 0x05;
case BUG:
return 0x06;
case GHOST:
return 0x07;
case FIRE:
return 0x09;
case WATER:
return 0x0A;
case GRASS:
return 0x0B;
case ELECTRIC:
return 0x0C;
case PSYCHIC:
return 0x0D;
case ICE:
return 0x0E;
case DRAGON:
return 0x0F;
case STEEL:
return 0x08;
case DARK:
return 0x10;
default:
return 0; // normal by default
}
}
| public static ItemList allowedItems, nonBadItems; |
Dabomstew/universal-pokemon-randomizer | src/com/dabomstew/pkrandom/constants/Gen1Constants.java | // Path: src/com/dabomstew/pkrandom/pokemon/ItemList.java
// public class ItemList {
//
// private boolean[] items;
// private boolean[] tms;
//
// public ItemList(int highestIndex) {
// items = new boolean[highestIndex + 1];
// tms = new boolean[highestIndex + 1];
// for (int i = 1; i <= highestIndex; i++) {
// items[i] = true;
// }
// }
//
// public boolean isTM(int index) {
// if (index < 0 || index >= tms.length) {
// return false;
// }
// return tms[index];
// }
//
// public boolean isAllowed(int index) {
// if (index < 0 || index >= tms.length) {
// return false;
// }
// return items[index];
// }
//
// public void banSingles(int... indexes) {
// for (int index : indexes) {
// items[index] = false;
// }
// }
//
// public void banRange(int startIndex, int length) {
// for (int i = 0; i < length; i++) {
// items[i + startIndex] = false;
// }
// }
//
// public void tmRange(int startIndex, int length) {
// for (int i = 0; i < length; i++) {
// tms[i + startIndex] = true;
// }
// }
//
// public int randomItem(Random random) {
// int chosen = 0;
// while (!items[chosen]) {
// chosen = random.nextInt(items.length);
// }
// return chosen;
// }
//
// public int randomNonTM(Random random) {
// int chosen = 0;
// while (!items[chosen] || tms[chosen]) {
// chosen = random.nextInt(items.length);
// }
// return chosen;
// }
//
// public int randomTM(Random random) {
// int chosen = 0;
// while (!tms[chosen]) {
// chosen = random.nextInt(items.length);
// }
// return chosen;
// }
//
// public ItemList copy() {
// ItemList other = new ItemList(items.length - 1);
// System.arraycopy(items, 0, other.items, 0, items.length);
// System.arraycopy(tms, 0, other.tms, 0, tms.length);
// return other;
// }
//
// }
//
// Path: src/com/dabomstew/pkrandom/pokemon/Type.java
// public enum Type {
//
// NORMAL, FIGHTING, FLYING, GRASS, WATER, FIRE, ROCK, GROUND, PSYCHIC, BUG, DRAGON, ELECTRIC, GHOST, POISON, ICE, STEEL, DARK, GAS(
// true), FAIRY(true), WOOD(true), ABNORMAL(true), WIND(true), SOUND(true), LIGHT(true), TRI(true);
//
// public boolean isHackOnly;
//
// private Type() {
// this.isHackOnly = false;
// }
//
// private Type(boolean isHackOnly) {
// this.isHackOnly = isHackOnly;
// }
//
// private static final List<Type> VALUES = Collections.unmodifiableList(Arrays.asList(values()));
// private static final int SIZE = VALUES.size();
//
// public static Type randomType(Random random) {
// return VALUES.get(random.nextInt(SIZE));
// }
//
// public String camelCase() {
// return RomFunctions.camelCase(this.toString());
// }
//
// }
| import java.util.Arrays;
import java.util.List;
import com.dabomstew.pkrandom.pokemon.ItemList;
import com.dabomstew.pkrandom.pokemon.Trainer;
import com.dabomstew.pkrandom.pokemon.Type; | package com.dabomstew.pkrandom.constants;
public class Gen1Constants {
public static final int baseStatsEntrySize = 0x1C;
public static final int bsHPOffset = 1, bsAttackOffset = 2, bsDefenseOffset = 3, bsSpeedOffset = 4,
bsSpecialOffset = 5, bsPrimaryTypeOffset = 6, bsSecondaryTypeOffset = 7, bsCatchRateOffset = 8,
bsExpYieldOffset = 9, bsFrontSpriteOffset = 11, bsLevel1MovesOffset = 15, bsGrowthCurveOffset = 19,
bsTMHMCompatOffset = 20;
public static final int mewIndex = 151, marowakIndex = 105;
public static final int encounterTableEnd = 0xFFFF, encounterTableSize = 10, yellowSuperRodTableSize = 4;
public static final int trainerClassCount = 47;
public static final int champRivalOffsetFromGymLeaderMoves = 0x44;
public static final int tmCount = 50, hmCount = 5;
public static final int[] gymLeaderTMs = new int[] { 34, 11, 24, 21, 6, 46, 38, 27 };
public static final int[] tclassesCounts = new int[] { 21, 47 };
public static final List<Integer> singularTrainers = Arrays.asList(28, 32, 33, 34, 35, 36, 37, 38, 39, 43, 45, 46);
public static final List<Integer> bannedMovesWithXAccBanned = Arrays.asList(49, 82, 147);
public static final List<Integer> bannedMovesWithoutXAccBanned = Arrays.asList(49, 82, 32, 90, 12, 147);
public static final List<Integer> fieldMoves = Arrays.asList(15, 19, 57, 70, 148, 91, 100);
public static final List<Integer> earlyRequiredHMs = Arrays.asList(15);
public static final int hmsStartIndex = 0xC4, tmsStartIndex = 0xC9;
public static final List<Integer> requiredFieldTMs = Arrays.asList(new Integer[] { 3, 4, 8, 10, 12, 14, 16, 19, 20,
22, 25, 26, 30, 40, 43, 44, 45, 47 });
public static final int towerMapsStartIndex = 0x90, towerMapsEndIndex = 0x94;
| // Path: src/com/dabomstew/pkrandom/pokemon/ItemList.java
// public class ItemList {
//
// private boolean[] items;
// private boolean[] tms;
//
// public ItemList(int highestIndex) {
// items = new boolean[highestIndex + 1];
// tms = new boolean[highestIndex + 1];
// for (int i = 1; i <= highestIndex; i++) {
// items[i] = true;
// }
// }
//
// public boolean isTM(int index) {
// if (index < 0 || index >= tms.length) {
// return false;
// }
// return tms[index];
// }
//
// public boolean isAllowed(int index) {
// if (index < 0 || index >= tms.length) {
// return false;
// }
// return items[index];
// }
//
// public void banSingles(int... indexes) {
// for (int index : indexes) {
// items[index] = false;
// }
// }
//
// public void banRange(int startIndex, int length) {
// for (int i = 0; i < length; i++) {
// items[i + startIndex] = false;
// }
// }
//
// public void tmRange(int startIndex, int length) {
// for (int i = 0; i < length; i++) {
// tms[i + startIndex] = true;
// }
// }
//
// public int randomItem(Random random) {
// int chosen = 0;
// while (!items[chosen]) {
// chosen = random.nextInt(items.length);
// }
// return chosen;
// }
//
// public int randomNonTM(Random random) {
// int chosen = 0;
// while (!items[chosen] || tms[chosen]) {
// chosen = random.nextInt(items.length);
// }
// return chosen;
// }
//
// public int randomTM(Random random) {
// int chosen = 0;
// while (!tms[chosen]) {
// chosen = random.nextInt(items.length);
// }
// return chosen;
// }
//
// public ItemList copy() {
// ItemList other = new ItemList(items.length - 1);
// System.arraycopy(items, 0, other.items, 0, items.length);
// System.arraycopy(tms, 0, other.tms, 0, tms.length);
// return other;
// }
//
// }
//
// Path: src/com/dabomstew/pkrandom/pokemon/Type.java
// public enum Type {
//
// NORMAL, FIGHTING, FLYING, GRASS, WATER, FIRE, ROCK, GROUND, PSYCHIC, BUG, DRAGON, ELECTRIC, GHOST, POISON, ICE, STEEL, DARK, GAS(
// true), FAIRY(true), WOOD(true), ABNORMAL(true), WIND(true), SOUND(true), LIGHT(true), TRI(true);
//
// public boolean isHackOnly;
//
// private Type() {
// this.isHackOnly = false;
// }
//
// private Type(boolean isHackOnly) {
// this.isHackOnly = isHackOnly;
// }
//
// private static final List<Type> VALUES = Collections.unmodifiableList(Arrays.asList(values()));
// private static final int SIZE = VALUES.size();
//
// public static Type randomType(Random random) {
// return VALUES.get(random.nextInt(SIZE));
// }
//
// public String camelCase() {
// return RomFunctions.camelCase(this.toString());
// }
//
// }
// Path: src/com/dabomstew/pkrandom/constants/Gen1Constants.java
import java.util.Arrays;
import java.util.List;
import com.dabomstew.pkrandom.pokemon.ItemList;
import com.dabomstew.pkrandom.pokemon.Trainer;
import com.dabomstew.pkrandom.pokemon.Type;
package com.dabomstew.pkrandom.constants;
public class Gen1Constants {
public static final int baseStatsEntrySize = 0x1C;
public static final int bsHPOffset = 1, bsAttackOffset = 2, bsDefenseOffset = 3, bsSpeedOffset = 4,
bsSpecialOffset = 5, bsPrimaryTypeOffset = 6, bsSecondaryTypeOffset = 7, bsCatchRateOffset = 8,
bsExpYieldOffset = 9, bsFrontSpriteOffset = 11, bsLevel1MovesOffset = 15, bsGrowthCurveOffset = 19,
bsTMHMCompatOffset = 20;
public static final int mewIndex = 151, marowakIndex = 105;
public static final int encounterTableEnd = 0xFFFF, encounterTableSize = 10, yellowSuperRodTableSize = 4;
public static final int trainerClassCount = 47;
public static final int champRivalOffsetFromGymLeaderMoves = 0x44;
public static final int tmCount = 50, hmCount = 5;
public static final int[] gymLeaderTMs = new int[] { 34, 11, 24, 21, 6, 46, 38, 27 };
public static final int[] tclassesCounts = new int[] { 21, 47 };
public static final List<Integer> singularTrainers = Arrays.asList(28, 32, 33, 34, 35, 36, 37, 38, 39, 43, 45, 46);
public static final List<Integer> bannedMovesWithXAccBanned = Arrays.asList(49, 82, 147);
public static final List<Integer> bannedMovesWithoutXAccBanned = Arrays.asList(49, 82, 32, 90, 12, 147);
public static final List<Integer> fieldMoves = Arrays.asList(15, 19, 57, 70, 148, 91, 100);
public static final List<Integer> earlyRequiredHMs = Arrays.asList(15);
public static final int hmsStartIndex = 0xC4, tmsStartIndex = 0xC9;
public static final List<Integer> requiredFieldTMs = Arrays.asList(new Integer[] { 3, 4, 8, 10, 12, 14, 16, 19, 20,
22, 25, 26, 30, 40, 43, 44, 45, 47 });
public static final int towerMapsStartIndex = 0x90, towerMapsEndIndex = 0x94;
| public static final Type[] typeTable = constructTypeTable(); |
Dabomstew/universal-pokemon-randomizer | src/com/dabomstew/pkrandom/constants/Gen1Constants.java | // Path: src/com/dabomstew/pkrandom/pokemon/ItemList.java
// public class ItemList {
//
// private boolean[] items;
// private boolean[] tms;
//
// public ItemList(int highestIndex) {
// items = new boolean[highestIndex + 1];
// tms = new boolean[highestIndex + 1];
// for (int i = 1; i <= highestIndex; i++) {
// items[i] = true;
// }
// }
//
// public boolean isTM(int index) {
// if (index < 0 || index >= tms.length) {
// return false;
// }
// return tms[index];
// }
//
// public boolean isAllowed(int index) {
// if (index < 0 || index >= tms.length) {
// return false;
// }
// return items[index];
// }
//
// public void banSingles(int... indexes) {
// for (int index : indexes) {
// items[index] = false;
// }
// }
//
// public void banRange(int startIndex, int length) {
// for (int i = 0; i < length; i++) {
// items[i + startIndex] = false;
// }
// }
//
// public void tmRange(int startIndex, int length) {
// for (int i = 0; i < length; i++) {
// tms[i + startIndex] = true;
// }
// }
//
// public int randomItem(Random random) {
// int chosen = 0;
// while (!items[chosen]) {
// chosen = random.nextInt(items.length);
// }
// return chosen;
// }
//
// public int randomNonTM(Random random) {
// int chosen = 0;
// while (!items[chosen] || tms[chosen]) {
// chosen = random.nextInt(items.length);
// }
// return chosen;
// }
//
// public int randomTM(Random random) {
// int chosen = 0;
// while (!tms[chosen]) {
// chosen = random.nextInt(items.length);
// }
// return chosen;
// }
//
// public ItemList copy() {
// ItemList other = new ItemList(items.length - 1);
// System.arraycopy(items, 0, other.items, 0, items.length);
// System.arraycopy(tms, 0, other.tms, 0, tms.length);
// return other;
// }
//
// }
//
// Path: src/com/dabomstew/pkrandom/pokemon/Type.java
// public enum Type {
//
// NORMAL, FIGHTING, FLYING, GRASS, WATER, FIRE, ROCK, GROUND, PSYCHIC, BUG, DRAGON, ELECTRIC, GHOST, POISON, ICE, STEEL, DARK, GAS(
// true), FAIRY(true), WOOD(true), ABNORMAL(true), WIND(true), SOUND(true), LIGHT(true), TRI(true);
//
// public boolean isHackOnly;
//
// private Type() {
// this.isHackOnly = false;
// }
//
// private Type(boolean isHackOnly) {
// this.isHackOnly = isHackOnly;
// }
//
// private static final List<Type> VALUES = Collections.unmodifiableList(Arrays.asList(values()));
// private static final int SIZE = VALUES.size();
//
// public static Type randomType(Random random) {
// return VALUES.get(random.nextInt(SIZE));
// }
//
// public String camelCase() {
// return RomFunctions.camelCase(this.toString());
// }
//
// }
| import java.util.Arrays;
import java.util.List;
import com.dabomstew.pkrandom.pokemon.ItemList;
import com.dabomstew.pkrandom.pokemon.Trainer;
import com.dabomstew.pkrandom.pokemon.Type; |
private static Type[] constructTypeTable() {
Type[] table = new Type[0x20];
table[0x00] = Type.NORMAL;
table[0x01] = Type.FIGHTING;
table[0x02] = Type.FLYING;
table[0x03] = Type.POISON;
table[0x04] = Type.GROUND;
table[0x05] = Type.ROCK;
table[0x07] = Type.BUG;
table[0x08] = Type.GHOST;
table[0x14] = Type.FIRE;
table[0x15] = Type.WATER;
table[0x16] = Type.GRASS;
table[0x17] = Type.ELECTRIC;
table[0x18] = Type.PSYCHIC;
table[0x19] = Type.ICE;
table[0x1A] = Type.DRAGON;
return table;
}
public static byte typeToByte(Type type) {
for (int i = 0; i < typeTable.length; i++) {
if (typeTable[i] == type) {
return (byte) i;
}
}
return (byte) 0;
}
| // Path: src/com/dabomstew/pkrandom/pokemon/ItemList.java
// public class ItemList {
//
// private boolean[] items;
// private boolean[] tms;
//
// public ItemList(int highestIndex) {
// items = new boolean[highestIndex + 1];
// tms = new boolean[highestIndex + 1];
// for (int i = 1; i <= highestIndex; i++) {
// items[i] = true;
// }
// }
//
// public boolean isTM(int index) {
// if (index < 0 || index >= tms.length) {
// return false;
// }
// return tms[index];
// }
//
// public boolean isAllowed(int index) {
// if (index < 0 || index >= tms.length) {
// return false;
// }
// return items[index];
// }
//
// public void banSingles(int... indexes) {
// for (int index : indexes) {
// items[index] = false;
// }
// }
//
// public void banRange(int startIndex, int length) {
// for (int i = 0; i < length; i++) {
// items[i + startIndex] = false;
// }
// }
//
// public void tmRange(int startIndex, int length) {
// for (int i = 0; i < length; i++) {
// tms[i + startIndex] = true;
// }
// }
//
// public int randomItem(Random random) {
// int chosen = 0;
// while (!items[chosen]) {
// chosen = random.nextInt(items.length);
// }
// return chosen;
// }
//
// public int randomNonTM(Random random) {
// int chosen = 0;
// while (!items[chosen] || tms[chosen]) {
// chosen = random.nextInt(items.length);
// }
// return chosen;
// }
//
// public int randomTM(Random random) {
// int chosen = 0;
// while (!tms[chosen]) {
// chosen = random.nextInt(items.length);
// }
// return chosen;
// }
//
// public ItemList copy() {
// ItemList other = new ItemList(items.length - 1);
// System.arraycopy(items, 0, other.items, 0, items.length);
// System.arraycopy(tms, 0, other.tms, 0, tms.length);
// return other;
// }
//
// }
//
// Path: src/com/dabomstew/pkrandom/pokemon/Type.java
// public enum Type {
//
// NORMAL, FIGHTING, FLYING, GRASS, WATER, FIRE, ROCK, GROUND, PSYCHIC, BUG, DRAGON, ELECTRIC, GHOST, POISON, ICE, STEEL, DARK, GAS(
// true), FAIRY(true), WOOD(true), ABNORMAL(true), WIND(true), SOUND(true), LIGHT(true), TRI(true);
//
// public boolean isHackOnly;
//
// private Type() {
// this.isHackOnly = false;
// }
//
// private Type(boolean isHackOnly) {
// this.isHackOnly = isHackOnly;
// }
//
// private static final List<Type> VALUES = Collections.unmodifiableList(Arrays.asList(values()));
// private static final int SIZE = VALUES.size();
//
// public static Type randomType(Random random) {
// return VALUES.get(random.nextInt(SIZE));
// }
//
// public String camelCase() {
// return RomFunctions.camelCase(this.toString());
// }
//
// }
// Path: src/com/dabomstew/pkrandom/constants/Gen1Constants.java
import java.util.Arrays;
import java.util.List;
import com.dabomstew.pkrandom.pokemon.ItemList;
import com.dabomstew.pkrandom.pokemon.Trainer;
import com.dabomstew.pkrandom.pokemon.Type;
private static Type[] constructTypeTable() {
Type[] table = new Type[0x20];
table[0x00] = Type.NORMAL;
table[0x01] = Type.FIGHTING;
table[0x02] = Type.FLYING;
table[0x03] = Type.POISON;
table[0x04] = Type.GROUND;
table[0x05] = Type.ROCK;
table[0x07] = Type.BUG;
table[0x08] = Type.GHOST;
table[0x14] = Type.FIRE;
table[0x15] = Type.WATER;
table[0x16] = Type.GRASS;
table[0x17] = Type.ELECTRIC;
table[0x18] = Type.PSYCHIC;
table[0x19] = Type.ICE;
table[0x1A] = Type.DRAGON;
return table;
}
public static byte typeToByte(Type type) {
for (int i = 0; i < typeTable.length; i++) {
if (typeTable[i] == type) {
return (byte) i;
}
}
return (byte) 0;
}
| public static final ItemList allowedItems = setupAllowedItems(); |
alexcojocaru/elasticsearch-maven-plugin | src/main/java/com/github/alexcojocaru/mojo/elasticsearch/v2/AbstractElasticsearchBaseMojo.java | // Path: src/main/java/com/github/alexcojocaru/mojo/elasticsearch/v2/configuration/ChainedArtifactResolver.java
// public class ChainedArtifactResolver
// implements PluginArtifactResolver
// {
//
// protected List<PluginArtifactResolver> resolverChain = new LinkedList<PluginArtifactResolver>();
//
// public ChainedArtifactResolver()
// {
// this.resolverChain.add(new SystemPathArtifactResolver());
// }
//
// @Override
// public File resolveArtifact(final String coordinates) throws ArtifactException
// {
// File result = null;
// for (PluginArtifactResolver resolver : resolverChain)
// {
// try
// {
// result = resolver.resolveArtifact(coordinates);
// if (result != null)
// {
// break;
// }
// // CHECKSTYLE:OFF: Empty catch block
// }
// catch (ArtifactException e)
// {
// }
// // CHECKSTYLE:ON: Empty catch block
// }
// if (result == null)
// {
// throw new ArtifactException(
// "Could not resolve artifact with coordinates " + coordinates);
// }
// return result;
// }
//
// public void addPluginArtifactResolver(PluginArtifactResolver pluginArtifactResolver)
// {
// Validate.notNull(pluginArtifactResolver, "PluginArtifactResolvers should not be null");
// this.resolverChain.add(pluginArtifactResolver);
// }
//
// }
//
// Path: src/main/java/com/github/alexcojocaru/mojo/elasticsearch/v2/configuration/ElasticsearchBaseConfiguration.java
// public interface ElasticsearchBaseConfiguration
// {
// int getInstanceCount();
//
// File getBaseDir();
//
// boolean isSkip();
//
// String getLogLevel();
//
//
// ClusterConfiguration buildClusterConfiguration();
//
// PluginArtifactResolver buildArtifactResolver();
//
// Log getLog();
//
// }
//
// Path: src/main/java/com/github/alexcojocaru/mojo/elasticsearch/v2/configuration/PluginArtifactResolver.java
// public interface PluginArtifactResolver
// {
// File resolveArtifact(String coordinates) throws ArtifactException;
// }
| import java.io.File;
import org.apache.maven.monitor.logging.DefaultLog;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.logging.Log;
import org.apache.maven.plugins.annotations.Parameter;
import org.codehaus.plexus.logging.Logger;
import org.codehaus.plexus.logging.console.ConsoleLogger;
import com.github.alexcojocaru.mojo.elasticsearch.v2.configuration.ChainedArtifactResolver;
import com.github.alexcojocaru.mojo.elasticsearch.v2.configuration.ElasticsearchBaseConfiguration;
import com.github.alexcojocaru.mojo.elasticsearch.v2.configuration.PluginArtifactResolver; | package com.github.alexcojocaru.mojo.elasticsearch.v2;
/**
* Base mojo to define maven parameters required by all ES mojos.
*
* @author Alex Cojocaru
*/
public abstract class AbstractElasticsearchBaseMojo
extends AbstractMojo | // Path: src/main/java/com/github/alexcojocaru/mojo/elasticsearch/v2/configuration/ChainedArtifactResolver.java
// public class ChainedArtifactResolver
// implements PluginArtifactResolver
// {
//
// protected List<PluginArtifactResolver> resolverChain = new LinkedList<PluginArtifactResolver>();
//
// public ChainedArtifactResolver()
// {
// this.resolverChain.add(new SystemPathArtifactResolver());
// }
//
// @Override
// public File resolveArtifact(final String coordinates) throws ArtifactException
// {
// File result = null;
// for (PluginArtifactResolver resolver : resolverChain)
// {
// try
// {
// result = resolver.resolveArtifact(coordinates);
// if (result != null)
// {
// break;
// }
// // CHECKSTYLE:OFF: Empty catch block
// }
// catch (ArtifactException e)
// {
// }
// // CHECKSTYLE:ON: Empty catch block
// }
// if (result == null)
// {
// throw new ArtifactException(
// "Could not resolve artifact with coordinates " + coordinates);
// }
// return result;
// }
//
// public void addPluginArtifactResolver(PluginArtifactResolver pluginArtifactResolver)
// {
// Validate.notNull(pluginArtifactResolver, "PluginArtifactResolvers should not be null");
// this.resolverChain.add(pluginArtifactResolver);
// }
//
// }
//
// Path: src/main/java/com/github/alexcojocaru/mojo/elasticsearch/v2/configuration/ElasticsearchBaseConfiguration.java
// public interface ElasticsearchBaseConfiguration
// {
// int getInstanceCount();
//
// File getBaseDir();
//
// boolean isSkip();
//
// String getLogLevel();
//
//
// ClusterConfiguration buildClusterConfiguration();
//
// PluginArtifactResolver buildArtifactResolver();
//
// Log getLog();
//
// }
//
// Path: src/main/java/com/github/alexcojocaru/mojo/elasticsearch/v2/configuration/PluginArtifactResolver.java
// public interface PluginArtifactResolver
// {
// File resolveArtifact(String coordinates) throws ArtifactException;
// }
// Path: src/main/java/com/github/alexcojocaru/mojo/elasticsearch/v2/AbstractElasticsearchBaseMojo.java
import java.io.File;
import org.apache.maven.monitor.logging.DefaultLog;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.logging.Log;
import org.apache.maven.plugins.annotations.Parameter;
import org.codehaus.plexus.logging.Logger;
import org.codehaus.plexus.logging.console.ConsoleLogger;
import com.github.alexcojocaru.mojo.elasticsearch.v2.configuration.ChainedArtifactResolver;
import com.github.alexcojocaru.mojo.elasticsearch.v2.configuration.ElasticsearchBaseConfiguration;
import com.github.alexcojocaru.mojo.elasticsearch.v2.configuration.PluginArtifactResolver;
package com.github.alexcojocaru.mojo.elasticsearch.v2;
/**
* Base mojo to define maven parameters required by all ES mojos.
*
* @author Alex Cojocaru
*/
public abstract class AbstractElasticsearchBaseMojo
extends AbstractMojo | implements ElasticsearchBaseConfiguration |
alexcojocaru/elasticsearch-maven-plugin | src/main/java/com/github/alexcojocaru/mojo/elasticsearch/v2/AbstractElasticsearchBaseMojo.java | // Path: src/main/java/com/github/alexcojocaru/mojo/elasticsearch/v2/configuration/ChainedArtifactResolver.java
// public class ChainedArtifactResolver
// implements PluginArtifactResolver
// {
//
// protected List<PluginArtifactResolver> resolverChain = new LinkedList<PluginArtifactResolver>();
//
// public ChainedArtifactResolver()
// {
// this.resolverChain.add(new SystemPathArtifactResolver());
// }
//
// @Override
// public File resolveArtifact(final String coordinates) throws ArtifactException
// {
// File result = null;
// for (PluginArtifactResolver resolver : resolverChain)
// {
// try
// {
// result = resolver.resolveArtifact(coordinates);
// if (result != null)
// {
// break;
// }
// // CHECKSTYLE:OFF: Empty catch block
// }
// catch (ArtifactException e)
// {
// }
// // CHECKSTYLE:ON: Empty catch block
// }
// if (result == null)
// {
// throw new ArtifactException(
// "Could not resolve artifact with coordinates " + coordinates);
// }
// return result;
// }
//
// public void addPluginArtifactResolver(PluginArtifactResolver pluginArtifactResolver)
// {
// Validate.notNull(pluginArtifactResolver, "PluginArtifactResolvers should not be null");
// this.resolverChain.add(pluginArtifactResolver);
// }
//
// }
//
// Path: src/main/java/com/github/alexcojocaru/mojo/elasticsearch/v2/configuration/ElasticsearchBaseConfiguration.java
// public interface ElasticsearchBaseConfiguration
// {
// int getInstanceCount();
//
// File getBaseDir();
//
// boolean isSkip();
//
// String getLogLevel();
//
//
// ClusterConfiguration buildClusterConfiguration();
//
// PluginArtifactResolver buildArtifactResolver();
//
// Log getLog();
//
// }
//
// Path: src/main/java/com/github/alexcojocaru/mojo/elasticsearch/v2/configuration/PluginArtifactResolver.java
// public interface PluginArtifactResolver
// {
// File resolveArtifact(String coordinates) throws ArtifactException;
// }
| import java.io.File;
import org.apache.maven.monitor.logging.DefaultLog;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.logging.Log;
import org.apache.maven.plugins.annotations.Parameter;
import org.codehaus.plexus.logging.Logger;
import org.codehaus.plexus.logging.console.ConsoleLogger;
import com.github.alexcojocaru.mojo.elasticsearch.v2.configuration.ChainedArtifactResolver;
import com.github.alexcojocaru.mojo.elasticsearch.v2.configuration.ElasticsearchBaseConfiguration;
import com.github.alexcojocaru.mojo.elasticsearch.v2.configuration.PluginArtifactResolver; | public Log getLog()
{
if (log == null)
{
log = new DefaultLog(new ConsoleLogger(getMavenLogLevel(), "console"));
}
return log;
}
@Override
public ClusterConfiguration buildClusterConfiguration()
{
ClusterConfiguration.Builder clusterConfigBuilder = new ClusterConfiguration.Builder()
.withArtifactResolver(buildArtifactResolver())
.withLog(getLog());
for (int i = 0; i < instanceCount; i++)
{
clusterConfigBuilder.addInstanceConfiguration(new InstanceConfiguration.Builder()
.withId(i)
.withBaseDir(baseDir.getAbsolutePath() + i)
.build());
}
ClusterConfiguration clusterConfig = clusterConfigBuilder.build();
return clusterConfig;
}
@Override | // Path: src/main/java/com/github/alexcojocaru/mojo/elasticsearch/v2/configuration/ChainedArtifactResolver.java
// public class ChainedArtifactResolver
// implements PluginArtifactResolver
// {
//
// protected List<PluginArtifactResolver> resolverChain = new LinkedList<PluginArtifactResolver>();
//
// public ChainedArtifactResolver()
// {
// this.resolverChain.add(new SystemPathArtifactResolver());
// }
//
// @Override
// public File resolveArtifact(final String coordinates) throws ArtifactException
// {
// File result = null;
// for (PluginArtifactResolver resolver : resolverChain)
// {
// try
// {
// result = resolver.resolveArtifact(coordinates);
// if (result != null)
// {
// break;
// }
// // CHECKSTYLE:OFF: Empty catch block
// }
// catch (ArtifactException e)
// {
// }
// // CHECKSTYLE:ON: Empty catch block
// }
// if (result == null)
// {
// throw new ArtifactException(
// "Could not resolve artifact with coordinates " + coordinates);
// }
// return result;
// }
//
// public void addPluginArtifactResolver(PluginArtifactResolver pluginArtifactResolver)
// {
// Validate.notNull(pluginArtifactResolver, "PluginArtifactResolvers should not be null");
// this.resolverChain.add(pluginArtifactResolver);
// }
//
// }
//
// Path: src/main/java/com/github/alexcojocaru/mojo/elasticsearch/v2/configuration/ElasticsearchBaseConfiguration.java
// public interface ElasticsearchBaseConfiguration
// {
// int getInstanceCount();
//
// File getBaseDir();
//
// boolean isSkip();
//
// String getLogLevel();
//
//
// ClusterConfiguration buildClusterConfiguration();
//
// PluginArtifactResolver buildArtifactResolver();
//
// Log getLog();
//
// }
//
// Path: src/main/java/com/github/alexcojocaru/mojo/elasticsearch/v2/configuration/PluginArtifactResolver.java
// public interface PluginArtifactResolver
// {
// File resolveArtifact(String coordinates) throws ArtifactException;
// }
// Path: src/main/java/com/github/alexcojocaru/mojo/elasticsearch/v2/AbstractElasticsearchBaseMojo.java
import java.io.File;
import org.apache.maven.monitor.logging.DefaultLog;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.logging.Log;
import org.apache.maven.plugins.annotations.Parameter;
import org.codehaus.plexus.logging.Logger;
import org.codehaus.plexus.logging.console.ConsoleLogger;
import com.github.alexcojocaru.mojo.elasticsearch.v2.configuration.ChainedArtifactResolver;
import com.github.alexcojocaru.mojo.elasticsearch.v2.configuration.ElasticsearchBaseConfiguration;
import com.github.alexcojocaru.mojo.elasticsearch.v2.configuration.PluginArtifactResolver;
public Log getLog()
{
if (log == null)
{
log = new DefaultLog(new ConsoleLogger(getMavenLogLevel(), "console"));
}
return log;
}
@Override
public ClusterConfiguration buildClusterConfiguration()
{
ClusterConfiguration.Builder clusterConfigBuilder = new ClusterConfiguration.Builder()
.withArtifactResolver(buildArtifactResolver())
.withLog(getLog());
for (int i = 0; i < instanceCount; i++)
{
clusterConfigBuilder.addInstanceConfiguration(new InstanceConfiguration.Builder()
.withId(i)
.withBaseDir(baseDir.getAbsolutePath() + i)
.build());
}
ClusterConfiguration clusterConfig = clusterConfigBuilder.build();
return clusterConfig;
}
@Override | public PluginArtifactResolver buildArtifactResolver() |
alexcojocaru/elasticsearch-maven-plugin | src/main/java/com/github/alexcojocaru/mojo/elasticsearch/v2/AbstractElasticsearchBaseMojo.java | // Path: src/main/java/com/github/alexcojocaru/mojo/elasticsearch/v2/configuration/ChainedArtifactResolver.java
// public class ChainedArtifactResolver
// implements PluginArtifactResolver
// {
//
// protected List<PluginArtifactResolver> resolverChain = new LinkedList<PluginArtifactResolver>();
//
// public ChainedArtifactResolver()
// {
// this.resolverChain.add(new SystemPathArtifactResolver());
// }
//
// @Override
// public File resolveArtifact(final String coordinates) throws ArtifactException
// {
// File result = null;
// for (PluginArtifactResolver resolver : resolverChain)
// {
// try
// {
// result = resolver.resolveArtifact(coordinates);
// if (result != null)
// {
// break;
// }
// // CHECKSTYLE:OFF: Empty catch block
// }
// catch (ArtifactException e)
// {
// }
// // CHECKSTYLE:ON: Empty catch block
// }
// if (result == null)
// {
// throw new ArtifactException(
// "Could not resolve artifact with coordinates " + coordinates);
// }
// return result;
// }
//
// public void addPluginArtifactResolver(PluginArtifactResolver pluginArtifactResolver)
// {
// Validate.notNull(pluginArtifactResolver, "PluginArtifactResolvers should not be null");
// this.resolverChain.add(pluginArtifactResolver);
// }
//
// }
//
// Path: src/main/java/com/github/alexcojocaru/mojo/elasticsearch/v2/configuration/ElasticsearchBaseConfiguration.java
// public interface ElasticsearchBaseConfiguration
// {
// int getInstanceCount();
//
// File getBaseDir();
//
// boolean isSkip();
//
// String getLogLevel();
//
//
// ClusterConfiguration buildClusterConfiguration();
//
// PluginArtifactResolver buildArtifactResolver();
//
// Log getLog();
//
// }
//
// Path: src/main/java/com/github/alexcojocaru/mojo/elasticsearch/v2/configuration/PluginArtifactResolver.java
// public interface PluginArtifactResolver
// {
// File resolveArtifact(String coordinates) throws ArtifactException;
// }
| import java.io.File;
import org.apache.maven.monitor.logging.DefaultLog;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.logging.Log;
import org.apache.maven.plugins.annotations.Parameter;
import org.codehaus.plexus.logging.Logger;
import org.codehaus.plexus.logging.console.ConsoleLogger;
import com.github.alexcojocaru.mojo.elasticsearch.v2.configuration.ChainedArtifactResolver;
import com.github.alexcojocaru.mojo.elasticsearch.v2.configuration.ElasticsearchBaseConfiguration;
import com.github.alexcojocaru.mojo.elasticsearch.v2.configuration.PluginArtifactResolver; | if (log == null)
{
log = new DefaultLog(new ConsoleLogger(getMavenLogLevel(), "console"));
}
return log;
}
@Override
public ClusterConfiguration buildClusterConfiguration()
{
ClusterConfiguration.Builder clusterConfigBuilder = new ClusterConfiguration.Builder()
.withArtifactResolver(buildArtifactResolver())
.withLog(getLog());
for (int i = 0; i < instanceCount; i++)
{
clusterConfigBuilder.addInstanceConfiguration(new InstanceConfiguration.Builder()
.withId(i)
.withBaseDir(baseDir.getAbsolutePath() + i)
.build());
}
ClusterConfiguration clusterConfig = clusterConfigBuilder.build();
return clusterConfig;
}
@Override
public PluginArtifactResolver buildArtifactResolver()
{ | // Path: src/main/java/com/github/alexcojocaru/mojo/elasticsearch/v2/configuration/ChainedArtifactResolver.java
// public class ChainedArtifactResolver
// implements PluginArtifactResolver
// {
//
// protected List<PluginArtifactResolver> resolverChain = new LinkedList<PluginArtifactResolver>();
//
// public ChainedArtifactResolver()
// {
// this.resolverChain.add(new SystemPathArtifactResolver());
// }
//
// @Override
// public File resolveArtifact(final String coordinates) throws ArtifactException
// {
// File result = null;
// for (PluginArtifactResolver resolver : resolverChain)
// {
// try
// {
// result = resolver.resolveArtifact(coordinates);
// if (result != null)
// {
// break;
// }
// // CHECKSTYLE:OFF: Empty catch block
// }
// catch (ArtifactException e)
// {
// }
// // CHECKSTYLE:ON: Empty catch block
// }
// if (result == null)
// {
// throw new ArtifactException(
// "Could not resolve artifact with coordinates " + coordinates);
// }
// return result;
// }
//
// public void addPluginArtifactResolver(PluginArtifactResolver pluginArtifactResolver)
// {
// Validate.notNull(pluginArtifactResolver, "PluginArtifactResolvers should not be null");
// this.resolverChain.add(pluginArtifactResolver);
// }
//
// }
//
// Path: src/main/java/com/github/alexcojocaru/mojo/elasticsearch/v2/configuration/ElasticsearchBaseConfiguration.java
// public interface ElasticsearchBaseConfiguration
// {
// int getInstanceCount();
//
// File getBaseDir();
//
// boolean isSkip();
//
// String getLogLevel();
//
//
// ClusterConfiguration buildClusterConfiguration();
//
// PluginArtifactResolver buildArtifactResolver();
//
// Log getLog();
//
// }
//
// Path: src/main/java/com/github/alexcojocaru/mojo/elasticsearch/v2/configuration/PluginArtifactResolver.java
// public interface PluginArtifactResolver
// {
// File resolveArtifact(String coordinates) throws ArtifactException;
// }
// Path: src/main/java/com/github/alexcojocaru/mojo/elasticsearch/v2/AbstractElasticsearchBaseMojo.java
import java.io.File;
import org.apache.maven.monitor.logging.DefaultLog;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.logging.Log;
import org.apache.maven.plugins.annotations.Parameter;
import org.codehaus.plexus.logging.Logger;
import org.codehaus.plexus.logging.console.ConsoleLogger;
import com.github.alexcojocaru.mojo.elasticsearch.v2.configuration.ChainedArtifactResolver;
import com.github.alexcojocaru.mojo.elasticsearch.v2.configuration.ElasticsearchBaseConfiguration;
import com.github.alexcojocaru.mojo.elasticsearch.v2.configuration.PluginArtifactResolver;
if (log == null)
{
log = new DefaultLog(new ConsoleLogger(getMavenLogLevel(), "console"));
}
return log;
}
@Override
public ClusterConfiguration buildClusterConfiguration()
{
ClusterConfiguration.Builder clusterConfigBuilder = new ClusterConfiguration.Builder()
.withArtifactResolver(buildArtifactResolver())
.withLog(getLog());
for (int i = 0; i < instanceCount; i++)
{
clusterConfigBuilder.addInstanceConfiguration(new InstanceConfiguration.Builder()
.withId(i)
.withBaseDir(baseDir.getAbsolutePath() + i)
.build());
}
ClusterConfiguration clusterConfig = clusterConfigBuilder.build();
return clusterConfig;
}
@Override
public PluginArtifactResolver buildArtifactResolver()
{ | ChainedArtifactResolver artifactResolver = new ChainedArtifactResolver(); |
alexcojocaru/elasticsearch-maven-plugin | src/main/java/com/github/alexcojocaru/mojo/elasticsearch/v2/configuration/Artifacts.java | // Path: src/main/java/com/github/alexcojocaru/mojo/elasticsearch/v2/AbstractArtifact.java
// public abstract class AbstractArtifact {
//
// @Parameter(required=true)
// protected String groupId;
//
// @Parameter(required=true)
// protected String artifactId;
//
// @Parameter
// protected String version;
//
// @Parameter
// protected String type;
//
// @Parameter
// protected String classifier;
//
// @Parameter
// protected String systemPath;
//
// protected File file;
//
// public AbstractArtifact() {
// // default constructor
// }
//
// public AbstractArtifact(String groupId, String artifactId, String version, String classifier, String type) {
// this.setGroupId(groupId);
// this.setArtifactId(artifactId);
// this.setVersion(version);
// this.setClassifier(classifier);
// this.setType(type);
//
// }
//
// public String getGroupId() {
// return groupId;
// }
//
// public void setGroupId(String groupId) {
// this.groupId = groupId;
// }
//
// public String getArtifactId() {
// return artifactId;
// }
//
// public void setArtifactId(String artifactId) {
// this.artifactId = artifactId;
// }
//
// public String getVersion() {
// return version;
// }
//
// public void setVersion(String version) {
// this.version = version;
// }
//
// public abstract String getType();
//
// public void setType(String type) {
// this.type = type;
// }
//
// public String getClassifier() {
// return classifier;
// }
//
// public void setClassifier(String classifier) {
// this.classifier = classifier;
// }
//
// public String getSystemPath() {
// return this.systemPath;
// }
//
// public void setSystemPath(String systemPath) {
// this.systemPath = systemPath;
// }
//
// public File getFile() {
// return file;
// }
//
// public void setFile(File file) {
// this.file = file;
// }
//
// public String getArtifactCoordinates() {
// if (!StringUtils.isBlank(getSystemPath())) {
// return getSystemPath();
// } else {
// return buildDefaultMavenCoordinates();
// }
// }
//
// /**
// * The {@code <groupId>:<artifactId>[:<extension>[:<classifier>]]:<version>} of the artifact.
// *
// * @return The Maven coordinates for the current artifact
// */
// protected String buildDefaultMavenCoordinates() {
// StringBuilder sb = new StringBuilder();
// sb.append(getGroupId()).append(":");
// sb.append(getArtifactId());
// if (StringUtils.isNotBlank(getType())) {
// sb.append(":").append(getType());
// }
// if (StringUtils.isNotBlank(getClassifier())) {
// sb.append(":").append(getClassifier());
// }
// sb.append(":");
// sb.append(getVersion());
// return sb.toString().trim();
// }
//
// @Override
// public String toString() {
// return "Artifact[" + getArtifactCoordinates() + "]";
// }
//
// }
| import com.github.alexcojocaru.mojo.elasticsearch.v2.AbstractArtifact;
import com.google.common.base.Splitter;
import com.google.common.collect.Iterables; | /**
* Copyright (C) 2010-2012 Joerg Bellmann <joerg.bellmann@googlemail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.alexcojocaru.mojo.elasticsearch.v2.configuration;
/**
* Copied from the t7mp project.
*
* @author Joerg Bellmann
*
*/
public final class Artifacts
{
private static final int ZERO = 0;
private static final int ONE = 1;
private static final int TWO = 2;
private static final int THREE = 3;
private static final int FOUR = 4;
private static final int FIVE = 5;
private Artifacts()
{
// hide constructor
}
| // Path: src/main/java/com/github/alexcojocaru/mojo/elasticsearch/v2/AbstractArtifact.java
// public abstract class AbstractArtifact {
//
// @Parameter(required=true)
// protected String groupId;
//
// @Parameter(required=true)
// protected String artifactId;
//
// @Parameter
// protected String version;
//
// @Parameter
// protected String type;
//
// @Parameter
// protected String classifier;
//
// @Parameter
// protected String systemPath;
//
// protected File file;
//
// public AbstractArtifact() {
// // default constructor
// }
//
// public AbstractArtifact(String groupId, String artifactId, String version, String classifier, String type) {
// this.setGroupId(groupId);
// this.setArtifactId(artifactId);
// this.setVersion(version);
// this.setClassifier(classifier);
// this.setType(type);
//
// }
//
// public String getGroupId() {
// return groupId;
// }
//
// public void setGroupId(String groupId) {
// this.groupId = groupId;
// }
//
// public String getArtifactId() {
// return artifactId;
// }
//
// public void setArtifactId(String artifactId) {
// this.artifactId = artifactId;
// }
//
// public String getVersion() {
// return version;
// }
//
// public void setVersion(String version) {
// this.version = version;
// }
//
// public abstract String getType();
//
// public void setType(String type) {
// this.type = type;
// }
//
// public String getClassifier() {
// return classifier;
// }
//
// public void setClassifier(String classifier) {
// this.classifier = classifier;
// }
//
// public String getSystemPath() {
// return this.systemPath;
// }
//
// public void setSystemPath(String systemPath) {
// this.systemPath = systemPath;
// }
//
// public File getFile() {
// return file;
// }
//
// public void setFile(File file) {
// this.file = file;
// }
//
// public String getArtifactCoordinates() {
// if (!StringUtils.isBlank(getSystemPath())) {
// return getSystemPath();
// } else {
// return buildDefaultMavenCoordinates();
// }
// }
//
// /**
// * The {@code <groupId>:<artifactId>[:<extension>[:<classifier>]]:<version>} of the artifact.
// *
// * @return The Maven coordinates for the current artifact
// */
// protected String buildDefaultMavenCoordinates() {
// StringBuilder sb = new StringBuilder();
// sb.append(getGroupId()).append(":");
// sb.append(getArtifactId());
// if (StringUtils.isNotBlank(getType())) {
// sb.append(":").append(getType());
// }
// if (StringUtils.isNotBlank(getClassifier())) {
// sb.append(":").append(getClassifier());
// }
// sb.append(":");
// sb.append(getVersion());
// return sb.toString().trim();
// }
//
// @Override
// public String toString() {
// return "Artifact[" + getArtifactCoordinates() + "]";
// }
//
// }
// Path: src/main/java/com/github/alexcojocaru/mojo/elasticsearch/v2/configuration/Artifacts.java
import com.github.alexcojocaru.mojo.elasticsearch.v2.AbstractArtifact;
import com.google.common.base.Splitter;
import com.google.common.collect.Iterables;
/**
* Copyright (C) 2010-2012 Joerg Bellmann <joerg.bellmann@googlemail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.alexcojocaru.mojo.elasticsearch.v2.configuration;
/**
* Copied from the t7mp project.
*
* @author Joerg Bellmann
*
*/
public final class Artifacts
{
private static final int ZERO = 0;
private static final int ONE = 1;
private static final int TWO = 2;
private static final int THREE = 3;
private static final int FOUR = 4;
private static final int FIVE = 5;
private Artifacts()
{
// hide constructor
}
| public static AbstractArtifact fromCoordinates(String coordinates) |
alexcojocaru/elasticsearch-maven-plugin | src/main/java/com/github/alexcojocaru/mojo/elasticsearch/v2/AbstractElasticsearchMojo.java | // Path: src/main/java/com/github/alexcojocaru/mojo/elasticsearch/v2/configuration/ChainedArtifactResolver.java
// public class ChainedArtifactResolver
// implements PluginArtifactResolver
// {
//
// protected List<PluginArtifactResolver> resolverChain = new LinkedList<PluginArtifactResolver>();
//
// public ChainedArtifactResolver()
// {
// this.resolverChain.add(new SystemPathArtifactResolver());
// }
//
// @Override
// public File resolveArtifact(final String coordinates) throws ArtifactException
// {
// File result = null;
// for (PluginArtifactResolver resolver : resolverChain)
// {
// try
// {
// result = resolver.resolveArtifact(coordinates);
// if (result != null)
// {
// break;
// }
// // CHECKSTYLE:OFF: Empty catch block
// }
// catch (ArtifactException e)
// {
// }
// // CHECKSTYLE:ON: Empty catch block
// }
// if (result == null)
// {
// throw new ArtifactException(
// "Could not resolve artifact with coordinates " + coordinates);
// }
// return result;
// }
//
// public void addPluginArtifactResolver(PluginArtifactResolver pluginArtifactResolver)
// {
// Validate.notNull(pluginArtifactResolver, "PluginArtifactResolvers should not be null");
// this.resolverChain.add(pluginArtifactResolver);
// }
//
// }
//
// Path: src/main/java/com/github/alexcojocaru/mojo/elasticsearch/v2/configuration/ElasticsearchConfiguration.java
// public interface ElasticsearchConfiguration extends ElasticsearchBaseConfiguration
// {
// String getVersion();
//
// String getClusterName();
//
// int getHttpPort();
//
// int getTransportPort();
//
// String getPathConf();
//
// String getPathData();
//
// String getPathLogs();
//
// List<PluginConfiguration> getPlugins();
//
// List<String> getPathInitScript();
//
// boolean isKeepExistingData();
//
// int getInstanceStartupTimeout();
//
// int getClusterStartupTimeout();
//
// boolean isSetAwait();
//
// boolean isAutoCreateIndex();
// }
//
// Path: src/main/java/com/github/alexcojocaru/mojo/elasticsearch/v2/configuration/PluginArtifactInstaller.java
// public interface PluginArtifactInstaller
// {
//
// void installArtifact(ElasticsearchArtifact artifact, File file) throws ArtifactException;
//
// }
//
// Path: src/main/java/com/github/alexcojocaru/mojo/elasticsearch/v2/configuration/PluginArtifactResolver.java
// public interface PluginArtifactResolver
// {
// File resolveArtifact(String coordinates) throws ArtifactException;
// }
| import com.github.alexcojocaru.mojo.elasticsearch.v2.configuration.ChainedArtifactResolver;
import com.github.alexcojocaru.mojo.elasticsearch.v2.configuration.ElasticsearchConfiguration;
import com.github.alexcojocaru.mojo.elasticsearch.v2.configuration.PluginArtifactInstaller;
import com.github.alexcojocaru.mojo.elasticsearch.v2.configuration.PluginArtifactResolver;
import com.google.common.base.Preconditions;
import org.apache.commons.lang3.StringUtils;
import org.apache.maven.plugins.annotations.Component;
import org.apache.maven.plugins.annotations.Parameter;
import org.eclipse.aether.RepositorySystem;
import org.eclipse.aether.RepositorySystemSession;
import org.eclipse.aether.repository.RemoteRepository;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.stream.Collectors;
import java.util.stream.Stream; | package com.github.alexcojocaru.mojo.elasticsearch.v2;
/**
* Mojo to define extra maven parameters required by the run forked mojo.
*
* @author Alex Cojocaru
*/
public abstract class AbstractElasticsearchMojo
extends AbstractElasticsearchBaseMojo | // Path: src/main/java/com/github/alexcojocaru/mojo/elasticsearch/v2/configuration/ChainedArtifactResolver.java
// public class ChainedArtifactResolver
// implements PluginArtifactResolver
// {
//
// protected List<PluginArtifactResolver> resolverChain = new LinkedList<PluginArtifactResolver>();
//
// public ChainedArtifactResolver()
// {
// this.resolverChain.add(new SystemPathArtifactResolver());
// }
//
// @Override
// public File resolveArtifact(final String coordinates) throws ArtifactException
// {
// File result = null;
// for (PluginArtifactResolver resolver : resolverChain)
// {
// try
// {
// result = resolver.resolveArtifact(coordinates);
// if (result != null)
// {
// break;
// }
// // CHECKSTYLE:OFF: Empty catch block
// }
// catch (ArtifactException e)
// {
// }
// // CHECKSTYLE:ON: Empty catch block
// }
// if (result == null)
// {
// throw new ArtifactException(
// "Could not resolve artifact with coordinates " + coordinates);
// }
// return result;
// }
//
// public void addPluginArtifactResolver(PluginArtifactResolver pluginArtifactResolver)
// {
// Validate.notNull(pluginArtifactResolver, "PluginArtifactResolvers should not be null");
// this.resolverChain.add(pluginArtifactResolver);
// }
//
// }
//
// Path: src/main/java/com/github/alexcojocaru/mojo/elasticsearch/v2/configuration/ElasticsearchConfiguration.java
// public interface ElasticsearchConfiguration extends ElasticsearchBaseConfiguration
// {
// String getVersion();
//
// String getClusterName();
//
// int getHttpPort();
//
// int getTransportPort();
//
// String getPathConf();
//
// String getPathData();
//
// String getPathLogs();
//
// List<PluginConfiguration> getPlugins();
//
// List<String> getPathInitScript();
//
// boolean isKeepExistingData();
//
// int getInstanceStartupTimeout();
//
// int getClusterStartupTimeout();
//
// boolean isSetAwait();
//
// boolean isAutoCreateIndex();
// }
//
// Path: src/main/java/com/github/alexcojocaru/mojo/elasticsearch/v2/configuration/PluginArtifactInstaller.java
// public interface PluginArtifactInstaller
// {
//
// void installArtifact(ElasticsearchArtifact artifact, File file) throws ArtifactException;
//
// }
//
// Path: src/main/java/com/github/alexcojocaru/mojo/elasticsearch/v2/configuration/PluginArtifactResolver.java
// public interface PluginArtifactResolver
// {
// File resolveArtifact(String coordinates) throws ArtifactException;
// }
// Path: src/main/java/com/github/alexcojocaru/mojo/elasticsearch/v2/AbstractElasticsearchMojo.java
import com.github.alexcojocaru.mojo.elasticsearch.v2.configuration.ChainedArtifactResolver;
import com.github.alexcojocaru.mojo.elasticsearch.v2.configuration.ElasticsearchConfiguration;
import com.github.alexcojocaru.mojo.elasticsearch.v2.configuration.PluginArtifactInstaller;
import com.github.alexcojocaru.mojo.elasticsearch.v2.configuration.PluginArtifactResolver;
import com.google.common.base.Preconditions;
import org.apache.commons.lang3.StringUtils;
import org.apache.maven.plugins.annotations.Component;
import org.apache.maven.plugins.annotations.Parameter;
import org.eclipse.aether.RepositorySystem;
import org.eclipse.aether.RepositorySystemSession;
import org.eclipse.aether.repository.RemoteRepository;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.stream.Collectors;
import java.util.stream.Stream;
package com.github.alexcojocaru.mojo.elasticsearch.v2;
/**
* Mojo to define extra maven parameters required by the run forked mojo.
*
* @author Alex Cojocaru
*/
public abstract class AbstractElasticsearchMojo
extends AbstractElasticsearchBaseMojo | implements ElasticsearchConfiguration |
alexcojocaru/elasticsearch-maven-plugin | src/main/java/com/github/alexcojocaru/mojo/elasticsearch/v2/AbstractElasticsearchMojo.java | // Path: src/main/java/com/github/alexcojocaru/mojo/elasticsearch/v2/configuration/ChainedArtifactResolver.java
// public class ChainedArtifactResolver
// implements PluginArtifactResolver
// {
//
// protected List<PluginArtifactResolver> resolverChain = new LinkedList<PluginArtifactResolver>();
//
// public ChainedArtifactResolver()
// {
// this.resolverChain.add(new SystemPathArtifactResolver());
// }
//
// @Override
// public File resolveArtifact(final String coordinates) throws ArtifactException
// {
// File result = null;
// for (PluginArtifactResolver resolver : resolverChain)
// {
// try
// {
// result = resolver.resolveArtifact(coordinates);
// if (result != null)
// {
// break;
// }
// // CHECKSTYLE:OFF: Empty catch block
// }
// catch (ArtifactException e)
// {
// }
// // CHECKSTYLE:ON: Empty catch block
// }
// if (result == null)
// {
// throw new ArtifactException(
// "Could not resolve artifact with coordinates " + coordinates);
// }
// return result;
// }
//
// public void addPluginArtifactResolver(PluginArtifactResolver pluginArtifactResolver)
// {
// Validate.notNull(pluginArtifactResolver, "PluginArtifactResolvers should not be null");
// this.resolverChain.add(pluginArtifactResolver);
// }
//
// }
//
// Path: src/main/java/com/github/alexcojocaru/mojo/elasticsearch/v2/configuration/ElasticsearchConfiguration.java
// public interface ElasticsearchConfiguration extends ElasticsearchBaseConfiguration
// {
// String getVersion();
//
// String getClusterName();
//
// int getHttpPort();
//
// int getTransportPort();
//
// String getPathConf();
//
// String getPathData();
//
// String getPathLogs();
//
// List<PluginConfiguration> getPlugins();
//
// List<String> getPathInitScript();
//
// boolean isKeepExistingData();
//
// int getInstanceStartupTimeout();
//
// int getClusterStartupTimeout();
//
// boolean isSetAwait();
//
// boolean isAutoCreateIndex();
// }
//
// Path: src/main/java/com/github/alexcojocaru/mojo/elasticsearch/v2/configuration/PluginArtifactInstaller.java
// public interface PluginArtifactInstaller
// {
//
// void installArtifact(ElasticsearchArtifact artifact, File file) throws ArtifactException;
//
// }
//
// Path: src/main/java/com/github/alexcojocaru/mojo/elasticsearch/v2/configuration/PluginArtifactResolver.java
// public interface PluginArtifactResolver
// {
// File resolveArtifact(String coordinates) throws ArtifactException;
// }
| import com.github.alexcojocaru.mojo.elasticsearch.v2.configuration.ChainedArtifactResolver;
import com.github.alexcojocaru.mojo.elasticsearch.v2.configuration.ElasticsearchConfiguration;
import com.github.alexcojocaru.mojo.elasticsearch.v2.configuration.PluginArtifactInstaller;
import com.github.alexcojocaru.mojo.elasticsearch.v2.configuration.PluginArtifactResolver;
import com.google.common.base.Preconditions;
import org.apache.commons.lang3.StringUtils;
import org.apache.maven.plugins.annotations.Component;
import org.apache.maven.plugins.annotations.Parameter;
import org.eclipse.aether.RepositorySystem;
import org.eclipse.aether.RepositorySystemSession;
import org.eclipse.aether.repository.RemoteRepository;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.stream.Collectors;
import java.util.stream.Stream; | .withPathConf(pathConf)
.withElasticsearchPlugins(plugins)
.withPathInitScripts(getPathInitScript())
.withKeepExistingData(keepExistingData)
.withStartupTimeout(clusterStartupTimeout)
.withSetAwait(setAwait)
.withAutoCreateIndex(autoCreateIndex);
for (int i = 0; i < instanceCount; i++)
{
final Properties settings = instanceSettings.size() > i ? instanceSettings.get(i): null;
clusterConfigBuilder.addInstanceConfiguration(new InstanceConfiguration.Builder()
.withId(i)
.withBaseDir(baseDir.getAbsolutePath() + i)
.withHttpPort(httpPort + i)
.withTransportPort(transportPort + i)
.withPathData(pathData)
.withPathLogs(pathLogs)
.withEnvironmentVariables(environmentVariables)
.withSettings(settings)
.withStartupTimeout(instanceStartupTimeout)
.build());
}
ClusterConfiguration clusterConfig = clusterConfigBuilder.build();
return clusterConfig;
}
@Override | // Path: src/main/java/com/github/alexcojocaru/mojo/elasticsearch/v2/configuration/ChainedArtifactResolver.java
// public class ChainedArtifactResolver
// implements PluginArtifactResolver
// {
//
// protected List<PluginArtifactResolver> resolverChain = new LinkedList<PluginArtifactResolver>();
//
// public ChainedArtifactResolver()
// {
// this.resolverChain.add(new SystemPathArtifactResolver());
// }
//
// @Override
// public File resolveArtifact(final String coordinates) throws ArtifactException
// {
// File result = null;
// for (PluginArtifactResolver resolver : resolverChain)
// {
// try
// {
// result = resolver.resolveArtifact(coordinates);
// if (result != null)
// {
// break;
// }
// // CHECKSTYLE:OFF: Empty catch block
// }
// catch (ArtifactException e)
// {
// }
// // CHECKSTYLE:ON: Empty catch block
// }
// if (result == null)
// {
// throw new ArtifactException(
// "Could not resolve artifact with coordinates " + coordinates);
// }
// return result;
// }
//
// public void addPluginArtifactResolver(PluginArtifactResolver pluginArtifactResolver)
// {
// Validate.notNull(pluginArtifactResolver, "PluginArtifactResolvers should not be null");
// this.resolverChain.add(pluginArtifactResolver);
// }
//
// }
//
// Path: src/main/java/com/github/alexcojocaru/mojo/elasticsearch/v2/configuration/ElasticsearchConfiguration.java
// public interface ElasticsearchConfiguration extends ElasticsearchBaseConfiguration
// {
// String getVersion();
//
// String getClusterName();
//
// int getHttpPort();
//
// int getTransportPort();
//
// String getPathConf();
//
// String getPathData();
//
// String getPathLogs();
//
// List<PluginConfiguration> getPlugins();
//
// List<String> getPathInitScript();
//
// boolean isKeepExistingData();
//
// int getInstanceStartupTimeout();
//
// int getClusterStartupTimeout();
//
// boolean isSetAwait();
//
// boolean isAutoCreateIndex();
// }
//
// Path: src/main/java/com/github/alexcojocaru/mojo/elasticsearch/v2/configuration/PluginArtifactInstaller.java
// public interface PluginArtifactInstaller
// {
//
// void installArtifact(ElasticsearchArtifact artifact, File file) throws ArtifactException;
//
// }
//
// Path: src/main/java/com/github/alexcojocaru/mojo/elasticsearch/v2/configuration/PluginArtifactResolver.java
// public interface PluginArtifactResolver
// {
// File resolveArtifact(String coordinates) throws ArtifactException;
// }
// Path: src/main/java/com/github/alexcojocaru/mojo/elasticsearch/v2/AbstractElasticsearchMojo.java
import com.github.alexcojocaru.mojo.elasticsearch.v2.configuration.ChainedArtifactResolver;
import com.github.alexcojocaru.mojo.elasticsearch.v2.configuration.ElasticsearchConfiguration;
import com.github.alexcojocaru.mojo.elasticsearch.v2.configuration.PluginArtifactInstaller;
import com.github.alexcojocaru.mojo.elasticsearch.v2.configuration.PluginArtifactResolver;
import com.google.common.base.Preconditions;
import org.apache.commons.lang3.StringUtils;
import org.apache.maven.plugins.annotations.Component;
import org.apache.maven.plugins.annotations.Parameter;
import org.eclipse.aether.RepositorySystem;
import org.eclipse.aether.RepositorySystemSession;
import org.eclipse.aether.repository.RemoteRepository;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.stream.Collectors;
import java.util.stream.Stream;
.withPathConf(pathConf)
.withElasticsearchPlugins(plugins)
.withPathInitScripts(getPathInitScript())
.withKeepExistingData(keepExistingData)
.withStartupTimeout(clusterStartupTimeout)
.withSetAwait(setAwait)
.withAutoCreateIndex(autoCreateIndex);
for (int i = 0; i < instanceCount; i++)
{
final Properties settings = instanceSettings.size() > i ? instanceSettings.get(i): null;
clusterConfigBuilder.addInstanceConfiguration(new InstanceConfiguration.Builder()
.withId(i)
.withBaseDir(baseDir.getAbsolutePath() + i)
.withHttpPort(httpPort + i)
.withTransportPort(transportPort + i)
.withPathData(pathData)
.withPathLogs(pathLogs)
.withEnvironmentVariables(environmentVariables)
.withSettings(settings)
.withStartupTimeout(instanceStartupTimeout)
.build());
}
ClusterConfiguration clusterConfig = clusterConfigBuilder.build();
return clusterConfig;
}
@Override | public PluginArtifactResolver buildArtifactResolver() |
alexcojocaru/elasticsearch-maven-plugin | src/main/java/com/github/alexcojocaru/mojo/elasticsearch/v2/AbstractElasticsearchMojo.java | // Path: src/main/java/com/github/alexcojocaru/mojo/elasticsearch/v2/configuration/ChainedArtifactResolver.java
// public class ChainedArtifactResolver
// implements PluginArtifactResolver
// {
//
// protected List<PluginArtifactResolver> resolverChain = new LinkedList<PluginArtifactResolver>();
//
// public ChainedArtifactResolver()
// {
// this.resolverChain.add(new SystemPathArtifactResolver());
// }
//
// @Override
// public File resolveArtifact(final String coordinates) throws ArtifactException
// {
// File result = null;
// for (PluginArtifactResolver resolver : resolverChain)
// {
// try
// {
// result = resolver.resolveArtifact(coordinates);
// if (result != null)
// {
// break;
// }
// // CHECKSTYLE:OFF: Empty catch block
// }
// catch (ArtifactException e)
// {
// }
// // CHECKSTYLE:ON: Empty catch block
// }
// if (result == null)
// {
// throw new ArtifactException(
// "Could not resolve artifact with coordinates " + coordinates);
// }
// return result;
// }
//
// public void addPluginArtifactResolver(PluginArtifactResolver pluginArtifactResolver)
// {
// Validate.notNull(pluginArtifactResolver, "PluginArtifactResolvers should not be null");
// this.resolverChain.add(pluginArtifactResolver);
// }
//
// }
//
// Path: src/main/java/com/github/alexcojocaru/mojo/elasticsearch/v2/configuration/ElasticsearchConfiguration.java
// public interface ElasticsearchConfiguration extends ElasticsearchBaseConfiguration
// {
// String getVersion();
//
// String getClusterName();
//
// int getHttpPort();
//
// int getTransportPort();
//
// String getPathConf();
//
// String getPathData();
//
// String getPathLogs();
//
// List<PluginConfiguration> getPlugins();
//
// List<String> getPathInitScript();
//
// boolean isKeepExistingData();
//
// int getInstanceStartupTimeout();
//
// int getClusterStartupTimeout();
//
// boolean isSetAwait();
//
// boolean isAutoCreateIndex();
// }
//
// Path: src/main/java/com/github/alexcojocaru/mojo/elasticsearch/v2/configuration/PluginArtifactInstaller.java
// public interface PluginArtifactInstaller
// {
//
// void installArtifact(ElasticsearchArtifact artifact, File file) throws ArtifactException;
//
// }
//
// Path: src/main/java/com/github/alexcojocaru/mojo/elasticsearch/v2/configuration/PluginArtifactResolver.java
// public interface PluginArtifactResolver
// {
// File resolveArtifact(String coordinates) throws ArtifactException;
// }
| import com.github.alexcojocaru.mojo.elasticsearch.v2.configuration.ChainedArtifactResolver;
import com.github.alexcojocaru.mojo.elasticsearch.v2.configuration.ElasticsearchConfiguration;
import com.github.alexcojocaru.mojo.elasticsearch.v2.configuration.PluginArtifactInstaller;
import com.github.alexcojocaru.mojo.elasticsearch.v2.configuration.PluginArtifactResolver;
import com.google.common.base.Preconditions;
import org.apache.commons.lang3.StringUtils;
import org.apache.maven.plugins.annotations.Component;
import org.apache.maven.plugins.annotations.Parameter;
import org.eclipse.aether.RepositorySystem;
import org.eclipse.aether.RepositorySystemSession;
import org.eclipse.aether.repository.RemoteRepository;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.stream.Collectors;
import java.util.stream.Stream; | .withPathInitScripts(getPathInitScript())
.withKeepExistingData(keepExistingData)
.withStartupTimeout(clusterStartupTimeout)
.withSetAwait(setAwait)
.withAutoCreateIndex(autoCreateIndex);
for (int i = 0; i < instanceCount; i++)
{
final Properties settings = instanceSettings.size() > i ? instanceSettings.get(i): null;
clusterConfigBuilder.addInstanceConfiguration(new InstanceConfiguration.Builder()
.withId(i)
.withBaseDir(baseDir.getAbsolutePath() + i)
.withHttpPort(httpPort + i)
.withTransportPort(transportPort + i)
.withPathData(pathData)
.withPathLogs(pathLogs)
.withEnvironmentVariables(environmentVariables)
.withSettings(settings)
.withStartupTimeout(instanceStartupTimeout)
.build());
}
ClusterConfiguration clusterConfig = clusterConfigBuilder.build();
return clusterConfig;
}
@Override
public PluginArtifactResolver buildArtifactResolver()
{ | // Path: src/main/java/com/github/alexcojocaru/mojo/elasticsearch/v2/configuration/ChainedArtifactResolver.java
// public class ChainedArtifactResolver
// implements PluginArtifactResolver
// {
//
// protected List<PluginArtifactResolver> resolverChain = new LinkedList<PluginArtifactResolver>();
//
// public ChainedArtifactResolver()
// {
// this.resolverChain.add(new SystemPathArtifactResolver());
// }
//
// @Override
// public File resolveArtifact(final String coordinates) throws ArtifactException
// {
// File result = null;
// for (PluginArtifactResolver resolver : resolverChain)
// {
// try
// {
// result = resolver.resolveArtifact(coordinates);
// if (result != null)
// {
// break;
// }
// // CHECKSTYLE:OFF: Empty catch block
// }
// catch (ArtifactException e)
// {
// }
// // CHECKSTYLE:ON: Empty catch block
// }
// if (result == null)
// {
// throw new ArtifactException(
// "Could not resolve artifact with coordinates " + coordinates);
// }
// return result;
// }
//
// public void addPluginArtifactResolver(PluginArtifactResolver pluginArtifactResolver)
// {
// Validate.notNull(pluginArtifactResolver, "PluginArtifactResolvers should not be null");
// this.resolverChain.add(pluginArtifactResolver);
// }
//
// }
//
// Path: src/main/java/com/github/alexcojocaru/mojo/elasticsearch/v2/configuration/ElasticsearchConfiguration.java
// public interface ElasticsearchConfiguration extends ElasticsearchBaseConfiguration
// {
// String getVersion();
//
// String getClusterName();
//
// int getHttpPort();
//
// int getTransportPort();
//
// String getPathConf();
//
// String getPathData();
//
// String getPathLogs();
//
// List<PluginConfiguration> getPlugins();
//
// List<String> getPathInitScript();
//
// boolean isKeepExistingData();
//
// int getInstanceStartupTimeout();
//
// int getClusterStartupTimeout();
//
// boolean isSetAwait();
//
// boolean isAutoCreateIndex();
// }
//
// Path: src/main/java/com/github/alexcojocaru/mojo/elasticsearch/v2/configuration/PluginArtifactInstaller.java
// public interface PluginArtifactInstaller
// {
//
// void installArtifact(ElasticsearchArtifact artifact, File file) throws ArtifactException;
//
// }
//
// Path: src/main/java/com/github/alexcojocaru/mojo/elasticsearch/v2/configuration/PluginArtifactResolver.java
// public interface PluginArtifactResolver
// {
// File resolveArtifact(String coordinates) throws ArtifactException;
// }
// Path: src/main/java/com/github/alexcojocaru/mojo/elasticsearch/v2/AbstractElasticsearchMojo.java
import com.github.alexcojocaru.mojo.elasticsearch.v2.configuration.ChainedArtifactResolver;
import com.github.alexcojocaru.mojo.elasticsearch.v2.configuration.ElasticsearchConfiguration;
import com.github.alexcojocaru.mojo.elasticsearch.v2.configuration.PluginArtifactInstaller;
import com.github.alexcojocaru.mojo.elasticsearch.v2.configuration.PluginArtifactResolver;
import com.google.common.base.Preconditions;
import org.apache.commons.lang3.StringUtils;
import org.apache.maven.plugins.annotations.Component;
import org.apache.maven.plugins.annotations.Parameter;
import org.eclipse.aether.RepositorySystem;
import org.eclipse.aether.RepositorySystemSession;
import org.eclipse.aether.repository.RemoteRepository;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.stream.Collectors;
import java.util.stream.Stream;
.withPathInitScripts(getPathInitScript())
.withKeepExistingData(keepExistingData)
.withStartupTimeout(clusterStartupTimeout)
.withSetAwait(setAwait)
.withAutoCreateIndex(autoCreateIndex);
for (int i = 0; i < instanceCount; i++)
{
final Properties settings = instanceSettings.size() > i ? instanceSettings.get(i): null;
clusterConfigBuilder.addInstanceConfiguration(new InstanceConfiguration.Builder()
.withId(i)
.withBaseDir(baseDir.getAbsolutePath() + i)
.withHttpPort(httpPort + i)
.withTransportPort(transportPort + i)
.withPathData(pathData)
.withPathLogs(pathLogs)
.withEnvironmentVariables(environmentVariables)
.withSettings(settings)
.withStartupTimeout(instanceStartupTimeout)
.build());
}
ClusterConfiguration clusterConfig = clusterConfigBuilder.build();
return clusterConfig;
}
@Override
public PluginArtifactResolver buildArtifactResolver()
{ | ChainedArtifactResolver artifactResolver = new ChainedArtifactResolver(); |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.