Skip to content

Commit dae73aa

Browse files
committed
更新1.6版本号,优化页面,合并通用搜题接口,新增专属题库(量少,但在不断优化中)。
1 parent 622f08a commit dae73aa

File tree

8 files changed

+125
-303
lines changed

8 files changed

+125
-303
lines changed

app/src/main/java/com/zmide/MainActivity.java

+2-59
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
3636
String TAG = "zmide";
3737
Context mContext;
3838
boolean isVip = false;
39-
String version = "v1.5";
39+
String version = "v1.6";
4040

4141

4242
private CardView card1;
@@ -69,30 +69,13 @@ protected void onCreate(Bundle savedInstanceState) {
6969

7070
card1 = (CardView) findViewById(R.id.card1);
7171
card2 = (CardView) findViewById(R.id.card2);
72-
card3 = (CardView) findViewById(R.id.card3);
73-
card4 = (CardView) findViewById(R.id.card4);
74-
card5 = (CardView) findViewById(R.id.card5);
75-
card6 = (CardView) findViewById(R.id.card6);
76-
card7 = (CardView) findViewById(R.id.card7);
77-
card8 = (CardView) findViewById(R.id.card8);
78-
card9 = (CardView) findViewById(R.id.card9);
79-
card10 = (CardView) findViewById(R.id.card10);
80-
8172
about = (LinearLayout) findViewById(R.id.about);
8273

8374
card1.setOnClickListener(this);
8475
card2.setOnClickListener(this);
85-
card3.setOnClickListener(this);
86-
card4.setOnClickListener(this);
87-
card5.setOnClickListener(this);
88-
card6.setOnClickListener(this);
89-
card7.setOnClickListener(this);
90-
card8.setOnClickListener(this);
91-
card9.setOnClickListener(this);
92-
card10.setOnClickListener(this);
93-
9476
about.setOnClickListener(this);
9577

78+
9679
}
9780

9881
@Override
@@ -106,46 +89,6 @@ public void onClick(View v) {
10689
Intent intent2 = new Intent(MainActivity.this, com.zmide.myClass.activity.MainActivity.class);
10790
startActivity(intent2);
10891
break;
109-
case R.id.card3:
110-
/*Intent intent = new Intent(MainActivity.this, Demo.class);
111-
startActivity(intent);*/
112-
toast("正在开发中....");
113-
break;
114-
case R.id.card4:
115-
/*Intent intent = new Intent(MainActivity.this, Demo.class);
116-
startActivity(intent);*/
117-
toast("待添加4");
118-
break;
119-
case R.id.card5:
120-
/*Intent intent = new Intent(MainActivity.this, Demo.class);
121-
startActivity(intent);*/
122-
toast("待添加5");
123-
break;
124-
case R.id.card6:
125-
/*Intent intent = new Intent(MainActivity.this, Demo.class);
126-
startActivity(intent);*/
127-
toast("待添加6");
128-
break;
129-
case R.id.card7:
130-
/*Intent intent = new Intent(MainActivity.this, Demo.class);
131-
startActivity(intent);*/
132-
toast("待添加7");
133-
break;
134-
case R.id.card8:
135-
/*Intent intent = new Intent(MainActivity.this, Demo.class);
136-
startActivity(intent);*/
137-
toast("待添加8");
138-
break;
139-
case R.id.card9:
140-
/*Intent intent = new Intent(MainActivity.this, Demo.class);
141-
startActivity(intent);*/
142-
toast("待添加9");
143-
break;
144-
case R.id.card10:
145-
/*Intent intent = new Intent(MainActivity.this, Demo.class);
146-
startActivity(intent);*/
147-
toast("待添加10");
148-
break;
14992
case R.id.about:
15093
intent = new Intent(MainActivity.this, AboutActivity.class);
15194
startActivity(intent);

app/src/main/java/com/zmide/search/MainActivity.java

+89-6
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public class MainActivity extends AppCompatActivity {
4141
private OkHttpClient client = new OkHttpClient();
4242
String TAG = "zmide";
4343
Context mContext;
44-
boolean isVip = false;
44+
boolean isVip = true;
4545

4646

4747
private Button paste;
@@ -99,15 +99,100 @@ public void onClick(View v) {
9999
new Thread(new Runnable() {
100100
@Override
101101
public void run() {
102+
102103
String tiku = (String) spinner.getSelectedItem();
103104
if (question.getText().toString().isEmpty()) {
104105
answer01.setText("请输入题目后搜索");
105106
toast("请输入题目后搜索");
106107
} else {
107108
answer01.setText("正在搜索中.....");
108109
toast("正在搜索中.....");
109-
String answer = null;
110+
// String answer = null;
110111
try {
112+
String tt = question.getText().toString();
113+
String answer = "";
114+
// String hh = "<br>";
115+
String hh = "\n";
116+
String regEx = "[\n`~!@#$%^&*()+=|{}':;',\\[\\].<>/?~!@#¥%……&*()——+|{}【】‘;:”“’。, 、?]";
117+
118+
119+
switch(tiku) {
120+
case "通用接口":
121+
// 题库一
122+
try {
123+
String da1 =searchDao.apiSeekTT1(tt);
124+
answer = answer + da1 + hh;
125+
} catch (IOException e) {
126+
e.printStackTrace();
127+
} catch (JSONException e) {
128+
e.printStackTrace();
129+
}
130+
131+
// 题库二
132+
try {
133+
String da2 = searchDao.apiSeekTT2(tt);
134+
answer = answer + da2 + hh;
135+
} catch (IOException e) {
136+
e.printStackTrace();
137+
} catch (JSONException e) {
138+
e.printStackTrace();
139+
}
140+
141+
// 题库三
142+
try {
143+
String da3 = searchDao.apiSeekTT3(tt);
144+
answer = answer + da3 + hh;
145+
} catch (IOException e) {
146+
e.printStackTrace();
147+
} catch (JSONException e) {
148+
e.printStackTrace();
149+
}
150+
// 处理接口返回脏数据
151+
answer = answer.replace("李恒雅", "查题君");
152+
answer = answer.replace("并发限制,请使用token(公众号:叛逆青年旅舍 申请)", "");
153+
toast(answer);
154+
answer01.setText(answer);
155+
156+
break;
157+
case "专属接口":
158+
if (isVip) {
159+
// 专属题库
160+
try {
161+
String da0 = searchDao.apiSeekTT0(tt);
162+
answer = answer + da0 + hh;
163+
} catch (IOException e) {
164+
e.printStackTrace();
165+
} catch (JSONException e) {
166+
e.printStackTrace();
167+
}
168+
}
169+
if (!isVip) {
170+
toast("未授权");
171+
answer01.setText("未授权");
172+
break;
173+
}
174+
toast(answer);
175+
answer01.setText(answer);
176+
break;
177+
case "英译汉":
178+
// 判断不是中文的话就翻译
179+
if (!isChinese(tt.replaceAll(regEx, ""))) {
180+
try {
181+
String fy = searchDao.apiFY(tt);
182+
answer = answer + fy + hh;
183+
} catch (IOException e) {
184+
e.printStackTrace();
185+
} catch (JSONException e) {
186+
e.printStackTrace();
187+
}
188+
}
189+
toast(answer);
190+
answer01.setText(answer);
191+
}
192+
193+
194+
/*
195+
String answer = "";
111196
switch(tiku){
112197
case "题库1":
113198
answer = searchDao.apiSeekTT1(question.getText().toString());
@@ -127,6 +212,8 @@ public void run() {
127212
answer = answer.replace("并发限制,请使用token(公众号:叛逆青年旅舍 申请)", "");
128213
answer01.setText(answer);
129214
toast(answer);
215+
*/
216+
130217
} catch (Exception e) {
131218
e.printStackTrace();
132219
}
@@ -160,10 +247,6 @@ public void run() {
160247

161248
private void initView() {
162249

163-
TextView mVipText = findViewById(R.id.main_vip_text);
164-
if(isVip) {
165-
mVipText.setVisibility(View.VISIBLE);
166-
}
167250

168251
//绑定打开悬浮窗按钮
169252
mStartBtn = findViewById(R.id.main_start_btn);

app/src/main/res/drawable/main_boder.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
android:top="0dp"
1414
android:bottom="2dp">
1515
<shape android:shape="rectangle">
16-
<solid android:color="#FAFAFA"/>
16+
<solid android:color="#7ABD9A"/>
1717
<corners android:radius="2dp" />
1818
</shape>
1919
</item>

app/src/main/res/layout/about_main.xml

+6-5
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,22 @@
33
xmlns:tools="http://schemas.android.com/tools"
44
android:layout_width="match_parent"
55
android:layout_height="match_parent"
6-
android:orientation="vertical"
7-
android:padding="15dp">
6+
android:orientation="vertical">
87

98
<LinearLayout
109
android:layout_width="match_parent"
11-
android:layout_height="wrap_content"
10+
android:layout_height="40dp"
1211
android:background="@drawable/main_boder"
1312
android:orientation="horizontal"
1413
android:gravity="center_vertical"
1514
>
1615
<TextView
1716
android:layout_width="wrap_content"
1817
android:layout_height="wrap_content"
18+
android:layout_marginTop="5dp"
1919
android:layout_marginLeft="15dp"
2020
android:layout_marginBottom="5dp"
21-
android:textSize="24dp"
21+
android:textSize="22dp"
2222
android:textStyle="bold"
2323
android:text="关于"/>
2424
</LinearLayout>
@@ -87,7 +87,8 @@
8787
android:layout_width="fill_parent"
8888
android:layout_height="wrap_content"
8989
android:gravity="center"
90-
android:orientation="vertical">
90+
android:orientation="vertical"
91+
android:layout_marginBottom="15dp">
9192
<TextView
9293
android:layout_width="wrap_content"
9394
android:layout_height="wrap_content"

0 commit comments

Comments
 (0)