手记

android 开发:仿照微信 发送本人位置(基于百度地图)(后篇)

最后是view展示类,LocationBaiduActivity ,主要是展示了数据

public class LocationBaiduActivity extends BaseActivity
        implements LocationBaiduContract.View {
    private TextView sendButton;
    private LocationBaiduContract.Presenter mPresenter;
    MapView mMapView = null;

    private Button btnMyLocation;
    private View pinInfoPanel;
    private TextView pinInfoTextView;

    private RecyclerView recyclerView;
    private EditText search_text;
    private TextView dileber_search_editext_button;
    private TextView dileber_search_editext_delete;
    LocationAdapter locationAdapter = null;

    @Override
    protected int layoutViewId() {
        return R.layout.activity_location_baidu;
    }

    @Override
    protected void initView() {
        new LocationBaiduPresenter(this);
        UToolBar uToolBar = new UToolBar();
        uToolBar.setTitleId(R.string.jcb_local_activity);
        uToolBar.setBackground(R.color.black);
        setToolBar(R.id.toolbar,uToolBar);
        //获取地图控件引用
        mMapView = getView(R.id.bmapView);
        btnMyLocation = getView(R.id.my_location);
        pinInfoPanel = getView(R.id.location_info);
        recyclerView = getView(R.id.search_list);
        recyclerView.setLayoutManager(new LinearLayoutManager(this));
        pinInfoTextView = getView(R.id.marker_address);
        sendButton =  getView(R.id.action_bar_right_clickable_textview);

        //发送按钮
        sendButton.setText(R.string.send);
        sendButton.setOnClickListener(mPresenter);
        sendButton.setVisibility(View.INVISIBLE);

        btnMyLocation.setOnClickListener(mPresenter);

        mPresenter.initMap();

        locationAdapter = new LocationAdapter(null,mPresenter);
        recyclerView.setAdapter(locationAdapter);
        recyclerView.addItemDecoration(new RecycleViewDivider(this, LinearLayoutManager.VERTICAL));
        search_text = getView(R.id.dileber_search_editext_edittext);
        search_text.setOnEditorActionListener(mPresenter);
        dileber_search_editext_delete = getView(R.id.dileber_search_editext_delete);
        dileber_search_editext_delete.setOnClickListener(mPresenter);
        dileber_search_editext_button = getView(R.id.dileber_search_editext_button);
        dileber_search_editext_button.setOnClickListener(mPresenter);
        search_text.addTextChangedListener(mPresenter);
    }

    public interface LocationOnCreateItem{
        void onItemClick(PoiInfo poiInfo);
    }

    @Override
    protected void onPause() {
        mMapView.onPause();
        super.onPause();
    }

    @Override
    protected void onResume() {
        mMapView.onResume();
        super.onResume();
        mPresenter.start();
    }

    @Override
    protected void onDestroy() {
        mPresenter.onDestroy();
        mMapView.onDestroy();
        mMapView = null;
        super.onDestroy();
    }

    @Override
    public void setAddress(String adress) {
        pinInfoTextView.setText(adress);
    }

    @Override
    public void refData(List<PoiInfo> poiInfoList) {
        locationAdapter.refData2(poiInfoList);
    }

    @Override
    public void sendButtonStatus(int status) {
        sendButton.setVisibility(status);
    }

    @Override
    public void pinInfoPanelStatus(int status) {
        pinInfoPanel.setVisibility(status);
    }

    @Override
    public MapView getMapView() {
        return mMapView;
    }

    @Override
    public void keybordState(boolean show) {
        //关闭键盘
        if(!show){
            TKeybord.closeKeybord(search_text,LocationBaiduActivity.this);
        }else{
            TKeybord.openKeybord(search_text,LocationBaiduActivity.this);
        }
    }

    @Override
    public void searchText(String text) {
        search_text.setText(text);
    }

    @Override
    public void setPinInfoText(String text) {
        pinInfoTextView.setText(text);
    }

    @Override
    public String getSearchText() {
        return search_text.getText().toString();
    }

    @Override
    public void deleteVisibility(int visiblility) {
        dileber_search_editext_delete.setVisibility(visiblility);
    }

    @Override
    public void setPresenter(LocationBaiduContract.Presenter presenter) {
        mPresenter = presenter;
    }

    @Override
    public void toast(String msg, int duration) {
        UUi.toast(LocationBaiduActivity.this, msg, Toast.LENGTH_LONG);
    }

    @Override
    public void showAlert(Integer type, String message) {

    }

    @Override
    public void loading() {

    }

    @Override
    public void loadDialogDismiss() {

    }

    @Override
    public void dialogOk(String content, DialogLinstener dialogLinstener) {

    }

    @Override
    public Context getContext() {
        return this;
    }

}

代码可能写的比较烦,大家完全可以将代码粘贴到项目中自己测试一下,再逐一弄懂。

1人推荐
随时随地看视频
慕课网APP

热门评论

写不下了,就拆成两个了

查看全部评论