Beispiel #1
0
  /** 状态栏是否可见 */
  public static boolean isTintStatusBarAvailable(Activity activity) {
    boolean isTintStatusBarAvailable = false;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
      Window win = activity.getWindow();
      WindowManager.LayoutParams winParams = win.getAttributes();
      if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && !sHassMIUI6) {
        // check window flags
        int bits = WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS;
        int uiOptions =
            View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                //                        | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                | View.SYSTEM_UI_FLAG_LAYOUT_STABLE;
        if ((winParams.flags & bits) != 0
            && win.getDecorView().getSystemUiVisibility() == uiOptions) {
          isTintStatusBarAvailable = true;
        }
      } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        // check theme attrs
        int[] attrs = {android.R.attr.windowTranslucentStatus};
        TypedArray a = activity.obtainStyledAttributes(attrs);
        try {
          isTintStatusBarAvailable = a.getBoolean(0, false);
        } finally {
          a.recycle();
        }

        // check window flags
        int bits = WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS;
        if ((winParams.flags & bits) != 0) {
          isTintStatusBarAvailable = true;
        }
      }
    }
    return isTintStatusBarAvailable;
  }
Beispiel #2
0
 /**
  * 计算actionbar高度 getActionBarHeight
  *
  * @param activity
  * @return
  * @since 3.5
  */
 @TargetApi(Build.VERSION_CODES.HONEYCOMB)
 public static float getActionBarHeight(Activity activity) {
   if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
     TypedArray actionbarSizeTypedArray =
         activity.obtainStyledAttributes(new int[] {android.R.attr.actionBarSize});
     return actionbarSizeTypedArray.getDimension(0, 0);
   }
   return 0;
 }
 @Override
 public void onInflate(Activity activity, AttributeSet attrs, Bundle savedInstanceState) {
   super.onInflate(activity, attrs, savedInstanceState);
   TypedArray a = activity.obtainStyledAttributes(attrs, R.styleable.ForecastFragment, 0, 0);
   mChoiceMode =
       a.getInt(R.styleable.ForecastFragment_android_choiceMode, AbsListView.CHOICE_MODE_NONE);
   mAutoSelectView = a.getBoolean(R.styleable.ForecastFragment_autoSelectView, false);
   mHoldForTransition = a.getBoolean(R.styleable.ForecastFragment_sharedElementTransitions, false);
   a.recycle();
 }
  @Override
  public void onInflate(Activity activity, AttributeSet attrs, Bundle savedInstanceState) {
    super.onInflate(activity, attrs, savedInstanceState);

    TypedArray a = activity.obtainStyledAttributes(attrs, R.styleable.CustomerThumbnailFragment);

    setHideControls(a.getBoolean(R.styleable.CustomerThumbnailFragment_hide_controls, false));

    a.recycle();
  }
 @Override
 public void onInflate(Activity activity, AttributeSet attrs, Bundle savedInstanceState) {
   super.onInflate(activity, attrs, savedInstanceState);
   TypedArray a =
       activity.obtainStyledAttributes(
           attrs,
           new int[] {R.attr.markasreadDrawable, R.attr.starredDrawable, R.attr.colorAccent});
   markAsReadDrawable = a.getDrawable(0);
   starredDrawable = a.getDrawable(1);
   accentColor = a.getColor(2, activity.getResources().getColor(R.color.owncloudBlueLight));
   a.recycle();
 }
  @Override
  public void onInflate(Activity activity, AttributeSet attrs, Bundle savedInstanceState) {
    super.onInflate(activity, attrs, savedInstanceState);
    TypedArray a =
        activity.obtainStyledAttributes(attrs, R.styleable.com_facebook_place_picker_fragment);

    setRadiusInMeters(
        a.getInt(R.styleable.com_facebook_place_picker_fragment_radius_in_meters, radiusInMeters));
    setResultsLimit(
        a.getInt(R.styleable.com_facebook_place_picker_fragment_results_limit, resultsLimit));
    if (a.hasValue(R.styleable.com_facebook_place_picker_fragment_results_limit)) {
      setSearchText(a.getString(R.styleable.com_facebook_place_picker_fragment_search_text));
    }
    showSearchBox =
        a.getBoolean(R.styleable.com_facebook_place_picker_fragment_show_search_box, showSearchBox);

    a.recycle();
  }
  /**
   * Constructor. Call this in the host activity onCreate method after its content view has been
   * set. You should always create new instances when the host activity is recreated.
   *
   * @param activity The host activity.
   */
  @TargetApi(19)
  public SystemBarTintManager(Activity activity) {

    Window win = activity.getWindow();
    ViewGroup decorViewGroup = (ViewGroup) win.getDecorView();

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
      // check theme attrs
      int[] attrs = {
        android.R.attr.windowTranslucentStatus, android.R.attr.windowTranslucentNavigation
      };
      TypedArray a = activity.obtainStyledAttributes(attrs);
      try {
        mStatusBarAvailable = a.getBoolean(0, false);
        mNavBarAvailable = a.getBoolean(1, false);
      } finally {
        a.recycle();
      }

      // check window flags
      WindowManager.LayoutParams winParams = win.getAttributes();
      int bits = WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS;
      if ((winParams.flags & bits) != 0) {
        mStatusBarAvailable = true;
      }
      bits = WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION;
      if ((winParams.flags & bits) != 0) {
        mNavBarAvailable = true;
      }
    }

    mConfig = new SystemBarConfig(activity, mStatusBarAvailable, mNavBarAvailable);
    // device might not have virtual navigation keys
    if (!mConfig.hasNavigtionBar()) {
      mNavBarAvailable = false;
    }

    if (mStatusBarAvailable) {
      setupStatusBarView(activity, decorViewGroup);
    }
    if (mNavBarAvailable) {
      setupNavBarView(activity, decorViewGroup);
    }
  }
  @Override
  public void onInflate(Activity activity, AttributeSet attrs, Bundle savedInstanceState) {
    super.onInflate(activity, attrs, savedInstanceState);
    TypedArray a = activity.obtainStyledAttributes(attrs, R.styleable.com_facebook_picker_fragment);

    setShowPictures(
        a.getBoolean(R.styleable.com_facebook_picker_fragment_show_pictures, showPictures));
    String extraFieldsString = a.getString(R.styleable.com_facebook_picker_fragment_extra_fields);
    if (extraFieldsString != null) {
      String[] strings = extraFieldsString.split(",");
      setExtraFields(Arrays.asList(strings));
    }

    showTitleBar =
        a.getBoolean(R.styleable.com_facebook_picker_fragment_show_title_bar, showTitleBar);
    titleText = a.getString(R.styleable.com_facebook_picker_fragment_title_text);
    doneButtonText = a.getString(R.styleable.com_facebook_picker_fragment_done_button_text);
    titleBarBackground =
        a.getDrawable(R.styleable.com_facebook_picker_fragment_title_bar_background);
    doneButtonBackground =
        a.getDrawable(R.styleable.com_facebook_picker_fragment_done_button_background);

    a.recycle();
  }
