public void setContentView(int layoutResId) {
   if (layoutResId == R.layout.error) {
     super.setContentView(layoutResId);
   } else {
     LayoutInflater layoutInflater = LayoutInflater.from(this);
     View contentView = layoutInflater.inflate(layoutResId, null);
     setContentView(contentView);
   }
 }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if (isOnline()) {
      super.setContentView(R.layout.fragment_progress);
    } else {
      setErrorView();
    }
  }