Example usage for android.graphics Typeface createFromAsset

List of usage examples for android.graphics Typeface createFromAsset

Introduction

In this page you can find the example usage for android.graphics Typeface createFromAsset.

Prototype

public static Typeface createFromAsset(AssetManager mgr, String path) 

Source Link

Document

Create a new typeface from the specified font data.

Usage

From source file:io.lqd.sdk.visual.SlideUp.java

private void setUpSlideUp() {
    LayoutInflater layoutInflater = (LayoutInflater) mContext
            .getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
    container = (ViewGroup) layoutInflater.inflate(R.layout.activity_slide_up, null);
    TextView mViewMessage = (TextView) container.findViewById(R.id.slideUpText);

    Typeface RegularLato = Typeface.createFromAsset(mContext.getAssets(), "fonts/Lato-Regular.ttf");

    // Set the font
    mViewMessage.setTypeface(RegularLato);

    // Set the message
    mViewMessage.setText(mSlideModel.getMessage());

    // Change Background Color
    container.findViewById(R.id.lowest_layout).setBackgroundColor(Color.parseColor(mSlideModel.getBgColor()));

    // Change Text Color
    ((TextView) container.findViewById(R.id.slideUpText))
            .setTextColor(Color.parseColor(mSlideModel.getMessageColor()));

    // Get View's height depending on device
    final ViewTreeObserver observer = container.getViewTreeObserver();
    observer.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
        @Override/*from  w  w  w. j  a v  a  2s.  c  o  m*/
        public void onGlobalLayout() {
            height = container.getHeight();
        }
    });

    mPopupWindow = new PopupWindow(container, ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT, true);

    mPopupWindow.setFocusable(false);
    mPopupWindow.setOutsideTouchable(true);
    mPopupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
        @Override
        public void onDismiss() {
            Liquid.getInstance().showInAppMessages();
        }
    });
}

From source file:foam.starwisp.StarwispActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    requestWindowFeature(Window.FEATURE_NO_TITLE);
    //        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
    //                             WindowManager.LayoutParams.FLAG_FULLSCREEN);

    setContentView(R.layout.main);//  w  w  w  .  j  a v  a 2  s .  c  o m
    //OuyaController.init(this);

    String arg = "none";
    Bundle extras = getIntent().getExtras();
    if (extras != null) {
        arg = extras.getString("arg");
    }

    String ori = "'portrait";
    if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
        ori = "'landscape";
    }
    m_Scheme.eval("(set! screen-orientation " + ori + ")");

    String json = m_Scheme.eval("(activity-callback 'on-create \"" + m_Name + "\" (list \"" + arg + "\"))");
    View root = findViewById(R.id.main);

    root.setPadding(0, 0, 0, 0);

    m_Typeface = Typeface.createFromAsset(getAssets(), "fonts/starwisp.ttf");
    //m_Typeface = Typeface.createFromAsset(getAssets(), "fonts/grstylus.ttf");

    try {
        m_Builder.Build(this, m_Name, new JSONArray(json), (ViewGroup) root);
    } catch (JSONException e) {
        Log.e("starwisp", "Error parsing [" + json + "] " + e.toString());
    }
}

From source file:com.lsb.inomet.Inomet.java

@SuppressWarnings("deprecation")
private void setup_widget() {

    digitalClock = (DigitalClock) findViewById(R.id.relojDigital);
    Typeface font = Typeface.createFromAsset(getAssets(), "damag.ttf");
    digitalClock.setTypeface(font);//  w  w w . j a  v  a 2 s  .c  o m

    logoInomet = (ImageView) findViewById(R.id.logoInomet);
    logoInomet.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            datuak_irakurri();
        }
    });

    lluviaInomet = (ImageView) findViewById(R.id.lluviaInomet);
    humedadText = (TextView) findViewById(R.id.humedadText);
    contaText = (TextView) findViewById(R.id.contaminacionText);
    vientoText = (TextView) findViewById(R.id.vientoText);
    tempeText = (TextView) findViewById(R.id.tempeText);
    presionText = (TextView) findViewById(R.id.presionText);
    luminosidadText = (TextView) findViewById(R.id.luminosidadText);
}

