Example usage for android.widget TextView setTypeface

List of usage examples for android.widget TextView setTypeface

Introduction

In this page you can find the example usage for android.widget TextView setTypeface.

Prototype

public void setTypeface(@Nullable Typeface tf) 

Source Link

Document

Sets the typeface and style in which the text should be displayed.

Usage

From source file:com.RSMSA.policeApp.OffenceReportForm.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_report_offence);
    sharedpreferences = getSharedPreferences(MyPREF, Context.MODE_PRIVATE);

    toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);//w  ww. j a  va 2  s  . c om

    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        setTranslucentStatus(true);
    }
    SystemBarTintManager tintManager = new SystemBarTintManager(this);
    tintManager.setStatusBarTintEnabled(true);
    ColorDrawable colorDrawable = new ColorDrawable(getResources().getColor(R.color.blue_900));
    tintManager.setTintDrawable(colorDrawable);

    RelativeLayout inputs = (RelativeLayout) findViewById(R.id.inputs);
    plateNumberEdit = (EditText) findViewById(R.id.plate_number_edit_text);
    licenceNumberEdit = (EditText) findViewById(R.id.licence_number_edit_text);

    final Bundle bundle = getIntent().getExtras();
    namePassed = bundle.getString("name");
    dLicense = bundle.getString("licence_number");
    plateNumberObtained = bundle.getString("plate_number");
    driverUid = bundle.getString("driverUid");
    vehicleUid = bundle.getString("vehicleUid");

    try {
        invalidLicence = bundle.getString("invalidLicence");
        expiredInsuarance = bundle.getString("expiredInsuarance");
    } catch (NullPointerException e) {
    }

    if (dLicense.equals("") || dLicense == null) {
        licenceNumberEdit.setVisibility(View.VISIBLE);
    } else if (plateNumberObtained.equals("") || plateNumberObtained == null) {
        plateNumberEdit.setVisibility(View.VISIBLE);
    }

    submit = (TextView) findViewById(R.id.submit_text);

    plateNo = (TextView) findViewById(R.id.plate_no_);
    chargesAcceptance = (TextView) findViewById(R.id.charges_acceptance);
    chargesAcceptance.setTypeface(MainOffence.Roboto_Regular);

    offensesCommittedTextview = (TextView) findViewById(R.id.offences_committed_title);
    offensesCommittedTextview.setTypeface(MainOffence.Roboto_BoldCondensed);

    ChargesAcceptanceTitle = (TextView) findViewById(R.id.charges_acceptance_title);
    paymentMethodTitle = (TextView) findViewById(R.id.payment_method_title);
    PaymentTitle = (TextView) findViewById(R.id.payment_title);

    ChargesAcceptanceTitle.setTypeface(MainOffence.Roboto_BoldCondensed);
    paymentMethodTitle.setTypeface(MainOffence.Roboto_BoldCondensed);
    PaymentTitle.setTypeface(MainOffence.Roboto_BoldCondensed);

    offencesCostTitle = (TextView) findViewById(R.id.offences_cost_title);
    offencesCostTitle.setTypeface(MainOffence.Roboto_BoldCondensed);

    submitText = (TextView) findViewById(R.id.submit_text);

    license = (TextView) findViewById(R.id.license);
    license.setText(dLicense);

    report = (RelativeLayout) findViewById(R.id.report);
    summary = (RelativeLayout) findViewById(R.id.summary);
    submit_layout = (RelativeLayout) findViewById(R.id.submit_layout);

    submit_layout1 = (RelativeLayout) findViewById(R.id.submit_layout1);
    submit_layout1.setVisibility(View.GONE);

    progressBar = (ProgressBar) findViewById(R.id.pbar_report);

    TextView driverName = (TextView) findViewById(R.id.driver_name);
    driverName.setTypeface(MainOffence.Roboto_BoldCondensed);

    TextView plateNumberTitle = (TextView) findViewById(R.id.plate_no_title_);
    plateNumberTitle.setTypeface(MainOffence.Roboto_BoldCondensed);

    TextView driverLicense = (TextView) findViewById(R.id.driver_license);
    driverLicense.setTypeface(MainOffence.Roboto_BoldCondensed);

    RelativeLayout OffenseType = (RelativeLayout) findViewById(R.id.offense_type);
    OffenseType.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Intent intent = new Intent(OffenceReportForm.this, OffenseListActivity.class);
            OffenceReportForm.this.startActivityForResult(intent, REPORT_RESULT);
        }
    });

    offense_type_text = (TextView) findViewById(R.id.offense_type_text);

    offencesSelectedTextView = (TextView) findViewById(R.id.offence_list);
    offensesCommittedTextview = (TextView) findViewById(R.id.offences_committed);

    TextView name = (TextView) findViewById(R.id.name);
    name.setText(namePassed);

    final RadioButton court = (RadioButton) findViewById(R.id.court);
    court.setTypeface(MainOffence.Roboto_BoldCondensed);
    final RadioButton guilty = (RadioButton) findViewById(R.id.guilty);
    guilty.setTypeface(MainOffence.Roboto_BoldCondensed);

    guilty.setChecked(true);

    court.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
            if (b == true) {
                guilty.setChecked(false);
                commit = false;
            }
        }
    });

    guilty.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
            if (b == true) {
                court.setChecked(false);
                commit = true;
            }
        }
    });

    final String[] paymentMethodsArray = this.getResources().getStringArray(R.array.payment_methods);
    final Spinner paymentMethodSpinner = (Spinner) findViewById(R.id.payment_method_spinner);
    final RadioButton paid = (RadioButton) findViewById(R.id.paid);
    paid.setTypeface(MainOffence.Roboto_Regular);
    final RadioButton not_paid = (RadioButton) findViewById(R.id.not_paid);
    final TextView receipt_title = (TextView) findViewById(R.id.receipt_title);
    receiptEditText = (EditText) findViewById(R.id.receipt);

    receipt_title.setTypeface(MainOffence.Roboto_BoldCondensed);

    not_paid.setTypeface(MainOffence.Roboto_Regular);

    not_paid.setChecked(true);

    paymentMethodSpinner.setBackground(null);

    paid.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
            if (b == true) {
                paymentStatus = true;
                paymentMethodTitle.setVisibility(View.VISIBLE);
                paymentMethodSpinner.setVisibility(View.VISIBLE);
                paymentMethod = paymentMethodsArray[0];
                paymentMethodSpinner.setSelection(0);
                receipt_title.setVisibility(View.VISIBLE);
                receiptEditText.setVisibility(View.VISIBLE);
            }
        }
    });

    not_paid.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
            if (b == true) {
                paymentStatus = false;
                paymentMethodTitle.setVisibility(View.GONE);
                paymentMethodSpinner.setVisibility(View.GONE);
                receipt_title.setVisibility(View.GONE);
                receiptEditText.setVisibility(View.GONE);
                paymentMethod = "";
                receiptEditText.setText("");

            }
        }
    });

    PaymentMethodSpinnerAdapter adapter = new PaymentMethodSpinnerAdapter(
            getSupportActionBar().getThemedContext(), R.layout.row_menu, paymentMethodsArray);
    paymentMethodSpinner.setAdapter(adapter);
    paymentMethodSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            paymentMethod = paymentMethodsArray[position];
            if (position == 0) {
                receiptEditText.setVisibility(View.VISIBLE);
                receipt_title.setVisibility(View.VISIBLE);
            } else {
                receiptEditText.setVisibility(View.GONE);
                receipt_title.setVisibility(View.GONE);
            }
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {

        }
    });

}

From source file:com.egloos.hyunyi.musicinfo.LinkPopUp.java

private void displayArtistInfo_bk(JSONObject j) throws JSONException {
    if (imageLoader == null)
        imageLoader = ImageLoader.getInstance();
    if (!imageLoader.isInited())
        imageLoader.init(config);/* www.ja  v  a  2 s.c  o m*/

    Log.i("musicInfo", "LinkPopUp. displayArtistInfo " + j.toString());

    JSONObject j_artist_info = j.getJSONObject("artist");

    tArtistName.setText(j_artist_info.getString("name"));
    final JSONObject urls = j_artist_info.optJSONObject("urls");
    final JSONArray videos = j_artist_info.optJSONArray("video");
    final JSONArray images = j_artist_info.optJSONArray("images");
    final String fm_image = j.optString("fm_image");
    final JSONArray available_images = new JSONArray();
    ArrayList<String> image_urls = new ArrayList<String>();

    if (fm_image != null) {
        image_urls.add(fm_image);
    }

    Log.i("musicInfo", images.toString());

    if (images != null) {
        for (int i = 0; i < images.length(); i++) {
            JSONObject image = images.getJSONObject(i);
            int width = image.optInt("width", 0);
            int height = image.optInt("height", 0);
            String url = image.optString("url", "");
            Log.i("musicInfo", i + ": " + url);
            if ((width * height > 10000) && (width * height < 100000) && (!url.contains("userserve-ak"))) {
                //if ((width>300&&width<100)&&(height>300&&height<1000)&&(!url.contains("userserve-ak"))) {
                image_urls.add(url);
                Log.i("musicInfo", "Selected: " + url);
                //available_images.put(image);
            }
        }

        int random = (int) (Math.random() * image_urls.size());
        final String f_url = image_urls.get(random);

        //int random = (int) (Math.random() * available_images.length());
        //final JSONObject fImage = available_images.length()>0?available_images.getJSONObject(random > images.length() ? 0 : random):images.getJSONObject(0);

        Log.i("musicInfo",
                "Total image#=" + available_images.length() + " Selected image#=" + random + " " + f_url);

        imageLoader.displayImage(f_url, ArtistImage, new ImageLoadingListener() {
            @Override
            public void onLoadingStarted(String imageUri, View view) {

            }

            @Override
            public void onLoadingFailed(String imageUri, View view, FailReason failReason) {

            }

            @Override
            public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {

                lLinkList.removeAllViews();
                //String attr = fImage.optJSONObject("license").optString("attribution");
                //tAttribution.setText("Credit. " + ((attr == null) || (attr.contains("n/a")) ? "Unknown" : attr));
                if (urls != null) {
                    String[] jsonName = { "wikipedia_url", "mb_url", "lastfm_url", "official_url",
                            "twitter_url" };
                    for (int i = 0; i < jsonName.length; i++) {
                        if ((urls.optString(jsonName[i]) != null) && (urls.optString(jsonName[i]) != "")) {
                            Log.d("musicinfo", "Link URL: " + urls.optString(jsonName[i]));
                            TextView tv = new TextView(getApplicationContext());
                            tv.setTextSize(11);
                            tv.setPadding(16, 16, 16, 16);
                            tv.setTextColor(Color.LTGRAY);
                            tv.setTypeface(Typeface.SANS_SERIF);
                            tv.setGravity(Gravity.CENTER_VERTICAL);
                            tv.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
                                    ViewGroup.LayoutParams.WRAP_CONTENT));

                            switch (jsonName[i]) {
                            case "official_url":
                                tv.setText("HOME.");
                                break;
                            case "wikipedia_url":
                                tv.setText("WIKI.");
                                break;
                            case "mb_url":
                                tv.setText("Music Brainz.");
                                break;
                            case "lastfm_url":
                                tv.setText("Last FM.");
                                break;
                            case "twitter_url":
                                tv.setText("Twitter.");
                                break;
                            }

                            try {
                                tv.setTag(urls.getString(jsonName[i]));
                            } catch (JSONException e) {
                                e.printStackTrace();
                            }

                            tv.setOnClickListener(new View.OnClickListener() {
                                @Override
                                public void onClick(View v) {
                                    Intent intent = new Intent();
                                    intent.setAction(Intent.ACTION_VIEW);
                                    intent.addCategory(Intent.CATEGORY_BROWSABLE);
                                    intent.setData(Uri.parse((String) v.getTag()));
                                    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                                    startActivity(intent);
                                    Toast.makeText(getApplicationContext(), "Open the Link...",
                                            Toast.LENGTH_SHORT).show();
                                    //finish();
                                }
                            });
                            lLinkList.addView(tv);
                        }
                    }
                } else {
                    TextView tv = new TextView(getApplicationContext());
                    tv.setTextSize(11);
                    tv.setPadding(16, 16, 16, 16);
                    tv.setTextColor(Color.LTGRAY);
                    tv.setTypeface(Typeface.SANS_SERIF);
                    tv.setGravity(Gravity.CENTER_VERTICAL);
                    tv.setText("Sorry, No Link Here...");
                    lLinkList.addView(tv);
                }

                if (videos != null) {
                    jVideoArray = videos;
                    mAdapter = new StaggeredViewAdapter(getApplicationContext(),
                            android.R.layout.simple_list_item_1, generateImageData(videos));
                    //if (mData == null) {
                    mData = generateImageData(videos);
                    //}

                    //mAdapter.clear();

                    for (JSONObject data : mData) {
                        mAdapter.add(data);
                    }
                    mGridView.setAdapter(mAdapter);
                } else {

                }

                adjBottomColor(((ImageView) view).getDrawable());
            }

            @Override
            public void onLoadingCancelled(String imageUri, View view) {

            }
        });
    }

}

