private static void drawToast(View v, Rect vRect) {
   // TODO Auto-generated method stub
   if (mToast != null) {
     View tv = mToast.getView();
     if (tv.getWidth() > 0 && tv.isShown()) {
       if (LOGD_ENABLED) Log.i(LOG_TAG, "==== " + tv.getWidth() + " " + tv.getHeight());
       Bitmap second = Utils.createPngScreenshot(tv, tv.getWidth(), tv.getHeight(), 0);
       if (LOGD_ENABLED)
         Log.d(
             LOG_TAG,
             "====== gravity "
                 + mToast.getGravity()
                 + " x y "
                 + mToast.getXOffset()
                 + " "
                 + mToast.getYOffset()
                 + " "
                 + mToast.getHorizontalMargin()
                 + " "
                 + mToast.getVerticalMargin());
       PointF fromPoint =
           new PointF(
               (v.getWidth() - tv.getWidth()) / 2,
               v.getHeight() - vRect.top - mToast.getYOffset() - tv.getHeight());
       if (LOGD_ENABLED)
         Log.i(LOG_TAG, "======= prepare menu view2  ========" + fromPoint.x + " " + fromPoint.y);
       mCapture = Utils.mixtureBitmap2(mCapture, second, fromPoint, 0, (float) 1.0);
     }
   }
 }
  /**
   * Event handler for the search stock button. Which calls the stock query class. Sends the
   * information about the medication and pharmacy to class which will carry out the search.
   *
   * @param view
   */
  public void searchStock(View view) {

    // if statement checks that the medication has been recorded and the pharmacy selected
    if (selectedPharmacy != null && contentTxt != null) {
      // separates the QR result string into individual elements
      String[] separated = temp.split("_");
      String stock_id = separated[0];
      String medication = separated[1];
      String quantity = separated[3];
      // Intent send to the stock query class giving it the information it needs to carry out the
      // stock check.
      Intent dataIntent = new Intent(getApplicationContext(), StockQuery.class);
      // pharmacy name and id have been returned to the main activity after selection on the map
      dataIntent.putExtra("pharmacy name", pharmacy_name);
      dataIntent.putExtra("pharmacy id", pharmacy_id);
      dataIntent.putExtra("stock id", stock_id);
      dataIntent.putExtra("medication", medication);
      dataIntent.putExtra("quantity", quantity);
      // starts the StockQuery activity and sends the intent
      startActivity(dataIntent);
    } else {
      Toast toast =
          Toast.makeText(
              getApplicationContext(),
              "Unable to search please select medication and pharmacy",
              Toast.LENGTH_LONG);
      toast.getView().setBackgroundColor(Color.WHITE);
      TextView v = (TextView) toast.getView().findViewById(android.R.id.message);
      v.setTextColor(Color.BLACK);
      toast.setGravity(Gravity.CENTER, 0, 0);
      toast.show();
    }
  }
Exemple #3
0
  public Toast build() {

    @SuppressLint("ShowToast")
    Toast toast = Toast.makeText(context, text, duration);

    if (backgroundResource > 0) {
      toast.getView().setBackgroundResource(backgroundResource);
    }

    if (backgroundColor < 0) {
      View view = toast.getView();
      Drawable toaster =
          DrawableCompat.wrap(view.getBackground().mutate().getConstantState().newDrawable());
      DrawableCompat.setTint(toaster, backgroundColor);

      if (Build.VERSION.SDK_INT > 15) {
        view.setBackground(toaster);
      } else {
        //noinspection deprecation
        view.setBackgroundDrawable(toaster);
      }
    }

    if (textColor < 0) {
      ((TextView) ((ViewGroup) toast.getView()).getChildAt(0)).setTextColor(textColor);
    }

    return toast;
  }
  public void displayToastWithImg(Context context, String str, int resId, int position) {

    Toast toast = Toast.makeText(context, str, Toast.LENGTH_SHORT);
    LinearLayout toastView = (LinearLayout) toast.getView();
    ImageView imageView = new ImageView(context);
    imageView.setImageResource(resId);
    switch (position) {
      case 1:
        toastView.addView(imageView, 0);
        break;
      case 2:
        toastView.addView(imageView, 1);
        break;
      case 3:
        toastView.setOrientation(LinearLayout.HORIZONTAL);
        toastView.addView(imageView, 0);
        break;
      case 4:
        toastView.setOrientation(LinearLayout.HORIZONTAL);
        toastView.addView(imageView, 1);
        break;
      default:
        break;
    }
    toast.show();
  }
