Android Open Source - Amppercent7 Download Manager






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.project;
/*from   w  w  w . j  a v  a  2s.  co m*/
import java.util.LinkedList;
import java.util.List;

import my.amppercent.adapters.AdapterIM;
import my.amppercent.adapters.ListViewAdapting;
import my.amppercent.project.R;
import my.amppercent.remoteservice.IBinding;
import my.amppercent.remoteservice.IntentManage;
import my.amppercent.types.State;
import my.amppercent.types.myNotification;
import my.amppercent.types.newActivity;

import android.os.Bundle;
import android.os.IBinder;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.util.Log;

public class DownloadManager extends newActivity {

  private Bundle temp = new Bundle();

  private ListViewAdapting<IntentManage> lva = null;

  private AdapterIM aim = null;

  private IntentManage[] lim;

  @Override
  public void onAIDLConnected(ComponentName name, IBinder service,
      IBinding myservice) {
    if (aim == null) {
      aim = AdapterIM.ArrayNullInit(this, R.layout.download_view, 0, lim);
      if (lva == null)
        lva = new ListViewAdapting<IntentManage>(this, R.id.listview,
            aim);
    } else
      ((AdapterIM) lva.getAdapter()).setService(myservice);
  }

  private void receiveIntent(Intent i, Bundle savedInstanceState) {
    IntentManage j = new IntentManage(i);

    if (savedInstanceState != null) {
      temp = savedInstanceState;
    } else {
      temp = new Bundle();
    }
    Log.d("receiveIntent: first/second", j.first_argument + " "
        + j.second_argument);

    if ((j != null) && (j.first_argument != null)
        && (j.second_argument != null))
      temp.putParcelable(j.getId(), j);

    lim = new IntentManage[temp.keySet().size()];
    int k = 0;

    if ((temp.keySet() != null) || (temp.size() > 0))
      for (String x : temp.keySet()) {
        Log.d("DownloadManager:key", x);
        try {
          IntentManage im = (IntentManage) temp.getParcelable(x);
          lim[k++] = im;
        } catch (Throwable t) {

        }
      }

    if (aim == null) {
      aim = AdapterIM.ArrayNullInit(this, R.layout.download_view, 0, lim);
      if (lva == null)
        lva = new ListViewAdapting<IntentManage>(this, R.id.listview,
            aim);
    } else {
      lva.add_and_update(j);
    }

  }

  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {

    /* Visualizzazione dell'interfaccia */
    super.onCreate(savedInstanceState);
    this.setTitle("Download Manager");
    setContentView(R.layout.listview);

    Intent i = getIntent();
    receiveIntent(i, savedInstanceState);

  }

  @Override
  public void onDestroy() {
    super.onDestroy();
    State.manager_in = false;
  }

  @Override
  public void onSaveInstanceState(Bundle outState) {
    // Updates with only the not handled objects
    List<String> toremove = new LinkedList<String>();
    for (String id : temp.keySet()) {
      try {
        IntentManage im = (IntentManage) temp.getParcelable(id);
        if (im.handled) {
          toremove.add(id);
        }
      } catch (Throwable t) {
        toremove.add(id);
      }

    }
    for (String id : toremove) {
      temp.remove(id);
    }
    super.onSaveInstanceState(temp);
  }

  public void deleteString(String id) {
    this.temp.remove(id);
  }

  @Override
  public void initializer() {
    State.manager_in = true;
    setCouldSetMainVisible(false);
    BroadcastReceiver brodrecv = new BroadcastReceiver() {
      @Override
      public void onReceive(Context context, Intent intent) {
        receiveIntent(intent, temp);
      }
    };
    setBroadcastReceiver(brodrecv, myNotification.FILE_REQUEST_STRING);
    setAIDL(IBinding.class);
  }

  @Override
  public void onIntent(Intent i) {
  }
}




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