This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
syntax = "proto3"; | |
package protobuf; | |
service StreamService { | |
rpc FetchResponse (Request) returns (stream Response) {} | |
} | |
message Request { | |
int32 id = 1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface AdapterOnClick { | |
fun onClick(item: Any) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Sample adapter with click interface | |
class DemoAdapter(val adapterOnClick: AdapterOnClick) : RecyclerView.Adapter<DemoAdapter.DemoVH> { | |
var itemList:MutableList<Any> = ArrayList() | |
override fun onBindViewHolder(demoVH: DemoVH, i: Int) { | |
demoVH.setItem(itemList.get(i)) | |
} | |
/* | |
implement other abstract method .. | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DemoActivity : AppCompatActivity(), AdapterOnClick { | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContentView(R.layout.activity_demo) | |
//create our adapter here and passing in our class | |
var demoAdapter = DemoAdapter(this) | |
//other layout manager binding | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Adapter having lambda function inside the constructor | |
class DemoAdapter(val adapterOnClick : (Any) -> Unit): RecyclerView.Adapter<DemoAdapter.DemoVH>(){ | |
var itemList:MutableList<Any> = ArrayList() | |
override fun onBindViewHolder(demoVH: DemoVH, i: Int) { | |
demoVH.setItem(itemList.get(i)) | |
} | |
/* | |
other abstract method implementation | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DemoActivity : AppCompatActivity(){ | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContentView(R.layout.activity_demo) | |
//now we creating adapter and passing in a lambda method | |
var demoAdapter = DemoAdapter{ item -> doClick(item) } | |
} | |
//creating method to make it look simpler |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"context" | |
"io" | |
"log" | |
pb "github.com/pramonow/go-grpc-server-streaming-example/src/proto" | |
"google.golang.org/grpc" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"log" | |
"net" | |
"sync" | |
"time" | |
pb "github.com/pramonow/go-grpc-server-streaming-example/src/proto" |