From 9ec3be18580f7c2f4ee58e63753deb813532ddb0 Mon Sep 17 00:00:00 2001 From: yy1717 <fctom1215@outlook.com> Date: 星期一, 13 一月 2020 14:18:55 +0800 Subject: [PATCH] Merge branch 'master' of https://gitee.com/endian11/DriveJudge --- app/src/main/java/safeluck/drive/evaluation/Constant.java | 1 app/src/main/java/safeluck/drive/evaluation/adapter/GpsInfoAdapter.java | 83 +++++++++ app/src/main/java/safeluck/drive/evaluation/DB/gps/GpsInfoViewModel.java | 32 +++ app/src/main/java/safeluck/drive/evaluation/DB/gps/GPSInfo.java | 101 +++++++++++ app/src/main/res/layout/layout_home_fragment.xml | 1 app/src/main/java/safeluck/drive/evaluation/DB/gps/GpsInfoWorker.java | 55 ++++++ app/src/main/res/layout/layout_rtk_setting.xml | 5 app/src/main/res/layout/layout_gps_info.xml | 9 + app/src/main/java/safeluck/drive/evaluation/app.java | 30 ++ app/src/main/java/safeluck/drive/evaluation/util/FileUtil.java | 49 +++++ app/src/main/java/safeluck/drive/evaluation/DB/WorkRoomDataBase.java | 6 app/src/main/java/safeluck/drive/evaluation/DB/gps/GpsInfoRepository.java | 37 ++++ app/src/main/java/safeluck/drive/evaluation/fragment/GpsInfoFragment.java | 67 +++++- app/src/main/java/safeluck/drive/evaluation/fragment/TcpFragment.java | 10 app/src/main/java/safeluck/drive/evaluation/DB/gps/GpsInfoDao.java | 24 ++ app/src/main/res/layout/gps_info_item.xml | 10 + 16 files changed, 496 insertions(+), 24 deletions(-) diff --git a/app/src/main/java/safeluck/drive/evaluation/Constant.java b/app/src/main/java/safeluck/drive/evaluation/Constant.java index ac559cd..ecfbc8c 100644 --- a/app/src/main/java/safeluck/drive/evaluation/Constant.java +++ b/app/src/main/java/safeluck/drive/evaluation/Constant.java @@ -55,4 +55,5 @@ public static final String BIND_RTKCONFIG_TOPIC = "rtkconfig_topic"; public static final String BIND_CONNECT_RTK_TOPIC = "rtk_connect_login_topic"; + public static final String GPS_INFO_DATA = "gps_info_data"; } diff --git a/app/src/main/java/safeluck/drive/evaluation/DB/WorkRoomDataBase.java b/app/src/main/java/safeluck/drive/evaluation/DB/WorkRoomDataBase.java index d4d21a4..ecd4ee3 100644 --- a/app/src/main/java/safeluck/drive/evaluation/DB/WorkRoomDataBase.java +++ b/app/src/main/java/safeluck/drive/evaluation/DB/WorkRoomDataBase.java @@ -24,6 +24,8 @@ import safeluck.drive.evaluation.DB.failitems.FailProjDao; import safeluck.drive.evaluation.DB.failitems.FailedProj; import safeluck.drive.evaluation.DB.failitems.FailedProjWorker; +import safeluck.drive.evaluation.DB.gps.GPSInfo; +import safeluck.drive.evaluation.DB.gps.GpsInfoDao; import safeluck.drive.evaluation.DB.rtktb.RTKConfig; import safeluck.drive.evaluation.DB.rtktb.RTKConfigDao; import safeluck.drive.evaluation.DB.rtktb.RTKConfigWork; @@ -35,7 +37,7 @@ * 閭锛�632393724@qq.com * All Rights Saved! Chongqing AnYun Tech co. LTD */ -@Database(entities = {Student.class, CriteriaForI.class, FailedProj.class, CriteriaForII.class, RTKConfig.class},version = 1,exportSchema = false) +@Database(entities = {Student.class, CriteriaForI.class, FailedProj.class, CriteriaForII.class, RTKConfig.class, GPSInfo.class},version = 1,exportSchema = false) public abstract class WorkRoomDataBase extends RoomDatabase { private static final String TAG = "WorkRoomDataBase"; public abstract StudentDao getstudentDao(); @@ -99,4 +101,6 @@ public abstract RTKConfigDao getRTKConfigDao(); + + public abstract GpsInfoDao getGpsInoDao(); } diff --git a/app/src/main/java/safeluck/drive/evaluation/DB/gps/GPSInfo.java b/app/src/main/java/safeluck/drive/evaluation/DB/gps/GPSInfo.java new file mode 100644 index 0000000..8e9ad24 --- /dev/null +++ b/app/src/main/java/safeluck/drive/evaluation/DB/gps/GPSInfo.java @@ -0,0 +1,101 @@ +package safeluck.drive.evaluation.DB.gps; + +import androidx.room.Entity; +import androidx.room.PrimaryKey; + +/** + * MyApplication2 + * Created by lzw on 2020/1/10. 16:39:18 + * 閭锛�632393724@qq.com + * All Rights Saved! Chongqing AnYun Tech co. LTD + */ +@Entity(tableName = "gps_info") +public class GPSInfo { +@PrimaryKey + private int id; + private String utc; + private int sat_num; + private int qf; + private double latitude; + private double longitude; + private double altitude; + private double speed; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getUtc() { + return utc; + } + + public void setUtc(String utc) { + this.utc = utc; + } + + public int getSat_num() { + return sat_num; + } + + public void setSat_num(int sat_num) { + this.sat_num = sat_num; + } + + public int getQf() { + return qf; + } + + public void setQf(int qf) { + this.qf = qf; + } + + public double getLatitude() { + return latitude; + } + + public void setLatitude(double latitude) { + this.latitude = latitude; + } + + public double getLongitude() { + return longitude; + } + + public void setLongitude(double longitude) { + this.longitude = longitude; + } + + public double getAltitude() { + return altitude; + } + + public void setAltitude(double altitude) { + this.altitude = altitude; + } + + public double getSpeed() { + return speed; + } + + public void setSpeed(double speed) { + this.speed = speed; + } + + @Override + public String toString() { + return "GPSInfo{" + + "id=" + id + + ", utc='" + utc + '\'' + + ", sat_num=" + sat_num + + ", qf=" + qf + + ", latitude=" + latitude + + ", longitude=" + longitude + + ", altitude=" + altitude + + ", speed=" + speed + + '}'; + } +} diff --git a/app/src/main/java/safeluck/drive/evaluation/DB/gps/GpsInfoDao.java b/app/src/main/java/safeluck/drive/evaluation/DB/gps/GpsInfoDao.java new file mode 100644 index 0000000..9c4d42e --- /dev/null +++ b/app/src/main/java/safeluck/drive/evaluation/DB/gps/GpsInfoDao.java @@ -0,0 +1,24 @@ +package safeluck.drive.evaluation.DB.gps; + +import androidx.lifecycle.LiveData; +import androidx.room.Dao; +import androidx.room.Insert; +import androidx.room.OnConflictStrategy; +import androidx.room.Query; + + +/** + * MyApplication2 + * Created by lzw on 2020/1/10. 16:44:57 + * 閭锛�632393724@qq.com + * All Rights Saved! Chongqing AnYun Tech co. LTD + */ +@Dao +public interface GpsInfoDao { + @Insert(onConflict = OnConflictStrategy.REPLACE) + void insert(GPSInfo gpsInfo); + + + @Query("SELECT * from gps_info") + LiveData<GPSInfo> getGpsInfo(); +} diff --git a/app/src/main/java/safeluck/drive/evaluation/DB/gps/GpsInfoRepository.java b/app/src/main/java/safeluck/drive/evaluation/DB/gps/GpsInfoRepository.java new file mode 100644 index 0000000..b3da451 --- /dev/null +++ b/app/src/main/java/safeluck/drive/evaluation/DB/gps/GpsInfoRepository.java @@ -0,0 +1,37 @@ +package safeluck.drive.evaluation.DB.gps; + +import android.app.Application; + +import androidx.lifecycle.LiveData; + +import safeluck.drive.evaluation.DB.WorkRoomDataBase; + +/** + * MyApplication2 + * Created by lzw on 2020/1/10. 16:46:57 + * 閭锛�632393724@qq.com + * All Rights Saved! Chongqing AnYun Tech co. LTD + */ +public class GpsInfoRepository { + + private GpsInfoDao gpsInfoDao; + private LiveData<GPSInfo> gpsInfo; + + public GpsInfoRepository(Application application) { + gpsInfoDao = WorkRoomDataBase.getWorkRoomDataBase(application).getGpsInoDao(); + gpsInfo = gpsInfoDao.getGpsInfo(); + } + + public void insertGpsInfo(final GPSInfo gpsInfo) { + WorkRoomDataBase.dataBaseWriteExecutor.execute(new Runnable() { + @Override + public void run() { + gpsInfoDao.insert(gpsInfo); + } + }); + } + + public LiveData<GPSInfo> getGpsInfo(){ + return gpsInfo; + } +} diff --git a/app/src/main/java/safeluck/drive/evaluation/DB/gps/GpsInfoViewModel.java b/app/src/main/java/safeluck/drive/evaluation/DB/gps/GpsInfoViewModel.java new file mode 100644 index 0000000..5a971eb --- /dev/null +++ b/app/src/main/java/safeluck/drive/evaluation/DB/gps/GpsInfoViewModel.java @@ -0,0 +1,32 @@ +package safeluck.drive.evaluation.DB.gps; + +import android.app.Application; + +import androidx.annotation.NonNull; +import androidx.lifecycle.AndroidViewModel; +import androidx.lifecycle.LiveData; + +/** + * MyApplication2 + * Created by lzw on 2020/1/10. 16:46:30 + * 閭锛�632393724@qq.com + * All Rights Saved! Chongqing AnYun Tech co. LTD + */ +public class GpsInfoViewModel extends AndroidViewModel { + + private GpsInfoRepository gpsInfoRepository; + + public GpsInfoViewModel(@NonNull Application application) { + super(application); + gpsInfoRepository = new GpsInfoRepository(application); + } + + public void insert(GPSInfo gpsInfo){ + gpsInfoRepository.insertGpsInfo(gpsInfo); + } + + + public LiveData<GPSInfo> getGpsInfo(){ + return gpsInfoRepository.getGpsInfo(); + } +} diff --git a/app/src/main/java/safeluck/drive/evaluation/DB/gps/GpsInfoWorker.java b/app/src/main/java/safeluck/drive/evaluation/DB/gps/GpsInfoWorker.java new file mode 100644 index 0000000..0623791 --- /dev/null +++ b/app/src/main/java/safeluck/drive/evaluation/DB/gps/GpsInfoWorker.java @@ -0,0 +1,55 @@ +package safeluck.drive.evaluation.DB.gps; + +import android.content.Context; +import android.util.Log; + +import androidx.annotation.NonNull; +import androidx.work.Worker; +import androidx.work.WorkerParameters; + +import com.google.gson.Gson; +import com.google.gson.reflect.TypeToken; +import com.google.gson.stream.JsonReader; + +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.lang.reflect.Type; +import java.util.List; + +import safeluck.drive.evaluation.Constant; +import safeluck.drive.evaluation.DB.Student; +import safeluck.drive.evaluation.DB.WorkRoomDataBase; + +/** + * MyApplication2 + * Created by lzw on 2020/1/10. 17:01:08 + * 閭锛�632393724@qq.com + * All Rights Saved! Chongqing AnYun Tech co. LTD + */ +public class GpsInfoWorker extends Worker { + + private static final String TAG = "GpsInfoWorker"; + public GpsInfoWorker(@NonNull Context context, @NonNull WorkerParameters workerParams) { + super(context, workerParams); + } + + @NonNull + @Override + public Result doWork() { + try { + Log.i(TAG, "doWork: "); + + Gson gson = new Gson(); + Type type = new TypeToken<GPSInfo>(){}.getType(); + + GPSInfo mstus=gson.fromJson(getInputData().getString(Constant.GPS_INFO_DATA), type); + WorkRoomDataBase.getWorkRoomDataBase(getApplicationContext()).getGpsInoDao().insert(mstus); + + } catch (Exception e) { + e.printStackTrace(); + return Result.failure(); + } + return Result.success(); + } +} diff --git a/app/src/main/java/safeluck/drive/evaluation/adapter/GpsInfoAdapter.java b/app/src/main/java/safeluck/drive/evaluation/adapter/GpsInfoAdapter.java new file mode 100644 index 0000000..8c6661c --- /dev/null +++ b/app/src/main/java/safeluck/drive/evaluation/adapter/GpsInfoAdapter.java @@ -0,0 +1,83 @@ +package safeluck.drive.evaluation.adapter; + +import android.content.Context; +import android.graphics.drawable.Drawable; +import android.util.Log; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.BaseAdapter; +import android.widget.TextView; + +import java.util.ArrayList; +import java.util.List; + +import safeluck.drive.evaluation.R; + +/** + * MyApplication2 + * Created by lzw on 2020/1/10. 16:33:13 + * 閭锛�632393724@qq.com + * All Rights Saved! Chongqing AnYun Tech co. LTD + */ + +public class GpsInfoAdapter extends BaseAdapter { + private List<String> persons = new ArrayList<>();//gps淇℃伅 + private final static String TAG = "anyun_info"; + private Context mContext; + @Override + public int getCount() { + return persons.size(); + } + + @Override + public String getItem(int i) { + return persons.get(i); + } + + @Override + public long getItemId(int i) { + return i; + } + + @Override + public View getView(int i, View view, ViewGroup viewGroup) { + InfoHodler infoHodler = null; + if (view == null){ + view = LayoutInflater.from(mContext).inflate(R.layout.gps_info_item,null); + infoHodler = new InfoHodler(); + infoHodler.name = view.findViewById(R.id.text_check_info); + view.setTag(infoHodler); + }else{ + infoHodler = (InfoHodler) view.getTag(); + } + + infoHodler.name.setText(getItem(i)); + return view; + } + + public GpsInfoAdapter(Context mContext) { + this.mContext = mContext; + } + /** + * //鍏堟竻鎺夊師鏉ョ殑鎵�鏈夋暟鎹啀娣诲姞鏂板姞杩涙潵鎵�鏈夌殑鏁版嵁 + * @param ps + */ + public void addAll(List<String> ps){ + persons.clear();//鍏堟竻鎺夊師鏉ョ殑鎵�鏈夋暟鎹� + persons.addAll(ps);//鍐嶆坊鍔犳柊鍔犺繘鏉ユ墍鏈夌殑鏁版嵁 + notifyDataSetChanged();//鍒锋柊鐣岄潰 + } + + static class InfoHodler { + + + public TextView name;//濮撳悕 + + + + + + } + +} diff --git a/app/src/main/java/safeluck/drive/evaluation/app.java b/app/src/main/java/safeluck/drive/evaluation/app.java index b346f70..e89276f 100644 --- a/app/src/main/java/safeluck/drive/evaluation/app.java +++ b/app/src/main/java/safeluck/drive/evaluation/app.java @@ -1,11 +1,15 @@ package safeluck.drive.evaluation; import android.app.Application; +import android.os.Environment; import android.text.TextUtils; import android.widget.Toast; import androidx.annotation.NonNull; +import androidx.work.Data; +import androidx.work.OneTimeWorkRequest; +import androidx.work.WorkManager; import com.anyun.exam.lib.AYSdk; import com.anyun.exam.lib.IAYExamListener; @@ -29,6 +33,7 @@ import safeluck.drive.evaluation.DB.failitems.FailedProj; import safeluck.drive.evaluation.DB.failitems.FailedProjRepository; +import safeluck.drive.evaluation.DB.gps.GpsInfoWorker; import safeluck.drive.evaluation.DB.rtktb.RTKConfig; import safeluck.drive.evaluation.DB.rtktb.RTKWorkRepository; import safeluck.drive.evaluation.cEventCenter.CEvent; @@ -76,6 +81,7 @@ //鏁版嵁搴撴搷浣� MyLog.i(TAG, "onCreate111"); + FileUtil.createdirs(getApplicationContext()); failedProjRepository = new FailedProjRepository(this); rtkWorkRepository = new RTKWorkRepository(this); } @@ -140,12 +146,28 @@ break; case Constant.FETCH_MAP_INFO: - StringBuffer buffer =FileUtil.readAssetTxtFile(this,Constant.MAP); - AYSdk.getInstance().sendCmd(Constant.PUSH_MAP_INFO,buffer.toString()); + StringBuffer buffer =FileUtil.readTxtFileFromSD(this,Constant.MAP); + if (buffer != null){ + + AYSdk.getInstance().sendCmd(Constant.PUSH_MAP_INFO,buffer.toString()); + }else{ + MyLog.d(TAG,String.format("鍦板浘妯″瀷鏈嫹鍏%s]鐩綍涓�", Environment.getExternalStorageDirectory().getAbsolutePath()+"/"+getApplicationContext().getPackageName())); + + } break; case Constant.REQ_VECHILE_PROFILE: - StringBuffer vebuffer =FileUtil.readAssetTxtFile(this,Constant.VEHICLE); - AYSdk.getInstance().sendCmd(Constant.PUSH_VECHILE_PROFILE,vebuffer.toString()); + StringBuffer vebuffer =FileUtil.readTxtFileFromSD(this,Constant.VEHICLE); + if (vebuffer != null){ + + AYSdk.getInstance().sendCmd(Constant.PUSH_VECHILE_PROFILE,vebuffer.toString()); + }else{ + MyLog.d(TAG,String.format("杞﹁締妯″瀷妯″瀷鏈嫹鍏%s]鐩綍涓�", Environment.getExternalStorageDirectory().getAbsolutePath()+"/"+getApplicationContext().getPackageName())); + } + break; + case Constant.GPS_INFO: + Data gpsData = new Data.Builder().putString(Constant.GPS_INFO_DATA,json).build(); + OneTimeWorkRequest gpsinfoWorkRequest = new OneTimeWorkRequest.Builder(GpsInfoWorker.class).setInputData(gpsData).build(); + WorkManager.getInstance(getApplicationContext()).enqueue(gpsinfoWorkRequest); break; } diff --git a/app/src/main/java/safeluck/drive/evaluation/fragment/GpsInfoFragment.java b/app/src/main/java/safeluck/drive/evaluation/fragment/GpsInfoFragment.java index 93ea834..2be43f3 100644 --- a/app/src/main/java/safeluck/drive/evaluation/fragment/GpsInfoFragment.java +++ b/app/src/main/java/safeluck/drive/evaluation/fragment/GpsInfoFragment.java @@ -8,6 +8,7 @@ import android.view.View; import android.view.ViewGroup; import android.widget.EditText; +import android.widget.ListView; import android.widget.TextView; import androidx.annotation.NonNull; @@ -15,27 +16,38 @@ import androidx.lifecycle.Observer; import androidx.lifecycle.ViewModelProviders; +import com.anyun.exam.lib.MyLog; + +import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.List; + import me.yokeyword.fragmentation.SupportFragment; +import safeluck.drive.evaluation.DB.gps.GPSInfo; +import safeluck.drive.evaluation.DB.gps.GpsInfoViewModel; import safeluck.drive.evaluation.DB.rtktb.RTKConfig; import safeluck.drive.evaluation.DB.rtktb.RTKConfigViewModel; import safeluck.drive.evaluation.R; +import safeluck.drive.evaluation.adapter.GpsInfoAdapter; import safeluck.drive.evaluation.util.Utils; -/**FTP閰嶇疆UI +/** + * FTP閰嶇疆UI * MyApplication2 * Created by lzw on 2019/3/20. 11:22:39 * 閭锛�632393724@qq.com * All Rights Saved! Chongqing AnYun Tech co. LTD */ -public class GpsInfoFragment extends SupportFragment{ +public class GpsInfoFragment extends SupportFragment { private static final String TAG = "RTKConfigFragment"; - private EditText et_ip,et_port,et_city_id,et_city_province,et_phone; - private RTKConfigViewModel rtkConfigViewModel; - private RTKConfig mRtkConfig; + private ListView lv; + private GpsInfoAdapter gpsInfoAdapter; + private List<String> gpsinfos = new ArrayList<>(); - public static SupportFragment newInstance(){ + + public static SupportFragment newInstance() { return new GpsInfoFragment(); } @@ -43,19 +55,44 @@ @Override public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { + View view = inflater.inflate(R.layout.layout_gps_info, container, false); + initView(view); + GpsInfoViewModel gpsInfoViewModel = ViewModelProviders.of(this).get(GpsInfoViewModel.class); + gpsInfoViewModel.getGpsInfo().observe(this, new Observer<GPSInfo>() { + @Override + public void onChanged(GPSInfo gpsInfo) { + if (gpsInfo != null) { + MyLog.i(TAG, "gpsinfo=" + gpsInfo == null ? "null" : gpsInfo.toString()); + gpsinfos.clear(); + Field[] fields = gpsInfo.getClass().getDeclaredFields(); + for (int i = 0; i < fields.length; i++) { + //璁剧疆鏄惁鍏佽璁块棶锛屼笉鏄慨鏀瑰師鏉ョ殑璁块棶鏉冮檺淇グ璇嶃�� + fields[i].setAccessible(true); + try { + if (fields[i].getName().equalsIgnoreCase("id")) { + continue; + } + gpsinfos.add(fields[i].getName() + ":" + fields[i].get(gpsInfo)); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } + } + gpsInfoAdapter.addAll(gpsinfos); + }else{ + MyLog.i(TAG,"鏈娴嬪埌GPS鏁版嵁搴撲俊鎭�"); + } - return initView(); + } + }); + return view; } - private View initView() { - TextView textView = new TextView(_mActivity); - ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); - textView.setText("鏀跺埌鍛戒护[3],Json鍐呭涓簕\"connected\":0,\"ip\":\"47.93.80.84\",\"port\":12125}"); - textView.setTextSize(Utils.dp2Px(20)); - textView.setLayoutParams(layoutParams); - textView.setGravity(Gravity.CENTER_VERTICAL); - return textView; + private void initView(View view) { + lv = view.findViewById(R.id.lv_gpsinfo); + gpsInfoAdapter = new GpsInfoAdapter(_mActivity); + lv.setAdapter(gpsInfoAdapter); + } } diff --git a/app/src/main/java/safeluck/drive/evaluation/fragment/TcpFragment.java b/app/src/main/java/safeluck/drive/evaluation/fragment/TcpFragment.java index df4e056..296e567 100644 --- a/app/src/main/java/safeluck/drive/evaluation/fragment/TcpFragment.java +++ b/app/src/main/java/safeluck/drive/evaluation/fragment/TcpFragment.java @@ -17,6 +17,8 @@ import androidx.lifecycle.LifecycleOwner; import androidx.lifecycle.Observer; import androidx.lifecycle.ViewModelProviders; +import androidx.work.OneTimeWorkRequest; +import androidx.work.WorkManager; import com.google.android.material.textfield.TextInputEditText; @@ -31,6 +33,7 @@ import safeluck.drive.evaluation.DB.criterias.viewmodel.CriteriaIViewModel; import safeluck.drive.evaluation.DB.failitems.FailedProj; import safeluck.drive.evaluation.DB.failitems.FailedProj_select; +import safeluck.drive.evaluation.DB.gps.GpsInfoWorker; import safeluck.drive.evaluation.R; import safeluck.drive.evaluation.im.IMSClientBootstrap; import safeluck.drive.evaluation.im.MessageProcessor; @@ -126,9 +129,12 @@ //// } +// +// MessageProcessor.getInstance().sendMessage(sendEditText.getText().toString().trim()); +// sendEditText.getText().clear(); - MessageProcessor.getInstance().sendMessage(sendEditText.getText().toString().trim()); - sendEditText.getText().clear(); + + break; } diff --git a/app/src/main/java/safeluck/drive/evaluation/util/FileUtil.java b/app/src/main/java/safeluck/drive/evaluation/util/FileUtil.java index ea5345b..6055ddb 100644 --- a/app/src/main/java/safeluck/drive/evaluation/util/FileUtil.java +++ b/app/src/main/java/safeluck/drive/evaluation/util/FileUtil.java @@ -3,6 +3,10 @@ import android.app.Application; import android.content.Context; import android.content.res.Resources; +import android.os.Environment; +import android.util.Log; + +import com.anyun.exam.lib.MyLog; import java.io.BufferedReader; import java.io.File; @@ -14,6 +18,7 @@ import java.io.OutputStream; public class FileUtil { + private static final String TAG = "FileUtil"; /** * 璇诲彇assert鐩綍涓� txt鏂囨湰鏂囦欢鍐呭 * @param context @@ -47,6 +52,50 @@ return stringBuffer; } + public static void createdirs(Context context){ + String dir = Environment.getExternalStorageDirectory().getAbsolutePath()+"/"+context.getPackageName(); + + File file = new File(dir); + if (!file.exists()){ + file.mkdir(); + }else{ + Log.i(TAG, "createdirs: 鐩綍宸茬粡瀛樺湪"); + } + + } + + public static StringBuffer readTxtFileFromSD(Context context,String fileName){ + String lineTxt = null; + StringBuffer stringBuffer = new StringBuffer(); + try { + InputStream inputStream = null; + String dir = Environment.getExternalStorageDirectory().getAbsolutePath()+"/"+context.getPackageName(); + File file = new File(dir,fileName); + if (!file.exists()){ + MyLog.d(TAG,fileName+"鏂囦欢涓嶅瓨鍦�"); + return null; + } + try { + inputStream = new FileInputStream(file); + } catch (IOException e) { + e.printStackTrace(); + } + + InputStreamReader inputStreamReader = new InputStreamReader(inputStream); + BufferedReader bufferedReader = new BufferedReader(inputStreamReader); + while((lineTxt = bufferedReader.readLine()) != null){ + System.out.println(lineTxt); + stringBuffer.append(lineTxt); + + } + inputStreamReader.close(); + bufferedReader.close(); + } catch (IOException e) { + e.printStackTrace(); + } + return stringBuffer; + } + /** * * @param fromFile 婧愭枃浠惰矾寰勫寘鎷枃浠跺悕锛堢粷瀵硅矾寰勶級 diff --git a/app/src/main/res/layout/gps_info_item.xml b/app/src/main/res/layout/gps_info_item.xml new file mode 100644 index 0000000..060ec8c --- /dev/null +++ b/app/src/main/res/layout/gps_info_item.xml @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="utf-8"?> +<TextView xmlns:android="http://schemas.android.com/apk/res/android" + android:id="@+id/text_check_info" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:textAppearance="?android:attr/textAppearanceListItemSmall" + android:gravity="center_vertical" + android:paddingStart="?android:attr/listPreferredItemPaddingStart" + android:paddingEnd="?android:attr/listPreferredItemPaddingEnd" + android:minHeight="?android:attr/listPreferredItemHeightSmall" /> \ No newline at end of file diff --git a/app/src/main/res/layout/layout_gps_info.xml b/app/src/main/res/layout/layout_gps_info.xml new file mode 100644 index 0000000..3f24621 --- /dev/null +++ b/app/src/main/res/layout/layout_gps_info.xml @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:orientation="vertical" android:layout_width="match_parent" + android:layout_height="match_parent"> + <ListView + android:layout_width="match_parent" + android:layout_height="match_parent" + android:id="@+id/lv_gpsinfo"></ListView> +</LinearLayout> \ No newline at end of file diff --git a/app/src/main/res/layout/layout_home_fragment.xml b/app/src/main/res/layout/layout_home_fragment.xml index bc27716..b03871d 100644 --- a/app/src/main/res/layout/layout_home_fragment.xml +++ b/app/src/main/res/layout/layout_home_fragment.xml @@ -92,7 +92,6 @@ android:text="@string/version_name" android:padding="10dp" android:id="@+id/tv_app_version" - android:textSize="20sp" android:textColor="@color/home_version_show" android:layout_alignParentBottom="true" android:layout_alignParentEnd="true"/> diff --git a/app/src/main/res/layout/layout_rtk_setting.xml b/app/src/main/res/layout/layout_rtk_setting.xml index 83faf92..4efa44a 100644 --- a/app/src/main/res/layout/layout_rtk_setting.xml +++ b/app/src/main/res/layout/layout_rtk_setting.xml @@ -1,5 +1,7 @@ <?xml version="1.0" encoding="utf-8"?> -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" +<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" + android:layout_height="match_parent"> +<LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" @@ -171,3 +173,4 @@ android:id="@+id/btn_save_rtk" android:text="淇濆瓨"/> </LinearLayout> +</ScrollView> \ No newline at end of file -- Gitblit v1.8.0