Skip to content
Snippets Groups Projects
Commit 09d7a2df authored by Jawn's avatar Jawn
Browse files

Issues status is updated as it is selected in the spinner

parent 0d128c54
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -43,6 +43,7 @@ dependencies {
compile 'com.jakewharton:butterknife:7.0.1'
compile 'com.jakewharton.timber:timber:3.1.0'
compile 'de.hdodenhof:circleimageview:1.3.0'
compile 'com.pnikosis:materialish-progress:1.5'
compile 'com.android.support:appcompat-v7:22.2.1'
compile 'com.android.support:design:22.2.1'
compile 'com.android.support:recyclerview-v7:22.2.1'
Loading
Loading
Loading
Loading
@@ -8,10 +8,10 @@ import android.text.method.LinkMovementMethod;
import android.view.MenuItem;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.ProgressBar;
import android.widget.ScrollView;
import android.widget.Spinner;
import android.widget.TextView;
Loading
Loading
@@ -49,9 +49,9 @@ public class IssueActivity extends BaseActivity {
@Bind(R.id.description) TextView description;
@Bind(R.id.note_list) ListView noteList;
@Bind(R.id.progressbar_loading) ProgressBar progressBar;
@Bind(R.id.progressbar_loading) View progressBar;
@Bind(R.id.new_note_edit) EditText newNoteEdit;
private ProgressDialog pd;
@Override
Loading
Loading
@@ -115,6 +115,21 @@ public class IssueActivity extends BaseActivity {
}
stateSpinner.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, temp3));
stateSpinner.setSelection(temp3.indexOf(Repository.selectedIssue.getState()));
//Hack so that the onItemSelected does not get triggered the first time we create the view
stateSpinner.post(new Runnable() {
@Override
public void run() {
stateSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
changeStatus();
}
@Override
public void onNothingSelected(AdapterView<?> parent) {}
});
}
});
 
if(Repository.selectedIssue.getAssignee() != null) {
ArrayList<User> temp = new ArrayList<User>();
Loading
Loading
@@ -147,6 +162,24 @@ public class IssueActivity extends BaseActivity {
progressBar.setVisibility(View.VISIBLE);
Repository.getService().getIssueNotes(Repository.selectedProject.getId(), Repository.selectedIssue.getId(), notesCallback);
}
private void changeStatus() {
String selection = stateSpinner.getSelectedItem().toString();
String value = "";
if(selection.equals("closed") && (Repository.selectedIssue.getState().equals("opened") || Repository.selectedIssue.getState().equals("reopened"))) {
value = "close";
}
if((selection.equals("reopened") || selection.equals("opened")) && Repository.selectedIssue.getState().equals("closed")) {
value = "reopen";
}
Repository.getService().editIssue(
Repository.selectedProject.getId(),
Repository.selectedIssue.getId(),
value,
"",
issueCallback);
}
private Callback<List<Note>> notesCallback = new Callback<List<Note>>() {
Loading
Loading
@@ -229,8 +262,12 @@ public class IssueActivity extends BaseActivity {
if((selection.equals("reopened") || selection.equals("opened")) && Repository.selectedIssue.getState().equals("closed"))
value = "reopen";
Repository.getService().editIssue(Repository.selectedProject.getId(), Repository.selectedIssue.getId(), value, assigneeSpinner.getSelectedItemId(), milestoneSpinner.getSelectedItemId(),
"", issueCallback);
Repository.getService().editIssue(
Repository.selectedProject.getId(),
Repository.selectedIssue.getId(),
value,
"",
issueCallback);
}
private Callback<Issue> issueCallback = new Callback<Issue>() {
Loading
Loading
@@ -244,16 +281,18 @@ public class IssueActivity extends BaseActivity {
Repository.selectedIssue.setAssignee((User) assigneeSpinner.getSelectedItem());
Repository.selectedIssue.setMilestone((Milestone) milestoneSpinner.getSelectedItem());
if(Repository.issueAdapter != null)
if(Repository.issueAdapter != null) {
Repository.issueAdapter.notifyDataSetChanged();
}
}
@Override
public void failure(RetrofitError e) {
RetrofitHelper.printDebugInfo(IssueActivity.this, e);
if(pd != null && pd.isShowing())
if(pd != null && pd.isShowing()) {
pd.cancel();
}
Snackbar.make(getWindow().getDecorView(), getString(R.string.connection_error), Snackbar.LENGTH_SHORT)
.show();
}
Loading
Loading
Loading
Loading
@@ -82,6 +82,13 @@ public interface GitLabAPI {
@PUT("/projects/{id}/issues/{issue_id}")
void editIssue(@Path("id") long projectId, @Path("issue_id") long issueId, @Query("state_event") String stateEvent, @Query("assignee_id") long assigneeId, @Query("milestone_id") long milestoneId,
@Body String blankBodySoRetrofitDoesntCry, Callback<Issue> cb);
@PUT("/projects/{id}/issues/{issue_id}")
void editIssue(@Path("id") long projectId,
@Path("issue_id") long issueId,
@Query("state_event") String stateEvent,
@Body String blankBodySoRetrofitDoesntCry,
Callback<Issue> cb);
@GET("/projects/{id}/issues/{issue_id}/notes?per_page=100")
void getIssueNotes(@Path("id") long projectId, @Path("issue_id") long issueId, Callback<List<Note>> cb);
Loading
Loading
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
Loading
Loading
@@ -66,12 +67,14 @@
android:text="Description"
android:textAppearance="?android:attr/textAppearanceMedium" />
 
<ProgressBar
<com.pnikosis.materialishprogress.ProgressWheel
android:id="@+id/progressbar_loading"
style="?android:attr/progressBarStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone" />
android:layout_gravity="center"
app:matProg_barColor="?attr/colorAccent"
app:matProg_progressIndeterminate="true"
android:visibility="gone"/>
 
<View
android:id="@+id/lsep"
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment