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
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;
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.
private static final String SKU_DOWNLOAD = "DOWNLOAD";
private static final String SKU_STREAMING = "STREAMING";
private static final String SKU_FULL_VERSION = "FULLVERSION";
private void isUserBuyStreaming() {
if (!isCafeInstalled()) {
Toast.makeText(this, R.string.cafebazaar_isnot_installed_error, Toast.LENGTH_SHORT).show();
return;
}
mHelper.queryInventoryAsync(new IabHelper.QueryInventoryFinishedListener() {
public void onQueryInventoryFinished(IabResult result, Inventory inventory) {
if (result.isFailure()) {
Toast.makeText(DetailActivity.this, R.string.query_inventory_error, Toast.LENGTH_SHORT).show();
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 void buyDownload() {
if (!isCafeInstalled()) {
Toast.makeText(this, R.string.cafebazaar_isnot_installed_error, Toast.LENGTH_SHORT).show();
return;
}
mHelper.launchPurchaseFlow(this, SKU_DOWNLOAD, 1, new IabHelper.OnIabPurchaseFinishedListener() {
@Override
public void onIabPurchaseFinished(IabResult result, Purchase info) {
if (result.isFailure()) {
private void buyFullVersion() {
mHelper.launchPurchaseFlow(this, SKU_FULL_VERSION, 1, new IabHelper.OnIabPurchaseFinishedListener() {
@Override
public void onIabPurchaseFinished(IabResult result, Purchase info) {
if (result.isFailure()) {
Toast.makeText(DetailActivity.this, R.string.purchasing_error, Toast.LENGTH_SHORT).show();
return;
} else if (info.getSku().equals(SKU_FULL_VERSION)) {
bookmarkMovie();
}