-
Notifications
You must be signed in to change notification settings - Fork 604
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: fetch & show notes for client and group
- Loading branch information
1 parent
5d929aa
commit 9f07605
Showing
18 changed files
with
730 additions
and
11 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
39 changes: 39 additions & 0 deletions
39
mifosng-android/src/main/java/com/mifos/api/datamanager/DataManagerNote.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,39 @@ | ||
package com.mifos.api.datamanager; | ||
|
||
import com.mifos.api.BaseApiManager; | ||
import com.mifos.api.local.databasehelper.DatabaseHelperNote; | ||
import com.mifos.objects.noncore.Note; | ||
|
||
import java.util.List; | ||
|
||
import javax.inject.Inject; | ||
import javax.inject.Singleton; | ||
|
||
import rx.Observable; | ||
|
||
/** | ||
* This DataManager is for Managing Notes API, In which Request is going to Server | ||
* and In Response, We are getting Notes API Observable Response using Retrofit2 | ||
* Created by rahul on 4/3/17. | ||
*/ | ||
@Singleton | ||
public class DataManagerNote { | ||
|
||
public final BaseApiManager mBaseApiManager; | ||
public final DatabaseHelperNote mDatabaseHelperNote; | ||
|
||
@Inject | ||
public DataManagerNote(BaseApiManager baseApiManager, | ||
DatabaseHelperNote databaseHelperNote) { | ||
mBaseApiManager = baseApiManager; | ||
mDatabaseHelperNote = databaseHelperNote; | ||
} | ||
|
||
|
||
/** | ||
* This Method Request the REST API of Note and In response give the List of Notes | ||
*/ | ||
public Observable<List<Note>> getNotes(String entityType, int entityId) { | ||
return mBaseApiManager.getNoteApi().getNotes(entityType, entityId); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
mifosng-android/src/main/java/com/mifos/api/local/databasehelper/DatabaseHelperNote.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,16 @@ | ||
package com.mifos.api.local.databasehelper; | ||
|
||
import javax.inject.Inject; | ||
import javax.inject.Singleton; | ||
|
||
/** | ||
* Created by rahul on 4/3/17. | ||
*/ | ||
@Singleton | ||
public class DatabaseHelperNote { | ||
|
||
@Inject | ||
public DatabaseHelperNote() { | ||
|
||
} | ||
} |
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
25 changes: 25 additions & 0 deletions
25
mifosng-android/src/main/java/com/mifos/api/services/NoteService.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,25 @@ | ||
/* | ||
* This project is licensed under the open source MPL V2. | ||
* See https://github.com/openMF/android-client/blob/master/LICENSE.md | ||
*/ | ||
package com.mifos.api.services; | ||
|
||
import com.mifos.api.model.APIEndPoint; | ||
import com.mifos.objects.noncore.Note; | ||
|
||
import java.util.List; | ||
|
||
import retrofit2.http.GET; | ||
import retrofit2.http.Path; | ||
import rx.Observable; | ||
|
||
public interface NoteService { | ||
@GET("{entityType}/{entityId}/" + APIEndPoint.NOTES) | ||
Observable<List<Note>> getNotes(@Path("entityType") String entityType, | ||
@Path("entityId") int entityId); | ||
/** | ||
* @param entityType - Type for which note is being fetched (Client or Group) | ||
* @param entityId - Id of Entity | ||
*/ | ||
} | ||
|
76 changes: 76 additions & 0 deletions
76
mifosng-android/src/main/java/com/mifos/mifosxdroid/adapters/NoteAdapter.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,76 @@ | ||
package com.mifos.mifosxdroid.adapters; | ||
|
||
import android.support.v7.widget.RecyclerView; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import android.widget.TextView; | ||
|
||
import com.mifos.mifosxdroid.R; | ||
import com.mifos.objects.noncore.Note; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import javax.inject.Inject; | ||
|
||
import butterknife.BindView; | ||
import butterknife.ButterKnife; | ||
|
||
/** | ||
* Created by rahul on 4/3/17. | ||
*/ | ||
|
||
public class NoteAdapter extends RecyclerView.Adapter<NoteAdapter.ViewHolder> { | ||
|
||
List<Note> notes; | ||
|
||
@Inject | ||
public NoteAdapter() { | ||
notes = new ArrayList<>(); | ||
} | ||
|
||
@Override | ||
public NoteAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { | ||
View view = LayoutInflater.from(parent.getContext()) | ||
.inflate(R.layout.item_note, parent, false); | ||
return new ViewHolder(view); | ||
} | ||
|
||
@Override | ||
public void onBindViewHolder(final NoteAdapter.ViewHolder holder, int position) { | ||
Note note = notes.get(position); | ||
holder.tvNote.setText(note.getNoteContent()); | ||
} | ||
|
||
|
||
public void setNotes(List<Note> notes) { | ||
this.notes = notes; | ||
notifyDataSetChanged(); | ||
} | ||
|
||
@Override | ||
public int getItemCount() { | ||
return notes.size(); | ||
} | ||
|
||
public Note getItem(int position) { | ||
return notes.get(position); | ||
} | ||
|
||
@Override | ||
public long getItemId(int i) { | ||
return 0; | ||
} | ||
|
||
public static class ViewHolder extends RecyclerView.ViewHolder { | ||
|
||
@BindView(R.id.tv_note) | ||
TextView tvNote; | ||
|
||
public ViewHolder(View v) { | ||
super(v); | ||
ButterKnife.bind(this, v); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.