示例#1
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
    String Language = preferences.getString("Lang", "no_find");
    Locale mylocale = new Locale(Language);
    if (Language == "no_find") mylocale = Resources.getSystem().getConfiguration().locale;
    Resources res1 = getResources();
    Configuration conf = res1.getConfiguration();
    conf.locale = mylocale;
    DisplayMetrics dm = res1.getDisplayMetrics();
    res1.updateConfiguration(conf, dm);
    Locale.setDefault(mylocale);

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    // Set up the action bar.
    final ActionBar actionBar = getActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    // Create the adapter that will return a fragment for each of the three
    // primary sections of the app.
    mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());

    // Set up the ViewPager with the sections adapter.
    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(mSectionsPagerAdapter);

    // When swiping between different sections, select the corresponding
    // tab. We can also use ActionBar.Tab#select() to do this if we have
    // a reference to the Tab.
    mViewPager.setOnPageChangeListener(
        new ViewPager.SimpleOnPageChangeListener() {
          @Override
          public void onPageSelected(int position) {
            actionBar.setSelectedNavigationItem(position);
          }
        });

    // For each of the sections in the app, add a tab to the action bar.
    for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) {
      // Create a tab with text corresponding to the page title defined by
      // the adapter. Also specify this Activity object, which implements
      // the TabListener interface, as the callback (listener) for when
      // this tab is selected.
      actionBar.addTab(
          actionBar.newTab().setText(mSectionsPagerAdapter.getPageTitle(i)).setTabListener(this));
    }

    // initializes the control object which serves as the interface between the gui and
    // the usb communication
    control = (Control) getLastCustomNonConfigurationInstance();
    if (control == null) {
      Resources res = getResources();
      String[] commands = res.getStringArray(R.array.command_select_options);
      control = new Control();
      Control.initialize(commands);
    }

    //        launchAboutActivity();
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_home_screen_tab);

    final ActionBar actionBar = getSupportActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());

    // Set up the ViewPager with the sections adapter.
    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(mSectionsPagerAdapter);

    mViewPager.setOnPageChangeListener(
        new ViewPager.SimpleOnPageChangeListener() {
          @Override
          public void onPageSelected(int position) {
            actionBar.setSelectedNavigationItem(position);
            mSectionsPagerAdapter.notifyDataSetChanged();
          }
        });

    // Add all of the tabs and a listener to each tab
    for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) {
      actionBar.addTab(
          actionBar.newTab().setText(mSectionsPagerAdapter.getPageTitle(i)).setTabListener(this));
    }
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    Log.i(TAG, "setting selected id from intent");
    setSelectedItemIDFromIntent();
    ActiveUser activeUser = ((GiveOrTakeApplication) getApplication()).getActiveUser();
    if (activeUser == null || activeUser.getUserID() == null) {
      Intent logoutIntent = new Intent(this, LoginActivity.class);
      logoutIntent.putExtra(LoginFragment.EXTRA_LOGIN_ACTION, LoginFragment.LOGOUT);
      logoutIntent.putExtra(MainActivity.EXTRA_ITEM_ID, getSelectedItemID());
      startActivity(logoutIntent);
      finish();
    }

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    // Set up the action bar.
    final ActionBar actionBar = getActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    // Create the adapter that will return a fragment for each of the three
    // primary sections of the app.
    mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());

    // Set up the ViewPager with the sections adapter.
    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(mSectionsPagerAdapter);

    // When swiping between different sections, select the corresponding
    // tab. We can also use ActionBar.Tab#select() to do this if we have
    // a reference to the Tab.
    mViewPager.setOnPageChangeListener(
        new ViewPager.SimpleOnPageChangeListener() {
          @Override
          public void onPageSelected(int position) {
            actionBar.setSelectedNavigationItem(position);
          }
        });

    // For each of the sections in the app, add a tab to the action bar.
    for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) {
      // Create a tab with text corresponding to the page title defined by
      // the adapter. Also specify this Activity object, which implements
      // the TabListener interface, as the callback (listener) for when
      // this tab is selected.
      actionBar.addTab(
          actionBar
              .newTab()
              .setText(mSectionsPagerAdapter.getPageTitle(i))
              .setIcon(mSectionsPagerAdapter.getPageIcon(i))
              .setTabListener(this));
    }

    actionBar.selectTab(actionBar.getTabAt(DEFAULT_SELECTED_TAB));

    Long itemID = getSelectedItemID();
    if (itemID != null) {
      actionBar.selectTab(actionBar.getTabAt(FREE_ITEMS_TAB));
    }
  }
