Search in sources :

Example 1 with PermissionUtils

use of com.rideread.rideread.common.util.PermissionUtils in project ride-read-android by Ride-Read.

the class MapFragment method initView.

@Override
public void initView() {
    mHandler = new WeakHandler();
    mAMap = mMapView.getMap();
    // 实例化UiSettings类对象
    mUiSettings = mAMap.getUiSettings();
    mUiSettings.setZoomControlsEnabled(false);
    mUiSettings.setCompassEnabled(true);
    mCurZoom = 18;
    // mAMap.moveCamera(CameraUpdateFactory.zoomBy(10));
    // aMap.moveCamera(CameraUpdateFactory.newCameraPosition(new CameraPosition(new LatLng(aMapLocation.getLatitude(), aMapLocation.getLongitude()), 16, 0, 0)));
    // 设置定位监听
    mAMap.setLocationSource(this);
    // 设置为true表示显示定位层并可触发定位,false表示隐藏定位层并不可触发定位,默认是false
    mAMap.setMyLocationEnabled(true);
    // mUiSettings.setMyLocationButtonEnabled(true); //显示默认的定位按钮
    // 设置定位的类型为定位模式,有定位、跟随或地图根据面向方向旋转几种
    // 初始化定位蓝点样式类
    MyLocationStyle myLocationStyle = new MyLocationStyle();
    // myLocationStyle.myLocationType(MyLocationStyle.LOCATION_TYPE_LOCATION_ROTATE);
    // myLocationStyle.(2000);
    myLocationStyle.radiusFillColor(getResources().getColor(R.color.blue_a20));
    // 连续定位、且将视角移动到地图中心点,定位点依照设备方向旋转,并且会跟随设备移动。(1秒1次定位)如果不设置myLocationType,默认也会执行此种模式。
    myLocationStyle.strokeColor(getResources().getColor(R.color.blue_a20));
    mAMap.setMyLocationStyle(myLocationStyle);
    mAMap.setMyLocationType(AMap.LOCATION_TYPE_LOCATE);
    // 在地图上加载moments
    loadMapMoments(mCurZoom);
    // 定位之前申请权限
    PermissionUtils permission = new PermissionUtils(getActivity());
    permission.grantPermission(getActivity(), Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.CAMERA, Manifest.permission.WRITE_EXTERNAL_STORAGE);
    // 定位
    AMapLocationUtils.init();
    LatLng center = new LatLng(AMapLocationUtils.getLatitude(), AMapLocationUtils.getLongitude());
    mAMap.moveCamera(CameraUpdateFactory.changeLatLng(center));
    mEdtSearch.setOnEditorActionListener((v, actionId, event) -> {
        if (KeyEvent.KEYCODE_ENTER == event.getKeyCode()) {
            searchKeyWord();
            KeyboardUtils.hideSoftInput(getActivity());
            return true;
        }
        return false;
    });
    mEdtSearch.addTextChangedListener(new TextWatcher() {

        @Override
        public void beforeTextChanged(CharSequence keyword, int start, int count, int after) {
            if (TextUtils.isEmpty(keyword)) {
                mImgClear.setVisibility(View.GONE);
            } else {
                mImgClear.setVisibility(View.VISIBLE);
            }
        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
        }

        @Override
        public void afterTextChanged(Editable s) {
        }
    });
    mAMap.setOnMarkerClickListener(marker -> {
        Moment moment = (Moment) marker.getObject();
        if (null != moment) {
            Bundle bundle = new Bundle();
            // int isFollow = moment.getUser().getIsFollowed();
            // boolean isAttent = isFollow == 0 || isFollow == 1;
            bundle.putInt(MomentDetailActivity.SELECTED_MOMENT_MID, moment.getMid());
            bundle.putInt(MomentDetailActivity.USER_TYPE, 0);
            getBaseActivity().gotoActivity(MomentDetailActivity.class, bundle);
        } else {
        }
        return false;
    });
    mAMap.setOnCameraChangeListener(new AMap.OnCameraChangeListener() {

        @Override
        public void onCameraChange(CameraPosition cameraPosition) {
        }

        @Override
        public void onCameraChangeFinish(CameraPosition cameraPosition) {
            int tempZoom = (int) cameraPosition.zoom;
            if (mIsShowNearby && mCurZoom != tempZoom) {
                mCurZoom = tempZoom;
                loadMapMoments(mCurZoom);
            }
        }
    });
}
Also used : MyLocationStyle(com.amap.api.maps.model.MyLocationStyle) AMap(com.amap.api.maps.AMap) Bundle(android.os.Bundle) LatLonPoint(com.amap.api.services.core.LatLonPoint) Point(android.graphics.Point) WeakHandler(com.badoo.mobile.util.WeakHandler) CameraPosition(com.amap.api.maps.model.CameraPosition) MapMoment(com.rideread.rideread.data.result.MapMoment) Moment(com.rideread.rideread.data.result.Moment) TextWatcher(android.text.TextWatcher) Editable(android.text.Editable) LatLng(com.amap.api.maps.model.LatLng) PermissionUtils(com.rideread.rideread.common.util.PermissionUtils)

