blob: 96aa153d52c9844c688fd22249c35d81439e23dc [file] [log] [blame]
Svetoslava798c0a2014-05-15 10:47:19 -07001/*
2 * Copyright (C) 2014 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package com.android.printspooler.ui;
18
19import android.app.Activity;
20import android.app.Fragment;
21import android.os.Bundle;
22import android.view.LayoutInflater;
23import android.view.View;
24import android.view.ViewGroup;
25import android.view.View.OnClickListener;
26import android.widget.Button;
27
28import android.widget.TextView;
29import com.android.printspooler.R;
30
31/**
32 * Fragment for showing a work in progress UI.
33 */
34public final class PrintProgressFragment extends Fragment {
35
36 public interface OnCancelRequestListener {
37 public void onCancelRequest();
38 }
39
40 public static PrintProgressFragment newInstance() {
41 return new PrintProgressFragment();
42 }
43
44 @Override
45 public View onCreateView(LayoutInflater inflater, ViewGroup root,
46 Bundle savedInstanceState) {
47 return inflater.inflate(R.layout.print_progress_fragment, root, false);
48 }
49
50 @Override
51 public void onViewCreated(View view, Bundle savedInstanceState) {
52 super.onViewCreated(view, savedInstanceState);
53
54 final Button cancelButton = (Button) view.findViewById(R.id.cancel_button);
55 final TextView message = (TextView) view.findViewById(R.id.message);
56
57 cancelButton.setOnClickListener(new OnClickListener() {
58 @Override
59 public void onClick(View view) {
60 Activity activity = getActivity();
61 if (activity instanceof OnCancelRequestListener) {
62 ((OnCancelRequestListener) getActivity()).onCancelRequest();
63 }
64 cancelButton.setVisibility(View.GONE);
65 message.setVisibility(View.VISIBLE);
66 }
67 });
68 }
69}