diff --git a/app/src/main/java/com/maning/gankmm/bean/rolltools/MobileLocationResultBean.java b/app/src/main/java/com/maning/gankmm/bean/rolltools/MobileLocationResultBean.java new file mode 100644 index 0000000..3c2d258 --- /dev/null +++ b/app/src/main/java/com/maning/gankmm/bean/rolltools/MobileLocationResultBean.java @@ -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; + } + } +} diff --git a/app/src/main/java/com/maning/gankmm/http/rolltools/APIRolltoolsService.java b/app/src/main/java/com/maning/gankmm/http/rolltools/APIRolltoolsService.java index 31814ae..2880b88 100644 --- a/app/src/main/java/com/maning/gankmm/http/rolltools/APIRolltoolsService.java +++ b/app/src/main/java/com/maning/gankmm/http/rolltools/APIRolltoolsService.java @@ -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; @@ -65,4 +66,13 @@ Call 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 getMobileLocation( + @Query("mobile") String mobile + ); + } diff --git a/app/src/main/java/com/maning/gankmm/http/rolltools/RolltoolsApi.java b/app/src/main/java/com/maning/gankmm/http/rolltools/RolltoolsApi.java index 2e8626e..0d35c32 100644 --- a/app/src/main/java/com/maning/gankmm/http/rolltools/RolltoolsApi.java +++ b/app/src/main/java/com/maning/gankmm/http/rolltools/RolltoolsApi.java @@ -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; @@ -63,5 +64,14 @@ public static void getRubbishType(String content, CommonHttpCallback httpCallback) { + BuildApi.getRooltoolsAPIService().getMobileLocation(phone).enqueue(httpCallback); + } + } diff --git a/app/src/main/java/com/maning/gankmm/ui/activity/tools/PhoneAddressActivity.java b/app/src/main/java/com/maning/gankmm/ui/activity/tools/PhoneAddressActivity.java index 6ffc9e6..7548336 100644 --- a/app/src/main/java/com/maning/gankmm/ui/activity/tools/PhoneAddressActivity.java +++ b/app/src/main/java/com/maning/gankmm/ui/activity/tools/PhoneAddressActivity.java @@ -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; @@ -22,7 +22,6 @@ import com.maning.gankmm.utils.MySnackbar; import java.util.HashMap; -import java.util.List; import butterknife.Bind; import butterknife.ButterKnife; @@ -98,37 +97,27 @@ public void btnQuery() { } showProgressDialog("正在查询..."); - MobApi.queryPhoneAddress(phoneNumber, 0x001, new MyCallBack() { + RolltoolsApi.getMobileLocation(phoneNumber, new CommonHttpCallback() { @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 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);