示例#4
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    doBindService();

    final ActionBar actionBar = getSupportActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());

    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(mSectionsPagerAdapter);

    mViewPager.setOnPageChangeListener(
        new ViewPager.SimpleOnPageChangeListener() {
          @Override
          public void onPageSelected(int position) {
            actionBar.setSelectedNavigationItem(position);
          }
        });

    // For each of the sections in the app, add a tab to the action bar.
    for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) {

      actionBar.addTab(
          actionBar.newTab().setText(mSectionsPagerAdapter.getPageTitle(i)).setTabListener(this));
    }
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    final ActionBar actionBar = getSupportActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    List<Fragment> tabs = new ArrayList<Fragment>();
    tabs.add(UsersFragment.getInstance());
    tabs.add(RoomsFragment.getInstance());

    sectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager(), tabs);

    viewPager = (ViewPager) findViewById(R.id.pager);
    viewPager.setAdapter(sectionsPagerAdapter);

    viewPager.setOnPageChangeListener(
        new ViewPager.SimpleOnPageChangeListener() {
          @Override
          public void onPageSelected(int position) {
            actionBar.setSelectedNavigationItem(position);
          }
        });

    for (int i = 0; i < sectionsPagerAdapter.getCount(); i++) {
      actionBar.addTab(
          actionBar.newTab().setText(sectionsPagerAdapter.getPageTitle(i)).setTabListener(this));
    }
  }
示例#6
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    ParseAnalytics.trackAppOpenedInBackground(getIntent());

    ParseUser currentUser = ParseUser.getCurrentUser();
    if (currentUser == null) {
      navigateToLogin();
    } else {
      Log.i(TAG, currentUser.getUsername());
    }

    // Set up the action bar.
    final ActionBar actionBar = getSupportActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    // Create the adapter that will return a fragment for each of the three
    // primary sections of the activity.
    Log.d(TAG, "Before new SectionPageAdapter");
    mSectionsPagerAdapter = new SectionsPagerAdapter(this, getSupportFragmentManager());
    Log.d(TAG, "After new SectionPageAdapter");

    // Set up the ViewPager with the sections adapter.
    Log.d(TAG, "Before findViewById(R.id.pager)");
    mViewPager = (ViewPager) findViewById(R.id.pager);
    Log.d(TAG, "After findViewById(R.id.pager)");
    Log.d(TAG, "Before setAdapter");
    mViewPager.setAdapter(mSectionsPagerAdapter);
    Log.d(TAG, "After setAdapter");

    // When swiping between different sections, select the corresponding
    // tab. We can also use ActionBar.Tab#select() to do this if we have
    // a reference to the Tab.
    mViewPager.setOnPageChangeListener(
        new ViewPager.SimpleOnPageChangeListener() {
          @Override
          public void onPageSelected(int position) {
            actionBar.setSelectedNavigationItem(position);
          }
        });
    Log.d(TAG, "Before loop");
    // For each of the sections in the app, add a tab to the action bar.
    for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) {
      // Create a tab with text corresponding to the page title defined by
      // the adapter. Also specify this Activity object, which implements
      // the TabListener interface, as the callback (listener) for when
      // this tab is selected.
      actionBar.addTab(
          actionBar.newTab().setText(mSectionsPagerAdapter.getPageTitle(i)).setTabListener(this));
    }
    Log.d(TAG, "After loop");
  }
