Commit c7ac6f5e by 徐丛奇

tiaozhengjiegou

parent 7614348f
*.iml
.gradle
.idea
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
/captures
......
......@@ -12,8 +12,6 @@
<option value="$PROJECT_DIR$/library" />
<option value="$PROJECT_DIR$/library/baselibrary" />
<option value="$PROJECT_DIR$/library/netlibrary" />
<option value="$PROJECT_DIR$/library/oo_statistics_lib" />
<option value="$PROJECT_DIR$/library/sys_state" />
</set>
</option>
<option name="resolveModulePerSourceSet" value="false" />
......
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="EntryPointsManager">
<entry_points version="2.0" />
</component>
<component name="NullableNotNullManager">
<option name="myDefaultNullable" value="android.support.annotation.Nullable" />
<option name="myDefaultNotNull" value="android.support.annotation.NonNull" />
......@@ -40,7 +43,7 @@
</profile-state>
</entry>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" project-jdk-name="1.8 (6)" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">
......
......@@ -4,12 +4,11 @@
<modules>
<module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" />
<module fileurl="file://$PROJECT_DIR$/library/baselibrary/baselibrary.iml" filepath="$PROJECT_DIR$/library/baselibrary/baselibrary.iml" />
<module fileurl="file://G:\workspace_ooyby\haihang\eye_haihang.iml" filepath="G:\workspace_ooyby\haihang\eye_haihang.iml" />
<module fileurl="file://$PROJECT_DIR$/eye_haihang.iml" filepath="$PROJECT_DIR$/eye_haihang.iml" />
<module fileurl="file://G:/workspace_ooyby/haihang/eye_haihang.iml" filepath="G:/workspace_ooyby/haihang/eye_haihang.iml" />
<module fileurl="file://$PROJECT_DIR$/.idea/haihang.iml" filepath="$PROJECT_DIR$/.idea/haihang.iml" />
<module fileurl="file://$PROJECT_DIR$/library/library.iml" filepath="$PROJECT_DIR$/library/library.iml" />
<module fileurl="file://$PROJECT_DIR$/library/netlibrary/netlibrary.iml" filepath="$PROJECT_DIR$/library/netlibrary/netlibrary.iml" />
<module fileurl="file://$PROJECT_DIR$/library/oo_statistics_lib/oo_statistics_lib.iml" filepath="$PROJECT_DIR$/library/oo_statistics_lib/oo_statistics_lib.iml" />
<module fileurl="file://$PROJECT_DIR$/library/sys_state/sys_state.iml" filepath="$PROJECT_DIR$/library/sys_state/sys_state.iml" />
</modules>
</component>
</project>
\ No newline at end of file
......@@ -3,7 +3,7 @@
package="com.oo.eye">
<application
android:name="com.app.baselibrary.base.app.BaseApplication"
android:name=".EyeApplication"
android:allowBackup="true"
android:label="@string/app_name"
android:icon="@drawable/nav2"
......@@ -44,9 +44,6 @@
android:name="com.oo.eye.activity.EyeTestActivity"
android:screenOrientation="landscape" />
<activity
android:name="com.oo.eye.activity.AfterEyeTestActivity"
android:screenOrientation="landscape" />
<activity
android:name="com.oo.eye.activity.EyeTestHistroyActivity"
android:screenOrientation="landscape" />
<activity
......
package com.oo.eye;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.os.Build;
import android.os.Looper;
import android.util.Log;
import android.widget.Toast;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.io.Writer;
import java.lang.Thread.UncaughtExceptionHandler;
import java.lang.reflect.Field;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* UncaughtException处理类,当程序发生Uncaught异常的时候,有该类来接管程序,并记录发送错误报告.
*
* @author user
*
*/
public class CrashHandler implements UncaughtExceptionHandler {
public static final String TAG = "CrashHandler";
//系统默认的UncaughtException处理类
private Thread.UncaughtExceptionHandler mDefaultHandler;
//CrashHandler实例
private static CrashHandler INSTANCE = new CrashHandler();
//程序的Context对象
private Context mContext;
//用来存储设备信息和异常信息
private Map<String, String> infos = new HashMap<String, String>();
//用于格式化日期,作为日志文件名的一部分
private DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss");
private ICrashListener listener;
public boolean isRestart = false;
/** 保证只有一个CrashHandler实例 */
private CrashHandler() {
}
/** 获取CrashHandler实例 ,单例模式 */
public static CrashHandler getInstance() {
return INSTANCE;
}
/**
* 初始化
*
* @param context
*/
public void init(Context context) {
mContext = context;
//获取系统默认的UncaughtException处理器
mDefaultHandler = Thread.getDefaultUncaughtExceptionHandler();
//设置该CrashHandler为程序的默认处理器
Thread.setDefaultUncaughtExceptionHandler(this);
}
/**
* 当UncaughtException发生时会转入该函数来处理
*/
@Override
public void uncaughtException(Thread thread, Throwable ex) {
ex.printStackTrace();
if (!handleException(ex) && mDefaultHandler != null) {
//如果用户没有处理则让系统默认的异常处理器来处理
mDefaultHandler.uncaughtException(thread, ex);
}else{
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
Log.e(TAG, "error : ", e);
}
//退出程序
android.os.Process.killProcess(android.os.Process.myPid());
System.exit(0);
}
}
/**
* 自定义错误处理,收集错误信息 发送错误报告等操作均在此完成.
*
* @param ex
* @return true:如果处理了该异常信息;否则返回false.
*/
private boolean handleException(Throwable ex) {
if (ex == null) {
return false;
}
//使用Toast来显示异常信息
new Thread() {
@Override
public void run() {
Looper.prepare();
Toast.makeText(mContext, "很抱歉,程序出现异常,即将退出.", Toast.LENGTH_LONG).show();
Looper.loop();
}
}.start();
//收集设备参数信息
// collectDeviceInfo(mContext);
//保存日志文件
saveCrashInfo2File(ex);
return true;
}
public void setCrashListener(ICrashListener listener){
this.listener = listener;
}
/**
* 收集设备参数信息
* @param ctx
*/
public void collectDeviceInfo(Context ctx) {
try {
PackageManager pm = ctx.getPackageManager();
PackageInfo pi = pm.getPackageInfo(ctx.getPackageName(), PackageManager.GET_ACTIVITIES);
if (pi != null) {
String versionName = pi.versionName == null ? "null" : pi.versionName;
String versionCode = pi.versionCode + "";
infos.put("versionName", versionName);
infos.put("versionCode", versionCode);
}
} catch (NameNotFoundException e) {
Log.e(TAG, "an error occured when collect package info", e);
}
Field[] fields = Build.class.getDeclaredFields();
for (Field field : fields) {
try {
field.setAccessible(true);
infos.put(field.getName(), field.get(null).toString());
Log.d(TAG, field.getName() + " : " + field.get(null));
} catch (Exception e) {
Log.e(TAG, "an error occured when collect crash info", e);
}
}
}
/**
* 保存错误信息到文件中
*
* @param ex
* @return 返回文件名称,便于将文件传送到服务器
*/
private void saveCrashInfo2File(Throwable ex) {
long timestamp = System.currentTimeMillis();
String time = formatter.format(new Date());
StringBuffer sb = new StringBuffer("{");
sb.append("date:");
sb.append(time);
sb.append(",");
sb.append("timestamp:");
sb.append(timestamp);
sb.append(",");
for (Map.Entry<String, String> entry : infos.entrySet()) {
String key = entry.getKey();
String value = entry.getValue();
sb.append(key + ":" + value + ",");
}
Writer writer = new StringWriter();
PrintWriter printWriter = new PrintWriter(writer);
ex.printStackTrace(printWriter);
Throwable cause = ex.getCause();
while (cause != null) {
cause.printStackTrace(printWriter);
cause = cause.getCause();
}
printWriter.close();
String result = writer.toString();
sb.append("exception:");
sb.append(result);
listener.onCrash(sb.toString());
}
public void resetApp(Throwable ex){
StackTraceElement stackTraceElement= ex.getStackTrace()[0];
String classname = stackTraceElement.getClassName();
try{
classname = classname.substring(0,classname.indexOf("$"));
}catch (Exception e){
classname = getCrashActivity(ex.toString());
}
Intent i = mContext.getPackageManager()
.getLaunchIntentForPackage(mContext.getPackageName());
// //非入口Activity 自动启动入口activity
// if(!classname.equals(i.getComponent().getClassName())){
// System.exit(0);
// i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
// mContext.startActivity(i);
// }else{
// //退出程序
// android.os.Process.killProcess(android.os.Process.myPid());
// System.exit(0);
// }
}
public void setRestart(boolean restart) {
isRestart = restart;
}
private static String getCrashActivity(String text) {
String str = "";
Pattern pattern = Pattern.compile("\\/(.*?)\\}");
Matcher matcher = pattern.matcher(text);
if (matcher.find()) {
str = matcher.group(1);
}
return str;
}
}
\ No newline at end of file
package com.oo.eye;
import com.app.baselibrary.base.app.BaseApplication;
import com.app.baselibrary.commonUtil.LogUtil;
/**
* Created by xucon on 2018/8/30.
*/
public class EyeApplication extends BaseApplication {
@Override
public void onCreate() {
super.onCreate();
CrashHandler crashHandler = CrashHandler.getInstance();
crashHandler.init(getApplicationContext());
crashHandler.setRestart(true);
crashHandler.setCrashListener(new ICrashListener() {
@Override
public void onCrash(String json) {
LogUtil.e(json);
}
});
}
}
package com.oo.eye;
import android.text.TextUtils;
import com.oo.eye.bean.Student;
import com.oo.eye.bean.EyeHistroyBean;
import java.util.List;
/**
* Created by xucon on 2017/12/22.
......@@ -14,11 +14,7 @@ public class EyeConfig {
private boolean isNetData = false;
private String name;
private EyeHistroyBean initBean;
private EyeHistroyBean cuurentBean;
private List<Student> mStudents;
private static EyeConfig instance = new EyeConfig();
......@@ -38,30 +34,11 @@ public class EyeConfig {
isNetData = netData;
}
public String getName() {
if(TextUtils.isEmpty(name)){
return "游客";
}
return name;
}
public void setName(String name) {
this.name = name;
}
public EyeHistroyBean getInitBean() {
return initBean;
}
public void setInitBean(EyeHistroyBean initBean) {
this.initBean = initBean;
}
public EyeHistroyBean getCuurentBean() {
return cuurentBean;
public List<Student> getStudents() {
return mStudents;
}
public void setCuurentBean(EyeHistroyBean cuurentBean) {
this.cuurentBean = cuurentBean;
public void setStudents(List<Student> students) {
mStudents = students;
}
}
package com.oo.eye;
/**
* Created by gyp on 16/11/11.
*/
public interface ICrashListener {
void onCrash(String json);
}
package com.oo.eye.activity;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
import com.app.baselibrary.base.common.BaseActivity;
import com.app.baselibrary.commonUtil.CalculateUtils;
import com.app.baselibrary.commonUtil.NibiruUtils;
import com.app.baselibrary.commonUtil.PreferencesUtils;
import com.app.baselibrary.commonUtil.SnUtils;
import com.app.baselibrary.commonUtil.ToastUtil;
import com.oo.eye.EyeConfig;
import com.oo.eye.R;
import com.oo.eye.R2;
import com.oo.eye.bean.Eye;
import com.oo.eye.bean.EyeHistroyBean;
import com.oo.eye.manager.DaemonSender;
import com.oo.eye.mvp.PresenterFactory;
import com.oo.eye.mvp.contract.EyeTestContract;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
/**
*/
public class AfterEyeTestActivity extends BaseActivity implements EyeTestContract.View {
@BindView(R.id.tv_after_title)
TextView mTvAfterTitle;
@BindView(R.id.tv_after_name)
TextView mTvAfterName;
@BindView(R.id.tv_after_time)
TextView mTvAfterTime;
@BindView(R.id.tv_after_save)
TextView mTvAfterSave;
@BindView(R.id.tv_after_give_up)
TextView mTvAfterGiveUp;
@BindView(R.id.tv_after_result_left)
TextView mTvAfterResultLeft;
@BindView(R.id.tv_after_result_right)
TextView mTvAfterResultRight;
private EyeTestContract.Presenter mPresenter;
private EyeHistroyBean mEyeTestBean;
private double mLeftEye;
private double mRightEye;
private int mLeftLine;
private int mRightLine;
@Override
protected int getLayoutId() {
return R.layout.activity_after_eye_test;
}
@Override
protected void init() {
PresenterFactory.createEyeTestPresenter(this);
DaemonSender.closeEyeTest(this);
mEyeTestBean = EyeConfig.getInstance().getCuurentBean();
if (mEyeTestBean == null) {
mEyeTestBean = new EyeHistroyBean();
mEyeTestBean.setType(2);
}
mLeftEye = getIntent().getDoubleExtra("leftEye", 0);
mRightEye = getIntent().getDoubleExtra("rightEye", 0);
mLeftLine = getIntent().getIntExtra("leftLine", 0);
mRightLine = getIntent().getIntExtra("rightLine", 0);
if (mEyeTestBean != null && mEyeTestBean.getLeft_eye() > 0 && mEyeTestBean.getRight_eye() > 0) {
double left = CalculateUtils.sub(mLeftEye, mEyeTestBean.getLeft_eye(), 1);
double right = CalculateUtils.sub(mRightEye, mEyeTestBean.getRight_eye(), 1);
int count = (int) CalculateUtils.add(CalculateUtils.mul(left, 10, 1),
CalculateUtils.mul(right, 10, 1), 1);
String text = "少于1";
if (count > 0) {
text = count + "";
}
}
mTvAfterName.setText(getString(R.string.after_eye_test_name, EyeConfig.getInstance().getName())
+ "(用户" + SnUtils.getSN() + ")");
int selectId = PreferencesUtils.getInt(EyeConfig.EYE_SETTING_KEY, 0);
String text = String.valueOf(mLeftEye) + " | " + String.valueOf(mRightEye);
if (selectId == 1) {
text = String.valueOf(Eye.transformSmall(mLeftEye)) + " | "
+ String.valueOf(Eye.transformSmall(mRightEye));
}
mTvAfterResultLeft.setText(mLeftEye+"");
mTvAfterResultRight.setText(mRightEye+"");
}
protected void onResume() {
super.onResume();
NibiruUtils.switchVR(false);
}
@Override
protected void onPause() {
super.onPause();
}
@OnClick(R2.id.tv_after_save)
void onClickSave(View view) {
mPresenter.postEyeTestData(this, SnUtils.getSN(),
mLeftEye, mRightEye, mLeftLine, mRightLine);
}
@OnClick(R2.id.tv_after_give_up)
void onClickGiveUp(View view) {
finish();
}
public void setPresenter(EyeTestContract.Presenter presenter) {
mPresenter = presenter;
}
public void postEyeTestDataSuccee() {
mEyeTestBean.setLeft_eye(mLeftEye);
mEyeTestBean.setRight_eye(mRightEye);
mEyeTestBean.setLeft_line(mLeftLine);
mEyeTestBean.setRight_line(mRightLine);
EyeConfig.getInstance().setCuurentBean(mEyeTestBean);
if (EyeConfig.getInstance().getInitBean() == null) {
EyeConfig.getInstance().setInitBean(mEyeTestBean);
}
ToastUtil.showLongMessage("数据保存成功");
finish();
}
public void postEyeTestDataFail(String msg) {
ToastUtil.showLongMessage("数据保存失败,请重试");
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// TODO: add setContentView(...) invocation
ButterKnife.bind(this);
}
}
package com.oo.eye.activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.net.ConnectivityManager;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;
......@@ -12,11 +8,9 @@ import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import com.app.baselibrary.base.common.BaseActivity;
import com.app.baselibrary.commonUtil.LogUtil;
import com.app.baselibrary.commonUtil.NibiruUtils;
import com.app.baselibrary.commonUtil.BDttsUtils;
import com.oo.eye.R;
import com.oo.eye.R2;
import com.oo.eye.manager.DaemonSender;
import butterknife.BindView;
import butterknife.ButterKnife;
......@@ -32,9 +26,6 @@ public class BeforeEyeTestActivity extends BaseActivity {
RelativeLayout mLlBeforeEyeStart1;
@BindView(R.id.ll_before_eye_prepare1)
LinearLayout mLlBeforeEyePrepare1;
// private DaemonReceiver mDaemonReceiver;
private ActionReceiver mActionReceiver;
private Handler mHandler;
......@@ -46,37 +37,22 @@ public class BeforeEyeTestActivity extends BaseActivity {
@Override
protected void init() {
mHandler = new Handler();
// mDaemonReceiver = new DaemonReceiver();
// mDaemonReceiver.registerScreenActionReceiver(this);
mActionReceiver = new ActionReceiver();
mActionReceiver.registerScreenActionReceiver(this);
DaemonSender.startEyeTest(this);
}
@Override
protected void onResume() {
super.onResume();
NibiruUtils.switchVR(false);
}
@Override
protected void onDestroy() {
super.onDestroy();
DaemonSender.closeEyeTestMotor(this);
// if (mDaemonReceiver != null) {
// mDaemonReceiver.unRegisterScreenActionReceiver(this);
// }
if (mActionReceiver != null) {
mActionReceiver.unRegisterScreenActionReceiver(this);
}
}
@OnClick(R2.id.tv_eye_test_start1)
public void click(View view) {
mLlBeforeEyeStart1.setVisibility(View.GONE);
mLlBeforeEyePrepare1.setVisibility(View.VISIBLE);
speak("调节测视距离,请等待");
// DaemonSender.startEyeTestMotor(this);
Intent intent2 = new Intent(BeforeEyeTestActivity.this,EyeTestActivity.class);
startActivity(intent2);
finish();
......@@ -85,96 +61,11 @@ public class BeforeEyeTestActivity extends BaseActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// TODO: add setContentView(...) invocation
ButterKnife.bind(this);
}
// public class DaemonReceiver extends BroadcastReceiver {
// private boolean isRegisterReceiver = false;
//
// @Override
// public void onReceive(Context context, Intent intent) {
// if (intent != null) {
// int type = intent.getIntExtra(OOMsg.ARG_SEEX_ACTION, 0);
// switch (type) {
// case OOMsg.EYE_TEST_MOTOR_FINISH:
// mHandler.postDelayed(new Runnable() {
// @Override
// public void run() {
// Intent intent2 = new Intent(BeforeEyeTestActivity.this, EyeTestActivity.class);
// startActivity(intent2);
// finish();
// }
// }, 1000);
// break;
// }
//
// }
//
// }
//
// public void registerScreenActionReceiver(Context mContext) {
// if (!isRegisterReceiver) {
// isRegisterReceiver = true;
//
// IntentFilter filter = new IntentFilter();
// filter.addAction(OOMsg.OO_INTENT_ACTION);
// mContext.registerReceiver(DaemonReceiver.this, filter);
// }
// }
//
// public void unRegisterScreenActionReceiver(Context mContext) {
// if (isRegisterReceiver) {
// isRegisterReceiver = false;
// mContext.unregisterReceiver(DaemonReceiver.this);
// }
// }
// }
class ActionReceiver extends BroadcastReceiver {
private String TAG = "TrainTaskService__ActionReceiver";
private boolean isRegisterReceiver = false;
@Override
public void onReceive(final Context context, Intent intent) {
String action = intent.getAction();
LogUtil.e(TAG, "action..." + action);
if (action.equals(Intent.ACTION_SCREEN_OFF)) {
//如果,灭屏,就进行暂停操作。
mLlBeforeEyeStart1.setVisibility(View.VISIBLE);
mLlBeforeEyePrepare1.setVisibility(View.GONE);
} else if (action.equals(Intent.ACTION_SCREEN_ON)) {
mLlBeforeEyeStart1.setVisibility(View.VISIBLE);
mLlBeforeEyePrepare1.setVisibility(View.GONE);
}
}
public void registerScreenActionReceiver(Context mContext) {
if (!isRegisterReceiver) {
isRegisterReceiver = true;
IntentFilter filter = new IntentFilter();
filter.addAction(Intent.ACTION_SCREEN_OFF);
filter.addAction(Intent.ACTION_SCREEN_ON);
filter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
LogUtil.e(TAG, "reg broadcast...");
mContext.registerReceiver(ActionReceiver.this, filter);
}
}
public void unRegisterScreenActionReceiver(Context mContext) {
if (isRegisterReceiver) {
isRegisterReceiver = false;
LogUtil.e(TAG, "unReg broadcast...");
mContext.unregisterReceiver(ActionReceiver.this);
}
}
}
private void speak(String text) {
DaemonSender.sendDBTTS(this, text);
BDttsUtils.getInstance().speak(text);
}
......
......@@ -10,8 +10,6 @@ import com.app.baselibrary.base.common.BaseActivity;
import com.app.baselibrary.commonUtil.PreferencesUtils;
import com.oo.eye.EyeConfig;
import com.oo.eye.R;
import com.oo.eye.R2;
import com.oo.seex.sys_state.widget.StateView;
import butterknife.BindView;
import butterknife.ButterKnife;
......@@ -22,8 +20,6 @@ import butterknife.OnClick;
public class EyeSettingActivity extends BaseActivity {
@BindView(R2.id.state_view)
StateView mStateView;
@BindView(R.id.group_decimal)
RadioGroup mGroupDecimal;
@BindView(R.id.group_distance)
......@@ -48,14 +44,12 @@ public class EyeSettingActivity extends BaseActivity {
protected void onResume() {
super.onResume();
mStateView.registStateListener();
}
@Override
protected void onPause() {
super.onPause();
mStateView.unRegistStateListener();
}
@Override
......
package com.oo.eye.activity;
import android.view.View;
import android.widget.TextView;
import com.app.baselibrary.base.common.BaseActivity;
import com.app.baselibrary.commonUtil.CalculateUtils;
import com.app.baselibrary.commonUtil.PreferencesUtils;
import com.app.baselibrary.commonUtil.ToastUtil;
import com.app.baselibrary.widget.LoadMoreListView;
import com.oo.eye.EyeConfig;
import com.oo.eye.R;
import com.oo.eye.R2;
import com.oo.eye.adapter.EyeHistroyListAdapter;
import com.oo.eye.bean.Eye;
import com.oo.eye.bean.EyeHistroyBean;
import com.oo.eye.mvp.PresenterFactory;
import com.oo.eye.mvp.contract.EyeHistroyContract;
import com.oo.seex.netlibrary.net.response.Page;
import com.oo.seex.sys_state.widget.StateView;
import java.util.ArrayList;
import java.util.List;
import butterknife.BindView;
import butterknife.OnClick;
/**
*/
public class EyeTestHistroyActivity extends BaseActivity
implements EyeHistroyListAdapter.AdapterLoadMoreListener,EyeHistroyContract.View {
private EyeHistroyContract.Presenter mPresenter;
@BindView(R2.id.state_view)
StateView mStateView;
@BindView(R2.id.tv_histroy_current_vision_left)
TextView currentVisionLeftText;
@BindView(R2.id.tv_histroy_current_vision_right)
TextView currentVisionRightText;
@BindView(R2.id.tv_histroy_current_vision_soure)
TextView currentVisionSoureText;
@BindView(R2.id.tv_histroy_init_vision_left)
TextView initVisionLeftText;
@BindView(R2.id.tv_histroy_init_vision_right)
TextView initVisionRightText;
@BindView(R2.id.tv_histroy_init_vision_soure)
TextView initVisionSoureText;
@BindView(R2.id.tv_histroy_lift_left)
TextView liftLeftText;
@BindView(R2.id.tv_histroy_lift_right)
TextView liftRightText;
@BindView(R2.id.tv_histroy_lift_soure)
TextView liftSoureText;
@BindView(R2.id.lv_eye_histroy)
LoadMoreListView mListView;
private EyeHistroyListAdapter mListAdapter;
private int requestPage = 0;
private int requestCount = 10;
private boolean hasMore = true;
private boolean isRequest = false;
private int selectId;
List<EyeHistroyBean> mEyeHistroyBeen = new ArrayList<>();
@Override
protected int getLayoutId() {
return R.layout.activity_eye_histroy;
}
@Override
protected void init() {
selectId = PreferencesUtils.getInt(EyeConfig.EYE_SETTING_KEY,0);
PresenterFactory.createEyeHistroyPresenter(this);
updateTopData(EyeConfig.getInstance().getInitBean(),EyeConfig.getInstance().getCuurentBean());
mListAdapter = new EyeHistroyListAdapter(this,mEyeHistroyBeen);
mListView.setAdapter(mListAdapter);
mListAdapter.setAdapterLoadMoreListener(this);
mListView.setLoadMoreVisible(true);
getData(1,requestCount);
}
protected void onResume() {
super.onResume();
mStateView.registStateListener();
}
@Override
protected void onPause() {
super.onPause();
mStateView.unRegistStateListener();
}
private void updateTopData(EyeHistroyBean initBean,EyeHistroyBean currentBean){
if(selectId == 1){
initVisionLeftText.setText(String.valueOf(Eye.transformSmall(initBean.getLeft_eye())));
initVisionRightText.setText(String.valueOf(Eye.transformSmall(initBean.getRight_eye())));
}else {
initVisionLeftText.setText(String.valueOf(initBean.getLeft_eye()));
initVisionRightText.setText(String.valueOf(initBean.getRight_eye()));
}
initVisionSoureText.setText(initBean.getType() == 1?
R.string.histroy_soure_input:R.string.histroy_soure_calculate);
if(selectId == 1){
currentVisionLeftText.setText(String.valueOf(Eye.transformSmall(currentBean.getLeft_eye())));
currentVisionRightText.setText(String.valueOf(Eye.transformSmall(currentBean.getRight_eye())));
}else {
currentVisionLeftText.setText(String.valueOf(currentBean.getLeft_eye()));
currentVisionRightText.setText(String.valueOf(currentBean.getRight_eye()));
}
currentVisionSoureText.setText(currentBean.getType() == 1?
R.string.histroy_soure_input:R.string.histroy_soure_calculate);
double left = CalculateUtils.sub(currentBean.getLeft_eye(),initBean.getLeft_eye(),1);
double right = CalculateUtils.sub(currentBean.getRight_eye(),initBean.getRight_eye(),1);
if(left < 0.1){
liftLeftText.setText("少于1行");
}else{
liftLeftText.setText((int)(CalculateUtils.mul(left,10,0))+"行");
}
if(right < 0.1){
liftRightText.setText("少于1行");
}else{
liftRightText.setText((int)(CalculateUtils.mul(right,10,0))+"行");
}
liftSoureText.setText(R.string.histroy_soure_calculate);
}
@OnClick(R2.id.ll_eye_histroy_refresh)
void onClickRefresh(View view){
getData(1,requestCount);
}
@Override
public void adapterLoadMore(){
if(hasMore) {
mListView.setLoadMoreVisible(true);
getData(requestPage + 1,requestCount);
}
}
private void getData(int page,int limit){
if(!isRequest) {
isRequest = true;
mPresenter.getEyeHistroy(this,EyeConfig.getInstance().isNetData(), page, limit);
}
}
public void setPresenter(EyeHistroyContract.Presenter presenter){
mPresenter = presenter;
}
public void getEyeHistroyNetSuccee(ArrayList<EyeHistroyBean> beans, Page page){
isRequest = false;
if(beans != null && beans.size() > 0){
if(page.getCurrentPage() == 1){
mEyeHistroyBeen.clear();
}
mEyeHistroyBeen.addAll(beans);
requestPage = page.getCurrentPage();
hasMore = page.getNextPage()>page.getCurrentPage();
mListAdapter.updateList(mEyeHistroyBeen);
mListAdapter.notifyDataSetChanged();
}else{
hasMore = false;
}
if(hasMore){
mListView.setLoadMoreVisible(false);
}else{
mListView.setLoadComplete();
}
}
public void getEyeHistroyFail(String msg){
isRequest = false;
ToastUtil.showLongMessage(msg);
}
public void getEyeHistroyDBSuccee(List<EyeHistroyBean> beans, int page, int count){
isRequest = false;
if(beans != null && beans.size() > 0){
mEyeHistroyBeen.clear();
mEyeHistroyBeen.addAll(beans);
requestPage = page;
hasMore = (count > page*requestCount);
mListAdapter.updateList(mEyeHistroyBeen);
mListAdapter.notifyDataSetChanged();
}else{
hasMore = false;
}
if(hasMore){
mListView.setLoadMoreVisible(false);
}else{
mListView.setLoadComplete();
}
}
}
......@@ -9,17 +9,17 @@ import android.widget.TextView;
import com.app.baselibrary.base.common.BaseActivity;
import com.app.baselibrary.commonUtil.LogUtil;
import com.app.baselibrary.commonUtil.NibiruUtils;
import com.app.baselibrary.commonUtil.ToastUtil;
import com.oo.eye.EyeConfig;
import com.oo.eye.R;
import com.oo.eye.R2;
import com.oo.eye.bean.EyeChartsBean;
import com.oo.eye.bean.EyeHistroyBean;
import com.oo.eye.bean.Student;
import com.oo.eye.db.DbManager;
import com.oo.eye.mvp.PresenterFactory;
import com.oo.eye.mvp.contract.EyeMainContract;
import com.oo.seex.sys_state.widget.StateView;
import java.util.ArrayList;
import butterknife.BindView;
import butterknife.ButterKnife;
......@@ -45,9 +45,6 @@ public class EyeTestMainActivity extends BaseActivity implements EyeMainContract
LinearLayout mLinEyeTestSetting;
private EyeMainContract.Presenter mPresenter;
@BindView(R2.id.state_view)
StateView mStateView;
private boolean isRequestFinish = false;
@Override
......@@ -67,15 +64,12 @@ public class EyeTestMainActivity extends BaseActivity implements EyeMainContract
protected void onResume() {
super.onResume();
NibiruUtils.switchVR(false);
mStateView.registStateListener();
}
@Override
protected void onPause() {
super.onPause();
mStateView.unRegistStateListener();
}
public void setPresenter(EyeMainContract.Presenter presenter) {
......@@ -123,13 +117,12 @@ public class EyeTestMainActivity extends BaseActivity implements EyeMainContract
startActivity(MorePeopleTestActivity.class);
break;
case R.id.lin_eye_test_statistics:
EyeHistroyBean eyeTestBean = EyeConfig.getInstance().getCuurentBean();
if (EyeConfig.getInstance().getCuurentBean() == null ||
(eyeTestBean.getLeft_eye() == 0.0 && eyeTestBean.getRight_eye() == 0.0)) {
ToastUtil.showLongMessage("暂无数据,请先去测视");
return;
}
startActivity(EyeTestStatisticsActivity.class);
ArrayList<Student> list = new ArrayList<>();
Student student = new Student();
student.setRealname("游客");
list.add(student);
EyeConfig.getInstance().setStudents(list);
startActivity(BeforeEyeTestActivity.class);
break;
case R.id.lin_eye_test_setting://测试报表
startActivity(TestResurtListActivity.class);
......
package com.oo.eye.activity;
import android.util.DisplayMetrics;
import android.widget.FrameLayout;
import android.widget.TextView;
import com.app.baselibrary.base.common.BaseActivity;
import com.app.baselibrary.commonUtil.CalculateUtils;
import com.app.baselibrary.commonUtil.DensityUtil;
import com.app.baselibrary.commonUtil.PreferencesUtils;
import com.app.baselibrary.commonUtil.ToastUtil;
import com.oo.eye.EyeConfig;
import com.oo.eye.R;
import com.oo.eye.R2;
import com.oo.eye.bean.Eye;
import com.oo.eye.bean.EyeChartsBean;
import com.oo.eye.bean.EyeHistroyBean;
import com.oo.eye.mvp.PresenterFactory;
import com.oo.eye.mvp.contract.EyeChartsContract;
import com.oo.eye.widget.ChartsView;
import com.oo.seex.sys_state.widget.StateView;
import java.util.List;
import butterknife.BindView;
/**
*/
public class EyeTestStatisticsActivity extends BaseActivity
implements EyeChartsContract.View{
private EyeChartsContract.Presenter mPresenter;
@BindView(R2.id.state_view)
StateView mStateView;
@BindView(R2.id.tv_eye_statistics_init_vision)
TextView initVisionText;
@BindView(R2.id.tv_eye_statistics_current_vision)
TextView currentVisionText;
@BindView(R2.id.tv_eye_statistics_lift_vision)
TextView liftText;
@BindView(R2.id.line_chart_left)
FrameLayout leftLineChart;
@BindView(R2.id.line_chart_right)
FrameLayout rightLineChart;
DisplayMetrics mDisplayMetrics = new DisplayMetrics();
private int selectId;
@Override
protected int getLayoutId() {
return R.layout.activity_eye_statistics;
}
protected void onResume() {
super.onResume();
mStateView.registStateListener();
}
@Override
protected void onPause() {
super.onPause();
mStateView.unRegistStateListener();
}
@Override
protected void init() {
getWindowManager().getDefaultDisplay().getMetrics(mDisplayMetrics);
selectId = PreferencesUtils.getInt( EyeConfig.EYE_SETTING_KEY,0);
PresenterFactory.createEyeChartsPresenter(this);
EyeHistroyBean initBean = EyeConfig.getInstance().getInitBean();
EyeHistroyBean currentBean = EyeConfig.getInstance().getCuurentBean();
String initText = String.valueOf(initBean.getLeft_eye()) + " | "
+ String.valueOf(initBean.getRight_eye());
if(selectId == 1) {
initText = String.valueOf(Eye.transformSmall(initBean.getLeft_eye())) + " | "
+ String.valueOf(Eye.transformSmall(initBean.getRight_eye()));
}
initVisionText.setText(initText);
String currentText = String.valueOf(currentBean.getLeft_eye()) + " | "
+ String.valueOf(currentBean.getRight_eye());
if(selectId == 1) {
currentText = String.valueOf(Eye.transformSmall(currentBean.getLeft_eye())) + " | "
+ String.valueOf(Eye.transformSmall(currentBean.getRight_eye()));
}
currentVisionText.setText(currentText);
double left = CalculateUtils.sub(currentBean.getLeft_eye(),initBean.getLeft_eye(),1);
double right = CalculateUtils.sub(currentBean.getRight_eye(),initBean.getRight_eye(),1);
if(left+right > 0) {
double num = CalculateUtils.add(left,right,1);
liftText.setText("" + (int) (CalculateUtils.mul(num,10,1)) + "行");
}else{
liftText.setText("少于1行");
}
mPresenter.getEyeChartsData(this,6);
// List<EyeChartsBean> beans = new ArrayList<>();
// EyeChartsBean bean = new EyeChartsBean();
// bean.setLeft_eye(4.6);
// bean.setRight_eye(4.5);
// bean.setCreated_month("2017-07");
// beans.add(bean);
// EyeChartsBean bean2 = new EyeChartsBean();
// bean2.setLeft_eye(4.4);
// bean2.setRight_eye(4.4);
// bean2.setCreated_month("2017-08");
// beans.add(bean2);
// EyeChartsBean bean3 = new EyeChartsBean();
// bean3.setLeft_eye(4.8);
// bean3.setRight_eye(4.8);
// bean3.setCreated_month("2017-09");
// beans.add(bean3);
// bean = new EyeChartsBean();
// bean.setLeft_eye(5.0);
// bean.setRight_eye(5.3);
// bean.setCreated_month("2017-10");
// beans.add(bean);
// bean2 = new EyeChartsBean();
// bean2.setLeft_eye(4.4);
// bean2.setRight_eye(5.2);
// bean2.setCreated_month("2017-11");
// beans.add(bean2);
// bean3 = new EyeChartsBean();
// bean3.setLeft_eye(4.8);
// bean3.setRight_eye(4.8);
// bean3.setCreated_month("2017-12");
// beans.add(bean3);
// getEyeChartsSuccee(beans);
}
public void setPresenter(EyeChartsContract.Presenter presenter){
mPresenter = presenter;
}
public void getEyeChartsSuccee(final List<EyeChartsBean> beans){
if(beans != null && beans.size() > 0) {
int w = mDisplayMetrics.widthPixels - DensityUtil.dip2px(290);
int h = DensityUtil.dip2px(220);
if(selectId == 1){
for(EyeChartsBean bean: beans){
bean.setLeft_eye(Eye.transformSmall(bean.getLeft_eye()));
bean.setRight_eye(Eye.transformSmall(bean.getRight_eye()));
}
}
ChartsView chartsView1 = new ChartsView(this,w/2,h);
leftLineChart.addView(chartsView1);
chartsView1.setData(beans,true);
ChartsView chartsView2 = new ChartsView(this,w/2,h);
rightLineChart.addView(chartsView2);
chartsView2.setData(beans,false);
}
}
public void getEyeChartsFail(String msg){
ToastUtil.showLongMessage(msg);
}
}
......@@ -4,7 +4,11 @@ import android.os.Bundle;
import android.widget.TextView;
import com.app.baselibrary.base.common.BaseActivity;
import com.oo.eye.EyeConfig;
import com.oo.eye.R;
import com.oo.eye.bean.Student;
import java.util.ArrayList;
import butterknife.BindView;
import butterknife.ButterKnife;
......@@ -32,12 +36,16 @@ public class SinglePeopleTestActivity extends BaseActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// TODO: add setContentView(...) invocation
ButterKnife.bind(this);
}
@OnClick(R.id.begin_test)
public void onClick() {
ArrayList<Student> list = new ArrayList<>();
Student student = new Student();
student.setRealname("游客");
list.add(student);
EyeConfig.getInstance().setStudents(list);
startActivity(BeforeEyeTestActivity.class);
}
}
package com.oo.eye.manager;
import android.content.Context;
import android.content.Intent;
/**
* Created by henry 16/8/4.
*/
public class DaemonSender {
/**
* 语音播报
* @param context
* @param text
*/
public static void sendDBTTS(Context context, String text) {
Intent intent = new Intent(OOMsg.DBTTS_INTENT_ACTION);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
intent.putExtra(OOMsg.DBTTS_KEY, text);
context.sendBroadcast(intent);
}
/**
* 开启视力测试
* @param context
*/
public static void startEyeTest(Context context) {
Intent intent = init(OOMsg.START_EYE_TEST);
context.sendBroadcast(intent);
}
/**
* 关闭视力测试
* @param context
*/
public static void closeEyeTest(Context context) {
Intent intent = init(OOMsg.CLOSE_EYE_TEST);
context.sendBroadcast(intent);
}
/**
* 打开视力测试马达调节
* @param context
*/
public static void startEyeTestMotor(Context context) {
Intent intent = init(OOMsg.START_EYE_TEST_MOTOR);
context.sendBroadcast(intent);
}
/**
* 关闭视力测试马达调节
* @param context
*/
public static void closeEyeTestMotor(Context context) {
Intent intent = init(OOMsg.CLOSE_EYE_TEST_MOTOR);
context.sendBroadcast(intent);
}
private static Intent init(int action) {
Intent intent = new Intent(OOMsg.DAEMON_INTENT_ACTION);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
intent.putExtra(OOMsg.ARG_SEEX_ACTION, action);
return intent;
}
}
package com.oo.eye.manager;
/**
* Created by xucon on 2017/12/25.
*/
public class OOMsg {
public static final String OO_INTENT_ACTION = "com.seex.daemon.task";
public static final String DAEMON_INTENT_ACTION = "com.oo.seex.message";
public static final String ARG_SEEX_ACTION = "arg_seex_action";
public static final String DBTTS_INTENT_ACTION = "com.oo.seex.cmd.tts";
public static final String DBTTS_KEY ="text";
public static final int EYE = 10000;
//发送启动视力测试
public static final int START_EYE_TEST = EYE + 1;
//发送关闭视力测试
public static final int CLOSE_EYE_TEST = EYE + 2;
//发送视力测试马达调节
public static final int START_EYE_TEST_MOTOR = EYE + 3;
//发送关闭视力测试马达调节
public static final int CLOSE_EYE_TEST_MOTOR = EYE + 4;
//接收视力测试马达调节完成
public static final int EYE_TEST_MOTOR_FINISH = EYE + 5;
}
......@@ -2,20 +2,8 @@ package com.oo.eye.mvp.presenter;
import android.content.Context;
import com.app.baselibrary.commonUtil.SnUtils;
import com.oo.eye.EyeConfig;
import com.oo.eye.bean.EyeHistroyBean;
import com.oo.eye.bean.InitDataBean;
import com.oo.eye.db.DbManager;
import com.oo.eye.gen.EyeHistroyBeanDao;
import com.oo.eye.mvp.contract.EyeMainContract;
import com.oo.eye.net.EyeDataManager;
import com.oo.seex.netlibrary.net.response.NewResponseImpl;
import com.oo.seex.netlibrary.net.response.RxCallback;
import org.greenrobot.greendao.query.QueryBuilder;
import java.util.List;
/**
* Created by xucon on 2017/12/27.
......@@ -38,48 +26,48 @@ public class EyeMainPresenter implements EyeMainContract.Presenter {
}
private void getEyeNet(){
EyeDataManager.getInstance().getEyeInit(SnUtils.getSN())
.subscribe(new RxCallback<NewResponseImpl<InitDataBean>>() {
@Override
public void onSuccess(NewResponseImpl<InitDataBean> response) {
InitDataBean initDataBean = response.getResultData();
if(initDataBean != null){
if(initDataBean.getInitializedEye() != null){
EyeHistroyBean initBean = initDataBean.getInitializedEye();
if(initBean != null && initBean.getLeft_eye() != 0 && initBean.getRight_eye() != 0){
EyeConfig.getInstance().setInitBean(initBean);
}
}
if(initDataBean.getCurrentEye() != null){
EyeHistroyBean currentBean = initDataBean.getCurrentEye();
if(currentBean != null && currentBean.getLeft_eye() != 0 && currentBean.getRight_eye() != 0){
EyeConfig.getInstance().setInitBean(currentBean);
}
}
}
if (mView != null && mView.isActive())
mView.getEyeSuccee();
}
@Override
public void onError(int errorCode, String errorMessage) {
mView.getEyeFail(errorMessage);
}
});
// EyeDataManager.getInstance().getEyeInit(SnUtils.getSN())
// .subscribe(new RxCallback<NewResponseImpl<InitDataBean>>() {
// @Override
// public void onSuccess(NewResponseImpl<InitDataBean> response) {
// InitDataBean initDataBean = response.getResultData();
// if(initDataBean != null){
// if(initDataBean.getInitializedEye() != null){
// EyeHistroyBean initBean = initDataBean.getInitializedEye();
// if(initBean != null && initBean.getLeft_eye() != 0 && initBean.getRight_eye() != 0){
// EyeConfig.getInstance().setInitBean(initBean);
// }
// }
// if(initDataBean.getCurrentEye() != null){
// EyeHistroyBean currentBean = initDataBean.getCurrentEye();
// if(currentBean != null && currentBean.getLeft_eye() != 0 && currentBean.getRight_eye() != 0){
// EyeConfig.getInstance().setInitBean(currentBean);
// }
// }
// }
// if (mView != null && mView.isActive())
// mView.getEyeSuccee();
// }
//
// @Override
// public void onError(int errorCode, String errorMessage) {
// mView.getEyeFail(errorMessage);
// }
// });
}
private void getEyeDB(Context context){
try {
QueryBuilder<EyeHistroyBean> builder = DbManager.getDaoMaster(context).newSession().getEyeHistroyBeanDao().queryBuilder();
List<EyeHistroyBean> descBeans = builder.orderDesc(EyeHistroyBeanDao.Properties.Created_time).build().list();
if (descBeans != null && descBeans.size() > 0) {
EyeConfig.getInstance().setCuurentBean(descBeans.get(0));
EyeConfig.getInstance().setInitBean(descBeans.get(descBeans.size() - 1));
}
EyeConfig.getInstance().setNetData(false);
if (mView != null && mView.isActive()) {
mView.getEyeSuccee();
}
// QueryBuilder<EyeHistroyBean> builder = DbManager.getDaoMaster(context).newSession().getEyeHistroyBeanDao().queryBuilder();
// List<EyeHistroyBean> descBeans = builder.orderDesc(EyeHistroyBeanDao.Properties.Created_time).build().list();
// if (descBeans != null && descBeans.size() > 0) {
// EyeConfig.getInstance().setCuurentBean(descBeans.get(0));
// EyeConfig.getInstance().setInitBean(descBeans.get(descBeans.size() - 1));
// }
// EyeConfig.getInstance().setNetData(false);
// if (mView != null && mView.isActive()) {
// mView.getEyeSuccee();
// }
}catch (Exception e){
e.printStackTrace();
if (mView != null && mView.isActive())
......
......@@ -15,11 +15,6 @@
android:textColor="@color/white"
android:textSize="18sp"/>
<com.oo.seex.sys_state.widget.StateView
android:id="@+id/state_view"
android:layout_width="match_parent"
android:layout_height="15dp"/>
<LinearLayout
android:id="@+id/ll_eye_histroy_top"
android:layout_width="334dp"
......
......@@ -43,12 +43,6 @@
</LinearLayout>
</RelativeLayout>
<com.oo.seex.sys_state.widget.StateView
android:id="@+id/state_view"
android:layout_width="match_parent"
android:layout_height="15dp"
android:visibility="gone" />
<LinearLayout
android:id="@+id/title_lay"
android:layout_width="wrap_content"
......
......@@ -14,10 +14,6 @@
android:text="视力统计"
android:textColor="@color/white"
android:textSize="18sp"/>
<com.oo.seex.sys_state.widget.StateView
android:id="@+id/state_view"
android:layout_width="match_parent"
android:layout_height="15dp"/>
<RelativeLayout
android:id="@+id/rl_eye_statistics_top"
android:layout_width="match_parent"
......
......@@ -76,12 +76,6 @@
android:src="@drawable/wingright" />
</LinearLayout>
<com.oo.seex.sys_state.widget.StateView
android:id="@+id/state_view"
android:layout_width="match_parent"
android:layout_height="15dp"
android:visibility="gone" />
<LinearLayout
android:layout_width="700dip"
android:layout_height="@dimen/dp_120"
......
......@@ -84,10 +84,6 @@ dependencies {
compile 'com.google.code.gson:gson:2.8.0'
//eventBus
compile 'org.greenrobot:eventbus:3.0.0'
compile project(':library:sys_state')
// compile files('libs/oo_analysis-1.0.jar')
compile files('libs/oo_framework.jar')
compile project(':library:oo_statistics_lib')
compile files('libs/com.baidu.tts_2.3.2.20180419_5a5fec8.jar')
compile files('libs/com.baidu.tts_2.3.0.jar')
}
......@@ -7,9 +7,7 @@ import android.os.Looper;
import com.app.baselibrary.commonUtil.BDttsUtils;
import com.app.baselibrary.commonUtil.PreferencesUtils;
import com.app.baselibrary.commonUtil.SnUtils;
import com.facebook.drawee.backends.pipeline.Fresco;
import com.oo.seex.oo_statistics_lib.OOAgent;
/**
* 在此写用途
......@@ -19,9 +17,6 @@ import com.oo.seex.oo_statistics_lib.OOAgent;
public class BaseApplication extends Application {
//统计的根路径;
public static final String STATISTICS_HOST_URL = "http://seexlog.ooyby.com";
private static BaseApplication mBaseApplication;
private static Handler UIHANDLER;
......@@ -32,10 +27,7 @@ public class BaseApplication extends Application {
mBaseApplication = this;
Fresco.initialize(this);
PreferencesUtils.putLong( "device_on_time", System.currentTimeMillis() / 1000);
OOAgent.initShincAgent(this, SnUtils.getSN(),STATISTICS_HOST_URL);
// OOAgent.showDebug();
BDttsUtils.getInstance();//初始化百度语音
//MobclickAgent.openActivityDurationTrack(false);
}
......
......@@ -11,7 +11,6 @@ import com.app.baselibrary.BuildConfig;
import com.app.baselibrary.R;
import com.app.baselibrary.base.app.AppManager;
import com.app.baselibrary.commonUtil.StatusBarCompat;
import com.oo.seex.oo_statistics_lib.OOAgent;
import com.tbruyelle.rxpermissions.RxPermissions;
import com.trello.rxlifecycle.components.support.RxAppCompatActivity;
import com.umeng.analytics.MobclickAgent;
......@@ -59,8 +58,6 @@ public abstract class BaseActivity extends RxAppCompatActivity {
super.onResume();
if (!BuildConfig.LOG_DEBUG)
MobclickAgent.onResume(this);
OOAgent.onResumeActivity(this);
}
@Override
......@@ -68,9 +65,6 @@ public abstract class BaseActivity extends RxAppCompatActivity {
super.onPause();
if (!BuildConfig.LOG_DEBUG)
MobclickAgent.onPause(this);
OOAgent.onPauseActivity(this);
}
@Override
......
......@@ -8,7 +8,6 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.oo.seex.oo_statistics_lib.OOAgent;
import com.tbruyelle.rxpermissions.RxPermissions;
import butterknife.ButterKnife;
......@@ -37,13 +36,11 @@ public abstract class BaseFragment extends Fragment {
@Override
public void onStart() {
super.onStart();
OOAgent.onFragmentResume(getActivity(),this.getClass().getSimpleName());
}
@Override
public void onStop() {
super.onStop();
OOAgent.onFragmentPause(getActivity(),this.getClass().getSimpleName());
}
//获取布局文件
......@@ -113,16 +110,12 @@ public abstract class BaseFragment extends Fragment {
@Override
public void onResume() {
super.onResume();
OOAgent.onFragmentResume(getActivity(), getClass().getSimpleName());
}
@Override
public void onPause() {
super.onPause();
OOAgent.onFragmentPause(getActivity(),getClass().getSimpleName());
}
@Override
......
......@@ -11,9 +11,6 @@ import com.app.baselibrary.BuildConfig;
import com.app.baselibrary.R;
import com.app.baselibrary.base.app.AppManager;
import com.app.baselibrary.commonUtil.StatusBarCompat;
import com.oo.seex.oo_statistics_lib.OOAgent;
import com.oo.seex.sys_state.Config;
import com.oo.seex.sys_state.SystemStateManager;
import com.tbruyelle.rxpermissions.RxPermissions;
import com.trello.rxlifecycle.LifecycleTransformer;
import com.trello.rxlifecycle.android.ActivityEvent;
......@@ -31,7 +28,6 @@ import butterknife.ButterKnife;
public abstract class BaseFragmentActivity extends RxFragmentActivity {
public RxPermissions mRxPermissions;
public SystemStateManager mSystemStateManager;
@Override
......@@ -61,9 +57,6 @@ public abstract class BaseFragmentActivity extends RxFragmentActivity {
//setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
//设置状态栏的主颜色:
SetTranslanteBar();
mSystemStateManager = new SystemStateManager(this, Config.FLAG_BLUETOOTH_STATE | Config.FLAG_BATTERY_STATE | Config.FLAG_WIFI_STATE);
}
@Override
......@@ -71,8 +64,6 @@ public abstract class BaseFragmentActivity extends RxFragmentActivity {
super.onResume();
if (!BuildConfig.LOG_DEBUG)
MobclickAgent.onResume(this);
OOAgent.onResumeActivity(this);
}
@Override
......@@ -80,8 +71,6 @@ public abstract class BaseFragmentActivity extends RxFragmentActivity {
super.onPause();
if (!BuildConfig.LOG_DEBUG)
MobclickAgent.onPause(this);
OOAgent.onPauseActivity(this);
}
@Override
......
......@@ -4,7 +4,6 @@ import com.app.baselibrary.base.app.BaseApplication;
import com.baidu.tts.auth.AuthInfo;
import com.baidu.tts.client.SpeechSynthesizer;
import com.baidu.tts.client.TtsMode;
import com.oo.seex.oo_statistics_lib.utils.utdid.utils.NetworkUtils;
import java.io.File;
import java.io.FileNotFoundException;
......@@ -38,7 +37,7 @@ public class BDttsUtils {
}
public static BDttsUtils getInstance() {
if (mInstance == null && NetworkUtils.isConnectInternet(BaseApplication.getAppContext())) {
if (mInstance == null && NetWorkUtils.isNetConnected(BaseApplication.getAppContext())) {
synchronized (BDttsUtils.class) {
if (mInstance == null) {
mInstance = new BDttsUtils();
......@@ -54,6 +53,7 @@ public class BDttsUtils {
@Override
public void run() {
super.run();
LogUtil.e("baidu----init");
initialEnv();
initialTts();
isInit = true;
......
package com.app.baselibrary.commonUtil;
import android.content.Context;
import android.content.Intent;
import com.app.baselibrary.base.app.BaseApplication;
/**
* Created by zhaopenglei on 16/9/23.
*/
public class NibiruUtils {
public static boolean isOpenVR = false;
public static boolean isOpenVR() {
return isOpenVR;
}
public static void setIsOpenVR(boolean isOpenVR) {
NibiruUtils.isOpenVR = isOpenVR;
}
/**
* 切换当双眼模式的方法;
*
* @param isOpenVR 是否开启VR模式;
*/
public static void switchVR(boolean isOpenVR) {
setIsOpenVR(isOpenVR);
Intent intent = new Intent("com.nibiru.vr.sdk.action.switchvr");
intent.putExtra("vr_mode", !isOpenVR);
ContextUtil.getAppContext().sendBroadcast(intent);
}
public static void switchLocalEnterStatus(boolean show) {
Intent intent = new Intent("com.oo.seex.sys.command.app_list");
intent.putExtra("show", show);
BaseApplication.getAppContext().sendBroadcast(intent);
PreferencesUtils.putBoolean( BaseApplication.getAppContext(), "switchLocal", show);
}
public static void startNibiruSetting(Context context) {
Intent launchIntent = context.getPackageManager().getLaunchIntentForPackage("com.android.nibiru.settings.vr");
if (null != launchIntent) {
context.startActivity(launchIntent);
} else {
ToastUtil.showMessage("找不到该package对应的应用!");
}
}
// public static String getNibiruVersionCode(Activity activity) {
//
// ServiceConnection mScon = new ServiceConnection() {
//
// @Override
// public void onServiceDisconnected(ComponentName arg0) {
// Log.d("wayne", "nps onServiceDisconnected");
// mNps = null;
// }
//
// @Override
// public void onServiceConnected(ComponentName arg0, IBinder ibinder) {
// Log.d("wayne", "nps onServiceConnected");
// mNps = INibiruVRPublicService.Stub.asInterface(ibinder);
// }
// };
//
// Intent intent = new Intent("com.nibiru.public.service");
// intent.setPackage("com.nibiru.vrconfig");
// activity.bindService(intent, mScon, BIND_AUTO_CREATE);
//
// try {
// if (null == mNps) {
// return "unfind_version";
// }
// return mNps.getNibiruOSVersion();
// } catch (RemoteException e) {
// e.printStackTrace();
// }
//
// return "unfind_version";
// }
}
......@@ -4,8 +4,6 @@ import android.content.Context;
import android.content.res.AssetManager;
import android.os.Environment;
import com.oo.seex.oo_statistics_lib.utils.FileUtil;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
......
......@@ -4,8 +4,6 @@ import android.content.Context;
import android.content.res.AssetManager;
import android.util.Log;
import com.oo.seex.oo_statistics_lib.utils.FileUtil;
import java.io.IOException;
import java.util.HashMap;
......
......@@ -7,7 +7,6 @@ import com.app.baselibrary.commonUtil.NetWorkUtils;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.oo.seex.netlibrary.net.BaseApiConfig;
import com.oo.seex.oo_statistics_lib.OOAgent;
import java.io.File;
import java.io.IOException;
......@@ -116,7 +115,7 @@ public class ServiceFactory {
public Response intercept(Chain chain) throws IOException {
Request build = chain.request().newBuilder()
.addHeader("Content-Type", "application/json")
.addHeader("User-Agent", OOAgent.getUserAgent(BaseApplication.getAppContext()))
// .addHeader("User-Agent", OOAgent.getUserAgent(BaseApplication.getAppContext()))
.build();
return chain.proceed(build);
}
......
package com.oo.seex.netlibrary.net.response;
import com.app.baselibrary.commonUtil.ContextUtil;
import com.oo.seex.oo_statistics_lib.OOAgent;
import java.util.HashMap;
import java.util.Map;
......@@ -17,8 +14,8 @@ public class Request {
private Map<String,String> headers = new HashMap<>();
public Request(){
String userAgent = OOAgent.getUserAgent(ContextUtil.getAppContext());
headers.put("User-Agent",userAgent);
// String userAgent = OOAgent.getUserAgent(ContextUtil.getAppContext());
// headers.put("User-Agent",userAgent);
}
public void setParams(Map<String, String> map){
......
apply plugin: 'com.android.library'
android {
compileSdkVersion 22
buildToolsVersion "25.0.2"
defaultConfig {
minSdkVersion 15
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
// buildTypes {
// release {
// minifyEnabled true
// zipAlignEnabled true
// shrinkResources true
// proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
// }
// }
lintOptions {
abortOnError false
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
}
dependencies {
}
task makeJar(type: Copy) {
from('build/intermediates/bundles/default/')
into('build/outputs/')
include('classes.jar')
rename('classes.jar', 'oo_analysis-' + android.defaultConfig.versionName + '.jar')
}
makeJar.dependsOn(build)
\ No newline at end of file
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /Users/pl/Library/Android/sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
-optimizationpasses 5 #指定代码的压缩级别;
-dontusemixedcaseclassnames #是否使用大小写混合;
#不去忽略非公共的库类
-dontskipnonpubliclibraryclasses
#保护注解
-keepattributes *Annotation*
-dontpreverify #混淆时是否做预校验;
-verbose #混淆时是否记录日志;
-dontskipnonpubliclibraryclasses
-ignorewarnings
-dontwarn android.support.**
-keep public class * extends android.app.Application # 保持哪些类不被混淆
-keep public class * extends android.app.Service # 保持哪些类不被混淆
-keep public class * extends android.app.Activity # 保持哪些类不被混淆
-keep public class * extends android.content.BroadcastReceiver # 保持哪些类不被混淆
-keep public class * extends android.content.ContentProvider # 保持哪些类不被混淆
-keep public class * extends android.app.backup.BackupAgentHelper # 保持哪些类不被混淆
-keep public class * extends android.preference.Preference # 保持哪些类不被混淆
-keep public class com.android.vending.licensing.ILicensingService # 保持哪些类不被混淆
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/* #混淆时所采用的算法;
-keepclasseswithmembernames class * { # 保持 native 方法不被混淆
native <methods>;
}
-keepclasseswithmembers class * { # 保持自定义控件类不被混淆
public <init>(android.content.Context, android.util.AttributeSet);
}
-keepclasseswithmembers class * {# 保持自定义控件类不被混淆
public <init>(android.content.Context, android.util.AttributeSet, int);
}
-keepclassmembers class * extends android.app.Activity { # 保持自定义控件类不被混淆
public void *(android.view.View);
}
-keepclassmembers enum * { # 保持枚举 enum 类不被混淆
public static **[] values();
public static ** valueOf(java.lang.String);
}
-keep class * implements android.os.Parcelable { # 保持 Parcelable 不被混淆
public static final android.os.Parcelable$Creator *;
}
-keep public class * implements java.io.Serializable {*;}
#统计的Bean文件不应该被混淆,
-keep class com.oo.seex.oo_statistics_lib.bean.** { *; }
-keep class com.oo.seex.oo_statistics_lib.utils.utdid.** { *; }
-keep class com.oo.seex.oo_statistics_lib.utils.utdid.core.** { *; }
-keep class com.oo.seex.oo_statistics_lib.utils.utdid.Device.** { *; }
-keep class com.oo.seex.oo_statistics_lib.utils.utdid.utils.** { *; }
-keep class com.oo.seex.oo_statistics_lib.utils.MyDbUtils { *; }
-keep class com.oo.seex.oo_statistics_lib.utils.MyCrashHandler.** { *; }
-keep class com.oo.seex.oo_statistics_lib.utils.xutils_dbbutil { *; }
-keep public class com.oo.seex.oo_statistics_lib.OOAgent {
public static <methods>;
public static <fields>;
}
\ No newline at end of file
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.oo.seex.oo_statistics_lib">
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<application
android:allowBackup="true"
android:label="@string/app_name"
android:supportsRtl="true">
</application>
</manifest>
package com.oo.seex.oo_statistics_lib;
import android.app.Activity;
import android.content.Context;
import android.os.Build;
import android.text.TextUtils;
import com.oo.seex.oo_statistics_lib.constant.OOConstant;
import com.oo.seex.oo_statistics_lib.utils.CommonUtil;
import com.oo.seex.oo_statistics_lib.utils.FileUtil;
import java.util.HashMap;
import java.util.Map;
/**
* Created by efort on 15/7/30.
* 试用接口;提供统计以及错误log提交服务
*/
public class OOAgent {
/**
* 发送这个页面的本次统计(activity)
*
* @param activity
*/
public static void onPauseActivity(final Activity activity) {
DataDeal.getInstance().dealActivityPause(activity);
}
/**
* 开始统计这个页面(activity)
*
* @param activity
*/
public static void onResumeActivity(final Activity activity) {
DataDeal.getInstance().dealActivityResume(activity);
}
/**
* 开始统计
* @param context
* @param fragmentName
*/
public static void onFragmentResume(final Context context, final String fragmentName) {
if (TextUtils.isEmpty(fragmentName)) {
return;
}
DataDeal.getInstance().dealResumeFragment(context,fragmentName);
}
/**
* 结束统计fragment的内容
*
* @param activity
* @param fragmentName
*/
public static void onFragmentPause(final Activity activity, final String fragmentName) {
if (TextUtils.isEmpty(fragmentName)) {
return;
}
DataDeal.getInstance().dealPauseFragment(activity,fragmentName);
}
/**
* 发送自定义事件
*
* @param context
* @param event_id
*/
public static void onEvent(final Context context, final String event_id) {
DataDeal.getInstance().onEvent(context, event_id, "", null, 1);
}
/**
* 发送自定义事件
*
* @param context
* @param event_id
*/
public static void onEvent(Context context, String event_id, int acc) {
DataDeal.getInstance().onEvent(context, event_id, "", null, acc);
}
/**
* @param mContext
* @param event_id 事件id;
* @param label 事件标签;
* @param remark 事件参数;
*/
private static void onEvent(Context mContext, String event_id, String label, String remark) {
HashMap<String, String> remarks = null;
if (!TextUtils.isEmpty(remark)) {
remarks = new HashMap<String, String>();
remarks.put("tag", remark);
}
DataDeal.getInstance().onEvent(mContext, event_id, label, remarks, 1);
}
/**
* @param mContext
* @param event_id 事件id;
* @param label 事件标签;
*/
public static void onEvent(Context mContext, String event_id, String label) {
DataDeal.getInstance().onEvent(mContext, event_id, label, null, 1);
}
/**
* @param mContext
* @param event_id 自定义事件的标示ID
* @param remarks 事件传递的参数;
*/
public static void onEvent(Context mContext, String event_id, Map<String, String> remarks) {
DataDeal.getInstance().onEvent(mContext, event_id, "", remarks, 1);
}
/**
* @param mContext
* @param event_id 自定义时间的标示ID;
* @param label 计数器;
* @param remarks 事件传递的参数;
*/
public static void onEvent(Context mContext, String event_id, String label, Map<String, String> remarks) {
DataDeal.getInstance().onEvent(mContext, event_id, label, remarks, 1);
}
/**
* 设置标示符,其实就是将我门应用的个人标示保存起来 eg userID
*
* @param version OS版本号
*/
public static void bindOSVersion(final Context context,String version) {
if (TextUtils.isEmpty(version)) {
version = "0";
}
FileUtil.saveOSToFile(version);
}
/**
* 设置标示符,其实就是将我门应用的个人标示保存起来 eg userID
*
* @param identifier
*/
public static void bindUserIdentifier(final Context context,String identifier) {
if (TextUtils.isEmpty(identifier)) {
identifier = "0";
}
FileUtil.saveUserIdToFile(identifier);
}
/**
* 设置标示符,其实就是将我门应用的个人标示保存起来 eg userID
* 这个方法还用于统计第三方登陆
*
* @param identifier
* @param provider 第三方渠道名称
*/
public static void bindUserIdentifier(final Context context, String identifier, final String provider) {
try {
if (TextUtils.isEmpty(identifier)) {
identifier = "0";
}
FileUtil.saveUserIdToFile(identifier);
HashMap<String, String> tempMap = new HashMap<>();
tempMap.put("PROVIDER", provider);
tempMap.put("USERID", identifier);
onEvent(context, "shinc_add_userId_provider", "", tempMap);
} catch (Exception e) {
CommonUtil.printLog("error_shinc_add_userId_provider", "info: " + e);
}
}
/**
* 初始化设备信息
*
* @param context
*/
public static void initShincAgent(Context context, String deviceId, String requestUrl) {
setBaseURL(requestUrl);
DataDeal.getInstance().initShincAgent(context, deviceId);
}
/**
* 错误日志
*/
public static void showDebug() {
OOConstant.DebugMode = true;
}
/**
* set base URL like http://localhost/razor/ums/index.php?
* 访问服务器地址 在我们的应用一开始的视后就需要设置
*
* @param url
*/
public static void setBaseURL(String url) {
//最初的服务器地址url
if (!TextUtils.isEmpty(url)) {
OOConstant.preUrl = url;
} else {
CommonUtil.printLog("OOAgent:", "base url should not NULL or \"\"");
}
}
public static String getUserAgent(Context context){
StringBuilder user_agent = new StringBuilder();
user_agent.append("device_sn:" + Build.SERIAL);
user_agent.append(";user_id:" + CommonUtil.getUserIdentifier(context));
user_agent.append(";device_ip:" + CommonUtil.getIp(context));
user_agent.append(";os_version:" + CommonUtil.getOSVersion(context));
user_agent.append(";soft_version:" + CommonUtil.getVersion(context));
user_agent.append(";app_key:" + CommonUtil.getAppKey(context));
user_agent.append(";platform:" + Build.PRODUCT);
return user_agent.toString();
}
}
package com.oo.seex.oo_statistics_lib.bean;
import com.oo.seex.oo_statistics_lib.utils.xutils_dbutils.db.annotation.Id;
/**
* Created by efort on 15/7/31.
*/
public class ActivityStaBean {
@Id
private int id;
private String session_id = "";
private String start_millis;
private String end_millis;
private String version;
private String activities;
private String appkey;
private String userId;
private Long saveTime;
private String secrect_key;
// private String clientdata_id;
private String device_id;
private String parent_activity;
@Override
public String toString() {
return "ActivityStaBean{" +
"id=" + id +
", session_id='" + session_id + '\'' +
", start_millis='" + start_millis + '\'' +
", end_millis='" + end_millis + '\'' +
", version='" + version + '\'' +
", activities='" + activities + '\'' +
", appkey='" + appkey + '\'' +
", userId='" + userId + '\'' +
", saveTime=" + saveTime +
", secrect_key='" + secrect_key + '\'' +
// ", clientdata_id='" + clientdata_id + '\'' +
", parent_activity='" + parent_activity + '\'' +
", duration='" + duration + '\'' +
'}';
}
private String duration;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getSession_id() {
return session_id;
}
public void setSession_id(String session_id) {
this.session_id = session_id;
}
public String getStart_millis() {
return start_millis;
}
public void setStart_millis(String start_millis) {
this.start_millis = start_millis;
}
public String getEnd_millis() {
return end_millis;
}
public void setEnd_millis(String end_millis) {
this.end_millis = end_millis;
}
public String getVersion() {
return version;
}
public void setVersion(String version) {
this.version = version;
}
public String getActivities() {
return activities;
}
public void setActivities(String activities) {
this.activities = activities;
}
public String getAppkey() {
return appkey;
}
public void setAppkey(String appkey) {
this.appkey = appkey;
}
public String getDuration() {
return duration;
}
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public void setDuration(String duration) {
this.duration = duration;
}
public Long getSaveTime() {
return saveTime;
}
public void setSaveTime(Long saveTime) {
this.saveTime = saveTime;
}
public String getSecrect_key() {
return secrect_key;
}
public void setSecrect_key(String secrect_key) {
this.secrect_key = secrect_key;
}
// public String getClientdata_id() {
// return clientdata_id;
// }
//
// public void setClientdata_id(String clientdata_id) {
// this.clientdata_id = clientdata_id;
// }
public String getParent_activity() {
return parent_activity;
}
public void setParent_activity(String parent_activity) {
this.parent_activity = parent_activity;
}
public String getDevice_id() {
return device_id;
}
public void setDevice_id(String device_id) {
this.device_id = device_id;
}
}
package com.oo.seex.oo_statistics_lib.bean;
import com.oo.seex.oo_statistics_lib.utils.xutils_dbutils.db.annotation.Id;
/**
* Created by efort on 15/7/31.
*/
public class ErrorStaBean {
@Id
private int id;
private String stacktrace;
private String time;
private String activity;
private String appkey;
private String channel;
private String os_version;
// private String clientdata_id;
private String device_id;
private String userId;
private String version;
public String getStacktrace() {
return stacktrace;
}
public void setStacktrace(String stacktrace) {
this.stacktrace = stacktrace;
}
public String getTime() {
return time;
}
public void setTime(String time) {
this.time = time;
}
public String getActivity() {
return activity;
}
public void setActivity(String activity) {
this.activity = activity;
}
public String getAppkey() {
return appkey;
}
public void setAppkey(String appkey) {
this.appkey = appkey;
}
public String getOs_version() {
return os_version;
}
public void setOs_version(String os_version) {
this.os_version = os_version;
}
public void setVersion(String version) {
this.version = version;
}
public String getVersion() {
return version;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
// public String getClientdata_id() {
// return clientdata_id;
// }
//
// public void setClientdata_id(String clientdata_id) {
// this.clientdata_id = clientdata_id;
// }
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public String getChannel() {
return channel;
}
public void setChannel(String channel) {
this.channel = channel;
}
public String getDevice_id() {
return device_id;
}
public void setDevice_id(String device_id) {
this.device_id = device_id;
}
}
package com.oo.seex.oo_statistics_lib.bean;
import android.content.Context;
import android.text.TextUtils;
import com.oo.seex.oo_statistics_lib.utils.CommonUtil;
import com.oo.seex.oo_statistics_lib.utils.xutils_dbutils.db.annotation.Id;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
/**
* Created by efort on 15/7/31.
*/
public class EventStaBean {
@Id
private int id;
private String event_id;
private String label;
private String device_id;
private String userId;
// private String clientdata_id;
private String acc;
private String remarks;
private String time;
private String activity;
private String version;
private String appkey;
public EventStaBean() {
}
public EventStaBean(String event_id, String label, String acc, Context context, Map<String, String> remarks) {
super();
this.event_id = TextUtils.isEmpty(event_id) ? "" : event_id;
this.label = TextUtils.isEmpty(label) ? "" : label;
this.acc = TextUtils.isEmpty(acc) ? "" : acc;
// this.remarks = TextUtils.isEmpty(remarks) ? "" : remarks;
StringBuilder stringBuilder = new StringBuilder();
try {
if (remarks != null && remarks.size() > 0) {
Iterator iter = remarks.entrySet().iterator();
while (iter.hasNext()) {
Map.Entry entry = (Map.Entry) iter.next();
String key = (String) entry.getKey();
String val = (String) entry.getValue();
if (!TextUtils.isEmpty(key)) {
stringBuilder.append(key);
} else {
continue;
}
stringBuilder.append("=");
if (!TextUtils.isEmpty(val)) {
stringBuilder.append(val);
} else {
stringBuilder.append("");
}
stringBuilder.append(",");
}
if (stringBuilder.toString().contains(","))
stringBuilder.deleteCharAt(stringBuilder.lastIndexOf(","));
}
} catch (NullPointerException e) {
CommonUtil.printLog("value中有空值", e.getMessage());
}
this.remarks = stringBuilder.toString();
this.time = String.valueOf(CommonUtil.getTime());
this.activity = CommonUtil.getActivityName(context);
this.appkey = CommonUtil.getAppKey(context);
this.version = CommonUtil.getVersion(context);
this.userId = CommonUtil.getUserIdentifier(context);
this.device_id = CommonUtil.getDeviceID(context);
}
// public EventStaBean(String event_id, String label, String acc, String time, String activity,
// String version, String appkey) {
// super();
// this.event_id = event_id;
// this.label = label;
// this.acc = acc;
// this.time = time;
// this.activity = activity;
// this.version = version;
// this.appkey = appkey;
// }
public boolean verification() {
if (getAcc().contains("-") || getAcc() == null || getAcc().equals("")) {
return false;
} else {
return true;
}
}
public String getTime() {
return time;
}
public void setTime(String time) {
this.time = time;
}
public String getActivity() {
return activity;
}
public void setActivity(String activity) {
this.activity = activity;
}
public String getVersion() {
return version;
}
public void setVersion(String version) {
this.version = version;
}
public String getAppkey() {
return appkey;
}
public void setAppkey(String appkey) {
this.appkey = appkey;
}
public String getEvent_id() {
return event_id;
}
public void setEvent_id(String event_id) {
this.event_id = event_id;
}
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public String getAcc() {
return acc;
}
public void setAcc(String acc) {
this.acc = acc;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((acc == null) ? 0 : acc.hashCode());
result = prime * result + ((activity == null) ? 0 : activity.hashCode());
result = prime * result + ((appkey == null) ? 0 : appkey.hashCode());
result = prime * result + ((event_id == null) ? 0 : event_id.hashCode());
result = prime * result + ((label == null) ? 0 : label.hashCode());
result = prime * result + ((time == null) ? 0 : time.hashCode());
result = prime * result + ((version == null) ? 0 : version.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
EventStaBean other = (EventStaBean) obj;
if (acc == null) {
if (other.acc != null)
return false;
} else if (!acc.equals(other.acc))
return false;
if (activity == null) {
if (other.activity != null)
return false;
} else if (!activity.equals(other.activity))
return false;
if (appkey == null) {
if (other.appkey != null)
return false;
} else if (!appkey.equals(other.appkey))
return false;
if (event_id == null) {
if (other.event_id != null)
return false;
} else if (!event_id.equals(other.event_id))
return false;
if (label == null) {
if (other.label != null)
return false;
} else if (!label.equals(other.label))
return false;
if (time == null) {
if (other.time != null)
return false;
} else if (!time.equals(other.time))
return false;
if (version == null) {
if (other.version != null)
return false;
} else if (!version.equals(other.version))
return false;
return true;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getRemarks() {
return remarks;
}
public Map<String, String> getRemarkByMap() {
HashMap<String, String> map = null;
try {
if (!TextUtils.isEmpty(remarks)) {
map = new HashMap<String, String>();
String[] remakeArrays = remarks.split(",");
if (remakeArrays == null || remakeArrays.length == 0)
return null;
for (int i = 0; i < remakeArrays.length; i++) {
String[] tempItem = remakeArrays[i].split("=");
if (tempItem != null && tempItem.length > 1 && tempItem[0] != null && tempItem[1] != null)
map.put(tempItem[0], tempItem[1]);
}
}
} catch (Exception e) {
CommonUtil.printLog("OOAgent", "getRemarkMap in getJsonData happen exception:" + e.getMessage());
}
return map;
}
public void setRemarks(String remarks) {
this.remarks = remarks;
}
public String getDevice_id() {
return device_id;
}
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
}
package com.oo.seex.oo_statistics_lib.bean;
import com.oo.seex.oo_statistics_lib.utils.xutils_dbutils.db.annotation.Id;
/**
* Created by efort on 15/7/31.
*/
public class FragmentBean {
@Id
private int id;
private String device_id;
private String userId;
// private String clientdata_id;
private String fragment_start_millis;
private long fragment_start;
private String fragment_end_millis;
private long fragment_end;
private String activity;
private String version;
private String fragments;
private String appkey;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getFragment_start_millis() {
return fragment_start_millis;
}
public void setFragment_start_millis(String fragment_start_millis) {
this.fragment_start_millis = fragment_start_millis;
}
public String getFragment_end_millis() {
return fragment_end_millis;
}
public void setFragment_end_millis(String fragment_end_millis) {
this.fragment_end_millis = fragment_end_millis;
}
public String getFragment_duration() {
return getFragment_end() - getFragment_start() + "";
}
public void setFragment_duration(String fragment_duration) {
String fragment_duration1 = fragment_duration;
}
public String getVersion() {
return version;
}
public void setVersion(String version) {
this.version = version;
}
public String getFragments() {
return fragments;
}
public void setFragments(String fragments) {
this.fragments = fragments;
}
public String getAppkey() {
return appkey;
}
public void setAppkey(String appkey) {
this.appkey = appkey;
}
public long getFragment_start() {
return fragment_start;
}
public void setFragment_start(long fragment_start) {
this.fragment_start = fragment_start;
}
public long getFragment_end() {
return fragment_end;
}
public void setFragment_end(long fragment_end) {
this.fragment_end = fragment_end;
}
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
// public String getClientdata_id() {
// return clientdata_id;
// }
//
// public void setClientdata_id(String clientdata_id) {
// this.clientdata_id = clientdata_id;
// }
public String getActivity() {
return activity;
}
public void setActivity(String activity) {
this.activity = activity;
}
public String getDevice_id() {
return device_id;
}
public void setDevice_id(String device_id) {
this.device_id = device_id;
}
}
package com.oo.seex.oo_statistics_lib.bean;
/**
* Created by efort on 15/8/24.
*/
public class InitInfo {
String app_key;
String time;
String resolution;
String device_id;
String devicename;
String imei;
String idfa;
String imsi;
String defaultbrowser;
String havebt;
String havegps;
String havegravity;
String channel;
private String udid;
@Override
public String toString() {
return "InitInfo{" +
"app_key='" + app_key + '\'' +
", time='" + time + '\'' +
", resolution='" + resolution + '\'' +
", device_id='" + device_id + '\'' +
", devicename='" + devicename + '\'' +
", imei='" + imei + '\'' +
", idfa='" + idfa + '\'' +
", imsi='" + imsi + '\'' +
", defaultbrowser='" + defaultbrowser + '\'' +
", havebt='" + havebt + '\'' +
", havegps='" + havegps + '\'' +
", havegravity='" + havegravity + '\'' +
", channel='" + channel + '\'' +
'}';
}
public String getApp_key() {
return app_key;
}
public void setApp_key(String app_key) {
this.app_key = app_key;
}
public String getTime() {
return time;
}
public void setTime(String time) {
this.time = time;
}
public String getResolution() {
return resolution;
}
public void setResolution(String resolution) {
this.resolution = resolution;
}
public String getDevice_id() {
return device_id;
}
public void setDevice_id(String device_id) {
this.device_id = device_id;
}
public String getDevicename() {
return devicename;
}
public void setDevicename(String devicename) {
this.devicename = devicename;
}
public String getImei() {
return imei;
}
public void setImei(String imei) {
this.imei = imei;
}
public String getIdfa() {
return idfa;
}
public void setIdfa(String idfa) {
this.idfa = idfa;
}
public String getImsi() {
return imsi;
}
public void setImsi(String imsi) {
this.imsi = imsi;
}
public String getDefaultbrowser() {
return defaultbrowser;
}
public void setDefaultbrowser(String defaultbrowser) {
this.defaultbrowser = defaultbrowser;
}
public String getHavebt() {
return havebt;
}
public void setHavebt(String havebt) {
this.havebt = havebt;
}
public String getHavegps() {
return havegps;
}
public void setHavegps(String havegps) {
this.havegps = havegps;
}
public String getHavegravity() {
return havegravity;
}
public void setHavegravity(String havegravity) {
this.havegravity = havegravity;
}
public String getChannel() {
return channel;
}
public void setChannel(String channel) {
this.channel = channel;
}
public String getUdid() {
return udid;
}
public void setUdid(String udid) {
this.udid = udid;
}
}
/**
* Cobub Razor
* <p>
* An open source analytics android sdk for mobile applications
*
* @package Cobub Razor
* @author WBTECH Dev Team
* @copyright Copyright (c) 2011 - 2012, NanJing Western Bridge Co.,Ltd.
* @license http://www.cobub.com/products/cobub-razor/license
* @link http://www.cobub.com/products/cobub-razor/
* @filesource
* @since Version 0.1
*/
package com.oo.seex.oo_statistics_lib.bean;
/**
* 访问网络后返回数据的解析类 这里会根据需求去更改;
*/
public class MyMessage {
private boolean flag;
private String msg;
public boolean isFlag() {
return flag;
}
public void setFlag(boolean flag) {
this.flag = flag;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
}
package com.oo.seex.oo_statistics_lib.bean;
import com.oo.seex.oo_statistics_lib.utils.xutils_dbutils.db.annotation.Id;
/**
* Created by efort on 15/7/31.
*/
public class PostClientBean {
/**
* 用户私人信息
*/
@Id
private int id;
/**
* appkey
* secrect_key
* time
* appversion 1.2.1 app的版本号
* platform android 平台
* os Flyme 操作系统
* os_version 2.3.1 操作系统版本
* language ch_zh 手机语言
* javasupport 1/0 是否支持java
* flashversion 13.2.1 flash版本
* wifimac 02:00:00:00 wifi的mac地址
* network wifi/3g/EVDO 联网方式
* laititude 23.23 东经
* longtitude 23.23 东经
* clientip 198.23.22.1 ip地址
* service_supplier china unicom 运营商
* country 中国 国家
* provence 安徽 省份
* city 合肥 城市
* isjailbroken 1/0 是否越狱
* device_id 设备号
* userId 用户Id
* resolution
* devicename
* imei
* idfa
* havebt
* havegps
* havegravity
* channel
*/
private String appkey;
private String device_id;
private String userId;
private String udid;
private String time;
private String appversion;
private String platform = "android";
private String os;
private String os_version;
private String language = "zh";
private String javasupport = "1";
private String wifimac;
private String network;
private String laititude;
private String longtitude;
private String clientip;
private String service_supplier;
private String provence;
private String city;
private String country;
private String address;
private String isjailbroken = "0";
private String resolution;
private String devicename;
private String imei;
private String idfa;
private String havebt;
private String havegps;
private String havegravity;
private long clientData;
public String getChannel() {
return channel;
}
public void setChannel(String channel) {
this.channel = channel;
}
public String getHavegravity() {
return havegravity;
}
public void setHavegravity(String havegravity) {
this.havegravity = havegravity;
}
public String getHavegps() {
return havegps;
}
public void setHavegps(String havegps) {
this.havegps = havegps;
}
public String getHavebt() {
return havebt;
}
public void setHavebt(String havebt) {
this.havebt = havebt;
}
public String getIdfa() {
return idfa;
}
public void setIdfa(String idfa) {
this.idfa = idfa;
}
public String getImei() {
return imei;
}
public void setImei(String imei) {
this.imei = imei;
}
public String getDevicename() {
return devicename;
}
public void setDevicename(String devicename) {
this.devicename = devicename;
}
public String getResolution() {
return resolution;
}
public void setResolution(String resolution) {
this.resolution = resolution;
}
private String channel;
@Override
public String toString() {
return "PostClientBean{" +
"longtitude='" + longtitude + '\'' +
", laititude='" + laititude + '\'' +
", device_id='" + device_id + '\'' +
", userId='" + userId + '\'' +
", clientip='" + clientip + '\'' +
", os_version='" + os_version + '\'' +
", os='" + os + '\'' +
", appversion='" + appversion + '\'' +
'}';
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getAppkey() {
return appkey;
}
public void setAppkey(String appkey) {
this.appkey = appkey;
}
public String getTime() {
return time;
}
public void setTime(String time) {
this.time = time;
}
public String getAppversion() {
return appversion;
}
public void setAppversion(String appversion) {
this.appversion = appversion;
}
public String getPlatform() {
return platform;
}
public void setPlatform(String platform) {
this.platform = platform;
}
public String getOs() {
return os;
}
public void setOs(String os) {
this.os = os;
}
public String getOs_version() {
return os_version;
}
public void setOs_version(String os_version) {
this.os_version = os_version;
}
public String getLanguage() {
return language;
}
public void setLanguage(String language) {
this.language = language;
}
public String getJavasupport() {
return javasupport;
}
public void setJavasupport(String javasupport) {
this.javasupport = javasupport;
}
public String getWifimac() {
return wifimac;
}
public void setWifimac(String wifimac) {
this.wifimac = wifimac;
}
public String getNetwork() {
return network;
}
public void setNetwork(String network) {
this.network = network;
}
public String getLaititude() {
return laititude;
}
public void setLaititude(String laititude) {
this.laititude = laititude;
}
public String getLongtitude() {
return longtitude;
}
public void setLongtitude(String longtitude) {
this.longtitude = longtitude;
}
public String getClientip() {
return clientip;
}
public void setClientip(String clientip) {
this.clientip = clientip;
}
public String getService_supplier() {
return service_supplier;
}
public void setService_supplier(String service_supplier) {
this.service_supplier = service_supplier;
}
public String getProvence() {
return provence;
}
public void setProvence(String provence) {
this.provence = provence;
}
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
public String getIsjailbroken() {
return isjailbroken;
}
public void setIsjailbroken(String isjailbroken) {
this.isjailbroken = isjailbroken;
}
public String getDevice_id() {
return device_id;
}
public void setDevice_id(String device_id) {
this.device_id = device_id;
}
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public String getUdid() {
return udid;
}
public void setUdid(String udid) {
this.udid = udid;
}
public String getCountry() {
return country;
}
public void setCountry(String country) {
this.country = country;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public void setClientData(long clientData) {
this.clientData = clientData;
}
public long getClientData() {
return clientData;
}
}
package com.oo.seex.oo_statistics_lib.bean;
/**
* Created by efort on 15/7/31.
*/
public class StatistivsBean {
private String appkey;
private String type;
private ActivityStaBean activityInfo;
private FragmentBean fragmentInfo;
private PostClientBean clientData;
private EventStaBean eventInfo;
private ErrorStaBean errorInfo;
@Override
public String toString() {
return "StatistivsBean{" +
"appkey='" + appkey + '\'' +
", type='" + type + '\'' +
", activityInfo=" + activityInfo +
", fragmentInfo=" + fragmentInfo +
", clientData=" + clientData +
", eventInfo=" + eventInfo +
", errorInfo=" + errorInfo +
'}';
}
public String getAppkey() {
return appkey;
}
public void setAppkey(String appkey) {
this.appkey = appkey;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public ActivityStaBean getActivityInfo() {
return activityInfo;
}
public void setActivityInfo(ActivityStaBean activityInfo) {
this.activityInfo = activityInfo;
}
public FragmentBean getFragmentInfo() {
return fragmentInfo;
}
public void setFragmentInfo(FragmentBean fragmentInfo) {
this.fragmentInfo = fragmentInfo;
}
public PostClientBean getClientData() {
return clientData;
}
public void setClientData(PostClientBean clientData) {
this.clientData = clientData;
}
public EventStaBean getEventInfo() {
return eventInfo;
}
public void setEventInfo(EventStaBean eventInfo) {
this.eventInfo = eventInfo;
}
public ErrorStaBean getErrorInfo() {
return errorInfo;
}
public void setErrorInfo(ErrorStaBean errorInfo) {
this.errorInfo = errorInfo;
}
}
package com.oo.seex.oo_statistics_lib.constant;
/**
* Created by efort on 15/7/30.
* 存放常量的地方 这里又最常见的地址信息
*/
public class OOConstant {
//是否打印我们添加的日志信息 Log.e 的内容 文中很多地方用到,只要置于false 就不会打印出来
public static boolean DebugMode = false;
//等待时间 这个事件之内不会重复生成session_id
public static long kContinueSessionMillis = 30000L;
//表示两次发送统计数据之间的间隔 默认是5m
public static long IntervalMillis = 5000L;
// 最初的服务器地址ur
// public static String preUrl = "http://192.168.1.226:8005";
// http-url: public static String preUrl = "http://120.26.71.154:4180";
//https url:https://shtjsdk.zhongguowangshi.com
public static String preUrl = "";
// 首次注册
public static String initUrl = "/api/device/index";
//发送用户个人信息;只会再应用开启的时候发送一次
public static String clientDataUrl = "/api/data/index";
//activity 统计信息
public static String activityUrl = "/api/activitylog/index";
//Fragment 统计
public static String fragmentUrl = "/api/fragment/index";
//发送错误信息 log 日志的网址
public static String errorUrl = "/api/error/index";
// 标签
public static String tagUser = "/api/tag/index";
//发送消息的地址 (统计事件,自定义事件等)
public static String eventUrl = "/api/event/index";
// 发送离线缓存的统计信息
public static String uploadUrl = "/api/upload/index";
//
public static Object saveOnlineConfigMutex = new Object();
//在线配置
public static String onlineConfigUrl = "";
}
/**
* Cobub Razor
* <p>
* An open source analytics android sdk for mobile applications
*
* @package Cobub Razor
* @author WBTECH Dev Team
* @copyright Copyright (c) 2011 - 2012, NanJing Western Bridge Co.,Ltd.
* @license http://www.cobub.com/products/cobub-razor/license
* @link http://www.cobub.com/products/cobub-razor/
* @filesource
* @since Version 0.1
*/
package com.oo.seex.oo_statistics_lib.dao;
import android.content.Context;
import android.text.TextUtils;
import com.oo.seex.oo_statistics_lib.bean.StatistivsBean;
import com.oo.seex.oo_statistics_lib.utils.CommonUtil;
import com.oo.seex.oo_statistics_lib.utils.MyDbUtils;
import com.oo.seex.oo_statistics_lib.utils.xutils_dbutils.exception.DbException;
/**
* save data to xutils db
*
* @author duzhou.xu
*/
public class SaveInfo extends Thread {
public Context context;
public StatistivsBean object;
public SaveInfo(Context context, StatistivsBean object) {
super();
this.object = object;
this.context = context;
}
@Override
public void run() {
super.run();
if (object == null || TextUtils.isEmpty(object.getType())) {
return;
}
try {
switch (object.getType()) {
case "eventInfo":
if (object.getEventInfo() != null)
MyDbUtils.getInstance(context).saveStatistics(context, object.getEventInfo());
break;
case "activityInfo":
if (object.getActivityInfo() != null )
MyDbUtils.getInstance(context).saveStatistics(context, object.getActivityInfo());
break;
case "fragmentInfo":
if (object.getFragmentInfo() != null)
MyDbUtils.getInstance(context).saveStatistics(context, object.getFragmentInfo());
break;
case "clientData":
if (object.getClientData() != null )
MyDbUtils.getInstance(context).saveStatistics(context, object.getClientData());
break;
case "errorInfo":
if (object.getErrorInfo() != null )
MyDbUtils.getInstance(context).saveStatistics(context, object.getErrorInfo());
break;
}
} catch (DbException e) {
CommonUtil.printLog("OOAgent", "error_save_info");
CommonUtil.printLog(e);
}
}
}
/**
* Cobub Razor
* <p>
* An open source analytics android sdk for mobile applications
*
* @package Cobub Razor
* @author WBTECH Dev Team
* @copyright Copyright (c) 2011 - 2012, NanJing Western Bridge Co.,Ltd.
* @license http://www.cobub.com/products/cobub-razor/license
* @link http://www.cobub.com/products/cobub-razor/
* @filesource
* @since Version 0.1
*/
package com.oo.seex.oo_statistics_lib.dao;
import android.content.Context;
import com.oo.seex.oo_statistics_lib.bean.ActivityStaBean;
import com.oo.seex.oo_statistics_lib.bean.ErrorStaBean;
import com.oo.seex.oo_statistics_lib.bean.EventStaBean;
import com.oo.seex.oo_statistics_lib.bean.FragmentBean;
import com.oo.seex.oo_statistics_lib.constant.OOConstant;
import com.oo.seex.oo_statistics_lib.getjsonobject.GetJson;
import com.oo.seex.oo_statistics_lib.network.NetworkUitlity;
import com.oo.seex.oo_statistics_lib.utils.CommonUtil;
import com.oo.seex.oo_statistics_lib.utils.MyDbUtils;
import com.oo.seex.oo_statistics_lib.utils.xutils_dbutils.exception.DbException;
import java.util.HashMap;
import java.util.List;
import java.util.Timer;
import java.util.TimerTask;
/**
* 获取存储的信息并且发送到服务端 如果发送成功那么极度删除调本地存储
*/
public class UploadNativeData{
private static final String TAG = "UploadNativeData";
private static UploadNativeData instance = new UploadNativeData();
public Context context;
private Timer mTimer;
private UploadTimerTask mTimerTask;
private UploadNativeData() {
}
public static UploadNativeData getInstance(){
return instance;
}
public void synNativeData(Context context){
this.context = context;
close();
try {
if (mTimer == null) {
mTimer = new Timer();
}
if (mTimerTask == null) {
mTimerTask = new UploadTimerTask();
}
mTimer.schedule(mTimerTask, 0, 10 * 60 * 1000);
}catch (Exception e){
e.printStackTrace();
}
}
private void close(){
try {
if (mTimer != null) {
mTimer.purge();
mTimer.cancel();
mTimer = null;
}
if(mTimerTask != null){
mTimerTask.cancel();
mTimerTask = null;
}
}catch (Exception e){
e.printStackTrace();
}
}
private class UploadTimerTask extends TimerTask {
@Override
public void run() {
try {
if (CommonUtil.isNetworkAvailable(context)) {
//activity data
List<ActivityStaBean> activityInfo = MyDbUtils.getInstance(context).getActivityStatistics();
if (activityInfo != null && activityInfo.size() > 0) {
CommonUtil.printLog(TAG,"activity:"+activityInfo.size());
for (int i = 0; i < activityInfo.size(); i++) {
final ActivityStaBean bean = activityInfo.get(i);
HashMap<String, String> info = GetJson.getActivityParams(bean);
if (info != null) {
NetworkUitlity.getInstance().requestPost(OOConstant.preUrl + OOConstant.activityUrl, info, context,
new NetworkUitlity.NetListener() {
@Override
public void succee() {
MyDbUtils.getInstance(context).deletActivitySta(bean);
}
@Override
public void error() {
}
});
}
}
}
//errorInfo
List<ErrorStaBean> errors = MyDbUtils.getInstance(context).getErrorStatistics();
if (errors != null && errors.size() > 0) {
CommonUtil.printLog(TAG,"error:"+errors.size());
for (int i = 0; i < errors.size(); i++) {
final ErrorStaBean bean = errors.get(i);
HashMap<String, String> info = GetJson.getErrorInfoParams(bean);
if (info != null) {
NetworkUitlity.getInstance().requestPost(OOConstant.preUrl + OOConstant.errorUrl, info, context,
new NetworkUitlity.NetListener() {
@Override
public void succee() {
MyDbUtils.getInstance(context).deletErrorSta(bean);
}
@Override
public void error() {
}
});
}
}
}
//event
List<EventStaBean> events = MyDbUtils.getInstance(context).getEventStatistics();
if (events != null && events.size() > 0) {
CommonUtil.printLog(TAG,"event:"+events.size());
for (int i = 0; i < events.size(); i++) {
final EventStaBean bean = events.get(i);
HashMap infoParams = GetJson.getEventParams(bean);
if (infoParams != null) {
NetworkUitlity.getInstance().requestPost(OOConstant.preUrl + OOConstant.eventUrl, infoParams, context,
new NetworkUitlity.NetListener() {
@Override
public void succee() {
MyDbUtils.getInstance(context).deletEventSta(bean);
}
@Override
public void error() {
}
});
}
}
}
//fragment data
List<FragmentBean> fragmentBeans = MyDbUtils.getInstance(context).getFragmentStatistics();
if (fragmentBeans != null && fragmentBeans.size() > 0) {
CommonUtil.printLog(TAG,"fragment:"+fragmentBeans.size());
for (int i = 0; i < fragmentBeans.size(); i++) {
final FragmentBean fragmentBean = fragmentBeans.get(i);
HashMap<String, String> infoParams = GetJson.getFragmentParams(fragmentBean);
if (infoParams != null) {
NetworkUitlity.getInstance().requestPost(OOConstant.preUrl + OOConstant.fragmentUrl,
infoParams, context,
new NetworkUitlity.NetListener() {
@Override
public void succee() {
MyDbUtils.getInstance(context).deletFragmentSta(fragmentBean);
}
@Override
public void error() {
}
});//访问网络
}
}
}
}
} catch (DbException e) {
CommonUtil.printLog("OOAgent", "get Cache For ShiNcDb error");
CommonUtil.printLog(e);
}
}
}
}
package com.oo.seex.oo_statistics_lib.network;
import android.content.Context;
import android.os.Handler;
import com.oo.seex.oo_statistics_lib.bean.EventStaBean;
import com.oo.seex.oo_statistics_lib.bean.StatistivsBean;
import com.oo.seex.oo_statistics_lib.constant.OOConstant;
import com.oo.seex.oo_statistics_lib.getjsonobject.GetJson;
import com.oo.seex.oo_statistics_lib.utils.CommonUtil;
/**
* 自定义统计事件的控制器
*/
public class EventController {
// static final String EVENTURL =ShiNcConstant.eventUrl;
/**
* 将自定义统计事件发送出去
*
* @param handler
* @param context
* @param event
* @return
*/
public static boolean postEventInfo(final Handler handler, final Context context, EventStaBean event) {
try {
if (!event.verification()) {
CommonUtil.printLog("OOAgent", "Illegal value of acc in postEventInfo");
return false;
}
final StatistivsBean statistivsBean = new StatistivsBean();
statistivsBean.setEventInfo(event);
if (CommonUtil.isNetworkAvailable(context)) {
NetworkUitlity.getInstance().requestPost(OOConstant.preUrl + OOConstant.eventUrl, GetJson.getEventParams(event), context,
new NetworkUitlity.NetListener() {
@Override
public void succee() {}
@Override
public void error() {
if(handler != null) {
CommonUtil.saveInfoToFile(handler, "eventInfo", statistivsBean, context);
}
}
});
} else {
if(handler != null) {
CommonUtil.saveInfoToFile(handler, "eventInfo", statistivsBean, context);
}
}
} catch (Exception e) {
CommonUtil.printLog("OOAgent_error", "Exception occurred in postEventInfo()");
CommonUtil.printLog(e);
return false;
}
return true;
}
}
package com.oo.seex.oo_statistics_lib.utils;
import android.os.Environment;
import android.os.StatFs;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
/**
* Created by xucon on 2017/11/3.
*/
public class FileUtil {
private static String CACHE_PATH = "/.daemon";
private static String CACHE_USER_FILE = "config_user.txt";
private static String CACHE_OS_FILE = "config_os.txt";
private static String CACHE_SOFT_FILE = "config_soft.txt";
/**
* 保存用户id
* @param userId
* @return
*/
public static boolean saveUserIdToFile(String userId) {
if (!Environment.getExternalStorageState().equals("mounted")) {
return false;
} else {
try {
File e = Environment.getExternalStorageDirectory();
File dir = new File(e.getAbsolutePath() + CACHE_PATH);
if (!dir.exists()) {
boolean file = dir.mkdir();
if (!file) {
return false;
}
}
File file1 = new File(dir, CACHE_USER_FILE);
FileOutputStream fos = new FileOutputStream(file1);
fos.write(userId.getBytes());
fos.close();
return true;
} catch (Exception var10) {
var10.printStackTrace();
return false;
}
}
}
/**
* 获取用户id
* @return
*/
public static String getUserIdToFile() {
if (!Environment.getExternalStorageState().equals("mounted")) {
return "";
}
File file = new File(Environment.getExternalStorageDirectory(),
CACHE_PATH+File.separator+CACHE_USER_FILE);
if(file == null || !file.exists()){
return "";
}
FileInputStream e = null;
BufferedReader br = null;
try {
e = new FileInputStream(file);
br = new BufferedReader(new InputStreamReader(e));
return br.readLine();
} catch (Exception var8) {
var8.printStackTrace();
}finally {
try {
if (br != null) {
br.close();
}
}catch (Exception ex){
ex.printStackTrace();
}
}
return "";
}
/**
* 保存soft
* @param soft
* @return
*/
public static boolean saveSoftToFile(String soft) {
if (!Environment.getExternalStorageState().equals("mounted")) {
return false;
} else {
try {
File e = Environment.getExternalStorageDirectory();
File dir = new File(e.getAbsolutePath() + CACHE_PATH);
if (!dir.exists()) {
boolean file = dir.mkdir();
if (!file) {
return false;
}
}
File file1 = new File(dir, CACHE_SOFT_FILE);
FileOutputStream fos = new FileOutputStream(file1);
fos.write(soft.getBytes());
fos.close();
return true;
} catch (Exception var10) {
var10.printStackTrace();
return false;
}
}
}
/**
* 获取soft
* @return
*/
public static String getSoftToFile() {
if (!Environment.getExternalStorageState().equals("mounted")) {
return "";
}
File file = new File(Environment.getExternalStorageDirectory(),
CACHE_PATH+File.separator+CACHE_SOFT_FILE);
if(file == null || !file.exists()){
return "";
}
FileInputStream e = null;
BufferedReader br = null;
try {
e = new FileInputStream(file);
br = new BufferedReader(new InputStreamReader(e));
return br.readLine();
} catch (Exception var8) {
var8.printStackTrace();
}finally {
try {
if (br != null) {
br.close();
}
}catch (Exception ex){
ex.printStackTrace();
}
}
return "";
}
/**
* 获取OS版本
* @return
*/
public static String getOSToFile() {
if (!Environment.getExternalStorageState().equals("mounted")) {
return "";
}
File file = new File(Environment.getExternalStorageDirectory(),
CACHE_PATH+File.separator+CACHE_OS_FILE);
if(file == null || !file.exists()){
return "";
}
FileInputStream e = null;
BufferedReader br = null;
try {
e = new FileInputStream(file);
br = new BufferedReader(new InputStreamReader(e));
return br.readLine();
} catch (Exception var8) {
var8.printStackTrace();
}finally {
try {
if (br != null) {
br.close();
}
}catch (Exception ex){
ex.printStackTrace();
}
}
return "";
}
/**
* 保存OS版本
* @param OSVersion
* @return
*/
public static boolean saveOSToFile(String OSVersion) {
if (!Environment.getExternalStorageState().equals("mounted")) {
return false;
} else {
try {
File e = Environment.getExternalStorageDirectory();
File dir = new File(e.getAbsolutePath() + CACHE_PATH);
if (!dir.exists()) {
boolean file = dir.mkdir();
if (!file) {
return false;
}
}
File file1 = new File(dir, CACHE_OS_FILE);
FileOutputStream fos = new FileOutputStream(file1);
fos.write(OSVersion.getBytes());
fos.close();
return true;
} catch (Exception var10) {
var10.printStackTrace();
return false;
}
}
}
/**
* 检查磁盘空间是否大于10mb
*
* @return true 大于
*/
public static boolean isDiskAvailable() {
long size = getDiskAvailableSize();
return size > 10 * 1024 * 1024; // > 10bm
}
/**
* 获取磁盘可用空间
*
* @return byte 单位 kb
*/
public static long getDiskAvailableSize() {
if (!existsSdcard()) return 0;
File path = Environment.getExternalStorageDirectory(); // 取得sdcard文件路径
StatFs stat = new StatFs(path.getAbsolutePath());
long blockSize = stat.getBlockSize();
long availableBlocks = stat.getAvailableBlocks();
return availableBlocks * blockSize;
// (availableBlocks * blockSize)/1024 KIB 单位
// (availableBlocks * blockSize)/1024 /1024 MIB单位
}
public static Boolean existsSdcard() {
return Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED);
}
}
package com.oo.seex.oo_statistics_lib.utils;
import android.content.Context;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.location.LocationProvider;
import android.os.Bundle;
import android.os.Looper;
import android.text.TextUtils;
/**
* Created by efort on 15/11/11.
*/
public class LocationUtils {
private static String latitude = "";
private static String longitude = "";
static LocationListener locationListener;
private static boolean isRemove = false;//判断网络监听是否移除
public static void getLocat(final Context context,final LocationManager locationManager, final MyLocationListener listener) {
try {
locationListener = new LocationListener() {
// Provider的状态在可用、暂时不可用和无服务三个状态直接切换时触发此函数
@Override
public void onStatusChanged(String provider, int status, Bundle extras) {
if (LocationProvider.OUT_OF_SERVICE == status) {
CommonUtil.printLog("", "网络定位服务无法使用,切换至Gps定位");
}
}
// Provider被enable时触发此函数,比如GPS被打开
@Override
public void onProviderEnabled(String provider) {
}
// Provider被disable时触发此函数,比如GPS被关闭
@Override
public void onProviderDisabled(String provider) {
}
//当坐标改变时触发此函数,如果Provider传进相同的坐标,它就不会被触发
@Override
public void onLocationChanged(Location location) {
try {
if (location != null) {
latitude = location.getLatitude() + ""; //经度
longitude = location.getLongitude() + ""; //纬度
CommonUtil.printLog("location:" + latitude, longitude);
if (!TextUtils.isEmpty(latitude) && !TextUtils.isEmpty(longitude)) {
listener.locat(location);
}
}
// 获得GPS服务后,移除network监听
if (location != null && !isRemove) {
locationManager.removeUpdates(locationListener);
isRemove = true;
}
}catch (Exception e){
CommonUtil.printLog(e);
}
}
};
boolean isGpsAvalible = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
boolean isNetAvalible = locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
if (isGpsAvalible) {
Looper.prepare();
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000, 1, locationListener);
Looper.loop();
Location locate = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
if (locate != null) {
latitude = locate.getLatitude() + "";
longitude = locate.getLongitude() + "";
if (!TextUtils.isEmpty(latitude) && !TextUtils.isEmpty(longitude)) {
listener.locat(locate);
CommonUtil.printLog("location", latitude + "--" + longitude);
return;
}
}
} else if (isNetAvalible && CommonUtil.isNetworkAvailable(context)) {
Looper.prepare();
locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 1000, 1, locationListener, Looper.myLooper());
Looper.loop();
Location locate = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
if (locate != null) {
latitude = locate.getLatitude() + "";
longitude = locate.getLongitude() + "";
if (!TextUtils.isEmpty(latitude) && !TextUtils.isEmpty(longitude)) {
listener.locat(locate);
CommonUtil.printLog("location", latitude + "--" + longitude);
return;
}
}
}
}catch (Exception e){
CommonUtil.printLog(e);
}
}
public interface MyLocationListener {
void locat(Location location);
}
}
/**
* Cobub Razor
* <p>
* An open source analytics android sdk for mobile applications
*
* @package Cobub Razor
* @author WBTECH Dev Team
* @copyright Copyright (c) 2011 - 2012, NanJing Western Bridge Co.,Ltd.
* @license http://www.cobub.com/products/cobub-razor/license
* @link http://www.cobub.com/products/cobub-razor/
* @filesource
* @since Version 0.1
*/
package com.oo.seex.oo_statistics_lib.utils;
import android.content.Context;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
public class MD5Utility {
/**
* 特有防伪标示符
*
* @param time
* @param context
* @return
*/
public static String getSecrect_key(String time, Context context) {
return md5Appkey(CommonUtil.getAppKey(context) + time);
// return "08f93cc52fafd6d49aa450acf577375a";
// + CommonUtil.getMasterKey(context)
}
/**
* 对字符串进行加密
*
* @param str
* @return
*/
public static String md5Appkey(String str) {
/*str To encrypt a string
* parmboolean string's length,true false
* **/
try {
MessageDigest localMessageDigest = MessageDigest.getInstance("MD5");
localMessageDigest.update(str.getBytes());
byte[] arrayOfByte = localMessageDigest.digest();
StringBuffer localStringBuffer = new StringBuffer();
for (int i = 0; i < arrayOfByte.length; i++) {
if (Integer.toHexString(0xFF & arrayOfByte[i]).length() == 1)
localStringBuffer.append("0").append(Integer.toHexString(0xFF & arrayOfByte[i]));
else
localStringBuffer.append(Integer.toHexString(0xFF & arrayOfByte[i]));
}
return localStringBuffer.toString();
} catch (NoSuchAlgorithmException localNoSuchAlgorithmException) {
CommonUtil.printLog("MD5Utility", "getMD5 error");
CommonUtil.printLog(localNoSuchAlgorithmException);
}
return "";
}
}
/**
* Cobub Razor
* <p>
* An open source analytics android sdk for mobile applications
*
* @package Cobub Razor
* @author WBTECH Dev Team
* @copyright Copyright (c) 2011 - 2012, NanJing Western Bridge Co.,Ltd.
* @license http://www.cobub.com/products/cobub-razor/license
* @link http://www.cobub.com/products/cobub-razor/
* @filesource
* @since Version 0.1
*/
package com.oo.seex.oo_statistics_lib.utils;
import android.content.Context;
import android.os.Handler;
import android.os.Looper;
import com.oo.seex.oo_statistics_lib.bean.ErrorStaBean;
import com.oo.seex.oo_statistics_lib.bean.StatistivsBean;
import com.oo.seex.oo_statistics_lib.constant.OOConstant;
import com.oo.seex.oo_statistics_lib.getjsonobject.GetJson;
import com.oo.seex.oo_statistics_lib.network.NetworkUitlity;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.io.Writer;
import java.lang.Thread.UncaughtExceptionHandler;
/**
* 抓取异常并且发送到服务器的操作;在接受到hanler的消息后开始运行
*/
public class MyCrashHandler implements UncaughtExceptionHandler {
private static MyCrashHandler myCrashHandler;
private Context context;
private String stacktrace;
private String activities;
private long time;
private String appkey;
private String os_version;
public Handler handler = null;
private MyCrashHandler() {
}
public static synchronized MyCrashHandler getInstance() {
if (myCrashHandler != null) {
return myCrashHandler;
} else {
myCrashHandler = new MyCrashHandler();
return myCrashHandler;
}
}
public void init(Context context, Handler handler) {
this.context = context;
this.handler = handler;
}
/**
* 发送错误信息到服务器 实时
*
* @param thread
* @param arg1
*/
@Override
public void uncaughtException(Thread thread, final Throwable arg1) {
arg1.printStackTrace();
new Thread() {
@Override
public void run() {
super.run();
try {
Looper.prepare();
String errorinfo = getErrorInfo(arg1);
String[] ss = errorinfo.split("\n\t");
String headstring = ss[0] + "\n\t" + ss[1] + "\n\t" + ss[2];
if (headstring.length() > 255) {
headstring = headstring.substring(0, 255) + "\n\t";
} else {
headstring = headstring + "\n\t";
}
String newErrorInfoString = headstring + errorinfo;
stacktrace = newErrorInfoString;
activities = CommonUtil.getActivityName(context);
time = CommonUtil.getTime();
appkey = CommonUtil.getAppKey(context);
os_version = CommonUtil.getOSVersion(context);
ErrorStaBean errorInfo = getErrorData(context);
final StatistivsBean statistivsBean = new StatistivsBean();
statistivsBean.setErrorInfo(errorInfo);
if (CommonUtil.isNetworkAvailable(context)) {
if (!stacktrace.equals("")) {
NetworkUitlity.getInstance().requestPost(OOConstant.preUrl + OOConstant.errorUrl,
GetJson.getErrorInfoParams(errorInfo), context, new NetworkUitlity.NetListener() {
@Override
public void succee() {
}
@Override
public void error() {
if (handler != null) {
CommonUtil.saveInfoToFile(handler, "errorInfo", statistivsBean, context);
}
}
});
}
} else {
if (handler != null) {
CommonUtil.saveInfoToFile(handler, "errorInfo", statistivsBean, context);
}
}
android.os.Process.killProcess(android.os.Process.myPid());
Looper.loop();
} catch (Exception e) {
CommonUtil.printLog(e);
}
}
}.start();
}
/**
* 组拼成JsonObject对象
*
* @param context
* @return
*/
private ErrorStaBean getErrorData(Context context) {
ErrorStaBean errorStaBean = new ErrorStaBean();
errorStaBean.setStacktrace(stacktrace);
errorStaBean.setTime(String.valueOf(time));
errorStaBean.setActivity(activities);
errorStaBean.setAppkey(appkey);
errorStaBean.setChannel(CommonUtil.getChannel(context));
errorStaBean.setVersion(CommonUtil.getVersion(context));
errorStaBean.setOs_version(os_version);
errorStaBean.setUserId(CommonUtil.getUserIdentifier(context));
errorStaBean.setDevice_id(CommonUtil.getDeviceID(context));
return errorStaBean;
}
/**
* 获取错误日志信息
*
* @param arg1
* @return
*/
private String getErrorInfo(Throwable arg1) {
Writer writer = new StringWriter();
PrintWriter pw = new PrintWriter(writer);
arg1.printStackTrace(pw);
pw.close();
String error = writer.toString();
return error;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment