Skip to content

Instantly share code, notes, and snippets.

View Audhil's full-sized avatar
🎯
Focusing

Mohammed Audhil Audhil

🎯
Focusing
View GitHub Profile
@Audhil
Audhil / SomeActivity.kt
Last active April 17, 2018 13:42
AlertDialogs with Extn funcs blog_4
class SomeActivity : AppCompatActivity() {
private var timeChooserDialog: AlertDialog? = null
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
showDialog()
}
private fun showDialog() {
@Audhil
Audhil / SomeFragmentFragment.kt
Last active April 17, 2018 13:29
AlertDialogs with Extn funcs blog_5
class SomeFragment : Fragment() {
private var notesDialog: AlertDialog? = null
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
showDialog()
}
// showing dialog
@Audhil
Audhil / appExtnFuncs.kt
Created April 17, 2018 10:51
log extn funcs
fun Any.showVLog(log: String) = Log.v(this::class.java.simpleName, log)
fun Any.showELog(log: String) = Log.e(this::class.java.simpleName, log)
fun Any.showDLog(log: String) = Log.d(this::class.java.simpleName, log)
fun Any.showILog(log: String) = Log.i(this::class.java.simpleName, log)
fun Any.showWLog(log: String) = Log.w(this::class.java.simpleName, log)
@Audhil
Audhil / notes_dialog.xml
Created April 17, 2018 16:15
AlertDialogs with Extn funcs blog_6
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/transparent">
<ImageView
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;
public class LinkedHashMapValueByIndexArray {
public static void main(String []args){
LinkedHashMap<String, Integer> map = new LinkedHashMap<String, Integer>();
map.put("Qatar", 98814);
onAttach
onCreate
onCreateDialog
onCreateView
onActivityCreated
onStart
onResume

1. Clone your fork:

git clone [email protected]:YOUR-USERNAME/YOUR-FORKED-REPO.git

2. Add remote from original repository in your forked repository:

cd into/cloned/fork-repo
git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git
git fetch upstream
@Audhil
Audhil / SomeActivity.kt
Last active September 6, 2018 07:16
multi-part request (uploading an Image) with HttpURLConnection - age old method.
// API call from Android side
Observable.create<String> { emitter ->
try {
emitter.onNext(makeAMultiPartRequest(imageBytes, token)!!)
emitter.onComplete()
} catch (e: Exception) {
e.printStackTrace()
emitter.tryOnError(e)
}
}.compose(AppRxSchedulers.applySchedulers())
@Audhil
Audhil / Apis.kt
Created September 6, 2018 07:21
multi-part request (uploading an Image) with Retrofit2
interface AppAPIs {
@Multipart
@POST(APIEndPoints.UPLOAD_PHOTO)
fun uploadTempProfilePic(
@Query(APIEndPoints.ID)
tempId: String,
@Part
image: MultipartBody.Part
): Flowable<PhotoUploadResponse>
}
@Audhil
Audhil / gist:6b572f55fff10c063558f2c0a03670f8
Created October 1, 2018 09:07
Making more Darker dialog background than default - works in DialogFragment too
val lp = dialog?.window?.attributes
lp?.dimAmount = .8f
dialog?.window?.attributes = lp
dialog?.window?.addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND)