Android Open Source - android-cd-travis-example City Base Activity






From Project

Back to project page android-cd-travis-example.

License

The source code is released under:

MIT License

If you think the Android project android-cd-travis-example 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.ruenzuo.weatherapp.base;
//w  ww . j  a  v  a2  s.c  o m
import com.ruenzuo.weatherapp.R;
import com.ruenzuo.weatherapp.fragments.CityFragment;
import com.ruenzuo.weatherapp.pojos.City;

import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.MenuItem;

public class CityBaseActivity extends ActionBarActivity {

    public static final String EXTRA_CITY = "city";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_city);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        Bundle extras = getIntent().getExtras();
        if (extras != null) {
            City city = (City) extras.getSerializable(EXTRA_CITY);
            CityFragment fragment = (CityFragment) getSupportFragmentManager()
                    .findFragmentById(R.id.cityFragment);
            try {
                City clone = (City) city.clone();
                fragment.setCity(clone);
                getSupportActionBar().setTitle(clone.getName());
            } catch (CloneNotSupportedException e) {
                e.printStackTrace();
            }
        }
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
            case android.R.id.home:
                onBackPressed();
                return true;
        }
        return super.onOptionsItemSelected(item);
    }

}




Java Source Code List

com.ruenzuo.weatherapp.activities.CitiesActivity.java
com.ruenzuo.weatherapp.activities.CitiesActivity.java
com.ruenzuo.weatherapp.activities.CityActivity.java
com.ruenzuo.weatherapp.activities.CityActivity.java
com.ruenzuo.weatherapp.adapters.CitiesAdapter.java
com.ruenzuo.weatherapp.adapters.CityAdapter.java
com.ruenzuo.weatherapp.base.CitiesBaseActivity.java
com.ruenzuo.weatherapp.base.CityBaseActivity.java
com.ruenzuo.weatherapp.fragments.CitiesListFragment.java
com.ruenzuo.weatherapp.fragments.CityFragment.java
com.ruenzuo.weatherapp.pojos.City.java
com.ruenzuo.weatherapp.pojos.Coordinate.java
com.ruenzuo.weatherapp.pojos.Forecast.java
com.ruenzuo.weatherapp.pojos.ListCities.java
com.ruenzuo.weatherapp.requests.CityJsonRequest.java
com.ruenzuo.weatherapp.test.CitiesActivityFunctionalTests.java
com.ruenzuo.weatherapp.test.CityActivityFunctionalTests.java