Skip to content

Commit 9b416b3

Browse files
committed
add search history
1 parent 3a6da5a commit 9b416b3

File tree

5 files changed

+104
-103
lines changed

5 files changed

+104
-103
lines changed

app/src/main/assets/shCore.css

Lines changed: 92 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -35,46 +35,46 @@
3535
.syntaxhighlighter table tr,
3636
.syntaxhighlighter table tbody
3737
{
38-
margin: 0 !important;
39-
padding: 0 !important;
40-
border: 0 !important;
41-
outline: 0 !important;
42-
background: none !important;
43-
text-align: left !important;
44-
float: none !important;
45-
vertical-align: baseline !important;
46-
position: static !important;
47-
left: auto !important;
48-
top: auto !important;
49-
right: auto !important;
50-
bottom: auto !important;
51-
height: auto !important;
52-
width: 100% !important;
53-
line-height: 1.1em !important;
54-
font-family: "Consolas", "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important;
55-
font-weight: normal !important;
56-
font-style: normal !important;
57-
font-size: 1em !important;
58-
min-height: inherit !important; /* For IE8, FF & WebKit */
59-
min-height: auto !important; /* For IE7 */
38+
margin: 0 !important;
39+
padding: 0 !important;
40+
border: 0 !important;
41+
outline: 0 !important;
42+
background: none !important;
43+
text-align: left !important;
44+
float: none !important;
45+
vertical-align: baseline !important;
46+
position: static !important;
47+
left: auto !important;
48+
top: auto !important;
49+
right: auto !important;
50+
bottom: auto !important;
51+
height: auto !important;
52+
width: 100% !important;
53+
line-height: 1.1em !important;
54+
font-family: "Consolas", "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important;
55+
font-weight: normal !important;
56+
font-style: normal !important;
57+
font-size: 1em !important;
58+
min-height: inherit !important; /* For IE8, FF & WebKit */
59+
min-height: auto !important; /* For IE7 */
6060
}
6161

6262
.syntaxhighlighter
6363
{
64-
width: 100% !important; /* 99% fixes IE8 horizontal scrollbar */
65-
margin: 1em 0 1em 0 !important;
66-
padding: 1px !important; /* adds a little border on top and bottom */
67-
position: relative !important;
64+
width: 100% !important; /* 99% fixes IE8 horizontal scrollbar */
65+
margin: 1em 0 1em 0 !important;
66+
padding: 1px !important; /* adds a little border on top and bottom */
67+
position: relative !important;
6868
}
6969

7070
.syntaxhighlighter .bold
7171
{
72-
font-weight: bold !important;
72+
font-weight: bold !important;
7373
}
7474

7575
.syntaxhighlighter .italic
7676
{
77-
font-style: italic !important;
77+
font-style: italic !important;
7878
}
7979

8080
.syntaxhighlighter .line
@@ -87,8 +87,8 @@
8787

8888
.syntaxhighlighter .line .content
8989
{
90-
padding-left: .5em !important;
91-
white-space: pre !important; /**强制不换行 */
90+
padding-left: .5em !important;
91+
white-space: pre !important; /**强制不换行 */
9292
}
9393

9494
.syntaxhighlighter .line .spaces
@@ -97,127 +97,127 @@
9797

9898
.syntaxhighlighter .line table
9999
{
100-
border-collapse: collapse !important;
100+
border-collapse: collapse !important;
101101
}
102102

103103
.syntaxhighlighter .line td
104104
{
105-
vertical-align: top !important;
105+
vertical-align: top !important;
106106
}
107107

108108
.syntaxhighlighter .line .number
109109
{
110-
width: 3em !important;
110+
width: 3em !important;
111111
}
112112

113113
.syntaxhighlighter .line .number code
114114
{
115-
width: 2.7em !important;
116-
padding-right: .3em !important;
117-
text-align: right !important;
118-
display: block !important;
115+
width: 2.7em !important;
116+
padding-right: .3em !important;
117+
text-align: right !important;
118+
display: block !important;
119119
}
120120

121121
/* Disable border and margin on the lines when no gutter option is set */
122122
.syntaxhighlighter.nogutter .line .content
123123
{
124-
border-left: none !important;
124+
border-left: none !important;
125125
}
126126

127127
.syntaxhighlighter .bar
128128
{
129-
display: none !important;
129+
display: none !important;
130130
}
131131

132132
.syntaxhighlighter .bar.show
133133
{
134-
display: block !important;
134+
display: block !important;
135135
}
136136

137137
.syntaxhighlighter.collapsed .bar
138138
{
139-
display: block !important;
139+
display: block !important;
140140
}
141141

142142
/* Adjust some properties when collapsed */
143143

144144
.syntaxhighlighter.collapsed .lines
145145
{
146-
display: none !important;
146+
display: none !important;
147147
}
148148

149149
.syntaxhighlighter .lines.no-wrap
150150
{
151-
overflow: auto !important;
152-
overflow-y: hidden !important;
153-
white-space: nowrap!important;
151+
overflow: auto !important;
152+
overflow-y: hidden !important;
153+
white-space: nowrap!important;
154154
}
155155

156156
/* Styles for the toolbar */
157157

158158
.syntaxhighlighter .toolbar
159159
{
160-
position: absolute !important;
161-
right: 0px !important;
162-
top: 0px !important;
163-
font-size: 1px !important;
164-
padding: 8px 8px 8px 0 !important; /* in px because images don't scale with ems */
160+
position: absolute !important;
161+
right: 0px !important;
162+
top: 0px !important;
163+
font-size: 1px !important;
164+
padding: 8px 8px 8px 0 !important; /* in px because images don't scale with ems */
165165
}
166166

167167
.syntaxhighlighter.collapsed .toolbar
168168
{
169-
font-size: 80% !important;
170-
padding: .2em 0 .5em .5em !important;
171-
position: static !important;
169+
font-size: 80% !important;
170+
padding: .2em 0 .5em .5em !important;
171+
position: static !important;
172172
}
173173

174174
.syntaxhighlighter .toolbar a.item,
175175
.syntaxhighlighter .toolbar .item
176176
{
177-
display: block !important;
178-
float: left !important;
179-
margin-left: 8px !important;
180-
background-repeat: no-repeat !important;
181-
overflow: hidden !important;
182-
text-indent: -5000px !important;
177+
display: block !important;
178+
float: left !important;
179+
margin-left: 8px !important;
180+
background-repeat: no-repeat !important;
181+
overflow: hidden !important;
182+
text-indent: -5000px !important;
183183
}
184184

185185
.syntaxhighlighter.collapsed .toolbar .item
186186
{
187-
display: none !important;
187+
display: none !important;
188188
}
189189

190190
.syntaxhighlighter.collapsed .toolbar .item.expandSource
191191
{
192-
background-image: url(magnifier.png) !important;
193-
display: inline !important;
194-
text-indent: 0 !important;
195-
width: auto !important;
196-
float: none !important;
197-
height: 16px !important;
198-
padding-left: 20px !important;
192+
background-image: url(magnifier.png) !important;
193+
display: inline !important;
194+
text-indent: 0 !important;
195+
width: auto !important;
196+
float: none !important;
197+
height: 16px !important;
198+
padding-left: 20px !important;
199199
}
200200

201201
.syntaxhighlighter .toolbar .item.viewSource
202202
{
203-
background-image: url(page_white_code.png) !important;
203+
background-image: url(page_white_code.png) !important;
204204
}
205205

206206
.syntaxhighlighter .toolbar .item.printSource
207207
{
208-
background-image: url(printer.png) !important;
208+
background-image: url(printer.png) !important;
209209
}
210210

211211
.syntaxhighlighter .toolbar .item.copyToClipboard
212212
{
213-
text-indent: 0 !important;
214-
background: none !important;
215-
overflow: visible !important;
213+
text-indent: 0 !important;
214+
background: none !important;
215+
overflow: visible !important;
216216
}
217217

218218
.syntaxhighlighter .toolbar .item.about
219219
{
220-
background-image: url(help.png) !important;
220+
background-image: url(help.png) !important;
221221
}
222222

223223
/**
@@ -232,100 +232,100 @@
232232
.syntaxhighlighter.printing .line.highlighted.alt1 .content,
233233
.syntaxhighlighter.printing .line.highlighted.alt2 .content,
234234
{
235-
background: none !important;
235+
background: none !important;
236236
}
237237

238238
/* Gutter line numbers */
239239
.syntaxhighlighter.printing .line .number
240240
{
241-
color: #bbb !important;
241+
color: #bbb !important;
242242
}
243243

