Skip to content

Instantly share code, notes, and snippets.

// create new directive with cli :
ng g d directive-name
// directives are used as attribute to existant html element ex :
<div direcrive-name> ... </div>
// example of a directive :
@Directive({
selector: '[myDirectives]'
// first add these to classes :
https://github.com/frogermcs/InstaMaterial/blob/master/app/src/main/java/io/github/froger/instamaterial/ui/view/FeedContextMenu.java
https://github.com/frogermcs/InstaMaterial/blob/master/app/src/main/java/io/github/froger/instamaterial/ui/view/FeedContextMenuManager.java
// Then add dependency ButterKnife :
// butterknife
compile 'com.jakewharton:butterknife:8.4.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.4.0'
// add view_context_menu.xml the layout of the menu :
@d4rkc0de
d4rkc0de / ViewPager with tabs
Created March 9, 2017 22:47
ViewPager with tabs code
// dependency for TabLayout
compile 'com.android.support:design:24.1.1'
// xml
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<include
@d4rkc0de
d4rkc0de / Angular 2 : child componenet -> parent componenet
Created February 27, 2017 14:33
Angular 2 : child componenet -> parent componenet
// child component :
export class ChildComponent implements OnInit {
@Output() close: EventEmitter<boolean> = new EventEmitter<boolean>();
callEvent() {
this.close.emit(true);
}
...
}
@d4rkc0de
d4rkc0de / scene transition
Created February 11, 2017 15:01
scene transition
package me.wangyuwei.signuptransition;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.transition.ChangeBounds;
import android.transition.Scene;
import android.transition.TransitionManager;
import android.view.animation.DecelerateInterpolator;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
@d4rkc0de
d4rkc0de / Scene : elevate from bottom to top
Created February 11, 2017 10:49
Scene : elevate from bottom to top
// java
private Scene mSceneMain;
LinearLayout container = (LinearLayout) findViewById(R.id.container);
mSceneMain = Scene.getSceneForLayout(container, R.layout.scene_main, this);
container.postDelayed(new Runnable() {
@Override
public void run() {
TransitionManager.go(mSceneMain, new ChangeBounds().setDuration(500).setInterpolator(new DecelerateInterpolator()));
}
}, 1000);
@d4rkc0de
d4rkc0de / Shared element transition among fragments that belong to different activities
Created February 9, 2017 13:30
Shared element transition among fragments that belong to different activities
Inside the first Activity :
Pair[] pairs = new Pair[1];
pairs[0] = new Pair(thumbnailImage, "THUMBNAIL_IMAGE");
public static void transitionExpand(Activity activity, Intent intent, Pair<View, String>[] sharedElements) {
ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(activity, sharedElements);
ActivityCompat.startActivity(activity, intent, options.toBundle());
}
@d4rkc0de
d4rkc0de / Shared Element transition between 2 activities
Created February 9, 2017 11:00
Shared Element transition between 2 activities
Pair<View, String> p1 = Pair.create(findViewById(R.id.linearLayout), "camera");
Pair<View, String> p2 = Pair.create(findViewById(R.id.button), "button");
ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(MainActivity.this,p1,p2);
startActivity(new Intent(MainActivity.this,Main2Activity.class),options.toBundle());
@d4rkc0de
d4rkc0de / Exclude the status bar and navigation bar from the window's default exit enter shared element transition
Created February 9, 2017 10:47
Exclude the status bar and navigation bar from the window's default exit enter shared element transition
inside onCreate() :
Transition fade = new Fade();
fade.excludeTarget(android.R.id.statusBarBackground, true);
fade.excludeTarget(android.R.id.navigationBarBackground, true);
getWindow().setEnterTransition(fade);
or via xml :
<?xml version="1.0" encoding="utf-8"?>
@d4rkc0de
d4rkc0de / animateBottom-up.java
Created November 29, 2016 13:11
Animate view locate at the bottom up/down elavation
public void animate(View view,Boolean up) {
if(up) {
view.setVisibility(View.VISIBLE);
ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(view, "translationY", view.getBottom(), 0);
objectAnimator.setDuration(400).setInterpolator(new DecelerateInterpolator());
objectAnimator.start();
} else {
ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(view, "translationY", 0, view.getBottom());
objectAnimator.setDuration(400).setInterpolator(new AccelerateInterpolator());
objectAnimator.start();