Skip to content

Commit

Permalink
fix openMF#1772: Error handling added to GroupDetailsFragment
Browse files Browse the repository at this point in the history
  • Loading branch information
PatelVatsalB21 committed Feb 14, 2021
1 parent c59191c commit 1b44c45
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 8 deletions.
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_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 1b44c45

Please sign in to comment.