244244
/* Add border to the lines */
245245
.syntaxhighlighter.printing .line .content
246246
{
247-
color: #000 !important;
247+
color: #000 !important;
248248
}
249249

250250
/* Toolbar when visible */
251251
.syntaxhighlighter.printing .toolbar
252252
{
253-
display: none !important;
253+
display: none !important;
254254
}
255255

256256
.syntaxhighlighter.printing a
257257
{
258-
text-decoration: none !important;
258+
text-decoration: none !important;
259259
}
260260

261261
.syntaxhighlighter.printing .plain,
262262
.syntaxhighlighter.printing .plain a
263263
{
264-
color: #000 !important;
264+
color: #000 !important;
265265
}
266266

267267
.syntaxhighlighter.printing .comments,
268268
.syntaxhighlighter.printing .comments a
269269
{
270-
color: #008200 !important;
270+
color: #008200 !important;
271271
}
272272

273273
.syntaxhighlighter.printing .string,
274274
.syntaxhighlighter.printing .string a
275275
{
276-
color: blue !important;
276+
color: blue !important;
277277
}
278278

279279
.syntaxhighlighter.printing .keyword
280280
{
281-
color: #069 !important;
282-
font-weight: bold !important;
281+
color: #069 !important;
282+
font-weight: bold !important;
283283
}
284284

285285
.syntaxhighlighter.printing .preprocessor
286286
{
287-
color: gray !important;
287+
color: gray !important;
288288
}
289289

290290
.syntaxhighlighter.printing .variable
291291
{
292-
color: #a70 !important;
292+
color: #a70 !important;
293293
}
294294

295295
.syntaxhighlighter.printing .value
296296
{
297-
color: #090 !important;
297+
color: #090 !important;
298298
}
299299

300300
.syntaxhighlighter.printing .functions
301301
{
302-
color: #ff1493 !important;
302+
color: #ff1493 !important;
303303
}
304304

305305
.syntaxhighlighter.printing .constants
306306
{
307-
color: #0066CC !important;
307+
color: #0066CC !important;
308308
}
309309

310310
.syntaxhighlighter.printing .script
311311
{
312-
font-weight: bold !important;
312+
font-weight: bold !important;
313313
}
314314

315315
.syntaxhighlighter.printing .color1,
316316
.syntaxhighlighter.printing .color1 a
317317
{
318-
color: #808080 !important;
318+
color: #808080 !important;
319319
}
320320

321321
.syntaxhighlighter.printing .color2,
322322
.syntaxhighlighter.printing .color2 a
323323
{
324-
color: #ff1493 !important;
324+
color: #ff1493 !important;
325325
}
326326

327327
.syntaxhighlighter.printing .color3,
328328
.syntaxhighlighter.printing .color3 a
329329
{
330-
color: red !important;
330+
color: red !important;
331331
}

app/src/main/java/com/brian/codeblog/activity/SearchActivity.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
public class SearchActivity extends BaseActivity {
4949
private static final String TAG = SearchActivity.class.getSimpleName();
5050

51-
private static final int MAX_HISTORY_COUNT = 8;
51+
private static final int MAX_HISTORY_COUNT = 5;
5252

5353
@BindView(R.id.title_bar) TitleBar mTitleBar;
5454
@BindView(R.id.et_search) EditText mSearchInput;
@@ -297,9 +297,9 @@ private List<String> getSearchHistory() {
297297

298298
private void addSearchHistory(String keyWord) {
299299
if (mHistoryAdapter.containData(keyWord)) {
300-
return;
300+
mHistoryAdapter.removeData(keyWord);
301301
}
302-
if (mHistoryAdapter.getCount() >= MAX_HISTORY_COUNT) {
302+
while (mHistoryAdapter.getCount() >= MAX_HISTORY_COUNT) {
303303
mHistoryAdapter.removeDataAt(mHistoryAdapter.getCount()-1);
304304
}
305305
mHistoryAdapter.addData(0, keyWord);

0 commit comments

Comments
 (0)