From source file:com.example.drugsformarinemammals.General_Info_Drug.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.general_info_drug);
    isStoredInLocal = false;//  ww w  .  ja  v a  2  s  .c om
    fiveLastScreen = false;
    helper = new Handler_Sqlite(this);
    helper.open();
    Bundle extras1 = this.getIntent().getExtras();
    if (extras1 != null) {
        infoBundle = extras1.getStringArrayList("generalInfoDrug");
        fiveLastScreen = extras1.getBoolean("fiveLastScreen");
        if (infoBundle == null)
            isStoredInLocal = true;
        if (!isStoredInLocal) {
            initializeGeneralInfoDrug();
            initializeCodesInformation();
            initializeCodes();
        } else {
            drug_name = extras1.getString("drugName");
            codes = helper.getCodes(drug_name);
            codesInformation = helper.getCodesInformation(drug_name);
        }
        //Title
        TextView drugTitle = (TextView) findViewById(R.id.drugTitle);
        drugTitle.setText(drug_name);
        drugTitle.setTypeface(Typeface.SANS_SERIF);

        //Description 
        LinearLayout borderDescription = new LinearLayout(this);
        borderDescription.setOrientation(LinearLayout.VERTICAL);
        borderDescription
                .setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
        borderDescription.setBackgroundResource(R.drawable.layout_border);

        TextView description = new TextView(this);
        if (isStoredInLocal)
            description.setText(helper.getDescription(drug_name));
        else
            description.setText(this.description);
        description.setTextSize(18);
        description.setTypeface(Typeface.SANS_SERIF);

        LinearLayout.LayoutParams paramsDescription = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                LayoutParams.WRAP_CONTENT);
        paramsDescription.leftMargin = 60;
        paramsDescription.rightMargin = 60;
        paramsDescription.topMargin = 20;

        borderDescription.addView(description, borderDescription.getChildCount(), paramsDescription);

        LinearLayout layoutDescription = (LinearLayout) findViewById(R.id.layoutDescription);
        layoutDescription.addView(borderDescription, layoutDescription.getChildCount());

        //Animals
        TextView headerAnimals = (TextView) findViewById(R.id.headerAnimals);
        headerAnimals.setTypeface(Typeface.SANS_SERIF, Typeface.BOLD);

        Button cetaceansButton = (Button) findViewById(R.id.cetaceansButton);
        cetaceansButton.setText("CETACEANS");
        cetaceansButton.setTypeface(Typeface.SANS_SERIF);
        cetaceansButton.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                showDoseInformation(drug_name, "Cetaceans");
            }
        });

        Button pinnipedsButton = (Button) findViewById(R.id.pinnipedsButton);
        pinnipedsButton.setText("PINNIPEDS");
        pinnipedsButton.setTypeface(Typeface.SANS_SERIF);
        pinnipedsButton.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                SQLiteDatabase db = helper.open();
                ArrayList<String> families = new ArrayList<String>();
                if (db != null)
                    families = helper.read_animals_family(drug_name, "Pinnipeds");
                if ((families != null && families.size() == 1 && families.get(0).equals(""))
                        || (families != null && families.size() == 0))
                    showDoseInformation(drug_name, "Pinnipeds");
                else
                    showDoseInformationPinnipeds(drug_name, families);
            }
        });

        Button otherButton = (Button) findViewById(R.id.otherButton);
        otherButton.setText("OTHER MM");
        otherButton.setTypeface(Typeface.SANS_SERIF);
        otherButton.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                showDoseInformation(drug_name, "Other MM");
            }
        });

        //Codes & therapeutic target & anatomical target
        TextView headerATCvetCodes = (TextView) findViewById(R.id.headerATCvetCodes);
        headerATCvetCodes.setTypeface(Typeface.SANS_SERIF, Typeface.BOLD);

        //Action
        TextView headerActionAnatomical = (TextView) findViewById(R.id.headerActionAnatomical);
        headerActionAnatomical.setTypeface(Typeface.SANS_SERIF, Typeface.BOLD);

        createTextViewAnatomical();
        createBorderAnatomicalGroup();

        TextView headerActionTherapeutic = (TextView) findViewById(R.id.headerActionTherapeutic);
        headerActionTherapeutic.setTypeface(Typeface.SANS_SERIF, Typeface.BOLD);

        createTextViewTherapeutic();
        createBorderTherapeuticGroup();

        params = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
        params.leftMargin = 60;
        params.rightMargin = 60;
        params.topMargin = 20;

        Spinner codesSpinner = (Spinner) findViewById(R.id.codesSpinner);
        SpinnerAdapter adapterCodes = new SpinnerAdapter(this, R.layout.item_spinner, codes);
        adapterCodes.setDropDownViewResource(R.layout.spinner_dropdown_item);
        codesSpinner.setAdapter(adapterCodes);
        codesSpinner.setOnItemSelectedListener(new OnItemSelectedListener() {

            public void onItemSelected(AdapterView<?> parent, View arg1, int arg2, long arg3) {
                userEntryCode = parent.getSelectedItem().toString();
                int numCodes = codesInformation.size();

                layoutAnatomicalGroup.removeView(borderAnatomicalGroup);
                createBorderAnatomicalGroup();

                boolean founded = false;
                int i = 0;
                while (!founded && i < numCodes) {
                    if (userEntryCode.equals(codesInformation.get(i).getCode())) {
                        createTextViewAnatomical();
                        anatomicalGroup.setText(codesInformation.get(i).getAnatomic_group() + "\n");
                        borderAnatomicalGroup.addView(anatomicalGroup, borderAnatomicalGroup.getChildCount(),
                                params);
                        founded = true;
                    }
                    i++;
                }

                layoutAnatomicalGroup = (LinearLayout) findViewById(R.id.layoutActionAnatomical);
                layoutAnatomicalGroup.addView(borderAnatomicalGroup, layoutAnatomicalGroup.getChildCount());
                layoutTherapeuticGroup.removeView(borderTherapeuticGroup);
                createBorderTherapeuticGroup();
                founded = false;
                i = 0;
                while (!founded && i < numCodes) {
                    if (userEntryCode.equals(codesInformation.get(i).getCode())) {
                        createTextViewTherapeutic();
                        therapeuticGroup.setText(codesInformation.get(i).getTherapeutic_group() + "\n");
                        borderTherapeuticGroup.addView(therapeuticGroup, borderTherapeuticGroup.getChildCount(),
                                params);
                        founded = true;
                    }
                    i++;
                }
                layoutTherapeuticGroup = (LinearLayout) findViewById(R.id.layoutActionTherapeutic);
                layoutTherapeuticGroup.addView(borderTherapeuticGroup, layoutTherapeuticGroup.getChildCount());
            }

            public void onNothingSelected(AdapterView<?> arg0) {
            }
        });

        layoutAnatomicalGroup = (LinearLayout) findViewById(R.id.layoutActionAnatomical);
        layoutTherapeuticGroup = (LinearLayout) findViewById(R.id.layoutActionTherapeutic);

        borderTherapeuticGroup.addView(therapeuticGroup, borderTherapeuticGroup.getChildCount(), params);
        borderAnatomicalGroup.addView(anatomicalGroup, borderAnatomicalGroup.getChildCount(), params);

        layoutAnatomicalGroup.addView(borderAnatomicalGroup, layoutAnatomicalGroup.getChildCount());
        layoutTherapeuticGroup.addView(borderTherapeuticGroup, layoutTherapeuticGroup.getChildCount());

        //Generic Drug
        TextView headerGenericDrug = (TextView) findViewById(R.id.headerGenericDrug);
        headerGenericDrug.setTypeface(Typeface.SANS_SERIF, Typeface.BOLD);
        boolean isAvalaible = false;
        if (isStoredInLocal)
            isAvalaible = helper.isAvalaible(drug_name);
        else
            isAvalaible = available.equals("Yes");
        if (isAvalaible) {
            ImageView genericDrug = new ImageView(this);
            genericDrug.setImageResource(R.drawable.tick_verde);
            LinearLayout layoutGenericDrug = (LinearLayout) findViewById(R.id.layoutGenericDrug);
            layoutGenericDrug.addView(genericDrug);
        } else {
            Typeface font = Typeface.createFromAsset(getAssets(), "Typoster_demo.otf");
            TextView genericDrug = new TextView(this);
            genericDrug.setTypeface(font);
            genericDrug.setText("Nd");
            genericDrug.setTextColor(getResources().getColor(R.color.maroon));
            genericDrug.setTextSize(20);
            DisplayMetrics metrics = new DisplayMetrics();
            getWindowManager().getDefaultDisplay().getMetrics(metrics);
            int size = metrics.widthPixels;
            int middle = size / 2;
            int quarter = size / 4;
            genericDrug.setTranslationX(middle - quarter);
            genericDrug.setTranslationY(-3);
            LinearLayout layoutGenericDrug = (LinearLayout) findViewById(R.id.layoutGenericDrug);
            layoutGenericDrug.addView(genericDrug);
        }

        //Licenses
        TextView headerLicense = (TextView) findViewById(R.id.headerLicense);
        headerLicense.setTypeface(Typeface.SANS_SERIF, Typeface.BOLD);

        TextView fdaLicense = (TextView) findViewById(R.id.license1);
        Typeface font = Typeface.createFromAsset(getAssets(), "Typoster_demo.otf");
        fdaLicense.setTypeface(font);

        String fda;
        if (isStoredInLocal)
            fda = helper.getLicense_FDA(drug_name);
        else
            fda = license_FDA;
        if (fda.equals("Yes")) {
            fdaLicense.setText("Yes");
            fdaLicense.setTextColor(getResources().getColor(R.color.lightGreen));
        } else {
            fdaLicense.setText("Nd");
            fdaLicense.setTextColor(getResources().getColor(R.color.maroon));
        }

        TextView emaLicense = (TextView) findViewById(R.id.license3);
        emaLicense.setTypeface(font);
        String ema;
        if (isStoredInLocal)
            ema = helper.getLicense_EMA(drug_name);
        else
            ema = license_EMA;
        if (ema.equals("Yes")) {
            emaLicense.setText("Yes");
            emaLicense.setTextColor(getResources().getColor(R.color.lightGreen));
        } else {
            emaLicense.setText("Nd");
            emaLicense.setTextColor(getResources().getColor(R.color.maroon));
        }

        TextView aempsLicense = (TextView) findViewById(R.id.license2);
        aempsLicense.setTypeface(font);
        String aemps;
        if (isStoredInLocal)
            aemps = helper.getLicense_AEMPS(drug_name);
        else
            aemps = license_AEMPS;
        if (aemps.equals("Yes")) {
            aempsLicense.setText("Yes");
            aempsLicense.setTextColor(getResources().getColor(R.color.lightGreen));
        } else {
            aempsLicense.setText("Nd");
            aempsLicense.setTextColor(getResources().getColor(R.color.maroon));
        }

        ImageButton food_and_drug = (ImageButton) findViewById(R.id.food_and_drug);
        food_and_drug.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(Intent.ACTION_VIEW);
                intent.setData(Uri.parse(
                        "http://www.fda.gov/animalveterinary/products/approvedanimaldrugproducts/default.htm"));
                startActivity(intent);
            }
        });

        ImageButton european_medicines_agency = (ImageButton) findViewById(R.id.european_medicines_agency);
        european_medicines_agency.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(Intent.ACTION_VIEW);
                intent.setData(Uri.parse(
                        "http://www.ema.europa.eu/ema/index.jsp?curl=pages/medicines/landing/vet_epar_search.jsp&mid=WC0b01ac058001fa1c"));
                startActivity(intent);
            }
        });

        ImageButton logo_aemps = (ImageButton) findViewById(R.id.logo_aemps);
        logo_aemps.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(Intent.ACTION_VIEW);
                intent.setData(Uri.parse(
                        "http://www.aemps.gob.es/medicamentosVeterinarios/Med-Vet-autorizados/home.htm"));
                startActivity(intent);
            }

        });

        if (helper.existDrug(drug_name)) {
            int drug_priority = helper.getDrugPriority(drug_name);
            ArrayList<String> sorted_drugs = new ArrayList<String>();
            sorted_drugs.add(0, drug_name);
            for (int i = 1; i < drug_priority; i++) {
                String name = helper.getDrugName(i);
                sorted_drugs.add(i, name);
            }

            for (int i = 0; i < sorted_drugs.size(); i++)
                helper.setDrugPriority(sorted_drugs.get(i), i + 1);
        }

        if (!isStoredInLocal) {
            //Server code
            String[] urls = { "http://formmulary.tk/Android/getDoseInformation.php?drug_name=",
                    "http://formmulary.tk/Android/getGeneralNotesInformation.php?drug_name=" };
            new GetDoseInformation(this).execute(urls);
        }

        helper.close();
    }

}

From source file:com.gh4a.IssueLabelListActivity.java

private void selectLabel(TextView tvLabel, View viewColor, String color, boolean clearOtherSelected,
        EditText etLabel) {// w  w  w  .  j  ava 2s .c  om
    final Typeface boldCondensed = getApplicationContext().boldCondensed;
    tvLabel.setTag(color);

    viewColor.setBackgroundColor(Color.parseColor("#" + color));
    tvLabel.setBackgroundColor(Color.parseColor("#" + color));
    int r = Color.red(Color.parseColor("#" + color));
    int g = Color.green(Color.parseColor("#" + color));
    int b = Color.blue(Color.parseColor("#" + color));
    if (r + g + b < 383) {
        tvLabel.setTextColor(getResources().getColor(R.color.abs__primary_text_holo_dark));
    } else {
        tvLabel.setTextColor(getResources().getColor(R.color.abs__primary_text_holo_light));
    }
    tvLabel.setTypeface(boldCondensed);

    mSelectedColor = color;
    mSelectedEtLabel = etLabel;
    mSelectedLabel = tvLabel.getText().toString();
    if (clearOtherSelected) {
        clearOtherSelected(false);
    }
}

From source file:com.corporatetaxi.TaxiOntheWay_Activity.java

private void initiatePopupWindowcanceltaxi() {
    try {/*from www.j a  v a 2s. com*/
        dialog = new Dialog(TaxiOntheWay_Activity.this);
        dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); // before
        dialog.setContentView(R.layout.canceltaxi_popup);

        cross = (ImageButton) dialog.findViewById(R.id.cross);
        cross.setOnClickListener(cancle_btn_click_listener);
        rd1 = (RadioButton) dialog.findViewById(R.id.radioButton);
        rd2 = (RadioButton) dialog.findViewById(R.id.radioButton2);
        rd3 = (RadioButton) dialog.findViewById(R.id.radioButton3);
        btn_confirm = (Button) dialog.findViewById(R.id.btn_acceptor);
        TextView txt = (TextView) dialog.findViewById(R.id.textView);
        textheader = (TextView) dialog.findViewById(R.id.popup_text);
        Typeface tf = Typeface.createFromAsset(this.getAssets(), "Montserrat-Regular.ttf");
        rd1.setTypeface(tf);
        rd2.setTypeface(tf);
        rd3.setTypeface(tf);
        btn_confirm.setTypeface(tf);
        txt.setTypeface(tf);
        textheader.setTypeface(tf);
        btn_confirm.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                if (rd1.isChecked()) {
                    canceltaxirequest = getResources().getString(R.string.prompt_cancel_reason_one);

                } else if (rd2.isChecked()) {
                    canceltaxirequest = getResources().getString(R.string.prompt_cancel_reason_two);

                } else if (rd3.isChecked()) {
                    canceltaxirequest = getResources().getString(R.string.prompt_cancel_reason_three);

                }

                Allbeans allbeans = new Allbeans();

                allbeans.setCanceltaxirequest(canceltaxirequest);

                new CancelTaxiAsynch(allbeans).execute();

            }
        });

        dialog.show();
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:com.example.drugsformarinemammals.Dose_Information.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.dose_information);

    Bundle parameters = this.getIntent().getExtras();
    if (parameters != null) {
        TextView textViewDrug = (TextView) findViewById(R.id.textView_drug_name);
        textViewDrug.setTypeface(Typeface.SANS_SERIF);
        textViewDrug.setText(parameters.getString("drugName"));
        TextView textViewGroupName = (TextView) findViewById(R.id.textView_group_name);
        textViewGroupName.setTypeface(Typeface.SANS_SERIF);
        textViewGroupName.setText("(" + parameters.getString("groupName") + ")");
        layoutDose = (LinearLayout) findViewById(R.id.layout_dose);

        helper = new Handler_Sqlite(this);
        SQLiteDatabase db = helper.open();
        ArrayList<String> notes_index = new ArrayList<String>();
        ArrayList<String> references = new ArrayList<String>();
        ArrayList<Article_Reference> references_index = new ArrayList<Article_Reference>();
        reference_index = 'a';
        ArrayList<String> families = new ArrayList<String>();
        if (db != null)
            families = helper.read_animals_family(parameters.getString("drugName"),
                    parameters.getString("groupName"));

        for (int l = 0; l < families.size(); l++) {
            //if exists animals family

            TextView textView_family = new TextView(this);
            textView_family.setText(families.get(l));
            textView_family.setTextSize(20);
            textView_family.setTextColor(getResources().getColor(R.color.darkGray));
            textView_family.setTypeface(Typeface.SANS_SERIF, Typeface.DEFAULT_BOLD.getStyle());

            LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                    LayoutParams.WRAP_CONTENT);
            params.leftMargin = 30;/*from   w ww.  j a va  2  s  .c o  m*/
            params.topMargin = 20;
            layoutDose.addView(textView_family, layoutDose.getChildCount(), params);

            //dose information

            LinearLayout layout_dose_information = new LinearLayout(this);
            layout_dose_information.setOrientation(LinearLayout.VERTICAL);
            layout_dose_information
                    .setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
            layout_dose_information.setBackgroundResource(R.drawable.layout_border);

            ArrayList<Dose_Data> dose = new ArrayList<Dose_Data>();
            if (db != null) {
                dose = helper.read_dose_information(parameters.getString("drugName"),
                        parameters.getString("groupName"), families.get(l), "", "");
            }
            TableLayout doseTable = new TableLayout(this);
            doseTable.setStretchAllColumns(true);

            screenWidth = Integer.parseInt(getString(R.string.display));

            TableRow header = new TableRow(this);

            //Amount

            TextView textView_dose_amount = new TextView(this);
            textView_dose_amount.setText("Dose");
            textView_dose_amount.setSingleLine(true);
            textView_dose_amount.setTextColor(getResources().getColor(R.color.darkGray));
            textView_dose_amount.setTextSize(17);
            textView_dose_amount.setTypeface(Typeface.SANS_SERIF, Typeface.DEFAULT_BOLD.getStyle());
            TableRow.LayoutParams paramsAmount = new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT,
                    TableRow.LayoutParams.WRAP_CONTENT);
            paramsAmount.gravity = Gravity.CENTER;
            header.addView(textView_dose_amount, paramsAmount);

            //Posology
            TextView textView_posology = new TextView(this);
            if (screenWidth >= 720)
                textView_posology.setText("Posology");
            else
                textView_posology.setText("Pos");
            textView_posology.setSingleLine(true);
            textView_posology.setTextColor(getResources().getColor(R.color.darkGray));
            textView_posology.setTextSize(17);
            textView_posology.setTypeface(Typeface.SANS_SERIF, Typeface.DEFAULT_BOLD.getStyle());
            TableRow.LayoutParams paramsPosology = new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT,
                    TableRow.LayoutParams.WRAP_CONTENT);
            paramsPosology.gravity = Gravity.CENTER;
            if ((screenWidth < 600 && !isCollapsed(parameters.getString("drugName"),
                    parameters.getString("groupName"), families.get(l), "Posology")) || screenWidth >= 600)
                header.addView(textView_posology, paramsPosology);

            //Route

            TextView textView_route = new TextView(this);
            textView_route.setText("Route");
            textView_route.setSingleLine(true);
            textView_route.setTextColor(getResources().getColor(R.color.darkGray));
            textView_route.setTextSize(17);
            textView_route.setTypeface(Typeface.SANS_SERIF, Typeface.DEFAULT_BOLD.getStyle());
            TableRow.LayoutParams paramsRoute = new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT,
                    TableRow.LayoutParams.WRAP_CONTENT);
            paramsRoute.gravity = Gravity.CENTER;
            header.addView(textView_route, paramsRoute);

            //Reference

            TextView textView_reference = new TextView(this);
            textView_reference.setText("Ref");
            textView_reference.setSingleLine(true);
            textView_reference.setTextColor(getResources().getColor(R.color.darkGray));
            textView_reference.setTextSize(17);
            textView_reference.setTypeface(Typeface.SANS_SERIF, Typeface.DEFAULT_BOLD.getStyle());
            TableRow.LayoutParams paramsReference = new TableRow.LayoutParams(
                    TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT);
            paramsReference.gravity = Gravity.CENTER;
            header.addView(textView_reference, paramsReference);

            //Specific Note

            TextView textView_specific_note = new TextView(this);
            textView_specific_note.setText("Note");
            textView_specific_note.setSingleLine(true);
            textView_specific_note.setTextColor(getResources().getColor(R.color.darkGray));
            textView_specific_note.setTextSize(17);
            textView_specific_note.setTypeface(Typeface.SANS_SERIF, Typeface.DEFAULT_BOLD.getStyle());
            TableRow.LayoutParams paramsSpecificNote = new TableRow.LayoutParams(
                    TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT);
            paramsSpecificNote.gravity = Gravity.CENTER;
            if ((screenWidth < 600 && !isCollapsed(parameters.getString("drugName"),
                    parameters.getString("groupName"), families.get(l), "Note")) || screenWidth >= 600)
                header.addView(textView_specific_note, paramsSpecificNote);

            TableRow doseData = new TableRow(this);
            doseTable.addView(header);

            //General Dose

            if (dose.size() > 0) {
                show_dose(dose, doseTable, doseData, parameters.getString("drugName"),
                        parameters.getString("groupName"), families.get(l), "", "", notes_index, references,
                        references_index);
            }

            HashMap<String, ArrayList<String>> animal_information = new HashMap<String, ArrayList<String>>();
            if (db != null)
                animal_information = helper.read_animal_information(parameters.getString("drugName"),
                        parameters.getString("groupName"), families.get(l));

            String animalName;
            Object[] animalsName = animal_information.keySet().toArray();
            for (int i = 0; i < animalsName.length; i++) {
                doseData = new TableRow(this);

                //if exists animal name
                animalName = (String) animalsName[i];
                TextView textView_animal_name = new TextView(this);
                if (!animalName.equals("")) {

                    //Animal name

                    textView_animal_name.setText(animalName);
                    textView_animal_name.setSingleLine(false);
                    textView_animal_name.setTextColor(getResources().getColor(R.color.darkGray));
                    textView_animal_name.setTextSize(15);
                    textView_animal_name.setTypeface(Typeface.SANS_SERIF, Typeface.DEFAULT_BOLD.getStyle());
                }

                //if exists category
                ArrayList<String> categories = animal_information.get(animalName);
                String animalCategory;
                for (int j = 0; j < categories.size(); j++) {

                    animalCategory = categories.get(j);

                    if (!animalCategory.equals("")) {

                        //Animal category

                        TextView textView_animal_category = new TextView(this);
                        textView_animal_category.setText(animalCategory);
                        textView_animal_category.setSingleLine(false);
                        textView_animal_category.setTextColor(Color.BLACK);
                        textView_animal_category.setTextSize(15);
                        textView_animal_category.setTypeface(Typeface.SANS_SERIF);
                        if (!animalName.equals("")) {
                            if (j == 0) {
                                TableRow.LayoutParams paramsAnimalName = new TableRow.LayoutParams(
                                        TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT);
                                if (screenWidth < 600
                                        && isCollapsed(parameters.getString("drugName"),
                                                parameters.getString("groupName"), families.get(l), "Posology")
                                        && isCollapsed(parameters.getString("drugName"),
                                                parameters.getString("groupName"), families.get(l), "Note"))
                                    paramsAnimalName.span = 3;
                                else if (screenWidth < 600 && (isCollapsed(parameters.getString("drugName"),
                                        parameters.getString("groupName"), families.get(l), "Posology")
                                        || isCollapsed(parameters.getString("drugName"),
                                                parameters.getString("groupName"), families.get(l), "Note")))
                                    paramsAnimalName.span = 4;
                                else
                                    paramsAnimalName.span = 5;

                                doseData.addView(textView_animal_name, paramsAnimalName);
                                doseTable.addView(doseData);
                            }

                            if (db != null)
                                dose = helper.read_dose_information(parameters.getString("drugName"),
                                        parameters.getString("groupName"), families.get(l), animalName,
                                        animalCategory);

                            doseData = new TableRow(this);
                            textView_animal_category.setTypeface(Typeface.SANS_SERIF, Typeface.ITALIC);
                            TableRow.LayoutParams paramsCategoryName = new TableRow.LayoutParams(
                                    TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT);
                            if (screenWidth < 600
                                    && isCollapsed(parameters.getString("drugName"),
                                            parameters.getString("groupName"), families.get(l), "Posology")
                                    && isCollapsed(parameters.getString("drugName"),
                                            parameters.getString("groupName"), families.get(l), "Note"))
                                paramsCategoryName.span = 3;
                            else if (screenWidth < 600 && (isCollapsed(parameters.getString("drugName"),
                                    parameters.getString("groupName"), families.get(l), "Posology")
                                    || isCollapsed(parameters.getString("drugName"),
                                            parameters.getString("groupName"), families.get(l), "Note")))
                                paramsCategoryName.span = 4;
                            else
                                paramsCategoryName.span = 5;
                            if (screenWidth < 600)
                                paramsCategoryName.leftMargin = 15;
                            else if (screenWidth >= 600 && screenWidth < 720)
                                paramsCategoryName.leftMargin = 20;
                            else
                                paramsCategoryName.leftMargin = 30;
                            doseData.addView(textView_animal_category, paramsCategoryName);
                            doseTable.addView(doseData);
                            doseData = new TableRow(this);
                            show_dose(dose, doseTable, doseData, parameters.getString("drugName"),
                                    parameters.getString("groupName"), families.get(l), animalName,
                                    animalCategory, notes_index, references, references_index);

                            doseData = new TableRow(this);
                        } else {
                            if (db != null)
                                dose = helper.read_dose_information(parameters.getString("drugName"),
                                        parameters.getString("groupName"), families.get(l), animalName,
                                        animalCategory);

                            textView_animal_category.setTypeface(Typeface.SANS_SERIF,
                                    Typeface.DEFAULT_BOLD.getStyle());
                            textView_animal_category.setTextColor(getResources().getColor(R.color.darkGray));
                            TableRow.LayoutParams paramsCategoryName = new TableRow.LayoutParams(
                                    TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT);
                            if (screenWidth < 600
                                    && isCollapsed(parameters.getString("drugName"),
                                            parameters.getString("groupName"), families.get(l), "Posology")
                                    && isCollapsed(parameters.getString("drugName"),
                                            parameters.getString("groupName"), families.get(l), "Note"))
                                paramsCategoryName.span = 3;
                            else if (screenWidth < 600 && (isCollapsed(parameters.getString("drugName"),
                                    parameters.getString("groupName"), families.get(l), "Posology")
                                    || isCollapsed(parameters.getString("drugName"),
                                            parameters.getString("groupName"), families.get(l), "Note")))
                                paramsCategoryName.span = 4;
                            else
                                paramsCategoryName.span = 5;
                            doseData.addView(textView_animal_category, paramsCategoryName);
                            doseTable.addView(doseData);
                            doseData = new TableRow(this);
                            show_dose(dose, doseTable, doseData, parameters.getString("drugName"),
                                    parameters.getString("groupName"), families.get(l), animalName,
                                    animalCategory, notes_index, references, references_index);

                            doseData = new TableRow(this);
                        }

                    }

                    if (!animalName.equals("") && animalCategory.equals("")) {
                        if (db != null)
                            dose = helper.read_dose_information(parameters.getString("drugName"),
                                    parameters.getString("groupName"), families.get(l), animalName,
                                    animalCategory);

                        TableRow.LayoutParams paramsAnimalName = new TableRow.LayoutParams(
                                TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT);
                        if (screenWidth < 600
                                && isCollapsed(parameters.getString("drugName"),
                                        parameters.getString("groupName"), families.get(l), "Posology")
                                && isCollapsed(parameters.getString("drugName"),
                                        parameters.getString("groupName"), families.get(l), "Note"))
                            paramsAnimalName.span = 3;
                        else if (screenWidth < 600 && (isCollapsed(parameters.getString("drugName"),
                                parameters.getString("groupName"), families.get(l), "Posology")
                                || isCollapsed(parameters.getString("drugName"),
                                        parameters.getString("groupName"), families.get(l), "Note")))
                            paramsAnimalName.span = 4;
                        else
                            paramsAnimalName.span = 5;
                        doseData.addView(textView_animal_name, paramsAnimalName);
                        doseTable.addView(doseData);
                        doseData = new TableRow(this);
                        show_dose(dose, doseTable, doseData, parameters.getString("drugName"),
                                parameters.getString("groupName"), families.get(l), animalName, animalCategory,
                                notes_index, references, references_index);

                        doseData = new TableRow(this);
                    }
                }

            }

            LinearLayout.LayoutParams paramsDoseTable = new LinearLayout.LayoutParams(
                    LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
            if (screenWidth >= 600) {
                paramsDoseTable.topMargin = 5;
                paramsDoseTable.leftMargin = 50;
                paramsDoseTable.rightMargin = 50;
            } else {
                paramsDoseTable.topMargin = 5;
                paramsDoseTable.leftMargin = 60;
                paramsDoseTable.rightMargin = 30;
            }
            layout_dose_information.addView(doseTable, paramsDoseTable);

            layoutDose.addView(layout_dose_information, layoutDose.getChildCount());
        }
        helper.close();

        //Notes
        additionalInformationInterface("GENERAL NOTES", parameters.getString("drugName"),
                parameters.getString("groupName"), notes_index, references_index);
        additionalInformationInterface("SPECIFIC NOTES", parameters.getString("drugName"),
                parameters.getString("groupName"), notes_index, references_index);
        //References
        additionalInformationInterface("REFERENCES", parameters.getString("drugName"),
                parameters.getString("groupName"), notes_index, references_index);

    }

}

From source file:com.egloos.hyunyi.musicinfo.LinkPopUp.java

private void displayArtistInfo(JSONObject j) throws JSONException {
    if (imageLoader == null)
        imageLoader = ImageLoader.getInstance();
    if (!imageLoader.isInited())
        imageLoader.init(config);/*from   w w  w .ja v a  2 s. c  o m*/

    Log.i("musicInfo", "LinkPopUp. displayArtistInfo " + j.toString());

    //JSONObject j_artist_info = j.getJSONObject("artist");

    final String artist_name = j.getString("name");

    tArtistName.setText(artist_name);
    final JSONObject urls = j.optJSONObject("urls");
    final JSONArray videos = j.optJSONArray("video");
    final JSONArray images = j.optJSONArray("images");

    final String msg = artist_name.replaceAll("\\p{Punct}", " ").replaceAll("\\p{Space}", "+");

    AsyncHttpClient client = new AsyncHttpClient();

    String fmURL = "http://ws.audioscrobbler.com/2.0/?method=artist.getinfo&artist=" + msg
            + "&autocorrect[1]&format=json&api_key=ca4c10f9ae187ebb889b33ba12da7ee9";
    Log.i("musicInfo", fmURL);

    client.get(fmURL, new AsyncHttpResponseHandler() {
        @Override
        public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
            String r = new String(responseBody);
            ArrayList<String> image_urls = new ArrayList<String>();

            try {
                Log.i("musicInfo", "Communicating with LastFM...");

                JSONObject json = new JSONObject(r);
                Log.i("musicInfo", json.toString());

                json = json.getJSONObject("artist");
                Log.i("musicInfo", json.toString());

                JSONArray artist_images = json.optJSONArray("image");
                Log.i("musicInfo", artist_images.toString());

                for (int i = 0; i < artist_images.length(); i++) {
                    JSONObject j = artist_images.getJSONObject(i);
                    Log.i("musicInfo", j.optString("size"));
                    if (j.optString("size").contains("extralarge")) {
                        image_urls.add(j.optString("#text"));
                        //b.putString("fm_image", j.getString("#text"));
                        //Log.i("musicInfo", j.getString("#text"));
                        break;
                    }
                }
            } catch (JSONException e) {
                e.printStackTrace();
            }

            if (images != null) {
                for (int i = 0; i < images.length(); i++) {
                    JSONObject image = null;
                    try {
                        image = images.getJSONObject(i);
                    } catch (JSONException e) {
                        e.printStackTrace();
                    }
                    int width = image.optInt("width", 0);
                    int height = image.optInt("height", 0);
                    String url = image.optString("url", "");
                    Log.i("musicInfo", i + ": " + url);
                    if ((width * height > 10000) && (width * height < 100000)
                            && (!url.contains("userserve-ak"))) {
                        //if ((width>300&&width<100)&&(height>300&&height<1000)&&(!url.contains("userserve-ak"))) {
                        image_urls.add(url);
                        Log.i("musicInfo", "Selected: " + url);
                        //available_images.put(image);
                    }
                }
            }

            int random = (int) (Math.random() * image_urls.size());
            final String f_url = image_urls.get(random);

            Log.i("musicInfo",
                    "Total image#=" + image_urls.size() + " Selected image#=" + random + " " + f_url);

            if (image_urls.size() > 0) {
                imageLoader.displayImage(f_url, ArtistImage, new ImageLoadingListener() {
                    @Override
                    public void onLoadingStarted(String imageUri, View view) {

                    }

                    @Override
                    public void onLoadingFailed(String imageUri, View view, FailReason failReason) {

                    }

                    @Override
                    public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {

                        lLinkList.removeAllViews();
                        //String attr = fImage.optJSONObject("license").optString("attribution");
                        //tAttribution.setText("Credit. " + ((attr == null) || (attr.contains("n/a")) ? "Unknown" : attr));
                        if (urls != null) {
                            String[] jsonName = { "wikipedia_url", "mb_url", "lastfm_url", "official_url",
                                    "twitter_url" };
                            for (int i = 0; i < jsonName.length; i++) {
                                if ((urls.optString(jsonName[i]) != null)
                                        && (urls.optString(jsonName[i]) != "")) {
                                    Log.d("musicinfo", "Link URL: " + urls.optString(jsonName[i]));
                                    TextView tv = new TextView(getApplicationContext());
                                    tv.setTextSize(11);
                                    tv.setPadding(16, 16, 16, 16);
                                    tv.setTextColor(Color.LTGRAY);
                                    tv.setTypeface(Typeface.SANS_SERIF);
                                    tv.setGravity(Gravity.CENTER_VERTICAL);

                                    switch (jsonName[i]) {
                                    case "official_url":
                                        tv.setText("HOME.");
                                        break;
                                    case "wikipedia_url":
                                        tv.setText("WIKI.");
                                        break;
                                    case "mb_url":
                                        tv.setText("Music Brainz.");
                                        break;
                                    case "lastfm_url":
                                        tv.setText("Last FM.");
                                        break;
                                    case "twitter_url":
                                        tv.setText("Twitter.");
                                        break;
                                    }

                                    try {
                                        tv.setTag(urls.getString(jsonName[i]));
                                    } catch (JSONException e) {
                                        e.printStackTrace();
                                    }

                                    tv.setOnClickListener(new View.OnClickListener() {
                                        @Override
                                        public void onClick(View v) {
                                            Intent intent = new Intent();
                                            intent.setAction(Intent.ACTION_VIEW);
                                            intent.addCategory(Intent.CATEGORY_BROWSABLE);
                                            intent.setData(Uri.parse((String) v.getTag()));
                                            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                                            startActivity(intent);
                                            Toast.makeText(getApplicationContext(), "Open the Link...",
                                                    Toast.LENGTH_SHORT).show();
                                            //finish();
                                        }
                                    });
                                    lLinkList.addView(tv);
                                }
                            }
                        } else {
                            TextView tv = new TextView(getApplicationContext());
                            tv.setTextSize(11);
                            tv.setPadding(16, 16, 16, 16);
                            tv.setTextColor(Color.LTGRAY);
                            tv.setTypeface(Typeface.SANS_SERIF);
                            tv.setGravity(Gravity.CENTER_VERTICAL);
                            tv.setText("Sorry, No Link Here...");
                            lLinkList.addView(tv);
                        }

                        if (videos != null) {
                            jVideoArray = videos;
                            mAdapter = new StaggeredViewAdapter(getApplicationContext(),
                                    android.R.layout.simple_list_item_1, generateImageData(videos));
                            //if (mData == null) {
                            mData = generateImageData(videos);
                            //}

                            //mAdapter.clear();

                            for (JSONObject data : mData) {
                                mAdapter.add(data);
                            }
                            mGridView.setAdapter(mAdapter);
                        } else {

                        }

                        adjBottomColor(((ImageView) view).getDrawable());
                    }

                    @Override
                    public void onLoadingCancelled(String imageUri, View view) {

                    }
                });
            } else {
                ArtistImage.setImageResource(R.drawable.lamb_no_image_available);
            }
        }

        @Override
        public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) {

        }
    });
}

