1.1.6需求
This commit is contained in:
@@ -13,7 +13,9 @@ import java.util.List;
|
||||
*/
|
||||
interface IOnlineCarPanelView extends IView {
|
||||
|
||||
void renderOnlineCarList( List< MarkerOnlineCar > onlineCars );
|
||||
void showLoading(boolean visible);
|
||||
|
||||
void renderOnlineCarList( List< MarkerOnlineCar > onlineCars, double lon, double lat );
|
||||
|
||||
void renderEmptyUi( OnlineCarStrategy strategy );
|
||||
|
||||
|
||||
@@ -33,9 +33,13 @@ import java.util.List;
|
||||
class OnlineCarPanelAdapter extends RecyclerView.Adapter< OnlineCarPanelAdapter.VH > {
|
||||
|
||||
private List< MarkerOnlineCar > mDatums;
|
||||
private double mToLon;
|
||||
private double mToLat;
|
||||
|
||||
public OnlineCarPanelAdapter( List< MarkerOnlineCar > mDatums ) {
|
||||
public OnlineCarPanelAdapter( List< MarkerOnlineCar > mDatums, double mToLon, double mToLat ) {
|
||||
this.mDatums = mDatums;
|
||||
this.mToLon = mToLon;
|
||||
this.mToLat = mToLat;
|
||||
}
|
||||
|
||||
public void setDatums( List< MarkerOnlineCar > mDatums ) {
|
||||
@@ -51,7 +55,7 @@ class OnlineCarPanelAdapter extends RecyclerView.Adapter< OnlineCarPanelAdapter.
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder( @NonNull OnlineCarPanelAdapter.VH holder, int position ) {
|
||||
holder.bind( mDatums.get( position ) );
|
||||
holder.bind( mDatums.get( position ), mToLon, mToLat );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -77,26 +81,22 @@ class OnlineCarPanelAdapter extends RecyclerView.Adapter< OnlineCarPanelAdapter.
|
||||
detail = itemView.findViewById( R.id.module_services_id_panel_item_detail );
|
||||
}
|
||||
|
||||
public void bind( MarkerOnlineCar car ) {
|
||||
public void bind( MarkerOnlineCar car, double lon, double lat ) {
|
||||
RequestOptions options = new RequestOptions().circleCrop().placeholder( R.drawable.module_common_default_user_head ).error( R.drawable.module_common_default_user_head );
|
||||
GlideApp.with( itemView.getContext() ).asBitmap().apply( options ).load( car.getUserInfo().getUserHead() ).into( new SkinAbleBitmapTarget( avatar, options ) );
|
||||
nickname.setText( car.getUserInfo().getUserName() );
|
||||
String content = getDistanceStr( car.getLocation() );
|
||||
String content = getDistanceStr( car.getLocation(), lon, lat );
|
||||
distance.setText( content );
|
||||
detail.setOnClickListener( view -> {
|
||||
MogoApisHandler.getInstance().getApis().getAnalyticsApi().track( "Mogoer_List_click", null );
|
||||
} );
|
||||
}
|
||||
|
||||
private String getDistanceStr( MarkerLocation location ) {
|
||||
MogoLocation mogoLocation = MarkerServiceHandler.getApis().getMapServiceApi().getSingletonLocationClient( itemView.getContext() ).getLastKnowLocation();
|
||||
private String getDistanceStr( MarkerLocation location, double lon, double lat ) {
|
||||
if ( location == null ) {
|
||||
return "";
|
||||
return "未知";
|
||||
}
|
||||
if ( mogoLocation == null ) {
|
||||
return "";
|
||||
}
|
||||
float distance = Utils.calculateLineDistance( location.getLon(), location.getLat(), mogoLocation.getLongitude(), mogoLocation.getLatitude() );
|
||||
float distance = Utils.calculateLineDistance( location.getLon(), location.getLat(), lon, lat );
|
||||
if ( distance >= 1000 ) {
|
||||
return String.format( "%.1fKM", distance / 1000 );
|
||||
} else {
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.mogo.module.service.onlinecar.panel;
|
||||
|
||||
import android.view.View;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
@@ -26,9 +28,15 @@ import java.util.Map;
|
||||
public class OnlineCarPanelFragment extends MvpFragment< IOnlineCarPanelView, OnlineCarPanelPresenter > implements IOnlineCarPanelView {
|
||||
|
||||
private RecyclerView mList;
|
||||
private View mRefreshPanel;
|
||||
private View mErrorPanel;
|
||||
|
||||
private View mRefreshPanel;
|
||||
private TextView mEmptyTip;
|
||||
private View m20KMStrategy;
|
||||
private View m40KMStrategy;
|
||||
|
||||
private ProgressBar mLoading;
|
||||
|
||||
private OnlineCarPanelAdapter mOnlineCarPanelAdapter;
|
||||
|
||||
@Override
|
||||
@@ -44,8 +52,34 @@ public class OnlineCarPanelFragment extends MvpFragment< IOnlineCarPanelView, On
|
||||
mList = findViewById( R.id.module_services_id_recycler_view );
|
||||
mRefreshPanel = findViewById( R.id.module_services_id_load_strategy_container );
|
||||
mErrorPanel = findViewById( R.id.module_services_id_error_container );
|
||||
m20KMStrategy = findViewById( R.id.module_services_id_20Km_radius );
|
||||
m40KMStrategy = findViewById( R.id.module_services_id_40Km_radius );
|
||||
mEmptyTip = findViewById( R.id.module_services_empty_tip );
|
||||
mLoading = findViewById( R.id.module_services_id_loading );
|
||||
|
||||
mList.setLayoutManager( new LinearLayoutManager( getContext(), LinearLayoutManager.VERTICAL, false ) );
|
||||
|
||||
m20KMStrategy.setOnClickListener( view -> {
|
||||
mPresenter.nextStrategy();
|
||||
} );
|
||||
m40KMStrategy.setOnClickListener( view -> {
|
||||
mPresenter.nextStrategy();
|
||||
} );
|
||||
mErrorPanel.setOnClickListener( view -> {
|
||||
mPresenter.loadOnlineCar();
|
||||
} );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showLoading( boolean visible ) {
|
||||
if ( visible ) {
|
||||
mRefreshPanel.setVisibility( View.GONE );
|
||||
mList.setVisibility( View.GONE );
|
||||
mErrorPanel.setVisibility( View.GONE );
|
||||
mLoading.setVisibility( View.VISIBLE );
|
||||
} else {
|
||||
mLoading.setVisibility( View.GONE );
|
||||
}
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@@ -55,12 +89,13 @@ public class OnlineCarPanelFragment extends MvpFragment< IOnlineCarPanelView, On
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderOnlineCarList( List< MarkerOnlineCar > onlineCars ) {
|
||||
public void renderOnlineCarList( List< MarkerOnlineCar > onlineCars, double lon, double lat ) {
|
||||
mRefreshPanel.setVisibility( View.GONE );
|
||||
mErrorPanel.setVisibility( View.GONE );
|
||||
mList.setVisibility( View.VISIBLE );
|
||||
mLoading.setVisibility( View.GONE );
|
||||
if ( mOnlineCarPanelAdapter == null ) {
|
||||
mOnlineCarPanelAdapter = new OnlineCarPanelAdapter( onlineCars );
|
||||
mOnlineCarPanelAdapter = new OnlineCarPanelAdapter( onlineCars, lon, lat );
|
||||
mList.setAdapter( mOnlineCarPanelAdapter );
|
||||
} else {
|
||||
mOnlineCarPanelAdapter.setDatums( onlineCars );
|
||||
@@ -76,6 +111,24 @@ public class OnlineCarPanelFragment extends MvpFragment< IOnlineCarPanelView, On
|
||||
mErrorPanel.setVisibility( View.GONE );
|
||||
mList.setVisibility( View.GONE );
|
||||
mRefreshPanel.setVisibility( View.VISIBLE );
|
||||
mLoading.setVisibility( View.GONE );
|
||||
|
||||
if ( strategy == null ) {
|
||||
m20KMStrategy.setVisibility( View.GONE );
|
||||
m40KMStrategy.setVisibility( View.GONE );
|
||||
mEmptyTip.setText( getString( R.string.module_services_online_car_panel_empty_tmpl, OnlineCarStrategy.Strategy3.getRadiusKM() ) );
|
||||
} else {
|
||||
switch ( strategy ) {
|
||||
case Strategy3:
|
||||
m20KMStrategy.setVisibility( View.GONE );
|
||||
m40KMStrategy.setVisibility( View.GONE );
|
||||
case Strategy2:
|
||||
m20KMStrategy.setVisibility( View.GONE );
|
||||
case Default:
|
||||
break;
|
||||
}
|
||||
mEmptyTip.setText( getString( R.string.module_services_online_car_panel_empty_tmpl, strategy.getRadiusKM() ) );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -83,12 +136,14 @@ public class OnlineCarPanelFragment extends MvpFragment< IOnlineCarPanelView, On
|
||||
mList.setVisibility( View.GONE );
|
||||
mRefreshPanel.setVisibility( View.GONE );
|
||||
mErrorPanel.setVisibility( View.VISIBLE );
|
||||
mLoading.setVisibility( View.GONE );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderErrorUi() {
|
||||
mList.setVisibility( View.GONE );
|
||||
mRefreshPanel.setVisibility( View.GONE );
|
||||
mLoading.setVisibility( View.GONE );
|
||||
mErrorPanel.setVisibility( View.VISIBLE );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,6 +25,8 @@ class OnlineCarPanelPresenter extends Presenter< IOnlineCarPanelView > implement
|
||||
private RefreshModel mRefreshModel;
|
||||
private OnlineCarStrategy mStrategy;
|
||||
private NavigationTargetInfo mNavigationTargetInfo;
|
||||
private Double mToLat;
|
||||
private Double mToLon;
|
||||
|
||||
public OnlineCarPanelPresenter( IOnlineCarPanelView view ) {
|
||||
super( view );
|
||||
@@ -44,14 +46,24 @@ class OnlineCarPanelPresenter extends Presenter< IOnlineCarPanelView > implement
|
||||
loadOnlineCar();
|
||||
}
|
||||
|
||||
public void nextStrategy() {
|
||||
if ( mStrategy != null ) {
|
||||
mStrategy = mStrategy.getNext();
|
||||
}
|
||||
if ( mStrategy != null ) {
|
||||
loadOnlineCar();
|
||||
}
|
||||
}
|
||||
|
||||
public void loadOnlineCar() {
|
||||
if ( mNavigationTargetInfo == null ) {
|
||||
return;
|
||||
}
|
||||
mView.showLoading( true );
|
||||
try {
|
||||
double toLat = Double.valueOf( mNavigationTargetInfo.getToPoiLatitude() );
|
||||
double toLon = Double.valueOf( mNavigationTargetInfo.getToPoiLongitude() );
|
||||
mRefreshModel.queryOnLineCarWithRoute( new MogoLatLng( toLat, toLon ),
|
||||
mToLat = Double.valueOf( mNavigationTargetInfo.getToPoiLatitude() );
|
||||
mToLon = Double.valueOf( mNavigationTargetInfo.getToPoiLongitude() );
|
||||
mRefreshModel.queryOnLineCarWithRoute( new MogoLatLng( mToLat, mToLon ),
|
||||
false,
|
||||
false,
|
||||
mStrategy.getRadius(),
|
||||
@@ -66,14 +78,13 @@ class OnlineCarPanelPresenter extends Presenter< IOnlineCarPanelView > implement
|
||||
|
||||
@Override
|
||||
public void onSuccess( MarkerResponse o ) {
|
||||
if ( o == null || o.getResult() == null ) {
|
||||
mView.renderErrorUi();
|
||||
if ( o == null
|
||||
|| o.getResult() == null
|
||||
|| o.getResult().getOnlineCar() == null
|
||||
|| o.getResult().getOnlineCar().isEmpty() ) {
|
||||
mView.renderEmptyUi( mStrategy );
|
||||
} else {
|
||||
if ( o.getResult().getOnlineCar() == null || o.getResult().getOnlineCar().isEmpty() ) {
|
||||
mView.renderEmptyUi( mStrategy );
|
||||
} else {
|
||||
mView.renderOnlineCarList( o.getResult().getOnlineCar() );
|
||||
}
|
||||
mView.renderOnlineCarList( o.getResult().getOnlineCar(), mToLon, mToLat );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,4 +24,12 @@ enum OnlineCarStrategy {
|
||||
public int getRadius() {
|
||||
return radius;
|
||||
}
|
||||
|
||||
public int getRadiusKM() {
|
||||
return radius / 1000;
|
||||
}
|
||||
|
||||
public OnlineCarStrategy getNext() {
|
||||
return next;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user