com.hippo.ripple.Ripple Java Examples

The following examples show how to use com.hippo.ripple.Ripple. 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 File: GalleryInfoScene.java    From MHViewer with 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 File: GalleryInfoScene.java    From EhViewer with 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 #3
Source File: PostFragment.java    From Nimingban with Apache License 2.0 6 votes vote down vote up
@SuppressLint("InflateParams")
public ReferenceDialogHelper(Site site, String id) {
    mSite = site;
    mId = id;

    mView = getActivity().getLayoutInflater().inflate(R.layout.dialog_reference, null);

    View progress = mView.findViewById(R.id.progress_view);
    View reference = mView.findViewById(R.id.reference);
    mViewTransition = new ViewTransition(progress, reference);

    mLeftText = (TextView) reference.findViewById(R.id.left_text);
    mCenterText = (TextView) reference.findViewById(R.id.center_text);
    mRightText = (TextView) reference.findViewById(R.id.right_text);
    mContent = (LinkifyTextView) reference.findViewById(R.id.content);
    mThumb = (LoadImageView) reference.findViewById(R.id.thumb);
    mButton = reference.findViewById(R.id.button);

    mContent.setOnClickListener(this);
    mThumb.setOnClickListener(this);
    Ripple.addRipple(mButton, ResourcesUtils.getAttrBoolean(getContext(), R.attr.dark));
}
 
Example #4
Source File: DownloadsScene.java    From MHViewer with Apache License 2.0 6 votes vote down vote up
public DownloadHolder(View itemView) {
    super(itemView);

    thumb = (LoadImageView) itemView.findViewById(R.id.thumb);
    title = (TextView) itemView.findViewById(R.id.title);
    uploader = (TextView) itemView.findViewById(R.id.uploader);
    rating = (SimpleRatingView) itemView.findViewById(R.id.rating);
    category = (TextView) itemView.findViewById(R.id.category);
    start = itemView.findViewById(R.id.start);
    stop = itemView.findViewById(R.id.stop);
    state = (TextView) itemView.findViewById(R.id.state);
    progressBar = (ProgressBar) itemView.findViewById(R.id.progress_bar);
    percent = (TextView) itemView.findViewById(R.id.percent);
    speed = (TextView) itemView.findViewById(R.id.speed);

    // TODO cancel on click listener when select items
    thumb.setOnClickListener(this);
    start.setOnClickListener(this);
    stop.setOnClickListener(this);

    boolean isDarkTheme = !AttrResources.getAttrBoolean(getContext2(), R.attr.isLightTheme);
    Ripple.addRipple(start, isDarkTheme);
    Ripple.addRipple(stop, isDarkTheme);
}
 
Example #5
Source File: DirPickerActivity.java    From MHViewer with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_dir_picker);
    setNavigationIcon(R.drawable.v_arrow_left_dark_x24);

    mPath = (TextView) ViewUtils.$$(this, R.id.path);
    mDirExplorer = (DirExplorer) ViewUtils.$$(this, R.id.dir_explorer);
    mOk = ViewUtils.$$(this, R.id.ok);

    File file;
    if (null == savedInstanceState) {
        file = onInit();
    } else {
        file = onRestore(savedInstanceState);
    }

    mDirExplorer.setCurrentFile(file);
    mDirExplorer.setOnChangeDirListener(this);

    Ripple.addRipple(mOk, !AttrResources.getAttrBoolean(this, R.attr.isLightTheme));

    mOk.setOnClickListener(this);

    mPath.setText(mDirExplorer.getCurrentFile().getPath());
}
 
Example #6
Source File: DownloadsScene.java    From EhViewer with Apache License 2.0 6 votes vote down vote up
public DownloadHolder(View itemView) {
    super(itemView);

    thumb = (LoadImageView) itemView.findViewById(R.id.thumb);
    title = (TextView) itemView.findViewById(R.id.title);
    uploader = (TextView) itemView.findViewById(R.id.uploader);
    rating = (SimpleRatingView) itemView.findViewById(R.id.rating);
    category = (TextView) itemView.findViewById(R.id.category);
    start = itemView.findViewById(R.id.start);
    stop = itemView.findViewById(R.id.stop);
    state = (TextView) itemView.findViewById(R.id.state);
    progressBar = (ProgressBar) itemView.findViewById(R.id.progress_bar);
    percent = (TextView) itemView.findViewById(R.id.percent);
    speed = (TextView) itemView.findViewById(R.id.speed);

    // TODO cancel on click listener when select items
    thumb.setOnClickListener(this);
    start.setOnClickListener(this);
    stop.setOnClickListener(this);

    boolean isDarkTheme = !AttrResources.getAttrBoolean(getContext2(), R.attr.isLightTheme);
    Ripple.addRipple(start, isDarkTheme);
    Ripple.addRipple(stop, isDarkTheme);
}
 
Example #7
Source File: ExcludedLanguagesActivity.java    From MHViewer with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.scene_excluded_languages);
    setNavigationIcon(R.drawable.v_arrow_left_dark_x24);

    if (null == savedInstanceState) {
        onInit();
    } else {
        onRestore(savedInstanceState);
    }

    mCancel = ViewUtils.$$(this, R.id.cancel);
    mOk = ViewUtils.$$(this, R.id.ok);
    mSelectAll = ViewUtils.$$(this, R.id.select_all);
    mDeselectAll = ViewUtils.$$(this, R.id.deselect_all);
    mInvertSelection = ViewUtils.$$(this, R.id.invert_selection);
    mRecyclerView = (EasyRecyclerView) ViewUtils.$$(this, R.id.recycler_view);

    mRecyclerView.setHasFixedSize(true);
    mRecyclerView.setClipToPadding(false);
    mAdapter = new LanguageAdapter();
    mRecyclerView.setAdapter(mAdapter);
    mRecyclerView.setLayoutManager(new LinearLayoutManager(this));

    mCancel.setOnClickListener(this);
    mOk.setOnClickListener(this);
    mSelectAll.setOnClickListener(this);
    mDeselectAll.setOnClickListener(this);
    mInvertSelection.setOnClickListener(this);

    boolean isDarkTheme = !AttrResources.getAttrBoolean(this, R.attr.isLightTheme);
    Ripple.addRipple(mCancel, isDarkTheme);
    Ripple.addRipple(mOk, isDarkTheme);
    Ripple.addRipple(mSelectAll, isDarkTheme);
    Ripple.addRipple(mDeselectAll, isDarkTheme);
    Ripple.addRipple(mInvertSelection, isDarkTheme);
}
 
Example #8
Source File: RightDrawer.java    From Nimingban with Apache License 2.0 5 votes vote down vote up
private void init(Context context) {
    mForums = new ArrayList<>();
    mAdapter = new ForumAdapter();
    setAdapter(mAdapter);
    setLayoutManager(new LinearLayoutManager(context));
    setOnItemClickListener(this);
    setSelector(Ripple.generateRippleDrawable(
            context, ResourcesUtils.getAttrBoolean(context, R.attr.dark)));

    mActionBarHeight = ResourcesUtils.getAttrDimensionPixelOffset(context, R.attr.actionBarSize);
}
 
