Advertisement
zaj

Activity Code

zaj
Sep 3rd, 2012
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.25 KB | None | 0 0
  1. public class OrderActivity extends BaseKaizenActivity implements OnClickListener {
  2.     private List<HashMap<String, String>>   listModel;
  3.     private AutoCompleteTextView        productTextView;
  4.     private Button              addProductButton;
  5.     private AutoCompleteTextView        supplierTextView;
  6.     private ListView                visibleTable;
  7.     private ListViewAdapter         tableAdapter;
  8.    
  9.     public void onCreate(Bundle savedInstanceState) {
  10.         super.onCreate(savedInstanceState);
  11.         setContentView(R.layout.order);
  12.         final Drawable x = getResources().getDrawable(R.drawable.clear);
  13.  
  14.         tf = Farsi.GetFarsiFont(this);
  15.  
  16.         supNameTV = (TextView) findViewById(R.id.supplierNameTV);
  17.         supNameTV.setTypeface(tf);
  18.         supNameTV.setText(Farsi.Convert(supNameTV.getText().toString()));
  19.  
  20.         proNameTV = (TextView) findViewById(R.id.prodNameTV);
  21.         proNameTV.setTypeface(tf);
  22.         proNameTV.setText(Farsi.Convert(proNameTV.getText().toString()));
  23.  
  24.         visibleTable = (ListView) findViewById(R.id.listview);
  25.         registerForContextMenu(visibleTable);
  26.  
  27.         createTableHeader();
  28.         listModel = new ArrayList<HashMap<String, String>>();
  29.  
  30.         Bundle extras = getIntent().getExtras();
  31.  
  32.         long customerId = extras.getLong("CUSTOMER_ID");
  33.         customerType = extras.getInt("CUSTOMER_TYPE");
  34.         Log.d("CUSTOMER ID IS = ", " " + customerId+"  TYPE "+customerType);
  35.         order = new Order(Long.toString(customerId));
  36.  
  37.         productTextView = (AutoCompleteTextView) findViewById(R.id.prodName_CB);
  38.         productTextView.setThreshold(0);
  39.         ClearableEditText.createClearableWidget(productTextView, x);
  40.         productTextView.setTypeface(tf);
  41.  
  42.         supplierTextView = (AutoCompleteTextView) findViewById(R.id.supplierName_CB);
  43.         supplierTextView.setThreshold(0);
  44.  
  45.         initControls();
  46.  
  47.         if (BaseKaizenActivity.getStorageManager().getSuppliers().size() == 0) {
  48.  
  49.             progressDialog = ProgressDialog.show(this, "Loading Supplier list");
  50.  
  51.             products = getConnection().getProducts();
  52.             BaseKaizenActivity.getStorageManager().setProducts(products);
  53.  
  54.             loadSuppliers();
  55.             loadProducts();
  56.  
  57.         }
  58.         else {
  59.  
  60.             handleSuccess(BaseKaizenActivity.getStorageManager().getSuppliers());
  61.             handleProductSuccess(BaseKaizenActivity.getStorageManager().getAllProducts());
  62.         }
  63.     }
  64.  
  65.  
  66. private void loadSuppliers() {
  67.         Thread thread = new Thread(new Runnable() {
  68.             @Override
  69.             public void run() {
  70.                 try {
  71.  
  72.                     List<String> suppliers = BaseKaizenActivity.getStorageManager().getSuppliers();
  73.                     Log.d("---", "loaded : Suppliersssssss: " + suppliers.size());
  74.                     for (String sup : suppliers) {
  75.                         Log.d("---", sup);
  76.                     }
  77.  
  78.                     handleSuccess(suppliers);
  79.                 }
  80.                 catch (Exception exc) {
  81.                     Log.d("--- ERROR ---", exc.getMessage());
  82.                     handleException(exc.getMessage());
  83.                 }
  84.             }
  85.         });
  86.         thread.start();
  87.     }
  88.  
  89.     private void loadProducts() {
  90.         Thread thread = new Thread(new Runnable() {
  91.             @Override
  92.             public void run() {
  93.                 try {
  94.                     allProducts = BaseKaizenActivity.getStorageManager().getAllProducts();
  95.  
  96.                     Log.d("---", "loaded : productsssss: " + allProducts.size());
  97.  
  98.                     for (String p : allProducts) {
  99.                         Log.d("Pro Name", p);
  100.                     }
  101.  
  102.                     handleProductSuccess(allProducts);
  103.                 }
  104.                 catch (Exception exc) {
  105.                     Log.d("--- ERROR ---", exc.getMessage());
  106.                     handleException(exc.getMessage());
  107.                 }
  108.             }
  109.         });
  110.         thread.start();
  111.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement