Advertisement
Guest User

SplashScreenActivity.java

a guest
Jul 20th, 2012
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.25 KB | None | 0 0
  1. package com.mysite.news;
  2.  
  3.  
  4. import com.mysite.datasources.ArticlesDataSource;
  5. import com.mysite.models.Section;
  6.  
  7. import android.app.Activity;
  8. import android.content.Context;
  9. import android.content.Intent;
  10. import android.os.AsyncTask;
  11. import android.os.Bundle;
  12. import android.util.Log;
  13. import android.widget.Toast;
  14.  
  15. //new DownloadArticlesTask(null).execute();
  16. //Intent myIntent = new Intent(SplashScreenActivity.this, MainActivity.class);
  17. //SplashScreenActivity.this.startActivity(myIntent);
  18.  
  19. public class SplashScreenActivity extends Activity
  20. {
  21.  
  22.     @Override
  23.     public void onCreate(Bundle savedInstanceState)
  24.     {
  25.         super.onCreate(savedInstanceState);
  26.         setContentView(R.layout.splashscreen);
  27.        
  28.         LoadApplication loadApplication = new LoadApplication(this);
  29.         loadApplication.execute("");
  30.    
  31.     }
  32.    
  33.     private class LoadApplication extends AsyncTask<String, Void, String> {
  34.  
  35.         Context context;
  36.         //ProgressDialog waitSpinner;
  37.         private ArticlesDataSource articlesDataSource;
  38.         //ConfigurationContainer configuration = ConfigurationContainer.getInstance();
  39.  
  40.         public LoadApplication(Context context) {
  41.             this.context = context;
  42.             //waitSpinner = new ProgressDialog(this.context);
  43.         }
  44.  
  45.         @Override
  46.         public String doInBackground(String... params)
  47.         {
  48.             //IMPORTS THE ARTICLES FROM THE RSS FEED (adds or updates)
  49.             articlesDataSource = new ArticlesDataSource(context);
  50.             try {
  51.                 articlesDataSource.importArticles(Section.currentSection, false);
  52.             } catch (Exception e) {
  53.                 Toast toast = Toast.makeText(
  54.                         getBaseContext(),
  55.                         "NOTICE: Could not import/update " + Section.currentSection.toString() + " articles.",
  56.                         Toast.LENGTH_LONG);
  57.                 toast.show();
  58.             }
  59.            
  60.             return null;
  61.         }
  62.  
  63.         @Override
  64.         protected void onProgressUpdate(Void... value) {
  65.             //Things to be done while execution of long running operation is in progress
  66.             //(for example updating ProgressDialog)
  67.         }
  68.  
  69.         @Override
  70.         protected void onPostExecute(String result) {
  71.             Intent myIntent = new Intent(SplashScreenActivity.this, MainActivity.class);
  72.             SplashScreenActivity.this.startActivity(myIntent);
  73.             finish(); //makes it so you can't click the back button to get to it
  74.         }
  75.     }
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement