Skip to content

Commit

Permalink
完善代码,去除未使用corepage.json进行注册而导致的报错堆栈信息
Browse files Browse the repository at this point in the history
  • Loading branch information
xuexiangjys committed May 9, 2018
1 parent b8edf4a commit 5154054
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.xuexiang.xpage.comiler;
package com.xuexiang.xpage.compiler;

import com.google.auto.service.AutoService;
import com.squareup.javapoet.ClassName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,20 @@
import com.xuexiang.xpage.logger.PageLog;

import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

/**
* 跳转页面管理
*
* @author XUE
* @date 2017/9/8 14:30
* <pre>
* desc : 跳转页面管理
* author : xuexiang
* time : 2018/5/9 下午3:13
* </pre>
*/
public class CorePageManager {
/**
Expand Down Expand Up @@ -91,6 +94,8 @@ public void init(Context context, String pageJson) {
*/

public void readConfig(String content) {
if (TextUtils.isEmpty(content)) return;

PageLog.d("readConfig from json");
JSONArray jsonArray = JSON.parseArray(content);
Iterator<Object> iterator = jsonArray.iterator();
Expand Down Expand Up @@ -121,17 +126,39 @@ public void readConfig(String content) {
* @return
*/
private String readFileFromAssets(Context context, String fileName) {
String result = "";
StringBuilder s = new StringBuilder();
BufferedReader br = null;
try {
InputStreamReader inputReader = new InputStreamReader(context.getResources().getAssets().open(fileName));
BufferedReader bufReader = new BufferedReader(inputReader);
br = new BufferedReader(inputReader);
String line;
while ((line = bufReader.readLine()) != null)
result += line;
while ((line = br.readLine()) != null) {
s.append(line);
}
} catch (Exception e) {
e.printStackTrace();

} finally {
closeIO(br);
}
return s.toString();
}

/**
* 关闭 IO
*
* @param closeables closeables
*/
static void closeIO(final Closeable... closeables) {
if (closeables == null) return;
for (Closeable closeable : closeables) {
if (closeable != null) {
try {
closeable.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
return result;
}

/**
Expand Down Expand Up @@ -294,7 +321,7 @@ private Bundle buildBundle(CorePage corePage) {
/**
* 判断fragment是否位于栈顶
*
* @param context 上下文
* @param context 上下文
* @param fragmentTag fragment的tag
* @return 是否是栈顶Fragment
*/
Expand All @@ -303,11 +330,7 @@ public boolean isFragmentTop(Context context, String fragmentTag) {
return ((CoreSwitcher) context).isFragmentTop(fragmentTag);
} else {
BaseActivity topActivity = BaseActivity.getTopActivity();
if (topActivity != null) {
return topActivity.isFragmentTop(fragmentTag);
} else {
return false;
}
return topActivity != null && topActivity.isFragmentTop(fragmentTag);
}
}
}

0 comments on commit 5154054

Please sign in to comment.