Skip to content

Commit

Permalink
fix openMF#1770 & openMF#1772: Error handling added to Client & Group…
Browse files Browse the repository at this point in the history
…DetailsFragment
  • Loading branch information
PatelVatsalB21 committed Feb 15, 2021
1 parent c59191c commit 7ea8c45
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import android.widget.TextView;
import android.widget.Toast;

import com.github.therajanmaurya.sweeterror.SweetUIErrorHandler;
import com.joanzapata.iconify.fonts.MaterialIcons;
import com.joanzapata.iconify.widget.IconTextView;
import com.mifos.mifosxdroid.R;
Expand Down Expand Up @@ -172,7 +173,9 @@ public class ClientDetailsFragment extends MifosBaseFragment implements ClientDe
@Inject
ClientDetailsPresenter mClientDetailsPresenter;

private View rootView;
private LinearLayout mainLayout;
private SweetUIErrorHandler sweetUIErrorHandler;
private View rootView, layoutError;
private OnFragmentInteractionListener mListener;
private File clientImageFile = new File(Environment.getExternalStorageDirectory().toString() +
"/client_image.png");
Expand Down Expand Up @@ -212,7 +215,9 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle

ButterKnife.bind(this, rootView);
mClientDetailsPresenter.attachView(this);

mainLayout = rootView.findViewById(R.id.ll_clientDetails);
layoutError = rootView.findViewById(R.id.layout_error);
sweetUIErrorHandler = new SweetUIErrorHandler(getActivity(), rootView);
inflateClientInformation();

return rootView;
Expand Down Expand Up @@ -682,9 +687,16 @@ public void onItemClick(AdapterView<?> adapterView, View view, int i,
}
}

@OnClick(R.id.btn_try_again)
public void reloadOnError() {
sweetUIErrorHandler.hideSweetErrorLayoutUI(mainLayout, layoutError);
mClientDetailsPresenter.loadClientDetailsAndClientAccounts(clientId);
}

@Override
public void showFetchingError(String s) {
Toast.makeText(getActivity(), s, Toast.LENGTH_SHORT).show();
sweetUIErrorHandler.showSweetErrorUI(String.valueOf(s), R.drawable.ic_error_black_24dp,
mainLayout, layoutError);
}

public interface OnFragmentInteractionListener {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import android.widget.TextView;
import android.widget.Toast;

import com.github.therajanmaurya.sweeterror.SweetUIErrorHandler;
import com.joanzapata.iconify.fonts.MaterialIcons;
import com.joanzapata.iconify.widget.IconTextView;
import com.mifos.mifosxdroid.R;
Expand Down Expand Up @@ -100,8 +101,9 @@ public class GroupDetailsFragment extends MifosBaseFragment implements GroupDeta

@Inject
GroupDetailsPresenter mGroupDetailsPresenter;

private View rootView;
private LinearLayout mainLayout;
private SweetUIErrorHandler sweetUIErrorHandler;
private View rootView, layoutError;
private int groupId;
private AccountAccordion accountAccordion;
private OnFragmentInteractionListener mListener;
Expand Down Expand Up @@ -131,7 +133,9 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle

ButterKnife.bind(this, rootView);
mGroupDetailsPresenter.attachView(this);

mainLayout = rootView.findViewById(R.id.ll_groupDetails);
layoutError = rootView.findViewById(R.id.layout_error);
sweetUIErrorHandler = new SweetUIErrorHandler(getActivity(), rootView);
mGroupDetailsPresenter.loadGroupDetailsAndAccounts(groupId);

return rootView;
Expand Down Expand Up @@ -299,9 +303,16 @@ public void onItemClick(AdapterView<?> adapterView, View view, int i,
}
}

@OnClick(R.id.btn_try_again)
public void reloadOnError() {
sweetUIErrorHandler.hideSweetErrorLayoutUI(mainLayout, layoutError);
mGroupDetailsPresenter.loadGroupDetailsAndAccounts(groupId);
}

@Override
public void showFetchingError(int errorMessage) {
Toast.makeText(getActivity(), getStringMessage(errorMessage), Toast.LENGTH_SHORT).show();
sweetUIErrorHandler.showSweetErrorUI(getStringMessage(errorMessage),
R.drawable.ic_error_black_24dp, mainLayout, layoutError);
}

@Override
Expand Down
16 changes: 12 additions & 4 deletions mifosng-android/src/main/res/layout/fragment_client_details.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginStart="@dimen/default_padding"
android:layout_marginEnd="@dimen/default_padding"
android:id="@+id/rl_client">

<ScrollView style="@style/ScrollView.Base">
<ScrollView style="@style/ScrollView.Base"
android:layout_marginStart="@dimen/default_padding"
android:layout_marginEnd="@dimen/default_padding">

<LinearLayout style="@style/LinearLayout.Base">
<LinearLayout style="@style/LinearLayout.Base"
android:id="@+id/ll_clientDetails">

<LinearLayout style="@style/LinearLayout.Width">

Expand Down Expand Up @@ -190,4 +191,11 @@
android:background="@color/accent" />
</LinearLayout>

<include
android:layout_width="match_parent"
android:layout_height="match_parent"
layout="@layout/layout_sweet_exception_handler"
android:visibility="gone"
android:id="@+id/layout_error"/>

</RelativeLayout>
16 changes: 12 additions & 4 deletions mifosng-android/src/main/res/layout/fragment_group_details.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginStart="@dimen/default_padding"
android:layout_marginEnd="@dimen/default_padding"
android:id="@+id/rl_group">

<ScrollView style="@style/ScrollView.Base">
<ScrollView style="@style/ScrollView.Base"
android:layout_marginStart="@dimen/default_padding"
android:layout_marginEnd="@dimen/default_padding">

<LinearLayout style="@style/LinearLayout.Base">
<LinearLayout style="@style/LinearLayout.Base"
android:id="@+id/ll_groupDetails">

<LinearLayout style="@style/LinearLayout.Width">

Expand Down Expand Up @@ -158,4 +159,11 @@
android:background="@color/accent" />
</LinearLayout>

<include
android:layout_width="match_parent"
android:layout_height="match_parent"
layout="@layout/layout_sweet_exception_handler"
android:visibility="gone"
android:id="@+id/layout_error"/>

</RelativeLayout>

0 comments on commit 7ea8c45

Please sign in to comment.