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:com.dycody.android.idealnote.BaseActivity.java

protected void setActionBarTitle(String title) {
    // Creating a spannable to support custom fonts on ActionBar
    int actionBarTitle = Resources.getSystem().getIdentifier("action_bar_title", "id", "android");
    android.widget.TextView actionBarTitleView = (android.widget.TextView) getWindow()
            .findViewById(actionBarTitle);
    Typeface font = Typeface.createFromAsset(getAssets(), "fonts/Roboto-Regular.ttf");
    if (actionBarTitleView != null) {
        actionBarTitleView.setTypeface(font);
    }//from   w  w w .ja va 2 s .co m

    if (getSupportActionBar() != null) {
        getSupportActionBar().setTitle(title);
    }
}

From source file:com.appeaser.sublimenavigationviewlibrary.SublimeNavigationView.java

public SublimeNavigationView(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);

    TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.SublimeNavigationView, defStyleAttr,
            R.style.SnvSublimeNavigationView);

    try {//from   w ww.ja va2 s  .co  m
        // Used for creating default resources
        SublimeThemer.DefaultTheme defaultTheme = SublimeThemer.DefaultTheme.LIGHT;

        if (a.hasValue(R.styleable.SublimeNavigationView_snvDefaultTheme)) {
            defaultTheme = a.getInt(R.styleable.SublimeNavigationView_snvDefaultTheme, 0) == 0
                    ? SublimeThemer.DefaultTheme.LIGHT
                    : SublimeThemer.DefaultTheme.DARK;
        }

        mThemer = new SublimeThemer(getContext(), defaultTheme);

        mThemer.setDrawerBackground(a.getDrawable(R.styleable.SublimeNavigationView_android_background));

        if (a.hasValue(R.styleable.SublimeNavigationView_elevation)) {
            mThemer.setElevation(
                    (float) a.getDimensionPixelSize(R.styleable.SublimeNavigationView_elevation, 0));
        }

        ViewCompat.setFitsSystemWindows(this,
                a.getBoolean(R.styleable.SublimeNavigationView_android_fitsSystemWindows, false));
        mMaxWidth = a.getDimensionPixelSize(R.styleable.SublimeNavigationView_android_maxWidth, 0);

        if (a.hasValue(R.styleable.SublimeNavigationView_snvItemIconTint)) {
            mThemer.setIconTintList(a.getColorStateList(R.styleable.SublimeNavigationView_snvItemIconTint));
        }

        mThemer.setGroupExpandDrawable(a.getDrawable(R.styleable.SublimeNavigationView_snvGroupExpandDrawable));

        mThemer.setGroupCollapseDrawable(
                a.getDrawable(R.styleable.SublimeNavigationView_snvGroupCollapseDrawable));

        // Text style profiles for Item, Hint, SubheaderItem & SubheaderHint
        ColorStateList itemTextColor = null, hintTextColor = null, subheaderItemTextColor = null,
                subheaderHintTextColor = null, badgeTextColor = null;
        Typeface itemTypeface = null, hintTypeface = null, subheaderItemTypeface = null,
                subheaderHintTypeface = null, badgeTypeface = null;
        int itemTypefaceStyle = 0, hintTypefaceStyle = 0, subheaderItemTypefaceStyle = 0,
                subheaderHintTypefaceStyle = 0, badgeTypefaceStyle = 0;

        if (a.hasValue(R.styleable.SublimeNavigationView_snvItemTextColor)) {
            itemTextColor = a.getColorStateList(R.styleable.SublimeNavigationView_snvItemTextColor);
        }

        if (a.hasValue(R.styleable.SublimeNavigationView_snvHintTextColor)) {
            hintTextColor = a.getColorStateList(R.styleable.SublimeNavigationView_snvHintTextColor);
        }

        if (a.hasValue(R.styleable.SublimeNavigationView_snvSubheaderItemTextColor)) {
            subheaderItemTextColor = a
                    .getColorStateList(R.styleable.SublimeNavigationView_snvSubheaderItemTextColor);
        }

        if (a.hasValue(R.styleable.SublimeNavigationView_snvSubheaderHintTextColor)) {
            subheaderHintTextColor = a
                    .getColorStateList(R.styleable.SublimeNavigationView_snvSubheaderHintTextColor);
        }

        if (a.hasValue(R.styleable.SublimeNavigationView_snvBadgeTextColor)) {
            badgeTextColor = a.getColorStateList(R.styleable.SublimeNavigationView_snvBadgeTextColor);
        }

        try { // Catch the RuntimeException thrown if
              // the Typeface filename is incorrect
            if (a.hasValue(R.styleable.SublimeNavigationView_snvItemTypefaceFilename)) {
                String itemTypefaceFilename = a
                        .getString(R.styleable.SublimeNavigationView_snvItemTypefaceFilename);
                if (!TextUtils.isEmpty(itemTypefaceFilename)) {
                    itemTypeface = Typeface.createFromAsset(context.getAssets(), itemTypefaceFilename);
                }
            }

            if (a.hasValue(R.styleable.SublimeNavigationView_snvHintTypefaceFilename)) {
                String hintTypefaceFilename = a
                        .getString(R.styleable.SublimeNavigationView_snvHintTypefaceFilename);
                if (!TextUtils.isEmpty(hintTypefaceFilename)) {
                    hintTypeface = Typeface.createFromAsset(context.getAssets(), hintTypefaceFilename);
                }
            }

            if (a.hasValue(R.styleable.SublimeNavigationView_snvSubheaderItemTypefaceFilename)) {
                String subheaderItemTypefaceFilename = a
                        .getString(R.styleable.SublimeNavigationView_snvSubheaderItemTypefaceFilename);
                if (!TextUtils.isEmpty(subheaderItemTypefaceFilename)) {
                    subheaderItemTypeface = Typeface.createFromAsset(context.getAssets(),
                            subheaderItemTypefaceFilename);
                }
            }

            if (a.hasValue(R.styleable.SublimeNavigationView_snvSubheaderHintTypefaceFilename)) {
                String subheaderHintTypefaceFilename = a
                        .getString(R.styleable.SublimeNavigationView_snvSubheaderHintTypefaceFilename);
                if (!TextUtils.isEmpty(subheaderHintTypefaceFilename)) {
                    subheaderHintTypeface = Typeface.createFromAsset(context.getAssets(),
                            subheaderHintTypefaceFilename);
                }
            }

            if (a.hasValue(R.styleable.SublimeNavigationView_snvBadgeTypefaceFilename)) {
                String badgeTypefaceFilename = a
                        .getString(R.styleable.SublimeNavigationView_snvBadgeTypefaceFilename);
                if (!TextUtils.isEmpty(badgeTypefaceFilename)) {
                    badgeTypeface = Typeface.createFromAsset(context.getAssets(), badgeTypefaceFilename);
                }
            }
        } catch (RuntimeException re) {
            Log.e(TAG,
                    "Error loading Typeface from Assets. " + "Confirm that the Typeface filename is correct:\n"
                            + "    - filename should include the extension\n"
                            + "    - filename is case-sensitive");
        }

        if (a.hasValue(R.styleable.SublimeNavigationView_snvItemTypefaceStyle)) {
            itemTypefaceStyle = a.getInt(R.styleable.SublimeNavigationView_snvItemTypefaceStyle,
                    Typeface.NORMAL);

            switch (itemTypefaceStyle) {
            case 1:
                itemTypefaceStyle = Typeface.BOLD;
                break;
            case 2:
                itemTypefaceStyle = Typeface.ITALIC;
                break;
            case 3:
                itemTypefaceStyle = Typeface.BOLD_ITALIC;
                break;
            default:
                // case 0: NORMAL
                itemTypefaceStyle = Typeface.NORMAL;
                break;
            }
        }

        if (a.hasValue(R.styleable.SublimeNavigationView_snvHintTypefaceStyle)) {
            hintTypefaceStyle = a.getInt(R.styleable.SublimeNavigationView_snvHintTypefaceStyle,
                    Typeface.NORMAL);

            switch (hintTypefaceStyle) {
            case 1:
                hintTypefaceStyle = Typeface.BOLD;
                break;
            case 2:
                hintTypefaceStyle = Typeface.ITALIC;
                break;
            case 3:
                hintTypefaceStyle = Typeface.BOLD_ITALIC;
                break;
            default:
                // case 0: NORMAL
                hintTypefaceStyle = Typeface.NORMAL;
                break;
            }
        }

        if (a.hasValue(R.styleable.SublimeNavigationView_snvSubheaderItemTypefaceStyle)) {
            subheaderItemTypefaceStyle = a
                    .getInt(R.styleable.SublimeNavigationView_snvSubheaderItemTypefaceStyle, Typeface.NORMAL);

            switch (subheaderItemTypefaceStyle) {
            case 1:
                subheaderItemTypefaceStyle = Typeface.BOLD;
                break;
            case 2:
                subheaderItemTypefaceStyle = Typeface.ITALIC;
                break;
            case 3:
                subheaderItemTypefaceStyle = Typeface.BOLD_ITALIC;
                break;
            default:
                // case 0: NORMAL
                subheaderItemTypefaceStyle = Typeface.NORMAL;
                break;
            }
        }

        if (a.hasValue(R.styleable.SublimeNavigationView_snvSubheaderHintTypefaceStyle)) {
            subheaderHintTypefaceStyle = a
                    .getInt(R.styleable.SublimeNavigationView_snvSubheaderHintTypefaceStyle, Typeface.NORMAL);

            switch (subheaderHintTypefaceStyle) {
            case 1:
                subheaderHintTypefaceStyle = Typeface.BOLD;
                break;
            case 2:
                subheaderHintTypefaceStyle = Typeface.ITALIC;
                break;
            case 3:
                subheaderHintTypefaceStyle = Typeface.BOLD_ITALIC;
                break;
            default:
                // case 0: NORMAL
                subheaderHintTypefaceStyle = Typeface.NORMAL;
                break;
            }
        }

        if (a.hasValue(R.styleable.SublimeNavigationView_snvBadgeTypefaceStyle)) {
            badgeTypefaceStyle = a.getInt(R.styleable.SublimeNavigationView_snvBadgeTypefaceStyle,
                    Typeface.NORMAL);

            switch (badgeTypefaceStyle) {
            case 1:
                badgeTypefaceStyle = Typeface.BOLD;
                break;
            case 2:
                badgeTypefaceStyle = Typeface.ITALIC;
                break;
            case 3:
                badgeTypefaceStyle = Typeface.BOLD_ITALIC;
                break;
            default:
                // case 0: NORMAL
                badgeTypefaceStyle = Typeface.NORMAL;
                break;
            }
        }

        // Item text styling
        TextViewStyleProfile itemStyleProfile = new TextViewStyleProfile(context, defaultTheme);
        itemStyleProfile.setTextColor(itemTextColor).setTypeface(itemTypeface)
                .setTypefaceStyle(itemTypefaceStyle);
        mThemer.setItemStyleProfile(itemStyleProfile);

        // Hint text styling
        TextViewStyleProfile hintStyleProfile = new TextViewStyleProfile(context, defaultTheme);
        hintStyleProfile.setTextColor(hintTextColor).setTypeface(hintTypeface)
                .setTypefaceStyle(hintTypefaceStyle);
        mThemer.setItemHintStyleProfile(hintStyleProfile);

        // Sub-header item text styling
        TextViewStyleProfile subheaderItemStyleProfile = new TextViewStyleProfile(context, defaultTheme);
        subheaderItemStyleProfile.setTextColor(subheaderItemTextColor).setTypeface(subheaderItemTypeface)
                .setTypefaceStyle(subheaderItemTypefaceStyle);
        mThemer.setSubheaderStyleProfile(subheaderItemStyleProfile);

        // Sub-header hint text styling
        TextViewStyleProfile subheaderHintStyleProfile = new TextViewStyleProfile(context, defaultTheme);
        subheaderHintStyleProfile.setTextColor(subheaderHintTextColor).setTypeface(subheaderHintTypeface)
                .setTypefaceStyle(subheaderHintTypefaceStyle);
        mThemer.setSubheaderHintStyleProfile(subheaderHintStyleProfile);

        // Badge text styling
        TextViewStyleProfile badgeStyleProfile = new TextViewStyleProfile(context, defaultTheme);
        badgeStyleProfile.setTextColor(badgeTextColor).setTypeface(badgeTypeface)
                .setTypefaceStyle(badgeTypefaceStyle);
        mThemer.setBadgeStyleProfile(badgeStyleProfile);

        mThemer.setItemBackground(a.getDrawable(R.styleable.SublimeNavigationView_snvItemBackground));

        if (a.hasValue(R.styleable.SublimeNavigationView_snvMenu)) {
            int menuResId = a.getResourceId(R.styleable.SublimeNavigationView_snvMenu, -1);

            if (menuResId == -1) {
                throw new RuntimeException("Passed menuResId was not valid");
            }

            mMenu = new SublimeMenu(menuResId);
            inflateMenu(menuResId);
        }

        mMenu.setCallback(new SublimeMenu.Callback() {
            public boolean onMenuItemSelected(SublimeMenu menu, SublimeBaseMenuItem item,
                    OnNavigationMenuEventListener.Event event) {
                return SublimeNavigationView.this.mEventListener != null
                        && SublimeNavigationView.this.mEventListener.onNavigationMenuEvent(event, item);
            }
        });

        mPresenter = new SublimeMenuPresenter();
        applyThemer();

        mMenu.setMenuPresenter(getContext(), mPresenter);
        addView(mPresenter.getMenuView(this));

        if (a.hasValue(R.styleable.SublimeNavigationView_snvHeaderLayout)) {
            inflateHeaderView(a.getResourceId(R.styleable.SublimeNavigationView_snvHeaderLayout, 0));
        }
    } finally {
        a.recycle();
    }

    // Upon creation, and until initializations are done,
    // SublimeMenuPresenter blocks all calls for invalidation.
    // We can now finalize the initialization phase to allow
    // invalidation of the menu when required.
    mPresenter.setInitializationDone();
}

From source file:fr.forexperts.ui.MarketOverviewFragment.java

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

    mListView = (ListView) rootView.findViewById(R.id.indexList);
    mLineChartView = (LineChartView) rootView.findViewById(R.id.chart);
    mPullToRefreshLayout = (PullToRefreshLayout) rootView.findViewById(R.id.ptr_layout);
    mProgressBar = (ProgressBar) rootView.findViewById(R.id.progressBar);
    mStartDateChart = (TextView) rootView.findViewById(R.id.startDateChart);
    mEndDateChart = (TextView) rootView.findViewById(R.id.endDateChart);

    // Setup the PullToRefreshLayout
    ActionBarPullToRefresh.from(getActivity())
            .options(Options.create().scrollDistance(.30f).headerLayout(R.layout.customised_header)
                    .headerTransformer(new CustomisedHeaderTransformer()).build())
            .allChildrenArePullable().listener(this).setup(mPullToRefreshLayout);

    mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override/*from   w w  w . j  a  va2  s. c o  m*/
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            mCallback.onItemSelect(CODE[position]);
        }
    });

    Calendar c = Calendar.getInstance();
    String month = TimeUtils.formatMonth(c);
    int day = c.get(Calendar.DAY_OF_MONTH);
    String date = Integer.toString(day) + " " + month;
    mEndDateChart.setText(date);

    Typeface tf = Typeface.createFromAsset(getActivity().getAssets(), "fonts/Roboto-Light.ttf");
    mStartDateChart.setTypeface(tf);
    mEndDateChart.setTypeface(tf);

    MarketOverviewTask marketOverviewTask = new MarketOverviewTask();
    marketOverviewTask.execute(CODE[0] + "," + CODE[1] + "," + CODE[2]);
    DownloadHistoricalDataTask downloadHistoricalDataTask = new DownloadHistoricalDataTask();
    downloadHistoricalDataTask.execute();

    return rootView;
}

From source file:co.ceryle.segmentedbutton.SegmentedButton.java

/**
 * @param location is .ttf file's path in assets folder. Example: 'fonts/my_font.ttf'
 *//*from  w  w w .  jav  a 2  s . c o m*/
public void setTypeface(String location) {
    if (null != location && !location.equals("")) {
        Typeface typeface = Typeface.createFromAsset(getContext().getAssets(), location);
        setTypeface(typeface);
    }
}

From source file:org.phillyopen.mytracks.cyclephilly.MainInput.java

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

    final Firebase ref = new Firebase("https://cyclephilly.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(), "cyclephilly.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.longitude, mySpot.latitude), 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("Cycle Philly");

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

From source file:com.scigames.slidegame.ProfileActivity.java

/** Called with the activity is first created. */
@Override//w  w w .j a  va2 s .c  o m
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE);
    Log.d(TAG, "super.OnCreate");
    Intent i = getIntent();
    Log.d(TAG, "getIntent");
    firstNameIn = i.getStringExtra("fName");
    lastNameIn = i.getStringExtra("lName");
    passwordIn = i.getStringExtra("password");
    massIn = i.getStringExtra("mass");
    emailIn = i.getStringExtra("email");
    classIdIn = i.getStringExtra("classId");
    studentIdIn = i.getStringExtra("studentId");
    visitIdIn = i.getStringExtra("visitId");
    rfidIn = i.getStringExtra("rfid");
    photoUrl = i.getStringExtra("photoUrl");
    photoUrl = "http://mysweetwebsite.com/" + photoUrl;
    slideLevel = i.getStringExtra("slideLevel");
    cartLevel = i.getStringExtra("cartLevel");
    Log.d(TAG, "...getStringExtra");
    // Inflate our UI from its XML layout description.
    setContentView(R.layout.profile_page);
    Log.d(TAG, "...setContentView");

    // Hook up button presses to the appropriate event handler.
    //((Button) findViewById(R.id.back)).setOnClickListener(mBackListener);
    //((Button) findViewById(R.id.clear)).setOnClickListener(mClearListener);
    ((Button) findViewById(R.id.done)).setOnClickListener(mDone);
    //Log.d(TAG,"...instantiateButtons");

    //display name and profile info
    Resources res = getResources();
    TextView greets = (TextView) findViewById(R.id.greeting);
    greets.setText(String.format(res.getString(R.string.greeting), firstNameIn, lastNameIn));

    TextView fname = (TextView) findViewById(R.id.first_name);
    fname.setText(String.format(res.getString(R.string.profile_first_name), firstNameIn));

    TextView lname = (TextView) findViewById(R.id.last_name);
    lname.setText(String.format(res.getString(R.string.profile_last_name), lastNameIn));

    TextView school = (TextView) findViewById(R.id.school_name);
    school.setText(String.format(res.getString(R.string.profile_school_name), "from DB"));

    TextView teacher = (TextView) findViewById(R.id.teacher_name);
    teacher.setText(String.format(res.getString(R.string.profile_teacher_name), "from DB"));

    TextView classid = (TextView) findViewById(R.id.class_id);
    classid.setText(String.format(res.getString(R.string.profile_classid), classIdIn));

    TextView mmass = (TextView) findViewById(R.id.mass);
    mmass.setText(String.format(res.getString(R.string.profile_mass), massIn));

    TextView memail = (TextView) findViewById(R.id.email);
    memail.setText(String.format(res.getString(R.string.profile_email), emailIn));

    TextView mpass = (TextView) findViewById(R.id.password);
    mpass.setText(String.format(res.getString(R.string.profile_password), passwordIn));

    TextView mRfid = (TextView) findViewById(R.id.rfid);
    mRfid.setText(String.format(res.getString(R.string.profile_rfid), rfidIn));

    Log.d(TAG, "...Profile Info");
    Typeface ExistenceLightOtf = Typeface.createFromAsset(getAssets(), "fonts/Existence-Light.ttf");
    Typeface Museo300Regular = Typeface.createFromAsset(getAssets(), "fonts/Museo300-Regular.otf");
    Typeface Museo500Regular = Typeface.createFromAsset(getAssets(), "fonts/Museo500-Regular.otf");
    Typeface Museo700Regular = Typeface.createFromAsset(getAssets(), "fonts/Museo700-Regular.otf");

    TextView welcome = (TextView) findViewById(R.id.welcome);
    TextView notascigamersentence = (TextView) findViewById(R.id.notascigamersentence);
    setTextViewFont(ExistenceLightOtf, greets);
    setTextViewFont(Museo500Regular, fname, lname, school, teacher, classid, mmass, memail, mpass, mRfid);

    Button Done = (Button) findViewById(R.id.done);
    setButtonFont(ExistenceLightOtf, Done);

    //set listener
    task.setOnResultsListener(this);

    //push picture back.-- photo
    task.cancel(true);
    //create a new async task for every time you hit login (each can only run once ever)
    task = new SciGamesHttpPoster(ProfileActivity.this, "http://mysweetwebsite.com/push/update_mass.php"); //i'm using MASS just for now
    //set listener
    task.setOnResultsListener(ProfileActivity.this);

    //prepare key value pairs to send
    String[] keyVals = { "student_id", studentIdIn, "visit_id", visitIdIn, "mass", massIn };

    //create AsyncTask, then execute
    @SuppressWarnings("unused")
    AsyncTask<String, Void, JSONObject> serverResponse = null;
    serverResponse = task.execute(keyVals);
    Log.d(TAG, "...task.execute(keyVals)");

}

From source file:net.evendanan.android.hagarfingerpainting.HagarFingerpaintingActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);

    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

    setContentView(R.layout.main);//from w  ww  .  j a  v  a  2 s.c  om
    mWhiteboard = (Whiteboard) findViewById(R.id.whiteboard);
    mPainterName = (TextView) findViewById(R.id.painter_name_text);
    mAdView = (AdView) findViewById(R.id.adView);
    mBackground = (ImageView) findViewById(R.id.background_image);
    mSettingsIcons = (SettingsIconsView) findViewById(R.id.settings_icons);
    mSettingsIcons.setOnSettingsIconsTouchedListener(this);
    mToolbox = (ViewGroup) findViewById(R.id.toolbox);

    for (View innerView : mToolbox.getTouchables()) {
        if (innerView instanceof ImageView) {
            if (innerView.getId() == R.id.toolbox_eraser) {
                mEraserToolBoxIcon = (ImageView) innerView;
            }

            innerView.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View v) {
                    onToolboxClicked(v.getId());
                }
            });
        }
    }

    mInAnimation = AnimationUtils.loadAnimation(getApplicationContext(), android.R.anim.fade_in);
    mOutAnimation = AnimationUtils.loadAnimation(getApplicationContext(), android.R.anim.slide_out_right);
    mOutAnimation.setAnimationListener(new AnimationListener() {
        @Override
        public void onAnimationStart(Animation animation) {
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
        }

        @Override
        public void onAnimationEnd(Animation animation) {
            mToolbox.setVisibility(View.GONE);
            mSettingsIcons.setVisibility(View.VISIBLE);
        }
    });

    SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
    sp.registerOnSharedPreferenceChangeListener(this);

    mBackgroundPaper = savedInstanceState == null ? null
            : (IntentDrivenPaperBackground) savedInstanceState.getSerializable(PAPER_INTENT_OBJECT_KEY);
    mPaperCreated = false;

    Typeface tf = Typeface.createFromAsset(getAssets(), "fonts/schoolbell.ttf");
    mPainterName.setTypeface(tf);
    mBlur = new BlurMaskFilter(2, BlurMaskFilter.Blur.NORMAL);

    readyPaperTools();
}

