Android Open Source - Commstat Main Activity






From Project

Back to project page Commstat.

License

The source code is released under:

GNU General Public License

If you think the Android project Commstat listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

/*
  Commstat - Funf-based Sensor Application 
  Copyright (C) 2013 Serkan Sakar/*ww  w .  ja  va 2  s.  c  o  m*/

  This program is free software: you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation, either version 3 of the License, or
  (at your option) any later version.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/


package de.tu_berlin.snet.commstat;

import java.util.Locale;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;

public class MainActivity extends FragmentActivity {

  /**
   * The {@link android.support.v4.view.PagerAdapter} that will provide
   * fragments for each of the sections. We use a
   * {@link android.support.v4.app.FragmentPagerAdapter} derivative, which
   * will keep every loaded fragment in memory. If this becomes too memory
   * intensive, it may be best to switch to a
   * {@link android.support.v4.app.FragmentStatePagerAdapter}.
   */
  SectionsPagerAdapter mSectionsPagerAdapter;

  /**
   * The {@link ViewPager} that will host the section contents.
   */
  ViewPager mViewPager;

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    // 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);
  }

  /**
   * A {@link FragmentPagerAdapter} that returns a fragment corresponding to
   * one of the sections/tabs/pages.
   */
  public class SectionsPagerAdapter extends FragmentPagerAdapter {

    public SectionsPagerAdapter(FragmentManager fm) {
      super(fm);
    }

    @Override
    public Fragment getItem(int position) {
      Fragment fragment = null;

      switch (position) {
      case 0:
        fragment = new SensorFragment();
        break;
      case 1:
        fragment = new EmailFragment();
        break;
      case 2:
        fragment = new FacebookFragment();
        break;
      }
      return fragment;
    }

    @Override
    public int getCount() {
      return 3;
    }

    @Override
    public CharSequence getPageTitle(int position) {
      Locale l = Locale.getDefault();
      switch (position) {
      case 0:
        return getString(R.string.sensor_title_section).toUpperCase(l);
      case 1:
        return getString(R.string.email_title_section).toUpperCase(l);
      case 2:
        return getString(R.string.facebook_title_section).toUpperCase(l);
      }
      return null;
    }
  }
}




Java Source Code List

de.tu_berlin.snet.commstat.EmailFragment.java
de.tu_berlin.snet.commstat.EmailSettingsActivity.java
de.tu_berlin.snet.commstat.FacebookFragment.java
de.tu_berlin.snet.commstat.MainActivity.java
de.tu_berlin.snet.commstat.SensorFragment.java
de.tu_berlin.snet.mail.MySSLSocketFactory.java
de.tu_berlin.snet.mail.MyTrustManager.java
de.tu_berlin.snet.probe.EmailProbe.java
de.tu_berlin.snet.probe.FacebookProbe.java