@Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.year_browser);
    // set the home button in actionbar
    ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    actionBar.setTitle("Courses by Year");

    ActionBar.Tab year1Tab = actionBar.newTab().setText("Year 1");
    ActionBar.Tab year2Tab = actionBar.newTab().setText("Year 2");
    ActionBar.Tab year3Tab = actionBar.newTab().setText("Year 3");
    ActionBar.Tab year4Tab = actionBar.newTab().setText("Year 4");
    ActionBar.Tab year5Tab = actionBar.newTab().setText("Year 5");

    Fragment year1Frag = new Year1Fragment();
    Fragment year2Frag = new Year2Fragment();
    Fragment year3Frag = new Year3Fragment();
    Fragment year4Frag = new Year4Fragment();
    Fragment year5Frag = new Year5Fragment();

    year1Tab.setTabListener(new YearTabsListener(year1Frag));
    year2Tab.setTabListener(new YearTabsListener(year2Frag));
    year3Tab.setTabListener(new YearTabsListener(year3Frag));
    year4Tab.setTabListener(new YearTabsListener(year4Frag));
    year5Tab.setTabListener(new YearTabsListener(year5Frag));

    actionBar.addTab(year1Tab);
    actionBar.addTab(year2Tab);
    actionBar.addTab(year3Tab);
    actionBar.addTab(year4Tab);
    actionBar.addTab(year5Tab);
  }
  private ActionBar.Tab constructTab(final Fragment fragment) {
    ActionBar actionBar = this.getSupportActionBar();
    ActionBar.Tab tab = actionBar.newTab();

    tab.setTabListener(
        new TabListener() {
          @Override
          public void onTabSelected(Tab tab, FragmentTransaction ignore) {
            FragmentManager manager = ContactSelectionActivity.this.getSupportFragmentManager();
            FragmentTransaction ft = manager.beginTransaction();

            ft.add(R.id.fragment_container, fragment);
            ft.commit();
          }

          @Override
          public void onTabUnselected(Tab tab, FragmentTransaction ignore) {
            FragmentManager manager = ContactSelectionActivity.this.getSupportFragmentManager();
            FragmentTransaction ft = manager.beginTransaction();
            ft.remove(fragment);
            ft.commit();
          }

          @Override
          public void onTabReselected(Tab tab, FragmentTransaction ft) {}
        });

    return tab;
  }
 public void addTab(ActionBar.Tab tab, Class<?> clss, Bundle args) {
   TabInfo info = new TabInfo(clss, args);
   tab.setTag(info);
   tab.setTabListener(this);
   mTabs.add(info);
   mActionBar.addTab(tab);
   notifyDataSetChanged();
 }
 private void setupGroupsTab() {
   groupsFragment =
       (ContactSelectionGroupsFragment)
           Fragment.instantiate(this, ContactSelectionGroupsFragment.class.getName());
   ActionBar.Tab groupsTab = constructTab(groupsFragment);
   groupsTab.setIcon(R.drawable.ic_tab_groups);
   this.getSupportActionBar().addTab(groupsTab);
 }
 private void setupContactsTab() {
   contactsFragment =
       (ContactSelectionListFragment)
           Fragment.instantiate(this, ContactSelectionListFragment.class.getName());
   ActionBar.Tab contactsTab = constructTab(contactsFragment);
   contactsTab.setIcon(R.drawable.ic_tab_contacts);
   this.getSupportActionBar().addTab(contactsTab);
 }
  private void setupRecentTab() {
    recentFragment =
        (ContactSelectionRecentFragment)
            Fragment.instantiate(this, ContactSelectionRecentFragment.class.getName());

    ActionBar.Tab recentTab = constructTab(recentFragment);
    recentTab.setIcon(R.drawable.ic_tab_recent);
    this.getSupportActionBar().addTab(recentTab);
  }
