com.androidnetworking.interfaces.StringRequestListener Java Examples

The following examples show how to use com.androidnetworking.interfaces.StringRequestListener. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DataManager.java    From Android-MVP-Sample-Application with Apache License 2.0 6 votes vote down vote up
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());
            }
        });

    }
 
Example #2
Source File: MFire.java    From xGetter with Apache License 2.0 5 votes vote down vote up
public static void fetch(String url, final LowCostVideo.OnTaskCompleted onTaskCompleted){
    AndroidNetworking.get(fixURL(url))
            .addHeaders("User-agent", agent)
            .build()
            .getAsString(new StringRequestListener() {
                @Override
                public void onResponse(String response) {
                    final String regex = "aria-label=\"Download file\"\\n.+href=\"(.*)\"";
                    final Pattern pattern = Pattern.compile(regex);
                    final Matcher matcher = pattern.matcher(response);
                    if (matcher.find()) {
                        ArrayList<XModel> xModels = new ArrayList<>();
                        putModel(matcher.group(1),"Normal",xModels);
                        onTaskCompleted.onTaskCompleted(xModels,false);
                    }else onTaskCompleted.onError();
                }

                @Override
                public void onError(ANError anError) {
                    onTaskCompleted.onError();
                }
            });
}
 
Example #3
Source File: Vlare.java    From xGetter with Apache License 2.0 5 votes vote down vote up
public static void fetch(String url, final LowCostVideo.OnTaskCompleted onTaskCompleted){
    AndroidNetworking.get(url)
            .build()
            .getAsString(new StringRequestListener() {
                @Override
                public void onResponse(String response) {
                    ArrayList<XModel> xModels = parseVideo(response);
                    if (xModels.isEmpty()){
                        onTaskCompleted.onError();
                    }else onTaskCompleted.onTaskCompleted(Utils.sortMe(xModels), true);
                }

                @Override
                public void onError(ANError anError) {
                    onTaskCompleted.onError();
                }
            });
}
 
Example #4
Source File: Muvix.java    From xGetter with Apache License 2.0 5 votes vote down vote up
public static void fetch(String url, final LowCostVideo.OnTaskCompleted onComplete){
    AndroidNetworking.get(fixURL(url))
            .build()
            .getAsString(new StringRequestListener() {
                @Override
                public void onResponse(String response) {
                    ArrayList<XModel> xModels = parse(response);
                    if (xModels!=null){
                        onComplete.onTaskCompleted(xModels,true);
                    }else onComplete.onError();
                }

                @Override
                public void onError(ANError anError) {
                    onComplete.onError();
                }
            });
}
 
Example #5
Source File: BitTube.java    From xGetter with Apache License 2.0 5 votes vote down vote up
public static void fetch(String url, final LowCostVideo.OnTaskCompleted onTaskCompleted){
    String id = getBitTubeID(url);
    if (id!=null) {
        AndroidNetworking.get("https://bittube.video/api/v1/videos/" + id)
                .build()
                .getAsString(new StringRequestListener() {
                    @Override
                    public void onResponse(String response) {
                        ArrayList<XModel> xModels = parseVideo(response);
                        if (xModels.isEmpty()) {
                            onTaskCompleted.onError();
                        } else onTaskCompleted.onTaskCompleted(Utils.sortMe(xModels), true);
                    }

                    @Override
                    public void onError(ANError anError) {
                        onTaskCompleted.onError();
                    }
                });
    }else onTaskCompleted.onError();
}
 
Example #6
Source File: GPhotos.java    From xGetter with Apache License 2.0 5 votes vote down vote up
public static void fetch(String url, final LowCostVideo.OnTaskCompleted onTaskCompleted){
    AndroidNetworking.get(url)
            .setUserAgent(LowCostVideo.agent)
            .build()
            .getAsString(new StringRequestListener() {
                @Override
                public void onResponse(String response) {
                    ArrayList<XModel> xModels = GPhotosUtils.getGPhotoLink(response);
                    onTaskCompleted.onTaskCompleted(xModels,true);
                }

                @Override
                public void onError(ANError anError) {
                    onTaskCompleted.onError();
                }
            });
}
 
Example #7
Source File: VideoBIN.java    From xGetter with Apache License 2.0 5 votes vote down vote up
public static void fetch(String url, final LowCostVideo.OnTaskCompleted onTaskCompleted){
    AndroidNetworking.get(url)
            .build()
            .getAsString(new StringRequestListener() {
                @Override
                public void onResponse(String response) {
                    ArrayList<XModel> xModels = parseVideo(response);
                    if (xModels.isEmpty()) {
                        onTaskCompleted.onError();
                    } else onTaskCompleted.onTaskCompleted(Utils.sortMe(xModels), true);
                }

                @Override
                public void onError(ANError anError) {
                    onTaskCompleted.onError();
                }
            });
}
 
Example #8
Source File: SendVid.java    From xGetter with Apache License 2.0 5 votes vote down vote up
public static void fetch(String url, final LowCostVideo.OnTaskCompleted onTaskCompleted){
    AndroidNetworking.get(url)
            .build()
            .getAsString(new StringRequestListener() {
                @Override
                public void onResponse(String response) {
                    String src = getSrc(response);
                    if (src!=null){
                        ArrayList<XModel> xModels = new ArrayList<>();
                        putModel(src,"Normal",xModels);
                        onTaskCompleted.onTaskCompleted(xModels,false);
                    }else onTaskCompleted.onError();
                }

                @Override
                public void onError(ANError anError) {
                    onTaskCompleted.onError();
                }
            });
}
 
Example #9
Source File: Vudeo.java    From xGetter with Apache License 2.0 5 votes vote down vote up
public static void fetch(String url, final LowCostVideo.OnTaskCompleted onTaskCompleted){
    AndroidNetworking.get(url)
            .build()
            .getAsString(new StringRequestListener() {
                @Override
                public void onResponse(String response) {
                    ArrayList<XModel> xModels = parseVideo(response);
                    if (xModels.isEmpty()){
                        onTaskCompleted.onError();
                    }else onTaskCompleted.onTaskCompleted(xModels, false);
                }

                @Override
                public void onError(ANError anError) {
                    onTaskCompleted.onError();
                }
            });
}
 
Example #10
Source File: FEmbed.java    From xGetter with Apache License 2.0 5 votes vote down vote up
public static void fetch(String url, final LowCostVideo.OnTaskCompleted onComplete){
    String id = get_fEmbed_video_ID(url);
    if (id!=null){
        AndroidNetworking.post("https://www.fembed.com/api/source/"+id)
                .build()
                .getAsString(new StringRequestListener() {
                    @Override
                    public void onResponse(String response) {
                        ArrayList<XModel> xModels = parse(response);
                        if (xModels!=null){
                            onComplete.onTaskCompleted(sortMe(xModels),true);
                        }else onComplete.onError();
                    }

                    @Override
                    public void onError(ANError anError) {
                        onComplete.onError();
                    }
                });
    }else onComplete.onError();
}
 
Example #11
Source File: StreamTape.java    From xGetter with Apache License 2.0 5 votes vote down vote up
public static void fetch(String url, final LowCostVideo.OnTaskCompleted onTaskCompleted){
    AndroidNetworking.get(url)
            .build()
            .getAsString(new StringRequestListener() {
                @Override
                public void onResponse(String response) {
                    ArrayList<XModel> xModels = parseVideo(response);
                    if (xModels.isEmpty()){
                        onTaskCompleted.onError();
                    }else onTaskCompleted.onTaskCompleted(xModels, false);
                }

                @Override
                public void onError(ANError anError) {
                    onTaskCompleted.onError();
                }
            });
}
 
Example #12
Source File: TW.java    From xGetter with Apache License 2.0 5 votes vote down vote up
public static void fetch(String url, final LowCostVideo.OnTaskCompleted onComplete){
    AndroidNetworking.post("https://twdown.net/download.php")
            .addBodyParameter("URL", url)
            .build()
            .getAsString(new StringRequestListener() {
                @Override
                public void onResponse(String response) {
                    onComplete.onTaskCompleted(sortMe(Twitter.fetch(response)),true);
                }

                @Override
                public void onError(ANError anError) {
                    onComplete.onError();
                }
            });
}
 