Example #9
Source File: LeftDrawer.java    From Nimingban with Apache License 2.0 5 votes vote down vote up
private void init(Context context) {
    setFillViewport(true);
    setHorizontalScrollBarEnabled(false);
    setVerticalScrollBarEnabled(false);

    LayoutInflater.from(context).inflate(R.layout.widget_left_drawer, this);
    mHeader = (HeaderImageView) findViewById(R.id.header);
    mDrawerListView = (DrawerListView) findViewById(R.id.drawer_list_view);
    mDarkTheme = (TextView) findViewById(R.id.dark_theme);

    mHeader.setOnLongClickImageListener(this);

    Resources resources = context.getResources();

    Drawable search = DrawableManager.getDrawable(context, R.drawable.v_magnify_x24);
    Drawable feed = DrawableManager.getDrawable(context, R.drawable.v_rss_x24);
    Drawable record = DrawableManager.getDrawable(context, R.drawable.v_history_x24);
    Drawable settings = DrawableManager.getDrawable(context, R.drawable.v_settings_x24);

    Drawable[] drawables = {
            search,
            feed,
            record,
            settings
    };
    String[] strings = {
            resources.getString(R.string.search),
            resources.getString(R.string.feed),
            resources.getString(R.string.record),
            resources.getString(R.string.settings)
    };

    mDrawerListView.setData(drawables, strings);
    mDrawerListView.setOnItemClickListener(this);

    mDarkTheme.setText(Settings.getDarkTheme() ? R.string.let_there_light : R.string.let_there_dark);
    mDarkTheme.setOnClickListener(this);
    Ripple.addRipple(mDarkTheme, ResourcesUtils.getAttrBoolean(context, R.attr.dark));
}
 
Example #10
Source File: HostsActivity.java    From EhViewer with 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 #11
Source File: ExcludedLanguagesActivity.java    From EhViewer with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.scene_excluded_languages);
    setNavigationIcon(R.drawable.v_arrow_left_dark_x24);

    if (null == savedInstanceState) {
        onInit();
    } else {
        onRestore(savedInstanceState);
    }

    mCancel = ViewUtils.$$(this, R.id.cancel);
    mOk = ViewUtils.$$(this, R.id.ok);
    mSelectAll = ViewUtils.$$(this, R.id.select_all);
    mDeselectAll = ViewUtils.$$(this, R.id.deselect_all);
    mInvertSelection = ViewUtils.$$(this, R.id.invert_selection);
    mRecyclerView = (EasyRecyclerView) ViewUtils.$$(this, R.id.recycler_view);

    mRecyclerView.setHasFixedSize(true);
    mRecyclerView.setClipToPadding(false);
    mAdapter = new LanguageAdapter();
    mRecyclerView.setAdapter(mAdapter);
    mRecyclerView.setLayoutManager(new LinearLayoutManager(this));

    mCancel.setOnClickListener(this);
    mOk.setOnClickListener(this);
    mSelectAll.setOnClickListener(this);
    mDeselectAll.setOnClickListener(this);
    mInvertSelection.setOnClickListener(this);

    boolean isDarkTheme = !AttrResources.getAttrBoolean(this, R.attr.isLightTheme);
    Ripple.addRipple(mCancel, isDarkTheme);
    Ripple.addRipple(mOk, isDarkTheme);
    Ripple.addRipple(mSelectAll, isDarkTheme);
    Ripple.addRipple(mDeselectAll, isDarkTheme);
    Ripple.addRipple(mInvertSelection, isDarkTheme);
}
 
Example #12
Source File: DirPickerActivity.java    From EhViewer with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_dir_picker);
    setNavigationIcon(R.drawable.v_arrow_left_dark_x24);

    mPath = findViewById(R.id.path);
    mDirExplorer = findViewById(R.id.dir_explorer);
    mDefault = findViewById(R.id.preset);
    mOk = findViewById(R.id.ok);

    File file;
    if (null == savedInstanceState) {
        file = onInit();
    } else {
        file = onRestore(savedInstanceState);
    }

    mDirExplorer.setCurrentFile(file);
    mDirExplorer.setOnChangeDirListener(this);

    Ripple.addRipple(mOk, !AttrResources.getAttrBoolean(this, R.attr.isLightTheme));

    mDefault.setOnClickListener(this);
    mOk.setOnClickListener(this);

    mPath.setText(mDirExplorer.getCurrentFile().getPath());
}
 
Example #13
Source File: HostsActivity.java    From MHViewer with 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 #14
Source File: PluginsActivity.java    From MHViewer with 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 #15
Source File: SearchLayout.java    From EhViewer with Apache License 2.0 4 votes vote down vote up
@SuppressLint("InflateParams")
private void init(Context context) {
    Resources resources = context.getResources();
    mInflater = LayoutInflater.from(context);

    mLayoutManager = new LinearLayoutManager(context);
    mAdapter = new SearchAdapter();
    setLayoutManager(mLayoutManager);
    setAdapter(mAdapter);
    setHasFixedSize(true);
    setClipToPadding(false);
    int interval = resources.getDimensionPixelOffset(R.dimen.search_layout_interval);
    int paddingH = resources.getDimensionPixelOffset(R.dimen.search_layout_margin_h);
    int paddingV = resources.getDimensionPixelOffset(R.dimen.search_layout_margin_v);
    MarginItemDecoration decoration = new MarginItemDecoration(
            interval, paddingH, paddingV, paddingH, paddingV);
    addItemDecoration(decoration);
    decoration.applyPaddings(this);

    // Create normal view
    View normalView = mInflater.inflate(R.layout.search_normal, null);
    mNormalView = normalView;
    mCategoryTable = (CategoryTable) normalView.findViewById(R.id.search_category_table);
    mNormalSearchMode = (RadioGridGroup) normalView.findViewById(R.id.normal_search_mode);
    mNormalSearchModeHelp = (ImageView) normalView.findViewById(R.id.normal_search_mode_help);
    mEnableAdvanceSwitch = (SwitchCompat) normalView.findViewById(R.id.search_enable_advance);
    mNormalSearchModeHelp.setOnClickListener(this);
    Ripple.addRipple(mNormalSearchModeHelp, !AttrResources.getAttrBoolean(context, R.attr.isLightTheme));
    mEnableAdvanceSwitch.setOnCheckedChangeListener(SearchLayout.this);
    mEnableAdvanceSwitch.setSwitchPadding(resources.getDimensionPixelSize(R.dimen.switch_padding));

    // Create advance view
    mAdvanceView = mInflater.inflate(R.layout.search_advance, null);
    mTableAdvanceSearch = (AdvanceSearchTable) mAdvanceView.findViewById(R.id.search_advance_search_table);

    // Create image view
    mImageView = (ImageSearchLayout) mInflater.inflate(R.layout.search_image, null);
    mImageView.setHelper(this);

    // Create action view
    mActionView = mInflater.inflate(R.layout.search_action, null);
    mAction = (TextView) mActionView.findViewById(R.id.action);
    mAction.setOnClickListener(this);
}
 
Example #16
Source File: GalleryCommentsScene.java    From EhViewer with Apache License 2.0 4 votes vote down vote up
@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();
    AssertUtils.assertNotNull(context);
    Resources resources = context.getResources();
    int paddingBottomFab = resources.getDimensionPixelOffset(R.dimen.gallery_padding_bottom_fab);

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

    mSendDrawable = DrawableManager.getVectorDrawable(context, R.drawable.v_send_dark_x24);
    mPencilDrawable = DrawableManager.getVectorDrawable(context, R.drawable.v_pencil_dark_x24);

    mAdapter = new CommentAdapter();
    mRecyclerView.setAdapter(mAdapter);
    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.setShowLastDivider(true);
    mRecyclerView.addItemDecoration(decoration);
    mRecyclerView.setSelector(Ripple.generateRippleDrawable(context, !AttrResources.getAttrBoolean(context, R.attr.isLightTheme), new ColorDrawable(Color.TRANSPARENT)));
    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;
}
 
Example #17
Source File: DownloadsScene.java    From EhViewer with Apache License 2.0 4 votes vote down vote up
@Nullable
@Override
public View onCreateView3(LayoutInflater inflater,
        @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.scene_download, container, false);

    View content = ViewUtils.$$(view, R.id.content);
    mRecyclerView = (EasyRecyclerView) ViewUtils.$$(content, R.id.recycler_view);
    FastScroller fastScroller = (FastScroller) ViewUtils.$$(content, R.id.fast_scroller);
    mFabLayout = (FabLayout) ViewUtils.$$(view, R.id.fab_layout);
    TextView tip = (TextView) ViewUtils.$$(view, R.id.tip);
    mViewTransition = new ViewTransition(content, tip);

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

    Drawable drawable = DrawableManager.getVectorDrawable(context, R.drawable.big_download);
    drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
    tip.setCompoundDrawables(null, drawable, null, null);

    mAdapter = new DownloadAdapter();
    mAdapter.setHasStableIds(true);
    mRecyclerView.setAdapter(mAdapter);
    mLayoutManager = new AutoStaggeredGridLayoutManager(0, StaggeredGridLayoutManager.VERTICAL);
    mLayoutManager.setColumnSize(resources.getDimensionPixelOffset(Settings.getDetailSizeResId()));
    mLayoutManager.setStrategy(AutoStaggeredGridLayoutManager.STRATEGY_MIN_SIZE);
    mRecyclerView.setLayoutManager(mLayoutManager);
    mRecyclerView.setSelector(Ripple.generateRippleDrawable(context, !AttrResources.getAttrBoolean(context, R.attr.isLightTheme), new ColorDrawable(Color.TRANSPARENT)));
    mRecyclerView.setDrawSelectorOnTop(true);
    mRecyclerView.setClipToPadding(false);
    mRecyclerView.setOnItemClickListener(this);
    mRecyclerView.setOnItemLongClickListener(this);
    mRecyclerView.setChoiceMode(EasyRecyclerView.CHOICE_MODE_MULTIPLE_CUSTOM);
    mRecyclerView.setCustomCheckedListener(new DownloadChoiceListener());
    // Cancel change animation
    RecyclerView.ItemAnimator itemAnimator = mRecyclerView.getItemAnimator();
    if (itemAnimator instanceof SimpleItemAnimator) {
        ((SimpleItemAnimator) itemAnimator).setSupportsChangeAnimations(false);
    }
    int interval = resources.getDimensionPixelOffset(R.dimen.gallery_list_interval);
    int paddingH = resources.getDimensionPixelOffset(R.dimen.gallery_list_margin_h);
    int paddingV = resources.getDimensionPixelOffset(R.dimen.gallery_list_margin_v);
    MarginItemDecoration decoration = new MarginItemDecoration(interval, paddingH, paddingV, paddingH, paddingV);
    mRecyclerView.addItemDecoration(decoration);
    decoration.applyPaddings(mRecyclerView);
    if (mInitPosition >= 0) {
        mRecyclerView.scrollToPosition(mInitPosition);
        mInitPosition = -1;
    }

    fastScroller.attachToRecyclerView(mRecyclerView);
    HandlerDrawable handlerDrawable = new HandlerDrawable();
    handlerDrawable.setColor(AttrResources.getAttrColor(context, R.attr.widgetColorThemeAccent));
    fastScroller.setHandlerDrawable(handlerDrawable);
    fastScroller.setOnDragHandlerListener(this);

    mFabLayout.setExpanded(false, false);
    mFabLayout.setHidePrimaryFab(true);
    mFabLayout.setAutoCancel(false);
    mFabLayout.setOnClickFabListener(this);
    addAboveSnackView(mFabLayout);

    updateView();

    guide();

    return view;
}
 
Example #18
Source File: HistoryScene.java    From EhViewer with Apache License 2.0 4 votes vote down vote up
@Nullable
@Override
public View onCreateView3(LayoutInflater inflater,
        @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.scene_history, container, false);
    View content = ViewUtils.$$(view, R.id.content);
    mRecyclerView = (EasyRecyclerView) ViewUtils.$$(content, R.id.recycler_view);
    FastScroller fastScroller = (FastScroller) ViewUtils.$$(content, R.id.fast_scroller);
    TextView tip = (TextView) ViewUtils.$$(view, R.id.tip);
    mViewTransition = new ViewTransition(content, tip);

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

    Drawable drawable = DrawableManager.getVectorDrawable(context, R.drawable.big_history);
    drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
    tip.setCompoundDrawables(null, drawable, null, null);

    RecyclerViewTouchActionGuardManager guardManager = new RecyclerViewTouchActionGuardManager();
    guardManager.setInterceptVerticalScrollingWhileAnimationRunning(true);
    guardManager.setEnabled(true);
    RecyclerViewSwipeManager swipeManager = new RecyclerViewSwipeManager();
    mAdapter = new HistoryAdapter();
    mAdapter.setHasStableIds(true);
    mAdapter = swipeManager.createWrappedAdapter(mAdapter);
    mRecyclerView.setAdapter(mAdapter);
    final GeneralItemAnimator animator = new SwipeDismissItemAnimator();
    animator.setSupportsChangeAnimations(false);
    mRecyclerView.setItemAnimator(animator);
    AutoStaggeredGridLayoutManager layoutManager = new AutoStaggeredGridLayoutManager(
            0, StaggeredGridLayoutManager.VERTICAL);
    layoutManager.setColumnSize(resources.getDimensionPixelOffset(Settings.getDetailSizeResId()));
    layoutManager.setStrategy(AutoStaggeredGridLayoutManager.STRATEGY_MIN_SIZE);
    mRecyclerView.setLayoutManager(layoutManager);
    mRecyclerView.setSelector(Ripple.generateRippleDrawable(context, !AttrResources.getAttrBoolean(context, R.attr.isLightTheme), new ColorDrawable(Color.TRANSPARENT)));
    mRecyclerView.setDrawSelectorOnTop(true);
    mRecyclerView.setClipToPadding(false);
    mRecyclerView.setOnItemClickListener(this);
    mRecyclerView.setOnItemLongClickListener(this);
    int interval = resources.getDimensionPixelOffset(R.dimen.gallery_list_interval);
    int paddingH = resources.getDimensionPixelOffset(R.dimen.gallery_list_margin_h);
    int paddingV = resources.getDimensionPixelOffset(R.dimen.gallery_list_margin_v);
    MarginItemDecoration decoration = new MarginItemDecoration(interval, paddingH, paddingV, paddingH, paddingV);
    mRecyclerView.addItemDecoration(decoration);
    decoration.applyPaddings(mRecyclerView);
    guardManager.attachRecyclerView(mRecyclerView);
    swipeManager.attachRecyclerView(mRecyclerView);

    fastScroller.attachToRecyclerView(mRecyclerView);
    HandlerDrawable handlerDrawable = new HandlerDrawable();
    handlerDrawable.setColor(AttrResources.getAttrColor(context, R.attr.widgetColorThemeAccent));
    fastScroller.setHandlerDrawable(handlerDrawable);

    updateLazyList();
    updateView(false);

    return view;
}
 
Example #19
Source File: FavoritesScene.java    From EhViewer with Apache License 2.0 4 votes vote down vote up
@Nullable
@Override
public View onCreateView2(LayoutInflater inflater,
        @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.scene_favorites, container, false);
    ContentLayout contentLayout = (ContentLayout) view.findViewById(R.id.content_layout);
    MainActivity activity = getActivity2();
    AssertUtils.assertNotNull(activity);
    mDrawerLayout = (EhDrawerLayout) ViewUtils.$$(activity, R.id.draw_view);
    mRecyclerView = contentLayout.getRecyclerView();
    FastScroller fastScroller = contentLayout.getFastScroller();
    RefreshLayout refreshLayout = contentLayout.getRefreshLayout();
    mSearchBar = (SearchBar) ViewUtils.$$(view, R.id.search_bar);
    mFabLayout = (FabLayout) ViewUtils.$$(view, R.id.fab_layout);

    Context context = getContext2();
    AssertUtils.assertNotNull(context);
    Resources resources = context.getResources();
    int paddingTopSB = resources.getDimensionPixelOffset(R.dimen.gallery_padding_top_search_bar);

    mHelper = new FavoritesHelper();
    mHelper.setEmptyString(resources.getString(R.string.gallery_list_empty_hit));
    contentLayout.setHelper(mHelper);
    contentLayout.getFastScroller().setOnDragHandlerListener(this);

    mAdapter = new FavoritesAdapter(inflater, resources, mRecyclerView, Settings.getListMode());
    mRecyclerView.setSelector(Ripple.generateRippleDrawable(context, !AttrResources.getAttrBoolean(context, R.attr.isLightTheme), new ColorDrawable(Color.TRANSPARENT)));
    mRecyclerView.setDrawSelectorOnTop(true);
    mRecyclerView.setClipToPadding(false);
    mRecyclerView.setOnItemClickListener(this);
    mRecyclerView.setOnItemLongClickListener(this);
    mRecyclerView.setChoiceMode(EasyRecyclerView.CHOICE_MODE_MULTIPLE_CUSTOM);
    mRecyclerView.setCustomCheckedListener(this);

    fastScroller.setPadding(fastScroller.getPaddingLeft(), fastScroller.getPaddingTop() + paddingTopSB,
            fastScroller.getPaddingRight(), fastScroller.getPaddingBottom());

    refreshLayout.setHeaderTranslationY(paddingTopSB);

    mLeftDrawable = new DrawerArrowDrawable(context, AttrResources.getAttrColor(context, R.attr.drawableColorPrimary));
    mSearchBar.setLeftDrawable(mLeftDrawable);
    mSearchBar.setRightDrawable(DrawableManager.getVectorDrawable(context, R.drawable.v_magnify_x24));
    mSearchBar.setHelper(this);
    mSearchBar.setAllowEmptySearch(false);
    updateSearchBar();
    mSearchBarMover = new SearchBarMover(this, mSearchBar, mRecyclerView);

    mActionFabDrawable = new AddDeleteDrawable(context, resources.getColor(R.color.primary_drawable_dark));
    mFabLayout.getPrimaryFab().setImageDrawable(mActionFabDrawable);
    mFabLayout.setExpanded(false, false);
    mFabLayout.setAutoCancel(true);
    mFabLayout.setHidePrimaryFab(false);
    mFabLayout.setOnClickFabListener(this);
    mFabLayout.setOnExpandListener(this);
    addAboveSnackView(mFabLayout);

    // Restore search mode
    if (mSearchMode) {
        mSearchMode = false;
        enterSearchMode(false);
    }

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

    guideCollections();

    return view;
}
 
Example #20
Source File: GalleryCommentsScene.java    From EhViewer with Apache License 2.0 4 votes vote down vote up
@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_drawer_favorites, 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, AttrResources.getAttrColor(context, R.attr.dividerColor),
            LayoutUtils.dp2pix(context, 1));
    decoration.setPadding(ResourcesUtils.getAttrDimensionPixelOffset(context, R.attr.dialogPreferredPadding));
    rv.addItemDecoration(decoration);
    rv.setSelector(Ripple.generateRippleDrawable(context, !AttrResources.getAttrBoolean(context, R.attr.isLightTheme), new ColorDrawable(Color.TRANSPARENT)));
    rv.setClipToPadding(false);
    builder.setView(rv).show();
}
 
Example #21
Source File: GalleryListScene.java    From EhViewer with Apache License 2.0 4 votes vote down vote up
@Nullable
@Override
public View onCreateView2(LayoutInflater inflater, @Nullable ViewGroup container,
        @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.scene_gallery_list, container, false);

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

    mHideActionFabSlop = ViewConfiguration.get(context).getScaledTouchSlop();
    mShowActionFab = true;

    View mainLayout = ViewUtils.$$(view, R.id.main_layout);
    ContentLayout contentLayout = (ContentLayout) ViewUtils.$$(mainLayout, R.id.content_layout);
    mRecyclerView = contentLayout.getRecyclerView();
    FastScroller fastScroller = contentLayout.getFastScroller();
    RefreshLayout refreshLayout = contentLayout.getRefreshLayout();
    mSearchLayout = (SearchLayout) ViewUtils.$$(mainLayout, R.id.search_layout);
    mSearchBar = (SearchBar) ViewUtils.$$(mainLayout, R.id.search_bar);
    mFabLayout = (FabLayout) ViewUtils.$$(mainLayout, R.id.fab_layout);
    mSearchFab = ViewUtils.$$(mainLayout, R.id.search_fab);

    int paddingTopSB = resources.getDimensionPixelOffset(R.dimen.gallery_padding_top_search_bar);
    int paddingBottomFab = resources.getDimensionPixelOffset(R.dimen.gallery_padding_bottom_fab);

    mViewTransition = new ViewTransition(contentLayout, mSearchLayout);

    mHelper = new GalleryListHelper();
    contentLayout.setHelper(mHelper);
    contentLayout.getFastScroller().setOnDragHandlerListener(this);

    mAdapter = new GalleryListAdapter(inflater, resources,
            mRecyclerView, Settings.getListMode());
    mRecyclerView.setSelector(Ripple.generateRippleDrawable(context, !AttrResources.getAttrBoolean(context, R.attr.isLightTheme), new ColorDrawable(Color.TRANSPARENT)));
    mRecyclerView.setDrawSelectorOnTop(true);
    mRecyclerView.setClipToPadding(false);
    mRecyclerView.setOnItemClickListener(this);
    mRecyclerView.setOnItemLongClickListener(this);
    mRecyclerView.addOnScrollListener(mOnScrollListener);

    fastScroller.setPadding(fastScroller.getPaddingLeft(), fastScroller.getPaddingTop() + paddingTopSB,
            fastScroller.getPaddingRight(), fastScroller.getPaddingBottom());

    refreshLayout.setHeaderTranslationY(paddingTopSB);

    mLeftDrawable = new DrawerArrowDrawable(context, AttrResources.getAttrColor(context, R.attr.drawableColorPrimary));
    mRightDrawable = new AddDeleteDrawable(context, AttrResources.getAttrColor(context, R.attr.drawableColorPrimary));
    mSearchBar.setLeftDrawable(mLeftDrawable);
    mSearchBar.setRightDrawable(mRightDrawable);
    mSearchBar.setHelper(this);
    mSearchBar.setOnStateChangeListener(this);
    setSearchBarHint(context, mSearchBar);
    setSearchBarSuggestionProvider(mSearchBar);

    mSearchLayout.setHelper(this);
    mSearchLayout.setPadding(mSearchLayout.getPaddingLeft(), mSearchLayout.getPaddingTop() + paddingTopSB,
            mSearchLayout.getPaddingRight(), mSearchLayout.getPaddingBottom() + paddingBottomFab);

    mFabLayout.setAutoCancel(true);
    mFabLayout.setExpanded(false);
    mFabLayout.setHidePrimaryFab(false);
    mFabLayout.setOnClickFabListener(this);
    mFabLayout.setOnExpandListener(this);
    addAboveSnackView(mFabLayout);

    mActionFabDrawable = new AddDeleteDrawable(context, resources.getColor(R.color.primary_drawable_dark));
    mFabLayout.getPrimaryFab().setImageDrawable(mActionFabDrawable);

    mSearchFab.setOnClickListener(this);

    mSearchBarMover = new SearchBarMover(this, mSearchBar, mRecyclerView, mSearchLayout);

    // Update list url builder
    onUpdateUrlBuilder();

    // Restore state
    int newState = mState;
    mState = STATE_NORMAL;
    setState(newState, false);

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

    guideQuickSearch();

    return view;
}
 
Example #22
Source File: FeedActivity.java    From Nimingban with Apache License 2.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mNMBClient = NMBApplication.getNMBClient(this);

    setStatusBarColor(ResourcesUtils.getAttrColor(this, R.attr.colorPrimaryDark));
    ToolbarActivityHelper.setContentView(this, R.layout.activity_feed);
    setActionBarUpIndicator(DrawableManager.getDrawable(this, R.drawable.v_arrow_left_dark_x24));

    mContentLayout = (ContentLayout) findViewById(R.id.content_layout);
    mRecyclerView = mContentLayout.getRecyclerView();

    mFeedHelper = new FeedHelper();
    mFeedHelper.setEmptyString(getString(R.string.no_feed));
    mContentLayout.setHelper(mFeedHelper);
    if (Settings.getFastScroller()) {
        mContentLayout.showFastScroll();
    } else {
        mContentLayout.hideFastScroll();
    }

    // Layout Manager
    int interval = getResources().getDimensionPixelOffset(R.dimen.card_interval);
    if (getResources().getBoolean(R.bool.two_way)) {
        mRecyclerView.setLayoutManager(new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL));
        MarginItemDecoration decoration = new MarginItemDecoration(interval, interval, interval, interval, interval);
        mRecyclerView.addItemDecoration(decoration);
        decoration.applyPaddings(mRecyclerView);
        mRecyclerView.setItemAnimator(new SlideInUpAnimator());
    } else {
        int halfInterval = interval / 2;
        mRecyclerView.addItemDecoration(new RawMarginItemDecoration(0, halfInterval, 0, halfInterval));
        mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
        mRecyclerView.setPadding(0, halfInterval, 0, halfInterval);
    }

    // touch guard manager  (this class is required to suppress scrolling while swipe-dismiss animation is running)
    mRecyclerViewTouchActionGuardManager = new RecyclerViewTouchActionGuardManager();
    mRecyclerViewTouchActionGuardManager.setInterceptVerticalScrollingWhileAnimationRunning(true);
    mRecyclerViewTouchActionGuardManager.setEnabled(true);

    // swipe manager
    mRecyclerViewSwipeManager = new RecyclerViewSwipeManager();

    mAdapter = new FeedAdapter();
    mAdapter.setHasStableIds(true);
    mWrappedAdapter = mRecyclerViewSwipeManager.createWrappedAdapter(mAdapter);      // wrap for swiping

    final GeneralItemAnimator animator = new SwipeDismissItemAnimator();

    // Change animations are enabled by default since support-v7-recyclerview v22.
    // Disable the change animation in order to make turning back animation of swiped item works properly.
    animator.setSupportsChangeAnimations(false);

    mRecyclerView.hasFixedSize();
    mRecyclerView.setAdapter(mWrappedAdapter);  // requires *wrapped* adapter
    mRecyclerView.setItemAnimator(animator);
    mRecyclerView.setOnItemClickListener(this);
    mRecyclerView.setSelector(Ripple.generateRippleDrawable(this, ResourcesUtils.getAttrBoolean(this, R.attr.dark)));
    mRecyclerView.setDrawSelectorOnTop(true);
    mRecyclerView.setClipToPadding(false);
    mRecyclerView.setClipChildren(false);
    mOnScrollListener = new RecyclerView.OnScrollListener() {
        @Override
        public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
            if (RecyclerView.SCROLL_STATE_DRAGGING == newState) {
                pauseHolders();
            } else if (RecyclerView.SCROLL_STATE_IDLE == newState) {
                resumeHolders();
            }
        }
    };
    mRecyclerView.addOnScrollListener(mOnScrollListener);

    // NOTE:
    // The initialization order is very important! This order determines the priority of touch event handling.
    //
    // priority: TouchActionGuard > Swipe > DragAndDrop
    mRecyclerViewTouchActionGuardManager.attachRecyclerView(mRecyclerView);
    mRecyclerViewSwipeManager.attachRecyclerView(mRecyclerView);

    mFeedHelper.firstRefresh();

    Messenger.getInstance().register(Constants.MESSENGER_ID_FAST_SCROLLER, this);
}
 
