Advertisement
Guest User

Untitled

a guest
Nov 26th, 2015
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.11 KB | None | 0 0
  1. package com.webninja.usjr.rest;
  2.  
  3. import android.app.Dialog;
  4. import android.app.DialogFragment;
  5. import android.app.FragmentManager;
  6. import android.os.Bundle;
  7. import android.view.LayoutInflater;
  8. import android.view.View;
  9. import android.view.ViewGroup;
  10. import android.view.Window;
  11. import android.view.WindowManager.LayoutParams;
  12. import android.widget.Button;
  13. import android.widget.IconTextView;
  14. import android.widget.ProgressBar;
  15. import android.widget.TextView;
  16.  
  17. import com.joanzapata.android.iconify.Iconify;
  18. import com.webninja.usjr.R;
  19.  
  20. /**
  21. * Created by webninja on 1/25/15.
  22. */
  23. public class RestDialogFragment extends DialogFragment {
  24.  
  25.  
  26. public View onCreateView(LayoutInflater inflater, ViewGroup container,
  27. Bundle savedInstanceState) {
  28. // Inflate the layout to use as dialog or embedded fragment
  29. View view = inflater.inflate(R.layout.rest_dialog, container, false);
  30. //setStyle(DialogFragment.STYLE_NO_TITLE, R.style.MyDialog);
  31.  
  32.  
  33. TextView msg = (TextView) view.findViewById(R.id.message);
  34. msg.setText(getArguments().getString("message"));
  35.  
  36.  
  37. return view;
  38. }
  39.  
  40. /** The system calls this only when creating the layout in a dialog. */
  41. @Override
  42. public Dialog onCreateDialog(Bundle savedInstanceState) {
  43. // The only reason you might override this method when using onCreateView() is
  44. // to modify any dialog characteristics. For example, the dialog includes a
  45. // title by default, but your custom layout might not need it. So here you can
  46. // remove the dialog title, but you must call the superclass to get the Dialog.
  47. Dialog dialog = super.onCreateDialog(savedInstanceState);
  48. dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
  49. return dialog;
  50. }
  51.  
  52.  
  53. @Override
  54. public void onResume() {
  55. ViewGroup.LayoutParams params = getDialog().getWindow().getAttributes();
  56. params.width = LayoutParams.MATCH_PARENT;
  57. params.height = LayoutParams.WRAP_CONTENT;
  58. getDialog().getWindow().setAttributes((LayoutParams) params);
  59. super.onResume();
  60. }
  61.  
  62. public static RestDialogFragment newInstance(String message) {
  63. RestDialogFragment f = new RestDialogFragment();
  64. Bundle args = new Bundle();
  65. args.putString("message", message);
  66. f.setArguments(args);
  67. return f;
  68. }
  69.  
  70. public void setData(String message,Boolean isError){
  71. try{
  72.  
  73. TextView msg = (TextView) getView().findViewById(R.id.message);
  74. ProgressBar progressBar = (ProgressBar) getView().findViewById(R.id.progressBar);
  75. Button okayBtn = (Button) getView().findViewById(R.id.okay);
  76. IconTextView icon = (IconTextView) getView().findViewById(R.id.icon);
  77. if(isError){
  78. Iconify.addIcons(icon);
  79. icon.setVisibility(View.VISIBLE);
  80. //okayBtn.setVisibility(View.VISIBLE);
  81. this.setCancelable(true);
  82.  
  83. }else{
  84. progressBar.setVisibility(View.VISIBLE);
  85.  
  86. }
  87.  
  88. msg.setText(message);
  89. }catch (NullPointerException e){
  90.  
  91. }
  92. }
  93.  
  94.  
  95. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement