Skip to content
This repository has been archived by the owner on Jan 11, 2024. It is now read-only.

Fix-322: Bug fixed & Improved UI in Planned Payment calendar #185

Open
wants to merge 1 commit into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
package org.apache.fineract.ui.online.loanaccounts.plannedpayment;

import android.app.DatePickerDialog;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
import androidx.appcompat.app.AppCompatActivity;
import androidx.cardview.widget.CardView;
import androidx.recyclerview.widget.RecyclerView;
import androidx.appcompat.widget.Toolbar;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CalendarView;
import android.widget.TextView;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.recyclerview.widget.RecyclerView;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;

import org.apache.fineract.R;
import org.apache.fineract.data.models.payment.PlannedPayment;
import org.apache.fineract.ui.adapters.PlannedPaymentAdapter;
Expand All @@ -39,8 +38,7 @@
* On 13/07/17.
*/
public class PlannedPaymentFragment extends FineractBaseFragment
implements PlannedPaymentContract.View, SwipeRefreshLayout.OnRefreshListener,
CalendarView.OnDateChangeListener {
implements PlannedPaymentContract.View, SwipeRefreshLayout.OnRefreshListener {

public static final String LOG_TAG = PlannedPaymentFragment.class.getSimpleName();

Expand All @@ -53,18 +51,12 @@ public class PlannedPaymentFragment extends FineractBaseFragment
@BindView(R.id.toolbar)
Toolbar toolbar;

@BindView(R.id.cv_planned_payment)
CardView cvCalenderPlannedPayment;

@BindView(R.id.layout_error)
View layoutError;

@BindView(R.id.tv_toolbar_date)
TextView tvToolbarDate;

@BindView(R.id.calender_view_payment)
CalendarView calenderViewPayment;

@Inject
PlannedPaymentAdapter plannedPaymentAdapter;

Expand All @@ -75,8 +67,9 @@ public class PlannedPaymentFragment extends FineractBaseFragment

private String productIdentifier;
private String caseIdentifier;
private boolean isCalenderVisible;
private String initialDisbursalDate = null;
private Calendar calendar = Calendar.getInstance();
private DatePickerDialog.OnDateSetListener date;

public static PlannedPaymentFragment newInstance(String productIdentifier,
String caseIdentifier) {
Expand Down Expand Up @@ -144,23 +137,30 @@ public void onLoadMore(int page, LoadCompleteNotifier loadComplete) {
initialDisbursalDate, true);
}
});
calenderViewPayment.setOnDateChangeListener(this);
tvToolbarDate.setText(DateUtils.getCurrentDate());

date = (view, year, monthOfYear, dayOfMonth) -> {
calendar.set(year, monthOfYear, dayOfMonth);

tvToolbarDate.setText(DateUtils.getDate(DateUtils.getDateInUTC(calendar),
DateUtils.STANDARD_DATE_TIME_FORMAT, DateUtils.OUTPUT_DATE_FORMAT));
initialDisbursalDate = DateUtils.getDateInUTC(calendar);

plannedPaymentPresenter.fetchPlannedPayment(productIdentifier, caseIdentifier, 0,
initialDisbursalDate, false);

};
tvToolbarDate.setText(DateUtils.getDate(DateUtils.getDateInUTC(calendar),
DateUtils.STANDARD_DATE_TIME_FORMAT, DateUtils.OUTPUT_DATE_FORMAT));
}

@OnClick(R.id.ll_toolbar_date)
void showCalender() {
if (!isCalenderVisible) {
cvCalenderPlannedPayment.setVisibility(View.VISIBLE);
isCalenderVisible = true;
tvToolbarDate.setCompoundDrawablesWithIntrinsicBounds(
0, 0, R.drawable.ic_arrow_drop_up_black_24dp, 0);
} else {
cvCalenderPlannedPayment.setVisibility(View.GONE);
tvToolbarDate.setCompoundDrawablesWithIntrinsicBounds(
0, 0, R.drawable.ic_arrow_drop_down_black_24dp, 0);
isCalenderVisible = false;
}
DatePickerDialog datePickerDialog = new DatePickerDialog(getActivity(),
R.style.MaterialDatePickerTheme, date, calendar
.get(Calendar.YEAR), calendar.get(Calendar.MONTH),
calendar.get(Calendar.DAY_OF_MONTH));
datePickerDialog.getDatePicker().setMaxDate(System.currentTimeMillis());
datePickerDialog.show();
}

@OnClick(R.id.btn_try_again)
Expand All @@ -174,25 +174,6 @@ public void onRefresh() {
initialDisbursalDate, false);
}

@OnClick(R.id.btn_load_planned_payment)
void loadPlannedPaymentAccordingToDate() {
isCalenderVisible = false;
cvCalenderPlannedPayment.setVisibility(View.GONE);
plannedPaymentPresenter.fetchPlannedPayment(productIdentifier, caseIdentifier, 0,
initialDisbursalDate, false);
}

@Override
public void onSelectedDayChange(@NonNull CalendarView view, int year, int month,
int dayOfMonth) {
Calendar calendar = Calendar.getInstance();
calendar.set(year, month, dayOfMonth);
tvToolbarDate.setText(DateUtils.getDate(DateUtils.getDateInUTC(calendar),
DateUtils.STANDARD_DATE_TIME_FORMAT, DateUtils.OUTPUT_DATE_FORMAT));
initialDisbursalDate = DateUtils.getDateInUTC(calendar);
}


@Override
public void showPlannedPayment(List<PlannedPayment> plannedPayments) {
showRecyclerView(true);
Expand Down
40 changes: 4 additions & 36 deletions app/src/main/res/layout/fragment_planned_payment.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@
android:padding="16dp">

<TextView
android:drawableEnd="@drawable/ic_arrow_drop_down_black_24dp"
android:drawableRight="@drawable/ic_arrow_drop_down_black_24dp"
android:drawableEnd="@drawable/ic_edit_black_24dp"
android:drawableRight="@drawable/ic_edit_black_24dp"
android:drawableTint="@color/white"
android:drawablePadding="@dimen/layout_padding_8dp"
android:gravity="center"
android:id="@+id/tv_toolbar_date"
android:layout_gravity="center"
Expand All @@ -50,40 +52,6 @@

</LinearLayout>

<androidx.cardview.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="@color/white"
android:clickable="true"
android:focusable="true"
android:foreground="?android:attr/selectableItemBackground"
android:id="@+id/cv_planned_payment"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:visibility="gone">

<LinearLayout
android:layout_height="match_parent"
android:layout_width="match_parent"
android:orientation="vertical">

<CalendarView
android:id="@+id/calender_view_payment"
android:layout_height="300dp"
android:layout_width="match_parent"/>

<androidx.appcompat.widget.AppCompatButton
android:id="@+id/btn_load_planned_payment"
android:layout_gravity="end"
android:layout_height="wrap_content"
android:layout_margin="@dimen/layout_padding_8dp"
android:layout_width="wrap_content"
android:text="@string/load_payment"
android:textAllCaps="false"/>

</LinearLayout>

</androidx.cardview.widget.CardView>

<androidx.coordinatorlayout.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
Expand Down