;
import android.os.Bundle;
import android.support.constraint.ConstraintLayout;
import android.support.v4.app.DialogFragment;
import android.view.Gravity;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.ImageView;
import com.electric.chargingpile.R;
public class ReportParkingDialogFragment extends DialogFragment implements View.OnClickListener {
public static final String TYPE_FIRST = "first";
public static final String TYPE_SECOND = "second";
public static final String TYPE_THIRD = "third";
private static Dialog mDialog;
private String mType;
private ConstraintLayout container;
private ConstraintLayout first;
private ImageView first_close;
private ConstraintLayout second;
private ImageView second_close;
private Button cancel_report;
private Button report;
private ConstraintLayout third;
private ImageView third_close;
private OnReportParkingDialogFragmentListener reportParkingDialogFragmentListener;
public static ReportParkingDialogFragment newInstance(String type) {
Bundle args = new Bundle();
args.putSerializable("type", type);
ReportParkingDialogFragment fragment = new ReportParkingDialogFragment();
fragment.setArguments(args);
return fragment;
}
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
mDialog = new Dialog(getActivity(), R.style.CenterDialog);
mDialog.setCancelable(true);
mDialog.setCanceledOnTouchOutside(true);
mDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
mDialog.setContentView(R.layout.fragment_dialog_report_parking);
Window window = mDialog.getWindow();
WindowManager.LayoutParams layoutParams = window.getAttributes();
// 布局属性位于整个窗口底部
layoutParams.gravity = Gravity.CENTER;
// 布局属性宽度填充整个窗口,默认是有margin的
layoutParams.width = WindowManager.LayoutParams.MATCH_PARENT;
window.setAttributes(layoutParams);
initDialog();
initListener();
return mDialog;
}
private void initDialog() {
mType = (String)getArguments().get("type");
container = mDialog.findViewById(R.id.container);
first = mDialog.findViewById(R.id.first);
first_close = mDialog.findViewById(R.id.first_close);
second = mDialog.findViewById(R.id.second);
second_close = mDialog.findViewById(R.id.second_close);
cancel_report = mDialog.findViewById(R.id.cancel_report);
report = mDialog.findViewById(R.id.report);
third = mDialog.findViewById(R.id.third);
third_close = mDialog.findViewById(R.id.third_close);
if (TYPE_FIRST.equals(mType)) {
first.setVisibility(View.VISIBLE);
second.setVisibility(View.GONE);
third.setVisibility(View.GONE);
} else if (TYPE_SECOND.equals(mType)) {
first.setVisibility(View.GONE);
second.setVisibility(View.VISIBLE);
third.setVisibility(View.GONE);
} else {
first.setVisibility(View.GONE);
second.setVisibility(View.GONE);
third.setVisibility(View.VISIBLE);
}
}
private void initListener() {
container.setOnClickListener(this);
first.setOnClickListener(this);
first_close.setOnClickListener(this);
second.setOnClickListener(this);
second_close.setOnClickListener(this);
cancel_report.setOnClickListener(this);
report.setOnClickListener(this);
third.setOnClickListener(this);
third_close.setOnClickListener(this);
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.container:
mDialog.dismiss();
break;
case R.id.first_close:
mDialog.dismiss();
break;
case R.id.second_close:
mDialog.dismiss();
break;
case R.id.cancel_report:
mDialog.dismiss();
break;
case R.id.report:
if (reportParkingDialogFragmentListener != null) {
reportParkingDialogFragmentListener.report();
}
mDialog.dismiss();
break;
case R.id.third_close:
mDialog.dismiss();
break;
}
}
public interface OnReportParkingDialogFragmentListener {
void report();
}
public void setOnReportParkingDialogFragmentListener(OnReportParkingDialogFragmentListener listener) {
this.reportParkingDialogFragmentListener = listener;
}
}
|
||
| 12 | 12 |
|
| 13 | 13 |
|
| 14 | 14 |
|
| 15 |
|
|
| 16 |
|
|
| 17 | 15 |
|
| 18 | 16 |
|
| 19 | 17 |
|
|
||
| 52 | 50 |
|
| 53 | 51 |
|
| 54 | 52 |
|
| 55 |
|
|
| 53 |
|
|
| 56 | 54 |
|
| 57 | 55 |
|
| 58 | 56 |
|
|
||
| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
|
||
| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
|
||
| 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 |
|
|
| 68 |
|
|
| 69 |
|
|
| 70 |
|
|
| 71 |
|
|
| 72 |
|
|
| 73 |
|
|
| 74 |
|
|
| 75 |
|
|
| 76 |
|
|
| 77 |
|
|
| 78 |
|
|
| 79 |
|
|
| 80 |
|
|
| 81 |
|
|
| 82 |
|
|
| 83 |
|
|
| 84 |
|
|
| 85 |
|
|
| 86 |
|
|
| 87 |
|
|
| 88 |
|
|
| 89 |
|
|
| 90 |
|
|
| 91 |
|
|
| 92 |
|
|
| 93 |
|
|
| 94 |
|
|
| 95 |
|
|
| 96 |
|
|
| 97 |
|
|
| 98 |
|
|
| 99 |
|
|
| 100 |
|
|
| 101 |
|
|
| 102 |
|
|
| 103 |
|
|
| 104 |
|
|
| 105 |
|
|
| 106 |
|
|
| 107 |
|
|
| 108 |
|
|
| 109 |
|
|
| 110 |
|
|
| 111 |
|
|
| 112 |
|
|
| 113 |
|
|
| 114 |
|
|
| 115 |
|
|
| 116 |
|
|
| 117 |
|
|
| 118 |
|
|
| 119 |
|
|
| 120 |
|
|
| 121 |
|
|
| 122 |
|
|
| 123 |
|
|
| 124 |
|
|
| 125 |
|
|
| 126 |
|
|
| 127 |
|
|
| 128 |
|
|
| 129 |
|
|
| 130 |
|
|
| 131 |
|
|
| 132 |
|
|
| 133 |
|
|
| 134 |
|
|
| 135 |
|
|
| 136 |
|
|
| 137 |
|
|
| 138 |
|
|
| 139 |
|
|
| 140 |
|
|
| 141 |
|
|
| 142 |
|
|
| 143 |
|
|
| 144 |
|
|
| 145 |
|
|
| 146 |
|
|
| 147 |
|
|
| 148 |
|
|
| 149 |
|
|
| 150 |
|
|
| 151 |
|
|
| 152 |
|
|
| 153 |
|
|
| 154 |
|
|
| 155 |
|
|
| 156 |
|
|
| 157 |
|
|
| 158 |
|
|
| 159 |
|
|
| 160 |
|
|
| 161 |
|
|
| 162 |
|
|
| 163 |
|
|
| 164 |
|
|
| 165 |
|
|
| 166 |
|
|
| 167 |
|
|
| 168 |
|
|
| 169 |
|
|
| 170 |
|
|
| 171 |
|
|
| 172 |
|
|
| 173 |
|
|
| 174 |
|
|
| 175 |
|
|
| 176 |
|
|
| 177 |
|
|
| 178 |
|
|
| 179 |
|
|
| 180 |
|
|
| 181 |
|
|
| 182 |
|
|
| 183 |
|
|
| 184 |
|
|
| 185 |
|
|
| 186 |
|
|
| 187 |
|
|
| 188 |
|
|
| 189 |
|
|
| 190 |
|
|
| 191 |
|
|
| 192 |
|
|
| 193 |
|
|
| 194 |
|
|
| 195 |
|
|
| 196 |
|
|
| 197 |
|
|
| 198 |
|
|
| 199 |
|
|
| 200 |
|
|
| 201 |
|
|
| 202 |
|
|
| 203 |
|
|
| 204 |
|
|
| 205 |
|
|
| 206 |
|
|
| 207 |
|
|
| 208 |
|
|
| 209 |
|
|
| 210 |
|
|
| 211 |
|
|
| 212 |
|
|
| 213 |
|
|
| 214 |
|
|
| 215 |
|
|
| 216 |
|
|
| 217 |
|
|
| 218 |
|
|
| 219 |
|
|
| 220 |
|
|
| 221 |
|
|
| 222 |
|
|
| 223 |
|
|
| 224 |
|
|
|
||
| 6 | 6 |
|
| 7 | 7 |
|
| 8 | 8 |
|
| 9 |
|
|
| 9 | 10 |
|
| 10 | 11 |
|
| 11 | 12 |
|
|
||
| 18 | 19 |
|
| 19 | 20 |
|
| 20 | 21 |
|
| 22 |
|
|
| 23 |
|
|
| 24 |
|
|
| 25 |
|
|
| 26 |
|
|
| 27 |
|
|
| 28 |
|
|
| 21 | 29 |
|
| 22 | 30 |
|
| 23 | 31 |
|