Android Open Source - classy_apps Hello Two Dbs






From Project

Back to project page classy_apps.

License

The source code is released under:

GNU General Public License

If you think the Android project classy_apps 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.example.hellotwodbs;
// w  w  w.  j  a va 2 s  .  c  o m
import javax.inject.Inject;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;
import au.com.cybersearch2.classyinject.DI;
import au.com.cybersearch2.example.v2.AndroidHelloTwoDbs;
import au.com.cybersearch2.example.v2.ComplexTask;
import au.com.cybersearch2.example.v2.SimpleTask;

import com.j256.ormlite.android.apptools.OpenHelperManager;
import com.j256.ormlite.android.apptools.OrmLiteBaseActivity;

/**
 * Sample Android UI activity which displays a text window when it is run.
 * 
 * <p>
 * <b>NOTE:</b> This does <i>not</i> extend the {@link OrmLiteBaseActivity} but instead manages the helper itself
 * locally using the {@link #databaseHelper1} field, the {@link #getHelper1()} private method, and the call to
 * {@link OpenHelperManager#releaseHelper()} inside of the {@link #onDestroy()} method.
 * </p>
 */
public class HelloTwoDbs extends Activity 
{

  private final String LOG_TAG = getClass().getSimpleName();
  @Inject AndroidHelloTwoDbs androidHelloTwoDbs;


  public HelloTwoDbs()
  {
    DI.inject(this);
  }
  
  /**
   * Called when the activity is first created.
   */
  @Override
  public void onCreate(Bundle savedInstanceState) 
  {
    super.onCreate(savedInstanceState);
    Log.i(LOG_TAG, "creating " + getClass() + " at " + System.currentTimeMillis());
    TextView tv = new TextView(this);
    tv.append(doSampleDatabaseStuff("onCreate"));
    Log.i(LOG_TAG, "Done with page at " + System.currentTimeMillis());
    setContentView(tv);
  }

  @Override
  protected void onDestroy() 
  {
    super.onDestroy();
        if (androidHelloTwoDbs != null)
          androidHelloTwoDbs.shutdown();
  }


  /**
   * Do our sample database stuff as an example.
   */
  protected String doSampleDatabaseStuff(String action) 
  {
    String text = "";
        // Run version 1 of example which will leave 2 database tables populated with version 1 objects.
        try
        {
          androidHelloTwoDbs.setUp();
          SimpleTask simpleTask = new SimpleTask(action);
          androidHelloTwoDbs.performPersistenceWork(AndroidHelloTwoDbs.PU_NAME1, simpleTask);
      // Our string builder for building the content-view
      StringBuilder sb = new StringBuilder();
      ComplexTask complexTask = new ComplexTask(action);
      androidHelloTwoDbs.performPersistenceWork(AndroidHelloTwoDbs.PU_NAME2, complexTask);
      androidHelloTwoDbs.logMessage(AndroidHelloTwoDbs.TAG, "Test completed successfully at " + System.currentTimeMillis());
      text = sb
          .append(AndroidHelloTwoDbs.SEPARATOR_LINE)
          .append(simpleTask.getMessage())
          .append(AndroidHelloTwoDbs.SEPARATOR_LINE)
          .append(complexTask.getMessage())
          .toString();
        }
        catch (InterruptedException e)
        {
        }
    Log.i(LOG_TAG, "Done with page at " + System.currentTimeMillis());
        return text;
  }

}




Java Source Code List

au.com.cybersearch2.classyfy.ClassyFyApplicationModule.java
au.com.cybersearch2.classyfy.ClassyFyApplication.java
au.com.cybersearch2.classyfy.ClassyFyEnvironmentModule.java
au.com.cybersearch2.classyfy.ClassyFyResourceEnvironment.java
au.com.cybersearch2.classyfy.ClassyFyStartup.java
au.com.cybersearch2.classyfy.ClassyFyThreadHelper.java
au.com.cybersearch2.classyfy.MainActivityTest.java
au.com.cybersearch2.classyfy.MainActivity.java
au.com.cybersearch2.classyfy.NodeDetailsDialog.java
au.com.cybersearch2.classyfy.NodeDetailsFragment.java
au.com.cybersearch2.classyfy.ProgressFragment.java
au.com.cybersearch2.classyfy.TitleSearchResultsActivityTest.java
au.com.cybersearch2.classyfy.TitleSearchResultsActivity.java
au.com.cybersearch2.classyfy.TitleSearchResultsFragment.java
au.com.cybersearch2.classyfy.data.DataLoader.java
au.com.cybersearch2.classyfy.data.DataStreamParser.java
au.com.cybersearch2.classyfy.data.FieldDescriptor.java
au.com.cybersearch2.classyfy.data.FilePlanNodeType.java
au.com.cybersearch2.classyfy.data.ManagedRecord.java
au.com.cybersearch2.classyfy.data.Model.java
au.com.cybersearch2.classyfy.data.RecordCategory.java
au.com.cybersearch2.classyfy.data.RecordField.java
au.com.cybersearch2.classyfy.data.RecordFolder.java
au.com.cybersearch2.classyfy.data.SqlFromNodeGenerator.java
au.com.cybersearch2.classyfy.data.alfresco.AlfrescoFilePlanLoaderModule.java
au.com.cybersearch2.classyfy.data.alfresco.AlfrescoFilePlanLoader.java
au.com.cybersearch2.classyfy.data.alfresco.AlfrescoFilePlanXmlParser.java
au.com.cybersearch2.classyfy.helper.FileUtils.java
au.com.cybersearch2.classyfy.provider.ClassyFyProviderTest.java
au.com.cybersearch2.classyfy.provider.ClassyFyProvider.java
au.com.cybersearch2.classyfy.provider.ClassyFySearchEngine.java
au.com.cybersearch2.classyjpa.entity.LoaderPersistenceContainerTest.java
au.com.cybersearch2.classyjpa.entity.TestPersistenceWork.java
au.com.cybersearch2.classyjpa.entity.UserPersistenceContainerTest.java
au.com.cybersearch2.classyutil.Transcript.java
au.com.cybersearch2.example.AndroidHelloTwoDbsModule.java
au.com.cybersearch2.example.AndroidHelloTwoDbs.java
au.com.cybersearch2.example.AppThreadHelper.java
au.com.cybersearch2.example.AppThreadHelper.java
au.com.cybersearch2.example.HelloTwoDbsEnvironmentModule.java
au.com.cybersearch2.example.HelloTwoDbsEnvironmentModule.java
au.com.cybersearch2.example.v2.AndroidHelloTwoDbsModule.java
au.com.cybersearch2.example.v2.AndroidHelloTwoDbs.java
au.com.cybersearch2.example.v2.HelloTwoDbsEnvironmentModule.java
com.example.hellotwodbs.HelloTwoDbsApplication.java
com.example.hellotwodbs.HelloTwoDbsApplication.java
com.example.hellotwodbs.HelloTwoDbs.java
com.example.hellotwodbs.HelloTwoDbs.java