Forum Avatars using the first letter of the forum and color from group

Also prevents the snackbar from hiding the bottom of the list.

Closes #337
This commit is contained in:
Torsten Grote
2016-05-04 13:04:00 -03:00
parent 3193b73687
commit e87991ecac
9 changed files with 172 additions and 11 deletions

View File

@@ -0,0 +1,44 @@
package org.briarproject.android.util;
import android.content.Context;
import android.support.design.widget.CoordinatorLayout;
import android.support.design.widget.Snackbar;
import android.util.AttributeSet;
import android.view.View;
public class BriarRecyclerViewBehavior
extends CoordinatorLayout.Behavior<BriarRecyclerView> {
public BriarRecyclerViewBehavior(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
public boolean onDependentViewChanged(CoordinatorLayout parent,
BriarRecyclerView child, View dependency) {
// FIXME the below code works, but does not reset margin when snackbar is dismissed
/*
int margin = 0;
if (dependency.isShown()) margin = dependency.getHeight();
// set snackbar height as bottom margin if it is shown
CoordinatorLayout.LayoutParams params =
(CoordinatorLayout.LayoutParams) child.getLayoutParams();
params.setMargins(0, 0, 0, margin);
child.setLayoutParams(params);
child.scrollToPosition(0);
*/
return true;
}
@Override
public boolean layoutDependsOn(CoordinatorLayout parent,
BriarRecyclerView child, View dependency) {
// we only want to trigger the change
// only when the changes is from a snackbar
return dependency instanceof Snackbar.SnackbarLayout;
}
}