This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| webview.setOnTouchListener(object: View.OnTouchListener { | |
| private var touchDownX: Float = -1f | |
| override fun onTouch(v: View, event: MotionEvent): Boolean { | |
| if (event.pointerCount > 1) { | |
| return true | |
| } | |
| when (event.action) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Cursor c = null; | |
| SubwayDatabaseHelper myDbHelper = new SubwayDatabaseHelper(MainActivity.this); // Reading SQLite database. | |
| try { | |
| myDbHelper.createDataBase(); | |
| } catch (IOException ioe) { | |
| throw new Error("Unable to create database"); | |
| } | |
| try { | |
| myDbHelper.openDataBase(); | |
| } catch (SQLException sqle) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| abstract class PaginationScrollListener(private val layoutManager: LinearLayoutManager) : | |
| RecyclerView.OnScrollListener() { | |
| override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) { | |
| super.onScrolled(recyclerView, dx, dy) | |
| val visibleItemCount: Int = layoutManager.childCount | |
| val totalItemCount: Int = layoutManager.itemCount | |
| val firstVisibleItemPosition: Int = layoutManager.findFirstVisibleItemPosition() | |
| if (!isLoading() && !isLastPage()) { | |
| if (visibleItemCount + firstVisibleItemPosition >= totalItemCount |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private fun printDirectoryTree(folder: File): String { | |
| if (!folder.isDirectory) { | |
| return String.empty() | |
| } | |
| val indent = 0 | |
| val sb = StringBuilder() | |
| printDirectoryTree(folder, indent, sb) | |
| return sb.toString() | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * ``` | |
| * // To post an event: | |
| * EventBus.send(SomeEvent()) | |
| * | |
| * // To subscribe to an event: | |
| * EventBus.register(this, SomeEvent::class) { event -> | |
| * } | |
| * | |
| * // To cancel a subscriber: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <androidx.constraintlayout.widget.ConstraintLayout | |
| android:layout_width="match_parent" | |
| android:layout_height="wrap_content"> | |
| <TextView | |
| android:id="@+id/tv_label_1" | |
| android:layout_width="wrap_content" | |
| android:layout_height="wrap_content" | |
| android:text="Label 1" | |
| app:layout_constraintStart_toStartOf="parent" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| et_name.filters = arrayOf(InputFilter { source, start, end, dest, dstart, dend -> | |
| val pattern = Pattern.compile("^[a-zA-Zㄱ-ㅎ가-힣ㅏ-ㅣ\\u318D\\u119E\\u11A2\\u2022\\u2025a\\u00B7\\uFE55]+$") | |
| if (pattern.matcher(source).matches()) { | |
| source | |
| } else { | |
| "" | |
| } | |
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * ``` | |
| * // To post an event: | |
| * EventBus.send(SomeEvent()) | |
| * | |
| * // To subscribe to an event: | |
| * EventBus.register(this, Dispatchers.Main, SomeEvent::class) { event -> | |
| * } | |
| * |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| override fun onCreate(savedInstanceState: Bundle?) { | |
| super.onCreate(savedInstanceState) | |
| activity?.onBackPressedDispatcher?.addCallback(this, object : OnBackPressedCallback(true) { | |
| override fun handleOnBackPressed() { | |
| // in here you can do logic when backPress is clicked | |
| } | |
| }) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import com.gargoylesoftware.htmlunit.WebClient | |
| import com.gargoylesoftware.htmlunit.html.HtmlDivision | |
| import com.gargoylesoftware.htmlunit.html.HtmlPage | |
| import org.jsoup.Jsoup | |
| import kotlin.system.measureTimeMillis | |
| data class Currency(val code: String, val engName: String) | |
| fun main() { | |
| val currencies = mutableListOf<Currency>() |
NewerOlder