use of com.tencent.wstt.gt.ui.model.LogEntry in project GT by Tencent.
the class GTLogSearchActivity method openLog.
private void openLog(final String filename) {
final AsyncTask<Void, Void, LogEntry[]> openFileTask = new AsyncTask<Void, Void, LogEntry[]>() {
@Override
protected void onPreExecute() {
super.onPreExecute();
// 转菊花
proDialog = ProgressDialog.show(GTLogSearchActivity.this, "get data..", "geting data..wait...", true, true);
}
@Override
protected LogEntry[] doInBackground(Void... params) {
final int maxLines = 1000;
LogEntry[] logLines = SaveLogHelper.openLog(filename, maxLines);
return logLines;
}
@Override
protected void onPostExecute(LogEntry[] logLines) {
super.onPostExecute(logLines);
// 取消菊花
proDialog.dismiss();
proDialog = null;
dataSet = logLines;
arrayAdapter = new SearchLogAdapter(GTLogSearchActivity.this, dataSet);
listView.setAdapter(arrayAdapter);
}
};
openFileTask.execute((Void) null);
}
use of com.tencent.wstt.gt.ui.model.LogEntry in project GT by Tencent.
the class AbsLogController method addEntrys.
@Override
public /*
* 这个方法是被生产者线程调用的,所以可以阻塞
* 目前实现是读写锁,这里应该是优先级最低的写锁
*/
void addEntrys(Collection logList) {
lock.writeLock().lock();
try {
// 需要显示的log只控制显示1000行,多于1000行,则把list队头的删除
showLogList.addAll(logList);
if (showLogList.size() > LogUtils.CACHE) {
int length = showLogList.size();
lastFilterEndLocation = lastFilterEndLocation - length + LogUtils.CACHE;
// 如果lastFilterEndLocation小于0,对调用程序来说已经没有用处了,取0即可
lastFilterEndLocation = Math.max(lastFilterEndLocation, 0);
showLogList.remove(0, length - LogUtils.CACHE);
}
for (Object o : logList) {
LogEntry entry = (LogEntry) o;
showTagSet.add(entry.tag);
}
} finally {
lock.writeLock().unlock();
}
// 此时最适合刷新UI,走过滤逻辑刷新
onDataChanged();
}
use of com.tencent.wstt.gt.ui.model.LogEntry in project GT by Tencent.
the class LogSearchController method setLastEntrys.
public void setLastEntrys(LogEntry[] lastEntrys) {
this.lastEntrys = lastEntrys;
int buffLength = lastSearchMsg.length();
// TODO 异步处理,解析搜索数据源,生成LastMatchedEntry数组
// TODO 此时需要堵住UI
lastMatchedEntryList.clear();
for (int i = 0; i < lastEntrys.length; i++) {
if (interrupted) {
break;
}
LogEntry log = lastEntrys[i];
String temp = log.msg.toLowerCase(Locale.CHINA);
int start = -1;
int end = -1;
do {
start = temp.indexOf(lastSearchMsg, end);
if (start >= 0) {
end = start + buffLength;
MatchedEntry matched = new MatchedEntry(i, start, end);
lastMatchedEntryList.add(matched);
}
} while (start >= 0);
}
// 这段影响到初始搜索,是否已选中最后一条匹配记录
if (lastMatchedEntryList.size() > 0) {
lastMatchedSeq = lastMatchedEntryList.size() - 1;
} else {
lastMatchedSeq = 0;
}
}
use of com.tencent.wstt.gt.ui.model.LogEntry in project GT by Tencent.
the class LogUtils method writeLog.
/**
* GT中的日志保存
*
* @param list
* @param path
*/
public static void writeLog(List<LogEntry> list, String fileName, boolean append) {
if (!GTUtils.isSDCardExist()) {
return;
}
File f = null;
if (fileName.contains(FileUtil.separator) || fileName.contains("\\")) {
f = new File(fileName);
} else {
f = new File(Env.ROOT_LOG_FOLDER, fileName);
}
if (f.exists() && !append) {
f.delete();
}
FileWriter fw = null;
try {
fw = new FileWriter(f, true);
} catch (IOException e) {
e.printStackTrace();
}
for (LogEntry entry : list) {
writeNotClose(entry.msg, f, fw);
writeNotClose("\r\n", f, fw);
}
FileUtil.closeWriter(fw);
}
use of com.tencent.wstt.gt.ui.model.LogEntry in project GT by Tencent.
the class LogUtils method writeLog.
public static void writeLog(List<LogEntry> list, File f, boolean append) {
if (!GTUtils.isSDCardExist()) {
return;
}
if (f.exists() && !append) {
f.delete();
}
FileWriter fw = null;
try {
fw = new FileWriter(f, true);
} catch (IOException e) {
e.printStackTrace();
}
for (LogEntry entry : list) {
writeNotClose(entry.msg, f, fw);
writeNotClose("\r\n", f, fw);
}
FileUtil.closeWriter(fw);
}
Aggregations