diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index f481f5c..2f474f6 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -252,7 +252,7 @@ - + diff --git a/app/src/main/java/com/maning/gankmm/bean/rolltools/WorldPhoneCodeResultBean.java b/app/src/main/java/com/maning/gankmm/bean/rolltools/WorldPhoneCodeResultBean.java new file mode 100644 index 0000000..eae9811 --- /dev/null +++ b/app/src/main/java/com/maning/gankmm/bean/rolltools/WorldPhoneCodeResultBean.java @@ -0,0 +1,58 @@ +package com.maning.gankmm.bean.rolltools; + +import java.util.List; + +/** + * @author : maning + * @date : 2020-10-15 + * @desc : + */ +public class WorldPhoneCodeResultBean extends RollToolsBaseBean { + + + private List data; + + public List getData() { + return data; + } + + public void setData(List data) { + this.data = data; + } + + public static class DataEntity { + /** + * zhCn : 中国 + * enUs : China + * phoneCode : +86 + */ + + private String zhCn; + private String enUs; + private String phoneCode; + + public String getZhCn() { + return zhCn; + } + + public void setZhCn(String zhCn) { + this.zhCn = zhCn; + } + + public String getEnUs() { + return enUs; + } + + public void setEnUs(String enUs) { + this.enUs = enUs; + } + + public String getPhoneCode() { + return phoneCode; + } + + public void setPhoneCode(String phoneCode) { + this.phoneCode = phoneCode; + } + } +} 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 221d754..04fb817 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 @@ -7,6 +7,7 @@ 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.bean.rolltools.WorldPhoneCodeResultBean; import com.maning.gankmm.constant.Constants; import retrofit2.Call; @@ -92,4 +93,11 @@ Call getIpLocation( @Query("ip") String ip ); + @Headers({ + "app_id:" + Constants.ROLL_TOOLS_APP_ID, + "app_secret:" + Constants.ROLL_TOOLS_APP_SECRET + }) + @GET("phone_code/list") + Call getWorldPhoneCode(); + } 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 4763cdc..8e222c4 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 @@ -7,6 +7,7 @@ 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.bean.rolltools.WorldPhoneCodeResultBean; import com.maning.gankmm.http.BuildApi; import com.maning.gankmm.http.callback.CommonHttpCallback; @@ -95,5 +96,13 @@ public static void getIpLocation(String ip, CommonHttpCallback htt BuildApi.getRooltoolsAPIService().getIpLocation(ip).enqueue(httpCallback); } + /** + * 获取世界电话区号列表。 + * @param httpCallback + */ + public static void getWorldPhoneCode(CommonHttpCallback httpCallback) { + BuildApi.getRooltoolsAPIService().getWorldPhoneCode().enqueue(httpCallback); + } + } diff --git a/app/src/main/java/com/maning/gankmm/ui/activity/MoreActivity.java b/app/src/main/java/com/maning/gankmm/ui/activity/MoreActivity.java index 83f8394..9b5b0d7 100644 --- a/app/src/main/java/com/maning/gankmm/ui/activity/MoreActivity.java +++ b/app/src/main/java/com/maning/gankmm/ui/activity/MoreActivity.java @@ -74,10 +74,10 @@ private void initRecyclerView() { private void initAdapter() { ArrayList mDatas = new ArrayList<>(); - mDatas.add("生活常用"); - mDatas.add("金融基金"); - mDatas.add("休闲旅游"); mDatas.add("便民服务"); + mDatas.add("生活阅读"); + mDatas.add("休闲旅游"); + mDatas.add("工具集合"); recycleMoreAdapter = new RecycleMoreAdapter(this, mDatas); recyclerView.setAdapter(recycleMoreAdapter); 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 776e5ff..a7d933a 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 @@ -14,7 +14,7 @@ import com.maning.gankmm.http.mob.MobApi; import com.maning.gankmm.http.callback.MyCallBack; import com.maning.gankmm.skin.SkinManager; -import com.maning.gankmm.ui.adapter.RecycleMobQueryAdapter; +import com.maning.gankmm.ui.adapter.RecycleCommonQueryAdapter; import com.maning.gankmm.ui.base.BaseActivity; import com.maning.gankmm.ui.view.MClearEditText; import com.maning.gankmm.utils.KeyboardUtils; @@ -38,7 +38,7 @@ public class BankCardActivity extends BaseActivity { MClearEditText editTextInput; @Bind(R.id.recyclerView) RecyclerView recyclerView; - private RecycleMobQueryAdapter recycleMobQueryAdapter; + private RecycleCommonQueryAdapter recycleCommonQueryAdapter; @Override protected void onCreate(Bundle savedInstanceState) { @@ -125,11 +125,11 @@ private void initAdapter(MobBankCard result) { 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); - recyclerView.setAdapter(recycleMobQueryAdapter); + if (recycleCommonQueryAdapter == null) { + recycleCommonQueryAdapter = new RecycleCommonQueryAdapter(this, mDatas); + recyclerView.setAdapter(recycleCommonQueryAdapter); } else { - recycleMobQueryAdapter.updateDatas(mDatas); + recycleCommonQueryAdapter.updateDatas(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 9735953..9d8f1be 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 @@ -14,7 +14,7 @@ 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.adapter.RecycleCommonQueryAdapter; import com.maning.gankmm.ui.base.BaseActivity; import com.maning.gankmm.ui.view.MClearEditText; import com.maning.gankmm.utils.KeyboardUtils; @@ -37,7 +37,7 @@ public class DictionaryActivity extends BaseActivity { MClearEditText editText; @Bind(R.id.recyclerView) RecyclerView recyclerView; - private RecycleMobQueryAdapter recycleMobQueryAdapter; + private RecycleCommonQueryAdapter recycleCommonQueryAdapter; @Override protected void onCreate(Bundle savedInstanceState) { @@ -117,11 +117,11 @@ private void initAdapter(DictionaryResultBean.DataEntity dataEntity) { mDatas.put("4", new CommonItemEntity("汉字释义:", dataEntity.getExplanation())); mDatas.put("5", new CommonItemEntity("汉字笔画数:", String.valueOf(dataEntity.getStrokes()))); - if (recycleMobQueryAdapter == null) { - recycleMobQueryAdapter = new RecycleMobQueryAdapter(this, mDatas); - recyclerView.setAdapter(recycleMobQueryAdapter); + if (recycleCommonQueryAdapter == null) { + recycleCommonQueryAdapter = new RecycleCommonQueryAdapter(this, mDatas); + recyclerView.setAdapter(recycleCommonQueryAdapter); } else { - recycleMobQueryAdapter.updateDatas(mDatas); + recycleCommonQueryAdapter.updateDatas(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 c59212d..d6f64a8 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 @@ -14,7 +14,7 @@ import com.maning.gankmm.http.mob.MobApi; import com.maning.gankmm.http.callback.MyCallBack; import com.maning.gankmm.skin.SkinManager; -import com.maning.gankmm.ui.adapter.RecycleMobQueryAdapter; +import com.maning.gankmm.ui.adapter.RecycleCommonQueryAdapter; import com.maning.gankmm.ui.base.BaseActivity; import com.maning.gankmm.ui.view.MClearEditText; import com.maning.gankmm.utils.KeyboardUtils; @@ -38,7 +38,7 @@ public class IDCardQueryActivity extends BaseActivity { MClearEditText editTextPhone; @Bind(R.id.recyclerView) RecyclerView recyclerView; - private RecycleMobQueryAdapter recycleMobQueryAdapter; + private RecycleCommonQueryAdapter recycleCommonQueryAdapter; @Override protected void onCreate(Bundle savedInstanceState) { @@ -123,11 +123,11 @@ private void initAdapter(MobIdCardEntity result) { mDatas.put("1", new CommonItemEntity("生日:", result.getBirthday())); mDatas.put("2", new CommonItemEntity("性别:", result.getSex())); - if (recycleMobQueryAdapter == null) { - recycleMobQueryAdapter = new RecycleMobQueryAdapter(this, mDatas); - recyclerView.setAdapter(recycleMobQueryAdapter); + if (recycleCommonQueryAdapter == null) { + recycleCommonQueryAdapter = new RecycleCommonQueryAdapter(this, mDatas); + recyclerView.setAdapter(recycleCommonQueryAdapter); } else { - recycleMobQueryAdapter.updateDatas(mDatas); + recycleCommonQueryAdapter.updateDatas(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 041d91d..56e0f39 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,25 +7,20 @@ 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.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.adapter.RecycleCommonQueryAdapter; import com.maning.gankmm.ui.base.BaseActivity; import com.maning.gankmm.ui.view.MClearEditText; import com.maning.gankmm.utils.KeyboardUtils; import com.maning.gankmm.utils.MySnackbar; import java.util.HashMap; -import java.util.List; import butterknife.Bind; import butterknife.ButterKnife; @@ -42,7 +37,7 @@ public class IPQueryActivity extends BaseActivity { MClearEditText editTextPhone; @Bind(R.id.recyclerView) RecyclerView recyclerView; - private RecycleMobQueryAdapter recycleMobQueryAdapter; + private RecycleCommonQueryAdapter recycleCommonQueryAdapter; @Override protected void onCreate(Bundle savedInstanceState) { @@ -140,11 +135,11 @@ private void initAdapter(IpResultBean.DataEntity data) { 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); - recyclerView.setAdapter(recycleMobQueryAdapter); + if (recycleCommonQueryAdapter == null) { + recycleCommonQueryAdapter = new RecycleCommonQueryAdapter(this, mDatas); + recyclerView.setAdapter(recycleCommonQueryAdapter); } else { - recycleMobQueryAdapter.updateDatas(mDatas); + recycleCommonQueryAdapter.updateDatas(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 deleted file mode 100644 index c871309..0000000 --- a/app/src/main/java/com/maning/gankmm/ui/activity/tools/IdiomActivity.java +++ /dev/null @@ -1,137 +0,0 @@ -package com.maning.gankmm.ui.activity.tools; - -import android.os.Bundle; -import android.support.v7.widget.DefaultItemAnimator; -import android.support.v7.widget.LinearLayoutManager; -import android.support.v7.widget.RecyclerView; -import android.support.v7.widget.Toolbar; -import android.text.TextUtils; -import android.view.MenuItem; - -import com.maning.gankmm.R; -import com.maning.gankmm.bean.mob.MobIdiomEntity; -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; -import com.maning.gankmm.ui.adapter.RecycleMobQueryAdapter; -import com.maning.gankmm.ui.base.BaseActivity; -import com.maning.gankmm.ui.view.MClearEditText; -import com.maning.gankmm.utils.KeyboardUtils; -import com.maning.gankmm.utils.MySnackbar; - -import java.util.HashMap; -import java.util.List; - -import butterknife.Bind; -import butterknife.ButterKnife; -import butterknife.OnClick; - -/** - * 成语大全 - */ -public class IdiomActivity extends BaseActivity { - - @Bind(R.id.toolbar) - Toolbar toolbar; - @Bind(R.id.editText) - MClearEditText editText; - @Bind(R.id.recyclerView) - RecyclerView recyclerView; - private RecycleMobQueryAdapter recycleMobQueryAdapter; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_idiom); - ButterKnife.bind(this); - - initMyToolBar(); - - initRecyclerView(); - - } - - private void initRecyclerView() { - LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false); - recyclerView.setLayoutManager(linearLayoutManager); - recyclerView.setItemAnimator(new DefaultItemAnimator()); - } - - private void initMyToolBar() { - int currentSkinType = SkinManager.getCurrentSkinType(this); - if (SkinManager.THEME_DAY == currentSkinType) { - initToolBar(toolbar, "成语查询", R.drawable.gank_ic_back_white); - } else { - initToolBar(toolbar, "成语查询", R.drawable.gank_ic_back_night); - } - } - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - switch (item.getItemId()) { - case android.R.id.home: - this.finish(); - return true; - } - return super.onOptionsItemSelected(item); - } - - - @OnClick(R.id.btn_query) - public void btnQuery() { - - KeyboardUtils.hideSoftInput(this); - - //获取输入 - String content = editText.getText().toString(); - - if (TextUtils.isEmpty(content)) { - MySnackbar.makeSnackBarRed(toolbar, "输入内容不能为空"); - return; - } - - showProgressDialog("正在查询..."); - MobApi.queryIdiom(content, 0x001, new MyCallBack() { - @Override - public void onSuccess(int what, Object object) { - dissmissProgressDialog(); - if (object != null) { - MobIdiomEntity result = (MobIdiomEntity) object; - initAdapter(result); - } - } - - @Override - public void onSuccessList(int what, List results) { - - } - - @Override - public void onFail(int what, String result) { - dissmissProgressDialog(); - MySnackbar.makeSnackBarRed(toolbar, result); - } - }); - - } - - private void initAdapter(MobIdiomEntity result) { - - HashMap mDatas = new HashMap<>(); - 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); - recyclerView.setAdapter(recycleMobQueryAdapter); - } else { - recycleMobQueryAdapter.updateDatas(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 9983400..fb1a6dd 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 @@ -14,7 +14,7 @@ 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.adapter.RecycleCommonQueryAdapter; import com.maning.gankmm.ui.base.BaseActivity; import com.maning.gankmm.ui.view.MClearEditText; import com.maning.gankmm.utils.GankUtils; @@ -38,7 +38,7 @@ public class PhoneAddressActivity extends BaseActivity { MClearEditText editTextPhone; @Bind(R.id.recyclerView) RecyclerView recyclerView; - private RecycleMobQueryAdapter recycleMobQueryAdapter; + private RecycleCommonQueryAdapter recycleCommonQueryAdapter; @Override protected void onCreate(Bundle savedInstanceState) { @@ -119,11 +119,11 @@ private void initAdapter(MobileLocationResultBean.DataEntity mobPhone) { mDatas.put("1", new CommonItemEntity("归属地省份:", mobPhone.getProvince())); mDatas.put("2", new CommonItemEntity("归属地描述:", mobPhone.getCarrier())); - if (recycleMobQueryAdapter == null) { - recycleMobQueryAdapter = new RecycleMobQueryAdapter(this, mDatas); - recyclerView.setAdapter(recycleMobQueryAdapter); + if (recycleCommonQueryAdapter == null) { + recycleCommonQueryAdapter = new RecycleCommonQueryAdapter(this, mDatas); + recyclerView.setAdapter(recycleCommonQueryAdapter); } else { - recycleMobQueryAdapter.updateDatas(mDatas); + recycleCommonQueryAdapter.updateDatas(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 ad10d1a..50aaa5a 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 @@ -14,7 +14,7 @@ import com.maning.gankmm.http.mob.MobApi; import com.maning.gankmm.http.callback.MyCallBack; import com.maning.gankmm.skin.SkinManager; -import com.maning.gankmm.ui.adapter.RecycleMobQueryAdapter; +import com.maning.gankmm.ui.adapter.RecycleCommonQueryAdapter; import com.maning.gankmm.ui.base.BaseActivity; import com.maning.gankmm.ui.view.MClearEditText; import com.maning.gankmm.utils.KeyboardUtils; @@ -38,7 +38,7 @@ public class PostCodeActivity extends BaseActivity { MClearEditText editTextPhone; @Bind(R.id.recyclerView) RecyclerView recyclerView; - private RecycleMobQueryAdapter recycleMobQueryAdapter; + private RecycleCommonQueryAdapter recycleCommonQueryAdapter; @Override protected void onCreate(Bundle savedInstanceState) { @@ -125,11 +125,11 @@ private void initAdapter(MobPostCodeEntity result) { mDatas.put("2", new CommonItemEntity("区县:", result.getDistrict())); mDatas.put("3", new CommonItemEntity("详细地址:", result.getAddress().toString())); - if (recycleMobQueryAdapter == null) { - recycleMobQueryAdapter = new RecycleMobQueryAdapter(this, mDatas); - recyclerView.setAdapter(recycleMobQueryAdapter); + if (recycleCommonQueryAdapter == null) { + recycleCommonQueryAdapter = new RecycleCommonQueryAdapter(this, mDatas); + recyclerView.setAdapter(recycleCommonQueryAdapter); } else { - recycleMobQueryAdapter.updateDatas(mDatas); + recycleCommonQueryAdapter.updateDatas(mDatas); } } diff --git a/app/src/main/java/com/maning/gankmm/ui/activity/tools/WorldPhoneCodeActivity.java b/app/src/main/java/com/maning/gankmm/ui/activity/tools/WorldPhoneCodeActivity.java new file mode 100644 index 0000000..fa37f9e --- /dev/null +++ b/app/src/main/java/com/maning/gankmm/ui/activity/tools/WorldPhoneCodeActivity.java @@ -0,0 +1,111 @@ +package com.maning.gankmm.ui.activity.tools; + +import android.os.Bundle; +import android.support.v7.widget.DefaultItemAnimator; +import android.support.v7.widget.LinearLayoutManager; +import android.support.v7.widget.RecyclerView; +import android.support.v7.widget.Toolbar; +import android.view.MenuItem; + +import com.maning.gankmm.R; +import com.maning.gankmm.bean.CommonItemEntity; +import com.maning.gankmm.bean.rolltools.WorldPhoneCodeResultBean; +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.RecycleCommonQueryAdapter; +import com.maning.gankmm.ui.base.BaseActivity; +import com.maning.gankmm.utils.MySnackbar; + +import java.util.HashMap; +import java.util.List; + +import butterknife.Bind; +import butterknife.ButterKnife; + +/** + * 世界电话区号列表 + */ +public class WorldPhoneCodeActivity extends BaseActivity { + + @Bind(R.id.toolbar) + Toolbar toolbar; + @Bind(R.id.recyclerView) + RecyclerView recyclerView; + private RecycleCommonQueryAdapter recycleCommonQueryAdapter; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_world_phone_code); + ButterKnife.bind(this); + + initMyToolBar(); + + initRecyclerView(); + + queryDatas(); + + } + + private void queryDatas() { + showProgressDialog(); + RolltoolsApi.getWorldPhoneCode(new CommonHttpCallback() { + @Override + public void onSuccess(WorldPhoneCodeResultBean result) { + dissmissProgressDialog(); + List data = result.getData(); + + HashMap mDatas = new HashMap<>(); + for (int i = 0; i < data.size(); i++) { + WorldPhoneCodeResultBean.DataEntity dataEntity = data.get(i); + mDatas.put("" + i, new CommonItemEntity(dataEntity.getZhCn() + "(" + dataEntity.getEnUs() + ")", dataEntity.getPhoneCode())); + } + initAdapter(mDatas); + } + + @Override + public void onFail(int code, String message) { + dissmissProgressDialog(); + MySnackbar.makeSnackBarRed(toolbar, message); + } + }); + } + + private void initRecyclerView() { + LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false); + recyclerView.setLayoutManager(linearLayoutManager); + recyclerView.setItemAnimator(new DefaultItemAnimator()); + } + + private void initMyToolBar() { + int currentSkinType = SkinManager.getCurrentSkinType(this); + if (SkinManager.THEME_DAY == currentSkinType) { + initToolBar(toolbar, "世界电话区号", R.drawable.gank_ic_back_white); + } else { + initToolBar(toolbar, "世界电话区号", R.drawable.gank_ic_back_night); + } + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + switch (item.getItemId()) { + case android.R.id.home: + this.finish(); + return true; + } + return super.onOptionsItemSelected(item); + } + + + private void initAdapter(HashMap mDatas) { + if (recycleCommonQueryAdapter == null) { + recycleCommonQueryAdapter = new RecycleCommonQueryAdapter(this, mDatas, 1); + recyclerView.setAdapter(recycleCommonQueryAdapter); + } else { + recycleCommonQueryAdapter.updateDatas(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/RecycleCommonQueryAdapter.java similarity index 78% rename from app/src/main/java/com/maning/gankmm/ui/adapter/RecycleMobQueryAdapter.java rename to app/src/main/java/com/maning/gankmm/ui/adapter/RecycleCommonQueryAdapter.java index d1b5414..9d17d20 100644 --- a/app/src/main/java/com/maning/gankmm/ui/adapter/RecycleMobQueryAdapter.java +++ b/app/src/main/java/com/maning/gankmm/ui/adapter/RecycleCommonQueryAdapter.java @@ -18,15 +18,22 @@ /** * 更多功能的Adapter */ -public class RecycleMobQueryAdapter extends RecyclerView.Adapter { +public class RecycleCommonQueryAdapter extends RecyclerView.Adapter { private Context context; + //0布局,1左右布局 + private int type = 0; private LayoutInflater layoutInflater; private HashMap mDatas; - public RecycleMobQueryAdapter(Context context, HashMap mDatas) { + public RecycleCommonQueryAdapter(Context context, HashMap mDatas) { + this(context, mDatas, 0); + } + + public RecycleCommonQueryAdapter(Context context, HashMap mDatas, int type) { this.context = context; this.mDatas = mDatas; + this.type = type; layoutInflater = LayoutInflater.from(this.context); } @@ -37,7 +44,7 @@ public void updateDatas(HashMap mDatas) { @Override public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { - View inflate = layoutInflater.inflate(R.layout.item_mob_query, parent, false); + View inflate = layoutInflater.inflate(type == 0 ? R.layout.item_common_query : R.layout.item_common_query2, parent, false); return new MyViewHolder(inflate); } 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 a782617..5f51c45 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 @@ -12,7 +12,6 @@ import com.maning.gankmm.R; import com.maning.gankmm.listeners.OnItemClickListener; -import com.maning.gankmm.ui.activity.tools.BankCardActivity; import com.maning.gankmm.ui.activity.tools.CarListActivity; import com.maning.gankmm.ui.activity.tools.ChineseCalendarActivity; import com.maning.gankmm.ui.activity.tools.CookMenuActivity; @@ -22,7 +21,7 @@ import com.maning.gankmm.ui.activity.tools.HistoryTodayActivity; import com.maning.gankmm.ui.activity.tools.IDCardQueryActivity; import com.maning.gankmm.ui.activity.tools.IPQueryActivity; -import com.maning.gankmm.ui.activity.tools.IdiomActivity; +import com.maning.gankmm.ui.activity.tools.WorldPhoneCodeActivity; import com.maning.gankmm.ui.activity.tools.LotteryCategoryActivity; import com.maning.gankmm.ui.activity.tools.OilPriceActivity; import com.maning.gankmm.ui.activity.tools.PhoneAddressActivity; @@ -72,21 +71,19 @@ public void onBindViewHolder(final RecyclerView.ViewHolder viewHolder, final int ArrayList mDatasItem = new ArrayList<>(); if (position == 0) { - 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("货币汇率"); -// mDatasItem.add("黄金数据"); -// mDatasItem.add("白银数据"); -// mDatasItem.add("国内现货交易所贵金属"); -// mDatasItem.add("全球股指查询"); + //生活阅读 + mDatasItem.add("历史上的今天"); } else if (position == 2) { + //休闲旅游 mDatasItem.add("周公解梦"); mDatasItem.add("婚姻匹配"); mDatasItem.add("八字算命"); @@ -96,9 +93,10 @@ public void onBindViewHolder(final RecyclerView.ViewHolder viewHolder, final int // mDatasItem.add("火车票查询"); // mDatasItem.add("航班信息查询"); } else if (position == 3) { - mDatasItem.add("垃圾分类"); - mDatasItem.add("历史上的今天"); - mDatasItem.add("新华字典"); + //工具集合 + mDatasItem.add("手机号码归属地"); + mDatasItem.add("IP地址"); + mDatasItem.add("世界电话区号"); // mDatasItem.add("全国省市今日油价"); // mDatasItem.add("汽车信息查询"); // mDatasItem.add("驾考题库"); @@ -125,23 +123,7 @@ public void onItemClick(View view, int position) { context.startActivity(new Intent(context, LotteryCategoryActivity.class)); } else if (title.equals("微信精选")) { context.startActivity(new Intent(context, WXArticleActivity.class)); - } - - if (title.equals("银行卡信息")) { - context.startActivity(new Intent(context, BankCardActivity.class)); - } else if (title.equals("货币汇率")) { - MySnackbar.makeSnackBarGreen(myViewHolder.recyclerViewItem, "功能暂未开通,敬请期待"); - } else if (title.equals("货币汇率")) { - MySnackbar.makeSnackBarGreen(myViewHolder.recyclerViewItem, "功能暂未开通,敬请期待"); - } else if (title.equals("白银数据")) { - MySnackbar.makeSnackBarGreen(myViewHolder.recyclerViewItem, "功能暂未开通,敬请期待"); - } else if (title.equals("国内现货交易所贵金属")) { - MySnackbar.makeSnackBarGreen(myViewHolder.recyclerViewItem, "功能暂未开通,敬请期待"); - } else if (title.equals("全球股指查询")) { - MySnackbar.makeSnackBarGreen(myViewHolder.recyclerViewItem, "功能暂未开通,敬请期待"); - } - - if (title.equals("周公解梦")) { + }else if (title.equals("周公解梦")) { IntentUtils.startToWebActivity(context, "工具", "周公解梦", "http://tools.2345.com/zhgjm.htm"); } else if (title.equals("婚姻匹配")) { IntentUtils.startToWebActivity(context, "工具", "婚姻匹配", "http://www.jjdzc.com/peidui/hehun.html"); @@ -157,14 +139,12 @@ public void onItemClick(View view, int position) { context.startActivity(new Intent(context, FlightActivity.class)); } else if (title.equals("足球五大联赛")) { MySnackbar.makeSnackBarGreen(myViewHolder.recyclerViewItem, "功能暂未开通,敬请期待"); - } - - if (title.equals("垃圾分类")) { + }else if (title.equals("垃圾分类")) { context.startActivity(new Intent(context, RubbishActivity.class)); } else if (title.equals("历史上的今天")) { context.startActivity(new Intent(context, HistoryTodayActivity.class)); - } else if (title.equals("成语大全")) { - context.startActivity(new Intent(context, IdiomActivity.class)); + } else if (title.equals("世界电话区号")) { + context.startActivity(new Intent(context, WorldPhoneCodeActivity.class)); } else if (title.equals("新华字典")) { context.startActivity(new Intent(context, DictionaryActivity.class)); } else if (title.equals("全国省市今日油价")) { diff --git a/app/src/main/java/com/maning/gankmm/ui/adapter/RecycleMoreItemAdapter.java b/app/src/main/java/com/maning/gankmm/ui/adapter/RecycleMoreItemAdapter.java index 4928a12..dc82763 100644 --- a/app/src/main/java/com/maning/gankmm/ui/adapter/RecycleMoreItemAdapter.java +++ b/app/src/main/java/com/maning/gankmm/ui/adapter/RecycleMoreItemAdapter.java @@ -4,6 +4,7 @@ import android.support.v7.widget.DefaultItemAnimator; import android.support.v7.widget.GridLayoutManager; import android.support.v7.widget.RecyclerView; +import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -12,7 +13,10 @@ import com.maning.gankmm.R; import com.maning.gankmm.listeners.OnItemClickListener; +import com.socks.library.KLog; +import com.socks.library.KLogUtil; +import java.util.HashMap; import java.util.List; import butterknife.Bind; @@ -23,6 +27,21 @@ */ public class RecycleMoreItemAdapter extends RecyclerView.Adapter { + private static HashMap titleIconMap = new HashMap() { + { + put("垃圾分类", R.drawable.gank_icon_tools_rubbish); + put("新华字典", R.drawable.gank_icon_tools_zidian); + put("历史上的今天", R.drawable.gank_icon_tools_history); + put("周公解梦", R.drawable.gank_icon_tools_zhougong); + put("婚姻匹配", R.drawable.gank_icon_tools_hunyin); + put("八字算命", R.drawable.gank_icon_tools_suanming); + put("老黄历", R.drawable.gank_icon_tools_huangli); + put("手机号码归属地", R.drawable.gank_icon_tools_phone_address); + put("IP地址", R.drawable.gank_icon_tools_ip); + put("世界电话区号", R.drawable.gank_icon_tools_phone_code); + } + }; + private Context context; private List mDatas; private LayoutInflater layoutInflater; @@ -55,74 +74,58 @@ public void onClick(View view) { String title = mDatas.get(position); myViewHolder.tv_title_more_item.setText(title); - - if (title.equals("手机号码归属地")) { - myViewHolder.iv_more_item.setImageResource(R.drawable.gank_icon_tools_phone_address); - } else if (title.equals("邮编查询")) { - myViewHolder.iv_more_item.setImageResource(R.drawable.gank_icon_tools_postcode); - } else if (title.equals("菜谱查询")) { - myViewHolder.iv_more_item.setImageResource(R.drawable.gank_icon_tools_cookbook); - } else if (title.equals("身份证查询")) { - myViewHolder.iv_more_item.setImageResource(R.drawable.gank_icon_tools_idcard_query); - } else if (title.equals("IP地址")) { - myViewHolder.iv_more_item.setImageResource(R.drawable.gank_icon_tools_ip); - } else if (title.equals("中国彩票开奖结果")) { - myViewHolder.iv_more_item.setImageResource(R.drawable.gank_icon_tools_lottery); - } else if (title.equals("微信精选")) { - myViewHolder.iv_more_item.setImageResource(R.drawable.gank_icon_tools_weixin); - } - - if (title.equals("银行卡信息")) { - myViewHolder.iv_more_item.setImageResource(R.drawable.gank_icon_tools_bank); - } else if (title.equals("白银数据")) { - myViewHolder.iv_more_item.setImageResource(R.drawable.gank_icon_tools_baiyin); - } else if (title.equals("黄金数据")) { - myViewHolder.iv_more_item.setImageResource(R.drawable.gank_icon_tools_gold); - } else if (title.equals("货币汇率")) { - myViewHolder.iv_more_item.setImageResource(R.drawable.gank_icon_tools_money); - } else if (title.equals("国内现货交易所贵金属")) { - myViewHolder.iv_more_item.setImageResource(R.drawable.gank_icon_tools_guijinshu); - } else if (title.equals("全球股指查询")) { - myViewHolder.iv_more_item.setImageResource(R.drawable.gank_icon_tools_guzhi); - } - - if (title.equals("周公解梦")) { - myViewHolder.iv_more_item.setImageResource(R.drawable.gank_icon_tools_zhougong); - } else if (title.equals("婚姻匹配")) { - myViewHolder.iv_more_item.setImageResource(R.drawable.gank_icon_tools_hunyin); - } else if (title.equals("手机号码查吉凶")) { - myViewHolder.iv_more_item.setImageResource(R.drawable.gank_icon_tools_jixiong); - } else if (title.equals("八字算命")) { - myViewHolder.iv_more_item.setImageResource(R.drawable.gank_icon_tools_suanming); - } else if (title.equals("老黄历")) { - myViewHolder.iv_more_item.setImageResource(R.drawable.gank_icon_tools_huangli); - } else if (title.equals("电影票房")) { - myViewHolder.iv_more_item.setImageResource(R.drawable.gank_icon_tools_movie); - } else if (title.equals("火车票查询")) { - myViewHolder.iv_more_item.setImageResource(R.drawable.gank_icon_tools_train); - } else if (title.equals("航班信息查询")) { - myViewHolder.iv_more_item.setImageResource(R.drawable.gank_icon_tools_plane); - } else if (title.equals("足球五大联赛")) { - myViewHolder.iv_more_item.setImageResource(R.drawable.gank_icon_tools_football); - } - - if (title.equals("健康知识")) { - myViewHolder.iv_more_item.setImageResource(R.drawable.gank_icon_tools_jiankang); - } else if (title.equals("历史上的今天")) { - myViewHolder.iv_more_item.setImageResource(R.drawable.gank_icon_tools_history); - } else if (title.equals("成语大全")) { - myViewHolder.iv_more_item.setImageResource(R.drawable.gank_icon_tools_chengyu); - } else if (title.equals("新华字典")) { - myViewHolder.iv_more_item.setImageResource(R.drawable.gank_icon_tools_zidian); - } else if (title.equals("全国省市今日油价")) { - myViewHolder.iv_more_item.setImageResource(R.drawable.gank_icon_tools_youjia); - } else if (title.equals("汽车信息查询")) { - myViewHolder.iv_more_item.setImageResource(R.drawable.gank_icon_tools_car); - } else if (title.equals("驾考题库")) { - myViewHolder.iv_more_item.setImageResource(R.drawable.gank_icon_tools_tiku_car); - }else if (title.equals("垃圾分类")) { - myViewHolder.iv_more_item.setImageResource(R.drawable.gank_icon_tools_rubbish); - } + Integer iconMap = titleIconMap.get(title); + myViewHolder.iv_more_item.setImageResource(iconMap == null ? R.drawable.gank_icon_more_tools : iconMap.intValue()); + +// if (title.equals("手机号码归属地")) { +// myViewHolder.iv_more_item.setImageResource(R.drawable.gank_icon_tools_phone_address); +// } else if (title.equals("邮编查询")) { +// myViewHolder.iv_more_item.setImageResource(R.drawable.gank_icon_tools_postcode); +// } else if (title.equals("菜谱查询")) { +// myViewHolder.iv_more_item.setImageResource(R.drawable.gank_icon_tools_cookbook); +// } else if (title.equals("身份证查询")) { +// myViewHolder.iv_more_item.setImageResource(R.drawable.gank_icon_tools_idcard_query); +// } else if (title.equals("IP地址")) { +// myViewHolder.iv_more_item.setImageResource(R.drawable.gank_icon_tools_ip); +// } else if (title.equals("中国彩票开奖结果")) { +// myViewHolder.iv_more_item.setImageResource(R.drawable.gank_icon_tools_lottery); +// } else if (title.equals("微信精选")) { +// myViewHolder.iv_more_item.setImageResource(R.drawable.gank_icon_tools_weixin); +// } else if (title.equals("周公解梦")) { +// myViewHolder.iv_more_item.setImageResource(R.drawable.gank_icon_tools_zhougong); +// } else if (title.equals("婚姻匹配")) { +// myViewHolder.iv_more_item.setImageResource(R.drawable.gank_icon_tools_hunyin); +// } else if (title.equals("手机号码查吉凶")) { +// myViewHolder.iv_more_item.setImageResource(R.drawable.gank_icon_tools_jixiong); +// } else if (title.equals("八字算命")) { +// myViewHolder.iv_more_item.setImageResource(R.drawable.gank_icon_tools_suanming); +// } else if (title.equals("老黄历")) { +// myViewHolder.iv_more_item.setImageResource(R.drawable.gank_icon_tools_huangli); +// } else if (title.equals("电影票房")) { +// myViewHolder.iv_more_item.setImageResource(R.drawable.gank_icon_tools_movie); +// } else if (title.equals("火车票查询")) { +// myViewHolder.iv_more_item.setImageResource(R.drawable.gank_icon_tools_train); +// } else if (title.equals("航班信息查询")) { +// myViewHolder.iv_more_item.setImageResource(R.drawable.gank_icon_tools_plane); +// } else if (title.equals("足球五大联赛")) { +// myViewHolder.iv_more_item.setImageResource(R.drawable.gank_icon_tools_football); +// }else if (title.equals("健康知识")) { +// myViewHolder.iv_more_item.setImageResource(R.drawable.gank_icon_tools_jiankang); +// } else if (title.equals("历史上的今天")) { +// myViewHolder.iv_more_item.setImageResource(R.drawable.gank_icon_tools_history); +// } else if (title.equals("成语大全")) { +// myViewHolder.iv_more_item.setImageResource(R.drawable.gank_icon_tools_chengyu); +// } else if (title.equals("新华字典")) { +// myViewHolder.iv_more_item.setImageResource(R.drawable.gank_icon_tools_zidian); +// } else if (title.equals("全国省市今日油价")) { +// myViewHolder.iv_more_item.setImageResource(R.drawable.gank_icon_tools_youjia); +// } else if (title.equals("汽车信息查询")) { +// myViewHolder.iv_more_item.setImageResource(R.drawable.gank_icon_tools_car); +// } else if (title.equals("驾考题库")) { +// myViewHolder.iv_more_item.setImageResource(R.drawable.gank_icon_tools_tiku_car); +// }else if (title.equals("垃圾分类")) { +// myViewHolder.iv_more_item.setImageResource(R.drawable.gank_icon_tools_rubbish); +// } } } @@ -151,5 +154,4 @@ public MyViewHolder(View itemView) { public void setOnItemClickLitener(OnItemClickListener mOnItemClickLitener) { this.mOnItemClickLitener = mOnItemClickLitener; } - } diff --git a/app/src/main/res/drawable-xxhdpi/gank_icon_tools_rubbish.png b/app/src/main/res/drawable-xxhdpi/gank_icon_tools_rubbish.png deleted file mode 100644 index 190abb8..0000000 Binary files a/app/src/main/res/drawable-xxhdpi/gank_icon_tools_rubbish.png and /dev/null differ diff --git a/app/src/main/res/drawable/gank_icon_tools_baiyin.xml b/app/src/main/res/drawable/gank_icon_tools_baiyin.xml deleted file mode 100644 index 6b04794..0000000 --- a/app/src/main/res/drawable/gank_icon_tools_baiyin.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/drawable/gank_icon_tools_bank.xml b/app/src/main/res/drawable/gank_icon_tools_bank.xml deleted file mode 100644 index c0047e7..0000000 --- a/app/src/main/res/drawable/gank_icon_tools_bank.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - - \ No newline at end of file diff --git a/app/src/main/res/drawable/gank_icon_tools_gold.xml b/app/src/main/res/drawable/gank_icon_tools_gold.xml deleted file mode 100644 index dcf889f..0000000 --- a/app/src/main/res/drawable/gank_icon_tools_gold.xml +++ /dev/null @@ -1,88 +0,0 @@ - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/drawable/gank_icon_tools_guijinshu.xml b/app/src/main/res/drawable/gank_icon_tools_guijinshu.xml deleted file mode 100644 index f22c6ae..0000000 --- a/app/src/main/res/drawable/gank_icon_tools_guijinshu.xml +++ /dev/null @@ -1,136 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/drawable/gank_icon_tools_guzhi.xml b/app/src/main/res/drawable/gank_icon_tools_guzhi.xml deleted file mode 100644 index 6a4b869..0000000 --- a/app/src/main/res/drawable/gank_icon_tools_guzhi.xml +++ /dev/null @@ -1,44 +0,0 @@ - - - - - \ No newline at end of file diff --git a/app/src/main/res/drawable/gank_icon_tools_money.xml b/app/src/main/res/drawable/gank_icon_tools_money.xml deleted file mode 100644 index 9e64001..0000000 --- a/app/src/main/res/drawable/gank_icon_tools_money.xml +++ /dev/null @@ -1,56 +0,0 @@ - - - - - \ No newline at end of file diff --git a/app/src/main/res/drawable/gank_icon_tools_phone_code.xml b/app/src/main/res/drawable/gank_icon_tools_phone_code.xml new file mode 100644 index 0000000..58af7d3 --- /dev/null +++ b/app/src/main/res/drawable/gank_icon_tools_phone_code.xml @@ -0,0 +1,18 @@ + + + + + + diff --git a/app/src/main/res/drawable/gank_icon_tools_rubbish.xml b/app/src/main/res/drawable/gank_icon_tools_rubbish.xml new file mode 100644 index 0000000..e400fc5 --- /dev/null +++ b/app/src/main/res/drawable/gank_icon_tools_rubbish.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/layout/activity_idiom.xml b/app/src/main/res/layout/activity_idiom.xml deleted file mode 100644 index 7ee0263..0000000 --- a/app/src/main/res/layout/activity_idiom.xml +++ /dev/null @@ -1,56 +0,0 @@ - - - - - - - -