Back to project page Joetz-Android-V2.
The source code is released under:
GNU General Public License
If you think the Android project Joetz-Android-V2 listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.example.jens.myapplication.activities; // w w w. ja va2 s . c o m import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.Window; import android.widget.TextView; import com.example.jens.myapplication.R; import com.example.jens.myapplication.apimanager.CancellableTask; import com.example.jens.myapplication.apimanager.SimpleRequestTask; import com.example.jens.myapplication.apimanager.manager.CampManager; import com.example.jens.myapplication.apimanager.manager.LoginManager; import com.example.jens.myapplication.main.MainActivity; import com.example.jens.myapplication.sam.JoetzApplication; public class StartActivity extends Activity { private CancellableTask loginTask; private TextView mTxtInfo; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getWindow().requestFeature(Window.FEATURE_ACTION_BAR); getActionBar().hide(); setContentView(R.layout.activity_start); mTxtInfo = (TextView) findViewById(R.id.txtInfo); checkLogin(); } /** * Check if there is a cached login key, if yes, perform login and go to main screen. If there * is no cached key, go straight to main screen */ private void checkLogin(){ LoginManager loginManager = JoetzApplication.getContext().getLoginManager(); if(!loginManager.isLoggedIn() && loginManager.existsCachedKey()){ mTxtInfo.setText(R.string.info_logging_in); loginTask = loginManager.tryLoginWithCachedKey(new SimpleRequestTask() { @Override public void doTask(int statusCode) { loginTask = null; mTxtInfo.setText(""); loadCamps(); goToMainScreen(); } }); }else{ loadCamps(); goToMainScreen(); } } /** * Start loading the camps in the background */ private void loadCamps(){ CampManager cm = JoetzApplication.getContext().getCampManager(); if(!cm.isCampsLoaded()){ cm.retrieveCamps(null); } } /** * Go to the main screen (seeing that this is just a startup screen) */ private void goToMainScreen(){ if(loginTask != null){ loginTask.cancelTask(); } Intent i = new Intent(this, MainActivity.class); startActivity(i); } @Override protected void onDestroy() { super.onDestroy(); if(loginTask != null){ loginTask.cancelTask(); } } }