FileDocCategorySizeDatePackage
PrintErrorFragment.javaAPI DocAndroid 5.1 API3230Thu Mar 12 22:22:42 GMT 2015com.android.printspooler.ui

PrintErrorFragment

public final class PrintErrorFragment extends android.app.Fragment
Fragment for showing an error UI.

Fields Summary
public static final int
ACTION_NONE
public static final int
ACTION_RETRY
private static final String
EXTRA_MESSAGE
private static final String
EXTRA_ACTION
Constructors Summary
Methods Summary
public static com.android.printspooler.ui.PrintErrorFragmentnewInstance(java.lang.CharSequence message, int action)


       
          
    

           
        Bundle arguments = new Bundle();
        arguments.putCharSequence(EXTRA_MESSAGE, message);
        arguments.putInt(EXTRA_ACTION, action);
        PrintErrorFragment fragment = new PrintErrorFragment();
        fragment.setArguments(arguments);
        return fragment;
    
public android.view.ViewonCreateView(android.view.LayoutInflater inflater, android.view.ViewGroup root, android.os.Bundle savedInstanceState)

        return inflater.inflate(R.layout.print_error_fragment, root, false);
    
public voidonViewCreated(android.view.View view, android.os.Bundle savedInstanceState)

        super.onViewCreated(view, savedInstanceState);

        CharSequence message = getArguments().getCharSequence(EXTRA_MESSAGE);

        if (!TextUtils.isEmpty(message)) {
            TextView messageView = (TextView) view.findViewById(R.id.message);
            messageView.setText(message);
        }

        Button actionButton = (Button) view.findViewById(R.id.action_button);

        final int action = getArguments().getInt(EXTRA_ACTION);
        switch (action) {
            case ACTION_RETRY: {
                actionButton.setVisibility(View.VISIBLE);
                actionButton.setText(R.string.print_error_retry);
            } break;

            case ACTION_NONE: {
                actionButton.setVisibility(View.GONE);
            } break;
        }

        actionButton.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View view) {
                Activity activity = getActivity();
                if (activity instanceof OnActionListener) {
                    ((OnActionListener) getActivity()).onActionPerformed();
                }
            }
        });