From source file:markson.visuals.sitapp.CCActivity.java

public void json() {

    ListAdapter adapter = new SimpleAdapter(this, mylist, R.layout.jsontest, new String[] { "cclass", "fdate" },
            new int[] { R.id.item_title, R.id.item_subtitle });

    setListAdapter(adapter);//  w  w  w  . jav  a2  s.c  o m

    final ListView lv = getListView();
    lv.setTextFilterEnabled(true);
    lv.setOnItemClickListener(new OnItemClickListener() {
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            @SuppressWarnings("unchecked")
            HashMap<String, String> o = (HashMap<String, String>) lv.getItemAtPosition(position);
            // Toast.makeText(eventActivity.this,"ID '" + o.get("link") +
            // "' was clicked.",Toast.LENGTH_SHORT).show();

            TextView title = (TextView) findViewById(R.id.item_title);
            Typeface tf = Typeface.createFromAsset(getAssets(), "fonts/roboto/Roboto-Regular.ttf");
            title.setTypeface(tf);

            TextView subtitle = (TextView) findViewById(R.id.item_subtitle);
            subtitle.setTypeface(tf);

            date = o.get("date");
            cclass = o.get("cclass");
            num = o.get("num");
            instructor = o.get("instructor");
            crn = o.get("crn");
            fdate = o.get("date");
            time = o.get("time");
            download();
        }
    });
}

From source file:playn.android.AndroidAssets.java

Typeface getTypeface(String path) {
    return Typeface.createFromAsset(assetMgr, normalizePath(pathPrefix + path));
}

From source file:ir.actfun.toofan.activities.NowWeatherPage.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 a va  2  s  .  c  o  m
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
    if (prefs.getString("theme", "fresh").equals("dark")) {
        setTheme(R.style.AppTheme_NoActionBar_Dark);
        darkTheme = true;
    } else if (prefs.getString("theme", "fresh").equals("transparent")) {
        setTheme(R.style.AppTheme_NoActionBar_transparent);
    }

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

    progressDialog = new ProgressDialog(NowWeatherPage.this);

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

    // Initialize textboxes
    setContentView(R.layout.nowweather_layout);

    weatherFont = Typeface.createFromAsset(getApplicationContext().getAssets(),
            "fonts/weathericons-regular-webfont.ttf");

    YoYo.with(Techniques.ZoomIn).duration(2000).playOn(findViewById(R.id.weather_icon));
    YoYo.with(Techniques.ZoomIn).duration(2000).playOn(findViewById(R.id.city_field));
    YoYo.with(Techniques.ZoomIn).duration(2000).playOn(findViewById(R.id.current_temperature_field));
    YoYo.with(Techniques.ZoomIn).duration(2200).playOn(findViewById(R.id.details_field));
    YoYo.with(Techniques.ZoomIn).duration(2400).playOn(findViewById(R.id.humidity_field));
    YoYo.with(Techniques.ZoomIn).duration(2800).playOn(findViewById(R.id.pressure_field));
    YoYo.with(Techniques.ZoomIn).duration(2600).playOn(findViewById(R.id.wind_field));
    YoYo.with(Techniques.ZoomIn).duration(3000).playOn(findViewById(R.id.updated_field));

    quote_writer = (TextView) findViewById(R.id.quote_writer);
    quote_text2 = (TextView) findViewById(R.id.quote_text2);
    quote_text = (TextView) findViewById(R.id.quote_text);
    cityField = (TextView) findViewById(R.id.city_field);
    lastUpdate = (TextView) findViewById(R.id.updated_field);
    todayDescription = (TextView) findViewById(R.id.details_field);
    todayTemperature = (TextView) findViewById(R.id.current_temperature_field);
    todayHumidity = (TextView) findViewById(R.id.humidity_field);
    todayPressure = (TextView) findViewById(R.id.pressure_field);
    todayWind = (TextView) findViewById(R.id.wind_field);
    todayIcon = (TextView) findViewById(R.id.weather_icon);
    todayIcon.setTypeface(weatherFont);

    // Preload data from cache
    preloadWeather();
    updateLastUpdateTime();

    // Set autoupdater
    AlarmReceiver.setRecurringAlarm(this);

    //Getting the quote from Ganjoor

    QuoteGenerator.placeIdTask asyncTask = new QuoteGenerator.placeIdTask(new QuoteGenerator.AsyncResponse() {
        public void processFinish(String m1, String m2, String author) {

            quote_text.setText(m1);
            quote_text2.setText(m2);
            quote_writer.setText(author);

        }
    });
    asyncTask.execute("25.180000", "89.530000"); //  asyncTask.execute("Latitude", "Longitude")

    YoYo.with(Techniques.FadeIn).duration(10000).playOn(findViewById(R.id.quote_text));
    YoYo.with(Techniques.FadeIn).duration(10000).playOn(findViewById(R.id.quote_text2));
    YoYo.with(Techniques.FadeOut).duration(5000).playOn(findViewById(R.id.quote_writer));
    //End of OnCreate Method.

}