List of usage examples for android.widget TextView setTypeface
public void setTypeface(@Nullable Typeface tf, @Typeface.Style int style)
From source file:com.amaze.filemanager.adapters.TabSpinnerAdapter.java
@Override public View getDropDownView(final int position, View convertView, ViewGroup parent) { LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); View row = inflater.inflate(R.layout.spinner_dropdown_layout, parent, false); ma = ((Main) fragmentTransaction.findFragmentById(R.id.content_frame)); final TextView textView = (TextView) row.findViewById(R.id.spinnerText); LinearLayout linearLayout = (LinearLayout) row.findViewById(R.id.textParent); final SharedPreferences sharedPreferences1 = PreferenceManager.getDefaultSharedPreferences(context); String skin = sharedPreferences1.getString("skin_color", "#5677fc"); final int spinner_current = sharedPreferences1.getInt("spinner_selected", 0); ImageButton imageButton = (ImageButton) row.findViewById(R.id.spinnerButton); if (items.get(position).equals("/")) textView.setText(R.string.rootdirectory); else// w w w .ja v a2 s.co m textView.setText(new File(items.get(position)).getName()); imageButton.setBackgroundColor(Color.parseColor(skin)); if (position == spinner_current) { textView.setTextColor(Color.parseColor(skin)); textView.setTypeface(null, Typeface.BOLD); } linearLayout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { hideSpinnerDropDown(spinner); if (position == spinner_current) { } else { TabHandler tabHandler1 = new TabHandler(context, null, null, 1); Tab tab = tabHandler1.findTab(position); String name = tab.getPath(); //Toast.makeText(getActivity(), name, Toast.LENGTH_SHORT).show(); sharedPreferences1.edit().putString("current", name).apply(); sharedPreferences1.edit().putInt("spinner_selected", position).apply(); Main ma = ((Main) fragmentTransaction.findFragmentById(R.id.content_frame)); ma.loadlist(new File(tab.getPath()), false); Animation animationLeft = AnimationUtils.loadAnimation(getContext(), R.anim.tab_selection_left); Animation animationRight = AnimationUtils.loadAnimation(getContext(), R.anim.tab_selection_right); if (position < spinner_current) { ma.listView.setAnimation(animationLeft); ma.gridView.setAnimation(animationLeft); } else { ma.listView.setAnimation(animationRight); ma.gridView.setAnimation(animationRight); } } } }); imageButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { TabHandler tabHandler = new TabHandler(context, null, null, 1); Tab tab = tabHandler.findTab(position); if (position > spinner_current) { //Toast.makeText(getContext(), "Closed", Toast.LENGTH_SHORT).show(); items.remove(position); int old_tab = tab.getTab(); int a; for (a = old_tab; a < tabHandler.getTabsCount() - 1; a++) { int new_tab = a + 1; Tab tab1 = tabHandler.findTab(new_tab); String next_label = tab1.getLabel(); String next_path = tab1.getPath(); tabHandler.updateTab(new Tab(a, next_label, next_path)); } tabHandler.deleteTab(tabHandler.getTabsCount() - 1); hideSpinnerDropDown(spinner); } else if (position < spinner_current) { // Toast.makeText(getContext(), "Closed", Toast.LENGTH_SHORT).show(); items.remove(position); int old_tab = tab.getTab(); int a; for (a = old_tab; a < tabHandler.getTabsCount() - 1; a++) { int new_tab = a + 1; Tab tab1 = tabHandler.findTab(new_tab); String next_label = tab1.getLabel(); String next_path = tab1.getPath(); tabHandler.updateTab(new Tab(a, next_label, next_path)); } tabHandler.deleteTab(tabHandler.getTabsCount() - 1); int older_spinner_selected = sharedPreferences1.getInt("spinner_selected", 0); older_spinner_selected--; sharedPreferences1.edit().putInt("spinner_selected", older_spinner_selected).apply(); hideSpinnerDropDown(spinner); } else if (position == spinner_current) { if (tabHandler.getTabsCount() == 1) { // Toast.makeText(getContext(), "exits the app", Toast.LENGTH_SHORT).show(); ma.home(); } else if (tabHandler.getTabsCount() - 1 > position) { items.remove(position); int old_tab = tab.getTab(); int a; for (a = old_tab; a < tabHandler.getTabsCount() - 1; a++) { int new_tab = a + 1; Tab tab1 = tabHandler.findTab(new_tab); String next_label = tab1.getLabel(); String next_path = tab1.getPath(); tabHandler.updateTab(new Tab(a, next_label, next_path)); } tabHandler.deleteTab(tabHandler.getTabsCount() - 1); Tab tab1 = tabHandler.findTab(spinner_current); ma.loadlist(new File(tab1.getPath()), false); } else if (tabHandler.getTabsCount() - 1 == position) { items.remove(position); tabHandler.deleteTab(tabHandler.getTabsCount() - 1); int older_spinner_selected = sharedPreferences1.getInt("spinner_selected", 0); older_spinner_selected--; sharedPreferences1.edit().putInt("spinner_selected", older_spinner_selected).apply(); Tab tab1 = tabHandler.findTab(older_spinner_selected); Main ma = ((Main) fragmentTransaction.findFragmentById(R.id.content_frame)); ma.loadlist(new File(tab1.getPath()), false); } } } }); return row; }
From source file:com.photon.phresco.nativeapp.eshop.activity.ProductDetailActivity.java
/** * Create the details sections at the bottom of the screen dynamically * * @param details/*from w ww . ja v a2s . co m*/ * @throws NumberFormatException */ private void renderProdcutDetails(Map<String, String> details) { try { LinearLayout tl = (LinearLayout) findViewById(R.id.product_details_layout); int totalDetails = details.size(); int cnt = 1; PhrescoLogger.info(TAG + "renderProdcutDetails() - totalDetails : " + totalDetails); TextView lblDetailLabel = null; for (Entry<String, String> entry : details.entrySet()) { // Create a TextView to hold the label for product detail lblDetailLabel = new TextView(this); if (cnt == 1) { lblDetailLabel.setBackgroundResource(R.drawable.view_cart_item_top); } else if (cnt == totalDetails) { lblDetailLabel.setBackgroundResource(R.drawable.view_cart_item_bottom); } else { lblDetailLabel.setBackgroundResource(R.drawable.view_cart_item_middle); } lblDetailLabel.setText(entry.getKey() + ": " + entry.getValue()); lblDetailLabel.setGravity(Gravity.CENTER); lblDetailLabel.setTypeface(Typeface.DEFAULT, style.TextViewStyle); lblDetailLabel.setTextColor(Color.WHITE); lblDetailLabel.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT, 1.0f)); tl.addView(lblDetailLabel); cnt++; } } catch (Exception ex) { PhrescoLogger.info(TAG + "renderProdcutDetails - Exception : " + ex.toString()); PhrescoLogger.warning(ex); } }
From source file:com.equinox.prodriver.Activities.RegisterDriverActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_register_driver); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar);/*from w w w .j a v a2s . co m*/ getSupportActionBar().setDisplayHomeAsUpEnabled(true); context = this; appBarLayout = (AppBarLayout) findViewById(R.id.app_bar); appBarLayout.setExpanded(false, true); mainScrollView = (NestedScrollView) findViewById(R.id.content_register_driver); mainScrollView.setSmoothScrollingEnabled(true); selectorsLayouts = new ArrayList<>(); editDriver = new Driver(); preferredPlace = new PrologixPlace(); if (currentDriver == null) { getSupportActionBar().setTitle(getString(R.string.title_activity_register_driver)); if (savedInstanceState != null && savedInstanceState.getBoolean("EDITING")) { editDriver = tempDriver; if (editDriver == null) editDriver = new Driver(); } vehiclesList = new ArrayList<>(); } else { getSupportActionBar().setTitle(getString(R.string.title_activity_update_driver)); editDriver = currentDriver.clone(); if (editDriver.getPreferredAddress() != null) { preferredPlace.setAddress( driverGson.fromJson(driverGson.toJson(editDriver.getPreferredAddress()), GeoAddress.class)); preferredPlace.setLocation( driverGson.fromJson(driverGson.toJson(editDriver.getPreferredLocation()), LatLng.class)); } } storagePermission = new PermissionManager(this); if (!storagePermission.checkReadStoragePermission()) storagePermission.getReadStoragePermission(); registerEmailHeaderFragment = RegisterEmailHeaderFragment.newInstance(editDriver); vehicleIndicator = (ImageView) findViewById(R.id.driver_vehicle_indicator); if (editDriver.getVehicles() == null) editDriver.setVehicles(new ArrayList<Vehicle>()); vehicleRecyclerAdapter = new VehicleRecyclerAdapter(context, editDriver.getVehicles(), false); if (!editDriver.getVehicles().isEmpty()) setIndicator(context, vehicleIndicator, true); if (!editDriver.getVehicles().contains(createVehicle)) { editDriver.getVehicles().add(new Vehicle()); //TODO remove this.. just for testing only /*String vehicleId = "SA-3184VLB"; DriverTask driverTask = new DriverTask(vehicleFetcher, "en"); driverTask.getVehicle.execute(vehicleId);*/ } vehicleListView = (RecyclerView) findViewById(R.id.vehicle_list_view); vehicleListView.setLayoutManager(new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false)); vehicleListView.setHasFixedSize(true); vehicleListView.setAdapter(vehicleRecyclerAdapter); vehicleListView.setNestedScrollingEnabled(false); licenseIndicator = (ImageView) findViewById(R.id.license_info_indicator); licenseValueNumber = (TextView) findViewById(R.id.license_info_number); licenseValueExpiry = (TextView) findViewById(R.id.license_info_expiry); licenseImage = (ImageView) findViewById(R.id.license_image); licenseImageLoaded = (NetworkImageView) findViewById(R.id.license_image_loaded); licenseInfoLayout = (RelativeLayout) findViewById(R.id.license_info_layout); if (editDriver.getLicenseNumber() != null) { setIndicator(context, licenseIndicator, true); licenseValueNumber.setText(editDriver.getLicenseNumber()); licenseValueExpiry.setText(StringManipulation.getFormattedDate(editDriver.getLicenseExpiry())); if (editDriver.getLicenseImage() != null) licenseImageLoaded.setImageUrl(editDriver.getLicenseImage(), DataHolder.getInstance().getImageLoader()); } if (photo1 != null) licenseImage.setImageBitmap(photo1); licenseInfoLayout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent scanIdIntent = new Intent(context, CameraVisionActivity.class); scanIdIntent.putExtra("source", REQUEST_DRIVER_LICENSE); startActivity(scanIdIntent); } }); residenceIndicator = (ImageView) findViewById(R.id.residence_info_indicator); residenceValueNumber = (TextView) findViewById(R.id.residence_info_number); residenceValueExpiry = (TextView) findViewById(R.id.residence_info_expiry); residenceValueLegalName = (TextView) findViewById(R.id.residence_info_legal_name); residenceImage = (ImageView) findViewById(R.id.residence_image); residenceImageLoaded = (NetworkImageView) findViewById(R.id.residence_image_loaded); residenceInfoLayout = (RelativeLayout) findViewById(R.id.residence_info_layout); if (editDriver.getResidenceNumber() != null) { setIndicator(context, residenceIndicator, true); residenceValueNumber.setText(editDriver.getResidenceNumber()); residenceValueLegalName.setText(editDriver.getLegalName()); if (editDriver.getResidenceImage() != null) residenceImageLoaded.setImageUrl(editDriver.getResidenceImage(), DataHolder.getInstance().getImageLoader()); } if (photo2 != null) residenceImage.setImageBitmap(photo2); residenceInfoLayout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent scanIdIntent = new Intent(context, CameraVisionActivity.class); scanIdIntent.putExtra(SOURCE, REQUEST_RESIDENCE_ID); startActivity(scanIdIntent); } }); nationalityIndicator = (ImageView) findViewById(R.id.nationality_indicator); nationalityValue = (TextView) findViewById(R.id.nationality_value); nationalityLayout = (RelativeLayout) findViewById(R.id.nationality_layout); nationalityProgressLayout = (LinearLayout) findViewById(R.id.nationality_progress_layout); final RelativeLayout nationalitySelector = (RelativeLayout) findViewById(R.id.nationality_selector); selectorsLayouts.add(nationalitySelector); nationalitySelectorContent = (LinearLayout) findViewById(R.id.nationality_selector_content); countryTask = new CountryTask(countryListHandler, "en"); countryTask.getCountryList.execute("en"); if (editDriver.getNationality() != null) { setIndicator(context, nationalityIndicator, true); nationalityValue.setText(editDriver.getNationality().getCountryName()); } nationalityAuto = (InstantAutoComplete) findViewById(R.id.nationality_auto); nationalityLayout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { hideKeyboard(context); if (nationalitySelector.getVisibility() == View.GONE) { closeInactiveLayouts(appBarLayout, selectorsLayouts, nationalitySelector); mainScrollView.postDelayed(new Runnable() { @Override public void run() { mainScrollView.smoothScrollTo(0, nationalityLayout.getTop()); nationalityAuto.showDropDown(); } }, 1000); } if (countryTask.getCountryList.getStatus().equals(AsyncTask.Status.RUNNING)) { nationalityProgressLayout.setVisibility(View.VISIBLE); nationalitySelectorContent.setVisibility(View.GONE); } LinearLayout okayButton = (LinearLayout) findViewById(R.id.nationality_okay_button); okayButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (editDriver.getNationality() != null) { setIndicator(context, nationalityIndicator, true); nationalityValue.setText(editDriver.getNationality().getCountryName()); addressLayout.postDelayed(new Runnable() { @Override public void run() { addressLayout.performClick(); } }, 1000); } else { setIndicator(context, nationalityIndicator, false); nationalitySelector.setVisibility(View.GONE); } } }); LinearLayout cancelButton = (LinearLayout) findViewById(R.id.nationality_cancel_button); cancelButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { nationalitySelector.setVisibility(View.GONE); } }); } }); addressIndicator = (ImageView) findViewById(R.id.preferred_address_indicator); addressValue = (TextView) findViewById(R.id.preferred_address_value); addressLayout = (RelativeLayout) findViewById(R.id.preferred_address_layout); if (editDriver.getPreferredAddress() != null) { setIndicator(context, addressIndicator, true); preferredPlace.setAddress(transform(editDriver.getPreferredAddress())); preferredPlace.setLocation(transform(editDriver.getPreferredLocation())); addressValue.setText(preferredPlace.getAddress().getFullAddress()); } addressChooser = (FrameLayout) findViewById(R.id.preferred_address_chooser); selectorsLayouts.add(addressChooser); addressLayout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { hideKeyboard(context); try { if (addressChooser.getVisibility() == View.GONE) { closeInactiveLayouts(appBarLayout, selectorsLayouts, addressChooser); getSupportFragmentManager().beginTransaction() .replace(R.id.preferred_address_chooser, PlaceChooserFragment.newInstance(preferredPlace, placeChooseHandler)) .commit(); mainScrollView.postDelayed(new Runnable() { @Override public void run() { mainScrollView.smoothScrollTo(0, addressLayout.getTop()); } }, 1500); } else { addressChooser.setVisibility(View.GONE); getSupportFragmentManager().popBackStack(); } } catch (Resources.NotFoundException | OutOfMemoryError ignored) { } } }); final ImageView phoneIndicator = (ImageView) findViewById(R.id.driver_phone_indicator); final TextView phoneValue = (TextView) findViewById(R.id.driver_phone_value); if (editDriver.getPhoneNumber() != null) { setIndicator(context, phoneIndicator, true); phoneValue.setText(editDriver.getPhoneNumber().replace(currentCountry.getPhoneCode(), "")); } final LinearLayout phoneSelector = (LinearLayout) findViewById(R.id.driver_phone_selector); selectorsLayouts.add(phoneSelector); phoneLayout = (RelativeLayout) findViewById(R.id.driver_phone_layout); phoneLayout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { hideKeyboard(context); if (phoneSelector.getVisibility() == View.GONE) { closeInactiveLayouts(appBarLayout, selectorsLayouts, phoneSelector); mainScrollView.postDelayed(new Runnable() { @Override public void run() { mainScrollView.smoothScrollTo(0, phoneLayout.getTop()); } }, 1000); } final EditText input = (EditText) findViewById(R.id.phone_number); if (editDriver.getPhoneNumber() != null) input.setText(editDriver.getPhoneNumber().replace(currentCountry.getPhoneCode(), "")); TextView phoneCode = (TextView) findViewById(R.id.country_code); phoneCode.setText(currentCountry.getPhoneCode()); NetworkImageView countryFlag = (NetworkImageView) findViewById(R.id.country_flag); countryFlag.setImageUrl(currentCountry.getFlag(), DataHolder.getInstance().getImageLoader()); LinearLayout okayButton = (LinearLayout) findViewById(R.id.driver_phone_okay_button); okayButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (!input.getText().toString().isEmpty()) { String phoneNumberEdit = currentCountry.getPhoneCode() + input.getText().toString().replaceAll(" ", ""); editDriver.setPhoneNumber(phoneNumberEdit); phoneValue.setText(phoneNumberEdit); setIndicator(context, phoneIndicator, true); mainScrollView.postDelayed(new Runnable() { @Override public void run() { mainScrollView.smoothScrollTo(0, dobLayout.getTop()); } }, 1000); } else { phoneValue.setText(getString(R.string.driver_phone_hint)); setIndicator(context, phoneIndicator, false); } phoneSelector.setVisibility(View.GONE); } }); LinearLayout cancelButton = (LinearLayout) findViewById(R.id.driver_phone_cancel_button); cancelButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { phoneSelector.setVisibility(View.GONE); } }); } }); dobValue = (TextView) findViewById(R.id.driver_dob_value); if (editDriver.getDob() != null) dobValue.setText(StringManipulation.getFormattedDate(editDriver.getDob())); dobLayout = (RelativeLayout) findViewById(R.id.driver_dob_layout); dobLayout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { final Calendar calendar = Calendar.getInstance(); if (editDriver.getDob() != null) { dobValue.setText(StringManipulation.getFormattedDate(editDriver.getDob())); calendar.setTimeInMillis(editDriver.getDob()); } DatePickerDialog datePickerDialog = DatePickerDialog .newInstance(new DatePickerDialog.OnDateSetListener() { @Override public void onDateSet(DatePickerDialog view, int year, int monthOfYear, int dayOfMonth) { calendar.set(Calendar.YEAR, year); calendar.set(Calendar.MONTH, monthOfYear); calendar.set(Calendar.DAY_OF_MONTH, dayOfMonth); editDriver.setDob(calendar.getTimeInMillis()); dobValue.setText(StringManipulation.getFormattedDate(editDriver.getDob())); } }, calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH)); datePickerDialog.show(getFragmentManager(), "Datepickerdialog"); } }); final TextView genderValue = (TextView) findViewById(R.id.driver_gender_value); if (editDriver.getGender() != null) genderValue.setText( editDriver.getGender() ? getString(R.string.male_option) : getString(R.string.female_option)); final LinearLayout genderSelector = (LinearLayout) findViewById(R.id.driver_gender_selector); selectorsLayouts.add(genderSelector); final RelativeLayout genderLayout = (RelativeLayout) findViewById(R.id.driver_gender_layout); genderLayout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { hideKeyboard(context); if (genderSelector.getVisibility() == View.GONE) { closeInactiveLayouts(appBarLayout, selectorsLayouts, genderSelector); mainScrollView.postDelayed(new Runnable() { @Override public void run() { mainScrollView.smoothScrollTo(0, genderLayout.getTop()); } }, 1000); } else genderSelector.setVisibility(View.GONE); final int checkedPos = editDriver.getGender() == null ? -1 : (editDriver.getGender() ? R.id.driver_gender_male : R.id.driver_gender_female); final RadioGroup insuranceRadioGroup = (RadioGroup) findViewById(R.id.driver_gender_radio_group); if (checkedPos != -1) insuranceRadioGroup.check(checkedPos); LinearLayout okayButton = (LinearLayout) findViewById(R.id.driver_gender_okay_button); okayButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { switch (insuranceRadioGroup.getCheckedRadioButtonId()) { case R.id.driver_gender_male: editDriver.setGender(true); genderValue.setText(getString(R.string.male_option)); break; case R.id.driver_gender_female: editDriver.setGender(false); genderValue.setText(getString(R.string.female_option)); break; default: break; } mainScrollView.postDelayed(new Runnable() { @Override public void run() { mainScrollView.smoothScrollTo(0, 0); } }, 500); appBarLayout.postDelayed(new Runnable() { @Override public void run() { appBarLayout.setExpanded(true, true); } }, 1500); } }); LinearLayout cancelButton = (LinearLayout) findViewById(R.id.driver_gender_cancel_button); cancelButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { genderSelector.setVisibility(View.GONE); } }); } }); //TODO image analyis on IDs (license) and cross check with profile photo1, or maybe selfie uploadCount = new AtomicInteger(0); saveDriverAction = (FloatingActionButton) findViewById(R.id.fab_save_id); saveDriverAction.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { boolean error = false; hideKeyboard(context); if (editDriver.getVehicles().size() == 1) { setIndicator(context, vehicleIndicator, false); error = true; } if (licenseImage.getDrawable() == null || editDriver.getLicenseExpiry() == null || editDriver.getLicenseNumber() == null) { setIndicator(context, licenseIndicator, false); error = true; } if (residenceImage.getDrawable() == null || editDriver.getResidenceNumber() == null) { setIndicator(context, residenceIndicator, false); error = true; } if (editDriver.getNationality() == null) { setIndicator(context, nationalityIndicator, false); error = true; } if (editDriver.getPreferredAddress() == null) { setIndicator(context, addressIndicator, false); error = true; } if (editDriver.getPhoneNumber() == null || editDriver.getPhoneNumber().isEmpty()) { setIndicator(context, phoneIndicator, false); error = true; } if (user == null && !registerEmailHeaderFragment.setCustomerValues()) error = true; if (error) Snackbar.make(view, getString(R.string.incorrect_driver_data_message), Snackbar.LENGTH_LONG) .show(); else if (user != null) { signUpAnalytics(user.getProviderId()); editDriver.getVehicles().remove(editDriver.getVehicles().size() - 1); uploadImage("driver_license_snapshot", "image_" + editDriver.getPhoneNumber().replace(currentCountry.getPhoneCode(), "") + "_" + editDriver.getLicenseNumber() + ".jpg", ((BitmapDrawable) licenseImage.getDrawable()).getBitmap(), REQUEST_DRIVER_LICENSE); uploadImage("driver_residence_snapshot", "image_" + editDriver.getPhoneNumber().replace(currentCountry.getPhoneCode(), "") + "_" + editDriver.getResidenceNumber() + ".jpg", ((BitmapDrawable) residenceImage.getDrawable()).getBitmap(), REQUEST_RESIDENCE_ID); crossFade(context, findViewById(R.id.driver_progress_layout), findViewById(R.id.driver_main_layout), null); //TODO verify registration details for duplicate, correctness, etc } } }); imageUploadStatus = (TextSwitcher) findViewById(R.id.image_upload_status); imageUploadStatus.setFactory(new ViewSwitcher.ViewFactory() { @Override public View makeView() { TextView switcherTextView = new TextView(getApplicationContext()); switcherTextView.setTextSize(16); switcherTextView.setTypeface(null, Typeface.BOLD); switcherTextView.setText(getString(R.string.uploading_images)); switcherTextView.setTextColor(getResources().getColor(R.color.colorAccent)); return switcherTextView; } }); Animation animationOut = AnimationUtils.loadAnimation(this, android.R.anim.slide_out_right); Animation animationIn = AnimationUtils.loadAnimation(this, android.R.anim.slide_in_left); imageUploadStatus.setOutAnimation(animationOut); imageUploadStatus.setInAnimation(animationIn); }
From source file:com.android.contacts.common.list.ViewPagerTabs.java
private void addTab(CharSequence tabTitle, final int position) { View tabView;//from ww w. j a v a 2s . c o m if (mTabIcons != null && position < mTabIcons.length) { View layout = LayoutInflater.from(getContext()).inflate(R.layout.unread_count_tab, null); View iconView = layout.findViewById(R.id.icon); iconView.setBackgroundResource(mTabIcons[position]); iconView.setContentDescription(tabTitle); TextView textView = (TextView) layout.findViewById(R.id.count); if (mUnreadCounts != null && mUnreadCounts[position] > 0) { textView.setText(Integer.toString(mUnreadCounts[position])); textView.setVisibility(View.VISIBLE); iconView.setContentDescription( getResources().getQuantityString(R.plurals.tab_title_with_unread_items, mUnreadCounts[position], tabTitle.toString(), mUnreadCounts[position])); } else { textView.setVisibility(View.INVISIBLE); iconView.setContentDescription(tabTitle); } tabView = layout; } else { final TextView textView = new TextView(getContext()); textView.setText(tabTitle); textView.setBackgroundResource(R.drawable.view_pager_tab_background); // Assign various text appearance related attributes to child views. if (mTextStyle > 0) { textView.setTypeface(textView.getTypeface(), mTextStyle); } if (mTextSize > 0) { textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTextSize); } if (mTextColor != null) { textView.setTextColor(mTextColor); } textView.setAllCaps(mTextAllCaps); textView.setGravity(Gravity.CENTER); tabView = textView; } tabView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { mPager.setCurrentItem(getRtlPosition(position)); } }); tabView.setOnLongClickListener(new OnTabLongClickListener(position)); tabView.setPadding(mSidePadding, 0, mSidePadding, 0); mTabStrip.addView(tabView, position, new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT, 1)); // Default to the first child being selected if (position == 0) { mPrevSelected = 0; tabView.setSelected(true); } }
From source file:com.example.zapbuild.baseclasses.util.SlidingTabLayout.java
private void populateTabStrip() { final PagerAdapter adapter = mViewPager.getAdapter(); final OnClickListener tabClickListener = new TabClickListener(); for (int i = 0; i < adapter.getCount(); i++) { View tabView = null;/*from w w w . j a v a 2 s . c o m*/ TextView tabTitleView = null; if (mTabViewLayoutId != 0) { // If there is a custom tab view layout id set, try and inflate it tabView = LayoutInflater.from(getContext()).inflate(mTabViewLayoutId, mTabStrip, false); tabTitleView = (TextView) tabView.findViewById(mTabViewTextViewId); } if (tabView == null) { tabView = createDefaultTabView(getContext()); } if (tabTitleView == null && TextView.class.isInstance(tabView)) { tabTitleView = (TextView) tabView; } if (mDistributeEvenly) { LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) tabView.getLayoutParams(); lp.width = 0; lp.weight = 1; } tabTitleView.setText(adapter.getPageTitle(i)); if (mTabTitleColor != -1) { try { tabTitleView.setTextColor(mTabTitleColor); } catch (Exception exp) { tabTitleView.setTextColor(Color.WHITE); } } else { tabTitleView.setTextColor(Color.WHITE); } tabTitleView.setTypeface(null, Typeface.BOLD); tabView.setOnClickListener(tabClickListener); String desc = mContentDescriptions.get(i, null); if (desc != null) { tabView.setContentDescription(desc); } mTabStrip.addView(tabView); if (i == mViewPager.getCurrentItem()) { tabView.setSelected(true); } } }
From source file:com.example.fragmentdemo.views.PagerSlidingTabStrip.java
private void addTab(final int position, CharSequence title, int iconResId, int iLayoutResId, int iTextId, int iIconLocation) { // final View tabView = ((Activity) getContext()).getLayoutInflater() // .inflate(iLayoutResId, null); // TextView tab_text_textview = (TextView) // tabView.findViewById(iTextId); // tab_text_textview.setText(title); LinearLayout tabView = new LinearLayout(getContext()); tabView.setGravity(Gravity.CENTER);/*from w w w . j a v a 2s . c om*/ TextView tab_text_textview = new TextView(getContext()); tab_text_textview.setId(position); tab_text_textview.setText(title); tab_text_textview.setGravity(Gravity.CENTER_VERTICAL); tab_text_textview.setSingleLine(); // tab_text_textview.setTextColor(tabTextColor); // tab_text_textview.setTextColor(getResources().getColor(R.color.indicator_tab_main_text_color)); XmlPullParser xrp = getResources().getXml(tabTextColor); try { ColorStateList csl = ColorStateList.createFromXml(getResources(), xrp); if (tab_text_textview != null) { tab_text_textview.setTextColor(csl); } } catch (Exception e) { } tab_text_textview.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize); tab_text_textview.setTypeface(tabTypeface, tabTypefaceStyle); LinearLayout.LayoutParams lpText = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); if (iconResId != 0) { // tab_text_textview.setCompoundDrawablesWithIntrinsicBounds( // iconResId, 0, 0, 0); // Drawable mDrawable = ((Activity) getContext()).getResources() // .getDrawable(iconResId); // mDrawable.setBounds(0, 0, mDrawable.getMinimumWidth(), // mDrawable.getMinimumHeight()); int iPandding = (int) ((Activity) getContext()).getResources().getDimension(R.dimen.common_padding); ImageView icon = new ImageView(getContext()); icon.setImageResource(iconResId); icon.setScaleType(ScaleType.CENTER_INSIDE); LinearLayout.LayoutParams lpImage = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, iIconHeight); switch (iIconLocation) { case 1: // tab_text_textview.setCompoundDrawables(mDrawable, null, null, // null); tabView.setOrientation(LinearLayout.HORIZONTAL); // tabView.setGravity(Gravity.CENTER_VERTICAL); tabView.addView(icon, lpImage); lpText.leftMargin = iPandding; tabView.addView(tab_text_textview, lpText); break; case 2: // tab_text_textview.setCompoundDrawables(null, mDrawable, null, // null); tabView.setOrientation(LinearLayout.VERTICAL); // tabView.setGravity(Gravity.CENTER_HORIZONTAL); tabView.addView(icon, lpImage); lpText.topMargin = iPandding; tabView.addView(tab_text_textview, lpText); break; case 3: // tab_text_textview.setCompoundDrawables(null, null, mDrawable, // null); tabView.setOrientation(LinearLayout.HORIZONTAL); // tabView.setGravity(Gravity.CENTER_VERTICAL); tabView.addView(tab_text_textview, lpText); lpImage.leftMargin = iPandding; tabView.addView(icon, lpImage); break; case 4: // tab_text_textview.setCompoundDrawables(null, null, null, // mDrawable); tabView.setOrientation(LinearLayout.VERTICAL); // tabView.setGravity(Gravity.CENTER_HORIZONTAL); tabView.addView(tab_text_textview, lpText); lpImage.topMargin = iPandding; tabView.addView(icon, lpImage); break; default: // tab_text_textview.setCompoundDrawables(mDrawable, null, null, // null); tabView.setOrientation(LinearLayout.HORIZONTAL); // tabView.setGravity(Gravity.CENTER_VERTICAL); tabView.addView(icon, lpImage); lpText.leftMargin = iPandding; tabView.addView(tab_text_textview, lpText); break; } // tab_text_textview // .setCompoundDrawablePadding((int) ((Activity) getContext()) // .getResources() // .getDimension(R.dimen.common_padding)); } else { tabView.addView(tab_text_textview, lpText); } tabView.setFocusable(true); tabView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { pager.setCurrentItem(position); } }); // tab_text_textview.setPadding(tabPadding, 0, tabPadding, 0); tabsContainer.addView(tabView, position, shouldExpand ? expandedTabLayoutParams : defaultTabLayoutParams); }
From source file:com.openerp.addons.messages.Message.java
public void setupListView(List<OEListViewRows> message_list) { // Destroying pre-loaded instance and going to create new one lstview = null;/*from w w w . j av a 2 s. c om*/ // Fetching required messages for listview by filtering of requrement if (list != null && list.size() <= 0) { list = message_list;// getMessages(message_list); } else { rootView.findViewById(R.id.messageSyncWaiter).setVisibility(View.GONE); rootView.findViewById(R.id.txvMessageAllReadMessage).setVisibility(View.GONE); } // Handling List View controls and keys String[] from = new String[] { "subject|type", "body", "starred", "author_id|email_from", "date", "model|type" }; int[] to = new int[] { R.id.txvMessageSubject, R.id.txvMessageBody, R.id.imgMessageStarred, R.id.txvMessageFrom, R.id.txvMessageDate, R.id.txvMessageTag }; // Creating instance for listAdapter listAdapter = new OEListViewAdapter(scope.context(), R.layout.message_listview_items, list, from, to, db, true, new int[] { R.drawable.message_listview_bg_toread_selector, R.drawable.message_listview_bg_tonotread_selector }, "to_read"); // Telling adapter to clean HTML text for key value listAdapter.cleanHtmlToTextOn("body"); listAdapter.cleanDate("date", scope.User().getTimezone()); // Setting callback handler for boolean field value change. listAdapter.setBooleanEventOperation("starred", R.drawable.ic_action_starred, R.drawable.ic_action_unstarred, updateStarred); listAdapter.addViewListener(new OEListViewOnCreateListener() { @Override public View listViewOnCreateListener(int position, View row_view, OEListViewRows row_data) { String model_name = row_data.getRow_data().get("model").toString(); String model = model_name; String res_id = row_data.getRow_data().get("res_id").toString(); if (model_name.equals("false")) { model_name = capitalizeString(row_data.getRow_data().get("type").toString()); } else { String[] model_parts = TextUtils.split(model_name, "\\."); HashSet unique_parts = new HashSet(Arrays.asList(model_parts)); model_name = capitalizeString(TextUtils.join(" ", unique_parts.toArray())); } TextView msgTag = (TextView) row_view.findViewById(R.id.txvMessageTag); int tag_color = 0; if (message_model_colors.containsKey(model_name)) { tag_color = message_model_colors.get(model_name); } else { tag_color = Color.parseColor(tag_colors[tag_color_count]); message_model_colors.put(model_name, tag_color); tag_color_count++; if (tag_color_count > tag_colors.length) { tag_color_count = 0; } } if (model.equals("mail.group")) { if (UserGroups.group_names.containsKey("group_" + res_id)) { model_name = UserGroups.group_names.get("group_" + res_id); tag_color = UserGroups.menu_color.get("group_" + res_id); } } msgTag.setBackgroundColor(tag_color); msgTag.setText(model_name); TextView txvSubject = (TextView) row_view.findViewById(R.id.txvMessageSubject); TextView txvAuthor = (TextView) row_view.findViewById(R.id.txvMessageFrom); if (row_data.getRow_data().get("to_read").toString().equals("false")) { txvSubject.setTypeface(null, Typeface.NORMAL); txvSubject.setTextColor(Color.BLACK); txvAuthor.setTypeface(null, Typeface.NORMAL); txvAuthor.setTextColor(Color.BLACK); } else { txvSubject.setTypeface(null, Typeface.BOLD); txvSubject.setTextColor(Color.parseColor("#414141")); txvAuthor.setTypeface(null, Typeface.BOLD); txvAuthor.setTextColor(Color.parseColor("#414141")); } return row_view; } }); // Creating instance for listview control lstview = (ListView) rootView.findViewById(R.id.lstMessages); // Providing adapter to listview scope.context().runOnUiThread(new Runnable() { @Override public void run() { lstview.setAdapter(listAdapter); } }); // Setting listview choice mode to multiple model lstview.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL); // Seeting item long click listern to activate action mode. lstview.setOnItemLongClickListener(new OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> arg0, View view, int index, long arg3) { // TODO Auto-generated method stub OEListViewRows data = (OEListViewRows) lstview.getAdapter().getItem(index); Toast.makeText(scope.context(), data.getRow_id() + " id clicked", Toast.LENGTH_LONG).show(); view.setSelected(true); if (mActionMode != null) { return false; } // Start the CAB using the ActionMode.Callback defined above mActionMode = scope.context().startActionMode(mActionModeCallback); selectedCounter++; view.setBackgroundResource(R.drawable.listitem_pressed); // lstview.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE); return true; } }); // Setting multi choice selection listener lstview.setMultiChoiceModeListener(new MultiChoiceModeListener() { HashMap<Integer, Boolean> selectedList = new HashMap<Integer, Boolean>(); @Override public void onItemCheckedStateChanged(ActionMode mode, int position, long id, boolean checked) { // Here you can do something when items are // selected/de-selected, // such as update the title in the CAB selectedList.put(position, checked); if (checked) { selectedCounter++; } else { selectedCounter--; } if (selectedCounter != 0) { mode.setTitle(selectedCounter + ""); } } @Override public boolean onActionItemClicked(ActionMode mode, MenuItem item) { // Respond to clicks on the actions in the CAB HashMap<Integer, Integer> msg_pos = new HashMap<Integer, Integer>(); OEDialog dialog = null; switch (item.getItemId()) { case R.id.menu_message_mark_unread_selected: Log.e("menu_message_context", "Mark as Unread"); for (int pos : selectedList.keySet()) { msg_pos.put(list.get(pos).getRow_id(), pos); } readunreadoperation = new PerformReadUnreadArchiveOperation(msg_pos, false); readunreadoperation.execute((Void) null); mode.finish(); return true; case R.id.menu_message_mark_read_selected: Log.e("menu_message_context", "Mark as Read"); for (int pos : selectedList.keySet()) { msg_pos.put(list.get(pos).getRow_id(), pos); } readunreadoperation = new PerformReadUnreadArchiveOperation(msg_pos, true); readunreadoperation.execute((Void) null); mode.finish(); return true; case R.id.menu_message_more_move_to_archive_selected: Log.e("menu_message_context", "Archive"); for (int pos : selectedList.keySet()) { msg_pos.put(list.get(pos).getRow_id(), pos); } readunreadoperation = new PerformReadUnreadArchiveOperation(msg_pos, false); readunreadoperation.execute((Void) null); mode.finish(); return true; case R.id.menu_message_more_add_star_selected: for (int pos : selectedList.keySet()) { msg_pos.put(list.get(pos).getRow_id(), pos); } markasTodoTask = new PerformOperation(msg_pos, true); markasTodoTask.execute((Void) null); mode.finish(); return true; case R.id.menu_message_more_remove_star_selected: for (int pos : selectedList.keySet()) { msg_pos.put(list.get(pos).getRow_id(), pos); } markasTodoTask = new PerformOperation(msg_pos, false); markasTodoTask.execute((Void) null); mode.finish(); return true; default: return false; } } @Override public boolean onCreateActionMode(ActionMode mode, Menu menu) { // Inflate the menu for the CAB MenuInflater inflater = mode.getMenuInflater(); inflater.inflate(R.menu.menu_fragment_message_context, menu); return true; } @Override public void onDestroyActionMode(ActionMode mode) { // Here you can make any necessary updates to the activity when // the CAB is removed. By default, selected items are // deselected/unchecked. /* * Perform Operation on Selected Ids. * * row_ids are list of selected message Ids. */ selectedList.clear(); selectedCounter = 0; lstview.clearChoices(); } @Override public boolean onPrepareActionMode(ActionMode mode, Menu menu) { // Here you can perform updates to the CAB due to // an invalidate() request return false; } }); lstview.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View view, int index, long id) { // TODO Auto-generated method stub MessageDetail messageDetail = new MessageDetail(); Bundle bundle = new Bundle(); bundle.putInt("message_id", list.get(index).getRow_id()); bundle.putInt("position", index); messageDetail.setArguments(bundle); scope.context().fragmentHandler.setBackStack(true, null); scope.context().fragmentHandler.replaceFragmnet(messageDetail); if (!type.equals("archive")) { list.remove(index); } listAdapter.refresh(list); } }); // Getting Pull To Refresh Attacher from Main Activity mPullToRefreshAttacher = scope.context().getPullToRefreshAttacher(); // Set the Refreshable View to be the ListView and the refresh listener // to be this. if (mPullToRefreshAttacher != null & lstview != null) { mPullToRefreshAttacher.setRefreshableView(lstview, this); } }
From source file:com.esri.android.mapsapp.MapFragment.java
/** * Shows the search result in the layout after successful geocoding and * reverse geocoding//from ww w . j a va 2 s. c o m * */ private void showSearchResultLayout(String address) { // Remove the layouts mMapContainer.removeView(mSearchBox); mMapContainer.removeView(mSearchResult); // Inflate the new layout from the xml file mSearchResult = mInflater.inflate(R.layout.search_result, null); // Set layout parameters mSearchResult.setLayoutParams(mlayoutParams); // Initialize the textview and set its text TextView tv = (TextView) mSearchResult.findViewById(R.id.textView1); tv.setTypeface(null, Typeface.BOLD); tv.setText(address); // Adding the search result layout to the map container mMapContainer.addView(mSearchResult); // Setup the listener for the "cancel" icon ImageView iv_cancel = (ImageView) mSearchResult.findViewById(R.id.imageView3); iv_cancel.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // Remove the search result view mMapContainer.removeView(mSearchResult); suggestionClickFlag = false; // Add the search box view showSearchBoxLayout(); // Remove all graphics from the map resetGraphicsLayers(); } }); // Set up the listener for the "Get Directions" icon ImageView iv_route = (ImageView) mSearchResult.findViewById(R.id.imageView2); iv_route.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { onGetRoute(getString(R.string.my_location), mLocationLayerPointString); } }); // Add the compass after getting the height of the layout mSearchResult.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() { @Override public void onGlobalLayout() { addCompass(mSearchResult.getHeight()); mSearchResult.getViewTreeObserver().removeGlobalOnLayoutListener(this); } }); }
From source file:com.esri.android.mapsapp.MapFragment.java
/** * Shows the Routing result layout after successful routing * // w ww .ja v a 2s . c om * @param time * @param distance * */ private void showRoutingResultLayout(double distance, double time) { // Remove the layours mMapContainer.removeView(mSearchResult); mMapContainer.removeView(mSearchBox); // Inflate the new layout from the xml file mSearchResult = mInflater.inflate(R.layout.routing_result, null); mSearchResult.setLayoutParams(mlayoutParams); // Shorten the start and end location by finding the first comma if // present int index_from = mStartLocation.indexOf(","); int index_to = mEndLocation.indexOf(","); if (index_from != -1) mStartLocation = mStartLocation.substring(0, index_from); if (index_to != -1) mEndLocation = mEndLocation.substring(0, index_to); // Initialize the textvieww and display the text TextView tv_from = (TextView) mSearchResult.findViewById(R.id.tv_from); tv_from.setTypeface(null, Typeface.BOLD); tv_from.setText(" " + mStartLocation); TextView tv_to = (TextView) mSearchResult.findViewById(R.id.tv_to); tv_to.setTypeface(null, Typeface.BOLD); tv_to.setText(" " + mEndLocation); // Rounding off the values distance = Math.round(distance * 10.0) / 10.0; time = Math.round(time * 10.0) / 10.0; TextView tv_time = (TextView) mSearchResult.findViewById(R.id.tv_time); tv_time.setTypeface(null, Typeface.BOLD); tv_time.setText(time + " mins"); TextView tv_dist = (TextView) mSearchResult.findViewById(R.id.tv_dist); tv_dist.setTypeface(null, Typeface.BOLD); tv_dist.setText(" (" + distance + " miles)"); // Adding the layout mMapContainer.addView(mSearchResult); // Setup the listener for the "Cancel" icon ImageView iv_cancel = (ImageView) mSearchResult.findViewById(R.id.imageView3); iv_cancel.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // Remove the search result view mMapContainer.removeView(mSearchResult); // Add the default search box view showSearchBoxLayout(); // Remove all graphics from the map resetGraphicsLayers(); } }); // Set up the listener for the "Show Directions" icon ImageView iv_directions = (ImageView) mSearchResult.findViewById(R.id.imageView2); iv_directions.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { showDirectionsDialogFragment(); } }); // Add the compass after getting the height of the layout mSearchResult.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() { @Override public void onGlobalLayout() { addCompass(mSearchResult.getHeight()); mSearchResult.getViewTreeObserver().removeGlobalOnLayoutListener(this); } }); }
From source file:com.edible.ocr.CaptureActivity.java
/** * Displays information relating to the result of OCR, and requests a translation if necessary. * //from w ww . j a va 2 s . c o m * @param ocrResult Object representing successful OCR results * @return True if a non-null result was received for OCR */ boolean handleOcrDecode(OcrResult ocrResult) { lastResult = ocrResult; // Test whether the result is null if (ocrResult.getText() == null || ocrResult.getText().equals("")) { Toast toast = Toast.makeText(this, "OCR failed. Please try again.", Toast.LENGTH_SHORT); toast.setGravity(Gravity.TOP, 0, 0); toast.show(); return false; } // Turn off capture-related UI elements shutterButton.setVisibility(View.GONE); statusViewBottom.setVisibility(View.GONE); statusViewTop.setVisibility(View.GONE); cameraButtonView.setVisibility(View.GONE); viewfinderView.setVisibility(View.GONE); resultView.setVisibility(View.VISIBLE); ImageView bitmapImageView = (ImageView) findViewById(R.id.image_view); lastBitmap = ocrResult.getBitmap(); if (lastBitmap == null) { bitmapImageView.setImageBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher)); } else { bitmapImageView.setImageBitmap(lastBitmap); } // Display the recognized text TextView sourceLanguageTextView = (TextView) findViewById(R.id.source_language_text_view); sourceLanguageTextView.setText(sourceLanguageReadable); TextView ocrResultTextView = (TextView) findViewById(R.id.ocr_result_text_view); ocrResultTextView.setText(stripNoise(ocrResult.getText())); // Crudely scale betweeen 22 and 32 -- bigger font for shorter text int scaledSize = Math.max(22, 32 - ocrResult.getText().length() / 4); ocrResultTextView.setTextSize(TypedValue.COMPLEX_UNIT_SP, scaledSize); TextView translationLanguageLabelTextView = (TextView) findViewById( R.id.translation_language_label_text_view); TextView translationLanguageTextView = (TextView) findViewById(R.id.translation_language_text_view); TextView translationTextView = (TextView) findViewById(R.id.translation_text_view); if (isTranslationActive) { // Handle translation text fields translationLanguageLabelTextView.setVisibility(View.VISIBLE); translationLanguageTextView.setText(targetLanguageReadable); translationLanguageTextView.setTypeface(Typeface.defaultFromStyle(Typeface.NORMAL), Typeface.NORMAL); translationLanguageTextView.setVisibility(View.VISIBLE); // Activate/re-activate the indeterminate progress indicator translationTextView.setVisibility(View.GONE); progressView.setVisibility(View.VISIBLE); setProgressBarVisibility(true); // Get the translation asynchronously new TranslateAsyncTask(this, sourceLanguageCodeTranslation, targetLanguageCodeTranslation, stripNoise(ocrResult.getText())).execute(); } else { translationLanguageLabelTextView.setVisibility(View.GONE); translationLanguageTextView.setVisibility(View.GONE); translationTextView.setVisibility(View.GONE); progressView.setVisibility(View.GONE); setProgressBarVisibility(false); } return true; }