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

Merge branch 'develop'

parents caf35d96 af2a2bcb
No related branches found
No related tags found
No related merge requests found
Pipeline #
Showing
with 422 additions and 197 deletions
Loading
Loading
@@ -10,8 +10,8 @@ android {
applicationId "com.commit451.gitlab"
minSdkVersion 16
targetSdkVersion 23
versionCode 211
versionName "2.1.1"
versionCode 212
versionName "2.1.2"
}
buildTypes {
release {
Loading
Loading
@@ -34,11 +34,11 @@ android {
 
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:design:23.0.1'
compile 'com.android.support:recyclerview-v7:23.0.1'
compile 'com.android.support:cardview-v7:23.0.1'
compile 'com.android.support:palette-v7:23.0.1'
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'com.android.support:design:23.1.0'
compile 'com.android.support:recyclerview-v7:23.1.0'
compile 'com.android.support:cardview-v7:23.1.0'
compile 'com.android.support:palette-v7:23.1.0'
compile 'com.google.code.gson:gson:2.3.1'
compile 'net.danlew:android.joda:2.8.2'
compile 'com.squareup.picasso:picasso:2.5.2'
Loading
Loading
Loading
Loading
@@ -7,6 +7,7 @@ import android.os.Bundle;
import android.os.Environment;
import android.support.design.widget.Snackbar;
import android.support.v7.widget.Toolbar;
import android.text.Html;
import android.util.Base64;
import android.view.MenuItem;
import android.view.View;
Loading
Loading
@@ -71,7 +72,7 @@ public class FileActivity extends BaseActivity {
} catch (UnsupportedEncodingException e) {
Timber.e(e.toString());
}
String temp = "<!DOCTYPE html><html><head><link href=\"github.css\" rel=\"stylesheet\" /></head><body><pre><code>" + text + "</code></pre><script src=\"highlight.pack.js\"></script><script>hljs.initHighlightingOnLoad();</script></body></html>";
String temp = "<!DOCTYPE html><html><head><link href=\"github.css\" rel=\"stylesheet\" /></head><body><pre><code>" + Html.escapeHtml(text) + "</code></pre><script src=\"highlight.pack.js\"></script><script>hljs.initHighlightingOnLoad();</script></body></html>";
fileBlobView.loadDataWithBaseURL("file:///android_asset/", temp, "text/html", "utf8", null);
toolbar.setTitle(mFileName);
toolbar.inflateMenu(R.menu.file);
Loading
Loading
Loading
Loading
@@ -15,14 +15,17 @@ import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
import android.widget.TextView;
 
import com.commit451.gitlab.GitLabApp;
import com.commit451.gitlab.R;
import com.commit451.gitlab.adapter.NotesAdapter;
import com.commit451.gitlab.api.GitLabClient;
import com.commit451.gitlab.dialogs.NewIssueDialog;
import com.commit451.gitlab.events.IssueChangedEvent;
import com.commit451.gitlab.model.Issue;
import com.commit451.gitlab.model.Note;
import com.commit451.gitlab.model.Project;
import com.commit451.gitlab.model.User;
import com.commit451.gitlab.tools.IntentUtil;
import com.squareup.otto.Subscribe;
 
import org.parceler.Parcels;
 
Loading
Loading
@@ -36,6 +39,9 @@ import retrofit.Response;
import retrofit.Retrofit;
import timber.log.Timber;
 
/**
* Shows off an issue like a bar of gold
*/
public class IssueActivity extends BaseActivity {
 
private static final String EXTRA_PROJECT = "extra_project";
Loading
Loading
@@ -48,16 +54,31 @@ public class IssueActivity extends BaseActivity {
return intent;
}
 
@Bind(R.id.toolbar) Toolbar toolbar;
@Bind(R.id.swipe_layout) SwipeRefreshLayout swipeRefreshLayout;
@Bind(R.id.list) RecyclerView listView;
@Bind(R.id.new_note_edit) EditText newNoteEdit;
@Bind(R.id.progress) View progress;
@Bind(R.id.toolbar) Toolbar mToolbar;
@Bind(R.id.issue_title) TextView mIssueTitle;
@Bind(R.id.swipe_layout) SwipeRefreshLayout mSwipeRefreshLayout;
@Bind(R.id.list) RecyclerView mListView;
@Bind(R.id.new_note_edit) EditText mNewNoteEdit;
@Bind(R.id.progress) View mProgress;
 
private NotesAdapter notesAdapter;
@OnClick(R.id.new_note_button)
public void onNewNoteClick() {
postNote();
}
@OnClick(R.id.fab_edit_issue)
public void onEditIssueClick() {
new NewIssueDialog(this, mProject, mIssue).show();
}
MenuItem mOpenCloseMenuItem;
NotesAdapter mNotesAdapter;
Project mProject;
Issue mIssue;
 
EventReceiver mEventReceiver;
private final Toolbar.OnMenuItemClickListener mOnMenuItemClickListener = new Toolbar.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
Loading
Loading
@@ -65,41 +86,106 @@ public class IssueActivity extends BaseActivity {
case R.id.action_share:
IntentUtil.share(getWindow().getDecorView(), mIssue.getUrl(mProject));
return true;
case R.id.action_close:
closeIssue();
return true;
}
return false;
}
};
private Callback<List<Note>> notesCallback = new Callback<List<Note>>() {
@Override
public void onResponse(Response<List<Note>> response, Retrofit retrofit) {
if (!response.isSuccess()) {
return;
}
mSwipeRefreshLayout.setRefreshing(false);
mNotesAdapter.addNotes(response.body());
}
@Override
public void onFailure(Throwable t) {
Timber.e(t.toString());
mSwipeRefreshLayout.setRefreshing(false);
Snackbar.make(getWindow().getDecorView(), getString(R.string.connection_error), Snackbar.LENGTH_SHORT)
.show();
}
};
private final Callback<Issue> mOpenCloseCallback = new Callback<Issue>() {
@Override
public void onResponse(Response<Issue> response, Retrofit retrofit) {
mProgress.setVisibility(View.GONE);
if (!response.isSuccess()) {
Snackbar.make(getWindow().getDecorView(), getString(R.string.error_changing_issue), Snackbar.LENGTH_SHORT)
.show();
return;
}
mIssue = response.body();
GitLabApp.bus().post(new IssueChangedEvent(mIssue));
setOpenCloseMenuStatus();
loadNotes();
}
@Override
public void onFailure(Throwable t) {
Timber.e(t.toString());
mProgress.setVisibility(View.GONE);
Snackbar.make(getWindow().getDecorView(), getString(R.string.error_changing_issue), Snackbar.LENGTH_SHORT)
.show();
}
};
private Callback<Note> noteCallback = new Callback<Note>() {
@Override
public void onResponse(Response<Note> response, Retrofit retrofit) {
if (!response.isSuccess()) {
return;
}
mProgress.setVisibility(View.GONE);
mNotesAdapter.addNote(response.body());
}
@Override
public void onFailure(Throwable t) {
Timber.e(t.toString());
mProgress.setVisibility(View.GONE);
Snackbar.make(getWindow().getDecorView(), getString(R.string.connection_error), Snackbar.LENGTH_SHORT)
.show();
}
};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_issue);
ButterKnife.bind(this);
mEventReceiver = new EventReceiver();
GitLabApp.bus().register(mEventReceiver);
 
mProject = Parcels.unwrap(getIntent().getParcelableExtra(EXTRA_PROJECT));
mIssue = Parcels.unwrap(getIntent().getParcelableExtra(EXTRA_SELECTED_ISSUE));
 
long tempId = mIssue.getIid();
if(tempId < 1) {
tempId = mIssue.getId();
}
mToolbar.setNavigationIcon(R.drawable.ic_back_24dp);
mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onBackPressed();
}
});
mToolbar.setSubtitle(mProject.getNameWithNamespace());
mToolbar.inflateMenu(R.menu.issue);
mOpenCloseMenuItem = mToolbar.getMenu().findItem(R.id.action_close);
mToolbar.setOnMenuItemClickListener(mOnMenuItemClickListener);
mNotesAdapter = new NotesAdapter(mIssue);
mListView.setLayoutManager(new LinearLayoutManager(this));
mListView.setAdapter(mNotesAdapter);
 
