Android Open Source - semana-isw2013 Semana Upload






From Project

Back to project page semana-isw2013.

License

The source code is released under:

Apache License

If you think the Android project semana-isw2013 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 mobi.itson.semanaisw2013app.utils;
//from   w w w .j a  v a 2  s  . c  o m
import java.io.File;
import java.io.FileNotFoundException;

import mobi.itson.semanaisw2013app.GalleryActivity;

import android.content.Context;
import android.view.View;
import android.widget.Toast;

import com.loopj.android.http.AsyncHttpClient;
import com.loopj.android.http.AsyncHttpResponseHandler;
import com.loopj.android.http.RequestParams;

public class SemanaUpload {
  
  private final static String GAPE_UPLOAD_URL = "http://codigo-itson.appspot.com/upload";
  private final static String GAPE_UPLOAD_IMGFILE_PARAM = "imgFile";
  
  public static void upload(final Context context, final File f, final View content, final View loadingScreen, final GalleryActivity ga) {
    AsyncHttpClient client = new AsyncHttpClient();
    client.get(GAPE_UPLOAD_URL, new AsyncHttpResponseHandler() {
        @Override
        public void onSuccess(String response) {
          response = response.trim();
            startUpload(context, response, f, content, loadingScreen, ga);
        }
    });
  }
  
  private static void startUpload(final Context context, final String url, final File f, final View content, final View loadingScreen, final GalleryActivity ga) {
    AsyncHttpClient client = new AsyncHttpClient();
    RequestParams params = new RequestParams();
    try {
      params.put(GAPE_UPLOAD_IMGFILE_PARAM, f);
    } catch(FileNotFoundException fnfe) {
      System.out.println(fnfe.getMessage());
    }
    client.post(url, params, new AsyncHttpResponseHandler() {
      @Override
      public void onSuccess(String response) {
      }
      
      @Override
      public void onFailure(Throwable arg0, String arg1) {
        System.out.println(arg1);
        System.out.println("ERROR: " + arg0.getMessage());
        Toast.makeText(context, "FAIL!", Toast.LENGTH_LONG).show();
        content.setVisibility(View.VISIBLE);
        loadingScreen.setVisibility(View.GONE);
      }
      
      @Override
      public void onFinish() {
        Toast.makeText(context, "FINISH!", Toast.LENGTH_LONG).show();
        content.setVisibility(View.VISIBLE);
        loadingScreen.setVisibility(View.GONE);
        ga.loadImages();
      }
    });
  }
}




Java Source Code List

mobi.itson.semanaisw2013app.AboutUsActivity.java
mobi.itson.semanaisw2013app.ConferenceActivity.java
mobi.itson.semanaisw2013app.Conference.java
mobi.itson.semanaisw2013app.ConferencesPagerFragment.java
mobi.itson.semanaisw2013app.GalleryActivity.java
mobi.itson.semanaisw2013app.ImagePagerActivity.java
mobi.itson.semanaisw2013app.MainActivity.java
mobi.itson.semanaisw2013app.ScheduleActivity.java
mobi.itson.semanaisw2013app.SplashActivity.java
mobi.itson.semanaisw2013app.WebView_Register_Actvity.java
mobi.itson.semanaisw2013app.WorkshopActivity.java
mobi.itson.semanaisw2013app.WorkshopPagerFragment.java
mobi.itson.semanaisw2013app.Workshop.java
mobi.itson.semanaisw2013app.utils.ActivityUtils.java
mobi.itson.semanaisw2013app.utils.BitmapHack.java
mobi.itson.semanaisw2013app.utils.Constants.java
mobi.itson.semanaisw2013app.utils.HttpHelper.java
mobi.itson.semanaisw2013app.utils.SemanaUpload.java
mobi.itson.semanaisw2013app.utils.TouchHighlightImageButton.java
mobi.itson.semanaisw2013app.utils.UploadImage.java