添加BaseOchFragment
This commit is contained in:
87
OCH/mogo-och/src/main/java/com/mogo/och/BaseOchFragment.java
Normal file
87
OCH/mogo-och/src/main/java/com/mogo/och/BaseOchFragment.java
Normal file
@@ -0,0 +1,87 @@
|
||||
package com.mogo.och;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.CheckedTextView;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import com.mogo.commons.mvp.IView;
|
||||
import com.mogo.commons.mvp.MvpFragment;
|
||||
import com.mogo.commons.mvp.Presenter;
|
||||
import com.mogo.och.view.SlidePanelView;
|
||||
|
||||
/**
|
||||
* 网约车基础Fragment,主要负责布局通用界面,处理站点面板和通话面板互斥情况
|
||||
*
|
||||
* @author tongchenfei
|
||||
*/
|
||||
public abstract class BaseOchFragment<V extends IView, P extends Presenter<V>> extends MvpFragment<V, P> {
|
||||
private SlidePanelView slidePanelView;
|
||||
private TextView tvNotice;
|
||||
private CheckedTextView ctvAutopilotStatus;
|
||||
private FrameLayout flStationPanelContainer;
|
||||
|
||||
private final SlidePanelView.OnSlidePanelMoveToEndListener onSlideToEndListener = () -> {
|
||||
// 此处做一个代理,处理一下共有情况
|
||||
hideSlidePanel();
|
||||
hideNotice();
|
||||
if (getSlidePanelOnEndListener() != null) {
|
||||
getSlidePanelOnEndListener().moveToEnd();
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.module_mogo_och_base_fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initViews() {
|
||||
slidePanelView = findViewById(R.id.module_mogo_och_slide_panel);
|
||||
tvNotice = findViewById(R.id.module_mogo_och_notice);
|
||||
ctvAutopilotStatus = findViewById(R.id.module_mogo_och_autopilot_status);
|
||||
flStationPanelContainer = findViewById(R.id.module_mogo_och_station_panel_container);
|
||||
|
||||
LayoutInflater.from(getContext()).inflate(getStationPanelViewId(), flStationPanelContainer);
|
||||
slidePanelView.setOnSlidePanelMoveToEndListener(onSlideToEndListener);
|
||||
}
|
||||
|
||||
public void showSlidePanle(String text) {
|
||||
slidePanelView.setText(text);
|
||||
slidePanelView.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
public void hideSlidePanel(){
|
||||
slidePanelView.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
public void showNotice(String notice) {
|
||||
tvNotice.setText(notice);
|
||||
tvNotice.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
public void hideNotice(){
|
||||
tvNotice.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
/**
|
||||
* 改变自动驾驶状态
|
||||
* @param isInAutopilot true - 在自动驾驶中 false - 不在自动驾驶中
|
||||
*/
|
||||
public void onAutopilotStatusChanged(boolean isInAutopilot) {
|
||||
ctvAutopilotStatus.setChecked(isInAutopilot);
|
||||
}
|
||||
|
||||
public SlidePanelView.OnSlidePanelMoveToEndListener getSlidePanelOnEndListener(){
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取站点面板view,在{@link #initViews()}时候添加到container中
|
||||
* @return 站点面板view
|
||||
*/
|
||||
public abstract int getStationPanelViewId();
|
||||
}
|
||||
Reference in New Issue
Block a user