示例#7
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    Comm.mainContext = MainActivity.this;

    findViewById(R.id.progress_bar_update).setVisibility(View.GONE);

    Comm.showsInstances = new DBHelper(this, null).loadShowsAll();
    Comm.showsFiltered = Comm.showsInstances;

    if (Comm.showsInstances.size() == 0) {
      Intent intent = new Intent(this, StartActivity.class);
      intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
      startActivity(intent);
    } else {
      getSupportLoaderManager().initLoader(3, null, this);
    }

    final ActionBar actionBar = getSupportActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());

    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(mSectionsPagerAdapter);

    mViewPager.setOnPageChangeListener(
        new ViewPager.SimpleOnPageChangeListener() {
          @Override
          public void onPageSelected(int position) {
            actionBar.setSelectedNavigationItem(position);
            if (position == 2) {
              filterView.setVisible(true);
            } else {
              filterView.setVisible(false);
            }
          }
        });

    for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) {
      actionBar.addTab(
          actionBar.newTab().setText(mSectionsPagerAdapter.getPageTitle(i)).setTabListener(this));
    }

    Bundle b = getIntent().getExtras();
    if (b != null) {
      if (b.getBoolean("via_notification", false)) {
        actionBar.setSelectedNavigationItem(1);
      }
    }
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    // Set up the action bar.
    final ActionBar actionBar = getSupportActionBar();

    if (actionBar != null) {
      actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    }

    // Create the adapter that will return a fragment for each of the three
    // primary sections of the activity.
    mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());

    // Set up the ViewPager with the sections adapter.
    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(mSectionsPagerAdapter);

    // When swiping between different sections, select the corresponding
    // tab. We can also use ActionBar.Tab#select() to do this if we have
    // a reference to the Tab.
    mViewPager.setOnPageChangeListener(
        new ViewPager.SimpleOnPageChangeListener() {
          @Override
          public void onPageSelected(int position) {
            if (actionBar != null) {
              actionBar.setSelectedNavigationItem(position);
            }
          }
        });

    Drawable drawable[] = new Drawable[mSectionsPagerAdapter.getCount()];
    drawable[0] = getResources().getDrawable(R.drawable.icon_tab_cinf);
    drawable[1] = getResources().getDrawable(R.drawable.icon_tab_ns);
    drawable[2] = getResources().getDrawable(R.drawable.icon_tab_ht);
    drawable[3] = getResources().getDrawable(R.drawable.icon_tab_ci);
    drawable[4] = getResources().getDrawable(R.drawable.icon_tab_sg);

    // For each of the sections in the app, add a tab to the action bar.
    for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) {
      // Create a tab with text corresponding to the page title defined by
      // the adapter. Also specify this Activity object, which implements
      // the TabListener interface, as the callback (listener) for when
      // this tab is selected.
      if (actionBar != null) {
        actionBar.addTab(actionBar.newTab().setTabListener(this).setIcon(drawable[i]));
      }
    }
  }
示例#9
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    pm = PreferenceManager.getDefaultSharedPreferences(ActivityMisMangas.this);
    darkTheme = pm.getBoolean("dark_theme", false);
    setTheme(darkTheme ? R.style.AppTheme_miDark : R.style.AppTheme_miLight);
    super.onCreate(savedInstanceState);
    PreferenceManager.setDefaultValues(this, R.xml.fragment_preferences, false);
    setContentView(R.layout.activity_mis_mangas);

    mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
    fragmentAddManga = new FragmentAddManga();
    fragmentMisMangas = new FragmentMisMangas();

    fragmentAddManga.setRetainInstance(true);
    fragmentMisMangas.setRetainInstance(true);
    mSectionsPagerAdapter.add(fragmentMisMangas);
    mSectionsPagerAdapter.add(fragmentAddManga);

    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(mSectionsPagerAdapter);
    mViewPager.setPageTransformer(false, new MoreMangasPageTransformer());

    button_add = (FloatingActionButton) findViewById(R.id.button_add);
    button_add.setOnClickListener(this);

    final boolean show_dialog = pm.getBoolean("show_updates", false);
    if (!show_dialog) { // ! o no segun la version 1.36 sin !
      AlertDialog.Builder dlgAlert = new AlertDialog.Builder(this);
      dlgAlert.setMessage(getString(R.string.update_message));
      dlgAlert.setTitle(R.string.app_name);
      dlgAlert.setCancelable(true);
      dlgAlert.setPositiveButton(
          android.R.string.ok,
          new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
              pm.edit().putBoolean("show_updates", true).apply(); // false 1.36
            }
          });
      dlgAlert.setNegativeButton(
          getString(R.string.see_later),
          new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
              dialog.dismiss();
            }
          });
      dlgAlert.create().show();
    }
  }
