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:org.opensmc.mytracks.cyclesmc.MainInput.java

/** Called when the activity is first created. */
@Override// ww w . ja  va 2s .c  om
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Firebase.setAndroidContext(this);

    final Firebase ref = new Firebase("https://org.opensmc.mytracks.cyclesmc.firebaseio.com");
    final Firebase phlref = new Firebase("https://phl.firebaseio.com");
    // Let's handle some launcher lifecycle issues:
    // If we're recording or saving right now, jump to the existing activity.
    // (This handles user who hit BACK button while recording)
    setContentView(R.layout.main);
    weatherFont = Typeface.createFromAsset(getAssets(), "cyclesmc.ttf");

    weatherText = (TextView) findViewById(R.id.weatherView);
    weatherText.setTypeface(weatherFont);
    weatherText.setText(R.string.cloudy);

    Intent rService = new Intent(this, RecordingService.class);
    ServiceConnection sc = new ServiceConnection() {
        public void onServiceDisconnected(ComponentName name) {
        }

        public void onServiceConnected(ComponentName name, IBinder service) {
            IRecordService rs = (IRecordService) service;
            int state = rs.getState();
            if (state > RecordingService.STATE_IDLE) {
                if (state == RecordingService.STATE_FULL) {
                    startActivity(new Intent(MainInput.this, SaveTrip.class));
                } else { // RECORDING OR PAUSED:
                    startActivity(new Intent(MainInput.this, RecordingActivity.class));
                }
                MainInput.this.finish();
            } else {
                // Idle. First run? Switch to user prefs screen if there are no prefs stored yet
                SharedPreferences settings = getSharedPreferences("PREFS", 0);
                String anon = settings.getString("" + PREF_ANONID, "NADA");

                if (settings.getAll().isEmpty()) {
                    showWelcomeDialog();
                } else if (anon == "NADA") {
                    showWelcomeDialog();
                }
                // Not first run - set up the list view of saved trips
                ListView listSavedTrips = (ListView) findViewById(R.id.ListSavedTrips);
                populateList(listSavedTrips);
            }
            MainInput.this.unbindService(this); // race?  this says we no longer care
        }
    };
    // This needs to block until the onServiceConnected (above) completes.
    // Thus, we can check the recording status before continuing on.
    bindService(rService, sc, Context.BIND_AUTO_CREATE);

    // And set up the record button
    final Button startButton = (Button) findViewById(R.id.ButtonStart);
    final Intent i = new Intent(this, RecordingActivity.class);
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd", Locale.US);
    SharedPreferences settings = getSharedPreferences("PREFS", 0);
    final String anon = settings.getString("" + PREF_ANONID, "NADA");

    Firebase weatherRef = new Firebase("https://publicdata-weather.firebaseio.com/philadelphia");
    Firebase tempRef = new Firebase("https://publicdata-weather.firebaseio.com/philadelphia/currently");

    tempRef.addValueEventListener(new ValueEventListener() {
        @Override
        public void onDataChange(DataSnapshot dataSnapshot) {
            Object val = dataSnapshot.getValue();
            String cardinal = null;

            TextView tempState = (TextView) findViewById(R.id.temperatureView);
            //                TextView liveTemp = (TextView) findViewById(R.id.warning);
            String apparentTemp = ((Map) val).get("apparentTemperature").toString();
            String windSpeed = ((Map) val).get("windSpeed").toString();
            Double windValue = (Double) ((Map) val).get("windSpeed");
            Long windBearing = (Long) ((Map) val).get("windBearing");

            //                liveTemp.setText(" "+apparentTemp.toString()+DEGREE);
            WindDirection[] windDirections = WindDirection.values();
            for (int i = 0; i < windDirections.length; i++) {
                if (windDirections[i].startDegree < windBearing && windDirections[i].endDegree > windBearing) {
                    //Get Cardinal direction
                    cardinal = windDirections[i].cardinal;
                }
            }

            if (windValue > 4) {
                tempState.setTextColor(0xFFDC143C);
                tempState.setText("winds " + cardinal + " at " + windSpeed + " mph. Ride with caution.");
            } else {
                tempState.setTextColor(0xFFFFFFFF);
                tempState.setText("winds " + cardinal + " at " + windSpeed + " mph.");
            }

        }

        @Override
        public void onCancelled(FirebaseError firebaseError) {

        }
    });

    connectedListener = ref.getRoot().child(".info/connected").addValueEventListener(new ValueEventListener() {
        @Override
        public void onDataChange(DataSnapshot dataSnapshot) {
            boolean connected = (Boolean) dataSnapshot.getValue();
            if (connected) {
                System.out.println("connected " + dataSnapshot.toString());
                //                    Firebase cycleRef = new Firebase(FIREBASE_REF+"/"+anon+"/connections");
                //                    cycleRef.setValue(Boolean.TRUE);
                //                    cycleRef.onDisconnect().removeValue();
            } else {
                System.out.println("disconnected");
            }
        }

        @Override
        public void onCancelled(FirebaseError error) {
            // No-op
        }
    });
    weatherRef.addValueEventListener(new ValueEventListener() {
        @Override
        public void onDataChange(DataSnapshot snapshot) {
            Object value = snapshot.getValue();
            Object hourly = ((Map) value).get("currently");
            String alert = ((Map) hourly).get("summary").toString();
            //                TextView weatherAlert = (TextView) findViewById(R.id.weatherAlert);
            //                weatherAlert.setText(alert);
        }

        @Override
        public void onCancelled(FirebaseError firebaseError) {

        }
    });

    // Acquire a reference to the system Location Manager
    // Define a listener that responds to location updates
    LocationListener locationListener = new LocationListener() {
        public void onLocationChanged(Location location) {
            // Called when a new location is found by the network location provider.

            mySpot = new LatLng(location.getLatitude(), location.getLongitude());
            makeUseOfNewLocation(location);
        }

        public void onStatusChanged(String provider, int status, Bundle extras) {
        }

        public void onProviderEnabled(String provider) {
        }

        public void onProviderDisabled(String provider) {
        }
    };

    //nearbyStations = (RecyclerView) findViewById(R.id.nearbyStationList);
    //nearbyStations.setLayoutManager(new LinearLayoutManager(getApplicationContext()));
    //Listener for Indego Changes
    /*indegoRef = new Firebase("https://phl.firebaseio.com/indego/kiosks");
    indegoRef.addValueEventListener(new ValueEventListener() {
    @Override
    public void onDataChange(DataSnapshot dataSnapshot) {
        //Updates! Add them to indego data list
        indegoDataList = dataSnapshot;
            
            
    }
            
    @Override
    public void onCancelled(FirebaseError firebaseError) {
            
    }
    });*/

    // Register the listener with the Location Manager to receive location updates

    //indegoGeofireRef = new Firebase("https://phl.firebaseio.com/indego/_geofire");
    //GeoFire geoFire = new GeoFire(indegoGeofireRef);
    locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
    locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, locationListener);
    mySpot = myCurrentLocation();
    //indegoList = new ArrayList<IndegoStation>();
    System.out.println("lo: " + mySpot.toString());

    /* GeoQuery geoQuery = geoFire.queryAtLocation(new GeoLocation(mySpot.latitude,mySpot.longitude), 0.5);
     geoQuery.addGeoQueryEventListener(new GeoQueryEventListener() {
    @Override
    public void onKeyEntered(String key, GeoLocation location) {
        System.out.println(String.format("Key %s entered the search area at [%f,%f]", key, location.latitude, location.longitude));
        //Create Indego Station object. To-do: check if object exists
       // IndegoStation station = new IndegoStation();
        //station.kioskId = key;
        //station.location = location;
       /* if(indegoDataList != null){
            //get latest info from list
            station.name = (String) indegoDataList.child(key).child("properties").child("name").getValue();
        }
        System.out.println(station.name);
        //indegoList.add(station);
        //To-do: Add indego station info to RideIndegoAdapter
            
    }
            
    @Override
    public void onKeyExited(String key) {
            
    }
            
    @Override
    public void onKeyMoved(String key, GeoLocation location) {
            
    }
            
    @Override
        /* public void onGeoQueryReady() {
        //System.out.println("GEO READY :"+indegoList.toString());
       // indegoAdapter = new RideIndegoAdapter(getApplicationContext(),indegoList);
        //nearbyStations.setAdapter(indegoAdapter);
            
            
    }
            
    @Override
    public void onGeoQueryError(FirebaseError error) {
        System.out.println("GEO error");
    }
     });*/

    startButton.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            // Before we go to record, check GPS status
            final LocationManager manager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
            if (!manager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
                buildAlertMessageNoGps();
            } else {
                startActivity(i);
                MainInput.this.finish();
            }
        }
    });

    toolbar = (Toolbar) findViewById(R.id.dashboard_bar);
    toolbar.setTitle(getString(R.string.app_name));

    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayShowTitleEnabled(true);
}

