Android Open Source - L5RHelper Load Profile View






From Project

Back to project page L5RHelper.

License

The source code is released under:

Copyright (c) 2010 Robert Uhl Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Sof...

If you think the Android project L5RHelper 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 com.uhl;
/*from   w  ww.j a v a 2 s.  co m*/
import java.util.Hashtable;

import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.AdapterView.OnItemClickListener;

import com.uhl.db.DBServiceLocator;
import com.uhl.db.IDBHelper;
import com.uhl.db.Profile;

public class LoadProfileView extends ListActivity {
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    
    dbHelper = DBServiceLocator.getDBHelper(this);
    
    buildProfileTable();
    String[] names = new String[profiles.keySet().size()];
    profiles.keySet().toArray(names);

    setListAdapter(new ArrayAdapter<String>(this, R.layout.list_item, names));

    ListView lv = getListView();
    lv.setTextFilterEnabled(true);

    lv.setOnItemClickListener(new OnItemClickListener() {
      public void onItemClick(AdapterView<?> parent, View view,
          int position, long id) {
          int value = profiles.get((String)((TextView) view).getText());
          if ( value == -1) return;
          startActivity(ProfileOverviewActivity.class, value );
      }
    });
  }
  
  private void startActivity(Class<?> classInput, Integer Id) {
    Intent intent = new Intent(this, classInput);
    intent.putExtra("ID", Id);
    this.startActivityForResult(intent, 0);
    
  }  

  protected void onActivityResult(int requestCode, int resultCode, Intent data){
    //for now just return to the main activity, however we could stop here if they selected something to load a new character
    this.finish();
  }
  
  private void buildProfileTable() {
    Profile[] profileSet = dbHelper.getProfiles();
    if(profileSet.length < 1){
      profiles.put("No Profiles", -1);
      return;
    }
    for(Profile profile : profileSet){
      profiles.put(profile.getName(), profile.getId());      
    }
  }

  private IDBHelper dbHelper;
  private Hashtable<String, Integer> profiles = new Hashtable<String, Integer>();
  
}




Java Source Code List

com.uhl.CasterRollCalculateActivity.java
com.uhl.EditCharacterActivity.java
com.uhl.EditTemplateActivity.java
com.uhl.HomeActivity.java
com.uhl.L5RUtilites.java
com.uhl.LoadProfileView.java
com.uhl.ManageTemplateView.java
com.uhl.MeleeRollCalculateActivity.java
com.uhl.ProfileOverviewActivity.java
com.uhl.calc.Histogram.java
com.uhl.calc.Raises.java
com.uhl.calc.Roll.java
com.uhl.db.DBHelper.java
com.uhl.db.DBServiceLocator.java
com.uhl.db.DefaultViews.java
com.uhl.db.IDBHelper.java
com.uhl.db.Profile.java
com.uhl.db.Record.java
com.uhl.db.Template.java