示例#10
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getWindow().requestFeature(Window.FEATURE_ACTION_BAR);
    setContentView(R.layout.country_activity);
    Log.d("ActivityTaste", "On Create ");
    // Set up the action bar.
    final ActionBar actionBar = getActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    Intent intent = getIntent();
    pos = intent.getExtras().getString("ARG_POSITION").toString();

    // Create the adapter that will return a fragment for each of the three
    // primary sections of the app.
    mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());

    // Set up the ViewPager with the sections adapter.
    mViewPager = (ViewPager) findViewById(R.id.country_pager);
    mViewPager.setAdapter(mSectionsPagerAdapter);

    // When swiping between different sections, select the corresponding
    // tab. We can also use ActionBar.Tab#select() to do this if we have
    // a reference to the Tab.

    mViewPager.setOnPageChangeListener(
        new ViewPager.SimpleOnPageChangeListener() {
          @Override
          public void onPageSelected(int position) {
            actionBar.setSelectedNavigationItem(position);
          }
        });

    // For each of the sections in the app, add a tab to the action bar.
    for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) {
      // Create a tab with text corresponding to the page title defined by
      // the adapter. Also specify this Activity object, which implements
      // the TabListener interface, as the callback (listener) for when
      // this tab is selected.
      boolean preselected = (i == 0);
      actionBar.addTab(
          actionBar.newTab().setText(mSectionsPagerAdapter.getPageTitle(i)).setTabListener(this),
          preselected);
    }
    if (savedInstanceState != null) {
      mTabSelected = savedInstanceState.getInt(TAB_SELECTED);
    }
  }
示例#11
0
  @Override
  public void startStream() {

    if (streamingListener == null) {
      streamingListener = (StreamingListener) mSectionsPagerAdapter.getFragment(0);
    }

    if (streamingListener != null) {
      streamingListener.onStreamingStart();
    }

    if (mediaPlayer == null) {
      mediaPlayer = new AACPlayer(this);
      mediaPlayer.setAudioBufferCapacityMs(3000);
      mediaPlayer.setDecodeBufferCapacityMs(1500);

      // untuk mencegak proses koneksi berulang pada protokol ICY
      // (Shoutcast streaming)
      mediaPlayer.setResponseCodeCheckEnabled(false);
    }

    if (mediaPlayer != null) {
      mediaPlayer.playAsync(RADIO_CHANNEL, 32);
    }
  }
示例#12
0
  @Override
  public void onTabSelected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {
    // When the given tab is selected, switch to the corresponding page in
    // the ViewPager.
    mViewPager.setCurrentItem(tab.getPosition());

    Log.d(LOG_TAG, "OnPageChangeListener Called with position - " + tab.getPosition());

    if (tab.getPosition() == 0) {
      Log.d(LOG_TAG, "Trying to find MySpotsFragment.");
      MySpotsFragment fragment = (MySpotsFragment) mSectionsPagerAdapter.getItem(tab.getPosition());
      if (fragment != null) {
        Log.d(LOG_TAG, "Found MySpotsFragment. Calling refresh spot list.");
        fragment.RefreshListOfSpotsTwoLines(this);
      }

    } else if (tab.getPosition() == 1) {
      //			AddSpotFragment fragment = (AddSpotFragment)
      // mSectionsPagerAdapter.getItem(tab.getPosition());
      //			if (fragment  != null) {
      //				Log.d(LOG_TAG, "Found MySpotsFragment. Calling refresh spot list.");
      //				fragment.refreshSpotNamesInAutocomplete(this);
      //			}
    }
  }
  private void setTabText(MediaType mode, String text) {

    TextView textView = null;
    for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) {

      SlidingTabStrip v = (SlidingTabStrip) mSlidingTabLayout.getChildAt(0);
      TextView currentTextView =
          (TextView) v.getChildAt(i); // currentTab.findViewById(android.R.id.text1);
      String currentText = currentTextView.getText().toString();

      if (mode == MediaType.IMAGE
          && currentText.startsWith(getResources().getString(R.string.image).trim())) {
        textView = currentTextView;
        break;
      }
      if (mode == MediaType.VIDEO
          && currentText.startsWith(getResources().getString(R.string.video).trim())) {
        textView = currentTextView;
        break;
      }
    }

    if (textView != null) {
      textView.setText(text);
    }
  }
示例#14
0
 @Override
 public void onPageSelected(int position) {
   // TODO Use the interface tasks to send data from MainActivity to Hourly & Daily Fragments
   if (position != 1) {
     mPagerAdapter.getMainWeatherFragment().closeDrawer();
   }
 }
示例#15
0
 @Override
 public void sendForecastToActivity(
     Forecast forecast) { // MainActivity receives the whole forecast from the main fragment
   // and stores it so that it would be available to all other fragments
   Log.i(TAG, "sendForecastToActivity is called");
   if (forecast != null) {
     mForecast = forecast;
     // Save forecast
     mPagerAdapter.getHourlyForecastFragment().setHours(mForecast.getHourlyForecast());
     mPagerAdapter.getHourlyForecastFragment().updateHourAdapter();
     mPagerAdapter.getDailyForecastFragment().setDays(mForecast.getDailyForecast());
     mPagerAdapter
         .getDailyForecastFragment()
         .updateDayAdapter(mForecast.getCurrent().getLocation());
   }
 }
示例#16
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    // Set up the action bar.
    final ActionBar actionBar = getActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    // Create the adapter that will return a fragment for each of the three
    // primary sections of the app.
    mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());

    // Set up the ViewPager with the sections adapter.
    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(mSectionsPagerAdapter);

    // When swiping between different sections, select the corresponding
    // tab. We can also use ActionBar.Tab#select() to do this if we have
    // a reference to the Tab.
    mViewPager.setOnPageChangeListener(
        new ViewPager.SimpleOnPageChangeListener() {
          @Override
          public void onPageSelected(int position) {
            actionBar.setSelectedNavigationItem(position);
          }
        });

    // For each of the sections in the app, add a tab to the action bar.
    for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) {
      // Create a tab with text corresponding to the page title defined by
      // the adapter. Also specify this Activity object, which implements
      // the TabListener interface, as the callback (listener) for when
      // this tab is selected.
      actionBar.addTab(
          actionBar.newTab().setText(mSectionsPagerAdapter.getPageTitle(i)).setTabListener(this));
    }

    // Location stuff
    if (servicesConnected()) {
      mLocationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
      mLocationManager.requestLocationUpdates(
          LocationManager.GPS_PROVIDER, 2000, 10, locationListener);
    }

    GrabComparisionBuoys();
  }
示例#17
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    this.context = getApplicationContext();
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    // Set up the action bar.
    // setup action bar for tabs
    final ActionBar actionBar = getActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    actionBar.setDisplayShowTitleEnabled(false);

    // Create the adapter that will return a fragment for each of the three
    // primary sections of the activity.
    mSectionsPagerAdapter = new SectionsPagerAdapter(getFragmentManager());

    // Set up the ViewPager with the sections adapter.
    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(mSectionsPagerAdapter);

    // When swiping between different sections, select the corresponding
    // tab. We can also use ActionBar.Tab#select() to do this if we have
    // a reference to the Tab.
    mViewPager.setOnPageChangeListener(
        new ViewPager.SimpleOnPageChangeListener() {
          @Override
          public void onPageSelected(int position) {
            actionBar.setSelectedNavigationItem(position);
          }
        });

    actionBar.addTab(
        actionBar
            .newTab()
            .setText(mSectionsPagerAdapter.getPageTitle(0))
            .setTabListener(new TabListener<Feed>(this, "", Feed.class)));
    actionBar.addTab(
        actionBar
            .newTab()
            .setText(mSectionsPagerAdapter.getPageTitle(1))
            .setTabListener(new TabListener<Circles>(this, "", Circles.class)));
    actionBar.addTab(
        actionBar
            .newTab()
            .setText(mSectionsPagerAdapter.getPageTitle(2))
            .setTabListener(new TabListener<Profile>(this, "", Profile.class)));
  }
