本文整理汇总了Java中com.androidnetworking.interfaces.StringRequestListener类的典型用法代码示例。如果您正苦于以下问题:Java StringRequestListener类的具体用法?Java StringRequestListener怎么用?Java StringRequestListener使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
StringRequestListener类属于com.androidnetworking.interfaces包,在下文中一共展示了StringRequestListener类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: testStringGetRequest
import com.androidnetworking.interfaces.StringRequestListener; //导入依赖的package包/类
public void testStringGetRequest() throws InterruptedException {
server.enqueue(new MockResponse().setBody("data"));
final AtomicReference<String> responseRef = new AtomicReference<>();
final CountDownLatch latch = new CountDownLatch(1);
AndroidNetworking.get(server.url("/").toString())
.build()
.getAsString(new StringRequestListener() {
@Override
public void onResponse(String response) {
responseRef.set(response);
latch.countDown();
}
@Override
public void onError(ANError anError) {
assertTrue(false);
}
});
assertTrue(latch.await(2, SECONDS));
assertEquals("data", responseRef.get());
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:27,代码来源:GetStringApiTest.java
示例2: getData
import com.androidnetworking.interfaces.StringRequestListener; //导入依赖的package包/类
public void getData(final DataListener listener) {
final String data = mPreferencesHelper.getData();
if (data != null) {
listener.onResponse(data);
return;
}
mApiHelper.getData(new StringRequestListener() {
@Override
public void onResponse(String response) {
mPreferencesHelper.putData(response);
listener.onResponse(response);
}
@Override
public void onError(ANError anError) {
listener.onError(anError.getErrorDetail());
}
});
}
开发者ID:amitshekhariitbhu,项目名称:Android-MVP-Sample-Application,代码行数:24,代码来源:DataManager.java
示例3: getAccessToken
import com.androidnetworking.interfaces.StringRequestListener; //导入依赖的package包/类
public void getAccessToken(final String code) {
AndroidNetworking.get(mTokenUrl + "&code=" + code)
.build()
.getAsString(new StringRequestListener() {
@Override
public void onResponse(String response) {
mAccessToken = response.substring(
response.indexOf("access_token=") + 13,
response.indexOf("&scope")
);
mSession.storeAccessToken(mAccessToken);
initHeaders();
mListener.onSuccess();
fetchUser();
}
@Override
public void onError(ANError anError) {
mListener.onFail(anError.getErrorDetail());
}
});
}
开发者ID:tpb1908,项目名称:AndroidProjectsClient,代码行数:23,代码来源:OAuthHandler.java
示例4: renderMarkDown
import com.androidnetworking.interfaces.StringRequestListener; //导入依赖的package包/类
public Loader renderMarkDown(@NonNull final ItemLoader<String> loader, String markdown) {
final JSONObject obj = new JSONObject();
try {
obj.put("text", markdown);
} catch(JSONException ignored) {
}
post(GIT_BASE + SEGMENT_MARKDOWN)
.addHeaders(API_AUTH_HEADERS)
.addJSONObjectBody(obj)
.setTag(loader)
.build()
.getAsString(new StringRequestListener() {
@Override
public void onResponse(String response) {
loader.loadComplete(response);
}
@Override
public void onError(ANError anError) {
loader.loadError(parseError(anError));
}
});
return this;
}
开发者ID:tpb1908,项目名称:AndroidProjectsClient,代码行数:25,代码来源:Loader.java
示例5: loadRawFile
import com.androidnetworking.interfaces.StringRequestListener; //导入依赖的package包/类
public void loadRawFile(final StringRequestListener listener, final String path) {
AndroidNetworking.get(path)
.addHeaders(API_AUTH_HEADERS)
.setPriority(Priority.IMMEDIATE)
.build()
.getAsString(new StringRequestListener() {
@Override
public void onResponse(String response) {
if(listener != null) listener.onResponse(response);
}
@Override
public void onError(ANError anError) {
if(listener != null) listener.onError(anError);
}
});
}
开发者ID:tpb1908,项目名称:AndroidProjectsClient,代码行数:18,代码来源:FileLoader.java
示例6: testStringMultipartRequest
import com.androidnetworking.interfaces.StringRequestListener; //导入依赖的package包/类
public void testStringMultipartRequest() throws InterruptedException {
server.enqueue(new MockResponse().setBody("data"));
final AtomicReference<String> responseRef = new AtomicReference<>();
final CountDownLatch latch = new CountDownLatch(1);
AndroidNetworking.upload(server.url("/").toString())
.addMultipartParameter("key", "value")
.build()
.getAsString(new StringRequestListener() {
@Override
public void onResponse(String response) {
responseRef.set(response);
latch.countDown();
}
@Override
public void onError(ANError anError) {
assertTrue(false);
}
});
assertTrue(latch.await(2, SECONDS));
assertEquals("data", responseRef.get());
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:28,代码来源:MultipartStringApiTest.java
示例7: testStringMultipartRequest404
import com.androidnetworking.interfaces.StringRequestListener; //导入依赖的package包/类
public void testStringMultipartRequest404() throws InterruptedException {
server.enqueue(new MockResponse().setResponseCode(404).setBody("data"));
final AtomicReference<String> errorDetailRef = new AtomicReference<>();
final AtomicReference<String> errorBodyRef = new AtomicReference<>();
final AtomicReference<Integer> errorCodeRef = new AtomicReference<>();
final CountDownLatch latch = new CountDownLatch(1);
AndroidNetworking.upload(server.url("/").toString())
.addMultipartParameter("key", "value")
.build()
.getAsString(new StringRequestListener() {
@Override
public void onResponse(String response) {
assertTrue(false);
}
@Override
public void onError(ANError anError) {
errorBodyRef.set(anError.getErrorBody());
errorDetailRef.set(anError.getErrorDetail());
errorCodeRef.set(anError.getErrorCode());
latch.countDown();
}
});
assertTrue(latch.await(2, SECONDS));
assertEquals(ANConstants.RESPONSE_FROM_SERVER_ERROR, errorDetailRef.get());
assertEquals("data", errorBodyRef.get());
assertEquals(404, errorCodeRef.get().intValue());
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:36,代码来源:MultipartStringApiTest.java
示例8: testStringGetRequest404
import com.androidnetworking.interfaces.StringRequestListener; //导入依赖的package包/类
public void testStringGetRequest404() throws InterruptedException {
server.enqueue(new MockResponse().setResponseCode(404).setBody("data"));
final AtomicReference<String> errorDetailRef = new AtomicReference<>();
final AtomicReference<String> errorBodyRef = new AtomicReference<>();
final AtomicReference<Integer> errorCodeRef = new AtomicReference<>();
final CountDownLatch latch = new CountDownLatch(1);
AndroidNetworking.get(server.url("/").toString())
.build()
.getAsString(new StringRequestListener() {
@Override
public void onResponse(String response) {
assertTrue(false);
}
@Override
public void onError(ANError anError) {
errorBodyRef.set(anError.getErrorBody());
errorDetailRef.set(anError.getErrorDetail());
errorCodeRef.set(anError.getErrorCode());
latch.countDown();
}
});
assertTrue(latch.await(2, SECONDS));
assertEquals(ANConstants.RESPONSE_FROM_SERVER_ERROR, errorDetailRef.get());
assertEquals("data", errorBodyRef.get());
assertEquals(404, errorCodeRef.get().intValue());
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:36,代码来源:GetStringApiTest.java
示例9: testStringPostRequest
import com.androidnetworking.interfaces.StringRequestListener; //导入依赖的package包/类
public void testStringPostRequest() throws InterruptedException {
server.enqueue(new MockResponse().setBody("data"));
final AtomicReference<String> responseRef = new AtomicReference<>();
final CountDownLatch latch = new CountDownLatch(1);
AndroidNetworking.post(server.url("/").toString())
.addBodyParameter("fistName", "Amit")
.addBodyParameter("lastName", "Shekhar")
.build()
.getAsString(new StringRequestListener() {
@Override
public void onResponse(String response) {
responseRef.set(response);
latch.countDown();
}
@Override
public void onError(ANError anError) {
assertTrue(false);
}
});
assertTrue(latch.await(2, SECONDS));
assertEquals("data", responseRef.get());
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:29,代码来源:PostStringApiTest.java
示例10: testStringPostRequest404
import com.androidnetworking.interfaces.StringRequestListener; //导入依赖的package包/类
public void testStringPostRequest404() throws InterruptedException {
server.enqueue(new MockResponse().setResponseCode(404).setBody("data"));
final AtomicReference<String> errorDetailRef = new AtomicReference<>();
final AtomicReference<String> errorBodyRef = new AtomicReference<>();
final AtomicReference<Integer> errorCodeRef = new AtomicReference<>();
final CountDownLatch latch = new CountDownLatch(1);
AndroidNetworking.post(server.url("/").toString())
.addBodyParameter("fistName", "Amit")
.addBodyParameter("lastName", "Shekhar")
.build()
.getAsString(new StringRequestListener() {
@Override
public void onResponse(String response) {
assertTrue(false);
}
@Override
public void onError(ANError anError) {
errorBodyRef.set(anError.getErrorBody());
errorDetailRef.set(anError.getErrorDetail());
errorCodeRef.set(anError.getErrorCode());
latch.countDown();
}
});
assertTrue(latch.await(2, SECONDS));
assertEquals(ANConstants.RESPONSE_FROM_SERVER_ERROR, errorDetailRef.get());
assertEquals("data", errorBodyRef.get());
assertEquals(404, errorCodeRef.get().intValue());
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:37,代码来源:PostStringApiTest.java
示例11: HindiGeetLyrics
import com.androidnetworking.interfaces.StringRequestListener; //导入依赖的package包/类
/**
* Fetch Lyrics from HindiGeet
*
* @param context
* @param artistName
* @param songName
* @param album
* @param path
* @param lyrics
* @11Search
*/
public static void HindiGeetLyrics(Context context, String artistName, String songName, String album, String path, TextView lyrics) {
String url = Constants.hindigeetUrl + "song/" + queryLyrics(songName, "_") + ".html";
AndroidNetworking.get(url)
.setPriority(Priority.HIGH)
.build()
.getAsString(new StringRequestListener() {
@Override
public void onResponse(String response) {
if (!response.isEmpty()) {
String scrapStart = "<pre>";
String scrapEnd = "</pre>";
if (response.contains(scrapStart) && response.contains(scrapEnd)) {
String fin = TextUtils.substring(response, response.indexOf(scrapStart), response.indexOf(scrapEnd));
if (fin.length() > 0) {
// other unwanted stuff clearance
fin = fin
.trim()
.replace("<pre>", "")
.replace("</pre>", "");
// set lyrics
setLyrics(context, songName, path, fin, lyrics);
Log.e("NetworkHelper", "lyrics from HindiGeet");
}
}
}
}
@Override
public void onError(ANError anError) {
lyrics.setText(LyricsHelper.getInbuiltLyrics(path));
}
});
}
开发者ID:RajneeshSingh007,项目名称:MusicX-music-player,代码行数:45,代码来源:NetworkHelper.java
示例12: getData
import com.androidnetworking.interfaces.StringRequestListener; //导入依赖的package包/类
public void getData(StringRequestListener listener) {
AndroidNetworking.get(ApiEndPoint.GET_DATA)
.addPathParameter("pageNumber", "0")
.addQueryParameter("limit", "3")
.build()
.getAsString(listener);
}
开发者ID:amitshekhariitbhu,项目名称:Android-MVP-Sample-Application,代码行数:8,代码来源:ApiHelper.java
示例13: loadPromotionList
import com.androidnetworking.interfaces.StringRequestListener; //导入依赖的package包/类
private void loadPromotionList() {
swipeRefreshLayout.setRefreshing(true);
AndroidNetworking.get(WebUrlFormaterUtils.getPromoteListUrl())
.build().getAsString(new StringRequestListener() {
@Override
public void onResponse(String response) {
promotionList.clear();
try {
JSONObject object = new JSONObject(response);
JSONArray array = object.getJSONArray("promoteList");
for (int i = 0; i < array.length(); i++) {
JSONObject promoObj = array.getJSONObject(i);
Promotion promotion = new Promotion();
promotion.setLinkUrl(promoObj.getString("promotionUrl"));
promotion.setTitle(promoObj.getString("promotionTitle"));
promotion.setImageUrl(promoObj.getString("prmotionImg"));
promotionList.add(promotion);
}
info = object.getString("promoteInfo");
} catch (JSONException e) {
e.printStackTrace();
}
notifyAdapter();
}
@Override
public void onError(ANError anError) {
}
});
}
开发者ID:TakumaMochizuki,项目名称:Komica,代码行数:32,代码来源:IndexFragment.java
示例14: loadIntegratedSection
import com.androidnetworking.interfaces.StringRequestListener; //导入依赖的package包/类
private void loadIntegratedSection() {
AndroidNetworking.get(url).build()
.getAsString(new StringRequestListener() {
@Override
public void onResponse(String response) {
Document document = Jsoup.parse(response);
title = document.getElementsByTag("title").text();
notifyTitle();
titlePostList.addAll(CrawlerUtils.getIntegratedPostList(document, url));
notifyAdapter();
Element pageElem = document.getElementsByAttributeValue("border", "1").first();
if (pageElem == null) {
return;
}
pageCount = pageElem.select("a").size();
if (pageElem.select("a").isEmpty()) {
return;
}
String linkTmp = pageElem.select("a").first().attr("href");
if ("".equals(link)) {
link = linkTmp.replaceAll("[0-9]", "");
}
}
@Override
public void onError(ANError anError) {
}
});
}
开发者ID:TakumaMochizuki,项目名称:Komica,代码行数:33,代码来源:SectionPreviewFragment.java
示例15: loadNormalSection
import com.androidnetworking.interfaces.StringRequestListener; //导入依赖的package包/类
private void loadNormalSection() {
AndroidNetworking.get(url).build().getAsString(new StringRequestListener() {
@Override
public void onResponse(String response) {
Document document = Jsoup.parse(response);
title = document.getElementsByTag("title").text();
notifyTitle();
titlePostList.addAll(CrawlerUtils.getPostList(document, url, webType));
notifyAdapter();
Element pageSwitch = document.getElementById("page_switch");
if (null == pageSwitch) {
pageSwitch = document.getElementsByClass("page_switch").first();
}
if (null == pageSwitch) {
pageSwitch = document.getElementById("page_switch");
}
// TODO has two mode, please watch out it.
if (pageCount <= 1 && null != pageSwitch.select("a") && !pageSwitch.getElementsByTag("table").isEmpty()) {
isLinkPage = false;
pageCount = pageSwitch.select("a").size();
if ("".equals(link) && pageSwitch.select("a").attr("href").contains("?")) {
link = pageSwitch.select("a").attr("href").replaceAll("[0-9]", "");
}
} else if (pageCount <= 1 && pageSwitch.getElementsByTag("table").isEmpty()) {
isLinkPage = true;
pageCount = pageSwitch.getElementsByAttributeValue("class", "link ").size();
if ("".equals(link)) {
Element pageStartLinkElem = pageSwitch.getElementsByAttributeValue("class", "link ").first();
link = pageStartLinkElem.select("a").attr("href");
}
}
}
@Override
public void onError(ANError anError) {
}
});
}
开发者ID:TakumaMochizuki,项目名称:Komica,代码行数:40,代码来源:SectionPreviewFragment.java
示例16: getAsString
import com.androidnetworking.interfaces.StringRequestListener; //导入依赖的package包/类
public void getAsString(StringRequestListener requestListener) {
this.mResponseType = ResponseType.STRING;
this.mStringRequestListener = requestListener;
ANRequestQueue.getInstance().addRequest(this);
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:6,代码来源:ANRequest.java
示例17: vagLyrics
import com.androidnetworking.interfaces.StringRequestListener; //导入依赖的package包/类
/**
* Fetch Lyrics from vag
* @param context
* @param artistName
* @param songName
* @param path
* @param lyrics
* @8Search
*/
public static void vagLyrics(Context context, String artistName, String songName, String album, String path, TextView lyrics) {
String url = Constants.vagUrl + queryLyrics(artistName, "-") + "/" + queryLyrics(songName, "-") + ".html";
AndroidNetworking.get(url)
.setPriority(Priority.HIGH)
.build()
.getAsString(new StringRequestListener() {
@Override
public void onResponse(String response) {
if (!response.isEmpty()) {
String scrapStart = "<div itemprop=description>";
String scrapEnd = "<div id=lyrFoot>";
if (response.contains(scrapStart) && response.contains(scrapEnd)) {
int start = response.indexOf(scrapStart);
int end = response.indexOf(scrapEnd);
if (start >= 0 && end >= 0) {
String fin = TextUtils.substring(response, start, end);
if (fin.length() > 0) {
// other unwanted stuff clearance
fin = fin
.trim()
.replace("<div id=lyrFoot>", "")
.replace("<div itemprop=description>", "")
.replace("<hr>", "")
.replace("<i>", "")
.replace("</i>", "")
.replaceAll("<a.*?</a>", "")
.replace("<br/>", "\n")
.replace("</div>", "");
// set lyrics
setLyrics(context, songName, path, fin, lyrics);
Log.e("NetworkHelper", "lyrics from Vag");
}
}
}
}
}
@Override
public void onError(ANError anError) {
metroLyrics(context, artistName, songName, album, path, lyrics);
}
});
}
开发者ID:RajneeshSingh007,项目名称:MusicX-music-player,代码行数:53,代码来源:NetworkHelper.java
示例18: metroLyrics
import com.androidnetworking.interfaces.StringRequestListener; //导入依赖的package包/类
/**
* Fetch Lyrics from metro
* @param context
* @param artistName
* @param songName
* @param path
* @param lyrics
* @9Search
*/
public static void metroLyrics(Context context, String artistName, String songName, String album, String path, TextView lyrics) {
String url = Constants.metroUrl + queryLyrics(songName, "-") + "-lyrics-" + queryLyrics(artistName, "-") + ".html";
AndroidNetworking.get(url)
.setPriority(Priority.HIGH)
.build()
.getAsString(new StringRequestListener() {
@Override
public void onResponse(String response) {
if (!response.isEmpty()) {
String scrapStart = "<div id=\"lyrics-body-text\" class=\"js-lyric-text\">";
String scrapEnd = "<p class=\"writers\">";
if (response.contains(scrapStart) && response.contains(scrapEnd)) {
int start = response.indexOf(scrapStart);
int end = response.indexOf(scrapEnd);
if (start >= 0 && end >= 0) {
String fin = TextUtils.substring(response, start, end);
if (fin.length() > 0) {
// other unwanted stuff clearance
fin = fin
.trim()
.replace("<div id=\"lyrics-body-text\" class=\"js-lyric-text\">", "")
.replace("<p class='verse'>", "\n")
.replace("<br>", "")
.replace("<i>", "")
.replace("</i>", "")
.replaceAll("<a.*?</a>", "")
.replace("</p>", "\n")
.replace("</div>", "");
// set lyrics
setLyrics(context, songName, path, fin, lyrics);
Log.e("NetworkHelper", "lyrics from Metro");
}
}
}
}
}
@Override
public void onError(ANError anError) {
directLyrics(context, artistName, songName, album, path, lyrics);
}
});
}
开发者ID:RajneeshSingh007,项目名称:MusicX-music-player,代码行数:53,代码来源:NetworkHelper.java
示例19: atozLyrics
import com.androidnetworking.interfaces.StringRequestListener; //导入依赖的package包/类
/**
* Fetch Lyrics from atoz
* @param context
* @param artistName
* @param songName
* @param path
* @param lyrics
* @5Search
*/
public static void atozLyrics(Context context, String artistName, String songName, String album, String path, TextView lyrics) {
String url = Constants.atozUrl + queryLyrics(artistName, "") + "/" + queryLyrics(songName, "") + ".html";
AndroidNetworking.get(url)
.setPriority(Priority.HIGH)
.build()
.getAsString(new StringRequestListener() {
@Override
public void onResponse(String response) {
if (!response.isEmpty()) {
String scrapStart = "<div>";
String scrapEnd = "<div class=\"noprint\">";
if (response.contains(scrapStart) && response.contains(scrapEnd)) {
String fin = TextUtils.substring(response, response.indexOf(scrapStart), response.indexOf(scrapEnd));
if (fin.length() > 0) {
// other unwanted stuff clearance
fin = fin
.trim()
.replaceAll("<!--.*?-->", "")
.replace("<div>", "")
.replace("<b>", "")
.replace("</b>", "")
.replace("<br>", "")
.replace("<i>", "")
.replace("</i>", "")
.replaceAll("<a.*?</a>", "")
.replace("</div>", "");
// set lyrics
setLyrics(context, songName, path, fin, lyrics);
Log.e("NetworkHelper", "lyrics from AtoZ");
}
}
}
}
@Override
public void onError(ANError anError) {
lyricsondemandLyrics(context, artistName, songName, album, path, lyrics);
}
});
}
开发者ID:RajneeshSingh007,项目名称:MusicX-music-player,代码行数:50,代码来源:NetworkHelper.java
示例20: songsLyrics
import com.androidnetworking.interfaces.StringRequestListener; //导入依赖的package包/类
/**
* Fetch Lyrics from songLyrics
*
* @param context
* @param artistName
* @param songName
* @param path
* @param lyrics
* @3Search
*/
public static void songsLyrics(Context context, String artistName, String songName, String album, String path, TextView lyrics) {
String url = Constants.songlyricsUrl + queryLyrics(artistName, "-") + "/" + queryLyrics(songName, "-") + "-lyrics" + "/";
AndroidNetworking.get(url)
.setPriority(Priority.HIGH)
.build()
.getAsString(new StringRequestListener() {
@Override
public void onResponse(String response) {
if (!response.isEmpty()) {
String scrapStart = "<div id=\"songLyricsDiv-outer\">";
String scrapEnd = "<div itemscope itemtype=\"http://schema.org/MusicRecording\">";
if (response.contains(scrapStart) && response.contains(scrapEnd)) {
String fin = TextUtils.substring(response, response.indexOf(scrapStart), response.indexOf(scrapEnd));
if (fin.length() > 0) {
// other unwanted stuff clearance
fin = fin
.trim()
.replace("<div id=\"songLyricsDiv-outer\">", "")
.replaceAll("<p id=\"songLyricsDiv\" class=\"songLyricsV14 iComment-text\">", "")
.replace("<br />", "")
.replaceAll("<a.*?</a>", "")
.replace("<i>", "")
.replace("</i>", "")
.replace("<br>", "")
.replace("</div>", "")
.replace("</p>", "");
// set lyrics
setLyrics(context, songName, path, fin, lyrics);
Log.e("NetworkHelper", "lyrics from SongLyrics");
}
}
}
}
@Override
public void onError(ANError anError) {
lyricsbogieLyrics(context, artistName, songName, album, path, lyrics);
}
});
}
开发者ID:RajneeshSingh007,项目名称:MusicX-music-player,代码行数:51,代码来源:NetworkHelper.java
注:本文中的com.androidnetworking.interfaces.StringRequestListener类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论