Austin Huang
4 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
25 changed files with 392 additions and 308 deletions
-
7app/build.gradle
-
2app/src/main/java/awais/instagrabber/activities/MainActivity.java
-
102app/src/main/java/awais/instagrabber/asyncs/HashtagFetcher.java
-
6app/src/main/java/awais/instagrabber/asyncs/HashtagPostFetchService.java
-
135app/src/main/java/awais/instagrabber/fragments/HashTagFragment.java
-
83app/src/main/java/awais/instagrabber/fragments/PostViewV2Fragment.java
-
11app/src/main/java/awais/instagrabber/fragments/main/ProfileFragment.java
-
35app/src/main/java/awais/instagrabber/models/HashtagModel.java
-
35app/src/main/java/awais/instagrabber/models/enums/FollowingType.java
-
3app/src/main/java/awais/instagrabber/repositories/GraphQLRepository.java
-
12app/src/main/java/awais/instagrabber/repositories/MediaRepository.java
-
14app/src/main/java/awais/instagrabber/repositories/TagsRepository.java
-
45app/src/main/java/awais/instagrabber/repositories/responses/Hashtag.java
-
8app/src/main/java/awais/instagrabber/utils/ExportImportUtils.java
-
36app/src/main/java/awais/instagrabber/viewmodels/PostViewV2ViewModel.java
-
42app/src/main/java/awais/instagrabber/webservices/GraphQLService.java
-
32app/src/main/java/awais/instagrabber/webservices/MediaService.java
-
51app/src/main/java/awais/instagrabber/webservices/TagsService.java
-
3app/src/main/res/menu/post_view_menu.xml
-
1app/src/main/res/values/strings.xml
-
BINgradle/wrapper/gradle-wrapper.jar
-
7gradle/wrapper/gradle-wrapper.properties
-
2gradlew
-
25gradlew.bat
-
3renovate.json
@ -1,102 +0,0 @@ |
|||||
package awais.instagrabber.asyncs; |
|
||||
|
|
||||
import android.os.AsyncTask; |
|
||||
import android.util.Log; |
|
||||
|
|
||||
import androidx.annotation.Nullable; |
|
||||
|
|
||||
import org.json.JSONArray; |
|
||||
import org.json.JSONObject; |
|
||||
|
|
||||
import java.io.BufferedReader; |
|
||||
import java.io.IOException; |
|
||||
import java.io.InputStream; |
|
||||
import java.io.InputStreamReader; |
|
||||
import java.net.HttpURLConnection; |
|
||||
import java.net.URL; |
|
||||
|
|
||||
import awais.instagrabber.BuildConfig; |
|
||||
import awais.instagrabber.interfaces.FetchListener; |
|
||||
import awais.instagrabber.models.HashtagModel; |
|
||||
import awais.instagrabber.utils.Constants; |
|
||||
import awais.instagrabber.utils.NetworkUtils; |
|
||||
//import awaisomereport.LogCollector; |
|
||||
|
|
||||
//import static awais.instagrabber.utils.Utils.logCollector; |
|
||||
|
|
||||
public final class HashtagFetcher extends AsyncTask<Void, Void, HashtagModel> { |
|
||||
private static final String TAG = "HashtagFetcher"; |
|
||||
|
|
||||
private final FetchListener<HashtagModel> fetchListener; |
|
||||
private final String hashtag; |
|
||||
|
|
||||
public HashtagFetcher(String hashtag, FetchListener<HashtagModel> fetchListener) { |
|
||||
this.hashtag = hashtag; |
|
||||
this.fetchListener = fetchListener; |
|
||||
} |
|
||||
|
|
||||
@Nullable |
|
||||
@Override |
|
||||
protected HashtagModel doInBackground(final Void... voids) { |
|
||||
HashtagModel result = null; |
|
||||
|
|
||||
try { |
|
||||
final HttpURLConnection conn = (HttpURLConnection) new URL("https://www.instagram.com/explore/tags/" + hashtag + "/?__a=1") |
|
||||
.openConnection(); |
|
||||
conn.setUseCaches(true); |
|
||||
conn.connect(); |
|
||||
|
|
||||
if (conn.getResponseCode() == HttpURLConnection.HTTP_OK) { |
|
||||
final JSONObject user = new JSONObject(NetworkUtils.readFromConnection(conn)).getJSONObject("graphql") |
|
||||
.getJSONObject(Constants.EXTRAS_HASHTAG); |
|
||||
|
|
||||
final JSONObject timelineMedia = user.getJSONObject("edge_hashtag_to_media"); |
|
||||
if (timelineMedia.has("edges")) { |
|
||||
final JSONArray edges = timelineMedia.getJSONArray("edges"); |
|
||||
} |
|
||||
|
|
||||
result = new HashtagModel( |
|
||||
user.getString(Constants.EXTRAS_ID), |
|
||||
user.getString("name"), |
|
||||
user.getString("profile_pic_url"), |
|
||||
timelineMedia.getLong("count"), |
|
||||
user.optBoolean("is_following")); |
|
||||
} else { |
|
||||
BufferedReader bufferedReader = null; |
|
||||
try { |
|
||||
final InputStream responseInputStream = conn.getErrorStream(); |
|
||||
bufferedReader = new BufferedReader(new InputStreamReader(responseInputStream)); |
|
||||
final StringBuilder builder = new StringBuilder(); |
|
||||
for (String line = bufferedReader.readLine(); line != null; line = bufferedReader.readLine()) { |
|
||||
if (builder.length() != 0) { |
|
||||
builder.append("\n"); |
|
||||
} |
|
||||
builder.append(line); |
|
||||
} |
|
||||
Log.d(TAG, "doInBackground: " + builder.toString()); |
|
||||
} finally { |
|
||||
if (bufferedReader != null) { |
|
||||
try { |
|
||||
bufferedReader.close(); |
|
||||
} catch (IOException ignored) { |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
conn.disconnect(); |
|
||||
} catch (final Exception e) { |
|
||||
// if (logCollector != null) |
|
||||
// logCollector.appendException(e, LogCollector.LogFile.ASYNC_HASHTAG_FETCHER, "doInBackground"); |
|
||||
if (BuildConfig.DEBUG) Log.e(TAG, "", e); |
|
||||
if (fetchListener != null) fetchListener.onFailure(e); |
|
||||
} |
|
||||
|
|
||||
return result; |
|
||||
} |
|
||||
|
|
||||
@Override |
|
||||
protected void onPostExecute(final HashtagModel result) { |
|
||||
if (fetchListener != null) fetchListener.onResult(result); |
|
||||
} |
|
||||
} |
|
@ -1,35 +0,0 @@ |
|||||
package awais.instagrabber.models; |
|
||||
|
|
||||
import java.io.Serializable; |
|
||||
|
|
||||
public final class HashtagModel implements Serializable { |
|
||||
private final boolean following; |
|
||||
private final long postCount; |
|
||||
private final String id; |
|
||||
private final String name; |
|
||||
private final String sdProfilePic; |
|
||||
|
|
||||
public HashtagModel(final String id, final String name, final String sdProfilePic, final long postCount, final boolean following) { |
|
||||
this.id = id; |
|
||||
this.name = name; |
|
||||
this.sdProfilePic = sdProfilePic; |
|
||||
this.postCount = postCount; |
|
||||
this.following = following; |
|
||||
} |
|
||||
|
|
||||
public String getId() { |
|
||||
return id; |
|
||||
} |
|
||||
|
|
||||
public String getName() { |
|
||||
return name; |
|
||||
} |
|
||||
|
|
||||
public String getSdProfilePic() { |
|
||||
return sdProfilePic; |
|
||||
} |
|
||||
|
|
||||
public Long getPostCount() { return postCount; } |
|
||||
|
|
||||
public boolean getFollowing() { return following; } |
|
||||
} |
|
@ -0,0 +1,35 @@ |
|||||
|
package awais.instagrabber.models.enums; |
||||
|
|
||||
|
import com.google.gson.annotations.SerializedName; |
||||
|
|
||||
|
import java.io.Serializable; |
||||
|
import java.util.HashMap; |
||||
|
import java.util.Map; |
||||
|
|
||||
|
public enum FollowingType implements Serializable { |
||||
|
@SerializedName("1") |
||||
|
FOLLOWING(1), |
||||
|
@SerializedName("0") |
||||
|
NOT_FOLLOWING(0); |
||||
|
|
||||
|
private final int id; |
||||
|
private static final Map<Integer, FollowingType> map = new HashMap<>(); |
||||
|
|
||||
|
static { |
||||
|
for (FollowingType type : FollowingType.values()) { |
||||
|
map.put(type.id, type); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
FollowingType(final int id) { |
||||
|
this.id = id; |
||||
|
} |
||||
|
|
||||
|
public int getId() { |
||||
|
return id; |
||||
|
} |
||||
|
|
||||
|
public static FollowingType valueOf(final int id) { |
||||
|
return map.get(id); |
||||
|
} |
||||
|
} |
@ -0,0 +1,45 @@ |
|||||
|
package awais.instagrabber.repositories.responses; |
||||
|
|
||||
|
import java.io.Serializable; |
||||
|
|
||||
|
import awais.instagrabber.models.enums.FollowingType; |
||||
|
|
||||
|
public final class Hashtag implements Serializable { |
||||
|
private final FollowingType following; // 0 false 1 true |
||||
|
private final long mediaCount; |
||||
|
private final String id; |
||||
|
private final String name; |
||||
|
private final String profilePicUrl; // on app API this is always null (property exists) |
||||
|
|
||||
|
public Hashtag(final String id, |
||||
|
final String name, |
||||
|
final String profilePicUrl, |
||||
|
final long mediaCount, |
||||
|
final FollowingType following) { |
||||
|
this.id = id; |
||||
|
this.name = name; |
||||
|
this.profilePicUrl = profilePicUrl; |
||||
|
this.mediaCount = mediaCount; |
||||
|
this.following = following; |
||||
|
} |
||||
|
|
||||
|
public String getId() { |
||||
|
return id; |
||||
|
} |
||||
|
|
||||
|
public String getName() { |
||||
|
return name; |
||||
|
} |
||||
|
|
||||
|
public String getProfilePicUrl() { |
||||
|
return profilePicUrl; |
||||
|
} |
||||
|
|
||||
|
public Long getMediaCount() { |
||||
|
return mediaCount; |
||||
|
} |
||||
|
|
||||
|
public FollowingType getFollowing() { |
||||
|
return following; |
||||
|
} |
||||
|
} |
@ -1,9 +1,6 @@ |
|||||
#Sun Feb 28 01:04:23 JST 2021 |
|
||||
distributionBase=GRADLE_USER_HOME |
distributionBase=GRADLE_USER_HOME |
||||
distributionPath=wrapper/dists |
distributionPath=wrapper/dists |
||||
|
distributionSha256Sum=9af5c8e7e2cd1a3b0f694a4ac262b9f38c75262e74a9e8b5101af302a6beadd7 |
||||
|
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-all.zip |
||||
zipStoreBase=GRADLE_USER_HOME |
zipStoreBase=GRADLE_USER_HOME |
||||
zipStorePath=wrapper/dists |
zipStorePath=wrapper/dists |
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.2-all.zip |
|
||||
distributionSha256Sum=1433372d903ffba27496f8d5af24265310d2da0d78bf6b4e5138831d4fe066e9 |
|
||||
# https://gradle.org/releases/ |
|
||||
# https://gradle.org/release-checksums/ |
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue