添加位置模型数据添加功能
This commit is contained in:
		@@ -1,8 +1,8 @@
 | 
			
		||||
#Created by .winboll/winboll_app_build.gradle
 | 
			
		||||
#Thu Apr 03 11:18:49 GMT 2025
 | 
			
		||||
#Thu Apr 03 13:23:15 GMT 2025
 | 
			
		||||
stageCount=0
 | 
			
		||||
libraryProject=
 | 
			
		||||
baseVersion=1.0
 | 
			
		||||
publishVersion=1.0.0
 | 
			
		||||
buildCount=409
 | 
			
		||||
buildCount=410
 | 
			
		||||
baseBetaVersion=1.0.1
 | 
			
		||||
 
 | 
			
		||||
@@ -42,6 +42,7 @@ import android.content.ComponentName;
 | 
			
		||||
import android.os.IBinder;
 | 
			
		||||
import cc.winboll.studio.positions.listeners.OnGPSRTLocationListener;
 | 
			
		||||
import cc.winboll.studio.positions.MainActivity;
 | 
			
		||||
import cc.winboll.studio.positions.views.PostionUtils;
 | 
			
		||||
 | 
			
		||||
public class PositionsFragment extends Fragment {
 | 
			
		||||
 | 
			
		||||
@@ -60,6 +61,8 @@ public class PositionsFragment extends Fragment {
 | 
			
		||||
    GPSService mGPSService;
 | 
			
		||||
    Button mbtnTXRT;
 | 
			
		||||
    Button mbtnAdd;
 | 
			
		||||
    Location mLocationTX;
 | 
			
		||||
    Location mLocationPhoneGPS;
 | 
			
		||||
    
 | 
			
		||||
    TextView mtvPostionFixModelInfo;
 | 
			
		||||
    TextView mtvLockPostionInfo;
 | 
			
		||||
@@ -77,8 +80,6 @@ public class PositionsFragment extends Fragment {
 | 
			
		||||
    double longitudeFuseLock;
 | 
			
		||||
 | 
			
		||||
    PostionFixModel mPostionFixModel;
 | 
			
		||||
    Location mLocationTX;
 | 
			
		||||
    Location mLocationPhoneGPS;
 | 
			
		||||
    static Location _LocationPhoneGPSLock;
 | 
			
		||||
 | 
			
		||||
    LocationManager locationManagerPhoneGPS;
 | 
			
		||||
@@ -129,7 +130,9 @@ public class PositionsFragment extends Fragment {
 | 
			
		||||
        mbtnAdd.setOnClickListener(new Button.OnClickListener(){
 | 
			
		||||
                @Override
 | 
			
		||||
                public void onClick(View view) {
 | 
			
		||||
                    ToastUtils.show("mbtnAdd");
 | 
			
		||||
                    //ToastUtils.show("mbtnAdd");
 | 
			
		||||
                    PostionUtils postionUtils = PostionUtils.getInstance(getActivity());
 | 
			
		||||
                    postionUtils.addPostion(mLocationPhoneGPS);
 | 
			
		||||
                }
 | 
			
		||||
            });
 | 
			
		||||
        
 | 
			
		||||
 
 | 
			
		||||
@@ -0,0 +1,50 @@
 | 
			
		||||
package cc.winboll.studio.positions.views;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @Author ZhanGSKen@AliYun.Com
 | 
			
		||||
 * @Date 2025/04/03 21:09:50
 | 
			
		||||
 * @Describe 位置处理工具集
 | 
			
		||||
 */
 | 
			
		||||
import android.content.Context;
 | 
			
		||||
import cc.winboll.studio.positions.models.PostionModel;
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
import android.location.Location;
 | 
			
		||||
 | 
			
		||||
public class PostionUtils {
 | 
			
		||||
 | 
			
		||||
    public static final String TAG = "PostionUtils";
 | 
			
		||||
 | 
			
		||||
    static volatile PostionUtils _PostionUtils;
 | 
			
		||||
 | 
			
		||||
    Context mContext;
 | 
			
		||||
    ArrayList<PostionModel> mPostionModelList = new ArrayList<PostionModel>();
 | 
			
		||||
 | 
			
		||||
    PostionUtils(Context context) {
 | 
			
		||||
        mContext = context;
 | 
			
		||||
        PostionModel.loadBeanList(mContext, mPostionModelList, PostionModel.class);
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public synchronized static PostionUtils getInstance(Context context) {
 | 
			
		||||
        if (_PostionUtils == null) {
 | 
			
		||||
            _PostionUtils = new PostionUtils(context);
 | 
			
		||||
        }
 | 
			
		||||
        return _PostionUtils;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public void addPostion(PostionModel item) {
 | 
			
		||||
        mPostionModelList.add(item);
 | 
			
		||||
        PostionModel.saveBeanList(mContext, mPostionModelList, PostionModel.class);
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public void addPostion(Location location) {
 | 
			
		||||
        PostionModel item = new PostionModel();
 | 
			
		||||
        item.setLatitude(location.getLatitude());
 | 
			
		||||
        item.setLongitude(location.getLongitude());
 | 
			
		||||
        item.setTimestamp(location.getTime());
 | 
			
		||||
        item.setAccuracy(location.getAccuracy());
 | 
			
		||||
        item.setProvider(location.getProvider());
 | 
			
		||||
        
 | 
			
		||||
        mPostionModelList.add(item);
 | 
			
		||||
        PostionModel.saveBeanList(mContext, mPostionModelList, PostionModel.class);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user