Skip to content

Instantly share code, notes, and snippets.

private void connectToRoom(String roomName) {
configureAudio(true);
ConnectOptions.Builder connectOptionsBuilder = new ConnectOptions.Builder(accessToken)
.roomName(roomName);
/*
* Add local audio track to connect options to share with participants.
*/
if (localAudioTrack != null) {
connectOptionsBuilder
// rxjava-challenge-solution
// this example use RxJava 1.0
// Province class => data class Province(val id: Int ,val name:String, var cities:List<City>? = null)
class DataManager {
// solution
fun getProvincesAndCities(): Observable<List<Province>> {
return getProvinces()
.subscribeOn(Schedulers.io())
void drawCustomMethod(Canvas canvas) {
int startLine = getTouchedLine(startX, startY);
int startCharPos = getCharPositionByTouch(startX, startY, startLine);
int currentLine = getTouchedLine(currentX, currentY);
int currentCharPos = getCharPositionByTouch(currentX, currentY, currentLine);
if(startLine == currentLine) {
drawSelection(canvas,startCharPos,currentCharPos,startLine);
return;
@abbas-oveissi
abbas-oveissi / gist:4987020
Last active February 28, 2020 14:44
sample C# code for socket
void drawSelection(Canvas canvas, int startChar, int endChar, int line) {
Rect rect = getTextRect(line);
float startX = layout.getPrimaryHorizontal(startChar );
float endX = 0;
int maxPosLine = layout.getLineEnd(line);
int getTouchedLine(float y) {
int line = 0;
for (int i = 0; i < layout.getLineCount(); i++) {
if (y > layout.getLineTop(i) && y < layout.getLineBottom(i)) {
line = i;
break;
}
}
return line;
}
@Override
public boolean onTouchEvent(MotionEvent event) {
int action = event.getActionMasked();
float x = event.getX();
float y = event.getY();
switch (action) {
case MotionEvent.ACTION_DOWN:
startX = x;
startY = y;
if (boring == null && isUndefined(desiredWidth) && desiredWidth <= width) {
// Is used when the width is not known and the text is not boring, ie. if it contains
// unicode characters.
layout = new StaticLayout();
} else if (boring != null && boring.width <= width) {
// Is used for single-line, boring text when the width is either unknown or bigger
// than the width of the text.
layout = new BoringLayout();
} else {
// Is used for multiline, boring text and the width is known.
public class VerticalTimelineDecoration extends RecyclerView.ItemDecoration {
Paint paintFill = null;
Paint paintStrokeFill = null;
Paint paintStroke = null;
Paint paintDotLine = null;
Paint paintText=null;
Paint paintTextBold=null;
private void consumeDownloadPurchase(Purchase purchase) {
mHelper.consumeAsync(purchase, new IabHelper.OnConsumeFinishedListener() {
@Override
public void onConsumeFinished(Purchase purchase, IabResult result) {
if (result.isFailure()) {
Toast.makeText(DetailActivity.this, R.string.purchasing_error, Toast.LENGTH_SHORT).show();
return;
}
startDownloading();
}
private static final String SKU_DOWNLOAD = "DOWNLOAD";
private static final String SKU_STREAMING = "STREAMING";
private static final String SKU_FULL_VERSION = "FULLVERSION";