Android Open Source - android-mia Main Activity






From Project

Back to project page android-mia.

License

The source code is released under:

Apache License

If you think the Android project android-mia 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.idunnolol.mia;
//from   ww w . j  a va2  s. co  m
import android.app.Activity;
import android.app.FragmentManager;
import android.os.Bundle;
import android.text.TextUtils;
import android.widget.Toast;

public class MainActivity extends Activity implements DataFragment.QueryListener, SearchFragment.SearchFragmentListener {

    private DataFragment mDataFragment;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        FragmentManager fm = getFragmentManager();
        if (savedInstanceState == null) {
            mDataFragment = new DataFragment();

            fm.beginTransaction()
                    .add(R.id.container, new SearchFragment())
                    .add(mDataFragment, DataFragment.TAG)
                    .commit();
        }
        else {
            mDataFragment = (DataFragment) fm.findFragmentByTag(DataFragment.TAG);
        }
    }

    //////////////////////////////////////////////////////////////////////////
    // QueryListener

    @Override
    public void onAudioStopLoaded(AudioStop audioStop) {
        if (audioStop != null) {
            Toast.makeText(this, "Loaded audio stop: " + audioStop.mTitle, Toast.LENGTH_SHORT).show();
        }
        else {
            Toast.makeText(this, getString(R.string.error_no_stop), Toast.LENGTH_SHORT).show();
        }
    }

    //////////////////////////////////////////////////////////////////////////
    // SearchFragmentListener

    @Override
    public void onQuery(String query) {
        if (TextUtils.isEmpty(query)) {
            Toast.makeText(this, getString(R.string.error_no_query), Toast.LENGTH_SHORT).show();
        }
        else {
            mDataFragment.query(query);
        }
    }
}




Java Source Code List

com.idunnolol.mia.AudioStop.java
com.idunnolol.mia.DataFragment.java
com.idunnolol.mia.MainActivity.java
com.idunnolol.mia.SearchFragment.java