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
import java.util.Random; | |
/** | |
* Clase MagicSquare realizada para el ejercicio de seminario de IP | |
* | |
* @author Fernando | |
* @version | |
*/ | |
public class MagicSquare | |
{ | |
public static final int MAX_SIZE = 10; |
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
import static org.junit.Assert.*; | |
import org.junit.After; | |
import org.junit.Before; | |
import org.junit.Test; | |
/** | |
* The test class MagicSquareTest. | |
* |
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
private fun deleteImages(uris: List<Uri>) { | |
val pendingIntent = MediaStore.createDeleteRequest(contentResolver, uris.filter { | |
checkUriPermission(it, Binder.getCallingPid(), Binder.getCallingUid(), Intent.FLAG_GRANT_WRITE_URI_PERMISSION) != PackageManager.PERMISSION_GRANTED | |
}) | |
startIntentSenderForResult(pendingIntent.intentSender, REQ_CODE, null, 0, 0, 0) | |
} | |
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { | |
super.onActivityResult(requestCode, resultCode, data) | |
if (requestCode == REQ_CODE && resultCode == Activity.RESULT_OK) { |
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
private fun overwriteImages(uris: List<Uri>) { | |
val pendingIntent = MediaStore.createWriteRequest(contentResolver, uris) | |
startIntentSenderForResult(pendingIntent.intentSender, REQ_CODE, null, 0, 0, 0) | |
} |
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
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { | |
super.onActivityResult(requestCode, resultCode, data) | |
if (requestCode == REQ_CODE && resultCode == Activity.RESULT_OK) { | |
val intent = Intent(this, MyService::class.java) | |
intent.data = uri | |
intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION) | |
startService(intent) | |
} | |
} |
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
val imeInsets = view.rootWindowInsets.getInsets(WindowInsets.Type.ime()) | |
if (imeInsets.isVisible()) { | |
// Move view by the height of the IME | |
view.translationX = imeInsets.bottom | |
} |
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
val inputLayoutMarginBottom = inputLayout.marginBottom | |
val callback = object : WindowInsetsAnimation.Callback(DISPATCH_MODE_STOP) { | |
override fun onProgress(insets: WindowInsets, animations: MutableList<WindowInsetsAnimation>): WindowInsets { | |
inputLayout.updateLayoutParams<ViewGroup.MarginLayoutParams> { | |
updateMargins(bottom = inputLayoutMarginBottom + | |
insets.getInsets(WindowInsets.Type.ime()).bottom) | |
} | |
return insets | |
} | |
} |
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
val listener = object : WindowInsetsAnimationControlListener { | |
override fun onCancelled() { | |
animationController = null | |
} | |
override fun onReady(controller: WindowInsetsAnimationController, types: Int) { | |
animationController = controller | |
} | |
} |
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
scrollView.viewTreeObserver.addOnScrollChangedListener { | |
animationController?.setInsetsAndAlpha(Insets.of(0, 0, 0, scrollView.scrollY), 1f, 0f) | |
} |
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
view.setOnApplyWindowInsetsListener { view, windowInsets -> | |
val systemWindowInsets = windowInsets.getInsets(WindowInsets.Type.systemBars()) | |
// It's also possible to use multiple types | |
val insets = windowInsets.getInsets( | |
WindowInsets.Type.ime() or | |
WindowInsets.Type.systemGestures() | |
) | |
windowInsets | |
} |
OlderNewer