From 0ef0489b349a704168497982d8fe60dab360a1cf Mon Sep 17 00:00:00 2001 From: Amrita Date: Mon, 11 Feb 2019 17:45:16 +0530 Subject: [PATCH] documentation: #182 - Added documentation to Invoice package --- .../mifospay/invoice/InvoiceContract.java | 16 ++++++++- .../invoice/presenter/InvoicePresenter.java | 13 +++++-- .../invoice/presenter/InvoicesPresenter.java | 16 ++++++++- .../mifospay/invoice/ui/InvoiceActivity.java | 18 ++++++++++ .../mifospay/invoice/ui/InvoicesActivity.java | 25 +++++++++++++ .../invoice/ui/adapter/InvoicesAdapter.java | 35 ++++++++++++++++++- 6 files changed, 118 insertions(+), 5 deletions(-) diff --git a/mifospay/src/main/java/org/mifos/mobilewallet/mifospay/invoice/InvoiceContract.java b/mifospay/src/main/java/org/mifos/mobilewallet/mifospay/invoice/InvoiceContract.java index 636a49593..92c8eba1e 100644 --- a/mifospay/src/main/java/org/mifos/mobilewallet/mifospay/invoice/InvoiceContract.java +++ b/mifospay/src/main/java/org/mifos/mobilewallet/mifospay/invoice/InvoiceContract.java @@ -9,11 +9,16 @@ import java.util.List; /** - * Created by ankur on 07/June/2018 + * This contract class acts as interface between the UI and the Presenter components of Invoice. + * @author ankur + * @since 07/June/2018 */ public interface InvoiceContract { + /** + * Contains all the functions of the Invoice UI component. + */ interface InvoiceView extends BaseView { void showInvoiceDetails(Invoice invoice, String merchantId, String paymentLink); @@ -23,12 +28,18 @@ interface InvoiceView extends BaseView { void showToast(String message); } + /** + * Contains all the functions of the Presenter component. + */ interface InvoicePresenter extends BasePresenter { void getInvoiceDetails(Uri data); } + /** + * Contains all the functions of the Invoices UI component. + */ interface InvoicesView extends BaseView { void showSnackbar(String message); @@ -40,6 +51,9 @@ interface InvoicesView extends BaseView { void hideProgress(); } + /** + * Contains all the functions of the Invoices Presenter component. + */ interface InvoicesPresenter extends BasePresenter { diff --git a/mifospay/src/main/java/org/mifos/mobilewallet/mifospay/invoice/presenter/InvoicePresenter.java b/mifospay/src/main/java/org/mifos/mobilewallet/mifospay/invoice/presenter/InvoicePresenter.java index 226985257..f2517f5ff 100644 --- a/mifospay/src/main/java/org/mifos/mobilewallet/mifospay/invoice/presenter/InvoicePresenter.java +++ b/mifospay/src/main/java/org/mifos/mobilewallet/mifospay/invoice/presenter/InvoicePresenter.java @@ -12,7 +12,9 @@ import javax.inject.Inject; /** - * Created by ankur on 07/June/2018 + * This class contains the components of the Presenter required by Invoice. + * @author ankur + * @since 07/June/2018 */ public class InvoicePresenter implements InvoiceContract.InvoicePresenter { @@ -29,13 +31,20 @@ public InvoicePresenter(UseCaseHandler useCaseHandler, PreferencesHelper prefere mPreferencesHelper = preferencesHelper; } - + /** + * This function attaches a view. + * @param baseView This is the view to be attached. + */ @Override public void attachView(BaseView baseView) { mInvoiceView = (InvoiceContract.InvoiceView) baseView; mInvoiceView.setPresenter(this); } + /** + * This function gets the invoice details. + * @param data This of the type Uri. + */ @Override public void getInvoiceDetails(final Uri data) { diff --git a/mifospay/src/main/java/org/mifos/mobilewallet/mifospay/invoice/presenter/InvoicesPresenter.java b/mifospay/src/main/java/org/mifos/mobilewallet/mifospay/invoice/presenter/InvoicesPresenter.java index 6dc9dde95..7da505dfe 100644 --- a/mifospay/src/main/java/org/mifos/mobilewallet/mifospay/invoice/presenter/InvoicesPresenter.java +++ b/mifospay/src/main/java/org/mifos/mobilewallet/mifospay/invoice/presenter/InvoicesPresenter.java @@ -14,7 +14,9 @@ import javax.inject.Inject; /** - * Created by ankur on 11/June/2018 + * This class contains components of the Presenter required by Invoices. + * @author ankur + * @since 11/June/2018 */ public class InvoicesPresenter implements InvoiceContract.InvoicesPresenter { @@ -31,12 +33,19 @@ public InvoicesPresenter(UseCaseHandler useCaseHandler, PreferencesHelper prefer mPreferencesHelper = preferencesHelper; } + /** + * This function attaches a view. + * @param baseView This is the view to be attached. + */ @Override public void attachView(BaseView baseView) { mInvoicesView = (InvoiceContract.InvoicesView) baseView; mInvoicesView.setPresenter(this); } + /** + * This function fetches the Invoices. + */ @Override public void fetchInvoices() { mUseCaseHandler.execute(fetchInvoicesUseCase, @@ -58,6 +67,11 @@ public void onError(String message) { }); } + /** + * This function gets the Unique Invoice Link + * @param id This is the client id of the type long. + * @return Returns data of the type Uri. + */ @Override public Uri getUniqueInvoiceLink(long id) { Uri data = Uri.parse( diff --git a/mifospay/src/main/java/org/mifos/mobilewallet/mifospay/invoice/ui/InvoiceActivity.java b/mifospay/src/main/java/org/mifos/mobilewallet/mifospay/invoice/ui/InvoiceActivity.java index 832c6f78b..06707feeb 100644 --- a/mifospay/src/main/java/org/mifos/mobilewallet/mifospay/invoice/ui/InvoiceActivity.java +++ b/mifospay/src/main/java/org/mifos/mobilewallet/mifospay/invoice/ui/InvoiceActivity.java @@ -87,11 +87,21 @@ protected void onCreate(Bundle savedInstanceState) { } + /** + * This function sets the Presenter. + * @param presenter This is the presenter that will be set. + */ @Override public void setPresenter(InvoiceContract.InvoicePresenter presenter) { mInvoicePresenter = presenter; } + /** + * This function shows the Invoice details. + * @param invoice This contains the invoice details. + * @param merchantId This is the merchant ID. + * @param paymentLink This is the payment link. + */ @Override public void showInvoiceDetails(final Invoice invoice, String merchantId, String paymentLink) { @@ -156,12 +166,20 @@ public boolean onLongClick(View v) { hideProgressDialog(); } + /** + * This function shows a toast message. + * @param message This is the message that will be shown. + */ @Override public void showToast(String message) { Toaster.showToast(this, message); finish(); } + /** + * This function shows a snackbar. + * @param message This is the message that will be shown on the snackbar. + */ @Override public void showSnackbar(String message) { Toaster.show(findViewById(android.R.id.content), message); diff --git a/mifospay/src/main/java/org/mifos/mobilewallet/mifospay/invoice/ui/InvoicesActivity.java b/mifospay/src/main/java/org/mifos/mobilewallet/mifospay/invoice/ui/InvoicesActivity.java index e126df820..491b1dfeb 100644 --- a/mifospay/src/main/java/org/mifos/mobilewallet/mifospay/invoice/ui/InvoicesActivity.java +++ b/mifospay/src/main/java/org/mifos/mobilewallet/mifospay/invoice/ui/InvoicesActivity.java @@ -73,6 +73,9 @@ protected void onCreate(Bundle savedInstanceState) { setupRecyclerView(); } + /** + * This function sets up the recyclerview. + */ private void setupRecyclerView() { mRvInvoices.setLayoutManager(new LinearLayoutManager(this)); mRvInvoices.setAdapter(mInvoicesAdapter); @@ -97,6 +100,9 @@ public void onItemLongPress(View childView, int position) { })); } + /** + * This fucntion sets up the Swipe Refresh Layout. + */ private void setupSwipeRefreshLayout() { setSwipeRefreshEnabled(true); swipeLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { @@ -107,11 +113,19 @@ public void onRefresh() { }); } + /** + * This function sets the presenter. + * @param presenter This is the presenter that will be set. + */ @Override public void setPresenter(InvoiceContract.InvoicesPresenter presenter) { mInvoicesPresenter = presenter; } + /** + * This function shows the Invoices. + * @param invoiceList This is the invoice list with the invoice data. + */ @Override public void showInvoices(List invoiceList) { if (invoiceList == null || invoiceList.size() == 0) { @@ -128,16 +142,27 @@ public void showInvoices(List invoiceList) { hideSwipeProgress(); } + /** + * This function hides the Swipe Progress + */ @Override public void hideProgress() { super.hideSwipeProgress(); } + /** + * This function shows a toast message. + * @param message This is the message that will be shown. + */ @Override public void showToast(String message) { Toaster.showToast(this, message); } + /** + * This function shows a snackbar message. + * @param message This is the message that is shown on the snackbar. + */ @Override public void showSnackbar(String message) { Toaster.show(findViewById(android.R.id.content), message); diff --git a/mifospay/src/main/java/org/mifos/mobilewallet/mifospay/invoice/ui/adapter/InvoicesAdapter.java b/mifospay/src/main/java/org/mifos/mobilewallet/mifospay/invoice/ui/adapter/InvoicesAdapter.java index cde2653ee..0d272cd75 100644 --- a/mifospay/src/main/java/org/mifos/mobilewallet/mifospay/invoice/ui/adapter/InvoicesAdapter.java +++ b/mifospay/src/main/java/org/mifos/mobilewallet/mifospay/invoice/ui/adapter/InvoicesAdapter.java @@ -20,7 +20,9 @@ import butterknife.ButterKnife; /** - * Created by ankur on 11/June/2018 + * This is the adapter class that will feed data to the RecyclerView. + * @author ankur + * @since 11/June/2018 */ public class InvoicesAdapter @@ -33,6 +35,12 @@ public class InvoicesAdapter public InvoicesAdapter() { } + /** + * This function creates the viewholder and initializes/inflates the view with the given layout. + * @param parent This is the parent view. + * @param viewType This is the viewtype. + * @return This returns the viewholder after inflation. + */ @Override public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { @@ -41,6 +49,11 @@ public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { return new ViewHolder(v); } + /** + * This function displays the data at the specified position. + * @param holder This is the viewholder. + * @param position This is the position of the view. + */ @Override public void onBindViewHolder(ViewHolder holder, int position) { Invoice invoice = mInvoiceList.get(position); @@ -52,6 +65,10 @@ public void onBindViewHolder(ViewHolder holder, int position) { holder.mTvInvoiceAmount.setText(Constants.INR + invoice.getAmount()); } + /** + * This function returns the item count of the invoice list. + * @return Item count of the invoice list. + */ @Override public int getItemCount() { if (mInvoiceList != null) { @@ -61,19 +78,35 @@ public int getItemCount() { } } + /** + * This function sets the context. + * @param context This is the context that is set. + */ public void setContext(Context context) { this.context = context; } + /** + * This function sets the data to the invoice list. + * @param invoices This is the new list whose data is set. + */ public void setData(List invoices) { this.mInvoiceList = invoices; notifyDataSetChanged(); } + /** + * This function returns the Invoice List. + * @return Invoice list of the type Invoice. + */ public List getInvoiceList() { return mInvoiceList; } + /** + * This is the Viewholder class which defines all the components + * to be feeded in the RecyclerView. + */ public class ViewHolder extends RecyclerView.ViewHolder { @BindView(R.id.tv_invoice_id)