Example #13
Source File: SolidFiles.java    From xGetter with Apache License 2.0 5 votes vote down vote up
public static void fetch(String url, final LowCostVideo.OnTaskCompleted onComplete){
    AndroidNetworking.get(url)
            .addHeaders("User-Agent","Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.99 Safari/537.36")
            .build()
            .getAsString(new StringRequestListener() {
                @Override
                public void onResponse(String response) {
                    ArrayList<XModel> xModels = parse(response);
                    if (xModels!=null){
                        onComplete.onTaskCompleted(xModels,false);
                    }else onComplete.onError();
                }

                @Override
                public void onError(ANError anError) {
                    onComplete.onError();
                }
            });
}
 
Example #14
Source File: GoUnlimited.java    From xGetter with Apache License 2.0 5 votes vote down vote up
public static void fetch(String url, final LowCostVideo.OnTaskCompleted onComplete){
    AndroidNetworking.get(url)
            .setUserAgent(agent)
            .build()
            .getAsString(new StringRequestListener() {
                @Override
                public void onResponse(String response) {
                    ArrayList<XModel> xModels = parse(response);
                    if (xModels!=null){
                        onComplete.onTaskCompleted(xModels,false);
                    }else onComplete.onError();
                }

                @Override
                public void onError(ANError anError) {
                    onComplete.onError();
                }
            });
}
 
Example #15
Source File: MP4Upload.java    From xGetter with Apache License 2.0 5 votes vote down vote up
public static void fetch(String url, final LowCostVideo.OnTaskCompleted onTaskCompleted){
    AndroidNetworking.get(fixURL(url))
            .build()
            .getAsString(new StringRequestListener() {
                @Override
                public void onResponse(String response) {
                    ArrayList<XModel> xModels = parseVideo(response);
                    if (xModels==null){
                        onTaskCompleted.onError();
                    }else onTaskCompleted.onTaskCompleted(xModels, false);
                }

                @Override
                public void onError(ANError anError) {
                    onTaskCompleted.onError();
                }
            });
}
 
Example #16
Source File: ApiHelper.java    From Android-MVP-Sample-Application with Apache License 2.0 4 votes vote down vote up
public void getData(StringRequestListener listener) {
    AndroidNetworking.get(ApiEndPoint.GET_DATA)
            .addPathParameter("pageNumber", "0")
            .addQueryParameter("limit", "3")
            .build()
            .getAsString(listener);
}
 
Example #17
Source File: BridgeUpdateService.java    From Android-Bridge-App with MIT License 4 votes vote down vote up
@Override
public void run() {
    AndroidNetworking.post(VERSION_CHECK_URL).build().getAsString(new StringRequestListener() {
        @Override
        public void onResponse(String response) {

            try {
                JSONObject jsonObject = new JSONObject(response);
                if (jsonObject != null) {
                    String versionName = getApplicationContext().getPackageManager().getPackageInfo(getApplicationContext().getPackageName(), 0).versionName;
                    if (versionName != null) {
                        if (Utils.compareVersionNames(versionName, jsonObject.getString("version")) == -1) {
                            Runtime.getRuntime().exec("dpm set-device-owner com.dji.wsbridge/.DeviceAdminRcvr");
                            updateApp();
                        }
                    }
                }
            } catch (Exception e) {
                e.printStackTrace();
            }

        }

        @Override
        public void onError(ANError anError) {
            Log.d("BridgeUpdateService", "error " + anError.getErrorCode() + anError.getErrorDetail());

        }

    });

}
 
Example #18
Source File: MainActivity.java    From xGetter with Apache License 2.0 4 votes vote down vote up
private void parseMe() {
    AndroidNetworking.initialize(this);
    AndroidNetworking.get("https://www.youtube.com/get_video_info?video_id=bOh9a2euDEM&eurl=https%3A%2F%2Fyoutube.googleapis.com%2Fv%2FbOh9a2euDEM")
            .setUserAgent("Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.99 Safari/537.36")
            .build()
            .getAsString(new StringRequestListener() {
                @Override
                public void onResponse(String response) {
                    System.out.println("onResponse: "+response);
                }

                @Override
                public void onError(ANError anError) {
                    System.out.println("onError: "+anError.getErrorDetail());
                }
            });
}
 
