Android Open Source - AndroIUT Mail Activity






From Project

Back to project page AndroIUT.

License

The source code is released under:

GNU General Public License

If you think the Android project AndroIUT 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.iutdijon.androiut2.mail.activities;
/*w  w  w.  j  a  va  2s  .  com*/

import javax.mail.Message;

import android.app.ListActivity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.view.Window;
import android.widget.Button;
import android.widget.ListView;

import com.iutdijon.androiut2.R;
import com.iutdijon.androiut2.global.AndroIUTApplication;
import com.iutdijon.androiut2.iut.data.account.UserAccount;
import com.iutdijon.androiut2.mail.adapters.MailDisplayAdapter;
import com.iutdijon.androiut2.mail.services.MailService;
import com.iutdijon.androiut2.util.UIUtil;

/**
 * 
 * @author Morgan Funtowicz
 * Classe associ?e ? l'IHM permettant de voir la liste des e-mails pour l'utilisateur.
 * La classe demande au mod?le de charger un nombre restreint de messages, correspondant aux 15 derniers
 * cette limite est repr?sent?e par MailService.MAIL_SIZE_LIMIT.
 * Le bouton load_more permet de charger 10 messages suppl?mentaires depuis le serveur. 
 */
public class MailActivity extends ListActivity implements View.OnClickListener{
  private ProgressDialog progressBar;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    
    this.requestWindowFeature(Window.FEATURE_NO_TITLE);
    
    setContentView(R.layout.activity_mail);
    
    Button load_more = (Button)findViewById(R.id.email_more);
    load_more.setOnClickListener(this);
    
    refreshUiMailList();
  }

  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.activity_mail, menu);
    return true;
  }
  
  
  /**
   * Cette m?thode permet de g?rer le clique sur un message dans la liste
   * Elle utilise {@link MailDisplayAdapter} afin de faire le lien entre les donn?es m?moires
   * d'un message et la repr?sentation sur l'?cran de celui-ci.
   * Durant le chargement d'un message, une progresse barre apparait afin d'informer l'utilisateur
   * de la progression du t?l?chargement.
   */
  @Override
  protected void onListItemClick(ListView l, View v, int position, long id) {
    super.onListItemClick(l, v, position, id);
    
    Message m = (Message) l.getItemAtPosition(position);
    
    MailDisplayAdapter adapter = new MailDisplayAdapter(){
      
      @Override
      protected void onPreExecute() {
        progressBar = ProgressDialog.show(MailActivity.this, "", getText(R.string.downloading_email));
        super.onPreExecute();
      }
      
      @Override
      protected void onPostExecute(Bundle result) {
        try {
          final Intent mail_display_intent = new Intent(MailActivity.this, MailReaderActivity.class);  
          mail_display_intent.putExtra("data", result);
          startActivity(mail_display_intent);
        } catch (Exception e) {
          e.printStackTrace();
          UIUtil.showMessage(MailActivity.this, "Erreur durant la r?cup?ration du message depuis le serveur ...");
        }finally{
          if(progressBar.isShowing()) progressBar.dismiss();
        }
      };
    };
    adapter.execute(m);
  }
  
  @Override
  /**
   * Callback du clique sur le bouton load_more permettant de charger plus d'email.
   * L'appui sur ce bouton implique un rafraichissement de la liste des e-mails.
   */
  public void onClick(View v) {
    MailService.MAIL_SIZE_LIMIT += 10;
    refreshUiMailList();
  }
  
  private void refreshUiMailList(){
    UserAccount account = AndroIUTApplication.getInstance().getAccount();

    if(account == null){
      throw new NullPointerException("Le compte utilisateur est null");
    }
    new MailService(this).execute(account.getLogin(), account.getPassword());
  }

}




Java Source Code List

