-
-
Notifications
You must be signed in to change notification settings - Fork 112
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
+ Percentage while downloading + Improved tag scraping
- Loading branch information
Showing
10 changed files
with
86 additions
and
239 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package com.dar.nclientv2.async; | ||
|
||
import android.app.IntentService; | ||
import android.content.Context; | ||
import android.content.Intent; | ||
import android.util.JsonReader; | ||
|
||
import com.dar.nclientv2.api.components.Tag; | ||
import com.dar.nclientv2.api.enums.TagStatus; | ||
import com.dar.nclientv2.api.enums.TagType; | ||
import com.dar.nclientv2.async.database.Queries; | ||
import com.dar.nclientv2.settings.Database; | ||
import com.dar.nclientv2.settings.Global; | ||
|
||
import java.io.IOException; | ||
import java.util.Date; | ||
|
||
import androidx.annotation.Nullable; | ||
import okhttp3.Request; | ||
|
||
public class ScrapeTags extends IntentService { | ||
private static final String URL="https://violable-hats.000webhostapp.com/tags.json"; | ||
//check every 30day | ||
private static final long DIFFERENCE_TIME=30L*24*60*60; | ||
public ScrapeTags() { | ||
super("Scrape Tag"); | ||
} | ||
|
||
|
||
@Override | ||
protected void onHandleIntent(@Nullable Intent intent) { | ||
try { | ||
if(new Date().getTime()-getApplicationContext().getSharedPreferences("Settings",0).getLong("lastSync",new Date().getTime())<DIFFERENCE_TIME)return; | ||
JsonReader reader=new JsonReader(Global.client.newCall(new Request.Builder().url(URL).build()).execute().body().charStream()); | ||
reader.beginArray(); | ||
int id=reader.nextInt(); | ||
String name=reader.nextString(); | ||
int count=reader.nextInt(); | ||
TagType type=TagType.values()[reader.nextInt()]; | ||
while (reader.hasNext()) Queries.TagTable.insert(Database.getDatabase(),new Tag(name,count,id,type, TagStatus.DEFAULT)); | ||
reader.close(); | ||
getApplicationContext().getSharedPreferences("Settings",0).edit().putLong("lastSync",new Date().getTime()).apply(); | ||
} catch (IOException e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
} |
86 changes: 0 additions & 86 deletions
86
app/src/main/java/com/dar/nclientv2/async/scrape/BulkScraper.java
This file was deleted.
Oops, something went wrong.
103 changes: 0 additions & 103 deletions
103
app/src/main/java/com/dar/nclientv2/async/scrape/TagPageScraper.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.