Skip to content

Commit

Permalink
Compile scan version 2.1.0:
Browse files Browse the repository at this point in the history
1. Support multi tag/group scanning.
  • Loading branch information
zhuqian committed May 8, 2023
1 parent d951c3d commit 55c6aaa
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package com.joelzhu.lib.scanner.java;

import com.joelzhu.lib.scanner.java.utils.Constants;
import com.joelzhu.lib.scanner.runtime.Scanner;
import com.joelzhu.lib.scanner.runtime.core.Options;

import android.os.Bundle;
import android.widget.TextView;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import com.joelzhu.lib.scanner.java.utils.Constants;
import com.joelzhu.lib.scanner.runtime.Scanner;
import com.joelzhu.lib.scanner.runtime.core.Options;

/**
* MainActivity.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,8 @@ private static <T> T[] handleReturning(final Options options, final T[] originRe
}

private static boolean isLegal(final Options options, final ScannedClass scannedClass) {
if (options.getTag().equals(scannedClass.getTag()) || options.isListAllTags()) {
if (options.getGroup().equals(scannedClass.getGroup()) || options.isListAllGroups()) {
if (options.getTags().contains(scannedClass.getTag()) || options.isListAllTags()) {
if (options.getGroups().contains(scannedClass.getGroup()) || options.isListAllGroups()) {
return !scannedClass.isDefault() || options.isWithDefault();
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package com.joelzhu.lib.scanner.runtime.core;

import java.util.ArrayList;
import java.util.List;

import com.joelzhu.lib.scanner.annotation.CompileScan;
import com.joelzhu.lib.scanner.runtime.Scanner;

import android.text.TextUtils;
import android.util.Log;

/**
Expand All @@ -15,9 +17,9 @@
public final class Options {
private static final String TAG = "CompileScan";

private String tag = "";
private final List<String> tags = new ArrayList<>();

private String group = "";
private final List<String> groups = new ArrayList<>();

private boolean enableNullReturn = false;

Expand Down Expand Up @@ -46,7 +48,7 @@ public Builder tag(final String tag) {
Log.e(TAG, "Already specified to list all tags, can't specify tag again.");
return this;
}
options.tag = tag;
options.tags.add(tag);
return this;
}

Expand All @@ -60,7 +62,7 @@ public Builder group(final String group) {
Log.e(TAG, "Already specified to list all groups, can't specify group again.");
return this;
}
options.group = group;
options.groups.add(group);
return this;
}

Expand All @@ -81,7 +83,7 @@ public Builder enableDefault() {
* @return Builder
*/
public Builder listAllTags() {
if (!TextUtils.isEmpty(options.tag)) {
if (!options.tags.isEmpty()) {
Log.w(TAG, "Already specified tag, this set will ignore the tag which specified before.");
}
options.listAllTags = true;
Expand All @@ -94,7 +96,7 @@ public Builder listAllTags() {
* @return Builder
*/
public Builder listAllGroups() {
if (!TextUtils.isEmpty(options.group)) {
if (!options.groups.isEmpty()) {
Log.w(TAG, "Already specified group, this set will ignore the group which specified before.");
}
options.listAllGroups = true;
Expand Down Expand Up @@ -127,12 +129,12 @@ public Options create() {
}
}

public String getTag() {
return tag;
public List<String> getTags() {
return tags;
}

public String getGroup() {
return group;
public List<String> getGroups() {
return groups;
}

public boolean isWithDefault() {
Expand Down

0 comments on commit 55c6aaa

Please sign in to comment.