This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MainActivity : AppCompatActivity() { | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContentView(R.layout.activity_main) | |
val progress = findViewById<ProgressBar>(R.id.progress) | |
val txvProgress = findViewById<TextView>(R.id.txvProgress) | |
val img = findViewById<AppCompatImageView>(R.id.img) | |
val animator = ObjectAnimator.ofInt(progress, "progress", 1, 100) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> | |
<item> | |
<shape | |
android:shape="ring" | |
android:thicknessRatio="16" | |
android:useLevel="false"> | |
<solid android:color="#d0d0d0" /> | |
</shape> | |
</item> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:tools="http://schemas.android.com/tools" | |
xmlns:app="http://schemas.android.com/apk/res-auto" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
android:background="@color/black" | |
tools:context=".MainActivity"> | |
<androidx.appcompat.widget.AppCompatImageView |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class NetworkConnection(private val context: Context) : LiveData<Boolean>() { | |
private var connectivityManager: ConnectivityManager = context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager | |
private var networkCallback: ConnectivityManager.NetworkCallback? = null | |
override fun onActive() { | |
super.onActive() | |
updateConnection() | |
when{ | |
Build.VERSION.SDK_INT >= Build.VERSION_CODES.N -> { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MainActivity2 : AppCompatActivity(), Animation.AnimationListener { | |
private lateinit var binding: ActivityMain2Binding | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
binding = ActivityMain2Binding.inflate(layoutInflater) | |
setContentView(binding.root) | |
binding.img.setOnClickListener { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<set | |
xmlns:android="http://schemas.android.com/apk/res/android" | |
android:interpolator="@android:anim/linear_interpolator" | |
android:fillAfter="true"> | |
<translate | |
android:fromYDelta="0%p" | |
android:toYDelta="-100%p" | |
android:duration="1500" /> | |
</set> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:app="http://schemas.android.com/apk/res-auto" | |
xmlns:tools="http://schemas.android.com/tools" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
tools:context=".MainActivity2"> | |
<ImageView | |
android:id="@+id/img" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun getImageUri(inContext: Context, inImage: Bitmap): Uri { | |
val path: String = MediaStore.Images.Media.insertImage( | |
inContext.contentResolver, | |
inImage, | |
"Title", | |
null | |
) | |
Log.i("TAG", "getImageUri: $path") | |
return Uri.parse(path) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun getPath(context: Context, uri: Uri?): String? { | |
var cursor: Cursor? = null | |
return try { | |
val proj = arrayOf(MediaStore.Images.Media.DATA) | |
cursor = uri?.let { context.contentResolver.query(it, proj, null, null, null) } | |
val column_index = cursor!!.getColumnIndexOrThrow(MediaStore.Images.Media.DATA) | |
cursor.moveToFirst() | |
cursor.getString(column_index) | |
} catch (e: Exception) { | |
loge("getRealPathFromURI Exception : $e") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Throws(IOException::class) | |
fun saveImage(context: Context, bitmap: Bitmap, folderName: String, fileName: String): Uri? { | |
val fos: OutputStream? | |
var imageFile: File? = null | |
var imageUri: Uri? = null | |
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { | |
val resolver = context.contentResolver | |
val contentValues = ContentValues() | |
contentValues.put(MediaStore.MediaColumns.DISPLAY_NAME, fileName) | |
contentValues.put(MediaStore.MediaColumns.MIME_TYPE, "image/jpeg") |
NewerOlder