Example usage for android.graphics Typeface NORMAL

List of usage examples for android.graphics Typeface NORMAL

Introduction

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

Prototype

int NORMAL

To view the source code for android.graphics Typeface NORMAL.

Click Source Link

Usage

From source file:com.google.android.apps.iosched.util.UIUtils.java

public static void updateTimeAndLivestreamBlockUI(final Context context, long blockStart, long blockEnd,
        boolean hasLivestream, View backgroundView, TextView titleView, TextView subtitleView,
        CharSequence subtitle) {/*from  w w  w.j a va  2s  . com*/
    long currentTimeMillis = getCurrentTime(context);

    boolean past = (currentTimeMillis > blockEnd && currentTimeMillis < CONFERENCE_END_MILLIS);
    boolean present = (blockStart <= currentTimeMillis && currentTimeMillis <= blockEnd);

    final Resources res = context.getResources();
    if (backgroundView != null) {
        backgroundView.setBackgroundColor(past ? res.getColor(R.color.past_background_color) : 0);
    }

    if (titleView != null) {
        titleView.setTypeface(Typeface.SANS_SERIF, past ? Typeface.NORMAL : Typeface.BOLD);
    }

    if (subtitleView != null) {
        boolean empty = true;
        SpannableStringBuilder sb = new SpannableStringBuilder(); // TODO: recycle
        if (subtitle != null) {
            sb.append(subtitle);
            empty = false;
        }

        if (present) {
            if (sNowPlayingText == null) {
                sNowPlayingText = Html.fromHtml(context.getString(R.string.now_playing_badge));
            }
            if (!empty) {
                sb.append("  ");
            }
            sb.append(sNowPlayingText);

            if (hasLivestream) {
                if (sLivestreamNowText == null) {
                    sLivestreamNowText = Html
                            .fromHtml("&nbsp;&nbsp;" + context.getString(R.string.live_now_badge));
                }
                sb.append(sLivestreamNowText);
            }
        } else if (hasLivestream) {
            if (sLivestreamAvailableText == null) {
                sLivestreamAvailableText = Html.fromHtml(context.getString(R.string.live_available_badge));
            }
            if (!empty) {
                sb.append("  ");
            }
            sb.append(sLivestreamAvailableText);
        }

        subtitleView.setText(sb);
    }
}

From source file:eu.iescities.pilot.rovereto.roveretoexplorer.fragments.event.info.EventDetailInfoAdapter.java

@SuppressWarnings("deprecation")
@Override/*from ww  w .j a v a 2s . c  o m*/
public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView,
        ViewGroup parentView) {
    final EventInfoParent parent = this.fragment.parents.get(groupPosition);
    final EventInfoChild child = parent.getChildren().get(childPosition);
    int itemType = getChildType(groupPosition, childPosition);

    Log.i("GROUPVIEW", "************ init child view!! ************ ");
    Log.i("GROUPVIEW", "COUNT: " + countChildViewCall);
    Log.i("GROUPVIEW", "CHILD TEXT: " + child.getText());
    Log.i("GROUPVIEW", "CHILD TYPE: " + child.getType());

    row = convertView;
    if (row == null) {
        // Inflate event_info_child_item.xml file for child rows
        LayoutInflater inflater = (LayoutInflater) this.fragment.context
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        row = inflater.inflate(R.layout.event_info_child_item, parentView, false);
        eventChildViewHolder = new EventInfoChildViewHolder();
        eventChildViewHolder.text = (TextView) row.findViewById(R.id.event_info_attribute_values);
        //         eventChildViewHolder.imgSx = (ImageView) row
        //               .findViewById(R.id.event_info_attribute_value_icon);
        eventChildViewHolder.imgsDx1 = (ImageView) row.findViewById(R.id.event_info_action1);

        eventChildViewHolder.divider = (View) row.findViewById(R.id.event_info_item_divider);

        //this will be added again when it will be possible to cancel/edit the single items
        //         eventChildViewHolder.imgsDx2 = (ImageView) row
        //               .findViewById(R.id.event_info_action2);
        //         eventChildViewHolder.imgsDx3 = (ImageView) row
        //               .findViewById(R.id.event_info_action3);

        row.setTag(eventChildViewHolder);
    } else {
        eventChildViewHolder = (EventInfoChildViewHolder) row.getTag();
    }

    // Get event_info_child_item.xml file elements and set values

    if (child.getTextInBold())
        eventChildViewHolder.text.setTypeface(null, Typeface.BOLD);
    else
        eventChildViewHolder.text.setTypeface(null, Typeface.NORMAL);

    if (!child.getText().contains("http")) {
        eventChildViewHolder.text.setText(child.getText());
    } else {

        if (!child.getText().matches(fragment.getString(R.string.start_url))) {

            Log.i("GROUPVIEW", "make the text part clickable!!!");

            //make the text part clickable
            int i1 = 0;
            int i2 = child.getName().length() - 1;
            eventChildViewHolder.text.setMovementMethod(LinkMovementMethod.getInstance());
            eventChildViewHolder.text.setText(child.getName(), BufferType.SPANNABLE);
            //eventChildViewHolder.text.setAutoLinkMask(Linkify.WEB_URLS);
            //Linkify.addLinks(eventChildViewHolder.text, Linkify.WEB_URLS);
            //String s = "<a href=\" + child.getText() + \">Website</a>";
            //eventChildViewHolder.text.setText(Html.fromHtml(s));

            Spannable mySpannable = (Spannable) eventChildViewHolder.text.getText();
            ClickableSpan myClickableSpan = new ClickableSpan() {
                @Override
                public void onClick(View widget) {
                    //               Toast.makeText(fragment.context,
                    //                     "Open browser ofr url: " + child.getText(),
                    //                     Toast.LENGTH_LONG).show(); 
                    String url = child.getText();
                    Intent i = new Intent(Intent.ACTION_VIEW);
                    i.setData(Uri.parse(url));
                    fragment.context.startActivity(i);

                }
            };

            //         row.setFocusable(true);
            //         row.setFocusableInTouchMode(true);

            mySpannable.setSpan(myClickableSpan, i1, i2, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

            //         eventChildViewHolder.text.setText(Html.fromHtml(child.getText()));
            //         eventChildViewHolder.text.setMovementMethod(LinkMovementMethod.getInstance());
        } else
            eventChildViewHolder.text.setText(child.getName());
    }

    if (child.getName().equals("Description")) {
        //Log.i("EVENT", "EventDetailInfoAdapter --> set description to html!!");
        eventChildViewHolder.text.setText(Html.fromHtml(child.getText()));
        eventChildViewHolder.text.setPadding(10, 10, 0, 0);
    }

    // set icon on the left side
    //      if (child.getLeftIconId() != -1) {
    //         Log.i("GROUPVIEW", "CHILD SX ICON ID: " + child.getLeftIconId());
    //         eventChildViewHolder.imgSx.setVisibility(View.VISIBLE);
    //         eventChildViewHolder.imgSx.setImageResource(child.getLeftIconId());
    //
    //         Log.i("IMAGE", "IMG CHILD NAME: "
    //               + child.getText());
    //
    //         Log.i("IMAGE", "IMG ICON WIDTH: "
    //               + eventChildViewHolder.imgSx.getWidth());
    //         
    //      } else {
    //         Log.i("GROUPVIEW", "CHILD SX ICON -1");
    //         if ( (child.getName().equals("email")) || (child.getName().equals("tel")) ){
    //            Log.i("GROUPVIEW", "CHILD NAME: " + child.getName());
    //            eventChildViewHolder.imgSx.setVisibility(View.INVISIBLE);
    //            eventChildViewHolder.text.setPadding(10, 0, 0, 0);
    //         }
    //         else{
    //            eventChildViewHolder.imgSx.setVisibility(View.GONE);
    //            eventChildViewHolder.text.setPadding(10, 10, 0, 0);
    //         }
    //         
    //      }

    // set icon on the left side
    if (child.getLeftIconId() != -1) {
        Log.i("GROUPVIEW", "CHILD SX ICON ID: " + child.getLeftIconId());
        eventChildViewHolder.text.setCompoundDrawablesWithIntrinsicBounds(child.getLeftIconId(), 0, 0, 0);
    } else
        eventChildViewHolder.text.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0);

    // set icons on the right side for the items of type 1 (telefono, email)
    if ((child.getRightIconIds() != null) && (child.getType() == 1)) {
        Log.i("GROUPVIEW", "CHILD DX1 ICON ID: " + child.getRightIconIds()[0]);

        eventChildViewHolder.text.setTypeface(null, Typeface.BOLD);

        eventChildViewHolder.imgsDx1.setVisibility(View.VISIBLE);
        eventChildViewHolder.imgsDx1.setImageResource(child.getRightIconIds()[0]);
        eventChildViewHolder.imgsDx1
                .setOnClickListener(new ChildAddIconClickListener(this.fragment.context, child));
    } else {
        Log.i("GROUPVIEW", "CHILD DX1 ICON NULL");
        eventChildViewHolder.imgsDx1.setVisibility(View.INVISIBLE);
    }

    //set divider line height and color
    eventChildViewHolder.divider.setBackgroundColor(fragment.getResources().getColor(child.getDividerColor()));
    eventChildViewHolder.divider.setLayoutParams(
            new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, child.getDividerHeight()));

    // set icons on the right side for the items of type 0 (single values)
    if ((child.getRightIconIds() != null) && (child.getType() == 0)) {
        Log.i("GROUPVIEW", "CHILD DX1 ICON ID: " + child.getRightIconIds()[0]);
        int iconsNumb = child.getRightIconIds().length;
        Log.i("GROUPVIEW", "ICON NUMMBER: " + iconsNumb);
        eventChildViewHolder.imgsDx1.setVisibility(View.VISIBLE);
        eventChildViewHolder.imgsDx1.setImageResource(child.getRightIconIds()[0]);
        eventChildViewHolder.imgsDx1
                .setOnClickListener(new ChildActionIconClickListener(this.fragment.context, child));
        //this will be added when cancel/edit for single item will be possible
        //         eventChildViewHolder.imgsDx2.setVisibility(View.VISIBLE);
        //         eventChildViewHolder.imgsDx2.setImageResource(child
        //               .getRightIconIds()[1]);
        //         if (iconsNumb == 3)
        //            eventChildViewHolder.imgsDx3.setVisibility(View.VISIBLE);
        //         eventChildViewHolder.imgsDx3.setImageResource(child
        //               .getRightIconIds()[2]);

    } else {
        Log.i("GROUPVIEW", "CHILD DX1 ICON NULL");
        eventChildViewHolder.imgsDx1.setVisibility(View.INVISIBLE);

        //this will be added when cancel/edit for single item will be possible
        //         eventChildViewHolder.imgsDx2.setVisibility(View.INVISIBLE);
        //         eventChildViewHolder.imgsDx3.setVisibility(View.INVISIBLE);
    }

    //      Log.i("GROUPVIEW", "child view: group  POS: " + groupPosition + "!!");
    //      Log.i("GROUPVIEW", "child view: child POS: " + childPosition + "!!");

    countChildViewCall++;

    return row;
}

