@AfterViews
 void crateData() {
   this.titleButton.setText("用户登录");
   this.titleButton.setVisibility(View.VISIBLE);
   this.rightButton.setVisibility(View.INVISIBLE);
   this.backButton.setVisibility(View.VISIBLE);
   this.backButton.setText("返回");
   this.backButton.setTextColor(Color.WHITE);
   SpannableString span = new SpannableString(this.registerButton.getText());
   ForegroundColorSpan fgcs = new ForegroundColorSpan(getResources().getColor(R.color.second_red));
   span.setSpan(fgcs, span.length() - 2, span.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
   this.registerButton.setText(span);
   mAutoCheck.setOnClickListener(
       new OnClickListener() {
         @Override
         public void onClick(View v) {
           auto = !auto;
           mAutoCheck.setChecked(auto);
         }
       });
   mUser = User.lastLoginUser(mContext);
   if (mUser == null) {
     mUser = new User();
     mUser.setUserName("");
     mUser.setPassword("");
   } else {
   }
   initUI();
   initData();
 }
Beispiel #2
0
  @Override
  public void onLocationChanged(Location location) {
    if (location.hasAccuracy()) {
      SpannableString s = new SpannableString(String.format("%.0f", location.getAccuracy()) + "m");
      s.setSpan(new RelativeSizeSpan(0.75f), s.length() - 1, s.length(), 0);
      accuracy.setText(s);

      if (firstfix) {
        status.setText("");
        fab.setVisibility(View.VISIBLE);
        if (!data.isRunning() && !maxSpeed.getText().equals("")) {
          refresh.setVisibility(View.VISIBLE);
        }
        firstfix = false;
      }
    } else {
      firstfix = true;
    }

    if (location.hasSpeed()) {
      progressBarCircularIndeterminate.setVisibility(View.GONE);
      SpannableString s =
          new SpannableString(String.format("%.0f", location.getSpeed() * 3.6) + "km/h");
      s.setSpan(new RelativeSizeSpan(0.25f), s.length() - 4, s.length(), 0);
      currentSpeed.setText(s);
    }
  }
 /** 抵用券显示样式 */
 public static SpannableString getVoucherPrice(
     Context context, double voucher, double miniAmount) {
   StringBuilder builder = new StringBuilder();
   int textOrange = context.getResources().getColor(android.R.color.holo_red_light);
   int textGray = context.getResources().getColor(android.R.color.darker_gray);
   SpannableString string;
   if (miniAmount > 0) {
     builder
         .append("满")
         .append(handleDouble(miniAmount))
         .append("元减")
         .append(handleDouble(voucher))
         .append("元");
     int index = builder.indexOf("元") + 1;
     string = new SpannableString(builder);
     /*改变文字的颜色*/
     int size = string.length();
     string.setSpan(new ForegroundColorSpan(textGray), 0, 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
     string.setSpan(
         new ForegroundColorSpan(textOrange), 1, index, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
     string.setSpan(
         new ForegroundColorSpan(textGray), index, index + 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
     string.setSpan(
         new ForegroundColorSpan(textOrange), index + 1, size, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
   } else {
     builder.append("立减").append(handleDouble(voucher)).append("元");
     string = new SpannableString(builder);
     /*改变文字的颜色*/
     int size = string.length();
     string.setSpan(new ForegroundColorSpan(textGray), 0, 2, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
     string.setSpan(
         new ForegroundColorSpan(textOrange), 2, size, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
   }
   return string;
 }
Beispiel #4
0
 private SpannableString generateCenterText() {
   SpannableString s = new SpannableString("Food Waste\\ndistribution");
   s.setSpan(new RelativeSizeSpan(1.6f), 0, 14, 0);
   s.setSpan(new ForegroundColorSpan(ColorTemplate.VORDIPLOM_COLORS[0]), 0, 14, 0);
   s.setSpan(new RelativeSizeSpan(1.4f), 25, s.length(), 0);
   s.setSpan(new ForegroundColorSpan(ColorTemplate.getHoloBlue()), 25, s.length(), 0);
   return s;
 }
        @Override
        public boolean onTouch(View v, MotionEvent event) {

          Layout layout = ((TextView) v).getLayout();

          int x = (int) event.getX();
          int y = (int) event.getY();
          int offset = 0;
          if (layout != null) {

            int line = layout.getLineForVertical(y);
            offset = layout.getOffsetForHorizontal(line, x);
          }

          TextView tv = (TextView) v;
          SpannableString value = SpannableString.valueOf(tv.getText());

          LinkMovementMethod.getInstance().onTouchEvent(tv, value, event);

          switch (event.getActionMasked()) {
            case MotionEvent.ACTION_DOWN:
              WeburlSpan[] urlSpans = value.getSpans(0, value.length(), WeburlSpan.class);
              boolean find = false;
              int findStart = 0;
              int findEnd = 0;
              for (WeburlSpan urlSpan : urlSpans) {
                int start = value.getSpanStart(urlSpan);
                int end = value.getSpanEnd(urlSpan);
                if (start <= offset && offset <= end) {
                  find = true;
                  findStart = start;
                  findEnd = end;

                  break;
                }
              }

              if (find) {
                BackgroundColorSpan bkcolor = new BackgroundColorSpan(0xff89660f);
                value.setSpan(bkcolor, findStart, findEnd, Spanned.SPAN_INCLUSIVE_INCLUSIVE);
                ((TextView) v).setText(value);
              }

              return find;
            case MotionEvent.ACTION_CANCEL:
            case MotionEvent.ACTION_UP:
              BackgroundColorSpan[] backgroundColorSpans =
                  value.getSpans(0, value.length(), BackgroundColorSpan.class);
              for (BackgroundColorSpan bkcolor : backgroundColorSpans) {
                value.removeSpan(bkcolor);
                ((TextView) v).setText(value);
              }
              break;
          }

          return false;
        }
 protected void setupView() {
   this.rootView = this.res.inflate(getContext(), R.layout.create_order_delivery, null, false);
   this.deliveryLayer = this.rootView.findViewById(R.id.delivery_info_layout);
   this.memoEt = ((EditText) this.rootView.findViewById(R.id.say_something));
   this.memoEt.addTextChangedListener(this.textWatcher);
   this.addressView = ((BasicSingleItem) this.rootView.findViewById(R.id.address));
   this.addressView.setOnClickListener(this);
   SpannableString localSpannableString = new SpannableString("请输入收货人");
   localSpannableString.setSpan(
       new AbsoluteSizeSpan(getResources().getDimensionPixelSize(R.dimen.text_size_17)),
       0,
       localSpannableString.length(),
       33);
   localSpannableString.setSpan(
       new ForegroundColorSpan(getResources().getColor(R.color.text_color_gray)),
       0,
       localSpannableString.length(),
       33);
   Object localObject = new SpannableString("请输入收货地址");
   ((SpannableString) localObject)
       .setSpan(
           new AbsoluteSizeSpan(getResources().getDimensionPixelSize(R.dimen.text_size_17)),
           0,
           ((SpannableString) localObject).length(),
           33);
   ((SpannableString) localObject)
       .setSpan(
           new ForegroundColorSpan(getResources().getColor(R.color.text_color_gray)),
           0,
           ((SpannableString) localObject).length(),
           33);
   SpannableStringBuilder localSpannableStringBuilder = new SpannableStringBuilder();
   localSpannableStringBuilder
       .append(localSpannableString)
       .append("\n")
       .append((CharSequence) localObject);
   this.addressView.setTitle(localSpannableStringBuilder);
   this.deliveryTypeItemView = ((BasicSingleItem) this.rootView.findViewById(R.id.delivery));
   this.deliveryTypeItemView.setOnClickListener(this);
   localSpannableString = new SpannableString("请选择收货方式");
   localSpannableString.setSpan(
       new AbsoluteSizeSpan(getResources().getDimensionPixelSize(R.dimen.text_size_17)),
       0,
       localSpannableString.length(),
       33);
   localSpannableString.setSpan(
       new ForegroundColorSpan(getResources().getColor(R.color.text_color_gray)),
       0,
       localSpannableString.length(),
       33);
   localObject = new SpannableStringBuilder();
   ((SpannableStringBuilder) localObject).append(localSpannableString);
   this.deliveryTypeItemView.setTitle((CharSequence) localObject);
   this.deliveryLayer.setVisibility(8);
 }
Beispiel #7
0
  public boolean update() {
    if (error != null) {
      text.setText(error + "\n" + getContext().getString(R.string.thread_refresh_bar_inactive));
      return false;
    } else {
      ChanThread chanThread = callback.getChanThread();
      if (chanThread == null) {
        return false; // Recyclerview not clearing immediately or view didn't receive
        // onDetachedFromWindow
      }

      boolean update = false;

      String statusText = "";

      if (chanThread.archived) {
        statusText += getContext().getString(R.string.thread_archived) + "\n";
      } else if (chanThread.closed) {
        statusText += getContext().getString(R.string.thread_closed) + "\n";
      }

      if (!chanThread.archived && !chanThread.closed) {
        long time = callback.getTimeUntilLoadMore() / 1000L;
        if (!callback.isWatching()) {
          statusText += getContext().getString(R.string.thread_refresh_bar_inactive) + "\n";
        } else if (time <= 0) {
          statusText += getContext().getString(R.string.thread_refresh_now) + "\n";
        } else {
          statusText += getContext().getString(R.string.thread_refresh_countdown, time) + "\n";
        }
        update = true;
      }

      Post op = chanThread.op;

      Board board = Chan.getBoardManager().getBoardByValue(chanThread.loadable.board);
      if (board != null) {
        SpannableString replies = new SpannableString(op.replies + "R");
        if (op.replies >= board.bumpLimit) {
          replies.setSpan(new StyleSpan(Typeface.ITALIC), 0, replies.length(), 0);
        }
        SpannableString images = new SpannableString(op.images + "I");
        if (op.images >= board.imageLimit) {
          images.setSpan(new StyleSpan(Typeface.ITALIC), 0, images.length(), 0);
        }

        text.setText(
            TextUtils.concat(
                statusText, replies, " / ", images, " / ", String.valueOf(op.uniqueIps) + "P"));
      }

      return update;
    }
  }
  private CharSequence generateInfoCategoryText(String category, double sum) {

    SpannableString categorySpan = new SpannableString(category);
    SpannableString sumSpan = new SpannableString(String.valueOf((float) sum));

    categorySpan.setSpan(new RelativeSizeSpan(1.3f), 0, categorySpan.length(), 0);
    categorySpan.setSpan(new StyleSpan(Typeface.NORMAL), 0, categorySpan.length(), 0);

    sumSpan.setSpan(new RelativeSizeSpan(1.5f), 0, sumSpan.length(), 0);
    sumSpan.setSpan(new StyleSpan(Typeface.ITALIC), 0, sumSpan.length(), 0);

    return TextUtils.concat(categorySpan, "\n", sumSpan);
  }
  private CharSequence generateCenterSpannableDefaultText() {

    SpannableString title = new SpannableString(getString(R.string.default_text_hole));
    SpannableString inTotal = new SpannableString(String.valueOf(this.inTotal));

    title.setSpan(new RelativeSizeSpan(1.5f), 0, title.length(), 0);
    title.setSpan(new StyleSpan(Typeface.NORMAL), 0, title.length(), 0);

    inTotal.setSpan(new RelativeSizeSpan(1.7f), 0, inTotal.length(), 0);
    inTotal.setSpan(new StyleSpan(Typeface.ITALIC), 0, inTotal.length(), 0);

    return TextUtils.concat(title, inTotal);
  }
    @Override
    public View getView(int position, View convertView, ViewGroup group) {
      if (convertView == null) {
        convertView = View.inflate(getActivity(), R.layout.buffer_line, null);
      }

      BufferEvent event = getItem(position);
      BufferEvent prevEvent = (position > 0) ? getItem(position - 1) : null;

      BufferEventItem firstItem = event.getFirstItem();
      BufferEventMessage firstItemMessage = firstItem.getMessage();

      boolean isNewDay = ((prevEvent != null) && (!firstItem.isSameDay(prevEvent.getFirstItem())));
      TextView dayView = (TextView) convertView.findViewById(R.id.day);
      dayView.setVisibility(isNewDay ? View.VISIBLE : View.GONE);
      if (isNewDay) {
        dayView.setText(mDateFormat.format(firstItemMessage.getDate()));
      }

      TextView timestampView = (TextView) convertView.findViewById(R.id.timestamp);
      TextView textView = (TextView) convertView.findViewById(R.id.text);

      Date date = firstItemMessage.getDate();
      if (date != null) {
        timestampView.setText(new SimpleDateFormat("h:mm aa").format(date));
        timestampView.setVisibility(View.VISIBLE);
      } else {
        timestampView.setVisibility(View.GONE);
      }
      CharSequence text = mRenderer.renderEvent(event);
      if ((!(mBuffer instanceof ConsoleBuffer)) && (!(text instanceof SpannableString))) {
        SpannableString span = new SpannableString(text);
        span.setSpan(
            new StyleSpan(Typeface.ITALIC), 0, span.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE);
        span.setSpan(
            new ForegroundColorSpan(Color.GRAY),
            0,
            span.length(),
            Spannable.SPAN_INCLUSIVE_INCLUSIVE);
        textView.setText(span);
      } else {
        textView.setText(text);
      }

      boolean highlight = firstItem.isHighlight() && (mBuffer instanceof ChannelBuffer);
      convertView
          .findViewById(R.id.inner)
          .setBackgroundColor(highlight ? mHighlightBgColor : Color.TRANSPARENT);

      return convertView;
    }
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
      if (convertView == null) {
        convertView = inflater.inflate(R.layout.item_main_menu, parent, false);
        convertView.setOnClickListener(sectionClickListener);
      }

      Section section = getItem(position);
      convertView.setSelected(section == currentSection);

      TextView tv = (TextView) convertView.findViewById(R.id.section_text);
      SpannableString sectionTitle = new SpannableString(getString(section.getTitleResId()));
      Drawable sectionIcon = ContextCompat.getDrawable(MainActivity.this, section.getIconResId());
      if (section == currentSection) {
        // Special color for the current section
        sectionTitle.setSpan(
            new ForegroundColorSpan(currentSectionForegroundColor),
            0,
            sectionTitle.length(),
            Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        // We need to mutate the drawable before applying the ColorFilter, or else all the similar
        // drawable instances will be tinted.
        sectionIcon.mutate().setColorFilter(currentSectionForegroundColor, PorterDuff.Mode.SRC_IN);
      }
      tv.setText(sectionTitle);
      TextViewCompat.setCompoundDrawablesRelativeWithIntrinsicBounds(
          tv, sectionIcon, null, null, null);

      return convertView;
    }
 private static void addDetectedValueHeader(
     @NonNull ListView listView,
     @StringRes int labelRes,
     @NonNull String labelKey,
     @NonNull String labelValue,
     @NonNull String value,
     @NonNull Icon icon) {
   final TextView textView =
       (TextView)
           LayoutInflater.from(listView.getContext())
               .inflate(R.layout.edx_selectable_list_item, listView, false);
   {
     final SpannableString labelValueSpan = new SpannableString(labelValue);
     labelValueSpan.setSpan(
         new ForegroundColorSpan(
             listView.getResources().getColor(R.color.edx_grayscale_neutral_dark)),
         0,
         labelValueSpan.length(),
         Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
     textView.setText(
         ResourceUtil.getFormattedString(
             listView.getContext().getResources(), labelRes, labelKey, labelValueSpan));
   }
   Context context = textView.getContext();
   TextViewCompat.setCompoundDrawablesRelativeWithIntrinsicBounds(
       textView,
       new IconDrawable(context, icon)
           .sizeRes(context, R.dimen.edx_base)
           .colorRes(context, R.color.edx_grayscale_neutral_light),
       null,
       null,
       null);
   listView.addHeaderView(textView, new FormOption(labelValue, value), true);
 }
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
      View item = inflater.inflate(R.layout.time_settings_item, null);

      if (position < times.size()) {
        SpannableString ss =
            new SpannableString(
                times.get(position)
                    + " "
                    + getString(R.string.min)
                    + " (+"
                    + increments.get(position)
                    + getString(R.string.secPerMove)
                    + ")");
        ss.setSpan(new ForegroundColorSpan(0xFF000000), 0, 6, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        ss.setSpan(
            new ForegroundColorSpan(0xFF666666),
            6,
            ss.length(),
            Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        ((TextView) item).setText(ss);
      }

      return item;
    }
    @Override
    public View getDropDownView(int position, View convertView, ViewGroup parent) {
      View item = inflater.inflate(R.layout.time_settings_dropdown_item, null);
      item.setMinimumHeight(60);

      if (position >= times.size()) {
        ((CheckedTextView) item).setText(getText(R.string.customTime));
      } else {
        SpannableString ss =
            new SpannableString(
                times.get(position)
                    + " "
                    + getString(R.string.min)
                    + " (+"
                    + increments.get(position)
                    + getString(R.string.secPerMove)
                    + ")");
        ss.setSpan(new ForegroundColorSpan(0xFF000000), 0, 6, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        ss.setSpan(
            new ForegroundColorSpan(0xFF666666),
            6,
            ss.length(),
            Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        ((CheckedTextView) item).setText(ss);
      }

      return item;
    }
Beispiel #15
0
  public static CharSequence getBoldedString(String value) {
    SpannableString spanned = new SpannableString(value);
    spanned.setSpan(
        new StyleSpan(Typeface.BOLD), 0, spanned.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

    return spanned;
  }
 @Override
 public Spannable getStyle(CharSequence param, CharSequence text) {
   SpannableString styled = new SpannableString(text);
   // The torrent tags can be the full url or just the group id
   String p = text.toString();
   if (!p.contains("what.cd")) {
     styled.setSpan(
         new URLSpan("https://what.cd/torrents.php?id=" + text),
         0,
         styled.length(),
         Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
   } else {
     styled.setSpan(new URLSpan(p), 0, styled.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
   }
   return styled;
 }
Beispiel #17
0
  private void setupActionBar() {
    ActionBar actionBar = getActionBar();

    actionBar.setDisplayShowCustomEnabled(true);
    actionBar.setDisplayShowTitleEnabled(false);
    actionBar.setHomeButtonEnabled(false);
    actionBar.setDisplayHomeAsUpEnabled(false);

    LayoutInflater inflator = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View actionBarCustomView = inflator.inflate(R.layout.white_action_bar, null);
    actionBarCustomView.findViewById(R.id.home_icon_container).setVisibility(View.VISIBLE);
    actionBar.setCustomView(actionBarCustomView);

    SpannableString s = new SpannableString(getString(R.string.redeem));
    s.setSpan(
        new TypefaceSpan(
            getApplicationContext(),
            CommonLib.BOLD_FONT_FILENAME,
            getResources().getColor(R.color.white),
            getResources().getDimension(R.dimen.size16)),
        0,
        s.length(),
        Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    TextView title = (TextView) actionBarCustomView.findViewById(R.id.title);

    ((RelativeLayout.LayoutParams)
            actionBarCustomView.findViewById(R.id.back_icon).getLayoutParams())
        .setMargins(width / 40, 0, 0, 0);
    actionBarCustomView.findViewById(R.id.title).setPadding(width / 20, 0, width / 40, 0);
    title.setText(s);
  }
Beispiel #18
0
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    // 1. Create inflater
    LayoutInflater inflater =
        (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    // 2. Get rowView from inflater
    View rowView = inflater.inflate(R.layout.list_item, parent, false);
    // 3. Get the two text view from the rowView
    labelView = (TextView) rowView.findViewById(R.id.anchor_name);
    valueView = (TextView) rowView.findViewById(R.id.client_name);
    descView = (TextView) rowView.findViewById(R.id.campaign_id);

    labelView.setOnClickListener(
        new AnchorListener(
            itemsArrayList.get(position).getAnchorName(),
            itemsArrayList.get(position).getClientName(),
            itemsArrayList.get(position).getAnchorCreationDate(),
            itemsArrayList.get(position).getClientWebsiteAddress(),
            itemsArrayList.get(position).getClientInfo()));
    SpannableString content = new SpannableString(itemsArrayList.get(position).getAnchorName());
    content.setSpan(new UnderlineSpan(), 0, content.length(), 0);
    labelView.setText(content);
    // 4. Set the text for textView
    valueView.setText(itemsArrayList.get(position).getClientName());
    descView.setText(itemsArrayList.get(position).getCampaignStatusDescription());
    // 5. return rowView
    return rowView;
  }
Beispiel #19
0
 @Override
 protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   setContentView(R.layout.comment);
   this.CommentList = (ListView) findViewById(R.id.commentpagelistviews);
   this.layoutinflater = LayoutInflater.from(this);
   this.playpostbutton = (ImageButton) findViewById(R.id.commentpageplays);
   Bundle bundle = getIntent().getExtras();
   postid = bundle.getInt("postid");
   player = new MediaPlayer();
   comment(postid);
   imageloader = new ImageLoader(this.getApplicationContext());
   getSupportActionBar().setBackgroundDrawable(new ColorDrawable(Color.parseColor("#F86960")));
   SpannableString s = new SpannableString("Comment");
   s.setSpan(
       new Typefacespan(this, "Roboto-Medium.ttf"),
       0,
       s.length(),
       Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
   getSupportActionBar().setTitle(s);
   getSupportActionBar().setDisplayShowHomeEnabled(true);
   getSupportActionBar().setHomeButtonEnabled(true);
   getSupportActionBar().setIcon(R.drawable.back);
   ImageView view = (ImageView) findViewById(android.R.id.home);
 }
 /** 对spanableString进行正则判断,如果符合要求,则以表情图片代替 */
 public static void dealExpression(
     Context context, SpannableString spannableString, Pattern patten, int start)
     throws Exception {
   Matcher matcher = patten.matcher(spannableString);
   while (matcher.find()) {
     String key = matcher.group();
     Log.d("Key", key);
     if (matcher.start() < start) {
       continue;
     }
     Field field =
         R.drawable.class.getDeclaredField(
             "emoji_" + key.substring(key.indexOf("]") + 1, key.lastIndexOf("[")));
     int resId = Integer.parseInt(field.get(null).toString());
     if (resId != 0) {
       Bitmap bitmap = BitmapFactory.decodeResource(context.getResources(), resId);
       ImageSpan imageSpan = new ImageSpan(bitmap);
       int end = matcher.start() + key.length();
       spannableString.setSpan(
           imageSpan, matcher.start(), end, Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
       if (end < spannableString.length()) {
         dealExpression(context, spannableString, patten, end);
       }
       break;
     }
   }
 }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_highscore);

    /* Use application class to maintain global state. */
    sqaApp = (SimpsonsQuizApp) getApplication();

    // set custom font for ActionBar Title
    SpannableString s = new SpannableString(getString(R.string.title_activity_highscore));
    s.setSpan(
        new TypefaceSpan(this, "Simpsonfont.ttf"),
        0,
        s.length(),
        Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

    if (getActionBar() != null) {
      // Update the action bar title with the TypefaceSpan instance
      getActionBar().setTitle(s);
    }

    layout = (TableLayout) findViewById(R.id.highscore_layout);
    LoadHighscoreTask lht = new LoadHighscoreTask();
    lht.execute();
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_maps);

    SpannableString s = new SpannableString("Pregled svih ruta");
    s.setSpan(
        new TypefaceSpan(this, "Choplin.otf"), 0, s.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

    mToolbar = (Toolbar) findViewById(R.id.toolbar);

    setSupportActionBar(mToolbar);
    getSupportActionBar().setDisplayShowHomeEnabled(true);
    getSupportActionBar().setTitle(s);

    mRecyclerView = (RecyclerView) findViewById(R.id.my_recycler_view);

    LinearLayoutManager llm = new LinearLayoutManager(this);
    mRecyclerView.setLayoutManager(llm);

    NavigationDrawerFragment drawerFragment =
        (NavigationDrawerFragment)
            getSupportFragmentManager().findFragmentById(R.id.fragment_navigation_drawer);
    drawerFragment.setUp(
        R.id.fragment_navigation_drawer, (DrawerLayout) findViewById(R.id.drawer_layout), mToolbar);

    initializeData();
  }
Beispiel #23
0
  @Override
  public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    SpannableString string = new SpannableString("(点击查看示例)");
    string.setSpan(
        new ClickableSpan() {
          @Override
          public void onClick(View widget) {
            if (togglePageListener != null) {
              togglePageListener.onToggleToGifSample();
            }
          }

          @Override
          public void updateDrawState(TextPaint ds) {
            ds.setColor(Color.parseColor("#0000ff"));
            super.updateDrawState(ds);
          }
        },
        0,
        string.length(),
        Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);

    gifIntroTextView.setMovementMethod(LinkMovementMethod.getInstance());
    gifIntroTextView.append(string);
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_full_screen_map);

    SpannableString s = new SpannableString("Pregled obliznjih ruta");
    s.setSpan(
        new TypefaceSpan(this, "Choplin.otf"), 0, s.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

    doubleClickIndicator = false;

    mMarkers = new ArrayList<>();
    buildGoogleApiClient();

    SupportMapFragment mapFragment =
        (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
    mapFragment.getMapAsync(this);

    mGoogleMap = mapFragment.getMap();

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);

    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayShowHomeEnabled(true);
    getSupportActionBar().setTitle(s);

    NavigationDrawerFragment drawerFragment =
        (NavigationDrawerFragment)
            getSupportFragmentManager().findFragmentById(R.id.fragment_navigation_drawer);
    drawerFragment.setUp(
        R.id.fragment_navigation_drawer, (DrawerLayout) findViewById(R.id.drawer_layout), toolbar);
  }
  protected void drawCenterText(Canvas c) {

    SpannableString centerText = mChart.getCenterText();

    if (mChart.isDrawCenterTextEnabled() && centerText != null) {

      PointF center = mChart.getCenterCircleBox();

      float innerRadius =
          mChart.isDrawHoleEnabled() && mChart.isHoleTransparent()
              ? mChart.getRadius() * (mChart.getHoleRadius() / 100f)
              : mChart.getRadius();

      RectF holeRect = mRectBuffer[0];
      holeRect.left = center.x - innerRadius;
      holeRect.top = center.y - innerRadius;
      holeRect.right = center.x + innerRadius;
      holeRect.bottom = center.y + innerRadius;
      RectF boundingRect = mRectBuffer[1];
      boundingRect.set(holeRect);

      float radiusPercent = mChart.getCenterTextRadiusPercent();
      if (radiusPercent > 0.0) {
        boundingRect.inset(
            (boundingRect.width() - boundingRect.width() * radiusPercent) / 2.f,
            (boundingRect.height() - boundingRect.height() * radiusPercent) / 2.f);
      }

      if (!centerText.equals(mCenterTextLastValue) || !boundingRect.equals(mCenterTextLastBounds)) {

        // Next time we won't recalculate StaticLayout...
        mCenterTextLastBounds.set(boundingRect);
        mCenterTextLastValue = centerText;

        float width = mCenterTextLastBounds.width();

        // If width is 0, it will crash. Always have a minimum of 1
        mCenterTextLayout =
            new StaticLayout(
                centerText,
                0,
                centerText.length(),
                mCenterTextPaint,
                (int) Math.max(Math.ceil(width), 1.f),
                Layout.Alignment.ALIGN_CENTER,
                1.f,
                0.f,
                false);
      }

      float layoutHeight = mCenterTextLayout.getHeight();

      c.save();
      c.translate(
          boundingRect.left, boundingRect.top + (boundingRect.height() - layoutHeight) / 2.f);
      mCenterTextLayout.draw(c);
      c.restore();
    }
  }
Beispiel #26
0
 public static void setTitle(ActionBar actionBar, Typeface typeface, String title) {
   if (typeface == null || actionBar == null) {
     Log.e(TAG, "typeface或actionbar为空");
     return;
   }
   SpannableString sp = new SpannableString(title);
   sp.setSpan(new TypefaceSpan(typeface), 0, sp.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
   setTitle(actionBar, sp);
 }
 private void applyFont() {
   SpannableString s = new SpannableString(title);
   s.setSpan(
       new FontTypefaceSpan(this, fonts[new Random().nextInt(fonts.length - 1)]),
       0,
       s.length(),
       Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
   getSupportActionBar().setTitle(s);
 }
  /**
   * 用本函数代替{@link #setText(CharSequence)}
   *
   * @param cs
   */
  public void setMText(CharSequence cs) {
    text = cs;

    obList.clear();
    //	contentList.clear();

    ArrayList<IS> isList = new ArrayList<MTextView.IS>();
    useDefault = false;
    if (cs instanceof SpannableString) {
      SpannableString ss = (SpannableString) cs;
      ImageSpan[] imageSpans = ss.getSpans(0, ss.length(), ImageSpan.class);
      for (int i = 0; i < imageSpans.length; i++) {
        int s = ss.getSpanStart(imageSpans[i]);
        int e = ss.getSpanEnd(imageSpans[i]);
        IS iS = new IS();
        iS.is = imageSpans[i];
        iS.start = s;
        iS.end = e;
        isList.add(iS);
      }
    }

    String str = cs.toString();

    for (int i = 0, j = 0; i < cs.length(); ) {
      if (j < isList.size()) {
        IS is = isList.get(j);
        if (i < is.start) {
          Integer cp = str.codePointAt(i);
          // 支持增补字符
          if (Character.isSupplementaryCodePoint(cp)) {
            i += 2;
          } else {
            i++;
          }

          obList.add(new String(Character.toChars(cp)));

        } else if (i >= is.start) {
          obList.add(is.is);
          j++;
          i = is.end;
        }
      } else {
        Integer cp = str.codePointAt(i);
        if (Character.isSupplementaryCodePoint(cp)) {
          i += 2;
        } else {
          i++;
        }

        obList.add(new String(Character.toChars(cp)));
      }
    }

    requestLayout();
  }
  /**
   * Updates message from the current {@link #mNotification notificiation}.
   *
   * @see #setMessages(CharSequence[])
   * @see #isMessageSecret()
   */
  private void updateMessage() {
    if (isPendingUpdate(PENDING_UPDATE_MESSAGE)) return;
    if (mNotification == null) {
      setMessages(null);
      return;
    }

    final boolean secret = isMessageSecret();

    // Get message text
    if (secret) {
      CharSequence[] messages;
      if (sSecureContentLabelRef == null || (messages = sSecureContentLabelRef.get()) == null) {
        final CharSequence cs = mContext.getString(R.string.privacy_mode_hidden_content);
        final SpannableString ss = new SpannableString(cs);
        Check.getInstance().isTrue(ss.length());
        ss.setSpan(
            new StyleSpan(Typeface.ITALIC),
            0 /* start */,
            ss.length() /* end */,
            Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);

        messages = new CharSequence[] {ss};
        sSecureContentLabelRef = new SoftReference<>(messages);
      }

      setMessages(messages);
    } else {
      CharSequence message;
      if (mBig) {
        if (mNotification.messageTextLines != null) {
          setMessages(mNotification.messageTextLines);
          return;
        }

        message = NullUtils.whileNotNull(mNotification.messageBigText, mNotification.messageText);
      } else {
        message = mNotification.messageText;
      }

      setMessages(TextUtils.isEmpty(message) ? null : new CharSequence[] {message});
    }
  }
Beispiel #30
0
 private void setActionBar() {
   ActionBar actionBar = getSupportActionBar();
   SpannableString text = new SpannableString(getString(R.string.app_name));
   text.setSpan(
       new CustomTypefaceSpan(Typeface.createFromAsset(getAssets(), "fonts/INU____.TTF")),
       0,
       text.length(),
       Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
   actionBar.setTitle(text);
 }