Skip to content

Instantly share code, notes, and snippets.

View basusingh's full-sized avatar

Basu basusingh

View GitHub Profile
@basusingh
basusingh / decode-premium-stats.java
Created November 6, 2020 16:50
Decoding premium stats for an URL
//Decoding premium stats
//For free version, choose the required variables
private void decodePremiumData(){
ArrayList<String> nameList = new ArrayList<>();
ArrayList<Integer> countList = new ArrayList<>();
new AsyncTask<Void, Void, Void>(){
@Override
protected Void doInBackground(Void... p){
for(int i = 0; i<mStatsList.size(); i++){
URLStatsItems items = mStatsList.get(i);
@basusingh
basusingh / get-all-tags.txt
Created November 6, 2020 16:05
Get all tags for an URL
@params
URL_ID = URL id of the shorten URL to all its tags
//Tags are returned as a String containing JSON file
//A default function is availavle to parse tags
//The tags are returned as an String array
ThrwAtURLManager.getInstance(getApplicationContext()).getAllTagsLive(items.getUrlId()).observe(this, new Observer<String>() {
@Override
public void onChanged(String s) {
String[] mTags = ThrwAtURLManager.getInstance(getApplicationContext()).parseTags(s);
@basusingh
basusingh / add-tag.txt
Created November 6, 2020 09:46
Add tag to an URL
@params
URL_ID = URL id of the shorten URL to add tag
YOUR_TAG = Your custom tag
//Adding a tag must be done on a background thread.
//You can declare your own logic to run the task on a background thread.
//This AsyncTask will leak memory
new AsyncTask<Void, Void, Void>(){
@Override
protected Void doInBackground(Void... voids) {
@basusingh
basusingh / delete-url.txt
Last active November 7, 2020 13:23
Delete an URL
@params
URL_ID = URL id of the shorten URL to delete
ThrwAtURLManager.getInstance(getApplicationContext()).deleteURL("URL_ID", new onURLDeleteListener() {
@Override
public void onComplete(ThrwAtURLDeleteTask task) {
Log.e("Message:", task.getMessage());
}
});
@basusingh
basusingh / add-update-password.txt
Created November 6, 2020 09:35
Add or update password to protect URL
@params
URL_ID = URL id of the shorten URL to add or update password
PASSWORD = Password to set for the URL
ThrwAtURLManager.getInstance(getApplicationContext()).updatePassword("URL_ID", "PASSWORD", new onURLPasswordUpdateListener() {
@Override
public void onComplete(ThrwAtURLPasswordUpdateTask task) {
if(task.isSuccessful()){
Log.e("Success message:", task.getMessage());
} else {
@basusingh
basusingh / remove-password.txt
Last active November 7, 2020 13:23
Remove password protection from the URL
@params
URL_ID = Url ID of the shorten url
ThrwAtURLManager.getInstance(getApplicationContext()).removePassword("URL_ID", new onURLPasswordRemoveListener() {
@Override
public void onComplete(ThrwAtURLPasswordRemoveListener task) {
if(task.isSuccessful()){
Log.e("Success message:", task.getMessage());
} else {
Log.e("Error message:", task.getMessage());
@basusingh
basusingh / URLItems.txt
Created November 6, 2020 09:15
URLItems description
//URLItems variables
//Unique ID of your URL
public String urlId;
//Long URL
public String url;
//Shorten URL
public String tinyUrl;
@basusingh
basusingh / get-all-url.txt
Last active November 7, 2020 13:24
Get all URLs
//All items are returned in descending order unless specified
//Get all URLs
List<URLItems>getAllShortenURLS()
//Get {count} number of URLs
List<URLItems>getShortenURLS(int count)
//Get all URLs in ascending order
List<URLItems> getAllShortenURLSAscending()
@basusingh
basusingh / get-user.txt
Last active November 7, 2020 13:24
Get current user
@return
Returns an instance of ThrwAtUser
ThrwAtUser user = ThrwAt.getInstance(getApplicationContext()).getCurrentUser();
Log.e("User ID:", user.getUserId());
Log.e("API Key:", user.getApiKey());
@basusingh
basusingh / force-sync.txt
Last active November 7, 2020 13:25
Do a force sync from server
ThrwAtURLManager.getInstance(getApplicationContext()).doForceSyncFromServer();