Skip to content

Instantly share code, notes, and snippets.

View yudikarma's full-sized avatar
🏠
Working from home

yudi karma yudikarma

🏠
Working from home
View GitHub Profile
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/dashboardfragment"
android:icon="@drawable/ic_home_white_32dp"
android:title="Dashboard"></item>
<item android:id="@+id/reportfragment"
android:icon="@drawable/ic_person_outline_white_32dp"
android:title="Report"></item>
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.3.21'
repositories {
google()
jcenter()
}
dependencies {
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply plugin: 'androidx.navigation.safeargs.kotlin'
===========================in adapter ======================
viewHolder.linecar.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
selected_position = i;
notifyDataSetChanged();
Log.e("position",""+selected_position);
Intent intent = new Intent("custom-message");
// intent.putExtra("quantity",Integer.parseInt(quantity.getText().toString()));
@yudikarma
yudikarma / detect device reverse portrait
Last active January 11, 2019 09:41
method detect reverse portrait
private SensorManager mSensorManager;
private Sensor mOrientation;
boolean Upsidedown = false;
float value_0 = -10000;
float value_1 = -10000;
float deviceRotation = 0.0f;
boolean ispotrait = false;
@yudikarma
yudikarma / MyDBHandler
Created January 2, 2019 09:14
Sqlite Helper for add record with image blop
package com.example.yudikarma.androidcamera.Sqlite;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.DatabaseUtils;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
<?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"
xmlns:app="http://schemas.android.com/apk/res-auto">
<com.example.yudikarma.androidcamera.Helper.AutoFitTextureView
android:id="@+id/textureview"
android:layout_width="wrap_content"
/**
* @return The largest supported picture size.
*/
public Size getDefaultPictureSize() {
StreamConfigurationMap configs = mCharacteristics.get(
CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP);
android.util.Size[] supportedSizes = configs.getOutputSizes(sCaptureImageFormat);
// Find the largest supported size.
android.util.Size largestSupportedSize = supportedSizes[0];
package com.example.yudikarma.androidcamera.Helper;
import android.content.Context;
import android.util.AttributeSet;
import android.view.TextureView;
/**
* A {@link TextureView} that can be adjusted to a specified aspect ratio.
*/
public class AutoFitTextureView extends TextureView {
private void captureStillPicture() {
try {
if (null == mCameraDevice ) {
return;
}
// This is the CaptureRequest.Builder that we use to take a picture.
final CaptureRequest.Builder captureBuilder =
mCameraDevice.createCaptureRequest(CameraDevice.TEMPLATE_STILL_CAPTURE);
captureBuilder.addTarget(mImageReader.getSurface());