This repository has been archived by the owner on Sep 30, 2021. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 933
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding milestone to issues & pull request as well as creating milesto…
…ne from FastHub #13
- Loading branch information
Kosh
committed
Mar 4, 2017
1 parent
a4699cb
commit 818b6d7
Showing
36 changed files
with
830 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
app/src/main/java/com/fastaccess/data/dao/CreateMilestoneModel.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.fastaccess.data.dao; | ||
|
||
import com.google.gson.annotations.SerializedName; | ||
|
||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
|
||
/** | ||
* Created by Kosh on 05 Mar 2017, 2:30 AM | ||
*/ | ||
|
||
@Getter @Setter @NoArgsConstructor | ||
public class CreateMilestoneModel { | ||
private String title; | ||
private String description; | ||
@SerializedName("due_one") private String dueOn; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
app/src/main/java/com/fastaccess/ui/adapter/MilestonesAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.fastaccess.ui.adapter; | ||
|
||
import android.support.annotation.NonNull; | ||
import android.view.ViewGroup; | ||
|
||
import com.fastaccess.data.dao.MilestoneModel; | ||
import com.fastaccess.ui.adapter.viewholder.MilestonesViewHolder; | ||
import com.fastaccess.ui.widgets.recyclerview.BaseRecyclerAdapter; | ||
import com.fastaccess.ui.widgets.recyclerview.BaseViewHolder; | ||
|
||
import java.util.ArrayList; | ||
|
||
/** | ||
* Created by Kosh on 11 Nov 2016, 2:07 PM | ||
*/ | ||
|
||
public class MilestonesAdapter extends BaseRecyclerAdapter<MilestoneModel, MilestonesViewHolder, | ||
BaseViewHolder.OnItemClickListener<MilestoneModel>> { | ||
|
||
public MilestonesAdapter(@NonNull ArrayList<MilestoneModel> eventsModels) { | ||
super(eventsModels); | ||
} | ||
|
||
@Override protected MilestonesViewHolder viewHolder(ViewGroup parent, int viewType) { | ||
return MilestonesViewHolder.newInstance(parent, this); | ||
} | ||
|
||
@Override protected void onBindView(MilestonesViewHolder holder, int position) { | ||
holder.bind(getItem(position)); | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
app/src/main/java/com/fastaccess/ui/adapter/viewholder/MilestonesViewHolder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package com.fastaccess.ui.adapter.viewholder; | ||
|
||
import android.support.annotation.NonNull; | ||
import android.support.annotation.Nullable; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
|
||
import com.fastaccess.R; | ||
import com.fastaccess.data.dao.MilestoneModel; | ||
import com.fastaccess.helper.ParseDateFormat; | ||
import com.fastaccess.ui.widgets.FontTextView; | ||
import com.fastaccess.ui.widgets.recyclerview.BaseRecyclerAdapter; | ||
import com.fastaccess.ui.widgets.recyclerview.BaseViewHolder; | ||
|
||
import butterknife.BindView; | ||
|
||
/** | ||
* Created by Kosh on 11 Nov 2016, 2:08 PM | ||
*/ | ||
|
||
public class MilestonesViewHolder extends BaseViewHolder<MilestoneModel> { | ||
|
||
@BindView(R.id.title) FontTextView title; | ||
@BindView(R.id.date) FontTextView date; | ||
@BindView(R.id.notificationTitle) FontTextView notificationTitle; | ||
|
||
private MilestonesViewHolder(@NonNull View itemView, @Nullable BaseRecyclerAdapter adapter) { | ||
super(itemView, adapter); | ||
} | ||
|
||
public static MilestonesViewHolder newInstance(@NonNull ViewGroup viewGroup, @Nullable BaseRecyclerAdapter adapter) { | ||
return new MilestonesViewHolder(getView(viewGroup, R.layout.notifications_row_item), adapter); | ||
} | ||
|
||
@Override public void bind(@NonNull MilestoneModel milestoneModel) { | ||
title.setText(milestoneModel.getTitle()); | ||
notificationTitle.setText(milestoneModel.getDescription()); | ||
if (milestoneModel.getDueOn() != null) { | ||
date.setText(ParseDateFormat.getTimeAgo(milestoneModel.getDueOn())); | ||
} else { | ||
date.setText(ParseDateFormat.getTimeAgo(milestoneModel.getCreatedAt())); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
app/src/main/java/com/fastaccess/ui/modules/repos/extras/milestone/MilestoneMvp.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package com.fastaccess.ui.modules.repos.extras.milestone; | ||
|
||
import android.support.annotation.NonNull; | ||
|
||
import com.fastaccess.data.dao.MilestoneModel; | ||
import com.fastaccess.ui.base.mvp.BaseMvp; | ||
import com.fastaccess.ui.modules.repos.extras.milestone.create.CreateMilestoneMvp; | ||
import com.fastaccess.ui.widgets.recyclerview.BaseViewHolder; | ||
|
||
import java.util.ArrayList; | ||
|
||
/** | ||
* Created by Kosh on 04 Mar 2017, 9:38 PM | ||
*/ | ||
|
||
public interface MilestoneMvp { | ||
|
||
|
||
interface OnMilestoneSelected { | ||
void onMilestoneSelected(@NonNull MilestoneModel milestoneModel); | ||
} | ||
|
||
interface View extends BaseMvp.FAView, CreateMilestoneMvp.OnMilestoneAdded { | ||
void onNotifyAdapter(); | ||
|
||
void onMilestoneSelected(@NonNull MilestoneModel milestoneModel); | ||
} | ||
|
||
interface Presenter extends BaseViewHolder.OnItemClickListener<MilestoneModel> { | ||
void onLoadMilestones(@NonNull String login, @NonNull String repo); | ||
|
||
@NonNull ArrayList<MilestoneModel> getMilestones(); | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
app/src/main/java/com/fastaccess/ui/modules/repos/extras/milestone/MilestonePresenter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package com.fastaccess.ui.modules.repos.extras.milestone; | ||
|
||
import android.support.annotation.NonNull; | ||
import android.view.View; | ||
|
||
import com.fastaccess.R; | ||
import com.fastaccess.data.dao.MilestoneModel; | ||
import com.fastaccess.provider.rest.RestProvider; | ||
import com.fastaccess.ui.base.mvp.presenter.BasePresenter; | ||
|
||
import java.util.ArrayList; | ||
|
||
/** | ||
* Created by Kosh on 04 Mar 2017, 9:41 PM | ||
*/ | ||
|
||
public class MilestonePresenter extends BasePresenter<MilestoneMvp.View> implements MilestoneMvp.Presenter { | ||
private ArrayList<MilestoneModel> milestoneModels = new ArrayList<>(); | ||
|
||
@Override public void onItemClick(int position, View v, MilestoneModel item) { | ||
if (getView() != null) getView().onMilestoneSelected(item); | ||
} | ||
|
||
@Override public void onItemLongClick(int position, View v, MilestoneModel item) { | ||
onItemClick(position, v, item); | ||
} | ||
|
||
@Override public void onLoadMilestones(@NonNull String login, @NonNull String repo) { | ||
makeRestCall(RestProvider.getRepoService().getMilestones(login, repo), | ||
response -> { | ||
if (response == null || response.getItems() == null || response.getItems().isEmpty()) { | ||
sendToView(view -> view.showMessage(R.string.error, R.string.no_milestones)); | ||
return; | ||
} | ||
if (response.getItems() != null) { | ||
milestoneModels.clear(); | ||
milestoneModels.addAll(response.getItems()); | ||
sendToView(MilestoneMvp.View::onNotifyAdapter); | ||
} | ||
}); | ||
} | ||
|
||
@NonNull @Override public ArrayList<MilestoneModel> getMilestones() { | ||
return milestoneModels; | ||
} | ||
} |
Oops, something went wrong.