Skip to content
Snippets Groups Projects
Commit a547c5d7 authored by Jawnnypoo's avatar Jawnnypoo
Browse files

LoganSquare -> Moshi

parent ad4cafdd
No related branches found
No related tags found
No related merge requests found
Showing
with 99 additions and 117 deletions
package com.commit451.gitlab.model.api;
 
import com.bluelinelabs.logansquare.annotation.JsonField;
import com.bluelinelabs.logansquare.annotation.JsonObject;
import com.squareup.moshi.Json;
 
import org.parceler.Parcel;
 
@Parcel
@JsonObject
public class RepositoryFile {
@JsonField(name = "file_name")
@Json(name = "file_name")
String fileName;
@JsonField(name = "file_path")
@Json(name = "file_path")
String filePath;
@JsonField(name = "size")
@Json(name = "size")
long size;
@JsonField(name = "encoding")
@Json(name = "encoding")
String encoding;
@JsonField(name = "content")
@Json(name = "content")
String content;
@JsonField(name = "ref")
@Json(name = "ref")
String ref;
@JsonField(name = "blob_id")
@Json(name = "blob_id")
String blobId;
@JsonField(name = "commit_id")
@Json(name = "commit_id")
String commitId;
@JsonField(name = "last_commit_id")
@Json(name = "last_commit_id")
String lastCommitId;
 
public RepositoryFile() {}
Loading
Loading
Loading
Loading
@@ -2,8 +2,7 @@ package com.commit451.gitlab.model.api;
 
import android.support.annotation.StringDef;
 
import com.bluelinelabs.logansquare.annotation.JsonField;
import com.bluelinelabs.logansquare.annotation.JsonObject;
import com.squareup.moshi.Json;
 
import org.parceler.Parcel;
 
Loading
Loading
@@ -11,7 +10,6 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
 
@Parcel
@JsonObject
public class RepositoryTreeObject {
 
public static final String TYPE_FOLDER = "tree";
Loading
Loading
@@ -23,14 +21,14 @@ public class RepositoryTreeObject {
public @interface Type {
}
 
@JsonField(name = "id")
@Json(name = "id")
String id;
@JsonField(name = "name")
@Json(name = "name")
String name;
@JsonField(name = "type")
@Json(name = "type")
@Type
String type;
@JsonField(name = "mode")
@Json(name = "mode")
String mode;
 
public RepositoryTreeObject() {}
Loading
Loading
package com.commit451.gitlab.model.api;
 
import com.bluelinelabs.logansquare.annotation.JsonField;
import com.bluelinelabs.logansquare.annotation.JsonObject;
import com.squareup.moshi.Json;
 
import org.parceler.Parcel;
 
Loading
Loading
@@ -9,18 +8,17 @@ import org.parceler.Parcel;
* A runner. It runs builds. yeah
*/
@Parcel
@JsonObject
public class Runner {
 
@JsonField(name = "id")
@Json(name = "id")
long id;
@JsonField(name = "description")
@Json(name = "description")
String description;
@JsonField(name = "active")
@Json(name = "active")
boolean active;
@JsonField(name = "is_shared")
@Json(name = "is_shared")
boolean isShared;
@JsonField(name = "name")
@Json(name = "name")
String name;
 
public long getId() {
Loading
Loading
package com.commit451.gitlab.model.api;
 
import com.bluelinelabs.logansquare.annotation.JsonField;
import com.bluelinelabs.logansquare.annotation.JsonObject;
import com.squareup.moshi.Json;
 
import org.parceler.Parcel;
 
Loading
Loading
@@ -11,21 +10,20 @@ import java.util.Date;
* A snippet!
*/
@Parcel
@JsonObject
public class Snippet {
@JsonField(name = "id")
@Json(name = "id")
long id;
@JsonField(name = "title")
@Json(name = "title")
String title;
@JsonField(name = "file_name")
@Json(name = "file_name")
String fileName;
@JsonField(name = "author")
@Json(name = "author")
Author author;
@JsonField(name = "expires_at")
@Json(name = "expires_at")
Date expiresAt;
@JsonField(name = "updated_at")
@Json(name = "updated_at")
Date updatedAt;
@JsonField(name = "created_at")
@Json(name = "created_at")
Date createdAt;
 
protected Snippet() {
Loading
Loading
@@ -45,19 +43,18 @@ public class Snippet {
}
 
@Parcel
@JsonObject
public static class Author {
@JsonField(name = "id")
@Json(name = "id")
long mId;
@JsonField(name = "username")
@Json(name = "username")
String mUsername;
@JsonField(name = "email")
@Json(name = "email")
String mEmail;
@JsonField(name = "name")
@Json(name = "name")
String mName;
@JsonField(name = "state")
@Json(name = "state")
String mState;
@JsonField(name = "created_at")
@Json(name = "created_at")
Date mCreatedAt;
 
protected Author() {
Loading
Loading
package com.commit451.gitlab.model.api;
 
import com.bluelinelabs.logansquare.annotation.JsonField;
import com.bluelinelabs.logansquare.annotation.JsonObject;
import com.squareup.moshi.Json;
 
/**
* A tag in Git
*/
@JsonObject
public class Tag {
 
@JsonField(name = "name")
@Json(name = "name")
String name;
@JsonField(name = "message")
@Json(name = "message")
String message;
@JsonField(name = "commit")
@Json(name = "commit")
Commit commit;
@JsonField(name = "release")
@Json(name = "release")
Release release;
 
protected Tag() {
Loading
Loading
@@ -38,20 +36,18 @@ public class Tag {
return release;
}
 
@JsonObject
public static class Commit {
 
@JsonField(name = "id")
@Json(name = "id")
String mId;
@JsonField(name = "message")
@Json(name = "message")
String mMessage;
}
 
@JsonObject
public static class Release {
@JsonField(name = "tag_name")
@Json(name = "tag_name")
String mTagName;
@JsonField(name = "description")
@Json(name = "description")
String mDescription;
}
}
Loading
Loading
@@ -2,8 +2,7 @@ package com.commit451.gitlab.model.api;
 
import android.support.annotation.StringDef;
 
import com.bluelinelabs.logansquare.annotation.JsonField;
import com.bluelinelabs.logansquare.annotation.JsonObject;
import com.squareup.moshi.Json;
 
import org.parceler.Parcel;
 
Loading
Loading
@@ -16,7 +15,6 @@ import java.util.Date;
* makes it not play nice with any automated json parsing
*/
@Parcel
@JsonObject
public class Todo {
 
public static final String TARGET_ISSUE = "Issue";
Loading
Loading
@@ -35,25 +33,25 @@ public class Todo {
public @interface State {
}
 
@JsonField(name = "id")
@Json(name = "id")
String id;
@JsonField(name = "project")
@Json(name = "project")
Project project;
@JsonField(name = "author")
@Json(name = "author")
UserBasic author;
@JsonField(name = "action_name")
@Json(name = "action_name")
String actionName;
@JsonField(name = "target_type")
@Json(name = "target_type")
@TargetType
String targetType;
@JsonField(name = "target_url")
@Json(name = "target_url")
String targetUrl;
@JsonField(name = "body")
@Json(name = "body")
String body;
@JsonField(name = "state")
@Json(name = "state")
@State
String state;
@JsonField(name = "created_at")
@Json(name = "created_at")
Date createdAt;
 
public Todo() {}
Loading
Loading
package com.commit451.gitlab.model.api;
 
import com.bluelinelabs.logansquare.annotation.JsonField;
import com.bluelinelabs.logansquare.annotation.JsonObject;
import com.squareup.moshi.Json;
 
import org.parceler.Parcel;
 
import java.util.Date;
 
@Parcel
@JsonObject
public class User extends UserBasic {
@JsonField(name = "created_at")
@Json(name = "created_at")
Date createdAt;
@JsonField(name = "is_admin")
@Json(name = "is_admin")
boolean isAdmin;
@JsonField(name = "bio")
@Json(name = "bio")
String bio;
@JsonField(name = "skype")
@Json(name = "skype")
String skype;
@JsonField(name = "linkedin")
@Json(name = "linkedin")
String linkedin;
@JsonField(name = "twitter")
@Json(name = "twitter")
String twitter;
@JsonField(name = "website_url")
@Json(name = "website_url")
String websiteUrl;
 
public User() {}
Loading
Loading
Loading
Loading
@@ -4,8 +4,7 @@ import android.net.Uri;
import android.support.annotation.Nullable;
import android.support.annotation.StringDef;
 
import com.bluelinelabs.logansquare.annotation.JsonField;
import com.bluelinelabs.logansquare.annotation.JsonObject;
import com.squareup.moshi.Json;
 
import org.parceler.Parcel;
 
Loading
Loading
@@ -13,7 +12,6 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
 
@Parcel
@JsonObject
public class UserBasic extends UserSafe {
 
public static final String STATE_ACTIVE = "active";
Loading
Loading
@@ -23,14 +21,14 @@ public class UserBasic extends UserSafe {
@Retention(RetentionPolicy.SOURCE)
public @interface State {}
 
@JsonField(name = "id")
@Json(name = "id")
long id;
@JsonField(name = "state")
@Json(name = "state")
@State
String state;
@JsonField(name = "avatar_url")
@Json(name = "avatar_url")
String avatarUrl;
@JsonField(name = "web_url")
@Json(name = "web_url")
String webUrl;
 
public UserBasic() {}
Loading
Loading
package com.commit451.gitlab.model.api;
 
import com.bluelinelabs.logansquare.annotation.JsonField;
import com.bluelinelabs.logansquare.annotation.JsonObject;
import com.squareup.moshi.Json;
 
import org.parceler.Parcel;
 
Loading
Loading
@@ -9,25 +8,24 @@ import java.util.Date;
import java.util.List;
 
@Parcel
@JsonObject
public class UserFull extends User {
@JsonField(name = "email")
@Json(name = "email")
String email;
@JsonField(name = "theme_id")
@Json(name = "theme_id")
int themeId;
@JsonField(name = "color_scheme_id")
@Json(name = "color_scheme_id")
int colorSchemeId;
@JsonField(name = "projects_limit")
@Json(name = "projects_limit")
int projectsLimit;
@JsonField(name = "current_sign_in_at")
@Json(name = "current_sign_in_at")
Date currentSignInAt;
@JsonField(name = "identities")
@Json(name = "identities")
List<Identity> identities;
@JsonField(name = "can_create_group")
@Json(name = "can_create_group")
boolean canCreateGroup;
@JsonField(name = "can_create_project")
@Json(name = "can_create_project")
boolean canCreateProject;
@JsonField(name = "two_factor_enabled")
@Json(name = "two_factor_enabled")
boolean twoFactorEnabled;
 
public UserFull() {}
Loading
Loading
package com.commit451.gitlab.model.api;
 
import com.bluelinelabs.logansquare.annotation.JsonField;
import com.bluelinelabs.logansquare.annotation.JsonObject;
import com.squareup.moshi.Json;
 
import org.parceler.Parcel;
 
@Parcel
@JsonObject
public class UserLogin extends UserFull {
@JsonField(name = "private_token")
@Json(name = "private_token")
String privateToken;
 
public UserLogin() {}
Loading
Loading
package com.commit451.gitlab.model.api;
 
import com.bluelinelabs.logansquare.annotation.JsonField;
import com.bluelinelabs.logansquare.annotation.JsonObject;
import com.squareup.moshi.Json;
 
import org.parceler.Parcel;
 
@Parcel
@JsonObject
public class UserSafe {
@JsonField(name = "name")
@Json(name = "name")
String name;
@JsonField(name = "username")
@Json(name = "username")
String username;
 
public UserSafe() {}
Loading
Loading
Loading
Loading
@@ -2,7 +2,7 @@ package com.commit451.gitlab.widget
 
import android.content.Context
import android.content.SharedPreferences
import com.bluelinelabs.logansquare.LoganSquare
import com.commit451.gitlab.api.MoshiProvider
import com.commit451.gitlab.model.Account
import java.io.IOException
 
Loading
Loading
@@ -24,7 +24,8 @@ object ProjectFeedWidgetPrefs {
val accountsJson = getSharedPrefs(context).getString(widgetId.toString() + KEY_ACCOUNT, null)
if (!accountsJson.isNullOrEmpty()) {
try {
return LoganSquare.parse(accountsJson, Account::class.java)
val adapter = MoshiProvider.moshi.adapter<Account>(Account::class.java)
return adapter.fromJson(accountsJson)
} catch (e: IOException) {
//why would this ever happen?!?!?1
getSharedPrefs(context).edit().remove(widgetId.toString() + KEY_ACCOUNT).commit()
Loading
Loading
@@ -35,7 +36,8 @@ object ProjectFeedWidgetPrefs {
 
fun setAccount(context: Context, widgetId: Int, account: Account) {
try {
val json = LoganSquare.serialize(account)
val adapter = MoshiProvider.moshi.adapter<Account>(Account::class.java)
val json = adapter.toJson(account)
getSharedPrefs(context)
.edit()
.putString(widgetId.toString() + KEY_ACCOUNT, json)
Loading
Loading
Loading
Loading
@@ -20,7 +20,7 @@ import android.appwidget.AppWidgetManager
import android.content.Context
import android.content.Intent
import android.widget.RemoteViewsService
import com.bluelinelabs.logansquare.LoganSquare
import com.commit451.gitlab.api.MoshiProvider
import com.commit451.gitlab.model.Account
import timber.log.Timber
 
Loading
Loading
@@ -40,7 +40,8 @@ class ProjectFeedWidgetService : RemoteViewsService() {
* :(
*/
fun newIntent(context: Context, widgetId: Int, account: Account, feedUrl: String): Intent {
val accountJson = LoganSquare.serialize(account)
val adapter = MoshiProvider.moshi.adapter<Account>(Account::class.java)
val accountJson = adapter.toJson(account)
val intent = Intent(context, ProjectFeedWidgetService::class.java)
intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, widgetId)
intent.putExtra(EXTRA_ACCOUNT_JSON, accountJson)
Loading
Loading
@@ -52,7 +53,8 @@ class ProjectFeedWidgetService : RemoteViewsService() {
override fun onGetViewFactory(intent: Intent): RemoteViewsService.RemoteViewsFactory {
Timber.d("onGetViewFactory")
val accountJson = intent.getStringExtra(EXTRA_ACCOUNT_JSON)
val account = LoganSquare.parse(accountJson, Account::class.java)
val adapter = MoshiProvider.moshi.adapter<Account>(Account::class.java)
val account = adapter.fromJson(accountJson)!!
val feedUrl = intent.getStringExtra(EXTRA_FEED_URL)
return FeedRemoteViewsFactory(applicationContext, intent, account, feedUrl)
}
Loading
Loading
Loading
Loading
@@ -2,7 +2,7 @@ package com.commit451.gitlab.widget
 
import android.content.Context
import android.content.SharedPreferences
import com.bluelinelabs.logansquare.LoganSquare
import com.commit451.gitlab.api.MoshiProvider
import com.commit451.gitlab.model.Account
import java.io.IOException
 
Loading
Loading
@@ -23,7 +23,8 @@ object UserFeedWidgetPrefs {
val accountsJson = getSharedPrefs(context).getString(widgetId.toString() + KEY_ACCOUNT, null)
if (!accountsJson.isNullOrEmpty()) {
try {
return LoganSquare.parse(accountsJson, Account::class.java)
val adapter = MoshiProvider.moshi.adapter<Account>(Account::class.java)
return adapter.fromJson(accountsJson)
} catch (e: IOException) {
//why would this ever happen?!?!?1
getSharedPrefs(context).edit().remove(widgetId.toString() + KEY_ACCOUNT).commit()
Loading
Loading
@@ -35,7 +36,8 @@ object UserFeedWidgetPrefs {
 
fun setAccount(context: Context, widgetId: Int, account: Account) {
try {
val json = LoganSquare.serialize(account)
val adapter = MoshiProvider.moshi.adapter<Account>(Account::class.java)
val json = adapter.toJson(account)
getSharedPrefs(context)
.edit()
.putString(widgetId.toString() + KEY_ACCOUNT, json)
Loading
Loading
Loading
Loading
@@ -6,9 +6,10 @@ buildscript {
repositories {
jcenter()
maven { url "https://jitpack.io" }
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0-alpha7'
classpath 'com.android.tools.build:gradle:3.0.0-alpha8'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
classpath 'com.github.ben-manes:gradle-versions-plugin:0.15.0'
classpath 'com.github.Commit451:updatewrapper:1.1.2'
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment