Android Open Source - WiseRadar Main Activity






From Project

Back to project page WiseRadar.

License

The source code is released under:

Apache License

If you think the Android project WiseRadar 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 wiseguys.radar.ui;
//  www.j a  v  a2s. c  o  m
import android.app.Activity;
import android.app.FragmentManager;
import android.content.Intent;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;

import wiseguys.radar.R;

public class MainActivity extends Activity {

    private RadarFragment radarFragment;

    /**
     * Called when the activity is first created.
     */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        if (findViewById(R.id.main_container) != null) {
            if (savedInstanceState != null) {
                return;
            }

            radarFragment = new RadarFragment();
            radarFragment.setArguments(getIntent().getExtras());

            getFragmentManager().beginTransaction()
                    .add(R.id.main_container, radarFragment, "radar_fragment")
                    .commit();
        }
    }


    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle item selection
        switch (item.getItemId()) {
            case R.id.menu_quit:
                quit();
                return true;
            case R.id.menu_about:
                //Show about page
                AboutFragment aboutFragment = new AboutFragment();

                getFragmentManager().beginTransaction()
                        .setCustomAnimations(android.R.animator.fade_in, android.R.animator.fade_out)
                        .replace(R.id.main_container, aboutFragment, "about_fragment")
                        .addToBackStack(null)
                        .commit();
                return true;
            case R.id.menu_refresh:
                radarFragment.refresh();
                return true;
            case R.id.menu_preferences:
                //Show preferences
                PrefFragment prefFragment = new PrefFragment();

                getFragmentManager().beginTransaction()
                                    .setCustomAnimations(android.R.animator.fade_in, android.R.animator.fade_out)
                                    .replace(R.id.main_container, prefFragment, "pref_fragment")
                                    .addToBackStack(null)
                                    .commit();
                return true;
            default:
                return super.onOptionsItemSelected(item);
        }
    }

    /**
     * On quit print log message
     */
    @Override
    protected void onDestroy() {
        super.onDestroy();
    }

    /**
     * On halt, print log message
     */
    @Override
    protected void onStop() {
        super.onStop();
    }

    /**
     * Creates our main
     */
    public boolean onCreateOptionsMenu(Menu menu) {
        MenuInflater inflater = getMenuInflater();
        inflater.inflate(R.menu.radar_menu, menu);
        return true;
    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_BACK) {
            if ( getFragmentManager().getBackStackEntryCount() == 0 ) {
                quit();
            } else {
                getFragmentManager().popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE);
            }
            return true;
        } else if (keyCode == KeyEvent.KEYCODE_MENU) {
            openOptionsMenu();
            return true;
        }
        return false;
    }

    /**
     * Closes our application
     */
    private void quit() {
        Intent intent = new Intent();
        setResult(RESULT_OK, intent);

        finish();
    }
}




Java Source Code List

wiseguys.radar.ImageFetcher.java
wiseguys.radar.RadarHelper.java
wiseguys.radar.RadarLoader.java
wiseguys.radar.conn.GPSHelper.java
wiseguys.radar.conn.ImageDownloaderThread.java
wiseguys.radar.conn.SourceFetcherThread.java
wiseguys.radar.helpers.GPSHelper.java
wiseguys.radar.helpers.RadarHelper.java
wiseguys.radar.ui.AboutFragment.java
wiseguys.radar.ui.MainActivity.java
wiseguys.radar.ui.PrefFragment.java
wiseguys.radar.ui.RadarFragment.java
wiseguys.radar.ui.adapter.Compat.java
wiseguys.radar.ui.adapter.IPhotoView.java
wiseguys.radar.ui.adapter.PhotoViewAttacher.java
wiseguys.radar.ui.adapter.PhotoView.java
wiseguys.radar.ui.adapter.SDK16.java
wiseguys.radar.ui.adapter.ScrollerProxy.java
wiseguys.radar.ui.adapter.VersionedGestureDetector.java