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:arc.noaa.weather.activities.MainActivity.java

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

    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
    setTheme(theme = getTheme(prefs.getString("theme", "fresh")));
    boolean darkTheme = theme == R.style.AppTheme_NoActionBar_Dark
            || theme == R.style.AppTheme_NoActionBar_Classic_Dark;

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

    progressDialog = new ProgressDialog(MainActivity.this);

    // Load toolbar
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);/*from  w  w w .  j  a va  2 s  .  co  m*/
    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);
    todaySunrise = (TextView) findViewById(R.id.todaySunrise);
    todaySunset = (TextView) findViewById(R.id.todaySunset);
    lastUpdate = (TextView) findViewById(R.id.lastUpdate);
    todayIcon = (TextView) findViewById(R.id.todayIcon);
    weatherFont = Typeface.createFromAsset(this.getAssets(), "fonts/weather.ttf");
    todayIcon.setTypeface(weatherFont);

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

    destroyed = false;

    initMappings();

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

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

From source file:com.speed.traquer.app.Feedback_rate_taxi.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_feedback_rate_taxi);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    inputTaxi = (EditText) findViewById(R.id.taxi_id);
    taxiDriver = (EditText) findViewById(R.id.taxi_driver);
    taxiLic = (EditText) findViewById(R.id.taxi_license);
    feedback_remarks = (EditText) findViewById(R.id.feedback_remarks);
    rgSafety = (RadioGroup) findViewById(R.id.radioSafety);
    rgDriver = (RadioGroup) findViewById(R.id.radioDriver);
    rgClean = (RadioGroup) findViewById(R.id.radioClean);
    rgComfort = (RadioGroup) findViewById(R.id.radioComfort);
    rgPunctual = (RadioGroup) findViewById(R.id.radioPunctual);
    rgIntegrity = (RadioGroup) findViewById(R.id.radioIntegrity);
    rateBtnBus = (ImageButton) findViewById(R.id.btn_rate_bus);
    editCurrDate = (EditText) findViewById(R.id.editCurrDate);
    editCurrTime = (EditText) findViewById(R.id.editCurrTime);
    ProgressBar barProgress = (ProgressBar) findViewById(R.id.progressLoading);

    rateBtnBus.setOnClickListener(new View.OnClickListener() {
        @Override//from  w ww  .j  a  v a2  s.  c o m
        public void onClick(View view) {
            Intent intent = new Intent(getApplicationContext(), Feedback_rate.class);
            startActivity(intent);
        }
    });

    //Auto Complete Database
    if (isNetworkConnected()) {
        actv_comp_taxi = (AutoCompleteTextView) findViewById(R.id.search_taxi_comp);
        SuggestionAdapter sa = new SuggestionAdapter(this, actv_comp_taxi.getText().toString(), taxiUrl,
                "compcode");
        sa.setLoadingIndicator(barProgress);
        actv_comp_taxi.setAdapter(sa);
    } else {
        Toast.makeText(getApplicationContext(), "Looks like there's a problem with your network connection.",
                Toast.LENGTH_SHORT).show();
    }

    actv_comp_taxi = (AutoCompleteTextView) findViewById(R.id.search_taxi_comp);
    SuggestionAdapter sa = new SuggestionAdapter(this, actv_comp_taxi.getText().toString(), taxiUrl,
            "compcode");
    sa.setLoadingIndicator(barProgress);
    actv_comp_taxi.setAdapter(sa);

    getCurrentDate();
    getCurrentTime();

    String fontPath = "fonts/segoeuil.ttf";
    Typeface tf = Typeface.createFromAsset(getAssets(), fontPath);
    actv_comp_taxi.setTypeface(tf);
    actv_comp_taxi.setTypeface(tf);
    feedback_remarks.setTypeface(tf);
    inputTaxi.setTypeface(tf);
    taxiDriver.setTypeface(tf);
    taxiLic.setTypeface(tf);

    TextView txtTaxiDriver = (TextView) findViewById(R.id.txt_taxi_driver);
    txtTaxiDriver.setTypeface(tf);

    TextView txtTaxiLic = (TextView) findViewById(R.id.txt_taxi_license);
    txtTaxiLic.setTypeface(tf);

    TextView txtComp = (TextView) findViewById(R.id.taxi_comp);
    txtComp.setTypeface(tf);

    TextView txtNumber = (TextView) findViewById(R.id.taxi_number);
    txtNumber.setTypeface(tf);

    TextView txtSafety = (TextView) findViewById(R.id.txtSafety);
    txtSafety.setTypeface(tf);

    TextView txtDriver = (TextView) findViewById(R.id.txtDriver);
    txtDriver.setTypeface(tf);

    TextView txtClean = (TextView) findViewById(R.id.txtClean);
    txtClean.setTypeface(tf);

    TextView txtComfort = (TextView) findViewById(R.id.txtComfort);
    txtComfort.setTypeface(tf);

    TextView txtPunctual = (TextView) findViewById(R.id.txtPunctual);
    txtPunctual.setTypeface(tf);

    TextView txtIntegrity = (TextView) findViewById(R.id.txtIntegrity);
    txtIntegrity.setTypeface(tf);

    rgSafety.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(RadioGroup radioGroup, int i) {
            RadioButton ibGreatSafety = (RadioButton) findViewById(R.id.ibGreatSafety);
            RadioButton ibGoodSafety = (RadioButton) findViewById(R.id.ibGoodSafety);
            RadioButton ibBadSafety = (RadioButton) findViewById(R.id.ibBadSafety);
            if (ibGreatSafety.isChecked()) {
                re1 = 1;
                rGroup1 = 1;
                //Toast.makeText(Feedback_rate.this, "Awesome Safety",Toast.LENGTH_SHORT).show();
            } else if (ibGoodSafety.isChecked()) {
                rg1 = 1;
                rGroup1 = 1;
                //Toast.makeText(Feedback_rate.this, "Good Safety",Toast.LENGTH_SHORT).show();
            } else if (ibBadSafety.isChecked()) {
                rb1 = 1;
                rGroup1 = 1;
                //Toast.makeText(Feedback_rate.this, "Bad Safety",Toast.LENGTH_SHORT).show();
            }
        }
    });
    rgDriver.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(RadioGroup radioGroup, int i) {
            RadioButton ibGreatDriver = (RadioButton) findViewById(R.id.ibGreatDriver);
            RadioButton ibGoodDriver = (RadioButton) findViewById(R.id.ibGoodDriver);
            RadioButton ibBadDriver = (RadioButton) findViewById(R.id.ibBadDriver);
            if (ibGreatDriver.isChecked()) {
                re2 = 1;
                rGroup2 = 1;
                //Toast.makeText(Feedback_rate.this, "Awesome Driver",Toast.LENGTH_SHORT).show();
            } else if (ibGoodDriver.isChecked()) {
                rg2 = 1;
                rGroup2 = 1;
                //Toast.makeText(Feedback_rate.this, "Good Driver",Toast.LENGTH_SHORT).show();
            } else if (ibBadDriver.isChecked()) {
                rb2 = 1;
                rGroup2 = 1;
                //Toast.makeText(Feedback_rate.this, "Bad Driver",Toast.LENGTH_SHORT).show();
            }
        }
    });
    rgClean.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(RadioGroup radioGroup, int i) {
            RadioButton ibGreatClean = (RadioButton) findViewById(R.id.ibGreatClean);
            RadioButton ibGoodClean = (RadioButton) findViewById(R.id.ibGoodClean);
            RadioButton ibBadClean = (RadioButton) findViewById(R.id.ibBadClean);
            if (ibGreatClean.isChecked()) {
                re3 = 1;
                rGroup3 = 1;
                //Toast.makeText(Feedback_rate.this, "Awesome Cleanliness",Toast.LENGTH_SHORT).show();
            } else if (ibGoodClean.isChecked()) {
                rg3 = 1;
                rGroup3 = 1;
                //Toast.makeText(Feedback_rate.this, "Good Cleanliness",Toast.LENGTH_SHORT).show();
            } else if (ibBadClean.isChecked()) {
                rb3 = 1;
                rGroup3 = 1;
                //Toast.makeText(Feedback_rate.this, "Bad Cleanliness",Toast.LENGTH_SHORT).show();
            }
        }
    });
    rgComfort.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(RadioGroup radioGroup, int i) {
            RadioButton ibGreatComfort = (RadioButton) findViewById(R.id.ibGreatComfort);
            RadioButton ibGoodComfort = (RadioButton) findViewById(R.id.ibGoodComfort);
            RadioButton ibBadComfort = (RadioButton) findViewById(R.id.ibBadComfort);
            if (ibGreatComfort.isChecked()) {
                re4 = 1;
                rGroup4 = 1;
                //Toast.makeText(Feedback_rate.this, "Super Comfort",Toast.LENGTH_SHORT).show();
            } else if (ibGoodComfort.isChecked()) {
                rg4 = 1;
                rGroup4 = 1;
                //Toast.makeText(Feedback_rate.this, "Comfort",Toast.LENGTH_SHORT).show();
            } else if (ibBadComfort.isChecked()) {
                rb4 = 1;
                rGroup4 = 1;
                //Toast.makeText(Feedback_rate.this, "Not Comfort at all",Toast.LENGTH_SHORT).show();
            }
        }
    });
    rgPunctual.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(RadioGroup radioGroup, int i) {
            RadioButton ibGreatPunctual = (RadioButton) findViewById(R.id.ibGreatPunctual);
            RadioButton ibGoodPunctual = (RadioButton) findViewById(R.id.ibGoodPunctual);
            RadioButton ibBadPunctual = (RadioButton) findViewById(R.id.ibBadPunctual);
            if (ibGreatPunctual.isChecked()) {
                re5 = 1;
                rGroup5 = 1;
                //Toast.makeText(Feedback_rate.this, "Very Punctual",Toast.LENGTH_SHORT).show();
            } else if (ibGoodPunctual.isChecked()) {
                rg5 = 1;
                rGroup5 = 1;
                //Toast.makeText(Feedback_rate.this, "Delay Abit",Toast.LENGTH_SHORT).show();
            } else if (ibBadPunctual.isChecked()) {
                rb5 = 1;
                rGroup5 = 1;
                //Toast.makeText(Feedback_rate.this, "Not Punctual at all",Toast.LENGTH_SHORT).show();
            }
        }
    });

    rgIntegrity.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(RadioGroup radioGroup, int i) {
            RadioButton ibGreatDriver = (RadioButton) findViewById(R.id.ibGreatIntegrity);
            RadioButton ibGoodDriver = (RadioButton) findViewById(R.id.ibGoodIntegrity);
            RadioButton ibBadDriver = (RadioButton) findViewById(R.id.ibBadIntegrity);
            if (ibGreatDriver.isChecked()) {
                re6 = 1;
                rGroup6 = 1;
                //Toast.makeText(Feedback_rate.this, "Awesome Driver",Toast.LENGTH_SHORT).show();
            } else if (ibGoodDriver.isChecked()) {
                rg6 = 1;
                rGroup6 = 1;
                //Toast.makeText(Feedback_rate.this, "Good Driver",Toast.LENGTH_SHORT).show();
            } else if (ibBadDriver.isChecked()) {
                rb6 = 1;
                rGroup6 = 1;
                //Toast.makeText(Feedback_rate.this, "Bad Driver",Toast.LENGTH_SHORT).show();
            }
        }
    });

    easyTracker = EasyTracker.getInstance(Feedback_rate_taxi.this);
}

From source file:root.magicword.MagicWord.java

@Override
public void onCreate(Bundle savedInstanceState) {

    context = this;
    mainApp = this;
    started();//from   w  ww  . ja  va 2s .  co  m
    boolean firstTime = getSharedPreferences("PREFERENCE", MODE_PRIVATE).getBoolean("firstTime", true);
    if (firstTime) {
        /*
         * getSharedPreferences("PREFERENCE", MODE_PRIVATE).edit()
         * .putBoolean("firstTime", false).commit();
         */
        Intent myIntent = new Intent(MagicWord.this, Startup.class);
        MagicWord.this.startActivity(myIntent);
    }

    /*
     * if (i == 1) { mShaker = new ShakeListener(this); mPreferences =
     * PreferenceManager .getDefaultSharedPreferences(context); String val =
     * mPreferences.getString("force", "1500"); Toast.makeText(this, " " +
     * val, Toast.LENGTH_SHORT).show(); // mShaker.setThreshold(val); }
     */

    super.onCreate(savedInstanceState);

    setContentView(R.layout.main);

    //started();

    startService(new Intent(this, Broadcastreceiver.class));
    vibe = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
    speech_to_text = (ImageButton) findViewById(R.id.imageButton3);
    text_to_speech = (ImageButton) findViewById(R.id.imageButton1);
    aboutus = (ImageButton) findViewById(R.id.imageButton8);
    settings = (ImageButton) findViewById(R.id.imageButton6);
    like = (ImageButton) findViewById(R.id.imageButton7);
    test_your_ear = (ImageButton) findViewById(R.id.imageButton2);
    forums = (ImageButton) findViewById(R.id.imageButton4);
    video = (ImageButton) findViewById(R.id.imageButton5);
    quotes = (TextView) findViewById(R.id.textView2);
    quotes.setTextColor(Color.WHITE);
    quotes.setSelected(true);

    Typeface tf = Typeface.createFromAsset(getAssets(), "fonts/MyriadPro.otf");
    TextView tv = (TextView) findViewById(R.id.textView1);
    tv.setTypeface(tf);
    tv.setText("AndroEar");

    Typeface tf2 = Typeface.createFromAsset(getAssets(), "fonts/RobotoItalic.ttf");
    quotes.setTypeface(tf2);

    cnt = getSharedPreferences("QUOTECOUNT", MODE_PRIVATE).getInt("cnt", 1);
    // Toast.makeText(this, " " + cnt, Toast.LENGTH_SHORT).show();
    displayquote();

    speech_to_text.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            vibe.vibrate(100);
            stopped();
            Intent myIntent = new Intent(MagicWord.this, Speechtotext.class);
            MagicWord.this.startActivity(myIntent);
            // overridePendingTransition(R.anim.hold, R.anim.fade_in);

        }

    });

    video.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            vibe.vibrate(100);
            Intent myIntent = new Intent(MagicWord.this, Video.class);
            MagicWord.this.startActivity(myIntent);
            // overridePendingTransition(R.anim.hold, R.anim.fade_in);

        }

    });

    /*
     * about.setOnClickListener(new OnClickListener() {
     * 
     * @Override public void onClick(View arg0) {
     * 
     * Intent myIntent = new Intent(MagicWord.this, Aboutus.class);
     * MagicWord.this.startActivity(myIntent);
     * 
     * }
     * 
     * });
     */

    forums.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            vibe.vibrate(100);
            /*
             * recorderThread.stopRecording();
             * detectorThread.stopDetection();
             */
            Intent myIntent = new Intent(MagicWord.this, Forums.class);
            MagicWord.this.startActivity(myIntent);
            overridePendingTransition(R.anim.slide_in, R.anim.slide_out);

        }

    });

    test_your_ear.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            vibe.vibrate(100);
            Intent myIntent = new Intent(MagicWord.this, Testyourear.class);
            MagicWord.this.startActivity(myIntent);
            // overridePendingTransition(R.anim.hold, R.anim.fade_in);

        }

    });

    aboutus.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            vibe.vibrate(100);
            Intent myIntent = new Intent(MagicWord.this, Aboutus.class);
            MagicWord.this.startActivity(myIntent);
            // overridePendingTransition(R.anim.hold, R.anim.fade_in);

        }

    });

    text_to_speech.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            vibe.vibrate(100);
            recorderThread.stopRecording();
            detectorThread.stopDetection();
            Intent myIntent = new Intent(MagicWord.this, Texttospeech.class);
            MagicWord.this.startActivity(myIntent);
            // overridePendingTransition(R.anim.hold, R.anim.fade_in);

        }

    });

    like.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            vibe.vibrate(100);
            /*
             * Intent myIntent = new Intent(MagicWord.this,
             * TestConnect.class); MagicWord.this.startActivity(myIntent);
             */
            // overridePendingTransition(R.anim.hold, R.anim.fade_in);

            callfacebook();

        }

    });

    settings.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            vibe.vibrate(100);
            Intent myIntent = new Intent(MagicWord.this, Settings.class);
            MagicWord.this.startActivity(myIntent);
            // overridePendingTransition(R.anim.hold, R.anim.fade_in);

        }

    });

}

