Android Open Source - Dumbledroid Jedi Activity






From Project

Back to project page Dumbledroid.

License

The source code is released under:

Copyright (c) 2013, Leocadio Tin? All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: ...

If you think the Android project Dumbledroid 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 io.leocad.dumbledoreexample.activities;
/*from ww w.  j ava 2  s.c  o  m*/
import io.leocad.dumbledoreexample.R;
import io.leocad.dumbledoreexample.models.Jedi;
import io.leocad.dumbledroid.net.NoConnectionException;
import android.annotation.SuppressLint;
import android.app.Dialog;
import android.app.ProgressDialog;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.widget.TextView;

public class JediActivity extends BaseActivity {
  
  private Dialog mDialog;

  @SuppressLint("NewApi")
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.jedi);
    
    if (Build.VERSION.SDK_INT >= 11) {
      // Show the Up button in the action bar.
      getActionBar().setDisplayHomeAsUpEnabled(true);
    }
    
    loadContent();
  }
  
  private void loadContent() {
    new AsyncTask<Void, Void, Jedi>() {

      @Override
      protected void onPreExecute() {
        mDialog = ProgressDialog.show(JediActivity.this, null, "Loading");
      };
      
      @Override
      protected Jedi doInBackground(Void... params) {

        try {
          Jedi jedi = new Jedi();
          jedi.load(JediActivity.this);
          return jedi;

        } catch (NoConnectionException e) {
          onConnectionError();
          return null;
          
        } catch (Exception e) {
          e.printStackTrace();
          return null;
        }
      }

      @Override
      protected void onPostExecute(Jedi jedi) {

        if (jedi != null) {
          printContent(jedi);
        }
        mDialog.dismiss();
      }
    }.execute();
  }
  
  private void printContent(Jedi jedi) {
    ((TextView) findViewById(R.id.tv_name)).setText( jedi.name );
    ((TextView) findViewById(R.id.tv_surname)).setText( jedi.surname );
    ((TextView) findViewById(R.id.tv_ability)).setText( jedi.ability );
    ((TextView) findViewById(R.id.tv_master)).setText( jedi.master );
    ((TextView) findViewById(R.id.tv_father)).setText( jedi.father );
  }

}




Java Source Code List

io.leocad.dumbledoreexample.activities.AboutActivity.java
io.leocad.dumbledoreexample.activities.BaseActivity.java
io.leocad.dumbledoreexample.activities.FlickrActivity.java
io.leocad.dumbledoreexample.activities.JediActivity.java
io.leocad.dumbledoreexample.activities.MainActivity.java
io.leocad.dumbledoreexample.activities.SithActivity.java
io.leocad.dumbledoreexample.adapters.FlickrAdapter.java
io.leocad.dumbledoreexample.models.FlickrPhotos.java
io.leocad.dumbledoreexample.models.Jedi.java
io.leocad.dumbledoreexample.models.Media.java
io.leocad.dumbledoreexample.models.PhotoItem.java
io.leocad.dumbledoreexample.models.Sith.java
io.leocad.dumbledoreexample.models.Suit.java
io.leocad.dumbledroid.data.AbstractModel.java
io.leocad.dumbledroid.data.DataController.java
io.leocad.dumbledroid.data.DataType.java
io.leocad.dumbledroid.data.JsonReflector.java
io.leocad.dumbledroid.data.ReflectionHelper.java
io.leocad.dumbledroid.data.XmlReflector.java
io.leocad.dumbledroid.data.cache.DiskCache.java
io.leocad.dumbledroid.data.cache.FileController.java
io.leocad.dumbledroid.data.cache.MemoryCache.java
io.leocad.dumbledroid.data.cache.ModelHolder.java
io.leocad.dumbledroid.data.cache.ObjectCopier.java
io.leocad.dumbledroid.data.xml.Node.java
io.leocad.dumbledroid.data.xml.SaxHandler.java
io.leocad.dumbledroid.data.xml.SaxParser.java
io.leocad.dumbledroid.net.HttpLoader.java
io.leocad.dumbledroid.net.HttpMethod.java
io.leocad.dumbledroid.net.NoConnectionException.java
io.leocad.dumbledroid.net.TimeoutException.java
io.leocad.dumbledroidplugin.core.ClassMapper.java
io.leocad.dumbledroidplugin.core.ClassWriter.java
io.leocad.dumbledroidplugin.core.DumbledroidClassCreator.java
io.leocad.dumbledroidplugin.core.FileUtils.java
io.leocad.dumbledroidplugin.core.JsonReverseReflector.java
io.leocad.dumbledroidplugin.core.XmlReverseReflector.java
io.leocad.dumbledroidplugin.exceptions.InvalidContentException.java
io.leocad.dumbledroidplugin.exceptions.InvalidUrlException.java
io.leocad.dumbledroidplugin.exceptions.UnsupportedContentTypeException.java
io.leocad.dumbledroidplugin.wizards.DataInputPage.java
io.leocad.dumbledroidplugin.wizards.FileCreationPage.java
io.leocad.dumbledroidplugin.wizards.NewModelWizard.java
org.apache.commons.validator.routines.DomainValidator.java
org.apache.commons.validator.routines.InetAddressValidator.java
org.apache.commons.validator.routines.RegexValidator.java
org.apache.commons.validator.routines.UrlValidator.java