Android Open Source - City-Outdoors-Android Splash Activity






From Project

Back to project page City-Outdoors-Android.

License

The source code is released under:

Copyright (c) 2012, Edinburgh Council All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are ...

If you think the Android project City-Outdoors-Android 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 uk.co.jarofgreen.cityoutdoors.UI;
/* ww  w  .  jav  a  2s.  co m*/
import uk.co.jarofgreen.cityoutdoors.OurApplication;
import uk.co.jarofgreen.cityoutdoors.R;
import uk.co.jarofgreen.cityoutdoors.Service.LoadDataIfStaleService;
import uk.co.jarofgreen.cityoutdoors.Service.LoadDataService;
import uk.co.jarofgreen.cityoutdoors.Service.SendFeatureFavouriteService;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.os.Handler;
import android.preference.PreferenceManager;
import android.view.View;
import android.widget.TextView;

public class SplashActivity extends BaseActivity {


  protected static final int DELAY_TILL_FIRST_CHECK = 2000;
  protected static final int DELAY_STILL_WORKING = 2000;

  protected TextView textView;

  Handler handler;
  final Runnable runnable = new Runnable() {
    public void run() {
      SplashActivity.this.nextScreenPlease(null);
    }
  };;

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

    textView = (TextView)findViewById(R.id.message);

    handler=new Handler();
    handler.postDelayed(runnable, SplashActivity.DELAY_TILL_FIRST_CHECK);

    startService(new Intent(this, LoadDataIfStaleService.class));
    startService(new Intent(this, SendFeatureFavouriteService.class));
  }

  @Override
  protected void onPause() {
    super.onPause();
    handler.removeCallbacks(runnable);
  }

  @Override
  protected void onResume() {
    super.onResume();
    handler.postDelayed(runnable, SplashActivity.DELAY_TILL_FIRST_CHECK);
  }

  public void nextScreenPlease(View v) {
    SharedPreferences settings=PreferenceManager.getDefaultSharedPreferences(this);
    long last = settings.getLong("lastDataUpdate", -1);
    if (last > 1000) {
      startActivity(new Intent(this, MainActivity.class));
      handler.removeCallbacks(runnable);
      finish();
    } else {    
      textView.setText(R.string.splash_still_loading);
      handler.removeCallbacks(runnable);
      handler.postDelayed(runnable, SplashActivity.DELAY_STILL_WORKING);      
      if (((OurApplication)getApplication()).getLoadDataSerivceState() == OurApplication.GET_DATA_SERVICE_STATE_NONE) {
        startService(new Intent(this, LoadDataService.class));
      }
    }
  }  
}




Java Source Code List