From source file:com.usertaxi.TaxiArrived_Acitivity.java

private void initiatePopupWindowcanceltaxi() {
    try {//w w  w . j a  va 2 s .  c  om
        dialog = new Dialog(TaxiArrived_Acitivity.this);
        dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); // before
        dialog.setContentView(R.layout.canceltaxi_popup);

        cross = (ImageButton) dialog.findViewById(R.id.cross);
        cross.setOnClickListener(cancle_btn_click_listener);
        rd1 = (RadioButton) dialog.findViewById(R.id.radioButton);
        rd2 = (RadioButton) dialog.findViewById(R.id.radioButton2);
        rd3 = (RadioButton) dialog.findViewById(R.id.radioButton3);
        btn_confirm = (Button) dialog.findViewById(R.id.btn_acceptor);
        TextView txt = (TextView) dialog.findViewById(R.id.textView);
        textheader = (TextView) dialog.findViewById(R.id.popup_text);

        Typeface tf = Typeface.createFromAsset(this.getAssets(), "Montserrat-Regular.ttf");
        rd1.setTypeface(tf);
        rd2.setTypeface(tf);
        rd3.setTypeface(tf);
        btn_confirm.setTypeface(tf);
        txt.setTypeface(tf);
        textheader.setTypeface(tf);
        btn_confirm.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                if (rd1.isChecked()) {
                    canceltaxirequest = getResources().getString(R.string.prompt_canceltaxione);

                } else if (rd2.isChecked()) {
                    canceltaxirequest = getResources().getString(R.string.prompt_cancel_reason_two);

                } else if (rd3.isChecked()) {
                    canceltaxirequest = getResources().getString(R.string.prompt_cancel_reason_three);

                }

                Allbeans allbeans = new Allbeans();

                allbeans.setCanceltaxirequest(canceltaxirequest);

                new CancelTaxiAsynch(allbeans).execute();

            }
        });
        dialog.show();

    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:com.example.drugsformarinemammals.Dose_Information.java

public void show_dose(ArrayList<Dose_Data> dose, TableLayout dose_table, TableRow dose_data, String drug_name,
        String group_name, String animal_family, String animal_name, String animal_category,
        ArrayList<String> notes, ArrayList<String> references, ArrayList<Article_Reference> references_index) {

    String doseAmount;/*from w w w.  ja  va2 s. com*/
    String dosePosology;
    String doseRoute;
    String doseBookReference;
    String doseArticleReference;
    for (int k = 0; k < dose.size(); k++) {
        if (k > 0) {
            dose_data = new TableRow(this);
        }

        doseAmount = dose.get(k).getAmount();
        dosePosology = dose.get(k).getPosology();
        doseRoute = dose.get(k).getRoute();
        doseBookReference = dose.get(k).getBookReference();
        doseArticleReference = dose.get(k).getArticleReference();

        //Dose amount data

        TextView textView_animal_dose_amount = new TextView(this);
        textView_animal_dose_amount.setText(doseAmount);
        textView_animal_dose_amount.setSingleLine(false);
        textView_animal_dose_amount.setTextColor(Color.BLACK);
        textView_animal_dose_amount.setTextSize(15);
        textView_animal_dose_amount.setTypeface(Typeface.SANS_SERIF);
        TableRow.LayoutParams paramsDoseAmount = new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT,
                TableRow.LayoutParams.WRAP_CONTENT);
        paramsDoseAmount.gravity = Gravity.CENTER;
        dose_data.addView(textView_animal_dose_amount, paramsDoseAmount);

        //Dose posology data

        TextView textView_animal_dose_posology = new TextView(this);
        textView_animal_dose_posology.setText(dosePosology);
        textView_animal_dose_posology.setSingleLine(false);
        textView_animal_dose_posology.setTextColor(Color.BLACK);
        textView_animal_dose_posology.setTextSize(15);
        textView_animal_dose_posology.setTypeface(Typeface.SANS_SERIF);
        TableRow.LayoutParams paramsDosePosology = new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT,
                TableRow.LayoutParams.WRAP_CONTENT);
        paramsDosePosology.gravity = Gravity.CENTER;
        if ((screenWidth < 600 && !isCollapsed(drug_name, group_name, animal_family, "Posology"))
                || screenWidth >= 600)
            dose_data.addView(textView_animal_dose_posology, paramsDosePosology);

        //Dose route data

        TextView textView_animal_dose_route = new TextView(this);
        textView_animal_dose_route.setText(doseRoute);
        textView_animal_dose_route.setSingleLine(false);
        textView_animal_dose_route.setTextColor(Color.BLACK);
        textView_animal_dose_route.setTextSize(15);
        textView_animal_dose_route.setTypeface(Typeface.SANS_SERIF);
        if (screenWidth >= 600) {
            TableRow.LayoutParams paramsDoseRoute = new TableRow.LayoutParams(
                    TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT);
            paramsDoseRoute.gravity = Gravity.CENTER;
            dose_data.addView(textView_animal_dose_route, paramsDoseRoute);
        } else {
            TableRow.LayoutParams paramsDoseRoute = new TableRow.LayoutParams(30,
                    TableRow.LayoutParams.WRAP_CONTENT);
            paramsDoseRoute.gravity = Gravity.CENTER;
            dose_data.addView(textView_animal_dose_route, paramsDoseRoute);
        }

        //Dose reference data

        TextView textView_animal_dose_reference = new TextView(this);
        if (!doseBookReference.equals(""))
            textView_animal_dose_reference.setText(doseBookReference);
        else if (!doseArticleReference.equals("")) {
            if (!references.contains(doseArticleReference)) {
                references.add(references.size(), doseArticleReference);
                Article_Reference article_reference = new Article_Reference(reference_index,
                        doseArticleReference);
                references_index.add(references_index.size(), article_reference);
                reference_index++;
            }
            int article_index = references.indexOf(doseArticleReference);
            textView_animal_dose_reference.setText("(" + references_index.get(article_index).getIndex() + ")");
        }
        textView_animal_dose_reference.setSingleLine(false);
        textView_animal_dose_reference.setTextColor(Color.BLACK);
        textView_animal_dose_reference.setTextSize(15);
        textView_animal_dose_reference.setTypeface(Typeface.SANS_SERIF);
        if (screenWidth >= 600) {
            TableRow.LayoutParams paramsDoseReference = new TableRow.LayoutParams(
                    TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT);
            paramsDoseReference.gravity = Gravity.CENTER;
            dose_data.addView(textView_animal_dose_reference, paramsDoseReference);
        } else {
            TableRow.LayoutParams paramsDoseReference = new TableRow.LayoutParams(150,
                    TableRow.LayoutParams.WRAP_CONTENT);
            paramsDoseReference.gravity = Gravity.CENTER;
            dose_data.addView(textView_animal_dose_reference, paramsDoseReference);
        }

        //Specific note index

        ArrayList<String> specific_notes = new ArrayList<String>();
        specific_notes = helper.read_specific_notes(drug_name, group_name, animal_name, animal_family,
                animal_category, doseAmount, dosePosology, doseRoute, doseBookReference, doseArticleReference);

        String index = "";
        for (int m = 0; m < specific_notes.size(); m++) {
            String note = specific_notes.get(m);
            if (!notes.contains(note)) {
                notes.add(notes.size(), note);
            }
            index += "(" + (notes.indexOf(note) + 1) + ")  ";
        }

        TextView textView_specific_note_index = new TextView(this);
        textView_specific_note_index.setText(index);
        textView_specific_note_index.setSingleLine(false);
        textView_specific_note_index.setTextColor(Color.BLACK);
        textView_specific_note_index.setTextSize(15);
        textView_specific_note_index.setTypeface(Typeface.SANS_SERIF);
        if (screenWidth >= 600 && screenWidth < 720) {
            TableRow.LayoutParams paramsSpecificNoteIndex = new TableRow.LayoutParams(150,
                    TableRow.LayoutParams.WRAP_CONTENT);
            paramsSpecificNoteIndex.gravity = Gravity.CENTER;
            dose_data.addView(textView_specific_note_index, paramsSpecificNoteIndex);
        } else if (screenWidth >= 720) {
            TableRow.LayoutParams paramsSpecificNoteIndex = new TableRow.LayoutParams(
                    TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT);
            paramsSpecificNoteIndex.gravity = Gravity.CENTER;
            dose_data.addView(textView_specific_note_index, paramsSpecificNoteIndex);
        } else {
            TableRow.LayoutParams paramsSpecificNoteIndex = new TableRow.LayoutParams(100,
                    TableRow.LayoutParams.WRAP_CONTENT);
            paramsSpecificNoteIndex.gravity = Gravity.CENTER;
            if ((screenWidth < 600 && !isCollapsed(drug_name, group_name, animal_family, "Note"))
                    || screenWidth >= 600)
                dose_data.addView(textView_specific_note_index, paramsSpecificNoteIndex);
        }

        dose_table.addView(dose_data);

    }
}

From source file:com.github.irshulx.Components.InputExtensions.java

private void updateTextStyle(TextView editText, EditorTextStyle editorTextStyle) {
    EditorControl tag;/*from  ww  w  .  j  a  va2 s  .  c  om*/
    if (editText == null) {
        editText = (EditText) editorCore.getActiveView();
    }
    EditorControl editorControl = editorCore.getControlTag(editText);
    if (isEditorTextStyleHeaders(editorTextStyle)) {
        if (editorCore.containsStyle(editorControl.editorTextStyles, editorTextStyle)) {
            editText.setTextSize(TypedValue.COMPLEX_UNIT_SP, NORMALTEXTSIZE);
            editText.setTypeface(getTypeface(CONTENT, Typeface.NORMAL));
            tag = reWriteTags(editorControl, EditorTextStyle.NORMAL);
        } else {
            editText.setTextSize(TypedValue.COMPLEX_UNIT_SP, getTextStyleFromStyle(editorTextStyle));
            editText.setTypeface(getTypeface(HEADING, Typeface.BOLD));
            tag = reWriteTags(editorControl, editorTextStyle);
        }
        editText.setTag(tag);
    }
}