Example #23
Source File: SearchActivity.java    From Nimingban with Apache License 2.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if (!handlerIntent(getIntent())) {
        finish();
        return;
    }

    mNMBClient = NMBApplication.getNMBClient(this);

    setStatusBarColor(ResourcesUtils.getAttrColor(this, R.attr.colorPrimaryDark));
    ToolbarActivityHelper.setContentView(this, R.layout.activity_search);
    setActionBarUpIndicator(DrawableManager.getDrawable(this, R.drawable.v_arrow_left_dark_x24));

    mContentLayout = (ContentLayout) findViewById(R.id.content_layout);
    EasyRecyclerView recyclerView = mContentLayout.getRecyclerView();
    mRecyclerView = recyclerView;

    mSearchHelper = new SearchHelper();
    mSearchHelper.setEmptyString(getString(R.string.not_found));
    mContentLayout.setHelper(mSearchHelper);
    if (Settings.getFastScroller()) {
        mContentLayout.showFastScroll();
    } else {
        mContentLayout.hideFastScroll();
    }

    mSearchAdapter = new SearchAdapter();
    recyclerView.setAdapter(mSearchAdapter);
    recyclerView.setSelector(Ripple.generateRippleDrawable(this, ResourcesUtils.getAttrBoolean(this, R.attr.dark)));
    recyclerView.setDrawSelectorOnTop(true);
    recyclerView.setOnItemClickListener(this);
    recyclerView.hasFixedSize();
    recyclerView.setClipToPadding(false);
    mOnScrollListener = new RecyclerView.OnScrollListener() {
        @Override
        public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
            if (RecyclerView.SCROLL_STATE_DRAGGING == newState) {
                pauseHolders();
            } else if (RecyclerView.SCROLL_STATE_IDLE == newState) {
                resumeHolders();
            }
        }
    };
    recyclerView.addOnScrollListener(mOnScrollListener);

    int interval = getResources().getDimensionPixelOffset(R.dimen.card_interval);
    if (getResources().getBoolean(R.bool.two_way)) {
        mRecyclerView.setLayoutManager(new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL));
        MarginItemDecoration decoration = new MarginItemDecoration(interval, interval, interval, interval, interval);
        mRecyclerView.addItemDecoration(decoration);
        decoration.applyPaddings(mRecyclerView);
        mRecyclerView.setItemAnimator(new SlideInUpAnimator());
    } else {
        int halfInterval = interval / 2;
        mRecyclerView.addItemDecoration(new RawMarginItemDecoration(0, halfInterval, 0, halfInterval));
        mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
        mRecyclerView.setPadding(0, halfInterval, 0, halfInterval);
    }

    mSearchHelper.firstRefresh();

    Messenger.getInstance().register(Constants.MESSENGER_ID_FAST_SCROLLER, this);
}
 
Example #24
Source File: DoodleActivity.java    From Nimingban with Apache License 2.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    File dir = NMBAppConfig.getDoodleDir();
    if (dir != null) {
        String filename = "doodle-" + ReadableTime.getFilenamableTime(System.currentTimeMillis()) + ".png";
        mOutputFile = new File(dir, filename);
    }

    setStatusBarColor(ResourcesUtils.getAttrColor(this, R.attr.colorPrimaryDark));
    setContentView(R.layout.activity_doodle);

    mDoodleView = (DoodleView) findViewById(R.id.doodle_view);
    mSide = findViewById(R.id.side);
    mPalette = findViewById(R.id.palette);
    mThickness = findViewById(R.id.thickness);
    mDrawAction = (ImageView) findViewById(R.id.draw_action);
    mImage = (ImageView) findViewById(R.id.image);
    mUndo = (ImageView) findViewById(R.id.undo);
    mRedo = (ImageView) findViewById(R.id.redo);
    mClear = findViewById(R.id.clear);
    mOk = findViewById(R.id.ok);
    mMenu = findViewById(R.id.menu);

    mDoodleView.setHelper(this);

    StateListDrawable undoDrawable = new StateListDrawable();
    undoDrawable.addState(new int[]{-android.R.attr.state_enabled},
            DrawableManager.getDrawable(this, R.drawable.v_undo_disabled_dark_x24));
    undoDrawable.addState(new int[]{},
            DrawableManager.getDrawable(this, R.drawable.v_undo_default_dark_x24));
    mUndo.setImageDrawable(undoDrawable);

    StateListDrawable redoDrawable = new StateListDrawable();
    redoDrawable.addState(new int[]{-android.R.attr.state_enabled},
            DrawableManager.getDrawable(this, R.drawable.v_redo_disabled_dark_x24));
    redoDrawable.addState(new int[]{},
            DrawableManager.getDrawable(this, R.drawable.v_redo_default_dark_x24));
    mRedo.setImageDrawable(redoDrawable);

    StateListDrawable actionDrawable = new StateListDrawable();
    actionDrawable.addState(new int[]{android.R.attr.state_activated},
            DrawableManager.getDrawable(this, R.drawable.v_eraser_dark_x24));
    actionDrawable.addState(new int[]{},
            DrawableManager.getDrawable(this, R.drawable.v_brush_dark_x24));
    mDrawAction.setImageDrawable(actionDrawable);

    StateListDrawable imageDrawable = new StateListDrawable();
    imageDrawable.addState(new int[]{android.R.attr.state_activated},
            DrawableManager.getDrawable(this, R.drawable.v_image_off_dark_x24));
    imageDrawable.addState(new int[]{},
            DrawableManager.getDrawable(this, R.drawable.v_image_dark_x24));
    mImage.setImageDrawable(imageDrawable);

    Ripple.addRipple(mPalette, true);
    Ripple.addRipple(mThickness, true);
    Ripple.addRipple(mDrawAction, true);
    Ripple.addRipple(mImage, true);
    Ripple.addRipple(mUndo, true);
    Ripple.addRipple(mRedo, true);
    Ripple.addRipple(mClear, true);
    Ripple.addRipple(mOk, true);
    Ripple.addRipple(mMenu, ResourcesUtils.getAttrBoolean(this, R.attr.dark));

    mSide.setOnClickListener(this);
    mPalette.setOnClickListener(this);
    mThickness.setOnClickListener(this);
    mDrawAction.setOnClickListener(this);
    mImage.setOnClickListener(this);
    mUndo.setOnClickListener(this);
    mRedo.setOnClickListener(this);
    mClear.setOnClickListener(this);
    mOk.setOnClickListener(this);
    mMenu.setOnClickListener(this);

    updateUndoRedo();

    if (mOutputFile == null) {
        Toast.makeText(this, R.string.cant_create_image_file, Toast.LENGTH_SHORT).show();
    }

    mSideAnimator = new ValueAnimator();
    mSideAnimator.setDuration(300);
    mSideAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            mSide.setTranslationX((Float) animation.getAnimatedValue());
        }
    });

    mHideSideRunnable = new Runnable() {
        @Override
        public void run() {
            hideSide();
        }
    };
    SimpleHandler.getInstance().postDelayed(mHideSideRunnable, 3000);
}
 
