예제 #1
0
  /*
  Défini l'action a réaliser lorsqu'on clique sur un des boutons du menu
   */
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    Configuration config;
    switch (item.getItemId()) {
      case R.id.action_english:
        mLocale = new Locale(LOCALE_ENGLISH);
        Locale.setDefault(mLocale);
        config = new Configuration();
        config.locale = mLocale;
        getBaseContext()
            .getResources()
            .updateConfiguration(config, getBaseContext().getResources().getDisplayMetrics());
        if (User.getConnectedUser().getStatus().compareTo("client") == 0
            || User.getConnectedUser().getStatus().compareTo("user") == 0) {
          setContentView(R.layout.activity_main);
        } else {
          Barman b = new Barman(User.getConnectedUser().getId());
          if (!b.Is_manager()) {
            setContentView(R.layout.activity_main_barman);
          } else {
            setContentView(R.layout.activity_main_manager);
          }
        }
        return true;

      case R.id.action_french:
        mLocale = new Locale(LOCALE_FRANCAIS);
        Locale.setDefault(mLocale);
        config = new Configuration();
        config.locale = mLocale;
        getBaseContext()
            .getResources()
            .updateConfiguration(config, getBaseContext().getResources().getDisplayMetrics());
        if (User.getConnectedUser().getStatus().compareTo("client") == 0
            || User.getConnectedUser().getStatus().compareTo("user") == 0) {
          setContentView(R.layout.activity_main);
        } else {
          Barman b = new Barman(User.getConnectedUser().getId());
          if (!b.Is_manager()) {
            setContentView(R.layout.activity_main_barman);
          } else {
            setContentView(R.layout.activity_main_manager);
          }
        }
        return true;
    }
    return false;
  }
예제 #2
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    System.out.println("STATUS : " + User.getConnectedUser().getStatus());

    if (User.getConnectedUser().getStatus().compareTo("client") == 0
        || User.getConnectedUser().getStatus().compareTo("user") == 0) {
      setContentView(R.layout.activity_main);
    } else {
      Barman b = new Barman(User.getConnectedUser().getId());
      if (!b.Is_manager()) {
        setContentView(R.layout.activity_main_barman);
      } else {
        setContentView(R.layout.activity_main_manager);
      }
    }

    // Affichage du message de bienvenue.
    TextView welcomeTxt = (TextView) findViewById(R.id.welcomeTxt);
    welcomeTxt.setText(getString(R.string.main_welcome) + " " + User.getConnectedUser().getName());
  }