opt switch logic

This commit is contained in:
lixiaopeng
2020-01-08 16:32:55 +08:00
parent 15557101c0
commit 64d6debe70
263 changed files with 7072 additions and 44 deletions

View File

@@ -37,6 +37,7 @@ import com.mogo.service.map.IMogoMapService;
import com.mogo.service.module.IMogoModuleLifecycle;
import com.mogo.tanlu.R;
import com.mogo.tanlu.model.event.MarkerInfo;
import com.mogo.tanlu.util.Utils;
import com.mogo.tanlu.video.FullMediaActivity;
import com.mogo.tanlu.video.SimpleCoverVideoPlayer;
import com.mogo.tanlu.view.AutoZoomInImageView;
@@ -51,6 +52,8 @@ import org.greenrobot.eventbus.ThreadMode;
import java.util.ArrayList;
import java.util.List;
import static com.mogo.tanlu.util.StringUitlKt.formatDate;
import static com.mogo.tanlu.util.Utils.handleDistance;
import static com.mogo.tanlu.video.VideoInitKt.initVideo;
/**
@@ -68,18 +71,16 @@ public class TanluCardViewFragment extends MvpFragment<IView, Presenter<IView>>
View.OnClickListener {
private static final String TAG = "liyz";
SimpleCoverVideoPlayer simpleCoverVideoPlayer;
AutoZoomInImageView autoZoomInImageView;
//map
private IMogoMarker mPoiMarker;
private IMogoMarkerManager mMarkerManager;
private IMogoMapService mMogoMapService;
//media
private GSYVideoOptionBuilder gsyVideoOptionBuilder = new GSYVideoOptionBuilder();
private String mVideoUrl = "http://ivi.bupt.edu.cn/hls/cctv1hd.m3u8";
private String mImageUrl = "https://oimagec4.ydstatic.com/image?id=-5397300958976572132&product=adpublish&w=520&h=347";
SimpleCoverVideoPlayer simpleCoverVideoPlayer;
AutoZoomInImageView autoZoomInImageView;
private IMogoImageloader mogoImageloader;
private TextView mPreviousTv;
private TextView mNextTv;
@@ -91,7 +92,8 @@ public class TanluCardViewFragment extends MvpFragment<IView, Presenter<IView>>
private TextView mTimeTv;
private List<MarkerExploreWay> markerExploreWayList = new ArrayList<>();
private int currentPosition = -1; //卡片媒体当前位置
private int currentPosition = 0; //卡片媒体当前位置
private Bitmap mMarkerIcon;
@Override
@@ -128,7 +130,7 @@ public class TanluCardViewFragment extends MvpFragment<IView, Presenter<IView>>
@Override
public void onClick(View view) {
Logger.d(TAG, "simpleCoverVideoPlayer onClick -------> ");
FullMediaActivity.Companion.launch(getActivity(), mVideoUrl, "image", "东城区环球贸易中心", 1300000300);
FullMediaActivity.Companion.launch(getActivity(), mVideoUrl, mImageUrl, "东城区环球贸易中心", 1300000300);
}
});
@@ -155,34 +157,27 @@ public class TanluCardViewFragment extends MvpFragment<IView, Presenter<IView>>
int id = view.getId();
if (id == R.id.tv_previous_res) { //上一个
//判断是图片还是视频,第一个时,上一个不可点击
simpleCoverVideoPlayer.setVisibility(View.VISIBLE);
autoZoomInImageView.setVisibility(View.GONE);
gsyVideoOptionBuilder.setUrl(mVideoUrl).setCacheWithPlay(false).setPlayTag(TAG)
.build(simpleCoverVideoPlayer);
Logger.d(TAG, " tv_previous_res --1-> currentPosition =" + currentPosition);
if (currentPosition < 0) {
return;
}
currentPosition--;
Logger.d(TAG, " tv_previous_res --2-> currentPosition =" + currentPosition);
if (markerExploreWayList.size() > currentPosition) {
handleData(markerExploreWayList.get(currentPosition));
}
} else if (id == R.id.tv_next_res) { //下一个
//判断是图片还是视频,最后一个时,下一个不可点击
autoZoomInImageView.setVisibility(View.VISIBLE);
simpleCoverVideoPlayer.setVisibility(View.GONE);
mogoImageloader.downloadImage(getActivity(), mImageUrl, new IMogoImageLoaderListener() {
@Override
public void onStart() {
Logger.d(TAG, "onStart ------>");
}
Logger.d(TAG, " tv_next_res --1-> currentPosition =" + currentPosition);
if (currentPosition > markerExploreWayList.size()) { //TODO >=
return;
}
currentPosition++;
Logger.d(TAG, " tv_next_res --2-> currentPosition =" + currentPosition);
if (markerExploreWayList.size() > currentPosition) {
handleData(markerExploreWayList.get(currentPosition));
}
@Override
public void onCompleted(Bitmap bitmap) {
Logger.d(TAG, "onCompleted ------>");
autoZoomInImageView.setImageBitmap(bitmap);
//动画
handleImageAnimation();
}
@Override
public void onFailure(Exception e) {
Logger.e(TAG, "onFailure ------>" + e);
}
});
} else if (id == R.id.tv_main_empty) { //TODO 上报路况,逻辑
Logger.d(TAG, "tv_main_empty click -----> ");
@@ -213,6 +208,17 @@ public class TanluCardViewFragment extends MvpFragment<IView, Presenter<IView>>
public boolean onMarkerClicked(IMogoMarker marker) {
//点击marker以后确认他的位置然后点击下一个操作
MarkerExploreWay exploreWay = (MarkerExploreWay) marker.getObject();
handleData(exploreWay);
return true;
}
/**
* 通用的处理数据逻辑
*
* @param exploreWay
*/
private void handleData(MarkerExploreWay exploreWay) {
if (exploreWay != null && exploreWay.getFileType() != null) {
if (exploreWay.getFileType().equals("0")) { //图片
refreshPhotoData(exploreWay);
@@ -220,10 +226,8 @@ public class TanluCardViewFragment extends MvpFragment<IView, Presenter<IView>>
refreshVideoData(exploreWay);
}
} else {
Logger.e(TAG, "onMarkerClicked exploreWay == null ");
Logger.e(TAG, "handleData exploreWay == null ");
}
return true;
}
/**
@@ -239,7 +243,9 @@ public class TanluCardViewFragment extends MvpFragment<IView, Presenter<IView>>
}
String videoUrl = markerExploreWay.getItems().get(0).getUrl();
mAddressTv.setText(markerExploreWay.getAddr());
mDistanceTv.setText(handleDistance(markerExploreWay.getDistance()));
mTimeTv.setText(formatDate(markerExploreWay.getGenerateTime()));
//判断是图片还是视频,第一个时,上一个不可点击
simpleCoverVideoPlayer.setVisibility(View.VISIBLE);
autoZoomInImageView.setVisibility(View.GONE);
@@ -261,6 +267,9 @@ public class TanluCardViewFragment extends MvpFragment<IView, Presenter<IView>>
return;
}
mAddressTv.setText(markerExploreWay.getAddr());
mDistanceTv.setText(handleDistance(markerExploreWay.getDistance()));
mTimeTv.setText(formatDate(markerExploreWay.getGenerateTime()));
String thumbnailUrl = markerExploreWay.getItems().get(0).getThumbnail();
Logger.d(TAG, "refreshPhotoData thumbnailUrl ------>" + thumbnailUrl);
autoZoomInImageView.setVisibility(View.VISIBLE);
@@ -284,7 +293,6 @@ public class TanluCardViewFragment extends MvpFragment<IView, Presenter<IView>>
});
}
@NonNull
@Override
protected Presenter createPresenter() {
@@ -376,7 +384,6 @@ public class TanluCardViewFragment extends MvpFragment<IView, Presenter<IView>>
}
}
@Override
public void onLocationChanged(MogoLocation location) {
// if (location.getErrCode() == 0) {
@@ -386,7 +393,6 @@ public class TanluCardViewFragment extends MvpFragment<IView, Presenter<IView>>
// }
}
@Override
public void onMapClick(MogoLatLng latLng) {
@@ -415,9 +421,6 @@ public class TanluCardViewFragment extends MvpFragment<IView, Presenter<IView>>
TanluServiceHandler.getLocationClient().removeLocationListener(this);
}
private Bitmap mMarkerIcon;
/**
* 接收到对应数据打点
*
@@ -425,7 +428,7 @@ public class TanluCardViewFragment extends MvpFragment<IView, Presenter<IView>>
*/
@Subscribe(threadMode = ThreadMode.MAIN)
public void onMarkerInfo(final MarkerInfo event) {
mMarkerIcon = BitmapFactory.decodeResource( getResources(), R.drawable.ic_search_poi_location );
mMarkerIcon = BitmapFactory.decodeResource(getResources(), R.drawable.ic_search_poi_location);
mogoImageloader.downloadImage(getActivity(), event.imageUrl, new IMogoImageLoaderListener() {
@Override
public void onStart() {
@@ -451,7 +454,6 @@ public class TanluCardViewFragment extends MvpFragment<IView, Presenter<IView>>
Logger.e(TAG, "onMarkerInfo onFailure -----E->" + e);
}
});
}

View File

@@ -1,6 +1,7 @@
package com.mogo.tanlu.util
import android.text.format.DateFormat
import java.text.DecimalFormat
const val format = "yy/MM/dd kk:mm:ss"
@@ -14,4 +15,17 @@ fun convertVar(param: Any?): Any? {
} else {
param
}
}
}
//处理距离大于1000时四舍五入保留一位小数
fun handleDistances(distance: Int): String {
if (distance < 1000) {
return distance.toString() + "M"
} else {
var floatDistance = distance.toFloat()
val df = DecimalFormat("0.0")
val transformDistance = floatDistance / 1000
return (df.format(transformDistance)).toString() + "KM"
}
}

View File

@@ -0,0 +1,23 @@
package com.mogo.tanlu.util;
import java.text.DecimalFormat;
/**
* @author lixiaopeng
* @description
* @since 2020-01-08
*/
public class Utils {
//处理距离大于1000时四舍五入保留一位小数
public static String handleDistance(long distance) {
if (distance < 1000) {
return distance + "M";
} else {
DecimalFormat df = new DecimalFormat("0.0");
double transformDistance = distance / 1000;
return (df.format(transformDistance)) + "KM";
}
}
}