Search in sources :

Example 1 with LinearDividerItemDecoration

use of com.hippo.easyrecyclerview.LinearDividerItemDecoration in project EhViewer by seven332.

the class FavoritesScene method showFavoritesInfoDialog.

@SuppressLint("InflateParams")
private void showFavoritesInfoDialog() {
    Context context = getContext2();
    if (null == context || null == mFavCatArray || null == mFavCountArray) {
        return;
    }
    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    context = builder.getContext();
    final LayoutInflater inflater = LayoutInflater.from(context);
    EasyRecyclerView rv = (EasyRecyclerView) inflater.inflate(R.layout.dialog_recycler_view, null);
    rv.setAdapter(new InfoAdapter(inflater));
    rv.setLayoutManager(new LinearLayoutManager(context));
    LinearDividerItemDecoration decoration = new LinearDividerItemDecoration(LinearDividerItemDecoration.VERTICAL, context.getResources().getColor(R.color.divider), LayoutUtils.dp2pix(context, 1));
    decoration.setPadding(ResourcesUtils.getAttrDimensionPixelOffset(context, R.attr.dialogPreferredPadding));
    rv.addItemDecoration(decoration);
    rv.setSelector(Ripple.generateRippleDrawable(context, false));
    rv.setClipToPadding(false);
    builder.setView(rv).show();
}
Also used : Context(android.content.Context) AlertDialog(android.support.v7.app.AlertDialog) EasyRecyclerView(com.hippo.easyrecyclerview.EasyRecyclerView) SpannableStringBuilder(android.text.SpannableStringBuilder) FavListUrlBuilder(com.hippo.ehviewer.client.data.FavListUrlBuilder) LayoutInflater(android.view.LayoutInflater) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) LinearDividerItemDecoration(com.hippo.easyrecyclerview.LinearDividerItemDecoration) SuppressLint(android.annotation.SuppressLint)

Example 2 with LinearDividerItemDecoration

use of com.hippo.easyrecyclerview.LinearDividerItemDecoration in project EhViewer by seven332.

the class GalleryCommentsScene method showVoteStatusDialog.

@SuppressLint("InflateParams")
public void showVoteStatusDialog(Context context, String voteStatus) {
    String[] temp = StringUtils.split(voteStatus, ',');
    final int length = temp.length;
    final String[] userArray = new String[length];
    final String[] voteArray = new String[length];
    for (int i = 0; i < length; i++) {
        String str = StringUtils.trim(temp[i]);
        int index = str.lastIndexOf(' ');
        if (index < 0) {
            Log.d(TAG, "Something wrong happened about vote state");
            userArray[i] = str;
            voteArray[i] = "";
        } else {
            userArray[i] = StringUtils.trim(str.substring(0, index));
            voteArray[i] = StringUtils.trim(str.substring(index + 1));
        }
    }
    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    context = builder.getContext();
    final LayoutInflater inflater = LayoutInflater.from(context);
    EasyRecyclerView rv = (EasyRecyclerView) inflater.inflate(R.layout.dialog_recycler_view, null);
    rv.setAdapter(new RecyclerView.Adapter<InfoHolder>() {

        @Override
        public InfoHolder onCreateViewHolder(ViewGroup parent, int viewType) {
            return new InfoHolder(inflater.inflate(R.layout.item_favorite_info_data, parent, false));
        }

        @Override
        public void onBindViewHolder(InfoHolder holder, int position) {
            holder.key.setText(userArray[position]);
            holder.value.setText(voteArray[position]);
        }

        @Override
        public int getItemCount() {
            return length;
        }
    });
    rv.setLayoutManager(new LinearLayoutManager(context));
    LinearDividerItemDecoration decoration = new LinearDividerItemDecoration(LinearDividerItemDecoration.VERTICAL, context.getResources().getColor(R.color.divider), LayoutUtils.dp2pix(context, 1));
    decoration.setPadding(ResourcesUtils.getAttrDimensionPixelOffset(context, R.attr.dialogPreferredPadding));
    rv.addItemDecoration(decoration);
    rv.setSelector(Ripple.generateRippleDrawable(context, false));
    rv.setClipToPadding(false);
    builder.setView(rv).show();
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) EasyRecyclerView(com.hippo.easyrecyclerview.EasyRecyclerView) ViewGroup(android.view.ViewGroup) SpannableStringBuilder(android.text.SpannableStringBuilder) SpannableString(android.text.SpannableString) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) LinearDividerItemDecoration(com.hippo.easyrecyclerview.LinearDividerItemDecoration) SuppressLint(android.annotation.SuppressLint) LayoutInflater(android.view.LayoutInflater) EasyRecyclerView(com.hippo.easyrecyclerview.EasyRecyclerView) RecyclerView(android.support.v7.widget.RecyclerView) SuppressLint(android.annotation.SuppressLint)

Example 3 with LinearDividerItemDecoration

use of com.hippo.easyrecyclerview.LinearDividerItemDecoration in project EhViewer by seven332.

the class GalleryCommentsScene method onCreateView3.

@Nullable
@Override
public View onCreateView3(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.scene_gallery_comments, container, false);
    mRecyclerView = (EasyRecyclerView) ViewUtils.$$(view, R.id.recycler_view);
    TextView tip = (TextView) ViewUtils.$$(view, R.id.tip);
    mEditPanel = ViewUtils.$$(view, R.id.edit_panel);
    mSendImage = (ImageView) ViewUtils.$$(mEditPanel, R.id.send);
    mEditText = (EditText) ViewUtils.$$(mEditPanel, R.id.edit_text);
    mFabLayout = (FabLayout) ViewUtils.$$(view, R.id.fab_layout);
    mFab = (FloatingActionButton) ViewUtils.$$(view, R.id.fab);
    Context context = getContext2();
    Assert.assertNotNull(context);
    Resources resources = context.getResources();
    int paddingBottomFab = resources.getDimensionPixelOffset(R.dimen.gallery_padding_bottom_fab);
    Drawable drawable = DrawableManager.getDrawable(context, R.drawable.big_weird_face);
    drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
    tip.setCompoundDrawables(null, drawable, null, null);
    mAdapter = new CommentAdapter();
    mRecyclerView.setAdapter(mAdapter);
    mRecyclerView.setLayoutManager(new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false));
    LinearDividerItemDecoration decoration = new LinearDividerItemDecoration(LinearDividerItemDecoration.VERTICAL, context.getResources().getColor(R.color.divider), LayoutUtils.dp2pix(context, 1));
    decoration.setShowLastDivider(true);
    mRecyclerView.addItemDecoration(decoration);
    mRecyclerView.setSelector(Ripple.generateRippleDrawable(context, false));
    mRecyclerView.setHasFixedSize(true);
    mRecyclerView.setOnItemClickListener(this);
    mRecyclerView.setPadding(mRecyclerView.getPaddingLeft(), mRecyclerView.getPaddingTop(), mRecyclerView.getPaddingRight(), mRecyclerView.getPaddingBottom() + paddingBottomFab);
    // Cancel change animator
    RecyclerView.ItemAnimator itemAnimator = mRecyclerView.getItemAnimator();
    if (itemAnimator instanceof DefaultItemAnimator) {
        ((DefaultItemAnimator) itemAnimator).setSupportsChangeAnimations(false);
    }
    mSendImage.setOnClickListener(this);
    mFab.setOnClickListener(this);
    addAboveSnackView(mEditPanel);
    addAboveSnackView(mFabLayout);
    mViewTransition = new ViewTransition(mRecyclerView, tip);
    updateView(false);
    return view;
}
Also used : Context(android.content.Context) Drawable(android.graphics.drawable.Drawable) ViewTransition(com.hippo.view.ViewTransition) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) LinearDividerItemDecoration(com.hippo.easyrecyclerview.LinearDividerItemDecoration) LinkifyTextView(com.hippo.widget.LinkifyTextView) ImageView(android.widget.ImageView) EasyRecyclerView(com.hippo.easyrecyclerview.EasyRecyclerView) View(android.view.View) TextView(android.widget.TextView) ObservedTextView(com.hippo.widget.ObservedTextView) RecyclerView(android.support.v7.widget.RecyclerView) SuppressLint(android.annotation.SuppressLint) DefaultItemAnimator(android.support.v7.widget.DefaultItemAnimator) LinkifyTextView(com.hippo.widget.LinkifyTextView) TextView(android.widget.TextView) ObservedTextView(com.hippo.widget.ObservedTextView) EasyRecyclerView(com.hippo.easyrecyclerview.EasyRecyclerView) RecyclerView(android.support.v7.widget.RecyclerView) Resources(android.content.res.Resources) Nullable(android.support.annotation.Nullable)