From source file:me.futuretechnology.util.ui.TitlePageIndicator.java

public TitlePageIndicator(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    if (isInEditMode()) {
        return;//from w w  w .  jav a  2  s.co m
    }

    // TODO clean this up
    // Load defaults from resources
    Resources res = getResources();
    int defaultFooterColor = res.getColor(R.color.default_title_indicator_footer_color);
    float defaultFooterLineHeight = res.getDimension(R.dimen.default_title_indicator_footer_line_height);
    float defaultFooterIndicatorHeight = res
            .getDimension(R.dimen.default_title_indicator_footer_indicator_height);
    float defaultFooterIndicatorUnderlinePadding = res
            .getDimension(R.dimen.default_title_indicator_footer_indicator_underline_padding);
    float defaultFooterPadding = res.getDimension(R.dimen.default_title_indicator_footer_padding);
    int defaultSelectedColor = res.getColor(R.color.default_title_indicator_selected_color);
    boolean defaultSelectedBold = res.getBoolean(R.bool.default_title_indicator_selected_bold);
    int defaultTextColor = res.getColor(R.color.default_title_indicator_text_color);
    float defaultTextSize = res.getDimension(R.dimen.default_title_indicator_text_size);
    float defaultTitlePadding = res.getDimension(R.dimen.default_title_indicator_title_padding);
    float defaultClipPadding = res.getDimension(R.dimen.default_title_indicator_clip_padding);
    float defaultTopPadding = res.getDimension(R.dimen.default_title_indicator_top_padding);

    // Retrieve styles attributes
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.TitlePageIndicator, defStyle, 0);

    // Retrieve the colors to be used for this view and apply them.
    mFooterLineHeight = a.getDimension(R.styleable.TitlePageIndicator_footerLineHeight,
            defaultFooterLineHeight);
    mFooterIndicatorHeight = a.getDimension(R.styleable.TitlePageIndicator_footerIndicatorHeight,
            defaultFooterIndicatorHeight);
    mFooterIndicatorUnderlinePadding = a.getDimension(
            R.styleable.TitlePageIndicator_footerIndicatorUnderlinePadding,
            defaultFooterIndicatorUnderlinePadding);
    mFooterPadding = a.getDimension(R.styleable.TitlePageIndicator_footerPadding, defaultFooterPadding);
    mTopPadding = a.getDimension(R.styleable.TitlePageIndicator_topPadding, defaultTopPadding);
    mTitlePadding = a.getDimension(R.styleable.TitlePageIndicator_titlePadding, defaultTitlePadding);
    mClipPadding = a.getDimension(R.styleable.TitlePageIndicator_clipPadding, defaultClipPadding);
    mColorSelected = a.getColor(R.styleable.TitlePageIndicator_selectedColor, defaultSelectedColor);
    mColorText = a.getColor(R.styleable.TitlePageIndicator_textColor, defaultTextColor);
    mBoldText = a.getBoolean(R.styleable.TitlePageIndicator_selectedBold, defaultSelectedBold);

    float textSize = a.getDimension(R.styleable.TitlePageIndicator_textSize, defaultTextSize);
    int footerColor = a.getColor(R.styleable.TitlePageIndicator_footerColor, defaultFooterColor);
    mPaintText.setTextSize(textSize);
    mPaintText.setAntiAlias(true);
    mPaintText.setDither(true);
    mPaintText.setTypeface(Typeface.create("sans-serif-condensed", Typeface.NORMAL));
    mPaintFooterLine.setStyle(Paint.Style.FILL_AND_STROKE);
    // noinspection SuspiciousNameCombination
    mPaintFooterLine.setStrokeWidth(mFooterLineHeight);
    mPaintFooterLine.setColor(footerColor);
    mPaintFooterIndicator.setDither(true);

    // http://code.google.com/p/android/issues/detail?id=24873
    // bug when enabling hardware acceleration

    // workaround #1: disable hw acceleration => the drawing will be rough
    // setLayerType(View.LAYER_TYPE_SOFTWARE, mPaintFooterIndicator);

    // workaround #2: avoid using 0 as stroke width => the drawing will be smooth as butter
    mPaintFooterIndicator.setStrokeWidth(1);

    mPaintFooterIndicator.setStyle(Paint.Style.FILL_AND_STROKE);
    mPaintFooterIndicator.setColor(footerColor);

    a.recycle();

    ViewConfiguration configuration = ViewConfiguration.get(context);
    mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration);
}