toolbar.setNavigationIcon(R.drawable.ic_back_24dp);
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onBackPressed();
}
});
toolbar.setTitle("Issue #" + tempId);
toolbar.inflateMenu(R.menu.issue);
toolbar.setOnMenuItemClickListener(mOnMenuItemClickListener);
notesAdapter = new NotesAdapter(mIssue);
listView.setLayoutManager(new LinearLayoutManager(this));
listView.setAdapter(notesAdapter);
newNoteEdit.setOnEditorActionListener(new TextView.OnEditorActionListener() {
mNewNoteEdit.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
postNote();
Loading
Loading
@@ -107,100 +193,83 @@ public class IssueActivity extends BaseActivity {
}
});
 
swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
load();
loadNotes();
}
});
load();
bindIssue();
loadNotes();
}
@Override
protected void onDestroy() {
super.onDestroy();
GitLabApp.bus().unregister(mEventReceiver);
}
 
private void load() {
swipeRefreshLayout.setRefreshing(true);
private void bindIssue() {
mToolbar.setTitle(getString(R.string.issue_number) + mIssue.getId());
setOpenCloseMenuStatus();
mIssueTitle.setText(mIssue.getTitle());
mNotesAdapter.updateIssue(mIssue);
}
private void loadNotes() {
mSwipeRefreshLayout.post(new Runnable() {
@Override
public void run() {
if (mSwipeRefreshLayout != null) {
mSwipeRefreshLayout.setRefreshing(true);
}
}
});
mSwipeRefreshLayout.setRefreshing(true);
GitLabClient.instance().getIssueNotes(mProject.getId(), mIssue.getId()).enqueue(notesCallback);
}
 
private void postNote() {
String body = newNoteEdit.getText().toString();
String body = mNewNoteEdit.getText().toString();
 
if(body.length() < 1) {
return;
}
 
progress.setVisibility(View.VISIBLE);
progress.setAlpha(0.0f);
progress.animate().alpha(1.0f);
mProgress.setVisibility(View.VISIBLE);
mProgress.setAlpha(0.0f);
mProgress.animate().alpha(1.0f);
// Clear text & collapse keyboard
InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(newNoteEdit.getWindowToken(), 0);
newNoteEdit.setText("");
imm.hideSoftInputFromWindow(mNewNoteEdit.getWindowToken(), 0);
mNewNoteEdit.setText("");
 
GitLabClient.instance().postIssueNote(mProject.getId(), mIssue.getId(), body).enqueue(noteCallback);
}
private Callback<List<Note>> notesCallback = new Callback<List<Note>>() {
@Override
public void onResponse(Response<List<Note>> response, Retrofit retrofit) {
if (!response.isSuccess()) {
return;
}
swipeRefreshLayout.setRefreshing(false);
notesAdapter.addNotes(response.body());
}
 
@Override
public void onFailure(Throwable t) {
Timber.e(t.toString());
swipeRefreshLayout.setRefreshing(false);
Snackbar.make(getWindow().getDecorView(), getString(R.string.connection_error), Snackbar.LENGTH_SHORT)
.show();
}
};
@OnClick(R.id.new_note_button)
public void onNewNoteClick() {
postNote();
}
private Callback<Note> noteCallback = new Callback<Note>() {
@Override
public void onResponse(Response<Note> response, Retrofit retrofit) {
if (!response.isSuccess()) {
return;
}
progress.setVisibility(View.GONE);
notesAdapter.addNote(response.body());
}
private void closeIssue() {
mProgress.setVisibility(View.VISIBLE);
if (mIssue.getState().equals(Issue.STATE_CLOSED)) {
GitLabClient.instance().setIssueStatus(mProject.getId(), mIssue.getId(), Issue.STATE_REOPEN)
.enqueue(mOpenCloseCallback);
} else {
GitLabClient.instance().setIssueStatus(mProject.getId(), mIssue.getId(), Issue.STATE_CLOSE)
.enqueue(mOpenCloseCallback);
}
}
 
@Override
public void onFailure(Throwable t) {
Timber.e(t.toString());
progress.setVisibility(View.GONE);
Snackbar.make(getWindow().getDecorView(), getString(R.string.connection_error), Snackbar.LENGTH_SHORT)
.show();
}
};
private Callback<List<User>> usersCallback = new Callback<List<User>>() {
@Override
public void onResponse(Response<List<User>> response, Retrofit retrofit) {
if (!response.isSuccess()) {
return;
}
swipeRefreshLayout.setRefreshing(false);
notesAdapter.addUsers(response.body());
}
private void setOpenCloseMenuStatus() {
mOpenCloseMenuItem.setTitle(mIssue.getState().equals(Issue.STATE_CLOSED) ? R.string.reopen : R.string.close);
}
 
@Override
public void onFailure(Throwable t) {
Timber.e(t.toString());
swipeRefreshLayout.setRefreshing(false);
Snackbar.make(getWindow().getDecorView(), getString(R.string.connection_error), Snackbar.LENGTH_SHORT)
.show();
}
};
private class EventReceiver {
@Subscribe
public void onIssueChanged(IssueChangedEvent event) {
if (mIssue.getId() == event.issue.getId()) {
mIssue = event.issue;
bindIssue();
}
}
}
}
Loading
Loading
@@ -70,4 +70,19 @@ public class IssuesAdapter extends RecyclerView.Adapter<IssueViewHolder> {
mValues.add(0, issue);
notifyItemInserted(0);
}
public void updateIssue(Issue issue) {
int indexToDelete = -1;
for (int i=0; i<mValues.size(); i++) {
if (mValues.get(i).getId() == issue.getId()) {
indexToDelete = i;
break;
}
}
if (indexToDelete != -1) {
mValues.remove(indexToDelete);
mValues.add(indexToDelete, issue);
}
notifyItemChanged(indexToDelete);
}
}
Loading
Loading
@@ -88,7 +88,6 @@ public class NotesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
}
 
public void addNote(Note note) {
//TODO declare position that changed
mNotes.add(0, note);
notifyItemInserted(0);
}
Loading
Loading
@@ -108,4 +107,9 @@ public class NotesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
}
notifyDataSetChanged();
}
public void updateIssue(Issue issue) {
mIssue = issue;
notifyItemChanged(0);
}
}
Loading
Loading
@@ -29,7 +29,7 @@ import retrofit.http.Path;
import retrofit.http.Query;
 
public interface GitLab {
String API_VERSION = "/api/v3";
String API_VERSION = "api/v3";
/* --- LOGIN --- */
 
@FormUrlEncoded
Loading
Loading
@@ -101,18 +101,6 @@ public interface GitLab {
@Field("title") String title,
@Field("description") String description);
 
@PUT(API_VERSION + "/projects/{id}/issues/{issue_id}")
Call<Issue> 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);
@PUT(API_VERSION + "/projects/{id}/issues/{issue_id}")
Call<Issue> editIssue(@Path("id") long projectId,
@Path("issue_id") long issueId,
@Query("state_event") String stateEvent);
@GET(API_VERSION + "/projects/{id}/issues/{issue_id}/notes?per_page=100")
Call<List<Note>> getIssueNotes(@Path("id") long projectId,
@Path("issue_id") long issueId);
Loading
Loading
@@ -122,6 +110,17 @@ public interface GitLab {
Call<Note> postIssueNote(@Path("id") long projectId,
@Path("issue_id") long issueId,
@Field("body") String body);
@PUT(API_VERSION + "/projects/{id}/issues/{issue_id}")
Call<Issue> setIssueStatus(@Path("id") long projectId,
@Path("issue_id") long issueId,
@Query("state_event") @Issue.EditState String status);
@PUT(API_VERSION + "/projects/{id}/issues/{issue_id}")
Call<Issue> updateIssue(@Path("id") long projectId,
@Path("issue_id") long issueId,
@Query("title") String title,
@Query("description") String description);
/* --- FILES --- */
 
Loading
Loading
Loading
Loading
@@ -10,8 +10,11 @@ import android.widget.Toast;
 
import com.commit451.gitlab.GitLabApp;
import com.commit451.gitlab.R;
import com.commit451.gitlab.api.GitLabClient;
import com.commit451.gitlab.events.IssueChangedEvent;
import com.commit451.gitlab.events.IssueCreatedEvent;
import com.commit451.gitlab.model.Issue;
import com.commit451.gitlab.model.Project;
 
import butterknife.Bind;
import butterknife.ButterKnife;
Loading
Loading
@@ -27,29 +30,48 @@ import timber.log.Timber;
*/
public class NewIssueDialog extends AppCompatDialog {
 
@Bind(R.id.titleInputLayout) TextInputLayout titleInputLayout;
@Bind(R.id.title_input) EditText titleInput;
@Bind(R.id.descriptionInputLayout) TextInputLayout descriptionInputLayout;
@Bind(R.id.description_input) EditText descriptionInput;
@Bind(R.id.progress) View progress;
@Bind(R.id.titleInputLayout) TextInputLayout mTitleInputLayout;
@Bind(R.id.title_input) EditText mTitleInput;
@Bind(R.id.descriptionInputLayout) TextInputLayout mDescriptionInputLayout;
@Bind(R.id.description_input) EditText mDescriptionInput;
@Bind(R.id.progress) View mProgress;
 
public NewIssueDialog(Context context) {
private Project mProject;
private Issue mIssue;
public NewIssueDialog(Context context, Project project) {
super(context);
setContentView(R.layout.dialog_add_issue);
ButterKnife.bind(this);
mProject = project;
}
public NewIssueDialog(Context context, Project project, Issue issue) {
super(context);
setContentView(R.layout.dialog_add_issue);
ButterKnife.bind(this);
mProject = project;
mIssue = issue;
bindIssue();
}
 
@OnClick(R.id.save_button)
public void onSaveClick() {
if(!TextUtils.isEmpty(titleInput.getText())) {
progress.setVisibility(View.VISIBLE);
progress.setAlpha(0.0f);
progress.animate().alpha(1.0f);
//TODO fix this
// GitLabClient.instance().postIssue(GitLabApp.instance().getSelectedProject().getId(), titleInput.getText().toString().trim(), descriptionInput.getText().toString().trim()).enqueue(issueCallback);
if(!TextUtils.isEmpty(mTitleInput.getText())) {
mTitleInputLayout.setError(null);
mProgress.setVisibility(View.VISIBLE);
mProgress.setAlpha(0.0f);
mProgress.animate().alpha(1.0f);
if (mIssue == null) {
GitLabClient.instance().postIssue(mProject.getId(), mTitleInput.getText().toString().trim(), mDescriptionInput.getText().toString().trim())
.enqueue(mIssueCallback);
} else {
GitLabClient.instance().updateIssue(mProject.getId(), mIssue.getId(), mTitleInput.getText().toString(), mDescriptionInput.getText().toString())
.enqueue(mIssueCallback);
}
}
else {
titleInputLayout.setError(getContext().getString(R.string.required_field));
mTitleInputLayout.setError(getContext().getString(R.string.required_field));
}
}
 
Loading
Loading
@@ -58,26 +80,36 @@ public class NewIssueDialog extends AppCompatDialog {
this.dismiss();
}
 
private Callback<Issue> issueCallback = new Callback<Issue>() {
private Callback<Issue> mIssueCallback = new Callback<Issue>() {
 
@Override
public void onResponse(Response<Issue> response, Retrofit retrofit) {
if (!response.isSuccess()) {
return;
}
//TODO update the parent list when a new issue is created
GitLabApp.bus().post(new IssueCreatedEvent(response.body()));
//TODO fix this
// getContext().startActivity(IssueActivity.newInstance(getContext(), response.body()));
if (mIssue == null) {
GitLabApp.bus().post(new IssueCreatedEvent(response.body()));
} else {
GitLabApp.bus().post(new IssueChangedEvent(response.body()));
}
dismiss();
}
 
@Override
public void onFailure(Throwable t) {
Timber.e(t.toString());
progress.setVisibility(View.GONE);
mProgress.setVisibility(View.GONE);
Toast.makeText(getContext(), getContext().getString(R.string.connection_error), Toast.LENGTH_SHORT)
.show();
}
};
private void bindIssue() {
if (!TextUtils.isEmpty(mIssue.getTitle())) {
mTitleInput.setText(mIssue.getTitle());
}
if (!TextUtils.isEmpty(mIssue.getDescription())) {
mDescriptionInput.setText(mIssue.getDescription());
}
}
}
package com.commit451.gitlab.events;
import com.commit451.gitlab.model.Issue;
/**
* Event indicating that an issue has changed
* Created by Jawnnypoo on 10/19/2015.
*/
public class IssueChangedEvent {
public Issue issue;
public IssueChangedEvent(Issue issue) {
this.issue = issue;
}
}
Loading
Loading
@@ -38,7 +38,7 @@ public class CommitsFragment extends BaseFragment implements SwipeRefreshLayout.
 
@Bind(R.id.list) RecyclerView listView;
CommitsAdapter adapter;
@Bind(R.id.swipe_layout) SwipeRefreshLayout swipeLayout;
@Bind(R.id.swipe_layout) SwipeRefreshLayout mSwipeRefreshLayout;
@Bind(R.id.message_text) View messageView;
 
EventReceiver mEventReceiver;
Loading
Loading
@@ -72,10 +72,11 @@ public class CommitsFragment extends BaseFragment implements SwipeRefreshLayout.
GitLabApp.bus().register(mEventReceiver);
listView.setLayoutManager(new LinearLayoutManager(getActivity()));
listView.setAdapter(adapter);
swipeLayout.setOnRefreshListener(this);
mSwipeRefreshLayout.setOnRefreshListener(this);
if (getActivity() instanceof ProjectActivity) {
mProject = ((ProjectActivity) getActivity()).getProject();
mBranchName = ((ProjectActivity) getActivity()).getBranchName();
if (!TextUtils.isEmpty(mBranchName)) {
if (!TextUtils.isEmpty(mBranchName) && mProject != null) {
loadData();
}
} else {
Loading
Loading
@@ -97,10 +98,12 @@ public class CommitsFragment extends BaseFragment implements SwipeRefreshLayout.
 
@Override
protected void loadData() {
swipeLayout.post(new Runnable() {
mSwipeRefreshLayout.post(new Runnable() {
@Override
public void run() {
swipeLayout.setRefreshing(true);
if (mSwipeRefreshLayout != null) {
mSwipeRefreshLayout.setRefreshing(true);
}
}
});
GitLabClient.instance().getCommits(mProject.getId(), mBranchName).enqueue(commitsCallback);
Loading
Loading
@@ -115,13 +118,13 @@ public class CommitsFragment extends BaseFragment implements SwipeRefreshLayout.
 
@Override
public void onResponse(Response<List<DiffLine>> response, Retrofit retrofit) {
if (!response.isSuccess()) {
return;
}
if (getView() == null) {
return;
}
swipeLayout.setRefreshing(false);
if (!response.isSuccess()) {
return;
}
mSwipeRefreshLayout.setRefreshing(false);
 
if(response.body().size() > 0) {
messageView.setVisibility(View.GONE);
Loading
Loading
@@ -135,10 +138,13 @@ public class CommitsFragment extends BaseFragment implements SwipeRefreshLayout.
 
@Override
public void onFailure(Throwable t) {
if (getView() == null) {
return;
}
Timber.e(t.toString());
 
if(swipeLayout != null && swipeLayout.isRefreshing()) {
swipeLayout.setRefreshing(false);
if(mSwipeRefreshLayout != null && mSwipeRefreshLayout.isRefreshing()) {
mSwipeRefreshLayout.setRefreshing(false);
}
messageView.setVisibility(View.VISIBLE);
 
Loading
Loading
Loading
Loading
@@ -51,7 +51,7 @@ public class FilesFragment extends BaseFragment {
}
 
@Bind(R.id.error_text) TextView errorText;
@Bind(R.id.swipe_layout) SwipeRefreshLayout swipeLayout;
@Bind(R.id.swipe_layout) SwipeRefreshLayout mSwipeRefreshLayout;
@Bind(R.id.list) RecyclerView list;
 
EventReceiver eventReceiver;
Loading
Loading
@@ -72,7 +72,7 @@ public class FilesFragment extends BaseFragment {
 
list.setLayoutManager(new LinearLayoutManager(getActivity()));
 
swipeLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
loadData();
Loading
Loading
@@ -105,12 +105,14 @@ public class FilesFragment extends BaseFragment {
@Override
protected void loadData() {
Timber.d("loadData");
swipeLayout.post(new Runnable() {
@Override
public void run() {
swipeLayout.setRefreshing(true);
}
});
mSwipeRefreshLayout.post(new Runnable() {
@Override
public void run() {
if (mSwipeRefreshLayout != null) {
mSwipeRefreshLayout.setRefreshing(true);
}
}
});
 
String currentPath = "";
for(String p : mPath) {
Loading
Loading
@@ -145,7 +147,7 @@ public class FilesFragment extends BaseFragment {
if (getView() == null) {
return;
}
swipeLayout.setRefreshing(false);
mSwipeRefreshLayout.setRefreshing(false);
if (response.body() != null && !response.body().isEmpty()) {
list.setVisibility(View.VISIBLE);
list.setAdapter(new FilesAdapter(response.body()));
Loading
Loading
@@ -157,8 +159,8 @@ public class FilesFragment extends BaseFragment {
 
@Override
public void onFailure(Throwable t) {
if(swipeLayout != null && swipeLayout.isRefreshing()) {
swipeLayout.setRefreshing(false);
if(mSwipeRefreshLayout != null && mSwipeRefreshLayout.isRefreshing()) {
mSwipeRefreshLayout.setRefreshing(false);
}
Snackbar.make(getActivity().getWindow().getDecorView(), getString(R.string.connection_error_files), Snackbar.LENGTH_SHORT)
.show();
Loading
Loading
Loading
Loading
@@ -16,6 +16,7 @@ import com.commit451.gitlab.activities.ProjectActivity;
import com.commit451.gitlab.adapter.IssuesAdapter;
import com.commit451.gitlab.api.GitLabClient;
import com.commit451.gitlab.dialogs.NewIssueDialog;
import com.commit451.gitlab.events.IssueChangedEvent;
import com.commit451.gitlab.events.IssueCreatedEvent;
import com.commit451.gitlab.events.ProjectReloadEvent;
import com.commit451.gitlab.model.Issue;
Loading
Loading
@@ -40,7 +41,7 @@ public class IssuesFragment extends BaseFragment implements SwipeRefreshLayout.O
 
@Bind(R.id.add_issue_button) View addIssueButton;
@Bind(R.id.list) RecyclerView listView;
@Bind(R.id.swipe_layout) SwipeRefreshLayout swipeLayout;
@Bind(R.id.swipe_layout) SwipeRefreshLayout mSwipeRefreshLayout;
 
IssuesAdapter issuesAdapter;
EventReceiver eventReceiver;
Loading
Loading
@@ -63,7 +64,7 @@ public class IssuesFragment extends BaseFragment implements SwipeRefreshLayout.O
listView.setLayoutManager(new LinearLayoutManager(getActivity()));
issuesAdapter = new IssuesAdapter(mIssuesAdapterListener);
listView.setAdapter(issuesAdapter);
swipeLayout.setOnRefreshListener(this);
mSwipeRefreshLayout.setOnRefreshListener(this);
 
eventReceiver = new EventReceiver();
GitLabApp.bus().register(eventReceiver);
Loading
Loading
@@ -93,10 +94,12 @@ public class IssuesFragment extends BaseFragment implements SwipeRefreshLayout.O
}
public void loadData() {
swipeLayout.post(new Runnable() {
mSwipeRefreshLayout.post(new Runnable() {
@Override
public void run() {
swipeLayout.setRefreshing(true);
if (mSwipeRefreshLayout != null) {
mSwipeRefreshLayout.setRefreshing(true);
}
}
});
GitLabClient.instance().getIssues(mProject.getId()).enqueue(issuesCallback);
Loading
Loading
@@ -106,13 +109,13 @@ public class IssuesFragment extends BaseFragment implements SwipeRefreshLayout.O
 
@Override
public void onResponse(Response<List<Issue>> response, Retrofit retrofit) {
if (!response.isSuccess()) {
return;
}
if (getView() == null) {
return;
}
swipeLayout.setRefreshing(false);
if (!response.isSuccess()) {
return;
}
mSwipeRefreshLayout.setRefreshing(false);
issuesAdapter.setIssues(response.body());
 
addIssueButton.setEnabled(true);
Loading
Loading
@@ -121,9 +124,13 @@ public class IssuesFragment extends BaseFragment implements SwipeRefreshLayout.O
@Override
public void onFailure(Throwable t) {
Timber.e(t.toString());
if (getView() == null) {
return;
}
 
if(swipeLayout != null && swipeLayout.isRefreshing())
swipeLayout.setRefreshing(false);
if(mSwipeRefreshLayout != null && mSwipeRefreshLayout.isRefreshing()) {
mSwipeRefreshLayout.setRefreshing(false);
}
Snackbar.make(getActivity().getWindow().getDecorView(), getString(R.string.connection_error_issues), Snackbar.LENGTH_SHORT)
.show();
listView.setAdapter(null);
Loading
Loading
@@ -136,7 +143,12 @@ public class IssuesFragment extends BaseFragment implements SwipeRefreshLayout.O
 
@OnClick(R.id.add_issue_button)
public void onAddIssueClick() {
new NewIssueDialog(getActivity()).show();
if (mProject != null) {
new NewIssueDialog(getActivity(), mProject).show();
} else {
Snackbar.make(getActivity().getWindow().getDecorView(), getString(R.string.wait_for_project_to_load), Snackbar.LENGTH_SHORT)
.show();
}
}
 
private class EventReceiver {
Loading
Loading
@@ -146,9 +158,16 @@ public class IssuesFragment extends BaseFragment implements SwipeRefreshLayout.O
mProject = event.project;
loadData();
}
@Subscribe
public void onIssueAdded(IssueCreatedEvent event) {
issuesAdapter.addIssue(event.issue);
listView.smoothScrollToPosition(0);
}
@Subscribe
public void onIssueChanged(IssueChangedEvent event) {
issuesAdapter.updateIssue(event.issue);
}
}
}
\ No newline at end of file
Loading
Loading
@@ -129,7 +129,9 @@ public class MergeRequestFragment extends BaseFragment {
mSwipeRefreshLayout.post(new Runnable() {
@Override
public void run() {
mSwipeRefreshLayout.setRefreshing(true);
if (mSwipeRefreshLayout != null) {
mSwipeRefreshLayout.setRefreshing(true);
}
}
});
GitLabClient.instance().getMergeRequests(mProject.getId()).enqueue(mCallback);
Loading
Loading
Loading
Loading
@@ -162,7 +162,9 @@ public class OverviewFragment extends BaseFragment {
mSwipeRefreshLayout.post(new Runnable() {
@Override
public void run() {
mSwipeRefreshLayout.setRefreshing(true);
if (mSwipeRefreshLayout != null) {
mSwipeRefreshLayout.setRefreshing(true);
}
}
});
GitLabClient.instance().getTree(mProject.getId(), mBranchName, null).enqueue(mFilesCallback);
Loading
Loading
Loading
Loading
@@ -66,9 +66,15 @@ public class ProjectsFragment extends BaseFragment {
private final Callback<List<Project>> mProjectsCallback = new Callback<List<Project>>() {
@Override
public void onResponse(Response<List<Project>> response, Retrofit retrofit) {
if (getView() == null) {
return;
}
mSwipeRefreshLayout.setRefreshing(false);
if (!response.isSuccess()) {
mRecyclerView.setVisibility(View.GONE);
mMessageText.setVisibility(View.VISIBLE);
mMessageText.setText(R.string.connection_error);
return;
}
if (response.body().isEmpty()) {
mMessageText.setText(R.string.no_projects);
Loading
Loading
@@ -87,6 +93,7 @@ public class ProjectsFragment extends BaseFragment {
if (getView() == null) {
return;
}
mSwipeRefreshLayout.setRefreshing(false);
mMessageText.setVisibility(View.VISIBLE);
mMessageText.setText(R.string.connection_error);
}
Loading
Loading
@@ -164,7 +171,9 @@ public class ProjectsFragment extends BaseFragment {
mSwipeRefreshLayout.post(new Runnable() {
@Override
public void run() {
mSwipeRefreshLayout.setRefreshing(true);
if (mSwipeRefreshLayout != null) {
mSwipeRefreshLayout.setRefreshing(true);
}
}
});
}
Loading
Loading
Loading
Loading
@@ -138,7 +138,14 @@ public class UsersFragment extends BaseFragment {
protected void loadData() {
super.loadData();
mMessageText.setVisibility(View.GONE);
mSwipeRefreshLayout.setRefreshing(true);
mSwipeRefreshLayout.post(new Runnable() {
@Override
public void run() {
if (mSwipeRefreshLayout != null) {
mSwipeRefreshLayout.setRefreshing(true);
}
}
});
GitLabClient.instance().searchUsers(mQuery).enqueue(mSearchCallback);
}
 
Loading
Loading
Loading
Loading
@@ -68,8 +68,11 @@ public class DiffLine {
}
 
public List<Line> getLines() {
ArrayList<Line> lines = new ArrayList<Line>();
ArrayList<Line> lines = new ArrayList<>();
 
if (message == null) {
return null;
}
String[] temp = message.split("\\r?\\n");
 
for(String s : temp) {
Loading
Loading
package com.commit451.gitlab.model;
 
import android.support.annotation.StringDef;
import com.google.gson.annotations.SerializedName;
import org.parceler.Parcel;
 
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.Date;
@Parcel
public class Issue {
@StringDef({STATE_REOPEN, STATE_CLOSE})
@Retention(RetentionPolicy.SOURCE)
public @interface State {}
public static final String STATE_REOPENED = "reopened";
public static final String STATE_CLOSED = "closed";
public static final String STATE_ACTIVE = "active";
public static final String STATE_OPENED = "opened";
@StringDef({STATE_REOPEN, STATE_CLOSE})
@Retention(RetentionPolicy.SOURCE)
public @interface EditState {}
public static final String STATE_REOPEN = "reopen";
public static final String STATE_CLOSE = "close";
@SerializedName("id")
long id;
@SerializedName("iid")
long iid;
@SerializedName("project_id")
long project_id;
@SerializedName("title")
String title;
@SerializedName("description")
String description;
@SerializedName("labels")
String[] labels;
@SerializedName("milestone")
Milestone milestone;
@SerializedName("assignee")
User assignee;
@SerializedName("author")
User author;
@SerializedName("state")
String state;
@SerializedName("updated_at")
Date updated_at;
@SerializedName("created_at")
Date created_at;
 
public Issue(){}
Loading
Loading
@@ -56,9 +89,10 @@ public class Issue {
public User getAuthor() {
return author;
}
@State
public String getState() {
return state;
return state;
}
public Date getUpdatedAt() {
Loading
Loading
Loading
Loading
@@ -9,6 +9,7 @@ import android.view.View;
import com.commit451.gitlab.R;
 
/**
* All the things to do with intents
* Created by Jawn on 8/25/2015.
*/
public class IntentUtil {
Loading
Loading
@@ -28,11 +29,10 @@ public class IntentUtil {
Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.setType("text/plain");
shareIntent.putExtra(Intent.EXTRA_TEXT, url);
root.getContext().startActivity(Intent.createChooser(shareIntent, root.getContext().getString(R.string.action_share)));
try {
root.getContext().startActivity(shareIntent);
} catch (ActivityNotFoundException e) {
Snackbar.make(root, R.string.error_no_browser, Snackbar.LENGTH_SHORT)
Snackbar.make(root, R.string.error_could_not_share, Snackbar.LENGTH_SHORT)
.show();
}
}
Loading
Loading
package com.commit451.gitlab.viewHolders;
 
import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.text.format.DateUtils;
import android.text.method.LinkMovementMethod;
import android.view.LayoutInflater;
Loading
Loading
@@ -11,6 +12,7 @@ import android.widget.TextView;
 
import com.commit451.gitlab.R;
import com.commit451.gitlab.model.Issue;
import com.commit451.gitlab.tools.ImageUtil;
import com.squareup.picasso.Picasso;
 
import butterknife.Bind;
Loading
Loading
@@ -28,31 +30,33 @@ public class IssueHeaderViewHolder extends RecyclerView.ViewHolder {
return new IssueHeaderViewHolder(view);
}
 
@Bind(R.id.title) TextView title;
@Bind(R.id.description) TextView description;
@Bind(R.id.author_image) ImageView authorImage;
@Bind(R.id.author) TextView author;
@Bind(R.id.date_added) TextView dateAdded;
Bypass mBypass;
 
public IssueHeaderViewHolder(View view) {
super(view);
ButterKnife.bind(this, view);
mBypass = new Bypass(view.getContext());
}
 
public void bind(Issue issue) {
title.setText(issue.getTitle());
Bypass bypass = new Bypass();
String desc = issue.getDescription();
if(desc == null) {
desc = "";
if (TextUtils.isEmpty(issue.getDescription())) {
description.setVisibility(View.GONE);
} else {
description.setVisibility(View.VISIBLE);
description.setText(mBypass.markdownToSpannable(issue.getDescription()));
description.setMovementMethod(LinkMovementMethod.getInstance());
}
description.setText(bypass.markdownToSpannable(desc));
description.setMovementMethod(LinkMovementMethod.getInstance());
if (issue.getAuthor() != null) {
Picasso.with(itemView.getContext())
.load(issue.getAuthor().getAvatarUrl())
.load(ImageUtil.getGravatarUrl(issue.getAuthor(), itemView.getResources().getDimensionPixelSize(R.dimen.image_size)))
.into(authorImage);
author.setText(issue.getAuthor().getName());
author.setText(issue.getAuthor().getName() + " "
+ itemView.getResources().getString(R.string.created_issue) + " "
+ DateUtils.getRelativeTimeSpanString(issue.getCreatedAt().getTime()));
}
if (issue.getCreatedAt() != null) {
DateUtils.getRelativeTimeSpanString(issue.getCreatedAt().getTime());
Loading
Loading
Loading
Loading
@@ -12,6 +12,7 @@ import android.support.v4.view.ViewCompat;
import android.util.AttributeSet;
import android.util.TypedValue;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.ImageView;
Loading
Loading
@@ -124,8 +125,8 @@ public class GitLabNavigationView extends NavigationView {
private void init() {
setNavigationItemSelectedListener(mOnNavigationItemSelectedListener);
inflateMenu(R.menu.navigation);
inflateHeaderView(R.layout.nav_drawer);
ButterKnife.bind(this);
View header = inflateHeaderView(R.layout.nav_drawer);
ButterKnife.bind(this, header);
mInsetForeground = new ColorDrawable(Color.parseColor("#44000000"));
setSelectedNavigationItem();
loadCurrentUser();
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