From source file:io.imoji.sdk.grid.ui.ResultView.java

public ResultView(Context context, @ResultViewSize int viewSize) {
    super(context);
    this.context = context;

    this.viewSize = viewSize;

    int resultWidth = getDimension(0);
    int resultHeight = getDimension(1);
    setLayoutParams(new StaggeredGridLayoutManager.LayoutParams(resultWidth, resultHeight));

    placeholder = new ImageView(context);
    int placeholderSide = getDimension(4);
    RelativeLayout.LayoutParams placeholderParams = new LayoutParams(placeholderSide, placeholderSide);
    placeholderParams.addRule(RelativeLayout.CENTER_IN_PARENT);
    placeholder.setLayoutParams(placeholderParams);
    addView(placeholder);/*from  ww  w  .  j  a v a 2s .co m*/

    container = new RelativeLayout(context);
    addView(container, new LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT,
            RelativeLayout.LayoutParams.MATCH_PARENT));

    final Animation pressedAnimation = AnimationUtils.loadAnimation(context, R.anim.search_result_pressed);
    final Animation releasedAnimation = AnimationUtils.loadAnimation(context, R.anim.search_result_released);
    imageView = new GifImageView(context) {

        @Override
        public boolean onTouchEvent(MotionEvent event) {
            switch (event.getAction()) {
            case MotionEvent.ACTION_DOWN:
                if (searchResult != null && !searchResult.isCategory()) {
                    imageView.startAnimation(pressedAnimation);
                }
                break;
            case MotionEvent.ACTION_CANCEL:
            case MotionEvent.ACTION_UP:
                if (searchResult != null && !searchResult.isCategory()) {
                    imageView.startAnimation(releasedAnimation);
                }
                break;
            }
            return super.onTouchEvent(event);
        }
    };

    RelativeLayout.LayoutParams imageParams = new LayoutParams(resultWidth, resultWidth);
    imageParams.addRule(RelativeLayout.CENTER_IN_PARENT);
    imageView.setLayoutParams(imageParams);
    container.addView(imageView);

    textView = new TextView(context);
    int titleHeight = getDimension(2);
    RelativeLayout.LayoutParams titleParams = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            titleHeight);
    titleParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
    textView.setLayoutParams(titleParams);
    textView.setTypeface(Typeface.createFromAsset(context.getAssets(), "fonts/Montserrat-Light.otf"));
    textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, getDimension(3));
    //TODO // FIXME: 5/2/16
    textView.setTextColor(getResources().getColor(R.color.search_result_category_title));
    textView.setGravity(Gravity.CENTER);
    container.addView(textView);

    imageView.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            listener.onTap(searchResult);
        }
    });

}

From source file:io.coldstart.android.TrapDetailFragment.java

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

    ((TextView) rootView.findViewById(R.id.hostname)).setText(hostname);
    ((TextView) rootView.findViewById(R.id.hostname))
            .setTypeface(Typeface.createFromAsset((getActivity()).getAssets(), "fonts/MavenPro-Regular.ttf"));

    ((TextView) rootView.findViewById(R.id.IPAddress)).setText(ipaddr);

    //TODO: We don't have any way of storing this data yet *AND* the phone interface doesn't have them either
    /*((TextView) rootView.findViewById(R.id.Location)).setText("Unknown Location");
    ((TextView) rootView.findViewById(R.id.Contact)).setText("No Contact information");
    ((TextView) rootView.findViewById(R.id.Description)).setText("...");*/

    list = (ListView) rootView.findViewById(R.id.trap_list);
    return rootView;
}

From source file:com.geomoby.geodeals.DemoService.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.geomoby_main);
    mContext = this;

    mToggle = (CompoundButton) findViewById(R.id.togglebutton);

    spref = getSharedPreferences(PREF_NAME, MODE_PRIVATE);
    isCheckedStatus = spref.getBoolean("check", false); //default is false

    /*//from  w  w w.  j a v  a  2s .  co m
     * Set up toggle status
     */
    if (!isCheckedStatus)
        mToggle.setChecked(false);
    else
        mToggle.setChecked(true);

    /*
     *  Save the tags in the GeoMoby shared preferences in private mode for the user. These tags will be used
     *  to segment your audience when creating your proximity alerts. Please make sure that they match with
     *  the ones configured in your dashboard when you create an alert.
     *  Ex: 'test' is the default tag so make sure that it is set up in your Account page
     */
    SharedPreferences mySharedPreferences = getSharedPreferences(PREF, MODE_PRIVATE);

    // Build the string of tags - empty for testing. Make sure that you create your first geofences with no tags in your dashboard.
    // Add your own logic here: "male,vip,monday"...
    String tags = "";

    // Commit the string
    SharedPreferences.Editor prefEditor = mySharedPreferences.edit();
    prefEditor.putString(SETTING_TAGS, tags);
    prefEditor.commit();

    /*
     *  Monitor the toggle - Our SDK will ensure that all services are running/stopping properly
     */
    mToggle.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {

            if (isChecked == false) {

                mToggle.setPressed(false);

                // Stop the GeoMoby tracking service
                startService(new Intent(DemoService.this, GeomobyStopService.class));

                SharedPreferences.Editor editor = spref.edit();
                editor.putBoolean("check", false);
                editor.commit();

            } else {

                mToggle.setPressed(true);

                // Start the GeoMoby tracking service
                startService(new Intent(DemoService.this, GeomobyStartService.class));

                SharedPreferences.Editor editor = spref.edit();
                editor.putBoolean("check", true);
                editor.commit();

                LayoutInflater inflater = getLayoutInflater();
                // Inflate the Layout
                View layout = inflater.inflate(R.layout.geomoby_toast,
                        (ViewGroup) findViewById(R.id.custom_toast_layout));

                // Set the Text to show in TextView
                TextView text = (TextView) layout.findViewById(R.id.textToShow);
                text.setText("GREAT! YOU ARE READY TO RECEIVE REAL-TIME NOTIFICATIONS!");
                Typeface face;
                face = Typeface.createFromAsset(getAssets(), "Bitter-Bold.otf");
                text.setTypeface(face);

                Toast toast = new Toast(getApplicationContext());
                toast.setGravity(Gravity.BOTTOM, 0, 50);
                toast.setDuration(Toast.LENGTH_LONG);
                toast.setView(layout);
                toast.show();
            }
        }
    });

    // Initialise GeoMoby Notification Listener
    GeomobyNotificationsReceiver receiver = new GeomobyNotificationsReceiver();
    receiver.setNotificationListener(this);
}

