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);
}
}
});
}
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();
}
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);
}
Aggregations