Android Open Source - QuMixDroid Main Activity






From Project

Back to project page QuMixDroid.

License

The source code is released under:

GNU General Public License

If you think the Android project QuMixDroid 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

/*******************************************************************************
 * Copyright (c) 2013 George Wieggers.// w  ww. j  a  v a 2s  . c om
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Public License v3.0
 * which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/gpl.html
 * 
 * Contributors:
 *     George Wieggers - initial API and implementation
 ******************************************************************************/
package org.wieggers.qu_apps.qumixdroid;

import java.io.InputStream;

import org.wieggers.qu_apps.qu16.Qu16_Mixer;
import org.wieggers.qu_apps.qu16.Qu16_Mixer.IMixerListener;

import android.app.Activity;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.content.res.AssetManager;
import android.content.res.Configuration;
import android.os.Bundle;
import android.view.Menu;
import android.widget.Toast;

public class MainActivity extends Activity implements IMixerListener
{

  private final int mRemotePort = 51325;
  private String mRemoteIp;
  private Boolean mDemoMode;

  private Qu16_Mixer mMixer;

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    //requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.activity_main);

    Intent intent = getIntent();
    mRemoteIp = intent.getStringExtra("address");
    mDemoMode = intent.getBooleanExtra("demo", false);

    getFragmentManager()
    .beginTransaction()
    .add(R.id.main_frame, new ConnectingFragment(), "main")
    .commit();
  }

  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main, menu);
    return true;
  }

  @Override
  protected void onPause() {
    super.onPause();

    if (mMixer != null) {
      mMixer.stop();
      mMixer = null;
    }
  }

  @Override
  protected void onResume() {
    super.onResume();

    mMixer = new Qu16_Mixer(mRemoteIp, mRemotePort, mDemoMode, this);

    mMixer.start();
    if (mDemoMode) {
      final AssetManager assetMgr = this.getAssets();
      
      Runnable run = new Runnable() {
        
        @Override
        public void run() {
          try {
            InputStream s = assetMgr.open("qu16_init_scene.txt");
            mMixer.readScene(s);
          } catch (Exception e) {
            errorOccurred(e);
          }          
        }
      };
      
      new Thread(run).start();
    }
  }

  @Override
  public void errorOccurred(Exception exception) {

    final String msg = exception.getMessage();

    runOnUiThread(new Runnable() {

      @Override
      public void run() {
        Toast toast = Toast.makeText(MainActivity.this, msg,
            Toast.LENGTH_LONG);
        toast.show();

        if (mMixer != null) {
          mMixer.stop();
          mMixer = null;
        }

        finish();
      }
    });
  }

  @Override
  public void initialSyncComplete() {
    runOnUiThread(new Runnable() {

      @Override
      public void run() {
        
        MixerFragment fragment = new MixerFragment();
        fragment.SetMixer(mMixer);
        
        getFragmentManager()
          .beginTransaction()
          .replace(R.id.main_frame, fragment, "main")
          .commit();
      }
    });
  }

  @Override
  public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
  }  


}




Java Source Code List

org.wieggers.qu_apps.communication.Connected_Device.java
org.wieggers.qu_apps.controls.Fader.java
org.wieggers.qu_apps.controls.RotaryKnob.java
org.wieggers.qu_apps.controls.bound.BoundMixFader.java
org.wieggers.qu_apps.controls.bound.BoundMixRotaryKnob.java
org.wieggers.qu_apps.controls.bound.BoundMixSeekbar.java
org.wieggers.qu_apps.controls.bound.BoundMixToggleButton.java
org.wieggers.qu_apps.controls.bound.BoundMuteToggleButton.java
org.wieggers.qu_apps.qu16.Qu16_MeteringValues.java
org.wieggers.qu_apps.qu16.Qu16_Midi_Parser.java
org.wieggers.qu_apps.qu16.Qu16_MixValue.java
org.wieggers.qu_apps.qu16.Qu16_Mixer.java
org.wieggers.qu_apps.qu16.Qu16_UI.java
org.wieggers.qu_apps.qu16.midi.Qu16_GEQ_Bands.java
org.wieggers.qu_apps.qu16.midi.Qu16_Id_Parameters.java
org.wieggers.qu_apps.qu16.midi.Qu16_Input_Channels.java
org.wieggers.qu_apps.qu16.midi.Qu16_VA_Ranges.java
org.wieggers.qu_apps.qu16.midi.Qu16_VX_Buses.java
org.wieggers.qu_apps.qumixdroid.ConnectingFragment.java
org.wieggers.qu_apps.qumixdroid.LoginActivity.java
org.wieggers.qu_apps.qumixdroid.MainActivity.java
org.wieggers.qu_apps.qumixdroid.MixerFragment.java