Skip to content

Commit

Permalink
Merge branch 'master-androidx' into master-androidx-java8
Browse files Browse the repository at this point in the history
  • Loading branch information
keepactive committed Nov 2, 2020
2 parents 01c5df6 + 2e74f1a commit 13b17f1
Show file tree
Hide file tree
Showing 50 changed files with 508 additions and 225 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.xiaojinzi.component.anno;

import com.xiaojinzi.component.anno.support.UiThreadCreateAnno;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
* 重试注解
*/
@UiThreadCreateAnno
@Target({ElementType.TYPE, ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
public @interface RetryAnno {

/**
* 这个服务对应的接口
*/
int value() default 1;

}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import java.io.IOException;
import java.io.Writer;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
Expand Down Expand Up @@ -97,7 +98,11 @@ public synchronized void init(ProcessingEnvironment processingEnvironment) {
arrayListClassName = ClassName.get(arrayListTypeElement);

activityTypeMirror = mElements.getTypeElement(ComponentConstants.ANDROID_ACTIVITY).asType();
fragmentTypeMirror = mElements.getTypeElement(ComponentConstants.ANDROID_FRAGMENT).asType();
TypeElement typeElementFragment = mElements.getTypeElement(ComponentConstants.ANDROID_FRAGMENT);
if (typeElementFragment == null) {
throw new ProcessException(getAddDependencyTip(Arrays.asList(ComponentConstants.ANDROID_FRAGMENT), false));
}
fragmentTypeMirror = typeElementFragment.asType();

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ public abstract class BaseHostProcessor extends BaseProcessor {
// 在每一个 module 中配置的 HOST 的信息
protected String componentHost = null;


@Override
public synchronized void init(ProcessingEnvironment processingEnvironment) {
super.init(processingEnvironment);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import com.squareup.javapoet.ClassName;
import com.squareup.javapoet.TypeName;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

import javax.annotation.processing.AbstractProcessor;
Expand Down Expand Up @@ -125,13 +127,33 @@ public synchronized void init(ProcessingEnvironment processingEnvironment) {
mClassNameNonNull = ClassName.get(mElements.getTypeElement(ComponentConstants.ANDROID_ANNOTATION_NONNULL));

if (mClassNameKeep == null || mClassNameNonNull == null) {
throw new ProcessException("Your configuration is wrong. " +
String addDependencyTip = getAddDependencyTip(Arrays.asList(
ComponentConstants.ANDROID_ANNOTATION_KEEP,
ComponentConstants.ANDROID_ANNOTATION_NONNULL
), true);
throw new ProcessException(addDependencyTip + " \nif you add dependency already, then your configuration is wrong. " +
"If you use androidx, see https://github.com/xiaojinzi123/Component/wiki/%E4%BE%9D%E8%B5%96%E5%92%8C%E9%85%8D%E7%BD%AE-AndroidX " +
"\n else see https://github.com/xiaojinzi123/Component/wiki/%E4%BE%9D%E8%B5%96%E5%92%8C%E9%85%8D%E7%BD%AE");
}

}

protected String getAddDependencyTip(List<String> classPathList, boolean isOr) {
StringBuilder sb = new StringBuilder();
for (int i = 0; i < classPathList.size(); i++) {
String classPath = classPathList.get(i);
if (i == 0) {
sb.append("'")
.append(classPath)
.append("'");
} else {
sb.append(" ").append(isOr ? "or" : "and").append(" ").append("'").append(classPath).append("'");
}
}
sb.append(" ").append("can't be found, did you add dependency to build.gradle?");
return sb.toString();
}

protected boolean isRouterDocEnable() {
return routerDocEnable && (routerDocFolder != null && !routerDocFolder.isEmpty());
}
Expand Down
2 changes: 2 additions & 0 deletions ComponentImpl/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'com.github.dcendents.android-maven'

group = 'com.github.xiaojinzi123'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.xiaojinzi.component.error;

public class NotSupportException extends RuntimeException {

public NotSupportException() {
}

public NotSupportException(String message) {
super(message);
}

public NotSupportException(String message, Throwable cause) {
super(message, cause);
}

public NotSupportException(Throwable cause) {
super(cause);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.xiaojinzi.component.error;

public class RunTimeTimeoutException extends RuntimeException {

public RunTimeTimeoutException() {
}

public RunTimeTimeoutException(String message) {
super(message);
}

public RunTimeTimeoutException(String message, Throwable cause) {
super(message, cause);
}

public RunTimeTimeoutException(Throwable cause) {
super(cause);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
*
* @author xiaojinzi
*/
@UiThread
@CheckClassNameAnno
public interface Callback extends OnRouterError, OnRouterCancel {

Expand Down
Loading

0 comments on commit 13b17f1

Please sign in to comment.