Android Open Source - MightyV Test Menu






From Project

Back to project page MightyV.

License

The source code is released under:

Apache License

If you think the Android project MightyV 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.indivisible.mightyv.activities.testing;
/*from w  w w  .j  a v a2 s  .  c  o m*/
import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Toast;
import com.indivisible.mightyv.util.MyLog;

/**
 * A basic Activity to contain a menu for use during development. Use it to
 * access Activities (testing or otherwise) directly. Bypasses the need for a
 * robust UI at this early stage.
 * 
 * @author indiv
 */
public class TestMenu
        extends ListActivity
{

    //=================================================//
    //    data
    //=================================================//

    // TAG for logging
    private String TAG;


    /**
     * Add all Activities that we would like to access from the TestMenu
     * Activity. Include path from src/com/indivisible/mightyv/ and above
     */
    String[] testActivities = new String[] {
            "activities.testing.TestShows", "activities.testing.TestEpisodes",
            "activities.testing.TestSearch", "activities.ShowSearchActivity",
            "activities.ShowAddActivity"
    };


    //=================================================//
    //    Activity Lifecycle methods
    //=================================================//

    // This method will always get called when an Activity gets created.
    //   See the Android Activity Lifecycle for more info on these sorts of methods and when they trigger
    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        TAG = this.getClass().getSimpleName();

        // populate the ListActivity's ListView with the Strings from testActivities
        super.setListAdapter(new ArrayAdapter<String>(TestMenu.this,
                android.R.layout.simple_list_item_1, testActivities));
    }


    //=================================================//
    //    ListView methods
    //=================================================//

    // This methods gets invoked whenever one of the ListActivity's rows gets clicked.
    //   We will use it to start the assigned Activity directly. 
    @Override
    protected void onListItemClick(ListView lv, View v, int position, long id)
    {
        super.onListItemClick(lv, v, position, id);

        String activityPath = "<NULL>";
        Class<?> newActivity = null;
        try
        {
            String activityStr = testActivities[position];
            activityPath = "com.indivisible.mightyv." + activityStr;
            newActivity = Class.forName(activityPath);  // manually create the class path
            if (MyLog.debug)
                MyLog.d(TAG, "Activity class path: " + newActivity);
            Intent ourIntent = new Intent(TestMenu.this, newActivity);
            startActivity(ourIntent);
        }
        catch (ClassNotFoundException e)  //if the chosen item cannot be formed into a valid class path
        {
            // inform the user that the selected item is not formed correctly and cannot be started as an Activity
            MyLog.e(TAG, "Class failed: " + activityPath);
            Toast toast = Toast.makeText(TestMenu.this, "Class not found:\n"
                    + newActivity, Toast.LENGTH_SHORT);
            toast.show();
        }

    }


}




Java Source Code List

com.indivisible.mightyv.activities.ShowAddActivity.java
com.indivisible.mightyv.activities.ShowSearchActivity.java
com.indivisible.mightyv.activities.testing.TestEpisodes.java
com.indivisible.mightyv.activities.testing.TestMenu.java
com.indivisible.mightyv.activities.testing.TestSearch.java
com.indivisible.mightyv.activities.testing.TestShows.java
com.indivisible.mightyv.data.DBMediaOpenHelper.java
com.indivisible.mightyv.data.EpisodeDataSource.java
com.indivisible.mightyv.data.Episode.java
com.indivisible.mightyv.data.ShowDataSource.java
com.indivisible.mightyv.data.Show.java
com.indivisible.mightyv.dialogs.SearchShowEntryDialog.java
com.indivisible.mightyv.dialogs.SearchShowResultsDialog.java
com.indivisible.mightyv.dialogs.SelectShowDialog.java
com.indivisible.mightyv.fragments.EpisodeListFragment.java
com.indivisible.mightyv.fragments.ShowAddButtonsFragment.java
com.indivisible.mightyv.fragments.ShowListFragment.java
com.indivisible.mightyv.fragments.ShowRageSearchFragment.java
com.indivisible.mightyv.util.Convert.java
com.indivisible.mightyv.util.EpisodeArrayAdapter.java
com.indivisible.mightyv.util.MyLog.java
com.indivisible.mightyv.util.ShowArrayAdapter.java
com.tvrage.api.EpisodeListXMLParser.java
com.tvrage.api.SearchXMLParser.java
com.tvrage.api.XMLParser.java