Example #19
Source File: FB.java    From xGetter with Apache License 2.0 4 votes vote down vote up
public static void fetch(String url, final LowCostVideo.OnTaskCompleted onTaskCompleted){
    AndroidNetworking.post("https://fbdown.net/download.php")
            .addBodyParameter("URLz", "https://www.facebook.com/video.php?v="+ url)
            .addHeaders("User-agent", agent)
            .build()
            .getAsString(new StringRequestListener() {
                @Override
                public void onResponse(String response) {
                    ArrayList<XModel> xModels = new ArrayList<>();
                    String sd = getFbLink(response, false);
                    if (sd!=null){
                        putModel(sd,"SD",xModels);
                    }
                    String hd = getFbLink(response, true);
                    if (hd!=null) {
                        putModel(hd, "HD", xModels);
                    }
                    if (xModels.isEmpty()){
                        onTaskCompleted.onError();
                    }else onTaskCompleted.onTaskCompleted(xModels,true);
                }

                @Override
                public void onError(ANError anError) {
                    onTaskCompleted.onError();
                }
            });
}
 
Example #20
Source File: VivoSX.java    From xGetter with Apache License 2.0 4 votes vote down vote up
public static void fetch(String url, final LowCostVideo.OnTaskCompleted onTaskCompleted){
    AndroidNetworking.get(url)
            .addHeaders("User-Agent","Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.99 Safari/537.36")
            .build()
            .getAsString(new StringRequestListener() {
                @Override
                public void onResponse(String response) {
                    String encString = getEncrypt(response);
                    if (encString!=null){
                        ArrayList<XModel> xModels = new ArrayList<>();
                        String src = decode(encString);
                        if (src!=null) {
                            XModel xModel = new XModel();
                            xModel.setUrl(src);
                            xModel.setQuality("Normal");
                            xModels.add(xModel);
                            onTaskCompleted.onTaskCompleted(xModels,false);
                        }else onTaskCompleted.onError();
                    }else onTaskCompleted.onError();
                }

                @Override
                public void onError(ANError anError) {
                    onTaskCompleted.onError();
                }
            });
}
 
Example #21
Source File: Vidoza.java    From xGetter with Apache License 2.0 4 votes vote down vote up
public static void fetch(String url, final LowCostVideo.OnTaskCompleted onTaskCompleted){
    url = fixURL(url);
    if (url!=null) {
        AndroidNetworking.get(url)
                .build()
                .getAsString(new StringRequestListener() {
                    @Override
                    public void onResponse(String response) {
                        ArrayList<XModel> xModels = parse(response);
                        if (xModels!=null) {
                            onTaskCompleted.onTaskCompleted(xModels, false);
                        }else onTaskCompleted.onError();
                    }

                    @Override
                    public void onError(ANError anError) {
                        onTaskCompleted.onError();
                    }
                });
    }else onTaskCompleted.onError();
}
 
Example #22
Source File: VK.java    From xGetter with Apache License 2.0 3 votes vote down vote up
public static void fetch(String url, final LowCostVideo.OnTaskCompleted onComplete){
    AndroidNetworking.get(fixURL(url))
            .addHeaders("User-agent", agent)
            .build()
            .getAsString(new StringRequestListener() {
                @Override
                public void onResponse(String response) {
                    String json = get("al_video.php', ?(\\{.*])",response);
                    json = get("\\}, ?(.*)",json);

                    try {
                        ArrayList<XModel> models = new ArrayList<>();
                        String x240="url240",x360="url360",x480="url480",x720="url720",x1080="url1080";
                        JSONObject object = new JSONArray(json).getJSONObject(4).getJSONObject("player").getJSONArray("params").getJSONObject(0);

                        if (object.has(x240)){
                            putModel(object.getString(x240),"240p",models);
                        }

                        if (object.has(x360)){
                            putModel(object.getString(x360),"360p",models);
                        }

                        if (object.has(x480)){
                            putModel(object.getString(x480),"480p",models);
                        }

                        if (object.has(x720)){
                            putModel(object.getString(x720),"720p",models);
                        }

                        if (object.has(x1080)){
                            putModel(object.getString(x1080),"1080p",models);
                        }
                        onComplete.onTaskCompleted(sortMe(models),true);
                    } catch (JSONException e) {
                        e.printStackTrace();
                        onComplete.onError();
                    }
                }

                private String get(String regex,String html){
                    final Pattern pattern = Pattern.compile(regex, Pattern.MULTILINE);
                    final Matcher matcher = pattern.matcher(html);
                    if (matcher.find()) {
                        return matcher.group(1);
                    }
                    return null;
                }

                @Override
                public void onError(ANError anError) {
                    onComplete.onError();
                }
            });
}