Java Code Examples for com.hippo.yorozuya.LayoutUtils

The following examples show how to use com.hippo.yorozuya.LayoutUtils. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: MHViewer   Source File: GalleryInfoScene.java    License: Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("deprecation")
@Nullable
@Override
public View onCreateView3(LayoutInflater inflater,
        @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.scene_gallery_info, container, false);

    Context context = getContext2();
    AssertUtils.assertNotNull(context);

    mRecyclerView = (EasyRecyclerView) ViewUtils.$$(view, R.id.recycler_view);
    InfoAdapter adapter = new InfoAdapter();
    mRecyclerView.setAdapter(adapter);
    mRecyclerView.setLayoutManager(new LinearLayoutManager(context, RecyclerView.VERTICAL, false));
    LinearDividerItemDecoration decoration = new LinearDividerItemDecoration(
            LinearDividerItemDecoration.VERTICAL,
            AttrResources.getAttrColor(context, R.attr.dividerColor),
            LayoutUtils.dp2pix(context, 1));
    decoration.setPadding(context.getResources().getDimensionPixelOffset(R.dimen.keyline_margin));
    mRecyclerView.addItemDecoration(decoration);
    mRecyclerView.setSelector(Ripple.generateRippleDrawable(context, !AttrResources.getAttrBoolean(context, R.attr.isLightTheme), new ColorDrawable(Color.TRANSPARENT)));
    mRecyclerView.setClipToPadding(false);
    mRecyclerView.setHasFixedSize(true);
    mRecyclerView.setOnItemClickListener(this);
    return view;
}
 
Example 2
Source Project: MHViewer   Source File: Slider.java    License: Apache License 2.0 6 votes vote down vote up
private void updateBubbleSize() {
    int oldWidth = mBubbleWidth;
    int oldHeight = mBubbleHeight;
    mBubbleWidth = (int) Math.max(mBubbleMinWidth,
            Integer.toString(mEnd).length() * mCharWidth + LayoutUtils.dp2pix(mContext, 8));
    mBubbleHeight = (int) Math.max(mBubbleMinHeight,
            mCharHeight + LayoutUtils.dp2pix(mContext, 8));

    if (oldWidth != mBubbleWidth && oldHeight != mBubbleHeight) {
        //noinspection deprecation
        AbsoluteLayout.LayoutParams lp = (AbsoluteLayout.LayoutParams) mBubble.getLayoutParams();
        lp.width = mBubbleWidth;
        lp.height = mBubbleHeight;
        mBubble.setLayoutParams(lp);
    }
}
 
Example 3
Source Project: MHViewer   Source File: Slider.java    License: Apache License 2.0 6 votes vote down vote up
private void updatePopup() {
    int width = getWidth();
    int paddingTop = getPaddingTop();
    int paddingBottom = getPaddingBottom();

    getLocationInWindow(mTemp);

    mPopupWidth = (int) (width - mRadius - mRadius + mBubbleWidth);
    int popupHeight = mBubbleHeight;
    mPopupX = (int) (mTemp[0] + mRadius - (mBubbleWidth / 2));
    mPopupY = (int) (mTemp[1] - popupHeight + paddingTop +
            ((getHeight() - paddingTop - paddingBottom) / 2) -
            mRadius -LayoutUtils.dp2pix(mContext, 2));

    mPopup.update(mPopupX, mPopupY, mPopupWidth, popupHeight, false);
}
 
Example 4
Source Project: MHViewer   Source File: ContentLayout.java    License: Apache License 2.0 6 votes vote down vote up
private void init(ContentLayout contentLayout) {
    mNextPageScrollSize = LayoutUtils.dp2pix(contentLayout.getContext(), 48);

    mProgressView = contentLayout.mProgressView;
    mTipView = contentLayout.mTipView;
    mContentView = contentLayout.mContentView;

    mRefreshLayout = contentLayout.mRefreshLayout;
    mRecyclerView = contentLayout.mRecyclerView;

    Drawable drawable = DrawableManager.getVectorDrawable(getContext(), R.drawable.big_sad_pandroid);
    drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
    mTipView.setCompoundDrawables(null, drawable, null, null);

    mViewTransition = new ViewTransition(mContentView, mProgressView, mTipView);
    mViewTransition.setOnShowViewListener(this);

    mRecyclerView.addOnScrollListener(mOnScrollListener);
    mRefreshLayout.setOnRefreshListener(mOnRefreshListener);

    mTipView.setOnClickListener(refreshListener);
}
 
Example 5
Source Project: Nimingban   Source File: TypeSendFragment.java    License: Apache License 2.0 6 votes vote down vote up
private boolean handleSelectedImageUri(Uri uri) {
    if (uri == null) {
        return false;
    }

    ContentResolver resolver = getContext().getContentResolver();
    String type = resolver.getType(uri);
    if (type == null) {
        type =  MimeTypeMap.getSingleton().getMimeTypeFromExtension(
                FileUtils.getExtensionFromFilename(uri.toString()));
    }

    int maxSize = LayoutUtils.dp2pix(getContext(), 256);
    Bitmap bitmap = BitmapUtils.decodeStream(new UriInputStreamPipe(getContext(), uri), maxSize, maxSize);
    if (bitmap != null) {
        setImagePreview(uri, type, bitmap);
        return true;
    }

    return false;
}
 
Example 6
Source Project: Nimingban   Source File: SortForumsActivity.java    License: Apache License 2.0 6 votes vote down vote up
private void showEyeGuide() {
    new GuideHelper.Builder(this)
            .setColor(ResourcesUtils.getAttrColor(this, R.attr.colorPrimary))
            .setPadding(LayoutUtils.dp2pix(this, 16))
            .setPaddingTop(LayoutUtils.dp2pix(this, 56))
            .setPaddingBottom(LayoutUtils.dp2pix(this, 56))
            .setMessagePosition(Gravity.LEFT)
            .setMessage(getString(R.string.click_eye_icon))
            .setButton(getString(R.string.get_it))
            .setBackgroundColor(0x73000000)
            .setOnDissmisListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    tryShowSecondGuide();
                    Settings.putGuideSortForumsActivity(false);
                }
            }).show();
}
 
Example 7
Source Project: Nimingban   Source File: SortForumsActivity.java    License: Apache License 2.0 6 votes vote down vote up
private void showFourBarsGuide() {
    new GuideHelper.Builder(this)
            .setColor(ResourcesUtils.getAttrColor(this, R.attr.colorPrimary))
            .setPadding(LayoutUtils.dp2pix(this, 16))
            .setPaddingTop(LayoutUtils.dp2pix(this, 56))
            .setPaddingBottom(LayoutUtils.dp2pix(this, 56))
            .setMessagePosition(Gravity.RIGHT)
            .setMessage(getString(R.string.drag_four_bars_exchange))
            .setButton(getString(R.string.get_it))
            .setBackgroundColor(0x73000000)
            .setOnDissmisListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Settings.putGuideSortingFourBars(false);
                }
            }).show();
}
 
Example 8
Source Project: Nimingban   Source File: SortForumsActivity.java    License: Apache License 2.0 6 votes vote down vote up
private void showStarGuide() {
    new GuideHelper.Builder(this)
            .setColor(ResourcesUtils.getAttrColor(this, R.attr.colorPrimary))
            .setPadding(LayoutUtils.dp2pix(this, 16))
            .setPaddingTop(LayoutUtils.dp2pix(this, 56))
            .setPaddingBottom(LayoutUtils.dp2pix(this, 56))
            .setMessagePosition(Gravity.RIGHT)
            .setMessage(getString(R.string.click_star_icon_pin))
            .setButton(getString(R.string.get_it))
            .setBackgroundColor(0x73000000)
            .setOnDissmisListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Settings.putGuidePinningStar(false);
                }
            }).show();
}
 
Example 9
Source Project: Nimingban   Source File: SettingsActivity.java    License: Apache License 2.0 6 votes vote down vote up
@SuppressLint("InflateParams")
public TextFormatDialogHelper() {
    mView = getActivity().getLayoutInflater().inflate(R.layout.dialog_text_format, null);
    mPreview = (FontTextView) mView.findViewById(R.id.preview);
    mFontSize = (Slider) mView.findViewById(R.id.font_size);
    mLineSpacing = (Slider) mView.findViewById(R.id.line_spacing);

    int fontSize = Settings.getFontSize();
    int lineSpacing = Settings.getLineSpacing();

    mPreview.setTextSize(fontSize);
    mPreview.setLineSpacing(LayoutUtils.dp2pix(getActivity(), lineSpacing), 1.0f);
    if (Settings.getFixEmojiDisplay()) {
        mPreview.useCustomTypeface();
    } else {
        mPreview.useOriginalTypeface();
    }

    mFontSize.setProgress(fontSize);
    mLineSpacing.setProgress(lineSpacing);
    mFontSize.setOnSetProgressListener(this);
    mLineSpacing.setOnSetProgressListener(this);
}
 
Example 10
Source Project: Nimingban   Source File: ContentLayout.java    License: Apache License 2.0 6 votes vote down vote up
private void init(ContentLayout contentLayout) {
    mNextPageScrollSize = LayoutUtils.dp2pix(contentLayout.getContext(), 48);

    mProgressView = contentLayout.mProgressView;
    mTipView = contentLayout.mTipView;
    mContentView = contentLayout.mContentView;

    mRefreshLayout = contentLayout.mRefreshLayout;
    mRecyclerView = contentLayout.mRecyclerView;
    mImageView = contentLayout.mImageView;
    mTextView = contentLayout.mTextView;

    mViewTransition = new ViewTransition(mContentView, mProgressView, mTipView);
    mViewTransition.showView(2, false);

    mRecyclerView.addOnScrollListener(mOnScrollListener);
    mRefreshLayout.setOnRefreshListener(mOnRefreshListener);

    mTipView.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            refresh();
        }
    });
}
 
Example 11
Source Project: Nimingban   Source File: DoodleView.java    License: Apache License 2.0 6 votes vote down vote up
private void init(Context context) {
    mBitmapPaint = new Paint(Paint.DITHER_FLAG | Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG);

    mBgColor = ResourcesUtils.getAttrColor(context, R.attr.colorPure);

    mColor = ResourcesUtils.getAttrColor(context, R.attr.colorPureInverse);
    mWidth = LayoutUtils.dp2pix(context, 4);

    mPath = new Path();

    mPaint = new Paint();
    mPaint.setAntiAlias(true);
    mPaint.setDither(true);
    mPaint.setStyle(Paint.Style.STROKE);
    mPaint.setStrokeJoin(Paint.Join.ROUND);
    mPaint.setStrokeCap(Paint.Cap.ROUND);

    mRecycler = new Recycler();
}
 
Example 12
Source Project: Nimingban   Source File: IconListPreference.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    if (convertView == null) {
        convertView = LayoutInflater.from(getContext())
                .inflate(android.R.layout.simple_list_item_single_choice, parent, false);
    }

    TextView textView = (TextView) convertView;
    textView.setText(getEntries()[position]);
    Drawable icon = getContext().getResources().getDrawable(mEntryIcons[position]);
    if (icon != null) {
        icon.setBounds(0, 0, icon.getIntrinsicWidth(), icon.getIntrinsicHeight());
    }
    textView.setCompoundDrawablePadding(LayoutUtils.dp2pix(getContext(), 16));
    textView.setCompoundDrawables(icon, null, null, null);

    return convertView;
}
 
Example 13
Source Project: Nimingban   Source File: Slider.java    License: Apache License 2.0 6 votes vote down vote up
private void updateBubbleSize() {
    int oldWidth = mBubbleWidth;
    int oldHeight = mBubbleHeight;
    mBubbleWidth = (int) Math.max(mBubbleMinWidth,
            Integer.toString(mEnd).length() * mCharWidth + LayoutUtils.dp2pix(mContext, 8));
    mBubbleHeight = (int) Math.max(mBubbleMinHeight,
            mCharHeight + LayoutUtils.dp2pix(mContext, 8));

    if (oldWidth != mBubbleWidth && oldHeight != mBubbleHeight) {
        //noinspection deprecation
        AbsoluteLayout.LayoutParams lp = (AbsoluteLayout.LayoutParams) mBubble.getLayoutParams();
        lp.width = mBubbleWidth;
        lp.height = mBubbleHeight;
        mBubble.setLayoutParams(lp);
    }
}
 
Example 14
Source Project: Nimingban   Source File: Slider.java    License: Apache License 2.0 6 votes vote down vote up
private void updatePopup() {
    int width = getWidth();
    int paddingTop = getPaddingTop();
    int paddingBottom = getPaddingBottom();

    getLocationInWindow(mTemp);

    mPopupWidth = (int) (width - mRadius - mRadius + mBubbleWidth);
    int popupHeight = mBubbleHeight;
    mPopupX = (int) (mTemp[0] + mRadius - (mBubbleWidth / 2));
    mPopupY = (int) (mTemp[1] - popupHeight + paddingTop +
            ((getHeight() - paddingTop - paddingBottom) / 2) -
            mRadius -LayoutUtils.dp2pix(mContext, 2));

    mPopup.update(mPopupX, mPopupY, mPopupWidth, popupHeight, false);
}
 
Example 15
Source Project: EhViewer   Source File: GalleryInfoScene.java    License: Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("deprecation")
@Nullable
@Override
public View onCreateView3(LayoutInflater inflater,
        @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.scene_gallery_info, container, false);

    Context context = getContext2();
    AssertUtils.assertNotNull(context);

    mRecyclerView = (EasyRecyclerView) ViewUtils.$$(view, R.id.recycler_view);
    InfoAdapter adapter = new InfoAdapter();
    mRecyclerView.setAdapter(adapter);
    mRecyclerView.setLayoutManager(new LinearLayoutManager(context, RecyclerView.VERTICAL, false));
    LinearDividerItemDecoration decoration = new LinearDividerItemDecoration(
            LinearDividerItemDecoration.VERTICAL,
            AttrResources.getAttrColor(context, R.attr.dividerColor),
            LayoutUtils.dp2pix(context, 1));
    decoration.setPadding(context.getResources().getDimensionPixelOffset(R.dimen.keyline_margin));
    mRecyclerView.addItemDecoration(decoration);
    mRecyclerView.setSelector(Ripple.generateRippleDrawable(context, !AttrResources.getAttrBoolean(context, R.attr.isLightTheme), new ColorDrawable(Color.TRANSPARENT)));
    mRecyclerView.setClipToPadding(false);
    mRecyclerView.setHasFixedSize(true);
    mRecyclerView.setOnItemClickListener(this);
    return view;
}
 
Example 16
Source Project: EhViewer   Source File: Slider.java    License: Apache License 2.0 6 votes vote down vote up
private void updateBubbleSize() {
    int oldWidth = mBubbleWidth;
    int oldHeight = mBubbleHeight;
    mBubbleWidth = (int) Math.max(mBubbleMinWidth,
            Integer.toString(mEnd).length() * mCharWidth + LayoutUtils.dp2pix(mContext, 8));
    mBubbleHeight = (int) Math.max(mBubbleMinHeight,
            mCharHeight + LayoutUtils.dp2pix(mContext, 8));

    if (oldWidth != mBubbleWidth && oldHeight != mBubbleHeight) {
        //noinspection deprecation
        AbsoluteLayout.LayoutParams lp = (AbsoluteLayout.LayoutParams) mBubble.getLayoutParams();
        lp.width = mBubbleWidth;
        lp.height = mBubbleHeight;
        mBubble.setLayoutParams(lp);
    }
}
 
Example 17
Source Project: EhViewer   Source File: Slider.java    License: Apache License 2.0 6 votes vote down vote up
private void updatePopup() {
    int width = getWidth();
    int paddingTop = getPaddingTop();
    int paddingBottom = getPaddingBottom();

    getLocationInWindow(mTemp);

    mPopupWidth = (int) (width - mRadius - mRadius + mBubbleWidth);
    int popupHeight = mBubbleHeight;
    mPopupX = (int) (mTemp[0] + mRadius - (mBubbleWidth / 2));
    mPopupY = (int) (mTemp[1] - popupHeight + paddingTop +
            ((getHeight() - paddingTop - paddingBottom) / 2) -
            mRadius -LayoutUtils.dp2pix(mContext, 2));

    mPopup.update(mPopupX, mPopupY, mPopupWidth, popupHeight, false);
}
 
Example 18
Source Project: MHViewer   Source File: HostsActivity.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);

  hosts = EhApplication.getHosts(this);
  data = hosts.getAll();

  setContentView(R.layout.activity_hosts);
  setNavigationIcon(R.drawable.v_arrow_left_dark_x24);
  recyclerView = findViewById(R.id.recycler_view);
  tip = findViewById(R.id.tip);
  FloatingActionButton fab = findViewById(R.id.fab);

  adapter = new HostsAdapter();
  recyclerView.setAdapter(adapter);
  recyclerView.setLayoutManager(new LinearLayoutManager(this, RecyclerView.VERTICAL, false));
  LinearDividerItemDecoration decoration = new LinearDividerItemDecoration(
      LinearDividerItemDecoration.VERTICAL,
      AttrResources.getAttrColor(this, R.attr.dividerColor),
      LayoutUtils.dp2pix(this, 1));
  decoration.setShowLastDivider(true);
  recyclerView.addItemDecoration(decoration);
  recyclerView.setSelector(Ripple.generateRippleDrawable(this, !AttrResources.getAttrBoolean(this, R.attr.isLightTheme), new ColorDrawable(Color.TRANSPARENT)));
  recyclerView.setHasFixedSize(true);
  recyclerView.setOnItemClickListener(this);
  recyclerView.setPadding(
      recyclerView.getPaddingLeft(),
      recyclerView.getPaddingTop(),
      recyclerView.getPaddingRight(),
      recyclerView.getPaddingBottom() + getResources().getDimensionPixelOffset(R.dimen.gallery_padding_bottom_fab));

  fab.setOnClickListener(this);

  recyclerView.setVisibility(data.isEmpty() ? View.GONE : View.VISIBLE);
  tip.setVisibility(data.isEmpty() ? View.VISIBLE : View.GONE);
}
 
Example 19
Source Project: MHViewer   Source File: PluginsActivity.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    data = MHPluginManager.Companion.getINSTANCE().plugins();

    setContentView(R.layout.activity_plugins);
    setNavigationIcon(R.drawable.v_arrow_left_dark_x24);
    recyclerView = findViewById(R.id.recycler_view);
    tip = findViewById(R.id.tip);
    FloatingActionButton fab = findViewById(R.id.fab);

    adapter = new PluginsAdapter();
    recyclerView.setAdapter(adapter);
    recyclerView.setLayoutManager(new LinearLayoutManager(this, RecyclerView.VERTICAL, false));
    LinearDividerItemDecoration decoration = new LinearDividerItemDecoration(
            LinearDividerItemDecoration.VERTICAL,
            AttrResources.getAttrColor(this, R.attr.dividerColor),
            LayoutUtils.dp2pix(this, 1));
    decoration.setShowLastDivider(true);
    recyclerView.addItemDecoration(decoration);
    recyclerView.setSelector(Ripple.generateRippleDrawable(this, !AttrResources.getAttrBoolean(this, R.attr.isLightTheme), new ColorDrawable(Color.TRANSPARENT)));
    recyclerView.setHasFixedSize(true);
    recyclerView.setOnItemClickListener(this);
    recyclerView.setPadding(
            recyclerView.getPaddingLeft(),
            recyclerView.getPaddingTop(),
            recyclerView.getPaddingRight(),
            recyclerView.getPaddingBottom() + getResources().getDimensionPixelOffset(R.dimen.gallery_padding_bottom_fab));

    fab.setOnClickListener(this);

    recyclerView.setVisibility(data.isEmpty() ? View.GONE : View.VISIBLE);
    tip.setVisibility(data.isEmpty() ? View.VISIBLE : View.GONE);
}
 
Example 20
Source Project: MHViewer   Source File: GalleryPreviewsScene.java    License: Apache License 2.0 5 votes vote down vote up
@Nullable
@Override
public View onCreateView3(LayoutInflater inflater,
        @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    ContentLayout contentLayout = (ContentLayout) inflater.inflate(
            R.layout.scene_gallery_previews, container, false);
    contentLayout.hideFastScroll();
    mRecyclerView = contentLayout.getRecyclerView();

    Context context = getContext2();
    AssertUtils.assertNotNull(context);
    Resources resources = context.getResources();

    mAdapter = new GalleryPreviewAdapter();
    mRecyclerView.setAdapter(mAdapter);
    int columnWidth = resources.getDimensionPixelOffset(Settings.getThumbSizeResId());
    AutoGridLayoutManager layoutManager = new AutoGridLayoutManager(context, columnWidth);
    layoutManager.setStrategy(AutoGridLayoutManager.STRATEGY_SUITABLE_SIZE);
    mRecyclerView.setLayoutManager(layoutManager);
    mRecyclerView.setClipToPadding(false);
    mRecyclerView.setOnItemClickListener(this);
    int padding = LayoutUtils.dp2pix(context, 4);
    MarginItemDecoration decoration = new MarginItemDecoration(padding, padding, padding, padding, padding);
    mRecyclerView.addItemDecoration(decoration);
    decoration.applyPaddings(mRecyclerView);

    mHelper = new GalleryPreviewHelper();
    contentLayout.setHelper(mHelper);

    // Only refresh for the first time
    if (!mHasFirstRefresh) {
        mHasFirstRefresh = true;
        mHelper.firstRefresh();
    }

    return contentLayout;
}
 
Example 21
Source Project: MHViewer   Source File: ShadowLinearLayout.java    License: Apache License 2.0 5 votes vote down vote up
private void init(Context context) {
    // TODO not only 2dp
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        setOutlineProvider(ViewOutlineProvider.BOUNDS);
        setElevation(LayoutUtils.dp2pix(context, 2));
    } else {
        setShadow((NinePatchDrawable) context.getResources().getDrawable(R.drawable.shadow_2dp)); // TODO draktheme
    }
}
 
Example 22
Source Project: Nimingban   Source File: RecordActivity.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onBindViewHolder(RecordHolder holder, int position) {
    ACRecordRaw raw = mLazyList.get(position);
    String leftText = null;
    switch (raw.getType()) {
        case DB.AC_RECORD_POST:
            leftText = getString(R.string.create_post);
            break;
        case DB.AC_RECORD_REPLY:
            leftText = getString(R.string.reply);
    }
    holder.leftText.setText(leftText);
    holder.rightText.setText(ReadableTime.getDisplayTime(raw.getTime()));
    holder.content.setText(raw.getContent());

    String image = raw.getImage();
    if (!TextUtils.isEmpty(image)) {
        holder.thumb.setVisibility(View.VISIBLE);
        holder.thumb.unload();
        holder.thumb.load(image, "dump", new LocalPathDataContain(image), false);
    } else {
        holder.thumb.setVisibility(View.GONE);
        holder.thumb.unload();
    }

    holder.content.setTextSize(Settings.getFontSize());
    holder.content.setLineSpacing(LayoutUtils.dp2pix(RecordActivity.this, Settings.getLineSpacing()), 1.0f);
    if (Settings.getFixEmojiDisplay()) {
        holder.content.useCustomTypeface();
    } else {
        holder.content.useOriginalTypeface();
    }
}
 
Example 23
Source Project: Nimingban   Source File: ListActivity.java    License: Apache License 2.0 5 votes vote down vote up
private void showLeftDrawerGuide() {
    new GuideHelper.Builder(this)
            .setColor(ResourcesUtils.getAttrColor(this, R.attr.colorPrimary))
            .setPadding(LayoutUtils.dp2pix(this, 16))
            .setMessagePosition(Gravity.LEFT)
            .setMessage(getString(R.string.swipe_right_open_menu))
            .setButton(getString(R.string.get_it))
            .setBackgroundColor(0x73000000)
            .setOnDissmisListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    showRightDrawerGuide();
                }
            }).show();
}
 
Example 24
Source Project: Nimingban   Source File: ListActivity.java    License: Apache License 2.0 5 votes vote down vote up
private void showRightDrawerGuide() {
    new GuideHelper.Builder(this)
            .setColor(ResourcesUtils.getAttrColor(this, R.attr.colorPrimary))
            .setPadding(LayoutUtils.dp2pix(this, 16))
            .setMessagePosition(Gravity.RIGHT)
            .setMessage(getString(R.string.swipe_left_open_forum_list))
            .setButton(getString(R.string.get_it))
            .setBackgroundColor(0x73000000)
            .setOnDissmisListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    showToolbarGuide();
                }
            }).show();
}
 
Example 25
Source Project: Nimingban   Source File: ListActivity.java    License: Apache License 2.0 5 votes vote down vote up
private void showToolbarGuide() {
    new GuideHelper.Builder(this)
            .setColor(ResourcesUtils.getAttrColor(this, R.attr.colorPrimary))
            .setPadding(LayoutUtils.dp2pix(this, 16))
            .setMessagePosition(Gravity.TOP)
            .setMessage(getString(R.string.double_click_toolbar_refresh))
            .setButton(getString(R.string.get_it))
            .setBackgroundColor(0x73000000)
            .setOnDissmisListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Settings.putGuideListActivity(false);
                }
            }).show();
}
 
Example 26
Source Project: Nimingban   Source File: ListActivity.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onClickCommonPosts() {
    AutoWrapLayout layout = new AutoWrapLayout(ListActivity.this);
    final Dialog dialog = new AlertDialog.Builder(this).setView(layout).show();

    List<CommonPost> list = DB.getAllACCommentPost();
    int padding = LayoutUtils.dp2pix(this, 4);
    layout.setPadding(padding, 0, padding, 0);
    LayoutInflater inflater = getLayoutInflater();
    for (final CommonPost cp : list) {
        inflater.inflate(R.layout.item_dialog_comment_post, layout);
        TextView tv = (TextView) layout.getChildAt(layout.getChildCount() - 1);
        tv.setText(cp.name);
        tv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dialog.dismiss();

                Intent intent = new Intent(ListActivity.this, PostActivity.class);
                intent.setAction(PostActivity.ACTION_SITE_ID);
                intent.putExtra(PostActivity.KEY_SITE, ACSite.getInstance().getId());
                intent.putExtra(PostActivity.KEY_ID, cp.id);
                startActivity(intent);
            }
        });
    }
}
 
Example 27
Source Project: Nimingban   Source File: PostActivity.java    License: Apache License 2.0 5 votes vote down vote up
private void showSwipeGuide() {
    new GuideHelper.Builder(this)
            .setColor(ResourcesUtils.getAttrColor(this, R.attr.colorPrimary))
            .setPadding(LayoutUtils.dp2pix(this, 16))
            .setMessagePosition(Gravity.TOP)
            .setMessage(getString(R.string.swipe_toolbar_hide_show))
            .setButton(getString(R.string.get_it))
            .setBackgroundColor(0x73000000)
            .setOnDissmisListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Settings.putGuideTypeSend(false);
                }
            }).show();
}
 
Example 28
Source Project: Nimingban   Source File: DoodleActivity.java    License: Apache License 2.0 5 votes vote down vote up
@SuppressLint("InflateParams")
public ThicknessDialogHelper() {
    mView = getLayoutInflater().inflate(R.layout.dialog_thickness, null);
    mTpv = (ThicknessPreviewView) mView.findViewById(R.id.thickness_preview_view);
    mSlider = (Slider) mView.findViewById(R.id.slider);

    mTpv.setThickness(mDoodleView.getPaintThickness());
    mTpv.setColor(mDoodleView.getPaintColor());
    mSlider.setProgress((int) LayoutUtils.pix2dp(DoodleActivity.this, mDoodleView.getPaintThickness()));
    mSlider.setOnSetProgressListener(this);
}
 
Example 29
Source Project: Nimingban   Source File: DraftActivity.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onBindViewHolder(DraftHolder holder, int position) {
    DraftRaw draftRaw = mLazyList.get(position);
    holder.time.setText(ReadableTime.getDisplayTime(draftRaw.getTime()));
    holder.content.setText(draftRaw.getContent());

    holder.content.setTextSize(Settings.getFontSize());
    holder.content.setLineSpacing(LayoutUtils.dp2pix(DraftActivity.this, Settings.getLineSpacing()), 1.0f);
    if (Settings.getFixEmojiDisplay()) {
        holder.content.useCustomTypeface();
    } else {
        holder.content.useOriginalTypeface();
    }
}
 
Example 30
Source Project: Nimingban   Source File: SearchActivity.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onBindViewHolder(SearchHolder holder, int position) {
    ACSearchItem item = mSearchHelper.getDataAt(position);
    holder.leftText.setText(item.getNMBDisplayUsername());
    holder.centerText.setText("No." + item.getNMBId());
    holder.rightText.setText(ReadableTime.getDisplayTime(item.getNMBTime()));
    ACItemUtils.setContentText(holder.content, item.getNMBDisplayContent());

    String thumbKey = item.getNMBThumbKey();
    String thumbUrl = item.getNMBThumbUrl();

    boolean showImage;
    boolean loadFromNetwork;
    int ils = Settings.getImageLoadingStrategy();
    if (ils == Settings.IMAGE_LOADING_STRATEGY_ALL ||
            (ils == Settings.IMAGE_LOADING_STRATEGY_WIFI && NMBApplication.isConnectedWifi(SearchActivity.this))) {
        showImage = true;
        loadFromNetwork = true;
    } else {
        showImage = Settings.getImageLoadingStrategy2();
        loadFromNetwork = false;
    }

    if (!TextUtils.isEmpty(thumbKey) && !TextUtils.isEmpty(thumbUrl) && showImage) {
        holder.thumb.setVisibility(View.VISIBLE);
        holder.thumb.unload();
        holder.thumb.load(thumbKey, thumbUrl, loadFromNetwork);
    } else {
        holder.thumb.setVisibility(View.GONE);
        holder.thumb.unload();
    }

    holder.content.setTextSize(Settings.getFontSize());
    holder.content.setLineSpacing(LayoutUtils.dp2pix(SearchActivity.this, Settings.getLineSpacing()), 1.0f);
    if (Settings.getFixEmojiDisplay()) {
        holder.content.useCustomTypeface();
    } else {
        holder.content.useOriginalTypeface();
    }
}