Java Code Examples for com.androidnetworking.interfaces.StringRequestListener

The following examples show how to use com.androidnetworking.interfaces.StringRequestListener. These examples are extracted from open source projects. 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
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 Project: xGetter   Source File: MP4Upload.java    License: 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 3
Source Project: xGetter   Source File: GoUnlimited.java    License: 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 4
Source Project: xGetter   Source File: SolidFiles.java    License: 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 5
Source Project: xGetter   Source File: TW.java    License: 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 6
Source Project: xGetter   Source File: StreamTape.java    License: 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 7
Source Project: xGetter   Source File: FEmbed.java    License: 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 8
Source Project: xGetter   Source File: MFire.java    License: 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 9
Source Project: xGetter   Source File: Vudeo.java    License: 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 Project: xGetter   Source File: SendVid.java    License: 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 11
Source Project: xGetter   Source File: VideoBIN.java    License: 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 12
Source Project: xGetter   Source File: GPhotos.java    License: 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 13
Source Project: xGetter   Source File: BitTube.java    License: 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 14
Source Project: xGetter   Source File: Vlare.java    License: 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 15
Source Project: xGetter   Source File: Muvix.java    License: 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 16
Source Project: xGetter   Source File: MainActivity.java    License: 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 17
Source Project: xGetter   Source File: Vidoza.java    License: 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 18
Source Project: xGetter   Source File: VivoSX.java    License: 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 19
Source Project: xGetter   Source File: FB.java    License: 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 Project: Android-Bridge-App   Source File: BridgeUpdateService.java    License: 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 21
Source Project: Android-MVP-Sample-Application   Source File: ApiHelper.java    License: 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 22
Source Project: xGetter   Source File: VK.java    License: 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();
                }
            });
}