├── .gitignore
├── README.md
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── com
│ │ └── ckj
│ │ └── dotaguide
│ │ ├── CommonApplication.java
│ │ ├── CustomGridView.java
│ │ ├── activity
│ │ ├── EquipmentInfoActivity.java
│ │ ├── HeroInfoActivity.java
│ │ ├── HerosActivity.java
│ │ └── MainActivity.java
│ │ ├── adapter
│ │ ├── CooperateHerosAdapter.java
│ │ ├── EquipmentGoodsAdapter.java
│ │ ├── EquipmentsAdapter.java
│ │ ├── EquipmentsGridAdapter.java
│ │ ├── HerosAdapter.java
│ │ ├── SkillOrderAdapter.java
│ │ └── SkillsAdapter.java
│ │ ├── model
│ │ └── Hero.java
│ │ ├── server
│ │ ├── CacheInterceptor.java
│ │ ├── HttpClientGenerator.java
│ │ └── HttpClientService.java
│ │ └── util
│ │ ├── NetworkUtils.java
│ │ └── RotateTextView.java
│ └── res
│ ├── drawable
│ ├── catalog_item_selector.xml
│ ├── cooperate_btn_bg_selector.xml
│ ├── default_image_cover_gray.png
│ ├── default_image_cover_white.png
│ ├── hero_gird_item_pressed_selector.xml
│ ├── hero_grid_item_cover_selector.xml
│ ├── hero_grid_item_selector.xml
│ ├── image_frame_selector.xml
│ ├── image_pressed_selector.xml
│ ├── loading.png
│ ├── price.png
│ ├── restraint_btn_bg_selector.xml
│ ├── right_arrow.png
│ ├── skill_list_item_selector.xml
│ ├── text_frame_selector.xml
│ └── triangle_corner.png
│ ├── layout
│ ├── activity_equipment_info.xml
│ ├── activity_hero_info.xml
│ ├── activity_heros.xml
│ ├── activity_main.xml
│ ├── cooperate_hero_dialog.xml
│ ├── cooperate_hero_list_item.xml
│ ├── equipment_goods_grid_item.xml
│ ├── equipment_goods_list_item.xml
│ ├── equipment_list_item.xml
│ ├── hero_grid_item.xml
│ ├── skill_detail_dialog.xml
│ ├── skill_list_item.xml
│ └── skill_order_item.xml
│ ├── mipmap-hdpi
│ └── ic_launcher.png
│ ├── mipmap-mdpi
│ └── ic_launcher.png
│ ├── mipmap-xhdpi
│ └── ic_launcher.png
│ ├── mipmap-xxhdpi
│ └── ic_launcher.png
│ ├── mipmap-xxxhdpi
│ └── ic_launcher.png
│ ├── values-w820dp
│ └── dimens.xml
│ └── values
│ ├── attrs.xml
│ ├── colors.xml
│ ├── dimens.xml
│ ├── strings.xml
│ └── styles.xml
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 |
3 |
4 | .gradle
5 |
6 | local.properties
7 |
8 | .idea
9 |
10 | build
11 |
12 | app/build
13 |
14 | captures
15 |
16 | .DS_Store
17 |
18 | app/.DS_Store
19 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # DotaGuide
2 |
3 | APP效果图:
4 |
5 |
6 |
7 |
8 | APP下载地址:https://pan.baidu.com/s/1c4i2YT6
9 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 25
5 | buildToolsVersion "25.0.0"
6 | defaultConfig {
7 | applicationId "com.ckj.dotaguide"
8 | minSdkVersion 17
9 | targetSdkVersion 25
10 | versionCode 1
11 | versionName "1.0"
12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
13 |
14 | renderscriptTargetApi 18
15 | renderscriptSupportModeEnabled true
16 | }
17 | buildTypes {
18 | release {
19 | minifyEnabled false
20 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
21 | }
22 | }
23 |
24 | useLibrary 'org.apache.http.legacy'
25 | }
26 |
27 | dependencies {
28 | compile fileTree(dir: 'libs', include: ['*.jar'])
29 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
30 | exclude group: 'com.android.support', module: 'support-annotations'
31 | })
32 |
33 | compile 'com.android.support:appcompat-v7:25.0.0'
34 | compile 'com.android.support:design:25.0.0'
35 | compile 'com.squareup.retrofit2:retrofit:2.2.0'
36 | compile 'com.squareup.retrofit2:adapter-rxjava:2.2.0'
37 | compile 'io.reactivex:rxandroid:1.2.1'
38 | compile 'org.jsoup:jsoup:1.10.2'
39 | compile 'com.android.support.constraint:constraint-layout:1.0.2'
40 | compile 'com.github.bumptech.glide:glide:3.7.0'
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /home/chenkaijian/Android/Sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
15 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
27 |
30 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/app/src/main/java/com/ckj/dotaguide/CommonApplication.java:
--------------------------------------------------------------------------------
1 | package com.ckj.dotaguide;
2 |
3 | import android.app.Application;
4 | import android.content.Context;
5 |
6 | /**
7 | * Created by chenkaijian on 17-8-31.
8 | */
9 |
10 | public class CommonApplication extends Application {
11 |
12 | public static Context mContext = null;
13 |
14 | @Override
15 | public void onCreate() {
16 | super.onCreate();
17 | mContext = this;
18 | }
19 |
20 | public static CommonApplication getInstance() {
21 | return (CommonApplication) mContext;
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/app/src/main/java/com/ckj/dotaguide/CustomGridView.java:
--------------------------------------------------------------------------------
1 | package com.ckj.dotaguide;
2 |
3 | import android.content.Context;
4 | import android.util.AttributeSet;
5 | import android.widget.GridView;
6 |
7 | /**
8 | * GridView,解决ScrollView中嵌套GridView显示不正常的问题
9 | * Created by chenkaijian on 17-3-14.
10 | */
11 |
12 | public class CustomGridView extends GridView {
13 |
14 | public CustomGridView(Context context, AttributeSet attrs) {
15 | super(context, attrs);
16 | }
17 |
18 | public CustomGridView(Context context) {
19 | super(context);
20 | }
21 |
22 | public CustomGridView(Context context, AttributeSet attrs, int defStyle) {
23 | super(context, attrs, defStyle);
24 | }
25 |
26 | @Override
27 | public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
28 |
29 | int expandSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2,
30 | MeasureSpec.AT_MOST);
31 | super.onMeasure(widthMeasureSpec, expandSpec);
32 | }
33 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/ckj/dotaguide/activity/EquipmentInfoActivity.java:
--------------------------------------------------------------------------------
1 | package com.ckj.dotaguide.activity;
2 |
3 | import android.app.Activity;
4 | import android.content.Context;
5 | import android.content.Intent;
6 | import android.os.Bundle;
7 | import android.support.v7.widget.LinearLayoutManager;
8 | import android.support.v7.widget.RecyclerView;
9 | import android.util.Log;
10 | import android.view.View;
11 | import android.widget.ImageView;
12 | import android.widget.TextView;
13 |
14 | import com.bumptech.glide.Glide;
15 | import com.ckj.dotaguide.R;
16 | import com.ckj.dotaguide.adapter.EquipmentGoodsAdapter;
17 | import com.ckj.dotaguide.server.HttpClientGenerator;
18 |
19 | import org.jsoup.Jsoup;
20 | import org.jsoup.nodes.Document;
21 | import org.jsoup.nodes.Element;
22 | import org.jsoup.select.Elements;
23 |
24 | import java.util.ArrayList;
25 | import java.util.HashMap;
26 |
27 | import okhttp3.ResponseBody;
28 | import rx.Subscriber;
29 | import rx.android.schedulers.AndroidSchedulers;
30 | import rx.schedulers.Schedulers;
31 |
32 | public class EquipmentInfoActivity extends Activity {
33 |
34 | private Context mContext;
35 | private int type;
36 | private String itemid;
37 | private String path;
38 |
39 | private ImageView mPortraitView;
40 | private TextView mNameTextView;
41 | private TextView mPriceTextView;
42 | private TextView mDescTextView;
43 |
44 | private View mRequestView;
45 | private RecyclerView mRequestRecyclerView;
46 | private ArrayList mRequestGoodsDatas;
47 | private EquipmentGoodsAdapter mRequestGoodsAdapter;
48 |
49 | private View mProvideView;
50 | private RecyclerView mProvideRecyclerView;
51 | private ArrayList mProvideGoodsDatas;
52 | private EquipmentGoodsAdapter mProvideGoodsAdapter;
53 |
54 | @Override
55 | protected void onCreate(Bundle savedInstanceState) {
56 | super.onCreate(savedInstanceState);
57 | setContentView(R.layout.activity_equipment_info);
58 |
59 | mContext = this;
60 | Intent intent = getIntent();
61 | type = intent.getIntExtra("type", 1);
62 | if (type == 1) {
63 | itemid = intent.getStringExtra("itemid");
64 | Log.v("ckjc", "itemid=" + itemid);
65 | } else {
66 | path = intent.getStringExtra("path");
67 | }
68 |
69 | // 物品基本信息
70 | mNameTextView = (TextView) findViewById(R.id.name);
71 | mPortraitView = (ImageView) findViewById(R.id.img);
72 | mPriceTextView = (TextView) findViewById(R.id.price);
73 | mDescTextView = (TextView) findViewById(R.id.desc_textview);
74 |
75 | mRequestView = findViewById(R.id.request_goods_view);
76 | mRequestRecyclerView = (RecyclerView) findViewById(R.id.request_recyclerview);
77 | LinearLayoutManager ll = new LinearLayoutManager(mContext);
78 | ll.setOrientation(LinearLayoutManager.VERTICAL);
79 | mRequestRecyclerView.setLayoutManager(ll);
80 | mRequestGoodsDatas = new ArrayList();
81 | mRequestGoodsAdapter = new EquipmentGoodsAdapter(mContext, mRequestGoodsDatas);
82 | mRequestRecyclerView.setAdapter(mRequestGoodsAdapter);
83 | mRequestGoodsAdapter.setOnItemClickListener(new EquipmentGoodsAdapter.OnItemClickListener() {
84 | @Override
85 | public void onItemClick(View view, int position) {
86 | showEquipmentInfo(mRequestGoodsDatas, position);
87 | }
88 | });
89 |
90 | mProvideView = findViewById(R.id.provide_goods_view);
91 | mProvideRecyclerView = (RecyclerView) findViewById(R.id.provide_recyclerview);
92 | LinearLayoutManager ll2 = new LinearLayoutManager(mContext);
93 | ll2.setOrientation(LinearLayoutManager.VERTICAL);
94 | mProvideRecyclerView.setLayoutManager(ll2);
95 | mProvideGoodsDatas = new ArrayList();
96 | mProvideGoodsAdapter = new EquipmentGoodsAdapter(mContext, mProvideGoodsDatas);
97 | mProvideRecyclerView.setAdapter(mProvideGoodsAdapter);
98 | mProvideGoodsAdapter.setOnItemClickListener(new EquipmentGoodsAdapter.OnItemClickListener() {
99 | @Override
100 | public void onItemClick(View view, int position) {
101 | showEquipmentInfo(mProvideGoodsDatas, position);
102 | }
103 | });
104 |
105 | getItem(type);
106 | }
107 |
108 | private void getItem(int type) {
109 | rx.Observable observable;
110 | if (type == 1) {
111 | String url = "http://dotadb.uuu9.com/items_index.aspx";
112 | observable = HttpClientGenerator.getHttpClientService().getItem(url, itemid);
113 | } else {
114 | String url = "http://db.dota.uuu9.com" + path;
115 | observable = HttpClientGenerator.getHttpClientService().getItem(url);
116 | }
117 | observable
118 | .subscribeOn(Schedulers.io())
119 | .observeOn(AndroidSchedulers.mainThread())
120 | .subscribe(new Subscriber() {
121 |
122 | @Override
123 | public void onNext(ResponseBody responseBody) {
124 | try {
125 | String html = new String(responseBody.bytes(), "utf-8");
126 | Document doc = Jsoup.parse(html);
127 | Element bodyElement = doc.getElementsByClass("w719 r").first();
128 | Element nameElement = bodyElement.getElementsByClass("picbox l").first();
129 | String name = nameElement.getElementsByTag("img").attr("title");
130 | String src = nameElement.getElementsByTag("img").attr("src");
131 | Log.v("ckjc", "name=" + name + " src=" + src);
132 | Glide.with(mContext).load(src).placeholder(R.drawable.default_image_cover_gray).into(mPortraitView);
133 | mNameTextView.setText(name);
134 |
135 | Element infoElement = bodyElement.getElementsByClass("textbox r").first();
136 | Element goldElement = infoElement.getElementsByClass("gold").first();
137 | mPriceTextView.setText("价格:" + goldElement.text());
138 | Element descElement = infoElement.getElementsByTag("p").get(1);
139 | String desc = descElement.ownText();
140 | Elements links = descElement.getElementsByTag("span");
141 | for (Element link : links) {
142 | String item = link.text();
143 | desc = desc + "\n" + item;
144 | }
145 | Log.v("ckjc", "mDescList=" + desc);
146 | mDescTextView.setText(desc);
147 |
148 | // 合成配方
149 | Element requestGoodsElement = bodyElement.getElementsByClass("content jianbg cl").first();
150 | Elements requestGoods = requestGoodsElement.getElementsByTag("li");
151 | if (requestGoods != null) {
152 | for (Element link : requestGoods) {
153 | String goodsSrc = link.getElementsByTag("img").attr("src");
154 | String goodsHref = link.getElementsByTag("a").attr("href");
155 | String goodsName = link.getElementsByTag("a").get(1).text();
156 | String goodsGold = link.getElementsByClass("gold").text();
157 | HashMap map = new HashMap();
158 | map.put("src", goodsSrc);
159 | map.put("href", goodsHref);
160 | map.put("name", goodsName);
161 | map.put("gold", goodsGold);
162 | mRequestGoodsDatas.add(map);
163 | }
164 | }
165 | if (mRequestGoodsDatas.size() != 0) {
166 | mRequestView.setVisibility(View.VISIBLE);
167 | mProvideGoodsAdapter.notifyDataSetChanged();
168 | }
169 |
170 | // 可升级为
171 | Element provideGoodsElement = bodyElement.getElementsByClass("content jianbg cl").get(1);
172 | Elements provideGoods = provideGoodsElement.getElementsByTag("li");
173 | if (provideGoods != null) {
174 | for (Element link : provideGoods) {
175 | String goodsSrc = link.getElementsByTag("img").attr("src");
176 | String goodsHref = link.getElementsByTag("a").attr("href");
177 | String goodsName = link.getElementsByTag("a").get(1).text();
178 | String goodsGold = link.getElementsByClass("gold").text();
179 | HashMap map = new HashMap();
180 | map.put("src", goodsSrc);
181 | map.put("href", goodsHref);
182 | map.put("name", goodsName);
183 | map.put("gold", goodsGold);
184 | mProvideGoodsDatas.add(map);
185 | }
186 | }
187 | if (mProvideGoodsDatas.size() != 0) {
188 | mProvideView.setVisibility(View.VISIBLE);
189 | mProvideGoodsAdapter.notifyDataSetChanged();
190 | }
191 |
192 | } catch (Exception e) {
193 | e.printStackTrace();
194 | }
195 | }
196 |
197 | @Override
198 | public void onCompleted() {
199 | }
200 |
201 | @Override
202 | public void onError(Throwable e) {
203 | Log.v("ckjc", "failure");
204 | e.printStackTrace();
205 | }
206 | });
207 |
208 | }
209 |
210 | /**
211 | * 跳转进入物品详情页面
212 | */
213 | private void showEquipmentInfo(ArrayList datas, int position) {
214 | String path = ((HashMap) datas.get(position)).get("href").toString();
215 | Intent intent = new Intent();
216 | intent.putExtra("type", 2);
217 | intent.putExtra("path", path);
218 | intent.setClass(mContext, EquipmentInfoActivity.class);
219 | startActivity(intent);
220 | }
221 |
222 | }
223 |
--------------------------------------------------------------------------------
/app/src/main/java/com/ckj/dotaguide/activity/HeroInfoActivity.java:
--------------------------------------------------------------------------------
1 | package com.ckj.dotaguide.activity;
2 |
3 | import android.app.Activity;
4 | import android.content.Context;
5 | import android.content.Intent;
6 | import android.os.Bundle;
7 | import android.support.v7.app.AlertDialog;
8 | import android.support.v7.widget.LinearLayoutManager;
9 | import android.support.v7.widget.RecyclerView;
10 | import android.util.Log;
11 | import android.view.View;
12 | import android.widget.GridView;
13 | import android.widget.ImageView;
14 | import android.widget.TextView;
15 |
16 | import com.bumptech.glide.Glide;
17 | import com.ckj.dotaguide.adapter.CooperateHerosAdapter;
18 | import com.ckj.dotaguide.adapter.EquipmentsAdapter;
19 | import com.ckj.dotaguide.adapter.SkillOrderAdapter;
20 | import com.ckj.dotaguide.adapter.SkillsAdapter;
21 | import com.ckj.dotaguide.R;
22 | import com.ckj.dotaguide.server.HttpClientGenerator;
23 | import com.ckj.dotaguide.util.RotateTextView;
24 |
25 | import org.jsoup.Jsoup;
26 | import org.jsoup.nodes.Document;
27 | import org.jsoup.nodes.Element;
28 | import org.jsoup.select.Elements;
29 |
30 | import java.io.IOException;
31 | import java.util.ArrayList;
32 | import java.util.HashMap;
33 |
34 | import okhttp3.ResponseBody;
35 | import rx.Subscriber;
36 | import rx.android.schedulers.AndroidSchedulers;
37 | import rx.schedulers.Schedulers;
38 |
39 | public class HeroInfoActivity extends Activity {
40 |
41 | private Context mContext = null;
42 | private String heroId;
43 |
44 | private TextView mTitleView;
45 | private ImageView mPortraitView;
46 | private TextView mHPView, mMPView;
47 | private TextView mAttrView1, mAttrView2, mAttrView3, mAttrView4, mAttrView5, mAttrView6;
48 | private TextView mCooperateBtn, mRestraintBtn;
49 | private GridView mSkillOrderGridView;
50 | private TextView mSkillOrderDescView;
51 | private RecyclerView mSkillRecyclerView;
52 |
53 | // 配合英雄和克制英雄
54 | private ArrayList mCooperateList, mRestraintList;
55 | private CooperateHerosAdapter adapter;
56 | // 技能加点顺序
57 | private String skillOrderDesc;
58 | private SkillOrderAdapter mSkillOrderAdapter;
59 | private ArrayList skillOrder;
60 | // 推荐出装
61 | private RecyclerView mEquipmentRecyclerView;
62 | private ArrayList mEquipmentDatas;
63 | private EquipmentsAdapter mEquipmentsAdapter;
64 | // 技能介绍
65 | private SkillsAdapter mSkillsAdapter;
66 | private ArrayList skills;
67 |
68 | @Override
69 | protected void onCreate(Bundle savedInstanceState) {
70 | super.onCreate(savedInstanceState);
71 | setContentView(R.layout.activity_hero_info);
72 |
73 | mContext = this;
74 |
75 | Intent intent = getIntent();
76 | heroId = intent.getStringExtra("heroId");
77 | Log.v("ckjc", "heroId=" + heroId);
78 |
79 | // 基础属性
80 | mTitleView = (TextView) findViewById(R.id.title);
81 | mPortraitView = (ImageView) findViewById(R.id.img);
82 | mHPView = (TextView) findViewById(R.id.hp);
83 | mMPView = (TextView) findViewById(R.id.mp);
84 | mAttrView1 = (TextView) findViewById(R.id.attr1);
85 | mAttrView2 = (TextView) findViewById(R.id.attr2);
86 | mAttrView3 = (TextView) findViewById(R.id.attr3);
87 | mAttrView4 = (TextView) findViewById(R.id.attr4);
88 | mAttrView5 = (TextView) findViewById(R.id.attr5);
89 | mAttrView6 = (TextView) findViewById(R.id.attr6);
90 |
91 | // 配合英雄和克制英雄
92 | mCooperateBtn = (TextView) findViewById(R.id.cooperateBtn);
93 | mRestraintBtn = (TextView) findViewById(R.id.restraintBtn);
94 | mCooperateList = new ArrayList();
95 | mRestraintList = new ArrayList();
96 | mCooperateBtn.setOnClickListener(new View.OnClickListener() {
97 | @Override
98 | public void onClick(View view) {
99 | showCooperatePopup("配合英雄", mCooperateList);
100 | }
101 | });
102 | mRestraintBtn.setOnClickListener(new View.OnClickListener() {
103 | @Override
104 | public void onClick(View view) {
105 | showCooperatePopup("克制英雄", mRestraintList);
106 | }
107 | });
108 |
109 | // 加点顺序
110 | mSkillOrderGridView = (GridView) findViewById(R.id.skill_order_grid);
111 | mSkillOrderDescView = (TextView) findViewById(R.id.skillOrderDesc);
112 | skillOrder = new ArrayList();
113 | mSkillOrderAdapter = new SkillOrderAdapter(mContext, heroId, skillOrder);
114 | mSkillOrderGridView.setAdapter(mSkillOrderAdapter);
115 |
116 | // 推荐出装
117 | mEquipmentRecyclerView = (RecyclerView) findViewById(R.id.equipments_recyclerview);
118 | LinearLayoutManager ll2 = new LinearLayoutManager(HeroInfoActivity.this);
119 | ll2.setOrientation(LinearLayoutManager.VERTICAL);
120 | mEquipmentRecyclerView.setLayoutManager(ll2);
121 | mEquipmentDatas = new ArrayList();
122 | mEquipmentsAdapter = new EquipmentsAdapter(this, mEquipmentDatas);
123 | mEquipmentRecyclerView.setAdapter(mEquipmentsAdapter);
124 |
125 | // 技能介绍
126 | mSkillRecyclerView = (RecyclerView) findViewById(R.id.skill_recyclerview);
127 | LinearLayoutManager ll = new LinearLayoutManager(HeroInfoActivity.this);
128 | ll.setOrientation(LinearLayoutManager.VERTICAL);
129 | mSkillRecyclerView.setLayoutManager(ll);
130 | skills = new ArrayList();
131 | mSkillsAdapter = new SkillsAdapter(mContext, heroId, skills);
132 | mSkillRecyclerView.setAdapter(mSkillsAdapter);
133 | mSkillsAdapter.setOnItemClickListener(new SkillsAdapter.OnItemClickListener() {
134 | @Override
135 | public void onItemClick(View view, int position) {
136 | showSkillDetailDialog(position);
137 | }
138 | });
139 |
140 | getHeroInfo();
141 | }
142 |
143 | private void getHeroInfo() {
144 | HttpClientGenerator.getHttpClientService().getHero(heroId)
145 | .subscribeOn(Schedulers.io())
146 | .observeOn(AndroidSchedulers.mainThread())
147 | .subscribe(new Subscriber() {
148 |
149 | @Override
150 | public void onNext(ResponseBody responseBody) {
151 | try {
152 | String html = new String(responseBody.bytes(), "GB2312");
153 | Document doc = Jsoup.parse(html);
154 |
155 | // 英雄信息
156 | Element bodyElement = doc.getElementsByClass("l zhiye_jieshao").first();
157 | String portraitUrl = bodyElement.getElementsByTag("img").first().attr("src");
158 | String name = bodyElement.getElementsByTag("h4").first().text();
159 | String nickname = bodyElement.getElementsByTag("dd").first().ownText().split(" ")[0];
160 | String abbreviation = bodyElement.getElementsByTag("em").first().text();
161 | Log.v("ckjc", "name=" + name + " nickname=" + nickname + " abbreviation=" + abbreviation + " portraitUrl=" + portraitUrl);
162 | mTitleView.setText(name + "(" + abbreviation + ")");
163 | if (!portraitUrl.startsWith("http")) {
164 | portraitUrl = "http://dota.uuu9.com/hero/" + heroId + "/" + portraitUrl;
165 | }
166 | Glide.with(mContext).load(portraitUrl).placeholder(R.drawable.default_image_cover_gray).into(mPortraitView);
167 |
168 | // 血量和魔量
169 | Element capacityElement = doc.getElementsByClass("cl capacity").first();
170 | String hp = capacityElement.getElementsByTag("dd").first().text();
171 | String mp = capacityElement.getElementsByTag("dd").get(1).text();
172 |
173 | mHPView.setText(hp);
174 | mMPView.setText(mp);
175 |
176 | // 基础属性
177 | Element table = doc.getElementsByTag("table").first();
178 | String attr1 = table.getElementsByTag("td").first().text();
179 | String attr2 = table.getElementsByTag("td").get(1).text();
180 | String attr3 = table.getElementsByTag("td").get(2).text();
181 | String attr4 = table.getElementsByTag("td").get(3).text();
182 | String attr5 = table.getElementsByTag("td").get(4).text();
183 | String attr6 = table.getElementsByTag("td").get(5).text();
184 | mAttrView1.setText(attr1);
185 | mAttrView2.setText(attr2);
186 | mAttrView3.setText(attr3);
187 | mAttrView4.setText(attr4);
188 | mAttrView5.setText(attr5);
189 | mAttrView6.setText(attr6);
190 |
191 | // 配合及克制英雄
192 | Element cooperateElement = bodyElement.getElementsByClass("cl cooperate_box").first();
193 | Elements cooperateItems = cooperateElement.getElementsByTag("a");
194 | for (Element link : cooperateItems) {
195 | HashMap map = new HashMap();
196 | String cooperateSrc = link.getElementsByTag("img").attr("src");
197 | String cooperateName = link.text();
198 | map.put("src", cooperateSrc);
199 | map.put("name", cooperateName);
200 | mCooperateList.add(map);
201 | }
202 |
203 | Element restraintElement = bodyElement.getElementsByClass("cl cooperate_box").get(1);
204 | Elements restraintItems = restraintElement.getElementsByTag("a");
205 | for (Element link : restraintItems) {
206 | String restraintSrc = link.getElementsByTag("img").attr("src");
207 | String restraintName = link.text();
208 | HashMap map = new HashMap();
209 | map.put("src", restraintSrc);
210 | map.put("name", restraintName);
211 | mRestraintList.add(map);
212 | }
213 |
214 | // 技能加点顺序
215 | Element skillOrderElement = doc.getElementsByClass("cl chuzhuang").first();
216 | Element firstSkillOrderElement = skillOrderElement.getElementsByClass("cl lpicbox").first();
217 | Elements links = firstSkillOrderElement.getElementsByTag("img");
218 | for (Element link : links) {
219 | String title = link.attr("title");
220 | String src = link.attr("src");
221 | skillOrder.add(src);
222 | }
223 | mSkillOrderAdapter.notifyDataSetChanged();
224 |
225 | skillOrderDesc = skillOrderElement.getElementsByClass("cgcon").first().text();
226 | mSkillOrderDescView.setText(skillOrderDesc);
227 |
228 | // 推荐出装
229 | Element equipmentElement = doc.getElementsByClass("cl m-10 chuzhuang").first();
230 | Elements titleElements = equipmentElement.getElementsByTag("strong");
231 | Elements goodsElements = equipmentElement.getElementsByClass("cl lpicbox");
232 | Elements descElements = equipmentElement.getElementsByClass("cgcon");
233 | for (int i = 0; i < titleElements.size(); i++) {
234 | HashMap hashMap = new HashMap();
235 | String title = titleElements.get(i).text();
236 | ArrayList goodsList = new ArrayList();
237 | Elements goods = goodsElements.get(i).getElementsByTag("li");
238 | for (Element good : goods) {
239 | String itemid = "";
240 | String href = good.getElementsByTag("a").attr("href");
241 | // http://dotadb.uuu9.com/items_index.aspx?itemid=reja
242 | // http://db.dota.uuu9.com/goods/show/SoulRing
243 | if (href.contains("=")) {
244 | itemid = href.split("=")[1];
245 | }
246 | // else if (!href.equals("")) {
247 | // itemid = href.substring(45).split("\\.")[0];
248 | // }
249 | String src = good.getElementsByTag("img").attr("src");
250 | HashMap map = new HashMap();
251 | map.put("itemid", itemid);
252 | map.put("src", src);
253 | if (src.endsWith("bmp")) {
254 | continue;
255 | }
256 | goodsList.add(map);
257 | }
258 | String desc = descElements.get(i).text();
259 |
260 | hashMap.put("title", title);
261 | hashMap.put("goodsList", goodsList);
262 | hashMap.put("desc", desc);
263 | mEquipmentDatas.add(hashMap);
264 | }
265 |
266 | mEquipmentsAdapter.setAbbreviation(abbreviation);
267 | mEquipmentsAdapter.notifyDataSetChanged();
268 |
269 | // 技能介绍
270 | Elements skillElements = doc.getElementsByClass("spell-body");
271 | for (Element skillElement : skillElements) {
272 | String img = skillElement.getElementsByTag("img").attr("src");
273 | String skillName = skillElement.getElementsByTag("img").attr("alt");
274 | String skillAttr = skillElement.getElementsByClass("spellicon").text();
275 | String hotKey = skillElement.getElementsByClass("hotkey").text();
276 | StringBuilder desc = new StringBuilder();
277 | HashMap map = new HashMap();
278 | Elements elements = skillElement.getElementsByTag("p");
279 | for (int i = 1; i < elements.size(); i++) {
280 | desc.append(elements.get(i).text() + "\n");
281 | }
282 | map.put("img", img);
283 | map.put("name", skillName);
284 | map.put("attr", skillAttr);
285 | map.put("hotkey", hotKey);
286 | map.put("desc", desc);
287 | Log.v("ckjc", "img=" + img + " skillName=" + skillName + " skillAttr=" + skillAttr + " hotKey=" + hotKey);
288 | skills.add(map);
289 | }
290 | mSkillsAdapter.notifyDataSetChanged();
291 | } catch (IOException e) {
292 | e.printStackTrace();
293 | }
294 | }
295 |
296 | @Override
297 | public void onCompleted() {
298 | }
299 |
300 | @Override
301 | public void onError(Throwable e) {
302 | Log.v("ckjc", "getHero failure");
303 | e.printStackTrace();
304 | }
305 | });
306 |
307 | }
308 |
309 | /**
310 | * 显示配合克制英雄弹框
311 | */
312 | private void showCooperatePopup(String title, ArrayList datas) {
313 | View v = getLayoutInflater().inflate(R.layout.cooperate_hero_dialog, null);
314 | TextView mTitleView = (TextView) v.findViewById(R.id.title);
315 | mTitleView.setText(title);
316 | RecyclerView mRecyclerView = (RecyclerView) v.findViewById(R.id.recyclerView);
317 | LinearLayoutManager ll = new LinearLayoutManager(HeroInfoActivity.this);
318 | ll.setOrientation(LinearLayoutManager.VERTICAL);
319 | mRecyclerView.setLayoutManager(ll);
320 | adapter = new CooperateHerosAdapter(mContext, heroId, datas);
321 | mRecyclerView.setAdapter(adapter);
322 |
323 | AlertDialog.Builder builder = new AlertDialog.Builder(mContext)
324 | .setView(v);
325 | AlertDialog dialog = builder.create();
326 | dialog.show();
327 | }
328 |
329 | /**
330 | * 显示技能详细信息
331 | */
332 | private void showSkillDetailDialog(int position) {
333 | String src = (((HashMap) skills.get(position)).get("img")).toString();
334 | if (!src.startsWith("http")) {
335 | src = "http://dota.uuu9.com/hero/" + heroId + "/" + src;
336 | }
337 | String name = ((HashMap) skills.get(position)).get("name").toString();
338 | String attr = ((HashMap) skills.get(position)).get("attr").toString();
339 | String hotkey = ((HashMap) skills.get(position)).get("hotkey").toString();
340 | String desc = ((HashMap) skills.get(position)).get("desc").toString();
341 |
342 | View v = getLayoutInflater().inflate(R.layout.skill_detail_dialog, null);
343 | ImageView img = (ImageView) v.findViewById(R.id.img);
344 | RotateTextView mAttrTV = (RotateTextView) v.findViewById(R.id.attr);
345 | TextView mNameTV = (TextView) v.findViewById(R.id.name);
346 | TextView mHotkeyTV = (TextView) v.findViewById(R.id.hot_key);
347 | TextView mDescTV = (TextView) v.findViewById(R.id.desc);
348 | Glide.with(mContext).load(src).placeholder(R.drawable.default_image_cover_gray).into(img);
349 | mAttrTV.setText(attr);
350 | mNameTV.setText(name);
351 | mHotkeyTV.setText(hotkey);
352 | mDescTV.setText(desc);
353 |
354 | AlertDialog.Builder builder = new AlertDialog.Builder(mContext)
355 | .setView(v);
356 | AlertDialog dialog = builder.create();
357 | dialog.show();
358 | }
359 | }
360 |
--------------------------------------------------------------------------------
/app/src/main/java/com/ckj/dotaguide/activity/HerosActivity.java:
--------------------------------------------------------------------------------
1 | package com.ckj.dotaguide.activity;
2 |
3 | import android.app.Activity;
4 | import android.content.Intent;
5 | import android.os.Bundle;
6 | import android.util.Log;
7 | import android.view.View;
8 | import android.widget.AdapterView;
9 |
10 | import com.ckj.dotaguide.CustomGridView;
11 | import com.ckj.dotaguide.R;
12 | import com.ckj.dotaguide.adapter.HerosAdapter;
13 | import com.ckj.dotaguide.server.HttpClientGenerator;
14 |
15 | import org.jsoup.Jsoup;
16 | import org.jsoup.nodes.Document;
17 | import org.jsoup.nodes.Element;
18 | import org.jsoup.select.Elements;
19 |
20 | import java.io.IOException;
21 | import java.util.ArrayList;
22 | import java.util.HashMap;
23 |
24 | import okhttp3.ResponseBody;
25 | import rx.Subscriber;
26 | import rx.android.schedulers.AndroidSchedulers;
27 | import rx.schedulers.Schedulers;
28 |
29 | /**
30 | * Created by chenkaijian on 17-8-24.
31 | */
32 |
33 | public class HerosActivity extends Activity {
34 |
35 | /**
36 | * hero type
37 | */
38 | private int type;
39 | private CustomGridView mHerosGridView;
40 | private HerosAdapter mHerosAdapter;
41 | private ArrayList datas;
42 |
43 | @Override
44 | protected void onCreate(Bundle savedInstanceState) {
45 | super.onCreate(savedInstanceState);
46 | setContentView(R.layout.activity_heros);
47 |
48 | Intent intent = getIntent();
49 | type = intent.getIntExtra("type", 0);
50 |
51 | mHerosGridView = (CustomGridView) findViewById(R.id.heros_gridview);
52 | datas = new ArrayList();
53 | mHerosAdapter = new HerosAdapter(this, datas);
54 | mHerosGridView.setAdapter(mHerosAdapter);
55 | mHerosGridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
56 | @Override
57 | public void onItemClick(AdapterView> adapterView, View view, int i, long l) {
58 | Intent intent = new Intent();
59 | intent.putExtra("heroId", ((HashMap) datas.get(i)).get("heroId").toString());
60 | intent.setClass(HerosActivity.this, HeroInfoActivity.class);
61 | startActivity(intent);
62 | }
63 | });
64 |
65 | getHeros();
66 | }
67 |
68 | private void getHeros() {
69 | HttpClientGenerator.getHttpClientService().getHeros()
70 | .subscribeOn(Schedulers.io())
71 | .observeOn(AndroidSchedulers.mainThread())
72 | .subscribe(new Subscriber() {
73 |
74 | @Override
75 | public void onNext(ResponseBody responseBody) {
76 | try {
77 | String html = new String(responseBody.bytes(), "GB2312");
78 | Document doc = Jsoup.parse(html);
79 | Element bodyElement = doc.getElementsByClass("l hero_box").first();
80 | Element powerElement = bodyElement.getElementsByClass("cl con picbox").get(type);
81 | Elements links = powerElement.getElementsByTag("li");
82 |
83 | for (Element link : links) {
84 | String img = link.getElementsByTag("img").attr("src");
85 | String name = link.text();
86 | String href = link.getElementsByTag("a").attr("href");
87 | String heroId = href.substring(26, href.length() - 1);
88 | HashMap map = new HashMap();
89 | map.put("img", img);
90 | map.put("name", name);
91 | map.put("heroId", heroId);
92 | datas.add(map);
93 | }
94 | mHerosAdapter.notifyDataSetChanged();
95 | } catch (IOException e) {
96 | e.printStackTrace();
97 | }
98 | }
99 |
100 | @Override
101 | public void onCompleted() {
102 | }
103 |
104 | @Override
105 | public void onError(Throwable e) {
106 | Log.v("ckjc", "getHeros() failure");
107 | e.printStackTrace();
108 | }
109 | });
110 |
111 | }
112 |
113 | }
114 |
--------------------------------------------------------------------------------
/app/src/main/java/com/ckj/dotaguide/activity/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.ckj.dotaguide.activity;
2 |
3 | import android.content.Intent;
4 | import android.support.v7.app.AppCompatActivity;
5 | import android.os.Bundle;
6 | import android.view.View;
7 |
8 | import com.ckj.dotaguide.R;
9 |
10 | public class MainActivity extends AppCompatActivity {
11 |
12 | private View tv1;
13 | private View tv2;
14 | private View tv3;
15 |
16 | @Override
17 | protected void onCreate(Bundle savedInstanceState) {
18 | super.onCreate(savedInstanceState);
19 | setContentView(R.layout.activity_main);
20 | tv1 = findViewById(R.id.catalog1);
21 | tv2 = findViewById(R.id.catalog2);
22 | tv3 = findViewById(R.id.catalog3);
23 |
24 | tv1.setOnClickListener(new View.OnClickListener() {
25 |
26 | @Override
27 | public void onClick(View v) {
28 | Intent intent = new Intent();
29 | intent.putExtra("type", 0);
30 | intent.setClass(MainActivity.this, HerosActivity.class);
31 | startActivity(intent);
32 | }
33 | });
34 |
35 | tv2.setOnClickListener(new View.OnClickListener() {
36 |
37 | @Override
38 | public void onClick(View v) {
39 | Intent intent = new Intent();
40 | intent.putExtra("type", 1);
41 | intent.setClass(MainActivity.this, HerosActivity.class);
42 | startActivity(intent);
43 | }
44 | });
45 |
46 | tv3.setOnClickListener(new View.OnClickListener() {
47 |
48 | @Override
49 | public void onClick(View v) {
50 | Intent intent = new Intent();
51 | intent.putExtra("type", 2);
52 | intent.setClass(MainActivity.this, HerosActivity.class);
53 | startActivity(intent);
54 | }
55 | });
56 |
57 | }
58 |
59 | }
60 |
--------------------------------------------------------------------------------
/app/src/main/java/com/ckj/dotaguide/adapter/CooperateHerosAdapter.java:
--------------------------------------------------------------------------------
1 | package com.ckj.dotaguide.adapter;
2 |
3 | import android.content.Context;
4 | import android.support.v7.widget.RecyclerView;
5 | import android.view.LayoutInflater;
6 | import android.view.View;
7 | import android.view.ViewGroup;
8 | import android.widget.ImageView;
9 | import android.widget.TextView;
10 |
11 | import com.bumptech.glide.Glide;
12 | import com.ckj.dotaguide.R;
13 |
14 | import java.util.ArrayList;
15 | import java.util.HashMap;
16 |
17 | /**
18 | * Created by chenkaijian on 17-9-12.
19 | */
20 |
21 | public class CooperateHerosAdapter extends RecyclerView.Adapter {
22 |
23 | private Context mContext;
24 | private String heroId;
25 | private ArrayList datas;
26 |
27 | public CooperateHerosAdapter(Context mContext, String heroId, ArrayList datas) {
28 | this.mContext = mContext;
29 | this.heroId = heroId;
30 | this.datas = datas;
31 | }
32 |
33 | @Override
34 | public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
35 | MyViewHolder holder = new MyViewHolder(LayoutInflater.from(
36 | mContext).inflate(R.layout.cooperate_hero_list_item, parent,
37 | false));
38 | return holder;
39 | }
40 |
41 | @Override
42 | public void onBindViewHolder(MyViewHolder holder, int position) {
43 | String src = ((HashMap) datas.get(position)).get("src").toString();
44 | String name = ((HashMap) datas.get(position)).get("name").toString();
45 | if (!src.startsWith("http")) {
46 | src = "http://dota.uuu9.com/hero/" + heroId + "/" + src;
47 | }
48 | Glide.with(mContext).load(src).placeholder(R.drawable.default_image_cover_gray).into(holder.img);
49 | holder.name.setText(name);
50 | }
51 |
52 | @Override
53 | public int getItemCount() {
54 | return datas.size();
55 | }
56 |
57 | class MyViewHolder extends RecyclerView.ViewHolder {
58 |
59 | public ImageView img;
60 | public TextView name;
61 |
62 | public MyViewHolder(View view) {
63 | super(view);
64 | img = (ImageView) view.findViewById(R.id.img);
65 | name = (TextView) view.findViewById(R.id.name);
66 | }
67 | }
68 |
69 | }
70 |
--------------------------------------------------------------------------------
/app/src/main/java/com/ckj/dotaguide/adapter/EquipmentGoodsAdapter.java:
--------------------------------------------------------------------------------
1 | package com.ckj.dotaguide.adapter;
2 |
3 | import android.content.Context;
4 | import android.support.v7.widget.RecyclerView;
5 | import android.view.LayoutInflater;
6 | import android.view.View;
7 | import android.view.ViewGroup;
8 | import android.widget.ImageView;
9 | import android.widget.TextView;
10 |
11 | import com.bumptech.glide.Glide;
12 | import com.ckj.dotaguide.R;
13 |
14 | import java.util.ArrayList;
15 | import java.util.HashMap;
16 |
17 | /**
18 | * Created by chenkaijian on 17-9-21.
19 | */
20 |
21 | public class EquipmentGoodsAdapter extends RecyclerView.Adapter implements View.OnClickListener {
22 |
23 | private Context mContext;
24 | private ArrayList datas;
25 | private OnItemClickListener listener = null;
26 |
27 | public interface OnItemClickListener {
28 | void onItemClick(View view, int position);
29 | }
30 |
31 | public EquipmentGoodsAdapter(Context mContext, ArrayList datas) {
32 | this.mContext = mContext;
33 | this.datas = datas;
34 | }
35 |
36 | @Override
37 | public EquipmentGoodsAdapter.MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
38 | View view = LayoutInflater.from(
39 | mContext).inflate(R.layout.equipment_goods_list_item, parent,
40 | false);
41 | EquipmentGoodsAdapter.MyViewHolder holder = new EquipmentGoodsAdapter.MyViewHolder(view);
42 | view.setOnClickListener(this);
43 | return holder;
44 | }
45 |
46 | @Override
47 | public void onClick(View view) {
48 | if (listener != null) {
49 | listener.onItemClick(view, (int) view.getTag());
50 | }
51 | }
52 |
53 | public void setOnItemClickListener(OnItemClickListener listener) {
54 | this.listener = listener;
55 | }
56 |
57 | @Override
58 | public void onBindViewHolder(EquipmentGoodsAdapter.MyViewHolder holder, int position) {
59 | String src = ((HashMap) datas.get(position)).get("src").toString();
60 | String name = ((HashMap) datas.get(position)).get("name").toString();
61 | String price = ((HashMap) datas.get(position)).get("gold").toString();
62 | Glide.with(mContext).load(src).placeholder(R.drawable.default_image_cover_gray).into(holder.img);
63 | holder.name.setText(name);
64 | holder.price.setText("价格:" + price);
65 |
66 | holder.itemView.setTag(position);
67 | }
68 |
69 | @Override
70 | public int getItemCount() {
71 | return datas.size();
72 | }
73 |
74 | class MyViewHolder extends RecyclerView.ViewHolder {
75 |
76 | public ImageView img;
77 | public TextView name;
78 | public TextView price;
79 |
80 | public MyViewHolder(View view) {
81 | super(view);
82 | img = (ImageView) view.findViewById(R.id.img);
83 | name = (TextView) view.findViewById(R.id.name);
84 | price = (TextView) view.findViewById(R.id.price);
85 | }
86 | }
87 |
88 | }
89 |
90 |
--------------------------------------------------------------------------------
/app/src/main/java/com/ckj/dotaguide/adapter/EquipmentsAdapter.java:
--------------------------------------------------------------------------------
1 | package com.ckj.dotaguide.adapter;
2 |
3 | import android.content.Context;
4 | import android.support.v7.widget.RecyclerView;
5 | import android.view.LayoutInflater;
6 | import android.view.View;
7 | import android.view.ViewGroup;
8 | import android.widget.TextView;
9 |
10 | import com.ckj.dotaguide.CustomGridView;
11 | import com.ckj.dotaguide.R;
12 |
13 | import java.util.ArrayList;
14 | import java.util.HashMap;
15 |
16 | /**
17 | * Created by chenkaijian on 17-3-13.
18 | */
19 |
20 | public class EquipmentsAdapter extends RecyclerView.Adapter {
21 | private Context mContext;
22 | private ArrayList datas;
23 | private String abbreviation;
24 | private ArrayList goodsList;
25 |
26 | public EquipmentsAdapter(Context context, ArrayList datas) {
27 | this.mContext = context;
28 | this.datas = datas;
29 | }
30 |
31 | @Override
32 | public EquipmentsAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
33 | View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.equipment_list_item, parent, false);
34 | ViewHolder vh = new ViewHolder(view);
35 | return vh;
36 | }
37 |
38 | @Override
39 | public void onBindViewHolder(ViewHolder holder, int position) {
40 | String title = (((HashMap) datas.get(position)).get("title")).toString();
41 | String desc = (((HashMap) datas.get(position)).get("desc")).toString();
42 | goodsList = (ArrayList) ((HashMap) datas.get(position)).get("goodsList");
43 | holder.title.setText(title);
44 | holder.desc.setText(desc);
45 | holder.gridview.setAdapter(new EquipmentsGridAdapter(mContext, abbreviation, goodsList));
46 | }
47 |
48 | public void setAbbreviation(String abbreviation) {
49 | this.abbreviation = abbreviation;
50 | }
51 |
52 | @Override
53 | public int getItemCount() {
54 | return datas.size();
55 | }
56 |
57 | public static class ViewHolder extends RecyclerView.ViewHolder {
58 | public TextView title;
59 | public TextView desc;
60 | public CustomGridView gridview;
61 |
62 | public ViewHolder(View view) {
63 | super(view);
64 | title = (TextView) view.findViewById(R.id.title);
65 | desc = (TextView) view.findViewById(R.id.desc);
66 | gridview = (CustomGridView) view.findViewById(R.id.goods_gridview);
67 | }
68 |
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/app/src/main/java/com/ckj/dotaguide/adapter/EquipmentsGridAdapter.java:
--------------------------------------------------------------------------------
1 | package com.ckj.dotaguide.adapter;
2 |
3 | import android.content.Context;
4 | import android.content.Intent;
5 | import android.view.LayoutInflater;
6 | import android.view.View;
7 | import android.view.ViewGroup;
8 | import android.widget.BaseAdapter;
9 | import android.widget.ImageView;
10 |
11 | import com.bumptech.glide.Glide;
12 | import com.ckj.dotaguide.R;
13 | import com.ckj.dotaguide.activity.EquipmentInfoActivity;
14 |
15 | import java.util.ArrayList;
16 | import java.util.HashMap;
17 |
18 | /**
19 | * Created by chenkaijian on 17-3-13.
20 | */
21 |
22 | public class EquipmentsGridAdapter extends BaseAdapter {
23 |
24 | private Context mContext;
25 | private String heroId;
26 | private ArrayList datas;
27 |
28 | public EquipmentsGridAdapter(Context context, String heroId, ArrayList datas) {
29 | this.mContext = context;
30 | this.heroId = heroId;
31 | this.datas = datas;
32 | }
33 |
34 | @Override
35 | public View getView(final int position, View convertView, ViewGroup parent) {
36 | ViewHolder holder;
37 | if (convertView == null) {
38 | holder = new ViewHolder();
39 | LayoutInflater inflater = LayoutInflater.from(mContext);
40 | convertView = inflater.inflate(R.layout.equipment_goods_grid_item, null);
41 | holder.img = (ImageView) convertView.findViewById(R.id.img);
42 | holder.effect = (ImageView) convertView.findViewById(R.id.effect);
43 | convertView.setTag(holder);
44 | } else {
45 | holder = (ViewHolder) convertView.getTag();
46 | }
47 |
48 | String src = ((HashMap) datas.get(position)).get("src").toString();
49 | if (!src.startsWith("http")) {
50 | src = "http://dota.uuu9.com/hero/" + heroId + "/" + src;
51 | }
52 | Glide.with(mContext).load(src).placeholder(R.drawable.default_image_cover_gray).into(holder.img);
53 |
54 | holder.effect.setOnClickListener(new View.OnClickListener() {
55 | @Override
56 | public void onClick(View view) {
57 | showEquipmentInfo(datas, position);
58 | }
59 | });
60 |
61 | return convertView;
62 | }
63 |
64 | private final class ViewHolder {
65 | ImageView img;
66 | ImageView effect;
67 | }
68 |
69 | @Override
70 | public Object getItem(int position) {
71 | return datas.get(position);
72 | }
73 |
74 | @Override
75 | public long getItemId(int position) {
76 | return position;
77 | }
78 |
79 | @Override
80 | public int getCount() {
81 | return datas.size();
82 | }
83 |
84 | /**
85 | * 跳转进入物品介绍页面
86 | */
87 | private void showEquipmentInfo(ArrayList datas, int position) {
88 | String itemid = ((HashMap) datas.get(position)).get("itemid").toString();
89 | Intent intent = new Intent();
90 | intent.putExtra("type", 1);
91 | intent.putExtra("itemid", itemid);
92 | intent.setClass(mContext, EquipmentInfoActivity.class);
93 | mContext.startActivity(intent);
94 | }
95 | }
96 |
--------------------------------------------------------------------------------
/app/src/main/java/com/ckj/dotaguide/adapter/HerosAdapter.java:
--------------------------------------------------------------------------------
1 | package com.ckj.dotaguide.adapter;
2 |
3 | import android.content.Context;
4 | import android.view.LayoutInflater;
5 | import android.view.View;
6 | import android.view.ViewGroup;
7 | import android.widget.BaseAdapter;
8 | import android.widget.ImageView;
9 | import android.widget.TextView;
10 |
11 | import com.bumptech.glide.Glide;
12 | import com.ckj.dotaguide.R;
13 |
14 | import java.util.ArrayList;
15 | import java.util.HashMap;
16 |
17 | /**
18 | * Created by chenkaijian on 17-8-24.
19 | */
20 |
21 | public class HerosAdapter extends BaseAdapter {
22 | private Context context;
23 | private ArrayList datas;
24 |
25 | public HerosAdapter(Context context, ArrayList datas) {
26 | this.context = context;
27 | this.datas = datas;
28 | }
29 |
30 | @Override
31 | public View getView(int position, View convertView, ViewGroup parent) {
32 | HerosAdapter.ViewHolder holder;
33 | if (convertView == null) {
34 | holder = new HerosAdapter.ViewHolder();
35 | LayoutInflater inflater = LayoutInflater.from(context);
36 | convertView = inflater.inflate(R.layout.hero_grid_item, null);
37 | holder.img = (ImageView) convertView.findViewById(R.id.img);
38 | holder.name = (TextView) convertView.findViewById(R.id.name);
39 | convertView.setTag(holder);
40 | } else {
41 | holder = (HerosAdapter.ViewHolder) convertView.getTag();
42 | }
43 |
44 | String img = ((HashMap) datas.get(position)).get("img").toString();
45 | if (!img.startsWith("http")) {
46 | img = "http://dota.uuu9.com/hero/" + img;
47 | }
48 |
49 | Glide.with(context).load(img).into(holder.img);
50 | holder.name.setText(((HashMap) datas.get(position)).get("name").toString());
51 |
52 | return convertView;
53 | }
54 |
55 | @Override
56 | public Object getItem(int position) {
57 | return datas.get(position);
58 | }
59 |
60 | @Override
61 | public long getItemId(int position) {
62 | return position;
63 | }
64 |
65 | @Override
66 | public int getCount() {
67 | return datas.size();
68 | }
69 |
70 | private final class ViewHolder {
71 | ImageView img;
72 | TextView name;
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/app/src/main/java/com/ckj/dotaguide/adapter/SkillOrderAdapter.java:
--------------------------------------------------------------------------------
1 | package com.ckj.dotaguide.adapter;
2 |
3 | import android.content.Context;
4 | import android.view.LayoutInflater;
5 | import android.view.View;
6 | import android.view.ViewGroup;
7 | import android.widget.BaseAdapter;
8 | import android.widget.ImageView;
9 |
10 | import com.bumptech.glide.Glide;
11 | import com.ckj.dotaguide.R;
12 |
13 | import java.util.ArrayList;
14 |
15 | /**
16 | * Created by chenkaijian on 17-3-13.
17 | */
18 |
19 | public class SkillOrderAdapter extends BaseAdapter {
20 |
21 | private Context context;
22 | private String heroId;
23 | private ArrayList datas;
24 |
25 | public SkillOrderAdapter(Context context, String heroId, ArrayList datas) {
26 | this.context = context;
27 | this.heroId = heroId;
28 | this.datas = datas;
29 | }
30 |
31 | @Override
32 | public View getView(int position, View convertView, ViewGroup parent) {
33 | ViewHolder holder;
34 | if (convertView == null) {
35 | holder = new ViewHolder();
36 | LayoutInflater inflater = LayoutInflater.from(context);
37 | convertView = inflater.inflate(R.layout.skill_order_item, null);
38 | holder.img = (ImageView) convertView.findViewById(R.id.img);
39 | convertView.setTag(holder);
40 | } else {
41 | holder = (ViewHolder) convertView.getTag();
42 | }
43 |
44 | String src = datas.get(position).toString();
45 | if (!src.startsWith("http")) {
46 | src = "http://dota.uuu9.com/hero/" + heroId + "/" + src;
47 | }
48 | Glide.with(context).load(src).placeholder(R.drawable.default_image_cover_gray).into(holder.img);
49 |
50 | return convertView;
51 | }
52 |
53 | private final class ViewHolder {
54 | ImageView img;
55 | }
56 |
57 | @Override
58 | public Object getItem(int position) {
59 | return datas.get(position);
60 | }
61 |
62 | @Override
63 | public long getItemId(int position) {
64 | return position;
65 | }
66 |
67 | @Override
68 | public int getCount() {
69 | return datas.size();
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/app/src/main/java/com/ckj/dotaguide/adapter/SkillsAdapter.java:
--------------------------------------------------------------------------------
1 |
2 | package com.ckj.dotaguide.adapter;
3 |
4 | import android.content.Context;
5 | import android.support.v7.widget.RecyclerView;
6 | import android.view.LayoutInflater;
7 | import android.view.View;
8 | import android.view.ViewGroup;
9 | import android.widget.ImageView;
10 | import android.widget.TextView;
11 |
12 | import com.bumptech.glide.Glide;
13 | import com.ckj.dotaguide.R;
14 |
15 | import java.util.ArrayList;
16 | import java.util.HashMap;
17 |
18 | /**
19 | * Created by chenkaijian on 17-3-14.
20 | */
21 |
22 | public class SkillsAdapter extends RecyclerView.Adapter implements View.OnClickListener {
23 |
24 | private Context context;
25 | private String heroId;
26 | private ArrayList datas;
27 | private OnItemClickListener listener = null;
28 |
29 | public interface OnItemClickListener {
30 | void onItemClick(View view, int position);
31 | }
32 |
33 | public SkillsAdapter(Context context, String heroId, ArrayList datas) {
34 | this.context = context;
35 | this.heroId = heroId;
36 | this.datas = datas;
37 | }
38 |
39 |
40 | //创建新View,被LayoutManager所调用
41 | @Override
42 | public SkillsAdapter.ViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
43 | View view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.skill_list_item, viewGroup, false);
44 | ViewHolder vh = new ViewHolder(view);
45 | view.setOnClickListener(this);
46 | return vh;
47 | }
48 |
49 |
50 | @Override
51 | public void onClick(View view) {
52 | if (listener != null) {
53 | listener.onItemClick(view, (int) view.getTag());
54 | }
55 | }
56 |
57 | public void setOnItemClickListener(OnItemClickListener listener) {
58 | this.listener = listener;
59 | }
60 |
61 | //将数据与界面进行绑定的操作
62 | @Override
63 | public void onBindViewHolder(ViewHolder viewHolder, int position) {
64 | String src = (((HashMap) datas.get(position)).get("img")).toString();
65 | if (!src.startsWith("http")) {
66 | src = "http://dota.uuu9.com/hero/" + heroId + "/" + src;
67 | }
68 | Glide.with(context).load(src).placeholder(R.drawable.default_image_cover_gray).into(viewHolder.img);
69 | String name = ((HashMap) datas.get(position)).get("name").toString();
70 | String attr = ((HashMap) datas.get(position)).get("attr").toString();
71 | String hotkey = ((HashMap) datas.get(position)).get("hotkey").toString();
72 | viewHolder.name.setText(name);
73 | viewHolder.attr.setText(attr);
74 | viewHolder.hotkey.setText(hotkey);
75 |
76 | viewHolder.itemView.setTag(position);
77 | }
78 |
79 | //自定义的ViewHolder,持有每个Item的的所有界面元素
80 | public static class ViewHolder extends RecyclerView.ViewHolder {
81 | public ImageView img;
82 | public TextView name;
83 | public TextView attr;
84 | public TextView hotkey;
85 |
86 | public ViewHolder(View view) {
87 | super(view);
88 | img = (ImageView) view.findViewById(R.id.img);
89 | name = (TextView) view.findViewById(R.id.name);
90 | attr = (TextView) view.findViewById(R.id.attr);
91 | hotkey = (TextView) view.findViewById(R.id.hot_key);
92 | }
93 |
94 | }
95 |
96 | @Override
97 | public int getItemCount() {
98 | return datas.size();
99 | }
100 | }
101 |
--------------------------------------------------------------------------------
/app/src/main/java/com/ckj/dotaguide/model/Hero.java:
--------------------------------------------------------------------------------
1 | package com.ckj.dotaguide.model;
2 |
3 | import java.util.ArrayList;
4 |
5 | /**
6 | * Created by chenkaijian on 17-3-7.
7 | */
8 |
9 | public class Hero {
10 |
11 | private String name;
12 | private String portraitUrl;
13 | private String coverUrl;
14 | // 推荐加点方案
15 | private ArrayList skillOrderList;
16 | private String skillOrderDesc;
17 |
18 | public Hero() {
19 | }
20 |
21 | public Hero(String name, String portraitUrl) {
22 | this.name = name;
23 | this.portraitUrl = portraitUrl;
24 | }
25 |
26 | public String getName() {
27 | return name;
28 | }
29 |
30 | public void setName(String name) {
31 | this.name = name;
32 | }
33 |
34 | public String getPortraitUrl() {
35 | return portraitUrl;
36 | }
37 |
38 | public void setPortraitUrl(String portraitUrl) {
39 | this.portraitUrl = portraitUrl;
40 | }
41 |
42 | public String getCoverUrl() {
43 | return coverUrl;
44 | }
45 |
46 | public void setCoverUrl(String coverUrl) {
47 | this.coverUrl = coverUrl;
48 | }
49 |
50 | public void setSkillOrderList(ArrayList skillOrderList) {
51 | this.skillOrderList = skillOrderList;
52 | }
53 |
54 | public ArrayList getSkillOrderList() {
55 | return skillOrderList;
56 | }
57 |
58 | // public String toString() {
59 | // StringBuilder hero = new StringBuilder();
60 | // hero.append("name:" + name + "\n");
61 | // hero.append("portraitUrl:" + portraitUrl + "\n");
62 | // hero.append("coverUrl:" + coverUrl + "\n");
63 | // for (String item : skillOrderList) {
64 | // hero.append("skillOrderList:" + item + "\n");
65 | // }
66 | // return hero.toString();
67 | // }
68 | }
69 |
--------------------------------------------------------------------------------
/app/src/main/java/com/ckj/dotaguide/server/CacheInterceptor.java:
--------------------------------------------------------------------------------
1 | package com.ckj.dotaguide.server;
2 |
3 | import android.content.Context;
4 |
5 | import com.ckj.dotaguide.util.NetworkUtils;
6 |
7 | import java.io.IOException;
8 |
9 | import okhttp3.CacheControl;
10 | import okhttp3.Interceptor;
11 | import okhttp3.Request;
12 | import okhttp3.Response;
13 |
14 | /**
15 | * Created by chenkaijian on 17-9-4.
16 | */
17 |
18 | public class CacheInterceptor implements Interceptor {
19 |
20 | private Context mContext;
21 |
22 | public CacheInterceptor(Context context) {
23 | mContext = context;
24 | }
25 |
26 | @Override
27 | public Response intercept(Chain chain) throws IOException {
28 | Request request = chain.request();
29 |
30 | if (NetworkUtils.isNetworkAvailable(mContext)) {//没网强制从缓存读取(必须得写,不然断网状态下,退出应用,或者等待一分钟后,就获取不到缓存)
31 | request = request.newBuilder()
32 | .cacheControl(CacheControl.FORCE_CACHE)
33 | .build();
34 | }
35 | Response response = chain.proceed(request);
36 | Response responseLatest;
37 | if (NetworkUtils.isNetworkAvailable(mContext)) {
38 | int maxAge = 5; //有网失效一分钟
39 | responseLatest = response.newBuilder()
40 | .removeHeader("Pragma")
41 | .removeHeader("Cache-Control")
42 | .header("Cache-Control", "public, max-age=" + maxAge)
43 | .build();
44 | } else {
45 | int maxStale = 60 * 60 * 6; // 没网失效6小时
46 | responseLatest = response.newBuilder()
47 | .removeHeader("Pragma")
48 | .removeHeader("Cache-Control")
49 | .header("Cache-Control", "public, only-if-cached, max-stale=" + maxStale)
50 | .build();
51 | }
52 | return responseLatest;
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/app/src/main/java/com/ckj/dotaguide/server/HttpClientGenerator.java:
--------------------------------------------------------------------------------
1 | package com.ckj.dotaguide.server;
2 |
3 | import com.ckj.dotaguide.CommonApplication;
4 |
5 | import java.io.File;
6 |
7 | import okhttp3.Cache;
8 | import okhttp3.OkHttpClient;
9 | import retrofit2.Retrofit;
10 | import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory;
11 |
12 | /**
13 | * Created by chenkaijian on 17-8-31.
14 | */
15 |
16 | public class HttpClientGenerator {
17 |
18 | private static final String BASE_URL = "http://dota.uuu9.com/";
19 |
20 | private static Retrofit mRetrofit;
21 | private static HttpClientService mHttpClientService;
22 |
23 | public static HttpClientService getHttpClientService() {
24 | if (mHttpClientService == null) {
25 | mHttpClientService = getRetrofit().create(HttpClientService.class);
26 | }
27 | return mHttpClientService;
28 | }
29 |
30 | private static Retrofit getRetrofit() {
31 | //创建retrofit,把OkHttpClient对象写入
32 | if (mRetrofit == null) {
33 | mRetrofit = new Retrofit.Builder()
34 | .baseUrl(BASE_URL)
35 | .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
36 | .client(getHttpClient())
37 | .build();
38 | }
39 |
40 | return mRetrofit;
41 | }
42 |
43 | private static OkHttpClient getHttpClient() {
44 | //设置缓存路径
45 | File httpCacheDirectory = new File(CommonApplication.getInstance().getCacheDir(), "responses");
46 | //设置缓存 10M
47 | Cache cache = new Cache(httpCacheDirectory, 10 * 1024 * 1024);
48 | //创建OkHttpClient,并添加拦截器和缓存代码
49 | OkHttpClient client = new OkHttpClient.Builder()
50 | .addNetworkInterceptor(new CacheInterceptor(CommonApplication.getInstance()))
51 | .cache(cache).build();
52 | return client;
53 | }
54 |
55 | }
56 |
--------------------------------------------------------------------------------
/app/src/main/java/com/ckj/dotaguide/server/HttpClientService.java:
--------------------------------------------------------------------------------
1 | package com.ckj.dotaguide.server;
2 |
3 | import okhttp3.ResponseBody;
4 | import retrofit2.http.GET;
5 | import retrofit2.http.Path;
6 | import retrofit2.http.Query;
7 | import retrofit2.http.Url;
8 | import rx.Observable;
9 |
10 | /**
11 | * Created by chenkaijian on 17-9-1.
12 | */
13 |
14 | public interface HttpClientService {
15 |
16 | @GET("/hero/")
17 | Observable getHeros();
18 |
19 | @GET("/hero/{heroid}/")
20 | Observable getHero(@Path("heroid") String heroid);
21 |
22 | @GET
23 | Observable getItem(@Url String url, @Query("itemid") String itemid);
24 |
25 | @GET
26 | Observable getItem(@Url String url);
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/app/src/main/java/com/ckj/dotaguide/util/NetworkUtils.java:
--------------------------------------------------------------------------------
1 | package com.ckj.dotaguide.util;
2 |
3 | import android.content.Context;
4 | import android.net.ConnectivityManager;
5 | import android.net.NetworkInfo;
6 |
7 | /**
8 | * Created by chenkaijian on 17-9-4.
9 | */
10 |
11 | public class NetworkUtils {
12 | /**
13 | * Returns whether the network is available
14 | *
15 | * @param context
16 | * Context
17 | * @return 网络是否可用
18 | * @see [类、类#方法、类#成员]
19 | */
20 | public static boolean isNetworkAvailable(Context context) {
21 | return getConnectedNetworkInfo(context) != null;
22 | // 模拟断网
23 | // return false;
24 | }
25 |
26 | public static NetworkInfo getConnectedNetworkInfo(Context context) {
27 | try {
28 | ConnectivityManager connectivity = (ConnectivityManager) context
29 | .getSystemService(Context.CONNECTIVITY_SERVICE);
30 | if (connectivity == null) {
31 | // LogUtils.error("couldn't get connectivity manager");
32 | }
33 | else {
34 | NetworkInfo info = connectivity.getActiveNetworkInfo();
35 | if (info != null) {
36 | /*
37 | * for (int i = 0; i < info.length; i++) { if
38 | * (info[i].getState() == NetworkInfo.State.CONNECTED) {
39 | * return info[i]; } }
40 | */
41 | return info;
42 | }
43 | }
44 |
45 | } catch (Exception e) {
46 | // LogUtils.error(e.toString(), e);
47 | }
48 | return null;
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/app/src/main/java/com/ckj/dotaguide/util/RotateTextView.java:
--------------------------------------------------------------------------------
1 | package com.ckj.dotaguide.util;
2 |
3 | import android.content.Context;
4 | import android.content.res.TypedArray;
5 | import android.graphics.Canvas;
6 | import android.support.v7.widget.AppCompatTextView;
7 | import android.util.AttributeSet;
8 |
9 | import com.ckj.dotaguide.R;
10 |
11 | /**
12 | * Created by chenkaijian on 17-9-19.
13 | */
14 | public class RotateTextView extends AppCompatTextView {
15 |
16 | private int degree;
17 |
18 | public RotateTextView(Context context) {
19 | super(context);
20 | }
21 |
22 | public RotateTextView(Context context, AttributeSet attrs) {
23 | super(context, attrs);
24 | TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.RotateTextView);
25 | degree = ta.getInteger(R.styleable.RotateTextView_degree, 0);
26 | }
27 |
28 | @Override
29 | protected void onDraw(Canvas canvas) {
30 | canvas.rotate(degree, getMeasuredWidth() / 2, getMeasuredHeight() / 2);
31 | super.onDraw(canvas);
32 | }
33 |
34 | }
--------------------------------------------------------------------------------
/app/src/main/res/drawable/catalog_item_selector.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | -
5 |
6 |
7 |
8 |
9 | -
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/cooperate_btn_bg_selector.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | -
4 |
5 |
6 |
7 |
8 |
9 | -
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/default_image_cover_gray.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ckj375/DotaGuide/6415a71e079c64f43b66ab324ca40ebc9f0c2b9a/app/src/main/res/drawable/default_image_cover_gray.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/default_image_cover_white.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ckj375/DotaGuide/6415a71e079c64f43b66ab324ca40ebc9f0c2b9a/app/src/main/res/drawable/default_image_cover_white.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/hero_gird_item_pressed_selector.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | -
5 |
6 |
7 |
8 |
9 | -
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/hero_grid_item_cover_selector.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | -
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/hero_grid_item_selector.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | -
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/image_frame_selector.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | -
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/image_pressed_selector.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | -
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/loading.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ckj375/DotaGuide/6415a71e079c64f43b66ab324ca40ebc9f0c2b9a/app/src/main/res/drawable/loading.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/price.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ckj375/DotaGuide/6415a71e079c64f43b66ab324ca40ebc9f0c2b9a/app/src/main/res/drawable/price.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/restraint_btn_bg_selector.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | -
4 |
5 |
6 |
7 |
8 |
9 | -
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/right_arrow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ckj375/DotaGuide/6415a71e079c64f43b66ab324ca40ebc9f0c2b9a/app/src/main/res/drawable/right_arrow.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/skill_list_item_selector.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | -
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/text_frame_selector.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | -
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/triangle_corner.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ckj375/DotaGuide/6415a71e079c64f43b66ab324ca40ebc9f0c2b9a/app/src/main/res/drawable/triangle_corner.png
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_equipment_info.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
13 |
14 |
20 |
21 |
28 |
29 |
30 |
31 |
39 |
40 |
45 |
46 |
52 |
53 |
60 |
61 |
69 |
70 |
71 |
72 |
73 |
81 |
82 |
89 |
90 |
91 |
92 |
93 |
103 |
104 |
115 |
116 |
122 |
123 |
124 |
125 |
126 |
136 |
137 |
147 |
148 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_hero_info.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
13 |
14 |
22 |
23 |
30 |
31 |
32 |
33 |
40 |
41 |
45 |
46 |
51 |
52 |
63 |
64 |
75 |
76 |
77 |
85 |
86 |
94 |
95 |
103 |
104 |
105 |
114 |
115 |
124 |
125 |
135 |
136 |
137 |
146 |
147 |
156 |
157 |
167 |
168 |
169 |
177 |
178 |
183 |
184 |
195 |
196 |
197 |
198 |
203 |
204 |
215 |
216 |
217 |
218 |
219 |
220 |
221 |
229 |
230 |
241 |
242 |
251 |
252 |
259 |
260 |
261 |
262 |
270 |
271 |
281 |
282 |
288 |
289 |
290 |
291 |
301 |
302 |
312 |
313 |
319 |
320 |
321 |
322 |
323 |
324 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_heros.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
13 |
14 |
20 |
21 |
29 |
30 |
31 |
44 |
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
14 |
15 |
23 |
24 |
25 |
26 |
33 |
34 |
40 |
41 |
42 |
43 |
47 |
48 |
55 |
56 |
61 |
62 |
63 |
64 |
68 |
69 |
76 |
77 |
82 |
83 |
84 |
85 |
89 |
90 |
91 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/cooperate_hero_dialog.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
13 |
14 |
22 |
23 |
24 |
29 |
30 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/cooperate_hero_list_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
12 |
13 |
22 |
23 |
29 |
30 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/equipment_goods_grid_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
12 |
13 |
18 |
19 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/equipment_goods_list_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
12 |
13 |
17 |
18 |
25 |
26 |
32 |
33 |
39 |
40 |
41 |
48 |
49 |
55 |
56 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/equipment_list_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
13 |
14 |
21 |
22 |
29 |
30 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/hero_grid_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
11 |
12 |
18 |
19 |
25 |
26 |
32 |
33 |
43 |
44 |
48 |
49 |
50 |
51 |
52 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/skill_detail_dialog.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
14 |
15 |
19 |
20 |
26 |
27 |
38 |
39 |
43 |
44 |
53 |
54 |
63 |
64 |
65 |
66 |
75 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/skill_list_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
12 |
13 |
17 |
18 |
24 |
25 |
36 |
37 |
41 |
42 |
46 |
47 |
48 |
56 |
57 |
64 |
65 |
72 |
73 |
79 |
80 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/skill_order_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
12 |
13 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ckj375/DotaGuide/6415a71e079c64f43b66ab324ca40ebc9f0c2b9a/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ckj375/DotaGuide/6415a71e079c64f43b66ab324ca40ebc9f0c2b9a/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ckj375/DotaGuide/6415a71e079c64f43b66ab324ca40ebc9f0c2b9a/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ckj375/DotaGuide/6415a71e079c64f43b66ab324ca40ebc9f0c2b9a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ckj375/DotaGuide/6415a71e079c64f43b66ab324ca40ebc9f0c2b9a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/attrs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #F5F5F5
4 | #303F9F
5 | #FF4081
6 |
7 | #2B2B2B
8 | #FFFFFF
9 |
10 | #6B6B6B
11 |
12 | #9DB843
13 | #6495ED
14 |
15 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 | 50dp
7 | 20dp
8 | 16dp
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | DotaGuide
3 | Main2Activity
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | jcenter()
6 | }
7 | dependencies {
8 | classpath 'com.android.tools.build:gradle:2.3.3'
9 |
10 | // NOTE: Do not place your application dependencies here; they belong
11 | // in the individual module build.gradle files
12 | }
13 | }
14 |
15 | allprojects {
16 | repositories {
17 | jcenter()
18 | }
19 | }
20 |
21 | task clean(type: Delete) {
22 | delete rootProject.buildDir
23 | }
24 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | org.gradle.jvmargs=-Xmx1536m
13 |
14 | # When configured, Gradle will run in incubating parallel mode.
15 | # This option should only be used with decoupled projects. More details, visit
16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
17 | # org.gradle.parallel=true
18 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ckj375/DotaGuide/6415a71e079c64f43b66ab324ca40ebc9f0c2b9a/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Mon Mar 06 09:43:08 CST 2017
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------