Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.nure.dmytro21;
- import android.app.*;
- import android.content.*;
- import android.os.*;
- import android.util.*;
- import android.view.*;
- import android.widget.*;
- import android.widget.AdapterView.*;
- import com.nure.dmytro21.Adapters.*;
- import com.nure.dmytro21.models.*;
- import java.util.*;
- import org.json.*;
- public class GoodsActivity extends Activity implements CarryOutQuerry.OnCarryOutListener, OnItemClickListener, OnClickListener
- //, GoodsAdapter.OnClickButtonChange
- {
- static Technique t;
- CarryOutQuerry carryOutQuerry;
- static ArrayList<Photos> photos;
- ArrayList<Technique> tech;
- String techQuerry = "SELECT t.id_NummTechn, t.description, p.titleOfProd, t.model, t.guaranteec, t.nInStore, t.created, t.cost, ti.title FROM technique as t INNER JOIN Title as ti ON t.id_title = ti.id_title INNER JOIN Producer as p ON t.id_producer = p.id_producer ";
- String techQuerryWhere;
- GoodsAdapter adapter;
- ProgressDialog pd;
- ListView list;
- EditText etQuerrySearch;
- Button btnSendSearch;
- Button btnGoToCar;
- @Override
- protected void onCreate(Bundle savedInstanceState)
- {
- super.onCreate(savedInstanceState);
- requestWindowFeature(Window.FEATURE_NO_TITLE);
- getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, 0);
- setContentView(R.layout.list_activity_goods);
- pd = new ProgressDialog(this);
- pd.setTitle("Loading");
- pd.setCanceledOnTouchOutside(false);
- pd.setCancelable(false);
- list = (ListView) findViewById(R.id.list_activity_goodsListView);
- etQuerrySearch = (EditText) findViewById(R.id.list_activity_goodsEtSearch);
- btnSendSearch = (Button) findViewById(R.id.list_activity_goodsBtnOK);
- btnGoToCar = (Button) findViewById(R.id.listactivitygoodsBtnCar);
- list.setOnItemClickListener(this);
- btnSendSearch.setOnClickListener(this);
- btnGoToCar.setOnClickListener(this);
- if (photos == null)
- photos = new ArrayList<>();
- carryOutQuerry = new CarryOutQuerry(this, "SELECT * FROM photos");
- carryOutQuerry.execute();
- carryOutQuerry.setICarryOut(this);
- }
- // @Override
- // public void onClickBtnChabge(View v, Technique tech, int requestCode)
- // {
- // if (requestCode == 1)
- // {
- // Intent Intent = new Intent(this, TechnActivity.class);
- // Intent.putExtra("idT", tech.getId_NummTechn());
- // startActivityForResult(Intent, requestCode);
- // }
- // }
- @Override
- protected void onActivityResult(int requestCode, int resultCode, Intent data)
- {
- // TODO: Implement this method
- super.onActivityResult(requestCode, resultCode, data);
- }
- @Override
- public void onClick(View p1)
- {
- switch (p1.getId())
- {
- case R.id.list_activity_goodsBtnOK : {
- if (etQuerrySearch.getText().toString() != null)
- {
- pd.setMessage("Поиск...");
- pd.show();
- CarryOutQuerry coq = new CarryOutQuerry(this, techQuerry + "WHERE Match(t.description) AGAINST(\"" + etQuerrySearch.getText().toString() + "\" IN NATURAL LANGUAGE MODE)");
- coq.execute();
- coq.setICarryOut(new CarryOutQuerry.OnCarryOutListener() {
- @Override
- public void onCarryOut(JSONArray array, String querry)
- {
- if (array != null)
- {
- tech = Technique.getTechniques(array, photos, 0);
- adapter.setDataSet(tech);
- adapter.notifyDataSetChanged();
- }
- else
- {
- Toast.makeText(GoodsActivity.this, "Ничего нету(( попробуйте еще раз.", Toast.LENGTH_SHORT).show();
- etQuerrySearch.setText("");
- }
- }
- });
- pd.hide();
- }
- }
- break;
- case R.id.listactivitygoodsBtnCar : {
- if (!MainActivity.isEmptyCar)
- {
- if (MainActivity.idCustomer != -1 && MainActivity.idCustomer != 0)
- {
- goToCar();
- }
- else
- {
- CarryOutQuerry coq = new CarryOutQuerry(this, "SELECT customerId from Customers where idUser =" + MainActivity.idUser + ";");
- coq.execute();
- coq.setICarryOut(new CarryOutQuerry.OnCarryOutListener(){
- @Override
- public void onCarryOut(JSONArray array, String querry)
- {
- try
- {
- MainActivity.idCustomer = array.getJSONObject(0).getInt("customerId");
- goToCar();
- }
- catch (JSONException e)
- {}
- }
- });
- }
- }
- else
- {
- Toast.makeText(this, "Корзина пуста", Toast.LENGTH_LONG).show();
- }
- }
- break;
- }
- }
- private void goToCar()
- {
- Intent intent = new Intent(this, CarActivity.class);
- Bills.InsertToBills(this, intent, null, null, null, null, 0);
- }
- @Override
- public void onItemClick(AdapterView<?> p1, View p2, int p3, long p4)
- {
- Toast.makeText(this, "AAAAA", Toast.LENGTH_LONG).show();
- Technique t = (Technique) p1.getItemAtPosition(p3);
- Intent intent = new Intent(this, GoodsItemResult.class);
- GoodsActivity.t = t;
- intent.putExtra("idT", t.getId_NummTechn());
- startActivity(intent);
- }
- @Override
- public void onCarryOut(JSONArray array, String querry)
- {
- if (querry.equals("SELECT * FROM photos"))
- {
- pd.setMessage("Загружаем картиночки");
- pd.show();
- if (photos.size() == 0)
- photos.addAll(Photos.getPhotos(array, true));
- carryOutQuerry = new CarryOutQuerry(this, techQuerry);
- carryOutQuerry.execute();
- carryOutQuerry.setICarryOut(this);
- }
- else if (querry.equals(techQuerry))
- {
- pd.setMessage("Выбираем технику");
- Log.i("mOLX", querry + "\n" + array.toString());
- tech = Technique.getTechniques(array, photos, 0);
- adapter = new GoodsAdapter(this, tech);
- //adapter.setOnClickBtnChange(this);
- list.setAdapter(adapter);
- pd.hide();
- }
- }
- }
- /*
- "SELECT t.id_NummTechn, t.description, p.titleOfProd, t.model, t.guaranteec,
- t.nInStore, t.created, t.cost, ti.title
- FROM technique as t INNER JOIN Title as ti ON
- t.id_title = ti.id_title
- INNER JOIN Producer as p ON
- t.id_producer = p.id_producer"
- ALTER TABLE Text ADD FULLTEXT (title,description);
- ALTER TABLE Text ADD FULLTEXT (title);
- */
Add Comment
Please, Sign In to add comment