Android Open Source - SandB-Android Xml Check Age Task






From Project

Back to project page SandB-Android.

License

The source code is released under:

GNU General Public License

If you think the Android project SandB-Android 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 edu.grinnell.sandb.xmlpull;
 /*  w w w . j  a  v  a  2s. c om*/
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Date;

import android.os.AsyncTask;
import android.util.Log;
 
public class XmlCheckAgeTask extends AsyncTask<String, Integer, Long> {
  
  public static final String TAG = "XmlCheckAgeTask";
  
  public static interface CheckAgeListener {
    public void receive(Long result);
  }
  
  private final CheckAgeListener mListener;
  
  public XmlCheckAgeTask(CheckAgeListener l) {
    super();
    this.mListener = l;
  }
  
  @Override
  protected Long doInBackground(String... args) {
    return lastModified(args[0]);
  }
 
  @Override
  protected void onPostExecute(Long result) {
    mListener.receive(result);
  }

  // GET THE LAST MODIFIED TIME
  public static long lastModified(String url) {
    HttpURLConnection.setFollowRedirects(false);
      HttpURLConnection con;
      long date = 0;
      try {
        con = (HttpURLConnection) new URL(url).openConnection();
        date = con.getLastModified();
        if (date == 0)
          Log.i(TAG, "No last-modified information.");
      else
        Log.i(TAG, "Last-Modified: " + new Date(date));
      } catch (MalformedURLException e) {
        e.printStackTrace();
      } catch (IOException e) {
        e.printStackTrace();
      }
      return date;
  }
}




Java Source Code List

edu.grinnell.sandb.ArticleDetailActivity.java
edu.grinnell.sandb.ArticleDetailFragment.java
edu.grinnell.sandb.ArticleListAdapter.java
edu.grinnell.sandb.ArticleListFragment.java
edu.grinnell.sandb.CommentListAdapter.java
edu.grinnell.sandb.CommentListFragment.java
edu.grinnell.sandb.ImagePagerActivity.java
edu.grinnell.sandb.MainActivity.java
edu.grinnell.sandb.MainPrefs.java
edu.grinnell.sandb.ScarletAndBlackApplication.java
edu.grinnell.sandb.Utility.java
edu.grinnell.sandb.comments.CommentStorageHelper.java
edu.grinnell.sandb.comments.CommentTable.java
edu.grinnell.sandb.comments.Comment.java
edu.grinnell.sandb.data.ArticleStorageHelper.java
edu.grinnell.sandb.data.ArticleTable.java
edu.grinnell.sandb.data.Article.java
edu.grinnell.sandb.img.BodyImageGetter.java
edu.grinnell.sandb.img.ImageStorageHelper.java
edu.grinnell.sandb.img.ImageTable.java
edu.grinnell.sandb.img.Image.java
edu.grinnell.sandb.img.UniversalLoaderUtility.java
edu.grinnell.sandb.xmlpull.CommentParseTask.java
edu.grinnell.sandb.xmlpull.XmlCheckAgeTask.java
edu.grinnell.sandb.xmlpull.XmlFetchTask.java
edu.grinnell.sandb.xmlpull.XmlParseTask.java
edu.grinnell.sandb.xmlpull.XmlPullReceiver.java
edu.grinnell.sandb.xmlpull.XmlPullService.java