|
@@ -1,869 +0,0 @@
|
|
|
-package com.sikey.veryfit.ui.avtivity.component.path;
|
|
|
-
|
|
|
-import android.app.Activity;
|
|
|
-import android.content.Intent;
|
|
|
-import android.os.Bundle;
|
|
|
-import android.os.Message;
|
|
|
-import androidx.fragment.app.FragmentTransaction;
|
|
|
-import androidx.recyclerview.widget.LinearLayoutManager;
|
|
|
-import androidx.recyclerview.widget.RecyclerView;
|
|
|
-import androidx.appcompat.widget.Toolbar;
|
|
|
-import android.util.Log;
|
|
|
-import android.view.Menu;
|
|
|
-import android.view.MenuItem;
|
|
|
-import android.view.View;
|
|
|
-import android.widget.ImageView;
|
|
|
-import android.widget.SeekBar;
|
|
|
-import android.widget.TextView;
|
|
|
-
|
|
|
-import com.android.volley.Request;
|
|
|
-import com.android.volley.Response;
|
|
|
-import com.android.volley.VolleyError;
|
|
|
-import com.android.volley.toolbox.JsonObjectRequest;
|
|
|
-import com.google.android.gms.maps.CameraUpdateFactory;
|
|
|
-import com.google.android.gms.maps.GoogleMap;
|
|
|
-import com.google.android.gms.maps.OnMapReadyCallback;
|
|
|
-import com.google.android.gms.maps.SupportMapFragment;
|
|
|
-import com.google.android.gms.maps.model.BitmapDescriptor;
|
|
|
-import com.google.android.gms.maps.model.BitmapDescriptorFactory;
|
|
|
-import com.google.android.gms.maps.model.CameraPosition;
|
|
|
-import com.google.android.gms.maps.model.Dot;
|
|
|
-import com.google.android.gms.maps.model.Gap;
|
|
|
-import com.google.android.gms.maps.model.LatLng;
|
|
|
-import com.google.android.gms.maps.model.LatLngBounds;
|
|
|
-import com.google.android.gms.maps.model.Marker;
|
|
|
-import com.google.android.gms.maps.model.MarkerOptions;
|
|
|
-import com.google.android.gms.maps.model.PatternItem;
|
|
|
-import com.google.android.gms.maps.model.Polyline;
|
|
|
-import com.google.android.gms.maps.model.PolylineOptions;
|
|
|
-import com.sikey.veryfit.R;
|
|
|
-import com.sikey.veryfit.app.DataManager;
|
|
|
-import com.sikey.veryfit.component.VersionMatch.VersionMatch;
|
|
|
-import com.sikey.veryfit.component.handler.WeakReferenceHandler;
|
|
|
-import com.sikey.veryfit.component.log.Logger;
|
|
|
-import com.sikey.veryfit.component.network.BusinessError;
|
|
|
-import com.sikey.veryfit.component.network.RequestManager;
|
|
|
-import com.sikey.veryfit.component.network.ZipGsonListener;
|
|
|
-import com.sikey.veryfit.constant.JSONConstants;
|
|
|
-import com.sikey.veryfit.constant.UrlConstants;
|
|
|
-import com.sikey.veryfit.data.bean.PathTraceBean;
|
|
|
-import com.sikey.veryfit.k2.entity.DateBean;
|
|
|
-import com.sikey.veryfit.k2.ui.settings.LocationSettingActivity;
|
|
|
-import com.sikey.veryfit.k2.utils.FormatUtils;
|
|
|
-import com.sikey.veryfit.ui.adapter.DateAdapter;
|
|
|
-import com.sikey.veryfit.ui.avtivity.base.BaseNoActionBarActivity;
|
|
|
-import com.sikey.veryfit.ui.fragment.path.TrackSeekBarFragment;
|
|
|
-import com.sikey.veryfit.utils.ResUtils;
|
|
|
-import com.sikey.veryfit.utils.ToastUtils;
|
|
|
-
|
|
|
-import org.json.JSONArray;
|
|
|
-import org.json.JSONException;
|
|
|
-import org.json.JSONObject;
|
|
|
-
|
|
|
-import java.text.SimpleDateFormat;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Arrays;
|
|
|
-import java.util.Calendar;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Locale;
|
|
|
-import java.util.TimeZone;
|
|
|
-import java.util.concurrent.ExecutorService;
|
|
|
-import java.util.concurrent.Executors;
|
|
|
-
|
|
|
-public class MDPathHistoryActivity extends BaseNoActionBarActivity
|
|
|
- implements View.OnClickListener,DateAdapter.DateItemClickListener,OnMapReadyCallback {
|
|
|
-
|
|
|
- private static final String TAG=MDPathHistoryActivity.class.getSimpleName();
|
|
|
-
|
|
|
- private static final int FIXED_THREAD_NUM=1;
|
|
|
-
|
|
|
- private static final int NORMAL_Z_INDEX=1;
|
|
|
-
|
|
|
- private static final int MSG_DRAW_PATH=1;
|
|
|
-
|
|
|
- private static final int POLYLINE_WIDTH=10;
|
|
|
- private static final int DOT_LINE_WIDTH=6;
|
|
|
- private static final int COLOR_GREEN=0xff259f44;
|
|
|
- private static final int COLOR_BLUE=0xff2c9cff;
|
|
|
-
|
|
|
- private static final long ONE_DAY_MILL_SECONDS=24*3600*1000;
|
|
|
-
|
|
|
- private static final long HALF_HOUR_SECONDS=38*60;
|
|
|
- private final int NEW_COUNT = 30;
|
|
|
-
|
|
|
- private final Calendar calendar = Calendar.getInstance();
|
|
|
-
|
|
|
- private GoogleMap map;
|
|
|
- private Polyline mMutablePolyline;
|
|
|
-
|
|
|
- private static final int PATTERN_GAP_LENGTH_PX = 20;
|
|
|
- private static final Dot DOT = new Dot();
|
|
|
- private static final Gap GAP = new Gap(PATTERN_GAP_LENGTH_PX);
|
|
|
- private static final List<PatternItem> PATTERN_DOTTED = Arrays.asList(DOT, GAP);
|
|
|
-
|
|
|
- @Override
|
|
|
- public void onMapReady(GoogleMap googleMap) {
|
|
|
- map = googleMap;
|
|
|
- setMapLoadFinishFlag(true);
|
|
|
- }
|
|
|
-
|
|
|
- private enum PointGravity{
|
|
|
- top,center,bottom
|
|
|
- }
|
|
|
-
|
|
|
- private final WeakReferenceHandler<Activity>mHandler=new WeakReferenceHandler<Activity>(this) {
|
|
|
- @Override
|
|
|
- protected void handleMessage(Activity activity, Message msg) {
|
|
|
- switch (msg.what)
|
|
|
- {
|
|
|
- case MSG_DRAW_PATH:
|
|
|
- drawPath(mCurrentBeanList);
|
|
|
- break;
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- };
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- private List<PathTraceBean>mCurrentBeanList;
|
|
|
-
|
|
|
- private final List<MarkerOptions>mOverlayOptionList=new ArrayList<>();
|
|
|
-
|
|
|
- private boolean mMapLoadFinishFlag=false;
|
|
|
-
|
|
|
- private final Object mLock=new Object();
|
|
|
-
|
|
|
- private ExecutorService mFixedThreadPool=null;
|
|
|
-
|
|
|
- private FragmentTransaction mFragmentTransaction;
|
|
|
- private TrackSeekBarFragment mTrackSeekBarFrag;
|
|
|
- private boolean isSeekFragShow=false;
|
|
|
- private Marker mCurrentMarker;
|
|
|
- private int mCurrentProgress=0;
|
|
|
-
|
|
|
- private Toolbar mToolbar;
|
|
|
- private TextView mName ;
|
|
|
- private TextView mRightTv ;
|
|
|
- private ImageView mBack ;
|
|
|
-
|
|
|
- RecyclerView mLytDate;
|
|
|
- DateAdapter mDateAdapter;
|
|
|
-
|
|
|
- private ArrayList<DateBean> dateData;
|
|
|
-
|
|
|
- private void initView()
|
|
|
- {
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- SupportMapFragment mapFragment =
|
|
|
- (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
|
|
|
- mapFragment.getMapAsync(this);
|
|
|
-
|
|
|
- mToolbar = (Toolbar) findViewById(R.id.toolbar);
|
|
|
- mName = (TextView) mToolbar.findViewById(R.id.title);
|
|
|
- mBack = (ImageView) mToolbar.findViewById(R.id.ic_back);
|
|
|
- mRightTv = (TextView) mToolbar.findViewById(R.id.rightActionTv);
|
|
|
- mRightTv.setText(getString(R.string.today));
|
|
|
- mRightTv.setTextColor(getResources().getColor(R.color.dark));
|
|
|
- mName.setText(getText(R.string.track_history));
|
|
|
-
|
|
|
- mBack.setVisibility(View.VISIBLE);
|
|
|
- mBack.setOnClickListener(this);
|
|
|
-
|
|
|
- mRightTv.setOnClickListener(this);
|
|
|
-
|
|
|
- //init date view
|
|
|
-
|
|
|
- dateData = new ArrayList<>();
|
|
|
- addMoreDays();
|
|
|
- mLytDate = (RecyclerView) findViewById(R.id.day_list);
|
|
|
- mLytDate.setHasFixedSize(true);
|
|
|
- LinearLayoutManager layoutManager = new LinearLayoutManager(this);
|
|
|
- layoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
|
|
|
- mLytDate.setLayoutManager(layoutManager);
|
|
|
- mDateAdapter = new DateAdapter(this,dateData);
|
|
|
- mLytDate.setAdapter(mDateAdapter);
|
|
|
- mLytDate.scrollToPosition(14);
|
|
|
- mDateAdapter.setSelectItem(14);
|
|
|
- mDateAdapter.setmListener(this);
|
|
|
- showSeekBarFragment();
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- findViewById(R.id.tv_set_location).setOnClickListener(this);
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- private void initData()
|
|
|
- {
|
|
|
- Date today=new Date(System.currentTimeMillis());
|
|
|
- //mChosenDate=today;
|
|
|
- startToSubmit(today);
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- private void startToSubmit(Date startDay)
|
|
|
- {
|
|
|
- SimpleDateFormat sdf=new SimpleDateFormat("yyyyMMdd", Locale.CHINA);
|
|
|
- String startTime=sdf.format(startDay);
|
|
|
- Logger.d(TAG, "startTime:" + startTime);
|
|
|
- //mChosenDayTv.setText(startTime);
|
|
|
- Date endDay=new Date(startDay.getTime()+ONE_DAY_MILL_SECONDS);
|
|
|
- String endTime=sdf.format(endDay);
|
|
|
- Logger.d(TAG, "endTime:" + endTime);
|
|
|
- submitRequest(startTime,endTime);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- @Override
|
|
|
- protected void onCreate(Bundle savedInstanceState) {
|
|
|
- super.onCreate(savedInstanceState);
|
|
|
- setContentView(R.layout.activity_mdpath_history);
|
|
|
- initView();
|
|
|
- initData();
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- @Override
|
|
|
- public void onClick(View v) {
|
|
|
- switch(v.getId())
|
|
|
- {
|
|
|
-
|
|
|
- case R.id.ic_back:
|
|
|
- backAction();
|
|
|
- break;
|
|
|
- case R.id.rightActionTv:
|
|
|
- onItemClick(14);
|
|
|
- break;
|
|
|
- case R.id.tv_set_location:
|
|
|
- startActivity(new Intent(this, LocationSettingActivity.class));
|
|
|
- break;
|
|
|
- default:
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private void showOrHideSeekBarFragment()
|
|
|
- {
|
|
|
- if(null==mCurrentBeanList||mCurrentBeanList.size()<1)
|
|
|
- {
|
|
|
- ToastUtils.showShortToast(R.string.no_path_history_tip);
|
|
|
- return;
|
|
|
- }
|
|
|
- if(null==mTrackSeekBarFrag)
|
|
|
- {
|
|
|
- TrackSeekBarManager manager=new TrackSeekBarManager();
|
|
|
- mCurrentProgress = 1;
|
|
|
- PathTraceBean bean = null;
|
|
|
- if(mCurrentBeanList.size() >= 1) {
|
|
|
- bean = mCurrentBeanList.get(mCurrentProgress - 1);
|
|
|
- }
|
|
|
-
|
|
|
- mTrackSeekBarFrag=TrackSeekBarFragment.newInstance(mCurrentBeanList.size()-1 ,manager,bean);
|
|
|
- }
|
|
|
- if(null==mFragmentTransaction)
|
|
|
- {
|
|
|
- mFragmentTransaction=this.getSupportFragmentManager().beginTransaction();
|
|
|
-
|
|
|
- mFragmentTransaction.replace(R.id.seekBarContainer,mTrackSeekBarFrag);
|
|
|
- mFragmentTransaction.commit();
|
|
|
- isSeekFragShow=true;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- mFragmentTransaction=this.getSupportFragmentManager().beginTransaction();
|
|
|
- if(isSeekFragShow)
|
|
|
- {
|
|
|
- Logger.d(TAG,"hide fragment");
|
|
|
- mFragmentTransaction.hide(mTrackSeekBarFrag);
|
|
|
- isSeekFragShow=false;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- isSeekFragShow=true;
|
|
|
- mFragmentTransaction.show(mTrackSeekBarFrag);
|
|
|
- }
|
|
|
-
|
|
|
- mFragmentTransaction.commit();
|
|
|
-
|
|
|
-// mCurrentProgress = 1;
|
|
|
- if(mCurrentBeanList.size() >= 1) {
|
|
|
- PathTraceBean bean = mCurrentBeanList.get(mCurrentProgress - 1);
|
|
|
- mTrackSeekBarFrag.setCurrentPositionDetail(bean,mCurrentProgress);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private void hideTrackSeekFrag()
|
|
|
- {
|
|
|
- Logger.d(TAG,"isSeekFragShow:"+isSeekFragShow);
|
|
|
- if(!isSeekFragShow||mTrackSeekBarFrag==null)
|
|
|
- {
|
|
|
- return;
|
|
|
- }
|
|
|
- mFragmentTransaction=this.getSupportFragmentManager().beginTransaction();
|
|
|
- Logger.d(TAG,"hide fragment");
|
|
|
- mFragmentTransaction.hide(mTrackSeekBarFrag);
|
|
|
- isSeekFragShow=false;
|
|
|
- mFragmentTransaction.commit();
|
|
|
- }
|
|
|
-
|
|
|
- private void showSeekBarFragment()
|
|
|
- {
|
|
|
- if(null==mTrackSeekBarFrag)
|
|
|
- {
|
|
|
- TrackSeekBarManager manager=new TrackSeekBarManager();
|
|
|
- mCurrentProgress = 1;
|
|
|
- PathTraceBean bean = null;
|
|
|
- int maxNum = 0;
|
|
|
- if(null!=mCurrentBeanList&&mCurrentBeanList.size() >= 1) {
|
|
|
- bean = mCurrentBeanList.get(mCurrentProgress - 1);
|
|
|
- maxNum = mCurrentBeanList.size()-1;
|
|
|
- }
|
|
|
-
|
|
|
- mTrackSeekBarFrag=TrackSeekBarFragment.newInstance(maxNum ,manager,bean);
|
|
|
- }
|
|
|
- if(null==mFragmentTransaction)
|
|
|
- {
|
|
|
- mFragmentTransaction=this.getSupportFragmentManager().beginTransaction();
|
|
|
-
|
|
|
- mFragmentTransaction.replace(R.id.seekBarContainer,mTrackSeekBarFrag);
|
|
|
- mFragmentTransaction.commit();
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- mFragmentTransaction=this.getSupportFragmentManager().beginTransaction();
|
|
|
- mFragmentTransaction.show(mTrackSeekBarFrag);
|
|
|
-
|
|
|
- mFragmentTransaction.commit();
|
|
|
-
|
|
|
-// mCurrentProgress = 1;
|
|
|
- if(mCurrentBeanList.size() >= 1) {
|
|
|
- PathTraceBean bean = mCurrentBeanList.get(mCurrentProgress - 1);
|
|
|
- mTrackSeekBarFrag.setCurrentPositionDetail(bean,mCurrentProgress);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- /*
|
|
|
- private void refreshNextDayBtn()
|
|
|
- {
|
|
|
- if(mChosenDateWrapper.getTime()>System.currentTimeMillis())
|
|
|
- {
|
|
|
- mNextDayBtn.setEnabled(false);
|
|
|
- }
|
|
|
- else if(Math.abs(mChosenDateWrapper.getTime()-System.currentTimeMillis())<TORATABLE_ERROR)
|
|
|
- {
|
|
|
- mNextDayBtn.setEnabled(false);
|
|
|
- }
|
|
|
- else if(mChosenDate.getTime()<System.currentTimeMillis())
|
|
|
- {
|
|
|
- mNextDayBtn.setEnabled(true);
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- */
|
|
|
- //generate more days
|
|
|
- private void addMoreDays() {
|
|
|
- calendar.add(Calendar.DATE, -15);
|
|
|
- for (int i = 0; i < NEW_COUNT; i++) {
|
|
|
- DateBean data = new DateBean();
|
|
|
- calendar.add(Calendar.DATE, 1);
|
|
|
- data.setDate(calendar.getTime());
|
|
|
- data.setDay(FormatUtils.formateDay(this,calendar.get(Calendar.DAY_OF_WEEK)));
|
|
|
- data.setDayOfMonth(calendar.get(Calendar.DAY_OF_MONTH));
|
|
|
- data.setMonth(calendar.get(Calendar.MONTH)+1);
|
|
|
- data.setYear(calendar.get(Calendar.YEAR));
|
|
|
-
|
|
|
-
|
|
|
- dateData.add(data);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- @Override
|
|
|
- protected void onResume()
|
|
|
- {
|
|
|
- super.onResume();
|
|
|
- View view = findViewById(R.id.lyt_location_setting);
|
|
|
- if(!VersionMatch.showLocationSetting()){
|
|
|
- view.setVisibility(View.GONE);
|
|
|
- }else {
|
|
|
-/* if(!DataManager.getInstance().getCurrentChildInfo().isTraceUploadSwitch()){
|
|
|
- view.setVisibility(View.VISIBLE);
|
|
|
- }else {
|
|
|
- view.setVisibility(View.GONE);
|
|
|
- }*/
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- protected void onPause()
|
|
|
- {
|
|
|
- super.onPause();
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- protected void onDestroy()
|
|
|
- {
|
|
|
- if(null!=mFixedThreadPool)
|
|
|
- {
|
|
|
- mFixedThreadPool.shutdownNow();
|
|
|
- }
|
|
|
-
|
|
|
- super.onDestroy();
|
|
|
- }
|
|
|
-
|
|
|
- private void setMapLoadFinishFlag(boolean flag)
|
|
|
- {
|
|
|
- synchronized (mLock)
|
|
|
- {
|
|
|
- mMapLoadFinishFlag=flag;
|
|
|
- mLock.notify();
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- @Override
|
|
|
- public boolean onCreateOptionsMenu(Menu menu) {
|
|
|
- // Inflate the menu; this adds items to the action bar if it is present.
|
|
|
- //getMenuInflater().inflate(R.menu.menu_mdpath_history, menu);
|
|
|
- //return true;
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public boolean onOptionsItemSelected(MenuItem item) {
|
|
|
- // Handle action bar item clicks here. The action bar will
|
|
|
- // automatically handle clicks on the Home/Up button, so long
|
|
|
- // as you specify a parent activity in AndroidManifest.xml.
|
|
|
- int id = item.getItemId();
|
|
|
-
|
|
|
- //noinspection SimplifiableIfStatement
|
|
|
- if (id == R.id.action_settings) {
|
|
|
- return true;
|
|
|
- }
|
|
|
-
|
|
|
- return super.onOptionsItemSelected(item);
|
|
|
- }
|
|
|
-
|
|
|
- private void submitRequest(String startTime,String endTime)
|
|
|
- {
|
|
|
- TimeZone timeZone = TimeZone.getDefault();
|
|
|
- int rawOffset = timeZone.getRawOffset()/1000;
|
|
|
- int mTimeZonehour = rawOffset/3600;
|
|
|
- int mTimeZoneMinute = (rawOffset/3600)%60;
|
|
|
- Log.d(TAG,"mTimeZonehour="+mTimeZonehour+"==mTimeZoneMinute=="+mTimeZoneMinute);
|
|
|
- if(!DataManager.checkLoginResponseAndCurrentChildInfo())
|
|
|
- {
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- JSONObject params=new JSONObject();
|
|
|
- try
|
|
|
- {
|
|
|
-// params.put(JSONConstants.USER_ID,DataManager.getInstance().getLoginResponse().getUserId());
|
|
|
-// params.put(JSONConstants.CHILD_ID,DataManager.getInstance().getCurrentChildInfo().getChildId());
|
|
|
- params.put(JSONConstants.BEGIN,startTime);
|
|
|
- params.put(JSONConstants.END,endTime);
|
|
|
- params.put("timeZone",mTimeZonehour);
|
|
|
- params.put("minutes",mTimeZoneMinute);
|
|
|
-// params.put(JSONConstants.SESSION_KEY,DataManager.getInstance().getLoginResponse().getSessionKey());
|
|
|
-
|
|
|
- }
|
|
|
- catch(JSONException ex)
|
|
|
- {
|
|
|
- ex.printStackTrace();
|
|
|
- }
|
|
|
-
|
|
|
- JsonObjectRequest request=new JsonObjectRequest(Request.Method.POST, UrlConstants.BaseURL + UrlConstants.GET_SINGLE_CHILD_TRACE_LIST,
|
|
|
- params,new ZipGsonListener<PathTraceBean>(PathTraceBean.class) {
|
|
|
- @Override
|
|
|
- protected void onResponse(BusinessError error, JSONObject response, JSONArray array, PathTraceBean responseBean, List<PathTraceBean> beanList) {
|
|
|
- Logger.d(TAG,"onResponse");
|
|
|
- hideProgressDialog();
|
|
|
- if(null!=error)
|
|
|
- {
|
|
|
- ToastUtils.showShortToast(error.getMessage());
|
|
|
- hideTrackSeekFrag();
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- mCurrentBeanList=beanList;
|
|
|
- if(null==beanList||beanList.size()==0)
|
|
|
- {
|
|
|
- map.clear();
|
|
|
- hideTrackSeekFrag();
|
|
|
- ToastUtils.showShortToast(R.string.no_path_history_tip);
|
|
|
- if(mTrackSeekBarFrag!=null) {
|
|
|
- mTrackSeekBarFrag.setMax(0);
|
|
|
- }
|
|
|
- return;
|
|
|
- }
|
|
|
- Logger.d(TAG, "beaList.size()=" + beanList.size());
|
|
|
-
|
|
|
- startToWaitOrDrawPath();
|
|
|
- if(mTrackSeekBarFrag!=null)
|
|
|
- {
|
|
|
- mTrackSeekBarFrag.setMax(mCurrentBeanList.size());
|
|
|
- PathTraceBean bean = mCurrentBeanList.get(0);
|
|
|
- mTrackSeekBarFrag.setCurrentPositionDetail(bean,1);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- },new Response.ErrorListener() {
|
|
|
- @Override
|
|
|
- public void onErrorResponse(VolleyError error) {
|
|
|
- hideProgressDialog();
|
|
|
- hideTrackSeekFrag();
|
|
|
- ToastUtils.showShortToast(R.string.network_exception);
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
- showProgressDialog();
|
|
|
- RequestManager.getInstance(this).addToRequestQueue(request);
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- private void addAllMarkers(List<LatLng>points)
|
|
|
- {
|
|
|
- mOverlayOptionList.clear();
|
|
|
- for(int i=0;i<points.size();++i)
|
|
|
- {
|
|
|
- if(i==0)
|
|
|
- {
|
|
|
- //addSingleMarker(R.drawable.path_end,points.get(0),NORMAL_Z_INDEX+1);
|
|
|
- addSingleMarker(R.drawable.point_start,points.get(0),NORMAL_Z_INDEX+1);
|
|
|
- }
|
|
|
- else if(i==points.size()-1)
|
|
|
- {
|
|
|
- //addSingleMarker(R.drawable.path_start,points.get(points.size()-1),NORMAL_Z_INDEX+1);
|
|
|
- addSingleMarker(R.drawable.point_end,points.get(points.size()-1),NORMAL_Z_INDEX+1);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- addSingleMarker(R.drawable.point_normal,points.get(i),NORMAL_Z_INDEX,PointGravity.center);
|
|
|
- //addSingleMarker(R.drawable.green_circle,points.get(i));
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- private void zoomToSpan(List<LatLng> points)
|
|
|
- {
|
|
|
- double minX=0.0,maxX=0.0,minY=0.0,maxY=0.0;
|
|
|
- if(points==null){
|
|
|
- return;
|
|
|
- }
|
|
|
- for(int i=0;i<points.size();++i)
|
|
|
- {
|
|
|
- //LatLng latLng=getConvertedLatLng(mAvatarItems.get(i).info.toLatLng());
|
|
|
- LatLng latLng=points.get(i);
|
|
|
- if(i==0)
|
|
|
- {
|
|
|
- minX=latLng.latitude;
|
|
|
- maxX=minX;
|
|
|
- minY=latLng.longitude;
|
|
|
- maxY=minY;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- if(latLng.latitude<minX)
|
|
|
- {
|
|
|
- minX=latLng.latitude;
|
|
|
- }
|
|
|
- if(latLng.latitude>maxX)
|
|
|
- {
|
|
|
- maxX=latLng.latitude;
|
|
|
- }
|
|
|
- if(latLng.longitude<minY)
|
|
|
- {
|
|
|
- minY=latLng.longitude;
|
|
|
- }
|
|
|
- if(latLng.longitude>maxY)
|
|
|
- {
|
|
|
- maxY=latLng.longitude;
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- LatLng southWest=new LatLng(minX,minY);
|
|
|
- LatLng earthEast=new LatLng(maxX,maxY);
|
|
|
- LatLngBounds bounds = new LatLngBounds(southWest, earthEast);
|
|
|
- map.setLatLngBoundsForCameraTarget(bounds);
|
|
|
- // 100是LatLngBounds与地图边缘100像素的填充区域
|
|
|
- map.animateCamera(CameraUpdateFactory.newLatLngBounds(bounds, 100));
|
|
|
- }
|
|
|
-
|
|
|
- private void startToWaitOrDrawPath()
|
|
|
- {
|
|
|
- /*
|
|
|
- Thread thread=new Thread(new Runnable() {
|
|
|
- @Override
|
|
|
- public void run() {
|
|
|
- synchronized (mLock)
|
|
|
- {
|
|
|
- while(!mMapLoadFinishFlag)
|
|
|
- {
|
|
|
- try
|
|
|
- {
|
|
|
- mLock.wait();
|
|
|
- }
|
|
|
- catch(InterruptedException ex)
|
|
|
- {
|
|
|
- ex.printStackTrace();
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- mHandler.sendEmptyMessage(MSG_DRAW_PATH);
|
|
|
- }
|
|
|
- });
|
|
|
- thread.start();
|
|
|
- */
|
|
|
- if(null==mFixedThreadPool)
|
|
|
- {
|
|
|
- mFixedThreadPool= Executors.newFixedThreadPool(FIXED_THREAD_NUM);
|
|
|
- }
|
|
|
- mFixedThreadPool.execute(new Runnable() {
|
|
|
- @Override
|
|
|
- public void run() {
|
|
|
- synchronized (mLock)
|
|
|
- {
|
|
|
- while(!mMapLoadFinishFlag)
|
|
|
- {
|
|
|
- try
|
|
|
- {
|
|
|
- mLock.wait();
|
|
|
- }
|
|
|
- catch(InterruptedException ex)
|
|
|
- {
|
|
|
- ex.printStackTrace();
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- mHandler.sendEmptyMessage(MSG_DRAW_PATH);
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- private void drawPath(List<PathTraceBean>beanList)
|
|
|
- {
|
|
|
- Logger.d(TAG,"drawPath");
|
|
|
- if(null==map||null==beanList||beanList.size()==0)
|
|
|
- {
|
|
|
- return;
|
|
|
- }
|
|
|
- map.clear();
|
|
|
- List<LatLng>points=generatePoints(beanList);
|
|
|
- addAllMarkers(points);
|
|
|
- drawAllLines(points);
|
|
|
-
|
|
|
- zoomToSpan(points);
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- private void drawAllLines(List<LatLng>points)
|
|
|
- {
|
|
|
- if(points.size()<2)
|
|
|
- {
|
|
|
- return;
|
|
|
- }
|
|
|
- List<LatLng>tempPoints=new ArrayList<>();
|
|
|
- long timeInterval;
|
|
|
- for(int i=0;i<points.size()-1;++i)
|
|
|
- {
|
|
|
- tempPoints.clear();
|
|
|
- tempPoints.add(points.get(i));
|
|
|
- tempPoints.add(points.get(i+1));
|
|
|
- timeInterval=mCurrentBeanList.get(i+1).getTimeTicks()-mCurrentBeanList.get(i).getTimeTicks();
|
|
|
- drawSingleLine(tempPoints,timeInterval);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- private void drawSingleLine(List<LatLng>tempPoints,long timeInterval)
|
|
|
- {
|
|
|
- PolylineOptions polyLine;
|
|
|
- if(timeInterval<HALF_HOUR_SECONDS)
|
|
|
- {
|
|
|
- polyLine=new PolylineOptions().width(POLYLINE_WIDTH).color(COLOR_GREEN).addAll(tempPoints);
|
|
|
- mMutablePolyline = map.addPolyline(polyLine);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- polyLine=new PolylineOptions().width(DOT_LINE_WIDTH).color(COLOR_BLUE).addAll(tempPoints);
|
|
|
- mMutablePolyline = map.addPolyline(polyLine);
|
|
|
- mMutablePolyline.setPattern(PATTERN_DOTTED);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private void addSingleMarker(int drawId,LatLng latLng,int customIndex)
|
|
|
- {
|
|
|
- addSingleMarker(drawId,latLng,customIndex,PointGravity.bottom);
|
|
|
- }
|
|
|
-
|
|
|
- private void addSingleMarker(int drawId,LatLng latLng,int customIndex,PointGravity gravity)
|
|
|
- {
|
|
|
- BitmapDescriptor descriptor= BitmapDescriptorFactory.fromResource(drawId);
|
|
|
- MarkerOptions options=new MarkerOptions().position(latLng).icon(descriptor)
|
|
|
- .zIndex(customIndex).draggable(false);
|
|
|
- switch (gravity){
|
|
|
- case top:
|
|
|
- options.anchor(0.5f,0f);
|
|
|
- break;
|
|
|
- case center:
|
|
|
- options.anchor(0.5f,0.5f);
|
|
|
- break;
|
|
|
- case bottom:
|
|
|
- options.anchor(0.5f,1f);
|
|
|
- break;
|
|
|
- default:
|
|
|
- break;
|
|
|
- }
|
|
|
- mOverlayOptionList.add(options);
|
|
|
- Marker marker = map.addMarker(options );
|
|
|
- }
|
|
|
-
|
|
|
- private List<LatLng> generatePoints(List<PathTraceBean>beanList)
|
|
|
- {
|
|
|
- List<LatLng>points=new ArrayList<>();
|
|
|
- for(PathTraceBean bean:beanList)
|
|
|
- {
|
|
|
- LatLng desLatLng=getConvertedLatLng(bean);
|
|
|
- points.add(desLatLng);
|
|
|
- }
|
|
|
- return points;
|
|
|
- }
|
|
|
-
|
|
|
- private LatLng getConvertedLatLng(PathTraceBean bean)
|
|
|
- {
|
|
|
- LatLng sourceLatLng=new LatLng(bean.getDecodeLat(),bean.getDecodeLng());
|
|
|
- return sourceLatLng;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- private String getTimeDetail(long time)
|
|
|
- {
|
|
|
- Logger.d(TAG,"time:"+time);
|
|
|
- Date date=new Date(time);
|
|
|
- //SimpleDateFormat sdf=new SimpleDateFormat("HH:MM:ss");
|
|
|
- SimpleDateFormat sdf=new SimpleDateFormat("HH:mm:ss",Locale.CHINA);
|
|
|
- Logger.d(TAG,"timeDetail:"+sdf.format(date));
|
|
|
- return sdf.format(date);
|
|
|
- }
|
|
|
-
|
|
|
- private String getPositionDetail(PathTraceBean bean)
|
|
|
- {
|
|
|
- StringBuilder builder=new StringBuilder();
|
|
|
- builder.append(mCurrentProgress);
|
|
|
- builder.append("/");
|
|
|
- builder.append(mCurrentBeanList.size());
|
|
|
- builder.append("(");
|
|
|
- builder.append(getTimeDetail(bean.getTimeTicks()*1000));
|
|
|
- builder.append(") ");
|
|
|
-
|
|
|
-// ChildInfo info = DataManager.getInstance().getCurrentChildInfo();
|
|
|
-// builder.append(MainHelper.getLocaTypeStr(bean.getLocaType(), info.isWatchDebugFlag()));
|
|
|
-
|
|
|
- String precision = ResUtils.getString(R.string.location_precision, bean.getAccuracy());
|
|
|
- builder.append(precision);
|
|
|
-
|
|
|
- return builder.toString();
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- private void refreshChosenMarkerAndPositionDetail()
|
|
|
- {
|
|
|
- if(mCurrentBeanList==null||mCurrentBeanList.size()==0
|
|
|
- ||mCurrentBeanList.size()<mCurrentProgress||mCurrentProgress<1)
|
|
|
- {
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- if(mCurrentMarker!=null)
|
|
|
- {
|
|
|
- mCurrentMarker.remove();
|
|
|
- }
|
|
|
-
|
|
|
- //mCurrentProgress can be [0,mCurrentBeanLis.size()];
|
|
|
- PathTraceBean bean=mCurrentBeanList.get(mCurrentProgress-1);
|
|
|
-
|
|
|
- mTrackSeekBarFrag.setCurrentPositionDetail(bean,mCurrentProgress);
|
|
|
-
|
|
|
- LatLng latLng=getConvertedLatLng(bean);
|
|
|
- BitmapDescriptor descriptor= BitmapDescriptorFactory.fromResource(R.drawable.point_selected);
|
|
|
- MarkerOptions options=new MarkerOptions().position(latLng).icon(descriptor)
|
|
|
- .zIndex(NORMAL_Z_INDEX+1).draggable(false).anchor(0.5f,0.5f);
|
|
|
- mOverlayOptionList.add(options);
|
|
|
- mCurrentMarker=map.addMarker(options);
|
|
|
- animateMapStatus(latLng);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- private void animateMapStatus(LatLng latLng)
|
|
|
- {
|
|
|
- CameraPosition position =new CameraPosition.Builder()
|
|
|
- .target(latLng).zoom(14.0f).bearing(0).tilt(0).build();
|
|
|
- map.animateCamera(CameraUpdateFactory.newCameraPosition(position));
|
|
|
- }
|
|
|
-
|
|
|
- //another useful function is that inner class could implements all the interfaces that outter class do not want to implements
|
|
|
- //In this way, the code will be elegant and tidy
|
|
|
- private class TrackSeekBarManager implements SeekBar.OnSeekBarChangeListener
|
|
|
- {
|
|
|
- @Override
|
|
|
- public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
|
|
|
- Logger.d(TAG,"progress:"+progress);
|
|
|
- mCurrentProgress=progress+1;
|
|
|
- refreshChosenMarkerAndPositionDetail();
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void onStartTrackingTouch(SeekBar seekBar) {
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void onStopTrackingTouch(SeekBar seekBar) {
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
- ///////////////////////////////////////////////////////////////
|
|
|
-
|
|
|
- @Override
|
|
|
- public void onItemClick(int postion) {
|
|
|
- mDateAdapter.setSelectItem(postion);
|
|
|
- mDateAdapter.notifyItemRangeChanged(0,NEW_COUNT);
|
|
|
-
|
|
|
- if(postion==14){
|
|
|
- mRightTv.setVisibility(View.GONE);
|
|
|
- }else {
|
|
|
- mRightTv.setVisibility(View.VISIBLE);
|
|
|
- }
|
|
|
-
|
|
|
- if(dateData.get(postion).getDate().getTime()>System.currentTimeMillis())
|
|
|
- {
|
|
|
- ToastUtils.showShortToast(R.string.date_proceed_today_tip);
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- startToSubmit(dateData.get(postion).getDate());
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-}
|