Skip to content

Commit

Permalink
优化
Browse files Browse the repository at this point in the history
  • Loading branch information
Invinciblelee committed May 26, 2019
1 parent a773cf3 commit 0c820eb
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ private void matchSearchListRegex(List<SearchBookBean> searchBooks, String res,
ruleGroups.add(Assistant.splitRegexRule(rule));
}
// 提取书籍列表信息
do {
while (resM.find()){
// 获取列表规则分组数
int resCount = resM.groupCount();
// 新建规则结果容器
Expand All @@ -154,7 +154,7 @@ private void matchSearchListRegex(List<SearchBookBean> searchBooks, String res,
}
// 保存当前节点的书籍信息
addSearchBook(searchBooks, infoList[0], infoList[1], infoList[2], infoList[3], infoList[4], infoList[5], infoList[6], getConfig().getVariableStore().getVariableMap());
} while (resM.find());
}
} else {
StringBuilder result = new StringBuilder();
while (resM.find()) result.append(resM.group());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,25 @@ final class RulePattern {
private RulePattern(@NonNull String rawRule, @Nullable VariableStore variableStore, @Nullable RuleMode ruleMode) {
elementsRule = new Rule();

final boolean regexTrait;

if (ruleMode == null) {
Rule rule = RootRule.fromStringRule(rawRule);
elementsRule.setMode(rule.getMode());

rawRule = rule.getRule();

regexTrait = true;
} else {
elementsRule.setMode(ruleMode);

regexTrait = false;
}

initRulePattern(rawRule, variableStore, elementsRule.getMode());
initRulePattern(rawRule, variableStore, elementsRule.getMode(), regexTrait);
}

private void initRulePattern(String rawRule, VariableStore variableStore, RuleMode ruleMode) {
private void initRulePattern(String rawRule, VariableStore variableStore, RuleMode ruleMode, boolean regexTrait) {
//分离get规则
rawRule = VariablesPattern.fromGetterRule(rawRule, variableStore).rule;

Expand All @@ -56,7 +62,7 @@ private void initRulePattern(String rawRule, VariableStore variableStore, RuleMo
rawRule = ensureRedirectRule(rawRule);

//分离正则表达式
rawRule = ensureRegexRule(rawRule, ruleMode == RuleMode.CSS || ruleMode == RuleMode.XPath);
rawRule = ensureRegexRule(rawRule, regexTrait || ruleMode == RuleMode.CSS || ruleMode == RuleMode.XPath);

//分离js
int start = ensureJavaScripts(rawRule);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ public static String[] splitRegexRule(String str) {
}
}
if (start > index) list.add(str.substring(index, start));
String[] arr = new String[list.size()];
return list.toArray(arr);
return list.toArray(new String[0]);
}

public static List<Object> evalArrayScript(String jsStr, JavaExecutor java, Object result, String baseUrl) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public void initData() {
this.put("java", getJavaExecutor());
}};
String javaScript = findRule.substring(4, sourceBean.getRuleFindUrl().lastIndexOf("<"));
findRule = (String) Assistant.evalObjectScript(javaScript, bindings);
findRule = String.valueOf(Assistant.evalObjectScript(javaScript, bindings));
MemoryCache.INSTANCE.putCache(sourceBean.getBookSourceUrl(), findRule);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ public void onBackPressed() {
}
}

if(AppActivityManager.getInstance().isExist(AudioBookActivity.class)){
if(!AppActivityManager.getInstance().isExist(AudioBookActivity.class)){
finishByAnim(R.anim.anim_alpha_in, R.anim.anim_right_out);
}else {
supportFinishAfterTransition();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,13 @@ public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int positi
}

final View.OnClickListener clickListener = view -> {
if (selectCover) return;

if (lastSelectIndex != -1 && lastSelectIndex != holder.getLayoutPosition()) {
notifyItemChanged(lastSelectIndex, 0);
}
if (!myViewHolder.ivChecked.isChecked()) {
myViewHolder.ivChecked.setChecked(true);
if (!selectCover) {
if (lastSelectIndex != -1 && lastSelectIndex != holder.getLayoutPosition()) {
notifyItemChanged(lastSelectIndex, 0);
}
if (!myViewHolder.ivChecked.isChecked()) {
myViewHolder.ivChecked.setChecked(true);
}
}
if (mOnItemClickListener != null) {
mOnItemClickListener.onItemClick(view, item);
Expand Down
4 changes: 2 additions & 2 deletions app/version.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#Tue May 21 12:18:06 CST 2019
VERSION_CODE=3001
#Sun May 26 09:24:13 CST 2019
VERSION_CODE=3005

0 comments on commit 0c820eb

Please sign in to comment.