示例#18
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    try {
      Ctxt = this;
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_measurements_entry);
      // Create the adapter that will return a fragment for each of the three primary sections
      // of the app.
      mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());

      // Set up the action bar.
      final ActionBar actionBar = getActionBar();
      actionBar.setDisplayShowTitleEnabled(false);
      actionBar.setHomeButtonEnabled(true);
      actionBar.setHomeButtonEnabled(true);
      actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

      // Set up the ViewPager with the sections adapter.
      mViewPager = (ViewPager) findViewById(R.id.pager);
      mViewPager.setAdapter(mSectionsPagerAdapter);

      // When swiping between different sections, select the corresponding tab.
      // We can also use ActionBar.Tab#select() to do this if we have a reference to the
      // Tab.
      mViewPager.setOnPageChangeListener(
          new ViewPager.SimpleOnPageChangeListener() {
            @Override
            public void onPageSelected(int position) {
              actionBar.setSelectedNavigationItem(position);
            }
          });

      // For each of the sections in the app, add a tab to the action bar.
      for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) {
        // Create a tab with text corresponding to the page title defined by the adapter.
        // Also specify this Activity object, which implements the TabListener interface, as the
        // listener for when this tab is selected.
        Tab tab = actionBar.newTab();
        tab.setText(mSectionsPagerAdapter.getPageTitle(i));
        //        	tab.setIcon(icon)
        tab.setTabListener(this);
        actionBar.addTab(tab);
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
示例#19
0
  @Override
  public void onBackPressed() {

    int currentFragment = mViewPager.getCurrentItem();

    switch (currentFragment) {
      case 0:
      case 2:
        mViewPager.setCurrentItem(1);
        break;
      case 1:
        if (mPagerAdapter.getMainWeatherFragment().isDrawerOpened())
          mPagerAdapter.getMainWeatherFragment().closeDrawer();
        else super.onBackPressed();
        break;
    }
  }
示例#20
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_quests_activity_swipe);

    heroId = getIntent().getExtras().getInt("heroId");
    name = getIntent().getExtras().getString("heroName");
    battleTagFull = getIntent().getExtras().getString("battleTagFull");
    region = getIntent().getExtras().getString("region");

    setTitle(name);
    // Set up the action bar.
    final ActionBar actionBar = getActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    // Show the Up button in the action bar.
    actionBar.setDisplayHomeAsUpEnabled(true);

    // Create the adapter that will return a fragment for each of the three
    // primary sections of the app.
    mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());

    // Set up the ViewPager with the sections adapter.
    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(mSectionsPagerAdapter);

    // When swiping between different sections, select the corresponding
    // tab. We can also use ActionBar.Tab#select() to do this if we have
    // a reference to the Tab.
    mViewPager.setOnPageChangeListener(
        new ViewPager.SimpleOnPageChangeListener() {
          @Override
          public void onPageSelected(int position) {
            actionBar.setSelectedNavigationItem(position);
          }
        });

    // For each of the sections in the app, add a tab to the action bar.
    for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) {
      // Create a tab with text corresponding to the page title defined by
      // the adapter. Also specify this Activity object, which implements
      // the TabListener interface, as the callback (listener) for when
      // this tab is selected.
      actionBar.addTab(
          actionBar.newTab().setText(mSectionsPagerAdapter.getPageTitle(i)).setTabListener(this));
    }
  }
 @Override
 public void onNavigationDrawerItemSelected(int position) {
   switch (position) {
       // SHOW ALL POSTS
     case 1:
       if (!blog.getActiveFilter().equals(Blog.FILTER_ALL)) {
         blog.setActiveFilter(Blog.FILTER_ALL);
         blog.setCurrentPage(1);
       }
       // Force to refresh by changing the title
       mSectionsPagerAdapter.changeTitle(1, getString(R.string.navigation_drawer_section1));
       mViewPager.setCurrentItem(1);
       actionBar.setTitle(getString(R.string.app_name));
       break;
       // SCROLL TO CATEGORIES
     case 2:
       mViewPager.setCurrentItem(0);
       break;
       // SCROLL TO AUTHORS
     case 3:
       mViewPager.setCurrentItem(2);
       break;
       // SHOW FAVOURITES POSTS
     case 4:
       if (!blog.getActiveFilter().equals(Blog.FILTER_FAVOURITES)) {
         blog.setActiveFilter(Blog.FILTER_FAVOURITES);
         blog.setCurrentPage(1);
       }
       // Force to refresh by changing the title
       mSectionsPagerAdapter.changeTitle(1, getString(R.string.navigation_drawer_section4));
       actionBar.setTitle(getString(R.string.navigation_drawer_section4));
       mViewPager.setCurrentItem(1);
       break;
       // LAUCH DEFAULT EMAIL APP
     case 5:
       Intent intent = new Intent(Intent.ACTION_SEND);
       intent.setType("text/message");
       intent.putExtra(Intent.EXTRA_EMAIL, new String[] {"*****@*****.**"});
       intent.putExtra(Intent.EXTRA_SUBJECT, "");
       intent.putExtra(Intent.EXTRA_TEXT, "");
       Intent mailer = Intent.createChooser(intent, null);
       startActivity(mailer);
       break;
   }
 }
  /** MUST BE CALLED ON MAIN THREAD */
  private void setupTabs() {

    mParent = getActivity();

    mEventBus = EventBus.getDefault();

    // Create the adapter that will return a fragment for each of the three
    // primary sections of the app.
    mSectionsPagerAdapter = new SectionsPagerAdapter(mParent.getSupportFragmentManager());

    // Set up the ViewPager with the sections adapter.
    /** The {@link android.support.v4.view.ViewPager} that will host the section contents. */
    mViewPager = (ViewPager) this.getView();
    mViewPager.setAdapter(mSectionsPagerAdapter);

    // When swiping between different sections, select the corresponding
    // tab. We can also use ActionBar.Tab#select() to do this if we have
    // a reference to the Tab.
    mViewPager.addOnPageChangeListener(
        new ViewPager.SimpleOnPageChangeListener() {
          @Override
          public void onPageSelected(int position) {
            String status = mSectionsPagerAdapter.getStatusAtPostion(position);

            mEventBus.post(new StatusSelected(status));
            mSelectedStatus = status;
            CardsFragment fragment = mSectionsPagerAdapter.getFragment(position);
            if (fragment == null) {
              // It may just have not been instantiated yet
              fragment = (CardsFragment) mSectionsPagerAdapter.getItem(position);
              if (fragment == null) {
                Log.e(
                    TAG,
                    String.format("Cannot refresh the page selected at position %d", position));
                return; // We cannot do any more here
              }
            }
            fragment.refresh(false);
          }
        });

    mTitles = new ArrayList<>();
    for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++)
      mTitles.add(mSectionsPagerAdapter.getPageTitle(i));
  }
示例#23
0
  // request new location and update UI accordingly
  public void startLocationUpdates() {
    if (!mGoogleApiClient.isConnected()) mGoogleApiClient.connect();
    mLocation = LocationServices.FusedLocationApi.getLastLocation(mGoogleApiClient);
    LocationServices.FusedLocationApi.requestLocationUpdates(
        mGoogleApiClient, mLocationRequest, MainActivity.this);

    mPagerAdapter.getMainWeatherFragment().handleNewLocation(mLocation);
    Log.i(TAG, "Main Activity startLocationUpdates method is done.");
  }
示例#24
0
 @Override
 protected void onActivityResult(int requestCode, int resultCode, Intent data) {
   if (resultCode == RESULT_OK) {
     switch (lastAction) {
       case CHAT:
         ((UsersFragment) sectionsPagerAdapter.getItem(POSITION_USER)).startChat();
         break;
       case ROOM_LIST:
         viewPager.setCurrentItem(POSITION_ROOM);
         break;
     }
     connectionListener = new ChatConnectionListener();
     QBChatService.getInstance().addConnectionListener(connectionListener);
     ((RoomsFragment) sectionsPagerAdapter.getItem(POSITION_ROOM)).loadRooms();
   } else {
     showUsersFragment();
   }
 }
 @Override
 protected void onNewIntent(Intent intent) {
   super.onNewIntent(intent);
   if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
     String query = intent.getStringExtra(SearchManager.QUERY);
     Log.i(TAG, "Got search query: " + query);
     ((FreeItemsFragment) mSectionsPagerAdapter.getFreeItemsFragment()).searchQuery(query);
   } else if (Intent.ACTION_VIEW.equals(intent.getAction())) {
     Long itemID = getSelectedItemID();
     if (itemID != null) {
       getActionBar().selectTab(getActionBar().getTabAt(FREE_ITEMS_TAB));
       ((FreeItemsFragment) mSectionsPagerAdapter.getFreeItemsFragment())
           .displaySingleItem(itemID);
     }
   } else {
     Log.i(TAG, "Action = " + intent.getAction());
   }
 }
示例#26
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    try {

      setContentView(R.layout.view_pager);
      actionBar = getSupportActionBar();
      actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

      mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());

      try {
        ViewConfiguration config = ViewConfiguration.get(this);
        Field menuKeyField = ViewConfiguration.class.getDeclaredField("sHasPermanentMenuKey");
        if (menuKeyField != null) {
          menuKeyField.setAccessible(true);
          menuKeyField.setBoolean(config, false);
        }
      } catch (Exception e) {
        e.printStackTrace();
      }

      mViewPager = (ViewPager) findViewById(R.id.pager);
      mViewPager.setAdapter(mSectionsPagerAdapter);
      mViewPager.setOnPageChangeListener(
          new ViewPager.SimpleOnPageChangeListener() {
            @Override
            public void onPageSelected(int position) {

              actionBar.setSelectedNavigationItem(position);
              mSectionsPagerAdapter.notifyDataSetChanged();
            }
          });

      for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) {

        actionBar.addTab(
            actionBar.newTab().setText(mSectionsPagerAdapter.getPageTitle(i)).setTabListener(this));
      }

      //      }
    } catch (Exception a) {
    }
  }
