Skip to content

Instantly share code, notes, and snippets.

View yccheok's full-sized avatar

Yan Cheng Cheok yccheok

View GitHub Profile
// Code to download.
Drive drive = getDriveService(googleSignInAccount);
com.google.api.services.drive.model.File driveFile = searchFromGoogleDrive(drive);
File downloadedZipFile = downloadFromAppFolder(drive, driveFile);
// Code to upload.
Drive drive = getDriveService(googleSignInAccount);
com.google.api.services.drive.model.File driveFile = searchFromGoogleDrive(drive);
uploadToAppFolder(drive, driveFile, zipFile)
private void startMediaRecorder() {
mediaRecorder = new MediaRecorder();
mediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
mediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
mediaRecorder.setAudioChannels(1);
mediaRecorder.setAudioSamplingRate(8000);
mediaRecorder.setAudioEncodingBitRate(32000);
/*
mediaRecorder.setAudioChannels(1);
// Minimize the execution scope of new user thread.
// Most code still run in UI thread, except isBillingSupported.
// Ensure user thread doesn't deal with member variable.
@Override
public void onServiceConnected(ComponentName name, IBinder service) {
BillingHelper.logVerbose(TAG, "Billing service connected.");
mService = IInAppBillingService.Stub.asInterface(service);
String packageName = mApplicationContext.getPackageName();
java.lang.IndexOutOfBoundsException:
at androidx.recyclerview.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline (RecyclerView.java:6023)
at androidx.recyclerview.widget.RecyclerView$Recycler.getViewForPosition (RecyclerView.java:5958)
at androidx.recyclerview.widget.RecyclerView$Recycler.getViewForPosition (RecyclerView.java:5954)
at androidx.recyclerview.widget.LinearLayoutManager$LayoutState.next (LinearLayoutManager.java:2226)
at androidx.recyclerview.widget.LinearLayoutManager.layoutChunk (LinearLayoutManager.java:1557)
at androidx.recyclerview.widget.LinearLayoutManager.fill (LinearLayoutManager.java:1517)
at androidx.recyclerview.widget.LinearLayoutManager.onLayoutChildren (LinearLayoutManager.java:622)
at androidx.recyclerview.widget.RecyclerView.dispatchLayoutStep1 (RecyclerView.java:3941)
at androidx.recyclerview.widget.RecyclerView.dispatchLayout (RecyclerView.java:3705)
exception.class.missing._Unknown_: View Holder 2
at androidx.recyclerview.widget.RecyclerView.handleMissingPreInfoForChangeError (RecyclerView.java:4124)
at androidx.recyclerview.widget.RecyclerView.dispatchLayoutStep3 (RecyclerView.java:4048)
at androidx.recyclerview.widget.RecyclerView.dispatchLayout (RecyclerView.java:3718)
at androidx.recyclerview.widget.RecyclerView.onLayout (RecyclerView.java:4260)
at android.view.View.layout (View.java:18804)
at android.view.ViewGroup.layout (ViewGroup.java:5951)
at android.widget.FrameLayout.layoutChildren (FrameLayout.java:323)
at android.widget.FrameLayout.onLayout (FrameLayout.java:261)
at android.view.View.layout (View.java:18804)
private boolean isHeAacEncoderSupported() {
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN) {
int numCodecs = MediaCodecList.getCodecCount();
for (int i = 0; i < numCodecs; i++) {
MediaCodecInfo codecInfo = MediaCodecList.getCodecInfoAt(i);
if (!codecInfo.isEncoder()) {
continue;
}
Uri uri = Uri.fromFile(destination);
MediaMetadataRetriever mmr = new MediaMetadataRetriever();
mmr.setDataSource(WeNoteApplication.instance(), uri);
String durationStr = mmr.extractMetadata(MediaMetadataRetriever.METADATA_KEY_DURATION);
long length = 0L;
try {
length = Long.parseLong(durationStr);
} catch (NumberFormatException e) {
Log.e(TAG, "", e);
}
private void startMediaRecorder() {
mediaRecorder = new MediaRecorder();
mediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
mediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
mediaRecorder.setAudioChannels(1);
mediaRecorder.setAudioSamplingRate(8000);
mediaRecorder.setAudioEncodingBitRate(32000);
/*
mediaRecorder.setAudioChannels(1);
mediaRecorder.setAudioSamplingRate(44100);
public class SyncForegroundIntentService extends IntentService {
@Override
protected void onHandleIntent(@Nullable Intent intent) {
try {
NotificationCompat.Builder builder = ...
startForeground(SYNC_FOREGROUND_INTENT_SERVICE_ID, builder.build());
2019-07-15 19:09:50.771 16243-16482/com.yocto.wenote E/Utils: com.google.api.client.googleapis.json.GoogleJsonResponseException: 403 Forbidden
{
"code": 403,
"errors": [
{
"domain": "usageLimits",
"message": "Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup.",
"reason": "dailyLimitExceededUnreg",
"extendedHelp": "https://code.google.com/apis/console"
}