diff --git a/android-L-preview/AndroidManifest.xml b/android-L-preview/AndroidManifest.xml
new file mode 100644
index 00000000..08eafe5f
--- /dev/null
+++ b/android-L-preview/AndroidManifest.xml
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/android-L-preview/proguard-project.txt b/android-L-preview/proguard-project.txt
new file mode 100644
index 00000000..f2fe1559
--- /dev/null
+++ b/android-L-preview/proguard-project.txt
@@ -0,0 +1,20 @@
+# To enable ProGuard in your project, edit project.properties
+# to define the proguard.config property as described in that file.
+#
+# Add project specific ProGuard rules here.
+# By default, the flags in this file are appended to flags specified
+# in ${sdk.dir}/tools/proguard/proguard-android.txt
+# You can edit the include path and order by changing the ProGuard
+# include property in project.properties.
+#
+# For more details, see
+# http://developer.android.com/guide/developing/tools/proguard.html
+
+# Add any project specific keep options here:
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+# public *;
+#}
diff --git a/android-L-preview/res/layout/activity_main.xml b/android-L-preview/res/layout/activity_main.xml
new file mode 100644
index 00000000..50fe8d03
--- /dev/null
+++ b/android-L-preview/res/layout/activity_main.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
diff --git a/android-L-preview/res/values/strings.xml b/android-L-preview/res/values/strings.xml
new file mode 100644
index 00000000..7d70ec05
--- /dev/null
+++ b/android-L-preview/res/values/strings.xml
@@ -0,0 +1,8 @@
+
+
+
+ L Preview
+ MainActivity
+ Hello world!
+
+
diff --git a/android-L-preview/res/values/styles.xml b/android-L-preview/res/values/styles.xml
new file mode 100644
index 00000000..1192db20
--- /dev/null
+++ b/android-L-preview/res/values/styles.xml
@@ -0,0 +1,4 @@
+
+
+
diff --git a/android-L-preview/src/com/hmkcode/android/L/MainActivity.java b/android-L-preview/src/com/hmkcode/android/L/MainActivity.java
new file mode 100644
index 00000000..95510ec1
--- /dev/null
+++ b/android-L-preview/src/com/hmkcode/android/L/MainActivity.java
@@ -0,0 +1,14 @@
+package com.hmkcode.android.L;
+
+import android.app.Activity;
+import android.os.Bundle;
+
+
+public class MainActivity extends Activity {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_main);
+ }
+}
diff --git a/android-canvas-donut-chart/AndroidManifest.xml b/android-canvas-donut-chart/AndroidManifest.xml
new file mode 100644
index 00000000..d363509e
--- /dev/null
+++ b/android-canvas-donut-chart/AndroidManifest.xml
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/android-canvas-donut-chart/res/layout/activity_main.xml b/android-canvas-donut-chart/res/layout/activity_main.xml
new file mode 100644
index 00000000..8a523745
--- /dev/null
+++ b/android-canvas-donut-chart/res/layout/activity_main.xml
@@ -0,0 +1,21 @@
+
+
+
+
+
diff --git a/android-canvas-donut-chart/res/values/attrs.xml b/android-canvas-donut-chart/res/values/attrs.xml
new file mode 100644
index 00000000..485e118d
--- /dev/null
+++ b/android-canvas-donut-chart/res/values/attrs.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/android-post-json/res/values/dimens.xml b/android-canvas-donut-chart/res/values/dimens.xml
similarity index 100%
rename from android-post-json/res/values/dimens.xml
rename to android-canvas-donut-chart/res/values/dimens.xml
diff --git a/android-canvas-donut-chart/res/values/strings.xml b/android-canvas-donut-chart/res/values/strings.xml
new file mode 100644
index 00000000..004653b7
--- /dev/null
+++ b/android-canvas-donut-chart/res/values/strings.xml
@@ -0,0 +1,8 @@
+
+
+
+ Donut Chart
+ Hello world!
+ Settings
+
+
diff --git a/android-canvas-donut-chart/res/values/styles.xml b/android-canvas-donut-chart/res/values/styles.xml
new file mode 100644
index 00000000..845fb572
--- /dev/null
+++ b/android-canvas-donut-chart/res/values/styles.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
diff --git a/android-canvas-donut-chart/src/com/hmkcode/views/DonutChart.java b/android-canvas-donut-chart/src/com/hmkcode/views/DonutChart.java
new file mode 100644
index 00000000..42e851d0
--- /dev/null
+++ b/android-canvas-donut-chart/src/com/hmkcode/views/DonutChart.java
@@ -0,0 +1,168 @@
+package com.hmkcode.views;
+
+
+import android.content.Context;
+import android.content.res.TypedArray;
+import android.graphics.BlurMaskFilter;
+import android.graphics.Canvas;
+
+import android.graphics.Paint;
+import android.graphics.Path;
+import android.graphics.RadialGradient;
+import android.graphics.RectF;
+import android.graphics.Shader.TileMode;
+import android.util.AttributeSet;
+import android.view.View;
+
+public class DonutChart extends View {
+
+
+ private float radius;
+
+ Paint paint;
+ Paint shadowPaint;
+
+ Path myPath;
+ Path shadowPath;
+
+ RectF outterCircle;
+ RectF innerCircle;
+ RectF shadowRectF;
+
+ public DonutChart(Context context, AttributeSet attrs) {
+ super(context, attrs);
+
+ TypedArray a = context.getTheme().obtainStyledAttributes(
+ attrs,
+ R.styleable.DonutChart,
+ 0, 0
+ );
+
+ try {
+ radius = a.getDimension(R.styleable.DonutChart_radius, 20.0f);
+ } finally {
+ a.recycle();
+ }
+
+ paint = new Paint();
+ paint.setDither(true);
+ paint.setStyle(Paint.Style.FILL);
+ paint.setStrokeJoin(Paint.Join.ROUND);
+ paint.setStrokeCap(Paint.Cap.ROUND);
+ paint.setAntiAlias(true);
+ paint.setStrokeWidth(radius / 14.0f);
+
+ shadowPaint = new Paint();
+ shadowPaint.setColor(0xf0000000);
+ shadowPaint.setStyle(Paint.Style.STROKE);
+ shadowPaint.setAntiAlias(true);
+ shadowPaint.setStrokeWidth(6.0f);
+ shadowPaint.setMaskFilter(new BlurMaskFilter(4, BlurMaskFilter.Blur.SOLID));
+
+
+ myPath = new Path();
+ shadowPath = new Path();
+
+
+ outterCircle = new RectF();
+ innerCircle = new RectF();
+ shadowRectF = new RectF();
+
+ float adjust = (.019f*radius);
+ shadowRectF.set(adjust, adjust, radius*2-adjust, radius*2-adjust);
+
+ adjust = .038f * radius;
+ outterCircle.set(adjust, adjust, radius*2-adjust, radius*2-adjust);
+
+ adjust = .276f * radius;
+ innerCircle.set(adjust, adjust, radius*2-adjust, radius*2-adjust);
+
+ }
+
+
+ @Override
+ protected void onDraw(Canvas canvas) {
+ super.onDraw(canvas);
+
+ // draw shadow
+ paint.setShader(null);
+ float adjust = (.0095f*radius);
+ paint.setShadowLayer(8, adjust, -adjust, 0xaa000000);
+ drawDonut(canvas,paint, 0,359.9f);
+
+
+ // green
+ setGradient(0xff84BC3D,0xff5B8829);
+ drawDonut(canvas,paint, 0,60);
+
+ //red
+ setGradient(0xffe04a2f,0xffB7161B);
+ drawDonut(canvas,paint, 60,60);
+
+ // blue
+ setGradient(0xff4AB6C1,0xff2182AD);
+ drawDonut(canvas,paint, 120,60);
+
+ // yellow
+ setGradient(0xffFFFF00,0xfffed325);
+ drawDonut(canvas,paint, 180,180);
+
+
+
+ }
+
+ public void drawDonut(Canvas canvas, Paint paint, float start,float sweep){
+
+ myPath.reset();
+ myPath.arcTo(outterCircle, start, sweep, false);
+ myPath.arcTo(innerCircle, start+sweep, -sweep, false);
+ myPath.close();
+ canvas.drawPath(myPath, paint);
+ }
+
+ public void setGradient(int sColor, int eColor){
+ paint.setShader(new RadialGradient(radius, radius, radius-5,
+ new int[]{sColor,eColor},
+ new float[]{.6f,.95f},TileMode.CLAMP) );
+ }
+
+ @Override
+ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+ super.onMeasure(widthMeasureSpec, heightMeasureSpec);
+
+ int desiredWidth = (int) radius*2;
+ int desiredHeight = (int) radius*2;
+
+ int widthMode = MeasureSpec.getMode(widthMeasureSpec);
+ int widthSize = MeasureSpec.getSize(widthMeasureSpec);
+ int heightMode = MeasureSpec.getMode(heightMeasureSpec);
+ int heightSize = MeasureSpec.getSize(heightMeasureSpec);
+
+ int width;
+ int height;
+
+ //70dp exact
+ if (widthMode == MeasureSpec.EXACTLY) {
+ width = widthSize;
+ }else if (widthMode == MeasureSpec.AT_MOST) {
+ //wrap content
+ width = Math.min(desiredWidth, widthSize);
+ } else {
+ width = desiredWidth;
+ }
+
+ //Measure Height
+ if (heightMode == MeasureSpec.EXACTLY) {
+ height = heightSize;
+ } else if (heightMode == MeasureSpec.AT_MOST) {
+ height = Math.min(desiredHeight, heightSize);
+ } else {
+ height = desiredHeight;
+ }
+
+ //MUST CALL THIS
+ setMeasuredDimension(width, height);
+ }
+
+
+}
diff --git a/android-canvas-donut-chart/src/com/hmkcode/views/MainActivity.java b/android-canvas-donut-chart/src/com/hmkcode/views/MainActivity.java
new file mode 100644
index 00000000..58b95bbd
--- /dev/null
+++ b/android-canvas-donut-chart/src/com/hmkcode/views/MainActivity.java
@@ -0,0 +1,14 @@
+package com.hmkcode.views;
+
+import android.app.Activity;
+import android.os.Bundle;
+
+
+public class MainActivity extends Activity {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_main);
+ }
+}
diff --git a/android-connectivity/app/build.gradle b/android-connectivity/app/build.gradle
new file mode 100644
index 00000000..0afafcf6
--- /dev/null
+++ b/android-connectivity/app/build.gradle
@@ -0,0 +1,40 @@
+apply plugin: 'com.android.application'
+
+apply plugin: 'kotlin-android'
+
+apply plugin: 'kotlin-android-extensions'
+
+android {
+ compileSdkVersion 28
+ buildToolsVersion "29.0.2"
+ defaultConfig {
+ applicationId "com.hmkcode.connectivity"
+ minSdkVersion 19
+ targetSdkVersion 28
+ versionCode 1
+ versionName "1.0"
+ testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
+ }
+ buildTypes {
+ release {
+ minifyEnabled false
+ proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
+ }
+ }
+}
+
+dependencies {
+ implementation fileTree(dir: 'libs', include: ['*.jar'])
+ implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
+ implementation 'androidx.appcompat:appcompat:1.1.0'
+ implementation 'androidx.core:core-ktx:1.1.0'
+ implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
+ // Coroutine
+ implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.2"
+ implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.2"
+ implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.2.0-alpha05"
+
+ testImplementation 'junit:junit:4.12'
+ androidTestImplementation 'androidx.test.ext:junit:1.1.1'
+ androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
+}
diff --git a/android-connectivity/app/src/main/AndroidManifest.xml b/android-connectivity/app/src/main/AndroidManifest.xml
new file mode 100644
index 00000000..16ef209d
--- /dev/null
+++ b/android-connectivity/app/src/main/AndroidManifest.xml
@@ -0,0 +1,24 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/android-connectivity/app/src/main/java/com/hmkcode/connectivity/MainActivity.kt b/android-connectivity/app/src/main/java/com/hmkcode/connectivity/MainActivity.kt
new file mode 100644
index 00000000..a58dcc66
--- /dev/null
+++ b/android-connectivity/app/src/main/java/com/hmkcode/connectivity/MainActivity.kt
@@ -0,0 +1,74 @@
+package com.hmkcode.connectivity
+
+import android.content.Context
+import android.net.ConnectivityManager
+import android.net.Network
+import android.net.NetworkCapabilities
+import android.net.NetworkRequest
+import android.os.Build
+import androidx.appcompat.app.AppCompatActivity
+import android.os.Bundle
+import android.util.Log
+import android.widget.TextView
+import androidx.lifecycle.lifecycleScope
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.launch
+import kotlinx.coroutines.withContext
+
+class MainActivity : AppCompatActivity() {
+
+ lateinit var tvConnectivity: TextView
+
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ setContentView(R.layout.activity_main)
+
+ tvConnectivity = findViewById(R.id.tvConnectivity)
+
+ // get ConnectivityManager
+ val cm:ConnectivityManager =
+ getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
+
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
+ val builder: NetworkRequest.Builder = NetworkRequest.Builder()
+ cm.registerNetworkCallback(
+
+ builder.build(),
+ object : ConnectivityManager.NetworkCallback() {
+
+ override fun onAvailable(network: Network) {
+ lifecycleScope.launch {
+ Log.i("MainActivity", "onAvailable!")
+
+ // check if NetworkCapabilities has TRANSPORT_WIFI
+ val isWifi:Boolean = cm.getNetworkCapabilities(network).hasTransport(
+ NetworkCapabilities.TRANSPORT_WIFI)
+
+ doSomething(true, isWifi)
+ }
+ }
+
+ override fun onLost(network: Network) {
+ lifecycleScope.launch {
+ Log.i("MainActivity", "onLost!")
+ doSomething(false)
+ }
+ }
+ }
+ )
+ }
+
+ }
+
+ private suspend fun doSomething(isConnected:Boolean, isWifi:Boolean= false){
+ withContext(Dispatchers.Main){
+ if(isConnected) {
+ tvConnectivity.text = "Connected "+(if(isWifi)"WIFI" else "MOBILE")
+ tvConnectivity.setBackgroundColor(-0x8333da)
+ }else {
+ tvConnectivity.text = "Not Connected"
+ tvConnectivity.setBackgroundColor(-0x10000)
+ }
+ }
+ }
+}
diff --git a/android-connectivity/app/src/main/res/drawable/ic_launcher_background.xml b/android-connectivity/app/src/main/res/drawable/ic_launcher_background.xml
new file mode 100644
index 00000000..0d025f9b
--- /dev/null
+++ b/android-connectivity/app/src/main/res/drawable/ic_launcher_background.xml
@@ -0,0 +1,170 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/android-connectivity/app/src/main/res/layout/activity_main.xml b/android-connectivity/app/src/main/res/layout/activity_main.xml
new file mode 100644
index 00000000..5acf0117
--- /dev/null
+++ b/android-connectivity/app/src/main/res/layout/activity_main.xml
@@ -0,0 +1,23 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/android-connectivity/app/src/main/res/values/colors.xml b/android-connectivity/app/src/main/res/values/colors.xml
new file mode 100644
index 00000000..69b22338
--- /dev/null
+++ b/android-connectivity/app/src/main/res/values/colors.xml
@@ -0,0 +1,6 @@
+
+
+ #008577
+ #00574B
+ #D81B60
+
diff --git a/android-connectivity/app/src/main/res/values/strings.xml b/android-connectivity/app/src/main/res/values/strings.xml
new file mode 100644
index 00000000..5bc6865a
--- /dev/null
+++ b/android-connectivity/app/src/main/res/values/strings.xml
@@ -0,0 +1,3 @@
+
+ connectivity
+
diff --git a/android-connectivity/app/src/main/res/values/styles.xml b/android-connectivity/app/src/main/res/values/styles.xml
new file mode 100644
index 00000000..5885930d
--- /dev/null
+++ b/android-connectivity/app/src/main/res/values/styles.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
diff --git a/android-connectivity/build.gradle b/android-connectivity/build.gradle
new file mode 100644
index 00000000..e3245e7f
--- /dev/null
+++ b/android-connectivity/build.gradle
@@ -0,0 +1,28 @@
+// Top-level build file where you can add configuration options common to all sub-projects/modules.
+
+buildscript {
+ ext.kotlin_version = '1.3.50'
+ repositories {
+ google()
+ jcenter()
+
+ }
+ dependencies {
+ classpath 'com.android.tools.build:gradle:3.5.1'
+ classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
+ // NOTE: Do not place your application dependencies here; they belong
+ // in the individual module build.gradle files
+ }
+}
+
+allprojects {
+ repositories {
+ google()
+ jcenter()
+
+ }
+}
+
+task clean(type: Delete) {
+ delete rootProject.buildDir
+}
diff --git a/android-custom-view/AndroidManifest.xml b/android-custom-view/AndroidManifest.xml
new file mode 100644
index 00000000..d363509e
--- /dev/null
+++ b/android-custom-view/AndroidManifest.xml
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/android-custom-view/res/layout/activity_main.xml b/android-custom-view/res/layout/activity_main.xml
new file mode 100644
index 00000000..33440667
--- /dev/null
+++ b/android-custom-view/res/layout/activity_main.xml
@@ -0,0 +1,38 @@
+
+
+
+
+
+
+
+
diff --git a/android-custom-view/res/values/attrs.xml b/android-custom-view/res/values/attrs.xml
new file mode 100644
index 00000000..a97caa47
--- /dev/null
+++ b/android-custom-view/res/values/attrs.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/android-custom-view/res/values/dimens.xml b/android-custom-view/res/values/dimens.xml
new file mode 100644
index 00000000..55c1e590
--- /dev/null
+++ b/android-custom-view/res/values/dimens.xml
@@ -0,0 +1,7 @@
+
+
+
+ 16dp
+ 16dp
+
+
diff --git a/android-custom-view/res/values/strings.xml b/android-custom-view/res/values/strings.xml
new file mode 100644
index 00000000..eed0eaf9
--- /dev/null
+++ b/android-custom-view/res/values/strings.xml
@@ -0,0 +1,8 @@
+
+
+
+ Simple Custom View
+ Hello world!
+ Settings
+
+
diff --git a/android-custom-view/res/values/styles.xml b/android-custom-view/res/values/styles.xml
new file mode 100644
index 00000000..845fb572
--- /dev/null
+++ b/android-custom-view/res/values/styles.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
diff --git a/android-custom-view/src/com/hmkcode/views/MainActivity.java b/android-custom-view/src/com/hmkcode/views/MainActivity.java
new file mode 100644
index 00000000..f0b152f6
--- /dev/null
+++ b/android-custom-view/src/com/hmkcode/views/MainActivity.java
@@ -0,0 +1,48 @@
+package com.hmkcode.views;
+
+import android.app.Activity;
+import android.os.Bundle;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.widget.TextView;
+
+
+public class MainActivity extends Activity implements OnClickListener {
+
+ SimpleView svCircle;
+ SimpleView svSquare;
+ TextView tv;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_main);
+
+ svCircle = (SimpleView) findViewById(R.id.simpleViewCircle);
+ svSquare = (SimpleView) findViewById(R.id.simpleViewSquare);
+ tv = (TextView) findViewById(R.id.tv);
+
+ svCircle.setOnClickListener(this);
+ svSquare.setOnClickListener(this);
+
+ }
+
+
+ @Override
+ public void onClick(View view) {
+
+ switch(view.getId()){
+ case R.id.simpleViewCircle:
+ tv.setText("Circle");
+ break;
+ case R.id.simpleViewSquare:
+ tv.setText("Square");
+ break;
+
+ }
+
+ }
+
+
+
+}
diff --git a/android-custom-view/src/com/hmkcode/views/SimpleView.java b/android-custom-view/src/com/hmkcode/views/SimpleView.java
new file mode 100644
index 00000000..121f690d
--- /dev/null
+++ b/android-custom-view/src/com/hmkcode/views/SimpleView.java
@@ -0,0 +1,57 @@
+package com.hmkcode.views;
+
+import android.content.Context;
+import android.content.res.TypedArray;
+import android.graphics.Canvas;
+import android.graphics.CornerPathEffect;
+import android.graphics.Paint;
+import android.util.AttributeSet;
+import android.view.View;
+
+public class SimpleView extends View {
+
+ float dim;
+ int shape;
+ Paint paint;
+
+ public static final int CIRCLE = 0;
+ public static final int SQUARE = 1;
+ public SimpleView(Context context, AttributeSet attrs) {
+ super(context, attrs);
+
+ TypedArray a = context.getTheme().obtainStyledAttributes(
+ attrs,
+ R.styleable.SimpleView,
+ 0, 0
+ );
+
+ try {
+ dim = a.getDimension(R.styleable.SimpleView_dim, 20f);
+ shape = a.getInteger(R.styleable.SimpleView_shape, 0);
+ } finally {
+ a.recycle();
+ }
+
+ paint = new Paint();
+ paint.setColor(0xfffed325); // yellow
+ }
+
+ @Override
+ protected void onDraw(Canvas canvas) {
+ super.onDraw(canvas);
+
+ // draw circle
+ switch(shape){
+ case CIRCLE:
+ canvas.drawCircle(dim, dim, dim, paint);
+ break;
+ case SQUARE:
+ canvas.drawRect(0, 0, dim, dim, paint);
+ break;
+
+ }
+
+ }
+
+
+}
diff --git a/android-draw-happy-face/AndroidManifest.xml b/android-draw-happy-face/AndroidManifest.xml
new file mode 100644
index 00000000..e8106618
--- /dev/null
+++ b/android-draw-happy-face/AndroidManifest.xml
@@ -0,0 +1,28 @@
+
+
+
+
+
+ e
+
+
+
+
+
+
+
+
+
+
diff --git a/android-post-json/res/drawable-hdpi/ic_launcher.png b/android-draw-happy-face/res/drawable-hdpi/ic_launcher.png
similarity index 100%
rename from android-post-json/res/drawable-hdpi/ic_launcher.png
rename to android-draw-happy-face/res/drawable-hdpi/ic_launcher.png
diff --git a/android-draw-happy-face/res/drawable-hdpi/woodgraybg.jpg b/android-draw-happy-face/res/drawable-hdpi/woodgraybg.jpg
new file mode 100644
index 00000000..54ebe7df
Binary files /dev/null and b/android-draw-happy-face/res/drawable-hdpi/woodgraybg.jpg differ
diff --git a/android-draw-happy-face/res/layout/activity_main.xml b/android-draw-happy-face/res/layout/activity_main.xml
new file mode 100644
index 00000000..f3ae3687
--- /dev/null
+++ b/android-draw-happy-face/res/layout/activity_main.xml
@@ -0,0 +1,26 @@
+
+
+
+
+
diff --git a/android-draw-happy-face/res/values/attrs.xml b/android-draw-happy-face/res/values/attrs.xml
new file mode 100644
index 00000000..d2383bfe
--- /dev/null
+++ b/android-draw-happy-face/res/values/attrs.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/android-draw-happy-face/res/values/dimens.xml b/android-draw-happy-face/res/values/dimens.xml
new file mode 100644
index 00000000..55c1e590
--- /dev/null
+++ b/android-draw-happy-face/res/values/dimens.xml
@@ -0,0 +1,7 @@
+
+
+
+ 16dp
+ 16dp
+
+
diff --git a/android-post-json/res/values/strings.xml b/android-draw-happy-face/res/values/strings.xml
similarity index 78%
rename from android-post-json/res/values/strings.xml
rename to android-draw-happy-face/res/values/strings.xml
index 2a387699..81bedf03 100644
--- a/android-post-json/res/values/strings.xml
+++ b/android-draw-happy-face/res/values/strings.xml
@@ -1,8 +1,8 @@
- POST JSON
- Settings
+ DrawFace
Hello world!
+ Settings
diff --git a/android-draw-happy-face/res/values/styles.xml b/android-draw-happy-face/res/values/styles.xml
new file mode 100644
index 00000000..845fb572
--- /dev/null
+++ b/android-draw-happy-face/res/values/styles.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
diff --git a/android-draw-happy-face/src/com/hmkcode/drawing/FaceView.java b/android-draw-happy-face/src/com/hmkcode/drawing/FaceView.java
new file mode 100644
index 00000000..e6a71654
--- /dev/null
+++ b/android-draw-happy-face/src/com/hmkcode/drawing/FaceView.java
@@ -0,0 +1,97 @@
+package com.hmkcode.drawing;
+
+
+import com.hmkcode.drawing.shapes.Face;
+
+import android.content.Context;
+import android.content.res.TypedArray;
+import android.graphics.Canvas;
+import android.util.AttributeSet;
+import android.util.Log;
+import android.view.View;
+
+public class FaceView extends View {
+ private float radius;
+ Face face;
+ public FaceView(Context context, AttributeSet attrs) {
+ super(context, attrs);
+
+ // get radius value
+ TypedArray a = context.getTheme().obtainStyledAttributes(
+ attrs,
+ R.styleable.FaceView,
+ 0, 0
+ );
+
+ try {
+ radius = a.getDimension(R.styleable.FaceView_radius, 20.0f);
+ } finally {
+ a.recycle();
+ }
+
+ // initiate Face class
+ face = new Face(radius);
+ }
+
+
+ @Override
+ protected void onDraw(Canvas canvas) {
+ super.onDraw(canvas);
+ face.draw(canvas);
+
+ }
+
+ @Override
+ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+ super.onMeasure(widthMeasureSpec, heightMeasureSpec);
+
+ int desiredWidth = (int) radius*2+(int) Math.ceil((radius/1.70));
+ int desiredHeight = (int) radius*2+(int)Math.ceil((radius/1.70));
+
+ int widthMode = MeasureSpec.getMode(widthMeasureSpec);
+ int widthSize = MeasureSpec.getSize(widthMeasureSpec);
+ int heightMode = MeasureSpec.getMode(heightMeasureSpec);
+ int heightSize = MeasureSpec.getSize(heightMeasureSpec);
+
+ int width;
+ int height;
+
+ //Measure Width
+ if (widthMode == MeasureSpec.EXACTLY) {
+ //Must be this size
+ width = widthSize;
+ } else if (widthMode == MeasureSpec.AT_MOST) {
+ //Can't be bigger than...
+ width = Math.min(desiredWidth, widthSize);
+ Log.d("Width AT_MOST", "width: "+width);
+ } else {
+ //Be whatever you want
+ width = desiredWidth;
+ Log.d("Width ELSE", "width: "+width);
+
+ }
+
+ //Measure Height
+ if (heightMode == MeasureSpec.EXACTLY) {
+ //Must be this size
+ height = heightSize;
+ } else if (heightMode == MeasureSpec.AT_MOST) {
+ //Can't be bigger than...
+ height = Math.min(desiredHeight, heightSize);
+ } else {
+ //Be whatever you want
+ height = desiredHeight;
+ }
+
+ //MUST CALL THIS
+ setMeasuredDimension(width, height);
+ }
+ public float getRadius() {
+ return radius;
+ }
+
+ public void setRadius(float radius) {
+ this.radius = radius;
+ }
+
+}
diff --git a/android-draw-happy-face/src/com/hmkcode/drawing/MainActivity.java b/android-draw-happy-face/src/com/hmkcode/drawing/MainActivity.java
new file mode 100644
index 00000000..818f6bd2
--- /dev/null
+++ b/android-draw-happy-face/src/com/hmkcode/drawing/MainActivity.java
@@ -0,0 +1,13 @@
+package com.hmkcode.drawing;
+
+
+import android.app.Activity;
+
+public class MainActivity extends Activity {
+
+ protected void onCreate(android.os.Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_main);
+ }
+
+}
diff --git a/android-draw-happy-face/src/com/hmkcode/drawing/shapes/Face.java b/android-draw-happy-face/src/com/hmkcode/drawing/shapes/Face.java
new file mode 100644
index 00000000..06ae5dd1
--- /dev/null
+++ b/android-draw-happy-face/src/com/hmkcode/drawing/shapes/Face.java
@@ -0,0 +1,96 @@
+package com.hmkcode.drawing.shapes;
+
+import android.graphics.Canvas;
+import android.graphics.CornerPathEffect;
+import android.graphics.Paint;
+import android.graphics.Path;
+import android.graphics.RectF;
+
+public class Face {
+
+ Paint facePaint;
+ Paint mePaint;
+
+
+ float radius;
+ float adjust;
+
+ float mouthLeftX, mouthRightX, mouthTopY, mouthBottomY;
+ RectF mouthRectF;
+ Path mouthPath;
+
+ RectF eyeLeftRectF, eyeRightRectF;
+ float eyeLeftX, eyeRightx, eyeTopY, eyeBottomY;
+
+
+ public Face(float radius){
+ this.radius= radius;
+
+ facePaint = new Paint();
+ facePaint.setColor(0xfffed325); // yellow
+ facePaint.setDither(true);
+ facePaint.setStrokeJoin(Paint.Join.ROUND);
+ facePaint.setStrokeCap(Paint.Cap.ROUND);
+ facePaint.setPathEffect(new CornerPathEffect(10) );
+ facePaint.setAntiAlias(true);
+ facePaint.setShadowLayer(4, 2, 2, 0x80000000);
+
+ mePaint = new Paint();
+ mePaint.setColor(0xff2a2a2a);
+ mePaint.setDither(true);
+ mePaint.setStyle(Paint.Style.STROKE);
+ mePaint.setStrokeJoin(Paint.Join.ROUND);
+ mePaint.setStrokeCap(Paint.Cap.ROUND);
+ mePaint.setPathEffect(new CornerPathEffect(10) );
+ mePaint.setAntiAlias(true);
+ mePaint.setStrokeWidth(radius / 14.0f);
+
+
+
+ adjust = radius / 3.2f;
+
+
+ // Left Eye
+ eyeLeftX = radius-(radius*0.43f);
+ eyeRightx = eyeLeftX+ (radius*0.3f);
+ eyeTopY = radius-(radius*0.5f);
+ eyeBottomY = eyeTopY + (radius*0.4f);
+
+ eyeLeftRectF = new RectF(eyeLeftX+adjust,eyeTopY+adjust,eyeRightx+adjust,eyeBottomY+adjust);
+
+ // Right Eye
+ eyeLeftX = eyeRightx + (radius*0.3f);
+ eyeRightx = eyeLeftX + (radius*0.3f);
+
+ eyeRightRectF = new RectF(eyeLeftX+adjust,eyeTopY+adjust,eyeRightx+adjust,eyeBottomY+adjust);
+
+
+ // Smiley Mouth
+ mouthLeftX = radius-(radius/2.0f);
+ mouthRightX = mouthLeftX+ radius;
+ mouthTopY = radius - (radius*0.2f);
+ mouthBottomY = mouthTopY + (radius*0.5f);
+
+ mouthRectF = new RectF(mouthLeftX+adjust,mouthTopY+adjust,mouthRightX+adjust,mouthBottomY+adjust);
+ mouthPath = new Path();
+
+ mouthPath.arcTo(mouthRectF, 30, 120, true);
+ }
+
+ public void draw(Canvas canvas) {
+
+ // 1. draw face
+ canvas.drawCircle(radius+adjust, radius+adjust, radius, facePaint);
+
+ // 2. draw mouth
+ mePaint.setStyle(Paint.Style.STROKE);
+
+ canvas.drawPath(mouthPath, mePaint);
+
+ // 3. draw eyes
+ mePaint.setStyle(Paint.Style.FILL);
+ canvas.drawArc(eyeLeftRectF, 0, 360, true, mePaint);
+ canvas.drawArc(eyeRightRectF, 0, 360, true, mePaint);
+
+ }
+}
diff --git a/android-gcm-client/AndroidManifest.xml b/android-gcm-client/AndroidManifest.xml
new file mode 100644
index 00000000..2cd7401f
--- /dev/null
+++ b/android-gcm-client/AndroidManifest.xml
@@ -0,0 +1,50 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/android-gcm-client/res/drawable-hdpi/ic_launcher.png b/android-gcm-client/res/drawable-hdpi/ic_launcher.png
new file mode 100644
index 00000000..288b6655
Binary files /dev/null and b/android-gcm-client/res/drawable-hdpi/ic_launcher.png differ
diff --git a/android-gcm-client/res/layout/activity_main.xml b/android-gcm-client/res/layout/activity_main.xml
new file mode 100644
index 00000000..07bda309
--- /dev/null
+++ b/android-gcm-client/res/layout/activity_main.xml
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
diff --git a/android-post-json/res/menu/main.xml b/android-gcm-client/res/menu/main.xml
similarity index 100%
rename from android-post-json/res/menu/main.xml
rename to android-gcm-client/res/menu/main.xml
diff --git a/android-gcm-client/res/values/dimens.xml b/android-gcm-client/res/values/dimens.xml
new file mode 100644
index 00000000..55c1e590
--- /dev/null
+++ b/android-gcm-client/res/values/dimens.xml
@@ -0,0 +1,7 @@
+
+
+
+ 16dp
+ 16dp
+
+
diff --git a/android-gcm-client/res/values/strings.xml b/android-gcm-client/res/values/strings.xml
new file mode 100644
index 00000000..8d9b6bd8
--- /dev/null
+++ b/android-gcm-client/res/values/strings.xml
@@ -0,0 +1,8 @@
+
+
+
+ Android GCM
+ Settings
+ Hello world!
+
+
diff --git a/android-post-json/res/values/styles.xml b/android-gcm-client/res/values/styles.xml
similarity index 100%
rename from android-post-json/res/values/styles.xml
rename to android-gcm-client/res/values/styles.xml
diff --git a/android-gcm-client/src/com/hmkcode/android/gcm/GcmBroadcastReceiver.java b/android-gcm-client/src/com/hmkcode/android/gcm/GcmBroadcastReceiver.java
new file mode 100644
index 00000000..822e208b
--- /dev/null
+++ b/android-gcm-client/src/com/hmkcode/android/gcm/GcmBroadcastReceiver.java
@@ -0,0 +1,23 @@
+package com.hmkcode.android.gcm;
+
+import android.app.Activity;
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.Intent;
+import android.support.v4.content.WakefulBroadcastReceiver;
+
+public class GcmBroadcastReceiver extends WakefulBroadcastReceiver {
+
+
+ @Override
+ public void onReceive(Context context, Intent intent) {
+
+ // Explicitly specify that GcmMessageHandler will handle the intent.
+ ComponentName comp = new ComponentName(context.getPackageName(),
+ GcmMessageHandler.class.getName());
+
+ // Start the service, keeping the device awake while it is launching.
+ startWakefulService(context, (intent.setComponent(comp)));
+ setResultCode(Activity.RESULT_OK);
+ }
+}
diff --git a/android-gcm-client/src/com/hmkcode/android/gcm/GcmMessageHandler.java b/android-gcm-client/src/com/hmkcode/android/gcm/GcmMessageHandler.java
new file mode 100644
index 00000000..14714a83
--- /dev/null
+++ b/android-gcm-client/src/com/hmkcode/android/gcm/GcmMessageHandler.java
@@ -0,0 +1,56 @@
+package com.hmkcode.android.gcm;
+
+import com.google.android.gms.gcm.GoogleCloudMessaging;
+
+import android.app.IntentService;
+import android.content.Intent;
+import android.os.Bundle;
+import android.os.Handler;
+import android.util.Log;
+import android.widget.Toast;
+
+public class GcmMessageHandler extends IntentService {
+
+ String mes;
+ private Handler handler;
+ public GcmMessageHandler() {
+ super("GcmMessageHandler");
+ }
+
+ @Override
+ public void onCreate() {
+ // TODO Auto-generated method stub
+ super.onCreate();
+ handler = new Handler();
+ }
+ @Override
+ protected void onHandleIntent(Intent intent) {
+ Bundle extras = intent.getExtras();
+
+ GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this);
+ // The getMessageType() intent parameter must be the intent you received
+ // in your BroadcastReceiver.
+ String messageType = gcm.getMessageType(intent);
+
+ mes = extras.getString("title");
+ showToast();
+ Log.i("GCM", "Received : (" +messageType+") "+extras.getString("title"));
+
+
+
+ GcmBroadcastReceiver.completeWakefulIntent(intent);
+
+ }
+
+ public void showToast(){
+ handler.post(new Runnable() {
+ public void run() {
+ Toast.makeText(getApplicationContext(),mes , Toast.LENGTH_LONG).show();
+ }
+ });
+
+ }
+
+
+
+}
diff --git a/android-gcm-client/src/com/hmkcode/android/gcm/MainActivity.java b/android-gcm-client/src/com/hmkcode/android/gcm/MainActivity.java
new file mode 100644
index 00000000..627d7691
--- /dev/null
+++ b/android-gcm-client/src/com/hmkcode/android/gcm/MainActivity.java
@@ -0,0 +1,67 @@
+package com.hmkcode.android.gcm;
+
+import java.io.IOException;
+
+import com.google.android.gms.gcm.GoogleCloudMessaging;
+
+import android.os.AsyncTask;
+import android.os.Bundle;
+import android.app.Activity;
+import android.util.Log;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.widget.Button;
+import android.widget.EditText;
+
+public class MainActivity extends Activity implements OnClickListener {
+
+ Button btnRegId;
+ EditText etRegId;
+ GoogleCloudMessaging gcm;
+ String regid;
+ String PROJECT_NUMBER = "1024888653441";
+
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_main);
+
+ btnRegId = (Button) findViewById(R.id.btnGetRegId);
+ etRegId = (EditText) findViewById(R.id.etRegId);
+
+ btnRegId.setOnClickListener(this);
+ }
+ public void getRegId(){
+ new AsyncTask() {
+ @Override
+ protected String doInBackground(Void... params) {
+ String msg = "";
+ try {
+ if (gcm == null) {
+ gcm = GoogleCloudMessaging.getInstance(getApplicationContext());
+ }
+ regid = gcm.register(PROJECT_NUMBER);
+ msg = "Device registered, registration ID=" + regid;
+ Log.i("GCM", msg);
+
+
+ } catch (IOException ex) {
+ msg = "Error :" + ex.getMessage();
+
+ }
+ return msg;
+ }
+
+ @Override
+ protected void onPostExecute(String msg) {
+ etRegId.setText(msg + "\n");
+ }
+ }.execute(null, null, null);
+ }
+ @Override
+ public void onClick(View v) {
+ getRegId();
+ }
+
+}
diff --git a/android-get-current-location/AndroidManifest.xml b/android-get-current-location/AndroidManifest.xml
new file mode 100644
index 00000000..0f5312b1
--- /dev/null
+++ b/android-get-current-location/AndroidManifest.xml
@@ -0,0 +1,36 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/android-get-current-location/res/layout/activity_main.xml b/android-get-current-location/res/layout/activity_main.xml
new file mode 100644
index 00000000..c7afbc81
--- /dev/null
+++ b/android-get-current-location/res/layout/activity_main.xml
@@ -0,0 +1,25 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/android-get-current-location/src/com/hmkcode/android/location/MainActivity.java b/android-get-current-location/src/com/hmkcode/android/location/MainActivity.java
new file mode 100644
index 00000000..e61eb8f5
--- /dev/null
+++ b/android-get-current-location/src/com/hmkcode/android/location/MainActivity.java
@@ -0,0 +1,117 @@
+package com.hmkcode.android.location;
+
+import com.google.android.gms.common.ConnectionResult;
+import com.google.android.gms.common.GooglePlayServicesClient;
+import com.google.android.gms.location.LocationClient;
+import com.google.android.gms.location.LocationListener;
+import com.google.android.gms.location.LocationRequest;
+
+import android.app.Activity;
+import android.content.Intent;
+
+import android.location.Location;
+import android.os.Bundle;
+import android.provider.Settings;
+import android.widget.TextView;
+import android.widget.Toast;
+
+public class MainActivity extends Activity implements
+ GooglePlayServicesClient.ConnectionCallbacks,
+ GooglePlayServicesClient.OnConnectionFailedListener,
+ LocationListener {
+
+ // locations objects
+ LocationClient mLocationClient;
+ Location mCurrentLocation;
+ LocationRequest mLocationRequest;
+
+ TextView txtLong,txtLat;
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ // 1. setContnetView
+ setContentView(R.layout.activity_main);
+
+ // 2. get reference to TextView
+ txtLong = (TextView) findViewById(R.id.txtLong);
+ txtLat = (TextView) findViewById(R.id.txtLat);
+
+ // 3. create LocationClient
+ mLocationClient = new LocationClient(this, this, this);
+
+ // 4. create & set LocationRequest for Location update
+ mLocationRequest = LocationRequest.create();
+ mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
+ // Set the update interval to 5 seconds
+ mLocationRequest.setInterval(1000 * 5);
+ // Set the fastest update interval to 1 second
+ mLocationRequest.setFastestInterval(1000 * 1);
+
+
+ }
+ @Override
+ protected void onStart() {
+ super.onStart();
+ // 1. connect the client.
+ mLocationClient.connect();
+ }
+ @Override
+ protected void onStop() {
+ super.onStop();
+ // 1. disconnecting the client invalidates it.
+ mLocationClient.disconnect();
+ }
+
+
+ // GooglePlayServicesClient.OnConnectionFailedListener
+ @Override
+ public void onConnectionFailed(ConnectionResult connectionResult) {
+ Toast.makeText(this, "Connection Failed", Toast.LENGTH_SHORT).show();
+ }
+
+ // GooglePlayServicesClient.ConnectionCallbacks
+ @Override
+ public void onConnected(Bundle arg0) {
+
+ if(mLocationClient != null)
+ mLocationClient.requestLocationUpdates(mLocationRequest, this);
+
+ Toast.makeText(this, "Connected", Toast.LENGTH_SHORT).show();
+
+ if(mLocationClient != null){
+ // get location
+ mCurrentLocation = mLocationClient.getLastLocation();
+ try{
+
+ // set TextView(s)
+ txtLat.setText(mCurrentLocation.getLatitude()+"");
+ txtLong.setText(mCurrentLocation.getLongitude()+"");
+
+ }catch(NullPointerException npe){
+
+ Toast.makeText(this, "Failed to Connect", Toast.LENGTH_SHORT).show();
+
+ // switch on location service intent
+ Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
+ startActivity(intent);
+ }
+ }
+
+ }
+ @Override
+ public void onDisconnected() {
+ Toast.makeText(this, "Disconnected.", Toast.LENGTH_SHORT).show();
+
+ }
+
+ // LocationListener
+ @Override
+ public void onLocationChanged(Location location) {
+ Toast.makeText(this, "Location changed.", Toast.LENGTH_SHORT).show();
+ mCurrentLocation = mLocationClient.getLastLocation();
+ txtLat.setText(mCurrentLocation.getLatitude()+"");
+
+ txtLong.setText(mCurrentLocation.getLongitude()+"");
+ }
+
+}
diff --git a/android-get-last-location-fused-api/AndroidManifest.xml b/android-get-last-location-fused-api/AndroidManifest.xml
new file mode 100644
index 00000000..4ba23ec5
--- /dev/null
+++ b/android-get-last-location-fused-api/AndroidManifest.xml
@@ -0,0 +1,33 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/android-get-last-location-fused-api/res/layout/activity_main.xml b/android-get-last-location-fused-api/res/layout/activity_main.xml
new file mode 100644
index 00000000..890d467b
--- /dev/null
+++ b/android-get-last-location-fused-api/res/layout/activity_main.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
diff --git a/android-get-last-location-fused-api/src/com/hmkcode/locations/MainActivity.java b/android-get-last-location-fused-api/src/com/hmkcode/locations/MainActivity.java
new file mode 100644
index 00000000..7648d677
--- /dev/null
+++ b/android-get-last-location-fused-api/src/com/hmkcode/locations/MainActivity.java
@@ -0,0 +1,73 @@
+package com.hmkcode.locations;
+
+import com.google.android.gms.common.ConnectionResult;
+import com.google.android.gms.common.api.GoogleApiClient;
+import com.google.android.gms.common.api.GoogleApiClient.ConnectionCallbacks;
+import com.google.android.gms.common.api.GoogleApiClient.OnConnectionFailedListener;
+import com.google.android.gms.location.LocationServices;
+
+import android.app.Activity;
+import android.location.Location;
+import android.os.Bundle;
+import android.widget.TextView;
+import android.widget.Toast;
+
+
+public class MainActivity extends Activity implements
+ ConnectionCallbacks, OnConnectionFailedListener {
+
+ GoogleApiClient mGoogleApiClient;
+ Location mLastLocation;
+ TextView tvLatlong;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_main);
+
+ tvLatlong = (TextView) findViewById(R.id.tvLatlong);
+
+ buildGoogleApiClient();
+
+ if(mGoogleApiClient!= null){
+ mGoogleApiClient.connect();
+ }
+ else
+ Toast.makeText(this, "Not connected...", Toast.LENGTH_SHORT).show();
+
+
+ }
+
+ @Override
+ public void onConnectionFailed(ConnectionResult arg0) {
+ Toast.makeText(this, "Failed to connect...", Toast.LENGTH_SHORT).show();
+
+ }
+
+ @Override
+ public void onConnected(Bundle arg0) {
+
+ mLastLocation = LocationServices.FusedLocationApi.getLastLocation(
+ mGoogleApiClient);
+
+ if (mLastLocation != null) {
+ tvLatlong.setText("Latitude: "+ String.valueOf(mLastLocation.getLatitude())+" - Longitude: "+
+ String.valueOf(mLastLocation.getLongitude()));
+ }
+
+ }
+
+ @Override
+ public void onConnectionSuspended(int arg0) {
+ Toast.makeText(this, "Connection suspended...", Toast.LENGTH_SHORT).show();
+
+ }
+
+ protected synchronized void buildGoogleApiClient() {
+ mGoogleApiClient = new GoogleApiClient.Builder(this)
+ .addConnectionCallbacks(this)
+ .addOnConnectionFailedListener(this)
+ .addApi(LocationServices.API)
+ .build();
+ }
+}
diff --git a/android-http/build.gradle b/android-http/build.gradle
new file mode 100644
index 00000000..e3245e7f
--- /dev/null
+++ b/android-http/build.gradle
@@ -0,0 +1,28 @@
+// Top-level build file where you can add configuration options common to all sub-projects/modules.
+
+buildscript {
+ ext.kotlin_version = '1.3.50'
+ repositories {
+ google()
+ jcenter()
+
+ }
+ dependencies {
+ classpath 'com.android.tools.build:gradle:3.5.1'
+ classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
+ // NOTE: Do not place your application dependencies here; they belong
+ // in the individual module build.gradle files
+ }
+}
+
+allprojects {
+ repositories {
+ google()
+ jcenter()
+
+ }
+}
+
+task clean(type: Delete) {
+ delete rootProject.buildDir
+}
diff --git a/android-http/http-asynctask/build.gradle b/android-http/http-asynctask/build.gradle
new file mode 100644
index 00000000..92493a00
--- /dev/null
+++ b/android-http/http-asynctask/build.gradle
@@ -0,0 +1,35 @@
+apply plugin: 'com.android.application'
+
+apply plugin: 'kotlin-android'
+
+apply plugin: 'kotlin-android-extensions'
+
+android {
+ compileSdkVersion 29
+ buildToolsVersion "29.0.2"
+ defaultConfig {
+ applicationId "com.hmkcode.http"
+ minSdkVersion 19
+ targetSdkVersion 29
+ versionCode 1
+ versionName "1.0"
+ testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
+ }
+ buildTypes {
+ release {
+ minifyEnabled false
+ proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
+ }
+ }
+}
+
+dependencies {
+ implementation fileTree(dir: 'libs', include: ['*.jar'])
+ implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
+ implementation 'androidx.appcompat:appcompat:1.0.2'
+ implementation 'androidx.core:core-ktx:1.0.2'
+ implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
+ testImplementation 'junit:junit:4.12'
+ androidTestImplementation 'androidx.test:runner:1.1.1'
+ androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
+}
diff --git a/android-http/http-asynctask/src/main/AndroidManifest.xml b/android-http/http-asynctask/src/main/AndroidManifest.xml
new file mode 100644
index 00000000..964aa8b7
--- /dev/null
+++ b/android-http/http-asynctask/src/main/AndroidManifest.xml
@@ -0,0 +1,25 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/android-http/http-asynctask/src/main/java/com/hmkcode/http/MainActivity.kt b/android-http/http-asynctask/src/main/java/com/hmkcode/http/MainActivity.kt
new file mode 100644
index 00000000..8ad5ca04
--- /dev/null
+++ b/android-http/http-asynctask/src/main/java/com/hmkcode/http/MainActivity.kt
@@ -0,0 +1,103 @@
+package com.hmkcode.http
+
+import android.content.Context
+import android.net.ConnectivityManager
+import android.net.Network
+import android.net.NetworkInfo
+import android.os.AsyncTask
+import android.os.Build
+import androidx.appcompat.app.AppCompatActivity
+import android.os.Bundle
+import android.widget.TextView
+import kotlinx.android.synthetic.main.activity_main.*
+import java.io.BufferedReader
+import java.io.InputStream
+import java.io.InputStreamReader
+import java.net.HttpURLConnection
+import java.net.URL
+
+class MainActivity : AppCompatActivity() {
+
+ lateinit var tvIsConnected: TextView;
+ lateinit var tvResult: TextView;
+
+
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ setContentView(R.layout.activity_main)
+ tvIsConnected = findViewById(R.id.tvIsConnected)
+ tvResult = findViewById(R.id.tvResult)
+
+ if(checkNetworkConnection())
+ HTTPAsyncTask().execute("http://hmkcode-api.appspot.com/rest/api/hello/Android")
+ }
+
+
+ private fun checkNetworkConnection(): Boolean {
+ val cm:ConnectivityManager =
+ getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
+
+ val networkInfo:NetworkInfo? = cm.activeNetworkInfo
+ val isConnected: Boolean = if(networkInfo != null) networkInfo.isConnected() else false
+
+ if(isConnected){
+ tvIsConnected.setText("Connected "+networkInfo?.typeName)
+ tvIsConnected.setBackgroundColor(0xFF7CCC26.toInt())
+
+ }else{
+ tvIsConnected.setText("Not Connected!")
+ tvIsConnected.setBackgroundColor(0xFFFF0000.toInt())
+ }
+ return isConnected;
+ }
+
+ inner class HTTPAsyncTask : AsyncTask() {
+ override fun doInBackground(vararg urls: String?): String {
+ return HttpGet(urls[0])
+ }
+ override fun onPostExecute(result: String?) {
+ tvResult.setText(result)
+ }
+ }
+
+ private fun HttpGet(myURL: String?): String {
+
+ val inputStream:InputStream
+ val result:String
+
+ // create URL
+ val url:URL = URL(myURL)
+
+ // create HttpURLConnection
+ val conn:HttpURLConnection = url.openConnection() as HttpURLConnection
+
+ // make GET request to the given URL
+ conn.connect()
+
+ // receive response as inputStream
+ inputStream = conn.inputStream
+
+ // convert inputstream to string
+ if(inputStream != null)
+ result = convertInputStreamToString(inputStream)
+ else
+ result = "Did not work!"
+
+ return result
+ }
+
+ private fun convertInputStreamToString(inputStream: InputStream): String {
+ val bufferedReader:BufferedReader? = BufferedReader(InputStreamReader(inputStream))
+ var line:String? = bufferedReader?.readLine()
+ var result:String = ""
+
+ while (line != null) {
+ result += line
+ line = bufferedReader?.readLine()
+ }
+
+ inputStream.close()
+ return result
+ }
+
+}
diff --git a/android-http/http-asynctask/src/main/res/layout/activity_main.xml b/android-http/http-asynctask/src/main/res/layout/activity_main.xml
new file mode 100644
index 00000000..fbab6354
--- /dev/null
+++ b/android-http/http-asynctask/src/main/res/layout/activity_main.xml
@@ -0,0 +1,36 @@
+
+
+
+
+
+
+
diff --git a/android-http/http-asynctask/src/main/res/values/colors.xml b/android-http/http-asynctask/src/main/res/values/colors.xml
new file mode 100644
index 00000000..69b22338
--- /dev/null
+++ b/android-http/http-asynctask/src/main/res/values/colors.xml
@@ -0,0 +1,6 @@
+
+
+ #008577
+ #00574B
+ #D81B60
+
diff --git a/android-http/http-asynctask/src/main/res/values/dimens.xml b/android-http/http-asynctask/src/main/res/values/dimens.xml
new file mode 100644
index 00000000..7b4d74af
--- /dev/null
+++ b/android-http/http-asynctask/src/main/res/values/dimens.xml
@@ -0,0 +1,6 @@
+
+
+
+ 16dp
+ 16dp
+
diff --git a/android-http/http-asynctask/src/main/res/values/strings.xml b/android-http/http-asynctask/src/main/res/values/strings.xml
new file mode 100644
index 00000000..03fc0f28
--- /dev/null
+++ b/android-http/http-asynctask/src/main/res/values/strings.xml
@@ -0,0 +1,3 @@
+
+ android-http
+
diff --git a/android-http/http-asynctask/src/main/res/values/styles.xml b/android-http/http-asynctask/src/main/res/values/styles.xml
new file mode 100644
index 00000000..5885930d
--- /dev/null
+++ b/android-http/http-asynctask/src/main/res/values/styles.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
diff --git a/android-http/http-coroutine/build.gradle b/android-http/http-coroutine/build.gradle
new file mode 100644
index 00000000..06e0675e
--- /dev/null
+++ b/android-http/http-coroutine/build.gradle
@@ -0,0 +1,41 @@
+apply plugin: 'com.android.application'
+
+apply plugin: 'kotlin-android'
+
+apply plugin: 'kotlin-android-extensions'
+
+android {
+ compileSdkVersion 29
+ buildToolsVersion "29.0.2"
+ defaultConfig {
+ applicationId "com.hmkcode.http"
+ minSdkVersion 19
+ targetSdkVersion 29
+ versionCode 1
+ versionName "1.0"
+ testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
+ }
+ buildTypes {
+ release {
+ minifyEnabled false
+ proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
+ }
+ }
+}
+
+dependencies {
+ implementation fileTree(dir: 'libs', include: ['*.jar'])
+ implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
+ implementation 'androidx.appcompat:appcompat:1.1.0'
+ implementation 'androidx.core:core-ktx:1.0.2'
+ implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
+ implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.2"
+ implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.2"
+ implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.2.0-alpha05"
+
+
+ implementation 'androidx.legacy:legacy-support-v4:1.0.0'
+ testImplementation 'junit:junit:4.12'
+ androidTestImplementation 'androidx.test:runner:1.1.1'
+ androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
+}
diff --git a/android-http/http-coroutine/src/main/AndroidManifest.xml b/android-http/http-coroutine/src/main/AndroidManifest.xml
new file mode 100644
index 00000000..964aa8b7
--- /dev/null
+++ b/android-http/http-coroutine/src/main/AndroidManifest.xml
@@ -0,0 +1,25 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/android-http/http-coroutine/src/main/java/com/hmkcode/http/MainActivity.kt b/android-http/http-coroutine/src/main/java/com/hmkcode/http/MainActivity.kt
new file mode 100644
index 00000000..9403d24c
--- /dev/null
+++ b/android-http/http-coroutine/src/main/java/com/hmkcode/http/MainActivity.kt
@@ -0,0 +1,116 @@
+package com.hmkcode.http
+
+import android.content.Context
+import android.net.ConnectivityManager
+import android.net.Network
+import android.net.NetworkInfo
+import android.os.AsyncTask
+import android.os.Build
+import androidx.appcompat.app.AppCompatActivity
+import android.os.Bundle
+import android.util.Log
+import android.widget.TextView
+import androidx.lifecycle.lifecycleScope
+import kotlinx.android.synthetic.main.activity_main.*
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.GlobalScope
+import kotlinx.coroutines.launch
+import kotlinx.coroutines.withContext
+import java.io.BufferedReader
+import java.io.InputStream
+import java.io.InputStreamReader
+import java.lang.Exception
+import java.lang.NumberFormatException
+import java.net.HttpURLConnection
+import java.net.URL
+
+class MainActivity : AppCompatActivity() {
+
+ lateinit var tvIsConnected: TextView;
+ lateinit var tvResult: TextView;
+
+
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ setContentView(R.layout.activity_main)
+ tvIsConnected = findViewById(R.id.tvIsConnected)
+ tvResult = findViewById(R.id.tvResult)
+
+ if(checkNetworkConnection()) {
+ lifecycleScope.launch {
+ val result = httpGet("http://hmkcode-api.appspot.com/rest/api/hello/Android")
+ tvResult.setText(result)
+ }
+ }
+
+ }
+
+
+ private fun checkNetworkConnection(): Boolean {
+
+ val cm:ConnectivityManager =
+ getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
+
+
+
+ val networkInfo:NetworkInfo? = cm.activeNetworkInfo
+ val isConnected: Boolean = if(networkInfo != null) networkInfo.isConnected() else false
+
+ if(isConnected){
+ tvIsConnected.setText("Connected "+networkInfo?.typeName)
+ tvIsConnected.setBackgroundColor(0xFF7CCC26.toInt())
+
+ }else{
+ tvIsConnected.setText("Not Connected!")
+ tvIsConnected.setBackgroundColor(0xFFFF0000.toInt())
+ }
+ return isConnected;
+ }
+
+
+
+ private suspend fun httpGet(myURL: String?): String? {
+
+ val result = withContext(Dispatchers.IO) {
+ val inputStream: InputStream
+
+
+ // create URL
+ val url: URL = URL(myURL)
+
+ // create HttpURLConnection
+ val conn: HttpURLConnection = url.openConnection() as HttpURLConnection
+
+ // make GET request to the given URL
+ conn.connect()
+
+ // receive response as inputStream
+ inputStream = conn.inputStream
+
+ // convert inputstream to string
+ if (inputStream != null)
+ convertInputStreamToString(inputStream)
+ else
+ "Did not work!"
+
+
+ }
+ return result
+ }
+
+ private fun convertInputStreamToString(inputStream: InputStream): String {
+ val bufferedReader:BufferedReader? = BufferedReader(InputStreamReader(inputStream))
+
+ var line:String? = bufferedReader?.readLine()
+ var result:String = ""
+
+ while (line != null) {
+ result += line
+ line = bufferedReader?.readLine()
+ }
+
+ inputStream.close()
+ return result
+ }
+
+}
diff --git a/android-http/http-coroutine/src/main/res/drawable/ic_launcher_background.xml b/android-http/http-coroutine/src/main/res/drawable/ic_launcher_background.xml
new file mode 100644
index 00000000..0d025f9b
--- /dev/null
+++ b/android-http/http-coroutine/src/main/res/drawable/ic_launcher_background.xml
@@ -0,0 +1,170 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/android-http/http-coroutine/src/main/res/layout/activity_main.xml b/android-http/http-coroutine/src/main/res/layout/activity_main.xml
new file mode 100644
index 00000000..fbab6354
--- /dev/null
+++ b/android-http/http-coroutine/src/main/res/layout/activity_main.xml
@@ -0,0 +1,36 @@
+
+
+
+
+
+
+
diff --git a/android-http/http-coroutine/src/main/res/values/colors.xml b/android-http/http-coroutine/src/main/res/values/colors.xml
new file mode 100644
index 00000000..69b22338
--- /dev/null
+++ b/android-http/http-coroutine/src/main/res/values/colors.xml
@@ -0,0 +1,6 @@
+
+
+ #008577
+ #00574B
+ #D81B60
+
diff --git a/android-http/http-coroutine/src/main/res/values/dimens.xml b/android-http/http-coroutine/src/main/res/values/dimens.xml
new file mode 100644
index 00000000..7b4d74af
--- /dev/null
+++ b/android-http/http-coroutine/src/main/res/values/dimens.xml
@@ -0,0 +1,6 @@
+
+
+
+ 16dp
+ 16dp
+
diff --git a/android-http/http-coroutine/src/main/res/values/strings.xml b/android-http/http-coroutine/src/main/res/values/strings.xml
new file mode 100644
index 00000000..7ce813ab
--- /dev/null
+++ b/android-http/http-coroutine/src/main/res/values/strings.xml
@@ -0,0 +1,6 @@
+
+ android-http
+
+
+ Hello blank fragment
+
diff --git a/android-http/http-coroutine/src/main/res/values/styles.xml b/android-http/http-coroutine/src/main/res/values/styles.xml
new file mode 100644
index 00000000..5885930d
--- /dev/null
+++ b/android-http/http-coroutine/src/main/res/values/styles.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
diff --git a/android-http/post-json/build.gradle b/android-http/post-json/build.gradle
new file mode 100644
index 00000000..ae8be9dd
--- /dev/null
+++ b/android-http/post-json/build.gradle
@@ -0,0 +1,42 @@
+apply plugin: 'com.android.application'
+apply plugin: 'kotlin-android'
+apply plugin: 'kotlin-android-extensions'
+android {
+ compileSdkVersion 29
+ buildToolsVersion "29.0.2"
+
+
+ defaultConfig {
+ applicationId "com.hmkcodes"
+ minSdkVersion 19
+ targetSdkVersion 29
+ versionCode 1
+ versionName "1.0"
+
+ testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
+ }
+
+ buildTypes {
+ release {
+ minifyEnabled false
+ proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
+ }
+ }
+
+}
+
+dependencies {
+ implementation fileTree(dir: 'libs', include: ['*.jar'])
+ implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
+ implementation 'androidx.appcompat:appcompat:1.1.0'
+ implementation 'com.google.android.material:material:1.1.0-beta01'
+ implementation 'androidx.core:core-ktx:1.1.0'
+ implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
+ implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.2"
+ implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.2"
+ implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.2.0-alpha05"
+
+ testImplementation 'junit:junit:4.12'
+ androidTestImplementation 'androidx.test.ext:junit:1.1.0'
+ androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
+}
diff --git a/android-http/post-json/src/main/AndroidManifest.xml b/android-http/post-json/src/main/AndroidManifest.xml
new file mode 100644
index 00000000..e84b4507
--- /dev/null
+++ b/android-http/post-json/src/main/AndroidManifest.xml
@@ -0,0 +1,25 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/android-http/post-json/src/main/java/com/hmkcode/MainActivity.kt b/android-http/post-json/src/main/java/com/hmkcode/MainActivity.kt
new file mode 100644
index 00000000..9cac05f8
--- /dev/null
+++ b/android-http/post-json/src/main/java/com/hmkcode/MainActivity.kt
@@ -0,0 +1,129 @@
+package com.hmkcode
+
+import android.content.Context
+import android.net.ConnectivityManager
+import androidx.appcompat.app.AppCompatActivity
+import android.os.Bundle
+import android.util.Log
+import android.view.View
+import android.widget.EditText
+import android.widget.TextView
+import android.widget.Toast
+import androidx.lifecycle.lifecycleScope
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.launch
+import kotlinx.coroutines.withContext
+import org.json.JSONException
+import org.json.JSONObject
+import java.io.BufferedWriter
+import java.io.IOException
+import java.io.OutputStreamWriter
+import java.net.HttpURLConnection
+import java.net.URL
+import javax.net.ssl.HttpsURLConnection
+
+class MainActivity : AppCompatActivity() {
+
+ lateinit var tvIsConnected: TextView
+ lateinit var etTitle: EditText
+ lateinit var etUrl: EditText
+ lateinit var etTags: EditText
+ lateinit var tvResult: TextView
+
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ setContentView(R.layout.activity_main)
+
+ tvIsConnected = findViewById(R.id.tvIsConnected)
+ etTitle = findViewById(R.id.etTitle)
+ etUrl = findViewById(R.id.etUrl)
+ etTags = findViewById(R.id.etTags)
+ tvResult = findViewById(R.id.tvResult)
+ checkNetworkConnection()
+ }
+
+ public fun send(view:View) {
+ Toast.makeText(this, "Clicked", Toast.LENGTH_SHORT).show()
+ // clear text result
+ tvResult.setText("")
+
+ if (checkNetworkConnection())
+ lifecycleScope.launch {
+ val result = httpPost("https://hmkcode-api.appspot.com/rest/link/add")
+ tvResult.setText(result)
+ }
+ else
+ Toast.makeText(this, "Not Connected!", Toast.LENGTH_SHORT).show()
+
+ }
+
+ @Throws(IOException::class, JSONException::class)
+ private suspend fun httpPost(myUrl: String): String {
+
+ val result = withContext(Dispatchers.IO) {
+ val url = URL(myUrl)
+ // 1. create HttpURLConnection
+ val conn = url.openConnection() as HttpsURLConnection
+ conn.requestMethod = "POST"
+ conn.setRequestProperty("Content-Type", "application/json; charset=utf-8")
+
+ // 2. build JSON object
+ val jsonObject = buidJsonObject()
+
+ // 3. add JSON content to POST request body
+ setPostRequestContent(conn, jsonObject)
+
+ // 4. make POST request to the given URL
+ conn.connect()
+
+ // 5. return response message
+ conn.responseMessage + ""
+ }
+ return result
+ }
+
+ private fun checkNetworkConnection(): Boolean {
+ val connMgr = getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
+
+ val networkInfo = connMgr.activeNetworkInfo
+ val isConnected: Boolean = if(networkInfo != null) networkInfo.isConnected() else false
+ if (networkInfo != null && isConnected) {
+ // show "Connected" & type of network "WIFI or MOBILE"
+ tvIsConnected.text = "Connected " + networkInfo.typeName
+ // change background color to red
+ tvIsConnected.setBackgroundColor(-0x8333da)
+
+
+ } else {
+ // show "Not Connected"
+ tvIsConnected.text = "Not Connected"
+ // change background color to green
+ tvIsConnected.setBackgroundColor(-0x10000)
+ }
+
+ return isConnected
+ }
+
+ @Throws(JSONException::class)
+ private fun buidJsonObject(): JSONObject {
+
+ val jsonObject = JSONObject()
+ jsonObject.accumulate("title", etTitle.getText().toString())
+ jsonObject.accumulate("url", etUrl.getText().toString())
+ jsonObject.accumulate("tags", etTags.getText().toString())
+
+ return jsonObject
+ }
+
+ @Throws(IOException::class)
+ private fun setPostRequestContent(conn: HttpURLConnection, jsonObject: JSONObject) {
+
+ val os = conn.outputStream
+ val writer = BufferedWriter(OutputStreamWriter(os, "UTF-8"))
+ writer.write(jsonObject.toString())
+ Log.i(MainActivity::class.java.toString(), jsonObject.toString())
+ writer.flush()
+ writer.close()
+ os.close()
+ }
+}
diff --git a/android-http/post-json/src/main/res/drawable/ic_launcher_background.xml b/android-http/post-json/src/main/res/drawable/ic_launcher_background.xml
new file mode 100644
index 00000000..0d025f9b
--- /dev/null
+++ b/android-http/post-json/src/main/res/drawable/ic_launcher_background.xml
@@ -0,0 +1,170 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/android-http/post-json/src/main/res/layout/activity_main.xml b/android-http/post-json/src/main/res/layout/activity_main.xml
new file mode 100644
index 00000000..157cdff1
--- /dev/null
+++ b/android-http/post-json/src/main/res/layout/activity_main.xml
@@ -0,0 +1,82 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/android-http/post-json/src/main/res/values/colors.xml b/android-http/post-json/src/main/res/values/colors.xml
new file mode 100644
index 00000000..69b22338
--- /dev/null
+++ b/android-http/post-json/src/main/res/values/colors.xml
@@ -0,0 +1,6 @@
+
+
+ #008577
+ #00574B
+ #D81B60
+
diff --git a/android-http/post-json/src/main/res/values/dimens.xml b/android-http/post-json/src/main/res/values/dimens.xml
new file mode 100644
index 00000000..48963b20
--- /dev/null
+++ b/android-http/post-json/src/main/res/values/dimens.xml
@@ -0,0 +1,6 @@
+
+
+
+ 16dp
+ 16dp
+
\ No newline at end of file
diff --git a/android-http/post-json/src/main/res/values/strings.xml b/android-http/post-json/src/main/res/values/strings.xml
new file mode 100644
index 00000000..844b97c4
--- /dev/null
+++ b/android-http/post-json/src/main/res/values/strings.xml
@@ -0,0 +1,3 @@
+
+ post-json
+
diff --git a/android-http/post-json/src/main/res/values/styles.xml b/android-http/post-json/src/main/res/values/styles.xml
new file mode 100644
index 00000000..5885930d
--- /dev/null
+++ b/android-http/post-json/src/main/res/values/styles.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
diff --git a/android-input-text-layout/AndroidManifest.xml b/android-input-text-layout/AndroidManifest.xml
new file mode 100644
index 00000000..827af018
--- /dev/null
+++ b/android-input-text-layout/AndroidManifest.xml
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/android-input-text-layout/project.properties b/android-input-text-layout/project.properties
new file mode 100644
index 00000000..fe03cc61
--- /dev/null
+++ b/android-input-text-layout/project.properties
@@ -0,0 +1,16 @@
+# This file is automatically generated by Android Tools.
+# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
+#
+# This file must be checked in Version Control Systems.
+#
+# To customize properties used by the Ant build system edit
+# "ant.properties", and override values to adapt the script to your
+# project structure.
+#
+# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
+#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
+
+# Project target.
+target=android-22
+android.library.reference.1=..\\..\\sdk\\extras\\android\\support\\design
+android.library.reference.2=../../sdk/extras/android/support/v7/appcompat
diff --git a/android-input-text-layout/res/layout/activity_main.xml b/android-input-text-layout/res/layout/activity_main.xml
new file mode 100644
index 00000000..fc90c755
--- /dev/null
+++ b/android-input-text-layout/res/layout/activity_main.xml
@@ -0,0 +1,36 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/android-input-text-layout/src/com/hmkcode/inputtextlayout/MainActivity.java b/android-input-text-layout/src/com/hmkcode/inputtextlayout/MainActivity.java
new file mode 100644
index 00000000..5a3b1109
--- /dev/null
+++ b/android-input-text-layout/src/com/hmkcode/inputtextlayout/MainActivity.java
@@ -0,0 +1,34 @@
+package com.hmkcode.inputtextlayout;
+
+import android.support.v7.app.ActionBarActivity;
+import android.os.Bundle;
+import android.view.Menu;
+import android.view.MenuItem;
+
+public class MainActivity extends ActionBarActivity {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_main);
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.main, menu);
+ return true;
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ // Handle action bar item clicks here. The action bar will
+ // automatically handle clicks on the Home/Up button, so long
+ // as you specify a parent activity in AndroidManifest.xml.
+ int id = item.getItemId();
+ if (id == R.id.action_settings) {
+ return true;
+ }
+ return super.onOptionsItemSelected(item);
+ }
+}
diff --git a/android-material-design-appcompat/AndroidManifest.xml b/android-material-design-appcompat/AndroidManifest.xml
new file mode 100644
index 00000000..70227ada
--- /dev/null
+++ b/android-material-design-appcompat/AndroidManifest.xml
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/android-material-design-appcompat/res/drawable-hdpi/cardview_border.xml b/android-material-design-appcompat/res/drawable-hdpi/cardview_border.xml
new file mode 100644
index 00000000..fdfa61f3
--- /dev/null
+++ b/android-material-design-appcompat/res/drawable-hdpi/cardview_border.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/android-material-design-appcompat/res/drawable-hdpi/ic_action_location_found.png b/android-material-design-appcompat/res/drawable-hdpi/ic_action_location_found.png
new file mode 100644
index 00000000..4748e901
Binary files /dev/null and b/android-material-design-appcompat/res/drawable-hdpi/ic_action_location_found.png differ
diff --git a/android-material-design-appcompat/res/drawable-hdpi/ic_action_location_found_dark.png b/android-material-design-appcompat/res/drawable-hdpi/ic_action_location_found_dark.png
new file mode 100644
index 00000000..e1bf5807
Binary files /dev/null and b/android-material-design-appcompat/res/drawable-hdpi/ic_action_location_found_dark.png differ
diff --git a/android-material-design-appcompat/res/drawable-hdpi/ic_launcher.png b/android-material-design-appcompat/res/drawable-hdpi/ic_launcher.png
new file mode 100644
index 00000000..288b6655
Binary files /dev/null and b/android-material-design-appcompat/res/drawable-hdpi/ic_launcher.png differ
diff --git a/android-material-design-appcompat/res/drawable-hdpi/ic_menu.png b/android-material-design-appcompat/res/drawable-hdpi/ic_menu.png
new file mode 100644
index 00000000..8962cbd9
Binary files /dev/null and b/android-material-design-appcompat/res/drawable-hdpi/ic_menu.png differ
diff --git a/android-material-design-appcompat/res/layout/activity_main.xml b/android-material-design-appcompat/res/layout/activity_main.xml
new file mode 100644
index 00000000..029a8f0c
--- /dev/null
+++ b/android-material-design-appcompat/res/layout/activity_main.xml
@@ -0,0 +1,72 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/android-material-design-appcompat/res/layout/activity_main_1.xml b/android-material-design-appcompat/res/layout/activity_main_1.xml
new file mode 100644
index 00000000..d87cbe42
--- /dev/null
+++ b/android-material-design-appcompat/res/layout/activity_main_1.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
diff --git a/android-material-design-appcompat/res/layout/activity_main_2.xml b/android-material-design-appcompat/res/layout/activity_main_2.xml
new file mode 100644
index 00000000..95915fb7
--- /dev/null
+++ b/android-material-design-appcompat/res/layout/activity_main_2.xml
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
+
diff --git a/android-material-design-appcompat/res/layout/activity_main_3.xml b/android-material-design-appcompat/res/layout/activity_main_3.xml
new file mode 100644
index 00000000..48f33a98
--- /dev/null
+++ b/android-material-design-appcompat/res/layout/activity_main_3.xml
@@ -0,0 +1,33 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/android-material-design-appcompat/res/layout/activity_main_4.xml b/android-material-design-appcompat/res/layout/activity_main_4.xml
new file mode 100644
index 00000000..4b712fbb
--- /dev/null
+++ b/android-material-design-appcompat/res/layout/activity_main_4.xml
@@ -0,0 +1,37 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/android-material-design-appcompat/res/layout/activity_main_5.xml b/android-material-design-appcompat/res/layout/activity_main_5.xml
new file mode 100644
index 00000000..5d8fe417
--- /dev/null
+++ b/android-material-design-appcompat/res/layout/activity_main_5.xml
@@ -0,0 +1,46 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/android-material-design-appcompat/res/layout/activity_main_6.xml b/android-material-design-appcompat/res/layout/activity_main_6.xml
new file mode 100644
index 00000000..3d5fcff6
--- /dev/null
+++ b/android-material-design-appcompat/res/layout/activity_main_6.xml
@@ -0,0 +1,55 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/android-material-design-appcompat/res/layout/cardviews.xml b/android-material-design-appcompat/res/layout/cardviews.xml
new file mode 100644
index 00000000..3ce1874c
--- /dev/null
+++ b/android-material-design-appcompat/res/layout/cardviews.xml
@@ -0,0 +1,107 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/android-material-design-appcompat/res/layout/nav_header.xml b/android-material-design-appcompat/res/layout/nav_header.xml
new file mode 100644
index 00000000..342e3ded
--- /dev/null
+++ b/android-material-design-appcompat/res/layout/nav_header.xml
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/android-material-design-appcompat/res/menu/main.xml b/android-material-design-appcompat/res/menu/main.xml
new file mode 100644
index 00000000..1db8bac6
--- /dev/null
+++ b/android-material-design-appcompat/res/menu/main.xml
@@ -0,0 +1,20 @@
+
diff --git a/android-material-design-appcompat/res/menu/navigation_drawer_items.xml b/android-material-design-appcompat/res/menu/navigation_drawer_items.xml
new file mode 100644
index 00000000..d2be94fb
--- /dev/null
+++ b/android-material-design-appcompat/res/menu/navigation_drawer_items.xml
@@ -0,0 +1,22 @@
+
diff --git a/android-material-design-appcompat/res/values-v21/colors.xml b/android-material-design-appcompat/res/values-v21/colors.xml
new file mode 100644
index 00000000..d96316ee
--- /dev/null
+++ b/android-material-design-appcompat/res/values-v21/colors.xml
@@ -0,0 +1,5 @@
+
+
+ #FFF5F5F5
+
+
diff --git a/android-material-design-appcompat/res/values-v21/dimens.xml b/android-material-design-appcompat/res/values-v21/dimens.xml
new file mode 100644
index 00000000..55c1e590
--- /dev/null
+++ b/android-material-design-appcompat/res/values-v21/dimens.xml
@@ -0,0 +1,7 @@
+
+
+
+ 16dp
+ 16dp
+
+
diff --git a/android-material-design-appcompat/res/values-v21/strings.xml b/android-material-design-appcompat/res/values-v21/strings.xml
new file mode 100644
index 00000000..20258df1
--- /dev/null
+++ b/android-material-design-appcompat/res/values-v21/strings.xml
@@ -0,0 +1,8 @@
+
+
+
+ HMKCODE App
+ Hello world!
+ Settings
+
+
diff --git a/android-material-design-appcompat/res/values-v21/styles.xml b/android-material-design-appcompat/res/values-v21/styles.xml
new file mode 100644
index 00000000..cf204b67
--- /dev/null
+++ b/android-material-design-appcompat/res/values-v21/styles.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
diff --git a/android-material-design-appcompat/res/values/colors.xml b/android-material-design-appcompat/res/values/colors.xml
new file mode 100644
index 00000000..74084b97
--- /dev/null
+++ b/android-material-design-appcompat/res/values/colors.xml
@@ -0,0 +1,14 @@
+
+
+ #CC000000
+
+
+ #ED1C24
+ #CC0000
+ #B3E5FC
+ #ED1C24
+ #ffffff
+ #ffffff
+ #FFFFFF
+ #B6B6B6
+
diff --git a/android-material-design-appcompat/res/values/dimens.xml b/android-material-design-appcompat/res/values/dimens.xml
new file mode 100644
index 00000000..b358808f
--- /dev/null
+++ b/android-material-design-appcompat/res/values/dimens.xml
@@ -0,0 +1,9 @@
+
+
+
+ 16dp
+ 16dp
+ 16dp
+ 256dp
+
+
diff --git a/android-material-design-appcompat/res/values/strings.xml b/android-material-design-appcompat/res/values/strings.xml
new file mode 100644
index 00000000..6b69df83
--- /dev/null
+++ b/android-material-design-appcompat/res/values/strings.xml
@@ -0,0 +1,17 @@
+
+
+
+ HMKCODE App
+ Hello world!
+ Settings
+ Find
+
+ Android 5.0 Lollipop was one of the most significant Android releases ever,
+ in no small part due to the introduction of material design,
+ a new design language that refreshed the entire Android experience
+
+
+ Open navigation drawer
+ Close navigation drawer
+
+
diff --git a/android-material-design-appcompat/res/values/styles.xml b/android-material-design-appcompat/res/values/styles.xml
new file mode 100644
index 00000000..23faf736
--- /dev/null
+++ b/android-material-design-appcompat/res/values/styles.xml
@@ -0,0 +1,48 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/android-material-design-appcompat/src/com/hmkcode/app/MainActivity.java b/android-material-design-appcompat/src/com/hmkcode/app/MainActivity.java
new file mode 100644
index 00000000..10acd7d2
--- /dev/null
+++ b/android-material-design-appcompat/src/com/hmkcode/app/MainActivity.java
@@ -0,0 +1,107 @@
+package com.hmkcode.app;
+
+
+import android.os.Bundle;
+import android.support.design.widget.CollapsingToolbarLayout;
+import android.support.design.widget.FloatingActionButton;
+import android.support.design.widget.Snackbar;
+import android.support.design.widget.TabLayout;
+import android.support.v4.view.GravityCompat;
+import android.support.v4.widget.DrawerLayout;
+import android.support.v7.app.ActionBar;
+import android.support.v7.app.AppCompatActivity;
+import android.support.v7.widget.Toolbar;
+import android.view.MenuItem;
+import android.view.View;
+import android.view.View.OnClickListener;
+
+public class MainActivity extends AppCompatActivity implements OnClickListener {
+
+ DrawerLayout drawerLayout;
+ CollapsingToolbarLayout collapsingToolbarLayout;
+ Toolbar toolbar;
+ TabLayout tabLayout;
+ FloatingActionButton fab;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_main);
+
+ setupNavigationView();
+ setupToolbar();
+ setupTablayout();
+ setupCollapsingToolbarLayout();
+ setupFab();
+
+ }
+
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()) {
+ case android.R.id.home:
+ if(drawerLayout != null)
+ drawerLayout.openDrawer(GravityCompat.START);
+ return true;
+ }
+ return super.onOptionsItemSelected(item);
+ }
+
+ private void setupNavigationView(){
+
+ drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
+ }
+
+ private void setupCollapsingToolbarLayout(){
+
+ collapsingToolbarLayout = (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar);
+ if(collapsingToolbarLayout != null){
+ collapsingToolbarLayout.setTitle(toolbar.getTitle());
+ //collapsingToolbarLayout.setCollapsedTitleTextColor(0xED1C24);
+ //collapsingToolbarLayout.setExpandedTitleColor(0xED1C24);
+ }
+ }
+
+ private void setupTablayout(){
+
+ tabLayout = (TabLayout) findViewById(R.id.tabLayout);
+
+ if(tabLayout == null)
+ return;
+
+ tabLayout.setTabGravity(TabLayout.GRAVITY_FILL);
+ tabLayout.addTab(tabLayout.newTab().setText("Tab 1"));
+ tabLayout.addTab(tabLayout.newTab().setText("Tab 2"));
+ tabLayout.addTab(tabLayout.newTab().setText("Tab 3"));
+ tabLayout.addTab(tabLayout.newTab().setText("Tab 4"));
+ }
+
+ private void setupFab(){
+ fab = (FloatingActionButton) findViewById(R.id.fab);
+ if(fab != null)
+ fab.setOnClickListener(this);
+ }
+ private void setupToolbar(){
+ toolbar = (Toolbar) findViewById(R.id.toolbar);
+ if(toolbar != null)
+ setSupportActionBar(toolbar);
+
+ // Show menu icon
+ final ActionBar ab = getSupportActionBar();
+ ab.setHomeAsUpIndicator(R.drawable.ic_menu);
+ ab.setDisplayHomeAsUpEnabled(true);
+ }
+
+ @Override
+ public void onClick(View view) {
+
+ if(view.getId() == R.id.fab){
+
+ Snackbar
+ .make(findViewById(R.id.coordinatorLayout), "This is Snackbar", Snackbar.LENGTH_LONG)
+ .setAction("Action", this)
+ .show(); // Don’t forget to show!
+ }
+ }
+}
diff --git a/android-post-json/app/build.gradle b/android-post-json/app/build.gradle
new file mode 100644
index 00000000..be999094
--- /dev/null
+++ b/android-post-json/app/build.gradle
@@ -0,0 +1,29 @@
+apply plugin: 'com.android.application'
+
+android {
+ compileSdkVersion 27
+ defaultConfig {
+ applicationId "com.hmkcode"
+ minSdkVersion 16
+ targetSdkVersion 27
+ versionCode 1
+ versionName "1.0"
+ testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
+ }
+ buildTypes {
+ release {
+ minifyEnabled false
+ proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
+ }
+ }
+}
+
+dependencies {
+ implementation fileTree(dir: 'libs', include: ['*.jar'])
+ implementation 'com.android.support:appcompat-v7:27.1.1'
+ implementation 'com.android.support:design:27.1.1'
+ implementation 'com.android.support.constraint:constraint-layout:1.1.2'
+ testImplementation 'junit:junit:4.12'
+ androidTestImplementation 'com.android.support.test:runner:1.0.2'
+ androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
+}
diff --git a/android-post-json/app/src/main/AndroidManifest.xml b/android-post-json/app/src/main/AndroidManifest.xml
new file mode 100644
index 00000000..8852e0b4
--- /dev/null
+++ b/android-post-json/app/src/main/AndroidManifest.xml
@@ -0,0 +1,24 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/android-post-json/app/src/main/java/com/hmkcode/MainActivity.java b/android-post-json/app/src/main/java/com/hmkcode/MainActivity.java
new file mode 100644
index 00000000..86b46cd1
--- /dev/null
+++ b/android-post-json/app/src/main/java/com/hmkcode/MainActivity.java
@@ -0,0 +1,154 @@
+package com.hmkcode;
+
+import android.content.Context;
+import android.net.ConnectivityManager;
+import android.net.NetworkInfo;
+import android.os.AsyncTask;
+import android.support.v7.app.AppCompatActivity;
+import android.os.Bundle;
+import android.util.Log;
+import android.view.View;
+import android.widget.EditText;
+import android.widget.TextView;
+import android.widget.Toast;
+
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.net.HttpURLConnection;
+import java.net.URL;
+
+public class MainActivity extends AppCompatActivity {
+
+ TextView tvIsConnected;
+ EditText etName;
+ EditText etCountry;
+ EditText etTwitter;
+ TextView tvResult;
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_main);
+ tvIsConnected = (TextView) findViewById(R.id.tvIsConnected);
+ etName = findViewById(R.id.etName);
+ etCountry = findViewById(R.id.etCountry);
+ etTwitter = findViewById(R.id.etTwitter);
+ tvResult = (TextView) findViewById(R.id.tvResult);
+ checkNetworkConnection();
+
+
+
+ }
+
+ // check network connection
+ public boolean checkNetworkConnection() {
+ ConnectivityManager connMgr = (ConnectivityManager)
+ getSystemService(Context.CONNECTIVITY_SERVICE);
+
+ NetworkInfo networkInfo = connMgr.getActiveNetworkInfo();
+ boolean isConnected = false;
+ if (networkInfo != null && (isConnected = networkInfo.isConnected())) {
+ // show "Connected" & type of network "WIFI or MOBILE"
+ tvIsConnected.setText("Connected "+networkInfo.getTypeName());
+ // change background color to red
+ tvIsConnected.setBackgroundColor(0xFF7CCC26);
+
+
+ } else {
+ // show "Not Connected"
+ tvIsConnected.setText("Not Connected");
+ // change background color to green
+ tvIsConnected.setBackgroundColor(0xFFFF0000);
+ }
+
+ return isConnected;
+ }
+
+
+ private String httpPost(String myUrl) throws IOException, JSONException {
+ String result = "";
+
+ URL url = new URL(myUrl);
+
+ // 1. create HttpURLConnection
+ HttpURLConnection conn = (HttpURLConnection) url.openConnection();
+ conn.setRequestMethod("POST");
+ conn.setRequestProperty("Content-Type", "application/json; charset=utf-8");
+
+ // 2. build JSON object
+ JSONObject jsonObject = buidJsonObject();
+
+ // 3. add JSON content to POST request body
+ setPostRequestContent(conn, jsonObject);
+
+ // 4. make POST request to the given URL
+ conn.connect();
+
+ // 5. return response message
+ return conn.getResponseMessage()+"";
+
+ }
+
+
+ private class HTTPAsyncTask extends AsyncTask {
+ @Override
+ protected String doInBackground(String... urls) {
+ // params comes from the execute() call: params[0] is the url.
+ try {
+ try {
+ return httpPost(urls[0]);
+ } catch (JSONException e) {
+ e.printStackTrace();
+ return "Error!";
+ }
+ } catch (IOException e) {
+ return "Unable to retrieve web page. URL may be invalid.";
+ }
+ }
+ // onPostExecute displays the results of the AsyncTask.
+ @Override
+ protected void onPostExecute(String result) {
+ tvResult.setText(result);
+ }
+ }
+
+
+ public void send(View view) {
+ Toast.makeText(this, "Clicked", Toast.LENGTH_SHORT).show();
+ // perform HTTP POST request
+ if(checkNetworkConnection())
+ new HTTPAsyncTask().execute("http://hmkcode.appspot.com/jsonservlet");
+ else
+ Toast.makeText(this, "Not Connected!", Toast.LENGTH_SHORT).show();
+
+ }
+
+ private JSONObject buidJsonObject() throws JSONException {
+
+ JSONObject jsonObject = new JSONObject();
+ jsonObject.accumulate("name", etName.getText().toString());
+ jsonObject.accumulate("country", etCountry.getText().toString());
+ jsonObject.accumulate("twitter", etTwitter.getText().toString());
+
+ return jsonObject;
+ }
+
+ private void setPostRequestContent(HttpURLConnection conn, JSONObject jsonObject) throws IOException {
+
+ OutputStream os = conn.getOutputStream();
+ BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(os, "UTF-8"));
+ writer.write(jsonObject.toString());
+ Log.i(MainActivity.class.toString(), jsonObject.toString());
+ writer.flush();
+ writer.close();
+ os.close();
+ }
+
+}
diff --git a/android-post-json/app/src/main/res/drawable/ic_launcher_background.xml b/android-post-json/app/src/main/res/drawable/ic_launcher_background.xml
new file mode 100644
index 00000000..d5fccc53
--- /dev/null
+++ b/android-post-json/app/src/main/res/drawable/ic_launcher_background.xml
@@ -0,0 +1,170 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/android-post-json/app/src/main/res/layout/activity_main.xml b/android-post-json/app/src/main/res/layout/activity_main.xml
new file mode 100644
index 00000000..5aa66a4e
--- /dev/null
+++ b/android-post-json/app/src/main/res/layout/activity_main.xml
@@ -0,0 +1,82 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/android-post-json/app/src/main/res/values/colors.xml b/android-post-json/app/src/main/res/values/colors.xml
new file mode 100644
index 00000000..3ab3e9cb
--- /dev/null
+++ b/android-post-json/app/src/main/res/values/colors.xml
@@ -0,0 +1,6 @@
+
+
+ #3F51B5
+ #303F9F
+ #FF4081
+
diff --git a/android-post-json/app/src/main/res/values/dimens.xml b/android-post-json/app/src/main/res/values/dimens.xml
new file mode 100644
index 00000000..48963b20
--- /dev/null
+++ b/android-post-json/app/src/main/res/values/dimens.xml
@@ -0,0 +1,6 @@
+
+
+
+ 16dp
+ 16dp
+
\ No newline at end of file
diff --git a/android-post-json/app/src/main/res/values/strings.xml b/android-post-json/app/src/main/res/values/strings.xml
new file mode 100644
index 00000000..b72e4945
--- /dev/null
+++ b/android-post-json/app/src/main/res/values/strings.xml
@@ -0,0 +1,3 @@
+
+ android-post-json
+
diff --git a/android-post-json/app/src/main/res/values/styles.xml b/android-post-json/app/src/main/res/values/styles.xml
new file mode 100644
index 00000000..5885930d
--- /dev/null
+++ b/android-post-json/app/src/main/res/values/styles.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
diff --git a/android-post-json/build.gradle b/android-post-json/build.gradle
new file mode 100644
index 00000000..077cb2fc
--- /dev/null
+++ b/android-post-json/build.gradle
@@ -0,0 +1,27 @@
+// Top-level build file where you can add configuration options common to all sub-projects/modules.
+
+buildscript {
+
+ repositories {
+ google()
+ jcenter()
+ }
+ dependencies {
+ classpath 'com.android.tools.build:gradle:3.1.4'
+
+
+ // NOTE: Do not place your application dependencies here; they belong
+ // in the individual module build.gradle files
+ }
+}
+
+allprojects {
+ repositories {
+ google()
+ jcenter()
+ }
+}
+
+task clean(type: Delete) {
+ delete rootProject.buildDir
+}
diff --git a/android-post-json/ic_launcher-web.png b/android-post-json/ic_launcher-web.png
deleted file mode 100644
index a18cbb48..00000000
Binary files a/android-post-json/ic_launcher-web.png and /dev/null differ
diff --git a/android-post-json/readme.md b/android-post-json/readme.md
new file mode 100644
index 00000000..8705ac27
--- /dev/null
+++ b/android-post-json/readme.md
@@ -0,0 +1,2 @@
+[For the updated code click here!](https://github.com/hmkcode/Android/tree/master/android-http/post-json)
+
diff --git a/android-post-json/res/layout/activity_main.xml b/android-post-json/res/layout/activity_main.xml
deleted file mode 100644
index 921cdeb9..00000000
--- a/android-post-json/res/layout/activity_main.xml
+++ /dev/null
@@ -1,70 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/android-post-json/settings.gradle b/android-post-json/settings.gradle
new file mode 100644
index 00000000..e7b4def4
--- /dev/null
+++ b/android-post-json/settings.gradle
@@ -0,0 +1 @@
+include ':app'
diff --git a/android-post-json/src/com/hmkcode/android/MainActivity.java b/android-post-json/src/com/hmkcode/android/MainActivity.java
deleted file mode 100644
index a68d5f4e..00000000
--- a/android-post-json/src/com/hmkcode/android/MainActivity.java
+++ /dev/null
@@ -1,186 +0,0 @@
-package com.hmkcode.android;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-
-import org.apache.http.HttpResponse;
-import org.apache.http.client.HttpClient;
-import org.apache.http.client.methods.HttpPost;
-import org.apache.http.entity.StringEntity;
-import org.apache.http.impl.client.DefaultHttpClient;
-import org.json.JSONObject;
-import android.net.ConnectivityManager;
-import android.net.NetworkInfo;
-import android.os.AsyncTask;
-import android.os.Bundle;
-import android.util.Log;
-import android.view.View;
-import android.view.View.OnClickListener;
-import android.widget.Button;
-import android.widget.EditText;
-import android.widget.TextView;
-import android.widget.Toast;
-import android.app.Activity;
-import com.hmkcode.android.vo.Person;
-
-public class MainActivity extends Activity implements OnClickListener {
-
- TextView tvIsConnected;
- EditText etName,etCountry,etTwitter;
- Button btnPost;
-
- Person person;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main);
-
- // get reference to the views
- tvIsConnected = (TextView) findViewById(R.id.tvIsConnected);
- etName = (EditText) findViewById(R.id.etName);
- etCountry = (EditText) findViewById(R.id.etCountry);
- etTwitter = (EditText) findViewById(R.id.etTwitter);
- btnPost = (Button) findViewById(R.id.btnPost);
-
- // check if you are connected or not
- if(isConnected()){
- tvIsConnected.setBackgroundColor(0xFF00CC00);
- tvIsConnected.setText("You are conncted");
- }
- else{
- tvIsConnected.setText("You are NOT conncted");
- }
-
- // add click listener to Button "POST"
- btnPost.setOnClickListener(this);
-
-
- }
-
- public static String POST(String url, Person person){
- InputStream inputStream = null;
- String result = "";
- try {
-
- // 1. create HttpClient
- HttpClient httpclient = new DefaultHttpClient();
-
- // 2. make POST request to the given URL
- HttpPost httpPost = new HttpPost(url);
-
- String json = "";
-
-
- // 3. build jsonObject
- JSONObject jsonObject = new JSONObject();
- jsonObject.accumulate("name", person.getName());
- jsonObject.accumulate("country", person.getCountry());
- jsonObject.accumulate("twitter", person.getTwitter());
-
- // 4. convert JSONObject to JSON to String
- json = jsonObject.toString();
-
-
- // ** Alternative way to convert Person object to JSON string usin Jackson Lib
- // ObjectMapper mapper = new ObjectMapper();
- // json = mapper.writeValueAsString(person);
-
- // 5. set json to StringEntity
- StringEntity se = new StringEntity(json);
-
- // 6. set httpPost Entity
- httpPost.setEntity(se);
-
- // 7. Set some headers to inform server about the type of the content
- httpPost.setHeader("Accept", "application/json");
- httpPost.setHeader("Content-type", "application/json");
-
- // 8. Execute POST request to the given URL
- HttpResponse httpResponse = httpclient.execute(httpPost);
-
- // 9. receive response as inputStream
- inputStream = httpResponse.getEntity().getContent();
-
-
- // 10. convert inputstream to string
- if(inputStream != null)
- result = convertInputStreamToString(inputStream);
- else
- result = "Did not work!";
-
- } catch (Exception e) {
- Log.d("InputStream", e.getLocalizedMessage());
- }
-
- // 11. return result
- return result;
- }
-
- @Override
- public void onClick(View view) {
-
- switch(view.getId()){
- case R.id.btnPost:
- if(!validate())
- Toast.makeText(getBaseContext(), "Enter some data!", Toast.LENGTH_LONG).show();
- // call AsynTask to perform network operation on separate thread
- new HttpAsyncTask().execute("http://hmkcode.appspot.com/jsonservlet");
- break;
- }
-
- }
-
- public boolean isConnected(){
- ConnectivityManager connMgr = (ConnectivityManager) getSystemService(Activity.CONNECTIVITY_SERVICE);
- NetworkInfo networkInfo = connMgr.getActiveNetworkInfo();
- if (networkInfo != null && networkInfo.isConnected())
- return true;
- else
- return false;
- }
-
- private class HttpAsyncTask extends AsyncTask {
- @Override
- protected String doInBackground(String... urls) {
-
- person = new Person();
- person.setName(etName.getText().toString());
- person.setCountry(etCountry.getText().toString());
- person.setTwitter(etTwitter.getText().toString());
-
- return POST(urls[0],person);
- }
- // onPostExecute displays the results of the AsyncTask.
- @Override
- protected void onPostExecute(String result) {
- Toast.makeText(getBaseContext(), "Data Sent!", Toast.LENGTH_LONG).show();
- }
- }
-
-
- private boolean validate(){
- if(etName.getText().toString().trim().equals(""))
- return false;
- else if(etCountry.getText().toString().trim().equals(""))
- return false;
- else if(etTwitter.getText().toString().trim().equals(""))
- return false;
- else
- return true;
- }
- private static String convertInputStreamToString(InputStream inputStream) throws IOException{
- BufferedReader bufferedReader = new BufferedReader( new InputStreamReader(inputStream));
- String line = "";
- String result = "";
- while((line = bufferedReader.readLine()) != null)
- result += line;
-
- inputStream.close();
- return result;
-
- }
-
-
-}
diff --git a/android-post-json/src/com/hmkcode/android/vo/Person.java b/android-post-json/src/com/hmkcode/android/vo/Person.java
deleted file mode 100644
index ec39e4e7..00000000
--- a/android-post-json/src/com/hmkcode/android/vo/Person.java
+++ /dev/null
@@ -1,40 +0,0 @@
-package com.hmkcode.android.vo;
-
-public class Person {
-
- private String name;
- private String country;
- private String twitter;
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getCountry() {
- return country;
- }
-
- public void setCountry(String country) {
- this.country = country;
- }
-
- public String getTwitter() {
- return twitter;
- }
-
- public void setTwitter(String twitter) {
- this.twitter = twitter;
- }
-
- @Override
- public String toString() {
- return "Person [name=" + name + ", country=" + country + ", twitter="
- + twitter + "]";
- }
-
-
-}
diff --git a/android-read-browser-bookmark/AndroidManifest.xml b/android-read-browser-bookmark/AndroidManifest.xml
new file mode 100644
index 00000000..fdb20f58
--- /dev/null
+++ b/android-read-browser-bookmark/AndroidManifest.xml
@@ -0,0 +1,29 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/android-read-browser-bookmark/res/layout/activity_main.xml b/android-read-browser-bookmark/res/layout/activity_main.xml
new file mode 100644
index 00000000..038f1268
--- /dev/null
+++ b/android-read-browser-bookmark/res/layout/activity_main.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
diff --git a/android-read-browser-bookmark/res/layout/link.xml b/android-read-browser-bookmark/res/layout/link.xml
new file mode 100644
index 00000000..f6668e7a
--- /dev/null
+++ b/android-read-browser-bookmark/res/layout/link.xml
@@ -0,0 +1,89 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/android-read-browser-bookmark/src/com/hmkcode/browser/bookmark/MainActivity.java b/android-read-browser-bookmark/src/com/hmkcode/browser/bookmark/MainActivity.java
new file mode 100644
index 00000000..686e07f7
--- /dev/null
+++ b/android-read-browser-bookmark/src/com/hmkcode/browser/bookmark/MainActivity.java
@@ -0,0 +1,30 @@
+package com.hmkcode.browser.bookmark;
+
+import android.app.Activity;
+import android.database.Cursor;
+import android.os.Bundle;
+import android.provider.Browser;
+
+import android.widget.ListView;
+
+public class MainActivity extends Activity {
+
+ ListView listView;
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_main);
+ listView = (ListView) findViewById(R.id.listView1);
+ getBrowserHist();
+ }
+
+ public void getBrowserHist() {
+
+ Cursor cursor = getContentResolver().query(Browser.BOOKMARKS_URI, null, null, null, null);
+
+ // Cursor cursor = getContentResolver().query(Browser.SEARCHES_URI, null, null, null, null);
+
+ MyCursorAdapter myCursorAdapter = new MyCursorAdapter(this,cursor,0);
+ listView.setAdapter(myCursorAdapter);
+ }
+}
diff --git a/android-read-browser-bookmark/src/com/hmkcode/browser/bookmark/MyCursorAdapter.java b/android-read-browser-bookmark/src/com/hmkcode/browser/bookmark/MyCursorAdapter.java
new file mode 100644
index 00000000..de95771d
--- /dev/null
+++ b/android-read-browser-bookmark/src/com/hmkcode/browser/bookmark/MyCursorAdapter.java
@@ -0,0 +1,68 @@
+package com.hmkcode.browser.bookmark;
+
+import java.util.Date;
+
+import android.content.Context;
+import android.database.Cursor;
+import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
+import android.provider.Browser;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.CursorAdapter;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+public class MyCursorAdapter extends CursorAdapter {
+
+ private LayoutInflater cursorInflater;
+
+ // Default constructor
+ public MyCursorAdapter(Context context, Cursor cursor, int flags) {
+ super(context, cursor, flags);
+ cursorInflater = (LayoutInflater) context.getSystemService(
+ Context.LAYOUT_INFLATER_SERVICE);
+ }
+
+ @Override
+ public void bindView(View view, Context context, Cursor cursor) {
+
+ TextView tvDate = (TextView) view.findViewById(R.id.date);
+ TextView tvTitle = (TextView) view.findViewById(R.id.title);
+ TextView tvBoV = (TextView) view.findViewById(R.id.bov);
+ TextView tvURL = (TextView) view.findViewById(R.id.url);
+ ImageView ivFavicon = (ImageView) view.findViewById(R.id.favicon);
+
+ // long date = cursor.getLong(Browser.SEARCHES_PROJECTION_DATE_INDEX);
+ // String title = cursor.getString(Browser.SEARCHES_PROJECTION_SEARCH_INDEX);
+
+ long date = cursor.getLong(Browser.HISTORY_PROJECTION_DATE_INDEX);
+ String title = cursor.getString(Browser.HISTORY_PROJECTION_TITLE_INDEX);
+ String url = cursor.getString(Browser.HISTORY_PROJECTION_URL_INDEX);
+ byte[] icon = cursor.getBlob(Browser.HISTORY_PROJECTION_FAVICON_INDEX);
+ String bokmrk = cursor.getString(Browser.HISTORY_PROJECTION_BOOKMARK_INDEX);
+ String visits = cursor.getString(Browser.HISTORY_PROJECTION_VISITS_INDEX);
+ String id = cursor.getString(Browser.HISTORY_PROJECTION_ID_INDEX);
+
+ // String names[] = cursor.getColumnNames();
+
+
+ tvDate.setText(new Date(date).toString());
+ tvBoV.setText(bokmrk.equals("1")?"Bookmarked":"Visited");
+ tvTitle.setText(title);
+ tvURL.setText(url);
+ if(icon != null){
+ Bitmap bm = BitmapFactory.decodeByteArray(icon, 0, icon.length);
+ ivFavicon.setImageBitmap(bm);
+ }
+
+ }
+
+ @Override
+ public View newView(Context context, Cursor cursor, ViewGroup parent) {
+ return cursorInflater.inflate(R.layout.link, parent, false);
+ }
+
+
+}
\ No newline at end of file
diff --git a/android-recyclerview/README.md b/android-recyclerview/README.md
new file mode 100644
index 00000000..c0a10be3
--- /dev/null
+++ b/android-recyclerview/README.md
@@ -0,0 +1,35 @@
+Android | Create a List with RecyclerView
+=========================================
+
+- `app` written in Java
+- `app-kotlin` is the same as `app` but written in Kotlin
+
+
+
+
+
+
+Creating a scrollable list of elements is a common pattern in mobile application. Using RecyclerView we can list a large data sets or frequently changing one. `RecyclerView` is an advanced and flexible version of ListView, addressing serveral issues with existing listing views. Here we will build a simple application with `RecyclerView`
+
+## Overview
+
+We will build two versions of a simple app (one in Java and one in Kotlin) that displays a list of hard-coded instances of class `Link` in a `RecyclerView`. To display items on `RecyclerView` you need to the following:
+
+- `RecyclerView` widget added to the activity layout.
+- A class extending `RecyclerView.Adapter`.
+- A class extending `RecyclerView.ViewHolder`.
+- Layout for RecyclerView items.
+
+Files we need for this app are shown in the image below.
+
+
+
+
+Android | RecyclerView Using Support Library ListAdapter
+========================================================
+
+- `app-listadapter` building recyclerview with `ListAdapter`
+
+
+
+ListAdapter for RecyclerView has been introduced in Revision 27.1.0 Release of Support Library. ListAdapter uses DiffUtil under the hood to compute list diffs on a background thread. This will help RecyclerView animate changes automatically with less work on the UI thread.
\ No newline at end of file
diff --git a/android-recyclerview/app-kotlin/build.gradle b/android-recyclerview/app-kotlin/build.gradle
new file mode 100644
index 00000000..b63ef48c
--- /dev/null
+++ b/android-recyclerview/app-kotlin/build.gradle
@@ -0,0 +1,38 @@
+apply plugin: 'com.android.application'
+apply plugin: 'kotlin-android'
+apply plugin: 'kotlin-android-extensions'
+android {
+ compileSdkVersion 28
+
+
+
+ defaultConfig {
+ applicationId "com.hmkcode"
+ minSdkVersion 19
+ targetSdkVersion 28
+ versionCode 1
+ versionName "1.0"
+
+ testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
+
+ }
+
+ buildTypes {
+ release {
+ minifyEnabled false
+ proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
+ }
+ }
+
+}
+
+dependencies {
+ implementation fileTree(dir: 'libs', include: ['*.jar'])
+ implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
+ implementation 'com.android.support:appcompat-v7:28.0.0'
+ implementation 'com.android.support.constraint:constraint-layout:1.1.3'
+ implementation 'com.android.support:recyclerview-v7:28.0.0'
+ testImplementation 'junit:junit:4.12'
+ androidTestImplementation 'com.android.support.test:runner:1.0.2'
+ androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
+}
diff --git a/android-recyclerview/app-kotlin/src/main/AndroidManifest.xml b/android-recyclerview/app-kotlin/src/main/AndroidManifest.xml
new file mode 100644
index 00000000..5989688d
--- /dev/null
+++ b/android-recyclerview/app-kotlin/src/main/AndroidManifest.xml
@@ -0,0 +1,21 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/android-recyclerview/app-kotlin/src/main/java/com/hmkcode/activities/MainActivity.kt b/android-recyclerview/app-kotlin/src/main/java/com/hmkcode/activities/MainActivity.kt
new file mode 100644
index 00000000..7457002d
--- /dev/null
+++ b/android-recyclerview/app-kotlin/src/main/java/com/hmkcode/activities/MainActivity.kt
@@ -0,0 +1,55 @@
+package com.hmkcode.activities
+
+import android.support.v7.app.AppCompatActivity
+import android.os.Bundle
+import android.support.v7.widget.LinearLayoutManager
+import android.support.v7.widget.RecyclerView
+import com.hmkcode.R
+import com.hmkcode.adapters.MyAdapter
+import com.hmkcode.model.Link
+import java.util.*
+
+class MainActivity : AppCompatActivity() {
+
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ setContentView(R.layout.activity_main)
+
+ val recyclerView = findViewById(R.id.recyclerView)
+
+ // layout manager
+ val layoutManager:RecyclerView.LayoutManager = LinearLayoutManager(this)
+ recyclerView.layoutManager = layoutManager;
+
+ // adapter
+ val adapter:RecyclerView.Adapter = MyAdapter(getListData())
+ recyclerView.adapter = adapter;
+ }
+
+ //generate a list of Link
+ private fun getListData(): List {
+ val links = LinkedList()
+
+ var link = Link()
+ link.icon = R.drawable.ic_link;
+ link.title ="HMKCODE BLOG";
+ link.url = "hmkcode.com";
+
+ links.add(link)
+
+ link = Link()
+ link.icon = R.drawable.ic_twitter
+ link.title = "@HMKCODE"
+ link.url = "twitter.com/hmkcode"
+
+ links.add(link)
+
+ link = Link()
+ link.icon = R.drawable.ic_github
+ link.title = "HMKCODE"
+ link.url = "github.com/hmkcode"
+
+ links.add(link)
+ return links
+ }
+}
diff --git a/android-recyclerview/app-kotlin/src/main/java/com/hmkcode/adapters/MyAdapter.kt b/android-recyclerview/app-kotlin/src/main/java/com/hmkcode/adapters/MyAdapter.kt
new file mode 100644
index 00000000..a9607675
--- /dev/null
+++ b/android-recyclerview/app-kotlin/src/main/java/com/hmkcode/adapters/MyAdapter.kt
@@ -0,0 +1,42 @@
+package com.hmkcode.adapters
+
+import android.support.v7.widget.RecyclerView
+import android.view.LayoutInflater
+import android.view.View
+import android.view.ViewGroup
+import android.widget.ImageView
+import android.widget.TextView
+import com.hmkcode.R
+import com.hmkcode.model.Link
+
+class MyAdapter(private val links:List): RecyclerView.Adapter() {
+
+ override fun onCreateViewHolder(parent: ViewGroup, viewType: Int):
+ MyViewHolder {
+
+ val itemLayoutView:View = LayoutInflater.from(parent.context)
+ .inflate(R.layout.item_layout, null)
+
+ val vh:MyViewHolder = MyViewHolder(itemLayoutView)
+ return vh
+ }
+
+ override fun onBindViewHolder(holder: MyViewHolder, position: Int) {
+ holder.itemIcon.setImageResource(links[position].icon)
+ holder.itemTitle.text = links[position].title
+ holder.itemUrl.text = links[position].url
+ }
+
+ override fun getItemCount(): Int {
+ return links?.size ?: 0
+ }
+
+ class MyViewHolder(itemLayoutView: View)
+ : RecyclerView.ViewHolder(itemLayoutView) {
+
+ val itemTitle = itemLayoutView.findViewById(R.id.item_title)
+ val itemUrl = itemLayoutView.findViewById(R.id.item_url)
+ val itemIcon = itemLayoutView.findViewById(R.id.item_icon)
+
+ }
+}
\ No newline at end of file
diff --git a/android-recyclerview/app-kotlin/src/main/java/com/hmkcode/model/Link.kt b/android-recyclerview/app-kotlin/src/main/java/com/hmkcode/model/Link.kt
new file mode 100644
index 00000000..4a945118
--- /dev/null
+++ b/android-recyclerview/app-kotlin/src/main/java/com/hmkcode/model/Link.kt
@@ -0,0 +1,8 @@
+package com.hmkcode.model
+
+class Link {
+
+ var icon: Int = 0
+ var title: String? = null
+ var url: String? = null
+}
diff --git a/android-recyclerview/app-kotlin/src/main/res/drawable/ic_github.xml b/android-recyclerview/app-kotlin/src/main/res/drawable/ic_github.xml
new file mode 100644
index 00000000..215402e6
--- /dev/null
+++ b/android-recyclerview/app-kotlin/src/main/res/drawable/ic_github.xml
@@ -0,0 +1,4 @@
+
+
+
diff --git a/android-recyclerview/app-kotlin/src/main/res/drawable/ic_launcher_background.xml b/android-recyclerview/app-kotlin/src/main/res/drawable/ic_launcher_background.xml
new file mode 100644
index 00000000..d5fccc53
--- /dev/null
+++ b/android-recyclerview/app-kotlin/src/main/res/drawable/ic_launcher_background.xml
@@ -0,0 +1,170 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/android-recyclerview/app-kotlin/src/main/res/drawable/ic_link.xml b/android-recyclerview/app-kotlin/src/main/res/drawable/ic_link.xml
new file mode 100644
index 00000000..5aaa617e
--- /dev/null
+++ b/android-recyclerview/app-kotlin/src/main/res/drawable/ic_link.xml
@@ -0,0 +1,4 @@
+
+
+
diff --git a/android-recyclerview/app-kotlin/src/main/res/drawable/ic_twitter.xml b/android-recyclerview/app-kotlin/src/main/res/drawable/ic_twitter.xml
new file mode 100644
index 00000000..bba43aa1
--- /dev/null
+++ b/android-recyclerview/app-kotlin/src/main/res/drawable/ic_twitter.xml
@@ -0,0 +1,12 @@
+
+
+
diff --git a/android-recyclerview/app-kotlin/src/main/res/drawable/item_border.xml b/android-recyclerview/app-kotlin/src/main/res/drawable/item_border.xml
new file mode 100644
index 00000000..4e0c57fd
--- /dev/null
+++ b/android-recyclerview/app-kotlin/src/main/res/drawable/item_border.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/android-recyclerview/app-kotlin/src/main/res/layout/activity_main.xml b/android-recyclerview/app-kotlin/src/main/res/layout/activity_main.xml
new file mode 100644
index 00000000..125071a6
--- /dev/null
+++ b/android-recyclerview/app-kotlin/src/main/res/layout/activity_main.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/android-recyclerview/app-kotlin/src/main/res/layout/item_layout.xml b/android-recyclerview/app-kotlin/src/main/res/layout/item_layout.xml
new file mode 100644
index 00000000..43887153
--- /dev/null
+++ b/android-recyclerview/app-kotlin/src/main/res/layout/item_layout.xml
@@ -0,0 +1,61 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/android-recyclerview/app-listadapter/build.gradle b/android-recyclerview/app-listadapter/build.gradle
new file mode 100644
index 00000000..2d5114b1
--- /dev/null
+++ b/android-recyclerview/app-listadapter/build.gradle
@@ -0,0 +1,41 @@
+apply plugin: 'com.android.application'
+
+android {
+ compileSdkVersion 28
+
+
+
+ defaultConfig {
+ applicationId "com.hmkcode"
+ minSdkVersion 19
+ targetSdkVersion 28
+ versionCode 1
+ versionName "1.0"
+
+ testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
+
+ }
+
+ buildTypes {
+ release {
+ minifyEnabled false
+ proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
+ }
+ }
+
+ compileOptions {
+ targetCompatibility 1.8
+ sourceCompatibility 1.8
+ }
+}
+
+dependencies {
+ implementation fileTree(dir: 'libs', include: ['*.jar'])
+
+ implementation 'com.android.support:appcompat-v7:28.0.0'
+ implementation 'com.android.support.constraint:constraint-layout:1.1.3'
+ testImplementation 'junit:junit:4.12'
+ implementation 'com.android.support:recyclerview-v7:28.0.0'
+ androidTestImplementation 'com.android.support.test:runner:1.0.2'
+ androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
+}
diff --git a/android-recyclerview/app-listadapter/src/main/AndroidManifest.xml b/android-recyclerview/app-listadapter/src/main/AndroidManifest.xml
new file mode 100644
index 00000000..5989688d
--- /dev/null
+++ b/android-recyclerview/app-listadapter/src/main/AndroidManifest.xml
@@ -0,0 +1,21 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/android-recyclerview/app-listadapter/src/main/java/com/hmkcode/activities/MainActivity.java b/android-recyclerview/app-listadapter/src/main/java/com/hmkcode/activities/MainActivity.java
new file mode 100644
index 00000000..bcd2595d
--- /dev/null
+++ b/android-recyclerview/app-listadapter/src/main/java/com/hmkcode/activities/MainActivity.java
@@ -0,0 +1,75 @@
+package com.hmkcode.activities;
+
+import android.support.v7.app.AppCompatActivity;
+import android.os.Bundle;
+import android.support.v7.recyclerview.extensions.ListAdapter;
+import android.support.v7.widget.LinearLayoutManager;
+import android.support.v7.widget.RecyclerView;
+import com.hmkcode.R;
+import com.hmkcode.adapters.MyListAdapter;
+import com.hmkcode.models.Link;
+import com.hmkcode.utils.LinkDiffCallback;
+import java.util.LinkedList;
+import java.util.List;
+
+public class MainActivity extends AppCompatActivity {
+
+ private RecyclerView recyclerView;
+ private List links;
+ private ListAdapter listAdapter;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_main);
+ recyclerView = findViewById(R.id.recyclerView);
+
+ // layout manager
+ RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(this);
+ recyclerView.setLayoutManager(layoutManager);
+
+ recyclerView.setClickable(true);
+
+ // list adapter
+ links = getListData();
+
+ listAdapter = new MyListAdapter(new LinkDiffCallback(),
+ link -> updateList(link));
+ recyclerView.setAdapter(listAdapter);
+
+ listAdapter.submitList(getListData());
+
+ }
+
+ private void updateList(Link link){
+ boolean removed = links.remove(link);
+ listAdapter.submitList(new LinkedList(links));
+ }
+
+ //generate a list of Link
+ private List getListData(){
+ List links = new LinkedList();
+
+ Link link = new Link();
+ link.setIcon(R.drawable.ic_link);
+ link.setTitle("HMKCODE BLOG");
+ link.setUrl("hmkcode.com");
+
+ links.add(link);
+
+ link = new Link();
+ link.setIcon(R.drawable.ic_twitter);
+ link.setTitle("@HMKCODE");
+ link.setUrl("twitter.com/hmkcode");
+
+ links.add(link);
+
+ link = new Link();
+ link.setIcon(R.drawable.ic_github);
+ link.setTitle("HMKCODE");
+ link.setUrl("github.com/hmkcode");
+
+ links.add(link);
+ return links;
+ }
+}
diff --git a/android-recyclerview/app-listadapter/src/main/java/com/hmkcode/adapters/MyListAdapter.java b/android-recyclerview/app-listadapter/src/main/java/com/hmkcode/adapters/MyListAdapter.java
new file mode 100644
index 00000000..2d66c891
--- /dev/null
+++ b/android-recyclerview/app-listadapter/src/main/java/com/hmkcode/adapters/MyListAdapter.java
@@ -0,0 +1,65 @@
+package com.hmkcode.adapters;
+
+import android.support.annotation.NonNull;
+import android.support.v7.recyclerview.extensions.ListAdapter;
+import android.support.v7.util.DiffUtil;
+import android.support.v7.widget.RecyclerView;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ImageView;
+import android.widget.TextView;
+import com.hmkcode.R;
+import com.hmkcode.listeners.MyItemClickListener;
+import com.hmkcode.models.Link;
+
+public class MyListAdapter extends ListAdapter {
+
+ MyItemClickListener myItemClickListener;
+ public MyListAdapter(@NonNull DiffUtil.ItemCallback diffCallback,
+ MyItemClickListener myItemClickListener) {
+ super(diffCallback);
+ this.myItemClickListener = myItemClickListener;
+ }
+
+ @NonNull
+ @Override
+ public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
+ View itemLayoutView = LayoutInflater.from(parent.getContext())
+ .inflate(R.layout.item_layout, null);
+
+ return new MyViewHolder(itemLayoutView);
+ }
+
+ @Override
+ public void onBindViewHolder(@NonNull MyViewHolder myViewHolder, int position) {
+ myViewHolder.bind(getItem(position));
+ }
+
+ // inner class
+ public class MyViewHolder extends RecyclerView.ViewHolder {
+
+ private View itemLayoutView;
+ private TextView itemTitle;
+ private TextView itemUrl;
+ private ImageView itemIcon;
+
+ public MyViewHolder(View itemLayoutView) {
+ super(itemLayoutView);
+ this.itemLayoutView = itemLayoutView;
+ this.itemTitle = itemLayoutView.findViewById(R.id.item_title);
+ this.itemUrl = itemLayoutView.findViewById(R.id.item_url);
+ this.itemIcon = itemLayoutView.findViewById(R.id.item_icon);
+ }
+ public void bind(Link link){
+ this.itemIcon.setImageResource(link.getIcon());
+ this.itemTitle.setText(link.getTitle());
+ this.itemUrl.setText(link.getUrl());
+
+ this.itemLayoutView.setOnClickListener(
+ v -> myItemClickListener.onClick(link));
+
+ }
+
+ }
+}
diff --git a/android-recyclerview/app-listadapter/src/main/java/com/hmkcode/listeners/MyItemClickListener.java b/android-recyclerview/app-listadapter/src/main/java/com/hmkcode/listeners/MyItemClickListener.java
new file mode 100644
index 00000000..fdcc07bb
--- /dev/null
+++ b/android-recyclerview/app-listadapter/src/main/java/com/hmkcode/listeners/MyItemClickListener.java
@@ -0,0 +1,8 @@
+package com.hmkcode.listeners;
+
+import com.hmkcode.models.Link;
+
+@FunctionalInterface
+public interface MyItemClickListener {
+ public void onClick(Link link);
+}
diff --git a/android-recyclerview/app-listadapter/src/main/java/com/hmkcode/models/Link.java b/android-recyclerview/app-listadapter/src/main/java/com/hmkcode/models/Link.java
new file mode 100644
index 00000000..8b46d7cb
--- /dev/null
+++ b/android-recyclerview/app-listadapter/src/main/java/com/hmkcode/models/Link.java
@@ -0,0 +1,46 @@
+package com.hmkcode.models;
+
+public class Link {
+
+ private int icon;
+ private String title;
+ private String url;
+
+ public int getIcon() {
+ return icon;
+ }
+
+ public void setIcon(int icon) {
+ this.icon = icon;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public String getUrl() {
+ return url;
+ }
+
+ public void setUrl(String url) {
+ this.url = url;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ return this.getUrl().equals(((Link)obj).getUrl());
+ }
+
+ @Override
+ public String toString() {
+ return "Link{" +
+ "icon=" + icon +
+ ", title='" + title + '\'' +
+ ", url='" + url + '\'' +
+ '}';
+ }
+}
diff --git a/android-recyclerview/app-listadapter/src/main/java/com/hmkcode/utils/LinkDiffCallback.java b/android-recyclerview/app-listadapter/src/main/java/com/hmkcode/utils/LinkDiffCallback.java
new file mode 100644
index 00000000..e886752e
--- /dev/null
+++ b/android-recyclerview/app-listadapter/src/main/java/com/hmkcode/utils/LinkDiffCallback.java
@@ -0,0 +1,16 @@
+package com.hmkcode.utils;
+
+import android.support.v7.util.DiffUtil;
+import com.hmkcode.models.Link;
+
+public class LinkDiffCallback extends DiffUtil.ItemCallback {
+ @Override
+ public boolean areItemsTheSame(Link oldItem, Link newItem) {
+ return oldItem.getUrl().equals(newItem.getUrl());
+ }
+
+ @Override
+ public boolean areContentsTheSame(Link oldItem, Link newItem) {
+ return oldItem.getUrl().equals(newItem.getUrl());
+ }
+}
diff --git a/android-recyclerview/app-listadapter/src/main/res/drawable/ic_github.xml b/android-recyclerview/app-listadapter/src/main/res/drawable/ic_github.xml
new file mode 100644
index 00000000..215402e6
--- /dev/null
+++ b/android-recyclerview/app-listadapter/src/main/res/drawable/ic_github.xml
@@ -0,0 +1,4 @@
+
+
+
diff --git a/android-recyclerview/app-listadapter/src/main/res/drawable/ic_launcher_background.xml b/android-recyclerview/app-listadapter/src/main/res/drawable/ic_launcher_background.xml
new file mode 100644
index 00000000..d5fccc53
--- /dev/null
+++ b/android-recyclerview/app-listadapter/src/main/res/drawable/ic_launcher_background.xml
@@ -0,0 +1,170 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/android-recyclerview/app-listadapter/src/main/res/drawable/ic_link.xml b/android-recyclerview/app-listadapter/src/main/res/drawable/ic_link.xml
new file mode 100644
index 00000000..5aaa617e
--- /dev/null
+++ b/android-recyclerview/app-listadapter/src/main/res/drawable/ic_link.xml
@@ -0,0 +1,4 @@
+
+
+
diff --git a/android-recyclerview/app-listadapter/src/main/res/drawable/ic_twitter.xml b/android-recyclerview/app-listadapter/src/main/res/drawable/ic_twitter.xml
new file mode 100644
index 00000000..bba43aa1
--- /dev/null
+++ b/android-recyclerview/app-listadapter/src/main/res/drawable/ic_twitter.xml
@@ -0,0 +1,12 @@
+
+
+
diff --git a/android-recyclerview/app-listadapter/src/main/res/drawable/item_border.xml b/android-recyclerview/app-listadapter/src/main/res/drawable/item_border.xml
new file mode 100644
index 00000000..4e0c57fd
--- /dev/null
+++ b/android-recyclerview/app-listadapter/src/main/res/drawable/item_border.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/android-recyclerview/app-listadapter/src/main/res/layout/activity_main.xml b/android-recyclerview/app-listadapter/src/main/res/layout/activity_main.xml
new file mode 100644
index 00000000..125071a6
--- /dev/null
+++ b/android-recyclerview/app-listadapter/src/main/res/layout/activity_main.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/android-recyclerview/app-listadapter/src/main/res/layout/item_layout.xml b/android-recyclerview/app-listadapter/src/main/res/layout/item_layout.xml
new file mode 100644
index 00000000..43887153
--- /dev/null
+++ b/android-recyclerview/app-listadapter/src/main/res/layout/item_layout.xml
@@ -0,0 +1,61 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/android-recyclerview/app/build.gradle b/android-recyclerview/app/build.gradle
new file mode 100644
index 00000000..df9717c5
--- /dev/null
+++ b/android-recyclerview/app/build.gradle
@@ -0,0 +1,34 @@
+apply plugin: 'com.android.application'
+
+apply plugin: 'kotlin-android'
+
+apply plugin: 'kotlin-android-extensions'
+
+android {
+ compileSdkVersion 28
+ defaultConfig {
+ applicationId "com.hmkcode"
+ minSdkVersion 19
+ targetSdkVersion 28
+ versionCode 1
+ versionName "1.0"
+ testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
+ }
+ buildTypes {
+ release {
+ minifyEnabled false
+ proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
+ }
+ }
+}
+
+dependencies {
+ implementation fileTree(dir: 'libs', include: ['*.jar'])
+ implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
+ implementation 'com.android.support:appcompat-v7:28.0.0'
+ implementation 'com.android.support.constraint:constraint-layout:1.1.3'
+ implementation 'com.android.support:recyclerview-v7:28.0.0'
+ testImplementation 'junit:junit:4.12'
+ androidTestImplementation 'com.android.support.test:runner:1.0.2'
+ androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
+}
diff --git a/android-recyclerview/app/src/main/AndroidManifest.xml b/android-recyclerview/app/src/main/AndroidManifest.xml
new file mode 100644
index 00000000..e38c44b9
--- /dev/null
+++ b/android-recyclerview/app/src/main/AndroidManifest.xml
@@ -0,0 +1,22 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/android-recyclerview/app/src/main/java/com/hmkcode/activities/MainActivity.java b/android-recyclerview/app/src/main/java/com/hmkcode/activities/MainActivity.java
new file mode 100644
index 00000000..809da5fc
--- /dev/null
+++ b/android-recyclerview/app/src/main/java/com/hmkcode/activities/MainActivity.java
@@ -0,0 +1,59 @@
+package com.hmkcode.activities;
+
+import android.support.v7.app.AppCompatActivity;
+import android.os.Bundle;
+import android.support.v7.widget.LinearLayoutManager;
+import android.support.v7.widget.RecyclerView;
+import com.hmkcode.R;
+import com.hmkcode.adapters.MyAdapter;
+import com.hmkcode.model.Link;
+
+import java.util.LinkedList;
+import java.util.List;
+
+public class MainActivity extends AppCompatActivity {
+
+ private RecyclerView recyclerView;
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_main);
+ recyclerView = findViewById(R.id.recyclerView);
+
+ // layout manager
+ RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(this);
+ recyclerView.setLayoutManager(layoutManager);
+
+ // adapter
+ RecyclerView.Adapter adapter = new MyAdapter(getListData());
+ recyclerView.setAdapter(adapter);
+
+ }
+
+ //generate a list of Link
+ private static List getListData(){
+ List links = new LinkedList();
+
+ Link link = new Link();
+ link.setIcon(R.drawable.ic_link);
+ link.setTitle("HMKCODE BLOG");
+ link.setUrl("hmkcode.com");
+
+ links.add(link);
+
+ link = new Link();
+ link.setIcon(R.drawable.ic_twitter);
+ link.setTitle("@HMKCODE");
+ link.setUrl("twitter.com/hmkcode");
+
+ links.add(link);
+
+ link = new Link();
+ link.setIcon(R.drawable.ic_github);
+ link.setTitle("HMKCODE");
+ link.setUrl("github.com/hmkcode");
+
+ links.add(link);
+ return links;
+ }
+}
diff --git a/android-recyclerview/app/src/main/java/com/hmkcode/adapters/MyAdapter.java b/android-recyclerview/app/src/main/java/com/hmkcode/adapters/MyAdapter.java
new file mode 100644
index 00000000..7fee528f
--- /dev/null
+++ b/android-recyclerview/app/src/main/java/com/hmkcode/adapters/MyAdapter.java
@@ -0,0 +1,66 @@
+package com.hmkcode.adapters;
+
+import android.support.annotation.NonNull;
+import android.support.v7.widget.RecyclerView;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+import com.hmkcode.R;
+import com.hmkcode.model.Link;
+
+import java.util.List;
+
+public class MyAdapter extends RecyclerView.Adapter {
+
+ private List links;
+
+ // constructor
+ public MyAdapter(List links){
+ this.links = links;
+ }
+
+ @NonNull
+ @Override
+ public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
+
+ // inflate item_layout
+ View itemLayoutView = LayoutInflater.from(parent.getContext())
+ .inflate(R.layout.item_layout, null);
+
+ MyViewHolder vh = new MyViewHolder(itemLayoutView);
+ return vh;
+ }
+
+ @Override
+ public void onBindViewHolder(@NonNull MyViewHolder holder, int position) {
+ holder.itemIcon.setImageResource(links.get(position).getIcon());
+ holder.itemTitle.setText(links.get(position).getTitle());
+ holder.itemUrl.setText(links.get(position).getUrl());
+ }
+
+ @Override
+ public int getItemCount() {
+ if(links != null)
+ return links.size();
+ else
+ return 0;
+ }
+
+ // inner static class
+ public static class MyViewHolder extends RecyclerView.ViewHolder {
+
+ public TextView itemTitle;
+ public TextView itemUrl;
+ public ImageView itemIcon;
+
+ public MyViewHolder(View itemLayoutView) {
+ super(itemLayoutView);
+ itemTitle = itemLayoutView.findViewById(R.id.item_title);
+ itemUrl = itemLayoutView.findViewById(R.id.item_url);
+ itemIcon = itemLayoutView.findViewById(R.id.item_icon);
+ }
+ }
+}
diff --git a/android-recyclerview/app/src/main/java/com/hmkcode/model/Link.java b/android-recyclerview/app/src/main/java/com/hmkcode/model/Link.java
new file mode 100644
index 00000000..c1251ee1
--- /dev/null
+++ b/android-recyclerview/app/src/main/java/com/hmkcode/model/Link.java
@@ -0,0 +1,32 @@
+package com.hmkcode.model;
+
+public class Link {
+
+ private int icon;
+ private String title;
+ private String url;
+
+ public int getIcon() {
+ return icon;
+ }
+
+ public void setIcon(int icon) {
+ this.icon = icon;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public String getUrl() {
+ return url;
+ }
+
+ public void setUrl(String url) {
+ this.url = url;
+ }
+}
diff --git a/android-recyclerview/app/src/main/res/drawable/ic_github.xml b/android-recyclerview/app/src/main/res/drawable/ic_github.xml
new file mode 100644
index 00000000..215402e6
--- /dev/null
+++ b/android-recyclerview/app/src/main/res/drawable/ic_github.xml
@@ -0,0 +1,4 @@
+
+
+
diff --git a/android-recyclerview/app/src/main/res/drawable/ic_launcher_background.xml b/android-recyclerview/app/src/main/res/drawable/ic_launcher_background.xml
new file mode 100644
index 00000000..d5fccc53
--- /dev/null
+++ b/android-recyclerview/app/src/main/res/drawable/ic_launcher_background.xml
@@ -0,0 +1,170 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/android-recyclerview/app/src/main/res/drawable/ic_link.xml b/android-recyclerview/app/src/main/res/drawable/ic_link.xml
new file mode 100644
index 00000000..5aaa617e
--- /dev/null
+++ b/android-recyclerview/app/src/main/res/drawable/ic_link.xml
@@ -0,0 +1,4 @@
+
+
+
diff --git a/android-recyclerview/app/src/main/res/drawable/ic_twitter.xml b/android-recyclerview/app/src/main/res/drawable/ic_twitter.xml
new file mode 100644
index 00000000..bba43aa1
--- /dev/null
+++ b/android-recyclerview/app/src/main/res/drawable/ic_twitter.xml
@@ -0,0 +1,12 @@
+
+
+
diff --git a/android-recyclerview/app/src/main/res/drawable/item_border.xml b/android-recyclerview/app/src/main/res/drawable/item_border.xml
new file mode 100644
index 00000000..4e0c57fd
--- /dev/null
+++ b/android-recyclerview/app/src/main/res/drawable/item_border.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/android-recyclerview/app/src/main/res/layout/activity_main.xml b/android-recyclerview/app/src/main/res/layout/activity_main.xml
new file mode 100644
index 00000000..125071a6
--- /dev/null
+++ b/android-recyclerview/app/src/main/res/layout/activity_main.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/android-recyclerview/app/src/main/res/layout/item_layout.xml b/android-recyclerview/app/src/main/res/layout/item_layout.xml
new file mode 100644
index 00000000..065094f9
--- /dev/null
+++ b/android-recyclerview/app/src/main/res/layout/item_layout.xml
@@ -0,0 +1,60 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/android-recyclerview/build.gradle b/android-recyclerview/build.gradle
new file mode 100644
index 00000000..98e76df1
--- /dev/null
+++ b/android-recyclerview/build.gradle
@@ -0,0 +1,27 @@
+// Top-level build file where you can add configuration options common to all sub-projects/modules.
+
+buildscript {
+ ext.kotlin_version = '1.2.61'
+ repositories {
+ google()
+ jcenter()
+ }
+ dependencies {
+ classpath 'com.android.tools.build:gradle:3.1.4'
+ classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
+
+ // NOTE: Do not place your application dependencies here; they belong
+ // in the individual module build.gradle files
+ }
+}
+
+allprojects {
+ repositories {
+ google()
+ jcenter()
+ }
+}
+
+task clean(type: Delete) {
+ delete rootProject.buildDir
+}
diff --git a/android-recyclerview/gradle/wrapper/gradle-wrapper.jar b/android-recyclerview/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 00000000..7a3265ee
Binary files /dev/null and b/android-recyclerview/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/android-recyclerview/gradle/wrapper/gradle-wrapper.properties b/android-recyclerview/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 00000000..06c482a8
--- /dev/null
+++ b/android-recyclerview/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,6 @@
+#Thu Aug 23 09:48:09 GMT+03:00 2018
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
diff --git a/android-recyclerview/settings.gradle b/android-recyclerview/settings.gradle
new file mode 100644
index 00000000..e7b4def4
--- /dev/null
+++ b/android-recyclerview/settings.gradle
@@ -0,0 +1 @@
+include ':app'
diff --git a/android-post-json/AndroidManifest.xml b/android-show-image-and-path/AndroidManifest.xml
similarity index 71%
rename from android-post-json/AndroidManifest.xml
rename to android-show-image-and-path/AndroidManifest.xml
index fed38ced..2bcbf097 100644
--- a/android-post-json/AndroidManifest.xml
+++ b/android-show-image-and-path/AndroidManifest.xml
@@ -1,15 +1,13 @@
-
-
-
+ android:targetSdkVersion="19" />
+
diff --git a/android-show-image-and-path/libs/android-support-v4.jar b/android-show-image-and-path/libs/android-support-v4.jar
new file mode 100644
index 00000000..c31cede4
Binary files /dev/null and b/android-show-image-and-path/libs/android-support-v4.jar differ
diff --git a/android-show-image-and-path/res/layout/activity_main.xml b/android-show-image-and-path/res/layout/activity_main.xml
new file mode 100644
index 00000000..73f12c85
--- /dev/null
+++ b/android-show-image-and-path/res/layout/activity_main.xml
@@ -0,0 +1,48 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/android-show-image-and-path/src/com/hmkcode/android/image/MainActivity.java b/android-show-image-and-path/src/com/hmkcode/android/image/MainActivity.java
new file mode 100644
index 00000000..5e453f98
--- /dev/null
+++ b/android-show-image-and-path/src/com/hmkcode/android/image/MainActivity.java
@@ -0,0 +1,106 @@
+package com.hmkcode.android.image;
+
+
+import java.io.File;
+import java.io.FileNotFoundException;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
+import android.net.Uri;
+import android.os.Build;
+import android.os.Bundle;
+import android.util.Log;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.widget.Button;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+public class MainActivity extends Activity implements OnClickListener {
+
+ TextView txtSDK;
+ Button btnSelectImage;
+ TextView txtUriPath,txtRealPath;
+ ImageView imageView;
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_main);
+
+ // get reference to views
+ txtSDK = (TextView) findViewById(R.id.txtSDK);
+ btnSelectImage = (Button) findViewById(R.id.btnSelectImage);
+ txtUriPath = (TextView) findViewById(R.id.txtUriPath);
+ txtRealPath = (TextView) findViewById(R.id.txtRealPath);
+ imageView = (ImageView) findViewById(R.id.imgView);
+
+ // add click listener to button
+ btnSelectImage.setOnClickListener(this);
+
+
+ }
+
+ @Override
+ public void onClick(View view) {
+
+ // 1. on Upload click call ACTION_GET_CONTENT intent
+ Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
+ // 2. pick image only
+ intent.setType("image/*");
+ // 3. start activity
+ startActivityForResult(intent, 0);
+
+ // define onActivityResult to do something with picked image
+ }
+
+
+ @Override
+ protected void onActivityResult(int reqCode, int resCode, Intent data) {
+ if(resCode == Activity.RESULT_OK && data != null){
+ String realPath;
+ // SDK < API11
+ if (Build.VERSION.SDK_INT < 11)
+ realPath = RealPathUtil.getRealPathFromURI_BelowAPI11(this, data.getData());
+
+ // SDK >= 11 && SDK < 19
+ else if (Build.VERSION.SDK_INT < 19)
+ realPath = RealPathUtil.getRealPathFromURI_API11to18(this, data.getData());
+
+ // SDK > 19 (Android 4.4)
+ else
+ realPath = RealPathUtil.getRealPathFromURI_API19(this, data.getData());
+
+
+ setTextViews(Build.VERSION.SDK_INT, data.getData().getPath(),realPath);
+ }
+ }
+
+ private void setTextViews(int sdk, String uriPath,String realPath){
+
+ this.txtSDK.setText("Build.VERSION.SDK_INT: "+sdk);
+ this.txtUriPath.setText("URI Path: "+uriPath);
+ this.txtRealPath.setText("Real Path: "+realPath);
+
+ Uri uriFromPath = Uri.fromFile(new File(realPath));
+
+ // you have two ways to display selected image
+
+ // ( 1 ) imageView.setImageURI(uriFromPath);
+
+ // ( 2 ) imageView.setImageBitmap(bitmap);
+ Bitmap bitmap = null;
+ try {
+ bitmap = BitmapFactory.decodeStream(getContentResolver().openInputStream(uriFromPath));
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ }
+ imageView.setImageBitmap(bitmap);
+
+ Log.d("HMKCODE", "Build.VERSION.SDK_INT:"+sdk);
+ Log.d("HMKCODE", "URI Path:"+uriPath);
+ Log.d("HMKCODE", "Real Path: "+realPath);
+ }
+
+}
diff --git a/android-show-image-and-path/src/com/hmkcode/android/image/RealPathUtil.java b/android-show-image-and-path/src/com/hmkcode/android/image/RealPathUtil.java
new file mode 100644
index 00000000..c52c8f0d
--- /dev/null
+++ b/android-show-image-and-path/src/com/hmkcode/android/image/RealPathUtil.java
@@ -0,0 +1,69 @@
+package com.hmkcode.android.image;
+
+import android.annotation.SuppressLint;
+import android.content.Context;
+import android.content.CursorLoader;
+import android.database.Cursor;
+import android.net.Uri;
+import android.provider.DocumentsContract;
+import android.provider.MediaStore;
+
+public class RealPathUtil {
+
+ @SuppressLint("NewApi")
+ public static String getRealPathFromURI_API19(Context context, Uri uri){
+ String filePath = "";
+ String wholeID = DocumentsContract.getDocumentId(uri);
+
+ // Split at colon, use second item in the array
+ String id = wholeID.split(":")[1];
+
+ String[] column = { MediaStore.Images.Media.DATA };
+
+ // where id is equal to
+ String sel = MediaStore.Images.Media._ID + "=?";
+
+ Cursor cursor = context.getContentResolver().query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
+ column, sel, new String[]{ id }, null);
+
+ int columnIndex = cursor.getColumnIndex(column[0]);
+
+ if (cursor.moveToFirst()) {
+ filePath = cursor.getString(columnIndex);
+ }
+
+ cursor.close();
+
+ return filePath;
+ }
+
+
+ @SuppressLint("NewApi")
+ public static String getRealPathFromURI_API11to18(Context context, Uri contentUri) {
+ String[] proj = { MediaStore.Images.Media.DATA };
+ String result = null;
+
+ CursorLoader cursorLoader = new CursorLoader(
+ context,
+ contentUri, proj, null, null, null);
+ Cursor cursor = cursorLoader.loadInBackground();
+
+ if(cursor != null){
+ int column_index =
+ cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
+ cursor.moveToFirst();
+ result = cursor.getString(column_index);
+ }
+
+ return result;
+ }
+
+ public static String getRealPathFromURI_BelowAPI11(Context context, Uri contentUri){
+ String[] proj = { MediaStore.Images.Media.DATA };
+ Cursor cursor = context.getContentResolver().query(contentUri, proj, null, null, null);
+ int column_index
+ = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
+ cursor.moveToFirst();
+ return cursor.getString(column_index);
+ }
+}
diff --git a/android-sign-in-up-screen/AndroidManifest.xml b/android-sign-in-up-screen/AndroidManifest.xml
new file mode 100644
index 00000000..03b2401d
--- /dev/null
+++ b/android-sign-in-up-screen/AndroidManifest.xml
@@ -0,0 +1,48 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/android-sign-in-up-screen/res/drawable-hdpi/balloon_bg.png b/android-sign-in-up-screen/res/drawable-hdpi/balloon_bg.png
new file mode 100644
index 00000000..844b4fa3
Binary files /dev/null and b/android-sign-in-up-screen/res/drawable-hdpi/balloon_bg.png differ
diff --git a/android-sign-in-up-screen/res/drawable-hdpi/button_default_bg.xml b/android-sign-in-up-screen/res/drawable-hdpi/button_default_bg.xml
new file mode 100644
index 00000000..27869eaa
--- /dev/null
+++ b/android-sign-in-up-screen/res/drawable-hdpi/button_default_bg.xml
@@ -0,0 +1,29 @@
+
+
+ -
+
+
+
+
+
+
+
+ -
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/android-sign-in-up-screen/res/drawable-hdpi/edittext_bottom_bg.xml b/android-sign-in-up-screen/res/drawable-hdpi/edittext_bottom_bg.xml
new file mode 100644
index 00000000..4a2dff32
--- /dev/null
+++ b/android-sign-in-up-screen/res/drawable-hdpi/edittext_bottom_bg.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
diff --git a/android-sign-in-up-screen/res/drawable-hdpi/edittext_default_bg.xml b/android-sign-in-up-screen/res/drawable-hdpi/edittext_default_bg.xml
new file mode 100644
index 00000000..36cf4f45
--- /dev/null
+++ b/android-sign-in-up-screen/res/drawable-hdpi/edittext_default_bg.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
diff --git a/android-sign-in-up-screen/res/drawable-hdpi/edittext_top_bg.xml b/android-sign-in-up-screen/res/drawable-hdpi/edittext_top_bg.xml
new file mode 100644
index 00000000..513ccd60
--- /dev/null
+++ b/android-sign-in-up-screen/res/drawable-hdpi/edittext_top_bg.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
diff --git a/android-sign-in-up-screen/res/drawable-hdpi/email.png b/android-sign-in-up-screen/res/drawable-hdpi/email.png
new file mode 100644
index 00000000..d821bc93
Binary files /dev/null and b/android-sign-in-up-screen/res/drawable-hdpi/email.png differ
diff --git a/android-sign-in-up-screen/res/drawable-hdpi/ic_launcher.png b/android-sign-in-up-screen/res/drawable-hdpi/ic_launcher.png
new file mode 100644
index 00000000..288b6655
Binary files /dev/null and b/android-sign-in-up-screen/res/drawable-hdpi/ic_launcher.png differ
diff --git a/android-sign-in-up-screen/res/drawable-hdpi/linearlayout_bg.xml b/android-sign-in-up-screen/res/drawable-hdpi/linearlayout_bg.xml
new file mode 100644
index 00000000..2109251a
--- /dev/null
+++ b/android-sign-in-up-screen/res/drawable-hdpi/linearlayout_bg.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
diff --git a/android-sign-in-up-screen/res/drawable-hdpi/password.png b/android-sign-in-up-screen/res/drawable-hdpi/password.png
new file mode 100644
index 00000000..58689b43
Binary files /dev/null and b/android-sign-in-up-screen/res/drawable-hdpi/password.png differ
diff --git a/android-sign-in-up-screen/res/drawable-hdpi/user.png b/android-sign-in-up-screen/res/drawable-hdpi/user.png
new file mode 100644
index 00000000..7b64886f
Binary files /dev/null and b/android-sign-in-up-screen/res/drawable-hdpi/user.png differ
diff --git a/android-sign-in-up-screen/res/layout/activity_main.xml b/android-sign-in-up-screen/res/layout/activity_main.xml
new file mode 100644
index 00000000..0130d133
--- /dev/null
+++ b/android-sign-in-up-screen/res/layout/activity_main.xml
@@ -0,0 +1,44 @@
+
+
+
+
+
+
+
+
+
diff --git a/android-sign-in-up-screen/res/layout/activity_sign_in_screen.xml b/android-sign-in-up-screen/res/layout/activity_sign_in_screen.xml
new file mode 100644
index 00000000..8081518c
--- /dev/null
+++ b/android-sign-in-up-screen/res/layout/activity_sign_in_screen.xml
@@ -0,0 +1,54 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/android-sign-in-up-screen/res/layout/activity_sign_up_screen.xml b/android-sign-in-up-screen/res/layout/activity_sign_up_screen.xml
new file mode 100644
index 00000000..347473fe
--- /dev/null
+++ b/android-sign-in-up-screen/res/layout/activity_sign_up_screen.xml
@@ -0,0 +1,64 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/android-sign-in-up-screen/res/menu/main.xml b/android-sign-in-up-screen/res/menu/main.xml
new file mode 100644
index 00000000..c0020282
--- /dev/null
+++ b/android-sign-in-up-screen/res/menu/main.xml
@@ -0,0 +1,9 @@
+
diff --git a/android-sign-in-up-screen/res/values/dimens.xml b/android-sign-in-up-screen/res/values/dimens.xml
new file mode 100644
index 00000000..55c1e590
--- /dev/null
+++ b/android-sign-in-up-screen/res/values/dimens.xml
@@ -0,0 +1,7 @@
+
+
+
+ 16dp
+ 16dp
+
+
diff --git a/android-sign-in-up-screen/res/values/strings.xml b/android-sign-in-up-screen/res/values/strings.xml
new file mode 100644
index 00000000..7e77bb94
--- /dev/null
+++ b/android-sign-in-up-screen/res/values/strings.xml
@@ -0,0 +1,21 @@
+
+
+
+ Sign In&Up
+ Settings
+ Hello world!
+
+
+
diff --git a/android-sign-in-up-screen/res/values/styles.xml b/android-sign-in-up-screen/res/values/styles.xml
new file mode 100644
index 00000000..6ce89c7b
--- /dev/null
+++ b/android-sign-in-up-screen/res/values/styles.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
diff --git a/android-sign-in-up-screen/src/com/hmkcode/android/sign/MainActivity.java b/android-sign-in-up-screen/src/com/hmkcode/android/sign/MainActivity.java
new file mode 100644
index 00000000..995fbfab
--- /dev/null
+++ b/android-sign-in-up-screen/src/com/hmkcode/android/sign/MainActivity.java
@@ -0,0 +1,42 @@
+package com.hmkcode.android.sign;
+
+import android.os.Bundle;
+import android.app.Activity;
+import android.content.Intent;
+import android.view.Menu;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.widget.Button;
+
+public class MainActivity extends Activity implements OnClickListener {
+
+ Button btnSignIn;
+ Button btnSignUp;
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_main);
+
+ btnSignIn = (Button) findViewById(R.id.btnSingIn);
+ btnSignUp = (Button) findViewById(R.id.btnSignUp);
+
+ btnSignIn.setOnClickListener(this);
+ btnSignUp.setOnClickListener(this);
+ }
+ @Override
+ public void onClick(View v) {
+ Intent i = null;
+ switch(v.getId()){
+ case R.id.btnSingIn:
+ i = new Intent(this,SignInActivity.class);
+ break;
+ case R.id.btnSignUp:
+ i = new Intent(this,SignUpActivity.class);
+ break;
+ }
+ startActivity(i);
+ }
+
+
+
+}
diff --git a/android-sign-in-up-screen/src/com/hmkcode/android/sign/SignInActivity.java b/android-sign-in-up-screen/src/com/hmkcode/android/sign/SignInActivity.java
new file mode 100644
index 00000000..3cbe89d0
--- /dev/null
+++ b/android-sign-in-up-screen/src/com/hmkcode/android/sign/SignInActivity.java
@@ -0,0 +1,16 @@
+package com.hmkcode.android.sign;
+
+import android.os.Bundle;
+import android.app.Activity;
+
+public class SignInActivity extends Activity {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_sign_in_screen);
+ }
+
+
+
+}
diff --git a/android-sign-in-up-screen/src/com/hmkcode/android/sign/SignUpActivity.java b/android-sign-in-up-screen/src/com/hmkcode/android/sign/SignUpActivity.java
new file mode 100644
index 00000000..1ea30c9c
--- /dev/null
+++ b/android-sign-in-up-screen/src/com/hmkcode/android/sign/SignUpActivity.java
@@ -0,0 +1,17 @@
+package com.hmkcode.android.sign;
+
+import android.os.Bundle;
+import android.app.Activity;
+import android.view.Menu;
+
+public class SignUpActivity extends Activity {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_sign_up_screen);
+ }
+
+
+
+}
diff --git a/android-swipe-views-tabs/app/build.gradle b/android-swipe-views-tabs/app/build.gradle
new file mode 100644
index 00000000..5e6d9469
--- /dev/null
+++ b/android-swipe-views-tabs/app/build.gradle
@@ -0,0 +1,34 @@
+apply plugin: 'com.android.application'
+
+apply plugin: 'kotlin-android'
+
+apply plugin: 'kotlin-android-extensions'
+
+android {
+ compileSdkVersion 27
+ defaultConfig {
+ applicationId "com.hmkcode"
+ minSdkVersion 19
+ targetSdkVersion 27
+ versionCode 1
+ versionName "1.0"
+ testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
+ }
+ buildTypes {
+ release {
+ minifyEnabled false
+ proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
+ }
+ }
+}
+
+dependencies {
+ implementation fileTree(dir: 'libs', include: ['*.jar'])
+ implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
+ implementation 'com.android.support:appcompat-v7:27.1.1'
+ implementation 'com.android.support.constraint:constraint-layout:1.1.3'
+ implementation 'com.android.support:design:27.1.1'
+ testImplementation 'junit:junit:4.12'
+ androidTestImplementation 'com.android.support.test:runner:1.0.2'
+ androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
+}
diff --git a/android-swipe-views-tabs/app/src/main/AndroidManifest.xml b/android-swipe-views-tabs/app/src/main/AndroidManifest.xml
new file mode 100644
index 00000000..c487a518
--- /dev/null
+++ b/android-swipe-views-tabs/app/src/main/AndroidManifest.xml
@@ -0,0 +1,21 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/android-swipe-views-tabs/app/src/main/java/com/hmkcode/MainActivity.java b/android-swipe-views-tabs/app/src/main/java/com/hmkcode/MainActivity.java
new file mode 100644
index 00000000..8245bd2a
--- /dev/null
+++ b/android-swipe-views-tabs/app/src/main/java/com/hmkcode/MainActivity.java
@@ -0,0 +1,42 @@
+package com.hmkcode;
+
+import android.support.design.widget.TabLayout;
+import android.support.v4.view.ViewPager;
+import android.os.Bundle;
+import android.support.v7.app.AppCompatActivity;
+
+import com.hmkcode.adapters.MyFragmentPagerAdapter;
+
+public class MainActivity extends AppCompatActivity {
+
+ MyFragmentPagerAdapter myFragmentPagerAdapter;
+ ViewPager viewPager;
+ TabLayout tabLayout;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_main);
+
+
+ viewPager = (ViewPager) findViewById(R.id.viewPager);
+ tabLayout = (TabLayout) findViewById(R.id.tabLayout);
+
+ setPagerAdapter();
+ setTabLayout();
+
+ }
+
+ private void setPagerAdapter(){
+ myFragmentPagerAdapter = new MyFragmentPagerAdapter(getSupportFragmentManager());
+ viewPager.setAdapter(myFragmentPagerAdapter);
+ }
+
+ private void setTabLayout() {
+ tabLayout.setupWithViewPager(viewPager);
+
+ tabLayout.getTabAt(0).setText("First");
+ tabLayout.getTabAt(1).setText("Second");
+ }
+}
diff --git a/android-swipe-views-tabs/app/src/main/java/com/hmkcode/adapters/MyFragmentPagerAdapter.java b/android-swipe-views-tabs/app/src/main/java/com/hmkcode/adapters/MyFragmentPagerAdapter.java
new file mode 100644
index 00000000..1747c3b8
--- /dev/null
+++ b/android-swipe-views-tabs/app/src/main/java/com/hmkcode/adapters/MyFragmentPagerAdapter.java
@@ -0,0 +1,32 @@
+package com.hmkcode.adapters;
+
+import android.support.v4.app.Fragment;
+import android.support.v4.app.FragmentManager;
+import android.support.v4.app.FragmentPagerAdapter;
+import com.hmkcode.fragments.FirstFragment;
+import com.hmkcode.fragments.SecondFragment;
+
+public class MyFragmentPagerAdapter extends FragmentPagerAdapter {
+
+
+ public MyFragmentPagerAdapter(FragmentManager fm) {
+ super(fm);
+ }
+
+ @Override
+ public Fragment getItem(int position) {
+ switch (position) {
+ case 0:
+ return new FirstFragment();
+ case 1:
+ return new SecondFragment();
+ default:
+ return null;
+ }
+ }
+
+ @Override
+ public int getCount() {
+ return 2;
+ }
+}
\ No newline at end of file
diff --git a/android-swipe-views-tabs/app/src/main/java/com/hmkcode/fragments/FirstFragment.java b/android-swipe-views-tabs/app/src/main/java/com/hmkcode/fragments/FirstFragment.java
new file mode 100644
index 00000000..8ab86584
--- /dev/null
+++ b/android-swipe-views-tabs/app/src/main/java/com/hmkcode/fragments/FirstFragment.java
@@ -0,0 +1,25 @@
+package com.hmkcode.fragments;
+
+import android.os.Bundle;
+import android.support.v4.app.Fragment;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import com.hmkcode.R;
+
+public class FirstFragment extends Fragment {
+
+ public FirstFragment() {}
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ }
+
+ @Override
+ public View onCreateView(LayoutInflater inflater,
+ ViewGroup container,
+ Bundle savedInstanceState) {
+ return inflater.inflate(R.layout.fragment_first, container, false);
+ }
+}
\ No newline at end of file
diff --git a/android-swipe-views-tabs/app/src/main/java/com/hmkcode/fragments/SecondFragment.java b/android-swipe-views-tabs/app/src/main/java/com/hmkcode/fragments/SecondFragment.java
new file mode 100644
index 00000000..da79fc5a
--- /dev/null
+++ b/android-swipe-views-tabs/app/src/main/java/com/hmkcode/fragments/SecondFragment.java
@@ -0,0 +1,25 @@
+package com.hmkcode.fragments;
+
+import android.os.Bundle;
+import android.support.v4.app.Fragment;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import com.hmkcode.R;
+
+public class SecondFragment extends Fragment {
+
+ public SecondFragment() {}
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ }
+
+ @Override
+ public View onCreateView(LayoutInflater inflater,
+ ViewGroup container,
+ Bundle savedInstanceState) {
+ return inflater.inflate(R.layout.fragment_second, container, false);
+ }
+}
\ No newline at end of file
diff --git a/android-swipe-views-tabs/app/src/main/res/layout/activity_main.xml b/android-swipe-views-tabs/app/src/main/res/layout/activity_main.xml
new file mode 100644
index 00000000..84160625
--- /dev/null
+++ b/android-swipe-views-tabs/app/src/main/res/layout/activity_main.xml
@@ -0,0 +1,23 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/android-swipe-views-tabs/app/src/main/res/layout/fragment_first.xml b/android-swipe-views-tabs/app/src/main/res/layout/fragment_first.xml
new file mode 100644
index 00000000..fdc305ff
--- /dev/null
+++ b/android-swipe-views-tabs/app/src/main/res/layout/fragment_first.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/android-swipe-views-tabs/app/src/main/res/layout/fragment_second.xml b/android-swipe-views-tabs/app/src/main/res/layout/fragment_second.xml
new file mode 100644
index 00000000..e845e912
--- /dev/null
+++ b/android-swipe-views-tabs/app/src/main/res/layout/fragment_second.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/android-swipe-views-tabs/build.gradle b/android-swipe-views-tabs/build.gradle
new file mode 100644
index 00000000..98e76df1
--- /dev/null
+++ b/android-swipe-views-tabs/build.gradle
@@ -0,0 +1,27 @@
+// Top-level build file where you can add configuration options common to all sub-projects/modules.
+
+buildscript {
+ ext.kotlin_version = '1.2.61'
+ repositories {
+ google()
+ jcenter()
+ }
+ dependencies {
+ classpath 'com.android.tools.build:gradle:3.1.4'
+ classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
+
+ // NOTE: Do not place your application dependencies here; they belong
+ // in the individual module build.gradle files
+ }
+}
+
+allprojects {
+ repositories {
+ google()
+ jcenter()
+ }
+}
+
+task clean(type: Delete) {
+ delete rootProject.buildDir
+}
diff --git a/android-whatsapp-profile-screen/res/drawable-hdpi/balloon.png b/android-whatsapp-profile-screen/res/drawable-hdpi/balloon.png
new file mode 100644
index 00000000..844b4fa3
Binary files /dev/null and b/android-whatsapp-profile-screen/res/drawable-hdpi/balloon.png differ
diff --git a/android-whatsapp-profile-screen/res/drawable-hdpi/edit_states.xml b/android-whatsapp-profile-screen/res/drawable-hdpi/edit_states.xml
new file mode 100644
index 00000000..e9f2ee42
--- /dev/null
+++ b/android-whatsapp-profile-screen/res/drawable-hdpi/edit_states.xml
@@ -0,0 +1,15 @@
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+
\ No newline at end of file
diff --git a/android-whatsapp-profile-screen/res/drawable-hdpi/ic_action_edit.png b/android-whatsapp-profile-screen/res/drawable-hdpi/ic_action_edit.png
new file mode 100644
index 00000000..756db316
Binary files /dev/null and b/android-whatsapp-profile-screen/res/drawable-hdpi/ic_action_edit.png differ
diff --git a/android-whatsapp-profile-screen/res/drawable-hdpi/ic_action_new_event.png b/android-whatsapp-profile-screen/res/drawable-hdpi/ic_action_new_event.png
new file mode 100644
index 00000000..f01b43e4
Binary files /dev/null and b/android-whatsapp-profile-screen/res/drawable-hdpi/ic_action_new_event.png differ
diff --git a/android-whatsapp-profile-screen/res/drawable-hdpi/ic_launcher.png b/android-whatsapp-profile-screen/res/drawable-hdpi/ic_launcher.png
new file mode 100644
index 00000000..288b6655
Binary files /dev/null and b/android-whatsapp-profile-screen/res/drawable-hdpi/ic_launcher.png differ
diff --git a/android-whatsapp-profile-screen/res/drawable-hdpi/image_border.xml b/android-whatsapp-profile-screen/res/drawable-hdpi/image_border.xml
new file mode 100644
index 00000000..63f3a77a
--- /dev/null
+++ b/android-whatsapp-profile-screen/res/drawable-hdpi/image_border.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
diff --git a/android-whatsapp-profile-screen/res/drawable-hdpi/image_state.xml b/android-whatsapp-profile-screen/res/drawable-hdpi/image_state.xml
new file mode 100644
index 00000000..3c63b233
--- /dev/null
+++ b/android-whatsapp-profile-screen/res/drawable-hdpi/image_state.xml
@@ -0,0 +1,25 @@
+
+
+ -
+
+
+
+
+
+
+
+ -
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/android-whatsapp-profile-screen/res/drawable-hdpi/textview_border.xml b/android-whatsapp-profile-screen/res/drawable-hdpi/textview_border.xml
new file mode 100644
index 00000000..82b85c1c
--- /dev/null
+++ b/android-whatsapp-profile-screen/res/drawable-hdpi/textview_border.xml
@@ -0,0 +1,30 @@
+
+
+ -
+
+
+
+
+
+
+ -
+
+
+
+
+
+
+ -
+
+
+
+
+
+
+ -
+
+
+
+
+
+
\ No newline at end of file
diff --git a/android-whatsapp-profile-screen/res/layout/activity_main.xml b/android-whatsapp-profile-screen/res/layout/activity_main.xml
new file mode 100644
index 00000000..85d68a29
--- /dev/null
+++ b/android-whatsapp-profile-screen/res/layout/activity_main.xml
@@ -0,0 +1,78 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/intent-action-send/build.gradle b/intent-action-send/build.gradle
new file mode 100644
index 00000000..172b7399
--- /dev/null
+++ b/intent-action-send/build.gradle
@@ -0,0 +1,37 @@
+apply plugin: 'com.android.application'
+apply plugin: 'kotlin-android'
+apply plugin: 'kotlin-android-extensions'
+android {
+ compileSdkVersion 29
+ buildToolsVersion "29.0.2"
+
+
+ defaultConfig {
+ applicationId "com.hmkcode.intent_action_send"
+ minSdkVersion 19
+ targetSdkVersion 29
+ versionCode 1
+ versionName "1.0"
+
+ testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
+ }
+
+ buildTypes {
+ release {
+ minifyEnabled false
+ proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
+ }
+ }
+
+}
+
+dependencies {
+ implementation fileTree(dir: 'libs', include: ['*.jar'])
+ implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
+ implementation 'androidx.appcompat:appcompat:1.0.2'
+ implementation 'androidx.core:core-ktx:1.0.2'
+ implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
+ testImplementation 'junit:junit:4.12'
+ androidTestImplementation 'androidx.test.ext:junit:1.1.0'
+ androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
+}
diff --git a/intent-action-send/src/main/AndroidManifest.xml b/intent-action-send/src/main/AndroidManifest.xml
new file mode 100644
index 00000000..bc050409
--- /dev/null
+++ b/intent-action-send/src/main/AndroidManifest.xml
@@ -0,0 +1,28 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/intent-action-send/src/main/java/com/hmkcode/intent_action_send/MainActivity.kt b/intent-action-send/src/main/java/com/hmkcode/intent_action_send/MainActivity.kt
new file mode 100644
index 00000000..07508fc2
--- /dev/null
+++ b/intent-action-send/src/main/java/com/hmkcode/intent_action_send/MainActivity.kt
@@ -0,0 +1,36 @@
+package com.hmkcode.intent_action_send
+
+import android.content.Intent
+import androidx.appcompat.app.AppCompatActivity
+import android.os.Bundle
+import android.widget.Button
+import android.widget.TextView
+
+class MainActivity : AppCompatActivity() {
+
+ private lateinit var textView: TextView
+
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ setContentView(R.layout.activity_main)
+
+ val button = findViewById