示例#27
0
  public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
      case R.id.save_btn:
        Bundle details = this.getIntent().getExtras();
        for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) {
          String tabTitle = mSectionsPagerAdapter.getPageTitle(i).toString();
          int tabCount = mSectionsPagerAdapter.getCount();
          MeasurmentFragment fragment = new MeasurmentFragment(tabTitle);
          String measurement = fragment.getMeasurement();
          if (measurement.isEmpty()) measurement = "";
          switch (tabCount) {
            case SHIRT:
              details.putString("shirtDetails", measurement);
            case TROUSER:
              details.putString("trouserDetails", measurement);
            default:
              details.putString("otherDetails", measurement);
          }
        }
        long newCustNumber = addCustomerDetails(details);

        if (newCustNumber != 0) {
          String newCustNum = String.valueOf(newCustNumber);
          // Show the next layout view
          Intent intent = new Intent(Ctxt, ShowCustomerDetails.class);
          /* sending the customer details to next activity 			 */
          Bundle bundle = new Bundle();
          bundle.putString("newCustmerNumber", newCustNum);
          intent.putExtras(bundle);
          // start the activity
          Ctxt.startActivity(intent);
        }

        return true;
      case android.R.id.home:
        // app icon in action bar clicked; go home
        Intent intent = new Intent(this, Matrix.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        startActivity(intent);
        return true;
      default:
        return super.onOptionsItemSelected(item);
    }
  }
示例#28
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.control);

    // Set up the action bar.
    final ActionBar actionBar = getActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    // Create the adapter that will return a fragment for each of the three
    // primary sections of the app.
    mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());

    // Set up the ViewPager with the sections adapter.
    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(mSectionsPagerAdapter);

    // When swiping between different sections, select the corresponding
    // tab. We can also use ActionBar.Tab#select() to do this if we have
    // a reference to the Tab.
    mViewPager.setOnPageChangeListener(
        new ViewPager.SimpleOnPageChangeListener() {
          @Override
          public void onPageSelected(int position) {
            actionBar.setSelectedNavigationItem(position);
          }
        });

    // For each of the sections in the app, add a tab to the action bar.
    for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) {
      // Create a tab with text corresponding to the page title defined by
      // the adapter. Also specify this Activity object, which implements
      // the TabListener interface, as the callback (listener) for when
      // this tab is selected.
      actionBar.addTab(
          actionBar.newTab().setText(mSectionsPagerAdapter.getPageTitle(i)).setTabListener(this));
    }

    fragments = new ArrayList<Fragment>();
    fragments.add(new HelpFragment());
    fragments.add(new MessageFragment());
    fragments.add(new FriendFragment());
  }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    // Create database connection
    datasource = new databaseIO(this);
    datasource.open();
    allTrails = datasource.getAllTrails();

    // Create the adapter that will return a fragment for each of the three primary sections
    // of the app.
    mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());

    // Set up the action bar.
    final ActionBar actionBar = getActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    // Set up the ViewPager with the sections adapter.
    mViewPager = (CustomViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(mSectionsPagerAdapter);

    // When swiping between different sections, select the corresponding tab.
    // We can also use ActionBar.Tab#select() to do this if we have a reference to the
    // Tab.
    mViewPager.setOnPageChangeListener(
        new CustomViewPager.SimpleOnPageChangeListener() {
          @Override
          public void onPageSelected(int position) {
            actionBar.setSelectedNavigationItem(position);
          }
        });

    // For each of the sections in the app, add a tab to the action bar.
    for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) {
      // Create a tab with text corresponding to the page title defined by the adapter.
      // Also specify this Activity object, which implements the TabListener interface, as the
      // listener for when this tab is selected.
      actionBar.addTab(
          actionBar.newTab().setText(mSectionsPagerAdapter.getPageTitle(i)).setTabListener(this));
    }
  }
示例#30
0
  // Save the recent activity's state
  private void saveComplexPreferences() {
    SharedPreferences sharedPreferences = getPreferences(Context.MODE_PRIVATE);
    SharedPreferences.Editor editor = sharedPreferences.edit();
    Gson gson = new Gson();
    MainActivitySave save =
        new MainActivitySave(mPagerAdapter.getMainWeatherFragment().isDrawerOpened());

    String json = gson.toJson(save);

    editor.putString(MAIN_ACTIVITY_SAVE, json);
    editor.apply();
  }