From source file:com.chalmers.feedlr.activity.FeedActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main_view_flipper);

    // get helpers from android system
    res = getResources();//from   www .  j a v a2 s  .c  o m
    lbm = LocalBroadcastManager.getInstance(this);
    inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    // add intent filter to be used by broadcast reciever
    intentFilter = new IntentFilter();
    intentFilter.addAction(TWITTER_USERS_UPDATED);
    intentFilter.addAction(TWITTER_USERS_PROBLEM_UPDATING);
    intentFilter.addAction(FACEBOOK_TIMELINE_UPDATED);
    intentFilter.addAction(FACEBOOK_USERS_UPDATED);
    intentFilter.addAction(FACEBOOK_USERS_PROBLEM_UPDATING);
    intentFilter.addAction(FACEBOOK_USER_NEWS_UPDATED);
    intentFilter.addAction(FEED_PROBLEM_UPDATING);

    // instanciate database helper
    db = new DatabaseHelper(this);

    // load typefaces from assets
    Typeface robotoMedium = Typeface.createFromAsset(getAssets(), "fonts/Roboto-Medium.ttf");

    // find views inflated from xml
    mainViewFlipper = (ViewFlipper) findViewById(R.id.main_view_flipper);
    feedViewSwiper = (ViewPager) findViewById(R.id.feed_view_pager);
    settingsViewFlipper = (ViewAnimator) findViewById(R.id.settings_view_flipper);

    facebookAuthButton = (Button) findViewById(R.id.button_facebook);
    twitterAuthButton = (Button) findViewById(R.id.button_twitter);
    Button cfb = (Button) findViewById(R.id.button_create_feed);
    Button s = (Button) findViewById(R.id.button_settings);
    settingsViewFlipper.getBackground().setDither(true);

    feedTitleTextView = (TextView) findViewById(R.id.feed_action_bar_title);

    // Set typefaces manually since Android can't handle custom typefaces in
    // xml in any way whatsoever. Shame on them.
    twitterAuthButton.setTypeface(robotoMedium);
    facebookAuthButton.setTypeface(robotoMedium);

    feedTitleTextView = (TextView) findViewById(R.id.feed_action_bar_title);

    cfb.setTypeface(robotoMedium);
    s.setTypeface(robotoMedium);

    feedTitleTextView.setTypeface(robotoMedium);

    // set adapters
    feedAdapter = new PageAdapter(getSupportFragmentManager(), db, this);
    feedViewSwiper.setAdapter(feedAdapter);

    // lets 3 feedsviews to each side of the current one be retained in an
    // idle state.
    feedViewSwiper.setOffscreenPageLimit(3);

    CirclePageIndicator circleIndicator = (CirclePageIndicator) findViewById(R.id.indicator);
    circleIndicator.setViewPager(feedViewSwiper);
    circleIndicator.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
        @Override
        public void onPageSelected(int feedIndex) {
            String feedTitle = feedAdapter.getFeedTitle(feedIndex);
            feedTitleTextView.setText(feedTitle);
        }

        @Override
        public void onPageScrolled(int arg0, float arg1, int arg2) {
            // TODO Auto-generated method stub'
        }

        @Override
        public void onPageScrollStateChanged(int arg0) {
            // TODO Auto-generated method stub
        }
    });

    // instanciate client and service helpers
    clientHandler = new ClientHandler(this);
    feedService = new DataServiceHelper(this);
    feedService.startService();

    // load animations from res/anim
    slideOutLeft = AnimationUtils.loadAnimation(this, R.anim.slide_out_left);
    slideOutRight = AnimationUtils.loadAnimation(this, R.anim.slide_out_right);
    slideInLeft = AnimationUtils.loadAnimation(this, R.anim.slide_in_left);
    slideInRight = AnimationUtils.loadAnimation(this, R.anim.slide_in_right);

    // Display name correct
    if (feedAdapter.getCount() > 0) {
        String feedTitle = feedAdapter.getFeedTitle(0);
        feedTitleTextView.setText(feedTitle);
    }

    // misc
    settingsViewFlipper.setInAnimation(slideInRight);
    settingsViewFlipper.setOutAnimation(slideOutLeft);

    updateOverlay();
}

From source file:com.fsa.en.dron.activity.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    RateThisApp.Config config = new RateThisApp.Config(5, 10);
    config.setTitle(R.string.my_own_title);
    config.setMessage(R.string.my_own_message);
    config.setYesButtonText(R.string.my_own_rate);
    config.setNoButtonText(R.string.my_own_thanks);
    config.setCancelButtonText(R.string.my_own_cancel);
    RateThisApp.init(config);/* w  w w  .j a  va2 s . c  om*/
    RateThisApp.setCallback(new RateThisApp.Callback() {
        @Override
        public void onYesClicked() {
            final String appPackageName = getPackageName(); // getPackageName() from Context or Activity  object
            try {
                startActivity(
                        new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + appPackageName)));
            } catch (android.content.ActivityNotFoundException anfe) {
                startActivity(new Intent(Intent.ACTION_VIEW,
                        Uri.parse("http://play.google.com/store/apps/details?id=" + appPackageName)));
            }
        }

        @Override
        public void onNoClicked() {
            TastyToast.makeText(getApplicationContext(), "Vuelve pronto!", TastyToast.LENGTH_LONG,
                    TastyToast.INFO);
        }

        @Override
        public void onCancelClicked() {
            TastyToast.makeText(getApplicationContext(), "Prometo tomar mejores fotografias!",
                    TastyToast.LENGTH_LONG, TastyToast.ERROR);
        }
    });
    button = (Button) findViewById(R.id.button);
    button.setVisibility(View.INVISIBLE);
    button.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            checkConnection();
        }
    });
    BottomNavigationBar bottomNavigationBar = (BottomNavigationBar) findViewById(R.id.bottom_navigation_bar);
    bottomNavigationBar.setBackgroundStyle(BottomNavigationBar.BACKGROUND_STYLE_RIPPLE);
    bottomNavigationBar.setMode(BottomNavigationBar.MODE_FIXED);
    bottomNavigationBar.setBackgroundStyle(BottomNavigationBar.BACKGROUND_STYLE_STATIC);
    bottomNavigationBar.setBarBackgroundColor(R.color.material_light_blue_800);
    bottomNavigationBar.setActiveColor(R.color.material_grey_900);
    bottomNavigationBar.setInActiveColor(R.color.material_blue_grey_200);
    bottomNavigationBar.addItem(new BottomNavigationItem(R.drawable.compose, "Mensaje"))
            .addItem(new BottomNavigationItem(R.drawable.sociales, "Sociales"))
            .addItem(new BottomNavigationItem(R.drawable.share, "Cuntale a un amigo")).initialise();
    bottomNavigationBar.setTabSelectedListener(new BottomNavigationBar.OnTabSelectedListener() {
        @Override
        public void onTabSelected(int position) {
            switch (position) {
            case 0:
                Intent email = new Intent(Intent.ACTION_SEND);
                email.putExtra(Intent.EXTRA_EMAIL, new String[] { "marceloespinoza00@gmail.com" });
                email.putExtra(Intent.EXTRA_SUBJECT, "Formosa en dron");
                email.putExtra(Intent.EXTRA_TEXT, "Dej tu mensaje");
                email.setType("message/rfc822");
                startActivity(Intent.createChooser(email, "Elige un cliente :"));
                break;
            case 1:
                Intent intent = new Intent(getApplication(), FacebookActivity.class);
                startActivity(intent);
                break;
            case 2:

                Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
                sharingIntent.setType("text/plain");
                sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Formosa en dron");
                sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT,
                        "https://play.google.com/store/apps/details?id=com.fsa.en.dron");
                startActivity(Intent.createChooser(sharingIntent, "Compartir via"));
                break;

            }

        }

        @Override
        public void onTabUnselected(int position) {

        }

        @Override
        public void onTabReselected(int position) {
            switch (position) {
            case 0:

                break;
            case 1:
                Intent intent = new Intent(getApplication(), FacebookActivity.class);
                startActivity(intent);
                break;
            case 2:

                break;

            }
        }
    });
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    LayoutInflater inflator = LayoutInflater.from(this);
    View v = inflator.inflate(R.layout.toolbar_title, null);
    Typeface budget = Typeface.createFromAsset(getAssets(), "fonts/Budget.otf");
    Typeface typographica = Typeface.createFromAsset(getAssets(), "fonts/TypoGraphica.otf");
    TextView mToolbarCustomTitle = (TextView) v.findViewById(R.id.title);
    TextView mToolbarCustomSubTitle = (TextView) v.findViewById(R.id.subtitle);
    mToolbarCustomTitle.setText("Formosa");
    mToolbarCustomSubTitle.setText("en dron");
    mToolbarCustomTitle.setTypeface(typographica);
    mToolbarCustomSubTitle.setTypeface(budget);
    getSupportActionBar().setCustomView(v);
    getSupportActionBar().setDisplayShowTitleEnabled(false);
    getSupportActionBar().setDisplayShowCustomEnabled(true);
    toolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {
            int id = item.getItemId();
            if (id == R.id.recargar) {
                checkConnection();
            }
            if (id == R.id.info) {
                showDialog();
            }
            return false;
        }
    });
    recyclerView = (RecyclerView) findViewById(R.id.recycler_view);
    recyclerView.addOnItemTouchListener(new GalleryAdapter.RecyclerTouchListener(getApplicationContext(),
            recyclerView, new GalleryAdapter.ClickListener() {
                @Override
                public void onClick(View view, int position) {
                    Bundle bundle = new Bundle();
                    bundle.putSerializable("images", images);
                    bundle.putInt("position", position);

                    FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
                    SlideshowDialogFragment newFragment = SlideshowDialogFragment.newInstance();
                    newFragment.setArguments(bundle);
                    newFragment.show(ft, "slideshow");
                }

                @Override
                public void onLongClick(View view, int position) {

                }
            }));
    pDialog = new ProgressDialog(this);
    images = new ArrayList<>();
    mAdapter = new GalleryAdapter(getApplicationContext(), images);
    RecyclerView.LayoutManager mLayoutManager = new GridLayoutManager(getApplicationContext(), 2);
    recyclerView.setLayoutManager(mLayoutManager);
    recyclerView.setItemAnimator(new DefaultItemAnimator());
    recyclerView.setAdapter(mAdapter);

}

From source file:com.mixiaoxiao.android.view.MxxPagerSlidingTabStrip.java

public MxxPagerSlidingTabStrip(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    setFillViewport(true);/*from w ww  .  j  av  a2 s  . c om*/
    setWillNotDraw(false);

    tabsContainer = new LinearLayout(context);
    tabsContainer.setOrientation(LinearLayout.HORIZONTAL);
    tabsContainer.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
    addView(tabsContainer);

    DisplayMetrics dm = getResources().getDisplayMetrics();

    scrollOffset = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, scrollOffset, dm);
    indicatorHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, indicatorHeight, dm);
    underlineHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, underlineHeight, dm);
    dividerPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dividerPadding, dm);
    tabPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, tabPadding, dm);
    dividerWidth = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dividerWidth, dm);
    tabTextSize = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, tabTextSize, dm);

    // get system attrs (android:textSize and android:textColor)

    TypedArray a = context.obtainStyledAttributes(attrs, ATTRS);

    tabTextSize = a.getDimensionPixelSize(0, tabTextSize);
    tabTextColor = a.getColor(1, tabTextColor);

    a.recycle();

    // get custom attrs

    //      a = context.obtainStyledAttributes(attrs, R.styleable.PagerSlidingTabStrip);
    //
    //      indicatorColor = a.getColor(R.styleable.PagerSlidingTabStrip_indicatorColor, indicatorColor);
    //      underlineColor = a.getColor(R.styleable.PagerSlidingTabStrip_underlineColor, underlineColor);
    //      dividerColor = a.getColor(R.styleable.PagerSlidingTabStrip_dividerColor, dividerColor);
    //      indicatorHeight = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_indicatorHeight, indicatorHeight);
    //      underlineHeight = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_underlineHeight, underlineHeight);
    //      dividerPadding = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_dividerPadding, dividerPadding);
    //      tabPadding = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_tabPaddingLeftRight, tabPadding);
    //      tabBackgroundResId = a.getResourceId(R.styleable.PagerSlidingTabStrip_tabBackground, tabBackgroundResId);
    //      shouldExpand = a.getBoolean(R.styleable.PagerSlidingTabStrip_shouldExpand, shouldExpand);
    //      scrollOffset = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_scrollOffset, scrollOffset);
    //      textAllCaps = a.getBoolean(R.styleable.PagerSlidingTabStrip_textAllCaps, textAllCaps);
    //
    //      a.recycle();

    rectPaint = new Paint();
    rectPaint.setAntiAlias(true);
    rectPaint.setStyle(Style.FILL);

    dividerPaint = new Paint();
    dividerPaint.setAntiAlias(true);
    dividerPaint.setStrokeWidth(dividerWidth);

    defaultTabLayoutParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
            LayoutParams.MATCH_PARENT);
    expandedTabLayoutParams = new LinearLayout.LayoutParams(0, LayoutParams.MATCH_PARENT, 1.0f);

    if (locale == null) {
        locale = getResources().getConfiguration().locale;
    }
    String font = "Roboto-Light.ttf";
    this.tabTypeface = Typeface.createFromAsset(getContext().getAssets(), font);
}

From source file:com.moonpi.tapunlock.MainActivity.java

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

    // Get lobster_two asset and create typeface
    // Set action bar title to lobster_two typeface
    lobsterTwo = Typeface.createFromAsset(getAssets(), "lobster_two.otf");

    int actionBarTitle = Resources.getSystem().getIdentifier("action_bar_title", "id", "android");
    actionBarTitleView = (TextView) getWindow().findViewById(actionBarTitle);

    if (actionBarTitleView != null) {
        actionBarTitleView.setTypeface(lobsterTwo);
        actionBarTitleView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 28f);
        actionBarTitleView.setTextColor(getResources().getColor(R.color.blue));
    }/*from ww w.  j  a va2 s .  c  o m*/

    setContentView(R.layout.activity_main);

    // Hide keyboard on app launch
    this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
    imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);

    // Get NFC service and adapter
    NfcManager nfcManager = (NfcManager) this.getSystemService(Context.NFC_SERVICE);
    nfcAdapter = nfcManager.getDefaultAdapter();

    // Create PendingIntent for enableForegroundDispatch for NFC tag discovery
    pIntent = PendingIntent.getActivity(this, 0,
            new Intent(this, getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0);

    readFromJSON();
    writeToJSON();
    readFromJSON();

    // If Android 4.2 or bigger
    if (Build.VERSION.SDK_INT > 16) {
        // Check if TapUnlock folder exists, if not, create directory
        File folder = new File(Environment.getExternalStorageDirectory() + "/TapUnlock");
        boolean folderSuccess = true;

        if (!folder.exists()) {
            folderSuccess = folder.mkdir();
        }

        try {
            // If blur var bigger than 0
            if (settings.getInt("blur") > 0) {
                // If folder exists or successfully created
                if (folderSuccess) {
                    // If blurred wallpaper file doesn't exist
                    if (!ImageUtils.doesBlurredWallpaperExist()) {
                        // Get default wallpaper
                        WallpaperManager wallpaperManager = WallpaperManager.getInstance(this);
                        final Drawable wallpaperDrawable = wallpaperManager.peekFastDrawable();

                        if (wallpaperDrawable != null) {
                            // Default wallpaper to bitmap - fastBlur the bitmap - store bitmap
                            new Thread(new Runnable() {
                                @Override
                                public void run() {
                                    Bitmap bitmapToBlur = ImageUtils.drawableToBitmap(wallpaperDrawable);

                                    Bitmap blurredWallpaper = null;
                                    if (bitmapToBlur != null)
                                        blurredWallpaper = ImageUtils.fastBlur(MainActivity.this, bitmapToBlur,
                                                blur);

                                    if (blurredWallpaper != null) {
                                        ImageUtils.storeImage(blurredWallpaper);
                                    }
                                }
                            }).start();
                        }
                    }
                }
            }

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

    // Initialize layout items
    pinEdit = (EditText) findViewById(R.id.pinEdit);
    pinEdit.setImeOptions(EditorInfo.IME_ACTION_DONE);
    Button setPin = (Button) findViewById(R.id.setPin);
    ImageButton newTag = (ImageButton) findViewById(R.id.newTag);
    enabled_disabled = (TextView) findViewById(R.id.enabled_disabled);
    Switch toggle = (Switch) findViewById(R.id.toggle);
    seekBar = (SeekBar) findViewById(R.id.seekBar);
    progressBar = (ProgressBar) findViewById(R.id.progressBar);
    Button refreshWallpaper = (Button) findViewById(R.id.refreshWallpaper);
    listView = (ListView) findViewById(R.id.listView);
    backgroundBlurValue = (TextView) findViewById(R.id.backgroundBlurValue);
    noTags = (TextView) findViewById(R.id.noTags);

    // Initialize TagAdapter
    adapter = new TagAdapter(this, tags);

    registerForContextMenu(listView);

    // Set listView adapter to TapAdapter object
    listView.setAdapter(adapter);

    // Set click, check and seekBar listeners
    setPin.setOnClickListener(this);
    newTag.setOnClickListener(this);
    refreshWallpaper.setOnClickListener(this);
    toggle.setOnCheckedChangeListener(this);
    seekBar.setOnSeekBarChangeListener(this);

    // Set seekBar progress to blur var
    try {
        seekBar.setProgress(settings.getInt("blur"));

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

    // Refresh the listView height
    updateListViewHeight(listView);

    // If no tags, show 'Press + to add Tags' textView
    if (tags.length() == 0)
        noTags.setVisibility(View.VISIBLE);

    else
        noTags.setVisibility(View.INVISIBLE);

    // Scroll up
    scrollView = (ScrollView) findViewById(R.id.scrollView);

    scrollView.post(new Runnable() {
        public void run() {
            scrollView.scrollTo(0, scrollView.getTop());
            scrollView.fullScroll(View.FOCUS_UP);
        }
    });

    // If lockscreen enabled, initialize switch, text and start service
    try {
        if (settings.getBoolean("lockscreen")) {
            onStart = true;
            enabled_disabled.setText(R.string.lockscreen_enabled);
            enabled_disabled.setTextColor(getResources().getColor(R.color.green));

            toggle.setChecked(true);
        }

    } catch (JSONException e1) {
        e1.printStackTrace();
    }
}

From source file:com.brandao.tictactoe.gamesettings.GameSettingsFragment.java

public void setTheme(View v) {
    Typeface titleFont = Typeface.createFromAsset(getActivity().getAssets(), "fonts/DroidSans-Bold.ttf");

    if (((TextView) v.findViewById(R.id.tic)) != null) {
        ((TextView) v.findViewById(R.id.tic)).setTypeface(titleFont);
        ((TextView) v.findViewById(R.id.tac)).setTypeface(titleFont);
        ((TextView) v.findViewById(R.id.toe)).setTypeface(titleFont);
    }// w w w  .  ja  v a 2s .  c om

    ((RadioButton) v.findViewById(R.id.set_difficulty_easy)).setTypeface(titleFont);
    ((RadioButton) v.findViewById(R.id.set_difficulty_medium)).setTypeface(titleFont);
    ((RadioButton) v.findViewById(R.id.set_difficulty_hard)).setTypeface(titleFont);

    ((TextView) v.findViewById(R.id.player_one_prompt)).setTypeface(titleFont);
    ((TextView) v.findViewById(R.id.player_two_prompt)).setTypeface(titleFont);
    ((TextView) v.findViewById(R.id.player_title)).setTypeface(titleFont);
    ((TextView) v.findViewById(R.id.who_goes_first_title)).setTypeface(titleFont);

    ((ImageView) v.findViewById(R.id.player_one_image)).setBackgroundResource(R.drawable.ic_green_x_android);
    ((ImageView) v.findViewById(R.id.player_two_image)).setBackgroundResource(R.drawable.ic_red_o_android);

    ((RadioButton) v.findViewById(R.id.set_o_first)).setBackgroundResource(R.drawable.red_o_android_selector);
    ((RadioButton) v.findViewById(R.id.set_x_first)).setBackgroundResource(R.drawable.green_x_android_selector);
    ((RadioButton) v.findViewById(R.id.set_x_o_random)).setBackgroundResource(R.drawable.xo_selector);

    ((RadioButton) v.findViewById(R.id.set_o_first)).setButtonDrawable(R.drawable.transparent_image);
    ((RadioButton) v.findViewById(R.id.set_x_first)).setButtonDrawable(R.drawable.transparent_image);
    ((RadioButton) v.findViewById(R.id.set_x_o_random)).setButtonDrawable(R.drawable.transparent_image);

    mPlayerOneNameInput.setTypeface(titleFont);
    mPlayerTwoNameInput.setTypeface(titleFont);
    mDifficultyTitleDisplay.setTypeface(titleFont);

    ((TextView) v.findViewById(R.id.start_tic_tac_toe)).setTypeface(titleFont);
    ((TextView) v.findViewById(R.id.back_button)).setTypeface(titleFont);
}

From source file:com.eugene.fithealthmaingit.MainActivity.java

private void applyFontToMenuItem(MenuItem mi) {
    Typeface font = Typeface.createFromAsset(getAssets(), "fonts/Roboto-Regular.ttf");
    SpannableString mNewTitle = new SpannableString(mi.getTitle());
    mNewTitle.setSpan(new CustomTypefaceSpan("", font), 0, mNewTitle.length(),
            Spannable.SPAN_INCLUSIVE_INCLUSIVE);
    mi.setTitle(mNewTitle);//from w w w.  j  a  v a  2 s .c o m
}

From source file:bottombar.BottomBar.java

private Typeface getTypeFaceFromAsset(String fontPath) {
    if (fontPath != null) {
        return Typeface.createFromAsset(getContext().getAssets(), fontPath);
    }//w w w  .j a va  2  s.co  m

    return null;
}

From source file:com.cs528.style.style.weather.WeatherActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    // Initialize the associated SharedPreferences file with default values
    PreferenceManager.setDefaultValues(this, R.xml.prefs, false);

    darkTheme = false;/*from w w w.j  av  a  2 s .  c  om*/
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
    if (prefs.getBoolean("darkTheme", false)) {
        setTheme(R.style.AppTheme_NoActionBar_Dark);
        darkTheme = true;
    }

    // Initiate activity
    super.onCreate(savedInstanceState);
    //setContentView(R.layout.activity_scrolling);
    appView = findViewById(R.id.viewApp);
    getLayoutInflater().inflate(R.layout.activity_scrolling, frameLayout);

    progressDialog = new ProgressDialog(WeatherActivity.this);

    // Load toolbar
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    if (darkTheme) {
        toolbar.setPopupTheme(R.style.AppTheme_PopupOverlay_Dark);
    }

    // Initialize textboxes
    todayTemperature = (TextView) findViewById(R.id.todayTemperature);
    todayDescription = (TextView) findViewById(R.id.todayDescription);
    todayWind = (TextView) findViewById(R.id.todayWind);
    todayPressure = (TextView) findViewById(R.id.todayPressure);
    todayHumidity = (TextView) findViewById(R.id.todayHumidity);
    //        todayIcon = (TextView) findViewById(R.id.todayIcon);
    topIcon = (TextView) findViewById(R.id.topIcon);
    bottomIcon = (TextView) findViewById(R.id.bottomIcon);
    hatIcon = (TextView) findViewById(R.id.hatIcon);
    shoeIcon = (TextView) findViewById(R.id.shoeIcon);

    weatherFont = Typeface.createFromAsset(this.getAssets(), "fonts/weather.ttf");
    clothFont = Typeface.createFromAsset(this.getAssets(), "fonts/cloth.ttf");
    //        todayIcon.setTypeface(weatherFont);
    topIcon.setTypeface(clothFont);
    bottomIcon.setTypeface(clothFont);
    shoeIcon.setTypeface(clothFont);
    hatIcon.setTypeface(clothFont);
    topIcon.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            scheduleAndWeatherFilter();
            Intent intent = new Intent(WeatherActivity.this, GalleryActivity.class);
            intent.putExtra("clothes", result.toArray());
            startActivity(intent);
        }
    });

    // Initialize viewPagerg
    viewPager = (ViewPager) findViewById(R.id.viewPager);
    tabLayout = (TabLayout) findViewById(R.id.tabs);

    destroyed = false;

    initMappings();

    // Preload data from cache
    preloadWeather();

    // Set autoupdater
    AlarmReceiver.setRecurringAlarm(this);
}

From source file:ua.mkh.weather.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setContentView(R.layout.activity_main);

    String roman = "fonts/Regular.otf";
    String medium = "fonts/Medium.otf";
    String bold = "fonts/Bold.otf";
    String thin = "fonts/Thin.otf";
    String ultra = "fonts/Ultralight.otf";
    typefaceRoman = Typeface.createFromAsset(getAssets(), roman);
    typefaceMedium = Typeface.createFromAsset(getAssets(), medium);
    typefaceBold = Typeface.createFromAsset(getAssets(), bold);
    typefaceThin = Typeface.createFromAsset(getAssets(), thin);
    typefaceUltra = Typeface.createFromAsset(getAssets(), ultra);

    mSettings = getSharedPreferences(APP_PREFERENCES, Context.MODE_PRIVATE);

    psListener = new myPhoneStateListener();
    telephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
    telephonyManager.listen(psListener, PhoneStateListener.LISTEN_SIGNAL_STRENGTHS);

    //check_int();

    Animation animation = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.cloudy_cloud);

    battery_green = (MyProgressBarGreen) findViewById(R.id.progressBarGreen);
    battery_white = (MyProgressBarWhite) findViewById(R.id.progressBarWhite);
    battery_yellow = (MyProgressBarYellow) findViewById(R.id.progressBarYellow);

    battery_green.setVisibility(View.INVISIBLE);
    battery_white.setVisibility(View.VISIBLE);
    battery_yellow.setVisibility(View.INVISIBLE);

    listView1 = (ListView) findViewById(R.id.listView1);
    listview = (HorizontalListView) findViewById(R.id.listview);

    button2 = (Button) findViewById(R.id.button2);
    button2.setOnClickListener(this);

    prog1 = (ProgressBar) findViewById(R.id.progressBar1);
    button1 = (Button) findViewById(R.id.button1);
    button1.setOnClickListener(this);

    cityText = (TextView) findViewById(R.id.cityText);
    condDescr = (TextView) findViewById(R.id.condDescr);
    temp = (TextView) findViewById(R.id.temp);
    hum = (TextView) findViewById(R.id.hum);
    press = (TextView) findViewById(R.id.press);
    windSpeed = (TextView) findViewById(R.id.windSpeed);
    tempDay = (TextView) findViewById(R.id.textView5);
    tempNight = (TextView) findViewById(R.id.textView6);

    TextView03 = (TextView) findViewById(R.id.TextView03);
    TextView01 = (TextView) findViewById(R.id.TextView01);
    textView1 = (TextView) findViewById(R.id.textView1);
    textView2 = (TextView) findViewById(R.id.textView2);
    textView3 = (TextView) findViewById(R.id.textView3);
    textView7 = (TextView) findViewById(R.id.textView7);
    textView8 = (TextView) findViewById(R.id.textView8);
    textView9 = (TextView) findViewById(R.id.textView9);
    textView10 = (TextView) findViewById(R.id.textView10);
    textView11 = (TextView) findViewById(R.id.textView11);
    textView12 = (TextView) findViewById(R.id.textView12);
    textView14 = (TextView) findViewById(R.id.textView14);
    textView15 = (TextView) findViewById(R.id.textView15);
    //imgView = (ImageView) findViewById(R.id.condIcon);

    img1 = (ImageView) findViewById(R.id.imageView1);

    main = (LinearLayout) findViewById(R.id.mainLayout);
    scrollView1 = (ScrollView) findViewById(R.id.scrollView1);
    scrollView1.setVisibility(View.GONE);
    main.setVisibility(View.GONE);

    //Intent intent = new Intent(this, AllCityActivity.class);
    //startActivity(intent);

    //JSONWeatherTask task = new JSONWeatherTask();
    //task.execute(new String[]{city,lang});

    //JSONForecastWeatherTask task1 = new JSONForecastWeatherTask();
    //task1.execute(new String[]{city,lang, forecastDaysNum});

    //mDbHelper = new CustomersDbAdapter(this);
    //mDbHelper.open();

    //new CopyDataBase().execute();

    //GetBaseWeather task3 = new GetBaseWeather();
    //task3.execute();

    SimpleDateFormat sdf = new SimpleDateFormat("EEEE");
    String currentDateandTime = sdf.format(new Date());

    String upperString = currentDateandTime.substring(0, 1).toUpperCase() + currentDateandTime.substring(1);

    textView1.setText(upperString);// w  ww.  ja  v a2 s.com

    temp.setTypeface(typefaceUltra);
    cityText.setTypeface(typefaceThin);
    condDescr.setTypeface(typefaceThin);
    hum.setTypeface(typefaceRoman);
    press.setTypeface(typefaceRoman);
    windSpeed.setTypeface(typefaceRoman);
    textView1.setTypeface(typefaceRoman);
    textView2.setTypeface(typefaceThin);
    textView3.setTypeface(typefaceRoman);
    textView7.setTypeface(typefaceRoman);
    TextView03.setTypeface(typefaceRoman);
    TextView01.setTypeface(typefaceRoman);
    textView8.setTypeface(typefaceRoman);
    textView9.setTypeface(typefaceRoman);
    textView10.setTypeface(typefaceRoman);
    textView11.setTypeface(typefaceRoman);
    textView12.setTypeface(typefaceRoman);
    textView14.setTypeface(typefaceRoman);
    textView15.setTypeface(typefaceRoman);
    //textView4.setTypeface(typefaceThin);
    tempDay.setTypeface(typefaceRoman);
    tempNight.setTypeface(typefaceThin);

}