Example 4 with LinearDividerItemDecoration

use of com.hippo.easyrecyclerview.LinearDividerItemDecoration in project EhViewer by seven332.

the class HostsActivity method onCreate.

@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, LinearLayoutManager.VERTICAL, false));
    LinearDividerItemDecoration decoration = new LinearDividerItemDecoration(LinearDividerItemDecoration.VERTICAL, getResources().getColor(R.color.divider), LayoutUtils.dp2pix(this, 1));
    decoration.setShowLastDivider(true);
    recyclerView.addItemDecoration(decoration);
    recyclerView.setSelector(Ripple.generateRippleDrawable(this, false));
    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);
}
Also used : FloatingActionButton(android.support.design.widget.FloatingActionButton) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) LinearDividerItemDecoration(com.hippo.easyrecyclerview.LinearDividerItemDecoration)

Example 5 with LinearDividerItemDecoration

use of com.hippo.easyrecyclerview.LinearDividerItemDecoration in project EhViewer by seven332.

the class GalleryInfoScene method onCreateView3.

@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();
    Assert.assertNotNull(context);
    mRecyclerView = (EasyRecyclerView) ViewUtils.$$(view, R.id.recycler_view);
    InfoAdapter adapter = new InfoAdapter();
    mRecyclerView.setAdapter(adapter);
    mRecyclerView.setLayoutManager(new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false));
    LinearDividerItemDecoration decoration = new LinearDividerItemDecoration(LinearDividerItemDecoration.VERTICAL, context.getResources().getColor(R.color.divider), LayoutUtils.dp2pix(context, 1));
    decoration.setPadding(context.getResources().getDimensionPixelOffset(R.dimen.keyline_margin));
    mRecyclerView.addItemDecoration(decoration);
    mRecyclerView.setSelector(Ripple.generateRippleDrawable(context, false));
    mRecyclerView.setClipToPadding(false);
    mRecyclerView.setHasFixedSize(true);
    mRecyclerView.setOnItemClickListener(this);
    return view;
}
Also used : Context(android.content.Context) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) LinearDividerItemDecoration(com.hippo.easyrecyclerview.LinearDividerItemDecoration) EasyRecyclerView(com.hippo.easyrecyclerview.EasyRecyclerView) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) View(android.view.View) Nullable(android.support.annotation.Nullable)

Aggregations

LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)6 LinearDividerItemDecoration (com.hippo.easyrecyclerview.LinearDividerItemDecoration)6 EasyRecyclerView (com.hippo.easyrecyclerview.EasyRecyclerView)4 SuppressLint (android.annotation.SuppressLint)3 Context (android.content.Context)3 RecyclerView (android.support.v7.widget.RecyclerView)3 Nullable (android.support.annotation.Nullable)2 AlertDialog (android.support.v7.app.AlertDialog)2 SpannableStringBuilder (android.text.SpannableStringBuilder)2 LayoutInflater (android.view.LayoutInflater)2 View (android.view.View)2 TextView (android.widget.TextView)2 Resources (android.content.res.Resources)1 Drawable (android.graphics.drawable.Drawable)1 FloatingActionButton (android.support.design.widget.FloatingActionButton)1 DefaultItemAnimator (android.support.v7.widget.DefaultItemAnimator)1 SpannableString (android.text.SpannableString)1 ViewGroup (android.view.ViewGroup)1 ImageView (android.widget.ImageView)1 FavListUrlBuilder (com.hippo.ehviewer.client.data.FavListUrlBuilder)1