From source file:hongik.android.project.best.StoreReviewActivity.java

public void drawTable() throws Exception {
    String query = "func=morereview" + "&license=" + license;
    DBConnector conn = new DBConnector(query);
    conn.start();/*from   w w  w .j a va2 s .c  o  m*/

    conn.join();
    JSONObject jsonResult = conn.getResult();
    boolean result = jsonResult.getBoolean("result");

    if (!result) {
        return;
    }

    String storeName = jsonResult.getString("sname");
    ((TextViewPlus) findViewById(R.id.storereview_storename)).setText(storeName);

    JSONArray review = null;
    if (!jsonResult.isNull("review")) {
        review = jsonResult.getJSONArray("review");
    }

    //Draw Review Table
    if (review != null) {
        TableRow motive = (TableRow) reviewTable.getChildAt(1);

        for (int i = 0; i < review.length(); i++) {
            JSONObject json = review.getJSONObject(i);
            final String[] elements = new String[4];
            elements[0] = Double.parseDouble(json.getString("GRADE")) + "";
            elements[1] = json.getString("NOTE");
            elements[2] = json.getString("CID#");
            elements[3] = json.getString("DAY");

            TableRow tbRow = new TableRow(this);
            TextViewPlus[] tbCols = new TextViewPlus[4];

            if (elements[1].length() > 14)
                elements[1] = elements[1].substring(0, 14) + "...";

            for (int j = 0; j < 4; j++) {
                tbCols[j] = new TextViewPlus(this);
                tbCols[j].setText(elements[j]);
                tbCols[j].setLayoutParams(motive.getChildAt(j).getLayoutParams());
                tbCols[j].setGravity(Gravity.CENTER);
                tbCols[j].setTypeface(Typeface.createFromAsset(tbCols[j].getContext().getAssets(),
                        "InterparkGothicBold.ttf"));
                tbCols[j].setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Intent reviewIntent = new Intent(originActivity, ReviewDetailActivity.class);
                        reviewIntent.putExtra("ACCESS", "STORE");
                        reviewIntent.putExtra("CID", elements[2]);
                        reviewIntent.putExtra("LICENSE", license);
                        Log.i("StoreReview", "StartActivity");
                        startActivity(reviewIntent);
                    }
                });

                Log.i("StoreMenu", "COL" + j + ":" + elements[j]);
                tbRow.addView(tbCols[j]);
            }
            reviewTable.addView(tbRow);
        }
    }
    reviewTable.removeViewAt(1);
}

From source file:com.liken.customviews.TypefaceTextView.java

public TypefaceTextView(Context context, AttributeSet attrs) {
    super(context, attrs);

    // Get our custom attributes
    TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.TypefaceTextView, 0, 0);

    Typeface typeface = Typeface.createFromAsset(context.getAssets(), "fonts/Aaargh.ttf");

    // Cache the Typeface object
    //   sTypefaceCache.put(typefaceName, typeface);

    setTypeface(typeface);/*ww  w.  ja v  a2s . c  o m*/
    /*        try {
    String typefaceName = a.getString(
            R.styleable.TypefaceTextView_Aaargh);
            
    if (!isInEditMode() && !TextUtils.isEmpty(typefaceName)) {
        Typeface typeface = sTypefaceCache.get(typefaceName);
                
        if (typeface == null) {
            typeface = Typeface.createFromAsset(context.getAssets(),
                   "fonts/Aaargh.ttf");
                    
            // Cache the Typeface object
            sTypefaceCache.put(typefaceName, typeface);
        }
        setTypeface(typeface);
                
        // Note: This flag is required for proper typeface rendering
        setPaintFlags(getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG);
    }
            } finally {
    a.recycle();
            }*/
}

From source file:app.philm.in.util.TypefaceManager.java

private Typeface getTypeface(final String filename) {
    Typeface typeface = mCache.get(filename);
    if (typeface == null) {
        typeface = Typeface.createFromAsset(mAssetManager, "fonts/" + filename);
        mCache.put(filename, typeface);/*from  w w w .  ja va 2 s  .  c om*/
    }
    return typeface;
}

From source file:co.dilaver.quoter.fragments.QODFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    View view = inflater.inflate(R.layout.fragment_qod, container, false);

    sharedPrefStorage = new SharedPrefStorage(getActivity());

    MainActivity activity = (MainActivity) getActivity();
    activity.setActionBarItemsClickListener(this);

    font = Typeface.createFromAsset(getActivity().getAssets(), sharedPrefStorage.getQodFont());

    qodText = (TextView) view.findViewById(R.id.tvQodText);
    qodAuthor = (TextView) view.findViewById(R.id.tvQodAuthor);
    noData = (TextView) view.findViewById(R.id.tvNoData);
    rootLayout = (CoordinatorLayout) view.findViewById(R.id.clQodRoot);
    loadingQod = (ProgressBar) view.findViewById(R.id.pbQod);
    noData.setOnClickListener(new View.OnClickListener() {
        @Override/*from   w  w  w.  jav a 2 s  .c o m*/
        public void onClick(View v) {
            noData.setVisibility(View.GONE);
            loadingQod.setVisibility(View.VISIBLE);
            getQod();
        }
    });

    AutofitHelper.create(qodText);

    qodText.setTypeface(font);
    qodAuthor.setTypeface(font);
    qodText.setTextColor(sharedPrefStorage.getQodColor());
    qodAuthor.setTextColor(sharedPrefStorage.getQodColor());

    if (sharedPrefStorage.getQodText().equals("empty") || sharedPrefStorage.getQodAuthor().equals("empty")) {
        loadingQod.setVisibility(View.VISIBLE);
        getQod();
    } else {
        qodString = sharedPrefStorage.getQodText();
        authorString = sharedPrefStorage.getQodAuthor();

        qodText.setText(getString(R.string.str_WithinQuotation, qodString));
        qodAuthor.setText(authorString);
        getQod();
    }

    return view;
}

From source file:cl.smartcities.isci.transportinspector.dialogs.BusSelectionDialog.java

@NonNull
@Override/*from   w w  w .j  a  v  a 2s .  c o  m*/
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final AlertDialog dialog;
    AlertDialog.Builder builder = new AlertDialog.Builder(getContext());

    LayoutInflater inflater = this.getActivity().getLayoutInflater();
    final View dialog_view = inflater.inflate(R.layout.bus_selection_dialog, null);
    final Typeface iconTypeface = Typeface.createFromAsset(this.getContext().getAssets(),
            getActivity().getString(R.string.icon_font));
    ((TextView) dialog_view.findViewById(R.id.suggestion_icon)).setTypeface(iconTypeface);

    builder.setView(dialog_view);
    builder.setCancelable(false);
    dialog = builder.create();

    final Bundle bundle = getArguments();
    ArrayList<Bus> buses = null;

    if (bundle != null) {
        buses = bundle.getParcelableArrayList(NotificationState.BUSES);
    }

    if (buses != null && !buses.isEmpty()) {
        dialog_view.findViewById(R.id.list_view).setVisibility(View.VISIBLE);
        setBusMap(buses);
        ArrayList<String> serviceList = new ArrayList<>();
        serviceList.addAll(this.busMap.keySet());
        BusSelectionAdapter adapter = new BusSelectionAdapter(this.getContext(), serviceList, busMap,
                new BusSelectionAdapter.ListViewAdapterListener() {
                    @Override
                    public void onPositiveClick(Bus bus) {
                        dialog.cancel();
                        listener.onPositiveClick(bus);
                    }

                    @Override
                    public void onNegativeClick() {
                        dialog.cancel();
                        listener.onNegativeClick();
                    }
                });
        ListView listView = (ListView) dialog_view.findViewById(R.id.list_view);

        listView.setAdapter(adapter);

        if (adapter.getCount() > VISIBLE_BUSES) {
            View item = adapter.getView(0, null, listView);
            item.measure(0, 0);
            LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
                    LinearLayout.LayoutParams.MATCH_PARENT,
                    (int) ((VISIBLE_BUSES + 0.5) * item.getMeasuredHeight()));
            listView.setLayoutParams(params);
        }

    }

    Button otherAcceptButton = (Button) dialog_view.findViewById(R.id.accept);
    otherAcceptButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            EditText serviceEditText = (EditText) dialog_view.findViewById(R.id.service_edit_text);
            EditText licensePlateEditText = (EditText) dialog_view.findViewById(R.id.license_plate_edit_text);
            String service = serviceEditText.getText().toString();
            String licensePlate = licensePlateEditText.getText().toString();
            ServiceHelper helper = new ServiceHelper(getContext());

            if (ServiceValidator.validate(service) && helper.getColorId(Util.formatServiceName(service)) != 0) {
                service = Util.formatServiceName(service);
                if (licensePlate.equals("")) {
                    licensePlate = Constants.DUMMY_LICENSE_PLATE;
                } else if (!LicensePlateValidator.validate(licensePlate)) {
                    Toast.makeText(getContext(), R.string.bus_selection_warning_plate, Toast.LENGTH_SHORT)
                            .show();
                    return;
                }
            } else {
                Toast.makeText(getContext(), R.string.bus_selection_warning_service, Toast.LENGTH_SHORT).show();
                return;
            }

            final Bus bus = new Bus(Util.formatServiceName(service), licensePlate);
            InputMethodManager imm = (InputMethodManager) getContext()
                    .getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(v.getWindowToken(), 0);

            Log.d("BusSelectionDialog", "hiding soft input");

            Timer timer = new Timer();
            timer.schedule(new TimerTask() {
                @Override
                public void run() {
                    BusSelectionDialog.this.getActivity().runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            dialog.cancel();
                            listener.onPositiveClick(bus);
                        }
                    });
                }
            }, 500);
            //dialog.cancel();
            // TODO(aantoine): This call is to quick, some times the keyboard is not
            // out of the window when de sliding panel shows up.
            //listener.onPositiveClick(bus);
        }
    });

    /* set cancel button to close dialog */
    dialog_view.findViewById(R.id.close_dialog).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            dialog.cancel();
            listener.onNegativeClick();
        }
    });
    ((Button) dialog_view.findViewById(R.id.close_dialog)).setTypeface(iconTypeface);
    dialog.setCanceledOnTouchOutside(false);

    return dialog;
}

From source file:com.module.candychat.net.view.custom.CaseInsensitiveAssetFontLoader.java

@Override
public Typeface getTypeFace(String typefaceName) {
    String lowerTypefaceName = typefaceName.toLowerCase();
    Typeface typeface = sTypefaceCache.get(lowerTypefaceName);

    if (typeface == null) {
        String fontFile = mTypefacenameMapping.get(lowerTypefaceName);

        try {//from  www  .j  a va  2  s  . c  om
            typeface = Typeface.createFromAsset(mAssetManager, fontFile);
            sTypefaceCache.put(lowerTypefaceName, typeface);
        } catch (RuntimeException e) {
            return Typeface.DEFAULT;
        }
    }
    return typeface;
}

From source file:com.hqas.ridetracker.RideTrackerFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_main, container, false);

    if (res == null) {
        res = getActivity().getResources();
    }/*from   w w w.j ava 2  s . c o  m*/

    pebbleStatus = (TextView) rootView.findViewById(R.id.pebble_connection_status);
    Typeface iconFont = Typeface.createFromAsset(res.getAssets(), "fonts/Android-Dev-Icons-1.ttf");
    pebbleStatus.setTypeface(iconFont);

    MapFragment mapFrag = (MapFragment) getFragmentManager().findFragmentById(R.id.map_container);
    map = mapFrag.getMap();
    if (map != null) {
        map.setMyLocationEnabled(true);
        map.getUiSettings().setZoomControlsEnabled(false);
        map.getUiSettings().setZoomGesturesEnabled(false);
    }

    startStop = (Button) rootView.findViewById(R.id.startStopButton);

    startStop.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (tService.getStarted()) {
                stopTracker();
            } else {
                startTracker();
            }
        }
    });

    clear = (Button) rootView.findViewById(R.id.clearButton);
    clear.setEnabled(false);
    clear.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            tService.resetPebbleData(getActivity().getApplicationContext());
        }
    });

    rootView.findViewById(R.id.shareButton).setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {

        }
    });

    return rootView;
}