public TechnicienActivity() { firstexecution = 0; listclt = new ArrayList<String>(); listclt.add("--Choisir un Client---"); listobjet = new ArrayList<String>(); String lan = Locale.getDefault().getLanguage(); if (lan.toLowerCase().equals("ar")) { listobjet.add("--اختيار الموضوع--"); listobjet.add("تبديل"); listobjet.add("تتبيت"); listobjet.add("معاينة"); listobjet.add("ازالة"); listobjet.add("ازالة/تتبيت"); } else if (lan.toLowerCase().equals("fr")) { listobjet.add("--Choisir un Objet--"); listobjet.add("Remplacement"); listobjet.add("Installation"); listobjet.add("Vérification"); listobjet.add("Désinstallation"); listobjet.add("Désin/Réinstall"); } allClient = new ArrayList<Client>(); labels = new ArrayList<>(); gps = new GpsTracker(); json = new JSONParser(); vendeurManager = VendeurManagerFactory.getClientManager(); technicien = TechnicienManagerFactory.getClientManager(); serv = new Services(); clt = new Client(); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_cataloge); if (android.os.Build.VERSION.SDK_INT > 9) { StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build(); StrictMode.setThreadPolicy(policy); } Bundle objetbunble = this.getIntent().getExtras(); if (objetbunble != null) { compte = (Compte) getIntent().getSerializableExtra("user"); cmdTrue = Integer.parseInt(getIntent().getStringExtra("cmd")); } PowerManager powerManager = (PowerManager) getSystemService(Context.POWER_SERVICE); wakelock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "no sleep"); wakelock.acquire(); ExpandList = (ExpandableListView) findViewById(R.id.exp_list); // ExpandList.setGroupIndicator(null); DisplayMetrics metrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(metrics); int width = metrics.widthPixels; // this code for adjusting the group indicator into right side of the view ExpandList.setIndicatorBounds(width - GetDipsFromPixel(50), width - GetDipsFromPixel(10)); categorie = new CategorieDaoMysql(getApplicationContext()); lscats = new ArrayList<>(); listclt = new ArrayList<>(); dialog = ProgressDialog.show( CatalogeActivity.this, getResources().getString(R.string.map_data), getResources().getString(R.string.msg_wait), true); /* if(CheckOutNet.isNetworkConnected(getApplicationContext())){ new ConnexionTask().execute(); }else{ new OfflineTask().execute(); } */ new OfflineTask().execute(); ExpandList.setEnabled(false); ExpandList.setOnChildClickListener( new OnChildClickListener() { @Override public boolean onChildClick( ExpandableListView parent, View v, int groupPosition, int childPosition, long id) { // TODO Auto-generated method stub produit = (Produit) parent.getExpandableListAdapter().getChild(groupPosition, childPosition); alertPutQty(); return false; } }); produit = new Produit(); client = new Client(); firstexecution = 0; vendeurManager = VendeurManagerFactory.getClientManager(); dico = new Dictionnaire(); produitsFacture = new ArrayList<Produit>(); products = new ArrayList<Produit>(); clients = new ArrayList<Client>(); gps = new GpsTracker(); firstinstance = 0; json = new JSONParser(); db = new TinyDB(this); db.clear(); myoffline = new Offlineimpl(getBaseContext()); gps = getGpsApplication(); clientspinner = (CustomAutoCompleteView) findViewById(R.id.autoclt); clientspinner.setOnItemClickListener(this); clientspinner.addTextChangedListener(this); catspinner = (CustomAutoCompleteView) findViewById(R.id.autocltcat); catspinner.setOnItemClickListener( new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { String selected = catspinner.getSelected(parent, view, position, id); Log.e("categorie sel ", selected); CategorieCustomer cc = null; for (int i = 0; i < lscat.size(); i++) { if (selected.equals(lscat.get(i).getLibelle())) { cc = lscat.get(i); } } if (cc != null) { listclt = new ArrayList<>(); for (int j = 0; j < cc.getLsclt().size(); j++) { for (int i = 0; i < clients.size(); i++) { if (cc.getLsclt().get(j) == clients.get(i).getId()) { listclt.add(clients.get(i).getName()); } } } if (listclt.size() == 0) { for (int i = 0; i < clients.size(); i++) { listclt.add(clients.get(i).getName()); } } addItemsOnSpinner(clientspinner, 1); } } }); catspinner.addTextChangedListener( new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { CustomAutoCompleteTextChangedListener txt = new CustomAutoCompleteTextChangedListener( CatalogeActivity.this, R.layout.list_view_row, listcat); myAdapter = txt.onTextChanged(s, start, before, count); myAdapter.notifyDataSetChanged(); catspinner.setAdapter(myAdapter); } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { // TODO Auto-generated method stub } @Override public void afterTextChanged(Editable s) { // TODO Auto-generated method stub String selected = s.toString(); Log.e("categorie after sel ", selected); CategorieCustomer cc = null; for (int i = 0; i < lscat.size(); i++) { if (selected.equals(lscat.get(i).getLibelle())) { cc = lscat.get(i); } } if (cc != null) { listclt = new ArrayList<>(); for (int j = 0; j < cc.getLsclt().size(); j++) { for (int i = 0; i < clients.size(); i++) { if (cc.getLsclt().get(j) == clients.get(i).getId()) { listclt.add(clients.get(i).getName()); } } } if (listclt.size() == 0) { for (int i = 0; i < clients.size(); i++) { listclt.add(clients.get(i).getName()); } } addItemsOnSpinner(clientspinner, 1); } else { listclt = new ArrayList<>(); for (int i = 0; i < clients.size(); i++) { listclt.add(clients.get(i).getName()); } addItemsOnSpinner(clientspinner, 1); } } }); /* clientspinner = (AutoCompleteTextView) findViewById(R.id.autoclt); clientspinner.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View arg1, int position, long arg3) { String selected = (String) parent.getItemAtPosition(position); client = new Client(); clientspinner.showDropDown(); final InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromInputMethod(parent.getWindowToken(), 0); clientspinner.setFilters(new InputFilter[] {new InputFilter.LengthFilter(selected.length())}); Log.e("Selected Client Spinner ",selected); for (int i = 0; i < clients.size(); i++) { client = clients.get(i); if (client.getName().equals(selected)) { client = clients.get(i); clientspinner.setEnabled(false); Log.e("Text selectionner ",client.toString()); ExpandList.setEnabled(true); break; } } } }); */ seepanier = (Button) findViewById(R.id.seesala); seepanier.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub if (produitsFacture.size() > 0) { if (products.size() > 0 || products != null) { Intent intent = new Intent(CatalogeActivity.this, FactureActivity.class); // intent.putExtra"products", produitsFacture); Map<String, Promotion> prom = new HashMap<>(); for (int i = 0; i < products.size(); i++) { Promotion pr = chargerMyPromo(client.getId(), products.get(i).getId()) .get( 0); // vendeurManager.getPromotions(client.getId(), // products.get(i).getId()).get(0); prom.put(products.get(i).getRef(), pr); } db.saveMapPromotion("allpromotion", prom); for (int i = 0; i < products.size(); i++) { Produit p = products.get(i); intent.putExtra("products" + i, p); Log.d("Product Spinner >> " + i, p.toString()); } for (int i = 0; i < produitsFacture.size(); i++) { Produit pm = produitsFacture.get(i); if (panier.size() > 0) { if (panier.containsKey(pm.getRef())) { pm.setQteDispo(panier.get(pm.getRef())); } } intent.putExtra("produit" + i, pm); } intent.putExtra("nmbproduct", produitsFacture.size() + ""); intent.putExtra("nmbproducts", products.size() + ""); intent.putExtra("total", totalTTC + ""); intent.putExtra("idclt", client.getId() + ""); intent.putExtra("gps", gps); intent.putExtra("compte", compte); intent.putExtra("dico", dico.getDico()); intent.putExtra("totalht", totalHT + ""); intent.putExtra("cmd", cmdTrue + ""); intent.putExtra("typeinvoice", "-1"); startActivity(intent); produitsFacture = new ArrayList<Produit>(); CatalogeActivity.this.finish(); } else { Toast.makeText( CatalogeActivity.this, getResources().getString(R.string.produit_min2), Toast.LENGTH_SHORT) .show(); } } else { Toast.makeText( CatalogeActivity.this, getResources().getString(R.string.produit_min2), Toast.LENGTH_SHORT) .show(); } } }); sv = new StockVirtual(CatalogeActivity.this); search = (SearchView) findViewById(R.id.searchView1); search.setOnQueryTextListener( new OnQueryTextListener() { @Override public boolean onQueryTextChange(String newText) { // TODO Auto-generated method stub Log.e("search data", "" + newText); Log.e("util", TextUtils.isEmpty(newText) + ""); if (TextUtils.isEmpty(newText)) { ExpandList.clearTextFilter(); remplireListview(lscats); } else { ExpandList.setFilterText(newText.toString()); ExpAdapter.getFilter().filter(newText.toString()); // bindingData = new BinderData(WeatherActivity.this, bindingData.getMap()); ExpAdapter.notifyDataSetChanged(); ExpandList.invalidateViews(); ExpandList.setAdapter(ExpAdapter); ExpandList.refreshDrawableState(); } return true; } @Override public boolean onQueryTextSubmit(String arg0) { // TODO Auto-generated method stub return false; } }); }