From source file:com.tr4android.support.extension.typeface.TypefaceCompat.java

/**
 * Creates a typeface object that best matches the specified typeface and the specified style.
 * Use this call if you want to pick a new style from the same family of an typeface object.
 * If family is null, this selects from the default font's family.
 *
 * @param ctx        A context.//ww  w .j a  va 2s  .  co m
 * @param familyName May be null. The name of the font family.
 * @param style      The style (normal, bold, italic) of the typeface, e.g. NORMAL, BOLD, ITALIC, BOLD_ITALIC.
 * @return The best matching typeface.
 * @since 0.1.1
 * @deprecated
 */
@Deprecated
public static Typeface create(Context ctx, String familyName, int style) {
    if (!mInitialized)
        initialize();
    if (isSupported(familyName) || familyName == null) {
        boolean styleAfterwards = false;
        String fileName = FONT_FAMILY_FILE_PREFIX.get(familyName == null ? "sans-serif" : familyName);
        if (fileName.endsWith("-")) {
            // All styles are supported.
            fileName += STYLE_SUFFIX[style];
        } else {
            switch (style) {
            case Typeface.NORMAL:
                break;
            case Typeface.BOLD:
            case Typeface.BOLD_ITALIC:
                // These styles are not supported by default. Therefore force style after retrieving normal font.
                styleAfterwards = true;
                break;
            case Typeface.ITALIC:
                fileName += STYLE_SUFFIX[style];
                break;
            }
        }
        fileName += TTF_SUFFIX;
        // Retrieve Typeface from cache.
        Typeface tf = TYPEFACE_CACHE.get(fileName);
        if (tf == null) {
            // Create Typeface and cache it for later.
            String fontPath = "fonts/" + fileName;
            tf = Typeface.createFromAsset(ctx.getAssets(), fontPath);
            if (tf != null) {
                TYPEFACE_CACHE.put(fileName, tf);
            }
        }
        if (tf != null) {
            return styleAfterwards ? Typeface.create(tf, style) : tf;
        }
    }
    // Let the default implementation of Typeface try.
    return Typeface.create(familyName, style);
}

From source file:com.towson.wavyleaf.Sighting.java

protected void init() {
    getWindow().setBackgroundDrawable(null);
    Typeface tf_light = Typeface.createFromAsset(getAssets(), "fonts/roboto_light.ttf");
    Typeface tf_bold = Typeface.createFromAsset(getAssets(), "fonts/roboto_bold.ttf");

    tvlat = (TextView) findViewById(R.id.tv_latitude);
    tvlong = (TextView) findViewById(R.id.tv_longitude);
    tvpicnotes = (TextView) findViewById(R.id.tv_picturenotes);
    tvper = (TextView) findViewById(R.id.tv_percentageseen);
    tvper_summary = (TextView) findViewById(R.id.tv_percentageseen_summary);
    tvcoor = (TextView) findViewById(R.id.tv_coordinates);
    tvarea = (TextView) findViewById(R.id.tv_areainfested);
    tvarea_summary = (TextView) findViewById(R.id.tv_areainfested_summary);
    tv_treatment = (TextView) findViewById(R.id.tv_treatment);
    notes = (EditText) findViewById(R.id.notes);
    etarea = (EditText) findViewById(R.id.et_areainfested);
    b1 = (ToggleButton) findViewById(R.id.bu_1);
    b2 = (ToggleButton) findViewById(R.id.bu_2);
    b3 = (ToggleButton) findViewById(R.id.bu_3);
    b4 = (ToggleButton) findViewById(R.id.bu_4);
    b5 = (ToggleButton) findViewById(R.id.bu_5);
    b6 = (ToggleButton) findViewById(R.id.bu_6);
    cb = (CheckBox) findViewById(R.id.cb_confirm);
    rg = (RadioGroup) findViewById(R.id.toggleGroup);
    sp = (Spinner) findViewById(R.id.sp_areainfested);
    sp_treatment = (Spinner) findViewById(R.id.sp_treatment);
    mLocationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);

    locationData = (LocationApplication) getApplication();
    currentEditableLocation = locationData.getLocation();

    updateLocationTimer = new Timer();
    TimerTask updateLocationTask = new TimerTask() {
        @Override//  w w w .j a  v  a 2  s  . co m
        public void run() {
            checkLocation();
        }
    };
    updateLocationTimer.scheduleAtFixedRate(updateLocationTask, 0, FIVE_SECONDS);

    // Listener for EditText in Area Infested
    etarea.addTextChangedListener(new TextWatcher() {
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            if (etarea.getText().length() == 0) {
                tvarea_summary.setText("");
            } else if (etarea.getText().toString().contains("-")) { // Negative number
                etarea.getEditableText().clear();
                Toast.makeText(getApplicationContext(), "Negative values not allowed", Toast.LENGTH_SHORT)
                        .show();
            } else {
                tvarea_summary.setText(etarea.getText() + " " + sp.getSelectedItem().toString());
            }
        }

        public void afterTextChanged(Editable s) {
        }

        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }
    });

    // Listener for spinner in Area Infested
    sp.setOnItemSelectedListener(new OnItemSelectedListener() {
        @Override
        public void onNothingSelected(AdapterView<?> arg0) {
        }

        @Override
        public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
            if (etarea.getText().length() != 0)
                tvarea_summary.setText(etarea.getText() + " " + sp.getSelectedItem());
        }
    });

    // Adapter for area infested spinner
    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.areainfested_array,
            android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    sp.setAdapter(adapter);

    // Adapter for Treatment spinner
    ArrayAdapter<CharSequence> adapter2 = ArrayAdapter.createFromResource(this, R.array.treatment_array,
            android.R.layout.simple_spinner_item);
    adapter2.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    sp_treatment.setAdapter(adapter2);

    // Just to be safe
    cb.setChecked(false);

    // Set all the beautiful typefaces
    tvlat.setTypeface(tf_light);
    tvlong.setTypeface(tf_light);
    tvcoor.setTypeface(tf_bold);
    tvarea.setTypeface(tf_bold);
    tvarea_summary.setTypeface(tf_bold);
    tvper.setTypeface(tf_bold);
    tvper_summary.setTypeface(tf_bold);
    tvpicnotes.setTypeface(tf_bold);
    tv_treatment.setTypeface(tf_bold);
    cb.setTypeface(tf_light);
    b1.setTypeface(tf_light);
    b2.setTypeface(tf_light);
    b3.setTypeface(tf_light);
    b4.setTypeface(tf_light);
    b5.setTypeface(tf_light);
    b6.setTypeface(tf_light);

    if (!locationData.isSearching())
        findUsersLocation();

    ib = (ImageButton) findViewById(R.id.imagebutton_sighting);
    // Listener for camera button
    ib.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            takePicture();
        }
    });

    ib_percent = (ImageButton) findViewById(R.id.ib_percent);
    // Listener for help button in Percentage Infested category
    ib_percent.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            showDialog(HELP_PERCENT);
        }
    });

    ib_treatment = (ImageButton) findViewById(R.id.ib_treatment);
    // Listener for help button in Treatment catgeory
    ib_treatment.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            showDialog(HELP_TREATMENT);
            //            Toast.makeText(getApplicationContext(), "Specify the type of treatment that was done to this area", Toast.LENGTH_LONG).show();
        }
    });
}

From source file:ru.frostdev.weather.MainActivity.java

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

    darkTheme = false;//w ww .jav  a 2s  .  c o m
    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);

    progressDialog = new ProgressDialog(MainActivity.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);
    todaySunrise = (TextView) findViewById(R.id.todaySunrise);
    todaySunset = (TextView) findViewById(R.id.todaySunset);
    lastUpdate = (TextView) findViewById(R.id.lastUpdate);
    todayIcon = (TextView) findViewById(R.id.todayIcon);
    weatherFont = Typeface.createFromAsset(this.getAssets(), "fonts/weather.ttf");
    todayIcon.setTypeface(weatherFont);

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

    destroyed = false;

    initMappings();

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

    // Set autoupdater
    AlarmReceiver.setRecurringAlarm(this);

}

From source file:reddy.preetham.forecast.MainActivity.java

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

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

    // Initiate activity
    super.onCreate(savedInstanceState);
    Fabric.with(this, new Crashlytics());
    setContentView(R.layout.activity_scrolling);
    appView = findViewById(R.id.viewApp);

    progressDialog = new ProgressDialog(MainActivity.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);
    todaySunrise = (TextView) findViewById(R.id.todaySunrise);
    todaySunset = (TextView) findViewById(R.id.todaySunset);
    lastUpdate = (TextView) findViewById(R.id.lastUpdate);
    todayIcon = (TextView) findViewById(R.id.todayIcon);
    weatherFont = Typeface.createFromAsset(this.getAssets(), "fonts/weather.ttf");
    todayIcon.setTypeface(weatherFont);

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

    destroyed = false;

    //changes in branch1

    initMappings();

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

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