Search in sources :

Example 1 with WeakHandler

use of com.badoo.mobile.util.WeakHandler 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 WeakHandler

use of com.badoo.mobile.util.WeakHandler in project ride-read-android by Ride-Read.

the class SettingActivity method initView.

@Override
public void initView() {
    new TitleBuilder(this).setTitleText(R.string.setting).IsBack(true).setLeftOnClickListener(v -> finish()).build();
    mHandler = new WeakHandler();
    countCache();
}
Also used : Fresco(com.facebook.drawee.backends.pipeline.Fresco) UserUtils(com.rideread.rideread.common.util.UserUtils) SwitchButton(com.kyleduo.switchbutton.SwitchButton) ConfirmDialogFragment(com.rideread.rideread.common.dialog.ConfirmDialogFragment) BaseCallback(com.rideread.rideread.function.net.retrofit.BaseCallback) TitleBuilder(com.rideread.rideread.common.util.TitleBuilder) R(com.rideread.rideread.R) BaseActivity(com.rideread.rideread.common.base.BaseActivity) File(java.io.File) OnClick(butterknife.OnClick) BindView(butterknife.BindView) TextView(android.widget.TextView) View(android.view.View) DefJsonResult(com.rideread.rideread.data.result.DefJsonResult) WeakHandler(com.badoo.mobile.util.WeakHandler) BaseModel(com.rideread.rideread.function.net.retrofit.BaseModel) FrescoApp(com.rideread.rideread.rrapp.FrescoApp) ApiUtils(com.rideread.rideread.function.net.retrofit.ApiUtils) AppUtils(com.rideread.rideread.common.util.AppUtils) FileUtils(com.rideread.rideread.common.util.FileUtils) WeakHandler(com.badoo.mobile.util.WeakHandler) TitleBuilder(com.rideread.rideread.common.util.TitleBuilder)

Example 3 with WeakHandler

use of com.badoo.mobile.util.WeakHandler in project ride-read-android by Ride-Read.

the class SplashActivity method initView.

@Override
public void initView() {
    // TODO 后期需要请求广告页面,再替换但前页面显示
    if (0 != UserUtils.getUid()) {
        mHandler = new WeakHandler();
        // 判断是否已经登录,已登录闪屏后进入主页
        mHandler.postDelayed(() -> {
            // ObjectAnimator.ofFloat(mImgSplashAd, "alpha", 0f, 1f).setDuration(1200l).start();
            startActivity(new Intent(SplashActivity.this, MainActivity.class));
            finish();
        }, 2000l);
    } else {
        startActivity(new Intent(SplashActivity.this, LoginActivity.class));
        finish();
    }
// todo 这里申请权限有跳转不当的问题,暂时先注释
// String[] permission = {Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.READ_PHONE_STATE};
// requestPermission(permission, 0x0001);
}
Also used : WeakHandler(com.badoo.mobile.util.WeakHandler) Intent(android.content.Intent) MainActivity(com.rideread.rideread.module.main.MainActivity)

Aggregations

WeakHandler (com.badoo.mobile.util.WeakHandler)3 Intent (android.content.Intent)1 Point (android.graphics.Point)1 Bundle (android.os.Bundle)1 Editable (android.text.Editable)1 TextWatcher (android.text.TextWatcher)1 View (android.view.View)1 TextView (android.widget.TextView)1 BindView (butterknife.BindView)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 Fresco (com.facebook.drawee.backends.pipeline.Fresco)1 SwitchButton (com.kyleduo.switchbutton.SwitchButton)1 R (com.rideread.rideread.R)1 BaseActivity (com.rideread.rideread.common.base.BaseActivity)1 ConfirmDialogFragment (com.rideread.rideread.common.dialog.ConfirmDialogFragment)1