Offline mode (#190)

This commit is contained in:
M M Arif
2019-11-13 15:52:49 +00:00
parent 80445952b1
commit b6c0e94ee9
71 changed files with 413 additions and 373 deletions

View File

@@ -35,7 +35,7 @@ public class AdminGetUsersViewModel extends ViewModel {
public static void loadUsersList(final Context ctx, String instanceUrl, String token) {
Call<List<UserInfo>> call = RetrofitClient
.getInstance(instanceUrl)
.getInstance(instanceUrl, ctx)
.getApiInterface()
.adminGetUsers(token);

View File

@@ -1,5 +1,6 @@
package org.mian.gitnex.viewmodels;
import android.content.Context;
import android.util.Log;
import org.mian.gitnex.clients.RetrofitClient;
import org.mian.gitnex.models.Branches;
@@ -20,18 +21,18 @@ public class BranchesViewModel extends ViewModel {
private static MutableLiveData<List<Branches>> branchesList;
public LiveData<List<Branches>> getBranchesList(String instanceUrl, String token, String owner, String repo) {
public LiveData<List<Branches>> getBranchesList(String instanceUrl, String token, String owner, String repo, Context ctx) {
branchesList = new MutableLiveData<>();
loadBranchesList(instanceUrl, token, owner, repo);
loadBranchesList(instanceUrl, token, owner, repo, ctx);
return branchesList;
}
public static void loadBranchesList(String instanceUrl, String token, String owner, String repo) {
public static void loadBranchesList(String instanceUrl, String token, String owner, String repo, Context ctx) {
Call<List<Branches>> call = RetrofitClient
.getInstance(instanceUrl)
.getInstance(instanceUrl, ctx)
.getApiInterface()
.getBranches(token, owner, repo);

View File

@@ -1,5 +1,6 @@
package org.mian.gitnex.viewmodels;
import android.content.Context;
import android.util.Log;
import org.mian.gitnex.clients.RetrofitClient;
import org.mian.gitnex.models.Collaborators;
@@ -20,18 +21,18 @@ public class CollaboratorsViewModel extends ViewModel {
private static MutableLiveData<List<Collaborators>> collaboratorsList;
public LiveData<List<Collaborators>> getCollaboratorsList(String instanceUrl, String token, String owner, String repo) {
public LiveData<List<Collaborators>> getCollaboratorsList(String instanceUrl, String token, String owner, String repo, Context ctx) {
collaboratorsList = new MutableLiveData<>();
loadCollaboratorsListList(instanceUrl, token, owner, repo);
loadCollaboratorsListList(instanceUrl, token, owner, repo, ctx);
return collaboratorsList;
}
private static void loadCollaboratorsListList(String instanceUrl, String token, String owner, String repo) {
private static void loadCollaboratorsListList(String instanceUrl, String token, String owner, String repo, Context ctx) {
Call<List<Collaborators>> call = RetrofitClient
.getInstance(instanceUrl)
.getInstance(instanceUrl, ctx)
.getApiInterface()
.getCollaborators(token, owner, repo);

View File

@@ -37,7 +37,7 @@ public class FilesViewModel extends ViewModel {
private static void loadFilesList(String instanceUrl, String token, String owner, String repo, final Context ctx) {
Call<List<Files>> call = RetrofitClient
.getInstance(instanceUrl)
.getInstance(instanceUrl, ctx)
.getApiInterface()
.getFiles(token, owner, repo);
@@ -81,7 +81,7 @@ public class FilesViewModel extends ViewModel {
private static void loadFilesList2(String instanceUrl, String token, String owner, String repo, String filesDir, final Context ctx) {
Call<List<Files>> call = RetrofitClient
.getInstance(instanceUrl)
.getInstance(instanceUrl, ctx)
.getApiInterface()
.getDirFiles(token, owner, repo, filesDir);

View File

@@ -1,5 +1,6 @@
package org.mian.gitnex.viewmodels;
import android.content.Context;
import android.util.Log;
import org.mian.gitnex.clients.RetrofitClient;
import org.mian.gitnex.models.IssueComments;
@@ -20,18 +21,18 @@ public class IssueCommentsViewModel extends ViewModel {
private static MutableLiveData<List<IssueComments>> issueComments;
public LiveData<List<IssueComments>> getIssueCommentList(String instanceUrl, String token, String owner, String repo, int index) {
public LiveData<List<IssueComments>> getIssueCommentList(String instanceUrl, String token, String owner, String repo, int index, Context ctx) {
issueComments = new MutableLiveData<>();
loadIssueComments(instanceUrl, token, owner, repo, index);
loadIssueComments(instanceUrl, token, owner, repo, index, ctx);
return issueComments;
}
public static void loadIssueComments(String instanceUrl, String token, String owner, String repo, int index) {
public static void loadIssueComments(String instanceUrl, String token, String owner, String repo, int index, Context ctx) {
Call<List<IssueComments>> call = RetrofitClient
.getInstance(instanceUrl)
.getInstance(instanceUrl, ctx)
.getApiInterface()
.getIssueComments(token, owner, repo, index);

View File

@@ -1,5 +1,6 @@
package org.mian.gitnex.viewmodels;
import android.content.Context;
import android.util.Log;
import org.mian.gitnex.clients.RetrofitClient;
import org.mian.gitnex.models.Labels;
@@ -20,18 +21,18 @@ public class LabelsViewModel extends ViewModel {
private static MutableLiveData<List<Labels>> labelsList;
public LiveData<List<Labels>> getLabelsList(String instanceUrl, String token, String owner, String repo) {
public LiveData<List<Labels>> getLabelsList(String instanceUrl, String token, String owner, String repo, Context ctx) {
labelsList = new MutableLiveData<>();
loadLabelsList(instanceUrl, token, owner, repo);
loadLabelsList(instanceUrl, token, owner, repo, ctx);
return labelsList;
}
public static void loadLabelsList(String instanceUrl, String token, String owner, String repo) {
public static void loadLabelsList(String instanceUrl, String token, String owner, String repo, Context ctx) {
Call<List<Labels>> call = RetrofitClient
.getInstance(instanceUrl)
.getInstance(instanceUrl, ctx)
.getApiInterface()
.getlabels(token, owner, repo);

View File

@@ -1,5 +1,6 @@
package org.mian.gitnex.viewmodels;
import android.content.Context;
import android.util.Log;
import org.mian.gitnex.clients.RetrofitClient;
import org.mian.gitnex.models.UserInfo;
@@ -20,18 +21,18 @@ public class MembersByOrgViewModel extends ViewModel {
private static MutableLiveData<List<UserInfo>> membersList;
public LiveData<List<UserInfo>> getMembersList(String instanceUrl, String token, String owner) {
public LiveData<List<UserInfo>> getMembersList(String instanceUrl, String token, String owner, Context ctx) {
membersList = new MutableLiveData<>();
loadMembersList(instanceUrl, token, owner);
loadMembersList(instanceUrl, token, owner, ctx);
return membersList;
}
private static void loadMembersList(String instanceUrl, String token, String owner) {
private static void loadMembersList(String instanceUrl, String token, String owner, Context ctx) {
Call<List<UserInfo>> call = RetrofitClient
.getInstance(instanceUrl)
.getInstance(instanceUrl, ctx)
.getApiInterface()
.getMembersByOrg(token, owner);

View File

@@ -1,5 +1,6 @@
package org.mian.gitnex.viewmodels;
import android.content.Context;
import android.util.Log;
import org.mian.gitnex.clients.RetrofitClient;
import org.mian.gitnex.models.Milestones;
@@ -20,18 +21,18 @@ public class MilestonesViewModel extends ViewModel {
private static MutableLiveData<List<Milestones>> milestonesList;
public LiveData<List<Milestones>> getMilestonesList(String instanceUrl, String token, String owner, String repo, String msState) {
public LiveData<List<Milestones>> getMilestonesList(String instanceUrl, String token, String owner, String repo, String msState, Context ctx) {
milestonesList = new MutableLiveData<>();
loadMilestonesList(instanceUrl, token, owner, repo, msState);
loadMilestonesList(instanceUrl, token, owner, repo, msState, ctx);
return milestonesList;
}
public static void loadMilestonesList(String instanceUrl, String token, String owner, String repo, String msState) {
public static void loadMilestonesList(String instanceUrl, String token, String owner, String repo, String msState, Context ctx) {
Call<List<Milestones>> call = RetrofitClient
.getInstance(instanceUrl)
.getInstance(instanceUrl, ctx)
.getApiInterface()
.getMilestones(token, owner, repo, msState);

View File

@@ -1,5 +1,6 @@
package org.mian.gitnex.viewmodels;
import android.content.Context;
import android.util.Log;
import org.mian.gitnex.clients.RetrofitClient;
import org.mian.gitnex.models.UserRepositories;
@@ -20,20 +21,20 @@ public class MyRepositoriesViewModel extends ViewModel {
private static MutableLiveData<List<UserRepositories>> myReposList;
public LiveData<List<UserRepositories>> getCurrentUserRepositories(String instanceUrl, String token, String username) {
public LiveData<List<UserRepositories>> getCurrentUserRepositories(String instanceUrl, String token, String username, Context ctx) {
//if (myReposList == null) {
myReposList = new MutableLiveData<>();
loadMyReposList(instanceUrl, token, username);
loadMyReposList(instanceUrl, token, username, ctx);
//}
return myReposList;
}
public static void loadMyReposList(String instanceUrl, String token, String username) {
public static void loadMyReposList(String instanceUrl, String token, String username, Context ctx) {
Call<List<UserRepositories>> call = RetrofitClient
.getInstance(instanceUrl)
.getInstance(instanceUrl, ctx)
.getApiInterface()
.getCurrentUserRepositories(token, username);

View File

@@ -1,5 +1,6 @@
package org.mian.gitnex.viewmodels;
import android.content.Context;
import android.util.Log;
import org.mian.gitnex.clients.RetrofitClient;
import org.mian.gitnex.models.UserOrganizations;
@@ -20,20 +21,20 @@ public class OrganizationListViewModel extends ViewModel {
private static MutableLiveData<List<UserOrganizations>> orgsList;
public LiveData<List<UserOrganizations>> getUserOrgs(String instanceUrl, String token) {
public LiveData<List<UserOrganizations>> getUserOrgs(String instanceUrl, String token, Context ctx) {
//if (orgsList == null) {
orgsList = new MutableLiveData<>();
loadOrgsList(instanceUrl, token);
loadOrgsList(instanceUrl, token, ctx);
//}
return orgsList;
}
public static void loadOrgsList(String instanceUrl, String token) {
public static void loadOrgsList(String instanceUrl, String token, Context ctx) {
Call<List<UserOrganizations>> call = RetrofitClient
.getInstance(instanceUrl)
.getInstance(instanceUrl, ctx)
.getApiInterface()
.getUserOrgs(token);

View File

@@ -1,5 +1,6 @@
package org.mian.gitnex.viewmodels;
import android.content.Context;
import android.util.Log;
import org.mian.gitnex.clients.RetrofitClient;
import org.mian.gitnex.models.Emails;
@@ -20,18 +21,18 @@ public class ProfileEmailsViewModel extends ViewModel {
private static MutableLiveData<List<Emails>> emailsList;
public LiveData<List<Emails>> getEmailsList(String instanceUrl, String token) {
public LiveData<List<Emails>> getEmailsList(String instanceUrl, String token, Context ctx) {
emailsList = new MutableLiveData<>();
loadEmailsList(instanceUrl, token);
loadEmailsList(instanceUrl, token, ctx);
return emailsList;
}
public static void loadEmailsList(String instanceUrl, String token) {
public static void loadEmailsList(String instanceUrl, String token, Context ctx) {
Call<List<Emails>> call = RetrofitClient
.getInstance(instanceUrl)
.getInstance(instanceUrl, ctx)
.getApiInterface()
.getUserEmails(token);

View File

@@ -1,5 +1,6 @@
package org.mian.gitnex.viewmodels;
import android.content.Context;
import android.util.Log;
import org.mian.gitnex.clients.RetrofitClient;
import org.mian.gitnex.models.UserInfo;
@@ -20,18 +21,18 @@ public class ProfileFollowersViewModel extends ViewModel {
private static MutableLiveData<List<UserInfo>> followersList;
public LiveData<List<UserInfo>> getFollowersList(String instanceUrl, String token) {
public LiveData<List<UserInfo>> getFollowersList(String instanceUrl, String token, Context ctx) {
followersList = new MutableLiveData<>();
loadFollowersList(instanceUrl, token);
loadFollowersList(instanceUrl, token, ctx);
return followersList;
}
public static void loadFollowersList(String instanceUrl, String token) {
public static void loadFollowersList(String instanceUrl, String token, Context ctx) {
Call<List<UserInfo>> call = RetrofitClient
.getInstance(instanceUrl)
.getInstance(instanceUrl, ctx)
.getApiInterface()
.getFollowers(token);

View File

@@ -1,5 +1,6 @@
package org.mian.gitnex.viewmodels;
import android.content.Context;
import android.util.Log;
import org.mian.gitnex.clients.RetrofitClient;
import org.mian.gitnex.models.UserInfo;
@@ -20,18 +21,18 @@ public class ProfileFollowingViewModel extends ViewModel {
private static MutableLiveData<List<UserInfo>> followingList;
public LiveData<List<UserInfo>> getFollowingList(String instanceUrl, String token) {
public LiveData<List<UserInfo>> getFollowingList(String instanceUrl, String token, Context ctx) {
followingList = new MutableLiveData<>();
loadFollowingList(instanceUrl, token);
loadFollowingList(instanceUrl, token, ctx);
return followingList;
}
public static void loadFollowingList(String instanceUrl, String token) {
public static void loadFollowingList(String instanceUrl, String token, Context ctx) {
Call<List<UserInfo>> call = RetrofitClient
.getInstance(instanceUrl)
.getInstance(instanceUrl, ctx)
.getApiInterface()
.getFollowing(token);

View File

@@ -1,5 +1,6 @@
package org.mian.gitnex.viewmodels;
import android.content.Context;
import android.util.Log;
import org.mian.gitnex.clients.RetrofitClient;
import org.mian.gitnex.models.Releases;
@@ -20,18 +21,18 @@ public class ReleasesViewModel extends ViewModel {
private static MutableLiveData<List<Releases>> releasesList;
public LiveData<List<Releases>> getReleasesList(String instanceUrl, String token, String owner, String repo) {
public LiveData<List<Releases>> getReleasesList(String instanceUrl, String token, String owner, String repo, Context ctx) {
releasesList = new MutableLiveData<>();
loadReleasesList(instanceUrl, token, owner, repo);
loadReleasesList(instanceUrl, token, owner, repo, ctx);
return releasesList;
}
public static void loadReleasesList(String instanceUrl, String token, String owner, String repo) {
public static void loadReleasesList(String instanceUrl, String token, String owner, String repo, Context ctx) {
Call<List<Releases>> call = RetrofitClient
.getInstance(instanceUrl)
.getInstance(instanceUrl, ctx)
.getApiInterface()
.getReleases(token, owner, repo);

View File

@@ -1,5 +1,6 @@
package org.mian.gitnex.viewmodels;
import android.content.Context;
import android.util.Log;
import androidx.annotation.NonNull;
import androidx.lifecycle.LiveData;
@@ -20,18 +21,18 @@ public class RepoStargazersViewModel extends ViewModel {
private static MutableLiveData<List<UserInfo>> stargazersList;
public LiveData<List<UserInfo>> getRepoStargazers(String instanceUrl, String token, String repoOwner, String repoName) {
public LiveData<List<UserInfo>> getRepoStargazers(String instanceUrl, String token, String repoOwner, String repoName, Context ctx) {
stargazersList = new MutableLiveData<>();
loadRepoStargazers(instanceUrl, token, repoOwner, repoName);
loadRepoStargazers(instanceUrl, token, repoOwner, repoName, ctx);
return stargazersList;
}
public static void loadRepoStargazers(String instanceUrl, String token, String repoOwner, String repoName) {
private static void loadRepoStargazers(String instanceUrl, String token, String repoOwner, String repoName, Context ctx) {
Call<List<UserInfo>> call = RetrofitClient
.getInstance(instanceUrl)
.getInstance(instanceUrl, ctx)
.getApiInterface()
.getRepoStargazers(token, repoOwner, repoName);

View File

@@ -1,5 +1,6 @@
package org.mian.gitnex.viewmodels;
import android.content.Context;
import android.util.Log;
import androidx.annotation.NonNull;
import androidx.lifecycle.LiveData;
@@ -20,18 +21,18 @@ public class RepoWatchersViewModel extends ViewModel {
private static MutableLiveData<List<UserInfo>> watchersList;
public LiveData<List<UserInfo>> getRepoWatchers(String instanceUrl, String token, String repoOwner, String repoName) {
public LiveData<List<UserInfo>> getRepoWatchers(String instanceUrl, String token, String repoOwner, String repoName, Context ctx) {
watchersList = new MutableLiveData<>();
loadRepoWatchers(instanceUrl, token, repoOwner, repoName);
loadRepoWatchers(instanceUrl, token, repoOwner, repoName, ctx);
return watchersList;
}
public static void loadRepoWatchers(String instanceUrl, String token, String repoOwner, String repoName) {
private static void loadRepoWatchers(String instanceUrl, String token, String repoOwner, String repoName, Context ctx) {
Call<List<UserInfo>> call = RetrofitClient
.getInstance(instanceUrl)
.getInstance(instanceUrl, ctx)
.getApiInterface()
.getRepoWatchers(token, repoOwner, repoName);

View File

@@ -1,5 +1,6 @@
package org.mian.gitnex.viewmodels;
import android.content.Context;
import android.util.Log;
import org.mian.gitnex.clients.RetrofitClient;
import org.mian.gitnex.models.UserRepositories;
@@ -20,18 +21,18 @@ public class RepositoriesByOrgViewModel extends ViewModel {
private static MutableLiveData<List<UserRepositories>> orgReposList;
public LiveData<List<UserRepositories>> getRepositoriesByOrg(String instanceUrl, String token, String orgName) {
public LiveData<List<UserRepositories>> getRepositoriesByOrg(String instanceUrl, String token, String orgName, Context ctx) {
orgReposList = new MutableLiveData<>();
loadOrgRepos(instanceUrl, token, orgName);
loadOrgRepos(instanceUrl, token, orgName, ctx);
return orgReposList;
}
public static void loadOrgRepos(String instanceUrl, String token, String orgName) {
public static void loadOrgRepos(String instanceUrl, String token, String orgName, Context ctx) {
Call<List<UserRepositories>> call = RetrofitClient
.getInstance(instanceUrl)
.getInstance(instanceUrl, ctx)
.getApiInterface()
.getReposByOrg(token, orgName);

View File

@@ -1,5 +1,6 @@
package org.mian.gitnex.viewmodels;
import android.content.Context;
import android.util.Log;
import org.mian.gitnex.clients.RetrofitClient;
import org.mian.gitnex.models.UserRepositories;
@@ -20,20 +21,20 @@ public class RepositoriesListViewModel extends ViewModel {
private static MutableLiveData<List<UserRepositories>> reposList;
public LiveData<List<UserRepositories>> getUserRepositories(String instanceUrl, String token) {
public LiveData<List<UserRepositories>> getUserRepositories(String instanceUrl, String token, Context ctx) {
//if (reposList == null) {
reposList = new MutableLiveData<>();
loadReposList(instanceUrl, token);
loadReposList(instanceUrl, token, ctx);
//}
return reposList;
}
public static void loadReposList(String instanceUrl, String token) {
public static void loadReposList(String instanceUrl, String token, Context ctx) {
Call<List<UserRepositories>> call = RetrofitClient
.getInstance(instanceUrl)
.getInstance(instanceUrl, ctx)
.getApiInterface()
.getUserRepositories(token);

View File

@@ -1,5 +1,6 @@
package org.mian.gitnex.viewmodels;
import android.content.Context;
import android.util.Log;
import org.mian.gitnex.clients.RetrofitClient;
import org.mian.gitnex.models.UserRepositories;
@@ -20,18 +21,18 @@ public class StarredRepositoriesViewModel extends ViewModel {
private static MutableLiveData<List<UserRepositories>> reposList;
public LiveData<List<UserRepositories>> getUserStarredRepositories(String instanceUrl, String token) {
public LiveData<List<UserRepositories>> getUserStarredRepositories(String instanceUrl, String token, Context ctx) {
reposList = new MutableLiveData<>();
loadStarredReposList(instanceUrl, token);
loadStarredReposList(instanceUrl, token, ctx);
return reposList;
}
public static void loadStarredReposList(String instanceUrl, String token) {
public static void loadStarredReposList(String instanceUrl, String token, Context ctx) {
Call<List<UserRepositories>> call = RetrofitClient
.getInstance(instanceUrl)
.getInstance(instanceUrl, ctx)
.getApiInterface()
.getUserStarredRepos(token);

View File

@@ -1,5 +1,6 @@
package org.mian.gitnex.viewmodels;
import android.content.Context;
import android.util.Log;
import org.mian.gitnex.clients.RetrofitClient;
import org.mian.gitnex.models.UserInfo;
@@ -20,18 +21,18 @@ public class TeamMembersByOrgViewModel extends ViewModel {
private static MutableLiveData<List<UserInfo>> teamMembersList;
public LiveData<List<UserInfo>> getMembersByOrgList(String instanceUrl, String token, int teamId) {
public LiveData<List<UserInfo>> getMembersByOrgList(String instanceUrl, String token, int teamId, Context ctx) {
teamMembersList = new MutableLiveData<>();
loadMembersByOrgList(instanceUrl, token, teamId);
loadMembersByOrgList(instanceUrl, token, teamId, ctx);
return teamMembersList;
}
private static void loadMembersByOrgList(String instanceUrl, String token, int teamId) {
private static void loadMembersByOrgList(String instanceUrl, String token, int teamId, Context ctx) {
Call<List<UserInfo>> call = RetrofitClient
.getInstance(instanceUrl)
.getInstance(instanceUrl, ctx)
.getApiInterface()
.getTeamMembersByOrg(token, teamId);

View File

@@ -1,5 +1,6 @@
package org.mian.gitnex.viewmodels;
import android.content.Context;
import android.util.Log;
import org.mian.gitnex.clients.RetrofitClient;
import org.mian.gitnex.models.Teams;
@@ -20,18 +21,18 @@ public class TeamsByOrgViewModel extends ViewModel {
private static MutableLiveData<List<Teams>> teamsList;
public LiveData<List<Teams>> getTeamsByOrg(String instanceUrl, String token, String orgName) {
public LiveData<List<Teams>> getTeamsByOrg(String instanceUrl, String token, String orgName, Context ctx) {
teamsList = new MutableLiveData<>();
loadTeamsByOrgList(instanceUrl, token, orgName);
loadTeamsByOrgList(instanceUrl, token, orgName, ctx);
return teamsList;
}
public static void loadTeamsByOrgList(String instanceUrl, String token, String orgName) {
public static void loadTeamsByOrgList(String instanceUrl, String token, String orgName, Context ctx) {
Call<List<Teams>> call = RetrofitClient
.getInstance(instanceUrl)
.getInstance(instanceUrl, ctx)
.getApiInterface()
.getTeamsByOrg(token, orgName);