-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* incomplete draft of splitting home fragment * Split home fragment and implemented select/delete * addressed pr comments + added parcelable interface * put uncommon methods from parent Home to children * Rename Fragments * Merge everything nicely --------- Co-authored-by: ldbonkowski <lbonkows@ualberta.ca>
- Loading branch information
1 parent
0017939
commit 9807ac1
Showing
18 changed files
with
680 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
app/src/main/java/com/example/househomey/DeleteItemsFragment.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package com.example.househomey; | ||
|
||
import android.app.AlertDialog; | ||
import android.app.Dialog; | ||
import android.content.Context; | ||
import android.os.Bundle; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
|
||
import androidx.annotation.NonNull; | ||
import androidx.annotation.Nullable; | ||
import androidx.fragment.app.DialogFragment; | ||
|
||
import java.util.ArrayList; | ||
|
||
/** | ||
* A Dialog popup fragment that handles confirmation of deletion of items | ||
* @author Sami Jagirdar | ||
*/ | ||
public class DeleteItemsFragment extends DialogFragment { | ||
|
||
private final DeleteCallBack listener; | ||
private final ArrayList<Item> selectedItems; | ||
|
||
/** | ||
* Constructor for the Delete Items confirmation dialog fragment | ||
* @param deleteCallBack context in which the dialog fragment is attached | ||
* @param selectedItems items selected to be deleted | ||
*/ | ||
public DeleteItemsFragment(DeleteCallBack deleteCallBack, ArrayList<Item> selectedItems) { | ||
this.listener = deleteCallBack; | ||
this.selectedItems = selectedItems; | ||
} | ||
|
||
/** | ||
* Called to create and return the delete items confirmation dialog | ||
* @param savedInstanceState The last saved instance state of the Fragment, | ||
* or null if this is a freshly created Fragment. | ||
* | ||
* @return The confirm deletion dialog to be displayed | ||
*/ | ||
@NonNull | ||
@Override | ||
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) { | ||
View view = getLayoutInflater().inflate(R.layout.fragment_delete_items, null); | ||
AlertDialog.Builder builder = new AlertDialog.Builder(getContext()); | ||
|
||
return builder | ||
.setView(view) | ||
.setTitle(listener.DialogTitle(selectedItems)) | ||
.setNegativeButton("Cancel",null) | ||
.setPositiveButton("OK",(dialog,which)->{ | ||
listener.onOKPressed(selectedItems); | ||
}).create(); | ||
} | ||
|
||
/** | ||
* A Callback interface for handling deletion of items in the applicable context | ||
* @see SelectFragment | ||
*/ | ||
public interface DeleteCallBack { | ||
void onOKPressed(ArrayList<Item> selectedItems); | ||
String DialogTitle(ArrayList<Item> selectedItems); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.