From de6d757176c12412301ba7aef3a5eac4cfbd6820 Mon Sep 17 00:00:00 2001 From: Lcukerd Date: Thu, 1 Feb 2018 17:06:09 +0530 Subject: [PATCH] changed scrapper as per changes in instagram. Fuckin stop changing instagramgit add . --- .idea/modules.xml | 2 + app/build.gradle | 2 +- .../com/instaswipe/ProfileActivity.java | 2 +- .../com/instaswipe/Utils/Scrapper.java | 67 ++++++++----------- .../instaswipe/adapter/GridImageAdapter.java | 6 +- build.gradle | 2 + 6 files changed, 36 insertions(+), 45 deletions(-) diff --git a/.idea/modules.xml b/.idea/modules.xml index 98d6f25..b9930fc 100644 --- a/.idea/modules.xml +++ b/.idea/modules.xml @@ -3,6 +3,8 @@ + + diff --git a/app/build.gradle b/app/build.gradle index fb89730..a55be89 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -2,7 +2,7 @@ apply plugin: 'com.android.application' android { compileSdkVersion 25 - buildToolsVersion "25.0.0" + buildToolsVersion '26.0.2' defaultConfig { applicationId "lcukerd.com.instaswipe" minSdkVersion 18 diff --git a/app/src/main/java/lcukerd/com/instaswipe/ProfileActivity.java b/app/src/main/java/lcukerd/com/instaswipe/ProfileActivity.java index 258157d..53b979d 100644 --- a/app/src/main/java/lcukerd/com/instaswipe/ProfileActivity.java +++ b/app/src/main/java/lcukerd/com/instaswipe/ProfileActivity.java @@ -153,7 +153,7 @@ public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) public void onClick(View v) { ArrayList temp = new ArrayList<>(); - temp.add(profilepicURL); + temp.add(Scrapper.getProfilePicHDUrl(sourceCode)); Intent intent = new Intent(ProfileActivity.this, SwipePic.class); intent.putStringArrayListExtra("urls", temp); intent.putExtra("id", "-1"); diff --git a/app/src/main/java/lcukerd/com/instaswipe/Utils/Scrapper.java b/app/src/main/java/lcukerd/com/instaswipe/Utils/Scrapper.java index 9310a68..3aac9cc 100644 --- a/app/src/main/java/lcukerd/com/instaswipe/Utils/Scrapper.java +++ b/app/src/main/java/lcukerd/com/instaswipe/Utils/Scrapper.java @@ -14,19 +14,15 @@ * Created by Programmer on 15-09-2017. */ -public class Scrapper -{ +public class Scrapper { private static final String tag = Scrapper.class.getSimpleName(); - public static ArrayList getUsersfromsearch(String result) - { + public static ArrayList getUsersfromsearch(String result) { ArrayList userArrayList = new ArrayList<>(); - try - { + try { JSONObject jsonObject = new JSONObject(result); JSONArray jsonArray = jsonObject.getJSONArray("users"); - for (int i = 0; i < jsonArray.length(); i++) - { + for (int i = 0; i < jsonArray.length(); i++) { User u = new User(); jsonObject = jsonArray.getJSONObject(i); jsonObject = jsonObject.getJSONObject("user"); @@ -41,32 +37,34 @@ public static ArrayList getUsersfromsearch(String result) u.isprivate = ""; userArrayList.add(u); } - } catch (JSONException e) - { + } catch (JSONException e) { Log.e(tag, "Error in Json " + result); } return userArrayList; } - public static String getUsername(String result) - { + public static String getUsername(String result) { int start = result.indexOf("", result.indexOf("", start); String videoUrl = result.substring(start, end); diff --git a/app/src/main/java/lcukerd/com/instaswipe/adapter/GridImageAdapter.java b/app/src/main/java/lcukerd/com/instaswipe/adapter/GridImageAdapter.java index 6083f13..fe61f6b 100644 --- a/app/src/main/java/lcukerd/com/instaswipe/adapter/GridImageAdapter.java +++ b/app/src/main/java/lcukerd/com/instaswipe/adapter/GridImageAdapter.java @@ -113,7 +113,7 @@ public boolean onLongClick(View v) { } }); } else { - if ((imgURLs.size() - 4 <= position + 1) && (imgURLs.size() >= 12)) { + if ((imgURLs.size() - 1 <= position + 1) && (imgURLs.size() >= 12)) { Log.d(tag, "end reached"); if ((wait == false) && (nomoreposts == false) && (Private == false) && (internetworking == true)) loadmore(); @@ -231,8 +231,8 @@ public void onCompleted(Exception e, String result) { } pos = result.indexOf("\",", result.indexOf("thumbnail_src", pos)); } catch (NullPointerException ne) { - internetworking = false; - Toast.makeText(mContext, "Internet Not Working", Toast.LENGTH_SHORT).show(); + /*internetworking = false; + Toast.makeText(mContext, "Internet Not Working", Toast.LENGTH_SHORT).show();*/ Log.e(tag, "Internet not working", ne); } catch (StringIndexOutOfBoundsException finished) { Toast.makeText(mContext, "No More posts", Toast.LENGTH_SHORT).show(); diff --git a/build.gradle b/build.gradle index c8d8891..331c6a5 100644 --- a/build.gradle +++ b/build.gradle @@ -3,6 +3,7 @@ buildscript { repositories { jcenter() + google() } dependencies { classpath 'com.android.tools.build:gradle:3.0.1' @@ -21,6 +22,7 @@ allprojects { mavenCentral() maven { url 'https://maven.google.com' } maven { url 'https://dl.bintray.com/drummer-aidan/maven' } + google() } }