mirror of
https://codeberg.org/gitnex/GitNex.git
synced 2024-12-26 16:04:07 +08:00
Offline mode (#190)
This commit is contained in:
parent
80445952b1
commit
b6c0e94ee9
@ -35,7 +35,7 @@ public class CollaboratorActions {
|
||||
Call<Collaborators> call;
|
||||
|
||||
call = RetrofitClient
|
||||
.getInstance(instanceUrl)
|
||||
.getInstance(instanceUrl, context)
|
||||
.getApiInterface()
|
||||
.deleteCollaborator(Authorization.returnAuthentication(context, loginUid, instanceToken), repoOwner, repoName, userName);
|
||||
|
||||
@ -105,7 +105,7 @@ public class CollaboratorActions {
|
||||
Call<Permission> call;
|
||||
|
||||
call = RetrofitClient
|
||||
.getInstance(instanceUrl)
|
||||
.getInstance(instanceUrl, context)
|
||||
.getApiInterface()
|
||||
.addCollaborator(Authorization.returnAuthentication(context, loginUid, instanceToken), repoOwner, repoName, userName, permissionString);
|
||||
|
||||
|
@ -37,7 +37,7 @@ public class IssueActions {
|
||||
Call<IssueComments> call;
|
||||
|
||||
call = RetrofitClient
|
||||
.getInstance(instanceUrl)
|
||||
.getInstance(instanceUrl, context)
|
||||
.getApiInterface()
|
||||
.patchIssueComment(Authorization.returnAuthentication(context, loginUid, instanceToken), repoOwner, repoName, commentId, commentBodyJson);
|
||||
|
||||
@ -104,7 +104,7 @@ public class IssueActions {
|
||||
Call<JsonElement> call;
|
||||
|
||||
call = RetrofitClient
|
||||
.getInstance(instanceUrl)
|
||||
.getInstance(instanceUrl, context)
|
||||
.getApiInterface()
|
||||
.closeReopenIssue(Authorization.returnAuthentication(context, loginUid, instanceToken), repoOwner, repoName, issueIndex, issueStatJson);
|
||||
|
||||
|
@ -33,7 +33,7 @@ public class RepositoryActions {
|
||||
Call<JsonElement> call;
|
||||
|
||||
call = RetrofitClient
|
||||
.getInstance(instanceUrl)
|
||||
.getInstance(instanceUrl, context)
|
||||
.getApiInterface()
|
||||
.starRepository(Authorization.returnAuthentication(context, loginUid, instanceToken), repoOwner, repoName);
|
||||
|
||||
@ -98,7 +98,7 @@ public class RepositoryActions {
|
||||
Call<JsonElement> call;
|
||||
|
||||
call = RetrofitClient
|
||||
.getInstance(instanceUrl)
|
||||
.getInstance(instanceUrl, context)
|
||||
.getApiInterface()
|
||||
.unStarRepository(Authorization.returnAuthentication(context, loginUid, instanceToken), repoOwner, repoName);
|
||||
|
||||
@ -163,7 +163,7 @@ public class RepositoryActions {
|
||||
Call<JsonElement> call;
|
||||
|
||||
call = RetrofitClient
|
||||
.getInstance(instanceUrl)
|
||||
.getInstance(instanceUrl, context)
|
||||
.getApiInterface()
|
||||
.watchRepository(Authorization.returnAuthentication(context, loginUid, instanceToken), repoOwner, repoName);
|
||||
|
||||
@ -228,7 +228,7 @@ public class RepositoryActions {
|
||||
Call<JsonElement> call;
|
||||
|
||||
call = RetrofitClient
|
||||
.getInstance(instanceUrl)
|
||||
.getInstance(instanceUrl, context)
|
||||
.getApiInterface()
|
||||
.unWatchRepository(Authorization.returnAuthentication(context, loginUid, instanceToken), repoOwner, repoName);
|
||||
|
||||
|
@ -23,9 +23,9 @@ import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.helpers.Authorization;
|
||||
import org.mian.gitnex.models.UserSearch;
|
||||
import org.mian.gitnex.models.UserInfo;
|
||||
import org.mian.gitnex.util.AppUtil;
|
||||
import org.mian.gitnex.util.TinyDB;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
@ -46,8 +46,6 @@ public class AddCollaboratorToRepositoryActivity extends AppCompatActivity {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_add_collaborator_to_repository);
|
||||
|
||||
boolean connToInternet = AppUtil.haveNetworkConnection(getApplicationContext());
|
||||
|
||||
TinyDB tinyDb = new TinyDB(getApplicationContext());
|
||||
final String instanceUrl = tinyDb.getString("instanceUrl");
|
||||
final String loginUid = tinyDb.getString("loginUid");
|
||||
@ -81,7 +79,7 @@ public class AddCollaboratorToRepositoryActivity extends AppCompatActivity {
|
||||
public void loadUserSearchList(String instanceUrl, String token, String searchKeyword, final Context context, String loginUid) {
|
||||
|
||||
Call<UserSearch> call = RetrofitClient
|
||||
.getInstance(instanceUrl)
|
||||
.getInstance(instanceUrl, getApplicationContext())
|
||||
.getApiInterface()
|
||||
.getUserBySearch(Authorization.returnAuthentication(getApplicationContext(), loginUid, token), searchKeyword, 10);
|
||||
|
||||
@ -101,7 +99,7 @@ public class AddCollaboratorToRepositoryActivity extends AppCompatActivity {
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<UserSearch> call, @NonNull Throwable t) {
|
||||
Log.i("onFailure", t.getMessage());
|
||||
Log.i("onFailure", t.toString());
|
||||
}
|
||||
|
||||
});
|
||||
|
@ -65,7 +65,7 @@ public class AddRemoveAssigneesActivity extends AppCompatActivity {
|
||||
final TinyDB tinyDb = new TinyDB(getApplicationContext());
|
||||
|
||||
Call<List<Collaborators>> call = RetrofitClient
|
||||
.getInstance(instanceUrl)
|
||||
.getInstance(instanceUrl, getApplicationContext())
|
||||
.getApiInterface()
|
||||
.getCollaborators(Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName);
|
||||
|
||||
@ -90,7 +90,7 @@ public class AddRemoveAssigneesActivity extends AppCompatActivity {
|
||||
|
||||
// get current issue assignees
|
||||
Call<Issues> callSingleIssueAssignees = RetrofitClient
|
||||
.getInstance(instanceUrl)
|
||||
.getInstance(instanceUrl, getApplicationContext())
|
||||
.getApiInterface()
|
||||
.getIssueByIndex(Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName, issueIndex);
|
||||
|
||||
@ -239,7 +239,7 @@ public class AddRemoveAssigneesActivity extends AppCompatActivity {
|
||||
Call<JsonElement> call3;
|
||||
|
||||
call3 = RetrofitClient
|
||||
.getInstance(instanceUrl)
|
||||
.getInstance(instanceUrl, getApplicationContext())
|
||||
.getApiInterface()
|
||||
.patchIssueAssignee(Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName, issueIndex, updateAssigneeJson);
|
||||
|
||||
|
@ -62,7 +62,7 @@ public class AddRemoveLabelsActivity extends AppCompatActivity {
|
||||
final TinyDB tinyDb = new TinyDB(getApplicationContext());
|
||||
|
||||
Call<List<Labels>> call = RetrofitClient
|
||||
.getInstance(instanceUrl)
|
||||
.getInstance(instanceUrl, getApplicationContext())
|
||||
.getApiInterface()
|
||||
.getlabels(Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName);
|
||||
|
||||
@ -87,7 +87,7 @@ public class AddRemoveLabelsActivity extends AppCompatActivity {
|
||||
|
||||
// get current issue labels
|
||||
Call<List<Labels>> callSingleIssueLabels = RetrofitClient
|
||||
.getInstance(instanceUrl)
|
||||
.getInstance(instanceUrl, getApplicationContext())
|
||||
.getApiInterface()
|
||||
.getIssueLabels(Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName, issueIndex);
|
||||
|
||||
@ -249,7 +249,7 @@ public class AddRemoveLabelsActivity extends AppCompatActivity {
|
||||
Labels patchIssueLabels = new Labels(issueLabels);
|
||||
|
||||
Call<JsonElement> call = RetrofitClient
|
||||
.getInstance(instanceUrl)
|
||||
.getInstance(instanceUrl, getApplicationContext())
|
||||
.getApiInterface()
|
||||
.updateIssueLabels(Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName, issueIndex, patchIssueLabels);
|
||||
|
||||
|
@ -40,6 +40,7 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
@ -217,7 +218,7 @@ public class CreateIssueActivity extends AppCompatActivity implements View.OnCli
|
||||
final String repoName = parts[1];
|
||||
|
||||
Call<List<Collaborators>> call = RetrofitClient
|
||||
.getInstance(instanceUrl)
|
||||
.getInstance(instanceUrl, getApplicationContext())
|
||||
.getApiInterface()
|
||||
.getCollaborators(Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName);
|
||||
|
||||
@ -248,7 +249,7 @@ public class CreateIssueActivity extends AppCompatActivity implements View.OnCli
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<Collaborators>> call, @NonNull Throwable t) {
|
||||
Log.i("onFailure", t.getMessage());
|
||||
Log.i("onFailure", t.toString());
|
||||
}
|
||||
|
||||
});
|
||||
@ -261,7 +262,7 @@ public class CreateIssueActivity extends AppCompatActivity implements View.OnCli
|
||||
Call<JsonElement> call3;
|
||||
|
||||
call3 = RetrofitClient
|
||||
.getInstance(instanceUrl)
|
||||
.getInstance(instanceUrl, getApplicationContext())
|
||||
.getApiInterface()
|
||||
.createNewIssue(Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName, createNewIssueJson);
|
||||
|
||||
@ -325,7 +326,7 @@ public class CreateIssueActivity extends AppCompatActivity implements View.OnCli
|
||||
|
||||
String msState = "open";
|
||||
Call<List<Milestones>> call = RetrofitClient
|
||||
.getInstance(instanceUrl)
|
||||
.getInstance(instanceUrl, getApplicationContext())
|
||||
.getApiInterface()
|
||||
.getMilestones(Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName, msState);
|
||||
|
||||
@ -379,7 +380,7 @@ public class CreateIssueActivity extends AppCompatActivity implements View.OnCli
|
||||
private void getCollaborators(String instanceUrl, String instanceToken, String repoOwner, String repoName, String loginUid) {
|
||||
|
||||
Call<List<Collaborators>> call = RetrofitClient
|
||||
.getInstance(instanceUrl)
|
||||
.getInstance(instanceUrl, getApplicationContext())
|
||||
.getApiInterface()
|
||||
.getCollaborators(Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName);
|
||||
|
||||
@ -449,7 +450,7 @@ public class CreateIssueActivity extends AppCompatActivity implements View.OnCli
|
||||
private void getLabels(String instanceUrl, String instanceToken, String repoOwner, String repoName, String loginUid) {
|
||||
|
||||
Call<List<Labels>> call = RetrofitClient
|
||||
.getInstance(instanceUrl)
|
||||
.getInstance(instanceUrl, getApplicationContext())
|
||||
.getApiInterface()
|
||||
.getlabels(Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName);
|
||||
|
||||
|
@ -28,6 +28,7 @@ import org.mian.gitnex.models.Labels;
|
||||
import org.mian.gitnex.util.AppUtil;
|
||||
import org.mian.gitnex.util.TinyDB;
|
||||
import org.mian.gitnex.viewmodels.LabelsViewModel;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
@ -55,9 +56,9 @@ public class CreateLabelActivity extends AppCompatActivity {
|
||||
final String loginUid = tinyDb.getString("loginUid");
|
||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||
|
||||
if(getIntent().getStringExtra("labelAction") != null && getIntent().getStringExtra("labelAction").equals("delete")) {
|
||||
if(getIntent().getStringExtra("labelAction") != null && Objects.requireNonNull(getIntent().getStringExtra("labelAction")).equals("delete")) {
|
||||
|
||||
deleteLabel(instanceUrl, instanceToken, repoOwner, repoName, Integer.valueOf(getIntent().getStringExtra("labelId")), loginUid);
|
||||
deleteLabel(instanceUrl, instanceToken, repoOwner, repoName, Integer.valueOf(Objects.requireNonNull(getIntent().getStringExtra("labelId"))), loginUid);
|
||||
finish();
|
||||
return;
|
||||
|
||||
@ -92,7 +93,7 @@ public class CreateLabelActivity extends AppCompatActivity {
|
||||
}
|
||||
});
|
||||
|
||||
if(getIntent().getStringExtra("labelAction") != null && getIntent().getStringExtra("labelAction").equals("edit")) {
|
||||
if(getIntent().getStringExtra("labelAction") != null && Objects.requireNonNull(getIntent().getStringExtra("labelAction")).equals("edit")) {
|
||||
|
||||
labelName.setText(getIntent().getStringExtra("labelTitle"));
|
||||
int labelColor_ = Color.parseColor("#" + getIntent().getStringExtra("labelColor"));
|
||||
@ -242,7 +243,7 @@ public class CreateLabelActivity extends AppCompatActivity {
|
||||
Call<CreateLabel> call;
|
||||
|
||||
call = RetrofitClient
|
||||
.getInstance(instanceUrl)
|
||||
.getInstance(instanceUrl, getApplicationContext())
|
||||
.getApiInterface()
|
||||
.createLabel(Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName, createLabelFunc);
|
||||
|
||||
@ -296,7 +297,7 @@ public class CreateLabelActivity extends AppCompatActivity {
|
||||
Call<CreateLabel> call;
|
||||
|
||||
call = RetrofitClient
|
||||
.getInstance(instanceUrl)
|
||||
.getInstance(instanceUrl, getApplicationContext())
|
||||
.getApiInterface()
|
||||
.patchLabel(Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName, labelId, createLabelFunc);
|
||||
|
||||
@ -369,7 +370,7 @@ public class CreateLabelActivity extends AppCompatActivity {
|
||||
Call<Labels> call;
|
||||
|
||||
call = RetrofitClient
|
||||
.getInstance(instanceUrl)
|
||||
.getInstance(instanceUrl, getApplicationContext())
|
||||
.getApiInterface()
|
||||
.deleteLabel(Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName, labelId);
|
||||
|
||||
@ -382,7 +383,7 @@ public class CreateLabelActivity extends AppCompatActivity {
|
||||
if(response.code() == 204) {
|
||||
|
||||
Toasty.info(getApplicationContext(), getString(R.string.labelDeleteText));
|
||||
LabelsViewModel.loadLabelsList(instanceUrl, instanceToken, repoOwner, repoName);
|
||||
LabelsViewModel.loadLabelsList(instanceUrl, instanceToken, repoOwner, repoName, getApplicationContext());
|
||||
getIntent().removeExtra("labelAction");
|
||||
getIntent().removeExtra("labelId");
|
||||
|
||||
|
@ -127,7 +127,7 @@ public class CreateNewUserActivity extends AppCompatActivity {
|
||||
Call<UserInfo> call;
|
||||
|
||||
call = RetrofitClient
|
||||
.getInstance(instanceUrl)
|
||||
.getInstance(instanceUrl, getApplicationContext())
|
||||
.getApiInterface()
|
||||
.createNewUser(instanceToken, createUser);
|
||||
|
||||
|
@ -164,7 +164,7 @@ public class CreateReleaseActivity extends AppCompatActivity {
|
||||
Call<Releases> call;
|
||||
|
||||
call = RetrofitClient
|
||||
.getInstance(instanceUrl)
|
||||
.getInstance(instanceUrl, getApplicationContext())
|
||||
.getApiInterface()
|
||||
.createNewRelease(token, repoOwner, repoName, createReleaseJson);
|
||||
|
||||
@ -224,7 +224,7 @@ public class CreateReleaseActivity extends AppCompatActivity {
|
||||
private void getBranches(String instanceUrl, String instanceToken, final String repoOwner, final String repoName) {
|
||||
|
||||
Call<List<Branches>> call = RetrofitClient
|
||||
.getInstance(instanceUrl)
|
||||
.getInstance(instanceUrl, getApplicationContext())
|
||||
.getApiInterface()
|
||||
.getBranches(instanceToken, repoOwner, repoName);
|
||||
|
||||
|
@ -308,7 +308,7 @@ public class CreateTeamByOrgActivity extends AppCompatActivity implements View.O
|
||||
Call<Teams> call3;
|
||||
|
||||
call3 = RetrofitClient
|
||||
.getInstance(instanceUrl)
|
||||
.getInstance(instanceUrl, getApplicationContext())
|
||||
.getApiInterface()
|
||||
.createTeamsByOrg(Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), orgName, createNewTeamJson);
|
||||
|
||||
|
@ -122,7 +122,7 @@ public class EditIssueActivity extends AppCompatActivity implements View.OnClick
|
||||
final String repoName = parts[1];
|
||||
|
||||
Call<List<Collaborators>> call = RetrofitClient
|
||||
.getInstance(instanceUrl)
|
||||
.getInstance(instanceUrl, getApplicationContext())
|
||||
.getApiInterface()
|
||||
.getCollaborators(Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName);
|
||||
|
||||
@ -153,7 +153,7 @@ public class EditIssueActivity extends AppCompatActivity implements View.OnClick
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<Collaborators>> call, @NonNull Throwable t) {
|
||||
Log.i("onFailure", t.getMessage());
|
||||
Log.i("onFailure", t.toString());
|
||||
}
|
||||
|
||||
});
|
||||
@ -229,7 +229,7 @@ public class EditIssueActivity extends AppCompatActivity implements View.OnClick
|
||||
CreateIssue issueData = new CreateIssue(title, description, dueDate, editIssueMilestoneId);
|
||||
|
||||
Call<JsonElement> call = RetrofitClient
|
||||
.getInstance(instanceUrl)
|
||||
.getInstance(instanceUrl, getApplicationContext())
|
||||
.getApiInterface()
|
||||
.patchIssue(Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName, issueIndex, issueData);
|
||||
|
||||
@ -307,7 +307,7 @@ public class EditIssueActivity extends AppCompatActivity implements View.OnClick
|
||||
private void getIssue(final String instanceUrl, final String instanceToken, final String loginUid, final String repoOwner, final String repoName, int issueIndex) {
|
||||
|
||||
Call<Issues> call = RetrofitClient
|
||||
.getInstance(instanceUrl)
|
||||
.getInstance(instanceUrl, getApplicationContext())
|
||||
.getApiInterface()
|
||||
.getIssueByIndex(Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName, issueIndex);
|
||||
|
||||
@ -331,7 +331,7 @@ public class EditIssueActivity extends AppCompatActivity implements View.OnClick
|
||||
if(response.body().getId() > 0) {
|
||||
|
||||
Call<List<Milestones>> call_ = RetrofitClient
|
||||
.getInstance(instanceUrl)
|
||||
.getInstance(instanceUrl, getApplicationContext())
|
||||
.getApiInterface()
|
||||
.getMilestones(Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName, msState);
|
||||
|
||||
|
@ -60,8 +60,6 @@ public class FileViewActivity extends AppCompatActivity {
|
||||
final String loginUid = tinyDb.getString("loginUid");
|
||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||
|
||||
boolean connToInternet = AppUtil.haveNetworkConnection(getApplicationContext());
|
||||
|
||||
ImageView closeActivity = findViewById(R.id.close);
|
||||
singleFileContents = findViewById(R.id.singleFileContents);
|
||||
singleCodeContents = findViewById(R.id.singleCodeContents);
|
||||
@ -78,19 +76,14 @@ public class FileViewActivity extends AppCompatActivity {
|
||||
initCloseListener();
|
||||
closeActivity.setOnClickListener(onClickListener);
|
||||
|
||||
if(connToInternet) {
|
||||
getSingleFileContents(instanceUrl, instanceToken, repoOwner, repoName, singleFileName);
|
||||
}
|
||||
else {
|
||||
Toasty.info(getApplicationContext(), getString(R.string.checkNetConnection));
|
||||
}
|
||||
getSingleFileContents(instanceUrl, instanceToken, repoOwner, repoName, singleFileName);
|
||||
|
||||
}
|
||||
|
||||
private void getSingleFileContents(String instanceUrl, String token, final String owner, String repo, final String filename) {
|
||||
|
||||
Call<Files> call = RetrofitClient
|
||||
.getInstance(instanceUrl)
|
||||
.getInstance(instanceUrl, getApplicationContext())
|
||||
.getApiInterface()
|
||||
.getSingleFileContents(token, owner, repo, filename);
|
||||
|
||||
|
@ -152,7 +152,7 @@ public class IssueDetailActivity extends AppCompatActivity {
|
||||
@Override
|
||||
public void run() {
|
||||
swipeRefresh.setRefreshing(false);
|
||||
IssueCommentsViewModel.loadIssueComments(instanceUrl, Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName, issueIndex);
|
||||
IssueCommentsViewModel.loadIssueComments(instanceUrl, Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName, issueIndex, getApplicationContext());
|
||||
}
|
||||
}, 500);
|
||||
}
|
||||
@ -206,7 +206,7 @@ public class IssueDetailActivity extends AppCompatActivity {
|
||||
scrollViewComments.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
IssueCommentsViewModel.loadIssueComments(instanceUrl, Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName, issueIndex);
|
||||
IssueCommentsViewModel.loadIssueComments(instanceUrl, Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName, issueIndex, getApplicationContext());
|
||||
|
||||
new Handler().postDelayed(new Runnable() {
|
||||
@Override
|
||||
@ -224,7 +224,7 @@ public class IssueDetailActivity extends AppCompatActivity {
|
||||
scrollViewComments.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
IssueCommentsViewModel.loadIssueComments(instanceUrl, Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName, issueIndex);
|
||||
IssueCommentsViewModel.loadIssueComments(instanceUrl, Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName, issueIndex, getApplicationContext());
|
||||
tinyDb.putBoolean("commentEdited", false);
|
||||
}
|
||||
});
|
||||
@ -264,7 +264,7 @@ public class IssueDetailActivity extends AppCompatActivity {
|
||||
|
||||
IssueCommentsViewModel issueCommentsModel = ViewModelProviders.of(this).get(IssueCommentsViewModel.class);
|
||||
|
||||
issueCommentsModel.getIssueCommentList(instanceUrl, Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), owner, repo, index).observe(this, new Observer<List<IssueComments>>() {
|
||||
issueCommentsModel.getIssueCommentList(instanceUrl, Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), owner, repo, index, getApplicationContext()).observe(this, new Observer<List<IssueComments>>() {
|
||||
@Override
|
||||
public void onChanged(@Nullable List<IssueComments> issueCommentsMain) {
|
||||
adapter = new IssueCommentsAdapter(getApplicationContext(), issueCommentsMain);
|
||||
@ -278,7 +278,7 @@ public class IssueDetailActivity extends AppCompatActivity {
|
||||
|
||||
final TinyDB tinyDb = new TinyDB(getApplicationContext());
|
||||
Call<Issues> call = RetrofitClient
|
||||
.getInstance(instanceUrl)
|
||||
.getInstance(instanceUrl, getApplicationContext())
|
||||
.getApiInterface()
|
||||
.getIssueByIndex(Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName, issueIndex);
|
||||
|
||||
|
@ -35,10 +35,10 @@ import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
import okhttp3.Credentials;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import android.provider.Settings.Secure;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
@ -144,7 +144,13 @@ public class LoginActivity extends AppCompatActivity implements View.OnClickList
|
||||
|
||||
loginButton.setOnClickListener(loginListener);
|
||||
|
||||
device_id = Integer.toHexString(Secure.getString(ctx.getContentResolver(), Secure.ANDROID_ID).hashCode());
|
||||
if(!tinyDb.getString("uniqueAppId").isEmpty()) {
|
||||
device_id = tinyDb.getString("uniqueAppId");
|
||||
}
|
||||
else {
|
||||
device_id = UUID.randomUUID().toString();
|
||||
tinyDb.putString("uniqueAppId", device_id);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -368,7 +374,7 @@ public class LoginActivity extends AppCompatActivity implements View.OnClickList
|
||||
final TinyDB tinyDb = new TinyDB(getApplicationContext());
|
||||
|
||||
Call<GiteaVersion> callVersion = RetrofitClient
|
||||
.getInstance(instanceUrl)
|
||||
.getInstance(instanceUrl, getApplicationContext())
|
||||
.getApiInterface()
|
||||
.getGiteaVersion();
|
||||
|
||||
@ -459,7 +465,7 @@ public class LoginActivity extends AppCompatActivity implements View.OnClickList
|
||||
final TinyDB tinyDb = new TinyDB(getApplicationContext());
|
||||
|
||||
Call<UserInfo> call = RetrofitClient
|
||||
.getInstance(instanceUrl)
|
||||
.getInstance(instanceUrl, getApplicationContext())
|
||||
.getApiInterface()
|
||||
.getUserInfo("token " + loginToken_);
|
||||
|
||||
@ -526,13 +532,13 @@ public class LoginActivity extends AppCompatActivity implements View.OnClickList
|
||||
Call<List<UserTokens>> call;
|
||||
if(loginOTP != 0) {
|
||||
call = RetrofitClient
|
||||
.getInstance(instanceUrl)
|
||||
.getInstance(instanceUrl, getApplicationContext())
|
||||
.getApiInterface()
|
||||
.getUserTokensWithOTP(credential, loginOTP, loginUid);
|
||||
}
|
||||
else {
|
||||
call = RetrofitClient
|
||||
.getInstance(instanceUrl)
|
||||
.getInstance(instanceUrl, getApplicationContext())
|
||||
.getApiInterface()
|
||||
.getUserTokens(credential, loginUid);
|
||||
}
|
||||
@ -570,13 +576,13 @@ public class LoginActivity extends AppCompatActivity implements View.OnClickList
|
||||
Call<UserTokens> callCreateToken;
|
||||
if(loginOTP != 0) {
|
||||
callCreateToken = RetrofitClient
|
||||
.getInstance(instanceUrl)
|
||||
.getInstance(instanceUrl, getApplicationContext())
|
||||
.getApiInterface()
|
||||
.createNewTokenWithOTP(credential, loginOTP, loginUid, createUserToken);
|
||||
}
|
||||
else {
|
||||
callCreateToken = RetrofitClient
|
||||
.getInstance(instanceUrl)
|
||||
.getInstance(instanceUrl, getApplicationContext())
|
||||
.getApiInterface()
|
||||
.createNewToken(credential, loginUid, createUserToken);
|
||||
}
|
||||
|
@ -124,41 +124,40 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
|
||||
@Override
|
||||
public void onDrawerOpened(@NonNull View drawerView) {
|
||||
|
||||
boolean connToInternet = AppUtil.haveNetworkConnection(getApplicationContext());
|
||||
if(!connToInternet) {
|
||||
|
||||
if(!tinyDb.getBoolean("noConnection")) {
|
||||
Toasty.info(getApplicationContext(), getResources().getString(R.string.checkNetConnection));
|
||||
}
|
||||
|
||||
tinyDb.putBoolean("noConnection", true);
|
||||
|
||||
String userEmailNav = tinyDb.getString("userEmail");
|
||||
String userFullNameNav = tinyDb.getString("userFullname");
|
||||
String userAvatarNav = tinyDb.getString("userAvatar");
|
||||
|
||||
userEmail = hView.findViewById(R.id.userEmail);
|
||||
if (!userEmailNav.equals("")) {
|
||||
userEmail.setText(userEmailNav);
|
||||
}
|
||||
|
||||
userFullName = hView.findViewById(R.id.userFullname);
|
||||
if (!userFullNameNav.equals("")) {
|
||||
userFullName.setText(userFullNameNav);
|
||||
}
|
||||
|
||||
userAvatar = hView.findViewById(R.id.userAvatar);
|
||||
if (!userAvatarNav.equals("")) {
|
||||
Picasso.get().load(userAvatarNav).networkPolicy(NetworkPolicy.OFFLINE).transform(new RoundedTransformation(8, 0)).resize(120, 120).centerCrop().into(userAvatar);
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
displayUserInfo(instanceUrl, instanceToken, loginUid);
|
||||
if(tinyDb.getBoolean("noConnection")) {
|
||||
Toasty.info(getApplicationContext(), getResources().getString(R.string.checkNetConnection));
|
||||
tinyDb.putBoolean("noConnection", false);
|
||||
|
||||
}
|
||||
|
||||
//tinyDb.putBoolean("noConnection", true);
|
||||
|
||||
String userEmailNav = tinyDb.getString("userEmail");
|
||||
String userFullNameNav = tinyDb.getString("userFullname");
|
||||
String userAvatarNav = tinyDb.getString("userAvatar");
|
||||
|
||||
userEmail = hView.findViewById(R.id.userEmail);
|
||||
if (!userEmailNav.equals("")) {
|
||||
userEmail.setText(userEmailNav);
|
||||
}
|
||||
|
||||
userFullName = hView.findViewById(R.id.userFullname);
|
||||
if (!userFullNameNav.equals("")) {
|
||||
userFullName.setText(userFullNameNav);
|
||||
}
|
||||
|
||||
userAvatar = hView.findViewById(R.id.userAvatar);
|
||||
if (!userAvatarNav.equals("")) {
|
||||
Picasso.get().load(userAvatarNav).networkPolicy(NetworkPolicy.OFFLINE).transform(new RoundedTransformation(8, 0)).resize(160, 160).centerCrop().into(userAvatar);
|
||||
}
|
||||
|
||||
userAvatar.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container,
|
||||
new ProfileFragment()).commit();
|
||||
drawer.closeDrawers();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -317,7 +316,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
|
||||
final TinyDB tinyDb = new TinyDB(getApplicationContext());
|
||||
|
||||
Call<UserInfo> call = RetrofitClient
|
||||
.getInstance(instanceUrl)
|
||||
.getInstance(instanceUrl, getApplicationContext())
|
||||
.getApiInterface()
|
||||
.getUserInfo(Authorization.returnAuthentication(getApplicationContext(), loginUid, token));
|
||||
|
||||
@ -345,7 +344,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
|
||||
tinyDb.putString("userFullname", userDetails.getFullname());
|
||||
}
|
||||
else {
|
||||
tinyDb.putString("userFullname", "...");
|
||||
tinyDb.putString("userFullname", userDetails.getLogin());
|
||||
}
|
||||
|
||||
tinyDb.putString("userEmail", userDetails.getEmail());
|
||||
|
@ -204,7 +204,7 @@ public class NewFileActivity extends AppCompatActivity {
|
||||
}
|
||||
|
||||
Call<JsonElement> call = RetrofitClient
|
||||
.getInstance(instanceUrl)
|
||||
.getInstance(instanceUrl, getApplicationContext())
|
||||
.getApiInterface()
|
||||
.createNewFile(token, repoOwner, repoName, fileName, createNewFileJsonStr);
|
||||
|
||||
@ -256,7 +256,7 @@ public class NewFileActivity extends AppCompatActivity {
|
||||
private void getBranches(String instanceUrl, String instanceToken, String repoOwner, String repoName, String loginUid) {
|
||||
|
||||
Call<List<Branches>> call = RetrofitClient
|
||||
.getInstance(instanceUrl)
|
||||
.getInstance(instanceUrl, getApplicationContext())
|
||||
.getApiInterface()
|
||||
.getBranches(Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName);
|
||||
|
||||
|
@ -137,7 +137,7 @@ public class NewMilestoneActivity extends AppCompatActivity implements View.OnCl
|
||||
Call<Milestones> call;
|
||||
|
||||
call = RetrofitClient
|
||||
.getInstance(instanceUrl)
|
||||
.getInstance(instanceUrl, getApplicationContext())
|
||||
.getApiInterface()
|
||||
.createMilestone(token, repoOwner, repoName, createMilestone);
|
||||
|
||||
|
@ -134,7 +134,7 @@ public class NewOrganizationActivity extends AppCompatActivity {
|
||||
UserOrganizations createOrganization = new UserOrganizations(orgName, null, orgDesc, null, null);
|
||||
|
||||
Call<UserOrganizations> call = RetrofitClient
|
||||
.getInstance(instanceUrl)
|
||||
.getInstance(instanceUrl, getApplicationContext())
|
||||
.getApiInterface()
|
||||
.createNewOrganization(token, createOrganization);
|
||||
|
||||
|
@ -162,7 +162,7 @@ public class NewRepoActivity extends AppCompatActivity {
|
||||
if(repoOwner.equals(loginUid)) {
|
||||
|
||||
call = RetrofitClient
|
||||
.getInstance(instanceUrl)
|
||||
.getInstance(instanceUrl, getApplicationContext())
|
||||
.getApiInterface()
|
||||
.createNewUserRepository(token, createRepository);
|
||||
|
||||
@ -170,7 +170,7 @@ public class NewRepoActivity extends AppCompatActivity {
|
||||
else {
|
||||
|
||||
call = RetrofitClient
|
||||
.getInstance(instanceUrl)
|
||||
.getInstance(instanceUrl, getApplicationContext())
|
||||
.getApiInterface()
|
||||
.createNewUserOrgRepository(token, repoOwner, createRepository);
|
||||
|
||||
@ -225,7 +225,7 @@ public class NewRepoActivity extends AppCompatActivity {
|
||||
private void getOrgs(String instanceUrl, String instanceToken, final String userLogin) {
|
||||
|
||||
Call<List<OrgOwner>> call = RetrofitClient
|
||||
.getInstance(instanceUrl)
|
||||
.getInstance(instanceUrl, getApplicationContext())
|
||||
.getApiInterface()
|
||||
.getOrgOwners(instanceToken);
|
||||
|
||||
|
@ -72,7 +72,7 @@ public class OrgTeamMembersActivity extends AppCompatActivity {
|
||||
|
||||
TeamMembersByOrgViewModel teamMembersModel = new ViewModelProvider(this).get(TeamMembersByOrgViewModel.class);
|
||||
|
||||
teamMembersModel.getMembersByOrgList(instanceUrl, instanceToken, teamId).observe(this, new Observer<List<UserInfo>>() {
|
||||
teamMembersModel.getMembersByOrgList(instanceUrl, instanceToken, teamId, getApplicationContext()).observe(this, new Observer<List<UserInfo>>() {
|
||||
@Override
|
||||
public void onChanged(@Nullable List<UserInfo> teamMembersListMain) {
|
||||
adapter = new TeamMembersByOrgAdapter(getApplicationContext(), teamMembersListMain);
|
||||
|
@ -114,7 +114,7 @@ public class ProfileEmailActivity extends AppCompatActivity {
|
||||
Call<JsonElement> call;
|
||||
|
||||
call = RetrofitClient
|
||||
.getInstance(instanceUrl)
|
||||
.getInstance(instanceUrl, getApplicationContext())
|
||||
.getApiInterface()
|
||||
.addNewEmail(token, addEmailFunc);
|
||||
|
||||
|
@ -118,7 +118,7 @@ public class ReplyToIssueActivity extends AppCompatActivity {
|
||||
final String repoName = parts[1];
|
||||
|
||||
Call<List<Collaborators>> call = RetrofitClient
|
||||
.getInstance(instanceUrl)
|
||||
.getInstance(instanceUrl, getApplicationContext())
|
||||
.getApiInterface()
|
||||
.getCollaborators(Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName);
|
||||
|
||||
@ -212,7 +212,7 @@ public class ReplyToIssueActivity extends AppCompatActivity {
|
||||
Issues issueComment = new Issues(newReplyDT);
|
||||
|
||||
Call<Issues> call = RetrofitClient
|
||||
.getInstance(instanceUrl)
|
||||
.getInstance(instanceUrl, getApplicationContext())
|
||||
.getApiInterface()
|
||||
.replyCommentToIssue(Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName, issueIndex, issueComment);
|
||||
|
||||
|
@ -237,7 +237,7 @@ public class RepoDetailActivity extends AppCompatActivity implements RepoBottomS
|
||||
private void getRepoInfo(String instanceUrl, String token, final String owner, String repo) {
|
||||
|
||||
Call<UserRepositories> call = RetrofitClient
|
||||
.getInstance(instanceUrl)
|
||||
.getInstance(instanceUrl, getApplicationContext())
|
||||
.getApiInterface()
|
||||
.getUserRepository(token, owner, repo);
|
||||
|
||||
@ -277,7 +277,7 @@ public class RepoDetailActivity extends AppCompatActivity implements RepoBottomS
|
||||
Call<JsonElement> call;
|
||||
|
||||
call = RetrofitClient
|
||||
.getInstance(instanceUrl)
|
||||
.getInstance(instanceUrl, getApplicationContext())
|
||||
.getApiInterface()
|
||||
.checkRepoStarStatus(instanceToken, owner, repo);
|
||||
|
||||
@ -304,7 +304,7 @@ public class RepoDetailActivity extends AppCompatActivity implements RepoBottomS
|
||||
Call<WatchRepository> call;
|
||||
|
||||
call = RetrofitClient
|
||||
.getInstance(instanceUrl)
|
||||
.getInstance(instanceUrl, getApplicationContext())
|
||||
.getApiInterface()
|
||||
.checkRepoWatchStatus(instanceToken, owner, repo);
|
||||
|
||||
|
@ -64,7 +64,7 @@ public class RepoStargazersActivity extends AppCompatActivity {
|
||||
|
||||
RepoStargazersViewModel repoStargazersModel = new ViewModelProvider(this).get(RepoStargazersViewModel.class);
|
||||
|
||||
repoStargazersModel.getRepoStargazers(instanceUrl, instanceToken, repoOwner, repoName).observe(this, new Observer<List<UserInfo>>() {
|
||||
repoStargazersModel.getRepoStargazers(instanceUrl, instanceToken, repoOwner, repoName, getApplicationContext()).observe(this, new Observer<List<UserInfo>>() {
|
||||
@Override
|
||||
public void onChanged(@Nullable List<UserInfo> stargazersListMain) {
|
||||
adapter = new RepoStargazersAdapter(getApplicationContext(), stargazersListMain);
|
||||
|
@ -64,7 +64,7 @@ public class RepoWatchersActivity extends AppCompatActivity {
|
||||
|
||||
RepoWatchersViewModel repoWatchersModel = new ViewModelProvider(this).get(RepoWatchersViewModel.class);
|
||||
|
||||
repoWatchersModel.getRepoWatchers(instanceUrl, instanceToken, repoOwner, repoName).observe(this, new Observer<List<UserInfo>>() {
|
||||
repoWatchersModel.getRepoWatchers(instanceUrl, instanceToken, repoOwner, repoName, getApplicationContext()).observe(this, new Observer<List<UserInfo>>() {
|
||||
@Override
|
||||
public void onChanged(@Nullable List<UserInfo> watchersListMain) {
|
||||
adapter = new RepoWatchersAdapter(getApplicationContext(), watchersListMain);
|
||||
|
@ -156,7 +156,7 @@ public class UserSearchAdapter extends RecyclerView.Adapter<UserSearchAdapter.Us
|
||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||
|
||||
Call<Collaborators> call = RetrofitClient
|
||||
.getInstance(instanceUrl)
|
||||
.getInstance(instanceUrl, mCtx)
|
||||
.getApiInterface()
|
||||
.checkRepoCollaborator(Authorization.returnAuthentication(mCtx, loginUid, instanceToken), repoOwner, repoName, currentItem.getUsername());
|
||||
|
||||
@ -191,7 +191,7 @@ public class UserSearchAdapter extends RecyclerView.Adapter<UserSearchAdapter.Us
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<Collaborators> call, @NonNull Throwable t) {
|
||||
Log.i("onFailure", t.getMessage());
|
||||
Log.i("onFailure", t.toString());
|
||||
}
|
||||
|
||||
});
|
||||
|
@ -1,6 +1,15 @@
|
||||
package org.mian.gitnex.clients;
|
||||
|
||||
import android.content.Context;
|
||||
import androidx.annotation.NonNull;
|
||||
import org.mian.gitnex.util.AppUtil;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import okhttp3.Cache;
|
||||
import okhttp3.Interceptor;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
import okhttp3.logging.HttpLoggingInterceptor;
|
||||
import retrofit2.Retrofit;
|
||||
import retrofit2.converter.gson.GsonConverterFactory;
|
||||
@ -11,21 +20,40 @@ import retrofit2.converter.gson.GsonConverterFactory;
|
||||
|
||||
public class IssuesService {
|
||||
|
||||
public static <S> S createService(Class<S> serviceClass, String instanceURL) {
|
||||
public static <S> S createService(Class<S> serviceClass, String instanceURL, Context ctx) {
|
||||
|
||||
final boolean connToInternet = AppUtil.haveNetworkConnection(ctx);
|
||||
File httpCacheDirectory = new File(ctx.getCacheDir(), "responses");
|
||||
int cacheSize = 20 * 1024 * 1024;
|
||||
Cache cache = new Cache(httpCacheDirectory, cacheSize);
|
||||
|
||||
HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
|
||||
logging.setLevel(HttpLoggingInterceptor.Level.BODY);
|
||||
|
||||
OkHttpClient.Builder httpClient = new OkHttpClient.Builder();
|
||||
|
||||
httpClient.addInterceptor(logging);
|
||||
|
||||
Retrofit retrofit = new Retrofit.Builder()
|
||||
.baseUrl(instanceURL)
|
||||
.addConverterFactory(GsonConverterFactory.create())
|
||||
//.client(httpClient.build())
|
||||
OkHttpClient okHttpClient = new OkHttpClient.Builder()
|
||||
.cache(cache)
|
||||
//.addInterceptor(logging)
|
||||
.addInterceptor(new Interceptor() {
|
||||
@NonNull
|
||||
@Override public Response intercept(@NonNull Chain chain) throws IOException {
|
||||
Request request = chain.request();
|
||||
if (connToInternet) {
|
||||
request = request.newBuilder().header("Cache-Control", "public, max-age=" + 60).build();
|
||||
} else {
|
||||
request = request.newBuilder().header("Cache-Control", "public, only-if-cached, max-stale=" + 60 * 60 * 24 * 30).build();
|
||||
}
|
||||
return chain.proceed(request);
|
||||
}
|
||||
})
|
||||
.build();
|
||||
|
||||
Retrofit.Builder builder = new Retrofit.Builder()
|
||||
.baseUrl(instanceURL)
|
||||
.client(okHttpClient)
|
||||
.addConverterFactory(GsonConverterFactory.create());
|
||||
|
||||
Retrofit retrofit = builder.build();
|
||||
|
||||
return retrofit.create(serviceClass);
|
||||
|
||||
}
|
||||
|
@ -1,7 +1,16 @@
|
||||
package org.mian.gitnex.clients;
|
||||
|
||||
import android.content.Context;
|
||||
import androidx.annotation.NonNull;
|
||||
import org.mian.gitnex.interfaces.ApiInterface;
|
||||
import org.mian.gitnex.util.AppUtil;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import okhttp3.Cache;
|
||||
import okhttp3.Interceptor;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
import okhttp3.logging.HttpLoggingInterceptor;
|
||||
import retrofit2.Retrofit;
|
||||
import retrofit2.converter.gson.GsonConverterFactory;
|
||||
@ -15,26 +24,45 @@ public class RetrofitClient {
|
||||
|
||||
private Retrofit retrofit;
|
||||
|
||||
private RetrofitClient(String instanceUrl) {
|
||||
private RetrofitClient(String instanceUrl, Context ctx) {
|
||||
|
||||
final boolean connToInternet = AppUtil.haveNetworkConnection(ctx);
|
||||
int cacheSize = 20 * 1024 * 1024;
|
||||
File httpCacheDirectory = new File(ctx.getCacheDir(), "responses");
|
||||
Cache cache = new Cache(httpCacheDirectory, cacheSize);
|
||||
|
||||
HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
|
||||
logging.setLevel(HttpLoggingInterceptor.Level.BODY);
|
||||
|
||||
OkHttpClient.Builder httpClient = new OkHttpClient.Builder();
|
||||
|
||||
httpClient.addInterceptor(logging);
|
||||
|
||||
retrofit = new Retrofit.Builder()
|
||||
.baseUrl(instanceUrl)
|
||||
.addConverterFactory(ScalarsConverterFactory.create())
|
||||
.addConverterFactory(GsonConverterFactory.create())
|
||||
//.client(httpClient.build())
|
||||
OkHttpClient okHttpClient = new OkHttpClient.Builder()
|
||||
.cache(cache)
|
||||
//.addInterceptor(logging)
|
||||
.addInterceptor(new Interceptor() {
|
||||
@NonNull
|
||||
@Override public Response intercept(@NonNull Chain chain) throws IOException {
|
||||
Request request = chain.request();
|
||||
if (connToInternet) {
|
||||
request = request.newBuilder().header("Cache-Control", "public, max-age=" + 60).build();
|
||||
} else {
|
||||
request = request.newBuilder().header("Cache-Control", "public, only-if-cached, max-stale=" + 60 * 60 * 24 * 30).build();
|
||||
}
|
||||
return chain.proceed(request);
|
||||
}
|
||||
})
|
||||
.build();
|
||||
|
||||
Retrofit.Builder builder = new Retrofit.Builder()
|
||||
.baseUrl(instanceUrl)
|
||||
.client(okHttpClient)
|
||||
.addConverterFactory(ScalarsConverterFactory.create())
|
||||
.addConverterFactory(GsonConverterFactory.create());
|
||||
|
||||
retrofit = builder.build();
|
||||
|
||||
}
|
||||
|
||||
public static synchronized RetrofitClient getInstance(String instanceUrl) {
|
||||
return new RetrofitClient(instanceUrl);
|
||||
public static synchronized RetrofitClient getInstance(String instanceUrl, Context ctx) {
|
||||
return new RetrofitClient(instanceUrl, ctx);
|
||||
}
|
||||
|
||||
public ApiInterface getApiInterface() {
|
||||
|
@ -96,7 +96,7 @@ public class BranchesFragment extends Fragment {
|
||||
@Override
|
||||
public void run() {
|
||||
swipeRefresh.setRefreshing(false);
|
||||
BranchesViewModel.loadBranchesList(instanceUrl, instanceToken, repoOwner, repoName);
|
||||
BranchesViewModel.loadBranchesList(instanceUrl, instanceToken, repoOwner, repoName, getContext());
|
||||
}
|
||||
}, 50);
|
||||
}
|
||||
@ -127,7 +127,7 @@ public class BranchesFragment extends Fragment {
|
||||
|
||||
BranchesViewModel branchesModel = new ViewModelProvider(this).get(BranchesViewModel.class);
|
||||
|
||||
branchesModel.getBranchesList(instanceUrl, instanceToken, owner, repo).observe(this, new Observer<List<Branches>>() {
|
||||
branchesModel.getBranchesList(instanceUrl, instanceToken, owner, repo, getContext()).observe(getViewLifecycleOwner(), new Observer<List<Branches>>() {
|
||||
@Override
|
||||
public void onChanged(@Nullable List<Branches> branchesListMain) {
|
||||
adapter = new BranchesAdapter(getContext(), branchesListMain);
|
||||
|
@ -127,7 +127,7 @@ public class ClosedIssuesFragment extends Fragment {
|
||||
recyclerViewClosed.setLayoutManager(new LinearLayoutManager(context));
|
||||
recyclerViewClosed.setAdapter(adapterClosed);
|
||||
|
||||
apiClosed = IssuesService.createService(ApiInterface.class, instanceUrl);
|
||||
apiClosed = IssuesService.createService(ApiInterface.class, instanceUrl, getContext());
|
||||
loadInitial(Authorization.returnAuthentication(getContext(), loginUid, instanceToken), repoOwner, repoName, issueState);
|
||||
|
||||
return v;
|
||||
@ -190,7 +190,7 @@ public class ClosedIssuesFragment extends Fragment {
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<Issues>> call, @NonNull Throwable t) {
|
||||
Log.e(TAG, t.getMessage());
|
||||
Log.e(TAG, t.toString());
|
||||
}
|
||||
|
||||
});
|
||||
@ -245,7 +245,7 @@ public class ClosedIssuesFragment extends Fragment {
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<Issues>> call, @NonNull Throwable t) {
|
||||
|
||||
Log.e(TAG, t.getMessage());
|
||||
Log.e(TAG, t.toString());
|
||||
|
||||
}
|
||||
|
||||
@ -265,9 +265,9 @@ public class ClosedIssuesFragment extends Fragment {
|
||||
searchView.setImeOptions(EditorInfo.IME_ACTION_DONE);
|
||||
//searchView.setQueryHint(getContext().getString(R.string.strFilter));
|
||||
|
||||
if(!connToInternet) {
|
||||
/*if(!connToInternet) {
|
||||
return;
|
||||
}
|
||||
}*/
|
||||
|
||||
searchView.setOnQueryTextListener(new androidx.appcompat.widget.SearchView.OnQueryTextListener() {
|
||||
|
||||
|
@ -100,7 +100,7 @@ public class CollaboratorsFragment extends Fragment {
|
||||
|
||||
CollaboratorsViewModel collaboratorsModel = new ViewModelProvider(this).get(CollaboratorsViewModel.class);
|
||||
|
||||
collaboratorsModel.getCollaboratorsList(instanceUrl, instanceToken, owner, repo).observe(this, new Observer<List<Collaborators>>() {
|
||||
collaboratorsModel.getCollaboratorsList(instanceUrl, instanceToken, owner, repo, getContext()).observe(getViewLifecycleOwner(), new Observer<List<Collaborators>>() {
|
||||
@Override
|
||||
public void onChanged(@Nullable List<Collaborators> collaboratorsListMain) {
|
||||
adapter = new CollaboratorsAdapter(getContext(), collaboratorsListMain);
|
||||
|
@ -92,26 +92,19 @@ public class ExploreRepositoriesFragment extends Fragment {
|
||||
mProgressBar = v.findViewById(R.id.progress_bar);
|
||||
mRecyclerView = v.findViewById(R.id.recyclerViewReposSearch);
|
||||
|
||||
if(connToInternet) {
|
||||
|
||||
searchKeyword.setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
||||
@Override
|
||||
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
||||
if (actionId == EditorInfo.IME_ACTION_SEND) {
|
||||
if(!searchKeyword.getText().toString().equals("")) {
|
||||
mProgressBar.setVisibility(View.VISIBLE);
|
||||
mRecyclerView.setVisibility(View.GONE);
|
||||
loadSearchReposList(instanceUrl, instanceToken, loginUid, searchKeyword.getText().toString(), repoTypeInclude, sort, order, getContext(), limit);
|
||||
}
|
||||
searchKeyword.setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
||||
@Override
|
||||
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
||||
if (actionId == EditorInfo.IME_ACTION_SEND) {
|
||||
if(!searchKeyword.getText().toString().equals("")) {
|
||||
mProgressBar.setVisibility(View.VISIBLE);
|
||||
mRecyclerView.setVisibility(View.GONE);
|
||||
loadSearchReposList(instanceUrl, instanceToken, loginUid, searchKeyword.getText().toString(), repoTypeInclude, sort, order, getContext(), limit);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
else {
|
||||
mProgressBar.setVisibility(View.GONE);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
return v;
|
||||
|
||||
@ -120,7 +113,7 @@ public class ExploreRepositoriesFragment extends Fragment {
|
||||
private void loadSearchReposList(String instanceUrl, String instanceToken, String loginUid, String searchKeyword, Boolean repoTypeInclude, String sort, String order, final Context context, int limit) {
|
||||
|
||||
Call<ExploreRepositories> call = RetrofitClient
|
||||
.getInstance(instanceUrl)
|
||||
.getInstance(instanceUrl, getContext())
|
||||
.getApiInterface()
|
||||
.queryRepos(Authorization.returnAuthentication(getContext(), loginUid, instanceToken), searchKeyword, repoTypeInclude, sort, order, limit);
|
||||
|
||||
|
@ -192,7 +192,7 @@ public class FilesFragment extends Fragment implements FilesAdapter.FilesAdapter
|
||||
|
||||
FilesViewModel filesModel = new ViewModelProvider(this).get(FilesViewModel.class);
|
||||
|
||||
filesModel.getFilesList(instanceUrl, instanceToken, owner, repo, getContext()).observe(this, new Observer<List<Files>>() {
|
||||
filesModel.getFilesList(instanceUrl, instanceToken, owner, repo, getContext()).observe(getViewLifecycleOwner(), new Observer<List<Files>>() {
|
||||
@Override
|
||||
public void onChanged(@Nullable List<Files> filesListMain) {
|
||||
adapter = new FilesAdapter(getContext(), filesListMain, FilesFragment.this);
|
||||
@ -262,9 +262,9 @@ public class FilesFragment extends Fragment implements FilesAdapter.FilesAdapter
|
||||
searchView.setImeOptions(EditorInfo.IME_ACTION_DONE);
|
||||
searchView.setQueryHint(getContext().getString(R.string.strFilter));
|
||||
|
||||
if(!connToInternet) {
|
||||
/*if(!connToInternet) {
|
||||
return;
|
||||
}
|
||||
}*/
|
||||
|
||||
searchView.setOnQueryTextListener(new androidx.appcompat.widget.SearchView.OnQueryTextListener() {
|
||||
@Override
|
||||
|
@ -126,7 +126,7 @@ public class IssuesFragment extends Fragment {
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(context));
|
||||
recyclerView.setAdapter(adapter);
|
||||
|
||||
api = IssuesService.createService(ApiInterface.class, instanceUrl);
|
||||
api = IssuesService.createService(ApiInterface.class, instanceUrl, getContext());
|
||||
loadInitial(Authorization.returnAuthentication(getContext(), loginUid, instanceToken), repoOwner, repoName);
|
||||
|
||||
return v;
|
||||
@ -189,7 +189,7 @@ public class IssuesFragment extends Fragment {
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<Issues>> call, @NonNull Throwable t) {
|
||||
Log.e(TAG, t.getMessage());
|
||||
Log.e(TAG, t.toString());
|
||||
}
|
||||
|
||||
});
|
||||
@ -244,7 +244,7 @@ public class IssuesFragment extends Fragment {
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<Issues>> call, @NonNull Throwable t) {
|
||||
|
||||
Log.e(TAG, t.getMessage());
|
||||
Log.e(TAG, t.toString());
|
||||
|
||||
}
|
||||
|
||||
@ -264,9 +264,9 @@ public class IssuesFragment extends Fragment {
|
||||
searchView.setImeOptions(EditorInfo.IME_ACTION_DONE);
|
||||
//searchView.setQueryHint(getContext().getString(R.string.strFilter));
|
||||
|
||||
if(!connToInternet) {
|
||||
/*if(!connToInternet) {
|
||||
return;
|
||||
}
|
||||
}*/
|
||||
|
||||
searchView.setOnQueryTextListener(new androidx.appcompat.widget.SearchView.OnQueryTextListener() {
|
||||
|
||||
|
@ -94,7 +94,7 @@ public class LabelsFragment extends Fragment {
|
||||
@Override
|
||||
public void run() {
|
||||
swipeRefresh.setRefreshing(false);
|
||||
LabelsViewModel.loadLabelsList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), repoOwner, repoName);
|
||||
LabelsViewModel.loadLabelsList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), repoOwner, repoName, getContext());
|
||||
}
|
||||
}, 200);
|
||||
}
|
||||
@ -119,7 +119,7 @@ public class LabelsFragment extends Fragment {
|
||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||
|
||||
if(tinyDb.getBoolean("labelsRefresh")) {
|
||||
LabelsViewModel.loadLabelsList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), repoOwner, repoName);
|
||||
LabelsViewModel.loadLabelsList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), repoOwner, repoName, getContext());
|
||||
tinyDb.putBoolean("labelsRefresh", false);
|
||||
}
|
||||
}
|
||||
@ -144,7 +144,7 @@ public class LabelsFragment extends Fragment {
|
||||
|
||||
LabelsViewModel labelsModel = new ViewModelProvider(this).get(LabelsViewModel.class);
|
||||
|
||||
labelsModel.getLabelsList(instanceUrl, instanceToken, owner, repo).observe(this, new Observer<List<Labels>>() {
|
||||
labelsModel.getLabelsList(instanceUrl, instanceToken, owner, repo, getContext()).observe(getViewLifecycleOwner(), new Observer<List<Labels>>() {
|
||||
@Override
|
||||
public void onChanged(@Nullable List<Labels> labelsListMain) {
|
||||
adapter = new LabelsAdapter(getContext(), labelsListMain);
|
||||
|
@ -83,7 +83,7 @@ public class MembersByOrgFragment extends Fragment {
|
||||
|
||||
MembersByOrgViewModel membersModel= new ViewModelProvider(this).get(MembersByOrgViewModel.class);
|
||||
|
||||
membersModel.getMembersList(instanceUrl, instanceToken, owner).observe(this, new Observer<List<UserInfo>>() {
|
||||
membersModel.getMembersList(instanceUrl, instanceToken, owner, getContext()).observe(getViewLifecycleOwner(), new Observer<List<UserInfo>>() {
|
||||
@Override
|
||||
public void onChanged(@Nullable List<UserInfo> membersListMain) {
|
||||
adapter = new MembersByOrgAdapter(getContext(), membersListMain);
|
||||
|
@ -104,7 +104,7 @@ public class MilestonesFragment extends Fragment {
|
||||
@Override
|
||||
public void run() {
|
||||
swipeRefresh.setRefreshing(false);
|
||||
MilestonesViewModel.loadMilestonesList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), repoOwner, repoName, msState);
|
||||
MilestonesViewModel.loadMilestonesList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), repoOwner, repoName, msState, getContext());
|
||||
}
|
||||
}, 50);
|
||||
}
|
||||
@ -128,7 +128,7 @@ public class MilestonesFragment extends Fragment {
|
||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||
|
||||
if(tinyDb.getBoolean("milestoneCreated")) {
|
||||
MilestonesViewModel.loadMilestonesList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), repoOwner, repoName, msState);
|
||||
MilestonesViewModel.loadMilestonesList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), repoOwner, repoName, msState, getContext());
|
||||
tinyDb.putBoolean("milestoneCreated", false);
|
||||
}
|
||||
}
|
||||
@ -153,7 +153,7 @@ public class MilestonesFragment extends Fragment {
|
||||
|
||||
MilestonesViewModel msModel = new ViewModelProvider(this).get(MilestonesViewModel.class);
|
||||
|
||||
msModel.getMilestonesList(instanceUrl, instanceToken, owner, repo, msState).observe(this, new Observer<List<Milestones>>() {
|
||||
msModel.getMilestonesList(instanceUrl, instanceToken, owner, repo, msState, getContext()).observe(getViewLifecycleOwner(), new Observer<List<Milestones>>() {
|
||||
@Override
|
||||
public void onChanged(@Nullable List<Milestones> msListMain) {
|
||||
adapter = new MilestonesAdapter(getContext(), msListMain);
|
||||
@ -185,9 +185,9 @@ public class MilestonesFragment extends Fragment {
|
||||
searchView.setImeOptions(EditorInfo.IME_ACTION_DONE);
|
||||
//searchView.setQueryHint(getContext().getString(R.string.strFilter));
|
||||
|
||||
if(!connToInternet) {
|
||||
/*if(!connToInternet) {
|
||||
return;
|
||||
}
|
||||
}*/
|
||||
|
||||
searchView.setOnQueryTextListener(new androidx.appcompat.widget.SearchView.OnQueryTextListener() {
|
||||
@Override
|
||||
|
@ -132,27 +132,20 @@ public class MyRepositoriesFragment extends Fragment {
|
||||
}
|
||||
});
|
||||
|
||||
if(connToInternet) {
|
||||
swipeRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
|
||||
@Override
|
||||
public void onRefresh() {
|
||||
new Handler().postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
swipeRefresh.setRefreshing(false);
|
||||
MyRepositoriesViewModel.loadMyReposList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), userLogin, getContext());
|
||||
}
|
||||
}, 50);
|
||||
}
|
||||
});
|
||||
|
||||
swipeRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
|
||||
@Override
|
||||
public void onRefresh() {
|
||||
new Handler().postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
swipeRefresh.setRefreshing(false);
|
||||
MyRepositoriesViewModel.loadMyReposList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), userLogin);
|
||||
}
|
||||
}, 50);
|
||||
}
|
||||
});
|
||||
|
||||
fetchDataAsync(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), userLogin);
|
||||
|
||||
}
|
||||
else {
|
||||
mProgressBar.setVisibility(View.GONE);
|
||||
}
|
||||
fetchDataAsync(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), userLogin);
|
||||
|
||||
return v;
|
||||
|
||||
@ -167,7 +160,7 @@ public class MyRepositoriesFragment extends Fragment {
|
||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||
final String userLogin = tinyDb.getString("userLogin");
|
||||
|
||||
MyRepositoriesViewModel.loadMyReposList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), userLogin);
|
||||
MyRepositoriesViewModel.loadMyReposList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), userLogin, getContext());
|
||||
|
||||
}
|
||||
|
||||
@ -175,7 +168,7 @@ public class MyRepositoriesFragment extends Fragment {
|
||||
|
||||
MyRepositoriesViewModel myRepoModel = new ViewModelProvider(this).get(MyRepositoriesViewModel.class);
|
||||
|
||||
myRepoModel.getCurrentUserRepositories(instanceUrl, instanceToken, userLogin).observe(this, new Observer<List<UserRepositories>>() {
|
||||
myRepoModel.getCurrentUserRepositories(instanceUrl, instanceToken, userLogin, getContext()).observe(getViewLifecycleOwner(), new Observer<List<UserRepositories>>() {
|
||||
@Override
|
||||
public void onChanged(@Nullable List<UserRepositories> myReposListMain) {
|
||||
adapter = new MyReposListAdapter(getContext(), myReposListMain);
|
||||
@ -207,9 +200,9 @@ public class MyRepositoriesFragment extends Fragment {
|
||||
searchView.setImeOptions(EditorInfo.IME_ACTION_DONE);
|
||||
//searchView.setQueryHint(getContext().getString(R.string.strFilter));
|
||||
|
||||
if(!connToInternet) {
|
||||
/*if(!connToInternet) {
|
||||
return;
|
||||
}
|
||||
}*/
|
||||
|
||||
searchView.setOnQueryTextListener(new androidx.appcompat.widget.SearchView.OnQueryTextListener() {
|
||||
@Override
|
||||
|
@ -88,7 +88,7 @@ public class OrganizationInfoFragment extends Fragment {
|
||||
private void getOrgInfo(String instanceUrl, String token, final String owner) {
|
||||
|
||||
Call<Organization> call = RetrofitClient
|
||||
.getInstance(instanceUrl)
|
||||
.getInstance(instanceUrl, getContext())
|
||||
.getApiInterface()
|
||||
.getOrganization(token, owner);
|
||||
|
||||
|
@ -101,25 +101,20 @@ public class OrganizationsFragment extends Fragment {
|
||||
}
|
||||
});
|
||||
|
||||
if(connToInternet) {
|
||||
swipeRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
|
||||
@Override
|
||||
public void onRefresh() {
|
||||
new Handler().postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
swipeRefresh.setRefreshing(false);
|
||||
OrganizationListViewModel.loadOrgsList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken));
|
||||
}
|
||||
}, 50);
|
||||
}
|
||||
});
|
||||
swipeRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
|
||||
@Override
|
||||
public void onRefresh() {
|
||||
new Handler().postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
swipeRefresh.setRefreshing(false);
|
||||
OrganizationListViewModel.loadOrgsList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), getContext());
|
||||
}
|
||||
}, 50);
|
||||
}
|
||||
});
|
||||
|
||||
fetchDataAsync(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken));
|
||||
}
|
||||
else {
|
||||
mProgressBar.setVisibility(View.GONE);
|
||||
}
|
||||
fetchDataAsync(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken));
|
||||
|
||||
return v;
|
||||
|
||||
@ -134,7 +129,7 @@ public class OrganizationsFragment extends Fragment {
|
||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||
|
||||
if(tinyDb.getBoolean("orgCreated")) {
|
||||
OrganizationListViewModel.loadOrgsList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken));
|
||||
OrganizationListViewModel.loadOrgsList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), getContext());
|
||||
tinyDb.putBoolean("orgCreated", false);
|
||||
}
|
||||
}
|
||||
@ -143,7 +138,7 @@ public class OrganizationsFragment extends Fragment {
|
||||
|
||||
OrganizationListViewModel orgModel = new ViewModelProvider(this).get(OrganizationListViewModel.class);
|
||||
|
||||
orgModel.getUserOrgs(instanceUrl, instanceToken).observe(this, new Observer<List<UserOrganizations>>() {
|
||||
orgModel.getUserOrgs(instanceUrl, instanceToken, getContext()).observe(getViewLifecycleOwner(), new Observer<List<UserOrganizations>>() {
|
||||
@Override
|
||||
public void onChanged(@Nullable List<UserOrganizations> orgsListMain) {
|
||||
adapter = new OrganizationsListAdapter(getContext(), orgsListMain);
|
||||
@ -175,9 +170,9 @@ public class OrganizationsFragment extends Fragment {
|
||||
searchView.setImeOptions(EditorInfo.IME_ACTION_DONE);
|
||||
//searchView.setQueryHint(getContext().getString(R.string.strFilter));
|
||||
|
||||
if(!connToInternet) {
|
||||
/*if(!connToInternet) {
|
||||
return;
|
||||
}
|
||||
}*/
|
||||
|
||||
searchView.setOnQueryTextListener(new androidx.appcompat.widget.SearchView.OnQueryTextListener() {
|
||||
@Override
|
||||
|
@ -95,7 +95,7 @@ public class ProfileEmailsFragment extends Fragment {
|
||||
@Override
|
||||
public void run() {
|
||||
swipeRefresh.setRefreshing(false);
|
||||
ProfileEmailsViewModel.loadEmailsList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken));
|
||||
ProfileEmailsViewModel.loadEmailsList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), getContext());
|
||||
}
|
||||
}, 200);
|
||||
}
|
||||
@ -111,7 +111,7 @@ public class ProfileEmailsFragment extends Fragment {
|
||||
|
||||
ProfileEmailsViewModel profileEmailModel = new ViewModelProvider(this).get(ProfileEmailsViewModel.class);
|
||||
|
||||
profileEmailModel.getEmailsList(instanceUrl, instanceToken).observe(this, new Observer<List<Emails>>() {
|
||||
profileEmailModel.getEmailsList(instanceUrl, instanceToken, getContext()).observe(getViewLifecycleOwner(), new Observer<List<Emails>>() {
|
||||
@Override
|
||||
public void onChanged(@Nullable List<Emails> emailsListMain) {
|
||||
adapter = new ProfileEmailsAdapter(getContext(), emailsListMain);
|
||||
|
@ -95,7 +95,7 @@ public class ProfileFollowersFragment extends Fragment {
|
||||
@Override
|
||||
public void run() {
|
||||
swipeRefresh.setRefreshing(false);
|
||||
ProfileFollowersViewModel.loadFollowersList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken));
|
||||
ProfileFollowersViewModel.loadFollowersList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), getContext());
|
||||
}
|
||||
}, 200);
|
||||
}
|
||||
@ -110,7 +110,7 @@ public class ProfileFollowersFragment extends Fragment {
|
||||
|
||||
ProfileFollowersViewModel pfModel = new ViewModelProvider(this).get(ProfileFollowersViewModel.class);
|
||||
|
||||
pfModel.getFollowersList(instanceUrl, instanceToken).observe(this, new Observer<List<UserInfo>>() {
|
||||
pfModel.getFollowersList(instanceUrl, instanceToken, getContext()).observe(getViewLifecycleOwner(), new Observer<List<UserInfo>>() {
|
||||
@Override
|
||||
public void onChanged(@Nullable List<UserInfo> pfListMain) {
|
||||
adapter = new ProfileFollowersAdapter(getContext(), pfListMain);
|
||||
|
@ -95,7 +95,7 @@ public class ProfileFollowingFragment extends Fragment {
|
||||
@Override
|
||||
public void run() {
|
||||
swipeRefresh.setRefreshing(false);
|
||||
ProfileFollowingViewModel.loadFollowingList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken));
|
||||
ProfileFollowingViewModel.loadFollowingList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), getContext());
|
||||
}
|
||||
}, 200);
|
||||
}
|
||||
@ -110,7 +110,7 @@ public class ProfileFollowingFragment extends Fragment {
|
||||
|
||||
ProfileFollowingViewModel pfModel = new ViewModelProvider(this).get(ProfileFollowingViewModel.class);
|
||||
|
||||
pfModel.getFollowingList(instanceUrl, instanceToken).observe(this, new Observer<List<UserInfo>>() {
|
||||
pfModel.getFollowingList(instanceUrl, instanceToken, getContext()).observe(getViewLifecycleOwner(), new Observer<List<UserInfo>>() {
|
||||
@Override
|
||||
public void onChanged(@Nullable List<UserInfo> pfListMain) {
|
||||
adapter = new ProfileFollowingAdapter(getContext(), pfListMain);
|
||||
|
@ -95,7 +95,7 @@ public class ReleasesFragment extends Fragment {
|
||||
@Override
|
||||
public void run() {
|
||||
swipeRefresh.setRefreshing(false);
|
||||
ReleasesViewModel.loadReleasesList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), repoOwner, repoName);
|
||||
ReleasesViewModel.loadReleasesList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), repoOwner, repoName, getContext());
|
||||
}
|
||||
}, 50);
|
||||
}
|
||||
@ -117,7 +117,7 @@ public class ReleasesFragment extends Fragment {
|
||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||
|
||||
if(tinyDb.getBoolean("updateReleases")) {
|
||||
ReleasesViewModel.loadReleasesList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), repoOwner, repoName);
|
||||
ReleasesViewModel.loadReleasesList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), repoOwner, repoName, getContext());
|
||||
tinyDb.putBoolean("updateReleases", false);
|
||||
}
|
||||
|
||||
@ -143,7 +143,7 @@ public class ReleasesFragment extends Fragment {
|
||||
|
||||
ReleasesViewModel releasesModel = new ViewModelProvider(this).get(ReleasesViewModel.class);
|
||||
|
||||
releasesModel.getReleasesList(instanceUrl, instanceToken, owner, repo).observe(this, new Observer<List<Releases>>() {
|
||||
releasesModel.getReleasesList(instanceUrl, instanceToken, owner, repo, getContext()).observe(getViewLifecycleOwner(), new Observer<List<Releases>>() {
|
||||
@Override
|
||||
public void onChanged(@Nullable List<Releases> releasesListMain) {
|
||||
adapter = new ReleasesAdapter(getContext(), releasesListMain);
|
||||
|
@ -218,7 +218,7 @@ public class RepoInfoFragment extends Fragment {
|
||||
final TinyDB tinyDb = new TinyDB(getContext());
|
||||
|
||||
Call<UserRepositories> call = RetrofitClient
|
||||
.getInstance(instanceUrl)
|
||||
.getInstance(instanceUrl, getContext())
|
||||
.getApiInterface()
|
||||
.getUserRepository(token, owner, repo);
|
||||
|
||||
@ -303,7 +303,7 @@ public class RepoInfoFragment extends Fragment {
|
||||
final TinyDB tinyDb = new TinyDB(getContext());
|
||||
|
||||
Call<String> call = RetrofitClient
|
||||
.getInstance(instanceUrl)
|
||||
.getInstance(instanceUrl, getContext())
|
||||
.getApiInterface()
|
||||
.getFileContents(token, owner, repo, filename);
|
||||
|
||||
|
@ -97,7 +97,7 @@ public class RepositoriesByOrgFragment extends Fragment {
|
||||
@Override
|
||||
public void run() {
|
||||
swipeRefresh.setRefreshing(false);
|
||||
RepositoriesByOrgViewModel.loadOrgRepos(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), orgName);
|
||||
RepositoriesByOrgViewModel.loadOrgRepos(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), orgName, getContext());
|
||||
}
|
||||
}, 200);
|
||||
}
|
||||
@ -117,7 +117,7 @@ public class RepositoriesByOrgFragment extends Fragment {
|
||||
final String loginUid = tinyDb.getString("loginUid");
|
||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||
|
||||
RepositoriesByOrgViewModel.loadOrgRepos(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), orgName);
|
||||
RepositoriesByOrgViewModel.loadOrgRepos(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), orgName, getContext());
|
||||
|
||||
}
|
||||
|
||||
@ -125,7 +125,7 @@ public class RepositoriesByOrgFragment extends Fragment {
|
||||
|
||||
RepositoriesByOrgViewModel orgRepoModel = new ViewModelProvider(this).get(RepositoriesByOrgViewModel.class);
|
||||
|
||||
orgRepoModel.getRepositoriesByOrg(instanceUrl, instanceToken, owner).observe(this, new Observer<List<UserRepositories>>() {
|
||||
orgRepoModel.getRepositoriesByOrg(instanceUrl, instanceToken, owner, getContext()).observe(getViewLifecycleOwner(), new Observer<List<UserRepositories>>() {
|
||||
@Override
|
||||
public void onChanged(@Nullable List<UserRepositories> orgReposListMain) {
|
||||
adapter = new RepositoriesByOrgAdapter(getContext(), orgReposListMain);
|
||||
|
@ -102,27 +102,20 @@ public class RepositoriesFragment extends Fragment {
|
||||
}
|
||||
});
|
||||
|
||||
if(connToInternet) {
|
||||
swipeRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
|
||||
@Override
|
||||
public void onRefresh() {
|
||||
new Handler().postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
swipeRefresh.setRefreshing(false);
|
||||
RepositoriesListViewModel.loadReposList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), getContext());
|
||||
}
|
||||
}, 50);
|
||||
}
|
||||
});
|
||||
|
||||
swipeRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
|
||||
@Override
|
||||
public void onRefresh() {
|
||||
new Handler().postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
swipeRefresh.setRefreshing(false);
|
||||
RepositoriesListViewModel.loadReposList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken));
|
||||
}
|
||||
}, 50);
|
||||
}
|
||||
});
|
||||
|
||||
fetchDataAsync(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken));
|
||||
|
||||
}
|
||||
else {
|
||||
mProgressBar.setVisibility(View.GONE);
|
||||
}
|
||||
fetchDataAsync(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken));
|
||||
|
||||
return v;
|
||||
|
||||
@ -137,7 +130,7 @@ public class RepositoriesFragment extends Fragment {
|
||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||
|
||||
if(tinyDb.getBoolean("repoCreated")) {
|
||||
RepositoriesListViewModel.loadReposList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken));
|
||||
RepositoriesListViewModel.loadReposList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), getContext());
|
||||
tinyDb.putBoolean("repoCreated", false);
|
||||
}
|
||||
}
|
||||
@ -146,7 +139,7 @@ public class RepositoriesFragment extends Fragment {
|
||||
|
||||
RepositoriesListViewModel repoModel = new ViewModelProvider(this).get(RepositoriesListViewModel.class);
|
||||
|
||||
repoModel.getUserRepositories(instanceUrl, instanceToken).observe(this, new Observer<List<UserRepositories>>() {
|
||||
repoModel.getUserRepositories(instanceUrl, instanceToken, getContext()).observe(getViewLifecycleOwner(), new Observer<List<UserRepositories>>() {
|
||||
@Override
|
||||
public void onChanged(@Nullable List<UserRepositories> reposListMain) {
|
||||
adapter = new ReposListAdapter(getContext(), reposListMain);
|
||||
@ -178,9 +171,9 @@ public class RepositoriesFragment extends Fragment {
|
||||
searchView.setImeOptions(EditorInfo.IME_ACTION_DONE);
|
||||
//searchView.setQueryHint(getContext().getString(R.string.strFilter));
|
||||
|
||||
if(!connToInternet) {
|
||||
/*if(!connToInternet) {
|
||||
return;
|
||||
}
|
||||
}*/
|
||||
|
||||
searchView.setOnQueryTextListener(new androidx.appcompat.widget.SearchView.OnQueryTextListener() {
|
||||
@Override
|
||||
|
@ -127,27 +127,20 @@ public class StarredRepositoriesFragment extends Fragment {
|
||||
}
|
||||
});
|
||||
|
||||
if(connToInternet) {
|
||||
swipeRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
|
||||
@Override
|
||||
public void onRefresh() {
|
||||
new Handler().postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
swipeRefresh.setRefreshing(false);
|
||||
StarredRepositoriesViewModel.loadStarredReposList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), getContext());
|
||||
}
|
||||
}, 50);
|
||||
}
|
||||
});
|
||||
|
||||
swipeRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
|
||||
@Override
|
||||
public void onRefresh() {
|
||||
new Handler().postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
swipeRefresh.setRefreshing(false);
|
||||
StarredRepositoriesViewModel.loadStarredReposList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken));
|
||||
}
|
||||
}, 50);
|
||||
}
|
||||
});
|
||||
|
||||
fetchDataAsync(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken));
|
||||
|
||||
}
|
||||
else {
|
||||
mProgressBar.setVisibility(View.GONE);
|
||||
}
|
||||
fetchDataAsync(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken));
|
||||
|
||||
return v;
|
||||
}
|
||||
@ -160,7 +153,7 @@ public class StarredRepositoriesFragment extends Fragment {
|
||||
final String loginUid = tinyDb.getString("loginUid");
|
||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||
|
||||
StarredRepositoriesViewModel.loadStarredReposList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken));
|
||||
StarredRepositoriesViewModel.loadStarredReposList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), getContext());
|
||||
|
||||
}
|
||||
|
||||
@ -168,7 +161,7 @@ public class StarredRepositoriesFragment extends Fragment {
|
||||
|
||||
StarredRepositoriesViewModel starredRepoModel = new ViewModelProvider(this).get(StarredRepositoriesViewModel.class);
|
||||
|
||||
starredRepoModel.getUserStarredRepositories(instanceUrl, instanceToken).observe(this, new Observer<List<UserRepositories>>() {
|
||||
starredRepoModel.getUserStarredRepositories(instanceUrl, instanceToken, getContext()).observe(getViewLifecycleOwner(), new Observer<List<UserRepositories>>() {
|
||||
@Override
|
||||
public void onChanged(@Nullable List<UserRepositories> starredReposListMain) {
|
||||
adapter = new StarredReposListAdapter(getContext(), starredReposListMain);
|
||||
@ -200,9 +193,9 @@ public class StarredRepositoriesFragment extends Fragment {
|
||||
searchView.setImeOptions(EditorInfo.IME_ACTION_DONE);
|
||||
//searchView.setQueryHint(getContext().getString(R.string.strFilter));
|
||||
|
||||
if(!connToInternet) {
|
||||
/*if(!connToInternet) {
|
||||
return;
|
||||
}
|
||||
}*/
|
||||
|
||||
searchView.setOnQueryTextListener(new androidx.appcompat.widget.SearchView.OnQueryTextListener() {
|
||||
@Override
|
||||
|
@ -97,7 +97,7 @@ public class TeamsByOrgFragment extends Fragment {
|
||||
@Override
|
||||
public void run() {
|
||||
swipeRefresh.setRefreshing(false);
|
||||
TeamsByOrgViewModel.loadTeamsByOrgList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), orgName);
|
||||
TeamsByOrgViewModel.loadTeamsByOrgList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), orgName, getContext());
|
||||
}
|
||||
}, 200);
|
||||
}
|
||||
@ -117,7 +117,7 @@ public class TeamsByOrgFragment extends Fragment {
|
||||
final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
|
||||
|
||||
if(tinyDb.getBoolean("resumeTeams")) {
|
||||
TeamsByOrgViewModel.loadTeamsByOrgList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), orgName);
|
||||
TeamsByOrgViewModel.loadTeamsByOrgList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), orgName, getContext());
|
||||
tinyDb.putBoolean("resumeTeams", false);
|
||||
}
|
||||
}
|
||||
@ -126,7 +126,7 @@ public class TeamsByOrgFragment extends Fragment {
|
||||
|
||||
TeamsByOrgViewModel teamModel = new ViewModelProvider(this).get(TeamsByOrgViewModel.class);
|
||||
|
||||
teamModel.getTeamsByOrg(instanceUrl, instanceToken, owner).observe(this, new Observer<List<Teams>>() {
|
||||
teamModel.getTeamsByOrg(instanceUrl, instanceToken, owner, getContext()).observe(getViewLifecycleOwner(), new Observer<List<Teams>>() {
|
||||
@Override
|
||||
public void onChanged(@Nullable List<Teams> orgTeamsListMain) {
|
||||
adapter = new TeamsByOrgAdapter(getContext(), orgTeamsListMain);
|
||||
@ -158,9 +158,9 @@ public class TeamsByOrgFragment extends Fragment {
|
||||
searchView.setImeOptions(EditorInfo.IME_ACTION_DONE);
|
||||
//searchView.setQueryHint(getContext().getString(R.string.strFilter));
|
||||
|
||||
if(!connToInternet) {
|
||||
/*if(!connToInternet) {
|
||||
return;
|
||||
}
|
||||
}*/
|
||||
|
||||
searchView.setOnQueryTextListener(new androidx.appcompat.widget.SearchView.OnQueryTextListener() {
|
||||
@Override
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user