-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBottomSheetForShopImage.java
More file actions
67 lines (51 loc) · 2.06 KB
/
BottomSheetForShopImage.java
File metadata and controls
67 lines (51 loc) · 2.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package com.ikai.unitshop;
import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.design.widget.BottomSheetDialogFragment;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
/**
* Created by shiv on 2/12/17.
*/
public class BottomSheetForShopImage extends BottomSheetDialogFragment
implements View.OnClickListener {
private Communicator communicator;
@Override
public void setupDialog(Dialog dialog, int style) {
super.setupDialog(dialog, style);
// Get activity reference to Communicator object, so we can call communicate function
// on this object.
communicator = ((Communicator) getFragmentManager().findFragmentByTag("Home"));
// Inflate view and set it to dialog.
View contentView = View.inflate(getActivity(), R.layout.bottom_sheet_for_shop_image, null);
dialog.setContentView(contentView);
// Get reference for camera and gallery icon container.
LinearLayout cameraIconContainer = contentView.findViewById(R.id.camera_container);
LinearLayout galleryIconContainer = contentView.findViewById(R.id.gallery_container);
// Set on click listener for both camera and gallery icon containers.
cameraIconContainer.setOnClickListener(this);
galleryIconContainer.setOnClickListener(this);
}
@Override
public void onClick(View view) {
int id = view.getId();
// Check for camera click.
if (id == R.id.camera_container) {
// Call fragment implemented communicate() function with code 1.
communicator.communicate(1);
dismiss();
}
// Check for gallery click.
if (id == R.id.gallery_container) {
// Call fragment implemented communicate() function with code 2.
communicator.communicate(2);
dismiss();
}
}
public interface Communicator {
void communicate(int resultCode);
}
}