Skip to content

Commit

Permalink
documentation: openMF#182 - Added documentation to Invoice package
Browse files Browse the repository at this point in the history
  • Loading branch information
theamritanair committed Feb 12, 2019
1 parent 8d3d61f commit 0ef0489
Show file tree
Hide file tree
Showing 6 changed files with 118 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<InvoicePresenter> {

void showInvoiceDetails(Invoice invoice, String merchantId, String paymentLink);
Expand All @@ -23,12 +28,18 @@ interface InvoiceView extends BaseView<InvoicePresenter> {
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<InvoicesPresenter> {

void showSnackbar(String message);
Expand All @@ -40,6 +51,9 @@ interface InvoicesView extends BaseView<InvoicesPresenter> {
void hideProgress();
}

/**
* Contains all the functions of the Invoices Presenter component.
*/
interface InvoicesPresenter extends BasePresenter {


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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,
Expand All @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {

Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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() {
Expand All @@ -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<Invoice> invoiceList) {
if (invoiceList == null || invoiceList.size() == 0) {
Expand All @@ -128,16 +142,27 @@ public void showInvoices(List<Invoice> 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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) {

Expand All @@ -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);
Expand All @@ -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) {
Expand All @@ -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<Invoice> invoices) {
this.mInvoiceList = invoices;
notifyDataSetChanged();
}

/**
* This function returns the Invoice List.
* @return Invoice list of the type Invoice.
*/
public List<Invoice> 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)
Expand Down

0 comments on commit 0ef0489

Please sign in to comment.