Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #1772: Error handling added to GroupDetailsFragment #1773

Closed
wants to merge 1 commit into from
Closed
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
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>