Android Open Source - cellar-communicator Sales History






From Project

Back to project page cellar-communicator.

License

The source code is released under:

GNU General Public License

If you think the Android project cellar-communicator 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.vinit.orderplacer;
//  w  w  w . java2 s . c  o m
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.params.BasicHttpParams;
import org.apache.http.util.EntityUtils;

import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.text.Html;
import android.view.ViewGroup.LayoutParams;
import android.widget.ScrollView;
import android.widget.TextView;

public class SalesHistory extends Activity {

  
  private class GetHistory extends AsyncTask <Void, Void, String> {


    IPGetter get_ip;
    Context c;
    TextView t;
    String s;
      ProgressDialog dialog;


    public GetHistory(Context c, TextView t, String s)   {
      this.c = c;
      this.t = t;
      this.s = s;
      dialog = new ProgressDialog(c);
    }
    
    @Override
    protected void onPreExecute()  {
      dialog.setMessage("Loading");
      dialog.show();
    }


    @Override
    protected String doInBackground(Void... arg0) {

      get_ip = new IPGetter();
      HttpClient httpClient = new DefaultHttpClient(new BasicHttpParams());
      HttpPost httpPost = new HttpPost(get_ip.getIP() + "history.php");
      try {
        httpPost.setEntity(new StringEntity(s));
        HttpResponse httpResponse = httpClient.execute(httpPost);
        HttpEntity entity = httpResponse.getEntity();
        String response = EntityUtils.toString(entity);
        return response;
      } catch (Exception e) {
        e.printStackTrace();
        return "";
      }
    }

    @Override
    protected void onPostExecute(String s)  {
      if(dialog.isShowing()) {
        dialog.dismiss();
      }
      t.setText(Html.fromHtml(s));
    }
  }


  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    TextView t = new TextView(this);
    Intent i = getIntent();
    ScrollView scroll = new ScrollView(this);
    scroll.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
      
    scroll.addView(t);
    setContentView(scroll);
    
    GetHistory g = new GetHistory(this, t, i.getStringExtra("salesman"));
    g.execute();
  }
}




Java Source Code List

com.vinit.orderplacer.CategoryList.java
com.vinit.orderplacer.CheckPin.java
com.vinit.orderplacer.CommentBox.java
com.vinit.orderplacer.CounterOnClickListener.java
com.vinit.orderplacer.DumpJSON.java
com.vinit.orderplacer.IPGetter.java
com.vinit.orderplacer.RetrieveJSON.java
com.vinit.orderplacer.RetrieveSalesmen.java
com.vinit.orderplacer.SalesApp.java
com.vinit.orderplacer.SalesHistory.java
com.vinit.orderplacer.Salesman.java
com.vinit.orderplacer.SecurityPIN.java
com.vinit.orderplacer.SummaryActivity.java