diff --git a/app/src/main/java/com/maning/gankmm/bean/mob/MobItemEntity.java b/app/src/main/java/com/maning/gankmm/bean/CommonItemEntity.java similarity index 80% rename from app/src/main/java/com/maning/gankmm/bean/mob/MobItemEntity.java rename to app/src/main/java/com/maning/gankmm/bean/CommonItemEntity.java index b7a1602..de2a107 100644 --- a/app/src/main/java/com/maning/gankmm/bean/mob/MobItemEntity.java +++ b/app/src/main/java/com/maning/gankmm/bean/CommonItemEntity.java @@ -1,18 +1,18 @@ -package com.maning.gankmm.bean.mob; +package com.maning.gankmm.bean; /** * Created by maning on 2017/5/8. */ -public class MobItemEntity { +public class CommonItemEntity { private String title; private String desc; - public MobItemEntity() { + public CommonItemEntity() { } - public MobItemEntity(String title, String desc) { + public CommonItemEntity(String title, String desc) { this.title = title; this.desc = desc; } diff --git a/app/src/main/java/com/maning/gankmm/bean/rolltools/IpResultBean.java b/app/src/main/java/com/maning/gankmm/bean/rolltools/IpResultBean.java new file mode 100644 index 0000000..9808bc0 --- /dev/null +++ b/app/src/main/java/com/maning/gankmm/bean/rolltools/IpResultBean.java @@ -0,0 +1,100 @@ +package com.maning.gankmm.bean.rolltools; + +/** + * @author : maning + * @date : 2020-10-15 + * @desc : + */ +public class IpResultBean extends RollToolsBaseBean { + + + /** + * data : {"ip":"119.123.72.166","province":"广东省","provinceId":440000,"city":"深圳市","cityId":440300,"isp":"电信","desc":"广东省深圳市 电信"} + */ + + private DataEntity data; + + public DataEntity getData() { + return data; + } + + public void setData(DataEntity data) { + this.data = data; + } + + public static class DataEntity { + /** + * ip : 119.123.72.166 + * province : 广东省 + * provinceId : 440000 + * city : 深圳市 + * cityId : 440300 + * isp : 电信 + * desc : 广东省深圳市 电信 + */ + + private String ip; + private String province; + private int provinceId; + private String city; + private int cityId; + private String isp; + private String desc; + + public String getIp() { + return ip; + } + + public void setIp(String ip) { + this.ip = ip; + } + + public String getProvince() { + return province; + } + + public void setProvince(String province) { + this.province = province; + } + + public int getProvinceId() { + return provinceId; + } + + public void setProvinceId(int provinceId) { + this.provinceId = provinceId; + } + + public String getCity() { + return city; + } + + public void setCity(String city) { + this.city = city; + } + + public int getCityId() { + return cityId; + } + + public void setCityId(int cityId) { + this.cityId = cityId; + } + + public String getIsp() { + return isp; + } + + public void setIsp(String isp) { + this.isp = isp; + } + + public String getDesc() { + return desc; + } + + public void setDesc(String desc) { + this.desc = desc; + } + } +} 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 2880b88..221d754 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.IpResultBean; import com.maning.gankmm.bean.rolltools.MobileLocationResultBean; import com.maning.gankmm.bean.rolltools.RubbishTypeResultBean; import com.maning.gankmm.bean.rolltools.WeatherFuturedaysResultBean; @@ -75,4 +76,20 @@ Call getMobileLocation( @Query("mobile") String mobile ); + @Headers({ + "app_id:" + Constants.ROLL_TOOLS_APP_ID, + "app_secret:" + Constants.ROLL_TOOLS_APP_SECRET + }) + @GET("ip/self") + Call getIpLocationSelf(); + + @Headers({ + "app_id:" + Constants.ROLL_TOOLS_APP_ID, + "app_secret:" + Constants.ROLL_TOOLS_APP_SECRET + }) + @GET("ip/aim_ip") + Call getIpLocation( + @Query("ip") String ip + ); + } 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 0d35c32..4763cdc 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.IpResultBean; import com.maning.gankmm.bean.rolltools.MobileLocationResultBean; import com.maning.gankmm.bean.rolltools.RubbishTypeResultBean; import com.maning.gankmm.bean.rolltools.WeatherFuturedaysResultBean; @@ -57,6 +58,7 @@ public static void convertDictionary(String content, CommonHttpCallback httpCallback) { + BuildApi.getRooltoolsAPIService().getIpLocationSelf().enqueue(httpCallback); + } + + /** + * 获取Ip地址 + * + * @param ip + * @param httpCallback + */ + public static void getIpLocation(String ip, CommonHttpCallback httpCallback) { + BuildApi.getRooltoolsAPIService().getIpLocation(ip).enqueue(httpCallback); + } + } diff --git a/app/src/main/java/com/maning/gankmm/ui/activity/tools/BankCardActivity.java b/app/src/main/java/com/maning/gankmm/ui/activity/tools/BankCardActivity.java index 786e6b8..776e5ff 100644 --- a/app/src/main/java/com/maning/gankmm/ui/activity/tools/BankCardActivity.java +++ b/app/src/main/java/com/maning/gankmm/ui/activity/tools/BankCardActivity.java @@ -10,7 +10,7 @@ import com.maning.gankmm.R; import com.maning.gankmm.bean.mob.MobBankCard; -import com.maning.gankmm.bean.mob.MobItemEntity; +import com.maning.gankmm.bean.CommonItemEntity; import com.maning.gankmm.http.mob.MobApi; import com.maning.gankmm.http.callback.MyCallBack; import com.maning.gankmm.skin.SkinManager; @@ -119,11 +119,11 @@ public void onFail(int what, String result) { private void initAdapter(MobBankCard result) { HashMap mDatas = new HashMap<>(); - mDatas.put("0", new MobItemEntity("所属银行:", result.getBank())); - mDatas.put("1", new MobItemEntity("卡名:", result.getCardName())); - mDatas.put("2", new MobItemEntity("卡片类型:", result.getCardType())); - mDatas.put("3", new MobItemEntity("卡号长度:", String.valueOf(result.getCardNumber()))); - mDatas.put("4", new MobItemEntity("bin码:", result.getBin())); + mDatas.put("0", new CommonItemEntity("所属银行:", result.getBank())); + mDatas.put("1", new CommonItemEntity("卡名:", result.getCardName())); + mDatas.put("2", new CommonItemEntity("卡片类型:", result.getCardType())); + mDatas.put("3", new CommonItemEntity("卡号长度:", String.valueOf(result.getCardNumber()))); + mDatas.put("4", new CommonItemEntity("bin码:", result.getBin())); if (recycleMobQueryAdapter == null) { recycleMobQueryAdapter = new RecycleMobQueryAdapter(this, mDatas); diff --git a/app/src/main/java/com/maning/gankmm/ui/activity/tools/DictionaryActivity.java b/app/src/main/java/com/maning/gankmm/ui/activity/tools/DictionaryActivity.java index e4cf991..9735953 100644 --- a/app/src/main/java/com/maning/gankmm/ui/activity/tools/DictionaryActivity.java +++ b/app/src/main/java/com/maning/gankmm/ui/activity/tools/DictionaryActivity.java @@ -9,7 +9,7 @@ import android.view.MenuItem; import com.maning.gankmm.R; -import com.maning.gankmm.bean.mob.MobItemEntity; +import com.maning.gankmm.bean.CommonItemEntity; import com.maning.gankmm.bean.rolltools.DictionaryResultBean; import com.maning.gankmm.http.callback.CommonHttpCallback; import com.maning.gankmm.http.rolltools.RolltoolsApi; @@ -110,12 +110,12 @@ public void onFail(int code, String message) { private void initAdapter(DictionaryResultBean.DataEntity dataEntity) { HashMap mDatas = new HashMap<>(); - mDatas.put("0", new MobItemEntity("原内容:", dataEntity.getWord())); - mDatas.put("1", new MobItemEntity("繁体:", dataEntity.getTraditional())); - mDatas.put("2", new MobItemEntity("拼音:", dataEntity.getPinyin())); - mDatas.put("3", new MobItemEntity("偏旁部首:", dataEntity.getRadicals())); - mDatas.put("4", new MobItemEntity("汉字释义:", dataEntity.getExplanation())); - mDatas.put("5", new MobItemEntity("汉字笔画数:", String.valueOf(dataEntity.getStrokes()))); + mDatas.put("0", new CommonItemEntity("原内容:", dataEntity.getWord())); + mDatas.put("1", new CommonItemEntity("繁体:", dataEntity.getTraditional())); + mDatas.put("2", new CommonItemEntity("拼音:", dataEntity.getPinyin())); + mDatas.put("3", new CommonItemEntity("偏旁部首:", dataEntity.getRadicals())); + mDatas.put("4", new CommonItemEntity("汉字释义:", dataEntity.getExplanation())); + mDatas.put("5", new CommonItemEntity("汉字笔画数:", String.valueOf(dataEntity.getStrokes()))); if (recycleMobQueryAdapter == null) { recycleMobQueryAdapter = new RecycleMobQueryAdapter(this, mDatas); diff --git a/app/src/main/java/com/maning/gankmm/ui/activity/tools/IDCardQueryActivity.java b/app/src/main/java/com/maning/gankmm/ui/activity/tools/IDCardQueryActivity.java index b3c1e3e..c59212d 100644 --- a/app/src/main/java/com/maning/gankmm/ui/activity/tools/IDCardQueryActivity.java +++ b/app/src/main/java/com/maning/gankmm/ui/activity/tools/IDCardQueryActivity.java @@ -10,7 +10,7 @@ import com.maning.gankmm.R; import com.maning.gankmm.bean.mob.MobIdCardEntity; -import com.maning.gankmm.bean.mob.MobItemEntity; +import com.maning.gankmm.bean.CommonItemEntity; import com.maning.gankmm.http.mob.MobApi; import com.maning.gankmm.http.callback.MyCallBack; import com.maning.gankmm.skin.SkinManager; @@ -119,9 +119,9 @@ public void onFail(int what, String result) { private void initAdapter(MobIdCardEntity result) { HashMap mDatas = new HashMap<>(); - mDatas.put("0", new MobItemEntity("地区:", result.getArea())); - mDatas.put("1", new MobItemEntity("生日:", result.getBirthday())); - mDatas.put("2", new MobItemEntity("性别:", result.getSex())); + mDatas.put("0", new CommonItemEntity("地区:", result.getArea())); + mDatas.put("1", new CommonItemEntity("生日:", result.getBirthday())); + mDatas.put("2", new CommonItemEntity("性别:", result.getSex())); if (recycleMobQueryAdapter == null) { recycleMobQueryAdapter = new RecycleMobQueryAdapter(this, mDatas); diff --git a/app/src/main/java/com/maning/gankmm/ui/activity/tools/IPQueryActivity.java b/app/src/main/java/com/maning/gankmm/ui/activity/tools/IPQueryActivity.java index 9dd0511..041d91d 100644 --- a/app/src/main/java/com/maning/gankmm/ui/activity/tools/IPQueryActivity.java +++ b/app/src/main/java/com/maning/gankmm/ui/activity/tools/IPQueryActivity.java @@ -7,12 +7,16 @@ import android.support.v7.widget.Toolbar; import android.text.TextUtils; import android.view.MenuItem; +import android.widget.Button; import com.maning.gankmm.R; +import com.maning.gankmm.bean.CommonItemEntity; import com.maning.gankmm.bean.mob.MobIpEntity; -import com.maning.gankmm.bean.mob.MobItemEntity; -import com.maning.gankmm.http.mob.MobApi; +import com.maning.gankmm.bean.rolltools.IpResultBean; +import com.maning.gankmm.http.callback.CommonHttpCallback; import com.maning.gankmm.http.callback.MyCallBack; +import com.maning.gankmm.http.mob.MobApi; +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; @@ -78,7 +82,26 @@ public boolean onOptionsItemSelected(MenuItem item) { } - @OnClick(R.id.btn_query) + @OnClick({R.id.btn_query_self}) + public void btnQuerySelf() { + showProgressDialog("正在查询..."); + RolltoolsApi.getIpLocationSelf(new CommonHttpCallback() { + @Override + public void onSuccess(IpResultBean result) { + dissmissProgressDialog(); + IpResultBean.DataEntity data = result.getData(); + initAdapter(data); + } + + @Override + public void onFail(int code, String message) { + dissmissProgressDialog(); + MySnackbar.makeSnackBarRed(toolbar, message); + } + }); + } + + @OnClick({R.id.btn_query}) public void btnQuery() { KeyboardUtils.hideSoftInput(this); @@ -90,38 +113,32 @@ public void btnQuery() { MySnackbar.makeSnackBarRed(toolbar, "IP号码不能为空"); return; } - showProgressDialog("正在查询..."); - MobApi.queryIp(number, 0x001, new MyCallBack() { + RolltoolsApi.getIpLocation(number, new CommonHttpCallback() { @Override - public void onSuccess(int what, Object object) { + public void onSuccess(IpResultBean result) { dissmissProgressDialog(); - if (object != null) { - MobIpEntity result = (MobIpEntity) object; - initAdapter(result); - } + IpResultBean.DataEntity data = result.getData(); + initAdapter(data); } @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(MobIpEntity result) { + private void initAdapter(IpResultBean.DataEntity data) { HashMap mDatas = new HashMap<>(); - mDatas.put("0", new MobItemEntity("IP:", result.getIp())); - mDatas.put("1", new MobItemEntity("国家:", result.getCountry())); - mDatas.put("2", new MobItemEntity("城市:", result.getProvince() + " " + result.getCity())); + mDatas.put("0", new CommonItemEntity("IP:", data.getIp())); + mDatas.put("1", new CommonItemEntity("服务商名称:", data.getIsp())); + mDatas.put("2", new CommonItemEntity("IP描述:", data.getDesc())); + mDatas.put("3", new CommonItemEntity("城市:", data.getProvince() + " " + data.getCity())); if (recycleMobQueryAdapter == null) { recycleMobQueryAdapter = new RecycleMobQueryAdapter(this, mDatas); diff --git a/app/src/main/java/com/maning/gankmm/ui/activity/tools/IdiomActivity.java b/app/src/main/java/com/maning/gankmm/ui/activity/tools/IdiomActivity.java index c59c0ce..c871309 100644 --- a/app/src/main/java/com/maning/gankmm/ui/activity/tools/IdiomActivity.java +++ b/app/src/main/java/com/maning/gankmm/ui/activity/tools/IdiomActivity.java @@ -10,7 +10,7 @@ import com.maning.gankmm.R; import com.maning.gankmm.bean.mob.MobIdiomEntity; -import com.maning.gankmm.bean.mob.MobItemEntity; +import com.maning.gankmm.bean.CommonItemEntity; import com.maning.gankmm.http.mob.MobApi; import com.maning.gankmm.http.callback.MyCallBack; import com.maning.gankmm.skin.SkinManager; @@ -119,11 +119,11 @@ public void onFail(int what, String result) { private void initAdapter(MobIdiomEntity result) { HashMap mDatas = new HashMap<>(); - mDatas.put("0", new MobItemEntity("拼音:", result.getPinyin())); - mDatas.put("1", new MobItemEntity("释义:", result.getPretation())); - mDatas.put("2", new MobItemEntity("出自:", result.getSource())); - mDatas.put("3", new MobItemEntity("示例:", result.getSample())); - mDatas.put("4", new MobItemEntity("示例出自:", result.getSampleFrom())); + mDatas.put("0", new CommonItemEntity("拼音:", result.getPinyin())); + mDatas.put("1", new CommonItemEntity("释义:", result.getPretation())); + mDatas.put("2", new CommonItemEntity("出自:", result.getSource())); + mDatas.put("3", new CommonItemEntity("示例:", result.getSample())); + mDatas.put("4", new CommonItemEntity("示例出自:", result.getSampleFrom())); if (recycleMobQueryAdapter == null) { recycleMobQueryAdapter = new RecycleMobQueryAdapter(this, mDatas); 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 7548336..9983400 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 @@ -9,7 +9,7 @@ import android.view.MenuItem; import com.maning.gankmm.R; -import com.maning.gankmm.bean.mob.MobItemEntity; +import com.maning.gankmm.bean.CommonItemEntity; import com.maning.gankmm.bean.rolltools.MobileLocationResultBean; import com.maning.gankmm.http.callback.CommonHttpCallback; import com.maning.gankmm.http.rolltools.RolltoolsApi; @@ -115,9 +115,9 @@ public void onFail(int code, String message) { private void initAdapter(MobileLocationResultBean.DataEntity mobPhone) { HashMap mDatas = new HashMap<>(); - mDatas.put("0", new MobItemEntity("手机号码:", mobPhone.getMobile())); - mDatas.put("1", new MobItemEntity("归属地省份:", mobPhone.getProvince())); - mDatas.put("2", new MobItemEntity("归属地描述:", mobPhone.getCarrier())); + mDatas.put("0", new CommonItemEntity("手机号码:", mobPhone.getMobile())); + mDatas.put("1", new CommonItemEntity("归属地省份:", mobPhone.getProvince())); + mDatas.put("2", new CommonItemEntity("归属地描述:", mobPhone.getCarrier())); if (recycleMobQueryAdapter == null) { recycleMobQueryAdapter = new RecycleMobQueryAdapter(this, mDatas); diff --git a/app/src/main/java/com/maning/gankmm/ui/activity/tools/PostCodeActivity.java b/app/src/main/java/com/maning/gankmm/ui/activity/tools/PostCodeActivity.java index f563b9b..ad10d1a 100644 --- a/app/src/main/java/com/maning/gankmm/ui/activity/tools/PostCodeActivity.java +++ b/app/src/main/java/com/maning/gankmm/ui/activity/tools/PostCodeActivity.java @@ -9,7 +9,7 @@ import android.view.MenuItem; import com.maning.gankmm.R; -import com.maning.gankmm.bean.mob.MobItemEntity; +import com.maning.gankmm.bean.CommonItemEntity; import com.maning.gankmm.bean.mob.MobPostCodeEntity; import com.maning.gankmm.http.mob.MobApi; import com.maning.gankmm.http.callback.MyCallBack; @@ -120,10 +120,10 @@ public void onFail(int what, String result) { private void initAdapter(MobPostCodeEntity result) { HashMap mDatas = new HashMap<>(); - mDatas.put("0", new MobItemEntity("省份:", result.getProvince())); - mDatas.put("1", new MobItemEntity("城市:", result.getCity())); - mDatas.put("2", new MobItemEntity("区县:", result.getDistrict())); - mDatas.put("3", new MobItemEntity("详细地址:", result.getAddress().toString())); + mDatas.put("0", new CommonItemEntity("省份:", result.getProvince())); + mDatas.put("1", new CommonItemEntity("城市:", result.getCity())); + mDatas.put("2", new CommonItemEntity("区县:", result.getDistrict())); + mDatas.put("3", new CommonItemEntity("详细地址:", result.getAddress().toString())); if (recycleMobQueryAdapter == null) { recycleMobQueryAdapter = new RecycleMobQueryAdapter(this, mDatas); diff --git a/app/src/main/java/com/maning/gankmm/ui/adapter/RecycleMobQueryAdapter.java b/app/src/main/java/com/maning/gankmm/ui/adapter/RecycleMobQueryAdapter.java index 38807cc..d1b5414 100644 --- a/app/src/main/java/com/maning/gankmm/ui/adapter/RecycleMobQueryAdapter.java +++ b/app/src/main/java/com/maning/gankmm/ui/adapter/RecycleMobQueryAdapter.java @@ -8,7 +8,7 @@ import android.widget.TextView; import com.maning.gankmm.R; -import com.maning.gankmm.bean.mob.MobItemEntity; +import com.maning.gankmm.bean.CommonItemEntity; import java.util.HashMap; @@ -45,10 +45,10 @@ public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { public void onBindViewHolder(final RecyclerView.ViewHolder viewHolder, final int position) { if (viewHolder instanceof MyViewHolder) { final MyViewHolder myViewHolder = (MyViewHolder) viewHolder; - MobItemEntity mobItemEntity = (MobItemEntity) mDatas.get(String.valueOf(position)); - if (mobItemEntity != null) { - myViewHolder.tvTitle.setText(mobItemEntity.getTitle()); - myViewHolder.tvDesc.setText(mobItemEntity.getDesc()); + CommonItemEntity commonItemEntity = (CommonItemEntity) mDatas.get(String.valueOf(position)); + if (commonItemEntity != null) { + myViewHolder.tvTitle.setText(commonItemEntity.getTitle()); + myViewHolder.tvDesc.setText(commonItemEntity.getDesc()); } } } diff --git a/app/src/main/java/com/maning/gankmm/ui/adapter/RecycleMoreAdapter.java b/app/src/main/java/com/maning/gankmm/ui/adapter/RecycleMoreAdapter.java index f46886e..a782617 100644 --- a/app/src/main/java/com/maning/gankmm/ui/adapter/RecycleMoreAdapter.java +++ b/app/src/main/java/com/maning/gankmm/ui/adapter/RecycleMoreAdapter.java @@ -73,12 +73,12 @@ public void onBindViewHolder(final RecyclerView.ViewHolder viewHolder, final int ArrayList mDatasItem = new ArrayList<>(); if (position == 0) { mDatasItem.add("手机号码归属地"); - mDatasItem.add("邮编查询"); - mDatasItem.add("菜谱查询"); - mDatasItem.add("身份证查询"); mDatasItem.add("IP地址"); - mDatasItem.add("中国彩票开奖结果"); - mDatasItem.add("微信精选"); +// mDatasItem.add("邮编查询"); +// mDatasItem.add("菜谱查询"); +// mDatasItem.add("身份证查询"); +// mDatasItem.add("中国彩票开奖结果"); +// mDatasItem.add("微信精选"); } else if (position == 1) { // mDatasItem.add("银行卡信息"); mDatasItem.add("货币汇率"); diff --git a/app/src/main/res/layout/activity_ip_query.xml b/app/src/main/res/layout/activity_ip_query.xml index 72e2bb5..dbfe3dd 100644 --- a/app/src/main/res/layout/activity_ip_query.xml +++ b/app/src/main/res/layout/activity_ip_query.xml @@ -13,11 +13,23 @@ android:padding="10dp">