Commit 000919da5eef7575dc867e044a47857732cc8d5c
1 parent
b700f4ac
- visibility : gone - addbook fragment
Showing
2 changed files
with
4 additions
and
140 deletions
app/src/main/java/net/devfac/userstory/FragmentAddBook.java
... | ... | @@ -86,8 +86,8 @@ public class FragmentAddBook extends Fragment implements View.OnClickListener, S |
86 | 86 | SearchBookReq searchBookReq = new SearchBookReq(); |
87 | 87 | searchBookReq.keyword = keyword; |
88 | 88 | |
89 | - WebView wv = (WebView)getActivity().findViewById(R.id.webView2); | |
90 | - StateContext.getInstance(getActivity()).setWebView(wv); | |
89 | +// WebView wv = (WebView)getActivity().findViewById(R.id.webView2); | |
90 | +// StateContext.getInstance(getActivity()).setWebView(wv); | |
91 | 91 | |
92 | 92 | StateContext.getInstance(getActivity()).processEvent(Action.REQ_BOOK_SEARCH_TO_ADD, searchBookReq); |
93 | 93 | |
... | ... | @@ -123,143 +123,6 @@ public class FragmentAddBook extends Fragment implements View.OnClickListener, S |
123 | 123 | |
124 | 124 | } |
125 | 125 | |
126 | -// private class ProcessSearchBookTask extends AsyncTask<String, Void, ArrayList<BookSearchResult>>{ | |
127 | -//// StringBuffer mResultStringBuffer; | |
128 | -// Activity mUiActivity; | |
129 | -// | |
130 | -// ProcessSearchBookTask(Activity uiActivity){ | |
131 | -// mUiActivity = uiActivity; | |
132 | -// } | |
133 | -// | |
134 | -// @Override | |
135 | -// protected ArrayList<BookSearchResult> doInBackground(String... params) { | |
136 | -// String keyword = params[0]; | |
137 | -//// mResultStringBuffer = new StringBuffer(""); | |
138 | -// ArrayList<BookSearchResult> mBookSearchResultArray = new ArrayList<>(); | |
139 | -// | |
140 | -// String strUrl = UrlGenerator.getInstance(getActivity()).getSearchBooksAtAladin(keyword); | |
141 | -// URL url = null; | |
142 | -// try { | |
143 | -// url = new URL(strUrl); | |
144 | -// | |
145 | -// Source source = new Source(url); | |
146 | -// source.fullSequentialParse(); | |
147 | -// | |
148 | -// List<Element> books = source.getAllElements(HTMLElementName.LI); | |
149 | -// | |
150 | -// for( Element book:books){ | |
151 | -// BookSearchResult mBookSearchResult = new BookSearchResult(); | |
152 | -// | |
153 | -//// String book_id = book.getAttributeValue("id"); | |
154 | -//// Logger.i("BOOK ID : " + book_id); | |
155 | -// mBookSearchResult.id = book.getAttributeValue("id"); | |
156 | -// | |
157 | -// for( Element elements : book.getAllElements(HTMLElementName.DIV)){ | |
158 | -// if( elements.getAttributeValue("class").equals(Constants.BOOK_SEARCH_CLASS_BOOK_INFO)){ | |
159 | -// for( Element bookInfo:elements.getAllElements(HTMLElementName.P)){ | |
160 | -// if( bookInfo.getAttributeValue("class").equals(Constants.BOOK_SEARCH_CLASS_BOOK_TITLE)){ | |
161 | -//// Logger.i("BOOK TITLE : " + bookInfo.getContent() ); | |
162 | -// mBookSearchResult.title = bookInfo.getContent().toString(); | |
163 | -// } | |
164 | -// else if( bookInfo.getAttributeValue("class").equals(Constants.BOOK_SEARCH_CLASS_BOOK_DESC)){ | |
165 | -//// Logger.i("BOOK DESC : " + bookInfo.getContent() ); | |
166 | -// mBookSearchResult.desc = bookInfo.getContent().toString(); | |
167 | -// } | |
168 | -// else if( bookInfo.getAttributeValue("class").equals(Constants.BOOK_SEARCH_CLASS_BOOK_GENRE)){ | |
169 | -//// Logger.i("BOOK GENRE : " + bookInfo.getContent() ); | |
170 | -// mBookSearchResult.genre = bookInfo.getContent().toString(); | |
171 | -// } | |
172 | -// } | |
173 | -// } | |
174 | -// else if( elements.getAttributeValue("class").equals(Constants.BOOK_SEARCH_CLASS_BOOK_IMAGE)){ | |
175 | -// for( Element bookImage:elements.getAllElements(HTMLElementName.IMG)){ | |
176 | -//// Logger.i("COVER SRC : " + bookImage.getAttributeValue("src")); | |
177 | -// | |
178 | -// mBookSearchResult.imageUrl = bookImage.getAttributeValue("src"); | |
179 | -// | |
180 | -// String[] splited_string = mBookSearchResult.imageUrl.split("/"); | |
181 | -// mBookSearchResult.imageFileName = splited_string[splited_string.length-1]; | |
182 | -// | |
183 | -// URL coverUrl = new URL(mBookSearchResult.imageUrl); | |
184 | -// Bitmap coverBitmap = BitmapFactory.decodeStream(coverUrl.openConnection().getInputStream()); | |
185 | -// | |
186 | -// saveBookCover(coverBitmap, mBookSearchResult.imageFileName); | |
187 | -// } | |
188 | -// } | |
189 | -// } | |
190 | -// | |
191 | -// mBookSearchResultArray.add(mBookSearchResult); | |
192 | -// } | |
193 | -// | |
194 | -// | |
195 | -// | |
196 | -//// HttpURLConnection connection = (HttpURLConnection)url.openConnection(); | |
197 | -//// | |
198 | -//// connection.setRequestProperty("User-Agent", ""); | |
199 | -//// connection.setRequestMethod("GET"); | |
200 | -//// connection.setDoOutput(true); | |
201 | -//// connection.connect(); | |
202 | -//// | |
203 | -//// InputStream inputStream = connection.getInputStream(); | |
204 | -//// | |
205 | -//// BufferedReader rd = new BufferedReader(new InputStreamReader(inputStream)); | |
206 | -//// | |
207 | -//// String line = ""; | |
208 | -//// while( (line = rd.readLine()) != null ){ | |
209 | -//// Logger.i("LINE : " + line); | |
210 | -//// mResultStringBuffer.append(line); | |
211 | -//// } | |
212 | -// } catch (MalformedURLException e) { | |
213 | -// e.printStackTrace(); | |
214 | -// } catch (IOException e) { | |
215 | -// e.printStackTrace(); | |
216 | -// } | |
217 | -// | |
218 | -// return mBookSearchResultArray; | |
219 | -// } | |
220 | -// | |
221 | -// @Override | |
222 | -// protected void onPostExecute(ArrayList<BookSearchResult> bookSearchResultArrayList) { | |
223 | -// final ArrayList<BookSearchResult> resultBookSearchResultArrayList = bookSearchResultArrayList; | |
224 | -// if(!resultBookSearchResultArrayList.isEmpty()){ | |
225 | -//// super.onPostExecute(bookSearchResultArrayList); | |
226 | -// mUiActivity.runOnUiThread(new Runnable() { | |
227 | -// @Override | |
228 | -// public void run() { | |
229 | -// mArrayAdapterBookSearchResult = new ArrayAdapterBookSearchResult(mUiActivity, R.layout.listview_searched_result_item, resultBookSearchResultArrayList ); | |
230 | -// mListSearchedResult.setAdapter(mArrayAdapterBookSearchResult); | |
231 | -// } | |
232 | -// }); | |
233 | -// | |
234 | -// } | |
235 | -// } | |
236 | -// | |
237 | -// private void saveBookCover(Bitmap bitmap, String coverFileName){ | |
238 | -// OutputStream outStream; | |
239 | -// | |
240 | -// File dir = new File(Constants.IMAGE_FILE_SAVE_PATH); | |
241 | -// if( !dir.exists() ){ | |
242 | -// if( !dir.mkdirs() ){ | |
243 | -// Logger.e("Fail to create dir :" + dir.toString()); | |
244 | -// return; | |
245 | -// } | |
246 | -// } | |
247 | -// | |
248 | -// File file = new File(Constants.IMAGE_FILE_SAVE_PATH, coverFileName); | |
249 | -// | |
250 | -// if( file.exists() ) return; | |
251 | -// | |
252 | -// try { | |
253 | -// outStream = new FileOutputStream(file); | |
254 | -// bitmap.compress(Bitmap.CompressFormat.PNG, 100, outStream); | |
255 | -// outStream.flush(); | |
256 | -// outStream.close(); | |
257 | -// } catch (IOException e) { | |
258 | -// e.printStackTrace(); | |
259 | -// } | |
260 | -// | |
261 | -// } | |
262 | -// } | |
263 | 126 | |
264 | 127 | public static class BookSearchResult{ |
265 | 128 | public String id; | ... | ... |
app/src/main/res/layout/fragment_addbook.xml
... | ... | @@ -31,5 +31,6 @@ |
31 | 31 | android:layout_width="match_parent" |
32 | 32 | android:layout_height="match_parent" |
33 | 33 | android:id="@+id/webView2" |
34 | - android:layout_gravity="center_horizontal" /> | |
34 | + android:layout_gravity="center_horizontal" | |
35 | + android:visibility="gone" /> | |
35 | 36 | </LinearLayout> |
36 | 37 | \ No newline at end of file | ... | ... |