Пример #1
0
  public void getItemListAsJSONObject() {

    // show ProgressBar
    mProgressBar.setVisibility(View.VISIBLE);
    String url = Data.URL_GET_SHOPS + "/" + mShop.getId();

    RequestQueue requestQueue = Volley.newRequestQueue(getBaseContext());
    JsonObjectRequest jsonObjectRequest =
        new JsonObjectRequest(
            Request.Method.GET, url, new JSONObject(), mResponseListener, mResponseErrorListener);
    jsonObjectRequest.setRetryPolicy(new DefaultRetryPolicy(4 * 1000, 3, 2));
    requestQueue.add(jsonObjectRequest);
  }
Пример #2
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_shop);

    // recieve passed mShop
    mShop = GlobalObject.getInstance().getPassedShop();
    setTitle(mShop.getName());

    mListView = (ListView) findViewById(R.id.listView);
    mEmptyView = (LinearLayout) findViewById(R.id.empty);
    mProgressBar = (ProgressBar) findViewById(R.id.progressBar);

    // OnClick Listener for listitem
    mListView.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

            GlobalObject.getInstance().setPosition(position);
            Intent intent = new Intent(activity, ActivityQuantity.class);
            startActivityForResult(intent, ACTIVITY_QUANTITY_ID);
          }
        });

    LayoutInflater inflater = getLayoutInflater();

    // getting items list by mShop id
    getItemListAsJSONObject();

    mDialog_warning = new AlertDialog.Builder(activity);
    mDialog_warning
        .setTitle("Want to go back?")
        .setMessage(Data.WARNING_MESSAGE_BACK_BUTTON)
        .setPositiveButton(
            "Ok",
            new DialogInterface.OnClickListener() {
              @Override
              public void onClick(DialogInterface dialog, int which) {
                mKeyGoBack = true;
                onBackPressed();
              }
            })
        .setNegativeButton("Cancel", null);
  }