From source file:de.hackerspacebremen.fragments.StatusFragment.java

public void onEvent(final RefreshEvent event) {
    if (statusAnimation != null) {
        statusAnimation.start();/*from   ww w .  j a va 2 s .co  m*/
    }
    if (messageAnimation != null) {
        messageAnimation.start();
    }
    StatusViewHolder.get().messageBlock.setVisibility(RelativeLayout.GONE);
    StatusViewHolder.get().imgStatus.setVisibility(ImageView.VISIBLE);
    StatusViewHolder.get().imgConnErr.setVisibility(ImageView.GONE);
    final TextView text = StatusViewHolder.get().statusMessage;
    text.setTypeface(null, Typeface.NORMAL);
    text.setText(getString(R.string.fetch_status));
    final TextView messageText = StatusViewHolder.get().messageText;
    messageText.setText(getString(R.string.fetch_message));
    final TextView messageLabel = StatusViewHolder.get().messageLabel;
    messageLabel.setVisibility(TextView.GONE);
    startStatusCommunication();
}

From source file:com.nma.util.sdcardtrac.SearchableActivity.java

public static int getTextHeight(Context context, CharSequence text, int textSize, int deviceWidth) { //, Typeface typeface,int padding) {
    TextView textView = new TextView(context);
    textView.setPadding(0, 0, 0, 0);/*from   w  w  w  .  jav a 2s.  c om*/
    textView.setTypeface(Typeface.defaultFromStyle(Typeface.NORMAL));
    textView.setText(text, TextView.BufferType.SPANNABLE);
    textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize);
    int widthMeasureSpec = View.MeasureSpec.makeMeasureSpec(deviceWidth, View.MeasureSpec.AT_MOST);
    int heightMeasureSpec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
    textView.measure(widthMeasureSpec, heightMeasureSpec);
    return textView.getMeasuredHeight();
}

From source file:org.crossconnect.bible.activity.MainActivity.java

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

    setContentView(R.layout.activity_main);

    mTabHost = (TabHost) findViewById(android.R.id.tabhost);
    mTabHost.setup();//  w w w. j a  v  a  2 s.c om

    mTabHost.getTabWidget().setDividerDrawable(R.drawable.tab_divider);

    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setOffscreenPageLimit(3);
    mTabsAdapter = new TabsAdapter(this, mTabHost, mViewPager);

    //Add top menu icons into the seperate list 
    resource_top_icons = new ArrayList<ImageButton>();
    resource_top_icons.add((ImageButton) findViewById(R.id.menu_button_churches));
    resource_top_icons.add((ImageButton) findViewById(R.id.menu_button_browse_resources));

    bible_text_top_icons = new ArrayList<ImageButton>();
    //        bible_text_top_icons.add((ImageButton) findViewById(R.id.menu_button_tabs));
    bible_text_top_icons.add((ImageButton) findViewById(R.id.menu_button_windows));

    audio_top_icons = new ArrayList<ImageButton>();
    audio_top_icons.add((ImageButton) findViewById(R.id.menu_button_audio));
    //        audio_top_icons.add((ImageButton) findViewById(R.id.menu_button_browse_audio));

    notes_top_icons = new ArrayList<ImageButton>();
    notes_top_icons.add((ImageButton) findViewById(R.id.menu_button_notes));
    notes_top_icons.add((ImageButton) findViewById(R.id.menu_button_notes_lock));

    hideAllIcons();

    //Load last opened verse
    bibleText = Utils.loadBibleText(getSharedPreferences("APP SETTINGS", Context.MODE_PRIVATE));

    //Setup listeners for top menu icons

    //Go to notes browsing view
    ((ImageButton) findViewById(R.id.menu_button_notes)).setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            saveCurrentTab();
            Intent intent = new Intent(MainActivity.this, NotesActivity.class);
            intent.putExtra("Translation", bibleText.getTranslation().getInitials());
            startActivityForResult(intent, NOTES_SELECT_CODE);
        }
    });

    ((ImageButton) findViewById(R.id.menu_button_churches)).setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = new Intent(MainActivity.this, ResourceRepositoryActivity.class);
            startActivity(intent);
        }
    });

    //        ((ImageButton) findViewById(R.id.menu_button_browse_audio)).setOnClickListener(new OnClickListener(){
    //            @Override
    //            public void onClick(View v) {
    //                Intent intent = new Intent(MainActivity.this, ResourceRepositoryActivity.class);
    //                startActivity(intent);    
    //            }
    //        });

    ((ImageButton) findViewById(R.id.menu_button_audio)).setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = new Intent(MainActivity.this, MusicActivity.class);
            intent.putExtra("Book", bibleText.getBook());
            intent.putExtra("Chapter", bibleText.getChapter());
            intent.putExtra("Translation", bibleText.getTranslation().getInitials());
            startActivity(intent);
        }
    });

    ((ImageButton) findViewById(R.id.menu_button_browse_resources)).setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = new Intent(MainActivity.this, MusicActivity.class);
            intent.putExtra("Book", bibleText.getBook());
            intent.putExtra("Chapter", bibleText.getChapter());
            intent.putExtra("Translation", bibleText.getTranslation().getInitials());
            startActivity(intent);
        }
    });

    headerTitleText = (Button) findViewById(R.id.header_title);
    headerTitleText.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/" + "Ubuntu-R.ttf"),
            Typeface.NORMAL);

    headerTitleText.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {

            saveCurrentTab();

            //TODO: can we pass the actual BibleText?
            Intent intent = new Intent(MainActivity.this, ChapterSelectionActivity.class);
            intent.putExtra("Book", bibleText.getBook());
            intent.putExtra("Chapter", bibleText.getChapter());
            intent.putExtra("Translation", bibleText.getTranslation().getInitials());
            startActivityForResult(intent, CHAPTER_SELECT_CODE);
        }
    });

    final ActionItem settingsAction = new ActionItem();

    settingsAction.setTitle("Settings");
    settingsAction.setIcon(getResources().getDrawable(R.drawable.icon_gear));

    //        final ActionItem accAction = new ActionItem();
    //        
    //        accAction.setTitle("Share");
    //        accAction.setIcon(getResources().getDrawable(R.drawable.icon_gear));
    //        
    //        final ActionItem upAction = new ActionItem();
    //        
    //        upAction.setTitle("Star");
    //        upAction.setIcon(getResources().getDrawable(R.drawable.icon_support));

    findViewById(R.id.title_bar_icon).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            mQuickAction = new QuickActionHorizontal(findViewById(R.id.title_bar_icon));

            settingsAction.setOnClickListener(new OnClickListener() {

                //Copy text action item
                @Override
                public void onClick(View v) {
                    startActivityForResult(new Intent(MainActivity.this, PreferencesFromXml.class),
                            SETTINGS_CODE);
                    mQuickAction.dismiss();
                }
            });

            //              accAction.setOnClickListener(new OnClickListener() {
            //                  @Override
            //                  public void onClick(View v) {
            //                      mQuickAction.dismiss();
            //                  }
            //              });
            //              
            //              upAction.setOnClickListener(new OnClickListener() {
            //                  @Override
            //                  public void onClick(View v) {
            //                      mQuickAction.dismiss();
            //                  }
            //              });

            mQuickAction.addActionItem(settingsAction);
            //              mQuickAction.addActionItem(accAction);
            //              mQuickAction.addActionItem(upAction);

            mQuickAction.setAnimStyle(QuickActionVertical.ANIM_AUTO);

            mQuickAction.setOnDismissListener(new OnDismissListener() {
                @Override
                public void onDismiss() {
                }
            });
            mQuickAction.show();
        }
    });

    //        if (Build.VERSION.SDK_INT >=  HONEYCOMB) {
    //            // If has holo theme use holo themed buttons
    //            mTabsAdapter.addTab(mTabHost.newTabSpec("simple").setIndicator("Simple"), NoteManagerBibleNotesFragment.class, null);
    //            mTabsAdapter.addTab(mTabHost.newTabSpec("simple").setIndicator("Simple"), BookmanagerBibleFragment.class, null);

    //            mTabsAdapter.addTab(mTabHost.newTabSpec("contacts").setIndicator("Contacts"),
    //                LoaderCursorSupport.CursorLoaderListFragment.class, null);
    //            mTabsAdapter.addTab(mTabHost.newTabSpec("custom").setIndicator("Custom"), LoaderCustomSupport.AppListFragment.class, null);
    //            mTabsAdapter.addTab(mTabHost.newTabSpec("throttle").setIndicator("Throttle"),
    //                LoaderThrottleSupport.ThrottledLoaderListFragment.class, null);
    //        } else {
    // Use custom tab style
    setupTab(new TextView(this), AUDIO_TAG, R.drawable.ico_audio, AudioBibleFragment.class);
    setupTab(new TextView(this), BIBLE_TAG, R.drawable.ico_bible, BibleTextFragment.class);
    setupTab(new TextView(this), NOTES_TAG, R.drawable.ico_notes, NotesEditorFragment.class);
    setupTab(new TextView(this), RESOURCE_TAG, R.drawable.ic_action_microphone, ResourceFragment.class);

    //            setupTab(new TextView(this), "Tab 3", LoaderCustomSupport.AppListFragment.class);
    //            setupTab(new TextView(this), "Tab 4", LoaderThrottleSupport.ThrottledLoaderListFragment.class);
    //        }

    //Set starting tab
    if (savedInstanceState != null) {
        mTabHost.setCurrentTabByTag(savedInstanceState.getString(DEFAULT_TAB));
    } else {
        mTabHost.setCurrentTabByTag(BIBLE_TAG);
    }
}

From source file:com.crossconnect.activity.MainActivity.java

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

    setContentView(R.layout.activity_main);

    mTabHost = (TabHost) findViewById(android.R.id.tabhost);
    mTabHost.setup();/*w  w w.  j a  v a  2  s  . c o m*/

    mTabHost.getTabWidget().setDividerDrawable(R.drawable.tab_divider);

    mViewPager = (ViewPager) findViewById(R.id.pager);
    mTabsAdapter = new TabsAdapter(this, mTabHost, mViewPager);

    //Add top menu icons into the seperate list 
    resource_top_icons = new ArrayList<ImageButton>();
    resource_top_icons.add((ImageButton) findViewById(R.id.menu_button_churches));
    resource_top_icons.add((ImageButton) findViewById(R.id.menu_button_browse_resources));

    bible_text_top_icons = new ArrayList<ImageButton>();
    bible_text_top_icons.add((ImageButton) findViewById(R.id.menu_button_tabs));
    bible_text_top_icons.add((ImageButton) findViewById(R.id.menu_button_windows));

    audio_top_icons = new ArrayList<ImageButton>();
    audio_top_icons.add((ImageButton) findViewById(R.id.menu_button_audio));
    //        audio_top_icons.add((ImageButton) findViewById(R.id.menu_button_browse_audio));

    notes_top_icons = new ArrayList<ImageButton>();
    notes_top_icons.add((ImageButton) findViewById(R.id.menu_button_notes));
    notes_top_icons.add((ImageButton) findViewById(R.id.menu_button_notes_lock));

    hideAllIcons();

    //Load last opened verse
    bibleText = Utils.loadBibleText(getSharedPreferences("APP SETTINGS", Context.MODE_PRIVATE));

    //Setup listeners for top menu icons

    //Go to notes browsing view
    ((ImageButton) findViewById(R.id.menu_button_notes)).setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = new Intent(MainActivity.this, NotesActivity.class);
            intent.putExtra("Translation", bibleText.getTranslation().getInitials());
            startActivityForResult(intent, NOTES_SELECT_CODE);
        }
    });

    ((ImageButton) findViewById(R.id.menu_button_churches)).setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = new Intent(MainActivity.this, ResourceRepositoryActivity.class);
            startActivity(intent);
        }
    });

    //        ((ImageButton) findViewById(R.id.menu_button_browse_audio)).setOnClickListener(new OnClickListener(){
    //            @Override
    //            public void onClick(View v) {
    //                Intent intent = new Intent(MainActivity.this, ResourceRepositoryActivity.class);
    //                startActivity(intent);    
    //            }
    //        });

    ((ImageButton) findViewById(R.id.menu_button_audio)).setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = new Intent(MainActivity.this, MusicActivity.class);
            intent.putExtra("Book", bibleText.getBook());
            intent.putExtra("Chapter", bibleText.getChapter());
            intent.putExtra("Translation", bibleText.getTranslation().getInitials());
            startActivity(intent);
        }
    });

    ((ImageButton) findViewById(R.id.menu_button_browse_resources)).setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = new Intent(MainActivity.this, MusicActivity.class);
            intent.putExtra("Book", bibleText.getBook());
            intent.putExtra("Chapter", bibleText.getChapter());
            intent.putExtra("Translation", bibleText.getTranslation().getInitials());
            startActivity(intent);
        }
    });

    headerTitleText = (Button) findViewById(R.id.header_title);
    headerTitleText.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/" + "Ubuntu-R.ttf"),
            Typeface.NORMAL);

    headerTitleText.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {

            Editor editor = getSharedPreferences("APP SETTINGS", Context.MODE_PRIVATE).edit();
            editor.putString(SharedPreferencesHelper.CURRENT_TAB, mTabHost.getCurrentTabTag());
            editor.commit();

            //TODO: can we pass the actual BibleText?
            Intent intent = new Intent(MainActivity.this, ChapterSelectionActivity.class);
            intent.putExtra("Book", bibleText.getBook());
            intent.putExtra("Chapter", bibleText.getChapter());
            intent.putExtra("Translation", bibleText.getTranslation().getInitials());
            startActivityForResult(intent, CHAPTER_SELECT_CODE);
        }
    });

    final ActionItem settingsAction = new ActionItem();

    settingsAction.setTitle("Settings");
    settingsAction.setIcon(getResources().getDrawable(R.drawable.ic_sysbar_quicksettings));

    final ActionItem accAction = new ActionItem();

    accAction.setTitle("Share");
    accAction.setIcon(getResources().getDrawable(R.drawable.kontak));

    final ActionItem upAction = new ActionItem();

    upAction.setTitle("Star");
    upAction.setIcon(getResources().getDrawable(R.drawable.kontak));

    findViewById(R.id.title_bar_icon).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            mQuickAction = new QuickActionHorizontal(findViewById(R.id.title_bar_icon));

            final String text;

            settingsAction.setOnClickListener(new OnClickListener() {

                //Copy text action item
                @Override
                public void onClick(View v) {
                    startActivityForResult(new Intent(MainActivity.this, PreferencesFromXml.class),
                            SETTINGS_CODE);
                    mQuickAction.dismiss();
                }
            });

            accAction.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View v) {
                    mQuickAction.dismiss();
                }
            });

            upAction.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View v) {
                    mQuickAction.dismiss();
                }
            });

            mQuickAction.addActionItem(settingsAction);
            mQuickAction.addActionItem(accAction);
            mQuickAction.addActionItem(upAction);

            mQuickAction.setAnimStyle(QuickActionVertical.ANIM_AUTO);

            mQuickAction.setOnDismissListener(new OnDismissListener() {
                @Override
                public void onDismiss() {
                }
            });
            mQuickAction.show();
        }
    });

    //        if (Build.VERSION.SDK_INT >=  HONEYCOMB) {
    //            // If has holo theme use holo themed buttons
    //            mTabsAdapter.addTab(mTabHost.newTabSpec("simple").setIndicator("Simple"), NoteManagerBibleNotesFragment.class, null);
    //            mTabsAdapter.addTab(mTabHost.newTabSpec("simple").setIndicator("Simple"), BookmanagerBibleFragment.class, null);

    //            mTabsAdapter.addTab(mTabHost.newTabSpec("contacts").setIndicator("Contacts"),
    //                LoaderCursorSupport.CursorLoaderListFragment.class, null);
    //            mTabsAdapter.addTab(mTabHost.newTabSpec("custom").setIndicator("Custom"), LoaderCustomSupport.AppListFragment.class, null);
    //            mTabsAdapter.addTab(mTabHost.newTabSpec("throttle").setIndicator("Throttle"),
    //                LoaderThrottleSupport.ThrottledLoaderListFragment.class, null);
    //        } else {
    // Use custom tab style
    setupTab(new TextView(this), AUDIO_TAG, R.drawable.ico_audio, AudioBibleFragment.class);
    setupTab(new TextView(this), BIBLE_TAG, R.drawable.ico_bible, BibleTextFragment.class);
    setupTab(new TextView(this), NOTES_TAG, R.drawable.ico_notes, NotesEditorFragment.class);
    setupTab(new TextView(this), RESOURCE_TAG, R.drawable.ic_action_microphone, ResourceFragment.class);

    //            setupTab(new TextView(this), "Tab 3", LoaderCustomSupport.AppListFragment.class);
    //            setupTab(new TextView(this), "Tab 4", LoaderThrottleSupport.ThrottledLoaderListFragment.class);
    //        }

    //Set starting tab
    if (savedInstanceState != null) {
        mTabHost.setCurrentTabByTag(savedInstanceState.getString(DEFAULT_TAB));
    } else {
        mTabHost.setCurrentTabByTag(BIBLE_TAG);
    }
}

From source file:com.facebook.react.views.textinput.ReactTextInputManager.java

/**
/* This code was taken from the method setFontWeight of the class ReactTextShadowNode
/* TODO: Factor into a common place they can both use
*//*from w w  w .  j a v a2 s  .c om*/
@ReactProp(name = ViewProps.FONT_WEIGHT)
public void setFontWeight(ReactEditText view, @Nullable String fontWeightString) {
    int fontWeightNumeric = fontWeightString != null ? parseNumericFontWeight(fontWeightString) : -1;
    int fontWeight = UNSET;
    if (fontWeightNumeric >= 500 || "bold".equals(fontWeightString)) {
        fontWeight = Typeface.BOLD;
    } else if ("normal".equals(fontWeightString) || (fontWeightNumeric != -1 && fontWeightNumeric < 500)) {
        fontWeight = Typeface.NORMAL;
    }
    Typeface currentTypeface = view.getTypeface();
    if (currentTypeface == null) {
        currentTypeface = Typeface.DEFAULT;
    }
    if (fontWeight != currentTypeface.getStyle()) {
        view.setTypeface(currentTypeface, fontWeight);
    }
}

From source file:com.sourcey.materiallogindemo.view.SlidingTabLayout.java

private void populateTabStrip() {
    final PagerAdapter adapter = mViewPager.getAdapter();
    final OnClickListener tabClickListener = new TabClickListener();

    for (int i = 0; i < adapter.getCount(); i++) {
        View tabView = null;/*from www.  ja v a 2  s .  co  m*/
        TextView tabTitleView = null;

        if (mTabViewLayoutId != 0) {
            // If there is a custom tab view layout id set, try and inflate it
            tabView = LayoutInflater.from(getContext()).inflate(mTabViewLayoutId, mTabStrip, false);
            tabTitleView = (TextView) tabView.findViewById(mTabViewTextViewId);
        }

        if (tabView == null) {
            tabView = createDefaultTabView(getContext());
        }

        if (tabTitleView == null && TextView.class.isInstance(tabView)) {
            tabTitleView = (TextView) tabView;
        }

        if (mDistributeEvenly) {
            LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) tabView.getLayoutParams();
            lp.width = 0;
            lp.weight = 1;
        }

        tabTitleView.setText(adapter.getPageTitle(i));
        tabView.setOnClickListener(tabClickListener);
        String desc = mContentDescriptions.get(i, null);
        if (desc != null) {
            tabView.setContentDescription(desc);
        }

        mTabStrip.addView(tabView);
        if (i == mViewPager.getCurrentItem()) {
            tabView.setSelected(true);
        }
        tabTitleView.setTextColor(getResources().getColorStateList(R.color.white));
        tabTitleView.setTextSize(12);
        tabTitleView.setTypeface(Typeface.create("sans-serif", Typeface.NORMAL));
    }
}

From source file:org.stockchart.core.Appearance.java

static int fontStyleToTypefaceConstant(FontStyle fs) {
    switch (fs) {
    case BOLD:/*from w ww.j av  a2s .  c  o  m*/
        return Typeface.BOLD;
    case ITALIC:
        return Typeface.ITALIC;
    case BOLD_ITALIC:
        return Typeface.BOLD_ITALIC;
    case NORMAL:
        return Typeface.NORMAL;
    }

    return -1;
}