This file contains hidden or 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
fun createBasicAlertDialog(){ | |
val builder = AlertDialog.Builder(this) | |
builder.setTitle("[DIALOG TITLE]") | |
builder.setMessage("[DIALOG MESSAGE]") | |
builder.setPositiveButton("[YES TEXT]") { dialog, which -> | |
// Action on click yes | |
} | |
builder.setCancelable(false) |
This file contains hidden or 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 Parameter: | |
String: "file:///storage/emulated/0/Android/data/com.example.disappeardents/cache/roof_1.jpg" | |
*/ | |
fun uriStringToBitmap(uriString : String) : Bitmap { | |
val uri = uriString.toUri() | |
val uriPath = uri.path | |
val bitmap = BitmapFactory.decodeFile(uriPath) |
This file contains hidden or 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
<!-- CHANGE TITLE --> | |
<activity android:name=".ActivityName" | |
android:label="[LABEL HERE]"/> | |
<!-- HIDE ACTION BAR --> | |
<activity android:name=".ActivityName" | |
android:theme="@style/AppTheme.NoActionBar"/> | |
This file contains hidden or 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
// Create action bar item (notification icon) | |
override fun onCreateOptionsMenu(menu: Menu): Boolean { | |
// Inflate the menu; this adds items to the action bar if it is present. | |
menuInflater.inflate(R.menu.action_bar_notifications, menu) | |
// Get the menu item | |
var menuItem = menu.findItem(R.id.notifications) | |
// Get the view of the menu item |
This file contains hidden or 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
// uri exposure fix | |
var builder = StrictMode.VmPolicy.Builder() | |
StrictMode.setVmPolicy(builder.build()) | |
// Class level variable | |
var photoURI: Uri? = null | |
// STEP 1: Call this where you need to do the capturing | |
fun openCamera(fileName: String, requestCode: Int){ | |
val intent = Intent(MediaStore.ACTION_IMAGE_CAPTURE); |
This file contains hidden or 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
<?xml version="1.0" encoding="utf-8"?> | |
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:app="http://schemas.android.com/apk/res-auto" | |
xmlns:tools="http://schemas.android.com/tools" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
tools:context=".Schedule.ScheduleActivity"> | |
<androidx.core.widget.NestedScrollView | |
android:layout_width="match_parent" |
This file contains hidden or 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
recycler_view.layoutManager = GridLayoutManager(this,2) |
This file contains hidden or 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
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
// Tell Android to use the Toolbar as the ActionBar | |
setSupportActionBar(toolbar) | |
// Remove default title, so we can use our custom title | |
supportActionBar!!.setDisplayShowTitleEnabled(false) | |
// Show the up/back button |
This file contains hidden or 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
<androidx.cardview.widget.CardView | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
app:cardCornerRadius="20dp" | |
android:layout_gravity="center" | |
app:cardElevation="50dp"> | |
<ImageView | |
android:id="@+id/imageView" | |
android:layout_width="match_parent" |
This file contains hidden or 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
<?xml version="1.0" encoding="utf-8"?> | |
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:app="http://schemas.android.com/apk/res-auto" | |
xmlns:tools="http://schemas.android.com/tools" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
tools:context=".Dashboard.DashboardActivity" | |
android:orientation="vertical"> | |
<androidx.appcompat.widget.Toolbar |
OlderNewer