Beispiel #9
0
 public void activityObtainTypedArrayAndLeak(Activity activity) {
   TypedArray array = activity.obtainStyledAttributes(new int[] {});
   ignore(array);
 }
 public static Drawable getThemeUpIndicator(Activity paramActivity) {
   paramActivity = paramActivity.obtainStyledAttributes(THEME_ATTRS);
   Drawable localDrawable = paramActivity.getDrawable(0);
   paramActivity.recycle();
   return localDrawable;
 }
 public static Drawable getThemeUpIndicator(Object info, Activity activity) {
   final TypedArray a = activity.obtainStyledAttributes(THEME_ATTRS);
   final Drawable result = a.getDrawable(0);
   a.recycle();
   return result;
 }
Beispiel #12
0
  public void setPost(final Post post, final ThreadManager manager) {
    this.post = post;
    this.manager = manager;

    highlightQuotesNo = -1;

    boolean boardCatalogMode =
        manager.getLoadable().isBoardMode() || manager.getLoadable().isCatalogMode();

    TypedArray ta =
        context.obtainStyledAttributes(null, R.styleable.PostView, R.attr.post_style, 0);

    if (!isBuild) {
      buildView(context, ta);
      isBuild = true;
    }

    int dateColor = ta.getColor(R.styleable.PostView_date_color, 0);
    int savedReplyColor = ta.getColor(R.styleable.PostView_saved_reply_color, 0);
    int highlightedColor = ta.getColor(R.styleable.PostView_highlighted_color, 0);
    int detailSize = ta.getDimensionPixelSize(R.styleable.PostView_detail_size, 0);

    ta.recycle();

    if (post.hasImage) {
      imageView.setVisibility(View.VISIBLE);
      imageView.setImageUrl(post.thumbnailUrl, ChanApplication.getVolleyImageLoader());
    } else {
      imageView.setVisibility(View.GONE);
      imageView.setImageUrl(null, null);
    }

    CharSequence total = new SpannableString("");

    if (post.subjectSpan != null) {
      total = TextUtils.concat(total, post.subjectSpan);
    }

    if (isList()) {
      CharSequence relativeTime =
          DateUtils.getRelativeTimeSpanString(
              post.time * 1000L, Time.get(), DateUtils.SECOND_IN_MILLIS, 0);
      SpannableString date = new SpannableString("No." + post.no + " " + relativeTime);
      date.setSpan(new ForegroundColorSpan(dateColor), 0, date.length(), 0);
      date.setSpan(new AbsoluteSizeSpan(detailSize), 0, date.length(), 0);

      total =
          TextUtils.concat(
              total,
              post.subjectSpan == null ? "" : "\n",
              post.nameTripcodeIdCapcodeSpan,
              date,
              " ");
    }

    if (!TextUtils.isEmpty(total)) {
      titleView.setText(total);
      titleView.setVisibility(View.VISIBLE);
    } else {
      titleView.setVisibility(View.GONE);
    }

    commentView.setText(post.comment);

    if (manager.getLoadable().isThreadMode()) {
      post.setLinkableListener(this);
      commentView.setMovementMethod(new PostViewMovementMethod());
      commentView.setOnClickListener(this);
    } else {
      post.setLinkableListener(null);
      commentView.setOnClickListener(null);
      commentView.setClickable(false);
      commentView.setMovementMethod(null);
    }

    if (isGrid()
        || ((post.isOP && boardCatalogMode && post.replies > 0) || (post.repliesFrom.size() > 0))) {
      repliesCountView.setVisibility(View.VISIBLE);

      String text = "";

      int count = boardCatalogMode ? post.replies : post.repliesFrom.size();

      if (count != 1) {
        text = count + " " + context.getString(R.string.multiple_replies);
      } else if (count == 1) {
        text = count + " " + context.getString(R.string.one_reply);
      }

      if (boardCatalogMode && post.images > 0) {
        if (post.images != 1) {
          text += ", " + post.images + " " + context.getString(R.string.multiple_images);
        } else {
          text += ", " + post.images + " " + context.getString(R.string.one_image);
        }
      }

      if (manager.getLoadable().isThreadMode()) {
        repliesCountView.setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                manager.showPostReplies(post);
              }
            });
      }

      repliesCountView.setText(text);
    } else {
      repliesCountView.setVisibility(View.GONE);
      repliesCountView.setOnClickListener(null);
    }

    boolean showCountryFlag =
        isList() && !TextUtils.isEmpty(post.country) && !TextUtils.isEmpty(post.countryUrl);
    boolean showStickyIcon = isList() && post.sticky;
    boolean showDeletedIcon = isList() && post.deleted;
    boolean showArchivedIcon = isList() && post.archived;
    boolean showClosedIcon = isList() && post.closed && !showArchivedIcon;

    iconsView.setVisibility(
        (showCountryFlag || showStickyIcon || showClosedIcon || showDeletedIcon || showArchivedIcon)
            ? View.VISIBLE
            : View.GONE);

    stickyView.setVisibility(showStickyIcon ? View.VISIBLE : View.GONE);
    closedView.setVisibility(showClosedIcon ? View.VISIBLE : View.GONE);
    deletedView.setVisibility(showDeletedIcon ? View.VISIBLE : View.GONE);
    archivedView.setVisibility(showArchivedIcon ? View.VISIBLE : View.GONE);
    if (showCountryFlag) {
      countryView.setVisibility(View.VISIBLE);
      countryView.setImageUrl(post.countryUrl, ChanApplication.getVolleyImageLoader());
    } else {
      countryView.setVisibility(View.GONE);
      countryView.setImageUrl(null, null);
    }

    if (post.isSavedReply) {
      full.setBackgroundColor(savedReplyColor);
    } else if (manager.isPostHightlighted(post)) {
      full.setBackgroundColor(highlightedColor);
    } else {
      full.setBackgroundColor(0x00000000);
    }

    if (manager.isPostLastSeen(post)) {
      lastSeen.setVisibility(View.VISIBLE);
    } else {
      lastSeen.setVisibility(View.GONE);
    }
  }