Android Open Source - Amppercent7 new Activity






From Project

Back to project page Amppercent7.

License

The source code is released under:

GNU General Public License

If you think the Android project Amppercent7 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 my.amppercent.types;
//ww  w .ja v a2  s. c  o  m
import my.amppercent.remoteservice.IBinding;
import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.ServiceConnection;
import android.os.Bundle;
import android.os.IBinder;
import android.util.Log;
import android.view.Display;
import android.view.WindowManager;

public class newActivity extends Activity {

  private BroadcastReceiver breceiver = null;

  private String what_to_breceive = null;

  private boolean breceiver_setter = false;

  private boolean visible = false;

  private Bundle getBundle = null;

  private String aidl_class_name = null;

  private boolean could_set_visible = false;

  private Display display;

  private int rotation;

  // Connessione al servizio remoto per effettuare AIDL

  private IBinding myservice = null;// Identifica inoltre se il servizio 
                    // attivo o meno

  private ServiceConnection mconn = new ServiceConnection() {

    public void onServiceDisconnected(ComponentName name) {
      Log.d("ServiceConnection@MAIN", "quitted");
      myservice = null;
    }

    public void onServiceConnected(ComponentName name, IBinder service) {
      myservice = IBinding.Stub.asInterface(service);
      Log.d("ServiceConnection@MAIN", "ok");
      onAIDLConnected(name, service, myservice);
    }
  };
  private Intent j = null;

  public void onAIDLConnected(ComponentName name, IBinder service,
      IBinding myservice) {
    Log.d("newActivity", "onAIDLConnected");
  }

  protected void setBroadcastReceiver(BroadcastReceiver brec, String str) {
    this.breceiver = brec;
    this.what_to_breceive = str;
  }

  protected void setAIDL(Class<?> cl) {
    this.aidl_class_name = cl.getName();
  }

  /**
   * Funzione di attivazione dei BroadcastReceivers
   */
  protected void activateBReceiver() {
    if ((!this.breceiver_setter) && (this.breceiver != null)) {
      registerReceiver(this.breceiver, new IntentFilter(
          this.what_to_breceive));
      breceiver_setter = true;
    }
  }

  /**
   * Inizializzazione del servizio remoto
   */
  protected void startAIDL() {
    if (this.aidl_class_name != null) {
      if (j == null) {
        j = new Intent(this.aidl_class_name);
        j.putExtra("version", "1.0");
        startService(j);
        bindService(j, mconn, BIND_AUTO_CREATE);
      }
    }
  }

  protected void setCouldSetMainVisible(boolean value) {
    this.could_set_visible = value;
  }

  /**
   * Terminazione del servizio remoto
   */
  protected void stopAIDL() {
    if (this.mconn != null) {
      unbindService(this.mconn);
      this.mconn = null;
    }
  }

  /**
   * Funzione di disattivazione dei BroadcastReceivers
   */
  protected void deactivateBReceiver() {
    if (this.breceiver_setter) {
      unregisterReceiver(this.breceiver);
      this.breceiver_setter = false;
    }
  }

  /**
   * Settaggio della visibilt del form
   * 
   * @param val
   */
  private void setVisiblity(boolean val) {
    /*
     * NOTA: originariamente, quando si settava la visibilit, si aggiornava
     * solamente this.visible
     */
    if (this.could_set_visible) {
      State.main_is_visible = val;
    }
    this.visible = val;
  }

  /**
   * Funzione da implementare per effettuare la inizializzazione. Verr
   * utilizzata all'atto della create;
   */
  public void initializer() {
    Log.d("newActivity", "initializer");
  }

  /**
   * Se l'activity  stata chiamata con un intent, allora dovr essere
   * eseguita l'azione opportuna
   */
  public void onIntent(Intent i) {

  }

  public Bundle getSavedInstance() {
    return this.getBundle;
  }

  protected void onCreate(Bundle savedInstance) {
    super.onCreate(savedInstance);
    Log.d("newACTIVITY", "INITING");

    this.display = ((WindowManager) getSystemService(Context.WINDOW_SERVICE))
        .getDefaultDisplay();
    this.rotation = display.getRotation();

    this.getBundle = savedInstance;
    // Chiamo la funzione di inizializzazione
    Log.d("INIT", "Initializing");
    initializer();

    Intent i = getIntent();
    if (i != null)
      onIntent(i);

    if (this.could_set_visible)
      State.main_is_active = true;

    // Attivazione di un BroadcastReceiver programmatico
    activateBReceiver();

  }

  /**
   * Gestione dell'evento di rotazione
   */
  protected void onRotate() {
    Log.d("newACTIVITY", "ROTATING");

  }

  protected void onPause() {
    super.onPause();
    Log.d("newACTIVITY", "PAUSING");
    if (this.rotation != display.getRotation())
      onRotate();
    setVisiblity(false);
    stopAIDL();
  }

  public boolean isRotating() {
    return (this.rotation != display.getRotation());
  }

  protected void onResume() {
    super.onResume();
    Log.d("newACTIVITY", "RESUMING");
    setVisiblity(true);
    startAIDL();
  }

  protected void onDestroy() {
    if (this.could_set_visible)
      State.main_is_active = false;
    deactivateBReceiver();
    super.onDestroy();

  }

  public IBinding getIBinding() {
    return this.myservice;
  }

  public boolean isVisible() {
    return this.visible;
  }

}




Java Source Code List

my.amppercent.adapters.AdapterChat.java
my.amppercent.adapters.AdapterElems.java
my.amppercent.adapters.AdapterIM.java
my.amppercent.adapters.AdapterUStatus.java
my.amppercent.adapters.ListViewAdapting.java
my.amppercent.adapters.ListView_XUser.java
my.amppercent.chatrequest.AvailabilitySettings.java
my.amppercent.chatrequest.SelectConnActivity.java
my.amppercent.chatrequest.connActivity.java
my.amppercent.chatrequest.serverActivity.java
my.amppercent.chattables.UberChat.java
my.amppercent.chattables.XConnect.java
my.amppercent.chattables.XRoster.java
my.amppercent.chattables.myChat.java
my.amppercent.project.Amppercent4Activity.java
my.amppercent.project.DownloadManager.java
my.amppercent.project.IBindRemoteService.java
my.amppercent.project.LaunchMe.java
my.amppercent.project.PrefActive.java
my.amppercent.project.TabFragment.java
my.amppercent.project.TextEntryActivity.java
my.amppercent.remoteservice.IFMessage.java
my.amppercent.remoteservice.IntentManage.java
my.amppercent.remoteservice.XUser.java
my.amppercent.remoteservice.chatAdapter.java
my.amppercent.types.Couple.java
my.amppercent.types.State.java
my.amppercent.types.myATask.java
my.amppercent.types.myNotification.java
my.amppercent.types.myYesNoDialog.java
my.amppercent.types.newActivity.java
org.jivesoftware.smackx.filetransfer.myOutgoingFileTransfer.java