Example #25
Source File: PostFragment.java    From Nimingban with Apache License 2.0 4 votes vote down vote up
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
        @Nullable Bundle savedInstanceState) {
    ViewGroup view = (ViewGroup) inflater.inflate(R.layout.activity_toolbar, container, false);
    ViewGroup contentPanel = (ViewGroup) view.findViewById(R.id.content_panel);
    ViewGroup contentView = (ViewGroup) inflater.inflate(R.layout.fragment_post, contentPanel, true);

    mToolbar = (Toolbar) view.findViewById(R.id.toolbar);
    // I like hardcode
    mToolbar.setSubtitle("A岛·adnmb.com");
    if (mId != null) {
        mToolbar.setTitle(mSite.getPostTitle(getContext(), mId));
    } else {
        mToolbar.setTitle(getString(R.string.thread));
    }
    mToolbar.setNavigationIcon(DrawableManager.getDrawable(getContext(), R.drawable.v_arrow_left_dark_x24));
    mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            getFragmentHost().finishFragment(PostFragment.this);
        }
    });
    mToolbar.inflateMenu(R.menu.activity_post);
    mToolbar.setOnMenuItemClickListener(this);

    mContentLayout = (ContentLayout) contentView.findViewById(R.id.content_layout);
    mRecyclerView = mContentLayout.getRecyclerView();

    mReplyHelper = new ReplyHelper();
    mReplyHelper.setEmptyString(getString(R.string.not_found));
    mContentLayout.setHelper(mReplyHelper);
    if (Settings.getFastScroller()) {
        mContentLayout.showFastScroll();
    } else {
        mContentLayout.hideFastScroll();
    }

    mReplyAdapter = new ReplyAdapter();
    mRecyclerView.setAdapter(mReplyAdapter);
    mRecyclerView.setSelector(Ripple.generateRippleDrawable(
            getContext(), ResourcesUtils.getAttrBoolean(getContext(), R.attr.dark)));
    mRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
    mRecyclerView.setOnItemClickListener(this);
    mRecyclerView.setOnItemLongClickListener(this);
    mRecyclerView.hasFixedSize();
    mOnScrollListener = new RecyclerView.OnScrollListener() {
        @Override
        public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
            if (RecyclerView.SCROLL_STATE_DRAGGING == newState) {
                pauseHolders();
            } else if (RecyclerView.SCROLL_STATE_IDLE == newState) {
                resumeHolders();
            }
        }
    };
    mRecyclerView.addOnScrollListener(mOnScrollListener);

    mOpColor = getResources().getColor(R.color.colorAccent);

    // Refresh
    mReplyHelper.firstRefresh();

    Messenger.getInstance().register(Constants.MESSENGER_ID_REPLY, this);
    Messenger.getInstance().register(Constants.MESSENGER_ID_FAST_SCROLLER, this);

    isLoaded = false;

    return view;
}
 
Example #26
Source File: RecordActivity.java    From Nimingban with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("deprecation")
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setStatusBarColor(ResourcesUtils.getAttrColor(this, R.attr.colorPrimaryDark));
    ToolbarActivityHelper.setContentView(this, R.layout.activity_record);
    setActionBarUpIndicator(DrawableManager.getDrawable(this, R.drawable.v_arrow_left_dark_x24));

    View tip = findViewById(R.id.tip);
    mRecyclerView = (EasyRecyclerView) findViewById(R.id.recycler_view);
    mViewTransition = new ViewTransition(tip, mRecyclerView);

    // Layout Manager
    int interval = getResources().getDimensionPixelOffset(R.dimen.card_interval);
    if (getResources().getBoolean(R.bool.two_way)) {
        mRecyclerView.setLayoutManager(new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL));
        MarginItemDecoration decoration = new MarginItemDecoration(interval, interval, interval, interval, interval);
        mRecyclerView.addItemDecoration(decoration);
        decoration.applyPaddings(mRecyclerView);
        mRecyclerView.setItemAnimator(new SlideInUpAnimator());
    } else {
        int halfInterval = interval / 2;
        mRecyclerView.addItemDecoration(new RawMarginItemDecoration(0, halfInterval, 0, halfInterval));
        mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
        mRecyclerView.setPadding(0, halfInterval, 0, halfInterval);
    }

    // touch guard manager  (this class is required to suppress scrolling while swipe-dismiss animation is running)
    mRecyclerViewTouchActionGuardManager = new RecyclerViewTouchActionGuardManager();
    mRecyclerViewTouchActionGuardManager.setInterceptVerticalScrollingWhileAnimationRunning(true);
    mRecyclerViewTouchActionGuardManager.setEnabled(true);

    // swipe manager
    mRecyclerViewSwipeManager = new RecyclerViewSwipeManager();

    mAdapter = new RecordAdapter();
    mAdapter.setHasStableIds(true);
    mWrappedAdapter = mRecyclerViewSwipeManager.createWrappedAdapter(mAdapter);      // wrap for swiping

    final GeneralItemAnimator animator = new SwipeDismissItemAnimator();

    // Change animations are enabled by default since support-v7-recyclerview v22.
    // Disable the change animation in order to make turning back animation of swiped item works properly.
    animator.setSupportsChangeAnimations(false);

    mRecyclerView.hasFixedSize();
    mRecyclerView.setAdapter(mWrappedAdapter);  // requires *wrapped* adapter
    mRecyclerView.setItemAnimator(animator);
    mRecyclerView.setOnItemClickListener(this);
    mRecyclerView.setSelector(Ripple.generateRippleDrawable(this, ResourcesUtils.getAttrBoolean(this, R.attr.dark)));
    mRecyclerView.setDrawSelectorOnTop(true);
    mRecyclerView.setClipToPadding(false);
    mRecyclerView.setClipChildren(false);

    // NOTE:
    // The initialization order is very important! This order determines the priority of touch event handling.
    //
    // priority: TouchActionGuard > Swipe > DragAndDrop
    mRecyclerViewTouchActionGuardManager.attachRecyclerView(mRecyclerView);
    mRecyclerViewSwipeManager.attachRecyclerView(mRecyclerView);

    updateLazyList();
    checkEmpty(false);

    Messenger.getInstance().register(Constants.MESSENGER_ID_UPDATE_RECORD, this);
}
 
