为了账号安全,请及时绑定邮箱和手机立即绑定

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

标签:
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人点赞

若觉得本文不错,就分享一下吧!

评论

作者其他优质文章

正在加载中
感谢您的支持,我会继续努力的~
扫码打赏,你说多少就多少
赞赏金额会直接到老师账户
支付方式
打开微信扫一扫,即可进行扫码打赏哦
今天注册有机会得

100积分直接送

付费专栏免费学

大额优惠券免费领

立即参与 放弃机会
意见反馈 帮助中心 APP下载
官方微信

举报

0/150
提交
取消