Ejemplo n.º 7
0
  @Override
  public void onTabSelected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {
    // When the given tab is selected, show the tab contents in the container
    int layout = R.layout.fragment_add_clips;

    if (mMenu != null) {
      mMenu.findItem(R.id.itemInfo).setVisible(false);
      mMenu.findItem(R.id.itemTrim).setVisible(false);
    }

    if (tab.getPosition() == 0) {
      if (mMenu != null) {
        mMenu.findItem(R.id.itemForward).setEnabled(true);
      }
      layout = R.layout.fragment_add_clips;

    } else if (tab.getPosition() == 1) {
      layout = R.layout.fragment_order_clips;

      if (mMenu != null) {
        mMenu.findItem(R.id.itemInfo).setVisible(true);
        mMenu.findItem(R.id.itemTrim).setVisible(true);
        mMenu.findItem(R.id.itemForward).setEnabled(true);
      }
    } else if (tab.getPosition() == 2) {
      layout = R.layout.fragment_story_publish;
      mMenu.findItem(R.id.itemForward).setEnabled(false);
    }

    String tag = "" + layout;
    FragmentManager fm = getSupportFragmentManager();
    Fragment fragment = fm.findFragmentByTag(tag + "");

    if (fragment == null) {
      try {
        fragment = new SceneChooserFragment(layout, fm, templateJsonPath);

        Bundle args = new Bundle();
        args.putInt(SceneChooserFragment.ARG_SECTION_NUMBER, tab.getPosition() + 1);
        fragment.setArguments(args);

      } catch (IOException e) {
        Log.e("SceneEditr", "IO erorr", e);

      } catch (JSONException e) {
        Log.e("SceneEditr", "json error", e);
      }
    }

    fm.beginTransaction()
        .replace(R.id.container, fragment, tag)
        //        .addToBackStack(null)
        .commit();
  }
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    inicializarRecursos();

    setContentView(R.layout.resumenadminfranquicia_activity);
    setTitle(R.string.resumen_gerenteventas_activity_title);
    getSupportActionBar().setSubtitle(nombre_cda);

    getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    ActionBar.Tab tab = getSupportActionBar().newTab();
    tab.setText("Resumen");
    tab.setTabListener(this);
    getSupportActionBar().addTab(tab);

    ActionBar.Tab tab2 = getSupportActionBar().newTab();
    tab2.setText("Detalle");
    tab2.setTabListener(this);
    getSupportActionBar().addTab(tab2);

    processAsync();
  }
Ejemplo n.º 9
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Normally one shouldn't instantiate all these objects in the onCreate method,
    // as onCreate is called every time a configuration change occurs (orientation,
    // keyboard hidden, screen size, etc). But we are handling configuration changes
    // ourselves.

    // hide the status bar
    this.getWindow()
        .setFlags(
            WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

    // get local Bluetooth adapter
    bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
    if (bluetoothAdapter == null) {
      Toast.makeText(this, R.string.bluetooth_unavailable, Toast.LENGTH_LONG).show();
      finish();
      return;
    }

    communicator = new AndroidCommunicator(this, bluetoothAdapter);
    communicator.addListener(this);

    remoteViewCommunicator = new SocketAndroidCommunicator(this);

    DatasetModelState datasetsState = new DatasetModelState(communicator, this);
    LayerModelState layersState = new LayerModelState(communicator, this);
    PlaceModelState placesState = new PlaceModelState(communicator, this);

    ItemModelState[] states = new ItemModelState[] {datasetsState, layersState, placesState};
    for (ItemModelState state : states) {
      itemModelStates.put(state.getModel().getId(), state);
      ItemModelFragmentMenuProvider menuProvider = new EmptyMenuProvider();
      if (state == placesState) {
        menuProvider = new PlacesMenuProvider(communicator);
      }
      menuProviders.put(state.getModel().getId(), menuProvider);
    }

    controlFragment = ControlFragment.newInstance(remoteViewCommunicator);
    datasetsFragment = ItemModelFragment.newInstance(datasetsState.getModel().getId(), false);
    layersFragment = ItemModelFragment.newInstance(layersState.getModel().getId(), false);
    flatLayersFragment = ItemModelFragment.newInstance(layersState.getModel().getId(), true);
    placesFragment = ItemModelFragment.newInstance(placesState.getModel().getId(), false);
    tabFragments =
        new Fragment[] {
          controlFragment, datasetsFragment, layersFragment, flatLayersFragment, placesFragment
        };

    // create the tabs
    getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    int[] tabIds =
        new int[] {
          R.string.controls_tab,
          R.string.datasets_tab,
          R.string.layers_tab,
          R.string.flat_layers_tab,
          R.string.places_tab
        };
    for (int i = 0; i < tabIds.length; i++) {
      ActionBar.Tab tab = getSupportActionBar().newTab();
      tab.setTag(tabIds[i]);
      tab.setText(tabIds[i]);
      tab.setTabListener(this);
      getSupportActionBar().addTab(tab);
    }

    getSupportActionBar().setDisplayShowTitleEnabled(false);
    getSupportActionBar().setHomeButtonEnabled(true);

    // setup the shake sensor
    sensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
    sensorListener.setOnShakeListener(
        new ShakeEventListener.OnShakeListener() {
          @Override
          public void onShake() {
            communicator.sendMessage(new ShakeMessage());
          }
        });

    // Acquire a reference to the system Location Manager
    LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);

    // Define a listener that responds to location updates
    LocationListener locationListener =
        new LocationListener() {
          public void onLocationChanged(Location location) {
            if (isSendLocation()) {
              communicator.sendMessage(
                  new LocationMessage(
                      location.getLatitude(),
                      location.getLongitude(),
                      location.getAltitude(),
                      location.getAccuracy(),
                      location.getBearing()));
            }
          }

          public void onStatusChanged(String provider, int status, Bundle extras) {}

          public void onProviderEnabled(String provider) {}

          public void onProviderDisabled(String provider) {}
        };
    locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, locationListener);
    // locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0,
    // locationListener);
  }
    public void update() {
      final ActionBar.Tab tab = mTab;
      final View custom = tab.getCustomView();
      if (custom != null) {
        final ViewParent customParent = custom.getParent();
        if (customParent != this) {
          if (customParent != null) ((ViewGroup) customParent).removeView(custom);
          addView(custom);
        }
        mCustomView = custom;
        if (mTextView != null) mTextView.setVisibility(GONE);
        if (mIconView != null) {
          mIconView.setVisibility(GONE);
          mIconView.setImageDrawable(null);
        }
      } else {
        if (mCustomView != null) {
          removeView(mCustomView);
          mCustomView = null;
        }

        final Drawable icon = tab.getIcon();
        final CharSequence text = tab.getText();

        if (icon != null) {
          if (mIconView == null) {
            ImageView iconView = new ImageView(getContext());
            LayoutParams lp =
                new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
            lp.gravity = Gravity.CENTER_VERTICAL;
            iconView.setLayoutParams(lp);
            addView(iconView, 0);
            mIconView = iconView;
          }
          mIconView.setImageDrawable(icon);
          mIconView.setVisibility(VISIBLE);
        } else if (mIconView != null) {
          mIconView.setVisibility(GONE);
          mIconView.setImageDrawable(null);
        }

        if (text != null) {
          if (mTextView == null) {
            CapitalizingTextView textView =
                new CapitalizingTextView(getContext(), null, R.attr.actionBarTabTextStyle);
            textView.setEllipsize(TruncateAt.END);
            LayoutParams lp =
                new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
            lp.gravity = Gravity.CENTER_VERTICAL;
            textView.setLayoutParams(lp);
            addView(textView);
            mTextView = textView;
          }
          mTextView.setTextCompat(text);
          mTextView.setVisibility(VISIBLE);
        } else if (mTextView != null) {
          mTextView.setVisibility(GONE);
          mTextView.setText(null);
        }

        if (mIconView != null) {
          mIconView.setContentDescription(tab.getContentDescription());
        }
      }
    }
