public void onClickSwitchReport(View v) { switch (reportMode) { case MODE_WEATHER: reportMode = MODE_SATELLITE; reportsViewPager.setCurrentItem(1); switchReportButton.setImageResource(R.drawable.btn_switch_weather); if (!satelliteUpdated) { startSatelliteTask(); } break; case MODE_SATELLITE: reportMode = MODE_WEATHER; reportsViewPager.setCurrentItem(0); switchReportButton.setImageResource(R.drawable.btn_switch_sat); if (!weatherUpdated) { startWeatherTask(); } break; } }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); this.context = this; this.cacheManager = CacheManager.getInstance(context); this.reportMode = MODE_WEATHER; this.exitTime = 0L; this.reportsViewPager = (CustomerViewPager) findViewById(R.id.viewpager_reports); this.updateButton = (ImageButton) findViewById(R.id.button_update); this.locationButton = (ImageButton) findViewById(R.id.button_location); this.settingsButton = (ImageButton) findViewById(R.id.button_settings); this.switchReportButton = (ImageButton) findViewById(R.id.button_switch_report); this.updatetimeTextView = (TextView) findViewById(R.id.textview_updatetime); this.locationTextView = (TextView) findViewById(R.id.textview_location); LayoutInflater inflater = LayoutInflater.from(context); weatherView = inflater.inflate(R.layout.linearlayout_weather, null); satelliteView = inflater.inflate(R.layout.linearlayout_satellite, null); this.forecastScrollView = (HorizontalScrollView) weatherView.findViewById(R.id.scrollview_forecast); this.templabelTextView = (TextView) weatherView.findViewById(R.id.textview_templabel); reportsViewList = new ArrayList<View>(); reportsViewList.add(weatherView); reportsViewList.add(satelliteView); reportsViewPager.setScrollable(false); reportsViewPager.setSwitchDuration(700); reportsViewPager.setAdapter(pagerAdapter); this.refreshDialog = DialogManager.createRefreshDialog(context); loadSettings(); StatManager.getInstance().sendStartApp(null); UmengUpdateAgent.update(this); }