use of com.rideread.rideread.data.result.Moment 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.rideread.rideread.data.result.Moment in project ride-read-android by Ride-Read.
the class PersonalityMapActivity method initView.
@Override
public void initView() {
mMoments = new ArrayList<>();
mAMap = mMapView.getMap();
// 实例化UiSettings类对象
mUiSettings = mAMap.getUiSettings();
mUiSettings.setZoomControlsEnabled(false);
mAMap.moveCamera(CameraUpdateFactory.changeLatLng(AMapLocationUtils.sLatLng));
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, isAttent ? MomentDetailActivity.USER_TYPE_ATTENTED : MomentDetailActivity.USER_TYPE_NEARBY);
gotoActivity(MomentDetailActivity.class, bundle);
}
return false;
});
mCurUid = getIntent().getIntExtra(USER_ID, UserUtils.getUid());
loadUserMoments();
mAMap.setOnCameraChangeListener(new AMap.OnCameraChangeListener() {
@Override
public void onCameraChange(CameraPosition cameraPosition) {
}
@Override
public void onCameraChangeFinish(CameraPosition cameraPosition) {
// textCurrentLevel.setText("当前地图的缩放级别为: " + cameraPosition.zoom);
Log.d("yayiji", "当前地图的缩放级别为: " + cameraPosition.zoom);
}
});
}
use of com.rideread.rideread.data.result.Moment in project ride-read-android by Ride-Read.
the class ProfileFragment method onRefreshMyMap.
@Subscribe(threadMode = MAIN, sticky = true)
public void onRefreshMyMap(RefreshMyMapEvent event) {
EventBus.getDefault().removeStickyEvent(RefreshMyMapEvent.class);
List<Moment> moments = event.mMoments;
if (!ListUtils.isEmpty(moments)) {
mAMap.clear();
for (Moment momentItem : moments) {
addSignInMarker(new LatLng(momentItem.getLatitude(), momentItem.getLongitude()));
}
}
}
use of com.rideread.rideread.data.result.Moment in project ride-read-android by Ride-Read.
the class UserMomentsAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(RecyclerView.ViewHolder tHolder, int position) {
if (TYPE_ITEM == tHolder.getItemViewType()) {
Moment moment = mMomentList.get(position);
MomentViewHolder holder = (MomentViewHolder) tHolder;
holder.mClMomentLayout.setOnClickListener(v -> {
Bundle bundle = new Bundle();
bundle.putInt(MomentDetailActivity.SELECTED_MOMENT_MID, moment.getMid());
mActivity.gotoActivity(MomentDetailActivity.class, bundle);
});
String msg = moment.getMsg();
if (!TextUtils.isEmpty(msg)) {
holder.mTvMomentText.setText(msg);
holder.mTvMomentText.setVisibility(View.VISIBLE);
} else {
holder.mTvMomentText.setVisibility(View.GONE);
}
List<String> pictures = moment.getPictures();
if (!ListUtils.isEmpty(pictures)) {
holder.mNineGridImgView.setAdapter(adapter);
holder.mNineGridImgView.setImagesData(pictures);
holder.mNineGridImgView.setVisibility(View.VISIBLE);
} else {
holder.mNineGridImgView.setVisibility(View.GONE);
}
holder.mTvTime.setText(getFriendlyTimeSpanByNow(moment.getCreatedAt()));
List<ThumbsUpUser> thumbsUp = moment.getThumbsUp();
int likeCount = ListUtils.isEmpty(thumbsUp) ? 0 : thumbsUp.size();
holder.mTvLikeCount.setText(likeCount + "");
List<Comment> comments = moment.getComment();
int commentSize = ListUtils.isEmpty(comments) ? 0 : comments.size();
holder.mTvCommentCount.setText(commentSize + "");
// TODO
holder.mTvLocInfo.setText(moment.getMomentLocation() + " 距离我" + moment.getDistanceString());
holder.setIsRecyclable(false);
} else if (TYPE_HEADER == tHolder.getItemViewType()) {
} else {
// 最后一个位置
}
}
use of com.rideread.rideread.data.result.Moment in project ride-read-android by Ride-Read.
the class MomentsAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(RecyclerView.ViewHolder tHolder, int position) {
if (TYPE_ITEM == tHolder.getItemViewType()) {
Moment moment = mMomentList.get(position);
MomentUser user = moment.getUser();
boolean isAttent = 0 == user.getIsFollowed();
MomentViewHolder holder = (MomentViewHolder) tHolder;
holder.mClMomentLayout.setOnClickListener(v -> {
Bundle bundle = new Bundle();
bundle.putInt(MomentDetailActivity.SELECTED_MOMENT_MID, moment.getMid());
bundle.putInt(MomentDetailActivity.USER_TYPE, isAttent ? MomentDetailActivity.USER_TYPE_ATTENTED : MomentDetailActivity.USER_TYPE_NEARBY);
mActivity.gotoActivity(MomentDetailActivity.class, bundle);
});
ImgLoader.getInstance().displayImage(user.getFaceUrl(), holder.mImgAvatar);
holder.mTvName.setText(user.getUsername());
holder.mImgAvatar.setOnClickListener(v -> {
Bundle bundle = new Bundle();
bundle.putInt(UserMomentsActivity.SELECTED_UID, user.getUid());
bundle.putString(UserMomentsActivity.SELECTED_USERNAME, user.getUsername());
mActivity.gotoActivity(UserMomentsActivity.class, bundle);
});
String msg = moment.getMsg();
if (!TextUtils.isEmpty(msg)) {
holder.mTvMomentText.setText(msg);
holder.mTvMomentText.setVisibility(View.VISIBLE);
} else {
holder.mTvMomentText.setVisibility(View.GONE);
}
List<String> pictures = moment.getPictures();
if (!ListUtils.isEmpty(pictures)) {
holder.mNineGridImgView.setAdapter(adapter);
holder.mNineGridImgView.setImagesData(pictures);
holder.mNineGridImgView.setVisibility(View.VISIBLE);
} else {
holder.mNineGridImgView.setVisibility(View.GONE);
}
holder.mBtnAttention.setBackgroundResource(isAttent ? R.drawable.icon_attented : R.drawable.icon_attention);
holder.mBtnAttention.setOnClickListener(v -> {
if (isAttent) {
ApiUtils.unfollow(user.getUid(), new BaseCallback<BaseModel<DefJsonResult>>() {
@Override
protected void onSuccess(BaseModel<DefJsonResult> model) throws Exception {
holder.mBtnAttention.setBackgroundResource(R.drawable.icon_attention);
user.setIsFollowed(-1);
}
});
} else {
ApiUtils.follow(user.getUid(), new BaseCallback<BaseModel<DefJsonResult>>() {
@Override
protected void onSuccess(BaseModel<DefJsonResult> model) throws Exception {
holder.mBtnAttention.setBackgroundResource(R.drawable.icon_attented);
user.setIsFollowed(1);
}
});
}
});
List<ThumbsUpUser> thumbsUp = moment.getThumbsUp();
int likeCount = ListUtils.isEmpty(thumbsUp) ? 0 : thumbsUp.size();
holder.mBtnLike.setOnClickListener(v -> ApiUtils.updateThumbsUp(moment.getMid(), new BaseCallback<BaseModel<DefJsonResult>>() {
@Override
protected void onSuccess(BaseModel<DefJsonResult> model) throws Exception {
ToastUtils.show("成功点赞");
holder.mTvLikeCount.setText((likeCount + 1) + "");
}
}));
holder.mTvTime.setText(getFriendlyTimeSpanByNow(moment.getCreatedAt()));
holder.mTvLikeCount.setText(likeCount + "");
List<Comment> comments = moment.getComment();
int commentSize = ListUtils.isEmpty(comments) ? 0 : comments.size();
holder.mTvCommentCount.setText(commentSize + "");
// TODO
holder.mTvLocInfo.setText(moment.getMomentLocation() + " 距离我" + moment.getDistanceString());
holder.setIsRecyclable(false);
} else if (TYPE_HEADER == tHolder.getItemViewType()) {
} else {
// 最后一个位置
}
}
Aggregations