@Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.offer_information);
    progressDialog = new ProgressDialogClass(this);
    singleOffer = (Offers) getIntent().getSerializableExtra("offer_data");
    getSupportActionBar().setBackgroundDrawable(new ColorDrawable(0xFFfd6620));
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setHomeButtonEnabled(true);
    mContext = OfferInformation.this;
    databaseHelper = new DatabaseHelper(mContext);
    imageLoader = new Lazy_ImageLoader(mContext);

    redeemButton = (Button) findViewById(R.id.redeem_button);
    store_logo = (ImageView) findViewById(R.id.store_logo);

    descriptionLayout = (RelativeLayout) findViewById(R.id.store_description_layout);
    offerTermsTitleLayout = (RelativeLayout) findViewById(R.id.offer_terms_title_layout);
    offerTermsLayout = (RelativeLayout) findViewById(R.id.offer_terms_layout);

    storeName = (TextView) findViewById(R.id.store_name);
    storeDescription = (TextView) findViewById(R.id.store_description);
    offerTitle = (TextView) findViewById(R.id.offer_title);
    offerDescription = (TextView) findViewById(R.id.offer_description);
    offerTermsTitle = (TextView) findViewById(R.id.offer_terms_title);
    offerTerms = (TextView) findViewById(R.id.offer_terms);
    offerLocationTitle = (TextView) findViewById(R.id.offer_location_title);
    offerLocations = (TextView) findViewById(R.id.offer_locations);
    endDate = (TextView) findViewById(R.id.offer_end_date);
    endDateText = (TextView) findViewById(R.id.offer_end_date_text);
    uploadButton = (Button) findViewById(R.id.next_button);

    ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMapAsync(this);
    mygoogleMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();

    storeName.setTypeface(Typeface.create("sans-serif-condensed", Typeface.BOLD));
    storeDescription.setTypeface(Typeface.create("sans-serif-condensed", Typeface.NORMAL));
    offerTitle.setTypeface(Typeface.create("sans-serif-condensed", Typeface.BOLD));
    offerDescription.setTypeface(Typeface.create("sans-serif-condensed", Typeface.NORMAL));
    offerTermsTitle.setTypeface(Typeface.create("sans-serif-condensed", Typeface.BOLD));
    offerTerms.setTypeface(Typeface.create("sans-serif-condensed", Typeface.NORMAL));
    offerLocationTitle.setTypeface(Typeface.create("sans-serif-condensed", Typeface.BOLD));
    offerLocations.setTypeface(Typeface.create("sans-serif-condensed", Typeface.NORMAL));
    endDate.setTypeface(Typeface.create("sans-serif-condensed", Typeface.NORMAL));
    endDateText.setTypeface(Typeface.create("sans-serif-condensed", Typeface.NORMAL));

    imageLoader.DisplayImage(singleOffer.getStore_logo(), store_logo);
    storeName.setText("" + singleOffer.getStore_name());
    storeDescription.setText("");
    offerDescription.setText("" + singleOffer.getOffer_description());
    offerTerms.setText("" + singleOffer.getOffer_terms_conditions());

    offerLocations.setText(" - " + singleOffer.getOffer_locations().replace(",", "\n - "));

    if (!singleOffer.getOffer_type().equalsIgnoreCase("HAPPY_HOUR")) {
      if (endDate != null) {
        if (singleOffer.getEnd_date_description() == null
            || singleOffer.getEnd_date_description().equalsIgnoreCase("")
            || singleOffer.getEnd_date_description().equalsIgnoreCase("null")) {
          endDateText.setText(
              "Valid Till- " + StaticVariables.getEndDateInWords(singleOffer.getEnd_date()));
          endDate.setText("" + StaticVariables.getTimer(singleOffer.getEnd_date()));
        } else endDate.setText("" + singleOffer.getEnd_date_description());
      }
    } else {
      endDate.setVisibility(View.INVISIBLE);
    }

    if (singleOffer.getOffer_type().equalsIgnoreCase("EXCLUSIVE"))
      redeemButton.setVisibility(View.VISIBLE);
    else redeemButton.setVisibility(View.GONE);

    Thread t =
        new Thread() {

          @Override
          public void run() {
            try {
              while (!isInterrupted()) {
                Thread.sleep(900);
                runOnUiThread(
                    new Runnable() {
                      @Override
                      public void run() {
                        if (singleOffer.getEnd_date_description() == null
                            || singleOffer.getEnd_date_description().equalsIgnoreCase("")
                            || singleOffer.getEnd_date_description().equalsIgnoreCase("null"))
                          endDate.setText("" + StaticVariables.getTimer(singleOffer.getEnd_date()));
                        else endDate.setText("" + singleOffer.getEnd_date_description());
                      }
                    });
              }
            } catch (InterruptedException e) {
            }
          }
        };

    t.start();

    uploadButton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            progressDialog.setProgressDialog("Please Wait..", false);
            StringRequest uploadOffer =
                new StringRequest(
                    PrepareLinks.getUploadNewOfferLink(singleOffer),
                    new Response.Listener<String>() {
                      @Override
                      public void onResponse(String response) {
                        try {
                          JSONArray jsonArray = new JSONArray(response);
                          JSONObject jsonObject;
                          if (jsonArray
                              .getJSONObject(0)
                              .getString("result")
                              .equalsIgnoreCase("success")) {
                            new AlertDialog.Builder(OfferInformation.this)
                                .setTitle("Offer Upload Status")
                                .setMessage("Offer Uploaded Successfully !")
                                .setPositiveButton(
                                    "Okay",
                                    new DialogInterface.OnClickListener() {
                                      public void onClick(DialogInterface dialog, int which) {
                                        Intent mStartActivity =
                                            new Intent(OfferInformation.this, SplashScreen.class);
                                        mStartActivity.addFlags(
                                            Intent.FLAG_ACTIVITY_CLEAR_TASK
                                                | Intent.FLAG_ACTIVITY_NEW_TASK);
                                        int mPendingIntentId = 123456;
                                        PendingIntent mPendingIntent =
                                            PendingIntent.getActivity(
                                                OfferInformation.this,
                                                mPendingIntentId,
                                                mStartActivity,
                                                PendingIntent.FLAG_CANCEL_CURRENT);
                                        AlarmManager mgr =
                                            (AlarmManager) getSystemService(Context.ALARM_SERVICE);
                                        mgr.set(
                                            AlarmManager.RTC,
                                            System.currentTimeMillis() + 100,
                                            mPendingIntent);
                                        System.exit(0);
                                      }
                                    })
                                .setCancelable(false)
                                .show();
                          } else {
                            new AlertDialog.Builder(OfferInformation.this)
                                .setTitle("Offer Upload Status")
                                .setMessage("Error Uploading Offer.Please Try Again !")
                                .setPositiveButton(
                                    "Okay",
                                    new DialogInterface.OnClickListener() {
                                      public void onClick(DialogInterface dialog, int which) {
                                        ((OfferInformation) mContext).finish();
                                        dialog.dismiss();
                                      }
                                    })
                                .setIcon(R.drawable.ic_error_red)
                                .setCancelable(false)
                                .show();
                          }
                        } catch (JSONException e) {
                          e.printStackTrace();
                        }
                        progressDialog.stopProgressDialog();
                      }
                    },
                    new Response.ErrorListener() {
                      @Override
                      public void onErrorResponse(VolleyError error) {
                        error.printStackTrace();
                        new AlertDialog.Builder(OfferInformation.this)
                            .setTitle("Offer Upload Status")
                            .setMessage("Error Uploading Offer.Please Try Again !")
                            .setPositiveButton(
                                "Okay",
                                new DialogInterface.OnClickListener() {
                                  public void onClick(DialogInterface dialog, int which) {
                                    dialog.dismiss();
                                  }
                                })
                            .setIcon(R.drawable.ic_error_red)
                            .setCancelable(false)
                            .show();
                        progressDialog.stopProgressDialog();
                      }
                    });

            RequestQueue queue = Volley.newRequestQueue(OfferInformation.this);
            queue.add(uploadOffer);
            queue.start();
          }
        });
  }