Exemple #5
0
  /** Ends the effect and then executes the runnable after the effect is finished. */
  public void end(final Runnable runnableOnODone) {
    // Cancel the tooltip if it's still showing.
    if ((tooltip != null) && (tooltip.getView().getParent() != null)) {
      tooltip.cancel();
      tooltip = null;
    }
    // End tool editing by canceling unfinished touch events.
    toolKit.cancel();
    // Output the pushed filter if it wasn't outputted.
    if (pushedFilter && disableFilterOutput) {
      outputFilter();
    }

    // Wait till last output callback is done before finishing.
    if ((lastFilterChangedCallback == null) || lastFilterChangedCallback.done) {
      finish(runnableOnODone);
    } else {
      lastFilterChangedCallback.runnableOnReady =
          new Runnable() {

            @Override
            public void run() {
              finish(runnableOnODone);
            }
          };
    }
  }
 /**
  * 显示错误信息
  *
  * @param err 需要显示的错误信息
  */
 public void ShowError(String err) {
   Toast toast = Toast.makeText(sInstance, "Error: " + err, 500);
   toast.setGravity(Gravity.CENTER_VERTICAL | Gravity.CENTER_HORIZONTAL, 0, 0);
   toast.getView().setBackgroundResource(R.drawable.red_round_rect);
   toast.show();
   Log.e(this.getClass().getName(), err);
 }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_nutrients_new_item);

    setTag(this.getClass().getSimpleName());
    // set activity name
    toolbarsManager = new ToolbarsManager(this);
    toolbarsManager.setNameActivity(this.getTitle().toString());

    nutrientsDBAdapter = new NutrientsDBAdapter();
    newName = (EditText) findViewById(R.id.nutrients_new_name);
    newProteins = (EditText) findViewById(R.id.nutrients_new_proteins);
    newFats = (EditText) findViewById(R.id.nutrients_new_fats);
    newCarbs = (EditText) findViewById(R.id.nutrients_new_carbs);
    newCalories = (EditText) findViewById(R.id.nutrients_new_calories);

    warningToast = Toast.makeText(this, "", Toast.LENGTH_SHORT);
    toastText = (TextView) warningToast.getView().findViewById(android.R.id.message);
    toastText.setTextColor(Color.RED);

    intent = getIntent();
    if (intent.getAction().equals(Intent.ACTION_EDIT))
      atEdit = true; // It's updating existing item, not inserting
    else atEdit = false; // It's inserting new row
  }
 public void toastText(String message) {
   Toast toast = Toast.makeText(getApplicationContext(), message, Toast.LENGTH_LONG);
   LinearLayout toastLayout = (LinearLayout) toast.getView();
   TextView toastTV = (TextView) toastLayout.getChildAt(0);
   toastTV.setTextSize(30);
   toast.setGravity(Gravity.CENTER_HORIZONTAL, 0, 0);
   toast.show();
 }
 public void showmessageThedataisuploadedsuccessfully() {
   Toast toast =
       Toast.makeText(this.context, "The data is uploaded successfully", Toast.LENGTH_SHORT);
   LinearLayout toastLayout = (LinearLayout) toast.getView();
   TextView toastTV = (TextView) toastLayout.getChildAt(0);
   toastTV.setTextSize(30);
   toastTV.setBackgroundColor(Color.BLACK);
   toast.show();
 }
Exemple #10
0
 public void onClick(View view) {
   Toast toast = Toast.makeText(getApplicationContext(), "New Toast", Toast.LENGTH_LONG);
   toast.setGravity(Gravity.CENTER, 0, 0);
   LinearLayout ll = (LinearLayout) toast.getView();
   ImageView catIV = new ImageView(getApplicationContext());
   catIV.setImageResource(R.drawable.cat);
   ll.addView(catIV, 0);
   toast.show();
 }
 /**
  * Non-Android query method that returns whether or not a particular custom {@code Toast} has been
  * shown.
  *
  * @param message the message to search for
  * @param layoutResourceIdToCheckForMessage the id of the resource that contains the toast
  *     messages
  * @return whether the {@code Toast} was requested
  */
 public static boolean showedCustomToast(
     CharSequence message, int layoutResourceIdToCheckForMessage) {
   for (Toast toast : shownToasts) {
     String text =
         ((TextView) toast.getView().findViewById(layoutResourceIdToCheckForMessage))
             .getText()
             .toString();
     if (text.equals(message.toString())) {
       return true;
     }
   }
   return false;
 }
Exemple #12
0
  public void displayToastWithOutImg(Context context, String str, int resId, int orientation) {

    Toast toast = Toast.makeText(context, str, Toast.LENGTH_LONG);
    View toastView = toast.getView();
    ImageView imgView = new ImageView(context);
    imgView.setImageResource(resId);
    LinearLayout lyt = new LinearLayout(context);
    lyt.setOrientation(orientation);
    lyt.addView(imgView);
    lyt.addView(toastView);
    toast.setView(lyt);
    toast.show();
  }
  /**
   * function handle scan result receives the intent from the scanned activity
   *
   * @param requestCode scanned code
   * @param resultCode result of scanned code
   * @param intent intent
   */
  public void onActivityResult(int requestCode, int resultCode, Intent intent) {

    // retrieve scan result and parse it into an instance of the intent result class
    IntentResult scanningResult =
        IntentIntegrator.parseActivityResult(requestCode, resultCode, intent);

    // check we have a result
    if (scanningResult != null) {
      // save the result to a string variable
      String scanContent = scanningResult.getContents();
      // put the scan result in a new file
      try {
        FileOutputStream fout = openFileOutput(file, MODE_WORLD_READABLE);
        fout.write(scanContent.getBytes()); // write the result to the file
        fout.close();
      } catch (FileNotFoundException e) {
        e.printStackTrace();
      } catch (IOException e) {
        e.printStackTrace();
      }
      // Toast message to inform the user that the database has been recorded.
      Toast toast =
          Toast.makeText(
              getApplicationContext(),
              "Medication recorded. Now select pharmacy",
              Toast.LENGTH_LONG);
      toast.getView().setBackgroundColor(Color.WHITE);
      TextView v = (TextView) toast.getView().findViewById(android.R.id.message);
      v.setTextColor(Color.BLACK);
      toast.setGravity(Gravity.CENTER, 0, 0);
      toast.show();
    } else {
      // if no result is recorded inform the user
      Toast toast =
          Toast.makeText(getApplicationContext(), "No scan data received!", Toast.LENGTH_LONG);
      toast.show();
    }
  }
    //显示 Toast
    private void makeToast(Context context){
        if("".equals(lunarTextToast))
            return;

        try{
            Toast toast = Toast.makeText(context, lunarTextToast, Toast.LENGTH_LONG);
            if(_notify_comp){
                //如果打开了美化
                LinearLayout toastView = (LinearLayout) toast.getView();

                //尝试寻找toastView布局中的textView节点
                TextView toastTextView;
                try{
                    toastTextView = (TextView) toastView.getChildAt(0);
                }catch(Throwable t){
                    try {
                        toastTextView = (TextView) toastView.getChildAt(1);
                    } catch (Throwable tt) {
                        toastTextView = null;
                    }
                }
                if(toastTextView != null){
                    toastTextView.setGravity(Gravity.CENTER_HORIZONTAL); //调整Toast为文字居中
                    toastTextView.setLineSpacing(0, 1.2f); //调整Toast文字行间距为原来的1.2倍
                }

                if(_notify_center)
                    //Toast在屏幕正中显示
                    toast.setGravity(Gravity.CENTER, 0, 0);

                if(_notify_icon){
                    //为Toast加入背景
                    toastView.setBackground((context.getResources().getDrawable(isFest ? ic_toast_bg_fest : ic_toast_bg)));
                    toastView.setGravity(Gravity.CENTER);
                    if(toastTextView != null){
                        toastTextView.setTextColor(0xFF000000);
                        toastTextView.setPadding(0, 15, 0, 0);
                        toastTextView.setShadowLayer(0, 0, 0, 0X00FFFFFF);
                    }
                }
            }
            toast.show();
            makeVibration(context);
        }catch(Throwable t){
            XposedBridge.log("xStatusBarLunarDate: Toast error:");
            XposedBridge.log(t);
        }
    }
    @Override
    public synchronized void onValueSelected(int i, int i1, PointValue pointValue) {
      final java.text.DateFormat timeFormat = DateFormat.getTimeFormat(context);
      // Won't give the exact time of the reading but the time on the grid: close enough.
      Long time = ((long) pointValue.getX()) * FUZZER;
      if (tooltip != null) {
        tooltip.cancel();
      }
      tooltip =
          Toast.makeText(
              context,
              timeFormat.format(time) + ": " + Math.round(pointValue.getY() * 10) / 10d,
              Toast.LENGTH_LONG);
      View view = tooltip.getView();
      view.setBackgroundColor(Color.parseColor("#212121"));

      tooltip.show();
    }
Exemple #16
0
  private static Toast show(Toast toast, Context context, String msg, int duration) {
    if (toast != null) {
      ((TextView) toast.getView()).setText(msg);
    } else {
      toast = new Toast(context);
      TextView tv = new TextView(context);
      tv.setBackgroundResource(R.drawable.toast_bg);
      tv.setGravity(Gravity.CENTER_VERTICAL);

      tv.setTextColor(Color.WHITE);
      tv.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
      tv.setText(msg);

      toast.setView(tv);
      toast.setGravity(Gravity.CENTER, 0, 0);
    }
    toast.setDuration(duration);
    toast.show();

    return toast;
  }
    @Override
    protected void onPostExecute(String s) {

      try {
        JSONArray jsonArray = new JSONArray(s);
        noOfObjects = jsonArray.length();
        Log.v("Number of json Obj " + noOfObjects, "   pd Objects.....");
        // pd.dismiss();
        for (int j = 0; j < jsonArray.length(); j++) {

          JSONObject jObj = jsonArray.getJSONObject(j);
          //   Log.v("No of times " + j, "shhhhhhhhh");
          // int k = j + 1;
          // detailNo = ""+k;
          activitycontactName = jObj.getString("FirstName");

          aciviitycontact_id = jObj.getString("PK_ContactID");

          aciviitycontact_type = jObj.getString("ContactType");

          aciviitycontact_mobile = jObj.getString("Mobile");
          aciviitycontact_email = jObj.getString("Email");
          aciviitycontact_response_code = jObj.getString("ResponseCode");
          // Log.v("ResponseCode",response_code);

          // Adding detail to Array
          activitycontactidArray.add(aciviitycontact_id);
          activitycontactNameArray.add(activitycontactName);
          activitycontact_mobileArray.add(aciviitycontact_mobile);
          activitycontact_typeArray.add(aciviitycontact_type);
          activitycontact_EmailArray.add(aciviitycontact_email);
          // contact_typeArray.add(aciviitycontact_type);

        }
        for (int k = 0; k < activitycontactNameArray.size(); k++) {

          final ModelClass model = new ModelClass();

          // ******* Firstly take data in model object ******//**//*
          model.setContactName(activitycontactNameArray.get(k));
          model.setContact_ConType(activitycontact_typeArray.get(k));
          model.setContact_mobile(activitycontact_mobileArray.get(k));
          model.setContactID(activitycontactidArray.get(k));
          model.setContact_Email(activitycontact_EmailArray.get(k));
          // model.setPdrecordno(detailNoArray.get(k));
          activitycustomSearchlist.add(model);
        }

        activityadapter =
            new ActivityDetailAdapter(
                UserActivities.this, R.layout.contact_list_view_row, activitycustomSearchlist);
        listview1.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
        listview1.setAdapter(activityadapter);
      } catch (JSONException e) {
        e.printStackTrace();
        System.out.println(" Exception is caught here ......." + e.toString());
      }

      try {
        if (aciviitycontact_response_code.equals("1")) {

          /*    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

              @Override
              public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                  Log.v("inside on Itemclick", "" + position);
                  // Use "if else" only if header is added
                     ModelClass name = customListArray.get(position);
                       String Contactno =  name.getContactName();
                      Toast.makeText(getApplicationContext(), Contactno + "\n"+
                              checkBox_header.getId() + "\n" + checkBox_header.isChecked(),
                              Toast.LENGTH_SHORT).show();
              }
          });
          */

          Toast toast =
              Toast.makeText(
                  getApplicationContext(), "Total Records are : " + noOfObjects, Toast.LENGTH_LONG);
          toast.setGravity(Gravity.CENTER, 0, 0);
          toast.getView().setPadding(20, 20, 20, 20);
          toast.getView().setBackgroundColor(Color.parseColor("#7CB342"));
          toast.show();
          pDialog.dismiss();
        } else {
          Toast toast =
              Toast.makeText(
                  getApplicationContext(), "No Records Founds : " + noOfObjects, Toast.LENGTH_LONG);
          toast.setGravity(Gravity.BOTTOM, 0, 0);
          toast.getView().setPadding(20, 20, 20, 20);
          toast.getView().setBackgroundColor(Color.parseColor("#7CB342"));
          toast.show();
          pDialog.dismiss();
        }

      } catch (Exception e) {
        Toast.makeText(UserActivities.this, "Connection  Failed ", Toast.LENGTH_LONG).show();
        pDialog.dismiss();
      }
    }
 private void showNumberOverFlowErrorToast() {
   if (numberOverflowErrorToast == null || !numberOverflowErrorToast.getView().isShown()) {
     numberOverflowErrorToast = Toast.makeText(mContext, "Number Overflow!", Toast.LENGTH_SHORT);
     numberOverflowErrorToast.show();
   }
 }
    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
      View vi = convertView;

      if (vi == null) {

        /*
         * LayoutInflater
         */
        final LayoutInflater sInflater =
            (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

        /*
         * Inflate Custom List View
         */
        vi = sInflater.inflate(R.layout.contact_list_view_row, null, false);
      }

      TextView contactNameTv = (TextView) vi.findViewById(R.id.contact_fullNameTv);
      TextView contactTypeTv = (TextView) vi.findViewById(R.id.contact_typeTv);
      TextView contactMobileNoTv = (TextView) vi.findViewById(R.id.contact_mobileNoTv);
      checkBox = (CheckBox) vi.findViewById(R.id.contact_checkBox);
      // checkBox.setVisibility(View.INVISIBLE);

      /* **************ADDING CONTENTS**************** */

      final ModelClass tempValues = (ModelClass) mylistdata.get(position);
      contactNameTv.setText(tempValues.getContactName());
      String s = tempValues.getContactName();
      contactTypeTv.setText(tempValues.getContact_ConType());

      contactMobileNoTv.setText(tempValues.getContact_mobile());

      contactNameTv.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {

              Intent intent = new Intent(UserActivities.this, ContactProfileActivity.class);
              intent.putExtra("cname", tempValues.getContactName());
              intent.putExtra("type", tempValues.getContact_ConType());
              intent.putExtra("mob", tempValues.getContact_mobile());
              startActivity(intent);
            }
          });
      if (s.equals("null")) {
        checkBox.setVisibility(View.INVISIBLE);
        contactNameTv.setVisibility(View.INVISIBLE);
        contactTypeTv.setVisibility(View.INVISIBLE);
        contactMobileNoTv.setVisibility(View.INVISIBLE);

        Toast toast =
            Toast.makeText(getApplicationContext(), "No Records Founds : ", Toast.LENGTH_LONG);
        toast.setGravity(Gravity.CENTER, 0, 0);
        toast.getView().setPadding(20, 20, 20, 20);
        toast.getView().setBackgroundColor(Color.parseColor("#7CB342"));
        toast.show();
      }
      // holder.joiningDateTv.setText(tempValues.getJoiningDate());

      checkBox.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              ModelClass modelClass = mylistdata.get(position);

              String name = modelClass.getContactID();
              String email = modelClass.getContact_Email();
              // Toast.makeText(getApplicationContext(), name + "  "+ email,
              // Toast.LENGTH_SHORT).show();
              Log.v("Contact  ID ", name);
              System.out.println(" Exception is caught here ......." + email);
              Log.v("Contact  Email ", email);
              // adapter.remove(customListArray.get(i));
            }
          });

      checkBox.setOnCheckedChangeListener(
          new CompoundButton.OnCheckedChangeListener() {

            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
              if (isChecked) {

                // Saving Checked Position

                mChecked.put(position, isChecked);

                // Find if all the check boxes are true

                if (isAllValuesChecked()) {

                  // set HeaderCheck box to true

                  checkBox_header1.setChecked(isChecked);
                }

              } else {

                mChecked.delete(position);

                checkBox_header1.setChecked(isChecked);
              }
            }
          });

      // Set CheckBox "TRUE" or "FALSE" if mChecked == true

      checkBox.setChecked((mChecked.get(position) == true ? true : false));

      return vi;
    }