uk.co.jarofgreen.cityoutdoors.OurApplication.java
uk.co.jarofgreen.cityoutdoors.Storage.java
uk.co.jarofgreen.cityoutdoors.API.BaseCall.java
uk.co.jarofgreen.cityoutdoors.API.BaseSubmitContentOrReportCall.java
uk.co.jarofgreen.cityoutdoors.API.CheckCurrentUserCall.java
uk.co.jarofgreen.cityoutdoors.API.CollectionCall.java
uk.co.jarofgreen.cityoutdoors.API.CollectionsCall.java
uk.co.jarofgreen.cityoutdoors.API.FeatureCall.java
uk.co.jarofgreen.cityoutdoors.API.FeatureFavouriteCall.java
uk.co.jarofgreen.cityoutdoors.API.FeaturesCall.java
uk.co.jarofgreen.cityoutdoors.API.IndexCall.java
uk.co.jarofgreen.cityoutdoors.API.InformationNeededFromContext.java
uk.co.jarofgreen.cityoutdoors.API.LogInOrSignUpCall.java
uk.co.jarofgreen.cityoutdoors.API.SubmitFeatureCheckinQuestionFreeTextAnswerCall.java
uk.co.jarofgreen.cityoutdoors.API.SubmitFeatureCheckinQuestionHigherOrLowerAnswerCall.java
uk.co.jarofgreen.cityoutdoors.API.SubmitFeatureCheckinQuestionMultipleChoiceAnswerCall.java
uk.co.jarofgreen.cityoutdoors.API.SubmitFeatureContentCall.java
uk.co.jarofgreen.cityoutdoors.API.SubmitFeatureReportCall.java
uk.co.jarofgreen.cityoutdoors.Model.BaseUploadContentOrReport.java
uk.co.jarofgreen.cityoutdoors.Model.Collection.java
uk.co.jarofgreen.cityoutdoors.Model.Content.java
uk.co.jarofgreen.cityoutdoors.Model.FeatureCheckinQuestionContent.java
uk.co.jarofgreen.cityoutdoors.Model.FeatureCheckinQuestionFreeText.java
uk.co.jarofgreen.cityoutdoors.Model.FeatureCheckinQuestionHigherOrLower.java
uk.co.jarofgreen.cityoutdoors.Model.FeatureCheckinQuestionMultipleChoice.java
uk.co.jarofgreen.cityoutdoors.Model.FeatureCheckinQuestionPossibleAnswer.java
uk.co.jarofgreen.cityoutdoors.Model.FeatureCheckinQuestion.java
uk.co.jarofgreen.cityoutdoors.Model.FeatureCheckin.java
uk.co.jarofgreen.cityoutdoors.Model.FeatureFavourite.java
uk.co.jarofgreen.cityoutdoors.Model.Feature.java
uk.co.jarofgreen.cityoutdoors.Model.ItemField.java
uk.co.jarofgreen.cityoutdoors.Model.Item.java
uk.co.jarofgreen.cityoutdoors.Model.UploadFeatureContent.java
uk.co.jarofgreen.cityoutdoors.Model.UploadFeatureReport.java
uk.co.jarofgreen.cityoutdoors.Service.LoadDataIfStaleService.java
uk.co.jarofgreen.cityoutdoors.Service.LoadDataService.java
uk.co.jarofgreen.cityoutdoors.Service.LoadUserDataService.java
uk.co.jarofgreen.cityoutdoors.Service.SendFeatureContentOrReportService.java
uk.co.jarofgreen.cityoutdoors.Service.SendFeatureFavouriteService.java
uk.co.jarofgreen.cityoutdoors.UI.AboutActivity.java
uk.co.jarofgreen.cityoutdoors.UI.AboutLegalActivity.java
uk.co.jarofgreen.cityoutdoors.UI.BaseActivity.java
uk.co.jarofgreen.cityoutdoors.UI.BaseListActivity.java
uk.co.jarofgreen.cityoutdoors.UI.BaseMonthlyActivity.java
uk.co.jarofgreen.cityoutdoors.UI.BaseNewFeatureContentOrReportActivity.java
uk.co.jarofgreen.cityoutdoors.UI.BrowseMapActivity.java
uk.co.jarofgreen.cityoutdoors.UI.CollectionActivity.java
uk.co.jarofgreen.cityoutdoors.UI.CollectionsActivity.java
uk.co.jarofgreen.cityoutdoors.UI.FavouritesActivity.java
uk.co.jarofgreen.cityoutdoors.UI.FeatureActivity.java
uk.co.jarofgreen.cityoutdoors.UI.FeatureCheckinQuestionExplanationActivity.java
uk.co.jarofgreen.cityoutdoors.UI.FeatureChildrenActivity.java
uk.co.jarofgreen.cityoutdoors.UI.LogInOrSignUpActivity.java
uk.co.jarofgreen.cityoutdoors.UI.LogInTwitterActivity.java
uk.co.jarofgreen.cityoutdoors.UI.MainActivity.java
uk.co.jarofgreen.cityoutdoors.UI.NewFeatureContentActivity.java
uk.co.jarofgreen.cityoutdoors.UI.NewFeatureReportActivity.java
uk.co.jarofgreen.cityoutdoors.UI.PreferencesActivity.java
uk.co.jarofgreen.cityoutdoors.UI.SendFeatureContentOrReportProgressActivity.java
uk.co.jarofgreen.cityoutdoors.UI.SplashActivity.java
uk.co.jarofgreen.cityoutdoors.UI.TermsAndConditionsActivity.java
uk.co.jarofgreen.cityoutdoors.UI.TitleBar.java
uk.co.jarofgreen.cityoutdoors.UI.ViewImageActivity.java
uk.co.jarofgreen.cityoutdoors.UI.WhatsOnActivity.java
uk.co.jarofgreen.cityoutdoors.UI.WildlifeActivity.java