Ejemplo n.º 11
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    resolver = getContentResolver();
    Cursor cursor = null;

    int cameraId = 0;
    String title = "";
    String url = "";
    boolean hasVideo = false;
    int isStarred = 0;

    String[] projection = {
      Cameras.CAMERA_ID,
      Cameras.CAMERA_TITLE,
      Cameras.CAMERA_URL,
      Cameras.CAMERA_HAS_VIDEO,
      Cameras.CAMERA_IS_STARRED
    };

    Bundle b = getIntent().getExtras();
    int id = b.getInt("id");

    try {
      cursor =
          resolver.query(
              Cameras.CONTENT_URI,
              projection,
              Cameras.CAMERA_ID + "=?",
              new String[] {Integer.toString(id)},
              null);

      if (cursor != null && cursor.moveToFirst()) {
        cameraId = cursor.getInt(0);
        title = cursor.getString(1);
        url = cursor.getString(2);
        hasVideo = cursor.getInt(3) != 0;
        isStarred = cursor.getInt(4);
      }
    } finally {
      if (cursor != null) {
        cursor.close();
      }
    }

    Bundle args = new Bundle();
    args.putInt("id", cameraId);
    args.putString("title", title);
    args.putString("url", url);
    args.putInt("isStarred", isStarred);

    getSupportActionBar().setTitle(title);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    ActionBar.Tab reportTab = getSupportActionBar().newTab();
    reportTab.setText("Camera");
    reportTab.setTabListener(
        new TabListener<CameraImageFragment>(this, "Camera", CameraImageFragment.class, args));
    getSupportActionBar().addTab(reportTab);

    if (hasVideo) {
      ActionBar.Tab camerasTab = getSupportActionBar().newTab();
      camerasTab.setText("Video");
      camerasTab.setTabListener(
          new TabListener<CameraVideoFragment>(this, "Video", CameraVideoFragment.class, args));
      getSupportActionBar().addTab(camerasTab);
    }

    if (savedInstanceState != null) {
      getSupportActionBar().setSelectedNavigationItem(savedInstanceState.getInt("tab", 0));
    }
  }