Android Open Source - AndroidForiOS Main Activity






From Project

Back to project page AndroidForiOS.

License

The source code is released under:

MIT License

If you think the Android project AndroidForiOS 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

package com.example.androidforios.app.activities;
/*from www .ja  va  2 s .  co m*/
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.ActivityCompat;
import android.support.v4.app.ActivityOptionsCompat;
import android.support.v4.app.Fragment;
import android.support.v7.app.ActionBarActivity;
import android.view.Menu;
import android.view.MenuItem;

import com.example.androidforios.app.R;
import com.example.androidforios.app.data.model.TripList;
import com.example.androidforios.app.fragments.SubwayListFragment;
import com.example.androidforios.app.fragments.SubwayListFragment.SubwayLineFragmentInteractionListener;

/**
 * Class that is the primary entry point for the MBTA Subway Sample app.  It contains
 * one fragment that shows a list of subways to choose from.
 *
 * Created by Stephen Barnes on 3/23/14.
 */
public class MainActivity extends ActionBarActivity implements SubwayLineFragmentInteractionListener {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        if (savedInstanceState == null) {
            Fragment subwayListFragment = SubwayListFragment.newInstance();
            getSupportFragmentManager().beginTransaction()
                    .add(R.id.activity_main_container, subwayListFragment)
                    .commit();
        }
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();
        if (id == R.id.action_about) {
            return true;
        }
        return super.onOptionsItemSelected(item);
    }

    /**
     * Move to the next activity after a user has selected a subway line.
     * @param lineType the subway line the user wants to see details for
     */
    public void onLineTypeSelected(TripList.LineType lineType) {
        Intent intent = TripListActivity.getTripListActivityIntent(getApplicationContext(), lineType);
        ActivityCompat.startActivity(this, intent, ActivityOptionsCompat.makeSceneTransitionAnimation(this).toBundle());
    }
}




Java Source Code List

com.example.androidforios.app.activities.MainActivity.java
com.example.androidforios.app.activities.TripDetailActivity.java
com.example.androidforios.app.activities.TripListActivity.java
com.example.androidforios.app.adapters.LineTypeArrayAdapter.java
com.example.androidforios.app.adapters.PredictionArrayAdapter.java
com.example.androidforios.app.adapters.TripArrayAdapter.java
com.example.androidforios.app.data.managers.DataManager.java
com.example.androidforios.app.data.model.Prediction.java
com.example.androidforios.app.data.model.TripList.java
com.example.androidforios.app.data.model.Trip.java
com.example.androidforios.app.fragments.SubwayListFragment.java
com.example.androidforios.app.fragments.TripDetailFragment.java
com.example.androidforios.app.fragments.TripListFragment.java
com.example.androidforios.app.views.TripDetailsView.java