Рейтинг 2.9/5
Описание из storebot.me:
if (m . matches ()) { String file_path = m . группа ( 1 ); дБ . updateParam ( " file_id " , file_path); } } String file_id = db . getParam ( " file_id " ); fileIdView . SetText (file_id); fileIdView . addTextChangedListener ( новый TextWatcher () { @Override public void beforeTextChanged ( CharSequence charSequence , int i , int i1 , int i2 ) { } @Override public void onTextChanged ( CharSequence charSequence , int i , int i1 , int i2 ) { } @Override public void afterTextChanged ( редактируемый редактируемый ) { String file_id = редактируется . нанизывать(); дБ . updateParam ( " file_id " , file_id); } }); submitButton . setOnClickListener ( новый вид . OnClickListener () { @Override public void onClick ( Просмотреть вид ) { final String fileStr = fileIdView . getText () . нанизывать(); if (fileStr . содержит ( " / " )) getFilePath ( null , fileStr); еще getFileId (fileStr); } }); } private void getFileId ( final String fileId ) { Журнал . d ( « fd » , « getFile » + fileId); дБ . insertFav ( " file_id " , FILEID, GetResources () . GetString ( R . Строка . file_downloader)); JSONObject jsonObject = новый JSONObject (); попробуйте { jsonObject . put ( " file_id " , fileId); } catch ( JSONException e) { Журнал . e ( « fd » , « getFile » , e); возвращение ; } final String json = jsonObject . нанизывать(); final String url = " https://api.telegram.org/bot " + _token + " / getFile " ; Thread thread = new Thread ( новый Runnable () { @Override public void run () { Строковый отклик = " " ; попробуйте { final MediaType JSON = MediaType . parse ( " application / json; charset = utf-8 " ); RequestBody тела = RequestBody . create ( JSON , json); Запрос запроса = новый запрос . Builder () .url (URL) .post (корпус) .build (); OkHttpClient client = new OkHttpClient(); Response resp = client.newCall(request).execute(); response = resp.body().string(); } catch (final MalformedURLException e) { Log.e("fd", "Malformed URL", e); showError(e.getLocalizedMessage()); return; } catch (final IOException e) { Log.e("fd", "IO", e); showError(e.getLocalizedMessage()); return; } catch (final NullPointerException e) { Log.e("fd", "Null Pointer", e); showError(e.getLocalizedMessage()); return; } final String filePath; try { JSONObject jsonObject = new JSONObject(response); if (!jsonObject.getBoolean("ok")) { Log.w("fd", "getFile response ok=false"); showError("getFile response ok=false"); return; } JSONObject result = jsonObject.getJSONObject("result"); filePath = result.getString("file_path"); } catch (JSONException e) { Log.e("fd", "getFile", e); showError(e.getLocalizedMessage()); return; } getFilePath(fileId, filePath); } }); thread.sta
Основные факторы рейтинга
Теги: #прочее