Example 2 with PermissionUtils

use of com.rideread.rideread.common.util.PermissionUtils in project ride-read-android by Ride-Read.

the class RegisterFragment method onClick.

@OnClick({ R.id.btn_invite_next, R.id.tv_send_code, R.id.btn_code_next, R.id.tv_agree_protocol, btn_pwd_next, R.id.img_avatar, R.id.btn_complete })
public void onClick(View view) {
    // 创建权限申请对象
    PermissionUtils permission = new PermissionUtils(getActivity());
    switch(view.getId()) {
        case R.id.btn_invite_next:
            verifyInviteId();
            break;
        case R.id.tv_send_code:
            mPhone = mEdtPhone.getText().toString().trim();
            getVerifyCode();
            break;
        case R.id.btn_code_next:
            verifyCode();
            break;
        case R.id.tv_agree_protocol:
            // TODO 跳转用户协议
            break;
        case btn_pwd_next:
            checkPwd();
            break;
        case R.id.img_avatar:
            // 存储和拍照权限
            permission.grantPermission(getActivity(), Manifest.permission.CAMERA, Manifest.permission.WRITE_EXTERNAL_STORAGE);
            setAvatarImg();
            break;
        case R.id.btn_complete:
            mMyRideReadId = mEdtNick.getText().toString();
            if (TextUtils.isEmpty(mMyRideReadId)) {
                ToastUtils.show("骑阅号不能为空");
                return;
            }
            getFaceUrl();
            break;
    }
}
Also used : PermissionUtils(com.rideread.rideread.common.util.PermissionUtils) OnClick(butterknife.OnClick)

Example 3 with PermissionUtils

use of com.rideread.rideread.common.util.PermissionUtils in project ride-read-android by Ride-Read.

the class RegisterFragment method verifyInviteId.

private void verifyInviteId() {
    mInvitedId = mEdtInviteId.getText().toString();
    if (TextUtils.isEmpty(mInvitedId)) {
        ToastUtils.show("骑阅邀请号不能为空");
        return;
    }
    ApiUtils.verifyRideReadId(mInvitedId, new BaseCallback<BaseModel<DefJsonResult>>() {

        @Override
        protected void onSuccess(BaseModel<DefJsonResult> model) throws Exception {
            showCodeView();
            // 申请发送短信权限
            PermissionUtils permission = new PermissionUtils(getActivity());
            permission.grantPermission(getActivity(), Manifest.permission.READ_PHONE_STATE);
        // permission.grantPermission(getActivity(), Manifest.permission.SEND_SMS);
        }
    });
}
Also used : DefJsonResult(com.rideread.rideread.data.result.DefJsonResult) BaseModel(com.rideread.rideread.function.net.retrofit.BaseModel) PermissionUtils(com.rideread.rideread.common.util.PermissionUtils)

Aggregations

PermissionUtils (com.rideread.rideread.common.util.PermissionUtils)3 Point (android.graphics.Point)1 Bundle (android.os.Bundle)1 Editable (android.text.Editable)1 TextWatcher (android.text.TextWatcher)1 OnClick (butterknife.OnClick)1 AMap (com.amap.api.maps.AMap)1 CameraPosition (com.amap.api.maps.model.CameraPosition)1 LatLng (com.amap.api.maps.model.LatLng)1 MyLocationStyle (com.amap.api.maps.model.MyLocationStyle)1 LatLonPoint (com.amap.api.services.core.LatLonPoint)1 WeakHandler (com.badoo.mobile.util.WeakHandler)1 DefJsonResult (com.rideread.rideread.data.result.DefJsonResult)1 MapMoment (com.rideread.rideread.data.result.MapMoment)1 Moment (com.rideread.rideread.data.result.Moment)1 BaseModel (com.rideread.rideread.function.net.retrofit.BaseModel)1