.ADEResourcesDataTree.java
com.iutdijon.androiut2.ade.activities.ADEActivity.java
com.iutdijon.androiut2.ade.activities.ADEListResourcesChooser.java
com.iutdijon.androiut2.ade.activities.OnImageDownloadedCallback.java
com.iutdijon.androiut2.ade.service.ADEICalendarDownloader.java
com.iutdijon.androiut2.ftp.activities.FTPActivity.java
com.iutdijon.androiut2.ftp.adapters.FTPFileListAdapter.java
com.iutdijon.androiut2.ftp.data.FTPCommandResult.java
com.iutdijon.androiut2.ftp.data.FTPCommandWrapper.java
com.iutdijon.androiut2.ftp.data.FTPCommand.java
com.iutdijon.androiut2.ftp.services.FTPDownloadMonitor.java
com.iutdijon.androiut2.ftp.services.FTPServiceCall.java
com.iutdijon.androiut2.ftp.services.ProgressDownload.java
com.iutdijon.androiut2.global.AndroIUTApplication.java
com.iutdijon.androiut2.iut.activities.HomeActivity.java
com.iutdijon.androiut2.iut.activities.LoginActivity.java
com.iutdijon.androiut2.iut.data.Credential.java
com.iutdijon.androiut2.iut.data.UserFactory.java
com.iutdijon.androiut2.iut.data.account.StudentAccount.java
com.iutdijon.androiut2.iut.data.account.TeacherAccount.java
com.iutdijon.androiut2.iut.data.account.UserAccount.java
com.iutdijon.androiut2.iut.services.IUTLoginServiceCall.java
com.iutdijon.androiut2.mail.activities.MailActivity.java
com.iutdijon.androiut2.mail.activities.MailReaderActivity.java
com.iutdijon.androiut2.mail.adapters.MailDisplayAdapter.java
com.iutdijon.androiut2.mail.adapters.MailsListAdapter.java
com.iutdijon.androiut2.mail.services.EmailUtils.java
com.iutdijon.androiut2.mail.services.MailReader.java
com.iutdijon.androiut2.mail.services.MailService.java
com.iutdijon.androiut2.schooling.activities.SchoolingActivity.java
com.iutdijon.androiut2.schooling.activities.SchoolingTabActivity.java
com.iutdijon.androiut2.schooling.adapters.SectionedAdapter.java
com.iutdijon.androiut2.schooling.data.Absence.java
com.iutdijon.androiut2.schooling.data.Mark.java
com.iutdijon.androiut2.schooling.data.SchoolingData.java
com.iutdijon.androiut2.schooling.service.SchoolingDataServiceCall.java
com.iutdijon.androiut2.util.AndroIUTLogger.java
com.iutdijon.androiut2.util.IOUtils.java
com.iutdijon.androiut2.util.PreferencesManager.java
com.iutdijon.androiut2.util.UIUtil.java
com.iutdijon.androiut2.util.adapters.AbsencesAdapter.java
com.iutdijon.androiut2.util.adapters.BitmapAdapter.java
com.iutdijon.androiut2.util.adapters.CalendarAdapter.java
com.iutdijon.androiut2.util.adapters.IAdapter.java
com.iutdijon.androiut2.util.adapters.MarksAdapter.java
com.iutdijon.androiut2.util.adapters.UserAdapter.java
com.iutdijon.androiut2.util.adapters.XmlAdapter.java
com.iutdijon.androiut2.util.bridge.BridgeFinder.java
com.iutdijon.androiut2.util.loaders.AndroIUTHTTPConnection.java
com.iutdijon.androiut2.util.loaders.AsyncServiceCall.java
com.iutdijon.androiut2.util.loaders.BitmapDownloaderTask.java
com.iutdijon.androiut2.util.loaders.GetAsyncServiceCall.java
com.iutdijon.androiut2.util.loaders.ImageDownloader.java
com.iutdijon.androiut2.util.loaders.PostAsyncServiceCall.java
com.iutdijon.androiut2.util.observers.Observable.java
com.iutdijon.androiut2.util.observers.Observer.java
com.iutdijon.androiut2.util.security.SecureCenter.java
com.iutdijon.androiut2.util.view.ImageZoomView.java
com.iutdijon.androiut2.util.zoom.AspectQuotient.java
com.iutdijon.androiut2.util.zoom.DynamicZoomControl.java
com.iutdijon.androiut2.util.zoom.LongPressZoomListener.java
com.iutdijon.androiut2.util.zoom.PinchZoomListener.java
com.iutdijon.androiut2.util.zoom.SimpleZoomListener.java
com.iutdijon.androiut2.util.zoom.ZoomState.java
com.iutdijon.androiut2.util.zoom.util.Dynamics.java
com.iutdijon.androiut2.util.zoom.util.SpringDynamics.java