Example #27
Source File: SearchLayout.java    From MHViewer with Apache License 2.0 4 votes vote down vote up
@SuppressLint("InflateParams")
private void init(Context context) {
    Resources resources = context.getResources();
    mInflater = LayoutInflater.from(context);

    mLayoutManager = new LinearLayoutManager(context);
    mAdapter = new SearchAdapter();
    setLayoutManager(mLayoutManager);
    setAdapter(mAdapter);
    setHasFixedSize(true);
    setClipToPadding(false);
    int interval = resources.getDimensionPixelOffset(R.dimen.search_layout_interval);
    int paddingH = resources.getDimensionPixelOffset(R.dimen.search_layout_margin_h);
    int paddingV = resources.getDimensionPixelOffset(R.dimen.search_layout_margin_v);
    MarginItemDecoration decoration = new MarginItemDecoration(
            interval, paddingH, paddingV, paddingH, paddingV);
    addItemDecoration(decoration);
    decoration.applyPaddings(this);

    // Create normal view
    View normalView = mInflater.inflate(R.layout.search_normal, null);
    mNormalView = normalView;
    mCategoryTable = (CategoryTable) normalView.findViewById(R.id.search_category_table);
    mNormalSearchMode = (RadioGridGroup) normalView.findViewById(R.id.normal_search_mode);
    mNormalSearchModeHelp = (ImageView) normalView.findViewById(R.id.normal_search_mode_help);
    mEnableAdvanceSwitch = (SwitchCompat) normalView.findViewById(R.id.search_enable_advance);
    mNormalSearchModeHelp.setOnClickListener(this);
    Ripple.addRipple(mNormalSearchModeHelp, !AttrResources.getAttrBoolean(context, R.attr.isLightTheme));
    mEnableAdvanceSwitch.setOnCheckedChangeListener(SearchLayout.this);
    mEnableAdvanceSwitch.setSwitchPadding(resources.getDimensionPixelSize(R.dimen.switch_padding));

    // Create advance view
    mAdvanceView = mInflater.inflate(R.layout.search_advance, null);
    mTableAdvanceSearch = (AdvanceSearchTable) mAdvanceView.findViewById(R.id.search_advance_search_table);

    // Create image view
    mImageView = (ImageSearchLayout) mInflater.inflate(R.layout.search_image, null);
    mImageView.setHelper(this);

    // Create action view
    mActionView = mInflater.inflate(R.layout.search_action, null);
    mAction = (TextView) mActionView.findViewById(R.id.action);
    mAction.setOnClickListener(this);
}
 
Example #28
Source File: GalleryCommentsScene.java    From MHViewer with Apache License 2.0 4 votes vote down vote up
@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_drawer_favorites, 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, AttrResources.getAttrColor(context, R.attr.dividerColor),
            LayoutUtils.dp2pix(context, 1));
    decoration.setPadding(ResourcesUtils.getAttrDimensionPixelOffset(context, R.attr.dialogPreferredPadding));
    rv.addItemDecoration(decoration);
    rv.setSelector(Ripple.generateRippleDrawable(context, !AttrResources.getAttrBoolean(context, R.attr.isLightTheme), new ColorDrawable(Color.TRANSPARENT)));
    rv.setClipToPadding(false);
    builder.setView(rv).show();
}
 
Example #29
Source File: GalleryCommentsScene.java    From MHViewer with Apache License 2.0 4 votes vote down vote up
@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();
    AssertUtils.assertNotNull(context);
    Resources resources = context.getResources();
    int paddingBottomFab = resources.getDimensionPixelOffset(R.dimen.gallery_padding_bottom_fab);

    Drawable drawable = DrawableManager.getVectorDrawable(context, R.drawable.big_sad_pandroid);
    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,
            RecyclerView.VERTICAL, false));
    LinearDividerItemDecoration decoration = new LinearDividerItemDecoration(
            LinearDividerItemDecoration.VERTICAL, AttrResources.getAttrColor(context, R.attr.dividerColor),
            LayoutUtils.dp2pix(context, 1));
    decoration.setShowLastDivider(true);
    mRecyclerView.addItemDecoration(decoration);
    mRecyclerView.setSelector(Ripple.generateRippleDrawable(context, !AttrResources.getAttrBoolean(context, R.attr.isLightTheme), new ColorDrawable(Color.TRANSPARENT)));
    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;
}
 
Example #30
Source File: DownloadsScene.java    From MHViewer with Apache License 2.0 4 votes vote down vote up
@Nullable
@Override
public View onCreateView3(LayoutInflater inflater,
        @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.scene_download, container, false);

    View content = ViewUtils.$$(view, R.id.content);
    mRecyclerView = (EasyRecyclerView) ViewUtils.$$(content, R.id.recycler_view);
    FastScroller fastScroller = (FastScroller) ViewUtils.$$(content, R.id.fast_scroller);
    mFabLayout = (FabLayout) ViewUtils.$$(view, R.id.fab_layout);
    TextView tip = (TextView) ViewUtils.$$(view, R.id.tip);
    mViewTransition = new ViewTransition(content, tip);

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

    Drawable drawable = DrawableManager.getVectorDrawable(context, R.drawable.big_download);
    drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
    tip.setCompoundDrawables(null, drawable, null, null);

    mAdapter = new DownloadAdapter();
    mAdapter.setHasStableIds(true);
    mRecyclerView.setAdapter(mAdapter);
    mLayoutManager = new AutoStaggeredGridLayoutManager(0, StaggeredGridLayoutManager.VERTICAL);
    mLayoutManager.setColumnSize(resources.getDimensionPixelOffset(Settings.getDetailSizeResId()));
    mLayoutManager.setStrategy(AutoStaggeredGridLayoutManager.STRATEGY_MIN_SIZE);
    mRecyclerView.setLayoutManager(mLayoutManager);
    mRecyclerView.setSelector(Ripple.generateRippleDrawable(context, !AttrResources.getAttrBoolean(context, R.attr.isLightTheme), new ColorDrawable(Color.TRANSPARENT)));
    mRecyclerView.setDrawSelectorOnTop(true);
    mRecyclerView.setClipToPadding(false);
    mRecyclerView.setOnItemClickListener(this);
    mRecyclerView.setOnItemLongClickListener(this);
    mRecyclerView.setChoiceMode(EasyRecyclerView.CHOICE_MODE_MULTIPLE_CUSTOM);
    mRecyclerView.setCustomCheckedListener(new DownloadChoiceListener());
    // Cancel change animation
    RecyclerView.ItemAnimator itemAnimator = mRecyclerView.getItemAnimator();
    if (itemAnimator instanceof SimpleItemAnimator) {
        ((SimpleItemAnimator) itemAnimator).setSupportsChangeAnimations(false);
    }
    int interval = resources.getDimensionPixelOffset(R.dimen.gallery_list_interval);
    int paddingH = resources.getDimensionPixelOffset(R.dimen.gallery_list_margin_h);
    int paddingV = resources.getDimensionPixelOffset(R.dimen.gallery_list_margin_v);
    MarginItemDecoration decoration = new MarginItemDecoration(interval, paddingH, paddingV, paddingH, paddingV);
    mRecyclerView.addItemDecoration(decoration);
    decoration.applyPaddings(mRecyclerView);
    if (mInitPosition >= 0) {
        mRecyclerView.scrollToPosition(mInitPosition);
        mInitPosition = -1;
    }

    fastScroller.attachToRecyclerView(mRecyclerView);
    HandlerDrawable handlerDrawable = new HandlerDrawable();
    handlerDrawable.setColor(AttrResources.getAttrColor(context, R.attr.widgetColorThemeAccent));
    fastScroller.setHandlerDrawable(handlerDrawable);
    fastScroller.setOnDragHandlerListener(this);

    mFabLayout.setExpanded(false, false);
    mFabLayout.setHidePrimaryFab(true);
    mFabLayout.setAutoCancel(false);
    mFabLayout.setOnClickFabListener(this);
    addAboveSnackView(mFabLayout);

    updateView();

    guide();

    return view;
}