Skip to content

Instantly share code, notes, and snippets.

View hiking93's full-sized avatar

Hsingchien Cheng (工程師 Hiking) hiking93

View GitHub Profile
@hiking93
hiking93 / ContextMenuListViewExample.kt
Created March 14, 2018 10:34
Register context menu with ListView
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
registerForContextMenu(listView)
}
override fun onCreateContextMenu(menu: ContextMenu, view: View,
menuInfo: ContextMenu.ContextMenuInfo?) {
activity!!.menuInflater.inflate(R.menu.context_menu, menu)
}
@hiking93
hiking93 / ContextMenuRecyclerView.kt
Last active February 27, 2019 18:04
RecyclerView with context menu implemented.
import android.content.Context
import android.support.v7.widget.RecyclerView
import android.util.AttributeSet
import android.view.ContextMenu
import android.view.View
/**
* Recycler view with context menu implemented.
*
* @author Hiking
@hiking93
hiking93 / ContextMenuExample_MainFragment.kt
Last active March 15, 2018 03:29
Context menu example.
import android.os.Bundle
import android.support.v4.app.Fragment
import android.support.v7.app.AlertDialog
import android.support.v7.widget.LinearLayoutManager
import android.view.*
import kotlinx.android.synthetic.main.fragment_main.*
class MainFragment : Fragment() {
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
@hiking93
hiking93 / ContextMenuExample_WrongViewHolder.kt
Created March 14, 2018 11:33
Wrong implementation of context menu view holder.
class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView), View.OnLongClickListener {
val titleTextView: TextView = itemView.titleTextView
val contentTextView: TextView = itemView.contentTextView
init {
this.itemView.setOnLongClickListener(this)
}
override fun onLongClick(v: View?): Boolean {
@hiking93
hiking93 / View_PerformLongClickInternal.java
Created March 15, 2018 03:20
Perform long click internal.
private boolean performLongClickInternal(float x, float y) {
sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_LONG_CLICKED);
boolean handled = false;
final ListenerInfo li = mListenerInfo;
if (li != null && li.mOnLongClickListener != null) {
handled = li.mOnLongClickListener.onLongClick(View.this);
}
if (!handled) {
final boolean isAnchored = !Float.isNaN(x) && !Float.isNaN(y);
@hiking93
hiking93 / 隱私權政策
Last active April 6, 2018 15:16
隱私權政策
Hiking Studio 於 Google Play 上提供之所有應用程式,均符合以下隱私權政策規範:
當您使用應用程式功能時,我們將視該服務功能性質,請您提供必要的應用程式權限,並在該特定目的範圍內處理及利用您的個人資料; 本應用程式不會將個人資料用於其他用途。本人不會於任何伺服器會自行記錄相關行徑,包括您使用連線設備的 IP 位址、使用時間、使用的瀏覽器、瀏覽及點選資料記錄等。  
本應用程式其他第三方應用程式的網路連結或廣告 SDK 行為,不適用本網站的隱私權保護政策,您必須參考該連結網站中或該廣告公司的隱私權保護政策。
本應用程式絕不會提供、交換、出租或出售任何您的個人資料給其他個人、團體、私人企業或公務機關。
本應用程式隱私權保護政策將因應需求隨時進行修正,修正後的條款將刊登於網站上。
@hiking93
hiking93 / dcard-mopub-tools.html
Created November 8, 2018 11:28
Dcard MoPub tools
<!DOCTYPE html>
<html lang="zh-Hant">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Dcard MoPub 工具集</title>
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons" />
<link rel="stylesheet" href="https://code.getmdl.io/1.3.0/material.teal-pink.min.css" />
@hiking93
hiking93 / VuzeVrFileDateSync.kt
Last active June 30, 2019 07:29
Vuze VR Studio rendering loses original file creation time. Sync date of rendered files with raw files.
import java.io.File
import java.nio.file.Files
import java.nio.file.Files.getFileAttributeView
import java.nio.file.Paths
import java.nio.file.attribute.BasicFileAttributeView
import java.nio.file.attribute.FileTime
import java.text.SimpleDateFormat
val rootDir = File("/path/to/root")
val rawDir = File(rootDir, "Raw")
@hiking93
hiking93 / ApkInstall.kt
Created November 25, 2019 10:25
Install APK in app
const val ANDROID_PACKAGE_ARCHIVE = "application/vnd.android.package-archive"
startActivity(Intent(Intent.ACTION_VIEW).apply {
flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_GRANT_READ_URI_PERMISSION
setDataAndType(uriForYourApk, MimeType.ANDROID_PACKAGE_ARCHIVE)
})
@hiking93
hiking93 / 抽籤.wy
Last active July 8, 2024 08:56
抽籤程式
吾有一數。曰三。名之曰「抽出人數」。
吾有一術。名之曰「運」。欲行是術。必先得一數。曰「值」。乃行是術曰。
乃得 Math.ceil(Math.random()*值);
是謂「運」之術也。
吾有一術。名之曰「克隆」。欲行是術。必先得一列。曰「列」。乃行是術曰。
吾有一列。名之曰「結果」。
凡「列」中之「物」。
充「結果」以「物」。