Skip to content

Commit

Permalink
手机号码归属地接口修改
Browse files Browse the repository at this point in the history
  • Loading branch information
maning0303 committed Oct 15, 2020
1 parent 1699427 commit bc55d80
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 23 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package com.maning.gankmm.bean.rolltools;

/**
* @author : maning
* @date : 2020-10-15
* @desc :
*/
public class MobileLocationResultBean extends RollToolsBaseBean {


/**
* data : {"mobile":"13227293721","province":"湖北","carrier":"湖北联通"}
*/

private DataEntity data;

public DataEntity getData() {
return data;
}

public void setData(DataEntity data) {
this.data = data;
}

public static class DataEntity {
/**
* mobile : 13227293721
* province : 湖北
* carrier : 湖北联通
*/

private String mobile;
private String province;
private String carrier;

public String getMobile() {
return mobile;
}

public void setMobile(String mobile) {
this.mobile = mobile;
}

public String getProvince() {
return province;
}

public void setProvince(String province) {
this.province = province;
}

public String getCarrier() {
return carrier;
}

public void setCarrier(String carrier) {
this.carrier = carrier;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.maning.gankmm.bean.rolltools.DictionaryResultBean;
import com.maning.gankmm.bean.rolltools.HistoryTodayBean;
import com.maning.gankmm.bean.rolltools.HolidaySingleResultBean;
import com.maning.gankmm.bean.rolltools.MobileLocationResultBean;
import com.maning.gankmm.bean.rolltools.RubbishTypeResultBean;
import com.maning.gankmm.bean.rolltools.WeatherFuturedaysResultBean;
import com.maning.gankmm.constant.Constants;
Expand Down Expand Up @@ -65,4 +66,13 @@ Call<RubbishTypeResultBean> getRubbishType(
@Query("name") String name
);

@Headers({
"app_id:" + Constants.ROLL_TOOLS_APP_ID,
"app_secret:" + Constants.ROLL_TOOLS_APP_SECRET
})
@GET("mobile_location/aim_mobile")
Call<MobileLocationResultBean> getMobileLocation(
@Query("mobile") String mobile
);

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.maning.gankmm.bean.rolltools.DictionaryResultBean;
import com.maning.gankmm.bean.rolltools.HistoryTodayBean;
import com.maning.gankmm.bean.rolltools.HolidaySingleResultBean;
import com.maning.gankmm.bean.rolltools.MobileLocationResultBean;
import com.maning.gankmm.bean.rolltools.RubbishTypeResultBean;
import com.maning.gankmm.bean.rolltools.WeatherFuturedaysResultBean;
import com.maning.gankmm.http.BuildApi;
Expand Down Expand Up @@ -63,5 +64,14 @@ public static void getRubbishType(String content, CommonHttpCallback<RubbishType
BuildApi.getRooltoolsAPIService().getRubbishType(content).enqueue(httpCallback);
}

/**
* 手机号码归属地查询
* @param phone
* @param httpCallback
*/
public static void getMobileLocation(String phone, CommonHttpCallback<MobileLocationResultBean> httpCallback) {
BuildApi.getRooltoolsAPIService().getMobileLocation(phone).enqueue(httpCallback);
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@

import com.maning.gankmm.R;
import com.maning.gankmm.bean.mob.MobItemEntity;
import com.maning.gankmm.bean.mob.MobPhoneAddressEntity;
import com.maning.gankmm.http.mob.MobApi;
import com.maning.gankmm.http.callback.MyCallBack;
import com.maning.gankmm.bean.rolltools.MobileLocationResultBean;
import com.maning.gankmm.http.callback.CommonHttpCallback;
import com.maning.gankmm.http.rolltools.RolltoolsApi;
import com.maning.gankmm.skin.SkinManager;
import com.maning.gankmm.ui.adapter.RecycleMobQueryAdapter;
import com.maning.gankmm.ui.base.BaseActivity;
Expand All @@ -22,7 +22,6 @@
import com.maning.gankmm.utils.MySnackbar;

import java.util.HashMap;
import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;
Expand Down Expand Up @@ -98,37 +97,27 @@ public void btnQuery() {
}

showProgressDialog("正在查询...");
MobApi.queryPhoneAddress(phoneNumber, 0x001, new MyCallBack() {
RolltoolsApi.getMobileLocation(phoneNumber, new CommonHttpCallback<MobileLocationResultBean>() {
@Override
public void onSuccess(int what, Object result) {
public void onSuccess(MobileLocationResultBean result) {
dissmissProgressDialog();
if (result != null) {
MobPhoneAddressEntity mobPhone = (MobPhoneAddressEntity) result;
initAdapter(mobPhone);
}
initAdapter(result.getData());
}

@Override
public void onSuccessList(int what, List results) {

}

@Override
public void onFail(int what, String result) {
public void onFail(int code, String message) {
dissmissProgressDialog();
MySnackbar.makeSnackBarRed(toolbar, result);
MySnackbar.makeSnackBarRed(toolbar, message);
}
});

}

private void initAdapter(MobPhoneAddressEntity mobPhone) {

private void initAdapter(MobileLocationResultBean.DataEntity mobPhone) {
HashMap<String, Object> mDatas = new HashMap<>();
mDatas.put("0", new MobItemEntity("营运商:", mobPhone.getOperator()));
mDatas.put("1", new MobItemEntity("城市:", mobPhone.getProvince() + " " + mobPhone.getCity()));
mDatas.put("2", new MobItemEntity("城市区号:", mobPhone.getCityCode()));
mDatas.put("3", new MobItemEntity("邮政编码:", mobPhone.getZipCode()));
mDatas.put("0", new MobItemEntity("手机号码:", mobPhone.getMobile()));
mDatas.put("1", new MobItemEntity("归属地省份:", mobPhone.getProvince()));
mDatas.put("2", new MobItemEntity("归属地描述:", mobPhone.getCarrier()));

if (recycleMobQueryAdapter == null) {
recycleMobQueryAdapter = new RecycleMobQueryAdapter(this, mDatas);
Expand Down

0 comments on commit bc55d80

Please sign in to comment.