Skip to content

Instantly share code, notes, and snippets.

View vpaliy's full-sized avatar

Vasyl Paliy vpaliy

View GitHub Profile
public class MistakesActivity extends ActionBarActivity {
public static final String TABLE_NAME = "names";
private LoadTask loadTask;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_mistakes);
loadTask=new LoadTask(this);
public class MistakesActivity extends ActionBarActivity {
///provides a CRUD interface, uses SQLiteDatabase under the hood, RxJava
private IRepository dataRepository;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_mistakes);
dataRepository=new Repository(context); //a better approach would be using a dependency injection framework
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View root=inflater.inflate(authLayout(),container,false);
ButterKnife.bind(this,root);
KeyboardVisibilityEvent.setEventListener(getActivity(), isOpen -> {
callback.scale(isOpen);
if(!isOpen){
clearFocus();
}
@OnClick(R.id.caption)
public void unfold(){
if(!lock) {
caption.setVerticalText(false);
caption.requestLayout();
Rotate transition = new Rotate();
transition.setStartAngle(-90f);
transition.setEndAngle(0f);
transition.addTarget(caption);
TransitionSet set=new TransitionSet();
set.addListener(new Transition.TransitionListenerAdapter(){
@Override
public void onTransitionEnd(Transition transition) {
caption.setTranslationX(getTextPadding());
caption.setRotation(0);
caption.setVerticalText(true);
caption.requestLayout();
}
});
@Override
public void fold() {
//release the lock, so you can click on the label again and get the unfold() animation running
lock = false;
TransitionSet set = new TransitionSet();
set.setDuration(getResources().getInteger(R.integer.duration));
//simple rotate transition
Rotate transition = new Rotate();
//at the end of the transiton our view will have -90 angle
transition.setEndAngle(-90f);
@vpaliy
vpaliy / FixViews.java
Last active September 21, 2018 04:07
views.forEach(editText -> {
if (editText.getId() == R.id.password_input_edit) {
final TextInputLayout inputLayout = ButterKnife.findById(view, R.id.password_input);
final TextInputLayout confirmLayout = ButterKnife.findById(view, R.id.confirm_password);
Typeface boldTypeface = Typeface.defaultFromStyle(Typeface.BOLD);
inputLayout.setTypeface(boldTypeface);
confirmLayout.setTypeface(boldTypeface);
editText.addTextChangedListener(new TextWatcherAdapter() {
@Override
public void afterTextChanged(Editable editable) {
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:radius="50dp"/> <!-- Change this line here to 0dp -->
<stroke android:color="#87eeeeee"/>
<solid android:color="#87eeeeee"/>
</shape>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/root"
tools:background="@color/color_sign_up"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.constraint.Guideline
public class AuthAdapter extends FragmentStatePagerAdapter
implements AuthFragment.Callback {
private final AnimatedViewPager pager;
private final SparseArray<AuthFragment> authArray;
private final List<ImageView> sharedElements;
private final ImageView authBackground;
private float factor;
public AuthAdapter(FragmentManager manager, AnimatedViewPager pager,