Skip to content

Instantly share code, notes, and snippets.

View javikin's full-sized avatar

Javier Olan javikin

View GitHub Profile
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout
android:id="@+id/textureView"
android:background="@color/white"
/**
* Crop a image taking a recerence a view parent like a frame, and a view child like final
* reference
*
* @param bitmap image to crop
* @param frame where the image is set it
* @param reference frame to take reference for crop the image
* @return image already cropped
*/
public static byte[] cropImage(Bitmap bitmap, View frame, View reference){
class MainActivity : Activity() {
...
override fun onCreate(savedInstanceState: Bundle?) {
...
mAdapter = MyAdapter(myDataset, {onClickActionItemList(it)}, {onClickActionButtonItemList(it)})
...
}
class MyAdapter(val mDataset: Array<String>,
val itemClickListener: (String) -> Unit,
val itemClickButtonListener: (String) -> Unit) :
RecyclerView.Adapter<MyAdapter.ViewHolder>() {
...
class ViewHolder(var mView: View) : RecyclerView.ViewHolder(mView) {
fun bind(item: String,
itemClickListener: (String) -> Unit,
public class MainActivity extends Activity implements MyAdapter.CallBackItemList{
...
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
...
mAdapter = new MyAdapter(myDataset, this);
...
public class MyAdapter extends RecyclerView.Adapter<MyAdapter.ViewHolder> {
...
private CallBackItemList mListener;
public MyAdapter(String[] myDataset, CallBackItemList listener) {
...
mListener = listener;
}
button.setOnClickListener { "Click".shortToast() }
fun String.shortToast() {
Toast.makeText(App.context(), this, Toast.LENGTH_SHORT).show()
}
@javikin
javikin / Button.kt
Last active December 1, 2017 01:15
button.setOnClickListener ({v -> Toast.makeText(v.context, "Yellow", Toast.LENGTH_SHORT).show() })
public class MainActivity extends Activity implements OnClickListener {
...
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
...
button.setOnClickListener(this);
}
public void onClick(View v) {