List of usage examples for android.util TypedValue applyDimension
public static float applyDimension(int unit, float value, DisplayMetrics metrics)
From source file:com.donsen.svg.ui.common.AnimatedSvgView.java
private void rebuildGlyphData() { SvgPathParser parser = new SvgPathParser() { @Override//from w w w . j ava 2 s . co m protected float transformX(float x) { return x * mWidth / mViewport.x; } @Override protected float transformY(float y) { return y * mHeight / mViewport.y; } }; mGlyphData = new GlyphData[mGlyphStrings.length]; for (int i = 0; i < mGlyphStrings.length; i++) { mGlyphData[i] = new GlyphData(); try { mGlyphData[i].path = parser.parsePath(mGlyphStrings[i]); } catch (ParseException e) { mGlyphData[i].path = new Path(); Log.e(TAG, "Couldn't parse path", e); } PathMeasure pm = new PathMeasure(mGlyphData[i].path, true); while (true) { mGlyphData[i].length = Math.max(mGlyphData[i].length, pm.getLength()); if (!pm.nextContour()) { break; } } mGlyphData[i].paint = new Paint(); mGlyphData[i].paint.setStyle(Paint.Style.STROKE); mGlyphData[i].paint.setAntiAlias(true); mGlyphData[i].paint.setColor(Color.WHITE); mGlyphData[i].paint.setStrokeWidth( TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 1, getResources().getDisplayMetrics())); } }
From source file:com.amitupadhyay.aboutexample.ui.widget.CollapsingTitleLayout.java
private void recalculate(int width) { // reset stateful objects that might change over measure passes paint.setTextSize(collapsedTextSize); displayText = new SpannableStringBuilder(title); // Calculate line height; ensure it' a multiple of 4dp to sit on the grid final float fourDip = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 4, getResources().getDisplayMetrics()); Paint.FontMetricsInt fm = paint.getFontMetricsInt(); int fontHeight = Math.abs(fm.ascent - fm.descent) + fm.leading; final int baselineAlignedLineHeight = (int) (fourDip * (float) Math.ceil(lineHeightHint / fourDip)); lineSpacingAdd = Math.max(0, baselineAlignedLineHeight - fontHeight); // now create the layout with our desired insets & line height createLayout(width, lineSpacingAdd); // adjust the title top inset to vertically center text with the toolbar collapsedHeight = (int) Math.max(ViewUtils.getActionBarSize(getContext()), (fourDip + baselineAlignedLineHeight + fourDip)); titleInsetTop = (collapsedHeight - baselineAlignedLineHeight) / 2f; if (lineCount == 1) { // single line mode layout = null;//from www . j a v a2 s .c o m collapsingText = new CollapsingTextHelper(this); collapsingText.setText(title); collapsingText.setCollapsedBounds(titleInsetStart, 0, width - titleInsetEnd, (int) collapsedHeight); collapsingText.setExpandedBounds(titleInsetStart, (int) titleInsetTop, width - titleInsetEnd, getMinimumHeight() - titleInsetBottom); collapsingText.setCollapsedTextColor(paint.getColor()); collapsingText.setExpandedTextColor(paint.getColor()); collapsingText.setCollapsedTextSize(collapsedTextSize); int expandedTitleTextSize = (int) Math.max(collapsedTextSize, ViewUtils.getSingleLineTextSize(displayText.toString(), paint, width - titleInsetStart - titleInsetEnd, collapsedTextSize, maxExpandedTextSize, 0.5f, getResources().getDisplayMetrics())); collapsingText.setExpandedTextSize(expandedTitleTextSize); collapsingText.setExpandedTextGravity(GravityCompat.START | Gravity.BOTTOM); collapsingText.setCollapsedTextGravity(GravityCompat.START | Gravity.CENTER_VERTICAL); collapsingText.setTypeface(paint.getTypeface()); textTop = getHeight() - titleInsetBottom - fontHeight; scrollRange = getMinimumHeight() - (int) collapsedHeight; } else { // multi-line mode // bottom align the text textTop = getDesiredHeight() - titleInsetBottom - layout.getHeight(); // pre-calculate at what scroll offsets lines should disappear scrollRange = (int) (textTop - titleInsetTop); final int fadeDistance = layout.getLineBottom(0) - layout.getLineBaseline(0); lines = new Line[lineCount]; for (int i = 1; i < lineCount; i++) { int lineBottomScrollOffset = scrollRange + ((lineCount - i - 1) * baselineAlignedLineHeight); lines[i] = new Line(layout.getLineStart(i), layout.getLineEnd(i), new TextColorSpan(paint.getColor()), lineBottomScrollOffset, lineBottomScrollOffset + fadeDistance); } } calculatedWithWidth = width; }
From source file:com.annanovas.bestprice.DashBoardEditActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_dash_board_edit); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar);/* w ww . j ava 2 s .c om*/ ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.setHomeButtonEnabled(true); actionBar.setDisplayHomeAsUpEnabled(true); } // chosenBrandList.add(new ArrayList<String>()); // chosenBrandList.add(new ArrayList<String>()); // chosenBrandList.add(new ArrayList<String>()); etAddress = (EditText) findViewById(R.id.et_address); etEmail = (EditText) findViewById(R.id.et_email); etShopName = (EditText) findViewById(R.id.et_shop_name); etDrivingLicense = (EditText) findViewById(R.id.et_driving_licence); etNid = (EditText) findViewById(R.id.et_nid); etExperience = (EditText) findViewById(R.id.et_experience); etFirstName = (EditText) findViewById(R.id.et_first_name); etMiddleName = (EditText) findViewById(R.id.et_middle_name); etLastName = (EditText) findViewById(R.id.et_last_name); etPhoneNumber = (EditText) findViewById(R.id.et_phone); tvAddress = (TextView) findViewById(R.id.tv_address); tvArea = (TextView) findViewById(R.id.tv_area); tvDealerShip = (LinearLayout) findViewById(R.id.tv_dealership); tvDealerShipWith = (TextView) findViewById(R.id.tv_dealership_content); tvSelectedProduct = (TextView) findViewById(R.id.tv_select_product_content); tvProduct = (LinearLayout) findViewById(R.id.tv_select_product); buttonSubmit = (Button) findViewById(R.id.button_submit); areaLayout = (LinearLayout) findViewById(R.id.layout_area); brandLayout = (LinearLayout) findViewById(R.id.layout_brand); productLayout = (LinearLayout) findViewById(R.id.layout_product); layoutCamera = (LinearLayout) findViewById(R.id.layout_camera); layoutGallery = (LinearLayout) findViewById(R.id.layout_gallery); userImage = (ImageView) findViewById(R.id.iv_user_image); areaRecyclerView = (RecyclerView) findViewById(R.id.recycler_view_area); brandRecyclerView = (RecyclerView) findViewById(R.id.recycler_view_brand); productRecyclerView = (RecyclerView) findViewById(R.id.recycler_view_product); etProductSearch = (EditText) findViewById(R.id.et_product_name); etBrandSearch = (EditText) findViewById(R.id.et_brand_name); etAreaSearch = (EditText) findViewById(R.id.et_area_name); layoutSearchArea = (LinearLayout) findViewById(R.id.layout_search_area); layoutSearchProduct = (LinearLayout) findViewById(R.id.layout_search_product); layoutSearchBrand = (LinearLayout) findViewById(R.id.layout_search_brand); tvSelectedBrand = (TextView) findViewById(R.id.tv_selected_brand); tvSelectedArea = (TextView) findViewById(R.id.tv_setect_area); ivArrow1 = (ImageView) findViewById(R.id.iv_arrow1); ivArrow2 = (ImageView) findViewById(R.id.iv_arrow2); ivArrow3 = (ImageView) findViewById(R.id.iv_arrow3); ivArrow4 = (ImageView) findViewById(R.id.iv_arrow4); myDB = MyDatabaseManager.getInstance(getApplicationContext()); sharedPreferences = getSharedPreferences(AppGlobal.MY_PREFS_NAME, MODE_PRIVATE); userType = sharedPreferences.getInt("user_type", 1); int imageDimen = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_PX, getResources().getDimension(R.dimen.size_150dp), getResources().getDisplayMetrics()); myDB.open(); Cursor cursor = myDB.getUserInfo(userType, sharedPreferences.getString("user_phone_number", "")); if (userType == AppGlobal.CAR_OWNER) { userImage.setImageResource(R.drawable.ic_car_owner); tvAddress.setVisibility(View.VISIBLE); etAddress.setVisibility(View.VISIBLE); tvArea.setVisibility(View.VISIBLE); areaLayout.setVisibility(View.VISIBLE); if (!cursor.isLast()) { while (cursor.moveToNext()) { etFirstName.setText(cursor.getString(cursor.getColumnIndex("firstname"))); etMiddleName.setText(cursor.getString(cursor.getColumnIndex("middlename"))); etLastName.setText(cursor.getString(cursor.getColumnIndex("lastname"))); if (cursor.getString(cursor.getColumnIndex("address")) != null && !cursor.getString(cursor.getColumnIndex("address")).equals("null")) { etAddress.setText(cursor.getString(cursor.getColumnIndex("address"))); } etPhoneNumber.setText(cursor.getString(cursor.getColumnIndex("phone"))); etEmail.setText(cursor.getString(cursor.getColumnIndex("email"))); etShopName.setText(cursor.getString(cursor.getColumnIndex("shopname"))); areaId = cursor.getInt(cursor.getColumnIndex("area_id")); if (areaId != 0) { tvSelectedArea.setText(myDB.getAreaName(areaId)); } else { tvSelectedArea.setText(getResources().getString(R.string.select_area)); } if (cursor.getString(cursor.getColumnIndex("image")) != null && !cursor.getString(cursor.getColumnIndex("image")).equals("null")) { Glide.with(getApplicationContext()) .load(AppGlobal.userImagePath + cursor.getString(cursor.getColumnIndex("image"))) .error(R.drawable.ic_supplier).dontAnimate().override(imageDimen, imageDimen) .into(userImage); } else { userImage.setImageResource(R.drawable.ic_car_owner); } } } cursor.close(); generateAreaRecyclerView(); } else if (userType == AppGlobal.SUPPLIER) { tvAddress.setVisibility(View.VISIBLE); etAddress.setVisibility(View.VISIBLE); tvDealerShip.setVisibility(View.VISIBLE); tvProduct.setVisibility(View.VISIBLE); tvArea.setVisibility(View.VISIBLE); brandLayout.setVisibility(View.VISIBLE); productLayout.setVisibility(View.VISIBLE); areaLayout.setVisibility(View.VISIBLE); etShopName.setVisibility(View.VISIBLE); if (!cursor.isLast()) { while (cursor.moveToNext()) { etFirstName.setText(cursor.getString(cursor.getColumnIndex("firstname"))); etMiddleName.setText(cursor.getString(cursor.getColumnIndex("middlename"))); etLastName.setText(cursor.getString(cursor.getColumnIndex("lastname"))); etPhoneNumber.setText(cursor.getString(cursor.getColumnIndex("phone"))); etEmail.setText(cursor.getString(cursor.getColumnIndex("email"))); etShopName.setText(cursor.getString(cursor.getColumnIndex("shopname"))); etAddress.setText(cursor.getString(cursor.getColumnIndex("address"))); areaId = cursor.getInt(cursor.getColumnIndex("area_id")); if (areaId != 0) { tvSelectedArea.setText(myDB.getAreaName(areaId)); } else { tvSelectedArea.setText(getResources().getString(R.string.select_area)); } selectedProductIdList = myDB.getSelectedProductList(cursor.getInt(cursor.getColumnIndex("id"))); chosenBrandIdList = myDB.getSelectedBrandList(cursor.getInt(cursor.getColumnIndex("id"))); if (cursor.getString(cursor.getColumnIndex("image")) != null && !cursor.getString(cursor.getColumnIndex("image")).equals("null")) { Glide.with(getApplicationContext()) .load(AppGlobal.userImagePath + cursor.getString(cursor.getColumnIndex("image"))) .error(R.drawable.ic_supplier).dontAnimate().override(imageDimen, imageDimen) .into(userImage); } else { userImage.setImageResource(R.drawable.ic_supplier); } } } cursor.close(); generateAreaRecyclerView(); generateProductRecyclerView(); } else if (userType == AppGlobal.DRIVER) { etDrivingLicense.setVisibility(View.VISIBLE); etNid.setVisibility(View.VISIBLE); etExperience.setVisibility(View.VISIBLE); if (!cursor.isLast()) { while (cursor.moveToNext()) { etFirstName.setText(cursor.getString(cursor.getColumnIndex("firstname"))); etMiddleName.setText(cursor.getString(cursor.getColumnIndex("middlename"))); etLastName.setText(cursor.getString(cursor.getColumnIndex("lastname"))); etAddress.setText(cursor.getString(cursor.getColumnIndex("address"))); etPhoneNumber.setText(cursor.getString(cursor.getColumnIndex("phone"))); etEmail.setText(cursor.getString(cursor.getColumnIndex("email"))); etDrivingLicense.setText(cursor.getString(cursor.getColumnIndex("drivinglicence"))); etNid.setText(cursor.getString(cursor.getColumnIndex("nid"))); etExperience.setText(cursor.getString(cursor.getColumnIndex("yearofexperience"))); if (cursor.getString(cursor.getColumnIndex("image")) != null && !cursor.getString(cursor.getColumnIndex("image")).equals("null")) { Glide.with(getApplicationContext()) .load(AppGlobal.userImagePath + cursor.getString(cursor.getColumnIndex("image"))) .error(R.drawable.ic_supplier).dontAnimate().override(imageDimen, imageDimen) .into(userImage); } else { userImage.setImageResource(R.drawable.ic_car_owner); } } } cursor.close(); } else if (userType == AppGlobal.SHOP_WORKER) { etShopName.setVisibility(View.VISIBLE); etNid.setVisibility(View.VISIBLE); if (!cursor.isLast()) { while (cursor.moveToNext()) { etFirstName.setText(cursor.getString(cursor.getColumnIndex("firstname"))); etMiddleName.setText(cursor.getString(cursor.getColumnIndex("middlename"))); etLastName.setText(cursor.getString(cursor.getColumnIndex("lastname"))); etAddress.setText(cursor.getString(cursor.getColumnIndex("address"))); etPhoneNumber.setText(cursor.getString(cursor.getColumnIndex("phone"))); etEmail.setText(cursor.getString(cursor.getColumnIndex("email"))); etShopName.setText(cursor.getString(cursor.getColumnIndex("shopname"))); etNid.setText(cursor.getString(cursor.getColumnIndex("nid"))); if (cursor.getString(cursor.getColumnIndex("image")) != null && !cursor.getString(cursor.getColumnIndex("image")).equals("null")) { Glide.with(getApplicationContext()) .load(AppGlobal.userImagePath + cursor.getString(cursor.getColumnIndex("image"))) .error(R.drawable.ic_supplier).dontAnimate().override(imageDimen, imageDimen) .into(userImage); } else { userImage.setImageResource(R.drawable.ic_car_owner); } } } cursor.close(); } myDB.close(); areaLayout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (layoutSearchArea.getVisibility() == View.GONE) { layoutSearchArea.setVisibility(View.VISIBLE); areaRecyclerView.setVisibility(View.VISIBLE); ivArrow2.setImageDrawable( ContextCompat.getDrawable(getApplicationContext(), R.drawable.ic_up_arrow)); } else { layoutSearchArea.setVisibility(View.GONE); areaRecyclerView.setVisibility(View.GONE); ivArrow2.setImageDrawable( ContextCompat.getDrawable(getApplicationContext(), R.drawable.ic_down_arrow)); } } }); brandLayout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (selectedProductIdList.size() == 0) { Toast.makeText(getApplicationContext(), R.string.add_product, Toast.LENGTH_SHORT).show(); return; } if (layoutSearchBrand.getVisibility() == View.GONE) { layoutSearchBrand.setVisibility(View.VISIBLE); brandRecyclerView.setVisibility(View.VISIBLE); ivArrow3.setImageDrawable( ContextCompat.getDrawable(getApplicationContext(), R.drawable.ic_up_arrow)); } else { layoutSearchBrand.setVisibility(View.GONE); brandRecyclerView.setVisibility(View.GONE); ivArrow3.setImageDrawable( ContextCompat.getDrawable(getApplicationContext(), R.drawable.ic_down_arrow)); } } }); productLayout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (layoutSearchProduct.getVisibility() == View.GONE) { layoutSearchProduct.setVisibility(View.VISIBLE); productRecyclerView.setVisibility(View.VISIBLE); ivArrow1.setImageDrawable( ContextCompat.getDrawable(getApplicationContext(), R.drawable.ic_up_arrow)); } else { layoutSearchProduct.setVisibility(View.GONE); productRecyclerView.setVisibility(View.GONE); ivArrow1.setImageDrawable( ContextCompat.getDrawable(getApplicationContext(), R.drawable.ic_down_arrow)); } } }); layoutCamera.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { try { Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); File file = createImageFile(); imageUri = String.valueOf(file); // showLog(imageUri); Uri photoURI = FileProvider.getUriForFile(getApplicationContext(), BuildConfig.APPLICATION_ID + ".provider", file); intent.putExtra(MediaStore.EXTRA_OUTPUT, photoURI); startActivityForResult(intent, REQUEST_CAMERA); } catch (IOException e) { e.printStackTrace(); } } }); layoutGallery.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent intent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI); intent.setType("image/*"); startActivityForResult(Intent.createChooser(intent, "Select File"), SELECT_FILE); } }); buttonSubmit.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { progressDialog = new ProgressDialog(DashBoardEditActivity.this); progressDialog.setMessage(getResources().getString(R.string.please_wait)); progressDialog.setCancelable(false); progressDialog.show(); UpdateUserInfo updateUserInfo = new UpdateUserInfo(getApplicationContext()); updateUserInfo.signUpListener = DashBoardEditActivity.this; //viewEnable(false); if (userType == AppGlobal.CAR_OWNER) { boolean hasError = false; boolean hasPhoneNoError = false; if (etFirstName.getText().length() == 0) { etFirstName.setError(getResources().getString(R.string.enter_first_name)); hasError = true; } if (etLastName.getText().length() == 0) { etLastName.setError(getResources().getString(R.string.enter_last_name)); hasError = true; } if (etPhoneNumber.getText().length() == 0) { etPhoneNumber.setError(getResources().getString(R.string.enter_phone_no)); hasError = true; hasPhoneNoError = true; } if (!hasPhoneNoError && etPhoneNumber.getText().length() != 11) { etPhoneNumber.setError(getResources().getString(R.string.enter_valid_phone_no)); hasError = true; } if (etEmail.getText().length() != 0 && !Patterns.EMAIL_ADDRESS.matcher(etEmail.getText().toString()).matches()) { etEmail.setError(getResources().getString(R.string.enter_valid_email)); hasError = true; } if (etAddress.getText().length() == 0) { etAddress.setError(getResources().getString(R.string.enter_address)); hasError = true; } if (hasError) { if (progressDialog.isShowing()) progressDialog.dismiss(); return; } HashMap<String, String> params = new HashMap<>(); params.put("authentication", AppGlobal.authentication); params.put("api_token", sharedPreferences.getString("api_token", "")); params.put("phone", etPhoneNumber.getText().toString()); params.put("firstname", etFirstName.getText().toString()); if (!etMiddleName.getText().toString().equals("")) { params.put("middlename", etMiddleName.getText().toString()); } params.put("lastname", etLastName.getText().toString()); params.put("district_id", "1"); params.put("area_id", String.valueOf(areaId)); params.put("address", etAddress.getText().toString()); if (!etEmail.getText().toString().equals("")) { params.put("email", etEmail.getText().toString()); } if (!image.equals("")) { params.put("image", image); } updateUserInfo.parseData(params, "updateCarOwnerInfo"); } else if (userType == AppGlobal.SUPPLIER) { boolean hasError = false; boolean hasPhoneNoError = false; if (etFirstName.getText().length() == 0) { etFirstName.setError(getResources().getString(R.string.enter_first_name)); hasError = true; } if (etLastName.getText().length() == 0) { etLastName.setError(getResources().getString(R.string.enter_last_name)); hasError = true; } if (etPhoneNumber.getText().length() == 0) { etPhoneNumber.setError(getResources().getString(R.string.enter_phone_no)); hasError = true; hasPhoneNoError = true; } if (!hasPhoneNoError && etPhoneNumber.getText().length() != 11) { etPhoneNumber.setError(getResources().getString(R.string.enter_valid_phone_no)); hasError = true; } if (etEmail.getText().length() != 0 && !Patterns.EMAIL_ADDRESS.matcher(etEmail.getText().toString()).matches()) { etEmail.setError(getResources().getString(R.string.enter_valid_email)); hasError = true; } if (etShopName.getText().length() == 0) { etShopName.setError(getResources().getString(R.string.enter_shop_name)); hasError = true; } if (etAddress.getText().length() == 0) { etAddress.setError(getResources().getString(R.string.enter_address)); hasError = true; } if (hasError) { if (progressDialog.isShowing()) progressDialog.dismiss(); return; } HashMap<String, String> params = new HashMap<>(); params.put("authentication", AppGlobal.authentication); params.put("api_token", sharedPreferences.getString("api_token", "")); params.put("phone", etPhoneNumber.getText().toString()); params.put("firstname", etFirstName.getText().toString()); if (!etMiddleName.getText().toString().equals("")) { params.put("middlename", etMiddleName.getText().toString()); } params.put("lastname", etLastName.getText().toString()); params.put("district_id", "1"); params.put("area_id", String.valueOf(areaId)); if (!etEmail.getText().toString().equals("")) { params.put("email", etEmail.getText().toString()); } if (!image.equals("")) { params.put("image", image); } params.put("shopname", etShopName.getText().toString()); params.put("address", etAddress.getText().toString()); for (int i = 0; i < selectedProductIdList.size(); i++) { params.put("products[" + i + "]", selectedProductIdList.get(i)); } for (int i = 0; i < chosenBrandIdList.size(); i++) { params.put("brands[" + i + "]", chosenBrandIdList.get(i)); } updateUserInfo.parseData(params, "updateSupplierInfo"); } else if (userType == AppGlobal.DRIVER) { boolean hasError = false; boolean hasPhoneNoError = false; boolean hasDrivingLicenseNoError = false; boolean hasNidNoError = false; if (etFirstName.getText().length() == 0) { etFirstName.setError(getResources().getString(R.string.enter_first_name)); hasError = true; } if (etLastName.getText().length() == 0) { etLastName.setError(getResources().getString(R.string.enter_last_name)); hasError = true; } if (etPhoneNumber.getText().length() == 0) { etPhoneNumber.setError(getResources().getString(R.string.enter_phone_no)); hasError = true; hasPhoneNoError = true; } if (!hasPhoneNoError && etPhoneNumber.getText().length() != 11) { etPhoneNumber.setError(getResources().getString(R.string.enter_valid_phone_no)); hasError = true; } if (etEmail.getText().length() != 0 && !Patterns.EMAIL_ADDRESS.matcher(etEmail.getText().toString()).matches()) { etEmail.setError(getResources().getString(R.string.enter_valid_email)); hasError = true; } if (etDrivingLicense.getText().length() == 0) { etDrivingLicense.setError(getResources().getString(R.string.enter_driving_licence)); hasError = true; hasDrivingLicenseNoError = true; } if (!hasDrivingLicenseNoError && etDrivingLicense.getText().length() != 15) { etDrivingLicense.setError(getResources().getString(R.string.enter_valid_driving_licence)); hasError = true; } if (etNid.getText().length() == 0) { etNid.setError(getResources().getString(R.string.enter_nid_no)); hasError = true; hasNidNoError = true; } if (!hasNidNoError && etNid.getText().length() != 17) { etNid.setError(getResources().getString(R.string.enter_valid_nid)); hasError = true; } if (etExperience.getText().length() == 0) { etExperience.setError(getResources().getString(R.string.enter_year_of_experience)); hasError = true; } if (hasError) { if (progressDialog.isShowing()) progressDialog.dismiss(); return; } HashMap<String, String> params = new HashMap<>(); params.put("authentication", AppGlobal.authentication); params.put("api_token", sharedPreferences.getString("api_token", "")); params.put("phone", etPhoneNumber.getText().toString()); params.put("firstname", etFirstName.getText().toString()); if (!etMiddleName.getText().toString().equals("")) { params.put("middlename", etMiddleName.getText().toString()); } params.put("lastname", etLastName.getText().toString()); params.put("drivinglicence", etDrivingLicense.getText().toString()); params.put("nid", etNid.getText().toString()); params.put("yearofexperience", etExperience.getText().toString()); if (!etEmail.getText().toString().equals("")) { params.put("email", etEmail.getText().toString()); } if (!image.equals("")) { params.put("image", image); } updateUserInfo.parseData(params, "updateDriverInfo"); } else if (userType == AppGlobal.SHOP_WORKER) { boolean hasError = false; boolean hasPhoneNoError = false; if (etFirstName.getText().length() == 0) { etFirstName.setError(getResources().getString(R.string.enter_first_name)); hasError = true; } if (etLastName.getText().length() == 0) { etLastName.setError(getResources().getString(R.string.enter_last_name)); hasError = true; } if (etPhoneNumber.getText().length() == 0) { etPhoneNumber.setError(getResources().getString(R.string.enter_phone_no)); hasError = true; hasPhoneNoError = true; } if (!hasPhoneNoError && etPhoneNumber.getText().length() != 11) { etPhoneNumber.setError(getResources().getString(R.string.enter_valid_phone_no)); hasError = true; } if (etEmail.getText().length() != 0 && !Patterns.EMAIL_ADDRESS.matcher(etEmail.getText().toString()).matches()) { etEmail.setError(getResources().getString(R.string.enter_valid_email)); hasError = true; } if (etNid.getText().length() == 0) { etNid.setError(getResources().getString(R.string.enter_nid_no)); hasError = true; } if (etShopName.getText().length() == 0) { etShopName.setError(getResources().getString(R.string.enter_shop_name)); hasError = true; } if (hasError) { if (progressDialog.isShowing()) progressDialog.dismiss(); return; } HashMap<String, String> params = new HashMap<>(); params.put("authentication", AppGlobal.authentication); params.put("api_token", sharedPreferences.getString("api_token", "")); params.put("phone", etPhoneNumber.getText().toString()); params.put("firstname", etFirstName.getText().toString()); if (!etMiddleName.getText().toString().equals("")) { params.put("middlename", etMiddleName.getText().toString()); } params.put("lastname", etLastName.getText().toString()); params.put("nid", etNid.getText().toString()); params.put("shopname", etShopName.getText().toString()); if (!etEmail.getText().toString().equals("")) { params.put("email", etEmail.getText().toString()); } if (!image.equals("")) { params.put("image", image); } updateUserInfo.parseData(params, "updateWorkerInfo"); } } }); }
From source file:babbq.com.searchplace.SearchActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_search); ButterKnife.bind(this); setupSearchView();/*from w w w .ja va2 s. c om*/ auto = TransitionInflater.from(this).inflateTransition(R.transition.auto); mGoogleApiClient = new GoogleApiClient.Builder(this).addApi(LocationServices.API) .addApi(Places.GEO_DATA_API).addConnectionCallbacks(this).addOnConnectionFailedListener(this) .build(); mAdapter = new TestAdapter(null, v -> { int position = results.getChildLayoutPosition(v); //Toast.makeText(getActivity(), "#" + position, Toast.LENGTH_SHORT).show(); PendingResult result = Places.GeoDataApi.getPlaceById(mGoogleApiClient, String.valueOf(mAdapter.getElementAt(position).placeId)); result.setResultCallback(mCoordinatePlaceDetailsCallback); }, mGoogleApiClient); dataManager = new SearchDataManager(mGoogleApiClient, mCoordinatePlaceDetailsCallback) { @Override public void onDataLoaded(List<? extends PlaceAutocomplete> data) { if (data != null && data.size() > 0) { if (results.getVisibility() != View.VISIBLE) { TransitionManager.beginDelayedTransition(container, auto); progress.setVisibility(View.GONE); results.setVisibility(View.VISIBLE); // fab.setVisibility(View.VISIBLE); fab.setAlpha(0.6f); fab.setScaleX(0f); fab.setScaleY(0f); fab.animate().alpha(1f).scaleX(1f).scaleY(1f).setStartDelay(800L).setDuration(300L) .setInterpolator(AnimationUtils.loadInterpolator(SearchActivity.this, android.R.interpolator.linear_out_slow_in)); } // mAdapter.addAndResort(data); mAdapter.setList(data); } else { TransitionManager.beginDelayedTransition(container, auto); progress.setVisibility(View.GONE); setNoResultsVisibility(View.VISIBLE); } } }; // mAdapter = new FeedAdapter(this, dataManager, columns); results.setAdapter(mAdapter); GridLayoutManager layoutManager = new GridLayoutManager(this, columns); // layoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() { // // @Override // public int getSpanSize(int position) { // return mAdapter.getItemColumnSpan(position); // } // }); results.setLayoutManager(layoutManager); results.addOnScrollListener(new InfiniteScrollListener(layoutManager, dataManager) { @Override public void onLoadMore() { dataManager.loadMore(); } }); results.setHasFixedSize(true); results.addOnScrollListener(gridScroll); // extract the search icon's location passed from the launching activity, minus 4dp to // compensate for different paddings in the views searchBackDistanceX = getIntent().getIntExtra(EXTRA_MENU_LEFT, 0) - (int) TypedValue .applyDimension(TypedValue.COMPLEX_UNIT_DIP, 4, getResources().getDisplayMetrics()); searchIconCenterX = getIntent().getIntExtra(EXTRA_MENU_CENTER_X, 0); // translate icon to match the launching screen then animate back into position searchBackContainer.setTranslationX(searchBackDistanceX); searchBackContainer.animate().translationX(0f).setDuration(650L) .setInterpolator(AnimationUtils.loadInterpolator(this, android.R.interpolator.fast_out_slow_in)); // transform from search icon to back icon AnimatedVectorDrawable searchToBack = (AnimatedVectorDrawable) ContextCompat.getDrawable(this, R.drawable.avd_search_to_back); searchBack.setImageDrawable(searchToBack); searchToBack.start(); // for some reason the animation doesn't always finish (leaving a part arrow!?) so after // the animation set a static drawable. Also animation callbacks weren't added until API23 // so using post delayed :( // TODO fix properly!! searchBack.postDelayed(new Runnable() { @Override public void run() { searchBack.setImageDrawable( ContextCompat.getDrawable(SearchActivity.this, R.drawable.ic_arrow_back_padded)); } }, 600); // fade in the other search chrome searchBackground.animate().alpha(1f).setDuration(300L) .setInterpolator(AnimationUtils.loadInterpolator(this, android.R.interpolator.linear_out_slow_in)); searchView.animate().alpha(1f).setStartDelay(400L).setDuration(400L) .setInterpolator(AnimationUtils.loadInterpolator(this, android.R.interpolator.linear_out_slow_in)) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { searchView.requestFocus(); ImeUtils.showIme(searchView); } }); // animate in a scrim over the content behind scrim.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() { @Override public boolean onPreDraw() { scrim.getViewTreeObserver().removeOnPreDrawListener(this); AnimatorSet showScrim = new AnimatorSet(); showScrim.playTogether( ViewAnimationUtils.createCircularReveal(scrim, searchIconCenterX, searchBackground.getBottom(), 0, (float) Math.hypot(searchBackDistanceX, scrim.getHeight() - searchBackground.getBottom())), ObjectAnimator.ofArgb(scrim, ViewUtils.BACKGROUND_COLOR, Color.TRANSPARENT, ContextCompat.getColor(SearchActivity.this, R.color.scrim))); showScrim.setDuration(400L); showScrim.setInterpolator(AnimationUtils.loadInterpolator(SearchActivity.this, android.R.interpolator.linear_out_slow_in)); showScrim.start(); return false; } }); onNewIntent(getIntent()); }
From source file:android.support.v7.widget.AppCompatTextViewAutoSizeHelper.java
/** * Specify whether this widget should automatically scale the text to try to perfectly fit * within the layout bounds by using the default auto-size configuration. * * @param autoSizeTextType the type of auto-size. Must be one of * {@link TextViewCompat#AUTO_SIZE_TEXT_TYPE_NONE} or * {@link TextViewCompat#AUTO_SIZE_TEXT_TYPE_UNIFORM} * * @attr ref R.styleable#AppCompatTextView_autoSizeTextType * * @see #getAutoSizeTextType()/*from w w w . j a v a 2 s . c o m*/ * * @hide */ @RestrictTo(LIBRARY_GROUP) void setAutoSizeTextTypeWithDefaults(@TextViewCompat.AutoSizeTextType int autoSizeTextType) { if (supportsAutoSizeText()) { switch (autoSizeTextType) { case TextViewCompat.AUTO_SIZE_TEXT_TYPE_NONE: clearAutoSizeConfiguration(); break; case TextViewCompat.AUTO_SIZE_TEXT_TYPE_UNIFORM: final DisplayMetrics displayMetrics = mContext.getResources().getDisplayMetrics(); final float autoSizeMinTextSizeInPx = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, DEFAULT_AUTO_SIZE_MIN_TEXT_SIZE_IN_SP, displayMetrics); final float autoSizeMaxTextSizeInPx = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, DEFAULT_AUTO_SIZE_MAX_TEXT_SIZE_IN_SP, displayMetrics); validateAndSetAutoSizeTextTypeUniformConfiguration(autoSizeMinTextSizeInPx, autoSizeMaxTextSizeInPx, DEFAULT_AUTO_SIZE_GRANULARITY_IN_PX); if (setupAutoSizeText()) { autoSizeText(); } break; default: throw new IllegalArgumentException("Unknown auto-size text type: " + autoSizeTextType); } } }
From source file:com.cloudexplorers.plugins.childBrowser.ChildBrowser.java
/** * Display a new browser with the specified URL. * //from www . jav a2 s.c om * @param url * The url to load. * @param jsonObject */ public String showWebPage(final String url, JSONObject options) { // Determine if we should hide the location bar. if (options != null) { showLocationBar = options.optBoolean("showLocationBar", true); } // Create dialog in new thread Runnable runnable = new Runnable() { /** * Convert our DIP units to Pixels * * @return int */ private int dpToPixels(int dipValue) { int value = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, (float) dipValue, cordova.getActivity().getResources().getDisplayMetrics()); return value; } public void run() { // Let's create the main dialog dialog = new Dialog(cordova.getActivity(), android.R.style.Theme_NoTitleBar); dialog.getWindow().getAttributes().windowAnimations = android.R.style.Animation_Dialog; dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setCancelable(true); dialog.setOnDismissListener(new DialogInterface.OnDismissListener() { public void onDismiss(DialogInterface dialog) { try { JSONObject obj = new JSONObject(); obj.put("type", CLOSE_EVENT); sendUpdate(obj, false); } catch (JSONException e) { Log.d(LOG_TAG, "Should never happen"); } } }); // Main container layout LinearLayout main = new LinearLayout(cordova.getActivity()); main.setOrientation(LinearLayout.VERTICAL); // Toolbar layout RelativeLayout toolbar = new RelativeLayout(cordova.getActivity()); toolbar.setLayoutParams( new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, this.dpToPixels(44))); toolbar.setPadding(this.dpToPixels(2), this.dpToPixels(2), this.dpToPixels(2), this.dpToPixels(2)); toolbar.setHorizontalGravity(Gravity.LEFT); toolbar.setVerticalGravity(Gravity.TOP); // Action Button Container layout RelativeLayout actionButtonContainer = new RelativeLayout(cordova.getActivity()); actionButtonContainer.setLayoutParams( new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); actionButtonContainer.setHorizontalGravity(Gravity.LEFT); actionButtonContainer.setVerticalGravity(Gravity.CENTER_VERTICAL); actionButtonContainer.setId(1); // Back button ImageButton back = new ImageButton(cordova.getActivity()); RelativeLayout.LayoutParams backLayoutParams = new RelativeLayout.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.FILL_PARENT); backLayoutParams.addRule(RelativeLayout.ALIGN_LEFT); back.setLayoutParams(backLayoutParams); back.setContentDescription("Back Button"); back.setId(2); try { back.setImageBitmap(loadDrawable("www/childbrowser/icon_arrow_left.png")); } catch (IOException e) { Log.e(LOG_TAG, e.getMessage(), e); } back.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { goBack(); } }); // Forward button ImageButton forward = new ImageButton(cordova.getActivity()); RelativeLayout.LayoutParams forwardLayoutParams = new RelativeLayout.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.FILL_PARENT); forwardLayoutParams.addRule(RelativeLayout.RIGHT_OF, 2); forward.setLayoutParams(forwardLayoutParams); forward.setContentDescription("Forward Button"); forward.setId(3); try { forward.setImageBitmap(loadDrawable("www/childbrowser/icon_arrow_right.png")); } catch (IOException e) { Log.e(LOG_TAG, e.getMessage(), e); } forward.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { goForward(); } }); // Edit Text Box edittext = new EditText(cordova.getActivity()); RelativeLayout.LayoutParams textLayoutParams = new RelativeLayout.LayoutParams( LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT); textLayoutParams.addRule(RelativeLayout.RIGHT_OF, 1); textLayoutParams.addRule(RelativeLayout.LEFT_OF, 5); edittext.setLayoutParams(textLayoutParams); edittext.setId(4); edittext.setSingleLine(true); edittext.setText(url); edittext.setInputType(InputType.TYPE_TEXT_VARIATION_URI); edittext.setImeOptions(EditorInfo.IME_ACTION_GO); edittext.setInputType(InputType.TYPE_NULL); // Will not except input... // Makes the text // NON-EDITABLE edittext.setOnKeyListener(new View.OnKeyListener() { public boolean onKey(View v, int keyCode, KeyEvent event) { // If the event is a key-down event on the "enter" button if ((event.getAction() == KeyEvent.ACTION_DOWN) && (keyCode == KeyEvent.KEYCODE_ENTER)) { navigate(edittext.getText().toString()); return true; } return false; } }); // Close button ImageButton close = new ImageButton(cordova.getActivity()); RelativeLayout.LayoutParams closeLayoutParams = new RelativeLayout.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.FILL_PARENT); closeLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); close.setLayoutParams(closeLayoutParams); forward.setContentDescription("Close Button"); close.setId(5); try { close.setImageBitmap(loadDrawable("www/childbrowser/icon_close.png")); } catch (IOException e) { Log.e(LOG_TAG, e.getMessage(), e); } close.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { closeDialog(); } }); // WebView webview = new WebView(cordova.getActivity()); webview.setLayoutParams( new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); webview.setWebChromeClient(new WebChromeClient()); WebViewClient client = new ChildBrowserClient(edittext); webview.setWebViewClient(client); WebSettings settings = webview.getSettings(); settings.setJavaScriptEnabled(true); settings.setJavaScriptCanOpenWindowsAutomatically(true); settings.setBuiltInZoomControls(true); settings.setPluginsEnabled(true); settings.setDomStorageEnabled(true); webview.loadUrl(url); webview.setId(6); webview.getSettings().setLoadWithOverviewMode(true); webview.getSettings().setUseWideViewPort(true); webview.getSettings().setJavaScriptEnabled(true); webview.getSettings().setPluginsEnabled(true); webview.requestFocus(); webview.requestFocusFromTouch(); // Add the back and forward buttons to our action button container // layout actionButtonContainer.addView(back); actionButtonContainer.addView(forward); // Add the views to our toolbar toolbar.addView(actionButtonContainer); toolbar.addView(edittext); toolbar.addView(close); // Don't add the toolbar if its been disabled if (getShowLocationBar()) { // Add our toolbar to our main view/layout main.addView(toolbar); } // Add our webview to our main view/layout main.addView(webview); WindowManager.LayoutParams lp = new WindowManager.LayoutParams(); lp.copyFrom(dialog.getWindow().getAttributes()); lp.width = WindowManager.LayoutParams.FILL_PARENT; lp.height = WindowManager.LayoutParams.FILL_PARENT; dialog.setContentView(main); dialog.show(); dialog.getWindow().setAttributes(lp); } private Bitmap loadDrawable(String filename) throws java.io.IOException { InputStream input = cordova.getActivity().getAssets().open(filename); return BitmapFactory.decodeStream(input); } }; this.cordova.getActivity().runOnUiThread(runnable); return ""; }
From source file:br.ufrgs.ufrgsmapas.libs.SearchBox.java
/*** * Hide the searchbox using the circle animation. Can be called regardless of result list length * @param activity Activity/*from w ww . jav a 2 s .c o m*/ */ public void hideCircularly(Activity activity) { Display display = activity.getWindowManager().getDefaultDisplay(); Point size = new Point(); final FrameLayout layout = (FrameLayout) activity.getWindow().getDecorView() .findViewById(android.R.id.content); RelativeLayout root = (RelativeLayout) findViewById(R.id.search_root); display.getSize(size); Resources r = getResources(); float px = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 96, r.getDisplayMetrics()); int cx = layout.getLeft() + layout.getRight(); int cy = layout.getTop(); int finalRadius = (int) Math.max(layout.getWidth() * 1.5, px); SupportAnimator animator = ViewAnimationUtils.createCircularReveal(root, cx, cy, 0, finalRadius); animator.setInterpolator(new ReverseInterpolator()); animator.setDuration(500); animator.start(); animator.addListener(new SupportAnimator.AnimatorListener() { @Override public void onAnimationStart() { } @Override public void onAnimationEnd() { setVisibility(View.GONE); } @Override public void onAnimationCancel() { } @Override public void onAnimationRepeat() { } }); }
From source file:com.arman.efficientqhalgoforch.SuperAwesomeCardFragment.java
@Override public View onCreateView(final LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if (position == 2) { final View vv = inflater.inflate(R.layout.benchmark_lay, null); Button run = (Button) vv.findViewById(R.id.runAlgor); Button reset = (Button) vv.findViewById(R.id.cleardata); run.setOnClickListener(new View.OnClickListener() { @Override/* www . j a v a 2 s.com*/ public void onClick(View v) { EditText thrd; EditText points; EditText canvasY; EditText canvasX; thrd = (EditText) vv.findViewById(R.id.numberTreadstxt); points = (EditText) vv.findViewById(R.id.numberpoints); canvasX = (EditText) vv.findViewById(R.id.canvasWidth); canvasY = (EditText) vv.findViewById(R.id.canvasHeight); int threads = Integer.valueOf(thrd.getText().toString()); int ponts = Integer.valueOf(points.getText().toString()); int canvY = Integer.valueOf(canvasY.getText().toString()); int canvX = Integer.valueOf(canvasX.getText().toString()); if (threads < 1) threads = 1; if (ponts <= 2) ponts = 3; if (threads > ponts) threads = ponts - 1; if (threads > 25) threads = 25; if (canvX + 100 < ponts) canvX = canvX + 100; if (canvY + 100 < ponts) canvY = canvY + 100; final Point2DCloud point2DCloud = new Point2DCloud(getActivity(), ponts /* points */, Utils.WIDTH = canvY, Utils.HEIGHT = canvX, true); int animTime = 10; final int finalThreads = threads; final int finalPonts = ponts; QuickHull qh = new QuickHull(point2DCloud, threads, true, animTime, new DoneListener() { @Override public void jobDone(int id, float time) { mResults.add(new DataHolder(finalThreads, time, finalPonts)); updateChart(mResults); } }); qh.run(); algorithmIndex = 2; } }); reset.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { for (DataHolder hld : mResults) { mResults.remove(hld); } updateChart(mResults); } }); doHardcore(vv, inflater); return vv; } else if (position == 3) { final View vv = inflater.inflate(R.layout.benchmark_lay, null); ((TextView) vv.findViewById(R.id.nametxt)).setText(" GrahamScan\n Multithreaded Benchmark"); Button run = (Button) vv.findViewById(R.id.runAlgor); Button resetgr = (Button) vv.findViewById(R.id.cleardata); run.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { EditText thrd; EditText points; EditText canvasY; EditText canvasX; thrd = (EditText) vv.findViewById(R.id.numberTreadstxt); points = (EditText) vv.findViewById(R.id.numberpoints); canvasX = (EditText) vv.findViewById(R.id.canvasWidth); canvasY = (EditText) vv.findViewById(R.id.canvasHeight); int threads = Integer.valueOf(thrd.getText().toString()); int ponts = Integer.valueOf(points.getText().toString()); int canvY = Integer.valueOf(canvasY.getText().toString()); int canvX = Integer.valueOf(canvasX.getText().toString()); if (threads < 1) threads = 1; if (ponts <= 2) ponts = 3; if (threads > ponts) threads = ponts - 1; if (threads > 25) threads = 25; if (canvX + 100 < ponts) canvX = canvX + 100; if (canvY + 100 < ponts) canvY = canvY + 100; final Point2DCloud point2DCloud = new Point2DCloud(getActivity(), ponts /* points */, Utils.WIDTH = canvY, Utils.HEIGHT = canvX, true); int animTime = 10; final int finalThreads = threads; final int finalPonts = ponts; GrahamScanParallel gh = new GrahamScanParallel(point2DCloud, threads, true, animTime, new DoneListener() { @Override public void jobDone(int id, float time) { mGResults.add(new DataHolder(finalThreads, time, finalPonts)); updateChart(mGResults); } }); gh.run(); algorithmIndex = 3; } }); resetgr.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { for (DataHolder hld : mGResults) { mGResults.remove(hld); } updateChart(mGResults); } }); doHardcore(vv, inflater); return vv; } else { if (position == 0) { LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); FrameLayout fl = new FrameLayout(getActivity()); fl.setLayoutParams(params); final int margin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, getResources().getDisplayMetrics()); View v = (View) inflater.inflate(R.layout.intro, null); params.setMargins(margin, margin, margin, margin); v.setLayoutParams(params); v.setLayoutParams(params); //v.setBackgroundResource(R.drawable.background_card); fl.addView(v); //fl.addView(btn); return fl; } else if (position == 1) { LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); FrameLayout fl = new FrameLayout(getActivity()); fl.setLayoutParams(params); final int margin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, getResources().getDisplayMetrics()); View v = (View) inflater.inflate(R.layout.algo, null); params.setMargins(margin, margin, margin, margin); v.setLayoutParams(params); v.setLayoutParams(params); //v.setBackgroundResource(R.drawable.background_card); fl.addView(v); return fl; } } return null; }
From source file:cc.softwarefactory.lokki.android.fragments.PlacesFragment.java
private RoundedImageView createAvatar(final String email) { int sizeInDip = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, (float) 65, getResources().getDisplayMetrics()); RoundedImageView image = new RoundedImageView(getActivity()); image.setTag(email);/* w w w . j a va 2s. co m*/ image.setCornerRadius(100f); image.setBorderWidth(0f); image.setPadding(20, 0, 0, 0); image.setLayoutParams(new LinearLayout.LayoutParams(sizeInDip, sizeInDip)); image.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { MainApplication.emailBeingTracked = email; LocalBroadcastManager.getInstance(getActivity()).sendBroadcast(new Intent("LOCATION-UPDATE")); LocalBroadcastManager.getInstance(getActivity()).sendBroadcast(new Intent("GO-TO-MAP")); } }); return image; }
From source file:com.android.switchaccess.OptionManager.java
@Override public void onSharedPreferenceChanged(SharedPreferences prefs, String key) { Context context = mOverlayController.getContext(); mOptionScanningEnabled = SwitchAccessPreferenceActivity.isOptionScanningEnabled(context); String defaultWeight = context.getString(R.string.pref_highlight_weight_default); /* Configure highlighting */ for (int i = 0; i < mOptionPaintArray.length; ++i) { /*/*from ww w .j a v a 2 s .com*/ * Always configure element 0 based on preferences. Only configure the others if we're * option scanning. */ if ((i == 0) || mOptionScanningEnabled) { String hexStringColor = prefs.getString(mHighlightColorPrefKeys[i], mHighlightColorDefaults[i]); int color = Integer.parseInt(hexStringColor, 16); mOptionPaintArray[i].setColor(color); mOptionPaintArray[i].setAlpha(255); String stringWeight = prefs.getString(mHighlightWeightPrefKeys[i], defaultWeight); int weight = Integer.valueOf(stringWeight); DisplayMetrics dm = context.getResources().getDisplayMetrics(); float strokeWidth = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, weight, dm); mOptionPaintArray[i].setStrokeWidth(strokeWidth); } else { mOptionPaintArray[i].setColor(Color.TRANSPARENT); } } mStartScanAutomatically = prefs.getBoolean(context.getString(R.string.switch_access_auto_start_scan_key), false); }