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"?> | |
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | |
package="com.example.mypackagereplaced" | |
android:versionCode="1" | |
android:versionName="1.0" > | |
<uses-sdk | |
android:minSdkVersion="8" | |
android:targetSdkVersion="17" /> |
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 cv2 | |
import numpy as np | |
img = cv2.imread('sudoku.jpg') | |
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) | |
gray = cv2.GaussianBlur(gray, (7, 7), 0) | |
thresh = cv2.adaptiveThreshold(gray, 255, 1, 1, 7, 2) | |
contours, hierarchy = cv2.findContours(thresh, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE) |
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
public class MyApplication extends Application { | |
@Override | |
public void onCreate() { | |
super.onCreate(); | |
SomeSdk.init(this); // init some SDK, MyApplication is the Context | |
} | |
} |
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
<application | |
android:icon="@mipmap/ic_launcher" | |
android:label="@string/app_name" | |
android:name="package.of.MyApplication" | |
... > |
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
<provider | |
android:authorities="${applicationId}.yourcontentprovider" | |
android:name=".YourContentProvider" | |
android:exported="false" /> |
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 NumberListAdapter : ListAdapter<Int, ViewHolder>(object : DiffUtil.ItemCallback<Int>() { | |
override fun areItemsTheSame(oldItem: Int?, newItem: Int?) = | |
oldItem == newItem // check uniqueness | |
override fun areContentsTheSame(oldItem: Int?, newItem: Int?) = | |
oldItem == newItem // check contents | |
}) { | |
... | |
} |
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 NumberViewHolder(parentView: View) : RecyclerView.ViewHolder( | |
LayoutInflater.from(parentView.context).inflate(R.layout.card_item, null, false)) { | |
private val numberView = itemView.findViewById<TextView>(R.id.number) | |
fun bindTo(position: Int) { | |
numberView.text = "# $position" | |
} | |
} |
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() { | |
private val numbersObservable: BehaviorSubject<List<Int>> | |
= BehaviorSubject.createDefault(listOf(0, 1, 2, 3, 4, 5, 6, 7, 8, 9)) | |
override fun onCreate(savedInstanceState: Bundle?) { | |
... | |
swipeRefreshLayout.setOnRefreshListener { | |
numbersObservable.onNext(listOf(1, 2, 4, 5, 6, 7, 8, 9)) // pass a new list without 0, 3 | |
} |
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 val DIFF_CALLBACK = object : DiffUtil.ItemCallback<Int>() { | |
override fun areItemsTheSame(oldItem: Int?, newItem: Int?) = | |
oldItem == newItem // check uniqueness | |
override fun areContentsTheSame(oldItem: Int?, newItem: Int?) = | |
oldItem == newItem // check contents | |
} |
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 onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
... | |
selectionTracker = SelectionTracker.Builder( | |
"selection-demo", | |
recyclerView, | |
StableIdKeyProvider(recyclerView), | |
itemDetailsLookup, | |
StorageStrategy.createLongStorage()) |
OlderNewer