Android Open Source - AURHelperDroid Main Activity






From Project

Back to project page AURHelperDroid.

License

The source code is released under:

Apache License

If you think the Android project AURHelperDroid 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.stomachion.aurhelperdroid.activities;
//from  w  w w  .  j av  a2s. c om
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import com.stomachion.aurhelperdroid.R;
import com.stomachion.aurhelperdroid.fragments.AboutFrag;
import com.stomachion.aurhelperdroid.fragments.NewsRSSFrag;
import com.stomachion.aurhelperdroid.fragments.PreferencesFrag;
import com.stomachion.aurhelperdroid.fragments.SearchFrag;
import shared.ui.actionscontentview.ActionsContentView;

public class MainActivity extends FragmentActivity implements AdapterView.OnItemClickListener {

    private ActionsContentView mActionsContentView;

    private final int MENU_NEW = 0;
    private final int MENU_SEARCH = 1;
    private final int MENU_ABOUT = 2;
    private final int MENU_PREFERENCES = 3;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        mActionsContentView = (ActionsContentView) findViewById(R.id.actionsContentView);

        final ListView viewActionsList = (ListView) findViewById(R.id.actions);

        final String[] values = new String[]{getString(R.string.menu_new), getString(R.string.menu_search), getString(R.string.menu_about), getString(R.string.menu_prefs)};

        final ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
                android.R.layout.simple_list_item_1, android.R.id.text1, values);

        viewActionsList.setAdapter(adapter);
        viewActionsList.setOnItemClickListener(this);
    }


    @Override
    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
        showFragment(position);
    }

    /**
     * Show a given fragment after selecting an item from the content menu
     *
     * @param position position of the item on the content menu
     */
    private void showFragment(int position) {
        final Fragment f;
        switch (position) {
            case MENU_NEW:
                f = new NewsRSSFrag();
                break;

            case MENU_SEARCH:
                f = new SearchFrag();
                break;

            case MENU_ABOUT:
                f = new AboutFrag();
                break;

            case MENU_PREFERENCES:
                f = new PreferencesFrag();
                break;

            default:
                return;
        }
        getSupportFragmentManager().beginTransaction().replace(R.id.content, f).commit();

        mActionsContentView.showContent();
    }
}




Java Source Code List

com.stomachion.aurhelperdroid.activities.MainActivity.java
com.stomachion.aurhelperdroid.activities.PreferencesActivity.java
com.stomachion.aurhelperdroid.adapters.NewsAdapter.java
com.stomachion.aurhelperdroid.fallbacksupport.ActivityHostFragment.java
com.stomachion.aurhelperdroid.fallbacksupport.LocalActivityManagerFragment.java
com.stomachion.aurhelperdroid.fragments.AboutFrag.java
com.stomachion.aurhelperdroid.fragments.NewsRSSFrag.java
com.stomachion.aurhelperdroid.fragments.PreferencesFrag.java
com.stomachion.aurhelperdroid.fragments.SearchFrag.java
com.stomachion.aurhelperdroid.logic.NewsItem.java
com.stomachion.aurhelperdroid.network.InternetState.java
com.stomachion.aurhelperdroid.parser.MainRssParser.java
com.stomachion.aurhelperdroid.parser.RssNewsHandler.java
com.stomachion.aurhelperdroid.utils.CommonUtils.java
com.stomachion.aurhelperdroid.utils.Constants.java
com.stomachion.aurhelperdroid.utils.Prefs.java