mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-05-05 13:46:42 +00:00
Merge pull request #724 from dinesh3434/leave-party
Leave party Confirmation
This commit is contained in:
commit
0872c2bcd4
2 changed files with 16 additions and 5 deletions
|
|
@ -387,6 +387,8 @@ To start, which parts of your life do you want to improve?</string>
|
|||
<string name="scan_qr_code">Scan QR Code</string>
|
||||
<string name="enter_recipient_uuid">Enter Recipient\'s User ID</string>
|
||||
<string name="invited_to_party">You were invited to join a party!</string>
|
||||
<string name="party_leave">Leave Party</string>
|
||||
<string name="party_leave_confirmation">Are you sure you want to leave the Party?</string>
|
||||
<string name="stats_widget_label">Habitica Stats</string>
|
||||
<string name="add_task">Add Task</string>
|
||||
<string name="add_habit">Add Habit</string>
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ import com.magicmicky.habitrpgwrapper.lib.models.Group;
|
|||
import com.magicmicky.habitrpgwrapper.lib.models.UserParty;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
|
|
@ -159,11 +160,19 @@ public class PartyFragment extends BaseMainFragment {
|
|||
this.displayEditForm();
|
||||
return true;
|
||||
case R.id.menu_guild_leave:
|
||||
this.apiHelper.apiService.leaveGroup(this.group.id).compose(apiHelper.configureApiCallObserver())
|
||||
.subscribe(group -> {
|
||||
getActivity().getSupportFragmentManager().beginTransaction().remove(PartyFragment.this).commit();
|
||||
}, throwable -> {
|
||||
});
|
||||
new AlertDialog.Builder(viewPager.getContext())
|
||||
.setTitle(viewPager.getContext().getString(R.string.party_leave))
|
||||
.setMessage(viewPager.getContext().getString(R.string.party_leave_confirmation))
|
||||
.setPositiveButton(viewPager.getContext().getString(R.string.yes), (dialog, which) -> this.apiHelper.apiService.leaveGroup(this.group.id)
|
||||
.compose(apiHelper.configureApiCallObserver())
|
||||
.subscribe(group -> {
|
||||
getActivity().getSupportFragmentManager().beginTransaction().remove(PartyFragment.this).commit();
|
||||
}, throwable -> {
|
||||
}))
|
||||
.setNegativeButton(viewPager.getContext().getString(R.string.no), (dialog, which) -> {
|
||||
dialog.dismiss();
|
||||
})
|
||||
.show();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue